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,863 | static int ohci_eof_timer_pre_load(void *opaque)
{
OHCIState *ohci = opaque;
ohci_bus_start(ohci);
return 0;
}
| true | qemu | fa1298c2d623522eda7b4f1f721fcb935abb7360 | static int ohci_eof_timer_pre_load(void *opaque)
{
OHCIState *ohci = opaque;
ohci_bus_start(ohci);
return 0;
}
| {
"code": [
"static int ohci_eof_timer_pre_load(void *opaque)",
" OHCIState *ohci = opaque;",
" ohci_bus_start(ohci);",
" return 0;"
],
"line_no": [
1,
5,
9,
13
]
} | static int FUNC_0(void *VAR_0)
{
OHCIState *ohci = VAR_0;
ohci_bus_start(ohci);
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"OHCIState *ohci = VAR_0;",
"ohci_bus_start(ohci);",
"return 0;",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
]
] |
19,865 | envlist_free(envlist_t *envlist)
{
struct envlist_entry *entry;
assert(envlist != NULL);
while (envlist->el_entries.lh_first != NULL) {
entry = envlist->el_entries.lh_first;
QLIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
}
free(envlist);
}
| true | qemu | ec45bbe5f1921c6553fbf9c0c76b358b0403c22d | envlist_free(envlist_t *envlist)
{
struct envlist_entry *entry;
assert(envlist != NULL);
while (envlist->el_entries.lh_first != NULL) {
entry = envlist->el_entries.lh_first;
QLIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
}
free(envlist);
}
| {
"code": [
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);",
"\tfree(envlist);",
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);",
"\t\tfree(entry);",
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);"
],
"line_no": [
21,
23,
27,
21,
23,
23,
21,
23
]
} | FUNC_0(envlist_t *VAR_0)
{
struct envlist_entry *VAR_1;
assert(VAR_0 != NULL);
while (VAR_0->el_entries.lh_first != NULL) {
VAR_1 = VAR_0->el_entries.lh_first;
QLIST_REMOVE(VAR_1, ev_link);
free((char *)VAR_1->ev_var);
free(VAR_1);
}
free(VAR_0);
}
| [
"FUNC_0(envlist_t *VAR_0)\n{",
"struct envlist_entry *VAR_1;",
"assert(VAR_0 != NULL);",
"while (VAR_0->el_entries.lh_first != NULL) {",
"VAR_1 = VAR_0->el_entries.lh_first;",
"QLIST_REMOVE(VAR_1, ev_link);",
"free((char *)VAR_1->ev_var);",
"free(VAR_1);",
"}",
"free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
19,867 | static void test_visitor_in_intList(TestInputVisitorData *data,
const void *unused)
{
/* Note: the visitor *sorts* ranges *unsigned* */
int64_t expect1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 };
int64_t expect2[] = { 32767, -32768, -32767 };
int64_t expect3[] = { INT64_MAX, INT64_MIN };
uint64_t expect4[] = { UINT64_MAX };
Error *err = NULL;
int64List *res = NULL;
int64List *tail;
Visitor *v;
int64_t val;
/* Valid lists */
v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8");
check_ilist(v, expect1, ARRAY_SIZE(expect1));
v = visitor_input_test_init(data, "32767,-32768--32767");
check_ilist(v, expect2, ARRAY_SIZE(expect2));
v = visitor_input_test_init(data,
"-9223372036854775808,9223372036854775807");
check_ilist(v, expect3, ARRAY_SIZE(expect3));
v = visitor_input_test_init(data, "18446744073709551615");
check_ulist(v, expect4, ARRAY_SIZE(expect4));
/* Empty list is invalid (weird) */
v = visitor_input_test_init(data, "");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
/* Not a list */
v = visitor_input_test_init(data, "not an int list");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
/* Unvisited list tail */
v = visitor_input_test_init(data, "0,2-3");
/* Would be simpler if the visitor genuinely supported virtual walks */
visit_type_int64(v, NULL, &tail->value, &error_abort);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_type_int64(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 2);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_check_list(v, &err);
error_free_or_abort(&err);
} | true | qemu | a9416dc62c36079b93b4951c894a0b15e53bb38c | static void test_visitor_in_intList(TestInputVisitorData *data,
const void *unused)
{
int64_t expect1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 };
int64_t expect2[] = { 32767, -32768, -32767 };
int64_t expect3[] = { INT64_MAX, INT64_MIN };
uint64_t expect4[] = { UINT64_MAX };
Error *err = NULL;
int64List *res = NULL;
int64List *tail;
Visitor *v;
int64_t val;
v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8");
check_ilist(v, expect1, ARRAY_SIZE(expect1));
v = visitor_input_test_init(data, "32767,-32768--32767");
check_ilist(v, expect2, ARRAY_SIZE(expect2));
v = visitor_input_test_init(data,
"-9223372036854775808,9223372036854775807");
check_ilist(v, expect3, ARRAY_SIZE(expect3));
v = visitor_input_test_init(data, "18446744073709551615");
check_ulist(v, expect4, ARRAY_SIZE(expect4));
v = visitor_input_test_init(data, "");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
v = visitor_input_test_init(data, "not an int list");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
v = visitor_input_test_init(data, "0,2-3");
visit_type_int64(v, NULL, &tail->value, &error_abort);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_type_int64(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 2);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_check_list(v, &err);
error_free_or_abort(&err);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
int64_t expect1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 };
int64_t expect2[] = { 32767, -32768, -32767 };
int64_t expect3[] = { INT64_MAX, INT64_MIN };
uint64_t expect4[] = { UINT64_MAX };
Error *err = NULL;
int64List *res = NULL;
int64List *tail;
Visitor *v;
int64_t val;
v = visitor_input_test_init(VAR_0, "1,2,0,2-4,20,5-9,1-8");
check_ilist(v, expect1, ARRAY_SIZE(expect1));
v = visitor_input_test_init(VAR_0, "32767,-32768--32767");
check_ilist(v, expect2, ARRAY_SIZE(expect2));
v = visitor_input_test_init(VAR_0,
"-9223372036854775808,9223372036854775807");
check_ilist(v, expect3, ARRAY_SIZE(expect3));
v = visitor_input_test_init(VAR_0, "18446744073709551615");
check_ulist(v, expect4, ARRAY_SIZE(expect4));
v = visitor_input_test_init(VAR_0, "");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
v = visitor_input_test_init(VAR_0, "not an int list");
visit_type_int64List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
v = visitor_input_test_init(VAR_0, "0,2-3");
visit_type_int64(v, NULL, &tail->value, &error_abort);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_type_int64(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 2);
tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));
g_assert(tail);
visit_check_list(v, &err);
error_free_or_abort(&err);
} | [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"int64_t expect1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 };",
"int64_t expect2[] = { 32767, -32768, -32767 };",
"int64_t expect3[] = { INT64_MAX, INT64_MIN };",
"uint64_t expect4[] = { UINT64_MAX };",
"Error *err = NULL;",
"int64List *res = NULL;",
"int64List *tail;",
"Visitor *v;",
"int64_t val;",
"v = visitor_input_test_init(VAR_0, \"1,2,0,2-4,20,5-9,1-8\");",
"check_ilist(v, expect1, ARRAY_SIZE(expect1));",
"v = visitor_input_test_init(VAR_0, \"32767,-32768--32767\");",
"check_ilist(v, expect2, ARRAY_SIZE(expect2));",
"v = visitor_input_test_init(VAR_0,\n\"-9223372036854775808,9223372036854775807\");",
"check_ilist(v, expect3, ARRAY_SIZE(expect3));",
"v = visitor_input_test_init(VAR_0, \"18446744073709551615\");",
"check_ulist(v, expect4, ARRAY_SIZE(expect4));",
"v = visitor_input_test_init(VAR_0, \"\");",
"visit_type_int64List(v, NULL, &res, &err);",
"error_free_or_abort(&err);",
"v = visitor_input_test_init(VAR_0, \"not an int list\");",
"visit_type_int64List(v, NULL, &res, &err);",
"error_free_or_abort(&err);",
"g_assert(!res);",
"v = visitor_input_test_init(VAR_0, \"0,2-3\");",
"visit_type_int64(v, NULL, &tail->value, &error_abort);",
"tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));",
"g_assert(tail);",
"visit_type_int64(v, NULL, &tail->value, &error_abort);",
"g_assert_cmpint(tail->value, ==, 2);",
"tail = (int64List *)visit_next_list(v, (GenericList *)tail, sizeof(*res));",
"g_assert(tail);",
"visit_check_list(v, &err);",
"error_free_or_abort(&err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19,
20
],
[
21
],
[
22
],
[
23
],
[
25
],
[
26
],
[
27
],
[
29
],
[
30
],
[
31
],
[
32
],
[
34
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
]
] |
19,868 | static void put_unused_buffer(QEMUFile *f, void *pv, size_t size)
{
static const uint8_t buf[1024];
int block_len;
while (size > 0) {
block_len = MIN(sizeof(buf), size);
size -= block_len;
qemu_put_buffer(f, buf, block_len);
}
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void put_unused_buffer(QEMUFile *f, void *pv, size_t size)
{
static const uint8_t buf[1024];
int block_len;
while (size > 0) {
block_len = MIN(sizeof(buf), size);
size -= block_len;
qemu_put_buffer(f, buf, block_len);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
static const uint8_t VAR_3[1024];
int VAR_4;
while (VAR_2 > 0) {
VAR_4 = MIN(sizeof(VAR_3), VAR_2);
VAR_2 -= VAR_4;
qemu_put_buffer(VAR_0, VAR_3, VAR_4);
}
}
| [
"static void FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"static const uint8_t VAR_3[1024];",
"int VAR_4;",
"while (VAR_2 > 0) {",
"VAR_4 = MIN(sizeof(VAR_3), VAR_2);",
"VAR_2 -= VAR_4;",
"qemu_put_buffer(VAR_0, VAR_3, VAR_4);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,869 | static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str)
{
BDRVQcowState *s = bs->opaque;
int i;
for(i = 0; i < s->nb_snapshots; i++) {
if (!strcmp(s->snapshots[i].id_str, id_str))
return i;
}
return -1;
}
| true | qemu | a89d89d3e65800fa4a8e00de7af0ea8272bef779 | static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str)
{
BDRVQcowState *s = bs->opaque;
int i;
for(i = 0; i < s->nb_snapshots; i++) {
if (!strcmp(s->snapshots[i].id_str, id_str))
return i;
}
return -1;
}
| {
"code": [
"static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str)",
" for(i = 0; i < s->nb_snapshots; i++) {",
" if (!strcmp(s->snapshots[i].id_str, id_str))",
" return i;",
" BDRVQcowState *s = bs->opaque;",
" for(i = 0; i < s->nb_snapshots; i++) {",
" return i;",
" return -1;"
],
"line_no": [
1,
11,
13,
15,
5,
11,
15,
19
]
} | static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_2;
for(VAR_2 = 0; VAR_2 < s->nb_snapshots; VAR_2++) {
if (!strcmp(s->snapshots[VAR_2].VAR_1, VAR_1))
return VAR_2;
}
return -1;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_2;",
"for(VAR_2 = 0; VAR_2 < s->nb_snapshots; VAR_2++) {",
"if (!strcmp(s->snapshots[VAR_2].VAR_1, VAR_1))\nreturn VAR_2;",
"}",
"return -1;",
"}"
] | [
1,
1,
0,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
]
] |
19,870 | static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
int x, int y, int w, int h)
{
DisplaySurface *surface = qemu_console_surface(s->vga.con);
int line;
int bypl;
int width;
int start;
uint8_t *src;
uint8_t *dst;
if (x < 0) {
fprintf(stderr, "%s: update x was < 0 (%d)\n", __func__, x);
w += x;
x = 0;
}
if (w < 0) {
fprintf(stderr, "%s: update w was < 0 (%d)\n", __func__, w);
w = 0;
}
if (x + w > surface_width(surface)) {
fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
__func__, x, w);
x = MIN(x, surface_width(surface));
w = surface_width(surface) - x;
}
if (y < 0) {
fprintf(stderr, "%s: update y was < 0 (%d)\n", __func__, y);
h += y;
y = 0;
}
if (h < 0) {
fprintf(stderr, "%s: update h was < 0 (%d)\n", __func__, h);
h = 0;
}
if (y + h > surface_height(surface)) {
fprintf(stderr, "%s: update height too large y: %d, h: %d\n",
__func__, y, h);
y = MIN(y, surface_height(surface));
h = surface_height(surface) - y;
}
bypl = surface_stride(surface);
width = surface_bytes_per_pixel(surface) * w;
start = surface_bytes_per_pixel(surface) * x + bypl * y;
src = s->vga.vram_ptr + start;
dst = surface_data(surface) + start;
for (line = h; line > 0; line--, src += bypl, dst += bypl) {
memcpy(dst, src, width);
}
dpy_gfx_update(s->vga.con, x, y, w, h);
}
| true | qemu | 1735fe1edba9cc86bc0f26937ed5a62d3cb47c9c | static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
int x, int y, int w, int h)
{
DisplaySurface *surface = qemu_console_surface(s->vga.con);
int line;
int bypl;
int width;
int start;
uint8_t *src;
uint8_t *dst;
if (x < 0) {
fprintf(stderr, "%s: update x was < 0 (%d)\n", __func__, x);
w += x;
x = 0;
}
if (w < 0) {
fprintf(stderr, "%s: update w was < 0 (%d)\n", __func__, w);
w = 0;
}
if (x + w > surface_width(surface)) {
fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
__func__, x, w);
x = MIN(x, surface_width(surface));
w = surface_width(surface) - x;
}
if (y < 0) {
fprintf(stderr, "%s: update y was < 0 (%d)\n", __func__, y);
h += y;
y = 0;
}
if (h < 0) {
fprintf(stderr, "%s: update h was < 0 (%d)\n", __func__, h);
h = 0;
}
if (y + h > surface_height(surface)) {
fprintf(stderr, "%s: update height too large y: %d, h: %d\n",
__func__, y, h);
y = MIN(y, surface_height(surface));
h = surface_height(surface) - y;
}
bypl = surface_stride(surface);
width = surface_bytes_per_pixel(surface) * w;
start = surface_bytes_per_pixel(surface) * x + bypl * y;
src = s->vga.vram_ptr + start;
dst = surface_data(surface) + start;
for (line = h; line > 0; line--, src += bypl, dst += bypl) {
memcpy(dst, src, width);
}
dpy_gfx_update(s->vga.con, x, y, w, h);
}
| {
"code": [
" if (x < 0) {",
" fprintf(stderr, \"%s: update x was < 0 (%d)\\n\", __func__, x);",
" w += x;",
" if (w < 0) {",
" fprintf(stderr, \"%s: update w was < 0 (%d)\\n\", __func__, w);",
" w = 0;",
" if (x + w > surface_width(surface)) {",
" fprintf(stderr, \"%s: update width too large x: %d, w: %d\\n\",",
" __func__, x, w);",
" x = MIN(x, surface_width(surface));",
" w = surface_width(surface) - x;",
" if (y < 0) {",
" fprintf(stderr, \"%s: update y was < 0 (%d)\\n\", __func__, y);",
" h += y;",
" if (h < 0) {",
" fprintf(stderr, \"%s: update h was < 0 (%d)\\n\", __func__, h);",
" h = 0;",
" if (y + h > surface_height(surface)) {",
" fprintf(stderr, \"%s: update height too large y: %d, h: %d\\n\",",
" __func__, y, h);",
" y = MIN(y, surface_height(surface));",
" h = surface_height(surface) - y;"
],
"line_no": [
23,
25,
27,
33,
35,
37,
41,
43,
45,
47,
49,
55,
57,
59,
65,
67,
69,
73,
75,
77,
79,
81
]
} | static inline void FUNC_0(struct vmsvga_state_s *VAR_0,
int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{
DisplaySurface *surface = qemu_console_surface(VAR_0->vga.con);
int VAR_5;
int VAR_6;
int VAR_7;
int VAR_8;
uint8_t *src;
uint8_t *dst;
if (VAR_1 < 0) {
fprintf(stderr, "%VAR_0: update VAR_1 was < 0 (%d)\n", __func__, VAR_1);
VAR_3 += VAR_1;
VAR_1 = 0;
}
if (VAR_3 < 0) {
fprintf(stderr, "%VAR_0: update VAR_3 was < 0 (%d)\n", __func__, VAR_3);
VAR_3 = 0;
}
if (VAR_1 + VAR_3 > surface_width(surface)) {
fprintf(stderr, "%VAR_0: update VAR_7 too large VAR_1: %d, VAR_3: %d\n",
__func__, VAR_1, VAR_3);
VAR_1 = MIN(VAR_1, surface_width(surface));
VAR_3 = surface_width(surface) - VAR_1;
}
if (VAR_2 < 0) {
fprintf(stderr, "%VAR_0: update VAR_2 was < 0 (%d)\n", __func__, VAR_2);
VAR_4 += VAR_2;
VAR_2 = 0;
}
if (VAR_4 < 0) {
fprintf(stderr, "%VAR_0: update VAR_4 was < 0 (%d)\n", __func__, VAR_4);
VAR_4 = 0;
}
if (VAR_2 + VAR_4 > surface_height(surface)) {
fprintf(stderr, "%VAR_0: update height too large VAR_2: %d, VAR_4: %d\n",
__func__, VAR_2, VAR_4);
VAR_2 = MIN(VAR_2, surface_height(surface));
VAR_4 = surface_height(surface) - VAR_2;
}
VAR_6 = surface_stride(surface);
VAR_7 = surface_bytes_per_pixel(surface) * VAR_3;
VAR_8 = surface_bytes_per_pixel(surface) * VAR_1 + VAR_6 * VAR_2;
src = VAR_0->vga.vram_ptr + VAR_8;
dst = surface_data(surface) + VAR_8;
for (VAR_5 = VAR_4; VAR_5 > 0; VAR_5--, src += VAR_6, dst += VAR_6) {
memcpy(dst, src, VAR_7);
}
dpy_gfx_update(VAR_0->vga.con, VAR_1, VAR_2, VAR_3, VAR_4);
}
| [
"static inline void FUNC_0(struct vmsvga_state_s *VAR_0,\nint VAR_1, int VAR_2, int VAR_3, int VAR_4)\n{",
"DisplaySurface *surface = qemu_console_surface(VAR_0->vga.con);",
"int VAR_5;",
"int VAR_6;",
"int VAR_7;",
"int VAR_8;",
"uint8_t *src;",
"uint8_t *dst;",
"if (VAR_1 < 0) {",
"fprintf(stderr, \"%VAR_0: update VAR_1 was < 0 (%d)\\n\", __func__, VAR_1);",
"VAR_3 += VAR_1;",
"VAR_1 = 0;",
"}",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"%VAR_0: update VAR_3 was < 0 (%d)\\n\", __func__, VAR_3);",
"VAR_3 = 0;",
"}",
"if (VAR_1 + VAR_3 > surface_width(surface)) {",
"fprintf(stderr, \"%VAR_0: update VAR_7 too large VAR_1: %d, VAR_3: %d\\n\",\n__func__, VAR_1, VAR_3);",
"VAR_1 = MIN(VAR_1, surface_width(surface));",
"VAR_3 = surface_width(surface) - VAR_1;",
"}",
"if (VAR_2 < 0) {",
"fprintf(stderr, \"%VAR_0: update VAR_2 was < 0 (%d)\\n\", __func__, VAR_2);",
"VAR_4 += VAR_2;",
"VAR_2 = 0;",
"}",
"if (VAR_4 < 0) {",
"fprintf(stderr, \"%VAR_0: update VAR_4 was < 0 (%d)\\n\", __func__, VAR_4);",
"VAR_4 = 0;",
"}",
"if (VAR_2 + VAR_4 > surface_height(surface)) {",
"fprintf(stderr, \"%VAR_0: update height too large VAR_2: %d, VAR_4: %d\\n\",\n__func__, VAR_2, VAR_4);",
"VAR_2 = MIN(VAR_2, surface_height(surface));",
"VAR_4 = surface_height(surface) - VAR_2;",
"}",
"VAR_6 = surface_stride(surface);",
"VAR_7 = surface_bytes_per_pixel(surface) * VAR_3;",
"VAR_8 = surface_bytes_per_pixel(surface) * VAR_1 + VAR_6 * VAR_2;",
"src = VAR_0->vga.vram_ptr + VAR_8;",
"dst = surface_data(surface) + VAR_8;",
"for (VAR_5 = VAR_4; VAR_5 > 0; VAR_5--, src += VAR_6, dst += VAR_6) {",
"memcpy(dst, src, VAR_7);",
"}",
"dpy_gfx_update(VAR_0->vga.con, VAR_1, VAR_2, VAR_3, VAR_4);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
1,
1,
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
]
] |
19,871 | static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *buf;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int i;
int end = 0;
// determine cues start and end positions
for (i = 0; i < seekhead_list->nb_elem; i++)
if (seekhead[i].id == MATROSKA_ID_CUES)
break;
if (i >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[i].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
// cues_end is computed as cues_start + cues_length + length of the
// Cues element ID + EBML length of the Cues element. cues_end is
// inclusive and the above sum is reduced by 1.
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
// parse the cues
matroska_parse_cues(matroska);
// cues start
av_dict_set_int(&s->streams[0]->metadata, CUES_START, cues_start, 0);
// cues end
av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0);
// if the file has cues at the start, fix up the init range so tht
// it does not include it
if (cues_start <= init_range)
av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0);
// bandwidth
bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&s->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
// check if all clusters start with key frames
av_dict_set_int(&s->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(s), 0);
// store cue point timestamps as a comma separated list for checking subsegment alignment in
// the muxer. assumes that each timestamp cannot be more than 20 characters long.
buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!buf) return -1;
strcpy(buf, "");
for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
int ret = snprintf(buf + end, 20 * sizeof(char),
"%" PRId64, s->streams[0]->index_entries[i].timestamp);
if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries - 1)) {
av_log(s, AV_LOG_ERROR, "timestamp too long.\n");
return AVERROR_INVALIDDATA;
}
end += ret;
if (i != s->streams[0]->nb_index_entries - 1) {
strncat(buf, ",", sizeof(char));
end++;
}
}
av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0);
return 0;
} | true | FFmpeg | cc25a887c5467be5c7b004665047a32d36c9cf42 | static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
{
MatroskaDemuxContext *matroska = s->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *buf;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int i;
int end = 0;
for (i = 0; i < seekhead_list->nb_elem; i++)
if (seekhead[i].id == MATROSKA_ID_CUES)
break;
if (i >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[i].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
matroska_parse_cues(matroska);
av_dict_set_int(&s->streams[0]->metadata, CUES_START, cues_start, 0);
av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0);
if (cues_start <= init_range)
av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0);
bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&s->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
av_dict_set_int(&s->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(s), 0);
buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!buf) return -1;
strcpy(buf, "");
for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
int ret = snprintf(buf + end, 20 * sizeof(char),
"%" PRId64, s->streams[0]->index_entries[i].timestamp);
if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries - 1)) {
av_log(s, AV_LOG_ERROR, "timestamp too long.\n");
return AVERROR_INVALIDDATA;
}
end += ret;
if (i != s->streams[0]->nb_index_entries - 1) {
strncat(buf, ",", sizeof(char));
end++;
}
}
av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1)
{
MatroskaDemuxContext *matroska = VAR_0->priv_data;
EbmlList *seekhead_list = &matroska->seekhead;
MatroskaSeekhead *seekhead = seekhead_list->elem;
char *VAR_2;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int VAR_3;
int VAR_4 = 0;
for (VAR_3 = 0; VAR_3 < seekhead_list->nb_elem; VAR_3++)
if (seekhead[VAR_3].id == MATROSKA_ID_CUES)
break;
if (VAR_3 >= seekhead_list->nb_elem) return -1;
before_pos = avio_tell(matroska->ctx->pb);
cues_start = seekhead[VAR_3].pos + matroska->segment_start;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
cues_end = cues_start + cues_length + bytes_read - 1;
}
avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
if (cues_start == -1 || cues_end == -1) return -1;
matroska_parse_cues(matroska);
av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_START, cues_start, 0);
av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_END, cues_end, 0);
if (cues_start <= VAR_1)
av_dict_set_int(&VAR_0->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0);
bandwidth = webm_dash_manifest_compute_bandwidth(VAR_0, cues_start);
if (bandwidth < 0) return -1;
av_dict_set_int(&VAR_0->streams[0]->metadata, BANDWIDTH, bandwidth, 0);
av_dict_set_int(&VAR_0->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(VAR_0), 0);
VAR_2 = av_malloc_array(VAR_0->streams[0]->nb_index_entries, 20 * sizeof(char));
if (!VAR_2) return -1;
strcpy(VAR_2, "");
for (VAR_3 = 0; VAR_3 < VAR_0->streams[0]->nb_index_entries; VAR_3++) {
int ret = snprintf(VAR_2 + VAR_4, 20 * sizeof(char),
"%" PRId64, VAR_0->streams[0]->index_entries[VAR_3].timestamp);
if (ret <= 0 || (ret == 20 && VAR_3 == VAR_0->streams[0]->nb_index_entries - 1)) {
av_log(VAR_0, AV_LOG_ERROR, "timestamp too long.\n");
return AVERROR_INVALIDDATA;
}
VAR_4 += ret;
if (VAR_3 != VAR_0->streams[0]->nb_index_entries - 1) {
strncat(VAR_2, ",", sizeof(char));
VAR_4++;
}
}
av_dict_set(&VAR_0->streams[0]->metadata, CUE_TIMESTAMPS, VAR_2, 0);
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1)\n{",
"MatroskaDemuxContext *matroska = VAR_0->priv_data;",
"EbmlList *seekhead_list = &matroska->seekhead;",
"MatroskaSeekhead *seekhead = seekhead_list->elem;",
"char *VAR_2;",
"int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;",
"int VAR_3;",
"int VAR_4 = 0;",
"for (VAR_3 = 0; VAR_3 < seekhead_list->nb_elem; VAR_3++)",
"if (seekhead[VAR_3].id == MATROSKA_ID_CUES)\nbreak;",
"if (VAR_3 >= seekhead_list->nb_elem) return -1;",
"before_pos = avio_tell(matroska->ctx->pb);",
"cues_start = seekhead[VAR_3].pos + matroska->segment_start;",
"if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {",
"uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;",
"bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);",
"bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);",
"cues_end = cues_start + cues_length + bytes_read - 1;",
"}",
"avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);",
"if (cues_start == -1 || cues_end == -1) return -1;",
"matroska_parse_cues(matroska);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_START, cues_start, 0);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CUES_END, cues_end, 0);",
"if (cues_start <= VAR_1)\nav_dict_set_int(&VAR_0->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0);",
"bandwidth = webm_dash_manifest_compute_bandwidth(VAR_0, cues_start);",
"if (bandwidth < 0) return -1;",
"av_dict_set_int(&VAR_0->streams[0]->metadata, BANDWIDTH, bandwidth, 0);",
"av_dict_set_int(&VAR_0->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(VAR_0), 0);",
"VAR_2 = av_malloc_array(VAR_0->streams[0]->nb_index_entries, 20 * sizeof(char));",
"if (!VAR_2) return -1;",
"strcpy(VAR_2, \"\");",
"for (VAR_3 = 0; VAR_3 < VAR_0->streams[0]->nb_index_entries; VAR_3++) {",
"int ret = snprintf(VAR_2 + VAR_4, 20 * sizeof(char),\n\"%\" PRId64, VAR_0->streams[0]->index_entries[VAR_3].timestamp);",
"if (ret <= 0 || (ret == 20 && VAR_3 == VAR_0->streams[0]->nb_index_entries - 1)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"timestamp too long.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_4 += ret;",
"if (VAR_3 != VAR_0->streams[0]->nb_index_entries - 1) {",
"strncat(VAR_2, \",\", sizeof(char));",
"VAR_4++;",
"}",
"}",
"av_dict_set(&VAR_0->streams[0]->metadata, CUE_TIMESTAMPS, VAR_2, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
71
],
[
77
],
[
85,
87
],
[
93
],
[
95
],
[
97
],
[
103
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
128
],
[
130
],
[
132
],
[
134
],
[
136
],
[
138
],
[
140
],
[
142
],
[
144
],
[
149
],
[
151
]
] |
19,872 | int avresample_convert(AVAudioResampleContext *avr, void **output,
int out_plane_size, int out_samples, void **input,
int in_plane_size, int in_samples)
{
AudioData input_buffer;
AudioData output_buffer;
AudioData *current_buffer;
int ret;
/* reset internal buffers */
if (avr->in_buffer) {
avr->in_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->in_buffer,
avr->in_buffer->allocated_channels);
}
if (avr->resample_out_buffer) {
avr->resample_out_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->resample_out_buffer,
avr->resample_out_buffer->allocated_channels);
}
if (avr->out_buffer) {
avr->out_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->out_buffer,
avr->out_buffer->allocated_channels);
}
av_dlog(avr, "[start conversion]\n");
/* initialize output_buffer with output data */
if (output) {
ret = ff_audio_data_init(&output_buffer, output, out_plane_size,
avr->out_channels, out_samples,
avr->out_sample_fmt, 0, "output");
if (ret < 0)
return ret;
output_buffer.nb_samples = 0;
}
if (input) {
/* initialize input_buffer with input data */
ret = ff_audio_data_init(&input_buffer, input, in_plane_size,
avr->in_channels, in_samples,
avr->in_sample_fmt, 1, "input");
if (ret < 0)
return ret;
current_buffer = &input_buffer;
if (avr->upmix_needed && !avr->in_convert_needed && !avr->resample_needed &&
!avr->out_convert_needed && output && out_samples >= in_samples) {
/* in some rare cases we can copy input to output and upmix
directly in the output buffer */
av_dlog(avr, "[copy] %s to output\n", current_buffer->name);
ret = ff_audio_data_copy(&output_buffer, current_buffer);
if (ret < 0)
return ret;
current_buffer = &output_buffer;
} else if (avr->mixing_needed || avr->in_convert_needed) {
/* if needed, copy or convert input to in_buffer, and downmix if
applicable */
if (avr->in_convert_needed) {
ret = ff_audio_data_realloc(avr->in_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[convert] %s to in_buffer\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_in, avr->in_buffer, current_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
} else {
av_dlog(avr, "[copy] %s to in_buffer\n", current_buffer->name);
ret = ff_audio_data_copy(avr->in_buffer, current_buffer);
if (ret < 0)
return ret;
}
ff_audio_data_set_channels(avr->in_buffer, avr->in_channels);
if (avr->downmix_needed) {
av_dlog(avr, "[downmix] in_buffer\n");
ret = ff_audio_mix(avr->am, avr->in_buffer);
if (ret < 0)
return ret;
}
current_buffer = avr->in_buffer;
}
} else {
/* flush resampling buffer and/or output FIFO if input is NULL */
if (!avr->resample_needed)
return handle_buffered_output(avr, output ? &output_buffer : NULL,
NULL);
current_buffer = NULL;
}
if (avr->resample_needed) {
AudioData *resample_out;
int consumed = 0;
if (!avr->out_convert_needed && output && out_samples > 0)
resample_out = &output_buffer;
else
resample_out = avr->resample_out_buffer;
av_dlog(avr, "[resample] %s to %s\n", current_buffer->name,
resample_out->name);
ret = ff_audio_resample(avr->resample, resample_out,
current_buffer, &consumed);
if (ret < 0)
return ret;
/* if resampling did not produce any samples, just return 0 */
if (resample_out->nb_samples == 0) {
av_dlog(avr, "[end conversion]\n");
return 0;
}
current_buffer = resample_out;
}
if (avr->upmix_needed) {
av_dlog(avr, "[upmix] %s\n", current_buffer->name);
ret = ff_audio_mix(avr->am, current_buffer);
if (ret < 0)
return ret;
}
/* if we resampled or upmixed directly to output, return here */
if (current_buffer == &output_buffer) {
av_dlog(avr, "[end conversion]\n");
return current_buffer->nb_samples;
}
if (avr->out_convert_needed) {
if (output && out_samples >= current_buffer->nb_samples) {
/* convert directly to output */
av_dlog(avr, "[convert] %s to output\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_out, &output_buffer, current_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[end conversion]\n");
return output_buffer.nb_samples;
} else {
ret = ff_audio_data_realloc(avr->out_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[convert] %s to out_buffer\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_out, avr->out_buffer,
current_buffer, current_buffer->nb_samples);
if (ret < 0)
return ret;
current_buffer = avr->out_buffer;
}
}
return handle_buffered_output(avr, &output_buffer, current_buffer);
}
| true | FFmpeg | 9684341346fd5aad436325529cade47966c4731b | int avresample_convert(AVAudioResampleContext *avr, void **output,
int out_plane_size, int out_samples, void **input,
int in_plane_size, int in_samples)
{
AudioData input_buffer;
AudioData output_buffer;
AudioData *current_buffer;
int ret;
if (avr->in_buffer) {
avr->in_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->in_buffer,
avr->in_buffer->allocated_channels);
}
if (avr->resample_out_buffer) {
avr->resample_out_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->resample_out_buffer,
avr->resample_out_buffer->allocated_channels);
}
if (avr->out_buffer) {
avr->out_buffer->nb_samples = 0;
ff_audio_data_set_channels(avr->out_buffer,
avr->out_buffer->allocated_channels);
}
av_dlog(avr, "[start conversion]\n");
if (output) {
ret = ff_audio_data_init(&output_buffer, output, out_plane_size,
avr->out_channels, out_samples,
avr->out_sample_fmt, 0, "output");
if (ret < 0)
return ret;
output_buffer.nb_samples = 0;
}
if (input) {
ret = ff_audio_data_init(&input_buffer, input, in_plane_size,
avr->in_channels, in_samples,
avr->in_sample_fmt, 1, "input");
if (ret < 0)
return ret;
current_buffer = &input_buffer;
if (avr->upmix_needed && !avr->in_convert_needed && !avr->resample_needed &&
!avr->out_convert_needed && output && out_samples >= in_samples) {
av_dlog(avr, "[copy] %s to output\n", current_buffer->name);
ret = ff_audio_data_copy(&output_buffer, current_buffer);
if (ret < 0)
return ret;
current_buffer = &output_buffer;
} else if (avr->mixing_needed || avr->in_convert_needed) {
if (avr->in_convert_needed) {
ret = ff_audio_data_realloc(avr->in_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[convert] %s to in_buffer\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_in, avr->in_buffer, current_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
} else {
av_dlog(avr, "[copy] %s to in_buffer\n", current_buffer->name);
ret = ff_audio_data_copy(avr->in_buffer, current_buffer);
if (ret < 0)
return ret;
}
ff_audio_data_set_channels(avr->in_buffer, avr->in_channels);
if (avr->downmix_needed) {
av_dlog(avr, "[downmix] in_buffer\n");
ret = ff_audio_mix(avr->am, avr->in_buffer);
if (ret < 0)
return ret;
}
current_buffer = avr->in_buffer;
}
} else {
if (!avr->resample_needed)
return handle_buffered_output(avr, output ? &output_buffer : NULL,
NULL);
current_buffer = NULL;
}
if (avr->resample_needed) {
AudioData *resample_out;
int consumed = 0;
if (!avr->out_convert_needed && output && out_samples > 0)
resample_out = &output_buffer;
else
resample_out = avr->resample_out_buffer;
av_dlog(avr, "[resample] %s to %s\n", current_buffer->name,
resample_out->name);
ret = ff_audio_resample(avr->resample, resample_out,
current_buffer, &consumed);
if (ret < 0)
return ret;
if (resample_out->nb_samples == 0) {
av_dlog(avr, "[end conversion]\n");
return 0;
}
current_buffer = resample_out;
}
if (avr->upmix_needed) {
av_dlog(avr, "[upmix] %s\n", current_buffer->name);
ret = ff_audio_mix(avr->am, current_buffer);
if (ret < 0)
return ret;
}
if (current_buffer == &output_buffer) {
av_dlog(avr, "[end conversion]\n");
return current_buffer->nb_samples;
}
if (avr->out_convert_needed) {
if (output && out_samples >= current_buffer->nb_samples) {
av_dlog(avr, "[convert] %s to output\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_out, &output_buffer, current_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[end conversion]\n");
return output_buffer.nb_samples;
} else {
ret = ff_audio_data_realloc(avr->out_buffer,
current_buffer->nb_samples);
if (ret < 0)
return ret;
av_dlog(avr, "[convert] %s to out_buffer\n", current_buffer->name);
ret = ff_audio_convert(avr->ac_out, avr->out_buffer,
current_buffer, current_buffer->nb_samples);
if (ret < 0)
return ret;
current_buffer = avr->out_buffer;
}
}
return handle_buffered_output(avr, &output_buffer, current_buffer);
}
| {
"code": [
" return handle_buffered_output(avr, &output_buffer, current_buffer);"
],
"line_no": [
309
]
} | int FUNC_0(AVAudioResampleContext *VAR_0, void **VAR_1,
int VAR_2, int VAR_3, void **VAR_4,
int VAR_5, int VAR_6)
{
AudioData input_buffer;
AudioData output_buffer;
AudioData *current_buffer;
int VAR_7;
if (VAR_0->in_buffer) {
VAR_0->in_buffer->nb_samples = 0;
ff_audio_data_set_channels(VAR_0->in_buffer,
VAR_0->in_buffer->allocated_channels);
}
if (VAR_0->resample_out_buffer) {
VAR_0->resample_out_buffer->nb_samples = 0;
ff_audio_data_set_channels(VAR_0->resample_out_buffer,
VAR_0->resample_out_buffer->allocated_channels);
}
if (VAR_0->out_buffer) {
VAR_0->out_buffer->nb_samples = 0;
ff_audio_data_set_channels(VAR_0->out_buffer,
VAR_0->out_buffer->allocated_channels);
}
av_dlog(VAR_0, "[start conversion]\n");
if (VAR_1) {
VAR_7 = ff_audio_data_init(&output_buffer, VAR_1, VAR_2,
VAR_0->out_channels, VAR_3,
VAR_0->out_sample_fmt, 0, "VAR_1");
if (VAR_7 < 0)
return VAR_7;
output_buffer.nb_samples = 0;
}
if (VAR_4) {
VAR_7 = ff_audio_data_init(&input_buffer, VAR_4, VAR_5,
VAR_0->in_channels, VAR_6,
VAR_0->in_sample_fmt, 1, "VAR_4");
if (VAR_7 < 0)
return VAR_7;
current_buffer = &input_buffer;
if (VAR_0->upmix_needed && !VAR_0->in_convert_needed && !VAR_0->resample_needed &&
!VAR_0->out_convert_needed && VAR_1 && VAR_3 >= VAR_6) {
av_dlog(VAR_0, "[copy] %s to VAR_1\n", current_buffer->name);
VAR_7 = ff_audio_data_copy(&output_buffer, current_buffer);
if (VAR_7 < 0)
return VAR_7;
current_buffer = &output_buffer;
} else if (VAR_0->mixing_needed || VAR_0->in_convert_needed) {
if (VAR_0->in_convert_needed) {
VAR_7 = ff_audio_data_realloc(VAR_0->in_buffer,
current_buffer->nb_samples);
if (VAR_7 < 0)
return VAR_7;
av_dlog(VAR_0, "[convert] %s to in_buffer\n", current_buffer->name);
VAR_7 = ff_audio_convert(VAR_0->ac_in, VAR_0->in_buffer, current_buffer,
current_buffer->nb_samples);
if (VAR_7 < 0)
return VAR_7;
} else {
av_dlog(VAR_0, "[copy] %s to in_buffer\n", current_buffer->name);
VAR_7 = ff_audio_data_copy(VAR_0->in_buffer, current_buffer);
if (VAR_7 < 0)
return VAR_7;
}
ff_audio_data_set_channels(VAR_0->in_buffer, VAR_0->in_channels);
if (VAR_0->downmix_needed) {
av_dlog(VAR_0, "[downmix] in_buffer\n");
VAR_7 = ff_audio_mix(VAR_0->am, VAR_0->in_buffer);
if (VAR_7 < 0)
return VAR_7;
}
current_buffer = VAR_0->in_buffer;
}
} else {
if (!VAR_0->resample_needed)
return handle_buffered_output(VAR_0, VAR_1 ? &output_buffer : NULL,
NULL);
current_buffer = NULL;
}
if (VAR_0->resample_needed) {
AudioData *resample_out;
int VAR_8 = 0;
if (!VAR_0->out_convert_needed && VAR_1 && VAR_3 > 0)
resample_out = &output_buffer;
else
resample_out = VAR_0->resample_out_buffer;
av_dlog(VAR_0, "[resample] %s to %s\n", current_buffer->name,
resample_out->name);
VAR_7 = ff_audio_resample(VAR_0->resample, resample_out,
current_buffer, &VAR_8);
if (VAR_7 < 0)
return VAR_7;
if (resample_out->nb_samples == 0) {
av_dlog(VAR_0, "[end conversion]\n");
return 0;
}
current_buffer = resample_out;
}
if (VAR_0->upmix_needed) {
av_dlog(VAR_0, "[upmix] %s\n", current_buffer->name);
VAR_7 = ff_audio_mix(VAR_0->am, current_buffer);
if (VAR_7 < 0)
return VAR_7;
}
if (current_buffer == &output_buffer) {
av_dlog(VAR_0, "[end conversion]\n");
return current_buffer->nb_samples;
}
if (VAR_0->out_convert_needed) {
if (VAR_1 && VAR_3 >= current_buffer->nb_samples) {
av_dlog(VAR_0, "[convert] %s to VAR_1\n", current_buffer->name);
VAR_7 = ff_audio_convert(VAR_0->ac_out, &output_buffer, current_buffer,
current_buffer->nb_samples);
if (VAR_7 < 0)
return VAR_7;
av_dlog(VAR_0, "[end conversion]\n");
return output_buffer.nb_samples;
} else {
VAR_7 = ff_audio_data_realloc(VAR_0->out_buffer,
current_buffer->nb_samples);
if (VAR_7 < 0)
return VAR_7;
av_dlog(VAR_0, "[convert] %s to out_buffer\n", current_buffer->name);
VAR_7 = ff_audio_convert(VAR_0->ac_out, VAR_0->out_buffer,
current_buffer, current_buffer->nb_samples);
if (VAR_7 < 0)
return VAR_7;
current_buffer = VAR_0->out_buffer;
}
}
return handle_buffered_output(VAR_0, &output_buffer, current_buffer);
}
| [
"int FUNC_0(AVAudioResampleContext *VAR_0, void **VAR_1,\nint VAR_2, int VAR_3, void **VAR_4,\nint VAR_5, int VAR_6)\n{",
"AudioData input_buffer;",
"AudioData output_buffer;",
"AudioData *current_buffer;",
"int VAR_7;",
"if (VAR_0->in_buffer) {",
"VAR_0->in_buffer->nb_samples = 0;",
"ff_audio_data_set_channels(VAR_0->in_buffer,\nVAR_0->in_buffer->allocated_channels);",
"}",
"if (VAR_0->resample_out_buffer) {",
"VAR_0->resample_out_buffer->nb_samples = 0;",
"ff_audio_data_set_channels(VAR_0->resample_out_buffer,\nVAR_0->resample_out_buffer->allocated_channels);",
"}",
"if (VAR_0->out_buffer) {",
"VAR_0->out_buffer->nb_samples = 0;",
"ff_audio_data_set_channels(VAR_0->out_buffer,\nVAR_0->out_buffer->allocated_channels);",
"}",
"av_dlog(VAR_0, \"[start conversion]\\n\");",
"if (VAR_1) {",
"VAR_7 = ff_audio_data_init(&output_buffer, VAR_1, VAR_2,\nVAR_0->out_channels, VAR_3,\nVAR_0->out_sample_fmt, 0, \"VAR_1\");",
"if (VAR_7 < 0)\nreturn VAR_7;",
"output_buffer.nb_samples = 0;",
"}",
"if (VAR_4) {",
"VAR_7 = ff_audio_data_init(&input_buffer, VAR_4, VAR_5,\nVAR_0->in_channels, VAR_6,\nVAR_0->in_sample_fmt, 1, \"VAR_4\");",
"if (VAR_7 < 0)\nreturn VAR_7;",
"current_buffer = &input_buffer;",
"if (VAR_0->upmix_needed && !VAR_0->in_convert_needed && !VAR_0->resample_needed &&\n!VAR_0->out_convert_needed && VAR_1 && VAR_3 >= VAR_6) {",
"av_dlog(VAR_0, \"[copy] %s to VAR_1\\n\", current_buffer->name);",
"VAR_7 = ff_audio_data_copy(&output_buffer, current_buffer);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"current_buffer = &output_buffer;",
"} else if (VAR_0->mixing_needed || VAR_0->in_convert_needed) {",
"if (VAR_0->in_convert_needed) {",
"VAR_7 = ff_audio_data_realloc(VAR_0->in_buffer,\ncurrent_buffer->nb_samples);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"av_dlog(VAR_0, \"[convert] %s to in_buffer\\n\", current_buffer->name);",
"VAR_7 = ff_audio_convert(VAR_0->ac_in, VAR_0->in_buffer, current_buffer,\ncurrent_buffer->nb_samples);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"} else {",
"av_dlog(VAR_0, \"[copy] %s to in_buffer\\n\", current_buffer->name);",
"VAR_7 = ff_audio_data_copy(VAR_0->in_buffer, current_buffer);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"}",
"ff_audio_data_set_channels(VAR_0->in_buffer, VAR_0->in_channels);",
"if (VAR_0->downmix_needed) {",
"av_dlog(VAR_0, \"[downmix] in_buffer\\n\");",
"VAR_7 = ff_audio_mix(VAR_0->am, VAR_0->in_buffer);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"}",
"current_buffer = VAR_0->in_buffer;",
"}",
"} else {",
"if (!VAR_0->resample_needed)\nreturn handle_buffered_output(VAR_0, VAR_1 ? &output_buffer : NULL,\nNULL);",
"current_buffer = NULL;",
"}",
"if (VAR_0->resample_needed) {",
"AudioData *resample_out;",
"int VAR_8 = 0;",
"if (!VAR_0->out_convert_needed && VAR_1 && VAR_3 > 0)\nresample_out = &output_buffer;",
"else\nresample_out = VAR_0->resample_out_buffer;",
"av_dlog(VAR_0, \"[resample] %s to %s\\n\", current_buffer->name,\nresample_out->name);",
"VAR_7 = ff_audio_resample(VAR_0->resample, resample_out,\ncurrent_buffer, &VAR_8);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"if (resample_out->nb_samples == 0) {",
"av_dlog(VAR_0, \"[end conversion]\\n\");",
"return 0;",
"}",
"current_buffer = resample_out;",
"}",
"if (VAR_0->upmix_needed) {",
"av_dlog(VAR_0, \"[upmix] %s\\n\", current_buffer->name);",
"VAR_7 = ff_audio_mix(VAR_0->am, current_buffer);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"}",
"if (current_buffer == &output_buffer) {",
"av_dlog(VAR_0, \"[end conversion]\\n\");",
"return current_buffer->nb_samples;",
"}",
"if (VAR_0->out_convert_needed) {",
"if (VAR_1 && VAR_3 >= current_buffer->nb_samples) {",
"av_dlog(VAR_0, \"[convert] %s to VAR_1\\n\", current_buffer->name);",
"VAR_7 = ff_audio_convert(VAR_0->ac_out, &output_buffer, current_buffer,\ncurrent_buffer->nb_samples);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"av_dlog(VAR_0, \"[end conversion]\\n\");",
"return output_buffer.nb_samples;",
"} else {",
"VAR_7 = ff_audio_data_realloc(VAR_0->out_buffer,\ncurrent_buffer->nb_samples);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"av_dlog(VAR_0, \"[convert] %s to out_buffer\\n\", current_buffer->name);",
"VAR_7 = ff_audio_convert(VAR_0->ac_out, VAR_0->out_buffer,\ncurrent_buffer, current_buffer->nb_samples);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"current_buffer = VAR_0->out_buffer;",
"}",
"}",
"return handle_buffered_output(VAR_0, &output_buffer, current_buffer);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
53
],
[
59
],
[
61,
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
81,
83,
85
],
[
87,
89
],
[
91
],
[
95,
97
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
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
],
[
173,
175,
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
193,
195
],
[
197,
199
],
[
201,
203
],
[
205,
207
],
[
209,
211
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239,
241
],
[
243
],
[
249
],
[
251
],
[
253
],
[
255
],
[
259
],
[
261
],
[
265
],
[
267,
269
],
[
271,
273
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287,
289
],
[
291
],
[
293,
295
],
[
297,
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
]
] |
19,873 | static ssize_t rtl8139_do_receive(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
{
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
/* size is the length of the buffer passed to the driver */
int size = size_;
const uint8_t *dot1q_buf = NULL;
uint32_t packet_header = 0;
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
DEBUG_PRINT((">>> RTL8139: received len=%d\n", size));
/* test if board clock is stopped */
if (!s->clock_enabled)
{
DEBUG_PRINT(("RTL8139: stopped ==========================\n"));
return -1;
}
/* first check if receiver is enabled */
if (!rtl8139_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: receiver disabled ================\n"));
return -1;
}
/* XXX: check this */
if (s->RxConfig & AcceptAllPhys) {
/* promiscuous: receive all */
DEBUG_PRINT((">>> RTL8139: packet received in promiscuous mode\n"));
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
/* broadcast address */
if (!(s->RxConfig & AcceptBroadcast))
{
DEBUG_PRINT((">>> RTL8139: broadcast packet rejected\n"));
/* update tally counter */
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxBroadcast;
DEBUG_PRINT((">>> RTL8139: broadcast packet received\n"));
/* update tally counter */
++s->tally_counters.RxOkBrd;
} else if (buf[0] & 0x01) {
/* multicast */
if (!(s->RxConfig & AcceptMulticast))
{
DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n"));
/* update tally counter */
++s->tally_counters.RxERR;
return size;
}
int mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
{
DEBUG_PRINT((">>> RTL8139: multicast address mismatch\n"));
/* update tally counter */
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxMulticast;
DEBUG_PRINT((">>> RTL8139: multicast packet received\n"));
/* update tally counter */
++s->tally_counters.RxOkMul;
} else if (s->phys[0] == buf[0] &&
s->phys[1] == buf[1] &&
s->phys[2] == buf[2] &&
s->phys[3] == buf[3] &&
s->phys[4] == buf[4] &&
s->phys[5] == buf[5]) {
/* match */
if (!(s->RxConfig & AcceptMyPhys))
{
DEBUG_PRINT((">>> RTL8139: rejecting physical address matching packet\n"));
/* update tally counter */
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxPhysical;
DEBUG_PRINT((">>> RTL8139: physical address matching packet received\n"));
/* update tally counter */
++s->tally_counters.RxOkPhy;
} else {
DEBUG_PRINT((">>> RTL8139: unknown packet\n"));
/* update tally counter */
++s->tally_counters.RxERR;
return size;
}
}
/* if too small buffer, then expand it
* Include some tailroom in case a vlan tag is later removed. */
if (size < MIN_BUF_SIZE + VLAN_HLEN) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE + VLAN_HLEN - size);
buf = buf1;
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
}
if (rtl8139_cp_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n"));
/* begin C+ receiver mode */
/* w0 ownership flag */
#define CP_RX_OWN (1<<31)
/* w0 end of ring flag */
#define CP_RX_EOR (1<<30)
/* w0 bits 0...12 : buffer size */
#define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1)
/* w1 tag available flag */
#define CP_RX_TAVA (1<<16)
/* w1 bits 0...15 : VLAN tag */
#define CP_RX_VLAN_TAG_MASK ((1<<16) - 1)
/* w2 low 32bit of Rx buffer ptr */
/* w3 high 32bit of Rx buffer ptr */
int descriptor = s->currCPlusRxDesc;
target_phys_addr_t cplus_rx_ring_desc;
cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI);
cplus_rx_ring_desc += 16 * descriptor;
DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016" PRIx64 "\n",
descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc));
uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI;
cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4);
rxdw0 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
rxdw1 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4);
rxbufLO = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4);
rxbufHI = le32_to_cpu(val);
DEBUG_PRINT(("RTL8139: +++ C+ mode RX descriptor %d %08x %08x %08x %08x\n",
descriptor,
rxdw0, rxdw1, rxbufLO, rxbufHI));
if (!(rxdw0 & CP_RX_OWN))
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d is owned by host\n", descriptor));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
/* update tally counter */
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK;
/* write VLAN info to descriptor variables. */
if (s->CpCmd & CPlusRxVLAN && be16_to_cpup((uint16_t *)
&buf[ETHER_ADDR_LEN * 2]) == ETH_P_8021Q) {
dot1q_buf = &buf[ETHER_ADDR_LEN * 2];
size -= VLAN_HLEN;
/* if too small buffer, use the tailroom added duing expansion */
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
/* BE + ~le_to_cpu()~ + cpu_to_le() = BE */
rxdw1 |= CP_RX_TAVA | le16_to_cpup((uint16_t *)
&dot1q_buf[ETHER_TYPE_LEN]);
DEBUG_PRINT(("RTL8139: C+ Rx mode : extracted vlan tag with tci: "
"%u\n", be16_to_cpup((uint16_t *)
&dot1q_buf[ETHER_TYPE_LEN])));
} else {
/* reset VLAN tag flag */
rxdw1 &= ~CP_RX_TAVA;
}
/* TODO: scatter the packet over available receive ring descriptors space */
if (size+4 > rx_space)
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d size %d received %d + 4\n",
descriptor, rx_space, size));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
/* update tally counter */
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI);
/* receive/copy to target memory */
if (dot1q_buf) {
cpu_physical_memory_write(rx_addr, buf, 2 * ETHER_ADDR_LEN);
cpu_physical_memory_write(rx_addr + 2 * ETHER_ADDR_LEN,
buf + 2 * ETHER_ADDR_LEN + VLAN_HLEN,
size - 2 * ETHER_ADDR_LEN);
} else {
cpu_physical_memory_write(rx_addr, buf, size);
}
if (s->CpCmd & CPlusRxChkSum)
{
/* do some packet checksumming */
}
/* write checksum */
val = cpu_to_le32(crc32(0, buf, size_));
cpu_physical_memory_write( rx_addr+size, (uint8_t *)&val, 4);
/* first segment of received packet flag */
#define CP_RX_STATUS_FS (1<<29)
/* last segment of received packet flag */
#define CP_RX_STATUS_LS (1<<28)
/* multicast packet flag */
#define CP_RX_STATUS_MAR (1<<26)
/* physical-matching packet flag */
#define CP_RX_STATUS_PAM (1<<25)
/* broadcast packet flag */
#define CP_RX_STATUS_BAR (1<<24)
/* runt packet flag */
#define CP_RX_STATUS_RUNT (1<<19)
/* crc error flag */
#define CP_RX_STATUS_CRC (1<<18)
/* IP checksum error flag */
#define CP_RX_STATUS_IPF (1<<15)
/* UDP checksum error flag */
#define CP_RX_STATUS_UDPF (1<<14)
/* TCP checksum error flag */
#define CP_RX_STATUS_TCPF (1<<13)
/* transfer ownership to target */
rxdw0 &= ~CP_RX_OWN;
/* set first segment bit */
rxdw0 |= CP_RX_STATUS_FS;
/* set last segment bit */
rxdw0 |= CP_RX_STATUS_LS;
/* set received packet type flags */
if (packet_header & RxBroadcast)
rxdw0 |= CP_RX_STATUS_BAR;
if (packet_header & RxMulticast)
rxdw0 |= CP_RX_STATUS_MAR;
if (packet_header & RxPhysical)
rxdw0 |= CP_RX_STATUS_PAM;
/* set received size */
rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK;
rxdw0 |= (size+4);
/* update ring data */
val = cpu_to_le32(rxdw0);
cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4);
val = cpu_to_le32(rxdw1);
cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
/* update tally counter */
++s->tally_counters.RxOk;
/* seek to next Rx descriptor */
if (rxdw0 & CP_RX_EOR)
{
s->currCPlusRxDesc = 0;
}
else
{
++s->currCPlusRxDesc;
}
DEBUG_PRINT(("RTL8139: done C+ Rx mode ----------------\n"));
}
else
{
DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n"));
/* begin ring receiver mode */
int avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize);
/* if receiver buffer is empty then avail == 0 */
if (avail != 0 && size + 8 >= avail)
{
DEBUG_PRINT(("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr, avail, size + 8));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
rtl8139_update_irq(s);
return size_;
}
packet_header |= RxStatusOK;
packet_header |= (((size+4) << 16) & 0xffff0000);
/* write header */
uint32_t val = cpu_to_le32(packet_header);
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
rtl8139_write_buffer(s, buf, size);
/* write checksum */
val = cpu_to_le32(crc32(0, buf, size));
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
/* correct buffer write pointer */
s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize);
/* now we can signal we have received something */
DEBUG_PRINT((" received: rx buffer length %d head 0x%04x read 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr));
}
s->IntrStatus |= RxOK;
if (do_interrupt)
{
rtl8139_update_irq(s);
}
return size_;
}
| true | qemu | afcd9c0dcd1d6ab14a72db6abde76142c6a0ac12 | static ssize_t rtl8139_do_receive(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
{
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
int size = size_;
const uint8_t *dot1q_buf = NULL;
uint32_t packet_header = 0;
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
DEBUG_PRINT((">>> RTL8139: received len=%d\n", size));
if (!s->clock_enabled)
{
DEBUG_PRINT(("RTL8139: stopped ==========================\n"));
return -1;
}
if (!rtl8139_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: receiver disabled ================\n"));
return -1;
}
if (s->RxConfig & AcceptAllPhys) {
DEBUG_PRINT((">>> RTL8139: packet received in promiscuous mode\n"));
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
if (!(s->RxConfig & AcceptBroadcast))
{
DEBUG_PRINT((">>> RTL8139: broadcast packet rejected\n"));
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxBroadcast;
DEBUG_PRINT((">>> RTL8139: broadcast packet received\n"));
++s->tally_counters.RxOkBrd;
} else if (buf[0] & 0x01) {
if (!(s->RxConfig & AcceptMulticast))
{
DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n"));
++s->tally_counters.RxERR;
return size;
}
int mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
{
DEBUG_PRINT((">>> RTL8139: multicast address mismatch\n"));
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxMulticast;
DEBUG_PRINT((">>> RTL8139: multicast packet received\n"));
++s->tally_counters.RxOkMul;
} else if (s->phys[0] == buf[0] &&
s->phys[1] == buf[1] &&
s->phys[2] == buf[2] &&
s->phys[3] == buf[3] &&
s->phys[4] == buf[4] &&
s->phys[5] == buf[5]) {
if (!(s->RxConfig & AcceptMyPhys))
{
DEBUG_PRINT((">>> RTL8139: rejecting physical address matching packet\n"));
++s->tally_counters.RxERR;
return size;
}
packet_header |= RxPhysical;
DEBUG_PRINT((">>> RTL8139: physical address matching packet received\n"));
++s->tally_counters.RxOkPhy;
} else {
DEBUG_PRINT((">>> RTL8139: unknown packet\n"));
++s->tally_counters.RxERR;
return size;
}
}
if (size < MIN_BUF_SIZE + VLAN_HLEN) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE + VLAN_HLEN - size);
buf = buf1;
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
}
if (rtl8139_cp_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n"));
#define CP_RX_OWN (1<<31)
#define CP_RX_EOR (1<<30)
#define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1)
#define CP_RX_TAVA (1<<16)
#define CP_RX_VLAN_TAG_MASK ((1<<16) - 1)
int descriptor = s->currCPlusRxDesc;
target_phys_addr_t cplus_rx_ring_desc;
cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI);
cplus_rx_ring_desc += 16 * descriptor;
DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016" PRIx64 "\n",
descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc));
uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI;
cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4);
rxdw0 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
rxdw1 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4);
rxbufLO = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4);
rxbufHI = le32_to_cpu(val);
DEBUG_PRINT(("RTL8139: +++ C+ mode RX descriptor %d %08x %08x %08x %08x\n",
descriptor,
rxdw0, rxdw1, rxbufLO, rxbufHI));
if (!(rxdw0 & CP_RX_OWN))
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d is owned by host\n", descriptor));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK;
if (s->CpCmd & CPlusRxVLAN && be16_to_cpup((uint16_t *)
&buf[ETHER_ADDR_LEN * 2]) == ETH_P_8021Q) {
dot1q_buf = &buf[ETHER_ADDR_LEN * 2];
size -= VLAN_HLEN;
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
rxdw1 |= CP_RX_TAVA | le16_to_cpup((uint16_t *)
&dot1q_buf[ETHER_TYPE_LEN]);
DEBUG_PRINT(("RTL8139: C+ Rx mode : extracted vlan tag with tci: "
"%u\n", be16_to_cpup((uint16_t *)
&dot1q_buf[ETHER_TYPE_LEN])));
} else {
rxdw1 &= ~CP_RX_TAVA;
}
if (size+4 > rx_space)
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : descriptor %d size %d received %d + 4\n",
descriptor, rx_space, size));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI);
if (dot1q_buf) {
cpu_physical_memory_write(rx_addr, buf, 2 * ETHER_ADDR_LEN);
cpu_physical_memory_write(rx_addr + 2 * ETHER_ADDR_LEN,
buf + 2 * ETHER_ADDR_LEN + VLAN_HLEN,
size - 2 * ETHER_ADDR_LEN);
} else {
cpu_physical_memory_write(rx_addr, buf, size);
}
if (s->CpCmd & CPlusRxChkSum)
{
}
val = cpu_to_le32(crc32(0, buf, size_));
cpu_physical_memory_write( rx_addr+size, (uint8_t *)&val, 4);
#define CP_RX_STATUS_FS (1<<29)
#define CP_RX_STATUS_LS (1<<28)
#define CP_RX_STATUS_MAR (1<<26)
#define CP_RX_STATUS_PAM (1<<25)
#define CP_RX_STATUS_BAR (1<<24)
#define CP_RX_STATUS_RUNT (1<<19)
#define CP_RX_STATUS_CRC (1<<18)
#define CP_RX_STATUS_IPF (1<<15)
#define CP_RX_STATUS_UDPF (1<<14)
#define CP_RX_STATUS_TCPF (1<<13)
rxdw0 &= ~CP_RX_OWN;
rxdw0 |= CP_RX_STATUS_FS;
rxdw0 |= CP_RX_STATUS_LS;
if (packet_header & RxBroadcast)
rxdw0 |= CP_RX_STATUS_BAR;
if (packet_header & RxMulticast)
rxdw0 |= CP_RX_STATUS_MAR;
if (packet_header & RxPhysical)
rxdw0 |= CP_RX_STATUS_PAM;
rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK;
rxdw0 |= (size+4);
val = cpu_to_le32(rxdw0);
cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4);
val = cpu_to_le32(rxdw1);
cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
++s->tally_counters.RxOk;
if (rxdw0 & CP_RX_EOR)
{
s->currCPlusRxDesc = 0;
}
else
{
++s->currCPlusRxDesc;
}
DEBUG_PRINT(("RTL8139: done C+ Rx mode ----------------\n"));
}
else
{
DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n"));
int avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize);
if (avail != 0 && size + 8 >= avail)
{
DEBUG_PRINT(("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr, avail, size + 8));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
rtl8139_update_irq(s);
return size_;
}
packet_header |= RxStatusOK;
packet_header |= (((size+4) << 16) & 0xffff0000);
uint32_t val = cpu_to_le32(packet_header);
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
rtl8139_write_buffer(s, buf, size);
val = cpu_to_le32(crc32(0, buf, size));
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize);
DEBUG_PRINT((" received: rx buffer length %d head 0x%04x read 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr));
}
s->IntrStatus |= RxOK;
if (do_interrupt)
{
rtl8139_update_irq(s);
}
return size_;
}
| {
"code": [
" DEBUG_PRINT((\"RTL8139: +++ C+ mode reading RX descriptor %d from host memory at %08x %08x = %016\" PRIx64 \"\\n\",",
" descriptor, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc));"
],
"line_no": [
315,
317
]
} | static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
{
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
int VAR_0 = size_;
const uint8_t *VAR_1 = NULL;
uint32_t packet_header = 0;
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
static const uint8_t VAR_2[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
DEBUG_PRINT((">>> RTL8139: received len=%d\n", VAR_0));
if (!s->clock_enabled)
{
DEBUG_PRINT(("RTL8139: stopped ==========================\n"));
return -1;
}
if (!rtl8139_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: receiver disabled ================\n"));
return -1;
}
if (s->RxConfig & AcceptAllPhys) {
DEBUG_PRINT((">>> RTL8139: packet received in promiscuous mode\n"));
} else {
if (!memcmp(buf, VAR_2, 6)) {
if (!(s->RxConfig & AcceptBroadcast))
{
DEBUG_PRINT((">>> RTL8139: broadcast packet rejected\n"));
++s->tally_counters.RxERR;
return VAR_0;
}
packet_header |= RxBroadcast;
DEBUG_PRINT((">>> RTL8139: broadcast packet received\n"));
++s->tally_counters.RxOkBrd;
} else if (buf[0] & 0x01) {
if (!(s->RxConfig & AcceptMulticast))
{
DEBUG_PRINT((">>> RTL8139: multicast packet rejected\n"));
++s->tally_counters.RxERR;
return VAR_0;
}
int VAR_3 = compute_mcast_idx(buf);
if (!(s->mult[VAR_3 >> 3] & (1 << (VAR_3 & 7))))
{
DEBUG_PRINT((">>> RTL8139: multicast address mismatch\n"));
++s->tally_counters.RxERR;
return VAR_0;
}
packet_header |= RxMulticast;
DEBUG_PRINT((">>> RTL8139: multicast packet received\n"));
++s->tally_counters.RxOkMul;
} else if (s->phys[0] == buf[0] &&
s->phys[1] == buf[1] &&
s->phys[2] == buf[2] &&
s->phys[3] == buf[3] &&
s->phys[4] == buf[4] &&
s->phys[5] == buf[5]) {
if (!(s->RxConfig & AcceptMyPhys))
{
DEBUG_PRINT((">>> RTL8139: rejecting physical address matching packet\n"));
++s->tally_counters.RxERR;
return VAR_0;
}
packet_header |= RxPhysical;
DEBUG_PRINT((">>> RTL8139: physical address matching packet received\n"));
++s->tally_counters.RxOkPhy;
} else {
DEBUG_PRINT((">>> RTL8139: unknown packet\n"));
++s->tally_counters.RxERR;
return VAR_0;
}
}
if (VAR_0 < MIN_BUF_SIZE + VLAN_HLEN) {
memcpy(buf1, buf, VAR_0);
memset(buf1 + VAR_0, 0, MIN_BUF_SIZE + VLAN_HLEN - VAR_0);
buf = buf1;
if (VAR_0 < MIN_BUF_SIZE) {
VAR_0 = MIN_BUF_SIZE;
}
}
if (rtl8139_cp_receiver_enabled(s))
{
DEBUG_PRINT(("RTL8139: in C+ Rx mode ================\n"));
#define CP_RX_OWN (1<<31)
#define CP_RX_EOR (1<<30)
#define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1)
#define CP_RX_TAVA (1<<16)
#define CP_RX_VLAN_TAG_MASK ((1<<16) - 1)
int VAR_4 = s->currCPlusRxDesc;
target_phys_addr_t cplus_rx_ring_desc;
cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI);
cplus_rx_ring_desc += 16 * VAR_4;
DEBUG_PRINT(("RTL8139: +++ C+ mode reading RX VAR_4 %d from host memory at %08x %08x = %016" PRIx64 "\n",
VAR_4, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc));
uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI;
cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4);
rxdw0 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
rxdw1 = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4);
rxbufLO = le32_to_cpu(val);
cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4);
rxbufHI = le32_to_cpu(val);
DEBUG_PRINT(("RTL8139: +++ C+ mode RX VAR_4 %d %08x %08x %08x %08x\n",
VAR_4,
rxdw0, rxdw1, rxbufLO, rxbufHI));
if (!(rxdw0 & CP_RX_OWN))
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : VAR_4 %d is owned by host\n", VAR_4));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK;
if (s->CpCmd & CPlusRxVLAN && be16_to_cpup((uint16_t *)
&buf[ETHER_ADDR_LEN * 2]) == ETH_P_8021Q) {
VAR_1 = &buf[ETHER_ADDR_LEN * 2];
VAR_0 -= VLAN_HLEN;
if (VAR_0 < MIN_BUF_SIZE) {
VAR_0 = MIN_BUF_SIZE;
}
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
rxdw1 |= CP_RX_TAVA | le16_to_cpup((uint16_t *)
&VAR_1[ETHER_TYPE_LEN]);
DEBUG_PRINT(("RTL8139: C+ Rx mode : extracted vlan tag with tci: "
"%u\n", be16_to_cpup((uint16_t *)
&VAR_1[ETHER_TYPE_LEN])));
} else {
rxdw1 &= ~CP_RX_TAVA;
}
if (VAR_0+4 > rx_space)
{
DEBUG_PRINT(("RTL8139: C+ Rx mode : VAR_4 %d VAR_0 %d received %d + 4\n",
VAR_4, rx_space, VAR_0));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
++s->tally_counters.RxERR;
++s->tally_counters.MissPkt;
rtl8139_update_irq(s);
return size_;
}
target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI);
if (VAR_1) {
cpu_physical_memory_write(rx_addr, buf, 2 * ETHER_ADDR_LEN);
cpu_physical_memory_write(rx_addr + 2 * ETHER_ADDR_LEN,
buf + 2 * ETHER_ADDR_LEN + VLAN_HLEN,
VAR_0 - 2 * ETHER_ADDR_LEN);
} else {
cpu_physical_memory_write(rx_addr, buf, VAR_0);
}
if (s->CpCmd & CPlusRxChkSum)
{
}
val = cpu_to_le32(crc32(0, buf, size_));
cpu_physical_memory_write( rx_addr+VAR_0, (uint8_t *)&val, 4);
#define CP_RX_STATUS_FS (1<<29)
#define CP_RX_STATUS_LS (1<<28)
#define CP_RX_STATUS_MAR (1<<26)
#define CP_RX_STATUS_PAM (1<<25)
#define CP_RX_STATUS_BAR (1<<24)
#define CP_RX_STATUS_RUNT (1<<19)
#define CP_RX_STATUS_CRC (1<<18)
#define CP_RX_STATUS_IPF (1<<15)
#define CP_RX_STATUS_UDPF (1<<14)
#define CP_RX_STATUS_TCPF (1<<13)
rxdw0 &= ~CP_RX_OWN;
rxdw0 |= CP_RX_STATUS_FS;
rxdw0 |= CP_RX_STATUS_LS;
if (packet_header & RxBroadcast)
rxdw0 |= CP_RX_STATUS_BAR;
if (packet_header & RxMulticast)
rxdw0 |= CP_RX_STATUS_MAR;
if (packet_header & RxPhysical)
rxdw0 |= CP_RX_STATUS_PAM;
rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK;
rxdw0 |= (VAR_0+4);
val = cpu_to_le32(rxdw0);
cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4);
val = cpu_to_le32(rxdw1);
cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);
++s->tally_counters.RxOk;
if (rxdw0 & CP_RX_EOR)
{
s->currCPlusRxDesc = 0;
}
else
{
++s->currCPlusRxDesc;
}
DEBUG_PRINT(("RTL8139: done C+ Rx mode ----------------\n"));
}
else
{
DEBUG_PRINT(("RTL8139: in ring Rx mode ================\n"));
int VAR_5 = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize);
if (VAR_5 != 0 && VAR_0 + 8 >= VAR_5)
{
DEBUG_PRINT(("rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr, VAR_5, VAR_0 + 8));
s->IntrStatus |= RxOverflow;
++s->RxMissed;
rtl8139_update_irq(s);
return size_;
}
packet_header |= RxStatusOK;
packet_header |= (((VAR_0+4) << 16) & 0xffff0000);
uint32_t val = cpu_to_le32(packet_header);
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
rtl8139_write_buffer(s, buf, VAR_0);
val = cpu_to_le32(crc32(0, buf, VAR_0));
rtl8139_write_buffer(s, (uint8_t *)&val, 4);
s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize);
DEBUG_PRINT((" received: rx buffer length %d head 0x%04x read 0x%04x\n",
s->RxBufferSize, s->RxBufAddr, s->RxBufPtr));
}
s->IntrStatus |= RxOK;
if (do_interrupt)
{
rtl8139_update_irq(s);
}
return size_;
}
| [
"static ssize_t FUNC_0(VLANClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)\n{",
"RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;",
"int VAR_0 = size_;",
"const uint8_t *VAR_1 = NULL;",
"uint32_t packet_header = 0;",
"uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];",
"static const uint8_t VAR_2[6] =\n{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };",
"DEBUG_PRINT((\">>> RTL8139: received len=%d\\n\", VAR_0));",
"if (!s->clock_enabled)\n{",
"DEBUG_PRINT((\"RTL8139: stopped ==========================\\n\"));",
"return -1;",
"}",
"if (!rtl8139_receiver_enabled(s))\n{",
"DEBUG_PRINT((\"RTL8139: receiver disabled ================\\n\"));",
"return -1;",
"}",
"if (s->RxConfig & AcceptAllPhys) {",
"DEBUG_PRINT((\">>> RTL8139: packet received in promiscuous mode\\n\"));",
"} else {",
"if (!memcmp(buf, VAR_2, 6)) {",
"if (!(s->RxConfig & AcceptBroadcast))\n{",
"DEBUG_PRINT((\">>> RTL8139: broadcast packet rejected\\n\"));",
"++s->tally_counters.RxERR;",
"return VAR_0;",
"}",
"packet_header |= RxBroadcast;",
"DEBUG_PRINT((\">>> RTL8139: broadcast packet received\\n\"));",
"++s->tally_counters.RxOkBrd;",
"} else if (buf[0] & 0x01) {",
"if (!(s->RxConfig & AcceptMulticast))\n{",
"DEBUG_PRINT((\">>> RTL8139: multicast packet rejected\\n\"));",
"++s->tally_counters.RxERR;",
"return VAR_0;",
"}",
"int VAR_3 = compute_mcast_idx(buf);",
"if (!(s->mult[VAR_3 >> 3] & (1 << (VAR_3 & 7))))\n{",
"DEBUG_PRINT((\">>> RTL8139: multicast address mismatch\\n\"));",
"++s->tally_counters.RxERR;",
"return VAR_0;",
"}",
"packet_header |= RxMulticast;",
"DEBUG_PRINT((\">>> RTL8139: multicast packet received\\n\"));",
"++s->tally_counters.RxOkMul;",
"} else if (s->phys[0] == buf[0] &&",
"s->phys[1] == buf[1] &&\ns->phys[2] == buf[2] &&\ns->phys[3] == buf[3] &&\ns->phys[4] == buf[4] &&\ns->phys[5] == buf[5]) {",
"if (!(s->RxConfig & AcceptMyPhys))\n{",
"DEBUG_PRINT((\">>> RTL8139: rejecting physical address matching packet\\n\"));",
"++s->tally_counters.RxERR;",
"return VAR_0;",
"}",
"packet_header |= RxPhysical;",
"DEBUG_PRINT((\">>> RTL8139: physical address matching packet received\\n\"));",
"++s->tally_counters.RxOkPhy;",
"} else {",
"DEBUG_PRINT((\">>> RTL8139: unknown packet\\n\"));",
"++s->tally_counters.RxERR;",
"return VAR_0;",
"}",
"}",
"if (VAR_0 < MIN_BUF_SIZE + VLAN_HLEN) {",
"memcpy(buf1, buf, VAR_0);",
"memset(buf1 + VAR_0, 0, MIN_BUF_SIZE + VLAN_HLEN - VAR_0);",
"buf = buf1;",
"if (VAR_0 < MIN_BUF_SIZE) {",
"VAR_0 = MIN_BUF_SIZE;",
"}",
"}",
"if (rtl8139_cp_receiver_enabled(s))\n{",
"DEBUG_PRINT((\"RTL8139: in C+ Rx mode ================\\n\"));",
"#define CP_RX_OWN (1<<31)\n#define CP_RX_EOR (1<<30)\n#define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1)\n#define CP_RX_TAVA (1<<16)\n#define CP_RX_VLAN_TAG_MASK ((1<<16) - 1)\nint VAR_4 = s->currCPlusRxDesc;",
"target_phys_addr_t cplus_rx_ring_desc;",
"cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, s->RxRingAddrHI);",
"cplus_rx_ring_desc += 16 * VAR_4;",
"DEBUG_PRINT((\"RTL8139: +++ C+ mode reading RX VAR_4 %d from host memory at %08x %08x = %016\" PRIx64 \"\\n\",\nVAR_4, s->RxRingAddrHI, s->RxRingAddrLO, (uint64_t)cplus_rx_ring_desc));",
"uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI;",
"cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4);",
"rxdw0 = le32_to_cpu(val);",
"cpu_physical_memory_read(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);",
"rxdw1 = le32_to_cpu(val);",
"cpu_physical_memory_read(cplus_rx_ring_desc+8, (uint8_t *)&val, 4);",
"rxbufLO = le32_to_cpu(val);",
"cpu_physical_memory_read(cplus_rx_ring_desc+12, (uint8_t *)&val, 4);",
"rxbufHI = le32_to_cpu(val);",
"DEBUG_PRINT((\"RTL8139: +++ C+ mode RX VAR_4 %d %08x %08x %08x %08x\\n\",\nVAR_4,\nrxdw0, rxdw1, rxbufLO, rxbufHI));",
"if (!(rxdw0 & CP_RX_OWN))\n{",
"DEBUG_PRINT((\"RTL8139: C+ Rx mode : VAR_4 %d is owned by host\\n\", VAR_4));",
"s->IntrStatus |= RxOverflow;",
"++s->RxMissed;",
"++s->tally_counters.RxERR;",
"++s->tally_counters.MissPkt;",
"rtl8139_update_irq(s);",
"return size_;",
"}",
"uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK;",
"if (s->CpCmd & CPlusRxVLAN && be16_to_cpup((uint16_t *)\n&buf[ETHER_ADDR_LEN * 2]) == ETH_P_8021Q) {",
"VAR_1 = &buf[ETHER_ADDR_LEN * 2];",
"VAR_0 -= VLAN_HLEN;",
"if (VAR_0 < MIN_BUF_SIZE) {",
"VAR_0 = MIN_BUF_SIZE;",
"}",
"rxdw1 &= ~CP_RX_VLAN_TAG_MASK;",
"rxdw1 |= CP_RX_TAVA | le16_to_cpup((uint16_t *)\n&VAR_1[ETHER_TYPE_LEN]);",
"DEBUG_PRINT((\"RTL8139: C+ Rx mode : extracted vlan tag with tci: \"\n\"%u\\n\", be16_to_cpup((uint16_t *)\n&VAR_1[ETHER_TYPE_LEN])));",
"} else {",
"rxdw1 &= ~CP_RX_TAVA;",
"}",
"if (VAR_0+4 > rx_space)\n{",
"DEBUG_PRINT((\"RTL8139: C+ Rx mode : VAR_4 %d VAR_0 %d received %d + 4\\n\",\nVAR_4, rx_space, VAR_0));",
"s->IntrStatus |= RxOverflow;",
"++s->RxMissed;",
"++s->tally_counters.RxERR;",
"++s->tally_counters.MissPkt;",
"rtl8139_update_irq(s);",
"return size_;",
"}",
"target_phys_addr_t rx_addr = rtl8139_addr64(rxbufLO, rxbufHI);",
"if (VAR_1) {",
"cpu_physical_memory_write(rx_addr, buf, 2 * ETHER_ADDR_LEN);",
"cpu_physical_memory_write(rx_addr + 2 * ETHER_ADDR_LEN,\nbuf + 2 * ETHER_ADDR_LEN + VLAN_HLEN,\nVAR_0 - 2 * ETHER_ADDR_LEN);",
"} else {",
"cpu_physical_memory_write(rx_addr, buf, VAR_0);",
"}",
"if (s->CpCmd & CPlusRxChkSum)\n{",
"}",
"val = cpu_to_le32(crc32(0, buf, size_));",
"cpu_physical_memory_write( rx_addr+VAR_0, (uint8_t *)&val, 4);",
"#define CP_RX_STATUS_FS (1<<29)\n#define CP_RX_STATUS_LS (1<<28)\n#define CP_RX_STATUS_MAR (1<<26)\n#define CP_RX_STATUS_PAM (1<<25)\n#define CP_RX_STATUS_BAR (1<<24)\n#define CP_RX_STATUS_RUNT (1<<19)\n#define CP_RX_STATUS_CRC (1<<18)\n#define CP_RX_STATUS_IPF (1<<15)\n#define CP_RX_STATUS_UDPF (1<<14)\n#define CP_RX_STATUS_TCPF (1<<13)\nrxdw0 &= ~CP_RX_OWN;",
"rxdw0 |= CP_RX_STATUS_FS;",
"rxdw0 |= CP_RX_STATUS_LS;",
"if (packet_header & RxBroadcast)\nrxdw0 |= CP_RX_STATUS_BAR;",
"if (packet_header & RxMulticast)\nrxdw0 |= CP_RX_STATUS_MAR;",
"if (packet_header & RxPhysical)\nrxdw0 |= CP_RX_STATUS_PAM;",
"rxdw0 &= ~CP_RX_BUFFER_SIZE_MASK;",
"rxdw0 |= (VAR_0+4);",
"val = cpu_to_le32(rxdw0);",
"cpu_physical_memory_write(cplus_rx_ring_desc, (uint8_t *)&val, 4);",
"val = cpu_to_le32(rxdw1);",
"cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4);",
"++s->tally_counters.RxOk;",
"if (rxdw0 & CP_RX_EOR)\n{",
"s->currCPlusRxDesc = 0;",
"}",
"else\n{",
"++s->currCPlusRxDesc;",
"}",
"DEBUG_PRINT((\"RTL8139: done C+ Rx mode ----------------\\n\"));",
"}",
"else\n{",
"DEBUG_PRINT((\"RTL8139: in ring Rx mode ================\\n\"));",
"int VAR_5 = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize);",
"if (VAR_5 != 0 && VAR_0 + 8 >= VAR_5)\n{",
"DEBUG_PRINT((\"rx overflow: rx buffer length %d head 0x%04x read 0x%04x === available 0x%04x need 0x%04x\\n\",\ns->RxBufferSize, s->RxBufAddr, s->RxBufPtr, VAR_5, VAR_0 + 8));",
"s->IntrStatus |= RxOverflow;",
"++s->RxMissed;",
"rtl8139_update_irq(s);",
"return size_;",
"}",
"packet_header |= RxStatusOK;",
"packet_header |= (((VAR_0+4) << 16) & 0xffff0000);",
"uint32_t val = cpu_to_le32(packet_header);",
"rtl8139_write_buffer(s, (uint8_t *)&val, 4);",
"rtl8139_write_buffer(s, buf, VAR_0);",
"val = cpu_to_le32(crc32(0, buf, VAR_0));",
"rtl8139_write_buffer(s, (uint8_t *)&val, 4);",
"s->RxBufAddr = MOD2((s->RxBufAddr + 3) & ~0x3, s->RxBufferSize);",
"DEBUG_PRINT((\" received: rx buffer length %d head 0x%04x read 0x%04x\\n\",\ns->RxBufferSize, s->RxBufAddr, s->RxBufPtr));",
"}",
"s->IntrStatus |= RxOK;",
"if (do_interrupt)\n{",
"rtl8139_update_irq(s);",
"}",
"return size_;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21,
23
],
[
27
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
67
],
[
71
],
[
73
],
[
77,
79
],
[
81
],
[
87
],
[
91
],
[
93
],
[
97
],
[
101
],
[
107
],
[
111
],
[
115,
117
],
[
119
],
[
125
],
[
129
],
[
131
],
[
135
],
[
139,
141
],
[
143
],
[
149
],
[
153
],
[
155
],
[
159
],
[
163
],
[
169
],
[
173
],
[
175,
177,
179,
181,
183
],
[
187,
189
],
[
191
],
[
197
],
[
201
],
[
203
],
[
207
],
[
211
],
[
217
],
[
221
],
[
225
],
[
231
],
[
235
],
[
237
],
[
239
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265,
267
],
[
269
],
[
279,
283,
287,
291,
295,
303
],
[
305
],
[
309
],
[
311
],
[
315,
317
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
343,
345,
347
],
[
351,
353
],
[
355
],
[
359
],
[
361
],
[
367
],
[
369
],
[
373
],
[
375
],
[
377
],
[
381
],
[
387,
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
405
],
[
409,
411
],
[
415,
417,
419
],
[
421
],
[
425
],
[
427
],
[
435,
437
],
[
439,
441
],
[
445
],
[
447
],
[
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
467
],
[
473
],
[
475
],
[
477,
479,
481
],
[
483
],
[
485
],
[
487
],
[
491,
493
],
[
497
],
[
503
],
[
505
],
[
511,
515,
519,
523,
527,
531,
535,
539,
543,
547,
553
],
[
559
],
[
565
],
[
571,
573
],
[
575,
577
],
[
579,
581
],
[
587
],
[
589
],
[
595
],
[
597
],
[
599
],
[
601
],
[
607
],
[
613,
615
],
[
617
],
[
619
],
[
621,
623
],
[
625
],
[
627
],
[
631
],
[
635
],
[
637,
639
],
[
641
],
[
647
],
[
655,
657
],
[
659,
661
],
[
665
],
[
667
],
[
669
],
[
671
],
[
673
],
[
677
],
[
681
],
[
687
],
[
691
],
[
695
],
[
701
],
[
703
],
[
709
],
[
717,
719
],
[
721
],
[
725
],
[
729,
731
],
[
733
],
[
735
],
[
739
],
[
741
]
] |
19,874 | static void decode_mb(MadContext *t, int inter)
{
MpegEncContext *s = &t->s;
int mv_map = 0;
int mv_x, mv_y;
int j;
if (inter) {
int v = decode210(&s->gb);
if (v < 2) {
mv_map = v ? get_bits(&s->gb, 6) : 63;
mv_x = decode_motion(&s->gb);
mv_y = decode_motion(&s->gb);
} else {
mv_map = 0;
}
}
for (j=0; j<6; j++) {
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
int add = 2*decode_motion(&s->gb);
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
} else {
s->dsp.clear_block(t->block);
decode_block_intra(t, t->block);
idct_put(t, t->block, s->mb_x, s->mb_y, j);
}
}
}
| true | FFmpeg | 6e20554a6d33e92b81dc3cfed6082e03bff2a7f8 | static void decode_mb(MadContext *t, int inter)
{
MpegEncContext *s = &t->s;
int mv_map = 0;
int mv_x, mv_y;
int j;
if (inter) {
int v = decode210(&s->gb);
if (v < 2) {
mv_map = v ? get_bits(&s->gb, 6) : 63;
mv_x = decode_motion(&s->gb);
mv_y = decode_motion(&s->gb);
} else {
mv_map = 0;
}
}
for (j=0; j<6; j++) {
if (mv_map & (1<<j)) {
int add = 2*decode_motion(&s->gb);
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
} else {
s->dsp.clear_block(t->block);
decode_block_intra(t, t->block);
idct_put(t, t->block, s->mb_x, s->mb_y, j);
}
}
}
| {
"code": [
" comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);"
],
"line_no": [
43
]
} | static void FUNC_0(MadContext *VAR_0, int VAR_1)
{
MpegEncContext *s = &VAR_0->s;
int VAR_2 = 0;
int VAR_3, VAR_4;
int VAR_5;
if (VAR_1) {
int VAR_6 = decode210(&s->gb);
if (VAR_6 < 2) {
VAR_2 = VAR_6 ? get_bits(&s->gb, 6) : 63;
VAR_3 = decode_motion(&s->gb);
VAR_4 = decode_motion(&s->gb);
} else {
VAR_2 = 0;
}
}
for (VAR_5=0; VAR_5<6; VAR_5++) {
if (VAR_2 & (1<<VAR_5)) {
int VAR_7 = 2*decode_motion(&s->gb);
comp_block(VAR_0, s->mb_x, s->mb_y, VAR_5, VAR_3, VAR_4, VAR_7);
} else {
s->dsp.clear_block(VAR_0->block);
decode_block_intra(VAR_0, VAR_0->block);
idct_put(VAR_0, VAR_0->block, s->mb_x, s->mb_y, VAR_5);
}
}
}
| [
"static void FUNC_0(MadContext *VAR_0, int VAR_1)\n{",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_2 = 0;",
"int VAR_3, VAR_4;",
"int VAR_5;",
"if (VAR_1) {",
"int VAR_6 = decode210(&s->gb);",
"if (VAR_6 < 2) {",
"VAR_2 = VAR_6 ? get_bits(&s->gb, 6) : 63;",
"VAR_3 = decode_motion(&s->gb);",
"VAR_4 = decode_motion(&s->gb);",
"} else {",
"VAR_2 = 0;",
"}",
"}",
"for (VAR_5=0; VAR_5<6; VAR_5++) {",
"if (VAR_2 & (1<<VAR_5)) {",
"int VAR_7 = 2*decode_motion(&s->gb);",
"comp_block(VAR_0, s->mb_x, s->mb_y, VAR_5, VAR_3, VAR_4, VAR_7);",
"} else {",
"s->dsp.clear_block(VAR_0->block);",
"decode_block_intra(VAR_0, VAR_0->block);",
"idct_put(VAR_0, VAR_0->block, s->mb_x, s->mb_y, VAR_5);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
19,876 | static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_output)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
DVBSubDisplayDefinition *display_def = ctx->display_definition;
DVBSubRegion *region;
AVSubtitleRect *rect;
DVBSubCLUT *clut;
uint32_t *clut_table;
int i;
int offset_x=0, offset_y=0;
int ret = 0;
if (display_def) {
offset_x = display_def->x;
offset_y = display_def->y;
}
/* Not touching AVSubtitles again*/
if(sub->num_rects) {
avpriv_request_sample(ctx, "Different Version of Segment asked Twice");
return AVERROR_PATCHWELCOME;
}
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (region && region->dirty)
sub->num_rects++;
}
if(ctx->compute_edt == 0) {
sub->end_display_time = ctx->time_out * 1000;
*got_output = 1;
} else if (ctx->prev_start != AV_NOPTS_VALUE) {
sub->end_display_time = av_rescale_q((sub->pts - ctx->prev_start ), AV_TIME_BASE_Q, (AVRational){ 1, 1000 }) - 1;
*got_output = 1;
}
if (sub->num_rects > 0) {
sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects);
if (!sub->rects) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < sub->num_rects; i++) {
sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));
if (!sub->rects[i]) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
i = 0;
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (!region)
continue;
if (!region->dirty)
continue;
rect = sub->rects[i];
rect->x = display->x_pos + offset_x;
rect->y = display->y_pos + offset_y;
rect->w = region->width;
rect->h = region->height;
rect->nb_colors = (1 << region->depth);
rect->type = SUBTITLE_BITMAP;
rect->linesize[0] = region->width;
clut = get_clut(ctx, region->clut);
if (!clut)
clut = &default_clut;
switch (region->depth) {
case 2:
clut_table = clut->clut4;
break;
case 8:
clut_table = clut->clut256;
break;
case 4:
default:
clut_table = clut->clut16;
break;
}
rect->data[1] = av_mallocz(AVPALETTE_SIZE);
if (!rect->data[1]) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
rect->data[0] = av_malloc(region->buf_size);
if (!rect->data[0]) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[0], region->pbuf, region->buf_size);
if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)
compute_default_clut(rect, rect->w, rect->h);
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
int j;
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
i++;
}
}
return 0;
fail:
if (sub->rects) {
for(i=0; i<sub->num_rects; i++) {
rect = sub->rects[i];
if (rect) {
av_freep(&rect->data[0]);
av_freep(&rect->data[1]);
}
av_freep(&sub->rects[i]);
}
av_freep(&sub->rects);
}
sub->num_rects = 0;
return ret;
}
| true | FFmpeg | eec67f7b24da5407cc2e8933ffe72358336811ab | static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_output)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
DVBSubDisplayDefinition *display_def = ctx->display_definition;
DVBSubRegion *region;
AVSubtitleRect *rect;
DVBSubCLUT *clut;
uint32_t *clut_table;
int i;
int offset_x=0, offset_y=0;
int ret = 0;
if (display_def) {
offset_x = display_def->x;
offset_y = display_def->y;
}
if(sub->num_rects) {
avpriv_request_sample(ctx, "Different Version of Segment asked Twice");
return AVERROR_PATCHWELCOME;
}
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (region && region->dirty)
sub->num_rects++;
}
if(ctx->compute_edt == 0) {
sub->end_display_time = ctx->time_out * 1000;
*got_output = 1;
} else if (ctx->prev_start != AV_NOPTS_VALUE) {
sub->end_display_time = av_rescale_q((sub->pts - ctx->prev_start ), AV_TIME_BASE_Q, (AVRational){ 1, 1000 }) - 1;
*got_output = 1;
}
if (sub->num_rects > 0) {
sub->rects = av_mallocz_array(sizeof(*sub->rects), sub->num_rects);
if (!sub->rects) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < sub->num_rects; i++) {
sub->rects[i] = av_mallocz(sizeof(*sub->rects[i]));
if (!sub->rects[i]) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
i = 0;
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (!region)
continue;
if (!region->dirty)
continue;
rect = sub->rects[i];
rect->x = display->x_pos + offset_x;
rect->y = display->y_pos + offset_y;
rect->w = region->width;
rect->h = region->height;
rect->nb_colors = (1 << region->depth);
rect->type = SUBTITLE_BITMAP;
rect->linesize[0] = region->width;
clut = get_clut(ctx, region->clut);
if (!clut)
clut = &default_clut;
switch (region->depth) {
case 2:
clut_table = clut->clut4;
break;
case 8:
clut_table = clut->clut256;
break;
case 4:
default:
clut_table = clut->clut16;
break;
}
rect->data[1] = av_mallocz(AVPALETTE_SIZE);
if (!rect->data[1]) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
rect->data[0] = av_malloc(region->buf_size);
if (!rect->data[0]) {
ret = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[0], region->pbuf, region->buf_size);
if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)
compute_default_clut(rect, rect->w, rect->h);
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
int j;
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
i++;
}
}
return 0;
fail:
if (sub->rects) {
for(i=0; i<sub->num_rects; i++) {
rect = sub->rects[i];
if (rect) {
av_freep(&rect->data[0]);
av_freep(&rect->data[1]);
}
av_freep(&sub->rects[i]);
}
av_freep(&sub->rects);
}
sub->num_rects = 0;
return ret;
}
| {
"code": [
" if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)",
" compute_default_clut(rect, rect->w, rect->h);"
],
"line_no": [
213,
215
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1, int *VAR_2)
{
DVBSubContext *ctx = VAR_0->priv_data;
DVBSubRegionDisplay *display;
DVBSubDisplayDefinition *display_def = ctx->display_definition;
DVBSubRegion *region;
AVSubtitleRect *rect;
DVBSubCLUT *clut;
uint32_t *clut_table;
int VAR_3;
int VAR_4=0, VAR_5=0;
int VAR_6 = 0;
if (display_def) {
VAR_4 = display_def->x;
VAR_5 = display_def->y;
}
if(VAR_1->num_rects) {
avpriv_request_sample(ctx, "Different Version of Segment asked Twice");
return AVERROR_PATCHWELCOME;
}
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (region && region->dirty)
VAR_1->num_rects++;
}
if(ctx->compute_edt == 0) {
VAR_1->end_display_time = ctx->time_out * 1000;
*VAR_2 = 1;
} else if (ctx->prev_start != AV_NOPTS_VALUE) {
VAR_1->end_display_time = av_rescale_q((VAR_1->pts - ctx->prev_start ), AV_TIME_BASE_Q, (AVRational){ 1, 1000 }) - 1;
*VAR_2 = 1;
}
if (VAR_1->num_rects > 0) {
VAR_1->rects = av_mallocz_array(sizeof(*VAR_1->rects), VAR_1->num_rects);
if (!VAR_1->rects) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
for (VAR_3 = 0; VAR_3 < VAR_1->num_rects; VAR_3++) {
VAR_1->rects[VAR_3] = av_mallocz(sizeof(*VAR_1->rects[VAR_3]));
if (!VAR_1->rects[VAR_3]) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
}
VAR_3 = 0;
for (display = ctx->display_list; display; display = display->next) {
region = get_region(ctx, display->region_id);
if (!region)
continue;
if (!region->dirty)
continue;
rect = VAR_1->rects[VAR_3];
rect->x = display->x_pos + VAR_4;
rect->y = display->y_pos + VAR_5;
rect->w = region->width;
rect->h = region->height;
rect->nb_colors = (1 << region->depth);
rect->type = SUBTITLE_BITMAP;
rect->linesize[0] = region->width;
clut = get_clut(ctx, region->clut);
if (!clut)
clut = &default_clut;
switch (region->depth) {
case 2:
clut_table = clut->clut4;
break;
case 8:
clut_table = clut->clut256;
break;
case 4:
default:
clut_table = clut->clut16;
break;
}
rect->data[1] = av_mallocz(AVPALETTE_SIZE);
if (!rect->data[1]) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
rect->data[0] = av_malloc(region->buf_size);
if (!rect->data[0]) {
VAR_6 = AVERROR(ENOMEM);
goto fail;
}
memcpy(rect->data[0], region->pbuf, region->buf_size);
if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)
compute_default_clut(rect, rect->w, rect->h);
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
int j;
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_3++;
}
}
return 0;
fail:
if (VAR_1->rects) {
for(VAR_3=0; VAR_3<VAR_1->num_rects; VAR_3++) {
rect = VAR_1->rects[VAR_3];
if (rect) {
av_freep(&rect->data[0]);
av_freep(&rect->data[1]);
}
av_freep(&VAR_1->rects[VAR_3]);
}
av_freep(&VAR_1->rects);
}
VAR_1->num_rects = 0;
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1, int *VAR_2)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"DVBSubRegionDisplay *display;",
"DVBSubDisplayDefinition *display_def = ctx->display_definition;",
"DVBSubRegion *region;",
"AVSubtitleRect *rect;",
"DVBSubCLUT *clut;",
"uint32_t *clut_table;",
"int VAR_3;",
"int VAR_4=0, VAR_5=0;",
"int VAR_6 = 0;",
"if (display_def) {",
"VAR_4 = display_def->x;",
"VAR_5 = display_def->y;",
"}",
"if(VAR_1->num_rects) {",
"avpriv_request_sample(ctx, \"Different Version of Segment asked Twice\");",
"return AVERROR_PATCHWELCOME;",
"}",
"for (display = ctx->display_list; display; display = display->next) {",
"region = get_region(ctx, display->region_id);",
"if (region && region->dirty)\nVAR_1->num_rects++;",
"}",
"if(ctx->compute_edt == 0) {",
"VAR_1->end_display_time = ctx->time_out * 1000;",
"*VAR_2 = 1;",
"} else if (ctx->prev_start != AV_NOPTS_VALUE) {",
"VAR_1->end_display_time = av_rescale_q((VAR_1->pts - ctx->prev_start ), AV_TIME_BASE_Q, (AVRational){ 1, 1000 }) - 1;",
"*VAR_2 = 1;",
"}",
"if (VAR_1->num_rects > 0) {",
"VAR_1->rects = av_mallocz_array(sizeof(*VAR_1->rects), VAR_1->num_rects);",
"if (!VAR_1->rects) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_1->num_rects; VAR_3++) {",
"VAR_1->rects[VAR_3] = av_mallocz(sizeof(*VAR_1->rects[VAR_3]));",
"if (!VAR_1->rects[VAR_3]) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"VAR_3 = 0;",
"for (display = ctx->display_list; display; display = display->next) {",
"region = get_region(ctx, display->region_id);",
"if (!region)\ncontinue;",
"if (!region->dirty)\ncontinue;",
"rect = VAR_1->rects[VAR_3];",
"rect->x = display->x_pos + VAR_4;",
"rect->y = display->y_pos + VAR_5;",
"rect->w = region->width;",
"rect->h = region->height;",
"rect->nb_colors = (1 << region->depth);",
"rect->type = SUBTITLE_BITMAP;",
"rect->linesize[0] = region->width;",
"clut = get_clut(ctx, region->clut);",
"if (!clut)\nclut = &default_clut;",
"switch (region->depth) {",
"case 2:\nclut_table = clut->clut4;",
"break;",
"case 8:\nclut_table = clut->clut256;",
"break;",
"case 4:\ndefault:\nclut_table = clut->clut16;",
"break;",
"}",
"rect->data[1] = av_mallocz(AVPALETTE_SIZE);",
"if (!rect->data[1]) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));",
"rect->data[0] = av_malloc(region->buf_size);",
"if (!rect->data[0]) {",
"VAR_6 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"memcpy(rect->data[0], region->pbuf, region->buf_size);",
"if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)\ncompute_default_clut(rect, rect->w, rect->h);",
"#if FF_API_AVPICTURE\nFF_DISABLE_DEPRECATION_WARNINGS\n{",
"int j;",
"for (j = 0; j < 4; j++) {",
"rect->pict.data[j] = rect->data[j];",
"rect->pict.linesize[j] = rect->linesize[j];",
"}",
"}",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_3++;",
"}",
"}",
"return 0;",
"fail:\nif (VAR_1->rects) {",
"for(VAR_3=0; VAR_3<VAR_1->num_rects; VAR_3++) {",
"rect = VAR_1->rects[VAR_3];",
"if (rect) {",
"av_freep(&rect->data[0]);",
"av_freep(&rect->data[1]);",
"}",
"av_freep(&VAR_1->rects[VAR_3]);",
"}",
"av_freep(&VAR_1->rects);",
"}",
"VAR_1->num_rects = 0;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
117,
119
],
[
123,
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
151,
153
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171,
173,
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
213,
215
],
[
219,
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239,
243
],
[
245
],
[
247
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
]
] |
19,877 | static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc,
unsigned int function, unsigned int site,
unsigned int position, unsigned int device,
uint32_t *val)
{
/* We don't support anything other than DCC 0, board stack position 0
* or sites other than motherboard/daughterboard:
*/
if (dcc != 0 || position != 0 ||
(site != SYS_CFG_SITE_MB && site != SYS_CFG_SITE_DB1)) {
goto cfgctrl_unimp;
}
switch (function) {
case SYS_CFG_VOLT:
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) {
*val = s->db_voltage[device];
return true;
}
if (site == SYS_CFG_SITE_MB && device == 0) {
/* There is only one motherboard voltage sensor:
* VIO : 3.3V : bus voltage between mother and daughterboard
*/
*val = 3300000;
return true;
}
break;
case SYS_CFG_OSC:
if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {
/* motherboard clock */
*val = s->mb_clock[device];
return true;
}
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_clocks) {
/* daughterboard clock */
*val = s->db_clock[device];
return true;
}
break;
default:
break;
}
cfgctrl_unimp:
qemu_log_mask(LOG_UNIMP,
"arm_sysctl: Unimplemented SYS_CFGCTRL read of function "
"0x%x DCC 0x%x site 0x%x position 0x%x device 0x%x\n",
function, dcc, site, position, device);
return false;
}
| true | qemu | ec1efab95767312ff4afb816d0d4b548e093b031 | static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc,
unsigned int function, unsigned int site,
unsigned int position, unsigned int device,
uint32_t *val)
{
if (dcc != 0 || position != 0 ||
(site != SYS_CFG_SITE_MB && site != SYS_CFG_SITE_DB1)) {
goto cfgctrl_unimp;
}
switch (function) {
case SYS_CFG_VOLT:
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) {
*val = s->db_voltage[device];
return true;
}
if (site == SYS_CFG_SITE_MB && device == 0) {
*val = 3300000;
return true;
}
break;
case SYS_CFG_OSC:
if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {
*val = s->mb_clock[device];
return true;
}
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_clocks) {
*val = s->db_clock[device];
return true;
}
break;
default:
break;
}
cfgctrl_unimp:
qemu_log_mask(LOG_UNIMP,
"arm_sysctl: Unimplemented SYS_CFGCTRL read of function "
"0x%x DCC 0x%x site 0x%x position 0x%x device 0x%x\n",
function, dcc, site, position, device);
return false;
}
| {
"code": [
" if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {",
" if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {"
],
"line_no": [
57,
57
]
} | static bool FUNC_0(arm_sysctl_state *s, unsigned int dcc,
unsigned int function, unsigned int site,
unsigned int position, unsigned int device,
uint32_t *val)
{
if (dcc != 0 || position != 0 ||
(site != SYS_CFG_SITE_MB && site != SYS_CFG_SITE_DB1)) {
goto cfgctrl_unimp;
}
switch (function) {
case SYS_CFG_VOLT:
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) {
*val = s->db_voltage[device];
return true;
}
if (site == SYS_CFG_SITE_MB && device == 0) {
*val = 3300000;
return true;
}
break;
case SYS_CFG_OSC:
if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {
*val = s->mb_clock[device];
return true;
}
if (site == SYS_CFG_SITE_DB1 && device < s->db_num_clocks) {
*val = s->db_clock[device];
return true;
}
break;
default:
break;
}
cfgctrl_unimp:
qemu_log_mask(LOG_UNIMP,
"arm_sysctl: Unimplemented SYS_CFGCTRL read of function "
"0x%x DCC 0x%x site 0x%x position 0x%x device 0x%x\n",
function, dcc, site, position, device);
return false;
}
| [
"static bool FUNC_0(arm_sysctl_state *s, unsigned int dcc,\nunsigned int function, unsigned int site,\nunsigned int position, unsigned int device,\nuint32_t *val)\n{",
"if (dcc != 0 || position != 0 ||\n(site != SYS_CFG_SITE_MB && site != SYS_CFG_SITE_DB1)) {",
"goto cfgctrl_unimp;",
"}",
"switch (function) {",
"case SYS_CFG_VOLT:\nif (site == SYS_CFG_SITE_DB1 && device < s->db_num_vsensors) {",
"*val = s->db_voltage[device];",
"return true;",
"}",
"if (site == SYS_CFG_SITE_MB && device == 0) {",
"*val = 3300000;",
"return true;",
"}",
"break;",
"case SYS_CFG_OSC:\nif (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) {",
"*val = s->mb_clock[device];",
"return true;",
"}",
"if (site == SYS_CFG_SITE_DB1 && device < s->db_num_clocks) {",
"*val = s->db_clock[device];",
"return true;",
"}",
"break;",
"default:\nbreak;",
"}",
"cfgctrl_unimp:\nqemu_log_mask(LOG_UNIMP,\n\"arm_sysctl: Unimplemented SYS_CFGCTRL read of function \"\n\"0x%x DCC 0x%x site 0x%x position 0x%x device 0x%x\\n\",\nfunction, dcc, site, position, device);",
"return false;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
87,
89,
91,
93,
95
],
[
97
],
[
99
]
] |
19,878 | static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset)
{
GetBitContext *gb = &v->s.gb;
int index, escape, run = 0, level = 0, lst = 0;
index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
if (index != vc1_ac_sizes[codingset] - 1) {
run = vc1_index_decode_table[codingset][index][0];
level = vc1_index_decode_table[codingset][index][1];
lst = index >= vc1_last_decode_table[codingset];
if(get_bits1(gb))
level = -level;
} else {
escape = decode210(gb);
if (escape != 2) {
index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
run = vc1_index_decode_table[codingset][index][0];
level = vc1_index_decode_table[codingset][index][1];
lst = index >= vc1_last_decode_table[codingset];
if(escape == 0) {
if(lst)
level += vc1_last_delta_level_table[codingset][run];
else
level += vc1_delta_level_table[codingset][run];
} else {
if(lst)
run += vc1_last_delta_run_table[codingset][level] + 1;
else
run += vc1_delta_run_table[codingset][level] + 1;
}
if(get_bits1(gb))
level = -level;
} else {
int sign;
lst = get_bits1(gb);
if(v->s.esc3_level_length == 0) {
if(v->pq < 8 || v->dquantfrm) { // table 59
v->s.esc3_level_length = get_bits(gb, 3);
if(!v->s.esc3_level_length)
v->s.esc3_level_length = get_bits(gb, 2) + 8;
} else { //table 60
v->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
}
v->s.esc3_run_length = 3 + get_bits(gb, 2);
}
run = get_bits(gb, v->s.esc3_run_length);
sign = get_bits1(gb);
level = get_bits(gb, v->s.esc3_level_length);
if(sign)
level = -level;
}
}
*last = lst;
*skip = run;
*value = level;
}
| true | FFmpeg | 2bbec1eda46d907605772a8b6e8263caa4bc4c82 | static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset)
{
GetBitContext *gb = &v->s.gb;
int index, escape, run = 0, level = 0, lst = 0;
index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
if (index != vc1_ac_sizes[codingset] - 1) {
run = vc1_index_decode_table[codingset][index][0];
level = vc1_index_decode_table[codingset][index][1];
lst = index >= vc1_last_decode_table[codingset];
if(get_bits1(gb))
level = -level;
} else {
escape = decode210(gb);
if (escape != 2) {
index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
run = vc1_index_decode_table[codingset][index][0];
level = vc1_index_decode_table[codingset][index][1];
lst = index >= vc1_last_decode_table[codingset];
if(escape == 0) {
if(lst)
level += vc1_last_delta_level_table[codingset][run];
else
level += vc1_delta_level_table[codingset][run];
} else {
if(lst)
run += vc1_last_delta_run_table[codingset][level] + 1;
else
run += vc1_delta_run_table[codingset][level] + 1;
}
if(get_bits1(gb))
level = -level;
} else {
int sign;
lst = get_bits1(gb);
if(v->s.esc3_level_length == 0) {
if(v->pq < 8 || v->dquantfrm) {
v->s.esc3_level_length = get_bits(gb, 3);
if(!v->s.esc3_level_length)
v->s.esc3_level_length = get_bits(gb, 2) + 8;
} else {
v->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
}
v->s.esc3_run_length = 3 + get_bits(gb, 2);
}
run = get_bits(gb, v->s.esc3_run_length);
sign = get_bits1(gb);
level = get_bits(gb, v->s.esc3_level_length);
if(sign)
level = -level;
}
}
*last = lst;
*skip = run;
*value = level;
}
| {
"code": [
" lst = index >= vc1_last_decode_table[codingset];"
],
"line_no": [
19
]
} | static void FUNC_0(VC1Context *VAR_0, int *VAR_1, int *VAR_2, int *VAR_3, int VAR_4)
{
GetBitContext *gb = &VAR_0->s.gb;
int VAR_5, VAR_6, VAR_7 = 0, VAR_8 = 0, VAR_9 = 0;
VAR_5 = get_vlc2(gb, ff_vc1_ac_coeff_table[VAR_4].table, AC_VLC_BITS, 3);
if (VAR_5 != vc1_ac_sizes[VAR_4] - 1) {
VAR_7 = vc1_index_decode_table[VAR_4][VAR_5][0];
VAR_8 = vc1_index_decode_table[VAR_4][VAR_5][1];
VAR_9 = VAR_5 >= vc1_last_decode_table[VAR_4];
if(get_bits1(gb))
VAR_8 = -VAR_8;
} else {
VAR_6 = decode210(gb);
if (VAR_6 != 2) {
VAR_5 = get_vlc2(gb, ff_vc1_ac_coeff_table[VAR_4].table, AC_VLC_BITS, 3);
VAR_7 = vc1_index_decode_table[VAR_4][VAR_5][0];
VAR_8 = vc1_index_decode_table[VAR_4][VAR_5][1];
VAR_9 = VAR_5 >= vc1_last_decode_table[VAR_4];
if(VAR_6 == 0) {
if(VAR_9)
VAR_8 += vc1_last_delta_level_table[VAR_4][VAR_7];
else
VAR_8 += vc1_delta_level_table[VAR_4][VAR_7];
} else {
if(VAR_9)
VAR_7 += vc1_last_delta_run_table[VAR_4][VAR_8] + 1;
else
VAR_7 += vc1_delta_run_table[VAR_4][VAR_8] + 1;
}
if(get_bits1(gb))
VAR_8 = -VAR_8;
} else {
int VAR_10;
VAR_9 = get_bits1(gb);
if(VAR_0->s.esc3_level_length == 0) {
if(VAR_0->pq < 8 || VAR_0->dquantfrm) {
VAR_0->s.esc3_level_length = get_bits(gb, 3);
if(!VAR_0->s.esc3_level_length)
VAR_0->s.esc3_level_length = get_bits(gb, 2) + 8;
} else {
VAR_0->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
}
VAR_0->s.esc3_run_length = 3 + get_bits(gb, 2);
}
VAR_7 = get_bits(gb, VAR_0->s.esc3_run_length);
VAR_10 = get_bits1(gb);
VAR_8 = get_bits(gb, VAR_0->s.esc3_level_length);
if(VAR_10)
VAR_8 = -VAR_8;
}
}
*VAR_1 = VAR_9;
*VAR_2 = VAR_7;
*VAR_3 = VAR_8;
}
| [
"static void FUNC_0(VC1Context *VAR_0, int *VAR_1, int *VAR_2, int *VAR_3, int VAR_4)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"int VAR_5, VAR_6, VAR_7 = 0, VAR_8 = 0, VAR_9 = 0;",
"VAR_5 = get_vlc2(gb, ff_vc1_ac_coeff_table[VAR_4].table, AC_VLC_BITS, 3);",
"if (VAR_5 != vc1_ac_sizes[VAR_4] - 1) {",
"VAR_7 = vc1_index_decode_table[VAR_4][VAR_5][0];",
"VAR_8 = vc1_index_decode_table[VAR_4][VAR_5][1];",
"VAR_9 = VAR_5 >= vc1_last_decode_table[VAR_4];",
"if(get_bits1(gb))\nVAR_8 = -VAR_8;",
"} else {",
"VAR_6 = decode210(gb);",
"if (VAR_6 != 2) {",
"VAR_5 = get_vlc2(gb, ff_vc1_ac_coeff_table[VAR_4].table, AC_VLC_BITS, 3);",
"VAR_7 = vc1_index_decode_table[VAR_4][VAR_5][0];",
"VAR_8 = vc1_index_decode_table[VAR_4][VAR_5][1];",
"VAR_9 = VAR_5 >= vc1_last_decode_table[VAR_4];",
"if(VAR_6 == 0) {",
"if(VAR_9)\nVAR_8 += vc1_last_delta_level_table[VAR_4][VAR_7];",
"else\nVAR_8 += vc1_delta_level_table[VAR_4][VAR_7];",
"} else {",
"if(VAR_9)\nVAR_7 += vc1_last_delta_run_table[VAR_4][VAR_8] + 1;",
"else\nVAR_7 += vc1_delta_run_table[VAR_4][VAR_8] + 1;",
"}",
"if(get_bits1(gb))\nVAR_8 = -VAR_8;",
"} else {",
"int VAR_10;",
"VAR_9 = get_bits1(gb);",
"if(VAR_0->s.esc3_level_length == 0) {",
"if(VAR_0->pq < 8 || VAR_0->dquantfrm) {",
"VAR_0->s.esc3_level_length = get_bits(gb, 3);",
"if(!VAR_0->s.esc3_level_length)\nVAR_0->s.esc3_level_length = get_bits(gb, 2) + 8;",
"} else {",
"VAR_0->s.esc3_level_length = get_unary(gb, 1, 6) + 2;",
"}",
"VAR_0->s.esc3_run_length = 3 + get_bits(gb, 2);",
"}",
"VAR_7 = get_bits(gb, VAR_0->s.esc3_run_length);",
"VAR_10 = get_bits1(gb);",
"VAR_8 = get_bits(gb, VAR_0->s.esc3_level_length);",
"if(VAR_10)\nVAR_8 = -VAR_8;",
"}",
"}",
"*VAR_1 = VAR_9;",
"*VAR_2 = VAR_7;",
"*VAR_3 = VAR_8;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
]
] |
19,879 | static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic,
int trellis_node, int x, int y, int mbs_per_slice,
ProresThreadData *td)
{
ProresContext *ctx = avctx->priv_data;
int i, q, pq, xp, yp;
const uint16_t *src;
int slice_width_factor = av_log2(mbs_per_slice);
int num_cblocks[MAX_PLANES], pwidth;
int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];
const int min_quant = ctx->profile_info->min_quant;
const int max_quant = ctx->profile_info->max_quant;
int error, bits, bits_limit;
int mbs, prev, cur, new_score;
int slice_bits[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];
int overquant;
uint16_t *qmat;
int linesize[4], line_add;
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
line_add = ctx->cur_picture_idx ^ !pic->top_field_first;
mbs = x + mbs_per_slice;
for (i = 0; i < ctx->num_planes; i++) {
is_chroma[i] = (i == 1 || i == 2);
plane_factor[i] = slice_width_factor + 2;
if (is_chroma[i])
plane_factor[i] += ctx->chroma_factor - 3;
if (!is_chroma[i] || ctx->chroma_factor == CFACTOR_Y444) {
xp = x << 4;
yp = y << 4;
num_cblocks[i] = 4;
pwidth = avctx->width;
} else {
xp = x << 3;
yp = y << 4;
num_cblocks[i] = 2;
pwidth = avctx->width >> 1;
}
linesize[i] = pic->linesize[i] * ctx->pictures_per_frame;
src = (const uint16_t*)(pic->data[i] + yp * linesize[i] +
line_add * pic->linesize[i]) + xp;
if (i < 3) {
get_slice_data(ctx, src, linesize[i], xp, yp,
pwidth, avctx->height / ctx->pictures_per_frame,
td->blocks[i], td->emu_buf,
mbs_per_slice, num_cblocks[i], is_chroma[i]);
} else {
get_alpha_data(ctx, src, linesize[i], xp, yp,
pwidth, avctx->height / ctx->pictures_per_frame,
td->blocks[i], mbs_per_slice, ctx->alpha_bits);
}
}
for (q = min_quant; q < max_quant + 2; q++) {
td->nodes[trellis_node + q].prev_node = -1;
td->nodes[trellis_node + q].quant = q;
}
// todo: maybe perform coarser quantising to fit into frame size when needed
for (q = min_quant; q <= max_quant; q++) {
bits = 0;
error = 0;
for (i = 0; i < ctx->num_planes - !!ctx->alpha_bits; i++) {
bits += estimate_slice_plane(ctx, &error, i,
src, linesize[i],
mbs_per_slice,
num_cblocks[i], plane_factor[i],
ctx->quants[q], td);
}
if (ctx->alpha_bits)
bits += estimate_alpha_plane(ctx, &error, src, linesize[3],
mbs_per_slice, q, td->blocks[3]);
if (bits > 65000 * 8) {
error = SCORE_LIMIT;
break;
}
slice_bits[q] = bits;
slice_score[q] = error;
}
if (slice_bits[max_quant] <= ctx->bits_per_mb * mbs_per_slice) {
slice_bits[max_quant + 1] = slice_bits[max_quant];
slice_score[max_quant + 1] = slice_score[max_quant] + 1;
overquant = max_quant;
} else {
for (q = max_quant + 1; q < 128; q++) {
bits = 0;
error = 0;
if (q < MAX_STORED_Q) {
qmat = ctx->quants[q];
} else {
qmat = td->custom_q;
for (i = 0; i < 64; i++)
qmat[i] = ctx->quant_mat[i] * q;
}
for (i = 0; i < ctx->num_planes - !!ctx->alpha_bits; i++) {
bits += estimate_slice_plane(ctx, &error, i,
src, linesize[i],
mbs_per_slice,
num_cblocks[i], plane_factor[i],
qmat, td);
}
if (ctx->alpha_bits)
bits += estimate_alpha_plane(ctx, &error, src, linesize[3],
mbs_per_slice, q, td->blocks[3]);
if (bits <= ctx->bits_per_mb * mbs_per_slice)
break;
}
slice_bits[max_quant + 1] = bits;
slice_score[max_quant + 1] = error;
overquant = q;
}
td->nodes[trellis_node + max_quant + 1].quant = overquant;
bits_limit = mbs * ctx->bits_per_mb;
for (pq = min_quant; pq < max_quant + 2; pq++) {
prev = trellis_node - TRELLIS_WIDTH + pq;
for (q = min_quant; q < max_quant + 2; q++) {
cur = trellis_node + q;
bits = td->nodes[prev].bits + slice_bits[q];
error = slice_score[q];
if (bits > bits_limit)
error = SCORE_LIMIT;
if (td->nodes[prev].score < SCORE_LIMIT && error < SCORE_LIMIT)
new_score = td->nodes[prev].score + error;
else
new_score = SCORE_LIMIT;
if (td->nodes[cur].prev_node == -1 ||
td->nodes[cur].score >= new_score) {
td->nodes[cur].bits = bits;
td->nodes[cur].score = new_score;
td->nodes[cur].prev_node = prev;
}
}
}
error = td->nodes[trellis_node + min_quant].score;
pq = trellis_node + min_quant;
for (q = min_quant + 1; q < max_quant + 2; q++) {
if (td->nodes[trellis_node + q].score <= error) {
error = td->nodes[trellis_node + q].score;
pq = trellis_node + q;
}
}
return pq;
}
| true | FFmpeg | 4690e01c3aaf495c87127e5dc74aa347197dbc0b | static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic,
int trellis_node, int x, int y, int mbs_per_slice,
ProresThreadData *td)
{
ProresContext *ctx = avctx->priv_data;
int i, q, pq, xp, yp;
const uint16_t *src;
int slice_width_factor = av_log2(mbs_per_slice);
int num_cblocks[MAX_PLANES], pwidth;
int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];
const int min_quant = ctx->profile_info->min_quant;
const int max_quant = ctx->profile_info->max_quant;
int error, bits, bits_limit;
int mbs, prev, cur, new_score;
int slice_bits[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];
int overquant;
uint16_t *qmat;
int linesize[4], line_add;
if (ctx->pictures_per_frame == 1)
line_add = 0;
else
line_add = ctx->cur_picture_idx ^ !pic->top_field_first;
mbs = x + mbs_per_slice;
for (i = 0; i < ctx->num_planes; i++) {
is_chroma[i] = (i == 1 || i == 2);
plane_factor[i] = slice_width_factor + 2;
if (is_chroma[i])
plane_factor[i] += ctx->chroma_factor - 3;
if (!is_chroma[i] || ctx->chroma_factor == CFACTOR_Y444) {
xp = x << 4;
yp = y << 4;
num_cblocks[i] = 4;
pwidth = avctx->width;
} else {
xp = x << 3;
yp = y << 4;
num_cblocks[i] = 2;
pwidth = avctx->width >> 1;
}
linesize[i] = pic->linesize[i] * ctx->pictures_per_frame;
src = (const uint16_t*)(pic->data[i] + yp * linesize[i] +
line_add * pic->linesize[i]) + xp;
if (i < 3) {
get_slice_data(ctx, src, linesize[i], xp, yp,
pwidth, avctx->height / ctx->pictures_per_frame,
td->blocks[i], td->emu_buf,
mbs_per_slice, num_cblocks[i], is_chroma[i]);
} else {
get_alpha_data(ctx, src, linesize[i], xp, yp,
pwidth, avctx->height / ctx->pictures_per_frame,
td->blocks[i], mbs_per_slice, ctx->alpha_bits);
}
}
for (q = min_quant; q < max_quant + 2; q++) {
td->nodes[trellis_node + q].prev_node = -1;
td->nodes[trellis_node + q].quant = q;
}
for (q = min_quant; q <= max_quant; q++) {
bits = 0;
error = 0;
for (i = 0; i < ctx->num_planes - !!ctx->alpha_bits; i++) {
bits += estimate_slice_plane(ctx, &error, i,
src, linesize[i],
mbs_per_slice,
num_cblocks[i], plane_factor[i],
ctx->quants[q], td);
}
if (ctx->alpha_bits)
bits += estimate_alpha_plane(ctx, &error, src, linesize[3],
mbs_per_slice, q, td->blocks[3]);
if (bits > 65000 * 8) {
error = SCORE_LIMIT;
break;
}
slice_bits[q] = bits;
slice_score[q] = error;
}
if (slice_bits[max_quant] <= ctx->bits_per_mb * mbs_per_slice) {
slice_bits[max_quant + 1] = slice_bits[max_quant];
slice_score[max_quant + 1] = slice_score[max_quant] + 1;
overquant = max_quant;
} else {
for (q = max_quant + 1; q < 128; q++) {
bits = 0;
error = 0;
if (q < MAX_STORED_Q) {
qmat = ctx->quants[q];
} else {
qmat = td->custom_q;
for (i = 0; i < 64; i++)
qmat[i] = ctx->quant_mat[i] * q;
}
for (i = 0; i < ctx->num_planes - !!ctx->alpha_bits; i++) {
bits += estimate_slice_plane(ctx, &error, i,
src, linesize[i],
mbs_per_slice,
num_cblocks[i], plane_factor[i],
qmat, td);
}
if (ctx->alpha_bits)
bits += estimate_alpha_plane(ctx, &error, src, linesize[3],
mbs_per_slice, q, td->blocks[3]);
if (bits <= ctx->bits_per_mb * mbs_per_slice)
break;
}
slice_bits[max_quant + 1] = bits;
slice_score[max_quant + 1] = error;
overquant = q;
}
td->nodes[trellis_node + max_quant + 1].quant = overquant;
bits_limit = mbs * ctx->bits_per_mb;
for (pq = min_quant; pq < max_quant + 2; pq++) {
prev = trellis_node - TRELLIS_WIDTH + pq;
for (q = min_quant; q < max_quant + 2; q++) {
cur = trellis_node + q;
bits = td->nodes[prev].bits + slice_bits[q];
error = slice_score[q];
if (bits > bits_limit)
error = SCORE_LIMIT;
if (td->nodes[prev].score < SCORE_LIMIT && error < SCORE_LIMIT)
new_score = td->nodes[prev].score + error;
else
new_score = SCORE_LIMIT;
if (td->nodes[cur].prev_node == -1 ||
td->nodes[cur].score >= new_score) {
td->nodes[cur].bits = bits;
td->nodes[cur].score = new_score;
td->nodes[cur].prev_node = prev;
}
}
}
error = td->nodes[trellis_node + min_quant].score;
pq = trellis_node + min_quant;
for (q = min_quant + 1; q < max_quant + 2; q++) {
if (td->nodes[trellis_node + q].score <= error) {
error = td->nodes[trellis_node + q].score;
pq = trellis_node + q;
}
}
return pq;
}
| {
"code": [
" if (bits > 65000 * 8) {",
" break;"
],
"line_no": [
155,
159
]
} | static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5,
ProresThreadData *VAR_6)
{
ProresContext *ctx = VAR_0->priv_data;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
const uint16_t *VAR_12;
int VAR_13 = av_log2(VAR_5);
int VAR_14[MAX_PLANES], pwidth;
int VAR_15[MAX_PLANES], is_chroma[MAX_PLANES];
const int VAR_16 = ctx->profile_info->VAR_16;
const int VAR_17 = ctx->profile_info->VAR_17;
int VAR_18, VAR_19, VAR_20;
int VAR_21, VAR_22, VAR_23, VAR_24;
int VAR_25[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];
int VAR_26;
uint16_t *qmat;
int VAR_27[4], VAR_28;
if (ctx->pictures_per_frame == 1)
VAR_28 = 0;
else
VAR_28 = ctx->cur_picture_idx ^ !VAR_1->top_field_first;
VAR_21 = VAR_3 + VAR_5;
for (VAR_7 = 0; VAR_7 < ctx->num_planes; VAR_7++) {
is_chroma[VAR_7] = (VAR_7 == 1 || VAR_7 == 2);
VAR_15[VAR_7] = VAR_13 + 2;
if (is_chroma[VAR_7])
VAR_15[VAR_7] += ctx->chroma_factor - 3;
if (!is_chroma[VAR_7] || ctx->chroma_factor == CFACTOR_Y444) {
VAR_10 = VAR_3 << 4;
VAR_11 = VAR_4 << 4;
VAR_14[VAR_7] = 4;
pwidth = VAR_0->width;
} else {
VAR_10 = VAR_3 << 3;
VAR_11 = VAR_4 << 4;
VAR_14[VAR_7] = 2;
pwidth = VAR_0->width >> 1;
}
VAR_27[VAR_7] = VAR_1->VAR_27[VAR_7] * ctx->pictures_per_frame;
VAR_12 = (const uint16_t*)(VAR_1->data[VAR_7] + VAR_11 * VAR_27[VAR_7] +
VAR_28 * VAR_1->VAR_27[VAR_7]) + VAR_10;
if (VAR_7 < 3) {
get_slice_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,
pwidth, VAR_0->height / ctx->pictures_per_frame,
VAR_6->blocks[VAR_7], VAR_6->emu_buf,
VAR_5, VAR_14[VAR_7], is_chroma[VAR_7]);
} else {
get_alpha_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,
pwidth, VAR_0->height / ctx->pictures_per_frame,
VAR_6->blocks[VAR_7], VAR_5, ctx->alpha_bits);
}
}
for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {
VAR_6->nodes[VAR_2 + VAR_8].prev_node = -1;
VAR_6->nodes[VAR_2 + VAR_8].quant = VAR_8;
}
for (VAR_8 = VAR_16; VAR_8 <= VAR_17; VAR_8++) {
VAR_19 = 0;
VAR_18 = 0;
for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {
VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,
VAR_12, VAR_27[VAR_7],
VAR_5,
VAR_14[VAR_7], VAR_15[VAR_7],
ctx->quants[VAR_8], VAR_6);
}
if (ctx->alpha_bits)
VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],
VAR_5, VAR_8, VAR_6->blocks[3]);
if (VAR_19 > 65000 * 8) {
VAR_18 = SCORE_LIMIT;
break;
}
VAR_25[VAR_8] = VAR_19;
slice_score[VAR_8] = VAR_18;
}
if (VAR_25[VAR_17] <= ctx->bits_per_mb * VAR_5) {
VAR_25[VAR_17 + 1] = VAR_25[VAR_17];
slice_score[VAR_17 + 1] = slice_score[VAR_17] + 1;
VAR_26 = VAR_17;
} else {
for (VAR_8 = VAR_17 + 1; VAR_8 < 128; VAR_8++) {
VAR_19 = 0;
VAR_18 = 0;
if (VAR_8 < MAX_STORED_Q) {
qmat = ctx->quants[VAR_8];
} else {
qmat = VAR_6->custom_q;
for (VAR_7 = 0; VAR_7 < 64; VAR_7++)
qmat[VAR_7] = ctx->quant_mat[VAR_7] * VAR_8;
}
for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {
VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,
VAR_12, VAR_27[VAR_7],
VAR_5,
VAR_14[VAR_7], VAR_15[VAR_7],
qmat, VAR_6);
}
if (ctx->alpha_bits)
VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],
VAR_5, VAR_8, VAR_6->blocks[3]);
if (VAR_19 <= ctx->bits_per_mb * VAR_5)
break;
}
VAR_25[VAR_17 + 1] = VAR_19;
slice_score[VAR_17 + 1] = VAR_18;
VAR_26 = VAR_8;
}
VAR_6->nodes[VAR_2 + VAR_17 + 1].quant = VAR_26;
VAR_20 = VAR_21 * ctx->bits_per_mb;
for (VAR_9 = VAR_16; VAR_9 < VAR_17 + 2; VAR_9++) {
VAR_22 = VAR_2 - TRELLIS_WIDTH + VAR_9;
for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {
VAR_23 = VAR_2 + VAR_8;
VAR_19 = VAR_6->nodes[VAR_22].VAR_19 + VAR_25[VAR_8];
VAR_18 = slice_score[VAR_8];
if (VAR_19 > VAR_20)
VAR_18 = SCORE_LIMIT;
if (VAR_6->nodes[VAR_22].score < SCORE_LIMIT && VAR_18 < SCORE_LIMIT)
VAR_24 = VAR_6->nodes[VAR_22].score + VAR_18;
else
VAR_24 = SCORE_LIMIT;
if (VAR_6->nodes[VAR_23].prev_node == -1 ||
VAR_6->nodes[VAR_23].score >= VAR_24) {
VAR_6->nodes[VAR_23].VAR_19 = VAR_19;
VAR_6->nodes[VAR_23].score = VAR_24;
VAR_6->nodes[VAR_23].prev_node = VAR_22;
}
}
}
VAR_18 = VAR_6->nodes[VAR_2 + VAR_16].score;
VAR_9 = VAR_2 + VAR_16;
for (VAR_8 = VAR_16 + 1; VAR_8 < VAR_17 + 2; VAR_8++) {
if (VAR_6->nodes[VAR_2 + VAR_8].score <= VAR_18) {
VAR_18 = VAR_6->nodes[VAR_2 + VAR_8].score;
VAR_9 = VAR_2 + VAR_8;
}
}
return VAR_9;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,\nint VAR_2, int VAR_3, int VAR_4, int VAR_5,\nProresThreadData *VAR_6)\n{",
"ProresContext *ctx = VAR_0->priv_data;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"const uint16_t *VAR_12;",
"int VAR_13 = av_log2(VAR_5);",
"int VAR_14[MAX_PLANES], pwidth;",
"int VAR_15[MAX_PLANES], is_chroma[MAX_PLANES];",
"const int VAR_16 = ctx->profile_info->VAR_16;",
"const int VAR_17 = ctx->profile_info->VAR_17;",
"int VAR_18, VAR_19, VAR_20;",
"int VAR_21, VAR_22, VAR_23, VAR_24;",
"int VAR_25[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];",
"int VAR_26;",
"uint16_t *qmat;",
"int VAR_27[4], VAR_28;",
"if (ctx->pictures_per_frame == 1)\nVAR_28 = 0;",
"else\nVAR_28 = ctx->cur_picture_idx ^ !VAR_1->top_field_first;",
"VAR_21 = VAR_3 + VAR_5;",
"for (VAR_7 = 0; VAR_7 < ctx->num_planes; VAR_7++) {",
"is_chroma[VAR_7] = (VAR_7 == 1 || VAR_7 == 2);",
"VAR_15[VAR_7] = VAR_13 + 2;",
"if (is_chroma[VAR_7])\nVAR_15[VAR_7] += ctx->chroma_factor - 3;",
"if (!is_chroma[VAR_7] || ctx->chroma_factor == CFACTOR_Y444) {",
"VAR_10 = VAR_3 << 4;",
"VAR_11 = VAR_4 << 4;",
"VAR_14[VAR_7] = 4;",
"pwidth = VAR_0->width;",
"} else {",
"VAR_10 = VAR_3 << 3;",
"VAR_11 = VAR_4 << 4;",
"VAR_14[VAR_7] = 2;",
"pwidth = VAR_0->width >> 1;",
"}",
"VAR_27[VAR_7] = VAR_1->VAR_27[VAR_7] * ctx->pictures_per_frame;",
"VAR_12 = (const uint16_t*)(VAR_1->data[VAR_7] + VAR_11 * VAR_27[VAR_7] +\nVAR_28 * VAR_1->VAR_27[VAR_7]) + VAR_10;",
"if (VAR_7 < 3) {",
"get_slice_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,\npwidth, VAR_0->height / ctx->pictures_per_frame,\nVAR_6->blocks[VAR_7], VAR_6->emu_buf,\nVAR_5, VAR_14[VAR_7], is_chroma[VAR_7]);",
"} else {",
"get_alpha_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,\npwidth, VAR_0->height / ctx->pictures_per_frame,\nVAR_6->blocks[VAR_7], VAR_5, ctx->alpha_bits);",
"}",
"}",
"for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {",
"VAR_6->nodes[VAR_2 + VAR_8].prev_node = -1;",
"VAR_6->nodes[VAR_2 + VAR_8].quant = VAR_8;",
"}",
"for (VAR_8 = VAR_16; VAR_8 <= VAR_17; VAR_8++) {",
"VAR_19 = 0;",
"VAR_18 = 0;",
"for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {",
"VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,\nVAR_12, VAR_27[VAR_7],\nVAR_5,\nVAR_14[VAR_7], VAR_15[VAR_7],\nctx->quants[VAR_8], VAR_6);",
"}",
"if (ctx->alpha_bits)\nVAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],\nVAR_5, VAR_8, VAR_6->blocks[3]);",
"if (VAR_19 > 65000 * 8) {",
"VAR_18 = SCORE_LIMIT;",
"break;",
"}",
"VAR_25[VAR_8] = VAR_19;",
"slice_score[VAR_8] = VAR_18;",
"}",
"if (VAR_25[VAR_17] <= ctx->bits_per_mb * VAR_5) {",
"VAR_25[VAR_17 + 1] = VAR_25[VAR_17];",
"slice_score[VAR_17 + 1] = slice_score[VAR_17] + 1;",
"VAR_26 = VAR_17;",
"} else {",
"for (VAR_8 = VAR_17 + 1; VAR_8 < 128; VAR_8++) {",
"VAR_19 = 0;",
"VAR_18 = 0;",
"if (VAR_8 < MAX_STORED_Q) {",
"qmat = ctx->quants[VAR_8];",
"} else {",
"qmat = VAR_6->custom_q;",
"for (VAR_7 = 0; VAR_7 < 64; VAR_7++)",
"qmat[VAR_7] = ctx->quant_mat[VAR_7] * VAR_8;",
"}",
"for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {",
"VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,\nVAR_12, VAR_27[VAR_7],\nVAR_5,\nVAR_14[VAR_7], VAR_15[VAR_7],\nqmat, VAR_6);",
"}",
"if (ctx->alpha_bits)\nVAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],\nVAR_5, VAR_8, VAR_6->blocks[3]);",
"if (VAR_19 <= ctx->bits_per_mb * VAR_5)\nbreak;",
"}",
"VAR_25[VAR_17 + 1] = VAR_19;",
"slice_score[VAR_17 + 1] = VAR_18;",
"VAR_26 = VAR_8;",
"}",
"VAR_6->nodes[VAR_2 + VAR_17 + 1].quant = VAR_26;",
"VAR_20 = VAR_21 * ctx->bits_per_mb;",
"for (VAR_9 = VAR_16; VAR_9 < VAR_17 + 2; VAR_9++) {",
"VAR_22 = VAR_2 - TRELLIS_WIDTH + VAR_9;",
"for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {",
"VAR_23 = VAR_2 + VAR_8;",
"VAR_19 = VAR_6->nodes[VAR_22].VAR_19 + VAR_25[VAR_8];",
"VAR_18 = slice_score[VAR_8];",
"if (VAR_19 > VAR_20)\nVAR_18 = SCORE_LIMIT;",
"if (VAR_6->nodes[VAR_22].score < SCORE_LIMIT && VAR_18 < SCORE_LIMIT)\nVAR_24 = VAR_6->nodes[VAR_22].score + VAR_18;",
"else\nVAR_24 = SCORE_LIMIT;",
"if (VAR_6->nodes[VAR_23].prev_node == -1 ||\nVAR_6->nodes[VAR_23].score >= VAR_24) {",
"VAR_6->nodes[VAR_23].VAR_19 = VAR_19;",
"VAR_6->nodes[VAR_23].score = VAR_24;",
"VAR_6->nodes[VAR_23].prev_node = VAR_22;",
"}",
"}",
"}",
"VAR_18 = VAR_6->nodes[VAR_2 + VAR_16].score;",
"VAR_9 = VAR_2 + VAR_16;",
"for (VAR_8 = VAR_16 + 1; VAR_8 < VAR_17 + 2; VAR_8++) {",
"if (VAR_6->nodes[VAR_2 + VAR_8].score <= VAR_18) {",
"VAR_18 = VAR_6->nodes[VAR_2 + VAR_8].score;",
"VAR_9 = VAR_2 + VAR_8;",
"}",
"}",
"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,
1,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87,
89
],
[
93
],
[
95,
97,
99,
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
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
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257,
259
],
[
263,
265
],
[
267,
269
],
[
271,
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
]
] |
19,880 | static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
{
int i;
int repeating = 0;
AVPacket avpkt;
if (ist->next_dts == AV_NOPTS_VALUE)
ist->next_dts = ist->last_dts;
if (!pkt) {
/* EOF handling */
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
} else {
avpkt = *pkt;
}
if (pkt && pkt->dts != AV_NOPTS_VALUE)
ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
// while we have more to decode or while the decoder did output something on EOF
while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {
int ret = 0;
int got_output = 0;
if (!repeating)
ist->last_dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output);
break;
case AVMEDIA_TYPE_VIDEO:
ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output);
if (repeating && !got_output)
;
else if (pkt && pkt->duration)
ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
else if (ist->st->avg_frame_rate.num)
ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),
AV_TIME_BASE_Q);
else if (ist->dec_ctx->framerate.num != 0) {
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
ist->dec_ctx->ticks_per_frame;
ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);
}
break;
case AVMEDIA_TYPE_SUBTITLE:
if (repeating)
break;
ret = transcode_subtitles(ist, &avpkt, &got_output);
break;
default:
return;
}
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
break;
}
if (!got_output)
break;
repeating = 1;
}
/* after flushing, send an EOF on all the filter inputs attached to the stream */
/* except when looping we need to flush but not to send an EOF */
if (!pkt && ist->decoding_needed && !no_eof) {
int ret = send_filter_eof(ist);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");
exit_program(1);
}
}
/* handle stream copy */
if (!ist->decoding_needed) {
ist->last_dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
ist->dec_ctx->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (ist->dec_ctx->framerate.num != 0) {
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
ist->next_dts += ((int64_t)AV_TIME_BASE *
ist->dec_ctx->framerate.den * ticks) /
ist->dec_ctx->framerate.num;
}
break;
}
}
for (i = 0; pkt && i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
if (!check_output_constraints(ist, ost) || ost->encoding_needed)
continue;
do_streamcopy(ist, ost, pkt);
}
return;
}
| true | FFmpeg | 27085d1b47c3741cc0fac284c916127c4066d049 | static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
{
int i;
int repeating = 0;
AVPacket avpkt;
if (ist->next_dts == AV_NOPTS_VALUE)
ist->next_dts = ist->last_dts;
if (!pkt) {
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
} else {
avpkt = *pkt;
}
if (pkt && pkt->dts != AV_NOPTS_VALUE)
ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {
int ret = 0;
int got_output = 0;
if (!repeating)
ist->last_dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output);
break;
case AVMEDIA_TYPE_VIDEO:
ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output);
if (repeating && !got_output)
;
else if (pkt && pkt->duration)
ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
else if (ist->st->avg_frame_rate.num)
ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),
AV_TIME_BASE_Q);
else if (ist->dec_ctx->framerate.num != 0) {
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
ist->dec_ctx->ticks_per_frame;
ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);
}
break;
case AVMEDIA_TYPE_SUBTITLE:
if (repeating)
break;
ret = transcode_subtitles(ist, &avpkt, &got_output);
break;
default:
return;
}
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
ist->file_index, ist->st->index);
if (exit_on_error)
exit_program(1);
break;
}
if (!got_output)
break;
repeating = 1;
}
if (!pkt && ist->decoding_needed && !no_eof) {
int ret = send_filter_eof(ist);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");
exit_program(1);
}
}
if (!ist->decoding_needed) {
ist->last_dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
ist->dec_ctx->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (ist->dec_ctx->framerate.num != 0) {
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;
ist->next_dts += ((int64_t)AV_TIME_BASE *
ist->dec_ctx->framerate.den * ticks) /
ist->dec_ctx->framerate.num;
}
break;
}
}
for (i = 0; pkt && i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
if (!check_output_constraints(ist, ost) || ost->encoding_needed)
continue;
do_streamcopy(ist, ost, pkt);
}
return;
}
| {
"code": [
" ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output);",
" ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output);",
" ret = transcode_subtitles(ist, &avpkt, &got_output);",
" av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d\\n\",",
" ist->file_index, ist->st->index);",
" if (exit_on_error)"
],
"line_no": [
63,
69,
103,
117,
119,
121
]
} | static void FUNC_0(InputStream *VAR_0, const AVPacket *VAR_1, int VAR_2)
{
int VAR_3;
int VAR_4 = 0;
AVPacket avpkt;
if (VAR_0->next_dts == AV_NOPTS_VALUE)
VAR_0->next_dts = VAR_0->last_dts;
if (!VAR_1) {
av_init_packet(&avpkt);
avpkt.data = NULL;
avpkt.size = 0;
} else {
avpkt = *VAR_1;
}
if (VAR_1 && VAR_1->dts != AV_NOPTS_VALUE)
VAR_0->next_dts = VAR_0->last_dts = av_rescale_q(VAR_1->dts, VAR_0->st->time_base, AV_TIME_BASE_Q);
while (VAR_0->decoding_needed && (!VAR_1 || avpkt.size > 0)) {
int VAR_8 = 0;
int VAR_6 = 0;
if (!VAR_4)
VAR_0->last_dts = VAR_0->next_dts;
switch (VAR_0->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_8 = decode_audio (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);
break;
case AVMEDIA_TYPE_VIDEO:
VAR_8 = decode_video (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);
if (VAR_4 && !VAR_6)
;
else if (VAR_1 && VAR_1->duration)
VAR_0->next_dts += av_rescale_q(VAR_1->duration, VAR_0->st->time_base, AV_TIME_BASE_Q);
else if (VAR_0->st->avg_frame_rate.num)
VAR_0->next_dts += av_rescale_q(1, av_inv_q(VAR_0->st->avg_frame_rate),
AV_TIME_BASE_Q);
else if (VAR_0->dec_ctx->framerate.num != 0) {
int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 :
VAR_0->dec_ctx->ticks_per_frame;
VAR_0->next_dts += av_rescale_q(VAR_8, VAR_0->dec_ctx->framerate, AV_TIME_BASE_Q);
}
break;
case AVMEDIA_TYPE_SUBTITLE:
if (VAR_4)
break;
VAR_8 = transcode_subtitles(VAR_0, &avpkt, &VAR_6);
break;
default:
return;
}
if (VAR_8 < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n",
VAR_0->file_index, VAR_0->st->index);
if (exit_on_error)
exit_program(1);
break;
}
if (!VAR_6)
break;
VAR_4 = 1;
}
if (!VAR_1 && VAR_0->decoding_needed && !VAR_2) {
int VAR_8 = send_filter_eof(VAR_0);
if (VAR_8 < 0) {
av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");
exit_program(1);
}
}
if (!VAR_0->decoding_needed) {
VAR_0->last_dts = VAR_0->next_dts;
switch (VAR_0->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_0->next_dts += ((int64_t)AV_TIME_BASE * VAR_0->dec_ctx->frame_size) /
VAR_0->dec_ctx->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
if (VAR_0->dec_ctx->framerate.num != 0) {
int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 : VAR_0->dec_ctx->ticks_per_frame;
VAR_0->next_dts += ((int64_t)AV_TIME_BASE *
VAR_0->dec_ctx->framerate.den * VAR_8) /
VAR_0->dec_ctx->framerate.num;
}
break;
}
}
for (VAR_3 = 0; VAR_1 && VAR_3 < nb_output_streams; VAR_3++) {
OutputStream *ost = output_streams[VAR_3];
if (!check_output_constraints(VAR_0, ost) || ost->encoding_needed)
continue;
do_streamcopy(VAR_0, ost, VAR_1);
}
return;
}
| [
"static void FUNC_0(InputStream *VAR_0, const AVPacket *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"int VAR_4 = 0;",
"AVPacket avpkt;",
"if (VAR_0->next_dts == AV_NOPTS_VALUE)\nVAR_0->next_dts = VAR_0->last_dts;",
"if (!VAR_1) {",
"av_init_packet(&avpkt);",
"avpkt.data = NULL;",
"avpkt.size = 0;",
"} else {",
"avpkt = *VAR_1;",
"}",
"if (VAR_1 && VAR_1->dts != AV_NOPTS_VALUE)\nVAR_0->next_dts = VAR_0->last_dts = av_rescale_q(VAR_1->dts, VAR_0->st->time_base, AV_TIME_BASE_Q);",
"while (VAR_0->decoding_needed && (!VAR_1 || avpkt.size > 0)) {",
"int VAR_8 = 0;",
"int VAR_6 = 0;",
"if (!VAR_4)\nVAR_0->last_dts = VAR_0->next_dts;",
"switch (VAR_0->dec_ctx->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_8 = decode_audio (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nVAR_8 = decode_video (VAR_0, VAR_4 ? NULL : &avpkt, &VAR_6);",
"if (VAR_4 && !VAR_6)\n;",
"else if (VAR_1 && VAR_1->duration)\nVAR_0->next_dts += av_rescale_q(VAR_1->duration, VAR_0->st->time_base, AV_TIME_BASE_Q);",
"else if (VAR_0->st->avg_frame_rate.num)\nVAR_0->next_dts += av_rescale_q(1, av_inv_q(VAR_0->st->avg_frame_rate),\nAV_TIME_BASE_Q);",
"else if (VAR_0->dec_ctx->framerate.num != 0) {",
"int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 :\nVAR_0->dec_ctx->ticks_per_frame;",
"VAR_0->next_dts += av_rescale_q(VAR_8, VAR_0->dec_ctx->framerate, AV_TIME_BASE_Q);",
"}",
"break;",
"case AVMEDIA_TYPE_SUBTITLE:\nif (VAR_4)\nbreak;",
"VAR_8 = transcode_subtitles(VAR_0, &avpkt, &VAR_6);",
"break;",
"default:\nreturn;",
"}",
"if (VAR_8 < 0) {",
"av_log(NULL, AV_LOG_ERROR, \"Error while decoding stream #%d:%d\\n\",\nVAR_0->file_index, VAR_0->st->index);",
"if (exit_on_error)\nexit_program(1);",
"break;",
"}",
"if (!VAR_6)\nbreak;",
"VAR_4 = 1;",
"}",
"if (!VAR_1 && VAR_0->decoding_needed && !VAR_2) {",
"int VAR_8 = send_filter_eof(VAR_0);",
"if (VAR_8 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Error marking filters as finished\\n\");",
"exit_program(1);",
"}",
"}",
"if (!VAR_0->decoding_needed) {",
"VAR_0->last_dts = VAR_0->next_dts;",
"switch (VAR_0->dec_ctx->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_0->next_dts += ((int64_t)AV_TIME_BASE * VAR_0->dec_ctx->frame_size) /\nVAR_0->dec_ctx->sample_rate;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif (VAR_0->dec_ctx->framerate.num != 0) {",
"int VAR_8 = VAR_0->st->parser ? VAR_0->st->parser->repeat_pict + 1 : VAR_0->dec_ctx->ticks_per_frame;",
"VAR_0->next_dts += ((int64_t)AV_TIME_BASE *\nVAR_0->dec_ctx->framerate.den * VAR_8) /\nVAR_0->dec_ctx->framerate.num;",
"}",
"break;",
"}",
"}",
"for (VAR_3 = 0; VAR_1 && VAR_3 < nb_output_streams; VAR_3++) {",
"OutputStream *ost = output_streams[VAR_3];",
"if (!check_output_constraints(VAR_0, ost) || ost->encoding_needed)\ncontinue;",
"do_streamcopy(VAR_0, ost, VAR_1);",
"}",
"return;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
45
],
[
47
],
[
49
],
[
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
],
[
115
],
[
117,
119
],
[
121,
123
],
[
125
],
[
127
],
[
131,
133
],
[
137
],
[
139
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
165
],
[
167
],
[
169
],
[
171,
173,
175
],
[
177
],
[
179,
181
],
[
183
],
[
185,
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205,
207
],
[
211
],
[
213
],
[
217
],
[
219
]
] |
19,881 | static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
{
int offset;
int channels,freq,size;
offset = is_adx(buf,bufsize);
if (offset==0) return 0;
channels = buf[7];
freq = read_long(buf+8);
size = read_long(buf+12);
// printf("freq=%d ch=%d\n",freq,channels);
avctx->sample_rate = freq;
avctx->channels = channels;
avctx->bit_rate = freq*channels*18*8/32;
// avctx->frame_size = 18*channels;
return offset;
}
| true | FFmpeg | f19af812a32c1398d48c3550d11dbc6aafbb2bfc | static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
{
int offset;
int channels,freq,size;
offset = is_adx(buf,bufsize);
if (offset==0) return 0;
channels = buf[7];
freq = read_long(buf+8);
size = read_long(buf+12);
avctx->sample_rate = freq;
avctx->channels = channels;
avctx->bit_rate = freq*channels*18*8/32;
return offset;
}
| {
"code": [
"\treturn offset;",
"\tint offset;",
"\tint channels,freq,size;",
"\toffset = is_adx(buf,bufsize);",
"\tif (offset==0) return 0;",
"\tchannels = buf[7];",
"\tfreq = read_long(buf+8);",
"\tsize = read_long(buf+12);",
"\tavctx->sample_rate = freq;",
"\tavctx->channels = channels;",
"\tavctx->bit_rate = freq*channels*18*8/32;",
"\treturn offset;"
],
"line_no": [
39,
5,
7,
11,
13,
17,
19,
21,
29,
31,
33,
39
]
} | static int FUNC_0(AVCodecContext *VAR_0,const unsigned char *VAR_1,size_t VAR_2)
{
int VAR_3;
int VAR_4,VAR_5,VAR_6;
VAR_3 = is_adx(VAR_1,VAR_2);
if (VAR_3==0) return 0;
VAR_4 = VAR_1[7];
VAR_5 = read_long(VAR_1+8);
VAR_6 = read_long(VAR_1+12);
VAR_0->sample_rate = VAR_5;
VAR_0->VAR_4 = VAR_4;
VAR_0->bit_rate = VAR_5*VAR_4*18*8/32;
return VAR_3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,const unsigned char *VAR_1,size_t VAR_2)\n{",
"int VAR_3;",
"int VAR_4,VAR_5,VAR_6;",
"VAR_3 = is_adx(VAR_1,VAR_2);",
"if (VAR_3==0) return 0;",
"VAR_4 = VAR_1[7];",
"VAR_5 = read_long(VAR_1+8);",
"VAR_6 = read_long(VAR_1+12);",
"VAR_0->sample_rate = VAR_5;",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->bit_rate = VAR_5*VAR_4*18*8/32;",
"return VAR_3;",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
]
] |
19,882 | uint32_t pci_default_read_config(PCIDevice *d,
uint32_t address, int len)
{
uint32_t val;
switch(len) {
case 1:
val = d->config[address];
break;
case 2:
val = le16_to_cpu(*(uint16_t *)(d->config + address));
break;
default:
case 4:
val = le32_to_cpu(*(uint32_t *)(d->config + address));
break;
}
return val;
}
| true | qemu | a2d4e44b485222a8972ea9e555b148148c655bb9 | uint32_t pci_default_read_config(PCIDevice *d,
uint32_t address, int len)
{
uint32_t val;
switch(len) {
case 1:
val = d->config[address];
break;
case 2:
val = le16_to_cpu(*(uint16_t *)(d->config + address));
break;
default:
case 4:
val = le32_to_cpu(*(uint32_t *)(d->config + address));
break;
}
return val;
}
| {
"code": [
" case 1:",
" val = d->config[address];",
" break;",
" case 2:",
" val = le16_to_cpu(*(uint16_t *)(d->config + address));",
" break;",
" val = le32_to_cpu(*(uint32_t *)(d->config + address));"
],
"line_no": [
11,
13,
15,
17,
19,
15,
27
]
} | uint32_t FUNC_0(PCIDevice *d,
uint32_t address, int len)
{
uint32_t val;
switch(len) {
case 1:
val = d->config[address];
break;
case 2:
val = le16_to_cpu(*(uint16_t *)(d->config + address));
break;
default:
case 4:
val = le32_to_cpu(*(uint32_t *)(d->config + address));
break;
}
return val;
}
| [
"uint32_t FUNC_0(PCIDevice *d,\nuint32_t address, int len)\n{",
"uint32_t val;",
"switch(len) {",
"case 1:\nval = d->config[address];",
"break;",
"case 2:\nval = le16_to_cpu(*(uint16_t *)(d->config + address));",
"break;",
"default:\ncase 4:\nval = le32_to_cpu(*(uint32_t *)(d->config + address));",
"break;",
"}",
"return val;",
"}"
] | [
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
19,883 | static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
{
const QDictEntry *ent;
int has_exec_key = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){
const char *arg_name = qdict_entry_key(ent);
const QObject *arg_obj = qdict_entry_value(ent);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"execute", "string");
return NULL;
}
has_exec_key = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"arguments", "object");
return NULL;
}
} else {
error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
} | true | qemu | 779cec4d20907cbccb26fbf5f5c19c6cdee33eff | static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
{
const QDictEntry *ent;
int has_exec_key = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (ent = qdict_first(input_dict); ent; ent = qdict_next(input_dict, ent)){
const char *arg_name = qdict_entry_key(ent);
const QObject *arg_obj = qdict_entry_value(ent);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"execute", "string");
return NULL;
}
has_exec_key = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"arguments", "object");
return NULL;
}
} else {
error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
} | {
"code": [],
"line_no": []
} | static QDict *FUNC_0(QObject *input_obj, Error **errp)
{
const QDictEntry *VAR_0;
int VAR_1 = 0;
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
input_dict = qobject_to_qdict(input_obj);
for (VAR_0 = qdict_first(input_dict); VAR_0; VAR_0 = qdict_next(input_dict, VAR_0)){
const char *arg_name = qdict_entry_key(VAR_0);
const QObject *arg_obj = qdict_entry_value(VAR_0);
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"execute", "string");
return NULL;
}
VAR_1 = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
"arguments", "object");
return NULL;
}
} else {
error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!VAR_1) {
error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
return input_dict;
} | [
"static QDict *FUNC_0(QObject *input_obj, Error **errp)\n{",
"const QDictEntry *VAR_0;",
"int VAR_1 = 0;",
"QDict *input_dict;",
"if (qobject_type(input_obj) != QTYPE_QDICT) {",
"error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, \"object\");",
"return NULL;",
"}",
"input_dict = qobject_to_qdict(input_obj);",
"for (VAR_0 = qdict_first(input_dict); VAR_0; VAR_0 = qdict_next(input_dict, VAR_0)){",
"const char *arg_name = qdict_entry_key(VAR_0);",
"const QObject *arg_obj = qdict_entry_value(VAR_0);",
"if (!strcmp(arg_name, \"execute\")) {",
"if (qobject_type(arg_obj) != QTYPE_QSTRING) {",
"error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,\n\"execute\", \"string\");",
"return NULL;",
"}",
"VAR_1 = 1;",
"} else if (!strcmp(arg_name, \"arguments\")) {",
"if (qobject_type(arg_obj) != QTYPE_QDICT) {",
"error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,\n\"arguments\", \"object\");",
"return NULL;",
"}",
"} else {",
"error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);",
"return NULL;",
"}",
"}",
"if (!VAR_1) {",
"error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, \"execute\");",
"return NULL;",
"}",
"return input_dict;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
19,884 | static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,
const void *pkt_data,
size_t pkt_len)
{
struct virtio_net_hdr *vhdr;
bool isip4, isip6, istcp, isudp;
uint8_t *data;
int len;
if (!net_rx_pkt_has_virt_hdr(pkt)) {
return;
}
vhdr = net_rx_pkt_get_vhdr(pkt);
if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {
return;
}
net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp);
if (!(isip4 || isip6) || !(istcp || isudp)) {
return;
}
vmxnet3_dump_virt_hdr(vhdr);
/* Validate packet len: csum_start + scum_offset + length of csum field */
if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {
VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, "
"cannot calculate checksum",
pkt_len, vhdr->csum_start, vhdr->csum_offset);
return;
}
data = (uint8_t *)pkt_data + vhdr->csum_start;
len = pkt_len - vhdr->csum_start;
/* Put the checksum obtained into the packet */
stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));
vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;
}
| true | qemu | 0dacea92d26c31d453c58de2e99c178fee554166 | static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,
const void *pkt_data,
size_t pkt_len)
{
struct virtio_net_hdr *vhdr;
bool isip4, isip6, istcp, isudp;
uint8_t *data;
int len;
if (!net_rx_pkt_has_virt_hdr(pkt)) {
return;
}
vhdr = net_rx_pkt_get_vhdr(pkt);
if (!VMXNET_FLAG_IS_SET(vhdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {
return;
}
net_rx_pkt_get_protocols(pkt, &isip4, &isip6, &isudp, &istcp);
if (!(isip4 || isip6) || !(istcp || isudp)) {
return;
}
vmxnet3_dump_virt_hdr(vhdr);
if (pkt_len < (vhdr->csum_start + vhdr->csum_offset + 2)) {
VMW_PKPRN("packet len:%zu < csum_start(%d) + csum_offset(%d) + 2, "
"cannot calculate checksum",
pkt_len, vhdr->csum_start, vhdr->csum_offset);
return;
}
data = (uint8_t *)pkt_data + vhdr->csum_start;
len = pkt_len - vhdr->csum_start;
stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));
vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;
}
| {
"code": [
" stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len));"
],
"line_no": [
73
]
} | static void FUNC_0(struct NetRxPkt *VAR_0,
const void *VAR_1,
size_t VAR_2)
{
struct virtio_net_hdr *VAR_3;
bool isip4, isip6, istcp, isudp;
uint8_t *data;
int VAR_4;
if (!net_rx_pkt_has_virt_hdr(VAR_0)) {
return;
}
VAR_3 = net_rx_pkt_get_vhdr(VAR_0);
if (!VMXNET_FLAG_IS_SET(VAR_3->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {
return;
}
net_rx_pkt_get_protocols(VAR_0, &isip4, &isip6, &isudp, &istcp);
if (!(isip4 || isip6) || !(istcp || isudp)) {
return;
}
vmxnet3_dump_virt_hdr(VAR_3);
if (VAR_2 < (VAR_3->csum_start + VAR_3->csum_offset + 2)) {
VMW_PKPRN("packet VAR_4:%zu < csum_start(%d) + csum_offset(%d) + 2, "
"cannot calculate checksum",
VAR_2, VAR_3->csum_start, VAR_3->csum_offset);
return;
}
data = (uint8_t *)VAR_1 + VAR_3->csum_start;
VAR_4 = VAR_2 - VAR_3->csum_start;
stw_be_p(data + VAR_3->csum_offset, net_raw_checksum(data, VAR_4));
VAR_3->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;
VAR_3->flags |= VIRTIO_NET_HDR_F_DATA_VALID;
}
| [
"static void FUNC_0(struct NetRxPkt *VAR_0,\nconst void *VAR_1,\nsize_t VAR_2)\n{",
"struct virtio_net_hdr *VAR_3;",
"bool isip4, isip6, istcp, isudp;",
"uint8_t *data;",
"int VAR_4;",
"if (!net_rx_pkt_has_virt_hdr(VAR_0)) {",
"return;",
"}",
"VAR_3 = net_rx_pkt_get_vhdr(VAR_0);",
"if (!VMXNET_FLAG_IS_SET(VAR_3->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM)) {",
"return;",
"}",
"net_rx_pkt_get_protocols(VAR_0, &isip4, &isip6, &isudp, &istcp);",
"if (!(isip4 || isip6) || !(istcp || isudp)) {",
"return;",
"}",
"vmxnet3_dump_virt_hdr(VAR_3);",
"if (VAR_2 < (VAR_3->csum_start + VAR_3->csum_offset + 2)) {",
"VMW_PKPRN(\"packet VAR_4:%zu < csum_start(%d) + csum_offset(%d) + 2, \"\n\"cannot calculate checksum\",\nVAR_2, VAR_3->csum_start, VAR_3->csum_offset);",
"return;",
"}",
"data = (uint8_t *)VAR_1 + VAR_3->csum_start;",
"VAR_4 = VAR_2 - VAR_3->csum_start;",
"stw_be_p(data + VAR_3->csum_offset, net_raw_checksum(data, VAR_4));",
"VAR_3->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM;",
"VAR_3->flags |= VIRTIO_NET_HDR_F_DATA_VALID;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55,
57,
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
]
] |
19,885 | int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
{
float Lbuf[91][32][2];
float Rbuf[91][32][2];
const int len = 32;
int is34 = ps->is34bands;
top += NR_BANDS[is34] - 64;
memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
if (top < NR_ALLPASS_BANDS[is34])
memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
hybrid_analysis(Lbuf, ps->in_buf, L, is34, len);
decorrelation(ps, Rbuf, Lbuf, is34);
stereo_processing(ps, Lbuf, Rbuf, is34);
hybrid_synthesis(L, Lbuf, is34, len);
hybrid_synthesis(R, Rbuf, is34, len);
return 0;
}
| false | FFmpeg | bf1945af301aff54c33352e75f17aec6cb5269d7 | int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
{
float Lbuf[91][32][2];
float Rbuf[91][32][2];
const int len = 32;
int is34 = ps->is34bands;
top += NR_BANDS[is34] - 64;
memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
if (top < NR_ALLPASS_BANDS[is34])
memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
hybrid_analysis(Lbuf, ps->in_buf, L, is34, len);
decorrelation(ps, Rbuf, Lbuf, is34);
stereo_processing(ps, Lbuf, Rbuf, is34);
hybrid_synthesis(L, Lbuf, is34, len);
hybrid_synthesis(R, Rbuf, is34, len);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, PSContext *VAR_1, float VAR_2[2][38][64], float VAR_3[2][38][64], int VAR_4)
{
float VAR_5[91][32][2];
float VAR_6[91][32][2];
const int VAR_7 = 32;
int VAR_8 = VAR_1->is34bands;
VAR_4 += NR_BANDS[VAR_8] - 64;
memset(VAR_1->delay+VAR_4, 0, (NR_BANDS[VAR_8] - VAR_4)*sizeof(VAR_1->delay[0]));
if (VAR_4 < NR_ALLPASS_BANDS[VAR_8])
memset(VAR_1->ap_delay + VAR_4, 0, (NR_ALLPASS_BANDS[VAR_8] - VAR_4)*sizeof(VAR_1->ap_delay[0]));
hybrid_analysis(VAR_5, VAR_1->in_buf, VAR_2, VAR_8, VAR_7);
decorrelation(VAR_1, VAR_6, VAR_5, VAR_8);
stereo_processing(VAR_1, VAR_5, VAR_6, VAR_8);
hybrid_synthesis(VAR_2, VAR_5, VAR_8, VAR_7);
hybrid_synthesis(VAR_3, VAR_6, VAR_8, VAR_7);
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, PSContext *VAR_1, float VAR_2[2][38][64], float VAR_3[2][38][64], int VAR_4)\n{",
"float VAR_5[91][32][2];",
"float VAR_6[91][32][2];",
"const int VAR_7 = 32;",
"int VAR_8 = VAR_1->is34bands;",
"VAR_4 += NR_BANDS[VAR_8] - 64;",
"memset(VAR_1->delay+VAR_4, 0, (NR_BANDS[VAR_8] - VAR_4)*sizeof(VAR_1->delay[0]));",
"if (VAR_4 < NR_ALLPASS_BANDS[VAR_8])\nmemset(VAR_1->ap_delay + VAR_4, 0, (NR_ALLPASS_BANDS[VAR_8] - VAR_4)*sizeof(VAR_1->ap_delay[0]));",
"hybrid_analysis(VAR_5, VAR_1->in_buf, VAR_2, VAR_8, VAR_7);",
"decorrelation(VAR_1, VAR_6, VAR_5, VAR_8);",
"stereo_processing(VAR_1, VAR_5, VAR_6, VAR_8);",
"hybrid_synthesis(VAR_2, VAR_5, VAR_8, VAR_7);",
"hybrid_synthesis(VAR_3, VAR_6, VAR_8, VAR_7);",
"return 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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
19,887 | static void bl_intrp(EVRCContext *e, float *ex, float delay)
{
float *f;
int offset, i, coef_idx;
int16_t t;
offset = lrintf(fabs(delay));
t = (offset - delay + 0.5) * 8.0 + 0.5;
if (t == 8) {
t = 0;
offset--;
}
f = ex - offset - 8;
coef_idx = t * (2 * 8 + 1);
ex[0] = 0.0;
for (i = 0; i < 2 * 8 + 1; i++)
ex[0] += e->interpolation_coeffs[coef_idx + i] * f[i];
}
| false | FFmpeg | f18d2dff1194b34b79dc7641aafe54d1df349e40 | static void bl_intrp(EVRCContext *e, float *ex, float delay)
{
float *f;
int offset, i, coef_idx;
int16_t t;
offset = lrintf(fabs(delay));
t = (offset - delay + 0.5) * 8.0 + 0.5;
if (t == 8) {
t = 0;
offset--;
}
f = ex - offset - 8;
coef_idx = t * (2 * 8 + 1);
ex[0] = 0.0;
for (i = 0; i < 2 * 8 + 1; i++)
ex[0] += e->interpolation_coeffs[coef_idx + i] * f[i];
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(EVRCContext *VAR_0, float *VAR_1, float VAR_2)
{
float *VAR_3;
int VAR_4, VAR_5, VAR_6;
int16_t t;
VAR_4 = lrintf(fabs(VAR_2));
t = (VAR_4 - VAR_2 + 0.5) * 8.0 + 0.5;
if (t == 8) {
t = 0;
VAR_4--;
}
VAR_3 = VAR_1 - VAR_4 - 8;
VAR_6 = t * (2 * 8 + 1);
VAR_1[0] = 0.0;
for (VAR_5 = 0; VAR_5 < 2 * 8 + 1; VAR_5++)
VAR_1[0] += VAR_0->interpolation_coeffs[VAR_6 + VAR_5] * VAR_3[VAR_5];
}
| [
"static void FUNC_0(EVRCContext *VAR_0, float *VAR_1, float VAR_2)\n{",
"float *VAR_3;",
"int VAR_4, VAR_5, VAR_6;",
"int16_t t;",
"VAR_4 = lrintf(fabs(VAR_2));",
"t = (VAR_4 - VAR_2 + 0.5) * 8.0 + 0.5;",
"if (t == 8) {",
"t = 0;",
"VAR_4--;",
"}",
"VAR_3 = VAR_1 - VAR_4 - 8;",
"VAR_6 = t * (2 * 8 + 1);",
"VAR_1[0] = 0.0;",
"for (VAR_5 = 0; VAR_5 < 2 * 8 + 1; VAR_5++)",
"VAR_1[0] += VAR_0->interpolation_coeffs[VAR_6 + VAR_5] * VAR_3[VAR_5];",
"}"
] | [
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
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
19,888 | static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd)
{
const int t0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];
const int t1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];
const int t2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];
const int t3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];
const unsigned t4 = 5793U * (t2 + t0 + 0x800 >> 12);
const unsigned t5 = 5793U * (t3 + t1 + 0x800 >> 12);
const unsigned t6 = t2 - t0;
const unsigned t7 = t3 - t1;
const unsigned t8 = 17734 * blk[2 * step] - 42813 * blk[6 * step];
const unsigned t9 = 17734 * blk[6 * step] + 42814 * blk[2 * step];
const unsigned tA = (blk[0 * step] - blk[4 * step]) * 32768 + rnd;
const unsigned tB = (blk[0 * step] + blk[4 * step]) * 32768 + rnd;
blk[0 * step] = (int)( t4 + t9 + tB) >> shift;
blk[1 * step] = (int)( t6 + t7 + t8 + tA) >> shift;
blk[2 * step] = (int)( t6 - t7 - t8 + tA) >> shift;
blk[3 * step] = (int)( t5 - t9 + tB) >> shift;
blk[4 * step] = (int)( -t5 - t9 + tB) >> shift;
blk[5 * step] = (int)(-(t6 - t7) - t8 + tA) >> shift;
blk[6 * step] = (int)(-(t6 + t7) + t8 + tA) >> shift;
blk[7 * step] = (int)( -t4 + t9 + tB) >> shift;
}
| true | FFmpeg | 0c9d5b015c2022e8deebb93367f8ee8a8eb779e8 | static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd)
{
const int t0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];
const int t1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];
const int t2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];
const int t3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];
const unsigned t4 = 5793U * (t2 + t0 + 0x800 >> 12);
const unsigned t5 = 5793U * (t3 + t1 + 0x800 >> 12);
const unsigned t6 = t2 - t0;
const unsigned t7 = t3 - t1;
const unsigned t8 = 17734 * blk[2 * step] - 42813 * blk[6 * step];
const unsigned t9 = 17734 * blk[6 * step] + 42814 * blk[2 * step];
const unsigned tA = (blk[0 * step] - blk[4 * step]) * 32768 + rnd;
const unsigned tB = (blk[0 * step] + blk[4 * step]) * 32768 + rnd;
blk[0 * step] = (int)( t4 + t9 + tB) >> shift;
blk[1 * step] = (int)( t6 + t7 + t8 + tA) >> shift;
blk[2 * step] = (int)( t6 - t7 - t8 + tA) >> shift;
blk[3 * step] = (int)( t5 - t9 + tB) >> shift;
blk[4 * step] = (int)( -t5 - t9 + tB) >> shift;
blk[5 * step] = (int)(-(t6 - t7) - t8 + tA) >> shift;
blk[6 * step] = (int)(-(t6 + t7) + t8 + tA) >> shift;
blk[7 * step] = (int)( -t4 + t9 + tB) >> shift;
}
| {
"code": [
" const int t0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];",
" const int t1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];",
" const int t2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];",
" const int t3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];",
" const unsigned t4 = 5793U * (t2 + t0 + 0x800 >> 12);",
" const unsigned t5 = 5793U * (t3 + t1 + 0x800 >> 12);"
],
"line_no": [
5,
7,
9,
11,
13,
15
]
} | static av_always_inline void FUNC_0(int16_t *blk, int step, int shift, int rnd)
{
const int VAR_0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];
const int VAR_1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];
const int VAR_2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];
const int VAR_3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];
const unsigned VAR_4 = 5793U * (VAR_2 + VAR_0 + 0x800 >> 12);
const unsigned VAR_5 = 5793U * (VAR_3 + VAR_1 + 0x800 >> 12);
const unsigned VAR_6 = VAR_2 - VAR_0;
const unsigned VAR_7 = VAR_3 - VAR_1;
const unsigned VAR_8 = 17734 * blk[2 * step] - 42813 * blk[6 * step];
const unsigned VAR_9 = 17734 * blk[6 * step] + 42814 * blk[2 * step];
const unsigned VAR_10 = (blk[0 * step] - blk[4 * step]) * 32768 + rnd;
const unsigned VAR_11 = (blk[0 * step] + blk[4 * step]) * 32768 + rnd;
blk[0 * step] = (int)( VAR_4 + VAR_9 + VAR_11) >> shift;
blk[1 * step] = (int)( VAR_6 + VAR_7 + VAR_8 + VAR_10) >> shift;
blk[2 * step] = (int)( VAR_6 - VAR_7 - VAR_8 + VAR_10) >> shift;
blk[3 * step] = (int)( VAR_5 - VAR_9 + VAR_11) >> shift;
blk[4 * step] = (int)( -VAR_5 - VAR_9 + VAR_11) >> shift;
blk[5 * step] = (int)(-(VAR_6 - VAR_7) - VAR_8 + VAR_10) >> shift;
blk[6 * step] = (int)(-(VAR_6 + VAR_7) + VAR_8 + VAR_10) >> shift;
blk[7 * step] = (int)( -VAR_4 + VAR_9 + VAR_11) >> shift;
}
| [
"static av_always_inline void FUNC_0(int16_t *blk, int step, int shift, int rnd)\n{",
"const int VAR_0 = 27246 * blk[3 * step] + 18405 * blk[5 * step];",
"const int VAR_1 = 27246 * blk[5 * step] - 18405 * blk[3 * step];",
"const int VAR_2 = 6393 * blk[7 * step] + 32139 * blk[1 * step];",
"const int VAR_3 = 6393 * blk[1 * step] - 32139 * blk[7 * step];",
"const unsigned VAR_4 = 5793U * (VAR_2 + VAR_0 + 0x800 >> 12);",
"const unsigned VAR_5 = 5793U * (VAR_3 + VAR_1 + 0x800 >> 12);",
"const unsigned VAR_6 = VAR_2 - VAR_0;",
"const unsigned VAR_7 = VAR_3 - VAR_1;",
"const unsigned VAR_8 = 17734 * blk[2 * step] - 42813 * blk[6 * step];",
"const unsigned VAR_9 = 17734 * blk[6 * step] + 42814 * blk[2 * step];",
"const unsigned VAR_10 = (blk[0 * step] - blk[4 * step]) * 32768 + rnd;",
"const unsigned VAR_11 = (blk[0 * step] + blk[4 * step]) * 32768 + rnd;",
"blk[0 * step] = (int)( VAR_4 + VAR_9 + VAR_11) >> shift;",
"blk[1 * step] = (int)( VAR_6 + VAR_7 + VAR_8 + VAR_10) >> shift;",
"blk[2 * step] = (int)( VAR_6 - VAR_7 - VAR_8 + VAR_10) >> shift;",
"blk[3 * step] = (int)( VAR_5 - VAR_9 + VAR_11) >> shift;",
"blk[4 * step] = (int)( -VAR_5 - VAR_9 + VAR_11) >> shift;",
"blk[5 * step] = (int)(-(VAR_6 - VAR_7) - VAR_8 + VAR_10) >> shift;",
"blk[6 * step] = (int)(-(VAR_6 + VAR_7) + VAR_8 + VAR_10) >> shift;",
"blk[7 * step] = (int)( -VAR_4 + VAR_9 + VAR_11) >> shift;",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
19,890 | static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma)
{
/* allocate pd */
rdma->pd = ibv_alloc_pd(rdma->verbs);
if (!rdma->pd) {
fprintf(stderr, "failed to allocate protection domain\n");
return -1;
}
/* create completion channel */
rdma->comp_channel = ibv_create_comp_channel(rdma->verbs);
if (!rdma->comp_channel) {
fprintf(stderr, "failed to allocate completion channel\n");
goto err_alloc_pd_cq;
}
/*
* Completion queue can be filled by both read and write work requests,
* so must reflect the sum of both possible queue sizes.
*/
rdma->cq = ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX * 3),
NULL, rdma->comp_channel, 0);
if (!rdma->cq) {
fprintf(stderr, "failed to allocate completion queue\n");
goto err_alloc_pd_cq;
}
return 0;
err_alloc_pd_cq:
if (rdma->pd) {
ibv_dealloc_pd(rdma->pd);
}
if (rdma->comp_channel) {
ibv_destroy_comp_channel(rdma->comp_channel);
}
rdma->pd = NULL;
rdma->comp_channel = NULL;
return -1;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma)
{
rdma->pd = ibv_alloc_pd(rdma->verbs);
if (!rdma->pd) {
fprintf(stderr, "failed to allocate protection domain\n");
return -1;
}
rdma->comp_channel = ibv_create_comp_channel(rdma->verbs);
if (!rdma->comp_channel) {
fprintf(stderr, "failed to allocate completion channel\n");
goto err_alloc_pd_cq;
}
rdma->cq = ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX * 3),
NULL, rdma->comp_channel, 0);
if (!rdma->cq) {
fprintf(stderr, "failed to allocate completion queue\n");
goto err_alloc_pd_cq;
}
return 0;
err_alloc_pd_cq:
if (rdma->pd) {
ibv_dealloc_pd(rdma->pd);
}
if (rdma->comp_channel) {
ibv_destroy_comp_channel(rdma->comp_channel);
}
rdma->pd = NULL;
rdma->comp_channel = NULL;
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RDMAContext *VAR_0)
{
VAR_0->pd = ibv_alloc_pd(VAR_0->verbs);
if (!VAR_0->pd) {
fprintf(stderr, "failed to allocate protection domain\n");
return -1;
}
VAR_0->comp_channel = ibv_create_comp_channel(VAR_0->verbs);
if (!VAR_0->comp_channel) {
fprintf(stderr, "failed to allocate completion channel\n");
goto err_alloc_pd_cq;
}
VAR_0->cq = ibv_create_cq(VAR_0->verbs, (RDMA_SIGNALED_SEND_MAX * 3),
NULL, VAR_0->comp_channel, 0);
if (!VAR_0->cq) {
fprintf(stderr, "failed to allocate completion queue\n");
goto err_alloc_pd_cq;
}
return 0;
err_alloc_pd_cq:
if (VAR_0->pd) {
ibv_dealloc_pd(VAR_0->pd);
}
if (VAR_0->comp_channel) {
ibv_destroy_comp_channel(VAR_0->comp_channel);
}
VAR_0->pd = NULL;
VAR_0->comp_channel = NULL;
return -1;
}
| [
"static int FUNC_0(RDMAContext *VAR_0)\n{",
"VAR_0->pd = ibv_alloc_pd(VAR_0->verbs);",
"if (!VAR_0->pd) {",
"fprintf(stderr, \"failed to allocate protection domain\\n\");",
"return -1;",
"}",
"VAR_0->comp_channel = ibv_create_comp_channel(VAR_0->verbs);",
"if (!VAR_0->comp_channel) {",
"fprintf(stderr, \"failed to allocate completion channel\\n\");",
"goto err_alloc_pd_cq;",
"}",
"VAR_0->cq = ibv_create_cq(VAR_0->verbs, (RDMA_SIGNALED_SEND_MAX * 3),\nNULL, VAR_0->comp_channel, 0);",
"if (!VAR_0->cq) {",
"fprintf(stderr, \"failed to allocate completion queue\\n\");",
"goto err_alloc_pd_cq;",
"}",
"return 0;",
"err_alloc_pd_cq:\nif (VAR_0->pd) {",
"ibv_dealloc_pd(VAR_0->pd);",
"}",
"if (VAR_0->comp_channel) {",
"ibv_destroy_comp_channel(VAR_0->comp_channel);",
"}",
"VAR_0->pd = NULL;",
"VAR_0->comp_channel = NULL;",
"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
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
]
] |
19,891 | static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
*obj = qint_get_int(qint);
}
| true | qemu | a9fc37f6bc3f2ab90585cb16493da9f6dcfbfbcf | static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
*obj = qint_get_int(qint);
}
| {
"code": [
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" \"integer\");",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" \"integer\");",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\",",
" error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : \"null\","
],
"line_no": [
25,
25,
25,
27,
25,
27,
25,
25,
25
]
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2,
Error **VAR_3)
{
QObjectInputVisitor *qiv = to_qiv(VAR_0);
QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_3);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : "null",
"integer");
return;
}
*VAR_2 = qint_get_int(qint);
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2,\nError **VAR_3)\n{",
"QObjectInputVisitor *qiv = to_qiv(VAR_0);",
"QObject *qobj = qobject_input_get_object(qiv, VAR_1, true, VAR_3);",
"QInt *qint;",
"if (!qobj) {",
"return;",
"}",
"qint = qobject_to_qint(qobj);",
"if (!qint) {",
"error_setg(VAR_3, QERR_INVALID_PARAMETER_TYPE, VAR_1 ? VAR_1 : \"null\",\n\"integer\");",
"return;",
"}",
"*VAR_2 = qint_get_int(qint);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
19,894 | static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->props = xlnx_zynqmp_props;
dc->realize = xlnx_zynqmp_realize;
} | true | qemu | 4c315c27661502a0813b129e41c0bf640c34a8d6 | static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->props = xlnx_zynqmp_props;
dc->realize = xlnx_zynqmp_realize;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->props = xlnx_zynqmp_props;
dc->realize = xlnx_zynqmp_realize;
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->props = xlnx_zynqmp_props;",
"dc->realize = xlnx_zynqmp_realize;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
]
] |
19,895 | static target_ulong h_send_logical_lan(CPUPPCState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong *bufs = args + 1;
target_ulong continue_token = args[7];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
unsigned total_len;
uint8_t *lbuf, *p;
int i, nbufs;
int ret;
dprintf("H_SEND_LOGICAL_LAN(0x" TARGET_FMT_lx ", <bufs>, 0x"
TARGET_FMT_lx ")\n", reg, continue_token);
if (!sdev) {
return H_PARAMETER;
}
dprintf("rxbufs = %d\n", dev->rx_bufs);
if (!dev->isopen) {
return H_DROPPED;
}
if (continue_token) {
return H_HARDWARE; /* FIXME actually handle this */
}
total_len = 0;
for (i = 0; i < 6; i++) {
dprintf(" buf desc: 0x" TARGET_FMT_lx "\n", bufs[i]);
if (!(bufs[i] & VLAN_BD_VALID)) {
break;
}
total_len += VLAN_BD_LEN(bufs[i]);
}
nbufs = i;
dprintf("h_send_logical_lan() %d buffers, total length 0x%x\n",
nbufs, total_len);
if (total_len == 0) {
return H_SUCCESS;
}
if (total_len > MAX_PACKET_SIZE) {
/* Don't let the guest force too large an allocation */
return H_RESOURCE;
}
lbuf = alloca(total_len);
p = lbuf;
for (i = 0; i < nbufs; i++) {
ret = spapr_tce_dma_read(sdev, VLAN_BD_ADDR(bufs[i]),
p, VLAN_BD_LEN(bufs[i]));
if (ret < 0) {
return ret;
}
p += VLAN_BD_LEN(bufs[i]);
}
qemu_send_packet(&dev->nic->nc, lbuf, total_len);
return H_SUCCESS;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | static target_ulong h_send_logical_lan(CPUPPCState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong *bufs = args + 1;
target_ulong continue_token = args[7];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
unsigned total_len;
uint8_t *lbuf, *p;
int i, nbufs;
int ret;
dprintf("H_SEND_LOGICAL_LAN(0x" TARGET_FMT_lx ", <bufs>, 0x"
TARGET_FMT_lx ")\n", reg, continue_token);
if (!sdev) {
return H_PARAMETER;
}
dprintf("rxbufs = %d\n", dev->rx_bufs);
if (!dev->isopen) {
return H_DROPPED;
}
if (continue_token) {
return H_HARDWARE;
}
total_len = 0;
for (i = 0; i < 6; i++) {
dprintf(" buf desc: 0x" TARGET_FMT_lx "\n", bufs[i]);
if (!(bufs[i] & VLAN_BD_VALID)) {
break;
}
total_len += VLAN_BD_LEN(bufs[i]);
}
nbufs = i;
dprintf("h_send_logical_lan() %d buffers, total length 0x%x\n",
nbufs, total_len);
if (total_len == 0) {
return H_SUCCESS;
}
if (total_len > MAX_PACKET_SIZE) {
return H_RESOURCE;
}
lbuf = alloca(total_len);
p = lbuf;
for (i = 0; i < nbufs; i++) {
ret = spapr_tce_dma_read(sdev, VLAN_BD_ADDR(bufs[i]),
p, VLAN_BD_LEN(bufs[i]));
if (ret < 0) {
return ret;
}
p += VLAN_BD_LEN(bufs[i]);
}
qemu_send_packet(&dev->nic->nc, lbuf, total_len);
return H_SUCCESS;
}
| {
"code": [
" ret = spapr_tce_dma_read(sdev, VLAN_BD_ADDR(bufs[i]),",
" if (ret < 0) {",
" return ret;",
" if (ret < 0) {",
" return ret;",
" if (ret < 0) {",
" return ret;",
" return H_PARAMETER;",
" return H_PARAMETER;",
" return H_SUCCESS;",
" return H_SUCCESS;"
],
"line_no": [
111,
115,
117,
115,
117,
115,
117,
35,
35,
133,
133
]
} | static target_ulong FUNC_0(CPUPPCState *env, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong reg = args[0];
target_ulong *bufs = args + 1;
target_ulong continue_token = args[7];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
unsigned VAR_0;
uint8_t *lbuf, *p;
int VAR_1, VAR_2;
int VAR_3;
dprintf("H_SEND_LOGICAL_LAN(0x" TARGET_FMT_lx ", <bufs>, 0x"
TARGET_FMT_lx ")\n", reg, continue_token);
if (!sdev) {
return H_PARAMETER;
}
dprintf("rxbufs = %d\n", dev->rx_bufs);
if (!dev->isopen) {
return H_DROPPED;
}
if (continue_token) {
return H_HARDWARE;
}
VAR_0 = 0;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {
dprintf(" buf desc: 0x" TARGET_FMT_lx "\n", bufs[VAR_1]);
if (!(bufs[VAR_1] & VLAN_BD_VALID)) {
break;
}
VAR_0 += VLAN_BD_LEN(bufs[VAR_1]);
}
VAR_2 = VAR_1;
dprintf("FUNC_0() %d buffers, total length 0x%x\n",
VAR_2, VAR_0);
if (VAR_0 == 0) {
return H_SUCCESS;
}
if (VAR_0 > MAX_PACKET_SIZE) {
return H_RESOURCE;
}
lbuf = alloca(VAR_0);
p = lbuf;
for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {
VAR_3 = spapr_tce_dma_read(sdev, VLAN_BD_ADDR(bufs[VAR_1]),
p, VLAN_BD_LEN(bufs[VAR_1]));
if (VAR_3 < 0) {
return VAR_3;
}
p += VLAN_BD_LEN(bufs[VAR_1]);
}
qemu_send_packet(&dev->nic->nc, lbuf, VAR_0);
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(CPUPPCState *env, sPAPREnvironment *spapr,\ntarget_ulong opcode, target_ulong *args)\n{",
"target_ulong reg = args[0];",
"target_ulong *bufs = args + 1;",
"target_ulong continue_token = args[7];",
"VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);",
"VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;",
"unsigned VAR_0;",
"uint8_t *lbuf, *p;",
"int VAR_1, VAR_2;",
"int VAR_3;",
"dprintf(\"H_SEND_LOGICAL_LAN(0x\" TARGET_FMT_lx \", <bufs>, 0x\"\nTARGET_FMT_lx \")\\n\", reg, continue_token);",
"if (!sdev) {",
"return H_PARAMETER;",
"}",
"dprintf(\"rxbufs = %d\\n\", dev->rx_bufs);",
"if (!dev->isopen) {",
"return H_DROPPED;",
"}",
"if (continue_token) {",
"return H_HARDWARE;",
"}",
"VAR_0 = 0;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"dprintf(\" buf desc: 0x\" TARGET_FMT_lx \"\\n\", bufs[VAR_1]);",
"if (!(bufs[VAR_1] & VLAN_BD_VALID)) {",
"break;",
"}",
"VAR_0 += VLAN_BD_LEN(bufs[VAR_1]);",
"}",
"VAR_2 = VAR_1;",
"dprintf(\"FUNC_0() %d buffers, total length 0x%x\\n\",\nVAR_2, VAR_0);",
"if (VAR_0 == 0) {",
"return H_SUCCESS;",
"}",
"if (VAR_0 > MAX_PACKET_SIZE) {",
"return H_RESOURCE;",
"}",
"lbuf = alloca(VAR_0);",
"p = lbuf;",
"for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {",
"VAR_3 = spapr_tce_dma_read(sdev, VLAN_BD_ADDR(bufs[VAR_1]),\np, VLAN_BD_LEN(bufs[VAR_1]));",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"p += VLAN_BD_LEN(bufs[VAR_1]);",
"}",
"qemu_send_packet(&dev->nic->nc, lbuf, VAR_0);",
"return H_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
129
],
[
133
],
[
135
]
] |
19,896 | static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = qemu_get_nic_opaque(nc);
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
VirtIODevice *vdev = VIRTIO_DEVICE(n);
struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
struct virtio_net_hdr_mrg_rxbuf mhdr;
unsigned mhdr_cnt = 0;
size_t offset, i, guest_offset;
if (!virtio_net_can_receive(nc)) {
return -1;
}
/* hdr_len refers to the header we supply to the guest */
if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {
return 0;
}
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int len, total;
const struct iovec *sg = elem.in_sg;
total = 0;
if (virtqueue_pop(q->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
error_report("virtio-net unexpected empty queue: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr len %zd, host hdr len %zd "
"guest features 0x%" PRIx64,
i, n->mergeable_rx_bufs, offset, size,
n->guest_hdr_len, n->host_hdr_len,
vdev->guest_features);
exit(1);
}
if (elem.in_num < 1) {
error_report("virtio-net receive queue contains no in buffers");
exit(1);
}
if (i == 0) {
assert(offset == 0);
if (n->mergeable_rx_bufs) {
mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),
sg, elem.in_num,
offsetof(typeof(mhdr), num_buffers),
sizeof(mhdr.num_buffers));
}
receive_header(n, sg, elem.in_num, buf, size);
offset = n->host_hdr_len;
total += n->guest_hdr_len;
guest_offset = n->guest_hdr_len;
} else {
guest_offset = 0;
}
/* copy in packet. ugh */
len = iov_from_buf(sg, elem.in_num, guest_offset,
buf + offset, size - offset);
total += len;
offset += len;
/* If buffers can't be merged, at this point we
* must have consumed the complete packet.
* Otherwise, drop it. */
if (!n->mergeable_rx_bufs && offset < size) {
#if 0
error_report("virtio-net truncated non-mergeable packet: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr len %zd, host hdr len %zd",
i, n->mergeable_rx_bufs,
offset, size, n->guest_hdr_len, n->host_hdr_len);
#endif
return size;
}
/* signal other side */
virtqueue_fill(q->rx_vq, &elem, total, i++);
}
if (mhdr_cnt) {
virtio_stw_p(vdev, &mhdr.num_buffers, i);
iov_from_buf(mhdr_sg, mhdr_cnt,
0,
&mhdr.num_buffers, sizeof mhdr.num_buffers);
}
virtqueue_flush(q->rx_vq, i);
virtio_notify(vdev, q->rx_vq);
return size;
}
| true | qemu | 0cf33fb6b49a19de32859e2cdc6021334f448fb3 | static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = qemu_get_nic_opaque(nc);
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
VirtIODevice *vdev = VIRTIO_DEVICE(n);
struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
struct virtio_net_hdr_mrg_rxbuf mhdr;
unsigned mhdr_cnt = 0;
size_t offset, i, guest_offset;
if (!virtio_net_can_receive(nc)) {
return -1;
}
if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {
return 0;
}
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int len, total;
const struct iovec *sg = elem.in_sg;
total = 0;
if (virtqueue_pop(q->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
error_report("virtio-net unexpected empty queue: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr len %zd, host hdr len %zd "
"guest features 0x%" PRIx64,
i, n->mergeable_rx_bufs, offset, size,
n->guest_hdr_len, n->host_hdr_len,
vdev->guest_features);
exit(1);
}
if (elem.in_num < 1) {
error_report("virtio-net receive queue contains no in buffers");
exit(1);
}
if (i == 0) {
assert(offset == 0);
if (n->mergeable_rx_bufs) {
mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),
sg, elem.in_num,
offsetof(typeof(mhdr), num_buffers),
sizeof(mhdr.num_buffers));
}
receive_header(n, sg, elem.in_num, buf, size);
offset = n->host_hdr_len;
total += n->guest_hdr_len;
guest_offset = n->guest_hdr_len;
} else {
guest_offset = 0;
}
len = iov_from_buf(sg, elem.in_num, guest_offset,
buf + offset, size - offset);
total += len;
offset += len;
if (!n->mergeable_rx_bufs && offset < size) {
#if 0
error_report("virtio-net truncated non-mergeable packet: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr len %zd, host hdr len %zd",
i, n->mergeable_rx_bufs,
offset, size, n->guest_hdr_len, n->host_hdr_len);
#endif
return size;
}
virtqueue_fill(q->rx_vq, &elem, total, i++);
}
if (mhdr_cnt) {
virtio_stw_p(vdev, &mhdr.num_buffers, i);
iov_from_buf(mhdr_sg, mhdr_cnt,
0,
&mhdr.num_buffers, sizeof mhdr.num_buffers);
}
virtqueue_flush(q->rx_vq, i);
virtio_notify(vdev, q->rx_vq);
return size;
}
| {
"code": [
"#if 0",
" error_report(\"virtio-net truncated non-mergeable packet: \"",
" \"i %zd mergeable %d offset %zd, size %zd, \"",
" \"guest hdr len %zd, host hdr len %zd\",",
" i, n->mergeable_rx_bufs,",
" offset, size, n->guest_hdr_len, n->host_hdr_len);",
"#endif"
],
"line_no": [
151,
153,
71,
157,
159,
161,
163
]
} | static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)
{
VirtIONet *n = qemu_get_nic_opaque(nc);
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
VirtIODevice *vdev = VIRTIO_DEVICE(n);
struct iovec VAR_0[VIRTQUEUE_MAX_SIZE];
struct virtio_net_hdr_mrg_rxbuf VAR_1;
unsigned VAR_2 = 0;
size_t offset, i, guest_offset;
if (!virtio_net_can_receive(nc)) {
return -1;
}
if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {
return 0;
}
if (!receive_filter(n, buf, size))
return size;
offset = i = 0;
while (offset < size) {
VirtQueueElement elem;
int VAR_3, VAR_4;
const struct iovec *VAR_5 = elem.in_sg;
VAR_4 = 0;
if (virtqueue_pop(q->rx_vq, &elem) == 0) {
if (i == 0)
return -1;
error_report("virtio-net unexpected empty queue: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr VAR_3 %zd, host hdr VAR_3 %zd "
"guest features 0x%" PRIx64,
i, n->mergeable_rx_bufs, offset, size,
n->guest_hdr_len, n->host_hdr_len,
vdev->guest_features);
exit(1);
}
if (elem.in_num < 1) {
error_report("virtio-net receive queue contains no in buffers");
exit(1);
}
if (i == 0) {
assert(offset == 0);
if (n->mergeable_rx_bufs) {
VAR_2 = iov_copy(VAR_0, ARRAY_SIZE(VAR_0),
VAR_5, elem.in_num,
offsetof(typeof(VAR_1), num_buffers),
sizeof(VAR_1.num_buffers));
}
receive_header(n, VAR_5, elem.in_num, buf, size);
offset = n->host_hdr_len;
VAR_4 += n->guest_hdr_len;
guest_offset = n->guest_hdr_len;
} else {
guest_offset = 0;
}
VAR_3 = iov_from_buf(VAR_5, elem.in_num, guest_offset,
buf + offset, size - offset);
VAR_4 += VAR_3;
offset += VAR_3;
if (!n->mergeable_rx_bufs && offset < size) {
#if 0
error_report("virtio-net truncated non-mergeable packet: "
"i %zd mergeable %d offset %zd, size %zd, "
"guest hdr VAR_3 %zd, host hdr VAR_3 %zd",
i, n->mergeable_rx_bufs,
offset, size, n->guest_hdr_len, n->host_hdr_len);
#endif
return size;
}
virtqueue_fill(q->rx_vq, &elem, VAR_4, i++);
}
if (VAR_2) {
virtio_stw_p(vdev, &VAR_1.num_buffers, i);
iov_from_buf(VAR_0, VAR_2,
0,
&VAR_1.num_buffers, sizeof VAR_1.num_buffers);
}
virtqueue_flush(q->rx_vq, i);
virtio_notify(vdev, q->rx_vq);
return size;
}
| [
"static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)\n{",
"VirtIONet *n = qemu_get_nic_opaque(nc);",
"VirtIONetQueue *q = virtio_net_get_subqueue(nc);",
"VirtIODevice *vdev = VIRTIO_DEVICE(n);",
"struct iovec VAR_0[VIRTQUEUE_MAX_SIZE];",
"struct virtio_net_hdr_mrg_rxbuf VAR_1;",
"unsigned VAR_2 = 0;",
"size_t offset, i, guest_offset;",
"if (!virtio_net_can_receive(nc)) {",
"return -1;",
"}",
"if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_len)) {",
"return 0;",
"}",
"if (!receive_filter(n, buf, size))\nreturn size;",
"offset = i = 0;",
"while (offset < size) {",
"VirtQueueElement elem;",
"int VAR_3, VAR_4;",
"const struct iovec *VAR_5 = elem.in_sg;",
"VAR_4 = 0;",
"if (virtqueue_pop(q->rx_vq, &elem) == 0) {",
"if (i == 0)\nreturn -1;",
"error_report(\"virtio-net unexpected empty queue: \"\n\"i %zd mergeable %d offset %zd, size %zd, \"\n\"guest hdr VAR_3 %zd, host hdr VAR_3 %zd \"\n\"guest features 0x%\" PRIx64,\ni, n->mergeable_rx_bufs, offset, size,\nn->guest_hdr_len, n->host_hdr_len,\nvdev->guest_features);",
"exit(1);",
"}",
"if (elem.in_num < 1) {",
"error_report(\"virtio-net receive queue contains no in buffers\");",
"exit(1);",
"}",
"if (i == 0) {",
"assert(offset == 0);",
"if (n->mergeable_rx_bufs) {",
"VAR_2 = iov_copy(VAR_0, ARRAY_SIZE(VAR_0),\nVAR_5, elem.in_num,\noffsetof(typeof(VAR_1), num_buffers),\nsizeof(VAR_1.num_buffers));",
"}",
"receive_header(n, VAR_5, elem.in_num, buf, size);",
"offset = n->host_hdr_len;",
"VAR_4 += n->guest_hdr_len;",
"guest_offset = n->guest_hdr_len;",
"} else {",
"guest_offset = 0;",
"}",
"VAR_3 = iov_from_buf(VAR_5, elem.in_num, guest_offset,\nbuf + offset, size - offset);",
"VAR_4 += VAR_3;",
"offset += VAR_3;",
"if (!n->mergeable_rx_bufs && offset < size) {",
"#if 0\nerror_report(\"virtio-net truncated non-mergeable packet: \"\n\"i %zd mergeable %d offset %zd, size %zd, \"\n\"guest hdr VAR_3 %zd, host hdr VAR_3 %zd\",\ni, n->mergeable_rx_bufs,\noffset, size, n->guest_hdr_len, n->host_hdr_len);",
"#endif\nreturn size;",
"}",
"virtqueue_fill(q->rx_vq, &elem, VAR_4, i++);",
"}",
"if (VAR_2) {",
"virtio_stw_p(vdev, &VAR_1.num_buffers, i);",
"iov_from_buf(VAR_0, VAR_2,\n0,\n&VAR_1.num_buffers, sizeof VAR_1.num_buffers);",
"}",
"virtqueue_flush(q->rx_vq, i);",
"virtio_notify(vdev, q->rx_vq);",
"return size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65,
67
],
[
69,
71,
73,
75,
77,
79,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105,
107,
109,
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
135,
137
],
[
139
],
[
141
],
[
149
],
[
151,
153,
155,
157,
159,
161
],
[
163,
165
],
[
167
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183,
185,
187
],
[
189
],
[
193
],
[
195
],
[
199
],
[
201
]
] |
19,897 | static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
{
int count = ffio_read_varlen(bc);
int skip_start = 0;
int skip_end = 0;
int channels = 0;
int64_t channel_layout = 0;
int sample_rate = 0;
int width = 0;
int height = 0;
int i, ret;
for (i=0; i<count; i++) {
uint8_t name[256], str_value[256], type_str[256];
int value;
if (avio_tell(bc) >= maxpos)
return AVERROR_INVALIDDATA;
ret = get_str(bc, name, sizeof(name));
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "get_str failed while reading sm data\n");
return ret;
}
value = get_s(bc);
if (value == -1) {
get_str(bc, str_value, sizeof(str_value));
av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value);
} else if (value == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(bc, type_str, sizeof(type_str));
value_len = ffio_read_varlen(bc);
if (avio_tell(bc) + value_len >= maxpos)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(bc);
continue;
} else {
av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str);
avio_skip(bc, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(bc, dst, value_len);
} else if (value == -3) {
value = get_s(bc);
} else if (value == -4) {
value = ffio_read_varlen(bc);
} else if (value < -4) {
get_s(bc);
} else {
if (!strcmp(name, "SkipStart")) {
skip_start = value;
} else if (!strcmp(name, "SkipEnd")) {
skip_end = value;
} else if (!strcmp(name, "Channels")) {
channels = value;
} else if (!strcmp(name, "SampleRate")) {
sample_rate = value;
} else if (!strcmp(name, "Width")) {
width = value;
} else if (!strcmp(name, "Height")) {
height = value;
} else {
av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name);
}
}
}
if (channels || channel_layout || sample_rate || width || height) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!channels) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height))
);
if (channels)
bytestream_put_le32(&dst, channels);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (sample_rate)
bytestream_put_le32(&dst, sample_rate);
if (width || height){
bytestream_put_le32(&dst, width);
bytestream_put_le32(&dst, height);
}
}
if (skip_start || skip_end) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, skip_start);
AV_WL32(dst+4, skip_end);
}
return 0;
}
| true | FFmpeg | 0b79a389ba488d50fd9947554d803fc51b877bb3 | static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
{
int count = ffio_read_varlen(bc);
int skip_start = 0;
int skip_end = 0;
int channels = 0;
int64_t channel_layout = 0;
int sample_rate = 0;
int width = 0;
int height = 0;
int i, ret;
for (i=0; i<count; i++) {
uint8_t name[256], str_value[256], type_str[256];
int value;
if (avio_tell(bc) >= maxpos)
return AVERROR_INVALIDDATA;
ret = get_str(bc, name, sizeof(name));
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "get_str failed while reading sm data\n");
return ret;
}
value = get_s(bc);
if (value == -1) {
get_str(bc, str_value, sizeof(str_value));
av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value);
} else if (value == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(bc, type_str, sizeof(type_str));
value_len = ffio_read_varlen(bc);
if (avio_tell(bc) + value_len >= maxpos)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(pkt, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(bc);
continue;
} else {
av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str);
avio_skip(bc, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(bc, dst, value_len);
} else if (value == -3) {
value = get_s(bc);
} else if (value == -4) {
value = ffio_read_varlen(bc);
} else if (value < -4) {
get_s(bc);
} else {
if (!strcmp(name, "SkipStart")) {
skip_start = value;
} else if (!strcmp(name, "SkipEnd")) {
skip_end = value;
} else if (!strcmp(name, "Channels")) {
channels = value;
} else if (!strcmp(name, "SampleRate")) {
sample_rate = value;
} else if (!strcmp(name, "Width")) {
width = value;
} else if (!strcmp(name, "Height")) {
height = value;
} else {
av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name);
}
}
}
if (channels || channel_layout || sample_rate || width || height) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!channels) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!sample_rate) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(width|height))
);
if (channels)
bytestream_put_le32(&dst, channels);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (sample_rate)
bytestream_put_le32(&dst, sample_rate);
if (width || height){
bytestream_put_le32(&dst, width);
bytestream_put_le32(&dst, height);
}
}
if (skip_start || skip_end) {
uint8_t *dst = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, skip_start);
AV_WL32(dst+4, skip_end);
}
return 0;
}
| {
"code": [
" get_str(bc, str_value, sizeof(str_value));",
" get_str(bc, type_str, sizeof(type_str));",
" get_str(bc, str_value, sizeof(str_value));",
" get_str(bc, str_value, sizeof(str_value));",
" get_str(bc, type_str, sizeof(type_str));"
],
"line_no": [
51,
63,
51,
51,
63
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVPacket *VAR_2, int VAR_3, int64_t VAR_4)
{
int VAR_5 = ffio_read_varlen(VAR_1);
int VAR_6 = 0;
int VAR_7 = 0;
int VAR_8 = 0;
int64_t channel_layout = 0;
int VAR_9 = 0;
int VAR_10 = 0;
int VAR_11 = 0;
int VAR_12, VAR_13;
for (VAR_12=0; VAR_12<VAR_5; VAR_12++) {
uint8_t name[256], str_value[256], type_str[256];
int VAR_14;
if (avio_tell(VAR_1) >= VAR_4)
return AVERROR_INVALIDDATA;
VAR_13 = get_str(VAR_1, name, sizeof(name));
if (VAR_13 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_str failed while reading sm data\n");
return VAR_13;
}
VAR_14 = get_s(VAR_1);
if (VAR_14 == -1) {
get_str(VAR_1, str_value, sizeof(str_value));
av_log(VAR_0, AV_LOG_WARNING, "Unknown string %VAR_0 / %VAR_0\n", name, str_value);
} else if (VAR_14 == -2) {
uint8_t *dst = NULL;
int64_t v64, value_len;
get_str(VAR_1, type_str, sizeof(type_str));
value_len = ffio_read_varlen(VAR_1);
if (avio_tell(VAR_1) + value_len >= VAR_4)
return AVERROR_INVALIDDATA;
if (!strcmp(name, "Palette")) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PALETTE, value_len);
} else if (!strcmp(name, "Extradata")) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_NEW_EXTRADATA, value_len);
} else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);
if(!dst)
return AVERROR(ENOMEM);
AV_WB64(dst, v64);
dst += 8;
} else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
channel_layout = avio_rl64(VAR_1);
continue;
} else {
av_log(VAR_0, AV_LOG_WARNING, "Unknown data %VAR_0 / %VAR_0\n", name, type_str);
avio_skip(VAR_1, value_len);
continue;
}
if(!dst)
return AVERROR(ENOMEM);
avio_read(VAR_1, dst, value_len);
} else if (VAR_14 == -3) {
VAR_14 = get_s(VAR_1);
} else if (VAR_14 == -4) {
VAR_14 = ffio_read_varlen(VAR_1);
} else if (VAR_14 < -4) {
get_s(VAR_1);
} else {
if (!strcmp(name, "SkipStart")) {
VAR_6 = VAR_14;
} else if (!strcmp(name, "SkipEnd")) {
VAR_7 = VAR_14;
} else if (!strcmp(name, "Channels")) {
VAR_8 = VAR_14;
} else if (!strcmp(name, "SampleRate")) {
VAR_9 = VAR_14;
} else if (!strcmp(name, "Width")) {
VAR_10 = VAR_14;
} else if (!strcmp(name, "Height")) {
VAR_11 = VAR_14;
} else {
av_log(VAR_0, AV_LOG_WARNING, "Unknown integer %VAR_0\n", name);
}
}
}
if (VAR_8 || channel_layout || VAR_9 || VAR_10 || VAR_11) {
uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PARAM_CHANGE, 28);
if (!dst)
return AVERROR(ENOMEM);
bytestream_put_le32(&dst,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!VAR_8) +
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!VAR_9) +
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(VAR_10|VAR_11))
);
if (VAR_8)
bytestream_put_le32(&dst, VAR_8);
if (channel_layout)
bytestream_put_le64(&dst, channel_layout);
if (VAR_9)
bytestream_put_le32(&dst, VAR_9);
if (VAR_10 || VAR_11){
bytestream_put_le32(&dst, VAR_10);
bytestream_put_le32(&dst, VAR_11);
}
}
if (VAR_6 || VAR_7) {
uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (!dst)
return AVERROR(ENOMEM);
AV_WL32(dst, VAR_6);
AV_WL32(dst+4, VAR_7);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, AVPacket *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"int VAR_5 = ffio_read_varlen(VAR_1);",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"int VAR_8 = 0;",
"int64_t channel_layout = 0;",
"int VAR_9 = 0;",
"int VAR_10 = 0;",
"int VAR_11 = 0;",
"int VAR_12, VAR_13;",
"for (VAR_12=0; VAR_12<VAR_5; VAR_12++) {",
"uint8_t name[256], str_value[256], type_str[256];",
"int VAR_14;",
"if (avio_tell(VAR_1) >= VAR_4)\nreturn AVERROR_INVALIDDATA;",
"VAR_13 = get_str(VAR_1, name, sizeof(name));",
"if (VAR_13 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_str failed while reading sm data\\n\");",
"return VAR_13;",
"}",
"VAR_14 = get_s(VAR_1);",
"if (VAR_14 == -1) {",
"get_str(VAR_1, str_value, sizeof(str_value));",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown string %VAR_0 / %VAR_0\\n\", name, str_value);",
"} else if (VAR_14 == -2) {",
"uint8_t *dst = NULL;",
"int64_t v64, value_len;",
"get_str(VAR_1, type_str, sizeof(type_str));",
"value_len = ffio_read_varlen(VAR_1);",
"if (avio_tell(VAR_1) + value_len >= VAR_4)\nreturn AVERROR_INVALIDDATA;",
"if (!strcmp(name, \"Palette\")) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PALETTE, value_len);",
"} else if (!strcmp(name, \"Extradata\")) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_NEW_EXTRADATA, value_len);",
"} else if (sscanf(name, \"CodecSpecificSide%\"SCNd64\"\", &v64) == 1) {",
"dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, value_len + 8);",
"if(!dst)\nreturn AVERROR(ENOMEM);",
"AV_WB64(dst, v64);",
"dst += 8;",
"} else if (!strcmp(name, \"ChannelLayout\") && value_len == 8) {",
"channel_layout = avio_rl64(VAR_1);",
"continue;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown data %VAR_0 / %VAR_0\\n\", name, type_str);",
"avio_skip(VAR_1, value_len);",
"continue;",
"}",
"if(!dst)\nreturn AVERROR(ENOMEM);",
"avio_read(VAR_1, dst, value_len);",
"} else if (VAR_14 == -3) {",
"VAR_14 = get_s(VAR_1);",
"} else if (VAR_14 == -4) {",
"VAR_14 = ffio_read_varlen(VAR_1);",
"} else if (VAR_14 < -4) {",
"get_s(VAR_1);",
"} else {",
"if (!strcmp(name, \"SkipStart\")) {",
"VAR_6 = VAR_14;",
"} else if (!strcmp(name, \"SkipEnd\")) {",
"VAR_7 = VAR_14;",
"} else if (!strcmp(name, \"Channels\")) {",
"VAR_8 = VAR_14;",
"} else if (!strcmp(name, \"SampleRate\")) {",
"VAR_9 = VAR_14;",
"} else if (!strcmp(name, \"Width\")) {",
"VAR_10 = VAR_14;",
"} else if (!strcmp(name, \"Height\")) {",
"VAR_11 = VAR_14;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"Unknown integer %VAR_0\\n\", name);",
"}",
"}",
"}",
"if (VAR_8 || channel_layout || VAR_9 || VAR_10 || VAR_11) {",
"uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_PARAM_CHANGE, 28);",
"if (!dst)\nreturn AVERROR(ENOMEM);",
"bytestream_put_le32(&dst,\nAV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT*(!!VAR_8) +\nAV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +\nAV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE*(!!VAR_9) +\nAV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS*(!!(VAR_10|VAR_11))\n);",
"if (VAR_8)\nbytestream_put_le32(&dst, VAR_8);",
"if (channel_layout)\nbytestream_put_le64(&dst, channel_layout);",
"if (VAR_9)\nbytestream_put_le32(&dst, VAR_9);",
"if (VAR_10 || VAR_11){",
"bytestream_put_le32(&dst, VAR_10);",
"bytestream_put_le32(&dst, VAR_11);",
"}",
"}",
"if (VAR_6 || VAR_7) {",
"uint8_t *dst = av_packet_new_side_data(VAR_2, AV_PKT_DATA_SKIP_SAMPLES, 10);",
"if (!dst)\nreturn AVERROR(ENOMEM);",
"AV_WL32(dst, VAR_6);",
"AV_WL32(dst+4, VAR_7);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
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
],
[
163
],
[
165
],
[
167,
169
],
[
171,
173,
175,
177,
179,
181
],
[
183,
185
],
[
187,
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
]
] |
19,898 | static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y,
const uint32_t *curr_row,
const uint32_t *above_row)
{
uint32_t N, W, NW, pred;
unsigned delta;
int GN, GW, GNW, R, G, B;
if (x && y) {
W = curr_row[x - 1];
N = above_row[x];
NW = above_row[x - 1];
GN = (N >> G_shift) & 0xFF;
GW = (W >> G_shift) & 0xFF;
GNW = (NW >> G_shift) & 0xFF;
G = epic_decode_component_pred(dc, GN, GW, GNW);
R = G + epic_decode_component_pred(dc,
((N >> R_shift) & 0xFF) - GN,
((W >> R_shift) & 0xFF) - GW,
((NW >> R_shift) & 0xFF) - GNW);
B = G + epic_decode_component_pred(dc,
((N >> B_shift) & 0xFF) - GN,
((W >> B_shift) & 0xFF) - GW,
((NW >> B_shift) & 0xFF) - GNW);
} else {
if (x)
pred = curr_row[x - 1];
else
pred = above_row[x];
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
R = ((pred >> R_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
G = ((pred >> G_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
B = ((pred >> B_shift) & 0xFF) - TOSIGNED(delta);
return (R << R_shift) | (G << G_shift) | (B << B_shift); | true | FFmpeg | b1e242bc565665420661e016127fe07b4b615ecb | static uint32_t epic_decode_pixel_pred(ePICContext *dc, int x, int y,
const uint32_t *curr_row,
const uint32_t *above_row)
{
uint32_t N, W, NW, pred;
unsigned delta;
int GN, GW, GNW, R, G, B;
if (x && y) {
W = curr_row[x - 1];
N = above_row[x];
NW = above_row[x - 1];
GN = (N >> G_shift) & 0xFF;
GW = (W >> G_shift) & 0xFF;
GNW = (NW >> G_shift) & 0xFF;
G = epic_decode_component_pred(dc, GN, GW, GNW);
R = G + epic_decode_component_pred(dc,
((N >> R_shift) & 0xFF) - GN,
((W >> R_shift) & 0xFF) - GW,
((NW >> R_shift) & 0xFF) - GNW);
B = G + epic_decode_component_pred(dc,
((N >> B_shift) & 0xFF) - GN,
((W >> B_shift) & 0xFF) - GW,
((NW >> B_shift) & 0xFF) - GNW);
} else {
if (x)
pred = curr_row[x - 1];
else
pred = above_row[x];
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
R = ((pred >> R_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
G = ((pred >> G_shift) & 0xFF) - TOSIGNED(delta);
delta = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
B = ((pred >> B_shift) & 0xFF) - TOSIGNED(delta);
return (R << R_shift) | (G << G_shift) | (B << B_shift); | {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(ePICContext *dc, int x, int y,
const uint32_t *curr_row,
const uint32_t *above_row)
{
uint32_t N, W, NW, pred;
unsigned VAR_0;
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
if (x && y) {
W = curr_row[x - 1];
N = above_row[x];
NW = above_row[x - 1];
VAR_1 = (N >> G_shift) & 0xFF;
VAR_2 = (W >> G_shift) & 0xFF;
VAR_3 = (NW >> G_shift) & 0xFF;
VAR_5 = epic_decode_component_pred(dc, VAR_1, VAR_2, VAR_3);
VAR_4 = VAR_5 + epic_decode_component_pred(dc,
((N >> R_shift) & 0xFF) - VAR_1,
((W >> R_shift) & 0xFF) - VAR_2,
((NW >> R_shift) & 0xFF) - VAR_3);
VAR_6 = VAR_5 + epic_decode_component_pred(dc,
((N >> B_shift) & 0xFF) - VAR_1,
((W >> B_shift) & 0xFF) - VAR_2,
((NW >> B_shift) & 0xFF) - VAR_3);
} else {
if (x)
pred = curr_row[x - 1];
else
pred = above_row[x];
VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
VAR_4 = ((pred >> R_shift) & 0xFF) - TOSIGNED(VAR_0);
VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
VAR_5 = ((pred >> G_shift) & 0xFF) - TOSIGNED(VAR_0);
VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);
VAR_6 = ((pred >> B_shift) & 0xFF) - TOSIGNED(VAR_0);
return (VAR_4 << R_shift) | (VAR_5 << G_shift) | (VAR_6 << B_shift); | [
"static uint32_t FUNC_0(ePICContext *dc, int x, int y,\nconst uint32_t *curr_row,\nconst uint32_t *above_row)\n{",
"uint32_t N, W, NW, pred;",
"unsigned VAR_0;",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"if (x && y) {",
"W = curr_row[x - 1];",
"N = above_row[x];",
"NW = above_row[x - 1];",
"VAR_1 = (N >> G_shift) & 0xFF;",
"VAR_2 = (W >> G_shift) & 0xFF;",
"VAR_3 = (NW >> G_shift) & 0xFF;",
"VAR_5 = epic_decode_component_pred(dc, VAR_1, VAR_2, VAR_3);",
"VAR_4 = VAR_5 + epic_decode_component_pred(dc,\n((N >> R_shift) & 0xFF) - VAR_1,\n((W >> R_shift) & 0xFF) - VAR_2,\n((NW >> R_shift) & 0xFF) - VAR_3);",
"VAR_6 = VAR_5 + epic_decode_component_pred(dc,\n((N >> B_shift) & 0xFF) - VAR_1,\n((W >> B_shift) & 0xFF) - VAR_2,\n((NW >> B_shift) & 0xFF) - VAR_3);",
"} else {",
"if (x)\npred = curr_row[x - 1];",
"else\npred = above_row[x];",
"VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);",
"VAR_4 = ((pred >> R_shift) & 0xFF) - TOSIGNED(VAR_0);",
"VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);",
"VAR_5 = ((pred >> G_shift) & 0xFF) - TOSIGNED(VAR_0);",
"VAR_0 = ff_els_decode_unsigned(&dc->els_ctx, &dc->unsigned_rung);",
"VAR_6 = ((pred >> B_shift) & 0xFF) - TOSIGNED(VAR_0);",
"return (VAR_4 << R_shift) | (VAR_5 << G_shift) | (VAR_6 << B_shift);"
] | [
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
]
] |
19,899 | static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *prod_name)
{
int fd = -1, ret;
USBDevice *d = NULL;
USBHostDevice *dev;
struct usbdevfs_connectinfo ci;
char buf[1024];
printf("husb: open device %d.%d\n", bus_num, addr);
if (!usb_host_device_path) {
perror("husb: USB Host Device Path not set");
goto fail;
}
snprintf(buf, sizeof(buf), "%s/%03d/%03d", usb_host_device_path,
bus_num, addr);
fd = open(buf, O_RDWR | O_NONBLOCK);
if (fd < 0) {
perror(buf);
goto fail;
}
dprintf("husb: opened %s\n", buf);
d = usb_create(NULL /* FIXME */, "USB Host Device");
dev = DO_UPCAST(USBHostDevice, dev, d);
dev->bus_num = bus_num;
dev->addr = addr;
dev->fd = fd;
/* read the device description */
dev->descr_len = read(fd, dev->descr, sizeof(dev->descr));
if (dev->descr_len <= 0) {
perror("husb: reading device data failed");
goto fail;
}
#ifdef DEBUG
{
int x;
printf("=== begin dumping device descriptor data ===\n");
for (x = 0; x < dev->descr_len; x++)
printf("%02x ", dev->descr[x]);
printf("\n=== end dumping device descriptor data ===\n");
}
#endif
/*
* Initial configuration is -1 which makes us claim first
* available config. We used to start with 1, which does not
* always work. I've seen devices where first config starts
* with 2.
*/
if (!usb_host_claim_interfaces(dev, -1))
goto fail;
ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
if (ret < 0) {
perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
goto fail;
}
printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
ret = usb_linux_update_endp_table(dev);
if (ret)
goto fail;
if (ci.slow)
dev->dev.speed = USB_SPEED_LOW;
else
dev->dev.speed = USB_SPEED_HIGH;
if (!prod_name || prod_name[0] == '\0')
snprintf(dev->dev.devname, sizeof(dev->dev.devname),
"host:%d.%d", bus_num, addr);
else
pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
prod_name);
/* USB devio uses 'write' flag to check for async completions */
qemu_set_fd_handler(dev->fd, NULL, async_complete, dev);
hostdev_link(dev);
qdev_init(&d->qdev);
return (USBDevice *) dev;
fail:
if (d)
qdev_free(&d->qdev);
if (fd != -1)
close(fd);
return NULL;
}
| true | qemu | 33e66b86d89040f0a9e99aa53deb74ce8936a649 | static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *prod_name)
{
int fd = -1, ret;
USBDevice *d = NULL;
USBHostDevice *dev;
struct usbdevfs_connectinfo ci;
char buf[1024];
printf("husb: open device %d.%d\n", bus_num, addr);
if (!usb_host_device_path) {
perror("husb: USB Host Device Path not set");
goto fail;
}
snprintf(buf, sizeof(buf), "%s/%03d/%03d", usb_host_device_path,
bus_num, addr);
fd = open(buf, O_RDWR | O_NONBLOCK);
if (fd < 0) {
perror(buf);
goto fail;
}
dprintf("husb: opened %s\n", buf);
d = usb_create(NULL , "USB Host Device");
dev = DO_UPCAST(USBHostDevice, dev, d);
dev->bus_num = bus_num;
dev->addr = addr;
dev->fd = fd;
dev->descr_len = read(fd, dev->descr, sizeof(dev->descr));
if (dev->descr_len <= 0) {
perror("husb: reading device data failed");
goto fail;
}
#ifdef DEBUG
{
int x;
printf("=== begin dumping device descriptor data ===\n");
for (x = 0; x < dev->descr_len; x++)
printf("%02x ", dev->descr[x]);
printf("\n=== end dumping device descriptor data ===\n");
}
#endif
if (!usb_host_claim_interfaces(dev, -1))
goto fail;
ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci);
if (ret < 0) {
perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
goto fail;
}
printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
ret = usb_linux_update_endp_table(dev);
if (ret)
goto fail;
if (ci.slow)
dev->dev.speed = USB_SPEED_LOW;
else
dev->dev.speed = USB_SPEED_HIGH;
if (!prod_name || prod_name[0] == '\0')
snprintf(dev->dev.devname, sizeof(dev->dev.devname),
"host:%d.%d", bus_num, addr);
else
pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
prod_name);
qemu_set_fd_handler(dev->fd, NULL, async_complete, dev);
hostdev_link(dev);
qdev_init(&d->qdev);
return (USBDevice *) dev;
fail:
if (d)
qdev_free(&d->qdev);
if (fd != -1)
close(fd);
return NULL;
}
| {
"code": [
" qdev_init(&d->qdev);"
],
"line_no": [
173
]
} | static USBDevice *FUNC_0(int bus_num, int addr, const char *prod_name)
{
int VAR_0 = -1, VAR_1;
USBDevice *d = NULL;
USBHostDevice *dev;
struct usbdevfs_connectinfo VAR_2;
char VAR_3[1024];
printf("husb: open device %d.%d\n", bus_num, addr);
if (!usb_host_device_path) {
perror("husb: USB Host Device Path not set");
goto fail;
}
snprintf(VAR_3, sizeof(VAR_3), "%s/%03d/%03d", usb_host_device_path,
bus_num, addr);
VAR_0 = open(VAR_3, O_RDWR | O_NONBLOCK);
if (VAR_0 < 0) {
perror(VAR_3);
goto fail;
}
dprintf("husb: opened %s\n", VAR_3);
d = usb_create(NULL , "USB Host Device");
dev = DO_UPCAST(USBHostDevice, dev, d);
dev->bus_num = bus_num;
dev->addr = addr;
dev->VAR_0 = VAR_0;
dev->descr_len = read(VAR_0, dev->descr, sizeof(dev->descr));
if (dev->descr_len <= 0) {
perror("husb: reading device data failed");
goto fail;
}
#ifdef DEBUG
{
int x;
printf("=== begin dumping device descriptor data ===\n");
for (x = 0; x < dev->descr_len; x++)
printf("%02x ", dev->descr[x]);
printf("\n=== end dumping device descriptor data ===\n");
}
#endif
if (!usb_host_claim_interfaces(dev, -1))
goto fail;
VAR_1 = ioctl(VAR_0, USBDEVFS_CONNECTINFO, &VAR_2);
if (VAR_1 < 0) {
perror("usb_host_device_open: USBDEVFS_CONNECTINFO");
goto fail;
}
printf("husb: grabbed usb device %d.%d\n", bus_num, addr);
VAR_1 = usb_linux_update_endp_table(dev);
if (VAR_1)
goto fail;
if (VAR_2.slow)
dev->dev.speed = USB_SPEED_LOW;
else
dev->dev.speed = USB_SPEED_HIGH;
if (!prod_name || prod_name[0] == '\0')
snprintf(dev->dev.devname, sizeof(dev->dev.devname),
"host:%d.%d", bus_num, addr);
else
pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
prod_name);
qemu_set_fd_handler(dev->VAR_0, NULL, async_complete, dev);
hostdev_link(dev);
qdev_init(&d->qdev);
return (USBDevice *) dev;
fail:
if (d)
qdev_free(&d->qdev);
if (VAR_0 != -1)
close(VAR_0);
return NULL;
}
| [
"static USBDevice *FUNC_0(int bus_num, int addr, const char *prod_name)\n{",
"int VAR_0 = -1, VAR_1;",
"USBDevice *d = NULL;",
"USBHostDevice *dev;",
"struct usbdevfs_connectinfo VAR_2;",
"char VAR_3[1024];",
"printf(\"husb: open device %d.%d\\n\", bus_num, addr);",
"if (!usb_host_device_path) {",
"perror(\"husb: USB Host Device Path not set\");",
"goto fail;",
"}",
"snprintf(VAR_3, sizeof(VAR_3), \"%s/%03d/%03d\", usb_host_device_path,\nbus_num, addr);",
"VAR_0 = open(VAR_3, O_RDWR | O_NONBLOCK);",
"if (VAR_0 < 0) {",
"perror(VAR_3);",
"goto fail;",
"}",
"dprintf(\"husb: opened %s\\n\", VAR_3);",
"d = usb_create(NULL , \"USB Host Device\");",
"dev = DO_UPCAST(USBHostDevice, dev, d);",
"dev->bus_num = bus_num;",
"dev->addr = addr;",
"dev->VAR_0 = VAR_0;",
"dev->descr_len = read(VAR_0, dev->descr, sizeof(dev->descr));",
"if (dev->descr_len <= 0) {",
"perror(\"husb: reading device data failed\");",
"goto fail;",
"}",
"#ifdef DEBUG\n{",
"int x;",
"printf(\"=== begin dumping device descriptor data ===\\n\");",
"for (x = 0; x < dev->descr_len; x++)",
"printf(\"%02x \", dev->descr[x]);",
"printf(\"\\n=== end dumping device descriptor data ===\\n\");",
"}",
"#endif\nif (!usb_host_claim_interfaces(dev, -1))\ngoto fail;",
"VAR_1 = ioctl(VAR_0, USBDEVFS_CONNECTINFO, &VAR_2);",
"if (VAR_1 < 0) {",
"perror(\"usb_host_device_open: USBDEVFS_CONNECTINFO\");",
"goto fail;",
"}",
"printf(\"husb: grabbed usb device %d.%d\\n\", bus_num, addr);",
"VAR_1 = usb_linux_update_endp_table(dev);",
"if (VAR_1)\ngoto fail;",
"if (VAR_2.slow)\ndev->dev.speed = USB_SPEED_LOW;",
"else\ndev->dev.speed = USB_SPEED_HIGH;",
"if (!prod_name || prod_name[0] == '\\0')\nsnprintf(dev->dev.devname, sizeof(dev->dev.devname),\n\"host:%d.%d\", bus_num, addr);",
"else\npstrcpy(dev->dev.devname, sizeof(dev->dev.devname),\nprod_name);",
"qemu_set_fd_handler(dev->VAR_0, NULL, async_complete, dev);",
"hostdev_link(dev);",
"qdev_init(&d->qdev);",
"return (USBDevice *) dev;",
"fail:\nif (d)\nqdev_free(&d->qdev);",
"if (VAR_0 != -1)\nclose(VAR_0);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
109,
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133,
135
],
[
139,
141
],
[
143,
145
],
[
149,
151,
153
],
[
155,
157,
159
],
[
165
],
[
169
],
[
173
],
[
175
],
[
179,
181,
183
],
[
185,
187
],
[
189
],
[
191
]
] |
19,900 | static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
int *got_frame, AVPacket *pkt)
{
const uint8_t *data = pkt->data;
int size = pkt->size;
VP9Context *s = avctx->priv_data;
int ret, i, j, ref;
int retain_segmap_ref = s->s.frames[REF_FRAME_SEGMAP].segmentation_map &&
(!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map);
AVFrame *f;
if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) {
return ret;
} else if (ret == 0) {
if (!s->s.refs[ref].f->buf[0]) {
av_log(avctx, AV_LOG_ERROR, "Requested reference %d not available\n", ref);
return AVERROR_INVALIDDATA;
}
if ((ret = av_frame_ref(frame, s->s.refs[ref].f)) < 0)
return ret;
((AVFrame *)frame)->pts = pkt->pts;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
((AVFrame *)frame)->pkt_pts = pkt->pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
((AVFrame *)frame)->pkt_dts = pkt->dts;
for (i = 0; i < 8; i++) {
if (s->next_refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->next_refs[i]);
if (s->s.refs[i].f->buf[0] &&
(ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i])) < 0)
return ret;
}
*got_frame = 1;
return pkt->size;
}
data += ret;
size -= ret;
if (!retain_segmap_ref || s->s.h.keyframe || s->s.h.intraonly) {
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0)
return ret;
}
if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_MVPAIR]);
if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0)
return ret;
if (s->s.frames[CUR_FRAME].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[CUR_FRAME]);
if ((ret = vp9_frame_alloc(avctx, &s->s.frames[CUR_FRAME])) < 0)
return ret;
f = s->s.frames[CUR_FRAME].tf.f;
f->key_frame = s->s.h.keyframe;
f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&
(s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width ||
s->s.frames[REF_FRAME_MVPAIR].tf.f->height != s->s.frames[CUR_FRAME].tf.f->height)) {
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
}
// ref frame setup
for (i = 0; i < 8; i++) {
if (s->next_refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->next_refs[i]);
if (s->s.h.refreshrefmask & (1 << i)) {
ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.frames[CUR_FRAME].tf);
} else if (s->s.refs[i].f->buf[0]) {
ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i]);
}
if (ret < 0)
return ret;
}
if (avctx->hwaccel) {
ret = avctx->hwaccel->start_frame(avctx, NULL, 0);
if (ret < 0)
return ret;
ret = avctx->hwaccel->decode_slice(avctx, pkt->data, pkt->size);
if (ret < 0)
return ret;
ret = avctx->hwaccel->end_frame(avctx);
if (ret < 0)
return ret;
goto finish;
}
// main tile decode loop
memset(s->above_partition_ctx, 0, s->cols);
memset(s->above_skip_ctx, 0, s->cols);
if (s->s.h.keyframe || s->s.h.intraonly) {
memset(s->above_mode_ctx, DC_PRED, s->cols * 2);
} else {
memset(s->above_mode_ctx, NEARESTMV, s->cols);
}
memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16);
memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_segpred_ctx, 0, s->cols);
s->pass = s->s.frames[CUR_FRAME].uses_2pass =
avctx->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode;
if ((ret = update_block_buffers(avctx)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Failed to allocate block buffers\n");
return ret;
}
if (s->s.h.refreshctx && s->s.h.parallelmode) {
int j, k, l, m;
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++)
for (k = 0; k < 2; k++)
for (l = 0; l < 6; l++)
for (m = 0; m < 6; m++)
memcpy(s->prob_ctx[s->s.h.framectxid].coef[i][j][k][l][m],
s->prob.coef[i][j][k][l][m], 3);
if (s->s.h.txfmmode == i)
break;
}
s->prob_ctx[s->s.h.framectxid].p = s->prob.p;
ff_thread_finish_setup(avctx);
} else if (!s->s.h.refreshctx) {
ff_thread_finish_setup(avctx);
}
#if HAVE_THREADS
if (avctx->active_thread_type & FF_THREAD_SLICE) {
for (i = 0; i < s->sb_rows; i++)
atomic_store(&s->entries[i], 0);
}
#endif
do {
for (i = 0; i < s->active_tile_cols; i++) {
s->td[i].b = s->td[i].b_base;
s->td[i].block = s->td[i].block_base;
s->td[i].uvblock[0] = s->td[i].uvblock_base[0];
s->td[i].uvblock[1] = s->td[i].uvblock_base[1];
s->td[i].eob = s->td[i].eob_base;
s->td[i].uveob[0] = s->td[i].uveob_base[0];
s->td[i].uveob[1] = s->td[i].uveob_base[1];
}
#if HAVE_THREADS
if (avctx->active_thread_type == FF_THREAD_SLICE) {
int tile_row, tile_col;
av_assert1(!s->pass);
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
int64_t tile_size;
if (tile_col == s->s.h.tiling.tile_cols - 1 &&
tile_row == s->s.h.tiling.tile_rows - 1) {
tile_size = size;
} else {
tile_size = AV_RB32(data);
data += 4;
size -= 4;
}
if (tile_size > size)
return AVERROR_INVALIDDATA;
ret = ff_vp56_init_range_decoder(&s->td[tile_col].c_b[tile_row], data, tile_size);
if (ret < 0)
return ret;
if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128)) // marker bit
return AVERROR_INVALIDDATA;
data += tile_size;
size -= tile_size;
}
}
ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
} else
#endif
{
ret = decode_tiles(avctx, data, size);
if (ret < 0)
return ret;
}
// Sum all counts fields into td[0].counts for tile threading
if (avctx->active_thread_type == FF_THREAD_SLICE)
for (i = 1; i < s->s.h.tiling.tile_cols; i++)
for (j = 0; j < sizeof(s->td[i].counts) / sizeof(unsigned); j++)
((unsigned *)&s->td[0].counts)[j] += ((unsigned *)&s->td[i].counts)[j];
if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) {
ff_vp9_adapt_probs(s);
ff_thread_finish_setup(avctx);
}
} while (s->pass++ == 1);
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
finish:
// ref frame setup
for (i = 0; i < 8; i++) {
if (s->s.refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->s.refs[i]);
if (s->next_refs[i].f->buf[0] &&
(ret = ff_thread_ref_frame(&s->s.refs[i], &s->next_refs[i])) < 0)
return ret;
}
if (!s->s.h.invisible) {
if ((ret = av_frame_ref(frame, s->s.frames[CUR_FRAME].tf.f)) < 0)
return ret;
*got_frame = 1;
}
return pkt->size;
}
| true | FFmpeg | 5e03eea673a9da2253ed15152e46b1422b35d145 | static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
int *got_frame, AVPacket *pkt)
{
const uint8_t *data = pkt->data;
int size = pkt->size;
VP9Context *s = avctx->priv_data;
int ret, i, j, ref;
int retain_segmap_ref = s->s.frames[REF_FRAME_SEGMAP].segmentation_map &&
(!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map);
AVFrame *f;
if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) {
return ret;
} else if (ret == 0) {
if (!s->s.refs[ref].f->buf[0]) {
av_log(avctx, AV_LOG_ERROR, "Requested reference %d not available\n", ref);
return AVERROR_INVALIDDATA;
}
if ((ret = av_frame_ref(frame, s->s.refs[ref].f)) < 0)
return ret;
((AVFrame *)frame)->pts = pkt->pts;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
((AVFrame *)frame)->pkt_pts = pkt->pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
((AVFrame *)frame)->pkt_dts = pkt->dts;
for (i = 0; i < 8; i++) {
if (s->next_refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->next_refs[i]);
if (s->s.refs[i].f->buf[0] &&
(ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i])) < 0)
return ret;
}
*got_frame = 1;
return pkt->size;
}
data += ret;
size -= ret;
if (!retain_segmap_ref || s->s.h.keyframe || s->s.h.intraonly) {
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0)
return ret;
}
if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_MVPAIR]);
if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0)
return ret;
if (s->s.frames[CUR_FRAME].tf.f->buf[0])
vp9_frame_unref(avctx, &s->s.frames[CUR_FRAME]);
if ((ret = vp9_frame_alloc(avctx, &s->s.frames[CUR_FRAME])) < 0)
return ret;
f = s->s.frames[CUR_FRAME].tf.f;
f->key_frame = s->s.h.keyframe;
f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&
(s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width ||
s->s.frames[REF_FRAME_MVPAIR].tf.f->height != s->s.frames[CUR_FRAME].tf.f->height)) {
vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]);
}
for (i = 0; i < 8; i++) {
if (s->next_refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->next_refs[i]);
if (s->s.h.refreshrefmask & (1 << i)) {
ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.frames[CUR_FRAME].tf);
} else if (s->s.refs[i].f->buf[0]) {
ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i]);
}
if (ret < 0)
return ret;
}
if (avctx->hwaccel) {
ret = avctx->hwaccel->start_frame(avctx, NULL, 0);
if (ret < 0)
return ret;
ret = avctx->hwaccel->decode_slice(avctx, pkt->data, pkt->size);
if (ret < 0)
return ret;
ret = avctx->hwaccel->end_frame(avctx);
if (ret < 0)
return ret;
goto finish;
}
memset(s->above_partition_ctx, 0, s->cols);
memset(s->above_skip_ctx, 0, s->cols);
if (s->s.h.keyframe || s->s.h.intraonly) {
memset(s->above_mode_ctx, DC_PRED, s->cols * 2);
} else {
memset(s->above_mode_ctx, NEARESTMV, s->cols);
}
memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16);
memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_segpred_ctx, 0, s->cols);
s->pass = s->s.frames[CUR_FRAME].uses_2pass =
avctx->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode;
if ((ret = update_block_buffers(avctx)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"Failed to allocate block buffers\n");
return ret;
}
if (s->s.h.refreshctx && s->s.h.parallelmode) {
int j, k, l, m;
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++)
for (k = 0; k < 2; k++)
for (l = 0; l < 6; l++)
for (m = 0; m < 6; m++)
memcpy(s->prob_ctx[s->s.h.framectxid].coef[i][j][k][l][m],
s->prob.coef[i][j][k][l][m], 3);
if (s->s.h.txfmmode == i)
break;
}
s->prob_ctx[s->s.h.framectxid].p = s->prob.p;
ff_thread_finish_setup(avctx);
} else if (!s->s.h.refreshctx) {
ff_thread_finish_setup(avctx);
}
#if HAVE_THREADS
if (avctx->active_thread_type & FF_THREAD_SLICE) {
for (i = 0; i < s->sb_rows; i++)
atomic_store(&s->entries[i], 0);
}
#endif
do {
for (i = 0; i < s->active_tile_cols; i++) {
s->td[i].b = s->td[i].b_base;
s->td[i].block = s->td[i].block_base;
s->td[i].uvblock[0] = s->td[i].uvblock_base[0];
s->td[i].uvblock[1] = s->td[i].uvblock_base[1];
s->td[i].eob = s->td[i].eob_base;
s->td[i].uveob[0] = s->td[i].uveob_base[0];
s->td[i].uveob[1] = s->td[i].uveob_base[1];
}
#if HAVE_THREADS
if (avctx->active_thread_type == FF_THREAD_SLICE) {
int tile_row, tile_col;
av_assert1(!s->pass);
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
int64_t tile_size;
if (tile_col == s->s.h.tiling.tile_cols - 1 &&
tile_row == s->s.h.tiling.tile_rows - 1) {
tile_size = size;
} else {
tile_size = AV_RB32(data);
data += 4;
size -= 4;
}
if (tile_size > size)
return AVERROR_INVALIDDATA;
ret = ff_vp56_init_range_decoder(&s->td[tile_col].c_b[tile_row], data, tile_size);
if (ret < 0)
return ret;
if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128))
return AVERROR_INVALIDDATA;
data += tile_size;
size -= tile_size;
}
}
ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
} else
#endif
{
ret = decode_tiles(avctx, data, size);
if (ret < 0)
return ret;
}
if (avctx->active_thread_type == FF_THREAD_SLICE)
for (i = 1; i < s->s.h.tiling.tile_cols; i++)
for (j = 0; j < sizeof(s->td[i].counts) / sizeof(unsigned); j++)
((unsigned *)&s->td[0].counts)[j] += ((unsigned *)&s->td[i].counts)[j];
if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) {
ff_vp9_adapt_probs(s);
ff_thread_finish_setup(avctx);
}
} while (s->pass++ == 1);
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
finish:
for (i = 0; i < 8; i++) {
if (s->s.refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->s.refs[i]);
if (s->next_refs[i].f->buf[0] &&
(ret = ff_thread_ref_frame(&s->s.refs[i], &s->next_refs[i])) < 0)
return ret;
}
if (!s->s.h.invisible) {
if ((ret = av_frame_ref(frame, s->s.frames[CUR_FRAME].tf.f)) < 0)
return ret;
*got_frame = 1;
}
return pkt->size;
}
| {
"code": [
" if (ret < 0)"
],
"line_no": [
367
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_4;
int VAR_5 = VAR_3->VAR_5;
VP9Context *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_11, VAR_9;
int VAR_10 = s->s.frames[REF_FRAME_SEGMAP].segmentation_map &&
(!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map);
AVFrame *f;
if ((VAR_6 = decode_frame_header(VAR_0, VAR_4, VAR_5, &VAR_9)) < 0) {
return VAR_6;
} else if (VAR_6 == 0) {
if (!s->s.refs[VAR_9].f->buf[0]) {
av_log(VAR_0, AV_LOG_ERROR, "Requested reference %d not available\n", VAR_9);
return AVERROR_INVALIDDATA;
}
if ((VAR_6 = av_frame_ref(VAR_1, s->s.refs[VAR_9].f)) < 0)
return VAR_6;
((AVFrame *)VAR_1)->pts = VAR_3->pts;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
((AVFrame *)VAR_1)->pkt_pts = VAR_3->pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
((AVFrame *)VAR_1)->pkt_dts = VAR_3->dts;
for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {
if (s->next_refs[VAR_7].f->buf[0])
ff_thread_release_buffer(VAR_0, &s->next_refs[VAR_7]);
if (s->s.refs[VAR_7].f->buf[0] &&
(VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.refs[VAR_7])) < 0)
return VAR_6;
}
*VAR_2 = 1;
return VAR_3->VAR_5;
}
VAR_4 += VAR_6;
VAR_5 -= VAR_6;
if (!VAR_10 || s->s.h.keyframe || s->s.h.intraonly) {
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0])
vp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP]);
if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(VAR_6 = vp9_frame_ref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0)
return VAR_6;
}
if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0])
vp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_MVPAIR]);
if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&
(VAR_6 = vp9_frame_ref(VAR_0, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0)
return VAR_6;
if (s->s.frames[CUR_FRAME].tf.f->buf[0])
vp9_frame_unref(VAR_0, &s->s.frames[CUR_FRAME]);
if ((VAR_6 = vp9_frame_alloc(VAR_0, &s->s.frames[CUR_FRAME])) < 0)
return VAR_6;
f = s->s.frames[CUR_FRAME].tf.f;
f->key_frame = s->s.h.keyframe;
f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&
(s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width ||
s->s.frames[REF_FRAME_MVPAIR].tf.f->height != s->s.frames[CUR_FRAME].tf.f->height)) {
vp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP]);
}
for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {
if (s->next_refs[VAR_7].f->buf[0])
ff_thread_release_buffer(VAR_0, &s->next_refs[VAR_7]);
if (s->s.h.refreshrefmask & (1 << VAR_7)) {
VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.frames[CUR_FRAME].tf);
} else if (s->s.refs[VAR_7].f->buf[0]) {
VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.refs[VAR_7]);
}
if (VAR_6 < 0)
return VAR_6;
}
if (VAR_0->hwaccel) {
VAR_6 = VAR_0->hwaccel->start_frame(VAR_0, NULL, 0);
if (VAR_6 < 0)
return VAR_6;
VAR_6 = VAR_0->hwaccel->decode_slice(VAR_0, VAR_3->VAR_4, VAR_3->VAR_5);
if (VAR_6 < 0)
return VAR_6;
VAR_6 = VAR_0->hwaccel->end_frame(VAR_0);
if (VAR_6 < 0)
return VAR_6;
goto finish;
}
memset(s->above_partition_ctx, 0, s->cols);
memset(s->above_skip_ctx, 0, s->cols);
if (s->s.h.keyframe || s->s.h.intraonly) {
memset(s->above_mode_ctx, DC_PRED, s->cols * 2);
} else {
memset(s->above_mode_ctx, NEARESTMV, s->cols);
}
memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16);
memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 16 >> s->ss_h);
memset(s->above_segpred_ctx, 0, s->cols);
s->pass = s->s.frames[CUR_FRAME].uses_2pass =
VAR_0->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode;
if ((VAR_6 = update_block_buffers(VAR_0)) < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Failed to allocate block buffers\n");
return VAR_6;
}
if (s->s.h.refreshctx && s->s.h.parallelmode) {
int VAR_11, VAR_11, VAR_12, VAR_13;
for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 6; VAR_12++)
for (VAR_13 = 0; VAR_13 < 6; VAR_13++)
memcpy(s->prob_ctx[s->s.h.framectxid].coef[VAR_7][VAR_11][VAR_11][VAR_12][VAR_13],
s->prob.coef[VAR_7][VAR_11][VAR_11][VAR_12][VAR_13], 3);
if (s->s.h.txfmmode == VAR_7)
break;
}
s->prob_ctx[s->s.h.framectxid].p = s->prob.p;
ff_thread_finish_setup(VAR_0);
} else if (!s->s.h.refreshctx) {
ff_thread_finish_setup(VAR_0);
}
#if HAVE_THREADS
if (VAR_0->active_thread_type & FF_THREAD_SLICE) {
for (VAR_7 = 0; VAR_7 < s->sb_rows; VAR_7++)
atomic_store(&s->entries[VAR_7], 0);
}
#endif
do {
for (VAR_7 = 0; VAR_7 < s->active_tile_cols; VAR_7++) {
s->td[VAR_7].b = s->td[VAR_7].b_base;
s->td[VAR_7].block = s->td[VAR_7].block_base;
s->td[VAR_7].uvblock[0] = s->td[VAR_7].uvblock_base[0];
s->td[VAR_7].uvblock[1] = s->td[VAR_7].uvblock_base[1];
s->td[VAR_7].eob = s->td[VAR_7].eob_base;
s->td[VAR_7].uveob[0] = s->td[VAR_7].uveob_base[0];
s->td[VAR_7].uveob[1] = s->td[VAR_7].uveob_base[1];
}
#if HAVE_THREADS
if (VAR_0->active_thread_type == FF_THREAD_SLICE) {
int tile_row, tile_col;
av_assert1(!s->pass);
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
int64_t tile_size;
if (tile_col == s->s.h.tiling.tile_cols - 1 &&
tile_row == s->s.h.tiling.tile_rows - 1) {
tile_size = VAR_5;
} else {
tile_size = AV_RB32(VAR_4);
VAR_4 += 4;
VAR_5 -= 4;
}
if (tile_size > VAR_5)
return AVERROR_INVALIDDATA;
VAR_6 = ff_vp56_init_range_decoder(&s->td[tile_col].c_b[tile_row], VAR_4, tile_size);
if (VAR_6 < 0)
return VAR_6;
if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128))
return AVERROR_INVALIDDATA;
VAR_4 += tile_size;
VAR_5 -= tile_size;
}
}
ff_slice_thread_execute_with_mainfunc(VAR_0, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
} else
#endif
{
VAR_6 = decode_tiles(VAR_0, VAR_4, VAR_5);
if (VAR_6 < 0)
return VAR_6;
}
if (VAR_0->active_thread_type == FF_THREAD_SLICE)
for (VAR_7 = 1; VAR_7 < s->s.h.tiling.tile_cols; VAR_7++)
for (VAR_11 = 0; VAR_11 < sizeof(s->td[VAR_7].counts) / sizeof(unsigned); VAR_11++)
((unsigned *)&s->td[0].counts)[VAR_11] += ((unsigned *)&s->td[VAR_7].counts)[VAR_11];
if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) {
ff_vp9_adapt_probs(s);
ff_thread_finish_setup(VAR_0);
}
} while (s->pass++ == 1);
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
finish:
for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {
if (s->s.refs[VAR_7].f->buf[0])
ff_thread_release_buffer(VAR_0, &s->s.refs[VAR_7]);
if (s->next_refs[VAR_7].f->buf[0] &&
(VAR_6 = ff_thread_ref_frame(&s->s.refs[VAR_7], &s->next_refs[VAR_7])) < 0)
return VAR_6;
}
if (!s->s.h.invisible) {
if ((VAR_6 = av_frame_ref(VAR_1, s->s.frames[CUR_FRAME].tf.f)) < 0)
return VAR_6;
*VAR_2 = 1;
}
return VAR_3->VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_4;",
"int VAR_5 = VAR_3->VAR_5;",
"VP9Context *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_11, VAR_9;",
"int VAR_10 = s->s.frames[REF_FRAME_SEGMAP].segmentation_map &&\n(!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map);",
"AVFrame *f;",
"if ((VAR_6 = decode_frame_header(VAR_0, VAR_4, VAR_5, &VAR_9)) < 0) {",
"return VAR_6;",
"} else if (VAR_6 == 0) {",
"if (!s->s.refs[VAR_9].f->buf[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Requested reference %d not available\\n\", VAR_9);",
"return AVERROR_INVALIDDATA;",
"}",
"if ((VAR_6 = av_frame_ref(VAR_1, s->s.refs[VAR_9].f)) < 0)\nreturn VAR_6;",
"((AVFrame *)VAR_1)->pts = VAR_3->pts;",
"#if FF_API_PKT_PTS\nFF_DISABLE_DEPRECATION_WARNINGS\n((AVFrame *)VAR_1)->pkt_pts = VAR_3->pts;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n((AVFrame *)VAR_1)->pkt_dts = VAR_3->dts;",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {",
"if (s->next_refs[VAR_7].f->buf[0])\nff_thread_release_buffer(VAR_0, &s->next_refs[VAR_7]);",
"if (s->s.refs[VAR_7].f->buf[0] &&\n(VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.refs[VAR_7])) < 0)\nreturn VAR_6;",
"}",
"*VAR_2 = 1;",
"return VAR_3->VAR_5;",
"}",
"VAR_4 += VAR_6;",
"VAR_5 -= VAR_6;",
"if (!VAR_10 || s->s.h.keyframe || s->s.h.intraonly) {",
"if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0])\nvp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP]);",
"if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&\n(VAR_6 = vp9_frame_ref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0)\nreturn VAR_6;",
"}",
"if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0])\nvp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_MVPAIR]);",
"if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] &&\n(VAR_6 = vp9_frame_ref(VAR_0, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0)\nreturn VAR_6;",
"if (s->s.frames[CUR_FRAME].tf.f->buf[0])\nvp9_frame_unref(VAR_0, &s->s.frames[CUR_FRAME]);",
"if ((VAR_6 = vp9_frame_alloc(VAR_0, &s->s.frames[CUR_FRAME])) < 0)\nreturn VAR_6;",
"f = s->s.frames[CUR_FRAME].tf.f;",
"f->key_frame = s->s.h.keyframe;",
"f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;",
"if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&\n(s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width ||\ns->s.frames[REF_FRAME_MVPAIR].tf.f->height != s->s.frames[CUR_FRAME].tf.f->height)) {",
"vp9_frame_unref(VAR_0, &s->s.frames[REF_FRAME_SEGMAP]);",
"}",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {",
"if (s->next_refs[VAR_7].f->buf[0])\nff_thread_release_buffer(VAR_0, &s->next_refs[VAR_7]);",
"if (s->s.h.refreshrefmask & (1 << VAR_7)) {",
"VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.frames[CUR_FRAME].tf);",
"} else if (s->s.refs[VAR_7].f->buf[0]) {",
"VAR_6 = ff_thread_ref_frame(&s->next_refs[VAR_7], &s->s.refs[VAR_7]);",
"}",
"if (VAR_6 < 0)\nreturn VAR_6;",
"}",
"if (VAR_0->hwaccel) {",
"VAR_6 = VAR_0->hwaccel->start_frame(VAR_0, NULL, 0);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"VAR_6 = VAR_0->hwaccel->decode_slice(VAR_0, VAR_3->VAR_4, VAR_3->VAR_5);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"VAR_6 = VAR_0->hwaccel->end_frame(VAR_0);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"goto finish;",
"}",
"memset(s->above_partition_ctx, 0, s->cols);",
"memset(s->above_skip_ctx, 0, s->cols);",
"if (s->s.h.keyframe || s->s.h.intraonly) {",
"memset(s->above_mode_ctx, DC_PRED, s->cols * 2);",
"} else {",
"memset(s->above_mode_ctx, NEARESTMV, s->cols);",
"}",
"memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16);",
"memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 16 >> s->ss_h);",
"memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 16 >> s->ss_h);",
"memset(s->above_segpred_ctx, 0, s->cols);",
"s->pass = s->s.frames[CUR_FRAME].uses_2pass =\nVAR_0->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode;",
"if ((VAR_6 = update_block_buffers(VAR_0)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Failed to allocate block buffers\\n\");",
"return VAR_6;",
"}",
"if (s->s.h.refreshctx && s->s.h.parallelmode) {",
"int VAR_11, VAR_11, VAR_12, VAR_13;",
"for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 6; VAR_12++)",
"for (VAR_13 = 0; VAR_13 < 6; VAR_13++)",
"memcpy(s->prob_ctx[s->s.h.framectxid].coef[VAR_7][VAR_11][VAR_11][VAR_12][VAR_13],\ns->prob.coef[VAR_7][VAR_11][VAR_11][VAR_12][VAR_13], 3);",
"if (s->s.h.txfmmode == VAR_7)\nbreak;",
"}",
"s->prob_ctx[s->s.h.framectxid].p = s->prob.p;",
"ff_thread_finish_setup(VAR_0);",
"} else if (!s->s.h.refreshctx) {",
"ff_thread_finish_setup(VAR_0);",
"}",
"#if HAVE_THREADS\nif (VAR_0->active_thread_type & FF_THREAD_SLICE) {",
"for (VAR_7 = 0; VAR_7 < s->sb_rows; VAR_7++)",
"atomic_store(&s->entries[VAR_7], 0);",
"}",
"#endif\ndo {",
"for (VAR_7 = 0; VAR_7 < s->active_tile_cols; VAR_7++) {",
"s->td[VAR_7].b = s->td[VAR_7].b_base;",
"s->td[VAR_7].block = s->td[VAR_7].block_base;",
"s->td[VAR_7].uvblock[0] = s->td[VAR_7].uvblock_base[0];",
"s->td[VAR_7].uvblock[1] = s->td[VAR_7].uvblock_base[1];",
"s->td[VAR_7].eob = s->td[VAR_7].eob_base;",
"s->td[VAR_7].uveob[0] = s->td[VAR_7].uveob_base[0];",
"s->td[VAR_7].uveob[1] = s->td[VAR_7].uveob_base[1];",
"}",
"#if HAVE_THREADS\nif (VAR_0->active_thread_type == FF_THREAD_SLICE) {",
"int tile_row, tile_col;",
"av_assert1(!s->pass);",
"for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {",
"for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {",
"int64_t tile_size;",
"if (tile_col == s->s.h.tiling.tile_cols - 1 &&\ntile_row == s->s.h.tiling.tile_rows - 1) {",
"tile_size = VAR_5;",
"} else {",
"tile_size = AV_RB32(VAR_4);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"}",
"if (tile_size > VAR_5)\nreturn AVERROR_INVALIDDATA;",
"VAR_6 = ff_vp56_init_range_decoder(&s->td[tile_col].c_b[tile_row], VAR_4, tile_size);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 += tile_size;",
"VAR_5 -= tile_size;",
"}",
"}",
"ff_slice_thread_execute_with_mainfunc(VAR_0, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);",
"} else",
"#endif\n{",
"VAR_6 = decode_tiles(VAR_0, VAR_4, VAR_5);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"}",
"if (VAR_0->active_thread_type == FF_THREAD_SLICE)\nfor (VAR_7 = 1; VAR_7 < s->s.h.tiling.tile_cols; VAR_7++)",
"for (VAR_11 = 0; VAR_11 < sizeof(s->td[VAR_7].counts) / sizeof(unsigned); VAR_11++)",
"((unsigned *)&s->td[0].counts)[VAR_11] += ((unsigned *)&s->td[VAR_7].counts)[VAR_11];",
"if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) {",
"ff_vp9_adapt_probs(s);",
"ff_thread_finish_setup(VAR_0);",
"}",
"} while (s->pass++ == 1);",
"ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);",
"finish:\nfor (VAR_7 = 0; VAR_7 < 8; VAR_7++) {",
"if (s->s.refs[VAR_7].f->buf[0])\nff_thread_release_buffer(VAR_0, &s->s.refs[VAR_7]);",
"if (s->next_refs[VAR_7].f->buf[0] &&\n(VAR_6 = ff_thread_ref_frame(&s->s.refs[VAR_7], &s->next_refs[VAR_7])) < 0)\nreturn VAR_6;",
"}",
"if (!s->s.h.invisible) {",
"if ((VAR_6 = av_frame_ref(VAR_1, s->s.frames[CUR_FRAME].tf.f)) < 0)\nreturn VAR_6;",
"*VAR_2 = 1;",
"}",
"return VAR_3->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,
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
],
[
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
],
[
81
],
[
83,
85
],
[
87,
89,
91
],
[
93
],
[
95,
97
],
[
99,
101,
103
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
121,
123,
125
],
[
127
],
[
129
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169,
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239,
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297,
299
],
[
301
],
[
305
],
[
309
],
[
311
],
[
313
],
[
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335
],
[
337
],
[
339,
341
],
[
343,
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
357
],
[
359
],
[
361,
363
],
[
365
],
[
367,
369
],
[
371
],
[
377,
379
],
[
381
],
[
383
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
401,
405
],
[
407,
409
],
[
411,
413,
415
],
[
417
],
[
421
],
[
423,
425
],
[
427
],
[
429
],
[
433
],
[
435
]
] |
19,901 | static void ccid_card_vscard_send_msg(PassthruState *s,
VSCMsgType type, uint32_t reader_id,
const uint8_t *payload, uint32_t length)
{
VSCMsgHeader scr_msg_header;
scr_msg_header.type = htonl(type);
scr_msg_header.reader_id = htonl(reader_id);
scr_msg_header.length = htonl(length);
qemu_chr_fe_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));
qemu_chr_fe_write(s->cs, payload, length);
}
| true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void ccid_card_vscard_send_msg(PassthruState *s,
VSCMsgType type, uint32_t reader_id,
const uint8_t *payload, uint32_t length)
{
VSCMsgHeader scr_msg_header;
scr_msg_header.type = htonl(type);
scr_msg_header.reader_id = htonl(reader_id);
scr_msg_header.length = htonl(length);
qemu_chr_fe_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));
qemu_chr_fe_write(s->cs, payload, length);
}
| {
"code": [
" qemu_chr_fe_write(s->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));",
" qemu_chr_fe_write(s->cs, payload, length);"
],
"line_no": [
19,
21
]
} | static void FUNC_0(PassthruState *VAR_0,
VSCMsgType VAR_1, uint32_t VAR_2,
const uint8_t *VAR_3, uint32_t VAR_4)
{
VSCMsgHeader scr_msg_header;
scr_msg_header.VAR_1 = htonl(VAR_1);
scr_msg_header.VAR_2 = htonl(VAR_2);
scr_msg_header.VAR_4 = htonl(VAR_4);
qemu_chr_fe_write(VAR_0->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));
qemu_chr_fe_write(VAR_0->cs, VAR_3, VAR_4);
}
| [
"static void FUNC_0(PassthruState *VAR_0,\nVSCMsgType VAR_1, uint32_t VAR_2,\nconst uint8_t *VAR_3, uint32_t VAR_4)\n{",
"VSCMsgHeader scr_msg_header;",
"scr_msg_header.VAR_1 = htonl(VAR_1);",
"scr_msg_header.VAR_2 = htonl(VAR_2);",
"scr_msg_header.VAR_4 = htonl(VAR_4);",
"qemu_chr_fe_write(VAR_0->cs, (uint8_t *)&scr_msg_header, sizeof(VSCMsgHeader));",
"qemu_chr_fe_write(VAR_0->cs, VAR_3, VAR_4);",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,902 | static int kvmclock_post_load(void *opaque, int version_id)
{
KVMClockState *s = opaque;
struct kvm_clock_data data;
data.clock = s->clock;
data.flags = 0;
return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
}
| true | qemu | 00f4d64ee76e873be881a82d893a591487aa7950 | static int kvmclock_post_load(void *opaque, int version_id)
{
KVMClockState *s = opaque;
struct kvm_clock_data data;
data.clock = s->clock;
data.flags = 0;
return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
}
| {
"code": [
" KVMClockState *s = opaque;",
" struct kvm_clock_data data;",
"static int kvmclock_post_load(void *opaque, int version_id)",
" KVMClockState *s = opaque;",
" struct kvm_clock_data data;",
" data.clock = s->clock;",
" data.flags = 0;",
" return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);"
],
"line_no": [
5,
7,
1,
5,
7,
11,
13,
15
]
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
KVMClockState *s = VAR_0;
struct kvm_clock_data VAR_2;
VAR_2.clock = s->clock;
VAR_2.flags = 0;
return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &VAR_2);
}
| [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"KVMClockState *s = VAR_0;",
"struct kvm_clock_data VAR_2;",
"VAR_2.clock = s->clock;",
"VAR_2.flags = 0;",
"return kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &VAR_2);",
"}"
] | [
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,903 | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64)
{
TCGReg datalo, datahi, addrlo, rbase;
TCGReg addrhi __attribute__((unused));
TCGMemOpIdx oi;
TCGMemOp opc, s_bits;
#ifdef CONFIG_SOFTMMU
int mem_index;
tcg_insn_unit *label_ptr;
#endif
datalo = *args++;
datahi = (TCG_TARGET_REG_BITS == 32 && is_64 ? *args++ : 0);
addrlo = *args++;
addrhi = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0);
oi = *args++;
opc = get_memop(oi);
s_bits = opc & MO_SIZE;
#ifdef CONFIG_SOFTMMU
mem_index = get_mmuidx(oi);
addrlo = tcg_out_tlb_read(s, s_bits, addrlo, addrhi, mem_index, false);
/* Load a pointer into the current opcode w/conditional branch-link. */
label_ptr = s->code_ptr;
tcg_out_bc_noaddr(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
rbase = TCG_REG_R3;
#else /* !CONFIG_SOFTMMU */
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {
tcg_out_ext32u(s, TCG_REG_TMP1, addrlo);
addrlo = TCG_REG_TMP1;
}
#endif
if (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) {
if (opc & MO_BSWAP) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, STWBRX | SAB(datahi, rbase, TCG_REG_R0));
} else if (rbase != 0) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWX | SAB(datahi, rbase, addrlo));
tcg_out32(s, STWX | SAB(datalo, rbase, TCG_REG_R0));
} else {
tcg_out32(s, STW | TAI(datahi, addrlo, 0));
tcg_out32(s, STW | TAI(datalo, addrlo, 4));
}
} else {
uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)];
if (!HAVE_ISA_2_06 && insn == STDBRX) {
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, addrlo, 4));
tcg_out_shri64(s, TCG_REG_R0, datalo, 32);
tcg_out32(s, STWBRX | SAB(TCG_REG_R0, rbase, TCG_REG_TMP1));
} else {
tcg_out32(s, insn | SAB(datalo, rbase, addrlo));
}
}
#ifdef CONFIG_SOFTMMU
add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi,
s->code_ptr, label_ptr);
#endif
}
| true | qemu | 68d45bb61c5bbfb3999486f78cf026c1e79eb301 | static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64)
{
TCGReg datalo, datahi, addrlo, rbase;
TCGReg addrhi __attribute__((unused));
TCGMemOpIdx oi;
TCGMemOp opc, s_bits;
#ifdef CONFIG_SOFTMMU
int mem_index;
tcg_insn_unit *label_ptr;
#endif
datalo = *args++;
datahi = (TCG_TARGET_REG_BITS == 32 && is_64 ? *args++ : 0);
addrlo = *args++;
addrhi = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0);
oi = *args++;
opc = get_memop(oi);
s_bits = opc & MO_SIZE;
#ifdef CONFIG_SOFTMMU
mem_index = get_mmuidx(oi);
addrlo = tcg_out_tlb_read(s, s_bits, addrlo, addrhi, mem_index, false);
label_ptr = s->code_ptr;
tcg_out_bc_noaddr(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
rbase = TCG_REG_R3;
#else
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {
tcg_out_ext32u(s, TCG_REG_TMP1, addrlo);
addrlo = TCG_REG_TMP1;
}
#endif
if (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) {
if (opc & MO_BSWAP) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, STWBRX | SAB(datahi, rbase, TCG_REG_R0));
} else if (rbase != 0) {
tcg_out32(s, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(s, STWX | SAB(datahi, rbase, addrlo));
tcg_out32(s, STWX | SAB(datalo, rbase, TCG_REG_R0));
} else {
tcg_out32(s, STW | TAI(datahi, addrlo, 0));
tcg_out32(s, STW | TAI(datalo, addrlo, 4));
}
} else {
uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)];
if (!HAVE_ISA_2_06 && insn == STDBRX) {
tcg_out32(s, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, addrlo, 4));
tcg_out_shri64(s, TCG_REG_R0, datalo, 32);
tcg_out32(s, STWBRX | SAB(TCG_REG_R0, rbase, TCG_REG_TMP1));
} else {
tcg_out32(s, insn | SAB(datalo, rbase, addrlo));
}
}
#ifdef CONFIG_SOFTMMU
add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi,
s->code_ptr, label_ptr);
#endif
}
| {
"code": [
" addrlo = tcg_out_tlb_read(s, s_bits, addrlo, addrhi, mem_index, false);"
],
"line_no": [
43
]
} | static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1, bool VAR_2)
{
TCGReg datalo, datahi, addrlo, rbase;
TCGReg addrhi __attribute__((unused));
TCGMemOpIdx oi;
TCGMemOp opc, s_bits;
#ifdef CONFIG_SOFTMMU
int mem_index;
tcg_insn_unit *label_ptr;
#endif
datalo = *VAR_1++;
datahi = (TCG_TARGET_REG_BITS == 32 && VAR_2 ? *VAR_1++ : 0);
addrlo = *VAR_1++;
addrhi = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *VAR_1++ : 0);
oi = *VAR_1++;
opc = get_memop(oi);
s_bits = opc & MO_SIZE;
#ifdef CONFIG_SOFTMMU
mem_index = get_mmuidx(oi);
addrlo = tcg_out_tlb_read(VAR_0, s_bits, addrlo, addrhi, mem_index, false);
label_ptr = VAR_0->code_ptr;
tcg_out_bc_noaddr(VAR_0, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);
rbase = TCG_REG_R3;
#else
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {
tcg_out_ext32u(VAR_0, TCG_REG_TMP1, addrlo);
addrlo = TCG_REG_TMP1;
}
#endif
if (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) {
if (opc & MO_BSWAP) {
tcg_out32(VAR_0, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(VAR_0, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(VAR_0, STWBRX | SAB(datahi, rbase, TCG_REG_R0));
} else if (rbase != 0) {
tcg_out32(VAR_0, ADDI | TAI(TCG_REG_R0, addrlo, 4));
tcg_out32(VAR_0, STWX | SAB(datahi, rbase, addrlo));
tcg_out32(VAR_0, STWX | SAB(datalo, rbase, TCG_REG_R0));
} else {
tcg_out32(VAR_0, STW | TAI(datahi, addrlo, 0));
tcg_out32(VAR_0, STW | TAI(datalo, addrlo, 4));
}
} else {
uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)];
if (!HAVE_ISA_2_06 && insn == STDBRX) {
tcg_out32(VAR_0, STWBRX | SAB(datalo, rbase, addrlo));
tcg_out32(VAR_0, ADDI | TAI(TCG_REG_TMP1, addrlo, 4));
tcg_out_shri64(VAR_0, TCG_REG_R0, datalo, 32);
tcg_out32(VAR_0, STWBRX | SAB(TCG_REG_R0, rbase, TCG_REG_TMP1));
} else {
tcg_out32(VAR_0, insn | SAB(datalo, rbase, addrlo));
}
}
#ifdef CONFIG_SOFTMMU
add_qemu_ldst_label(VAR_0, false, oi, datalo, datahi, addrlo, addrhi,
VAR_0->code_ptr, label_ptr);
#endif
}
| [
"static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1, bool VAR_2)\n{",
"TCGReg datalo, datahi, addrlo, rbase;",
"TCGReg addrhi __attribute__((unused));",
"TCGMemOpIdx oi;",
"TCGMemOp opc, s_bits;",
"#ifdef CONFIG_SOFTMMU\nint mem_index;",
"tcg_insn_unit *label_ptr;",
"#endif\ndatalo = *VAR_1++;",
"datahi = (TCG_TARGET_REG_BITS == 32 && VAR_2 ? *VAR_1++ : 0);",
"addrlo = *VAR_1++;",
"addrhi = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *VAR_1++ : 0);",
"oi = *VAR_1++;",
"opc = get_memop(oi);",
"s_bits = opc & MO_SIZE;",
"#ifdef CONFIG_SOFTMMU\nmem_index = get_mmuidx(oi);",
"addrlo = tcg_out_tlb_read(VAR_0, s_bits, addrlo, addrhi, mem_index, false);",
"label_ptr = VAR_0->code_ptr;",
"tcg_out_bc_noaddr(VAR_0, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK);",
"rbase = TCG_REG_R3;",
"#else\nrbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;",
"if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) {",
"tcg_out_ext32u(VAR_0, TCG_REG_TMP1, addrlo);",
"addrlo = TCG_REG_TMP1;",
"}",
"#endif\nif (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) {",
"if (opc & MO_BSWAP) {",
"tcg_out32(VAR_0, ADDI | TAI(TCG_REG_R0, addrlo, 4));",
"tcg_out32(VAR_0, STWBRX | SAB(datalo, rbase, addrlo));",
"tcg_out32(VAR_0, STWBRX | SAB(datahi, rbase, TCG_REG_R0));",
"} else if (rbase != 0) {",
"tcg_out32(VAR_0, ADDI | TAI(TCG_REG_R0, addrlo, 4));",
"tcg_out32(VAR_0, STWX | SAB(datahi, rbase, addrlo));",
"tcg_out32(VAR_0, STWX | SAB(datalo, rbase, TCG_REG_R0));",
"} else {",
"tcg_out32(VAR_0, STW | TAI(datahi, addrlo, 0));",
"tcg_out32(VAR_0, STW | TAI(datalo, addrlo, 4));",
"}",
"} else {",
"uint32_t insn = qemu_stx_opc[opc & (MO_BSWAP | MO_SIZE)];",
"if (!HAVE_ISA_2_06 && insn == STDBRX) {",
"tcg_out32(VAR_0, STWBRX | SAB(datalo, rbase, addrlo));",
"tcg_out32(VAR_0, ADDI | TAI(TCG_REG_TMP1, addrlo, 4));",
"tcg_out_shri64(VAR_0, TCG_REG_R0, datalo, 32);",
"tcg_out32(VAR_0, STWBRX | SAB(TCG_REG_R0, rbase, TCG_REG_TMP1));",
"} else {",
"tcg_out32(VAR_0, insn | SAB(datalo, rbase, addrlo));",
"}",
"}",
"#ifdef CONFIG_SOFTMMU\nadd_qemu_ldst_label(VAR_0, false, oi, datalo, datahi, addrlo, addrhi,\nVAR_0->code_ptr, label_ptr);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123,
125,
127
],
[
129,
131
]
] |
19,904 | static int decode_dvd_subtitles(AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = 0;
uint8_t colormap[4], alpha[256];
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
sub_header->rects = NULL;
sub_header->num_rects = 0;
sub_header->format = 0;
sub_header->start_display_time = 0;
sub_header->end_display_time = 0;
if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
while ((cmd_pos + 2 + offset_size) < buf_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
dprintf(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
dprintf(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
/* menu subpicture */
is_menu = 1;
break;
case 0x01:
/* set start date */
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
/* set end date */
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
/* set colormap */
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
/* set alpha */
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
dprintf(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
/* HD set palette */
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
/* HD set contrast (alpha) */
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
dprintf(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
/* decode the bitmap */
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
sub_header->rects[0]->pict.data[1] = av_malloc(256 * 4);
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->pict.data[1] = av_malloc(4 * 4);
sub_header->rects[0]->nb_colors = 4;
guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
}
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
return -1;
}
| true | FFmpeg | ffbe087b589506cb0e671fa711e5c2c6ea203ac0 | static int decode_dvd_subtitles(AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = 0;
uint8_t colormap[4], alpha[256];
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
sub_header->rects = NULL;
sub_header->num_rects = 0;
sub_header->format = 0;
sub_header->start_display_time = 0;
sub_header->end_display_time = 0;
if (AV_RB16(buf) == 0) {
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
while ((cmd_pos + 2 + offset_size) < buf_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
dprintf(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
dprintf(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
is_menu = 1;
break;
case 0x01:
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
dprintf(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
dprintf(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
sub_header->rects[0]->pict.data[1] = av_malloc(256 * 4);
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->pict.data[1] = av_malloc(4 * 4);
sub_header->rects[0]->nb_colors = 4;
guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
}
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
if (sub_header->rects != NULL) {
for (i = 0; i < sub_header->num_rects; i++) {
av_freep(&sub_header->rects[i]->pict.data[0]);
av_freep(&sub_header->rects[i]->pict.data[1]);
av_freep(&sub_header->rects[i]);
}
av_freep(&sub_header->rects);
sub_header->num_rects = 0;
}
return -1;
}
| {
"code": [
" while ((cmd_pos + 2 + offset_size) < buf_size) {"
],
"line_no": [
63
]
} | static int FUNC_0(AVSubtitle *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
int VAR_13, VAR_14, VAR_15 = 0;
const uint8_t *VAR_16 = 0;
uint8_t colormap[4], alpha[256];
int VAR_17;
int VAR_18;
int VAR_19 = 0;
if (VAR_2 < 10)
return -1;
VAR_0->rects = NULL;
VAR_0->num_rects = 0;
VAR_0->format = 0;
VAR_0->start_display_time = 0;
VAR_0->end_display_time = 0;
if (AV_RB16(VAR_1) == 0) {
VAR_13 = 1;
VAR_14 = 4;
VAR_3 = 6;
} else {
VAR_13 = 0;
VAR_14 = 2;
VAR_3 = 2;
}
VAR_3 = READ_OFFSET(VAR_1 + VAR_3);
while ((VAR_3 + 2 + VAR_14) < VAR_2) {
VAR_17 = AV_RB16(VAR_1 + VAR_3);
VAR_12 = READ_OFFSET(VAR_1 + VAR_3 + 2);
dprintf(NULL, "VAR_3=0x%04x next=0x%04x VAR_17=%d\n",
VAR_3, VAR_12, VAR_17);
VAR_4 = VAR_3 + 2 + VAR_14;
VAR_10 = -1;
VAR_11 = -1;
VAR_6 = VAR_7 = VAR_8 = VAR_9 = 0;
while (VAR_4 < VAR_2) {
VAR_5 = VAR_1[VAR_4++];
dprintf(NULL, "VAR_5=%02x\n", VAR_5);
switch(VAR_5) {
case 0x00:
VAR_19 = 1;
break;
case 0x01:
VAR_0->start_display_time = (VAR_17 << 10) / 90;
break;
case 0x02:
VAR_0->end_display_time = (VAR_17 << 10) / 90;
break;
case 0x03:
if ((VAR_2 - VAR_4) < 2)
goto fail;
colormap[3] = VAR_1[VAR_4] >> 4;
colormap[2] = VAR_1[VAR_4] & 0x0f;
colormap[1] = VAR_1[VAR_4 + 1] >> 4;
colormap[0] = VAR_1[VAR_4 + 1] & 0x0f;
VAR_4 += 2;
break;
case 0x04:
if ((VAR_2 - VAR_4) < 2)
goto fail;
alpha[3] = VAR_1[VAR_4] >> 4;
alpha[2] = VAR_1[VAR_4] & 0x0f;
alpha[1] = VAR_1[VAR_4 + 1] >> 4;
alpha[0] = VAR_1[VAR_4 + 1] & 0x0f;
VAR_4 += 2;
dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((VAR_2 - VAR_4) < 6)
goto fail;
VAR_6 = (VAR_1[VAR_4] << 4) | (VAR_1[VAR_4 + 1] >> 4);
VAR_8 = ((VAR_1[VAR_4 + 1] & 0x0f) << 8) | VAR_1[VAR_4 + 2];
VAR_7 = (VAR_1[VAR_4 + 3] << 4) | (VAR_1[VAR_4 + 4] >> 4);
VAR_9 = ((VAR_1[VAR_4 + 4] & 0x0f) << 8) | VAR_1[VAR_4 + 5];
if (VAR_5 & 0x80)
VAR_15 = 1;
dprintf(NULL, "VAR_6=%d VAR_8=%d VAR_7=%d VAR_9=%d\n", VAR_6, VAR_8, VAR_7, VAR_9);
VAR_4 += 6;
break;
case 0x06:
if ((VAR_2 - VAR_4) < 4)
goto fail;
VAR_10 = AV_RB16(VAR_1 + VAR_4);
VAR_11 = AV_RB16(VAR_1 + VAR_4 + 2);
dprintf(NULL, "VAR_10=0x%04x VAR_11=0x%04x\n", VAR_10, VAR_11);
VAR_4 += 4;
break;
case 0x86:
if ((VAR_2 - VAR_4) < 8)
goto fail;
VAR_10 = AV_RB32(VAR_1 + VAR_4);
VAR_11 = AV_RB32(VAR_1 + VAR_4 + 4);
dprintf(NULL, "VAR_10=0x%04x VAR_11=0x%04x\n", VAR_10, VAR_11);
VAR_4 += 8;
break;
case 0x83:
if ((VAR_2 - VAR_4) < 768)
goto fail;
VAR_16 = VAR_1 + VAR_4;
VAR_4 += 768;
break;
case 0x84:
if ((VAR_2 - VAR_4) < 256)
goto fail;
for (VAR_18 = 0; VAR_18 < 256; VAR_18++)
alpha[VAR_18] = 0xFF - VAR_1[VAR_4+VAR_18];
VAR_4 += 256;
break;
case 0xff:
goto the_end;
default:
dprintf(NULL, "unrecognised subpicture command 0x%x\n", VAR_5);
goto the_end;
}
}
the_end:
if (VAR_10 >= 0) {
int VAR_20, VAR_21;
uint8_t *bitmap;
VAR_20 = VAR_8 - VAR_6 + 1;
if (VAR_20 < 0)
VAR_20 = 0;
VAR_21 = VAR_9 - VAR_7;
if (VAR_21 < 0)
VAR_21 = 0;
if (VAR_20 > 0 && VAR_21 > 0) {
if (VAR_0->rects != NULL) {
for (VAR_18 = 0; VAR_18 < VAR_0->num_rects; VAR_18++) {
av_freep(&VAR_0->rects[VAR_18]->pict.data[0]);
av_freep(&VAR_0->rects[VAR_18]->pict.data[1]);
av_freep(&VAR_0->rects[VAR_18]);
}
av_freep(&VAR_0->rects);
VAR_0->num_rects = 0;
}
bitmap = av_malloc(VAR_20 * VAR_21);
VAR_0->rects = av_mallocz(sizeof(*VAR_0->rects));
VAR_0->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
VAR_0->num_rects = 1;
VAR_0->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, VAR_20 * 2, VAR_20, (VAR_21 + 1) / 2,
VAR_1, VAR_10, VAR_2, VAR_15);
decode_rle(bitmap + VAR_20, VAR_20 * 2, VAR_20, VAR_21 / 2,
VAR_1, VAR_11, VAR_2, VAR_15);
if (VAR_15) {
if (VAR_16 == 0)
goto fail;
VAR_0->rects[0]->pict.data[1] = av_malloc(256 * 4);
VAR_0->rects[0]->nb_colors = 256;
yuv_a_to_rgba(VAR_16, alpha, (uint32_t*)VAR_0->rects[0]->pict.data[1], 256);
} else {
VAR_0->rects[0]->pict.data[1] = av_malloc(4 * 4);
VAR_0->rects[0]->nb_colors = 4;
guess_palette((uint32_t*)VAR_0->rects[0]->pict.data[1],
colormap, alpha, 0xffff00);
}
VAR_0->rects[0]->x = VAR_6;
VAR_0->rects[0]->y = VAR_7;
VAR_0->rects[0]->VAR_20 = VAR_20;
VAR_0->rects[0]->VAR_21 = VAR_21;
VAR_0->rects[0]->type = SUBTITLE_BITMAP;
VAR_0->rects[0]->pict.linesize[0] = VAR_20;
}
}
if (VAR_12 == VAR_3)
break;
VAR_3 = VAR_12;
}
if (VAR_0->num_rects > 0)
return VAR_19;
fail:
if (VAR_0->rects != NULL) {
for (VAR_18 = 0; VAR_18 < VAR_0->num_rects; VAR_18++) {
av_freep(&VAR_0->rects[VAR_18]->pict.data[0]);
av_freep(&VAR_0->rects[VAR_18]->pict.data[1]);
av_freep(&VAR_0->rects[VAR_18]);
}
av_freep(&VAR_0->rects);
VAR_0->num_rects = 0;
}
return -1;
}
| [
"static int FUNC_0(AVSubtitle *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"int VAR_13, VAR_14, VAR_15 = 0;",
"const uint8_t *VAR_16 = 0;",
"uint8_t colormap[4], alpha[256];",
"int VAR_17;",
"int VAR_18;",
"int VAR_19 = 0;",
"if (VAR_2 < 10)\nreturn -1;",
"VAR_0->rects = NULL;",
"VAR_0->num_rects = 0;",
"VAR_0->format = 0;",
"VAR_0->start_display_time = 0;",
"VAR_0->end_display_time = 0;",
"if (AV_RB16(VAR_1) == 0) {",
"VAR_13 = 1;",
"VAR_14 = 4;",
"VAR_3 = 6;",
"} else {",
"VAR_13 = 0;",
"VAR_14 = 2;",
"VAR_3 = 2;",
"}",
"VAR_3 = READ_OFFSET(VAR_1 + VAR_3);",
"while ((VAR_3 + 2 + VAR_14) < VAR_2) {",
"VAR_17 = AV_RB16(VAR_1 + VAR_3);",
"VAR_12 = READ_OFFSET(VAR_1 + VAR_3 + 2);",
"dprintf(NULL, \"VAR_3=0x%04x next=0x%04x VAR_17=%d\\n\",\nVAR_3, VAR_12, VAR_17);",
"VAR_4 = VAR_3 + 2 + VAR_14;",
"VAR_10 = -1;",
"VAR_11 = -1;",
"VAR_6 = VAR_7 = VAR_8 = VAR_9 = 0;",
"while (VAR_4 < VAR_2) {",
"VAR_5 = VAR_1[VAR_4++];",
"dprintf(NULL, \"VAR_5=%02x\\n\", VAR_5);",
"switch(VAR_5) {",
"case 0x00:\nVAR_19 = 1;",
"break;",
"case 0x01:\nVAR_0->start_display_time = (VAR_17 << 10) / 90;",
"break;",
"case 0x02:\nVAR_0->end_display_time = (VAR_17 << 10) / 90;",
"break;",
"case 0x03:\nif ((VAR_2 - VAR_4) < 2)\ngoto fail;",
"colormap[3] = VAR_1[VAR_4] >> 4;",
"colormap[2] = VAR_1[VAR_4] & 0x0f;",
"colormap[1] = VAR_1[VAR_4 + 1] >> 4;",
"colormap[0] = VAR_1[VAR_4 + 1] & 0x0f;",
"VAR_4 += 2;",
"break;",
"case 0x04:\nif ((VAR_2 - VAR_4) < 2)\ngoto fail;",
"alpha[3] = VAR_1[VAR_4] >> 4;",
"alpha[2] = VAR_1[VAR_4] & 0x0f;",
"alpha[1] = VAR_1[VAR_4 + 1] >> 4;",
"alpha[0] = VAR_1[VAR_4 + 1] & 0x0f;",
"VAR_4 += 2;",
"dprintf(NULL, \"alpha=%x%x%x%x\\n\", alpha[0],alpha[1],alpha[2],alpha[3]);",
"break;",
"case 0x05:\ncase 0x85:\nif ((VAR_2 - VAR_4) < 6)\ngoto fail;",
"VAR_6 = (VAR_1[VAR_4] << 4) | (VAR_1[VAR_4 + 1] >> 4);",
"VAR_8 = ((VAR_1[VAR_4 + 1] & 0x0f) << 8) | VAR_1[VAR_4 + 2];",
"VAR_7 = (VAR_1[VAR_4 + 3] << 4) | (VAR_1[VAR_4 + 4] >> 4);",
"VAR_9 = ((VAR_1[VAR_4 + 4] & 0x0f) << 8) | VAR_1[VAR_4 + 5];",
"if (VAR_5 & 0x80)\nVAR_15 = 1;",
"dprintf(NULL, \"VAR_6=%d VAR_8=%d VAR_7=%d VAR_9=%d\\n\", VAR_6, VAR_8, VAR_7, VAR_9);",
"VAR_4 += 6;",
"break;",
"case 0x06:\nif ((VAR_2 - VAR_4) < 4)\ngoto fail;",
"VAR_10 = AV_RB16(VAR_1 + VAR_4);",
"VAR_11 = AV_RB16(VAR_1 + VAR_4 + 2);",
"dprintf(NULL, \"VAR_10=0x%04x VAR_11=0x%04x\\n\", VAR_10, VAR_11);",
"VAR_4 += 4;",
"break;",
"case 0x86:\nif ((VAR_2 - VAR_4) < 8)\ngoto fail;",
"VAR_10 = AV_RB32(VAR_1 + VAR_4);",
"VAR_11 = AV_RB32(VAR_1 + VAR_4 + 4);",
"dprintf(NULL, \"VAR_10=0x%04x VAR_11=0x%04x\\n\", VAR_10, VAR_11);",
"VAR_4 += 8;",
"break;",
"case 0x83:\nif ((VAR_2 - VAR_4) < 768)\ngoto fail;",
"VAR_16 = VAR_1 + VAR_4;",
"VAR_4 += 768;",
"break;",
"case 0x84:\nif ((VAR_2 - VAR_4) < 256)\ngoto fail;",
"for (VAR_18 = 0; VAR_18 < 256; VAR_18++)",
"alpha[VAR_18] = 0xFF - VAR_1[VAR_4+VAR_18];",
"VAR_4 += 256;",
"break;",
"case 0xff:\ngoto the_end;",
"default:\ndprintf(NULL, \"unrecognised subpicture command 0x%x\\n\", VAR_5);",
"goto the_end;",
"}",
"}",
"the_end:\nif (VAR_10 >= 0) {",
"int VAR_20, VAR_21;",
"uint8_t *bitmap;",
"VAR_20 = VAR_8 - VAR_6 + 1;",
"if (VAR_20 < 0)\nVAR_20 = 0;",
"VAR_21 = VAR_9 - VAR_7;",
"if (VAR_21 < 0)\nVAR_21 = 0;",
"if (VAR_20 > 0 && VAR_21 > 0) {",
"if (VAR_0->rects != NULL) {",
"for (VAR_18 = 0; VAR_18 < VAR_0->num_rects; VAR_18++) {",
"av_freep(&VAR_0->rects[VAR_18]->pict.data[0]);",
"av_freep(&VAR_0->rects[VAR_18]->pict.data[1]);",
"av_freep(&VAR_0->rects[VAR_18]);",
"}",
"av_freep(&VAR_0->rects);",
"VAR_0->num_rects = 0;",
"}",
"bitmap = av_malloc(VAR_20 * VAR_21);",
"VAR_0->rects = av_mallocz(sizeof(*VAR_0->rects));",
"VAR_0->rects[0] = av_mallocz(sizeof(AVSubtitleRect));",
"VAR_0->num_rects = 1;",
"VAR_0->rects[0]->pict.data[0] = bitmap;",
"decode_rle(bitmap, VAR_20 * 2, VAR_20, (VAR_21 + 1) / 2,\nVAR_1, VAR_10, VAR_2, VAR_15);",
"decode_rle(bitmap + VAR_20, VAR_20 * 2, VAR_20, VAR_21 / 2,\nVAR_1, VAR_11, VAR_2, VAR_15);",
"if (VAR_15) {",
"if (VAR_16 == 0)\ngoto fail;",
"VAR_0->rects[0]->pict.data[1] = av_malloc(256 * 4);",
"VAR_0->rects[0]->nb_colors = 256;",
"yuv_a_to_rgba(VAR_16, alpha, (uint32_t*)VAR_0->rects[0]->pict.data[1], 256);",
"} else {",
"VAR_0->rects[0]->pict.data[1] = av_malloc(4 * 4);",
"VAR_0->rects[0]->nb_colors = 4;",
"guess_palette((uint32_t*)VAR_0->rects[0]->pict.data[1],\ncolormap, alpha, 0xffff00);",
"}",
"VAR_0->rects[0]->x = VAR_6;",
"VAR_0->rects[0]->y = VAR_7;",
"VAR_0->rects[0]->VAR_20 = VAR_20;",
"VAR_0->rects[0]->VAR_21 = VAR_21;",
"VAR_0->rects[0]->type = SUBTITLE_BITMAP;",
"VAR_0->rects[0]->pict.linesize[0] = VAR_20;",
"}",
"}",
"if (VAR_12 == VAR_3)\nbreak;",
"VAR_3 = VAR_12;",
"}",
"if (VAR_0->num_rects > 0)\nreturn VAR_19;",
"fail:\nif (VAR_0->rects != NULL) {",
"for (VAR_18 = 0; VAR_18 < VAR_0->num_rects; VAR_18++) {",
"av_freep(&VAR_0->rects[VAR_18]->pict.data[0]);",
"av_freep(&VAR_0->rects[VAR_18]->pict.data[1]);",
"av_freep(&VAR_0->rects[VAR_18]);",
"}",
"av_freep(&VAR_0->rects);",
"VAR_0->num_rects = 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,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
93
],
[
95
],
[
97,
101
],
[
103
],
[
105,
109
],
[
111
],
[
113,
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157,
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181,
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
219,
221
],
[
223
],
[
225
],
[
227
],
[
229,
233,
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247,
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
273
],
[
275,
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
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
]
] |
19,905 | int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)
{
VABufferID va_buffers[3];
unsigned int n_va_buffers = 0;
vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id);
va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;
if (vactx->iq_matrix_buf_id) {
vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);
va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;
}
if (vactx->bitplane_buf_id) {
vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id);
va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;
}
if (vaBeginPicture(vactx->display, vactx->context_id,
surface) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
vactx->slice_buf_ids,
vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)
return -1;
if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)
return -1;
} | true | FFmpeg | 2ee380aefbb92c89e8e9c7aa5846aa404919ec7c | int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)
{
VABufferID va_buffers[3];
unsigned int n_va_buffers = 0;
vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id);
va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;
if (vactx->iq_matrix_buf_id) {
vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);
va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;
}
if (vactx->bitplane_buf_id) {
vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id);
va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;
}
if (vaBeginPicture(vactx->display, vactx->context_id,
surface) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(vactx->display, vactx->context_id,
vactx->slice_buf_ids,
vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)
return -1;
if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)
return -1;
} | {
"code": [],
"line_no": []
} | int FUNC_0(struct vaapi_context *VAR_0, VASurfaceID VAR_1)
{
VABufferID va_buffers[3];
unsigned int VAR_2 = 0;
vaUnmapBuffer(VAR_0->display, VAR_0->pic_param_buf_id);
va_buffers[VAR_2++] = VAR_0->pic_param_buf_id;
if (VAR_0->iq_matrix_buf_id) {
vaUnmapBuffer(VAR_0->display, VAR_0->iq_matrix_buf_id);
va_buffers[VAR_2++] = VAR_0->iq_matrix_buf_id;
}
if (VAR_0->bitplane_buf_id) {
vaUnmapBuffer(VAR_0->display, VAR_0->bitplane_buf_id);
va_buffers[VAR_2++] = VAR_0->bitplane_buf_id;
}
if (vaBeginPicture(VAR_0->display, VAR_0->context_id,
VAR_1) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(VAR_0->display, VAR_0->context_id,
va_buffers, VAR_2) != VA_STATUS_SUCCESS)
return -1;
if (vaRenderPicture(VAR_0->display, VAR_0->context_id,
VAR_0->slice_buf_ids,
VAR_0->n_slice_buf_ids) != VA_STATUS_SUCCESS)
return -1;
if (vaEndPicture(VAR_0->display, VAR_0->context_id) != VA_STATUS_SUCCESS)
return -1;
} | [
"int FUNC_0(struct vaapi_context *VAR_0, VASurfaceID VAR_1)\n{",
"VABufferID va_buffers[3];",
"unsigned int VAR_2 = 0;",
"vaUnmapBuffer(VAR_0->display, VAR_0->pic_param_buf_id);",
"va_buffers[VAR_2++] = VAR_0->pic_param_buf_id;",
"if (VAR_0->iq_matrix_buf_id) {",
"vaUnmapBuffer(VAR_0->display, VAR_0->iq_matrix_buf_id);",
"va_buffers[VAR_2++] = VAR_0->iq_matrix_buf_id;",
"}",
"if (VAR_0->bitplane_buf_id) {",
"vaUnmapBuffer(VAR_0->display, VAR_0->bitplane_buf_id);",
"va_buffers[VAR_2++] = VAR_0->bitplane_buf_id;",
"}",
"if (vaBeginPicture(VAR_0->display, VAR_0->context_id,\nVAR_1) != VA_STATUS_SUCCESS)\nreturn -1;",
"if (vaRenderPicture(VAR_0->display, VAR_0->context_id,\nva_buffers, VAR_2) != VA_STATUS_SUCCESS)\nreturn -1;",
"if (vaRenderPicture(VAR_0->display, VAR_0->context_id,\nVAR_0->slice_buf_ids,\nVAR_0->n_slice_buf_ids) != VA_STATUS_SUCCESS)\nreturn -1;",
"if (vaEndPicture(VAR_0->display, VAR_0->context_id) != VA_STATUS_SUCCESS)\nreturn -1;",
"}"
] | [
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
]
] |
19,906 | static av_cold int xcbgrab_read_header(AVFormatContext *s)
{
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
char *host = s->filename[0] ? s->filename : NULL;
const char *opts = strchr(s->filename, '+');
if (opts) {
sscanf(opts, "%d,%d", &c->x, &c->y);
host = av_strdup(s->filename);
host[opts - s->filename] = '\0';
}
c->conn = xcb_connect(host, &screen_num);
if (opts)
av_free(host);
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? host : "default", ret);
return AVERROR(EIO);
}
setup = xcb_get_setup(c->conn);
c->screen = get_screen(setup, screen_num);
if (!c->screen) {
av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
screen_num);
xcbgrab_read_close(s);
return AVERROR(EIO);
}
ret = create_stream(s);
if (ret < 0) {
xcbgrab_read_close(s);
return ret;
}
#if CONFIG_LIBXCB_SHM
if ((c->has_shm = check_shm(c->conn)))
c->segment = xcb_generate_id(c->conn);
#endif
#if CONFIG_LIBXCB_XFIXES
if (c->draw_mouse) {
if (!(c->draw_mouse = check_xfixes(c->conn))) {
av_log(s, AV_LOG_WARNING,
"XFixes not available, cannot draw the mouse.\n");
}
if (c->bpp < 24) {
avpriv_report_missing_feature(s, "%d bits per pixel screen",
c->bpp);
c->draw_mouse = 0;
}
}
#endif
if (c->show_region)
setup_window(s);
return 0;
}
| true | FFmpeg | 5f5b78aca35d07c771f5c4c73a984be9fe04a0b8 | static av_cold int xcbgrab_read_header(AVFormatContext *s)
{
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
char *host = s->filename[0] ? s->filename : NULL;
const char *opts = strchr(s->filename, '+');
if (opts) {
sscanf(opts, "%d,%d", &c->x, &c->y);
host = av_strdup(s->filename);
host[opts - s->filename] = '\0';
}
c->conn = xcb_connect(host, &screen_num);
if (opts)
av_free(host);
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? host : "default", ret);
return AVERROR(EIO);
}
setup = xcb_get_setup(c->conn);
c->screen = get_screen(setup, screen_num);
if (!c->screen) {
av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
screen_num);
xcbgrab_read_close(s);
return AVERROR(EIO);
}
ret = create_stream(s);
if (ret < 0) {
xcbgrab_read_close(s);
return ret;
}
#if CONFIG_LIBXCB_SHM
if ((c->has_shm = check_shm(c->conn)))
c->segment = xcb_generate_id(c->conn);
#endif
#if CONFIG_LIBXCB_XFIXES
if (c->draw_mouse) {
if (!(c->draw_mouse = check_xfixes(c->conn))) {
av_log(s, AV_LOG_WARNING,
"XFixes not available, cannot draw the mouse.\n");
}
if (c->bpp < 24) {
avpriv_report_missing_feature(s, "%d bits per pixel screen",
c->bpp);
c->draw_mouse = 0;
}
}
#endif
if (c->show_region)
setup_window(s);
return 0;
}
| {
"code": [
" if (opts)",
" av_free(host);"
],
"line_no": [
33,
35
]
} | static av_cold int FUNC_0(AVFormatContext *s)
{
XCBGrabContext *c = s->priv_data;
int VAR_0, VAR_1;
const xcb_setup_t *VAR_2;
char *VAR_3 = s->filename[0] ? s->filename : NULL;
const char *VAR_4 = strchr(s->filename, '+');
if (VAR_4) {
sscanf(VAR_4, "%d,%d", &c->x, &c->y);
VAR_3 = av_strdup(s->filename);
VAR_3[VAR_4 - s->filename] = '\0';
}
c->conn = xcb_connect(VAR_3, &VAR_0);
if (VAR_4)
av_free(VAR_3);
if ((VAR_1 = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? VAR_3 : "default", VAR_1);
return AVERROR(EIO);
}
VAR_2 = xcb_get_setup(c->conn);
c->screen = get_screen(VAR_2, VAR_0);
if (!c->screen) {
av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
VAR_0);
xcbgrab_read_close(s);
return AVERROR(EIO);
}
VAR_1 = create_stream(s);
if (VAR_1 < 0) {
xcbgrab_read_close(s);
return VAR_1;
}
#if CONFIG_LIBXCB_SHM
if ((c->has_shm = check_shm(c->conn)))
c->segment = xcb_generate_id(c->conn);
#endif
#if CONFIG_LIBXCB_XFIXES
if (c->draw_mouse) {
if (!(c->draw_mouse = check_xfixes(c->conn))) {
av_log(s, AV_LOG_WARNING,
"XFixes not available, cannot draw the mouse.\n");
}
if (c->bpp < 24) {
avpriv_report_missing_feature(s, "%d bits per pixel screen",
c->bpp);
c->draw_mouse = 0;
}
}
#endif
if (c->show_region)
setup_window(s);
return 0;
}
| [
"static av_cold int FUNC_0(AVFormatContext *s)\n{",
"XCBGrabContext *c = s->priv_data;",
"int VAR_0, VAR_1;",
"const xcb_setup_t *VAR_2;",
"char *VAR_3 = s->filename[0] ? s->filename : NULL;",
"const char *VAR_4 = strchr(s->filename, '+');",
"if (VAR_4) {",
"sscanf(VAR_4, \"%d,%d\", &c->x, &c->y);",
"VAR_3 = av_strdup(s->filename);",
"VAR_3[VAR_4 - s->filename] = '\\0';",
"}",
"c->conn = xcb_connect(VAR_3, &VAR_0);",
"if (VAR_4)\nav_free(VAR_3);",
"if ((VAR_1 = xcb_connection_has_error(c->conn))) {",
"av_log(s, AV_LOG_ERROR, \"Cannot open display %s, error %d.\\n\",\ns->filename[0] ? VAR_3 : \"default\", VAR_1);",
"return AVERROR(EIO);",
"}",
"VAR_2 = xcb_get_setup(c->conn);",
"c->screen = get_screen(VAR_2, VAR_0);",
"if (!c->screen) {",
"av_log(s, AV_LOG_ERROR, \"The screen %d does not exist.\\n\",\nVAR_0);",
"xcbgrab_read_close(s);",
"return AVERROR(EIO);",
"}",
"VAR_1 = create_stream(s);",
"if (VAR_1 < 0) {",
"xcbgrab_read_close(s);",
"return VAR_1;",
"}",
"#if CONFIG_LIBXCB_SHM\nif ((c->has_shm = check_shm(c->conn)))\nc->segment = xcb_generate_id(c->conn);",
"#endif\n#if CONFIG_LIBXCB_XFIXES\nif (c->draw_mouse) {",
"if (!(c->draw_mouse = check_xfixes(c->conn))) {",
"av_log(s, AV_LOG_WARNING,\n\"XFixes not available, cannot draw the mouse.\\n\");",
"}",
"if (c->bpp < 24) {",
"avpriv_report_missing_feature(s, \"%d bits per pixel screen\",\nc->bpp);",
"c->draw_mouse = 0;",
"}",
"}",
"#endif\nif (c->show_region)\nsetup_window(s);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33,
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85,
87
],
[
89,
93,
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117,
121,
123
],
[
127
],
[
129
]
] |
19,909 | static int parse_pixel_format(AVCodecContext *avctx)
{
DDSContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
char buf[32];
uint32_t flags, fourcc, gimp_tag;
enum DDSDXGIFormat dxgi;
int size, bpp, r, g, b, a;
int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map, array;
/* Alternative DDS implementations use reserved1 as custom header. */
bytestream2_skip(gbc, 4 * 3);
gimp_tag = bytestream2_get_le32(gbc);
alpha_exponent = gimp_tag == MKTAG('A', 'E', 'X', 'P');
ycocg_classic = gimp_tag == MKTAG('Y', 'C', 'G', '1');
ycocg_scaled = gimp_tag == MKTAG('Y', 'C', 'G', '2');
bytestream2_skip(gbc, 4 * 7);
/* Now the real DDPF starts. */
size = bytestream2_get_le32(gbc);
if (size != 32) {
av_log(avctx, AV_LOG_ERROR, "Invalid pixel format header %d.\n", size);
return AVERROR_INVALIDDATA;
flags = bytestream2_get_le32(gbc);
ctx->compressed = flags & DDPF_FOURCC;
ctx->paletted = flags & DDPF_PALETTE;
normal_map = flags & DDPF_NORMALMAP;
fourcc = bytestream2_get_le32(gbc);
bpp = bytestream2_get_le32(gbc); // rgbbitcount
r = bytestream2_get_le32(gbc); // rbitmask
g = bytestream2_get_le32(gbc); // gbitmask
b = bytestream2_get_le32(gbc); // bbitmask
a = bytestream2_get_le32(gbc); // abitmask
bytestream2_skip(gbc, 4); // caps
bytestream2_skip(gbc, 4); // caps2
bytestream2_skip(gbc, 4); // caps3
bytestream2_skip(gbc, 4); // caps4
bytestream2_skip(gbc, 4); // reserved2
av_get_codec_tag_string(buf, sizeof(buf), fourcc);
av_log(avctx, AV_LOG_VERBOSE, "fourcc %s bpp %d "
"r 0x%x g 0x%x b 0x%x a 0x%x\n", buf, bpp, r, g, b, a);
if (gimp_tag) {
av_get_codec_tag_string(buf, sizeof(buf), gimp_tag);
av_log(avctx, AV_LOG_VERBOSE, "and GIMP-DDS tag %s\n", buf);
if (ctx->compressed)
avctx->pix_fmt = AV_PIX_FMT_RGBA;
if (ctx->compressed) {
switch (fourcc) {
case MKTAG('D', 'X', 'T', '1'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case MKTAG('D', 'X', 'T', '2'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt2_block;
break;
case MKTAG('D', 'X', 'T', '3'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case MKTAG('D', 'X', 'T', '4'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt4_block;
break;
case MKTAG('D', 'X', 'T', '5'):
ctx->tex_ratio = 16;
if (ycocg_scaled)
ctx->tex_funct = ctx->texdsp.dxt5ys_block;
else if (ycocg_classic)
ctx->tex_funct = ctx->texdsp.dxt5y_block;
else
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case MKTAG('R', 'X', 'G', 'B'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
/* This format may be considered as a normal map,
* but it is handled differently in a separate postproc. */
ctx->postproc = DDS_SWIZZLE_RXGB;
normal_map = 0;
break;
case MKTAG('A', 'T', 'I', '1'):
case MKTAG('B', 'C', '4', 'U'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case MKTAG('B', 'C', '4', 'S'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case MKTAG('A', 'T', 'I', '2'):
/* RGT2 variant with swapped R and G (3Dc)*/
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxn3dc_block;
break;
case MKTAG('B', 'C', '5', 'U'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case MKTAG('B', 'C', '5', 'S'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
case MKTAG('U', 'Y', 'V', 'Y'):
ctx->compressed = 0;
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
break;
case MKTAG('Y', 'U', 'Y', '2'):
ctx->compressed = 0;
avctx->pix_fmt = AV_PIX_FMT_YUYV422;
break;
case MKTAG('P', '8', ' ', ' '):
/* ATI Palette8, same as normal palette */
ctx->compressed = 0;
ctx->paletted = 1;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case MKTAG('D', 'X', '1', '0'):
/* DirectX 10 extra header */
dxgi = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4); // resourceDimension
bytestream2_skip(gbc, 4); // miscFlag
array = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4); // miscFlag2
if (array != 0)
av_log(avctx, AV_LOG_VERBOSE,
"Found array of size %d (ignored).\n", array);
/* Only BC[1-5] are actually compressed. */
ctx->compressed = (dxgi >= 70) && (dxgi <= 84);
av_log(avctx, AV_LOG_VERBOSE, "DXGI format %d.\n", dxgi);
switch (dxgi) {
/* RGB types. */
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
avctx->pix_fmt = AV_PIX_FMT_BGRA64;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
avctx->pix_fmt = AV_PIX_FMT_BGRA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGBA;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGBA; // opaque
break;
case DXGI_FORMAT_B5G6R5_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGB565LE;
break;
/* Texture types. */
case DXGI_FORMAT_BC1_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case DXGI_FORMAT_BC2_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case DXGI_FORMAT_BC3_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case DXGI_FORMAT_BC4_SNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case DXGI_FORMAT_BC5_SNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported DXGI format %d.\n", dxgi);
return AVERROR_INVALIDDATA;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported %s fourcc.\n", buf);
return AVERROR_INVALIDDATA;
} else if (ctx->paletted) {
if (bpp == 8) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported palette bpp %d.\n", bpp);
return AVERROR_INVALIDDATA;
} else {
/* 8 bpp */
if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
/* 16 bpp */
else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00)
avctx->pix_fmt = AV_PIX_FMT_YA8;
else if (bpp == 16 && r == 0xffff && g == 0 && b == 0 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
else if (bpp == 16 && r == 0xf800 && g == 0x7e0 && b == 0x1f && a == 0)
avctx->pix_fmt = AV_PIX_FMT_RGB565LE;
/* 24 bpp */
else if (bpp == 24 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
avctx->pix_fmt = AV_PIX_FMT_BGR24;
/* 32 bpp */
else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
avctx->pix_fmt = AV_PIX_FMT_BGRA; // opaque
else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_RGBA; // opaque
else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0xff000000)
avctx->pix_fmt = AV_PIX_FMT_BGRA;
else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0xff000000)
avctx->pix_fmt = AV_PIX_FMT_RGBA;
/* give up */
else {
av_log(avctx, AV_LOG_ERROR, "Unknown pixel format "
"[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp, r, g, b, a);
return AVERROR_INVALIDDATA;
/* Set any remaining post-proc that should happen before frame is ready. */
if (alpha_exponent)
ctx->postproc = DDS_ALPHA_EXP;
else if (normal_map)
ctx->postproc = DDS_NORMAL_MAP;
else if (ycocg_classic && !ctx->compressed)
ctx->postproc = DDS_RAW_YCOCG;
else if (avctx->pix_fmt == AV_PIX_FMT_YA8)
ctx->postproc = DDS_SWAP_ALPHA;
/* ATI/NVidia variants sometimes add swizzling in bpp. */
switch (bpp) {
case MKTAG('A', '2', 'X', 'Y'):
ctx->postproc = DDS_SWIZZLE_A2XY;
break;
case MKTAG('x', 'G', 'B', 'R'):
ctx->postproc = DDS_SWIZZLE_XGBR;
break;
case MKTAG('x', 'R', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_XRBG;
break;
case MKTAG('R', 'B', 'x', 'G'):
ctx->postproc = DDS_SWIZZLE_RBXG;
break;
case MKTAG('R', 'G', 'x', 'B'):
ctx->postproc = DDS_SWIZZLE_RGXB;
break;
case MKTAG('R', 'x', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_RXBG;
break;
case MKTAG('x', 'G', 'x', 'R'):
ctx->postproc = DDS_SWIZZLE_XGXR;
break;
case MKTAG('A', '2', 'D', '5'):
ctx->postproc = DDS_NORMAL_MAP;
break;
return 0; | true | FFmpeg | 0a8bff788b0a9f96b863f0e836a235cb1d223f55 | static int parse_pixel_format(AVCodecContext *avctx)
{
DDSContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
char buf[32];
uint32_t flags, fourcc, gimp_tag;
enum DDSDXGIFormat dxgi;
int size, bpp, r, g, b, a;
int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map, array;
bytestream2_skip(gbc, 4 * 3);
gimp_tag = bytestream2_get_le32(gbc);
alpha_exponent = gimp_tag == MKTAG('A', 'E', 'X', 'P');
ycocg_classic = gimp_tag == MKTAG('Y', 'C', 'G', '1');
ycocg_scaled = gimp_tag == MKTAG('Y', 'C', 'G', '2');
bytestream2_skip(gbc, 4 * 7);
size = bytestream2_get_le32(gbc);
if (size != 32) {
av_log(avctx, AV_LOG_ERROR, "Invalid pixel format header %d.\n", size);
return AVERROR_INVALIDDATA;
flags = bytestream2_get_le32(gbc);
ctx->compressed = flags & DDPF_FOURCC;
ctx->paletted = flags & DDPF_PALETTE;
normal_map = flags & DDPF_NORMALMAP;
fourcc = bytestream2_get_le32(gbc);
bpp = bytestream2_get_le32(gbc);
r = bytestream2_get_le32(gbc);
g = bytestream2_get_le32(gbc);
b = bytestream2_get_le32(gbc);
a = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4);
bytestream2_skip(gbc, 4); 2
bytestream2_skip(gbc, 4); 3
bytestream2_skip(gbc, 4); 4
bytestream2_skip(gbc, 4);
av_get_codec_tag_string(buf, sizeof(buf), fourcc);
av_log(avctx, AV_LOG_VERBOSE, "fourcc %s bpp %d "
"r 0x%x g 0x%x b 0x%x a 0x%x\n", buf, bpp, r, g, b, a);
if (gimp_tag) {
av_get_codec_tag_string(buf, sizeof(buf), gimp_tag);
av_log(avctx, AV_LOG_VERBOSE, "and GIMP-DDS tag %s\n", buf);
if (ctx->compressed)
avctx->pix_fmt = AV_PIX_FMT_RGBA;
if (ctx->compressed) {
switch (fourcc) {
case MKTAG('D', 'X', 'T', '1'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case MKTAG('D', 'X', 'T', '2'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt2_block;
break;
case MKTAG('D', 'X', 'T', '3'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case MKTAG('D', 'X', 'T', '4'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt4_block;
break;
case MKTAG('D', 'X', 'T', '5'):
ctx->tex_ratio = 16;
if (ycocg_scaled)
ctx->tex_funct = ctx->texdsp.dxt5ys_block;
else if (ycocg_classic)
ctx->tex_funct = ctx->texdsp.dxt5y_block;
else
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case MKTAG('R', 'X', 'G', 'B'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
ctx->postproc = DDS_SWIZZLE_RXGB;
normal_map = 0;
break;
case MKTAG('A', 'T', 'I', '1'):
case MKTAG('B', 'C', '4', 'U'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case MKTAG('B', 'C', '4', 'S'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case MKTAG('A', 'T', 'I', '2'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxn3dc_block;
break;
case MKTAG('B', 'C', '5', 'U'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case MKTAG('B', 'C', '5', 'S'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
case MKTAG('U', 'Y', 'V', 'Y'):
ctx->compressed = 0;
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
break;
case MKTAG('Y', 'U', 'Y', '2'):
ctx->compressed = 0;
avctx->pix_fmt = AV_PIX_FMT_YUYV422;
break;
case MKTAG('P', '8', ' ', ' '):
ctx->compressed = 0;
ctx->paletted = 1;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case MKTAG('D', 'X', '1', '0'):
dxgi = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4);
bytestream2_skip(gbc, 4);
array = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4); 2
if (array != 0)
av_log(avctx, AV_LOG_VERBOSE,
"Found array of size %d (ignored).\n", array);
ctx->compressed = (dxgi >= 70) && (dxgi <= 84);
av_log(avctx, AV_LOG_VERBOSE, "DXGI format %d.\n", dxgi);
switch (dxgi) {
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
avctx->pix_fmt = AV_PIX_FMT_BGRA64;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
avctx->pix_fmt = AV_PIX_FMT_BGRA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGBA;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGBA;
break;
case DXGI_FORMAT_B5G6R5_UNORM:
avctx->pix_fmt = AV_PIX_FMT_RGB565LE;
break;
case DXGI_FORMAT_BC1_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case DXGI_FORMAT_BC2_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case DXGI_FORMAT_BC3_UNORM_SRGB:
avctx->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case DXGI_FORMAT_BC4_SNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case DXGI_FORMAT_BC5_SNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported DXGI format %d.\n", dxgi);
return AVERROR_INVALIDDATA;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported %s fourcc.\n", buf);
return AVERROR_INVALIDDATA;
} else if (ctx->paletted) {
if (bpp == 8) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported palette bpp %d.\n", bpp);
return AVERROR_INVALIDDATA;
} else {
if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00)
avctx->pix_fmt = AV_PIX_FMT_YA8;
else if (bpp == 16 && r == 0xffff && g == 0 && b == 0 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
else if (bpp == 16 && r == 0xf800 && g == 0x7e0 && b == 0x1f && a == 0)
avctx->pix_fmt = AV_PIX_FMT_RGB565LE;
else if (bpp == 24 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
avctx->pix_fmt = AV_PIX_FMT_BGR24;
else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
avctx->pix_fmt = AV_PIX_FMT_BGRA;
else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0)
avctx->pix_fmt = AV_PIX_FMT_RGBA;
else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0xff000000)
avctx->pix_fmt = AV_PIX_FMT_BGRA;
else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0xff000000)
avctx->pix_fmt = AV_PIX_FMT_RGBA;
else {
av_log(avctx, AV_LOG_ERROR, "Unknown pixel format "
"[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp, r, g, b, a);
return AVERROR_INVALIDDATA;
if (alpha_exponent)
ctx->postproc = DDS_ALPHA_EXP;
else if (normal_map)
ctx->postproc = DDS_NORMAL_MAP;
else if (ycocg_classic && !ctx->compressed)
ctx->postproc = DDS_RAW_YCOCG;
else if (avctx->pix_fmt == AV_PIX_FMT_YA8)
ctx->postproc = DDS_SWAP_ALPHA;
switch (bpp) {
case MKTAG('A', '2', 'X', 'Y'):
ctx->postproc = DDS_SWIZZLE_A2XY;
break;
case MKTAG('x', 'G', 'B', 'R'):
ctx->postproc = DDS_SWIZZLE_XGBR;
break;
case MKTAG('x', 'R', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_XRBG;
break;
case MKTAG('R', 'B', 'x', 'G'):
ctx->postproc = DDS_SWIZZLE_RBXG;
break;
case MKTAG('R', 'G', 'x', 'B'):
ctx->postproc = DDS_SWIZZLE_RGXB;
break;
case MKTAG('R', 'x', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_RXBG;
break;
case MKTAG('x', 'G', 'x', 'R'):
ctx->postproc = DDS_SWIZZLE_XGXR;
break;
case MKTAG('A', '2', 'D', '5'):
ctx->postproc = DDS_NORMAL_MAP;
break;
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
DDSContext *ctx = VAR_0->priv_data;
GetByteContext *gbc = &ctx->gbc;
char VAR_1[32];
uint32_t flags, fourcc, gimp_tag;
enum DDSDXGIFormat VAR_2;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
bytestream2_skip(gbc, 4 * 3);
gimp_tag = bytestream2_get_le32(gbc);
VAR_9 = gimp_tag == MKTAG('A', 'E', 'X', 'P');
VAR_10 = gimp_tag == MKTAG('Y', 'C', 'G', '1');
VAR_11 = gimp_tag == MKTAG('Y', 'C', 'G', '2');
bytestream2_skip(gbc, 4 * 7);
VAR_3 = bytestream2_get_le32(gbc);
if (VAR_3 != 32) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid pixel format header %d.\n", VAR_3);
return AVERROR_INVALIDDATA;
flags = bytestream2_get_le32(gbc);
ctx->compressed = flags & DDPF_FOURCC;
ctx->paletted = flags & DDPF_PALETTE;
VAR_12 = flags & DDPF_NORMALMAP;
fourcc = bytestream2_get_le32(gbc);
VAR_4 = bytestream2_get_le32(gbc);
VAR_5 = bytestream2_get_le32(gbc);
VAR_6 = bytestream2_get_le32(gbc);
VAR_7 = bytestream2_get_le32(gbc);
VAR_8 = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4);
bytestream2_skip(gbc, 4); 2
bytestream2_skip(gbc, 4); 3
bytestream2_skip(gbc, 4); 4
bytestream2_skip(gbc, 4);
av_get_codec_tag_string(VAR_1, sizeof(VAR_1), fourcc);
av_log(VAR_0, AV_LOG_VERBOSE, "fourcc %s VAR_4 %d "
"VAR_5 0x%x VAR_6 0x%x VAR_7 0x%x VAR_8 0x%x\n", VAR_1, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);
if (gimp_tag) {
av_get_codec_tag_string(VAR_1, sizeof(VAR_1), gimp_tag);
av_log(VAR_0, AV_LOG_VERBOSE, "and GIMP-DDS tag %s\n", VAR_1);
if (ctx->compressed)
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
if (ctx->compressed) {
switch (fourcc) {
case MKTAG('D', 'X', 'T', '1'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case MKTAG('D', 'X', 'T', '2'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt2_block;
break;
case MKTAG('D', 'X', 'T', '3'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case MKTAG('D', 'X', 'T', '4'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt4_block;
break;
case MKTAG('D', 'X', 'T', '5'):
ctx->tex_ratio = 16;
if (VAR_11)
ctx->tex_funct = ctx->texdsp.dxt5ys_block;
else if (VAR_10)
ctx->tex_funct = ctx->texdsp.dxt5y_block;
else
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case MKTAG('R', 'X', 'G', 'B'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
ctx->postproc = DDS_SWIZZLE_RXGB;
VAR_12 = 0;
break;
case MKTAG('A', 'T', 'I', '1'):
case MKTAG('B', 'C', '4', 'U'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case MKTAG('B', 'C', '4', 'S'):
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case MKTAG('A', 'T', 'I', '2'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxn3dc_block;
break;
case MKTAG('B', 'C', '5', 'U'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case MKTAG('B', 'C', '5', 'S'):
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
case MKTAG('U', 'Y', 'V', 'Y'):
ctx->compressed = 0;
VAR_0->pix_fmt = AV_PIX_FMT_UYVY422;
break;
case MKTAG('Y', 'U', 'Y', '2'):
ctx->compressed = 0;
VAR_0->pix_fmt = AV_PIX_FMT_YUYV422;
break;
case MKTAG('P', '8', ' ', ' '):
ctx->compressed = 0;
ctx->paletted = 1;
VAR_0->pix_fmt = AV_PIX_FMT_PAL8;
break;
case MKTAG('D', 'X', '1', '0'):
VAR_2 = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4);
bytestream2_skip(gbc, 4);
VAR_13 = bytestream2_get_le32(gbc);
bytestream2_skip(gbc, 4); 2
if (VAR_13 != 0)
av_log(VAR_0, AV_LOG_VERBOSE,
"Found VAR_13 of VAR_3 %d (ignored).\n", VAR_13);
ctx->compressed = (VAR_2 >= 70) && (VAR_2 <= 84);
av_log(VAR_0, AV_LOG_VERBOSE, "DXGI format %d.\n", VAR_2);
switch (VAR_2) {
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
VAR_0->pix_fmt = AV_PIX_FMT_BGRA64;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
VAR_0->pix_fmt = AV_PIX_FMT_BGRA;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM:
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
break;
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM:
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
break;
case DXGI_FORMAT_B5G6R5_UNORM:
VAR_0->pix_fmt = AV_PIX_FMT_RGB565LE;
break;
case DXGI_FORMAT_BC1_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.dxt1a_block;
break;
case DXGI_FORMAT_BC2_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt3_block;
break;
case DXGI_FORMAT_BC3_UNORM_SRGB:
VAR_0->colorspace = AVCOL_SPC_RGB;
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.dxt5_block;
break;
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1u_block;
break;
case DXGI_FORMAT_BC4_SNORM:
ctx->tex_ratio = 8;
ctx->tex_funct = ctx->texdsp.rgtc1s_block;
break;
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2u_block;
break;
case DXGI_FORMAT_BC5_SNORM:
ctx->tex_ratio = 16;
ctx->tex_funct = ctx->texdsp.rgtc2s_block;
break;
default:
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported DXGI format %d.\n", VAR_2);
return AVERROR_INVALIDDATA;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unsupported %s fourcc.\n", VAR_1);
return AVERROR_INVALIDDATA;
} else if (ctx->paletted) {
if (VAR_4 == 8) {
VAR_0->pix_fmt = AV_PIX_FMT_PAL8;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported palette VAR_4 %d.\n", VAR_4);
return AVERROR_INVALIDDATA;
} else {
if (VAR_4 == 8 && VAR_5 == 0xff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_GRAY8;
else if (VAR_4 == 16 && VAR_5 == 0xff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0xff00)
VAR_0->pix_fmt = AV_PIX_FMT_YA8;
else if (VAR_4 == 16 && VAR_5 == 0xffff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_GRAY16LE;
else if (VAR_4 == 16 && VAR_5 == 0xf800 && VAR_6 == 0x7e0 && VAR_7 == 0x1f && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_RGB565LE;
else if (VAR_4 == 24 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_BGR24;
else if (VAR_4 == 32 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_BGRA;
else if (VAR_4 == 32 && VAR_5 == 0xff && VAR_6 == 0xff00 && VAR_7 == 0xff0000 && VAR_8 == 0)
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
else if (VAR_4 == 32 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0xff000000)
VAR_0->pix_fmt = AV_PIX_FMT_BGRA;
else if (VAR_4 == 32 && VAR_5 == 0xff && VAR_6 == 0xff00 && VAR_7 == 0xff0000 && VAR_8 == 0xff000000)
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
else {
av_log(VAR_0, AV_LOG_ERROR, "Unknown pixel format "
"[VAR_4 %d VAR_5 0x%x VAR_6 0x%x VAR_7 0x%x VAR_8 0x%x].\n", VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);
return AVERROR_INVALIDDATA;
if (VAR_9)
ctx->postproc = DDS_ALPHA_EXP;
else if (VAR_12)
ctx->postproc = DDS_NORMAL_MAP;
else if (VAR_10 && !ctx->compressed)
ctx->postproc = DDS_RAW_YCOCG;
else if (VAR_0->pix_fmt == AV_PIX_FMT_YA8)
ctx->postproc = DDS_SWAP_ALPHA;
switch (VAR_4) {
case MKTAG('A', '2', 'X', 'Y'):
ctx->postproc = DDS_SWIZZLE_A2XY;
break;
case MKTAG('x', 'G', 'B', 'R'):
ctx->postproc = DDS_SWIZZLE_XGBR;
break;
case MKTAG('x', 'R', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_XRBG;
break;
case MKTAG('R', 'B', 'x', 'G'):
ctx->postproc = DDS_SWIZZLE_RBXG;
break;
case MKTAG('R', 'G', 'x', 'B'):
ctx->postproc = DDS_SWIZZLE_RGXB;
break;
case MKTAG('R', 'x', 'B', 'G'):
ctx->postproc = DDS_SWIZZLE_RXBG;
break;
case MKTAG('x', 'G', 'x', 'R'):
ctx->postproc = DDS_SWIZZLE_XGXR;
break;
case MKTAG('A', '2', 'D', '5'):
ctx->postproc = DDS_NORMAL_MAP;
break;
return 0; | [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"DDSContext *ctx = VAR_0->priv_data;",
"GetByteContext *gbc = &ctx->gbc;",
"char VAR_1[32];",
"uint32_t flags, fourcc, gimp_tag;",
"enum DDSDXGIFormat VAR_2;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"bytestream2_skip(gbc, 4 * 3);",
"gimp_tag = bytestream2_get_le32(gbc);",
"VAR_9 = gimp_tag == MKTAG('A', 'E', 'X', 'P');",
"VAR_10 = gimp_tag == MKTAG('Y', 'C', 'G', '1');",
"VAR_11 = gimp_tag == MKTAG('Y', 'C', 'G', '2');",
"bytestream2_skip(gbc, 4 * 7);",
"VAR_3 = bytestream2_get_le32(gbc);",
"if (VAR_3 != 32) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid pixel format header %d.\\n\", VAR_3);",
"return AVERROR_INVALIDDATA;",
"flags = bytestream2_get_le32(gbc);",
"ctx->compressed = flags & DDPF_FOURCC;",
"ctx->paletted = flags & DDPF_PALETTE;",
"VAR_12 = flags & DDPF_NORMALMAP;",
"fourcc = bytestream2_get_le32(gbc);",
"VAR_4 = bytestream2_get_le32(gbc);",
"VAR_5 = bytestream2_get_le32(gbc);",
"VAR_6 = bytestream2_get_le32(gbc);",
"VAR_7 = bytestream2_get_le32(gbc);",
"VAR_8 = bytestream2_get_le32(gbc);",
"bytestream2_skip(gbc, 4);",
"bytestream2_skip(gbc, 4); 2",
"bytestream2_skip(gbc, 4); 3",
"bytestream2_skip(gbc, 4); 4",
"bytestream2_skip(gbc, 4);",
"av_get_codec_tag_string(VAR_1, sizeof(VAR_1), fourcc);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"fourcc %s VAR_4 %d \"\n\"VAR_5 0x%x VAR_6 0x%x VAR_7 0x%x VAR_8 0x%x\\n\", VAR_1, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);",
"if (gimp_tag) {",
"av_get_codec_tag_string(VAR_1, sizeof(VAR_1), gimp_tag);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"and GIMP-DDS tag %s\\n\", VAR_1);",
"if (ctx->compressed)\nVAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"if (ctx->compressed) {",
"switch (fourcc) {",
"case MKTAG('D', 'X', 'T', '1'):\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.dxt1a_block;",
"break;",
"case MKTAG('D', 'X', 'T', '2'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt2_block;",
"break;",
"case MKTAG('D', 'X', 'T', '3'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt3_block;",
"break;",
"case MKTAG('D', 'X', 'T', '4'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt4_block;",
"break;",
"case MKTAG('D', 'X', 'T', '5'):\nctx->tex_ratio = 16;",
"if (VAR_11)\nctx->tex_funct = ctx->texdsp.dxt5ys_block;",
"else if (VAR_10)\nctx->tex_funct = ctx->texdsp.dxt5y_block;",
"else\nctx->tex_funct = ctx->texdsp.dxt5_block;",
"break;",
"case MKTAG('R', 'X', 'G', 'B'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt5_block;",
"ctx->postproc = DDS_SWIZZLE_RXGB;",
"VAR_12 = 0;",
"break;",
"case MKTAG('A', 'T', 'I', '1'):\ncase MKTAG('B', 'C', '4', 'U'):\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.rgtc1u_block;",
"break;",
"case MKTAG('B', 'C', '4', 'S'):\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.rgtc1s_block;",
"break;",
"case MKTAG('A', 'T', 'I', '2'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxn3dc_block;",
"break;",
"case MKTAG('B', 'C', '5', 'U'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.rgtc2u_block;",
"break;",
"case MKTAG('B', 'C', '5', 'S'):\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.rgtc2s_block;",
"break;",
"case MKTAG('U', 'Y', 'V', 'Y'):\nctx->compressed = 0;",
"VAR_0->pix_fmt = AV_PIX_FMT_UYVY422;",
"break;",
"case MKTAG('Y', 'U', 'Y', '2'):\nctx->compressed = 0;",
"VAR_0->pix_fmt = AV_PIX_FMT_YUYV422;",
"break;",
"case MKTAG('P', '8', ' ', ' '):\nctx->compressed = 0;",
"ctx->paletted = 1;",
"VAR_0->pix_fmt = AV_PIX_FMT_PAL8;",
"break;",
"case MKTAG('D', 'X', '1', '0'):\nVAR_2 = bytestream2_get_le32(gbc);",
"bytestream2_skip(gbc, 4);",
"bytestream2_skip(gbc, 4);",
"VAR_13 = bytestream2_get_le32(gbc);",
"bytestream2_skip(gbc, 4); 2",
"if (VAR_13 != 0)\nav_log(VAR_0, AV_LOG_VERBOSE,\n\"Found VAR_13 of VAR_3 %d (ignored).\\n\", VAR_13);",
"ctx->compressed = (VAR_2 >= 70) && (VAR_2 <= 84);",
"av_log(VAR_0, AV_LOG_VERBOSE, \"DXGI format %d.\\n\", VAR_2);",
"switch (VAR_2) {",
"case DXGI_FORMAT_R16G16B16A16_TYPELESS:\ncase DXGI_FORMAT_R16G16B16A16_FLOAT:\ncase DXGI_FORMAT_R16G16B16A16_UNORM:\ncase DXGI_FORMAT_R16G16B16A16_UINT:\ncase DXGI_FORMAT_R16G16B16A16_SNORM:\ncase DXGI_FORMAT_R16G16B16A16_SINT:\nVAR_0->pix_fmt = AV_PIX_FMT_BGRA64;",
"break;",
"case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_R8G8B8A8_TYPELESS:\ncase DXGI_FORMAT_R8G8B8A8_UNORM:\ncase DXGI_FORMAT_R8G8B8A8_UINT:\ncase DXGI_FORMAT_R8G8B8A8_SNORM:\ncase DXGI_FORMAT_R8G8B8A8_SINT:\nVAR_0->pix_fmt = AV_PIX_FMT_BGRA;",
"break;",
"case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_B8G8R8A8_TYPELESS:\ncase DXGI_FORMAT_B8G8R8A8_UNORM:\nVAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"break;",
"case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_B8G8R8X8_TYPELESS:\ncase DXGI_FORMAT_B8G8R8X8_UNORM:\nVAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"break;",
"case DXGI_FORMAT_B5G6R5_UNORM:\nVAR_0->pix_fmt = AV_PIX_FMT_RGB565LE;",
"break;",
"case DXGI_FORMAT_BC1_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_BC1_TYPELESS:\ncase DXGI_FORMAT_BC1_UNORM:\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.dxt1a_block;",
"break;",
"case DXGI_FORMAT_BC2_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_BC2_TYPELESS:\ncase DXGI_FORMAT_BC2_UNORM:\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt3_block;",
"break;",
"case DXGI_FORMAT_BC3_UNORM_SRGB:\nVAR_0->colorspace = AVCOL_SPC_RGB;",
"case DXGI_FORMAT_BC3_TYPELESS:\ncase DXGI_FORMAT_BC3_UNORM:\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.dxt5_block;",
"break;",
"case DXGI_FORMAT_BC4_TYPELESS:\ncase DXGI_FORMAT_BC4_UNORM:\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.rgtc1u_block;",
"break;",
"case DXGI_FORMAT_BC4_SNORM:\nctx->tex_ratio = 8;",
"ctx->tex_funct = ctx->texdsp.rgtc1s_block;",
"break;",
"case DXGI_FORMAT_BC5_TYPELESS:\ncase DXGI_FORMAT_BC5_UNORM:\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.rgtc2u_block;",
"break;",
"case DXGI_FORMAT_BC5_SNORM:\nctx->tex_ratio = 16;",
"ctx->tex_funct = ctx->texdsp.rgtc2s_block;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported DXGI format %d.\\n\", VAR_2);",
"return AVERROR_INVALIDDATA;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unsupported %s fourcc.\\n\", VAR_1);",
"return AVERROR_INVALIDDATA;",
"} else if (ctx->paletted) {",
"if (VAR_4 == 8) {",
"VAR_0->pix_fmt = AV_PIX_FMT_PAL8;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported palette VAR_4 %d.\\n\", VAR_4);",
"return AVERROR_INVALIDDATA;",
"} else {",
"if (VAR_4 == 8 && VAR_5 == 0xff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_GRAY8;",
"else if (VAR_4 == 16 && VAR_5 == 0xff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0xff00)\nVAR_0->pix_fmt = AV_PIX_FMT_YA8;",
"else if (VAR_4 == 16 && VAR_5 == 0xffff && VAR_6 == 0 && VAR_7 == 0 && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_GRAY16LE;",
"else if (VAR_4 == 16 && VAR_5 == 0xf800 && VAR_6 == 0x7e0 && VAR_7 == 0x1f && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB565LE;",
"else if (VAR_4 == 24 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_BGR24;",
"else if (VAR_4 == 32 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_BGRA;",
"else if (VAR_4 == 32 && VAR_5 == 0xff && VAR_6 == 0xff00 && VAR_7 == 0xff0000 && VAR_8 == 0)\nVAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"else if (VAR_4 == 32 && VAR_5 == 0xff0000 && VAR_6 == 0xff00 && VAR_7 == 0xff && VAR_8 == 0xff000000)\nVAR_0->pix_fmt = AV_PIX_FMT_BGRA;",
"else if (VAR_4 == 32 && VAR_5 == 0xff && VAR_6 == 0xff00 && VAR_7 == 0xff0000 && VAR_8 == 0xff000000)\nVAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unknown pixel format \"\n\"[VAR_4 %d VAR_5 0x%x VAR_6 0x%x VAR_7 0x%x VAR_8 0x%x].\\n\", VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);",
"return AVERROR_INVALIDDATA;",
"if (VAR_9)\nctx->postproc = DDS_ALPHA_EXP;",
"else if (VAR_12)\nctx->postproc = DDS_NORMAL_MAP;",
"else if (VAR_10 && !ctx->compressed)\nctx->postproc = DDS_RAW_YCOCG;",
"else if (VAR_0->pix_fmt == AV_PIX_FMT_YA8)\nctx->postproc = DDS_SWAP_ALPHA;",
"switch (VAR_4) {",
"case MKTAG('A', '2', 'X', 'Y'):\nctx->postproc = DDS_SWIZZLE_A2XY;",
"break;",
"case MKTAG('x', 'G', 'B', 'R'):\nctx->postproc = DDS_SWIZZLE_XGBR;",
"break;",
"case MKTAG('x', 'R', 'B', 'G'):\nctx->postproc = DDS_SWIZZLE_XRBG;",
"break;",
"case MKTAG('R', 'B', 'x', 'G'):\nctx->postproc = DDS_SWIZZLE_RBXG;",
"break;",
"case MKTAG('R', 'G', 'x', 'B'):\nctx->postproc = DDS_SWIZZLE_RGXB;",
"break;",
"case MKTAG('R', 'x', 'B', 'G'):\nctx->postproc = DDS_SWIZZLE_RXBG;",
"break;",
"case MKTAG('x', 'G', 'x', 'R'):\nctx->postproc = DDS_SWIZZLE_XGXR;",
"break;",
"case MKTAG('A', '2', 'D', '5'):\nctx->postproc = DDS_NORMAL_MAP;",
"break;",
"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
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38,
39
],
[
40
],
[
41
],
[
42
],
[
43,
44
],
[
45
],
[
46
],
[
47,
48
],
[
49
],
[
50
],
[
51,
52
],
[
53
],
[
54
],
[
55,
56
],
[
57
],
[
58
],
[
59,
60
],
[
61
],
[
62
],
[
63,
64
],
[
65,
66
],
[
67,
68
],
[
69,
70
],
[
71
],
[
72,
73
],
[
74
],
[
77
],
[
78
],
[
79
],
[
80,
81,
82
],
[
83
],
[
84
],
[
85,
86
],
[
87
],
[
88
],
[
89,
91
],
[
92
],
[
93
],
[
94,
95
],
[
96
],
[
97
],
[
98,
99
],
[
100
],
[
101
],
[
102,
103
],
[
104
],
[
105
],
[
106,
107
],
[
108
],
[
109
],
[
110,
112
],
[
113
],
[
114
],
[
115
],
[
116,
118
],
[
119
],
[
120
],
[
121
],
[
122
],
[
123,
124,
125
],
[
127
],
[
128
],
[
129
],
[
131,
132,
133,
134,
135,
136,
137
],
[
138
],
[
139,
140
],
[
141,
142,
143,
144,
145,
146
],
[
147
],
[
148,
149
],
[
150,
151,
152
],
[
153
],
[
154,
155
],
[
156,
157,
158
],
[
159
],
[
160,
161
],
[
162
],
[
164,
165
],
[
166,
167,
168
],
[
169
],
[
170
],
[
171,
172
],
[
173,
174,
175
],
[
176
],
[
177
],
[
178,
179
],
[
180,
181,
182
],
[
183
],
[
184
],
[
185,
186,
187
],
[
188
],
[
189
],
[
190,
191
],
[
192
],
[
193
],
[
194,
195,
196
],
[
197
],
[
198
],
[
199,
200
],
[
201
],
[
202
],
[
203,
204,
205
],
[
206
],
[
207
],
[
208,
209
],
[
210
],
[
211
],
[
212
],
[
213
],
[
214
],
[
215
],
[
216
],
[
217
],
[
219,
220
],
[
222,
223
],
[
224,
225
],
[
226,
227
],
[
229,
230
],
[
232,
233
],
[
234,
235
],
[
236,
237
],
[
238,
239
],
[
241
],
[
242,
243
],
[
244
],
[
246,
247
],
[
248,
249
],
[
250,
251
],
[
252,
253
],
[
255
],
[
256,
257
],
[
258
],
[
259,
260
],
[
261
],
[
262,
263
],
[
264
],
[
265,
266
],
[
267
],
[
268,
269
],
[
270
],
[
271,
272
],
[
273
],
[
274,
275
],
[
276
],
[
277,
278
],
[
279
],
[
280
]
] |
19,911 | static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
{
if (o->max*den < num*intnum || o->min*den > num*intnum) {
av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n",
num*intnum/den, o->name);
return AVERROR(ERANGE);
}
switch (o->type) {
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
case AV_OPT_TYPE_RATIONAL:
if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
break;
default:
return AVERROR(EINVAL);
}
return 0;
}
| true | FFmpeg | ef4dc3e55b677b27f6e8f471946c711bcf92da82 | static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
{
if (o->max*den < num*intnum || o->min*den > num*intnum) {
av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n",
num*intnum/den, o->name);
return AVERROR(ERANGE);
}
switch (o->type) {
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
case AV_OPT_TYPE_RATIONAL:
if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
break;
default:
return AVERROR(EINVAL);
}
return 0;
}
| {
"code": [
" av_log(obj, AV_LOG_ERROR, \"Value %f for parameter '%s' out of range\\n\",",
" num*intnum/den, o->name);"
],
"line_no": [
7,
9
]
} | static int FUNC_0(void *VAR_0, const AVOption *VAR_1, void *VAR_2, double VAR_3, int VAR_4, int64_t VAR_5)
{
if (VAR_1->max*VAR_4 < VAR_3*VAR_5 || VAR_1->min*VAR_4 > VAR_3*VAR_5) {
av_log(VAR_0, AV_LOG_ERROR, "Value %f for parameter '%s' out of range\n",
VAR_3*VAR_5/VAR_4, VAR_1->name);
return AVERROR(ERANGE);
}
switch (VAR_1->type) {
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT: *(int *)VAR_2= llrint(VAR_3/VAR_4)*VAR_5; break;
case AV_OPT_TYPE_INT64: *(int64_t *)VAR_2= llrint(VAR_3/VAR_4)*VAR_5; break;
case AV_OPT_TYPE_FLOAT: *(float *)VAR_2= VAR_3*VAR_5/VAR_4; break;
case AV_OPT_TYPE_DOUBLE:*(double *)VAR_2= VAR_3*VAR_5/VAR_4; break;
case AV_OPT_TYPE_RATIONAL:
if ((int)VAR_3 == VAR_3) *(AVRational*)VAR_2= (AVRational){VAR_3*VAR_5, VAR_4};
else *(AVRational*)VAR_2= av_d2q(VAR_3*VAR_5/VAR_4, 1<<24);
break;
default:
return AVERROR(EINVAL);
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, const AVOption *VAR_1, void *VAR_2, double VAR_3, int VAR_4, int64_t VAR_5)\n{",
"if (VAR_1->max*VAR_4 < VAR_3*VAR_5 || VAR_1->min*VAR_4 > VAR_3*VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Value %f for parameter '%s' out of range\\n\",\nVAR_3*VAR_5/VAR_4, VAR_1->name);",
"return AVERROR(ERANGE);",
"}",
"switch (VAR_1->type) {",
"case AV_OPT_TYPE_FLAGS:\ncase AV_OPT_TYPE_INT: *(int *)VAR_2= llrint(VAR_3/VAR_4)*VAR_5; break;",
"case AV_OPT_TYPE_INT64: *(int64_t *)VAR_2= llrint(VAR_3/VAR_4)*VAR_5; break;",
"case AV_OPT_TYPE_FLOAT: *(float *)VAR_2= VAR_3*VAR_5/VAR_4; break;",
"case AV_OPT_TYPE_DOUBLE:*(double *)VAR_2= VAR_3*VAR_5/VAR_4; break;",
"case AV_OPT_TYPE_RATIONAL:\nif ((int)VAR_3 == VAR_3) *(AVRational*)VAR_2= (AVRational){VAR_3*VAR_5, VAR_4};",
"else *(AVRational*)VAR_2= av_d2q(VAR_3*VAR_5/VAR_4, 1<<24);",
"break;",
"default:\nreturn AVERROR(EINVAL);",
"}",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
]
] |
19,913 | static uint64_t itc_tag_read(void *opaque, hwaddr addr, unsigned size)
{
MIPSITUState *tag = (MIPSITUState *)opaque;
uint64_t index = addr >> 3;
uint64_t ret = 0;
switch (index) {
case 0 ... ITC_ADDRESSMAP_NUM:
ret = tag->ITCAddressMap[index];
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Read 0x%" PRIx64 "\n", addr);
break;
}
return ret;
}
| true | qemu | f2eb665a11a34ac9f6459f8a18c3d9d8be9ca359 | static uint64_t itc_tag_read(void *opaque, hwaddr addr, unsigned size)
{
MIPSITUState *tag = (MIPSITUState *)opaque;
uint64_t index = addr >> 3;
uint64_t ret = 0;
switch (index) {
case 0 ... ITC_ADDRESSMAP_NUM:
ret = tag->ITCAddressMap[index];
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Read 0x%" PRIx64 "\n", addr);
break;
}
return ret;
}
| {
"code": [
" uint64_t ret = 0;",
" switch (index) {",
" case 0 ... ITC_ADDRESSMAP_NUM:",
" ret = tag->ITCAddressMap[index];",
" break;",
" default:",
" break;",
" return ret;"
],
"line_no": [
9,
13,
15,
17,
19,
21,
19,
31
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)
{
MIPSITUState *tag = (MIPSITUState *)opaque;
uint64_t index = addr >> 3;
uint64_t ret = 0;
switch (index) {
case 0 ... ITC_ADDRESSMAP_NUM:
ret = tag->ITCAddressMap[index];
break;
default:
qemu_log_mask(LOG_GUEST_ERROR, "Read 0x%" PRIx64 "\n", addr);
break;
}
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)\n{",
"MIPSITUState *tag = (MIPSITUState *)opaque;",
"uint64_t index = addr >> 3;",
"uint64_t ret = 0;",
"switch (index) {",
"case 0 ... ITC_ADDRESSMAP_NUM:\nret = tag->ITCAddressMap[index];",
"break;",
"default:\nqemu_log_mask(LOG_GUEST_ERROR, \"Read 0x%\" PRIx64 \"\\n\", addr);",
"break;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
19,914 | static int calc_add_mv(RV34DecContext *r, int dir, int val)
{
int mul = dir ? -r->mv_weight2 : r->mv_weight1;
return (val * mul + 0x2000) >> 14;
}
| true | FFmpeg | 4bd869eb7c8416942f12b61db6439d2bfc474456 | static int calc_add_mv(RV34DecContext *r, int dir, int val)
{
int mul = dir ? -r->mv_weight2 : r->mv_weight1;
return (val * mul + 0x2000) >> 14;
}
| {
"code": [
" return (val * mul + 0x2000) >> 14;"
],
"line_no": [
9
]
} | static int FUNC_0(RV34DecContext *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3 = VAR_1 ? -VAR_0->mv_weight2 : VAR_0->mv_weight1;
return (VAR_2 * VAR_3 + 0x2000) >> 14;
}
| [
"static int FUNC_0(RV34DecContext *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3 = VAR_1 ? -VAR_0->mv_weight2 : VAR_0->mv_weight1;",
"return (VAR_2 * VAR_3 + 0x2000) >> 14;",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
19,915 | static void put_line(uint8_t *dst, int size, int width, const int *runs)
{
PutBitContext pb;
int run, mode = ~0, pix_left = width, run_idx = 0;
init_put_bits(&pb, dst, size * 8);
while (pix_left > 0) {
run = runs[run_idx++];
mode = ~mode;
pix_left -= run;
for (; run > 16; run -= 16)
put_sbits(&pb, 16, mode);
if (run)
put_sbits(&pb, run, mode);
}
flush_put_bits(&pb);
}
| true | FFmpeg | 50833c9f7b4e1922197a8955669f8ab3589c8cef | static void put_line(uint8_t *dst, int size, int width, const int *runs)
{
PutBitContext pb;
int run, mode = ~0, pix_left = width, run_idx = 0;
init_put_bits(&pb, dst, size * 8);
while (pix_left > 0) {
run = runs[run_idx++];
mode = ~mode;
pix_left -= run;
for (; run > 16; run -= 16)
put_sbits(&pb, 16, mode);
if (run)
put_sbits(&pb, run, mode);
}
flush_put_bits(&pb);
}
| {
"code": [
" init_put_bits(&pb, dst, size * 8);"
],
"line_no": [
11
]
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, const int *VAR_3)
{
PutBitContext pb;
int VAR_4, VAR_5 = ~0, VAR_6 = VAR_2, VAR_7 = 0;
init_put_bits(&pb, VAR_0, VAR_1 * 8);
while (VAR_6 > 0) {
VAR_4 = VAR_3[VAR_7++];
VAR_5 = ~VAR_5;
VAR_6 -= VAR_4;
for (; VAR_4 > 16; VAR_4 -= 16)
put_sbits(&pb, 16, VAR_5);
if (VAR_4)
put_sbits(&pb, VAR_4, VAR_5);
}
flush_put_bits(&pb);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2, const int *VAR_3)\n{",
"PutBitContext pb;",
"int VAR_4, VAR_5 = ~0, VAR_6 = VAR_2, VAR_7 = 0;",
"init_put_bits(&pb, VAR_0, VAR_1 * 8);",
"while (VAR_6 > 0) {",
"VAR_4 = VAR_3[VAR_7++];",
"VAR_5 = ~VAR_5;",
"VAR_6 -= VAR_4;",
"for (; VAR_4 > 16; VAR_4 -= 16)",
"put_sbits(&pb, 16, VAR_5);",
"if (VAR_4)\nput_sbits(&pb, VAR_4, VAR_5);",
"}",
"flush_put_bits(&pb);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
]
] |
19,917 | int ff_load_image(uint8_t *data[4], int linesize[4],
int *w, int *h, enum PixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int frame_decoded, ret = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to open input file '%s'\n", filename);
return ret;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_read_frame(format_ctx, &pkt);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
if (ret < 0 || !frame_decoded) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
ret = 0;
*w = frame->width;
*h = frame->height;
*pix_fmt = frame->format;
if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0)
goto end;
ret = 0;
av_image_copy(data, linesize, frame->data, frame->linesize, *pix_fmt, *w, *h);
end:
if (codec_ctx)
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (ret < 0)
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
return ret;
}
| false | FFmpeg | 44391f706b0be13e74b2432b57a6597b210a989c | int ff_load_image(uint8_t *data[4], int linesize[4],
int *w, int *h, enum PixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int frame_decoded, ret = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to open input file '%s'\n", filename);
return ret;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_read_frame(format_ctx, &pkt);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
if (ret < 0 || !frame_decoded) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
ret = 0;
*w = frame->width;
*h = frame->height;
*pix_fmt = frame->format;
if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0)
goto end;
ret = 0;
av_image_copy(data, linesize, frame->data, frame->linesize, *pix_fmt, *w, *h);
end:
if (codec_ctx)
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (ret < 0)
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],
int *VAR_2, int *VAR_3, enum PixelFormat *VAR_4,
const char *VAR_5, void *VAR_6)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int VAR_7, VAR_8 = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((VAR_8 = avformat_open_input(&format_ctx, VAR_5, iformat, NULL)) < 0) {
av_log(VAR_6, AV_LOG_ERROR,
"Failed to open input file '%s'\n", VAR_5);
return VAR_8;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(VAR_6, AV_LOG_ERROR, "Failed to find codec\n");
VAR_8 = AVERROR(EINVAL);
goto end;
}
if ((VAR_8 = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(VAR_6, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(VAR_6, AV_LOG_ERROR, "Failed to alloc frame\n");
VAR_8 = AVERROR(ENOMEM);
goto end;
}
VAR_8 = av_read_frame(format_ctx, &pkt);
if (VAR_8 < 0) {
av_log(VAR_6, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
VAR_8 = avcodec_decode_video2(codec_ctx, frame, &VAR_7, &pkt);
if (VAR_8 < 0 || !VAR_7) {
av_log(VAR_6, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
VAR_8 = 0;
*VAR_2 = frame->width;
*VAR_3 = frame->height;
*VAR_4 = frame->format;
if ((VAR_8 = av_image_alloc(VAR_0, VAR_1, *VAR_2, *VAR_3, *VAR_4, 16)) < 0)
goto end;
VAR_8 = 0;
av_image_copy(VAR_0, VAR_1, frame->VAR_0, frame->VAR_1, *VAR_4, *VAR_2, *VAR_3);
end:
if (codec_ctx)
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (VAR_8 < 0)
av_log(VAR_6, AV_LOG_ERROR, "Error loading image file '%s'\n", VAR_5);
return VAR_8;
}
| [
"int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4],\nint *VAR_2, int *VAR_3, enum PixelFormat *VAR_4,\nconst char *VAR_5, void *VAR_6)\n{",
"AVInputFormat *iformat = NULL;",
"AVFormatContext *format_ctx;",
"AVCodec *codec;",
"AVCodecContext *codec_ctx;",
"AVFrame *frame;",
"int VAR_7, VAR_8 = 0;",
"AVPacket pkt;",
"av_register_all();",
"iformat = av_find_input_format(\"image2\");",
"if ((VAR_8 = avformat_open_input(&format_ctx, VAR_5, iformat, NULL)) < 0) {",
"av_log(VAR_6, AV_LOG_ERROR,\n\"Failed to open input file '%s'\\n\", VAR_5);",
"return VAR_8;",
"}",
"codec_ctx = format_ctx->streams[0]->codec;",
"codec = avcodec_find_decoder(codec_ctx->codec_id);",
"if (!codec) {",
"av_log(VAR_6, AV_LOG_ERROR, \"Failed to find codec\\n\");",
"VAR_8 = AVERROR(EINVAL);",
"goto end;",
"}",
"if ((VAR_8 = avcodec_open2(codec_ctx, codec, NULL)) < 0) {",
"av_log(VAR_6, AV_LOG_ERROR, \"Failed to open codec\\n\");",
"goto end;",
"}",
"if (!(frame = avcodec_alloc_frame()) ) {",
"av_log(VAR_6, AV_LOG_ERROR, \"Failed to alloc frame\\n\");",
"VAR_8 = AVERROR(ENOMEM);",
"goto end;",
"}",
"VAR_8 = av_read_frame(format_ctx, &pkt);",
"if (VAR_8 < 0) {",
"av_log(VAR_6, AV_LOG_ERROR, \"Failed to read frame from file\\n\");",
"goto end;",
"}",
"VAR_8 = avcodec_decode_video2(codec_ctx, frame, &VAR_7, &pkt);",
"if (VAR_8 < 0 || !VAR_7) {",
"av_log(VAR_6, AV_LOG_ERROR, \"Failed to decode image from file\\n\");",
"goto end;",
"}",
"VAR_8 = 0;",
"*VAR_2 = frame->width;",
"*VAR_3 = frame->height;",
"*VAR_4 = frame->format;",
"if ((VAR_8 = av_image_alloc(VAR_0, VAR_1, *VAR_2, *VAR_3, *VAR_4, 16)) < 0)\ngoto end;",
"VAR_8 = 0;",
"av_image_copy(VAR_0, VAR_1, frame->VAR_0, frame->VAR_1, *VAR_4, *VAR_2, *VAR_3);",
"end:\nif (codec_ctx)\navcodec_close(codec_ctx);",
"if (format_ctx)\navformat_close_input(&format_ctx);",
"av_freep(&frame);",
"if (VAR_8 < 0)\nav_log(VAR_6, AV_LOG_ERROR, \"Error loading image file '%s'\\n\", VAR_5);",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119
],
[
123
],
[
127,
129,
131
],
[
133,
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
]
] |
19,918 | void ff_vdpau_h264_picture_complete(MpegEncContext *s)
{
H264Context *h = s->avctx->priv_data;
struct vdpau_render_state *render;
int i;
render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
assert(render);
render->info.h264.slice_count = h->slice_num;
if (render->info.h264.slice_count < 1)
return;
for (i = 0; i < 2; ++i) {
int foc = s->current_picture_ptr->field_poc[i];
if (foc == INT_MAX)
foc = 0;
render->info.h264.field_order_cnt[i] = foc;
}
render->info.h264.is_reference = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
render->info.h264.frame_num = h->frame_num;
render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME;
render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD;
render->info.h264.num_ref_frames = h->sps.ref_frame_count;
render->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !render->info.h264.field_pic_flag;
render->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
render->info.h264.weighted_pred_flag = h->pps.weighted_pred;
render->info.h264.weighted_bipred_idc = h->pps.weighted_bipred_idc;
render->info.h264.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;
render->info.h264.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
render->info.h264.chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
render->info.h264.second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
render->info.h264.pic_init_qp_minus26 = h->pps.init_qp - 26;
render->info.h264.num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
render->info.h264.num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
render->info.h264.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4;
render->info.h264.pic_order_cnt_type = h->sps.poc_type;
render->info.h264.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
render->info.h264.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
render->info.h264.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
render->info.h264.entropy_coding_mode_flag = h->pps.cabac;
render->info.h264.pic_order_present_flag = h->pps.pic_order_present;
render->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
render->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;
memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4));
memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8));
ff_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
| false | FFmpeg | 49caac24132c06e2f14b275da9048588c7da63d0 | void ff_vdpau_h264_picture_complete(MpegEncContext *s)
{
H264Context *h = s->avctx->priv_data;
struct vdpau_render_state *render;
int i;
render = (struct vdpau_render_state *)s->current_picture_ptr->data[0];
assert(render);
render->info.h264.slice_count = h->slice_num;
if (render->info.h264.slice_count < 1)
return;
for (i = 0; i < 2; ++i) {
int foc = s->current_picture_ptr->field_poc[i];
if (foc == INT_MAX)
foc = 0;
render->info.h264.field_order_cnt[i] = foc;
}
render->info.h264.is_reference = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
render->info.h264.frame_num = h->frame_num;
render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME;
render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD;
render->info.h264.num_ref_frames = h->sps.ref_frame_count;
render->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !render->info.h264.field_pic_flag;
render->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
render->info.h264.weighted_pred_flag = h->pps.weighted_pred;
render->info.h264.weighted_bipred_idc = h->pps.weighted_bipred_idc;
render->info.h264.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;
render->info.h264.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
render->info.h264.chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
render->info.h264.second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
render->info.h264.pic_init_qp_minus26 = h->pps.init_qp - 26;
render->info.h264.num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
render->info.h264.num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
render->info.h264.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4;
render->info.h264.pic_order_cnt_type = h->sps.poc_type;
render->info.h264.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
render->info.h264.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
render->info.h264.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
render->info.h264.entropy_coding_mode_flag = h->pps.cabac;
render->info.h264.pic_order_present_flag = h->pps.pic_order_present;
render->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
render->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;
memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4));
memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8));
ff_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0)
{
H264Context *h = VAR_0->avctx->priv_data;
struct vdpau_render_state *VAR_1;
int VAR_2;
VAR_1 = (struct vdpau_render_state *)VAR_0->current_picture_ptr->data[0];
assert(VAR_1);
VAR_1->info.h264.slice_count = h->slice_num;
if (VAR_1->info.h264.slice_count < 1)
return;
for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {
int VAR_3 = VAR_0->current_picture_ptr->field_poc[VAR_2];
if (VAR_3 == INT_MAX)
VAR_3 = 0;
VAR_1->info.h264.field_order_cnt[VAR_2] = VAR_3;
}
VAR_1->info.h264.is_reference = (VAR_0->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
VAR_1->info.h264.frame_num = h->frame_num;
VAR_1->info.h264.field_pic_flag = VAR_0->picture_structure != PICT_FRAME;
VAR_1->info.h264.bottom_field_flag = VAR_0->picture_structure == PICT_BOTTOM_FIELD;
VAR_1->info.h264.num_ref_frames = h->sps.ref_frame_count;
VAR_1->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !VAR_1->info.h264.field_pic_flag;
VAR_1->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred;
VAR_1->info.h264.weighted_pred_flag = h->pps.weighted_pred;
VAR_1->info.h264.weighted_bipred_idc = h->pps.weighted_bipred_idc;
VAR_1->info.h264.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;
VAR_1->info.h264.transform_8x8_mode_flag = h->pps.transform_8x8_mode;
VAR_1->info.h264.chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];
VAR_1->info.h264.second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];
VAR_1->info.h264.pic_init_qp_minus26 = h->pps.init_qp - 26;
VAR_1->info.h264.num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;
VAR_1->info.h264.num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;
VAR_1->info.h264.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4;
VAR_1->info.h264.pic_order_cnt_type = h->sps.poc_type;
VAR_1->info.h264.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;
VAR_1->info.h264.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;
VAR_1->info.h264.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;
VAR_1->info.h264.entropy_coding_mode_flag = h->pps.cabac;
VAR_1->info.h264.pic_order_present_flag = h->pps.pic_order_present;
VAR_1->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;
VAR_1->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;
memcpy(VAR_1->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(VAR_1->info.h264.scaling_lists_4x4));
memcpy(VAR_1->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(VAR_1->info.h264.scaling_lists_8x8));
ff_draw_horiz_band(VAR_0, 0, VAR_0->avctx->height);
VAR_1->bitstream_buffers_used = 0;
}
| [
"void FUNC_0(MpegEncContext *VAR_0)\n{",
"H264Context *h = VAR_0->avctx->priv_data;",
"struct vdpau_render_state *VAR_1;",
"int VAR_2;",
"VAR_1 = (struct vdpau_render_state *)VAR_0->current_picture_ptr->data[0];",
"assert(VAR_1);",
"VAR_1->info.h264.slice_count = h->slice_num;",
"if (VAR_1->info.h264.slice_count < 1)\nreturn;",
"for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {",
"int VAR_3 = VAR_0->current_picture_ptr->field_poc[VAR_2];",
"if (VAR_3 == INT_MAX)\nVAR_3 = 0;",
"VAR_1->info.h264.field_order_cnt[VAR_2] = VAR_3;",
"}",
"VAR_1->info.h264.is_reference = (VAR_0->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;",
"VAR_1->info.h264.frame_num = h->frame_num;",
"VAR_1->info.h264.field_pic_flag = VAR_0->picture_structure != PICT_FRAME;",
"VAR_1->info.h264.bottom_field_flag = VAR_0->picture_structure == PICT_BOTTOM_FIELD;",
"VAR_1->info.h264.num_ref_frames = h->sps.ref_frame_count;",
"VAR_1->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !VAR_1->info.h264.field_pic_flag;",
"VAR_1->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred;",
"VAR_1->info.h264.weighted_pred_flag = h->pps.weighted_pred;",
"VAR_1->info.h264.weighted_bipred_idc = h->pps.weighted_bipred_idc;",
"VAR_1->info.h264.frame_mbs_only_flag = h->sps.frame_mbs_only_flag;",
"VAR_1->info.h264.transform_8x8_mode_flag = h->pps.transform_8x8_mode;",
"VAR_1->info.h264.chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0];",
"VAR_1->info.h264.second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1];",
"VAR_1->info.h264.pic_init_qp_minus26 = h->pps.init_qp - 26;",
"VAR_1->info.h264.num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1;",
"VAR_1->info.h264.num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1;",
"VAR_1->info.h264.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4;",
"VAR_1->info.h264.pic_order_cnt_type = h->sps.poc_type;",
"VAR_1->info.h264.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4;",
"VAR_1->info.h264.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag;",
"VAR_1->info.h264.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag;",
"VAR_1->info.h264.entropy_coding_mode_flag = h->pps.cabac;",
"VAR_1->info.h264.pic_order_present_flag = h->pps.pic_order_present;",
"VAR_1->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present;",
"VAR_1->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present;",
"memcpy(VAR_1->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(VAR_1->info.h264.scaling_lists_4x4));",
"memcpy(VAR_1->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(VAR_1->info.h264.scaling_lists_8x8));",
"ff_draw_horiz_band(VAR_0, 0, VAR_0->avctx->height);",
"VAR_1->bitstream_buffers_used = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
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,920 | static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
{
flat_print_key_prefix(wctx);
printf("%s=%lld\n", key, value);
}
| false | FFmpeg | 01e4537f66c6d054f8c7bdbdd5b3cfb4220d12fe | static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
{
flat_print_key_prefix(wctx);
printf("%s=%lld\n", key, value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, long long int VAR_2)
{
flat_print_key_prefix(VAR_0);
printf("%s=%lld\n", VAR_1, VAR_2);
}
| [
"static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, long long int VAR_2)\n{",
"flat_print_key_prefix(VAR_0);",
"printf(\"%s=%lld\\n\", VAR_1, VAR_2);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
19,921 | void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
{
while (size > 0) {
int len = FFMIN(f->end - f->wptr, size);
memcpy(f->wptr, buf, len);
f->wptr += len;
if (f->wptr >= f->end)
f->wptr = f->buffer;
buf += len;
size -= len;
}
}
| false | FFmpeg | 50b4468598cbc032c0ec4597df9637f71b9ef664 | void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
{
while (size > 0) {
int len = FFMIN(f->end - f->wptr, size);
memcpy(f->wptr, buf, len);
f->wptr += len;
if (f->wptr >= f->end)
f->wptr = f->buffer;
buf += len;
size -= len;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVFifoBuffer *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
while (VAR_2 > 0) {
int VAR_3 = FFMIN(VAR_0->end - VAR_0->wptr, VAR_2);
memcpy(VAR_0->wptr, VAR_1, VAR_3);
VAR_0->wptr += VAR_3;
if (VAR_0->wptr >= VAR_0->end)
VAR_0->wptr = VAR_0->buffer;
VAR_1 += VAR_3;
VAR_2 -= VAR_3;
}
}
| [
"void FUNC_0(AVFifoBuffer *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"while (VAR_2 > 0) {",
"int VAR_3 = FFMIN(VAR_0->end - VAR_0->wptr, VAR_2);",
"memcpy(VAR_0->wptr, VAR_1, VAR_3);",
"VAR_0->wptr += VAR_3;",
"if (VAR_0->wptr >= VAR_0->end)\nVAR_0->wptr = VAR_0->buffer;",
"VAR_1 += VAR_3;",
"VAR_2 -= VAR_3;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,922 | static int handle_packets(MpegTSContext *ts, int nb_packets)
{
AVFormatContext *s = ts->stream;
uint8_t packet[TS_PACKET_SIZE];
int packet_num, ret = 0;
if (avio_tell(s->pb) != ts->last_pos) {
int i;
av_dlog("Skipping after seek\n");
/* seek detected, flush pes buffer */
for (i = 0; i < NB_PID_MAX; i++) {
if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
av_freep(&pes->buffer);
ts->pids[i]->last_cc = -1;
pes->data_index = 0;
pes->state = MPEGTS_SKIP; /* skip until pes header */
}
}
}
ts->stop_parse = 0;
packet_num = 0;
for(;;) {
if (ts->stop_parse>0)
break;
packet_num++;
if (nb_packets != 0 && packet_num >= nb_packets)
break;
ret = read_packet(s, packet, ts->raw_packet_size);
if (ret != 0)
break;
ret = handle_packet(ts, packet);
if (ret != 0)
break;
}
ts->last_pos = avio_tell(s->pb);
return ret;
}
| false | FFmpeg | 162f1fbc147bbff6e23b4df1e587cec5d5111052 | static int handle_packets(MpegTSContext *ts, int nb_packets)
{
AVFormatContext *s = ts->stream;
uint8_t packet[TS_PACKET_SIZE];
int packet_num, ret = 0;
if (avio_tell(s->pb) != ts->last_pos) {
int i;
av_dlog("Skipping after seek\n");
for (i = 0; i < NB_PID_MAX; i++) {
if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
av_freep(&pes->buffer);
ts->pids[i]->last_cc = -1;
pes->data_index = 0;
pes->state = MPEGTS_SKIP;
}
}
}
ts->stop_parse = 0;
packet_num = 0;
for(;;) {
if (ts->stop_parse>0)
break;
packet_num++;
if (nb_packets != 0 && packet_num >= nb_packets)
break;
ret = read_packet(s, packet, ts->raw_packet_size);
if (ret != 0)
break;
ret = handle_packet(ts, packet);
if (ret != 0)
break;
}
ts->last_pos = avio_tell(s->pb);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegTSContext *VAR_0, int VAR_1)
{
AVFormatContext *s = VAR_0->stream;
uint8_t packet[TS_PACKET_SIZE];
int VAR_2, VAR_3 = 0;
if (avio_tell(s->pb) != VAR_0->last_pos) {
int VAR_4;
av_dlog("Skipping after seek\n");
for (VAR_4 = 0; VAR_4 < NB_PID_MAX; VAR_4++) {
if (VAR_0->pids[VAR_4] && VAR_0->pids[VAR_4]->type == MPEGTS_PES) {
PESContext *pes = VAR_0->pids[VAR_4]->u.pes_filter.opaque;
av_freep(&pes->buffer);
VAR_0->pids[VAR_4]->last_cc = -1;
pes->data_index = 0;
pes->state = MPEGTS_SKIP;
}
}
}
VAR_0->stop_parse = 0;
VAR_2 = 0;
for(;;) {
if (VAR_0->stop_parse>0)
break;
VAR_2++;
if (VAR_1 != 0 && VAR_2 >= VAR_1)
break;
VAR_3 = read_packet(s, packet, VAR_0->raw_packet_size);
if (VAR_3 != 0)
break;
VAR_3 = handle_packet(VAR_0, packet);
if (VAR_3 != 0)
break;
}
VAR_0->last_pos = avio_tell(s->pb);
return VAR_3;
}
| [
"static int FUNC_0(MpegTSContext *VAR_0, int VAR_1)\n{",
"AVFormatContext *s = VAR_0->stream;",
"uint8_t packet[TS_PACKET_SIZE];",
"int VAR_2, VAR_3 = 0;",
"if (avio_tell(s->pb) != VAR_0->last_pos) {",
"int VAR_4;",
"av_dlog(\"Skipping after seek\\n\");",
"for (VAR_4 = 0; VAR_4 < NB_PID_MAX; VAR_4++) {",
"if (VAR_0->pids[VAR_4] && VAR_0->pids[VAR_4]->type == MPEGTS_PES) {",
"PESContext *pes = VAR_0->pids[VAR_4]->u.pes_filter.opaque;",
"av_freep(&pes->buffer);",
"VAR_0->pids[VAR_4]->last_cc = -1;",
"pes->data_index = 0;",
"pes->state = MPEGTS_SKIP;",
"}",
"}",
"}",
"VAR_0->stop_parse = 0;",
"VAR_2 = 0;",
"for(;;) {",
"if (VAR_0->stop_parse>0)\nbreak;",
"VAR_2++;",
"if (VAR_1 != 0 && VAR_2 >= VAR_1)\nbreak;",
"VAR_3 = read_packet(s, packet, VAR_0->raw_packet_size);",
"if (VAR_3 != 0)\nbreak;",
"VAR_3 = handle_packet(VAR_0, packet);",
"if (VAR_3 != 0)\nbreak;",
"}",
"VAR_0->last_pos = avio_tell(s->pb);",
"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,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
19,923 | void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
av_unused int dir;
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = h->slice_alpha_c0_offset - qp_bd_offset;
int b = h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type
&& IS_INTERLACED(mb_type^h->left_type[LTOP])
// and left mb is in available to us
&& h->left_type[LTOP]) {
/* First vertical edge is different in MBAFF frames
* There are 8 different bS to compute and 2 different Qp
*/
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = h->left_mb_xy[LEFT(j)];
int mbn_type= h->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[h->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[h->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
tprintf(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(h->avctx, " bS[%d]:%d", i, bS[i]); tprintf(h->avctx, "\n"); }
if (MB_FIELD(h)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
for( dir = 0; dir < 2; dir++ )
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir);
#else
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| false | FFmpeg | f777504f640260337974848c7d5d7a3f064bbb45 | void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
av_unused int dir;
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = h->slice_alpha_c0_offset - qp_bd_offset;
int b = h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
&& IS_INTERLACED(mb_type^h->left_type[LTOP])
&& h->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = h->left_mb_xy[LEFT(j)];
int mbn_type= h->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[h->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[h->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
tprintf(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(h->avctx, " bS[%d]:%d", i, bS[i]); tprintf(h->avctx, "\n"); }
if (MB_FIELD(h)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
for( dir = 0; dir < 2; dir++ )
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir);
#else
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, uint8_t *VAR_4, uint8_t *VAR_5, unsigned int VAR_6, unsigned int VAR_7) {
const int VAR_8= VAR_1 + VAR_2*VAR_0->mb_stride;
const int VAR_9 = VAR_0->cur_pic.VAR_9[VAR_8];
const int VAR_10 = IS_INTERLACED(VAR_9) ? 2 : 4;
int VAR_11 = 0;
av_unused int dir;
int VAR_12 = !(CONFIG_GRAY && (VAR_0->flags&CODEC_FLAG_GRAY));
int VAR_13 = 6 * (VAR_0->sps.bit_depth_luma - 8);
int VAR_14 = VAR_0->slice_alpha_c0_offset - VAR_13;
int VAR_15 = VAR_0->slice_beta_offset - VAR_13;
if (FRAME_MBAFF(VAR_0)
&& IS_INTERLACED(VAR_9^VAR_0->left_type[LTOP])
&& VAR_0->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int VAR_16[2];
int VAR_17[2];
int VAR_18[2];
int VAR_19, VAR_20, VAR_21;
int VAR_28;
VAR_11 = 1;
if( IS_INTRA(VAR_9) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t VAR_23[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *VAR_24= VAR_23[MB_FIELD(VAR_0)][VAR_2&1];
for( VAR_28 = 0; VAR_28 < 8; VAR_28++ ) {
int VAR_25= MB_FIELD(VAR_0) ? VAR_28>>2 : VAR_28&1;
int VAR_26 = VAR_0->left_mb_xy[LEFT(VAR_25)];
int VAR_27= VAR_0->left_type[LEFT(VAR_25)];
if( IS_INTRA( VAR_27 ) )
bS[VAR_28] = 4;
else{
bS[VAR_28] = 1 + !!(VAR_0->non_zero_count_cache[12+8*(VAR_28>>1)] |
((!VAR_0->pps.cabac && IS_8x8DCT(VAR_27)) ?
(VAR_0->cbp_table[VAR_26] & (((MB_FIELD(VAR_0) ? (VAR_28&2) : (VAR_2&1)) ? 8 : 2) << 12))
:
VAR_0->non_zero_count[VAR_26][ VAR_24[VAR_28] ]));
}
}
}
VAR_19 = VAR_0->cur_pic.qscale_table[VAR_8];
VAR_20 = VAR_0->cur_pic.qscale_table[VAR_0->left_mb_xy[0]];
VAR_21 = VAR_0->cur_pic.qscale_table[VAR_0->left_mb_xy[1]];
VAR_16[0] = ( VAR_19 + VAR_20 + 1 ) >> 1;
VAR_17[0] = ( get_chroma_qp( VAR_0, 0, VAR_19 ) +
get_chroma_qp( VAR_0, 0, VAR_20 ) + 1 ) >> 1;
VAR_18[0] = ( get_chroma_qp( VAR_0, 1, VAR_19 ) +
get_chroma_qp( VAR_0, 1, VAR_20 ) + 1 ) >> 1;
VAR_16[1] = ( VAR_19 + VAR_21 + 1 ) >> 1;
VAR_17[1] = ( get_chroma_qp( VAR_0, 0, VAR_19 ) +
get_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;
VAR_18[1] = ( get_chroma_qp( VAR_0, 1, VAR_19 ) +
get_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;
tprintf(VAR_0->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", VAR_1, VAR_2, VAR_16[0], VAR_16[1], VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_6, VAR_7);
{ int VAR_28; for (VAR_28 = 0; VAR_28 < 8; VAR_28++) tprintf(VAR_0->avctx, " bS[%d]:%d", VAR_28, bS[VAR_28]); tprintf(VAR_0->avctx, "\n"); }
if (MB_FIELD(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_3 , VAR_6, bS , 1, VAR_16 [0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_3 + 8* VAR_6, VAR_6, bS+4, 1, VAR_16 [1], VAR_14, VAR_15, 1 );
if (VAR_12){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1 );
} else if (CHROMA422(VAR_0)) {
filter_mb_mbaff_edgecv(VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_4 + 8*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1);
filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1);
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_4 + 4*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( VAR_0, VAR_3 , 2* VAR_6, bS , 2, VAR_16 [0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_3 + VAR_6, 2* VAR_6, bS+1, 2, VAR_16 [1], VAR_14, VAR_15, 1 );
if (VAR_12){
if (CHROMA444(VAR_0)) {
filter_mb_mbaff_edgev ( VAR_0, VAR_4, 2*VAR_7, bS , 2, VAR_17[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2*VAR_7, bS+1, 2, VAR_17[1], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_7, bS , 2, VAR_18[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_7, 2*VAR_7, bS+1, 2, VAR_18[1], VAR_14, VAR_15, 1 );
}else{
filter_mb_mbaff_edgecv( VAR_0, VAR_4, 2*VAR_7, bS , 2, VAR_17[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_4 + VAR_7, 2*VAR_7, bS+1, 2, VAR_17[1], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_7, bS , 2, VAR_18[0], VAR_14, VAR_15, 1 );
filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_7, 2*VAR_7, bS+1, 2, VAR_18[1], VAR_14, VAR_15, 1 );
}
}
}
}
#if CONFIG_SMALL
for( dir = 0; dir < 2; dir++ )
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, dir ? 0 : VAR_11, VAR_14, VAR_15, VAR_12, dir);
#else
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_14, VAR_15, VAR_12, 0);
filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, 0, VAR_14, VAR_15, VAR_12, 1);
#endif
}
| [
"void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2, uint8_t *VAR_3, uint8_t *VAR_4, uint8_t *VAR_5, unsigned int VAR_6, unsigned int VAR_7) {",
"const int VAR_8= VAR_1 + VAR_2*VAR_0->mb_stride;",
"const int VAR_9 = VAR_0->cur_pic.VAR_9[VAR_8];",
"const int VAR_10 = IS_INTERLACED(VAR_9) ? 2 : 4;",
"int VAR_11 = 0;",
"av_unused int dir;",
"int VAR_12 = !(CONFIG_GRAY && (VAR_0->flags&CODEC_FLAG_GRAY));",
"int VAR_13 = 6 * (VAR_0->sps.bit_depth_luma - 8);",
"int VAR_14 = VAR_0->slice_alpha_c0_offset - VAR_13;",
"int VAR_15 = VAR_0->slice_beta_offset - VAR_13;",
"if (FRAME_MBAFF(VAR_0)\n&& IS_INTERLACED(VAR_9^VAR_0->left_type[LTOP])\n&& VAR_0->left_type[LTOP]) {",
"DECLARE_ALIGNED(8, int16_t, bS)[8];",
"int VAR_16[2];",
"int VAR_17[2];",
"int VAR_18[2];",
"int VAR_19, VAR_20, VAR_21;",
"int VAR_28;",
"VAR_11 = 1;",
"if( IS_INTRA(VAR_9) ) {",
"AV_WN64A(&bS[0], 0x0004000400040004ULL);",
"AV_WN64A(&bS[4], 0x0004000400040004ULL);",
"} else {",
"static const uint8_t VAR_23[2][2][8]={",
"{",
"{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},",
"{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},",
"},{",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},",
"}",
"};",
"const uint8_t *VAR_24= VAR_23[MB_FIELD(VAR_0)][VAR_2&1];",
"for( VAR_28 = 0; VAR_28 < 8; VAR_28++ ) {",
"int VAR_25= MB_FIELD(VAR_0) ? VAR_28>>2 : VAR_28&1;",
"int VAR_26 = VAR_0->left_mb_xy[LEFT(VAR_25)];",
"int VAR_27= VAR_0->left_type[LEFT(VAR_25)];",
"if( IS_INTRA( VAR_27 ) )\nbS[VAR_28] = 4;",
"else{",
"bS[VAR_28] = 1 + !!(VAR_0->non_zero_count_cache[12+8*(VAR_28>>1)] |\n((!VAR_0->pps.cabac && IS_8x8DCT(VAR_27)) ?\n(VAR_0->cbp_table[VAR_26] & (((MB_FIELD(VAR_0) ? (VAR_28&2) : (VAR_2&1)) ? 8 : 2) << 12))\n:\nVAR_0->non_zero_count[VAR_26][ VAR_24[VAR_28] ]));",
"}",
"}",
"}",
"VAR_19 = VAR_0->cur_pic.qscale_table[VAR_8];",
"VAR_20 = VAR_0->cur_pic.qscale_table[VAR_0->left_mb_xy[0]];",
"VAR_21 = VAR_0->cur_pic.qscale_table[VAR_0->left_mb_xy[1]];",
"VAR_16[0] = ( VAR_19 + VAR_20 + 1 ) >> 1;",
"VAR_17[0] = ( get_chroma_qp( VAR_0, 0, VAR_19 ) +\nget_chroma_qp( VAR_0, 0, VAR_20 ) + 1 ) >> 1;",
"VAR_18[0] = ( get_chroma_qp( VAR_0, 1, VAR_19 ) +\nget_chroma_qp( VAR_0, 1, VAR_20 ) + 1 ) >> 1;",
"VAR_16[1] = ( VAR_19 + VAR_21 + 1 ) >> 1;",
"VAR_17[1] = ( get_chroma_qp( VAR_0, 0, VAR_19 ) +\nget_chroma_qp( VAR_0, 0, VAR_21 ) + 1 ) >> 1;",
"VAR_18[1] = ( get_chroma_qp( VAR_0, 1, VAR_19 ) +\nget_chroma_qp( VAR_0, 1, VAR_21 ) + 1 ) >> 1;",
"tprintf(VAR_0->avctx, \"filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d\", VAR_1, VAR_2, VAR_16[0], VAR_16[1], VAR_17[0], VAR_17[1], VAR_18[0], VAR_18[1], VAR_6, VAR_7);",
"{ int VAR_28; for (VAR_28 = 0; VAR_28 < 8; VAR_28++) tprintf(VAR_0->avctx, \" bS[%d]:%d\", VAR_28, bS[VAR_28]); tprintf(VAR_0->avctx, \"\\n\"); }",
"if (MB_FIELD(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_3 , VAR_6, bS , 1, VAR_16 [0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_3 + 8* VAR_6, VAR_6, bS+4, 1, VAR_16 [1], VAR_14, VAR_15, 1 );",
"if (VAR_12){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + 8*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + 8*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1 );",
"} else if (CHROMA422(VAR_0)) {",
"filter_mb_mbaff_edgecv(VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_4 + 8*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1);",
"filter_mb_mbaff_edgecv(VAR_0, VAR_5 + 8*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1);",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_4, VAR_7, bS , 1, VAR_17[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_4 + 4*VAR_7, VAR_7, bS+4, 1, VAR_17[1], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, VAR_7, bS , 1, VAR_18[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + 4*VAR_7, VAR_7, bS+4, 1, VAR_18[1], VAR_14, VAR_15, 1 );",
"}",
"}",
"}else{",
"filter_mb_mbaff_edgev ( VAR_0, VAR_3 , 2* VAR_6, bS , 2, VAR_16 [0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_3 + VAR_6, 2* VAR_6, bS+1, 2, VAR_16 [1], VAR_14, VAR_15, 1 );",
"if (VAR_12){",
"if (CHROMA444(VAR_0)) {",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4, 2*VAR_7, bS , 2, VAR_17[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_4 + VAR_7, 2*VAR_7, bS+1, 2, VAR_17[1], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5, 2*VAR_7, bS , 2, VAR_18[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgev ( VAR_0, VAR_5 + VAR_7, 2*VAR_7, bS+1, 2, VAR_18[1], VAR_14, VAR_15, 1 );",
"}else{",
"filter_mb_mbaff_edgecv( VAR_0, VAR_4, 2*VAR_7, bS , 2, VAR_17[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_4 + VAR_7, 2*VAR_7, bS+1, 2, VAR_17[1], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5, 2*VAR_7, bS , 2, VAR_18[0], VAR_14, VAR_15, 1 );",
"filter_mb_mbaff_edgecv( VAR_0, VAR_5 + VAR_7, 2*VAR_7, bS+1, 2, VAR_18[1], VAR_14, VAR_15, 1 );",
"}",
"}",
"}",
"}",
"#if CONFIG_SMALL\nfor( dir = 0; dir < 2; dir++ )",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, dir ? 0 : VAR_11, VAR_14, VAR_15, VAR_12, dir);",
"#else\nfilter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_14, VAR_15, VAR_12, 0);",
"filter_mb_dir(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, 0, VAR_14, VAR_15, VAR_12, 1);",
"#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,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
27,
31
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99,
101,
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129,
131
],
[
133
],
[
135,
137
],
[
139,
141
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
231,
233
],
[
235
],
[
237,
239
],
[
241
],
[
243,
245
]
] |
19,924 | DIRAC_PIXOP(put, ff_put, mmx)
DIRAC_PIXOP(avg, ff_avg, mmx)
DIRAC_PIXOP(avg, ff_avg, mmxext)
void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
{
if (h&3)
ff_put_dirac_pixels16_c(dst, src, stride, h);
else
ff_put_pixels16_sse2(dst, src[0], stride, h);
}
| false | FFmpeg | 6a4832caaede15e3d918b1408ff83fe30324507b | DIRAC_PIXOP(put, ff_put, mmx)
DIRAC_PIXOP(avg, ff_avg, mmx)
DIRAC_PIXOP(avg, ff_avg, mmxext)
void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
{
if (h&3)
ff_put_dirac_pixels16_c(dst, src, stride, h);
else
ff_put_pixels16_sse2(dst, src[0], stride, h);
}
| {
"code": [],
"line_no": []
} | DIRAC_PIXOP(put, ff_put, mmx)
DIRAC_PIXOP(avg, ff_avg, mmx)
DIRAC_PIXOP(avg, ff_avg, mmxext)
void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
{
if (h&3)
ff_put_dirac_pixels16_c(dst, src, stride, h);
else
ff_put_pixels16_sse2(dst, src[0], stride, h);
}
| [
"DIRAC_PIXOP(put, ff_put, mmx)\nDIRAC_PIXOP(avg, ff_avg, mmx)\nDIRAC_PIXOP(avg, ff_avg, mmxext)\nvoid ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)\n{",
"if (h&3)\nff_put_dirac_pixels16_c(dst, src, stride, h);",
"else\nff_put_pixels16_sse2(dst, src[0], stride, h);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5,
9,
11
],
[
13,
15
],
[
17,
19
],
[
21
]
] |
19,925 | static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
const char *type = backend->u.spicevmc->type;
const char **psubtype = spice_server_char_device_recognized_subtypes();
for (; *psubtype != NULL; ++psubtype) {
if (strcmp(type, *psubtype) == 0) {
break;
}
}
if (*psubtype == NULL) {
fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type);
print_allowed_subtypes();
return NULL;
}
return chr_open(type, spice_vmc_set_fe_open);
}
| false | qemu | d0d7708ba29cbcc343364a46bff981e0ff88366f | static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
const char *type = backend->u.spicevmc->type;
const char **psubtype = spice_server_char_device_recognized_subtypes();
for (; *psubtype != NULL; ++psubtype) {
if (strcmp(type, *psubtype) == 0) {
break;
}
}
if (*psubtype == NULL) {
fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type);
print_allowed_subtypes();
return NULL;
}
return chr_open(type, spice_vmc_set_fe_open);
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
const char *VAR_0 = backend->u.spicevmc->VAR_0;
const char **VAR_1 = spice_server_char_device_recognized_subtypes();
for (; *VAR_1 != NULL; ++VAR_1) {
if (strcmp(VAR_0, *VAR_1) == 0) {
break;
}
}
if (*VAR_1 == NULL) {
fprintf(stderr, "spice-qemu-char: unsupported VAR_0: %s\n", VAR_0);
print_allowed_subtypes();
return NULL;
}
return chr_open(VAR_0, spice_vmc_set_fe_open);
}
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevBackend *backend,\nChardevReturn *ret,\nError **errp)\n{",
"const char *VAR_0 = backend->u.spicevmc->VAR_0;",
"const char **VAR_1 = spice_server_char_device_recognized_subtypes();",
"for (; *VAR_1 != NULL; ++VAR_1) {",
"if (strcmp(VAR_0, *VAR_1) == 0) {",
"break;",
"}",
"}",
"if (*VAR_1 == NULL) {",
"fprintf(stderr, \"spice-qemu-char: unsupported VAR_0: %s\\n\", VAR_0);",
"print_allowed_subtypes();",
"return NULL;",
"}",
"return chr_open(VAR_0, spice_vmc_set_fe_open);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
]
] |
19,926 | void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
{
GArray *table_offsets;
unsigned facs, dsdt, rsdt;
AcpiCpuInfo cpu;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
PcPciInfo pci;
uint8_t *u;
acpi_get_cpu_info(&cpu);
acpi_get_pm_info(&pm);
acpi_get_dsdt(&misc);
acpi_get_hotplug_info(&misc);
acpi_get_misc_info(&misc);
acpi_get_pci_info(&pci);
table_offsets = g_array_new(false, true /* clear */,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF(3, "init ACPI tables\n");
bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
64 /* Ensure FACS is aligned */,
false /* high memory */);
/*
* FACS is pointed to by FADT.
* We place it first since it's the only table that has alignment
* requirements.
*/
facs = tables->table_data->len;
build_facs(tables->table_data, tables->linker, guest_info);
/* DSDT is pointed to by FADT */
dsdt = tables->table_data->len;
build_dsdt(tables->table_data, tables->linker, &misc);
/* ACPI tables pointed to by RSDT */
acpi_add_table(table_offsets, tables->table_data);
build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
acpi_add_table(table_offsets, tables->table_data);
build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
guest_info);
acpi_add_table(table_offsets, tables->table_data);
build_madt(tables->table_data, tables->linker, &cpu, guest_info);
acpi_add_table(table_offsets, tables->table_data);
if (misc.has_hpet) {
build_hpet(tables->table_data, tables->linker);
}
if (guest_info->numa_nodes) {
acpi_add_table(table_offsets, tables->table_data);
build_srat(tables->table_data, tables->linker, &cpu, guest_info);
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables->table_data);
build_mcfg_q35(tables->table_data, tables->linker, &mcfg);
}
/* Add tables supplied by user (if any) */
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables->table_data);
g_array_append_vals(tables->table_data, u, len);
}
/* RSDT is pointed to by RSDP */
rsdt = tables->table_data->len;
build_rsdt(tables->table_data, tables->linker, table_offsets);
/* RSDP is in FSEG memory, so allocate it separately */
build_rsdp(tables->rsdp, tables->linker, rsdt);
/* We'll expose it all to Guest so align size to reduce
* chance of size changes.
* RSDP is small so it's easy to keep it immutable, no need to
* bother with alignment.
*/
acpi_align_size(tables->table_data, 0x1000);
acpi_align_size(tables->linker, 0x1000);
/* Cleanup memory that's no longer used. */
g_array_free(table_offsets, true);
}
| false | qemu | 99fd437dee468609de8218f0eb3b16621fb6a9c9 | void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
{
GArray *table_offsets;
unsigned facs, dsdt, rsdt;
AcpiCpuInfo cpu;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
PcPciInfo pci;
uint8_t *u;
acpi_get_cpu_info(&cpu);
acpi_get_pm_info(&pm);
acpi_get_dsdt(&misc);
acpi_get_hotplug_info(&misc);
acpi_get_misc_info(&misc);
acpi_get_pci_info(&pci);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF(3, "init ACPI tables\n");
bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,
64 ,
false );
facs = tables->table_data->len;
build_facs(tables->table_data, tables->linker, guest_info);
dsdt = tables->table_data->len;
build_dsdt(tables->table_data, tables->linker, &misc);
acpi_add_table(table_offsets, tables->table_data);
build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
acpi_add_table(table_offsets, tables->table_data);
build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
guest_info);
acpi_add_table(table_offsets, tables->table_data);
build_madt(tables->table_data, tables->linker, &cpu, guest_info);
acpi_add_table(table_offsets, tables->table_data);
if (misc.has_hpet) {
build_hpet(tables->table_data, tables->linker);
}
if (guest_info->numa_nodes) {
acpi_add_table(table_offsets, tables->table_data);
build_srat(tables->table_data, tables->linker, &cpu, guest_info);
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, tables->table_data);
build_mcfg_q35(tables->table_data, tables->linker, &mcfg);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, tables->table_data);
g_array_append_vals(tables->table_data, u, len);
}
rsdt = tables->table_data->len;
build_rsdt(tables->table_data, tables->linker, table_offsets);
build_rsdp(tables->rsdp, tables->linker, rsdt);
acpi_align_size(tables->table_data, 0x1000);
acpi_align_size(tables->linker, 0x1000);
g_array_free(table_offsets, true);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PcGuestInfo *VAR_0, AcpiBuildTables *VAR_1)
{
GArray *table_offsets;
unsigned VAR_2, VAR_3, VAR_4;
AcpiCpuInfo cpu;
AcpiPmInfo pm;
AcpiMiscInfo misc;
AcpiMcfgInfo mcfg;
PcPciInfo pci;
uint8_t *u;
acpi_get_cpu_info(&cpu);
acpi_get_pm_info(&pm);
acpi_get_dsdt(&misc);
acpi_get_hotplug_info(&misc);
acpi_get_misc_info(&misc);
acpi_get_pci_info(&pci);
table_offsets = g_array_new(false, true ,
sizeof(uint32_t));
ACPI_BUILD_DPRINTF(3, "init ACPI VAR_1\n");
bios_linker_loader_alloc(VAR_1->linker, ACPI_BUILD_TABLE_FILE,
64 ,
false );
VAR_2 = VAR_1->table_data->len;
build_facs(VAR_1->table_data, VAR_1->linker, VAR_0);
VAR_3 = VAR_1->table_data->len;
build_dsdt(VAR_1->table_data, VAR_1->linker, &misc);
acpi_add_table(table_offsets, VAR_1->table_data);
build_fadt(VAR_1->table_data, VAR_1->linker, &pm, VAR_2, VAR_3);
acpi_add_table(table_offsets, VAR_1->table_data);
build_ssdt(VAR_1->table_data, VAR_1->linker, &cpu, &pm, &misc, &pci,
VAR_0);
acpi_add_table(table_offsets, VAR_1->table_data);
build_madt(VAR_1->table_data, VAR_1->linker, &cpu, VAR_0);
acpi_add_table(table_offsets, VAR_1->table_data);
if (misc.has_hpet) {
build_hpet(VAR_1->table_data, VAR_1->linker);
}
if (VAR_0->numa_nodes) {
acpi_add_table(table_offsets, VAR_1->table_data);
build_srat(VAR_1->table_data, VAR_1->linker, &cpu, VAR_0);
}
if (acpi_get_mcfg(&mcfg)) {
acpi_add_table(table_offsets, VAR_1->table_data);
build_mcfg_q35(VAR_1->table_data, VAR_1->linker, &mcfg);
}
for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
unsigned len = acpi_table_len(u);
acpi_add_table(table_offsets, VAR_1->table_data);
g_array_append_vals(VAR_1->table_data, u, len);
}
VAR_4 = VAR_1->table_data->len;
build_rsdt(VAR_1->table_data, VAR_1->linker, table_offsets);
build_rsdp(VAR_1->rsdp, VAR_1->linker, VAR_4);
acpi_align_size(VAR_1->table_data, 0x1000);
acpi_align_size(VAR_1->linker, 0x1000);
g_array_free(table_offsets, true);
}
| [
"void FUNC_0(PcGuestInfo *VAR_0, AcpiBuildTables *VAR_1)\n{",
"GArray *table_offsets;",
"unsigned VAR_2, VAR_3, VAR_4;",
"AcpiCpuInfo cpu;",
"AcpiPmInfo pm;",
"AcpiMiscInfo misc;",
"AcpiMcfgInfo mcfg;",
"PcPciInfo pci;",
"uint8_t *u;",
"acpi_get_cpu_info(&cpu);",
"acpi_get_pm_info(&pm);",
"acpi_get_dsdt(&misc);",
"acpi_get_hotplug_info(&misc);",
"acpi_get_misc_info(&misc);",
"acpi_get_pci_info(&pci);",
"table_offsets = g_array_new(false, true ,\nsizeof(uint32_t));",
"ACPI_BUILD_DPRINTF(3, \"init ACPI VAR_1\\n\");",
"bios_linker_loader_alloc(VAR_1->linker, ACPI_BUILD_TABLE_FILE,\n64 ,\nfalse );",
"VAR_2 = VAR_1->table_data->len;",
"build_facs(VAR_1->table_data, VAR_1->linker, VAR_0);",
"VAR_3 = VAR_1->table_data->len;",
"build_dsdt(VAR_1->table_data, VAR_1->linker, &misc);",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"build_fadt(VAR_1->table_data, VAR_1->linker, &pm, VAR_2, VAR_3);",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"build_ssdt(VAR_1->table_data, VAR_1->linker, &cpu, &pm, &misc, &pci,\nVAR_0);",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"build_madt(VAR_1->table_data, VAR_1->linker, &cpu, VAR_0);",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"if (misc.has_hpet) {",
"build_hpet(VAR_1->table_data, VAR_1->linker);",
"}",
"if (VAR_0->numa_nodes) {",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"build_srat(VAR_1->table_data, VAR_1->linker, &cpu, VAR_0);",
"}",
"if (acpi_get_mcfg(&mcfg)) {",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"build_mcfg_q35(VAR_1->table_data, VAR_1->linker, &mcfg);",
"}",
"for (u = acpi_table_first(); u; u = acpi_table_next(u)) {",
"unsigned len = acpi_table_len(u);",
"acpi_add_table(table_offsets, VAR_1->table_data);",
"g_array_append_vals(VAR_1->table_data, u, len);",
"}",
"VAR_4 = VAR_1->table_data->len;",
"build_rsdt(VAR_1->table_data, VAR_1->linker, table_offsets);",
"build_rsdp(VAR_1->rsdp, VAR_1->linker, VAR_4);",
"acpi_align_size(VAR_1->table_data, 0x1000);",
"acpi_align_size(VAR_1->linker, 0x1000);",
"g_array_free(table_offsets, true);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
45,
47,
49
],
[
63
],
[
65
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
149
],
[
163
],
[
167
],
[
173
],
[
175
]
] |
19,928 | static uint32_t xen_platform_ioport_readb(void *opaque, uint32_t addr)
{
addr &= 0xff;
if (addr == 0) {
return platform_fixed_ioport_readb(opaque, XEN_PLATFORM_IOPORT);
} else {
return ~0u;
}
}
| false | qemu | de00982e9e14e2d6ba3d148f02c5a1e94deaa985 | static uint32_t xen_platform_ioport_readb(void *opaque, uint32_t addr)
{
addr &= 0xff;
if (addr == 0) {
return platform_fixed_ioport_readb(opaque, XEN_PLATFORM_IOPORT);
} else {
return ~0u;
}
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, uint32_t addr)
{
addr &= 0xff;
if (addr == 0) {
return platform_fixed_ioport_readb(opaque, XEN_PLATFORM_IOPORT);
} else {
return ~0u;
}
}
| [
"static uint32_t FUNC_0(void *opaque, uint32_t addr)\n{",
"addr &= 0xff;",
"if (addr == 0) {",
"return platform_fixed_ioport_readb(opaque, XEN_PLATFORM_IOPORT);",
"} else {",
"return ~0u;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,929 | static ssize_t mp_pacl_getxattr(FsContext *ctx, const char *path,
const char *name, void *value, size_t size)
{
char buffer[PATH_MAX];
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS, value, size);
}
| false | qemu | 4fa4ce7107c6ec432f185307158c5df91ce54308 | static ssize_t mp_pacl_getxattr(FsContext *ctx, const char *path,
const char *name, void *value, size_t size)
{
char buffer[PATH_MAX];
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS, value, size);
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(FsContext *ctx, const char *path,
const char *name, void *value, size_t size)
{
char VAR_0[PATH_MAX];
return lgetxattr(rpath(ctx, path, VAR_0), MAP_ACL_ACCESS, value, size);
}
| [
"static ssize_t FUNC_0(FsContext *ctx, const char *path,\nconst char *name, void *value, size_t size)\n{",
"char VAR_0[PATH_MAX];",
"return lgetxattr(rpath(ctx, path, VAR_0), MAP_ACL_ACCESS, value, size);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
19,930 | void ga_command_state_init(GAState *s, GACommandState *cs)
{
if (vss_init(true)) {
ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup);
}
}
| false | qemu | 1281c08a46df94a66acca140bafc1785c0fcd47f | void ga_command_state_init(GAState *s, GACommandState *cs)
{
if (vss_init(true)) {
ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(GAState *VAR_0, GACommandState *VAR_1)
{
if (vss_init(true)) {
ga_command_state_add(VAR_1, NULL, guest_fsfreeze_cleanup);
}
}
| [
"void FUNC_0(GAState *VAR_0, GACommandState *VAR_1)\n{",
"if (vss_init(true)) {",
"ga_command_state_add(VAR_1, NULL, guest_fsfreeze_cleanup);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
19,931 | int ff_vaapi_commit_slices(FFVAContext *vactx)
{
VABufferID *slice_buf_ids;
VABufferID slice_param_buf_id, slice_data_buf_id;
if (vactx->slice_count == 0)
return 0;
slice_buf_ids =
av_fast_realloc(vactx->slice_buf_ids,
&vactx->slice_buf_ids_alloc,
(vactx->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));
if (!slice_buf_ids)
return -1;
vactx->slice_buf_ids = slice_buf_ids;
slice_param_buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
VASliceParameterBufferType,
vactx->slice_param_size,
vactx->slice_count, vactx->slice_params,
&slice_param_buf_id) != VA_STATUS_SUCCESS)
return -1;
vactx->slice_count = 0;
slice_data_buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
VASliceDataBufferType,
vactx->slice_data_size,
1, (void *)vactx->slice_data,
&slice_data_buf_id) != VA_STATUS_SUCCESS)
return -1;
vactx->slice_data = NULL;
vactx->slice_data_size = 0;
slice_buf_ids[vactx->n_slice_buf_ids++] = slice_param_buf_id;
slice_buf_ids[vactx->n_slice_buf_ids++] = slice_data_buf_id;
return 0;
}
| false | FFmpeg | 8813d55fa5978660d9f4e7dbe1f50da9922be08d | int ff_vaapi_commit_slices(FFVAContext *vactx)
{
VABufferID *slice_buf_ids;
VABufferID slice_param_buf_id, slice_data_buf_id;
if (vactx->slice_count == 0)
return 0;
slice_buf_ids =
av_fast_realloc(vactx->slice_buf_ids,
&vactx->slice_buf_ids_alloc,
(vactx->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));
if (!slice_buf_ids)
return -1;
vactx->slice_buf_ids = slice_buf_ids;
slice_param_buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
VASliceParameterBufferType,
vactx->slice_param_size,
vactx->slice_count, vactx->slice_params,
&slice_param_buf_id) != VA_STATUS_SUCCESS)
return -1;
vactx->slice_count = 0;
slice_data_buf_id = 0;
if (vaCreateBuffer(vactx->display, vactx->context_id,
VASliceDataBufferType,
vactx->slice_data_size,
1, (void *)vactx->slice_data,
&slice_data_buf_id) != VA_STATUS_SUCCESS)
return -1;
vactx->slice_data = NULL;
vactx->slice_data_size = 0;
slice_buf_ids[vactx->n_slice_buf_ids++] = slice_param_buf_id;
slice_buf_ids[vactx->n_slice_buf_ids++] = slice_data_buf_id;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(FFVAContext *VAR_0)
{
VABufferID *slice_buf_ids;
VABufferID slice_param_buf_id, slice_data_buf_id;
if (VAR_0->slice_count == 0)
return 0;
slice_buf_ids =
av_fast_realloc(VAR_0->slice_buf_ids,
&VAR_0->slice_buf_ids_alloc,
(VAR_0->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));
if (!slice_buf_ids)
return -1;
VAR_0->slice_buf_ids = slice_buf_ids;
slice_param_buf_id = 0;
if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,
VASliceParameterBufferType,
VAR_0->slice_param_size,
VAR_0->slice_count, VAR_0->slice_params,
&slice_param_buf_id) != VA_STATUS_SUCCESS)
return -1;
VAR_0->slice_count = 0;
slice_data_buf_id = 0;
if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,
VASliceDataBufferType,
VAR_0->slice_data_size,
1, (void *)VAR_0->slice_data,
&slice_data_buf_id) != VA_STATUS_SUCCESS)
return -1;
VAR_0->slice_data = NULL;
VAR_0->slice_data_size = 0;
slice_buf_ids[VAR_0->n_slice_buf_ids++] = slice_param_buf_id;
slice_buf_ids[VAR_0->n_slice_buf_ids++] = slice_data_buf_id;
return 0;
}
| [
"int FUNC_0(FFVAContext *VAR_0)\n{",
"VABufferID *slice_buf_ids;",
"VABufferID slice_param_buf_id, slice_data_buf_id;",
"if (VAR_0->slice_count == 0)\nreturn 0;",
"slice_buf_ids =\nav_fast_realloc(VAR_0->slice_buf_ids,\n&VAR_0->slice_buf_ids_alloc,\n(VAR_0->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));",
"if (!slice_buf_ids)\nreturn -1;",
"VAR_0->slice_buf_ids = slice_buf_ids;",
"slice_param_buf_id = 0;",
"if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,\nVASliceParameterBufferType,\nVAR_0->slice_param_size,\nVAR_0->slice_count, VAR_0->slice_params,\n&slice_param_buf_id) != VA_STATUS_SUCCESS)\nreturn -1;",
"VAR_0->slice_count = 0;",
"slice_data_buf_id = 0;",
"if (vaCreateBuffer(VAR_0->display, VAR_0->context_id,\nVASliceDataBufferType,\nVAR_0->slice_data_size,\n1, (void *)VAR_0->slice_data,\n&slice_data_buf_id) != VA_STATUS_SUCCESS)\nreturn -1;",
"VAR_0->slice_data = NULL;",
"VAR_0->slice_data_size = 0;",
"slice_buf_ids[VAR_0->n_slice_buf_ids++] = slice_param_buf_id;",
"slice_buf_ids[VAR_0->n_slice_buf_ids++] = slice_data_buf_id;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17,
19,
21,
23
],
[
25,
27
],
[
29
],
[
33
],
[
35,
37,
39,
41,
43,
45
],
[
47
],
[
51
],
[
53,
55,
57,
59,
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
]
] |
19,934 | static void dec_scall(DisasContext *dc)
{
TCGv t0;
int l1;
if (dc->imm5 == 7) {
LOG_DIS("scall\n");
} else if (dc->imm5 == 2) {
LOG_DIS("break\n");
} else {
cpu_abort(dc->env, "invalid opcode\n");
}
t0 = tcg_temp_new();
l1 = gen_new_label();
if (dc->imm5 == 7) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_SYSTEMCALL);
} else {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_BREAKPOINT);
}
}
| false | qemu | b798068d51ecf173702c91617793989ab843c8fb | static void dec_scall(DisasContext *dc)
{
TCGv t0;
int l1;
if (dc->imm5 == 7) {
LOG_DIS("scall\n");
} else if (dc->imm5 == 2) {
LOG_DIS("break\n");
} else {
cpu_abort(dc->env, "invalid opcode\n");
}
t0 = tcg_temp_new();
l1 = gen_new_label();
if (dc->imm5 == 7) {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_SYSTEMCALL);
} else {
tcg_gen_movi_tl(cpu_pc, dc->pc);
t_gen_raise_exception(dc, EXCP_BREAKPOINT);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
TCGv t0;
int VAR_1;
if (VAR_0->imm5 == 7) {
LOG_DIS("scall\n");
} else if (VAR_0->imm5 == 2) {
LOG_DIS("break\n");
} else {
cpu_abort(VAR_0->env, "invalid opcode\n");
}
t0 = tcg_temp_new();
VAR_1 = gen_new_label();
if (VAR_0->imm5 == 7) {
tcg_gen_movi_tl(cpu_pc, VAR_0->pc);
t_gen_raise_exception(VAR_0, EXCP_SYSTEMCALL);
} else {
tcg_gen_movi_tl(cpu_pc, VAR_0->pc);
t_gen_raise_exception(VAR_0, EXCP_BREAKPOINT);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"TCGv t0;",
"int VAR_1;",
"if (VAR_0->imm5 == 7) {",
"LOG_DIS(\"scall\\n\");",
"} else if (VAR_0->imm5 == 2) {",
"LOG_DIS(\"break\\n\");",
"} else {",
"cpu_abort(VAR_0->env, \"invalid opcode\\n\");",
"}",
"t0 = tcg_temp_new();",
"VAR_1 = gen_new_label();",
"if (VAR_0->imm5 == 7) {",
"tcg_gen_movi_tl(cpu_pc, VAR_0->pc);",
"t_gen_raise_exception(VAR_0, EXCP_SYSTEMCALL);",
"} else {",
"tcg_gen_movi_tl(cpu_pc, VAR_0->pc);",
"t_gen_raise_exception(VAR_0, EXCP_BREAKPOINT);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
19,936 | static void slavio_check_interrupts(void *opaque)
{
CPUState *env;
SLAVIO_INTCTLState *s = opaque;
uint32_t pending = s->intregm_pending;
unsigned int i, j, max = 0;
pending &= ~s->intregm_disabled;
if (pending && !(s->intregm_disabled & 0x80000000)) {
for (i = 0; i < 32; i++) {
if (pending & (1 << i)) {
if (max < s->intbit_to_level[i])
max = s->intbit_to_level[i];
}
}
env = s->cpu_envs[s->target_cpu];
if (!env) {
DPRINTF("No CPU %d, not triggered (pending %x)\n", s->target_cpu, pending);
}
else {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered CPU %d pil %d\n", s->target_cpu, max);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[max]++;
#endif
env->interrupt_index = TT_EXTINT | max;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
else
DPRINTF("Not triggered (pending %x), pending exception %x\n", pending, env->interrupt_index);
}
}
else
DPRINTF("Not triggered (pending %x), disabled %x\n", pending, s->intregm_disabled);
for (i = 0; i < MAX_CPUS; i++) {
max = 0;
env = s->cpu_envs[i];
if (!env)
continue;
for (j = 17; j < 32; j++) {
if (s->intreg_pending[i] & (1 << j)) {
if (max < j - 16)
max = j - 16;
}
}
if (max > 0) {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered softint %d for cpu %d (pending %x)\n", max, i, pending);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[max]++;
#endif
env->interrupt_index = TT_EXTINT | max;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
}
}
}
| false | qemu | b3a2319792ad5c0f0f8c3d2f4d02b95fd7efbc69 | static void slavio_check_interrupts(void *opaque)
{
CPUState *env;
SLAVIO_INTCTLState *s = opaque;
uint32_t pending = s->intregm_pending;
unsigned int i, j, max = 0;
pending &= ~s->intregm_disabled;
if (pending && !(s->intregm_disabled & 0x80000000)) {
for (i = 0; i < 32; i++) {
if (pending & (1 << i)) {
if (max < s->intbit_to_level[i])
max = s->intbit_to_level[i];
}
}
env = s->cpu_envs[s->target_cpu];
if (!env) {
DPRINTF("No CPU %d, not triggered (pending %x)\n", s->target_cpu, pending);
}
else {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered CPU %d pil %d\n", s->target_cpu, max);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[max]++;
#endif
env->interrupt_index = TT_EXTINT | max;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
else
DPRINTF("Not triggered (pending %x), pending exception %x\n", pending, env->interrupt_index);
}
}
else
DPRINTF("Not triggered (pending %x), disabled %x\n", pending, s->intregm_disabled);
for (i = 0; i < MAX_CPUS; i++) {
max = 0;
env = s->cpu_envs[i];
if (!env)
continue;
for (j = 17; j < 32; j++) {
if (s->intreg_pending[i] & (1 << j)) {
if (max < j - 16)
max = j - 16;
}
}
if (max > 0) {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered softint %d for cpu %d (pending %x)\n", max, i, pending);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[max]++;
#endif
env->interrupt_index = TT_EXTINT | max;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
CPUState *env;
SLAVIO_INTCTLState *s = VAR_0;
uint32_t pending = s->intregm_pending;
unsigned int VAR_1, VAR_2, VAR_3 = 0;
pending &= ~s->intregm_disabled;
if (pending && !(s->intregm_disabled & 0x80000000)) {
for (VAR_1 = 0; VAR_1 < 32; VAR_1++) {
if (pending & (1 << VAR_1)) {
if (VAR_3 < s->intbit_to_level[VAR_1])
VAR_3 = s->intbit_to_level[VAR_1];
}
}
env = s->cpu_envs[s->target_cpu];
if (!env) {
DPRINTF("No CPU %d, not triggered (pending %x)\n", s->target_cpu, pending);
}
else {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered CPU %d pil %d\n", s->target_cpu, VAR_3);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[VAR_3]++;
#endif
env->interrupt_index = TT_EXTINT | VAR_3;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
else
DPRINTF("Not triggered (pending %x), pending exception %x\n", pending, env->interrupt_index);
}
}
else
DPRINTF("Not triggered (pending %x), disabled %x\n", pending, s->intregm_disabled);
for (VAR_1 = 0; VAR_1 < MAX_CPUS; VAR_1++) {
VAR_3 = 0;
env = s->cpu_envs[VAR_1];
if (!env)
continue;
for (VAR_2 = 17; VAR_2 < 32; VAR_2++) {
if (s->intreg_pending[VAR_1] & (1 << VAR_2)) {
if (VAR_3 < VAR_2 - 16)
VAR_3 = VAR_2 - 16;
}
}
if (VAR_3 > 0) {
if (env->halted)
env->halted = 0;
if (env->interrupt_index == 0) {
DPRINTF("Triggered softint %d for cpu %d (pending %x)\n", VAR_3, VAR_1, pending);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[VAR_3]++;
#endif
env->interrupt_index = TT_EXTINT | VAR_3;
cpu_interrupt(env, CPU_INTERRUPT_HARD);
}
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"CPUState *env;",
"SLAVIO_INTCTLState *s = VAR_0;",
"uint32_t pending = s->intregm_pending;",
"unsigned int VAR_1, VAR_2, VAR_3 = 0;",
"pending &= ~s->intregm_disabled;",
"if (pending && !(s->intregm_disabled & 0x80000000)) {",
"for (VAR_1 = 0; VAR_1 < 32; VAR_1++) {",
"if (pending & (1 << VAR_1)) {",
"if (VAR_3 < s->intbit_to_level[VAR_1])\nVAR_3 = s->intbit_to_level[VAR_1];",
"}",
"}",
"env = s->cpu_envs[s->target_cpu];",
"if (!env) {",
"DPRINTF(\"No CPU %d, not triggered (pending %x)\\n\", s->target_cpu, pending);",
"}",
"else {",
"if (env->halted)\nenv->halted = 0;",
"if (env->interrupt_index == 0) {",
"DPRINTF(\"Triggered CPU %d pil %d\\n\", s->target_cpu, VAR_3);",
"#ifdef DEBUG_IRQ_COUNT\ns->irq_count[VAR_3]++;",
"#endif\nenv->interrupt_index = TT_EXTINT | VAR_3;",
"cpu_interrupt(env, CPU_INTERRUPT_HARD);",
"}",
"else\nDPRINTF(\"Not triggered (pending %x), pending exception %x\\n\", pending, env->interrupt_index);",
"}",
"}",
"else\nDPRINTF(\"Not triggered (pending %x), disabled %x\\n\", pending, s->intregm_disabled);",
"for (VAR_1 = 0; VAR_1 < MAX_CPUS; VAR_1++) {",
"VAR_3 = 0;",
"env = s->cpu_envs[VAR_1];",
"if (!env)\ncontinue;",
"for (VAR_2 = 17; VAR_2 < 32; VAR_2++) {",
"if (s->intreg_pending[VAR_1] & (1 << VAR_2)) {",
"if (VAR_3 < VAR_2 - 16)\nVAR_3 = VAR_2 - 16;",
"}",
"}",
"if (VAR_3 > 0) {",
"if (env->halted)\nenv->halted = 0;",
"if (env->interrupt_index == 0) {",
"DPRINTF(\"Triggered softint %d for cpu %d (pending %x)\\n\", VAR_3, VAR_1, pending);",
"#ifdef DEBUG_IRQ_COUNT\ns->irq_count[VAR_3]++;",
"#endif\nenv->interrupt_index = TT_EXTINT | VAR_3;",
"cpu_interrupt(env, CPU_INTERRUPT_HARD);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
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
]
] |
19,937 | static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
{
int size;
char *path;
void *ptr;
char name[32];
const VMStateDescription *vmsd;
if (!pdev->romfile)
return 0;
if (strlen(pdev->romfile) == 0)
return 0;
if (!pdev->rom_bar) {
/*
* Load rom via fw_cfg instead of creating a rom bar,
* for 0.11 compatibility.
*/
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
rom_add_option(pdev->romfile, -1);
}
return 0;
}
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = g_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
g_free(path);
return -1;
}
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
vmsd = qdev_get_vmsd(DEVICE(pdev));
if (vmsd) {
snprintf(name, sizeof(name), "%s.rom", vmsd->name);
} else {
snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev)));
}
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, name, size);
vmstate_register_ram(&pdev->rom, &pdev->qdev);
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
g_free(path);
if (is_default_rom) {
/* Only the default rom images will be patched (if needed). */
pci_patch_ids(pdev, ptr, size);
}
qemu_put_ram_ptr(ptr);
pci_register_bar(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
return 0;
}
| false | qemu | 8c7f3dd05e4f1ee90000c89e428e69ae2e6bd691 | static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
{
int size;
char *path;
void *ptr;
char name[32];
const VMStateDescription *vmsd;
if (!pdev->romfile)
return 0;
if (strlen(pdev->romfile) == 0)
return 0;
if (!pdev->rom_bar) {
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
rom_add_option(pdev->romfile, -1);
}
return 0;
}
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
if (path == NULL) {
path = g_strdup(pdev->romfile);
}
size = get_image_size(path);
if (size < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, pdev->romfile);
g_free(path);
return -1;
}
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
vmsd = qdev_get_vmsd(DEVICE(pdev));
if (vmsd) {
snprintf(name, sizeof(name), "%s.rom", vmsd->name);
} else {
snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev)));
}
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, name, size);
vmstate_register_ram(&pdev->rom, &pdev->qdev);
ptr = memory_region_get_ram_ptr(&pdev->rom);
load_image(path, ptr);
g_free(path);
if (is_default_rom) {
pci_patch_ids(pdev, ptr, size);
}
qemu_put_ram_ptr(ptr);
pci_register_bar(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, bool VAR_1)
{
int VAR_2;
char *VAR_3;
void *VAR_4;
char VAR_5[32];
const VMStateDescription *VAR_6;
if (!VAR_0->romfile)
return 0;
if (strlen(VAR_0->romfile) == 0)
return 0;
if (!VAR_0->rom_bar) {
int VAR_7 = pci_get_word(VAR_0->config + PCI_CLASS_DEVICE);
if (VAR_7 == 0x0300) {
rom_add_vga(VAR_0->romfile);
} else {
rom_add_option(VAR_0->romfile, -1);
}
return 0;
}
VAR_3 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0->romfile);
if (VAR_3 == NULL) {
VAR_3 = g_strdup(VAR_0->romfile);
}
VAR_2 = get_image_size(VAR_3);
if (VAR_2 < 0) {
error_report("%s: failed to find romfile \"%s\"",
__FUNCTION__, VAR_0->romfile);
g_free(VAR_3);
return -1;
}
if (VAR_2 & (VAR_2 - 1)) {
VAR_2 = 1 << qemu_fls(VAR_2);
}
VAR_6 = qdev_get_vmsd(DEVICE(VAR_0));
if (VAR_6) {
snprintf(VAR_5, sizeof(VAR_5), "%s.rom", VAR_6->VAR_5);
} else {
snprintf(VAR_5, sizeof(VAR_5), "%s.rom", object_get_typename(OBJECT(VAR_0)));
}
VAR_0->has_rom = true;
memory_region_init_ram(&VAR_0->rom, VAR_5, VAR_2);
vmstate_register_ram(&VAR_0->rom, &VAR_0->qdev);
VAR_4 = memory_region_get_ram_ptr(&VAR_0->rom);
load_image(VAR_3, VAR_4);
g_free(VAR_3);
if (VAR_1) {
pci_patch_ids(VAR_0, VAR_4, VAR_2);
}
qemu_put_ram_ptr(VAR_4);
pci_register_bar(VAR_0, PCI_ROM_SLOT, 0, &VAR_0->rom);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, bool VAR_1)\n{",
"int VAR_2;",
"char *VAR_3;",
"void *VAR_4;",
"char VAR_5[32];",
"const VMStateDescription *VAR_6;",
"if (!VAR_0->romfile)\nreturn 0;",
"if (strlen(VAR_0->romfile) == 0)\nreturn 0;",
"if (!VAR_0->rom_bar) {",
"int VAR_7 = pci_get_word(VAR_0->config + PCI_CLASS_DEVICE);",
"if (VAR_7 == 0x0300) {",
"rom_add_vga(VAR_0->romfile);",
"} else {",
"rom_add_option(VAR_0->romfile, -1);",
"}",
"return 0;",
"}",
"VAR_3 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0->romfile);",
"if (VAR_3 == NULL) {",
"VAR_3 = g_strdup(VAR_0->romfile);",
"}",
"VAR_2 = get_image_size(VAR_3);",
"if (VAR_2 < 0) {",
"error_report(\"%s: failed to find romfile \\\"%s\\\"\",\n__FUNCTION__, VAR_0->romfile);",
"g_free(VAR_3);",
"return -1;",
"}",
"if (VAR_2 & (VAR_2 - 1)) {",
"VAR_2 = 1 << qemu_fls(VAR_2);",
"}",
"VAR_6 = qdev_get_vmsd(DEVICE(VAR_0));",
"if (VAR_6) {",
"snprintf(VAR_5, sizeof(VAR_5), \"%s.rom\", VAR_6->VAR_5);",
"} else {",
"snprintf(VAR_5, sizeof(VAR_5), \"%s.rom\", object_get_typename(OBJECT(VAR_0)));",
"}",
"VAR_0->has_rom = true;",
"memory_region_init_ram(&VAR_0->rom, VAR_5, VAR_2);",
"vmstate_register_ram(&VAR_0->rom, &VAR_0->qdev);",
"VAR_4 = memory_region_get_ram_ptr(&VAR_0->rom);",
"load_image(VAR_3, VAR_4);",
"g_free(VAR_3);",
"if (VAR_1) {",
"pci_patch_ids(VAR_0, VAR_4, VAR_2);",
"}",
"qemu_put_ram_ptr(VAR_4);",
"pci_register_bar(VAR_0, PCI_ROM_SLOT, 0, &VAR_0->rom);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
27
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
125
],
[
129
],
[
133
],
[
135
]
] |
19,938 | static char *qemu_rbd_next_tok(int max_len,
char *src, char delim,
const char *name,
char **p, Error **errp)
{
int l;
char *end;
*p = NULL;
if (delim != '\0') {
for (end = src; *end; ++end) {
if (*end == delim) {
break;
}
if (*end == '\\' && end[1] != '\0') {
end++;
}
}
if (*end == delim) {
*p = end + 1;
*end = '\0';
}
}
l = strlen(src);
if (l >= max_len) {
error_setg(errp, "%s too long", name);
return NULL;
} else if (l == 0) {
error_setg(errp, "%s too short", name);
return NULL;
}
return src;
}
| false | qemu | 730b00bbfdc15f914f47e03a703fa7647c10c4a9 | static char *qemu_rbd_next_tok(int max_len,
char *src, char delim,
const char *name,
char **p, Error **errp)
{
int l;
char *end;
*p = NULL;
if (delim != '\0') {
for (end = src; *end; ++end) {
if (*end == delim) {
break;
}
if (*end == '\\' && end[1] != '\0') {
end++;
}
}
if (*end == delim) {
*p = end + 1;
*end = '\0';
}
}
l = strlen(src);
if (l >= max_len) {
error_setg(errp, "%s too long", name);
return NULL;
} else if (l == 0) {
error_setg(errp, "%s too short", name);
return NULL;
}
return src;
}
| {
"code": [],
"line_no": []
} | static char *FUNC_0(int VAR_0,
char *VAR_1, char VAR_2,
const char *VAR_3,
char **VAR_4, Error **VAR_5)
{
int VAR_6;
char *VAR_7;
*VAR_4 = NULL;
if (VAR_2 != '\0') {
for (VAR_7 = VAR_1; *VAR_7; ++VAR_7) {
if (*VAR_7 == VAR_2) {
break;
}
if (*VAR_7 == '\\' && VAR_7[1] != '\0') {
VAR_7++;
}
}
if (*VAR_7 == VAR_2) {
*VAR_4 = VAR_7 + 1;
*VAR_7 = '\0';
}
}
VAR_6 = strlen(VAR_1);
if (VAR_6 >= VAR_0) {
error_setg(VAR_5, "%s too long", VAR_3);
return NULL;
} else if (VAR_6 == 0) {
error_setg(VAR_5, "%s too short", VAR_3);
return NULL;
}
return VAR_1;
}
| [
"static char *FUNC_0(int VAR_0,\nchar *VAR_1, char VAR_2,\nconst char *VAR_3,\nchar **VAR_4, Error **VAR_5)\n{",
"int VAR_6;",
"char *VAR_7;",
"*VAR_4 = NULL;",
"if (VAR_2 != '\\0') {",
"for (VAR_7 = VAR_1; *VAR_7; ++VAR_7) {",
"if (*VAR_7 == VAR_2) {",
"break;",
"}",
"if (*VAR_7 == '\\\\' && VAR_7[1] != '\\0') {",
"VAR_7++;",
"}",
"}",
"if (*VAR_7 == VAR_2) {",
"*VAR_4 = VAR_7 + 1;",
"*VAR_7 = '\\0';",
"}",
"}",
"VAR_6 = strlen(VAR_1);",
"if (VAR_6 >= VAR_0) {",
"error_setg(VAR_5, \"%s too long\", VAR_3);",
"return NULL;",
"} else if (VAR_6 == 0) {",
"error_setg(VAR_5, \"%s too short\", VAR_3);",
"return 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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
19,939 | static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len)
{
int auth = read_u32(data, 0);
if (auth != vs->vd->subauth) {
VNC_DEBUG("Rejecting auth %d\n", auth);
vnc_write_u8(vs, 0); /* Reject auth */
vnc_flush(vs);
vnc_client_error(vs);
} else {
VNC_DEBUG("Accepting auth %d, setting up TLS for handshake\n", auth);
vnc_write_u8(vs, 1); /* Accept auth */
vnc_flush(vs);
if (vnc_tls_client_setup(vs, NEED_X509_AUTH(vs)) < 0) {
VNC_DEBUG("Failed to setup TLS\n");
return 0;
}
VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
if (vnc_start_vencrypt_handshake(vs) < 0) {
VNC_DEBUG("Failed to start TLS handshake\n");
return 0;
}
}
return 0;
}
| false | qemu | 7e7e2ebc942da8285931ceabf12823e165dced8b | static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len)
{
int auth = read_u32(data, 0);
if (auth != vs->vd->subauth) {
VNC_DEBUG("Rejecting auth %d\n", auth);
vnc_write_u8(vs, 0);
vnc_flush(vs);
vnc_client_error(vs);
} else {
VNC_DEBUG("Accepting auth %d, setting up TLS for handshake\n", auth);
vnc_write_u8(vs, 1);
vnc_flush(vs);
if (vnc_tls_client_setup(vs, NEED_X509_AUTH(vs)) < 0) {
VNC_DEBUG("Failed to setup TLS\n");
return 0;
}
VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
if (vnc_start_vencrypt_handshake(vs) < 0) {
VNC_DEBUG("Failed to start TLS handshake\n");
return 0;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)
{
int VAR_3 = read_u32(VAR_1, 0);
if (VAR_3 != VAR_0->vd->subauth) {
VNC_DEBUG("Rejecting VAR_3 %d\n", VAR_3);
vnc_write_u8(VAR_0, 0);
vnc_flush(VAR_0);
vnc_client_error(VAR_0);
} else {
VNC_DEBUG("Accepting VAR_3 %d, setting up TLS for handshake\n", VAR_3);
vnc_write_u8(VAR_0, 1);
vnc_flush(VAR_0);
if (vnc_tls_client_setup(VAR_0, NEED_X509_AUTH(VAR_0)) < 0) {
VNC_DEBUG("Failed to setup TLS\n");
return 0;
}
VNC_DEBUG("Start TLS VeNCrypt handshake process\n");
if (vnc_start_vencrypt_handshake(VAR_0) < 0) {
VNC_DEBUG("Failed to start TLS handshake\n");
return 0;
}
}
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{",
"int VAR_3 = read_u32(VAR_1, 0);",
"if (VAR_3 != VAR_0->vd->subauth) {",
"VNC_DEBUG(\"Rejecting VAR_3 %d\\n\", VAR_3);",
"vnc_write_u8(VAR_0, 0);",
"vnc_flush(VAR_0);",
"vnc_client_error(VAR_0);",
"} else {",
"VNC_DEBUG(\"Accepting VAR_3 %d, setting up TLS for handshake\\n\", VAR_3);",
"vnc_write_u8(VAR_0, 1);",
"vnc_flush(VAR_0);",
"if (vnc_tls_client_setup(VAR_0, NEED_X509_AUTH(VAR_0)) < 0) {",
"VNC_DEBUG(\"Failed to setup TLS\\n\");",
"return 0;",
"}",
"VNC_DEBUG(\"Start TLS VeNCrypt handshake process\\n\");",
"if (vnc_start_vencrypt_handshake(VAR_0) < 0) {",
"VNC_DEBUG(\"Failed to start TLS handshake\\n\");",
"return 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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
19,940 | int64_t qemu_strtosz_metric(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'B', 1000);
}
| false | qemu | f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7 | int64_t qemu_strtosz_metric(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'B', 1000);
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'B', 1000);
}
| [
"int64_t FUNC_0(const char *nptr, char **end)\n{",
"return do_strtosz(nptr, end, 'B', 1000);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
19,941 | static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table)
{
BDRVQcow2State *s = bs->opaque;
int ret;
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);
return ret;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
uint64_t **l2_table)
{
BDRVQcow2State *s = bs->opaque;
int ret;
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t **VAR_2)
{
BDRVQcow2State *s = VAR_0->opaque;
int VAR_3;
VAR_3 = qcow2_cache_get(VAR_0, s->l2_table_cache, VAR_1, (void**) VAR_2);
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t **VAR_2)\n{",
"BDRVQcow2State *s = VAR_0->opaque;",
"int VAR_3;",
"VAR_3 = qcow2_cache_get(VAR_0, s->l2_table_cache, VAR_1, (void**) VAR_2);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
]
] |
19,942 | static int mjpeg_decode_init(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
MpegEncContext s2;
s->avctx = avctx;
/* ugly way to get the idct & scantable */
memset(&s2, 0, sizeof(MpegEncContext));
s2.flags= avctx->flags;
s2.avctx= avctx;
// s2->out_format = FMT_MJPEG;
s2.width = 8;
s2.height = 8;
if (MPV_common_init(&s2) < 0)
return -1;
s->scantable= s2.intra_scantable;
s->idct_put= s2.idct_put;
MPV_common_end(&s2);
s->mpeg_enc_ctx_allocated = 0;
s->buffer_size = 102400; /* smaller buffer should be enough,
but photojpg files could ahive bigger sizes */
s->buffer = av_malloc(s->buffer_size);
if (!s->buffer)
return -1;
s->start_code = -1;
s->first_picture = 1;
s->org_width = avctx->width;
s->org_height = avctx->height;
build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
{
printf("mjpeg: using external huffman table\n");
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size);
mjpeg_decode_dht(s);
/* should check for error - but dunno */
}
return 0;
}
| false | FFmpeg | 68f593b48433842f3407586679fe07f3e5199ab9 | static int mjpeg_decode_init(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
MpegEncContext s2;
s->avctx = avctx;
memset(&s2, 0, sizeof(MpegEncContext));
s2.flags= avctx->flags;
s2.avctx= avctx;
s2.width = 8;
s2.height = 8;
if (MPV_common_init(&s2) < 0)
return -1;
s->scantable= s2.intra_scantable;
s->idct_put= s2.idct_put;
MPV_common_end(&s2);
s->mpeg_enc_ctx_allocated = 0;
s->buffer_size = 102400;
s->buffer = av_malloc(s->buffer_size);
if (!s->buffer)
return -1;
s->start_code = -1;
s->first_picture = 1;
s->org_width = avctx->width;
s->org_height = avctx->height;
build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
{
printf("mjpeg: using external huffman table\n");
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size);
mjpeg_decode_dht(s);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
MJpegDecodeContext *s = VAR_0->priv_data;
MpegEncContext s2;
s->VAR_0 = VAR_0;
memset(&s2, 0, sizeof(MpegEncContext));
s2.flags= VAR_0->flags;
s2.VAR_0= VAR_0;
s2.width = 8;
s2.height = 8;
if (MPV_common_init(&s2) < 0)
return -1;
s->scantable= s2.intra_scantable;
s->idct_put= s2.idct_put;
MPV_common_end(&s2);
s->mpeg_enc_ctx_allocated = 0;
s->buffer_size = 102400;
s->buffer = av_malloc(s->buffer_size);
if (!s->buffer)
return -1;
s->start_code = -1;
s->first_picture = 1;
s->org_width = VAR_0->width;
s->org_height = VAR_0->height;
build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
if (VAR_0->flags & CODEC_FLAG_EXTERN_HUFF)
{
printf("mjpeg: using external huffman table\n");
init_get_bits(&s->gb, VAR_0->extradata, VAR_0->extradata_size);
mjpeg_decode_dht(s);
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"MJpegDecodeContext *s = VAR_0->priv_data;",
"MpegEncContext s2;",
"s->VAR_0 = VAR_0;",
"memset(&s2, 0, sizeof(MpegEncContext));",
"s2.flags= VAR_0->flags;",
"s2.VAR_0= VAR_0;",
"s2.width = 8;",
"s2.height = 8;",
"if (MPV_common_init(&s2) < 0)\nreturn -1;",
"s->scantable= s2.intra_scantable;",
"s->idct_put= s2.idct_put;",
"MPV_common_end(&s2);",
"s->mpeg_enc_ctx_allocated = 0;",
"s->buffer_size = 102400;",
"s->buffer = av_malloc(s->buffer_size);",
"if (!s->buffer)\nreturn -1;",
"s->start_code = -1;",
"s->first_picture = 1;",
"s->org_width = VAR_0->width;",
"s->org_height = VAR_0->height;",
"build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);",
"build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);",
"build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);",
"build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);",
"if (VAR_0->flags & CODEC_FLAG_EXTERN_HUFF)\n{",
"printf(\"mjpeg: using external huffman table\\n\");",
"init_get_bits(&s->gb, VAR_0->extradata, VAR_0->extradata_size);",
"mjpeg_decode_dht(s);",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
]
] |
19,943 | static int pci_std_vga_initfn(PCIDevice *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
VGACommonState *s = &d->vga;
/* vga + console init */
vga_common_init(s);
vga_init(s, pci_address_space(dev), pci_address_space_io(dev), true);
s->con = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
/* XXX: VGA_RAM_SIZE must be a power of two */
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
/* mmio bar for vga register access */
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {
memory_region_init(&d->mmio, "vga.mmio", 4096);
memory_region_init_io(&d->ioport, &pci_vga_ioport_ops, d,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_init_io(&d->bochs, &pci_vga_bochs_ops, d,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,
&d->ioport);
memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,
&d->bochs);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
if (!dev->rom_bar) {
/* compatibility with pc-0.13 and older */
vga_init_vbe(s, pci_address_space(dev));
}
return 0;
}
| false | qemu | 2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5 | static int pci_std_vga_initfn(PCIDevice *dev)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
VGACommonState *s = &d->vga;
vga_common_init(s);
vga_init(s, pci_address_space(dev), pci_address_space_io(dev), true);
s->con = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {
memory_region_init(&d->mmio, "vga.mmio", 4096);
memory_region_init_io(&d->ioport, &pci_vga_ioport_ops, d,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_init_io(&d->bochs, &pci_vga_bochs_ops, d,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,
&d->ioport);
memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,
&d->bochs);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
if (!dev->rom_bar) {
vga_init_vbe(s, pci_address_space(dev));
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
PCIVGAState *d = DO_UPCAST(PCIVGAState, VAR_0, VAR_0);
VGACommonState *s = &d->vga;
vga_common_init(s);
vga_init(s, pci_address_space(VAR_0), pci_address_space_io(VAR_0), true);
s->con = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
pci_register_bar(&d->VAR_0, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {
memory_region_init(&d->mmio, "vga.mmio", 4096);
memory_region_init_io(&d->ioport, &pci_vga_ioport_ops, d,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
memory_region_init_io(&d->bochs, &pci_vga_bochs_ops, d,
"bochs dispi interface", PCI_VGA_BOCHS_SIZE);
memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,
&d->ioport);
memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,
&d->bochs);
pci_register_bar(&d->VAR_0, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
if (!VAR_0->rom_bar) {
vga_init_vbe(s, pci_address_space(VAR_0));
}
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"PCIVGAState *d = DO_UPCAST(PCIVGAState, VAR_0, VAR_0);",
"VGACommonState *s = &d->vga;",
"vga_common_init(s);",
"vga_init(s, pci_address_space(VAR_0), pci_address_space_io(VAR_0), true);",
"s->con = graphic_console_init(s->update, s->invalidate,\ns->screen_dump, s->text_update, s);",
"pci_register_bar(&d->VAR_0, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);",
"if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_MMIO)) {",
"memory_region_init(&d->mmio, \"vga.mmio\", 4096);",
"memory_region_init_io(&d->ioport, &pci_vga_ioport_ops, d,\n\"vga ioports remapped\", PCI_VGA_IOPORT_SIZE);",
"memory_region_init_io(&d->bochs, &pci_vga_bochs_ops, d,\n\"bochs dispi interface\", PCI_VGA_BOCHS_SIZE);",
"memory_region_add_subregion(&d->mmio, PCI_VGA_IOPORT_OFFSET,\n&d->ioport);",
"memory_region_add_subregion(&d->mmio, PCI_VGA_BOCHS_OFFSET,\n&d->bochs);",
"pci_register_bar(&d->VAR_0, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);",
"}",
"if (!VAR_0->rom_bar) {",
"vga_init_vbe(s, pci_address_space(VAR_0));",
"}",
"return 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
],
[
13
],
[
15
],
[
19,
21
],
[
27
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
19,944 | static int tosa_dac_recv(I2CSlave *s)
{
printf("%s: recv not supported!!!\n", __FUNCTION__);
return -1;
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static int tosa_dac_recv(I2CSlave *s)
{
printf("%s: recv not supported!!!\n", __FUNCTION__);
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(I2CSlave *VAR_0)
{
printf("%VAR_0: recv not supported!!!\n", __FUNCTION__);
return -1;
}
| [
"static int FUNC_0(I2CSlave *VAR_0)\n{",
"printf(\"%VAR_0: recv not supported!!!\\n\", __FUNCTION__);",
"return -1;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
19,945 | static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)
{
memset (wfx, 0, sizeof (*wfx));
wfx->wFormatTag = WAVE_FORMAT_PCM;
wfx->nChannels = as->nchannels;
wfx->nSamplesPerSec = as->freq;
wfx->nAvgBytesPerSec = as->freq << (as->nchannels == 2);
wfx->nBlockAlign = 1 << (as->nchannels == 2);
wfx->cbSize = 0;
switch (as->fmt) {
case AUD_FMT_S8:
case AUD_FMT_U8:
wfx->wBitsPerSample = 8;
break;
case AUD_FMT_S16:
case AUD_FMT_U16:
wfx->wBitsPerSample = 16;
wfx->nAvgBytesPerSec <<= 1;
wfx->nBlockAlign <<= 1;
break;
case AUD_FMT_S32:
case AUD_FMT_U32:
wfx->wBitsPerSample = 32;
wfx->nAvgBytesPerSec <<= 2;
wfx->nBlockAlign <<= 2;
break;
default:
dolog ("Internal logic error: Bad audio format %d\n", as->freq);
return -1;
}
return 0;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)
{
memset (wfx, 0, sizeof (*wfx));
wfx->wFormatTag = WAVE_FORMAT_PCM;
wfx->nChannels = as->nchannels;
wfx->nSamplesPerSec = as->freq;
wfx->nAvgBytesPerSec = as->freq << (as->nchannels == 2);
wfx->nBlockAlign = 1 << (as->nchannels == 2);
wfx->cbSize = 0;
switch (as->fmt) {
case AUD_FMT_S8:
case AUD_FMT_U8:
wfx->wBitsPerSample = 8;
break;
case AUD_FMT_S16:
case AUD_FMT_U16:
wfx->wBitsPerSample = 16;
wfx->nAvgBytesPerSec <<= 1;
wfx->nBlockAlign <<= 1;
break;
case AUD_FMT_S32:
case AUD_FMT_U32:
wfx->wBitsPerSample = 32;
wfx->nAvgBytesPerSec <<= 2;
wfx->nBlockAlign <<= 2;
break;
default:
dolog ("Internal logic error: Bad audio format %d\n", as->freq);
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (WAVEFORMATEX *VAR_0, audsettings_t *VAR_1)
{
memset (VAR_0, 0, sizeof (*VAR_0));
VAR_0->wFormatTag = WAVE_FORMAT_PCM;
VAR_0->nChannels = VAR_1->nchannels;
VAR_0->nSamplesPerSec = VAR_1->freq;
VAR_0->nAvgBytesPerSec = VAR_1->freq << (VAR_1->nchannels == 2);
VAR_0->nBlockAlign = 1 << (VAR_1->nchannels == 2);
VAR_0->cbSize = 0;
switch (VAR_1->fmt) {
case AUD_FMT_S8:
case AUD_FMT_U8:
VAR_0->wBitsPerSample = 8;
break;
case AUD_FMT_S16:
case AUD_FMT_U16:
VAR_0->wBitsPerSample = 16;
VAR_0->nAvgBytesPerSec <<= 1;
VAR_0->nBlockAlign <<= 1;
break;
case AUD_FMT_S32:
case AUD_FMT_U32:
VAR_0->wBitsPerSample = 32;
VAR_0->nAvgBytesPerSec <<= 2;
VAR_0->nBlockAlign <<= 2;
break;
default:
dolog ("Internal logic error: Bad audio format %d\n", VAR_1->freq);
return -1;
}
return 0;
}
| [
"static int FUNC_0 (WAVEFORMATEX *VAR_0, audsettings_t *VAR_1)\n{",
"memset (VAR_0, 0, sizeof (*VAR_0));",
"VAR_0->wFormatTag = WAVE_FORMAT_PCM;",
"VAR_0->nChannels = VAR_1->nchannels;",
"VAR_0->nSamplesPerSec = VAR_1->freq;",
"VAR_0->nAvgBytesPerSec = VAR_1->freq << (VAR_1->nchannels == 2);",
"VAR_0->nBlockAlign = 1 << (VAR_1->nchannels == 2);",
"VAR_0->cbSize = 0;",
"switch (VAR_1->fmt) {",
"case AUD_FMT_S8:\ncase AUD_FMT_U8:\nVAR_0->wBitsPerSample = 8;",
"break;",
"case AUD_FMT_S16:\ncase AUD_FMT_U16:\nVAR_0->wBitsPerSample = 16;",
"VAR_0->nAvgBytesPerSec <<= 1;",
"VAR_0->nBlockAlign <<= 1;",
"break;",
"case AUD_FMT_S32:\ncase AUD_FMT_U32:\nVAR_0->wBitsPerSample = 32;",
"VAR_0->nAvgBytesPerSec <<= 2;",
"VAR_0->nBlockAlign <<= 2;",
"break;",
"default:\ndolog (\"Internal logic error: Bad audio format %d\\n\", VAR_1->freq);",
"return -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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27,
29
],
[
31
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
19,946 | static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}
| false | qemu | d8b7e0adf562277180f96ecbd7f1777a384a0308 | static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}
| {
"code": [],
"line_no": []
} | static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}
| [
"static BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockDriverCompletionFunc *cb, void *opaque)\n{",
"return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
]
] |
19,947 | static int blk_mig_save_dirty_block(Monitor *mon, QEMUFile *f, int is_async)
{
BlkMigDevState *bmds;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (mig_save_device_dirty(mon, f, bmds, is_async) == 0) {
ret = 1;
break;
}
}
return ret;
}
| false | qemu | 539de1246d355d3b8aa33fb7cde732352d8827c7 | static int blk_mig_save_dirty_block(Monitor *mon, QEMUFile *f, int is_async)
{
BlkMigDevState *bmds;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (mig_save_device_dirty(mon, f, bmds, is_async) == 0) {
ret = 1;
break;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1, int VAR_2)
{
BlkMigDevState *bmds;
int VAR_3 = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (mig_save_device_dirty(VAR_0, VAR_1, bmds, VAR_2) == 0) {
VAR_3 = 1;
break;
}
}
return VAR_3;
}
| [
"static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1, int VAR_2)\n{",
"BlkMigDevState *bmds;",
"int VAR_3 = 0;",
"QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {",
"if (mig_save_device_dirty(VAR_0, VAR_1, bmds, VAR_2) == 0) {",
"VAR_3 = 1;",
"break;",
"}",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
19,948 | float64 float64_sqrt( float64 a STATUS_PARAM )
{
flag aSign;
int16 aExp, zExp;
bits64 aSig, zSig, doubleZSig;
bits64 rem0, rem1, term0, term1;
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
if ( aSig ) return propagateFloat64NaN( a, a STATUS_VAR );
if ( ! aSign ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aSign ) {
if ( ( aExp | aSig ) == 0 ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aExp == 0 ) {
if ( aSig == 0 ) return 0;
normalizeFloat64Subnormal( aSig, &aExp, &aSig );
}
zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
aSig |= LIT64( 0x0010000000000000 );
zSig = estimateSqrt32( aExp, aSig>>21 );
aSig <<= 9 - ( aExp & 1 );
zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
if ( ( zSig & 0x1FF ) <= 5 ) {
doubleZSig = zSig<<1;
mul64To128( zSig, zSig, &term0, &term1 );
sub128( aSig, 0, term0, term1, &rem0, &rem1 );
while ( (sbits64) rem0 < 0 ) {
--zSig;
doubleZSig -= 2;
add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
}
zSig |= ( ( rem0 | rem1 ) != 0 );
}
return roundAndPackFloat64( 0, zExp, zSig STATUS_VAR );
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | float64 float64_sqrt( float64 a STATUS_PARAM )
{
flag aSign;
int16 aExp, zExp;
bits64 aSig, zSig, doubleZSig;
bits64 rem0, rem1, term0, term1;
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
if ( aSig ) return propagateFloat64NaN( a, a STATUS_VAR );
if ( ! aSign ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aSign ) {
if ( ( aExp | aSig ) == 0 ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aExp == 0 ) {
if ( aSig == 0 ) return 0;
normalizeFloat64Subnormal( aSig, &aExp, &aSig );
}
zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
aSig |= LIT64( 0x0010000000000000 );
zSig = estimateSqrt32( aExp, aSig>>21 );
aSig <<= 9 - ( aExp & 1 );
zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
if ( ( zSig & 0x1FF ) <= 5 ) {
doubleZSig = zSig<<1;
mul64To128( zSig, zSig, &term0, &term1 );
sub128( aSig, 0, term0, term1, &rem0, &rem1 );
while ( (sbits64) rem0 < 0 ) {
--zSig;
doubleZSig -= 2;
add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
}
zSig |= ( ( rem0 | rem1 ) != 0 );
}
return roundAndPackFloat64( 0, zExp, zSig STATUS_VAR );
}
| {
"code": [],
"line_no": []
} | float64 FUNC_0( float64 a STATUS_PARAM )
{
flag aSign;
int16 aExp, zExp;
bits64 aSig, zSig, doubleZSig;
bits64 rem0, rem1, term0, term1;
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
if ( aSig ) return propagateFloat64NaN( a, a STATUS_VAR );
if ( ! aSign ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aSign ) {
if ( ( aExp | aSig ) == 0 ) return a;
float_raise( float_flag_invalid STATUS_VAR);
return float64_default_nan;
}
if ( aExp == 0 ) {
if ( aSig == 0 ) return 0;
normalizeFloat64Subnormal( aSig, &aExp, &aSig );
}
zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
aSig |= LIT64( 0x0010000000000000 );
zSig = estimateSqrt32( aExp, aSig>>21 );
aSig <<= 9 - ( aExp & 1 );
zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
if ( ( zSig & 0x1FF ) <= 5 ) {
doubleZSig = zSig<<1;
mul64To128( zSig, zSig, &term0, &term1 );
sub128( aSig, 0, term0, term1, &rem0, &rem1 );
while ( (sbits64) rem0 < 0 ) {
--zSig;
doubleZSig -= 2;
add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
}
zSig |= ( ( rem0 | rem1 ) != 0 );
}
return roundAndPackFloat64( 0, zExp, zSig STATUS_VAR );
}
| [
"float64 FUNC_0( float64 a STATUS_PARAM )\n{",
"flag aSign;",
"int16 aExp, zExp;",
"bits64 aSig, zSig, doubleZSig;",
"bits64 rem0, rem1, term0, term1;",
"aSig = extractFloat64Frac( a );",
"aExp = extractFloat64Exp( a );",
"aSign = extractFloat64Sign( a );",
"if ( aExp == 0x7FF ) {",
"if ( aSig ) return propagateFloat64NaN( a, a STATUS_VAR );",
"if ( ! aSign ) return a;",
"float_raise( float_flag_invalid STATUS_VAR);",
"return float64_default_nan;",
"}",
"if ( aSign ) {",
"if ( ( aExp | aSig ) == 0 ) return a;",
"float_raise( float_flag_invalid STATUS_VAR);",
"return float64_default_nan;",
"}",
"if ( aExp == 0 ) {",
"if ( aSig == 0 ) return 0;",
"normalizeFloat64Subnormal( aSig, &aExp, &aSig );",
"}",
"zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;",
"aSig |= LIT64( 0x0010000000000000 );",
"zSig = estimateSqrt32( aExp, aSig>>21 );",
"aSig <<= 9 - ( aExp & 1 );",
"zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );",
"if ( ( zSig & 0x1FF ) <= 5 ) {",
"doubleZSig = zSig<<1;",
"mul64To128( zSig, zSig, &term0, &term1 );",
"sub128( aSig, 0, term0, term1, &rem0, &rem1 );",
"while ( (sbits64) rem0 < 0 ) {",
"--zSig;",
"doubleZSig -= 2;",
"add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );",
"}",
"zSig |= ( ( rem0 | rem1 ) != 0 );",
"}",
"return roundAndPackFloat64( 0, zExp, zSig STATUS_VAR );",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
],
[
87
]
] |
19,950 | static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
struct sigevent ev;
timer_t host_timer;
struct sigaction act;
sigfillset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = host_alarm_handler;
sigaction(SIGALRM, &act, NULL);
/*
* Initialize ev struct to 0 to avoid valgrind complaining
* about uninitialized data in timer_create call
*/
memset(&ev, 0, sizeof(ev));
ev.sigev_value.sival_int = 0;
ev.sigev_notify = SIGEV_SIGNAL;
#ifdef SIGEV_THREAD_ID
if (qemu_signalfd_available()) {
ev.sigev_notify = SIGEV_THREAD_ID;
ev._sigev_un._tid = qemu_get_thread_id();
}
#endif /* SIGEV_THREAD_ID */
ev.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) {
perror("timer_create");
return -1;
}
t->timer = host_timer;
return 0;
}
| false | qemu | 1e9737da4aafb54681203931dfe8f8eea21fcef7 | static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
struct sigevent ev;
timer_t host_timer;
struct sigaction act;
sigfillset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = host_alarm_handler;
sigaction(SIGALRM, &act, NULL);
memset(&ev, 0, sizeof(ev));
ev.sigev_value.sival_int = 0;
ev.sigev_notify = SIGEV_SIGNAL;
#ifdef SIGEV_THREAD_ID
if (qemu_signalfd_available()) {
ev.sigev_notify = SIGEV_THREAD_ID;
ev._sigev_un._tid = qemu_get_thread_id();
}
#endif
ev.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) {
perror("timer_create");
return -1;
}
t->timer = host_timer;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct qemu_alarm_timer *VAR_0)
{
struct sigevent VAR_1;
timer_t host_timer;
struct sigaction VAR_2;
sigfillset(&VAR_2.sa_mask);
VAR_2.sa_flags = 0;
VAR_2.sa_handler = host_alarm_handler;
sigaction(SIGALRM, &VAR_2, NULL);
memset(&VAR_1, 0, sizeof(VAR_1));
VAR_1.sigev_value.sival_int = 0;
VAR_1.sigev_notify = SIGEV_SIGNAL;
#ifdef SIGEV_THREAD_ID
if (qemu_signalfd_available()) {
VAR_1.sigev_notify = SIGEV_THREAD_ID;
VAR_1._sigev_un._tid = qemu_get_thread_id();
}
#endif
VAR_1.sigev_signo = SIGALRM;
if (timer_create(CLOCK_REALTIME, &VAR_1, &host_timer)) {
perror("timer_create");
return -1;
}
VAR_0->timer = host_timer;
return 0;
}
| [
"static int FUNC_0(struct qemu_alarm_timer *VAR_0)\n{",
"struct sigevent VAR_1;",
"timer_t host_timer;",
"struct sigaction VAR_2;",
"sigfillset(&VAR_2.sa_mask);",
"VAR_2.sa_flags = 0;",
"VAR_2.sa_handler = host_alarm_handler;",
"sigaction(SIGALRM, &VAR_2, NULL);",
"memset(&VAR_1, 0, sizeof(VAR_1));",
"VAR_1.sigev_value.sival_int = 0;",
"VAR_1.sigev_notify = SIGEV_SIGNAL;",
"#ifdef SIGEV_THREAD_ID\nif (qemu_signalfd_available()) {",
"VAR_1.sigev_notify = SIGEV_THREAD_ID;",
"VAR_1._sigev_un._tid = qemu_get_thread_id();",
"}",
"#endif\nVAR_1.sigev_signo = SIGALRM;",
"if (timer_create(CLOCK_REALTIME, &VAR_1, &host_timer)) {",
"perror(\"timer_create\");",
"return -1;",
"}",
"VAR_0->timer = host_timer;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
]
] |
19,951 | void sysbus_register_withprop(SysBusDeviceInfo *info)
{
info->qdev.init = sysbus_device_init;
info->qdev.bus_type = BUS_TYPE_SYSTEM;
assert(info->qdev.size >= sizeof(SysBusDevice));
qdev_register(&info->qdev);
}
| false | qemu | 10c4c98ab7dc18169b37b76f6ea5e60ebe65222b | void sysbus_register_withprop(SysBusDeviceInfo *info)
{
info->qdev.init = sysbus_device_init;
info->qdev.bus_type = BUS_TYPE_SYSTEM;
assert(info->qdev.size >= sizeof(SysBusDevice));
qdev_register(&info->qdev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(SysBusDeviceInfo *VAR_0)
{
VAR_0->qdev.init = sysbus_device_init;
VAR_0->qdev.bus_type = BUS_TYPE_SYSTEM;
assert(VAR_0->qdev.size >= sizeof(SysBusDevice));
qdev_register(&VAR_0->qdev);
}
| [
"void FUNC_0(SysBusDeviceInfo *VAR_0)\n{",
"VAR_0->qdev.init = sysbus_device_init;",
"VAR_0->qdev.bus_type = BUS_TYPE_SYSTEM;",
"assert(VAR_0->qdev.size >= sizeof(SysBusDevice));",
"qdev_register(&VAR_0->qdev);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
19,952 | int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time)
{
if (!timer_head)
return 0;
return (timer_head->expire_time <= current_time);
}
| false | qemu | 4a998740b22aa673ea475060c787da7c545588cf | int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time)
{
if (!timer_head)
return 0;
return (timer_head->expire_time <= current_time);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QEMUTimer *VAR_0, int64_t VAR_1)
{
if (!VAR_0)
return 0;
return (VAR_0->expire_time <= VAR_1);
}
| [
"int FUNC_0(QEMUTimer *VAR_0, int64_t VAR_1)\n{",
"if (!VAR_0)\nreturn 0;",
"return (VAR_0->expire_time <= VAR_1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
]
] |
19,953 | static int cbs_read_se_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc,
const char *name, int32_t *write_to,
int32_t range_min, int32_t range_max)
{
int32_t value;
int position;
if (ctx->trace_enable) {
char bits[65];
uint32_t v;
unsigned int k;
int i, j;
position = bitstream_tell(bc);
for (i = 0; i < 32; i++) {
k = bitstream_read_bit(bc);
bits[i] = k ? '1' : '0';
if (k)
break;
}
if (i >= 32) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "
"code found while reading %s: "
"more than 31 zeroes.\n", name);
return AVERROR_INVALIDDATA;
}
v = 1;
for (j = 0; j < i; j++) {
k = bitstream_read_bit(bc);
bits[i + j + 1] = k ? '1' : '0';
v = v << 1 | k;
}
bits[i + j + 1] = 0;
if (v & 1)
value = -(int32_t)(v / 2);
else
value = v / 2;
ff_cbs_trace_syntax_element(ctx, position, name, bits, value);
} else {
value = get_se_golomb_long(bc);
}
if (value < range_min || value > range_max) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
"%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
name, value, range_min, range_max);
return AVERROR_INVALIDDATA;
}
*write_to = value;
return 0;
}
| false | FFmpeg | 44cde38c8acbef7d5250e6d1b52b1020871e093b | static int cbs_read_se_golomb(CodedBitstreamContext *ctx, BitstreamContext *bc,
const char *name, int32_t *write_to,
int32_t range_min, int32_t range_max)
{
int32_t value;
int position;
if (ctx->trace_enable) {
char bits[65];
uint32_t v;
unsigned int k;
int i, j;
position = bitstream_tell(bc);
for (i = 0; i < 32; i++) {
k = bitstream_read_bit(bc);
bits[i] = k ? '1' : '0';
if (k)
break;
}
if (i >= 32) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "
"code found while reading %s: "
"more than 31 zeroes.\n", name);
return AVERROR_INVALIDDATA;
}
v = 1;
for (j = 0; j < i; j++) {
k = bitstream_read_bit(bc);
bits[i + j + 1] = k ? '1' : '0';
v = v << 1 | k;
}
bits[i + j + 1] = 0;
if (v & 1)
value = -(int32_t)(v / 2);
else
value = v / 2;
ff_cbs_trace_syntax_element(ctx, position, name, bits, value);
} else {
value = get_se_golomb_long(bc);
}
if (value < range_min || value > range_max) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
"%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
name, value, range_min, range_max);
return AVERROR_INVALIDDATA;
}
*write_to = value;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CodedBitstreamContext *VAR_0, BitstreamContext *VAR_1,
const char *VAR_2, int32_t *VAR_3,
int32_t VAR_4, int32_t VAR_5)
{
int32_t value;
int VAR_6;
if (VAR_0->trace_enable) {
char VAR_7[65];
uint32_t v;
unsigned int VAR_8;
int VAR_9, VAR_10;
VAR_6 = bitstream_tell(VAR_1);
for (VAR_9 = 0; VAR_9 < 32; VAR_9++) {
VAR_8 = bitstream_read_bit(VAR_1);
VAR_7[VAR_9] = VAR_8 ? '1' : '0';
if (VAR_8)
break;
}
if (VAR_9 >= 32) {
av_log(VAR_0->log_ctx, AV_LOG_ERROR, "Invalid se-golomb "
"code found while reading %s: "
"more than 31 zeroes.\n", VAR_2);
return AVERROR_INVALIDDATA;
}
v = 1;
for (VAR_10 = 0; VAR_10 < VAR_9; VAR_10++) {
VAR_8 = bitstream_read_bit(VAR_1);
VAR_7[VAR_9 + VAR_10 + 1] = VAR_8 ? '1' : '0';
v = v << 1 | VAR_8;
}
VAR_7[VAR_9 + VAR_10 + 1] = 0;
if (v & 1)
value = -(int32_t)(v / 2);
else
value = v / 2;
ff_cbs_trace_syntax_element(VAR_0, VAR_6, VAR_2, VAR_7, value);
} else {
value = get_se_golomb_long(VAR_1);
}
if (value < VAR_4 || value > VAR_5) {
av_log(VAR_0->log_ctx, AV_LOG_ERROR, "%s out of range: "
"%"PRId32", but must be in [%"PRId32",%"PRId32"].\n",
VAR_2, value, VAR_4, VAR_5);
return AVERROR_INVALIDDATA;
}
*VAR_3 = value;
return 0;
}
| [
"static int FUNC_0(CodedBitstreamContext *VAR_0, BitstreamContext *VAR_1,\nconst char *VAR_2, int32_t *VAR_3,\nint32_t VAR_4, int32_t VAR_5)\n{",
"int32_t value;",
"int VAR_6;",
"if (VAR_0->trace_enable) {",
"char VAR_7[65];",
"uint32_t v;",
"unsigned int VAR_8;",
"int VAR_9, VAR_10;",
"VAR_6 = bitstream_tell(VAR_1);",
"for (VAR_9 = 0; VAR_9 < 32; VAR_9++) {",
"VAR_8 = bitstream_read_bit(VAR_1);",
"VAR_7[VAR_9] = VAR_8 ? '1' : '0';",
"if (VAR_8)\nbreak;",
"}",
"if (VAR_9 >= 32) {",
"av_log(VAR_0->log_ctx, AV_LOG_ERROR, \"Invalid se-golomb \"\n\"code found while reading %s: \"\n\"more than 31 zeroes.\\n\", VAR_2);",
"return AVERROR_INVALIDDATA;",
"}",
"v = 1;",
"for (VAR_10 = 0; VAR_10 < VAR_9; VAR_10++) {",
"VAR_8 = bitstream_read_bit(VAR_1);",
"VAR_7[VAR_9 + VAR_10 + 1] = VAR_8 ? '1' : '0';",
"v = v << 1 | VAR_8;",
"}",
"VAR_7[VAR_9 + VAR_10 + 1] = 0;",
"if (v & 1)\nvalue = -(int32_t)(v / 2);",
"else\nvalue = v / 2;",
"ff_cbs_trace_syntax_element(VAR_0, VAR_6, VAR_2, VAR_7, value);",
"} else {",
"value = get_se_golomb_long(VAR_1);",
"}",
"if (value < VAR_4 || value > VAR_5) {",
"av_log(VAR_0->log_ctx, AV_LOG_ERROR, \"%s out of range: \"\n\"%\"PRId32\", but must be in [%\"PRId32\",%\"PRId32\"].\\n\",\nVAR_2, value, VAR_4, VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"*VAR_3 = value;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
]
] |
19,954 | void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
/* test if maximum index reached */
if (index & 0x80000000) {
if (index > env->cpuid_xlevel)
index = env->cpuid_level;
} else {
if (index > env->cpuid_level)
index = env->cpuid_level;
}
switch(index) {
case 0:
*eax = env->cpuid_level;
*ebx = env->cpuid_vendor1;
*edx = env->cpuid_vendor2;
*ecx = env->cpuid_vendor3;
/* sysenter isn't supported on compatibility mode on AMD. and syscall
* isn't supported in compatibility mode on Intel. so advertise the
* actuall cpu, and say goodbye to migration between different vendors
* is you use compatibility mode. */
if (kvm_enabled())
host_cpuid(0, NULL, ebx, ecx, edx);
break;
case 1:
*eax = env->cpuid_version;
*ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
*ecx = env->cpuid_ext_features;
*edx = env->cpuid_features;
/* "Hypervisor present" bit required for Microsoft SVVP */
if (kvm_enabled())
*ecx |= (1 << 31);
break;
case 2:
/* cache info: needed for Pentium Pro compatibility */
*eax = 1;
*ebx = 0;
*ecx = 0;
*edx = 0x2c307d;
break;
case 4:
/* cache info: needed for Core compatibility */
switch (*ecx) {
case 0: /* L1 dcache info */
*eax = 0x0000121;
*ebx = 0x1c0003f;
*ecx = 0x000003f;
*edx = 0x0000001;
break;
case 1: /* L1 icache info */
*eax = 0x0000122;
*ebx = 0x1c0003f;
*ecx = 0x000003f;
*edx = 0x0000001;
break;
case 2: /* L2 cache info */
*eax = 0x0000143;
*ebx = 0x3c0003f;
*ecx = 0x0000fff;
*edx = 0x0000001;
break;
default: /* end of info */
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
}
break;
case 5:
/* mwait info: needed for Core compatibility */
*eax = 0; /* Smallest monitor-line size in bytes */
*ebx = 0; /* Largest monitor-line size in bytes */
*ecx = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
*edx = 0;
break;
case 6:
/* Thermal and Power Leaf */
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 9:
/* Direct Cache Access Information Leaf */
*eax = 0; /* Bits 0-31 in DCA_CAP MSR */
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0xA:
/* Architectural Performance Monitoring Leaf */
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0x80000000:
*eax = env->cpuid_xlevel;
*ebx = env->cpuid_vendor1;
*edx = env->cpuid_vendor2;
*ecx = env->cpuid_vendor3;
break;
case 0x80000001:
*eax = env->cpuid_features;
*ebx = 0;
*ecx = env->cpuid_ext3_features;
*edx = env->cpuid_ext2_features;
if (kvm_enabled()) {
uint32_t h_eax, h_edx;
host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
/* disable CPU features that the host does not support */
/* long mode */
if ((h_edx & 0x20000000) == 0 /* || !lm_capable_kernel */)
*edx &= ~0x20000000;
/* syscall */
if ((h_edx & 0x00000800) == 0)
*edx &= ~0x00000800;
/* nx */
if ((h_edx & 0x00100000) == 0)
*edx &= ~0x00100000;
/* disable CPU features that KVM cannot support */
/* svm */
*ecx &= ~4UL;
/* 3dnow */
*edx = ~0xc0000000;
}
break;
case 0x80000002:
case 0x80000003:
case 0x80000004:
*eax = env->cpuid_model[(index - 0x80000002) * 4 + 0];
*ebx = env->cpuid_model[(index - 0x80000002) * 4 + 1];
*ecx = env->cpuid_model[(index - 0x80000002) * 4 + 2];
*edx = env->cpuid_model[(index - 0x80000002) * 4 + 3];
break;
case 0x80000005:
/* cache info (L1 cache) */
*eax = 0x01ff01ff;
*ebx = 0x01ff01ff;
*ecx = 0x40020140;
*edx = 0x40020140;
break;
case 0x80000006:
/* cache info (L2 cache) */
*eax = 0;
*ebx = 0x42004200;
*ecx = 0x02008140;
*edx = 0;
break;
case 0x80000008:
/* virtual & phys address size in low 2 bytes. */
/* XXX: This value must match the one used in the MMU code. */
if (env->cpuid_ext2_features & CPUID_EXT2_LM) {
/* 64 bit processor */
#if defined(USE_KQEMU)
*eax = 0x00003020; /* 48 bits virtual, 32 bits physical */
#else
/* XXX: The physical address space is limited to 42 bits in exec.c. */
*eax = 0x00003028; /* 48 bits virtual, 40 bits physical */
#endif
} else {
#if defined(USE_KQEMU)
*eax = 0x00000020; /* 32 bits physical */
#else
if (env->cpuid_features & CPUID_PSE36)
*eax = 0x00000024; /* 36 bits physical */
else
*eax = 0x00000020; /* 32 bits physical */
#endif
}
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0x8000000A:
*eax = 0x00000001; /* SVM Revision */
*ebx = 0x00000010; /* nr of ASIDs */
*ecx = 0;
*edx = 0; /* optional features */
break;
default:
/* reserved values: zero */
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
}
}
| false | qemu | 57003085037f554de82327cbc34105cda1942892 | void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
if (index & 0x80000000) {
if (index > env->cpuid_xlevel)
index = env->cpuid_level;
} else {
if (index > env->cpuid_level)
index = env->cpuid_level;
}
switch(index) {
case 0:
*eax = env->cpuid_level;
*ebx = env->cpuid_vendor1;
*edx = env->cpuid_vendor2;
*ecx = env->cpuid_vendor3;
if (kvm_enabled())
host_cpuid(0, NULL, ebx, ecx, edx);
break;
case 1:
*eax = env->cpuid_version;
*ebx = (env->cpuid_apic_id << 24) | 8 << 8;
*ecx = env->cpuid_ext_features;
*edx = env->cpuid_features;
if (kvm_enabled())
*ecx |= (1 << 31);
break;
case 2:
*eax = 1;
*ebx = 0;
*ecx = 0;
*edx = 0x2c307d;
break;
case 4:
switch (*ecx) {
case 0:
*eax = 0x0000121;
*ebx = 0x1c0003f;
*ecx = 0x000003f;
*edx = 0x0000001;
break;
case 1:
*eax = 0x0000122;
*ebx = 0x1c0003f;
*ecx = 0x000003f;
*edx = 0x0000001;
break;
case 2:
*eax = 0x0000143;
*ebx = 0x3c0003f;
*ecx = 0x0000fff;
*edx = 0x0000001;
break;
default:
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
}
break;
case 5:
*eax = 0;
*ebx = 0;
*ecx = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
*edx = 0;
break;
case 6:
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 9:
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0xA:
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0x80000000:
*eax = env->cpuid_xlevel;
*ebx = env->cpuid_vendor1;
*edx = env->cpuid_vendor2;
*ecx = env->cpuid_vendor3;
break;
case 0x80000001:
*eax = env->cpuid_features;
*ebx = 0;
*ecx = env->cpuid_ext3_features;
*edx = env->cpuid_ext2_features;
if (kvm_enabled()) {
uint32_t h_eax, h_edx;
host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
if ((h_edx & 0x20000000) == 0 )
*edx &= ~0x20000000;
if ((h_edx & 0x00000800) == 0)
*edx &= ~0x00000800;
if ((h_edx & 0x00100000) == 0)
*edx &= ~0x00100000;
*ecx &= ~4UL;
*edx = ~0xc0000000;
}
break;
case 0x80000002:
case 0x80000003:
case 0x80000004:
*eax = env->cpuid_model[(index - 0x80000002) * 4 + 0];
*ebx = env->cpuid_model[(index - 0x80000002) * 4 + 1];
*ecx = env->cpuid_model[(index - 0x80000002) * 4 + 2];
*edx = env->cpuid_model[(index - 0x80000002) * 4 + 3];
break;
case 0x80000005:
*eax = 0x01ff01ff;
*ebx = 0x01ff01ff;
*ecx = 0x40020140;
*edx = 0x40020140;
break;
case 0x80000006:
*eax = 0;
*ebx = 0x42004200;
*ecx = 0x02008140;
*edx = 0;
break;
case 0x80000008:
if (env->cpuid_ext2_features & CPUID_EXT2_LM) {
#if defined(USE_KQEMU)
*eax = 0x00003020;
#else
*eax = 0x00003028;
#endif
} else {
#if defined(USE_KQEMU)
*eax = 0x00000020;
#else
if (env->cpuid_features & CPUID_PSE36)
*eax = 0x00000024;
else
*eax = 0x00000020;
#endif
}
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
case 0x8000000A:
*eax = 0x00000001;
*ebx = 0x00000010;
*ecx = 0;
*edx = 0;
break;
default:
*eax = 0;
*ebx = 0;
*ecx = 0;
*edx = 0;
break;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1,
uint32_t *VAR_2, uint32_t *VAR_3,
uint32_t *VAR_4, uint32_t *VAR_5)
{
if (VAR_1 & 0x80000000) {
if (VAR_1 > VAR_0->cpuid_xlevel)
VAR_1 = VAR_0->cpuid_level;
} else {
if (VAR_1 > VAR_0->cpuid_level)
VAR_1 = VAR_0->cpuid_level;
}
switch(VAR_1) {
case 0:
*VAR_2 = VAR_0->cpuid_level;
*VAR_3 = VAR_0->cpuid_vendor1;
*VAR_5 = VAR_0->cpuid_vendor2;
*VAR_4 = VAR_0->cpuid_vendor3;
if (kvm_enabled())
host_cpuid(0, NULL, VAR_3, VAR_4, VAR_5);
break;
case 1:
*VAR_2 = VAR_0->cpuid_version;
*VAR_3 = (VAR_0->cpuid_apic_id << 24) | 8 << 8;
*VAR_4 = VAR_0->cpuid_ext_features;
*VAR_5 = VAR_0->cpuid_features;
if (kvm_enabled())
*VAR_4 |= (1 << 31);
break;
case 2:
*VAR_2 = 1;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0x2c307d;
break;
case 4:
switch (*VAR_4) {
case 0:
*VAR_2 = 0x0000121;
*VAR_3 = 0x1c0003f;
*VAR_4 = 0x000003f;
*VAR_5 = 0x0000001;
break;
case 1:
*VAR_2 = 0x0000122;
*VAR_3 = 0x1c0003f;
*VAR_4 = 0x000003f;
*VAR_5 = 0x0000001;
break;
case 2:
*VAR_2 = 0x0000143;
*VAR_3 = 0x3c0003f;
*VAR_4 = 0x0000fff;
*VAR_5 = 0x0000001;
break;
default:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
}
break;
case 5:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
*VAR_5 = 0;
break;
case 6:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
case 9:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
case 0xA:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
case 0x80000000:
*VAR_2 = VAR_0->cpuid_xlevel;
*VAR_3 = VAR_0->cpuid_vendor1;
*VAR_5 = VAR_0->cpuid_vendor2;
*VAR_4 = VAR_0->cpuid_vendor3;
break;
case 0x80000001:
*VAR_2 = VAR_0->cpuid_features;
*VAR_3 = 0;
*VAR_4 = VAR_0->cpuid_ext3_features;
*VAR_5 = VAR_0->cpuid_ext2_features;
if (kvm_enabled()) {
uint32_t h_eax, h_edx;
host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
if ((h_edx & 0x20000000) == 0 )
*VAR_5 &= ~0x20000000;
if ((h_edx & 0x00000800) == 0)
*VAR_5 &= ~0x00000800;
if ((h_edx & 0x00100000) == 0)
*VAR_5 &= ~0x00100000;
*VAR_4 &= ~4UL;
*VAR_5 = ~0xc0000000;
}
break;
case 0x80000002:
case 0x80000003:
case 0x80000004:
*VAR_2 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 0];
*VAR_3 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 1];
*VAR_4 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 2];
*VAR_5 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 3];
break;
case 0x80000005:
*VAR_2 = 0x01ff01ff;
*VAR_3 = 0x01ff01ff;
*VAR_4 = 0x40020140;
*VAR_5 = 0x40020140;
break;
case 0x80000006:
*VAR_2 = 0;
*VAR_3 = 0x42004200;
*VAR_4 = 0x02008140;
*VAR_5 = 0;
break;
case 0x80000008:
if (VAR_0->cpuid_ext2_features & CPUID_EXT2_LM) {
#if defined(USE_KQEMU)
*VAR_2 = 0x00003020;
#else
*VAR_2 = 0x00003028;
#endif
} else {
#if defined(USE_KQEMU)
*VAR_2 = 0x00000020;
#else
if (VAR_0->cpuid_features & CPUID_PSE36)
*VAR_2 = 0x00000024;
else
*VAR_2 = 0x00000020;
#endif
}
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
case 0x8000000A:
*VAR_2 = 0x00000001;
*VAR_3 = 0x00000010;
*VAR_4 = 0;
*VAR_5 = 0;
break;
default:
*VAR_2 = 0;
*VAR_3 = 0;
*VAR_4 = 0;
*VAR_5 = 0;
break;
}
}
| [
"void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1,\nuint32_t *VAR_2, uint32_t *VAR_3,\nuint32_t *VAR_4, uint32_t *VAR_5)\n{",
"if (VAR_1 & 0x80000000) {",
"if (VAR_1 > VAR_0->cpuid_xlevel)\nVAR_1 = VAR_0->cpuid_level;",
"} else {",
"if (VAR_1 > VAR_0->cpuid_level)\nVAR_1 = VAR_0->cpuid_level;",
"}",
"switch(VAR_1) {",
"case 0:\n*VAR_2 = VAR_0->cpuid_level;",
"*VAR_3 = VAR_0->cpuid_vendor1;",
"*VAR_5 = VAR_0->cpuid_vendor2;",
"*VAR_4 = VAR_0->cpuid_vendor3;",
"if (kvm_enabled())\nhost_cpuid(0, NULL, VAR_3, VAR_4, VAR_5);",
"break;",
"case 1:\n*VAR_2 = VAR_0->cpuid_version;",
"*VAR_3 = (VAR_0->cpuid_apic_id << 24) | 8 << 8;",
"*VAR_4 = VAR_0->cpuid_ext_features;",
"*VAR_5 = VAR_0->cpuid_features;",
"if (kvm_enabled())\n*VAR_4 |= (1 << 31);",
"break;",
"case 2:\n*VAR_2 = 1;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0x2c307d;",
"break;",
"case 4:\nswitch (*VAR_4) {",
"case 0:\n*VAR_2 = 0x0000121;",
"*VAR_3 = 0x1c0003f;",
"*VAR_4 = 0x000003f;",
"*VAR_5 = 0x0000001;",
"break;",
"case 1:\n*VAR_2 = 0x0000122;",
"*VAR_3 = 0x1c0003f;",
"*VAR_4 = 0x000003f;",
"*VAR_5 = 0x0000001;",
"break;",
"case 2:\n*VAR_2 = 0x0000143;",
"*VAR_3 = 0x3c0003f;",
"*VAR_4 = 0x0000fff;",
"*VAR_5 = 0x0000001;",
"break;",
"default:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"}",
"break;",
"case 5:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;",
"*VAR_5 = 0;",
"break;",
"case 6:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"case 9:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"case 0xA:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"case 0x80000000:\n*VAR_2 = VAR_0->cpuid_xlevel;",
"*VAR_3 = VAR_0->cpuid_vendor1;",
"*VAR_5 = VAR_0->cpuid_vendor2;",
"*VAR_4 = VAR_0->cpuid_vendor3;",
"break;",
"case 0x80000001:\n*VAR_2 = VAR_0->cpuid_features;",
"*VAR_3 = 0;",
"*VAR_4 = VAR_0->cpuid_ext3_features;",
"*VAR_5 = VAR_0->cpuid_ext2_features;",
"if (kvm_enabled()) {",
"uint32_t h_eax, h_edx;",
"host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);",
"if ((h_edx & 0x20000000) == 0 )\n*VAR_5 &= ~0x20000000;",
"if ((h_edx & 0x00000800) == 0)\n*VAR_5 &= ~0x00000800;",
"if ((h_edx & 0x00100000) == 0)\n*VAR_5 &= ~0x00100000;",
"*VAR_4 &= ~4UL;",
"*VAR_5 = ~0xc0000000;",
"}",
"break;",
"case 0x80000002:\ncase 0x80000003:\ncase 0x80000004:\n*VAR_2 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 0];",
"*VAR_3 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 1];",
"*VAR_4 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 2];",
"*VAR_5 = VAR_0->cpuid_model[(VAR_1 - 0x80000002) * 4 + 3];",
"break;",
"case 0x80000005:\n*VAR_2 = 0x01ff01ff;",
"*VAR_3 = 0x01ff01ff;",
"*VAR_4 = 0x40020140;",
"*VAR_5 = 0x40020140;",
"break;",
"case 0x80000006:\n*VAR_2 = 0;",
"*VAR_3 = 0x42004200;",
"*VAR_4 = 0x02008140;",
"*VAR_5 = 0;",
"break;",
"case 0x80000008:\nif (VAR_0->cpuid_ext2_features & CPUID_EXT2_LM) {",
"#if defined(USE_KQEMU)\n*VAR_2 = 0x00003020;",
"#else\n*VAR_2 = 0x00003028;",
"#endif\n} else {",
"#if defined(USE_KQEMU)\n*VAR_2 = 0x00000020;",
"#else\nif (VAR_0->cpuid_features & CPUID_PSE36)\n*VAR_2 = 0x00000024;",
"else\n*VAR_2 = 0x00000020;",
"#endif\n}",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"case 0x8000000A:\n*VAR_2 = 0x00000001;",
"*VAR_3 = 0x00000010;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"break;",
"default:\n*VAR_2 = 0;",
"*VAR_3 = 0;",
"*VAR_4 = 0;",
"*VAR_5 = 0;",
"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
] | [
[
1,
3,
5,
7
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
69,
71
],
[
73
],
[
75,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
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
],
[
147
],
[
149,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
235
],
[
245,
247
],
[
251,
253
],
[
257,
259
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279,
281,
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309,
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323,
329
],
[
333,
335
],
[
337,
341
],
[
343,
345
],
[
347,
349
],
[
351,
353,
355
],
[
357,
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
]
] |
19,955 | static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
{
return cpu_inl(addr & IOPORTS_MASK);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
{
return cpu_inl(addr & IOPORTS_MASK);
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
return cpu_inl(addr & IOPORTS_MASK);
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"return cpu_inl(addr & IOPORTS_MASK);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
19,956 | static always_inline int _pte_check (mmu_ctx_t *ctx, int is_64b,
target_ulong pte0, target_ulong pte1,
int h, int rw)
{
target_ulong ptem, mmask;
int access, ret, pteh, ptev;
access = 0;
ret = -1;
/* Check validity and table match */
#if defined(TARGET_PPC64)
if (is_64b) {
ptev = pte64_is_valid(pte0);
pteh = (pte0 >> 1) & 1;
} else
#endif
{
ptev = pte_is_valid(pte0);
pteh = (pte0 >> 6) & 1;
}
if (ptev && h == pteh) {
/* Check vsid & api */
#if defined(TARGET_PPC64)
if (is_64b) {
ptem = pte0 & PTE64_PTEM_MASK;
mmask = PTE64_CHECK_MASK;
} else
#endif
{
ptem = pte0 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
}
if (ptem == ctx->ptem) {
if (ctx->raddr != (target_ulong)-1) {
/* all matches should have equal RPN, WIMG & PP */
if ((ctx->raddr & mmask) != (pte1 & mmask)) {
if (loglevel != 0)
fprintf(logfile, "Bad RPN/WIMG/PP\n");
return -3;
}
}
/* Compute access rights */
if (ctx->key == 0) {
access = PAGE_READ;
if ((pte1 & 0x00000003) != 0x3)
access |= PAGE_WRITE;
} else {
switch (pte1 & 0x00000003) {
case 0x0:
access = 0;
break;
case 0x1:
case 0x3:
access = PAGE_READ;
break;
case 0x2:
access = PAGE_READ | PAGE_WRITE;
break;
}
}
/* Keep the matching PTE informations */
ctx->raddr = pte1;
ctx->prot = access;
if ((rw == 0 && (access & PAGE_READ)) ||
(rw == 1 && (access & PAGE_WRITE))) {
/* Access granted */
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE access granted !\n");
#endif
ret = 0;
} else {
/* Access right violation */
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE access rejected\n");
#endif
ret = -2;
}
}
}
return ret;
}
| false | qemu | b227a8e9aa5f27d29f77ba90d5eb9d0662a1175e | static always_inline int _pte_check (mmu_ctx_t *ctx, int is_64b,
target_ulong pte0, target_ulong pte1,
int h, int rw)
{
target_ulong ptem, mmask;
int access, ret, pteh, ptev;
access = 0;
ret = -1;
#if defined(TARGET_PPC64)
if (is_64b) {
ptev = pte64_is_valid(pte0);
pteh = (pte0 >> 1) & 1;
} else
#endif
{
ptev = pte_is_valid(pte0);
pteh = (pte0 >> 6) & 1;
}
if (ptev && h == pteh) {
#if defined(TARGET_PPC64)
if (is_64b) {
ptem = pte0 & PTE64_PTEM_MASK;
mmask = PTE64_CHECK_MASK;
} else
#endif
{
ptem = pte0 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
}
if (ptem == ctx->ptem) {
if (ctx->raddr != (target_ulong)-1) {
if ((ctx->raddr & mmask) != (pte1 & mmask)) {
if (loglevel != 0)
fprintf(logfile, "Bad RPN/WIMG/PP\n");
return -3;
}
}
if (ctx->key == 0) {
access = PAGE_READ;
if ((pte1 & 0x00000003) != 0x3)
access |= PAGE_WRITE;
} else {
switch (pte1 & 0x00000003) {
case 0x0:
access = 0;
break;
case 0x1:
case 0x3:
access = PAGE_READ;
break;
case 0x2:
access = PAGE_READ | PAGE_WRITE;
break;
}
}
ctx->raddr = pte1;
ctx->prot = access;
if ((rw == 0 && (access & PAGE_READ)) ||
(rw == 1 && (access & PAGE_WRITE))) {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE access granted !\n");
#endif
ret = 0;
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE access rejected\n");
#endif
ret = -2;
}
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static always_inline int FUNC_0 (mmu_ctx_t *ctx, int is_64b,
target_ulong pte0, target_ulong pte1,
int h, int rw)
{
target_ulong ptem, mmask;
int VAR_0, VAR_1, VAR_2, VAR_3;
VAR_0 = 0;
VAR_1 = -1;
#if defined(TARGET_PPC64)
if (is_64b) {
VAR_3 = pte64_is_valid(pte0);
VAR_2 = (pte0 >> 1) & 1;
} else
#endif
{
VAR_3 = pte_is_valid(pte0);
VAR_2 = (pte0 >> 6) & 1;
}
if (VAR_3 && h == VAR_2) {
#if defined(TARGET_PPC64)
if (is_64b) {
ptem = pte0 & PTE64_PTEM_MASK;
mmask = PTE64_CHECK_MASK;
} else
#endif
{
ptem = pte0 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
}
if (ptem == ctx->ptem) {
if (ctx->raddr != (target_ulong)-1) {
if ((ctx->raddr & mmask) != (pte1 & mmask)) {
if (loglevel != 0)
fprintf(logfile, "Bad RPN/WIMG/PP\n");
return -3;
}
}
if (ctx->key == 0) {
VAR_0 = PAGE_READ;
if ((pte1 & 0x00000003) != 0x3)
VAR_0 |= PAGE_WRITE;
} else {
switch (pte1 & 0x00000003) {
case 0x0:
VAR_0 = 0;
break;
case 0x1:
case 0x3:
VAR_0 = PAGE_READ;
break;
case 0x2:
VAR_0 = PAGE_READ | PAGE_WRITE;
break;
}
}
ctx->raddr = pte1;
ctx->prot = VAR_0;
if ((rw == 0 && (VAR_0 & PAGE_READ)) ||
(rw == 1 && (VAR_0 & PAGE_WRITE))) {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE VAR_0 granted !\n");
#endif
VAR_1 = 0;
} else {
#if defined (DEBUG_MMU)
if (loglevel != 0)
fprintf(logfile, "PTE VAR_0 rejected\n");
#endif
VAR_1 = -2;
}
}
}
return VAR_1;
}
| [
"static always_inline int FUNC_0 (mmu_ctx_t *ctx, int is_64b,\ntarget_ulong pte0, target_ulong pte1,\nint h, int rw)\n{",
"target_ulong ptem, mmask;",
"int VAR_0, VAR_1, VAR_2, VAR_3;",
"VAR_0 = 0;",
"VAR_1 = -1;",
"#if defined(TARGET_PPC64)\nif (is_64b) {",
"VAR_3 = pte64_is_valid(pte0);",
"VAR_2 = (pte0 >> 1) & 1;",
"} else",
"#endif\n{",
"VAR_3 = pte_is_valid(pte0);",
"VAR_2 = (pte0 >> 6) & 1;",
"}",
"if (VAR_3 && h == VAR_2) {",
"#if defined(TARGET_PPC64)\nif (is_64b) {",
"ptem = pte0 & PTE64_PTEM_MASK;",
"mmask = PTE64_CHECK_MASK;",
"} else",
"#endif\n{",
"ptem = pte0 & PTE_PTEM_MASK;",
"mmask = PTE_CHECK_MASK;",
"}",
"if (ptem == ctx->ptem) {",
"if (ctx->raddr != (target_ulong)-1) {",
"if ((ctx->raddr & mmask) != (pte1 & mmask)) {",
"if (loglevel != 0)\nfprintf(logfile, \"Bad RPN/WIMG/PP\\n\");",
"return -3;",
"}",
"}",
"if (ctx->key == 0) {",
"VAR_0 = PAGE_READ;",
"if ((pte1 & 0x00000003) != 0x3)\nVAR_0 |= PAGE_WRITE;",
"} else {",
"switch (pte1 & 0x00000003) {",
"case 0x0:\nVAR_0 = 0;",
"break;",
"case 0x1:\ncase 0x3:\nVAR_0 = PAGE_READ;",
"break;",
"case 0x2:\nVAR_0 = PAGE_READ | PAGE_WRITE;",
"break;",
"}",
"}",
"ctx->raddr = pte1;",
"ctx->prot = VAR_0;",
"if ((rw == 0 && (VAR_0 & PAGE_READ)) ||\n(rw == 1 && (VAR_0 & PAGE_WRITE))) {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0)\nfprintf(logfile, \"PTE VAR_0 granted !\\n\");",
"#endif\nVAR_1 = 0;",
"} else {",
"#if defined (DEBUG_MMU)\nif (loglevel != 0)\nfprintf(logfile, \"PTE VAR_0 rejected\\n\");",
"#endif\nVAR_1 = -2;",
"}",
"}",
"}",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103,
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
133,
135,
137
],
[
139,
141
],
[
143
],
[
147,
149,
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
]
] |
19,957 | void qmp_block_job_resume(const char *device, Error **errp)
{
BlockJob *job = find_block_job(device);
if (!job) {
error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
return;
}
trace_qmp_block_job_resume(job);
block_job_resume(job);
}
| false | qemu | 3d948cdf3760b52238038626a7ffa7d30913060b | void qmp_block_job_resume(const char *device, Error **errp)
{
BlockJob *job = find_block_job(device);
if (!job) {
error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
return;
}
trace_qmp_block_job_resume(job);
block_job_resume(job);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, Error **VAR_1)
{
BlockJob *job = find_block_job(VAR_0);
if (!job) {
error_set(VAR_1, QERR_BLOCK_JOB_NOT_ACTIVE, VAR_0);
return;
}
trace_qmp_block_job_resume(job);
block_job_resume(job);
}
| [
"void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"BlockJob *job = find_block_job(VAR_0);",
"if (!job) {",
"error_set(VAR_1, QERR_BLOCK_JOB_NOT_ACTIVE, VAR_0);",
"return;",
"}",
"trace_qmp_block_job_resume(job);",
"block_job_resume(job);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
19,958 | int AUD_write (SWVoiceOut *sw, void *buf, int size)
{
int bytes;
if (!sw) {
/* XXX: Consider options */
return size;
}
if (!sw->hw->enabled) {
dolog ("Writing to disabled voice %s\n", SW_NAME (sw));
return 0;
}
bytes = sw->hw->pcm_ops->write (sw, buf, size);
return bytes;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | int AUD_write (SWVoiceOut *sw, void *buf, int size)
{
int bytes;
if (!sw) {
return size;
}
if (!sw->hw->enabled) {
dolog ("Writing to disabled voice %s\n", SW_NAME (sw));
return 0;
}
bytes = sw->hw->pcm_ops->write (sw, buf, size);
return bytes;
}
| {
"code": [],
"line_no": []
} | int FUNC_0 (SWVoiceOut *VAR_0, void *VAR_1, int VAR_2)
{
int VAR_3;
if (!VAR_0) {
return VAR_2;
}
if (!VAR_0->hw->enabled) {
dolog ("Writing to disabled voice %s\n", SW_NAME (VAR_0));
return 0;
}
VAR_3 = VAR_0->hw->pcm_ops->write (VAR_0, VAR_1, VAR_2);
return VAR_3;
}
| [
"int FUNC_0 (SWVoiceOut *VAR_0, void *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"if (!VAR_0) {",
"return VAR_2;",
"}",
"if (!VAR_0->hw->enabled) {",
"dolog (\"Writing to disabled voice %s\\n\", SW_NAME (VAR_0));",
"return 0;",
"}",
"VAR_3 = VAR_0->hw->pcm_ops->write (VAR_0, VAR_1, VAR_2);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
]
] |
19,959 | static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size)
{
RomResetData *rrd = qemu_malloc(sizeof *rrd);
rrd->data = qemu_malloc(size);
cpu_physical_memory_read(addr, rrd->data, size);
rrd->addr = addr;
rrd->size = size;
qemu_register_reset(option_rom_reset, rrd);
}
| false | qemu | 45a50b1668822c23afc2a89f724654e176518bc4 | static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size)
{
RomResetData *rrd = qemu_malloc(sizeof *rrd);
rrd->data = qemu_malloc(size);
cpu_physical_memory_read(addr, rrd->data, size);
rrd->addr = addr;
rrd->size = size;
qemu_register_reset(option_rom_reset, rrd);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(target_phys_addr_t VAR_0, unsigned VAR_1)
{
RomResetData *rrd = qemu_malloc(sizeof *rrd);
rrd->data = qemu_malloc(VAR_1);
cpu_physical_memory_read(VAR_0, rrd->data, VAR_1);
rrd->VAR_0 = VAR_0;
rrd->VAR_1 = VAR_1;
qemu_register_reset(option_rom_reset, rrd);
}
| [
"static void FUNC_0(target_phys_addr_t VAR_0, unsigned VAR_1)\n{",
"RomResetData *rrd = qemu_malloc(sizeof *rrd);",
"rrd->data = qemu_malloc(VAR_1);",
"cpu_physical_memory_read(VAR_0, rrd->data, VAR_1);",
"rrd->VAR_0 = VAR_0;",
"rrd->VAR_1 = VAR_1;",
"qemu_register_reset(option_rom_reset, rrd);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,960 | static uint32_t drc_unisolate_physical(sPAPRDRConnector *drc)
{
/* cannot unisolate a non-existent resource, and, or resources
* which are in an 'UNUSABLE' allocation state. (PAPR 2.7,
* 13.5.3.5)
*/
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
return RTAS_OUT_SUCCESS;
}
| false | qemu | 9d4c0f4f0a71e74fd7e04d73620268484d693adf | static uint32_t drc_unisolate_physical(sPAPRDRConnector *drc)
{
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
return RTAS_OUT_SUCCESS;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(sPAPRDRConnector *drc)
{
if (!drc->dev) {
return RTAS_OUT_NO_SUCH_INDICATOR;
}
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
return RTAS_OUT_SUCCESS;
}
| [
"static uint32_t FUNC_0(sPAPRDRConnector *drc)\n{",
"if (!drc->dev) {",
"return RTAS_OUT_NO_SUCH_INDICATOR;",
"}",
"drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;",
"return RTAS_OUT_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
]
] |
19,961 | static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque)
{
monitor_suspend(mon);
handle_user_command(mon, cmdline);
monitor_resume(mon);
}
| false | qemu | c60bf3391bf4cb79b7adc6650094e21671ddaabd | static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque)
{
monitor_suspend(mon);
handle_user_command(mon, cmdline);
monitor_resume(mon);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, const char *VAR_1, void *VAR_2)
{
monitor_suspend(VAR_0);
handle_user_command(VAR_0, VAR_1);
monitor_resume(VAR_0);
}
| [
"static void FUNC_0(Monitor *VAR_0, const char *VAR_1, void *VAR_2)\n{",
"monitor_suspend(VAR_0);",
"handle_user_command(VAR_0, VAR_1);",
"monitor_resume(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
19,964 | static void dct_unquantize_mpeg1_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int i, level, nCoeffs;
const UINT16 *quant_matrix;
if(s->alternate_scan) nCoeffs= 64;
else nCoeffs= s->block_last_index[n]+1;
if (s->mb_intra) {
if (n < 4)
block[0] = block[0] * s->y_dc_scale;
else
block[0] = block[0] * s->c_dc_scale;
/* XXX: only mpeg1 */
quant_matrix = s->intra_matrix;
for(i=1;i<nCoeffs;i++) {
int j= zigzag_direct[i];
level = block[j];
if (level) {
if (level < 0) {
level = -level;
level = (int)(level * qscale * quant_matrix[j]) >> 3;
level = (level - 1) | 1;
level = -level;
} else {
level = (int)(level * qscale * quant_matrix[j]) >> 3;
level = (level - 1) | 1;
}
#ifdef PARANOID
if (level < -2048 || level > 2047)
fprintf(stderr, "unquant error %d %d\n", i, level);
#endif
block[j] = level;
}
}
} else {
i = 0;
quant_matrix = s->non_intra_matrix;
for(;i<nCoeffs;i++) {
int j= zigzag_direct[i];
level = block[j];
if (level) {
if (level < 0) {
level = -level;
level = (((level << 1) + 1) * qscale *
((int) (quant_matrix[j]))) >> 4;
level = (level - 1) | 1;
level = -level;
} else {
level = (((level << 1) + 1) * qscale *
((int) (quant_matrix[j]))) >> 4;
level = (level - 1) | 1;
}
#ifdef PARANOID
if (level < -2048 || level > 2047)
fprintf(stderr, "unquant error %d %d\n", i, level);
#endif
block[j] = level;
}
}
}
}
| true | FFmpeg | d7e9533aa06f4073a27812349b35ba5fede11ca1 | static void dct_unquantize_mpeg1_c(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int i, level, nCoeffs;
const UINT16 *quant_matrix;
if(s->alternate_scan) nCoeffs= 64;
else nCoeffs= s->block_last_index[n]+1;
if (s->mb_intra) {
if (n < 4)
block[0] = block[0] * s->y_dc_scale;
else
block[0] = block[0] * s->c_dc_scale;
quant_matrix = s->intra_matrix;
for(i=1;i<nCoeffs;i++) {
int j= zigzag_direct[i];
level = block[j];
if (level) {
if (level < 0) {
level = -level;
level = (int)(level * qscale * quant_matrix[j]) >> 3;
level = (level - 1) | 1;
level = -level;
} else {
level = (int)(level * qscale * quant_matrix[j]) >> 3;
level = (level - 1) | 1;
}
#ifdef PARANOID
if (level < -2048 || level > 2047)
fprintf(stderr, "unquant error %d %d\n", i, level);
#endif
block[j] = level;
}
}
} else {
i = 0;
quant_matrix = s->non_intra_matrix;
for(;i<nCoeffs;i++) {
int j= zigzag_direct[i];
level = block[j];
if (level) {
if (level < 0) {
level = -level;
level = (((level << 1) + 1) * qscale *
((int) (quant_matrix[j]))) >> 4;
level = (level - 1) | 1;
level = -level;
} else {
level = (((level << 1) + 1) * qscale *
((int) (quant_matrix[j]))) >> 4;
level = (level - 1) | 1;
}
#ifdef PARANOID
if (level < -2048 || level > 2047)
fprintf(stderr, "unquant error %d %d\n", i, level);
#endif
block[j] = level;
}
}
}
}
| {
"code": [
" quant_matrix = s->non_intra_matrix;",
" quant_matrix = s->non_intra_matrix;",
" i = 0;",
"#endif",
"#endif",
"#endif",
" } else {",
" } else {",
"#ifdef PARANOID",
"#endif",
" quant_matrix = s->non_intra_matrix;",
" quant_matrix = s->non_intra_matrix;"
],
"line_no": [
77,
77,
75,
65,
65,
65,
73,
73,
59,
65,
77,
77
]
} | static void FUNC_0(MpegEncContext *VAR_0,
DCTELEM *VAR_1, int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6;
const UINT16 *VAR_7;
if(VAR_0->alternate_scan) VAR_6= 64;
else VAR_6= VAR_0->block_last_index[VAR_2]+1;
if (VAR_0->mb_intra) {
if (VAR_2 < 4)
VAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale;
else
VAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale;
VAR_7 = VAR_0->intra_matrix;
for(VAR_4=1;VAR_4<VAR_6;VAR_4++) {
int VAR_9= zigzag_direct[VAR_4];
VAR_5 = VAR_1[VAR_9];
if (VAR_5) {
if (VAR_5 < 0) {
VAR_5 = -VAR_5;
VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_9]) >> 3;
VAR_5 = (VAR_5 - 1) | 1;
VAR_5 = -VAR_5;
} else {
VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_9]) >> 3;
VAR_5 = (VAR_5 - 1) | 1;
}
#ifdef PARANOID
if (VAR_5 < -2048 || VAR_5 > 2047)
fprintf(stderr, "unquant error %d %d\VAR_2", VAR_4, VAR_5);
#endif
VAR_1[VAR_9] = VAR_5;
}
}
} else {
VAR_4 = 0;
VAR_7 = VAR_0->non_intra_matrix;
for(;VAR_4<VAR_6;VAR_4++) {
int VAR_9= zigzag_direct[VAR_4];
VAR_5 = VAR_1[VAR_9];
if (VAR_5) {
if (VAR_5 < 0) {
VAR_5 = -VAR_5;
VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *
((int) (VAR_7[VAR_9]))) >> 4;
VAR_5 = (VAR_5 - 1) | 1;
VAR_5 = -VAR_5;
} else {
VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *
((int) (VAR_7[VAR_9]))) >> 4;
VAR_5 = (VAR_5 - 1) | 1;
}
#ifdef PARANOID
if (VAR_5 < -2048 || VAR_5 > 2047)
fprintf(stderr, "unquant error %d %d\VAR_2", VAR_4, VAR_5);
#endif
VAR_1[VAR_9] = VAR_5;
}
}
}
}
| [
"static void FUNC_0(MpegEncContext *VAR_0,\nDCTELEM *VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"const UINT16 *VAR_7;",
"if(VAR_0->alternate_scan) VAR_6= 64;",
"else VAR_6= VAR_0->block_last_index[VAR_2]+1;",
"if (VAR_0->mb_intra) {",
"if (VAR_2 < 4)\nVAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale;",
"else\nVAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale;",
"VAR_7 = VAR_0->intra_matrix;",
"for(VAR_4=1;VAR_4<VAR_6;VAR_4++) {",
"int VAR_9= zigzag_direct[VAR_4];",
"VAR_5 = VAR_1[VAR_9];",
"if (VAR_5) {",
"if (VAR_5 < 0) {",
"VAR_5 = -VAR_5;",
"VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_9]) >> 3;",
"VAR_5 = (VAR_5 - 1) | 1;",
"VAR_5 = -VAR_5;",
"} else {",
"VAR_5 = (int)(VAR_5 * VAR_3 * VAR_7[VAR_9]) >> 3;",
"VAR_5 = (VAR_5 - 1) | 1;",
"}",
"#ifdef PARANOID\nif (VAR_5 < -2048 || VAR_5 > 2047)\nfprintf(stderr, \"unquant error %d %d\\VAR_2\", VAR_4, VAR_5);",
"#endif\nVAR_1[VAR_9] = VAR_5;",
"}",
"}",
"} else {",
"VAR_4 = 0;",
"VAR_7 = VAR_0->non_intra_matrix;",
"for(;VAR_4<VAR_6;VAR_4++) {",
"int VAR_9= zigzag_direct[VAR_4];",
"VAR_5 = VAR_1[VAR_9];",
"if (VAR_5) {",
"if (VAR_5 < 0) {",
"VAR_5 = -VAR_5;",
"VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *\n((int) (VAR_7[VAR_9]))) >> 4;",
"VAR_5 = (VAR_5 - 1) | 1;",
"VAR_5 = -VAR_5;",
"} else {",
"VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *\n((int) (VAR_7[VAR_9]))) >> 4;",
"VAR_5 = (VAR_5 - 1) | 1;",
"}",
"#ifdef PARANOID\nif (VAR_5 < -2048 || VAR_5 > 2047)\nfprintf(stderr, \"unquant error %d %d\\VAR_2\", VAR_4, VAR_5);",
"#endif\nVAR_1[VAR_9] = VAR_5;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25,
27
],
[
31
],
[
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
]
] |
19,967 | static void balloon_stats_get_all(Object *obj, struct Visitor *v,
void *opaque, const char *name, Error **errp)
{
Error *err = NULL;
VirtIOBalloon *s = opaque;
int i;
if (!s->stats_last_update) {
error_setg(errp, "guest hasn't updated any stats yet");
return;
}
visit_start_struct(v, NULL, "guest-stats", name, 0, &err);
if (err) {
goto out;
}
visit_type_int(v, &s->stats_last_update, "last-update", &err);
visit_start_struct(v, NULL, NULL, "stats", 0, &err);
if (err) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
visit_type_int64(v, (int64_t *) &s->stats[i], balloon_stat_names[i],
&err);
}
visit_end_struct(v, &err);
out_end:
visit_end_struct(v, &err);
out:
error_propagate(errp, err);
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | static void balloon_stats_get_all(Object *obj, struct Visitor *v,
void *opaque, const char *name, Error **errp)
{
Error *err = NULL;
VirtIOBalloon *s = opaque;
int i;
if (!s->stats_last_update) {
error_setg(errp, "guest hasn't updated any stats yet");
return;
}
visit_start_struct(v, NULL, "guest-stats", name, 0, &err);
if (err) {
goto out;
}
visit_type_int(v, &s->stats_last_update, "last-update", &err);
visit_start_struct(v, NULL, NULL, "stats", 0, &err);
if (err) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
visit_type_int64(v, (int64_t *) &s->stats[i], balloon_stat_names[i],
&err);
}
visit_end_struct(v, &err);
out_end:
visit_end_struct(v, &err);
out:
error_propagate(errp, err);
}
| {
"code": [
" visit_end_struct(v, &err);",
" for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {",
" goto out;",
" Error *err = NULL;"
],
"line_no": [
57,
49,
29,
7
]
} | static void FUNC_0(Object *VAR_0, struct Visitor *VAR_1,
void *VAR_2, const char *VAR_3, Error **VAR_4)
{
Error *err = NULL;
VirtIOBalloon *s = VAR_2;
int VAR_5;
if (!s->stats_last_update) {
error_setg(VAR_4, "guest hasn't updated any stats yet");
return;
}
visit_start_struct(VAR_1, NULL, "guest-stats", VAR_3, 0, &err);
if (err) {
goto out;
}
visit_type_int(VAR_1, &s->stats_last_update, "last-update", &err);
visit_start_struct(VAR_1, NULL, NULL, "stats", 0, &err);
if (err) {
goto out_end;
}
for (VAR_5 = 0; VAR_5 < VIRTIO_BALLOON_S_NR; VAR_5++) {
visit_type_int64(VAR_1, (int64_t *) &s->stats[VAR_5], balloon_stat_names[VAR_5],
&err);
}
visit_end_struct(VAR_1, &err);
out_end:
visit_end_struct(VAR_1, &err);
out:
error_propagate(VAR_4, err);
}
| [
"static void FUNC_0(Object *VAR_0, struct Visitor *VAR_1,\nvoid *VAR_2, const char *VAR_3, Error **VAR_4)\n{",
"Error *err = NULL;",
"VirtIOBalloon *s = VAR_2;",
"int VAR_5;",
"if (!s->stats_last_update) {",
"error_setg(VAR_4, \"guest hasn't updated any stats yet\");",
"return;",
"}",
"visit_start_struct(VAR_1, NULL, \"guest-stats\", VAR_3, 0, &err);",
"if (err) {",
"goto out;",
"}",
"visit_type_int(VAR_1, &s->stats_last_update, \"last-update\", &err);",
"visit_start_struct(VAR_1, NULL, NULL, \"stats\", 0, &err);",
"if (err) {",
"goto out_end;",
"}",
"for (VAR_5 = 0; VAR_5 < VIRTIO_BALLOON_S_NR; VAR_5++) {",
"visit_type_int64(VAR_1, (int64_t *) &s->stats[VAR_5], balloon_stat_names[VAR_5],\n&err);",
"}",
"visit_end_struct(VAR_1, &err);",
"out_end:\nvisit_end_struct(VAR_1, &err);",
"out:\nerror_propagate(VAR_4, err);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61,
63
],
[
67,
69
],
[
71
]
] |
19,968 | void qemuio_add_command(const cmdinfo_t *ci)
{
cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));
cmdtab[ncmds - 1] = *ci;
qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);
}
| true | qemu | 02c4f26b1517d9e403ec10d6f6ca3c0276d19e43 | void qemuio_add_command(const cmdinfo_t *ci)
{
cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));
cmdtab[ncmds - 1] = *ci;
qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);
}
| {
"code": [
" cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));"
],
"line_no": [
5
]
} | void FUNC_0(const cmdinfo_t *VAR_0)
{
cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));
cmdtab[ncmds - 1] = *VAR_0;
qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);
}
| [
"void FUNC_0(const cmdinfo_t *VAR_0)\n{",
"cmdtab = g_realloc(cmdtab, ++ncmds * sizeof(*cmdtab));",
"cmdtab[ncmds - 1] = *VAR_0;",
"qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
19,969 | static void max_x86_cpu_initfn(Object *obj)
{
X86CPU *cpu = X86_CPU(obj);
CPUX86State *env = &cpu->env;
KVMState *s = kvm_state;
/* We can't fill the features array here because we don't know yet if
* "migratable" is true or false.
*/
cpu->max_features = true;
if (kvm_enabled()) {
X86CPUDefinition host_cpudef = { };
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,
&host_cpudef.model, &host_cpudef.stepping);
cpu_x86_fill_model_id(host_cpudef.model_id);
x86_cpu_load_def(cpu, &host_cpudef, &error_abort);
env->cpuid_min_level =
kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
env->cpuid_min_xlevel =
kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
env->cpuid_min_xlevel2 =
kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (lmce_supported()) {
object_property_set_bool(OBJECT(cpu), true, "lmce", &error_abort);
}
} else {
object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,
"vendor", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "family", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "model", &error_abort);
object_property_set_int(OBJECT(cpu), 3, "stepping", &error_abort);
object_property_set_str(OBJECT(cpu),
"QEMU TCG CPU version " QEMU_HW_VERSION,
"model-id", &error_abort);
}
object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
}
| true | qemu | bd1820227ecc0c77cc2aeba7c7c25b2d0a72ff3c | static void max_x86_cpu_initfn(Object *obj)
{
X86CPU *cpu = X86_CPU(obj);
CPUX86State *env = &cpu->env;
KVMState *s = kvm_state;
cpu->max_features = true;
if (kvm_enabled()) {
X86CPUDefinition host_cpudef = { };
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,
&host_cpudef.model, &host_cpudef.stepping);
cpu_x86_fill_model_id(host_cpudef.model_id);
x86_cpu_load_def(cpu, &host_cpudef, &error_abort);
env->cpuid_min_level =
kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
env->cpuid_min_xlevel =
kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
env->cpuid_min_xlevel2 =
kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (lmce_supported()) {
object_property_set_bool(OBJECT(cpu), true, "lmce", &error_abort);
}
} else {
object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,
"vendor", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "family", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "model", &error_abort);
object_property_set_int(OBJECT(cpu), 3, "stepping", &error_abort);
object_property_set_str(OBJECT(cpu),
"QEMU TCG CPU version " QEMU_HW_VERSION,
"model-id", &error_abort);
}
object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
}
| {
"code": [
" X86CPUDefinition host_cpudef = { };",
" uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;",
" host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,",
" &host_cpudef.model, &host_cpudef.stepping);",
" cpu_x86_fill_model_id(host_cpudef.model_id);",
" x86_cpu_load_def(cpu, &host_cpudef, &error_abort);"
],
"line_no": [
25,
27,
31,
33,
37,
41
]
} | static void FUNC_0(Object *VAR_0)
{
X86CPU *cpu = X86_CPU(VAR_0);
CPUX86State *env = &cpu->env;
KVMState *s = kvm_state;
cpu->max_features = true;
if (kvm_enabled()) {
X86CPUDefinition host_cpudef = { };
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,
&host_cpudef.model, &host_cpudef.stepping);
cpu_x86_fill_model_id(host_cpudef.model_id);
x86_cpu_load_def(cpu, &host_cpudef, &error_abort);
env->cpuid_min_level =
kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
env->cpuid_min_xlevel =
kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
env->cpuid_min_xlevel2 =
kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (lmce_supported()) {
object_property_set_bool(OBJECT(cpu), true, "lmce", &error_abort);
}
} else {
object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,
"vendor", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "family", &error_abort);
object_property_set_int(OBJECT(cpu), 6, "model", &error_abort);
object_property_set_int(OBJECT(cpu), 3, "stepping", &error_abort);
object_property_set_str(OBJECT(cpu),
"QEMU TCG CPU version " QEMU_HW_VERSION,
"model-id", &error_abort);
}
object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"X86CPU *cpu = X86_CPU(VAR_0);",
"CPUX86State *env = &cpu->env;",
"KVMState *s = kvm_state;",
"cpu->max_features = true;",
"if (kvm_enabled()) {",
"X86CPUDefinition host_cpudef = { };",
"uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;",
"host_vendor_fms(host_cpudef.vendor, &host_cpudef.family,\n&host_cpudef.model, &host_cpudef.stepping);",
"cpu_x86_fill_model_id(host_cpudef.model_id);",
"x86_cpu_load_def(cpu, &host_cpudef, &error_abort);",
"env->cpuid_min_level =\nkvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);",
"env->cpuid_min_xlevel =\nkvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);",
"env->cpuid_min_xlevel2 =\nkvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);",
"if (lmce_supported()) {",
"object_property_set_bool(OBJECT(cpu), true, \"lmce\", &error_abort);",
"}",
"} else {",
"object_property_set_str(OBJECT(cpu), CPUID_VENDOR_AMD,\n\"vendor\", &error_abort);",
"object_property_set_int(OBJECT(cpu), 6, \"family\", &error_abort);",
"object_property_set_int(OBJECT(cpu), 6, \"model\", &error_abort);",
"object_property_set_int(OBJECT(cpu), 3, \"stepping\", &error_abort);",
"object_property_set_str(OBJECT(cpu),\n\"QEMU TCG CPU version \" QEMU_HW_VERSION,\n\"model-id\", &error_abort);",
"}",
"object_property_set_bool(OBJECT(cpu), true, \"pmu\", &error_abort);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
37
],
[
41
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
87
],
[
89
]
] |
19,971 | static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
{
struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
int ret, i;
ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name);
if (ret < 0) {
error_report("vfio: error getting device %s from group %d: %m\n",
name, group->groupid);
error_report("Verify all devices in group %d are bound to vfio-pci "
"or pci-stub and not already in use\n", group->groupid);
return ret;
}
vdev->fd = ret;
vdev->group = group;
QLIST_INSERT_HEAD(&group->device_list, vdev, next);
/* Sanity check device */
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &dev_info);
if (ret) {
error_report("vfio: error getting device info: %m\n");
goto error;
}
DPRINTF("Device %s flags: %u, regions: %u, irgs: %u\n", name,
dev_info.flags, dev_info.num_regions, dev_info.num_irqs);
if (!(dev_info.flags & VFIO_DEVICE_FLAGS_PCI)) {
error_report("vfio: Um, this isn't a PCI device\n");
goto error;
}
vdev->reset_works = !!(dev_info.flags & VFIO_DEVICE_FLAGS_RESET);
if (!vdev->reset_works) {
error_report("Warning, device %s does not support reset\n", name);
}
if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) {
error_report("vfio: unexpected number of io regions %u\n",
dev_info.num_regions);
goto error;
}
if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) {
error_report("vfio: unexpected number of irqs %u\n", dev_info.num_irqs);
goto error;
}
for (i = VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; i++) {
reg_info.index = i;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting region %d info: %m\n", i);
goto error;
}
DPRINTF("Device %s region %d:\n", name, i);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->bars[i].flags = reg_info.flags;
vdev->bars[i].size = reg_info.size;
vdev->bars[i].fd_offset = reg_info.offset;
vdev->bars[i].fd = vdev->fd;
vdev->bars[i].nr = i;
}
reg_info.index = VFIO_PCI_ROM_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting ROM info: %m\n");
goto error;
}
DPRINTF("Device %s ROM:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = reg_info.size;
vdev->rom_offset = reg_info.offset;
reg_info.index = VFIO_PCI_CONFIG_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting config info: %m\n");
goto error;
}
DPRINTF("Device %s config:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->config_size = reg_info.size;
vdev->config_offset = reg_info.offset;
error:
if (ret) {
QLIST_REMOVE(vdev, next);
vdev->group = NULL;
close(vdev->fd);
}
return ret;
}
| true | qemu | 8fc94e5a8046e349e07976f9bcaffbcd5833f3a2 | static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
{
struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
int ret, i;
ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name);
if (ret < 0) {
error_report("vfio: error getting device %s from group %d: %m\n",
name, group->groupid);
error_report("Verify all devices in group %d are bound to vfio-pci "
"or pci-stub and not already in use\n", group->groupid);
return ret;
}
vdev->fd = ret;
vdev->group = group;
QLIST_INSERT_HEAD(&group->device_list, vdev, next);
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &dev_info);
if (ret) {
error_report("vfio: error getting device info: %m\n");
goto error;
}
DPRINTF("Device %s flags: %u, regions: %u, irgs: %u\n", name,
dev_info.flags, dev_info.num_regions, dev_info.num_irqs);
if (!(dev_info.flags & VFIO_DEVICE_FLAGS_PCI)) {
error_report("vfio: Um, this isn't a PCI device\n");
goto error;
}
vdev->reset_works = !!(dev_info.flags & VFIO_DEVICE_FLAGS_RESET);
if (!vdev->reset_works) {
error_report("Warning, device %s does not support reset\n", name);
}
if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) {
error_report("vfio: unexpected number of io regions %u\n",
dev_info.num_regions);
goto error;
}
if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) {
error_report("vfio: unexpected number of irqs %u\n", dev_info.num_irqs);
goto error;
}
for (i = VFIO_PCI_BAR0_REGION_INDEX; i < VFIO_PCI_ROM_REGION_INDEX; i++) {
reg_info.index = i;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting region %d info: %m\n", i);
goto error;
}
DPRINTF("Device %s region %d:\n", name, i);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->bars[i].flags = reg_info.flags;
vdev->bars[i].size = reg_info.size;
vdev->bars[i].fd_offset = reg_info.offset;
vdev->bars[i].fd = vdev->fd;
vdev->bars[i].nr = i;
}
reg_info.index = VFIO_PCI_ROM_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting ROM info: %m\n");
goto error;
}
DPRINTF("Device %s ROM:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->rom_size = reg_info.size;
vdev->rom_offset = reg_info.offset;
reg_info.index = VFIO_PCI_CONFIG_REGION_INDEX;
ret = ioctl(vdev->fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
if (ret) {
error_report("vfio: Error getting config info: %m\n");
goto error;
}
DPRINTF("Device %s config:\n", name);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)reg_info.size, (unsigned long)reg_info.offset,
(unsigned long)reg_info.flags);
vdev->config_size = reg_info.size;
vdev->config_offset = reg_info.offset;
error:
if (ret) {
QLIST_REMOVE(vdev, next);
vdev->group = NULL;
close(vdev->fd);
}
return ret;
}
| {
"code": [
" if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) {",
" if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) {"
],
"line_no": [
79,
91
]
} | static int FUNC_0(VFIOGroup *VAR_0, const char *VAR_1, VFIODevice *VAR_2)
{
struct vfio_device_info VAR_3 = { .argsz = sizeof(VAR_3) };
struct vfio_region_info VAR_4 = { .argsz = sizeof(VAR_4) };
int VAR_5, VAR_6;
VAR_5 = ioctl(VAR_0->fd, VFIO_GROUP_GET_DEVICE_FD, VAR_1);
if (VAR_5 < 0) {
error_report("vfio: error getting device %s from VAR_0 %d: %m\n",
VAR_1, VAR_0->groupid);
error_report("Verify all devices in VAR_0 %d are bound to vfio-pci "
"or pci-stub and not already in use\n", VAR_0->groupid);
return VAR_5;
}
VAR_2->fd = VAR_5;
VAR_2->VAR_0 = VAR_0;
QLIST_INSERT_HEAD(&VAR_0->device_list, VAR_2, next);
VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_INFO, &VAR_3);
if (VAR_5) {
error_report("vfio: error getting device info: %m\n");
goto error;
}
DPRINTF("Device %s flags: %u, regions: %u, irgs: %u\n", VAR_1,
VAR_3.flags, VAR_3.num_regions, VAR_3.num_irqs);
if (!(VAR_3.flags & VFIO_DEVICE_FLAGS_PCI)) {
error_report("vfio: Um, this isn't a PCI device\n");
goto error;
}
VAR_2->reset_works = !!(VAR_3.flags & VFIO_DEVICE_FLAGS_RESET);
if (!VAR_2->reset_works) {
error_report("Warning, device %s does not support reset\n", VAR_1);
}
if (VAR_3.num_regions != VFIO_PCI_NUM_REGIONS) {
error_report("vfio: unexpected number of io regions %u\n",
VAR_3.num_regions);
goto error;
}
if (VAR_3.num_irqs != VFIO_PCI_NUM_IRQS) {
error_report("vfio: unexpected number of irqs %u\n", VAR_3.num_irqs);
goto error;
}
for (VAR_6 = VFIO_PCI_BAR0_REGION_INDEX; VAR_6 < VFIO_PCI_ROM_REGION_INDEX; VAR_6++) {
VAR_4.index = VAR_6;
VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);
if (VAR_5) {
error_report("vfio: Error getting region %d info: %m\n", VAR_6);
goto error;
}
DPRINTF("Device %s region %d:\n", VAR_1, VAR_6);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,
(unsigned long)VAR_4.flags);
VAR_2->bars[VAR_6].flags = VAR_4.flags;
VAR_2->bars[VAR_6].size = VAR_4.size;
VAR_2->bars[VAR_6].fd_offset = VAR_4.offset;
VAR_2->bars[VAR_6].fd = VAR_2->fd;
VAR_2->bars[VAR_6].nr = VAR_6;
}
VAR_4.index = VFIO_PCI_ROM_REGION_INDEX;
VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);
if (VAR_5) {
error_report("vfio: Error getting ROM info: %m\n");
goto error;
}
DPRINTF("Device %s ROM:\n", VAR_1);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,
(unsigned long)VAR_4.flags);
VAR_2->rom_size = VAR_4.size;
VAR_2->rom_offset = VAR_4.offset;
VAR_4.index = VFIO_PCI_CONFIG_REGION_INDEX;
VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);
if (VAR_5) {
error_report("vfio: Error getting config info: %m\n");
goto error;
}
DPRINTF("Device %s config:\n", VAR_1);
DPRINTF(" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\n",
(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,
(unsigned long)VAR_4.flags);
VAR_2->config_size = VAR_4.size;
VAR_2->config_offset = VAR_4.offset;
error:
if (VAR_5) {
QLIST_REMOVE(VAR_2, next);
VAR_2->VAR_0 = NULL;
close(VAR_2->fd);
}
return VAR_5;
}
| [
"static int FUNC_0(VFIOGroup *VAR_0, const char *VAR_1, VFIODevice *VAR_2)\n{",
"struct vfio_device_info VAR_3 = { .argsz = sizeof(VAR_3) };",
"struct vfio_region_info VAR_4 = { .argsz = sizeof(VAR_4) };",
"int VAR_5, VAR_6;",
"VAR_5 = ioctl(VAR_0->fd, VFIO_GROUP_GET_DEVICE_FD, VAR_1);",
"if (VAR_5 < 0) {",
"error_report(\"vfio: error getting device %s from VAR_0 %d: %m\\n\",\nVAR_1, VAR_0->groupid);",
"error_report(\"Verify all devices in VAR_0 %d are bound to vfio-pci \"\n\"or pci-stub and not already in use\\n\", VAR_0->groupid);",
"return VAR_5;",
"}",
"VAR_2->fd = VAR_5;",
"VAR_2->VAR_0 = VAR_0;",
"QLIST_INSERT_HEAD(&VAR_0->device_list, VAR_2, next);",
"VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_INFO, &VAR_3);",
"if (VAR_5) {",
"error_report(\"vfio: error getting device info: %m\\n\");",
"goto error;",
"}",
"DPRINTF(\"Device %s flags: %u, regions: %u, irgs: %u\\n\", VAR_1,\nVAR_3.flags, VAR_3.num_regions, VAR_3.num_irqs);",
"if (!(VAR_3.flags & VFIO_DEVICE_FLAGS_PCI)) {",
"error_report(\"vfio: Um, this isn't a PCI device\\n\");",
"goto error;",
"}",
"VAR_2->reset_works = !!(VAR_3.flags & VFIO_DEVICE_FLAGS_RESET);",
"if (!VAR_2->reset_works) {",
"error_report(\"Warning, device %s does not support reset\\n\", VAR_1);",
"}",
"if (VAR_3.num_regions != VFIO_PCI_NUM_REGIONS) {",
"error_report(\"vfio: unexpected number of io regions %u\\n\",\nVAR_3.num_regions);",
"goto error;",
"}",
"if (VAR_3.num_irqs != VFIO_PCI_NUM_IRQS) {",
"error_report(\"vfio: unexpected number of irqs %u\\n\", VAR_3.num_irqs);",
"goto error;",
"}",
"for (VAR_6 = VFIO_PCI_BAR0_REGION_INDEX; VAR_6 < VFIO_PCI_ROM_REGION_INDEX; VAR_6++) {",
"VAR_4.index = VAR_6;",
"VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);",
"if (VAR_5) {",
"error_report(\"vfio: Error getting region %d info: %m\\n\", VAR_6);",
"goto error;",
"}",
"DPRINTF(\"Device %s region %d:\\n\", VAR_1, VAR_6);",
"DPRINTF(\" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\\n\",\n(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,\n(unsigned long)VAR_4.flags);",
"VAR_2->bars[VAR_6].flags = VAR_4.flags;",
"VAR_2->bars[VAR_6].size = VAR_4.size;",
"VAR_2->bars[VAR_6].fd_offset = VAR_4.offset;",
"VAR_2->bars[VAR_6].fd = VAR_2->fd;",
"VAR_2->bars[VAR_6].nr = VAR_6;",
"}",
"VAR_4.index = VFIO_PCI_ROM_REGION_INDEX;",
"VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);",
"if (VAR_5) {",
"error_report(\"vfio: Error getting ROM info: %m\\n\");",
"goto error;",
"}",
"DPRINTF(\"Device %s ROM:\\n\", VAR_1);",
"DPRINTF(\" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\\n\",\n(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,\n(unsigned long)VAR_4.flags);",
"VAR_2->rom_size = VAR_4.size;",
"VAR_2->rom_offset = VAR_4.offset;",
"VAR_4.index = VFIO_PCI_CONFIG_REGION_INDEX;",
"VAR_5 = ioctl(VAR_2->fd, VFIO_DEVICE_GET_REGION_INFO, &VAR_4);",
"if (VAR_5) {",
"error_report(\"vfio: Error getting config info: %m\\n\");",
"goto error;",
"}",
"DPRINTF(\"Device %s config:\\n\", VAR_1);",
"DPRINTF(\" size: 0x%lx, offset: 0x%lx, flags: 0x%lx\\n\",\n(unsigned long)VAR_4.size, (unsigned long)VAR_4.offset,\n(unsigned long)VAR_4.flags);",
"VAR_2->config_size = VAR_4.size;",
"VAR_2->config_offset = VAR_4.offset;",
"error:\nif (VAR_5) {",
"QLIST_REMOVE(VAR_2, next);",
"VAR_2->VAR_0 = NULL;",
"close(VAR_2->fd);",
"}",
"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,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121,
123,
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161,
163,
165
],
[
169
],
[
171
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193,
195,
197
],
[
201
],
[
203
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
]
] |
19,972 | static int parse_inputs(const char **buf, AVFilterInOut **currInputs,
AVFilterInOut **openLinks, AVClass *log_ctx)
{
int pad = 0;
while(**buf == '[') {
char *name = parse_link_name(buf, log_ctx);
AVFilterInOut *match;
if(!name)
return -1;
/* First check if the label is not in the openLinks list */
match = extract_inout(name, openLinks);
if(match) {
/* A label of a open link. Make it one of the inputs of the next
filter */
if(match->type != LinkTypeOut) {
av_log(log_ctx, AV_LOG_ERROR,
"Label \"%s\" appears twice as input!\n", match->name);
return -1;
}
} else {
/* Not in the list, so add it as an input */
match = av_mallocz(sizeof(AVFilterInOut));
match->name = name;
match->type = LinkTypeIn;
match->pad_idx = pad;
}
insert_inout(currInputs, match);
*buf += consume_whitespace(*buf);
pad++;
}
return pad;
} | true | FFmpeg | 64fbf5e263a0698c6cf6e0580feebe9a6f502ae5 | static int parse_inputs(const char **buf, AVFilterInOut **currInputs,
AVFilterInOut **openLinks, AVClass *log_ctx)
{
int pad = 0;
while(**buf == '[') {
char *name = parse_link_name(buf, log_ctx);
AVFilterInOut *match;
if(!name)
return -1;
match = extract_inout(name, openLinks);
if(match) {
if(match->type != LinkTypeOut) {
av_log(log_ctx, AV_LOG_ERROR,
"Label \"%s\" appears twice as input!\n", match->name);
return -1;
}
} else {
match = av_mallocz(sizeof(AVFilterInOut));
match->name = name;
match->type = LinkTypeIn;
match->pad_idx = pad;
}
insert_inout(currInputs, match);
*buf += consume_whitespace(*buf);
pad++;
}
return pad;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(const char **VAR_0, AVFilterInOut **VAR_1,
AVFilterInOut **VAR_2, AVClass *VAR_3)
{
int VAR_4 = 0;
while(**VAR_0 == '[') {
char *VAR_5 = parse_link_name(VAR_0, VAR_3);
AVFilterInOut *match;
if(!VAR_5)
return -1;
match = extract_inout(VAR_5, VAR_2);
if(match) {
if(match->type != LinkTypeOut) {
av_log(VAR_3, AV_LOG_ERROR,
"Label \"%s\" appears twice as input!\n", match->VAR_5);
return -1;
}
} else {
match = av_mallocz(sizeof(AVFilterInOut));
match->VAR_5 = VAR_5;
match->type = LinkTypeIn;
match->pad_idx = VAR_4;
}
insert_inout(VAR_1, match);
*VAR_0 += consume_whitespace(*VAR_0);
VAR_4++;
}
return VAR_4;
} | [
"static int FUNC_0(const char **VAR_0, AVFilterInOut **VAR_1,\nAVFilterInOut **VAR_2, AVClass *VAR_3)\n{",
"int VAR_4 = 0;",
"while(**VAR_0 == '[') {",
"char *VAR_5 = parse_link_name(VAR_0, VAR_3);",
"AVFilterInOut *match;",
"if(!VAR_5)\nreturn -1;",
"match = extract_inout(VAR_5, VAR_2);",
"if(match) {",
"if(match->type != LinkTypeOut) {",
"av_log(VAR_3, AV_LOG_ERROR,\n\"Label \\\"%s\\\" appears twice as input!\\n\", match->VAR_5);",
"return -1;",
"}",
"} else {",
"match = av_mallocz(sizeof(AVFilterInOut));",
"match->VAR_5 = VAR_5;",
"match->type = LinkTypeIn;",
"match->pad_idx = VAR_4;",
"}",
"insert_inout(VAR_1, match);",
"*VAR_0 += consume_whitespace(*VAR_0);",
"VAR_4++;",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
27
],
[
31
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
48
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
64
],
[
68
],
[
70
],
[
72
],
[
76
],
[
78
]
] |
19,973 | static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
Error **errp)
{
const char *buf;
int bdrv_flags = 0;
int on_read_error, on_write_error;
BlockBackend *blk;
BlockDriverState *bs;
ThrottleConfig cfg;
int snapshot = 0;
Error *error = NULL;
QemuOpts *opts;
const char *id;
bool has_driver_specific_opts;
BlockdevDetectZeroesOptions detect_zeroes =
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
const char *throttling_group = NULL;
/* Check common options by copying from bs_opts to opts, all other options
* stay in bs_opts for processing by bdrv_open(). */
id = qdict_get_try_str(bs_opts, "id");
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
if (error) {
error_propagate(errp, error);
goto err_no_opts;
}
qemu_opts_absorb_qdict(opts, bs_opts, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if (id) {
qdict_del(bs_opts, "id");
}
has_driver_specific_opts = !!qdict_size(bs_opts);
/* extract parameters */
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true);
account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true);
extract_common_blockdev_options(opts, &bdrv_flags, &throttling_group, &cfg,
&detect_zeroes, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
goto early_err;
}
if (qdict_haskey(bs_opts, "driver")) {
error_setg(errp, "Cannot specify both 'driver' and 'format'");
goto early_err;
}
qdict_put(bs_opts, "driver", qstring_from_str(buf));
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
on_write_error = parse_block_error_action(buf, 0, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
on_read_error = parse_block_error_action(buf, 1, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
if (snapshot) {
/* always use cache=unsafe with snapshot */
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
/* init */
if ((!file || !*file) && !has_driver_specific_opts) {
BlockBackendRootState *blk_rs;
blk = blk_new(qemu_opts_id(opts), errp);
if (!blk) {
goto early_err;
}
blk_rs = blk_get_root_state(blk);
blk_rs->open_flags = bdrv_flags;
blk_rs->read_only = !(bdrv_flags & BDRV_O_RDWR);
blk_rs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
blk_rs->throttle_group = g_strdup(throttling_group);
blk_rs->throttle_state = throttle_group_incref(throttling_group);
blk_rs->throttle_state->cfg = cfg;
}
QDECREF(bs_opts);
} else {
if (file && !*file) {
file = NULL;
}
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags,
errp);
if (!blk) {
goto err_no_bs_opts;
}
bs = blk_bs(blk);
bs->detect_zeroes = detect_zeroes;
/* disk I/O throttling */
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
bdrv_io_limits_enable(bs, throttling_group);
bdrv_set_io_limits(bs, &cfg);
}
if (bdrv_key_required(bs)) {
autostart = 0;
}
block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
}
blk_set_on_error(blk, on_read_error, on_write_error);
err_no_bs_opts:
qemu_opts_del(opts);
return blk;
early_err:
qemu_opts_del(opts);
err_no_opts:
QDECREF(bs_opts);
return NULL;
} | true | qemu | 362e9299b34b3101aaa20f20363441c9f055fa5e | static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
Error **errp)
{
const char *buf;
int bdrv_flags = 0;
int on_read_error, on_write_error;
BlockBackend *blk;
BlockDriverState *bs;
ThrottleConfig cfg;
int snapshot = 0;
Error *error = NULL;
QemuOpts *opts;
const char *id;
bool has_driver_specific_opts;
BlockdevDetectZeroesOptions detect_zeroes =
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
const char *throttling_group = NULL;
id = qdict_get_try_str(bs_opts, "id");
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
if (error) {
error_propagate(errp, error);
goto err_no_opts;
}
qemu_opts_absorb_qdict(opts, bs_opts, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if (id) {
qdict_del(bs_opts, "id");
}
has_driver_specific_opts = !!qdict_size(bs_opts);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true);
account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true);
extract_common_blockdev_options(opts, &bdrv_flags, &throttling_group, &cfg,
&detect_zeroes, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(buf)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
goto early_err;
}
if (qdict_haskey(bs_opts, "driver")) {
error_setg(errp, "Cannot specify both 'driver' and 'format'");
goto early_err;
}
qdict_put(bs_opts, "driver", qstring_from_str(buf));
}
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
on_write_error = parse_block_error_action(buf, 0, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
on_read_error = BLOCKDEV_ON_ERROR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
on_read_error = parse_block_error_action(buf, 1, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if ((!file || !*file) && !has_driver_specific_opts) {
BlockBackendRootState *blk_rs;
blk = blk_new(qemu_opts_id(opts), errp);
if (!blk) {
goto early_err;
}
blk_rs = blk_get_root_state(blk);
blk_rs->open_flags = bdrv_flags;
blk_rs->read_only = !(bdrv_flags & BDRV_O_RDWR);
blk_rs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
blk_rs->throttle_group = g_strdup(throttling_group);
blk_rs->throttle_state = throttle_group_incref(throttling_group);
blk_rs->throttle_state->cfg = cfg;
}
QDECREF(bs_opts);
} else {
if (file && !*file) {
file = NULL;
}
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags,
errp);
if (!blk) {
goto err_no_bs_opts;
}
bs = blk_bs(blk);
bs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!throttling_group) {
throttling_group = blk_name(blk);
}
bdrv_io_limits_enable(bs, throttling_group);
bdrv_set_io_limits(bs, &cfg);
}
if (bdrv_key_required(bs)) {
autostart = 0;
}
block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
}
blk_set_on_error(blk, on_read_error, on_write_error);
err_no_bs_opts:
qemu_opts_del(opts);
return blk;
early_err:
qemu_opts_del(opts);
err_no_opts:
QDECREF(bs_opts);
return NULL;
} | {
"code": [],
"line_no": []
} | static BlockBackend *FUNC_0(const char *file, QDict *bs_opts,
Error **errp)
{
const char *VAR_0;
int VAR_1 = 0;
int VAR_2, VAR_3;
BlockBackend *blk;
BlockDriverState *bs;
ThrottleConfig cfg;
int VAR_4 = 0;
Error *error = NULL;
QemuOpts *opts;
const char *VAR_5;
bool has_driver_specific_opts;
BlockdevDetectZeroesOptions detect_zeroes =
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
const char *VAR_6 = NULL;
VAR_5 = qdict_get_try_str(bs_opts, "VAR_5");
opts = qemu_opts_create(&qemu_common_drive_opts, VAR_5, 1, &error);
if (error) {
error_propagate(errp, error);
goto err_no_opts;
}
qemu_opts_absorb_qdict(opts, bs_opts, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if (VAR_5) {
qdict_del(bs_opts, "VAR_5");
}
has_driver_specific_opts = !!qdict_size(bs_opts);
VAR_4 = qemu_opt_get_bool(opts, "VAR_4", 0);
account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true);
account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true);
extract_common_blockdev_options(opts, &VAR_1, &VAR_6, &cfg,
&detect_zeroes, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
if ((VAR_0 = qemu_opt_get(opts, "format")) != NULL) {
if (is_help_option(VAR_0)) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
goto early_err;
}
if (qdict_haskey(bs_opts, "driver")) {
error_setg(errp, "Cannot specify both 'driver' and 'format'");
goto early_err;
}
qdict_put(bs_opts, "driver", qstring_from_str(VAR_0));
}
VAR_3 = BLOCKDEV_ON_ERROR_ENOSPC;
if ((VAR_0 = qemu_opt_get(opts, "werror")) != NULL) {
VAR_3 = parse_block_error_action(VAR_0, 0, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
VAR_2 = BLOCKDEV_ON_ERROR_REPORT;
if ((VAR_0 = qemu_opt_get(opts, "rerror")) != NULL) {
VAR_2 = parse_block_error_action(VAR_0, 1, &error);
if (error) {
error_propagate(errp, error);
goto early_err;
}
}
if (VAR_4) {
VAR_1 &= ~BDRV_O_CACHE_MASK;
VAR_1 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if ((!file || !*file) && !has_driver_specific_opts) {
BlockBackendRootState *blk_rs;
blk = blk_new(qemu_opts_id(opts), errp);
if (!blk) {
goto early_err;
}
blk_rs = blk_get_root_state(blk);
blk_rs->open_flags = VAR_1;
blk_rs->read_only = !(VAR_1 & BDRV_O_RDWR);
blk_rs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!VAR_6) {
VAR_6 = blk_name(blk);
}
blk_rs->throttle_group = g_strdup(VAR_6);
blk_rs->throttle_state = throttle_group_incref(VAR_6);
blk_rs->throttle_state->cfg = cfg;
}
QDECREF(bs_opts);
} else {
if (file && !*file) {
file = NULL;
}
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, VAR_1,
errp);
if (!blk) {
goto err_no_bs_opts;
}
bs = blk_bs(blk);
bs->detect_zeroes = detect_zeroes;
if (throttle_enabled(&cfg)) {
if (!VAR_6) {
VAR_6 = blk_name(blk);
}
bdrv_io_limits_enable(bs, VAR_6);
bdrv_set_io_limits(bs, &cfg);
}
if (bdrv_key_required(bs)) {
autostart = 0;
}
block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
}
blk_set_on_error(blk, VAR_2, VAR_3);
err_no_bs_opts:
qemu_opts_del(opts);
return blk;
early_err:
qemu_opts_del(opts);
err_no_opts:
QDECREF(bs_opts);
return NULL;
} | [
"static BlockBackend *FUNC_0(const char *file, QDict *bs_opts,\nError **errp)\n{",
"const char *VAR_0;",
"int VAR_1 = 0;",
"int VAR_2, VAR_3;",
"BlockBackend *blk;",
"BlockDriverState *bs;",
"ThrottleConfig cfg;",
"int VAR_4 = 0;",
"Error *error = NULL;",
"QemuOpts *opts;",
"const char *VAR_5;",
"bool has_driver_specific_opts;",
"BlockdevDetectZeroesOptions detect_zeroes =\nBLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;",
"const char *VAR_6 = NULL;",
"VAR_5 = qdict_get_try_str(bs_opts, \"VAR_5\");",
"opts = qemu_opts_create(&qemu_common_drive_opts, VAR_5, 1, &error);",
"if (error) {",
"error_propagate(errp, error);",
"goto err_no_opts;",
"}",
"qemu_opts_absorb_qdict(opts, bs_opts, &error);",
"if (error) {",
"error_propagate(errp, error);",
"goto early_err;",
"}",
"if (VAR_5) {",
"qdict_del(bs_opts, \"VAR_5\");",
"}",
"has_driver_specific_opts = !!qdict_size(bs_opts);",
"VAR_4 = qemu_opt_get_bool(opts, \"VAR_4\", 0);",
"account_invalid = qemu_opt_get_bool(opts, \"stats-account-invalid\", true);",
"account_failed = qemu_opt_get_bool(opts, \"stats-account-failed\", true);",
"extract_common_blockdev_options(opts, &VAR_1, &VAR_6, &cfg,\n&detect_zeroes, &error);",
"if (error) {",
"error_propagate(errp, error);",
"goto early_err;",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"format\")) != NULL) {",
"if (is_help_option(VAR_0)) {",
"error_printf(\"Supported formats:\");",
"bdrv_iterate_format(bdrv_format_print, NULL);",
"error_printf(\"\\n\");",
"goto early_err;",
"}",
"if (qdict_haskey(bs_opts, \"driver\")) {",
"error_setg(errp, \"Cannot specify both 'driver' and 'format'\");",
"goto early_err;",
"}",
"qdict_put(bs_opts, \"driver\", qstring_from_str(VAR_0));",
"}",
"VAR_3 = BLOCKDEV_ON_ERROR_ENOSPC;",
"if ((VAR_0 = qemu_opt_get(opts, \"werror\")) != NULL) {",
"VAR_3 = parse_block_error_action(VAR_0, 0, &error);",
"if (error) {",
"error_propagate(errp, error);",
"goto early_err;",
"}",
"}",
"VAR_2 = BLOCKDEV_ON_ERROR_REPORT;",
"if ((VAR_0 = qemu_opt_get(opts, \"rerror\")) != NULL) {",
"VAR_2 = parse_block_error_action(VAR_0, 1, &error);",
"if (error) {",
"error_propagate(errp, error);",
"goto early_err;",
"}",
"}",
"if (VAR_4) {",
"VAR_1 &= ~BDRV_O_CACHE_MASK;",
"VAR_1 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);",
"}",
"if ((!file || !*file) && !has_driver_specific_opts) {",
"BlockBackendRootState *blk_rs;",
"blk = blk_new(qemu_opts_id(opts), errp);",
"if (!blk) {",
"goto early_err;",
"}",
"blk_rs = blk_get_root_state(blk);",
"blk_rs->open_flags = VAR_1;",
"blk_rs->read_only = !(VAR_1 & BDRV_O_RDWR);",
"blk_rs->detect_zeroes = detect_zeroes;",
"if (throttle_enabled(&cfg)) {",
"if (!VAR_6) {",
"VAR_6 = blk_name(blk);",
"}",
"blk_rs->throttle_group = g_strdup(VAR_6);",
"blk_rs->throttle_state = throttle_group_incref(VAR_6);",
"blk_rs->throttle_state->cfg = cfg;",
"}",
"QDECREF(bs_opts);",
"} else {",
"if (file && !*file) {",
"file = NULL;",
"}",
"blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, VAR_1,\nerrp);",
"if (!blk) {",
"goto err_no_bs_opts;",
"}",
"bs = blk_bs(blk);",
"bs->detect_zeroes = detect_zeroes;",
"if (throttle_enabled(&cfg)) {",
"if (!VAR_6) {",
"VAR_6 = blk_name(blk);",
"}",
"bdrv_io_limits_enable(bs, VAR_6);",
"bdrv_set_io_limits(bs, &cfg);",
"}",
"if (bdrv_key_required(bs)) {",
"autostart = 0;",
"}",
"block_acct_init(blk_get_stats(blk), account_invalid, account_failed);",
"}",
"blk_set_on_error(blk, VAR_2, VAR_3);",
"err_no_bs_opts:\nqemu_opts_del(opts);",
"return blk;",
"early_err:\nqemu_opts_del(opts);",
"err_no_opts:\nQDECREF(bs_opts);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
14
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30,
32
],
[
34
],
[
42
],
[
44
],
[
46
],
[
48
],
[
50
],
[
52
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
68
],
[
70
],
[
72
],
[
76
],
[
82
],
[
86
],
[
88
],
[
92,
94
],
[
96
],
[
98
],
[
100
],
[
102
],
[
106
],
[
108
],
[
110
],
[
112
],
[
114
],
[
116
],
[
118
],
[
122
],
[
124
],
[
126
],
[
128
],
[
130
],
[
132
],
[
136
],
[
138
],
[
140
],
[
142
],
[
144
],
[
146
],
[
148
],
[
150
],
[
154
],
[
156
],
[
158
],
[
160
],
[
162
],
[
164
],
[
166
],
[
168
],
[
172
],
[
176
],
[
178
],
[
180
],
[
186
],
[
188
],
[
192
],
[
194
],
[
196
],
[
198
],
[
202
],
[
204
],
[
206
],
[
208
],
[
212
],
[
214
],
[
216
],
[
218
],
[
220
],
[
222
],
[
224
],
[
226
],
[
230
],
[
232
],
[
234
],
[
236
],
[
238
],
[
242,
244
],
[
246
],
[
248
],
[
250
],
[
252
],
[
256
],
[
262
],
[
264
],
[
266
],
[
268
],
[
270
],
[
272
],
[
274
],
[
278
],
[
280
],
[
282
],
[
286
],
[
288
],
[
292
],
[
296,
298
],
[
300
],
[
304,
306
],
[
308,
310
],
[
312
],
[
314
]
] |
19,974 | static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
AVFilterInOut *in)
{
AVFilterContext *last_filter;
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
InputStream *ist = ifilter->ist;
InputFile *f = input_files[ist->file_index];
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
ist->st->time_base;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
int64_t tsoffset = 0;
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
if (!par)
return AVERROR(ENOMEM);
memset(par, 0, sizeof(*par));
par->format = AV_PIX_FMT_NONE;
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL);
}
if (!fr.num)
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist);
if (ret < 0)
return ret;
}
sar = ist->st->sample_aspect_ratio.num ?
ist->st->sample_aspect_ratio :
ist->dec_ctx->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
av_bprint_init(&args, 0, 1);
av_bprintf(&args,
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
"pixel_aspect=%d/%d:sws_param=flags=%d", ist->resample_width,
ist->resample_height,
ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,
tb.num, tb.den, sar.num, sar.den,
SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
args.str, NULL, fg->graph)) < 0)
return ret;
par->hw_frames_ctx = ist->hw_frames_ctx;
ret = av_buffersrc_parameters_set(ifilter->filter, par);
if (ret < 0)
return ret;
av_freep(&par);
last_filter = ifilter->filter;
if (ist->autorotate) {
double theta = get_rotation(ist->st);
if (fabs(theta - 90) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock");
} else if (fabs(theta - 180) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
if (ret < 0)
return ret;
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
} else if (fabs(theta - 270) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock");
} else if (fabs(theta) > 1.0) {
char rotate_buf[64];
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
}
if (ret < 0)
return ret;
}
if (ist->framerate.num) {
AVFilterContext *setpts;
snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&setpts,
avfilter_get_by_name("setpts"),
name, "N", NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)
return ret;
last_filter = setpts;
}
if (do_deinterlace) {
AVFilterContext *yadif;
snprintf(name, sizeof(name), "deinterlace input from stream %d:%d",
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&yadif,
avfilter_get_by_name("yadif"),
name, "", NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
return ret;
last_filter = yadif;
}
snprintf(name, sizeof(name), "trim for input stream %d:%d",
ist->file_index, ist->st->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
tsoffset += f->ctx->start_time;
}
ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
AV_NOPTS_VALUE : tsoffset, f->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
return ret;
return 0;
}
| true | FFmpeg | 4a81bddb4d9bd6402fc3be64ca406dda7976058d | static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
AVFilterInOut *in)
{
AVFilterContext *last_filter;
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
InputStream *ist = ifilter->ist;
InputFile *f = input_files[ist->file_index];
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
ist->st->time_base;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
int64_t tsoffset = 0;
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
if (!par)
return AVERROR(ENOMEM);
memset(par, 0, sizeof(*par));
par->format = AV_PIX_FMT_NONE;
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL);
}
if (!fr.num)
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist);
if (ret < 0)
return ret;
}
sar = ist->st->sample_aspect_ratio.num ?
ist->st->sample_aspect_ratio :
ist->dec_ctx->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
av_bprint_init(&args, 0, 1);
av_bprintf(&args,
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
"pixel_aspect=%d/%d:sws_param=flags=%d", ist->resample_width,
ist->resample_height,
ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,
tb.num, tb.den, sar.num, sar.den,
SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
args.str, NULL, fg->graph)) < 0)
return ret;
par->hw_frames_ctx = ist->hw_frames_ctx;
ret = av_buffersrc_parameters_set(ifilter->filter, par);
if (ret < 0)
return ret;
av_freep(&par);
last_filter = ifilter->filter;
if (ist->autorotate) {
double theta = get_rotation(ist->st);
if (fabs(theta - 90) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock");
} else if (fabs(theta - 180) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
if (ret < 0)
return ret;
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
} else if (fabs(theta - 270) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock");
} else if (fabs(theta) > 1.0) {
char rotate_buf[64];
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
}
if (ret < 0)
return ret;
}
if (ist->framerate.num) {
AVFilterContext *setpts;
snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&setpts,
avfilter_get_by_name("setpts"),
name, "N", NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)
return ret;
last_filter = setpts;
}
if (do_deinterlace) {
AVFilterContext *yadif;
snprintf(name, sizeof(name), "deinterlace input from stream %d:%d",
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&yadif,
avfilter_get_by_name("yadif"),
name, "", NULL,
fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
return ret;
last_filter = yadif;
}
snprintf(name, sizeof(name), "trim for input stream %d:%d",
ist->file_index, ist->st->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
tsoffset += f->ctx->start_time;
}
ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
AV_NOPTS_VALUE : tsoffset, f->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
return ret;
return 0;
}
| {
"code": [
" return AVERROR(EINVAL);",
" return ret;",
" return ret;",
" return ret;"
],
"line_no": [
49,
67,
115,
115
]
} | static int FUNC_0(FilterGraph *VAR_0, InputFilter *VAR_1,
AVFilterInOut *VAR_2)
{
AVFilterContext *last_filter;
const AVFilter *VAR_3 = avfilter_get_by_name("buffer");
InputStream *ist = VAR_1->ist;
InputFile *f = input_files[ist->file_index];
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
ist->st->time_base;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
char VAR_4[255];
int VAR_5, VAR_6 = 0;
int64_t tsoffset = 0;
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
if (!par)
return AVERROR(ENOMEM);
memset(par, 0, sizeof(*par));
par->format = AV_PIX_FMT_NONE;
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL);
}
if (!fr.num)
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
VAR_5 = sub2video_prepare(ist);
if (VAR_5 < 0)
return VAR_5;
}
sar = ist->st->sample_aspect_ratio.num ?
ist->st->sample_aspect_ratio :
ist->dec_ctx->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
av_bprint_init(&args, 0, 1);
av_bprintf(&args,
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
"pixel_aspect=%d/%d:sws_param=flags=%d", ist->resample_width,
ist->resample_height,
ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,
tb.num, tb.den, sar.num, sar.den,
SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(VAR_4, sizeof(VAR_4), "graph %d input from stream %d:%d", VAR_0->index,
ist->file_index, ist->st->index);
if ((VAR_5 = avfilter_graph_create_filter(&VAR_1->filter, VAR_3, VAR_4,
args.str, NULL, VAR_0->graph)) < 0)
return VAR_5;
par->hw_frames_ctx = ist->hw_frames_ctx;
VAR_5 = av_buffersrc_parameters_set(VAR_1->filter, par);
if (VAR_5 < 0)
return VAR_5;
av_freep(&par);
last_filter = VAR_1->filter;
if (ist->autorotate) {
double VAR_7 = get_rotation(ist->st);
if (fabs(VAR_7 - 90) < 1.0) {
VAR_5 = insert_filter(&last_filter, &VAR_6, "transpose", "clock");
} else if (fabs(VAR_7 - 180) < 1.0) {
VAR_5 = insert_filter(&last_filter, &VAR_6, "hflip", NULL);
if (VAR_5 < 0)
return VAR_5;
VAR_5 = insert_filter(&last_filter, &VAR_6, "vflip", NULL);
} else if (fabs(VAR_7 - 270) < 1.0) {
VAR_5 = insert_filter(&last_filter, &VAR_6, "transpose", "cclock");
} else if (fabs(VAR_7) > 1.0) {
char VAR_8[64];
snprintf(VAR_8, sizeof(VAR_8), "%f*PI/180", VAR_7);
VAR_5 = insert_filter(&last_filter, &VAR_6, "rotate", VAR_8);
}
if (VAR_5 < 0)
return VAR_5;
}
if (ist->framerate.num) {
AVFilterContext *setpts;
snprintf(VAR_4, sizeof(VAR_4), "force CFR for input from stream %d:%d",
ist->file_index, ist->st->index);
if ((VAR_5 = avfilter_graph_create_filter(&setpts,
avfilter_get_by_name("setpts"),
VAR_4, "N", NULL,
VAR_0->graph)) < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, 0, setpts, 0)) < 0)
return VAR_5;
last_filter = setpts;
}
if (do_deinterlace) {
AVFilterContext *yadif;
snprintf(VAR_4, sizeof(VAR_4), "deinterlace input from stream %d:%d",
ist->file_index, ist->st->index);
if ((VAR_5 = avfilter_graph_create_filter(&yadif,
avfilter_get_by_name("yadif"),
VAR_4, "", NULL,
VAR_0->graph)) < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, 0, yadif, 0)) < 0)
return VAR_5;
last_filter = yadif;
}
snprintf(VAR_4, sizeof(VAR_4), "trim for input stream %d:%d",
ist->file_index, ist->st->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
tsoffset += f->ctx->start_time;
}
VAR_5 = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?
AV_NOPTS_VALUE : tsoffset, f->recording_time,
&last_filter, &VAR_6, VAR_4);
if (VAR_5 < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, 0, VAR_2->filter_ctx, VAR_2->VAR_6)) < 0)
return VAR_5;
return 0;
}
| [
"static int FUNC_0(FilterGraph *VAR_0, InputFilter *VAR_1,\nAVFilterInOut *VAR_2)\n{",
"AVFilterContext *last_filter;",
"const AVFilter *VAR_3 = avfilter_get_by_name(\"buffer\");",
"InputStream *ist = VAR_1->ist;",
"InputFile *f = input_files[ist->file_index];",
"AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :\nist->st->time_base;",
"AVRational fr = ist->framerate;",
"AVRational sar;",
"AVBPrint args;",
"char VAR_4[255];",
"int VAR_5, VAR_6 = 0;",
"int64_t tsoffset = 0;",
"AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();",
"if (!par)\nreturn AVERROR(ENOMEM);",
"memset(par, 0, sizeof(*par));",
"par->format = AV_PIX_FMT_NONE;",
"if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {",
"av_log(NULL, AV_LOG_ERROR, \"Cannot connect video filter to audio input\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (!fr.num)\nfr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);",
"if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"VAR_5 = sub2video_prepare(ist);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"sar = ist->st->sample_aspect_ratio.num ?\nist->st->sample_aspect_ratio :\nist->dec_ctx->sample_aspect_ratio;",
"if(!sar.den)\nsar = (AVRational){0,1};",
"av_bprint_init(&args, 0, 1);",
"av_bprintf(&args,\n\"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:\"\n\"pixel_aspect=%d/%d:sws_param=flags=%d\", ist->resample_width,\nist->resample_height,\nist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,\ntb.num, tb.den, sar.num, sar.den,\nSWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));",
"if (fr.num && fr.den)\nav_bprintf(&args, \":frame_rate=%d/%d\", fr.num, fr.den);",
"snprintf(VAR_4, sizeof(VAR_4), \"graph %d input from stream %d:%d\", VAR_0->index,\nist->file_index, ist->st->index);",
"if ((VAR_5 = avfilter_graph_create_filter(&VAR_1->filter, VAR_3, VAR_4,\nargs.str, NULL, VAR_0->graph)) < 0)\nreturn VAR_5;",
"par->hw_frames_ctx = ist->hw_frames_ctx;",
"VAR_5 = av_buffersrc_parameters_set(VAR_1->filter, par);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"av_freep(&par);",
"last_filter = VAR_1->filter;",
"if (ist->autorotate) {",
"double VAR_7 = get_rotation(ist->st);",
"if (fabs(VAR_7 - 90) < 1.0) {",
"VAR_5 = insert_filter(&last_filter, &VAR_6, \"transpose\", \"clock\");",
"} else if (fabs(VAR_7 - 180) < 1.0) {",
"VAR_5 = insert_filter(&last_filter, &VAR_6, \"hflip\", NULL);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_5 = insert_filter(&last_filter, &VAR_6, \"vflip\", NULL);",
"} else if (fabs(VAR_7 - 270) < 1.0) {",
"VAR_5 = insert_filter(&last_filter, &VAR_6, \"transpose\", \"cclock\");",
"} else if (fabs(VAR_7) > 1.0) {",
"char VAR_8[64];",
"snprintf(VAR_8, sizeof(VAR_8), \"%f*PI/180\", VAR_7);",
"VAR_5 = insert_filter(&last_filter, &VAR_6, \"rotate\", VAR_8);",
"}",
"if (VAR_5 < 0)\nreturn VAR_5;",
"}",
"if (ist->framerate.num) {",
"AVFilterContext *setpts;",
"snprintf(VAR_4, sizeof(VAR_4), \"force CFR for input from stream %d:%d\",\nist->file_index, ist->st->index);",
"if ((VAR_5 = avfilter_graph_create_filter(&setpts,\navfilter_get_by_name(\"setpts\"),\nVAR_4, \"N\", NULL,\nVAR_0->graph)) < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, 0, setpts, 0)) < 0)\nreturn VAR_5;",
"last_filter = setpts;",
"}",
"if (do_deinterlace) {",
"AVFilterContext *yadif;",
"snprintf(VAR_4, sizeof(VAR_4), \"deinterlace input from stream %d:%d\",\nist->file_index, ist->st->index);",
"if ((VAR_5 = avfilter_graph_create_filter(&yadif,\navfilter_get_by_name(\"yadif\"),\nVAR_4, \"\", NULL,\nVAR_0->graph)) < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, 0, yadif, 0)) < 0)\nreturn VAR_5;",
"last_filter = yadif;",
"}",
"snprintf(VAR_4, sizeof(VAR_4), \"trim for input stream %d:%d\",\nist->file_index, ist->st->index);",
"if (copy_ts) {",
"tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;",
"if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)\ntsoffset += f->ctx->start_time;",
"}",
"VAR_5 = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ?\nAV_NOPTS_VALUE : tsoffset, f->recording_time,\n&last_filter, &VAR_6, VAR_4);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, 0, VAR_2->filter_ctx, VAR_2->VAR_6)) < 0)\nreturn VAR_5;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
73,
75,
77
],
[
79,
81
],
[
83
],
[
85,
87,
89,
91,
93,
95,
97
],
[
99,
101
],
[
103,
105
],
[
111,
113,
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
173
],
[
175
],
[
179,
181
],
[
183,
185,
187,
189,
191
],
[
195,
197
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213,
215
],
[
217,
219,
221,
223,
225
],
[
229,
231
],
[
235
],
[
237
],
[
241,
243
],
[
245
],
[
247
],
[
249,
251
],
[
253
],
[
255,
257,
259
],
[
261,
263
],
[
267,
269
],
[
271
],
[
273
]
] |
19,975 | static void do_video_stats(OutputStream *ost, int frame_size)
{
AVCodecContext *enc;
int frame_number;
double ti1, bitrate, avg_bitrate;
/* this is executed just the first time do_video_stats is called */
if (!vstats_file) {
vstats_file = fopen(vstats_filename, "w");
if (!vstats_file) {
perror("fopen");
exit(1);
}
}
enc = ost->st->codec;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
frame_number = ost->frame_number;
fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality / (float)FF_QP2LAMBDA);
if (enc->flags&CODEC_FLAG_PSNR)
fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
fprintf(vstats_file,"f_size= %6d ", frame_size);
/* compute pts value */
ti1 = ost->sync_opts * av_q2d(enc->time_base);
if (ti1 < 0.01)
ti1 = 0.01;
bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
avg_bitrate = (double)(video_size * 8) / ti1 / 1000.0;
fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
(double)video_size / 1024, ti1, bitrate, avg_bitrate);
fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(enc->coded_frame->pict_type));
}
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb | static void do_video_stats(OutputStream *ost, int frame_size)
{
AVCodecContext *enc;
int frame_number;
double ti1, bitrate, avg_bitrate;
if (!vstats_file) {
vstats_file = fopen(vstats_filename, "w");
if (!vstats_file) {
perror("fopen");
exit(1);
}
}
enc = ost->st->codec;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
frame_number = ost->frame_number;
fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality / (float)FF_QP2LAMBDA);
if (enc->flags&CODEC_FLAG_PSNR)
fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
fprintf(vstats_file,"f_size= %6d ", frame_size);
ti1 = ost->sync_opts * av_q2d(enc->time_base);
if (ti1 < 0.01)
ti1 = 0.01;
bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
avg_bitrate = (double)(video_size * 8) / ti1 / 1000.0;
fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
(double)video_size / 1024, ti1, bitrate, avg_bitrate);
fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(enc->coded_frame->pict_type));
}
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
23,
23,
23,
23,
23,
23,
23,
23
]
} | static void FUNC_0(OutputStream *VAR_0, int VAR_1)
{
AVCodecContext *enc;
int VAR_2;
double VAR_3, VAR_4, VAR_5;
if (!vstats_file) {
vstats_file = fopen(vstats_filename, "w");
if (!vstats_file) {
perror("fopen");
exit(1);
}
}
enc = VAR_0->st->codec;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
VAR_2 = VAR_0->VAR_2;
fprintf(vstats_file, "frame= %5d q= %2.1f ", VAR_2, enc->coded_frame->quality / (float)FF_QP2LAMBDA);
if (enc->flags&CODEC_FLAG_PSNR)
fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
fprintf(vstats_file,"f_size= %6d ", VAR_1);
VAR_3 = VAR_0->sync_opts * av_q2d(enc->time_base);
if (VAR_3 < 0.01)
VAR_3 = 0.01;
VAR_4 = (VAR_1 * 8) / av_q2d(enc->time_base) / 1000.0;
VAR_5 = (double)(video_size * 8) / VAR_3 / 1000.0;
fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
(double)video_size / 1024, VAR_3, VAR_4, VAR_5);
fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(enc->coded_frame->pict_type));
}
}
| [
"static void FUNC_0(OutputStream *VAR_0, int VAR_1)\n{",
"AVCodecContext *enc;",
"int VAR_2;",
"double VAR_3, VAR_4, VAR_5;",
"if (!vstats_file) {",
"vstats_file = fopen(vstats_filename, \"w\");",
"if (!vstats_file) {",
"perror(\"fopen\");",
"exit(1);",
"}",
"}",
"enc = VAR_0->st->codec;",
"if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {",
"VAR_2 = VAR_0->VAR_2;",
"fprintf(vstats_file, \"frame= %5d q= %2.1f \", VAR_2, enc->coded_frame->quality / (float)FF_QP2LAMBDA);",
"if (enc->flags&CODEC_FLAG_PSNR)\nfprintf(vstats_file, \"PSNR= %6.2f \", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));",
"fprintf(vstats_file,\"f_size= %6d \", VAR_1);",
"VAR_3 = VAR_0->sync_opts * av_q2d(enc->time_base);",
"if (VAR_3 < 0.01)\nVAR_3 = 0.01;",
"VAR_4 = (VAR_1 * 8) / av_q2d(enc->time_base) / 1000.0;",
"VAR_5 = (double)(video_size * 8) / VAR_3 / 1000.0;",
"fprintf(vstats_file, \"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s \",\n(double)video_size / 1024, VAR_3, VAR_4, VAR_5);",
"fprintf(vstats_file, \"type= %c\\n\", av_get_picture_type_char(enc->coded_frame->pict_type));",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
45
],
[
49
],
[
51,
53
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
]
] |
19,977 | void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
int mb_x, int mb_y)
{
AVCodecContext *avctx = s->avctx;
int x, y, mode, nnz, tr;
// for the first row, we need to run xchg_mb_border to init the top edge to 127
// otherwise, skip it if we aren't going to deblock
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 1);
if (mb->mode < MODE_I4x4) {
if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // tested
mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y);
} else {
mode = check_intra_pred8x8_mode(mb->mode, mb_x, mb_y);
}
s->hpc.pred16x16[mode](dst[0], s->linesize);
} else {
uint8_t *ptr = dst[0];
uint8_t *intra4x4 = s->intra4x4_pred_mode_mb;
uint8_t tr_top[4] = { 127, 127, 127, 127 };
// all blocks on the right edge of the macroblock use bottom edge
// the top macroblock for their topright edge
uint8_t *tr_right = ptr - s->linesize + 16;
// if we're on the right edge of the frame, said edge is extended
// from the top macroblock
if (mb_x == s->mb_width-1) {
tr = tr_right[-1]*0x01010101;
tr_right = (uint8_t *)&tr;
}
if (mb->skip)
AV_ZERO128(s->non_zero_count_cache);
for (y = 0; y < 4; y++) {
uint8_t *topright = ptr + 4 - s->linesize;
for (x = 0; x < 4; x++) {
int copy = 0, linesize = s->linesize;
uint8_t *dst = ptr+4*x;
DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
topright = tr_top;
} else if (x == 3)
topright = tr_right;
if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // mb_x+x or mb_y+y is a hack but works
mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x, mb_y + y, ©);
if (copy) {
dst = copy_dst + 12;
linesize = 8;
if (!(mb_y + y)) {
copy_dst[3] = 127U;
* (uint32_t *) (copy_dst + 4) = 127U * 0x01010101U;
} else {
* (uint32_t *) (copy_dst + 4) = * (uint32_t *) (ptr+4*x-s->linesize);
if (!(mb_x + x)) {
copy_dst[3] = 129U;
} else {
copy_dst[3] = ptr[4*x-s->linesize-1];
}
}
if (!(mb_x + x)) {
copy_dst[11] =
copy_dst[19] =
copy_dst[27] =
copy_dst[35] = 129U;
} else {
copy_dst[11] = ptr[4*x -1];
copy_dst[19] = ptr[4*x+s->linesize -1];
copy_dst[27] = ptr[4*x+s->linesize*2-1];
copy_dst[35] = ptr[4*x+s->linesize*3-1];
}
}
} else {
mode = intra4x4[x];
}
s->hpc.pred4x4[mode](dst, topright, linesize);
if (copy) {
* (uint32_t *) (ptr+4*x) = * (uint32_t *) (copy_dst + 12);
* (uint32_t *) (ptr+4*x+s->linesize) = * (uint32_t *) (copy_dst + 20);
* (uint32_t *) (ptr+4*x+s->linesize*2) = * (uint32_t *) (copy_dst + 28);
* (uint32_t *) (ptr+4*x+s->linesize*3) = * (uint32_t *) (copy_dst + 36);
}
nnz = s->non_zero_count_cache[y][x];
if (nnz) {
if (nnz == 1)
s->vp8dsp.vp8_idct_dc_add(ptr+4*x, s->block[y][x], s->linesize);
else
s->vp8dsp.vp8_idct_add(ptr+4*x, s->block[y][x], s->linesize);
}
topright += 4;
}
ptr += 4*s->linesize;
intra4x4 += 4;
}
}
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
mode = check_intra_pred8x8_mode_emuedge(s->chroma_pred_mode, mb_x, mb_y);
} else {
mode = check_intra_pred8x8_mode(s->chroma_pred_mode, mb_x, mb_y);
}
s->hpc.pred8x8[mode](dst[1], s->uvlinesize);
s->hpc.pred8x8[mode](dst[2], s->uvlinesize);
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 0);
}
| true | FFmpeg | 7148da489e4991c88eeff9cd6238ad6e273613b5 | void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
int mb_x, int mb_y)
{
AVCodecContext *avctx = s->avctx;
int x, y, mode, nnz, tr;
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 1);
if (mb->mode < MODE_I4x4) {
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y);
} else {
mode = check_intra_pred8x8_mode(mb->mode, mb_x, mb_y);
}
s->hpc.pred16x16[mode](dst[0], s->linesize);
} else {
uint8_t *ptr = dst[0];
uint8_t *intra4x4 = s->intra4x4_pred_mode_mb;
uint8_t tr_top[4] = { 127, 127, 127, 127 };
uint8_t *tr_right = ptr - s->linesize + 16;
if (mb_x == s->mb_width-1) {
tr = tr_right[-1]*0x01010101;
tr_right = (uint8_t *)&tr;
}
if (mb->skip)
AV_ZERO128(s->non_zero_count_cache);
for (y = 0; y < 4; y++) {
uint8_t *topright = ptr + 4 - s->linesize;
for (x = 0; x < 4; x++) {
int copy = 0, linesize = s->linesize;
uint8_t *dst = ptr+4*x;
DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
topright = tr_top;
} else if (x == 3)
topright = tr_right;
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x, mb_y + y, ©);
if (copy) {
dst = copy_dst + 12;
linesize = 8;
if (!(mb_y + y)) {
copy_dst[3] = 127U;
* (uint32_t *) (copy_dst + 4) = 127U * 0x01010101U;
} else {
* (uint32_t *) (copy_dst + 4) = * (uint32_t *) (ptr+4*x-s->linesize);
if (!(mb_x + x)) {
copy_dst[3] = 129U;
} else {
copy_dst[3] = ptr[4*x-s->linesize-1];
}
}
if (!(mb_x + x)) {
copy_dst[11] =
copy_dst[19] =
copy_dst[27] =
copy_dst[35] = 129U;
} else {
copy_dst[11] = ptr[4*x -1];
copy_dst[19] = ptr[4*x+s->linesize -1];
copy_dst[27] = ptr[4*x+s->linesize*2-1];
copy_dst[35] = ptr[4*x+s->linesize*3-1];
}
}
} else {
mode = intra4x4[x];
}
s->hpc.pred4x4[mode](dst, topright, linesize);
if (copy) {
* (uint32_t *) (ptr+4*x) = * (uint32_t *) (copy_dst + 12);
* (uint32_t *) (ptr+4*x+s->linesize) = * (uint32_t *) (copy_dst + 20);
* (uint32_t *) (ptr+4*x+s->linesize*2) = * (uint32_t *) (copy_dst + 28);
* (uint32_t *) (ptr+4*x+s->linesize*3) = * (uint32_t *) (copy_dst + 36);
}
nnz = s->non_zero_count_cache[y][x];
if (nnz) {
if (nnz == 1)
s->vp8dsp.vp8_idct_dc_add(ptr+4*x, s->block[y][x], s->linesize);
else
s->vp8dsp.vp8_idct_add(ptr+4*x, s->block[y][x], s->linesize);
}
topright += 4;
}
ptr += 4*s->linesize;
intra4x4 += 4;
}
}
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
mode = check_intra_pred8x8_mode_emuedge(s->chroma_pred_mode, mb_x, mb_y);
} else {
mode = check_intra_pred8x8_mode(s->chroma_pred_mode, mb_x, mb_y);
}
s->hpc.pred8x8[mode](dst[1], s->uvlinesize);
s->hpc.pred8x8[mode](dst[2], s->uvlinesize);
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 0);
}
| {
"code": [
" if (mb_x == s->mb_width-1) {"
],
"line_no": [
63
]
} | void FUNC_0(VP8Context *VAR_0, uint8_t *VAR_1[3], VP8Macroblock *VAR_2,
int VAR_3, int VAR_4)
{
AVCodecContext *avctx = VAR_0->avctx;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !VAR_4) && (VAR_0->deblock_filter || !VAR_4))
xchg_mb_border(VAR_0->top_border[VAR_3+1], VAR_1[0], VAR_1[1], VAR_1[2],
VAR_0->VAR_11, VAR_0->uvlinesize, VAR_3, VAR_4, VAR_0->mb_width,
VAR_0->filter.simple, 1);
if (VAR_2->VAR_7 < MODE_I4x4) {
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
VAR_7 = check_intra_pred8x8_mode_emuedge(VAR_2->VAR_7, VAR_3, VAR_4);
} else {
VAR_7 = check_intra_pred8x8_mode(VAR_2->VAR_7, VAR_3, VAR_4);
}
VAR_0->hpc.pred16x16[VAR_7](VAR_1[0], VAR_0->VAR_11);
} else {
uint8_t *ptr = VAR_1[0];
uint8_t *intra4x4 = VAR_0->intra4x4_pred_mode_mb;
uint8_t tr_top[4] = { 127, 127, 127, 127 };
uint8_t *tr_right = ptr - VAR_0->VAR_11 + 16;
if (VAR_3 == VAR_0->mb_width-1) {
VAR_9 = tr_right[-1]*0x01010101;
tr_right = (uint8_t *)&VAR_9;
}
if (VAR_2->skip)
AV_ZERO128(VAR_0->non_zero_count_cache);
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
uint8_t *topright = ptr + 4 - VAR_0->VAR_11;
for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {
int VAR_10 = 0, VAR_11 = VAR_0->VAR_11;
uint8_t *VAR_1 = ptr+4*VAR_5;
DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
if ((VAR_6 == 0 || VAR_5 == 3) && VAR_4 == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
topright = tr_top;
} else if (VAR_5 == 3)
topright = tr_right;
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
VAR_7 = check_intra_pred4x4_mode_emuedge(intra4x4[VAR_5], VAR_3 + VAR_5, VAR_4 + VAR_6, &VAR_10);
if (VAR_10) {
VAR_1 = copy_dst + 12;
VAR_11 = 8;
if (!(VAR_4 + VAR_6)) {
copy_dst[3] = 127U;
* (uint32_t *) (copy_dst + 4) = 127U * 0x01010101U;
} else {
* (uint32_t *) (copy_dst + 4) = * (uint32_t *) (ptr+4*VAR_5-VAR_0->VAR_11);
if (!(VAR_3 + VAR_5)) {
copy_dst[3] = 129U;
} else {
copy_dst[3] = ptr[4*VAR_5-VAR_0->VAR_11-1];
}
}
if (!(VAR_3 + VAR_5)) {
copy_dst[11] =
copy_dst[19] =
copy_dst[27] =
copy_dst[35] = 129U;
} else {
copy_dst[11] = ptr[4*VAR_5 -1];
copy_dst[19] = ptr[4*VAR_5+VAR_0->VAR_11 -1];
copy_dst[27] = ptr[4*VAR_5+VAR_0->VAR_11*2-1];
copy_dst[35] = ptr[4*VAR_5+VAR_0->VAR_11*3-1];
}
}
} else {
VAR_7 = intra4x4[VAR_5];
}
VAR_0->hpc.pred4x4[VAR_7](VAR_1, topright, VAR_11);
if (VAR_10) {
* (uint32_t *) (ptr+4*VAR_5) = * (uint32_t *) (copy_dst + 12);
* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11) = * (uint32_t *) (copy_dst + 20);
* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11*2) = * (uint32_t *) (copy_dst + 28);
* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11*3) = * (uint32_t *) (copy_dst + 36);
}
VAR_8 = VAR_0->non_zero_count_cache[VAR_6][VAR_5];
if (VAR_8) {
if (VAR_8 == 1)
VAR_0->vp8dsp.vp8_idct_dc_add(ptr+4*VAR_5, VAR_0->block[VAR_6][VAR_5], VAR_0->VAR_11);
else
VAR_0->vp8dsp.vp8_idct_add(ptr+4*VAR_5, VAR_0->block[VAR_6][VAR_5], VAR_0->VAR_11);
}
topright += 4;
}
ptr += 4*VAR_0->VAR_11;
intra4x4 += 4;
}
}
if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
VAR_7 = check_intra_pred8x8_mode_emuedge(VAR_0->chroma_pred_mode, VAR_3, VAR_4);
} else {
VAR_7 = check_intra_pred8x8_mode(VAR_0->chroma_pred_mode, VAR_3, VAR_4);
}
VAR_0->hpc.pred8x8[VAR_7](VAR_1[1], VAR_0->uvlinesize);
VAR_0->hpc.pred8x8[VAR_7](VAR_1[2], VAR_0->uvlinesize);
if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !VAR_4) && (VAR_0->deblock_filter || !VAR_4))
xchg_mb_border(VAR_0->top_border[VAR_3+1], VAR_1[0], VAR_1[1], VAR_1[2],
VAR_0->VAR_11, VAR_0->uvlinesize, VAR_3, VAR_4, VAR_0->mb_width,
VAR_0->filter.simple, 0);
}
| [
"void FUNC_0(VP8Context *VAR_0, uint8_t *VAR_1[3], VP8Macroblock *VAR_2,\nint VAR_3, int VAR_4)\n{",
"AVCodecContext *avctx = VAR_0->avctx;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !VAR_4) && (VAR_0->deblock_filter || !VAR_4))\nxchg_mb_border(VAR_0->top_border[VAR_3+1], VAR_1[0], VAR_1[1], VAR_1[2],\nVAR_0->VAR_11, VAR_0->uvlinesize, VAR_3, VAR_4, VAR_0->mb_width,\nVAR_0->filter.simple, 1);",
"if (VAR_2->VAR_7 < MODE_I4x4) {",
"if (avctx->flags & CODEC_FLAG_EMU_EDGE) {",
"VAR_7 = check_intra_pred8x8_mode_emuedge(VAR_2->VAR_7, VAR_3, VAR_4);",
"} else {",
"VAR_7 = check_intra_pred8x8_mode(VAR_2->VAR_7, VAR_3, VAR_4);",
"}",
"VAR_0->hpc.pred16x16[VAR_7](VAR_1[0], VAR_0->VAR_11);",
"} else {",
"uint8_t *ptr = VAR_1[0];",
"uint8_t *intra4x4 = VAR_0->intra4x4_pred_mode_mb;",
"uint8_t tr_top[4] = { 127, 127, 127, 127 };",
"uint8_t *tr_right = ptr - VAR_0->VAR_11 + 16;",
"if (VAR_3 == VAR_0->mb_width-1) {",
"VAR_9 = tr_right[-1]*0x01010101;",
"tr_right = (uint8_t *)&VAR_9;",
"}",
"if (VAR_2->skip)\nAV_ZERO128(VAR_0->non_zero_count_cache);",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"uint8_t *topright = ptr + 4 - VAR_0->VAR_11;",
"for (VAR_5 = 0; VAR_5 < 4; VAR_5++) {",
"int VAR_10 = 0, VAR_11 = VAR_0->VAR_11;",
"uint8_t *VAR_1 = ptr+4*VAR_5;",
"DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];",
"if ((VAR_6 == 0 || VAR_5 == 3) && VAR_4 == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {",
"topright = tr_top;",
"} else if (VAR_5 == 3)",
"topright = tr_right;",
"if (avctx->flags & CODEC_FLAG_EMU_EDGE) {",
"VAR_7 = check_intra_pred4x4_mode_emuedge(intra4x4[VAR_5], VAR_3 + VAR_5, VAR_4 + VAR_6, &VAR_10);",
"if (VAR_10) {",
"VAR_1 = copy_dst + 12;",
"VAR_11 = 8;",
"if (!(VAR_4 + VAR_6)) {",
"copy_dst[3] = 127U;",
"* (uint32_t *) (copy_dst + 4) = 127U * 0x01010101U;",
"} else {",
"* (uint32_t *) (copy_dst + 4) = * (uint32_t *) (ptr+4*VAR_5-VAR_0->VAR_11);",
"if (!(VAR_3 + VAR_5)) {",
"copy_dst[3] = 129U;",
"} else {",
"copy_dst[3] = ptr[4*VAR_5-VAR_0->VAR_11-1];",
"}",
"}",
"if (!(VAR_3 + VAR_5)) {",
"copy_dst[11] =\ncopy_dst[19] =\ncopy_dst[27] =\ncopy_dst[35] = 129U;",
"} else {",
"copy_dst[11] = ptr[4*VAR_5 -1];",
"copy_dst[19] = ptr[4*VAR_5+VAR_0->VAR_11 -1];",
"copy_dst[27] = ptr[4*VAR_5+VAR_0->VAR_11*2-1];",
"copy_dst[35] = ptr[4*VAR_5+VAR_0->VAR_11*3-1];",
"}",
"}",
"} else {",
"VAR_7 = intra4x4[VAR_5];",
"}",
"VAR_0->hpc.pred4x4[VAR_7](VAR_1, topright, VAR_11);",
"if (VAR_10) {",
"* (uint32_t *) (ptr+4*VAR_5) = * (uint32_t *) (copy_dst + 12);",
"* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11) = * (uint32_t *) (copy_dst + 20);",
"* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11*2) = * (uint32_t *) (copy_dst + 28);",
"* (uint32_t *) (ptr+4*VAR_5+VAR_0->VAR_11*3) = * (uint32_t *) (copy_dst + 36);",
"}",
"VAR_8 = VAR_0->non_zero_count_cache[VAR_6][VAR_5];",
"if (VAR_8) {",
"if (VAR_8 == 1)\nVAR_0->vp8dsp.vp8_idct_dc_add(ptr+4*VAR_5, VAR_0->block[VAR_6][VAR_5], VAR_0->VAR_11);",
"else\nVAR_0->vp8dsp.vp8_idct_add(ptr+4*VAR_5, VAR_0->block[VAR_6][VAR_5], VAR_0->VAR_11);",
"}",
"topright += 4;",
"}",
"ptr += 4*VAR_0->VAR_11;",
"intra4x4 += 4;",
"}",
"}",
"if (avctx->flags & CODEC_FLAG_EMU_EDGE) {",
"VAR_7 = check_intra_pred8x8_mode_emuedge(VAR_0->chroma_pred_mode, VAR_3, VAR_4);",
"} else {",
"VAR_7 = check_intra_pred8x8_mode(VAR_0->chroma_pred_mode, VAR_3, VAR_4);",
"}",
"VAR_0->hpc.pred8x8[VAR_7](VAR_1[1], VAR_0->uvlinesize);",
"VAR_0->hpc.pred8x8[VAR_7](VAR_1[2], VAR_0->uvlinesize);",
"if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !VAR_4) && (VAR_0->deblock_filter || !VAR_4))\nxchg_mb_border(VAR_0->top_border[VAR_3+1], VAR_1[0], VAR_1[1], VAR_1[2],\nVAR_0->VAR_11, VAR_0->uvlinesize, VAR_3, VAR_4, VAR_0->mb_width,\nVAR_0->filter.simple, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
17,
19,
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
55
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
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
],
[
181
],
[
183
],
[
185,
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227,
229,
231,
233
],
[
235
]
] |
19,978 | Aml *aml_buffer(void)
{
Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
return var;
}
| true | qemu | ed8b5847e46c24d6e9c286892a00a34bee9b0835 | Aml *aml_buffer(void)
{
Aml *var = aml_bundle(0x11 , AML_BUFFER);
return var;
}
| {
"code": [
"Aml *aml_buffer(void)"
],
"line_no": [
1
]
} | Aml *FUNC_0(void)
{
Aml *var = aml_bundle(0x11 , AML_BUFFER);
return var;
}
| [
"Aml *FUNC_0(void)\n{",
"Aml *var = aml_bundle(0x11 , AML_BUFFER);",
"return var;",
"}"
] | [
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
19,979 | static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
ppc_slb_t *slb, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int i;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (i = 0; i < HPTES_PER_GROUP; i++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
/* This compares V, B, H (secondary) and the AVPN */
if (HPTE64_V_COMPARE(pte0, ptem)) {
unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);
/*
* If there is no match, ignore the PTE, it could simply
* be for a different segment size encoding and the
* architecture specifies we should not match. Linux will
* potentially leave behind PTEs for the wrong base page
* size when demoting segments.
*/
if (pshift == 0) {
continue;
}
/* We don't do anything with pshift yet as qemu TLB only deals
* with 4K pages anyway
*/
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + i) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
/*
* We didn't find a valid entry.
*/
return -1;
}
| true | qemu | 949868633f0454715af1781c0f377413b6ab000e | static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
ppc_slb_t *slb, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int i;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (i = 0; i < HPTES_PER_GROUP; i++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
if (HPTE64_V_COMPARE(pte0, ptem)) {
unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);
if (pshift == 0) {
continue;
}
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + i) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
return -1;
}
| {
"code": [
" ppc_hash_pte64_t *pte)",
" unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);",
" if (pshift == 0) {",
" ppc_hash_pte64_t *pte)",
" return -1;"
],
"line_no": [
5,
43,
59,
5,
27
]
} | static hwaddr FUNC_0(PowerPCCPU *cpu, hwaddr hash,
ppc_slb_t *slb, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int VAR_0;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (VAR_0 = 0; VAR_0 < HPTES_PER_GROUP; VAR_0++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, VAR_0);
pte1 = ppc_hash64_load_hpte1(cpu, token, VAR_0);
if (HPTE64_V_COMPARE(pte0, ptem)) {
unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);
if (pshift == 0) {
continue;
}
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + VAR_0) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
return -1;
}
| [
"static hwaddr FUNC_0(PowerPCCPU *cpu, hwaddr hash,\nppc_slb_t *slb, target_ulong ptem,\nppc_hash_pte64_t *pte)\n{",
"CPUPPCState *env = &cpu->env;",
"int VAR_0;",
"uint64_t token;",
"target_ulong pte0, pte1;",
"target_ulong pte_index;",
"pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;",
"token = ppc_hash64_start_access(cpu, pte_index);",
"if (!token) {",
"return -1;",
"}",
"for (VAR_0 = 0; VAR_0 < HPTES_PER_GROUP; VAR_0++) {",
"pte0 = ppc_hash64_load_hpte0(cpu, token, VAR_0);",
"pte1 = ppc_hash64_load_hpte1(cpu, token, VAR_0);",
"if (HPTE64_V_COMPARE(pte0, ptem)) {",
"unsigned pshift = hpte_page_shift(slb->sps, pte0, pte1);",
"if (pshift == 0) {",
"continue;",
"}",
"pte->pte0 = pte0;",
"pte->pte1 = pte1;",
"ppc_hash64_stop_access(cpu, token);",
"return (pte_index + VAR_0) * HASH_PTE_SIZE_64;",
"}",
"}",
"ppc_hash64_stop_access(cpu, token);",
"return -1;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
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
],
[
41
],
[
43
],
[
59
],
[
61
],
[
63
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
91
],
[
93
]
] |
19,980 | static int qxl_init_common(PCIQXLDevice *qxl)
{
uint8_t* config = qxl->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
qxl->mode = QXL_MODE_UNDEFINED;
qxl->generation = 1;
qxl->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&qxl->track_lock);
qemu_mutex_init(&qxl->async_lock);
qxl->current_async = QXL_UNDEFINED_IO;
qxl->guest_bug = 0;
switch (qxl->revision) {
case 1: /* spice 0.4 -- qxl-1 */
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2: /* spice 0.6 -- qxl-2 */
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3: /* qxl-3 */
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32; /* PCI region size must be pow2 */
break;
/* 0x000b01 == 0.11.1 */
#if SPICE_SERVER_VERSION >= 0x000b01 && \
defined(CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC)
case 4: /* qxl-4 */
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
break;
#endif
default:
error_report("Invalid revision %d for qxl device (max %d)",
qxl->revision, QXL_DEFAULT_REVISION);
return -1;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
qxl->rom_size = qxl_rom_size();
memory_region_init_ram(&qxl->rom_bar, "qxl.vrom", qxl->rom_size);
vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
init_qxl_rom(qxl);
init_qxl_ram(qxl);
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
memory_region_init_ram(&qxl->vram_bar, "qxl.vram", qxl->vram_size);
vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
memory_region_init_alias(&qxl->vram32_bar, "qxl.vram32", &qxl->vram_bar,
0, qxl->vram32_size);
memory_region_init_io(&qxl->io_bar, &qxl_io_ops, qxl,
"qxl-ioports", io_size);
if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga);
}
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
if (qxl->vram32_size < qxl->vram_size) {
/*
* Make the 64bit vram bar show up only in case it is
* configured to be larger than the 32bit vram bar.
*/
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&qxl->vram_bar);
}
/* print pci bar details */
dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
qxl->id == 0 ? "pri" : "sec",
qxl->vga.vram_size / (1024*1024));
dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
qxl->vram32_size / (1024*1024));
dprint(qxl, 1, "vram/64: %d MB %s\n",
qxl->vram_size / (1024*1024),
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
qxl->ssd.qxl.base.sif = &qxl_interface.base;
qxl->ssd.qxl.id = qxl->id;
qemu_spice_add_interface(&qxl->ssd.qxl.base);
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
init_pipe_signaling(qxl);
qxl_reset_state(qxl);
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
return 0;
}
| true | qemu | e25a0651f4be22099122b5e14c77c354be0aa88b | static int qxl_init_common(PCIQXLDevice *qxl)
{
uint8_t* config = qxl->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
qxl->mode = QXL_MODE_UNDEFINED;
qxl->generation = 1;
qxl->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&qxl->track_lock);
qemu_mutex_init(&qxl->async_lock);
qxl->current_async = QXL_UNDEFINED_IO;
qxl->guest_bug = 0;
switch (qxl->revision) {
case 1:
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2:
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3:
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32;
break;
#if SPICE_SERVER_VERSION >= 0x000b01 && \
defined(CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC)
case 4:
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
break;
#endif
default:
error_report("Invalid revision %d for qxl device (max %d)",
qxl->revision, QXL_DEFAULT_REVISION);
return -1;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
qxl->rom_size = qxl_rom_size();
memory_region_init_ram(&qxl->rom_bar, "qxl.vrom", qxl->rom_size);
vmstate_register_ram(&qxl->rom_bar, &qxl->pci.qdev);
init_qxl_rom(qxl);
init_qxl_ram(qxl);
qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
memory_region_init_ram(&qxl->vram_bar, "qxl.vram", qxl->vram_size);
vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
memory_region_init_alias(&qxl->vram32_bar, "qxl.vram32", &qxl->vram_bar,
0, qxl->vram32_size);
memory_region_init_io(&qxl->io_bar, &qxl_io_ops, qxl,
"qxl-ioports", io_size);
if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga);
}
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar);
pci_register_bar(&qxl->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vga.vram);
pci_register_bar(&qxl->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->vram32_bar);
if (qxl->vram32_size < qxl->vram_size) {
pci_register_bar(&qxl->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&qxl->vram_bar);
}
dprint(qxl, 1, "ram/%s: %d MB [region 0]\n",
qxl->id == 0 ? "pri" : "sec",
qxl->vga.vram_size / (1024*1024));
dprint(qxl, 1, "vram/32: %d MB [region 1]\n",
qxl->vram32_size / (1024*1024));
dprint(qxl, 1, "vram/64: %d MB %s\n",
qxl->vram_size / (1024*1024),
qxl->vram32_size < qxl->vram_size ? "[region 4]" : "[unmapped]");
qxl->ssd.qxl.base.sif = &qxl_interface.base;
qxl->ssd.qxl.id = qxl->id;
qemu_spice_add_interface(&qxl->ssd.qxl.base);
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
init_pipe_signaling(qxl);
qxl_reset_state(qxl);
qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
return 0;
}
| {
"code": [
" qemu_spice_add_interface(&qxl->ssd.qxl.base);"
],
"line_no": [
201
]
} | static int FUNC_0(PCIQXLDevice *VAR_0)
{
uint8_t* config = VAR_0->pci.config;
uint32_t pci_device_rev;
uint32_t io_size;
VAR_0->mode = QXL_MODE_UNDEFINED;
VAR_0->generation = 1;
VAR_0->num_memslots = NUM_MEMSLOTS;
qemu_mutex_init(&VAR_0->track_lock);
qemu_mutex_init(&VAR_0->async_lock);
VAR_0->current_async = QXL_UNDEFINED_IO;
VAR_0->guest_bug = 0;
switch (VAR_0->revision) {
case 1:
pci_device_rev = QXL_REVISION_STABLE_V04;
io_size = 8;
break;
case 2:
pci_device_rev = QXL_REVISION_STABLE_V06;
io_size = 16;
break;
case 3:
pci_device_rev = QXL_REVISION_STABLE_V10;
io_size = 32;
break;
#if SPICE_SERVER_VERSION >= 0x000b01 && \
defined(CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC)
case 4:
pci_device_rev = QXL_REVISION_STABLE_V12;
io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
break;
#endif
default:
error_report("Invalid revision %d for VAR_0 device (max %d)",
VAR_0->revision, QXL_DEFAULT_REVISION);
return -1;
}
pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
VAR_0->rom_size = qxl_rom_size();
memory_region_init_ram(&VAR_0->rom_bar, "VAR_0.vrom", VAR_0->rom_size);
vmstate_register_ram(&VAR_0->rom_bar, &VAR_0->pci.qdev);
init_qxl_rom(VAR_0);
init_qxl_ram(VAR_0);
VAR_0->guest_surfaces.cmds = g_new0(QXLPHYSICAL, VAR_0->ssd.num_surfaces);
memory_region_init_ram(&VAR_0->vram_bar, "VAR_0.vram", VAR_0->vram_size);
vmstate_register_ram(&VAR_0->vram_bar, &VAR_0->pci.qdev);
memory_region_init_alias(&VAR_0->vram32_bar, "VAR_0.vram32", &VAR_0->vram_bar,
0, VAR_0->vram32_size);
memory_region_init_io(&VAR_0->io_bar, &qxl_io_ops, VAR_0,
"VAR_0-ioports", io_size);
if (VAR_0->id == 0) {
vga_dirty_log_start(&VAR_0->vga);
}
memory_region_set_flush_coalesced(&VAR_0->io_bar);
pci_register_bar(&VAR_0->pci, QXL_IO_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_IO, &VAR_0->io_bar);
pci_register_bar(&VAR_0->pci, QXL_ROM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->rom_bar);
pci_register_bar(&VAR_0->pci, QXL_RAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vga.vram);
pci_register_bar(&VAR_0->pci, QXL_VRAM_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vram32_bar);
if (VAR_0->vram32_size < VAR_0->vram_size) {
pci_register_bar(&VAR_0->pci, QXL_VRAM64_RANGE_INDEX,
PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_TYPE_64 |
PCI_BASE_ADDRESS_MEM_PREFETCH,
&VAR_0->vram_bar);
}
dprint(VAR_0, 1, "ram/%s: %d MB [region 0]\n",
VAR_0->id == 0 ? "pri" : "sec",
VAR_0->vga.vram_size / (1024*1024));
dprint(VAR_0, 1, "vram/32: %d MB [region 1]\n",
VAR_0->vram32_size / (1024*1024));
dprint(VAR_0, 1, "vram/64: %d MB %s\n",
VAR_0->vram_size / (1024*1024),
VAR_0->vram32_size < VAR_0->vram_size ? "[region 4]" : "[unmapped]");
VAR_0->ssd.VAR_0.base.sif = &qxl_interface.base;
VAR_0->ssd.VAR_0.id = VAR_0->id;
qemu_spice_add_interface(&VAR_0->ssd.VAR_0.base);
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, VAR_0);
init_pipe_signaling(VAR_0);
qxl_reset_state(VAR_0);
VAR_0->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, VAR_0);
return 0;
}
| [
"static int FUNC_0(PCIQXLDevice *VAR_0)\n{",
"uint8_t* config = VAR_0->pci.config;",
"uint32_t pci_device_rev;",
"uint32_t io_size;",
"VAR_0->mode = QXL_MODE_UNDEFINED;",
"VAR_0->generation = 1;",
"VAR_0->num_memslots = NUM_MEMSLOTS;",
"qemu_mutex_init(&VAR_0->track_lock);",
"qemu_mutex_init(&VAR_0->async_lock);",
"VAR_0->current_async = QXL_UNDEFINED_IO;",
"VAR_0->guest_bug = 0;",
"switch (VAR_0->revision) {",
"case 1:\npci_device_rev = QXL_REVISION_STABLE_V04;",
"io_size = 8;",
"break;",
"case 2:\npci_device_rev = QXL_REVISION_STABLE_V06;",
"io_size = 16;",
"break;",
"case 3:\npci_device_rev = QXL_REVISION_STABLE_V10;",
"io_size = 32;",
"break;",
"#if SPICE_SERVER_VERSION >= 0x000b01 && \\\ndefined(CONFIG_QXL_IO_MONITORS_CONFIG_ASYNC)\ncase 4:\npci_device_rev = QXL_REVISION_STABLE_V12;",
"io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);",
"break;",
"#endif\ndefault:\nerror_report(\"Invalid revision %d for VAR_0 device (max %d)\",\nVAR_0->revision, QXL_DEFAULT_REVISION);",
"return -1;",
"}",
"pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);",
"pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);",
"VAR_0->rom_size = qxl_rom_size();",
"memory_region_init_ram(&VAR_0->rom_bar, \"VAR_0.vrom\", VAR_0->rom_size);",
"vmstate_register_ram(&VAR_0->rom_bar, &VAR_0->pci.qdev);",
"init_qxl_rom(VAR_0);",
"init_qxl_ram(VAR_0);",
"VAR_0->guest_surfaces.cmds = g_new0(QXLPHYSICAL, VAR_0->ssd.num_surfaces);",
"memory_region_init_ram(&VAR_0->vram_bar, \"VAR_0.vram\", VAR_0->vram_size);",
"vmstate_register_ram(&VAR_0->vram_bar, &VAR_0->pci.qdev);",
"memory_region_init_alias(&VAR_0->vram32_bar, \"VAR_0.vram32\", &VAR_0->vram_bar,\n0, VAR_0->vram32_size);",
"memory_region_init_io(&VAR_0->io_bar, &qxl_io_ops, VAR_0,\n\"VAR_0-ioports\", io_size);",
"if (VAR_0->id == 0) {",
"vga_dirty_log_start(&VAR_0->vga);",
"}",
"memory_region_set_flush_coalesced(&VAR_0->io_bar);",
"pci_register_bar(&VAR_0->pci, QXL_IO_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_IO, &VAR_0->io_bar);",
"pci_register_bar(&VAR_0->pci, QXL_ROM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->rom_bar);",
"pci_register_bar(&VAR_0->pci, QXL_RAM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vga.vram);",
"pci_register_bar(&VAR_0->pci, QXL_VRAM_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY, &VAR_0->vram32_bar);",
"if (VAR_0->vram32_size < VAR_0->vram_size) {",
"pci_register_bar(&VAR_0->pci, QXL_VRAM64_RANGE_INDEX,\nPCI_BASE_ADDRESS_SPACE_MEMORY |\nPCI_BASE_ADDRESS_MEM_TYPE_64 |\nPCI_BASE_ADDRESS_MEM_PREFETCH,\n&VAR_0->vram_bar);",
"}",
"dprint(VAR_0, 1, \"ram/%s: %d MB [region 0]\\n\",\nVAR_0->id == 0 ? \"pri\" : \"sec\",\nVAR_0->vga.vram_size / (1024*1024));",
"dprint(VAR_0, 1, \"vram/32: %d MB [region 1]\\n\",\nVAR_0->vram32_size / (1024*1024));",
"dprint(VAR_0, 1, \"vram/64: %d MB %s\\n\",\nVAR_0->vram_size / (1024*1024),\nVAR_0->vram32_size < VAR_0->vram_size ? \"[region 4]\" : \"[unmapped]\");",
"VAR_0->ssd.VAR_0.base.sif = &qxl_interface.base;",
"VAR_0->ssd.VAR_0.id = VAR_0->id;",
"qemu_spice_add_interface(&VAR_0->ssd.VAR_0.base);",
"qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, VAR_0);",
"init_pipe_signaling(VAR_0);",
"qxl_reset_state(VAR_0);",
"VAR_0->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, 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,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57,
59,
61,
63
],
[
65
],
[
67
],
[
69,
71,
73,
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129,
131
],
[
135,
137
],
[
141,
143
],
[
147,
149
],
[
153
],
[
163,
165,
167,
169,
171
],
[
173
],
[
179,
181,
183
],
[
185,
187
],
[
189,
191,
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213
],
[
217
],
[
219
]
] |
19,981 | static void create_header64(DumpState *s, Error **errp)
{
DiskDumpHeader64 *dh = NULL;
KdumpSubHeader64 *kh = NULL;
size_t size;
uint32_t block_size;
uint32_t sub_hdr_size;
uint32_t bitmap_blocks;
uint32_t status = 0;
uint64_t offset_note;
Error *local_err = NULL;
/* write common header, the version of kdump-compressed format is 6th */
size = sizeof(DiskDumpHeader64);
dh = g_malloc0(size);
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
dh->header_version = cpu_to_dump32(s, 6);
block_size = s->dump_info.page_size;
dh->block_size = cpu_to_dump32(s, block_size);
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
dh->sub_hdr_size = cpu_to_dump32(s, sub_hdr_size);
/* dh->max_mapnr may be truncated, full 64bit is in kh.max_mapnr_64 */
dh->max_mapnr = cpu_to_dump32(s, MIN(s->max_mapnr, UINT_MAX));
dh->nr_cpus = cpu_to_dump32(s, s->nr_cpus);
bitmap_blocks = DIV_ROUND_UP(s->len_dump_bitmap, block_size) * 2;
dh->bitmap_blocks = cpu_to_dump32(s, bitmap_blocks);
strncpy(dh->utsname.machine, ELF_MACHINE_UNAME, sizeof(dh->utsname.machine));
if (s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) {
status |= DUMP_DH_COMPRESSED_ZLIB;
#ifdef CONFIG_LZO
if (s->flag_compress & DUMP_DH_COMPRESSED_LZO) {
status |= DUMP_DH_COMPRESSED_LZO;
#endif
#ifdef CONFIG_SNAPPY
if (s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) {
status |= DUMP_DH_COMPRESSED_SNAPPY;
#endif
dh->status = cpu_to_dump32(s, status);
if (write_buffer(s->fd, 0, dh, size) < 0) {
error_setg(errp, "dump: failed to write disk dump header");
goto out;
/* write sub header */
size = sizeof(KdumpSubHeader64);
kh = g_malloc0(size);
/* 64bit max_mapnr_64 */
kh->max_mapnr_64 = cpu_to_dump64(s, s->max_mapnr);
kh->phys_base = cpu_to_dump64(s, s->dump_info.phys_base);
kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
kh->offset_note = cpu_to_dump64(s, offset_note);
kh->note_size = cpu_to_dump64(s, s->note_size);
if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
block_size, kh, size) < 0) {
error_setg(errp, "dump: failed to write kdump sub header");
goto out;
/* write note */
s->note_buf = g_malloc0(s->note_size);
s->note_buf_offset = 0;
/* use s->note_buf to store notes temporarily */
write_elf64_notes(buf_write_note, s, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
if (write_buffer(s->fd, offset_note, s->note_buf,
s->note_size) < 0) {
error_setg(errp, "dump: failed to write notes");
goto out;
/* get offset of dump_bitmap */
s->offset_dump_bitmap = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size) *
block_size;
/* get offset of page */
s->offset_page = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size + bitmap_blocks) *
block_size;
out:
g_free(dh);
g_free(kh);
g_free(s->note_buf); | true | qemu | 9ada575bbafaf6d3724a7f59df9da89776817cac | static void create_header64(DumpState *s, Error **errp)
{
DiskDumpHeader64 *dh = NULL;
KdumpSubHeader64 *kh = NULL;
size_t size;
uint32_t block_size;
uint32_t sub_hdr_size;
uint32_t bitmap_blocks;
uint32_t status = 0;
uint64_t offset_note;
Error *local_err = NULL;
size = sizeof(DiskDumpHeader64);
dh = g_malloc0(size);
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
dh->header_version = cpu_to_dump32(s, 6);
block_size = s->dump_info.page_size;
dh->block_size = cpu_to_dump32(s, block_size);
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
dh->sub_hdr_size = cpu_to_dump32(s, sub_hdr_size);
dh->max_mapnr = cpu_to_dump32(s, MIN(s->max_mapnr, UINT_MAX));
dh->nr_cpus = cpu_to_dump32(s, s->nr_cpus);
bitmap_blocks = DIV_ROUND_UP(s->len_dump_bitmap, block_size) * 2;
dh->bitmap_blocks = cpu_to_dump32(s, bitmap_blocks);
strncpy(dh->utsname.machine, ELF_MACHINE_UNAME, sizeof(dh->utsname.machine));
if (s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) {
status |= DUMP_DH_COMPRESSED_ZLIB;
#ifdef CONFIG_LZO
if (s->flag_compress & DUMP_DH_COMPRESSED_LZO) {
status |= DUMP_DH_COMPRESSED_LZO;
#endif
#ifdef CONFIG_SNAPPY
if (s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) {
status |= DUMP_DH_COMPRESSED_SNAPPY;
#endif
dh->status = cpu_to_dump32(s, status);
if (write_buffer(s->fd, 0, dh, size) < 0) {
error_setg(errp, "dump: failed to write disk dump header");
goto out;
size = sizeof(KdumpSubHeader64);
kh = g_malloc0(size);
kh->max_mapnr_64 = cpu_to_dump64(s, s->max_mapnr);
kh->phys_base = cpu_to_dump64(s, s->dump_info.phys_base);
kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
kh->offset_note = cpu_to_dump64(s, offset_note);
kh->note_size = cpu_to_dump64(s, s->note_size);
if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS *
block_size, kh, size) < 0) {
error_setg(errp, "dump: failed to write kdump sub header");
goto out;
s->note_buf = g_malloc0(s->note_size);
s->note_buf_offset = 0;
write_elf64_notes(buf_write_note, s, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
if (write_buffer(s->fd, offset_note, s->note_buf,
s->note_size) < 0) {
error_setg(errp, "dump: failed to write notes");
goto out;
s->offset_dump_bitmap = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size) *
block_size;
s->offset_page = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size + bitmap_blocks) *
block_size;
out:
g_free(dh);
g_free(kh);
g_free(s->note_buf); | {
"code": [],
"line_no": []
} | static void FUNC_0(DumpState *VAR_0, Error **VAR_1)
{
DiskDumpHeader64 *dh = NULL;
KdumpSubHeader64 *kh = NULL;
size_t size;
uint32_t block_size;
uint32_t sub_hdr_size;
uint32_t bitmap_blocks;
uint32_t status = 0;
uint64_t offset_note;
Error *local_err = NULL;
size = sizeof(DiskDumpHeader64);
dh = g_malloc0(size);
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
dh->header_version = cpu_to_dump32(VAR_0, 6);
block_size = VAR_0->dump_info.page_size;
dh->block_size = cpu_to_dump32(VAR_0, block_size);
sub_hdr_size = sizeof(struct KdumpSubHeader64) + VAR_0->note_size;
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
dh->sub_hdr_size = cpu_to_dump32(VAR_0, sub_hdr_size);
dh->max_mapnr = cpu_to_dump32(VAR_0, MIN(VAR_0->max_mapnr, UINT_MAX));
dh->nr_cpus = cpu_to_dump32(VAR_0, VAR_0->nr_cpus);
bitmap_blocks = DIV_ROUND_UP(VAR_0->len_dump_bitmap, block_size) * 2;
dh->bitmap_blocks = cpu_to_dump32(VAR_0, bitmap_blocks);
strncpy(dh->utsname.machine, ELF_MACHINE_UNAME, sizeof(dh->utsname.machine));
if (VAR_0->flag_compress & DUMP_DH_COMPRESSED_ZLIB) {
status |= DUMP_DH_COMPRESSED_ZLIB;
#ifdef CONFIG_LZO
if (VAR_0->flag_compress & DUMP_DH_COMPRESSED_LZO) {
status |= DUMP_DH_COMPRESSED_LZO;
#endif
#ifdef CONFIG_SNAPPY
if (VAR_0->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) {
status |= DUMP_DH_COMPRESSED_SNAPPY;
#endif
dh->status = cpu_to_dump32(VAR_0, status);
if (write_buffer(VAR_0->fd, 0, dh, size) < 0) {
error_setg(VAR_1, "dump: failed to write disk dump header");
goto out;
size = sizeof(KdumpSubHeader64);
kh = g_malloc0(size);
kh->max_mapnr_64 = cpu_to_dump64(VAR_0, VAR_0->max_mapnr);
kh->phys_base = cpu_to_dump64(VAR_0, VAR_0->dump_info.phys_base);
kh->dump_level = cpu_to_dump32(VAR_0, DUMP_LEVEL);
offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
kh->offset_note = cpu_to_dump64(VAR_0, offset_note);
kh->note_size = cpu_to_dump64(VAR_0, VAR_0->note_size);
if (write_buffer(VAR_0->fd, DISKDUMP_HEADER_BLOCKS *
block_size, kh, size) < 0) {
error_setg(VAR_1, "dump: failed to write kdump sub header");
goto out;
VAR_0->note_buf = g_malloc0(VAR_0->note_size);
VAR_0->note_buf_offset = 0;
write_elf64_notes(buf_write_note, VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
goto out;
if (write_buffer(VAR_0->fd, offset_note, VAR_0->note_buf,
VAR_0->note_size) < 0) {
error_setg(VAR_1, "dump: failed to write notes");
goto out;
VAR_0->offset_dump_bitmap = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size) *
block_size;
VAR_0->offset_page = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size + bitmap_blocks) *
block_size;
out:
g_free(dh);
g_free(kh);
g_free(VAR_0->note_buf); | [
"static void FUNC_0(DumpState *VAR_0, Error **VAR_1)\n{",
"DiskDumpHeader64 *dh = NULL;",
"KdumpSubHeader64 *kh = NULL;",
"size_t size;",
"uint32_t block_size;",
"uint32_t sub_hdr_size;",
"uint32_t bitmap_blocks;",
"uint32_t status = 0;",
"uint64_t offset_note;",
"Error *local_err = NULL;",
"size = sizeof(DiskDumpHeader64);",
"dh = g_malloc0(size);",
"strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));",
"dh->header_version = cpu_to_dump32(VAR_0, 6);",
"block_size = VAR_0->dump_info.page_size;",
"dh->block_size = cpu_to_dump32(VAR_0, block_size);",
"sub_hdr_size = sizeof(struct KdumpSubHeader64) + VAR_0->note_size;",
"sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);",
"dh->sub_hdr_size = cpu_to_dump32(VAR_0, sub_hdr_size);",
"dh->max_mapnr = cpu_to_dump32(VAR_0, MIN(VAR_0->max_mapnr, UINT_MAX));",
"dh->nr_cpus = cpu_to_dump32(VAR_0, VAR_0->nr_cpus);",
"bitmap_blocks = DIV_ROUND_UP(VAR_0->len_dump_bitmap, block_size) * 2;",
"dh->bitmap_blocks = cpu_to_dump32(VAR_0, bitmap_blocks);",
"strncpy(dh->utsname.machine, ELF_MACHINE_UNAME, sizeof(dh->utsname.machine));",
"if (VAR_0->flag_compress & DUMP_DH_COMPRESSED_ZLIB) {",
"status |= DUMP_DH_COMPRESSED_ZLIB;",
"#ifdef CONFIG_LZO\nif (VAR_0->flag_compress & DUMP_DH_COMPRESSED_LZO) {",
"status |= DUMP_DH_COMPRESSED_LZO;",
"#endif\n#ifdef CONFIG_SNAPPY\nif (VAR_0->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) {",
"status |= DUMP_DH_COMPRESSED_SNAPPY;",
"#endif\ndh->status = cpu_to_dump32(VAR_0, status);",
"if (write_buffer(VAR_0->fd, 0, dh, size) < 0) {",
"error_setg(VAR_1, \"dump: failed to write disk dump header\");",
"goto out;",
"size = sizeof(KdumpSubHeader64);",
"kh = g_malloc0(size);",
"kh->max_mapnr_64 = cpu_to_dump64(VAR_0, VAR_0->max_mapnr);",
"kh->phys_base = cpu_to_dump64(VAR_0, VAR_0->dump_info.phys_base);",
"kh->dump_level = cpu_to_dump32(VAR_0, DUMP_LEVEL);",
"offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;",
"kh->offset_note = cpu_to_dump64(VAR_0, offset_note);",
"kh->note_size = cpu_to_dump64(VAR_0, VAR_0->note_size);",
"if (write_buffer(VAR_0->fd, DISKDUMP_HEADER_BLOCKS *\nblock_size, kh, size) < 0) {",
"error_setg(VAR_1, \"dump: failed to write kdump sub header\");",
"goto out;",
"VAR_0->note_buf = g_malloc0(VAR_0->note_size);",
"VAR_0->note_buf_offset = 0;",
"write_elf64_notes(buf_write_note, VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"goto out;",
"if (write_buffer(VAR_0->fd, offset_note, VAR_0->note_buf,\nVAR_0->note_size) < 0) {",
"error_setg(VAR_1, \"dump: failed to write notes\");",
"goto out;",
"VAR_0->offset_dump_bitmap = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size) *\nblock_size;",
"VAR_0->offset_page = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size + bitmap_blocks) *\nblock_size;",
"out:\ng_free(dh);",
"g_free(kh);",
"g_free(VAR_0->note_buf);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30,
31
],
[
32
],
[
33,
34,
35
],
[
36
],
[
37,
38
],
[
39
],
[
40
],
[
41
],
[
43
],
[
44
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52,
53
],
[
54
],
[
55
],
[
57
],
[
58
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64,
65
],
[
66
],
[
67
],
[
69,
70
],
[
72,
73
],
[
74,
75
],
[
76
],
[
77
]
] |
19,982 | static void test_rtas_get_time_of_day(void)
{
QOSState *qs;
struct tm tm;
uint32_t ns;
uint64_t ret;
time_t t1, t2;
qs = qtest_spapr_boot("-machine pseries");
g_assert(qs != NULL);
t1 = time(NULL);
ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);
g_assert_cmpint(ret, ==, 0);
t2 = mktimegm(&tm);
g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
qtest_shutdown(qs);
}
| true | qemu | 458f3b2c953bdc7110896cb3691251023652523f | static void test_rtas_get_time_of_day(void)
{
QOSState *qs;
struct tm tm;
uint32_t ns;
uint64_t ret;
time_t t1, t2;
qs = qtest_spapr_boot("-machine pseries");
g_assert(qs != NULL);
t1 = time(NULL);
ret = qrtas_get_time_of_day(qs->alloc, &tm, &ns);
g_assert_cmpint(ret, ==, 0);
t2 = mktimegm(&tm);
g_assert(t2 - t1 < 5);
qtest_shutdown(qs);
}
| {
"code": [
" g_assert(qs != NULL);"
],
"line_no": [
19
]
} | static void FUNC_0(void)
{
QOSState *qs;
struct VAR_0 VAR_0;
uint32_t ns;
uint64_t ret;
time_t t1, t2;
qs = qtest_spapr_boot("-machine pseries");
g_assert(qs != NULL);
t1 = time(NULL);
ret = qrtas_get_time_of_day(qs->alloc, &VAR_0, &ns);
g_assert_cmpint(ret, ==, 0);
t2 = mktimegm(&VAR_0);
g_assert(t2 - t1 < 5);
qtest_shutdown(qs);
}
| [
"static void FUNC_0(void)\n{",
"QOSState *qs;",
"struct VAR_0 VAR_0;",
"uint32_t ns;",
"uint64_t ret;",
"time_t t1, t2;",
"qs = qtest_spapr_boot(\"-machine pseries\");",
"g_assert(qs != NULL);",
"t1 = time(NULL);",
"ret = qrtas_get_time_of_day(qs->alloc, &VAR_0, &ns);",
"g_assert_cmpint(ret, ==, 0);",
"t2 = mktimegm(&VAR_0);",
"g_assert(t2 - t1 < 5);",
"qtest_shutdown(qs);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
19,983 | int qemu_opts_set(QemuOptsList *list, const char *id,
const char *name, const char *value)
{
QemuOpts *opts;
opts = qemu_opts_create(list, id, 1);
if (opts == NULL) {
return -1;
}
return qemu_opt_set(opts, name, value);
}
| true | qemu | 8be7e7e4c72c048b90e3482557954a24bba43ba7 | int qemu_opts_set(QemuOptsList *list, const char *id,
const char *name, const char *value)
{
QemuOpts *opts;
opts = qemu_opts_create(list, id, 1);
if (opts == NULL) {
return -1;
}
return qemu_opt_set(opts, name, value);
}
| {
"code": [
" opts = qemu_opts_create(list, id, 1);",
" if (opts == NULL) {"
],
"line_no": [
11,
13
]
} | int FUNC_0(QemuOptsList *VAR_0, const char *VAR_1,
const char *VAR_2, const char *VAR_3)
{
QemuOpts *opts;
opts = qemu_opts_create(VAR_0, VAR_1, 1);
if (opts == NULL) {
return -1;
}
return qemu_opt_set(opts, VAR_2, VAR_3);
}
| [
"int FUNC_0(QemuOptsList *VAR_0, const char *VAR_1,\nconst char *VAR_2, const char *VAR_3)\n{",
"QemuOpts *opts;",
"opts = qemu_opts_create(VAR_0, VAR_1, 1);",
"if (opts == NULL) {",
"return -1;",
"}",
"return qemu_opt_set(opts, VAR_2, VAR_3);",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,984 | static int parse_icy(HTTPContext *s, const char *tag, const char *p)
{
int len = 4 + strlen(p) + strlen(tag);
int is_first = !s->icy_metadata_headers;
int ret;
if (s->icy_metadata_headers)
len += strlen(s->icy_metadata_headers);
if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
return ret;
av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
return 0;
} | true | FFmpeg | 6998a9f4c4e069f515c50614179f4cfc7d0184f5 | static int parse_icy(HTTPContext *s, const char *tag, const char *p)
{
int len = 4 + strlen(p) + strlen(tag);
int is_first = !s->icy_metadata_headers;
int ret;
if (s->icy_metadata_headers)
len += strlen(s->icy_metadata_headers);
if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
return ret;
av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(HTTPContext *VAR_0, const char *VAR_1, const char *VAR_2)
{
int VAR_3 = 4 + strlen(VAR_2) + strlen(VAR_1);
int VAR_4 = !VAR_0->icy_metadata_headers;
int VAR_5;
if (VAR_0->icy_metadata_headers)
VAR_3 += strlen(VAR_0->icy_metadata_headers);
if ((VAR_5 = av_reallocp(&VAR_0->icy_metadata_headers, VAR_3)) < 0)
return VAR_5;
av_strlcatf(VAR_0->icy_metadata_headers, VAR_3, "%VAR_0: %VAR_0\n", VAR_1, VAR_2);
return 0;
} | [
"static int FUNC_0(HTTPContext *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"int VAR_3 = 4 + strlen(VAR_2) + strlen(VAR_1);",
"int VAR_4 = !VAR_0->icy_metadata_headers;",
"int VAR_5;",
"if (VAR_0->icy_metadata_headers)\nVAR_3 += strlen(VAR_0->icy_metadata_headers);",
"if ((VAR_5 = av_reallocp(&VAR_0->icy_metadata_headers, VAR_3)) < 0)\nreturn VAR_5;",
"av_strlcatf(VAR_0->icy_metadata_headers, VAR_3, \"%VAR_0: %VAR_0\\n\", VAR_1, VAR_2);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6,
7
],
[
8,
9
],
[
10
],
[
11
],
[
12
]
] |
19,985 | static av_cold void decode_init_vlc(void){
static int done = 0;
if (!done) {
int i;
done = 1;
init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,
&chroma_dc_coeff_token_len [0], 1, 1,
&chroma_dc_coeff_token_bits[0], 1, 1, 1);
for(i=0; i<4; i++){
init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17,
&coeff_token_len [i][0], 1, 1,
&coeff_token_bits[i][0], 1, 1, 1);
}
for(i=0; i<3; i++){
init_vlc(&chroma_dc_total_zeros_vlc[i], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,
&chroma_dc_total_zeros_len [i][0], 1, 1,
&chroma_dc_total_zeros_bits[i][0], 1, 1, 1);
}
for(i=0; i<15; i++){
init_vlc(&total_zeros_vlc[i], TOTAL_ZEROS_VLC_BITS, 16,
&total_zeros_len [i][0], 1, 1,
&total_zeros_bits[i][0], 1, 1, 1);
}
for(i=0; i<6; i++){
init_vlc(&run_vlc[i], RUN_VLC_BITS, 7,
&run_len [i][0], 1, 1,
&run_bits[i][0], 1, 1, 1);
}
init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
&run_len [6][0], 1, 1,
&run_bits[6][0], 1, 1, 1);
}
}
| true | FFmpeg | 910e3668170d2e1e56dc28f8b722232a218e4b9a | static av_cold void decode_init_vlc(void){
static int done = 0;
if (!done) {
int i;
done = 1;
init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,
&chroma_dc_coeff_token_len [0], 1, 1,
&chroma_dc_coeff_token_bits[0], 1, 1, 1);
for(i=0; i<4; i++){
init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17,
&coeff_token_len [i][0], 1, 1,
&coeff_token_bits[i][0], 1, 1, 1);
}
for(i=0; i<3; i++){
init_vlc(&chroma_dc_total_zeros_vlc[i], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,
&chroma_dc_total_zeros_len [i][0], 1, 1,
&chroma_dc_total_zeros_bits[i][0], 1, 1, 1);
}
for(i=0; i<15; i++){
init_vlc(&total_zeros_vlc[i], TOTAL_ZEROS_VLC_BITS, 16,
&total_zeros_len [i][0], 1, 1,
&total_zeros_bits[i][0], 1, 1, 1);
}
for(i=0; i<6; i++){
init_vlc(&run_vlc[i], RUN_VLC_BITS, 7,
&run_len [i][0], 1, 1,
&run_bits[i][0], 1, 1, 1);
}
init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
&run_len [6][0], 1, 1,
&run_bits[6][0], 1, 1, 1);
}
}
| {
"code": [
" &chroma_dc_coeff_token_bits[0], 1, 1, 1);",
" &coeff_token_bits[i][0], 1, 1, 1);",
" init_vlc(&chroma_dc_total_zeros_vlc[i], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,",
" &chroma_dc_total_zeros_bits[i][0], 1, 1, 1);",
" init_vlc(&total_zeros_vlc[i], TOTAL_ZEROS_VLC_BITS, 16,",
" &total_zeros_bits[i][0], 1, 1, 1);",
" init_vlc(&run_vlc[i], RUN_VLC_BITS, 7,",
" &run_bits[i][0], 1, 1, 1);",
" &run_bits[6][0], 1, 1, 1);"
],
"line_no": [
19,
29,
37,
41,
47,
51,
59,
63,
71
]
} | static av_cold void FUNC_0(void){
static int VAR_0 = 0;
if (!VAR_0) {
int VAR_1;
VAR_0 = 1;
init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,
&chroma_dc_coeff_token_len [0], 1, 1,
&chroma_dc_coeff_token_bits[0], 1, 1, 1);
for(VAR_1=0; VAR_1<4; VAR_1++){
init_vlc(&coeff_token_vlc[VAR_1], COEFF_TOKEN_VLC_BITS, 4*17,
&coeff_token_len [VAR_1][0], 1, 1,
&coeff_token_bits[VAR_1][0], 1, 1, 1);
}
for(VAR_1=0; VAR_1<3; VAR_1++){
init_vlc(&chroma_dc_total_zeros_vlc[VAR_1], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,
&chroma_dc_total_zeros_len [VAR_1][0], 1, 1,
&chroma_dc_total_zeros_bits[VAR_1][0], 1, 1, 1);
}
for(VAR_1=0; VAR_1<15; VAR_1++){
init_vlc(&total_zeros_vlc[VAR_1], TOTAL_ZEROS_VLC_BITS, 16,
&total_zeros_len [VAR_1][0], 1, 1,
&total_zeros_bits[VAR_1][0], 1, 1, 1);
}
for(VAR_1=0; VAR_1<6; VAR_1++){
init_vlc(&run_vlc[VAR_1], RUN_VLC_BITS, 7,
&run_len [VAR_1][0], 1, 1,
&run_bits[VAR_1][0], 1, 1, 1);
}
init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
&run_len [6][0], 1, 1,
&run_bits[6][0], 1, 1, 1);
}
}
| [
"static av_cold void FUNC_0(void){",
"static int VAR_0 = 0;",
"if (!VAR_0) {",
"int VAR_1;",
"VAR_0 = 1;",
"init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,\n&chroma_dc_coeff_token_len [0], 1, 1,\n&chroma_dc_coeff_token_bits[0], 1, 1, 1);",
"for(VAR_1=0; VAR_1<4; VAR_1++){",
"init_vlc(&coeff_token_vlc[VAR_1], COEFF_TOKEN_VLC_BITS, 4*17,\n&coeff_token_len [VAR_1][0], 1, 1,\n&coeff_token_bits[VAR_1][0], 1, 1, 1);",
"}",
"for(VAR_1=0; VAR_1<3; VAR_1++){",
"init_vlc(&chroma_dc_total_zeros_vlc[VAR_1], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,\n&chroma_dc_total_zeros_len [VAR_1][0], 1, 1,\n&chroma_dc_total_zeros_bits[VAR_1][0], 1, 1, 1);",
"}",
"for(VAR_1=0; VAR_1<15; VAR_1++){",
"init_vlc(&total_zeros_vlc[VAR_1], TOTAL_ZEROS_VLC_BITS, 16,\n&total_zeros_len [VAR_1][0], 1, 1,\n&total_zeros_bits[VAR_1][0], 1, 1, 1);",
"}",
"for(VAR_1=0; VAR_1<6; VAR_1++){",
"init_vlc(&run_vlc[VAR_1], RUN_VLC_BITS, 7,\n&run_len [VAR_1][0], 1, 1,\n&run_bits[VAR_1][0], 1, 1, 1);",
"}",
"init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,\n&run_len [6][0], 1, 1,\n&run_bits[6][0], 1, 1, 1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
1,
0,
0,
1,
0,
0,
1,
0,
1,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
23
],
[
25,
27,
29
],
[
31
],
[
35
],
[
37,
39,
41
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
57
],
[
59,
61,
63
],
[
65
],
[
67,
69,
71
],
[
73
],
[
75
]
] |
19,986 | static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char label[32];
static int index;
while (*filename && *filename != ':') {
const char *p;
char *e;
if (strstart(filename, "vendorid=", &p)) {
vendorid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus vendor ID %s", p);
return NULL;
}
filename = e;
} else if (strstart(filename, "productid=", &p)) {
productid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus product ID %s", p);
return NULL;
}
filename = e;
} else {
error_report("unrecognized serial USB option %s", filename);
return NULL;
}
while(*filename == ',')
filename++;
}
if (!*filename) {
error_report("character device specification needed");
return NULL;
}
filename++;
snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_new(label, filename, NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
}
| true | qemu | 3bc36a401e0f33e63a4d2c58b646ddf78efb567c | static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char label[32];
static int index;
while (*filename && *filename != ':') {
const char *p;
char *e;
if (strstart(filename, "vendorid=", &p)) {
vendorid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus vendor ID %s", p);
return NULL;
}
filename = e;
} else if (strstart(filename, "productid=", &p)) {
productid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
error_report("bogus product ID %s", p);
return NULL;
}
filename = e;
} else {
error_report("unrecognized serial USB option %s", filename);
return NULL;
}
while(*filename == ',')
filename++;
}
if (!*filename) {
error_report("character device specification needed");
return NULL;
}
filename++;
snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_new(label, filename, NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
}
| {
"code": [
" return NULL;",
" qdev_init_nofail(&dev->qdev);",
" qdev_init_nofail(&dev->qdev);",
" qdev_init_nofail(&dev->qdev);",
" return NULL;",
" qdev_init_nofail(&dev->qdev);"
],
"line_no": [
69,
99,
99,
99,
69,
99
]
} | static USBDevice *FUNC_0(USBBus *bus, const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char VAR_0[32];
static int VAR_1;
while (*filename && *filename != ':') {
const char *VAR_2;
char *VAR_3;
if (strstart(filename, "vendorid=", &VAR_2)) {
vendorid = strtol(VAR_2, &VAR_3, 16);
if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {
error_report("bogus vendor ID %s", VAR_2);
return NULL;
}
filename = VAR_3;
} else if (strstart(filename, "productid=", &VAR_2)) {
productid = strtol(VAR_2, &VAR_3, 16);
if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {
error_report("bogus product ID %s", VAR_2);
return NULL;
}
filename = VAR_3;
} else {
error_report("unrecognized serial USB option %s", filename);
return NULL;
}
while(*filename == ',')
filename++;
}
if (!*filename) {
error_report("character device specification needed");
return NULL;
}
filename++;
snprintf(VAR_0, sizeof(VAR_0), "usbserial%d", VAR_1++);
cdrv = qemu_chr_new(VAR_0, filename, NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
}
| [
"static USBDevice *FUNC_0(USBBus *bus, const char *filename)\n{",
"USBDevice *dev;",
"CharDriverState *cdrv;",
"uint32_t vendorid = 0, productid = 0;",
"char VAR_0[32];",
"static int VAR_1;",
"while (*filename && *filename != ':') {",
"const char *VAR_2;",
"char *VAR_3;",
"if (strstart(filename, \"vendorid=\", &VAR_2)) {",
"vendorid = strtol(VAR_2, &VAR_3, 16);",
"if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {",
"error_report(\"bogus vendor ID %s\", VAR_2);",
"return NULL;",
"}",
"filename = VAR_3;",
"} else if (strstart(filename, \"productid=\", &VAR_2)) {",
"productid = strtol(VAR_2, &VAR_3, 16);",
"if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {",
"error_report(\"bogus product ID %s\", VAR_2);",
"return NULL;",
"}",
"filename = VAR_3;",
"} else {",
"error_report(\"unrecognized serial USB option %s\", filename);",
"return NULL;",
"}",
"while(*filename == ',')\nfilename++;",
"}",
"if (!*filename) {",
"error_report(\"character device specification needed\");",
"return NULL;",
"}",
"filename++;",
"snprintf(VAR_0, sizeof(VAR_0), \"usbserial%d\", VAR_1++);",
"cdrv = qemu_chr_new(VAR_0, filename, NULL);",
"if (!cdrv)\nreturn NULL;",
"dev = usb_create(bus, \"usb-serial\");",
"qdev_prop_set_chr(&dev->qdev, \"chardev\", cdrv);",
"if (vendorid)\nqdev_prop_set_uint16(&dev->qdev, \"vendorid\", vendorid);",
"if (productid)\nqdev_prop_set_uint16(&dev->qdev, \"productid\", productid);",
"qdev_init_nofail(&dev->qdev);",
"return dev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81,
83
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.