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
|
---|---|---|---|---|---|---|---|---|---|---|
25,259 | static int qdev_add_one_global(QemuOpts *opts, void *opaque)
{
GlobalProperty *g;
ObjectClass *oc;
g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
oc = object_class_by_name(g->driver);
if (oc) {
DeviceClass *dc = DEVICE_CLASS(oc);
if (dc->hotpluggable) {
/* If hotpluggable then skip not_used checking. */
g->not_used = false;
} else {
/* Maybe a typo. */
g->not_used = true;
}
} else {
/* Maybe a typo. */
g->not_used = true;
}
qdev_prop_register_global(g);
return 0;
}
| true | qemu | dd98b71f4885814de9a64e7acc0e17b38ab7c38b | static int qdev_add_one_global(QemuOpts *opts, void *opaque)
{
GlobalProperty *g;
ObjectClass *oc;
g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
oc = object_class_by_name(g->driver);
if (oc) {
DeviceClass *dc = DEVICE_CLASS(oc);
if (dc->hotpluggable) {
g->not_used = false;
} else {
g->not_used = true;
}
} else {
g->not_used = true;
}
qdev_prop_register_global(g);
return 0;
}
| {
"code": [
" oc = object_class_by_name(g->driver);"
],
"line_no": [
19
]
} | static int FUNC_0(QemuOpts *VAR_0, void *VAR_1)
{
GlobalProperty *g;
ObjectClass *oc;
g = g_malloc0(sizeof(*g));
g->driver = qemu_opt_get(VAR_0, "driver");
g->property = qemu_opt_get(VAR_0, "property");
g->value = qemu_opt_get(VAR_0, "value");
oc = object_class_by_name(g->driver);
if (oc) {
DeviceClass *dc = DEVICE_CLASS(oc);
if (dc->hotpluggable) {
g->not_used = false;
} else {
g->not_used = true;
}
} else {
g->not_used = true;
}
qdev_prop_register_global(g);
return 0;
}
| [
"static int FUNC_0(QemuOpts *VAR_0, void *VAR_1)\n{",
"GlobalProperty *g;",
"ObjectClass *oc;",
"g = g_malloc0(sizeof(*g));",
"g->driver = qemu_opt_get(VAR_0, \"driver\");",
"g->property = qemu_opt_get(VAR_0, \"property\");",
"g->value = qemu_opt_get(VAR_0, \"value\");",
"oc = object_class_by_name(g->driver);",
"if (oc) {",
"DeviceClass *dc = DEVICE_CLASS(oc);",
"if (dc->hotpluggable) {",
"g->not_used = false;",
"} else {",
"g->not_used = true;",
"}",
"} else {",
"g->not_used = true;",
"}",
"qdev_prop_register_global(g);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
25,261 | void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
const ptrdiff_t dst_pitch)
{
int x, y, indx;
int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;
int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
ptrdiff_t pitch, back_pitch;
const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
const int num_bands = 4;
/* all bands should have the same pitch */
pitch = plane->bands[0].pitch;
/* pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration */
back_pitch = 0;
/* get pointers to the wavelet bands */
b0_ptr = plane->bands[0].buf;
b1_ptr = plane->bands[1].buf;
b2_ptr = plane->bands[2].buf;
b3_ptr = plane->bands[3].buf;
for (y = 0; y < plane->height; y += 2) {
if (y+2 >= plane->height)
pitch= 0;
/* load storage variables with values */
if (num_bands > 0) {
b0_1 = b0_ptr[0];
b0_2 = b0_ptr[pitch];
}
if (num_bands > 1) {
b1_1 = b1_ptr[back_pitch];
b1_2 = b1_ptr[0];
b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch];
}
if (num_bands > 2) {
b2_2 = b2_ptr[0]; // b2[x, y ]
b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
b2_5 = b2_ptr[pitch]; // b2[x ,y+1]
b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
}
if (num_bands > 3) {
b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
b3_5 = b3_ptr[0]; // b3[x ,y ]
b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch];
b3_9 = b3_8;
}
for (x = 0, indx = 0; x < plane->width; x+=2, indx++) {
if (x+2 >= plane->width) {
b0_ptr --;
b1_ptr --;
b2_ptr --;
b3_ptr --;
}
/* some values calculated in the previous iterations can */
/* be reused in the next ones, so do appropriate copying */
b2_1 = b2_2; // b2[x-1,y ] = b2[x, y ]
b2_2 = b2_3; // b2[x ,y ] = b2[x+1,y ]
b2_4 = b2_5; // b2[x-1,y+1] = b2[x ,y+1]
b2_5 = b2_6; // b2[x ,y+1] = b2[x+1,y+1]
b3_1 = b3_2; // b3[x-1,y-1] = b3[x ,y-1]
b3_2 = b3_3; // b3[x ,y-1] = b3[x+1,y-1]
b3_4 = b3_5; // b3[x-1,y ] = b3[x ,y ]
b3_5 = b3_6; // b3[x ,y ] = b3[x+1,y ]
b3_7 = b3_8; // vert_HPF(x-1)
b3_8 = b3_9; // vert_HPF(x )
p0 = p1 = p2 = p3 = 0;
/* process the LL-band by applying LPF both vertically and horizontally */
if (num_bands > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
b0_1 = b0_ptr[indx+1];
b0_2 = b0_ptr[pitch+indx+1];
tmp1 = tmp0 + b0_1;
p0 = tmp0 << 4;
p1 = tmp1 << 3;
p2 = (tmp0 + tmp2) << 3;
p3 = (tmp1 + tmp2 + b0_2) << 2;
}
/* process the HL-band by applying HPF vertically and LPF horizontally */
if (num_bands > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
b1_2 = b1_ptr[indx+1];
b1_1 = b1_ptr[back_pitch+indx+1];
tmp2 = tmp1 - tmp0*6 + b1_3;
b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1];
p0 += (tmp0 + tmp1) << 3;
p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
p2 += tmp2 << 2;
p3 += (tmp2 + b1_3) << 1;
}
/* process the LH-band by applying LPF vertically and HPF horizontally */
if (num_bands > 2) {
b2_3 = b2_ptr[indx+1];
b2_6 = b2_ptr[pitch+indx+1];
tmp0 = b2_1 + b2_2;
tmp1 = b2_1 - b2_2*6 + b2_3;
p0 += tmp0 << 3;
p1 += tmp1 << 2;
p2 += (tmp0 + b2_4 + b2_5) << 2;
p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;
}
/* process the HH-band by applying HPF both vertically and horizontally */
if (num_bands > 3) {
b3_6 = b3_ptr[indx+1]; // b3[x+1,y ]
b3_3 = b3_ptr[back_pitch+indx+1]; // b3[x+1,y-1]
tmp0 = b3_1 + b3_4;
tmp1 = b3_2 + b3_5;
tmp2 = b3_3 + b3_6;
b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1];
p0 += (tmp0 + tmp1) << 2;
p1 += (tmp0 - tmp1*6 + tmp2) << 1;
p2 += (b3_7 + b3_8) << 1;
p3 += b3_7 - b3_8*6 + b3_9;
}
/* output four pixels */
dst[x] = av_clip_uint8((p0 >> 6) + 128);
dst[x+1] = av_clip_uint8((p1 >> 6) + 128);
dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128);
dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128);
}// for x
dst += dst_pitch << 1;
back_pitch = -pitch;
b0_ptr += pitch + 1;
b1_ptr += pitch + 1;
b2_ptr += pitch + 1;
b3_ptr += pitch + 1;
}
}
| true | FFmpeg | 8fb00b3e858b7a5aeccfe6bdfc10290c2121c3ec | void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
const ptrdiff_t dst_pitch)
{
int x, y, indx;
int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;
int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
ptrdiff_t pitch, back_pitch;
const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
const int num_bands = 4;
pitch = plane->bands[0].pitch;
back_pitch = 0;
b0_ptr = plane->bands[0].buf;
b1_ptr = plane->bands[1].buf;
b2_ptr = plane->bands[2].buf;
b3_ptr = plane->bands[3].buf;
for (y = 0; y < plane->height; y += 2) {
if (y+2 >= plane->height)
pitch= 0;
if (num_bands > 0) {
b0_1 = b0_ptr[0];
b0_2 = b0_ptr[pitch];
}
if (num_bands > 1) {
b1_1 = b1_ptr[back_pitch];
b1_2 = b1_ptr[0];
b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch];
}
if (num_bands > 2) {
b2_2 = b2_ptr[0];
b2_3 = b2_2;
b2_5 = b2_ptr[pitch];
b2_6 = b2_5;
}
if (num_bands > 3) {
b3_2 = b3_ptr[back_pitch];
b3_3 = b3_2;
b3_5 = b3_ptr[0];
b3_6 = b3_5;
b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch];
b3_9 = b3_8;
}
for (x = 0, indx = 0; x < plane->width; x+=2, indx++) {
if (x+2 >= plane->width) {
b0_ptr --;
b1_ptr --;
b2_ptr --;
b3_ptr --;
}
b2_1 = b2_2;
b2_2 = b2_3;
b2_4 = b2_5;
b2_5 = b2_6; = b2[x+1,y+1]
b3_1 = b3_2;
b3_2 = b3_3; = b3[x+1,y-1]
b3_4 = b3_5;
b3_5 = b3_6; = b3[x+1,y ]
b3_7 = b3_8;
b3_8 = b3_9;
p0 = p1 = p2 = p3 = 0;
if (num_bands > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
b0_1 = b0_ptr[indx+1];
b0_2 = b0_ptr[pitch+indx+1];
tmp1 = tmp0 + b0_1;
p0 = tmp0 << 4;
p1 = tmp1 << 3;
p2 = (tmp0 + tmp2) << 3;
p3 = (tmp1 + tmp2 + b0_2) << 2;
}
if (num_bands > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
b1_2 = b1_ptr[indx+1];
b1_1 = b1_ptr[back_pitch+indx+1];
tmp2 = tmp1 - tmp0*6 + b1_3;
b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1];
p0 += (tmp0 + tmp1) << 3;
p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
p2 += tmp2 << 2;
p3 += (tmp2 + b1_3) << 1;
}
if (num_bands > 2) {
b2_3 = b2_ptr[indx+1];
b2_6 = b2_ptr[pitch+indx+1];
tmp0 = b2_1 + b2_2;
tmp1 = b2_1 - b2_2*6 + b2_3;
p0 += tmp0 << 3;
p1 += tmp1 << 2;
p2 += (tmp0 + b2_4 + b2_5) << 2;
p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;
}
if (num_bands > 3) {
b3_6 = b3_ptr[indx+1];
b3_3 = b3_ptr[back_pitch+indx+1];
tmp0 = b3_1 + b3_4;
tmp1 = b3_2 + b3_5;
tmp2 = b3_3 + b3_6;
b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1];
p0 += (tmp0 + tmp1) << 2;
p1 += (tmp0 - tmp1*6 + tmp2) << 1;
p2 += (b3_7 + b3_8) << 1;
p3 += b3_7 - b3_8*6 + b3_9;
}
dst[x] = av_clip_uint8((p0 >> 6) + 128);
dst[x+1] = av_clip_uint8((p1 >> 6) + 128);
dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128);
dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128);
}
dst += dst_pitch << 1;
back_pitch = -pitch;
b0_ptr += pitch + 1;
b1_ptr += pitch + 1;
b2_ptr += pitch + 1;
b3_ptr += pitch + 1;
}
}
| {
"code": [
" p0 = tmp0 << 4;",
" p1 = tmp1 << 3;",
" p2 = (tmp0 + tmp2) << 3;",
" p3 = (tmp1 + tmp2 + b0_2) << 2;",
" p0 += (tmp0 + tmp1) << 3;",
" p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;",
" p2 += tmp2 << 2;",
" p3 += (tmp2 + b1_3) << 1;",
" p0 += tmp0 << 3;",
" p1 += tmp1 << 2;",
" p2 += (tmp0 + b2_4 + b2_5) << 2;",
" p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;",
" p0 += (tmp0 + tmp1) << 2;",
" p1 += (tmp0 - tmp1*6 + tmp2) << 1;",
" p2 += (b3_7 + b3_8) << 1;"
],
"line_no": [
173,
175,
177,
179,
205,
207,
209,
211,
233,
235,
237,
239,
267,
269,
271
]
} | void FUNC_0(const IVIPlaneDesc *VAR_0, uint8_t *VAR_1,
const ptrdiff_t VAR_2)
{
int VAR_3, VAR_4, VAR_5;
int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;
int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
ptrdiff_t pitch, back_pitch;
const short *VAR_6, *VAR_7, *VAR_8, *VAR_9;
const int VAR_10 = 4;
pitch = VAR_0->bands[0].pitch;
back_pitch = 0;
VAR_6 = VAR_0->bands[0].buf;
VAR_7 = VAR_0->bands[1].buf;
VAR_8 = VAR_0->bands[2].buf;
VAR_9 = VAR_0->bands[3].buf;
for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4 += 2) {
if (VAR_4+2 >= VAR_0->height)
pitch= 0;
if (VAR_10 > 0) {
b0_1 = VAR_6[0];
b0_2 = VAR_6[pitch];
}
if (VAR_10 > 1) {
b1_1 = VAR_7[back_pitch];
b1_2 = VAR_7[0];
b1_3 = b1_1 - b1_2*6 + VAR_7[pitch];
}
if (VAR_10 > 2) {
b2_2 = VAR_8[0];
b2_3 = b2_2;
b2_5 = VAR_8[pitch];
b2_6 = b2_5;
}
if (VAR_10 > 3) {
b3_2 = VAR_9[back_pitch];
b3_3 = b3_2;
b3_5 = VAR_9[0];
b3_6 = b3_5;
b3_8 = b3_2 - b3_5*6 + VAR_9[pitch];
b3_9 = b3_8;
}
for (VAR_3 = 0, VAR_5 = 0; VAR_3 < VAR_0->width; VAR_3+=2, VAR_5++) {
if (VAR_3+2 >= VAR_0->width) {
VAR_6 --;
VAR_7 --;
VAR_8 --;
VAR_9 --;
}
b2_1 = b2_2;
b2_2 = b2_3;
b2_4 = b2_5;
b2_5 = b2_6; = b2[VAR_3+1,VAR_4+1]
b3_1 = b3_2;
b3_2 = b3_3; = b3[VAR_3+1,VAR_4-1]
b3_4 = b3_5;
b3_5 = b3_6; = b3[VAR_3+1,VAR_4 ]
b3_7 = b3_8;
b3_8 = b3_9;
p0 = p1 = p2 = p3 = 0;
if (VAR_10 > 0) {
tmp0 = b0_1;
tmp2 = b0_2;
b0_1 = VAR_6[VAR_5+1];
b0_2 = VAR_6[pitch+VAR_5+1];
tmp1 = tmp0 + b0_1;
p0 = tmp0 << 4;
p1 = tmp1 << 3;
p2 = (tmp0 + tmp2) << 3;
p3 = (tmp1 + tmp2 + b0_2) << 2;
}
if (VAR_10 > 1) {
tmp0 = b1_2;
tmp1 = b1_1;
b1_2 = VAR_7[VAR_5+1];
b1_1 = VAR_7[back_pitch+VAR_5+1];
tmp2 = tmp1 - tmp0*6 + b1_3;
b1_3 = b1_1 - b1_2*6 + VAR_7[pitch+VAR_5+1];
p0 += (tmp0 + tmp1) << 3;
p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
p2 += tmp2 << 2;
p3 += (tmp2 + b1_3) << 1;
}
if (VAR_10 > 2) {
b2_3 = VAR_8[VAR_5+1];
b2_6 = VAR_8[pitch+VAR_5+1];
tmp0 = b2_1 + b2_2;
tmp1 = b2_1 - b2_2*6 + b2_3;
p0 += tmp0 << 3;
p1 += tmp1 << 2;
p2 += (tmp0 + b2_4 + b2_5) << 2;
p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;
}
if (VAR_10 > 3) {
b3_6 = VAR_9[VAR_5+1];
b3_3 = VAR_9[back_pitch+VAR_5+1];
tmp0 = b3_1 + b3_4;
tmp1 = b3_2 + b3_5;
tmp2 = b3_3 + b3_6;
b3_9 = b3_3 - b3_6*6 + VAR_9[pitch+VAR_5+1];
p0 += (tmp0 + tmp1) << 2;
p1 += (tmp0 - tmp1*6 + tmp2) << 1;
p2 += (b3_7 + b3_8) << 1;
p3 += b3_7 - b3_8*6 + b3_9;
}
VAR_1[VAR_3] = av_clip_uint8((p0 >> 6) + 128);
VAR_1[VAR_3+1] = av_clip_uint8((p1 >> 6) + 128);
VAR_1[VAR_2+VAR_3] = av_clip_uint8((p2 >> 6) + 128);
VAR_1[VAR_2+VAR_3+1] = av_clip_uint8((p3 >> 6) + 128);
}
VAR_1 += VAR_2 << 1;
back_pitch = -pitch;
VAR_6 += pitch + 1;
VAR_7 += pitch + 1;
VAR_8 += pitch + 1;
VAR_9 += pitch + 1;
}
}
| [
"void FUNC_0(const IVIPlaneDesc *VAR_0, uint8_t *VAR_1,\nconst ptrdiff_t VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;",
"int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;",
"int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;",
"ptrdiff_t pitch, back_pitch;",
"const short *VAR_6, *VAR_7, *VAR_8, *VAR_9;",
"const int VAR_10 = 4;",
"pitch = VAR_0->bands[0].pitch;",
"back_pitch = 0;",
"VAR_6 = VAR_0->bands[0].buf;",
"VAR_7 = VAR_0->bands[1].buf;",
"VAR_8 = VAR_0->bands[2].buf;",
"VAR_9 = VAR_0->bands[3].buf;",
"for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4 += 2) {",
"if (VAR_4+2 >= VAR_0->height)\npitch= 0;",
"if (VAR_10 > 0) {",
"b0_1 = VAR_6[0];",
"b0_2 = VAR_6[pitch];",
"}",
"if (VAR_10 > 1) {",
"b1_1 = VAR_7[back_pitch];",
"b1_2 = VAR_7[0];",
"b1_3 = b1_1 - b1_2*6 + VAR_7[pitch];",
"}",
"if (VAR_10 > 2) {",
"b2_2 = VAR_8[0];",
"b2_3 = b2_2;",
"b2_5 = VAR_8[pitch];",
"b2_6 = b2_5;",
"}",
"if (VAR_10 > 3) {",
"b3_2 = VAR_9[back_pitch];",
"b3_3 = b3_2;",
"b3_5 = VAR_9[0];",
"b3_6 = b3_5;",
"b3_8 = b3_2 - b3_5*6 + VAR_9[pitch];",
"b3_9 = b3_8;",
"}",
"for (VAR_3 = 0, VAR_5 = 0; VAR_3 < VAR_0->width; VAR_3+=2, VAR_5++) {",
"if (VAR_3+2 >= VAR_0->width) {",
"VAR_6 --;",
"VAR_7 --;",
"VAR_8 --;",
"VAR_9 --;",
"}",
"b2_1 = b2_2;",
"b2_2 = b2_3;",
"b2_4 = b2_5;",
"b2_5 = b2_6; = b2[VAR_3+1,VAR_4+1]",
"b3_1 = b3_2;",
"b3_2 = b3_3; = b3[VAR_3+1,VAR_4-1]",
"b3_4 = b3_5;",
"b3_5 = b3_6; = b3[VAR_3+1,VAR_4 ]",
"b3_7 = b3_8;",
"b3_8 = b3_9;",
"p0 = p1 = p2 = p3 = 0;",
"if (VAR_10 > 0) {",
"tmp0 = b0_1;",
"tmp2 = b0_2;",
"b0_1 = VAR_6[VAR_5+1];",
"b0_2 = VAR_6[pitch+VAR_5+1];",
"tmp1 = tmp0 + b0_1;",
"p0 = tmp0 << 4;",
"p1 = tmp1 << 3;",
"p2 = (tmp0 + tmp2) << 3;",
"p3 = (tmp1 + tmp2 + b0_2) << 2;",
"}",
"if (VAR_10 > 1) {",
"tmp0 = b1_2;",
"tmp1 = b1_1;",
"b1_2 = VAR_7[VAR_5+1];",
"b1_1 = VAR_7[back_pitch+VAR_5+1];",
"tmp2 = tmp1 - tmp0*6 + b1_3;",
"b1_3 = b1_1 - b1_2*6 + VAR_7[pitch+VAR_5+1];",
"p0 += (tmp0 + tmp1) << 3;",
"p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;",
"p2 += tmp2 << 2;",
"p3 += (tmp2 + b1_3) << 1;",
"}",
"if (VAR_10 > 2) {",
"b2_3 = VAR_8[VAR_5+1];",
"b2_6 = VAR_8[pitch+VAR_5+1];",
"tmp0 = b2_1 + b2_2;",
"tmp1 = b2_1 - b2_2*6 + b2_3;",
"p0 += tmp0 << 3;",
"p1 += tmp1 << 2;",
"p2 += (tmp0 + b2_4 + b2_5) << 2;",
"p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;",
"}",
"if (VAR_10 > 3) {",
"b3_6 = VAR_9[VAR_5+1];",
"b3_3 = VAR_9[back_pitch+VAR_5+1];",
"tmp0 = b3_1 + b3_4;",
"tmp1 = b3_2 + b3_5;",
"tmp2 = b3_3 + b3_6;",
"b3_9 = b3_3 - b3_6*6 + VAR_9[pitch+VAR_5+1];",
"p0 += (tmp0 + tmp1) << 2;",
"p1 += (tmp0 - tmp1*6 + tmp2) << 1;",
"p2 += (b3_7 + b3_8) << 1;",
"p3 += b3_7 - b3_8*6 + b3_9;",
"}",
"VAR_1[VAR_3] = av_clip_uint8((p0 >> 6) + 128);",
"VAR_1[VAR_3+1] = av_clip_uint8((p1 >> 6) + 128);",
"VAR_1[VAR_2+VAR_3] = av_clip_uint8((p2 >> 6) + 128);",
"VAR_1[VAR_2+VAR_3+1] = av_clip_uint8((p3 >> 6) + 128);",
"}",
"VAR_1 += VAR_2 << 1;",
"back_pitch = -pitch;",
"VAR_6 += pitch + 1;",
"VAR_7 += pitch + 1;",
"VAR_8 += pitch + 1;",
"VAR_9 += pitch + 1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51,
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
]
] |
25,262 | void virtio_scsi_common_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev);
int i;
virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig));
s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_event);
for (i = 0; i < s->conf.num_queues; i++) {
s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
}
| true | qemu | 91d670fbf9945ca4ecbd123affb36889e7fe8a5d | void virtio_scsi_common_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev);
int i;
virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig));
s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_event);
for (i = 0; i < s->conf.num_queues; i++) {
s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
}
| {
"code": [
"void virtio_scsi_common_realize(DeviceState *dev, Error **errp)",
" virtio_scsi_handle_ctrl);",
" virtio_scsi_handle_event);",
" virtio_scsi_handle_cmd);"
],
"line_no": [
1,
29,
33,
39
]
} | void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(VAR_0);
int VAR_2;
virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig));
s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_event);
for (VAR_2 = 0; VAR_2 < s->conf.num_queues; VAR_2++) {
s->cmd_vqs[VAR_2] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
}
| [
"void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(VAR_0);",
"int VAR_2;",
"virtio_init(vdev, \"virtio-scsi\", VIRTIO_ID_SCSI,\nsizeof(VirtIOSCSIConfig));",
"s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));",
"s->sense_size = VIRTIO_SCSI_SENSE_SIZE;",
"s->cdb_size = VIRTIO_SCSI_CDB_SIZE;",
"s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,\nvirtio_scsi_handle_ctrl);",
"s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,\nvirtio_scsi_handle_event);",
"for (VAR_2 = 0; VAR_2 < s->conf.num_queues; VAR_2++) {",
"s->cmd_vqs[VAR_2] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,\nvirtio_scsi_handle_cmd);",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
]
] |
25,264 | static CharDriverState *qemu_chr_open_udp_fd(int fd)
{
CharDriverState *chr = NULL;
NetCharDriver *s = NULL;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(NetCharDriver));
s->fd = fd;
s->chan = io_channel_from_socket(s->fd);
s->bufcnt = 0;
s->bufptr = 0;
chr->opaque = s;
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
chr->chr_close = udp_chr_close;
/* be isn't opened until we get a connection */
chr->explicit_be_open = true;
return chr;
}
| true | qemu | 2d528d45ecf5ee3c1a566a9f3d664464925ef830 | static CharDriverState *qemu_chr_open_udp_fd(int fd)
{
CharDriverState *chr = NULL;
NetCharDriver *s = NULL;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(NetCharDriver));
s->fd = fd;
s->chan = io_channel_from_socket(s->fd);
s->bufcnt = 0;
s->bufptr = 0;
chr->opaque = s;
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
chr->chr_close = udp_chr_close;
chr->explicit_be_open = true;
return chr;
}
| {
"code": [
" s = g_malloc0(sizeof(NetCharDriver));"
],
"line_no": [
13
]
} | static CharDriverState *FUNC_0(int fd)
{
CharDriverState *chr = NULL;
NetCharDriver *s = NULL;
chr = qemu_chr_alloc();
s = g_malloc0(sizeof(NetCharDriver));
s->fd = fd;
s->chan = io_channel_from_socket(s->fd);
s->bufcnt = 0;
s->bufptr = 0;
chr->opaque = s;
chr->chr_write = udp_chr_write;
chr->chr_update_read_handler = udp_chr_update_read_handler;
chr->chr_close = udp_chr_close;
chr->explicit_be_open = true;
return chr;
}
| [
"static CharDriverState *FUNC_0(int fd)\n{",
"CharDriverState *chr = NULL;",
"NetCharDriver *s = NULL;",
"chr = qemu_chr_alloc();",
"s = g_malloc0(sizeof(NetCharDriver));",
"s->fd = fd;",
"s->chan = io_channel_from_socket(s->fd);",
"s->bufcnt = 0;",
"s->bufptr = 0;",
"chr->opaque = s;",
"chr->chr_write = udp_chr_write;",
"chr->chr_update_read_handler = udp_chr_update_read_handler;",
"chr->chr_close = udp_chr_close;",
"chr->explicit_be_open = true;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
25,267 | static int genh_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
GENHDemuxContext *c = s->priv_data;
int ret;
if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP &&
codec->channels > 1) {
int i, ch;
if (avio_feof(s->pb))
return AVERROR_EOF;
av_new_packet(pkt, 8 * codec->channels);
for (i = 0; i < 8 / c->interleave_size; i++) {
for (ch = 0; ch < codec->channels; ch++) {
pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb);
pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb);
}
}
ret = 0;
} else {
ret = av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels);
}
pkt->stream_index = 0;
return ret;
}
| false | FFmpeg | acf23d9451e9ea014a4eddf2abdb476c4f33edc4 | static int genh_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
GENHDemuxContext *c = s->priv_data;
int ret;
if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP &&
codec->channels > 1) {
int i, ch;
if (avio_feof(s->pb))
return AVERROR_EOF;
av_new_packet(pkt, 8 * codec->channels);
for (i = 0; i < 8 / c->interleave_size; i++) {
for (ch = 0; ch < codec->channels; ch++) {
pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb);
pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb);
}
}
ret = 0;
} else {
ret = av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels);
}
pkt->stream_index = 0;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
AVCodecContext *codec = VAR_0->streams[0]->codec;
GENHDemuxContext *c = VAR_0->priv_data;
int VAR_2;
if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP &&
codec->channels > 1) {
int VAR_3, VAR_4;
if (avio_feof(VAR_0->pb))
return AVERROR_EOF;
av_new_packet(VAR_1, 8 * codec->channels);
for (VAR_3 = 0; VAR_3 < 8 / c->interleave_size; VAR_3++) {
for (VAR_4 = 0; VAR_4 < codec->channels; VAR_4++) {
VAR_1->data[VAR_4 * 8 + VAR_3*c->interleave_size+0] = avio_r8(VAR_0->pb);
VAR_1->data[VAR_4 * 8 + VAR_3*c->interleave_size+1] = avio_r8(VAR_0->pb);
}
}
VAR_2 = 0;
} else {
VAR_2 = av_get_packet(VAR_0->pb, VAR_1, codec->block_align ? codec->block_align : 1024 * codec->channels);
}
VAR_1->stream_index = 0;
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"AVCodecContext *codec = VAR_0->streams[0]->codec;",
"GENHDemuxContext *c = VAR_0->priv_data;",
"int VAR_2;",
"if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP &&\ncodec->channels > 1) {",
"int VAR_3, VAR_4;",
"if (avio_feof(VAR_0->pb))\nreturn AVERROR_EOF;",
"av_new_packet(VAR_1, 8 * codec->channels);",
"for (VAR_3 = 0; VAR_3 < 8 / c->interleave_size; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < codec->channels; VAR_4++) {",
"VAR_1->data[VAR_4 * 8 + VAR_3*c->interleave_size+0] = avio_r8(VAR_0->pb);",
"VAR_1->data[VAR_4 * 8 + VAR_3*c->interleave_size+1] = avio_r8(VAR_0->pb);",
"}",
"}",
"VAR_2 = 0;",
"} else {",
"VAR_2 = av_get_packet(VAR_0->pb, VAR_1, codec->block_align ? codec->block_align : 1024 * codec->channels);",
"}",
"VAR_1->stream_index = 0;",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
]
] |
25,268 | static void balloon_page(void *addr, int deflate)
{
#if defined(__linux__)
if (!kvm_enabled() || kvm_has_sync_mmu())
madvise(addr, TARGET_PAGE_SIZE,
deflate ? MADV_WILLNEED : MADV_DONTNEED);
#endif
}
| true | qemu | e78815a554adaa551d62a71be10ee2fcf128e473 | static void balloon_page(void *addr, int deflate)
{
#if defined(__linux__)
if (!kvm_enabled() || kvm_has_sync_mmu())
madvise(addr, TARGET_PAGE_SIZE,
deflate ? MADV_WILLNEED : MADV_DONTNEED);
#endif
}
| {
"code": [
"#endif",
"#endif",
" madvise(addr, TARGET_PAGE_SIZE,",
" deflate ? MADV_WILLNEED : MADV_DONTNEED);",
"#endif"
],
"line_no": [
13,
13,
9,
11,
13
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
#if defined(__linux__)
if (!kvm_enabled() || kvm_has_sync_mmu())
madvise(VAR_0, TARGET_PAGE_SIZE,
VAR_1 ? MADV_WILLNEED : MADV_DONTNEED);
#endif
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"#if defined(__linux__)\nif (!kvm_enabled() || kvm_has_sync_mmu())\nmadvise(VAR_0, TARGET_PAGE_SIZE,\nVAR_1 ? MADV_WILLNEED : MADV_DONTNEED);",
"#endif\n}"
] | [
0,
1,
1
] | [
[
1,
3
],
[
5,
7,
9,
11
],
[
13,
15
]
] |
25,269 | static void test_self(void)
{
Coroutine *coroutine;
coroutine = qemu_coroutine_create(verify_self);
qemu_coroutine_enter(coroutine, &coroutine);
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static void test_self(void)
{
Coroutine *coroutine;
coroutine = qemu_coroutine_create(verify_self);
qemu_coroutine_enter(coroutine, &coroutine);
}
| {
"code": [
" coroutine = qemu_coroutine_create(verify_self);",
" qemu_coroutine_enter(coroutine, &coroutine);"
],
"line_no": [
9,
11
]
} | static void FUNC_0(void)
{
Coroutine *coroutine;
coroutine = qemu_coroutine_create(verify_self);
qemu_coroutine_enter(coroutine, &coroutine);
}
| [
"static void FUNC_0(void)\n{",
"Coroutine *coroutine;",
"coroutine = qemu_coroutine_create(verify_self);",
"qemu_coroutine_enter(coroutine, &coroutine);",
"}"
] | [
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
25,270 | static void gen_wrteei(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
if (ctx->opcode & 0x00008000) {
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
/* Stop translation to have a chance to raise an exception */
gen_stop_exception(ctx);
} else {
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
}
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_wrteei(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
if (ctx->opcode & 0x00008000) {
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
gen_stop_exception(ctx);
} else {
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
}
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
13,
7,
11,
13,
7,
11,
13,
7,
13,
5,
9,
11,
33,
5,
9,
11,
33,
33,
5,
9,
11,
7,
11,
13,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
11,
33,
7,
13,
33,
7,
11,
13,
33,
7,
13,
33,
7,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
11,
33,
11,
33,
11,
33,
11,
33,
5,
7,
9,
11,
13,
33,
7,
11,
13,
33,
5,
7,
9,
11,
13,
33,
5,
7,
9,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
5,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33,
7,
11,
13,
33
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
if (VAR_0->opcode & 0x00008000) {
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
gen_stop_exception(VAR_0);
} else {
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
}
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"if (VAR_0->opcode & 0x00008000) {",
"tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));",
"gen_stop_exception(VAR_0);",
"} else {",
"tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));",
"}",
"#endif\n}"
] | [
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
]
] |
25,272 | void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUFile *VAR_0, unsigned int VAR_1)
{
qemu_put_byte(VAR_0, VAR_1 >> 8);
qemu_put_byte(VAR_0, VAR_1);
}
| [
"void FUNC_0(QEMUFile *VAR_0, unsigned int VAR_1)\n{",
"qemu_put_byte(VAR_0, VAR_1 >> 8);",
"qemu_put_byte(VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,273 | static void test_cancel(void)
{
WorkerTestData data[100];
int num_canceled;
int i;
/* Start more work items than there will be threads, to ensure
* the pool is full.
*/
test_submit_many();
/* Start long running jobs, to ensure we can cancel some. */
for (i = 0; i < 100; i++) {
data[i].n = 0;
data[i].ret = -EINPROGRESS;
data[i].aiocb = thread_pool_submit_aio(pool, long_cb, &data[i],
done_cb, &data[i]);
}
/* Starting the threads may be left to a bottom half. Let it
* run, but do not waste too much time...
*/
active = 100;
aio_notify(ctx);
aio_poll(ctx, false);
/* Wait some time for the threads to start, with some sanity
* testing on the behavior of the scheduler...
*/
g_assert_cmpint(active, ==, 100);
g_usleep(1000000);
g_assert_cmpint(active, >, 50);
/* Cancel the jobs that haven't been started yet. */
num_canceled = 0;
for (i = 0; i < 100; i++) {
if (atomic_cmpxchg(&data[i].n, 0, 3) == 0) {
data[i].ret = -ECANCELED;
bdrv_aio_cancel(data[i].aiocb);
active--;
num_canceled++;
}
}
g_assert_cmpint(active, >, 0);
g_assert_cmpint(num_canceled, <, 100);
/* Canceling the others will be a blocking operation. */
for (i = 0; i < 100; i++) {
if (data[i].n != 3) {
bdrv_aio_cancel(data[i].aiocb);
}
}
/* Finish execution and execute any remaining callbacks. */
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
g_assert_cmpint(data[i].ret, ==, -ECANCELED);
g_assert(data[i].aiocb != NULL);
} else {
g_assert_cmpint(data[i].n, ==, 2);
g_assert_cmpint(data[i].ret, ==, 0);
g_assert(data[i].aiocb == NULL);
}
}
}
| true | qemu | 35ecde26018207fe723bec6efbd340db6e9c2d53 | static void test_cancel(void)
{
WorkerTestData data[100];
int num_canceled;
int i;
test_submit_many();
for (i = 0; i < 100; i++) {
data[i].n = 0;
data[i].ret = -EINPROGRESS;
data[i].aiocb = thread_pool_submit_aio(pool, long_cb, &data[i],
done_cb, &data[i]);
}
active = 100;
aio_notify(ctx);
aio_poll(ctx, false);
g_assert_cmpint(active, ==, 100);
g_usleep(1000000);
g_assert_cmpint(active, >, 50);
num_canceled = 0;
for (i = 0; i < 100; i++) {
if (atomic_cmpxchg(&data[i].n, 0, 3) == 0) {
data[i].ret = -ECANCELED;
bdrv_aio_cancel(data[i].aiocb);
active--;
num_canceled++;
}
}
g_assert_cmpint(active, >, 0);
g_assert_cmpint(num_canceled, <, 100);
for (i = 0; i < 100; i++) {
if (data[i].n != 3) {
bdrv_aio_cancel(data[i].aiocb);
}
}
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
if (data[i].n == 3) {
g_assert_cmpint(data[i].ret, ==, -ECANCELED);
g_assert(data[i].aiocb != NULL);
} else {
g_assert_cmpint(data[i].n, ==, 2);
g_assert_cmpint(data[i].ret, ==, 0);
g_assert(data[i].aiocb == NULL);
}
}
}
| {
"code": [
" qemu_aio_wait_all();",
" qemu_aio_wait_all();",
" qemu_aio_wait_all();",
" qemu_aio_wait_all();"
],
"line_no": [
109,
109,
109,
109
]
} | static void FUNC_0(void)
{
WorkerTestData data[100];
int VAR_0;
int VAR_1;
test_submit_many();
for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {
data[VAR_1].n = 0;
data[VAR_1].ret = -EINPROGRESS;
data[VAR_1].aiocb = thread_pool_submit_aio(pool, long_cb, &data[VAR_1],
done_cb, &data[VAR_1]);
}
active = 100;
aio_notify(ctx);
aio_poll(ctx, false);
g_assert_cmpint(active, ==, 100);
g_usleep(1000000);
g_assert_cmpint(active, >, 50);
VAR_0 = 0;
for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {
if (atomic_cmpxchg(&data[VAR_1].n, 0, 3) == 0) {
data[VAR_1].ret = -ECANCELED;
bdrv_aio_cancel(data[VAR_1].aiocb);
active--;
VAR_0++;
}
}
g_assert_cmpint(active, >, 0);
g_assert_cmpint(VAR_0, <, 100);
for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {
if (data[VAR_1].n != 3) {
bdrv_aio_cancel(data[VAR_1].aiocb);
}
}
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {
if (data[VAR_1].n == 3) {
g_assert_cmpint(data[VAR_1].ret, ==, -ECANCELED);
g_assert(data[VAR_1].aiocb != NULL);
} else {
g_assert_cmpint(data[VAR_1].n, ==, 2);
g_assert_cmpint(data[VAR_1].ret, ==, 0);
g_assert(data[VAR_1].aiocb == NULL);
}
}
}
| [
"static void FUNC_0(void)\n{",
"WorkerTestData data[100];",
"int VAR_0;",
"int VAR_1;",
"test_submit_many();",
"for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {",
"data[VAR_1].n = 0;",
"data[VAR_1].ret = -EINPROGRESS;",
"data[VAR_1].aiocb = thread_pool_submit_aio(pool, long_cb, &data[VAR_1],\ndone_cb, &data[VAR_1]);",
"}",
"active = 100;",
"aio_notify(ctx);",
"aio_poll(ctx, false);",
"g_assert_cmpint(active, ==, 100);",
"g_usleep(1000000);",
"g_assert_cmpint(active, >, 50);",
"VAR_0 = 0;",
"for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {",
"if (atomic_cmpxchg(&data[VAR_1].n, 0, 3) == 0) {",
"data[VAR_1].ret = -ECANCELED;",
"bdrv_aio_cancel(data[VAR_1].aiocb);",
"active--;",
"VAR_0++;",
"}",
"}",
"g_assert_cmpint(active, >, 0);",
"g_assert_cmpint(VAR_0, <, 100);",
"for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {",
"if (data[VAR_1].n != 3) {",
"bdrv_aio_cancel(data[VAR_1].aiocb);",
"}",
"}",
"qemu_aio_wait_all();",
"g_assert_cmpint(active, ==, 0);",
"for (VAR_1 = 0; VAR_1 < 100; VAR_1++) {",
"if (data[VAR_1].n == 3) {",
"g_assert_cmpint(data[VAR_1].ret, ==, -ECANCELED);",
"g_assert(data[VAR_1].aiocb != NULL);",
"} else {",
"g_assert_cmpint(data[VAR_1].n, ==, 2);",
"g_assert_cmpint(data[VAR_1].ret, ==, 0);",
"g_assert(data[VAR_1].aiocb == 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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
45
],
[
47
],
[
49
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
25,274 | static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
{
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]);
if (ctx->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| {
"code": [
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {",
" if (ctx->tb->cflags & CF_USE_ICOUNT) {"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
]
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)
{
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_store_tbl(cpu_env, cpu_gpr[VAR_2]);
if (VAR_0->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_stop_exception(VAR_0);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)\n{",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"}",
"gen_helper_store_tbl(cpu_env, cpu_gpr[VAR_2]);",
"if (VAR_0->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_end();",
"gen_stop_exception(VAR_0);",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
25,275 | static void coroutine_fn commit_run(void *opaque)
{
CommitBlockJob *s = opaque;
BlockDriverState *active = s->active;
BlockDriverState *top = s->top;
BlockDriverState *base = s->base;
BlockDriverState *overlay_bs = NULL;
int64_t sector_num, end;
int ret = 0;
int n = 0;
void *buf;
int bytes_written = 0;
int64_t base_len;
ret = s->common.len = bdrv_getlength(top);
if (s->common.len < 0) {
goto exit_restore_reopen;
}
ret = base_len = bdrv_getlength(base);
if (base_len < 0) {
goto exit_restore_reopen;
}
if (base_len < s->common.len) {
ret = bdrv_truncate(base, s->common.len);
if (ret) {
goto exit_restore_reopen;
}
}
overlay_bs = bdrv_find_overlay(active, top);
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE);
for (sector_num = 0; sector_num < end; sector_num += n) {
uint64_t delay_ns = 0;
bool copy;
wait:
/* Note that even when no rate limit is applied we need to yield
* with no pending I/O here so that bdrv_drain_all() returns.
*/
block_job_sleep_ns(&s->common, rt_clock, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
/* Copy if allocated above the base */
ret = bdrv_co_is_allocated_above(top, base, sector_num,
COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,
&n);
copy = (ret == 1);
trace_commit_one_iteration(s, sector_num, n, ret);
if (copy) {
if (s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);
if (delay_ns > 0) {
goto wait;
}
}
ret = commit_populate(top, base, sector_num, n, buf);
bytes_written += n * BDRV_SECTOR_SIZE;
}
if (ret < 0) {
if (s->on_error == BLOCKDEV_ON_ERROR_STOP ||
s->on_error == BLOCKDEV_ON_ERROR_REPORT||
(s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) {
goto exit_free_buf;
} else {
n = 0;
continue;
}
}
/* Publish progress */
s->common.offset += n * BDRV_SECTOR_SIZE;
}
ret = 0;
if (!block_job_is_cancelled(&s->common) && sector_num == end) {
/* success */
ret = bdrv_drop_intermediate(active, top, base);
}
exit_free_buf:
qemu_vfree(buf);
exit_restore_reopen:
/* restore base open flags here if appropriate (e.g., change the base back
* to r/o). These reopens do not need to be atomic, since we won't abort
* even on failure here */
if (s->base_flags != bdrv_get_flags(base)) {
bdrv_reopen(base, s->base_flags, NULL);
}
if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
}
block_job_completed(&s->common, ret);
}
| true | qemu | 6d759117d3fd28e38c49c56c9de206cc718d32fa | static void coroutine_fn commit_run(void *opaque)
{
CommitBlockJob *s = opaque;
BlockDriverState *active = s->active;
BlockDriverState *top = s->top;
BlockDriverState *base = s->base;
BlockDriverState *overlay_bs = NULL;
int64_t sector_num, end;
int ret = 0;
int n = 0;
void *buf;
int bytes_written = 0;
int64_t base_len;
ret = s->common.len = bdrv_getlength(top);
if (s->common.len < 0) {
goto exit_restore_reopen;
}
ret = base_len = bdrv_getlength(base);
if (base_len < 0) {
goto exit_restore_reopen;
}
if (base_len < s->common.len) {
ret = bdrv_truncate(base, s->common.len);
if (ret) {
goto exit_restore_reopen;
}
}
overlay_bs = bdrv_find_overlay(active, top);
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE);
for (sector_num = 0; sector_num < end; sector_num += n) {
uint64_t delay_ns = 0;
bool copy;
wait:
block_job_sleep_ns(&s->common, rt_clock, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
ret = bdrv_co_is_allocated_above(top, base, sector_num,
COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,
&n);
copy = (ret == 1);
trace_commit_one_iteration(s, sector_num, n, ret);
if (copy) {
if (s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);
if (delay_ns > 0) {
goto wait;
}
}
ret = commit_populate(top, base, sector_num, n, buf);
bytes_written += n * BDRV_SECTOR_SIZE;
}
if (ret < 0) {
if (s->on_error == BLOCKDEV_ON_ERROR_STOP ||
s->on_error == BLOCKDEV_ON_ERROR_REPORT||
(s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) {
goto exit_free_buf;
} else {
n = 0;
continue;
}
}
s->common.offset += n * BDRV_SECTOR_SIZE;
}
ret = 0;
if (!block_job_is_cancelled(&s->common) && sector_num == end) {
ret = bdrv_drop_intermediate(active, top, base);
}
exit_free_buf:
qemu_vfree(buf);
exit_restore_reopen:
if (s->base_flags != bdrv_get_flags(base)) {
bdrv_reopen(base, s->base_flags, NULL);
}
if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
}
block_job_completed(&s->common, ret);
}
| {
"code": [
" BlockDriverState *overlay_bs = NULL;",
" overlay_bs = bdrv_find_overlay(active, top);",
" if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {"
],
"line_no": [
13,
67,
195
]
} | static void VAR_0 commit_run(void *opaque)
{
CommitBlockJob *s = opaque;
BlockDriverState *active = s->active;
BlockDriverState *top = s->top;
BlockDriverState *base = s->base;
BlockDriverState *overlay_bs = NULL;
int64_t sector_num, end;
int ret = 0;
int n = 0;
void *buf;
int bytes_written = 0;
int64_t base_len;
ret = s->common.len = bdrv_getlength(top);
if (s->common.len < 0) {
goto exit_restore_reopen;
}
ret = base_len = bdrv_getlength(base);
if (base_len < 0) {
goto exit_restore_reopen;
}
if (base_len < s->common.len) {
ret = bdrv_truncate(base, s->common.len);
if (ret) {
goto exit_restore_reopen;
}
}
overlay_bs = bdrv_find_overlay(active, top);
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE);
for (sector_num = 0; sector_num < end; sector_num += n) {
uint64_t delay_ns = 0;
bool copy;
wait:
block_job_sleep_ns(&s->common, rt_clock, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
ret = bdrv_co_is_allocated_above(top, base, sector_num,
COMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,
&n);
copy = (ret == 1);
trace_commit_one_iteration(s, sector_num, n, ret);
if (copy) {
if (s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);
if (delay_ns > 0) {
goto wait;
}
}
ret = commit_populate(top, base, sector_num, n, buf);
bytes_written += n * BDRV_SECTOR_SIZE;
}
if (ret < 0) {
if (s->on_error == BLOCKDEV_ON_ERROR_STOP ||
s->on_error == BLOCKDEV_ON_ERROR_REPORT||
(s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) {
goto exit_free_buf;
} else {
n = 0;
continue;
}
}
s->common.offset += n * BDRV_SECTOR_SIZE;
}
ret = 0;
if (!block_job_is_cancelled(&s->common) && sector_num == end) {
ret = bdrv_drop_intermediate(active, top, base);
}
exit_free_buf:
qemu_vfree(buf);
exit_restore_reopen:
if (s->base_flags != bdrv_get_flags(base)) {
bdrv_reopen(base, s->base_flags, NULL);
}
if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
}
block_job_completed(&s->common, ret);
}
| [
"static void VAR_0 commit_run(void *opaque)\n{",
"CommitBlockJob *s = opaque;",
"BlockDriverState *active = s->active;",
"BlockDriverState *top = s->top;",
"BlockDriverState *base = s->base;",
"BlockDriverState *overlay_bs = NULL;",
"int64_t sector_num, end;",
"int ret = 0;",
"int n = 0;",
"void *buf;",
"int bytes_written = 0;",
"int64_t base_len;",
"ret = s->common.len = bdrv_getlength(top);",
"if (s->common.len < 0) {",
"goto exit_restore_reopen;",
"}",
"ret = base_len = bdrv_getlength(base);",
"if (base_len < 0) {",
"goto exit_restore_reopen;",
"}",
"if (base_len < s->common.len) {",
"ret = bdrv_truncate(base, s->common.len);",
"if (ret) {",
"goto exit_restore_reopen;",
"}",
"}",
"overlay_bs = bdrv_find_overlay(active, top);",
"end = s->common.len >> BDRV_SECTOR_BITS;",
"buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE);",
"for (sector_num = 0; sector_num < end; sector_num += n) {",
"uint64_t delay_ns = 0;",
"bool copy;",
"wait:\nblock_job_sleep_ns(&s->common, rt_clock, delay_ns);",
"if (block_job_is_cancelled(&s->common)) {",
"break;",
"}",
"ret = bdrv_co_is_allocated_above(top, base, sector_num,\nCOMMIT_BUFFER_SIZE / BDRV_SECTOR_SIZE,\n&n);",
"copy = (ret == 1);",
"trace_commit_one_iteration(s, sector_num, n, ret);",
"if (copy) {",
"if (s->common.speed) {",
"delay_ns = ratelimit_calculate_delay(&s->limit, n);",
"if (delay_ns > 0) {",
"goto wait;",
"}",
"}",
"ret = commit_populate(top, base, sector_num, n, buf);",
"bytes_written += n * BDRV_SECTOR_SIZE;",
"}",
"if (ret < 0) {",
"if (s->on_error == BLOCKDEV_ON_ERROR_STOP ||\ns->on_error == BLOCKDEV_ON_ERROR_REPORT||\n(s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) {",
"goto exit_free_buf;",
"} else {",
"n = 0;",
"continue;",
"}",
"}",
"s->common.offset += n * BDRV_SECTOR_SIZE;",
"}",
"ret = 0;",
"if (!block_job_is_cancelled(&s->common) && sector_num == end) {",
"ret = bdrv_drop_intermediate(active, top, base);",
"}",
"exit_free_buf:\nqemu_vfree(buf);",
"exit_restore_reopen:\nif (s->base_flags != bdrv_get_flags(base)) {",
"bdrv_reopen(base, s->base_flags, NULL);",
"}",
"if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {",
"bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);",
"}",
"block_job_completed(&s->common, ret);",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85,
93
],
[
95
],
[
97
],
[
99
],
[
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
161
],
[
165
],
[
169
],
[
171
],
[
175,
177
],
[
181,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
]
] |
25,276 | static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;
}
| true | qemu | 155eb9aa09249874b4ff49e94c58595ad82d3abb | static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;
}
| {
"code": [
" return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;"
],
"line_no": [
7
]
} | static inline long double FUNC_0(void)
{
assert(block_mig_state.total_time != 0);
return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;
}
| [
"static inline long double FUNC_0(void)\n{",
"assert(block_mig_state.total_time != 0);",
"return (block_mig_state.reads * BLOCK_SIZE)/ block_mig_state.total_time;",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,277 | size_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...)
{
int i;
va_list ap;
size_t old_offset = offset;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += v9fs_unpack(valp, out_sg, out_num, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le16_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le32_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le64_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"w", &str->size);
/* FIXME: sanity check str->size */
str->data = g_malloc(str->size + 1);
offset += v9fs_unpack(str->data, out_sg, out_num, offset,
str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| false | qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | size_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...)
{
int i;
va_list ap;
size_t old_offset = offset;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += v9fs_unpack(valp, out_sg, out_num, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le16_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le32_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le64_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"w", &str->size);
str->data = g_malloc(str->size + 1);
offset += v9fs_unpack(str->data, out_sg, out_num, offset,
str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += v9fs_unmarshal(out_sg, out_num, offset, bswap,
"ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| {
"code": [],
"line_no": []
} | size_t FUNC_0(struct iovec *out_sg, int out_num, size_t offset,
int bswap, const char *fmt, ...)
{
int VAR_0;
va_list ap;
size_t old_offset = offset;
va_start(ap, fmt);
for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {
switch (fmt[VAR_0]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += v9fs_unpack(valp, out_sg, out_num, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le16_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le32_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));
if (bswap) {
*valp = le64_to_cpu(val);
} else {
*valp = val;
}
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += FUNC_0(out_sg, out_num, offset, bswap,
"w", &str->size);
str->data = g_malloc(str->size + 1);
offset += v9fs_unpack(str->data, out_sg, out_num, offset,
str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += FUNC_0(out_sg, out_num, offset, bswap, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += FUNC_0(out_sg, out_num, offset, bswap,
"wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += FUNC_0(out_sg, out_num, offset, bswap,
"ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| [
"size_t FUNC_0(struct iovec *out_sg, int out_num, size_t offset,\nint bswap, const char *fmt, ...)\n{",
"int VAR_0;",
"va_list ap;",
"size_t old_offset = offset;",
"va_start(ap, fmt);",
"for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {",
"switch (fmt[VAR_0]) {",
"case 'b': {",
"uint8_t *valp = va_arg(ap, uint8_t *);",
"offset += v9fs_unpack(valp, out_sg, out_num, offset, sizeof(*valp));",
"break;",
"}",
"case 'w': {",
"uint16_t val, *valp;",
"valp = va_arg(ap, uint16_t *);",
"offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));",
"if (bswap) {",
"*valp = le16_to_cpu(val);",
"} else {",
"*valp = val;",
"}",
"break;",
"}",
"case 'd': {",
"uint32_t val, *valp;",
"valp = va_arg(ap, uint32_t *);",
"offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));",
"if (bswap) {",
"*valp = le32_to_cpu(val);",
"} else {",
"*valp = val;",
"}",
"break;",
"}",
"case 'q': {",
"uint64_t val, *valp;",
"valp = va_arg(ap, uint64_t *);",
"offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val));",
"if (bswap) {",
"*valp = le64_to_cpu(val);",
"} else {",
"*valp = val;",
"}",
"break;",
"}",
"case 's': {",
"V9fsString *str = va_arg(ap, V9fsString *);",
"offset += FUNC_0(out_sg, out_num, offset, bswap,\n\"w\", &str->size);",
"str->data = g_malloc(str->size + 1);",
"offset += v9fs_unpack(str->data, out_sg, out_num, offset,\nstr->size);",
"str->data[str->size] = 0;",
"break;",
"}",
"case 'Q': {",
"V9fsQID *qidp = va_arg(ap, V9fsQID *);",
"offset += FUNC_0(out_sg, out_num, offset, bswap, \"bdq\",\n&qidp->type, &qidp->version, &qidp->path);",
"break;",
"}",
"case 'S': {",
"V9fsStat *statp = va_arg(ap, V9fsStat *);",
"offset += FUNC_0(out_sg, out_num, offset, bswap,\n\"wwdQdddqsssssddd\",\n&statp->size, &statp->type, &statp->dev,\n&statp->qid, &statp->mode, &statp->atime,\n&statp->mtime, &statp->length,\n&statp->name, &statp->uid, &statp->gid,\n&statp->muid, &statp->extension,\n&statp->n_uid, &statp->n_gid,\n&statp->n_muid);",
"break;",
"}",
"case 'I': {",
"V9fsIattr *iattr = va_arg(ap, V9fsIattr *);",
"offset += FUNC_0(out_sg, out_num, offset, bswap,\n\"ddddqqqqq\",\n&iattr->valid, &iattr->mode,\n&iattr->uid, &iattr->gid, &iattr->size,\n&iattr->atime_sec, &iattr->atime_nsec,\n&iattr->mtime_sec, &iattr->mtime_nsec);",
"break;",
"}",
"default:\nbreak;",
"}",
"}",
"va_end(ap);",
"return offset - old_offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139,
141,
143,
145,
147,
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163,
165,
167,
169,
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
191
],
[
193
]
] |
25,279 | int coroutine_fn thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,
void *arg)
{
ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };
assert(qemu_in_coroutine());
thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);
qemu_coroutine_yield();
return tpc.ret;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | int coroutine_fn thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,
void *arg)
{
ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };
assert(qemu_in_coroutine());
thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);
qemu_coroutine_yield();
return tpc.ret;
}
| {
"code": [],
"line_no": []
} | int VAR_0 thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,
void *arg)
{
ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };
assert(qemu_in_coroutine());
thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);
qemu_coroutine_yield();
return tpc.ret;
}
| [
"int VAR_0 thread_pool_submit_co(ThreadPool *pool, ThreadPoolFunc *func,\nvoid *arg)\n{",
"ThreadPoolCo tpc = { .co = qemu_coroutine_self(), .ret = -EINPROGRESS };",
"assert(qemu_in_coroutine());",
"thread_pool_submit_aio(pool, func, arg, thread_pool_co_cb, &tpc);",
"qemu_coroutine_yield();",
"return tpc.ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,281 | int qcrypto_init(Error **errp G_GNUC_UNUSED)
{
return 0;
}
| false | qemu | 91bfcdb01d4869aa8f4cb67007827de63b8c2217 | int qcrypto_init(Error **errp G_GNUC_UNUSED)
{
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Error **VAR_0 G_GNUC_UNUSED)
{
return 0;
}
| [
"int FUNC_0(Error **VAR_0 G_GNUC_UNUSED)\n{",
"return 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,282 | static av_cold int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels <= 0 || channels > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
return AVERROR(EINVAL);
}
bitrate = bitrate / 1000;
s->nb_channels = channels;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
/* encoding freq */
s->lsf = 0;
for(i=0;i<3;i++) {
if (avpriv_mpa_freq_tab[i] == freq)
break;
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
return AVERROR(EINVAL);
}
s->freq_index = i;
/* encoding bitrate & frequency */
for(i=0;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
}
s->bitrate_index = i;
/* compute total header size & pad bit */
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
/* frame fractional size to compute padding */
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
/* select the right allocation table */
table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
/* number of used subbands */
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = ff_mpa_enwindow[i];
#if WFRAC_BITS != 16
v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
s->filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
s->scale_factor_table[i] = v;
s->scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20);
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
s->scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = ff_mpa_quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
s->total_quant_bits[i] = 12 * v;
}
return 0;
}
| false | FFmpeg | 2df0c32ea12ddfa72ba88309812bfb13b674130f | static av_cold int MPA_encode_init(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int freq = avctx->sample_rate;
int bitrate = avctx->bit_rate;
int channels = avctx->channels;
int i, v, table;
float a;
if (channels <= 0 || channels > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
return AVERROR(EINVAL);
}
bitrate = bitrate / 1000;
s->nb_channels = channels;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
s->lsf = 0;
for(i=0;i<3;i++) {
if (avpriv_mpa_freq_tab[i] == freq)
break;
if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
}
if (i == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
return AVERROR(EINVAL);
}
s->freq_index = i;
for(i=0;i<15;i++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15){
av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
return AVERROR(EINVAL);
}
s->bitrate_index = i;
a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
s->frame_size = ((int)a) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
table = ff_mpa_l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
s->samples_offset[i] = 0;
for(i=0;i<257;i++) {
int v;
v = ff_mpa_enwindow[i];
#if WFRAC_BITS != 16
v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
s->filter_bank[512 - i] = v;
}
for(i=0;i<64;i++) {
v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20));
if (v <= 0)
v = 1;
s->scale_factor_table[i] = v;
s->scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20);
}
for(i=0;i<128;i++) {
v = i - 64;
if (v <= -3)
v = 0;
else if (v < 0)
v = 1;
else if (v == 0)
v = 2;
else if (v < 3)
v = 3;
else
v = 4;
s->scale_diff_table[i] = v;
}
for(i=0;i<17;i++) {
v = ff_mpa_quant_bits[i];
if (v < 0)
v = -v;
else
v = v * 3;
s->total_quant_bits[i] = 12 * v;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
MpegAudioContext *s = avctx->priv_data;
int VAR_0 = avctx->sample_rate;
int VAR_1 = avctx->bit_rate;
int VAR_2 = avctx->VAR_2;
int VAR_3, VAR_7, VAR_5;
float VAR_6;
if (VAR_2 <= 0 || VAR_2 > 2){
av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", VAR_2);
return AVERROR(EINVAL);
}
VAR_1 = VAR_1 / 1000;
s->nb_channels = VAR_2;
avctx->frame_size = MPA_FRAME_SIZE;
avctx->delay = 512 - 32 + 1;
s->lsf = 0;
for(VAR_3=0;VAR_3<3;VAR_3++) {
if (avpriv_mpa_freq_tab[VAR_3] == VAR_0)
break;
if ((avpriv_mpa_freq_tab[VAR_3] / 2) == VAR_0) {
s->lsf = 1;
break;
}
}
if (VAR_3 == 3){
av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", VAR_0);
return AVERROR(EINVAL);
}
s->freq_index = VAR_3;
for(VAR_3=0;VAR_3<15;VAR_3++) {
if (avpriv_mpa_bitrate_tab[s->lsf][1][VAR_3] == VAR_1)
break;
}
if (VAR_3 == 15){
av_log(avctx, AV_LOG_ERROR, "VAR_1 %d is not allowed in mp2\n", VAR_1);
return AVERROR(EINVAL);
}
s->bitrate_index = VAR_3;
VAR_6 = (float)(VAR_1 * 1000 * MPA_FRAME_SIZE) / (VAR_0 * 8.0);
s->frame_size = ((int)VAR_6) * 8;
s->frame_frac = 0;
s->frame_frac_incr = (int)((VAR_6 - floor(VAR_6)) * 65536.0);
VAR_5 = ff_mpa_l2_select_table(VAR_1, s->nb_channels, VAR_0, s->lsf);
s->sblimit = ff_mpa_sblimit_table[VAR_5];
s->alloc_table = ff_mpa_alloc_tables[VAR_5];
av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, VAR_5=%d, padincr=%x\n",
VAR_1, VAR_0, s->frame_size, VAR_5, s->frame_frac_incr);
for(VAR_3=0;VAR_3<s->nb_channels;VAR_3++)
s->samples_offset[VAR_3] = 0;
for(VAR_3=0;VAR_3<257;VAR_3++) {
int VAR_7;
VAR_7 = ff_mpa_enwindow[VAR_3];
#if WFRAC_BITS != 16
VAR_7 = (VAR_7 + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
#endif
s->filter_bank[VAR_3] = VAR_7;
if ((VAR_3 & 63) != 0)
VAR_7 = -VAR_7;
if (VAR_3 != 0)
s->filter_bank[512 - VAR_3] = VAR_7;
}
for(VAR_3=0;VAR_3<64;VAR_3++) {
VAR_7 = (int)(pow(2.0, (3 - VAR_3) / 3.0) * (1 << 20));
if (VAR_7 <= 0)
VAR_7 = 1;
s->scale_factor_table[VAR_3] = VAR_7;
s->scale_factor_inv_table[VAR_3] = pow(2.0, -(3 - VAR_3) / 3.0) / (float)(1 << 20);
}
for(VAR_3=0;VAR_3<128;VAR_3++) {
VAR_7 = VAR_3 - 64;
if (VAR_7 <= -3)
VAR_7 = 0;
else if (VAR_7 < 0)
VAR_7 = 1;
else if (VAR_7 == 0)
VAR_7 = 2;
else if (VAR_7 < 3)
VAR_7 = 3;
else
VAR_7 = 4;
s->scale_diff_table[VAR_3] = VAR_7;
}
for(VAR_3=0;VAR_3<17;VAR_3++) {
VAR_7 = ff_mpa_quant_bits[VAR_3];
if (VAR_7 < 0)
VAR_7 = -VAR_7;
else
VAR_7 = VAR_7 * 3;
s->total_quant_bits[VAR_3] = 12 * VAR_7;
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"MpegAudioContext *s = avctx->priv_data;",
"int VAR_0 = avctx->sample_rate;",
"int VAR_1 = avctx->bit_rate;",
"int VAR_2 = avctx->VAR_2;",
"int VAR_3, VAR_7, VAR_5;",
"float VAR_6;",
"if (VAR_2 <= 0 || VAR_2 > 2){",
"av_log(avctx, AV_LOG_ERROR, \"encoding %d channel(s) is not allowed in mp2\\n\", VAR_2);",
"return AVERROR(EINVAL);",
"}",
"VAR_1 = VAR_1 / 1000;",
"s->nb_channels = VAR_2;",
"avctx->frame_size = MPA_FRAME_SIZE;",
"avctx->delay = 512 - 32 + 1;",
"s->lsf = 0;",
"for(VAR_3=0;VAR_3<3;VAR_3++) {",
"if (avpriv_mpa_freq_tab[VAR_3] == VAR_0)\nbreak;",
"if ((avpriv_mpa_freq_tab[VAR_3] / 2) == VAR_0) {",
"s->lsf = 1;",
"break;",
"}",
"}",
"if (VAR_3 == 3){",
"av_log(avctx, AV_LOG_ERROR, \"Sampling rate %d is not allowed in mp2\\n\", VAR_0);",
"return AVERROR(EINVAL);",
"}",
"s->freq_index = VAR_3;",
"for(VAR_3=0;VAR_3<15;VAR_3++) {",
"if (avpriv_mpa_bitrate_tab[s->lsf][1][VAR_3] == VAR_1)\nbreak;",
"}",
"if (VAR_3 == 15){",
"av_log(avctx, AV_LOG_ERROR, \"VAR_1 %d is not allowed in mp2\\n\", VAR_1);",
"return AVERROR(EINVAL);",
"}",
"s->bitrate_index = VAR_3;",
"VAR_6 = (float)(VAR_1 * 1000 * MPA_FRAME_SIZE) / (VAR_0 * 8.0);",
"s->frame_size = ((int)VAR_6) * 8;",
"s->frame_frac = 0;",
"s->frame_frac_incr = (int)((VAR_6 - floor(VAR_6)) * 65536.0);",
"VAR_5 = ff_mpa_l2_select_table(VAR_1, s->nb_channels, VAR_0, s->lsf);",
"s->sblimit = ff_mpa_sblimit_table[VAR_5];",
"s->alloc_table = ff_mpa_alloc_tables[VAR_5];",
"av_dlog(avctx, \"%d kb/s, %d Hz, frame_size=%d bits, VAR_5=%d, padincr=%x\\n\",\nVAR_1, VAR_0, s->frame_size, VAR_5, s->frame_frac_incr);",
"for(VAR_3=0;VAR_3<s->nb_channels;VAR_3++)",
"s->samples_offset[VAR_3] = 0;",
"for(VAR_3=0;VAR_3<257;VAR_3++) {",
"int VAR_7;",
"VAR_7 = ff_mpa_enwindow[VAR_3];",
"#if WFRAC_BITS != 16\nVAR_7 = (VAR_7 + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);",
"#endif\ns->filter_bank[VAR_3] = VAR_7;",
"if ((VAR_3 & 63) != 0)\nVAR_7 = -VAR_7;",
"if (VAR_3 != 0)\ns->filter_bank[512 - VAR_3] = VAR_7;",
"}",
"for(VAR_3=0;VAR_3<64;VAR_3++) {",
"VAR_7 = (int)(pow(2.0, (3 - VAR_3) / 3.0) * (1 << 20));",
"if (VAR_7 <= 0)\nVAR_7 = 1;",
"s->scale_factor_table[VAR_3] = VAR_7;",
"s->scale_factor_inv_table[VAR_3] = pow(2.0, -(3 - VAR_3) / 3.0) / (float)(1 << 20);",
"}",
"for(VAR_3=0;VAR_3<128;VAR_3++) {",
"VAR_7 = VAR_3 - 64;",
"if (VAR_7 <= -3)\nVAR_7 = 0;",
"else if (VAR_7 < 0)\nVAR_7 = 1;",
"else if (VAR_7 == 0)\nVAR_7 = 2;",
"else if (VAR_7 < 3)\nVAR_7 = 3;",
"else\nVAR_7 = 4;",
"s->scale_diff_table[VAR_3] = VAR_7;",
"}",
"for(VAR_3=0;VAR_3<17;VAR_3++) {",
"VAR_7 = ff_mpa_quant_bits[VAR_3];",
"if (VAR_7 < 0)\nVAR_7 = -VAR_7;",
"else\nVAR_7 = VAR_7 * 3;",
"s->total_quant_bits[VAR_3] = 12 * VAR_7;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
95
],
[
97
],
[
103
],
[
105
],
[
111
],
[
117
],
[
119
],
[
123,
125
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
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
],
[
217
],
[
219
],
[
223
],
[
225
]
] |
25,283 | BlockDriverState *check_to_replace_node(const char *node_name, Error **errp)
{
BlockDriverState *to_replace_bs = bdrv_find_node(node_name);
AioContext *aio_context;
if (!to_replace_bs) {
error_setg(errp, "Node name '%s' not found", node_name);
return NULL;
}
aio_context = bdrv_get_aio_context(to_replace_bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {
to_replace_bs = NULL;
goto out;
}
/* We don't want arbitrary node of the BDS chain to be replaced only the top
* most non filter in order to prevent data corruption.
* Another benefit is that this tests exclude backing files which are
* blocked by the backing blockers.
*/
if (!bdrv_is_first_non_filter(to_replace_bs)) {
error_setg(errp, "Only top most non filter can be replaced");
to_replace_bs = NULL;
goto out;
}
out:
aio_context_release(aio_context);
return to_replace_bs;
}
| false | qemu | e12f3784097a26a1ba51be420f41038b4c0ae5d1 | BlockDriverState *check_to_replace_node(const char *node_name, Error **errp)
{
BlockDriverState *to_replace_bs = bdrv_find_node(node_name);
AioContext *aio_context;
if (!to_replace_bs) {
error_setg(errp, "Node name '%s' not found", node_name);
return NULL;
}
aio_context = bdrv_get_aio_context(to_replace_bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {
to_replace_bs = NULL;
goto out;
}
if (!bdrv_is_first_non_filter(to_replace_bs)) {
error_setg(errp, "Only top most non filter can be replaced");
to_replace_bs = NULL;
goto out;
}
out:
aio_context_release(aio_context);
return to_replace_bs;
}
| {
"code": [],
"line_no": []
} | BlockDriverState *FUNC_0(const char *node_name, Error **errp)
{
BlockDriverState *to_replace_bs = bdrv_find_node(node_name);
AioContext *aio_context;
if (!to_replace_bs) {
error_setg(errp, "Node name '%s' not found", node_name);
return NULL;
}
aio_context = bdrv_get_aio_context(to_replace_bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {
to_replace_bs = NULL;
goto out;
}
if (!bdrv_is_first_non_filter(to_replace_bs)) {
error_setg(errp, "Only top most non filter can be replaced");
to_replace_bs = NULL;
goto out;
}
out:
aio_context_release(aio_context);
return to_replace_bs;
}
| [
"BlockDriverState *FUNC_0(const char *node_name, Error **errp)\n{",
"BlockDriverState *to_replace_bs = bdrv_find_node(node_name);",
"AioContext *aio_context;",
"if (!to_replace_bs) {",
"error_setg(errp, \"Node name '%s' not found\", node_name);",
"return NULL;",
"}",
"aio_context = bdrv_get_aio_context(to_replace_bs);",
"aio_context_acquire(aio_context);",
"if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) {",
"to_replace_bs = NULL;",
"goto out;",
"}",
"if (!bdrv_is_first_non_filter(to_replace_bs)) {",
"error_setg(errp, \"Only top most non filter can be replaced\");",
"to_replace_bs = NULL;",
"goto out;",
"}",
"out:\naio_context_release(aio_context);",
"return to_replace_bs;",
"}"
] | [
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63
],
[
65
]
] |
25,285 | static uint32_t ecc_mem_readb(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 00\n", addr);
return 0;
}
| false | qemu | 7c560456707bfe53eb1728fcde759be7d9418b62 | static uint32_t ecc_mem_readb(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 00\n", addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
printf("ECC: Unsupported read 0x" TARGET_FMT_plx " 00\n", addr);
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"printf(\"ECC: Unsupported read 0x\" TARGET_FMT_plx \" 00\\n\", addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,286 | static inline void gen_op_mov_reg_v(int ot, int reg, TCGv t0)
{
switch(ot) {
case OT_BYTE:
if (reg < 4 X86_64_DEF( || reg >= 8 || x86_64_hregs)) {
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 8);
} else {
tcg_gen_deposit_tl(cpu_regs[reg - 4], cpu_regs[reg - 4], t0, 8, 8);
}
break;
case OT_WORD:
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 16);
break;
default: /* XXX this shouldn't be reached; abort? */
case OT_LONG:
/* For x86_64, this sets the higher half of register to zero.
For i386, this is equivalent to a mov. */
tcg_gen_ext32u_tl(cpu_regs[reg], t0);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
tcg_gen_mov_tl(cpu_regs[reg], t0);
break;
#endif
}
}
| false | qemu | 96d7073fb058e6f05257cd9041ffbbd736f6ccec | static inline void gen_op_mov_reg_v(int ot, int reg, TCGv t0)
{
switch(ot) {
case OT_BYTE:
if (reg < 4 X86_64_DEF( || reg >= 8 || x86_64_hregs)) {
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 8);
} else {
tcg_gen_deposit_tl(cpu_regs[reg - 4], cpu_regs[reg - 4], t0, 8, 8);
}
break;
case OT_WORD:
tcg_gen_deposit_tl(cpu_regs[reg], cpu_regs[reg], t0, 0, 16);
break;
default:
case OT_LONG:
tcg_gen_ext32u_tl(cpu_regs[reg], t0);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
tcg_gen_mov_tl(cpu_regs[reg], t0);
break;
#endif
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0, int VAR_1, TCGv VAR_2)
{
switch(VAR_0) {
case OT_BYTE:
if (VAR_1 < 4 X86_64_DEF( || VAR_1 >= 8 || x86_64_hregs)) {
tcg_gen_deposit_tl(cpu_regs[VAR_1], cpu_regs[VAR_1], VAR_2, 0, 8);
} else {
tcg_gen_deposit_tl(cpu_regs[VAR_1 - 4], cpu_regs[VAR_1 - 4], VAR_2, 8, 8);
}
break;
case OT_WORD:
tcg_gen_deposit_tl(cpu_regs[VAR_1], cpu_regs[VAR_1], VAR_2, 0, 16);
break;
default:
case OT_LONG:
tcg_gen_ext32u_tl(cpu_regs[VAR_1], VAR_2);
break;
#ifdef TARGET_X86_64
case OT_QUAD:
tcg_gen_mov_tl(cpu_regs[VAR_1], VAR_2);
break;
#endif
}
}
| [
"static inline void FUNC_0(int VAR_0, int VAR_1, TCGv VAR_2)\n{",
"switch(VAR_0) {",
"case OT_BYTE:\nif (VAR_1 < 4 X86_64_DEF( || VAR_1 >= 8 || x86_64_hregs)) {",
"tcg_gen_deposit_tl(cpu_regs[VAR_1], cpu_regs[VAR_1], VAR_2, 0, 8);",
"} else {",
"tcg_gen_deposit_tl(cpu_regs[VAR_1 - 4], cpu_regs[VAR_1 - 4], VAR_2, 8, 8);",
"}",
"break;",
"case OT_WORD:\ntcg_gen_deposit_tl(cpu_regs[VAR_1], cpu_regs[VAR_1], VAR_2, 0, 16);",
"break;",
"default:\ncase OT_LONG:\ntcg_gen_ext32u_tl(cpu_regs[VAR_1], VAR_2);",
"break;",
"#ifdef TARGET_X86_64\ncase OT_QUAD:\ntcg_gen_mov_tl(cpu_regs[VAR_1], VAR_2);",
"break;",
"#endif\n}",
"}"
] | [
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
]
] |
25,287 | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
V9fsPath *dir_path, const char *name, FsCred *credp)
{
int err = -1;
int serrno = 0;
char *newpath;
V9fsString fullname;
char buffer[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
newpath = fullname.data;
/* Determine the security model */
if (fs_ctx->fs_sm == SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
fd = open(rpath(fs_ctx, newpath, buffer), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (fd == -1) {
err = fd;
goto out;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(rpath(fs_ctx, newpath, buffer), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
(fs_ctx->fs_sm == SM_NONE)) {
err = symlink(oldpath, rpath(fs_ctx, newpath, buffer));
if (err) {
goto out;
}
err = lchown(rpath(fs_ctx, newpath, buffer), credp->fc_uid,
credp->fc_gid);
if (err == -1) {
/*
* If we fail to change ownership and if we are
* using security model none. Ignore the error
*/
if (fs_ctx->fs_sm != SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
goto out;
err_end:
remove(rpath(fs_ctx, newpath, buffer));
errno = serrno;
out:
v9fs_string_free(&fullname);
return err;
}
| false | qemu | b97400caef60ccfb0bc81c59f8bd824c43a0d6c8 | static int local_symlink(FsContext *fs_ctx, const char *oldpath,
V9fsPath *dir_path, const char *name, FsCred *credp)
{
int err = -1;
int serrno = 0;
char *newpath;
V9fsString fullname;
char buffer[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
newpath = fullname.data;
if (fs_ctx->fs_sm == SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
fd = open(rpath(fs_ctx, newpath, buffer), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (fd == -1) {
err = fd;
goto out;
}
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(rpath(fs_ctx, newpath, buffer), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) ||
(fs_ctx->fs_sm == SM_NONE)) {
err = symlink(oldpath, rpath(fs_ctx, newpath, buffer));
if (err) {
goto out;
}
err = lchown(rpath(fs_ctx, newpath, buffer), credp->fc_uid,
credp->fc_gid);
if (err == -1) {
if (fs_ctx->fs_sm != SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
goto out;
err_end:
remove(rpath(fs_ctx, newpath, buffer));
errno = serrno;
out:
v9fs_string_free(&fullname);
return err;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1,
V9fsPath *VAR_2, const char *VAR_3, FsCred *VAR_4)
{
int VAR_5 = -1;
int VAR_6 = 0;
char *VAR_7;
V9fsString fullname;
char VAR_8[PATH_MAX];
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", VAR_2->data, VAR_3);
VAR_7 = fullname.data;
if (VAR_0->fs_sm == SM_MAPPED) {
int VAR_9;
ssize_t oldpath_size, write_size;
VAR_9 = open(rpath(VAR_0, VAR_7, VAR_8), O_CREAT|O_EXCL|O_RDWR,
SM_LOCAL_MODE_BITS);
if (VAR_9 == -1) {
VAR_5 = VAR_9;
goto out;
}
oldpath_size = strlen(VAR_1);
do {
write_size = write(VAR_9, (void *)VAR_1, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
VAR_6 = errno;
close(VAR_9);
VAR_5 = -1;
goto err_end;
}
close(VAR_9);
VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;
VAR_5 = local_set_xattr(rpath(VAR_0, VAR_7, VAR_8), VAR_4);
if (VAR_5 == -1) {
VAR_6 = errno;
goto err_end;
}
} else if ((VAR_0->fs_sm == SM_PASSTHROUGH) ||
(VAR_0->fs_sm == SM_NONE)) {
VAR_5 = symlink(VAR_1, rpath(VAR_0, VAR_7, VAR_8));
if (VAR_5) {
goto out;
}
VAR_5 = lchown(rpath(VAR_0, VAR_7, VAR_8), VAR_4->fc_uid,
VAR_4->fc_gid);
if (VAR_5 == -1) {
if (VAR_0->fs_sm != SM_NONE) {
VAR_6 = errno;
goto err_end;
} else
VAR_5 = 0;
}
}
goto out;
err_end:
remove(rpath(VAR_0, VAR_7, VAR_8));
errno = VAR_6;
out:
v9fs_string_free(&fullname);
return VAR_5;
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1,\nV9fsPath *VAR_2, const char *VAR_3, FsCred *VAR_4)\n{",
"int VAR_5 = -1;",
"int VAR_6 = 0;",
"char *VAR_7;",
"V9fsString fullname;",
"char VAR_8[PATH_MAX];",
"v9fs_string_init(&fullname);",
"v9fs_string_sprintf(&fullname, \"%s/%s\", VAR_2->data, VAR_3);",
"VAR_7 = fullname.data;",
"if (VAR_0->fs_sm == SM_MAPPED) {",
"int VAR_9;",
"ssize_t oldpath_size, write_size;",
"VAR_9 = open(rpath(VAR_0, VAR_7, VAR_8), O_CREAT|O_EXCL|O_RDWR,\nSM_LOCAL_MODE_BITS);",
"if (VAR_9 == -1) {",
"VAR_5 = VAR_9;",
"goto out;",
"}",
"oldpath_size = strlen(VAR_1);",
"do {",
"write_size = write(VAR_9, (void *)VAR_1, oldpath_size);",
"} while (write_size == -1 && errno == EINTR);",
"if (write_size != oldpath_size) {",
"VAR_6 = errno;",
"close(VAR_9);",
"VAR_5 = -1;",
"goto err_end;",
"}",
"close(VAR_9);",
"VAR_4->fc_mode = VAR_4->fc_mode|S_IFLNK;",
"VAR_5 = local_set_xattr(rpath(VAR_0, VAR_7, VAR_8), VAR_4);",
"if (VAR_5 == -1) {",
"VAR_6 = errno;",
"goto err_end;",
"}",
"} else if ((VAR_0->fs_sm == SM_PASSTHROUGH) ||",
"(VAR_0->fs_sm == SM_NONE)) {",
"VAR_5 = symlink(VAR_1, rpath(VAR_0, VAR_7, VAR_8));",
"if (VAR_5) {",
"goto out;",
"}",
"VAR_5 = lchown(rpath(VAR_0, VAR_7, VAR_8), VAR_4->fc_uid,\nVAR_4->fc_gid);",
"if (VAR_5 == -1) {",
"if (VAR_0->fs_sm != SM_NONE) {",
"VAR_6 = errno;",
"goto err_end;",
"} else",
"VAR_5 = 0;",
"}",
"}",
"goto out;",
"err_end:\nremove(rpath(VAR_0, VAR_7, VAR_8));",
"errno = VAR_6;",
"out:\nv9fs_string_free(&fullname);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
]
] |
25,288 | int socket_listen(SocketAddress *addr, Error **errp)
{
QemuOpts *opts;
int fd;
opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
switch (addr->kind) {
case SOCKET_ADDRESS_KIND_INET:
inet_addr_to_opts(opts, addr->inet);
fd = inet_listen_opts(opts, 0, errp);
break;
case SOCKET_ADDRESS_KIND_UNIX:
qemu_opt_set(opts, "path", addr->q_unix->path, &error_abort);
fd = unix_listen_opts(opts, errp);
break;
case SOCKET_ADDRESS_KIND_FD:
fd = monitor_get_fd(cur_mon, addr->fd->str, errp);
break;
default:
abort();
}
qemu_opts_del(opts);
return fd;
}
| false | qemu | 2d32addae70987521578d8bb27c6b3f52cdcbdcb | int socket_listen(SocketAddress *addr, Error **errp)
{
QemuOpts *opts;
int fd;
opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
switch (addr->kind) {
case SOCKET_ADDRESS_KIND_INET:
inet_addr_to_opts(opts, addr->inet);
fd = inet_listen_opts(opts, 0, errp);
break;
case SOCKET_ADDRESS_KIND_UNIX:
qemu_opt_set(opts, "path", addr->q_unix->path, &error_abort);
fd = unix_listen_opts(opts, errp);
break;
case SOCKET_ADDRESS_KIND_FD:
fd = monitor_get_fd(cur_mon, addr->fd->str, errp);
break;
default:
abort();
}
qemu_opts_del(opts);
return fd;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(SocketAddress *VAR_0, Error **VAR_1)
{
QemuOpts *opts;
int VAR_2;
opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);
switch (VAR_0->kind) {
case SOCKET_ADDRESS_KIND_INET:
inet_addr_to_opts(opts, VAR_0->inet);
VAR_2 = inet_listen_opts(opts, 0, VAR_1);
break;
case SOCKET_ADDRESS_KIND_UNIX:
qemu_opt_set(opts, "path", VAR_0->q_unix->path, &error_abort);
VAR_2 = unix_listen_opts(opts, VAR_1);
break;
case SOCKET_ADDRESS_KIND_FD:
VAR_2 = monitor_get_fd(cur_mon, VAR_0->VAR_2->str, VAR_1);
break;
default:
abort();
}
qemu_opts_del(opts);
return VAR_2;
}
| [
"int FUNC_0(SocketAddress *VAR_0, Error **VAR_1)\n{",
"QemuOpts *opts;",
"int VAR_2;",
"opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort);",
"switch (VAR_0->kind) {",
"case SOCKET_ADDRESS_KIND_INET:\ninet_addr_to_opts(opts, VAR_0->inet);",
"VAR_2 = inet_listen_opts(opts, 0, VAR_1);",
"break;",
"case SOCKET_ADDRESS_KIND_UNIX:\nqemu_opt_set(opts, \"path\", VAR_0->q_unix->path, &error_abort);",
"VAR_2 = unix_listen_opts(opts, VAR_1);",
"break;",
"case SOCKET_ADDRESS_KIND_FD:\nVAR_2 = monitor_get_fd(cur_mon, VAR_0->VAR_2->str, VAR_1);",
"break;",
"default:\nabort();",
"}",
"qemu_opts_del(opts);",
"return VAR_2;",
"}"
] | [
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
],
[
35,
37
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
25,289 | static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
unsigned int len, i, shift;
int ret;
QCowHeader header;
Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
false, errp);
if (!bs->file) {
return -EINVAL;
}
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
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);
be32_to_cpus(&header.mtime);
be64_to_cpus(&header.size);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image not in qcow format");
ret = -EINVAL;
goto fail;
}
if (header.version != QCOW_VERSION) {
error_setg(errp, "Unsupported qcow version %" PRIu32, header.version);
ret = -ENOTSUP;
goto fail;
}
if (header.size <= 1) {
error_setg(errp, "Image size is too small (must be at least 2 bytes)");
ret = -EINVAL;
goto fail;
}
if (header.cluster_bits < 9 || header.cluster_bits > 16) {
error_setg(errp, "Cluster size must be between 512 and 64k");
ret = -EINVAL;
goto fail;
}
/* l2_bits specifies number of entries; storing a uint64_t in each entry,
* so bytes = num_entries << 3. */
if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) {
error_setg(errp, "L2 table size must be between 512 and 64k");
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "invalid encryption method in qcow header");
ret = -EINVAL;
goto fail;
}
if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,
QCRYPTO_CIPHER_MODE_CBC)) {
error_setg(errp, "AES cipher not available");
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
if (bdrv_uses_whitelist() &&
s->crypt_method_header == QCOW_CRYPT_AES) {
error_setg(errp,
"Use of AES-CBC encrypted qcow images is no longer "
"supported in system emulators");
error_append_hint(errp,
"You can use 'qemu-img convert' to convert your "
"image to an alternative supported format, such "
"as unencrypted qcow, or raw with the LUKS "
"format instead.\n");
ret = -ENOSYS;
goto fail;
}
bs->encrypted = true;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = header.l2_bits;
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
/* read the level 1 table */
shift = s->cluster_bits + s->l2_bits;
if (header.size > UINT64_MAX - (1LL << shift)) {
error_setg(errp, "Image too large");
ret = -EINVAL;
goto fail;
} else {
uint64_t l1_size = (header.size + (1LL << shift) - 1) >> shift;
if (l1_size > INT_MAX / sizeof(uint64_t)) {
error_setg(errp, "Image too large");
ret = -EINVAL;
goto fail;
}
s->l1_size = l1_size;
}
s->l1_table_offset = header.l1_table_offset;
s->l1_table = g_try_new(uint64_t, s->l1_size);
if (s->l1_table == NULL) {
error_setg(errp, "Could not allocate memory for L1 table");
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
/* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */
s->l2_cache =
qemu_try_blockalign(bs->file->bs,
s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
if (s->l2_cache == NULL) {
error_setg(errp, "Could not allocate L2 table cache");
ret = -ENOMEM;
goto fail;
}
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = g_malloc(s->cluster_size);
s->cluster_cache_offset = -1;
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023 || len >= sizeof(bs->backing_file)) {
error_setg(errp, "Backing file name too long");
ret = -EINVAL;
goto fail;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
goto fail;
}
bs->backing_file[len] = '\0';
}
/* Disable migration when qcow images are used */
error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
ret = migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_propagate(errp, local_err);
error_free(s->migration_blocker);
goto fail;
}
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
return ret;
}
| false | qemu | d85f4222b4681da7ebf8a90b26e085a68fa2c55a | static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
unsigned int len, i, shift;
int ret;
QCowHeader header;
Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
false, errp);
if (!bs->file) {
return -EINVAL;
}
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
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);
be32_to_cpus(&header.mtime);
be64_to_cpus(&header.size);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image not in qcow format");
ret = -EINVAL;
goto fail;
}
if (header.version != QCOW_VERSION) {
error_setg(errp, "Unsupported qcow version %" PRIu32, header.version);
ret = -ENOTSUP;
goto fail;
}
if (header.size <= 1) {
error_setg(errp, "Image size is too small (must be at least 2 bytes)");
ret = -EINVAL;
goto fail;
}
if (header.cluster_bits < 9 || header.cluster_bits > 16) {
error_setg(errp, "Cluster size must be between 512 and 64k");
ret = -EINVAL;
goto fail;
}
if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) {
error_setg(errp, "L2 table size must be between 512 and 64k");
ret = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "invalid encryption method in qcow header");
ret = -EINVAL;
goto fail;
}
if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,
QCRYPTO_CIPHER_MODE_CBC)) {
error_setg(errp, "AES cipher not available");
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
if (bdrv_uses_whitelist() &&
s->crypt_method_header == QCOW_CRYPT_AES) {
error_setg(errp,
"Use of AES-CBC encrypted qcow images is no longer "
"supported in system emulators");
error_append_hint(errp,
"You can use 'qemu-img convert' to convert your "
"image to an alternative supported format, such "
"as unencrypted qcow, or raw with the LUKS "
"format instead.\n");
ret = -ENOSYS;
goto fail;
}
bs->encrypted = true;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = header.l2_bits;
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
shift = s->cluster_bits + s->l2_bits;
if (header.size > UINT64_MAX - (1LL << shift)) {
error_setg(errp, "Image too large");
ret = -EINVAL;
goto fail;
} else {
uint64_t l1_size = (header.size + (1LL << shift) - 1) >> shift;
if (l1_size > INT_MAX / sizeof(uint64_t)) {
error_setg(errp, "Image too large");
ret = -EINVAL;
goto fail;
}
s->l1_size = l1_size;
}
s->l1_table_offset = header.l1_table_offset;
s->l1_table = g_try_new(uint64_t, s->l1_size);
if (s->l1_table == NULL) {
error_setg(errp, "Could not allocate memory for L1 table");
ret = -ENOMEM;
goto fail;
}
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
s->l2_cache =
qemu_try_blockalign(bs->file->bs,
s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
if (s->l2_cache == NULL) {
error_setg(errp, "Could not allocate L2 table cache");
ret = -ENOMEM;
goto fail;
}
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = g_malloc(s->cluster_size);
s->cluster_cache_offset = -1;
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > 1023 || len >= sizeof(bs->backing_file)) {
error_setg(errp, "Backing file name too long");
ret = -EINVAL;
goto fail;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
goto fail;
}
bs->backing_file[len] = '\0';
}
error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
ret = migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_propagate(errp, local_err);
error_free(s->migration_blocker);
goto fail;
}
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(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;
unsigned int VAR_4, VAR_5, VAR_6;
int VAR_7;
QCowHeader header;
Error *local_err = NULL;
VAR_0->file = bdrv_open_child(NULL, VAR_1, "file", VAR_0, &child_file,
false, VAR_3);
if (!VAR_0->file) {
return -EINVAL;
}
VAR_7 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));
if (VAR_7 < 0) {
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);
be32_to_cpus(&header.mtime);
be64_to_cpus(&header.size);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
if (header.magic != QCOW_MAGIC) {
error_setg(VAR_3, "Image not in qcow format");
VAR_7 = -EINVAL;
goto fail;
}
if (header.version != QCOW_VERSION) {
error_setg(VAR_3, "Unsupported qcow version %" PRIu32, header.version);
VAR_7 = -ENOTSUP;
goto fail;
}
if (header.size <= 1) {
error_setg(VAR_3, "Image size is too small (must be at least 2 bytes)");
VAR_7 = -EINVAL;
goto fail;
}
if (header.cluster_bits < 9 || header.cluster_bits > 16) {
error_setg(VAR_3, "Cluster size must be between 512 and 64k");
VAR_7 = -EINVAL;
goto fail;
}
if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) {
error_setg(VAR_3, "L2 table size must be between 512 and 64k");
VAR_7 = -EINVAL;
goto fail;
}
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(VAR_3, "invalid encryption method in qcow header");
VAR_7 = -EINVAL;
goto fail;
}
if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,
QCRYPTO_CIPHER_MODE_CBC)) {
error_setg(VAR_3, "AES cipher not available");
VAR_7 = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
if (bdrv_uses_whitelist() &&
s->crypt_method_header == QCOW_CRYPT_AES) {
error_setg(VAR_3,
"Use of AES-CBC encrypted qcow images is no longer "
"supported in system emulators");
error_append_hint(VAR_3,
"You can use 'qemu-img convert' to convert your "
"image to an alternative supported format, such "
"as unencrypted qcow, or raw with the LUKS "
"format instead.\n");
VAR_7 = -ENOSYS;
goto fail;
}
VAR_0->encrypted = true;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
s->l2_bits = header.l2_bits;
s->l2_size = 1 << s->l2_bits;
VAR_0->total_sectors = header.size / 512;
s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
VAR_6 = s->cluster_bits + s->l2_bits;
if (header.size > UINT64_MAX - (1LL << VAR_6)) {
error_setg(VAR_3, "Image too large");
VAR_7 = -EINVAL;
goto fail;
} else {
uint64_t l1_size = (header.size + (1LL << VAR_6) - 1) >> VAR_6;
if (l1_size > INT_MAX / sizeof(uint64_t)) {
error_setg(VAR_3, "Image too large");
VAR_7 = -EINVAL;
goto fail;
}
s->l1_size = l1_size;
}
s->l1_table_offset = header.l1_table_offset;
s->l1_table = g_try_new(uint64_t, s->l1_size);
if (s->l1_table == NULL) {
error_setg(VAR_3, "Could not allocate memory for L1 table");
VAR_7 = -ENOMEM;
goto fail;
}
VAR_7 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (VAR_7 < 0) {
goto fail;
}
for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {
be64_to_cpus(&s->l1_table[VAR_5]);
}
s->l2_cache =
qemu_try_blockalign(VAR_0->file->VAR_0,
s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
if (s->l2_cache == NULL) {
error_setg(VAR_3, "Could not allocate L2 table cache");
VAR_7 = -ENOMEM;
goto fail;
}
s->cluster_cache = g_malloc(s->cluster_size);
s->cluster_data = g_malloc(s->cluster_size);
s->cluster_cache_offset = -1;
if (header.backing_file_offset != 0) {
VAR_4 = header.backing_file_size;
if (VAR_4 > 1023 || VAR_4 >= sizeof(VAR_0->backing_file)) {
error_setg(VAR_3, "Backing file name too long");
VAR_7 = -EINVAL;
goto fail;
}
VAR_7 = bdrv_pread(VAR_0->file, header.backing_file_offset,
VAR_0->backing_file, VAR_4);
if (VAR_7 < 0) {
goto fail;
}
VAR_0->backing_file[VAR_4] = '\0';
}
error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(VAR_0));
VAR_7 = migrate_add_blocker(s->migration_blocker, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
error_free(s->migration_blocker);
goto fail;
}
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
return VAR_7;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"unsigned int VAR_4, VAR_5, VAR_6;",
"int VAR_7;",
"QCowHeader header;",
"Error *local_err = NULL;",
"VAR_0->file = bdrv_open_child(NULL, VAR_1, \"file\", VAR_0, &child_file,\nfalse, VAR_3);",
"if (!VAR_0->file) {",
"return -EINVAL;",
"}",
"VAR_7 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));",
"if (VAR_7 < 0) {",
"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);",
"be32_to_cpus(&header.mtime);",
"be64_to_cpus(&header.size);",
"be32_to_cpus(&header.crypt_method);",
"be64_to_cpus(&header.l1_table_offset);",
"if (header.magic != QCOW_MAGIC) {",
"error_setg(VAR_3, \"Image not in qcow format\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"if (header.version != QCOW_VERSION) {",
"error_setg(VAR_3, \"Unsupported qcow version %\" PRIu32, header.version);",
"VAR_7 = -ENOTSUP;",
"goto fail;",
"}",
"if (header.size <= 1) {",
"error_setg(VAR_3, \"Image size is too small (must be at least 2 bytes)\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"if (header.cluster_bits < 9 || header.cluster_bits > 16) {",
"error_setg(VAR_3, \"Cluster size must be between 512 and 64k\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) {",
"error_setg(VAR_3, \"L2 table size must be between 512 and 64k\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"if (header.crypt_method > QCOW_CRYPT_AES) {",
"error_setg(VAR_3, \"invalid encryption method in qcow header\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,\nQCRYPTO_CIPHER_MODE_CBC)) {",
"error_setg(VAR_3, \"AES cipher not available\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"s->crypt_method_header = header.crypt_method;",
"if (s->crypt_method_header) {",
"if (bdrv_uses_whitelist() &&\ns->crypt_method_header == QCOW_CRYPT_AES) {",
"error_setg(VAR_3,\n\"Use of AES-CBC encrypted qcow images is no longer \"\n\"supported in system emulators\");",
"error_append_hint(VAR_3,\n\"You can use 'qemu-img convert' to convert your \"\n\"image to an alternative supported format, such \"\n\"as unencrypted qcow, or raw with the LUKS \"\n\"format instead.\\n\");",
"VAR_7 = -ENOSYS;",
"goto fail;",
"}",
"VAR_0->encrypted = true;",
"}",
"s->cluster_bits = header.cluster_bits;",
"s->cluster_size = 1 << s->cluster_bits;",
"s->cluster_sectors = 1 << (s->cluster_bits - 9);",
"s->l2_bits = header.l2_bits;",
"s->l2_size = 1 << s->l2_bits;",
"VAR_0->total_sectors = header.size / 512;",
"s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;",
"VAR_6 = s->cluster_bits + s->l2_bits;",
"if (header.size > UINT64_MAX - (1LL << VAR_6)) {",
"error_setg(VAR_3, \"Image too large\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"} else {",
"uint64_t l1_size = (header.size + (1LL << VAR_6) - 1) >> VAR_6;",
"if (l1_size > INT_MAX / sizeof(uint64_t)) {",
"error_setg(VAR_3, \"Image too large\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"s->l1_size = l1_size;",
"}",
"s->l1_table_offset = header.l1_table_offset;",
"s->l1_table = g_try_new(uint64_t, s->l1_size);",
"if (s->l1_table == NULL) {",
"error_setg(VAR_3, \"Could not allocate memory for L1 table\");",
"VAR_7 = -ENOMEM;",
"goto fail;",
"}",
"VAR_7 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,\ns->l1_size * sizeof(uint64_t));",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {",
"be64_to_cpus(&s->l1_table[VAR_5]);",
"}",
"s->l2_cache =\nqemu_try_blockalign(VAR_0->file->VAR_0,\ns->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));",
"if (s->l2_cache == NULL) {",
"error_setg(VAR_3, \"Could not allocate L2 table cache\");",
"VAR_7 = -ENOMEM;",
"goto fail;",
"}",
"s->cluster_cache = g_malloc(s->cluster_size);",
"s->cluster_data = g_malloc(s->cluster_size);",
"s->cluster_cache_offset = -1;",
"if (header.backing_file_offset != 0) {",
"VAR_4 = header.backing_file_size;",
"if (VAR_4 > 1023 || VAR_4 >= sizeof(VAR_0->backing_file)) {",
"error_setg(VAR_3, \"Backing file name too long\");",
"VAR_7 = -EINVAL;",
"goto fail;",
"}",
"VAR_7 = bdrv_pread(VAR_0->file, header.backing_file_offset,\nVAR_0->backing_file, VAR_4);",
"if (VAR_7 < 0) {",
"goto fail;",
"}",
"VAR_0->backing_file[VAR_4] = '\\0';",
"}",
"error_setg(&s->migration_blocker, \"The qcow format used by node '%s' \"\n\"does not support live migration\",\nbdrv_get_device_or_node_name(VAR_0));",
"VAR_7 = migrate_add_blocker(s->migration_blocker, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"error_free(s->migration_blocker);",
"goto fail;",
"}",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"fail:\ng_free(s->l1_table);",
"qemu_vfree(s->l2_cache);",
"g_free(s->cluster_cache);",
"g_free(s->cluster_data);",
"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,
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
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149,
151
],
[
153,
155,
157,
159,
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
261,
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
319,
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
]
] |
25,290 | static void sigp_restart(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
SigpInfo *si = arg.host_ptr;
struct kvm_s390_irq irq = {
.type = KVM_S390_RESTART,
};
switch (s390_cpu_get_state(cpu)) {
case CPU_STATE_STOPPED:
/* the restart irq has to be delivered prior to any other pending irq */
cpu_synchronize_state(cs);
do_restart_interrupt(&cpu->env);
s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
break;
case CPU_STATE_OPERATING:
kvm_s390_vcpu_interrupt(cpu, &irq);
break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| false | qemu | eabcea18f835178c1f8f088f88bf00e379f09438 | static void sigp_restart(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
SigpInfo *si = arg.host_ptr;
struct kvm_s390_irq irq = {
.type = KVM_S390_RESTART,
};
switch (s390_cpu_get_state(cpu)) {
case CPU_STATE_STOPPED:
cpu_synchronize_state(cs);
do_restart_interrupt(&cpu->env);
s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
break;
case CPU_STATE_OPERATING:
kvm_s390_vcpu_interrupt(cpu, &irq);
break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUState *VAR_0, run_on_cpu_data VAR_1)
{
S390CPU *cpu = S390_CPU(VAR_0);
SigpInfo *si = VAR_1.host_ptr;
struct kvm_s390_irq VAR_2 = {
.type = KVM_S390_RESTART,
};
switch (s390_cpu_get_state(cpu)) {
case CPU_STATE_STOPPED:
cpu_synchronize_state(VAR_0);
do_restart_interrupt(&cpu->env);
s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
break;
case CPU_STATE_OPERATING:
kvm_s390_vcpu_interrupt(cpu, &VAR_2);
break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
| [
"static void FUNC_0(CPUState *VAR_0, run_on_cpu_data VAR_1)\n{",
"S390CPU *cpu = S390_CPU(VAR_0);",
"SigpInfo *si = VAR_1.host_ptr;",
"struct kvm_s390_irq VAR_2 = {",
".type = KVM_S390_RESTART,\n};",
"switch (s390_cpu_get_state(cpu)) {",
"case CPU_STATE_STOPPED:\ncpu_synchronize_state(VAR_0);",
"do_restart_interrupt(&cpu->env);",
"s390_cpu_set_state(CPU_STATE_OPERATING, cpu);",
"break;",
"case CPU_STATE_OPERATING:\nkvm_s390_vcpu_interrupt(cpu, &VAR_2);",
"break;",
"}",
"si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
19,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
25,291 | void qemu_purge_queued_packets(VLANClientState *vc)
{
VLANPacket *packet, *next;
TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) {
if (packet->sender == vc) {
TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
qemu_free(packet);
}
}
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void qemu_purge_queued_packets(VLANClientState *vc)
{
VLANPacket *packet, *next;
TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) {
if (packet->sender == vc) {
TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
qemu_free(packet);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VLANClientState *VAR_0)
{
VLANPacket *packet, *next;
TAILQ_FOREACH_SAFE(packet, &VAR_0->vlan->send_queue, entry, next) {
if (packet->sender == VAR_0) {
TAILQ_REMOVE(&VAR_0->vlan->send_queue, packet, entry);
qemu_free(packet);
}
}
}
| [
"void FUNC_0(VLANClientState *VAR_0)\n{",
"VLANPacket *packet, *next;",
"TAILQ_FOREACH_SAFE(packet, &VAR_0->vlan->send_queue, entry, next) {",
"if (packet->sender == VAR_0) {",
"TAILQ_REMOVE(&VAR_0->vlan->send_queue, packet, entry);",
"qemu_free(packet);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
25,292 | static void mips_tlb_flush_extra (CPUState *env, int first)
{
/* Discard entries from env->tlb[first] onwards. */
while (env->tlb_in_use > first) {
invalidate_tlb(--env->tlb_in_use, 0);
}
}
| false | qemu | 2ee4aed86ff2ba38a0e1846de18a9aec38d73015 | static void mips_tlb_flush_extra (CPUState *env, int first)
{
while (env->tlb_in_use > first) {
invalidate_tlb(--env->tlb_in_use, 0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (CPUState *VAR_0, int VAR_1)
{
while (VAR_0->tlb_in_use > VAR_1) {
invalidate_tlb(--VAR_0->tlb_in_use, 0);
}
}
| [
"static void FUNC_0 (CPUState *VAR_0, int VAR_1)\n{",
"while (VAR_0->tlb_in_use > VAR_1) {",
"invalidate_tlb(--VAR_0->tlb_in_use, 0);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,293 | void ff_avg_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2,
stride, dst, stride, 8, 1);
}
| false | FFmpeg | 72dbc610be3272ba36603f78a39cc2d2d8fe0cc3 | void ff_avg_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(src - (2 * stride) - 2,
stride, dst, stride, 8, 1);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_midh_qrt_and_aver_dst_8w_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2, 8, 1);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_midh_qrt_and_aver_dst_8w_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2, 8, 1);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
25,294 | DeviceState *exynos4210_uart_create(target_phys_addr_t addr,
int fifo_size,
int channel,
CharDriverState *chr,
qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *bus;
const char chr_name[] = "serial";
char label[ARRAY_SIZE(chr_name) + 1];
dev = qdev_create(NULL, "exynos4210.uart");
if (!chr) {
if (channel >= MAX_SERIAL_PORTS) {
hw_error("Only %d serial ports are supported by QEMU.\n",
MAX_SERIAL_PORTS);
}
chr = serial_hds[channel];
if (!chr) {
snprintf(label, ARRAY_SIZE(label), "%s%d", chr_name, channel);
chr = qemu_chr_new(label, "null", NULL);
if (!(chr)) {
hw_error("Can't assign serial port to UART%d.\n", channel);
}
}
}
qdev_prop_set_chr(dev, "chardev", chr);
qdev_prop_set_uint32(dev, "channel", channel);
qdev_prop_set_uint32(dev, "rx-size", fifo_size);
qdev_prop_set_uint32(dev, "tx-size", fifo_size);
bus = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(bus, 0, addr);
}
sysbus_connect_irq(bus, 0, irq);
return dev;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | DeviceState *exynos4210_uart_create(target_phys_addr_t addr,
int fifo_size,
int channel,
CharDriverState *chr,
qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *bus;
const char chr_name[] = "serial";
char label[ARRAY_SIZE(chr_name) + 1];
dev = qdev_create(NULL, "exynos4210.uart");
if (!chr) {
if (channel >= MAX_SERIAL_PORTS) {
hw_error("Only %d serial ports are supported by QEMU.\n",
MAX_SERIAL_PORTS);
}
chr = serial_hds[channel];
if (!chr) {
snprintf(label, ARRAY_SIZE(label), "%s%d", chr_name, channel);
chr = qemu_chr_new(label, "null", NULL);
if (!(chr)) {
hw_error("Can't assign serial port to UART%d.\n", channel);
}
}
}
qdev_prop_set_chr(dev, "chardev", chr);
qdev_prop_set_uint32(dev, "channel", channel);
qdev_prop_set_uint32(dev, "rx-size", fifo_size);
qdev_prop_set_uint32(dev, "tx-size", fifo_size);
bus = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(bus, 0, addr);
}
sysbus_connect_irq(bus, 0, irq);
return dev;
}
| {
"code": [],
"line_no": []
} | DeviceState *FUNC_0(target_phys_addr_t addr,
int fifo_size,
int channel,
CharDriverState *chr,
qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *bus;
const char VAR_0[] = "serial";
char VAR_1[ARRAY_SIZE(VAR_0) + 1];
dev = qdev_create(NULL, "exynos4210.uart");
if (!chr) {
if (channel >= MAX_SERIAL_PORTS) {
hw_error("Only %d serial ports are supported by QEMU.\n",
MAX_SERIAL_PORTS);
}
chr = serial_hds[channel];
if (!chr) {
snprintf(VAR_1, ARRAY_SIZE(VAR_1), "%s%d", VAR_0, channel);
chr = qemu_chr_new(VAR_1, "null", NULL);
if (!(chr)) {
hw_error("Can't assign serial port to UART%d.\n", channel);
}
}
}
qdev_prop_set_chr(dev, "chardev", chr);
qdev_prop_set_uint32(dev, "channel", channel);
qdev_prop_set_uint32(dev, "rx-size", fifo_size);
qdev_prop_set_uint32(dev, "tx-size", fifo_size);
bus = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(bus, 0, addr);
}
sysbus_connect_irq(bus, 0, irq);
return dev;
}
| [
"DeviceState *FUNC_0(target_phys_addr_t addr,\nint fifo_size,\nint channel,\nCharDriverState *chr,\nqemu_irq irq)\n{",
"DeviceState *dev;",
"SysBusDevice *bus;",
"const char VAR_0[] = \"serial\";",
"char VAR_1[ARRAY_SIZE(VAR_0) + 1];",
"dev = qdev_create(NULL, \"exynos4210.uart\");",
"if (!chr) {",
"if (channel >= MAX_SERIAL_PORTS) {",
"hw_error(\"Only %d serial ports are supported by QEMU.\\n\",\nMAX_SERIAL_PORTS);",
"}",
"chr = serial_hds[channel];",
"if (!chr) {",
"snprintf(VAR_1, ARRAY_SIZE(VAR_1), \"%s%d\", VAR_0, channel);",
"chr = qemu_chr_new(VAR_1, \"null\", NULL);",
"if (!(chr)) {",
"hw_error(\"Can't assign serial port to UART%d.\\n\", channel);",
"}",
"}",
"}",
"qdev_prop_set_chr(dev, \"chardev\", chr);",
"qdev_prop_set_uint32(dev, \"channel\", channel);",
"qdev_prop_set_uint32(dev, \"rx-size\", fifo_size);",
"qdev_prop_set_uint32(dev, \"tx-size\", fifo_size);",
"bus = sysbus_from_qdev(dev);",
"qdev_init_nofail(dev);",
"if (addr != (target_phys_addr_t)-1) {",
"sysbus_mmio_map(bus, 0, addr);",
"}",
"sysbus_connect_irq(bus, 0, irq);",
"return dev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
25,295 | static VncClientInfo *qmp_query_vnc_client(const VncState *client)
{
struct sockaddr_storage sa;
socklen_t salen = sizeof(sa);
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
VncClientInfo *info;
if (getpeername(client->csock, (struct sockaddr *)&sa, &salen) < 0) {
return NULL;
}
if (getnameinfo((struct sockaddr *)&sa, salen,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
return NULL;
}
info = g_malloc0(sizeof(*info));
info->base = g_malloc0(sizeof(*info->base));
info->base->host = g_strdup(host);
info->base->service = g_strdup(serv);
info->base->family = inet_netfamily(sa.ss_family);
info->base->websocket = client->websocket;
if (client->tls) {
info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);
info->has_x509_dname = info->x509_dname != NULL;
}
#ifdef CONFIG_VNC_SASL
if (client->sasl.conn && client->sasl.username) {
info->has_sasl_username = true;
info->sasl_username = g_strdup(client->sasl.username);
}
#endif
return info;
}
| false | qemu | ddf21908961073199f3d186204da4810f2ea150b | static VncClientInfo *qmp_query_vnc_client(const VncState *client)
{
struct sockaddr_storage sa;
socklen_t salen = sizeof(sa);
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
VncClientInfo *info;
if (getpeername(client->csock, (struct sockaddr *)&sa, &salen) < 0) {
return NULL;
}
if (getnameinfo((struct sockaddr *)&sa, salen,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
return NULL;
}
info = g_malloc0(sizeof(*info));
info->base = g_malloc0(sizeof(*info->base));
info->base->host = g_strdup(host);
info->base->service = g_strdup(serv);
info->base->family = inet_netfamily(sa.ss_family);
info->base->websocket = client->websocket;
if (client->tls) {
info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);
info->has_x509_dname = info->x509_dname != NULL;
}
#ifdef CONFIG_VNC_SASL
if (client->sasl.conn && client->sasl.username) {
info->has_sasl_username = true;
info->sasl_username = g_strdup(client->sasl.username);
}
#endif
return info;
}
| {
"code": [],
"line_no": []
} | static VncClientInfo *FUNC_0(const VncState *client)
{
struct sockaddr_storage VAR_0;
socklen_t salen = sizeof(VAR_0);
char VAR_1[NI_MAXHOST];
char VAR_2[NI_MAXSERV];
VncClientInfo *info;
if (getpeername(client->csock, (struct sockaddr *)&VAR_0, &salen) < 0) {
return NULL;
}
if (getnameinfo((struct sockaddr *)&VAR_0, salen,
VAR_1, sizeof(VAR_1),
VAR_2, sizeof(VAR_2),
NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
return NULL;
}
info = g_malloc0(sizeof(*info));
info->base = g_malloc0(sizeof(*info->base));
info->base->VAR_1 = g_strdup(VAR_1);
info->base->service = g_strdup(VAR_2);
info->base->family = inet_netfamily(VAR_0.ss_family);
info->base->websocket = client->websocket;
if (client->tls) {
info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);
info->has_x509_dname = info->x509_dname != NULL;
}
#ifdef CONFIG_VNC_SASL
if (client->sasl.conn && client->sasl.username) {
info->has_sasl_username = true;
info->sasl_username = g_strdup(client->sasl.username);
}
#endif
return info;
}
| [
"static VncClientInfo *FUNC_0(const VncState *client)\n{",
"struct sockaddr_storage VAR_0;",
"socklen_t salen = sizeof(VAR_0);",
"char VAR_1[NI_MAXHOST];",
"char VAR_2[NI_MAXSERV];",
"VncClientInfo *info;",
"if (getpeername(client->csock, (struct sockaddr *)&VAR_0, &salen) < 0) {",
"return NULL;",
"}",
"if (getnameinfo((struct sockaddr *)&VAR_0, salen,\nVAR_1, sizeof(VAR_1),\nVAR_2, sizeof(VAR_2),\nNI_NUMERICHOST | NI_NUMERICSERV) < 0) {",
"return NULL;",
"}",
"info = g_malloc0(sizeof(*info));",
"info->base = g_malloc0(sizeof(*info->base));",
"info->base->VAR_1 = g_strdup(VAR_1);",
"info->base->service = g_strdup(VAR_2);",
"info->base->family = inet_netfamily(VAR_0.ss_family);",
"info->base->websocket = client->websocket;",
"if (client->tls) {",
"info->x509_dname = qcrypto_tls_session_get_peer_name(client->tls);",
"info->has_x509_dname = info->x509_dname != NULL;",
"}",
"#ifdef CONFIG_VNC_SASL\nif (client->sasl.conn && client->sasl.username) {",
"info->has_sasl_username = true;",
"info->sasl_username = g_strdup(client->sasl.username);",
"}",
"#endif\nreturn 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27,
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71,
75
],
[
77
]
] |
25,296 | static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
{
uint8_t *src;
int x, y, x_end, y_end, chroma;
int c_tc[2], beta[2], tc[2];
uint8_t no_p[2] = { 0 };
uint8_t no_q[2] = { 0 };
int log2_ctb_size = s->sps->log2_ctb_size;
int ctb_size = 1 << log2_ctb_size;
int ctb = (x0 >> log2_ctb_size) +
(y0 >> log2_ctb_size) * s->sps->ctb_width;
int cur_tc_offset = s->deblock[ctb].tc_offset;
int cur_beta_offset = s->deblock[ctb].beta_offset;
int tc_offset, left_tc_offset, beta_offset, left_beta_offset;
int pcmf = (s->sps->pcm_enabled_flag &&
s->sps->pcm.loop_filter_disable_flag) ||
s->pps->transquant_bypass_enable_flag;
if (x0) {
left_tc_offset = s->deblock[ctb - 1].tc_offset;
left_beta_offset = s->deblock[ctb - 1].beta_offset;
}
x_end = x0 + ctb_size;
if (x_end > s->sps->width)
x_end = s->sps->width;
y_end = y0 + ctb_size;
if (y_end > s->sps->height)
y_end = s->sps->height;
tc_offset = cur_tc_offset;
beta_offset = cur_beta_offset;
// vertical filtering luma
for (y = y0; y < y_end; y += 8) {
for (x = x0 ? x0 : 8; x < x_end; x += 8) {
const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width];
const int bs1 = s->vertical_bs[(x >> 3) + ((y + 4) >> 2) * s->bs_width];
if (bs0 || bs1) {
const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x - 1, y + 4) + get_qPy(s, x, y + 4) + 1) >> 1;
beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + 4);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x, y + 4);
s->hevcdsp.hevc_v_loop_filter_luma_c(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
} else
s->hevcdsp.hevc_v_loop_filter_luma(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
}
}
}
// vertical filtering chroma
for (chroma = 1; chroma <= 2; chroma++) {
for (y = y0; y < y_end; y += 16) {
for (x = x0 ? x0 : 16; x < x_end; x += 16) {
const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width];
const int bs1 = s->vertical_bs[(x >> 3) + ((y + 8) >> 2) * s->bs_width];
if ((bs0 == 2) || (bs1 == 2)) {
const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x - 1, y + 8) + get_qPy(s, x, y + 8) + 1) >> 1;
c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
src = &s->frame->data[chroma][y / 2 * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + 8);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x, y + 8);
s->hevcdsp.hevc_v_loop_filter_chroma_c(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
} else
s->hevcdsp.hevc_v_loop_filter_chroma(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
}
}
}
}
// horizontal filtering luma
if (x_end != s->sps->width)
x_end -= 8;
for (y = y0 ? y0 : 8; y < y_end; y += 8) {
for (x = x0 ? x0 - 8 : 0; x < x_end; x += 8) {
const int bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
const int bs1 = s->horizontal_bs[(x + 4 + y * s->bs_width) >> 2];
if (bs0 || bs1) {
const int qp0 = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x + 4, y - 1) + get_qPy(s, x + 4, y) + 1) >> 1;
tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 4, y - 1);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x + 4, y);
s->hevcdsp.hevc_h_loop_filter_luma_c(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
} else
s->hevcdsp.hevc_h_loop_filter_luma(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
}
}
}
// horizontal filtering chroma
for (chroma = 1; chroma <= 2; chroma++) {
for (y = y0 ? y0 : 16; y < y_end; y += 16) {
for (x = x0 - 8; x < x_end; x += 16) {
int bs0, bs1;
// to make sure no memory access over boundary when x = -8
// TODO: simplify with row based deblocking
if (x < 0) {
bs0 = 0;
bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2];
} else if (x >= x_end - 8) {
bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
bs1 = 0;
} else {
bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2];
}
if ((bs0 == 2) || (bs1 == 2)) {
const int qp0 = bs0 == 2 ? (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1 : 0;
const int qp1 = bs1 == 2 ? (get_qPy(s, x + 8, y - 1) + get_qPy(s, x + 8, y) + 1) >> 1 : 0;
tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
src = &s->frame->data[chroma][y / 2 * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 8, y - 1);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x + 8, y);
s->hevcdsp.hevc_h_loop_filter_chroma_c(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
} else
s->hevcdsp.hevc_h_loop_filter_chroma(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
}
}
}
}
}
| false | FFmpeg | 73bb8f61d48dbf7237df2e9cacd037f12b84b00a | static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
{
uint8_t *src;
int x, y, x_end, y_end, chroma;
int c_tc[2], beta[2], tc[2];
uint8_t no_p[2] = { 0 };
uint8_t no_q[2] = { 0 };
int log2_ctb_size = s->sps->log2_ctb_size;
int ctb_size = 1 << log2_ctb_size;
int ctb = (x0 >> log2_ctb_size) +
(y0 >> log2_ctb_size) * s->sps->ctb_width;
int cur_tc_offset = s->deblock[ctb].tc_offset;
int cur_beta_offset = s->deblock[ctb].beta_offset;
int tc_offset, left_tc_offset, beta_offset, left_beta_offset;
int pcmf = (s->sps->pcm_enabled_flag &&
s->sps->pcm.loop_filter_disable_flag) ||
s->pps->transquant_bypass_enable_flag;
if (x0) {
left_tc_offset = s->deblock[ctb - 1].tc_offset;
left_beta_offset = s->deblock[ctb - 1].beta_offset;
}
x_end = x0 + ctb_size;
if (x_end > s->sps->width)
x_end = s->sps->width;
y_end = y0 + ctb_size;
if (y_end > s->sps->height)
y_end = s->sps->height;
tc_offset = cur_tc_offset;
beta_offset = cur_beta_offset;
for (y = y0; y < y_end; y += 8) {
for (x = x0 ? x0 : 8; x < x_end; x += 8) {
const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width];
const int bs1 = s->vertical_bs[(x >> 3) + ((y + 4) >> 2) * s->bs_width];
if (bs0 || bs1) {
const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x - 1, y + 4) + get_qPy(s, x, y + 4) + 1) >> 1;
beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + 4);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x, y + 4);
s->hevcdsp.hevc_v_loop_filter_luma_c(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
} else
s->hevcdsp.hevc_v_loop_filter_luma(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
}
}
}
for (chroma = 1; chroma <= 2; chroma++) {
for (y = y0; y < y_end; y += 16) {
for (x = x0 ? x0 : 16; x < x_end; x += 16) {
const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width];
const int bs1 = s->vertical_bs[(x >> 3) + ((y + 8) >> 2) * s->bs_width];
if ((bs0 == 2) || (bs1 == 2)) {
const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x - 1, y + 8) + get_qPy(s, x, y + 8) + 1) >> 1;
c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
src = &s->frame->data[chroma][y / 2 * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + 8);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x, y + 8);
s->hevcdsp.hevc_v_loop_filter_chroma_c(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
} else
s->hevcdsp.hevc_v_loop_filter_chroma(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
}
}
}
}
if (x_end != s->sps->width)
x_end -= 8;
for (y = y0 ? y0 : 8; y < y_end; y += 8) {
for (x = x0 ? x0 - 8 : 0; x < x_end; x += 8) {
const int bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
const int bs1 = s->horizontal_bs[(x + 4 + y * s->bs_width) >> 2];
if (bs0 || bs1) {
const int qp0 = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1;
const int qp1 = (get_qPy(s, x + 4, y - 1) + get_qPy(s, x + 4, y) + 1) >> 1;
tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0;
src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 4, y - 1);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x + 4, y);
s->hevcdsp.hevc_h_loop_filter_luma_c(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
} else
s->hevcdsp.hevc_h_loop_filter_luma(src,
s->frame->linesize[LUMA],
beta, tc, no_p, no_q);
}
}
}
for (chroma = 1; chroma <= 2; chroma++) {
for (y = y0 ? y0 : 16; y < y_end; y += 16) {
for (x = x0 - 8; x < x_end; x += 16) {
int bs0, bs1;
if (x < 0) {
bs0 = 0;
bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2];
} else if (x >= x_end - 8) {
bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
bs1 = 0;
} else {
bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2];
bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2];
}
if ((bs0 == 2) || (bs1 == 2)) {
const int qp0 = bs0 == 2 ? (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1 : 0;
const int qp1 = bs1 == 2 ? (get_qPy(s, x + 8, y - 1) + get_qPy(s, x + 8, y) + 1) >> 1 : 0;
tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
src = &s->frame->data[chroma][y / 2 * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 8, y - 1);
no_q[0] = get_pcm(s, x, y);
no_q[1] = get_pcm(s, x + 8, y);
s->hevcdsp.hevc_h_loop_filter_chroma_c(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
} else
s->hevcdsp.hevc_h_loop_filter_chroma(src,
s->frame->linesize[chroma],
c_tc, no_p, no_q);
}
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2)
{
uint8_t *src;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8[2], VAR_9[2], VAR_10[2];
uint8_t no_p[2] = { 0 };
uint8_t no_q[2] = { 0 };
int VAR_11 = VAR_0->sps->VAR_11;
int VAR_12 = 1 << VAR_11;
int VAR_13 = (VAR_1 >> VAR_11) +
(VAR_2 >> VAR_11) * VAR_0->sps->ctb_width;
int VAR_14 = VAR_0->deblock[VAR_13].VAR_16;
int VAR_15 = VAR_0->deblock[VAR_13].VAR_18;
int VAR_16, VAR_17, VAR_18, VAR_19;
int VAR_20 = (VAR_0->sps->pcm_enabled_flag &&
VAR_0->sps->pcm.loop_filter_disable_flag) ||
VAR_0->pps->transquant_bypass_enable_flag;
if (VAR_1) {
VAR_17 = VAR_0->deblock[VAR_13 - 1].VAR_16;
VAR_19 = VAR_0->deblock[VAR_13 - 1].VAR_18;
}
VAR_5 = VAR_1 + VAR_12;
if (VAR_5 > VAR_0->sps->width)
VAR_5 = VAR_0->sps->width;
VAR_6 = VAR_2 + VAR_12;
if (VAR_6 > VAR_0->sps->height)
VAR_6 = VAR_0->sps->height;
VAR_16 = VAR_14;
VAR_18 = VAR_15;
for (VAR_4 = VAR_2; VAR_4 < VAR_6; VAR_4 += 8) {
for (VAR_3 = VAR_1 ? VAR_1 : 8; VAR_3 < VAR_5; VAR_3 += 8) {
const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + (VAR_4 >> 2) * VAR_0->bs_width];
const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + ((VAR_4 + 4) >> 2) * VAR_0->bs_width];
if (VAR_25 || VAR_25) {
const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;
const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4 + 4) + get_qPy(VAR_0, VAR_3, VAR_4 + 4) + 1) >> 1;
VAR_9[0] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];
VAR_9[1] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];
VAR_10[0] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;
VAR_10[1] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;
src = &VAR_0->frame->data[LUMA][VAR_4 * VAR_0->frame->linesize[LUMA] + (VAR_3 << VAR_0->sps->pixel_shift)];
if (VAR_20) {
no_p[0] = get_pcm(VAR_0, VAR_3 - 1, VAR_4);
no_p[1] = get_pcm(VAR_0, VAR_3 - 1, VAR_4 + 4);
no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);
no_q[1] = get_pcm(VAR_0, VAR_3, VAR_4 + 4);
VAR_0->hevcdsp.hevc_v_loop_filter_luma_c(src,
VAR_0->frame->linesize[LUMA],
VAR_9, VAR_10, no_p, no_q);
} else
VAR_0->hevcdsp.hevc_v_loop_filter_luma(src,
VAR_0->frame->linesize[LUMA],
VAR_9, VAR_10, no_p, no_q);
}
}
}
for (VAR_7 = 1; VAR_7 <= 2; VAR_7++) {
for (VAR_4 = VAR_2; VAR_4 < VAR_6; VAR_4 += 16) {
for (VAR_3 = VAR_1 ? VAR_1 : 16; VAR_3 < VAR_5; VAR_3 += 16) {
const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + (VAR_4 >> 2) * VAR_0->bs_width];
const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + ((VAR_4 + 8) >> 2) * VAR_0->bs_width];
if ((VAR_25 == 2) || (VAR_25 == 2)) {
const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;
const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4 + 8) + get_qPy(VAR_0, VAR_3, VAR_4 + 8) + 1) >> 1;
VAR_8[0] = (VAR_25 == 2) ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;
VAR_8[1] = (VAR_25 == 2) ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;
src = &VAR_0->frame->data[VAR_7][VAR_4 / 2 * VAR_0->frame->linesize[VAR_7] + ((VAR_3 / 2) << VAR_0->sps->pixel_shift)];
if (VAR_20) {
no_p[0] = get_pcm(VAR_0, VAR_3 - 1, VAR_4);
no_p[1] = get_pcm(VAR_0, VAR_3 - 1, VAR_4 + 8);
no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);
no_q[1] = get_pcm(VAR_0, VAR_3, VAR_4 + 8);
VAR_0->hevcdsp.hevc_v_loop_filter_chroma_c(src,
VAR_0->frame->linesize[VAR_7],
VAR_8, no_p, no_q);
} else
VAR_0->hevcdsp.hevc_v_loop_filter_chroma(src,
VAR_0->frame->linesize[VAR_7],
VAR_8, no_p, no_q);
}
}
}
}
if (VAR_5 != VAR_0->sps->width)
VAR_5 -= 8;
for (VAR_4 = VAR_2 ? VAR_2 : 8; VAR_4 < VAR_6; VAR_4 += 8) {
for (VAR_3 = VAR_1 ? VAR_1 - 8 : 0; VAR_3 < VAR_5; VAR_3 += 8) {
const int VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];
const int VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 4 + VAR_4 * VAR_0->bs_width) >> 2];
if (VAR_25 || VAR_25) {
const int VAR_25 = (get_qPy(VAR_0, VAR_3, VAR_4 - 1) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;
const int VAR_25 = (get_qPy(VAR_0, VAR_3 + 4, VAR_4 - 1) + get_qPy(VAR_0, VAR_3 + 4, VAR_4) + 1) >> 1;
VAR_16 = VAR_3 >= VAR_1 ? VAR_14 : VAR_17;
VAR_18 = VAR_3 >= VAR_1 ? VAR_15 : VAR_19;
VAR_9[0] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];
VAR_9[1] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];
VAR_10[0] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;
VAR_10[1] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;
src = &VAR_0->frame->data[LUMA][VAR_4 * VAR_0->frame->linesize[LUMA] + (VAR_3 << VAR_0->sps->pixel_shift)];
if (VAR_20) {
no_p[0] = get_pcm(VAR_0, VAR_3, VAR_4 - 1);
no_p[1] = get_pcm(VAR_0, VAR_3 + 4, VAR_4 - 1);
no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);
no_q[1] = get_pcm(VAR_0, VAR_3 + 4, VAR_4);
VAR_0->hevcdsp.hevc_h_loop_filter_luma_c(src,
VAR_0->frame->linesize[LUMA],
VAR_9, VAR_10, no_p, no_q);
} else
VAR_0->hevcdsp.hevc_h_loop_filter_luma(src,
VAR_0->frame->linesize[LUMA],
VAR_9, VAR_10, no_p, no_q);
}
}
}
for (VAR_7 = 1; VAR_7 <= 2; VAR_7++) {
for (VAR_4 = VAR_2 ? VAR_2 : 16; VAR_4 < VAR_6; VAR_4 += 16) {
for (VAR_3 = VAR_1 - 8; VAR_3 < VAR_5; VAR_3 += 16) {
int VAR_25, VAR_25;
if (VAR_3 < 0) {
VAR_25 = 0;
VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 8 + VAR_4 * VAR_0->bs_width) >> 2];
} else if (VAR_3 >= VAR_5 - 8) {
VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];
VAR_25 = 0;
} else {
VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];
VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 8 + VAR_4 * VAR_0->bs_width) >> 2];
}
if ((VAR_25 == 2) || (VAR_25 == 2)) {
const int VAR_25 = VAR_25 == 2 ? (get_qPy(VAR_0, VAR_3, VAR_4 - 1) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1 : 0;
const int VAR_25 = VAR_25 == 2 ? (get_qPy(VAR_0, VAR_3 + 8, VAR_4 - 1) + get_qPy(VAR_0, VAR_3 + 8, VAR_4) + 1) >> 1 : 0;
VAR_16 = VAR_3 >= VAR_1 ? VAR_14 : VAR_17;
VAR_8[0] = VAR_25 == 2 ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;
VAR_8[1] = VAR_25 == 2 ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_14) : 0;
src = &VAR_0->frame->data[VAR_7][VAR_4 / 2 * VAR_0->frame->linesize[VAR_7] + ((VAR_3 / 2) << VAR_0->sps->pixel_shift)];
if (VAR_20) {
no_p[0] = get_pcm(VAR_0, VAR_3, VAR_4 - 1);
no_p[1] = get_pcm(VAR_0, VAR_3 + 8, VAR_4 - 1);
no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);
no_q[1] = get_pcm(VAR_0, VAR_3 + 8, VAR_4);
VAR_0->hevcdsp.hevc_h_loop_filter_chroma_c(src,
VAR_0->frame->linesize[VAR_7],
VAR_8, no_p, no_q);
} else
VAR_0->hevcdsp.hevc_h_loop_filter_chroma(src,
VAR_0->frame->linesize[VAR_7],
VAR_8, no_p, no_q);
}
}
}
}
}
| [
"static void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2)\n{",
"uint8_t *src;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8[2], VAR_9[2], VAR_10[2];",
"uint8_t no_p[2] = { 0 };",
"uint8_t no_q[2] = { 0 };",
"int VAR_11 = VAR_0->sps->VAR_11;",
"int VAR_12 = 1 << VAR_11;",
"int VAR_13 = (VAR_1 >> VAR_11) +\n(VAR_2 >> VAR_11) * VAR_0->sps->ctb_width;",
"int VAR_14 = VAR_0->deblock[VAR_13].VAR_16;",
"int VAR_15 = VAR_0->deblock[VAR_13].VAR_18;",
"int VAR_16, VAR_17, VAR_18, VAR_19;",
"int VAR_20 = (VAR_0->sps->pcm_enabled_flag &&\nVAR_0->sps->pcm.loop_filter_disable_flag) ||\nVAR_0->pps->transquant_bypass_enable_flag;",
"if (VAR_1) {",
"VAR_17 = VAR_0->deblock[VAR_13 - 1].VAR_16;",
"VAR_19 = VAR_0->deblock[VAR_13 - 1].VAR_18;",
"}",
"VAR_5 = VAR_1 + VAR_12;",
"if (VAR_5 > VAR_0->sps->width)\nVAR_5 = VAR_0->sps->width;",
"VAR_6 = VAR_2 + VAR_12;",
"if (VAR_6 > VAR_0->sps->height)\nVAR_6 = VAR_0->sps->height;",
"VAR_16 = VAR_14;",
"VAR_18 = VAR_15;",
"for (VAR_4 = VAR_2; VAR_4 < VAR_6; VAR_4 += 8) {",
"for (VAR_3 = VAR_1 ? VAR_1 : 8; VAR_3 < VAR_5; VAR_3 += 8) {",
"const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + (VAR_4 >> 2) * VAR_0->bs_width];",
"const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + ((VAR_4 + 4) >> 2) * VAR_0->bs_width];",
"if (VAR_25 || VAR_25) {",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4 + 4) + get_qPy(VAR_0, VAR_3, VAR_4 + 4) + 1) >> 1;",
"VAR_9[0] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];",
"VAR_9[1] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];",
"VAR_10[0] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;",
"VAR_10[1] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;",
"src = &VAR_0->frame->data[LUMA][VAR_4 * VAR_0->frame->linesize[LUMA] + (VAR_3 << VAR_0->sps->pixel_shift)];",
"if (VAR_20) {",
"no_p[0] = get_pcm(VAR_0, VAR_3 - 1, VAR_4);",
"no_p[1] = get_pcm(VAR_0, VAR_3 - 1, VAR_4 + 4);",
"no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);",
"no_q[1] = get_pcm(VAR_0, VAR_3, VAR_4 + 4);",
"VAR_0->hevcdsp.hevc_v_loop_filter_luma_c(src,\nVAR_0->frame->linesize[LUMA],\nVAR_9, VAR_10, no_p, no_q);",
"} else",
"VAR_0->hevcdsp.hevc_v_loop_filter_luma(src,\nVAR_0->frame->linesize[LUMA],\nVAR_9, VAR_10, no_p, no_q);",
"}",
"}",
"}",
"for (VAR_7 = 1; VAR_7 <= 2; VAR_7++) {",
"for (VAR_4 = VAR_2; VAR_4 < VAR_6; VAR_4 += 16) {",
"for (VAR_3 = VAR_1 ? VAR_1 : 16; VAR_3 < VAR_5; VAR_3 += 16) {",
"const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + (VAR_4 >> 2) * VAR_0->bs_width];",
"const int VAR_25 = VAR_0->vertical_bs[(VAR_3 >> 3) + ((VAR_4 + 8) >> 2) * VAR_0->bs_width];",
"if ((VAR_25 == 2) || (VAR_25 == 2)) {",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3 - 1, VAR_4 + 8) + get_qPy(VAR_0, VAR_3, VAR_4 + 8) + 1) >> 1;",
"VAR_8[0] = (VAR_25 == 2) ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;",
"VAR_8[1] = (VAR_25 == 2) ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;",
"src = &VAR_0->frame->data[VAR_7][VAR_4 / 2 * VAR_0->frame->linesize[VAR_7] + ((VAR_3 / 2) << VAR_0->sps->pixel_shift)];",
"if (VAR_20) {",
"no_p[0] = get_pcm(VAR_0, VAR_3 - 1, VAR_4);",
"no_p[1] = get_pcm(VAR_0, VAR_3 - 1, VAR_4 + 8);",
"no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);",
"no_q[1] = get_pcm(VAR_0, VAR_3, VAR_4 + 8);",
"VAR_0->hevcdsp.hevc_v_loop_filter_chroma_c(src,\nVAR_0->frame->linesize[VAR_7],\nVAR_8, no_p, no_q);",
"} else",
"VAR_0->hevcdsp.hevc_v_loop_filter_chroma(src,\nVAR_0->frame->linesize[VAR_7],\nVAR_8, no_p, no_q);",
"}",
"}",
"}",
"}",
"if (VAR_5 != VAR_0->sps->width)\nVAR_5 -= 8;",
"for (VAR_4 = VAR_2 ? VAR_2 : 8; VAR_4 < VAR_6; VAR_4 += 8) {",
"for (VAR_3 = VAR_1 ? VAR_1 - 8 : 0; VAR_3 < VAR_5; VAR_3 += 8) {",
"const int VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];",
"const int VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 4 + VAR_4 * VAR_0->bs_width) >> 2];",
"if (VAR_25 || VAR_25) {",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3, VAR_4 - 1) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1;",
"const int VAR_25 = (get_qPy(VAR_0, VAR_3 + 4, VAR_4 - 1) + get_qPy(VAR_0, VAR_3 + 4, VAR_4) + 1) >> 1;",
"VAR_16 = VAR_3 >= VAR_1 ? VAR_14 : VAR_17;",
"VAR_18 = VAR_3 >= VAR_1 ? VAR_15 : VAR_19;",
"VAR_9[0] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];",
"VAR_9[1] = betatable[av_clip(VAR_25 + VAR_18, 0, MAX_QP)];",
"VAR_10[0] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;",
"VAR_10[1] = VAR_25 ? TC_CALC(VAR_25, VAR_25) : 0;",
"src = &VAR_0->frame->data[LUMA][VAR_4 * VAR_0->frame->linesize[LUMA] + (VAR_3 << VAR_0->sps->pixel_shift)];",
"if (VAR_20) {",
"no_p[0] = get_pcm(VAR_0, VAR_3, VAR_4 - 1);",
"no_p[1] = get_pcm(VAR_0, VAR_3 + 4, VAR_4 - 1);",
"no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);",
"no_q[1] = get_pcm(VAR_0, VAR_3 + 4, VAR_4);",
"VAR_0->hevcdsp.hevc_h_loop_filter_luma_c(src,\nVAR_0->frame->linesize[LUMA],\nVAR_9, VAR_10, no_p, no_q);",
"} else",
"VAR_0->hevcdsp.hevc_h_loop_filter_luma(src,\nVAR_0->frame->linesize[LUMA],\nVAR_9, VAR_10, no_p, no_q);",
"}",
"}",
"}",
"for (VAR_7 = 1; VAR_7 <= 2; VAR_7++) {",
"for (VAR_4 = VAR_2 ? VAR_2 : 16; VAR_4 < VAR_6; VAR_4 += 16) {",
"for (VAR_3 = VAR_1 - 8; VAR_3 < VAR_5; VAR_3 += 16) {",
"int VAR_25, VAR_25;",
"if (VAR_3 < 0) {",
"VAR_25 = 0;",
"VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 8 + VAR_4 * VAR_0->bs_width) >> 2];",
"} else if (VAR_3 >= VAR_5 - 8) {",
"VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];",
"VAR_25 = 0;",
"} else {",
"VAR_25 = VAR_0->horizontal_bs[(VAR_3 + VAR_4 * VAR_0->bs_width) >> 2];",
"VAR_25 = VAR_0->horizontal_bs[(VAR_3 + 8 + VAR_4 * VAR_0->bs_width) >> 2];",
"}",
"if ((VAR_25 == 2) || (VAR_25 == 2)) {",
"const int VAR_25 = VAR_25 == 2 ? (get_qPy(VAR_0, VAR_3, VAR_4 - 1) + get_qPy(VAR_0, VAR_3, VAR_4) + 1) >> 1 : 0;",
"const int VAR_25 = VAR_25 == 2 ? (get_qPy(VAR_0, VAR_3 + 8, VAR_4 - 1) + get_qPy(VAR_0, VAR_3 + 8, VAR_4) + 1) >> 1 : 0;",
"VAR_16 = VAR_3 >= VAR_1 ? VAR_14 : VAR_17;",
"VAR_8[0] = VAR_25 == 2 ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_16) : 0;",
"VAR_8[1] = VAR_25 == 2 ? chroma_tc(VAR_0, VAR_25, VAR_7, VAR_14) : 0;",
"src = &VAR_0->frame->data[VAR_7][VAR_4 / 2 * VAR_0->frame->linesize[VAR_7] + ((VAR_3 / 2) << VAR_0->sps->pixel_shift)];",
"if (VAR_20) {",
"no_p[0] = get_pcm(VAR_0, VAR_3, VAR_4 - 1);",
"no_p[1] = get_pcm(VAR_0, VAR_3 + 8, VAR_4 - 1);",
"no_q[0] = get_pcm(VAR_0, VAR_3, VAR_4);",
"no_q[1] = get_pcm(VAR_0, VAR_3 + 8, VAR_4);",
"VAR_0->hevcdsp.hevc_h_loop_filter_chroma_c(src,\nVAR_0->frame->linesize[VAR_7],\nVAR_8, no_p, no_q);",
"} else",
"VAR_0->hevcdsp.hevc_h_loop_filter_chroma(src,\nVAR_0->frame->linesize[VAR_7],\nVAR_8, no_p, no_q);",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33,
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
63
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115,
117,
119
],
[
121
],
[
123
],
[
125
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167,
169
],
[
171
],
[
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239,
241
],
[
243
],
[
245,
247,
249
],
[
251
],
[
253
],
[
255
],
[
261
],
[
263
],
[
265
],
[
267
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
323,
325
],
[
327
],
[
329,
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
]
] |
25,297 | static inline void mix_2f_2r_to_dolby(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] -= output[3][i];
output[2][i] += output[4][i];
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
}
| false | FFmpeg | 486637af8ef29ec215e0e0b7ecd3b5470f0e04e5 | static inline void mix_2f_2r_to_dolby(AC3DecodeContext *ctx)
{
int i;
float (*output)[256] = ctx->audio_block.block_output;
for (i = 0; i < 256; i++) {
output[1][i] -= output[3][i];
output[2][i] += output[4][i];
}
memset(output[3], 0, sizeof(output[3]));
memset(output[4], 0, sizeof(output[4]));
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(AC3DecodeContext *VAR_0)
{
int VAR_1;
float (*VAR_2)[256] = VAR_0->audio_block.block_output;
for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {
VAR_2[1][VAR_1] -= VAR_2[3][VAR_1];
VAR_2[2][VAR_1] += VAR_2[4][VAR_1];
}
memset(VAR_2[3], 0, sizeof(VAR_2[3]));
memset(VAR_2[4], 0, sizeof(VAR_2[4]));
}
| [
"static inline void FUNC_0(AC3DecodeContext *VAR_0)\n{",
"int VAR_1;",
"float (*VAR_2)[256] = VAR_0->audio_block.block_output;",
"for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {",
"VAR_2[1][VAR_1] -= VAR_2[3][VAR_1];",
"VAR_2[2][VAR_1] += VAR_2[4][VAR_1];",
"}",
"memset(VAR_2[3], 0, sizeof(VAR_2[3]));",
"memset(VAR_2[4], 0, sizeof(VAR_2[4]));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
25,298 | int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
{
QSVFrame *cur;
MFXVideoENCODE_Close(q->session);
if (q->internal_session)
MFXClose(q->internal_session);
q->session = NULL;
q->internal_session = NULL;
cur = q->work_frames;
while (cur) {
q->work_frames = cur->next;
av_frame_free(&cur->frame);
av_freep(&cur);
cur = q->work_frames;
}
while (q->async_fifo && av_fifo_size(q->async_fifo)) {
AVPacket pkt;
mfxSyncPoint sync;
mfxBitstream *bs;
av_fifo_generic_read(q->async_fifo, &pkt, sizeof(pkt), NULL);
av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL);
av_fifo_generic_read(q->async_fifo, &bs, sizeof(bs), NULL);
av_freep(&bs);
av_packet_unref(&pkt);
}
av_fifo_free(q->async_fifo);
q->async_fifo = NULL;
av_frame_free(&avctx->coded_frame);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
{
QSVFrame *cur;
MFXVideoENCODE_Close(q->session);
if (q->internal_session)
MFXClose(q->internal_session);
q->session = NULL;
q->internal_session = NULL;
cur = q->work_frames;
while (cur) {
q->work_frames = cur->next;
av_frame_free(&cur->frame);
av_freep(&cur);
cur = q->work_frames;
}
while (q->async_fifo && av_fifo_size(q->async_fifo)) {
AVPacket pkt;
mfxSyncPoint sync;
mfxBitstream *bs;
av_fifo_generic_read(q->async_fifo, &pkt, sizeof(pkt), NULL);
av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL);
av_fifo_generic_read(q->async_fifo, &bs, sizeof(bs), NULL);
av_freep(&bs);
av_packet_unref(&pkt);
}
av_fifo_free(q->async_fifo);
q->async_fifo = NULL;
av_frame_free(&avctx->coded_frame);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1)
{
QSVFrame *cur;
MFXVideoENCODE_Close(VAR_1->session);
if (VAR_1->internal_session)
MFXClose(VAR_1->internal_session);
VAR_1->session = NULL;
VAR_1->internal_session = NULL;
cur = VAR_1->work_frames;
while (cur) {
VAR_1->work_frames = cur->next;
av_frame_free(&cur->frame);
av_freep(&cur);
cur = VAR_1->work_frames;
}
while (VAR_1->async_fifo && av_fifo_size(VAR_1->async_fifo)) {
AVPacket pkt;
mfxSyncPoint sync;
mfxBitstream *bs;
av_fifo_generic_read(VAR_1->async_fifo, &pkt, sizeof(pkt), NULL);
av_fifo_generic_read(VAR_1->async_fifo, &sync, sizeof(sync), NULL);
av_fifo_generic_read(VAR_1->async_fifo, &bs, sizeof(bs), NULL);
av_freep(&bs);
av_packet_unref(&pkt);
}
av_fifo_free(VAR_1->async_fifo);
VAR_1->async_fifo = NULL;
av_frame_free(&VAR_0->coded_frame);
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, QSVEncContext *VAR_1)\n{",
"QSVFrame *cur;",
"MFXVideoENCODE_Close(VAR_1->session);",
"if (VAR_1->internal_session)\nMFXClose(VAR_1->internal_session);",
"VAR_1->session = NULL;",
"VAR_1->internal_session = NULL;",
"cur = VAR_1->work_frames;",
"while (cur) {",
"VAR_1->work_frames = cur->next;",
"av_frame_free(&cur->frame);",
"av_freep(&cur);",
"cur = VAR_1->work_frames;",
"}",
"while (VAR_1->async_fifo && av_fifo_size(VAR_1->async_fifo)) {",
"AVPacket pkt;",
"mfxSyncPoint sync;",
"mfxBitstream *bs;",
"av_fifo_generic_read(VAR_1->async_fifo, &pkt, sizeof(pkt), NULL);",
"av_fifo_generic_read(VAR_1->async_fifo, &sync, sizeof(sync), NULL);",
"av_fifo_generic_read(VAR_1->async_fifo, &bs, sizeof(bs), NULL);",
"av_freep(&bs);",
"av_packet_unref(&pkt);",
"}",
"av_fifo_free(VAR_1->async_fifo);",
"VAR_1->async_fifo = NULL;",
"av_frame_free(&VAR_0->coded_frame);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
]
] |
25,299 | static av_cold int raw_encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int raw_encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *VAR_0 = av_pix_fmt_desc_get(avctx->pix_fmt);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(VAR_0);
if(!avctx->codec_tag)
avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"const AVPixFmtDescriptor *VAR_0 = av_pix_fmt_desc_get(avctx->pix_fmt);",
"avctx->coded_frame = av_frame_alloc();",
"if (!avctx->coded_frame)\nreturn AVERROR(ENOMEM);",
"avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"avctx->coded_frame->key_frame = 1;",
"avctx->bits_per_coded_sample = av_get_bits_per_pixel(VAR_0);",
"if(!avctx->codec_tag)\navctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
]
] |
25,300 | int ff_audio_mix(AudioMix *am, AudioData *src)
{
int use_generic = 1;
int len = src->nb_samples;
int i, j;
/* determine whether to use the optimized function based on pointer and
samples alignment in both the input and output */
if (am->has_optimized_func) {
int aligned_len = FFALIGN(len, am->samples_align);
if (!(src->ptr_align % am->ptr_align) &&
src->samples_align >= aligned_len) {
len = aligned_len;
use_generic = 0;
}
}
av_dlog(am->avr, "audio_mix: %d samples - %d to %d channels (%s)\n",
src->nb_samples, am->in_channels, am->out_channels,
use_generic ? am->func_descr_generic : am->func_descr);
if (am->in_matrix_channels && am->out_matrix_channels) {
uint8_t **data;
uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];
if (am->out_matrix_channels < am->out_channels ||
am->in_matrix_channels < am->in_channels) {
for (i = 0, j = 0; i < FFMAX(am->in_channels, am->out_channels); i++) {
if (am->input_skip[i] || am->output_skip[i] || am->output_zero[i])
continue;
data0[j++] = src->data[i];
}
data = data0;
} else {
data = src->data;
}
if (use_generic)
am->mix_generic(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
else
am->mix(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
}
if (am->out_matrix_channels < am->out_channels) {
for (i = 0; i < am->out_channels; i++)
if (am->output_zero[i])
av_samples_set_silence(&src->data[i], 0, len, 1, am->fmt);
}
ff_audio_data_set_channels(src, am->out_channels);
return 0;
}
| true | FFmpeg | 3d95d27376e59de14f984e7a22a52e066d85df35 | int ff_audio_mix(AudioMix *am, AudioData *src)
{
int use_generic = 1;
int len = src->nb_samples;
int i, j;
if (am->has_optimized_func) {
int aligned_len = FFALIGN(len, am->samples_align);
if (!(src->ptr_align % am->ptr_align) &&
src->samples_align >= aligned_len) {
len = aligned_len;
use_generic = 0;
}
}
av_dlog(am->avr, "audio_mix: %d samples - %d to %d channels (%s)\n",
src->nb_samples, am->in_channels, am->out_channels,
use_generic ? am->func_descr_generic : am->func_descr);
if (am->in_matrix_channels && am->out_matrix_channels) {
uint8_t **data;
uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];
if (am->out_matrix_channels < am->out_channels ||
am->in_matrix_channels < am->in_channels) {
for (i = 0, j = 0; i < FFMAX(am->in_channels, am->out_channels); i++) {
if (am->input_skip[i] || am->output_skip[i] || am->output_zero[i])
continue;
data0[j++] = src->data[i];
}
data = data0;
} else {
data = src->data;
}
if (use_generic)
am->mix_generic(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
else
am->mix(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
}
if (am->out_matrix_channels < am->out_channels) {
for (i = 0; i < am->out_channels; i++)
if (am->output_zero[i])
av_samples_set_silence(&src->data[i], 0, len, 1, am->fmt);
}
ff_audio_data_set_channels(src, am->out_channels);
return 0;
}
| {
"code": [
" uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];"
],
"line_no": [
45
]
} | int FUNC_0(AudioMix *VAR_0, AudioData *VAR_1)
{
int VAR_2 = 1;
int VAR_3 = VAR_1->nb_samples;
int VAR_4, VAR_5;
if (VAR_0->has_optimized_func) {
int VAR_6 = FFALIGN(VAR_3, VAR_0->samples_align);
if (!(VAR_1->ptr_align % VAR_0->ptr_align) &&
VAR_1->samples_align >= VAR_6) {
VAR_3 = VAR_6;
VAR_2 = 0;
}
}
av_dlog(VAR_0->avr, "audio_mix: %d samples - %d to %d channels (%s)\n",
VAR_1->nb_samples, VAR_0->in_channels, VAR_0->out_channels,
VAR_2 ? VAR_0->func_descr_generic : VAR_0->func_descr);
if (VAR_0->in_matrix_channels && VAR_0->out_matrix_channels) {
uint8_t **data;
uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];
if (VAR_0->out_matrix_channels < VAR_0->out_channels ||
VAR_0->in_matrix_channels < VAR_0->in_channels) {
for (VAR_4 = 0, VAR_5 = 0; VAR_4 < FFMAX(VAR_0->in_channels, VAR_0->out_channels); VAR_4++) {
if (VAR_0->input_skip[VAR_4] || VAR_0->output_skip[VAR_4] || VAR_0->output_zero[VAR_4])
continue;
data0[VAR_5++] = VAR_1->data[VAR_4];
}
data = data0;
} else {
data = VAR_1->data;
}
if (VAR_2)
VAR_0->mix_generic(data, VAR_0->matrix, VAR_3, VAR_0->out_matrix_channels,
VAR_0->in_matrix_channels);
else
VAR_0->mix(data, VAR_0->matrix, VAR_3, VAR_0->out_matrix_channels,
VAR_0->in_matrix_channels);
}
if (VAR_0->out_matrix_channels < VAR_0->out_channels) {
for (VAR_4 = 0; VAR_4 < VAR_0->out_channels; VAR_4++)
if (VAR_0->output_zero[VAR_4])
av_samples_set_silence(&VAR_1->data[VAR_4], 0, VAR_3, 1, VAR_0->fmt);
}
ff_audio_data_set_channels(VAR_1, VAR_0->out_channels);
return 0;
}
| [
"int FUNC_0(AudioMix *VAR_0, AudioData *VAR_1)\n{",
"int VAR_2 = 1;",
"int VAR_3 = VAR_1->nb_samples;",
"int VAR_4, VAR_5;",
"if (VAR_0->has_optimized_func) {",
"int VAR_6 = FFALIGN(VAR_3, VAR_0->samples_align);",
"if (!(VAR_1->ptr_align % VAR_0->ptr_align) &&\nVAR_1->samples_align >= VAR_6) {",
"VAR_3 = VAR_6;",
"VAR_2 = 0;",
"}",
"}",
"av_dlog(VAR_0->avr, \"audio_mix: %d samples - %d to %d channels (%s)\\n\",\nVAR_1->nb_samples, VAR_0->in_channels, VAR_0->out_channels,\nVAR_2 ? VAR_0->func_descr_generic : VAR_0->func_descr);",
"if (VAR_0->in_matrix_channels && VAR_0->out_matrix_channels) {",
"uint8_t **data;",
"uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];",
"if (VAR_0->out_matrix_channels < VAR_0->out_channels ||\nVAR_0->in_matrix_channels < VAR_0->in_channels) {",
"for (VAR_4 = 0, VAR_5 = 0; VAR_4 < FFMAX(VAR_0->in_channels, VAR_0->out_channels); VAR_4++) {",
"if (VAR_0->input_skip[VAR_4] || VAR_0->output_skip[VAR_4] || VAR_0->output_zero[VAR_4])\ncontinue;",
"data0[VAR_5++] = VAR_1->data[VAR_4];",
"}",
"data = data0;",
"} else {",
"data = VAR_1->data;",
"}",
"if (VAR_2)\nVAR_0->mix_generic(data, VAR_0->matrix, VAR_3, VAR_0->out_matrix_channels,\nVAR_0->in_matrix_channels);",
"else\nVAR_0->mix(data, VAR_0->matrix, VAR_3, VAR_0->out_matrix_channels,\nVAR_0->in_matrix_channels);",
"}",
"if (VAR_0->out_matrix_channels < VAR_0->out_channels) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->out_channels; VAR_4++)",
"if (VAR_0->output_zero[VAR_4])\nav_samples_set_silence(&VAR_1->data[VAR_4], 0, VAR_3, 1, VAR_0->fmt);",
"}",
"ff_audio_data_set_channels(VAR_1, VAR_0->out_channels);",
"return 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,
3
],
[
5
],
[
7
],
[
9
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
79,
81,
83
],
[
85
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
101
],
[
105
],
[
107
]
] |
25,301 | static int ahci_dma_set_inactive(IDEDMA *dma)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
DPRINTF(ad->port_no, "dma done\n");
/* update d2h status */
ahci_write_fis_d2h(ad, NULL);
ad->dma_cb = NULL;
/* maybe we still have something to process, check later */
ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);
qemu_bh_schedule(ad->check_bh);
return 0;
}
| true | qemu | 4d29b50a41810684ad34e44352a630eb1dd94b58 | static int ahci_dma_set_inactive(IDEDMA *dma)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
DPRINTF(ad->port_no, "dma done\n");
ahci_write_fis_d2h(ad, NULL);
ad->dma_cb = NULL;
ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);
qemu_bh_schedule(ad->check_bh);
return 0;
}
| {
"code": [
" ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);",
" qemu_bh_schedule(ad->check_bh);"
],
"line_no": [
25,
27
]
} | static int FUNC_0(IDEDMA *VAR_0)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);
DPRINTF(ad->port_no, "VAR_0 done\n");
ahci_write_fis_d2h(ad, NULL);
ad->dma_cb = NULL;
ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);
qemu_bh_schedule(ad->check_bh);
return 0;
}
| [
"static int FUNC_0(IDEDMA *VAR_0)\n{",
"AHCIDevice *ad = DO_UPCAST(AHCIDevice, VAR_0, VAR_0);",
"DPRINTF(ad->port_no, \"VAR_0 done\\n\");",
"ahci_write_fis_d2h(ad, NULL);",
"ad->dma_cb = NULL;",
"ad->check_bh = qemu_bh_new(ahci_check_cmd_bh, ad);",
"qemu_bh_schedule(ad->check_bh);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
15
],
[
19
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
25,302 | DriveInfo *drive_init(QemuOpts *opts, void *opaque,
int *fatal_error)
{
const char *buf;
const char *file = NULL;
char devname[128];
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
QEMUMachine *machine = opaque;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
int snapshot = 0;
*fatal_error = 1;
translation = BIOS_ATA_TRANSLATION_AUTO;
if (machine && machine->use_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
/* extract parameters */
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else if (!strcmp(buf, "none")) {
type = IF_NONE;
max_devs = 0;
} else {
fprintf(stderr, "qemu: unsupported bus type '%s'\n", buf);
return NULL;
}
}
if (cyls || heads || secs) {
if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", buf);
return NULL;
}
if (heads < 1 || (type == IF_IDE && heads > 16)) {
fprintf(stderr, "qemu: '%s' invalid physical heads number\n", buf);
return NULL;
}
if (secs < 1 || (type == IF_IDE && secs > 63)) {
fprintf(stderr, "qemu: '%s' invalid physical secs number\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
fprintf(stderr,
"qemu: '%s' trans must be used with cyls,heads and secs\n",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid translation type\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid media\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
bdrv_flags |= BDRV_O_NOCACHE;
} else if (!strcmp(buf, "writeback")) {
} else if (!strcmp(buf, "writethrough")) {
/* this is the default */
} else {
fprintf(stderr, "qemu: invalid cache option\n");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
/* this is the default */
} else {
fprintf(stderr, "qemu: invalid aio option\n");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(buf, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", buf);
return NULL;
}
}
on_write_error = BLOCK_ERR_STOP_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCK_ERR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO) {
fprintf(stderr, "rerror is no supported by this format\n");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
fprintf(stderr, "addr is not supported\n");
return NULL;
}
}
/* compute bus and unit according index */
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
fprintf(stderr,
"qemu: index cannot be used with bus and unit\n");
return NULL;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
/* if user doesn't specify a unit_id,
* try to find the first free
*/
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
/* check unit id */
if (max_devs && unit_id >= max_devs) {
fprintf(stderr, "qemu: unit %d too big (max is %d)\n",
unit_id, max_devs - 1);
return NULL;
}
/*
* ignore multiple definitions
*/
if (drive_get(type, bus_id, unit_id) != NULL) {
*fatal_error = 0;
return NULL;
}
/* init */
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(buf);
} else {
/* no id supplied -> create one */
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
devname, mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->on_read_error = on_read_error;
dinfo->on_write_error = on_write_error;
dinfo->opts = opts;
if (serial)
strncpy(dinfo->serial, serial, sizeof(serial));
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs);
bdrv_set_translation_hint(dinfo->bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
/* FIXME: This isn't really a floppy, but it's a reasonable
approximation. */
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
/* add virtio block device */
opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
case IF_COUNT:
abort();
}
if (!file) {
*fatal_error = 0;
return NULL;
}
if (snapshot) {
/* always use write-back with snapshot */
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB);
}
if (media == MEDIA_CDROM) {
/* CDROM is fine for any interface, don't check. */
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n");
return NULL;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
file, strerror(errno));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
} | true | qemu | 016f5cf6ff465411733878a17c8f8febb7668321 | DriveInfo *drive_init(QemuOpts *opts, void *opaque,
int *fatal_error)
{
const char *buf;
const char *file = NULL;
char devname[128];
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
QEMUMachine *machine = opaque;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
int snapshot = 0;
*fatal_error = 1;
translation = BIOS_ATA_TRANSLATION_AUTO;
if (machine && machine->use_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else if (!strcmp(buf, "none")) {
type = IF_NONE;
max_devs = 0;
} else {
fprintf(stderr, "qemu: unsupported bus type '%s'\n", buf);
return NULL;
}
}
if (cyls || heads || secs) {
if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", buf);
return NULL;
}
if (heads < 1 || (type == IF_IDE && heads > 16)) {
fprintf(stderr, "qemu: '%s' invalid physical heads number\n", buf);
return NULL;
}
if (secs < 1 || (type == IF_IDE && secs > 63)) {
fprintf(stderr, "qemu: '%s' invalid physical secs number\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
fprintf(stderr,
"qemu: '%s' trans must be used with cyls,heads and secs\n",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid translation type\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid media\n", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
bdrv_flags |= BDRV_O_NOCACHE;
} else if (!strcmp(buf, "writeback")) {
} else if (!strcmp(buf, "writethrough")) {
} else {
fprintf(stderr, "qemu: invalid cache option\n");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
fprintf(stderr, "qemu: invalid aio option\n");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(buf, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", buf);
return NULL;
}
}
on_write_error = BLOCK_ERR_STOP_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCK_ERR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO) {
fprintf(stderr, "rerror is no supported by this format\n");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
fprintf(stderr, "addr is not supported\n");
return NULL;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
fprintf(stderr,
"qemu: index cannot be used with bus and unit\n");
return NULL;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
fprintf(stderr, "qemu: unit %d too big (max is %d)\n",
unit_id, max_devs - 1);
return NULL;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
*fatal_error = 0;
return NULL;
}
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(buf);
} else {
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
devname, mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->on_read_error = on_read_error;
dinfo->on_write_error = on_write_error;
dinfo->opts = opts;
if (serial)
strncpy(dinfo->serial, serial, sizeof(serial));
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs);
bdrv_set_translation_hint(dinfo->bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
case IF_COUNT:
abort();
}
if (!file) {
*fatal_error = 0;
return NULL;
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB);
}
if (media == MEDIA_CDROM) {
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n");
return NULL;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
file, strerror(errno));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
} | {
"code": [],
"line_no": []
} | DriveInfo *FUNC_0(QemuOpts *opts, void *opaque,
int *fatal_error)
{
const char *VAR_0;
const char *VAR_1 = NULL;
char VAR_2[128];
const char *VAR_3;
const char *VAR_4 = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;
int VAR_6, VAR_7;
int VAR_8, VAR_9, VAR_10, VAR_11;
BlockDriver *drv = NULL;
QEMUMachine *machine = opaque;
int VAR_12;
int VAR_13;
int VAR_14 = 0;
int VAR_15 = 0;
int VAR_16, VAR_17;
const char *VAR_18;
DriveInfo *dinfo;
int VAR_19 = 0;
*fatal_error = 1;
VAR_11 = BIOS_ATA_TRANSLATION_AUTO;
if (machine && machine->use_scsi) {
type = IF_SCSI;
VAR_12 = MAX_SCSI_DEVS;
pstrcpy(VAR_2, sizeof(VAR_2), "scsi");
} else {
type = IF_IDE;
VAR_12 = MAX_IDE_DEVS;
pstrcpy(VAR_2, sizeof(VAR_2), "ide");
}
VAR_5 = MEDIA_DISK;
VAR_6 = qemu_opt_get_number(opts, "bus", 0);
VAR_7 = qemu_opt_get_number(opts, "unit", -1);
VAR_13 = qemu_opt_get_number(opts, "VAR_13", -1);
VAR_8 = qemu_opt_get_number(opts, "VAR_8", 0);
VAR_9 = qemu_opt_get_number(opts, "VAR_9", 0);
VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0);
VAR_19 = qemu_opt_get_bool(opts, "VAR_19", 0);
VAR_14 = qemu_opt_get_bool(opts, "readonly", 0);
VAR_1 = qemu_opt_get(opts, "VAR_1");
VAR_3 = qemu_opt_get(opts, "VAR_3");
if ((VAR_0 = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);
if (!strcmp(VAR_0, "ide")) {
type = IF_IDE;
VAR_12 = MAX_IDE_DEVS;
} else if (!strcmp(VAR_0, "scsi")) {
type = IF_SCSI;
VAR_12 = MAX_SCSI_DEVS;
} else if (!strcmp(VAR_0, "floppy")) {
type = IF_FLOPPY;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "pflash")) {
type = IF_PFLASH;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "mtd")) {
type = IF_MTD;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "sd")) {
type = IF_SD;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "virtio")) {
type = IF_VIRTIO;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "xen")) {
type = IF_XEN;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "none")) {
type = IF_NONE;
VAR_12 = 0;
} else {
fprintf(stderr, "qemu: unsupported bus type '%s'\n", VAR_0);
return NULL;
}
}
if (VAR_8 || VAR_9 || VAR_10) {
if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {
fprintf(stderr, "qemu: '%s' invalid physical VAR_8 number\n", VAR_0);
return NULL;
}
if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {
fprintf(stderr, "qemu: '%s' invalid physical VAR_9 number\n", VAR_0);
return NULL;
}
if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {
fprintf(stderr, "qemu: '%s' invalid physical VAR_10 number\n", VAR_0);
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "trans")) != NULL) {
if (!VAR_8) {
fprintf(stderr,
"qemu: '%s' trans must be used with VAR_8,VAR_9 and VAR_10\n",
VAR_0);
return NULL;
}
if (!strcmp(VAR_0, "none"))
VAR_11 = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(VAR_0, "lba"))
VAR_11 = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(VAR_0, "auto"))
VAR_11 = BIOS_ATA_TRANSLATION_AUTO;
else {
fprintf(stderr, "qemu: '%s' invalid VAR_11 type\n", VAR_0);
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "VAR_5")) != NULL) {
if (!strcmp(VAR_0, "disk")) {
VAR_5 = MEDIA_DISK;
} else if (!strcmp(VAR_0, "cdrom")) {
if (VAR_8 || VAR_10 || VAR_9) {
fprintf(stderr,
"qemu: '%s' invalid physical CHS format\n", VAR_0);
return NULL;
}
VAR_5 = MEDIA_CDROM;
} else {
fprintf(stderr, "qemu: '%s' invalid VAR_5\n", VAR_0);
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(VAR_0, "off") || !strcmp(VAR_0, "none")) {
VAR_15 |= BDRV_O_NOCACHE;
} else if (!strcmp(VAR_0, "writeback")) {
} else if (!strcmp(VAR_0, "writethrough")) {
} else {
fprintf(stderr, "qemu: invalid cache option\n");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((VAR_0 = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(VAR_0, "native")) {
VAR_15 |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(VAR_0, "threads")) {
} else {
fprintf(stderr, "qemu: invalid aio option\n");
return NULL;
}
}
#endif
if ((VAR_0 = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(VAR_0, "?") == 0) {
fprintf(stderr, "qemu: Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
fprintf(stderr, "\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(VAR_0);
if (!drv) {
fprintf(stderr, "qemu: '%s' invalid format\n", VAR_0);
return NULL;
}
}
VAR_17 = BLOCK_ERR_STOP_ENOSPC;
if ((VAR_0 = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {
fprintf(stderr, "werror is no supported by this format\n");
return NULL;
}
VAR_17 = parse_block_error_action(VAR_0, 0);
if (VAR_17 < 0) {
return NULL;
}
}
VAR_16 = BLOCK_ERR_REPORT;
if ((VAR_0 = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO) {
fprintf(stderr, "rerror is no supported by this format\n");
return NULL;
}
VAR_16 = parse_block_error_action(VAR_0, 1);
if (VAR_16 < 0) {
return NULL;
}
}
if ((VAR_18 = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
fprintf(stderr, "addr is not supported\n");
return NULL;
}
}
if (VAR_13 != -1) {
if (VAR_6 != 0 || VAR_7 != -1) {
fprintf(stderr,
"qemu: VAR_13 cannot be used with bus and unit\n");
return NULL;
}
if (VAR_12 == 0)
{
VAR_7 = VAR_13;
VAR_6 = 0;
} else {
VAR_7 = VAR_13 % VAR_12;
VAR_6 = VAR_13 / VAR_12;
}
}
if (VAR_7 == -1) {
VAR_7 = 0;
while (drive_get(type, VAR_6, VAR_7) != NULL) {
VAR_7++;
if (VAR_12 && VAR_7 >= VAR_12) {
VAR_7 -= VAR_12;
VAR_6++;
}
}
}
if (VAR_12 && VAR_7 >= VAR_12) {
fprintf(stderr, "qemu: unit %d too big (max is %d)\n",
VAR_7, VAR_12 - 1);
return NULL;
}
if (drive_get(type, VAR_6, VAR_7) != NULL) {
*fatal_error = 0;
return NULL;
}
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((VAR_0 = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(VAR_0);
} else {
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
VAR_4 = (VAR_5 == MEDIA_CDROM) ? "-cd" : "-hd";
if (VAR_12)
snprintf(dinfo->id, 32, "%s%i%s%i",
VAR_2, VAR_6, VAR_4, VAR_7);
else
snprintf(dinfo->id, 32, "%s%s%i",
VAR_2, VAR_4, VAR_7);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->VAR_18 = VAR_18;
dinfo->type = type;
dinfo->bus = VAR_6;
dinfo->unit = VAR_7;
dinfo->VAR_16 = VAR_16;
dinfo->VAR_17 = VAR_17;
dinfo->opts = opts;
if (VAR_3)
strncpy(dinfo->VAR_3, VAR_3, sizeof(VAR_3));
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(VAR_5) {
case MEDIA_DISK:
if (VAR_8 != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);
bdrv_set_translation_hint(dinfo->bdrv, VAR_11);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create(&qemu_device_opts, NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (VAR_18)
qemu_opt_set(opts, "addr", VAR_18);
break;
case IF_COUNT:
abort();
}
if (!VAR_1) {
*fatal_error = 0;
return NULL;
}
if (VAR_19) {
VAR_15 &= ~BDRV_O_CACHE_MASK;
VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB);
}
if (VAR_5 == MEDIA_CDROM) {
VAR_14 = 1;
} else if (VAR_14 == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {
fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n");
return NULL;
}
}
VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;
if (bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
VAR_1, strerror(errno));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
} | [
"DriveInfo *FUNC_0(QemuOpts *opts, void *opaque,\nint *fatal_error)\n{",
"const char *VAR_0;",
"const char *VAR_1 = NULL;",
"char VAR_2[128];",
"const char *VAR_3;",
"const char *VAR_4 = \"\";",
"BlockInterfaceType type;",
"enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8, VAR_9, VAR_10, VAR_11;",
"BlockDriver *drv = NULL;",
"QEMUMachine *machine = opaque;",
"int VAR_12;",
"int VAR_13;",
"int VAR_14 = 0;",
"int VAR_15 = 0;",
"int VAR_16, VAR_17;",
"const char *VAR_18;",
"DriveInfo *dinfo;",
"int VAR_19 = 0;",
"*fatal_error = 1;",
"VAR_11 = BIOS_ATA_TRANSLATION_AUTO;",
"if (machine && machine->use_scsi) {",
"type = IF_SCSI;",
"VAR_12 = MAX_SCSI_DEVS;",
"pstrcpy(VAR_2, sizeof(VAR_2), \"scsi\");",
"} else {",
"type = IF_IDE;",
"VAR_12 = MAX_IDE_DEVS;",
"pstrcpy(VAR_2, sizeof(VAR_2), \"ide\");",
"}",
"VAR_5 = MEDIA_DISK;",
"VAR_6 = qemu_opt_get_number(opts, \"bus\", 0);",
"VAR_7 = qemu_opt_get_number(opts, \"unit\", -1);",
"VAR_13 = qemu_opt_get_number(opts, \"VAR_13\", -1);",
"VAR_8 = qemu_opt_get_number(opts, \"VAR_8\", 0);",
"VAR_9 = qemu_opt_get_number(opts, \"VAR_9\", 0);",
"VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);",
"VAR_19 = qemu_opt_get_bool(opts, \"VAR_19\", 0);",
"VAR_14 = qemu_opt_get_bool(opts, \"readonly\", 0);",
"VAR_1 = qemu_opt_get(opts, \"VAR_1\");",
"VAR_3 = qemu_opt_get(opts, \"VAR_3\");",
"if ((VAR_0 = qemu_opt_get(opts, \"if\")) != NULL) {",
"pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);",
"if (!strcmp(VAR_0, \"ide\")) {",
"type = IF_IDE;",
"VAR_12 = MAX_IDE_DEVS;",
"} else if (!strcmp(VAR_0, \"scsi\")) {",
"type = IF_SCSI;",
"VAR_12 = MAX_SCSI_DEVS;",
"} else if (!strcmp(VAR_0, \"floppy\")) {",
"type = IF_FLOPPY;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"pflash\")) {",
"type = IF_PFLASH;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"mtd\")) {",
"type = IF_MTD;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"sd\")) {",
"type = IF_SD;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"virtio\")) {",
"type = IF_VIRTIO;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"xen\")) {",
"type = IF_XEN;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"none\")) {",
"type = IF_NONE;",
"VAR_12 = 0;",
"} else {",
"fprintf(stderr, \"qemu: unsupported bus type '%s'\\n\", VAR_0);",
"return NULL;",
"}",
"}",
"if (VAR_8 || VAR_9 || VAR_10) {",
"if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {",
"fprintf(stderr, \"qemu: '%s' invalid physical VAR_8 number\\n\", VAR_0);",
"return NULL;",
"}",
"if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {",
"fprintf(stderr, \"qemu: '%s' invalid physical VAR_9 number\\n\", VAR_0);",
"return NULL;",
"}",
"if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {",
"fprintf(stderr, \"qemu: '%s' invalid physical VAR_10 number\\n\", VAR_0);",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"trans\")) != NULL) {",
"if (!VAR_8) {",
"fprintf(stderr,\n\"qemu: '%s' trans must be used with VAR_8,VAR_9 and VAR_10\\n\",\nVAR_0);",
"return NULL;",
"}",
"if (!strcmp(VAR_0, \"none\"))\nVAR_11 = BIOS_ATA_TRANSLATION_NONE;",
"else if (!strcmp(VAR_0, \"lba\"))\nVAR_11 = BIOS_ATA_TRANSLATION_LBA;",
"else if (!strcmp(VAR_0, \"auto\"))\nVAR_11 = BIOS_ATA_TRANSLATION_AUTO;",
"else {",
"fprintf(stderr, \"qemu: '%s' invalid VAR_11 type\\n\", VAR_0);",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"VAR_5\")) != NULL) {",
"if (!strcmp(VAR_0, \"disk\")) {",
"VAR_5 = MEDIA_DISK;",
"} else if (!strcmp(VAR_0, \"cdrom\")) {",
"if (VAR_8 || VAR_10 || VAR_9) {",
"fprintf(stderr,\n\"qemu: '%s' invalid physical CHS format\\n\", VAR_0);",
"return NULL;",
"}",
"VAR_5 = MEDIA_CDROM;",
"} else {",
"fprintf(stderr, \"qemu: '%s' invalid VAR_5\\n\", VAR_0);",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"cache\")) != NULL) {",
"if (!strcmp(VAR_0, \"off\") || !strcmp(VAR_0, \"none\")) {",
"VAR_15 |= BDRV_O_NOCACHE;",
"} else if (!strcmp(VAR_0, \"writeback\")) {",
"} else if (!strcmp(VAR_0, \"writethrough\")) {",
"} else {",
"fprintf(stderr, \"qemu: invalid cache option\\n\");",
"return NULL;",
"}",
"}",
"#ifdef CONFIG_LINUX_AIO\nif ((VAR_0 = qemu_opt_get(opts, \"aio\")) != NULL) {",
"if (!strcmp(VAR_0, \"native\")) {",
"VAR_15 |= BDRV_O_NATIVE_AIO;",
"} else if (!strcmp(VAR_0, \"threads\")) {",
"} else {",
"fprintf(stderr, \"qemu: invalid aio option\\n\");",
"return NULL;",
"}",
"}",
"#endif\nif ((VAR_0 = qemu_opt_get(opts, \"format\")) != NULL) {",
"if (strcmp(VAR_0, \"?\") == 0) {",
"fprintf(stderr, \"qemu: Supported formats:\");",
"bdrv_iterate_format(bdrv_format_print, NULL);",
"fprintf(stderr, \"\\n\");",
"return NULL;",
"}",
"drv = bdrv_find_whitelisted_format(VAR_0);",
"if (!drv) {",
"fprintf(stderr, \"qemu: '%s' invalid format\\n\", VAR_0);",
"return NULL;",
"}",
"}",
"VAR_17 = BLOCK_ERR_STOP_ENOSPC;",
"if ((VAR_0 = qemu_opt_get(opts, \"werror\")) != NULL) {",
"if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) {",
"fprintf(stderr, \"werror is no supported by this format\\n\");",
"return NULL;",
"}",
"VAR_17 = parse_block_error_action(VAR_0, 0);",
"if (VAR_17 < 0) {",
"return NULL;",
"}",
"}",
"VAR_16 = BLOCK_ERR_REPORT;",
"if ((VAR_0 = qemu_opt_get(opts, \"rerror\")) != NULL) {",
"if (type != IF_IDE && type != IF_VIRTIO) {",
"fprintf(stderr, \"rerror is no supported by this format\\n\");",
"return NULL;",
"}",
"VAR_16 = parse_block_error_action(VAR_0, 1);",
"if (VAR_16 < 0) {",
"return NULL;",
"}",
"}",
"if ((VAR_18 = qemu_opt_get(opts, \"addr\")) != NULL) {",
"if (type != IF_VIRTIO) {",
"fprintf(stderr, \"addr is not supported\\n\");",
"return NULL;",
"}",
"}",
"if (VAR_13 != -1) {",
"if (VAR_6 != 0 || VAR_7 != -1) {",
"fprintf(stderr,\n\"qemu: VAR_13 cannot be used with bus and unit\\n\");",
"return NULL;",
"}",
"if (VAR_12 == 0)\n{",
"VAR_7 = VAR_13;",
"VAR_6 = 0;",
"} else {",
"VAR_7 = VAR_13 % VAR_12;",
"VAR_6 = VAR_13 / VAR_12;",
"}",
"}",
"if (VAR_7 == -1) {",
"VAR_7 = 0;",
"while (drive_get(type, VAR_6, VAR_7) != NULL) {",
"VAR_7++;",
"if (VAR_12 && VAR_7 >= VAR_12) {",
"VAR_7 -= VAR_12;",
"VAR_6++;",
"}",
"}",
"}",
"if (VAR_12 && VAR_7 >= VAR_12) {",
"fprintf(stderr, \"qemu: unit %d too big (max is %d)\\n\",\nVAR_7, VAR_12 - 1);",
"return NULL;",
"}",
"if (drive_get(type, VAR_6, VAR_7) != NULL) {",
"*fatal_error = 0;",
"return NULL;",
"}",
"dinfo = qemu_mallocz(sizeof(*dinfo));",
"if ((VAR_0 = qemu_opts_id(opts)) != NULL) {",
"dinfo->id = qemu_strdup(VAR_0);",
"} else {",
"dinfo->id = qemu_mallocz(32);",
"if (type == IF_IDE || type == IF_SCSI)\nVAR_4 = (VAR_5 == MEDIA_CDROM) ? \"-cd\" : \"-hd\";",
"if (VAR_12)\nsnprintf(dinfo->id, 32, \"%s%i%s%i\",\nVAR_2, VAR_6, VAR_4, VAR_7);",
"else\nsnprintf(dinfo->id, 32, \"%s%s%i\",\nVAR_2, VAR_4, VAR_7);",
"}",
"dinfo->bdrv = bdrv_new(dinfo->id);",
"dinfo->VAR_18 = VAR_18;",
"dinfo->type = type;",
"dinfo->bus = VAR_6;",
"dinfo->unit = VAR_7;",
"dinfo->VAR_16 = VAR_16;",
"dinfo->VAR_17 = VAR_17;",
"dinfo->opts = opts;",
"if (VAR_3)\nstrncpy(dinfo->VAR_3, VAR_3, sizeof(VAR_3));",
"QTAILQ_INSERT_TAIL(&drives, dinfo, next);",
"switch(type) {",
"case IF_IDE:\ncase IF_SCSI:\ncase IF_XEN:\ncase IF_NONE:\nswitch(VAR_5) {",
"case MEDIA_DISK:\nif (VAR_8 != 0) {",
"bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);",
"bdrv_set_translation_hint(dinfo->bdrv, VAR_11);",
"}",
"break;",
"case MEDIA_CDROM:\nbdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);",
"break;",
"}",
"break;",
"case IF_SD:\ncase IF_FLOPPY:\nbdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);",
"break;",
"case IF_PFLASH:\ncase IF_MTD:\nbreak;",
"case IF_VIRTIO:\nopts = qemu_opts_create(&qemu_device_opts, NULL, 0);",
"qemu_opt_set(opts, \"driver\", \"virtio-blk-pci\");",
"qemu_opt_set(opts, \"drive\", dinfo->id);",
"if (VAR_18)\nqemu_opt_set(opts, \"addr\", VAR_18);",
"break;",
"case IF_COUNT:\nabort();",
"}",
"if (!VAR_1) {",
"*fatal_error = 0;",
"return NULL;",
"}",
"if (VAR_19) {",
"VAR_15 &= ~BDRV_O_CACHE_MASK;",
"VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB);",
"}",
"if (VAR_5 == MEDIA_CDROM) {",
"VAR_14 = 1;",
"} else if (VAR_14 == 1) {",
"if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) {",
"fprintf(stderr, \"qemu: readonly flag not supported for drive with this interface\\n\");",
"return NULL;",
"}",
"}",
"VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;",
"if (bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv) < 0) {",
"fprintf(stderr, \"qemu: could not open disk image %s: %s\\n\",\nVAR_1, strerror(errno));",
"return NULL;",
"}",
"if (bdrv_key_required(dinfo->bdrv))\nautostart = 0;",
"*fatal_error = 0;",
"return dinfo;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211,
213,
215
],
[
217
],
[
219
],
[
221,
223
],
[
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
289
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327,
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
429
],
[
431
],
[
433,
435
],
[
437
],
[
439
],
[
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
495
],
[
497,
499
],
[
501
],
[
503
],
[
515
],
[
517
],
[
519
],
[
521
],
[
529
],
[
531
],
[
533
],
[
535
],
[
539
],
[
541,
543
],
[
545,
547,
549
],
[
551,
553,
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575,
577
],
[
579
],
[
583
],
[
585,
587,
589,
591,
593
],
[
595,
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607,
609
],
[
611
],
[
613
],
[
615
],
[
617,
623,
625
],
[
627
],
[
629,
631,
633
],
[
635,
639
],
[
641
],
[
643
],
[
645,
647
],
[
649
],
[
651,
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
669
],
[
671
],
[
673
],
[
677
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
697
],
[
701
],
[
703,
705
],
[
707
],
[
709
],
[
713,
715
],
[
717
],
[
719
],
[
721
]
] |
25,303 | static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)
{
int i, x, y;
i=0; x=0; y=0;
while(i<buf_size) {
int run_length, color;
if (buf[i] & 0x80) {
run_length = 1;
color = buf[i];
i++;
}else{
run_length = (buf[i] & 0x7f) + 2;
color = buf[i+1];
i+=2;
}
if (half_horiz)
run_length *=2;
if (color) {
memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length);
if (half_vert)
memset(s->frame.data[0] + (y+1)*s->frame.linesize[0] + x, color, run_length);
}
x+= run_length;
if (x >= s->avctx->width) {
x=0;
y += half_vert ? 2 : 1;
}
}
}
| false | FFmpeg | 091bc6ca8c643bfece2c70ff2404c7b31574e1f1 | static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)
{
int i, x, y;
i=0; x=0; y=0;
while(i<buf_size) {
int run_length, color;
if (buf[i] & 0x80) {
run_length = 1;
color = buf[i];
i++;
}else{
run_length = (buf[i] & 0x7f) + 2;
color = buf[i+1];
i+=2;
}
if (half_horiz)
run_length *=2;
if (color) {
memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length);
if (half_vert)
memset(s->frame.data[0] + (y+1)*s->frame.linesize[0] + x, color, run_length);
}
x+= run_length;
if (x >= s->avctx->width) {
x=0;
y += half_vert ? 2 : 1;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4)
{
int VAR_5, VAR_6, VAR_7;
VAR_5=0; VAR_6=0; VAR_7=0;
while(VAR_5<VAR_4) {
int VAR_8, VAR_9;
if (VAR_3[VAR_5] & 0x80) {
VAR_8 = 1;
VAR_9 = VAR_3[VAR_5];
VAR_5++;
}else{
VAR_8 = (VAR_3[VAR_5] & 0x7f) + 2;
VAR_9 = VAR_3[VAR_5+1];
VAR_5+=2;
}
if (VAR_1)
VAR_8 *=2;
if (VAR_9) {
memset(VAR_0->frame.data[0] + VAR_7*VAR_0->frame.linesize[0] + VAR_6, VAR_9, VAR_8);
if (VAR_2)
memset(VAR_0->frame.data[0] + (VAR_7+1)*VAR_0->frame.linesize[0] + VAR_6, VAR_9, VAR_8);
}
VAR_6+= VAR_8;
if (VAR_6 >= VAR_0->avctx->width) {
VAR_6=0;
VAR_7 += VAR_2 ? 2 : 1;
}
}
}
| [
"static void FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7;",
"VAR_5=0; VAR_6=0; VAR_7=0;",
"while(VAR_5<VAR_4) {",
"int VAR_8, VAR_9;",
"if (VAR_3[VAR_5] & 0x80) {",
"VAR_8 = 1;",
"VAR_9 = VAR_3[VAR_5];",
"VAR_5++;",
"}else{",
"VAR_8 = (VAR_3[VAR_5] & 0x7f) + 2;",
"VAR_9 = VAR_3[VAR_5+1];",
"VAR_5+=2;",
"}",
"if (VAR_1)\nVAR_8 *=2;",
"if (VAR_9) {",
"memset(VAR_0->frame.data[0] + VAR_7*VAR_0->frame.linesize[0] + VAR_6, VAR_9, VAR_8);",
"if (VAR_2)\nmemset(VAR_0->frame.data[0] + (VAR_7+1)*VAR_0->frame.linesize[0] + VAR_6, VAR_9, VAR_8);",
"}",
"VAR_6+= VAR_8;",
"if (VAR_6 >= VAR_0->avctx->width) {",
"VAR_6=0;",
"VAR_7 += VAR_2 ? 2 : 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
25,304 | 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 */
hwaddr flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
hwaddr initrd_base = sdram_base + 0x1002000;
hwaddr 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, NULL, "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, cpu, 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 && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
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);
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); | true | qemu | f41152bd9d01ab327c19a3828bb7896d67cf0752 | 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;
hwaddr flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
hwaddr initrd_base = sdram_base + 0x1002000;
hwaddr 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, NULL, "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, cpu, 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 && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
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);
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;
hwaddr flash_base = 0x00000000;
size_t flash_sector_size = 128 * 1024;
size_t flash_size = 32 * 1024 * 1024;
hwaddr sdram_base = 0x40000000;
size_t sdram_size = 128 * 1024 * 1024;
hwaddr initrd_base = sdram_base + 0x1002000;
hwaddr 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, NULL, "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, cpu, 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 && !qtest_enabled()) {
fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
bios_name);
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);
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;",
"hwaddr flash_base = 0x00000000;",
"size_t flash_sector_size = 128 * 1024;",
"size_t flash_size = 32 * 1024 * 1024;",
"hwaddr sdram_base = 0x40000000;",
"size_t sdram_size = 128 * 1024 * 1024;",
"hwaddr initrd_base = sdram_base + 0x1002000;",
"hwaddr 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, NULL, \"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, cpu, 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 && !qtest_enabled()) {",
"fprintf(stderr, \"qemu: could not load Milkymist One bios '%s'\\n\",\nbios_name);",
"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);",
"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
] | [
[
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
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
38,
39,
40,
41
],
[
43
],
[
44
],
[
45
],
[
46
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
55
],
[
56,
57
],
[
58
],
[
59,
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68,
69
],
[
71
],
[
72
],
[
73
],
[
75,
76
],
[
77
],
[
78
],
[
79,
80
],
[
81
],
[
82
],
[
83,
84
],
[
85
],
[
86,
87
],
[
88
],
[
89
],
[
90
],
[
91,
92
],
[
93
],
[
94
],
[
95
]
] |
25,305 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
static int count;
static char line[1024], prev[1024];
static int is_atty;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
if(level>av_log_level)
return;
line[0]=0;
#undef fprintf
if(print_prefix && avc) {
if (avc->parent_log_context_offset) {
AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
if(parent && *parent){
snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent);
}
}
snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
}
vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
print_prefix= line[strlen(line)-1] == '\n';
#if HAVE_ISATTY
if(!is_atty) is_atty= isatty(2) ? 1 : -1;
#endif
if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
count++;
if(is_atty==1)
fprintf(stderr, " Last message repeated %d times\r", count);
return;
}
if(count>0){
fprintf(stderr, " Last message repeated %d times\n", count);
count=0;
}
colored_fputs(av_clip(level>>3, 0, 6), line);
strcpy(prev, line);
}
| true | FFmpeg | 0247bdee2581a6857a24c5ff297f01d3a3112b11 | void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
static int count;
static char line[1024], prev[1024];
static int is_atty;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
if(level>av_log_level)
return;
line[0]=0;
#undef fprintf
if(print_prefix && avc) {
if (avc->parent_log_context_offset) {
AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
if(parent && *parent){
snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent);
}
}
snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
}
vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
print_prefix= line[strlen(line)-1] == '\n';
#if HAVE_ISATTY
if(!is_atty) is_atty= isatty(2) ? 1 : -1;
#endif
if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
count++;
if(is_atty==1)
fprintf(stderr, " Last message repeated %d times\r", count);
return;
}
if(count>0){
fprintf(stderr, " Last message repeated %d times\n", count);
count=0;
}
colored_fputs(av_clip(level>>3, 0, 6), line);
strcpy(prev, line);
}
| {
"code": [
" static char line[1024], prev[1024];",
" if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){",
" strcpy(prev, line);"
],
"line_no": [
9,
59,
81
]
} | void FUNC_0(void* VAR_0, int VAR_1, const char* VAR_2, va_list VAR_3)
{
static int VAR_4=1;
static int VAR_5;
static char VAR_6[1024], VAR_7[1024];
static int VAR_8;
AVClass* avc= VAR_0 ? *(AVClass**)VAR_0 : NULL;
if(VAR_1>av_log_level)
return;
VAR_6[0]=0;
#undef fprintf
if(VAR_4 && avc) {
if (avc->parent_log_context_offset) {
AVClass** parent= *(AVClass***)(((uint8_t*)VAR_0) + avc->parent_log_context_offset);
if(parent && *parent){
snprintf(VAR_6, sizeof(VAR_6), "[%s @ %p] ", (*parent)->item_name(parent), parent);
}
}
snprintf(VAR_6 + strlen(VAR_6), sizeof(VAR_6) - strlen(VAR_6), "[%s @ %p] ", avc->item_name(VAR_0), VAR_0);
}
vsnprintf(VAR_6 + strlen(VAR_6), sizeof(VAR_6) - strlen(VAR_6), VAR_2, VAR_3);
VAR_4= VAR_6[strlen(VAR_6)-1] == '\n';
#if HAVE_ISATTY
if(!VAR_8) VAR_8= isatty(2) ? 1 : -1;
#endif
if(VAR_4 && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(VAR_6, VAR_7)){
VAR_5++;
if(VAR_8==1)
fprintf(stderr, " Last message repeated %d times\r", VAR_5);
return;
}
if(VAR_5>0){
fprintf(stderr, " Last message repeated %d times\n", VAR_5);
VAR_5=0;
}
colored_fputs(av_clip(VAR_1>>3, 0, 6), VAR_6);
strcpy(VAR_7, VAR_6);
}
| [
"void FUNC_0(void* VAR_0, int VAR_1, const char* VAR_2, va_list VAR_3)\n{",
"static int VAR_4=1;",
"static int VAR_5;",
"static char VAR_6[1024], VAR_7[1024];",
"static int VAR_8;",
"AVClass* avc= VAR_0 ? *(AVClass**)VAR_0 : NULL;",
"if(VAR_1>av_log_level)\nreturn;",
"VAR_6[0]=0;",
"#undef fprintf\nif(VAR_4 && avc) {",
"if (avc->parent_log_context_offset) {",
"AVClass** parent= *(AVClass***)(((uint8_t*)VAR_0) + avc->parent_log_context_offset);",
"if(parent && *parent){",
"snprintf(VAR_6, sizeof(VAR_6), \"[%s @ %p] \", (*parent)->item_name(parent), parent);",
"}",
"}",
"snprintf(VAR_6 + strlen(VAR_6), sizeof(VAR_6) - strlen(VAR_6), \"[%s @ %p] \", avc->item_name(VAR_0), VAR_0);",
"}",
"vsnprintf(VAR_6 + strlen(VAR_6), sizeof(VAR_6) - strlen(VAR_6), VAR_2, VAR_3);",
"VAR_4= VAR_6[strlen(VAR_6)-1] == '\\n';",
"#if HAVE_ISATTY\nif(!VAR_8) VAR_8= isatty(2) ? 1 : -1;",
"#endif\nif(VAR_4 && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(VAR_6, VAR_7)){",
"VAR_5++;",
"if(VAR_8==1)\nfprintf(stderr, \" Last message repeated %d times\\r\", VAR_5);",
"return;",
"}",
"if(VAR_5>0){",
"fprintf(stderr, \" Last message repeated %d times\\n\", VAR_5);",
"VAR_5=0;",
"}",
"colored_fputs(av_clip(VAR_1>>3, 0, 6), VAR_6);",
"strcpy(VAR_7, VAR_6);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
51,
53
],
[
55,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
25,307 | static int bt_hci_name_req(struct bt_hci_s *hci, bdaddr_t *bdaddr)
{
struct bt_device_s *slave;
evt_remote_name_req_complete params;
int len;
for (slave = hci->device.net->slave; slave; slave = slave->next)
if (slave->page_scan && !bacmp(&slave->bd_addr, bdaddr))
break;
if (!slave)
return -ENODEV;
bt_hci_event_status(hci, HCI_SUCCESS);
params.status = HCI_SUCCESS;
bacpy(¶ms.bdaddr, &slave->bd_addr);
len = snprintf(params.name, sizeof(params.name),
"%s", slave->lmp_name ?: "");
memset(params.name + len, 0, sizeof(params.name) - len);
bt_hci_event(hci, EVT_REMOTE_NAME_REQ_COMPLETE,
¶ms, EVT_REMOTE_NAME_REQ_COMPLETE_SIZE);
return 0;
}
| true | qemu | e5fda03839e3c61b01d6c60de5625501d01c69d0 | static int bt_hci_name_req(struct bt_hci_s *hci, bdaddr_t *bdaddr)
{
struct bt_device_s *slave;
evt_remote_name_req_complete params;
int len;
for (slave = hci->device.net->slave; slave; slave = slave->next)
if (slave->page_scan && !bacmp(&slave->bd_addr, bdaddr))
break;
if (!slave)
return -ENODEV;
bt_hci_event_status(hci, HCI_SUCCESS);
params.status = HCI_SUCCESS;
bacpy(¶ms.bdaddr, &slave->bd_addr);
len = snprintf(params.name, sizeof(params.name),
"%s", slave->lmp_name ?: "");
memset(params.name + len, 0, sizeof(params.name) - len);
bt_hci_event(hci, EVT_REMOTE_NAME_REQ_COMPLETE,
¶ms, EVT_REMOTE_NAME_REQ_COMPLETE_SIZE);
return 0;
}
| {
"code": [
" int len;",
" len = snprintf(params.name, sizeof(params.name),",
" \"%s\", slave->lmp_name ?: \"\");",
" memset(params.name + len, 0, sizeof(params.name) - len);"
],
"line_no": [
9,
33,
35,
37
]
} | static int FUNC_0(struct bt_hci_s *VAR_0, bdaddr_t *VAR_1)
{
struct bt_device_s *VAR_2;
evt_remote_name_req_complete params;
int VAR_3;
for (VAR_2 = VAR_0->device.net->VAR_2; VAR_2; VAR_2 = VAR_2->next)
if (VAR_2->page_scan && !bacmp(&VAR_2->bd_addr, VAR_1))
break;
if (!VAR_2)
return -ENODEV;
bt_hci_event_status(VAR_0, HCI_SUCCESS);
params.status = HCI_SUCCESS;
bacpy(¶ms.VAR_1, &VAR_2->bd_addr);
VAR_3 = snprintf(params.name, sizeof(params.name),
"%s", VAR_2->lmp_name ?: "");
memset(params.name + VAR_3, 0, sizeof(params.name) - VAR_3);
bt_hci_event(VAR_0, EVT_REMOTE_NAME_REQ_COMPLETE,
¶ms, EVT_REMOTE_NAME_REQ_COMPLETE_SIZE);
return 0;
}
| [
"static int FUNC_0(struct bt_hci_s *VAR_0, bdaddr_t *VAR_1)\n{",
"struct bt_device_s *VAR_2;",
"evt_remote_name_req_complete params;",
"int VAR_3;",
"for (VAR_2 = VAR_0->device.net->VAR_2; VAR_2; VAR_2 = VAR_2->next)",
"if (VAR_2->page_scan && !bacmp(&VAR_2->bd_addr, VAR_1))\nbreak;",
"if (!VAR_2)\nreturn -ENODEV;",
"bt_hci_event_status(VAR_0, HCI_SUCCESS);",
"params.status = HCI_SUCCESS;",
"bacpy(¶ms.VAR_1, &VAR_2->bd_addr);",
"VAR_3 = snprintf(params.name, sizeof(params.name),\n\"%s\", VAR_2->lmp_name ?: \"\");",
"memset(params.name + VAR_3, 0, sizeof(params.name) - VAR_3);",
"bt_hci_event(VAR_0, EVT_REMOTE_NAME_REQ_COMPLETE,\n¶ms, EVT_REMOTE_NAME_REQ_COMPLETE_SIZE);",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19,
21
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
45
],
[
47
]
] |
25,308 | int av_opt_is_set_to_default(void *obj, const AVOption *o)
{
int64_t i64;
double d, d2;
float f;
AVRational q;
int ret, w, h;
char *str;
void *dst;
if (!o || !obj)
return AVERROR(EINVAL);
dst = ((uint8_t*)obj) + o->offset;
switch (o->type) {
case AV_OPT_TYPE_CONST:
return 1;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_INT64:
read_number(o, dst, NULL, NULL, &i64);
return o->default_val.i64 == i64;
case AV_OPT_TYPE_STRING:
str = *(char **)dst;
if (str == o->default_val.str) //2 NULLs
return 1;
if (!str || !o->default_val.str) //1 NULL
return 0;
return !strcmp(str, o->default_val.str);
case AV_OPT_TYPE_DOUBLE:
read_number(o, dst, &d, NULL, NULL);
return o->default_val.dbl == d;
case AV_OPT_TYPE_FLOAT:
read_number(o, dst, &d, NULL, NULL);
f = o->default_val.dbl;
d2 = f;
return d2 == d;
case AV_OPT_TYPE_RATIONAL:
q = av_d2q(o->default_val.dbl, INT_MAX);
return !av_cmp_q(*(AVRational*)dst, q);
case AV_OPT_TYPE_BINARY: {
struct {
uint8_t *data;
int size;
} tmp = {0};
int opt_size = *(int *)((void **)dst + 1);
void *opt_ptr = *(void **)dst;
if (!opt_ptr && (!o->default_val.str || !strlen(o->default_val.str)))
return 1;
if (opt_ptr && o->default_val.str && !strlen(o->default_val.str))
return 0;
if (opt_size != strlen(o->default_val.str) / 2)
return 0;
ret = set_string_binary(NULL, NULL, o->default_val.str, &tmp.data);
if (!ret)
ret = !memcmp(opt_ptr, tmp.data, tmp.size);
av_free(tmp.data);
return ret;
}
case AV_OPT_TYPE_DICT:
/* Binary and dict have not default support yet. Any pointer is not default. */
return !!(*(void **)dst);
case AV_OPT_TYPE_IMAGE_SIZE:
if (!o->default_val.str || !strcmp(o->default_val.str, "none"))
w = h = 0;
else if ((ret = av_parse_video_size(&w, &h, o->default_val.str)) < 0)
return ret;
return (w == *(int *)dst) && (h == *((int *)dst+1));
case AV_OPT_TYPE_VIDEO_RATE:
q = (AVRational){0, 0};
if (o->default_val.str)
av_parse_video_rate(&q, o->default_val.str);
return !av_cmp_q(*(AVRational*)dst, q);
case AV_OPT_TYPE_COLOR: {
uint8_t color[4] = {0, 0, 0, 0};
if (o->default_val.str)
av_parse_color(color, o->default_val.str, -1, NULL);
return !memcmp(color, dst, sizeof(color));
}
default:
av_log(obj, AV_LOG_WARNING, "Not supported option type: %d, option name: %s\n", o->type, o->name);
break;
}
return AVERROR_PATCHWELCOME;
}
| false | FFmpeg | eb74839caa2c50018b1d5a88a43c3da9f4345a8d | int av_opt_is_set_to_default(void *obj, const AVOption *o)
{
int64_t i64;
double d, d2;
float f;
AVRational q;
int ret, w, h;
char *str;
void *dst;
if (!o || !obj)
return AVERROR(EINVAL);
dst = ((uint8_t*)obj) + o->offset;
switch (o->type) {
case AV_OPT_TYPE_CONST:
return 1;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_INT64:
read_number(o, dst, NULL, NULL, &i64);
return o->default_val.i64 == i64;
case AV_OPT_TYPE_STRING:
str = *(char **)dst;
if (str == o->default_val.str)
return 1;
if (!str || !o->default_val.str)
return 0;
return !strcmp(str, o->default_val.str);
case AV_OPT_TYPE_DOUBLE:
read_number(o, dst, &d, NULL, NULL);
return o->default_val.dbl == d;
case AV_OPT_TYPE_FLOAT:
read_number(o, dst, &d, NULL, NULL);
f = o->default_val.dbl;
d2 = f;
return d2 == d;
case AV_OPT_TYPE_RATIONAL:
q = av_d2q(o->default_val.dbl, INT_MAX);
return !av_cmp_q(*(AVRational*)dst, q);
case AV_OPT_TYPE_BINARY: {
struct {
uint8_t *data;
int size;
} tmp = {0};
int opt_size = *(int *)((void **)dst + 1);
void *opt_ptr = *(void **)dst;
if (!opt_ptr && (!o->default_val.str || !strlen(o->default_val.str)))
return 1;
if (opt_ptr && o->default_val.str && !strlen(o->default_val.str))
return 0;
if (opt_size != strlen(o->default_val.str) / 2)
return 0;
ret = set_string_binary(NULL, NULL, o->default_val.str, &tmp.data);
if (!ret)
ret = !memcmp(opt_ptr, tmp.data, tmp.size);
av_free(tmp.data);
return ret;
}
case AV_OPT_TYPE_DICT:
return !!(*(void **)dst);
case AV_OPT_TYPE_IMAGE_SIZE:
if (!o->default_val.str || !strcmp(o->default_val.str, "none"))
w = h = 0;
else if ((ret = av_parse_video_size(&w, &h, o->default_val.str)) < 0)
return ret;
return (w == *(int *)dst) && (h == *((int *)dst+1));
case AV_OPT_TYPE_VIDEO_RATE:
q = (AVRational){0, 0};
if (o->default_val.str)
av_parse_video_rate(&q, o->default_val.str);
return !av_cmp_q(*(AVRational*)dst, q);
case AV_OPT_TYPE_COLOR: {
uint8_t color[4] = {0, 0, 0, 0};
if (o->default_val.str)
av_parse_color(color, o->default_val.str, -1, NULL);
return !memcmp(color, dst, sizeof(color));
}
default:
av_log(obj, AV_LOG_WARNING, "Not supported option type: %d, option name: %s\n", o->type, o->name);
break;
}
return AVERROR_PATCHWELCOME;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void *VAR_0, const AVOption *VAR_1)
{
int64_t i64;
double VAR_2, VAR_3;
float VAR_4;
AVRational q;
int VAR_5, VAR_6, VAR_7;
char *VAR_8;
void *VAR_9;
if (!VAR_1 || !VAR_0)
return AVERROR(EINVAL);
VAR_9 = ((uint8_t*)VAR_0) + VAR_1->offset;
switch (VAR_1->type) {
case AV_OPT_TYPE_CONST:
return 1;
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_CHANNEL_LAYOUT:
case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_INT64:
read_number(VAR_1, VAR_9, NULL, NULL, &i64);
return VAR_1->default_val.i64 == i64;
case AV_OPT_TYPE_STRING:
VAR_8 = *(char **)VAR_9;
if (VAR_8 == VAR_1->default_val.VAR_8)
return 1;
if (!VAR_8 || !VAR_1->default_val.VAR_8)
return 0;
return !strcmp(VAR_8, VAR_1->default_val.VAR_8);
case AV_OPT_TYPE_DOUBLE:
read_number(VAR_1, VAR_9, &VAR_2, NULL, NULL);
return VAR_1->default_val.dbl == VAR_2;
case AV_OPT_TYPE_FLOAT:
read_number(VAR_1, VAR_9, &VAR_2, NULL, NULL);
VAR_4 = VAR_1->default_val.dbl;
VAR_3 = VAR_4;
return VAR_3 == VAR_2;
case AV_OPT_TYPE_RATIONAL:
q = av_d2q(VAR_1->default_val.dbl, INT_MAX);
return !av_cmp_q(*(AVRational*)VAR_9, q);
case AV_OPT_TYPE_BINARY: {
struct {
uint8_t *data;
int size;
} VAR_10 = {0};
int VAR_11 = *(int *)((void **)VAR_9 + 1);
void *VAR_12 = *(void **)VAR_9;
if (!VAR_12 && (!VAR_1->default_val.VAR_8 || !strlen(VAR_1->default_val.VAR_8)))
return 1;
if (VAR_12 && VAR_1->default_val.VAR_8 && !strlen(VAR_1->default_val.VAR_8))
return 0;
if (VAR_11 != strlen(VAR_1->default_val.VAR_8) / 2)
return 0;
VAR_5 = set_string_binary(NULL, NULL, VAR_1->default_val.VAR_8, &VAR_10.data);
if (!VAR_5)
VAR_5 = !memcmp(VAR_12, VAR_10.data, VAR_10.size);
av_free(VAR_10.data);
return VAR_5;
}
case AV_OPT_TYPE_DICT:
return !!(*(void **)VAR_9);
case AV_OPT_TYPE_IMAGE_SIZE:
if (!VAR_1->default_val.VAR_8 || !strcmp(VAR_1->default_val.VAR_8, "none"))
VAR_6 = VAR_7 = 0;
else if ((VAR_5 = av_parse_video_size(&VAR_6, &VAR_7, VAR_1->default_val.VAR_8)) < 0)
return VAR_5;
return (VAR_6 == *(int *)VAR_9) && (VAR_7 == *((int *)VAR_9+1));
case AV_OPT_TYPE_VIDEO_RATE:
q = (AVRational){0, 0};
if (VAR_1->default_val.VAR_8)
av_parse_video_rate(&q, VAR_1->default_val.VAR_8);
return !av_cmp_q(*(AVRational*)VAR_9, q);
case AV_OPT_TYPE_COLOR: {
uint8_t color[4] = {0, 0, 0, 0};
if (VAR_1->default_val.VAR_8)
av_parse_color(color, VAR_1->default_val.VAR_8, -1, NULL);
return !memcmp(color, VAR_9, sizeof(color));
}
default:
av_log(VAR_0, AV_LOG_WARNING, "Not supported option type: %VAR_2, option name: %s\n", VAR_1->type, VAR_1->name);
break;
}
return AVERROR_PATCHWELCOME;
}
| [
"int FUNC_0(void *VAR_0, const AVOption *VAR_1)\n{",
"int64_t i64;",
"double VAR_2, VAR_3;",
"float VAR_4;",
"AVRational q;",
"int VAR_5, VAR_6, VAR_7;",
"char *VAR_8;",
"void *VAR_9;",
"if (!VAR_1 || !VAR_0)\nreturn AVERROR(EINVAL);",
"VAR_9 = ((uint8_t*)VAR_0) + VAR_1->offset;",
"switch (VAR_1->type) {",
"case AV_OPT_TYPE_CONST:\nreturn 1;",
"case AV_OPT_TYPE_FLAGS:\ncase AV_OPT_TYPE_PIXEL_FMT:\ncase AV_OPT_TYPE_SAMPLE_FMT:\ncase AV_OPT_TYPE_INT:\ncase AV_OPT_TYPE_CHANNEL_LAYOUT:\ncase AV_OPT_TYPE_DURATION:\ncase AV_OPT_TYPE_INT64:\nread_number(VAR_1, VAR_9, NULL, NULL, &i64);",
"return VAR_1->default_val.i64 == i64;",
"case AV_OPT_TYPE_STRING:\nVAR_8 = *(char **)VAR_9;",
"if (VAR_8 == VAR_1->default_val.VAR_8)\nreturn 1;",
"if (!VAR_8 || !VAR_1->default_val.VAR_8)\nreturn 0;",
"return !strcmp(VAR_8, VAR_1->default_val.VAR_8);",
"case AV_OPT_TYPE_DOUBLE:\nread_number(VAR_1, VAR_9, &VAR_2, NULL, NULL);",
"return VAR_1->default_val.dbl == VAR_2;",
"case AV_OPT_TYPE_FLOAT:\nread_number(VAR_1, VAR_9, &VAR_2, NULL, NULL);",
"VAR_4 = VAR_1->default_val.dbl;",
"VAR_3 = VAR_4;",
"return VAR_3 == VAR_2;",
"case AV_OPT_TYPE_RATIONAL:\nq = av_d2q(VAR_1->default_val.dbl, INT_MAX);",
"return !av_cmp_q(*(AVRational*)VAR_9, q);",
"case AV_OPT_TYPE_BINARY: {",
"struct {",
"uint8_t *data;",
"int size;",
"} VAR_10 = {0};",
"int VAR_11 = *(int *)((void **)VAR_9 + 1);",
"void *VAR_12 = *(void **)VAR_9;",
"if (!VAR_12 && (!VAR_1->default_val.VAR_8 || !strlen(VAR_1->default_val.VAR_8)))\nreturn 1;",
"if (VAR_12 && VAR_1->default_val.VAR_8 && !strlen(VAR_1->default_val.VAR_8))\nreturn 0;",
"if (VAR_11 != strlen(VAR_1->default_val.VAR_8) / 2)\nreturn 0;",
"VAR_5 = set_string_binary(NULL, NULL, VAR_1->default_val.VAR_8, &VAR_10.data);",
"if (!VAR_5)\nVAR_5 = !memcmp(VAR_12, VAR_10.data, VAR_10.size);",
"av_free(VAR_10.data);",
"return VAR_5;",
"}",
"case AV_OPT_TYPE_DICT:\nreturn !!(*(void **)VAR_9);",
"case AV_OPT_TYPE_IMAGE_SIZE:\nif (!VAR_1->default_val.VAR_8 || !strcmp(VAR_1->default_val.VAR_8, \"none\"))\nVAR_6 = VAR_7 = 0;",
"else if ((VAR_5 = av_parse_video_size(&VAR_6, &VAR_7, VAR_1->default_val.VAR_8)) < 0)\nreturn VAR_5;",
"return (VAR_6 == *(int *)VAR_9) && (VAR_7 == *((int *)VAR_9+1));",
"case AV_OPT_TYPE_VIDEO_RATE:\nq = (AVRational){0, 0};",
"if (VAR_1->default_val.VAR_8)\nav_parse_video_rate(&q, VAR_1->default_val.VAR_8);",
"return !av_cmp_q(*(AVRational*)VAR_9, q);",
"case AV_OPT_TYPE_COLOR: {",
"uint8_t color[4] = {0, 0, 0, 0};",
"if (VAR_1->default_val.VAR_8)\nav_parse_color(color, VAR_1->default_val.VAR_8, -1, NULL);",
"return !memcmp(color, VAR_9, sizeof(color));",
"}",
"default:\nav_log(VAR_0, AV_LOG_WARNING, \"Not supported option type: %VAR_2, option name: %s\\n\", VAR_1->type, VAR_1->name);",
"break;",
"}",
"return AVERROR_PATCHWELCOME;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
31
],
[
33,
35
],
[
37,
39,
41,
43,
45,
47,
49,
51
],
[
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129,
133
],
[
135,
137,
139
],
[
141,
143
],
[
145
],
[
147,
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
179
]
] |
25,309 | static int indeo3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
unsigned char *buf, int buf_size)
{
Indeo3DecodeContext *s=avctx->priv_data;
unsigned char *src, *dest;
int y;
/* no supplementary picture */
if (buf_size == 0) {
return 0;
}
iv_decode_frame(s, buf, buf_size);
if(s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
s->frame.reference = 0;
if(avctx->get_buffer(avctx, &s->frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
src = s->cur_frame->Ybuf;
dest = s->frame.data[0];
for (y = 0; y < s->height; y++) {
memcpy(dest, src, s->cur_frame->y_w);
src += s->cur_frame->y_w;
dest += s->frame.linesize[0];
}
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
{
src = s->cur_frame->Ubuf;
dest = s->frame.data[1];
for (y = 0; y < s->height / 4; y++) {
memcpy(dest, src, s->cur_frame->uv_w);
src += s->cur_frame->uv_w;
dest += s->frame.linesize[1];
}
src = s->cur_frame->Vbuf;
dest = s->frame.data[2];
for (y = 0; y < s->height / 4; y++) {
memcpy(dest, src, s->cur_frame->uv_w);
src += s->cur_frame->uv_w;
dest += s->frame.linesize[2];
}
}
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->frame;
return buf_size;
}
| false | FFmpeg | 934982c4ace1a3d5d627b518782ed092a456c49e | static int indeo3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
unsigned char *buf, int buf_size)
{
Indeo3DecodeContext *s=avctx->priv_data;
unsigned char *src, *dest;
int y;
if (buf_size == 0) {
return 0;
}
iv_decode_frame(s, buf, buf_size);
if(s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
s->frame.reference = 0;
if(avctx->get_buffer(avctx, &s->frame) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
src = s->cur_frame->Ybuf;
dest = s->frame.data[0];
for (y = 0; y < s->height; y++) {
memcpy(dest, src, s->cur_frame->y_w);
src += s->cur_frame->y_w;
dest += s->frame.linesize[0];
}
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
{
src = s->cur_frame->Ubuf;
dest = s->frame.data[1];
for (y = 0; y < s->height / 4; y++) {
memcpy(dest, src, s->cur_frame->uv_w);
src += s->cur_frame->uv_w;
dest += s->frame.linesize[1];
}
src = s->cur_frame->Vbuf;
dest = s->frame.data[2];
for (y = 0; y < s->height / 4; y++) {
memcpy(dest, src, s->cur_frame->uv_w);
src += s->cur_frame->uv_w;
dest += s->frame.linesize[2];
}
}
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->frame;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
unsigned char *VAR_3, int VAR_4)
{
Indeo3DecodeContext *s=VAR_0->priv_data;
unsigned char *VAR_5, *VAR_6;
int VAR_7;
if (VAR_4 == 0) {
return 0;
}
iv_decode_frame(s, VAR_3, VAR_4);
if(s->frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->frame);
s->frame.reference = 0;
if(VAR_0->get_buffer(VAR_0, &s->frame) < 0) {
av_log(s->VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
VAR_5 = s->cur_frame->Ybuf;
VAR_6 = s->frame.VAR_1[0];
for (VAR_7 = 0; VAR_7 < s->height; VAR_7++) {
memcpy(VAR_6, VAR_5, s->cur_frame->y_w);
VAR_5 += s->cur_frame->y_w;
VAR_6 += s->frame.linesize[0];
}
if (!(s->VAR_0->flags & CODEC_FLAG_GRAY))
{
VAR_5 = s->cur_frame->Ubuf;
VAR_6 = s->frame.VAR_1[1];
for (VAR_7 = 0; VAR_7 < s->height / 4; VAR_7++) {
memcpy(VAR_6, VAR_5, s->cur_frame->uv_w);
VAR_5 += s->cur_frame->uv_w;
VAR_6 += s->frame.linesize[1];
}
VAR_5 = s->cur_frame->Vbuf;
VAR_6 = s->frame.VAR_1[2];
for (VAR_7 = 0; VAR_7 < s->height / 4; VAR_7++) {
memcpy(VAR_6, VAR_5, s->cur_frame->uv_w);
VAR_5 += s->cur_frame->uv_w;
VAR_6 += s->frame.linesize[2];
}
}
*VAR_2=sizeof(AVFrame);
*(AVFrame*)VAR_1= s->frame;
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nunsigned char *VAR_3, int VAR_4)\n{",
"Indeo3DecodeContext *s=VAR_0->priv_data;",
"unsigned char *VAR_5, *VAR_6;",
"int VAR_7;",
"if (VAR_4 == 0) {",
"return 0;",
"}",
"iv_decode_frame(s, VAR_3, VAR_4);",
"if(s->frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->frame);",
"s->frame.reference = 0;",
"if(VAR_0->get_buffer(VAR_0, &s->frame) < 0) {",
"av_log(s->VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"VAR_5 = s->cur_frame->Ybuf;",
"VAR_6 = s->frame.VAR_1[0];",
"for (VAR_7 = 0; VAR_7 < s->height; VAR_7++) {",
"memcpy(VAR_6, VAR_5, s->cur_frame->y_w);",
"VAR_5 += s->cur_frame->y_w;",
"VAR_6 += s->frame.linesize[0];",
"}",
"if (!(s->VAR_0->flags & CODEC_FLAG_GRAY))\n{",
"VAR_5 = s->cur_frame->Ubuf;",
"VAR_6 = s->frame.VAR_1[1];",
"for (VAR_7 = 0; VAR_7 < s->height / 4; VAR_7++) {",
"memcpy(VAR_6, VAR_5, s->cur_frame->uv_w);",
"VAR_5 += s->cur_frame->uv_w;",
"VAR_6 += s->frame.linesize[1];",
"}",
"VAR_5 = s->cur_frame->Vbuf;",
"VAR_6 = s->frame.VAR_1[2];",
"for (VAR_7 = 0; VAR_7 < s->height / 4; VAR_7++) {",
"memcpy(VAR_6, VAR_5, s->cur_frame->uv_w);",
"VAR_5 += s->cur_frame->uv_w;",
"VAR_6 += s->frame.linesize[2];",
"}",
"}",
"*VAR_2=sizeof(AVFrame);",
"*(AVFrame*)VAR_1= s->frame;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
25,311 | void ff_h261_loop_filter(MpegEncContext *s){
H261Context * h= (H261Context*)s;
const int linesize = s->linesize;
const int uvlinesize= s->uvlinesize;
uint8_t *dest_y = s->dest[0];
uint8_t *dest_cb= s->dest[1];
uint8_t *dest_cr= s->dest[2];
if(!(IS_FIL (h->mtype)))
return;
s->dsp.h261_loop_filter(dest_y , linesize);
s->dsp.h261_loop_filter(dest_y + 8, linesize);
s->dsp.h261_loop_filter(dest_y + 8 * linesize , linesize);
s->dsp.h261_loop_filter(dest_y + 8 * linesize + 8, linesize);
s->dsp.h261_loop_filter(dest_cb, uvlinesize);
s->dsp.h261_loop_filter(dest_cr, uvlinesize);
}
| false | FFmpeg | ed16c2dbf47cdd7c48825b4da6e7036698e5dde1 | void ff_h261_loop_filter(MpegEncContext *s){
H261Context * h= (H261Context*)s;
const int linesize = s->linesize;
const int uvlinesize= s->uvlinesize;
uint8_t *dest_y = s->dest[0];
uint8_t *dest_cb= s->dest[1];
uint8_t *dest_cr= s->dest[2];
if(!(IS_FIL (h->mtype)))
return;
s->dsp.h261_loop_filter(dest_y , linesize);
s->dsp.h261_loop_filter(dest_y + 8, linesize);
s->dsp.h261_loop_filter(dest_y + 8 * linesize , linesize);
s->dsp.h261_loop_filter(dest_y + 8 * linesize + 8, linesize);
s->dsp.h261_loop_filter(dest_cb, uvlinesize);
s->dsp.h261_loop_filter(dest_cr, uvlinesize);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0){
H261Context * h= (H261Context*)VAR_0;
const int VAR_1 = VAR_0->VAR_1;
const int VAR_2= VAR_0->VAR_2;
uint8_t *dest_y = VAR_0->dest[0];
uint8_t *dest_cb= VAR_0->dest[1];
uint8_t *dest_cr= VAR_0->dest[2];
if(!(IS_FIL (h->mtype)))
return;
VAR_0->dsp.h261_loop_filter(dest_y , VAR_1);
VAR_0->dsp.h261_loop_filter(dest_y + 8, VAR_1);
VAR_0->dsp.h261_loop_filter(dest_y + 8 * VAR_1 , VAR_1);
VAR_0->dsp.h261_loop_filter(dest_y + 8 * VAR_1 + 8, VAR_1);
VAR_0->dsp.h261_loop_filter(dest_cb, VAR_2);
VAR_0->dsp.h261_loop_filter(dest_cr, VAR_2);
}
| [
"void FUNC_0(MpegEncContext *VAR_0){",
"H261Context * h= (H261Context*)VAR_0;",
"const int VAR_1 = VAR_0->VAR_1;",
"const int VAR_2= VAR_0->VAR_2;",
"uint8_t *dest_y = VAR_0->dest[0];",
"uint8_t *dest_cb= VAR_0->dest[1];",
"uint8_t *dest_cr= VAR_0->dest[2];",
"if(!(IS_FIL (h->mtype)))\nreturn;",
"VAR_0->dsp.h261_loop_filter(dest_y , VAR_1);",
"VAR_0->dsp.h261_loop_filter(dest_y + 8, VAR_1);",
"VAR_0->dsp.h261_loop_filter(dest_y + 8 * VAR_1 , VAR_1);",
"VAR_0->dsp.h261_loop_filter(dest_y + 8 * VAR_1 + 8, VAR_1);",
"VAR_0->dsp.h261_loop_filter(dest_cb, VAR_2);",
"VAR_0->dsp.h261_loop_filter(dest_cr, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
25,312 | static gboolean check_old_packet_regular(void *opaque)
{
CompareState *s = opaque;
/* if have old packet we will notify checkpoint */
colo_old_packet_check(s);
return TRUE;
}
| false | qemu | dd321ecfc2e82e6f9578b986060b1aa3f036bd98 | static gboolean check_old_packet_regular(void *opaque)
{
CompareState *s = opaque;
colo_old_packet_check(s);
return TRUE;
}
| {
"code": [],
"line_no": []
} | static gboolean FUNC_0(void *opaque)
{
CompareState *s = opaque;
colo_old_packet_check(s);
return TRUE;
}
| [
"static gboolean FUNC_0(void *opaque)\n{",
"CompareState *s = opaque;",
"colo_old_packet_check(s);",
"return TRUE;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
15
],
[
17
]
] |
25,313 | float64 helper_fsqrtd(CPUSPARCState *env, float64 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float64_sqrt(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | float64 helper_fsqrtd(CPUSPARCState *env, float64 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float64_sqrt(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| {
"code": [],
"line_no": []
} | float64 FUNC_0(CPUSPARCState *env, float64 src)
{
float64 ret;
clear_float_exceptions(env);
ret = float64_sqrt(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| [
"float64 FUNC_0(CPUSPARCState *env, float64 src)\n{",
"float64 ret;",
"clear_float_exceptions(env);",
"ret = float64_sqrt(src, &env->fp_status);",
"check_ieee_exceptions(env);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,314 | static int local_mknod(FsContext *ctx, const char *path, mode_t mode, dev_t dev)
{
return mknod(rpath(ctx, path), mode, dev);
}
| false | qemu | 1c29331248d82e5a9caaf7974756a9d8bd5cd1e5 | static int local_mknod(FsContext *ctx, const char *path, mode_t mode, dev_t dev)
{
return mknod(rpath(ctx, path), mode, dev);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1, mode_t VAR_2, dev_t VAR_3)
{
return mknod(rpath(VAR_0, VAR_1), VAR_2, VAR_3);
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1, mode_t VAR_2, dev_t VAR_3)\n{",
"return mknod(rpath(VAR_0, VAR_1), VAR_2, VAR_3);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,315 | int ioinst_handle_msch(CPUS390XState *env, uint64_t reg1, uint32_t ipb)
{
int cssid, ssid, schid, m;
SubchDev *sch;
SCHIB *schib;
uint64_t addr;
int ret = -ENODEV;
int cc;
hwaddr len = sizeof(*schib);
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(env, PGM_OPERAND, 2);
return -EIO;
}
trace_ioinst_sch_id("msch", cssid, ssid, schid);
addr = decode_basedisp_s(env, ipb);
if (addr & 3) {
program_interrupt(env, PGM_SPECIFICATION, 2);
return -EIO;
}
schib = s390_cpu_physical_memory_map(env, addr, &len, 0);
if (!schib || len != sizeof(*schib)) {
program_interrupt(env, PGM_ADDRESSING, 2);
cc = -EIO;
goto out;
}
if (!ioinst_schib_valid(schib)) {
program_interrupt(env, PGM_OPERAND, 2);
cc = -EIO;
goto out;
}
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_msch(sch, schib);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
out:
s390_cpu_physical_memory_unmap(env, schib, len, 0);
return cc;
}
| false | qemu | 71ed827abd57dc7947ce3316118d0e601e70fac9 | int ioinst_handle_msch(CPUS390XState *env, uint64_t reg1, uint32_t ipb)
{
int cssid, ssid, schid, m;
SubchDev *sch;
SCHIB *schib;
uint64_t addr;
int ret = -ENODEV;
int cc;
hwaddr len = sizeof(*schib);
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
program_interrupt(env, PGM_OPERAND, 2);
return -EIO;
}
trace_ioinst_sch_id("msch", cssid, ssid, schid);
addr = decode_basedisp_s(env, ipb);
if (addr & 3) {
program_interrupt(env, PGM_SPECIFICATION, 2);
return -EIO;
}
schib = s390_cpu_physical_memory_map(env, addr, &len, 0);
if (!schib || len != sizeof(*schib)) {
program_interrupt(env, PGM_ADDRESSING, 2);
cc = -EIO;
goto out;
}
if (!ioinst_schib_valid(schib)) {
program_interrupt(env, PGM_OPERAND, 2);
cc = -EIO;
goto out;
}
sch = css_find_subch(m, cssid, ssid, schid);
if (sch && css_subch_visible(sch)) {
ret = css_do_msch(sch, schib);
}
switch (ret) {
case -ENODEV:
cc = 3;
break;
case -EBUSY:
cc = 2;
break;
case 0:
cc = 0;
break;
default:
cc = 1;
break;
}
out:
s390_cpu_physical_memory_unmap(env, schib, len, 0);
return cc;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUS390XState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6;
SubchDev *sch;
SCHIB *schib;
uint64_t addr;
int VAR_7 = -ENODEV;
int VAR_8;
hwaddr len = sizeof(*schib);
if (ioinst_disassemble_sch_ident(VAR_1, &VAR_6, &VAR_3, &VAR_4, &VAR_5)) {
program_interrupt(VAR_0, PGM_OPERAND, 2);
return -EIO;
}
trace_ioinst_sch_id("msch", VAR_3, VAR_4, VAR_5);
addr = decode_basedisp_s(VAR_0, VAR_2);
if (addr & 3) {
program_interrupt(VAR_0, PGM_SPECIFICATION, 2);
return -EIO;
}
schib = s390_cpu_physical_memory_map(VAR_0, addr, &len, 0);
if (!schib || len != sizeof(*schib)) {
program_interrupt(VAR_0, PGM_ADDRESSING, 2);
VAR_8 = -EIO;
goto out;
}
if (!ioinst_schib_valid(schib)) {
program_interrupt(VAR_0, PGM_OPERAND, 2);
VAR_8 = -EIO;
goto out;
}
sch = css_find_subch(VAR_6, VAR_3, VAR_4, VAR_5);
if (sch && css_subch_visible(sch)) {
VAR_7 = css_do_msch(sch, schib);
}
switch (VAR_7) {
case -ENODEV:
VAR_8 = 3;
break;
case -EBUSY:
VAR_8 = 2;
break;
case 0:
VAR_8 = 0;
break;
default:
VAR_8 = 1;
break;
}
out:
s390_cpu_physical_memory_unmap(VAR_0, schib, len, 0);
return VAR_8;
}
| [
"int FUNC_0(CPUS390XState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"SubchDev *sch;",
"SCHIB *schib;",
"uint64_t addr;",
"int VAR_7 = -ENODEV;",
"int VAR_8;",
"hwaddr len = sizeof(*schib);",
"if (ioinst_disassemble_sch_ident(VAR_1, &VAR_6, &VAR_3, &VAR_4, &VAR_5)) {",
"program_interrupt(VAR_0, PGM_OPERAND, 2);",
"return -EIO;",
"}",
"trace_ioinst_sch_id(\"msch\", VAR_3, VAR_4, VAR_5);",
"addr = decode_basedisp_s(VAR_0, VAR_2);",
"if (addr & 3) {",
"program_interrupt(VAR_0, PGM_SPECIFICATION, 2);",
"return -EIO;",
"}",
"schib = s390_cpu_physical_memory_map(VAR_0, addr, &len, 0);",
"if (!schib || len != sizeof(*schib)) {",
"program_interrupt(VAR_0, PGM_ADDRESSING, 2);",
"VAR_8 = -EIO;",
"goto out;",
"}",
"if (!ioinst_schib_valid(schib)) {",
"program_interrupt(VAR_0, PGM_OPERAND, 2);",
"VAR_8 = -EIO;",
"goto out;",
"}",
"sch = css_find_subch(VAR_6, VAR_3, VAR_4, VAR_5);",
"if (sch && css_subch_visible(sch)) {",
"VAR_7 = css_do_msch(sch, schib);",
"}",
"switch (VAR_7) {",
"case -ENODEV:\nVAR_8 = 3;",
"break;",
"case -EBUSY:\nVAR_8 = 2;",
"break;",
"case 0:\nVAR_8 = 0;",
"break;",
"default:\nVAR_8 = 1;",
"break;",
"}",
"out:\ns390_cpu_physical_memory_unmap(VAR_0, schib, len, 0);",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
]
] |
25,316 | static void v9fs_readlink(void *opaque)
{
V9fsPDU *pdu = opaque;
size_t offset = 7;
V9fsString target;
int32_t fid;
int err = 0;
V9fsFidState *fidp;
pdu_unmarshal(pdu, offset, "d", &fid);
trace_v9fs_readlink(pdu->tag, pdu->id, fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
v9fs_string_init(&target);
err = v9fs_co_readlink(pdu, &fidp->path, &target);
if (err < 0) {
goto out;
}
offset += pdu_marshal(pdu, offset, "s", &target);
err = offset;
trace_v9fs_readlink_return(pdu->tag, pdu->id, target.data);
v9fs_string_free(&target);
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
}
| false | qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | static void v9fs_readlink(void *opaque)
{
V9fsPDU *pdu = opaque;
size_t offset = 7;
V9fsString target;
int32_t fid;
int err = 0;
V9fsFidState *fidp;
pdu_unmarshal(pdu, offset, "d", &fid);
trace_v9fs_readlink(pdu->tag, pdu->id, fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -ENOENT;
goto out_nofid;
}
v9fs_string_init(&target);
err = v9fs_co_readlink(pdu, &fidp->path, &target);
if (err < 0) {
goto out;
}
offset += pdu_marshal(pdu, offset, "s", &target);
err = offset;
trace_v9fs_readlink_return(pdu->tag, pdu->id, target.data);
v9fs_string_free(&target);
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, err);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
V9fsPDU *pdu = VAR_0;
size_t offset = 7;
V9fsString target;
int32_t fid;
int VAR_1 = 0;
V9fsFidState *fidp;
pdu_unmarshal(pdu, offset, "d", &fid);
trace_v9fs_readlink(pdu->tag, pdu->id, fid);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
VAR_1 = -ENOENT;
goto out_nofid;
}
v9fs_string_init(&target);
VAR_1 = v9fs_co_readlink(pdu, &fidp->path, &target);
if (VAR_1 < 0) {
goto out;
}
offset += pdu_marshal(pdu, offset, "s", &target);
VAR_1 = offset;
trace_v9fs_readlink_return(pdu->tag, pdu->id, target.data);
v9fs_string_free(&target);
out:
put_fid(pdu, fidp);
out_nofid:
complete_pdu(pdu->s, pdu, VAR_1);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"V9fsPDU *pdu = VAR_0;",
"size_t offset = 7;",
"V9fsString target;",
"int32_t fid;",
"int VAR_1 = 0;",
"V9fsFidState *fidp;",
"pdu_unmarshal(pdu, offset, \"d\", &fid);",
"trace_v9fs_readlink(pdu->tag, pdu->id, fid);",
"fidp = get_fid(pdu, fid);",
"if (fidp == NULL) {",
"VAR_1 = -ENOENT;",
"goto out_nofid;",
"}",
"v9fs_string_init(&target);",
"VAR_1 = v9fs_co_readlink(pdu, &fidp->path, &target);",
"if (VAR_1 < 0) {",
"goto out;",
"}",
"offset += pdu_marshal(pdu, offset, \"s\", &target);",
"VAR_1 = offset;",
"trace_v9fs_readlink_return(pdu->tag, pdu->id, target.data);",
"v9fs_string_free(&target);",
"out:\nput_fid(pdu, fidp);",
"out_nofid:\ncomplete_pdu(pdu->s, pdu, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61
]
] |
25,317 | static void gt64120_write_config(PCIDevice *d, uint32_t address, uint32_t val,
int len)
{
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
pci_default_write_config(d, address, val, len);
}
| false | qemu | 1931e26054fdf2b1b84091f0b9662979eb6931ec | static void gt64120_write_config(PCIDevice *d, uint32_t address, uint32_t val,
int len)
{
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
pci_default_write_config(d, address, val, len);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1, uint32_t VAR_2,
int VAR_3)
{
#ifdef TARGET_WORDS_BIGENDIAN
VAR_2 = bswap32(VAR_2);
#endif
pci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);
}
| [
"static void FUNC_0(PCIDevice *VAR_0, uint32_t VAR_1, uint32_t VAR_2,\nint VAR_3)\n{",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_2 = bswap32(VAR_2);",
"#endif\npci_default_write_config(VAR_0, VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11,
13
],
[
15
]
] |
25,318 | static void arm_thiswdog_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
arm_mptimer_state *s = (arm_mptimer_state *)opaque;
int id = get_current_cpu(s);
timerblock_write(&s->timerblock[id * 2 + 1], addr, value, size);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void arm_thiswdog_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
arm_mptimer_state *s = (arm_mptimer_state *)opaque;
int id = get_current_cpu(s);
timerblock_write(&s->timerblock[id * 2 + 1], addr, value, size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
arm_mptimer_state *s = (arm_mptimer_state *)VAR_0;
int VAR_4 = get_current_cpu(s);
timerblock_write(&s->timerblock[VAR_4 * 2 + 1], VAR_1, VAR_2, VAR_3);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"arm_mptimer_state *s = (arm_mptimer_state *)VAR_0;",
"int VAR_4 = get_current_cpu(s);",
"timerblock_write(&s->timerblock[VAR_4 * 2 + 1], VAR_1, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,319 | static void rtc_save_td(QEMUFile *f, void *opaque)
{
RTCState *s = opaque;
qemu_put_be32(f, s->irq_coalesced);
qemu_put_be32(f, s->period);
}
| false | qemu | 048c74c4379789d03c857cea038ec00d95b68eaf | static void rtc_save_td(QEMUFile *f, void *opaque)
{
RTCState *s = opaque;
qemu_put_be32(f, s->irq_coalesced);
qemu_put_be32(f, s->period);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, void *VAR_1)
{
RTCState *s = VAR_1;
qemu_put_be32(VAR_0, s->irq_coalesced);
qemu_put_be32(VAR_0, s->period);
}
| [
"static void FUNC_0(QEMUFile *VAR_0, void *VAR_1)\n{",
"RTCState *s = VAR_1;",
"qemu_put_be32(VAR_0, s->irq_coalesced);",
"qemu_put_be32(VAR_0, s->period);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
25,320 | static void scsi_realize(SCSIDevice *dev, Error **errp)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
Error *err = NULL;
if (!s->qdev.conf.bs) {
error_setg(errp, "drive property not set");
return;
}
if (!(s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!bdrv_is_inserted(s->qdev.conf.bs)) {
error_setg(errp, "Device needs media, but drive is empty");
return;
}
blkconf_serial(&s->qdev.conf, &s->serial);
if (dev->type == TYPE_DISK) {
blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err);
if (err) {
error_propagate(errp, err);
return;
}
}
if (s->qdev.conf.discard_granularity == -1) {
s->qdev.conf.discard_granularity =
MAX(s->qdev.conf.logical_block_size, DEFAULT_DISCARD_GRANULARITY);
}
if (!s->version) {
s->version = g_strdup(qemu_get_version());
}
if (!s->vendor) {
s->vendor = g_strdup("QEMU");
}
if (bdrv_is_sg(s->qdev.conf.bs)) {
error_setg(errp, "unwanted /dev/sg*");
return;
}
if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!(s->features & (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS))) {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s);
} else {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
}
bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
bdrv_iostatus_enable(s->qdev.conf.bs);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void scsi_realize(SCSIDevice *dev, Error **errp)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
Error *err = NULL;
if (!s->qdev.conf.bs) {
error_setg(errp, "drive property not set");
return;
}
if (!(s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!bdrv_is_inserted(s->qdev.conf.bs)) {
error_setg(errp, "Device needs media, but drive is empty");
return;
}
blkconf_serial(&s->qdev.conf, &s->serial);
if (dev->type == TYPE_DISK) {
blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err);
if (err) {
error_propagate(errp, err);
return;
}
}
if (s->qdev.conf.discard_granularity == -1) {
s->qdev.conf.discard_granularity =
MAX(s->qdev.conf.logical_block_size, DEFAULT_DISCARD_GRANULARITY);
}
if (!s->version) {
s->version = g_strdup(qemu_get_version());
}
if (!s->vendor) {
s->vendor = g_strdup("QEMU");
}
if (bdrv_is_sg(s->qdev.conf.bs)) {
error_setg(errp, "unwanted /dev/sg*");
return;
}
if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!(s->features & (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS))) {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s);
} else {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
}
bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
bdrv_iostatus_enable(s->qdev.conf.bs);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);
Error *err = NULL;
if (!s->qdev.conf.bs) {
error_setg(VAR_1, "drive property not set");
return;
}
if (!(s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!bdrv_is_inserted(s->qdev.conf.bs)) {
error_setg(VAR_1, "Device needs media, but drive is empty");
return;
}
blkconf_serial(&s->qdev.conf, &s->serial);
if (VAR_0->type == TYPE_DISK) {
blkconf_geometry(&VAR_0->conf, NULL, 65535, 255, 255, &err);
if (err) {
error_propagate(VAR_1, err);
return;
}
}
if (s->qdev.conf.discard_granularity == -1) {
s->qdev.conf.discard_granularity =
MAX(s->qdev.conf.logical_block_size, DEFAULT_DISCARD_GRANULARITY);
}
if (!s->version) {
s->version = g_strdup(qemu_get_version());
}
if (!s->vendor) {
s->vendor = g_strdup("QEMU");
}
if (bdrv_is_sg(s->qdev.conf.bs)) {
error_setg(VAR_1, "unwanted /VAR_0/sg*");
return;
}
if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&
!(s->features & (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS))) {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s);
} else {
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
}
bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
bdrv_iostatus_enable(s->qdev.conf.bs);
}
| [
"static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);",
"Error *err = NULL;",
"if (!s->qdev.conf.bs) {",
"error_setg(VAR_1, \"drive property not set\");",
"return;",
"}",
"if (!(s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&\n!bdrv_is_inserted(s->qdev.conf.bs)) {",
"error_setg(VAR_1, \"Device needs media, but drive is empty\");",
"return;",
"}",
"blkconf_serial(&s->qdev.conf, &s->serial);",
"if (VAR_0->type == TYPE_DISK) {",
"blkconf_geometry(&VAR_0->conf, NULL, 65535, 255, 255, &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"}",
"if (s->qdev.conf.discard_granularity == -1) {",
"s->qdev.conf.discard_granularity =\nMAX(s->qdev.conf.logical_block_size, DEFAULT_DISCARD_GRANULARITY);",
"}",
"if (!s->version) {",
"s->version = g_strdup(qemu_get_version());",
"}",
"if (!s->vendor) {",
"s->vendor = g_strdup(\"QEMU\");",
"}",
"if (bdrv_is_sg(s->qdev.conf.bs)) {",
"error_setg(VAR_1, \"unwanted /VAR_0/sg*\");",
"return;",
"}",
"if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) &&\n!(s->features & (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS))) {",
"bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s);",
"} else {",
"bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);",
"}",
"bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);",
"bdrv_iostatus_enable(s->qdev.conf.bs);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
]
] |
25,321 | static void ahci_shutdown(AHCIQState *ahci)
{
QOSState *qs = ahci->parent;
ahci_clean_mem(ahci);
free_ahci_device(ahci->dev);
g_free(ahci);
qtest_shutdown(qs);
}
| false | qemu | debaaa114a8877a939533ba846e64168fb287b7b | static void ahci_shutdown(AHCIQState *ahci)
{
QOSState *qs = ahci->parent;
ahci_clean_mem(ahci);
free_ahci_device(ahci->dev);
g_free(ahci);
qtest_shutdown(qs);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AHCIQState *VAR_0)
{
QOSState *qs = VAR_0->parent;
ahci_clean_mem(VAR_0);
free_ahci_device(VAR_0->dev);
g_free(VAR_0);
qtest_shutdown(qs);
}
| [
"static void FUNC_0(AHCIQState *VAR_0)\n{",
"QOSState *qs = VAR_0->parent;",
"ahci_clean_mem(VAR_0);",
"free_ahci_device(VAR_0->dev);",
"g_free(VAR_0);",
"qtest_shutdown(qs);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,322 | int udp_set_remote_url(URLContext *h, const char *uri)
{
UDPContext *s = h->priv_data;
char hostname[256];
int port;
url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
/* set the destination address */
if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0)
return AVERROR_IO;
s->dest_addr.sin_family = AF_INET;
s->dest_addr.sin_port = htons(port);
return 0;
}
| false | FFmpeg | 6ba5cbc699e77cae66bb719354fa142114b64eab | int udp_set_remote_url(URLContext *h, const char *uri)
{
UDPContext *s = h->priv_data;
char hostname[256];
int port;
url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0)
return AVERROR_IO;
s->dest_addr.sin_family = AF_INET;
s->dest_addr.sin_port = htons(port);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(URLContext *VAR_0, const char *VAR_1)
{
UDPContext *s = VAR_0->priv_data;
char VAR_2[256];
int VAR_3;
url_split(NULL, 0, VAR_2, sizeof(VAR_2), &VAR_3, NULL, 0, VAR_1);
if (resolve_host(&s->dest_addr.sin_addr, VAR_2) < 0)
return AVERROR_IO;
s->dest_addr.sin_family = AF_INET;
s->dest_addr.sin_port = htons(VAR_3);
return 0;
}
| [
"int FUNC_0(URLContext *VAR_0, const char *VAR_1)\n{",
"UDPContext *s = VAR_0->priv_data;",
"char VAR_2[256];",
"int VAR_3;",
"url_split(NULL, 0, VAR_2, sizeof(VAR_2), &VAR_3, NULL, 0, VAR_1);",
"if (resolve_host(&s->dest_addr.sin_addr, VAR_2) < 0)\nreturn AVERROR_IO;",
"s->dest_addr.sin_family = AF_INET;",
"s->dest_addr.sin_port = htons(VAR_3);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
25,323 | int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ucontext_t *uc = puc;
#else
ucontext_t *uc = puc;
#endif
unsigned long pc;
int is_write;
pc = IAR_sig(uc);
is_write = 0;
#if 0
/* ppc 4xx case */
if (DSISR_sig(uc) & 0x00800000) {
is_write = 1;
}
#else
if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {
is_write = 1;
}
#endif
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
is_write, &uc->uc_sigmask);
}
| false | qemu | a78b1299f1bbb9608e3e3a36a7f16cf700a2789d | int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ucontext_t *uc = puc;
#else
ucontext_t *uc = puc;
#endif
unsigned long pc;
int is_write;
pc = IAR_sig(uc);
is_write = 0;
#if 0
if (DSISR_sig(uc) & 0x00800000) {
is_write = 1;
}
#else
if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {
is_write = 1;
}
#endif
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
is_write, &uc->uc_sigmask);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, void *VAR_1,
void *VAR_2)
{
siginfo_t *info = VAR_1;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ucontext_t *uc = VAR_2;
#else
ucontext_t *uc = VAR_2;
#endif
unsigned long VAR_3;
int VAR_4;
VAR_3 = IAR_sig(uc);
VAR_4 = 0;
#if 0
if (DSISR_sig(uc) & 0x00800000) {
VAR_4 = 1;
}
#else
if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {
VAR_4 = 1;
}
#endif
return handle_cpu_signal(VAR_3, (unsigned long)info->si_addr,
VAR_4, &uc->uc_sigmask);
}
| [
"int FUNC_0(int VAR_0, void *VAR_1,\nvoid *VAR_2)\n{",
"siginfo_t *info = VAR_1;",
"#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)\nucontext_t *uc = VAR_2;",
"#else\nucontext_t *uc = VAR_2;",
"#endif\nunsigned long VAR_3;",
"int VAR_4;",
"VAR_3 = IAR_sig(uc);",
"VAR_4 = 0;",
"#if 0\nif (DSISR_sig(uc) & 0x00800000) {",
"VAR_4 = 1;",
"}",
"#else\nif (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {",
"VAR_4 = 1;",
"}",
"#endif\nreturn handle_cpu_signal(VAR_3, (unsigned long)info->si_addr,\nVAR_4, &uc->uc_sigmask);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
25
],
[
27
],
[
29,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
]
] |
25,326 | static void net_socket_connected(int fd, Error *err, void *opaque)
{
socket_connect_data *c = opaque;
NetSocketState *s;
char *addr_str = NULL;
Error *local_error = NULL;
addr_str = socket_address_to_string(c->saddr, &local_error);
if (addr_str == NULL) {
error_report_err(local_error);
closesocket(fd);
goto end;
}
s = net_socket_fd_init(c->peer, c->model, c->name, fd, true);
if (!s) {
closesocket(fd);
goto end;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s", addr_str);
end:
g_free(addr_str);
socket_connect_data_free(c);
}
| false | qemu | 6701e5514beab7b781a10424a94e9850c707287c | static void net_socket_connected(int fd, Error *err, void *opaque)
{
socket_connect_data *c = opaque;
NetSocketState *s;
char *addr_str = NULL;
Error *local_error = NULL;
addr_str = socket_address_to_string(c->saddr, &local_error);
if (addr_str == NULL) {
error_report_err(local_error);
closesocket(fd);
goto end;
}
s = net_socket_fd_init(c->peer, c->model, c->name, fd, true);
if (!s) {
closesocket(fd);
goto end;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s", addr_str);
end:
g_free(addr_str);
socket_connect_data_free(c);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, Error *VAR_1, void *VAR_2)
{
socket_connect_data *c = VAR_2;
NetSocketState *s;
char *VAR_3 = NULL;
Error *local_error = NULL;
VAR_3 = socket_address_to_string(c->saddr, &local_error);
if (VAR_3 == NULL) {
error_report_err(local_error);
closesocket(VAR_0);
goto end;
}
s = net_socket_fd_init(c->peer, c->model, c->name, VAR_0, true);
if (!s) {
closesocket(VAR_0);
goto end;
}
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: connect to %s", VAR_3);
end:
g_free(VAR_3);
socket_connect_data_free(c);
}
| [
"static void FUNC_0(int VAR_0, Error *VAR_1, void *VAR_2)\n{",
"socket_connect_data *c = VAR_2;",
"NetSocketState *s;",
"char *VAR_3 = NULL;",
"Error *local_error = NULL;",
"VAR_3 = socket_address_to_string(c->saddr, &local_error);",
"if (VAR_3 == NULL) {",
"error_report_err(local_error);",
"closesocket(VAR_0);",
"goto end;",
"}",
"s = net_socket_fd_init(c->peer, c->model, c->name, VAR_0, true);",
"if (!s) {",
"closesocket(VAR_0);",
"goto end;",
"}",
"snprintf(s->nc.info_str, sizeof(s->nc.info_str),\n\"socket: connect to %s\", VAR_3);",
"end:\ng_free(VAR_3);",
"socket_connect_data_free(c);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
47,
49
],
[
51
],
[
53
]
] |
25,327 | void OPPROTO op_decw_ECX(void)
{
ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff);
}
| false | qemu | 6e0d8677cb443e7408c0b7a25a93c6596d7fa380 | void OPPROTO op_decw_ECX(void)
{
ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff);
}
| {
"code": [],
"line_no": []
} | void VAR_0 op_decw_ECX(void)
{
ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff);
}
| [
"void VAR_0 op_decw_ECX(void)\n{",
"ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,328 | static int vnc_auth_sasl_check_access(VncState *vs)
{
const void *val;
int err;
err = sasl_getprop(vs->sasl.conn, SASL_USERNAME, &val);
if (err != SASL_OK) {
VNC_DEBUG("cannot query SASL username on connection %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
return -1;
}
if (val == NULL) {
VNC_DEBUG("no client username was found\n");
return -1;
}
VNC_DEBUG("SASL client username %s\n", (const char *)val);
vs->sasl.username = qemu_strdup((const char*)val);
return 0;
}
| false | qemu | 76655d6dece88bd00e190956e8e4285b682edcbb | static int vnc_auth_sasl_check_access(VncState *vs)
{
const void *val;
int err;
err = sasl_getprop(vs->sasl.conn, SASL_USERNAME, &val);
if (err != SASL_OK) {
VNC_DEBUG("cannot query SASL username on connection %d (%s)\n",
err, sasl_errstring(err, NULL, NULL));
return -1;
}
if (val == NULL) {
VNC_DEBUG("no client username was found\n");
return -1;
}
VNC_DEBUG("SASL client username %s\n", (const char *)val);
vs->sasl.username = qemu_strdup((const char*)val);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0)
{
const void *VAR_1;
int VAR_2;
VAR_2 = sasl_getprop(VAR_0->sasl.conn, SASL_USERNAME, &VAR_1);
if (VAR_2 != SASL_OK) {
VNC_DEBUG("cannot query SASL username on connection %d (%s)\n",
VAR_2, sasl_errstring(VAR_2, NULL, NULL));
return -1;
}
if (VAR_1 == NULL) {
VNC_DEBUG("no client username was found\n");
return -1;
}
VNC_DEBUG("SASL client username %s\n", (const char *)VAR_1);
VAR_0->sasl.username = qemu_strdup((const char*)VAR_1);
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0)\n{",
"const void *VAR_1;",
"int VAR_2;",
"VAR_2 = sasl_getprop(VAR_0->sasl.conn, SASL_USERNAME, &VAR_1);",
"if (VAR_2 != SASL_OK) {",
"VNC_DEBUG(\"cannot query SASL username on connection %d (%s)\\n\",\nVAR_2, sasl_errstring(VAR_2, NULL, NULL));",
"return -1;",
"}",
"if (VAR_1 == NULL) {",
"VNC_DEBUG(\"no client username was found\\n\");",
"return -1;",
"}",
"VNC_DEBUG(\"SASL client username %s\\n\", (const char *)VAR_1);",
"VAR_0->sasl.username = qemu_strdup((const char*)VAR_1);",
"return 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
],
[
35
],
[
39
],
[
41
]
] |
25,329 | ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
ssize_t ret;
TRACE("Sending request to server: "
"{ .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64
", .type=%" PRIu32 " }",
request->from, request->len, request->handle, request->type);
stl_be_p(buf, NBD_REQUEST_MAGIC);
stl_be_p(buf + 4, request->type);
stq_be_p(buf + 8, request->handle);
stq_be_p(buf + 16, request->from);
stl_be_p(buf + 24, request->len);
ret = write_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
if (ret != sizeof(buf)) {
LOG("writing to socket failed");
return -EINVAL;
}
return 0;
}
| false | qemu | b626b51a6721e53817155af720243f59072e424f | ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
ssize_t ret;
TRACE("Sending request to server: "
"{ .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64
", .type=%" PRIu32 " }",
request->from, request->len, request->handle, request->type);
stl_be_p(buf, NBD_REQUEST_MAGIC);
stl_be_p(buf + 4, request->type);
stq_be_p(buf + 8, request->handle);
stq_be_p(buf + 16, request->from);
stl_be_p(buf + 24, request->len);
ret = write_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
if (ret != sizeof(buf)) {
LOG("writing to socket failed");
return -EINVAL;
}
return 0;
}
| {
"code": [],
"line_no": []
} | ssize_t FUNC_0(QIOChannel *ioc, struct nbd_request *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
ssize_t ret;
TRACE("Sending request to server: "
"{ .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64
", .type=%" PRIu32 " }",
request->from, request->len, request->handle, request->type);
stl_be_p(buf, NBD_REQUEST_MAGIC);
stl_be_p(buf + 4, request->type);
stq_be_p(buf + 8, request->handle);
stq_be_p(buf + 16, request->from);
stl_be_p(buf + 24, request->len);
ret = write_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
if (ret != sizeof(buf)) {
LOG("writing to socket failed");
return -EINVAL;
}
return 0;
}
| [
"ssize_t FUNC_0(QIOChannel *ioc, struct nbd_request *request)\n{",
"uint8_t buf[NBD_REQUEST_SIZE];",
"ssize_t ret;",
"TRACE(\"Sending request to server: \"\n\"{ .from = %\" PRIu64\", .len = %\" PRIu32 \", .handle = %\" PRIu64",
"\", .type=%\" PRIu32 \" }\",",
"request->from, request->len, request->handle, request->type);",
"stl_be_p(buf, NBD_REQUEST_MAGIC);",
"stl_be_p(buf + 4, request->type);",
"stq_be_p(buf + 8, request->handle);",
"stq_be_p(buf + 16, request->from);",
"stl_be_p(buf + 24, request->len);",
"ret = write_sync(ioc, buf, sizeof(buf));",
"if (ret < 0) {",
"return ret;",
"}",
"if (ret != sizeof(buf)) {",
"LOG(\"writing to socket failed\");",
"return -EINVAL;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
25,330 | static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
QDict *dict;
if (type == JSON_OPERATOR) {
switch (qstring_get_str(token)[0]) {
case '{':
parser->brace_count++;
break;
case '}':
parser->brace_count--;
break;
case '[':
parser->bracket_count++;
break;
case ']':
parser->bracket_count--;
break;
default:
break;
}
}
dict = qdict_new();
qdict_put(dict, "type", qint_from_int(type));
QINCREF(token);
qdict_put(dict, "token", token);
qdict_put(dict, "x", qint_from_int(x));
qdict_put(dict, "y", qint_from_int(y));
parser->token_size += token->length;
qlist_append(parser->tokens, dict);
if (type == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
parser->bracket_count > MAX_NESTING ||
parser->brace_count > MAX_NESTING) {
/* Security consideration, we limit total memory allocated per object
* and the maximum recursion depth that a message can force.
*/
goto out_emit;
}
return;
out_emit_bad:
/* clear out token list and tell the parser to emit and error
* indication by passing it a NULL list
*/
QDECREF(parser->tokens);
parser->tokens = NULL;
out_emit:
/* send current list of tokens to parser and reset tokenizer */
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
if (parser->tokens) {
QDECREF(parser->tokens);
}
parser->tokens = qlist_new();
parser->token_size = 0;
}
| true | qemu | 4f2d31fbc0bfdf41feea7d1be49f4f7ffa005534 | static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
QDict *dict;
if (type == JSON_OPERATOR) {
switch (qstring_get_str(token)[0]) {
case '{':
parser->brace_count++;
break;
case '}':
parser->brace_count--;
break;
case '[':
parser->bracket_count++;
break;
case ']':
parser->bracket_count--;
break;
default:
break;
}
}
dict = qdict_new();
qdict_put(dict, "type", qint_from_int(type));
QINCREF(token);
qdict_put(dict, "token", token);
qdict_put(dict, "x", qint_from_int(x));
qdict_put(dict, "y", qint_from_int(y));
parser->token_size += token->length;
qlist_append(parser->tokens, dict);
if (type == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
parser->bracket_count > MAX_NESTING ||
parser->brace_count > MAX_NESTING) {
goto out_emit;
}
return;
out_emit_bad:
QDECREF(parser->tokens);
parser->tokens = NULL;
out_emit:
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
if (parser->tokens) {
QDECREF(parser->tokens);
}
parser->tokens = qlist_new();
parser->token_size = 0;
}
| {
"code": [
" parser->bracket_count > MAX_NESTING ||",
" parser->brace_count > MAX_NESTING) {"
],
"line_no": [
87,
89
]
} | static void FUNC_0(JSONLexer *VAR_0, QString *VAR_1, JSONTokenType VAR_2, int VAR_3, int VAR_4)
{
JSONMessageParser *parser = container_of(VAR_0, JSONMessageParser, VAR_0);
QDict *dict;
if (VAR_2 == JSON_OPERATOR) {
switch (qstring_get_str(VAR_1)[0]) {
case '{':
parser->brace_count++;
break;
case '}':
parser->brace_count--;
break;
case '[':
parser->bracket_count++;
break;
case ']':
parser->bracket_count--;
break;
default:
break;
}
}
dict = qdict_new();
qdict_put(dict, "VAR_2", qint_from_int(VAR_2));
QINCREF(VAR_1);
qdict_put(dict, "VAR_1", VAR_1);
qdict_put(dict, "VAR_3", qint_from_int(VAR_3));
qdict_put(dict, "VAR_4", qint_from_int(VAR_4));
parser->token_size += VAR_1->length;
qlist_append(parser->tokens, dict);
if (VAR_2 == JSON_ERROR) {
goto out_emit_bad;
} else if (parser->brace_count < 0 ||
parser->bracket_count < 0 ||
(parser->brace_count == 0 &&
parser->bracket_count == 0)) {
goto out_emit;
} else if (parser->token_size > MAX_TOKEN_SIZE ||
parser->bracket_count > MAX_NESTING ||
parser->brace_count > MAX_NESTING) {
goto out_emit;
}
return;
out_emit_bad:
QDECREF(parser->tokens);
parser->tokens = NULL;
out_emit:
parser->brace_count = 0;
parser->bracket_count = 0;
parser->emit(parser, parser->tokens);
if (parser->tokens) {
QDECREF(parser->tokens);
}
parser->tokens = qlist_new();
parser->token_size = 0;
}
| [
"static void FUNC_0(JSONLexer *VAR_0, QString *VAR_1, JSONTokenType VAR_2, int VAR_3, int VAR_4)\n{",
"JSONMessageParser *parser = container_of(VAR_0, JSONMessageParser, VAR_0);",
"QDict *dict;",
"if (VAR_2 == JSON_OPERATOR) {",
"switch (qstring_get_str(VAR_1)[0]) {",
"case '{':",
"parser->brace_count++;",
"break;",
"case '}':",
"parser->brace_count--;",
"break;",
"case '[':\nparser->bracket_count++;",
"break;",
"case ']':\nparser->bracket_count--;",
"break;",
"default:\nbreak;",
"}",
"}",
"dict = qdict_new();",
"qdict_put(dict, \"VAR_2\", qint_from_int(VAR_2));",
"QINCREF(VAR_1);",
"qdict_put(dict, \"VAR_1\", VAR_1);",
"qdict_put(dict, \"VAR_3\", qint_from_int(VAR_3));",
"qdict_put(dict, \"VAR_4\", qint_from_int(VAR_4));",
"parser->token_size += VAR_1->length;",
"qlist_append(parser->tokens, dict);",
"if (VAR_2 == JSON_ERROR) {",
"goto out_emit_bad;",
"} else if (parser->brace_count < 0 ||",
"parser->bracket_count < 0 ||\n(parser->brace_count == 0 &&\nparser->bracket_count == 0)) {",
"goto out_emit;",
"} else if (parser->token_size > MAX_TOKEN_SIZE ||",
"parser->bracket_count > MAX_NESTING ||\nparser->brace_count > MAX_NESTING) {",
"goto out_emit;",
"}",
"return;",
"out_emit_bad:\nQDECREF(parser->tokens);",
"parser->tokens = NULL;",
"out_emit:\nparser->brace_count = 0;",
"parser->bracket_count = 0;",
"parser->emit(parser, parser->tokens);",
"if (parser->tokens) {",
"QDECREF(parser->tokens);",
"}",
"parser->tokens = qlist_new();",
"parser->token_size = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
97
],
[
99
],
[
103
],
[
107,
115
],
[
117
],
[
119,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
]
] |
25,331 | static bool gen_wsr_ccompare(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
uint32_t id = sr - CCOMPARE;
bool ret = false;
if (id < dc->config->nccompare) {
uint32_t int_bit = 1 << dc->config->timerint[id];
TCGv_i32 tmp = tcg_const_i32(id);
tcg_gen_mov_i32(cpu_SR[sr], v);
tcg_gen_andi_i32(cpu_SR[INTSET], cpu_SR[INTSET], ~int_bit);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_update_ccompare(cpu_env, tmp);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_jumpi_check_loop_end(dc, 0);
ret = true;
}
tcg_temp_free(tmp);
}
return ret;
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static bool gen_wsr_ccompare(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
uint32_t id = sr - CCOMPARE;
bool ret = false;
if (id < dc->config->nccompare) {
uint32_t int_bit = 1 << dc->config->timerint[id];
TCGv_i32 tmp = tcg_const_i32(id);
tcg_gen_mov_i32(cpu_SR[sr], v);
tcg_gen_andi_i32(cpu_SR[INTSET], cpu_SR[INTSET], ~int_bit);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_update_ccompare(cpu_env, tmp);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_jumpi_check_loop_end(dc, 0);
ret = true;
}
tcg_temp_free(tmp);
}
return ret;
}
| {
"code": [
" if (dc->tb->cflags & CF_USE_ICOUNT) {",
" if (dc->tb->cflags & CF_USE_ICOUNT) {",
" if (dc->tb->cflags & CF_USE_ICOUNT) {",
" if (dc->tb->cflags & CF_USE_ICOUNT) {",
" if (dc->tb->cflags & CF_USE_ICOUNT) {",
" if (dc->tb->cflags & CF_USE_ICOUNT) {"
],
"line_no": [
23,
23,
23,
23,
23,
23
]
} | static bool FUNC_0(DisasContext *dc, uint32_t sr, TCGv_i32 v)
{
uint32_t id = sr - CCOMPARE;
bool ret = false;
if (id < dc->config->nccompare) {
uint32_t int_bit = 1 << dc->config->timerint[id];
TCGv_i32 tmp = tcg_const_i32(id);
tcg_gen_mov_i32(cpu_SR[sr], v);
tcg_gen_andi_i32(cpu_SR[INTSET], cpu_SR[INTSET], ~int_bit);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_start();
}
gen_helper_update_ccompare(cpu_env, tmp);
if (dc->tb->cflags & CF_USE_ICOUNT) {
gen_io_end();
gen_jumpi_check_loop_end(dc, 0);
ret = true;
}
tcg_temp_free(tmp);
}
return ret;
}
| [
"static bool FUNC_0(DisasContext *dc, uint32_t sr, TCGv_i32 v)\n{",
"uint32_t id = sr - CCOMPARE;",
"bool ret = false;",
"if (id < dc->config->nccompare) {",
"uint32_t int_bit = 1 << dc->config->timerint[id];",
"TCGv_i32 tmp = tcg_const_i32(id);",
"tcg_gen_mov_i32(cpu_SR[sr], v);",
"tcg_gen_andi_i32(cpu_SR[INTSET], cpu_SR[INTSET], ~int_bit);",
"if (dc->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_start();",
"}",
"gen_helper_update_ccompare(cpu_env, tmp);",
"if (dc->tb->cflags & CF_USE_ICOUNT) {",
"gen_io_end();",
"gen_jumpi_check_loop_end(dc, 0);",
"ret = true;",
"}",
"tcg_temp_free(tmp);",
"}",
"return ret;",
"}"
] | [
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
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
25,332 | static void vnc_write_pixels_generic(VncState *vs, void *pixels1, int size)
{
uint8_t buf[4];
if (vs->depth == 4) {
uint32_t *pixels = pixels1;
int n, i;
n = size >> 2;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else if (vs->depth == 2) {
uint16_t *pixels = pixels1;
int n, i;
n = size >> 1;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else if (vs->depth == 1) {
uint8_t *pixels = pixels1;
int n, i;
n = size;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else {
fprintf(stderr, "vnc_write_pixels_generic: VncState color depth not supported\n");
}
}
| true | qemu | 6cec5487990bf3f1f22b3fcb871978255e92ae0d | static void vnc_write_pixels_generic(VncState *vs, void *pixels1, int size)
{
uint8_t buf[4];
if (vs->depth == 4) {
uint32_t *pixels = pixels1;
int n, i;
n = size >> 2;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else if (vs->depth == 2) {
uint16_t *pixels = pixels1;
int n, i;
n = size >> 1;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else if (vs->depth == 1) {
uint8_t *pixels = pixels1;
int n, i;
n = size;
for(i = 0; i < n; i++) {
vnc_convert_pixel(vs, buf, pixels[i]);
vnc_write(vs, buf, vs->pix_bpp);
}
} else {
fprintf(stderr, "vnc_write_pixels_generic: VncState color depth not supported\n");
}
}
| {
"code": [
" if (vs->depth == 4) {",
" vnc_write(vs, buf, vs->pix_bpp);",
" } else if (vs->depth == 2) {",
" vnc_write(vs, buf, vs->pix_bpp);",
" } else if (vs->depth == 1) {",
" vnc_write(vs, buf, vs->pix_bpp);",
" if (vs->depth == 4) {",
" } else if (vs->depth == 2) {",
" } else if (vs->depth == 1) {"
],
"line_no": [
9,
21,
25,
21,
41,
21,
9,
25,
41
]
} | static void FUNC_0(VncState *VAR_0, void *VAR_1, int VAR_2)
{
uint8_t buf[4];
if (VAR_0->depth == 4) {
uint32_t *pixels = VAR_1;
int VAR_5, VAR_5;
VAR_5 = VAR_2 >> 2;
for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {
vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);
vnc_write(VAR_0, buf, VAR_0->pix_bpp);
}
} else if (VAR_0->depth == 2) {
uint16_t *pixels = VAR_1;
int VAR_5, VAR_5;
VAR_5 = VAR_2 >> 1;
for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {
vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);
vnc_write(VAR_0, buf, VAR_0->pix_bpp);
}
} else if (VAR_0->depth == 1) {
uint8_t *pixels = VAR_1;
int VAR_5, VAR_5;
VAR_5 = VAR_2;
for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {
vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);
vnc_write(VAR_0, buf, VAR_0->pix_bpp);
}
} else {
fprintf(stderr, "FUNC_0: VncState color depth not supported\VAR_5");
}
}
| [
"static void FUNC_0(VncState *VAR_0, void *VAR_1, int VAR_2)\n{",
"uint8_t buf[4];",
"if (VAR_0->depth == 4) {",
"uint32_t *pixels = VAR_1;",
"int VAR_5, VAR_5;",
"VAR_5 = VAR_2 >> 2;",
"for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {",
"vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);",
"vnc_write(VAR_0, buf, VAR_0->pix_bpp);",
"}",
"} else if (VAR_0->depth == 2) {",
"uint16_t *pixels = VAR_1;",
"int VAR_5, VAR_5;",
"VAR_5 = VAR_2 >> 1;",
"for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {",
"vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);",
"vnc_write(VAR_0, buf, VAR_0->pix_bpp);",
"}",
"} else if (VAR_0->depth == 1) {",
"uint8_t *pixels = VAR_1;",
"int VAR_5, VAR_5;",
"VAR_5 = VAR_2;",
"for(VAR_5 = 0; VAR_5 < VAR_5; VAR_5++) {",
"vnc_convert_pixel(VAR_0, buf, pixels[VAR_5]);",
"vnc_write(VAR_0, buf, VAR_0->pix_bpp);",
"}",
"} else {",
"fprintf(stderr, \"FUNC_0: VncState color depth not supported\\VAR_5\");",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
25,333 | static int parse_tonal(DCALbrDecoder *s, int group)
{
unsigned int amp[DCA_LBR_CHANNELS_TOTAL];
unsigned int phs[DCA_LBR_CHANNELS_TOTAL];
unsigned int diff, main_amp, shift;
int sf, sf_idx, ch, main_ch, freq;
int ch_nbits = av_ceil_log2(s->nchannels_total);
// Parse subframes for this group
for (sf = 0; sf < 1 << group; sf += diff ? 8 : 1) {
sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] = s->ntones;
// Parse tones for this subframe
for (freq = 1;; freq++) {
if (get_bits_left(&s->gb) < 1) {
av_log(s->avctx, AV_LOG_ERROR, "Tonal group chunk too short\n");
return -1;
}
diff = parse_vlc(&s->gb, &ff_dca_vlc_tnl_grp[group], 2);
if (diff >= FF_ARRAY_ELEMS(ff_dca_fst_amp)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tonal frequency diff\n");
return -1;
}
diff = get_bitsz(&s->gb, diff >> 2) + ff_dca_fst_amp[diff];
if (diff <= 1)
break; // End of subframe
freq += diff - 2;
if (freq >> (5 - group) > s->nsubbands * 4 - 5) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid spectral line offset\n");
return -1;
}
// Main channel
main_ch = get_bitsz(&s->gb, ch_nbits);
main_amp = parse_vlc(&s->gb, &ff_dca_vlc_tnl_scf, 2)
+ s->tonal_scf[ff_dca_freq_to_sb[freq >> (7 - group)]]
+ s->limited_range - 2;
amp[main_ch] = main_amp < AMP_MAX ? main_amp : 0;
phs[main_ch] = get_bits(&s->gb, 3);
// Secondary channels
for (ch = 0; ch < s->nchannels_total; ch++) {
if (ch == main_ch)
continue;
if (get_bits1(&s->gb)) {
amp[ch] = amp[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_damp, 1);
phs[ch] = phs[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_dph, 1);
} else {
amp[ch] = 0;
phs[ch] = 0;
}
}
if (amp[main_ch]) {
// Allocate new tone
DCALbrTone *t = &s->tones[s->ntones];
s->ntones = (s->ntones + 1) & (DCA_LBR_TONES - 1);
t->x_freq = freq >> (5 - group);
t->f_delt = (freq & ((1 << (5 - group)) - 1)) << group;
t->ph_rot = 256 - (t->x_freq & 1) * 128 - t->f_delt * 4;
shift = ff_dca_ph0_shift[(t->x_freq & 3) * 2 + (freq & 1)]
- ((t->ph_rot << (5 - group)) - t->ph_rot);
for (ch = 0; ch < s->nchannels; ch++) {
t->amp[ch] = amp[ch] < AMP_MAX ? amp[ch] : 0;
t->phs[ch] = 128 - phs[ch] * 32 + shift;
}
}
}
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
return 0;
}
| true | FFmpeg | 61f70416f8542cc86c84ae6e0342ba10a35d7cba | static int parse_tonal(DCALbrDecoder *s, int group)
{
unsigned int amp[DCA_LBR_CHANNELS_TOTAL];
unsigned int phs[DCA_LBR_CHANNELS_TOTAL];
unsigned int diff, main_amp, shift;
int sf, sf_idx, ch, main_ch, freq;
int ch_nbits = av_ceil_log2(s->nchannels_total);
for (sf = 0; sf < 1 << group; sf += diff ? 8 : 1) {
sf_idx = ((s->framenum << group) + sf) & 31;
s->tonal_bounds[group][sf_idx][0] = s->ntones;
for (freq = 1;; freq++) {
if (get_bits_left(&s->gb) < 1) {
av_log(s->avctx, AV_LOG_ERROR, "Tonal group chunk too short\n");
return -1;
}
diff = parse_vlc(&s->gb, &ff_dca_vlc_tnl_grp[group], 2);
if (diff >= FF_ARRAY_ELEMS(ff_dca_fst_amp)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid tonal frequency diff\n");
return -1;
}
diff = get_bitsz(&s->gb, diff >> 2) + ff_dca_fst_amp[diff];
if (diff <= 1)
break;
freq += diff - 2;
if (freq >> (5 - group) > s->nsubbands * 4 - 5) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid spectral line offset\n");
return -1;
}
main_ch = get_bitsz(&s->gb, ch_nbits);
main_amp = parse_vlc(&s->gb, &ff_dca_vlc_tnl_scf, 2)
+ s->tonal_scf[ff_dca_freq_to_sb[freq >> (7 - group)]]
+ s->limited_range - 2;
amp[main_ch] = main_amp < AMP_MAX ? main_amp : 0;
phs[main_ch] = get_bits(&s->gb, 3);
for (ch = 0; ch < s->nchannels_total; ch++) {
if (ch == main_ch)
continue;
if (get_bits1(&s->gb)) {
amp[ch] = amp[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_damp, 1);
phs[ch] = phs[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_dph, 1);
} else {
amp[ch] = 0;
phs[ch] = 0;
}
}
if (amp[main_ch]) {
DCALbrTone *t = &s->tones[s->ntones];
s->ntones = (s->ntones + 1) & (DCA_LBR_TONES - 1);
t->x_freq = freq >> (5 - group);
t->f_delt = (freq & ((1 << (5 - group)) - 1)) << group;
t->ph_rot = 256 - (t->x_freq & 1) * 128 - t->f_delt * 4;
shift = ff_dca_ph0_shift[(t->x_freq & 3) * 2 + (freq & 1)]
- ((t->ph_rot << (5 - group)) - t->ph_rot);
for (ch = 0; ch < s->nchannels; ch++) {
t->amp[ch] = amp[ch] < AMP_MAX ? amp[ch] : 0;
t->phs[ch] = 128 - phs[ch] * 32 + shift;
}
}
}
s->tonal_bounds[group][sf_idx][1] = s->ntones;
}
return 0;
}
| {
"code": [
" if (freq >> (5 - group) > s->nsubbands * 4 - 5) {"
],
"line_no": [
63
]
} | static int FUNC_0(DCALbrDecoder *VAR_0, int VAR_1)
{
unsigned int VAR_2[DCA_LBR_CHANNELS_TOTAL];
unsigned int VAR_3[DCA_LBR_CHANNELS_TOTAL];
unsigned int VAR_4, VAR_5, VAR_6;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
int VAR_12 = av_ceil_log2(VAR_0->nchannels_total);
for (VAR_7 = 0; VAR_7 < 1 << VAR_1; VAR_7 += VAR_4 ? 8 : 1) {
VAR_8 = ((VAR_0->framenum << VAR_1) + VAR_7) & 31;
VAR_0->tonal_bounds[VAR_1][VAR_8][0] = VAR_0->ntones;
for (VAR_11 = 1;; VAR_11++) {
if (get_bits_left(&VAR_0->gb) < 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Tonal VAR_1 chunk too short\n");
return -1;
}
VAR_4 = parse_vlc(&VAR_0->gb, &ff_dca_vlc_tnl_grp[VAR_1], 2);
if (VAR_4 >= FF_ARRAY_ELEMS(ff_dca_fst_amp)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid tonal frequency VAR_4\n");
return -1;
}
VAR_4 = get_bitsz(&VAR_0->gb, VAR_4 >> 2) + ff_dca_fst_amp[VAR_4];
if (VAR_4 <= 1)
break;
VAR_11 += VAR_4 - 2;
if (VAR_11 >> (5 - VAR_1) > VAR_0->nsubbands * 4 - 5) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid spectral line offset\n");
return -1;
}
VAR_10 = get_bitsz(&VAR_0->gb, VAR_12);
VAR_5 = parse_vlc(&VAR_0->gb, &ff_dca_vlc_tnl_scf, 2)
+ VAR_0->tonal_scf[ff_dca_freq_to_sb[VAR_11 >> (7 - VAR_1)]]
+ VAR_0->limited_range - 2;
VAR_2[VAR_10] = VAR_5 < AMP_MAX ? VAR_5 : 0;
VAR_3[VAR_10] = get_bits(&VAR_0->gb, 3);
for (VAR_9 = 0; VAR_9 < VAR_0->nchannels_total; VAR_9++) {
if (VAR_9 == VAR_10)
continue;
if (get_bits1(&VAR_0->gb)) {
VAR_2[VAR_9] = VAR_2[VAR_10] - parse_vlc(&VAR_0->gb, &ff_dca_vlc_damp, 1);
VAR_3[VAR_9] = VAR_3[VAR_10] - parse_vlc(&VAR_0->gb, &ff_dca_vlc_dph, 1);
} else {
VAR_2[VAR_9] = 0;
VAR_3[VAR_9] = 0;
}
}
if (VAR_2[VAR_10]) {
DCALbrTone *t = &VAR_0->tones[VAR_0->ntones];
VAR_0->ntones = (VAR_0->ntones + 1) & (DCA_LBR_TONES - 1);
t->x_freq = VAR_11 >> (5 - VAR_1);
t->f_delt = (VAR_11 & ((1 << (5 - VAR_1)) - 1)) << VAR_1;
t->ph_rot = 256 - (t->x_freq & 1) * 128 - t->f_delt * 4;
VAR_6 = ff_dca_ph0_shift[(t->x_freq & 3) * 2 + (VAR_11 & 1)]
- ((t->ph_rot << (5 - VAR_1)) - t->ph_rot);
for (VAR_9 = 0; VAR_9 < VAR_0->nchannels; VAR_9++) {
t->VAR_2[VAR_9] = VAR_2[VAR_9] < AMP_MAX ? VAR_2[VAR_9] : 0;
t->VAR_3[VAR_9] = 128 - VAR_3[VAR_9] * 32 + VAR_6;
}
}
}
VAR_0->tonal_bounds[VAR_1][VAR_8][1] = VAR_0->ntones;
}
return 0;
}
| [
"static int FUNC_0(DCALbrDecoder *VAR_0, int VAR_1)\n{",
"unsigned int VAR_2[DCA_LBR_CHANNELS_TOTAL];",
"unsigned int VAR_3[DCA_LBR_CHANNELS_TOTAL];",
"unsigned int VAR_4, VAR_5, VAR_6;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"int VAR_12 = av_ceil_log2(VAR_0->nchannels_total);",
"for (VAR_7 = 0; VAR_7 < 1 << VAR_1; VAR_7 += VAR_4 ? 8 : 1) {",
"VAR_8 = ((VAR_0->framenum << VAR_1) + VAR_7) & 31;",
"VAR_0->tonal_bounds[VAR_1][VAR_8][0] = VAR_0->ntones;",
"for (VAR_11 = 1;; VAR_11++) {",
"if (get_bits_left(&VAR_0->gb) < 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Tonal VAR_1 chunk too short\\n\");",
"return -1;",
"}",
"VAR_4 = parse_vlc(&VAR_0->gb, &ff_dca_vlc_tnl_grp[VAR_1], 2);",
"if (VAR_4 >= FF_ARRAY_ELEMS(ff_dca_fst_amp)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid tonal frequency VAR_4\\n\");",
"return -1;",
"}",
"VAR_4 = get_bitsz(&VAR_0->gb, VAR_4 >> 2) + ff_dca_fst_amp[VAR_4];",
"if (VAR_4 <= 1)\nbreak;",
"VAR_11 += VAR_4 - 2;",
"if (VAR_11 >> (5 - VAR_1) > VAR_0->nsubbands * 4 - 5) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Invalid spectral line offset\\n\");",
"return -1;",
"}",
"VAR_10 = get_bitsz(&VAR_0->gb, VAR_12);",
"VAR_5 = parse_vlc(&VAR_0->gb, &ff_dca_vlc_tnl_scf, 2)\n+ VAR_0->tonal_scf[ff_dca_freq_to_sb[VAR_11 >> (7 - VAR_1)]]\n+ VAR_0->limited_range - 2;",
"VAR_2[VAR_10] = VAR_5 < AMP_MAX ? VAR_5 : 0;",
"VAR_3[VAR_10] = get_bits(&VAR_0->gb, 3);",
"for (VAR_9 = 0; VAR_9 < VAR_0->nchannels_total; VAR_9++) {",
"if (VAR_9 == VAR_10)\ncontinue;",
"if (get_bits1(&VAR_0->gb)) {",
"VAR_2[VAR_9] = VAR_2[VAR_10] - parse_vlc(&VAR_0->gb, &ff_dca_vlc_damp, 1);",
"VAR_3[VAR_9] = VAR_3[VAR_10] - parse_vlc(&VAR_0->gb, &ff_dca_vlc_dph, 1);",
"} else {",
"VAR_2[VAR_9] = 0;",
"VAR_3[VAR_9] = 0;",
"}",
"}",
"if (VAR_2[VAR_10]) {",
"DCALbrTone *t = &VAR_0->tones[VAR_0->ntones];",
"VAR_0->ntones = (VAR_0->ntones + 1) & (DCA_LBR_TONES - 1);",
"t->x_freq = VAR_11 >> (5 - VAR_1);",
"t->f_delt = (VAR_11 & ((1 << (5 - VAR_1)) - 1)) << VAR_1;",
"t->ph_rot = 256 - (t->x_freq & 1) * 128 - t->f_delt * 4;",
"VAR_6 = ff_dca_ph0_shift[(t->x_freq & 3) * 2 + (VAR_11 & 1)]\n- ((t->ph_rot << (5 - VAR_1)) - t->ph_rot);",
"for (VAR_9 = 0; VAR_9 < VAR_0->nchannels; VAR_9++) {",
"t->VAR_2[VAR_9] = VAR_2[VAR_9] < AMP_MAX ? VAR_2[VAR_9] : 0;",
"t->VAR_3[VAR_9] = 128 - VAR_3[VAR_9] * 32 + VAR_6;",
"}",
"}",
"}",
"VAR_0->tonal_bounds[VAR_1][VAR_8][1] = VAR_0->ntones;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133,
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
159
],
[
161
]
] |
25,334 | static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
unsigned size)
{
mv88w8618_eth_state *s = opaque;
switch (offset) {
case MP_ETH_SMIR:
if (s->smir & MP_ETH_SMIR_OPCODE) {
switch (s->smir & MP_ETH_SMIR_ADDR) {
case MP_ETH_PHY1_BMSR:
return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID1:
return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID2:
return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
default:
return MP_ETH_SMIR_RDVALID;
}
}
return 0;
case MP_ETH_ICR:
return s->icr;
case MP_ETH_IMR:
return s->imr;
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
default:
return 0;
}
}
| true | qemu | cf143ad35018c5fc1da6365b45acda2b34aba90a | static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
unsigned size)
{
mv88w8618_eth_state *s = opaque;
switch (offset) {
case MP_ETH_SMIR:
if (s->smir & MP_ETH_SMIR_OPCODE) {
switch (s->smir & MP_ETH_SMIR_ADDR) {
case MP_ETH_PHY1_BMSR:
return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID1:
return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID2:
return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
default:
return MP_ETH_SMIR_RDVALID;
}
}
return 0;
case MP_ETH_ICR:
return s->icr;
case MP_ETH_IMR:
return s->imr;
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
default:
return 0;
}
}
| {
"code": [
" case MP_ETH_CTDP0 ... MP_ETH_CTDP3:",
" case MP_ETH_CTDP0 ... MP_ETH_CTDP3:"
],
"line_no": [
69,
69
]
} | static uint64_t FUNC_0(void *opaque, hwaddr offset,
unsigned size)
{
mv88w8618_eth_state *s = opaque;
switch (offset) {
case MP_ETH_SMIR:
if (s->smir & MP_ETH_SMIR_OPCODE) {
switch (s->smir & MP_ETH_SMIR_ADDR) {
case MP_ETH_PHY1_BMSR:
return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID1:
return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
case MP_ETH_PHY1_PHYSID2:
return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
default:
return MP_ETH_SMIR_RDVALID;
}
}
return 0;
case MP_ETH_ICR:
return s->icr;
case MP_ETH_IMR:
return s->imr;
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
case MP_ETH_CTDP0 ... MP_ETH_CTDP3:
return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
default:
return 0;
}
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr offset,\nunsigned size)\n{",
"mv88w8618_eth_state *s = opaque;",
"switch (offset) {",
"case MP_ETH_SMIR:\nif (s->smir & MP_ETH_SMIR_OPCODE) {",
"switch (s->smir & MP_ETH_SMIR_ADDR) {",
"case MP_ETH_PHY1_BMSR:\nreturn MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |\nMP_ETH_SMIR_RDVALID;",
"case MP_ETH_PHY1_PHYSID1:\nreturn (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;",
"case MP_ETH_PHY1_PHYSID2:\nreturn (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;",
"default:\nreturn MP_ETH_SMIR_RDVALID;",
"}",
"}",
"return 0;",
"case MP_ETH_ICR:\nreturn s->icr;",
"case MP_ETH_IMR:\nreturn s->imr;",
"case MP_ETH_FRDP0 ... MP_ETH_FRDP3:\nreturn s->frx_queue[(offset - MP_ETH_FRDP0)/4];",
"case MP_ETH_CRDP0 ... MP_ETH_CRDP3:\nreturn s->rx_queue[(offset - MP_ETH_CRDP0)/4];",
"case MP_ETH_CTDP0 ... MP_ETH_CTDP3:\nreturn s->tx_queue[(offset - MP_ETH_CTDP0)/4];",
"default:\nreturn 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21,
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
51,
53
],
[
57,
59
],
[
63,
65
],
[
69,
71
],
[
75,
77
],
[
79
],
[
81
]
] |
25,335 | static int make_cdt16_entry(int p1, int p2, int16_t *cdt)
{
int r, b, lo;
b = cdt[p2];
r = cdt[p1] << 11;
lo = b + r;
return (lo + (lo << 16)) << 1;
}
| true | FFmpeg | cf818be4f2f1e06bf63da3a6b55a4c3620952070 | static int make_cdt16_entry(int p1, int p2, int16_t *cdt)
{
int r, b, lo;
b = cdt[p2];
r = cdt[p1] << 11;
lo = b + r;
return (lo + (lo << 16)) << 1;
}
| {
"code": [
" return (lo + (lo << 16)) << 1;"
],
"line_no": [
15
]
} | static int FUNC_0(int VAR_0, int VAR_1, int16_t *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
VAR_4 = VAR_2[VAR_1];
VAR_3 = VAR_2[VAR_0] << 11;
VAR_5 = VAR_4 + VAR_3;
return (VAR_5 + (VAR_5 << 16)) << 1;
}
| [
"static int FUNC_0(int VAR_0, int VAR_1, int16_t *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"VAR_4 = VAR_2[VAR_1];",
"VAR_3 = VAR_2[VAR_0] << 11;",
"VAR_5 = VAR_4 + VAR_3;",
"return (VAR_5 + (VAR_5 << 16)) << 1;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,336 | static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
QObject *data = NULL;
cmd->mhandler.cmd_new(mon, params, &data);
if (is_async_return(data)) {
/*
* Asynchronous commands have no initial return data but they can
* generate errors. Data is returned via the async completion handler.
*/
if (monitor_ctrl_mode(mon) && monitor_has_error(mon)) {
monitor_protocol_emitter(mon, NULL);
}
} else if (monitor_ctrl_mode(mon)) {
/* Monitor Protocol */
monitor_protocol_emitter(mon, data);
} else {
/* User Protocol */
if (data)
cmd->user_print(mon, data);
}
qobject_decref(data);
}
| true | qemu | bb89c2e901b1a0c1cb6b94392cae1f98e6660ed7 | static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
QObject *data = NULL;
cmd->mhandler.cmd_new(mon, params, &data);
if (is_async_return(data)) {
if (monitor_ctrl_mode(mon) && monitor_has_error(mon)) {
monitor_protocol_emitter(mon, NULL);
}
} else if (monitor_ctrl_mode(mon)) {
monitor_protocol_emitter(mon, data);
} else {
if (data)
cmd->user_print(mon, data);
}
qobject_decref(data);
}
| {
"code": [
" cmd->mhandler.cmd_new(mon, params, &data);"
],
"line_no": [
11
]
} | static void FUNC_0(Monitor *VAR_0, const mon_cmd_t *VAR_1,
const QDict *VAR_2)
{
QObject *data = NULL;
VAR_1->mhandler.cmd_new(VAR_0, VAR_2, &data);
if (is_async_return(data)) {
if (monitor_ctrl_mode(VAR_0) && monitor_has_error(VAR_0)) {
monitor_protocol_emitter(VAR_0, NULL);
}
} else if (monitor_ctrl_mode(VAR_0)) {
monitor_protocol_emitter(VAR_0, data);
} else {
if (data)
VAR_1->user_print(VAR_0, data);
}
qobject_decref(data);
}
| [
"static void FUNC_0(Monitor *VAR_0, const mon_cmd_t *VAR_1,\nconst QDict *VAR_2)\n{",
"QObject *data = NULL;",
"VAR_1->mhandler.cmd_new(VAR_0, VAR_2, &data);",
"if (is_async_return(data)) {",
"if (monitor_ctrl_mode(VAR_0) && monitor_has_error(VAR_0)) {",
"monitor_protocol_emitter(VAR_0, NULL);",
"}",
"} else if (monitor_ctrl_mode(VAR_0)) {",
"monitor_protocol_emitter(VAR_0, data);",
"} else {",
"if (data)\nVAR_1->user_print(VAR_0, data);",
"}",
"qobject_decref(data);",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
49
],
[
51
]
] |
25,337 | static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset,
bool write)
{
BDRVVPCState *s = bs->opaque;
uint64_t bitmap_offset, block_offset;
uint32_t pagetable_index, offset_in_block;
pagetable_index = offset / s->block_size;
offset_in_block = offset % s->block_size;
if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)
return -1; /* not allocated */
bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];
block_offset = bitmap_offset + s->bitmap_size + offset_in_block;
/* We must ensure that we don't write to any sectors which are marked as
unused in the bitmap. We get away with setting all bits in the block
bitmap each time we write to a new block. This might cause Virtual PC to
miss sparse read optimization, but it's not a problem in terms of
correctness. */
if (write && (s->last_bitmap_offset != bitmap_offset)) {
uint8_t bitmap[s->bitmap_size];
s->last_bitmap_offset = bitmap_offset;
memset(bitmap, 0xff, s->bitmap_size);
bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
}
return block_offset;
}
| true | qemu | cfc87e00c22ab4ea0262c9771c803ed03d754001 | static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset,
bool write)
{
BDRVVPCState *s = bs->opaque;
uint64_t bitmap_offset, block_offset;
uint32_t pagetable_index, offset_in_block;
pagetable_index = offset / s->block_size;
offset_in_block = offset % s->block_size;
if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)
return -1;
bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];
block_offset = bitmap_offset + s->bitmap_size + offset_in_block;
if (write && (s->last_bitmap_offset != bitmap_offset)) {
uint8_t bitmap[s->bitmap_size];
s->last_bitmap_offset = bitmap_offset;
memset(bitmap, 0xff, s->bitmap_size);
bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
}
return block_offset;
}
| {
"code": [
" bool write)",
" bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);"
],
"line_no": [
3,
53
]
} | static inline int64_t FUNC_0(BlockDriverState *bs, uint64_t offset,
bool write)
{
BDRVVPCState *s = bs->opaque;
uint64_t bitmap_offset, block_offset;
uint32_t pagetable_index, offset_in_block;
pagetable_index = offset / s->block_size;
offset_in_block = offset % s->block_size;
if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)
return -1;
bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];
block_offset = bitmap_offset + s->bitmap_size + offset_in_block;
if (write && (s->last_bitmap_offset != bitmap_offset)) {
uint8_t bitmap[s->bitmap_size];
s->last_bitmap_offset = bitmap_offset;
memset(bitmap, 0xff, s->bitmap_size);
bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);
}
return block_offset;
}
| [
"static inline int64_t FUNC_0(BlockDriverState *bs, uint64_t offset,\nbool write)\n{",
"BDRVVPCState *s = bs->opaque;",
"uint64_t bitmap_offset, block_offset;",
"uint32_t pagetable_index, offset_in_block;",
"pagetable_index = offset / s->block_size;",
"offset_in_block = offset % s->block_size;",
"if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff)\nreturn -1;",
"bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index];",
"block_offset = bitmap_offset + s->bitmap_size + offset_in_block;",
"if (write && (s->last_bitmap_offset != bitmap_offset)) {",
"uint8_t bitmap[s->bitmap_size];",
"s->last_bitmap_offset = bitmap_offset;",
"memset(bitmap, 0xff, s->bitmap_size);",
"bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size);",
"}",
"return block_offset;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
25,338 | static void openpic_tmr_write(void *opaque, hwaddr addr, uint64_t val,
unsigned len)
{
OpenPICState *opp = opaque;
int idx;
DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val);
if (addr & 0xF)
return;
idx = (addr >> 6) & 0x3;
addr = addr & 0x30;
if (addr == 0x0) {
/* TIFR (TFRR) */
opp->tifr = val;
return;
}
switch (addr & 0x30) {
case 0x00: /* TICC (GTCCR) */
break;
case 0x10: /* TIBC (GTBCR) */
if ((opp->timers[idx].ticc & TICC_TOG) != 0 &&
(val & TIBC_CI) == 0 &&
(opp->timers[idx].tibc & TIBC_CI) != 0) {
opp->timers[idx].ticc &= ~TICC_TOG;
}
opp->timers[idx].tibc = val;
break;
case 0x20: /* TIVP (GTIVPR) */
write_IRQreg_ipvp(opp, opp->irq_tim0 + idx, val);
break;
case 0x30: /* TIDE (GTIDR) */
write_IRQreg_ide(opp, opp->irq_tim0 + idx, val);
break;
}
}
| true | qemu | af7e9e74c6a62a5bcd911726a9e88d28b61490e0 | static void openpic_tmr_write(void *opaque, hwaddr addr, uint64_t val,
unsigned len)
{
OpenPICState *opp = opaque;
int idx;
DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val);
if (addr & 0xF)
return;
idx = (addr >> 6) & 0x3;
addr = addr & 0x30;
if (addr == 0x0) {
opp->tifr = val;
return;
}
switch (addr & 0x30) {
case 0x00:
break;
case 0x10:
if ((opp->timers[idx].ticc & TICC_TOG) != 0 &&
(val & TIBC_CI) == 0 &&
(opp->timers[idx].tibc & TIBC_CI) != 0) {
opp->timers[idx].ticc &= ~TICC_TOG;
}
opp->timers[idx].tibc = val;
break;
case 0x20:
write_IRQreg_ipvp(opp, opp->irq_tim0 + idx, val);
break;
case 0x30:
write_IRQreg_ide(opp, opp->irq_tim0 + idx, val);
break;
}
}
| {
"code": [
" if (addr & 0xF)",
" if (addr & 0xF)",
" if (addr & 0xF)",
" if (addr & 0xF)",
" if (addr & 0xF)",
" if (addr & 0xF)",
" if (addr & 0xF)"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15
]
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,
unsigned VAR_3)
{
OpenPICState *opp = VAR_0;
int VAR_4;
DPRINTF("%s: VAR_1 %08x <= %08x\n", __func__, VAR_1, VAR_2);
if (VAR_1 & 0xF)
return;
VAR_4 = (VAR_1 >> 6) & 0x3;
VAR_1 = VAR_1 & 0x30;
if (VAR_1 == 0x0) {
opp->tifr = VAR_2;
return;
}
switch (VAR_1 & 0x30) {
case 0x00:
break;
case 0x10:
if ((opp->timers[VAR_4].ticc & TICC_TOG) != 0 &&
(VAR_2 & TIBC_CI) == 0 &&
(opp->timers[VAR_4].tibc & TIBC_CI) != 0) {
opp->timers[VAR_4].ticc &= ~TICC_TOG;
}
opp->timers[VAR_4].tibc = VAR_2;
break;
case 0x20:
write_IRQreg_ipvp(opp, opp->irq_tim0 + VAR_4, VAR_2);
break;
case 0x30:
write_IRQreg_ide(opp, opp->irq_tim0 + VAR_4, VAR_2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{",
"OpenPICState *opp = VAR_0;",
"int VAR_4;",
"DPRINTF(\"%s: VAR_1 %08x <= %08x\\n\", __func__, VAR_1, VAR_2);",
"if (VAR_1 & 0xF)\nreturn;",
"VAR_4 = (VAR_1 >> 6) & 0x3;",
"VAR_1 = VAR_1 & 0x30;",
"if (VAR_1 == 0x0) {",
"opp->tifr = VAR_2;",
"return;",
"}",
"switch (VAR_1 & 0x30) {",
"case 0x00:\nbreak;",
"case 0x10:\nif ((opp->timers[VAR_4].ticc & TICC_TOG) != 0 &&\n(VAR_2 & TIBC_CI) == 0 &&\n(opp->timers[VAR_4].tibc & TIBC_CI) != 0) {",
"opp->timers[VAR_4].ticc &= ~TICC_TOG;",
"}",
"opp->timers[VAR_4].tibc = VAR_2;",
"break;",
"case 0x20:\nwrite_IRQreg_ipvp(opp, opp->irq_tim0 + VAR_4, VAR_2);",
"break;",
"case 0x30:\nwrite_IRQreg_ide(opp, opp->irq_tim0 + VAR_4, VAR_2);",
"break;",
"}",
"}"
] | [
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
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43,
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
]
] |
25,339 | int load_vmstate(const char *name, Error **errp)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
AioContext *aio_context;
MigrationIncomingState *mis = migration_incoming_get_current();
if (!bdrv_all_can_snapshot(&bs)) {
error_setg(errp,
"Device '%s' is writable but does not support snapshots",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
ret = bdrv_all_find_snapshot(name, &bs);
if (ret < 0) {
error_setg(errp,
"Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), name);
return ret;
}
bs_vm_state = bdrv_all_find_vmstate_bs();
if (!bs_vm_state) {
error_setg(errp, "No block device supports snapshots");
return -ENOTSUP;
}
aio_context = bdrv_get_aio_context(bs_vm_state);
/* Don't even try to load empty VM states */
aio_context_acquire(aio_context);
ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
aio_context_release(aio_context);
if (ret < 0) {
return ret;
} else if (sn.vm_state_size == 0) {
error_setg(errp, "This is a disk-only snapshot. Revert to it "
" offline using qemu-img");
return -EINVAL;
}
/* Flush all IO requests so they don't interfere with the new state. */
bdrv_drain_all();
ret = bdrv_all_goto_snapshot(name, &bs);
if (ret < 0) {
error_setg(errp, "Error %d while activating snapshot '%s' on '%s'",
ret, name, bdrv_get_device_name(bs));
return ret;
}
/* restore the VM state */
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_setg(errp, "Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
mis->from_src_file = f;
aio_context_acquire(aio_context);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
aio_context_release(aio_context);
migration_incoming_state_destroy();
if (ret < 0) {
error_setg(errp, "Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| true | qemu | aedbe19297907143f17b733a7ff0e0534377bed1 | int load_vmstate(const char *name, Error **errp)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
AioContext *aio_context;
MigrationIncomingState *mis = migration_incoming_get_current();
if (!bdrv_all_can_snapshot(&bs)) {
error_setg(errp,
"Device '%s' is writable but does not support snapshots",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
ret = bdrv_all_find_snapshot(name, &bs);
if (ret < 0) {
error_setg(errp,
"Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), name);
return ret;
}
bs_vm_state = bdrv_all_find_vmstate_bs();
if (!bs_vm_state) {
error_setg(errp, "No block device supports snapshots");
return -ENOTSUP;
}
aio_context = bdrv_get_aio_context(bs_vm_state);
aio_context_acquire(aio_context);
ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
aio_context_release(aio_context);
if (ret < 0) {
return ret;
} else if (sn.vm_state_size == 0) {
error_setg(errp, "This is a disk-only snapshot. Revert to it "
" offline using qemu-img");
return -EINVAL;
}
bdrv_drain_all();
ret = bdrv_all_goto_snapshot(name, &bs);
if (ret < 0) {
error_setg(errp, "Error %d while activating snapshot '%s' on '%s'",
ret, name, bdrv_get_device_name(bs));
return ret;
}
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_setg(errp, "Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
mis->from_src_file = f;
aio_context_acquire(aio_context);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
aio_context_release(aio_context);
migration_incoming_state_destroy();
if (ret < 0) {
error_setg(errp, "Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| {
"code": [
" qemu_system_reset(VMRESET_SILENT);",
" qemu_system_reset(VMRESET_SILENT);"
],
"line_no": [
119,
119
]
} | int FUNC_0(const char *VAR_0, Error **VAR_1)
{
BlockDriverState *bs, *bs_vm_state;
QEMUSnapshotInfo sn;
QEMUFile *f;
int VAR_2;
AioContext *aio_context;
MigrationIncomingState *mis = migration_incoming_get_current();
if (!bdrv_all_can_snapshot(&bs)) {
error_setg(VAR_1,
"Device '%s' is writable but does not support snapshots",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
VAR_2 = bdrv_all_find_snapshot(VAR_0, &bs);
if (VAR_2 < 0) {
error_setg(VAR_1,
"Device '%s' does not have the requested snapshot '%s'",
bdrv_get_device_name(bs), VAR_0);
return VAR_2;
}
bs_vm_state = bdrv_all_find_vmstate_bs();
if (!bs_vm_state) {
error_setg(VAR_1, "No block device supports snapshots");
return -ENOTSUP;
}
aio_context = bdrv_get_aio_context(bs_vm_state);
aio_context_acquire(aio_context);
VAR_2 = bdrv_snapshot_find(bs_vm_state, &sn, VAR_0);
aio_context_release(aio_context);
if (VAR_2 < 0) {
return VAR_2;
} else if (sn.vm_state_size == 0) {
error_setg(VAR_1, "This is a disk-only snapshot. Revert to it "
" offline using qemu-img");
return -EINVAL;
}
bdrv_drain_all();
VAR_2 = bdrv_all_goto_snapshot(VAR_0, &bs);
if (VAR_2 < 0) {
error_setg(VAR_1, "Error %d while activating snapshot '%s' on '%s'",
VAR_2, VAR_0, bdrv_get_device_name(bs));
return VAR_2;
}
f = qemu_fopen_bdrv(bs_vm_state, 0);
if (!f) {
error_setg(VAR_1, "Could not open VM state file");
return -EINVAL;
}
qemu_system_reset(VMRESET_SILENT);
mis->from_src_file = f;
aio_context_acquire(aio_context);
VAR_2 = qemu_loadvm_state(f);
qemu_fclose(f);
aio_context_release(aio_context);
migration_incoming_state_destroy();
if (VAR_2 < 0) {
error_setg(VAR_1, "Error %d while loading VM state", VAR_2);
return VAR_2;
}
return 0;
}
| [
"int FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"BlockDriverState *bs, *bs_vm_state;",
"QEMUSnapshotInfo sn;",
"QEMUFile *f;",
"int VAR_2;",
"AioContext *aio_context;",
"MigrationIncomingState *mis = migration_incoming_get_current();",
"if (!bdrv_all_can_snapshot(&bs)) {",
"error_setg(VAR_1,\n\"Device '%s' is writable but does not support snapshots\",\nbdrv_get_device_name(bs));",
"return -ENOTSUP;",
"}",
"VAR_2 = bdrv_all_find_snapshot(VAR_0, &bs);",
"if (VAR_2 < 0) {",
"error_setg(VAR_1,\n\"Device '%s' does not have the requested snapshot '%s'\",\nbdrv_get_device_name(bs), VAR_0);",
"return VAR_2;",
"}",
"bs_vm_state = bdrv_all_find_vmstate_bs();",
"if (!bs_vm_state) {",
"error_setg(VAR_1, \"No block device supports snapshots\");",
"return -ENOTSUP;",
"}",
"aio_context = bdrv_get_aio_context(bs_vm_state);",
"aio_context_acquire(aio_context);",
"VAR_2 = bdrv_snapshot_find(bs_vm_state, &sn, VAR_0);",
"aio_context_release(aio_context);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"} else if (sn.vm_state_size == 0) {",
"error_setg(VAR_1, \"This is a disk-only snapshot. Revert to it \"\n\" offline using qemu-img\");",
"return -EINVAL;",
"}",
"bdrv_drain_all();",
"VAR_2 = bdrv_all_goto_snapshot(VAR_0, &bs);",
"if (VAR_2 < 0) {",
"error_setg(VAR_1, \"Error %d while activating snapshot '%s' on '%s'\",\nVAR_2, VAR_0, bdrv_get_device_name(bs));",
"return VAR_2;",
"}",
"f = qemu_fopen_bdrv(bs_vm_state, 0);",
"if (!f) {",
"error_setg(VAR_1, \"Could not open VM state file\");",
"return -EINVAL;",
"}",
"qemu_system_reset(VMRESET_SILENT);",
"mis->from_src_file = f;",
"aio_context_acquire(aio_context);",
"VAR_2 = qemu_loadvm_state(f);",
"qemu_fclose(f);",
"aio_context_release(aio_context);",
"migration_incoming_state_destroy();",
"if (VAR_2 < 0) {",
"error_setg(VAR_1, \"Error %d while loading VM state\", VAR_2);",
"return VAR_2;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
87
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
]
] |
25,340 | CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s),
Error **errp)
{
CharDriver *cd;
CharDriverState *chr;
GSList *i;
if (qemu_opts_id(opts) == NULL) {
error_setg(errp, "chardev: no id specified");
goto err;
}
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
for (i = backends; i; i = i->next) {
cd = i->data;
if (strcmp(cd->name, qemu_opt_get(opts, "backend")) == 0) {
break;
}
}
if (i == NULL) {
error_setg(errp, "chardev: backend \"%s\" not found",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!cd->open) {
/* using new, qapi init */
ChardevBackend *backend = g_new0(ChardevBackend, 1);
ChardevReturn *ret = NULL;
const char *id = qemu_opts_id(opts);
const char *bid = NULL;
if (qemu_opt_get_bool(opts, "mux", 0)) {
bid = g_strdup_printf("%s-base", id);
}
chr = NULL;
backend->kind = cd->kind;
if (cd->parse) {
cd->parse(opts, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
ret = qmp_chardev_add(bid ? bid : id, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
if (bid) {
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
backend = g_new0(ChardevBackend, 1);
backend->mux = g_new0(ChardevMux, 1);
backend->kind = CHARDEV_BACKEND_KIND_MUX;
backend->mux->chardev = g_strdup(bid);
ret = qmp_chardev_add(id, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
chr = qemu_chr_find(id);
qapi_out:
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
return chr;
}
chr = cd->open(opts);
if (!chr) {
error_setg(errp, "chardev: opening backend \"%s\" failed",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!chr->filename)
chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
chr->init = init;
/* if we didn't create the chardev via qmp_chardev_add, we
* need to send the OPENED event here
*/
if (!chr->explicit_be_open) {
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
}
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
if (qemu_opt_get_bool(opts, "mux", 0)) {
CharDriverState *base = chr;
int len = strlen(qemu_opts_id(opts)) + 6;
base->label = g_malloc(len);
snprintf(base->label, len, "%s-base", qemu_opts_id(opts));
chr = qemu_chr_open_mux(base);
chr->filename = base->filename;
chr->avail_connections = MAX_MUX;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
} else {
chr->avail_connections = 1;
}
chr->label = g_strdup(qemu_opts_id(opts));
chr->opts = opts;
return chr;
err:
qemu_opts_del(opts);
return NULL;
}
| true | qemu | dc2c4eca89ec5ee7b7a4c2563c991a14a7c5ee84 | CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s),
Error **errp)
{
CharDriver *cd;
CharDriverState *chr;
GSList *i;
if (qemu_opts_id(opts) == NULL) {
error_setg(errp, "chardev: no id specified");
goto err;
}
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
for (i = backends; i; i = i->next) {
cd = i->data;
if (strcmp(cd->name, qemu_opt_get(opts, "backend")) == 0) {
break;
}
}
if (i == NULL) {
error_setg(errp, "chardev: backend \"%s\" not found",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!cd->open) {
ChardevBackend *backend = g_new0(ChardevBackend, 1);
ChardevReturn *ret = NULL;
const char *id = qemu_opts_id(opts);
const char *bid = NULL;
if (qemu_opt_get_bool(opts, "mux", 0)) {
bid = g_strdup_printf("%s-base", id);
}
chr = NULL;
backend->kind = cd->kind;
if (cd->parse) {
cd->parse(opts, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
ret = qmp_chardev_add(bid ? bid : id, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
if (bid) {
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
backend = g_new0(ChardevBackend, 1);
backend->mux = g_new0(ChardevMux, 1);
backend->kind = CHARDEV_BACKEND_KIND_MUX;
backend->mux->chardev = g_strdup(bid);
ret = qmp_chardev_add(id, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
chr = qemu_chr_find(id);
qapi_out:
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
return chr;
}
chr = cd->open(opts);
if (!chr) {
error_setg(errp, "chardev: opening backend \"%s\" failed",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!chr->filename)
chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
chr->init = init;
if (!chr->explicit_be_open) {
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
}
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
if (qemu_opt_get_bool(opts, "mux", 0)) {
CharDriverState *base = chr;
int len = strlen(qemu_opts_id(opts)) + 6;
base->label = g_malloc(len);
snprintf(base->label, len, "%s-base", qemu_opts_id(opts));
chr = qemu_chr_open_mux(base);
chr->filename = base->filename;
chr->avail_connections = MAX_MUX;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
} else {
chr->avail_connections = 1;
}
chr->label = g_strdup(qemu_opts_id(opts));
chr->opts = opts;
return chr;
err:
qemu_opts_del(opts);
return NULL;
}
| {
"code": [
" const char *bid = NULL;",
" if (error_is_set(errp)) {",
" goto qapi_out;"
],
"line_no": [
73,
93,
95
]
} | CharDriverState *FUNC_0(QemuOpts *opts,
void (*init)(struct CharDriverState *s),
Error **errp)
{
CharDriver *cd;
CharDriverState *chr;
GSList *i;
if (qemu_opts_id(opts) == NULL) {
error_setg(errp, "chardev: no VAR_0 specified");
goto err;
}
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
for (i = backends; i; i = i->next) {
cd = i->data;
if (strcmp(cd->name, qemu_opt_get(opts, "backend")) == 0) {
break;
}
}
if (i == NULL) {
error_setg(errp, "chardev: backend \"%s\" not found",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!cd->open) {
ChardevBackend *backend = g_new0(ChardevBackend, 1);
ChardevReturn *ret = NULL;
const char *VAR_0 = qemu_opts_id(opts);
const char *VAR_1 = NULL;
if (qemu_opt_get_bool(opts, "mux", 0)) {
VAR_1 = g_strdup_printf("%s-base", VAR_0);
}
chr = NULL;
backend->kind = cd->kind;
if (cd->parse) {
cd->parse(opts, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
ret = qmp_chardev_add(VAR_1 ? VAR_1 : VAR_0, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
if (VAR_1) {
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
backend = g_new0(ChardevBackend, 1);
backend->mux = g_new0(ChardevMux, 1);
backend->kind = CHARDEV_BACKEND_KIND_MUX;
backend->mux->chardev = g_strdup(VAR_1);
ret = qmp_chardev_add(VAR_0, backend, errp);
if (error_is_set(errp)) {
goto qapi_out;
}
}
chr = qemu_chr_find(VAR_0);
qapi_out:
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
return chr;
}
chr = cd->open(opts);
if (!chr) {
error_setg(errp, "chardev: opening backend \"%s\" failed",
qemu_opt_get(opts, "backend"));
goto err;
}
if (!chr->filename)
chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
chr->init = init;
if (!chr->explicit_be_open) {
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
}
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
if (qemu_opt_get_bool(opts, "mux", 0)) {
CharDriverState *base = chr;
int VAR_2 = strlen(qemu_opts_id(opts)) + 6;
base->label = g_malloc(VAR_2);
snprintf(base->label, VAR_2, "%s-base", qemu_opts_id(opts));
chr = qemu_chr_open_mux(base);
chr->filename = base->filename;
chr->avail_connections = MAX_MUX;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
} else {
chr->avail_connections = 1;
}
chr->label = g_strdup(qemu_opts_id(opts));
chr->opts = opts;
return chr;
err:
qemu_opts_del(opts);
return NULL;
}
| [
"CharDriverState *FUNC_0(QemuOpts *opts,\nvoid (*init)(struct CharDriverState *s),\nError **errp)\n{",
"CharDriver *cd;",
"CharDriverState *chr;",
"GSList *i;",
"if (qemu_opts_id(opts) == NULL) {",
"error_setg(errp, \"chardev: no VAR_0 specified\");",
"goto err;",
"}",
"if (qemu_opt_get(opts, \"backend\") == NULL) {",
"error_setg(errp, \"chardev: \\\"%s\\\" missing backend\",\nqemu_opts_id(opts));",
"goto err;",
"}",
"for (i = backends; i; i = i->next) {",
"cd = i->data;",
"if (strcmp(cd->name, qemu_opt_get(opts, \"backend\")) == 0) {",
"break;",
"}",
"}",
"if (i == NULL) {",
"error_setg(errp, \"chardev: backend \\\"%s\\\" not found\",\nqemu_opt_get(opts, \"backend\"));",
"goto err;",
"}",
"if (!cd->open) {",
"ChardevBackend *backend = g_new0(ChardevBackend, 1);",
"ChardevReturn *ret = NULL;",
"const char *VAR_0 = qemu_opts_id(opts);",
"const char *VAR_1 = NULL;",
"if (qemu_opt_get_bool(opts, \"mux\", 0)) {",
"VAR_1 = g_strdup_printf(\"%s-base\", VAR_0);",
"}",
"chr = NULL;",
"backend->kind = cd->kind;",
"if (cd->parse) {",
"cd->parse(opts, backend, errp);",
"if (error_is_set(errp)) {",
"goto qapi_out;",
"}",
"}",
"ret = qmp_chardev_add(VAR_1 ? VAR_1 : VAR_0, backend, errp);",
"if (error_is_set(errp)) {",
"goto qapi_out;",
"}",
"if (VAR_1) {",
"qapi_free_ChardevBackend(backend);",
"qapi_free_ChardevReturn(ret);",
"backend = g_new0(ChardevBackend, 1);",
"backend->mux = g_new0(ChardevMux, 1);",
"backend->kind = CHARDEV_BACKEND_KIND_MUX;",
"backend->mux->chardev = g_strdup(VAR_1);",
"ret = qmp_chardev_add(VAR_0, backend, errp);",
"if (error_is_set(errp)) {",
"goto qapi_out;",
"}",
"}",
"chr = qemu_chr_find(VAR_0);",
"qapi_out:\nqapi_free_ChardevBackend(backend);",
"qapi_free_ChardevReturn(ret);",
"return chr;",
"}",
"chr = cd->open(opts);",
"if (!chr) {",
"error_setg(errp, \"chardev: opening backend \\\"%s\\\" failed\",\nqemu_opt_get(opts, \"backend\"));",
"goto err;",
"}",
"if (!chr->filename)\nchr->filename = g_strdup(qemu_opt_get(opts, \"backend\"));",
"chr->init = init;",
"if (!chr->explicit_be_open) {",
"qemu_chr_be_event(chr, CHR_EVENT_OPENED);",
"}",
"QTAILQ_INSERT_TAIL(&chardevs, chr, next);",
"if (qemu_opt_get_bool(opts, \"mux\", 0)) {",
"CharDriverState *base = chr;",
"int VAR_2 = strlen(qemu_opts_id(opts)) + 6;",
"base->label = g_malloc(VAR_2);",
"snprintf(base->label, VAR_2, \"%s-base\", qemu_opts_id(opts));",
"chr = qemu_chr_open_mux(base);",
"chr->filename = base->filename;",
"chr->avail_connections = MAX_MUX;",
"QTAILQ_INSERT_TAIL(&chardevs, chr, next);",
"} else {",
"chr->avail_connections = 1;",
"}",
"chr->label = g_strdup(qemu_opts_id(opts));",
"chr->opts = opts;",
"return chr;",
"err:\nqemu_opts_del(opts);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
167,
169
],
[
171
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221,
223
],
[
225
],
[
227
]
] |
25,341 | void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y)
{
MotionEstContext * const c= &s->me;
uint8_t *pix, *ppix;
int sum, mx, my, dmin;
int varc; ///< the variance of the block (sum of squared (p[y][x]-average))
int vard; ///< sum of squared differences with the estimated motion vector
int P[10][2];
const int shift= 1+s->quarter_sample;
int mb_type=0;
Picture * const pic= &s->current_picture;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
assert(s->quarter_sample==0 || s->quarter_sample==1);
assert(s->linesize == c->stride);
assert(s->uvlinesize == c->uvstride);
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
get_limits(s, 16*mb_x, 16*mb_y);
c->skip=0;
/* intra / predictive decision */
pix = c->src[0][0];
sum = s->dsp.pix_sum(pix, s->linesize);
varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500;
pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
c->mb_var_sum_temp += (varc+128)>>8;
if(c->avctx->me_threshold){
vard= check_input_motion(s, mb_x, mb_y, 1);
if((vard+128)>>8 < c->avctx->me_threshold){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
c->mc_mb_var_sum_temp += (vard+128)>>8;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
return;
}
if((vard+128)>>8 < c->avctx->mb_threshold)
mb_type= s->mb_type[mb_x + mb_y*s->mb_stride];
}
switch(s->me_method) {
case ME_ZERO:
default:
no_motion_search(s, &mx, &my);
mx-= mb_x*16;
my-= mb_y*16;
dmin = 0;
break;
case ME_X1:
case ME_EPZS:
{
const int mot_stride = s->b8_stride;
const int mot_xy = s->block_index[0];
P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0];
P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1];
if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift);
if(!s->first_slice_line) {
P_TOP[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][0];
P_TOP[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][0];
P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][1];
if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift);
if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
if(s->out_format == FMT_H263){
c->pred_x = P_MEDIAN[0];
c->pred_y = P_MEDIAN[1];
}else { /* mpeg1 at least */
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}else{
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);
break;
}
/* At this point (mx,my) are full-pell and the relative displacement */
ppix = c->ref[0][0] + (my * s->linesize) + mx;
vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16);
pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin;
c->mc_mb_var_sum_temp += (vard+128)>>8;
if(mb_type){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
if(mb_type == CANDIDATE_MB_TYPE_INTER){
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
set_p_mv_tables(s, mx, my, 1);
}else{
mx <<=shift;
my <<=shift;
}
if(mb_type == CANDIDATE_MB_TYPE_INTER4V){
h263_mv4_search(s, mx, my, shift);
set_p_mv_tables(s, mx, my, 0);
}
if(mb_type == CANDIDATE_MB_TYPE_INTER_I){
interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1);
}
}else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
if (vard*2 + 200*256 > varc)
mb_type|= CANDIDATE_MB_TYPE_INTRA;
if (varc*2 + 200*256 > vard || s->qscale > 24){
// if (varc*2 + 200*256 + 50*(s->lambda2>>FF_LAMBDA_SHIFT) > vard){
mb_type|= CANDIDATE_MB_TYPE_INTER;
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
if(s->flags&CODEC_FLAG_MV0)
if(mx || my)
mb_type |= CANDIDATE_MB_TYPE_SKIPPED; //FIXME check difference
}else{
mx <<=shift;
my <<=shift;
}
if((s->flags&CODEC_FLAG_4MV)
&& !c->skip && varc>50<<8 && vard>10<<8){
if(h263_mv4_search(s, mx, my, shift) < INT_MAX)
mb_type|=CANDIDATE_MB_TYPE_INTER4V;
set_p_mv_tables(s, mx, my, 0);
}else
set_p_mv_tables(s, mx, my, 1);
if((s->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){ //FIXME varc/d checks
if(interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0) < INT_MAX)
mb_type |= CANDIDATE_MB_TYPE_INTER_I;
}
}else{
int intra_score, i;
mb_type= CANDIDATE_MB_TYPE_INTER;
dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
if((s->flags&CODEC_FLAG_4MV)
&& !c->skip && varc>50<<8 && vard>10<<8){
int dmin4= h263_mv4_search(s, mx, my, shift);
if(dmin4 < dmin){
mb_type= CANDIDATE_MB_TYPE_INTER4V;
dmin=dmin4;
}
}
if((s->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){ //FIXME varc/d checks
int dmin_i= interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0);
if(dmin_i < dmin){
mb_type = CANDIDATE_MB_TYPE_INTER_I;
dmin= dmin_i;
}
}
// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin;
set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V);
/* get intra luma score */
if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
intra_score= varc - 500;
}else{
int mean= (sum+128)>>8;
mean*= 0x01010101;
for(i=0; i<16; i++){
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 0]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 4]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 8]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+12]) = mean;
}
intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16);
}
intra_score += c->mb_penalty_factor*16;
if(intra_score < dmin){
mb_type= CANDIDATE_MB_TYPE_INTRA;
s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup
}else
s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = 0;
{
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
}
}
s->mb_type[mb_y*s->mb_stride + mb_x]= mb_type;
}
| true | FFmpeg | e708afd3c026a9eb547dab07781320a7e2564312 | void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y)
{
MotionEstContext * const c= &s->me;
uint8_t *pix, *ppix;
int sum, mx, my, dmin;
int varc;
int vard;
int P[10][2];
const int shift= 1+s->quarter_sample;
int mb_type=0;
Picture * const pic= &s->current_picture;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
assert(s->quarter_sample==0 || s->quarter_sample==1);
assert(s->linesize == c->stride);
assert(s->uvlinesize == c->uvstride);
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
get_limits(s, 16*mb_x, 16*mb_y);
c->skip=0;
pix = c->src[0][0];
sum = s->dsp.pix_sum(pix, s->linesize);
varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500;
pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
c->mb_var_sum_temp += (varc+128)>>8;
if(c->avctx->me_threshold){
vard= check_input_motion(s, mb_x, mb_y, 1);
if((vard+128)>>8 < c->avctx->me_threshold){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
c->mc_mb_var_sum_temp += (vard+128)>>8;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
return;
}
if((vard+128)>>8 < c->avctx->mb_threshold)
mb_type= s->mb_type[mb_x + mb_y*s->mb_stride];
}
switch(s->me_method) {
case ME_ZERO:
default:
no_motion_search(s, &mx, &my);
mx-= mb_x*16;
my-= mb_y*16;
dmin = 0;
break;
case ME_X1:
case ME_EPZS:
{
const int mot_stride = s->b8_stride;
const int mot_xy = s->block_index[0];
P_LEFT[0] = s->current_picture.f.motion_val[0][mot_xy - 1][0];
P_LEFT[1] = s->current_picture.f.motion_val[0][mot_xy - 1][1];
if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift);
if(!s->first_slice_line) {
P_TOP[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][0];
P_TOP[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride ][1];
P_TOPRIGHT[0] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][0];
P_TOPRIGHT[1] = s->current_picture.f.motion_val[0][mot_xy - mot_stride + 2][1];
if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift);
if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
if(s->out_format == FMT_H263){
c->pred_x = P_MEDIAN[0];
c->pred_y = P_MEDIAN[1];
}else {
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}else{
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);
break;
}
ppix = c->ref[0][0] + (my * s->linesize) + mx;
vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16);
pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
c->mc_mb_var_sum_temp += (vard+128)>>8;
if(mb_type){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
if(mb_type == CANDIDATE_MB_TYPE_INTER){
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
set_p_mv_tables(s, mx, my, 1);
}else{
mx <<=shift;
my <<=shift;
}
if(mb_type == CANDIDATE_MB_TYPE_INTER4V){
h263_mv4_search(s, mx, my, shift);
set_p_mv_tables(s, mx, my, 0);
}
if(mb_type == CANDIDATE_MB_TYPE_INTER_I){
interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1);
}
}else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
if (vard*2 + 200*256 > varc)
mb_type|= CANDIDATE_MB_TYPE_INTRA;
if (varc*2 + 200*256 > vard || s->qscale > 24){
mb_type|= CANDIDATE_MB_TYPE_INTER;
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
if(s->flags&CODEC_FLAG_MV0)
if(mx || my)
mb_type |= CANDIDATE_MB_TYPE_SKIPPED;
}else{
mx <<=shift;
my <<=shift;
}
if((s->flags&CODEC_FLAG_4MV)
&& !c->skip && varc>50<<8 && vard>10<<8){
if(h263_mv4_search(s, mx, my, shift) < INT_MAX)
mb_type|=CANDIDATE_MB_TYPE_INTER4V;
set_p_mv_tables(s, mx, my, 0);
}else
set_p_mv_tables(s, mx, my, 1);
if((s->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){
if(interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0) < INT_MAX)
mb_type |= CANDIDATE_MB_TYPE_INTER_I;
}
}else{
int intra_score, i;
mb_type= CANDIDATE_MB_TYPE_INTER;
dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
if((s->flags&CODEC_FLAG_4MV)
&& !c->skip && varc>50<<8 && vard>10<<8){
int dmin4= h263_mv4_search(s, mx, my, shift);
if(dmin4 < dmin){
mb_type= CANDIDATE_MB_TYPE_INTER4V;
dmin=dmin4;
}
}
if((s->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){
int dmin_i= interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0);
if(dmin_i < dmin){
mb_type = CANDIDATE_MB_TYPE_INTER_I;
dmin= dmin_i;
}
}
set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V);
if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
intra_score= varc - 500;
}else{
int mean= (sum+128)>>8;
mean*= 0x01010101;
for(i=0; i<16; i++){
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 0]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 4]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+ 8]) = mean;
*(uint32_t*)(&c->scratchpad[i*s->linesize+12]) = mean;
}
intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16);
}
intra_score += c->mb_penalty_factor*16;
if(intra_score < dmin){
mb_type= CANDIDATE_MB_TYPE_INTRA;
s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = CANDIDATE_MB_TYPE_INTRA;
}else
s->current_picture.f.mb_type[mb_y*s->mb_stride + mb_x] = 0;
{
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
}
}
s->mb_type[mb_y*s->mb_stride + mb_x]= mb_type;
}
| {
"code": [
" varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500;",
" int mean= (sum+128)>>8;"
],
"line_no": [
61,
385
]
} | void FUNC_0(MpegEncContext * VAR_0,
int VAR_1, int VAR_2)
{
MotionEstContext * const c= &VAR_0->me;
uint8_t *pix, *ppix;
int VAR_3, VAR_4, VAR_5, VAR_6;
int VAR_7;
int VAR_8;
int VAR_9[10][2];
const int VAR_10= 1+VAR_0->quarter_sample;
int VAR_11=0;
Picture * const pic= &VAR_0->current_picture;
init_ref(c, VAR_0->new_picture.f.data, VAR_0->last_picture.f.data, NULL, 16*VAR_1, 16*VAR_2, 0);
assert(VAR_0->quarter_sample==0 || VAR_0->quarter_sample==1);
assert(VAR_0->linesize == c->stride);
assert(VAR_0->uvlinesize == c->uvstride);
c->penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_sub_cmp);
c->mb_penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->mb_cmp);
c->current_mv_penalty= c->mv_penalty[VAR_0->f_code] + MAX_MV;
get_limits(VAR_0, 16*VAR_1, 16*VAR_2);
c->skip=0;
pix = c->src[0][0];
VAR_3 = VAR_0->dsp.pix_sum(pix, VAR_0->linesize);
VAR_7 = VAR_0->dsp.pix_norm1(pix, VAR_0->linesize) - (((unsigned)(VAR_3*VAR_3))>>8) + 500;
pic->mb_mean[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_3+128)>>8;
pic->mb_var [VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_7+128)>>8;
c->mb_var_sum_temp += (VAR_7+128)>>8;
if(c->avctx->me_threshold){
VAR_8= check_input_motion(VAR_0, VAR_1, VAR_2, 1);
if((VAR_8+128)>>8 < c->avctx->me_threshold){
int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);
int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;
pic->mc_mb_var[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_8+128)>>8;
c->mc_mb_var_sum_temp += (VAR_8+128)>>8;
c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);
return;
}
if((VAR_8+128)>>8 < c->avctx->mb_threshold)
VAR_11= VAR_0->VAR_11[VAR_1 + VAR_2*VAR_0->mb_stride];
}
switch(VAR_0->me_method) {
case ME_ZERO:
default:
no_motion_search(VAR_0, &VAR_4, &VAR_5);
VAR_4-= VAR_1*16;
VAR_5-= VAR_2*16;
VAR_6 = 0;
break;
case ME_X1:
case ME_EPZS:
{
const int VAR_14 = VAR_0->b8_stride;
const int VAR_15 = VAR_0->block_index[0];
P_LEFT[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - 1][0];
P_LEFT[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - 1][1];
if(P_LEFT[0] > (c->xmax<<VAR_10)) P_LEFT[0] = (c->xmax<<VAR_10);
if(!VAR_0->first_slice_line) {
P_TOP[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 ][0];
P_TOP[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 ][1];
P_TOPRIGHT[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 + 2][0];
P_TOPRIGHT[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 + 2][1];
if(P_TOP[1] > (c->ymax<<VAR_10)) P_TOP[1] = (c->ymax<<VAR_10);
if(P_TOPRIGHT[0] < (c->xmin<<VAR_10)) P_TOPRIGHT[0]= (c->xmin<<VAR_10);
if(P_TOPRIGHT[1] > (c->ymax<<VAR_10)) P_TOPRIGHT[1]= (c->ymax<<VAR_10);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
if(VAR_0->out_format == FMT_H263){
c->pred_x = P_MEDIAN[0];
c->pred_y = P_MEDIAN[1];
}else {
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}else{
c->pred_x= P_LEFT[0];
c->pred_y= P_LEFT[1];
}
}
VAR_6 = ff_epzs_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_9, 0, 0, VAR_0->p_mv_table, (1<<16)>>VAR_10, 0, 16);
break;
}
ppix = c->ref[0][0] + (VAR_5 * VAR_0->linesize) + VAR_4;
VAR_8 = VAR_0->dsp.sse[0](NULL, pix, ppix, VAR_0->linesize, 16);
pic->mc_mb_var[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_8+128)>>8;
c->mc_mb_var_sum_temp += (VAR_8+128)>>8;
if(VAR_11){
int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);
int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);
if(VAR_11 == CANDIDATE_MB_TYPE_INTER){
c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);
set_p_mv_tables(VAR_0, VAR_4, VAR_5, 1);
}else{
VAR_4 <<=VAR_10;
VAR_5 <<=VAR_10;
}
if(VAR_11 == CANDIDATE_MB_TYPE_INTER4V){
h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10);
set_p_mv_tables(VAR_0, VAR_4, VAR_5, 0);
}
if(VAR_11 == CANDIDATE_MB_TYPE_INTER_I){
interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 1);
}
}else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);
int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);
if (VAR_8*2 + 200*256 > VAR_7)
VAR_11|= CANDIDATE_MB_TYPE_INTRA;
if (VAR_7*2 + 200*256 > VAR_8 || VAR_0->qscale > 24){
VAR_11|= CANDIDATE_MB_TYPE_INTER;
c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);
if(VAR_0->flags&CODEC_FLAG_MV0)
if(VAR_4 || VAR_5)
VAR_11 |= CANDIDATE_MB_TYPE_SKIPPED;
}else{
VAR_4 <<=VAR_10;
VAR_5 <<=VAR_10;
}
if((VAR_0->flags&CODEC_FLAG_4MV)
&& !c->skip && VAR_7>50<<8 && VAR_8>10<<8){
if(h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10) < INT_MAX)
VAR_11|=CANDIDATE_MB_TYPE_INTER4V;
set_p_mv_tables(VAR_0, VAR_4, VAR_5, 0);
}else
set_p_mv_tables(VAR_0, VAR_4, VAR_5, 1);
if((VAR_0->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){
if(interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 0) < INT_MAX)
VAR_11 |= CANDIDATE_MB_TYPE_INTER_I;
}
}else{
int VAR_16, VAR_17;
VAR_11= CANDIDATE_MB_TYPE_INTER;
VAR_6= c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);
if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
VAR_6= ff_get_mb_score(VAR_0, VAR_4, VAR_5, 0, 0, 0, 16, 1);
if((VAR_0->flags&CODEC_FLAG_4MV)
&& !c->skip && VAR_7>50<<8 && VAR_8>10<<8){
int VAR_18= h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10);
if(VAR_18 < VAR_6){
VAR_11= CANDIDATE_MB_TYPE_INTER4V;
VAR_6=VAR_18;
}
}
if((VAR_0->flags&CODEC_FLAG_INTERLACED_ME)
&& !c->skip){
int VAR_19= interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 0);
if(VAR_19 < VAR_6){
VAR_11 = CANDIDATE_MB_TYPE_INTER_I;
VAR_6= VAR_19;
}
}
set_p_mv_tables(VAR_0, VAR_4, VAR_5, VAR_11!=CANDIDATE_MB_TYPE_INTER4V);
if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
VAR_16= VAR_7 - 500;
}else{
int VAR_20= (VAR_3+128)>>8;
VAR_20*= 0x01010101;
for(VAR_17=0; VAR_17<16; VAR_17++){
*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 0]) = VAR_20;
*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 4]) = VAR_20;
*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 8]) = VAR_20;
*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+12]) = VAR_20;
}
VAR_16= VAR_0->dsp.mb_cmp[0](VAR_0, c->scratchpad, pix, VAR_0->linesize, 16);
}
VAR_16 += c->mb_penalty_factor*16;
if(VAR_16 < VAR_6){
VAR_11= CANDIDATE_MB_TYPE_INTRA;
VAR_0->current_picture.f.VAR_11[VAR_2*VAR_0->mb_stride + VAR_1] = CANDIDATE_MB_TYPE_INTRA;
}else
VAR_0->current_picture.f.VAR_11[VAR_2*VAR_0->mb_stride + VAR_1] = 0;
{
int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);
int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);
}
}
VAR_0->VAR_11[VAR_2*VAR_0->mb_stride + VAR_1]= VAR_11;
}
| [
"void FUNC_0(MpegEncContext * VAR_0,\nint VAR_1, int VAR_2)\n{",
"MotionEstContext * const c= &VAR_0->me;",
"uint8_t *pix, *ppix;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"int VAR_7;",
"int VAR_8;",
"int VAR_9[10][2];",
"const int VAR_10= 1+VAR_0->quarter_sample;",
"int VAR_11=0;",
"Picture * const pic= &VAR_0->current_picture;",
"init_ref(c, VAR_0->new_picture.f.data, VAR_0->last_picture.f.data, NULL, 16*VAR_1, 16*VAR_2, 0);",
"assert(VAR_0->quarter_sample==0 || VAR_0->quarter_sample==1);",
"assert(VAR_0->linesize == c->stride);",
"assert(VAR_0->uvlinesize == c->uvstride);",
"c->penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_cmp);",
"c->sub_penalty_factor= get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->me_sub_cmp);",
"c->mb_penalty_factor = get_penalty_factor(VAR_0->lambda, VAR_0->lambda2, c->avctx->mb_cmp);",
"c->current_mv_penalty= c->mv_penalty[VAR_0->f_code] + MAX_MV;",
"get_limits(VAR_0, 16*VAR_1, 16*VAR_2);",
"c->skip=0;",
"pix = c->src[0][0];",
"VAR_3 = VAR_0->dsp.pix_sum(pix, VAR_0->linesize);",
"VAR_7 = VAR_0->dsp.pix_norm1(pix, VAR_0->linesize) - (((unsigned)(VAR_3*VAR_3))>>8) + 500;",
"pic->mb_mean[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_3+128)>>8;",
"pic->mb_var [VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_7+128)>>8;",
"c->mb_var_sum_temp += (VAR_7+128)>>8;",
"if(c->avctx->me_threshold){",
"VAR_8= check_input_motion(VAR_0, VAR_1, VAR_2, 1);",
"if((VAR_8+128)>>8 < c->avctx->me_threshold){",
"int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);",
"int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;",
"pic->mc_mb_var[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_8+128)>>8;",
"c->mc_mb_var_sum_temp += (VAR_8+128)>>8;",
"c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);",
"return;",
"}",
"if((VAR_8+128)>>8 < c->avctx->mb_threshold)\nVAR_11= VAR_0->VAR_11[VAR_1 + VAR_2*VAR_0->mb_stride];",
"}",
"switch(VAR_0->me_method) {",
"case ME_ZERO:\ndefault:\nno_motion_search(VAR_0, &VAR_4, &VAR_5);",
"VAR_4-= VAR_1*16;",
"VAR_5-= VAR_2*16;",
"VAR_6 = 0;",
"break;",
"case ME_X1:\ncase ME_EPZS:\n{",
"const int VAR_14 = VAR_0->b8_stride;",
"const int VAR_15 = VAR_0->block_index[0];",
"P_LEFT[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - 1][0];",
"P_LEFT[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - 1][1];",
"if(P_LEFT[0] > (c->xmax<<VAR_10)) P_LEFT[0] = (c->xmax<<VAR_10);",
"if(!VAR_0->first_slice_line) {",
"P_TOP[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 ][0];",
"P_TOP[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 ][1];",
"P_TOPRIGHT[0] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 + 2][0];",
"P_TOPRIGHT[1] = VAR_0->current_picture.f.motion_val[0][VAR_15 - VAR_14 + 2][1];",
"if(P_TOP[1] > (c->ymax<<VAR_10)) P_TOP[1] = (c->ymax<<VAR_10);",
"if(P_TOPRIGHT[0] < (c->xmin<<VAR_10)) P_TOPRIGHT[0]= (c->xmin<<VAR_10);",
"if(P_TOPRIGHT[1] > (c->ymax<<VAR_10)) P_TOPRIGHT[1]= (c->ymax<<VAR_10);",
"P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);",
"P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);",
"if(VAR_0->out_format == FMT_H263){",
"c->pred_x = P_MEDIAN[0];",
"c->pred_y = P_MEDIAN[1];",
"}else {",
"c->pred_x= P_LEFT[0];",
"c->pred_y= P_LEFT[1];",
"}",
"}else{",
"c->pred_x= P_LEFT[0];",
"c->pred_y= P_LEFT[1];",
"}",
"}",
"VAR_6 = ff_epzs_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_9, 0, 0, VAR_0->p_mv_table, (1<<16)>>VAR_10, 0, 16);",
"break;",
"}",
"ppix = c->ref[0][0] + (VAR_5 * VAR_0->linesize) + VAR_4;",
"VAR_8 = VAR_0->dsp.sse[0](NULL, pix, ppix, VAR_0->linesize, 16);",
"pic->mc_mb_var[VAR_0->mb_stride * VAR_2 + VAR_1] = (VAR_8+128)>>8;",
"c->mc_mb_var_sum_temp += (VAR_8+128)>>8;",
"if(VAR_11){",
"int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);",
"int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;",
"c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);",
"if(VAR_11 == CANDIDATE_MB_TYPE_INTER){",
"c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);",
"set_p_mv_tables(VAR_0, VAR_4, VAR_5, 1);",
"}else{",
"VAR_4 <<=VAR_10;",
"VAR_5 <<=VAR_10;",
"}",
"if(VAR_11 == CANDIDATE_MB_TYPE_INTER4V){",
"h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10);",
"set_p_mv_tables(VAR_0, VAR_4, VAR_5, 0);",
"}",
"if(VAR_11 == CANDIDATE_MB_TYPE_INTER_I){",
"interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 1);",
"}",
"}else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){",
"int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);",
"int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;",
"c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);",
"if (VAR_8*2 + 200*256 > VAR_7)\nVAR_11|= CANDIDATE_MB_TYPE_INTRA;",
"if (VAR_7*2 + 200*256 > VAR_8 || VAR_0->qscale > 24){",
"VAR_11|= CANDIDATE_MB_TYPE_INTER;",
"c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);",
"if(VAR_0->flags&CODEC_FLAG_MV0)\nif(VAR_4 || VAR_5)\nVAR_11 |= CANDIDATE_MB_TYPE_SKIPPED;",
"}else{",
"VAR_4 <<=VAR_10;",
"VAR_5 <<=VAR_10;",
"}",
"if((VAR_0->flags&CODEC_FLAG_4MV)\n&& !c->skip && VAR_7>50<<8 && VAR_8>10<<8){",
"if(h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10) < INT_MAX)\nVAR_11|=CANDIDATE_MB_TYPE_INTER4V;",
"set_p_mv_tables(VAR_0, VAR_4, VAR_5, 0);",
"}else",
"set_p_mv_tables(VAR_0, VAR_4, VAR_5, 1);",
"if((VAR_0->flags&CODEC_FLAG_INTERLACED_ME)\n&& !c->skip){",
"if(interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 0) < INT_MAX)\nVAR_11 |= CANDIDATE_MB_TYPE_INTER_I;",
"}",
"}else{",
"int VAR_16, VAR_17;",
"VAR_11= CANDIDATE_MB_TYPE_INTER;",
"VAR_6= c->sub_motion_search(VAR_0, &VAR_4, &VAR_5, VAR_6, 0, 0, 0, 16);",
"if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)\nVAR_6= ff_get_mb_score(VAR_0, VAR_4, VAR_5, 0, 0, 0, 16, 1);",
"if((VAR_0->flags&CODEC_FLAG_4MV)\n&& !c->skip && VAR_7>50<<8 && VAR_8>10<<8){",
"int VAR_18= h263_mv4_search(VAR_0, VAR_4, VAR_5, VAR_10);",
"if(VAR_18 < VAR_6){",
"VAR_11= CANDIDATE_MB_TYPE_INTER4V;",
"VAR_6=VAR_18;",
"}",
"}",
"if((VAR_0->flags&CODEC_FLAG_INTERLACED_ME)\n&& !c->skip){",
"int VAR_19= interlaced_search(VAR_0, 0, VAR_0->p_field_mv_table, VAR_0->p_field_select_table, VAR_4, VAR_5, 0);",
"if(VAR_19 < VAR_6){",
"VAR_11 = CANDIDATE_MB_TYPE_INTER_I;",
"VAR_6= VAR_19;",
"}",
"}",
"set_p_mv_tables(VAR_0, VAR_4, VAR_5, VAR_11!=CANDIDATE_MB_TYPE_INTER4V);",
"if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){",
"VAR_16= VAR_7 - 500;",
"}else{",
"int VAR_20= (VAR_3+128)>>8;",
"VAR_20*= 0x01010101;",
"for(VAR_17=0; VAR_17<16; VAR_17++){",
"*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 0]) = VAR_20;",
"*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 4]) = VAR_20;",
"*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+ 8]) = VAR_20;",
"*(uint32_t*)(&c->scratchpad[VAR_17*VAR_0->linesize+12]) = VAR_20;",
"}",
"VAR_16= VAR_0->dsp.mb_cmp[0](VAR_0, c->scratchpad, pix, VAR_0->linesize, 16);",
"}",
"VAR_16 += c->mb_penalty_factor*16;",
"if(VAR_16 < VAR_6){",
"VAR_11= CANDIDATE_MB_TYPE_INTRA;",
"VAR_0->current_picture.f.VAR_11[VAR_2*VAR_0->mb_stride + VAR_1] = CANDIDATE_MB_TYPE_INTRA;",
"}else",
"VAR_0->current_picture.f.VAR_11[VAR_2*VAR_0->mb_stride + VAR_1] = 0;",
"{",
"int VAR_21= FFMIN(VAR_8, VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*100);",
"int VAR_21= VAR_7-500+(VAR_0->lambda2>>FF_LAMBDA_SHIFT)*20;",
"c->scene_change_score+= ff_sqrt(VAR_21) - ff_sqrt(VAR_21);",
"}",
"}",
"VAR_0->VAR_11[VAR_2*VAR_0->mb_stride + VAR_1]= VAR_11;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121,
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
195
],
[
197
],
[
203
],
[
207
],
[
211
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269,
271
],
[
273
],
[
277
],
[
279
],
[
281,
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299,
301
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
315,
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
329
],
[
331,
333
],
[
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
373
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
405
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
439
],
[
441
]
] |
25,342 | static int init_directory(BDRVVVFATState* s,const char* dirname)
{
bootsector_t* bootsector=(bootsector_t*)&(s->first_sectors[(s->first_sectors_number-1)*0x200]);
unsigned int i;
unsigned int cluster;
memset(&(s->first_sectors[0]),0,0x40*0x200);
/* TODO: if FAT32, this is probably wrong */
s->sectors_per_fat=0xfc;
s->sectors_per_cluster=0x10;
s->cluster_size=s->sectors_per_cluster*0x200;
s->cluster=malloc(s->cluster_size);
array_init(&(s->mapping),sizeof(mapping_t));
array_init(&(s->directory),sizeof(direntry_t));
array_init(&(s->commit),sizeof(commit_t));
/* add volume label */
{
direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28; /* archive | volume label */
snprintf(entry->name,11,"QEMU VVFAT");
}
if(read_directory(s,dirname,0))
return -1;
/* make sure that the number of directory entries is multiple of 0x200/0x20 (to fit the last sector exactly) */
s->sectors_for_directory=s->directory.next/0x10;
s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2+s->sectors_for_directory;
s->cluster_count=(s->sector_count-s->faked_sectors)/s->sectors_per_cluster;
/* Now build FAT, and write back information into directory */
init_fat(s);
cluster=s->sectors_for_directory/s->sectors_per_cluster;
assert(s->sectors_for_directory%s->sectors_per_cluster==0);
/* set the end of the last read directory */
if(s->first_file_mapping>0) {
mapping_t* mapping=array_get(&(s->mapping),s->first_file_mapping-1);
mapping->end=cluster;
}
for(i=1;i<s->mapping.next;i++) {
mapping_t* mapping=array_get(&(s->mapping),i);
direntry_t* direntry=array_get(&(s->directory),mapping->dir_index);
if(mapping->mode==MODE_DIRECTORY) {
/* directory */
int i;
#ifdef DEBUG
fprintf(stderr,"assert: %s %d < %d\n",mapping->filename,(int)mapping->begin,(int)mapping->end);
#endif
assert(mapping->begin<mapping->end);
for(i=mapping->begin;i<mapping->end-1;i++)
fat_set(s,i,i+1);
fat_set(s,i,0x7fffffff);
} else {
/* as the space is virtual, we can be sloppy about it */
unsigned int end_cluster=cluster+mapping->end/s->cluster_size;
if(end_cluster>=s->cluster_count) {
fprintf(stderr,"Directory does not fit in FAT%d\n",s->fat_type);
return -1;
}
mapping->begin=cluster;
mapping->mode=MODE_NORMAL;
mapping->offset=0;
direntry->size=cpu_to_le32(mapping->end);
if(direntry->size==0) {
direntry->begin=0;
mapping->end=cluster;
continue;
}
direntry->begin=cpu_to_le16(cluster);
mapping->end=end_cluster+1;
for(;cluster<end_cluster;cluster++)
fat_set(s,cluster,cluster+1);
fat_set(s,cluster,0x7fffffff);
cluster++;
}
}
s->current_mapping=0;
bootsector->jump[0]=0xeb;
bootsector->jump[1]=0x3e;
bootsector->jump[2]=0x90;
memcpy(bootsector->name,"QEMU ",8);
bootsector->sector_size=cpu_to_le16(0x200);
bootsector->sectors_per_cluster=s->sectors_per_cluster;
bootsector->reserved_sectors=cpu_to_le16(1);
bootsector->number_of_fats=0x2; /* number of FATs */
bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10);
bootsector->zero=0;
bootsector->media_type=(s->first_sectors_number==1?0xf0:0xf8); /* media descriptor */
bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat);
bootsector->sectors_per_track=cpu_to_le16(0x3f);
bootsector->number_of_heads=cpu_to_le16(0x10);
bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f);
/* TODO: if FAT32, adjust */
bootsector->total_sectors=cpu_to_le32(s->sector_count);
/* TODO: if FAT32, this is wrong */
bootsector->u.fat16.drive_number=0x80; /* assume this is hda (TODO) */
bootsector->u.fat16.current_head=0;
bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11);
memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
return 0;
}
| true | qemu | 0b7a4a97119eefc2c39c5f34602df9e1cc0f493b | static int init_directory(BDRVVVFATState* s,const char* dirname)
{
bootsector_t* bootsector=(bootsector_t*)&(s->first_sectors[(s->first_sectors_number-1)*0x200]);
unsigned int i;
unsigned int cluster;
memset(&(s->first_sectors[0]),0,0x40*0x200);
s->sectors_per_fat=0xfc;
s->sectors_per_cluster=0x10;
s->cluster_size=s->sectors_per_cluster*0x200;
s->cluster=malloc(s->cluster_size);
array_init(&(s->mapping),sizeof(mapping_t));
array_init(&(s->directory),sizeof(direntry_t));
array_init(&(s->commit),sizeof(commit_t));
{
direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28;
snprintf(entry->name,11,"QEMU VVFAT");
}
if(read_directory(s,dirname,0))
return -1;
s->sectors_for_directory=s->directory.next/0x10;
s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2+s->sectors_for_directory;
s->cluster_count=(s->sector_count-s->faked_sectors)/s->sectors_per_cluster;
init_fat(s);
cluster=s->sectors_for_directory/s->sectors_per_cluster;
assert(s->sectors_for_directory%s->sectors_per_cluster==0);
if(s->first_file_mapping>0) {
mapping_t* mapping=array_get(&(s->mapping),s->first_file_mapping-1);
mapping->end=cluster;
}
for(i=1;i<s->mapping.next;i++) {
mapping_t* mapping=array_get(&(s->mapping),i);
direntry_t* direntry=array_get(&(s->directory),mapping->dir_index);
if(mapping->mode==MODE_DIRECTORY) {
int i;
#ifdef DEBUG
fprintf(stderr,"assert: %s %d < %d\n",mapping->filename,(int)mapping->begin,(int)mapping->end);
#endif
assert(mapping->begin<mapping->end);
for(i=mapping->begin;i<mapping->end-1;i++)
fat_set(s,i,i+1);
fat_set(s,i,0x7fffffff);
} else {
unsigned int end_cluster=cluster+mapping->end/s->cluster_size;
if(end_cluster>=s->cluster_count) {
fprintf(stderr,"Directory does not fit in FAT%d\n",s->fat_type);
return -1;
}
mapping->begin=cluster;
mapping->mode=MODE_NORMAL;
mapping->offset=0;
direntry->size=cpu_to_le32(mapping->end);
if(direntry->size==0) {
direntry->begin=0;
mapping->end=cluster;
continue;
}
direntry->begin=cpu_to_le16(cluster);
mapping->end=end_cluster+1;
for(;cluster<end_cluster;cluster++)
fat_set(s,cluster,cluster+1);
fat_set(s,cluster,0x7fffffff);
cluster++;
}
}
s->current_mapping=0;
bootsector->jump[0]=0xeb;
bootsector->jump[1]=0x3e;
bootsector->jump[2]=0x90;
memcpy(bootsector->name,"QEMU ",8);
bootsector->sector_size=cpu_to_le16(0x200);
bootsector->sectors_per_cluster=s->sectors_per_cluster;
bootsector->reserved_sectors=cpu_to_le16(1);
bootsector->number_of_fats=0x2;
bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10);
bootsector->zero=0;
bootsector->media_type=(s->first_sectors_number==1?0xf0:0xf8);
bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat);
bootsector->sectors_per_track=cpu_to_le16(0x3f);
bootsector->number_of_heads=cpu_to_le16(0x10);
bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f);
bootsector->total_sectors=cpu_to_le32(s->sector_count);
bootsector->u.fat16.drive_number=0x80;
bootsector->u.fat16.current_head=0;
bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11);
memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
return 0;
}
| {
"code": [
" s->sectors_per_fat=0xfc;"
],
"line_no": [
19
]
} | static int FUNC_0(BDRVVVFATState* VAR_0,const char* VAR_1)
{
bootsector_t* bootsector=(bootsector_t*)&(VAR_0->first_sectors[(VAR_0->first_sectors_number-1)*0x200]);
unsigned int VAR_2;
unsigned int VAR_3;
memset(&(VAR_0->first_sectors[0]),0,0x40*0x200);
VAR_0->sectors_per_fat=0xfc;
VAR_0->sectors_per_cluster=0x10;
VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200;
VAR_0->VAR_3=malloc(VAR_0->cluster_size);
array_init(&(VAR_0->mapping),sizeof(mapping_t));
array_init(&(VAR_0->directory),sizeof(direntry_t));
array_init(&(VAR_0->commit),sizeof(commit_t));
{
direntry_t* entry=array_get_next(&(VAR_0->directory));
entry->attributes=0x28;
snprintf(entry->name,11,"QEMU VVFAT");
}
if(read_directory(VAR_0,VAR_1,0))
return -1;
VAR_0->sectors_for_directory=VAR_0->directory.next/0x10;
VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2+VAR_0->sectors_for_directory;
VAR_0->cluster_count=(VAR_0->sector_count-VAR_0->faked_sectors)/VAR_0->sectors_per_cluster;
init_fat(VAR_0);
VAR_3=VAR_0->sectors_for_directory/VAR_0->sectors_per_cluster;
assert(VAR_0->sectors_for_directory%VAR_0->sectors_per_cluster==0);
if(VAR_0->first_file_mapping>0) {
mapping_t* mapping=array_get(&(VAR_0->mapping),VAR_0->first_file_mapping-1);
mapping->end=VAR_3;
}
for(VAR_2=1;VAR_2<VAR_0->mapping.next;VAR_2++) {
mapping_t* mapping=array_get(&(VAR_0->mapping),VAR_2);
direntry_t* direntry=array_get(&(VAR_0->directory),mapping->dir_index);
if(mapping->mode==MODE_DIRECTORY) {
int VAR_2;
#ifdef DEBUG
fprintf(stderr,"assert: %VAR_0 %d < %d\n",mapping->filename,(int)mapping->begin,(int)mapping->end);
#endif
assert(mapping->begin<mapping->end);
for(VAR_2=mapping->begin;VAR_2<mapping->end-1;VAR_2++)
fat_set(VAR_0,VAR_2,VAR_2+1);
fat_set(VAR_0,VAR_2,0x7fffffff);
} else {
unsigned int end_cluster=VAR_3+mapping->end/VAR_0->cluster_size;
if(end_cluster>=VAR_0->cluster_count) {
fprintf(stderr,"Directory does not fit in FAT%d\n",VAR_0->fat_type);
return -1;
}
mapping->begin=VAR_3;
mapping->mode=MODE_NORMAL;
mapping->offset=0;
direntry->size=cpu_to_le32(mapping->end);
if(direntry->size==0) {
direntry->begin=0;
mapping->end=VAR_3;
continue;
}
direntry->begin=cpu_to_le16(VAR_3);
mapping->end=end_cluster+1;
for(;VAR_3<end_cluster;VAR_3++)
fat_set(VAR_0,VAR_3,VAR_3+1);
fat_set(VAR_0,VAR_3,0x7fffffff);
VAR_3++;
}
}
VAR_0->current_mapping=0;
bootsector->jump[0]=0xeb;
bootsector->jump[1]=0x3e;
bootsector->jump[2]=0x90;
memcpy(bootsector->name,"QEMU ",8);
bootsector->sector_size=cpu_to_le16(0x200);
bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster;
bootsector->reserved_sectors=cpu_to_le16(1);
bootsector->number_of_fats=0x2;
bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10);
bootsector->zero=0;
bootsector->media_type=(VAR_0->first_sectors_number==1?0xf0:0xf8);
bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat);
bootsector->sectors_per_track=cpu_to_le16(0x3f);
bootsector->number_of_heads=cpu_to_le16(0x10);
bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f);
bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count);
bootsector->u.fat16.drive_number=0x80;
bootsector->u.fat16.current_head=0;
bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11);
memcpy(bootsector->fat_type,(VAR_0->fat_type==12?"FAT12 ":VAR_0->fat_type==16?"FAT16 ":"FAT32 "),8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
return 0;
}
| [
"static int FUNC_0(BDRVVVFATState* VAR_0,const char* VAR_1)\n{",
"bootsector_t* bootsector=(bootsector_t*)&(VAR_0->first_sectors[(VAR_0->first_sectors_number-1)*0x200]);",
"unsigned int VAR_2;",
"unsigned int VAR_3;",
"memset(&(VAR_0->first_sectors[0]),0,0x40*0x200);",
"VAR_0->sectors_per_fat=0xfc;",
"VAR_0->sectors_per_cluster=0x10;",
"VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200;",
"VAR_0->VAR_3=malloc(VAR_0->cluster_size);",
"array_init(&(VAR_0->mapping),sizeof(mapping_t));",
"array_init(&(VAR_0->directory),sizeof(direntry_t));",
"array_init(&(VAR_0->commit),sizeof(commit_t));",
"{",
"direntry_t* entry=array_get_next(&(VAR_0->directory));",
"entry->attributes=0x28;",
"snprintf(entry->name,11,\"QEMU VVFAT\");",
"}",
"if(read_directory(VAR_0,VAR_1,0))\nreturn -1;",
"VAR_0->sectors_for_directory=VAR_0->directory.next/0x10;",
"VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2+VAR_0->sectors_for_directory;",
"VAR_0->cluster_count=(VAR_0->sector_count-VAR_0->faked_sectors)/VAR_0->sectors_per_cluster;",
"init_fat(VAR_0);",
"VAR_3=VAR_0->sectors_for_directory/VAR_0->sectors_per_cluster;",
"assert(VAR_0->sectors_for_directory%VAR_0->sectors_per_cluster==0);",
"if(VAR_0->first_file_mapping>0) {",
"mapping_t* mapping=array_get(&(VAR_0->mapping),VAR_0->first_file_mapping-1);",
"mapping->end=VAR_3;",
"}",
"for(VAR_2=1;VAR_2<VAR_0->mapping.next;VAR_2++) {",
"mapping_t* mapping=array_get(&(VAR_0->mapping),VAR_2);",
"direntry_t* direntry=array_get(&(VAR_0->directory),mapping->dir_index);",
"if(mapping->mode==MODE_DIRECTORY) {",
"int VAR_2;",
"#ifdef DEBUG\nfprintf(stderr,\"assert: %VAR_0 %d < %d\\n\",mapping->filename,(int)mapping->begin,(int)mapping->end);",
"#endif\nassert(mapping->begin<mapping->end);",
"for(VAR_2=mapping->begin;VAR_2<mapping->end-1;VAR_2++)",
"fat_set(VAR_0,VAR_2,VAR_2+1);",
"fat_set(VAR_0,VAR_2,0x7fffffff);",
"} else {",
"unsigned int end_cluster=VAR_3+mapping->end/VAR_0->cluster_size;",
"if(end_cluster>=VAR_0->cluster_count) {",
"fprintf(stderr,\"Directory does not fit in FAT%d\\n\",VAR_0->fat_type);",
"return -1;",
"}",
"mapping->begin=VAR_3;",
"mapping->mode=MODE_NORMAL;",
"mapping->offset=0;",
"direntry->size=cpu_to_le32(mapping->end);",
"if(direntry->size==0) {",
"direntry->begin=0;",
"mapping->end=VAR_3;",
"continue;",
"}",
"direntry->begin=cpu_to_le16(VAR_3);",
"mapping->end=end_cluster+1;",
"for(;VAR_3<end_cluster;VAR_3++)",
"fat_set(VAR_0,VAR_3,VAR_3+1);",
"fat_set(VAR_0,VAR_3,0x7fffffff);",
"VAR_3++;",
"}",
"}",
"VAR_0->current_mapping=0;",
"bootsector->jump[0]=0xeb;",
"bootsector->jump[1]=0x3e;",
"bootsector->jump[2]=0x90;",
"memcpy(bootsector->name,\"QEMU \",8);",
"bootsector->sector_size=cpu_to_le16(0x200);",
"bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster;",
"bootsector->reserved_sectors=cpu_to_le16(1);",
"bootsector->number_of_fats=0x2;",
"bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10);",
"bootsector->zero=0;",
"bootsector->media_type=(VAR_0->first_sectors_number==1?0xf0:0xf8);",
"bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat);",
"bootsector->sectors_per_track=cpu_to_le16(0x3f);",
"bootsector->number_of_heads=cpu_to_le16(0x10);",
"bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f);",
"bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count);",
"bootsector->u.fat16.drive_number=0x80;",
"bootsector->u.fat16.current_head=0;",
"bootsector->u.fat16.signature=0x29;",
"bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);",
"memcpy(bootsector->u.fat16.volume_label,\"QEMU VVFAT \",11);",
"memcpy(bootsector->fat_type,(VAR_0->fat_type==12?\"FAT12 \":VAR_0->fat_type==16?\"FAT16 \":\"FAT32 \"),8);",
"bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
59
],
[
63
],
[
65
],
[
71
],
[
75
],
[
77
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
233
],
[
235
]
] |
25,343 | static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[8], int qp[2] ) {
int i;
for( i = 0; i < 8; i++, pix += stride) {
int index_a;
int alpha;
int beta;
int qp_index;
int bS_index = i;
if( bS[bS_index] == 0 ) {
continue;
}
qp_index = MB_FIELD ? (i >> 2) : (i & 1);
index_a = qp[qp_index] + h->slice_alpha_c0_offset;
alpha = (alpha_table+52)[index_a];
beta = (beta_table+52)[qp[qp_index] + h->slice_beta_offset];
if( bS[bS_index] < 4 ) {
const int tc = (tc0_table+52)[index_a][bS[bS_index]] + 1;
const int p0 = pix[-1];
const int p1 = pix[-2];
const int q0 = pix[0];
const int q1 = pix[1];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
const int i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
const int p1 = pix[-2];
const int q0 = pix[0];
const int q1 = pix[1];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, pix[-3], p1, p0, q0, q1, pix[2], pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
}
| false | FFmpeg | 082cf97106e2e94a969877d4f8c05c1e526acf54 | static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[8], int qp[2] ) {
int i;
for( i = 0; i < 8; i++, pix += stride) {
int index_a;
int alpha;
int beta;
int qp_index;
int bS_index = i;
if( bS[bS_index] == 0 ) {
continue;
}
qp_index = MB_FIELD ? (i >> 2) : (i & 1);
index_a = qp[qp_index] + h->slice_alpha_c0_offset;
alpha = (alpha_table+52)[index_a];
beta = (beta_table+52)[qp[qp_index] + h->slice_beta_offset];
if( bS[bS_index] < 4 ) {
const int tc = (tc0_table+52)[index_a][bS[bS_index]] + 1;
const int p0 = pix[-1];
const int p1 = pix[-2];
const int q0 = pix[0];
const int q1 = pix[1];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
const int i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-1] = av_clip_uint8( p0 + i_delta );
pix[0] = av_clip_uint8( q0 - i_delta );
tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
const int p1 = pix[-2];
const int q0 = pix[0];
const int q1 = pix[1];
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, pix[-3], p1, p0, q0, q1, pix[2], pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[8], int VAR_4[2] ) {
int VAR_5;
for( VAR_5 = 0; VAR_5 < 8; VAR_5++, VAR_1 += VAR_2) {
int VAR_6;
int VAR_7;
int VAR_8;
int VAR_9;
int VAR_10 = VAR_5;
if( VAR_3[VAR_10] == 0 ) {
continue;
}
VAR_9 = MB_FIELD ? (VAR_5 >> 2) : (VAR_5 & 1);
VAR_6 = VAR_4[VAR_9] + VAR_0->slice_alpha_c0_offset;
VAR_7 = (alpha_table+52)[VAR_6];
VAR_8 = (beta_table+52)[VAR_4[VAR_9] + VAR_0->slice_beta_offset];
if( VAR_3[VAR_10] < 4 ) {
const int VAR_11 = (tc0_table+52)[VAR_6][VAR_3[VAR_10]] + 1;
const int VAR_17 = VAR_1[-1];
const int VAR_17 = VAR_1[-2];
const int VAR_17 = VAR_1[0];
const int VAR_17 = VAR_1[1];
if( FFABS( VAR_17 - VAR_17 ) < VAR_7 &&
FFABS( VAR_17 - VAR_17 ) < VAR_8 &&
FFABS( VAR_17 - VAR_17 ) < VAR_8 ) {
const int VAR_16 = av_clip( (((VAR_17 - VAR_17 ) << 2) + (VAR_17 - VAR_17) + 4) >> 3, -VAR_11, VAR_11 );
VAR_1[-1] = av_clip_uint8( VAR_17 + VAR_16 );
VAR_1[0] = av_clip_uint8( VAR_17 - VAR_16 );
tprintf(VAR_0->s.avctx, "FUNC_0 VAR_5:%d, VAR_4:%d, indexA:%d, VAR_7:%d, VAR_8:%d, VAR_11:%d\n# VAR_3:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", VAR_5, VAR_4[VAR_9], VAR_6, VAR_7, VAR_8, VAR_11, VAR_3[VAR_10], VAR_1[-3], VAR_17, VAR_17, VAR_17, VAR_17, VAR_1[2], VAR_17, VAR_1[-1], VAR_1[0], VAR_17);
}
}else{
const int VAR_17 = VAR_1[-1];
const int VAR_17 = VAR_1[-2];
const int VAR_17 = VAR_1[0];
const int VAR_17 = VAR_1[1];
if( FFABS( VAR_17 - VAR_17 ) < VAR_7 &&
FFABS( VAR_17 - VAR_17 ) < VAR_8 &&
FFABS( VAR_17 - VAR_17 ) < VAR_8 ) {
VAR_1[-1] = ( 2*VAR_17 + VAR_17 + VAR_17 + 2 ) >> 2;
VAR_1[0] = ( 2*VAR_17 + VAR_17 + VAR_17 + 2 ) >> 2;
tprintf(VAR_0->s.avctx, "FUNC_0 VAR_5:%d\n# VAR_3:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", VAR_5, VAR_1[-3], VAR_17, VAR_17, VAR_17, VAR_17, VAR_1[2], VAR_1[-3], VAR_1[-2], VAR_1[-1], VAR_1[0], VAR_1[1], VAR_1[2]);
}
}
}
}
| [
"static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int16_t VAR_3[8], int VAR_4[2] ) {",
"int VAR_5;",
"for( VAR_5 = 0; VAR_5 < 8; VAR_5++, VAR_1 += VAR_2) {",
"int VAR_6;",
"int VAR_7;",
"int VAR_8;",
"int VAR_9;",
"int VAR_10 = VAR_5;",
"if( VAR_3[VAR_10] == 0 ) {",
"continue;",
"}",
"VAR_9 = MB_FIELD ? (VAR_5 >> 2) : (VAR_5 & 1);",
"VAR_6 = VAR_4[VAR_9] + VAR_0->slice_alpha_c0_offset;",
"VAR_7 = (alpha_table+52)[VAR_6];",
"VAR_8 = (beta_table+52)[VAR_4[VAR_9] + VAR_0->slice_beta_offset];",
"if( VAR_3[VAR_10] < 4 ) {",
"const int VAR_11 = (tc0_table+52)[VAR_6][VAR_3[VAR_10]] + 1;",
"const int VAR_17 = VAR_1[-1];",
"const int VAR_17 = VAR_1[-2];",
"const int VAR_17 = VAR_1[0];",
"const int VAR_17 = VAR_1[1];",
"if( FFABS( VAR_17 - VAR_17 ) < VAR_7 &&\nFFABS( VAR_17 - VAR_17 ) < VAR_8 &&\nFFABS( VAR_17 - VAR_17 ) < VAR_8 ) {",
"const int VAR_16 = av_clip( (((VAR_17 - VAR_17 ) << 2) + (VAR_17 - VAR_17) + 4) >> 3, -VAR_11, VAR_11 );",
"VAR_1[-1] = av_clip_uint8( VAR_17 + VAR_16 );",
"VAR_1[0] = av_clip_uint8( VAR_17 - VAR_16 );",
"tprintf(VAR_0->s.avctx, \"FUNC_0 VAR_5:%d, VAR_4:%d, indexA:%d, VAR_7:%d, VAR_8:%d, VAR_11:%d\\n# VAR_3:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\\n\", VAR_5, VAR_4[VAR_9], VAR_6, VAR_7, VAR_8, VAR_11, VAR_3[VAR_10], VAR_1[-3], VAR_17, VAR_17, VAR_17, VAR_17, VAR_1[2], VAR_17, VAR_1[-1], VAR_1[0], VAR_17);",
"}",
"}else{",
"const int VAR_17 = VAR_1[-1];",
"const int VAR_17 = VAR_1[-2];",
"const int VAR_17 = VAR_1[0];",
"const int VAR_17 = VAR_1[1];",
"if( FFABS( VAR_17 - VAR_17 ) < VAR_7 &&\nFFABS( VAR_17 - VAR_17 ) < VAR_8 &&\nFFABS( VAR_17 - VAR_17 ) < VAR_8 ) {",
"VAR_1[-1] = ( 2*VAR_17 + VAR_17 + VAR_17 + 2 ) >> 2;",
"VAR_1[0] = ( 2*VAR_17 + VAR_17 + VAR_17 + 2 ) >> 2;",
"tprintf(VAR_0->s.avctx, \"FUNC_0 VAR_5:%d\\n# VAR_3:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\\n\", VAR_5, VAR_1[-3], VAR_17, VAR_17, VAR_17, VAR_17, VAR_1[2], VAR_1[-3], VAR_1[-2], VAR_1[-1], VAR_1[0], VAR_1[1], VAR_1[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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85,
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
]
] |
25,345 | int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
int ret;
AVStream *st;
ff_read_frame_flush(s);
if(flags & AVSEEK_FLAG_BYTE)
return seek_frame_byte(s, stream_index, timestamp, flags);
if(stream_index < 0){
stream_index= av_find_default_stream_index(s);
if(stream_index < 0)
return -1;
st= s->streams[stream_index];
/* timestamp for default must be expressed in AV_TIME_BASE units */
timestamp = av_rescale(timestamp, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);
}
/* first, we try the format specific seek */
if (s->iformat->read_seek)
ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
else
ret = -1;
if (ret >= 0) {
return 0;
}
if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH))
return av_seek_frame_binary(s, stream_index, timestamp, flags);
else if (!(s->iformat->flags & AVFMT_NOGENSEARCH))
return seek_frame_generic(s, stream_index, timestamp, flags);
else
return -1;
}
| false | FFmpeg | 0041cdba98d5b636a8d912352dd3d8ca72bba4ce | int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
int ret;
AVStream *st;
ff_read_frame_flush(s);
if(flags & AVSEEK_FLAG_BYTE)
return seek_frame_byte(s, stream_index, timestamp, flags);
if(stream_index < 0){
stream_index= av_find_default_stream_index(s);
if(stream_index < 0)
return -1;
st= s->streams[stream_index];
timestamp = av_rescale(timestamp, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);
}
if (s->iformat->read_seek)
ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
else
ret = -1;
if (ret >= 0) {
return 0;
}
if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH))
return av_seek_frame_binary(s, stream_index, timestamp, flags);
else if (!(s->iformat->flags & AVFMT_NOGENSEARCH))
return seek_frame_generic(s, stream_index, timestamp, flags);
else
return -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
int VAR_4;
AVStream *st;
ff_read_frame_flush(VAR_0);
if(VAR_3 & AVSEEK_FLAG_BYTE)
return seek_frame_byte(VAR_0, VAR_1, VAR_2, VAR_3);
if(VAR_1 < 0){
VAR_1= av_find_default_stream_index(VAR_0);
if(VAR_1 < 0)
return -1;
st= VAR_0->streams[VAR_1];
VAR_2 = av_rescale(VAR_2, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);
}
if (VAR_0->iformat->read_seek)
VAR_4 = VAR_0->iformat->read_seek(VAR_0, VAR_1, VAR_2, VAR_3);
else
VAR_4 = -1;
if (VAR_4 >= 0) {
return 0;
}
if(VAR_0->iformat->read_timestamp && !(VAR_0->iformat->VAR_3 & AVFMT_NOBINSEARCH))
return av_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3);
else if (!(VAR_0->iformat->VAR_3 & AVFMT_NOGENSEARCH))
return seek_frame_generic(VAR_0, VAR_1, VAR_2, VAR_3);
else
return -1;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"int VAR_4;",
"AVStream *st;",
"ff_read_frame_flush(VAR_0);",
"if(VAR_3 & AVSEEK_FLAG_BYTE)\nreturn seek_frame_byte(VAR_0, VAR_1, VAR_2, VAR_3);",
"if(VAR_1 < 0){",
"VAR_1= av_find_default_stream_index(VAR_0);",
"if(VAR_1 < 0)\nreturn -1;",
"st= VAR_0->streams[VAR_1];",
"VAR_2 = av_rescale(VAR_2, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);",
"}",
"if (VAR_0->iformat->read_seek)\nVAR_4 = VAR_0->iformat->read_seek(VAR_0, VAR_1, VAR_2, VAR_3);",
"else\nVAR_4 = -1;",
"if (VAR_4 >= 0) {",
"return 0;",
"}",
"if(VAR_0->iformat->read_timestamp && !(VAR_0->iformat->VAR_3 & AVFMT_NOBINSEARCH))\nreturn av_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3);",
"else if (!(VAR_0->iformat->VAR_3 & AVFMT_NOGENSEARCH))\nreturn seek_frame_generic(VAR_0, VAR_1, VAR_2, VAR_3);",
"else\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25,
27
],
[
31
],
[
35
],
[
37
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
71
]
] |
25,346 | static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
const char *in, int x1, int y1, int x2, int y2)
{
char c, *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
if (x1 >= 0 && y1 >= 0) {
if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
out += snprintf(out, out_end-out,
"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
else
out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
}
for (; out < out_end && !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
*out++ = *in;
break;
case '{': /* skip all {\xxx} substrings except for {\an%d}
and all microdvd like styles such as {Y:xxx} */
an += sscanf(in, "{\\an%*1u}%c", &c) == 1;
if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) ||
sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) {
in += len - 1;
} else
*out++ = *in;
break;
case '<':
tag_close = in[1] == '/';
if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) {
if ((param = strchr(buffer, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, buffer))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!strcmp(buffer, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
out += snprintf(out, out_end-out,
"%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!strncmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!strncmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(avctx, param));
} else if (!strncmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
out += snprintf(out, out_end-out,
"%s", stack[sptr].param[i]);
}
} else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
out += snprintf(out, out_end-out,
"{\\%c%d}", buffer[0], !tag_close);
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", buffer);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
*out++ = *in;
} else
av_strlcpy(stack[sptr++].tag, buffer,
sizeof(stack[0].tag));
break;
}
}
default:
*out++ = *in;
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
out = FFMIN(out, out_end-3);
while (!strncmp(out-2, "\\N", 2))
out -= 2;
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\r\n");
return in;
}
| false | FFmpeg | b9a07e787bd09036b96370bb87fdf841fe380f9f | static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
const char *in, int x1, int y1, int x2, int y2)
{
char c, *param, buffer[128], tmp[128];
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
SrtStack stack[16];
stack[0].tag[0] = 0;
strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
if (x1 >= 0 && y1 >= 0) {
if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
out += snprintf(out, out_end-out,
"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
else
out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
}
for (; out < out_end && !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
*out++ = *in;
break;
case '{':
an += sscanf(in, "{\\an%*1u}%c", &c) == 1;
if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) ||
sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) {
in += len - 1;
} else
*out++ = *in;
break;
case '<':
tag_close = in[1] == '/';
if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) {
if ((param = strchr(buffer, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, buffer))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!strcmp(buffer, "font")) {
if (tag_close) {
for (i=PARAM_NUMBER-1; i>=0; i--)
if (stack[sptr-1].param[i][0])
for (j=sptr-2; j>=0; j--)
if (stack[j].param[i][0]) {
out += snprintf(out, out_end-out,
"%s", stack[j].param[i]);
break;
}
} else {
while (param) {
if (!strncmp(param, "size=", 5)) {
unsigned font_size;
param += 5 + (param[5] == '"');
if (sscanf(param, "%u", &font_size) == 1) {
snprintf(stack[sptr].param[PARAM_SIZE],
sizeof(stack[0].param[PARAM_SIZE]),
"{\\fs%u}", font_size);
}
} else if (!strncmp(param, "color=", 6)) {
param += 6 + (param[6] == '"');
snprintf(stack[sptr].param[PARAM_COLOR],
sizeof(stack[0].param[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(avctx, param));
} else if (!strncmp(param, "face=", 5)) {
param += 5 + (param[5] == '"');
len = strcspn(param,
param[-1] == '"' ? "\"" :" ");
av_strlcpy(tmp, param,
FFMIN(sizeof(tmp), len+1));
param += len;
snprintf(stack[sptr].param[PARAM_FACE],
sizeof(stack[0].param[PARAM_FACE]),
"{\\fn%s}", tmp);
}
if ((param = strchr(param, ' ')))
param++;
}
for (i=0; i<PARAM_NUMBER; i++)
if (stack[sptr].param[i][0])
out += snprintf(out, out_end-out,
"%s", stack[sptr].param[i]);
}
} else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
out += snprintf(out, out_end-out,
"{\\%c%d}", buffer[0], !tag_close);
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", buffer);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
*out++ = *in;
} else
av_strlcpy(stack[sptr++].tag, buffer,
sizeof(stack[0].tag));
break;
}
}
default:
*out++ = *in;
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
out = FFMIN(out, out_end-3);
while (!strncmp(out-2, "\\N", 2))
out -= 2;
while (out[-1] == ' ')
out--;
out += snprintf(out, out_end-out, "\r\n");
return in;
}
| {
"code": [],
"line_no": []
} | static const char *FUNC_0(AVCodecContext *VAR_0, char *VAR_1, char *VAR_2,
const char *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{
char VAR_8, *VAR_9, VAR_10[128], VAR_11[128];
int VAR_12, VAR_13, VAR_14 = 1, VAR_15 = 1, VAR_16 = 0, VAR_17 = 0;
SrtStack stack[16];
stack[0].tag[0] = 0;
strcpy(stack[0].VAR_9[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].VAR_9[PARAM_COLOR], "{\\VAR_8}");
strcpy(stack[0].VAR_9[PARAM_FACE], "{\\fn}");
if (VAR_4 >= 0 && VAR_5 >= 0) {
if (VAR_6 >= 0 && VAR_7 >= 0 && (VAR_6 != VAR_4 || VAR_7 != VAR_5))
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,
"{\\an1}{\\move(%d,%d,%d,%d)}", VAR_4, VAR_5, VAR_6, VAR_7);
else
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1, "{\\an1}{\\pos(%d,%d)}", VAR_4, VAR_5);
}
for (; VAR_1 < VAR_2 && !VAR_17 && *VAR_3; VAR_3++) {
switch (*VAR_3) {
case '\r':
break;
case '\n':
if (VAR_15) {
VAR_17 = 1;
break;
}
while (VAR_1[-1] == ' ')
VAR_1--;
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1, "\\N");
VAR_15 = 1;
break;
case ' ':
if (!VAR_15)
*VAR_1++ = *VAR_3;
break;
case '{':
VAR_16 += sscanf(VAR_3, "{\\VAR_16%*1u}%VAR_8", &VAR_8) == 1;
if ((VAR_16 != 1 && sscanf(VAR_3, "{\\%*[^}]}%n%VAR_8", &VAR_12, &VAR_8) > 0) ||
sscanf(VAR_3, "{%*1[CcFfoPSsYy]:%*[^}]}%n%VAR_8", &VAR_12, &VAR_8) > 0) {
VAR_3 += VAR_12 - 1;
} else
*VAR_1++ = *VAR_3;
break;
case '<':
VAR_13 = VAR_3[1] == '/';
if (sscanf(VAR_3+VAR_13+1, "%127[^>]>%n%VAR_8", VAR_10, &VAR_12,&VAR_8) >= 2) {
if ((VAR_9 = strchr(VAR_10, ' ')))
*VAR_9++ = 0;
if ((!VAR_13 && VAR_14 < FF_ARRAY_ELEMS(stack)) ||
( VAR_13 && VAR_14 > 0 && !strcmp(stack[VAR_14-1].tag, VAR_10))) {
int VAR_18, VAR_19, VAR_20 = 0;
VAR_3 += VAR_12 + VAR_13;
if (!VAR_13)
memset(stack+VAR_14, 0, sizeof(*stack));
if (!strcmp(VAR_10, "font")) {
if (VAR_13) {
for (VAR_18=PARAM_NUMBER-1; VAR_18>=0; VAR_18--)
if (stack[VAR_14-1].VAR_9[VAR_18][0])
for (VAR_19=VAR_14-2; VAR_19>=0; VAR_19--)
if (stack[VAR_19].VAR_9[VAR_18][0]) {
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,
"%s", stack[VAR_19].VAR_9[VAR_18]);
break;
}
} else {
while (VAR_9) {
if (!strncmp(VAR_9, "size=", 5)) {
unsigned VAR_21;
VAR_9 += 5 + (VAR_9[5] == '"');
if (sscanf(VAR_9, "%u", &VAR_21) == 1) {
snprintf(stack[VAR_14].VAR_9[PARAM_SIZE],
sizeof(stack[0].VAR_9[PARAM_SIZE]),
"{\\fs%u}", VAR_21);
}
} else if (!strncmp(VAR_9, "color=", 6)) {
VAR_9 += 6 + (VAR_9[6] == '"');
snprintf(stack[VAR_14].VAR_9[PARAM_COLOR],
sizeof(stack[0].VAR_9[PARAM_COLOR]),
"{\\VAR_8&H%X&}",
html_color_parse(VAR_0, VAR_9));
} else if (!strncmp(VAR_9, "face=", 5)) {
VAR_9 += 5 + (VAR_9[5] == '"');
VAR_12 = strcspn(VAR_9,
VAR_9[-1] == '"' ? "\"" :" ");
av_strlcpy(VAR_11, VAR_9,
FFMIN(sizeof(VAR_11), VAR_12+1));
VAR_9 += VAR_12;
snprintf(stack[VAR_14].VAR_9[PARAM_FACE],
sizeof(stack[0].VAR_9[PARAM_FACE]),
"{\\fn%s}", VAR_11);
}
if ((VAR_9 = strchr(VAR_9, ' ')))
VAR_9++;
}
for (VAR_18=0; VAR_18<PARAM_NUMBER; VAR_18++)
if (stack[VAR_14].VAR_9[VAR_18][0])
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,
"%s", stack[VAR_14].VAR_9[VAR_18]);
}
} else if (!VAR_10[1] && strspn(VAR_10, "bisu") == 1) {
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,
"{\\%VAR_8%d}", VAR_10[0], !VAR_13);
} else {
VAR_20 = 1;
snprintf(VAR_11, sizeof(VAR_11), "</%s>", VAR_10);
}
if (VAR_13) {
VAR_14--;
} else if (VAR_20 && !strstr(VAR_3, VAR_11)) {
VAR_3 -= VAR_12 + VAR_13;
*VAR_1++ = *VAR_3;
} else
av_strlcpy(stack[VAR_14++].tag, VAR_10,
sizeof(stack[0].tag));
break;
}
}
default:
*VAR_1++ = *VAR_3;
break;
}
if (*VAR_3 != ' ' && *VAR_3 != '\r' && *VAR_3 != '\n')
VAR_15 = 0;
}
VAR_1 = FFMIN(VAR_1, VAR_2-3);
while (!strncmp(VAR_1-2, "\\N", 2))
VAR_1 -= 2;
while (VAR_1[-1] == ' ')
VAR_1--;
VAR_1 += snprintf(VAR_1, VAR_2-VAR_1, "\r\n");
return VAR_3;
}
| [
"static const char *FUNC_0(AVCodecContext *VAR_0, char *VAR_1, char *VAR_2,\nconst char *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)\n{",
"char VAR_8, *VAR_9, VAR_10[128], VAR_11[128];",
"int VAR_12, VAR_13, VAR_14 = 1, VAR_15 = 1, VAR_16 = 0, VAR_17 = 0;",
"SrtStack stack[16];",
"stack[0].tag[0] = 0;",
"strcpy(stack[0].VAR_9[PARAM_SIZE], \"{\\\\fs}\");",
"strcpy(stack[0].VAR_9[PARAM_COLOR], \"{\\\\VAR_8}\");",
"strcpy(stack[0].VAR_9[PARAM_FACE], \"{\\\\fn}\");",
"if (VAR_4 >= 0 && VAR_5 >= 0) {",
"if (VAR_6 >= 0 && VAR_7 >= 0 && (VAR_6 != VAR_4 || VAR_7 != VAR_5))\nVAR_1 += snprintf(VAR_1, VAR_2-VAR_1,\n\"{\\\\an1}{\\\\move(%d,%d,%d,%d)}\", VAR_4, VAR_5, VAR_6, VAR_7);",
"else\nVAR_1 += snprintf(VAR_1, VAR_2-VAR_1, \"{\\\\an1}{\\\\pos(%d,%d)}\", VAR_4, VAR_5);",
"}",
"for (; VAR_1 < VAR_2 && !VAR_17 && *VAR_3; VAR_3++) {",
"switch (*VAR_3) {",
"case '\\r':\nbreak;",
"case '\\n':\nif (VAR_15) {",
"VAR_17 = 1;",
"break;",
"}",
"while (VAR_1[-1] == ' ')\nVAR_1--;",
"VAR_1 += snprintf(VAR_1, VAR_2-VAR_1, \"\\\\N\");",
"VAR_15 = 1;",
"break;",
"case ' ':\nif (!VAR_15)\n*VAR_1++ = *VAR_3;",
"break;",
"case '{':",
"VAR_16 += sscanf(VAR_3, \"{\\\\VAR_16%*1u}%VAR_8\", &VAR_8) == 1;",
"if ((VAR_16 != 1 && sscanf(VAR_3, \"{\\\\%*[^}]}%n%VAR_8\", &VAR_12, &VAR_8) > 0) ||",
"sscanf(VAR_3, \"{%*1[CcFfoPSsYy]:%*[^}]}%n%VAR_8\", &VAR_12, &VAR_8) > 0) {",
"VAR_3 += VAR_12 - 1;",
"} else",
"*VAR_1++ = *VAR_3;",
"break;",
"case '<':\nVAR_13 = VAR_3[1] == '/';",
"if (sscanf(VAR_3+VAR_13+1, \"%127[^>]>%n%VAR_8\", VAR_10, &VAR_12,&VAR_8) >= 2) {",
"if ((VAR_9 = strchr(VAR_10, ' ')))\n*VAR_9++ = 0;",
"if ((!VAR_13 && VAR_14 < FF_ARRAY_ELEMS(stack)) ||\n( VAR_13 && VAR_14 > 0 && !strcmp(stack[VAR_14-1].tag, VAR_10))) {",
"int VAR_18, VAR_19, VAR_20 = 0;",
"VAR_3 += VAR_12 + VAR_13;",
"if (!VAR_13)\nmemset(stack+VAR_14, 0, sizeof(*stack));",
"if (!strcmp(VAR_10, \"font\")) {",
"if (VAR_13) {",
"for (VAR_18=PARAM_NUMBER-1; VAR_18>=0; VAR_18--)",
"if (stack[VAR_14-1].VAR_9[VAR_18][0])\nfor (VAR_19=VAR_14-2; VAR_19>=0; VAR_19--)",
"if (stack[VAR_19].VAR_9[VAR_18][0]) {",
"VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,\n\"%s\", stack[VAR_19].VAR_9[VAR_18]);",
"break;",
"}",
"} else {",
"while (VAR_9) {",
"if (!strncmp(VAR_9, \"size=\", 5)) {",
"unsigned VAR_21;",
"VAR_9 += 5 + (VAR_9[5] == '\"');",
"if (sscanf(VAR_9, \"%u\", &VAR_21) == 1) {",
"snprintf(stack[VAR_14].VAR_9[PARAM_SIZE],\nsizeof(stack[0].VAR_9[PARAM_SIZE]),\n\"{\\\\fs%u}\", VAR_21);",
"}",
"} else if (!strncmp(VAR_9, \"color=\", 6)) {",
"VAR_9 += 6 + (VAR_9[6] == '\"');",
"snprintf(stack[VAR_14].VAR_9[PARAM_COLOR],\nsizeof(stack[0].VAR_9[PARAM_COLOR]),\n\"{\\\\VAR_8&H%X&}\",",
"html_color_parse(VAR_0, VAR_9));",
"} else if (!strncmp(VAR_9, \"face=\", 5)) {",
"VAR_9 += 5 + (VAR_9[5] == '\"');",
"VAR_12 = strcspn(VAR_9,\nVAR_9[-1] == '\"' ? \"\\\"\" :\" \");",
"av_strlcpy(VAR_11, VAR_9,\nFFMIN(sizeof(VAR_11), VAR_12+1));",
"VAR_9 += VAR_12;",
"snprintf(stack[VAR_14].VAR_9[PARAM_FACE],\nsizeof(stack[0].VAR_9[PARAM_FACE]),\n\"{\\\\fn%s}\", VAR_11);",
"}",
"if ((VAR_9 = strchr(VAR_9, ' ')))\nVAR_9++;",
"}",
"for (VAR_18=0; VAR_18<PARAM_NUMBER; VAR_18++)",
"if (stack[VAR_14].VAR_9[VAR_18][0])\nVAR_1 += snprintf(VAR_1, VAR_2-VAR_1,\n\"%s\", stack[VAR_14].VAR_9[VAR_18]);",
"}",
"} else if (!VAR_10[1] && strspn(VAR_10, \"bisu\") == 1) {",
"VAR_1 += snprintf(VAR_1, VAR_2-VAR_1,\n\"{\\\\%VAR_8%d}\", VAR_10[0], !VAR_13);",
"} else {",
"VAR_20 = 1;",
"snprintf(VAR_11, sizeof(VAR_11), \"</%s>\", VAR_10);",
"}",
"if (VAR_13) {",
"VAR_14--;",
"} else if (VAR_20 && !strstr(VAR_3, VAR_11)) {",
"VAR_3 -= VAR_12 + VAR_13;",
"*VAR_1++ = *VAR_3;",
"} else",
"av_strlcpy(stack[VAR_14++].tag, VAR_10,\nsizeof(stack[0].tag));",
"break;",
"}",
"}",
"default:\n*VAR_1++ = *VAR_3;",
"break;",
"}",
"if (*VAR_3 != ' ' && *VAR_3 != '\\r' && *VAR_3 != '\\n')\nVAR_15 = 0;",
"}",
"VAR_1 = FFMIN(VAR_1, VAR_2-3);",
"while (!strncmp(VAR_1-2, \"\\\\N\", 2))\nVAR_1 -= 2;",
"while (VAR_1[-1] == ' ')\nVAR_1--;",
"VAR_1 += snprintf(VAR_1, VAR_2-VAR_1, \"\\r\\n\");",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27,
29,
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105,
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151,
153
],
[
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183,
185,
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199,
201,
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
259
],
[
261,
263
],
[
265,
267
],
[
269
],
[
271
],
[
273
]
] |
25,349 | int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
{
AVMetadata *m= *pm;
AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
if(!m)
m=*pm= av_mallocz(sizeof(*m));
if(tag){
av_free(tag->value);
av_free(tag->key);
*tag= m->elems[--m->count];
}else{
AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp){
m->elems= tmp;
}else
return AVERROR(ENOMEM);
}
if(value){
m->elems[m->count].key = av_strdup(key );
m->elems[m->count].value= av_strdup(value);
m->count++;
}
if(!m->count) {
av_free(m->elems);
av_freep(pm);
}
return 0;
}
| false | FFmpeg | a181981eb49fc20d1a701fcfebda5cec70def295 | int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
{
AVMetadata *m= *pm;
AVMetadataTag *tag= av_metadata_get(m, key, NULL, AV_METADATA_MATCH_CASE);
if(!m)
m=*pm= av_mallocz(sizeof(*m));
if(tag){
av_free(tag->value);
av_free(tag->key);
*tag= m->elems[--m->count];
}else{
AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp){
m->elems= tmp;
}else
return AVERROR(ENOMEM);
}
if(value){
m->elems[m->count].key = av_strdup(key );
m->elems[m->count].value= av_strdup(value);
m->count++;
}
if(!m->count) {
av_free(m->elems);
av_freep(pm);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVMetadata **VAR_0, const char *VAR_1, const char *VAR_2)
{
AVMetadata *m= *VAR_0;
AVMetadataTag *tag= av_metadata_get(m, VAR_1, NULL, AV_METADATA_MATCH_CASE);
if(!m)
m=*VAR_0= av_mallocz(sizeof(*m));
if(tag){
av_free(tag->VAR_2);
av_free(tag->VAR_1);
*tag= m->elems[--m->count];
}else{
AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
if(tmp){
m->elems= tmp;
}else
return AVERROR(ENOMEM);
}
if(VAR_2){
m->elems[m->count].VAR_1 = av_strdup(VAR_1 );
m->elems[m->count].VAR_2= av_strdup(VAR_2);
m->count++;
}
if(!m->count) {
av_free(m->elems);
av_freep(VAR_0);
}
return 0;
}
| [
"int FUNC_0(AVMetadata **VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"AVMetadata *m= *VAR_0;",
"AVMetadataTag *tag= av_metadata_get(m, VAR_1, NULL, AV_METADATA_MATCH_CASE);",
"if(!m)\nm=*VAR_0= av_mallocz(sizeof(*m));",
"if(tag){",
"av_free(tag->VAR_2);",
"av_free(tag->VAR_1);",
"*tag= m->elems[--m->count];",
"}else{",
"AVMetadataTag *tmp= av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));",
"if(tmp){",
"m->elems= tmp;",
"}else",
"return AVERROR(ENOMEM);",
"}",
"if(VAR_2){",
"m->elems[m->count].VAR_1 = av_strdup(VAR_1 );",
"m->elems[m->count].VAR_2= av_strdup(VAR_2);",
"m->count++;",
"}",
"if(!m->count) {",
"av_free(m->elems);",
"av_freep(VAR_0);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
]
] |
25,350 | static void zynq_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
ObjectClass *cpu_oc;
ARMCPU *cpu;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
int n;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
/* max 2GB ram */
if (ram_size > 0x80000000) {
ram_size = 0x80000000;
}
/* DDR remapped to address zero. */
memory_region_init_ram(ext_ram, NULL, "zynq.ext_ram", ram_size,
&error_abort);
vmstate_register_ram_global(ext_ram);
memory_region_add_subregion(address_space_mem, 0, ext_ram);
/* 256K of on-chip memory */
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
&error_abort);
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
/* AMD */
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
FLASH_SECTOR_SIZE,
FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
0);
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
dev = qdev_create(NULL, "pl330");
qdev_prop_set_uint8(dev, "num_chnls", 8);
qdev_prop_set_uint8(dev, "num_periph_req", 4);
qdev_prop_set_uint8(dev, "num_events", 16);
qdev_prop_set_uint8(dev, "data_width", 64);
qdev_prop_set_uint8(dev, "wr_cap", 8);
qdev_prop_set_uint8(dev, "wr_q_dep", 16);
qdev_prop_set_uint8(dev, "rd_cap", 8);
qdev_prop_set_uint8(dev, "rd_q_dep", 16);
qdev_prop_set_uint16(dev, "data_buffer_dep", 256);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0xF8003000);
sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]); /* abort irq line */
for (n = 0; n < 8; ++n) { /* event irqs */
sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);
}
zynq_binfo.ram_size = ram_size;
zynq_binfo.kernel_filename = kernel_filename;
zynq_binfo.kernel_cmdline = kernel_cmdline;
zynq_binfo.initrd_filename = initrd_filename;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void zynq_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
ObjectClass *cpu_oc;
ARMCPU *cpu;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
int n;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
if (ram_size > 0x80000000) {
ram_size = 0x80000000;
}
memory_region_init_ram(ext_ram, NULL, "zynq.ext_ram", ram_size,
&error_abort);
vmstate_register_ram_global(ext_ram);
memory_region_add_subregion(address_space_mem, 0, ext_ram);
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
&error_abort);
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
FLASH_SECTOR_SIZE,
FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
0);
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
dev = qdev_create(NULL, "pl330");
qdev_prop_set_uint8(dev, "num_chnls", 8);
qdev_prop_set_uint8(dev, "num_periph_req", 4);
qdev_prop_set_uint8(dev, "num_events", 16);
qdev_prop_set_uint8(dev, "data_width", 64);
qdev_prop_set_uint8(dev, "wr_cap", 8);
qdev_prop_set_uint8(dev, "wr_q_dep", 16);
qdev_prop_set_uint8(dev, "rd_cap", 8);
qdev_prop_set_uint8(dev, "rd_q_dep", 16);
qdev_prop_set_uint16(dev, "data_buffer_dep", 256);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0xF8003000);
sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]);
for (n = 0; n < 8; ++n) {
sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);
}
zynq_binfo.ram_size = ram_size;
zynq_binfo.kernel_filename = kernel_filename;
zynq_binfo.kernel_cmdline = kernel_cmdline;
zynq_binfo.initrd_filename = initrd_filename;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
ObjectClass *cpu_oc;
ARMCPU *cpu;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
int VAR_5;
if (!VAR_1) {
VAR_1 = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, VAR_1);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
if (ram_size > 0x80000000) {
ram_size = 0x80000000;
}
memory_region_init_ram(ext_ram, NULL, "zynq.ext_ram", ram_size,
&error_abort);
vmstate_register_ram_global(ext_ram);
memory_region_add_subregion(address_space_mem, 0, ext_ram);
memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
&error_abort);
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
FLASH_SECTOR_SIZE,
FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
0);
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (VAR_5 = 0; VAR_5 < 64; VAR_5++) {
pic[VAR_5] = qdev_get_gpio_in(dev, VAR_5);
}
zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);
zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);
sysbus_create_simple("xlnx,ps7-usb", 0xE0002000, pic[53-IRQ_OFFSET]);
sysbus_create_simple("xlnx,ps7-usb", 0xE0003000, pic[76-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
dev = qdev_create(NULL, "pl330");
qdev_prop_set_uint8(dev, "num_chnls", 8);
qdev_prop_set_uint8(dev, "num_periph_req", 4);
qdev_prop_set_uint8(dev, "num_events", 16);
qdev_prop_set_uint8(dev, "data_width", 64);
qdev_prop_set_uint8(dev, "wr_cap", 8);
qdev_prop_set_uint8(dev, "wr_q_dep", 16);
qdev_prop_set_uint8(dev, "rd_cap", 8);
qdev_prop_set_uint8(dev, "rd_q_dep", 16);
qdev_prop_set_uint16(dev, "data_buffer_dep", 256);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, 0xF8003000);
sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]);
for (VAR_5 = 0; VAR_5 < 8; ++VAR_5) {
sysbus_connect_irq(busdev, VAR_5 + 1, pic[dma_irqs[VAR_5] - IRQ_OFFSET]);
}
zynq_binfo.ram_size = ram_size;
zynq_binfo.VAR_2 = VAR_2;
zynq_binfo.VAR_3 = VAR_3;
zynq_binfo.VAR_4 = VAR_4;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"ObjectClass *cpu_oc;",
"ARMCPU *cpu;",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *ext_ram = g_new(MemoryRegion, 1);",
"MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);",
"DeviceState *dev;",
"SysBusDevice *busdev;",
"qemu_irq pic[64];",
"Error *err = NULL;",
"int VAR_5;",
"if (!VAR_1) {",
"VAR_1 = \"cortex-a9\";",
"}",
"cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, VAR_1);",
"cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));",
"object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, \"midr\", &err);",
"if (err) {",
"error_report(\"%s\", error_get_pretty(err));",
"exit(1);",
"}",
"object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, \"reset-cbar\", &err);",
"if (err) {",
"error_report(\"%s\", error_get_pretty(err));",
"exit(1);",
"}",
"object_property_set_bool(OBJECT(cpu), true, \"realized\", &err);",
"if (err) {",
"error_report(\"%s\", error_get_pretty(err));",
"exit(1);",
"}",
"if (ram_size > 0x80000000) {",
"ram_size = 0x80000000;",
"}",
"memory_region_init_ram(ext_ram, NULL, \"zynq.ext_ram\", ram_size,\n&error_abort);",
"vmstate_register_ram_global(ext_ram);",
"memory_region_add_subregion(address_space_mem, 0, ext_ram);",
"memory_region_init_ram(ocm_ram, NULL, \"zynq.ocm_ram\", 256 << 10,\n&error_abort);",
"vmstate_register_ram_global(ocm_ram);",
"memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);",
"DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);",
"pflash_cfi02_register(0xe2000000, NULL, \"zynq.pflash\", FLASH_SIZE,\ndinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,\nFLASH_SECTOR_SIZE,\nFLASH_SIZE/FLASH_SECTOR_SIZE, 1,\n1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,\n0);",
"dev = qdev_create(NULL, \"xilinx,zynq_slcr\");",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);",
"dev = qdev_create(NULL, \"a9mpcore_priv\");",
"qdev_prop_set_uint32(dev, \"num-cpu\", 1);",
"qdev_init_nofail(dev);",
"busdev = SYS_BUS_DEVICE(dev);",
"sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);",
"sysbus_connect_irq(busdev, 0,\nqdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));",
"for (VAR_5 = 0; VAR_5 < 64; VAR_5++) {",
"pic[VAR_5] = qdev_get_gpio_in(dev, VAR_5);",
"}",
"zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false);",
"zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false);",
"zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true);",
"sysbus_create_simple(\"xlnx,ps7-usb\", 0xE0002000, pic[53-IRQ_OFFSET]);",
"sysbus_create_simple(\"xlnx,ps7-usb\", 0xE0003000, pic[76-IRQ_OFFSET]);",
"sysbus_create_simple(\"cadence_uart\", 0xE0000000, pic[59-IRQ_OFFSET]);",
"sysbus_create_simple(\"cadence_uart\", 0xE0001000, pic[82-IRQ_OFFSET]);",
"sysbus_create_varargs(\"cadence_ttc\", 0xF8001000,\npic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);",
"sysbus_create_varargs(\"cadence_ttc\", 0xF8002000,\npic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);",
"gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);",
"gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);",
"dev = qdev_create(NULL, \"generic-sdhci\");",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);",
"dev = qdev_create(NULL, \"generic-sdhci\");",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);",
"dev = qdev_create(NULL, \"pl330\");",
"qdev_prop_set_uint8(dev, \"num_chnls\", 8);",
"qdev_prop_set_uint8(dev, \"num_periph_req\", 4);",
"qdev_prop_set_uint8(dev, \"num_events\", 16);",
"qdev_prop_set_uint8(dev, \"data_width\", 64);",
"qdev_prop_set_uint8(dev, \"wr_cap\", 8);",
"qdev_prop_set_uint8(dev, \"wr_q_dep\", 16);",
"qdev_prop_set_uint8(dev, \"rd_cap\", 8);",
"qdev_prop_set_uint8(dev, \"rd_q_dep\", 16);",
"qdev_prop_set_uint16(dev, \"data_buffer_dep\", 256);",
"qdev_init_nofail(dev);",
"busdev = SYS_BUS_DEVICE(dev);",
"sysbus_mmio_map(busdev, 0, 0xF8003000);",
"sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]);",
"for (VAR_5 = 0; VAR_5 < 8; ++VAR_5) {",
"sysbus_connect_irq(busdev, VAR_5 + 1, pic[dma_irqs[VAR_5] - IRQ_OFFSET]);",
"}",
"zynq_binfo.ram_size = ram_size;",
"zynq_binfo.VAR_2 = VAR_2;",
"zynq_binfo.VAR_3 = VAR_3;",
"zynq_binfo.VAR_4 = VAR_4;",
"zynq_binfo.nb_cpus = 1;",
"zynq_binfo.board_id = 0xd32;",
"zynq_binfo.loader_start = 0;",
"arm_load_kernel(ARM_CPU(first_cpu), &zynq_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
97,
99
],
[
101
],
[
103
],
[
109,
111
],
[
113
],
[
115
],
[
119
],
[
125,
127,
129,
131,
133,
135
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191,
193
],
[
195,
197
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
]
] |
25,351 | static void tcg_out_brcond(TCGContext *s, TCGMemOp ext, TCGCond c, TCGArg a,
TCGArg b, bool b_const, int label)
{
TCGLabel *l = &s->labels[label];
intptr_t offset;
bool need_cmp;
if (b_const && b == 0 && (c == TCG_COND_EQ || c == TCG_COND_NE)) {
need_cmp = false;
} else {
need_cmp = true;
tcg_out_cmp(s, ext, a, b, b_const);
}
if (!l->has_value) {
tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, label, 0);
offset = tcg_in32(s) >> 5;
} else {
offset = l->u.value_ptr - s->code_ptr;
assert(offset == sextract64(offset, 0, 19));
}
if (need_cmp) {
tcg_out_insn(s, 3202, B_C, c, offset);
} else if (c == TCG_COND_EQ) {
tcg_out_insn(s, 3201, CBZ, ext, a, offset);
} else {
tcg_out_insn(s, 3201, CBNZ, ext, a, offset);
}
}
| false | qemu | bec1631100323fac0900aea71043d5c4e22fc2fa | static void tcg_out_brcond(TCGContext *s, TCGMemOp ext, TCGCond c, TCGArg a,
TCGArg b, bool b_const, int label)
{
TCGLabel *l = &s->labels[label];
intptr_t offset;
bool need_cmp;
if (b_const && b == 0 && (c == TCG_COND_EQ || c == TCG_COND_NE)) {
need_cmp = false;
} else {
need_cmp = true;
tcg_out_cmp(s, ext, a, b, b_const);
}
if (!l->has_value) {
tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, label, 0);
offset = tcg_in32(s) >> 5;
} else {
offset = l->u.value_ptr - s->code_ptr;
assert(offset == sextract64(offset, 0, 19));
}
if (need_cmp) {
tcg_out_insn(s, 3202, B_C, c, offset);
} else if (c == TCG_COND_EQ) {
tcg_out_insn(s, 3201, CBZ, ext, a, offset);
} else {
tcg_out_insn(s, 3201, CBNZ, ext, a, offset);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGMemOp VAR_1, TCGCond VAR_2, TCGArg VAR_3,
TCGArg VAR_4, bool VAR_5, int VAR_6)
{
TCGLabel *l = &VAR_0->labels[VAR_6];
intptr_t offset;
bool need_cmp;
if (VAR_5 && VAR_4 == 0 && (VAR_2 == TCG_COND_EQ || VAR_2 == TCG_COND_NE)) {
need_cmp = false;
} else {
need_cmp = true;
tcg_out_cmp(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5);
}
if (!l->has_value) {
tcg_out_reloc(VAR_0, VAR_0->code_ptr, R_AARCH64_CONDBR19, VAR_6, 0);
offset = tcg_in32(VAR_0) >> 5;
} else {
offset = l->u.value_ptr - VAR_0->code_ptr;
assert(offset == sextract64(offset, 0, 19));
}
if (need_cmp) {
tcg_out_insn(VAR_0, 3202, B_C, VAR_2, offset);
} else if (VAR_2 == TCG_COND_EQ) {
tcg_out_insn(VAR_0, 3201, CBZ, VAR_1, VAR_3, offset);
} else {
tcg_out_insn(VAR_0, 3201, CBNZ, VAR_1, VAR_3, offset);
}
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGMemOp VAR_1, TCGCond VAR_2, TCGArg VAR_3,\nTCGArg VAR_4, bool VAR_5, int VAR_6)\n{",
"TCGLabel *l = &VAR_0->labels[VAR_6];",
"intptr_t offset;",
"bool need_cmp;",
"if (VAR_5 && VAR_4 == 0 && (VAR_2 == TCG_COND_EQ || VAR_2 == TCG_COND_NE)) {",
"need_cmp = false;",
"} else {",
"need_cmp = true;",
"tcg_out_cmp(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5);",
"}",
"if (!l->has_value) {",
"tcg_out_reloc(VAR_0, VAR_0->code_ptr, R_AARCH64_CONDBR19, VAR_6, 0);",
"offset = tcg_in32(VAR_0) >> 5;",
"} else {",
"offset = l->u.value_ptr - VAR_0->code_ptr;",
"assert(offset == sextract64(offset, 0, 19));",
"}",
"if (need_cmp) {",
"tcg_out_insn(VAR_0, 3202, B_C, VAR_2, offset);",
"} else if (VAR_2 == TCG_COND_EQ) {",
"tcg_out_insn(VAR_0, 3201, CBZ, VAR_1, VAR_3, offset);",
"} else {",
"tcg_out_insn(VAR_0, 3201, CBNZ, VAR_1, VAR_3, offset);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
25,352 | static target_ulong h_vio_signal(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong mode = args[1];
VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRDeviceInfo *info;
if (!dev) {
return H_PARAMETER;
}
info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
if (mode & ~info->signal_mask) {
return H_PARAMETER;
}
dev->signal_state = mode;
return H_SUCCESS;
}
| false | qemu | 3954d33ab7f82f5a5fa0ced231849920265a5fec | static target_ulong h_vio_signal(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong mode = args[1];
VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRDeviceInfo *info;
if (!dev) {
return H_PARAMETER;
}
info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
if (mode & ~info->signal_mask) {
return H_PARAMETER;
}
dev->signal_state = mode;
return H_SUCCESS;
}
| {
"code": [],
"line_no": []
} | static target_ulong FUNC_0(CPUState *env, sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong mode = args[1];
VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRDeviceInfo *info;
if (!dev) {
return H_PARAMETER;
}
info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
if (mode & ~info->signal_mask) {
return H_PARAMETER;
}
dev->signal_state = mode;
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(CPUState *env, sPAPREnvironment *spapr,\ntarget_ulong opcode,\ntarget_ulong *args)\n{",
"target_ulong reg = args[0];",
"target_ulong mode = args[1];",
"VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);",
"VIOsPAPRDeviceInfo *info;",
"if (!dev) {",
"return H_PARAMETER;",
"}",
"info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);",
"if (mode & ~info->signal_mask) {",
"return H_PARAMETER;",
"}",
"dev->signal_state = mode;",
"return H_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45
]
] |
25,354 | static TCGArg do_constant_folding(int op, TCGArg x, TCGArg y)
{
TCGArg res = do_constant_folding_2(op, x, y);
#if TCG_TARGET_REG_BITS == 64
if (op_bits(op) == 32) {
res &= 0xffffffff;
}
#endif
return res;
}
| false | qemu | 25c4d9cc845fb58f624dae8c0f690e20c70e7a1d | static TCGArg do_constant_folding(int op, TCGArg x, TCGArg y)
{
TCGArg res = do_constant_folding_2(op, x, y);
#if TCG_TARGET_REG_BITS == 64
if (op_bits(op) == 32) {
res &= 0xffffffff;
}
#endif
return res;
}
| {
"code": [],
"line_no": []
} | static TCGArg FUNC_0(int op, TCGArg x, TCGArg y)
{
TCGArg res = do_constant_folding_2(op, x, y);
#if TCG_TARGET_REG_BITS == 64
if (op_bits(op) == 32) {
res &= 0xffffffff;
}
#endif
return res;
}
| [
"static TCGArg FUNC_0(int op, TCGArg x, TCGArg y)\n{",
"TCGArg res = do_constant_folding_2(op, x, y);",
"#if TCG_TARGET_REG_BITS == 64\nif (op_bits(op) == 32) {",
"res &= 0xffffffff;",
"}",
"#endif\nreturn res;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
]
] |
25,355 | static int64_t seek_to_sector(BDRVParallelsState *s, int64_t sector_num)
{
uint32_t index, offset;
index = sector_num / s->tracks;
offset = sector_num % s->tracks;
/* not allocated */
if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))
return -1;
return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset;
}
| false | qemu | 369f7de9d57e4dd2f312255fc12271d5749c0a4e | static int64_t seek_to_sector(BDRVParallelsState *s, int64_t sector_num)
{
uint32_t index, offset;
index = sector_num / s->tracks;
offset = sector_num % s->tracks;
if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))
return -1;
return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(BDRVParallelsState *s, int64_t sector_num)
{
uint32_t index, offset;
index = sector_num / s->tracks;
offset = sector_num % s->tracks;
if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))
return -1;
return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset;
}
| [
"static int64_t FUNC_0(BDRVParallelsState *s, int64_t sector_num)\n{",
"uint32_t index, offset;",
"index = sector_num / s->tracks;",
"offset = sector_num % s->tracks;",
"if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))\nreturn -1;",
"return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
17,
19
],
[
21
],
[
23
]
] |
25,356 | int load_image_targphys(const char *filename,
target_phys_addr_t addr, uint64_t max_sz)
{
int size;
size = get_image_size(filename);
if (size > max_sz) {
return -1;
}
if (size > 0) {
rom_add_file_fixed(filename, addr, -1);
}
return size;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | int load_image_targphys(const char *filename,
target_phys_addr_t addr, uint64_t max_sz)
{
int size;
size = get_image_size(filename);
if (size > max_sz) {
return -1;
}
if (size > 0) {
rom_add_file_fixed(filename, addr, -1);
}
return size;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0,
target_phys_addr_t VAR_1, uint64_t VAR_2)
{
int VAR_3;
VAR_3 = get_image_size(VAR_0);
if (VAR_3 > VAR_2) {
return -1;
}
if (VAR_3 > 0) {
rom_add_file_fixed(VAR_0, VAR_1, -1);
}
return VAR_3;
}
| [
"int FUNC_0(const char *VAR_0,\ntarget_phys_addr_t VAR_1, uint64_t VAR_2)\n{",
"int VAR_3;",
"VAR_3 = get_image_size(VAR_0);",
"if (VAR_3 > VAR_2) {",
"return -1;",
"}",
"if (VAR_3 > 0) {",
"rom_add_file_fixed(VAR_0, VAR_1, -1);",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,358 | static uint64_t vfio_bar_read(void *opaque,
hwaddr addr, unsigned size)
{
VFIOBAR *bar = opaque;
union {
uint8_t byte;
uint16_t word;
uint32_t dword;
uint64_t qword;
} buf;
uint64_t data = 0;
if (pread(bar->fd, &buf, size, bar->fd_offset + addr) != size) {
error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
__func__, addr, size);
return (uint64_t)-1;
}
switch (size) {
case 1:
data = buf.byte;
break;
case 2:
data = le16_to_cpu(buf.word);
break;
case 4:
data = le32_to_cpu(buf.dword);
break;
default:
hw_error("vfio: unsupported read size, %d bytes\n", size);
break;
}
DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", %d) = 0x%"PRIx64"\n",
__func__, bar->nr, addr, size, data);
/* Same as write above */
vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
return data;
}
| false | qemu | 82ca891283a08cddd659b534592fe00f2159bc74 | static uint64_t vfio_bar_read(void *opaque,
hwaddr addr, unsigned size)
{
VFIOBAR *bar = opaque;
union {
uint8_t byte;
uint16_t word;
uint32_t dword;
uint64_t qword;
} buf;
uint64_t data = 0;
if (pread(bar->fd, &buf, size, bar->fd_offset + addr) != size) {
error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
__func__, addr, size);
return (uint64_t)-1;
}
switch (size) {
case 1:
data = buf.byte;
break;
case 2:
data = le16_to_cpu(buf.word);
break;
case 4:
data = le32_to_cpu(buf.dword);
break;
default:
hw_error("vfio: unsupported read size, %d bytes\n", size);
break;
}
DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", %d) = 0x%"PRIx64"\n",
__func__, bar->nr, addr, size, data);
vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
return data;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque,
hwaddr addr, unsigned size)
{
VFIOBAR *bar = opaque;
union {
uint8_t byte;
uint16_t word;
uint32_t dword;
uint64_t qword;
} VAR_0;
uint64_t data = 0;
if (pread(bar->fd, &VAR_0, size, bar->fd_offset + addr) != size) {
error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m",
__func__, addr, size);
return (uint64_t)-1;
}
switch (size) {
case 1:
data = VAR_0.byte;
break;
case 2:
data = le16_to_cpu(VAR_0.word);
break;
case 4:
data = le32_to_cpu(VAR_0.dword);
break;
default:
hw_error("vfio: unsupported read size, %d bytes\n", size);
break;
}
DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", %d) = 0x%"PRIx64"\n",
__func__, bar->nr, addr, size, data);
vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
return data;
}
| [
"static uint64_t FUNC_0(void *opaque,\nhwaddr addr, unsigned size)\n{",
"VFIOBAR *bar = opaque;",
"union {",
"uint8_t byte;",
"uint16_t word;",
"uint32_t dword;",
"uint64_t qword;",
"} VAR_0;",
"uint64_t data = 0;",
"if (pread(bar->fd, &VAR_0, size, bar->fd_offset + addr) != size) {",
"error_report(\"%s(,0x%\"HWADDR_PRIx\", %d) failed: %m\",\n__func__, addr, size);",
"return (uint64_t)-1;",
"}",
"switch (size) {",
"case 1:\ndata = VAR_0.byte;",
"break;",
"case 2:\ndata = le16_to_cpu(VAR_0.word);",
"break;",
"case 4:\ndata = le32_to_cpu(VAR_0.dword);",
"break;",
"default:\nhw_error(\"vfio: unsupported read size, %d bytes\\n\", size);",
"break;",
"}",
"DPRINTF(\"%s(BAR%d+0x%\"HWADDR_PRIx\", %d) = 0x%\"PRIx64\"\\n\",\n__func__, bar->nr, addr, size, data);",
"vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));",
"return data;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67,
69
],
[
75
],
[
79
],
[
81
]
] |
25,359 | static int l2tpv3_can_send(void *opaque)
{
NetL2TPV3State *s = opaque;
return qemu_can_send_packet(&s->nc);
}
| false | qemu | 95b1416ae93106923f733941e52dfe55c4318643 | static int l2tpv3_can_send(void *opaque)
{
NetL2TPV3State *s = opaque;
return qemu_can_send_packet(&s->nc);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
NetL2TPV3State *s = VAR_0;
return qemu_can_send_packet(&s->nc);
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"NetL2TPV3State *s = VAR_0;",
"return qemu_can_send_packet(&s->nc);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
25,360 | static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
const char **throttling_group, ThrottleConfig *throttle_cfg,
BlockdevDetectZeroesOptions *detect_zeroes, Error **errp)
{
const char *discard;
Error *local_error = NULL;
const char *aio;
if (bdrv_flags) {
if (!qemu_opt_get_bool(opts, "read-only", false)) {
*bdrv_flags |= BDRV_O_RDWR;
}
if (qemu_opt_get_bool(opts, "copy-on-read", false)) {
*bdrv_flags |= BDRV_O_COPY_ON_READ;
}
if ((discard = qemu_opt_get(opts, "discard")) != NULL) {
if (bdrv_parse_discard_flags(discard, bdrv_flags) != 0) {
error_setg(errp, "Invalid discard option");
return;
}
}
if ((aio = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(aio, "native")) {
*bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(aio, "threads")) {
/* this is the default */
} else {
error_setg(errp, "invalid aio option");
return;
}
}
}
/* disk I/O throttling */
if (throttling_group) {
*throttling_group = qemu_opt_get(opts, "throttling.group");
}
if (throttle_cfg) {
memset(throttle_cfg, 0, sizeof(*throttle_cfg));
throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.bps-total", 0);
throttle_cfg->buckets[THROTTLE_BPS_READ].avg =
qemu_opt_get_number(opts, "throttling.bps-read", 0);
throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.bps-write", 0);
throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.iops-total", 0);
throttle_cfg->buckets[THROTTLE_OPS_READ].avg =
qemu_opt_get_number(opts, "throttling.iops-read", 0);
throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.iops-write", 0);
throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
throttle_cfg->buckets[THROTTLE_BPS_READ].max =
qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_READ].max =
qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
throttle_cfg->op_size =
qemu_opt_get_number(opts, "throttling.iops-size", 0);
if (!check_throttle_config(throttle_cfg, errp)) {
return;
}
}
if (detect_zeroes) {
*detect_zeroes =
qapi_enum_parse(BlockdevDetectZeroesOptions_lookup,
qemu_opt_get(opts, "detect-zeroes"),
BLOCKDEV_DETECT_ZEROES_OPTIONS__MAX,
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
&local_error);
if (local_error) {
error_propagate(errp, local_error);
return;
}
if (bdrv_flags &&
*detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
!(*bdrv_flags & BDRV_O_UNMAP))
{
error_setg(errp, "setting detect-zeroes to unmap is not allowed "
"without setting discard operation to unmap");
return;
}
}
}
| false | qemu | d5851089a8a77d5c23e8d5fffb5b99265009ba62 | static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
const char **throttling_group, ThrottleConfig *throttle_cfg,
BlockdevDetectZeroesOptions *detect_zeroes, Error **errp)
{
const char *discard;
Error *local_error = NULL;
const char *aio;
if (bdrv_flags) {
if (!qemu_opt_get_bool(opts, "read-only", false)) {
*bdrv_flags |= BDRV_O_RDWR;
}
if (qemu_opt_get_bool(opts, "copy-on-read", false)) {
*bdrv_flags |= BDRV_O_COPY_ON_READ;
}
if ((discard = qemu_opt_get(opts, "discard")) != NULL) {
if (bdrv_parse_discard_flags(discard, bdrv_flags) != 0) {
error_setg(errp, "Invalid discard option");
return;
}
}
if ((aio = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(aio, "native")) {
*bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(aio, "threads")) {
} else {
error_setg(errp, "invalid aio option");
return;
}
}
}
if (throttling_group) {
*throttling_group = qemu_opt_get(opts, "throttling.group");
}
if (throttle_cfg) {
memset(throttle_cfg, 0, sizeof(*throttle_cfg));
throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.bps-total", 0);
throttle_cfg->buckets[THROTTLE_BPS_READ].avg =
qemu_opt_get_number(opts, "throttling.bps-read", 0);
throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.bps-write", 0);
throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =
qemu_opt_get_number(opts, "throttling.iops-total", 0);
throttle_cfg->buckets[THROTTLE_OPS_READ].avg =
qemu_opt_get_number(opts, "throttling.iops-read", 0);
throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =
qemu_opt_get_number(opts, "throttling.iops-write", 0);
throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
throttle_cfg->buckets[THROTTLE_BPS_READ].max =
qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =
qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_READ].max =
qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =
qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
throttle_cfg->op_size =
qemu_opt_get_number(opts, "throttling.iops-size", 0);
if (!check_throttle_config(throttle_cfg, errp)) {
return;
}
}
if (detect_zeroes) {
*detect_zeroes =
qapi_enum_parse(BlockdevDetectZeroesOptions_lookup,
qemu_opt_get(opts, "detect-zeroes"),
BLOCKDEV_DETECT_ZEROES_OPTIONS__MAX,
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
&local_error);
if (local_error) {
error_propagate(errp, local_error);
return;
}
if (bdrv_flags &&
*detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
!(*bdrv_flags & BDRV_O_UNMAP))
{
error_setg(errp, "setting detect-zeroes to unmap is not allowed "
"without setting discard operation to unmap");
return;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QemuOpts *VAR_0, int *VAR_1,
const char **VAR_2, ThrottleConfig *VAR_3,
BlockdevDetectZeroesOptions *VAR_4, Error **VAR_5)
{
const char *VAR_6;
Error *local_error = NULL;
const char *VAR_7;
if (VAR_1) {
if (!qemu_opt_get_bool(VAR_0, "read-only", false)) {
*VAR_1 |= BDRV_O_RDWR;
}
if (qemu_opt_get_bool(VAR_0, "copy-on-read", false)) {
*VAR_1 |= BDRV_O_COPY_ON_READ;
}
if ((VAR_6 = qemu_opt_get(VAR_0, "VAR_6")) != NULL) {
if (bdrv_parse_discard_flags(VAR_6, VAR_1) != 0) {
error_setg(VAR_5, "Invalid VAR_6 option");
return;
}
}
if ((VAR_7 = qemu_opt_get(VAR_0, "VAR_7")) != NULL) {
if (!strcmp(VAR_7, "native")) {
*VAR_1 |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(VAR_7, "threads")) {
} else {
error_setg(VAR_5, "invalid VAR_7 option");
return;
}
}
}
if (VAR_2) {
*VAR_2 = qemu_opt_get(VAR_0, "throttling.group");
}
if (VAR_3) {
memset(VAR_3, 0, sizeof(*VAR_3));
VAR_3->buckets[THROTTLE_BPS_TOTAL].avg =
qemu_opt_get_number(VAR_0, "throttling.bps-total", 0);
VAR_3->buckets[THROTTLE_BPS_READ].avg =
qemu_opt_get_number(VAR_0, "throttling.bps-read", 0);
VAR_3->buckets[THROTTLE_BPS_WRITE].avg =
qemu_opt_get_number(VAR_0, "throttling.bps-write", 0);
VAR_3->buckets[THROTTLE_OPS_TOTAL].avg =
qemu_opt_get_number(VAR_0, "throttling.iops-total", 0);
VAR_3->buckets[THROTTLE_OPS_READ].avg =
qemu_opt_get_number(VAR_0, "throttling.iops-read", 0);
VAR_3->buckets[THROTTLE_OPS_WRITE].avg =
qemu_opt_get_number(VAR_0, "throttling.iops-write", 0);
VAR_3->buckets[THROTTLE_BPS_TOTAL].max =
qemu_opt_get_number(VAR_0, "throttling.bps-total-max", 0);
VAR_3->buckets[THROTTLE_BPS_READ].max =
qemu_opt_get_number(VAR_0, "throttling.bps-read-max", 0);
VAR_3->buckets[THROTTLE_BPS_WRITE].max =
qemu_opt_get_number(VAR_0, "throttling.bps-write-max", 0);
VAR_3->buckets[THROTTLE_OPS_TOTAL].max =
qemu_opt_get_number(VAR_0, "throttling.iops-total-max", 0);
VAR_3->buckets[THROTTLE_OPS_READ].max =
qemu_opt_get_number(VAR_0, "throttling.iops-read-max", 0);
VAR_3->buckets[THROTTLE_OPS_WRITE].max =
qemu_opt_get_number(VAR_0, "throttling.iops-write-max", 0);
VAR_3->op_size =
qemu_opt_get_number(VAR_0, "throttling.iops-size", 0);
if (!check_throttle_config(VAR_3, VAR_5)) {
return;
}
}
if (VAR_4) {
*VAR_4 =
qapi_enum_parse(BlockdevDetectZeroesOptions_lookup,
qemu_opt_get(VAR_0, "detect-zeroes"),
BLOCKDEV_DETECT_ZEROES_OPTIONS__MAX,
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
&local_error);
if (local_error) {
error_propagate(VAR_5, local_error);
return;
}
if (VAR_1 &&
*VAR_4 == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
!(*VAR_1 & BDRV_O_UNMAP))
{
error_setg(VAR_5, "setting detect-zeroes to unmap is not allowed "
"without setting VAR_6 operation to unmap");
return;
}
}
}
| [
"static void FUNC_0(QemuOpts *VAR_0, int *VAR_1,\nconst char **VAR_2, ThrottleConfig *VAR_3,\nBlockdevDetectZeroesOptions *VAR_4, Error **VAR_5)\n{",
"const char *VAR_6;",
"Error *local_error = NULL;",
"const char *VAR_7;",
"if (VAR_1) {",
"if (!qemu_opt_get_bool(VAR_0, \"read-only\", false)) {",
"*VAR_1 |= BDRV_O_RDWR;",
"}",
"if (qemu_opt_get_bool(VAR_0, \"copy-on-read\", false)) {",
"*VAR_1 |= BDRV_O_COPY_ON_READ;",
"}",
"if ((VAR_6 = qemu_opt_get(VAR_0, \"VAR_6\")) != NULL) {",
"if (bdrv_parse_discard_flags(VAR_6, VAR_1) != 0) {",
"error_setg(VAR_5, \"Invalid VAR_6 option\");",
"return;",
"}",
"}",
"if ((VAR_7 = qemu_opt_get(VAR_0, \"VAR_7\")) != NULL) {",
"if (!strcmp(VAR_7, \"native\")) {",
"*VAR_1 |= BDRV_O_NATIVE_AIO;",
"} else if (!strcmp(VAR_7, \"threads\")) {",
"} else {",
"error_setg(VAR_5, \"invalid VAR_7 option\");",
"return;",
"}",
"}",
"}",
"if (VAR_2) {",
"*VAR_2 = qemu_opt_get(VAR_0, \"throttling.group\");",
"}",
"if (VAR_3) {",
"memset(VAR_3, 0, sizeof(*VAR_3));",
"VAR_3->buckets[THROTTLE_BPS_TOTAL].avg =\nqemu_opt_get_number(VAR_0, \"throttling.bps-total\", 0);",
"VAR_3->buckets[THROTTLE_BPS_READ].avg =\nqemu_opt_get_number(VAR_0, \"throttling.bps-read\", 0);",
"VAR_3->buckets[THROTTLE_BPS_WRITE].avg =\nqemu_opt_get_number(VAR_0, \"throttling.bps-write\", 0);",
"VAR_3->buckets[THROTTLE_OPS_TOTAL].avg =\nqemu_opt_get_number(VAR_0, \"throttling.iops-total\", 0);",
"VAR_3->buckets[THROTTLE_OPS_READ].avg =\nqemu_opt_get_number(VAR_0, \"throttling.iops-read\", 0);",
"VAR_3->buckets[THROTTLE_OPS_WRITE].avg =\nqemu_opt_get_number(VAR_0, \"throttling.iops-write\", 0);",
"VAR_3->buckets[THROTTLE_BPS_TOTAL].max =\nqemu_opt_get_number(VAR_0, \"throttling.bps-total-max\", 0);",
"VAR_3->buckets[THROTTLE_BPS_READ].max =\nqemu_opt_get_number(VAR_0, \"throttling.bps-read-max\", 0);",
"VAR_3->buckets[THROTTLE_BPS_WRITE].max =\nqemu_opt_get_number(VAR_0, \"throttling.bps-write-max\", 0);",
"VAR_3->buckets[THROTTLE_OPS_TOTAL].max =\nqemu_opt_get_number(VAR_0, \"throttling.iops-total-max\", 0);",
"VAR_3->buckets[THROTTLE_OPS_READ].max =\nqemu_opt_get_number(VAR_0, \"throttling.iops-read-max\", 0);",
"VAR_3->buckets[THROTTLE_OPS_WRITE].max =\nqemu_opt_get_number(VAR_0, \"throttling.iops-write-max\", 0);",
"VAR_3->op_size =\nqemu_opt_get_number(VAR_0, \"throttling.iops-size\", 0);",
"if (!check_throttle_config(VAR_3, VAR_5)) {",
"return;",
"}",
"}",
"if (VAR_4) {",
"*VAR_4 =\nqapi_enum_parse(BlockdevDetectZeroesOptions_lookup,\nqemu_opt_get(VAR_0, \"detect-zeroes\"),\nBLOCKDEV_DETECT_ZEROES_OPTIONS__MAX,\nBLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,\n&local_error);",
"if (local_error) {",
"error_propagate(VAR_5, local_error);",
"return;",
"}",
"if (VAR_1 &&\n*VAR_4 == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&\n!(*VAR_1 & BDRV_O_UNMAP))\n{",
"error_setg(VAR_5, \"setting detect-zeroes to unmap is not allowed \"\n\"without setting VAR_6 operation to unmap\");",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89,
91
],
[
93,
95
],
[
97,
99
],
[
101,
103
],
[
105,
107
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
131,
133
],
[
137,
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155,
157,
159,
161,
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177,
179,
181,
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
]
] |
25,361 | static inline void tcg_out_dat_rI(TCGContext *s, int cond, int opc, TCGArg dst,
TCGArg lhs, TCGArg rhs, int rhs_is_const)
{
/* Emit either the reg,imm or reg,reg form of a data-processing insn.
* rhs must satisfy the "rI" constraint.
*/
if (rhs_is_const) {
int rot = encode_imm(rhs);
assert(rot >= 0);
tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7));
} else {
tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0));
}
}
| false | qemu | eabb7b91b36b202b4dac2df2d59d698e3aff197a | static inline void tcg_out_dat_rI(TCGContext *s, int cond, int opc, TCGArg dst,
TCGArg lhs, TCGArg rhs, int rhs_is_const)
{
if (rhs_is_const) {
int rot = encode_imm(rhs);
assert(rot >= 0);
tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7));
} else {
tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0));
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGContext *VAR_0, int VAR_1, int VAR_2, TCGArg VAR_3,
TCGArg VAR_4, TCGArg VAR_5, int VAR_6)
{
if (VAR_6) {
int VAR_7 = encode_imm(VAR_5);
assert(VAR_7 >= 0);
tcg_out_dat_imm(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, rotl(VAR_5, VAR_7) | (VAR_7 << 7));
} else {
tcg_out_dat_reg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, SHIFT_IMM_LSL(0));
}
}
| [
"static inline void FUNC_0(TCGContext *VAR_0, int VAR_1, int VAR_2, TCGArg VAR_3,\nTCGArg VAR_4, TCGArg VAR_5, int VAR_6)\n{",
"if (VAR_6) {",
"int VAR_7 = encode_imm(VAR_5);",
"assert(VAR_7 >= 0);",
"tcg_out_dat_imm(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, rotl(VAR_5, VAR_7) | (VAR_7 << 7));",
"} else {",
"tcg_out_dat_reg(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, SHIFT_IMM_LSL(0));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,362 | static always_inline void gen_bcond (DisasContext *ctx,
TCGCond cond,
int ra, int32_t disp16, int mask)
{
int l1, l2;
l1 = gen_new_label();
l2 = gen_new_label();
if (likely(ra != 31)) {
if (mask) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
tcg_gen_brcondi_i64(cond, tmp, 0, l1);
tcg_temp_free(tmp);
} else
tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, l1);
} else {
/* Very uncommon case - Do not bother to optimize. */
TCGv tmp = tcg_const_i64(0);
tcg_gen_brcondi_i64(cond, tmp, 0, l1);
tcg_temp_free(tmp);
}
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));
gen_set_label(l2);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static always_inline void gen_bcond (DisasContext *ctx,
TCGCond cond,
int ra, int32_t disp16, int mask)
{
int l1, l2;
l1 = gen_new_label();
l2 = gen_new_label();
if (likely(ra != 31)) {
if (mask) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
tcg_gen_brcondi_i64(cond, tmp, 0, l1);
tcg_temp_free(tmp);
} else
tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, l1);
} else {
TCGv tmp = tcg_const_i64(0);
tcg_gen_brcondi_i64(cond, tmp, 0, l1);
tcg_temp_free(tmp);
}
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));
gen_set_label(l2);
}
| {
"code": [],
"line_no": []
} | static always_inline void FUNC_0 (DisasContext *ctx,
TCGCond cond,
int ra, int32_t disp16, int mask)
{
int VAR_0, VAR_1;
VAR_0 = gen_new_label();
VAR_1 = gen_new_label();
if (likely(ra != 31)) {
if (mask) {
TCGv tmp = tcg_temp_new(TCG_TYPE_I64);
tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
tcg_gen_brcondi_i64(cond, tmp, 0, VAR_0);
tcg_temp_free(tmp);
} else
tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, VAR_0);
} else {
TCGv tmp = tcg_const_i64(0);
tcg_gen_brcondi_i64(cond, tmp, 0, VAR_0);
tcg_temp_free(tmp);
}
tcg_gen_movi_i64(cpu_pc, ctx->pc);
tcg_gen_br(VAR_1);
gen_set_label(VAR_0);
tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));
gen_set_label(VAR_1);
}
| [
"static always_inline void FUNC_0 (DisasContext *ctx,\nTCGCond cond,\nint ra, int32_t disp16, int mask)\n{",
"int VAR_0, VAR_1;",
"VAR_0 = gen_new_label();",
"VAR_1 = gen_new_label();",
"if (likely(ra != 31)) {",
"if (mask) {",
"TCGv tmp = tcg_temp_new(TCG_TYPE_I64);",
"tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);",
"tcg_gen_brcondi_i64(cond, tmp, 0, VAR_0);",
"tcg_temp_free(tmp);",
"} else",
"tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, VAR_0);",
"} else {",
"TCGv tmp = tcg_const_i64(0);",
"tcg_gen_brcondi_i64(cond, tmp, 0, VAR_0);",
"tcg_temp_free(tmp);",
"}",
"tcg_gen_movi_i64(cpu_pc, ctx->pc);",
"tcg_gen_br(VAR_1);",
"gen_set_label(VAR_0);",
"tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));",
"gen_set_label(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
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
25,364 | void qemu_aio_set_event_notifier(EventNotifier *notifier,
EventNotifierHandler *io_read,
AioFlushEventNotifierHandler *io_flush)
{
qemu_aio_set_fd_handler(event_notifier_get_fd(notifier),
(IOHandler *)io_read, NULL,
(AioFlushHandler *)io_flush, notifier);
}
| false | qemu | 82cbbdc6a0958b49c77639a60906e30d02e6bb7b | void qemu_aio_set_event_notifier(EventNotifier *notifier,
EventNotifierHandler *io_read,
AioFlushEventNotifierHandler *io_flush)
{
qemu_aio_set_fd_handler(event_notifier_get_fd(notifier),
(IOHandler *)io_read, NULL,
(AioFlushHandler *)io_flush, notifier);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(EventNotifier *VAR_0,
EventNotifierHandler *VAR_1,
AioFlushEventNotifierHandler *VAR_2)
{
qemu_aio_set_fd_handler(event_notifier_get_fd(VAR_0),
(IOHandler *)VAR_1, NULL,
(AioFlushHandler *)VAR_2, VAR_0);
}
| [
"void FUNC_0(EventNotifier *VAR_0,\nEventNotifierHandler *VAR_1,\nAioFlushEventNotifierHandler *VAR_2)\n{",
"qemu_aio_set_fd_handler(event_notifier_get_fd(VAR_0),\n(IOHandler *)VAR_1, NULL,\n(AioFlushHandler *)VAR_2, VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11,
13
],
[
15
]
] |
25,365 | uint32_t HELPER(lpebr)(CPUS390XState *env, uint32_t f1, uint32_t f2)
{
float32 v1;
float32 v2 = env->fregs[f2].d;
v1 = float32_abs(v2);
env->fregs[f1].d = v1;
return set_cc_nz_f32(v1);
}
| false | qemu | 5d7fd045cafeac1831c1999cb9e1251b7906c6b2 | uint32_t HELPER(lpebr)(CPUS390XState *env, uint32_t f1, uint32_t f2)
{
float32 v1;
float32 v2 = env->fregs[f2].d;
v1 = float32_abs(v2);
env->fregs[f1].d = v1;
return set_cc_nz_f32(v1);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(lpebr)(CPUS390XState *env, uint32_t f1, uint32_t f2)
{
float32 v1;
float32 v2 = env->fregs[f2].d;
v1 = float32_abs(v2);
env->fregs[f1].d = v1;
return set_cc_nz_f32(v1);
}
| [
"uint32_t FUNC_0(lpebr)(CPUS390XState *env, uint32_t f1, uint32_t f2)\n{",
"float32 v1;",
"float32 v2 = env->fregs[f2].d;",
"v1 = float32_abs(v2);",
"env->fregs[f1].d = v1;",
"return set_cc_nz_f32(v1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,366 | uint64_t helper_fsel (uint64_t arg1, uint64_t arg2, uint64_t arg3)
{
CPU_DoubleU farg1;
farg1.ll = arg1;
if ((!float64_is_neg(farg1.d) || float64_is_zero(farg1.d)) && !float64_is_nan(farg1.d))
return arg2;
else
return arg3;
}
| false | qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | uint64_t helper_fsel (uint64_t arg1, uint64_t arg2, uint64_t arg3)
{
CPU_DoubleU farg1;
farg1.ll = arg1;
if ((!float64_is_neg(farg1.d) || float64_is_zero(farg1.d)) && !float64_is_nan(farg1.d))
return arg2;
else
return arg3;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (uint64_t arg1, uint64_t arg2, uint64_t arg3)
{
CPU_DoubleU farg1;
farg1.ll = arg1;
if ((!float64_is_neg(farg1.d) || float64_is_zero(farg1.d)) && !float64_is_nan(farg1.d))
return arg2;
else
return arg3;
}
| [
"uint64_t FUNC_0 (uint64_t arg1, uint64_t arg2, uint64_t arg3)\n{",
"CPU_DoubleU farg1;",
"farg1.ll = arg1;",
"if ((!float64_is_neg(farg1.d) || float64_is_zero(farg1.d)) && !float64_is_nan(farg1.d))\nreturn arg2;",
"else\nreturn arg3;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
]
] |
25,367 | static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
{
int dir;
size_t len = 0, pktlen = 0;
#ifdef DEBUG_PACKET
const char *str = NULL;
#endif
int pid;
int ret;
int i;
USBDevice *dev;
struct ohci_td td;
uint32_t addr;
int flag_r;
int completion;
addr = ed->head & OHCI_DPTR_MASK;
/* See if this TD has already been submitted to the device. */
completion = (addr == ohci->async_td);
if (completion && !ohci->async_complete) {
#ifdef DEBUG_PACKET
DPRINTF("Skipping async TD\n");
#endif
return 1;
}
if (!ohci_read_td(ohci, addr, &td)) {
fprintf(stderr, "usb-ohci: TD read error at %x\n", addr);
return 0;
}
dir = OHCI_BM(ed->flags, ED_D);
switch (dir) {
case OHCI_TD_DIR_OUT:
case OHCI_TD_DIR_IN:
/* Same value. */
break;
default:
dir = OHCI_BM(td.flags, TD_DP);
break;
}
switch (dir) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_PACKET
str = "in";
#endif
pid = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_PACKET
str = "out";
#endif
pid = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_PACKET
str = "setup";
#endif
pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "usb-ohci: Bad direction\n");
return 1;
}
if (td.cbp && td.be) {
if ((td.cbp & 0xfffff000) != (td.be & 0xfffff000)) {
len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff);
} else {
len = (td.be - td.cbp) + 1;
}
pktlen = len;
if (len && dir != OHCI_TD_DIR_IN) {
/* The endpoint may not allow us to transfer it all now */
pktlen = (ed->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT;
if (pktlen > len) {
pktlen = len;
}
if (!completion) {
ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen, 0);
}
}
}
flag_r = (td.flags & OHCI_TD_R) != 0;
#ifdef DEBUG_PACKET
DPRINTF(" TD @ 0x%.8x %" PRId64 " of %" PRId64
" bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
addr, (int64_t)pktlen, (int64_t)len, str, flag_r, td.cbp, td.be);
if (pktlen > 0 && dir != OHCI_TD_DIR_IN) {
DPRINTF(" data:");
for (i = 0; i < pktlen; i++) {
printf(" %.2x", ohci->usb_buf[i]);
}
DPRINTF("\n");
}
#endif
if (completion) {
ret = ohci->usb_packet.result;
ohci->async_td = 0;
ohci->async_complete = 0;
} else {
if (ohci->async_td) {
/* ??? The hardware should allow one active packet per
endpoint. We only allow one active packet per controller.
This should be sufficient as long as devices respond in a
timely manner.
*/
#ifdef DEBUG_PACKET
DPRINTF("Too many pending packets\n");
#endif
return 1;
}
usb_packet_setup(&ohci->usb_packet, pid,
OHCI_BM(ed->flags, ED_FA),
OHCI_BM(ed->flags, ED_EN));
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen);
dev = ohci_find_device(ohci, ohci->usb_packet.devaddr);
ret = usb_handle_packet(dev, &ohci->usb_packet);
#ifdef DEBUG_PACKET
DPRINTF("ret=%d\n", ret);
#endif
if (ret == USB_RET_ASYNC) {
ohci->async_td = addr;
return 1;
}
}
if (ret >= 0) {
if (dir == OHCI_TD_DIR_IN) {
ohci_copy_td(ohci, &td, ohci->usb_buf, ret, 1);
#ifdef DEBUG_PACKET
DPRINTF(" data:");
for (i = 0; i < ret; i++)
printf(" %.2x", ohci->usb_buf[i]);
DPRINTF("\n");
#endif
} else {
ret = pktlen;
}
}
/* Writeback */
if (ret == pktlen || (dir == OHCI_TD_DIR_IN && ret >= 0 && flag_r)) {
/* Transmission succeeded. */
if (ret == len) {
td.cbp = 0;
} else {
if ((td.cbp & 0xfff) + ret > 0xfff) {
td.cbp = (td.be & ~0xfff) + ((td.cbp + ret) & 0xfff);
} else {
td.cbp += ret;
}
}
td.flags |= OHCI_TD_T1;
td.flags ^= OHCI_TD_T0;
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_NOERROR);
OHCI_SET_BM(td.flags, TD_EC, 0);
if ((dir != OHCI_TD_DIR_IN) && (ret != len)) {
/* Partial packet transfer: TD not ready to retire yet */
goto exit_no_retire;
}
/* Setting ED_C is part of the TD retirement process */
ed->head &= ~OHCI_ED_C;
if (td.flags & OHCI_TD_T0)
ed->head |= OHCI_ED_C;
} else {
if (ret >= 0) {
DPRINTF("usb-ohci: Underrun\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAUNDERRUN);
} else {
switch (ret) {
case USB_RET_NODEV:
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);
case USB_RET_NAK:
DPRINTF("usb-ohci: got NAK\n");
return 1;
case USB_RET_STALL:
DPRINTF("usb-ohci: got STALL\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_STALL);
break;
case USB_RET_BABBLE:
DPRINTF("usb-ohci: got BABBLE\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
break;
default:
fprintf(stderr, "usb-ohci: Bad device response %d\n", ret);
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_UNDEXPETEDPID);
OHCI_SET_BM(td.flags, TD_EC, 3);
break;
}
}
ed->head |= OHCI_ED_H;
}
/* Retire this TD */
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= td.next & OHCI_DPTR_MASK;
td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
exit_no_retire:
ohci_put_td(ohci, addr, &td);
return OHCI_BM(td.flags, TD_CC) != OHCI_CC_NOERROR;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
{
int dir;
size_t len = 0, pktlen = 0;
#ifdef DEBUG_PACKET
const char *str = NULL;
#endif
int pid;
int ret;
int i;
USBDevice *dev;
struct ohci_td td;
uint32_t addr;
int flag_r;
int completion;
addr = ed->head & OHCI_DPTR_MASK;
completion = (addr == ohci->async_td);
if (completion && !ohci->async_complete) {
#ifdef DEBUG_PACKET
DPRINTF("Skipping async TD\n");
#endif
return 1;
}
if (!ohci_read_td(ohci, addr, &td)) {
fprintf(stderr, "usb-ohci: TD read error at %x\n", addr);
return 0;
}
dir = OHCI_BM(ed->flags, ED_D);
switch (dir) {
case OHCI_TD_DIR_OUT:
case OHCI_TD_DIR_IN:
break;
default:
dir = OHCI_BM(td.flags, TD_DP);
break;
}
switch (dir) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_PACKET
str = "in";
#endif
pid = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_PACKET
str = "out";
#endif
pid = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_PACKET
str = "setup";
#endif
pid = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "usb-ohci: Bad direction\n");
return 1;
}
if (td.cbp && td.be) {
if ((td.cbp & 0xfffff000) != (td.be & 0xfffff000)) {
len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff);
} else {
len = (td.be - td.cbp) + 1;
}
pktlen = len;
if (len && dir != OHCI_TD_DIR_IN) {
pktlen = (ed->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT;
if (pktlen > len) {
pktlen = len;
}
if (!completion) {
ohci_copy_td(ohci, &td, ohci->usb_buf, pktlen, 0);
}
}
}
flag_r = (td.flags & OHCI_TD_R) != 0;
#ifdef DEBUG_PACKET
DPRINTF(" TD @ 0x%.8x %" PRId64 " of %" PRId64
" bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
addr, (int64_t)pktlen, (int64_t)len, str, flag_r, td.cbp, td.be);
if (pktlen > 0 && dir != OHCI_TD_DIR_IN) {
DPRINTF(" data:");
for (i = 0; i < pktlen; i++) {
printf(" %.2x", ohci->usb_buf[i]);
}
DPRINTF("\n");
}
#endif
if (completion) {
ret = ohci->usb_packet.result;
ohci->async_td = 0;
ohci->async_complete = 0;
} else {
if (ohci->async_td) {
#ifdef DEBUG_PACKET
DPRINTF("Too many pending packets\n");
#endif
return 1;
}
usb_packet_setup(&ohci->usb_packet, pid,
OHCI_BM(ed->flags, ED_FA),
OHCI_BM(ed->flags, ED_EN));
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen);
dev = ohci_find_device(ohci, ohci->usb_packet.devaddr);
ret = usb_handle_packet(dev, &ohci->usb_packet);
#ifdef DEBUG_PACKET
DPRINTF("ret=%d\n", ret);
#endif
if (ret == USB_RET_ASYNC) {
ohci->async_td = addr;
return 1;
}
}
if (ret >= 0) {
if (dir == OHCI_TD_DIR_IN) {
ohci_copy_td(ohci, &td, ohci->usb_buf, ret, 1);
#ifdef DEBUG_PACKET
DPRINTF(" data:");
for (i = 0; i < ret; i++)
printf(" %.2x", ohci->usb_buf[i]);
DPRINTF("\n");
#endif
} else {
ret = pktlen;
}
}
if (ret == pktlen || (dir == OHCI_TD_DIR_IN && ret >= 0 && flag_r)) {
if (ret == len) {
td.cbp = 0;
} else {
if ((td.cbp & 0xfff) + ret > 0xfff) {
td.cbp = (td.be & ~0xfff) + ((td.cbp + ret) & 0xfff);
} else {
td.cbp += ret;
}
}
td.flags |= OHCI_TD_T1;
td.flags ^= OHCI_TD_T0;
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_NOERROR);
OHCI_SET_BM(td.flags, TD_EC, 0);
if ((dir != OHCI_TD_DIR_IN) && (ret != len)) {
goto exit_no_retire;
}
ed->head &= ~OHCI_ED_C;
if (td.flags & OHCI_TD_T0)
ed->head |= OHCI_ED_C;
} else {
if (ret >= 0) {
DPRINTF("usb-ohci: Underrun\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAUNDERRUN);
} else {
switch (ret) {
case USB_RET_NODEV:
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);
case USB_RET_NAK:
DPRINTF("usb-ohci: got NAK\n");
return 1;
case USB_RET_STALL:
DPRINTF("usb-ohci: got STALL\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_STALL);
break;
case USB_RET_BABBLE:
DPRINTF("usb-ohci: got BABBLE\n");
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
break;
default:
fprintf(stderr, "usb-ohci: Bad device response %d\n", ret);
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_UNDEXPETEDPID);
OHCI_SET_BM(td.flags, TD_EC, 3);
break;
}
}
ed->head |= OHCI_ED_H;
}
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= td.next & OHCI_DPTR_MASK;
td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
exit_no_retire:
ohci_put_td(ohci, addr, &td);
return OHCI_BM(td.flags, TD_CC) != OHCI_CC_NOERROR;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OHCIState *VAR_0, struct ohci_ed *VAR_1)
{
int VAR_2;
size_t len = 0, pktlen = 0;
#ifdef DEBUG_PACKET
const char *str = NULL;
#endif
int VAR_3;
int VAR_4;
int VAR_5;
USBDevice *dev;
struct ohci_td VAR_6;
uint32_t addr;
int VAR_7;
int VAR_8;
addr = VAR_1->head & OHCI_DPTR_MASK;
VAR_8 = (addr == VAR_0->async_td);
if (VAR_8 && !VAR_0->async_complete) {
#ifdef DEBUG_PACKET
DPRINTF("Skipping async TD\n");
#endif
return 1;
}
if (!ohci_read_td(VAR_0, addr, &VAR_6)) {
fprintf(stderr, "usb-VAR_0: TD read error at %x\n", addr);
return 0;
}
VAR_2 = OHCI_BM(VAR_1->flags, ED_D);
switch (VAR_2) {
case OHCI_TD_DIR_OUT:
case OHCI_TD_DIR_IN:
break;
default:
VAR_2 = OHCI_BM(VAR_6.flags, TD_DP);
break;
}
switch (VAR_2) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_PACKET
str = "in";
#endif
VAR_3 = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_PACKET
str = "out";
#endif
VAR_3 = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_PACKET
str = "setup";
#endif
VAR_3 = USB_TOKEN_SETUP;
break;
default:
fprintf(stderr, "usb-VAR_0: Bad direction\n");
return 1;
}
if (VAR_6.cbp && VAR_6.be) {
if ((VAR_6.cbp & 0xfffff000) != (VAR_6.be & 0xfffff000)) {
len = (VAR_6.be & 0xfff) + 0x1001 - (VAR_6.cbp & 0xfff);
} else {
len = (VAR_6.be - VAR_6.cbp) + 1;
}
pktlen = len;
if (len && VAR_2 != OHCI_TD_DIR_IN) {
pktlen = (VAR_1->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT;
if (pktlen > len) {
pktlen = len;
}
if (!VAR_8) {
ohci_copy_td(VAR_0, &VAR_6, VAR_0->usb_buf, pktlen, 0);
}
}
}
VAR_7 = (VAR_6.flags & OHCI_TD_R) != 0;
#ifdef DEBUG_PACKET
DPRINTF(" TD @ 0x%.8x %" PRId64 " of %" PRId64
" bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
addr, (int64_t)pktlen, (int64_t)len, str, VAR_7, VAR_6.cbp, VAR_6.be);
if (pktlen > 0 && VAR_2 != OHCI_TD_DIR_IN) {
DPRINTF(" data:");
for (VAR_5 = 0; VAR_5 < pktlen; VAR_5++) {
printf(" %.2x", VAR_0->usb_buf[VAR_5]);
}
DPRINTF("\n");
}
#endif
if (VAR_8) {
VAR_4 = VAR_0->usb_packet.result;
VAR_0->async_td = 0;
VAR_0->async_complete = 0;
} else {
if (VAR_0->async_td) {
#ifdef DEBUG_PACKET
DPRINTF("Too many pending packets\n");
#endif
return 1;
}
usb_packet_setup(&VAR_0->usb_packet, VAR_3,
OHCI_BM(VAR_1->flags, ED_FA),
OHCI_BM(VAR_1->flags, ED_EN));
usb_packet_addbuf(&VAR_0->usb_packet, VAR_0->usb_buf, pktlen);
dev = ohci_find_device(VAR_0, VAR_0->usb_packet.devaddr);
VAR_4 = usb_handle_packet(dev, &VAR_0->usb_packet);
#ifdef DEBUG_PACKET
DPRINTF("VAR_4=%d\n", VAR_4);
#endif
if (VAR_4 == USB_RET_ASYNC) {
VAR_0->async_td = addr;
return 1;
}
}
if (VAR_4 >= 0) {
if (VAR_2 == OHCI_TD_DIR_IN) {
ohci_copy_td(VAR_0, &VAR_6, VAR_0->usb_buf, VAR_4, 1);
#ifdef DEBUG_PACKET
DPRINTF(" data:");
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)
printf(" %.2x", VAR_0->usb_buf[VAR_5]);
DPRINTF("\n");
#endif
} else {
VAR_4 = pktlen;
}
}
if (VAR_4 == pktlen || (VAR_2 == OHCI_TD_DIR_IN && VAR_4 >= 0 && VAR_7)) {
if (VAR_4 == len) {
VAR_6.cbp = 0;
} else {
if ((VAR_6.cbp & 0xfff) + VAR_4 > 0xfff) {
VAR_6.cbp = (VAR_6.be & ~0xfff) + ((VAR_6.cbp + VAR_4) & 0xfff);
} else {
VAR_6.cbp += VAR_4;
}
}
VAR_6.flags |= OHCI_TD_T1;
VAR_6.flags ^= OHCI_TD_T0;
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_NOERROR);
OHCI_SET_BM(VAR_6.flags, TD_EC, 0);
if ((VAR_2 != OHCI_TD_DIR_IN) && (VAR_4 != len)) {
goto exit_no_retire;
}
VAR_1->head &= ~OHCI_ED_C;
if (VAR_6.flags & OHCI_TD_T0)
VAR_1->head |= OHCI_ED_C;
} else {
if (VAR_4 >= 0) {
DPRINTF("usb-VAR_0: Underrun\n");
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DATAUNDERRUN);
} else {
switch (VAR_4) {
case USB_RET_NODEV:
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);
case USB_RET_NAK:
DPRINTF("usb-VAR_0: got NAK\n");
return 1;
case USB_RET_STALL:
DPRINTF("usb-VAR_0: got STALL\n");
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_STALL);
break;
case USB_RET_BABBLE:
DPRINTF("usb-VAR_0: got BABBLE\n");
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DATAOVERRUN);
break;
default:
fprintf(stderr, "usb-VAR_0: Bad device response %d\n", VAR_4);
OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_UNDEXPETEDPID);
OHCI_SET_BM(VAR_6.flags, TD_EC, 3);
break;
}
}
VAR_1->head |= OHCI_ED_H;
}
VAR_1->head &= ~OHCI_DPTR_MASK;
VAR_1->head |= VAR_6.next & OHCI_DPTR_MASK;
VAR_6.next = VAR_0->done;
VAR_0->done = addr;
VAR_5 = OHCI_BM(VAR_6.flags, TD_DI);
if (VAR_5 < VAR_0->done_count)
VAR_0->done_count = VAR_5;
exit_no_retire:
ohci_put_td(VAR_0, addr, &VAR_6);
return OHCI_BM(VAR_6.flags, TD_CC) != OHCI_CC_NOERROR;
}
| [
"static int FUNC_0(OHCIState *VAR_0, struct ohci_ed *VAR_1)\n{",
"int VAR_2;",
"size_t len = 0, pktlen = 0;",
"#ifdef DEBUG_PACKET\nconst char *str = NULL;",
"#endif\nint VAR_3;",
"int VAR_4;",
"int VAR_5;",
"USBDevice *dev;",
"struct ohci_td VAR_6;",
"uint32_t addr;",
"int VAR_7;",
"int VAR_8;",
"addr = VAR_1->head & OHCI_DPTR_MASK;",
"VAR_8 = (addr == VAR_0->async_td);",
"if (VAR_8 && !VAR_0->async_complete) {",
"#ifdef DEBUG_PACKET\nDPRINTF(\"Skipping async TD\\n\");",
"#endif\nreturn 1;",
"}",
"if (!ohci_read_td(VAR_0, addr, &VAR_6)) {",
"fprintf(stderr, \"usb-VAR_0: TD read error at %x\\n\", addr);",
"return 0;",
"}",
"VAR_2 = OHCI_BM(VAR_1->flags, ED_D);",
"switch (VAR_2) {",
"case OHCI_TD_DIR_OUT:\ncase OHCI_TD_DIR_IN:\nbreak;",
"default:\nVAR_2 = OHCI_BM(VAR_6.flags, TD_DP);",
"break;",
"}",
"switch (VAR_2) {",
"case OHCI_TD_DIR_IN:\n#ifdef DEBUG_PACKET\nstr = \"in\";",
"#endif\nVAR_3 = USB_TOKEN_IN;",
"break;",
"case OHCI_TD_DIR_OUT:\n#ifdef DEBUG_PACKET\nstr = \"out\";",
"#endif\nVAR_3 = USB_TOKEN_OUT;",
"break;",
"case OHCI_TD_DIR_SETUP:\n#ifdef DEBUG_PACKET\nstr = \"setup\";",
"#endif\nVAR_3 = USB_TOKEN_SETUP;",
"break;",
"default:\nfprintf(stderr, \"usb-VAR_0: Bad direction\\n\");",
"return 1;",
"}",
"if (VAR_6.cbp && VAR_6.be) {",
"if ((VAR_6.cbp & 0xfffff000) != (VAR_6.be & 0xfffff000)) {",
"len = (VAR_6.be & 0xfff) + 0x1001 - (VAR_6.cbp & 0xfff);",
"} else {",
"len = (VAR_6.be - VAR_6.cbp) + 1;",
"}",
"pktlen = len;",
"if (len && VAR_2 != OHCI_TD_DIR_IN) {",
"pktlen = (VAR_1->flags & OHCI_ED_MPS_MASK) >> OHCI_ED_MPS_SHIFT;",
"if (pktlen > len) {",
"pktlen = len;",
"}",
"if (!VAR_8) {",
"ohci_copy_td(VAR_0, &VAR_6, VAR_0->usb_buf, pktlen, 0);",
"}",
"}",
"}",
"VAR_7 = (VAR_6.flags & OHCI_TD_R) != 0;",
"#ifdef DEBUG_PACKET\nDPRINTF(\" TD @ 0x%.8x %\" PRId64 \" of %\" PRId64\n\" bytes %s r=%d cbp=0x%.8x be=0x%.8x\\n\",\naddr, (int64_t)pktlen, (int64_t)len, str, VAR_7, VAR_6.cbp, VAR_6.be);",
"if (pktlen > 0 && VAR_2 != OHCI_TD_DIR_IN) {",
"DPRINTF(\" data:\");",
"for (VAR_5 = 0; VAR_5 < pktlen; VAR_5++) {",
"printf(\" %.2x\", VAR_0->usb_buf[VAR_5]);",
"}",
"DPRINTF(\"\\n\");",
"}",
"#endif\nif (VAR_8) {",
"VAR_4 = VAR_0->usb_packet.result;",
"VAR_0->async_td = 0;",
"VAR_0->async_complete = 0;",
"} else {",
"if (VAR_0->async_td) {",
"#ifdef DEBUG_PACKET\nDPRINTF(\"Too many pending packets\\n\");",
"#endif\nreturn 1;",
"}",
"usb_packet_setup(&VAR_0->usb_packet, VAR_3,\nOHCI_BM(VAR_1->flags, ED_FA),\nOHCI_BM(VAR_1->flags, ED_EN));",
"usb_packet_addbuf(&VAR_0->usb_packet, VAR_0->usb_buf, pktlen);",
"dev = ohci_find_device(VAR_0, VAR_0->usb_packet.devaddr);",
"VAR_4 = usb_handle_packet(dev, &VAR_0->usb_packet);",
"#ifdef DEBUG_PACKET\nDPRINTF(\"VAR_4=%d\\n\", VAR_4);",
"#endif\nif (VAR_4 == USB_RET_ASYNC) {",
"VAR_0->async_td = addr;",
"return 1;",
"}",
"}",
"if (VAR_4 >= 0) {",
"if (VAR_2 == OHCI_TD_DIR_IN) {",
"ohci_copy_td(VAR_0, &VAR_6, VAR_0->usb_buf, VAR_4, 1);",
"#ifdef DEBUG_PACKET\nDPRINTF(\" data:\");",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)",
"printf(\" %.2x\", VAR_0->usb_buf[VAR_5]);",
"DPRINTF(\"\\n\");",
"#endif\n} else {",
"VAR_4 = pktlen;",
"}",
"}",
"if (VAR_4 == pktlen || (VAR_2 == OHCI_TD_DIR_IN && VAR_4 >= 0 && VAR_7)) {",
"if (VAR_4 == len) {",
"VAR_6.cbp = 0;",
"} else {",
"if ((VAR_6.cbp & 0xfff) + VAR_4 > 0xfff) {",
"VAR_6.cbp = (VAR_6.be & ~0xfff) + ((VAR_6.cbp + VAR_4) & 0xfff);",
"} else {",
"VAR_6.cbp += VAR_4;",
"}",
"}",
"VAR_6.flags |= OHCI_TD_T1;",
"VAR_6.flags ^= OHCI_TD_T0;",
"OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_NOERROR);",
"OHCI_SET_BM(VAR_6.flags, TD_EC, 0);",
"if ((VAR_2 != OHCI_TD_DIR_IN) && (VAR_4 != len)) {",
"goto exit_no_retire;",
"}",
"VAR_1->head &= ~OHCI_ED_C;",
"if (VAR_6.flags & OHCI_TD_T0)\nVAR_1->head |= OHCI_ED_C;",
"} else {",
"if (VAR_4 >= 0) {",
"DPRINTF(\"usb-VAR_0: Underrun\\n\");",
"OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DATAUNDERRUN);",
"} else {",
"switch (VAR_4) {",
"case USB_RET_NODEV:\nOHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);",
"case USB_RET_NAK:\nDPRINTF(\"usb-VAR_0: got NAK\\n\");",
"return 1;",
"case USB_RET_STALL:\nDPRINTF(\"usb-VAR_0: got STALL\\n\");",
"OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_STALL);",
"break;",
"case USB_RET_BABBLE:\nDPRINTF(\"usb-VAR_0: got BABBLE\\n\");",
"OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_DATAOVERRUN);",
"break;",
"default:\nfprintf(stderr, \"usb-VAR_0: Bad device response %d\\n\", VAR_4);",
"OHCI_SET_BM(VAR_6.flags, TD_CC, OHCI_CC_UNDEXPETEDPID);",
"OHCI_SET_BM(VAR_6.flags, TD_EC, 3);",
"break;",
"}",
"}",
"VAR_1->head |= OHCI_ED_H;",
"}",
"VAR_1->head &= ~OHCI_DPTR_MASK;",
"VAR_1->head |= VAR_6.next & OHCI_DPTR_MASK;",
"VAR_6.next = VAR_0->done;",
"VAR_0->done = addr;",
"VAR_5 = OHCI_BM(VAR_6.flags, TD_DI);",
"if (VAR_5 < VAR_0->done_count)\nVAR_0->done_count = VAR_5;",
"exit_no_retire:\nohci_put_td(VAR_0, addr, &VAR_6);",
"return OHCI_BM(VAR_6.flags, TD_CC) != OHCI_CC_NOERROR;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65,
67,
71
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
85,
87,
89
],
[
91,
93
],
[
95
],
[
97,
99,
101
],
[
103,
105
],
[
107
],
[
109,
111,
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171,
173,
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
219,
221
],
[
223,
225
],
[
227
],
[
229,
231,
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
319
],
[
323
],
[
325
],
[
331
],
[
333,
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351
],
[
353,
355
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409
],
[
411,
413
],
[
415
],
[
417
]
] |
25,369 | static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt) {
GetByteContext gb;
AVFrame * const p = data;
unsigned int version, w, h, d3d_format, depth, stride, flags;
unsigned int y, v;
uint8_t *ptr;
uint32_t *pal;
int ret;
bytestream2_init(&gb, avpkt->data, avpkt->size);
version = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 72);
d3d_format = bytestream2_get_le32(&gb);
w = bytestream2_get_le16(&gb);
h = bytestream2_get_le16(&gb);
depth = bytestream2_get_byte(&gb);
bytestream2_skip(&gb, 2);
flags = bytestream2_get_byte(&gb);
if (version < 8 || version > 9) {
av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
version);
return AVERROR_PATCHWELCOME;
}
if (depth == 8) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else if (depth == 16 || depth == 32) {
avctx->pix_fmt = AV_PIX_FMT_RGB32;
} else {
av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
return AVERROR_PATCHWELCOME;
}
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
if (depth == 8) {
pal = (uint32_t *) p->data[1];
for (y = 0; y < 256; y++) {
v = bytestream2_get_be32(&gb);
pal[y] = (v >> 8) + (v << 24);
}
if (bytestream2_get_bytes_left(&gb) < w * h)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, 4);
for (y=0; y<h; y++) {
bytestream2_get_buffer(&gb, ptr, w);
ptr += stride;
}
} else if (depth == 16) {
bytestream2_skip(&gb, 4);
switch (d3d_format) {
case 0:
if (!(flags & 1))
goto unsupported;
case FF_S3TC_DXT1:
if (bytestream2_get_bytes_left(&gb) < (w/4) * (h/4) * 8)
return AVERROR_INVALIDDATA;
ff_decode_dxt1(&gb, ptr, w, h, stride);
break;
case FF_S3TC_DXT3:
if (bytestream2_get_bytes_left(&gb) < (w/4) * (h/4) * 16)
return AVERROR_INVALIDDATA;
ff_decode_dxt3(&gb, ptr, w, h, stride);
break;
default:
goto unsupported;
}
} else if (depth == 32) {
switch (d3d_format) {
case 0x15:
case 0x16:
if (bytestream2_get_bytes_left(&gb) < h * w * 4)
return AVERROR_INVALIDDATA;
for (y=0; y<h; y++) {
bytestream2_get_buffer(&gb, ptr, w * 4);
ptr += stride;
}
break;
default:
goto unsupported;
}
}
*got_frame = 1;
return avpkt->size;
unsupported:
av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format);
return AVERROR_PATCHWELCOME;
}
| false | FFmpeg | daea3209693f28328ca553fb33fdf8fc2ab42044 | static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt) {
GetByteContext gb;
AVFrame * const p = data;
unsigned int version, w, h, d3d_format, depth, stride, flags;
unsigned int y, v;
uint8_t *ptr;
uint32_t *pal;
int ret;
bytestream2_init(&gb, avpkt->data, avpkt->size);
version = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 72);
d3d_format = bytestream2_get_le32(&gb);
w = bytestream2_get_le16(&gb);
h = bytestream2_get_le16(&gb);
depth = bytestream2_get_byte(&gb);
bytestream2_skip(&gb, 2);
flags = bytestream2_get_byte(&gb);
if (version < 8 || version > 9) {
av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
version);
return AVERROR_PATCHWELCOME;
}
if (depth == 8) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
} else if (depth == 16 || depth == 32) {
avctx->pix_fmt = AV_PIX_FMT_RGB32;
} else {
av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
return AVERROR_PATCHWELCOME;
}
if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
if (depth == 8) {
pal = (uint32_t *) p->data[1];
for (y = 0; y < 256; y++) {
v = bytestream2_get_be32(&gb);
pal[y] = (v >> 8) + (v << 24);
}
if (bytestream2_get_bytes_left(&gb) < w * h)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, 4);
for (y=0; y<h; y++) {
bytestream2_get_buffer(&gb, ptr, w);
ptr += stride;
}
} else if (depth == 16) {
bytestream2_skip(&gb, 4);
switch (d3d_format) {
case 0:
if (!(flags & 1))
goto unsupported;
case FF_S3TC_DXT1:
if (bytestream2_get_bytes_left(&gb) < (w/4) * (h/4) * 8)
return AVERROR_INVALIDDATA;
ff_decode_dxt1(&gb, ptr, w, h, stride);
break;
case FF_S3TC_DXT3:
if (bytestream2_get_bytes_left(&gb) < (w/4) * (h/4) * 16)
return AVERROR_INVALIDDATA;
ff_decode_dxt3(&gb, ptr, w, h, stride);
break;
default:
goto unsupported;
}
} else if (depth == 32) {
switch (d3d_format) {
case 0x15:
case 0x16:
if (bytestream2_get_bytes_left(&gb) < h * w * 4)
return AVERROR_INVALIDDATA;
for (y=0; y<h; y++) {
bytestream2_get_buffer(&gb, ptr, w * 4);
ptr += stride;
}
break;
default:
goto unsupported;
}
}
*got_frame = 1;
return avpkt->size;
unsupported:
av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format);
return AVERROR_PATCHWELCOME;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3) {
GetByteContext gb;
AVFrame * const p = VAR_1;
unsigned int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
unsigned int VAR_11, VAR_12;
uint8_t *ptr;
uint32_t *pal;
int VAR_13;
bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);
VAR_4 = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 72);
VAR_7 = bytestream2_get_le32(&gb);
VAR_5 = bytestream2_get_le16(&gb);
VAR_6 = bytestream2_get_le16(&gb);
VAR_8 = bytestream2_get_byte(&gb);
bytestream2_skip(&gb, 2);
VAR_10 = bytestream2_get_byte(&gb);
if (VAR_4 < 8 || VAR_4 > 9) {
av_log(VAR_0, AV_LOG_ERROR, "texture VAR_1 VAR_4 %i is unsupported\n",
VAR_4);
return AVERROR_PATCHWELCOME;
}
if (VAR_8 == 8) {
VAR_0->pix_fmt = AV_PIX_FMT_PAL8;
} else if (VAR_8 == 16 || VAR_8 == 32) {
VAR_0->pix_fmt = AV_PIX_FMT_RGB32;
} else {
av_log(VAR_0, AV_LOG_ERROR, "VAR_8 of %i is unsupported\n", VAR_8);
return AVERROR_PATCHWELCOME;
}
if ((VAR_13 = ff_set_dimensions(VAR_0, VAR_5, VAR_6)) < 0)
return VAR_13;
if ((VAR_13 = ff_get_buffer(VAR_0, p, 0)) < 0)
return VAR_13;
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->VAR_1[0];
VAR_9 = p->linesize[0];
if (VAR_8 == 8) {
pal = (uint32_t *) p->VAR_1[1];
for (VAR_11 = 0; VAR_11 < 256; VAR_11++) {
VAR_12 = bytestream2_get_be32(&gb);
pal[VAR_11] = (VAR_12 >> 8) + (VAR_12 << 24);
}
if (bytestream2_get_bytes_left(&gb) < VAR_5 * VAR_6)
return AVERROR_INVALIDDATA;
bytestream2_skip(&gb, 4);
for (VAR_11=0; VAR_11<VAR_6; VAR_11++) {
bytestream2_get_buffer(&gb, ptr, VAR_5);
ptr += VAR_9;
}
} else if (VAR_8 == 16) {
bytestream2_skip(&gb, 4);
switch (VAR_7) {
case 0:
if (!(VAR_10 & 1))
goto unsupported;
case FF_S3TC_DXT1:
if (bytestream2_get_bytes_left(&gb) < (VAR_5/4) * (VAR_6/4) * 8)
return AVERROR_INVALIDDATA;
ff_decode_dxt1(&gb, ptr, VAR_5, VAR_6, VAR_9);
break;
case FF_S3TC_DXT3:
if (bytestream2_get_bytes_left(&gb) < (VAR_5/4) * (VAR_6/4) * 16)
return AVERROR_INVALIDDATA;
ff_decode_dxt3(&gb, ptr, VAR_5, VAR_6, VAR_9);
break;
default:
goto unsupported;
}
} else if (VAR_8 == 32) {
switch (VAR_7) {
case 0x15:
case 0x16:
if (bytestream2_get_bytes_left(&gb) < VAR_6 * VAR_5 * 4)
return AVERROR_INVALIDDATA;
for (VAR_11=0; VAR_11<VAR_6; VAR_11++) {
bytestream2_get_buffer(&gb, ptr, VAR_5 * 4);
ptr += VAR_9;
}
break;
default:
goto unsupported;
}
}
*VAR_2 = 1;
return VAR_3->size;
unsupported:
av_log(VAR_0, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", VAR_7);
return AVERROR_PATCHWELCOME;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3) {",
"GetByteContext gb;",
"AVFrame * const p = VAR_1;",
"unsigned int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"unsigned int VAR_11, VAR_12;",
"uint8_t *ptr;",
"uint32_t *pal;",
"int VAR_13;",
"bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);",
"VAR_4 = bytestream2_get_le32(&gb);",
"bytestream2_skip(&gb, 72);",
"VAR_7 = bytestream2_get_le32(&gb);",
"VAR_5 = bytestream2_get_le16(&gb);",
"VAR_6 = bytestream2_get_le16(&gb);",
"VAR_8 = bytestream2_get_byte(&gb);",
"bytestream2_skip(&gb, 2);",
"VAR_10 = bytestream2_get_byte(&gb);",
"if (VAR_4 < 8 || VAR_4 > 9) {",
"av_log(VAR_0, AV_LOG_ERROR, \"texture VAR_1 VAR_4 %i is unsupported\\n\",\nVAR_4);",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_8 == 8) {",
"VAR_0->pix_fmt = AV_PIX_FMT_PAL8;",
"} else if (VAR_8 == 16 || VAR_8 == 32) {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGB32;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"VAR_8 of %i is unsupported\\n\", VAR_8);",
"return AVERROR_PATCHWELCOME;",
"}",
"if ((VAR_13 = ff_set_dimensions(VAR_0, VAR_5, VAR_6)) < 0)\nreturn VAR_13;",
"if ((VAR_13 = ff_get_buffer(VAR_0, p, 0)) < 0)\nreturn VAR_13;",
"p->pict_type = AV_PICTURE_TYPE_I;",
"ptr = p->VAR_1[0];",
"VAR_9 = p->linesize[0];",
"if (VAR_8 == 8) {",
"pal = (uint32_t *) p->VAR_1[1];",
"for (VAR_11 = 0; VAR_11 < 256; VAR_11++) {",
"VAR_12 = bytestream2_get_be32(&gb);",
"pal[VAR_11] = (VAR_12 >> 8) + (VAR_12 << 24);",
"}",
"if (bytestream2_get_bytes_left(&gb) < VAR_5 * VAR_6)\nreturn AVERROR_INVALIDDATA;",
"bytestream2_skip(&gb, 4);",
"for (VAR_11=0; VAR_11<VAR_6; VAR_11++) {",
"bytestream2_get_buffer(&gb, ptr, VAR_5);",
"ptr += VAR_9;",
"}",
"} else if (VAR_8 == 16) {",
"bytestream2_skip(&gb, 4);",
"switch (VAR_7) {",
"case 0:\nif (!(VAR_10 & 1))\ngoto unsupported;",
"case FF_S3TC_DXT1:\nif (bytestream2_get_bytes_left(&gb) < (VAR_5/4) * (VAR_6/4) * 8)\nreturn AVERROR_INVALIDDATA;",
"ff_decode_dxt1(&gb, ptr, VAR_5, VAR_6, VAR_9);",
"break;",
"case FF_S3TC_DXT3:\nif (bytestream2_get_bytes_left(&gb) < (VAR_5/4) * (VAR_6/4) * 16)\nreturn AVERROR_INVALIDDATA;",
"ff_decode_dxt3(&gb, ptr, VAR_5, VAR_6, VAR_9);",
"break;",
"default:\ngoto unsupported;",
"}",
"} else if (VAR_8 == 32) {",
"switch (VAR_7) {",
"case 0x15:\ncase 0x16:\nif (bytestream2_get_bytes_left(&gb) < VAR_6 * VAR_5 * 4)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_11=0; VAR_11<VAR_6; VAR_11++) {",
"bytestream2_get_buffer(&gb, ptr, VAR_5 * 4);",
"ptr += VAR_9;",
"}",
"break;",
"default:\ngoto unsupported;",
"}",
"}",
"*VAR_2 = 1;",
"return VAR_3->size;",
"unsupported:\nav_log(VAR_0, AV_LOG_ERROR, \"unsupported d3d format (%08x)\\n\", VAR_7);",
"return AVERROR_PATCHWELCOME;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
77,
79
],
[
83
],
[
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
],
[
157
],
[
159
],
[
161,
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
189
],
[
193
],
[
197,
199
],
[
201
],
[
203
]
] |
25,371 | static int read_packet(AVFormatContext* ctx, AVPacket *pkt)
{
al_data *ad = ctx->priv_data;
int error=0;
const char *error_msg;
ALCint nb_samples;
/* Get number of samples available */
alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);
if (error = al_get_error(ad->device, &error_msg)) goto fail;
/* Create a packet of appropriate size */
av_new_packet(pkt, nb_samples*ad->sample_step);
pkt->pts = av_gettime();
/* Fill the packet with the available samples */
alcCaptureSamples(ad->device, pkt->data, nb_samples);
if (error = al_get_error(ad->device, &error_msg)) goto fail;
return pkt->size;
fail:
/* Handle failure */
if (pkt->data)
av_destruct_packet(pkt);
if (error_msg)
av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);
return error;
}
| false | FFmpeg | bf8bcd3b2b51c4d3f0a157e80a8c96c8542217b0 | static int read_packet(AVFormatContext* ctx, AVPacket *pkt)
{
al_data *ad = ctx->priv_data;
int error=0;
const char *error_msg;
ALCint nb_samples;
alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);
if (error = al_get_error(ad->device, &error_msg)) goto fail;
av_new_packet(pkt, nb_samples*ad->sample_step);
pkt->pts = av_gettime();
alcCaptureSamples(ad->device, pkt->data, nb_samples);
if (error = al_get_error(ad->device, &error_msg)) goto fail;
return pkt->size;
fail:
if (pkt->data)
av_destruct_packet(pkt);
if (error_msg)
av_log(ctx, AV_LOG_ERROR, "Error: %s\n", error_msg);
return error;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext* VAR_0, AVPacket *VAR_1)
{
al_data *ad = VAR_0->priv_data;
int VAR_2=0;
const char *VAR_3;
ALCint nb_samples;
alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);
if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;
av_new_packet(VAR_1, nb_samples*ad->sample_step);
VAR_1->pts = av_gettime();
alcCaptureSamples(ad->device, VAR_1->data, nb_samples);
if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;
return VAR_1->size;
fail:
if (VAR_1->data)
av_destruct_packet(VAR_1);
if (VAR_3)
av_log(VAR_0, AV_LOG_ERROR, "Error: %s\n", VAR_3);
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext* VAR_0, AVPacket *VAR_1)\n{",
"al_data *ad = VAR_0->priv_data;",
"int VAR_2=0;",
"const char *VAR_3;",
"ALCint nb_samples;",
"alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples);",
"if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;",
"av_new_packet(VAR_1, nb_samples*ad->sample_step);",
"VAR_1->pts = av_gettime();",
"alcCaptureSamples(ad->device, VAR_1->data, nb_samples);",
"if (VAR_2 = al_get_error(ad->device, &VAR_3)) goto fail;",
"return VAR_1->size;",
"fail:\nif (VAR_1->data)\nav_destruct_packet(VAR_1);",
"if (VAR_3)\nav_log(VAR_0, AV_LOG_ERROR, \"Error: %s\\n\", VAR_3);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
25
],
[
27
],
[
33
],
[
35
],
[
39
],
[
41,
45,
47
],
[
49,
51
],
[
53
],
[
55
]
] |
25,372 | static int read_header(FFV1Context *f){
uint8_t state[CONTEXT_SIZE];
int i, j, context_count;
RangeCoder * const c= &f->slice_context[0]->c;
memset(state, 128, sizeof(state));
if(f->version < 2){
f->version= get_symbol(c, state, 0);
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
if(f->ac>1){
for(i=1; i<256; i++){
f->state_transition[i]= get_symbol(c, state, 1) + c->one_state[i];
}
}
f->colorspace= get_symbol(c, state, 0); //YUV cs type
if(f->version>0)
f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
f->chroma_planes= get_rac(c, state);
f->chroma_h_shift= get_symbol(c, state, 0);
f->chroma_v_shift= get_symbol(c, state, 0);
f->transparency= get_rac(c, state);
f->plane_count= 2 + f->transparency;
}
if(f->colorspace==0){
if(!f->transparency && !f->chroma_planes){
if (f->avctx->bits_per_raw_sample<=8)
f->avctx->pix_fmt= PIX_FMT_GRAY8;
else
f->avctx->pix_fmt= PIX_FMT_GRAY16;
}else if(f->avctx->bits_per_raw_sample<=8 && !f->transparency){
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P; break;
case 0x01: f->avctx->pix_fmt= PIX_FMT_YUV440P; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P; break;
case 0x20: f->avctx->pix_fmt= PIX_FMT_YUV411P; break;
case 0x22: f->avctx->pix_fmt= PIX_FMT_YUV410P; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample<=8 && f->transparency){
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUVA444P; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUVA420P; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample==9) {
f->packed_at_lsb=1;
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P9; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P9; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P9; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample==10) {
f->packed_at_lsb=1;
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P10; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P10; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P10; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else {
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P16; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P16; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P16; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}
}else if(f->colorspace==1){
if(f->chroma_h_shift || f->chroma_v_shift){
av_log(f->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n");
return -1;
}
if(f->transparency) f->avctx->pix_fmt= PIX_FMT_RGB32;
else f->avctx->pix_fmt= PIX_FMT_0RGB32;
}else{
av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
return -1;
}
//printf("%d %d %d\n", f->chroma_h_shift, f->chroma_v_shift,f->avctx->pix_fmt);
if(f->version < 2){
context_count= read_quant_tables(c, f->quant_table);
if(context_count < 0){
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
return -1;
}
}else{
f->slice_count= get_symbol(c, state, 0);
if(f->slice_count > (unsigned)MAX_SLICES)
return -1;
}
for(j=0; j<f->slice_count; j++){
FFV1Context *fs= f->slice_context[j];
fs->ac= f->ac;
fs->packed_at_lsb= f->packed_at_lsb;
if(f->version >= 2){
fs->slice_x = get_symbol(c, state, 0) *f->width ;
fs->slice_y = get_symbol(c, state, 0) *f->height;
fs->slice_width =(get_symbol(c, state, 0)+1)*f->width + fs->slice_x;
fs->slice_height=(get_symbol(c, state, 0)+1)*f->height + fs->slice_y;
fs->slice_x /= f->num_h_slices;
fs->slice_y /= f->num_v_slices;
fs->slice_width = fs->slice_width /f->num_h_slices - fs->slice_x;
fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
if((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
return -1;
if( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
return -1;
}
for(i=0; i<f->plane_count; i++){
PlaneContext * const p= &fs->plane[i];
if(f->version >= 2){
int idx=get_symbol(c, state, 0);
if(idx > (unsigned)f->quant_table_count){
av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
return -1;
}
p->quant_table_index= idx;
memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table));
context_count= f->context_count[idx];
}else{
memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table));
}
if(p->context_count < context_count){
av_freep(&p->state);
av_freep(&p->vlc_state);
}
p->context_count= context_count;
}
}
return 0;
}
| false | FFmpeg | d7a4c43f1830a23f8acd71bea567f7908a99a539 | static int read_header(FFV1Context *f){
uint8_t state[CONTEXT_SIZE];
int i, j, context_count;
RangeCoder * const c= &f->slice_context[0]->c;
memset(state, 128, sizeof(state));
if(f->version < 2){
f->version= get_symbol(c, state, 0);
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
if(f->ac>1){
for(i=1; i<256; i++){
f->state_transition[i]= get_symbol(c, state, 1) + c->one_state[i];
}
}
f->colorspace= get_symbol(c, state, 0);
if(f->version>0)
f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
f->chroma_planes= get_rac(c, state);
f->chroma_h_shift= get_symbol(c, state, 0);
f->chroma_v_shift= get_symbol(c, state, 0);
f->transparency= get_rac(c, state);
f->plane_count= 2 + f->transparency;
}
if(f->colorspace==0){
if(!f->transparency && !f->chroma_planes){
if (f->avctx->bits_per_raw_sample<=8)
f->avctx->pix_fmt= PIX_FMT_GRAY8;
else
f->avctx->pix_fmt= PIX_FMT_GRAY16;
}else if(f->avctx->bits_per_raw_sample<=8 && !f->transparency){
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P; break;
case 0x01: f->avctx->pix_fmt= PIX_FMT_YUV440P; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P; break;
case 0x20: f->avctx->pix_fmt= PIX_FMT_YUV411P; break;
case 0x22: f->avctx->pix_fmt= PIX_FMT_YUV410P; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample<=8 && f->transparency){
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUVA444P; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUVA420P; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample==9) {
f->packed_at_lsb=1;
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P9; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P9; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P9; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(f->avctx->bits_per_raw_sample==10) {
f->packed_at_lsb=1;
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P10; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P10; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P10; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else {
switch(16*f->chroma_h_shift + f->chroma_v_shift){
case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P16; break;
case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P16; break;
case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P16; break;
default:
av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}
}else if(f->colorspace==1){
if(f->chroma_h_shift || f->chroma_v_shift){
av_log(f->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n");
return -1;
}
if(f->transparency) f->avctx->pix_fmt= PIX_FMT_RGB32;
else f->avctx->pix_fmt= PIX_FMT_0RGB32;
}else{
av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
return -1;
}
if(f->version < 2){
context_count= read_quant_tables(c, f->quant_table);
if(context_count < 0){
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
return -1;
}
}else{
f->slice_count= get_symbol(c, state, 0);
if(f->slice_count > (unsigned)MAX_SLICES)
return -1;
}
for(j=0; j<f->slice_count; j++){
FFV1Context *fs= f->slice_context[j];
fs->ac= f->ac;
fs->packed_at_lsb= f->packed_at_lsb;
if(f->version >= 2){
fs->slice_x = get_symbol(c, state, 0) *f->width ;
fs->slice_y = get_symbol(c, state, 0) *f->height;
fs->slice_width =(get_symbol(c, state, 0)+1)*f->width + fs->slice_x;
fs->slice_height=(get_symbol(c, state, 0)+1)*f->height + fs->slice_y;
fs->slice_x /= f->num_h_slices;
fs->slice_y /= f->num_v_slices;
fs->slice_width = fs->slice_width /f->num_h_slices - fs->slice_x;
fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
if((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
return -1;
if( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
return -1;
}
for(i=0; i<f->plane_count; i++){
PlaneContext * const p= &fs->plane[i];
if(f->version >= 2){
int idx=get_symbol(c, state, 0);
if(idx > (unsigned)f->quant_table_count){
av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
return -1;
}
p->quant_table_index= idx;
memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table));
context_count= f->context_count[idx];
}else{
memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table));
}
if(p->context_count < context_count){
av_freep(&p->state);
av_freep(&p->vlc_state);
}
p->context_count= context_count;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FFV1Context *VAR_0){
uint8_t state[CONTEXT_SIZE];
int VAR_1, VAR_2, VAR_3;
RangeCoder * const c= &VAR_0->slice_context[0]->c;
memset(state, 128, sizeof(state));
if(VAR_0->version < 2){
VAR_0->version= get_symbol(c, state, 0);
VAR_0->ac= VAR_0->avctx->coder_type= get_symbol(c, state, 0);
if(VAR_0->ac>1){
for(VAR_1=1; VAR_1<256; VAR_1++){
VAR_0->state_transition[VAR_1]= get_symbol(c, state, 1) + c->one_state[VAR_1];
}
}
VAR_0->colorspace= get_symbol(c, state, 0);
if(VAR_0->version>0)
VAR_0->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
VAR_0->chroma_planes= get_rac(c, state);
VAR_0->chroma_h_shift= get_symbol(c, state, 0);
VAR_0->chroma_v_shift= get_symbol(c, state, 0);
VAR_0->transparency= get_rac(c, state);
VAR_0->plane_count= 2 + VAR_0->transparency;
}
if(VAR_0->colorspace==0){
if(!VAR_0->transparency && !VAR_0->chroma_planes){
if (VAR_0->avctx->bits_per_raw_sample<=8)
VAR_0->avctx->pix_fmt= PIX_FMT_GRAY8;
else
VAR_0->avctx->pix_fmt= PIX_FMT_GRAY16;
}else if(VAR_0->avctx->bits_per_raw_sample<=8 && !VAR_0->transparency){
switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){
case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P; break;
case 0x01: VAR_0->avctx->pix_fmt= PIX_FMT_YUV440P; break;
case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P; break;
case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P; break;
case 0x20: VAR_0->avctx->pix_fmt= PIX_FMT_YUV411P; break;
case 0x22: VAR_0->avctx->pix_fmt= PIX_FMT_YUV410P; break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(VAR_0->avctx->bits_per_raw_sample<=8 && VAR_0->transparency){
switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){
case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUVA444P; break;
case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUVA420P; break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(VAR_0->avctx->bits_per_raw_sample==9) {
VAR_0->packed_at_lsb=1;
switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){
case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P9; break;
case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P9; break;
case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P9; break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else if(VAR_0->avctx->bits_per_raw_sample==10) {
VAR_0->packed_at_lsb=1;
switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){
case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P10; break;
case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P10; break;
case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P10; break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}else {
switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){
case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P16; break;
case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P16; break;
case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P16; break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
}
}
}else if(VAR_0->colorspace==1){
if(VAR_0->chroma_h_shift || VAR_0->chroma_v_shift){
av_log(VAR_0->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n");
return -1;
}
if(VAR_0->transparency) VAR_0->avctx->pix_fmt= PIX_FMT_RGB32;
else VAR_0->avctx->pix_fmt= PIX_FMT_0RGB32;
}else{
av_log(VAR_0->avctx, AV_LOG_ERROR, "colorspace not supported\n");
return -1;
}
if(VAR_0->version < 2){
VAR_3= read_quant_tables(c, VAR_0->quant_table);
if(VAR_3 < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "read_quant_table error\n");
return -1;
}
}else{
VAR_0->slice_count= get_symbol(c, state, 0);
if(VAR_0->slice_count > (unsigned)MAX_SLICES)
return -1;
}
for(VAR_2=0; VAR_2<VAR_0->slice_count; VAR_2++){
FFV1Context *fs= VAR_0->slice_context[VAR_2];
fs->ac= VAR_0->ac;
fs->packed_at_lsb= VAR_0->packed_at_lsb;
if(VAR_0->version >= 2){
fs->slice_x = get_symbol(c, state, 0) *VAR_0->width ;
fs->slice_y = get_symbol(c, state, 0) *VAR_0->height;
fs->slice_width =(get_symbol(c, state, 0)+1)*VAR_0->width + fs->slice_x;
fs->slice_height=(get_symbol(c, state, 0)+1)*VAR_0->height + fs->slice_y;
fs->slice_x /= VAR_0->num_h_slices;
fs->slice_y /= VAR_0->num_v_slices;
fs->slice_width = fs->slice_width /VAR_0->num_h_slices - fs->slice_x;
fs->slice_height = fs->slice_height/VAR_0->num_v_slices - fs->slice_y;
if((unsigned)fs->slice_width > VAR_0->width || (unsigned)fs->slice_height > VAR_0->height)
return -1;
if( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > VAR_0->width
|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > VAR_0->height)
return -1;
}
for(VAR_1=0; VAR_1<VAR_0->plane_count; VAR_1++){
PlaneContext * const p= &fs->plane[VAR_1];
if(VAR_0->version >= 2){
int idx=get_symbol(c, state, 0);
if(idx > (unsigned)VAR_0->quant_table_count){
av_log(VAR_0->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
return -1;
}
p->quant_table_index= idx;
memcpy(p->quant_table, VAR_0->quant_tables[idx], sizeof(p->quant_table));
VAR_3= VAR_0->VAR_3[idx];
}else{
memcpy(p->quant_table, VAR_0->quant_table, sizeof(p->quant_table));
}
if(p->VAR_3 < VAR_3){
av_freep(&p->state);
av_freep(&p->vlc_state);
}
p->VAR_3= VAR_3;
}
}
return 0;
}
| [
"static int FUNC_0(FFV1Context *VAR_0){",
"uint8_t state[CONTEXT_SIZE];",
"int VAR_1, VAR_2, VAR_3;",
"RangeCoder * const c= &VAR_0->slice_context[0]->c;",
"memset(state, 128, sizeof(state));",
"if(VAR_0->version < 2){",
"VAR_0->version= get_symbol(c, state, 0);",
"VAR_0->ac= VAR_0->avctx->coder_type= get_symbol(c, state, 0);",
"if(VAR_0->ac>1){",
"for(VAR_1=1; VAR_1<256; VAR_1++){",
"VAR_0->state_transition[VAR_1]= get_symbol(c, state, 1) + c->one_state[VAR_1];",
"}",
"}",
"VAR_0->colorspace= get_symbol(c, state, 0);",
"if(VAR_0->version>0)\nVAR_0->avctx->bits_per_raw_sample= get_symbol(c, state, 0);",
"VAR_0->chroma_planes= get_rac(c, state);",
"VAR_0->chroma_h_shift= get_symbol(c, state, 0);",
"VAR_0->chroma_v_shift= get_symbol(c, state, 0);",
"VAR_0->transparency= get_rac(c, state);",
"VAR_0->plane_count= 2 + VAR_0->transparency;",
"}",
"if(VAR_0->colorspace==0){",
"if(!VAR_0->transparency && !VAR_0->chroma_planes){",
"if (VAR_0->avctx->bits_per_raw_sample<=8)\nVAR_0->avctx->pix_fmt= PIX_FMT_GRAY8;",
"else\nVAR_0->avctx->pix_fmt= PIX_FMT_GRAY16;",
"}else if(VAR_0->avctx->bits_per_raw_sample<=8 && !VAR_0->transparency){",
"switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){",
"case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P; break;",
"case 0x01: VAR_0->avctx->pix_fmt= PIX_FMT_YUV440P; break;",
"case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P; break;",
"case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P; break;",
"case 0x20: VAR_0->avctx->pix_fmt= PIX_FMT_YUV411P; break;",
"case 0x22: VAR_0->avctx->pix_fmt= PIX_FMT_YUV410P; break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"format not supported\\n\");",
"return -1;",
"}",
"}else if(VAR_0->avctx->bits_per_raw_sample<=8 && VAR_0->transparency){",
"switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){",
"case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUVA444P; break;",
"case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUVA420P; break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"format not supported\\n\");",
"return -1;",
"}",
"}else if(VAR_0->avctx->bits_per_raw_sample==9) {",
"VAR_0->packed_at_lsb=1;",
"switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){",
"case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P9; break;",
"case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P9; break;",
"case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P9; break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"format not supported\\n\");",
"return -1;",
"}",
"}else if(VAR_0->avctx->bits_per_raw_sample==10) {",
"VAR_0->packed_at_lsb=1;",
"switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){",
"case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P10; break;",
"case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P10; break;",
"case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P10; break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"format not supported\\n\");",
"return -1;",
"}",
"}else {",
"switch(16*VAR_0->chroma_h_shift + VAR_0->chroma_v_shift){",
"case 0x00: VAR_0->avctx->pix_fmt= PIX_FMT_YUV444P16; break;",
"case 0x10: VAR_0->avctx->pix_fmt= PIX_FMT_YUV422P16; break;",
"case 0x11: VAR_0->avctx->pix_fmt= PIX_FMT_YUV420P16; break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"format not supported\\n\");",
"return -1;",
"}",
"}",
"}else if(VAR_0->colorspace==1){",
"if(VAR_0->chroma_h_shift || VAR_0->chroma_v_shift){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"chroma subsampling not supported in this colorspace\\n\");",
"return -1;",
"}",
"if(VAR_0->transparency) VAR_0->avctx->pix_fmt= PIX_FMT_RGB32;",
"else VAR_0->avctx->pix_fmt= PIX_FMT_0RGB32;",
"}else{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"colorspace not supported\\n\");",
"return -1;",
"}",
"if(VAR_0->version < 2){",
"VAR_3= read_quant_tables(c, VAR_0->quant_table);",
"if(VAR_3 < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"read_quant_table error\\n\");",
"return -1;",
"}",
"}else{",
"VAR_0->slice_count= get_symbol(c, state, 0);",
"if(VAR_0->slice_count > (unsigned)MAX_SLICES)\nreturn -1;",
"}",
"for(VAR_2=0; VAR_2<VAR_0->slice_count; VAR_2++){",
"FFV1Context *fs= VAR_0->slice_context[VAR_2];",
"fs->ac= VAR_0->ac;",
"fs->packed_at_lsb= VAR_0->packed_at_lsb;",
"if(VAR_0->version >= 2){",
"fs->slice_x = get_symbol(c, state, 0) *VAR_0->width ;",
"fs->slice_y = get_symbol(c, state, 0) *VAR_0->height;",
"fs->slice_width =(get_symbol(c, state, 0)+1)*VAR_0->width + fs->slice_x;",
"fs->slice_height=(get_symbol(c, state, 0)+1)*VAR_0->height + fs->slice_y;",
"fs->slice_x /= VAR_0->num_h_slices;",
"fs->slice_y /= VAR_0->num_v_slices;",
"fs->slice_width = fs->slice_width /VAR_0->num_h_slices - fs->slice_x;",
"fs->slice_height = fs->slice_height/VAR_0->num_v_slices - fs->slice_y;",
"if((unsigned)fs->slice_width > VAR_0->width || (unsigned)fs->slice_height > VAR_0->height)\nreturn -1;",
"if( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > VAR_0->width\n|| (unsigned)fs->slice_y + (uint64_t)fs->slice_height > VAR_0->height)\nreturn -1;",
"}",
"for(VAR_1=0; VAR_1<VAR_0->plane_count; VAR_1++){",
"PlaneContext * const p= &fs->plane[VAR_1];",
"if(VAR_0->version >= 2){",
"int idx=get_symbol(c, state, 0);",
"if(idx > (unsigned)VAR_0->quant_table_count){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"quant_table_index out of range\\n\");",
"return -1;",
"}",
"p->quant_table_index= idx;",
"memcpy(p->quant_table, VAR_0->quant_tables[idx], sizeof(p->quant_table));",
"VAR_3= VAR_0->VAR_3[idx];",
"}else{",
"memcpy(p->quant_table, VAR_0->quant_table, sizeof(p->quant_table));",
"}",
"if(p->VAR_3 < VAR_3){",
"av_freep(&p->state);",
"av_freep(&p->vlc_state);",
"}",
"p->VAR_3= VAR_3;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
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
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247,
249,
251
],
[
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307
]
] |
25,373 | static void avc_loopfilter_cb_or_cr_intra_edge_hor_msa(uint8_t *data_cb_or_cr,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
v16u8 alpha, beta;
v16u8 is_less_than;
v8i16 p0_or_q0, q0_or_p0;
v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org;
v16i8 zero = { 0 };
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than_alpha, is_less_than_beta;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
p1_or_q1_org = LOAD_UB(data_cb_or_cr - (img_width << 1));
p0_or_q0_org = LOAD_UB(data_cb_or_cr - img_width);
q0_or_p0_org = LOAD_UB(data_cb_or_cr);
q1_or_p1_org = LOAD_UB(data_cb_or_cr + img_width);
p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org);
p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org);
q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org);
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0);
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0);
p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0);
q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0);
p0_or_q0_org =
__msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than);
q0_or_p0_org =
__msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than);
STORE_UB(q0_or_p0_org, data_cb_or_cr);
STORE_UB(p0_or_q0_org, data_cb_or_cr - img_width);
}
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | static void avc_loopfilter_cb_or_cr_intra_edge_hor_msa(uint8_t *data_cb_or_cr,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
v16u8 alpha, beta;
v16u8 is_less_than;
v8i16 p0_or_q0, q0_or_p0;
v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org;
v16i8 zero = { 0 };
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than_alpha, is_less_than_beta;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
p1_or_q1_org = LOAD_UB(data_cb_or_cr - (img_width << 1));
p0_or_q0_org = LOAD_UB(data_cb_or_cr - img_width);
q0_or_p0_org = LOAD_UB(data_cb_or_cr);
q1_or_p1_org = LOAD_UB(data_cb_or_cr + img_width);
p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org);
p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org);
q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org);
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0);
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0);
p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0);
q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0);
p0_or_q0_org =
__msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than);
q0_or_p0_org =
__msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than);
STORE_UB(q0_or_p0_org, data_cb_or_cr);
STORE_UB(p0_or_q0_org, data_cb_or_cr - img_width);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0,
uint8_t VAR_1,
uint8_t VAR_2,
uint32_t VAR_3)
{
v16u8 alpha, beta;
v16u8 is_less_than;
v8i16 p0_or_q0, q0_or_p0;
v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org;
v16i8 zero = { 0 };
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;
v16u8 is_less_than_alpha, is_less_than_beta;
v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;
alpha = (v16u8) __msa_fill_b(VAR_1);
beta = (v16u8) __msa_fill_b(VAR_2);
p1_or_q1_org = LOAD_UB(VAR_0 - (VAR_3 << 1));
p0_or_q0_org = LOAD_UB(VAR_0 - VAR_3);
q0_or_p0_org = LOAD_UB(VAR_0);
q1_or_p1_org = LOAD_UB(VAR_0 + VAR_3);
p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org);
p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org);
q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);
if (!__msa_test_bz_v(is_less_than)) {
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org);
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org);
AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0);
AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0);
p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0);
q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0);
p0_or_q0_org =
__msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than);
q0_or_p0_org =
__msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than);
STORE_UB(q0_or_p0_org, VAR_0);
STORE_UB(p0_or_q0_org, VAR_0 - VAR_3);
}
}
| [
"static void FUNC_0(uint8_t *VAR_0,\nuint8_t VAR_1,\nuint8_t VAR_2,\nuint32_t VAR_3)\n{",
"v16u8 alpha, beta;",
"v16u8 is_less_than;",
"v8i16 p0_or_q0, q0_or_p0;",
"v16u8 p1_or_q1_org, p0_or_q0_org, q0_or_p0_org, q1_or_p1_org;",
"v16i8 zero = { 0 };",
"v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0;",
"v16u8 is_less_than_alpha, is_less_than_beta;",
"v8i16 p1_org_r, p0_org_r, q0_org_r, q1_org_r;",
"alpha = (v16u8) __msa_fill_b(VAR_1);",
"beta = (v16u8) __msa_fill_b(VAR_2);",
"p1_or_q1_org = LOAD_UB(VAR_0 - (VAR_3 << 1));",
"p0_or_q0_org = LOAD_UB(VAR_0 - VAR_3);",
"q0_or_p0_org = LOAD_UB(VAR_0);",
"q1_or_p1_org = LOAD_UB(VAR_0 + VAR_3);",
"p0_asub_q0 = __msa_asub_u_b(p0_or_q0_org, q0_or_p0_org);",
"p1_asub_p0 = __msa_asub_u_b(p1_or_q1_org, p0_or_q0_org);",
"q1_asub_q0 = __msa_asub_u_b(q1_or_p1_org, q0_or_p0_org);",
"is_less_than_alpha = (p0_asub_q0 < alpha);",
"is_less_than_beta = (p1_asub_p0 < beta);",
"is_less_than = is_less_than_beta & is_less_than_alpha;",
"is_less_than_beta = (q1_asub_q0 < beta);",
"is_less_than = is_less_than_beta & is_less_than;",
"is_less_than = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) is_less_than);",
"if (!__msa_test_bz_v(is_less_than)) {",
"p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_or_q1_org);",
"p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_or_q0_org);",
"q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_or_p0_org);",
"q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_or_p1_org);",
"AVC_LOOP_FILTER_P0_OR_Q0(p0_org_r, q1_org_r, p1_org_r, p0_or_q0);",
"AVC_LOOP_FILTER_P0_OR_Q0(q0_org_r, p1_org_r, q1_org_r, q0_or_p0);",
"p0_or_q0 = (v8i16) __msa_pckev_b(zero, (v16i8) p0_or_q0);",
"q0_or_p0 = (v8i16) __msa_pckev_b(zero, (v16i8) q0_or_p0);",
"p0_or_q0_org =\n__msa_bmnz_v(p0_or_q0_org, (v16u8) p0_or_q0, is_less_than);",
"q0_or_p0_org =\n__msa_bmnz_v(q0_or_p0_org, (v16u8) q0_or_p0, is_less_than);",
"STORE_UB(q0_or_p0_org, VAR_0);",
"STORE_UB(p0_or_q0_org, VAR_0 - VAR_3);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
89
],
[
93,
95
],
[
97,
99
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
25,374 | static void gen_cli(DisasContext *ctx)
{
/* Cache line invalidate: privileged and treated as no-op */
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_cli(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
15,
9,
13,
15,
9,
13,
15,
9,
15,
7,
11,
13,
21,
7,
11,
13,
21,
21,
7,
11,
13,
9,
13,
15,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
13,
21,
9,
15,
21,
9,
13,
15,
21,
9,
15,
21,
9,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
13,
21,
13,
21,
13,
21,
13,
21,
7,
9,
11,
13,
15,
21,
9,
13,
15,
21,
7,
9,
11,
13,
15,
21,
7,
9,
11,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
7,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21,
9,
13,
15,
21
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"#endif\n}"
] | [
0,
1,
1,
1,
0,
0,
1
] | [
[
1,
3
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
]
] |
25,376 | void palette8tobgr15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
{
unsigned i;
for(i=0; i<num_pixels; i++)
((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | void palette8tobgr15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)
{
unsigned i;
for(i=0; i<num_pixels; i++)
((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
}
| {
"code": [
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"void palette8tobgr15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette)",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
1,
5,
5,
5,
5,
5,
5,
5,
5
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)
{
unsigned VAR_4;
for(VAR_4=0; VAR_4<VAR_2; VAR_4++)
((uint16_t *)VAR_1)[VAR_4] = bswap_16(((uint16_t *)VAR_3)[ VAR_0[VAR_4] ]);
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned VAR_2, const uint8_t *VAR_3)\n{",
"unsigned VAR_4;",
"for(VAR_4=0; VAR_4<VAR_2; VAR_4++)",
"((uint16_t *)VAR_1)[VAR_4] = bswap_16(((uint16_t *)VAR_3)[ VAR_0[VAR_4] ]);",
"}"
] | [
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
25,377 | static int decode_interrupt_cb(void *ctx)
{
return received_nb_signals > transcode_init_done;
}
| true | FFmpeg | 76d8c77430e9e0110623705bfb54d922cc2ac3ea | static int decode_interrupt_cb(void *ctx)
{
return received_nb_signals > transcode_init_done;
}
| {
"code": [
" return received_nb_signals > transcode_init_done;"
],
"line_no": [
5
]
} | static int FUNC_0(void *VAR_0)
{
return received_nb_signals > transcode_init_done;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"return received_nb_signals > transcode_init_done;",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,378 | static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
mxf->packages_count = avio_rb32(pb);
mxf->packages_refs = av_calloc(mxf->packages_count, sizeof(UID));
if (!mxf->packages_refs)
return AVERROR(ENOMEM);
avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */
avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
} | true | FFmpeg | 0834f2056c7f1a0c09129802a003465e0ebcc9b8 | static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
mxf->packages_count = avio_rb32(pb);
mxf->packages_refs = av_calloc(mxf->packages_count, sizeof(UID));
if (!mxf->packages_refs)
return AVERROR(ENOMEM);
avio_skip(pb, 4);
avio_read(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)
{
MXFContext *mxf = VAR_0;
switch (VAR_2) {
case 0x1901:
mxf->packages_count = avio_rb32(VAR_1);
mxf->packages_refs = av_calloc(mxf->packages_count, sizeof(UID));
if (!mxf->packages_refs)
return AVERROR(ENOMEM);
avio_skip(VAR_1, 4);
avio_read(VAR_1, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
break;
}
return 0;
} | [
"static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4, int64_t VAR_5)\n{",
"MXFContext *mxf = VAR_0;",
"switch (VAR_2) {",
"case 0x1901:\nmxf->packages_count = avio_rb32(VAR_1);",
"mxf->packages_refs = av_calloc(mxf->packages_count, sizeof(UID));",
"if (!mxf->packages_refs)\nreturn AVERROR(ENOMEM);",
"avio_skip(VAR_1, 4);",
"avio_read(VAR_1, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));",
"break;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
14
],
[
16
],
[
18,
20
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30
],
[
32
]
] |
25,379 | void qmp_cont(Error **errp)
{
Error *local_err = NULL;
if (runstate_check(RUN_STATE_INMIGRATE)) {
error_set(errp, QERR_MIGRATION_EXPECTED);
return;
} else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN)) {
error_set(errp, QERR_RESET_REQUIRED);
return;
} else if (runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
bdrv_iterate(iostatus_bdrv_it, NULL);
bdrv_iterate(encrypted_bdrv_it, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
vm_start();
}
| true | qemu | 1e9981465f05a0f103d7e09afd975c9c0ff6d132 | void qmp_cont(Error **errp)
{
Error *local_err = NULL;
if (runstate_check(RUN_STATE_INMIGRATE)) {
error_set(errp, QERR_MIGRATION_EXPECTED);
return;
} else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN)) {
error_set(errp, QERR_RESET_REQUIRED);
return;
} else if (runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
bdrv_iterate(iostatus_bdrv_it, NULL);
bdrv_iterate(encrypted_bdrv_it, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
vm_start();
}
| {
"code": [
" if (runstate_check(RUN_STATE_INMIGRATE)) {",
" error_set(errp, QERR_MIGRATION_EXPECTED);",
" } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||",
" vm_start();"
],
"line_no": [
9,
11,
15,
45
]
} | void FUNC_0(Error **VAR_0)
{
Error *local_err = NULL;
if (runstate_check(RUN_STATE_INMIGRATE)) {
error_set(VAR_0, QERR_MIGRATION_EXPECTED);
return;
} else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
runstate_check(RUN_STATE_SHUTDOWN)) {
error_set(VAR_0, QERR_RESET_REQUIRED);
return;
} else if (runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
bdrv_iterate(iostatus_bdrv_it, NULL);
bdrv_iterate(encrypted_bdrv_it, &local_err);
if (local_err) {
error_propagate(VAR_0, local_err);
return;
}
vm_start();
}
| [
"void FUNC_0(Error **VAR_0)\n{",
"Error *local_err = NULL;",
"if (runstate_check(RUN_STATE_INMIGRATE)) {",
"error_set(VAR_0, QERR_MIGRATION_EXPECTED);",
"return;",
"} else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||",
"runstate_check(RUN_STATE_SHUTDOWN)) {",
"error_set(VAR_0, QERR_RESET_REQUIRED);",
"return;",
"} else if (runstate_check(RUN_STATE_SUSPENDED)) {",
"return;",
"}",
"bdrv_iterate(iostatus_bdrv_it, NULL);",
"bdrv_iterate(encrypted_bdrv_it, &local_err);",
"if (local_err) {",
"error_propagate(VAR_0, local_err);",
"return;",
"}",
"vm_start();",
"}"
] | [
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.