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
|
---|---|---|---|---|---|---|---|---|---|---|
2,688 | static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,
int step)
{
int i, j;
int offset = avctx->width * step;
uint8_t *outdata = p->data[0];
for (i = 0; i < avctx->height; i++) {
int size, left, code, pix;
uint8_t *out = outdata;
int pos = 0;
/* size of packed line */
size = left = bytestream2_get_be16(gbc);
if (bytestream2_get_bytes_left(gbc) < size)
/* decode line */
while (left > 0) {
code = bytestream2_get_byte(gbc);
if (code & 0x80 ) { /* run */
pix = bytestream2_get_byte(gbc);
for (j = 0; j < 257 - code; j++) {
out[pos] = pix;
pos += step;
if (pos >= offset) {
pos -= offset;
pos++;
}
}
left -= 2;
} else { /* copy */
for (j = 0; j < code + 1; j++) {
out[pos] = bytestream2_get_byte(gbc);
pos += step;
if (pos >= offset) {
pos -= offset;
pos++;
}
}
left -= 2 + code;
}
}
outdata += p->linesize[0];
}
return 0;
} | true | FFmpeg | 1eda55510ae5d15ce3df9f496002508580899045 | static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,
int step)
{
int i, j;
int offset = avctx->width * step;
uint8_t *outdata = p->data[0];
for (i = 0; i < avctx->height; i++) {
int size, left, code, pix;
uint8_t *out = outdata;
int pos = 0;
size = left = bytestream2_get_be16(gbc);
if (bytestream2_get_bytes_left(gbc) < size)
while (left > 0) {
code = bytestream2_get_byte(gbc);
if (code & 0x80 ) {
pix = bytestream2_get_byte(gbc);
for (j = 0; j < 257 - code; j++) {
out[pos] = pix;
pos += step;
if (pos >= offset) {
pos -= offset;
pos++;
}
}
left -= 2;
} else {
for (j = 0; j < code + 1; j++) {
out[pos] = bytestream2_get_byte(gbc);
pos += step;
if (pos >= offset) {
pos -= offset;
pos++;
}
}
left -= 2 + code;
}
}
outdata += p->linesize[0];
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, GetByteContext *VAR_2,
int VAR_3)
{
int VAR_4, VAR_5;
int VAR_6 = VAR_0->width * VAR_3;
uint8_t *outdata = VAR_1->data[0];
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {
int size, left, code, pix;
uint8_t *out = outdata;
int pos = 0;
size = left = bytestream2_get_be16(VAR_2);
if (bytestream2_get_bytes_left(VAR_2) < size)
while (left > 0) {
code = bytestream2_get_byte(VAR_2);
if (code & 0x80 ) {
pix = bytestream2_get_byte(VAR_2);
for (VAR_5 = 0; VAR_5 < 257 - code; VAR_5++) {
out[pos] = pix;
pos += VAR_3;
if (pos >= VAR_6) {
pos -= VAR_6;
pos++;
}
}
left -= 2;
} else {
for (VAR_5 = 0; VAR_5 < code + 1; VAR_5++) {
out[pos] = bytestream2_get_byte(VAR_2);
pos += VAR_3;
if (pos >= VAR_6) {
pos -= VAR_6;
pos++;
}
}
left -= 2 + code;
}
}
outdata += VAR_1->linesize[0];
}
return 0;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, GetByteContext *VAR_2,\nint VAR_3)\n{",
"int VAR_4, VAR_5;",
"int VAR_6 = VAR_0->width * VAR_3;",
"uint8_t *outdata = VAR_1->data[0];",
"for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) {",
"int size, left, code, pix;",
"uint8_t *out = outdata;",
"int pos = 0;",
"size = left = bytestream2_get_be16(VAR_2);",
"if (bytestream2_get_bytes_left(VAR_2) < size)\nwhile (left > 0) {",
"code = bytestream2_get_byte(VAR_2);",
"if (code & 0x80 ) {",
"pix = bytestream2_get_byte(VAR_2);",
"for (VAR_5 = 0; VAR_5 < 257 - code; VAR_5++) {",
"out[pos] = pix;",
"pos += VAR_3;",
"if (pos >= VAR_6) {",
"pos -= VAR_6;",
"pos++;",
"}",
"}",
"left -= 2;",
"} else {",
"for (VAR_5 = 0; VAR_5 < code + 1; VAR_5++) {",
"out[pos] = bytestream2_get_byte(VAR_2);",
"pos += VAR_3;",
"if (pos >= VAR_6) {",
"pos -= VAR_6;",
"pos++;",
"}",
"}",
"left -= 2 + code;",
"}",
"}",
"outdata += VAR_1->linesize[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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29,
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
46
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
74
],
[
76
],
[
78
],
[
82
],
[
84
],
[
86
],
[
88
],
[
90
],
[
92
],
[
94
],
[
96
]
] |
2,689 | uint64_t helper_msub64_q_ssov(CPUTriCoreState *env, uint64_t r1, uint32_t r2,
uint32_t r3, uint32_t n)
{
int64_t t1 = (int64_t)r1;
int64_t t2 = sextract64(r2, 0, 32);
int64_t t3 = sextract64(r3, 0, 32);
int64_t result, mul;
int64_t ovf;
mul = (t2 * t3) << n;
result = t1 - mul;
env->PSW_USB_AV = (result ^ result * 2u) >> 32;
env->PSW_USB_SAV |= env->PSW_USB_AV;
ovf = (result ^ t1) & (t1 ^ mul);
/* we do the saturation by hand, since we produce an overflow on the host
if the mul before was (0x80000000 * 0x80000000) << 1). If this is the
case, we flip the saturated value. */
if (mul == 0x8000000000000000LL) {
if (ovf >= 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
/* ext_ret > MAX_INT */
if (mul >= 0) {
result = INT64_MAX;
/* ext_ret < MIN_INT */
result = INT64_MIN;
}
}
if (ovf < 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
/* ext_ret > MAX_INT */
if (mul < 0) {
result = INT64_MAX;
/* ext_ret < MIN_INT */
result = INT64_MIN;
}
}
}
return (uint64_t)result;
} | true | qemu | 9029710b9ead9c11649ec142d18581412d8f3e68 | uint64_t helper_msub64_q_ssov(CPUTriCoreState *env, uint64_t r1, uint32_t r2,
uint32_t r3, uint32_t n)
{
int64_t t1 = (int64_t)r1;
int64_t t2 = sextract64(r2, 0, 32);
int64_t t3 = sextract64(r3, 0, 32);
int64_t result, mul;
int64_t ovf;
mul = (t2 * t3) << n;
result = t1 - mul;
env->PSW_USB_AV = (result ^ result * 2u) >> 32;
env->PSW_USB_SAV |= env->PSW_USB_AV;
ovf = (result ^ t1) & (t1 ^ mul);
if (mul == 0x8000000000000000LL) {
if (ovf >= 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
if (mul >= 0) {
result = INT64_MAX;
result = INT64_MIN;
}
}
if (ovf < 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
if (mul < 0) {
result = INT64_MAX;
result = INT64_MIN;
}
}
}
return (uint64_t)result;
} | {
"code": [],
"line_no": []
} | uint64_t FUNC_0(CPUTriCoreState *env, uint64_t r1, uint32_t r2,
uint32_t r3, uint32_t n)
{
int64_t t1 = (int64_t)r1;
int64_t t2 = sextract64(r2, 0, 32);
int64_t t3 = sextract64(r3, 0, 32);
int64_t result, mul;
int64_t ovf;
mul = (t2 * t3) << n;
result = t1 - mul;
env->PSW_USB_AV = (result ^ result * 2u) >> 32;
env->PSW_USB_SAV |= env->PSW_USB_AV;
ovf = (result ^ t1) & (t1 ^ mul);
if (mul == 0x8000000000000000LL) {
if (ovf >= 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
if (mul >= 0) {
result = INT64_MAX;
result = INT64_MIN;
}
}
if (ovf < 0) {
env->PSW_USB_V = (1 << 31);
env->PSW_USB_SV = (1 << 31);
if (mul < 0) {
result = INT64_MAX;
result = INT64_MIN;
}
}
}
return (uint64_t)result;
} | [
"uint64_t FUNC_0(CPUTriCoreState *env, uint64_t r1, uint32_t r2,\nuint32_t r3, uint32_t n)\n{",
"int64_t t1 = (int64_t)r1;",
"int64_t t2 = sextract64(r2, 0, 32);",
"int64_t t3 = sextract64(r3, 0, 32);",
"int64_t result, mul;",
"int64_t ovf;",
"mul = (t2 * t3) << n;",
"result = t1 - mul;",
"env->PSW_USB_AV = (result ^ result * 2u) >> 32;",
"env->PSW_USB_SAV |= env->PSW_USB_AV;",
"ovf = (result ^ t1) & (t1 ^ mul);",
"if (mul == 0x8000000000000000LL) {",
"if (ovf >= 0) {",
"env->PSW_USB_V = (1 << 31);",
"env->PSW_USB_SV = (1 << 31);",
"if (mul >= 0) {",
"result = INT64_MAX;",
"result = INT64_MIN;",
"}",
"}",
"if (ovf < 0) {",
"env->PSW_USB_V = (1 << 31);",
"env->PSW_USB_SV = (1 << 31);",
"if (mul < 0) {",
"result = INT64_MAX;",
"result = INT64_MIN;",
"}",
"}",
"}",
"return (uint64_t)result;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
56
],
[
58
],
[
62
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
80
],
[
82
],
[
86
],
[
88
],
[
92
],
[
94
]
] |
2,690 | static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
hwaddr base,
MemoryRegionListHead *alias_print_queue)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
if (!mr) {
return;
}
for (i = 0; i < level; i++) {
mon_printf(f, MTREE_INDENT);
}
if (mr->alias) {
MemoryRegionList *ml;
bool found = false;
/* check if the alias is already in the queue */
QTAILQ_FOREACH(ml, alias_print_queue, queue) {
if (ml->mr == mr->alias) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->mr = mr->alias;
QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %s): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
base + mr->addr,
base + mr->addr + MR_SIZE(mr->size),
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
memory_region_name(mr->alias),
mr->alias_offset,
mr->alias_offset + MR_SIZE(mr->size),
mr->enabled ? "" : " [disabled]");
} else {
mon_printf(f,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",
base + mr->addr,
base + mr->addr + MR_SIZE(mr->size),
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
mr->enabled ? "" : " [disabled]");
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->mr = submr;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->mr->addr < ml->mr->addr ||
(new_ml->mr->addr == ml->mr->addr &&
new_ml->mr->priority > ml->mr->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
alias_print_queue);
}
QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {
g_free(ml);
}
}
| true | qemu | b31f84126215e3fd4b8acbc3083ae30d407329e8 | static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
hwaddr base,
MemoryRegionListHead *alias_print_queue)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
if (!mr) {
return;
}
for (i = 0; i < level; i++) {
mon_printf(f, MTREE_INDENT);
}
if (mr->alias) {
MemoryRegionList *ml;
bool found = false;
QTAILQ_FOREACH(ml, alias_print_queue, queue) {
if (ml->mr == mr->alias) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->mr = mr->alias;
QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %s): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
base + mr->addr,
base + mr->addr + MR_SIZE(mr->size),
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
memory_region_name(mr->alias),
mr->alias_offset,
mr->alias_offset + MR_SIZE(mr->size),
mr->enabled ? "" : " [disabled]");
} else {
mon_printf(f,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",
base + mr->addr,
base + mr->addr + MR_SIZE(mr->size),
mr->priority,
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
mr->enabled ? "" : " [disabled]");
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->mr = submr;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->mr->addr < ml->mr->addr ||
(new_ml->mr->addr == ml->mr->addr &&
new_ml->mr->priority > ml->mr->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
alias_print_queue);
}
QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {
g_free(ml);
}
}
| {
"code": [
" base + mr->addr,",
" base + mr->addr + MR_SIZE(mr->size),",
" base + mr->addr,",
" base + mr->addr + MR_SIZE(mr->size),",
" mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,"
],
"line_no": [
75,
77,
75,
77,
155
]
} | static void FUNC_0(fprintf_function VAR_0, void *VAR_1,
const MemoryRegion *VAR_2, unsigned int VAR_3,
hwaddr VAR_4,
MemoryRegionListHead *VAR_5)
{
MemoryRegionList *new_ml, *ml, *next_ml;
MemoryRegionListHead submr_print_queue;
const MemoryRegion *VAR_6;
unsigned int VAR_7;
if (!VAR_2) {
return;
}
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
VAR_0(VAR_1, MTREE_INDENT);
}
if (VAR_2->alias) {
MemoryRegionList *ml;
bool found = false;
QTAILQ_FOREACH(ml, VAR_5, queue) {
if (ml->VAR_2 == VAR_2->alias) {
found = true;
}
}
if (!found) {
ml = g_new(MemoryRegionList, 1);
ml->VAR_2 = VAR_2->alias;
QTAILQ_INSERT_TAIL(VAR_5, ml, queue);
}
VAR_0(VAR_1, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %s): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),
VAR_2->priority,
memory_region_type((MemoryRegion *)VAR_2),
memory_region_name(VAR_2),
memory_region_name(VAR_2->alias),
VAR_2->alias_offset,
VAR_2->alias_offset + MR_SIZE(VAR_2->size),
VAR_2->enabled ? "" : " [disabled]");
} else {
VAR_0(VAR_1,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),
VAR_2->priority,
memory_region_type((MemoryRegion *)VAR_2),
memory_region_name(VAR_2),
VAR_2->enabled ? "" : " [disabled]");
}
QTAILQ_INIT(&submr_print_queue);
QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) {
new_ml = g_new(MemoryRegionList, 1);
new_ml->VAR_2 = VAR_6;
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
if (new_ml->VAR_2->addr < ml->VAR_2->addr ||
(new_ml->VAR_2->addr == ml->VAR_2->addr &&
new_ml->VAR_2->priority > ml->VAR_2->priority)) {
QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
new_ml = NULL;
break;
}
}
if (new_ml) {
QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
}
}
QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,
VAR_5);
}
QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {
g_free(ml);
}
}
| [
"static void FUNC_0(fprintf_function VAR_0, void *VAR_1,\nconst MemoryRegion *VAR_2, unsigned int VAR_3,\nhwaddr VAR_4,\nMemoryRegionListHead *VAR_5)\n{",
"MemoryRegionList *new_ml, *ml, *next_ml;",
"MemoryRegionListHead submr_print_queue;",
"const MemoryRegion *VAR_6;",
"unsigned int VAR_7;",
"if (!VAR_2) {",
"return;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"VAR_0(VAR_1, MTREE_INDENT);",
"}",
"if (VAR_2->alias) {",
"MemoryRegionList *ml;",
"bool found = false;",
"QTAILQ_FOREACH(ml, VAR_5, queue) {",
"if (ml->VAR_2 == VAR_2->alias) {",
"found = true;",
"}",
"}",
"if (!found) {",
"ml = g_new(MemoryRegionList, 1);",
"ml->VAR_2 = VAR_2->alias;",
"QTAILQ_INSERT_TAIL(VAR_5, ml, queue);",
"}",
"VAR_0(VAR_1, TARGET_FMT_plx \"-\" TARGET_FMT_plx\n\" (prio %d, %s): alias %s @%s \" TARGET_FMT_plx\n\"-\" TARGET_FMT_plx \"%s\\n\",\nVAR_4 + VAR_2->addr,\nVAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),\nVAR_2->priority,\nmemory_region_type((MemoryRegion *)VAR_2),\nmemory_region_name(VAR_2),\nmemory_region_name(VAR_2->alias),\nVAR_2->alias_offset,\nVAR_2->alias_offset + MR_SIZE(VAR_2->size),\nVAR_2->enabled ? \"\" : \" [disabled]\");",
"} else {",
"VAR_0(VAR_1,\nTARGET_FMT_plx \"-\" TARGET_FMT_plx \" (prio %d, %s): %s%s\\n\",\nVAR_4 + VAR_2->addr,\nVAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),\nVAR_2->priority,\nmemory_region_type((MemoryRegion *)VAR_2),\nmemory_region_name(VAR_2),\nVAR_2->enabled ? \"\" : \" [disabled]\");",
"}",
"QTAILQ_INIT(&submr_print_queue);",
"QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) {",
"new_ml = g_new(MemoryRegionList, 1);",
"new_ml->VAR_2 = VAR_6;",
"QTAILQ_FOREACH(ml, &submr_print_queue, queue) {",
"if (new_ml->VAR_2->addr < ml->VAR_2->addr ||\n(new_ml->VAR_2->addr == ml->VAR_2->addr &&\nnew_ml->VAR_2->priority > ml->VAR_2->priority)) {",
"QTAILQ_INSERT_BEFORE(ml, new_ml, queue);",
"new_ml = NULL;",
"break;",
"}",
"}",
"if (new_ml) {",
"QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);",
"}",
"}",
"QTAILQ_FOREACH(ml, &submr_print_queue, queue) {",
"FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,\nVAR_5);",
"}",
"QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {",
"g_free(ml);",
"}",
"}"
] | [
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,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95,
97,
99,
101,
103,
105,
107,
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155,
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
]
] |
2,691 | static uint64_t bonito_cop_readl(void *opaque, hwaddr addr,
unsigned size)
{
uint32_t val;
PCIBonitoState *s = opaque;
val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)];
return val; | true | qemu | 58d479786b11a7e982419c1e0905b8490ef9a787 | static uint64_t bonito_cop_readl(void *opaque, hwaddr addr,
unsigned size)
{
uint32_t val;
PCIBonitoState *s = opaque;
val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)];
return val; | {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
uint32_t val;
PCIBonitoState *s = opaque;
val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)];
return val; | [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"uint32_t val;",
"PCIBonitoState *s = opaque;",
"val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)];",
"return val;"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
]
] |
2,692 | static int vmdk_snapshot_create(const char *filename, const char *backing_file)
{
int snp_fd, p_fd;
int ret;
uint32_t p_cid;
char *p_name, *gd_buf, *rgd_buf;
const char *real_filename, *temp_str;
VMDK4Header header;
uint32_t gde_entries, gd_size;
int64_t gd_offset, rgd_offset, capacity, gt_size;
char p_desc[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
static const char desc_template[] =
"# Disk DescriptorFile\n"
"version=1\n"
"CID=%x\n"
"parentCID=%x\n"
"createType=\"monolithicSparse\"\n"
"parentFileNameHint=\"%s\"\n"
"\n"
"# Extent description\n"
"RW %u SPARSE \"%s\"\n"
"\n"
"# The Disk Data Base \n"
"#DDB\n"
"\n";
snp_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
if (snp_fd < 0)
return -errno;
p_fd = open(backing_file, O_RDONLY | O_BINARY | O_LARGEFILE);
if (p_fd < 0) {
close(snp_fd);
return -errno;
}
/* read the header */
if (lseek(p_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, hdr, HEADER_SIZE) != HEADER_SIZE) {
ret = -errno;
goto fail;
}
/* write the header */
if (lseek(snp_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, hdr, HEADER_SIZE) == -1) {
ret = -errno;
goto fail;
}
memset(&header, 0, sizeof(header));
memcpy(&header,&hdr[4], sizeof(header)); // skip the VMDK4_MAGIC
if (ftruncate(snp_fd, header.grain_offset << 9)) {
ret = -errno;
goto fail;
}
/* the descriptor offset = 0x200 */
if (lseek(p_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE) {
ret = -errno;
goto fail;
}
if ((p_name = strstr(p_desc,"CID")) != NULL) {
p_name += sizeof("CID");
sscanf(p_name,"%x",&p_cid);
}
real_filename = filename;
if ((temp_str = strrchr(real_filename, '\\')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, '/')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, ':')) != NULL)
real_filename = temp_str + 1;
snprintf(s_desc, sizeof(s_desc), desc_template, p_cid, p_cid, backing_file,
(uint32_t)header.capacity, real_filename);
/* write the descriptor */
if (lseek(snp_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, s_desc, strlen(s_desc)) == -1) {
ret = -errno;
goto fail;
}
gd_offset = header.gd_offset * SECTOR_SIZE; // offset of GD table
rgd_offset = header.rgd_offset * SECTOR_SIZE; // offset of RGD table
capacity = header.capacity * SECTOR_SIZE; // Extent size
/*
* Each GDE span 32M disk, means:
* 512 GTE per GT, each GTE points to grain
*/
gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
if (!gt_size) {
ret = -EINVAL;
goto fail;
}
gde_entries = (uint32_t)(capacity / gt_size); // number of gde/rgde
gd_size = gde_entries * sizeof(uint32_t);
/* write RGD */
rgd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (read(p_fd, rgd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_rgd;
}
if (lseek(snp_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (write(snp_fd, rgd_buf, gd_size) == -1) {
ret = -errno;
goto fail_rgd;
}
qemu_free(rgd_buf);
/* write GD */
gd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (read(p_fd, gd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_gd;
}
if (lseek(snp_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (write(snp_fd, gd_buf, gd_size) == -1) {
ret = -errno;
goto fail_gd;
}
qemu_free(gd_buf);
close(p_fd);
close(snp_fd);
return 0;
fail_gd:
qemu_free(gd_buf);
fail_rgd:
qemu_free(rgd_buf);
fail:
close(p_fd);
close(snp_fd);
return ret;
}
| true | qemu | a161329b61106ab093aab6d3227ac85e0b8251a9 | static int vmdk_snapshot_create(const char *filename, const char *backing_file)
{
int snp_fd, p_fd;
int ret;
uint32_t p_cid;
char *p_name, *gd_buf, *rgd_buf;
const char *real_filename, *temp_str;
VMDK4Header header;
uint32_t gde_entries, gd_size;
int64_t gd_offset, rgd_offset, capacity, gt_size;
char p_desc[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
static const char desc_template[] =
"# Disk DescriptorFile\n"
"version=1\n"
"CID=%x\n"
"parentCID=%x\n"
"createType=\"monolithicSparse\"\n"
"parentFileNameHint=\"%s\"\n"
"\n"
"# Extent description\n"
"RW %u SPARSE \"%s\"\n"
"\n"
"# The Disk Data Base \n"
"#DDB\n"
"\n";
snp_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
if (snp_fd < 0)
return -errno;
p_fd = open(backing_file, O_RDONLY | O_BINARY | O_LARGEFILE);
if (p_fd < 0) {
close(snp_fd);
return -errno;
}
if (lseek(p_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, hdr, HEADER_SIZE) != HEADER_SIZE) {
ret = -errno;
goto fail;
}
if (lseek(snp_fd, 0x0, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, hdr, HEADER_SIZE) == -1) {
ret = -errno;
goto fail;
}
memset(&header, 0, sizeof(header));
memcpy(&header,&hdr[4], sizeof(header));
if (ftruncate(snp_fd, header.grain_offset << 9)) {
ret = -errno;
goto fail;
}
if (lseek(p_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE) {
ret = -errno;
goto fail;
}
if ((p_name = strstr(p_desc,"CID")) != NULL) {
p_name += sizeof("CID");
sscanf(p_name,"%x",&p_cid);
}
real_filename = filename;
if ((temp_str = strrchr(real_filename, '\\')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, '/')) != NULL)
real_filename = temp_str + 1;
if ((temp_str = strrchr(real_filename, ':')) != NULL)
real_filename = temp_str + 1;
snprintf(s_desc, sizeof(s_desc), desc_template, p_cid, p_cid, backing_file,
(uint32_t)header.capacity, real_filename);
if (lseek(snp_fd, 0x200, SEEK_SET) == -1) {
ret = -errno;
goto fail;
}
if (write(snp_fd, s_desc, strlen(s_desc)) == -1) {
ret = -errno;
goto fail;
}
gd_offset = header.gd_offset * SECTOR_SIZE;
rgd_offset = header.rgd_offset * SECTOR_SIZE;
capacity = header.capacity * SECTOR_SIZE;
gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
if (!gt_size) {
ret = -EINVAL;
goto fail;
}
gde_entries = (uint32_t)(capacity / gt_size);
gd_size = gde_entries * sizeof(uint32_t);
rgd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (read(p_fd, rgd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_rgd;
}
if (lseek(snp_fd, rgd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_rgd;
}
if (write(snp_fd, rgd_buf, gd_size) == -1) {
ret = -errno;
goto fail_rgd;
}
qemu_free(rgd_buf);
gd_buf = qemu_malloc(gd_size);
if (lseek(p_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (read(p_fd, gd_buf, gd_size) != gd_size) {
ret = -errno;
goto fail_gd;
}
if (lseek(snp_fd, gd_offset, SEEK_SET) == -1) {
ret = -errno;
goto fail_gd;
}
if (write(snp_fd, gd_buf, gd_size) == -1) {
ret = -errno;
goto fail_gd;
}
qemu_free(gd_buf);
close(p_fd);
close(snp_fd);
return 0;
fail_gd:
qemu_free(gd_buf);
fail_rgd:
qemu_free(rgd_buf);
fail:
close(p_fd);
close(snp_fd);
return ret;
}
| {
"code": [
" qemu_free(rgd_buf);"
],
"line_no": [
263
]
} | static int FUNC_0(const char *VAR_0, const char *VAR_1)
{
int VAR_2, VAR_3;
int VAR_4;
uint32_t p_cid;
char *VAR_5, *VAR_6, *VAR_7;
const char *VAR_8, *VAR_9;
VMDK4Header header;
uint32_t gde_entries, gd_size;
int64_t gd_offset, rgd_offset, capacity, gt_size;
char VAR_10[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
static const char VAR_11[] =
"# Disk DescriptorFile\n"
"version=1\n"
"CID=%x\n"
"parentCID=%x\n"
"createType=\"monolithicSparse\"\n"
"parentFileNameHint=\"%s\"\n"
"\n"
"# Extent description\n"
"RW %u SPARSE \"%s\"\n"
"\n"
"# The Disk Data Base \n"
"#DDB\n"
"\n";
VAR_2 = open(VAR_0, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
if (VAR_2 < 0)
return -errno;
VAR_3 = open(VAR_1, O_RDONLY | O_BINARY | O_LARGEFILE);
if (VAR_3 < 0) {
close(VAR_2);
return -errno;
}
if (lseek(VAR_3, 0x0, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail;
}
if (read(VAR_3, hdr, HEADER_SIZE) != HEADER_SIZE) {
VAR_4 = -errno;
goto fail;
}
if (lseek(VAR_2, 0x0, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail;
}
if (write(VAR_2, hdr, HEADER_SIZE) == -1) {
VAR_4 = -errno;
goto fail;
}
memset(&header, 0, sizeof(header));
memcpy(&header,&hdr[4], sizeof(header));
if (ftruncate(VAR_2, header.grain_offset << 9)) {
VAR_4 = -errno;
goto fail;
}
if (lseek(VAR_3, 0x200, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail;
}
if (read(VAR_3, VAR_10, DESC_SIZE) != DESC_SIZE) {
VAR_4 = -errno;
goto fail;
}
if ((VAR_5 = strstr(VAR_10,"CID")) != NULL) {
VAR_5 += sizeof("CID");
sscanf(VAR_5,"%x",&p_cid);
}
VAR_8 = VAR_0;
if ((VAR_9 = strrchr(VAR_8, '\\')) != NULL)
VAR_8 = VAR_9 + 1;
if ((VAR_9 = strrchr(VAR_8, '/')) != NULL)
VAR_8 = VAR_9 + 1;
if ((VAR_9 = strrchr(VAR_8, ':')) != NULL)
VAR_8 = VAR_9 + 1;
snprintf(s_desc, sizeof(s_desc), VAR_11, p_cid, p_cid, VAR_1,
(uint32_t)header.capacity, VAR_8);
if (lseek(VAR_2, 0x200, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail;
}
if (write(VAR_2, s_desc, strlen(s_desc)) == -1) {
VAR_4 = -errno;
goto fail;
}
gd_offset = header.gd_offset * SECTOR_SIZE;
rgd_offset = header.rgd_offset * SECTOR_SIZE;
capacity = header.capacity * SECTOR_SIZE;
gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
if (!gt_size) {
VAR_4 = -EINVAL;
goto fail;
}
gde_entries = (uint32_t)(capacity / gt_size);
gd_size = gde_entries * sizeof(uint32_t);
VAR_7 = qemu_malloc(gd_size);
if (lseek(VAR_3, rgd_offset, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail_rgd;
}
if (read(VAR_3, VAR_7, gd_size) != gd_size) {
VAR_4 = -errno;
goto fail_rgd;
}
if (lseek(VAR_2, rgd_offset, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail_rgd;
}
if (write(VAR_2, VAR_7, gd_size) == -1) {
VAR_4 = -errno;
goto fail_rgd;
}
qemu_free(VAR_7);
VAR_6 = qemu_malloc(gd_size);
if (lseek(VAR_3, gd_offset, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail_gd;
}
if (read(VAR_3, VAR_6, gd_size) != gd_size) {
VAR_4 = -errno;
goto fail_gd;
}
if (lseek(VAR_2, gd_offset, SEEK_SET) == -1) {
VAR_4 = -errno;
goto fail_gd;
}
if (write(VAR_2, VAR_6, gd_size) == -1) {
VAR_4 = -errno;
goto fail_gd;
}
qemu_free(VAR_6);
close(VAR_3);
close(VAR_2);
return 0;
fail_gd:
qemu_free(VAR_6);
fail_rgd:
qemu_free(VAR_7);
fail:
close(VAR_3);
close(VAR_2);
return VAR_4;
}
| [
"static int FUNC_0(const char *VAR_0, const char *VAR_1)\n{",
"int VAR_2, VAR_3;",
"int VAR_4;",
"uint32_t p_cid;",
"char *VAR_5, *VAR_6, *VAR_7;",
"const char *VAR_8, *VAR_9;",
"VMDK4Header header;",
"uint32_t gde_entries, gd_size;",
"int64_t gd_offset, rgd_offset, capacity, gt_size;",
"char VAR_10[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];",
"static const char VAR_11[] =\n\"# Disk DescriptorFile\\n\"\n\"version=1\\n\"\n\"CID=%x\\n\"\n\"parentCID=%x\\n\"\n\"createType=\\\"monolithicSparse\\\"\\n\"\n\"parentFileNameHint=\\\"%s\\\"\\n\"\n\"\\n\"\n\"# Extent description\\n\"\n\"RW %u SPARSE \\\"%s\\\"\\n\"\n\"\\n\"\n\"# The Disk Data Base \\n\"\n\"#DDB\\n\"\n\"\\n\";",
"VAR_2 = open(VAR_0, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);",
"if (VAR_2 < 0)\nreturn -errno;",
"VAR_3 = open(VAR_1, O_RDONLY | O_BINARY | O_LARGEFILE);",
"if (VAR_3 < 0) {",
"close(VAR_2);",
"return -errno;",
"}",
"if (lseek(VAR_3, 0x0, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (read(VAR_3, hdr, HEADER_SIZE) != HEADER_SIZE) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (lseek(VAR_2, 0x0, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (write(VAR_2, hdr, HEADER_SIZE) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"memset(&header, 0, sizeof(header));",
"memcpy(&header,&hdr[4], sizeof(header));",
"if (ftruncate(VAR_2, header.grain_offset << 9)) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (lseek(VAR_3, 0x200, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (read(VAR_3, VAR_10, DESC_SIZE) != DESC_SIZE) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if ((VAR_5 = strstr(VAR_10,\"CID\")) != NULL) {",
"VAR_5 += sizeof(\"CID\");",
"sscanf(VAR_5,\"%x\",&p_cid);",
"}",
"VAR_8 = VAR_0;",
"if ((VAR_9 = strrchr(VAR_8, '\\\\')) != NULL)\nVAR_8 = VAR_9 + 1;",
"if ((VAR_9 = strrchr(VAR_8, '/')) != NULL)\nVAR_8 = VAR_9 + 1;",
"if ((VAR_9 = strrchr(VAR_8, ':')) != NULL)\nVAR_8 = VAR_9 + 1;",
"snprintf(s_desc, sizeof(s_desc), VAR_11, p_cid, p_cid, VAR_1,\n(uint32_t)header.capacity, VAR_8);",
"if (lseek(VAR_2, 0x200, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"if (write(VAR_2, s_desc, strlen(s_desc)) == -1) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"gd_offset = header.gd_offset * SECTOR_SIZE;",
"rgd_offset = header.rgd_offset * SECTOR_SIZE;",
"capacity = header.capacity * SECTOR_SIZE;",
"gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;",
"if (!gt_size) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"gde_entries = (uint32_t)(capacity / gt_size);",
"gd_size = gde_entries * sizeof(uint32_t);",
"VAR_7 = qemu_malloc(gd_size);",
"if (lseek(VAR_3, rgd_offset, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail_rgd;",
"}",
"if (read(VAR_3, VAR_7, gd_size) != gd_size) {",
"VAR_4 = -errno;",
"goto fail_rgd;",
"}",
"if (lseek(VAR_2, rgd_offset, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail_rgd;",
"}",
"if (write(VAR_2, VAR_7, gd_size) == -1) {",
"VAR_4 = -errno;",
"goto fail_rgd;",
"}",
"qemu_free(VAR_7);",
"VAR_6 = qemu_malloc(gd_size);",
"if (lseek(VAR_3, gd_offset, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail_gd;",
"}",
"if (read(VAR_3, VAR_6, gd_size) != gd_size) {",
"VAR_4 = -errno;",
"goto fail_gd;",
"}",
"if (lseek(VAR_2, gd_offset, SEEK_SET) == -1) {",
"VAR_4 = -errno;",
"goto fail_gd;",
"}",
"if (write(VAR_2, VAR_6, gd_size) == -1) {",
"VAR_4 = -errno;",
"goto fail_gd;",
"}",
"qemu_free(VAR_6);",
"close(VAR_3);",
"close(VAR_2);",
"return 0;",
"fail_gd:\nqemu_free(VAR_6);",
"fail_rgd:\nqemu_free(VAR_7);",
"fail:\nclose(VAR_3);",
"close(VAR_2);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157,
159
],
[
161,
163
],
[
165,
167
],
[
171,
173
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
315,
317
],
[
319,
321
],
[
323,
325
],
[
327
],
[
329
],
[
331
]
] |
2,693 | static void piix3_ide_xen_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = pci_piix_ide_initfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
dc->unplug = pci_piix3_xen_ide_unplug;
}
| true | qemu | efec3dd631d94160288392721a5f9c39e50fb2bc | static void piix3_ide_xen_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = pci_piix_ide_initfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
dc->unplug = pci_piix3_xen_ide_unplug;
}
| {
"code": [
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;",
" dc->no_user = 1;"
],
"line_no": [
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);
k->init = pci_piix_ide_initfn;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
k->class_id = PCI_CLASS_STORAGE_IDE;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
dc->no_user = 1;
dc->unplug = pci_piix3_xen_ide_unplug;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);",
"k->init = pci_piix_ide_initfn;",
"k->vendor_id = PCI_VENDOR_ID_INTEL;",
"k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;",
"k->class_id = PCI_CLASS_STORAGE_IDE;",
"set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);",
"dc->no_user = 1;",
"dc->unplug = pci_piix3_xen_ide_unplug;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
2,694 | static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
{
SAMIContext *sami = avctx->priv_data;
int ret = 0;
char *tag = NULL;
char *dupsrc = av_strdup(src);
char *p = dupsrc;
AVBPrint *dst_content = &sami->encoded_content;
AVBPrint *dst_source = &sami->encoded_source;
av_bprint_clear(&sami->encoded_content);
av_bprint_clear(&sami->content);
av_bprint_clear(&sami->encoded_source);
for (;;) {
char *saveptr = NULL;
int prev_chr_is_space = 0;
AVBPrint *dst = &sami->content;
/* parse & extract paragraph tag */
p = av_stristr(p, "<P");
if (!p)
break;
if (p[2] != '>' && !av_isspace(p[2])) { // avoid confusion with tags such as <PRE>
p++;
continue;
}
if (dst->len) // add a separator with the previous paragraph if there was one
av_bprintf(dst, "\\N");
tag = av_strtok(p, ">", &saveptr);
if (!tag || !saveptr)
break;
p = saveptr;
/* check if the current paragraph is the "source" (speaker name) */
if (av_stristr(tag, "ID=Source") || av_stristr(tag, "ID=\"Source\"")) {
dst = &sami->source;
av_bprint_clear(dst);
}
/* if empty event -> skip subtitle */
while (av_isspace(*p))
p++;
if (!strncmp(p, " ", 6)) {
ret = -1;
goto end;
}
/* extract the text, stripping most of the tags */
while (*p) {
if (*p == '<') {
if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2])))
break;
}
if (!av_strncasecmp(p, "<BR", 3)) {
av_bprintf(dst, "\\N");
p++;
while (*p && *p != '>')
p++;
if (!*p)
break;
if (*p == '>')
p++;
continue;
}
if (!av_isspace(*p))
av_bprint_chars(dst, *p, 1);
else if (!prev_chr_is_space)
av_bprint_chars(dst, ' ', 1);
prev_chr_is_space = av_isspace(*p);
p++;
}
}
av_bprint_clear(&sami->full);
if (sami->source.len) {
ret = ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str);
}
ret = ff_htmlmarkup_to_ass(avctx, dst_content, sami->content.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "%s", sami->encoded_content.str);
end:
av_free(dupsrc);
return ret;
} | true | FFmpeg | 61bbc537ab2305392bd170a6f404ed6402bee4a8 | static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
{
SAMIContext *sami = avctx->priv_data;
int ret = 0;
char *tag = NULL;
char *dupsrc = av_strdup(src);
char *p = dupsrc;
AVBPrint *dst_content = &sami->encoded_content;
AVBPrint *dst_source = &sami->encoded_source;
av_bprint_clear(&sami->encoded_content);
av_bprint_clear(&sami->content);
av_bprint_clear(&sami->encoded_source);
for (;;) {
char *saveptr = NULL;
int prev_chr_is_space = 0;
AVBPrint *dst = &sami->content;
p = av_stristr(p, "<P");
if (!p)
break;
if (p[2] != '>' && !av_isspace(p[2])) {
p++;
continue;
}
if (dst->len)
av_bprintf(dst, "\\N");
tag = av_strtok(p, ">", &saveptr);
if (!tag || !saveptr)
break;
p = saveptr;
if (av_stristr(tag, "ID=Source") || av_stristr(tag, "ID=\"Source\"")) {
dst = &sami->source;
av_bprint_clear(dst);
}
while (av_isspace(*p))
p++;
if (!strncmp(p, " ", 6)) {
ret = -1;
goto end;
}
while (*p) {
if (*p == '<') {
if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2])))
break;
}
if (!av_strncasecmp(p, "<BR", 3)) {
av_bprintf(dst, "\\N");
p++;
while (*p && *p != '>')
p++;
if (!*p)
break;
if (*p == '>')
p++;
continue;
}
if (!av_isspace(*p))
av_bprint_chars(dst, *p, 1);
else if (!prev_chr_is_space)
av_bprint_chars(dst, ' ', 1);
prev_chr_is_space = av_isspace(*p);
p++;
}
}
av_bprint_clear(&sami->full);
if (sami->source.len) {
ret = ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str);
}
ret = ff_htmlmarkup_to_ass(avctx, dst_content, sami->content.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "%s", sami->encoded_content.str);
end:
av_free(dupsrc);
return ret;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, const char *VAR_1)
{
SAMIContext *sami = VAR_0->priv_data;
int VAR_2 = 0;
char *VAR_3 = NULL;
char *VAR_4 = av_strdup(VAR_1);
char *VAR_5 = VAR_4;
AVBPrint *dst_content = &sami->encoded_content;
AVBPrint *dst_source = &sami->encoded_source;
av_bprint_clear(&sami->encoded_content);
av_bprint_clear(&sami->content);
av_bprint_clear(&sami->encoded_source);
for (;;) {
char *VAR_6 = NULL;
int VAR_7 = 0;
AVBPrint *dst = &sami->content;
VAR_5 = av_stristr(VAR_5, "<P");
if (!VAR_5)
break;
if (VAR_5[2] != '>' && !av_isspace(VAR_5[2])) {
VAR_5++;
continue;
}
if (dst->len)
av_bprintf(dst, "\\N");
VAR_3 = av_strtok(VAR_5, ">", &VAR_6);
if (!VAR_3 || !VAR_6)
break;
VAR_5 = VAR_6;
if (av_stristr(VAR_3, "ID=Source") || av_stristr(VAR_3, "ID=\"Source\"")) {
dst = &sami->source;
av_bprint_clear(dst);
}
while (av_isspace(*VAR_5))
VAR_5++;
if (!strncmp(VAR_5, " ", 6)) {
VAR_2 = -1;
goto end;
}
while (*VAR_5) {
if (*VAR_5 == '<') {
if (!av_strncasecmp(VAR_5, "<P", 2) && (VAR_5[2] == '>' || av_isspace(VAR_5[2])))
break;
}
if (!av_strncasecmp(VAR_5, "<BR", 3)) {
av_bprintf(dst, "\\N");
VAR_5++;
while (*VAR_5 && *VAR_5 != '>')
VAR_5++;
if (!*VAR_5)
break;
if (*VAR_5 == '>')
VAR_5++;
continue;
}
if (!av_isspace(*VAR_5))
av_bprint_chars(dst, *VAR_5, 1);
else if (!VAR_7)
av_bprint_chars(dst, ' ', 1);
VAR_7 = av_isspace(*VAR_5);
VAR_5++;
}
}
av_bprint_clear(&sami->full);
if (sami->source.len) {
VAR_2 = ff_htmlmarkup_to_ass(VAR_0, dst_source, sami->source.str);
if (VAR_2 < 0)
goto end;
av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str);
}
VAR_2 = ff_htmlmarkup_to_ass(VAR_0, dst_content, sami->content.str);
if (VAR_2 < 0)
goto end;
av_bprintf(&sami->full, "%s", sami->encoded_content.str);
end:
av_free(VAR_4);
return VAR_2;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, const char *VAR_1)\n{",
"SAMIContext *sami = VAR_0->priv_data;",
"int VAR_2 = 0;",
"char *VAR_3 = NULL;",
"char *VAR_4 = av_strdup(VAR_1);",
"char *VAR_5 = VAR_4;",
"AVBPrint *dst_content = &sami->encoded_content;",
"AVBPrint *dst_source = &sami->encoded_source;",
"av_bprint_clear(&sami->encoded_content);",
"av_bprint_clear(&sami->content);",
"av_bprint_clear(&sami->encoded_source);",
"for (;;) {",
"char *VAR_6 = NULL;",
"int VAR_7 = 0;",
"AVBPrint *dst = &sami->content;",
"VAR_5 = av_stristr(VAR_5, \"<P\");",
"if (!VAR_5)\nbreak;",
"if (VAR_5[2] != '>' && !av_isspace(VAR_5[2])) {",
"VAR_5++;",
"continue;",
"}",
"if (dst->len)\nav_bprintf(dst, \"\\\\N\");",
"VAR_3 = av_strtok(VAR_5, \">\", &VAR_6);",
"if (!VAR_3 || !VAR_6)\nbreak;",
"VAR_5 = VAR_6;",
"if (av_stristr(VAR_3, \"ID=Source\") || av_stristr(VAR_3, \"ID=\\\"Source\\\"\")) {",
"dst = &sami->source;",
"av_bprint_clear(dst);",
"}",
"while (av_isspace(*VAR_5))\nVAR_5++;",
"if (!strncmp(VAR_5, \" \", 6)) {",
"VAR_2 = -1;",
"goto end;",
"}",
"while (*VAR_5) {",
"if (*VAR_5 == '<') {",
"if (!av_strncasecmp(VAR_5, \"<P\", 2) && (VAR_5[2] == '>' || av_isspace(VAR_5[2])))\nbreak;",
"}",
"if (!av_strncasecmp(VAR_5, \"<BR\", 3)) {",
"av_bprintf(dst, \"\\\\N\");",
"VAR_5++;",
"while (*VAR_5 && *VAR_5 != '>')\nVAR_5++;",
"if (!*VAR_5)\nbreak;",
"if (*VAR_5 == '>')\nVAR_5++;",
"continue;",
"}",
"if (!av_isspace(*VAR_5))\nav_bprint_chars(dst, *VAR_5, 1);",
"else if (!VAR_7)\nav_bprint_chars(dst, ' ', 1);",
"VAR_7 = av_isspace(*VAR_5);",
"VAR_5++;",
"}",
"}",
"av_bprint_clear(&sami->full);",
"if (sami->source.len) {",
"VAR_2 = ff_htmlmarkup_to_ass(VAR_0, dst_source, sami->source.str);",
"if (VAR_2 < 0)\ngoto end;",
"av_bprintf(&sami->full, \"{\\\\i1}%s{\\\\i0}\\\\N\", sami->encoded_source.str);",
"}",
"VAR_2 = ff_htmlmarkup_to_ass(VAR_0, dst_content, sami->content.str);",
"if (VAR_2 < 0)\ngoto end;",
"av_bprintf(&sami->full, \"%s\", sami->encoded_content.str);",
"end:\nav_free(VAR_4);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
18
],
[
19,
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25,
26
],
[
27
],
[
28,
29
],
[
30
],
[
32
],
[
33
],
[
34
],
[
35
],
[
37,
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
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
],
[
75
],
[
76,
77
],
[
78
],
[
79,
80
],
[
81
],
[
82
]
] |
2,695 | static void reset_codec(WmallDecodeCtx *s)
{
int ich, ilms;
s->mclms_recent = s->mclms_order * s->num_channels;
for (ich = 0; ich < s->num_channels; ich++) {
for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++)
s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
/* first sample of a seekable subframe is considered as the starting of
a transient area which is samples_per_frame samples long */
s->channel[ich].transient_counter = s->samples_per_frame;
s->transient[ich] = 1;
}
}
| true | FFmpeg | be8a0d26dbeec72b8e254e00724f170c28644c98 | static void reset_codec(WmallDecodeCtx *s)
{
int ich, ilms;
s->mclms_recent = s->mclms_order * s->num_channels;
for (ich = 0; ich < s->num_channels; ich++) {
for (ilms = 0; ilms < s->cdlms_ttl[ich]; ilms++)
s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;
s->channel[ich].transient_counter = s->samples_per_frame;
s->transient[ich] = 1;
}
}
| {
"code": [
" s->cdlms[ich][ilms].recent = s->cdlms[ich][ilms].order;"
],
"line_no": [
13
]
} | static void FUNC_0(WmallDecodeCtx *VAR_0)
{
int VAR_1, VAR_2;
VAR_0->mclms_recent = VAR_0->mclms_order * VAR_0->num_channels;
for (VAR_1 = 0; VAR_1 < VAR_0->num_channels; VAR_1++) {
for (VAR_2 = 0; VAR_2 < VAR_0->cdlms_ttl[VAR_1]; VAR_2++)
VAR_0->cdlms[VAR_1][VAR_2].recent = VAR_0->cdlms[VAR_1][VAR_2].order;
VAR_0->channel[VAR_1].transient_counter = VAR_0->samples_per_frame;
VAR_0->transient[VAR_1] = 1;
}
}
| [
"static void FUNC_0(WmallDecodeCtx *VAR_0)\n{",
"int VAR_1, VAR_2;",
"VAR_0->mclms_recent = VAR_0->mclms_order * VAR_0->num_channels;",
"for (VAR_1 = 0; VAR_1 < VAR_0->num_channels; VAR_1++) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->cdlms_ttl[VAR_1]; VAR_2++)",
"VAR_0->cdlms[VAR_1][VAR_2].recent = VAR_0->cdlms[VAR_1][VAR_2].order;",
"VAR_0->channel[VAR_1].transient_counter = VAR_0->samples_per_frame;",
"VAR_0->transient[VAR_1] = 1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
2,696 | static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid, int read) {
AVCodecContext *vcodec = vstream->codec;
switch(flv_codecid) {
case FLV_CODECID_H263 : vcodec->codec_id = AV_CODEC_ID_FLV1 ; break;
case FLV_CODECID_SCREEN: vcodec->codec_id = AV_CODEC_ID_FLASHSV; break;
case FLV_CODECID_SCREEN2: vcodec->codec_id = AV_CODEC_ID_FLASHSV2; break;
case FLV_CODECID_VP6 : vcodec->codec_id = AV_CODEC_ID_VP6F ;
case FLV_CODECID_VP6A :
if(flv_codecid == FLV_CODECID_VP6A)
vcodec->codec_id = AV_CODEC_ID_VP6A;
if (read) {
if (vcodec->extradata_size != 1) {
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
vcodec->extradata[0] = avio_r8(s->pb);
}
return 1; // 1 byte body size adjustment for flv_read_packet()
case FLV_CODECID_H264:
vcodec->codec_id = AV_CODEC_ID_H264;
return 3; // not 4, reading packet type will consume one byte
default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
vcodec->codec_tag = flv_codecid;
}
return 0;
}
| true | FFmpeg | c5a738ca4e9789b4678b10240777d931e7dc24c9 | static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid, int read) {
AVCodecContext *vcodec = vstream->codec;
switch(flv_codecid) {
case FLV_CODECID_H263 : vcodec->codec_id = AV_CODEC_ID_FLV1 ; break;
case FLV_CODECID_SCREEN: vcodec->codec_id = AV_CODEC_ID_FLASHSV; break;
case FLV_CODECID_SCREEN2: vcodec->codec_id = AV_CODEC_ID_FLASHSV2; break;
case FLV_CODECID_VP6 : vcodec->codec_id = AV_CODEC_ID_VP6F ;
case FLV_CODECID_VP6A :
if(flv_codecid == FLV_CODECID_VP6A)
vcodec->codec_id = AV_CODEC_ID_VP6A;
if (read) {
if (vcodec->extradata_size != 1) {
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
vcodec->extradata[0] = avio_r8(s->pb);
}
return 1;
case FLV_CODECID_H264:
vcodec->codec_id = AV_CODEC_ID_H264;
return 3;
default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
vcodec->codec_tag = flv_codecid;
}
return 0;
}
| {
"code": [
" vcodec->extradata_size = 1;",
" vcodec->extradata[0] = avio_r8(s->pb);"
],
"line_no": [
25,
31
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int VAR_2, int VAR_3) {
AVCodecContext *vcodec = VAR_1->codec;
switch(VAR_2) {
case FLV_CODECID_H263 : vcodec->codec_id = AV_CODEC_ID_FLV1 ; break;
case FLV_CODECID_SCREEN: vcodec->codec_id = AV_CODEC_ID_FLASHSV; break;
case FLV_CODECID_SCREEN2: vcodec->codec_id = AV_CODEC_ID_FLASHSV2; break;
case FLV_CODECID_VP6 : vcodec->codec_id = AV_CODEC_ID_VP6F ;
case FLV_CODECID_VP6A :
if(VAR_2 == FLV_CODECID_VP6A)
vcodec->codec_id = AV_CODEC_ID_VP6A;
if (VAR_3) {
if (vcodec->extradata_size != 1) {
vcodec->extradata_size = 1;
vcodec->extradata = av_malloc(1);
}
vcodec->extradata[0] = avio_r8(VAR_0->pb);
}
return 1;
case FLV_CODECID_H264:
vcodec->codec_id = AV_CODEC_ID_H264;
return 3;
default:
av_log(VAR_0, AV_LOG_INFO, "Unsupported video codec (%x)\n", VAR_2);
vcodec->codec_tag = VAR_2;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, int VAR_2, int VAR_3) {",
"AVCodecContext *vcodec = VAR_1->codec;",
"switch(VAR_2) {",
"case FLV_CODECID_H263 : vcodec->codec_id = AV_CODEC_ID_FLV1 ; break;",
"case FLV_CODECID_SCREEN: vcodec->codec_id = AV_CODEC_ID_FLASHSV; break;",
"case FLV_CODECID_SCREEN2: vcodec->codec_id = AV_CODEC_ID_FLASHSV2; break;",
"case FLV_CODECID_VP6 : vcodec->codec_id = AV_CODEC_ID_VP6F ;",
"case FLV_CODECID_VP6A :\nif(VAR_2 == FLV_CODECID_VP6A)\nvcodec->codec_id = AV_CODEC_ID_VP6A;",
"if (VAR_3) {",
"if (vcodec->extradata_size != 1) {",
"vcodec->extradata_size = 1;",
"vcodec->extradata = av_malloc(1);",
"}",
"vcodec->extradata[0] = avio_r8(VAR_0->pb);",
"}",
"return 1;",
"case FLV_CODECID_H264:\nvcodec->codec_id = AV_CODEC_ID_H264;",
"return 3;",
"default:\nav_log(VAR_0, AV_LOG_INFO, \"Unsupported video codec (%x)\\n\", VAR_2);",
"vcodec->codec_tag = VAR_2;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
2,697 | float64 float64_scalbn( float64 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint64_t aSig;
a = float64_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
return a;
}
if ( aExp != 0 )
aSig |= LIT64( 0x0010000000000000 );
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 10;
return normalizeRoundAndPackFloat64( aSign, aExp, aSig STATUS_VAR );
}
| true | qemu | 326b9e98a391d542cc33c4c91782ff4ba51edfc5 | float64 float64_scalbn( float64 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint64_t aSig;
a = float64_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
return a;
}
if ( aExp != 0 )
aSig |= LIT64( 0x0010000000000000 );
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 10;
return normalizeRoundAndPackFloat64( aSign, aExp, aSig STATUS_VAR );
}
| {
"code": [
" int16 aExp;",
" int16 aExp;",
" int16 aExp;",
" if ( aExp == 0x7FF ) {"
],
"line_no": [
7,
7,
7,
23
]
} | float64 FUNC_0( float64 a, int n STATUS_PARAM )
{
flag aSign;
int16 aExp;
uint64_t aSig;
a = float64_squash_input_denormal(a STATUS_VAR);
aSig = extractFloat64Frac( a );
aExp = extractFloat64Exp( a );
aSign = extractFloat64Sign( a );
if ( aExp == 0x7FF ) {
return a;
}
if ( aExp != 0 )
aSig |= LIT64( 0x0010000000000000 );
else if ( aSig == 0 )
return a;
aExp += n - 1;
aSig <<= 10;
return normalizeRoundAndPackFloat64( aSign, aExp, aSig STATUS_VAR );
}
| [
"float64 FUNC_0( float64 a, int n STATUS_PARAM )\n{",
"flag aSign;",
"int16 aExp;",
"uint64_t aSig;",
"a = float64_squash_input_denormal(a STATUS_VAR);",
"aSig = extractFloat64Frac( a );",
"aExp = extractFloat64Exp( a );",
"aSign = extractFloat64Sign( a );",
"if ( aExp == 0x7FF ) {",
"return a;",
"}",
"if ( aExp != 0 )\naSig |= LIT64( 0x0010000000000000 );",
"else if ( aSig == 0 )\nreturn a;",
"aExp += n - 1;",
"aSig <<= 10;",
"return normalizeRoundAndPackFloat64( aSign, aExp, aSig STATUS_VAR );",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
2,698 | static int postcopy_start(MigrationState *ms, bool *old_vm_running)
{
int ret;
QIOChannelBuffer *bioc;
QEMUFile *fb;
int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
bool restart_block = false;
int cur_state = MIGRATION_STATUS_ACTIVE;
if (!migrate_pause_before_switchover()) {
migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
trace_postcopy_start();
qemu_mutex_lock_iothread();
trace_postcopy_start_set_run();
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*old_vm_running = runstate_is_running();
global_state_store();
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (ret < 0) {
goto fail;
}
ret = migration_maybe_pause(ms, &cur_state,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
if (ret < 0) {
goto fail;
}
ret = bdrv_inactivate_all();
if (ret < 0) {
goto fail;
}
restart_block = true;
/*
* Cause any non-postcopiable, but iterative devices to
* send out their final data.
*/
qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
/*
* in Finish migrate and with the io-lock held everything should
* be quiet, but we've potentially still got dirty pages and we
* need to tell the destination to throw any pages it's already received
* that are dirty
*/
if (migrate_postcopy_ram()) {
if (ram_postcopy_send_discard_bitmap(ms)) {
error_report("postcopy send discard bitmap failed");
goto fail;
}
}
/*
* send rest of state - note things that are doing postcopy
* will notice we're in POSTCOPY_ACTIVE and not actually
* wrap their state up here
*/
qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX);
if (migrate_postcopy_ram()) {
/* Ping just for debugging, helps line traces up */
qemu_savevm_send_ping(ms->to_dst_file, 2);
}
/*
* While loading the device state we may trigger page transfer
* requests and the fd must be free to process those, and thus
* the destination must read the whole device state off the fd before
* it starts processing it. Unfortunately the ad-hoc migration format
* doesn't allow the destination to know the size to read without fully
* parsing it through each devices load-state code (especially the open
* coded devices that use get/put).
* So we wrap the device state up in a package with a length at the start;
* to do this we use a qemu_buf to hold the whole of the device state.
*/
bioc = qio_channel_buffer_new(4096);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
/*
* Make sure the receiver can get incoming pages before we send the rest
* of the state
*/
qemu_savevm_send_postcopy_listen(fb);
qemu_savevm_state_complete_precopy(fb, false, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
qemu_savevm_send_postcopy_run(fb);
/* <><> end of stuff going into the package */
/* Last point of recovery; as soon as we send the package the destination
* can open devices and potentially start running.
* Lets just check again we've not got any errors.
*/
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored (pre package)");
goto fail_closefb;
}
restart_block = false;
/* Now send that blob */
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
goto fail_closefb;
}
qemu_fclose(fb);
/* Send a notify to give a chance for anything that needs to happen
* at the transition to postcopy and after the device state; in particular
* spice needs to trigger a transition now
*/
ms->postcopy_after_devices = true;
notifier_list_notify(&migration_state_notifiers, ms);
ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
qemu_mutex_unlock_iothread();
if (migrate_postcopy_ram()) {
/*
* Although this ping is just for debug, it could potentially be
* used for getting a better measurement of downtime at the source.
*/
qemu_savevm_send_ping(ms->to_dst_file, 4);
}
if (migrate_release_ram()) {
ram_postcopy_migrated_memory_release(ms);
}
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored");
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
}
return ret;
fail_closefb:
qemu_fclose(fb);
fail:
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
if (restart_block) {
/* A failure happened early enough that we know the destination hasn't
* accessed block devices, so we're safe to recover.
*/
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
qemu_mutex_unlock_iothread();
return -1;
}
| true | qemu | 7287cbd46e2d6fb582ca78c3cb49b1e53d91a761 | static int postcopy_start(MigrationState *ms, bool *old_vm_running)
{
int ret;
QIOChannelBuffer *bioc;
QEMUFile *fb;
int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
bool restart_block = false;
int cur_state = MIGRATION_STATUS_ACTIVE;
if (!migrate_pause_before_switchover()) {
migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
trace_postcopy_start();
qemu_mutex_lock_iothread();
trace_postcopy_start_set_run();
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*old_vm_running = runstate_is_running();
global_state_store();
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (ret < 0) {
goto fail;
}
ret = migration_maybe_pause(ms, &cur_state,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
if (ret < 0) {
goto fail;
}
ret = bdrv_inactivate_all();
if (ret < 0) {
goto fail;
}
restart_block = true;
qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
if (migrate_postcopy_ram()) {
if (ram_postcopy_send_discard_bitmap(ms)) {
error_report("postcopy send discard bitmap failed");
goto fail;
}
}
qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(ms->to_dst_file, 2);
}
bioc = qio_channel_buffer_new(4096);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
qemu_savevm_send_postcopy_listen(fb);
qemu_savevm_state_complete_precopy(fb, false, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
qemu_savevm_send_postcopy_run(fb);
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored (pre package)");
goto fail_closefb;
}
restart_block = false;
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
goto fail_closefb;
}
qemu_fclose(fb);
ms->postcopy_after_devices = true;
notifier_list_notify(&migration_state_notifiers, ms);
ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
qemu_mutex_unlock_iothread();
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(ms->to_dst_file, 4);
}
if (migrate_release_ram()) {
ram_postcopy_migrated_memory_release(ms);
}
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored");
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
}
return ret;
fail_closefb:
qemu_fclose(fb);
fail:
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
if (restart_block) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
qemu_mutex_unlock_iothread();
return -1;
}
| {
"code": [
"static int postcopy_start(MigrationState *ms, bool *old_vm_running)",
" *old_vm_running = runstate_is_running();"
],
"line_no": [
1,
37
]
} | static int FUNC_0(MigrationState *VAR_0, bool *VAR_1)
{
int VAR_2;
QIOChannelBuffer *bioc;
QEMUFile *fb;
int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
bool restart_block = false;
int VAR_3 = MIGRATION_STATUS_ACTIVE;
if (!migrate_pause_before_switchover()) {
migrate_set_state(&VAR_0->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
trace_postcopy_start();
qemu_mutex_lock_iothread();
trace_postcopy_start_set_run();
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*VAR_1 = runstate_is_running();
global_state_store();
VAR_2 = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (VAR_2 < 0) {
goto fail;
}
VAR_2 = migration_maybe_pause(VAR_0, &VAR_3,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
if (VAR_2 < 0) {
goto fail;
}
VAR_2 = bdrv_inactivate_all();
if (VAR_2 < 0) {
goto fail;
}
restart_block = true;
qemu_savevm_state_complete_precopy(VAR_0->to_dst_file, true, false);
if (migrate_postcopy_ram()) {
if (ram_postcopy_send_discard_bitmap(VAR_0)) {
error_report("postcopy send discard bitmap failed");
goto fail;
}
}
qemu_file_set_rate_limit(VAR_0->to_dst_file, INT64_MAX);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(VAR_0->to_dst_file, 2);
}
bioc = qio_channel_buffer_new(4096);
qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer");
fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));
object_unref(OBJECT(bioc));
qemu_savevm_send_postcopy_listen(fb);
qemu_savevm_state_complete_precopy(fb, false, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
qemu_savevm_send_postcopy_run(fb);
VAR_2 = qemu_file_get_error(VAR_0->to_dst_file);
if (VAR_2) {
error_report("FUNC_0: Migration stream errored (pre package)");
goto fail_closefb;
}
restart_block = false;
if (qemu_savevm_send_packaged(VAR_0->to_dst_file, bioc->data, bioc->usage)) {
goto fail_closefb;
}
qemu_fclose(fb);
VAR_0->postcopy_after_devices = true;
notifier_list_notify(&migration_state_notifiers, VAR_0);
VAR_0->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
qemu_mutex_unlock_iothread();
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(VAR_0->to_dst_file, 4);
}
if (migrate_release_ram()) {
ram_postcopy_migrated_memory_release(VAR_0);
}
VAR_2 = qemu_file_get_error(VAR_0->to_dst_file);
if (VAR_2) {
error_report("FUNC_0: Migration stream errored");
migrate_set_state(&VAR_0->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
}
return VAR_2;
fail_closefb:
qemu_fclose(fb);
fail:
migrate_set_state(&VAR_0->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
if (restart_block) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
qemu_mutex_unlock_iothread();
return -1;
}
| [
"static int FUNC_0(MigrationState *VAR_0, bool *VAR_1)\n{",
"int VAR_2;",
"QIOChannelBuffer *bioc;",
"QEMUFile *fb;",
"int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);",
"bool restart_block = false;",
"int VAR_3 = MIGRATION_STATUS_ACTIVE;",
"if (!migrate_pause_before_switchover()) {",
"migrate_set_state(&VAR_0->state, MIGRATION_STATUS_ACTIVE,\nMIGRATION_STATUS_POSTCOPY_ACTIVE);",
"}",
"trace_postcopy_start();",
"qemu_mutex_lock_iothread();",
"trace_postcopy_start_set_run();",
"qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);",
"*VAR_1 = runstate_is_running();",
"global_state_store();",
"VAR_2 = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);",
"if (VAR_2 < 0) {",
"goto fail;",
"}",
"VAR_2 = migration_maybe_pause(VAR_0, &VAR_3,\nMIGRATION_STATUS_POSTCOPY_ACTIVE);",
"if (VAR_2 < 0) {",
"goto fail;",
"}",
"VAR_2 = bdrv_inactivate_all();",
"if (VAR_2 < 0) {",
"goto fail;",
"}",
"restart_block = true;",
"qemu_savevm_state_complete_precopy(VAR_0->to_dst_file, true, false);",
"if (migrate_postcopy_ram()) {",
"if (ram_postcopy_send_discard_bitmap(VAR_0)) {",
"error_report(\"postcopy send discard bitmap failed\");",
"goto fail;",
"}",
"}",
"qemu_file_set_rate_limit(VAR_0->to_dst_file, INT64_MAX);",
"if (migrate_postcopy_ram()) {",
"qemu_savevm_send_ping(VAR_0->to_dst_file, 2);",
"}",
"bioc = qio_channel_buffer_new(4096);",
"qio_channel_set_name(QIO_CHANNEL(bioc), \"migration-postcopy-buffer\");",
"fb = qemu_fopen_channel_output(QIO_CHANNEL(bioc));",
"object_unref(OBJECT(bioc));",
"qemu_savevm_send_postcopy_listen(fb);",
"qemu_savevm_state_complete_precopy(fb, false, false);",
"if (migrate_postcopy_ram()) {",
"qemu_savevm_send_ping(fb, 3);",
"}",
"qemu_savevm_send_postcopy_run(fb);",
"VAR_2 = qemu_file_get_error(VAR_0->to_dst_file);",
"if (VAR_2) {",
"error_report(\"FUNC_0: Migration stream errored (pre package)\");",
"goto fail_closefb;",
"}",
"restart_block = false;",
"if (qemu_savevm_send_packaged(VAR_0->to_dst_file, bioc->data, bioc->usage)) {",
"goto fail_closefb;",
"}",
"qemu_fclose(fb);",
"VAR_0->postcopy_after_devices = true;",
"notifier_list_notify(&migration_state_notifiers, VAR_0);",
"VAR_0->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;",
"qemu_mutex_unlock_iothread();",
"if (migrate_postcopy_ram()) {",
"qemu_savevm_send_ping(VAR_0->to_dst_file, 4);",
"}",
"if (migrate_release_ram()) {",
"ram_postcopy_migrated_memory_release(VAR_0);",
"}",
"VAR_2 = qemu_file_get_error(VAR_0->to_dst_file);",
"if (VAR_2) {",
"error_report(\"FUNC_0: Migration stream errored\");",
"migrate_set_state(&VAR_0->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,\nMIGRATION_STATUS_FAILED);",
"}",
"return VAR_2;",
"fail_closefb:\nqemu_fclose(fb);",
"fail:\nmigrate_set_state(&VAR_0->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,\nMIGRATION_STATUS_FAILED);",
"if (restart_block) {",
"Error *local_err = NULL;",
"bdrv_invalidate_cache_all(&local_err);",
"if (local_err) {",
"error_report_err(local_err);",
"}",
"}",
"qemu_mutex_unlock_iothread();",
"return -1;",
"}"
] | [
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
83
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
123
],
[
125
],
[
129
],
[
131
],
[
157
],
[
159
],
[
161
],
[
163
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
223
],
[
225
],
[
227
],
[
229
],
[
241
],
[
243
],
[
247
],
[
251
],
[
255
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285,
287
],
[
289
],
[
293
],
[
297,
299
],
[
301,
303,
305
],
[
307
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
]
] |
2,699 | static BusState *qbus_find(const char *path)
{
DeviceState *dev;
BusState *bus;
char elem[128];
int pos, len;
/* find start element */
if (path[0] == '/') {
bus = sysbus_get_default();
pos = 0;
} else {
if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
assert(!path[0]);
elem[0] = len = 0;
}
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
return NULL;
} else if (qbus_is_full(bus)) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
elem);
return NULL;
}
pos = len;
}
for (;;) {
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
return bus;
}
/* find device */
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
return NULL;
}
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
/* last specified element is a device. If it has exactly
* one child bus accept it nevertheless */
switch (dev->num_child_bus) {
case 0:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has no child bus", elem);
return NULL;
case 1:
return QLIST_FIRST(&dev->child_bus);
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
/* find bus */
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
}
| true | qemu | ed238ba2a0239368dd0cec9bfaf3300a5bd303ce | static BusState *qbus_find(const char *path)
{
DeviceState *dev;
BusState *bus;
char elem[128];
int pos, len;
if (path[0] == '/') {
bus = sysbus_get_default();
pos = 0;
} else {
if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
assert(!path[0]);
elem[0] = len = 0;
}
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
return NULL;
} else if (qbus_is_full(bus)) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
elem);
return NULL;
}
pos = len;
}
for (;;) {
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
return bus;
}
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
qerror_report(QERR_DEVICE_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
return NULL;
}
assert(path[pos] == '/' || !path[pos]);
while (path[pos] == '/') {
pos++;
}
if (path[pos] == '\0') {
switch (dev->num_child_bus) {
case 0:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has no child bus", elem);
return NULL;
case 1:
return QLIST_FIRST(&dev->child_bus);
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
g_assert_not_reached();
elem[0] = len = 0;
}
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, elem);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
}
| {
"code": [
" } else if (qbus_is_full(bus)) {",
" qerror_report(ERROR_CLASS_GENERIC_ERROR, \"Bus '%s' is full\",",
" elem);",
" return NULL;",
" return bus;",
" switch (dev->num_child_bus) {",
" case 0:",
" qerror_report(ERROR_CLASS_GENERIC_ERROR,",
" \"Device '%s' has no child bus\", elem);",
" return NULL;",
" case 1:",
" return QLIST_FIRST(&dev->child_bus);",
" default:",
" return NULL;"
],
"line_no": [
41,
43,
45,
39,
69,
119,
121,
123,
125,
127,
129,
131,
133,
127
]
} | static BusState *FUNC_0(const char *path)
{
DeviceState *dev;
BusState *bus;
char VAR_0[128];
int VAR_1, VAR_2;
if (path[0] == '/') {
bus = sysbus_get_default();
VAR_1 = 0;
} else {
if (sscanf(path, "%127[^/]%n", VAR_0, &VAR_2) != 1) {
assert(!path[0]);
VAR_0[0] = VAR_2 = 0;
}
bus = qbus_find_recursive(sysbus_get_default(), VAR_0, NULL);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, VAR_0);
return NULL;
} else if (qbus_is_full(bus)) {
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
VAR_0);
return NULL;
}
VAR_1 = VAR_2;
}
for (;;) {
assert(path[VAR_1] == '/' || !path[VAR_1]);
while (path[VAR_1] == '/') {
VAR_1++;
}
if (path[VAR_1] == '\0') {
return bus;
}
if (sscanf(path+VAR_1, "%127[^/]%n", VAR_0, &VAR_2) != 1) {
g_assert_not_reached();
VAR_0[0] = VAR_2 = 0;
}
VAR_1 += VAR_2;
dev = qbus_find_dev(bus, VAR_0);
if (!dev) {
qerror_report(QERR_DEVICE_NOT_FOUND, VAR_0);
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
return NULL;
}
assert(path[VAR_1] == '/' || !path[VAR_1]);
while (path[VAR_1] == '/') {
VAR_1++;
}
if (path[VAR_1] == '\0') {
switch (dev->num_child_bus) {
case 0:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has no child bus", VAR_0);
return NULL;
case 1:
return QLIST_FIRST(&dev->child_bus);
default:
qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", VAR_0);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
if (sscanf(path+VAR_1, "%127[^/]%n", VAR_0, &VAR_2) != 1) {
g_assert_not_reached();
VAR_0[0] = VAR_2 = 0;
}
VAR_1 += VAR_2;
bus = qbus_find_bus(dev, VAR_0);
if (!bus) {
qerror_report(QERR_BUS_NOT_FOUND, VAR_0);
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
return NULL;
}
}
}
| [
"static BusState *FUNC_0(const char *path)\n{",
"DeviceState *dev;",
"BusState *bus;",
"char VAR_0[128];",
"int VAR_1, VAR_2;",
"if (path[0] == '/') {",
"bus = sysbus_get_default();",
"VAR_1 = 0;",
"} else {",
"if (sscanf(path, \"%127[^/]%n\", VAR_0, &VAR_2) != 1) {",
"assert(!path[0]);",
"VAR_0[0] = VAR_2 = 0;",
"}",
"bus = qbus_find_recursive(sysbus_get_default(), VAR_0, NULL);",
"if (!bus) {",
"qerror_report(QERR_BUS_NOT_FOUND, VAR_0);",
"return NULL;",
"} else if (qbus_is_full(bus)) {",
"qerror_report(ERROR_CLASS_GENERIC_ERROR, \"Bus '%s' is full\",\nVAR_0);",
"return NULL;",
"}",
"VAR_1 = VAR_2;",
"}",
"for (;;) {",
"assert(path[VAR_1] == '/' || !path[VAR_1]);",
"while (path[VAR_1] == '/') {",
"VAR_1++;",
"}",
"if (path[VAR_1] == '\\0') {",
"return bus;",
"}",
"if (sscanf(path+VAR_1, \"%127[^/]%n\", VAR_0, &VAR_2) != 1) {",
"g_assert_not_reached();",
"VAR_0[0] = VAR_2 = 0;",
"}",
"VAR_1 += VAR_2;",
"dev = qbus_find_dev(bus, VAR_0);",
"if (!dev) {",
"qerror_report(QERR_DEVICE_NOT_FOUND, VAR_0);",
"if (!monitor_cur_is_qmp()) {",
"qbus_list_dev(bus);",
"}",
"return NULL;",
"}",
"assert(path[VAR_1] == '/' || !path[VAR_1]);",
"while (path[VAR_1] == '/') {",
"VAR_1++;",
"}",
"if (path[VAR_1] == '\\0') {",
"switch (dev->num_child_bus) {",
"case 0:\nqerror_report(ERROR_CLASS_GENERIC_ERROR,\n\"Device '%s' has no child bus\", VAR_0);",
"return NULL;",
"case 1:\nreturn QLIST_FIRST(&dev->child_bus);",
"default:\nqerror_report(ERROR_CLASS_GENERIC_ERROR,\n\"Device '%s' has multiple child busses\", VAR_0);",
"if (!monitor_cur_is_qmp()) {",
"qbus_list_bus(dev);",
"}",
"return NULL;",
"}",
"}",
"if (sscanf(path+VAR_1, \"%127[^/]%n\", VAR_0, &VAR_2) != 1) {",
"g_assert_not_reached();",
"VAR_0[0] = VAR_2 = 0;",
"}",
"VAR_1 += VAR_2;",
"bus = qbus_find_bus(dev, VAR_0);",
"if (!bus) {",
"qerror_report(QERR_BUS_NOT_FOUND, VAR_0);",
"if (!monitor_cur_is_qmp()) {",
"qbus_list_bus(dev);",
"}",
"return NULL;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121,
123,
125
],
[
127
],
[
129,
131
],
[
133,
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
]
] |
2,700 | void bdrv_init(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
bdrv_register(&bdrv_cow);
bdrv_register(&bdrv_qcow);
bdrv_register(&bdrv_vmdk);
bdrv_register(&bdrv_cloop);
bdrv_register(&bdrv_dmg);
bdrv_register(&bdrv_bochs);
bdrv_register(&bdrv_vpc);
bdrv_register(&bdrv_vvfat);
bdrv_register(&bdrv_qcow2);
bdrv_register(&bdrv_parallels);
bdrv_register(&bdrv_nbd);
} | true | qemu | cd01b4a312248dd4e12c3d389d1a349cea4015d8 | void bdrv_init(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
bdrv_register(&bdrv_cow);
bdrv_register(&bdrv_qcow);
bdrv_register(&bdrv_vmdk);
bdrv_register(&bdrv_cloop);
bdrv_register(&bdrv_dmg);
bdrv_register(&bdrv_bochs);
bdrv_register(&bdrv_vpc);
bdrv_register(&bdrv_vvfat);
bdrv_register(&bdrv_qcow2);
bdrv_register(&bdrv_parallels);
bdrv_register(&bdrv_nbd);
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
bdrv_register(&bdrv_cow);
bdrv_register(&bdrv_qcow);
bdrv_register(&bdrv_vmdk);
bdrv_register(&bdrv_cloop);
bdrv_register(&bdrv_dmg);
bdrv_register(&bdrv_bochs);
bdrv_register(&bdrv_vpc);
bdrv_register(&bdrv_vvfat);
bdrv_register(&bdrv_qcow2);
bdrv_register(&bdrv_parallels);
bdrv_register(&bdrv_nbd);
} | [
"void FUNC_0(void)\n{",
"bdrv_register(&bdrv_raw);",
"bdrv_register(&bdrv_host_device);",
"bdrv_register(&bdrv_cow);",
"bdrv_register(&bdrv_qcow);",
"bdrv_register(&bdrv_vmdk);",
"bdrv_register(&bdrv_cloop);",
"bdrv_register(&bdrv_dmg);",
"bdrv_register(&bdrv_bochs);",
"bdrv_register(&bdrv_vpc);",
"bdrv_register(&bdrv_vvfat);",
"bdrv_register(&bdrv_qcow2);",
"bdrv_register(&bdrv_parallels);",
"bdrv_register(&bdrv_nbd);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
10
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
32
],
[
35
]
] |
2,701 | void ff_h264_direct_dist_scale_factor(H264Context * const h){
const int poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
const int poc1 = h->ref_list[1][0].poc;
int i, field;
if (FRAME_MBAFF(h))
for (field = 0; field < 2; field++){
const int poc = h->cur_pic_ptr->field_poc[field];
const int poc1 = h->ref_list[1][0].field_poc[field];
for (i = 0; i < 2 * h->ref_count[0]; i++)
h->dist_scale_factor_field[field][i^field] =
get_scale_factor(h, poc, poc1, i+16);
}
for (i = 0; i < h->ref_count[0]; i++){
h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i);
}
}
| true | FFmpeg | ebd1c505d22ad96e044880755ed9f4cf7cab4f78 | void ff_h264_direct_dist_scale_factor(H264Context * const h){
const int poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
const int poc1 = h->ref_list[1][0].poc;
int i, field;
if (FRAME_MBAFF(h))
for (field = 0; field < 2; field++){
const int poc = h->cur_pic_ptr->field_poc[field];
const int poc1 = h->ref_list[1][0].field_poc[field];
for (i = 0; i < 2 * h->ref_count[0]; i++)
h->dist_scale_factor_field[field][i^field] =
get_scale_factor(h, poc, poc1, i+16);
}
for (i = 0; i < h->ref_count[0]; i++){
h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i);
}
}
| {
"code": [
" const int poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];"
],
"line_no": [
3
]
} | void FUNC_0(H264Context * const VAR_0){
const int VAR_5 = VAR_0->cur_pic_ptr->field_poc[VAR_0->picture_structure == PICT_BOTTOM_FIELD];
const int VAR_5 = VAR_0->ref_list[1][0].VAR_5;
int VAR_3, VAR_4;
if (FRAME_MBAFF(VAR_0))
for (VAR_4 = 0; VAR_4 < 2; VAR_4++){
const int VAR_5 = VAR_0->cur_pic_ptr->field_poc[VAR_4];
const int VAR_5 = VAR_0->ref_list[1][0].field_poc[VAR_4];
for (VAR_3 = 0; VAR_3 < 2 * VAR_0->ref_count[0]; VAR_3++)
VAR_0->dist_scale_factor_field[VAR_4][VAR_3^VAR_4] =
get_scale_factor(VAR_0, VAR_5, VAR_5, VAR_3+16);
}
for (VAR_3 = 0; VAR_3 < VAR_0->ref_count[0]; VAR_3++){
VAR_0->dist_scale_factor[VAR_3] = get_scale_factor(VAR_0, VAR_5, VAR_5, VAR_3);
}
}
| [
"void FUNC_0(H264Context * const VAR_0){",
"const int VAR_5 = VAR_0->cur_pic_ptr->field_poc[VAR_0->picture_structure == PICT_BOTTOM_FIELD];",
"const int VAR_5 = VAR_0->ref_list[1][0].VAR_5;",
"int VAR_3, VAR_4;",
"if (FRAME_MBAFF(VAR_0))\nfor (VAR_4 = 0; VAR_4 < 2; VAR_4++){",
"const int VAR_5 = VAR_0->cur_pic_ptr->field_poc[VAR_4];",
"const int VAR_5 = VAR_0->ref_list[1][0].field_poc[VAR_4];",
"for (VAR_3 = 0; VAR_3 < 2 * VAR_0->ref_count[0]; VAR_3++)",
"VAR_0->dist_scale_factor_field[VAR_4][VAR_3^VAR_4] =\nget_scale_factor(VAR_0, VAR_5, VAR_5, VAR_3+16);",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_0->ref_count[0]; VAR_3++){",
"VAR_0->dist_scale_factor[VAR_3] = get_scale_factor(VAR_0, VAR_5, VAR_5, VAR_3);",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
2,702 | static void virtio_net_handle_tx_bh(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIONet *n = to_virtio_net(vdev);
if (unlikely(n->tx_waiting)) {
return;
}
virtio_queue_set_notification(vq, 0);
qemu_bh_schedule(n->tx_bh);
n->tx_waiting = 1;
}
| true | qemu | 783e7706937fe15523b609b545587a028a2bdd03 | static void virtio_net_handle_tx_bh(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIONet *n = to_virtio_net(vdev);
if (unlikely(n->tx_waiting)) {
return;
}
virtio_queue_set_notification(vq, 0);
qemu_bh_schedule(n->tx_bh);
n->tx_waiting = 1;
}
| {
"code": [
" VirtIONet *n = to_virtio_net(vdev);",
" n->tx_waiting = 1;"
],
"line_no": [
5,
19
]
} | static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)
{
VirtIONet *n = to_virtio_net(VAR_0);
if (unlikely(n->tx_waiting)) {
return;
}
virtio_queue_set_notification(VAR_1, 0);
qemu_bh_schedule(n->tx_bh);
n->tx_waiting = 1;
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, VirtQueue *VAR_1)\n{",
"VirtIONet *n = to_virtio_net(VAR_0);",
"if (unlikely(n->tx_waiting)) {",
"return;",
"}",
"virtio_queue_set_notification(VAR_1, 0);",
"qemu_bh_schedule(n->tx_bh);",
"n->tx_waiting = 1;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
2,703 | static int net_dump_init(NetClientState *peer, const char *device,
const char *name, const char *filename, int len)
{
struct pcap_file_hdr hdr;
NetClientState *nc;
DumpState *s;
struct tm tm;
int fd;
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (fd < 0) {
error_report("-net dump: can't open %s", filename);
return -1;
}
hdr.magic = PCAP_MAGIC;
hdr.version_major = 2;
hdr.version_minor = 4;
hdr.thiszone = 0;
hdr.sigfigs = 0;
hdr.snaplen = len;
hdr.linktype = 1;
if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
error_report("-net dump write error: %s", strerror(errno));
close(fd);
return -1;
}
nc = qemu_new_net_client(&net_dump_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (len=%d)", filename, len);
s = DO_UPCAST(DumpState, nc, nc);
s->fd = fd;
s->pcap_caplen = len;
qemu_get_timedate(&tm, 0);
s->start_ts = mktime(&tm);
return 0;
}
| true | qemu | 3791f83ca999edc2d11eb2006ccc1091cd712c15 | static int net_dump_init(NetClientState *peer, const char *device,
const char *name, const char *filename, int len)
{
struct pcap_file_hdr hdr;
NetClientState *nc;
DumpState *s;
struct tm tm;
int fd;
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (fd < 0) {
error_report("-net dump: can't open %s", filename);
return -1;
}
hdr.magic = PCAP_MAGIC;
hdr.version_major = 2;
hdr.version_minor = 4;
hdr.thiszone = 0;
hdr.sigfigs = 0;
hdr.snaplen = len;
hdr.linktype = 1;
if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
error_report("-net dump write error: %s", strerror(errno));
close(fd);
return -1;
}
nc = qemu_new_net_client(&net_dump_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (len=%d)", filename, len);
s = DO_UPCAST(DumpState, nc, nc);
s->fd = fd;
s->pcap_caplen = len;
qemu_get_timedate(&tm, 0);
s->start_ts = mktime(&tm);
return 0;
}
| {
"code": [
" const char *name, const char *filename, int len)",
" error_report(\"-net dump: can't open %s\", filename);",
" error_report(\"-net dump write error: %s\", strerror(errno));"
],
"line_no": [
3,
23,
49
]
} | static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,
const char *VAR_2, const char *VAR_3, int VAR_4)
{
struct pcap_file_hdr VAR_5;
NetClientState *nc;
DumpState *s;
struct VAR_6 VAR_6;
int VAR_7;
VAR_7 = open(VAR_3, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (VAR_7 < 0) {
error_report("-net dump: can't open %s", VAR_3);
return -1;
}
VAR_5.magic = PCAP_MAGIC;
VAR_5.version_major = 2;
VAR_5.version_minor = 4;
VAR_5.thiszone = 0;
VAR_5.sigfigs = 0;
VAR_5.snaplen = VAR_4;
VAR_5.linktype = 1;
if (write(VAR_7, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) {
error_report("-net dump write error: %s", strerror(errno));
close(VAR_7);
return -1;
}
nc = qemu_new_net_client(&net_dump_info, VAR_0, VAR_1, VAR_2);
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (VAR_4=%d)", VAR_3, VAR_4);
s = DO_UPCAST(DumpState, nc, nc);
s->VAR_7 = VAR_7;
s->pcap_caplen = VAR_4;
qemu_get_timedate(&VAR_6, 0);
s->start_ts = mktime(&VAR_6);
return 0;
}
| [
"static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,\nconst char *VAR_2, const char *VAR_3, int VAR_4)\n{",
"struct pcap_file_hdr VAR_5;",
"NetClientState *nc;",
"DumpState *s;",
"struct VAR_6 VAR_6;",
"int VAR_7;",
"VAR_7 = open(VAR_3, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);",
"if (VAR_7 < 0) {",
"error_report(\"-net dump: can't open %s\", VAR_3);",
"return -1;",
"}",
"VAR_5.magic = PCAP_MAGIC;",
"VAR_5.version_major = 2;",
"VAR_5.version_minor = 4;",
"VAR_5.thiszone = 0;",
"VAR_5.sigfigs = 0;",
"VAR_5.snaplen = VAR_4;",
"VAR_5.linktype = 1;",
"if (write(VAR_7, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) {",
"error_report(\"-net dump write error: %s\", strerror(errno));",
"close(VAR_7);",
"return -1;",
"}",
"nc = qemu_new_net_client(&net_dump_info, VAR_0, VAR_1, VAR_2);",
"snprintf(nc->info_str, sizeof(nc->info_str),\n\"dump to %s (VAR_4=%d)\", VAR_3, VAR_4);",
"s = DO_UPCAST(DumpState, nc, nc);",
"s->VAR_7 = VAR_7;",
"s->pcap_caplen = VAR_4;",
"qemu_get_timedate(&VAR_6, 0);",
"s->start_ts = mktime(&VAR_6);",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63,
65
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
2,705 | AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int size,
int64_t channel_layout, int planar)
{
AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
AVFilterBufferRef *ref = NULL;
int i, sample_size, chans_nb, bufsize, per_channel_size, step_size = 0;
char *buf;
if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
goto fail;
ref->buf = samples;
ref->format = sample_fmt;
ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps));
if (!ref->audio)
goto fail;
ref->audio->channel_layout = channel_layout;
ref->audio->size = size;
ref->audio->planar = planar;
/* make sure the buffer gets read permission or it's useless for output */
ref->perms = perms | AV_PERM_READ;
samples->refcount = 1;
samples->free = ff_avfilter_default_free_buffer;
sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3;
chans_nb = av_get_channel_layout_nb_channels(channel_layout);
per_channel_size = size/chans_nb;
ref->audio->nb_samples = per_channel_size/sample_size;
/* Set the number of bytes to traverse to reach next sample of a particular channel:
* For planar, this is simply the sample size.
* For packed, this is the number of samples * sample_size.
*/
for (i = 0; i < chans_nb; i++)
samples->linesize[i] = planar > 0 ? per_channel_size : sample_size;
memset(&samples->linesize[chans_nb], 0, (8-chans_nb) * sizeof(samples->linesize[0]));
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
bufsize = (size + 15)&~15;
buf = av_malloc(bufsize);
if (!buf)
goto fail;
/* For planar, set the start point of each channel's data within the buffer
* For packed, set the start point of the entire buffer only
*/
samples->data[0] = buf;
if (buf && planar) {
for (i = 1; i < chans_nb; i++) {
step_size += per_channel_size;
samples->data[i] = buf + step_size;
}
} else {
for (i = 1; i < chans_nb; i++)
samples->data[i] = buf;
}
memset(&samples->data[chans_nb], 0, (8-chans_nb) * sizeof(samples->data[0]));
memcpy(ref->data, samples->data, sizeof(ref->data));
memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize));
return ref;
fail:
av_free(buf);
if (ref && ref->audio)
av_free(ref->audio);
av_free(ref);
av_free(samples);
return NULL;
}
| true | FFmpeg | ecea47a6ed9e9250474e1ef26120ff5dc9e71e8e | AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int size,
int64_t channel_layout, int planar)
{
AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
AVFilterBufferRef *ref = NULL;
int i, sample_size, chans_nb, bufsize, per_channel_size, step_size = 0;
char *buf;
if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
goto fail;
ref->buf = samples;
ref->format = sample_fmt;
ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps));
if (!ref->audio)
goto fail;
ref->audio->channel_layout = channel_layout;
ref->audio->size = size;
ref->audio->planar = planar;
ref->perms = perms | AV_PERM_READ;
samples->refcount = 1;
samples->free = ff_avfilter_default_free_buffer;
sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3;
chans_nb = av_get_channel_layout_nb_channels(channel_layout);
per_channel_size = size/chans_nb;
ref->audio->nb_samples = per_channel_size/sample_size;
for (i = 0; i < chans_nb; i++)
samples->linesize[i] = planar > 0 ? per_channel_size : sample_size;
memset(&samples->linesize[chans_nb], 0, (8-chans_nb) * sizeof(samples->linesize[0]));
bufsize = (size + 15)&~15;
buf = av_malloc(bufsize);
if (!buf)
goto fail;
samples->data[0] = buf;
if (buf && planar) {
for (i = 1; i < chans_nb; i++) {
step_size += per_channel_size;
samples->data[i] = buf + step_size;
}
} else {
for (i = 1; i < chans_nb; i++)
samples->data[i] = buf;
}
memset(&samples->data[chans_nb], 0, (8-chans_nb) * sizeof(samples->data[0]));
memcpy(ref->data, samples->data, sizeof(ref->data));
memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize));
return ref;
fail:
av_free(buf);
if (ref && ref->audio)
av_free(ref->audio);
av_free(ref);
av_free(samples);
return NULL;
}
| {
"code": [
" av_free(buf);"
],
"line_no": [
143
]
} | AVFilterBufferRef *FUNC_0(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int size,
int64_t channel_layout, int planar)
{
AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
AVFilterBufferRef *ref = NULL;
int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5 = 0;
char *VAR_6;
if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
goto fail;
ref->VAR_6 = samples;
ref->format = sample_fmt;
ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps));
if (!ref->audio)
goto fail;
ref->audio->channel_layout = channel_layout;
ref->audio->size = size;
ref->audio->planar = planar;
ref->perms = perms | AV_PERM_READ;
samples->refcount = 1;
samples->free = ff_avfilter_default_free_buffer;
VAR_1 = av_get_bits_per_sample_fmt(sample_fmt) >>3;
VAR_2 = av_get_channel_layout_nb_channels(channel_layout);
VAR_4 = size/VAR_2;
ref->audio->nb_samples = VAR_4/VAR_1;
for (VAR_0 = 0; VAR_0 < VAR_2; VAR_0++)
samples->linesize[VAR_0] = planar > 0 ? VAR_4 : VAR_1;
memset(&samples->linesize[VAR_2], 0, (8-VAR_2) * sizeof(samples->linesize[0]));
VAR_3 = (size + 15)&~15;
VAR_6 = av_malloc(VAR_3);
if (!VAR_6)
goto fail;
samples->data[0] = VAR_6;
if (VAR_6 && planar) {
for (VAR_0 = 1; VAR_0 < VAR_2; VAR_0++) {
VAR_5 += VAR_4;
samples->data[VAR_0] = VAR_6 + VAR_5;
}
} else {
for (VAR_0 = 1; VAR_0 < VAR_2; VAR_0++)
samples->data[VAR_0] = VAR_6;
}
memset(&samples->data[VAR_2], 0, (8-VAR_2) * sizeof(samples->data[0]));
memcpy(ref->data, samples->data, sizeof(ref->data));
memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize));
return ref;
fail:
av_free(VAR_6);
if (ref && ref->audio)
av_free(ref->audio);
av_free(ref);
av_free(samples);
return NULL;
}
| [
"AVFilterBufferRef *FUNC_0(AVFilterLink *link, int perms,\nenum AVSampleFormat sample_fmt, int size,\nint64_t channel_layout, int planar)\n{",
"AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));",
"AVFilterBufferRef *ref = NULL;",
"int VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5 = 0;",
"char *VAR_6;",
"if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))\ngoto fail;",
"ref->VAR_6 = samples;",
"ref->format = sample_fmt;",
"ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps));",
"if (!ref->audio)\ngoto fail;",
"ref->audio->channel_layout = channel_layout;",
"ref->audio->size = size;",
"ref->audio->planar = planar;",
"ref->perms = perms | AV_PERM_READ;",
"samples->refcount = 1;",
"samples->free = ff_avfilter_default_free_buffer;",
"VAR_1 = av_get_bits_per_sample_fmt(sample_fmt) >>3;",
"VAR_2 = av_get_channel_layout_nb_channels(channel_layout);",
"VAR_4 = size/VAR_2;",
"ref->audio->nb_samples = VAR_4/VAR_1;",
"for (VAR_0 = 0; VAR_0 < VAR_2; VAR_0++)",
"samples->linesize[VAR_0] = planar > 0 ? VAR_4 : VAR_1;",
"memset(&samples->linesize[VAR_2], 0, (8-VAR_2) * sizeof(samples->linesize[0]));",
"VAR_3 = (size + 15)&~15;",
"VAR_6 = av_malloc(VAR_3);",
"if (!VAR_6)\ngoto fail;",
"samples->data[0] = VAR_6;",
"if (VAR_6 && planar) {",
"for (VAR_0 = 1; VAR_0 < VAR_2; VAR_0++) {",
"VAR_5 += VAR_4;",
"samples->data[VAR_0] = VAR_6 + VAR_5;",
"}",
"} else {",
"for (VAR_0 = 1; VAR_0 < VAR_2; VAR_0++)",
"samples->data[VAR_0] = VAR_6;",
"}",
"memset(&samples->data[VAR_2], 0, (8-VAR_2) * sizeof(samples->data[0]));",
"memcpy(ref->data, samples->data, sizeof(ref->data));",
"memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize));",
"return ref;",
"fail:\nav_free(VAR_6);",
"if (ref && ref->audio)\nav_free(ref->audio);",
"av_free(ref);",
"av_free(samples);",
"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,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
67
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93,
95
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
137
],
[
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
]
] |
2,706 | static void test_keyval_visit_any(void)
{
Visitor *v;
QDict *qdict;
QObject *any;
QList *qlist;
QString *qstr;
qdict = keyval_parse("a.0=null,a.1=1", NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
QDECREF(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_any(v, "a", &any, &error_abort);
qlist = qobject_to_qlist(any);
g_assert(qlist);
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "null");
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "1");
g_assert(qlist_empty(qlist));
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
visit_free(v);
} | true | qemu | cb69166bb8defaaa4b3e0a4e31de693737634a54 | static void test_keyval_visit_any(void)
{
Visitor *v;
QDict *qdict;
QObject *any;
QList *qlist;
QString *qstr;
qdict = keyval_parse("a.0=null,a.1=1", NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
QDECREF(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_any(v, "a", &any, &error_abort);
qlist = qobject_to_qlist(any);
g_assert(qlist);
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "null");
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "1");
g_assert(qlist_empty(qlist));
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
visit_free(v);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
Visitor *v;
QDict *qdict;
QObject *any;
QList *qlist;
QString *qstr;
qdict = keyval_parse("a.0=null,a.1=1", NULL, &error_abort);
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
QDECREF(qdict);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_type_any(v, "a", &any, &error_abort);
qlist = qobject_to_qlist(any);
g_assert(qlist);
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "null");
qstr = qobject_to_qstring(qlist_pop(qlist));
g_assert_cmpstr(qstring_get_str(qstr), ==, "1");
g_assert(qlist_empty(qlist));
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
visit_free(v);
} | [
"static void FUNC_0(void)\n{",
"Visitor *v;",
"QDict *qdict;",
"QObject *any;",
"QList *qlist;",
"QString *qstr;",
"qdict = keyval_parse(\"a.0=null,a.1=1\", NULL, &error_abort);",
"v = qobject_input_visitor_new_keyval(QOBJECT(qdict));",
"QDECREF(qdict);",
"visit_start_struct(v, NULL, NULL, 0, &error_abort);",
"visit_type_any(v, \"a\", &any, &error_abort);",
"qlist = qobject_to_qlist(any);",
"g_assert(qlist);",
"qstr = qobject_to_qstring(qlist_pop(qlist));",
"g_assert_cmpstr(qstring_get_str(qstr), ==, \"null\");",
"qstr = qobject_to_qstring(qlist_pop(qlist));",
"g_assert_cmpstr(qstring_get_str(qstr), ==, \"1\");",
"g_assert(qlist_empty(qlist));",
"visit_check_struct(v, &error_abort);",
"visit_end_struct(v, NULL);",
"visit_free(v);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
36
],
[
38
],
[
40
],
[
44
],
[
46
],
[
48
],
[
50
]
] |
2,707 | static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
int coded, int codingset, int mquant)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0; /* Direction of the DC prediction used */
int i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
/* Get DC differential */
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff) {
if (dcdiff == 119 /* ESC index value */) {
/* TODO: Optimize */
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else {
if (mquant == 1)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
}
if (get_bits1(gb))
dcdiff = -dcdiff;
}
/* Prediction */
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
/* Store the quantized DC coeff, used for prediction */
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
//AC Decoding
i = 1;
/* check if AC is needed at all */
if (!a_avail && !c_avail)
use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0);
if (dc_pred_dir) // left
ac_val -= 16;
else // top
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.f.qscale_table[mb_pos];
if ( dc_pred_dir && c_avail && mb_pos)
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if ( dc_pred_dir && n == 1)
q2 = q1;
if (!dc_pred_dir && n == 2)
q2 = q1;
if (n == 3)
q2 = q1;
if (coded) {
int last = 0, skip, value;
const uint8_t *zz_table;
int k;
if (v->s.ac_pred) {
if (!use_pred && v->fcm == ILACE_FRAME) {
zz_table = v->zzi_8x8;
} else {
if (!dc_pred_dir) // top
zz_table = v->zz_8x8[2];
else // left
zz_table = v->zz_8x8[3];
}
} else {
if (v->fcm != ILACE_FRAME)
zz_table = v->zz_8x8[1];
else
zz_table = v->zzi_8x8;
}
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if (i > 63)
break;
block[zz_table[i++]] = value;
}
/* apply AC prediction if needed */
if (use_pred) {
/* scale predictors if needed*/
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
if (dc_pred_dir) { // left
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { // top
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if (dc_pred_dir) { //left
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += ac_val[k];
} else { //top
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for (k = 1; k < 8; k++) {
ac_val2[k ] = block[k << v->left_blk_sh];
ac_val2[k + 8] = block[k << v->top_blk_sh];
}
/* scale AC coeffs */
for (k = 1; k < 64; k++)
if (block[k]) {
block[k] *= scale;
if (!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if (use_pred) i = 63;
} else { // no AC coeffs
int k;
memset(ac_val2, 0, 16 * 2);
if (dc_pred_dir) { // left
if (use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else { // top
if (use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
/* apply AC prediction if needed */
if (use_pred) {
if (dc_pred_dir) { // left
for (k = 1; k < 8; k++) {
block[k << v->left_blk_sh] = ac_val2[k] * scale;
if (!v->pquantizer && block[k << v->left_blk_sh])
block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
}
} else { // top
for (k = 1; k < 8; k++) {
block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
if (!v->pquantizer && block[k << v->top_blk_sh])
block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| true | FFmpeg | 63c61f0be03624fbd9e352d8393122beb3ddcc1a | static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
int coded, int codingset, int mquant)
{
GetBitContext *gb = &v->s.gb;
MpegEncContext *s = &v->s;
int dc_pred_dir = 0;
int i;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int dcdiff;
int a_avail = v->a_avail, c_avail = v->c_avail;
int use_pred = s->ac_pred;
int scale;
int q1, q2 = 0;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
if (n < 4) {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (dcdiff < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
return -1;
}
if (dcdiff) {
if (dcdiff == 119 ) {
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else {
if (mquant == 1)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
else if (mquant == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
}
if (get_bits1(gb))
dcdiff = -dcdiff;
}
dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
*dc_val = dcdiff;
if (n < 4) {
block[0] = dcdiff * s->y_dc_scale;
} else {
block[0] = dcdiff * s->c_dc_scale;
}
i = 1;
if (!a_avail && !c_avail)
use_pred = 0;
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val2 = ac_val;
scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0);
if (dc_pred_dir)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.f.qscale_table[mb_pos];
if ( dc_pred_dir && c_avail && mb_pos)
q2 = s->current_picture.f.qscale_table[mb_pos - 1];
if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
if ( dc_pred_dir && n == 1)
q2 = q1;
if (!dc_pred_dir && n == 2)
q2 = q1;
if (n == 3)
q2 = q1;
if (coded) {
int last = 0, skip, value;
const uint8_t *zz_table;
int k;
if (v->s.ac_pred) {
if (!use_pred && v->fcm == ILACE_FRAME) {
zz_table = v->zzi_8x8;
} else {
if (!dc_pred_dir)
zz_table = v->zz_8x8[2];
else
zz_table = v->zz_8x8[3];
}
} else {
if (v->fcm != ILACE_FRAME)
zz_table = v->zz_8x8[1];
else
zz_table = v->zzi_8x8;
}
while (!last) {
vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
i += skip;
if (i > 63)
break;
block[zz_table[i++]] = value;
}
if (use_pred) {
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
if (dc_pred_dir) {
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else {
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if (dc_pred_dir) {
for (k = 1; k < 8; k++)
block[k << v->left_blk_sh] += ac_val[k];
} else {
for (k = 1; k < 8; k++)
block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
}
for (k = 1; k < 8; k++) {
ac_val2[k ] = block[k << v->left_blk_sh];
ac_val2[k + 8] = block[k << v->top_blk_sh];
}
for (k = 1; k < 64; k++)
if (block[k]) {
block[k] *= scale;
if (!v->pquantizer)
block[k] += (block[k] < 0) ? -mquant : mquant;
}
if (use_pred) i = 63;
} else {
int k;
memset(ac_val2, 0, 16 * 2);
if (dc_pred_dir) {
if (use_pred) {
memcpy(ac_val2, ac_val, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
} else {
if (use_pred) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if (q2 && q1 != q2) {
q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
if (q1 < 1)
return AVERROR_INVALIDDATA;
for (k = 1; k < 8; k++)
ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
}
}
if (use_pred) {
if (dc_pred_dir) {
for (k = 1; k < 8; k++) {
block[k << v->left_blk_sh] = ac_val2[k] * scale;
if (!v->pquantizer && block[k << v->left_blk_sh])
block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
}
} else {
for (k = 1; k < 8; k++) {
block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
if (!v->pquantizer && block[k << v->top_blk_sh])
block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
}
}
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| {
"code": [
" int16_t *dc_val;",
" int16_t *dc_val;"
],
"line_no": [
15,
15
]
} | static int FUNC_0(VC1Context *VAR_0, int16_t VAR_1[64], int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
GetBitContext *gb = &VAR_0->s.gb;
MpegEncContext *s = &VAR_0->s;
int VAR_6 = 0;
int VAR_7;
int16_t *dc_val;
int16_t *ac_val, *ac_val2;
int VAR_8;
int VAR_9 = VAR_0->VAR_9, VAR_10 = VAR_0->VAR_10;
int VAR_11 = s->ac_pred;
int VAR_12;
int VAR_13, VAR_14 = 0;
int VAR_15 = s->mb_x + s->mb_y * s->mb_stride;
if (VAR_2 < 4) {
VAR_8 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
} else {
VAR_8 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
}
if (VAR_8 < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\VAR_2");
return -1;
}
if (VAR_8) {
if (VAR_8 == 119 ) {
if (VAR_5 == 1) VAR_8 = get_bits(gb, 10);
else if (VAR_5 == 2) VAR_8 = get_bits(gb, 9);
else VAR_8 = get_bits(gb, 8);
} else {
if (VAR_5 == 1)
VAR_8 = (VAR_8 << 2) + get_bits(gb, 2) - 3;
else if (VAR_5 == 2)
VAR_8 = (VAR_8 << 1) + get_bits1(gb) - 1;
}
if (get_bits1(gb))
VAR_8 = -VAR_8;
}
VAR_8 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_5, VAR_2, VAR_0->VAR_9, VAR_0->VAR_10, &dc_val, &VAR_6);
*dc_val = VAR_8;
if (VAR_2 < 4) {
VAR_1[0] = VAR_8 * s->y_dc_scale;
} else {
VAR_1[0] = VAR_8 * s->c_dc_scale;
}
VAR_7 = 1;
if (!VAR_9 && !VAR_10)
VAR_11 = 0;
ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;
ac_val2 = ac_val;
VAR_12 = VAR_5 * 2 + ((VAR_5 == VAR_0->pq) ? VAR_0->halfpq : 0);
if (VAR_6)
ac_val -= 16;
else
ac_val -= 16 * s->block_wrap[VAR_2];
VAR_13 = s->current_picture.f.qscale_table[VAR_15];
if ( VAR_6 && VAR_10 && VAR_15)
VAR_14 = s->current_picture.f.qscale_table[VAR_15 - 1];
if (!VAR_6 && VAR_9 && VAR_15 >= s->mb_stride)
VAR_14 = s->current_picture.f.qscale_table[VAR_15 - s->mb_stride];
if ( VAR_6 && VAR_2 == 1)
VAR_14 = VAR_13;
if (!VAR_6 && VAR_2 == 2)
VAR_14 = VAR_13;
if (VAR_2 == 3)
VAR_14 = VAR_13;
if (VAR_3) {
int VAR_16 = 0, VAR_17, VAR_18;
const uint8_t *VAR_19;
int VAR_21;
if (VAR_0->s.ac_pred) {
if (!VAR_11 && VAR_0->fcm == ILACE_FRAME) {
VAR_19 = VAR_0->zzi_8x8;
} else {
if (!VAR_6)
VAR_19 = VAR_0->zz_8x8[2];
else
VAR_19 = VAR_0->zz_8x8[3];
}
} else {
if (VAR_0->fcm != ILACE_FRAME)
VAR_19 = VAR_0->zz_8x8[1];
else
VAR_19 = VAR_0->zzi_8x8;
}
while (!VAR_16) {
vc1_decode_ac_coeff(VAR_0, &VAR_16, &VAR_17, &VAR_18, VAR_4);
VAR_7 += VAR_17;
if (VAR_7 > 63)
break;
VAR_1[VAR_19[VAR_7++]] = VAR_18;
}
if (VAR_11) {
if (VAR_14 && VAR_13 != VAR_14) {
VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
if (VAR_13 < 1)
return AVERROR_INVALIDDATA;
if (VAR_6) {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
VAR_1[VAR_21 << VAR_0->left_blk_sh] += (ac_val[VAR_21] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;
} else {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
VAR_1[VAR_21 << VAR_0->top_blk_sh] += (ac_val[VAR_21 + 8] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;
}
} else {
if (VAR_6) {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
VAR_1[VAR_21 << VAR_0->left_blk_sh] += ac_val[VAR_21];
} else {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
VAR_1[VAR_21 << VAR_0->top_blk_sh] += ac_val[VAR_21 + 8];
}
}
}
for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {
ac_val2[VAR_21 ] = VAR_1[VAR_21 << VAR_0->left_blk_sh];
ac_val2[VAR_21 + 8] = VAR_1[VAR_21 << VAR_0->top_blk_sh];
}
for (VAR_21 = 1; VAR_21 < 64; VAR_21++)
if (VAR_1[VAR_21]) {
VAR_1[VAR_21] *= VAR_12;
if (!VAR_0->pquantizer)
VAR_1[VAR_21] += (VAR_1[VAR_21] < 0) ? -VAR_5 : VAR_5;
}
if (VAR_11) VAR_7 = 63;
} else {
int VAR_21;
memset(ac_val2, 0, 16 * 2);
if (VAR_6) {
if (VAR_11) {
memcpy(ac_val2, ac_val, 8 * 2);
if (VAR_14 && VAR_13 != VAR_14) {
VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
if (VAR_13 < 1)
return AVERROR_INVALIDDATA;
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
ac_val2[VAR_21] = (ac_val2[VAR_21] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;
}
}
} else {
if (VAR_11) {
memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
if (VAR_14 && VAR_13 != VAR_14) {
VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;
if (VAR_13 < 1)
return AVERROR_INVALIDDATA;
for (VAR_21 = 1; VAR_21 < 8; VAR_21++)
ac_val2[VAR_21 + 8] = (ac_val2[VAR_21 + 8] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;
}
}
}
if (VAR_11) {
if (VAR_6) {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {
VAR_1[VAR_21 << VAR_0->left_blk_sh] = ac_val2[VAR_21] * VAR_12;
if (!VAR_0->pquantizer && VAR_1[VAR_21 << VAR_0->left_blk_sh])
VAR_1[VAR_21 << VAR_0->left_blk_sh] += (VAR_1[VAR_21 << VAR_0->left_blk_sh] < 0) ? -VAR_5 : VAR_5;
}
} else {
for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {
VAR_1[VAR_21 << VAR_0->top_blk_sh] = ac_val2[VAR_21 + 8] * VAR_12;
if (!VAR_0->pquantizer && VAR_1[VAR_21 << VAR_0->top_blk_sh])
VAR_1[VAR_21 << VAR_0->top_blk_sh] += (VAR_1[VAR_21 << VAR_0->top_blk_sh] < 0) ? -VAR_5 : VAR_5;
}
}
VAR_7 = 63;
}
}
s->block_last_index[VAR_2] = VAR_7;
return 0;
}
| [
"static int FUNC_0(VC1Context *VAR_0, int16_t VAR_1[64], int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"GetBitContext *gb = &VAR_0->s.gb;",
"MpegEncContext *s = &VAR_0->s;",
"int VAR_6 = 0;",
"int VAR_7;",
"int16_t *dc_val;",
"int16_t *ac_val, *ac_val2;",
"int VAR_8;",
"int VAR_9 = VAR_0->VAR_9, VAR_10 = VAR_0->VAR_10;",
"int VAR_11 = s->ac_pred;",
"int VAR_12;",
"int VAR_13, VAR_14 = 0;",
"int VAR_15 = s->mb_x + s->mb_y * s->mb_stride;",
"if (VAR_2 < 4) {",
"VAR_8 = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"} else {",
"VAR_8 = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);",
"}",
"if (VAR_8 < 0) {",
"av_log(s->avctx, AV_LOG_ERROR, \"Illegal DC VLC\\VAR_2\");",
"return -1;",
"}",
"if (VAR_8) {",
"if (VAR_8 == 119 ) {",
"if (VAR_5 == 1) VAR_8 = get_bits(gb, 10);",
"else if (VAR_5 == 2) VAR_8 = get_bits(gb, 9);",
"else VAR_8 = get_bits(gb, 8);",
"} else {",
"if (VAR_5 == 1)\nVAR_8 = (VAR_8 << 2) + get_bits(gb, 2) - 3;",
"else if (VAR_5 == 2)\nVAR_8 = (VAR_8 << 1) + get_bits1(gb) - 1;",
"}",
"if (get_bits1(gb))\nVAR_8 = -VAR_8;",
"}",
"VAR_8 += vc1_pred_dc(&VAR_0->s, VAR_0->overlap, VAR_5, VAR_2, VAR_0->VAR_9, VAR_0->VAR_10, &dc_val, &VAR_6);",
"*dc_val = VAR_8;",
"if (VAR_2 < 4) {",
"VAR_1[0] = VAR_8 * s->y_dc_scale;",
"} else {",
"VAR_1[0] = VAR_8 * s->c_dc_scale;",
"}",
"VAR_7 = 1;",
"if (!VAR_9 && !VAR_10)\nVAR_11 = 0;",
"ac_val = s->ac_val[0][0] + s->block_index[VAR_2] * 16;",
"ac_val2 = ac_val;",
"VAR_12 = VAR_5 * 2 + ((VAR_5 == VAR_0->pq) ? VAR_0->halfpq : 0);",
"if (VAR_6)\nac_val -= 16;",
"else\nac_val -= 16 * s->block_wrap[VAR_2];",
"VAR_13 = s->current_picture.f.qscale_table[VAR_15];",
"if ( VAR_6 && VAR_10 && VAR_15)\nVAR_14 = s->current_picture.f.qscale_table[VAR_15 - 1];",
"if (!VAR_6 && VAR_9 && VAR_15 >= s->mb_stride)\nVAR_14 = s->current_picture.f.qscale_table[VAR_15 - s->mb_stride];",
"if ( VAR_6 && VAR_2 == 1)\nVAR_14 = VAR_13;",
"if (!VAR_6 && VAR_2 == 2)\nVAR_14 = VAR_13;",
"if (VAR_2 == 3)\nVAR_14 = VAR_13;",
"if (VAR_3) {",
"int VAR_16 = 0, VAR_17, VAR_18;",
"const uint8_t *VAR_19;",
"int VAR_21;",
"if (VAR_0->s.ac_pred) {",
"if (!VAR_11 && VAR_0->fcm == ILACE_FRAME) {",
"VAR_19 = VAR_0->zzi_8x8;",
"} else {",
"if (!VAR_6)\nVAR_19 = VAR_0->zz_8x8[2];",
"else\nVAR_19 = VAR_0->zz_8x8[3];",
"}",
"} else {",
"if (VAR_0->fcm != ILACE_FRAME)\nVAR_19 = VAR_0->zz_8x8[1];",
"else\nVAR_19 = VAR_0->zzi_8x8;",
"}",
"while (!VAR_16) {",
"vc1_decode_ac_coeff(VAR_0, &VAR_16, &VAR_17, &VAR_18, VAR_4);",
"VAR_7 += VAR_17;",
"if (VAR_7 > 63)\nbreak;",
"VAR_1[VAR_19[VAR_7++]] = VAR_18;",
"}",
"if (VAR_11) {",
"if (VAR_14 && VAR_13 != VAR_14) {",
"VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"if (VAR_13 < 1)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_6) {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"VAR_1[VAR_21 << VAR_0->left_blk_sh] += (ac_val[VAR_21] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;",
"} else {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"VAR_1[VAR_21 << VAR_0->top_blk_sh] += (ac_val[VAR_21 + 8] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;",
"}",
"} else {",
"if (VAR_6) {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"VAR_1[VAR_21 << VAR_0->left_blk_sh] += ac_val[VAR_21];",
"} else {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"VAR_1[VAR_21 << VAR_0->top_blk_sh] += ac_val[VAR_21 + 8];",
"}",
"}",
"}",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {",
"ac_val2[VAR_21 ] = VAR_1[VAR_21 << VAR_0->left_blk_sh];",
"ac_val2[VAR_21 + 8] = VAR_1[VAR_21 << VAR_0->top_blk_sh];",
"}",
"for (VAR_21 = 1; VAR_21 < 64; VAR_21++)",
"if (VAR_1[VAR_21]) {",
"VAR_1[VAR_21] *= VAR_12;",
"if (!VAR_0->pquantizer)\nVAR_1[VAR_21] += (VAR_1[VAR_21] < 0) ? -VAR_5 : VAR_5;",
"}",
"if (VAR_11) VAR_7 = 63;",
"} else {",
"int VAR_21;",
"memset(ac_val2, 0, 16 * 2);",
"if (VAR_6) {",
"if (VAR_11) {",
"memcpy(ac_val2, ac_val, 8 * 2);",
"if (VAR_14 && VAR_13 != VAR_14) {",
"VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"if (VAR_13 < 1)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"ac_val2[VAR_21] = (ac_val2[VAR_21] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;",
"}",
"}",
"} else {",
"if (VAR_11) {",
"memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);",
"if (VAR_14 && VAR_13 != VAR_14) {",
"VAR_13 = VAR_13 * 2 + ((VAR_13 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"VAR_14 = VAR_14 * 2 + ((VAR_14 == VAR_0->pq) ? VAR_0->halfpq : 0) - 1;",
"if (VAR_13 < 1)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++)",
"ac_val2[VAR_21 + 8] = (ac_val2[VAR_21 + 8] * VAR_14 * ff_vc1_dqscale[VAR_13 - 1] + 0x20000) >> 18;",
"}",
"}",
"}",
"if (VAR_11) {",
"if (VAR_6) {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {",
"VAR_1[VAR_21 << VAR_0->left_blk_sh] = ac_val2[VAR_21] * VAR_12;",
"if (!VAR_0->pquantizer && VAR_1[VAR_21 << VAR_0->left_blk_sh])\nVAR_1[VAR_21 << VAR_0->left_blk_sh] += (VAR_1[VAR_21 << VAR_0->left_blk_sh] < 0) ? -VAR_5 : VAR_5;",
"}",
"} else {",
"for (VAR_21 = 1; VAR_21 < 8; VAR_21++) {",
"VAR_1[VAR_21 << VAR_0->top_blk_sh] = ac_val2[VAR_21 + 8] * VAR_12;",
"if (!VAR_0->pquantizer && VAR_1[VAR_21 << VAR_0->top_blk_sh])\nVAR_1[VAR_21 << VAR_0->top_blk_sh] += (VAR_1[VAR_21 << VAR_0->top_blk_sh] < 0) ? -VAR_5 : VAR_5;",
"}",
"}",
"VAR_7 = 63;",
"}",
"}",
"s->block_last_index[VAR_2] = VAR_7;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77,
79
],
[
81
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
115,
117
],
[
119
],
[
121
],
[
125
],
[
129,
131
],
[
133,
135
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153,
155
],
[
157,
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185,
187
],
[
189
],
[
191
],
[
193,
195
],
[
197,
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
223
],
[
227
],
[
229
],
[
231
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
287
],
[
289
],
[
291
],
[
293,
295
],
[
297
],
[
301
],
[
303
],
[
305
],
[
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
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385,
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
403
],
[
405
]
] |
2,708 | static int crc_write_packet(struct AVFormatContext *s,
int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
CRCState *crc = s->priv_data;
crc->crcval = adler32(crc->crcval, buf, size);
return 0;
}
| false | FFmpeg | ee9f36a88eb3e2706ea659acb0ca80c414fa5d8a | static int crc_write_packet(struct AVFormatContext *s,
int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
CRCState *crc = s->priv_data;
crc->crcval = adler32(crc->crcval, buf, size);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct AVFormatContext *VAR_0,
int VAR_1,
const uint8_t *VAR_2, int VAR_3, int64_t VAR_4)
{
CRCState *crc = VAR_0->priv_data;
crc->crcval = adler32(crc->crcval, VAR_2, VAR_3);
return 0;
}
| [
"static int FUNC_0(struct AVFormatContext *VAR_0,\nint VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"CRCState *crc = VAR_0->priv_data;",
"crc->crcval = adler32(crc->crcval, VAR_2, VAR_3);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
2,709 | void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg)
{
}
| true | qemu | 8a0548f94edecb96acb9b7fb9106ccc821c4996f | void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg)
{
}
| {
"code": [
"void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg)"
],
"line_no": [
1
]
} | void FUNC_0(CPUState *VAR_0, struct kvm_guest_debug *VAR_1)
{
}
| [
"void FUNC_0(CPUState *VAR_0, struct kvm_guest_debug *VAR_1)\n{",
"}"
] | [
1,
0
] | [
[
1,
3
],
[
5
]
] |
2,710 | static void do_subtitle_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVSubtitle *sub)
{
int subtitle_out_max_size = 1024 * 1024;
int subtitle_out_size, nb, i;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (sub->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = ost->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size);
}
/* Note: DVB subtitle need one packet to draw them and one other
packet to clear them */
/* XXX: signal it in the codec context ? */
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
nb = 2;
else
nb = 1;
/* shift timestamp to honor -ss and make check_recording_time() work with -t */
pts = sub->pts;
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[ost->file_index]->start_time;
for (i = 0; i < nb; i++) {
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(ost))
return;
sub->pts = pts;
// start_display_time is required to be 0
sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
sub->end_display_time -= sub->start_display_time;
sub->start_display_time = 0;
if (i == 1)
sub->num_rects = 0;
ost->frames_encoded++;
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
subtitle_out_max_size, sub);
if (i == 1)
sub->num_rects = save_num_rects;
if (subtitle_out_size < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = subtitle_out_size;
pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
/* XXX: the pts correction is handled here. Maybe handling
it in the codec would be better */
if (i == 0)
pkt.pts += 90 * sub->start_display_time;
else
pkt.pts += 90 * sub->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(s, &pkt, ost);
}
} | true | FFmpeg | 36393434782b013ebacc8c30dd3c93531e2b197d | static void do_subtitle_out(AVFormatContext *s,
OutputStream *ost,
InputStream *ist,
AVSubtitle *sub)
{
int subtitle_out_max_size = 1024 * 1024;
int subtitle_out_size, nb, i;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (sub->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = ost->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size);
}
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
nb = 2;
else
nb = 1;
pts = sub->pts;
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[ost->file_index]->start_time;
for (i = 0; i < nb; i++) {
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(ost))
return;
sub->pts = pts;
sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
sub->end_display_time -= sub->start_display_time;
sub->start_display_time = 0;
if (i == 1)
sub->num_rects = 0;
ost->frames_encoded++;
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
subtitle_out_max_size, sub);
if (i == 1)
sub->num_rects = save_num_rects;
if (subtitle_out_size < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = subtitle_out_size;
pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
if (i == 0)
pkt.pts += 90 * sub->start_display_time;
else
pkt.pts += 90 * sub->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(s, &pkt, ost);
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0,
OutputStream *VAR_1,
InputStream *VAR_2,
AVSubtitle *VAR_3)
{
int VAR_4 = 1024 * 1024;
int VAR_5, VAR_6, VAR_7;
AVCodecContext *enc;
AVPacket pkt;
int64_t pts;
if (VAR_3->pts == AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
if (exit_on_error)
exit_program(1);
return;
}
enc = VAR_1->enc_ctx;
if (!subtitle_out) {
subtitle_out = av_malloc(VAR_4);
}
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
VAR_6 = 2;
else
VAR_6 = 1;
pts = VAR_3->pts;
if (output_files[VAR_1->file_index]->start_time != AV_NOPTS_VALUE)
pts -= output_files[VAR_1->file_index]->start_time;
for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) {
VAR_1->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
if (!check_recording_time(VAR_1))
return;
VAR_3->pts = pts;
VAR_3->pts += av_rescale_q(VAR_3->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);
VAR_3->end_display_time -= VAR_3->start_display_time;
VAR_3->start_display_time = 0;
if (VAR_7 == 1)
VAR_3->num_rects = 0;
VAR_1->frames_encoded++;
VAR_5 = avcodec_encode_subtitle(enc, subtitle_out,
VAR_4, VAR_3);
if (VAR_7 == 1)
VAR_3->num_rects = save_num_rects;
if (VAR_5 < 0) {
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
exit_program(1);
}
av_init_packet(&pkt);
pkt.data = subtitle_out;
pkt.size = VAR_5;
pkt.pts = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, VAR_1->st->time_base);
pkt.duration = av_rescale_q(VAR_3->end_display_time, (AVRational){ 1, 1000 }, VAR_1->st->time_base);
if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
if (VAR_7 == 0)
pkt.pts += 90 * VAR_3->start_display_time;
else
pkt.pts += 90 * VAR_3->end_display_time;
}
pkt.dts = pkt.pts;
write_frame(VAR_0, &pkt, VAR_1);
}
} | [
"static void FUNC_0(AVFormatContext *VAR_0,\nOutputStream *VAR_1,\nInputStream *VAR_2,\nAVSubtitle *VAR_3)\n{",
"int VAR_4 = 1024 * 1024;",
"int VAR_5, VAR_6, VAR_7;",
"AVCodecContext *enc;",
"AVPacket pkt;",
"int64_t pts;",
"if (VAR_3->pts == AV_NOPTS_VALUE) {",
"av_log(NULL, AV_LOG_ERROR, \"Subtitle packets must have a pts\\n\");",
"if (exit_on_error)\nexit_program(1);",
"return;",
"}",
"enc = VAR_1->enc_ctx;",
"if (!subtitle_out) {",
"subtitle_out = av_malloc(VAR_4);",
"}",
"if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)\nVAR_6 = 2;",
"else\nVAR_6 = 1;",
"pts = VAR_3->pts;",
"if (output_files[VAR_1->file_index]->start_time != AV_NOPTS_VALUE)\npts -= output_files[VAR_1->file_index]->start_time;",
"for (VAR_7 = 0; VAR_7 < VAR_6; VAR_7++) {",
"VAR_1->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);",
"if (!check_recording_time(VAR_1))\nreturn;",
"VAR_3->pts = pts;",
"VAR_3->pts += av_rescale_q(VAR_3->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q);",
"VAR_3->end_display_time -= VAR_3->start_display_time;",
"VAR_3->start_display_time = 0;",
"if (VAR_7 == 1)\nVAR_3->num_rects = 0;",
"VAR_1->frames_encoded++;",
"VAR_5 = avcodec_encode_subtitle(enc, subtitle_out,\nVAR_4, VAR_3);",
"if (VAR_7 == 1)\nVAR_3->num_rects = save_num_rects;",
"if (VAR_5 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Subtitle encoding failed\\n\");",
"exit_program(1);",
"}",
"av_init_packet(&pkt);",
"pkt.data = subtitle_out;",
"pkt.size = VAR_5;",
"pkt.pts = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, VAR_1->st->time_base);",
"pkt.duration = av_rescale_q(VAR_3->end_display_time, (AVRational){ 1, 1000 }, VAR_1->st->time_base);",
"if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {",
"if (VAR_7 == 0)\npkt.pts += 90 * VAR_3->start_display_time;",
"else\npkt.pts += 90 * VAR_3->end_display_time;",
"}",
"pkt.dts = pkt.pts;",
"write_frame(VAR_0, &pkt, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
24,
25
],
[
26,
27
],
[
29
],
[
30,
31
],
[
32
],
[
33
],
[
34,
35
],
[
36
],
[
38
],
[
39
],
[
40
],
[
41,
42
],
[
43
],
[
44,
45
],
[
46,
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57
],
[
60,
61
],
[
62,
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
]
] |
2,711 | static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr)
{
UHCIState *s = opaque;
uint32_t val;
addr &= 0x1f;
switch(addr) {
case 0x00:
val = s->cmd;
break;
case 0x02:
val = s->status;
break;
case 0x04:
val = s->intr;
break;
case 0x06:
val = s->frnum;
break;
case 0x10 ... 0x1f:
{
UHCIPort *port;
int n;
n = (addr >> 1) & 7;
if (n >= NB_PORTS)
goto read_default;
port = &s->ports[n];
val = port->ctrl;
}
break;
default:
read_default:
val = 0xff7f; /* disabled port */
break;
}
#ifdef DEBUG
printf("uhci readw port=0x%04x val=0x%04x\n", addr, val);
#endif
return val;
}
| false | qemu | 54f254f973a1b2ed0f3571390f4de060adfe23e8 | static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr)
{
UHCIState *s = opaque;
uint32_t val;
addr &= 0x1f;
switch(addr) {
case 0x00:
val = s->cmd;
break;
case 0x02:
val = s->status;
break;
case 0x04:
val = s->intr;
break;
case 0x06:
val = s->frnum;
break;
case 0x10 ... 0x1f:
{
UHCIPort *port;
int n;
n = (addr >> 1) & 7;
if (n >= NB_PORTS)
goto read_default;
port = &s->ports[n];
val = port->ctrl;
}
break;
default:
read_default:
val = 0xff7f;
break;
}
#ifdef DEBUG
printf("uhci readw port=0x%04x val=0x%04x\n", addr, val);
#endif
return val;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, uint32_t addr)
{
UHCIState *s = opaque;
uint32_t val;
addr &= 0x1f;
switch(addr) {
case 0x00:
val = s->cmd;
break;
case 0x02:
val = s->status;
break;
case 0x04:
val = s->intr;
break;
case 0x06:
val = s->frnum;
break;
case 0x10 ... 0x1f:
{
UHCIPort *port;
int VAR_0;
VAR_0 = (addr >> 1) & 7;
if (VAR_0 >= NB_PORTS)
goto read_default;
port = &s->ports[VAR_0];
val = port->ctrl;
}
break;
default:
read_default:
val = 0xff7f;
break;
}
#ifdef DEBUG
printf("uhci readw port=0x%04x val=0x%04x\VAR_0", addr, val);
#endif
return val;
}
| [
"static uint32_t FUNC_0(void *opaque, uint32_t addr)\n{",
"UHCIState *s = opaque;",
"uint32_t val;",
"addr &= 0x1f;",
"switch(addr) {",
"case 0x00:\nval = s->cmd;",
"break;",
"case 0x02:\nval = s->status;",
"break;",
"case 0x04:\nval = s->intr;",
"break;",
"case 0x06:\nval = s->frnum;",
"break;",
"case 0x10 ... 0x1f:\n{",
"UHCIPort *port;",
"int VAR_0;",
"VAR_0 = (addr >> 1) & 7;",
"if (VAR_0 >= NB_PORTS)\ngoto read_default;",
"port = &s->ports[VAR_0];",
"val = port->ctrl;",
"}",
"break;",
"default:\nread_default:\nval = 0xff7f;",
"break;",
"}",
"#ifdef DEBUG\nprintf(\"uhci readw port=0x%04x val=0x%04x\\VAR_0\", addr, val);",
"#endif\nreturn val;",
"}"
] | [
0,
0,
0,
0,
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
]
] |
2,712 | cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
{
CACPKIAppletData *pki_applet_data = NULL;
if (applet_private == NULL) {
return;
}
pki_applet_data = &(applet_private->u.pki_data);
if (pki_applet_data->cert != NULL) {
g_free(pki_applet_data->cert);
}
if (pki_applet_data->sign_buffer != NULL) {
g_free(pki_applet_data->sign_buffer);
}
if (pki_applet_data->key != NULL) {
vcard_emul_delete_key(pki_applet_data->key);
}
g_free(applet_private);
}
| false | qemu | 1687a089f103f9b7a1b4a1555068054cb46ee9e9 | cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
{
CACPKIAppletData *pki_applet_data = NULL;
if (applet_private == NULL) {
return;
}
pki_applet_data = &(applet_private->u.pki_data);
if (pki_applet_data->cert != NULL) {
g_free(pki_applet_data->cert);
}
if (pki_applet_data->sign_buffer != NULL) {
g_free(pki_applet_data->sign_buffer);
}
if (pki_applet_data->key != NULL) {
vcard_emul_delete_key(pki_applet_data->key);
}
g_free(applet_private);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VCardAppletPrivate *VAR_0)
{
CACPKIAppletData *pki_applet_data = NULL;
if (VAR_0 == NULL) {
return;
}
pki_applet_data = &(VAR_0->u.pki_data);
if (pki_applet_data->cert != NULL) {
g_free(pki_applet_data->cert);
}
if (pki_applet_data->sign_buffer != NULL) {
g_free(pki_applet_data->sign_buffer);
}
if (pki_applet_data->key != NULL) {
vcard_emul_delete_key(pki_applet_data->key);
}
g_free(VAR_0);
}
| [
"FUNC_0(VCardAppletPrivate *VAR_0)\n{",
"CACPKIAppletData *pki_applet_data = NULL;",
"if (VAR_0 == NULL) {",
"return;",
"}",
"pki_applet_data = &(VAR_0->u.pki_data);",
"if (pki_applet_data->cert != NULL) {",
"g_free(pki_applet_data->cert);",
"}",
"if (pki_applet_data->sign_buffer != NULL) {",
"g_free(pki_applet_data->sign_buffer);",
"}",
"if (pki_applet_data->key != NULL) {",
"vcard_emul_delete_key(pki_applet_data->key);",
"}",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
2,714 | static void cpu_handle_debug_exception(CPUState *env)
{
CPUWatchpoint *wp;
if (!env->watchpoint_hit)
TAILQ_FOREACH(wp, &env->watchpoints, entry)
wp->flags &= ~BP_WATCHPOINT_HIT;
if (debug_excp_handler)
debug_excp_handler(env);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void cpu_handle_debug_exception(CPUState *env)
{
CPUWatchpoint *wp;
if (!env->watchpoint_hit)
TAILQ_FOREACH(wp, &env->watchpoints, entry)
wp->flags &= ~BP_WATCHPOINT_HIT;
if (debug_excp_handler)
debug_excp_handler(env);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUState *VAR_0)
{
CPUWatchpoint *wp;
if (!VAR_0->watchpoint_hit)
TAILQ_FOREACH(wp, &VAR_0->watchpoints, entry)
wp->flags &= ~BP_WATCHPOINT_HIT;
if (debug_excp_handler)
debug_excp_handler(VAR_0);
}
| [
"static void FUNC_0(CPUState *VAR_0)\n{",
"CPUWatchpoint *wp;",
"if (!VAR_0->watchpoint_hit)\nTAILQ_FOREACH(wp, &VAR_0->watchpoints, entry)\nwp->flags &= ~BP_WATCHPOINT_HIT;",
"if (debug_excp_handler)\ndebug_excp_handler(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13
],
[
17,
19
],
[
21
]
] |
2,715 | static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int64_t count, int flags, int64_t *total)
{
Coroutine *co;
CoWriteZeroes data = {
.blk = blk,
.offset = offset,
.count = count,
.total = total,
.flags = flags,
.done = false,
};
if (count >> BDRV_SECTOR_BITS > INT_MAX) {
return -ERANGE;
}
co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data);
qemu_coroutine_enter(co);
while (!data.done) {
aio_poll(blk_get_aio_context(blk), true);
}
if (data.ret < 0) {
return data.ret;
} else {
return 1;
}
}
| false | qemu | a367467995d0528fe591d87ca2e437c7b7d7951b | static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int64_t count, int flags, int64_t *total)
{
Coroutine *co;
CoWriteZeroes data = {
.blk = blk,
.offset = offset,
.count = count,
.total = total,
.flags = flags,
.done = false,
};
if (count >> BDRV_SECTOR_BITS > INT_MAX) {
return -ERANGE;
}
co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data);
qemu_coroutine_enter(co);
while (!data.done) {
aio_poll(blk_get_aio_context(blk), true);
}
if (data.ret < 0) {
return data.ret;
} else {
return 1;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockBackend *VAR_0, int64_t VAR_1,
int64_t VAR_2, int VAR_3, int64_t *VAR_4)
{
Coroutine *co;
CoWriteZeroes data = {
.VAR_0 = VAR_0,
.VAR_1 = VAR_1,
.VAR_2 = VAR_2,
.VAR_4 = VAR_4,
.VAR_3 = VAR_3,
.done = false,
};
if (VAR_2 >> BDRV_SECTOR_BITS > INT_MAX) {
return -ERANGE;
}
co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data);
qemu_coroutine_enter(co);
while (!data.done) {
aio_poll(blk_get_aio_context(VAR_0), true);
}
if (data.ret < 0) {
return data.ret;
} else {
return 1;
}
}
| [
"static int FUNC_0(BlockBackend *VAR_0, int64_t VAR_1,\nint64_t VAR_2, int VAR_3, int64_t *VAR_4)\n{",
"Coroutine *co;",
"CoWriteZeroes data = {",
".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_4 = VAR_4,\n.VAR_3 = VAR_3,\n.done = false,\n};",
"if (VAR_2 >> BDRV_SECTOR_BITS > INT_MAX) {",
"return -ERANGE;",
"}",
"co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data);",
"qemu_coroutine_enter(co);",
"while (!data.done) {",
"aio_poll(blk_get_aio_context(VAR_0), true);",
"}",
"if (data.ret < 0) {",
"return data.ret;",
"} else {",
"return 1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13,
15,
17,
19,
21,
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
2,716 | static inline void cow_set_bits(uint8_t *bitmap, int start, int64_t nb_sectors)
{
int64_t bitnum = start, last = start + nb_sectors;
while (bitnum < last) {
if ((bitnum & 7) == 0 && bitnum + 8 <= last) {
bitmap[bitnum / 8] = 0xFF;
bitnum += 8;
continue;
}
bitmap[bitnum/8] |= (1 << (bitnum % 8));
bitnum++;
}
}
| false | qemu | 550830f9351291c585c963204ad9127998b1c1ce | static inline void cow_set_bits(uint8_t *bitmap, int start, int64_t nb_sectors)
{
int64_t bitnum = start, last = start + nb_sectors;
while (bitnum < last) {
if ((bitnum & 7) == 0 && bitnum + 8 <= last) {
bitmap[bitnum / 8] = 0xFF;
bitnum += 8;
continue;
}
bitmap[bitnum/8] |= (1 << (bitnum % 8));
bitnum++;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, int64_t VAR_2)
{
int64_t bitnum = VAR_1, last = VAR_1 + VAR_2;
while (bitnum < last) {
if ((bitnum & 7) == 0 && bitnum + 8 <= last) {
VAR_0[bitnum / 8] = 0xFF;
bitnum += 8;
continue;
}
VAR_0[bitnum/8] |= (1 << (bitnum % 8));
bitnum++;
}
}
| [
"static inline void FUNC_0(uint8_t *VAR_0, int VAR_1, int64_t VAR_2)\n{",
"int64_t bitnum = VAR_1, last = VAR_1 + VAR_2;",
"while (bitnum < last) {",
"if ((bitnum & 7) == 0 && bitnum + 8 <= last) {",
"VAR_0[bitnum / 8] = 0xFF;",
"bitnum += 8;",
"continue;",
"}",
"VAR_0[bitnum/8] |= (1 << (bitnum % 8));",
"bitnum++;",
"}",
"}"
] | [
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
]
] |
2,717 | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret, open_flags;
char tmp_filename[PATH_MAX];
char backing_filename[PATH_MAX];
bs->is_temporary = 0;
bs->encrypted = 0;
bs->valid_key = 0;
/* buffer_alignment defaulted to 512, drivers can change this value */
bs->buffer_alignment = 512;
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
/* if there is a backing file, use it */
bs1 = bdrv_new("");
ret = bdrv_open2(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
}
total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
/* Real path is meaningless for protocols */
if (is_protocol)
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
else if (!realpath(filename, backing_filename))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (flags & BDRV_O_FILE) {
drv = find_protocol(filename);
} else if (!drv) {
drv = find_hdev_driver(filename);
if (!drv) {
drv = find_image_format(filename);
}
}
if (!drv) {
ret = -ENOENT;
goto unlink_and_fail;
}
bs->drv = drv;
bs->opaque = qemu_mallocz(drv->instance_size);
/*
* Yes, BDRV_O_NOCACHE aka O_DIRECT means we have to present a
* write cache to the guest. We do need the fdatasync to flush
* out transactions for block allocations, and we maybe have a
* volatile write cache in our backing device to deal with.
*/
if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
bs->enable_write_cache = 1;
bs->read_only = (flags & BDRV_O_RDWR) == 0;
if (!(flags & BDRV_O_FILE)) {
open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
if (bs->is_temporary) { /* snapshot should be writeable */
open_flags |= BDRV_O_RDWR;
}
} else {
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
}
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
ret = -ENOTSUP;
} else {
ret = drv->bdrv_open(bs, filename, open_flags);
}
if (ret < 0) {
qemu_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
unlink_and_fail:
if (bs->is_temporary)
unlink(filename);
return ret;
}
if (drv->bdrv_getlength) {
bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
/* if there is a backing file, use it */
BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);
if (bs->backing_format[0] != '\0')
back_drv = bdrv_find_format(bs->backing_format);
ret = bdrv_open2(bs->backing_hd, backing_filename, open_flags,
back_drv);
bs->backing_hd->read_only = (open_flags & BDRV_O_RDWR) == 0;
if (ret < 0) {
bdrv_close(bs);
return ret;
}
}
if (!bdrv_key_required(bs)) {
/* call the change callback */
bs->media_changed = 1;
if (bs->change_cb)
bs->change_cb(bs->change_opaque);
}
return 0;
}
| false | qemu | 6987307ca30aead67e8545934186c92f942710f6 | int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
BlockDriver *drv)
{
int ret, open_flags;
char tmp_filename[PATH_MAX];
char backing_filename[PATH_MAX];
bs->is_temporary = 0;
bs->encrypted = 0;
bs->valid_key = 0;
bs->buffer_alignment = 512;
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
bs1 = bdrv_new("");
ret = bdrv_open2(bs1, filename, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
return ret;
}
total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (is_protocol)
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
else if (!realpath(filename, backing_filename))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
if (ret < 0) {
return ret;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
pstrcpy(bs->filename, sizeof(bs->filename), filename);
if (flags & BDRV_O_FILE) {
drv = find_protocol(filename);
} else if (!drv) {
drv = find_hdev_driver(filename);
if (!drv) {
drv = find_image_format(filename);
}
}
if (!drv) {
ret = -ENOENT;
goto unlink_and_fail;
}
bs->drv = drv;
bs->opaque = qemu_mallocz(drv->instance_size);
if (flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
bs->enable_write_cache = 1;
bs->read_only = (flags & BDRV_O_RDWR) == 0;
if (!(flags & BDRV_O_FILE)) {
open_flags = (flags & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
if (bs->is_temporary) {
open_flags |= BDRV_O_RDWR;
}
} else {
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
}
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
ret = -ENOTSUP;
} else {
ret = drv->bdrv_open(bs, filename, open_flags);
}
if (ret < 0) {
qemu_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
unlink_and_fail:
if (bs->is_temporary)
unlink(filename);
return ret;
}
if (drv->bdrv_getlength) {
bs->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
}
#ifndef _WIN32
if (bs->is_temporary) {
unlink(filename);
}
#endif
if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
BlockDriver *back_drv = NULL;
bs->backing_hd = bdrv_new("");
path_combine(backing_filename, sizeof(backing_filename),
filename, bs->backing_file);
if (bs->backing_format[0] != '\0')
back_drv = bdrv_find_format(bs->backing_format);
ret = bdrv_open2(bs->backing_hd, backing_filename, open_flags,
back_drv);
bs->backing_hd->read_only = (open_flags & BDRV_O_RDWR) == 0;
if (ret < 0) {
bdrv_close(bs);
return ret;
}
}
if (!bdrv_key_required(bs)) {
bs->media_changed = 1;
if (bs->change_cb)
bs->change_cb(bs->change_opaque);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2,
BlockDriver *VAR_3)
{
int VAR_4, VAR_5;
char VAR_6[PATH_MAX];
char VAR_7[PATH_MAX];
VAR_0->is_temporary = 0;
VAR_0->encrypted = 0;
VAR_0->valid_key = 0;
VAR_0->buffer_alignment = 512;
if (VAR_2 & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int VAR_8 = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
bs1 = bdrv_new("");
VAR_4 = FUNC_0(bs1, VAR_1, 0, VAR_3);
if (VAR_4 < 0) {
bdrv_delete(bs1);
return VAR_4;
}
total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS;
if (bs1->VAR_3 && bs1->VAR_3->protocol_name)
VAR_8 = 1;
bdrv_delete(bs1);
get_tmp_filename(VAR_6, sizeof(VAR_6));
if (VAR_8)
snprintf(VAR_7, sizeof(VAR_7),
"%s", VAR_1);
else if (!realpath(VAR_1, VAR_7))
return -errno;
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, VAR_7);
if (VAR_3) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
VAR_3->format_name);
}
VAR_4 = bdrv_create(bdrv_qcow2, VAR_6, options);
if (VAR_4 < 0) {
return VAR_4;
}
VAR_1 = VAR_6;
VAR_3 = bdrv_qcow2;
VAR_0->is_temporary = 1;
}
pstrcpy(VAR_0->VAR_1, sizeof(VAR_0->VAR_1), VAR_1);
if (VAR_2 & BDRV_O_FILE) {
VAR_3 = find_protocol(VAR_1);
} else if (!VAR_3) {
VAR_3 = find_hdev_driver(VAR_1);
if (!VAR_3) {
VAR_3 = find_image_format(VAR_1);
}
}
if (!VAR_3) {
VAR_4 = -ENOENT;
goto unlink_and_fail;
}
VAR_0->VAR_3 = VAR_3;
VAR_0->opaque = qemu_mallocz(VAR_3->instance_size);
if (VAR_2 & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))
VAR_0->enable_write_cache = 1;
VAR_0->read_only = (VAR_2 & BDRV_O_RDWR) == 0;
if (!(VAR_2 & BDRV_O_FILE)) {
VAR_5 = (VAR_2 & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
if (VAR_0->is_temporary) {
VAR_5 |= BDRV_O_RDWR;
}
} else {
VAR_5 = VAR_2 & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
}
if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_3)) {
VAR_4 = -ENOTSUP;
} else {
VAR_4 = VAR_3->bdrv_open(VAR_0, VAR_1, VAR_5);
}
if (VAR_4 < 0) {
qemu_free(VAR_0->opaque);
VAR_0->opaque = NULL;
VAR_0->VAR_3 = NULL;
unlink_and_fail:
if (VAR_0->is_temporary)
unlink(VAR_1);
return VAR_4;
}
if (VAR_3->bdrv_getlength) {
VAR_0->total_sectors = bdrv_getlength(VAR_0) >> BDRV_SECTOR_BITS;
}
#ifndef _WIN32
if (VAR_0->is_temporary) {
unlink(VAR_1);
}
#endif
if ((VAR_2 & BDRV_O_NO_BACKING) == 0 && VAR_0->backing_file[0] != '\0') {
BlockDriver *back_drv = NULL;
VAR_0->backing_hd = bdrv_new("");
path_combine(VAR_7, sizeof(VAR_7),
VAR_1, VAR_0->backing_file);
if (VAR_0->backing_format[0] != '\0')
back_drv = bdrv_find_format(VAR_0->backing_format);
VAR_4 = FUNC_0(VAR_0->backing_hd, VAR_7, VAR_5,
back_drv);
VAR_0->backing_hd->read_only = (VAR_5 & BDRV_O_RDWR) == 0;
if (VAR_4 < 0) {
bdrv_close(VAR_0);
return VAR_4;
}
}
if (!bdrv_key_required(VAR_0)) {
VAR_0->media_changed = 1;
if (VAR_0->change_cb)
VAR_0->change_cb(VAR_0->change_opaque);
}
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2,\nBlockDriver *VAR_3)\n{",
"int VAR_4, VAR_5;",
"char VAR_6[PATH_MAX];",
"char VAR_7[PATH_MAX];",
"VAR_0->is_temporary = 0;",
"VAR_0->encrypted = 0;",
"VAR_0->valid_key = 0;",
"VAR_0->buffer_alignment = 512;",
"if (VAR_2 & BDRV_O_SNAPSHOT) {",
"BlockDriverState *bs1;",
"int64_t total_size;",
"int VAR_8 = 0;",
"BlockDriver *bdrv_qcow2;",
"QEMUOptionParameter *options;",
"bs1 = bdrv_new(\"\");",
"VAR_4 = FUNC_0(bs1, VAR_1, 0, VAR_3);",
"if (VAR_4 < 0) {",
"bdrv_delete(bs1);",
"return VAR_4;",
"}",
"total_size = bdrv_getlength(bs1) >> BDRV_SECTOR_BITS;",
"if (bs1->VAR_3 && bs1->VAR_3->protocol_name)\nVAR_8 = 1;",
"bdrv_delete(bs1);",
"get_tmp_filename(VAR_6, sizeof(VAR_6));",
"if (VAR_8)\nsnprintf(VAR_7, sizeof(VAR_7),\n\"%s\", VAR_1);",
"else if (!realpath(VAR_1, VAR_7))\nreturn -errno;",
"bdrv_qcow2 = bdrv_find_format(\"qcow2\");",
"options = parse_option_parameters(\"\", bdrv_qcow2->create_options, NULL);",
"set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);",
"set_option_parameter(options, BLOCK_OPT_BACKING_FILE, VAR_7);",
"if (VAR_3) {",
"set_option_parameter(options, BLOCK_OPT_BACKING_FMT,\nVAR_3->format_name);",
"}",
"VAR_4 = bdrv_create(bdrv_qcow2, VAR_6, options);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"VAR_1 = VAR_6;",
"VAR_3 = bdrv_qcow2;",
"VAR_0->is_temporary = 1;",
"}",
"pstrcpy(VAR_0->VAR_1, sizeof(VAR_0->VAR_1), VAR_1);",
"if (VAR_2 & BDRV_O_FILE) {",
"VAR_3 = find_protocol(VAR_1);",
"} else if (!VAR_3) {",
"VAR_3 = find_hdev_driver(VAR_1);",
"if (!VAR_3) {",
"VAR_3 = find_image_format(VAR_1);",
"}",
"}",
"if (!VAR_3) {",
"VAR_4 = -ENOENT;",
"goto unlink_and_fail;",
"}",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->opaque = qemu_mallocz(VAR_3->instance_size);",
"if (VAR_2 & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))\nVAR_0->enable_write_cache = 1;",
"VAR_0->read_only = (VAR_2 & BDRV_O_RDWR) == 0;",
"if (!(VAR_2 & BDRV_O_FILE)) {",
"VAR_5 = (VAR_2 & (BDRV_O_RDWR | BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));",
"if (VAR_0->is_temporary) {",
"VAR_5 |= BDRV_O_RDWR;",
"}",
"} else {",
"VAR_5 = VAR_2 & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);",
"}",
"if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_3)) {",
"VAR_4 = -ENOTSUP;",
"} else {",
"VAR_4 = VAR_3->bdrv_open(VAR_0, VAR_1, VAR_5);",
"}",
"if (VAR_4 < 0) {",
"qemu_free(VAR_0->opaque);",
"VAR_0->opaque = NULL;",
"VAR_0->VAR_3 = NULL;",
"unlink_and_fail:\nif (VAR_0->is_temporary)\nunlink(VAR_1);",
"return VAR_4;",
"}",
"if (VAR_3->bdrv_getlength) {",
"VAR_0->total_sectors = bdrv_getlength(VAR_0) >> BDRV_SECTOR_BITS;",
"}",
"#ifndef _WIN32\nif (VAR_0->is_temporary) {",
"unlink(VAR_1);",
"}",
"#endif\nif ((VAR_2 & BDRV_O_NO_BACKING) == 0 && VAR_0->backing_file[0] != '\\0') {",
"BlockDriver *back_drv = NULL;",
"VAR_0->backing_hd = bdrv_new(\"\");",
"path_combine(VAR_7, sizeof(VAR_7),\nVAR_1, VAR_0->backing_file);",
"if (VAR_0->backing_format[0] != '\\0')\nback_drv = bdrv_find_format(VAR_0->backing_format);",
"VAR_4 = FUNC_0(VAR_0->backing_hd, VAR_7, VAR_5,\nback_drv);",
"VAR_0->backing_hd->read_only = (VAR_5 & BDRV_O_RDWR) == 0;",
"if (VAR_4 < 0) {",
"bdrv_close(VAR_0);",
"return VAR_4;",
"}",
"}",
"if (!bdrv_key_required(VAR_0)) {",
"VAR_0->media_changed = 1;",
"if (VAR_0->change_cb)\nVAR_0->change_cb(VAR_0->change_opaque);",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
71
],
[
75
],
[
81,
83,
85
],
[
87,
89
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
177,
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219,
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243,
245
],
[
249
],
[
251
],
[
253,
255
],
[
257,
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
283
],
[
285,
287
],
[
289
],
[
291
],
[
293
]
] |
2,718 | milkymist_init(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
int kernel_size;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
qemu_irq irq[32], *cpu_irq;
int i;
char *bios_filename;
ResetInfo *reset_info;
/* memory map */
target_phys_addr_t flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
target_phys_addr_t sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
target_phys_addr_t initrd_base = sdram_base + 0x1002000;
target_phys_addr_t cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
}
cpu = cpu_lm32_init(cpu_model);
env = &cpu->env;
reset_info->cpu = cpu;
cpu_lm32_set_phys_msb_ignore(env, 1);
memory_region_init_ram(phys_sdram, "milkymist.sdram", sdram_size);
vmstate_register_ram_global(phys_sdram);
memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
dinfo = drive_get(IF_PFLASH, 0, 0);
/* Numonyx JS28F256J3F105 */
pflash_cfi01_register(flash_base, NULL, "milkymist.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 2,
0x00, 0x89, 0x00, 0x1d, 1);
/* create irq lines */
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, env, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
/* load bios rom */
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename) {
load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
}
reset_info->bootstrap_pc = BIOS_OFFSET;
/* if no kernel is given no valid bios rom is a fatal error */
if (!kernel_filename && !dinfo && !bios_filename) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
exit(1);
}
milkymist_uart_create(0x60000000, irq[0]);
milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],
80000000, 0x10014d31, 0x0000041f, 0x00000001);
milkymist_hpdmc_create(0x60002000);
milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff);
milkymist_memcard_create(0x60004000);
milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);
milkymist_pfpu_create(0x60006000, irq[8]);
milkymist_tmu2_create(0x60007000, irq[9]);
milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);
milkymist_softusb_create(0x6000f000, irq[15],
0x20000000, 0x1000, 0x20020000, 0x2000);
/* make sure juart isn't the first chardev */
env->juart_state = lm32_juart_init();
if (kernel_filename) {
uint64_t entry;
/* Boots a kernel elf binary. */
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, sdram_base,
sdram_size);
reset_info->bootstrap_pc = sdram_base;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = (uint32_t)cmdline_base;
}
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = (uint32_t)initrd_base;
reset_info->initrd_size = (uint32_t)initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | milkymist_init(QEMUMachineInitArgs *args)
{
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
int kernel_size;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
qemu_irq irq[32], *cpu_irq;
int i;
char *bios_filename;
ResetInfo *reset_info;
target_phys_addr_t flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
target_phys_addr_t sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
target_phys_addr_t initrd_base = sdram_base + 0x1002000;
target_phys_addr_t cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (cpu_model == NULL) {
cpu_model = "lm32-full";
}
cpu = cpu_lm32_init(cpu_model);
env = &cpu->env;
reset_info->cpu = cpu;
cpu_lm32_set_phys_msb_ignore(env, 1);
memory_region_init_ram(phys_sdram, "milkymist.sdram", sdram_size);
vmstate_register_ram_global(phys_sdram);
memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(flash_base, NULL, "milkymist.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 2,
0x00, 0x89, 0x00, 0x1d, 1);
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, env, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (i = 0; i < 32; i++) {
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename) {
load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
}
reset_info->bootstrap_pc = BIOS_OFFSET;
if (!kernel_filename && !dinfo && !bios_filename) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
exit(1);
}
milkymist_uart_create(0x60000000, irq[0]);
milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],
80000000, 0x10014d31, 0x0000041f, 0x00000001);
milkymist_hpdmc_create(0x60002000);
milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff);
milkymist_memcard_create(0x60004000);
milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);
milkymist_pfpu_create(0x60006000, irq[8]);
milkymist_tmu2_create(0x60007000, irq[9]);
milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);
milkymist_softusb_create(0x6000f000, irq[15],
0x20000000, 0x1000, 0x20020000, 0x2000);
env->juart_state = lm32_juart_init();
if (kernel_filename) {
uint64_t entry;
kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (kernel_size < 0) {
kernel_size = load_image_targphys(kernel_filename, sdram_base,
sdram_size);
reset_info->bootstrap_pc = sdram_base;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
}
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
kernel_cmdline);
reset_info->cmdline_base = (uint32_t)cmdline_base;
}
if (initrd_filename) {
size_t initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
reset_info->initrd_base = (uint32_t)initrd_base;
reset_info->initrd_size = (uint32_t)initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| {
"code": [],
"line_no": []
} | FUNC_0(QEMUMachineInitArgs *VAR_0)
{
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
LM32CPU *cpu;
CPULM32State *env;
int VAR_5;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
qemu_irq irq[32], *cpu_irq;
int VAR_6;
char *VAR_7;
ResetInfo *reset_info;
target_phys_addr_t flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
target_phys_addr_t sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
target_phys_addr_t initrd_base = sdram_base + 0x1002000;
target_phys_addr_t cmdline_base = sdram_base + 0x1000000;
size_t initrd_max = sdram_size - 0x1002000;
reset_info = g_malloc0(sizeof(ResetInfo));
if (VAR_1 == NULL) {
VAR_1 = "lm32-full";
}
cpu = cpu_lm32_init(VAR_1);
env = &cpu->env;
reset_info->cpu = cpu;
cpu_lm32_set_phys_msb_ignore(env, 1);
memory_region_init_ram(phys_sdram, "milkymist.sdram", sdram_size);
vmstate_register_ram_global(phys_sdram);
memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(flash_base, NULL, "milkymist.flash", flash_size,
dinfo ? dinfo->bdrv : NULL, flash_sector_size,
flash_size / flash_sector_size, 2,
0x00, 0x89, 0x00, 0x1d, 1);
cpu_irq = qemu_allocate_irqs(cpu_irq_handler, env, 1);
env->pic_state = lm32_pic_init(*cpu_irq);
for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {
irq[VAR_6] = qdev_get_gpio_in(env->pic_state, VAR_6);
}
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
VAR_7 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_7) {
load_image_targphys(VAR_7, BIOS_OFFSET, BIOS_SIZE);
}
reset_info->bootstrap_pc = BIOS_OFFSET;
if (!VAR_2 && !dinfo && !VAR_7) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
exit(1);
}
milkymist_uart_create(0x60000000, irq[0]);
milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],
80000000, 0x10014d31, 0x0000041f, 0x00000001);
milkymist_hpdmc_create(0x60002000);
milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff);
milkymist_memcard_create(0x60004000);
milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);
milkymist_pfpu_create(0x60006000, irq[8]);
milkymist_tmu2_create(0x60007000, irq[9]);
milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);
milkymist_softusb_create(0x6000f000, irq[15],
0x20000000, 0x1000, 0x20020000, 0x2000);
env->juart_state = lm32_juart_init();
if (VAR_2) {
uint64_t entry;
VAR_5 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
reset_info->bootstrap_pc = entry;
if (VAR_5 < 0) {
VAR_5 = load_image_targphys(VAR_2, sdram_base,
sdram_size);
reset_info->bootstrap_pc = sdram_base;
}
if (VAR_5 < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_2);
exit(1);
}
}
if (VAR_3 && strlen(VAR_3)) {
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
VAR_3);
reset_info->cmdline_base = (uint32_t)cmdline_base;
}
if (VAR_4) {
size_t initrd_size;
initrd_size = load_image_targphys(VAR_4, initrd_base,
initrd_max);
reset_info->initrd_base = (uint32_t)initrd_base;
reset_info->initrd_size = (uint32_t)initrd_size;
}
qemu_register_reset(main_cpu_reset, reset_info);
}
| [
"FUNC_0(QEMUMachineInitArgs *VAR_0)\n{",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"LM32CPU *cpu;",
"CPULM32State *env;",
"int VAR_5;",
"DriveInfo *dinfo;",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);",
"qemu_irq irq[32], *cpu_irq;",
"int VAR_6;",
"char *VAR_7;",
"ResetInfo *reset_info;",
"target_phys_addr_t flash_base = 0x00000000;",
"size_t flash_sector_size = 128 * 1024;",
"size_t flash_size = 32 * 1024 * 1024;",
"target_phys_addr_t sdram_base = 0x40000000;",
"size_t sdram_size = 128 * 1024 * 1024;",
"target_phys_addr_t initrd_base = sdram_base + 0x1002000;",
"target_phys_addr_t cmdline_base = sdram_base + 0x1000000;",
"size_t initrd_max = sdram_size - 0x1002000;",
"reset_info = g_malloc0(sizeof(ResetInfo));",
"if (VAR_1 == NULL) {",
"VAR_1 = \"lm32-full\";",
"}",
"cpu = cpu_lm32_init(VAR_1);",
"env = &cpu->env;",
"reset_info->cpu = cpu;",
"cpu_lm32_set_phys_msb_ignore(env, 1);",
"memory_region_init_ram(phys_sdram, \"milkymist.sdram\", sdram_size);",
"vmstate_register_ram_global(phys_sdram);",
"memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);",
"dinfo = drive_get(IF_PFLASH, 0, 0);",
"pflash_cfi01_register(flash_base, NULL, \"milkymist.flash\", flash_size,\ndinfo ? dinfo->bdrv : NULL, flash_sector_size,\nflash_size / flash_sector_size, 2,\n0x00, 0x89, 0x00, 0x1d, 1);",
"cpu_irq = qemu_allocate_irqs(cpu_irq_handler, env, 1);",
"env->pic_state = lm32_pic_init(*cpu_irq);",
"for (VAR_6 = 0; VAR_6 < 32; VAR_6++) {",
"irq[VAR_6] = qdev_get_gpio_in(env->pic_state, VAR_6);",
"}",
"if (bios_name == NULL) {",
"bios_name = BIOS_FILENAME;",
"}",
"VAR_7 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_7) {",
"load_image_targphys(VAR_7, BIOS_OFFSET, BIOS_SIZE);",
"}",
"reset_info->bootstrap_pc = BIOS_OFFSET;",
"if (!VAR_2 && !dinfo && !VAR_7) {",
"fprintf(stderr, \"qemu: could not load Milkymist One bios '%s'\\n\",\nbios_name);",
"exit(1);",
"}",
"milkymist_uart_create(0x60000000, irq[0]);",
"milkymist_sysctl_create(0x60001000, irq[1], irq[2], irq[3],\n80000000, 0x10014d31, 0x0000041f, 0x00000001);",
"milkymist_hpdmc_create(0x60002000);",
"milkymist_vgafb_create(0x60003000, 0x40000000, 0x0fffffff);",
"milkymist_memcard_create(0x60004000);",
"milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);",
"milkymist_pfpu_create(0x60006000, irq[8]);",
"milkymist_tmu2_create(0x60007000, irq[9]);",
"milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);",
"milkymist_softusb_create(0x6000f000, irq[15],\n0x20000000, 0x1000, 0x20020000, 0x2000);",
"env->juart_state = lm32_juart_init();",
"if (VAR_2) {",
"uint64_t entry;",
"VAR_5 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL,\n1, ELF_MACHINE, 0);",
"reset_info->bootstrap_pc = entry;",
"if (VAR_5 < 0) {",
"VAR_5 = load_image_targphys(VAR_2, sdram_base,\nsdram_size);",
"reset_info->bootstrap_pc = sdram_base;",
"}",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_2);",
"exit(1);",
"}",
"}",
"if (VAR_3 && strlen(VAR_3)) {",
"pstrcpy_targphys(\"cmdline\", cmdline_base, TARGET_PAGE_SIZE,\nVAR_3);",
"reset_info->cmdline_base = (uint32_t)cmdline_base;",
"}",
"if (VAR_4) {",
"size_t initrd_size;",
"initrd_size = load_image_targphys(VAR_4, initrd_base,\ninitrd_max);",
"reset_info->initrd_base = (uint32_t)initrd_base;",
"reset_info->initrd_size = (uint32_t)initrd_size;",
"}",
"qemu_register_reset(main_cpu_reset, reset_info);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91,
93,
95,
97
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
135
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
181
],
[
185
],
[
187
],
[
193,
195
],
[
197
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
]
] |
2,719 | static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
{
AACContext *ac = avctx->priv_data;
ChannelElement *che = NULL, *che_prev = NULL;
enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
int err, elem_id;
int samples = 0, multiplier, audio_found = 0, pce_found = 0;
int is_dmono, sce_count = 0;
ac->frame = data;
if (show_bits(gb, 12) == 0xfff) {
if (parse_adts_frame_header(ac, gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
err = -1;
goto fail;
}
if (ac->oc[1].m4ac.sampling_index > 12) {
av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index);
err = -1;
goto fail;
}
}
if (frame_configure_elements(avctx) < 0) {
err = -1;
goto fail;
}
ac->tags_mapped = 0;
// parse
while ((elem_type = get_bits(gb, 3)) != TYPE_END) {
elem_id = get_bits(gb, 4);
if (elem_type < TYPE_DSE) {
if (!(che=get_che(ac, elem_type, elem_id))) {
av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
elem_type, elem_id);
err = -1;
goto fail;
}
samples = 1024;
}
switch (elem_type) {
case TYPE_SCE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
audio_found = 1;
sce_count++;
break;
case TYPE_CPE:
err = decode_cpe(ac, gb, che);
audio_found = 1;
break;
case TYPE_CCE:
err = decode_cce(ac, gb, che);
break;
case TYPE_LFE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
audio_found = 1;
break;
case TYPE_DSE:
err = skip_data_stream_element(ac, gb);
break;
case TYPE_PCE: {
uint8_t layout_map[MAX_ELEM_ID*4][3];
int tags;
push_output_configuration(ac);
tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb);
if (tags < 0) {
err = tags;
break;
}
if (pce_found) {
av_log(avctx, AV_LOG_ERROR,
"Not evaluating a further program_config_element as this construct is dubious at best.\n");
pop_output_configuration(ac);
} else {
err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1);
if (!err)
ac->oc[1].m4ac.chan_config = 0;
pce_found = 1;
}
break;
}
case TYPE_FIL:
if (elem_id == 15)
elem_id += get_bits(gb, 8) - 1;
if (get_bits_left(gb) < 8 * elem_id) {
av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err);
err = -1;
goto fail;
}
while (elem_id > 0)
elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev);
err = 0; /* FIXME */
break;
default:
err = -1; /* should not happen, but keeps compiler happy */
break;
}
che_prev = che;
elem_type_prev = elem_type;
if (err)
goto fail;
if (get_bits_left(gb) < 3) {
av_log(avctx, AV_LOG_ERROR, overread_err);
err = -1;
goto fail;
}
}
spectral_to_sample(ac);
multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0;
samples <<= multiplier;
/* for dual-mono audio (SCE + SCE) */
is_dmono = ac->dmono_mode && sce_count == 2 &&
ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
if (samples)
ac->frame->nb_samples = samples;
*got_frame_ptr = !!samples;
if (is_dmono) {
if (ac->dmono_mode == 1)
((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0];
else if (ac->dmono_mode == 2)
((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1];
}
if (ac->oc[1].status && audio_found) {
avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier;
avctx->frame_size = samples;
ac->oc[1].status = OC_LOCKED;
}
if (multiplier) {
int side_size;
uint32_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if (side && side_size>=4)
AV_WL32(side, 2*AV_RL32(side));
}
return 0;
fail:
pop_output_configuration(ac);
return err;
}
| false | FFmpeg | 21f68528e39db68fd3e22fef8f4783d19034dc1d | static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
{
AACContext *ac = avctx->priv_data;
ChannelElement *che = NULL, *che_prev = NULL;
enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
int err, elem_id;
int samples = 0, multiplier, audio_found = 0, pce_found = 0;
int is_dmono, sce_count = 0;
ac->frame = data;
if (show_bits(gb, 12) == 0xfff) {
if (parse_adts_frame_header(ac, gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
err = -1;
goto fail;
}
if (ac->oc[1].m4ac.sampling_index > 12) {
av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index);
err = -1;
goto fail;
}
}
if (frame_configure_elements(avctx) < 0) {
err = -1;
goto fail;
}
ac->tags_mapped = 0;
while ((elem_type = get_bits(gb, 3)) != TYPE_END) {
elem_id = get_bits(gb, 4);
if (elem_type < TYPE_DSE) {
if (!(che=get_che(ac, elem_type, elem_id))) {
av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
elem_type, elem_id);
err = -1;
goto fail;
}
samples = 1024;
}
switch (elem_type) {
case TYPE_SCE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
audio_found = 1;
sce_count++;
break;
case TYPE_CPE:
err = decode_cpe(ac, gb, che);
audio_found = 1;
break;
case TYPE_CCE:
err = decode_cce(ac, gb, che);
break;
case TYPE_LFE:
err = decode_ics(ac, &che->ch[0], gb, 0, 0);
audio_found = 1;
break;
case TYPE_DSE:
err = skip_data_stream_element(ac, gb);
break;
case TYPE_PCE: {
uint8_t layout_map[MAX_ELEM_ID*4][3];
int tags;
push_output_configuration(ac);
tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb);
if (tags < 0) {
err = tags;
break;
}
if (pce_found) {
av_log(avctx, AV_LOG_ERROR,
"Not evaluating a further program_config_element as this construct is dubious at best.\n");
pop_output_configuration(ac);
} else {
err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1);
if (!err)
ac->oc[1].m4ac.chan_config = 0;
pce_found = 1;
}
break;
}
case TYPE_FIL:
if (elem_id == 15)
elem_id += get_bits(gb, 8) - 1;
if (get_bits_left(gb) < 8 * elem_id) {
av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err);
err = -1;
goto fail;
}
while (elem_id > 0)
elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev);
err = 0;
break;
default:
err = -1;
break;
}
che_prev = che;
elem_type_prev = elem_type;
if (err)
goto fail;
if (get_bits_left(gb) < 3) {
av_log(avctx, AV_LOG_ERROR, overread_err);
err = -1;
goto fail;
}
}
spectral_to_sample(ac);
multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0;
samples <<= multiplier;
is_dmono = ac->dmono_mode && sce_count == 2 &&
ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
if (samples)
ac->frame->nb_samples = samples;
*got_frame_ptr = !!samples;
if (is_dmono) {
if (ac->dmono_mode == 1)
((AVFrame *)data)->data[1] =((AVFrame *)data)->data[0];
else if (ac->dmono_mode == 2)
((AVFrame *)data)->data[0] =((AVFrame *)data)->data[1];
}
if (ac->oc[1].status && audio_found) {
avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier;
avctx->frame_size = samples;
ac->oc[1].status = OC_LOCKED;
}
if (multiplier) {
int side_size;
uint32_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if (side && side_size>=4)
AV_WL32(side, 2*AV_RL32(side));
}
return 0;
fail:
pop_output_configuration(ac);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, GetBitContext *VAR_3, AVPacket *VAR_4)
{
AACContext *ac = VAR_0->priv_data;
ChannelElement *che = NULL, *che_prev = NULL;
enum RawDataBlockType VAR_5, VAR_6 = TYPE_END;
int VAR_7, VAR_8;
int VAR_9 = 0, VAR_10, VAR_11 = 0, VAR_12 = 0;
int VAR_13, VAR_14 = 0;
ac->frame = VAR_1;
if (show_bits(VAR_3, 12) == 0xfff) {
if (parse_adts_frame_header(ac, VAR_3) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
VAR_7 = -1;
goto fail;
}
if (ac->oc[1].m4ac.sampling_index > 12) {
av_log(ac->VAR_0, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index);
VAR_7 = -1;
goto fail;
}
}
if (frame_configure_elements(VAR_0) < 0) {
VAR_7 = -1;
goto fail;
}
ac->tags_mapped = 0;
while ((VAR_5 = get_bits(VAR_3, 3)) != TYPE_END) {
VAR_8 = get_bits(VAR_3, 4);
if (VAR_5 < TYPE_DSE) {
if (!(che=get_che(ac, VAR_5, VAR_8))) {
av_log(ac->VAR_0, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
VAR_5, VAR_8);
VAR_7 = -1;
goto fail;
}
VAR_9 = 1024;
}
switch (VAR_5) {
case TYPE_SCE:
VAR_7 = decode_ics(ac, &che->ch[0], VAR_3, 0, 0);
VAR_11 = 1;
VAR_14++;
break;
case TYPE_CPE:
VAR_7 = decode_cpe(ac, VAR_3, che);
VAR_11 = 1;
break;
case TYPE_CCE:
VAR_7 = decode_cce(ac, VAR_3, che);
break;
case TYPE_LFE:
VAR_7 = decode_ics(ac, &che->ch[0], VAR_3, 0, 0);
VAR_11 = 1;
break;
case TYPE_DSE:
VAR_7 = skip_data_stream_element(ac, VAR_3);
break;
case TYPE_PCE: {
uint8_t layout_map[MAX_ELEM_ID*4][3];
int VAR_15;
push_output_configuration(ac);
VAR_15 = decode_pce(VAR_0, &ac->oc[1].m4ac, layout_map, VAR_3);
if (VAR_15 < 0) {
VAR_7 = VAR_15;
break;
}
if (VAR_12) {
av_log(VAR_0, AV_LOG_ERROR,
"Not evaluating a further program_config_element as this construct is dubious at best.\n");
pop_output_configuration(ac);
} else {
VAR_7 = output_configure(ac, layout_map, VAR_15, OC_TRIAL_PCE, 1);
if (!VAR_7)
ac->oc[1].m4ac.chan_config = 0;
VAR_12 = 1;
}
break;
}
case TYPE_FIL:
if (VAR_8 == 15)
VAR_8 += get_bits(VAR_3, 8) - 1;
if (get_bits_left(VAR_3) < 8 * VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "TYPE_FIL: "overread_err);
VAR_7 = -1;
goto fail;
}
while (VAR_8 > 0)
VAR_8 -= decode_extension_payload(ac, VAR_3, VAR_8, che_prev, VAR_6);
VAR_7 = 0;
break;
default:
VAR_7 = -1;
break;
}
che_prev = che;
VAR_6 = VAR_5;
if (VAR_7)
goto fail;
if (get_bits_left(VAR_3) < 3) {
av_log(VAR_0, AV_LOG_ERROR, overread_err);
VAR_7 = -1;
goto fail;
}
}
spectral_to_sample(ac);
VAR_10 = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0;
VAR_9 <<= VAR_10;
VAR_13 = ac->dmono_mode && VAR_14 == 2 &&
ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
if (VAR_9)
ac->frame->nb_samples = VAR_9;
*VAR_2 = !!VAR_9;
if (VAR_13) {
if (ac->dmono_mode == 1)
((AVFrame *)VAR_1)->VAR_1[1] =((AVFrame *)VAR_1)->VAR_1[0];
else if (ac->dmono_mode == 2)
((AVFrame *)VAR_1)->VAR_1[0] =((AVFrame *)VAR_1)->VAR_1[1];
}
if (ac->oc[1].status && VAR_11) {
VAR_0->sample_rate = ac->oc[1].m4ac.sample_rate << VAR_10;
VAR_0->frame_size = VAR_9;
ac->oc[1].status = OC_LOCKED;
}
if (VAR_10) {
int VAR_16;
uint32_t *side = av_packet_get_side_data(VAR_4, AV_PKT_DATA_SKIP_SAMPLES, &VAR_16);
if (side && VAR_16>=4)
AV_WL32(side, 2*AV_RL32(side));
}
return 0;
fail:
pop_output_configuration(ac);
return VAR_7;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, GetBitContext *VAR_3, AVPacket *VAR_4)\n{",
"AACContext *ac = VAR_0->priv_data;",
"ChannelElement *che = NULL, *che_prev = NULL;",
"enum RawDataBlockType VAR_5, VAR_6 = TYPE_END;",
"int VAR_7, VAR_8;",
"int VAR_9 = 0, VAR_10, VAR_11 = 0, VAR_12 = 0;",
"int VAR_13, VAR_14 = 0;",
"ac->frame = VAR_1;",
"if (show_bits(VAR_3, 12) == 0xfff) {",
"if (parse_adts_frame_header(ac, VAR_3) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error decoding AAC frame header.\\n\");",
"VAR_7 = -1;",
"goto fail;",
"}",
"if (ac->oc[1].m4ac.sampling_index > 12) {",
"av_log(ac->VAR_0, AV_LOG_ERROR, \"invalid sampling rate index %d\\n\", ac->oc[1].m4ac.sampling_index);",
"VAR_7 = -1;",
"goto fail;",
"}",
"}",
"if (frame_configure_elements(VAR_0) < 0) {",
"VAR_7 = -1;",
"goto fail;",
"}",
"ac->tags_mapped = 0;",
"while ((VAR_5 = get_bits(VAR_3, 3)) != TYPE_END) {",
"VAR_8 = get_bits(VAR_3, 4);",
"if (VAR_5 < TYPE_DSE) {",
"if (!(che=get_che(ac, VAR_5, VAR_8))) {",
"av_log(ac->VAR_0, AV_LOG_ERROR, \"channel element %d.%d is not allocated\\n\",\nVAR_5, VAR_8);",
"VAR_7 = -1;",
"goto fail;",
"}",
"VAR_9 = 1024;",
"}",
"switch (VAR_5) {",
"case TYPE_SCE:\nVAR_7 = decode_ics(ac, &che->ch[0], VAR_3, 0, 0);",
"VAR_11 = 1;",
"VAR_14++;",
"break;",
"case TYPE_CPE:\nVAR_7 = decode_cpe(ac, VAR_3, che);",
"VAR_11 = 1;",
"break;",
"case TYPE_CCE:\nVAR_7 = decode_cce(ac, VAR_3, che);",
"break;",
"case TYPE_LFE:\nVAR_7 = decode_ics(ac, &che->ch[0], VAR_3, 0, 0);",
"VAR_11 = 1;",
"break;",
"case TYPE_DSE:\nVAR_7 = skip_data_stream_element(ac, VAR_3);",
"break;",
"case TYPE_PCE: {",
"uint8_t layout_map[MAX_ELEM_ID*4][3];",
"int VAR_15;",
"push_output_configuration(ac);",
"VAR_15 = decode_pce(VAR_0, &ac->oc[1].m4ac, layout_map, VAR_3);",
"if (VAR_15 < 0) {",
"VAR_7 = VAR_15;",
"break;",
"}",
"if (VAR_12) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Not evaluating a further program_config_element as this construct is dubious at best.\\n\");",
"pop_output_configuration(ac);",
"} else {",
"VAR_7 = output_configure(ac, layout_map, VAR_15, OC_TRIAL_PCE, 1);",
"if (!VAR_7)\nac->oc[1].m4ac.chan_config = 0;",
"VAR_12 = 1;",
"}",
"break;",
"}",
"case TYPE_FIL:\nif (VAR_8 == 15)\nVAR_8 += get_bits(VAR_3, 8) - 1;",
"if (get_bits_left(VAR_3) < 8 * VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"TYPE_FIL: \"overread_err);",
"VAR_7 = -1;",
"goto fail;",
"}",
"while (VAR_8 > 0)\nVAR_8 -= decode_extension_payload(ac, VAR_3, VAR_8, che_prev, VAR_6);",
"VAR_7 = 0;",
"break;",
"default:\nVAR_7 = -1;",
"break;",
"}",
"che_prev = che;",
"VAR_6 = VAR_5;",
"if (VAR_7)\ngoto fail;",
"if (get_bits_left(VAR_3) < 3) {",
"av_log(VAR_0, AV_LOG_ERROR, overread_err);",
"VAR_7 = -1;",
"goto fail;",
"}",
"}",
"spectral_to_sample(ac);",
"VAR_10 = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0;",
"VAR_9 <<= VAR_10;",
"VAR_13 = ac->dmono_mode && VAR_14 == 2 &&\nac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);",
"if (VAR_9)\nac->frame->nb_samples = VAR_9;",
"*VAR_2 = !!VAR_9;",
"if (VAR_13) {",
"if (ac->dmono_mode == 1)\n((AVFrame *)VAR_1)->VAR_1[1] =((AVFrame *)VAR_1)->VAR_1[0];",
"else if (ac->dmono_mode == 2)\n((AVFrame *)VAR_1)->VAR_1[0] =((AVFrame *)VAR_1)->VAR_1[1];",
"}",
"if (ac->oc[1].status && VAR_11) {",
"VAR_0->sample_rate = ac->oc[1].m4ac.sample_rate << VAR_10;",
"VAR_0->frame_size = VAR_9;",
"ac->oc[1].status = OC_LOCKED;",
"}",
"if (VAR_10) {",
"int VAR_16;",
"uint32_t *side = av_packet_get_side_data(VAR_4, AV_PKT_DATA_SKIP_SAMPLES, &VAR_16);",
"if (side && VAR_16>=4)\nAV_WL32(side, 2*AV_RL32(side));",
"}",
"return 0;",
"fail:\npop_output_configuration(ac);",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
],
[
135,
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
213,
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
229,
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
253
],
[
255
],
[
259,
261
],
[
265,
267
],
[
269
],
[
273
],
[
275,
277
],
[
279,
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
]
] |
2,720 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *idebus0, BusState *idebus1,
FDCtrl *floppy_controller, ISADevice *s)
{
int val, nb;
FDriveType fd0, fd1;
static pc_cmos_init_late_arg arg;
/* various important CMOS locations needed by PC/Bochs bios */
/* memory size */
val = 640; /* base memory in K */
rtc_set_memory(s, 0x15, val);
rtc_set_memory(s, 0x16, val >> 8);
val = (ram_size / 1024) - 1024;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x17, val);
rtc_set_memory(s, 0x18, val >> 8);
rtc_set_memory(s, 0x30, val);
rtc_set_memory(s, 0x31, val >> 8);
if (above_4g_mem_size) {
rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
}
if (ram_size > (16 * 1024 * 1024))
val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
else
val = 0;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x34, val);
rtc_set_memory(s, 0x35, val >> 8);
/* set the number of CPU */
rtc_set_memory(s, 0x5f, smp_cpus - 1);
/* set boot devices, and disable floppy signature check if requested */
if (set_boot_dev(s, boot_device, fd_bootchk)) {
exit(1);
}
/* floppy type */
fd0 = fdctrl_get_drive_type(floppy_controller, 0);
fd1 = fdctrl_get_drive_type(floppy_controller, 1);
val = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1);
rtc_set_memory(s, 0x10, val);
val = 0;
nb = 0;
if (fd0 < FDRIVE_DRV_NONE) {
nb++;
}
if (fd1 < FDRIVE_DRV_NONE) {
nb++;
}
switch (nb) {
case 0:
break;
case 1:
val |= 0x01; /* 1 drive, ready for boot */
break;
case 2:
val |= 0x41; /* 2 drives, ready for boot */
break;
}
val |= 0x02; /* FPU is there */
val |= 0x04; /* PS/2 mouse installed */
rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
/* hard drives */
arg.rtc_state = s;
arg.idebus0 = idebus0;
arg.idebus1 = idebus1;
qemu_register_reset(pc_cmos_init_late, &arg);
}
| false | qemu | 63ffb564dca94f8bda01ed6d209784104630a4d2 | void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device,
BusState *idebus0, BusState *idebus1,
FDCtrl *floppy_controller, ISADevice *s)
{
int val, nb;
FDriveType fd0, fd1;
static pc_cmos_init_late_arg arg;
val = 640;
rtc_set_memory(s, 0x15, val);
rtc_set_memory(s, 0x16, val >> 8);
val = (ram_size / 1024) - 1024;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x17, val);
rtc_set_memory(s, 0x18, val >> 8);
rtc_set_memory(s, 0x30, val);
rtc_set_memory(s, 0x31, val >> 8);
if (above_4g_mem_size) {
rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
}
if (ram_size > (16 * 1024 * 1024))
val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
else
val = 0;
if (val > 65535)
val = 65535;
rtc_set_memory(s, 0x34, val);
rtc_set_memory(s, 0x35, val >> 8);
rtc_set_memory(s, 0x5f, smp_cpus - 1);
if (set_boot_dev(s, boot_device, fd_bootchk)) {
exit(1);
}
fd0 = fdctrl_get_drive_type(floppy_controller, 0);
fd1 = fdctrl_get_drive_type(floppy_controller, 1);
val = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1);
rtc_set_memory(s, 0x10, val);
val = 0;
nb = 0;
if (fd0 < FDRIVE_DRV_NONE) {
nb++;
}
if (fd1 < FDRIVE_DRV_NONE) {
nb++;
}
switch (nb) {
case 0:
break;
case 1:
val |= 0x01;
break;
case 2:
val |= 0x41;
break;
}
val |= 0x02;
val |= 0x04;
rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
arg.rtc_state = s;
arg.idebus0 = idebus0;
arg.idebus1 = idebus1;
qemu_register_reset(pc_cmos_init_late, &arg);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1,
const char *VAR_2,
BusState *VAR_3, BusState *VAR_4,
FDCtrl *VAR_5, ISADevice *VAR_6)
{
int VAR_7, VAR_8;
FDriveType fd0, fd1;
static pc_cmos_init_late_arg VAR_9;
VAR_7 = 640;
rtc_set_memory(VAR_6, 0x15, VAR_7);
rtc_set_memory(VAR_6, 0x16, VAR_7 >> 8);
VAR_7 = (VAR_0 / 1024) - 1024;
if (VAR_7 > 65535)
VAR_7 = 65535;
rtc_set_memory(VAR_6, 0x17, VAR_7);
rtc_set_memory(VAR_6, 0x18, VAR_7 >> 8);
rtc_set_memory(VAR_6, 0x30, VAR_7);
rtc_set_memory(VAR_6, 0x31, VAR_7 >> 8);
if (VAR_1) {
rtc_set_memory(VAR_6, 0x5b, (unsigned int)VAR_1 >> 16);
rtc_set_memory(VAR_6, 0x5c, (unsigned int)VAR_1 >> 24);
rtc_set_memory(VAR_6, 0x5d, (uint64_t)VAR_1 >> 32);
}
if (VAR_0 > (16 * 1024 * 1024))
VAR_7 = (VAR_0 / 65536) - ((16 * 1024 * 1024) / 65536);
else
VAR_7 = 0;
if (VAR_7 > 65535)
VAR_7 = 65535;
rtc_set_memory(VAR_6, 0x34, VAR_7);
rtc_set_memory(VAR_6, 0x35, VAR_7 >> 8);
rtc_set_memory(VAR_6, 0x5f, smp_cpus - 1);
if (set_boot_dev(VAR_6, VAR_2, fd_bootchk)) {
exit(1);
}
fd0 = fdctrl_get_drive_type(VAR_5, 0);
fd1 = fdctrl_get_drive_type(VAR_5, 1);
VAR_7 = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1);
rtc_set_memory(VAR_6, 0x10, VAR_7);
VAR_7 = 0;
VAR_8 = 0;
if (fd0 < FDRIVE_DRV_NONE) {
VAR_8++;
}
if (fd1 < FDRIVE_DRV_NONE) {
VAR_8++;
}
switch (VAR_8) {
case 0:
break;
case 1:
VAR_7 |= 0x01;
break;
case 2:
VAR_7 |= 0x41;
break;
}
VAR_7 |= 0x02;
VAR_7 |= 0x04;
rtc_set_memory(VAR_6, REG_EQUIPMENT_BYTE, VAR_7);
VAR_9.rtc_state = VAR_6;
VAR_9.VAR_3 = VAR_3;
VAR_9.VAR_4 = VAR_4;
qemu_register_reset(pc_cmos_init_late, &VAR_9);
}
| [
"void FUNC_0(ram_addr_t VAR_0, ram_addr_t VAR_1,\nconst char *VAR_2,\nBusState *VAR_3, BusState *VAR_4,\nFDCtrl *VAR_5, ISADevice *VAR_6)\n{",
"int VAR_7, VAR_8;",
"FDriveType fd0, fd1;",
"static pc_cmos_init_late_arg VAR_9;",
"VAR_7 = 640;",
"rtc_set_memory(VAR_6, 0x15, VAR_7);",
"rtc_set_memory(VAR_6, 0x16, VAR_7 >> 8);",
"VAR_7 = (VAR_0 / 1024) - 1024;",
"if (VAR_7 > 65535)\nVAR_7 = 65535;",
"rtc_set_memory(VAR_6, 0x17, VAR_7);",
"rtc_set_memory(VAR_6, 0x18, VAR_7 >> 8);",
"rtc_set_memory(VAR_6, 0x30, VAR_7);",
"rtc_set_memory(VAR_6, 0x31, VAR_7 >> 8);",
"if (VAR_1) {",
"rtc_set_memory(VAR_6, 0x5b, (unsigned int)VAR_1 >> 16);",
"rtc_set_memory(VAR_6, 0x5c, (unsigned int)VAR_1 >> 24);",
"rtc_set_memory(VAR_6, 0x5d, (uint64_t)VAR_1 >> 32);",
"}",
"if (VAR_0 > (16 * 1024 * 1024))\nVAR_7 = (VAR_0 / 65536) - ((16 * 1024 * 1024) / 65536);",
"else\nVAR_7 = 0;",
"if (VAR_7 > 65535)\nVAR_7 = 65535;",
"rtc_set_memory(VAR_6, 0x34, VAR_7);",
"rtc_set_memory(VAR_6, 0x35, VAR_7 >> 8);",
"rtc_set_memory(VAR_6, 0x5f, smp_cpus - 1);",
"if (set_boot_dev(VAR_6, VAR_2, fd_bootchk)) {",
"exit(1);",
"}",
"fd0 = fdctrl_get_drive_type(VAR_5, 0);",
"fd1 = fdctrl_get_drive_type(VAR_5, 1);",
"VAR_7 = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1);",
"rtc_set_memory(VAR_6, 0x10, VAR_7);",
"VAR_7 = 0;",
"VAR_8 = 0;",
"if (fd0 < FDRIVE_DRV_NONE) {",
"VAR_8++;",
"}",
"if (fd1 < FDRIVE_DRV_NONE) {",
"VAR_8++;",
"}",
"switch (VAR_8) {",
"case 0:\nbreak;",
"case 1:\nVAR_7 |= 0x01;",
"break;",
"case 2:\nVAR_7 |= 0x41;",
"break;",
"}",
"VAR_7 |= 0x02;",
"VAR_7 |= 0x04;",
"rtc_set_memory(VAR_6, REG_EQUIPMENT_BYTE, VAR_7);",
"VAR_9.rtc_state = VAR_6;",
"VAR_9.VAR_3 = VAR_3;",
"VAR_9.VAR_4 = VAR_4;",
"qemu_register_reset(pc_cmos_init_late, &VAR_9);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
81
],
[
87
],
[
89
],
[
91
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133,
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
]
] |
2,721 | START_TEST(unterminated_dict_comma)
{
QObject *obj = qobject_from_json("{'abc':32,");
fail_unless(obj == NULL);
}
| false | qemu | ef76dc59fa5203d146a2acf85a0ad5a5971a4824 | START_TEST(unterminated_dict_comma)
{
QObject *obj = qobject_from_json("{'abc':32,");
fail_unless(obj == NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
QObject *obj = qobject_from_json("{'abc':32,");
fail_unless(obj == NULL);
}
| [
"FUNC_0(VAR_0)\n{",
"QObject *obj = qobject_from_json(\"{'abc':32,\");",
"fail_unless(obj == NULL);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
2,722 | void qemu_iovec_concat(QEMUIOVector *dst,
QEMUIOVector *src, size_t soffset, size_t sbytes)
{
int i;
size_t done;
struct iovec *siov = src->iov;
assert(dst->nalloc != -1);
assert(src->size >= soffset);
for (i = 0, done = 0; done < sbytes && i < src->niov; i++) {
if (soffset < siov[i].iov_len) {
size_t len = MIN(siov[i].iov_len - soffset, sbytes - done);
qemu_iovec_add(dst, siov[i].iov_base + soffset, len);
done += len;
soffset = 0;
} else {
soffset -= siov[i].iov_len;
}
}
/* return done; */
}
| false | qemu | 530c0bbd73e1b658c9266582072847de1fbdff10 | void qemu_iovec_concat(QEMUIOVector *dst,
QEMUIOVector *src, size_t soffset, size_t sbytes)
{
int i;
size_t done;
struct iovec *siov = src->iov;
assert(dst->nalloc != -1);
assert(src->size >= soffset);
for (i = 0, done = 0; done < sbytes && i < src->niov; i++) {
if (soffset < siov[i].iov_len) {
size_t len = MIN(siov[i].iov_len - soffset, sbytes - done);
qemu_iovec_add(dst, siov[i].iov_base + soffset, len);
done += len;
soffset = 0;
} else {
soffset -= siov[i].iov_len;
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUIOVector *VAR_0,
QEMUIOVector *VAR_1, size_t VAR_2, size_t VAR_3)
{
int VAR_4;
size_t done;
struct iovec *VAR_5 = VAR_1->iov;
assert(VAR_0->nalloc != -1);
assert(VAR_1->size >= VAR_2);
for (VAR_4 = 0, done = 0; done < VAR_3 && VAR_4 < VAR_1->niov; VAR_4++) {
if (VAR_2 < VAR_5[VAR_4].iov_len) {
size_t len = MIN(VAR_5[VAR_4].iov_len - VAR_2, VAR_3 - done);
qemu_iovec_add(VAR_0, VAR_5[VAR_4].iov_base + VAR_2, len);
done += len;
VAR_2 = 0;
} else {
VAR_2 -= VAR_5[VAR_4].iov_len;
}
}
}
| [
"void FUNC_0(QEMUIOVector *VAR_0,\nQEMUIOVector *VAR_1, size_t VAR_2, size_t VAR_3)\n{",
"int VAR_4;",
"size_t done;",
"struct iovec *VAR_5 = VAR_1->iov;",
"assert(VAR_0->nalloc != -1);",
"assert(VAR_1->size >= VAR_2);",
"for (VAR_4 = 0, done = 0; done < VAR_3 && VAR_4 < VAR_1->niov; VAR_4++) {",
"if (VAR_2 < VAR_5[VAR_4].iov_len) {",
"size_t len = MIN(VAR_5[VAR_4].iov_len - VAR_2, VAR_3 - done);",
"qemu_iovec_add(VAR_0, VAR_5[VAR_4].iov_base + VAR_2, len);",
"done += len;",
"VAR_2 = 0;",
"} else {",
"VAR_2 -= VAR_5[VAR_4].iov_len;",
"}",
"}",
"}"
] | [
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
]
] |
2,723 | void net_host_device_add(Monitor *mon, const char *device, const char *opts)
{
if (!net_host_check_device(device)) {
monitor_printf(mon, "invalid host network device %s\n", device);
return;
}
if (net_client_init(device, opts ? : "") < 0) {
monitor_printf(mon, "adding host network device %s failed\n", device);
}
}
| false | qemu | 206ab6e090eeddce71372041454d50d93a63017d | void net_host_device_add(Monitor *mon, const char *device, const char *opts)
{
if (!net_host_check_device(device)) {
monitor_printf(mon, "invalid host network device %s\n", device);
return;
}
if (net_client_init(device, opts ? : "") < 0) {
monitor_printf(mon, "adding host network device %s failed\n", device);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Monitor *VAR_0, const char *VAR_1, const char *VAR_2)
{
if (!net_host_check_device(VAR_1)) {
monitor_printf(VAR_0, "invalid host network VAR_1 %s\n", VAR_1);
return;
}
if (net_client_init(VAR_1, VAR_2 ? : "") < 0) {
monitor_printf(VAR_0, "adding host network VAR_1 %s failed\n", VAR_1);
}
}
| [
"void FUNC_0(Monitor *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"if (!net_host_check_device(VAR_1)) {",
"monitor_printf(VAR_0, \"invalid host network VAR_1 %s\\n\", VAR_1);",
"return;",
"}",
"if (net_client_init(VAR_1, VAR_2 ? : \"\") < 0) {",
"monitor_printf(VAR_0, \"adding host network VAR_1 %s failed\\n\", VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
2,724 | static void musicpal_register_devices(void)
{
sysbus_register_dev("mv88w8618_pic", sizeof(mv88w8618_pic_state),
mv88w8618_pic_init);
sysbus_register_dev("mv88w8618_pit", sizeof(mv88w8618_pit_state),
mv88w8618_pit_init);
sysbus_register_dev("mv88w8618_flashcfg", sizeof(mv88w8618_flashcfg_state),
mv88w8618_flashcfg_init);
sysbus_register_dev("mv88w8618_eth", sizeof(mv88w8618_eth_state),
mv88w8618_eth_init);
sysbus_register_dev("mv88w8618_wlan", sizeof(SysBusDevice),
mv88w8618_wlan_init);
sysbus_register_dev("musicpal_lcd", sizeof(musicpal_lcd_state),
musicpal_lcd_init);
sysbus_register_withprop(&musicpal_gpio_info);
sysbus_register_dev("musicpal_key", sizeof(musicpal_key_state),
musicpal_key_init);
}
| false | qemu | c88d6bded69804617f412a60c7375cc93f8687a5 | static void musicpal_register_devices(void)
{
sysbus_register_dev("mv88w8618_pic", sizeof(mv88w8618_pic_state),
mv88w8618_pic_init);
sysbus_register_dev("mv88w8618_pit", sizeof(mv88w8618_pit_state),
mv88w8618_pit_init);
sysbus_register_dev("mv88w8618_flashcfg", sizeof(mv88w8618_flashcfg_state),
mv88w8618_flashcfg_init);
sysbus_register_dev("mv88w8618_eth", sizeof(mv88w8618_eth_state),
mv88w8618_eth_init);
sysbus_register_dev("mv88w8618_wlan", sizeof(SysBusDevice),
mv88w8618_wlan_init);
sysbus_register_dev("musicpal_lcd", sizeof(musicpal_lcd_state),
musicpal_lcd_init);
sysbus_register_withprop(&musicpal_gpio_info);
sysbus_register_dev("musicpal_key", sizeof(musicpal_key_state),
musicpal_key_init);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
sysbus_register_dev("mv88w8618_pic", sizeof(mv88w8618_pic_state),
mv88w8618_pic_init);
sysbus_register_dev("mv88w8618_pit", sizeof(mv88w8618_pit_state),
mv88w8618_pit_init);
sysbus_register_dev("mv88w8618_flashcfg", sizeof(mv88w8618_flashcfg_state),
mv88w8618_flashcfg_init);
sysbus_register_dev("mv88w8618_eth", sizeof(mv88w8618_eth_state),
mv88w8618_eth_init);
sysbus_register_dev("mv88w8618_wlan", sizeof(SysBusDevice),
mv88w8618_wlan_init);
sysbus_register_dev("musicpal_lcd", sizeof(musicpal_lcd_state),
musicpal_lcd_init);
sysbus_register_withprop(&musicpal_gpio_info);
sysbus_register_dev("musicpal_key", sizeof(musicpal_key_state),
musicpal_key_init);
}
| [
"static void FUNC_0(void)\n{",
"sysbus_register_dev(\"mv88w8618_pic\", sizeof(mv88w8618_pic_state),\nmv88w8618_pic_init);",
"sysbus_register_dev(\"mv88w8618_pit\", sizeof(mv88w8618_pit_state),\nmv88w8618_pit_init);",
"sysbus_register_dev(\"mv88w8618_flashcfg\", sizeof(mv88w8618_flashcfg_state),\nmv88w8618_flashcfg_init);",
"sysbus_register_dev(\"mv88w8618_eth\", sizeof(mv88w8618_eth_state),\nmv88w8618_eth_init);",
"sysbus_register_dev(\"mv88w8618_wlan\", sizeof(SysBusDevice),\nmv88w8618_wlan_init);",
"sysbus_register_dev(\"musicpal_lcd\", sizeof(musicpal_lcd_state),\nmusicpal_lcd_init);",
"sysbus_register_withprop(&musicpal_gpio_info);",
"sysbus_register_dev(\"musicpal_key\", sizeof(musicpal_key_state),\nmusicpal_key_init);",
"}"
] | [
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
]
] |
2,725 | static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EMEDIUMTYPE;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
/* Initialise version 3 header fields */
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
/* Handle feature bits */
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
/* Corrupt images may not be written to unless they are being repaired
*/
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
/* Check support for various header values */
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
/* read the level 1 table */
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
/* the L1 table must contain at least enough entries to put
header.size bytes */
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
/* alloc L2 table/refcount block cache */
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
/* one more sector for decompressed data alignment */
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
/* read qcow2 extensions */
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
}
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
/* Clear unknown autoclear feature bits */
if (!bs->read_only && s->autoclear_features != 0) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
/* Initialise locks */
qemu_co_mutex_init(&s->lock);
/* Repair image if dirty */
if (!(flags & BDRV_O_CHECK) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
/* Enable lazy_refcounts according to image and command line options */
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
/* overlap-check defines a template bitmask, but every flag may be
* overwritten through the associated boolean option */
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
/* else pre-write overlap checks in cache_destroy may crash */
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
}
| false | qemu | 76abe4071d111a9ca6dcc9b9689a831c39ffa718 | static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
int len, i, ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EMEDIUMTYPE;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023) {
len = 1023;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
}
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
if (!bs->read_only && s->autoclear_features != 0) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
qemu_co_mutex_init(&s->lock);
if (!(flags & BDRV_O_CHECK) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_4, VAR_5, VAR_6 = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *VAR_7;
int VAR_8 = 0;
VAR_6 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(VAR_3, "Image is not in qcow2 format");
VAR_6 = -EMEDIUMTYPE;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(VAR_0, VAR_3, "QCOW version %d", header.version);
VAR_6 = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
VAR_6 = bdrv_pread(VAR_0->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *VAR_9 = NULL;
qcow2_read_extensions(VAR_0, header.header_length, ext_end,
&VAR_9, NULL);
report_unsupported_feature(VAR_0, VAR_3, VAR_9,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
VAR_6 = -ENOTSUP;
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((VAR_2 & BDRV_O_RDWR) && !(VAR_2 & BDRV_O_CHECK)) {
error_setg(VAR_3, "qcow2: Image is corrupt; cannot be opened "
"read/write");
VAR_6 = -EACCES;
goto fail;
}
}
if (header.refcount_order != 4) {
report_unsupported(VAR_0, VAR_3, "%d bit reference counts",
1 << header.refcount_order);
VAR_6 = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(VAR_3, "Unsupported cluster size: 2^%VAR_5", header.cluster_bits);
VAR_6 = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(VAR_3, "Unsupported encryption method: %VAR_5",
header.crypt_method);
VAR_6 = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
VAR_0->encrypted = 1;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
VAR_0->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(VAR_3, "Image is too big");
VAR_6 = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(VAR_3, "L1 table is too small");
VAR_6 = -EINVAL;
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
VAR_6 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read L1 table");
goto fail;
}
for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {
be64_to_cpus(&s->l1_table[VAR_5]);
}
}
s->l2_table_cache = qcow2_cache_create(VAR_0, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(VAR_0, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = qemu_blockalign(VAR_0, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->VAR_2 = VAR_2;
VAR_6 = qcow2_refcount_init(VAR_0);
if (VAR_6 != 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(VAR_0, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(VAR_3, local_err);
VAR_6 = -EINVAL;
goto fail;
}
if (header.backing_file_offset != 0) {
VAR_4 = header.backing_file_size;
if (VAR_4 > 1023) {
VAR_4 = 1023;
}
VAR_6 = bdrv_pread(VAR_0->file, header.backing_file_offset,
VAR_0->backing_file, VAR_4);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read backing file name");
goto fail;
}
VAR_0->backing_file[VAR_4] = '\0';
}
VAR_6 = qcow2_read_snapshots(VAR_0);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not read snapshots");
goto fail;
}
if (!VAR_0->read_only && s->autoclear_features != 0) {
s->autoclear_features = 0;
VAR_6 = qcow2_update_header(VAR_0);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not update qcow2 header");
goto fail;
}
}
qemu_co_mutex_init(&s->lock);
if (!(VAR_2 & BDRV_O_CHECK) && !VAR_0->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
VAR_6 = qcow2_check(VAR_0, &result, BDRV_FIX_ERRORS);
if (VAR_6 < 0) {
error_setg_errno(VAR_3, -VAR_6, "Could not repair dirty image");
goto fail;
}
}
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_1, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_6 = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
VAR_2 & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
VAR_7 = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(VAR_7, "none")) {
VAR_8 = 0;
} else if (!strcmp(VAR_7, "constant")) {
VAR_8 = QCOW2_OL_CONSTANT;
} else if (!strcmp(VAR_7, "cached")) {
VAR_8 = QCOW2_OL_CACHED;
} else if (!strcmp(VAR_7, "all")) {
VAR_8 = QCOW2_OL_ALL;
} else {
error_setg(VAR_3, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", VAR_7);
qemu_opts_del(opts);
VAR_6 = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (VAR_5 = 0; VAR_5 < QCOW2_OL_MAX_BITNR; VAR_5++) {
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[VAR_5],
VAR_8 & (1 << VAR_5)) << VAR_5;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(VAR_3, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
VAR_6 = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(VAR_0, &result, 0);
}
#endif
return VAR_6;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(VAR_0);
qcow2_free_snapshots(VAR_0);
qcow2_refcount_close(VAR_0);
g_free(s->l1_table);
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(VAR_0, s->l2_table_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return VAR_6;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_4, VAR_5, VAR_6 = 0;",
"QCowHeader header;",
"QemuOpts *opts;",
"Error *local_err = NULL;",
"uint64_t ext_end;",
"uint64_t l1_vm_state_index;",
"const char *VAR_7;",
"int VAR_8 = 0;",
"VAR_6 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read qcow2 header\");",
"goto fail;",
"}",
"be32_to_cpus(&header.magic);",
"be32_to_cpus(&header.version);",
"be64_to_cpus(&header.backing_file_offset);",
"be32_to_cpus(&header.backing_file_size);",
"be64_to_cpus(&header.size);",
"be32_to_cpus(&header.cluster_bits);",
"be32_to_cpus(&header.crypt_method);",
"be64_to_cpus(&header.l1_table_offset);",
"be32_to_cpus(&header.l1_size);",
"be64_to_cpus(&header.refcount_table_offset);",
"be32_to_cpus(&header.refcount_table_clusters);",
"be64_to_cpus(&header.snapshots_offset);",
"be32_to_cpus(&header.nb_snapshots);",
"if (header.magic != QCOW_MAGIC) {",
"error_setg(VAR_3, \"Image is not in qcow2 format\");",
"VAR_6 = -EMEDIUMTYPE;",
"goto fail;",
"}",
"if (header.version < 2 || header.version > 3) {",
"report_unsupported(VAR_0, VAR_3, \"QCOW version %d\", header.version);",
"VAR_6 = -ENOTSUP;",
"goto fail;",
"}",
"s->qcow_version = header.version;",
"if (header.version == 2) {",
"header.incompatible_features = 0;",
"header.compatible_features = 0;",
"header.autoclear_features = 0;",
"header.refcount_order = 4;",
"header.header_length = 72;",
"} else {",
"be64_to_cpus(&header.incompatible_features);",
"be64_to_cpus(&header.compatible_features);",
"be64_to_cpus(&header.autoclear_features);",
"be32_to_cpus(&header.refcount_order);",
"be32_to_cpus(&header.header_length);",
"}",
"if (header.header_length > sizeof(header)) {",
"s->unknown_header_fields_size = header.header_length - sizeof(header);",
"s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);",
"VAR_6 = bdrv_pread(VAR_0->file, sizeof(header), s->unknown_header_fields,\ns->unknown_header_fields_size);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read unknown qcow2 header \"\n\"fields\");",
"goto fail;",
"}",
"}",
"if (header.backing_file_offset) {",
"ext_end = header.backing_file_offset;",
"} else {",
"ext_end = 1 << header.cluster_bits;",
"}",
"s->incompatible_features = header.incompatible_features;",
"s->compatible_features = header.compatible_features;",
"s->autoclear_features = header.autoclear_features;",
"if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {",
"void *VAR_9 = NULL;",
"qcow2_read_extensions(VAR_0, header.header_length, ext_end,\n&VAR_9, NULL);",
"report_unsupported_feature(VAR_0, VAR_3, VAR_9,\ns->incompatible_features &\n~QCOW2_INCOMPAT_MASK);",
"VAR_6 = -ENOTSUP;",
"goto fail;",
"}",
"if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {",
"if ((VAR_2 & BDRV_O_RDWR) && !(VAR_2 & BDRV_O_CHECK)) {",
"error_setg(VAR_3, \"qcow2: Image is corrupt; cannot be opened \"",
"\"read/write\");",
"VAR_6 = -EACCES;",
"goto fail;",
"}",
"}",
"if (header.refcount_order != 4) {",
"report_unsupported(VAR_0, VAR_3, \"%d bit reference counts\",\n1 << header.refcount_order);",
"VAR_6 = -ENOTSUP;",
"goto fail;",
"}",
"s->refcount_order = header.refcount_order;",
"if (header.cluster_bits < MIN_CLUSTER_BITS ||\nheader.cluster_bits > MAX_CLUSTER_BITS) {",
"error_setg(VAR_3, \"Unsupported cluster size: 2^%VAR_5\", header.cluster_bits);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"if (header.crypt_method > QCOW_CRYPT_AES) {",
"error_setg(VAR_3, \"Unsupported encryption method: %VAR_5\",\nheader.crypt_method);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->crypt_method_header = header.crypt_method;",
"if (s->crypt_method_header) {",
"VAR_0->encrypted = 1;",
"}",
"s->cluster_bits = header.cluster_bits;",
"s->cluster_size = 1 << s->cluster_bits;",
"s->cluster_sectors = 1 << (s->cluster_bits - 9);",
"s->l2_bits = s->cluster_bits - 3;",
"s->l2_size = 1 << s->l2_bits;",
"VAR_0->total_sectors = header.size / 512;",
"s->csize_shift = (62 - (s->cluster_bits - 8));",
"s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;",
"s->cluster_offset_mask = (1LL << s->csize_shift) - 1;",
"s->refcount_table_offset = header.refcount_table_offset;",
"s->refcount_table_size =\nheader.refcount_table_clusters << (s->cluster_bits - 3);",
"s->snapshots_offset = header.snapshots_offset;",
"s->nb_snapshots = header.nb_snapshots;",
"s->l1_size = header.l1_size;",
"l1_vm_state_index = size_to_l1(s, header.size);",
"if (l1_vm_state_index > INT_MAX) {",
"error_setg(VAR_3, \"Image is too big\");",
"VAR_6 = -EFBIG;",
"goto fail;",
"}",
"s->l1_vm_state_index = l1_vm_state_index;",
"if (s->l1_size < s->l1_vm_state_index) {",
"error_setg(VAR_3, \"L1 table is too small\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->l1_table_offset = header.l1_table_offset;",
"if (s->l1_size > 0) {",
"s->l1_table = g_malloc0(\nalign_offset(s->l1_size * sizeof(uint64_t), 512));",
"VAR_6 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,\ns->l1_size * sizeof(uint64_t));",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read L1 table\");",
"goto fail;",
"}",
"for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {",
"be64_to_cpus(&s->l1_table[VAR_5]);",
"}",
"}",
"s->l2_table_cache = qcow2_cache_create(VAR_0, L2_CACHE_SIZE);",
"s->refcount_block_cache = qcow2_cache_create(VAR_0, REFCOUNT_CACHE_SIZE);",
"s->cluster_cache = g_malloc(s->cluster_size);",
"s->cluster_data = qemu_blockalign(VAR_0, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size\n+ 512);",
"s->cluster_cache_offset = -1;",
"s->VAR_2 = VAR_2;",
"VAR_6 = qcow2_refcount_init(VAR_0);",
"if (VAR_6 != 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not initialize refcount handling\");",
"goto fail;",
"}",
"QLIST_INIT(&s->cluster_allocs);",
"QTAILQ_INIT(&s->discards);",
"if (qcow2_read_extensions(VAR_0, header.header_length, ext_end, NULL,\n&local_err)) {",
"error_propagate(VAR_3, local_err);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"if (header.backing_file_offset != 0) {",
"VAR_4 = header.backing_file_size;",
"if (VAR_4 > 1023) {",
"VAR_4 = 1023;",
"}",
"VAR_6 = bdrv_pread(VAR_0->file, header.backing_file_offset,\nVAR_0->backing_file, VAR_4);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read backing file name\");",
"goto fail;",
"}",
"VAR_0->backing_file[VAR_4] = '\\0';",
"}",
"VAR_6 = qcow2_read_snapshots(VAR_0);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not read snapshots\");",
"goto fail;",
"}",
"if (!VAR_0->read_only && s->autoclear_features != 0) {",
"s->autoclear_features = 0;",
"VAR_6 = qcow2_update_header(VAR_0);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not update qcow2 header\");",
"goto fail;",
"}",
"}",
"qemu_co_mutex_init(&s->lock);",
"if (!(VAR_2 & BDRV_O_CHECK) && !VAR_0->read_only &&\n(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {",
"BdrvCheckResult result = {0};",
"VAR_6 = qcow2_check(VAR_0, &result, BDRV_FIX_ERRORS);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_3, -VAR_6, \"Could not repair dirty image\");",
"goto fail;",
"}",
"}",
"opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_1, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,\n(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));",
"s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;",
"s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;",
"s->discard_passthrough[QCOW2_DISCARD_REQUEST] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,\nVAR_2 & BDRV_O_UNMAP);",
"s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);",
"s->discard_passthrough[QCOW2_DISCARD_OTHER] =\nqemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);",
"VAR_7 = qemu_opt_get(opts, \"overlap-check\") ?: \"cached\";",
"if (!strcmp(VAR_7, \"none\")) {",
"VAR_8 = 0;",
"} else if (!strcmp(VAR_7, \"constant\")) {",
"VAR_8 = QCOW2_OL_CONSTANT;",
"} else if (!strcmp(VAR_7, \"cached\")) {",
"VAR_8 = QCOW2_OL_CACHED;",
"} else if (!strcmp(VAR_7, \"all\")) {",
"VAR_8 = QCOW2_OL_ALL;",
"} else {",
"error_setg(VAR_3, \"Unsupported value '%s' for qcow2 option \"\n\"'overlap-check'. Allowed are either of the following: \"\n\"none, constant, cached, all\", VAR_7);",
"qemu_opts_del(opts);",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"s->overlap_check = 0;",
"for (VAR_5 = 0; VAR_5 < QCOW2_OL_MAX_BITNR; VAR_5++) {",
"s->overlap_check |=\nqemu_opt_get_bool(opts, overlap_bool_option_names[VAR_5],\nVAR_8 & (1 << VAR_5)) << VAR_5;",
"}",
"qemu_opts_del(opts);",
"if (s->use_lazy_refcounts && s->qcow_version < 3) {",
"error_setg(VAR_3, \"Lazy refcounts require a qcow2 image with at least \"\n\"qemu 1.1 compatibility level\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"#ifdef DEBUG_ALLOC\n{",
"BdrvCheckResult result = {0};",
"qcow2_check_refcounts(VAR_0, &result, 0);",
"}",
"#endif\nreturn VAR_6;",
"fail:\ng_free(s->unknown_header_fields);",
"cleanup_unknown_header_ext(VAR_0);",
"qcow2_free_snapshots(VAR_0);",
"qcow2_refcount_close(VAR_0);",
"g_free(s->l1_table);",
"s->l1_table = NULL;",
"if (s->l2_table_cache) {",
"qcow2_cache_destroy(VAR_0, s->l2_table_cache);",
"}",
"g_free(s->cluster_cache);",
"qemu_vfree(s->cluster_data);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171,
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
287
],
[
289
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333,
335
],
[
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
361
],
[
363
],
[
367
],
[
371,
373
],
[
375
],
[
377
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
393
],
[
395
],
[
401,
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427,
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
479
],
[
485,
487
],
[
489
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
525,
527
],
[
531
],
[
533
],
[
535,
537,
539
],
[
541,
543
],
[
545,
547
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571,
573,
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
587
],
[
589
],
[
595,
597,
599
],
[
601
],
[
605
],
[
609
],
[
611,
613
],
[
615
],
[
617
],
[
619
],
[
623,
625
],
[
627
],
[
629
],
[
631
],
[
633,
635
],
[
639,
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
]
] |
2,726 | static void vexpress_a9_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env = NULL;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *lowram = g_new(MemoryRegion, 1);
MemoryRegion *vram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *hackram = g_new(MemoryRegion, 1);
DeviceState *dev, *sysctl, *pl041;
SysBusDevice *busdev;
qemu_irq *irqp;
qemu_irq pic[64];
int n;
qemu_irq cpu_irq[4];
uint32_t proc_id;
uint32_t sys_id;
ram_addr_t low_ram_size, vram_size, sram_size;
target_phys_addr_t *map = motherboard_legacy_map;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
for (n = 0; n < smp_cpus; n++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
irqp = arm_pic_init_cpu(env);
cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ];
}
if (ram_size > 0x40000000) {
/* 1GB is the maximum the address space permits */
fprintf(stderr, "vexpress: cannot model more than 1GB RAM\n");
exit(1);
}
memory_region_init_ram(ram, "vexpress.highmem", ram_size);
vmstate_register_ram_global(ram);
low_ram_size = ram_size;
if (low_ram_size > 0x4000000) {
low_ram_size = 0x4000000;
}
/* RAM is from 0x60000000 upwards. The bottom 64MB of the
* address space should in theory be remappable to various
* things including ROM or RAM; we always map the RAM there.
*/
memory_region_init_alias(lowram, "vexpress.lowmem", ram, 0, low_ram_size);
memory_region_add_subregion(sysmem, 0x0, lowram);
memory_region_add_subregion(sysmem, 0x60000000, ram);
/* 0x1e000000 A9MPCore (SCU) private memory region */
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
vexpress_binfo.smp_priv_base = 0x1e000000;
sysbus_mmio_map(busdev, 0, vexpress_binfo.smp_priv_base);
for (n = 0; n < smp_cpus; n++) {
sysbus_connect_irq(busdev, n, cpu_irq[n]);
}
/* Interrupts [42:0] are from the motherboard;
* [47:43] are reserved; [63:48] are daughterboard
* peripherals. Note that some documentation numbers
* external interrupts starting from 32 (because the
* A9MP has internal interrupts 0..31).
*/
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
/* Motherboard peripherals: the wiring is the same but the
* addresses vary between the legacy and A-Series memory maps.
*/
sys_id = 0x1190f500;
proc_id = 0x0c000191;
sysctl = qdev_create(NULL, "realview_sysctl");
qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
qdev_init_nofail(sysctl);
sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, map[VE_SYSREGS]);
/* VE_SP810: not modelled */
/* VE_SERIALPCI: not modelled */
pl041 = qdev_create(NULL, "pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
qdev_init_nofail(pl041);
sysbus_mmio_map(sysbus_from_qdev(pl041), 0, map[VE_PL041]);
sysbus_connect_irq(sysbus_from_qdev(pl041), 0, pic[11]);
dev = sysbus_create_varargs("pl181", map[VE_MMCI], pic[9], pic[10], NULL);
/* Wire up MMC card detect and read-only signals */
qdev_connect_gpio_out(dev, 0,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));
qdev_connect_gpio_out(dev, 1,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN));
sysbus_create_simple("pl050_keyboard", map[VE_KMI0], pic[12]);
sysbus_create_simple("pl050_mouse", map[VE_KMI1], pic[13]);
sysbus_create_simple("pl011", map[VE_UART0], pic[5]);
sysbus_create_simple("pl011", map[VE_UART1], pic[6]);
sysbus_create_simple("pl011", map[VE_UART2], pic[7]);
sysbus_create_simple("pl011", map[VE_UART3], pic[8]);
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
/* VE_SERIALDVI: not modelled */
sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
/* VE_COMPACTFLASH: not modelled */
/* VE_CLCD: not modelled (we use the daughterboard CLCD only) */
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
/* 0x10020000 PL111 CLCD (daughterboard) */
sysbus_create_simple("pl111", 0x10020000, pic[44]);
/* 0x10060000 AXI RAM */
/* 0x100e0000 PL341 Dynamic Memory Controller */
/* 0x100e1000 PL354 Static Memory Controller */
/* 0x100e2000 System Configuration Controller */
sysbus_create_simple("sp804", 0x100e4000, pic[48]);
/* 0x100e5000 SP805 Watchdog module */
/* 0x100e6000 BP147 TrustZone Protection Controller */
/* 0x100e9000 PL301 'Fast' AXI matrix */
/* 0x100ea000 PL301 'Slow' AXI matrix */
/* 0x100ec000 TrustZone Address Space Controller */
/* 0x10200000 CoreSight debug APB */
/* 0x1e00a000 PL310 L2 Cache Controller */
sysbus_create_varargs("l2x0", 0x1e00a000, NULL);
/* VE_NORFLASH0: not modelled */
/* VE_NORFLASH0ALIAS: not modelled */
/* VE_NORFLASH1: not modelled */
sram_size = 0x2000000;
memory_region_init_ram(sram, "vexpress.sram", sram_size);
vmstate_register_ram_global(sram);
memory_region_add_subregion(sysmem, map[VE_SRAM], sram);
vram_size = 0x800000;
memory_region_init_ram(vram, "vexpress.vram", vram_size);
vmstate_register_ram_global(vram);
memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram);
/* 0x4e000000 LAN9118 Ethernet */
if (nd_table[0].vlan) {
lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);
}
/* VE_USB: not modelled */
/* VE_DAPROM: not modelled */
/* ??? Hack to map an additional page of ram for the secondary CPU
startup code. I guess this works on real hardware because the
BootROM happens to be in ROM/flash or in memory that isn't clobbered
until after Linux boots the secondary CPUs. */
memory_region_init_ram(hackram, "vexpress.hack", 0x1000);
vmstate_register_ram_global(hackram);
memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, hackram);
vexpress_binfo.ram_size = ram_size;
vexpress_binfo.kernel_filename = kernel_filename;
vexpress_binfo.kernel_cmdline = kernel_cmdline;
vexpress_binfo.initrd_filename = initrd_filename;
vexpress_binfo.nb_cpus = smp_cpus;
vexpress_binfo.board_id = VEXPRESS_BOARD_ID;
vexpress_binfo.loader_start = 0x60000000;
vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
arm_load_kernel(first_cpu, &vexpress_binfo);
}
| false | qemu | aac1e02c1d4b6d02f35a199a454fd46416380ff5 | static void vexpress_a9_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env = NULL;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *lowram = g_new(MemoryRegion, 1);
MemoryRegion *vram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *hackram = g_new(MemoryRegion, 1);
DeviceState *dev, *sysctl, *pl041;
SysBusDevice *busdev;
qemu_irq *irqp;
qemu_irq pic[64];
int n;
qemu_irq cpu_irq[4];
uint32_t proc_id;
uint32_t sys_id;
ram_addr_t low_ram_size, vram_size, sram_size;
target_phys_addr_t *map = motherboard_legacy_map;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
for (n = 0; n < smp_cpus; n++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
irqp = arm_pic_init_cpu(env);
cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ];
}
if (ram_size > 0x40000000) {
fprintf(stderr, "vexpress: cannot model more than 1GB RAM\n");
exit(1);
}
memory_region_init_ram(ram, "vexpress.highmem", ram_size);
vmstate_register_ram_global(ram);
low_ram_size = ram_size;
if (low_ram_size > 0x4000000) {
low_ram_size = 0x4000000;
}
memory_region_init_alias(lowram, "vexpress.lowmem", ram, 0, low_ram_size);
memory_region_add_subregion(sysmem, 0x0, lowram);
memory_region_add_subregion(sysmem, 0x60000000, ram);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
vexpress_binfo.smp_priv_base = 0x1e000000;
sysbus_mmio_map(busdev, 0, vexpress_binfo.smp_priv_base);
for (n = 0; n < smp_cpus; n++) {
sysbus_connect_irq(busdev, n, cpu_irq[n]);
}
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
sys_id = 0x1190f500;
proc_id = 0x0c000191;
sysctl = qdev_create(NULL, "realview_sysctl");
qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
qdev_init_nofail(sysctl);
sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, map[VE_SYSREGS]);
pl041 = qdev_create(NULL, "pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
qdev_init_nofail(pl041);
sysbus_mmio_map(sysbus_from_qdev(pl041), 0, map[VE_PL041]);
sysbus_connect_irq(sysbus_from_qdev(pl041), 0, pic[11]);
dev = sysbus_create_varargs("pl181", map[VE_MMCI], pic[9], pic[10], NULL);
qdev_connect_gpio_out(dev, 0,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));
qdev_connect_gpio_out(dev, 1,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN));
sysbus_create_simple("pl050_keyboard", map[VE_KMI0], pic[12]);
sysbus_create_simple("pl050_mouse", map[VE_KMI1], pic[13]);
sysbus_create_simple("pl011", map[VE_UART0], pic[5]);
sysbus_create_simple("pl011", map[VE_UART1], pic[6]);
sysbus_create_simple("pl011", map[VE_UART2], pic[7]);
sysbus_create_simple("pl011", map[VE_UART3], pic[8]);
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
sysbus_create_simple("pl031", map[VE_RTC], pic[4]);
sysbus_create_simple("pl111", 0x10020000, pic[44]);
sysbus_create_simple("sp804", 0x100e4000, pic[48]);
sysbus_create_varargs("l2x0", 0x1e00a000, NULL);
sram_size = 0x2000000;
memory_region_init_ram(sram, "vexpress.sram", sram_size);
vmstate_register_ram_global(sram);
memory_region_add_subregion(sysmem, map[VE_SRAM], sram);
vram_size = 0x800000;
memory_region_init_ram(vram, "vexpress.vram", vram_size);
vmstate_register_ram_global(vram);
memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram);
if (nd_table[0].vlan) {
lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);
}
memory_region_init_ram(hackram, "vexpress.hack", 0x1000);
vmstate_register_ram_global(hackram);
memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, hackram);
vexpress_binfo.ram_size = ram_size;
vexpress_binfo.kernel_filename = kernel_filename;
vexpress_binfo.kernel_cmdline = kernel_cmdline;
vexpress_binfo.initrd_filename = initrd_filename;
vexpress_binfo.nb_cpus = smp_cpus;
vexpress_binfo.board_id = VEXPRESS_BOARD_ID;
vexpress_binfo.loader_start = 0x60000000;
vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
arm_load_kernel(first_cpu, &vexpress_binfo);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ram_addr_t VAR_0,
const char *VAR_1,
const char *VAR_2, const char *VAR_3,
const char *VAR_4, const char *VAR_5)
{
CPUState *env = NULL;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *lowram = g_new(MemoryRegion, 1);
MemoryRegion *vram = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
MemoryRegion *hackram = g_new(MemoryRegion, 1);
DeviceState *dev, *sysctl, *pl041;
SysBusDevice *busdev;
qemu_irq *irqp;
qemu_irq pic[64];
int VAR_6;
qemu_irq cpu_irq[4];
uint32_t proc_id;
uint32_t sys_id;
ram_addr_t low_ram_size, vram_size, sram_size;
target_phys_addr_t *map = motherboard_legacy_map;
if (!VAR_5) {
VAR_5 = "cortex-a9";
}
for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) {
env = cpu_init(VAR_5);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\VAR_6");
exit(1);
}
irqp = arm_pic_init_cpu(env);
cpu_irq[VAR_6] = irqp[ARM_PIC_CPU_IRQ];
}
if (VAR_0 > 0x40000000) {
fprintf(stderr, "vexpress: cannot model more than 1GB RAM\VAR_6");
exit(1);
}
memory_region_init_ram(ram, "vexpress.highmem", VAR_0);
vmstate_register_ram_global(ram);
low_ram_size = VAR_0;
if (low_ram_size > 0x4000000) {
low_ram_size = 0x4000000;
}
memory_region_init_alias(lowram, "vexpress.lowmem", ram, 0, low_ram_size);
memory_region_add_subregion(sysmem, 0x0, lowram);
memory_region_add_subregion(sysmem, 0x60000000, ram);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
vexpress_binfo.smp_priv_base = 0x1e000000;
sysbus_mmio_map(busdev, 0, vexpress_binfo.smp_priv_base);
for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) {
sysbus_connect_irq(busdev, VAR_6, cpu_irq[VAR_6]);
}
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);
}
sys_id = 0x1190f500;
proc_id = 0x0c000191;
sysctl = qdev_create(NULL, "realview_sysctl");
qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
qdev_init_nofail(sysctl);
sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, map[VE_SYSREGS]);
pl041 = qdev_create(NULL, "pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
qdev_init_nofail(pl041);
sysbus_mmio_map(sysbus_from_qdev(pl041), 0, map[VE_PL041]);
sysbus_connect_irq(sysbus_from_qdev(pl041), 0, pic[11]);
dev = sysbus_create_varargs("pl181", map[VE_MMCI], pic[9], pic[10], NULL);
qdev_connect_gpio_out(dev, 0,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));
qdev_connect_gpio_out(dev, 1,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN));
sysbus_create_simple("pl050_keyboard", map[VE_KMI0], pic[12]);
sysbus_create_simple("pl050_mouse", map[VE_KMI1], pic[13]);
sysbus_create_simple("pl011", map[VE_UART0], pic[5]);
sysbus_create_simple("pl011", map[VE_UART1], pic[6]);
sysbus_create_simple("pl011", map[VE_UART2], pic[7]);
sysbus_create_simple("pl011", map[VE_UART3], pic[8]);
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
sysbus_create_simple("pl031", map[VE_RTC], pic[4]);
sysbus_create_simple("pl111", 0x10020000, pic[44]);
sysbus_create_simple("sp804", 0x100e4000, pic[48]);
sysbus_create_varargs("l2x0", 0x1e00a000, NULL);
sram_size = 0x2000000;
memory_region_init_ram(sram, "vexpress.sram", sram_size);
vmstate_register_ram_global(sram);
memory_region_add_subregion(sysmem, map[VE_SRAM], sram);
vram_size = 0x800000;
memory_region_init_ram(vram, "vexpress.vram", vram_size);
vmstate_register_ram_global(vram);
memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram);
if (nd_table[0].vlan) {
lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);
}
memory_region_init_ram(hackram, "vexpress.hack", 0x1000);
vmstate_register_ram_global(hackram);
memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, hackram);
vexpress_binfo.VAR_0 = VAR_0;
vexpress_binfo.VAR_2 = VAR_2;
vexpress_binfo.VAR_3 = VAR_3;
vexpress_binfo.VAR_4 = VAR_4;
vexpress_binfo.nb_cpus = smp_cpus;
vexpress_binfo.board_id = VEXPRESS_BOARD_ID;
vexpress_binfo.loader_start = 0x60000000;
vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
arm_load_kernel(first_cpu, &vexpress_binfo);
}
| [
"static void FUNC_0(ram_addr_t VAR_0,\nconst char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5)\n{",
"CPUState *env = NULL;",
"MemoryRegion *sysmem = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"MemoryRegion *lowram = g_new(MemoryRegion, 1);",
"MemoryRegion *vram = g_new(MemoryRegion, 1);",
"MemoryRegion *sram = g_new(MemoryRegion, 1);",
"MemoryRegion *hackram = g_new(MemoryRegion, 1);",
"DeviceState *dev, *sysctl, *pl041;",
"SysBusDevice *busdev;",
"qemu_irq *irqp;",
"qemu_irq pic[64];",
"int VAR_6;",
"qemu_irq cpu_irq[4];",
"uint32_t proc_id;",
"uint32_t sys_id;",
"ram_addr_t low_ram_size, vram_size, sram_size;",
"target_phys_addr_t *map = motherboard_legacy_map;",
"if (!VAR_5) {",
"VAR_5 = \"cortex-a9\";",
"}",
"for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) {",
"env = cpu_init(VAR_5);",
"if (!env) {",
"fprintf(stderr, \"Unable to find CPU definition\\VAR_6\");",
"exit(1);",
"}",
"irqp = arm_pic_init_cpu(env);",
"cpu_irq[VAR_6] = irqp[ARM_PIC_CPU_IRQ];",
"}",
"if (VAR_0 > 0x40000000) {",
"fprintf(stderr, \"vexpress: cannot model more than 1GB RAM\\VAR_6\");",
"exit(1);",
"}",
"memory_region_init_ram(ram, \"vexpress.highmem\", VAR_0);",
"vmstate_register_ram_global(ram);",
"low_ram_size = VAR_0;",
"if (low_ram_size > 0x4000000) {",
"low_ram_size = 0x4000000;",
"}",
"memory_region_init_alias(lowram, \"vexpress.lowmem\", ram, 0, low_ram_size);",
"memory_region_add_subregion(sysmem, 0x0, lowram);",
"memory_region_add_subregion(sysmem, 0x60000000, ram);",
"dev = qdev_create(NULL, \"a9mpcore_priv\");",
"qdev_prop_set_uint32(dev, \"num-cpu\", smp_cpus);",
"qdev_init_nofail(dev);",
"busdev = sysbus_from_qdev(dev);",
"vexpress_binfo.smp_priv_base = 0x1e000000;",
"sysbus_mmio_map(busdev, 0, vexpress_binfo.smp_priv_base);",
"for (VAR_6 = 0; VAR_6 < smp_cpus; VAR_6++) {",
"sysbus_connect_irq(busdev, VAR_6, cpu_irq[VAR_6]);",
"}",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"pic[VAR_6] = qdev_get_gpio_in(dev, VAR_6);",
"}",
"sys_id = 0x1190f500;",
"proc_id = 0x0c000191;",
"sysctl = qdev_create(NULL, \"realview_sysctl\");",
"qdev_prop_set_uint32(sysctl, \"sys_id\", sys_id);",
"qdev_prop_set_uint32(sysctl, \"proc_id\", proc_id);",
"qdev_init_nofail(sysctl);",
"sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, map[VE_SYSREGS]);",
"pl041 = qdev_create(NULL, \"pl041\");",
"qdev_prop_set_uint32(pl041, \"nc_fifo_depth\", 512);",
"qdev_init_nofail(pl041);",
"sysbus_mmio_map(sysbus_from_qdev(pl041), 0, map[VE_PL041]);",
"sysbus_connect_irq(sysbus_from_qdev(pl041), 0, pic[11]);",
"dev = sysbus_create_varargs(\"pl181\", map[VE_MMCI], pic[9], pic[10], NULL);",
"qdev_connect_gpio_out(dev, 0,\nqdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));",
"qdev_connect_gpio_out(dev, 1,\nqdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN));",
"sysbus_create_simple(\"pl050_keyboard\", map[VE_KMI0], pic[12]);",
"sysbus_create_simple(\"pl050_mouse\", map[VE_KMI1], pic[13]);",
"sysbus_create_simple(\"pl011\", map[VE_UART0], pic[5]);",
"sysbus_create_simple(\"pl011\", map[VE_UART1], pic[6]);",
"sysbus_create_simple(\"pl011\", map[VE_UART2], pic[7]);",
"sysbus_create_simple(\"pl011\", map[VE_UART3], pic[8]);",
"sysbus_create_simple(\"sp804\", map[VE_TIMER01], pic[2]);",
"sysbus_create_simple(\"sp804\", map[VE_TIMER23], pic[3]);",
"sysbus_create_simple(\"pl031\", map[VE_RTC], pic[4]);",
"sysbus_create_simple(\"pl111\", 0x10020000, pic[44]);",
"sysbus_create_simple(\"sp804\", 0x100e4000, pic[48]);",
"sysbus_create_varargs(\"l2x0\", 0x1e00a000, NULL);",
"sram_size = 0x2000000;",
"memory_region_init_ram(sram, \"vexpress.sram\", sram_size);",
"vmstate_register_ram_global(sram);",
"memory_region_add_subregion(sysmem, map[VE_SRAM], sram);",
"vram_size = 0x800000;",
"memory_region_init_ram(vram, \"vexpress.vram\", vram_size);",
"vmstate_register_ram_global(vram);",
"memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram);",
"if (nd_table[0].vlan) {",
"lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);",
"}",
"memory_region_init_ram(hackram, \"vexpress.hack\", 0x1000);",
"vmstate_register_ram_global(hackram);",
"memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, hackram);",
"vexpress_binfo.VAR_0 = VAR_0;",
"vexpress_binfo.VAR_2 = VAR_2;",
"vexpress_binfo.VAR_3 = VAR_3;",
"vexpress_binfo.VAR_4 = VAR_4;",
"vexpress_binfo.nb_cpus = smp_cpus;",
"vexpress_binfo.board_id = VEXPRESS_BOARD_ID;",
"vexpress_binfo.loader_start = 0x60000000;",
"vexpress_binfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;",
"arm_load_kernel(first_cpu, &vexpress_binfo);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
147
],
[
149
],
[
151
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
203,
205
],
[
207,
209
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
239
],
[
257
],
[
271
],
[
287
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
],
[
313
],
[
315
],
[
321
],
[
323
],
[
325
],
[
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
]
] |
2,727 | static void gpollfds_to_select(int ret)
{
int i;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
if (ret <= 0) {
return;
}
for (i = 0; i < gpollfds->len; i++) {
int fd = g_array_index(gpollfds, GPollFD, i).fd;
int revents = g_array_index(gpollfds, GPollFD, i).revents;
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
FD_SET(fd, &rfds);
}
if (revents & (G_IO_OUT | G_IO_ERR)) {
FD_SET(fd, &wfds);
}
if (revents & G_IO_PRI) {
FD_SET(fd, &xfds);
}
}
}
| false | qemu | 9cbaacf999b01b27dc3a22502705178057af66de | static void gpollfds_to_select(int ret)
{
int i;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
if (ret <= 0) {
return;
}
for (i = 0; i < gpollfds->len; i++) {
int fd = g_array_index(gpollfds, GPollFD, i).fd;
int revents = g_array_index(gpollfds, GPollFD, i).revents;
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
FD_SET(fd, &rfds);
}
if (revents & (G_IO_OUT | G_IO_ERR)) {
FD_SET(fd, &wfds);
}
if (revents & G_IO_PRI) {
FD_SET(fd, &xfds);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
int VAR_1;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
FD_ZERO(&xfds);
if (VAR_0 <= 0) {
return;
}
for (VAR_1 = 0; VAR_1 < gpollfds->len; VAR_1++) {
int fd = g_array_index(gpollfds, GPollFD, VAR_1).fd;
int revents = g_array_index(gpollfds, GPollFD, VAR_1).revents;
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {
FD_SET(fd, &rfds);
}
if (revents & (G_IO_OUT | G_IO_ERR)) {
FD_SET(fd, &wfds);
}
if (revents & G_IO_PRI) {
FD_SET(fd, &xfds);
}
}
}
| [
"static void FUNC_0(int VAR_0)\n{",
"int VAR_1;",
"FD_ZERO(&rfds);",
"FD_ZERO(&wfds);",
"FD_ZERO(&xfds);",
"if (VAR_0 <= 0) {",
"return;",
"}",
"for (VAR_1 = 0; VAR_1 < gpollfds->len; VAR_1++) {",
"int fd = g_array_index(gpollfds, GPollFD, VAR_1).fd;",
"int revents = g_array_index(gpollfds, GPollFD, VAR_1).revents;",
"if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) {",
"FD_SET(fd, &rfds);",
"}",
"if (revents & (G_IO_OUT | G_IO_ERR)) {",
"FD_SET(fd, &wfds);",
"}",
"if (revents & G_IO_PRI) {",
"FD_SET(fd, &xfds);",
"}",
"}",
"}"
] | [
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
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
2,728 | static void cpu_4xx_pit_cb (void *opaque)
{
CPUState *env;
ppc_tb_t *tb_env;
ppcemb_timer_t *ppcemb_timer;
env = opaque;
tb_env = env->tb_env;
ppcemb_timer = tb_env->opaque;
env->spr[SPR_40x_TSR] |= 1 << 27;
if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)
ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
start_stop_pit(env, tb_env, 1);
LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " "
"%016" PRIx64 "\n", __func__,
(int)((env->spr[SPR_40x_TCR] >> 22) & 0x1),
(int)((env->spr[SPR_40x_TCR] >> 26) & 0x1),
env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR],
ppcemb_timer->pit_reload);
}
| false | qemu | d63cb48db9016328a7a69f3a1c2938cd3dfc9d1a | static void cpu_4xx_pit_cb (void *opaque)
{
CPUState *env;
ppc_tb_t *tb_env;
ppcemb_timer_t *ppcemb_timer;
env = opaque;
tb_env = env->tb_env;
ppcemb_timer = tb_env->opaque;
env->spr[SPR_40x_TSR] |= 1 << 27;
if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)
ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
start_stop_pit(env, tb_env, 1);
LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " "
"%016" PRIx64 "\n", __func__,
(int)((env->spr[SPR_40x_TCR] >> 22) & 0x1),
(int)((env->spr[SPR_40x_TCR] >> 26) & 0x1),
env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR],
ppcemb_timer->pit_reload);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0)
{
CPUState *env;
ppc_tb_t *tb_env;
ppcemb_timer_t *ppcemb_timer;
env = VAR_0;
tb_env = env->tb_env;
ppcemb_timer = tb_env->VAR_0;
env->spr[SPR_40x_TSR] |= 1 << 27;
if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)
ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
start_stop_pit(env, tb_env, 1);
LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " "
"%016" PRIx64 "\n", __func__,
(int)((env->spr[SPR_40x_TCR] >> 22) & 0x1),
(int)((env->spr[SPR_40x_TCR] >> 26) & 0x1),
env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR],
ppcemb_timer->pit_reload);
}
| [
"static void FUNC_0 (void *VAR_0)\n{",
"CPUState *env;",
"ppc_tb_t *tb_env;",
"ppcemb_timer_t *ppcemb_timer;",
"env = VAR_0;",
"tb_env = env->tb_env;",
"ppcemb_timer = tb_env->VAR_0;",
"env->spr[SPR_40x_TSR] |= 1 << 27;",
"if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)\nppc_set_irq(env, PPC_INTERRUPT_PIT, 1);",
"start_stop_pit(env, tb_env, 1);",
"LOG_TB(\"%s: ar %d ir %d TCR \" TARGET_FMT_lx \" TSR \" TARGET_FMT_lx \" \"\n\"%016\" PRIx64 \"\\n\", __func__,\n(int)((env->spr[SPR_40x_TCR] >> 22) & 0x1),\n(int)((env->spr[SPR_40x_TCR] >> 26) & 0x1),\nenv->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR],\nppcemb_timer->pit_reload);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29,
31,
33,
35,
37
],
[
39
]
] |
2,729 | CPUArchState *cpu_copy(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *new_env = cpu_init(cpu_model);
CPUState *new_cpu = ENV_GET_CPU(new_env);
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
CPUWatchpoint *wp;
#endif
/* Reset non arch specific state */
cpu_reset(new_cpu);
memcpy(new_env, env, sizeof(CPUArchState));
/* Clone all break/watchpoints.
Note: Once we support ptrace with hw-debug register access, make sure
BP_CPU break/watchpoints are handled correctly on clone. */
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
#if defined(TARGET_HAS_ICE)
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
}
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);
}
#endif
return new_env;
}
| false | qemu | ec53b45bcd1f74f7a4c31331fa6d50b402cd6d26 | CPUArchState *cpu_copy(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *new_env = cpu_init(cpu_model);
CPUState *new_cpu = ENV_GET_CPU(new_env);
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
CPUWatchpoint *wp;
#endif
cpu_reset(new_cpu);
memcpy(new_env, env, sizeof(CPUArchState));
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
#if defined(TARGET_HAS_ICE)
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
}
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);
}
#endif
return new_env;
}
| {
"code": [],
"line_no": []
} | CPUArchState *FUNC_0(CPUArchState *env)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *new_env = cpu_init(cpu_model);
CPUState *new_cpu = ENV_GET_CPU(new_env);
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
CPUWatchpoint *wp;
#endif
cpu_reset(new_cpu);
memcpy(new_env, env, sizeof(CPUArchState));
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
#if defined(TARGET_HAS_ICE)
QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
}
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);
}
#endif
return new_env;
}
| [
"CPUArchState *FUNC_0(CPUArchState *env)\n{",
"CPUState *cpu = ENV_GET_CPU(env);",
"CPUArchState *new_env = cpu_init(cpu_model);",
"CPUState *new_cpu = ENV_GET_CPU(new_env);",
"#if defined(TARGET_HAS_ICE)\nCPUBreakpoint *bp;",
"CPUWatchpoint *wp;",
"#endif\ncpu_reset(new_cpu);",
"memcpy(new_env, env, sizeof(CPUArchState));",
"QTAILQ_INIT(&cpu->breakpoints);",
"QTAILQ_INIT(&cpu->watchpoints);",
"#if defined(TARGET_HAS_ICE)\nQTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {",
"cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);",
"}",
"QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {",
"cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);",
"}",
"#endif\nreturn new_env;",
"}"
] | [
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
],
[
27
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
59
],
[
61
]
] |
2,730 | static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
{
mdct->fft.mdct_calc(&mdct->fft, out, in);
}
| false | FFmpeg | 79997def65fd2313b48a5f3c3a884c6149ae9b5d | static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
{
mdct->fft.mdct_calc(&mdct->fft, out, in);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3MDCTContext *VAR_0, float *VAR_1, float *VAR_2)
{
VAR_0->fft.mdct_calc(&VAR_0->fft, VAR_1, VAR_2);
}
| [
"static void FUNC_0(AC3MDCTContext *VAR_0, float *VAR_1, float *VAR_2)\n{",
"VAR_0->fft.mdct_calc(&VAR_0->fft, VAR_1, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
2,731 | static void av_noinline qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
if(!refdata)
refdata= dst;
/* copy prev frame */
for(i = 0; i < height; i++)
memcpy(dst + (i * stride), refdata + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
/* motion compensation */
while(bytestream2_get_bytes_left(&qctx->buffer) > 0 && (code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
/* get block size by index */
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
/* extract motion vector */
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
/* check motion vector */
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y >= orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
/* do motion compensation */
me_plane = refdata + (filled + me_x) + (height - me_y) * stride;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * stride)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0) /* end-of-picture code */
break;
if(code > 0xE0) { /* run code: 0xE1..0xFF */
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
code &= 0x1F;
if(code + 1 > bytestream2_get_bytes_left(&qctx->buffer))
break;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) { /* skip code: 0x80..0xBF */
int skip;
code &= 0x3F;
/* codes 0x80 and 0x81 are actually escape codes,
skip value minus constant is in the next byte */
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
/* zero code treated as one-pixel skip */
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| false | FFmpeg | 921706691a87c3ea5f5b92afd9b423e5f8c6e9d9 | static void av_noinline qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
if(!refdata)
refdata= dst;
for(i = 0; i < height; i++)
memcpy(dst + (i * stride), refdata + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
while(bytestream2_get_bytes_left(&qctx->buffer) > 0 && (code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y >= orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
me_plane = refdata + (filled + me_x) + (height - me_y) * stride;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * stride)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0)
break;
if(code > 0xE0) {
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) {
code &= 0x1F;
if(code + 1 > bytestream2_get_bytes_left(&qctx->buffer))
break;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) {
int skip;
code &= 0x3F;
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| {
"code": [],
"line_no": []
} | static void VAR_0 qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
int stride, int width, int height,
int delta, const uint8_t *ctable,
uint8_t *refdata)
{
int i, j;
int code;
int filled = 0;
int orig_height;
if(!refdata)
refdata= dst;
for(i = 0; i < height; i++)
memcpy(dst + (i * stride), refdata + (i * stride), width);
orig_height = height;
height--;
dst = dst + height * stride;
while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {
code = bytestream2_get_byte(&qctx->buffer);
if(delta) {
while(bytestream2_get_bytes_left(&qctx->buffer) > 0 && (code & 0xF0) == 0xF0) {
if(delta == 1) {
int me_idx;
int me_w, me_h, me_x, me_y;
uint8_t *me_plane;
int corr, val;
me_idx = code & 0xF;
me_w = qpeg_table_w[me_idx];
me_h = qpeg_table_h[me_idx];
corr = bytestream2_get_byte(&qctx->buffer);
val = corr >> 4;
if(val > 7)
val -= 16;
me_x = val;
val = corr & 0xF;
if(val > 7)
val -= 16;
me_y = val;
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
(height - me_y - me_h < 0) || (height - me_y >= orig_height) ||
(filled + me_w > width) || (height - me_h < 0))
av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n",
me_x, me_y, me_w, me_h, filled, height);
else {
me_plane = refdata + (filled + me_x) + (height - me_y) * stride;
for(j = 0; j < me_h; j++) {
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * stride)];
}
}
}
code = bytestream2_get_byte(&qctx->buffer);
}
}
if(code == 0xE0)
break;
if(code > 0xE0) {
int p;
code &= 0x1F;
p = bytestream2_get_byte(&qctx->buffer);
for(i = 0; i <= code; i++) {
dst[filled++] = p;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0xC0) {
code &= 0x1F;
if(code + 1 > bytestream2_get_bytes_left(&qctx->buffer))
break;
for(i = 0; i <= code; i++) {
dst[filled++] = bytestream2_get_byte(&qctx->buffer);
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
if (height < 0)
break;
}
}
} else if(code >= 0x80) {
int skip;
code &= 0x3F;
if(!code)
skip = bytestream2_get_byte(&qctx->buffer) + 64;
else if(code == 1)
skip = bytestream2_get_byte(&qctx->buffer) + 320;
else
skip = code;
filled += skip;
while( filled >= width) {
filled -= width;
dst -= stride;
height--;
if(height < 0)
break;
}
} else {
if(code) {
dst[filled++] = ctable[code & 0x7F];
}
else
filled++;
if(filled >= width) {
filled = 0;
dst -= stride;
height--;
}
}
}
}
| [
"static void VAR_0 qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,\nint stride, int width, int height,\nint delta, const uint8_t *ctable,\nuint8_t *refdata)\n{",
"int i, j;",
"int code;",
"int filled = 0;",
"int orig_height;",
"if(!refdata)\nrefdata= dst;",
"for(i = 0; i < height; i++)",
"memcpy(dst + (i * stride), refdata + (i * stride), width);",
"orig_height = height;",
"height--;",
"dst = dst + height * stride;",
"while ((bytestream2_get_bytes_left(&qctx->buffer) > 0) && (height >= 0)) {",
"code = bytestream2_get_byte(&qctx->buffer);",
"if(delta) {",
"while(bytestream2_get_bytes_left(&qctx->buffer) > 0 && (code & 0xF0) == 0xF0) {",
"if(delta == 1) {",
"int me_idx;",
"int me_w, me_h, me_x, me_y;",
"uint8_t *me_plane;",
"int corr, val;",
"me_idx = code & 0xF;",
"me_w = qpeg_table_w[me_idx];",
"me_h = qpeg_table_h[me_idx];",
"corr = bytestream2_get_byte(&qctx->buffer);",
"val = corr >> 4;",
"if(val > 7)\nval -= 16;",
"me_x = val;",
"val = corr & 0xF;",
"if(val > 7)\nval -= 16;",
"me_y = val;",
"if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||\n(height - me_y - me_h < 0) || (height - me_y >= orig_height) ||\n(filled + me_w > width) || (height - me_h < 0))\nav_log(NULL, AV_LOG_ERROR, \"Bogus motion vector (%i,%i), block size %ix%i at %i,%i\\n\",\nme_x, me_y, me_w, me_h, filled, height);",
"else {",
"me_plane = refdata + (filled + me_x) + (height - me_y) * stride;",
"for(j = 0; j < me_h; j++) {",
"for(i = 0; i < me_w; i++)",
"dst[filled + i - (j * stride)] = me_plane[i - (j * stride)];",
"}",
"}",
"}",
"code = bytestream2_get_byte(&qctx->buffer);",
"}",
"}",
"if(code == 0xE0)\nbreak;",
"if(code > 0xE0) {",
"int p;",
"code &= 0x1F;",
"p = bytestream2_get_byte(&qctx->buffer);",
"for(i = 0; i <= code; i++) {",
"dst[filled++] = p;",
"if(filled >= width) {",
"filled = 0;",
"dst -= stride;",
"height--;",
"if (height < 0)\nbreak;",
"}",
"}",
"} else if(code >= 0xC0) {",
"code &= 0x1F;",
"if(code + 1 > bytestream2_get_bytes_left(&qctx->buffer))\nbreak;",
"for(i = 0; i <= code; i++) {",
"dst[filled++] = bytestream2_get_byte(&qctx->buffer);",
"if(filled >= width) {",
"filled = 0;",
"dst -= stride;",
"height--;",
"if (height < 0)\nbreak;",
"}",
"}",
"} else if(code >= 0x80) {",
"int skip;",
"code &= 0x3F;",
"if(!code)\nskip = bytestream2_get_byte(&qctx->buffer) + 64;",
"else if(code == 1)\nskip = bytestream2_get_byte(&qctx->buffer) + 320;",
"else\nskip = code;",
"filled += skip;",
"while( filled >= width) {",
"filled -= width;",
"dst -= stride;",
"height--;",
"if(height < 0)\nbreak;",
"}",
"} else {",
"if(code) {",
"dst[filled++] = ctable[code & 0x7F];",
"}",
"else\nfilled++;",
"if(filled >= width) {",
"filled = 0;",
"dst -= stride;",
"height--;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
93
],
[
95,
97
],
[
99
],
[
105,
107,
109,
111,
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181,
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
219,
221
],
[
223,
225
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
]
] |
2,732 | static void block_job_detach_aio_context(void *opaque)
{
BlockJob *job = opaque;
/* In case the job terminates during aio_poll()... */
block_job_ref(job);
block_job_pause(job);
if (!job->paused) {
/* If job is !job->busy this kicks it into the next pause point. */
block_job_enter(job);
}
while (!job->paused && !job->completed) {
aio_poll(block_job_get_aio_context(job), true);
}
block_job_unref(job);
}
| false | qemu | bae8196d9f97916de6323e70e3e374362ee16ec4 | static void block_job_detach_aio_context(void *opaque)
{
BlockJob *job = opaque;
block_job_ref(job);
block_job_pause(job);
if (!job->paused) {
block_job_enter(job);
}
while (!job->paused && !job->completed) {
aio_poll(block_job_get_aio_context(job), true);
}
block_job_unref(job);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
BlockJob *job = VAR_0;
block_job_ref(job);
block_job_pause(job);
if (!job->paused) {
block_job_enter(job);
}
while (!job->paused && !job->completed) {
aio_poll(block_job_get_aio_context(job), true);
}
block_job_unref(job);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"BlockJob *job = VAR_0;",
"block_job_ref(job);",
"block_job_pause(job);",
"if (!job->paused) {",
"block_job_enter(job);",
"}",
"while (!job->paused && !job->completed) {",
"aio_poll(block_job_get_aio_context(job), true);",
"}",
"block_job_unref(job);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
2,733 | void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)
{
int mapped_node_id; /* set by -numa option */
int node_id = object_property_get_int(OBJECT(dev), "node-id", &error_abort);
/* by default CPUState::numa_node was 0 if it wasn't set explicitly
* TODO: make it error when incomplete numa mapping support is removed
*/
mapped_node_id = slot->props.node_id;
if (!slot->props.has_node_id) {
mapped_node_id = 0;
}
if (node_id == CPU_UNSET_NUMA_NODE_ID) {
/* due to bug in libvirt, it doesn't pass node-id from props on
* device_add as expected, so we have to fix it up here */
object_property_set_int(OBJECT(dev), mapped_node_id, "node-id", errp);
} else if (node_id != mapped_node_id) {
error_setg(errp, "node-id=%d must match numa node specified "
"with -numa option", node_id);
}
}
| false | qemu | d41f3e750d2c06c613cb1b8db7724f0fbc0a2b14 | void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)
{
int mapped_node_id;
int node_id = object_property_get_int(OBJECT(dev), "node-id", &error_abort);
mapped_node_id = slot->props.node_id;
if (!slot->props.has_node_id) {
mapped_node_id = 0;
}
if (node_id == CPU_UNSET_NUMA_NODE_ID) {
object_property_set_int(OBJECT(dev), mapped_node_id, "node-id", errp);
} else if (node_id != mapped_node_id) {
error_setg(errp, "node-id=%d must match numa node specified "
"with -numa option", node_id);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const CPUArchId *VAR_0, DeviceState *VAR_1, Error **VAR_2)
{
int VAR_3;
int VAR_4 = object_property_get_int(OBJECT(VAR_1), "node-id", &error_abort);
VAR_3 = VAR_0->props.VAR_4;
if (!VAR_0->props.has_node_id) {
VAR_3 = 0;
}
if (VAR_4 == CPU_UNSET_NUMA_NODE_ID) {
object_property_set_int(OBJECT(VAR_1), VAR_3, "node-id", VAR_2);
} else if (VAR_4 != VAR_3) {
error_setg(VAR_2, "node-id=%d must match numa node specified "
"with -numa option", VAR_4);
}
}
| [
"void FUNC_0(const CPUArchId *VAR_0, DeviceState *VAR_1, Error **VAR_2)\n{",
"int VAR_3;",
"int VAR_4 = object_property_get_int(OBJECT(VAR_1), \"node-id\", &error_abort);",
"VAR_3 = VAR_0->props.VAR_4;",
"if (!VAR_0->props.has_node_id) {",
"VAR_3 = 0;",
"}",
"if (VAR_4 == CPU_UNSET_NUMA_NODE_ID) {",
"object_property_set_int(OBJECT(VAR_1), VAR_3, \"node-id\", VAR_2);",
"} else if (VAR_4 != VAR_3) {",
"error_setg(VAR_2, \"node-id=%d must match numa node specified \"\n\"with -numa option\", VAR_4);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
]
] |
2,734 | static void multiwrite_cb(void *opaque, int ret)
{
MultiwriteCB *mcb = opaque;
trace_multiwrite_cb(mcb, ret);
if (ret < 0 && !mcb->error) {
mcb->error = ret;
}
mcb->num_requests--;
if (mcb->num_requests == 0) {
multiwrite_user_cb(mcb);
g_free(mcb);
}
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | static void multiwrite_cb(void *opaque, int ret)
{
MultiwriteCB *mcb = opaque;
trace_multiwrite_cb(mcb, ret);
if (ret < 0 && !mcb->error) {
mcb->error = ret;
}
mcb->num_requests--;
if (mcb->num_requests == 0) {
multiwrite_user_cb(mcb);
g_free(mcb);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
MultiwriteCB *mcb = VAR_0;
trace_multiwrite_cb(mcb, VAR_1);
if (VAR_1 < 0 && !mcb->error) {
mcb->error = VAR_1;
}
mcb->num_requests--;
if (mcb->num_requests == 0) {
multiwrite_user_cb(mcb);
g_free(mcb);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"MultiwriteCB *mcb = VAR_0;",
"trace_multiwrite_cb(mcb, VAR_1);",
"if (VAR_1 < 0 && !mcb->error) {",
"mcb->error = VAR_1;",
"}",
"mcb->num_requests--;",
"if (mcb->num_requests == 0) {",
"multiwrite_user_cb(mcb);",
"g_free(mcb);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
2,735 | static void qdict_setup(void)
{
tests_dict = qdict_new();
fail_unless(tests_dict != NULL);
}
| false | qemu | ac531cb6e542b1e61d668604adf9dc5306a948c0 | static void qdict_setup(void)
{
tests_dict = qdict_new();
fail_unless(tests_dict != NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
tests_dict = qdict_new();
fail_unless(tests_dict != NULL);
}
| [
"static void FUNC_0(void)\n{",
"tests_dict = qdict_new();",
"fail_unless(tests_dict != NULL);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
2,736 | static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVParallelsState *s = bs->opaque;
int i;
ParallelsHeader ph;
int ret;
ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));
if (ret < 0) {
goto fail;
}
bs->total_sectors = le64_to_cpu(ph.nb_sectors);
if (le32_to_cpu(ph.version) != HEADER_VERSION) {
goto fail_format;
}
if (!memcmp(ph.magic, HEADER_MAGIC, 16)) {
s->off_multiplier = 1;
bs->total_sectors = 0xffffffff & bs->total_sectors;
} else if (!memcmp(ph.magic, HEADER_MAGIC2, 16)) {
s->off_multiplier = le32_to_cpu(ph.tracks);
} else {
goto fail_format;
}
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(errp, "Invalid image: Zero sectors per track");
ret = -EINVAL;
goto fail;
}
if (s->tracks > INT32_MAX/513) {
error_setg(errp, "Invalid image: Too big cluster");
ret = -EFBIG;
goto fail;
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size);
if (s->catalog_size && s->catalog_bitmap == NULL) {
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, sizeof(ParallelsHeader),
s->catalog_bitmap, s->catalog_size * sizeof(uint32_t));
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->has_truncate = bdrv_has_zero_init(bs->file) &&
bdrv_truncate(bs->file, bdrv_getlength(bs->file)) == 0;
qemu_co_mutex_init(&s->lock);
return 0;
fail_format:
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
fail:
g_free(s->catalog_bitmap);
return ret;
}
| false | qemu | 369f7de9d57e4dd2f312255fc12271d5749c0a4e | static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVParallelsState *s = bs->opaque;
int i;
ParallelsHeader ph;
int ret;
ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));
if (ret < 0) {
goto fail;
}
bs->total_sectors = le64_to_cpu(ph.nb_sectors);
if (le32_to_cpu(ph.version) != HEADER_VERSION) {
goto fail_format;
}
if (!memcmp(ph.magic, HEADER_MAGIC, 16)) {
s->off_multiplier = 1;
bs->total_sectors = 0xffffffff & bs->total_sectors;
} else if (!memcmp(ph.magic, HEADER_MAGIC2, 16)) {
s->off_multiplier = le32_to_cpu(ph.tracks);
} else {
goto fail_format;
}
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(errp, "Invalid image: Zero sectors per track");
ret = -EINVAL;
goto fail;
}
if (s->tracks > INT32_MAX/513) {
error_setg(errp, "Invalid image: Too big cluster");
ret = -EFBIG;
goto fail;
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size);
if (s->catalog_size && s->catalog_bitmap == NULL) {
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, sizeof(ParallelsHeader),
s->catalog_bitmap, s->catalog_size * sizeof(uint32_t));
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->has_truncate = bdrv_has_zero_init(bs->file) &&
bdrv_truncate(bs->file, bdrv_getlength(bs->file)) == 0;
qemu_co_mutex_init(&s->lock);
return 0;
fail_format:
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
fail:
g_free(s->catalog_bitmap);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVParallelsState *s = VAR_0->opaque;
int VAR_4;
ParallelsHeader ph;
int VAR_5;
VAR_5 = bdrv_pread(VAR_0->file, 0, &ph, sizeof(ph));
if (VAR_5 < 0) {
goto fail;
}
VAR_0->total_sectors = le64_to_cpu(ph.nb_sectors);
if (le32_to_cpu(ph.version) != HEADER_VERSION) {
goto fail_format;
}
if (!memcmp(ph.magic, HEADER_MAGIC, 16)) {
s->off_multiplier = 1;
VAR_0->total_sectors = 0xffffffff & VAR_0->total_sectors;
} else if (!memcmp(ph.magic, HEADER_MAGIC2, 16)) {
s->off_multiplier = le32_to_cpu(ph.tracks);
} else {
goto fail_format;
}
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(VAR_3, "Invalid image: Zero sectors per track");
VAR_5 = -EINVAL;
goto fail;
}
if (s->tracks > INT32_MAX/513) {
error_setg(VAR_3, "Invalid image: Too big cluster");
VAR_5 = -EFBIG;
goto fail;
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {
error_setg(VAR_3, "Catalog too large");
VAR_5 = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size);
if (s->catalog_size && s->catalog_bitmap == NULL) {
VAR_5 = -ENOMEM;
goto fail;
}
VAR_5 = bdrv_pread(VAR_0->file, sizeof(ParallelsHeader),
s->catalog_bitmap, s->catalog_size * sizeof(uint32_t));
if (VAR_5 < 0) {
goto fail;
}
for (VAR_4 = 0; VAR_4 < s->catalog_size; VAR_4++)
le32_to_cpus(&s->catalog_bitmap[VAR_4]);
s->has_truncate = bdrv_has_zero_init(VAR_0->file) &&
bdrv_truncate(VAR_0->file, bdrv_getlength(VAR_0->file)) == 0;
qemu_co_mutex_init(&s->lock);
return 0;
fail_format:
error_setg(VAR_3, "Image not in Parallels format");
VAR_5 = -EINVAL;
fail:
g_free(s->catalog_bitmap);
return VAR_5;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVParallelsState *s = VAR_0->opaque;",
"int VAR_4;",
"ParallelsHeader ph;",
"int VAR_5;",
"VAR_5 = bdrv_pread(VAR_0->file, 0, &ph, sizeof(ph));",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"VAR_0->total_sectors = le64_to_cpu(ph.nb_sectors);",
"if (le32_to_cpu(ph.version) != HEADER_VERSION) {",
"goto fail_format;",
"}",
"if (!memcmp(ph.magic, HEADER_MAGIC, 16)) {",
"s->off_multiplier = 1;",
"VAR_0->total_sectors = 0xffffffff & VAR_0->total_sectors;",
"} else if (!memcmp(ph.magic, HEADER_MAGIC2, 16)) {",
"s->off_multiplier = le32_to_cpu(ph.tracks);",
"} else {",
"goto fail_format;",
"}",
"s->tracks = le32_to_cpu(ph.tracks);",
"if (s->tracks == 0) {",
"error_setg(VAR_3, \"Invalid image: Zero sectors per track\");",
"VAR_5 = -EINVAL;",
"goto fail;",
"}",
"if (s->tracks > INT32_MAX/513) {",
"error_setg(VAR_3, \"Invalid image: Too big cluster\");",
"VAR_5 = -EFBIG;",
"goto fail;",
"}",
"s->catalog_size = le32_to_cpu(ph.catalog_entries);",
"if (s->catalog_size > INT_MAX / sizeof(uint32_t)) {",
"error_setg(VAR_3, \"Catalog too large\");",
"VAR_5 = -EFBIG;",
"goto fail;",
"}",
"s->catalog_bitmap = g_try_new(uint32_t, s->catalog_size);",
"if (s->catalog_size && s->catalog_bitmap == NULL) {",
"VAR_5 = -ENOMEM;",
"goto fail;",
"}",
"VAR_5 = bdrv_pread(VAR_0->file, sizeof(ParallelsHeader),\ns->catalog_bitmap, s->catalog_size * sizeof(uint32_t));",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"for (VAR_4 = 0; VAR_4 < s->catalog_size; VAR_4++)",
"le32_to_cpus(&s->catalog_bitmap[VAR_4]);",
"s->has_truncate = bdrv_has_zero_init(VAR_0->file) &&\nbdrv_truncate(VAR_0->file, bdrv_getlength(VAR_0->file)) == 0;",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"fail_format:\nerror_setg(VAR_3, \"Image not in Parallels format\");",
"VAR_5 = -EINVAL;",
"fail:\ng_free(s->catalog_bitmap);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121,
123
],
[
127
],
[
129
],
[
133,
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
]
] |
2,738 | void imx_timerp_create(const target_phys_addr_t addr,
qemu_irq irq,
DeviceState *ccm)
{
IMXTimerPState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerp", addr, irq);
pp = container_of(dev, IMXTimerPState, busdev.qdev);
pp->ccm = ccm;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | void imx_timerp_create(const target_phys_addr_t addr,
qemu_irq irq,
DeviceState *ccm)
{
IMXTimerPState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerp", addr, irq);
pp = container_of(dev, IMXTimerPState, busdev.qdev);
pp->ccm = ccm;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const target_phys_addr_t VAR_0,
qemu_irq VAR_1,
DeviceState *VAR_2)
{
IMXTimerPState *pp;
DeviceState *dev;
dev = sysbus_create_simple("imx_timerp", VAR_0, VAR_1);
pp = container_of(dev, IMXTimerPState, busdev.qdev);
pp->VAR_2 = VAR_2;
}
| [
"void FUNC_0(const target_phys_addr_t VAR_0,\nqemu_irq VAR_1,\nDeviceState *VAR_2)\n{",
"IMXTimerPState *pp;",
"DeviceState *dev;",
"dev = sysbus_create_simple(\"imx_timerp\", VAR_0, VAR_1);",
"pp = container_of(dev, IMXTimerPState, busdev.qdev);",
"pp->VAR_2 = VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
2,739 | if_start(Slirp *slirp)
{
uint64_t now = qemu_get_clock_ns(rt_clock);
int requeued = 0;
bool from_batchq = false;
struct mbuf *ifm, *ifqt;
DEBUG_CALL("if_start");
if (slirp->if_queued == 0)
return; /* Nothing to do */
again:
/* check if we can really output */
if (!slirp_can_output(slirp->opaque))
return;
/*
* See which queue to get next packet from
* If there's something in the fastq, select it immediately
*/
if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
ifm = slirp->if_fastq.ifq_next;
} else {
/* Nothing on fastq, see if next_m is valid */
if (slirp->next_m != &slirp->if_batchq)
ifm = slirp->next_m;
else
ifm = slirp->if_batchq.ifq_next;
from_batchq = true;
}
slirp->if_queued--;
/* Try to send packet unless it already expired */
if (ifm->expiration_date >= now && !if_encap(slirp, ifm)) {
/* Packet is delayed due to pending ARP resolution */
requeued++;
goto out;
}
if (from_batchq) {
/* Set which packet to send on next iteration */
slirp->next_m = ifm->ifq_next;
}
/* Remove it from the queue */
ifqt = ifm->ifq_prev;
remque(ifm);
/* If there are more packets for this session, re-queue them */
if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) {
insque(ifm->ifs_next, ifqt);
ifs_remque(ifm);
}
/* Update so_queued */
if (ifm->ifq_so) {
if (--ifm->ifq_so->so_queued == 0)
/* If there's no more queued, reset nqueued */
ifm->ifq_so->so_nqueued = 0;
}
m_free(ifm);
out:
if (slirp->if_queued)
goto again;
slirp->if_queued = requeued;
}
| false | qemu | b87ffa163185e339f9f9f1e6dbc561e0f990442d | if_start(Slirp *slirp)
{
uint64_t now = qemu_get_clock_ns(rt_clock);
int requeued = 0;
bool from_batchq = false;
struct mbuf *ifm, *ifqt;
DEBUG_CALL("if_start");
if (slirp->if_queued == 0)
return;
again:
if (!slirp_can_output(slirp->opaque))
return;
if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
ifm = slirp->if_fastq.ifq_next;
} else {
if (slirp->next_m != &slirp->if_batchq)
ifm = slirp->next_m;
else
ifm = slirp->if_batchq.ifq_next;
from_batchq = true;
}
slirp->if_queued--;
if (ifm->expiration_date >= now && !if_encap(slirp, ifm)) {
requeued++;
goto out;
}
if (from_batchq) {
slirp->next_m = ifm->ifq_next;
}
ifqt = ifm->ifq_prev;
remque(ifm);
if (ifm->ifs_next != ifm) {
insque(ifm->ifs_next, ifqt);
ifs_remque(ifm);
}
if (ifm->ifq_so) {
if (--ifm->ifq_so->so_queued == 0)
ifm->ifq_so->so_nqueued = 0;
}
m_free(ifm);
out:
if (slirp->if_queued)
goto again;
slirp->if_queued = requeued;
}
| {
"code": [],
"line_no": []
} | FUNC_0(Slirp *VAR_0)
{
uint64_t now = qemu_get_clock_ns(rt_clock);
int VAR_1 = 0;
bool from_batchq = false;
struct mbuf *VAR_2, *VAR_3;
DEBUG_CALL("FUNC_0");
if (VAR_0->if_queued == 0)
return;
again:
if (!slirp_can_output(VAR_0->opaque))
return;
if (VAR_0->if_fastq.ifq_next != &VAR_0->if_fastq) {
VAR_2 = VAR_0->if_fastq.ifq_next;
} else {
if (VAR_0->next_m != &VAR_0->if_batchq)
VAR_2 = VAR_0->next_m;
else
VAR_2 = VAR_0->if_batchq.ifq_next;
from_batchq = true;
}
VAR_0->if_queued--;
if (VAR_2->expiration_date >= now && !if_encap(VAR_0, VAR_2)) {
VAR_1++;
goto out;
}
if (from_batchq) {
VAR_0->next_m = VAR_2->ifq_next;
}
VAR_3 = VAR_2->ifq_prev;
remque(VAR_2);
if (VAR_2->ifs_next != VAR_2) {
insque(VAR_2->ifs_next, VAR_3);
ifs_remque(VAR_2);
}
if (VAR_2->ifq_so) {
if (--VAR_2->ifq_so->so_queued == 0)
VAR_2->ifq_so->so_nqueued = 0;
}
m_free(VAR_2);
out:
if (VAR_0->if_queued)
goto again;
VAR_0->if_queued = VAR_1;
}
| [
"FUNC_0(Slirp *VAR_0)\n{",
"uint64_t now = qemu_get_clock_ns(rt_clock);",
"int VAR_1 = 0;",
"bool from_batchq = false;",
"struct mbuf *VAR_2, *VAR_3;",
"DEBUG_CALL(\"FUNC_0\");",
"if (VAR_0->if_queued == 0)\nreturn;",
"again:\nif (!slirp_can_output(VAR_0->opaque))\nreturn;",
"if (VAR_0->if_fastq.ifq_next != &VAR_0->if_fastq) {",
"VAR_2 = VAR_0->if_fastq.ifq_next;",
"} else {",
"if (VAR_0->next_m != &VAR_0->if_batchq)\nVAR_2 = VAR_0->next_m;",
"else\nVAR_2 = VAR_0->if_batchq.ifq_next;",
"from_batchq = true;",
"}",
"VAR_0->if_queued--;",
"if (VAR_2->expiration_date >= now && !if_encap(VAR_0, VAR_2)) {",
"VAR_1++;",
"goto out;",
"}",
"if (from_batchq) {",
"VAR_0->next_m = VAR_2->ifq_next;",
"}",
"VAR_3 = VAR_2->ifq_prev;",
"remque(VAR_2);",
"if (VAR_2->ifs_next != VAR_2) {",
"insque(VAR_2->ifs_next, VAR_3);",
"ifs_remque(VAR_2);",
"}",
"if (VAR_2->ifq_so) {",
"if (--VAR_2->ifq_so->so_queued == 0)\nVAR_2->ifq_so->so_nqueued = 0;",
"}",
"m_free(VAR_2);",
"out:\nif (VAR_0->if_queued)\ngoto again;",
"VAR_0->if_queued = 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25,
29,
31
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
61
],
[
63
],
[
67
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119,
123
],
[
125
],
[
129
],
[
133,
135,
137
],
[
141
],
[
143
]
] |
2,740 | e1000_cleanup(NetClientState *nc)
{
E1000State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| false | qemu | 57407ea44cc0a3d630b9b89a2be011f1955ce5c1 | e1000_cleanup(NetClientState *nc)
{
E1000State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
| {
"code": [],
"line_no": []
} | FUNC_0(NetClientState *VAR_0)
{
E1000State *s = qemu_get_nic_opaque(VAR_0);
s->nic = NULL;
}
| [
"FUNC_0(NetClientState *VAR_0)\n{",
"E1000State *s = qemu_get_nic_opaque(VAR_0);",
"s->nic = NULL;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
2,741 | void ff_vp3_h_loop_filter_mmx(uint8_t *src, int stride, int *bounding_values)
{
x86_reg tmp;
__asm__ volatile(
"movd -2(%1), %%mm6 \n\t"
"movd -2(%1,%3), %%mm0 \n\t"
"movd -2(%1,%3,2), %%mm1 \n\t"
"movd -2(%1,%4), %%mm4 \n\t"
TRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)
VP3_LOOP_FILTER(%5)
SBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)
STORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)
STORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)
: "=&r"(tmp)
: "r"(src), "r"(src+4*stride), "r"((x86_reg)stride), "r"((x86_reg)3*stride),
"m"(*(uint64_t*)(bounding_values+129))
: "memory"
);
}
| false | FFmpeg | daa1ea049a9445b7bed03963cb789497065dd1eb | void ff_vp3_h_loop_filter_mmx(uint8_t *src, int stride, int *bounding_values)
{
x86_reg tmp;
__asm__ volatile(
"movd -2(%1), %%mm6 \n\t"
"movd -2(%1,%3), %%mm0 \n\t"
"movd -2(%1,%3,2), %%mm1 \n\t"
"movd -2(%1,%4), %%mm4 \n\t"
TRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)
VP3_LOOP_FILTER(%5)
SBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)
STORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)
STORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)
: "=&r"(tmp)
: "r"(src), "r"(src+4*stride), "r"((x86_reg)stride), "r"((x86_reg)3*stride),
"m"(*(uint64_t*)(bounding_values+129))
: "memory"
);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, int VAR_1, int *VAR_2)
{
x86_reg tmp;
__asm__ volatile(
"movd -2(%1), %%mm6 \n\t"
"movd -2(%1,%3), %%mm0 \n\t"
"movd -2(%1,%3,2), %%mm1 \n\t"
"movd -2(%1,%4), %%mm4 \n\t"
TRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)
VP3_LOOP_FILTER(%5)
SBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)
STORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)
STORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)
: "=&r"(tmp)
: "r"(VAR_0), "r"(VAR_0+4*VAR_1), "r"((x86_reg)VAR_1), "r"((x86_reg)3*VAR_1),
"m"(*(uint64_t*)(VAR_2+129))
: "memory"
);
}
| [
"void FUNC_0(uint8_t *VAR_0, int VAR_1, int *VAR_2)\n{",
"x86_reg tmp;",
"__asm__ volatile(\n\"movd -2(%1), %%mm6 \\n\\t\"\n\"movd -2(%1,%3), %%mm0 \\n\\t\"\n\"movd -2(%1,%3,2), %%mm1 \\n\\t\"\n\"movd -2(%1,%4), %%mm4 \\n\\t\"\nTRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)\nVP3_LOOP_FILTER(%5)\nSBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)\nSTORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)\nSTORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)\n: \"=&r\"(tmp)\n: \"r\"(VAR_0), \"r\"(VAR_0+4*VAR_1), \"r\"((x86_reg)VAR_1), \"r\"((x86_reg)3*VAR_1),\n\"m\"(*(uint64_t*)(VAR_2+129))\n: \"memory\"\n);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13,
15,
17,
21,
23,
25,
29,
31,
35,
37,
39,
41,
43
],
[
45
]
] |
2,742 | static void sdram_set_bcr (uint32_t *bcrp, uint32_t bcr, int enabled)
{
if (*bcrp & 0x00000001) {
/* Unmap RAM */
#ifdef DEBUG_SDRAM
printf("%s: unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(*bcrp), sdram_size(*bcrp));
#endif
cpu_register_physical_memory(sdram_base(*bcrp), sdram_size(*bcrp),
IO_MEM_UNASSIGNED);
}
*bcrp = bcr & 0xFFDEE001;
if (enabled && (bcr & 0x00000001)) {
#ifdef DEBUG_SDRAM
printf("%s: Map RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(bcr), sdram_size(bcr));
#endif
cpu_register_physical_memory(sdram_base(bcr), sdram_size(bcr),
sdram_base(bcr) | IO_MEM_RAM);
}
}
| false | qemu | b6dcbe086c77ec683f5ff0b693593cda1d61f3a1 | static void sdram_set_bcr (uint32_t *bcrp, uint32_t bcr, int enabled)
{
if (*bcrp & 0x00000001) {
#ifdef DEBUG_SDRAM
printf("%s: unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(*bcrp), sdram_size(*bcrp));
#endif
cpu_register_physical_memory(sdram_base(*bcrp), sdram_size(*bcrp),
IO_MEM_UNASSIGNED);
}
*bcrp = bcr & 0xFFDEE001;
if (enabled && (bcr & 0x00000001)) {
#ifdef DEBUG_SDRAM
printf("%s: Map RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(bcr), sdram_size(bcr));
#endif
cpu_register_physical_memory(sdram_base(bcr), sdram_size(bcr),
sdram_base(bcr) | IO_MEM_RAM);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (uint32_t *VAR_0, uint32_t VAR_1, int VAR_2)
{
if (*VAR_0 & 0x00000001) {
#ifdef DEBUG_SDRAM
printf("%s: unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(*VAR_0), sdram_size(*VAR_0));
#endif
cpu_register_physical_memory(sdram_base(*VAR_0), sdram_size(*VAR_0),
IO_MEM_UNASSIGNED);
}
*VAR_0 = VAR_1 & 0xFFDEE001;
if (VAR_2 && (VAR_1 & 0x00000001)) {
#ifdef DEBUG_SDRAM
printf("%s: Map RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
__func__, sdram_base(VAR_1), sdram_size(VAR_1));
#endif
cpu_register_physical_memory(sdram_base(VAR_1), sdram_size(VAR_1),
sdram_base(VAR_1) | IO_MEM_RAM);
}
}
| [
"static void FUNC_0 (uint32_t *VAR_0, uint32_t VAR_1, int VAR_2)\n{",
"if (*VAR_0 & 0x00000001) {",
"#ifdef DEBUG_SDRAM\nprintf(\"%s: unmap RAM area \" TARGET_FMT_plx \" \" TARGET_FMT_lx \"\\n\",\n__func__, sdram_base(*VAR_0), sdram_size(*VAR_0));",
"#endif\ncpu_register_physical_memory(sdram_base(*VAR_0), sdram_size(*VAR_0),\nIO_MEM_UNASSIGNED);",
"}",
"*VAR_0 = VAR_1 & 0xFFDEE001;",
"if (VAR_2 && (VAR_1 & 0x00000001)) {",
"#ifdef DEBUG_SDRAM\nprintf(\"%s: Map RAM area \" TARGET_FMT_plx \" \" TARGET_FMT_lx \"\\n\",\n__func__, sdram_base(VAR_1), sdram_size(VAR_1));",
"#endif\ncpu_register_physical_memory(sdram_base(VAR_1), sdram_size(VAR_1),\nsdram_base(VAR_1) | IO_MEM_RAM);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29,
31
],
[
33,
35,
37
],
[
39
],
[
41
]
] |
2,743 | static Suite *qfloat_suite(void)
{
Suite *s;
TCase *qfloat_public_tcase;
s = suite_create("QFloat test-suite");
qfloat_public_tcase = tcase_create("Public Interface");
suite_add_tcase(s, qfloat_public_tcase);
tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
return s;
}
| false | qemu | a9e1c28ddaae5a48415fec1f336b5560eb85d3e1 | static Suite *qfloat_suite(void)
{
Suite *s;
TCase *qfloat_public_tcase;
s = suite_create("QFloat test-suite");
qfloat_public_tcase = tcase_create("Public Interface");
suite_add_tcase(s, qfloat_public_tcase);
tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
return s;
}
| {
"code": [],
"line_no": []
} | static Suite *FUNC_0(void)
{
Suite *s;
TCase *qfloat_public_tcase;
s = suite_create("QFloat test-suite");
qfloat_public_tcase = tcase_create("Public Interface");
suite_add_tcase(s, qfloat_public_tcase);
tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);
tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);
return s;
}
| [
"static Suite *FUNC_0(void)\n{",
"Suite *s;",
"TCase *qfloat_public_tcase;",
"s = suite_create(\"QFloat test-suite\");",
"qfloat_public_tcase = tcase_create(\"Public Interface\");",
"suite_add_tcase(s, qfloat_public_tcase);",
"tcase_add_test(qfloat_public_tcase, qfloat_from_double_test);",
"tcase_add_test(qfloat_public_tcase, qfloat_destroy_test);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
2,744 | void qemu_unregister_clock_reset_notifier(QEMUClock *clock,
Notifier *notifier)
{
qemu_clock_unregister_reset_notifier(clock->type, notifier);
}
| false | qemu | b4049b74b97f30fe944c63b5f158ec9e87bd2593 | void qemu_unregister_clock_reset_notifier(QEMUClock *clock,
Notifier *notifier)
{
qemu_clock_unregister_reset_notifier(clock->type, notifier);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUClock *VAR_0,
Notifier *VAR_1)
{
qemu_clock_unregister_reset_notifier(VAR_0->type, VAR_1);
}
| [
"void FUNC_0(QEMUClock *VAR_0,\nNotifier *VAR_1)\n{",
"qemu_clock_unregister_reset_notifier(VAR_0->type, VAR_1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
2,745 | target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
{
uint8_t *pde_ptr, *pte_ptr;
uint32_t pde, pte, paddr, page_offset, page_size;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
page_size = 4096;
} else {
/* page directory entry */
pde_ptr = phys_ram_base +
(((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask);
pde = ldl_raw(pde_ptr);
if (!(pde & PG_PRESENT_MASK))
return -1;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
pte = pde & ~0x003ff000; /* align to 4MB */
page_size = 4096 * 1024;
} else {
/* page directory entry */
pte_ptr = phys_ram_base +
(((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask);
pte = ldl_raw(pte_ptr);
if (!(pte & PG_PRESENT_MASK))
return -1;
page_size = 4096;
}
}
pte = pte & a20_mask;
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
return paddr;
}
| false | qemu | 1ac157da77c863b62b1d2f467626a440d57cf17d | target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
{
uint8_t *pde_ptr, *pte_ptr;
uint32_t pde, pte, paddr, page_offset, page_size;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
page_size = 4096;
} else {
pde_ptr = phys_ram_base +
(((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask);
pde = ldl_raw(pde_ptr);
if (!(pde & PG_PRESENT_MASK))
return -1;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
pte = pde & ~0x003ff000;
page_size = 4096 * 1024;
} else {
pte_ptr = phys_ram_base +
(((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask);
pte = ldl_raw(pte_ptr);
if (!(pte & PG_PRESENT_MASK))
return -1;
page_size = 4096;
}
}
pte = pte & a20_mask;
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
return paddr;
}
| {
"code": [],
"line_no": []
} | target_ulong FUNC_0(CPUState *env, target_ulong addr)
{
uint8_t *pde_ptr, *pte_ptr;
uint32_t pde, pte, paddr, page_offset, page_size;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
page_size = 4096;
} else {
pde_ptr = phys_ram_base +
(((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask);
pde = ldl_raw(pde_ptr);
if (!(pde & PG_PRESENT_MASK))
return -1;
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
pte = pde & ~0x003ff000;
page_size = 4096 * 1024;
} else {
pte_ptr = phys_ram_base +
(((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask);
pte = ldl_raw(pte_ptr);
if (!(pte & PG_PRESENT_MASK))
return -1;
page_size = 4096;
}
}
pte = pte & a20_mask;
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
return paddr;
}
| [
"target_ulong FUNC_0(CPUState *env, target_ulong addr)\n{",
"uint8_t *pde_ptr, *pte_ptr;",
"uint32_t pde, pte, paddr, page_offset, page_size;",
"if (!(env->cr[0] & CR0_PG_MASK)) {",
"pte = addr;",
"page_size = 4096;",
"} else {",
"pde_ptr = phys_ram_base +\n(((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) & a20_mask);",
"pde = ldl_raw(pde_ptr);",
"if (!(pde & PG_PRESENT_MASK))\nreturn -1;",
"if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {",
"pte = pde & ~0x003ff000;",
"page_size = 4096 * 1024;",
"} else {",
"pte_ptr = phys_ram_base +\n(((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & a20_mask);",
"pte = ldl_raw(pte_ptr);",
"if (!(pte & PG_PRESENT_MASK))\nreturn -1;",
"page_size = 4096;",
"}",
"}",
"pte = pte & a20_mask;",
"page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);",
"paddr = (pte & TARGET_PAGE_MASK) + page_offset;",
"return paddr;",
"}"
] | [
0,
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
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
2,746 | static uint64_t imx_serial_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
uint32_t c;
DPRINTF("read(offset=%x)\n", offset >> 2);
switch (offset >> 2) {
case 0x0: /* URXD */
c = s->readbuff;
if (!(s->uts1 & UTS1_RXEMPTY)) {
/* Character is valid */
c |= URXD_CHARRDY;
s->usr1 &= ~USR1_RRDY;
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
qemu_chr_accept_input(s->chr);
}
return c;
case 0x20: /* UCR1 */
return s->ucr1;
case 0x21: /* UCR2 */
return s->ucr2;
case 0x25: /* USR1 */
return s->usr1;
case 0x26: /* USR2 */
return s->usr2;
case 0x2A: /* BRM Modulator */
return s->ubmr;
case 0x2B: /* Baud Rate Count */
return s->ubrc;
case 0x2d: /* Test register */
return s->uts1;
case 0x24: /* UFCR */
return s->ufcr;
case 0x2c:
return s->onems;
case 0x22: /* UCR3 */
return s->ucr3;
case 0x23: /* UCR4 */
case 0x29: /* BRM Incremental */
return 0x0; /* TODO */
default:
IPRINTF("imx_serial_read: bad offset: 0x%x\n", (int)offset);
return 0;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t imx_serial_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
uint32_t c;
DPRINTF("read(offset=%x)\n", offset >> 2);
switch (offset >> 2) {
case 0x0:
c = s->readbuff;
if (!(s->uts1 & UTS1_RXEMPTY)) {
c |= URXD_CHARRDY;
s->usr1 &= ~USR1_RRDY;
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
qemu_chr_accept_input(s->chr);
}
return c;
case 0x20:
return s->ucr1;
case 0x21:
return s->ucr2;
case 0x25:
return s->usr1;
case 0x26:
return s->usr2;
case 0x2A:
return s->ubmr;
case 0x2B:
return s->ubrc;
case 0x2d:
return s->uts1;
case 0x24:
return s->ufcr;
case 0x2c:
return s->onems;
case 0x22:
return s->ucr3;
case 0x23:
case 0x29:
return 0x0;
default:
IPRINTF("imx_serial_read: bad offset: 0x%x\n", (int)offset);
return 0;
}
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
IMXSerialState *s = (IMXSerialState *)opaque;
uint32_t c;
DPRINTF("read(offset=%x)\n", offset >> 2);
switch (offset >> 2) {
case 0x0:
c = s->readbuff;
if (!(s->uts1 & UTS1_RXEMPTY)) {
c |= URXD_CHARRDY;
s->usr1 &= ~USR1_RRDY;
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
qemu_chr_accept_input(s->chr);
}
return c;
case 0x20:
return s->ucr1;
case 0x21:
return s->ucr2;
case 0x25:
return s->usr1;
case 0x26:
return s->usr2;
case 0x2A:
return s->ubmr;
case 0x2B:
return s->ubrc;
case 0x2d:
return s->uts1;
case 0x24:
return s->ufcr;
case 0x2c:
return s->onems;
case 0x22:
return s->ucr3;
case 0x23:
case 0x29:
return 0x0;
default:
IPRINTF("FUNC_0: bad offset: 0x%x\n", (int)offset);
return 0;
}
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"IMXSerialState *s = (IMXSerialState *)opaque;",
"uint32_t c;",
"DPRINTF(\"read(offset=%x)\\n\", offset >> 2);",
"switch (offset >> 2) {",
"case 0x0:\nc = s->readbuff;",
"if (!(s->uts1 & UTS1_RXEMPTY)) {",
"c |= URXD_CHARRDY;",
"s->usr1 &= ~USR1_RRDY;",
"s->usr2 &= ~USR2_RDR;",
"s->uts1 |= UTS1_RXEMPTY;",
"imx_update(s);",
"qemu_chr_accept_input(s->chr);",
"}",
"return c;",
"case 0x20:\nreturn s->ucr1;",
"case 0x21:\nreturn s->ucr2;",
"case 0x25:\nreturn s->usr1;",
"case 0x26:\nreturn s->usr2;",
"case 0x2A:\nreturn s->ubmr;",
"case 0x2B:\nreturn s->ubrc;",
"case 0x2d:\nreturn s->uts1;",
"case 0x24:\nreturn s->ufcr;",
"case 0x2c:\nreturn s->onems;",
"case 0x22:\nreturn s->ucr3;",
"case 0x23:\ncase 0x29:\nreturn 0x0;",
"default:\nIPRINTF(\"FUNC_0: bad offset: 0x%x\\n\", (int)offset);",
"return 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
49,
51
],
[
55,
57
],
[
61,
63
],
[
67,
69
],
[
73,
75
],
[
79,
81
],
[
85,
87
],
[
91,
93
],
[
97,
99
],
[
103,
105,
107
],
[
111,
113
],
[
115
],
[
117
],
[
119
]
] |
2,747 | void qemu_del_net_client(NetClientState *nc)
{
NetClientState *ncs[MAX_QUEUE_NUM];
int queues, i;
/* If the NetClientState belongs to a multiqueue backend, we will change all
* other NetClientStates also.
*/
queues = qemu_find_net_clients_except(nc->name, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
MAX_QUEUE_NUM);
assert(queues != 0);
/* If there is a peer NIC, delete and cleanup client, but do not free. */
if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = qemu_get_nic(nc->peer);
if (nic->peer_deleted) {
return;
}
nic->peer_deleted = true;
for (i = 0; i < queues; i++) {
ncs[i]->peer->link_down = true;
}
if (nc->peer->info->link_status_changed) {
nc->peer->info->link_status_changed(nc->peer);
}
for (i = 0; i < queues; i++) {
qemu_cleanup_net_client(ncs[i]);
}
return;
}
assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
for (i = 0; i < queues; i++) {
qemu_cleanup_net_client(ncs[i]);
qemu_free_net_client(ncs[i]);
}
}
| false | qemu | 7fb439115de7354b3ac2becf24457acaf828296b | void qemu_del_net_client(NetClientState *nc)
{
NetClientState *ncs[MAX_QUEUE_NUM];
int queues, i;
queues = qemu_find_net_clients_except(nc->name, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
MAX_QUEUE_NUM);
assert(queues != 0);
if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = qemu_get_nic(nc->peer);
if (nic->peer_deleted) {
return;
}
nic->peer_deleted = true;
for (i = 0; i < queues; i++) {
ncs[i]->peer->link_down = true;
}
if (nc->peer->info->link_status_changed) {
nc->peer->info->link_status_changed(nc->peer);
}
for (i = 0; i < queues; i++) {
qemu_cleanup_net_client(ncs[i]);
}
return;
}
assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
for (i = 0; i < queues; i++) {
qemu_cleanup_net_client(ncs[i]);
qemu_free_net_client(ncs[i]);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(NetClientState *VAR_0)
{
NetClientState *ncs[MAX_QUEUE_NUM];
int VAR_1, VAR_2;
VAR_1 = qemu_find_net_clients_except(VAR_0->name, ncs,
NET_CLIENT_OPTIONS_KIND_NIC,
MAX_QUEUE_NUM);
assert(VAR_1 != 0);
if (VAR_0->peer && VAR_0->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = qemu_get_nic(VAR_0->peer);
if (nic->peer_deleted) {
return;
}
nic->peer_deleted = true;
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
ncs[VAR_2]->peer->link_down = true;
}
if (VAR_0->peer->info->link_status_changed) {
VAR_0->peer->info->link_status_changed(VAR_0->peer);
}
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
qemu_cleanup_net_client(ncs[VAR_2]);
}
return;
}
assert(VAR_0->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {
qemu_cleanup_net_client(ncs[VAR_2]);
qemu_free_net_client(ncs[VAR_2]);
}
}
| [
"void FUNC_0(NetClientState *VAR_0)\n{",
"NetClientState *ncs[MAX_QUEUE_NUM];",
"int VAR_1, VAR_2;",
"VAR_1 = qemu_find_net_clients_except(VAR_0->name, ncs,\nNET_CLIENT_OPTIONS_KIND_NIC,\nMAX_QUEUE_NUM);",
"assert(VAR_1 != 0);",
"if (VAR_0->peer && VAR_0->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {",
"NICState *nic = qemu_get_nic(VAR_0->peer);",
"if (nic->peer_deleted) {",
"return;",
"}",
"nic->peer_deleted = true;",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"ncs[VAR_2]->peer->link_down = true;",
"}",
"if (VAR_0->peer->info->link_status_changed) {",
"VAR_0->peer->info->link_status_changed(VAR_0->peer);",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"qemu_cleanup_net_client(ncs[VAR_2]);",
"}",
"return;",
"}",
"assert(VAR_0->info->type != NET_CLIENT_OPTIONS_KIND_NIC);",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {",
"qemu_cleanup_net_client(ncs[VAR_2]);",
"qemu_free_net_client(ncs[VAR_2]);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
17,
19,
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
2,748 | static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
{
if (timer->pt)
/* TODO in overflow-and-match mode if the first event to
* occurs is the match, don't toggle. */
omap_gp_timer_out(timer, !timer->out_val);
else
/* TODO inverted pulse on timer->out_val == 1? */
qemu_irq_pulse(timer->out);
}
| false | qemu | 75554a3ca10a7ad295d2a3d2e14ee6ba90f94c8b | static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
{
if (timer->pt)
omap_gp_timer_out(timer, !timer->out_val);
else
qemu_irq_pulse(timer->out);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(struct omap_gp_timer_s *VAR_0)
{
if (VAR_0->pt)
omap_gp_timer_out(VAR_0, !VAR_0->out_val);
else
qemu_irq_pulse(VAR_0->out);
}
| [
"static inline void FUNC_0(struct omap_gp_timer_s *VAR_0)\n{",
"if (VAR_0->pt)\nomap_gp_timer_out(VAR_0, !VAR_0->out_val);",
"else\nqemu_irq_pulse(VAR_0->out);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
11
],
[
13,
17
],
[
19
]
] |
2,749 | timer_write(void *opaque, target_phys_addr_t addr,
uint64_t val64, unsigned int size)
{
struct etrax_timer *t = opaque;
uint32_t value = val64;
switch (addr)
{
case RW_TMR0_DIV:
t->rw_tmr0_div = value;
break;
case RW_TMR0_CTRL:
D(printf ("RW_TMR0_CTRL=%x\n", value));
t->rw_tmr0_ctrl = value;
update_ctrl(t, 0);
break;
case RW_TMR1_DIV:
t->rw_tmr1_div = value;
break;
case RW_TMR1_CTRL:
D(printf ("RW_TMR1_CTRL=%x\n", value));
t->rw_tmr1_ctrl = value;
update_ctrl(t, 1);
break;
case RW_INTR_MASK:
D(printf ("RW_INTR_MASK=%x\n", value));
t->rw_intr_mask = value;
timer_update_irq(t);
break;
case RW_WD_CTRL:
timer_watchdog_update(t, value);
break;
case RW_ACK_INTR:
t->rw_ack_intr = value;
timer_update_irq(t);
t->rw_ack_intr = 0;
break;
default:
printf ("%s " TARGET_FMT_plx " %x\n",
__func__, addr, value);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | timer_write(void *opaque, target_phys_addr_t addr,
uint64_t val64, unsigned int size)
{
struct etrax_timer *t = opaque;
uint32_t value = val64;
switch (addr)
{
case RW_TMR0_DIV:
t->rw_tmr0_div = value;
break;
case RW_TMR0_CTRL:
D(printf ("RW_TMR0_CTRL=%x\n", value));
t->rw_tmr0_ctrl = value;
update_ctrl(t, 0);
break;
case RW_TMR1_DIV:
t->rw_tmr1_div = value;
break;
case RW_TMR1_CTRL:
D(printf ("RW_TMR1_CTRL=%x\n", value));
t->rw_tmr1_ctrl = value;
update_ctrl(t, 1);
break;
case RW_INTR_MASK:
D(printf ("RW_INTR_MASK=%x\n", value));
t->rw_intr_mask = value;
timer_update_irq(t);
break;
case RW_WD_CTRL:
timer_watchdog_update(t, value);
break;
case RW_ACK_INTR:
t->rw_ack_intr = value;
timer_update_irq(t);
t->rw_ack_intr = 0;
break;
default:
printf ("%s " TARGET_FMT_plx " %x\n",
__func__, addr, value);
break;
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned int VAR_3)
{
struct etrax_timer *VAR_4 = VAR_0;
uint32_t value = VAR_2;
switch (VAR_1)
{
case RW_TMR0_DIV:
VAR_4->rw_tmr0_div = value;
break;
case RW_TMR0_CTRL:
D(printf ("RW_TMR0_CTRL=%x\n", value));
VAR_4->rw_tmr0_ctrl = value;
update_ctrl(VAR_4, 0);
break;
case RW_TMR1_DIV:
VAR_4->rw_tmr1_div = value;
break;
case RW_TMR1_CTRL:
D(printf ("RW_TMR1_CTRL=%x\n", value));
VAR_4->rw_tmr1_ctrl = value;
update_ctrl(VAR_4, 1);
break;
case RW_INTR_MASK:
D(printf ("RW_INTR_MASK=%x\n", value));
VAR_4->rw_intr_mask = value;
timer_update_irq(VAR_4);
break;
case RW_WD_CTRL:
timer_watchdog_update(VAR_4, value);
break;
case RW_ACK_INTR:
VAR_4->rw_ack_intr = value;
timer_update_irq(VAR_4);
VAR_4->rw_ack_intr = 0;
break;
default:
printf ("%s " TARGET_FMT_plx " %x\n",
__func__, VAR_1, value);
break;
}
}
| [
"FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{",
"struct etrax_timer *VAR_4 = VAR_0;",
"uint32_t value = VAR_2;",
"switch (VAR_1)\n{",
"case RW_TMR0_DIV:\nVAR_4->rw_tmr0_div = value;",
"break;",
"case RW_TMR0_CTRL:\nD(printf (\"RW_TMR0_CTRL=%x\\n\", value));",
"VAR_4->rw_tmr0_ctrl = value;",
"update_ctrl(VAR_4, 0);",
"break;",
"case RW_TMR1_DIV:\nVAR_4->rw_tmr1_div = value;",
"break;",
"case RW_TMR1_CTRL:\nD(printf (\"RW_TMR1_CTRL=%x\\n\", value));",
"VAR_4->rw_tmr1_ctrl = value;",
"update_ctrl(VAR_4, 1);",
"break;",
"case RW_INTR_MASK:\nD(printf (\"RW_INTR_MASK=%x\\n\", value));",
"VAR_4->rw_intr_mask = value;",
"timer_update_irq(VAR_4);",
"break;",
"case RW_WD_CTRL:\ntimer_watchdog_update(VAR_4, value);",
"break;",
"case RW_ACK_INTR:\nVAR_4->rw_ack_intr = value;",
"timer_update_irq(VAR_4);",
"VAR_4->rw_ack_intr = 0;",
"break;",
"default:\nprintf (\"%s \" TARGET_FMT_plx \" %x\\n\",\n__func__, VAR_1, value);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75,
77,
79
],
[
81
],
[
83
],
[
85
]
] |
2,750 | void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
{
mpeg1_encode_sequence_header(s);
/* mpeg1 picture header */
put_header(s, PICTURE_START_CODE);
/* temporal reference */
// RAL: s->picture_number instead of s->fake_picture_number
put_bits(&s->pb, 10, (s->picture_number -
s->gop_picture_number) & 0x3ff);
s->fake_picture_number++;
put_bits(&s->pb, 3, s->pict_type);
s->vbv_delay_ptr= s->pb.buf + get_bit_count(&s->pb)/8;
put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
// RAL: Forward f_code also needed for B frames
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0); /* half pel coordinates */
if(s->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
else
put_bits(&s->pb, 3, 7); /* forward_f_code */
}
// RAL: Backward f_code necessary for B frames
if (s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0); /* half pel coordinates */
if(s->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
else
put_bits(&s->pb, 3, 7); /* backward_f_code */
}
put_bits(&s->pb, 1, 0); /* extra bit picture */
s->frame_pred_frame_dct = 1;
if(s->codec_id == CODEC_ID_MPEG2VIDEO){
put_header(s, EXT_START_CODE);
put_bits(&s->pb, 4, 8); //pic ext
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 4, s->f_code);
put_bits(&s->pb, 4, s->f_code);
}else{
put_bits(&s->pb, 8, 255);
}
if (s->pict_type == B_TYPE) {
put_bits(&s->pb, 4, s->b_code);
put_bits(&s->pb, 4, s->b_code);
}else{
put_bits(&s->pb, 8, 255);
}
put_bits(&s->pb, 2, s->intra_dc_precision);
put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME);
if (s->progressive_sequence) {
put_bits(&s->pb, 1, 0); /* no repeat */
} else {
put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
}
/* XXX: optimize the generation of this flag with entropy
measures */
s->frame_pred_frame_dct = s->progressive_sequence;
put_bits(&s->pb, 1, s->frame_pred_frame_dct);
put_bits(&s->pb, 1, s->concealment_motion_vectors);
put_bits(&s->pb, 1, s->q_scale_type);
put_bits(&s->pb, 1, s->intra_vlc_format);
put_bits(&s->pb, 1, s->alternate_scan);
put_bits(&s->pb, 1, s->repeat_first_field);
put_bits(&s->pb, 1, s->chroma_420_type=1);
s->progressive_frame = s->progressive_sequence;
put_bits(&s->pb, 1, s->progressive_frame);
put_bits(&s->pb, 1, 0); //composite_display_flag
}
if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){
int i;
put_header(s, USER_START_CODE);
for(i=0; i<sizeof(svcd_scan_offset_placeholder); i++){
put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]);
}
}
s->mb_y=0;
ff_mpeg1_encode_slice_header(s);
}
| false | FFmpeg | 2c492e94fc9d8a5e998b25f4d0390c95f2d4674f | void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
{
mpeg1_encode_sequence_header(s);
put_header(s, PICTURE_START_CODE);
put_bits(&s->pb, 10, (s->picture_number -
s->gop_picture_number) & 0x3ff);
s->fake_picture_number++;
put_bits(&s->pb, 3, s->pict_type);
s->vbv_delay_ptr= s->pb.buf + get_bit_count(&s->pb)/8;
put_bits(&s->pb, 16, 0xFFFF);
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0);
if(s->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&s->pb, 3, s->f_code);
else
put_bits(&s->pb, 3, 7);
}
if (s->pict_type == B_TYPE) {
put_bits(&s->pb, 1, 0);
if(s->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&s->pb, 3, s->b_code);
else
put_bits(&s->pb, 3, 7);
}
put_bits(&s->pb, 1, 0);
s->frame_pred_frame_dct = 1;
if(s->codec_id == CODEC_ID_MPEG2VIDEO){
put_header(s, EXT_START_CODE);
put_bits(&s->pb, 4, 8);
if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
put_bits(&s->pb, 4, s->f_code);
put_bits(&s->pb, 4, s->f_code);
}else{
put_bits(&s->pb, 8, 255);
}
if (s->pict_type == B_TYPE) {
put_bits(&s->pb, 4, s->b_code);
put_bits(&s->pb, 4, s->b_code);
}else{
put_bits(&s->pb, 8, 255);
}
put_bits(&s->pb, 2, s->intra_dc_precision);
put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME);
if (s->progressive_sequence) {
put_bits(&s->pb, 1, 0);
} else {
put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
}
s->frame_pred_frame_dct = s->progressive_sequence;
put_bits(&s->pb, 1, s->frame_pred_frame_dct);
put_bits(&s->pb, 1, s->concealment_motion_vectors);
put_bits(&s->pb, 1, s->q_scale_type);
put_bits(&s->pb, 1, s->intra_vlc_format);
put_bits(&s->pb, 1, s->alternate_scan);
put_bits(&s->pb, 1, s->repeat_first_field);
put_bits(&s->pb, 1, s->chroma_420_type=1);
s->progressive_frame = s->progressive_sequence;
put_bits(&s->pb, 1, s->progressive_frame);
put_bits(&s->pb, 1, 0);
}
if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){
int i;
put_header(s, USER_START_CODE);
for(i=0; i<sizeof(svcd_scan_offset_placeholder); i++){
put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]);
}
}
s->mb_y=0;
ff_mpeg1_encode_slice_header(s);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0, int VAR_1)
{
mpeg1_encode_sequence_header(VAR_0);
put_header(VAR_0, PICTURE_START_CODE);
put_bits(&VAR_0->pb, 10, (VAR_0->VAR_1 -
VAR_0->gop_picture_number) & 0x3ff);
VAR_0->fake_picture_number++;
put_bits(&VAR_0->pb, 3, VAR_0->pict_type);
VAR_0->vbv_delay_ptr= VAR_0->pb.buf + get_bit_count(&VAR_0->pb)/8;
put_bits(&VAR_0->pb, 16, 0xFFFF);
if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type == B_TYPE) {
put_bits(&VAR_0->pb, 1, 0);
if(VAR_0->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&VAR_0->pb, 3, VAR_0->f_code);
else
put_bits(&VAR_0->pb, 3, 7);
}
if (VAR_0->pict_type == B_TYPE) {
put_bits(&VAR_0->pb, 1, 0);
if(VAR_0->codec_id == CODEC_ID_MPEG1VIDEO)
put_bits(&VAR_0->pb, 3, VAR_0->b_code);
else
put_bits(&VAR_0->pb, 3, 7);
}
put_bits(&VAR_0->pb, 1, 0);
VAR_0->frame_pred_frame_dct = 1;
if(VAR_0->codec_id == CODEC_ID_MPEG2VIDEO){
put_header(VAR_0, EXT_START_CODE);
put_bits(&VAR_0->pb, 4, 8);
if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type == B_TYPE) {
put_bits(&VAR_0->pb, 4, VAR_0->f_code);
put_bits(&VAR_0->pb, 4, VAR_0->f_code);
}else{
put_bits(&VAR_0->pb, 8, 255);
}
if (VAR_0->pict_type == B_TYPE) {
put_bits(&VAR_0->pb, 4, VAR_0->b_code);
put_bits(&VAR_0->pb, 4, VAR_0->b_code);
}else{
put_bits(&VAR_0->pb, 8, 255);
}
put_bits(&VAR_0->pb, 2, VAR_0->intra_dc_precision);
put_bits(&VAR_0->pb, 2, VAR_0->picture_structure= PICT_FRAME);
if (VAR_0->progressive_sequence) {
put_bits(&VAR_0->pb, 1, 0);
} else {
put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->top_field_first);
}
VAR_0->frame_pred_frame_dct = VAR_0->progressive_sequence;
put_bits(&VAR_0->pb, 1, VAR_0->frame_pred_frame_dct);
put_bits(&VAR_0->pb, 1, VAR_0->concealment_motion_vectors);
put_bits(&VAR_0->pb, 1, VAR_0->q_scale_type);
put_bits(&VAR_0->pb, 1, VAR_0->intra_vlc_format);
put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan);
put_bits(&VAR_0->pb, 1, VAR_0->repeat_first_field);
put_bits(&VAR_0->pb, 1, VAR_0->chroma_420_type=1);
VAR_0->progressive_frame = VAR_0->progressive_sequence;
put_bits(&VAR_0->pb, 1, VAR_0->progressive_frame);
put_bits(&VAR_0->pb, 1, 0);
}
if(VAR_0->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){
int VAR_2;
put_header(VAR_0, USER_START_CODE);
for(VAR_2=0; VAR_2<sizeof(svcd_scan_offset_placeholder); VAR_2++){
put_bits(&VAR_0->pb, 8, svcd_scan_offset_placeholder[VAR_2]);
}
}
VAR_0->mb_y=0;
ff_mpeg1_encode_slice_header(VAR_0);
}
| [
"void FUNC_0(MpegEncContext *VAR_0, int VAR_1)\n{",
"mpeg1_encode_sequence_header(VAR_0);",
"put_header(VAR_0, PICTURE_START_CODE);",
"put_bits(&VAR_0->pb, 10, (VAR_0->VAR_1 -\nVAR_0->gop_picture_number) & 0x3ff);",
"VAR_0->fake_picture_number++;",
"put_bits(&VAR_0->pb, 3, VAR_0->pict_type);",
"VAR_0->vbv_delay_ptr= VAR_0->pb.buf + get_bit_count(&VAR_0->pb)/8;",
"put_bits(&VAR_0->pb, 16, 0xFFFF);",
"if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type == B_TYPE) {",
"put_bits(&VAR_0->pb, 1, 0);",
"if(VAR_0->codec_id == CODEC_ID_MPEG1VIDEO)\nput_bits(&VAR_0->pb, 3, VAR_0->f_code);",
"else\nput_bits(&VAR_0->pb, 3, 7);",
"}",
"if (VAR_0->pict_type == B_TYPE) {",
"put_bits(&VAR_0->pb, 1, 0);",
"if(VAR_0->codec_id == CODEC_ID_MPEG1VIDEO)\nput_bits(&VAR_0->pb, 3, VAR_0->b_code);",
"else\nput_bits(&VAR_0->pb, 3, 7);",
"}",
"put_bits(&VAR_0->pb, 1, 0);",
"VAR_0->frame_pred_frame_dct = 1;",
"if(VAR_0->codec_id == CODEC_ID_MPEG2VIDEO){",
"put_header(VAR_0, EXT_START_CODE);",
"put_bits(&VAR_0->pb, 4, 8);",
"if (VAR_0->pict_type == P_TYPE || VAR_0->pict_type == B_TYPE) {",
"put_bits(&VAR_0->pb, 4, VAR_0->f_code);",
"put_bits(&VAR_0->pb, 4, VAR_0->f_code);",
"}else{",
"put_bits(&VAR_0->pb, 8, 255);",
"}",
"if (VAR_0->pict_type == B_TYPE) {",
"put_bits(&VAR_0->pb, 4, VAR_0->b_code);",
"put_bits(&VAR_0->pb, 4, VAR_0->b_code);",
"}else{",
"put_bits(&VAR_0->pb, 8, 255);",
"}",
"put_bits(&VAR_0->pb, 2, VAR_0->intra_dc_precision);",
"put_bits(&VAR_0->pb, 2, VAR_0->picture_structure= PICT_FRAME);",
"if (VAR_0->progressive_sequence) {",
"put_bits(&VAR_0->pb, 1, 0);",
"} else {",
"put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->top_field_first);",
"}",
"VAR_0->frame_pred_frame_dct = VAR_0->progressive_sequence;",
"put_bits(&VAR_0->pb, 1, VAR_0->frame_pred_frame_dct);",
"put_bits(&VAR_0->pb, 1, VAR_0->concealment_motion_vectors);",
"put_bits(&VAR_0->pb, 1, VAR_0->q_scale_type);",
"put_bits(&VAR_0->pb, 1, VAR_0->intra_vlc_format);",
"put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan);",
"put_bits(&VAR_0->pb, 1, VAR_0->repeat_first_field);",
"put_bits(&VAR_0->pb, 1, VAR_0->chroma_420_type=1);",
"VAR_0->progressive_frame = VAR_0->progressive_sequence;",
"put_bits(&VAR_0->pb, 1, VAR_0->progressive_frame);",
"put_bits(&VAR_0->pb, 1, 0);",
"}",
"if(VAR_0->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){",
"int VAR_2;",
"put_header(VAR_0, USER_START_CODE);",
"for(VAR_2=0; VAR_2<sizeof(svcd_scan_offset_placeholder); VAR_2++){",
"put_bits(&VAR_0->pb, 8, svcd_scan_offset_placeholder[VAR_2]);",
"}",
"}",
"VAR_0->mb_y=0;",
"ff_mpeg1_encode_slice_header(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
19,
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
57
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
]
] |
2,751 | static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
{
gen_helper_fcmpd(cpu_env, r_rs1, r_rs2);
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
{
gen_helper_fcmpd(cpu_env, r_rs1, r_rs2);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0, TCGv_i64 VAR_1, TCGv_i64 VAR_2)
{
gen_helper_fcmpd(cpu_env, VAR_1, VAR_2);
}
| [
"static inline void FUNC_0(int VAR_0, TCGv_i64 VAR_1, TCGv_i64 VAR_2)\n{",
"gen_helper_fcmpd(cpu_env, VAR_1, VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
2,752 | int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
uint8_t ar, uintptr_t ra)
{
CPUS390XState *env = &cpu->env;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
MemTxResult result;
int i;
uint32_t fh;
uint8_t pcias;
uint8_t len;
uint8_t buffer[128];
if (env->psw.mask & PSW_MASK_PSTATE) {
s390_program_interrupt(env, PGM_PRIVILEGED, 6, ra);
return 0;
}
fh = env->regs[r1] >> 32;
pcias = (env->regs[r1] >> 16) & 0xf;
len = env->regs[r1] & 0xff;
if (pcias > 5) {
DPRINTF("pcistb invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r1, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
switch (len) {
case 16:
case 32:
case 64:
case 128:
break;
default:
s390_program_interrupt(env, PGM_SPECIFICATION, 6, ra);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(s390_get_phb(), fh);
if (!pbdev) {
DPRINTF("pcistb no pci dev fh 0x%x\n", fh);
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r1, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
mr = pbdev->pdev->io_regions[pcias].memory;
if (!memory_region_access_valid(mr, env->regs[r3], len, true)) {
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
return 0;
}
if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) {
s390_cpu_virt_mem_handle_exc(cpu, ra);
return 0;
}
for (i = 0; i < len / 8; i++) {
result = memory_region_dispatch_write(mr, env->regs[r3] + i * 8,
ldq_p(buffer + i * 8), 8,
MEMTXATTRS_UNSPECIFIED);
if (result != MEMTX_OK) {
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
return 0;
}
}
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| false | qemu | 0e7c259adff7e97f829a08a5f146e7ee03b5ae47 | int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
uint8_t ar, uintptr_t ra)
{
CPUS390XState *env = &cpu->env;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
MemTxResult result;
int i;
uint32_t fh;
uint8_t pcias;
uint8_t len;
uint8_t buffer[128];
if (env->psw.mask & PSW_MASK_PSTATE) {
s390_program_interrupt(env, PGM_PRIVILEGED, 6, ra);
return 0;
}
fh = env->regs[r1] >> 32;
pcias = (env->regs[r1] >> 16) & 0xf;
len = env->regs[r1] & 0xff;
if (pcias > 5) {
DPRINTF("pcistb invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r1, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
switch (len) {
case 16:
case 32:
case 64:
case 128:
break;
default:
s390_program_interrupt(env, PGM_SPECIFICATION, 6, ra);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(s390_get_phb(), fh);
if (!pbdev) {
DPRINTF("pcistb no pci dev fh 0x%x\n", fh);
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r1, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
mr = pbdev->pdev->io_regions[pcias].memory;
if (!memory_region_access_valid(mr, env->regs[r3], len, true)) {
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
return 0;
}
if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) {
s390_cpu_virt_mem_handle_exc(cpu, ra);
return 0;
}
for (i = 0; i < len / 8; i++) {
result = memory_region_dispatch_write(mr, env->regs[r3] + i * 8,
ldq_p(buffer + i * 8), 8,
MEMTXATTRS_UNSPECIFIED);
if (result != MEMTX_OK) {
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
return 0;
}
}
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2, uint64_t VAR_3,
uint8_t VAR_4, uintptr_t VAR_5)
{
CPUS390XState *env = &VAR_0->env;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
MemTxResult result;
int VAR_6;
uint32_t fh;
uint8_t pcias;
uint8_t len;
uint8_t buffer[128];
if (env->psw.mask & PSW_MASK_PSTATE) {
s390_program_interrupt(env, PGM_PRIVILEGED, 6, VAR_5);
return 0;
}
fh = env->regs[VAR_1] >> 32;
pcias = (env->regs[VAR_1] >> 16) & 0xf;
len = env->regs[VAR_1] & 0xff;
if (pcias > 5) {
DPRINTF("pcistb invalid space\n");
setcc(VAR_0, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, VAR_1, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
switch (len) {
case 16:
case 32:
case 64:
case 128:
break;
default:
s390_program_interrupt(env, PGM_SPECIFICATION, 6, VAR_5);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(s390_get_phb(), fh);
if (!pbdev) {
DPRINTF("pcistb no pci dev fh 0x%x\n", fh);
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(VAR_0, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, VAR_1, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
mr = pbdev->pdev->io_regions[pcias].memory;
if (!memory_region_access_valid(mr, env->regs[VAR_2], len, true)) {
s390_program_interrupt(env, PGM_OPERAND, 6, VAR_5);
return 0;
}
if (s390_cpu_virt_mem_read(VAR_0, VAR_3, VAR_4, buffer, len)) {
s390_cpu_virt_mem_handle_exc(VAR_0, VAR_5);
return 0;
}
for (VAR_6 = 0; VAR_6 < len / 8; VAR_6++) {
result = memory_region_dispatch_write(mr, env->regs[VAR_2] + VAR_6 * 8,
ldq_p(buffer + VAR_6 * 8), 8,
MEMTXATTRS_UNSPECIFIED);
if (result != MEMTX_OK) {
s390_program_interrupt(env, PGM_OPERAND, 6, VAR_5);
return 0;
}
}
setcc(VAR_0, ZPCI_PCI_LS_OK);
return 0;
}
| [
"int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2, uint64_t VAR_3,\nuint8_t VAR_4, uintptr_t VAR_5)\n{",
"CPUS390XState *env = &VAR_0->env;",
"S390PCIBusDevice *pbdev;",
"MemoryRegion *mr;",
"MemTxResult result;",
"int VAR_6;",
"uint32_t fh;",
"uint8_t pcias;",
"uint8_t len;",
"uint8_t buffer[128];",
"if (env->psw.mask & PSW_MASK_PSTATE) {",
"s390_program_interrupt(env, PGM_PRIVILEGED, 6, VAR_5);",
"return 0;",
"}",
"fh = env->regs[VAR_1] >> 32;",
"pcias = (env->regs[VAR_1] >> 16) & 0xf;",
"len = env->regs[VAR_1] & 0xff;",
"if (pcias > 5) {",
"DPRINTF(\"pcistb invalid space\\n\");",
"setcc(VAR_0, ZPCI_PCI_LS_ERR);",
"s390_set_status_code(env, VAR_1, ZPCI_PCI_ST_INVAL_AS);",
"return 0;",
"}",
"switch (len) {",
"case 16:\ncase 32:\ncase 64:\ncase 128:\nbreak;",
"default:\ns390_program_interrupt(env, PGM_SPECIFICATION, 6, VAR_5);",
"return 0;",
"}",
"pbdev = s390_pci_find_dev_by_fh(s390_get_phb(), fh);",
"if (!pbdev) {",
"DPRINTF(\"pcistb no pci dev fh 0x%x\\n\", fh);",
"setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"}",
"switch (pbdev->state) {",
"case ZPCI_FS_RESERVED:\ncase ZPCI_FS_STANDBY:\ncase ZPCI_FS_DISABLED:\ncase ZPCI_FS_PERMANENT_ERROR:\nsetcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"case ZPCI_FS_ERROR:\nsetcc(VAR_0, ZPCI_PCI_LS_ERR);",
"s390_set_status_code(env, VAR_1, ZPCI_PCI_ST_BLOCKED);",
"return 0;",
"default:\nbreak;",
"}",
"mr = pbdev->pdev->io_regions[pcias].memory;",
"if (!memory_region_access_valid(mr, env->regs[VAR_2], len, true)) {",
"s390_program_interrupt(env, PGM_OPERAND, 6, VAR_5);",
"return 0;",
"}",
"if (s390_cpu_virt_mem_read(VAR_0, VAR_3, VAR_4, buffer, len)) {",
"s390_cpu_virt_mem_handle_exc(VAR_0, VAR_5);",
"return 0;",
"}",
"for (VAR_6 = 0; VAR_6 < len / 8; VAR_6++) {",
"result = memory_region_dispatch_write(mr, env->regs[VAR_2] + VAR_6 * 8,\nldq_p(buffer + VAR_6 * 8), 8,\nMEMTXATTRS_UNSPECIFIED);",
"if (result != MEMTX_OK) {",
"s390_program_interrupt(env, PGM_OPERAND, 6, VAR_5);",
"return 0;",
"}",
"}",
"setcc(VAR_0, ZPCI_PCI_LS_OK);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63,
65,
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97,
99,
101,
103,
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149,
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
]
] |
2,754 | static void *spapr_create_fdt_skel(const char *cpu_model,
target_phys_addr_t rma_size,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
const char *boot_device,
const char *kernel_cmdline,
long hash_shift)
{
void *fdt;
CPUState *env;
uint64_t mem_reg_property_rma[] = { 0, cpu_to_be64(rma_size) };
uint64_t mem_reg_property_nonrma[] = { cpu_to_be64(rma_size),
cpu_to_be64(ram_size - rma_size) };
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
uint32_t pft_size_prop[] = {0, cpu_to_be32(hash_shift)};
char hypertas_prop[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int i;
char *modelname;
int smt = kvmppc_smt_threads();
#define _FDT(exp) \
do { \
int ret = (exp); \
if (ret < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(ret)); \
exit(1); \
} \
} while (0)
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
_FDT((fdt_finish_reservemap(fdt)));
/* Root node */
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
/* /chosen */
_FDT((fdt_begin_node(fdt, "chosen")));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
_FDT((fdt_end_node(fdt)));
/* memory node(s) */
_FDT((fdt_begin_node(fdt, "memory@0")));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property_rma,
sizeof(mem_reg_property_rma))));
_FDT((fdt_end_node(fdt)));
if (ram_size > rma_size) {
char mem_name[32];
sprintf(mem_name, "memory@%" PRIx64, (uint64_t)rma_size);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property_nonrma,
sizeof(mem_reg_property_nonrma))));
_FDT((fdt_end_node(fdt)));
}
/* cpus */
_FDT((fdt_begin_node(fdt, "cpus")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
modelname = g_strdup(cpu_model);
for (i = 0; i < strlen(modelname); i++) {
modelname[i] = toupper(modelname[i]);
}
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t vmx = kvm_enabled() ? kvmppc_get_vmx() : 0;
uint32_t dfp = kvm_enabled() ? kvmppc_get_dfp() : 0;
if ((index % smt) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(fdt, nodename)));
free(nodename);
_FDT((fdt_property_cell(fdt, "reg", index)));
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
_FDT((fdt_property_cell(fdt, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(fdt, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(fdt, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(fdt, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(fdt, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(fdt, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(fdt, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(fdt, "status", "okay")));
_FDT((fdt_property(fdt, "64-bit", NULL, 0)));
/* Build interrupt servers and gservers properties */
for (i = 0; i < smp_threads; i++) {
servers_prop[i] = cpu_to_be32(index + i);
/* Hack, direct the group queues back to cpu 0 */
gservers_prop[i*2] = cpu_to_be32(index + i);
gservers_prop[i*2 + 1] = 0;
}
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(fdt, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
/* Advertise VMX/VSX (vector extensions) if available
* 0 / no property == no vector extensions
* 1 == VMX / Altivec available
* 2 == VSX available */
if (vmx) {
_FDT((fdt_property_cell(fdt, "ibm,vmx", vmx)));
}
/* Advertise DFP (Decimal Floating Point) if available
* 0 / no property == no DFP
* 1 == DFP available */
if (dfp) {
_FDT((fdt_property_cell(fdt, "ibm,dfp", dfp)));
}
_FDT((fdt_end_node(fdt)));
}
g_free(modelname);
_FDT((fdt_end_node(fdt)));
/* RTAS */
_FDT((fdt_begin_node(fdt, "rtas")));
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas_prop,
sizeof(hypertas_prop))));
_FDT((fdt_end_node(fdt)));
/* interrupt controller */
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
/* vdevice */
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_end_node(fdt))); /* close root node */
_FDT((fdt_finish(fdt)));
return fdt;
}
| false | qemu | a7342588c081c7497bc7810431a03fa7b669af40 | static void *spapr_create_fdt_skel(const char *cpu_model,
target_phys_addr_t rma_size,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
const char *boot_device,
const char *kernel_cmdline,
long hash_shift)
{
void *fdt;
CPUState *env;
uint64_t mem_reg_property_rma[] = { 0, cpu_to_be64(rma_size) };
uint64_t mem_reg_property_nonrma[] = { cpu_to_be64(rma_size),
cpu_to_be64(ram_size - rma_size) };
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
uint32_t pft_size_prop[] = {0, cpu_to_be32(hash_shift)};
char hypertas_prop[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int i;
char *modelname;
int smt = kvmppc_smt_threads();
#define _FDT(exp) \
do { \
int ret = (exp); \
if (ret < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(ret)); \
exit(1); \
} \
} while (0)
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
_FDT((fdt_finish_reservemap(fdt)));
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
_FDT((fdt_begin_node(fdt, "chosen")));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
_FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "memory@0")));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property_rma,
sizeof(mem_reg_property_rma))));
_FDT((fdt_end_node(fdt)));
if (ram_size > rma_size) {
char mem_name[32];
sprintf(mem_name, "memory@%" PRIx64, (uint64_t)rma_size);
_FDT((fdt_begin_node(fdt, mem_name)));
_FDT((fdt_property_string(fdt, "device_type", "memory")));
_FDT((fdt_property(fdt, "reg", mem_reg_property_nonrma,
sizeof(mem_reg_property_nonrma))));
_FDT((fdt_end_node(fdt)));
}
_FDT((fdt_begin_node(fdt, "cpus")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
modelname = g_strdup(cpu_model);
for (i = 0; i < strlen(modelname); i++) {
modelname[i] = toupper(modelname[i]);
}
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t vmx = kvm_enabled() ? kvmppc_get_vmx() : 0;
uint32_t dfp = kvm_enabled() ? kvmppc_get_dfp() : 0;
if ((index % smt) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", modelname, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(fdt, nodename)));
free(nodename);
_FDT((fdt_property_cell(fdt, "reg", index)));
_FDT((fdt_property_string(fdt, "device_type", "cpu")));
_FDT((fdt_property_cell(fdt, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(fdt, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(fdt, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(fdt, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(fdt, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(fdt, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(fdt, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(fdt, "status", "okay")));
_FDT((fdt_property(fdt, "64-bit", NULL, 0)));
for (i = 0; i < smp_threads; i++) {
servers_prop[i] = cpu_to_be32(index + i);
gservers_prop[i*2] = cpu_to_be32(index + i);
gservers_prop[i*2 + 1] = 0;
}
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(fdt, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(fdt, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
if (vmx) {
_FDT((fdt_property_cell(fdt, "ibm,vmx", vmx)));
}
if (dfp) {
_FDT((fdt_property_cell(fdt, "ibm,dfp", dfp)));
}
_FDT((fdt_end_node(fdt)));
}
g_free(modelname);
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "rtas")));
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas_prop,
sizeof(hypertas_prop))));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_finish(fdt)));
return fdt;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(const char *VAR_0,
target_phys_addr_t VAR_1,
target_phys_addr_t VAR_2,
target_phys_addr_t VAR_3,
const char *VAR_4,
const char *VAR_5,
long VAR_6)
{
void *VAR_7;
CPUState *env;
uint64_t mem_reg_property_rma[] = { 0, cpu_to_be64(VAR_1) };
uint64_t mem_reg_property_nonrma[] = { cpu_to_be64(VAR_1),
cpu_to_be64(ram_size - VAR_1) };
uint32_t start_prop = cpu_to_be32(VAR_2);
uint32_t end_prop = cpu_to_be32(VAR_2 + VAR_3);
uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_6)};
char VAR_8[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
"\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
int VAR_9;
char *VAR_10;
int VAR_11 = kvmppc_smt_threads();
#define _FDT(exp) \
do { \
int VAR_12 = (exp); \
if (VAR_12 < 0) { \
fprintf(stderr, "qemu: error creating device tree: %s: %s\n", \
#exp, fdt_strerror(VAR_12)); \
exit(1); \
} \
} while (0)
VAR_7 = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(VAR_7, FDT_MAX_SIZE)));
_FDT((fdt_finish_reservemap(VAR_7)));
_FDT((fdt_begin_node(VAR_7, "")));
_FDT((fdt_property_string(VAR_7, "device_type", "chrp")));
_FDT((fdt_property_string(VAR_7, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_cell(VAR_7, "#address-cells", 0x2)));
_FDT((fdt_property_cell(VAR_7, "#size-cells", 0x2)));
_FDT((fdt_begin_node(VAR_7, "chosen")));
_FDT((fdt_property_string(VAR_7, "bootargs", VAR_5)));
_FDT((fdt_property(VAR_7, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(VAR_7, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
_FDT((fdt_property_string(VAR_7, "qemu,boot-device", VAR_4)));
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_begin_node(VAR_7, "memory@0")));
_FDT((fdt_property_string(VAR_7, "device_type", "memory")));
_FDT((fdt_property(VAR_7, "reg", mem_reg_property_rma,
sizeof(mem_reg_property_rma))));
_FDT((fdt_end_node(VAR_7)));
if (ram_size > VAR_1) {
char VAR_13[32];
sprintf(VAR_13, "memory@%" PRIx64, (uint64_t)VAR_1);
_FDT((fdt_begin_node(VAR_7, VAR_13)));
_FDT((fdt_property_string(VAR_7, "device_type", "memory")));
_FDT((fdt_property(VAR_7, "reg", mem_reg_property_nonrma,
sizeof(mem_reg_property_nonrma))));
_FDT((fdt_end_node(VAR_7)));
}
_FDT((fdt_begin_node(VAR_7, "cpus")));
_FDT((fdt_property_cell(VAR_7, "#address-cells", 0x1)));
_FDT((fdt_property_cell(VAR_7, "#size-cells", 0x0)));
VAR_10 = g_strdup(VAR_0);
for (VAR_9 = 0; VAR_9 < strlen(VAR_10); VAR_9++) {
VAR_10[VAR_9] = toupper(VAR_10[VAR_9]);
}
for (env = first_cpu; env != NULL; env = env->next_cpu) {
int index = env->cpu_index;
uint32_t servers_prop[smp_threads];
uint32_t gservers_prop[smp_threads * 2];
char *nodename;
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0xffffffff, 0xffffffff};
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
uint32_t vmx = kvm_enabled() ? kvmppc_get_vmx() : 0;
uint32_t dfp = kvm_enabled() ? kvmppc_get_dfp() : 0;
if ((index % VAR_11) != 0) {
continue;
}
if (asprintf(&nodename, "%s@%x", VAR_10, index) < 0) {
fprintf(stderr, "Allocation failure\n");
exit(1);
}
_FDT((fdt_begin_node(VAR_7, nodename)));
free(nodename);
_FDT((fdt_property_cell(VAR_7, "reg", index)));
_FDT((fdt_property_string(VAR_7, "device_type", "cpu")));
_FDT((fdt_property_cell(VAR_7, "cpu-version", env->spr[SPR_PVR])));
_FDT((fdt_property_cell(VAR_7, "dcache-block-size",
env->dcache_line_size)));
_FDT((fdt_property_cell(VAR_7, "icache-block-size",
env->icache_line_size)));
_FDT((fdt_property_cell(VAR_7, "timebase-frequency", tbfreq)));
_FDT((fdt_property_cell(VAR_7, "clock-frequency", cpufreq)));
_FDT((fdt_property_cell(VAR_7, "ibm,slb-size", env->slb_nr)));
_FDT((fdt_property(VAR_7, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop))));
_FDT((fdt_property_string(VAR_7, "status", "okay")));
_FDT((fdt_property(VAR_7, "64-bit", NULL, 0)));
for (VAR_9 = 0; VAR_9 < smp_threads; VAR_9++) {
servers_prop[VAR_9] = cpu_to_be32(index + VAR_9);
gservers_prop[VAR_9*2] = cpu_to_be32(index + VAR_9);
gservers_prop[VAR_9*2 + 1] = 0;
}
_FDT((fdt_property(VAR_7, "ibm,ppc-interrupt-server#s",
servers_prop, sizeof(servers_prop))));
_FDT((fdt_property(VAR_7, "ibm,ppc-interrupt-gserver#s",
gservers_prop, sizeof(gservers_prop))));
if (env->mmu_model & POWERPC_MMU_1TSEG) {
_FDT((fdt_property(VAR_7, "ibm,processor-segment-sizes",
segs, sizeof(segs))));
}
if (vmx) {
_FDT((fdt_property_cell(VAR_7, "ibm,vmx", vmx)));
}
if (dfp) {
_FDT((fdt_property_cell(VAR_7, "ibm,dfp", dfp)));
}
_FDT((fdt_end_node(VAR_7)));
}
g_free(VAR_10);
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_begin_node(VAR_7, "rtas")));
_FDT((fdt_property(VAR_7, "ibm,hypertas-functions", VAR_8,
sizeof(VAR_8))));
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_begin_node(VAR_7, "interrupt-controller")));
_FDT((fdt_property_string(VAR_7, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(VAR_7, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(VAR_7, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(VAR_7, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(VAR_7, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(VAR_7, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(VAR_7, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_begin_node(VAR_7, "vdevice")));
_FDT((fdt_property_string(VAR_7, "device_type", "vdevice")));
_FDT((fdt_property_string(VAR_7, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(VAR_7, "#address-cells", 0x1)));
_FDT((fdt_property_cell(VAR_7, "#size-cells", 0x0)));
_FDT((fdt_property_cell(VAR_7, "#interrupt-cells", 0x2)));
_FDT((fdt_property(VAR_7, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_end_node(VAR_7)));
_FDT((fdt_finish(VAR_7)));
return VAR_7;
}
| [
"static void *FUNC_0(const char *VAR_0,\ntarget_phys_addr_t VAR_1,\ntarget_phys_addr_t VAR_2,\ntarget_phys_addr_t VAR_3,\nconst char *VAR_4,\nconst char *VAR_5,\nlong VAR_6)\n{",
"void *VAR_7;",
"CPUState *env;",
"uint64_t mem_reg_property_rma[] = { 0, cpu_to_be64(VAR_1) };",
"uint64_t mem_reg_property_nonrma[] = { cpu_to_be64(VAR_1),",
"cpu_to_be64(ram_size - VAR_1) };",
"uint32_t start_prop = cpu_to_be32(VAR_2);",
"uint32_t end_prop = cpu_to_be32(VAR_2 + VAR_3);",
"uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_6)};",
"char VAR_8[] = \"hcall-pft\\0hcall-term\\0hcall-dabr\\0hcall-interrupt\"\n\"\\0hcall-tce\\0hcall-vio\\0hcall-splpar\\0hcall-bulk\";",
"uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};",
"int VAR_9;",
"char *VAR_10;",
"int VAR_11 = kvmppc_smt_threads();",
"#define _FDT(exp) \\\ndo { \\",
"int VAR_12 = (exp); \\",
"if (VAR_12 < 0) { \\",
"fprintf(stderr, \"qemu: error creating device tree: %s: %s\\n\", \\\n#exp, fdt_strerror(VAR_12)); \\",
"exit(1); \\",
"} \\",
"} while (0)",
"VAR_7 = g_malloc0(FDT_MAX_SIZE);",
"_FDT((fdt_create(VAR_7, FDT_MAX_SIZE)));",
"_FDT((fdt_finish_reservemap(VAR_7)));",
"_FDT((fdt_begin_node(VAR_7, \"\")));",
"_FDT((fdt_property_string(VAR_7, \"device_type\", \"chrp\")));",
"_FDT((fdt_property_string(VAR_7, \"model\", \"IBM pSeries (emulated by qemu)\")));",
"_FDT((fdt_property_cell(VAR_7, \"#address-cells\", 0x2)));",
"_FDT((fdt_property_cell(VAR_7, \"#size-cells\", 0x2)));",
"_FDT((fdt_begin_node(VAR_7, \"chosen\")));",
"_FDT((fdt_property_string(VAR_7, \"bootargs\", VAR_5)));",
"_FDT((fdt_property(VAR_7, \"linux,initrd-start\",\n&start_prop, sizeof(start_prop))));",
"_FDT((fdt_property(VAR_7, \"linux,initrd-end\",\n&end_prop, sizeof(end_prop))));",
"_FDT((fdt_property_string(VAR_7, \"qemu,boot-device\", VAR_4)));",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_begin_node(VAR_7, \"memory@0\")));",
"_FDT((fdt_property_string(VAR_7, \"device_type\", \"memory\")));",
"_FDT((fdt_property(VAR_7, \"reg\", mem_reg_property_rma,\nsizeof(mem_reg_property_rma))));",
"_FDT((fdt_end_node(VAR_7)));",
"if (ram_size > VAR_1) {",
"char VAR_13[32];",
"sprintf(VAR_13, \"memory@%\" PRIx64, (uint64_t)VAR_1);",
"_FDT((fdt_begin_node(VAR_7, VAR_13)));",
"_FDT((fdt_property_string(VAR_7, \"device_type\", \"memory\")));",
"_FDT((fdt_property(VAR_7, \"reg\", mem_reg_property_nonrma,\nsizeof(mem_reg_property_nonrma))));",
"_FDT((fdt_end_node(VAR_7)));",
"}",
"_FDT((fdt_begin_node(VAR_7, \"cpus\")));",
"_FDT((fdt_property_cell(VAR_7, \"#address-cells\", 0x1)));",
"_FDT((fdt_property_cell(VAR_7, \"#size-cells\", 0x0)));",
"VAR_10 = g_strdup(VAR_0);",
"for (VAR_9 = 0; VAR_9 < strlen(VAR_10); VAR_9++) {",
"VAR_10[VAR_9] = toupper(VAR_10[VAR_9]);",
"}",
"for (env = first_cpu; env != NULL; env = env->next_cpu) {",
"int index = env->cpu_index;",
"uint32_t servers_prop[smp_threads];",
"uint32_t gservers_prop[smp_threads * 2];",
"char *nodename;",
"uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),",
"0xffffffff, 0xffffffff};",
"uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TIMEBASE_FREQ;",
"uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;",
"uint32_t vmx = kvm_enabled() ? kvmppc_get_vmx() : 0;",
"uint32_t dfp = kvm_enabled() ? kvmppc_get_dfp() : 0;",
"if ((index % VAR_11) != 0) {",
"continue;",
"}",
"if (asprintf(&nodename, \"%s@%x\", VAR_10, index) < 0) {",
"fprintf(stderr, \"Allocation failure\\n\");",
"exit(1);",
"}",
"_FDT((fdt_begin_node(VAR_7, nodename)));",
"free(nodename);",
"_FDT((fdt_property_cell(VAR_7, \"reg\", index)));",
"_FDT((fdt_property_string(VAR_7, \"device_type\", \"cpu\")));",
"_FDT((fdt_property_cell(VAR_7, \"cpu-version\", env->spr[SPR_PVR])));",
"_FDT((fdt_property_cell(VAR_7, \"dcache-block-size\",\nenv->dcache_line_size)));",
"_FDT((fdt_property_cell(VAR_7, \"icache-block-size\",\nenv->icache_line_size)));",
"_FDT((fdt_property_cell(VAR_7, \"timebase-frequency\", tbfreq)));",
"_FDT((fdt_property_cell(VAR_7, \"clock-frequency\", cpufreq)));",
"_FDT((fdt_property_cell(VAR_7, \"ibm,slb-size\", env->slb_nr)));",
"_FDT((fdt_property(VAR_7, \"ibm,pft-size\",\npft_size_prop, sizeof(pft_size_prop))));",
"_FDT((fdt_property_string(VAR_7, \"status\", \"okay\")));",
"_FDT((fdt_property(VAR_7, \"64-bit\", NULL, 0)));",
"for (VAR_9 = 0; VAR_9 < smp_threads; VAR_9++) {",
"servers_prop[VAR_9] = cpu_to_be32(index + VAR_9);",
"gservers_prop[VAR_9*2] = cpu_to_be32(index + VAR_9);",
"gservers_prop[VAR_9*2 + 1] = 0;",
"}",
"_FDT((fdt_property(VAR_7, \"ibm,ppc-interrupt-server#s\",\nservers_prop, sizeof(servers_prop))));",
"_FDT((fdt_property(VAR_7, \"ibm,ppc-interrupt-gserver#s\",\ngservers_prop, sizeof(gservers_prop))));",
"if (env->mmu_model & POWERPC_MMU_1TSEG) {",
"_FDT((fdt_property(VAR_7, \"ibm,processor-segment-sizes\",\nsegs, sizeof(segs))));",
"}",
"if (vmx) {",
"_FDT((fdt_property_cell(VAR_7, \"ibm,vmx\", vmx)));",
"}",
"if (dfp) {",
"_FDT((fdt_property_cell(VAR_7, \"ibm,dfp\", dfp)));",
"}",
"_FDT((fdt_end_node(VAR_7)));",
"}",
"g_free(VAR_10);",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_begin_node(VAR_7, \"rtas\")));",
"_FDT((fdt_property(VAR_7, \"ibm,hypertas-functions\", VAR_8,\nsizeof(VAR_8))));",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_begin_node(VAR_7, \"interrupt-controller\")));",
"_FDT((fdt_property_string(VAR_7, \"device_type\",\n\"PowerPC-External-Interrupt-Presentation\")));",
"_FDT((fdt_property_string(VAR_7, \"compatible\", \"IBM,ppc-xicp\")));",
"_FDT((fdt_property(VAR_7, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_property(VAR_7, \"ibm,interrupt-server-ranges\",\ninterrupt_server_ranges_prop,\nsizeof(interrupt_server_ranges_prop))));",
"_FDT((fdt_property_cell(VAR_7, \"#interrupt-cells\", 2)));",
"_FDT((fdt_property_cell(VAR_7, \"linux,phandle\", PHANDLE_XICP)));",
"_FDT((fdt_property_cell(VAR_7, \"phandle\", PHANDLE_XICP)));",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_begin_node(VAR_7, \"vdevice\")));",
"_FDT((fdt_property_string(VAR_7, \"device_type\", \"vdevice\")));",
"_FDT((fdt_property_string(VAR_7, \"compatible\", \"IBM,vdevice\")));",
"_FDT((fdt_property_cell(VAR_7, \"#address-cells\", 0x1)));",
"_FDT((fdt_property_cell(VAR_7, \"#size-cells\", 0x0)));",
"_FDT((fdt_property_cell(VAR_7, \"#interrupt-cells\", 0x2)));",
"_FDT((fdt_property(VAR_7, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_end_node(VAR_7)));",
"_FDT((fdt_finish(VAR_7)));",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
95
],
[
99
],
[
101,
103
],
[
105,
107
],
[
109
],
[
113
],
[
119
],
[
123
],
[
125,
127
],
[
129
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
157
],
[
161
],
[
163
],
[
167
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
225
],
[
229
],
[
231
],
[
235
],
[
237,
239
],
[
241,
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275,
277
],
[
279,
281
],
[
285
],
[
287,
289
],
[
291
],
[
303
],
[
305
],
[
307
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
331
],
[
335
],
[
341
],
[
345,
347
],
[
351
],
[
357
],
[
361,
363
],
[
365
],
[
367
],
[
369,
371,
373
],
[
375
],
[
377
],
[
379
],
[
383
],
[
389
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
411
],
[
413
],
[
417
],
[
419
]
] |
2,755 | static target_phys_addr_t get_offset(target_phys_addr_t phys_addr,
DumpState *s)
{
RAMBlock *block;
target_phys_addr_t offset = s->memory_offset;
int64_t size_in_block, start;
if (s->has_filter) {
if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {
return -1;
}
}
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
/* This block is out of the range */
continue;
}
if (s->begin <= block->offset) {
start = block->offset;
} else {
start = s->begin;
}
size_in_block = block->length - (start - block->offset);
if (s->begin + s->length < block->offset + block->length) {
size_in_block -= block->offset + block->length -
(s->begin + s->length);
}
} else {
start = block->offset;
size_in_block = block->length;
}
if (phys_addr >= start && phys_addr < start + size_in_block) {
return phys_addr - start + offset;
}
offset += size_in_block;
}
return -1;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static target_phys_addr_t get_offset(target_phys_addr_t phys_addr,
DumpState *s)
{
RAMBlock *block;
target_phys_addr_t offset = s->memory_offset;
int64_t size_in_block, start;
if (s->has_filter) {
if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {
return -1;
}
}
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
continue;
}
if (s->begin <= block->offset) {
start = block->offset;
} else {
start = s->begin;
}
size_in_block = block->length - (start - block->offset);
if (s->begin + s->length < block->offset + block->length) {
size_in_block -= block->offset + block->length -
(s->begin + s->length);
}
} else {
start = block->offset;
size_in_block = block->length;
}
if (phys_addr >= start && phys_addr < start + size_in_block) {
return phys_addr - start + offset;
}
offset += size_in_block;
}
return -1;
}
| {
"code": [],
"line_no": []
} | static target_phys_addr_t FUNC_0(target_phys_addr_t phys_addr,
DumpState *s)
{
RAMBlock *block;
target_phys_addr_t offset = s->memory_offset;
int64_t size_in_block, start;
if (s->has_filter) {
if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {
return -1;
}
}
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
continue;
}
if (s->begin <= block->offset) {
start = block->offset;
} else {
start = s->begin;
}
size_in_block = block->length - (start - block->offset);
if (s->begin + s->length < block->offset + block->length) {
size_in_block -= block->offset + block->length -
(s->begin + s->length);
}
} else {
start = block->offset;
size_in_block = block->length;
}
if (phys_addr >= start && phys_addr < start + size_in_block) {
return phys_addr - start + offset;
}
offset += size_in_block;
}
return -1;
}
| [
"static target_phys_addr_t FUNC_0(target_phys_addr_t phys_addr,\nDumpState *s)\n{",
"RAMBlock *block;",
"target_phys_addr_t offset = s->memory_offset;",
"int64_t size_in_block, start;",
"if (s->has_filter) {",
"if (phys_addr < s->begin || phys_addr >= s->begin + s->length) {",
"return -1;",
"}",
"}",
"QLIST_FOREACH(block, &ram_list.blocks, next) {",
"if (s->has_filter) {",
"if (block->offset >= s->begin + s->length ||\nblock->offset + block->length <= s->begin) {",
"continue;",
"}",
"if (s->begin <= block->offset) {",
"start = block->offset;",
"} else {",
"start = s->begin;",
"}",
"size_in_block = block->length - (start - block->offset);",
"if (s->begin + s->length < block->offset + block->length) {",
"size_in_block -= block->offset + block->length -\n(s->begin + s->length);",
"}",
"} else {",
"start = block->offset;",
"size_in_block = block->length;",
"}",
"if (phys_addr >= start && phys_addr < start + size_in_block) {",
"return phys_addr - start + offset;",
"}",
"offset += size_in_block;",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91
]
] |
2,756 | static MegasasCmd *megasas_enqueue_frame(MegasasState *s,
target_phys_addr_t frame, uint64_t context, int count)
{
MegasasCmd *cmd = NULL;
int frame_size = MFI_FRAME_SIZE * 16;
target_phys_addr_t frame_size_p = frame_size;
cmd = megasas_next_frame(s, frame);
/* All frames busy */
if (!cmd) {
return NULL;
}
if (!cmd->pa) {
cmd->pa = frame;
/* Map all possible frames */
cmd->frame = cpu_physical_memory_map(frame, &frame_size_p, 0);
if (frame_size_p != frame_size) {
trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);
if (cmd->frame) {
cpu_physical_memory_unmap(cmd->frame, frame_size_p, 0, 0);
cmd->frame = NULL;
cmd->pa = 0;
}
s->event_count++;
return NULL;
}
cmd->pa_size = frame_size_p;
cmd->context = context;
if (!megasas_use_queue64(s)) {
cmd->context &= (uint64_t)0xFFFFFFFF;
}
}
cmd->count = count;
s->busy++;
trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,
s->reply_queue_head, s->busy);
return cmd;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static MegasasCmd *megasas_enqueue_frame(MegasasState *s,
target_phys_addr_t frame, uint64_t context, int count)
{
MegasasCmd *cmd = NULL;
int frame_size = MFI_FRAME_SIZE * 16;
target_phys_addr_t frame_size_p = frame_size;
cmd = megasas_next_frame(s, frame);
if (!cmd) {
return NULL;
}
if (!cmd->pa) {
cmd->pa = frame;
cmd->frame = cpu_physical_memory_map(frame, &frame_size_p, 0);
if (frame_size_p != frame_size) {
trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);
if (cmd->frame) {
cpu_physical_memory_unmap(cmd->frame, frame_size_p, 0, 0);
cmd->frame = NULL;
cmd->pa = 0;
}
s->event_count++;
return NULL;
}
cmd->pa_size = frame_size_p;
cmd->context = context;
if (!megasas_use_queue64(s)) {
cmd->context &= (uint64_t)0xFFFFFFFF;
}
}
cmd->count = count;
s->busy++;
trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,
s->reply_queue_head, s->busy);
return cmd;
}
| {
"code": [],
"line_no": []
} | static MegasasCmd *FUNC_0(MegasasState *s,
target_phys_addr_t frame, uint64_t context, int count)
{
MegasasCmd *cmd = NULL;
int VAR_0 = MFI_FRAME_SIZE * 16;
target_phys_addr_t frame_size_p = VAR_0;
cmd = megasas_next_frame(s, frame);
if (!cmd) {
return NULL;
}
if (!cmd->pa) {
cmd->pa = frame;
cmd->frame = cpu_physical_memory_map(frame, &frame_size_p, 0);
if (frame_size_p != VAR_0) {
trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);
if (cmd->frame) {
cpu_physical_memory_unmap(cmd->frame, frame_size_p, 0, 0);
cmd->frame = NULL;
cmd->pa = 0;
}
s->event_count++;
return NULL;
}
cmd->pa_size = frame_size_p;
cmd->context = context;
if (!megasas_use_queue64(s)) {
cmd->context &= (uint64_t)0xFFFFFFFF;
}
}
cmd->count = count;
s->busy++;
trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,
s->reply_queue_head, s->busy);
return cmd;
}
| [
"static MegasasCmd *FUNC_0(MegasasState *s,\ntarget_phys_addr_t frame, uint64_t context, int count)\n{",
"MegasasCmd *cmd = NULL;",
"int VAR_0 = MFI_FRAME_SIZE * 16;",
"target_phys_addr_t frame_size_p = VAR_0;",
"cmd = megasas_next_frame(s, frame);",
"if (!cmd) {",
"return NULL;",
"}",
"if (!cmd->pa) {",
"cmd->pa = frame;",
"cmd->frame = cpu_physical_memory_map(frame, &frame_size_p, 0);",
"if (frame_size_p != VAR_0) {",
"trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);",
"if (cmd->frame) {",
"cpu_physical_memory_unmap(cmd->frame, frame_size_p, 0, 0);",
"cmd->frame = NULL;",
"cmd->pa = 0;",
"}",
"s->event_count++;",
"return NULL;",
"}",
"cmd->pa_size = frame_size_p;",
"cmd->context = context;",
"if (!megasas_use_queue64(s)) {",
"cmd->context &= (uint64_t)0xFFFFFFFF;",
"}",
"}",
"cmd->count = count;",
"s->busy++;",
"trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,\ns->reply_queue_head, s->busy);",
"return cmd;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
77
],
[
79
]
] |
2,757 | void helper_stl_raw(uint64_t t0, uint64_t t1)
{
stl_raw(t1, t0);
}
| false | qemu | 2374e73edafff0586cbfb67c333c5a7588f81fd5 | void helper_stl_raw(uint64_t t0, uint64_t t1)
{
stl_raw(t1, t0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)
{
stl_raw(VAR_1, VAR_0);
}
| [
"void FUNC_0(uint64_t VAR_0, uint64_t VAR_1)\n{",
"stl_raw(VAR_1, VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
2,758 | static void string_deserialize(void **native_out, void *datap,
VisitorFunc visit, Error **errp)
{
StringSerializeData *d = datap;
d->string = string_output_get_string(d->sov);
d->siv = string_input_visitor_new(d->string);
visit(d->siv, native_out, errp);
}
| false | qemu | 3b098d56979d2f7fd707c5be85555d114353a28d | static void string_deserialize(void **native_out, void *datap,
VisitorFunc visit, Error **errp)
{
StringSerializeData *d = datap;
d->string = string_output_get_string(d->sov);
d->siv = string_input_visitor_new(d->string);
visit(d->siv, native_out, errp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void **VAR_0, void *VAR_1,
VisitorFunc VAR_2, Error **VAR_3)
{
StringSerializeData *d = VAR_1;
d->string = string_output_get_string(d->sov);
d->siv = string_input_visitor_new(d->string);
VAR_2(d->siv, VAR_0, VAR_3);
}
| [
"static void FUNC_0(void **VAR_0, void *VAR_1,\nVisitorFunc VAR_2, Error **VAR_3)\n{",
"StringSerializeData *d = VAR_1;",
"d->string = string_output_get_string(d->sov);",
"d->siv = string_input_visitor_new(d->string);",
"VAR_2(d->siv, VAR_0, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
2,759 | static uint16_t mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
{
uint16_t crc;
if (!crc_init) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init = 1;
}
crc = av_crc(crc_2D, 0, buf, buf_size - 2);
crc ^= AV_RL16(buf + buf_size - 2);
return crc;
}
| false | FFmpeg | ee5b34d56e7fa9c1eb1a2aeb2bf7b55516c99c8a | static uint16_t mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
{
uint16_t crc;
if (!crc_init) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init = 1;
}
crc = av_crc(crc_2D, 0, buf, buf_size - 2);
crc ^= AV_RL16(buf + buf_size - 2);
return crc;
}
| {
"code": [],
"line_no": []
} | static uint16_t FUNC_0(const uint8_t *buf, unsigned int buf_size)
{
uint16_t crc;
if (!crc_init) {
av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
crc_init = 1;
}
crc = av_crc(crc_2D, 0, buf, buf_size - 2);
crc ^= AV_RL16(buf + buf_size - 2);
return crc;
}
| [
"static uint16_t FUNC_0(const uint8_t *buf, unsigned int buf_size)\n{",
"uint16_t crc;",
"if (!crc_init) {",
"av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));",
"crc_init = 1;",
"}",
"crc = av_crc(crc_2D, 0, buf, buf_size - 2);",
"crc ^= AV_RL16(buf + buf_size - 2);",
"return crc;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
2,760 | static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event)
{
BDRVBlkdebugState *s = bs->opaque;
struct BlkdebugRule *rule;
bool injected;
assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
injected = false;
s->new_state = s->state;
QLIST_FOREACH(rule, &s->rules[event], next) {
injected = process_rule(bs, rule, injected);
}
s->state = s->new_state;
}
| false | qemu | 3c90c65d7adab49a41952ee14e1d65f81355e408 | static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event)
{
BDRVBlkdebugState *s = bs->opaque;
struct BlkdebugRule *rule;
bool injected;
assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
injected = false;
s->new_state = s->state;
QLIST_FOREACH(rule, &s->rules[event], next) {
injected = process_rule(bs, rule, injected);
}
s->state = s->new_state;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, BlkDebugEvent VAR_1)
{
BDRVBlkdebugState *s = VAR_0->opaque;
struct BlkdebugRule *VAR_2;
bool injected;
assert((int)VAR_1 >= 0 && VAR_1 < BLKDBG_EVENT_MAX);
injected = false;
s->new_state = s->state;
QLIST_FOREACH(VAR_2, &s->rules[VAR_1], next) {
injected = process_rule(VAR_0, VAR_2, injected);
}
s->state = s->new_state;
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, BlkDebugEvent VAR_1)\n{",
"BDRVBlkdebugState *s = VAR_0->opaque;",
"struct BlkdebugRule *VAR_2;",
"bool injected;",
"assert((int)VAR_1 >= 0 && VAR_1 < BLKDBG_EVENT_MAX);",
"injected = false;",
"s->new_state = s->state;",
"QLIST_FOREACH(VAR_2, &s->rules[VAR_1], next) {",
"injected = process_rule(VAR_0, VAR_2, injected);",
"}",
"s->state = s->new_state;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
2,761 | static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
{
char buf[1024];
VncShareMode mode;
int size;
mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;
switch (vs->vd->share_policy) {
case VNC_SHARE_POLICY_IGNORE:
/*
* Ignore the shared flag. Nothing to do here.
*
* Doesn't conform to the rfb spec but is traditional qemu
* behavior, thus left here as option for compatibility
* reasons.
*/
break;
case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:
/*
* Policy: Allow clients ask for exclusive access.
*
* Implementation: When a client asks for exclusive access,
* disconnect all others. Shared connects are allowed as long
* as no exclusive connection exists.
*
* This is how the rfb spec suggests to handle the shared flag.
*/
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
VncState *client;
QTAILQ_FOREACH(client, &vs->vd->clients, next) {
if (vs == client) {
continue;
}
if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&
client->share_mode != VNC_SHARE_MODE_SHARED) {
continue;
}
vnc_disconnect_start(client);
}
}
if (mode == VNC_SHARE_MODE_SHARED) {
if (vs->vd->num_exclusive > 0) {
vnc_disconnect_start(vs);
return 0;
}
}
break;
case VNC_SHARE_POLICY_FORCE_SHARED:
/*
* Policy: Shared connects only.
* Implementation: Disallow clients asking for exclusive access.
*
* Useful for shared desktop sessions where you don't want
* someone forgetting to say -shared when running the vnc
* client disconnect everybody else.
*/
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
vnc_disconnect_start(vs);
return 0;
}
break;
}
vnc_set_share_mode(vs, mode);
if (vs->vd->num_shared > vs->vd->connections_limit) {
vnc_disconnect_start(vs);
return 0;
}
vs->client_width = pixman_image_get_width(vs->vd->server);
vs->client_height = pixman_image_get_height(vs->vd->server);
vnc_write_u16(vs, vs->client_width);
vnc_write_u16(vs, vs->client_height);
pixel_format_message(vs);
if (qemu_name)
size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
else
size = snprintf(buf, sizeof(buf), "QEMU");
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs);
vnc_client_cache_auth(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
| false | qemu | 97efe4f961dcf5a0126baa75e8a6bff66d33186f | static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
{
char buf[1024];
VncShareMode mode;
int size;
mode = data[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;
switch (vs->vd->share_policy) {
case VNC_SHARE_POLICY_IGNORE:
break;
case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
VncState *client;
QTAILQ_FOREACH(client, &vs->vd->clients, next) {
if (vs == client) {
continue;
}
if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&
client->share_mode != VNC_SHARE_MODE_SHARED) {
continue;
}
vnc_disconnect_start(client);
}
}
if (mode == VNC_SHARE_MODE_SHARED) {
if (vs->vd->num_exclusive > 0) {
vnc_disconnect_start(vs);
return 0;
}
}
break;
case VNC_SHARE_POLICY_FORCE_SHARED:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
vnc_disconnect_start(vs);
return 0;
}
break;
}
vnc_set_share_mode(vs, mode);
if (vs->vd->num_shared > vs->vd->connections_limit) {
vnc_disconnect_start(vs);
return 0;
}
vs->client_width = pixman_image_get_width(vs->vd->server);
vs->client_height = pixman_image_get_height(vs->vd->server);
vnc_write_u16(vs, vs->client_width);
vnc_write_u16(vs, vs->client_height);
pixel_format_message(vs);
if (qemu_name)
size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
else
size = snprintf(buf, sizeof(buf), "QEMU");
vnc_write_u32(vs, size);
vnc_write(vs, buf, size);
vnc_flush(vs);
vnc_client_cache_auth(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED);
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)
{
char VAR_3[1024];
VncShareMode mode;
int VAR_4;
mode = VAR_1[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;
switch (VAR_0->vd->share_policy) {
case VNC_SHARE_POLICY_IGNORE:
break;
case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
VncState *client;
QTAILQ_FOREACH(client, &VAR_0->vd->clients, next) {
if (VAR_0 == client) {
continue;
}
if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&
client->share_mode != VNC_SHARE_MODE_SHARED) {
continue;
}
vnc_disconnect_start(client);
}
}
if (mode == VNC_SHARE_MODE_SHARED) {
if (VAR_0->vd->num_exclusive > 0) {
vnc_disconnect_start(VAR_0);
return 0;
}
}
break;
case VNC_SHARE_POLICY_FORCE_SHARED:
if (mode == VNC_SHARE_MODE_EXCLUSIVE) {
vnc_disconnect_start(VAR_0);
return 0;
}
break;
}
vnc_set_share_mode(VAR_0, mode);
if (VAR_0->vd->num_shared > VAR_0->vd->connections_limit) {
vnc_disconnect_start(VAR_0);
return 0;
}
VAR_0->client_width = pixman_image_get_width(VAR_0->vd->server);
VAR_0->client_height = pixman_image_get_height(VAR_0->vd->server);
vnc_write_u16(VAR_0, VAR_0->client_width);
vnc_write_u16(VAR_0, VAR_0->client_height);
pixel_format_message(VAR_0);
if (qemu_name)
VAR_4 = snprintf(VAR_3, sizeof(VAR_3), "QEMU (%s)", qemu_name);
else
VAR_4 = snprintf(VAR_3, sizeof(VAR_3), "QEMU");
vnc_write_u32(VAR_0, VAR_4);
vnc_write(VAR_0, VAR_3, VAR_4);
vnc_flush(VAR_0);
vnc_client_cache_auth(VAR_0);
vnc_qmp_event(VAR_0, QAPI_EVENT_VNC_INITIALIZED);
vnc_read_when(VAR_0, protocol_client_msg, 1);
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{",
"char VAR_3[1024];",
"VncShareMode mode;",
"int VAR_4;",
"mode = VAR_1[0] ? VNC_SHARE_MODE_SHARED : VNC_SHARE_MODE_EXCLUSIVE;",
"switch (VAR_0->vd->share_policy) {",
"case VNC_SHARE_POLICY_IGNORE:\nbreak;",
"case VNC_SHARE_POLICY_ALLOW_EXCLUSIVE:\nif (mode == VNC_SHARE_MODE_EXCLUSIVE) {",
"VncState *client;",
"QTAILQ_FOREACH(client, &VAR_0->vd->clients, next) {",
"if (VAR_0 == client) {",
"continue;",
"}",
"if (client->share_mode != VNC_SHARE_MODE_EXCLUSIVE &&\nclient->share_mode != VNC_SHARE_MODE_SHARED) {",
"continue;",
"}",
"vnc_disconnect_start(client);",
"}",
"}",
"if (mode == VNC_SHARE_MODE_SHARED) {",
"if (VAR_0->vd->num_exclusive > 0) {",
"vnc_disconnect_start(VAR_0);",
"return 0;",
"}",
"}",
"break;",
"case VNC_SHARE_POLICY_FORCE_SHARED:\nif (mode == VNC_SHARE_MODE_EXCLUSIVE) {",
"vnc_disconnect_start(VAR_0);",
"return 0;",
"}",
"break;",
"}",
"vnc_set_share_mode(VAR_0, mode);",
"if (VAR_0->vd->num_shared > VAR_0->vd->connections_limit) {",
"vnc_disconnect_start(VAR_0);",
"return 0;",
"}",
"VAR_0->client_width = pixman_image_get_width(VAR_0->vd->server);",
"VAR_0->client_height = pixman_image_get_height(VAR_0->vd->server);",
"vnc_write_u16(VAR_0, VAR_0->client_width);",
"vnc_write_u16(VAR_0, VAR_0->client_height);",
"pixel_format_message(VAR_0);",
"if (qemu_name)\nVAR_4 = snprintf(VAR_3, sizeof(VAR_3), \"QEMU (%s)\", qemu_name);",
"else\nVAR_4 = snprintf(VAR_3, sizeof(VAR_3), \"QEMU\");",
"vnc_write_u32(VAR_0, VAR_4);",
"vnc_write(VAR_0, VAR_3, VAR_4);",
"vnc_flush(VAR_0);",
"vnc_client_cache_auth(VAR_0);",
"vnc_qmp_event(VAR_0, QAPI_EVENT_VNC_INITIALIZED);",
"vnc_read_when(VAR_0, protocol_client_msg, 1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
33
],
[
35,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
153,
155
],
[
157,
159
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
177
],
[
181
],
[
183
]
] |
2,764 | static void migration_completion(MigrationState *s, int current_active_state,
bool *old_vm_running,
int64_t *start_time)
{
int ret;
if (s->state == MIGRATION_STATUS_ACTIVE) {
qemu_mutex_lock_iothread();
*start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*old_vm_running = runstate_is_running();
ret = global_state_store();
if (!ret) {
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (ret >= 0) {
ret = bdrv_inactivate_all();
}
if (ret >= 0) {
qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
qemu_savevm_state_complete_precopy(s->to_dst_file, false);
}
}
qemu_mutex_unlock_iothread();
if (ret < 0) {
goto fail;
}
} else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {
trace_migration_completion_postcopy_end();
qemu_savevm_state_complete_postcopy(s->to_dst_file);
trace_migration_completion_postcopy_end_after_complete();
}
/*
* If rp was opened we must clean up the thread before
* cleaning everything else up (since if there are no failures
* it will wait for the destination to send it's status in
* a SHUT command).
* Postcopy opens rp if enabled (even if it's not avtivated)
*/
if (migrate_postcopy_ram()) {
int rp_error;
trace_migration_completion_postcopy_end_before_rp();
rp_error = await_return_path_close_on_source(s);
trace_migration_completion_postcopy_end_after_rp(rp_error);
if (rp_error) {
goto fail_invalidate;
}
}
if (qemu_file_get_error(s->to_dst_file)) {
trace_migration_completion_file_err();
goto fail_invalidate;
}
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_COMPLETED);
return;
fail_invalidate:
/* If not doing postcopy, vm_start() will be called: let's regain
* control on images.
*/
if (s->state == MIGRATION_STATUS_ACTIVE) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
fail:
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_FAILED);
}
| false | qemu | 0b827d5e7291193887d22d058bc20c12b423047c | static void migration_completion(MigrationState *s, int current_active_state,
bool *old_vm_running,
int64_t *start_time)
{
int ret;
if (s->state == MIGRATION_STATUS_ACTIVE) {
qemu_mutex_lock_iothread();
*start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*old_vm_running = runstate_is_running();
ret = global_state_store();
if (!ret) {
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (ret >= 0) {
ret = bdrv_inactivate_all();
}
if (ret >= 0) {
qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
qemu_savevm_state_complete_precopy(s->to_dst_file, false);
}
}
qemu_mutex_unlock_iothread();
if (ret < 0) {
goto fail;
}
} else if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {
trace_migration_completion_postcopy_end();
qemu_savevm_state_complete_postcopy(s->to_dst_file);
trace_migration_completion_postcopy_end_after_complete();
}
if (migrate_postcopy_ram()) {
int rp_error;
trace_migration_completion_postcopy_end_before_rp();
rp_error = await_return_path_close_on_source(s);
trace_migration_completion_postcopy_end_after_rp(rp_error);
if (rp_error) {
goto fail_invalidate;
}
}
if (qemu_file_get_error(s->to_dst_file)) {
trace_migration_completion_file_err();
goto fail_invalidate;
}
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_COMPLETED);
return;
fail_invalidate:
if (s->state == MIGRATION_STATUS_ACTIVE) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
fail:
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_FAILED);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MigrationState *VAR_0, int VAR_1,
bool *VAR_2,
int64_t *VAR_3)
{
int VAR_4;
if (VAR_0->state == MIGRATION_STATUS_ACTIVE) {
qemu_mutex_lock_iothread();
*VAR_3 = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
*VAR_2 = runstate_is_running();
VAR_4 = global_state_store();
if (!VAR_4) {
VAR_4 = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
if (VAR_4 >= 0) {
VAR_4 = bdrv_inactivate_all();
}
if (VAR_4 >= 0) {
qemu_file_set_rate_limit(VAR_0->to_dst_file, INT64_MAX);
qemu_savevm_state_complete_precopy(VAR_0->to_dst_file, false);
}
}
qemu_mutex_unlock_iothread();
if (VAR_4 < 0) {
goto fail;
}
} else if (VAR_0->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {
trace_migration_completion_postcopy_end();
qemu_savevm_state_complete_postcopy(VAR_0->to_dst_file);
trace_migration_completion_postcopy_end_after_complete();
}
if (migrate_postcopy_ram()) {
int VAR_5;
trace_migration_completion_postcopy_end_before_rp();
VAR_5 = await_return_path_close_on_source(VAR_0);
trace_migration_completion_postcopy_end_after_rp(VAR_5);
if (VAR_5) {
goto fail_invalidate;
}
}
if (qemu_file_get_error(VAR_0->to_dst_file)) {
trace_migration_completion_file_err();
goto fail_invalidate;
}
migrate_set_state(&VAR_0->state, VAR_1,
MIGRATION_STATUS_COMPLETED);
return;
fail_invalidate:
if (VAR_0->state == MIGRATION_STATUS_ACTIVE) {
Error *local_err = NULL;
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
}
}
fail:
migrate_set_state(&VAR_0->state, VAR_1,
MIGRATION_STATUS_FAILED);
}
| [
"static void FUNC_0(MigrationState *VAR_0, int VAR_1,\nbool *VAR_2,\nint64_t *VAR_3)\n{",
"int VAR_4;",
"if (VAR_0->state == MIGRATION_STATUS_ACTIVE) {",
"qemu_mutex_lock_iothread();",
"*VAR_3 = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);",
"qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);",
"*VAR_2 = runstate_is_running();",
"VAR_4 = global_state_store();",
"if (!VAR_4) {",
"VAR_4 = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);",
"if (VAR_4 >= 0) {",
"VAR_4 = bdrv_inactivate_all();",
"}",
"if (VAR_4 >= 0) {",
"qemu_file_set_rate_limit(VAR_0->to_dst_file, INT64_MAX);",
"qemu_savevm_state_complete_precopy(VAR_0->to_dst_file, false);",
"}",
"}",
"qemu_mutex_unlock_iothread();",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"} else if (VAR_0->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {",
"trace_migration_completion_postcopy_end();",
"qemu_savevm_state_complete_postcopy(VAR_0->to_dst_file);",
"trace_migration_completion_postcopy_end_after_complete();",
"}",
"if (migrate_postcopy_ram()) {",
"int VAR_5;",
"trace_migration_completion_postcopy_end_before_rp();",
"VAR_5 = await_return_path_close_on_source(VAR_0);",
"trace_migration_completion_postcopy_end_after_rp(VAR_5);",
"if (VAR_5) {",
"goto fail_invalidate;",
"}",
"}",
"if (qemu_file_get_error(VAR_0->to_dst_file)) {",
"trace_migration_completion_file_err();",
"goto fail_invalidate;",
"}",
"migrate_set_state(&VAR_0->state, VAR_1,\nMIGRATION_STATUS_COMPLETED);",
"return;",
"fail_invalidate:\nif (VAR_0->state == MIGRATION_STATUS_ACTIVE) {",
"Error *local_err = NULL;",
"bdrv_invalidate_cache_all(&local_err);",
"if (local_err) {",
"error_report_err(local_err);",
"}",
"}",
"fail:\nmigrate_set_state(&VAR_0->state, VAR_1,\nMIGRATION_STATUS_FAILED);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119
],
[
123,
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149,
151,
153
],
[
155
]
] |
2,765 | void replay_read_next_clock(ReplayClockKind kind)
{
unsigned int read_kind = replay_data_kind - EVENT_CLOCK;
assert(read_kind == kind);
int64_t clock = replay_get_qword();
replay_check_error();
replay_finish_event();
replay_state.cached_clock[read_kind] = clock;
}
| false | qemu | f186d64d8fda4bb22c15beb8e45b7814fbd8b51e | void replay_read_next_clock(ReplayClockKind kind)
{
unsigned int read_kind = replay_data_kind - EVENT_CLOCK;
assert(read_kind == kind);
int64_t clock = replay_get_qword();
replay_check_error();
replay_finish_event();
replay_state.cached_clock[read_kind] = clock;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ReplayClockKind VAR_0)
{
unsigned int VAR_1 = replay_data_kind - EVENT_CLOCK;
assert(VAR_1 == VAR_0);
int64_t clock = replay_get_qword();
replay_check_error();
replay_finish_event();
replay_state.cached_clock[VAR_1] = clock;
}
| [
"void FUNC_0(ReplayClockKind VAR_0)\n{",
"unsigned int VAR_1 = replay_data_kind - EVENT_CLOCK;",
"assert(VAR_1 == VAR_0);",
"int64_t clock = replay_get_qword();",
"replay_check_error();",
"replay_finish_event();",
"replay_state.cached_clock[VAR_1] = clock;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
]
] |
2,766 | static void exynos4210_gfrc_event(void *opaque)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)opaque;
int i;
uint64_t distance;
DPRINTF("\n");
s->g_timer.reg.cnt += s->g_timer.count;
/* Process all comparators */
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if (s->g_timer.reg.cnt == s->g_timer.reg.comp[i]) {
/* reached nearest comparator */
s->g_timer.reg.int_cstat |= G_INT_CSTAT_COMP(i);
/* Auto increment */
if (s->g_timer.reg.tcon & G_TCON_AUTO_ICREMENT(i)) {
s->g_timer.reg.comp[i] += s->g_timer.reg.comp_add_incr[i];
}
/* IRQ */
exynos4210_gcomp_raise_irq(&s->g_timer, i);
}
}
/* Reload FRC to reach nearest comparator */
s->g_timer.curr_comp = exynos4210_gcomp_find(s);
distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);
if (distance > MCT_GT_COUNTER_STEP) {
distance = MCT_GT_COUNTER_STEP;
}
exynos4210_gfrc_set_count(&s->g_timer, distance);
exynos4210_gfrc_start(&s->g_timer);
}
| false | qemu | 97331270e50f5858c82a0c6d146da81f5b776535 | static void exynos4210_gfrc_event(void *opaque)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)opaque;
int i;
uint64_t distance;
DPRINTF("\n");
s->g_timer.reg.cnt += s->g_timer.count;
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if (s->g_timer.reg.cnt == s->g_timer.reg.comp[i]) {
s->g_timer.reg.int_cstat |= G_INT_CSTAT_COMP(i);
if (s->g_timer.reg.tcon & G_TCON_AUTO_ICREMENT(i)) {
s->g_timer.reg.comp[i] += s->g_timer.reg.comp_add_incr[i];
}
exynos4210_gcomp_raise_irq(&s->g_timer, i);
}
}
s->g_timer.curr_comp = exynos4210_gcomp_find(s);
distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);
if (distance > MCT_GT_COUNTER_STEP) {
distance = MCT_GT_COUNTER_STEP;
}
exynos4210_gfrc_set_count(&s->g_timer, distance);
exynos4210_gfrc_start(&s->g_timer);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)VAR_0;
int VAR_1;
uint64_t distance;
DPRINTF("\n");
s->g_timer.reg.cnt += s->g_timer.count;
for (VAR_1 = 0; VAR_1 < MCT_GT_CMP_NUM; VAR_1++) {
if (s->g_timer.reg.cnt == s->g_timer.reg.comp[VAR_1]) {
s->g_timer.reg.int_cstat |= G_INT_CSTAT_COMP(VAR_1);
if (s->g_timer.reg.tcon & G_TCON_AUTO_ICREMENT(VAR_1)) {
s->g_timer.reg.comp[VAR_1] += s->g_timer.reg.comp_add_incr[VAR_1];
}
exynos4210_gcomp_raise_irq(&s->g_timer, VAR_1);
}
}
s->g_timer.curr_comp = exynos4210_gcomp_find(s);
distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);
if (distance > MCT_GT_COUNTER_STEP) {
distance = MCT_GT_COUNTER_STEP;
}
exynos4210_gfrc_set_count(&s->g_timer, distance);
exynos4210_gfrc_start(&s->g_timer);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"Exynos4210MCTState *s = (Exynos4210MCTState *)VAR_0;",
"int VAR_1;",
"uint64_t distance;",
"DPRINTF(\"\\n\");",
"s->g_timer.reg.cnt += s->g_timer.count;",
"for (VAR_1 = 0; VAR_1 < MCT_GT_CMP_NUM; VAR_1++) {",
"if (s->g_timer.reg.cnt == s->g_timer.reg.comp[VAR_1]) {",
"s->g_timer.reg.int_cstat |= G_INT_CSTAT_COMP(VAR_1);",
"if (s->g_timer.reg.tcon & G_TCON_AUTO_ICREMENT(VAR_1)) {",
"s->g_timer.reg.comp[VAR_1] += s->g_timer.reg.comp_add_incr[VAR_1];",
"}",
"exynos4210_gcomp_raise_irq(&s->g_timer, VAR_1);",
"}",
"}",
"s->g_timer.curr_comp = exynos4210_gcomp_find(s);",
"distance = exynos4210_gcomp_get_distance(s, s->g_timer.curr_comp);",
"if (distance > MCT_GT_COUNTER_STEP) {",
"distance = MCT_GT_COUNTER_STEP;",
"}",
"exynos4210_gfrc_set_count(&s->g_timer, distance);",
"exynos4210_gfrc_start(&s->g_timer);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
23
],
[
27
],
[
33
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
2,767 | static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
void *dma_opaque, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
qemu_irq reset;
qemu_check_nic_model(&nd_table[0], "lance");
dev = qdev_create(NULL, "lance");
dev->nd = nd;
qdev_prop_set_ptr(dev, "dma", dma_opaque);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, leaddr);
sysbus_connect_irq(s, 0, irq);
reset = qdev_get_gpio_in(dev, 0);
qdev_connect_gpio_out(dma_opaque, 0, reset);
}
| true | qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
void *dma_opaque, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
qemu_irq reset;
qemu_check_nic_model(&nd_table[0], "lance");
dev = qdev_create(NULL, "lance");
dev->nd = nd;
qdev_prop_set_ptr(dev, "dma", dma_opaque);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, leaddr);
sysbus_connect_irq(s, 0, irq);
reset = qdev_get_gpio_in(dev, 0);
qdev_connect_gpio_out(dma_opaque, 0, reset);
}
| {
"code": [
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);"
],
"line_no": [
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25,
25
]
} | static void FUNC_0(NICInfo *VAR_0, target_phys_addr_t VAR_1,
void *VAR_2, qemu_irq VAR_3)
{
DeviceState *dev;
SysBusDevice *s;
qemu_irq reset;
qemu_check_nic_model(&nd_table[0], "lance");
dev = qdev_create(NULL, "lance");
dev->VAR_0 = VAR_0;
qdev_prop_set_ptr(dev, "dma", VAR_2);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, VAR_1);
sysbus_connect_irq(s, 0, VAR_3);
reset = qdev_get_gpio_in(dev, 0);
qdev_connect_gpio_out(VAR_2, 0, reset);
}
| [
"static void FUNC_0(NICInfo *VAR_0, target_phys_addr_t VAR_1,\nvoid *VAR_2, qemu_irq VAR_3)\n{",
"DeviceState *dev;",
"SysBusDevice *s;",
"qemu_irq reset;",
"qemu_check_nic_model(&nd_table[0], \"lance\");",
"dev = qdev_create(NULL, \"lance\");",
"dev->VAR_0 = VAR_0;",
"qdev_prop_set_ptr(dev, \"dma\", VAR_2);",
"qdev_init(dev);",
"s = sysbus_from_qdev(dev);",
"sysbus_mmio_map(s, 0, VAR_1);",
"sysbus_connect_irq(s, 0, VAR_3);",
"reset = qdev_get_gpio_in(dev, 0);",
"qdev_connect_gpio_out(VAR_2, 0, reset);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
2,768 | int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
{
int ret;
av_assert0(!dst->f.buf[0]);
av_assert0(src->f.buf[0]);
src->tf.f = &src->f;
dst->tf.f = &dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
ret = update_picture_tables(dst, src);
if (ret < 0)
goto fail;
if (src->hwaccel_picture_private) {
dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
if (!dst->hwaccel_priv_buf)
goto fail;
dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
}
dst->field_picture = src->field_picture;
dst->mb_var_sum = src->mb_var_sum;
dst->mc_mb_var_sum = src->mc_mb_var_sum;
dst->b_frame_score = src->b_frame_score;
dst->needs_realloc = src->needs_realloc;
dst->reference = src->reference;
dst->shared = src->shared;
return 0;
fail:
ff_mpeg_unref_picture(s, dst);
return ret;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src)
{
int ret;
av_assert0(!dst->f.buf[0]);
av_assert0(src->f.buf[0]);
src->tf.f = &src->f;
dst->tf.f = &dst->f;
ret = ff_thread_ref_frame(&dst->tf, &src->tf);
if (ret < 0)
goto fail;
ret = update_picture_tables(dst, src);
if (ret < 0)
goto fail;
if (src->hwaccel_picture_private) {
dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
if (!dst->hwaccel_priv_buf)
goto fail;
dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
}
dst->field_picture = src->field_picture;
dst->mb_var_sum = src->mb_var_sum;
dst->mc_mb_var_sum = src->mc_mb_var_sum;
dst->b_frame_score = src->b_frame_score;
dst->needs_realloc = src->needs_realloc;
dst->reference = src->reference;
dst->shared = src->shared;
return 0;
fail:
ff_mpeg_unref_picture(s, dst);
return ret;
}
| {
"code": [
" av_assert0(!dst->f.buf[0]);",
" av_assert0(src->f.buf[0]);",
" src->tf.f = &src->f;",
" dst->tf.f = &dst->f;"
],
"line_no": [
9,
11,
15,
17
]
} | int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1, Picture *VAR_2)
{
int VAR_3;
av_assert0(!VAR_1->f.buf[0]);
av_assert0(VAR_2->f.buf[0]);
VAR_2->tf.f = &VAR_2->f;
VAR_1->tf.f = &VAR_1->f;
VAR_3 = ff_thread_ref_frame(&VAR_1->tf, &VAR_2->tf);
if (VAR_3 < 0)
goto fail;
VAR_3 = update_picture_tables(VAR_1, VAR_2);
if (VAR_3 < 0)
goto fail;
if (VAR_2->hwaccel_picture_private) {
VAR_1->hwaccel_priv_buf = av_buffer_ref(VAR_2->hwaccel_priv_buf);
if (!VAR_1->hwaccel_priv_buf)
goto fail;
VAR_1->hwaccel_picture_private = VAR_1->hwaccel_priv_buf->data;
}
VAR_1->field_picture = VAR_2->field_picture;
VAR_1->mb_var_sum = VAR_2->mb_var_sum;
VAR_1->mc_mb_var_sum = VAR_2->mc_mb_var_sum;
VAR_1->b_frame_score = VAR_2->b_frame_score;
VAR_1->needs_realloc = VAR_2->needs_realloc;
VAR_1->reference = VAR_2->reference;
VAR_1->shared = VAR_2->shared;
return 0;
fail:
ff_mpeg_unref_picture(VAR_0, VAR_1);
return VAR_3;
}
| [
"int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1, Picture *VAR_2)\n{",
"int VAR_3;",
"av_assert0(!VAR_1->f.buf[0]);",
"av_assert0(VAR_2->f.buf[0]);",
"VAR_2->tf.f = &VAR_2->f;",
"VAR_1->tf.f = &VAR_1->f;",
"VAR_3 = ff_thread_ref_frame(&VAR_1->tf, &VAR_2->tf);",
"if (VAR_3 < 0)\ngoto fail;",
"VAR_3 = update_picture_tables(VAR_1, VAR_2);",
"if (VAR_3 < 0)\ngoto fail;",
"if (VAR_2->hwaccel_picture_private) {",
"VAR_1->hwaccel_priv_buf = av_buffer_ref(VAR_2->hwaccel_priv_buf);",
"if (!VAR_1->hwaccel_priv_buf)\ngoto fail;",
"VAR_1->hwaccel_picture_private = VAR_1->hwaccel_priv_buf->data;",
"}",
"VAR_1->field_picture = VAR_2->field_picture;",
"VAR_1->mb_var_sum = VAR_2->mb_var_sum;",
"VAR_1->mc_mb_var_sum = VAR_2->mc_mb_var_sum;",
"VAR_1->b_frame_score = VAR_2->b_frame_score;",
"VAR_1->needs_realloc = VAR_2->needs_realloc;",
"VAR_1->reference = VAR_2->reference;",
"VAR_1->shared = VAR_2->shared;",
"return 0;",
"fail:\nff_mpeg_unref_picture(VAR_0, VAR_1);",
"return VAR_3;",
"}"
] | [
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71
],
[
73
]
] |
2,769 | static int encode_slices(VC2EncContext *s)
{
uint8_t *buf;
int i, slice_x, slice_y, skip = 0;
int bytes_left = 0;
SliceArgs *enc_args = s->slice_args;
int bytes_top[SLICE_REDIST_TOTAL] = {0};
SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};
avpriv_align_put_bits(&s->pb);
flush_put_bits(&s->pb);
buf = put_bits_ptr(&s->pb);
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
bytes_left += args->bytes_left;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
if (args->bytes > bytes_top[i]) {
bytes_top[i] = args->bytes;
top_loc[i] = args;
break;
}
}
}
}
while (1) {
int distributed = 0;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
SliceArgs *args;
int bits, bytes, diff, prev_bytes, new_idx;
if (bytes_left <= 0)
break;
if (!top_loc[i] || !top_loc[i]->quant_idx)
break;
args = top_loc[i];
prev_bytes = args->bytes;
new_idx = av_clip(args->quant_idx - 1, 0, s->q_ceil);
bits = count_hq_slice(s, args->cache, args->x, args->y, new_idx);
bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
diff = bytes - prev_bytes;
if ((bytes_left - diff) >= 0) {
args->quant_idx = new_idx;
args->bytes = bytes;
bytes_left -= diff;
distributed++;
}
}
if (!distributed)
break;
}
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
init_put_bits(&args->pb, buf + skip, args->bytes);
s->q_avg = (s->q_avg + args->quant_idx)/2;
skip += args->bytes;
}
}
s->avctx->execute(s->avctx, encode_hq_slice, enc_args, NULL, s->num_x*s->num_y,
sizeof(SliceArgs));
skip_put_bytes(&s->pb, skip);
return 0;
}
| true | FFmpeg | b88be742fac7a77a8095e8155ba8790db4b77568 | static int encode_slices(VC2EncContext *s)
{
uint8_t *buf;
int i, slice_x, slice_y, skip = 0;
int bytes_left = 0;
SliceArgs *enc_args = s->slice_args;
int bytes_top[SLICE_REDIST_TOTAL] = {0};
SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};
avpriv_align_put_bits(&s->pb);
flush_put_bits(&s->pb);
buf = put_bits_ptr(&s->pb);
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
bytes_left += args->bytes_left;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
if (args->bytes > bytes_top[i]) {
bytes_top[i] = args->bytes;
top_loc[i] = args;
break;
}
}
}
}
while (1) {
int distributed = 0;
for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {
SliceArgs *args;
int bits, bytes, diff, prev_bytes, new_idx;
if (bytes_left <= 0)
break;
if (!top_loc[i] || !top_loc[i]->quant_idx)
break;
args = top_loc[i];
prev_bytes = args->bytes;
new_idx = av_clip(args->quant_idx - 1, 0, s->q_ceil);
bits = count_hq_slice(s, args->cache, args->x, args->y, new_idx);
bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
diff = bytes - prev_bytes;
if ((bytes_left - diff) >= 0) {
args->quant_idx = new_idx;
args->bytes = bytes;
bytes_left -= diff;
distributed++;
}
}
if (!distributed)
break;
}
for (slice_y = 0; slice_y < s->num_y; slice_y++) {
for (slice_x = 0; slice_x < s->num_x; slice_x++) {
SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
init_put_bits(&args->pb, buf + skip, args->bytes);
s->q_avg = (s->q_avg + args->quant_idx)/2;
skip += args->bytes;
}
}
s->avctx->execute(s->avctx, encode_hq_slice, enc_args, NULL, s->num_x*s->num_y,
sizeof(SliceArgs));
skip_put_bytes(&s->pb, skip);
return 0;
}
| {
"code": [
" int i, slice_x, slice_y, skip = 0;",
" int bytes_left = 0;",
" int bytes_top[SLICE_REDIST_TOTAL] = {0};",
" SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};",
" bytes_left += args->bytes_left;",
" for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {",
" if (args->bytes > bytes_top[i]) {",
" bytes_top[i] = args->bytes;",
" top_loc[i] = args;",
" break;",
" while (1) {",
" int distributed = 0;",
" for (i = 0; i < FFMIN(SLICE_REDIST_TOTAL, s->num_x*s->num_y); i++) {",
" SliceArgs *args;",
" int bits, bytes, diff, prev_bytes, new_idx;",
" if (bytes_left <= 0)",
" break;",
" if (!top_loc[i] || !top_loc[i]->quant_idx)",
" break;",
" args = top_loc[i];",
" prev_bytes = args->bytes;",
" new_idx = av_clip(args->quant_idx - 1, 0, s->q_ceil);",
" bits = count_hq_slice(s, args->cache, args->x, args->y, new_idx);",
" bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;",
" diff = bytes - prev_bytes;",
" if ((bytes_left - diff) >= 0) {",
" args->quant_idx = new_idx;",
" args->bytes = bytes;",
" bytes_left -= diff;",
" distributed++;",
" if (!distributed)",
" break;",
" for (slice_y = 0; slice_y < s->num_y; slice_y++) {",
" for (slice_x = 0; slice_x < s->num_x; slice_x++) {",
" SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];",
" init_put_bits(&args->pb, buf + skip, args->bytes);",
" s->q_avg = (s->q_avg + args->quant_idx)/2;",
" for (slice_y = 0; slice_y < s->num_y; slice_y++) {",
" for (slice_x = 0; slice_x < s->num_x; slice_x++) {"
],
"line_no": [
7,
9,
15,
17,
35,
37,
39,
41,
43,
45,
57,
59,
61,
63,
65,
67,
69,
71,
69,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
101,
103,
29,
31,
33,
115,
117,
29,
31
]
} | static int FUNC_0(VC2EncContext *VAR_0)
{
uint8_t *buf;
int VAR_1, VAR_2, VAR_3, VAR_4 = 0;
int VAR_5 = 0;
SliceArgs *enc_args = VAR_0->slice_args;
int VAR_6[SLICE_REDIST_TOTAL] = {0};
SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};
avpriv_align_put_bits(&VAR_0->pb);
flush_put_bits(&VAR_0->pb);
buf = put_bits_ptr(&VAR_0->pb);
for (VAR_3 = 0; VAR_3 < VAR_0->num_y; VAR_3++) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_x; VAR_2++) {
SliceArgs *args = &enc_args[VAR_0->num_x*VAR_3 + VAR_2];
VAR_5 += args->VAR_5;
for (VAR_1 = 0; VAR_1 < FFMIN(SLICE_REDIST_TOTAL, VAR_0->num_x*VAR_0->num_y); VAR_1++) {
if (args->bytes > VAR_6[VAR_1]) {
VAR_6[VAR_1] = args->bytes;
top_loc[VAR_1] = args;
break;
}
}
}
}
while (1) {
int VAR_7 = 0;
for (VAR_1 = 0; VAR_1 < FFMIN(SLICE_REDIST_TOTAL, VAR_0->num_x*VAR_0->num_y); VAR_1++) {
SliceArgs *args;
int bits, bytes, diff, prev_bytes, new_idx;
if (VAR_5 <= 0)
break;
if (!top_loc[VAR_1] || !top_loc[VAR_1]->quant_idx)
break;
args = top_loc[VAR_1];
prev_bytes = args->bytes;
new_idx = av_clip(args->quant_idx - 1, 0, VAR_0->q_ceil);
bits = count_hq_slice(VAR_0, args->cache, args->x, args->y, new_idx);
bytes = FFALIGN((bits >> 3), VAR_0->size_scaler) + 4 + VAR_0->prefix_bytes;
diff = bytes - prev_bytes;
if ((VAR_5 - diff) >= 0) {
args->quant_idx = new_idx;
args->bytes = bytes;
VAR_5 -= diff;
VAR_7++;
}
}
if (!VAR_7)
break;
}
for (VAR_3 = 0; VAR_3 < VAR_0->num_y; VAR_3++) {
for (VAR_2 = 0; VAR_2 < VAR_0->num_x; VAR_2++) {
SliceArgs *args = &enc_args[VAR_0->num_x*VAR_3 + VAR_2];
init_put_bits(&args->pb, buf + VAR_4, args->bytes);
VAR_0->q_avg = (VAR_0->q_avg + args->quant_idx)/2;
VAR_4 += args->bytes;
}
}
VAR_0->avctx->execute(VAR_0->avctx, encode_hq_slice, enc_args, NULL, VAR_0->num_x*VAR_0->num_y,
sizeof(SliceArgs));
skip_put_bytes(&VAR_0->pb, VAR_4);
return 0;
}
| [
"static int FUNC_0(VC2EncContext *VAR_0)\n{",
"uint8_t *buf;",
"int VAR_1, VAR_2, VAR_3, VAR_4 = 0;",
"int VAR_5 = 0;",
"SliceArgs *enc_args = VAR_0->slice_args;",
"int VAR_6[SLICE_REDIST_TOTAL] = {0};",
"SliceArgs *top_loc[SLICE_REDIST_TOTAL] = {NULL};",
"avpriv_align_put_bits(&VAR_0->pb);",
"flush_put_bits(&VAR_0->pb);",
"buf = put_bits_ptr(&VAR_0->pb);",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_y; VAR_3++) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_x; VAR_2++) {",
"SliceArgs *args = &enc_args[VAR_0->num_x*VAR_3 + VAR_2];",
"VAR_5 += args->VAR_5;",
"for (VAR_1 = 0; VAR_1 < FFMIN(SLICE_REDIST_TOTAL, VAR_0->num_x*VAR_0->num_y); VAR_1++) {",
"if (args->bytes > VAR_6[VAR_1]) {",
"VAR_6[VAR_1] = args->bytes;",
"top_loc[VAR_1] = args;",
"break;",
"}",
"}",
"}",
"}",
"while (1) {",
"int VAR_7 = 0;",
"for (VAR_1 = 0; VAR_1 < FFMIN(SLICE_REDIST_TOTAL, VAR_0->num_x*VAR_0->num_y); VAR_1++) {",
"SliceArgs *args;",
"int bits, bytes, diff, prev_bytes, new_idx;",
"if (VAR_5 <= 0)\nbreak;",
"if (!top_loc[VAR_1] || !top_loc[VAR_1]->quant_idx)\nbreak;",
"args = top_loc[VAR_1];",
"prev_bytes = args->bytes;",
"new_idx = av_clip(args->quant_idx - 1, 0, VAR_0->q_ceil);",
"bits = count_hq_slice(VAR_0, args->cache, args->x, args->y, new_idx);",
"bytes = FFALIGN((bits >> 3), VAR_0->size_scaler) + 4 + VAR_0->prefix_bytes;",
"diff = bytes - prev_bytes;",
"if ((VAR_5 - diff) >= 0) {",
"args->quant_idx = new_idx;",
"args->bytes = bytes;",
"VAR_5 -= diff;",
"VAR_7++;",
"}",
"}",
"if (!VAR_7)\nbreak;",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_0->num_y; VAR_3++) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->num_x; VAR_2++) {",
"SliceArgs *args = &enc_args[VAR_0->num_x*VAR_3 + VAR_2];",
"init_put_bits(&args->pb, buf + VAR_4, args->bytes);",
"VAR_0->q_avg = (VAR_0->q_avg + args->quant_idx)/2;",
"VAR_4 += args->bytes;",
"}",
"}",
"VAR_0->avctx->execute(VAR_0->avctx, encode_hq_slice, enc_args, NULL, VAR_0->num_x*VAR_0->num_y,\nsizeof(SliceArgs));",
"skip_put_bytes(&VAR_0->pb, VAR_4);",
"return 0;",
"}"
] | [
0,
0,
1,
1,
0,
1,
1,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
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
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
133
],
[
137
],
[
139
]
] |
2,770 | int64_t parse_time_or_die(const char *context, const char *timestr,
int is_duration)
{
int64_t us;
if (av_parse_time(&us, timestr, is_duration) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit(1);
}
return us;
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb | int64_t parse_time_or_die(const char *context, const char *timestr,
int is_duration)
{
int64_t us;
if (av_parse_time(&us, timestr, is_duration) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit(1);
}
return us;
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15
]
} | int64_t FUNC_0(const char *context, const char *timestr,
int is_duration)
{
int64_t us;
if (av_parse_time(&us, timestr, is_duration) < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
is_duration ? "duration" : "date", context, timestr);
exit(1);
}
return us;
}
| [
"int64_t FUNC_0(const char *context, const char *timestr,\nint is_duration)\n{",
"int64_t us;",
"if (av_parse_time(&us, timestr, is_duration) < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid %s specification for %s: %s\\n\",\nis_duration ? \"duration\" : \"date\", context, timestr);",
"exit(1);",
"}",
"return us;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
2,771 | PPC_OP(mulhw)
{
T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(mulhw)
{
T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;
RETURN();
}
| {
"code": [
" RETURN();",
"PPC_OP(mulhw)",
" T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;",
" RETURN();"
],
"line_no": [
7,
1,
5,
7
]
} | FUNC_0(VAR_0)
{
T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"T0 = ((int64_t)Ts0 * (int64_t)Ts1) >> 32;",
"RETURN();",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
2,772 | static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
cs->halted = 1;
qemu_cpu_kick(cs);
/*
* While stopping a CPU, the guest calls H_CPPR which
* effectively disables interrupts on XICS level.
* However decrementer interrupts in TCG can still
* wake the CPU up so here we disable interrupts in MSR
* as well.
* As rtas_start_cpu() resets the whole MSR anyway, there is
* no need to bother with specific bits, we just clear it.
*/
env->msr = 0;
/* Disable Power-saving mode Exit Cause exceptions for the CPU.
* This could deliver an interrupt on a dying CPU and crash the
* guest */
env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;
} | true | qemu | 9a94ee5bb15793ef69692998ef57794a33074134 | static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
cs->halted = 1;
qemu_cpu_kick(cs);
env->msr = 0;
env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(PowerPCCPU *VAR_0, sPAPRMachineState *VAR_1,
uint32_t VAR_2, uint32_t VAR_3,
target_ulong VAR_4,
uint32_t VAR_5, target_ulong VAR_6)
{
CPUState *cs = CPU(VAR_0);
CPUPPCState *env = &VAR_0->env;
cs->halted = 1;
qemu_cpu_kick(cs);
env->msr = 0;
env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;
} | [
"static void FUNC_0(PowerPCCPU *VAR_0, sPAPRMachineState *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3,\ntarget_ulong VAR_4,\nuint32_t VAR_5, target_ulong VAR_6)\n{",
"CPUState *cs = CPU(VAR_0);",
"CPUPPCState *env = &VAR_0->env;",
"cs->halted = 1;",
"qemu_cpu_kick(cs);",
"env->msr = 0;",
"env->spr[SPR_LPCR] &= ~pcc->lpcr_pm;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
18
],
[
20
],
[
40
],
[
50
],
[
52
]
] |
2,773 | static int get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int allocate,
int compressed_size,
int n_start, int n_end, uint64_t *result)
{
BDRVQcowState *s = bs->opaque;
int min_index, i, j, l1_index, l2_index, ret;
uint64_t l2_offset, *l2_table, cluster_offset, tmp;
uint32_t min_count;
int new_l2_table;
*result = 0;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
l2_offset = s->l1_table[l1_index];
new_l2_table = 0;
if (!l2_offset) {
if (!allocate)
return 0;
/* allocate a new l2 entry */
l2_offset = bdrv_getlength(bs->file->bs);
/* round to cluster size */
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
/* update the L1 entry */
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
ret = bdrv_pwrite_sync(bs->file,
s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
new_l2_table = 1;
}
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == s->l2_cache_offsets[i]) {
/* increment the hit count */
if (++s->l2_cache_counts[i] == 0xffffffff) {
for(j = 0; j < L2_CACHE_SIZE; j++) {
s->l2_cache_counts[j] >>= 1;
}
}
l2_table = s->l2_cache + (i << s->l2_bits);
goto found;
}
}
/* not found: load a new entry in the least used one */
min_index = 0;
min_count = 0xffffffff;
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (s->l2_cache_counts[i] < min_count) {
min_count = s->l2_cache_counts[i];
min_index = i;
}
}
l2_table = s->l2_cache + (min_index << s->l2_bits);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
ret = bdrv_pwrite_sync(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
} else {
ret = bdrv_pread(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
found:
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
if (!cluster_offset ||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
if (!allocate)
return 0;
/* allocate a new cluster */
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
(n_end - n_start) < s->cluster_sectors) {
/* if the cluster is already compressed, we must
decompress it in the case it is not completely
overwritten */
if (decompress_cluster(bs, cluster_offset) < 0) {
return -EIO;
}
cluster_offset = bdrv_getlength(bs->file->bs);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
/* write the cluster content */
ret = bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache,
s->cluster_size);
if (ret < 0) {
return ret;
}
} else {
cluster_offset = bdrv_getlength(bs->file->bs);
if (allocate == 1) {
/* round to cluster size */
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
bdrv_truncate(bs->file, cluster_offset + s->cluster_size,
PREALLOC_MODE_OFF, NULL);
/* if encrypted, we must initialize the cluster
content which won't be written */
if (bs->encrypted &&
(n_end - n_start) < s->cluster_sectors) {
uint64_t start_sect;
assert(s->crypto);
start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
for(i = 0; i < s->cluster_sectors; i++) {
if (i < n_start || i >= n_end) {
memset(s->cluster_data, 0x00, 512);
if (qcrypto_block_encrypt(s->crypto, start_sect + i,
s->cluster_data,
BDRV_SECTOR_SIZE,
NULL) < 0) {
return -EIO;
}
ret = bdrv_pwrite(bs->file,
cluster_offset + i * 512,
s->cluster_data, 512);
if (ret < 0) {
return ret;
}
}
}
}
} else if (allocate == 2) {
cluster_offset |= QCOW_OFLAG_COMPRESSED |
(uint64_t)compressed_size << (63 - s->cluster_bits);
}
}
/* update L2 table */
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
ret = bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
}
*result = cluster_offset;
return 1;
}
| true | qemu | d7a753a148d4738eef95a3b193b081a9c905399f | static int get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int allocate,
int compressed_size,
int n_start, int n_end, uint64_t *result)
{
BDRVQcowState *s = bs->opaque;
int min_index, i, j, l1_index, l2_index, ret;
uint64_t l2_offset, *l2_table, cluster_offset, tmp;
uint32_t min_count;
int new_l2_table;
*result = 0;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
l2_offset = s->l1_table[l1_index];
new_l2_table = 0;
if (!l2_offset) {
if (!allocate)
return 0;
l2_offset = bdrv_getlength(bs->file->bs);
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
ret = bdrv_pwrite_sync(bs->file,
s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
new_l2_table = 1;
}
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == s->l2_cache_offsets[i]) {
if (++s->l2_cache_counts[i] == 0xffffffff) {
for(j = 0; j < L2_CACHE_SIZE; j++) {
s->l2_cache_counts[j] >>= 1;
}
}
l2_table = s->l2_cache + (i << s->l2_bits);
goto found;
}
}
min_index = 0;
min_count = 0xffffffff;
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (s->l2_cache_counts[i] < min_count) {
min_count = s->l2_cache_counts[i];
min_index = i;
}
}
l2_table = s->l2_cache + (min_index << s->l2_bits);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
ret = bdrv_pwrite_sync(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
} else {
ret = bdrv_pread(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
found:
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
if (!cluster_offset ||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
if (!allocate)
return 0;
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
(n_end - n_start) < s->cluster_sectors) {
if (decompress_cluster(bs, cluster_offset) < 0) {
return -EIO;
}
cluster_offset = bdrv_getlength(bs->file->bs);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
ret = bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache,
s->cluster_size);
if (ret < 0) {
return ret;
}
} else {
cluster_offset = bdrv_getlength(bs->file->bs);
if (allocate == 1) {
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
bdrv_truncate(bs->file, cluster_offset + s->cluster_size,
PREALLOC_MODE_OFF, NULL);
if (bs->encrypted &&
(n_end - n_start) < s->cluster_sectors) {
uint64_t start_sect;
assert(s->crypto);
start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
for(i = 0; i < s->cluster_sectors; i++) {
if (i < n_start || i >= n_end) {
memset(s->cluster_data, 0x00, 512);
if (qcrypto_block_encrypt(s->crypto, start_sect + i,
s->cluster_data,
BDRV_SECTOR_SIZE,
NULL) < 0) {
return -EIO;
}
ret = bdrv_pwrite(bs->file,
cluster_offset + i * 512,
s->cluster_data, 512);
if (ret < 0) {
return ret;
}
}
}
}
} else if (allocate == 2) {
cluster_offset |= QCOW_OFLAG_COMPRESSED |
(uint64_t)compressed_size << (63 - s->cluster_bits);
}
}
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
ret = bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
}
*result = cluster_offset;
return 1;
}
| {
"code": [
" uint64_t l2_offset, *l2_table, cluster_offset, tmp;",
" l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);",
" cluster_offset = (cluster_offset + s->cluster_size - 1) &",
" ~(s->cluster_size - 1);",
" cluster_offset = (cluster_offset + s->cluster_size - 1) &",
" ~(s->cluster_size - 1);",
" bdrv_truncate(bs->file, cluster_offset + s->cluster_size,",
" PREALLOC_MODE_OFF, NULL);"
],
"line_no": [
15,
43,
177,
179,
201,
203,
205,
207
]
} | static int FUNC_0(BlockDriverState *VAR_0,
uint64_t VAR_1, int VAR_2,
int VAR_3,
int VAR_4, int VAR_5, uint64_t *VAR_6)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
uint64_t l2_offset, *l2_table, cluster_offset, tmp;
uint32_t min_count;
int VAR_13;
*VAR_6 = 0;
VAR_10 = VAR_1 >> (s->l2_bits + s->cluster_bits);
l2_offset = s->l1_table[VAR_10];
VAR_13 = 0;
if (!l2_offset) {
if (!VAR_2)
return 0;
l2_offset = bdrv_getlength(VAR_0->file->VAR_0);
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
s->l1_table[VAR_10] = l2_offset;
tmp = cpu_to_be64(l2_offset);
VAR_12 = bdrv_pwrite_sync(VAR_0->file,
s->l1_table_offset + VAR_10 * sizeof(tmp),
&tmp, sizeof(tmp));
if (VAR_12 < 0) {
return VAR_12;
}
VAR_13 = 1;
}
for(VAR_8 = 0; VAR_8 < L2_CACHE_SIZE; VAR_8++) {
if (l2_offset == s->l2_cache_offsets[VAR_8]) {
if (++s->l2_cache_counts[VAR_8] == 0xffffffff) {
for(VAR_9 = 0; VAR_9 < L2_CACHE_SIZE; VAR_9++) {
s->l2_cache_counts[VAR_9] >>= 1;
}
}
l2_table = s->l2_cache + (VAR_8 << s->l2_bits);
goto found;
}
}
VAR_7 = 0;
min_count = 0xffffffff;
for(VAR_8 = 0; VAR_8 < L2_CACHE_SIZE; VAR_8++) {
if (s->l2_cache_counts[VAR_8] < min_count) {
min_count = s->l2_cache_counts[VAR_8];
VAR_7 = VAR_8;
}
}
l2_table = s->l2_cache + (VAR_7 << s->l2_bits);
if (VAR_13) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
VAR_12 = bdrv_pwrite_sync(VAR_0->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (VAR_12 < 0) {
return VAR_12;
}
} else {
VAR_12 = bdrv_pread(VAR_0->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (VAR_12 < 0) {
return VAR_12;
}
}
s->l2_cache_offsets[VAR_7] = l2_offset;
s->l2_cache_counts[VAR_7] = 1;
found:
VAR_11 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[VAR_11]);
if (!cluster_offset ||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && VAR_2 == 1)) {
if (!VAR_2)
return 0;
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
(VAR_5 - VAR_4) < s->cluster_sectors) {
if (decompress_cluster(VAR_0, cluster_offset) < 0) {
return -EIO;
}
cluster_offset = bdrv_getlength(VAR_0->file->VAR_0);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
VAR_12 = bdrv_pwrite(VAR_0->file, cluster_offset, s->cluster_cache,
s->cluster_size);
if (VAR_12 < 0) {
return VAR_12;
}
} else {
cluster_offset = bdrv_getlength(VAR_0->file->VAR_0);
if (VAR_2 == 1) {
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
bdrv_truncate(VAR_0->file, cluster_offset + s->cluster_size,
PREALLOC_MODE_OFF, NULL);
if (VAR_0->encrypted &&
(VAR_5 - VAR_4) < s->cluster_sectors) {
uint64_t start_sect;
assert(s->crypto);
start_sect = (VAR_1 & ~(s->cluster_size - 1)) >> 9;
for(VAR_8 = 0; VAR_8 < s->cluster_sectors; VAR_8++) {
if (VAR_8 < VAR_4 || VAR_8 >= VAR_5) {
memset(s->cluster_data, 0x00, 512);
if (qcrypto_block_encrypt(s->crypto, start_sect + VAR_8,
s->cluster_data,
BDRV_SECTOR_SIZE,
NULL) < 0) {
return -EIO;
}
VAR_12 = bdrv_pwrite(VAR_0->file,
cluster_offset + VAR_8 * 512,
s->cluster_data, 512);
if (VAR_12 < 0) {
return VAR_12;
}
}
}
}
} else if (VAR_2 == 2) {
cluster_offset |= QCOW_OFLAG_COMPRESSED |
(uint64_t)VAR_3 << (63 - s->cluster_bits);
}
}
tmp = cpu_to_be64(cluster_offset);
l2_table[VAR_11] = tmp;
VAR_12 = bdrv_pwrite_sync(VAR_0->file, l2_offset + VAR_11 * sizeof(tmp),
&tmp, sizeof(tmp));
if (VAR_12 < 0) {
return VAR_12;
}
}
*VAR_6 = cluster_offset;
return 1;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nuint64_t VAR_1, int VAR_2,\nint VAR_3,\nint VAR_4, int VAR_5, uint64_t *VAR_6)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"uint64_t l2_offset, *l2_table, cluster_offset, tmp;",
"uint32_t min_count;",
"int VAR_13;",
"*VAR_6 = 0;",
"VAR_10 = VAR_1 >> (s->l2_bits + s->cluster_bits);",
"l2_offset = s->l1_table[VAR_10];",
"VAR_13 = 0;",
"if (!l2_offset) {",
"if (!VAR_2)\nreturn 0;",
"l2_offset = bdrv_getlength(VAR_0->file->VAR_0);",
"l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);",
"s->l1_table[VAR_10] = l2_offset;",
"tmp = cpu_to_be64(l2_offset);",
"VAR_12 = bdrv_pwrite_sync(VAR_0->file,\ns->l1_table_offset + VAR_10 * sizeof(tmp),\n&tmp, sizeof(tmp));",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"VAR_13 = 1;",
"}",
"for(VAR_8 = 0; VAR_8 < L2_CACHE_SIZE; VAR_8++) {",
"if (l2_offset == s->l2_cache_offsets[VAR_8]) {",
"if (++s->l2_cache_counts[VAR_8] == 0xffffffff) {",
"for(VAR_9 = 0; VAR_9 < L2_CACHE_SIZE; VAR_9++) {",
"s->l2_cache_counts[VAR_9] >>= 1;",
"}",
"}",
"l2_table = s->l2_cache + (VAR_8 << s->l2_bits);",
"goto found;",
"}",
"}",
"VAR_7 = 0;",
"min_count = 0xffffffff;",
"for(VAR_8 = 0; VAR_8 < L2_CACHE_SIZE; VAR_8++) {",
"if (s->l2_cache_counts[VAR_8] < min_count) {",
"min_count = s->l2_cache_counts[VAR_8];",
"VAR_7 = VAR_8;",
"}",
"}",
"l2_table = s->l2_cache + (VAR_7 << s->l2_bits);",
"if (VAR_13) {",
"memset(l2_table, 0, s->l2_size * sizeof(uint64_t));",
"VAR_12 = bdrv_pwrite_sync(VAR_0->file, l2_offset, l2_table,\ns->l2_size * sizeof(uint64_t));",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"} else {",
"VAR_12 = bdrv_pread(VAR_0->file, l2_offset, l2_table,\ns->l2_size * sizeof(uint64_t));",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"}",
"s->l2_cache_offsets[VAR_7] = l2_offset;",
"s->l2_cache_counts[VAR_7] = 1;",
"found:\nVAR_11 = (VAR_1 >> s->cluster_bits) & (s->l2_size - 1);",
"cluster_offset = be64_to_cpu(l2_table[VAR_11]);",
"if (!cluster_offset ||\n((cluster_offset & QCOW_OFLAG_COMPRESSED) && VAR_2 == 1)) {",
"if (!VAR_2)\nreturn 0;",
"if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&\n(VAR_5 - VAR_4) < s->cluster_sectors) {",
"if (decompress_cluster(VAR_0, cluster_offset) < 0) {",
"return -EIO;",
"}",
"cluster_offset = bdrv_getlength(VAR_0->file->VAR_0);",
"cluster_offset = (cluster_offset + s->cluster_size - 1) &\n~(s->cluster_size - 1);",
"VAR_12 = bdrv_pwrite(VAR_0->file, cluster_offset, s->cluster_cache,\ns->cluster_size);",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"} else {",
"cluster_offset = bdrv_getlength(VAR_0->file->VAR_0);",
"if (VAR_2 == 1) {",
"cluster_offset = (cluster_offset + s->cluster_size - 1) &\n~(s->cluster_size - 1);",
"bdrv_truncate(VAR_0->file, cluster_offset + s->cluster_size,\nPREALLOC_MODE_OFF, NULL);",
"if (VAR_0->encrypted &&\n(VAR_5 - VAR_4) < s->cluster_sectors) {",
"uint64_t start_sect;",
"assert(s->crypto);",
"start_sect = (VAR_1 & ~(s->cluster_size - 1)) >> 9;",
"for(VAR_8 = 0; VAR_8 < s->cluster_sectors; VAR_8++) {",
"if (VAR_8 < VAR_4 || VAR_8 >= VAR_5) {",
"memset(s->cluster_data, 0x00, 512);",
"if (qcrypto_block_encrypt(s->crypto, start_sect + VAR_8,\ns->cluster_data,\nBDRV_SECTOR_SIZE,\nNULL) < 0) {",
"return -EIO;",
"}",
"VAR_12 = bdrv_pwrite(VAR_0->file,\ncluster_offset + VAR_8 * 512,\ns->cluster_data, 512);",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"}",
"}",
"}",
"} else if (VAR_2 == 2) {",
"cluster_offset |= QCOW_OFLAG_COMPRESSED |\n(uint64_t)VAR_3 << (63 - s->cluster_bits);",
"}",
"}",
"tmp = cpu_to_be64(cluster_offset);",
"l2_table[VAR_11] = tmp;",
"VAR_12 = bdrv_pwrite_sync(VAR_0->file, l2_offset + VAR_11 * sizeof(tmp),\n&tmp, sizeof(tmp));",
"if (VAR_12 < 0) {",
"return VAR_12;",
"}",
"}",
"*VAR_6 = cluster_offset;",
"return 1;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
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,
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
159,
161
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201,
203
],
[
205,
207
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231,
233,
235
],
[
237
],
[
239
],
[
241,
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
]
] |
2,774 | int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
size= ffio_limit(s, size);
ret= av_new_packet(pkt, size);
if(ret<0)
return ret;
pkt->pos= avio_tell(s);
ret= avio_read(s, pkt->data, size);
if(ret<=0)
av_free_packet(pkt);
else
av_shrink_packet(pkt, ret);
if (pkt->size < orig_size)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
return ret;
} | true | FFmpeg | 7effbee66cf457c62f795d9b9ed3a1110b364b89 | int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
size= ffio_limit(s, size);
ret= av_new_packet(pkt, size);
if(ret<0)
return ret;
pkt->pos= avio_tell(s);
ret= avio_read(s, pkt->data, size);
if(ret<=0)
av_free_packet(pkt);
else
av_shrink_packet(pkt, ret);
if (pkt->size < orig_size)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
return ret;
} | {
"code": [],
"line_no": []
} | int FUNC_0(AVIOContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{
int VAR_3;
VAR_2= ffio_limit(VAR_0, VAR_2);
VAR_3= av_new_packet(VAR_1, VAR_2);
if(VAR_3<0)
return VAR_3;
VAR_1->pos= avio_tell(VAR_0);
VAR_3= avio_read(VAR_0, VAR_1->data, VAR_2);
if(VAR_3<=0)
av_free_packet(VAR_1);
else
av_shrink_packet(VAR_1, VAR_3);
if (VAR_1->VAR_2 < orig_size)
VAR_1->flags |= AV_PKT_FLAG_CORRUPT;
return VAR_3;
} | [
"int FUNC_0(AVIOContext *VAR_0, AVPacket *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"VAR_2= ffio_limit(VAR_0, VAR_2);",
"VAR_3= av_new_packet(VAR_1, VAR_2);",
"if(VAR_3<0)\nreturn VAR_3;",
"VAR_1->pos= avio_tell(VAR_0);",
"VAR_3= avio_read(VAR_0, VAR_1->data, VAR_2);",
"if(VAR_3<=0)\nav_free_packet(VAR_1);",
"else\nav_shrink_packet(VAR_1, VAR_3);",
"if (VAR_1->VAR_2 < orig_size)\nVAR_1->flags |= AV_PKT_FLAG_CORRUPT;",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
8
],
[
12
],
[
16,
18
],
[
22
],
[
26
],
[
28,
30
],
[
32,
34
],
[
36,
38
],
[
42
],
[
44
]
] |
2,775 | void xtensa_translate_init(void)
{
static const char * const regnames[] = {
"ar0", "ar1", "ar2", "ar3",
"ar4", "ar5", "ar6", "ar7",
"ar8", "ar9", "ar10", "ar11",
"ar12", "ar13", "ar14", "ar15",
};
static const char * const fregnames[] = {
"f0", "f1", "f2", "f3",
"f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11",
"f12", "f13", "f14", "f15",
};
int i;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, pc), "pc");
for (i = 0; i < 16; i++) {
cpu_R[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, regs[i]),
regnames[i]);
}
for (i = 0; i < 16; i++) {
cpu_FR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, fregs[i]),
fregnames[i]);
}
for (i = 0; i < 256; ++i) {
if (sregnames[i]) {
cpu_SR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, sregs[i]),
sregnames[i]);
}
}
for (i = 0; i < 256; ++i) {
if (uregnames[i]) {
cpu_UR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, uregs[i]),
uregnames[i]);
}
}
#define GEN_HELPER 2
#include "helper.h"
}
| true | qemu | fe0bd475aa31e60674f7f53b85dc293108026202 | void xtensa_translate_init(void)
{
static const char * const regnames[] = {
"ar0", "ar1", "ar2", "ar3",
"ar4", "ar5", "ar6", "ar7",
"ar8", "ar9", "ar10", "ar11",
"ar12", "ar13", "ar14", "ar15",
};
static const char * const fregnames[] = {
"f0", "f1", "f2", "f3",
"f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11",
"f12", "f13", "f14", "f15",
};
int i;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, pc), "pc");
for (i = 0; i < 16; i++) {
cpu_R[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, regs[i]),
regnames[i]);
}
for (i = 0; i < 16; i++) {
cpu_FR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, fregs[i]),
fregnames[i]);
}
for (i = 0; i < 256; ++i) {
if (sregnames[i]) {
cpu_SR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, sregs[i]),
sregnames[i]);
}
}
for (i = 0; i < 256; ++i) {
if (uregnames[i]) {
cpu_UR[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, uregs[i]),
uregnames[i]);
}
}
#define GEN_HELPER 2
#include "helper.h"
}
| {
"code": [
" if (sregnames[i]) {",
" sregnames[i]);",
" if (uregnames[i]) {",
" uregnames[i]);",
" if (sregnames[i]) {",
" if (uregnames[i]) {"
],
"line_no": [
67,
73,
83,
89,
67,
83
]
} | void FUNC_0(void)
{
static const char * const VAR_0[] = {
"ar0", "ar1", "ar2", "ar3",
"ar4", "ar5", "ar6", "ar7",
"ar8", "ar9", "ar10", "ar11",
"ar12", "ar13", "ar14", "ar15",
};
static const char * const VAR_1[] = {
"f0", "f1", "f2", "f3",
"f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11",
"f12", "f13", "f14", "f15",
};
int VAR_2;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, pc), "pc");
for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {
cpu_R[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, regs[VAR_2]),
VAR_0[VAR_2]);
}
for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {
cpu_FR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, fregs[VAR_2]),
VAR_1[VAR_2]);
}
for (VAR_2 = 0; VAR_2 < 256; ++VAR_2) {
if (sregnames[VAR_2]) {
cpu_SR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, sregs[VAR_2]),
sregnames[VAR_2]);
}
}
for (VAR_2 = 0; VAR_2 < 256; ++VAR_2) {
if (uregnames[VAR_2]) {
cpu_UR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUXtensaState, uregs[VAR_2]),
uregnames[VAR_2]);
}
}
#define GEN_HELPER 2
#include "helper.h"
}
| [
"void FUNC_0(void)\n{",
"static const char * const VAR_0[] = {",
"\"ar0\", \"ar1\", \"ar2\", \"ar3\",\n\"ar4\", \"ar5\", \"ar6\", \"ar7\",\n\"ar8\", \"ar9\", \"ar10\", \"ar11\",\n\"ar12\", \"ar13\", \"ar14\", \"ar15\",\n};",
"static const char * const VAR_1[] = {",
"\"f0\", \"f1\", \"f2\", \"f3\",\n\"f4\", \"f5\", \"f6\", \"f7\",\n\"f8\", \"f9\", \"f10\", \"f11\",\n\"f12\", \"f13\", \"f14\", \"f15\",\n};",
"int VAR_2;",
"cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, \"env\");",
"cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,\noffsetof(CPUXtensaState, pc), \"pc\");",
"for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {",
"cpu_R[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,\noffsetof(CPUXtensaState, regs[VAR_2]),\nVAR_0[VAR_2]);",
"}",
"for (VAR_2 = 0; VAR_2 < 16; VAR_2++) {",
"cpu_FR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,\noffsetof(CPUXtensaState, fregs[VAR_2]),\nVAR_1[VAR_2]);",
"}",
"for (VAR_2 = 0; VAR_2 < 256; ++VAR_2) {",
"if (sregnames[VAR_2]) {",
"cpu_SR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,\noffsetof(CPUXtensaState, sregs[VAR_2]),\nsregnames[VAR_2]);",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < 256; ++VAR_2) {",
"if (uregnames[VAR_2]) {",
"cpu_UR[VAR_2] = tcg_global_mem_new_i32(TCG_AREG0,\noffsetof(CPUXtensaState, uregs[VAR_2]),\nuregnames[VAR_2]);",
"}",
"}",
"#define GEN_HELPER 2\n#include \"helper.h\"\n}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15
],
[
17
],
[
19,
21,
23,
25,
27
],
[
29
],
[
33
],
[
35,
37
],
[
41
],
[
43,
45,
47
],
[
49
],
[
53
],
[
55,
57,
59
],
[
61
],
[
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87,
89
],
[
91
],
[
93
],
[
95,
97,
99
]
] |
2,776 | float64 HELPER(recpe_f64)(float64 input, void *fpstp)
{
float_status *fpst = fpstp;
float64 f64 = float64_squash_input_denormal(input, fpst);
uint64_t f64_val = float64_val(f64);
uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;
int64_t f64_exp = extract64(f64_val, 52, 11);
float64 r64;
uint64_t r64_val;
int64_t r64_exp;
uint64_t r64_frac;
/* Deal with any special cases */
if (float64_is_any_nan(f64)) {
float64 nan = f64;
if (float64_is_signaling_nan(f64)) {
float_raise(float_flag_invalid, fpst);
nan = float64_maybe_silence_nan(f64);
}
if (fpst->default_nan_mode) {
nan = float64_default_nan;
}
return nan;
} else if (float64_is_infinity(f64)) {
return float64_set_sign(float64_zero, float64_is_neg(f64));
} else if (float64_is_zero(f64)) {
float_raise(float_flag_divbyzero, fpst);
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {
/* Abs(value) < 2.0^-1024 */
float_raise(float_flag_overflow | float_flag_inexact, fpst);
if (round_to_inf(fpst, f64_sbit)) {
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else {
return float64_set_sign(float64_maxnorm, float64_is_neg(f64));
}
} else if (f64_exp >= 1023 && fpst->flush_to_zero) {
float_raise(float_flag_underflow, fpst);
return float64_set_sign(float64_zero, float64_is_neg(f64));
}
r64 = call_recip_estimate(f64, 2045, fpst);
r64_val = float64_val(r64);
r64_exp = extract64(r64_val, 52, 11);
r64_frac = extract64(r64_val, 0, 52);
/* result = sign : result_exp<10:0> : fraction<51:0> */
return make_float64(f64_sbit |
((r64_exp & 0x7ff) << 52) |
r64_frac);
}
| true | qemu | fc1792e9aa36227ee9994757974f9397684e1a48 | float64 HELPER(recpe_f64)(float64 input, void *fpstp)
{
float_status *fpst = fpstp;
float64 f64 = float64_squash_input_denormal(input, fpst);
uint64_t f64_val = float64_val(f64);
uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;
int64_t f64_exp = extract64(f64_val, 52, 11);
float64 r64;
uint64_t r64_val;
int64_t r64_exp;
uint64_t r64_frac;
if (float64_is_any_nan(f64)) {
float64 nan = f64;
if (float64_is_signaling_nan(f64)) {
float_raise(float_flag_invalid, fpst);
nan = float64_maybe_silence_nan(f64);
}
if (fpst->default_nan_mode) {
nan = float64_default_nan;
}
return nan;
} else if (float64_is_infinity(f64)) {
return float64_set_sign(float64_zero, float64_is_neg(f64));
} else if (float64_is_zero(f64)) {
float_raise(float_flag_divbyzero, fpst);
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {
float_raise(float_flag_overflow | float_flag_inexact, fpst);
if (round_to_inf(fpst, f64_sbit)) {
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else {
return float64_set_sign(float64_maxnorm, float64_is_neg(f64));
}
} else if (f64_exp >= 1023 && fpst->flush_to_zero) {
float_raise(float_flag_underflow, fpst);
return float64_set_sign(float64_zero, float64_is_neg(f64));
}
r64 = call_recip_estimate(f64, 2045, fpst);
r64_val = float64_val(r64);
r64_exp = extract64(r64_val, 52, 11);
r64_frac = extract64(r64_val, 0, 52);
return make_float64(f64_sbit |
((r64_exp & 0x7ff) << 52) |
r64_frac);
}
| {
"code": [
" } else if (f64_exp >= 1023 && fpst->flush_to_zero) {"
],
"line_no": [
73
]
} | float64 FUNC_0(recpe_f64)(float64 input, void *fpstp)
{
float_status *fpst = fpstp;
float64 f64 = float64_squash_input_denormal(input, fpst);
uint64_t f64_val = float64_val(f64);
uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;
int64_t f64_exp = extract64(f64_val, 52, 11);
float64 r64;
uint64_t r64_val;
int64_t r64_exp;
uint64_t r64_frac;
if (float64_is_any_nan(f64)) {
float64 nan = f64;
if (float64_is_signaling_nan(f64)) {
float_raise(float_flag_invalid, fpst);
nan = float64_maybe_silence_nan(f64);
}
if (fpst->default_nan_mode) {
nan = float64_default_nan;
}
return nan;
} else if (float64_is_infinity(f64)) {
return float64_set_sign(float64_zero, float64_is_neg(f64));
} else if (float64_is_zero(f64)) {
float_raise(float_flag_divbyzero, fpst);
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {
float_raise(float_flag_overflow | float_flag_inexact, fpst);
if (round_to_inf(fpst, f64_sbit)) {
return float64_set_sign(float64_infinity, float64_is_neg(f64));
} else {
return float64_set_sign(float64_maxnorm, float64_is_neg(f64));
}
} else if (f64_exp >= 1023 && fpst->flush_to_zero) {
float_raise(float_flag_underflow, fpst);
return float64_set_sign(float64_zero, float64_is_neg(f64));
}
r64 = call_recip_estimate(f64, 2045, fpst);
r64_val = float64_val(r64);
r64_exp = extract64(r64_val, 52, 11);
r64_frac = extract64(r64_val, 0, 52);
return make_float64(f64_sbit |
((r64_exp & 0x7ff) << 52) |
r64_frac);
}
| [
"float64 FUNC_0(recpe_f64)(float64 input, void *fpstp)\n{",
"float_status *fpst = fpstp;",
"float64 f64 = float64_squash_input_denormal(input, fpst);",
"uint64_t f64_val = float64_val(f64);",
"uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;",
"int64_t f64_exp = extract64(f64_val, 52, 11);",
"float64 r64;",
"uint64_t r64_val;",
"int64_t r64_exp;",
"uint64_t r64_frac;",
"if (float64_is_any_nan(f64)) {",
"float64 nan = f64;",
"if (float64_is_signaling_nan(f64)) {",
"float_raise(float_flag_invalid, fpst);",
"nan = float64_maybe_silence_nan(f64);",
"}",
"if (fpst->default_nan_mode) {",
"nan = float64_default_nan;",
"}",
"return nan;",
"} else if (float64_is_infinity(f64)) {",
"return float64_set_sign(float64_zero, float64_is_neg(f64));",
"} else if (float64_is_zero(f64)) {",
"float_raise(float_flag_divbyzero, fpst);",
"return float64_set_sign(float64_infinity, float64_is_neg(f64));",
"} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {",
"float_raise(float_flag_overflow | float_flag_inexact, fpst);",
"if (round_to_inf(fpst, f64_sbit)) {",
"return float64_set_sign(float64_infinity, float64_is_neg(f64));",
"} else {",
"return float64_set_sign(float64_maxnorm, float64_is_neg(f64));",
"}",
"} else if (f64_exp >= 1023 && fpst->flush_to_zero) {",
"float_raise(float_flag_underflow, fpst);",
"return float64_set_sign(float64_zero, float64_is_neg(f64));",
"}",
"r64 = call_recip_estimate(f64, 2045, fpst);",
"r64_val = float64_val(r64);",
"r64_exp = extract64(r64_val, 52, 11);",
"r64_frac = extract64(r64_val, 0, 52);",
"return make_float64(f64_sbit |\n((r64_exp & 0x7ff) << 52) |\nr64_frac);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95,
97,
99
],
[
101
]
] |
2,777 | static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
STM32F2XXUsartState *s = opaque;
uint32_t value = val64;
unsigned char ch;
DB_PRINT("Write 0x%" PRIx32 ", 0x%"HWADDR_PRIx"\n", value, addr);
switch (addr) {
case USART_SR:
if (value <= 0x3FF) {
s->usart_sr = value;
} else {
s->usart_sr &= value;
}
if (!(s->usart_sr & USART_SR_RXNE)) {
qemu_set_irq(s->irq, 0);
}
return;
case USART_DR:
if (value < 0xF000) {
ch = value;
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
s->usart_sr |= USART_SR_TC;
s->usart_sr &= ~USART_SR_TXE;
}
return;
case USART_BRR:
s->usart_brr = value;
return;
case USART_CR1:
s->usart_cr1 = value;
if (s->usart_cr1 & USART_CR1_RXNEIE &&
s->usart_sr & USART_SR_RXNE) {
qemu_set_irq(s->irq, 1);
}
return;
case USART_CR2:
s->usart_cr2 = value;
return;
case USART_CR3:
s->usart_cr3 = value;
return;
case USART_GTPR:
s->usart_gtpr = value;
return;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
}
} | true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
uint64_t val64, unsigned int size)
{
STM32F2XXUsartState *s = opaque;
uint32_t value = val64;
unsigned char ch;
DB_PRINT("Write 0x%" PRIx32 ", 0x%"HWADDR_PRIx"\n", value, addr);
switch (addr) {
case USART_SR:
if (value <= 0x3FF) {
s->usart_sr = value;
} else {
s->usart_sr &= value;
}
if (!(s->usart_sr & USART_SR_RXNE)) {
qemu_set_irq(s->irq, 0);
}
return;
case USART_DR:
if (value < 0xF000) {
ch = value;
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
s->usart_sr |= USART_SR_TC;
s->usart_sr &= ~USART_SR_TXE;
}
return;
case USART_BRR:
s->usart_brr = value;
return;
case USART_CR1:
s->usart_cr1 = value;
if (s->usart_cr1 & USART_CR1_RXNEIE &&
s->usart_sr & USART_SR_RXNE) {
qemu_set_irq(s->irq, 1);
}
return;
case USART_CR2:
s->usart_cr2 = value;
return;
case USART_CR3:
s->usart_cr3 = value;
return;
case USART_GTPR:
s->usart_gtpr = value;
return;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned int VAR_3)
{
STM32F2XXUsartState *s = VAR_0;
uint32_t value = VAR_2;
unsigned char VAR_4;
DB_PRINT("Write 0x%" PRIx32 ", 0x%"HWADDR_PRIx"\n", value, VAR_1);
switch (VAR_1) {
case USART_SR:
if (value <= 0x3FF) {
s->usart_sr = value;
} else {
s->usart_sr &= value;
}
if (!(s->usart_sr & USART_SR_RXNE)) {
qemu_set_irq(s->irq, 0);
}
return;
case USART_DR:
if (value < 0xF000) {
VAR_4 = value;
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &VAR_4, 1);
}
s->usart_sr |= USART_SR_TC;
s->usart_sr &= ~USART_SR_TXE;
}
return;
case USART_BRR:
s->usart_brr = value;
return;
case USART_CR1:
s->usart_cr1 = value;
if (s->usart_cr1 & USART_CR1_RXNEIE &&
s->usart_sr & USART_SR_RXNE) {
qemu_set_irq(s->irq, 1);
}
return;
case USART_CR2:
s->usart_cr2 = value;
return;
case USART_CR3:
s->usart_cr3 = value;
return;
case USART_GTPR:
s->usart_gtpr = value;
return;
default:
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, VAR_1);
}
} | [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{",
"STM32F2XXUsartState *s = VAR_0;",
"uint32_t value = VAR_2;",
"unsigned char VAR_4;",
"DB_PRINT(\"Write 0x%\" PRIx32 \", 0x%\"HWADDR_PRIx\"\\n\", value, VAR_1);",
"switch (VAR_1) {",
"case USART_SR:\nif (value <= 0x3FF) {",
"s->usart_sr = value;",
"} else {",
"s->usart_sr &= value;",
"}",
"if (!(s->usart_sr & USART_SR_RXNE)) {",
"qemu_set_irq(s->irq, 0);",
"}",
"return;",
"case USART_DR:\nif (value < 0xF000) {",
"VAR_4 = value;",
"if (s->chr) {",
"qemu_chr_fe_write_all(s->chr, &VAR_4, 1);",
"}",
"s->usart_sr |= USART_SR_TC;",
"s->usart_sr &= ~USART_SR_TXE;",
"}",
"return;",
"case USART_BRR:\ns->usart_brr = value;",
"return;",
"case USART_CR1:\ns->usart_cr1 = value;",
"if (s->usart_cr1 & USART_CR1_RXNEIE &&\ns->usart_sr & USART_SR_RXNE) {",
"qemu_set_irq(s->irq, 1);",
"}",
"return;",
"case USART_CR2:\ns->usart_cr2 = value;",
"return;",
"case USART_CR3:\ns->usart_cr3 = value;",
"return;",
"case USART_GTPR:\ns->usart_gtpr = value;",
"return;",
"default:\nqemu_log_mask(LOG_GUEST_ERROR,\n\"%s: Bad offset 0x%\"HWADDR_PRIx\"\\n\", __func__, 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
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
]
] |
2,778 | static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[]){
int srcStride[3];
uint8_t *src[3];
uint8_t *dst[3];
if(c->srcFormat == IMGFMT_I420){
src[0]= srcParam[0];
src[1]= srcParam[2];
src[2]= srcParam[1];
srcStride[0]= srcStrideParam[0];
srcStride[1]= srcStrideParam[2];
srcStride[2]= srcStrideParam[1];
}
else if(c->srcFormat==IMGFMT_YV12){
src[0]= srcParam[0];
src[1]= srcParam[1];
src[2]= srcParam[2];
srcStride[0]= srcStrideParam[0];
srcStride[1]= srcStrideParam[1];
srcStride[2]= srcStrideParam[2];
}
else if(isPacked(c->srcFormat) || isGray(c->srcFormat)){
src[0]= srcParam[0];
src[1]=
src[2]= NULL;
srcStride[0]= srcStrideParam[0];
srcStride[1]=
srcStride[2]= 0;
}
if(c->dstFormat == IMGFMT_I420){
dst[0]= dstParam[0];
dst[1]= dstParam[2];
dst[2]= dstParam[1];
}else{
dst[0]= dstParam[0];
dst[1]= dstParam[1];
dst[2]= dstParam[2];
}
if(isPacked(c->srcFormat))
{
if(dstStride[0]==srcStride[0])
memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]);
else
{
int i;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
int length=0;
/* universal length finder */
while(length+c->srcW <= dstStride[0]
&& length+c->srcW <= srcStride[0]) length+= c->srcW;
ASSERT(length!=0);
for(i=0; i<srcSliceH; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
}
}
}
else
{ /* Planar YUV */
int plane;
for(plane=0; plane<3; plane++)
{
int length= plane==0 ? c->srcW : ((c->srcW+1)>>1);
int y= plane==0 ? srcSliceY: ((srcSliceY+1)>>1);
int height= plane==0 ? srcSliceH: ((srcSliceH+1)>>1);
if(dstStride[plane]==srcStride[plane])
memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]);
else
{
int i;
uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
for(i=0; i<height; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
}
}
}
}
| true | FFmpeg | 9bd8bd1add6be33f5eb7f2645350901ab2a56a6c | static void simpleCopy(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[]){
int srcStride[3];
uint8_t *src[3];
uint8_t *dst[3];
if(c->srcFormat == IMGFMT_I420){
src[0]= srcParam[0];
src[1]= srcParam[2];
src[2]= srcParam[1];
srcStride[0]= srcStrideParam[0];
srcStride[1]= srcStrideParam[2];
srcStride[2]= srcStrideParam[1];
}
else if(c->srcFormat==IMGFMT_YV12){
src[0]= srcParam[0];
src[1]= srcParam[1];
src[2]= srcParam[2];
srcStride[0]= srcStrideParam[0];
srcStride[1]= srcStrideParam[1];
srcStride[2]= srcStrideParam[2];
}
else if(isPacked(c->srcFormat) || isGray(c->srcFormat)){
src[0]= srcParam[0];
src[1]=
src[2]= NULL;
srcStride[0]= srcStrideParam[0];
srcStride[1]=
srcStride[2]= 0;
}
if(c->dstFormat == IMGFMT_I420){
dst[0]= dstParam[0];
dst[1]= dstParam[2];
dst[2]= dstParam[1];
}else{
dst[0]= dstParam[0];
dst[1]= dstParam[1];
dst[2]= dstParam[2];
}
if(isPacked(c->srcFormat))
{
if(dstStride[0]==srcStride[0])
memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]);
else
{
int i;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
int length=0;
while(length+c->srcW <= dstStride[0]
&& length+c->srcW <= srcStride[0]) length+= c->srcW;
ASSERT(length!=0);
for(i=0; i<srcSliceH; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[0];
dstPtr+= dstStride[0];
}
}
}
else
{
int plane;
for(plane=0; plane<3; plane++)
{
int length= plane==0 ? c->srcW : ((c->srcW+1)>>1);
int y= plane==0 ? srcSliceY: ((srcSliceY+1)>>1);
int height= plane==0 ? srcSliceH: ((srcSliceH+1)>>1);
if(dstStride[plane]==srcStride[plane])
memcpy(dst[plane] + dstStride[plane]*y, src[plane], height*dstStride[plane]);
else
{
int i;
uint8_t *srcPtr= src[plane];
uint8_t *dstPtr= dst[plane] + dstStride[plane]*y;
for(i=0; i<height; i++)
{
memcpy(dstPtr, srcPtr, length);
srcPtr+= srcStride[plane];
dstPtr+= dstStride[plane];
}
}
}
}
}
| {
"code": [
"\t\t\twhile(length+c->srcW <= dstStride[0] ",
"\t\t\t && length+c->srcW <= srcStride[0]) length+= c->srcW;"
],
"line_no": [
111,
113
]
} | static void FUNC_0(SwsContext *VAR_0, uint8_t* VAR_1[], int VAR_2[], int VAR_3,
int VAR_4, uint8_t* VAR_5[], int VAR_6[]){
int VAR_7[3];
uint8_t *src[3];
uint8_t *dst[3];
if(VAR_0->srcFormat == IMGFMT_I420){
src[0]= VAR_1[0];
src[1]= VAR_1[2];
src[2]= VAR_1[1];
VAR_7[0]= VAR_2[0];
VAR_7[1]= VAR_2[2];
VAR_7[2]= VAR_2[1];
}
else if(VAR_0->srcFormat==IMGFMT_YV12){
src[0]= VAR_1[0];
src[1]= VAR_1[1];
src[2]= VAR_1[2];
VAR_7[0]= VAR_2[0];
VAR_7[1]= VAR_2[1];
VAR_7[2]= VAR_2[2];
}
else if(isPacked(VAR_0->srcFormat) || isGray(VAR_0->srcFormat)){
src[0]= VAR_1[0];
src[1]=
src[2]= NULL;
VAR_7[0]= VAR_2[0];
VAR_7[1]=
VAR_7[2]= 0;
}
if(VAR_0->dstFormat == IMGFMT_I420){
dst[0]= VAR_5[0];
dst[1]= VAR_5[2];
dst[2]= VAR_5[1];
}else{
dst[0]= VAR_5[0];
dst[1]= VAR_5[1];
dst[2]= VAR_5[2];
}
if(isPacked(VAR_0->srcFormat))
{
if(VAR_6[0]==VAR_7[0])
memcpy(dst[0] + VAR_6[0]*VAR_3, src[0], VAR_4*VAR_6[0]);
else
{
int VAR_13;
uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + VAR_6[0]*VAR_3;
int VAR_11=0;
while(VAR_11+VAR_0->srcW <= VAR_6[0]
&& VAR_11+VAR_0->srcW <= VAR_7[0]) VAR_11+= VAR_0->srcW;
ASSERT(VAR_11!=0);
for(VAR_13=0; VAR_13<VAR_4; VAR_13++)
{
memcpy(dstPtr, srcPtr, VAR_11);
srcPtr+= VAR_7[0];
dstPtr+= VAR_6[0];
}
}
}
else
{
int VAR_10;
for(VAR_10=0; VAR_10<3; VAR_10++)
{
int VAR_11= VAR_10==0 ? VAR_0->srcW : ((VAR_0->srcW+1)>>1);
int VAR_11= VAR_10==0 ? VAR_3: ((VAR_3+1)>>1);
int VAR_12= VAR_10==0 ? VAR_4: ((VAR_4+1)>>1);
if(VAR_6[VAR_10]==VAR_7[VAR_10])
memcpy(dst[VAR_10] + VAR_6[VAR_10]*VAR_11, src[VAR_10], VAR_12*VAR_6[VAR_10]);
else
{
int VAR_13;
uint8_t *srcPtr= src[VAR_10];
uint8_t *dstPtr= dst[VAR_10] + VAR_6[VAR_10]*VAR_11;
for(VAR_13=0; VAR_13<VAR_12; VAR_13++)
{
memcpy(dstPtr, srcPtr, VAR_11);
srcPtr+= VAR_7[VAR_10];
dstPtr+= VAR_6[VAR_10];
}
}
}
}
}
| [
"static void FUNC_0(SwsContext *VAR_0, uint8_t* VAR_1[], int VAR_2[], int VAR_3,\nint VAR_4, uint8_t* VAR_5[], int VAR_6[]){",
"int VAR_7[3];",
"uint8_t *src[3];",
"uint8_t *dst[3];",
"if(VAR_0->srcFormat == IMGFMT_I420){",
"src[0]= VAR_1[0];",
"src[1]= VAR_1[2];",
"src[2]= VAR_1[1];",
"VAR_7[0]= VAR_2[0];",
"VAR_7[1]= VAR_2[2];",
"VAR_7[2]= VAR_2[1];",
"}",
"else if(VAR_0->srcFormat==IMGFMT_YV12){",
"src[0]= VAR_1[0];",
"src[1]= VAR_1[1];",
"src[2]= VAR_1[2];",
"VAR_7[0]= VAR_2[0];",
"VAR_7[1]= VAR_2[1];",
"VAR_7[2]= VAR_2[2];",
"}",
"else if(isPacked(VAR_0->srcFormat) || isGray(VAR_0->srcFormat)){",
"src[0]= VAR_1[0];",
"src[1]=\nsrc[2]= NULL;",
"VAR_7[0]= VAR_2[0];",
"VAR_7[1]=\nVAR_7[2]= 0;",
"}",
"if(VAR_0->dstFormat == IMGFMT_I420){",
"dst[0]= VAR_5[0];",
"dst[1]= VAR_5[2];",
"dst[2]= VAR_5[1];",
"}else{",
"dst[0]= VAR_5[0];",
"dst[1]= VAR_5[1];",
"dst[2]= VAR_5[2];",
"}",
"if(isPacked(VAR_0->srcFormat))\n{",
"if(VAR_6[0]==VAR_7[0])\nmemcpy(dst[0] + VAR_6[0]*VAR_3, src[0], VAR_4*VAR_6[0]);",
"else\n{",
"int VAR_13;",
"uint8_t *srcPtr= src[0];",
"uint8_t *dstPtr= dst[0] + VAR_6[0]*VAR_3;",
"int VAR_11=0;",
"while(VAR_11+VAR_0->srcW <= VAR_6[0]\n&& VAR_11+VAR_0->srcW <= VAR_7[0]) VAR_11+= VAR_0->srcW;",
"ASSERT(VAR_11!=0);",
"for(VAR_13=0; VAR_13<VAR_4; VAR_13++)",
"{",
"memcpy(dstPtr, srcPtr, VAR_11);",
"srcPtr+= VAR_7[0];",
"dstPtr+= VAR_6[0];",
"}",
"}",
"}",
"else\n{",
"int VAR_10;",
"for(VAR_10=0; VAR_10<3; VAR_10++)",
"{",
"int VAR_11= VAR_10==0 ? VAR_0->srcW : ((VAR_0->srcW+1)>>1);",
"int VAR_11= VAR_10==0 ? VAR_3: ((VAR_3+1)>>1);",
"int VAR_12= VAR_10==0 ? VAR_4: ((VAR_4+1)>>1);",
"if(VAR_6[VAR_10]==VAR_7[VAR_10])\nmemcpy(dst[VAR_10] + VAR_6[VAR_10]*VAR_11, src[VAR_10], VAR_12*VAR_6[VAR_10]);",
"else\n{",
"int VAR_13;",
"uint8_t *srcPtr= src[VAR_10];",
"uint8_t *dstPtr= dst[VAR_10] + VAR_6[VAR_10]*VAR_11;",
"for(VAR_13=0; VAR_13<VAR_12; VAR_13++)",
"{",
"memcpy(dstPtr, srcPtr, VAR_11);",
"srcPtr+= VAR_7[VAR_10];",
"dstPtr+= VAR_6[VAR_10];",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
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
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111,
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153,
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
]
] |
2,779 | static void free_ahci_device(QPCIDevice *dev)
{
QPCIBus *pcibus = dev ? dev->bus : NULL;
/* libqos doesn't have a function for this, so free it manually */
g_free(dev);
qpci_free_pc(pcibus);
}
| true | qemu | 9a75b0a037e3a8030992244353f17b62f6daf2ab | static void free_ahci_device(QPCIDevice *dev)
{
QPCIBus *pcibus = dev ? dev->bus : NULL;
g_free(dev);
qpci_free_pc(pcibus);
}
| {
"code": [
"static void free_ahci_device(QPCIDevice *dev)",
" QPCIBus *pcibus = dev ? dev->bus : NULL;",
" g_free(dev);",
" qpci_free_pc(pcibus);"
],
"line_no": [
1,
5,
11,
13
]
} | static void FUNC_0(QPCIDevice *VAR_0)
{
QPCIBus *pcibus = VAR_0 ? VAR_0->bus : NULL;
g_free(VAR_0);
qpci_free_pc(pcibus);
}
| [
"static void FUNC_0(QPCIDevice *VAR_0)\n{",
"QPCIBus *pcibus = VAR_0 ? VAR_0->bus : NULL;",
"g_free(VAR_0);",
"qpci_free_pc(pcibus);",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15
]
] |
2,780 | int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0};
int sign= (nom<0) ^ (den<0);
int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
nom = FFABS(nom)/gcd;
den = FFABS(den)/gcd;
if(nom<=max && den<=max){
a1= (AVRational){nom, den};
den=0;
}
while(den){
int64_t x = nom / den;
int64_t next_den= nom - den*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
if(a2n > max || a2d > max){
if(a1.num) x= (max - a0.num) / a1.num;
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
// Won't overflow, sum == original denominator
if (den*(2*x*a1.den + a0.den) > nom*a1.den)
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
break;
}
a0= a1;
a1= (AVRational){a2n, a2d};
nom= den;
den= next_den;
}
assert(ff_gcd(a1.num, a1.den) == 1);
*dst_nom = sign ? -a1.num : a1.num;
*dst_den = a1.den;
return den==0;
}
| true | FFmpeg | 62b9fc1571b1354cf596a280b5fe55a9593a7a2f | int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
AVRational a0={0,1}, a1={1,0};
int sign= (nom<0) ^ (den<0);
int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
nom = FFABS(nom)/gcd;
den = FFABS(den)/gcd;
if(nom<=max && den<=max){
a1= (AVRational){nom, den};
den=0;
}
while(den){
int64_t x = nom / den;
int64_t next_den= nom - den*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
if(a2n > max || a2d > max){
if(a1.num) x= (max - a0.num) / a1.num;
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
if (den*(2*x*a1.den + a0.den) > nom*a1.den)
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
break;
}
a0= a1;
a1= (AVRational){a2n, a2d};
nom= den;
den= next_den;
}
assert(ff_gcd(a1.num, a1.den) == 1);
*dst_nom = sign ? -a1.num : a1.num;
*dst_den = a1.den;
return den==0;
}
| {
"code": [
" int64_t x = nom / den;"
],
"line_no": [
27
]
} | int FUNC_0(int *VAR_0, int *VAR_1, int64_t VAR_2, int64_t VAR_3, int64_t VAR_4){
AVRational a0={0,1}, a1={1,0};
int VAR_5= (VAR_2<0) ^ (VAR_3<0);
int64_t gcd= ff_gcd(FFABS(VAR_2), FFABS(VAR_3));
VAR_2 = FFABS(VAR_2)/gcd;
VAR_3 = FFABS(VAR_3)/gcd;
if(VAR_2<=VAR_4 && VAR_3<=VAR_4){
a1= (AVRational){VAR_2, VAR_3};
VAR_3=0;
}
while(VAR_3){
int64_t x = VAR_2 / VAR_3;
int64_t next_den= VAR_2 - VAR_3*x;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.VAR_3 + a0.VAR_3;
if(a2n > VAR_4 || a2d > VAR_4){
if(a1.num) x= (VAR_4 - a0.num) / a1.num;
if(a1.VAR_3) x= FFMIN(x, (VAR_4 - a0.VAR_3) / a1.VAR_3);
if (VAR_3*(2*x*a1.VAR_3 + a0.VAR_3) > VAR_2*a1.VAR_3)
a1 = (AVRational){x*a1.num + a0.num, x*a1.VAR_3 + a0.VAR_3};
break;
}
a0= a1;
a1= (AVRational){a2n, a2d};
VAR_2= VAR_3;
VAR_3= next_den;
}
assert(ff_gcd(a1.num, a1.VAR_3) == 1);
*VAR_0 = VAR_5 ? -a1.num : a1.num;
*VAR_1 = a1.VAR_3;
return VAR_3==0;
}
| [
"int FUNC_0(int *VAR_0, int *VAR_1, int64_t VAR_2, int64_t VAR_3, int64_t VAR_4){",
"AVRational a0={0,1}, a1={1,0};",
"int VAR_5= (VAR_2<0) ^ (VAR_3<0);",
"int64_t gcd= ff_gcd(FFABS(VAR_2), FFABS(VAR_3));",
"VAR_2 = FFABS(VAR_2)/gcd;",
"VAR_3 = FFABS(VAR_3)/gcd;",
"if(VAR_2<=VAR_4 && VAR_3<=VAR_4){",
"a1= (AVRational){VAR_2, VAR_3};",
"VAR_3=0;",
"}",
"while(VAR_3){",
"int64_t x = VAR_2 / VAR_3;",
"int64_t next_den= VAR_2 - VAR_3*x;",
"int64_t a2n= x*a1.num + a0.num;",
"int64_t a2d= x*a1.VAR_3 + a0.VAR_3;",
"if(a2n > VAR_4 || a2d > VAR_4){",
"if(a1.num) x= (VAR_4 - a0.num) / a1.num;",
"if(a1.VAR_3) x= FFMIN(x, (VAR_4 - a0.VAR_3) / a1.VAR_3);",
"if (VAR_3*(2*x*a1.VAR_3 + a0.VAR_3) > VAR_2*a1.VAR_3)\na1 = (AVRational){x*a1.num + a0.num, x*a1.VAR_3 + a0.VAR_3};",
"break;",
"}",
"a0= a1;",
"a1= (AVRational){a2n, a2d};",
"VAR_2= VAR_3;",
"VAR_3= next_den;",
"}",
"assert(ff_gcd(a1.num, a1.VAR_3) == 1);",
"*VAR_0 = VAR_5 ? -a1.num : a1.num;",
"*VAR_1 = a1.VAR_3;",
"return VAR_3==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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
2,781 | PPC_OP(cmpi)
{
if (Ts0 < SPARAM(1)) {
T0 = 0x08;
} else if (Ts0 > SPARAM(1)) {
T0 = 0x04;
} else {
T0 = 0x02;
}
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(cmpi)
{
if (Ts0 < SPARAM(1)) {
T0 = 0x08;
} else if (Ts0 > SPARAM(1)) {
T0 = 0x04;
} else {
T0 = 0x02;
}
RETURN();
}
| {
"code": [
" RETURN();",
" } else {",
" } else {",
" } else {",
"PPC_OP(cmpi)",
" if (Ts0 < SPARAM(1)) {",
" } else if (Ts0 > SPARAM(1)) {",
" } else {",
" } else {",
" } else {",
" } else {",
" } else {",
" RETURN();",
" } else {",
" } else {"
],
"line_no": [
19,
13,
13,
13,
1,
5,
9,
13,
13,
13,
13,
13,
19,
13,
13
]
} | FUNC_0(VAR_0)
{
if (Ts0 < SPARAM(1)) {
T0 = 0x08;
} else if (Ts0 > SPARAM(1)) {
T0 = 0x04;
} else {
T0 = 0x02;
}
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"if (Ts0 < SPARAM(1)) {",
"T0 = 0x08;",
"} else if (Ts0 > SPARAM(1)) {",
"T0 = 0x04;",
"} else {",
"T0 = 0x02;",
"}",
"RETURN();",
"}"
] | [
1,
1,
0,
1,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
2,782 | static int bdrv_rd_badreq_bytes(BlockDriverState *bs,
int64_t offset, int count)
{
int64_t size = bs->total_sectors << SECTOR_BITS;
return
count < 0 ||
size < 0 ||
count > size ||
offset > size - count;
}
| true | qemu | b5eff355460643d09e533024360fe0522f368c07 | static int bdrv_rd_badreq_bytes(BlockDriverState *bs,
int64_t offset, int count)
{
int64_t size = bs->total_sectors << SECTOR_BITS;
return
count < 0 ||
size < 0 ||
count > size ||
offset > size - count;
}
| {
"code": [
"static int bdrv_rd_badreq_bytes(BlockDriverState *bs,",
" int64_t offset, int count)",
" int64_t size = bs->total_sectors << SECTOR_BITS;",
" count < 0 ||",
" size < 0 ||",
" count > size ||",
" offset > size - count;",
" int64_t offset, int count)",
" int64_t size = bs->total_sectors << SECTOR_BITS;"
],
"line_no": [
1,
3,
7,
11,
13,
15,
17,
3,
7
]
} | static int FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1, int VAR_2)
{
int64_t size = VAR_0->total_sectors << SECTOR_BITS;
return
VAR_2 < 0 ||
size < 0 ||
VAR_2 > size ||
VAR_1 > size - VAR_2;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1, int VAR_2)\n{",
"int64_t size = VAR_0->total_sectors << SECTOR_BITS;",
"return\nVAR_2 < 0 ||\nsize < 0 ||\nVAR_2 > size ||\nVAR_1 > size - VAR_2;",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11,
13,
15,
17
],
[
19
]
] |
2,783 | static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
ff_asf_guid mediatype, ff_asf_guid subtype,
ff_asf_guid formattype, int size)
{
WtvContext *wtv = s->priv_data;
AVIOContext *pb = wtv->pb;
if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) &&
!ff_guidcmp(formattype, format_cpfilters_processed)) {
ff_asf_guid actual_subtype;
ff_asf_guid actual_formattype;
if (size < 32) {
av_log(s, AV_LOG_WARNING, "format buffer size underflow\n");
avio_skip(pb, size);
return NULL;
}
avio_skip(pb, size - 32);
ff_get_guid(pb, &actual_subtype);
ff_get_guid(pb, &actual_formattype);
avio_seek(pb, -size, SEEK_CUR);
st = parse_media_type(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);
avio_skip(pb, 32);
return st;
} else if (!ff_guidcmp(mediatype, mediatype_audio)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_waveformatex)) {
ff_get_wav_header(pb, st->codec, size);
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
if (st->codec->extradata && st->codec->extradata_size >= 22)
parse_mpeg1waveformatex(st);
else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else {
st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype);
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
}
return st;
} else if (!ff_guidcmp(mediatype, mediatype_video)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_videoinfo2)) {
int consumed = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - consumed, 0));
} else if (!ff_guidcmp(formattype, format_mpeg2_video)) {
int consumed = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - consumed, 0));
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else {
st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);
}
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_TELETEXT;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID
", subtype:"PRI_GUID", formattype:"PRI_GUID"\n",
ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
| true | FFmpeg | ca402f32e392590a81a1381dab41c4f9c2c2f98a | static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
ff_asf_guid mediatype, ff_asf_guid subtype,
ff_asf_guid formattype, int size)
{
WtvContext *wtv = s->priv_data;
AVIOContext *pb = wtv->pb;
if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) &&
!ff_guidcmp(formattype, format_cpfilters_processed)) {
ff_asf_guid actual_subtype;
ff_asf_guid actual_formattype;
if (size < 32) {
av_log(s, AV_LOG_WARNING, "format buffer size underflow\n");
avio_skip(pb, size);
return NULL;
}
avio_skip(pb, size - 32);
ff_get_guid(pb, &actual_subtype);
ff_get_guid(pb, &actual_formattype);
avio_seek(pb, -size, SEEK_CUR);
st = parse_media_type(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);
avio_skip(pb, 32);
return st;
} else if (!ff_guidcmp(mediatype, mediatype_audio)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_waveformatex)) {
ff_get_wav_header(pb, st->codec, size);
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
if (st->codec->extradata && st->codec->extradata_size >= 22)
parse_mpeg1waveformatex(st);
else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else {
st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype);
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
}
return st;
} else if (!ff_guidcmp(mediatype, mediatype_video)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_videoinfo2)) {
int consumed = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - consumed, 0));
} else if (!ff_guidcmp(formattype, format_mpeg2_video)) {
int consumed = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - consumed, 0));
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else {
st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);
}
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_TELETEXT;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID
", subtype:"PRI_GUID", formattype:"PRI_GUID"\n",
ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
| {
"code": [
" ff_get_wav_header(pb, st->codec, size);"
],
"line_no": [
61
]
} | static AVStream * FUNC_0(AVFormatContext *s, AVStream *st, int sid,
ff_asf_guid mediatype, ff_asf_guid subtype,
ff_asf_guid formattype, int size)
{
WtvContext *wtv = s->priv_data;
AVIOContext *pb = wtv->pb;
if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) &&
!ff_guidcmp(formattype, format_cpfilters_processed)) {
ff_asf_guid actual_subtype;
ff_asf_guid actual_formattype;
if (size < 32) {
av_log(s, AV_LOG_WARNING, "format buffer size underflow\n");
avio_skip(pb, size);
return NULL;
}
avio_skip(pb, size - 32);
ff_get_guid(pb, &actual_subtype);
ff_get_guid(pb, &actual_formattype);
avio_seek(pb, -size, SEEK_CUR);
st = FUNC_0(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);
avio_skip(pb, 32);
return st;
} else if (!ff_guidcmp(mediatype, mediatype_audio)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_waveformatex)) {
ff_get_wav_header(pb, st->codec, size);
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
if (st->codec->extradata && st->codec->extradata_size >= 22)
parse_mpeg1waveformatex(st);
else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else {
st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype);
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
}
return st;
} else if (!ff_guidcmp(mediatype, mediatype_video)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO);
if (!st)
return NULL;
if (!ff_guidcmp(formattype, format_videoinfo2)) {
int VAR_1 = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - VAR_1, 0));
} else if (!ff_guidcmp(formattype, format_mpeg2_video)) {
int VAR_1 = parse_videoinfoheader2(s, st);
avio_skip(pb, FFMAX(size - VAR_1, 0));
} else {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
}
if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else {
st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);
}
if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {
st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return NULL;
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_TELETEXT;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID
", subtype:"PRI_GUID", formattype:"PRI_GUID"\n",
ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));
avio_skip(pb, size);
return NULL;
}
| [
"static AVStream * FUNC_0(AVFormatContext *s, AVStream *st, int sid,\nff_asf_guid mediatype, ff_asf_guid subtype,\nff_asf_guid formattype, int size)\n{",
"WtvContext *wtv = s->priv_data;",
"AVIOContext *pb = wtv->pb;",
"if (!ff_guidcmp(subtype, mediasubtype_cpfilters_processed) &&\n!ff_guidcmp(formattype, format_cpfilters_processed)) {",
"ff_asf_guid actual_subtype;",
"ff_asf_guid actual_formattype;",
"if (size < 32) {",
"av_log(s, AV_LOG_WARNING, \"format buffer size underflow\\n\");",
"avio_skip(pb, size);",
"return NULL;",
"}",
"avio_skip(pb, size - 32);",
"ff_get_guid(pb, &actual_subtype);",
"ff_get_guid(pb, &actual_formattype);",
"avio_seek(pb, -size, SEEK_CUR);",
"st = FUNC_0(s, st, sid, mediatype, actual_subtype, actual_formattype, size - 32);",
"avio_skip(pb, 32);",
"return st;",
"} else if (!ff_guidcmp(mediatype, mediatype_audio)) {",
"st = new_stream(s, st, sid, AVMEDIA_TYPE_AUDIO);",
"if (!st)\nreturn NULL;",
"if (!ff_guidcmp(formattype, format_waveformatex)) {",
"ff_get_wav_header(pb, st->codec, size);",
"} else {",
"if (ff_guidcmp(formattype, format_none))\nav_log(s, AV_LOG_WARNING, \"unknown formattype:\"PRI_GUID\"\\n\", ARG_GUID(formattype));",
"avio_skip(pb, size);",
"}",
"if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {",
"st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);",
"} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {",
"if (st->codec->extradata && st->codec->extradata_size >= 22)\nparse_mpeg1waveformatex(st);",
"else\nav_log(s, AV_LOG_WARNING, \"MPEG1WAVEFORMATEX underflow\\n\");",
"} else {",
"st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype);",
"if (st->codec->codec_id == CODEC_ID_NONE)\nav_log(s, AV_LOG_WARNING, \"unknown subtype:\"PRI_GUID\"\\n\", ARG_GUID(subtype));",
"}",
"return st;",
"} else if (!ff_guidcmp(mediatype, mediatype_video)) {",
"st = new_stream(s, st, sid, AVMEDIA_TYPE_VIDEO);",
"if (!st)\nreturn NULL;",
"if (!ff_guidcmp(formattype, format_videoinfo2)) {",
"int VAR_1 = parse_videoinfoheader2(s, st);",
"avio_skip(pb, FFMAX(size - VAR_1, 0));",
"} else if (!ff_guidcmp(formattype, format_mpeg2_video)) {",
"int VAR_1 = parse_videoinfoheader2(s, st);",
"avio_skip(pb, FFMAX(size - VAR_1, 0));",
"} else {",
"if (ff_guidcmp(formattype, format_none))\nav_log(s, AV_LOG_WARNING, \"unknown formattype:\"PRI_GUID\"\\n\", ARG_GUID(formattype));",
"avio_skip(pb, size);",
"}",
"if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {",
"st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));",
"} else {",
"st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);",
"}",
"if (st->codec->codec_id == CODEC_ID_NONE)\nav_log(s, AV_LOG_WARNING, \"unknown subtype:\"PRI_GUID\"\\n\", ARG_GUID(subtype));",
"return st;",
"} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&",
"!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {",
"st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);",
"if (!st)\nreturn NULL;",
"if (ff_guidcmp(formattype, format_none))\nav_log(s, AV_LOG_WARNING, \"unknown formattype:\"PRI_GUID\"\\n\", ARG_GUID(formattype));",
"avio_skip(pb, size);",
"st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;",
"return st;",
"} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&",
"(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {",
"st = new_stream(s, st, sid, AVMEDIA_TYPE_SUBTITLE);",
"if (!st)\nreturn NULL;",
"if (ff_guidcmp(formattype, format_none))\nav_log(s, AV_LOG_WARNING, \"unknown formattype:\"PRI_GUID\"\\n\", ARG_GUID(formattype));",
"avio_skip(pb, size);",
"st->codec->codec_id = CODEC_ID_DVB_TELETEXT;",
"return st;",
"} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&",
"!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {",
"if (ff_guidcmp(formattype, format_none))\nav_log(s, AV_LOG_WARNING, \"unknown formattype:\"PRI_GUID\"\\n\", ARG_GUID(formattype));",
"avio_skip(pb, size);",
"return NULL;",
"}",
"av_log(s, AV_LOG_WARNING, \"unknown media type, mediatype:\"PRI_GUID\n\", subtype:\"PRI_GUID\", formattype:\"PRI_GUID\"\\n\",\nARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));",
"avio_skip(pb, size);",
"return NULL;",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
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
],
[
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
],
[
205,
207,
209
],
[
211
],
[
213
],
[
215
]
] |
2,784 | static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
int flags, int canMMX2BeUsed, int16_t *hLumFilter,
int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
#ifdef HAVE_MMX
// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
}
else // Fast Bilinear upscale / crap downscale
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
:: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyYCode)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
}
else
{
#endif
long xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
//NO MMX just normal asm ...
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_b", %%"REG_b" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // 2*xalpha
ASMALIGN16
"1: \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
"movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
"adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
"movzbl (%0, %%"REG_b"), %%edi \n\t" //src[xx]
"movzbl 1(%0, %%"REG_b"), %%esi \n\t" //src[xx+1]
"subl %%edi, %%esi \n\t" //src[xx+1] - src[xx]
"imull %%ecx, %%esi \n\t" //(src[xx+1] - src[xx])*2*xalpha
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t" //2*xalpha += xInc&0xFF
"adc %3, %%"REG_b" \n\t" //xx+= xInc>>8 + carry
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
} //if MMX2 can't be used
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif
}
}
| false | FFmpeg | 4bff9ef9d0781c4de228bf1f85634d2706fc589b | static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
int flags, int canMMX2BeUsed, int16_t *hLumFilter,
int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_UYVY)
{
RENAME(uyvyToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR32)
{
RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR24)
{
RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR16)
{
RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR15)
{
RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB32)
{
RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB24)
{
RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int i;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
:: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyYCode)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
}
else
{
#endif
long xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for(i=0;i<dstWidth;i++)
{
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,
int flags, int canMMX2BeUsed, int16_t *hLumFilter,
int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos)
{
if(srcFormat==IMGFMT_YUY2)
{
FUNC_0(yuy2ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_UYVY)
{
FUNC_0(uyvyToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR32)
{
FUNC_0(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR24)
{
FUNC_0(bgr24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR16)
{
FUNC_0(bgr16ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_BGR15)
{
FUNC_0(bgr15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB32)
{
FUNC_0(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
else if(srcFormat==IMGFMT_RGB24)
{
FUNC_0(rgb24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
#ifdef HAVE_MMX
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))
#else
if(!(flags&SWS_FAST_BILINEAR))
#endif
{
FUNC_0(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
}
else
{
#if defined(ARCH_X86) || defined(ARCH_X86_64)
#ifdef HAVE_MMX2
int VAR_0;
if(canMMX2BeUsed)
{
asm volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#ifdef ARCH_X86_64
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi\n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define FUNNY_Y_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c"\n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
:: "m" (src), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (funnyYCode)
: "%"REG_a, "%"REG_b, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
);
for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128;
}
else
{
#endif
long xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
asm volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_b", %%"REG_b" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN16
"1: \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, (%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"movzbl (%0, %%"REG_b"), %%edi \n\t"
"movzbl 1(%0, %%"REG_b"), %%esi \n\t"
"subl %%edi, %%esi \n\t" - src[xx]
"imull %%ecx, %%esi \n\t"
"shll $16, %%edi \n\t"
"addl %%edi, %%esi \n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"mov %1, %%"REG_D" \n\t"
"shrl $9, %%esi \n\t"
"movw %%si, 2(%%"REG_D", %%"REG_a", 2)\n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_b" \n\t"
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
);
#ifdef HAVE_MMX2
}
#endif
#else
int VAR_0;
unsigned int VAR_1=0;
for(VAR_0=0;VAR_0<dstWidth;VAR_0++)
{
register unsigned int xx=VAR_1>>16;
register unsigned int xalpha=(VAR_1&0xFFFF)>>9;
dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
VAR_1+=xInc;
}
#endif
}
}
| [
"static inline void FUNC_0(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc,\nint flags, int canMMX2BeUsed, int16_t *hLumFilter,\nint16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,\nint srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,\nint32_t *mmx2FilterPos)\n{",
"if(srcFormat==IMGFMT_YUY2)\n{",
"FUNC_0(yuy2ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_UYVY)\n{",
"FUNC_0(uyvyToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_BGR32)\n{",
"FUNC_0(bgr32ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_BGR24)\n{",
"FUNC_0(bgr24ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_BGR16)\n{",
"FUNC_0(bgr16ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_BGR15)\n{",
"FUNC_0(bgr15ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_RGB32)\n{",
"FUNC_0(rgb32ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"else if(srcFormat==IMGFMT_RGB24)\n{",
"FUNC_0(rgb24ToY)(formatConvBuffer, src, srcW);",
"src= formatConvBuffer;",
"}",
"#ifdef HAVE_MMX\nif(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed))\n#else\nif(!(flags&SWS_FAST_BILINEAR))\n#endif\n{",
"FUNC_0(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);",
"}",
"else\n{",
"#if defined(ARCH_X86) || defined(ARCH_X86_64)\n#ifdef HAVE_MMX2\nint VAR_0;",
"if(canMMX2BeUsed)\n{",
"asm volatile(\n\"pxor %%mm7, %%mm7\t\t\\n\\t\"\n\"mov %0, %%\"REG_c\"\t\t\\n\\t\"\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"mov %2, %%\"REG_d\"\t\t\\n\\t\"\n\"mov %3, %%\"REG_b\"\t\t\\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\nPREFETCH\" (%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 32(%%\"REG_c\")\t\t\\n\\t\"\nPREFETCH\" 64(%%\"REG_c\")\t\t\\n\\t\"\n#ifdef ARCH_X86_64\n#define FUNNY_Y_CODE \\\n\"movl (%%\"REG_b\"), %%esi\t\\n\\t\"\\\n\"call *%4\t\t\t\\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi\\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\"\t\\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\"\t\\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\\\n#else\n#define FUNNY_Y_CODE \\\n\"movl (%%\"REG_b\"), %%esi\t\\n\\t\"\\\n\"call *%4\t\t\t\\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\"\\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\"\t\\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\\\n#endif\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\nFUNNY_Y_CODE\n:: \"m\" (src), \"m\" (dst), \"m\" (mmx2Filter), \"m\" (mmx2FilterPos),\n\"m\" (funnyYCode)\n: \"%\"REG_a, \"%\"REG_b, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n);",
"for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128;",
"}",
"else\n{",
"#endif\nlong xInc_shr16 = xInc >> 16;",
"uint16_t xInc_mask = xInc & 0xffff;",
"asm volatile(\n\"xor %%\"REG_a\", %%\"REG_a\"\t\\n\\t\"\n\"xor %%\"REG_b\", %%\"REG_b\"\t\\n\\t\"\n\"xorl %%ecx, %%ecx\t\t\\n\\t\"\nASMALIGN16\n\"1:\t\t\t\t\\n\\t\"\n\"movzbl (%0, %%\"REG_b\"), %%edi\t\\n\\t\"\n\"movzbl 1(%0, %%\"REG_b\"), %%esi\t\\n\\t\"\n\"subl %%edi, %%esi\t\t\\n\\t\" - src[xx]\n\"imull %%ecx, %%esi\t\t\\n\\t\"\n\"shll $16, %%edi\t\t\\n\\t\"\n\"addl %%edi, %%esi\t\t\\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"shrl $9, %%esi\t\t\t\\n\\t\"\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2)\\n\\t\"\n\"addw %4, %%cx\t\t\t\\n\\t\"\n\"adc %3, %%\"REG_b\"\t\t\\n\\t\"\n\"movzbl (%0, %%\"REG_b\"), %%edi\t\\n\\t\"\n\"movzbl 1(%0, %%\"REG_b\"), %%esi\t\\n\\t\"\n\"subl %%edi, %%esi\t\t\\n\\t\" - src[xx]\n\"imull %%ecx, %%esi\t\t\\n\\t\"\n\"shll $16, %%edi\t\t\\n\\t\"\n\"addl %%edi, %%esi\t\t\\n\\t\" *2*xalpha + src[xx]*(1-2*xalpha)\n\"mov %1, %%\"REG_D\"\t\t\\n\\t\"\n\"shrl $9, %%esi\t\t\t\\n\\t\"\n\"movw %%si, 2(%%\"REG_D\", %%\"REG_a\", 2)\\n\\t\"\n\"addw %4, %%cx\t\t\t\\n\\t\"\n\"adc %3, %%\"REG_b\"\t\t\\n\\t\"\n\"add $2, %%\"REG_a\"\t\t\\n\\t\"\n\"cmp %2, %%\"REG_a\"\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n:: \"r\" (src), \"m\" (dst), \"m\" (dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask)\n: \"%\"REG_a, \"%\"REG_b, \"%ecx\", \"%\"REG_D, \"%esi\"\n);",
"#ifdef HAVE_MMX2\n}",
"#endif\n#else\nint VAR_0;",
"unsigned int VAR_1=0;",
"for(VAR_0=0;VAR_0<dstWidth;VAR_0++)",
"{",
"register unsigned int xx=VAR_1>>16;",
"register unsigned int xalpha=(VAR_1&0xFFFF)>>9;",
"dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;",
"VAR_1+=xInc;",
"}",
"#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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95,
99,
101,
103,
105,
107
],
[
109
],
[
111
],
[
113,
115
],
[
117,
119,
121
],
[
123,
125
],
[
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
149,
153,
155,
157,
159,
161,
163,
165,
169,
173,
175,
177,
179,
181,
183,
187,
191,
193,
195,
197,
199,
201,
203,
205,
209,
211,
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225,
227
],
[
229
],
[
233,
235,
237,
239,
241,
243,
245,
247,
249,
251,
253,
255,
257,
259,
261,
263,
265,
269,
271,
273,
275,
277,
279,
281,
283,
285,
287,
289,
295,
297,
299,
305,
307,
309
],
[
311,
313
],
[
315,
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
]
] |
2,785 | static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic,
int parity, int tff)
{
YADIFContext *yadif = ctx->priv;
int y, i;
for (i = 0; i < yadif->csp->nb_components; i++) {
int w = dstpic->video->w;
int h = dstpic->video->h;
int refs = yadif->cur->linesize[i];
int df = (yadif->csp->comp[i].depth_minus1 + 8) / 8;
if (i == 1 || i == 2) {
/* Why is this not part of the per-plane description thing? */
w >>= yadif->csp->log2_chroma_w;
h >>= yadif->csp->log2_chroma_h;
}
for (y = 0; y < h; y++) {
if ((y ^ parity) & 1) {
uint8_t *prev = &yadif->prev->data[i][y*refs];
uint8_t *cur = &yadif->cur ->data[i][y*refs];
uint8_t *next = &yadif->next->data[i][y*refs];
uint8_t *dst = &dstpic->data[i][y*dstpic->linesize[i]];
int mode = y==1 || y+2==h ? 2 : yadif->mode;
yadif->filter_line(dst, prev, cur, next, w, y+1<h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode);
} else {
memcpy(&dstpic->data[i][y*dstpic->linesize[i]],
&yadif->cur->data[i][y*refs], w*df);
}
}
}
emms_c();
}
| false | FFmpeg | 2f7e8dcf45f11df94f47acbe6825cc93514ea59b | static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic,
int parity, int tff)
{
YADIFContext *yadif = ctx->priv;
int y, i;
for (i = 0; i < yadif->csp->nb_components; i++) {
int w = dstpic->video->w;
int h = dstpic->video->h;
int refs = yadif->cur->linesize[i];
int df = (yadif->csp->comp[i].depth_minus1 + 8) / 8;
if (i == 1 || i == 2) {
w >>= yadif->csp->log2_chroma_w;
h >>= yadif->csp->log2_chroma_h;
}
for (y = 0; y < h; y++) {
if ((y ^ parity) & 1) {
uint8_t *prev = &yadif->prev->data[i][y*refs];
uint8_t *cur = &yadif->cur ->data[i][y*refs];
uint8_t *next = &yadif->next->data[i][y*refs];
uint8_t *dst = &dstpic->data[i][y*dstpic->linesize[i]];
int mode = y==1 || y+2==h ? 2 : yadif->mode;
yadif->filter_line(dst, prev, cur, next, w, y+1<h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode);
} else {
memcpy(&dstpic->data[i][y*dstpic->linesize[i]],
&yadif->cur->data[i][y*refs], w*df);
}
}
}
emms_c();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterContext *VAR_0, AVFilterBufferRef *VAR_1,
int VAR_2, int VAR_3)
{
YADIFContext *yadif = VAR_0->priv;
int VAR_4, VAR_5;
for (VAR_5 = 0; VAR_5 < yadif->csp->nb_components; VAR_5++) {
int w = VAR_1->video->w;
int h = VAR_1->video->h;
int refs = yadif->cur->linesize[VAR_5];
int df = (yadif->csp->comp[VAR_5].depth_minus1 + 8) / 8;
if (VAR_5 == 1 || VAR_5 == 2) {
w >>= yadif->csp->log2_chroma_w;
h >>= yadif->csp->log2_chroma_h;
}
for (VAR_4 = 0; VAR_4 < h; VAR_4++) {
if ((VAR_4 ^ VAR_2) & 1) {
uint8_t *prev = &yadif->prev->data[VAR_5][VAR_4*refs];
uint8_t *cur = &yadif->cur ->data[VAR_5][VAR_4*refs];
uint8_t *next = &yadif->next->data[VAR_5][VAR_4*refs];
uint8_t *dst = &VAR_1->data[VAR_5][VAR_4*VAR_1->linesize[VAR_5]];
int mode = VAR_4==1 || VAR_4+2==h ? 2 : yadif->mode;
yadif->filter_line(dst, prev, cur, next, w, VAR_4+1<h ? refs : -refs, VAR_4 ? -refs : refs, VAR_2 ^ VAR_3, mode);
} else {
memcpy(&VAR_1->data[VAR_5][VAR_4*VAR_1->linesize[VAR_5]],
&yadif->cur->data[VAR_5][VAR_4*refs], w*df);
}
}
}
emms_c();
}
| [
"static void FUNC_0(AVFilterContext *VAR_0, AVFilterBufferRef *VAR_1,\nint VAR_2, int VAR_3)\n{",
"YADIFContext *yadif = VAR_0->priv;",
"int VAR_4, VAR_5;",
"for (VAR_5 = 0; VAR_5 < yadif->csp->nb_components; VAR_5++) {",
"int w = VAR_1->video->w;",
"int h = VAR_1->video->h;",
"int refs = yadif->cur->linesize[VAR_5];",
"int df = (yadif->csp->comp[VAR_5].depth_minus1 + 8) / 8;",
"if (VAR_5 == 1 || VAR_5 == 2) {",
"w >>= yadif->csp->log2_chroma_w;",
"h >>= yadif->csp->log2_chroma_h;",
"}",
"for (VAR_4 = 0; VAR_4 < h; VAR_4++) {",
"if ((VAR_4 ^ VAR_2) & 1) {",
"uint8_t *prev = &yadif->prev->data[VAR_5][VAR_4*refs];",
"uint8_t *cur = &yadif->cur ->data[VAR_5][VAR_4*refs];",
"uint8_t *next = &yadif->next->data[VAR_5][VAR_4*refs];",
"uint8_t *dst = &VAR_1->data[VAR_5][VAR_4*VAR_1->linesize[VAR_5]];",
"int mode = VAR_4==1 || VAR_4+2==h ? 2 : yadif->mode;",
"yadif->filter_line(dst, prev, cur, next, w, VAR_4+1<h ? refs : -refs, VAR_4 ? -refs : refs, VAR_2 ^ VAR_3, mode);",
"} else {",
"memcpy(&VAR_1->data[VAR_5][VAR_4*VAR_1->linesize[VAR_5]],\n&yadif->cur->data[VAR_5][VAR_4*refs], w*df);",
"}",
"}",
"}",
"emms_c();",
"}"
] | [
0,
0,
0,
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
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
2,786 | static void vorbis_free_extradata(PayloadContext * data)
{
av_free(data);
}
| false | FFmpeg | 202a6697ba54293235ce2d7bd5724f4f461e417f | static void vorbis_free_extradata(PayloadContext * data)
{
av_free(data);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PayloadContext * VAR_0)
{
av_free(VAR_0);
}
| [
"static void FUNC_0(PayloadContext * VAR_0)\n{",
"av_free(VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
2,787 | static int dxva2_alloc(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
HANDLE device_handle;
HRESULT hr;
AVHWDeviceContext *device_ctx;
AVDXVA2DeviceContext *device_hwctx;
int ret;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = dxva2_uninit;
ist->hwaccel_get_buffer = dxva2_get_buffer;
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
ist->hwaccel_device, NULL, 0);
if (ret < 0)
goto fail;
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
&device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to open a device handle\n");
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
&IID_IDirectXVideoDecoderService,
(void **)&ctx->decoder_service);
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n");
goto fail;
}
ctx->tmp_frame = av_frame_alloc();
if (!ctx->tmp_frame)
goto fail;
s->hwaccel_context = av_mallocz(sizeof(struct dxva_context));
if (!s->hwaccel_context)
goto fail;
return 0;
fail:
dxva2_uninit(s);
return AVERROR(EINVAL);
}
| false | FFmpeg | 70143a3954e1c4412efb2bf1a3a818adea2d3abf | static int dxva2_alloc(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
HANDLE device_handle;
HRESULT hr;
AVHWDeviceContext *device_ctx;
AVDXVA2DeviceContext *device_hwctx;
int ret;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = dxva2_uninit;
ist->hwaccel_get_buffer = dxva2_get_buffer;
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
ist->hwaccel_device, NULL, 0);
if (ret < 0)
goto fail;
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
&device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to open a device handle\n");
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
&IID_IDirectXVideoDecoderService,
(void **)&ctx->decoder_service);
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n");
goto fail;
}
ctx->tmp_frame = av_frame_alloc();
if (!ctx->tmp_frame)
goto fail;
s->hwaccel_context = av_mallocz(sizeof(struct dxva_context));
if (!s->hwaccel_context)
goto fail;
return 0;
fail:
dxva2_uninit(s);
return AVERROR(EINVAL);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
InputStream *ist = VAR_0->opaque;
int VAR_1 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
HANDLE device_handle;
HRESULT hr;
AVHWDeviceContext *device_ctx;
AVDXVA2DeviceContext *device_hwctx;
int VAR_2;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = dxva2_uninit;
ist->hwaccel_get_buffer = dxva2_get_buffer;
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
VAR_2 = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
ist->hwaccel_device, NULL, 0);
if (VAR_2 < 0)
goto fail;
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
&device_handle);
if (FAILED(hr)) {
av_log(NULL, VAR_1, "Failed to open a device handle\n");
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
&IID_IDirectXVideoDecoderService,
(void **)&ctx->decoder_service);
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
if (FAILED(hr)) {
av_log(NULL, VAR_1, "Failed to create IDirectXVideoDecoderService\n");
goto fail;
}
ctx->tmp_frame = av_frame_alloc();
if (!ctx->tmp_frame)
goto fail;
VAR_0->hwaccel_context = av_mallocz(sizeof(struct dxva_context));
if (!VAR_0->hwaccel_context)
goto fail;
return 0;
fail:
dxva2_uninit(VAR_0);
return AVERROR(EINVAL);
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"InputStream *ist = VAR_0->opaque;",
"int VAR_1 = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;",
"DXVA2Context *ctx;",
"HANDLE device_handle;",
"HRESULT hr;",
"AVHWDeviceContext *device_ctx;",
"AVDXVA2DeviceContext *device_hwctx;",
"int VAR_2;",
"ctx = av_mallocz(sizeof(*ctx));",
"if (!ctx)\nreturn AVERROR(ENOMEM);",
"ist->hwaccel_ctx = ctx;",
"ist->hwaccel_uninit = dxva2_uninit;",
"ist->hwaccel_get_buffer = dxva2_get_buffer;",
"ist->hwaccel_retrieve_data = dxva2_retrieve_data;",
"VAR_2 = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,\nist->hwaccel_device, NULL, 0);",
"if (VAR_2 < 0)\ngoto fail;",
"device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;",
"device_hwctx = device_ctx->hwctx;",
"hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,\n&device_handle);",
"if (FAILED(hr)) {",
"av_log(NULL, VAR_1, \"Failed to open a device handle\\n\");",
"goto fail;",
"}",
"hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,\n&IID_IDirectXVideoDecoderService,\n(void **)&ctx->decoder_service);",
"IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);",
"if (FAILED(hr)) {",
"av_log(NULL, VAR_1, \"Failed to create IDirectXVideoDecoderService\\n\");",
"goto fail;",
"}",
"ctx->tmp_frame = av_frame_alloc();",
"if (!ctx->tmp_frame)\ngoto fail;",
"VAR_0->hwaccel_context = av_mallocz(sizeof(struct dxva_context));",
"if (!VAR_0->hwaccel_context)\ngoto fail;",
"return 0;",
"fail:\ndxva2_uninit(VAR_0);",
"return AVERROR(EINVAL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
97
],
[
99,
101
],
[
105
],
[
107,
109
],
[
111
],
[
113
]
] |
2,788 | static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
{
AMRContext *s = avctx->priv_data;
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return AVERROR(ENOSYS);
}
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return AVERROR(ENOSYS);
}
avctx->frame_size = 160;
avctx->initial_padding = 50;
ff_af_queue_init(avctx, &s->afq);
s->enc_state = Encoder_Interface_init(s->enc_dtx);
if (!s->enc_state) {
av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
av_freep(&avctx->coded_frame);
return -1;
}
s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
s->enc_bitrate = avctx->bit_rate;
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
{
AMRContext *s = avctx->priv_data;
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return AVERROR(ENOSYS);
}
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return AVERROR(ENOSYS);
}
avctx->frame_size = 160;
avctx->initial_padding = 50;
ff_af_queue_init(avctx, &s->afq);
s->enc_state = Encoder_Interface_init(s->enc_dtx);
if (!s->enc_state) {
av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
av_freep(&avctx->coded_frame);
return -1;
}
s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
s->enc_bitrate = avctx->bit_rate;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
AMRContext *s = avctx->priv_data;
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return AVERROR(ENOSYS);
}
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return AVERROR(ENOSYS);
}
avctx->frame_size = 160;
avctx->initial_padding = 50;
ff_af_queue_init(avctx, &s->afq);
s->enc_state = Encoder_Interface_init(s->enc_dtx);
if (!s->enc_state) {
av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
av_freep(&avctx->coded_frame);
return -1;
}
s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
s->enc_bitrate = avctx->bit_rate;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"AMRContext *s = avctx->priv_data;",
"if (avctx->sample_rate != 8000) {",
"av_log(avctx, AV_LOG_ERROR, \"Only 8000Hz sample rate supported\\n\");",
"return AVERROR(ENOSYS);",
"}",
"if (avctx->channels != 1) {",
"av_log(avctx, AV_LOG_ERROR, \"Only mono supported\\n\");",
"return AVERROR(ENOSYS);",
"}",
"avctx->frame_size = 160;",
"avctx->initial_padding = 50;",
"ff_af_queue_init(avctx, &s->afq);",
"s->enc_state = Encoder_Interface_init(s->enc_dtx);",
"if (!s->enc_state) {",
"av_log(avctx, AV_LOG_ERROR, \"Encoder_Interface_init error\\n\");",
"av_freep(&avctx->coded_frame);",
"return -1;",
"}",
"s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);",
"s->enc_bitrate = avctx->bit_rate;",
"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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
2,790 | static void avc_luma_mid_4w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height)
{
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8;
v8i16 dst0, dst1, dst2, dst3;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1, mask2);
hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1, mask2);
PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3);
hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
XORI_B4_128_SB(src0, src1, src2, src3);
hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1,
mask2);
hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1,
mask2);
PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8);
dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2,
hz_out3, hz_out4, hz_out5);
dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3,
hz_out4, hz_out5, hz_out6);
dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4,
hz_out5, hz_out6, hz_out7);
dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5,
hz_out6, hz_out7, hz_out8);
PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1);
XORI_B2_128_SB(src0, src1);
ST4x4_UB(src0, src1, 0, 2, 0, 2, dst, dst_stride);
dst += (4 * dst_stride);
hz_out0 = hz_out4;
hz_out1 = hz_out5;
hz_out2 = hz_out6;
hz_out3 = hz_out7;
hz_out4 = hz_out8;
}
}
| false | FFmpeg | e549933a270dd2cfc36f2cf9bb6b29acf3dc6d08 | static void avc_luma_mid_4w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height)
{
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8;
v8i16 dst0, dst1, dst2, dst3;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1, mask2);
hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1, mask2);
PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3);
hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
XORI_B4_128_SB(src0, src1, src2, src3);
hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1,
mask2);
hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1,
mask2);
PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8);
dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2,
hz_out3, hz_out4, hz_out5);
dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3,
hz_out4, hz_out5, hz_out6);
dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4,
hz_out5, hz_out6, hz_out7);
dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5,
hz_out6, hz_out7, hz_out8);
PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1);
XORI_B2_128_SB(src0, src1);
ST4x4_UB(src0, src1, 0, 2, 0, 2, dst, dst_stride);
dst += (4 * dst_stride);
hz_out0 = hz_out4;
hz_out1 = hz_out5;
hz_out2 = hz_out6;
hz_out3 = hz_out7;
hz_out4 = hz_out8;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,
uint8_t *VAR_2, int32_t VAR_3,
int32_t VAR_4)
{
uint32_t loop_cnt;
v16i8 src0, src1, src2, src3, src4;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, hz_out2, hz_out3;
v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8;
v8i16 dst0, dst1, dst2, dst3;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(VAR_0, VAR_1, src0, src1, src2, src3, src4);
VAR_0 += (5 * VAR_1);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1, mask2);
hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1, mask2);
PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3);
hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2);
for (loop_cnt = (VAR_4 >> 2); loop_cnt--;) {
LD_SB4(VAR_0, VAR_1, src0, src1, src2, src3);
VAR_0 += (4 * VAR_1);
XORI_B4_128_SB(src0, src1, src2, src3);
hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,
mask0, mask1,
mask2);
hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,
mask0, mask1,
mask2);
PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8);
dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2,
hz_out3, hz_out4, hz_out5);
dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3,
hz_out4, hz_out5, hz_out6);
dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4,
hz_out5, hz_out6, hz_out7);
dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5,
hz_out6, hz_out7, hz_out8);
PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1);
XORI_B2_128_SB(src0, src1);
ST4x4_UB(src0, src1, 0, 2, 0, 2, VAR_2, VAR_3);
VAR_2 += (4 * VAR_3);
hz_out0 = hz_out4;
hz_out1 = hz_out5;
hz_out2 = hz_out6;
hz_out3 = hz_out7;
hz_out4 = hz_out8;
}
}
| [
"static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,\nuint8_t *VAR_2, int32_t VAR_3,\nint32_t VAR_4)\n{",
"uint32_t loop_cnt;",
"v16i8 src0, src1, src2, src3, src4;",
"v16i8 mask0, mask1, mask2;",
"v8i16 hz_out0, hz_out1, hz_out2, hz_out3;",
"v8i16 hz_out4, hz_out5, hz_out6, hz_out7, hz_out8;",
"v8i16 dst0, dst1, dst2, dst3;",
"LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);",
"LD_SB5(VAR_0, VAR_1, src0, src1, src2, src3, src4);",
"VAR_0 += (5 * VAR_1);",
"XORI_B5_128_SB(src0, src1, src2, src3, src4);",
"hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,\nmask0, mask1, mask2);",
"hz_out2 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,\nmask0, mask1, mask2);",
"PCKOD_D2_SH(hz_out0, hz_out0, hz_out2, hz_out2, hz_out1, hz_out3);",
"hz_out4 = AVC_HORZ_FILTER_SH(src4, src4, mask0, mask1, mask2);",
"for (loop_cnt = (VAR_4 >> 2); loop_cnt--;) {",
"LD_SB4(VAR_0, VAR_1, src0, src1, src2, src3);",
"VAR_0 += (4 * VAR_1);",
"XORI_B4_128_SB(src0, src1, src2, src3);",
"hz_out5 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src0, src1,\nmask0, mask1,\nmask2);",
"hz_out7 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src2, src3,\nmask0, mask1,\nmask2);",
"PCKOD_D2_SH(hz_out5, hz_out5, hz_out7, hz_out7, hz_out6, hz_out8);",
"dst0 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out0, hz_out1, hz_out2,\nhz_out3, hz_out4, hz_out5);",
"dst1 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out1, hz_out2, hz_out3,\nhz_out4, hz_out5, hz_out6);",
"dst2 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out2, hz_out3, hz_out4,\nhz_out5, hz_out6, hz_out7);",
"dst3 = AVC_CALC_DPADD_H_6PIX_2COEFF_R_SH(hz_out3, hz_out4, hz_out5,\nhz_out6, hz_out7, hz_out8);",
"PCKEV_B2_SB(dst1, dst0, dst3, dst2, src0, src1);",
"XORI_B2_128_SB(src0, src1);",
"ST4x4_UB(src0, src1, 0, 2, 0, 2, VAR_2, VAR_3);",
"VAR_2 += (4 * VAR_3);",
"hz_out0 = hz_out4;",
"hz_out1 = hz_out5;",
"hz_out2 = hz_out6;",
"hz_out3 = hz_out7;",
"hz_out4 = hz_out8;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35,
37
],
[
39,
41
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65,
67,
69
],
[
71,
73,
75
],
[
79
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
101
],
[
103
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
]
] |
2,791 | static int svq1_motion_inter_4v_block(MpegEncContext *s, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int i, result;
/* predict and decode motion vector (0) */
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
/* predict and decode motion vector (1) */
pmv[0] = &mv;
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 3];
}
result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
if (result != 0)
return result;
/* predict and decode motion vector (2) */
pmv[1] = &motion[0];
pmv[2] = &motion[(x / 8) + 1];
result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
if (result != 0)
return result;
/* predict and decode motion vector (3) */
pmv[2] = &motion[(x / 8) + 2];
pmv[3] = &motion[(x / 8) + 3];
result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
if (result != 0)
return result;
/* form predictions */
for (i = 0; i < 4; i++) {
int mvx = pmv[i]->x + (i & 1) * 16;
int mvy = pmv[i]->y + (i >> 1) * 16;
// FIXME: clipping or padding?
if (y + (mvy >> 1) < 0)
mvy = 0;
if (x + (mvx >> 1) < 0)
mvx = 0;
src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
dst = current;
s->dsp.put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
/* select next block */
if (i & 1)
current += 8 * (pitch - 1);
else
current += 8;
}
return 0;
}
| false | FFmpeg | 7b9fc769e40a7709fa59a54e2a810f76364eee4b | static int svq1_motion_inter_4v_block(MpegEncContext *s, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int i, result;
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
pmv[0] = &mv;
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 3];
}
result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
if (result != 0)
return result;
pmv[1] = &motion[0];
pmv[2] = &motion[(x / 8) + 1];
result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
if (result != 0)
return result;
pmv[2] = &motion[(x / 8) + 2];
pmv[3] = &motion[(x / 8) + 3];
result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
if (result != 0)
return result;
for (i = 0; i < 4; i++) {
int mvx = pmv[i]->x + (i & 1) * 16;
int mvy = pmv[i]->y + (i >> 1) * 16;
if (y + (mvy >> 1) < 0)
mvy = 0;
if (x + (mvx >> 1) < 0)
mvx = 0;
src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
dst = current;
s->dsp.put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
if (i & 1)
current += 8 * (pitch - 1);
else
current += 8;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1,
uint8_t *VAR_2, uint8_t *VAR_3,
int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[4];
int VAR_8, VAR_9;
pmv[0] = &VAR_5[0];
if (VAR_7 == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &VAR_5[(VAR_6 / 8) + 2];
pmv[2] = &VAR_5[(VAR_6 / 8) + 4];
}
VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[0] = &mv;
if (VAR_7 == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &VAR_5[(VAR_6 / 8) + 3];
}
VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[1] = &VAR_5[0];
pmv[2] = &VAR_5[(VAR_6 / 8) + 1];
VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv);
if (VAR_9 != 0)
return VAR_9;
pmv[2] = &VAR_5[(VAR_6 / 8) + 2];
pmv[3] = &VAR_5[(VAR_6 / 8) + 3];
VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv);
if (VAR_9 != 0)
return VAR_9;
for (VAR_8 = 0; VAR_8 < 4; VAR_8++) {
int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8 & 1) * 16;
int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16;
if (VAR_7 + (VAR_11 >> 1) < 0)
VAR_11 = 0;
if (VAR_6 + (VAR_10 >> 1) < 0)
VAR_10 = 0;
src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4];
dst = VAR_2;
VAR_0->dsp.put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8);
if (VAR_8 & 1)
VAR_2 += 8 * (VAR_4 - 1);
else
VAR_2 += 8;
}
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1,\nuint8_t *VAR_2, uint8_t *VAR_3,\nint VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)\n{",
"uint8_t *src;",
"uint8_t *dst;",
"svq1_pmv mv;",
"svq1_pmv *pmv[4];",
"int VAR_8, VAR_9;",
"pmv[0] = &VAR_5[0];",
"if (VAR_7 == 0) {",
"pmv[1] =\npmv[2] = pmv[0];",
"} else {",
"pmv[1] = &VAR_5[(VAR_6 / 8) + 2];",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 4];",
"}",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[0] = &mv;",
"if (VAR_7 == 0) {",
"pmv[1] =\npmv[2] = pmv[0];",
"} else {",
"pmv[1] = &VAR_5[(VAR_6 / 8) + 3];",
"}",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[1] = &VAR_5[0];",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 1];",
"VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"pmv[2] = &VAR_5[(VAR_6 / 8) + 2];",
"pmv[3] = &VAR_5[(VAR_6 / 8) + 3];",
"VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv);",
"if (VAR_9 != 0)\nreturn VAR_9;",
"for (VAR_8 = 0; VAR_8 < 4; VAR_8++) {",
"int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8 & 1) * 16;",
"int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16;",
"if (VAR_7 + (VAR_11 >> 1) < 0)\nVAR_11 = 0;",
"if (VAR_6 + (VAR_10 >> 1) < 0)\nVAR_10 = 0;",
"src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4];",
"dst = VAR_2;",
"VAR_0->dsp.put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8);",
"if (VAR_8 & 1)\nVAR_2 += 8 * (VAR_4 - 1);",
"else\nVAR_2 += 8;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45,
47
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
79
],
[
81
],
[
85
],
[
89,
91
],
[
97
],
[
99
],
[
103
],
[
107,
109
],
[
115
],
[
117
],
[
119
],
[
125,
127
],
[
129,
131
],
[
135
],
[
137
],
[
141
],
[
147,
149
],
[
151,
153
],
[
155
],
[
159
],
[
161
]
] |
2,792 | int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
{
const uint8_t *p = buf_in;
const uint8_t *end = p + size;
const uint8_t *nal_start, *nal_end;
size = 0;
nal_start = ff_avc_find_startcode(p, end);
while (nal_start < end) {
while(!*(nal_start++));
nal_end = ff_avc_find_startcode(nal_start, end);
avio_wb32(pb, nal_end - nal_start);
avio_write(pb, nal_start, nal_end - nal_start);
size += 4 + nal_end - nal_start;
nal_start = nal_end;
}
return size;
}
| false | FFmpeg | 6c643e070584ba7af251d3907e277d2170537b1f | int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
{
const uint8_t *p = buf_in;
const uint8_t *end = p + size;
const uint8_t *nal_start, *nal_end;
size = 0;
nal_start = ff_avc_find_startcode(p, end);
while (nal_start < end) {
while(!*(nal_start++));
nal_end = ff_avc_find_startcode(nal_start, end);
avio_wb32(pb, nal_end - nal_start);
avio_write(pb, nal_start, nal_end - nal_start);
size += 4 + nal_end - nal_start;
nal_start = nal_end;
}
return size;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVIOContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
const uint8_t *VAR_3 = VAR_1;
const uint8_t *VAR_4 = VAR_3 + VAR_2;
const uint8_t *VAR_5, *nal_end;
VAR_2 = 0;
VAR_5 = ff_avc_find_startcode(VAR_3, VAR_4);
while (VAR_5 < VAR_4) {
while(!*(VAR_5++));
nal_end = ff_avc_find_startcode(VAR_5, VAR_4);
avio_wb32(VAR_0, nal_end - VAR_5);
avio_write(VAR_0, VAR_5, nal_end - VAR_5);
VAR_2 += 4 + nal_end - VAR_5;
VAR_5 = nal_end;
}
return VAR_2;
}
| [
"int FUNC_0(AVIOContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"const uint8_t *VAR_3 = VAR_1;",
"const uint8_t *VAR_4 = VAR_3 + VAR_2;",
"const uint8_t *VAR_5, *nal_end;",
"VAR_2 = 0;",
"VAR_5 = ff_avc_find_startcode(VAR_3, VAR_4);",
"while (VAR_5 < VAR_4) {",
"while(!*(VAR_5++));",
"nal_end = ff_avc_find_startcode(VAR_5, VAR_4);",
"avio_wb32(VAR_0, nal_end - VAR_5);",
"avio_write(VAR_0, VAR_5, nal_end - VAR_5);",
"VAR_2 += 4 + nal_end - VAR_5;",
"VAR_5 = nal_end;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
2,794 | static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
FLACParseContext *fpc = s->priv_data;
FLACHeaderMarker *curr;
int nb_headers;
int read_size = 0;
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
FLACFrameInfo fi;
if (frame_header_is_valid(avctx, buf, &fi))
avctx->frame_size = fi.blocksize;
*poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
fpc->avctx = avctx;
if (fpc->best_header_valid)
return get_best_header(fpc, poutbuf, poutbuf_size);
/* If a best_header was found last call remove it with the buffer data. */
if (fpc->best_header && fpc->best_header->best_child) {
FLACHeaderMarker *temp;
FLACHeaderMarker *best_child = fpc->best_header->best_child;
/* Remove headers in list until the end of the best_header. */
for (curr = fpc->headers; curr != best_child; curr = temp) {
if (curr != fpc->best_header) {
av_log(avctx, AV_LOG_DEBUG,
"dropping low score %i frame header from offset %i to %i\n",
curr->max_score, curr->offset, curr->next->offset);
}
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
fpc->nb_headers_buffered--;
}
/* Release returned data from ring buffer. */
av_fifo_drain(fpc->fifo_buf, best_child->offset);
/* Fix the offset for the headers remaining to match the new buffer. */
for (curr = best_child->next; curr; curr = curr->next)
curr->offset -= best_child->offset;
fpc->nb_headers_buffered--;
best_child->offset = 0;
fpc->headers = best_child;
if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {
fpc->best_header = best_child;
return get_best_header(fpc, poutbuf, poutbuf_size);
}
fpc->best_header = NULL;
} else if (fpc->best_header) {
/* No end frame no need to delete the buffer; probably eof */
FLACHeaderMarker *temp;
for (curr = fpc->headers; curr != fpc->best_header; curr = temp) {
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
}
fpc->headers = fpc->best_header->next;
av_freep(&fpc->best_header->link_penalty);
av_freep(&fpc->best_header);
}
/* Find and score new headers. */
if (buf_size || !fpc->end_padded) {
int start_offset;
/* Pad the end once if EOF, to check the final region for headers. */
if (!buf_size) {
fpc->end_padded = 1;
buf_size = read_size = MAX_FRAME_HEADER_SIZE;
} else {
/* The maximum read size is the upper-bound of what the parser
needs to have the required number of frames buffered */
int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;
read_size = FFMIN(buf_size, nb_desired * FLAC_AVG_FRAME_SIZE);
}
/* Fill the buffer. */
if (av_fifo_realloc2(fpc->fifo_buf,
read_size + av_fifo_size(fpc->fifo_buf)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"couldn't reallocate buffer of size %d\n",
read_size + av_fifo_size(fpc->fifo_buf));
goto handle_error;
}
if (buf) {
av_fifo_generic_write(fpc->fifo_buf, (void*) buf, read_size, NULL);
} else {
int8_t pad[MAX_FRAME_HEADER_SIZE];
memset(pad, 0, sizeof(pad));
av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);
}
/* Tag headers and update sequences. */
start_offset = av_fifo_size(fpc->fifo_buf) -
(read_size + (MAX_FRAME_HEADER_SIZE - 1));
start_offset = FFMAX(0, start_offset);
nb_headers = find_new_headers(fpc, start_offset);
if (nb_headers < 0) {
av_log(avctx, AV_LOG_ERROR,
"find_new_headers couldn't allocate FLAC header\n");
goto handle_error;
}
fpc->nb_headers_buffered = nb_headers;
/* Wait till FLAC_MIN_HEADERS to output a valid frame. */
if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS)
goto handle_error;
/* If headers found, update the scores since we have longer chains. */
if (fpc->end_padded || fpc->nb_headers_found)
score_sequences(fpc);
/* restore the state pre-padding */
if (fpc->end_padded) {
/* HACK: drain the tail of the fifo */
fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
if (fpc->fifo_buf->wptr < 0) {
fpc->fifo_buf->wptr += fpc->fifo_buf->end -
fpc->fifo_buf->buffer;
}
buf_size = read_size = 0;
}
}
curr = fpc->headers;
for (curr = fpc->headers; curr; curr = curr->next)
if (!fpc->best_header || curr->max_score > fpc->best_header->max_score)
fpc->best_header = curr;
if (fpc->best_header) {
fpc->best_header_valid = 1;
if (fpc->best_header->offset > 0) {
/* Output a junk frame. */
av_log(avctx, AV_LOG_DEBUG, "Junk frame till offset %i\n",
fpc->best_header->offset);
/* Set frame_size to 0. It is unknown or invalid in a junk frame. */
avctx->frame_size = 0;
*poutbuf_size = fpc->best_header->offset;
*poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size,
&fpc->wrap_buf,
&fpc->wrap_buf_allocated_size);
return buf_size ? read_size : (fpc->best_header->offset -
av_fifo_size(fpc->fifo_buf));
}
if (!buf_size)
return get_best_header(fpc, poutbuf, poutbuf_size);
}
handle_error:
*poutbuf = NULL;
*poutbuf_size = 0;
return read_size;
}
| false | FFmpeg | 4b5d4720c1c46e8a80b945854a6dec5f681e11c0 | static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
FLACParseContext *fpc = s->priv_data;
FLACHeaderMarker *curr;
int nb_headers;
int read_size = 0;
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
FLACFrameInfo fi;
if (frame_header_is_valid(avctx, buf, &fi))
avctx->frame_size = fi.blocksize;
*poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
fpc->avctx = avctx;
if (fpc->best_header_valid)
return get_best_header(fpc, poutbuf, poutbuf_size);
if (fpc->best_header && fpc->best_header->best_child) {
FLACHeaderMarker *temp;
FLACHeaderMarker *best_child = fpc->best_header->best_child;
for (curr = fpc->headers; curr != best_child; curr = temp) {
if (curr != fpc->best_header) {
av_log(avctx, AV_LOG_DEBUG,
"dropping low score %i frame header from offset %i to %i\n",
curr->max_score, curr->offset, curr->next->offset);
}
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
fpc->nb_headers_buffered--;
}
av_fifo_drain(fpc->fifo_buf, best_child->offset);
for (curr = best_child->next; curr; curr = curr->next)
curr->offset -= best_child->offset;
fpc->nb_headers_buffered--;
best_child->offset = 0;
fpc->headers = best_child;
if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {
fpc->best_header = best_child;
return get_best_header(fpc, poutbuf, poutbuf_size);
}
fpc->best_header = NULL;
} else if (fpc->best_header) {
FLACHeaderMarker *temp;
for (curr = fpc->headers; curr != fpc->best_header; curr = temp) {
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
}
fpc->headers = fpc->best_header->next;
av_freep(&fpc->best_header->link_penalty);
av_freep(&fpc->best_header);
}
if (buf_size || !fpc->end_padded) {
int start_offset;
if (!buf_size) {
fpc->end_padded = 1;
buf_size = read_size = MAX_FRAME_HEADER_SIZE;
} else {
int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;
read_size = FFMIN(buf_size, nb_desired * FLAC_AVG_FRAME_SIZE);
}
if (av_fifo_realloc2(fpc->fifo_buf,
read_size + av_fifo_size(fpc->fifo_buf)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"couldn't reallocate buffer of size %d\n",
read_size + av_fifo_size(fpc->fifo_buf));
goto handle_error;
}
if (buf) {
av_fifo_generic_write(fpc->fifo_buf, (void*) buf, read_size, NULL);
} else {
int8_t pad[MAX_FRAME_HEADER_SIZE];
memset(pad, 0, sizeof(pad));
av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);
}
start_offset = av_fifo_size(fpc->fifo_buf) -
(read_size + (MAX_FRAME_HEADER_SIZE - 1));
start_offset = FFMAX(0, start_offset);
nb_headers = find_new_headers(fpc, start_offset);
if (nb_headers < 0) {
av_log(avctx, AV_LOG_ERROR,
"find_new_headers couldn't allocate FLAC header\n");
goto handle_error;
}
fpc->nb_headers_buffered = nb_headers;
if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS)
goto handle_error;
if (fpc->end_padded || fpc->nb_headers_found)
score_sequences(fpc);
if (fpc->end_padded) {
fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
if (fpc->fifo_buf->wptr < 0) {
fpc->fifo_buf->wptr += fpc->fifo_buf->end -
fpc->fifo_buf->buffer;
}
buf_size = read_size = 0;
}
}
curr = fpc->headers;
for (curr = fpc->headers; curr; curr = curr->next)
if (!fpc->best_header || curr->max_score > fpc->best_header->max_score)
fpc->best_header = curr;
if (fpc->best_header) {
fpc->best_header_valid = 1;
if (fpc->best_header->offset > 0) {
av_log(avctx, AV_LOG_DEBUG, "Junk frame till offset %i\n",
fpc->best_header->offset);
avctx->frame_size = 0;
*poutbuf_size = fpc->best_header->offset;
*poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size,
&fpc->wrap_buf,
&fpc->wrap_buf_allocated_size);
return buf_size ? read_size : (fpc->best_header->offset -
av_fifo_size(fpc->fifo_buf));
}
if (!buf_size)
return get_best_header(fpc, poutbuf, poutbuf_size);
}
handle_error:
*poutbuf = NULL;
*poutbuf_size = 0;
return read_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,
const uint8_t **VAR_2, int *VAR_3,
const uint8_t *VAR_4, int VAR_5)
{
FLACParseContext *fpc = VAR_0->priv_data;
FLACHeaderMarker *curr;
int VAR_6;
int VAR_7 = 0;
if (VAR_0->flags & PARSER_FLAG_COMPLETE_FRAMES) {
FLACFrameInfo fi;
if (frame_header_is_valid(VAR_1, VAR_4, &fi))
VAR_1->frame_size = fi.blocksize;
*VAR_2 = VAR_4;
*VAR_3 = VAR_5;
return VAR_5;
}
fpc->VAR_1 = VAR_1;
if (fpc->best_header_valid)
return get_best_header(fpc, VAR_2, VAR_3);
if (fpc->best_header && fpc->best_header->best_child) {
FLACHeaderMarker *temp;
FLACHeaderMarker *best_child = fpc->best_header->best_child;
for (curr = fpc->headers; curr != best_child; curr = temp) {
if (curr != fpc->best_header) {
av_log(VAR_1, AV_LOG_DEBUG,
"dropping low score %i frame header from offset %i to %i\n",
curr->max_score, curr->offset, curr->next->offset);
}
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
fpc->nb_headers_buffered--;
}
av_fifo_drain(fpc->fifo_buf, best_child->offset);
for (curr = best_child->next; curr; curr = curr->next)
curr->offset -= best_child->offset;
fpc->nb_headers_buffered--;
best_child->offset = 0;
fpc->headers = best_child;
if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {
fpc->best_header = best_child;
return get_best_header(fpc, VAR_2, VAR_3);
}
fpc->best_header = NULL;
} else if (fpc->best_header) {
FLACHeaderMarker *temp;
for (curr = fpc->headers; curr != fpc->best_header; curr = temp) {
temp = curr->next;
av_freep(&curr->link_penalty);
av_free(curr);
}
fpc->headers = fpc->best_header->next;
av_freep(&fpc->best_header->link_penalty);
av_freep(&fpc->best_header);
}
if (VAR_5 || !fpc->end_padded) {
int VAR_8;
if (!VAR_5) {
fpc->end_padded = 1;
VAR_5 = VAR_7 = MAX_FRAME_HEADER_SIZE;
} else {
int VAR_9 = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;
VAR_7 = FFMIN(VAR_5, VAR_9 * FLAC_AVG_FRAME_SIZE);
}
if (av_fifo_realloc2(fpc->fifo_buf,
VAR_7 + av_fifo_size(fpc->fifo_buf)) < 0) {
av_log(VAR_1, AV_LOG_ERROR,
"couldn't reallocate buffer of size %d\n",
VAR_7 + av_fifo_size(fpc->fifo_buf));
goto handle_error;
}
if (VAR_4) {
av_fifo_generic_write(fpc->fifo_buf, (void*) VAR_4, VAR_7, NULL);
} else {
int8_t pad[MAX_FRAME_HEADER_SIZE];
memset(pad, 0, sizeof(pad));
av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);
}
VAR_8 = av_fifo_size(fpc->fifo_buf) -
(VAR_7 + (MAX_FRAME_HEADER_SIZE - 1));
VAR_8 = FFMAX(0, VAR_8);
VAR_6 = find_new_headers(fpc, VAR_8);
if (VAR_6 < 0) {
av_log(VAR_1, AV_LOG_ERROR,
"find_new_headers couldn't allocate FLAC header\n");
goto handle_error;
}
fpc->nb_headers_buffered = VAR_6;
if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS)
goto handle_error;
if (fpc->end_padded || fpc->nb_headers_found)
score_sequences(fpc);
if (fpc->end_padded) {
fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
if (fpc->fifo_buf->wptr < 0) {
fpc->fifo_buf->wptr += fpc->fifo_buf->end -
fpc->fifo_buf->buffer;
}
VAR_5 = VAR_7 = 0;
}
}
curr = fpc->headers;
for (curr = fpc->headers; curr; curr = curr->next)
if (!fpc->best_header || curr->max_score > fpc->best_header->max_score)
fpc->best_header = curr;
if (fpc->best_header) {
fpc->best_header_valid = 1;
if (fpc->best_header->offset > 0) {
av_log(VAR_1, AV_LOG_DEBUG, "Junk frame till offset %i\n",
fpc->best_header->offset);
VAR_1->frame_size = 0;
*VAR_3 = fpc->best_header->offset;
*VAR_2 = flac_fifo_read_wrap(fpc, 0, *VAR_3,
&fpc->wrap_buf,
&fpc->wrap_buf_allocated_size);
return VAR_5 ? VAR_7 : (fpc->best_header->offset -
av_fifo_size(fpc->fifo_buf));
}
if (!VAR_5)
return get_best_header(fpc, VAR_2, VAR_3);
}
handle_error:
*VAR_2 = NULL;
*VAR_3 = 0;
return VAR_7;
}
| [
"static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,\nconst uint8_t **VAR_2, int *VAR_3,\nconst uint8_t *VAR_4, int VAR_5)\n{",
"FLACParseContext *fpc = VAR_0->priv_data;",
"FLACHeaderMarker *curr;",
"int VAR_6;",
"int VAR_7 = 0;",
"if (VAR_0->flags & PARSER_FLAG_COMPLETE_FRAMES) {",
"FLACFrameInfo fi;",
"if (frame_header_is_valid(VAR_1, VAR_4, &fi))\nVAR_1->frame_size = fi.blocksize;",
"*VAR_2 = VAR_4;",
"*VAR_3 = VAR_5;",
"return VAR_5;",
"}",
"fpc->VAR_1 = VAR_1;",
"if (fpc->best_header_valid)\nreturn get_best_header(fpc, VAR_2, VAR_3);",
"if (fpc->best_header && fpc->best_header->best_child) {",
"FLACHeaderMarker *temp;",
"FLACHeaderMarker *best_child = fpc->best_header->best_child;",
"for (curr = fpc->headers; curr != best_child; curr = temp) {",
"if (curr != fpc->best_header) {",
"av_log(VAR_1, AV_LOG_DEBUG,\n\"dropping low score %i frame header from offset %i to %i\\n\",\ncurr->max_score, curr->offset, curr->next->offset);",
"}",
"temp = curr->next;",
"av_freep(&curr->link_penalty);",
"av_free(curr);",
"fpc->nb_headers_buffered--;",
"}",
"av_fifo_drain(fpc->fifo_buf, best_child->offset);",
"for (curr = best_child->next; curr; curr = curr->next)",
"curr->offset -= best_child->offset;",
"fpc->nb_headers_buffered--;",
"best_child->offset = 0;",
"fpc->headers = best_child;",
"if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {",
"fpc->best_header = best_child;",
"return get_best_header(fpc, VAR_2, VAR_3);",
"}",
"fpc->best_header = NULL;",
"} else if (fpc->best_header) {",
"FLACHeaderMarker *temp;",
"for (curr = fpc->headers; curr != fpc->best_header; curr = temp) {",
"temp = curr->next;",
"av_freep(&curr->link_penalty);",
"av_free(curr);",
"}",
"fpc->headers = fpc->best_header->next;",
"av_freep(&fpc->best_header->link_penalty);",
"av_freep(&fpc->best_header);",
"}",
"if (VAR_5 || !fpc->end_padded) {",
"int VAR_8;",
"if (!VAR_5) {",
"fpc->end_padded = 1;",
"VAR_5 = VAR_7 = MAX_FRAME_HEADER_SIZE;",
"} else {",
"int VAR_9 = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;",
"VAR_7 = FFMIN(VAR_5, VAR_9 * FLAC_AVG_FRAME_SIZE);",
"}",
"if (av_fifo_realloc2(fpc->fifo_buf,\nVAR_7 + av_fifo_size(fpc->fifo_buf)) < 0) {",
"av_log(VAR_1, AV_LOG_ERROR,\n\"couldn't reallocate buffer of size %d\\n\",\nVAR_7 + av_fifo_size(fpc->fifo_buf));",
"goto handle_error;",
"}",
"if (VAR_4) {",
"av_fifo_generic_write(fpc->fifo_buf, (void*) VAR_4, VAR_7, NULL);",
"} else {",
"int8_t pad[MAX_FRAME_HEADER_SIZE];",
"memset(pad, 0, sizeof(pad));",
"av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);",
"}",
"VAR_8 = av_fifo_size(fpc->fifo_buf) -\n(VAR_7 + (MAX_FRAME_HEADER_SIZE - 1));",
"VAR_8 = FFMAX(0, VAR_8);",
"VAR_6 = find_new_headers(fpc, VAR_8);",
"if (VAR_6 < 0) {",
"av_log(VAR_1, AV_LOG_ERROR,\n\"find_new_headers couldn't allocate FLAC header\\n\");",
"goto handle_error;",
"}",
"fpc->nb_headers_buffered = VAR_6;",
"if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS)\ngoto handle_error;",
"if (fpc->end_padded || fpc->nb_headers_found)\nscore_sequences(fpc);",
"if (fpc->end_padded) {",
"fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;",
"fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;",
"if (fpc->fifo_buf->wptr < 0) {",
"fpc->fifo_buf->wptr += fpc->fifo_buf->end -\nfpc->fifo_buf->buffer;",
"}",
"VAR_5 = VAR_7 = 0;",
"}",
"}",
"curr = fpc->headers;",
"for (curr = fpc->headers; curr; curr = curr->next)",
"if (!fpc->best_header || curr->max_score > fpc->best_header->max_score)\nfpc->best_header = curr;",
"if (fpc->best_header) {",
"fpc->best_header_valid = 1;",
"if (fpc->best_header->offset > 0) {",
"av_log(VAR_1, AV_LOG_DEBUG, \"Junk frame till offset %i\\n\",\nfpc->best_header->offset);",
"VAR_1->frame_size = 0;",
"*VAR_3 = fpc->best_header->offset;",
"*VAR_2 = flac_fifo_read_wrap(fpc, 0, *VAR_3,\n&fpc->wrap_buf,\n&fpc->wrap_buf_allocated_size);",
"return VAR_5 ? VAR_7 : (fpc->best_header->offset -\nav_fifo_size(fpc->fifo_buf));",
"}",
"if (!VAR_5)\nreturn get_best_header(fpc, VAR_2, VAR_3);",
"}",
"handle_error:\n*VAR_2 = NULL;",
"*VAR_3 = 0;",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
139
],
[
141
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
169,
171
],
[
173,
175,
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
203,
205
],
[
207
],
[
209
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
225
],
[
229,
231
],
[
237,
239
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273,
275
],
[
279
],
[
281
],
[
283
],
[
287,
289
],
[
295
],
[
297
],
[
299,
301,
303
],
[
305,
307
],
[
309
],
[
311,
313
],
[
315
],
[
319,
321
],
[
323
],
[
325
],
[
327
]
] |
2,796 | void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
{
if (s->chr_read) {
s->chr_read(s->handler_opaque, buf, len);
}
}
| false | qemu | 33577b47c64435fcc2a1bc01c7e82534256f1fc3 | void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
{
if (s->chr_read) {
s->chr_read(s->handler_opaque, buf, len);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CharDriverState *VAR_0, uint8_t *VAR_1, int VAR_2)
{
if (VAR_0->chr_read) {
VAR_0->chr_read(VAR_0->handler_opaque, VAR_1, VAR_2);
}
}
| [
"void FUNC_0(CharDriverState *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"if (VAR_0->chr_read) {",
"VAR_0->chr_read(VAR_0->handler_opaque, VAR_1, VAR_2);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.