id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
2,440 | static void handle_port_status_write(EHCIState *s, int port, uint32_t val)
{
uint32_t *portsc = &s->portsc[port];
USBDevice *dev = s->ports[port].dev;
/* Clear rwc bits */
*portsc &= ~(val & PORTSC_RWC_MASK);
/* The guest may clear, but not set the PED bit */
*portsc &= val | ~PORTSC_PED;
/* POWNER is masked out by RO_MASK as it is RO when we've no companion */
handle_port_owner_write(s, port, val);
/* And finally apply RO_MASK */
val &= PORTSC_RO_MASK;
if ((val & PORTSC_PRESET) && !(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 1);
}
if (!(val & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 0);
if (dev && dev->attached) {
usb_port_reset(&s->ports[port]);
*portsc &= ~PORTSC_CSC;
}
/*
* Table 2.16 Set the enable bit(and enable bit change) to indicate
* to SW that this port has a high speed device attached
*/
if (dev && dev->attached && (dev->speedmask & USB_SPEED_MASK_HIGH)) {
val |= PORTSC_PED;
}
}
*portsc &= ~PORTSC_RO_MASK;
*portsc |= val;
}
| true | qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | static void handle_port_status_write(EHCIState *s, int port, uint32_t val)
{
uint32_t *portsc = &s->portsc[port];
USBDevice *dev = s->ports[port].dev;
*portsc &= ~(val & PORTSC_RWC_MASK);
*portsc &= val | ~PORTSC_PED;
handle_port_owner_write(s, port, val);
val &= PORTSC_RO_MASK;
if ((val & PORTSC_PRESET) && !(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 1);
}
if (!(val & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(port, 0);
if (dev && dev->attached) {
usb_port_reset(&s->ports[port]);
*portsc &= ~PORTSC_CSC;
}
if (dev && dev->attached && (dev->speedmask & USB_SPEED_MASK_HIGH)) {
val |= PORTSC_PED;
}
}
*portsc &= ~PORTSC_RO_MASK;
*portsc |= val;
}
| {
"code": [
"static void handle_port_status_write(EHCIState *s, int port, uint32_t val)"
],
"line_no": [
1
]
} | static void FUNC_0(EHCIState *VAR_0, int VAR_1, uint32_t VAR_2)
{
uint32_t *portsc = &VAR_0->portsc[VAR_1];
USBDevice *dev = VAR_0->ports[VAR_1].dev;
*portsc &= ~(VAR_2 & PORTSC_RWC_MASK);
*portsc &= VAR_2 | ~PORTSC_PED;
handle_port_owner_write(VAR_0, VAR_1, VAR_2);
VAR_2 &= PORTSC_RO_MASK;
if ((VAR_2 & PORTSC_PRESET) && !(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(VAR_1, 1);
}
if (!(VAR_2 & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {
trace_usb_ehci_port_reset(VAR_1, 0);
if (dev && dev->attached) {
usb_port_reset(&VAR_0->ports[VAR_1]);
*portsc &= ~PORTSC_CSC;
}
if (dev && dev->attached && (dev->speedmask & USB_SPEED_MASK_HIGH)) {
VAR_2 |= PORTSC_PED;
}
}
*portsc &= ~PORTSC_RO_MASK;
*portsc |= VAR_2;
}
| [
"static void FUNC_0(EHCIState *VAR_0, int VAR_1, uint32_t VAR_2)\n{",
"uint32_t *portsc = &VAR_0->portsc[VAR_1];",
"USBDevice *dev = VAR_0->ports[VAR_1].dev;",
"*portsc &= ~(VAR_2 & PORTSC_RWC_MASK);",
"*portsc &= VAR_2 | ~PORTSC_PED;",
"handle_port_owner_write(VAR_0, VAR_1, VAR_2);",
"VAR_2 &= PORTSC_RO_MASK;",
"if ((VAR_2 & PORTSC_PRESET) && !(*portsc & PORTSC_PRESET)) {",
"trace_usb_ehci_port_reset(VAR_1, 1);",
"}",
"if (!(VAR_2 & PORTSC_PRESET) &&(*portsc & PORTSC_PRESET)) {",
"trace_usb_ehci_port_reset(VAR_1, 0);",
"if (dev && dev->attached) {",
"usb_port_reset(&VAR_0->ports[VAR_1]);",
"*portsc &= ~PORTSC_CSC;",
"}",
"if (dev && dev->attached && (dev->speedmask & USB_SPEED_MASK_HIGH)) {",
"VAR_2 |= PORTSC_PED;",
"}",
"}",
"*portsc &= ~PORTSC_RO_MASK;",
"*portsc |= VAR_2;",
"}"
] | [
1,
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
],
[
13
],
[
17
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
]
] |
2,441 | static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
const uint8_t *map, unsigned size, VLC *vlc)
{
Node nodes[2*size], *tmp = &nodes[size];
int a, b, i;
/* first compute probabilities from model */
tmp[0].count = 256;
for (i=0; i<size-1; i++) {
a = tmp[i].count * coeff_model[i] >> 8;
b = tmp[i].count * (255 - coeff_model[i]) >> 8;
nodes[map[2*i ]].count = a + !a;
nodes[map[2*i+1]].count = b + !b;
}
/* then build the huffman tree accodring to probabilities */
ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
FF_HUFFMAN_FLAG_HNODE_FIRST);
} | true | FFmpeg | 0a41faa9a77dc83d8d933e99f1ba902ecd146e79 | static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
const uint8_t *map, unsigned size, VLC *vlc)
{
Node nodes[2*size], *tmp = &nodes[size];
int a, b, i;
tmp[0].count = 256;
for (i=0; i<size-1; i++) {
a = tmp[i].count * coeff_model[i] >> 8;
b = tmp[i].count * (255 - coeff_model[i]) >> 8;
nodes[map[2*i ]].count = a + !a;
nodes[map[2*i+1]].count = b + !b;
}
ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
FF_HUFFMAN_FLAG_HNODE_FIRST);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(VP56Context *VAR_0, uint8_t VAR_1[],
const uint8_t *VAR_2, unsigned VAR_3, VLC *VAR_4)
{
Node nodes[2*VAR_3], *tmp = &nodes[VAR_3];
int VAR_5, VAR_6, VAR_7;
tmp[0].count = 256;
for (VAR_7=0; VAR_7<VAR_3-1; VAR_7++) {
VAR_5 = tmp[VAR_7].count * VAR_1[VAR_7] >> 8;
VAR_6 = tmp[VAR_7].count * (255 - VAR_1[VAR_7]) >> 8;
nodes[VAR_2[2*VAR_7 ]].count = VAR_5 + !VAR_5;
nodes[VAR_2[2*VAR_7+1]].count = VAR_6 + !VAR_6;
}
ff_huff_build_tree(VAR_0->avctx, VAR_4, VAR_3, nodes, vp6_huff_cmp,
FF_HUFFMAN_FLAG_HNODE_FIRST);
} | [
"static void FUNC_0(VP56Context *VAR_0, uint8_t VAR_1[],\nconst uint8_t *VAR_2, unsigned VAR_3, VLC *VAR_4)\n{",
"Node nodes[2*VAR_3], *tmp = &nodes[VAR_3];",
"int VAR_5, VAR_6, VAR_7;",
"tmp[0].count = 256;",
"for (VAR_7=0; VAR_7<VAR_3-1; VAR_7++) {",
"VAR_5 = tmp[VAR_7].count * VAR_1[VAR_7] >> 8;",
"VAR_6 = tmp[VAR_7].count * (255 - VAR_1[VAR_7]) >> 8;",
"nodes[VAR_2[2*VAR_7 ]].count = VAR_5 + !VAR_5;",
"nodes[VAR_2[2*VAR_7+1]].count = VAR_6 + !VAR_6;",
"}",
"ff_huff_build_tree(VAR_0->avctx, VAR_4, VAR_3, nodes, vp6_huff_cmp,\nFF_HUFFMAN_FLAG_HNODE_FIRST);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
34,
36
],
[
38
]
] |
2,442 | static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
TextAttributes *t_attrib)
{
uint8_t *d;
const uint8_t *font_ptr;
unsigned int font_data, linesize, xorcol, bpp;
int i;
unsigned int fgcol, bgcol;
#ifdef DEBUG_CONSOLE
printf("x: %2i y: %2i", x, y);
console_print_text_attributes(t_attrib, ch);
#endif
if (t_attrib->invers) {
bgcol = color_table[t_attrib->bold][t_attrib->fgcol];
fgcol = color_table[t_attrib->bold][t_attrib->bgcol];
} else {
fgcol = color_table[t_attrib->bold][t_attrib->fgcol];
bgcol = color_table[t_attrib->bold][t_attrib->bgcol];
}
bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
d = ds_get_data(ds) +
ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
linesize = ds_get_linesize(ds);
font_ptr = vgafont16 + FONT_HEIGHT * ch;
xorcol = bgcol ^ fgcol;
switch(ds_get_bits_per_pixel(ds)) {
case 8:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 16:
case 15:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 32:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
d += linesize;
}
break;
}
}
| true | qemu | 439229c7cb97f6c4cddd3965c3e9d2b8319fe83c | static void vga_putcharxy(DisplayState *ds, int x, int y, int ch,
TextAttributes *t_attrib)
{
uint8_t *d;
const uint8_t *font_ptr;
unsigned int font_data, linesize, xorcol, bpp;
int i;
unsigned int fgcol, bgcol;
#ifdef DEBUG_CONSOLE
printf("x: %2i y: %2i", x, y);
console_print_text_attributes(t_attrib, ch);
#endif
if (t_attrib->invers) {
bgcol = color_table[t_attrib->bold][t_attrib->fgcol];
fgcol = color_table[t_attrib->bold][t_attrib->bgcol];
} else {
fgcol = color_table[t_attrib->bold][t_attrib->fgcol];
bgcol = color_table[t_attrib->bold][t_attrib->bgcol];
}
bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3;
d = ds_get_data(ds) +
ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH;
linesize = ds_get_linesize(ds);
font_ptr = vgafont16 + FONT_HEIGHT * ch;
xorcol = bgcol ^ fgcol;
switch(ds_get_bits_per_pixel(ds)) {
case 8:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 16:
case 15:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline
&& ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
d += linesize;
}
break;
case 32:
for(i = 0; i < FONT_HEIGHT; i++) {
font_data = *font_ptr++;
if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) {
font_data = 0xFFFF;
}
((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
d += linesize;
}
break;
}
}
| {
"code": [
" font_data = 0xFFFF;",
" font_data = 0xFFFF;",
" font_data = 0xFFFF;"
],
"line_no": [
69,
69,
69
]
} | static void FUNC_0(DisplayState *VAR_0, int VAR_1, int VAR_2, int VAR_3,
TextAttributes *VAR_4)
{
uint8_t *d;
const uint8_t *VAR_5;
unsigned int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10;
unsigned int VAR_11, VAR_12;
#ifdef DEBUG_CONSOLE
printf("VAR_1: %2i VAR_2: %2i", VAR_1, VAR_2);
console_print_text_attributes(VAR_4, VAR_3);
#endif
if (VAR_4->invers) {
VAR_12 = color_table[VAR_4->bold][VAR_4->VAR_11];
VAR_11 = color_table[VAR_4->bold][VAR_4->VAR_12];
} else {
VAR_11 = color_table[VAR_4->bold][VAR_4->VAR_11];
VAR_12 = color_table[VAR_4->bold][VAR_4->VAR_12];
}
VAR_9 = (ds_get_bits_per_pixel(VAR_0) + 7) >> 3;
d = ds_get_data(VAR_0) +
ds_get_linesize(VAR_0) * VAR_2 * FONT_HEIGHT + VAR_9 * VAR_1 * FONT_WIDTH;
VAR_7 = ds_get_linesize(VAR_0);
VAR_5 = vgafont16 + FONT_HEIGHT * VAR_3;
VAR_8 = VAR_12 ^ VAR_11;
switch(ds_get_bits_per_pixel(VAR_0)) {
case 8:
for(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {
VAR_6 = *VAR_5++;
if (VAR_4->uline
&& ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {
VAR_6 = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask16[(VAR_6 >> 4)] & VAR_8) ^ VAR_12;
((uint32_t *)d)[1] = (dmask16[(VAR_6 >> 0) & 0xf] & VAR_8) ^ VAR_12;
d += VAR_7;
}
break;
case 16:
case 15:
for(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {
VAR_6 = *VAR_5++;
if (VAR_4->uline
&& ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {
VAR_6 = 0xFFFF;
}
((uint32_t *)d)[0] = (dmask4[(VAR_6 >> 6)] & VAR_8) ^ VAR_12;
((uint32_t *)d)[1] = (dmask4[(VAR_6 >> 4) & 3] & VAR_8) ^ VAR_12;
((uint32_t *)d)[2] = (dmask4[(VAR_6 >> 2) & 3] & VAR_8) ^ VAR_12;
((uint32_t *)d)[3] = (dmask4[(VAR_6 >> 0) & 3] & VAR_8) ^ VAR_12;
d += VAR_7;
}
break;
case 32:
for(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {
VAR_6 = *VAR_5++;
if (VAR_4->uline && ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {
VAR_6 = 0xFFFF;
}
((uint32_t *)d)[0] = (-((VAR_6 >> 7)) & VAR_8) ^ VAR_12;
((uint32_t *)d)[1] = (-((VAR_6 >> 6) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[2] = (-((VAR_6 >> 5) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[3] = (-((VAR_6 >> 4) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[4] = (-((VAR_6 >> 3) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[5] = (-((VAR_6 >> 2) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[6] = (-((VAR_6 >> 1) & 1) & VAR_8) ^ VAR_12;
((uint32_t *)d)[7] = (-((VAR_6 >> 0) & 1) & VAR_8) ^ VAR_12;
d += VAR_7;
}
break;
}
}
| [
"static void FUNC_0(DisplayState *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nTextAttributes *VAR_4)\n{",
"uint8_t *d;",
"const uint8_t *VAR_5;",
"unsigned int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10;",
"unsigned int VAR_11, VAR_12;",
"#ifdef DEBUG_CONSOLE\nprintf(\"VAR_1: %2i VAR_2: %2i\", VAR_1, VAR_2);",
"console_print_text_attributes(VAR_4, VAR_3);",
"#endif\nif (VAR_4->invers) {",
"VAR_12 = color_table[VAR_4->bold][VAR_4->VAR_11];",
"VAR_11 = color_table[VAR_4->bold][VAR_4->VAR_12];",
"} else {",
"VAR_11 = color_table[VAR_4->bold][VAR_4->VAR_11];",
"VAR_12 = color_table[VAR_4->bold][VAR_4->VAR_12];",
"}",
"VAR_9 = (ds_get_bits_per_pixel(VAR_0) + 7) >> 3;",
"d = ds_get_data(VAR_0) +\nds_get_linesize(VAR_0) * VAR_2 * FONT_HEIGHT + VAR_9 * VAR_1 * FONT_WIDTH;",
"VAR_7 = ds_get_linesize(VAR_0);",
"VAR_5 = vgafont16 + FONT_HEIGHT * VAR_3;",
"VAR_8 = VAR_12 ^ VAR_11;",
"switch(ds_get_bits_per_pixel(VAR_0)) {",
"case 8:\nfor(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {",
"VAR_6 = *VAR_5++;",
"if (VAR_4->uline\n&& ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {",
"VAR_6 = 0xFFFF;",
"}",
"((uint32_t *)d)[0] = (dmask16[(VAR_6 >> 4)] & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[1] = (dmask16[(VAR_6 >> 0) & 0xf] & VAR_8) ^ VAR_12;",
"d += VAR_7;",
"}",
"break;",
"case 16:\ncase 15:\nfor(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {",
"VAR_6 = *VAR_5++;",
"if (VAR_4->uline\n&& ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {",
"VAR_6 = 0xFFFF;",
"}",
"((uint32_t *)d)[0] = (dmask4[(VAR_6 >> 6)] & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[1] = (dmask4[(VAR_6 >> 4) & 3] & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[2] = (dmask4[(VAR_6 >> 2) & 3] & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[3] = (dmask4[(VAR_6 >> 0) & 3] & VAR_8) ^ VAR_12;",
"d += VAR_7;",
"}",
"break;",
"case 32:\nfor(VAR_10 = 0; VAR_10 < FONT_HEIGHT; VAR_10++) {",
"VAR_6 = *VAR_5++;",
"if (VAR_4->uline && ((VAR_10 == FONT_HEIGHT - 2) || (VAR_10 == FONT_HEIGHT - 3))) {",
"VAR_6 = 0xFFFF;",
"}",
"((uint32_t *)d)[0] = (-((VAR_6 >> 7)) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[1] = (-((VAR_6 >> 6) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[2] = (-((VAR_6 >> 5) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[3] = (-((VAR_6 >> 4) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[4] = (-((VAR_6 >> 3) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[5] = (-((VAR_6 >> 2) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[6] = (-((VAR_6 >> 1) & 1) & VAR_8) ^ VAR_12;",
"((uint32_t *)d)[7] = (-((VAR_6 >> 0) & 1) & VAR_8) ^ VAR_12;",
"d += VAR_7;",
"}",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
]
] |
2,443 | static int iscsi_create(const char *filename, QemuOpts *opts, Error **errp)
{
int ret = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("", &error_abort);
/* Read out options */
total_size =
qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "filename", qstring_from_str(filename));
ret = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (ret != 0) {
goto out;
}
iscsi_detach_aio_context(bs);
if (iscsilun->type != TYPE_DISK) {
ret = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
ret = -ENOSPC;
goto out;
}
ret = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return ret;
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | static int iscsi_create(const char *filename, QemuOpts *opts, Error **errp)
{
int ret = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("", &error_abort);
total_size =
qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "filename", qstring_from_str(filename));
ret = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (ret != 0) {
goto out;
}
iscsi_detach_aio_context(bs);
if (iscsilun->type != TYPE_DISK) {
ret = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
ret = -ENOSPC;
goto out;
}
ret = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return ret;
}
| {
"code": [
" bs->opaque = g_malloc0(sizeof(struct IscsiLun));"
],
"line_no": [
27
]
} | static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)
{
int VAR_3 = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("", &error_abort);
total_size =
qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "VAR_0", qstring_from_str(VAR_0));
VAR_3 = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (VAR_3 != 0) {
goto out;
}
iscsi_detach_aio_context(bs);
if (iscsilun->type != TYPE_DISK) {
VAR_3 = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
VAR_3 = -ENOSPC;
goto out;
}
VAR_3 = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1, Error **VAR_2)\n{",
"int VAR_3 = 0;",
"int64_t total_size = 0;",
"BlockDriverState *bs;",
"IscsiLun *iscsilun = NULL;",
"QDict *bs_options;",
"bs = bdrv_new(\"\", &error_abort);",
"total_size =\nqemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0) / BDRV_SECTOR_SIZE;",
"bs->opaque = g_malloc0(sizeof(struct IscsiLun));",
"iscsilun = bs->opaque;",
"bs_options = qdict_new();",
"qdict_put(bs_options, \"VAR_0\", qstring_from_str(VAR_0));",
"VAR_3 = iscsi_open(bs, bs_options, 0, NULL);",
"QDECREF(bs_options);",
"if (VAR_3 != 0) {",
"goto out;",
"}",
"iscsi_detach_aio_context(bs);",
"if (iscsilun->type != TYPE_DISK) {",
"VAR_3 = -ENODEV;",
"goto out;",
"}",
"if (bs->total_sectors < total_size) {",
"VAR_3 = -ENOSPC;",
"goto out;",
"}",
"VAR_3 = 0;",
"out:\nif (iscsilun->iscsi != NULL) {",
"iscsi_destroy_context(iscsilun->iscsi);",
"}",
"g_free(bs->opaque);",
"bs->opaque = NULL;",
"bdrv_unref(bs);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23,
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
2,444 | static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
av_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i % 16)
av_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
return 0;
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
av_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
} | true | FFmpeg | ebe3a41ea3b93579379b0460338ff511f9749602 | static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int i, clut_id;
int version;
DVBSubCLUT *clut;
int entry_id, depth , full_range;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
av_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
av_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
av_dlog(avctx, "\n");
}
if (i % 16)
av_dlog(avctx, "\n");
clut_id = *buf++;
version = ((*buf)>>4)&15;
buf += 1;
clut = get_clut(ctx, clut_id);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = clut_id;
clut->version = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->version != version) {
clut->version = version;
while (buf + 4 < buf_end) {
entry_id = *buf++;
depth = (*buf) & 0xe0;
if (depth == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
return 0;
}
full_range = (*buf++) & 1;
if (full_range) {
y = *buf++;
cr = *buf++;
cb = *buf++;
alpha = *buf++;
} else {
y = buf[0] & 0xfc;
cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
cb = (buf[1] << 2) & 0xf0;
alpha = (buf[1] << 6) & 0xc0;
buf += 2;
}
if (y == 0)
alpha = 0xff;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) {
av_dlog(avctx, "More than one bit level marked: %x\n", depth);
if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x40)
clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
else if (depth & 0x20)
clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
DVBSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_3 = VAR_1 + VAR_2;
int VAR_4, VAR_5;
int VAR_6;
DVBSubCLUT *clut;
int VAR_7, VAR_8 , VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13;
int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19;
av_dlog(VAR_0, "DVB clut packet:\n");
for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) {
av_dlog(VAR_0, "%02x ", VAR_1[VAR_4]);
if (VAR_4 % 16 == 15)
av_dlog(VAR_0, "\n");
}
if (VAR_4 % 16)
av_dlog(VAR_0, "\n");
VAR_5 = *VAR_1++;
VAR_6 = ((*VAR_1)>>4)&15;
VAR_1 += 1;
clut = get_clut(ctx, VAR_5);
if (!clut) {
clut = av_malloc(sizeof(DVBSubCLUT));
memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
clut->id = VAR_5;
clut->VAR_6 = -1;
clut->next = ctx->clut_list;
ctx->clut_list = clut;
}
if (clut->VAR_6 != VAR_6) {
clut->VAR_6 = VAR_6;
while (VAR_1 + 4 < VAR_3) {
VAR_7 = *VAR_1++;
VAR_8 = (*VAR_1) & 0xe0;
if (VAR_8 == 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid clut VAR_8 0x%x!\n", *VAR_1);
return 0;
}
VAR_9 = (*VAR_1++) & 1;
if (VAR_9) {
VAR_10 = *VAR_1++;
VAR_11 = *VAR_1++;
VAR_12 = *VAR_1++;
VAR_13 = *VAR_1++;
} else {
VAR_10 = VAR_1[0] & 0xfc;
VAR_11 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4;
VAR_12 = (VAR_1[1] << 2) & 0xf0;
VAR_13 = (VAR_1[1] << 6) & 0xc0;
VAR_1 += 2;
}
if (VAR_10 == 0)
VAR_13 = 0xff;
YUV_TO_RGB1_CCIR(VAR_12, VAR_11);
YUV_TO_RGB2_CCIR(VAR_14, VAR_15, VAR_16, VAR_10);
av_dlog(VAR_0, "clut %d := (%d,%d,%d,%d)\n", VAR_7, VAR_14, VAR_15, VAR_16, VAR_13);
if (!!(VAR_8 & 0x80) + !!(VAR_8 & 0x40) + !!(VAR_8 & 0x20) > 1) {
av_dlog(VAR_0, "More than one bit level marked: %x\n", VAR_8);
if (VAR_0->strict_std_compliance > FF_COMPLIANCE_NORMAL)
return AVERROR_INVALIDDATA;
}
if (VAR_8 & 0x80)
clut->clut4[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
else if (VAR_8 & 0x40)
clut->clut16[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
else if (VAR_8 & 0x20)
clut->clut256[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);
}
}
return 0;
} | [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_3 = VAR_1 + VAR_2;",
"int VAR_4, VAR_5;",
"int VAR_6;",
"DVBSubCLUT *clut;",
"int VAR_7, VAR_8 , VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13;",
"int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19;",
"av_dlog(VAR_0, \"DVB clut packet:\\n\");",
"for (VAR_4=0; VAR_4 < VAR_2; VAR_4++) {",
"av_dlog(VAR_0, \"%02x \", VAR_1[VAR_4]);",
"if (VAR_4 % 16 == 15)\nav_dlog(VAR_0, \"\\n\");",
"}",
"if (VAR_4 % 16)\nav_dlog(VAR_0, \"\\n\");",
"VAR_5 = *VAR_1++;",
"VAR_6 = ((*VAR_1)>>4)&15;",
"VAR_1 += 1;",
"clut = get_clut(ctx, VAR_5);",
"if (!clut) {",
"clut = av_malloc(sizeof(DVBSubCLUT));",
"memcpy(clut, &default_clut, sizeof(DVBSubCLUT));",
"clut->id = VAR_5;",
"clut->VAR_6 = -1;",
"clut->next = ctx->clut_list;",
"ctx->clut_list = clut;",
"}",
"if (clut->VAR_6 != VAR_6) {",
"clut->VAR_6 = VAR_6;",
"while (VAR_1 + 4 < VAR_3) {",
"VAR_7 = *VAR_1++;",
"VAR_8 = (*VAR_1) & 0xe0;",
"if (VAR_8 == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid clut VAR_8 0x%x!\\n\", *VAR_1);",
"return 0;",
"}",
"VAR_9 = (*VAR_1++) & 1;",
"if (VAR_9) {",
"VAR_10 = *VAR_1++;",
"VAR_11 = *VAR_1++;",
"VAR_12 = *VAR_1++;",
"VAR_13 = *VAR_1++;",
"} else {",
"VAR_10 = VAR_1[0] & 0xfc;",
"VAR_11 = (((VAR_1[0] & 3) << 2) | ((VAR_1[1] >> 6) & 3)) << 4;",
"VAR_12 = (VAR_1[1] << 2) & 0xf0;",
"VAR_13 = (VAR_1[1] << 6) & 0xc0;",
"VAR_1 += 2;",
"}",
"if (VAR_10 == 0)\nVAR_13 = 0xff;",
"YUV_TO_RGB1_CCIR(VAR_12, VAR_11);",
"YUV_TO_RGB2_CCIR(VAR_14, VAR_15, VAR_16, VAR_10);",
"av_dlog(VAR_0, \"clut %d := (%d,%d,%d,%d)\\n\", VAR_7, VAR_14, VAR_15, VAR_16, VAR_13);",
"if (!!(VAR_8 & 0x80) + !!(VAR_8 & 0x40) + !!(VAR_8 & 0x20) > 1) {",
"av_dlog(VAR_0, \"More than one bit level marked: %x\\n\", VAR_8);",
"if (VAR_0->strict_std_compliance > FF_COMPLIANCE_NORMAL)\nreturn AVERROR_INVALIDDATA;",
"}",
"if (VAR_8 & 0x80)\nclut->clut4[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"else if (VAR_8 & 0x40)\nclut->clut16[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"else if (VAR_8 & 0x20)\nclut->clut256[VAR_7] = RGBA(VAR_14,VAR_15,VAR_16,255 - VAR_13);",
"}",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
69
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
95
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147,
149
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
173,
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
]
] |
2,445 | static void scsi_write_request(SCSIDiskReq *r)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
/* No data transfer may already be in progress */
assert(r->req.aiocb == NULL);
n = r->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -EIO);
}
} else {
/* Invoke completion routine to fetch data from host. */
scsi_write_complete(r, 0);
}
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void scsi_write_request(SCSIDiskReq *r)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
assert(r->req.aiocb == NULL);
n = r->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -EIO);
}
} else {
scsi_write_complete(r, 0);
}
}
| {
"code": [
"static void scsi_write_request(SCSIDiskReq *r)"
],
"line_no": [
1
]
} | static void FUNC_0(SCSIDiskReq *VAR_0)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);
uint32_t n;
assert(VAR_0->req.aiocb == NULL);
n = VAR_0->iov.iov_len / 512;
if (n) {
qemu_iovec_init_external(&VAR_0->qiov, &VAR_0->iov, 1);
VAR_0->req.aiocb = bdrv_aio_writev(s->bs, VAR_0->sector, &VAR_0->qiov, n,
scsi_write_complete, VAR_0);
if (VAR_0->req.aiocb == NULL) {
scsi_write_complete(VAR_0, -EIO);
}
} else {
scsi_write_complete(VAR_0, 0);
}
}
| [
"static void FUNC_0(SCSIDiskReq *VAR_0)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);",
"uint32_t n;",
"assert(VAR_0->req.aiocb == NULL);",
"n = VAR_0->iov.iov_len / 512;",
"if (n) {",
"qemu_iovec_init_external(&VAR_0->qiov, &VAR_0->iov, 1);",
"VAR_0->req.aiocb = bdrv_aio_writev(s->bs, VAR_0->sector, &VAR_0->qiov, n,\nscsi_write_complete, VAR_0);",
"if (VAR_0->req.aiocb == NULL) {",
"scsi_write_complete(VAR_0, -EIO);",
"}",
"} else {",
"scsi_write_complete(VAR_0, 0);",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
] |
2,446 | static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
{
DXAContext *c = s->priv_data;
int ret;
uint32_t size;
uint8_t buf[DXA_EXTRA_SIZE], pal[768+4];
int pal_size = 0;
if(!c->readvid && c->has_sound && c->bytes_left){
c->readvid = 1;
avio_seek(s->pb, c->wavpos, SEEK_SET);
size = FFMIN(c->bytes_left, c->bpc);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 1;
if(ret != size)
return AVERROR(EIO);
c->bytes_left -= size;
c->wavpos = avio_tell(s->pb);
return 0;
}
avio_seek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
return AVERROR(ENOMEM);
pkt->stream_index = 0;
if(pal_size) memcpy(pkt->data, pal, pal_size);
memcpy(pkt->data + pal_size, buf, 4);
c->frames--;
c->vidpos = avio_tell(s->pb);
c->readvid = 0;
return 0;
case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4;
memcpy(pal, buf, 4);
avio_read(s->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
return AVERROR_INVALIDDATA;
}
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
av_free_packet(pkt);
return AVERROR(EIO);
}
if(pal_size) memcpy(pkt->data, pal, pal_size);
pkt->stream_index = 0;
c->frames--;
c->vidpos = avio_tell(s->pb);
c->readvid = 0;
return 0;
default:
av_log(s, AV_LOG_ERROR, "Unknown tag %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]);
return AVERROR_INVALIDDATA;
}
}
return AVERROR_EOF;
}
| true | FFmpeg | ae09db1023083cbc99009c9f16e83e159d0ea040 | static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
{
DXAContext *c = s->priv_data;
int ret;
uint32_t size;
uint8_t buf[DXA_EXTRA_SIZE], pal[768+4];
int pal_size = 0;
if(!c->readvid && c->has_sound && c->bytes_left){
c->readvid = 1;
avio_seek(s->pb, c->wavpos, SEEK_SET);
size = FFMIN(c->bytes_left, c->bpc);
ret = av_get_packet(s->pb, pkt, size);
pkt->stream_index = 1;
if(ret != size)
return AVERROR(EIO);
c->bytes_left -= size;
c->wavpos = avio_tell(s->pb);
return 0;
}
avio_seek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(pkt, 4 + pal_size) < 0)
return AVERROR(ENOMEM);
pkt->stream_index = 0;
if(pal_size) memcpy(pkt->data, pal, pal_size);
memcpy(pkt->data + pal_size, buf, 4);
c->frames--;
c->vidpos = avio_tell(s->pb);
c->readvid = 0;
return 0;
case MKTAG('C', 'M', 'A', 'P'):
pal_size = 768+4;
memcpy(pal, buf, 4);
avio_read(s->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
return AVERROR_INVALIDDATA;
}
if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
if(ret != size){
av_free_packet(pkt);
return AVERROR(EIO);
}
if(pal_size) memcpy(pkt->data, pal, pal_size);
pkt->stream_index = 0;
c->frames--;
c->vidpos = avio_tell(s->pb);
c->readvid = 0;
return 0;
default:
av_log(s, AV_LOG_ERROR, "Unknown tag %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]);
return AVERROR_INVALIDDATA;
}
}
return AVERROR_EOF;
}
| {
"code": [
" avio_read(s->pb, buf, 4);",
" avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);"
],
"line_no": [
45,
81
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
DXAContext *c = VAR_0->priv_data;
int VAR_2;
uint32_t size;
uint8_t buf[DXA_EXTRA_SIZE], pal[768+4];
int VAR_3 = 0;
if(!c->readvid && c->has_sound && c->bytes_left){
c->readvid = 1;
avio_seek(VAR_0->pb, c->wavpos, SEEK_SET);
size = FFMIN(c->bytes_left, c->bpc);
VAR_2 = av_get_packet(VAR_0->pb, VAR_1, size);
VAR_1->stream_index = 1;
if(VAR_2 != size)
return AVERROR(EIO);
c->bytes_left -= size;
c->wavpos = avio_tell(VAR_0->pb);
return 0;
}
avio_seek(VAR_0->pb, c->vidpos, SEEK_SET);
while(!url_feof(VAR_0->pb) && c->frames){
avio_read(VAR_0->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
if(av_new_packet(VAR_1, 4 + VAR_3) < 0)
return AVERROR(ENOMEM);
VAR_1->stream_index = 0;
if(VAR_3) memcpy(VAR_1->data, pal, VAR_3);
memcpy(VAR_1->data + VAR_3, buf, 4);
c->frames--;
c->vidpos = avio_tell(VAR_0->pb);
c->readvid = 0;
return 0;
case MKTAG('C', 'M', 'A', 'P'):
VAR_3 = 768+4;
memcpy(pal, buf, 4);
avio_read(VAR_0->pb, pal + 4, 768);
break;
case MKTAG('F', 'R', 'A', 'M'):
avio_read(VAR_0->pb, buf + 4, DXA_EXTRA_SIZE - 4);
size = AV_RB32(buf + 5);
if(size > 0xFFFFFF){
av_log(VAR_0, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
return AVERROR_INVALIDDATA;
}
if(av_new_packet(VAR_1, size + DXA_EXTRA_SIZE + VAR_3) < 0)
return AVERROR(ENOMEM);
memcpy(VAR_1->data + VAR_3, buf, DXA_EXTRA_SIZE);
VAR_2 = avio_read(VAR_0->pb, VAR_1->data + DXA_EXTRA_SIZE + VAR_3, size);
if(VAR_2 != size){
av_free_packet(VAR_1);
return AVERROR(EIO);
}
if(VAR_3) memcpy(VAR_1->data, pal, VAR_3);
VAR_1->stream_index = 0;
c->frames--;
c->vidpos = avio_tell(VAR_0->pb);
c->readvid = 0;
return 0;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown tag %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]);
return AVERROR_INVALIDDATA;
}
}
return AVERROR_EOF;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"DXAContext *c = VAR_0->priv_data;",
"int VAR_2;",
"uint32_t size;",
"uint8_t buf[DXA_EXTRA_SIZE], pal[768+4];",
"int VAR_3 = 0;",
"if(!c->readvid && c->has_sound && c->bytes_left){",
"c->readvid = 1;",
"avio_seek(VAR_0->pb, c->wavpos, SEEK_SET);",
"size = FFMIN(c->bytes_left, c->bpc);",
"VAR_2 = av_get_packet(VAR_0->pb, VAR_1, size);",
"VAR_1->stream_index = 1;",
"if(VAR_2 != size)\nreturn AVERROR(EIO);",
"c->bytes_left -= size;",
"c->wavpos = avio_tell(VAR_0->pb);",
"return 0;",
"}",
"avio_seek(VAR_0->pb, c->vidpos, SEEK_SET);",
"while(!url_feof(VAR_0->pb) && c->frames){",
"avio_read(VAR_0->pb, buf, 4);",
"switch(AV_RL32(buf)){",
"case MKTAG('N', 'U', 'L', 'L'):\nif(av_new_packet(VAR_1, 4 + VAR_3) < 0)\nreturn AVERROR(ENOMEM);",
"VAR_1->stream_index = 0;",
"if(VAR_3) memcpy(VAR_1->data, pal, VAR_3);",
"memcpy(VAR_1->data + VAR_3, buf, 4);",
"c->frames--;",
"c->vidpos = avio_tell(VAR_0->pb);",
"c->readvid = 0;",
"return 0;",
"case MKTAG('C', 'M', 'A', 'P'):\nVAR_3 = 768+4;",
"memcpy(pal, buf, 4);",
"avio_read(VAR_0->pb, pal + 4, 768);",
"break;",
"case MKTAG('F', 'R', 'A', 'M'):\navio_read(VAR_0->pb, buf + 4, DXA_EXTRA_SIZE - 4);",
"size = AV_RB32(buf + 5);",
"if(size > 0xFFFFFF){",
"av_log(VAR_0, AV_LOG_ERROR, \"Frame size is too big: %d\\n\", size);",
"return AVERROR_INVALIDDATA;",
"}",
"if(av_new_packet(VAR_1, size + DXA_EXTRA_SIZE + VAR_3) < 0)\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_1->data + VAR_3, buf, DXA_EXTRA_SIZE);",
"VAR_2 = avio_read(VAR_0->pb, VAR_1->data + DXA_EXTRA_SIZE + VAR_3, size);",
"if(VAR_2 != size){",
"av_free_packet(VAR_1);",
"return AVERROR(EIO);",
"}",
"if(VAR_3) memcpy(VAR_1->data, pal, VAR_3);",
"VAR_1->stream_index = 0;",
"c->frames--;",
"c->vidpos = avio_tell(VAR_0->pb);",
"c->readvid = 0;",
"return 0;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown tag %c%c%c%c\\n\", buf[0], buf[1], buf[2], buf[3]);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"return AVERROR_EOF;",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
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
]
] |
2,447 | static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx)
{
struct ibv_recv_wr *bad_wr;
struct ibv_sge sge = {
.addr = (uint64_t)(rdma->wr_data[idx].control),
.length = RDMA_CONTROL_MAX_BUFFER,
.lkey = rdma->wr_data[idx].control_mr->lkey,
};
struct ibv_recv_wr recv_wr = {
.wr_id = RDMA_WRID_RECV_CONTROL + idx,
.sg_list = &sge,
.num_sge = 1,
};
if (ibv_post_recv(rdma->qp, &recv_wr, &bad_wr)) {
return -1;
}
return 0;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx)
{
struct ibv_recv_wr *bad_wr;
struct ibv_sge sge = {
.addr = (uint64_t)(rdma->wr_data[idx].control),
.length = RDMA_CONTROL_MAX_BUFFER,
.lkey = rdma->wr_data[idx].control_mr->lkey,
};
struct ibv_recv_wr recv_wr = {
.wr_id = RDMA_WRID_RECV_CONTROL + idx,
.sg_list = &sge,
.num_sge = 1,
};
if (ibv_post_recv(rdma->qp, &recv_wr, &bad_wr)) {
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RDMAContext *VAR_0, int VAR_1)
{
struct ibv_recv_wr *VAR_2;
struct ibv_sge VAR_3 = {
.addr = (uint64_t)(VAR_0->wr_data[VAR_1].control),
.length = RDMA_CONTROL_MAX_BUFFER,
.lkey = VAR_0->wr_data[VAR_1].control_mr->lkey,
};
struct ibv_recv_wr VAR_4 = {
.wr_id = RDMA_WRID_RECV_CONTROL + VAR_1,
.sg_list = &VAR_3,
.num_sge = 1,
};
if (ibv_post_recv(VAR_0->qp, &VAR_4, &VAR_2)) {
return -1;
}
return 0;
}
| [
"static int FUNC_0(RDMAContext *VAR_0, int VAR_1)\n{",
"struct ibv_recv_wr *VAR_2;",
"struct ibv_sge VAR_3 = {",
".addr = (uint64_t)(VAR_0->wr_data[VAR_1].control),\n.length = RDMA_CONTROL_MAX_BUFFER,\n.lkey = VAR_0->wr_data[VAR_1].control_mr->lkey,\n};",
"struct ibv_recv_wr VAR_4 = {",
".wr_id = RDMA_WRID_RECV_CONTROL + VAR_1,\n.sg_list = &VAR_3,\n.num_sge = 1,\n};",
"if (ibv_post_recv(VAR_0->qp, &VAR_4, &VAR_2)) {",
"return -1;",
"}",
"return 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
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
2,448 | static void adx_encode(unsigned char *adx,const short *wav,PREV *prev)
{
int scale;
int i;
int s0,s1,s2,d;
int max=0;
int min=0;
int data[32];
s1 = prev->s1;
s2 = prev->s2;
for(i=0;i<32;i++) {
s0 = wav[i];
d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;
data[i]=d;
if (max<d) max=d;
if (min>d) min=d;
s2 = s1;
s1 = s0;
}
prev->s1 = s1;
prev->s2 = s2;
/* -8..+7 */
if (max==0 && min==0) {
memset(adx,0,18);
return;
}
if (max/7>-min/8) scale = max/7;
else scale = -min/8;
if (scale==0) scale=1;
adx[0] = scale>>8;
adx[1] = scale;
for(i=0;i<16;i++) {
adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);
}
}
| true | FFmpeg | f19af812a32c1398d48c3550d11dbc6aafbb2bfc | static void adx_encode(unsigned char *adx,const short *wav,PREV *prev)
{
int scale;
int i;
int s0,s1,s2,d;
int max=0;
int min=0;
int data[32];
s1 = prev->s1;
s2 = prev->s2;
for(i=0;i<32;i++) {
s0 = wav[i];
d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;
data[i]=d;
if (max<d) max=d;
if (min>d) min=d;
s2 = s1;
s1 = s0;
}
prev->s1 = s1;
prev->s2 = s2;
if (max==0 && min==0) {
memset(adx,0,18);
return;
}
if (max/7>-min/8) scale = max/7;
else scale = -min/8;
if (scale==0) scale=1;
adx[0] = scale>>8;
adx[1] = scale;
for(i=0;i<16;i++) {
adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);
}
}
| {
"code": [
"\tint scale;",
"\tint i;",
"\tint s0,s1,s2,d;",
"\tint max=0;",
"\tint min=0;",
"\tint data[32];",
"\ts1 = prev->s1;",
"\ts2 = prev->s2;",
"\tfor(i=0;i<32;i++) {",
"\t\ts0 = wav[i];",
"\t\td = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;",
"\t\tdata[i]=d;",
"\t\tif (max<d) max=d;",
"\t\tif (min>d) min=d;",
"\t\ts2 = s1;",
"\t\ts1 = s0;",
"\tprev->s1 = s1;",
"\tprev->s2 = s2;",
"\tif (max==0 && min==0) {",
"\t\tmemset(adx,0,18);",
"\tif (max/7>-min/8) scale = max/7;",
"\telse scale = -min/8;",
"\tif (scale==0) scale=1;",
"\tadx[0] = scale>>8;",
"\tadx[1] = scale;",
"\tfor(i=0;i<16;i++) {",
"\t\tadx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);",
"\tint i;",
"\tint s0,s1,s2,d;",
"\ts1 = prev->s1;",
"\ts2 = prev->s2;",
"\tfor(i=0;i<16;i++) {",
"\t\ts2 = s1;",
"\t\ts1 = s0;",
"\t\ts2 = s1;",
"\t\ts1 = s0;",
"\tprev->s1 = s1;",
"\tprev->s2 = s2;",
"\tint i;",
"\tfor(i=0;i<32;i++) {",
"\tint i;"
],
"line_no": [
5,
7,
9,
11,
13,
15,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
41,
43,
51,
53,
61,
63,
67,
71,
73,
77,
79,
7,
9,
19,
21,
77,
35,
37,
35,
37,
41,
43,
7,
23,
7
]
} | static void FUNC_0(unsigned char *VAR_0,const short *VAR_1,PREV *VAR_2)
{
int VAR_3;
int VAR_4;
int VAR_5,VAR_6,VAR_7,VAR_8;
int VAR_9=0;
int VAR_10=0;
int VAR_11[32];
VAR_6 = VAR_2->VAR_6;
VAR_7 = VAR_2->VAR_7;
for(VAR_4=0;VAR_4<32;VAR_4++) {
VAR_5 = VAR_1[VAR_4];
VAR_8 = ((VAR_5<<14) - SCALE1*VAR_6 + SCALE2*VAR_7)/BASEVOL;
VAR_11[VAR_4]=VAR_8;
if (VAR_9<VAR_8) VAR_9=VAR_8;
if (VAR_10>VAR_8) VAR_10=VAR_8;
VAR_7 = VAR_6;
VAR_6 = VAR_5;
}
VAR_2->VAR_6 = VAR_6;
VAR_2->VAR_7 = VAR_7;
if (VAR_9==0 && VAR_10==0) {
memset(VAR_0,0,18);
return;
}
if (VAR_9/7>-VAR_10/8) VAR_3 = VAR_9/7;
else VAR_3 = -VAR_10/8;
if (VAR_3==0) VAR_3=1;
VAR_0[0] = VAR_3>>8;
VAR_0[1] = VAR_3;
for(VAR_4=0;VAR_4<16;VAR_4++) {
VAR_0[VAR_4+2] = ((VAR_11[VAR_4*2]/VAR_3)<<4) | ((VAR_11[VAR_4*2+1]/VAR_3)&0xf);
}
}
| [
"static void FUNC_0(unsigned char *VAR_0,const short *VAR_1,PREV *VAR_2)\n{",
"int VAR_3;",
"int VAR_4;",
"int VAR_5,VAR_6,VAR_7,VAR_8;",
"int VAR_9=0;",
"int VAR_10=0;",
"int VAR_11[32];",
"VAR_6 = VAR_2->VAR_6;",
"VAR_7 = VAR_2->VAR_7;",
"for(VAR_4=0;VAR_4<32;VAR_4++) {",
"VAR_5 = VAR_1[VAR_4];",
"VAR_8 = ((VAR_5<<14) - SCALE1*VAR_6 + SCALE2*VAR_7)/BASEVOL;",
"VAR_11[VAR_4]=VAR_8;",
"if (VAR_9<VAR_8) VAR_9=VAR_8;",
"if (VAR_10>VAR_8) VAR_10=VAR_8;",
"VAR_7 = VAR_6;",
"VAR_6 = VAR_5;",
"}",
"VAR_2->VAR_6 = VAR_6;",
"VAR_2->VAR_7 = VAR_7;",
"if (VAR_9==0 && VAR_10==0) {",
"memset(VAR_0,0,18);",
"return;",
"}",
"if (VAR_9/7>-VAR_10/8) VAR_3 = VAR_9/7;",
"else VAR_3 = -VAR_10/8;",
"if (VAR_3==0) VAR_3=1;",
"VAR_0[0] = VAR_3>>8;",
"VAR_0[1] = VAR_3;",
"for(VAR_4=0;VAR_4<16;VAR_4++) {",
"VAR_0[VAR_4+2] = ((VAR_11[VAR_4*2]/VAR_3)<<4) | ((VAR_11[VAR_4*2+1]/VAR_3)&0xf);",
"}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
2,449 | void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len, unsigned int idx)
{
VRingUsedElem uelem;
trace_virtqueue_fill(vq, elem, len, idx);
virtqueue_unmap_sg(vq, elem, len);
idx = (idx + vq->used_idx) % vq->vring.num;
uelem.id = elem->index;
uelem.len = len;
vring_used_write(vq, &uelem, idx); | true | qemu | f5ed36635d8fa73feb66fe12b3b9c2ed90a1adbe | void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len, unsigned int idx)
{
VRingUsedElem uelem;
trace_virtqueue_fill(vq, elem, len, idx);
virtqueue_unmap_sg(vq, elem, len);
idx = (idx + vq->used_idx) % vq->vring.num;
uelem.id = elem->index;
uelem.len = len;
vring_used_write(vq, &uelem, idx); | {
"code": [],
"line_no": []
} | void FUNC_0(VirtQueue *VAR_0, const VirtQueueElement *VAR_1,
unsigned int VAR_2, unsigned int VAR_3)
{
VRingUsedElem uelem;
trace_virtqueue_fill(VAR_0, VAR_1, VAR_2, VAR_3);
virtqueue_unmap_sg(VAR_0, VAR_1, VAR_2);
VAR_3 = (VAR_3 + VAR_0->used_idx) % VAR_0->vring.num;
uelem.id = VAR_1->index;
uelem.VAR_2 = VAR_2;
vring_used_write(VAR_0, &uelem, VAR_3); | [
"void FUNC_0(VirtQueue *VAR_0, const VirtQueueElement *VAR_1,\nunsigned int VAR_2, unsigned int VAR_3)\n{",
"VRingUsedElem uelem;",
"trace_virtqueue_fill(VAR_0, VAR_1, VAR_2, VAR_3);",
"virtqueue_unmap_sg(VAR_0, VAR_1, VAR_2);",
"VAR_3 = (VAR_3 + VAR_0->used_idx) % VAR_0->vring.num;",
"uelem.id = VAR_1->index;",
"uelem.VAR_2 = VAR_2;",
"vring_used_write(VAR_0, &uelem, VAR_3);"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
]
] |
2,452 | void rtsp_close_streams(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
int i;
RTSPStream *rtsp_st;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st) {
if (rtsp_st->transport_priv) {
if (s->oformat) {
AVFormatContext *rtpctx = rtsp_st->transport_priv;
av_write_trailer(rtpctx);
url_fclose(rtpctx->pb);
av_free(rtpctx->streams[0]);
av_free(rtpctx);
} else if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_parse_close(rtsp_st->transport_priv);
else
rtp_parse_close(rtsp_st->transport_priv);
}
if (rtsp_st->rtp_handle)
url_close(rtsp_st->rtp_handle);
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler->close(
rtsp_st->dynamic_protocol_context);
}
}
av_free(rt->rtsp_streams);
if (rt->asf_ctx) {
av_close_input_stream (rt->asf_ctx);
rt->asf_ctx = NULL;
}
av_freep(&rt->auth_b64);
} | true | FFmpeg | f86f66562311f38b6b7864c19720727916fb0d19 | void rtsp_close_streams(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
int i;
RTSPStream *rtsp_st;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st) {
if (rtsp_st->transport_priv) {
if (s->oformat) {
AVFormatContext *rtpctx = rtsp_st->transport_priv;
av_write_trailer(rtpctx);
url_fclose(rtpctx->pb);
av_free(rtpctx->streams[0]);
av_free(rtpctx);
} else if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_parse_close(rtsp_st->transport_priv);
else
rtp_parse_close(rtsp_st->transport_priv);
}
if (rtsp_st->rtp_handle)
url_close(rtsp_st->rtp_handle);
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler->close(
rtsp_st->dynamic_protocol_context);
}
}
av_free(rt->rtsp_streams);
if (rt->asf_ctx) {
av_close_input_stream (rt->asf_ctx);
rt->asf_ctx = NULL;
}
av_freep(&rt->auth_b64);
} | {
"code": [],
"line_no": []
} | void FUNC_0(AVFormatContext *VAR_0)
{
RTSPState *rt = VAR_0->priv_data;
int VAR_1;
RTSPStream *rtsp_st;
for (VAR_1 = 0; VAR_1 < rt->nb_rtsp_streams; VAR_1++) {
rtsp_st = rt->rtsp_streams[VAR_1];
if (rtsp_st) {
if (rtsp_st->transport_priv) {
if (VAR_0->oformat) {
AVFormatContext *rtpctx = rtsp_st->transport_priv;
av_write_trailer(rtpctx);
url_fclose(rtpctx->pb);
av_free(rtpctx->streams[0]);
av_free(rtpctx);
} else if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_parse_close(rtsp_st->transport_priv);
else
rtp_parse_close(rtsp_st->transport_priv);
}
if (rtsp_st->rtp_handle)
url_close(rtsp_st->rtp_handle);
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler->close(
rtsp_st->dynamic_protocol_context);
}
}
av_free(rt->rtsp_streams);
if (rt->asf_ctx) {
av_close_input_stream (rt->asf_ctx);
rt->asf_ctx = NULL;
}
av_freep(&rt->auth_b64);
} | [
"void FUNC_0(AVFormatContext *VAR_0)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"int VAR_1;",
"RTSPStream *rtsp_st;",
"for (VAR_1 = 0; VAR_1 < rt->nb_rtsp_streams; VAR_1++) {",
"rtsp_st = rt->rtsp_streams[VAR_1];",
"if (rtsp_st) {",
"if (rtsp_st->transport_priv) {",
"if (VAR_0->oformat) {",
"AVFormatContext *rtpctx = rtsp_st->transport_priv;",
"av_write_trailer(rtpctx);",
"url_fclose(rtpctx->pb);",
"av_free(rtpctx->streams[0]);",
"av_free(rtpctx);",
"} else if (rt->transport == RTSP_TRANSPORT_RDT)",
"ff_rdt_parse_close(rtsp_st->transport_priv);",
"else\nrtp_parse_close(rtsp_st->transport_priv);",
"}",
"if (rtsp_st->rtp_handle)\nurl_close(rtsp_st->rtp_handle);",
"if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)\nrtsp_st->dynamic_handler->close(\nrtsp_st->dynamic_protocol_context);",
"}",
"}",
"av_free(rt->rtsp_streams);",
"if (rt->asf_ctx) {",
"av_close_input_stream (rt->asf_ctx);",
"rt->asf_ctx = NULL;",
"}",
"av_freep(&rt->auth_b64);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
2,453 | void replay_save_instructions(void)
{
if (replay_file && replay_mode == REPLAY_MODE_RECORD) {
replay_mutex_lock();
int diff = (int)(replay_get_current_step() - replay_state.current_step);
if (diff > 0) {
replay_put_event(EVENT_INSTRUCTION);
replay_put_dword(diff);
replay_state.current_step += diff;
}
replay_mutex_unlock();
}
} | true | qemu | 982263ce714ffcc4c7c41a7b255bd29e093912fe | void replay_save_instructions(void)
{
if (replay_file && replay_mode == REPLAY_MODE_RECORD) {
replay_mutex_lock();
int diff = (int)(replay_get_current_step() - replay_state.current_step);
if (diff > 0) {
replay_put_event(EVENT_INSTRUCTION);
replay_put_dword(diff);
replay_state.current_step += diff;
}
replay_mutex_unlock();
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
if (replay_file && replay_mode == REPLAY_MODE_RECORD) {
replay_mutex_lock();
int VAR_0 = (int)(replay_get_current_step() - replay_state.current_step);
if (VAR_0 > 0) {
replay_put_event(EVENT_INSTRUCTION);
replay_put_dword(VAR_0);
replay_state.current_step += VAR_0;
}
replay_mutex_unlock();
}
} | [
"void FUNC_0(void)\n{",
"if (replay_file && replay_mode == REPLAY_MODE_RECORD) {",
"replay_mutex_lock();",
"int VAR_0 = (int)(replay_get_current_step() - replay_state.current_step);",
"if (VAR_0 > 0) {",
"replay_put_event(EVENT_INSTRUCTION);",
"replay_put_dword(VAR_0);",
"replay_state.current_step += VAR_0;",
"}",
"replay_mutex_unlock();",
"}",
"}"
] | [
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
]
] |
2,454 | int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
/* Verify if there is a device that doesn't support snapshots and is writable */
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
continue;
}
if (!bdrv_can_snapshot(bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
}
bs = bdrv_snapshots();
if (!bs) {
error_report("No block device supports snapshots");
return -EINVAL;
}
/* Flush all IO requests so they don't interfere with the new state. */
qemu_aio_flush();
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
ret = bdrv_snapshot_goto(bs1, name);
if (ret < 0) {
switch(ret) {
case -ENOTSUP:
error_report("%sSnapshots not supported on device '%s'",
bs != bs1 ? "Warning: " : "",
bdrv_get_device_name(bs1));
break;
case -ENOENT:
error_report("%sCould not find snapshot '%s' on device '%s'",
bs != bs1 ? "Warning: " : "",
name, bdrv_get_device_name(bs1));
break;
default:
error_report("%sError %d while activating snapshot on '%s'",
bs != bs1 ? "Warning: " : "",
ret, bdrv_get_device_name(bs1));
break;
}
/* fatal on snapshot block device */
if (bs == bs1)
return 0;
}
}
}
/* Don't even try to load empty VM states */
ret = bdrv_snapshot_find(bs, &sn, name);
if ((ret >= 0) && (sn.vm_state_size == 0))
return -EINVAL;
/* restore the VM state */
f = qemu_fopen_bdrv(bs, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
ret = qemu_loadvm_state(f);
qemu_fclose(f);
if (ret < 0) {
error_report("Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| true | qemu | f0aa7a8b2d518c54430e4382309281b93e51981a | int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int ret;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
continue;
}
if (!bdrv_can_snapshot(bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
}
bs = bdrv_snapshots();
if (!bs) {
error_report("No block device supports snapshots");
return -EINVAL;
}
qemu_aio_flush();
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
ret = bdrv_snapshot_goto(bs1, name);
if (ret < 0) {
switch(ret) {
case -ENOTSUP:
error_report("%sSnapshots not supported on device '%s'",
bs != bs1 ? "Warning: " : "",
bdrv_get_device_name(bs1));
break;
case -ENOENT:
error_report("%sCould not find snapshot '%s' on device '%s'",
bs != bs1 ? "Warning: " : "",
name, bdrv_get_device_name(bs1));
break;
default:
error_report("%sError %d while activating snapshot on '%s'",
bs != bs1 ? "Warning: " : "",
ret, bdrv_get_device_name(bs1));
break;
}
if (bs == bs1)
return 0;
}
}
}
ret = bdrv_snapshot_find(bs, &sn, name);
if ((ret >= 0) && (sn.vm_state_size == 0))
return -EINVAL;
f = qemu_fopen_bdrv(bs, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
ret = qemu_loadvm_state(f);
qemu_fclose(f);
if (ret < 0) {
error_report("Error %d while loading VM state", ret);
return ret;
}
return 0;
}
| {
"code": [
" BlockDriverState *bs, *bs1;",
" bs = bdrv_snapshots();",
" if (!bs) {",
" error_report(\"No block device supports snapshots\");",
" return -EINVAL;",
" bs1 = NULL;",
" while ((bs1 = bdrv_next(bs1))) {",
" if (bdrv_can_snapshot(bs1)) {",
" ret = bdrv_snapshot_goto(bs1, name);",
" switch(ret) {",
" case -ENOTSUP:",
" error_report(\"%sSnapshots not supported on device '%s'\",",
" bs != bs1 ? \"Warning: \" : \"\",",
" bdrv_get_device_name(bs1));",
" break;",
" case -ENOENT:",
" error_report(\"%sCould not find snapshot '%s' on device '%s'\",",
" bs != bs1 ? \"Warning: \" : \"\",",
" name, bdrv_get_device_name(bs1));",
" break;",
" default:",
" error_report(\"%sError %d while activating snapshot on '%s'\",",
" bs != bs1 ? \"Warning: \" : \"\",",
" ret, bdrv_get_device_name(bs1));",
" break;",
" if (bs == bs1)",
" return 0;",
" ret = bdrv_snapshot_find(bs, &sn, name);",
" if ((ret >= 0) && (sn.vm_state_size == 0))",
" return -EINVAL;",
" f = qemu_fopen_bdrv(bs, 0);"
],
"line_no": [
5,
45,
47,
49,
51,
63,
65,
67,
69,
73,
75,
77,
79,
81,
83,
85,
87,
79,
91,
83,
95,
97,
79,
101,
83,
109,
111,
123,
125,
51,
133
]
} | int FUNC_0(const char *VAR_0)
{
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
int VAR_1;
bs = NULL;
while ((bs = bdrv_next(bs))) {
if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
continue;
}
if (!bdrv_can_snapshot(bs)) {
error_report("Device '%s' is writable but does not support snapshots.",
bdrv_get_device_name(bs));
return -ENOTSUP;
}
}
bs = bdrv_snapshots();
if (!bs) {
error_report("No block device supports snapshots");
return -EINVAL;
}
qemu_aio_flush();
bs1 = NULL;
while ((bs1 = bdrv_next(bs1))) {
if (bdrv_can_snapshot(bs1)) {
VAR_1 = bdrv_snapshot_goto(bs1, VAR_0);
if (VAR_1 < 0) {
switch(VAR_1) {
case -ENOTSUP:
error_report("%sSnapshots not supported on device '%s'",
bs != bs1 ? "Warning: " : "",
bdrv_get_device_name(bs1));
break;
case -ENOENT:
error_report("%sCould not find snapshot '%s' on device '%s'",
bs != bs1 ? "Warning: " : "",
VAR_0, bdrv_get_device_name(bs1));
break;
default:
error_report("%sError %d while activating snapshot on '%s'",
bs != bs1 ? "Warning: " : "",
VAR_1, bdrv_get_device_name(bs1));
break;
}
if (bs == bs1)
return 0;
}
}
}
VAR_1 = bdrv_snapshot_find(bs, &sn, VAR_0);
if ((VAR_1 >= 0) && (sn.vm_state_size == 0))
return -EINVAL;
f = qemu_fopen_bdrv(bs, 0);
if (!f) {
error_report("Could not open VM state file");
return -EINVAL;
}
VAR_1 = qemu_loadvm_state(f);
qemu_fclose(f);
if (VAR_1 < 0) {
error_report("Error %d while loading VM state", VAR_1);
return VAR_1;
}
return 0;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"BlockDriverState *bs, *bs1;",
"QEMUSnapshotInfo sn;",
"QEMUFile *f;",
"int VAR_1;",
"bs = NULL;",
"while ((bs = bdrv_next(bs))) {",
"if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {",
"continue;",
"}",
"if (!bdrv_can_snapshot(bs)) {",
"error_report(\"Device '%s' is writable but does not support snapshots.\",\nbdrv_get_device_name(bs));",
"return -ENOTSUP;",
"}",
"}",
"bs = bdrv_snapshots();",
"if (!bs) {",
"error_report(\"No block device supports snapshots\");",
"return -EINVAL;",
"}",
"qemu_aio_flush();",
"bs1 = NULL;",
"while ((bs1 = bdrv_next(bs1))) {",
"if (bdrv_can_snapshot(bs1)) {",
"VAR_1 = bdrv_snapshot_goto(bs1, VAR_0);",
"if (VAR_1 < 0) {",
"switch(VAR_1) {",
"case -ENOTSUP:\nerror_report(\"%sSnapshots not supported on device '%s'\",\nbs != bs1 ? \"Warning: \" : \"\",\nbdrv_get_device_name(bs1));",
"break;",
"case -ENOENT:\nerror_report(\"%sCould not find snapshot '%s' on device '%s'\",\nbs != bs1 ? \"Warning: \" : \"\",\nVAR_0, bdrv_get_device_name(bs1));",
"break;",
"default:\nerror_report(\"%sError %d while activating snapshot on '%s'\",\nbs != bs1 ? \"Warning: \" : \"\",\nVAR_1, bdrv_get_device_name(bs1));",
"break;",
"}",
"if (bs == bs1)\nreturn 0;",
"}",
"}",
"}",
"VAR_1 = bdrv_snapshot_find(bs, &sn, VAR_0);",
"if ((VAR_1 >= 0) && (sn.vm_state_size == 0))\nreturn -EINVAL;",
"f = qemu_fopen_bdrv(bs, 0);",
"if (!f) {",
"error_report(\"Could not open VM state file\");",
"return -EINVAL;",
"}",
"VAR_1 = qemu_loadvm_state(f);",
"qemu_fclose(f);",
"if (VAR_1 < 0) {",
"error_report(\"Error %d while loading VM state\", VAR_1);",
"return VAR_1;",
"}",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
0,
0,
1,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77,
79,
81
],
[
83
],
[
85,
87,
89,
91
],
[
93
],
[
95,
97,
99,
101
],
[
103
],
[
105
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
123
],
[
125,
127
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
]
] |
2,455 | static int flv_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;
int i, metadata_count = 0;
double framerate = 0.0;
int64_t metadata_size_pos, data_size, metadata_count_pos;
AVDictionaryEntry *tag = NULL;
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
FLVStreamContext *sc;
switch (enc->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (s->streams[i]->r_frame_rate.den &&
s->streams[i]->r_frame_rate.num) {
framerate = av_q2d(s->streams[i]->r_frame_rate);
} else {
framerate = 1 / av_q2d(s->streams[i]->codec->time_base);
}
video_enc = enc;
if (enc->codec_tag == 0) {
av_log(s, AV_LOG_ERROR, "video codec not compatible with flv\n");
return -1;
}
break;
case AVMEDIA_TYPE_AUDIO:
audio_enc = enc;
if (get_audio_flags(s, enc) < 0)
return AVERROR_INVALIDDATA;
break;
case AVMEDIA_TYPE_DATA:
if (enc->codec_id != CODEC_ID_TEXT) {
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
return AVERROR_INVALIDDATA;
}
data_enc = enc;
break;
default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
return -1;
}
avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
sc = av_mallocz(sizeof(FLVStreamContext));
if (!sc)
return AVERROR(ENOMEM);
s->streams[i]->priv_data = sc;
sc->last_ts = -1;
}
flv->delay = AV_NOPTS_VALUE;
avio_write(pb, "FLV", 3);
avio_w8(pb, 1);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc +
FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
avio_wb32(pb, 9);
avio_wb32(pb, 0);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_tag == 5) {
avio_w8(pb, 8); // message type
avio_wb24(pb, 0); // include flags
avio_wb24(pb, 0); // time stamp
avio_wb32(pb, 0); // reserved
avio_wb32(pb, 11); // size
flv->reserved = 5;
}
/* write meta_tag */
avio_w8(pb, 18); // tag type META
metadata_size_pos = avio_tell(pb);
avio_wb24(pb, 0); // size of data part (sum of all parts below)
avio_wb24(pb, 0); // timestamp
avio_wb32(pb, 0); // reserved
/* now data of data_size size */
/* first event name as a string */
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData"); // 12 bytes
/* mixed array (hash) with size and string/type/data tuples */
avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
metadata_count_pos = avio_tell(pb);
metadata_count = 5 * !!video_enc +
5 * !!audio_enc +
1 * !!data_enc +
2; // +2 for duration and file size
avio_wb32(pb, metadata_count);
put_amf_string(pb, "duration");
flv->duration_offset= avio_tell(pb);
// fill in the guessed duration, it'll be corrected later if incorrect
put_amf_double(pb, s->duration / AV_TIME_BASE);
if (video_enc) {
put_amf_string(pb, "width");
put_amf_double(pb, video_enc->width);
put_amf_string(pb, "height");
put_amf_double(pb, video_enc->height);
put_amf_string(pb, "videodatarate");
put_amf_double(pb, video_enc->bit_rate / 1024.0);
put_amf_string(pb, "framerate");
put_amf_double(pb, framerate);
put_amf_string(pb, "videocodecid");
put_amf_double(pb, video_enc->codec_tag);
}
if (audio_enc) {
put_amf_string(pb, "audiodatarate");
put_amf_double(pb, audio_enc->bit_rate / 1024.0);
put_amf_string(pb, "audiosamplerate");
put_amf_double(pb, audio_enc->sample_rate);
put_amf_string(pb, "audiosamplesize");
put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_string(pb, "stereo");
put_amf_bool(pb, audio_enc->channels == 2);
put_amf_string(pb, "audiocodecid");
put_amf_double(pb, audio_enc->codec_tag);
}
if (data_enc) {
put_amf_string(pb, "datastream");
put_amf_double(pb, 0.0);
}
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
metadata_count++;
}
put_amf_string(pb, "filesize");
flv->filesize_offset = avio_tell(pb);
put_amf_double(pb, 0); // delayed write
put_amf_string(pb, "");
avio_w8(pb, AMF_END_OF_OBJECT);
/* write total size of tag */
data_size = avio_tell(pb) - metadata_size_pos - 10;
avio_seek(pb, metadata_count_pos, SEEK_SET);
avio_wb32(pb, metadata_count);
avio_seek(pb, metadata_size_pos, SEEK_SET);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11);
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
int64_t pos;
avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
avio_wb24(pb, 0); // size patched later
avio_wb24(pb, 0); // ts
avio_w8(pb, 0); // ts ext
avio_wb24(pb, 0); // streamid
pos = avio_tell(pb);
if (enc->codec_id == CODEC_ID_AAC) {
avio_w8(pb, get_audio_flags(s, enc));
avio_w8(pb, 0); // AAC sequence header
avio_write(pb, enc->extradata, enc->extradata_size);
} else {
avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
avio_w8(pb, 0); // AVC sequence header
avio_wb24(pb, 0); // composition time
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
}
data_size = avio_tell(pb) - pos;
avio_seek(pb, -data_size - 10, SEEK_CUR);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11); // previous tag size
}
}
return 0;
}
| true | FFmpeg | aba232cfa9b193604ed98f3fa505378d006b1b3b | static int flv_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;
int i, metadata_count = 0;
double framerate = 0.0;
int64_t metadata_size_pos, data_size, metadata_count_pos;
AVDictionaryEntry *tag = NULL;
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
FLVStreamContext *sc;
switch (enc->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (s->streams[i]->r_frame_rate.den &&
s->streams[i]->r_frame_rate.num) {
framerate = av_q2d(s->streams[i]->r_frame_rate);
} else {
framerate = 1 / av_q2d(s->streams[i]->codec->time_base);
}
video_enc = enc;
if (enc->codec_tag == 0) {
av_log(s, AV_LOG_ERROR, "video codec not compatible with flv\n");
return -1;
}
break;
case AVMEDIA_TYPE_AUDIO:
audio_enc = enc;
if (get_audio_flags(s, enc) < 0)
return AVERROR_INVALIDDATA;
break;
case AVMEDIA_TYPE_DATA:
if (enc->codec_id != CODEC_ID_TEXT) {
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
return AVERROR_INVALIDDATA;
}
data_enc = enc;
break;
default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
return -1;
}
avpriv_set_pts_info(s->streams[i], 32, 1, 1000);
sc = av_mallocz(sizeof(FLVStreamContext));
if (!sc)
return AVERROR(ENOMEM);
s->streams[i]->priv_data = sc;
sc->last_ts = -1;
}
flv->delay = AV_NOPTS_VALUE;
avio_write(pb, "FLV", 3);
avio_w8(pb, 1);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc +
FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
avio_wb32(pb, 9);
avio_wb32(pb, 0);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_tag == 5) {
avio_w8(pb, 8);
avio_wb24(pb, 0);
avio_wb24(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 11);
flv->reserved = 5;
}
avio_w8(pb, 18);
metadata_size_pos = avio_tell(pb);
avio_wb24(pb, 0); of data part (sum of all parts below)
avio_wb24(pb, 0);
avio_wb32(pb, 0);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData");
avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
metadata_count_pos = avio_tell(pb);
metadata_count = 5 * !!video_enc +
5 * !!audio_enc +
1 * !!data_enc +
2;
avio_wb32(pb, metadata_count);
put_amf_string(pb, "duration");
flv->duration_offset= avio_tell(pb);
put_amf_double(pb, s->duration / AV_TIME_BASE);
if (video_enc) {
put_amf_string(pb, "width");
put_amf_double(pb, video_enc->width);
put_amf_string(pb, "height");
put_amf_double(pb, video_enc->height);
put_amf_string(pb, "videodatarate");
put_amf_double(pb, video_enc->bit_rate / 1024.0);
put_amf_string(pb, "framerate");
put_amf_double(pb, framerate);
put_amf_string(pb, "videocodecid");
put_amf_double(pb, video_enc->codec_tag);
}
if (audio_enc) {
put_amf_string(pb, "audiodatarate");
put_amf_double(pb, audio_enc->bit_rate / 1024.0);
put_amf_string(pb, "audiosamplerate");
put_amf_double(pb, audio_enc->sample_rate);
put_amf_string(pb, "audiosamplesize");
put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_string(pb, "stereo");
put_amf_bool(pb, audio_enc->channels == 2);
put_amf_string(pb, "audiocodecid");
put_amf_double(pb, audio_enc->codec_tag);
}
if (data_enc) {
put_amf_string(pb, "datastream");
put_amf_double(pb, 0.0);
}
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
metadata_count++;
}
put_amf_string(pb, "filesize");
flv->filesize_offset = avio_tell(pb);
put_amf_double(pb, 0);
put_amf_string(pb, "");
avio_w8(pb, AMF_END_OF_OBJECT);
data_size = avio_tell(pb) - metadata_size_pos - 10;
avio_seek(pb, metadata_count_pos, SEEK_SET);
avio_wb32(pb, metadata_count);
avio_seek(pb, metadata_size_pos, SEEK_SET);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11);
for (i = 0; i < s->nb_streams; i++) {
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
int64_t pos;
avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
avio_wb24(pb, 0); patched later
avio_wb24(pb, 0);
avio_w8(pb, 0); ext
avio_wb24(pb, 0);
pos = avio_tell(pb);
if (enc->codec_id == CODEC_ID_AAC) {
avio_w8(pb, get_audio_flags(s, enc));
avio_w8(pb, 0);
avio_write(pb, enc->extradata, enc->extradata_size);
} else {
avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY);
avio_w8(pb, 0);
avio_wb24(pb, 0);
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
}
data_size = avio_tell(pb) - pos;
avio_seek(pb, -data_size - 10, SEEK_CUR);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11);
}
}
return 0;
}
| {
"code": [
" if (s->streams[i]->r_frame_rate.den &&",
" s->streams[i]->r_frame_rate.num) {",
" framerate = av_q2d(s->streams[i]->r_frame_rate);"
],
"line_no": [
31,
33,
35
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
AVIOContext *pb = VAR_0->pb;
FLVContext *flv = VAR_0->priv_data;
AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;
int VAR_1, VAR_2 = 0;
double VAR_3 = 0.0;
int64_t metadata_size_pos, data_size, metadata_count_pos;
AVDictionaryEntry *tag = NULL;
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVCodecContext *enc = VAR_0->streams[VAR_1]->codec;
FLVStreamContext *sc;
switch (enc->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (VAR_0->streams[VAR_1]->r_frame_rate.den &&
VAR_0->streams[VAR_1]->r_frame_rate.num) {
VAR_3 = av_q2d(VAR_0->streams[VAR_1]->r_frame_rate);
} else {
VAR_3 = 1 / av_q2d(VAR_0->streams[VAR_1]->codec->time_base);
}
video_enc = enc;
if (enc->codec_tag == 0) {
av_log(VAR_0, AV_LOG_ERROR, "video codec not compatible with flv\n");
return -1;
}
break;
case AVMEDIA_TYPE_AUDIO:
audio_enc = enc;
if (get_audio_flags(VAR_0, enc) < 0)
return AVERROR_INVALIDDATA;
break;
case AVMEDIA_TYPE_DATA:
if (enc->codec_id != CODEC_ID_TEXT) {
av_log(VAR_0, AV_LOG_ERROR, "codec not compatible with flv\n");
return AVERROR_INVALIDDATA;
}
data_enc = enc;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "codec not compatible with flv\n");
return -1;
}
avpriv_set_pts_info(VAR_0->streams[VAR_1], 32, 1, 1000);
sc = av_mallocz(sizeof(FLVStreamContext));
if (!sc)
return AVERROR(ENOMEM);
VAR_0->streams[VAR_1]->priv_data = sc;
sc->last_ts = -1;
}
flv->delay = AV_NOPTS_VALUE;
avio_write(pb, "FLV", 3);
avio_w8(pb, 1);
avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc +
FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
avio_wb32(pb, 9);
avio_wb32(pb, 0);
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++)
if (VAR_0->streams[VAR_1]->codec->codec_tag == 5) {
avio_w8(pb, 8);
avio_wb24(pb, 0);
avio_wb24(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 11);
flv->reserved = 5;
}
avio_w8(pb, 18);
metadata_size_pos = avio_tell(pb);
avio_wb24(pb, 0); of data part (sum of all parts below)
avio_wb24(pb, 0);
avio_wb32(pb, 0);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData");
avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
metadata_count_pos = avio_tell(pb);
VAR_2 = 5 * !!video_enc +
5 * !!audio_enc +
1 * !!data_enc +
2;
avio_wb32(pb, VAR_2);
put_amf_string(pb, "duration");
flv->duration_offset= avio_tell(pb);
put_amf_double(pb, VAR_0->duration / AV_TIME_BASE);
if (video_enc) {
put_amf_string(pb, "width");
put_amf_double(pb, video_enc->width);
put_amf_string(pb, "height");
put_amf_double(pb, video_enc->height);
put_amf_string(pb, "videodatarate");
put_amf_double(pb, video_enc->bit_rate / 1024.0);
put_amf_string(pb, "VAR_3");
put_amf_double(pb, VAR_3);
put_amf_string(pb, "videocodecid");
put_amf_double(pb, video_enc->codec_tag);
}
if (audio_enc) {
put_amf_string(pb, "audiodatarate");
put_amf_double(pb, audio_enc->bit_rate / 1024.0);
put_amf_string(pb, "audiosamplerate");
put_amf_double(pb, audio_enc->sample_rate);
put_amf_string(pb, "audiosamplesize");
put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);
put_amf_string(pb, "stereo");
put_amf_bool(pb, audio_enc->channels == 2);
put_amf_string(pb, "audiocodecid");
put_amf_double(pb, audio_enc->codec_tag);
}
if (data_enc) {
put_amf_string(pb, "datastream");
put_amf_double(pb, 0.0);
}
while ((tag = av_dict_get(VAR_0->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
VAR_2++;
}
put_amf_string(pb, "filesize");
flv->filesize_offset = avio_tell(pb);
put_amf_double(pb, 0);
put_amf_string(pb, "");
avio_w8(pb, AMF_END_OF_OBJECT);
data_size = avio_tell(pb) - metadata_size_pos - 10;
avio_seek(pb, metadata_count_pos, SEEK_SET);
avio_wb32(pb, VAR_2);
avio_seek(pb, metadata_size_pos, SEEK_SET);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11);
for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
AVCodecContext *enc = VAR_0->streams[VAR_1]->codec;
if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
int64_t pos;
avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
avio_wb24(pb, 0); patched later
avio_wb24(pb, 0);
avio_w8(pb, 0); ext
avio_wb24(pb, 0);
pos = avio_tell(pb);
if (enc->codec_id == CODEC_ID_AAC) {
avio_w8(pb, get_audio_flags(VAR_0, enc));
avio_w8(pb, 0);
avio_write(pb, enc->extradata, enc->extradata_size);
} else {
avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY);
avio_w8(pb, 0);
avio_wb24(pb, 0);
ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
}
data_size = avio_tell(pb) - pos;
avio_seek(pb, -data_size - 10, SEEK_CUR);
avio_wb24(pb, data_size);
avio_skip(pb, data_size + 10 - 3);
avio_wb32(pb, data_size + 11);
}
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"AVIOContext *pb = VAR_0->pb;",
"FLVContext *flv = VAR_0->priv_data;",
"AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;",
"int VAR_1, VAR_2 = 0;",
"double VAR_3 = 0.0;",
"int64_t metadata_size_pos, data_size, metadata_count_pos;",
"AVDictionaryEntry *tag = NULL;",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVCodecContext *enc = VAR_0->streams[VAR_1]->codec;",
"FLVStreamContext *sc;",
"switch (enc->codec_type) {",
"case AVMEDIA_TYPE_VIDEO:\nif (VAR_0->streams[VAR_1]->r_frame_rate.den &&\nVAR_0->streams[VAR_1]->r_frame_rate.num) {",
"VAR_3 = av_q2d(VAR_0->streams[VAR_1]->r_frame_rate);",
"} else {",
"VAR_3 = 1 / av_q2d(VAR_0->streams[VAR_1]->codec->time_base);",
"}",
"video_enc = enc;",
"if (enc->codec_tag == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"video codec not compatible with flv\\n\");",
"return -1;",
"}",
"break;",
"case AVMEDIA_TYPE_AUDIO:\naudio_enc = enc;",
"if (get_audio_flags(VAR_0, enc) < 0)\nreturn AVERROR_INVALIDDATA;",
"break;",
"case AVMEDIA_TYPE_DATA:\nif (enc->codec_id != CODEC_ID_TEXT) {",
"av_log(VAR_0, AV_LOG_ERROR, \"codec not compatible with flv\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"data_enc = enc;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"codec not compatible with flv\\n\");",
"return -1;",
"}",
"avpriv_set_pts_info(VAR_0->streams[VAR_1], 32, 1, 1000);",
"sc = av_mallocz(sizeof(FLVStreamContext));",
"if (!sc)\nreturn AVERROR(ENOMEM);",
"VAR_0->streams[VAR_1]->priv_data = sc;",
"sc->last_ts = -1;",
"}",
"flv->delay = AV_NOPTS_VALUE;",
"avio_write(pb, \"FLV\", 3);",
"avio_w8(pb, 1);",
"avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc +\nFLV_HEADER_FLAG_HASVIDEO * !!video_enc);",
"avio_wb32(pb, 9);",
"avio_wb32(pb, 0);",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++)",
"if (VAR_0->streams[VAR_1]->codec->codec_tag == 5) {",
"avio_w8(pb, 8);",
"avio_wb24(pb, 0);",
"avio_wb24(pb, 0);",
"avio_wb32(pb, 0);",
"avio_wb32(pb, 11);",
"flv->reserved = 5;",
"}",
"avio_w8(pb, 18);",
"metadata_size_pos = avio_tell(pb);",
"avio_wb24(pb, 0); of data part (sum of all parts below)",
"avio_wb24(pb, 0);",
"avio_wb32(pb, 0);",
"avio_w8(pb, AMF_DATA_TYPE_STRING);",
"put_amf_string(pb, \"onMetaData\");",
"avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);",
"metadata_count_pos = avio_tell(pb);",
"VAR_2 = 5 * !!video_enc +\n5 * !!audio_enc +\n1 * !!data_enc +\n2;",
"avio_wb32(pb, VAR_2);",
"put_amf_string(pb, \"duration\");",
"flv->duration_offset= avio_tell(pb);",
"put_amf_double(pb, VAR_0->duration / AV_TIME_BASE);",
"if (video_enc) {",
"put_amf_string(pb, \"width\");",
"put_amf_double(pb, video_enc->width);",
"put_amf_string(pb, \"height\");",
"put_amf_double(pb, video_enc->height);",
"put_amf_string(pb, \"videodatarate\");",
"put_amf_double(pb, video_enc->bit_rate / 1024.0);",
"put_amf_string(pb, \"VAR_3\");",
"put_amf_double(pb, VAR_3);",
"put_amf_string(pb, \"videocodecid\");",
"put_amf_double(pb, video_enc->codec_tag);",
"}",
"if (audio_enc) {",
"put_amf_string(pb, \"audiodatarate\");",
"put_amf_double(pb, audio_enc->bit_rate / 1024.0);",
"put_amf_string(pb, \"audiosamplerate\");",
"put_amf_double(pb, audio_enc->sample_rate);",
"put_amf_string(pb, \"audiosamplesize\");",
"put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);",
"put_amf_string(pb, \"stereo\");",
"put_amf_bool(pb, audio_enc->channels == 2);",
"put_amf_string(pb, \"audiocodecid\");",
"put_amf_double(pb, audio_enc->codec_tag);",
"}",
"if (data_enc) {",
"put_amf_string(pb, \"datastream\");",
"put_amf_double(pb, 0.0);",
"}",
"while ((tag = av_dict_get(VAR_0->metadata, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {",
"put_amf_string(pb, tag->key);",
"avio_w8(pb, AMF_DATA_TYPE_STRING);",
"put_amf_string(pb, tag->value);",
"VAR_2++;",
"}",
"put_amf_string(pb, \"filesize\");",
"flv->filesize_offset = avio_tell(pb);",
"put_amf_double(pb, 0);",
"put_amf_string(pb, \"\");",
"avio_w8(pb, AMF_END_OF_OBJECT);",
"data_size = avio_tell(pb) - metadata_size_pos - 10;",
"avio_seek(pb, metadata_count_pos, SEEK_SET);",
"avio_wb32(pb, VAR_2);",
"avio_seek(pb, metadata_size_pos, SEEK_SET);",
"avio_wb24(pb, data_size);",
"avio_skip(pb, data_size + 10 - 3);",
"avio_wb32(pb, data_size + 11);",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"AVCodecContext *enc = VAR_0->streams[VAR_1]->codec;",
"if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {",
"int64_t pos;",
"avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?\nFLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);",
"avio_wb24(pb, 0); patched later",
"avio_wb24(pb, 0);",
"avio_w8(pb, 0); ext",
"avio_wb24(pb, 0);",
"pos = avio_tell(pb);",
"if (enc->codec_id == CODEC_ID_AAC) {",
"avio_w8(pb, get_audio_flags(VAR_0, enc));",
"avio_w8(pb, 0);",
"avio_write(pb, enc->extradata, enc->extradata_size);",
"} else {",
"avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY);",
"avio_w8(pb, 0);",
"avio_wb24(pb, 0);",
"ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);",
"}",
"data_size = avio_tell(pb) - pos;",
"avio_seek(pb, -data_size - 10, SEEK_CUR);",
"avio_wb24(pb, data_size);",
"avio_skip(pb, data_size + 10 - 3);",
"avio_wb32(pb, data_size + 11);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
163
],
[
165
],
[
171
],
[
173
],
[
175,
177,
179,
181
],
[
185
],
[
189
],
[
191
],
[
197
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
249
],
[
251
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303
],
[
309
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
389
]
] |
2,456 | void ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
{
char *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}");
for (; !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
rstrip_spaces_buf(dst);
av_bprintf(dst, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
av_bprint_chars(dst, *in, 1);
break;
case '{': /* skip all {\xxx} substrings except for {\an%d}
and all microdvd like styles such as {Y:xxx} */
len = 0;
an += sscanf(in, "{\\an%*1u}%n", &len) >= 0 && len > 0;
if ((an != 1 && (len = 0, sscanf(in, "{\\%*[^}]}%n", &len) >= 0 && len > 0)) ||
(len = 0, sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n", &len) >= 0 && len > 0)) {
in += len - 1;
} else
av_bprint_chars(dst, *in, 1);
break;
case '<':
tag_close = in[1] == '/';
len = 0;
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!strcmp(tagname, "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]) {
av_bprintf(dst, "%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(log_ctx, 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])
av_bprintf(dst, "%s", stack[sptr].param[i]);
}
} else if (tagname[0] && !tagname[1] && strspn(tagname, "bisu") == 1) {
av_bprintf(dst, "{\\%c%d}", tagname[0], !tag_close);
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", tagname);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
av_bprint_chars(dst, *in, 1);
} else
av_strlcpy(stack[sptr++].tag, tagname,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(dst, *in, 1);
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
dst->len -= 2;
dst->str[dst->len] = 0;
rstrip_spaces_buf(dst);
}
| true | FFmpeg | f4ae3cce64bd46b1d539bdeac39753f83015f114 | void ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
{
char *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}");
for (; !end && *in; in++) {
switch (*in) {
case '\r':
break;
case '\n':
if (line_start) {
end = 1;
break;
}
rstrip_spaces_buf(dst);
av_bprintf(dst, "\\N");
line_start = 1;
break;
case ' ':
if (!line_start)
av_bprint_chars(dst, *in, 1);
break;
case '{':
len = 0;
an += sscanf(in, "{\\an%*1u}%n", &len) >= 0 && len > 0;
if ((an != 1 && (len = 0, sscanf(in, "{\\%*[^}]}%n", &len) >= 0 && len > 0)) ||
(len = 0, sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n", &len) >= 0 && len > 0)) {
in += len - 1;
} else
av_bprint_chars(dst, *in, 1);
break;
case '<':
tag_close = in[1] == '/';
len = 0;
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
const char *tagname = buffer;
while (*tagname == ' ')
tagname++;
if ((param = strchr(tagname, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, tagname))) {
int i, j, unknown = 0;
in += len + tag_close;
if (!tag_close)
memset(stack+sptr, 0, sizeof(*stack));
if (!strcmp(tagname, "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]) {
av_bprintf(dst, "%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(log_ctx, 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])
av_bprintf(dst, "%s", stack[sptr].param[i]);
}
} else if (tagname[0] && !tagname[1] && strspn(tagname, "bisu") == 1) {
av_bprintf(dst, "{\\%c%d}", tagname[0], !tag_close);
} else {
unknown = 1;
snprintf(tmp, sizeof(tmp), "</%s>", tagname);
}
if (tag_close) {
sptr--;
} else if (unknown && !strstr(in, tmp)) {
in -= len + tag_close;
av_bprint_chars(dst, *in, 1);
} else
av_strlcpy(stack[sptr++].tag, tagname,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(dst, *in, 1);
break;
}
if (*in != ' ' && *in != '\r' && *in != '\n')
line_start = 0;
}
while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
dst->len -= 2;
dst->str[dst->len] = 0;
rstrip_spaces_buf(dst);
}
| {
"code": [
"void ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)"
],
"line_no": [
1
]
} | void FUNC_0(void *VAR_0, AVBPrint *VAR_1, const char *VAR_2)
{
char *VAR_3, VAR_4[128], VAR_5[128];
int VAR_6, VAR_7, VAR_8 = 1, VAR_9 = 1, VAR_10 = 0, VAR_11 = 0;
SrtStack stack[16];
stack[0].tag[0] = 0;
strcpy(stack[0].VAR_3[PARAM_SIZE], "{\\fs}");
strcpy(stack[0].VAR_3[PARAM_COLOR], "{\\c}");
strcpy(stack[0].VAR_3[PARAM_FACE], "{\\fn}");
for (; !VAR_11 && *VAR_2; VAR_2++) {
switch (*VAR_2) {
case '\r':
break;
case '\n':
if (VAR_9) {
VAR_11 = 1;
break;
}
rstrip_spaces_buf(VAR_1);
av_bprintf(VAR_1, "\\N");
VAR_9 = 1;
break;
case ' ':
if (!VAR_9)
av_bprint_chars(VAR_1, *VAR_2, 1);
break;
case '{':
VAR_6 = 0;
VAR_10 += sscanf(VAR_2, "{\\VAR_10%*1u}%n", &VAR_6) >= 0 && VAR_6 > 0;
if ((VAR_10 != 1 && (VAR_6 = 0, sscanf(VAR_2, "{\\%*[^}]}%n", &VAR_6) >= 0 && VAR_6 > 0)) ||
(VAR_6 = 0, sscanf(VAR_2, "{%*1[CcFfoPSsYy]:%*[^}]}%n", &VAR_6) >= 0 && VAR_6 > 0)) {
VAR_2 += VAR_6 - 1;
} else
av_bprint_chars(VAR_1, *VAR_2, 1);
break;
case '<':
VAR_7 = VAR_2[1] == '/';
VAR_6 = 0;
if (sscanf(VAR_2+VAR_7+1, "%127[^>]>%n", VAR_4, &VAR_6) >= 1 && VAR_6 > 0) {
const char *VAR_12 = VAR_4;
while (*VAR_12 == ' ')
VAR_12++;
if ((VAR_3 = strchr(VAR_12, ' ')))
*VAR_3++ = 0;
if ((!VAR_7 && VAR_8 < FF_ARRAY_ELEMS(stack)) ||
( VAR_7 && VAR_8 > 0 && !strcmp(stack[VAR_8-1].tag, VAR_12))) {
int VAR_13, VAR_14, VAR_15 = 0;
VAR_2 += VAR_6 + VAR_7;
if (!VAR_7)
memset(stack+VAR_8, 0, sizeof(*stack));
if (!strcmp(VAR_12, "font")) {
if (VAR_7) {
for (VAR_13=PARAM_NUMBER-1; VAR_13>=0; VAR_13--)
if (stack[VAR_8-1].VAR_3[VAR_13][0])
for (VAR_14=VAR_8-2; VAR_14>=0; VAR_14--)
if (stack[VAR_14].VAR_3[VAR_13][0]) {
av_bprintf(VAR_1, "%s", stack[VAR_14].VAR_3[VAR_13]);
break;
}
} else {
while (VAR_3) {
if (!strncmp(VAR_3, "size=", 5)) {
unsigned VAR_16;
VAR_3 += 5 + (VAR_3[5] == '"');
if (sscanf(VAR_3, "%u", &VAR_16) == 1) {
snprintf(stack[VAR_8].VAR_3[PARAM_SIZE],
sizeof(stack[0].VAR_3[PARAM_SIZE]),
"{\\fs%u}", VAR_16);
}
} else if (!strncmp(VAR_3, "color=", 6)) {
VAR_3 += 6 + (VAR_3[6] == '"');
snprintf(stack[VAR_8].VAR_3[PARAM_COLOR],
sizeof(stack[0].VAR_3[PARAM_COLOR]),
"{\\c&H%X&}",
html_color_parse(VAR_0, VAR_3));
} else if (!strncmp(VAR_3, "face=", 5)) {
VAR_3 += 5 + (VAR_3[5] == '"');
VAR_6 = strcspn(VAR_3,
VAR_3[-1] == '"' ? "\"" :" ");
av_strlcpy(VAR_5, VAR_3,
FFMIN(sizeof(VAR_5), VAR_6+1));
VAR_3 += VAR_6;
snprintf(stack[VAR_8].VAR_3[PARAM_FACE],
sizeof(stack[0].VAR_3[PARAM_FACE]),
"{\\fn%s}", VAR_5);
}
if ((VAR_3 = strchr(VAR_3, ' ')))
VAR_3++;
}
for (VAR_13=0; VAR_13<PARAM_NUMBER; VAR_13++)
if (stack[VAR_8].VAR_3[VAR_13][0])
av_bprintf(VAR_1, "%s", stack[VAR_8].VAR_3[VAR_13]);
}
} else if (VAR_12[0] && !VAR_12[1] && strspn(VAR_12, "bisu") == 1) {
av_bprintf(VAR_1, "{\\%c%d}", VAR_12[0], !VAR_7);
} else {
VAR_15 = 1;
snprintf(VAR_5, sizeof(VAR_5), "</%s>", VAR_12);
}
if (VAR_7) {
VAR_8--;
} else if (VAR_15 && !strstr(VAR_2, VAR_5)) {
VAR_2 -= VAR_6 + VAR_7;
av_bprint_chars(VAR_1, *VAR_2, 1);
} else
av_strlcpy(stack[VAR_8++].tag, VAR_12,
sizeof(stack[0].tag));
break;
}
}
default:
av_bprint_chars(VAR_1, *VAR_2, 1);
break;
}
if (*VAR_2 != ' ' && *VAR_2 != '\r' && *VAR_2 != '\n')
VAR_9 = 0;
}
while (VAR_1->VAR_6 >= 2 && !strncmp(&VAR_1->str[VAR_1->VAR_6 - 2], "\\N", 2))
VAR_1->VAR_6 -= 2;
VAR_1->str[VAR_1->VAR_6] = 0;
rstrip_spaces_buf(VAR_1);
}
| [
"void FUNC_0(void *VAR_0, AVBPrint *VAR_1, const char *VAR_2)\n{",
"char *VAR_3, VAR_4[128], VAR_5[128];",
"int VAR_6, VAR_7, VAR_8 = 1, VAR_9 = 1, VAR_10 = 0, VAR_11 = 0;",
"SrtStack stack[16];",
"stack[0].tag[0] = 0;",
"strcpy(stack[0].VAR_3[PARAM_SIZE], \"{\\\\fs}\");",
"strcpy(stack[0].VAR_3[PARAM_COLOR], \"{\\\\c}\");",
"strcpy(stack[0].VAR_3[PARAM_FACE], \"{\\\\fn}\");",
"for (; !VAR_11 && *VAR_2; VAR_2++) {",
"switch (*VAR_2) {",
"case '\\r':\nbreak;",
"case '\\n':\nif (VAR_9) {",
"VAR_11 = 1;",
"break;",
"}",
"rstrip_spaces_buf(VAR_1);",
"av_bprintf(VAR_1, \"\\\\N\");",
"VAR_9 = 1;",
"break;",
"case ' ':\nif (!VAR_9)\nav_bprint_chars(VAR_1, *VAR_2, 1);",
"break;",
"case '{':",
"VAR_6 = 0;",
"VAR_10 += sscanf(VAR_2, \"{\\\\VAR_10%*1u}%n\", &VAR_6) >= 0 && VAR_6 > 0;",
"if ((VAR_10 != 1 && (VAR_6 = 0, sscanf(VAR_2, \"{\\\\%*[^}]}%n\", &VAR_6) >= 0 && VAR_6 > 0)) ||",
"(VAR_6 = 0, sscanf(VAR_2, \"{%*1[CcFfoPSsYy]:%*[^}]}%n\", &VAR_6) >= 0 && VAR_6 > 0)) {",
"VAR_2 += VAR_6 - 1;",
"} else",
"av_bprint_chars(VAR_1, *VAR_2, 1);",
"break;",
"case '<':\nVAR_7 = VAR_2[1] == '/';",
"VAR_6 = 0;",
"if (sscanf(VAR_2+VAR_7+1, \"%127[^>]>%n\", VAR_4, &VAR_6) >= 1 && VAR_6 > 0) {",
"const char *VAR_12 = VAR_4;",
"while (*VAR_12 == ' ')\nVAR_12++;",
"if ((VAR_3 = strchr(VAR_12, ' ')))\n*VAR_3++ = 0;",
"if ((!VAR_7 && VAR_8 < FF_ARRAY_ELEMS(stack)) ||\n( VAR_7 && VAR_8 > 0 && !strcmp(stack[VAR_8-1].tag, VAR_12))) {",
"int VAR_13, VAR_14, VAR_15 = 0;",
"VAR_2 += VAR_6 + VAR_7;",
"if (!VAR_7)\nmemset(stack+VAR_8, 0, sizeof(*stack));",
"if (!strcmp(VAR_12, \"font\")) {",
"if (VAR_7) {",
"for (VAR_13=PARAM_NUMBER-1; VAR_13>=0; VAR_13--)",
"if (stack[VAR_8-1].VAR_3[VAR_13][0])\nfor (VAR_14=VAR_8-2; VAR_14>=0; VAR_14--)",
"if (stack[VAR_14].VAR_3[VAR_13][0]) {",
"av_bprintf(VAR_1, \"%s\", stack[VAR_14].VAR_3[VAR_13]);",
"break;",
"}",
"} else {",
"while (VAR_3) {",
"if (!strncmp(VAR_3, \"size=\", 5)) {",
"unsigned VAR_16;",
"VAR_3 += 5 + (VAR_3[5] == '\"');",
"if (sscanf(VAR_3, \"%u\", &VAR_16) == 1) {",
"snprintf(stack[VAR_8].VAR_3[PARAM_SIZE],\nsizeof(stack[0].VAR_3[PARAM_SIZE]),\n\"{\\\\fs%u}\", VAR_16);",
"}",
"} else if (!strncmp(VAR_3, \"color=\", 6)) {",
"VAR_3 += 6 + (VAR_3[6] == '\"');",
"snprintf(stack[VAR_8].VAR_3[PARAM_COLOR],\nsizeof(stack[0].VAR_3[PARAM_COLOR]),\n\"{\\\\c&H%X&}\",",
"html_color_parse(VAR_0, VAR_3));",
"} else if (!strncmp(VAR_3, \"face=\", 5)) {",
"VAR_3 += 5 + (VAR_3[5] == '\"');",
"VAR_6 = strcspn(VAR_3,\nVAR_3[-1] == '\"' ? \"\\\"\" :\" \");",
"av_strlcpy(VAR_5, VAR_3,\nFFMIN(sizeof(VAR_5), VAR_6+1));",
"VAR_3 += VAR_6;",
"snprintf(stack[VAR_8].VAR_3[PARAM_FACE],\nsizeof(stack[0].VAR_3[PARAM_FACE]),\n\"{\\\\fn%s}\", VAR_5);",
"}",
"if ((VAR_3 = strchr(VAR_3, ' ')))\nVAR_3++;",
"}",
"for (VAR_13=0; VAR_13<PARAM_NUMBER; VAR_13++)",
"if (stack[VAR_8].VAR_3[VAR_13][0])\nav_bprintf(VAR_1, \"%s\", stack[VAR_8].VAR_3[VAR_13]);",
"}",
"} else if (VAR_12[0] && !VAR_12[1] && strspn(VAR_12, \"bisu\") == 1) {",
"av_bprintf(VAR_1, \"{\\\\%c%d}\", VAR_12[0], !VAR_7);",
"} else {",
"VAR_15 = 1;",
"snprintf(VAR_5, sizeof(VAR_5), \"</%s>\", VAR_12);",
"}",
"if (VAR_7) {",
"VAR_8--;",
"} else if (VAR_15 && !strstr(VAR_2, VAR_5)) {",
"VAR_2 -= VAR_6 + VAR_7;",
"av_bprint_chars(VAR_1, *VAR_2, 1);",
"} else",
"av_strlcpy(stack[VAR_8++].tag, VAR_12,\nsizeof(stack[0].tag));",
"break;",
"}",
"}",
"default:\nav_bprint_chars(VAR_1, *VAR_2, 1);",
"break;",
"}",
"if (*VAR_2 != ' ' && *VAR_2 != '\\r' && *VAR_2 != '\\n')\nVAR_9 = 0;",
"}",
"while (VAR_1->VAR_6 >= 2 && !strncmp(&VAR_1->str[VAR_1->VAR_6 - 2], \"\\\\N\", 2))\nVAR_1->VAR_6 -= 2;",
"VAR_1->str[VAR_1->VAR_6] = 0;",
"rstrip_spaces_buf(VAR_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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
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
],
[
243,
245
],
[
247
],
[
249
],
[
251
]
] |
2,457 | static void qpa_fini_in (HWVoiceIn *hw)
{
void *ret;
PAVoiceIn *pa = (PAVoiceIn *) hw;
audio_pt_lock (&pa->pt, AUDIO_FUNC);
pa->done = 1;
audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);
audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
if (pa->s) {
pa_simple_free (pa->s);
pa->s = NULL;
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
| true | qemu | ea9ebc2ce69198f7aca4b43652824c5d621ac978 | static void qpa_fini_in (HWVoiceIn *hw)
{
void *ret;
PAVoiceIn *pa = (PAVoiceIn *) hw;
audio_pt_lock (&pa->pt, AUDIO_FUNC);
pa->done = 1;
audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);
audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
if (pa->s) {
pa_simple_free (pa->s);
pa->s = NULL;
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
| {
"code": [
" if (pa->s) {",
" pa_simple_free (pa->s);",
" pa->s = NULL;",
" if (pa->s) {",
" pa_simple_free (pa->s);",
" pa->s = NULL;"
],
"line_no": [
21,
23,
25,
21,
23,
25
]
} | static void FUNC_0 (HWVoiceIn *VAR_0)
{
void *VAR_1;
PAVoiceIn *pa = (PAVoiceIn *) VAR_0;
audio_pt_lock (&pa->pt, AUDIO_FUNC);
pa->done = 1;
audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);
audio_pt_join (&pa->pt, &VAR_1, AUDIO_FUNC);
if (pa->s) {
pa_simple_free (pa->s);
pa->s = NULL;
}
audio_pt_fini (&pa->pt, AUDIO_FUNC);
g_free (pa->pcm_buf);
pa->pcm_buf = NULL;
}
| [
"static void FUNC_0 (HWVoiceIn *VAR_0)\n{",
"void *VAR_1;",
"PAVoiceIn *pa = (PAVoiceIn *) VAR_0;",
"audio_pt_lock (&pa->pt, AUDIO_FUNC);",
"pa->done = 1;",
"audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);",
"audio_pt_join (&pa->pt, &VAR_1, AUDIO_FUNC);",
"if (pa->s) {",
"pa_simple_free (pa->s);",
"pa->s = NULL;",
"}",
"audio_pt_fini (&pa->pt, AUDIO_FUNC);",
"g_free (pa->pcm_buf);",
"pa->pcm_buf = NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
2,458 | static void onenand_reset(OneNANDState *s, int cold)
{
memset(&s->addr, 0, sizeof(s->addr));
s->command = 0;
s->count = 1;
s->bufaddr = 0;
s->config[0] = 0x40c0;
s->config[1] = 0x0000;
onenand_intr_update(s);
qemu_irq_raise(s->rdy);
s->status = 0x0000;
s->intstatus = cold ? 0x8080 : 0x8010;
s->unladdr[0] = 0;
s->unladdr[1] = 0;
s->wpstatus = 0x0002;
s->cycle = 0;
s->otpmode = 0;
s->blk_cur = s->blk;
s->current = s->image;
s->secs_cur = s->secs;
if (cold) {
/* Lock the whole flash */
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
if (s->blk_cur && blk_read(s->blk_cur, 0, s->boot[0], 8) < 0) {
hw_error("%s: Loading the BootRAM failed.\n", __func__);
}
}
}
| true | qemu | 441692ddd8321d5e0f09b163e86410e578d87236 | static void onenand_reset(OneNANDState *s, int cold)
{
memset(&s->addr, 0, sizeof(s->addr));
s->command = 0;
s->count = 1;
s->bufaddr = 0;
s->config[0] = 0x40c0;
s->config[1] = 0x0000;
onenand_intr_update(s);
qemu_irq_raise(s->rdy);
s->status = 0x0000;
s->intstatus = cold ? 0x8080 : 0x8010;
s->unladdr[0] = 0;
s->unladdr[1] = 0;
s->wpstatus = 0x0002;
s->cycle = 0;
s->otpmode = 0;
s->blk_cur = s->blk;
s->current = s->image;
s->secs_cur = s->secs;
if (cold) {
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
if (s->blk_cur && blk_read(s->blk_cur, 0, s->boot[0], 8) < 0) {
hw_error("%s: Loading the BootRAM failed.\n", __func__);
}
}
}
| {
"code": [
" if (s->blk_cur && blk_read(s->blk_cur, 0, s->boot[0], 8) < 0) {"
],
"line_no": [
51
]
} | static void FUNC_0(OneNANDState *VAR_0, int VAR_1)
{
memset(&VAR_0->addr, 0, sizeof(VAR_0->addr));
VAR_0->command = 0;
VAR_0->count = 1;
VAR_0->bufaddr = 0;
VAR_0->config[0] = 0x40c0;
VAR_0->config[1] = 0x0000;
onenand_intr_update(VAR_0);
qemu_irq_raise(VAR_0->rdy);
VAR_0->status = 0x0000;
VAR_0->intstatus = VAR_1 ? 0x8080 : 0x8010;
VAR_0->unladdr[0] = 0;
VAR_0->unladdr[1] = 0;
VAR_0->wpstatus = 0x0002;
VAR_0->cycle = 0;
VAR_0->otpmode = 0;
VAR_0->blk_cur = VAR_0->blk;
VAR_0->current = VAR_0->image;
VAR_0->secs_cur = VAR_0->secs;
if (VAR_1) {
memset(VAR_0->blockwp, ONEN_LOCK_LOCKED, VAR_0->blocks);
if (VAR_0->blk_cur && blk_read(VAR_0->blk_cur, 0, VAR_0->boot[0], 8) < 0) {
hw_error("%VAR_0: Loading the BootRAM failed.\n", __func__);
}
}
}
| [
"static void FUNC_0(OneNANDState *VAR_0, int VAR_1)\n{",
"memset(&VAR_0->addr, 0, sizeof(VAR_0->addr));",
"VAR_0->command = 0;",
"VAR_0->count = 1;",
"VAR_0->bufaddr = 0;",
"VAR_0->config[0] = 0x40c0;",
"VAR_0->config[1] = 0x0000;",
"onenand_intr_update(VAR_0);",
"qemu_irq_raise(VAR_0->rdy);",
"VAR_0->status = 0x0000;",
"VAR_0->intstatus = VAR_1 ? 0x8080 : 0x8010;",
"VAR_0->unladdr[0] = 0;",
"VAR_0->unladdr[1] = 0;",
"VAR_0->wpstatus = 0x0002;",
"VAR_0->cycle = 0;",
"VAR_0->otpmode = 0;",
"VAR_0->blk_cur = VAR_0->blk;",
"VAR_0->current = VAR_0->image;",
"VAR_0->secs_cur = VAR_0->secs;",
"if (VAR_1) {",
"memset(VAR_0->blockwp, ONEN_LOCK_LOCKED, VAR_0->blocks);",
"if (VAR_0->blk_cur && blk_read(VAR_0->blk_cur, 0, VAR_0->boot[0], 8) < 0) {",
"hw_error(\"%VAR_0: Loading the BootRAM failed.\\n\", __func__);",
"}",
"}",
"}"
] | [
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
] |
2,459 | static void flush_packet(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts, int64_t scr)
{
MpegMuxContext *s = ctx->priv_data;
StreamInfo *stream = ctx->streams[stream_index]->priv_data;
uint8_t *buf_ptr;
int size, payload_size, startcode, id, len, stuffing_size, i, header_len;
uint8_t buffer[128];
id = stream->id;
#if 0
printf("packet ID=%2x PTS=%0.3f\n",
id, pts / 90000.0);
#endif
buf_ptr = buffer;
if (((s->packet_number % s->pack_header_freq) == 0)) {
/* output pack and systems header if needed */
size = put_pack_header(ctx, buf_ptr, scr);
buf_ptr += size;
if ((s->packet_number % s->system_header_freq) == 0) {
size = put_system_header(ctx, buf_ptr);
buf_ptr += size;
}
}
size = buf_ptr - buffer;
put_buffer(&ctx->pb, buffer, size);
/* packet header */
if (s->is_mpeg2) {
header_len = 3;
} else {
header_len = 0;
}
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE)
header_len += 5 + 5;
else
header_len += 5;
} else {
if (!s->is_mpeg2)
header_len++;
}
payload_size = s->packet_size - (size + 6 + header_len);
if (id < 0xc0) {
startcode = PRIVATE_STREAM_1;
payload_size -= 4;
} else {
startcode = 0x100 + id;
}
stuffing_size = payload_size - stream->buffer_ptr;
if (stuffing_size < 0)
stuffing_size = 0;
put_be32(&ctx->pb, startcode);
put_be16(&ctx->pb, payload_size + header_len);
/* stuffing */
for(i=0;i<stuffing_size;i++)
put_byte(&ctx->pb, 0xff);
if (s->is_mpeg2) {
put_byte(&ctx->pb, 0x80); /* mpeg2 id */
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_byte(&ctx->pb, 0xc0); /* flags */
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_byte(&ctx->pb, 0x80); /* flags */
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x00); /* flags */
put_byte(&ctx->pb, header_len - 3);
}
} else {
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x0f);
}
}
if (startcode == PRIVATE_STREAM_1) {
put_byte(&ctx->pb, id);
if (id >= 0x80 && id <= 0xbf) {
/* XXX: need to check AC3 spec */
put_byte(&ctx->pb, 1);
put_byte(&ctx->pb, 0);
put_byte(&ctx->pb, 2);
}
}
/* output data */
put_buffer(&ctx->pb, stream->buffer, payload_size - stuffing_size);
put_flush_packet(&ctx->pb);
/* preserve remaining data */
len = stream->buffer_ptr - payload_size;
if (len < 0)
len = 0;
memmove(stream->buffer, stream->buffer + stream->buffer_ptr - len, len);
stream->buffer_ptr = len;
s->packet_number++;
stream->packet_number++;
}
| true | FFmpeg | 0dbb48d91e9e97c7eb11f4ebc03c4ff4b6f5b692 | static void flush_packet(AVFormatContext *ctx, int stream_index,
int64_t pts, int64_t dts, int64_t scr)
{
MpegMuxContext *s = ctx->priv_data;
StreamInfo *stream = ctx->streams[stream_index]->priv_data;
uint8_t *buf_ptr;
int size, payload_size, startcode, id, len, stuffing_size, i, header_len;
uint8_t buffer[128];
id = stream->id;
#if 0
printf("packet ID=%2x PTS=%0.3f\n",
id, pts / 90000.0);
#endif
buf_ptr = buffer;
if (((s->packet_number % s->pack_header_freq) == 0)) {
size = put_pack_header(ctx, buf_ptr, scr);
buf_ptr += size;
if ((s->packet_number % s->system_header_freq) == 0) {
size = put_system_header(ctx, buf_ptr);
buf_ptr += size;
}
}
size = buf_ptr - buffer;
put_buffer(&ctx->pb, buffer, size);
if (s->is_mpeg2) {
header_len = 3;
} else {
header_len = 0;
}
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE)
header_len += 5 + 5;
else
header_len += 5;
} else {
if (!s->is_mpeg2)
header_len++;
}
payload_size = s->packet_size - (size + 6 + header_len);
if (id < 0xc0) {
startcode = PRIVATE_STREAM_1;
payload_size -= 4;
} else {
startcode = 0x100 + id;
}
stuffing_size = payload_size - stream->buffer_ptr;
if (stuffing_size < 0)
stuffing_size = 0;
put_be32(&ctx->pb, startcode);
put_be16(&ctx->pb, payload_size + header_len);
for(i=0;i<stuffing_size;i++)
put_byte(&ctx->pb, 0xff);
if (s->is_mpeg2) {
put_byte(&ctx->pb, 0x80);
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_byte(&ctx->pb, 0xc0);
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_byte(&ctx->pb, 0x80);
put_byte(&ctx->pb, header_len - 3);
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x00);
put_byte(&ctx->pb, header_len - 3);
}
} else {
if (pts != AV_NOPTS_VALUE) {
if (dts != AV_NOPTS_VALUE) {
put_timestamp(&ctx->pb, 0x03, pts);
put_timestamp(&ctx->pb, 0x01, dts);
} else {
put_timestamp(&ctx->pb, 0x02, pts);
}
} else {
put_byte(&ctx->pb, 0x0f);
}
}
if (startcode == PRIVATE_STREAM_1) {
put_byte(&ctx->pb, id);
if (id >= 0x80 && id <= 0xbf) {
put_byte(&ctx->pb, 1);
put_byte(&ctx->pb, 0);
put_byte(&ctx->pb, 2);
}
}
put_buffer(&ctx->pb, stream->buffer, payload_size - stuffing_size);
put_flush_packet(&ctx->pb);
len = stream->buffer_ptr - payload_size;
if (len < 0)
len = 0;
memmove(stream->buffer, stream->buffer + stream->buffer_ptr - len, len);
stream->buffer_ptr = len;
s->packet_number++;
stream->packet_number++;
}
| {
"code": [
" int size, payload_size, startcode, id, len, stuffing_size, i, header_len;",
" payload_size = s->packet_size - (size + 6 + header_len);",
" put_be16(&ctx->pb, payload_size + header_len);",
" put_byte(&ctx->pb, 1);",
" put_byte(&ctx->pb, 0);",
" put_byte(&ctx->pb, 2);",
" len = stream->buffer_ptr - payload_size;",
" if (len < 0) ",
" len = 0;",
" memmove(stream->buffer, stream->buffer + stream->buffer_ptr - len, len);",
" stream->buffer_ptr = len;"
],
"line_no": [
13,
91,
117,
197,
199,
201,
219,
221,
223,
225,
227
]
} | static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int64_t VAR_3, int64_t VAR_4)
{
MpegMuxContext *s = VAR_0->priv_data;
StreamInfo *stream = VAR_0->streams[VAR_1]->priv_data;
uint8_t *buf_ptr;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
uint8_t buffer[128];
VAR_8 = stream->VAR_8;
#if 0
printf("packet ID=%2x PTS=%0.3f\n",
VAR_8, VAR_2 / 90000.0);
#endif
buf_ptr = buffer;
if (((s->packet_number % s->pack_header_freq) == 0)) {
VAR_5 = put_pack_header(VAR_0, buf_ptr, VAR_4);
buf_ptr += VAR_5;
if ((s->packet_number % s->system_header_freq) == 0) {
VAR_5 = put_system_header(VAR_0, buf_ptr);
buf_ptr += VAR_5;
}
}
VAR_5 = buf_ptr - buffer;
put_buffer(&VAR_0->pb, buffer, VAR_5);
if (s->is_mpeg2) {
VAR_12 = 3;
} else {
VAR_12 = 0;
}
if (VAR_2 != AV_NOPTS_VALUE) {
if (VAR_3 != AV_NOPTS_VALUE)
VAR_12 += 5 + 5;
else
VAR_12 += 5;
} else {
if (!s->is_mpeg2)
VAR_12++;
}
VAR_6 = s->packet_size - (VAR_5 + 6 + VAR_12);
if (VAR_8 < 0xc0) {
VAR_7 = PRIVATE_STREAM_1;
VAR_6 -= 4;
} else {
VAR_7 = 0x100 + VAR_8;
}
VAR_10 = VAR_6 - stream->buffer_ptr;
if (VAR_10 < 0)
VAR_10 = 0;
put_be32(&VAR_0->pb, VAR_7);
put_be16(&VAR_0->pb, VAR_6 + VAR_12);
for(VAR_11=0;VAR_11<VAR_10;VAR_11++)
put_byte(&VAR_0->pb, 0xff);
if (s->is_mpeg2) {
put_byte(&VAR_0->pb, 0x80);
if (VAR_2 != AV_NOPTS_VALUE) {
if (VAR_3 != AV_NOPTS_VALUE) {
put_byte(&VAR_0->pb, 0xc0);
put_byte(&VAR_0->pb, VAR_12 - 3);
put_timestamp(&VAR_0->pb, 0x03, VAR_2);
put_timestamp(&VAR_0->pb, 0x01, VAR_3);
} else {
put_byte(&VAR_0->pb, 0x80);
put_byte(&VAR_0->pb, VAR_12 - 3);
put_timestamp(&VAR_0->pb, 0x02, VAR_2);
}
} else {
put_byte(&VAR_0->pb, 0x00);
put_byte(&VAR_0->pb, VAR_12 - 3);
}
} else {
if (VAR_2 != AV_NOPTS_VALUE) {
if (VAR_3 != AV_NOPTS_VALUE) {
put_timestamp(&VAR_0->pb, 0x03, VAR_2);
put_timestamp(&VAR_0->pb, 0x01, VAR_3);
} else {
put_timestamp(&VAR_0->pb, 0x02, VAR_2);
}
} else {
put_byte(&VAR_0->pb, 0x0f);
}
}
if (VAR_7 == PRIVATE_STREAM_1) {
put_byte(&VAR_0->pb, VAR_8);
if (VAR_8 >= 0x80 && VAR_8 <= 0xbf) {
put_byte(&VAR_0->pb, 1);
put_byte(&VAR_0->pb, 0);
put_byte(&VAR_0->pb, 2);
}
}
put_buffer(&VAR_0->pb, stream->buffer, VAR_6 - VAR_10);
put_flush_packet(&VAR_0->pb);
VAR_9 = stream->buffer_ptr - VAR_6;
if (VAR_9 < 0)
VAR_9 = 0;
memmove(stream->buffer, stream->buffer + stream->buffer_ptr - VAR_9, VAR_9);
stream->buffer_ptr = VAR_9;
s->packet_number++;
stream->packet_number++;
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int64_t VAR_3, int64_t VAR_4)\n{",
"MpegMuxContext *s = VAR_0->priv_data;",
"StreamInfo *stream = VAR_0->streams[VAR_1]->priv_data;",
"uint8_t *buf_ptr;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"uint8_t buffer[128];",
"VAR_8 = stream->VAR_8;",
"#if 0\nprintf(\"packet ID=%2x PTS=%0.3f\\n\",\nVAR_8, VAR_2 / 90000.0);",
"#endif\nbuf_ptr = buffer;",
"if (((s->packet_number % s->pack_header_freq) == 0)) {",
"VAR_5 = put_pack_header(VAR_0, buf_ptr, VAR_4);",
"buf_ptr += VAR_5;",
"if ((s->packet_number % s->system_header_freq) == 0) {",
"VAR_5 = put_system_header(VAR_0, buf_ptr);",
"buf_ptr += VAR_5;",
"}",
"}",
"VAR_5 = buf_ptr - buffer;",
"put_buffer(&VAR_0->pb, buffer, VAR_5);",
"if (s->is_mpeg2) {",
"VAR_12 = 3;",
"} else {",
"VAR_12 = 0;",
"}",
"if (VAR_2 != AV_NOPTS_VALUE) {",
"if (VAR_3 != AV_NOPTS_VALUE)\nVAR_12 += 5 + 5;",
"else\nVAR_12 += 5;",
"} else {",
"if (!s->is_mpeg2)\nVAR_12++;",
"}",
"VAR_6 = s->packet_size - (VAR_5 + 6 + VAR_12);",
"if (VAR_8 < 0xc0) {",
"VAR_7 = PRIVATE_STREAM_1;",
"VAR_6 -= 4;",
"} else {",
"VAR_7 = 0x100 + VAR_8;",
"}",
"VAR_10 = VAR_6 - stream->buffer_ptr;",
"if (VAR_10 < 0)\nVAR_10 = 0;",
"put_be32(&VAR_0->pb, VAR_7);",
"put_be16(&VAR_0->pb, VAR_6 + VAR_12);",
"for(VAR_11=0;VAR_11<VAR_10;VAR_11++)",
"put_byte(&VAR_0->pb, 0xff);",
"if (s->is_mpeg2) {",
"put_byte(&VAR_0->pb, 0x80);",
"if (VAR_2 != AV_NOPTS_VALUE) {",
"if (VAR_3 != AV_NOPTS_VALUE) {",
"put_byte(&VAR_0->pb, 0xc0);",
"put_byte(&VAR_0->pb, VAR_12 - 3);",
"put_timestamp(&VAR_0->pb, 0x03, VAR_2);",
"put_timestamp(&VAR_0->pb, 0x01, VAR_3);",
"} else {",
"put_byte(&VAR_0->pb, 0x80);",
"put_byte(&VAR_0->pb, VAR_12 - 3);",
"put_timestamp(&VAR_0->pb, 0x02, VAR_2);",
"}",
"} else {",
"put_byte(&VAR_0->pb, 0x00);",
"put_byte(&VAR_0->pb, VAR_12 - 3);",
"}",
"} else {",
"if (VAR_2 != AV_NOPTS_VALUE) {",
"if (VAR_3 != AV_NOPTS_VALUE) {",
"put_timestamp(&VAR_0->pb, 0x03, VAR_2);",
"put_timestamp(&VAR_0->pb, 0x01, VAR_3);",
"} else {",
"put_timestamp(&VAR_0->pb, 0x02, VAR_2);",
"}",
"} else {",
"put_byte(&VAR_0->pb, 0x0f);",
"}",
"}",
"if (VAR_7 == PRIVATE_STREAM_1) {",
"put_byte(&VAR_0->pb, VAR_8);",
"if (VAR_8 >= 0x80 && VAR_8 <= 0xbf) {",
"put_byte(&VAR_0->pb, 1);",
"put_byte(&VAR_0->pb, 0);",
"put_byte(&VAR_0->pb, 2);",
"}",
"}",
"put_buffer(&VAR_0->pb, stream->buffer, VAR_6 - VAR_10);",
"put_flush_packet(&VAR_0->pb);",
"VAR_9 = stream->buffer_ptr - VAR_6;",
"if (VAR_9 < 0)\nVAR_9 = 0;",
"memmove(stream->buffer, stream->buffer + stream->buffer_ptr - VAR_9, VAR_9);",
"stream->buffer_ptr = VAR_9;",
"s->packet_number++;",
"stream->packet_number++;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25,
27
],
[
29,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
113
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
211
],
[
213
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
],
[
233
],
[
235
]
] |
2,460 | static QPCIDevice *get_pci_device(void **bmdma_base, void **ide_base)
{
QPCIDevice *dev;
uint16_t vendor_id, device_id;
if (!pcibus) {
pcibus = qpci_init_pc(NULL);
}
/* Find PCI device and verify it's the right one */
dev = qpci_device_find(pcibus, QPCI_DEVFN(IDE_PCI_DEV, IDE_PCI_FUNC));
g_assert(dev != NULL);
vendor_id = qpci_config_readw(dev, PCI_VENDOR_ID);
device_id = qpci_config_readw(dev, PCI_DEVICE_ID);
g_assert(vendor_id == PCI_VENDOR_ID_INTEL);
g_assert(device_id == PCI_DEVICE_ID_INTEL_82371SB_1);
/* Map bmdma BAR */
*bmdma_base = qpci_iomap(dev, 4, NULL);
*ide_base = qpci_legacy_iomap(dev, IDE_BASE);
qpci_device_enable(dev);
return dev;
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static QPCIDevice *get_pci_device(void **bmdma_base, void **ide_base)
{
QPCIDevice *dev;
uint16_t vendor_id, device_id;
if (!pcibus) {
pcibus = qpci_init_pc(NULL);
}
dev = qpci_device_find(pcibus, QPCI_DEVFN(IDE_PCI_DEV, IDE_PCI_FUNC));
g_assert(dev != NULL);
vendor_id = qpci_config_readw(dev, PCI_VENDOR_ID);
device_id = qpci_config_readw(dev, PCI_DEVICE_ID);
g_assert(vendor_id == PCI_VENDOR_ID_INTEL);
g_assert(device_id == PCI_DEVICE_ID_INTEL_82371SB_1);
*bmdma_base = qpci_iomap(dev, 4, NULL);
*ide_base = qpci_legacy_iomap(dev, IDE_BASE);
qpci_device_enable(dev);
return dev;
}
| {
"code": [
"static QPCIDevice *get_pci_device(void **bmdma_base, void **ide_base)",
" *bmdma_base = qpci_iomap(dev, 4, NULL);",
" *ide_base = qpci_legacy_iomap(dev, IDE_BASE);"
],
"line_no": [
1,
39,
43
]
} | static QPCIDevice *FUNC_0(void **bmdma_base, void **ide_base)
{
QPCIDevice *dev;
uint16_t vendor_id, device_id;
if (!pcibus) {
pcibus = qpci_init_pc(NULL);
}
dev = qpci_device_find(pcibus, QPCI_DEVFN(IDE_PCI_DEV, IDE_PCI_FUNC));
g_assert(dev != NULL);
vendor_id = qpci_config_readw(dev, PCI_VENDOR_ID);
device_id = qpci_config_readw(dev, PCI_DEVICE_ID);
g_assert(vendor_id == PCI_VENDOR_ID_INTEL);
g_assert(device_id == PCI_DEVICE_ID_INTEL_82371SB_1);
*bmdma_base = qpci_iomap(dev, 4, NULL);
*ide_base = qpci_legacy_iomap(dev, IDE_BASE);
qpci_device_enable(dev);
return dev;
}
| [
"static QPCIDevice *FUNC_0(void **bmdma_base, void **ide_base)\n{",
"QPCIDevice *dev;",
"uint16_t vendor_id, device_id;",
"if (!pcibus) {",
"pcibus = qpci_init_pc(NULL);",
"}",
"dev = qpci_device_find(pcibus, QPCI_DEVFN(IDE_PCI_DEV, IDE_PCI_FUNC));",
"g_assert(dev != NULL);",
"vendor_id = qpci_config_readw(dev, PCI_VENDOR_ID);",
"device_id = qpci_config_readw(dev, PCI_DEVICE_ID);",
"g_assert(vendor_id == PCI_VENDOR_ID_INTEL);",
"g_assert(device_id == PCI_DEVICE_ID_INTEL_82371SB_1);",
"*bmdma_base = qpci_iomap(dev, 4, NULL);",
"*ide_base = qpci_legacy_iomap(dev, IDE_BASE);",
"qpci_device_enable(dev);",
"return dev;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
43
],
[
47
],
[
51
],
[
53
]
] |
2,461 | static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
int16_t *dstV,
const uint8_t *src,
int width,
enum AVPixelFormat origin,
int shr, int shg,
int shb, int shp,
int maskr, int maskg,
int maskb, int rsh,
int gsh, int bsh, int S,
int32_t *rgb2yuv)
{
const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
maskgx = ~(maskr | maskb);
const unsigned rnd = (256U<<(S)) + (1<<(S-6));
int i;
maskr |= maskr << 1;
maskb |= maskb << 1;
maskg |= maskg << 1;
for (i = 0; i < width; i++) {
int px0 = input_pixel(2 * i + 0) >> shp;
int px1 = input_pixel(2 * i + 1) >> shp;
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
int rb = px0 + px1 - g;
b = (rb & maskb) >> shb;
if (shp ||
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
g >>= shg;
} else {
g = (g & maskg) >> shg;
}
r = (rb & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
}
}
| true | FFmpeg | 293d5d7a8e12e38bf70b51f6aa70321e079ffa64 | static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
int16_t *dstV,
const uint8_t *src,
int width,
enum AVPixelFormat origin,
int shr, int shg,
int shb, int shp,
int maskr, int maskg,
int maskb, int rsh,
int gsh, int bsh, int S,
int32_t *rgb2yuv)
{
const int ru = rgb2yuv[RU_IDX] << rsh, gu = rgb2yuv[GU_IDX] << gsh, bu = rgb2yuv[BU_IDX] << bsh,
rv = rgb2yuv[RV_IDX] << rsh, gv = rgb2yuv[GV_IDX] << gsh, bv = rgb2yuv[BV_IDX] << bsh,
maskgx = ~(maskr | maskb);
const unsigned rnd = (256U<<(S)) + (1<<(S-6));
int i;
maskr |= maskr << 1;
maskb |= maskb << 1;
maskg |= maskg << 1;
for (i = 0; i < width; i++) {
int px0 = input_pixel(2 * i + 0) >> shp;
int px1 = input_pixel(2 * i + 1) >> shp;
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
int rb = px0 + px1 - g;
b = (rb & maskb) >> shb;
if (shp ||
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
g >>= shg;
} else {
g = (g & maskg) >> shg;
}
r = (rb & maskr) >> shr;
dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
}
}
| {
"code": [
" int px0 = input_pixel(2 * i + 0) >> shp;",
" int px1 = input_pixel(2 * i + 1) >> shp;"
],
"line_no": [
45,
47
]
} | static av_always_inline void FUNC_0(int16_t *dstU,
int16_t *dstV,
const uint8_t *src,
int width,
enum AVPixelFormat origin,
int shr, int shg,
int shb, int shp,
int maskr, int maskg,
int maskb, int rsh,
int gsh, int bsh, int S,
int32_t *rgb2yuv)
{
const int VAR_0 = rgb2yuv[RU_IDX] << rsh, VAR_1 = rgb2yuv[GU_IDX] << gsh, VAR_2 = rgb2yuv[BU_IDX] << bsh,
VAR_3 = rgb2yuv[RV_IDX] << rsh, VAR_4 = rgb2yuv[GV_IDX] << gsh, VAR_5 = rgb2yuv[BV_IDX] << bsh,
VAR_6 = ~(maskr | maskb);
const unsigned VAR_7 = (256U<<(S)) + (1<<(S-6));
int VAR_8;
maskr |= maskr << 1;
maskb |= maskb << 1;
maskg |= maskg << 1;
for (VAR_8 = 0; VAR_8 < width; VAR_8++) {
int VAR_9 = input_pixel(2 * VAR_8 + 0) >> shp;
int VAR_10 = input_pixel(2 * VAR_8 + 1) >> shp;
int VAR_11, VAR_12, VAR_13 = (VAR_9 & VAR_6) + (VAR_10 & VAR_6);
int VAR_14 = VAR_9 + VAR_10 - VAR_13;
VAR_11 = (VAR_14 & maskb) >> shb;
if (shp ||
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
VAR_13 >>= shg;
} else {
VAR_13 = (VAR_13 & maskg) >> shg;
}
VAR_12 = (VAR_14 & maskr) >> shr;
dstU[VAR_8] = (VAR_0 * VAR_12 + VAR_1 * VAR_13 + VAR_2 * VAR_11 + (unsigned)VAR_7) >> ((S)-6+1);
dstV[VAR_8] = (VAR_3 * VAR_12 + VAR_4 * VAR_13 + VAR_5 * VAR_11 + (unsigned)VAR_7) >> ((S)-6+1);
}
}
| [
"static av_always_inline void FUNC_0(int16_t *dstU,\nint16_t *dstV,\nconst uint8_t *src,\nint width,\nenum AVPixelFormat origin,\nint shr, int shg,\nint shb, int shp,\nint maskr, int maskg,\nint maskb, int rsh,\nint gsh, int bsh, int S,\nint32_t *rgb2yuv)\n{",
"const int VAR_0 = rgb2yuv[RU_IDX] << rsh, VAR_1 = rgb2yuv[GU_IDX] << gsh, VAR_2 = rgb2yuv[BU_IDX] << bsh,\nVAR_3 = rgb2yuv[RV_IDX] << rsh, VAR_4 = rgb2yuv[GV_IDX] << gsh, VAR_5 = rgb2yuv[BV_IDX] << bsh,\nVAR_6 = ~(maskr | maskb);",
"const unsigned VAR_7 = (256U<<(S)) + (1<<(S-6));",
"int VAR_8;",
"maskr |= maskr << 1;",
"maskb |= maskb << 1;",
"maskg |= maskg << 1;",
"for (VAR_8 = 0; VAR_8 < width; VAR_8++) {",
"int VAR_9 = input_pixel(2 * VAR_8 + 0) >> shp;",
"int VAR_10 = input_pixel(2 * VAR_8 + 1) >> shp;",
"int VAR_11, VAR_12, VAR_13 = (VAR_9 & VAR_6) + (VAR_10 & VAR_6);",
"int VAR_14 = VAR_9 + VAR_10 - VAR_13;",
"VAR_11 = (VAR_14 & maskb) >> shb;",
"if (shp ||\norigin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||\norigin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {",
"VAR_13 >>= shg;",
"} else {",
"VAR_13 = (VAR_13 & maskg) >> shg;",
"}",
"VAR_12 = (VAR_14 & maskr) >> shr;",
"dstU[VAR_8] = (VAR_0 * VAR_12 + VAR_1 * VAR_13 + VAR_2 * VAR_11 + (unsigned)VAR_7) >> ((S)-6+1);",
"dstV[VAR_8] = (VAR_3 * VAR_12 + VAR_4 * VAR_13 + VAR_5 * VAR_11 + (unsigned)VAR_7) >> ((S)-6+1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
]
] |
2,462 | static int read_header(AVFormatContext *s1)
{
VideoDemuxData *s = s1->priv_data;
int first_index, last_index, ret = 0;
int width = 0, height = 0;
AVStream *st;
enum PixelFormat pix_fmt = PIX_FMT_NONE;
AVRational framerate;
s1->ctx_flags |= AVFMTCTX_NOHEADER;
st = avformat_new_stream(s1, NULL);
if (!st) {
return AVERROR(ENOMEM);
}
if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
return AVERROR(EINVAL);
}
if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
return ret;
}
if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
return ret;
}
av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
/* find format */
if (s1->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else{
s->is_pipe = 1;
st->need_parsing = AVSTREAM_PARSE_FULL;
}
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (width && height) {
st->codec->width = width;
st->codec->height = height;
}
if (!s->is_pipe) {
s->use_glob = is_glob(s->path);
if (s->use_glob) {
#if HAVE_GLOB
char *p = s->path, *q, *dup;
int gerr;
dup = q = av_strdup(p);
while (*q) {
/* Do we have room for the next char and a \ insertion? */
if ((p - s->path) >= (sizeof(s->path) - 2))
break;
if (*q == '%' && strspn(q + 1, "%*?[]{}"))
++q;
else if (strspn(q, "\\*?[]{}"))
*p++ = '\\';
*p++ = *q++;
}
*p = 0;
av_free(dup);
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
first_index = 0;
last_index = s->globstate.gl_pathc - 1;
#endif
} else {
if (find_image_range(&first_index, &last_index, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR,
"Could find no file with with path '%s' and index in the range %d-%d\n",
s->path, s->start_number, s->start_number + s->start_number_range - 1);
return AVERROR(ENOENT);
}
}
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index;
/* compute duration */
st->start_time = 0;
st->duration = last_index - first_index + 1;
}
if(s1->video_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s1->video_codec_id;
}else if(s1->audio_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s1->audio_codec_id;
}else{
const char *str= strrchr(s->path, '.');
s->split_planes = str && !av_strcasecmp(str + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
st->codec->codec_id = AV_CODEC_ID_MJPEG;
}
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE)
st->codec->pix_fmt = pix_fmt;
return 0;
}
| false | FFmpeg | 3a06ea843656891fdb4d1072d9df2d5c3c9426f5 | static int read_header(AVFormatContext *s1)
{
VideoDemuxData *s = s1->priv_data;
int first_index, last_index, ret = 0;
int width = 0, height = 0;
AVStream *st;
enum PixelFormat pix_fmt = PIX_FMT_NONE;
AVRational framerate;
s1->ctx_flags |= AVFMTCTX_NOHEADER;
st = avformat_new_stream(s1, NULL);
if (!st) {
return AVERROR(ENOMEM);
}
if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
return AVERROR(EINVAL);
}
if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
return ret;
}
if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
return ret;
}
av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
if (s1->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else{
s->is_pipe = 1;
st->need_parsing = AVSTREAM_PARSE_FULL;
}
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (width && height) {
st->codec->width = width;
st->codec->height = height;
}
if (!s->is_pipe) {
s->use_glob = is_glob(s->path);
if (s->use_glob) {
#if HAVE_GLOB
char *p = s->path, *q, *dup;
int gerr;
dup = q = av_strdup(p);
while (*q) {
if ((p - s->path) >= (sizeof(s->path) - 2))
break;
if (*q == '%' && strspn(q + 1, "%*?[]{}"))
++q;
else if (strspn(q, "\\*?[]{}"))
*p++ = '\\';
*p++ = *q++;
}
*p = 0;
av_free(dup);
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
first_index = 0;
last_index = s->globstate.gl_pathc - 1;
#endif
} else {
if (find_image_range(&first_index, &last_index, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR,
"Could find no file with with path '%s' and index in the range %d-%d\n",
s->path, s->start_number, s->start_number + s->start_number_range - 1);
return AVERROR(ENOENT);
}
}
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index;
st->start_time = 0;
st->duration = last_index - first_index + 1;
}
if(s1->video_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s1->video_codec_id;
}else if(s1->audio_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s1->audio_codec_id;
}else{
const char *str= strrchr(s->path, '.');
s->split_planes = str && !av_strcasecmp(str + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
st->codec->codec_id = AV_CODEC_ID_MJPEG;
}
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != PIX_FMT_NONE)
st->codec->pix_fmt = pix_fmt;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
VideoDemuxData *s = VAR_0->priv_data;
int VAR_1, VAR_2, VAR_3 = 0;
int VAR_4 = 0, VAR_5 = 0;
AVStream *st;
enum PixelFormat VAR_6 = PIX_FMT_NONE;
AVRational framerate;
VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;
st = avformat_new_stream(VAR_0, NULL);
if (!st) {
return AVERROR(ENOMEM);
}
if (s->pixel_format && (VAR_6 = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {
av_log(VAR_0, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format);
return AVERROR(EINVAL);
}
if (s->video_size && (VAR_3 = av_parse_video_size(&VAR_4, &VAR_5, s->video_size)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse video size: %s.\n", s->video_size);
return VAR_3;
}
if ((VAR_3 = av_parse_video_rate(&framerate, s->framerate)) < 0) {
av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s->framerate);
return VAR_3;
}
av_strlcpy(s->path, VAR_0->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
if (VAR_0->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0;
else{
s->is_pipe = 1;
st->need_parsing = AVSTREAM_PARSE_FULL;
}
avpriv_set_pts_info(st, 60, framerate.den, framerate.num);
if (VAR_4 && VAR_5) {
st->codec->VAR_4 = VAR_4;
st->codec->VAR_5 = VAR_5;
}
if (!s->is_pipe) {
s->use_glob = is_glob(s->path);
if (s->use_glob) {
#if HAVE_GLOB
char *p = s->path, *q, *dup;
int gerr;
dup = q = av_strdup(p);
while (*q) {
if ((p - s->path) >= (sizeof(s->path) - 2))
break;
if (*q == '%' && strspn(q + 1, "%*?[]{}"))
++q;
else if (strspn(q, "\\*?[]{}"))
*p++ = '\\';
*p++ = *q++;
}
*p = 0;
av_free(dup);
gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
if (gerr != 0) {
return AVERROR(ENOENT);
}
VAR_1 = 0;
VAR_2 = s->globstate.gl_pathc - 1;
#endif
} else {
if (find_image_range(&VAR_1, &VAR_2, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Could find no file with with path '%s' and index in the range %d-%d\n",
s->path, s->start_number, s->start_number + s->start_number_range - 1);
return AVERROR(ENOENT);
}
}
s->img_first = VAR_1;
s->img_last = VAR_2;
s->img_number = VAR_1;
st->start_time = 0;
st->duration = VAR_2 - VAR_1 + 1;
}
if(VAR_0->video_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = VAR_0->video_codec_id;
}else if(VAR_0->audio_codec_id){
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = VAR_0->audio_codec_id;
}else{
const char *VAR_7= strrchr(s->path, '.');
s->split_planes = VAR_7 && !av_strcasecmp(VAR_7 + 1, "y");
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = ff_guess_image2_codec(s->path);
if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
st->codec->codec_id = AV_CODEC_ID_MJPEG;
}
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_6 != PIX_FMT_NONE)
st->codec->VAR_6 = VAR_6;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"VideoDemuxData *s = VAR_0->priv_data;",
"int VAR_1, VAR_2, VAR_3 = 0;",
"int VAR_4 = 0, VAR_5 = 0;",
"AVStream *st;",
"enum PixelFormat VAR_6 = PIX_FMT_NONE;",
"AVRational framerate;",
"VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st) {",
"return AVERROR(ENOMEM);",
"}",
"if (s->pixel_format && (VAR_6 = av_get_pix_fmt(s->pixel_format)) == PIX_FMT_NONE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No such pixel format: %s.\\n\", s->pixel_format);",
"return AVERROR(EINVAL);",
"}",
"if (s->video_size && (VAR_3 = av_parse_video_size(&VAR_4, &VAR_5, s->video_size)) < 0) {",
"av_log(s, AV_LOG_ERROR, \"Could not parse video size: %s.\\n\", s->video_size);",
"return VAR_3;",
"}",
"if ((VAR_3 = av_parse_video_rate(&framerate, s->framerate)) < 0) {",
"av_log(s, AV_LOG_ERROR, \"Could not parse framerate: %s.\\n\", s->framerate);",
"return VAR_3;",
"}",
"av_strlcpy(s->path, VAR_0->filename, sizeof(s->path));",
"s->img_number = 0;",
"s->img_count = 0;",
"if (VAR_0->iformat->flags & AVFMT_NOFILE)\ns->is_pipe = 0;",
"else{",
"s->is_pipe = 1;",
"st->need_parsing = AVSTREAM_PARSE_FULL;",
"}",
"avpriv_set_pts_info(st, 60, framerate.den, framerate.num);",
"if (VAR_4 && VAR_5) {",
"st->codec->VAR_4 = VAR_4;",
"st->codec->VAR_5 = VAR_5;",
"}",
"if (!s->is_pipe) {",
"s->use_glob = is_glob(s->path);",
"if (s->use_glob) {",
"#if HAVE_GLOB\nchar *p = s->path, *q, *dup;",
"int gerr;",
"dup = q = av_strdup(p);",
"while (*q) {",
"if ((p - s->path) >= (sizeof(s->path) - 2))\nbreak;",
"if (*q == '%' && strspn(q + 1, \"%*?[]{}\"))",
"++q;",
"else if (strspn(q, \"\\\\*?[]{}\"))",
"*p++ = '\\\\';",
"*p++ = *q++;",
"}",
"*p = 0;",
"av_free(dup);",
"gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);",
"if (gerr != 0) {",
"return AVERROR(ENOENT);",
"}",
"VAR_1 = 0;",
"VAR_2 = s->globstate.gl_pathc - 1;",
"#endif\n} else {",
"if (find_image_range(&VAR_1, &VAR_2, s->path,\ns->start_number, s->start_number_range) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Could find no file with with path '%s' and index in the range %d-%d\\n\",\ns->path, s->start_number, s->start_number + s->start_number_range - 1);",
"return AVERROR(ENOENT);",
"}",
"}",
"s->img_first = VAR_1;",
"s->img_last = VAR_2;",
"s->img_number = VAR_1;",
"st->start_time = 0;",
"st->duration = VAR_2 - VAR_1 + 1;",
"}",
"if(VAR_0->video_codec_id){",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = VAR_0->video_codec_id;",
"}else if(VAR_0->audio_codec_id){",
"st->codec->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codec->codec_id = VAR_0->audio_codec_id;",
"}else{",
"const char *VAR_7= strrchr(s->path, '.');",
"s->split_planes = VAR_7 && !av_strcasecmp(VAR_7 + 1, \"y\");",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = ff_guess_image2_codec(s->path);",
"if (st->codec->codec_id == AV_CODEC_ID_LJPEG)\nst->codec->codec_id = AV_CODEC_ID_MJPEG;",
"}",
"if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_6 != PIX_FMT_NONE)\nst->codec->VAR_6 = VAR_6;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155,
157
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215,
217
],
[
221
],
[
223
]
] |
2,463 | static int qdraw_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
if (!b[10] && AV_RB32(b+11) == 0x1102ff0c && !b[15] ||
p->buf_size >= 528 && !b[522] && AV_RB32(b+523) == 0x1102ff0c && !b[527])
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| false | FFmpeg | dee7943819042f310d7995671d3e39f4dd31d770 | static int qdraw_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
if (!b[10] && AV_RB32(b+11) == 0x1102ff0c && !b[15] ||
p->buf_size >= 528 && !b[522] && AV_RB32(b+523) == 0x1102ff0c && !b[527])
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
const uint8_t *VAR_1 = VAR_0->buf;
if (!VAR_1[10] && AV_RB32(VAR_1+11) == 0x1102ff0c && !VAR_1[15] ||
VAR_0->buf_size >= 528 && !VAR_1[522] && AV_RB32(VAR_1+523) == 0x1102ff0c && !VAR_1[527])
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"const uint8_t *VAR_1 = VAR_0->buf;",
"if (!VAR_1[10] && AV_RB32(VAR_1+11) == 0x1102ff0c && !VAR_1[15] ||\nVAR_0->buf_size >= 528 && !VAR_1[522] && AV_RB32(VAR_1+523) == 0x1102ff0c && !VAR_1[527])\nreturn AVPROBE_SCORE_EXTENSION + 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13
],
[
15
],
[
17
]
] |
2,464 | static int decode_format80(VqaContext *s, int src_size,
unsigned char *dest, int dest_size, int check_size) {
int dest_index = 0;
int count, opcode, start;
int src_pos;
unsigned char color;
int i;
start = bytestream2_tell(&s->gb);
while (bytestream2_tell(&s->gb) - start < src_size) {
opcode = bytestream2_get_byte(&s->gb);
av_dlog(s->avctx, "opcode %02X: ", opcode);
/* 0x80 means that frame is finished */
if (opcode == 0x80)
return 0;
if (dest_index >= dest_size) {
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
dest_index, dest_size);
return AVERROR_INVALIDDATA;
}
if (opcode == 0xFF) {
count = bytestream2_get_le16(&s->gb);
src_pos = bytestream2_get_le16(&s->gb);
av_dlog(s->avctx, "(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (opcode == 0xFE) {
count = bytestream2_get_le16(&s->gb);
color = bytestream2_get_byte(&s->gb);
av_dlog(s->avctx, "(2) set %X bytes to %02X\n", count, color);
CHECK_COUNT();
memset(&dest[dest_index], color, count);
dest_index += count;
} else if ((opcode & 0xC0) == 0xC0) {
count = (opcode & 0x3F) + 3;
src_pos = bytestream2_get_le16(&s->gb);
av_dlog(s->avctx, "(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (opcode > 0x80) {
count = opcode & 0x3F;
av_dlog(s->avctx, "(4) copy %X bytes from source to dest\n", count);
CHECK_COUNT();
bytestream2_get_buffer(&s->gb, &dest[dest_index], count);
dest_index += count;
} else {
count = ((opcode & 0x70) >> 4) + 3;
src_pos = bytestream2_get_byte(&s->gb) | ((opcode & 0x0F) << 8);
av_dlog(s->avctx, "(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(dest_index - src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i];
dest_index += count;
}
}
/* validate that the entire destination buffer was filled; this is
* important for decoding frame maps since each vector needs to have a
* codebook entry; it is not important for compressed codebooks because
* not every entry needs to be filled */
if (check_size)
if (dest_index < dest_size)
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
dest_index, dest_size);
return 0; // let's display what we decoded anyway
}
| false | FFmpeg | 263105deebbd0a5737dfd1165668c7afb2cc870a | static int decode_format80(VqaContext *s, int src_size,
unsigned char *dest, int dest_size, int check_size) {
int dest_index = 0;
int count, opcode, start;
int src_pos;
unsigned char color;
int i;
start = bytestream2_tell(&s->gb);
while (bytestream2_tell(&s->gb) - start < src_size) {
opcode = bytestream2_get_byte(&s->gb);
av_dlog(s->avctx, "opcode %02X: ", opcode);
if (opcode == 0x80)
return 0;
if (dest_index >= dest_size) {
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: dest_index (%d) exceeded dest_size (%d)\n",
dest_index, dest_size);
return AVERROR_INVALIDDATA;
}
if (opcode == 0xFF) {
count = bytestream2_get_le16(&s->gb);
src_pos = bytestream2_get_le16(&s->gb);
av_dlog(s->avctx, "(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (opcode == 0xFE) {
count = bytestream2_get_le16(&s->gb);
color = bytestream2_get_byte(&s->gb);
av_dlog(s->avctx, "(2) set %X bytes to %02X\n", count, color);
CHECK_COUNT();
memset(&dest[dest_index], color, count);
dest_index += count;
} else if ((opcode & 0xC0) == 0xC0) {
count = (opcode & 0x3F) + 3;
src_pos = bytestream2_get_le16(&s->gb);
av_dlog(s->avctx, "(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
dest_index += count;
} else if (opcode > 0x80) {
count = opcode & 0x3F;
av_dlog(s->avctx, "(4) copy %X bytes from source to dest\n", count);
CHECK_COUNT();
bytestream2_get_buffer(&s->gb, &dest[dest_index], count);
dest_index += count;
} else {
count = ((opcode & 0x70) >> 4) + 3;
src_pos = bytestream2_get_byte(&s->gb) | ((opcode & 0x0F) << 8);
av_dlog(s->avctx, "(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
CHECK_COPY(dest_index - src_pos);
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i];
dest_index += count;
}
}
if (check_size)
if (dest_index < dest_size)
av_log(s->avctx, AV_LOG_ERROR, "decode_format80 problem: decode finished with dest_index (%d) < dest_size (%d)\n",
dest_index, dest_size);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VqaContext *VAR_0, int VAR_1,
unsigned char *VAR_2, int VAR_3, int VAR_4) {
int VAR_5 = 0;
int VAR_6, VAR_7, VAR_8;
int VAR_9;
unsigned char VAR_10;
int VAR_11;
VAR_8 = bytestream2_tell(&VAR_0->gb);
while (bytestream2_tell(&VAR_0->gb) - VAR_8 < VAR_1) {
VAR_7 = bytestream2_get_byte(&VAR_0->gb);
av_dlog(VAR_0->avctx, "VAR_7 %02X: ", VAR_7);
if (VAR_7 == 0x80)
return 0;
if (VAR_5 >= VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "FUNC_0 problem: VAR_5 (%d) exceeded VAR_3 (%d)\n",
VAR_5, VAR_3);
return AVERROR_INVALIDDATA;
}
if (VAR_7 == 0xFF) {
VAR_6 = bytestream2_get_le16(&VAR_0->gb);
VAR_9 = bytestream2_get_le16(&VAR_0->gb);
av_dlog(VAR_0->avctx, "(1) copy %X bytes from absolute pos %X\n", VAR_6, VAR_9);
CHECK_COUNT();
CHECK_COPY(VAR_9);
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)
VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_9 + VAR_11];
VAR_5 += VAR_6;
} else if (VAR_7 == 0xFE) {
VAR_6 = bytestream2_get_le16(&VAR_0->gb);
VAR_10 = bytestream2_get_byte(&VAR_0->gb);
av_dlog(VAR_0->avctx, "(2) set %X bytes to %02X\n", VAR_6, VAR_10);
CHECK_COUNT();
memset(&VAR_2[VAR_5], VAR_10, VAR_6);
VAR_5 += VAR_6;
} else if ((VAR_7 & 0xC0) == 0xC0) {
VAR_6 = (VAR_7 & 0x3F) + 3;
VAR_9 = bytestream2_get_le16(&VAR_0->gb);
av_dlog(VAR_0->avctx, "(3) copy %X bytes from absolute pos %X\n", VAR_6, VAR_9);
CHECK_COUNT();
CHECK_COPY(VAR_9);
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)
VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_9 + VAR_11];
VAR_5 += VAR_6;
} else if (VAR_7 > 0x80) {
VAR_6 = VAR_7 & 0x3F;
av_dlog(VAR_0->avctx, "(4) copy %X bytes from source to VAR_2\n", VAR_6);
CHECK_COUNT();
bytestream2_get_buffer(&VAR_0->gb, &VAR_2[VAR_5], VAR_6);
VAR_5 += VAR_6;
} else {
VAR_6 = ((VAR_7 & 0x70) >> 4) + 3;
VAR_9 = bytestream2_get_byte(&VAR_0->gb) | ((VAR_7 & 0x0F) << 8);
av_dlog(VAR_0->avctx, "(5) copy %X bytes from relpos %X\n", VAR_6, VAR_9);
CHECK_COUNT();
CHECK_COPY(VAR_5 - VAR_9);
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)
VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_5 - VAR_9 + VAR_11];
VAR_5 += VAR_6;
}
}
if (VAR_4)
if (VAR_5 < VAR_3)
av_log(VAR_0->avctx, AV_LOG_ERROR, "FUNC_0 problem: decode finished with VAR_5 (%d) < VAR_3 (%d)\n",
VAR_5, VAR_3);
return 0;
}
| [
"static int FUNC_0(VqaContext *VAR_0, int VAR_1,\nunsigned char *VAR_2, int VAR_3, int VAR_4) {",
"int VAR_5 = 0;",
"int VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"unsigned char VAR_10;",
"int VAR_11;",
"VAR_8 = bytestream2_tell(&VAR_0->gb);",
"while (bytestream2_tell(&VAR_0->gb) - VAR_8 < VAR_1) {",
"VAR_7 = bytestream2_get_byte(&VAR_0->gb);",
"av_dlog(VAR_0->avctx, \"VAR_7 %02X: \", VAR_7);",
"if (VAR_7 == 0x80)\nreturn 0;",
"if (VAR_5 >= VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"FUNC_0 problem: VAR_5 (%d) exceeded VAR_3 (%d)\\n\",\nVAR_5, VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_7 == 0xFF) {",
"VAR_6 = bytestream2_get_le16(&VAR_0->gb);",
"VAR_9 = bytestream2_get_le16(&VAR_0->gb);",
"av_dlog(VAR_0->avctx, \"(1) copy %X bytes from absolute pos %X\\n\", VAR_6, VAR_9);",
"CHECK_COUNT();",
"CHECK_COPY(VAR_9);",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)",
"VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_9 + VAR_11];",
"VAR_5 += VAR_6;",
"} else if (VAR_7 == 0xFE) {",
"VAR_6 = bytestream2_get_le16(&VAR_0->gb);",
"VAR_10 = bytestream2_get_byte(&VAR_0->gb);",
"av_dlog(VAR_0->avctx, \"(2) set %X bytes to %02X\\n\", VAR_6, VAR_10);",
"CHECK_COUNT();",
"memset(&VAR_2[VAR_5], VAR_10, VAR_6);",
"VAR_5 += VAR_6;",
"} else if ((VAR_7 & 0xC0) == 0xC0) {",
"VAR_6 = (VAR_7 & 0x3F) + 3;",
"VAR_9 = bytestream2_get_le16(&VAR_0->gb);",
"av_dlog(VAR_0->avctx, \"(3) copy %X bytes from absolute pos %X\\n\", VAR_6, VAR_9);",
"CHECK_COUNT();",
"CHECK_COPY(VAR_9);",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)",
"VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_9 + VAR_11];",
"VAR_5 += VAR_6;",
"} else if (VAR_7 > 0x80) {",
"VAR_6 = VAR_7 & 0x3F;",
"av_dlog(VAR_0->avctx, \"(4) copy %X bytes from source to VAR_2\\n\", VAR_6);",
"CHECK_COUNT();",
"bytestream2_get_buffer(&VAR_0->gb, &VAR_2[VAR_5], VAR_6);",
"VAR_5 += VAR_6;",
"} else {",
"VAR_6 = ((VAR_7 & 0x70) >> 4) + 3;",
"VAR_9 = bytestream2_get_byte(&VAR_0->gb) | ((VAR_7 & 0x0F) << 8);",
"av_dlog(VAR_0->avctx, \"(5) copy %X bytes from relpos %X\\n\", VAR_6, VAR_9);",
"CHECK_COUNT();",
"CHECK_COPY(VAR_5 - VAR_9);",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++)",
"VAR_2[VAR_5 + VAR_11] = VAR_2[VAR_5 - VAR_9 + VAR_11];",
"VAR_5 += VAR_6;",
"}",
"}",
"if (VAR_4)\nif (VAR_5 < VAR_3)\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"FUNC_0 problem: decode finished with VAR_5 (%d) < VAR_3 (%d)\\n\",\nVAR_5, 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
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31,
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
161,
163,
165,
167
],
[
171
],
[
173
]
] |
2,465 | static int open_input_file(OptionsContext *o, const char *filename)
{
InputFile *f;
AVFormatContext *ic;
AVInputFormat *file_iformat = NULL;
int err, i, ret;
int64_t timestamp;
uint8_t buf[128];
AVDictionary **opts;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
int orig_nb_streams; // number of streams before avformat_find_stream_info
if (o->format) {
if (!(file_iformat = av_find_input_format(o->format))) {
av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
exit_program(1);
}
}
if (!strcmp(filename, "-"))
filename = "pipe:";
using_stdin |= !strncmp(filename, "pipe:", 5) ||
!strcmp(filename, "/dev/stdin");
/* get default parameters from command line */
ic = avformat_alloc_context();
if (!ic) {
print_error(filename, AVERROR(ENOMEM));
exit_program(1);
}
if (o->nb_audio_sample_rate) {
snprintf(buf, sizeof(buf), "%d", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i);
av_dict_set(&o->g->format_opts, "sample_rate", buf, 0);
}
if (o->nb_audio_channels) {
/* because we set audio_channels based on both the "ac" and
* "channel_layout" options, we need to check that the specified
* demuxer actually has the "channels" option before setting it */
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
snprintf(buf, sizeof(buf), "%d",
o->audio_channels[o->nb_audio_channels - 1].u.i);
av_dict_set(&o->g->format_opts, "channels", buf, 0);
}
}
if (o->nb_frame_rates) {
/* set the format-level framerate option;
* this is important for video grabbers, e.g. x11 */
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set(&o->g->format_opts, "framerate",
o->frame_rates[o->nb_frame_rates - 1].u.str, 0);
}
}
if (o->nb_frame_sizes) {
av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0);
}
if (o->nb_frame_pix_fmts)
av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
/* open the input file with generic libav function */
err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
assert_avoptions(o->g->format_opts);
/* apply forced codec ids */
for (i = 0; i < ic->nb_streams; i++)
choose_decoder(o, ic, ic->streams[i]);
/* Set AVCodecContext options for avformat_find_stream_info */
opts = setup_find_stream_info_opts(ic, o->g->codec_opts);
orig_nb_streams = ic->nb_streams;
/* If not enough info to get the stream parameters, we decode the
first frames to get it. (used in mpeg case for example) */
ret = avformat_find_stream_info(ic, opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
avformat_close_input(&ic);
exit_program(1);
}
timestamp = o->start_time;
/* add the stream start time */
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
/* if seeking requested, we execute it */
if (o->start_time != 0) {
ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
if (ret < 0) {
av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
filename, (double)timestamp / AV_TIME_BASE);
}
}
/* update the current parameters so that they match the one of the input stream */
add_input_streams(o, ic);
/* dump the file content */
av_dump_format(ic, nb_input_files, filename, 0);
GROW_ARRAY(input_files, nb_input_files);
f = av_mallocz(sizeof(*f));
if (!f)
exit_program(1);
input_files[nb_input_files - 1] = f;
f->ctx = ic;
f->ist_index = nb_input_streams - ic->nb_streams;
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = o->rate_emu;
/* check if all codec options have been used */
unused_opts = strip_specifiers(o->g->codec_opts);
for (i = f->ist_index; i < nb_input_streams; i++) {
e = NULL;
while ((e = av_dict_get(input_streams[i]->opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option)
continue;
if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) is not a decoding option.\n", e->key,
option->help ? option->help : "", nb_input_files - 1,
filename);
exit_program(1);
}
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some decoder "
"which was not actually used for any stream.\n", e->key,
option->help ? option->help : "", nb_input_files - 1, filename);
}
av_dict_free(&unused_opts);
for (i = 0; i < o->nb_dump_attachment; i++) {
int j;
for (j = 0; j < ic->nb_streams; j++) {
AVStream *st = ic->streams[j];
if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1)
dump_attachment(st, o->dump_attachment[i].u.str);
}
}
for (i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
av_freep(&opts);
return 0;
}
| false | FFmpeg | 56ee3f9de7b9f6090d599a27d33a392890a2f7b8 | static int open_input_file(OptionsContext *o, const char *filename)
{
InputFile *f;
AVFormatContext *ic;
AVInputFormat *file_iformat = NULL;
int err, i, ret;
int64_t timestamp;
uint8_t buf[128];
AVDictionary **opts;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
int orig_nb_streams;
if (o->format) {
if (!(file_iformat = av_find_input_format(o->format))) {
av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
exit_program(1);
}
}
if (!strcmp(filename, "-"))
filename = "pipe:";
using_stdin |= !strncmp(filename, "pipe:", 5) ||
!strcmp(filename, "/dev/stdin");
ic = avformat_alloc_context();
if (!ic) {
print_error(filename, AVERROR(ENOMEM));
exit_program(1);
}
if (o->nb_audio_sample_rate) {
snprintf(buf, sizeof(buf), "%d", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i);
av_dict_set(&o->g->format_opts, "sample_rate", buf, 0);
}
if (o->nb_audio_channels) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
snprintf(buf, sizeof(buf), "%d",
o->audio_channels[o->nb_audio_channels - 1].u.i);
av_dict_set(&o->g->format_opts, "channels", buf, 0);
}
}
if (o->nb_frame_rates) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set(&o->g->format_opts, "framerate",
o->frame_rates[o->nb_frame_rates - 1].u.str, 0);
}
}
if (o->nb_frame_sizes) {
av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0);
}
if (o->nb_frame_pix_fmts)
av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
if (err < 0) {
print_error(filename, err);
exit_program(1);
}
assert_avoptions(o->g->format_opts);
for (i = 0; i < ic->nb_streams; i++)
choose_decoder(o, ic, ic->streams[i]);
opts = setup_find_stream_info_opts(ic, o->g->codec_opts);
orig_nb_streams = ic->nb_streams;
ret = avformat_find_stream_info(ic, opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
avformat_close_input(&ic);
exit_program(1);
}
timestamp = o->start_time;
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
if (o->start_time != 0) {
ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
if (ret < 0) {
av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
filename, (double)timestamp / AV_TIME_BASE);
}
}
add_input_streams(o, ic);
av_dump_format(ic, nb_input_files, filename, 0);
GROW_ARRAY(input_files, nb_input_files);
f = av_mallocz(sizeof(*f));
if (!f)
exit_program(1);
input_files[nb_input_files - 1] = f;
f->ctx = ic;
f->ist_index = nb_input_streams - ic->nb_streams;
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = o->rate_emu;
unused_opts = strip_specifiers(o->g->codec_opts);
for (i = f->ist_index; i < nb_input_streams; i++) {
e = NULL;
while ((e = av_dict_get(input_streams[i]->opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *class = avcodec_get_class();
const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!option)
continue;
if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) is not a decoding option.\n", e->key,
option->help ? option->help : "", nb_input_files - 1,
filename);
exit_program(1);
}
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some decoder "
"which was not actually used for any stream.\n", e->key,
option->help ? option->help : "", nb_input_files - 1, filename);
}
av_dict_free(&unused_opts);
for (i = 0; i < o->nb_dump_attachment; i++) {
int j;
for (j = 0; j < ic->nb_streams; j++) {
AVStream *st = ic->streams[j];
if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1)
dump_attachment(st, o->dump_attachment[i].u.str);
}
}
for (i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
av_freep(&opts);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1)
{
InputFile *f;
AVFormatContext *ic;
AVInputFormat *file_iformat = NULL;
int VAR_2, VAR_3, VAR_4;
int64_t timestamp;
uint8_t buf[128];
AVDictionary **opts;
AVDictionary *unused_opts = NULL;
AVDictionaryEntry *e = NULL;
int VAR_5;
if (VAR_0->format) {
if (!(file_iformat = av_find_input_format(VAR_0->format))) {
av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", VAR_0->format);
exit_program(1);
}
}
if (!strcmp(VAR_1, "-"))
VAR_1 = "pipe:";
using_stdin |= !strncmp(VAR_1, "pipe:", 5) ||
!strcmp(VAR_1, "/dev/stdin");
ic = avformat_alloc_context();
if (!ic) {
print_error(VAR_1, AVERROR(ENOMEM));
exit_program(1);
}
if (VAR_0->nb_audio_sample_rate) {
snprintf(buf, sizeof(buf), "%d", VAR_0->audio_sample_rate[VAR_0->nb_audio_sample_rate - 1].u.VAR_3);
av_dict_set(&VAR_0->g->format_opts, "sample_rate", buf, 0);
}
if (VAR_0->nb_audio_channels) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
snprintf(buf, sizeof(buf), "%d",
VAR_0->audio_channels[VAR_0->nb_audio_channels - 1].u.VAR_3);
av_dict_set(&VAR_0->g->format_opts, "channels", buf, 0);
}
}
if (VAR_0->nb_frame_rates) {
if (file_iformat && file_iformat->priv_class &&
av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set(&VAR_0->g->format_opts, "framerate",
VAR_0->frame_rates[VAR_0->nb_frame_rates - 1].u.str, 0);
}
}
if (VAR_0->nb_frame_sizes) {
av_dict_set(&VAR_0->g->format_opts, "video_size", VAR_0->frame_sizes[VAR_0->nb_frame_sizes - 1].u.str, 0);
}
if (VAR_0->nb_frame_pix_fmts)
av_dict_set(&VAR_0->g->format_opts, "pixel_format", VAR_0->frame_pix_fmts[VAR_0->nb_frame_pix_fmts - 1].u.str, 0);
ic->flags |= AVFMT_FLAG_NONBLOCK;
ic->interrupt_callback = int_cb;
VAR_2 = avformat_open_input(&ic, VAR_1, file_iformat, &VAR_0->g->format_opts);
if (VAR_2 < 0) {
print_error(VAR_1, VAR_2);
exit_program(1);
}
assert_avoptions(VAR_0->g->format_opts);
for (VAR_3 = 0; VAR_3 < ic->nb_streams; VAR_3++)
choose_decoder(VAR_0, ic, ic->streams[VAR_3]);
opts = setup_find_stream_info_opts(ic, VAR_0->g->codec_opts);
VAR_5 = ic->nb_streams;
VAR_4 = avformat_find_stream_info(ic, opts);
if (VAR_4 < 0) {
av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", VAR_1);
avformat_close_input(&ic);
exit_program(1);
}
timestamp = VAR_0->start_time;
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
if (VAR_0->start_time != 0) {
VAR_4 = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
if (VAR_4 < 0) {
av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
VAR_1, (double)timestamp / AV_TIME_BASE);
}
}
add_input_streams(VAR_0, ic);
av_dump_format(ic, nb_input_files, VAR_1, 0);
GROW_ARRAY(input_files, nb_input_files);
f = av_mallocz(sizeof(*f));
if (!f)
exit_program(1);
input_files[nb_input_files - 1] = f;
f->ctx = ic;
f->ist_index = nb_input_streams - ic->nb_streams;
f->ts_offset = VAR_0->input_ts_offset - (copy_ts ? 0 : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = VAR_0->rate_emu;
unused_opts = strip_specifiers(VAR_0->g->codec_opts);
for (VAR_3 = f->ist_index; VAR_3 < nb_input_streams; VAR_3++) {
e = NULL;
while ((e = av_dict_get(input_streams[VAR_3]->opts, "", e,
AV_DICT_IGNORE_SUFFIX)))
av_dict_set(&unused_opts, e->key, NULL, 0);
}
e = NULL;
while ((e = av_dict_get(unused_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
const AVClass *VAR_6 = avcodec_get_class();
const AVOption *VAR_7 = av_opt_find(&VAR_6, e->key, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
if (!VAR_7)
continue;
if (!(VAR_7->flags & AV_OPT_FLAG_DECODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) is not a decoding VAR_7.\n", e->key,
VAR_7->help ? VAR_7->help : "", nb_input_files - 1,
VAR_1);
exit_program(1);
}
av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) has not been used for any stream. The most "
"likely reason is either wrong type (e.g. a video VAR_7 with "
"no video streams) or that it is a private VAR_7 of some decoder "
"which was not actually used for any stream.\n", e->key,
VAR_7->help ? VAR_7->help : "", nb_input_files - 1, VAR_1);
}
av_dict_free(&unused_opts);
for (VAR_3 = 0; VAR_3 < VAR_0->nb_dump_attachment; VAR_3++) {
int j;
for (j = 0; j < ic->nb_streams; j++) {
AVStream *st = ic->streams[j];
if (check_stream_specifier(ic, st, VAR_0->dump_attachment[VAR_3].specifier) == 1)
dump_attachment(st, VAR_0->dump_attachment[VAR_3].u.str);
}
}
for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3++)
av_dict_free(&opts[VAR_3]);
av_freep(&opts);
return 0;
}
| [
"static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1)\n{",
"InputFile *f;",
"AVFormatContext *ic;",
"AVInputFormat *file_iformat = NULL;",
"int VAR_2, VAR_3, VAR_4;",
"int64_t timestamp;",
"uint8_t buf[128];",
"AVDictionary **opts;",
"AVDictionary *unused_opts = NULL;",
"AVDictionaryEntry *e = NULL;",
"int VAR_5;",
"if (VAR_0->format) {",
"if (!(file_iformat = av_find_input_format(VAR_0->format))) {",
"av_log(NULL, AV_LOG_FATAL, \"Unknown input format: '%s'\\n\", VAR_0->format);",
"exit_program(1);",
"}",
"}",
"if (!strcmp(VAR_1, \"-\"))\nVAR_1 = \"pipe:\";",
"using_stdin |= !strncmp(VAR_1, \"pipe:\", 5) ||\n!strcmp(VAR_1, \"/dev/stdin\");",
"ic = avformat_alloc_context();",
"if (!ic) {",
"print_error(VAR_1, AVERROR(ENOMEM));",
"exit_program(1);",
"}",
"if (VAR_0->nb_audio_sample_rate) {",
"snprintf(buf, sizeof(buf), \"%d\", VAR_0->audio_sample_rate[VAR_0->nb_audio_sample_rate - 1].u.VAR_3);",
"av_dict_set(&VAR_0->g->format_opts, \"sample_rate\", buf, 0);",
"}",
"if (VAR_0->nb_audio_channels) {",
"if (file_iformat && file_iformat->priv_class &&\nav_opt_find(&file_iformat->priv_class, \"channels\", NULL, 0,\nAV_OPT_SEARCH_FAKE_OBJ)) {",
"snprintf(buf, sizeof(buf), \"%d\",\nVAR_0->audio_channels[VAR_0->nb_audio_channels - 1].u.VAR_3);",
"av_dict_set(&VAR_0->g->format_opts, \"channels\", buf, 0);",
"}",
"}",
"if (VAR_0->nb_frame_rates) {",
"if (file_iformat && file_iformat->priv_class &&\nav_opt_find(&file_iformat->priv_class, \"framerate\", NULL, 0,\nAV_OPT_SEARCH_FAKE_OBJ)) {",
"av_dict_set(&VAR_0->g->format_opts, \"framerate\",\nVAR_0->frame_rates[VAR_0->nb_frame_rates - 1].u.str, 0);",
"}",
"}",
"if (VAR_0->nb_frame_sizes) {",
"av_dict_set(&VAR_0->g->format_opts, \"video_size\", VAR_0->frame_sizes[VAR_0->nb_frame_sizes - 1].u.str, 0);",
"}",
"if (VAR_0->nb_frame_pix_fmts)\nav_dict_set(&VAR_0->g->format_opts, \"pixel_format\", VAR_0->frame_pix_fmts[VAR_0->nb_frame_pix_fmts - 1].u.str, 0);",
"ic->flags |= AVFMT_FLAG_NONBLOCK;",
"ic->interrupt_callback = int_cb;",
"VAR_2 = avformat_open_input(&ic, VAR_1, file_iformat, &VAR_0->g->format_opts);",
"if (VAR_2 < 0) {",
"print_error(VAR_1, VAR_2);",
"exit_program(1);",
"}",
"assert_avoptions(VAR_0->g->format_opts);",
"for (VAR_3 = 0; VAR_3 < ic->nb_streams; VAR_3++)",
"choose_decoder(VAR_0, ic, ic->streams[VAR_3]);",
"opts = setup_find_stream_info_opts(ic, VAR_0->g->codec_opts);",
"VAR_5 = ic->nb_streams;",
"VAR_4 = avformat_find_stream_info(ic, opts);",
"if (VAR_4 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"%s: could not find codec parameters\\n\", VAR_1);",
"avformat_close_input(&ic);",
"exit_program(1);",
"}",
"timestamp = VAR_0->start_time;",
"if (ic->start_time != AV_NOPTS_VALUE)\ntimestamp += ic->start_time;",
"if (VAR_0->start_time != 0) {",
"VAR_4 = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);",
"if (VAR_4 < 0) {",
"av_log(NULL, AV_LOG_WARNING, \"%s: could not seek to position %0.3f\\n\",\nVAR_1, (double)timestamp / AV_TIME_BASE);",
"}",
"}",
"add_input_streams(VAR_0, ic);",
"av_dump_format(ic, nb_input_files, VAR_1, 0);",
"GROW_ARRAY(input_files, nb_input_files);",
"f = av_mallocz(sizeof(*f));",
"if (!f)\nexit_program(1);",
"input_files[nb_input_files - 1] = f;",
"f->ctx = ic;",
"f->ist_index = nb_input_streams - ic->nb_streams;",
"f->ts_offset = VAR_0->input_ts_offset - (copy_ts ? 0 : timestamp);",
"f->nb_streams = ic->nb_streams;",
"f->rate_emu = VAR_0->rate_emu;",
"unused_opts = strip_specifiers(VAR_0->g->codec_opts);",
"for (VAR_3 = f->ist_index; VAR_3 < nb_input_streams; VAR_3++) {",
"e = NULL;",
"while ((e = av_dict_get(input_streams[VAR_3]->opts, \"\", e,\nAV_DICT_IGNORE_SUFFIX)))\nav_dict_set(&unused_opts, e->key, NULL, 0);",
"}",
"e = NULL;",
"while ((e = av_dict_get(unused_opts, \"\", e, AV_DICT_IGNORE_SUFFIX))) {",
"const AVClass *VAR_6 = avcodec_get_class();",
"const AVOption *VAR_7 = av_opt_find(&VAR_6, e->key, NULL, 0,\nAV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);",
"if (!VAR_7)\ncontinue;",
"if (!(VAR_7->flags & AV_OPT_FLAG_DECODING_PARAM)) {",
"av_log(NULL, AV_LOG_ERROR, \"Codec AVOption %s (%s) specified for \"\n\"input file #%d (%s) is not a decoding VAR_7.\\n\", e->key,\nVAR_7->help ? VAR_7->help : \"\", nb_input_files - 1,\nVAR_1);",
"exit_program(1);",
"}",
"av_log(NULL, AV_LOG_WARNING, \"Codec AVOption %s (%s) specified for \"\n\"input file #%d (%s) has not been used for any stream. The most \"\n\"likely reason is either wrong type (e.g. a video VAR_7 with \"\n\"no video streams) or that it is a private VAR_7 of some decoder \"\n\"which was not actually used for any stream.\\n\", e->key,\nVAR_7->help ? VAR_7->help : \"\", nb_input_files - 1, VAR_1);",
"}",
"av_dict_free(&unused_opts);",
"for (VAR_3 = 0; VAR_3 < VAR_0->nb_dump_attachment; VAR_3++) {",
"int j;",
"for (j = 0; j < ic->nb_streams; j++) {",
"AVStream *st = ic->streams[j];",
"if (check_stream_specifier(ic, st, VAR_0->dump_attachment[VAR_3].specifier) == 1)\ndump_attachment(st, VAR_0->dump_attachment[VAR_3].u.str);",
"}",
"}",
"for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3++)",
"av_dict_free(&opts[VAR_3]);",
"av_freep(&opts);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
47,
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
81,
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
103,
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
153
],
[
155
],
[
161
],
[
163
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
189,
191
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
215
],
[
221
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
251
],
[
253
],
[
255
],
[
257,
259,
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277,
279
],
[
281
],
[
283,
285,
287,
289
],
[
291
],
[
293
],
[
297,
299,
301,
303,
305,
307
],
[
309
],
[
311
],
[
315
],
[
317
],
[
321
],
[
323
],
[
327,
329
],
[
331
],
[
333
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
]
] |
2,467 | static int theora_packet(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
int duration;
/* first packet handling
here we parse the duration of each packet in the first page and compare
the total duration to the page granule to find the encoder delay and
set the first timestamp */
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
int seg;
duration = 1;
for (seg = os->segp; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255)
duration ++;
}
os->lastpts = os->lastdts = theora_gptopts(s, idx, os->granule, NULL) - duration;
if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
s->streams[idx]->start_time = os->lastpts;
if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time;
}
}
/* parse packet duration */
if (os->psize > 0) {
os->pduration = 1;
}
return 0;
}
| false | FFmpeg | 0c1d62ab9d757d546fafca366d776524e7bb9893 | static int theora_packet(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
int duration;
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
int seg;
duration = 1;
for (seg = os->segp; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255)
duration ++;
}
os->lastpts = os->lastdts = theora_gptopts(s, idx, os->granule, NULL) - duration;
if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
s->streams[idx]->start_time = os->lastpts;
if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time;
}
}
if (os->psize > 0) {
os->pduration = 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
struct VAR_2 *VAR_2 = VAR_0->priv_data;
struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;
int VAR_4;
if ((!VAR_3->lastpts || VAR_3->lastpts == AV_NOPTS_VALUE) && !(VAR_3->flags & OGG_FLAG_EOS)) {
int VAR_5;
VAR_4 = 1;
for (VAR_5 = VAR_3->segp; VAR_5 < VAR_3->nsegs; VAR_5++) {
if (VAR_3->segments[VAR_5] < 255)
VAR_4 ++;
}
VAR_3->lastpts = VAR_3->lastdts = theora_gptopts(VAR_0, VAR_1, VAR_3->granule, NULL) - VAR_4;
if(VAR_0->streams[VAR_1]->start_time == AV_NOPTS_VALUE) {
VAR_0->streams[VAR_1]->start_time = VAR_3->lastpts;
if (VAR_0->streams[VAR_1]->VAR_4)
VAR_0->streams[VAR_1]->VAR_4 -= VAR_0->streams[VAR_1]->start_time;
}
}
if (VAR_3->psize > 0) {
VAR_3->pduration = 1;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"struct VAR_2 *VAR_2 = VAR_0->priv_data;",
"struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;",
"int VAR_4;",
"if ((!VAR_3->lastpts || VAR_3->lastpts == AV_NOPTS_VALUE) && !(VAR_3->flags & OGG_FLAG_EOS)) {",
"int VAR_5;",
"VAR_4 = 1;",
"for (VAR_5 = VAR_3->segp; VAR_5 < VAR_3->nsegs; VAR_5++) {",
"if (VAR_3->segments[VAR_5] < 255)\nVAR_4 ++;",
"}",
"VAR_3->lastpts = VAR_3->lastdts = theora_gptopts(VAR_0, VAR_1, VAR_3->granule, NULL) - VAR_4;",
"if(VAR_0->streams[VAR_1]->start_time == AV_NOPTS_VALUE) {",
"VAR_0->streams[VAR_1]->start_time = VAR_3->lastpts;",
"if (VAR_0->streams[VAR_1]->VAR_4)\nVAR_0->streams[VAR_1]->VAR_4 -= VAR_0->streams[VAR_1]->start_time;",
"}",
"}",
"if (VAR_3->psize > 0) {",
"VAR_3->pduration = 1;",
"}",
"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
],
[
9
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
2,468 | static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0);
ffio_wfourcc(pb, "wfex");
ff_put_wav_header(pb, track->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
return update_size(pb, pos);
}
| false | FFmpeg | dc6b99d6b20e832a7d353474c2d093f8b2fb17d2 | static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0);
ffio_wfourcc(pb, "wfex");
ff_put_wav_header(pb, track->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
return update_size(pb, pos);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)
{
int64_t pos = avio_tell(VAR_0);
avio_wb32(VAR_0, 0);
ffio_wfourcc(VAR_0, "wfex");
ff_put_wav_header(VAR_0, VAR_1->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
return update_size(VAR_0, pos);
}
| [
"static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)\n{",
"int64_t pos = avio_tell(VAR_0);",
"avio_wb32(VAR_0, 0);",
"ffio_wfourcc(VAR_0, \"wfex\");",
"ff_put_wav_header(VAR_0, VAR_1->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);",
"return update_size(VAR_0, pos);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
2,469 | static void denoise_depth(HQDN3DContext *s,
uint8_t *src, uint8_t *dst,
uint16_t *line_ant, uint16_t **frame_ant_ptr,
int w, int h, int sstride, int dstride,
int16_t *spatial, int16_t *temporal, int depth)
{
// FIXME: For 16bit depth, frame_ant could be a pointer to the previous
// filtered frame rather than a separate buffer.
long x, y;
uint16_t *frame_ant = *frame_ant_ptr;
if (!frame_ant) {
uint8_t *frame_src = src;
*frame_ant_ptr = frame_ant = av_malloc(w*h*sizeof(uint16_t));
for (y = 0; y < h; y++, src += sstride, frame_ant += w)
for (x = 0; x < w; x++)
frame_ant[x] = LOAD(x);
src = frame_src;
frame_ant = *frame_ant_ptr;
}
if (spatial[0])
denoise_spatial(s, src, dst, line_ant, frame_ant,
w, h, sstride, dstride, spatial, temporal, depth);
else
denoise_temporal(src, dst, frame_ant,
w, h, sstride, dstride, temporal, depth);
emms_c();
}
| false | FFmpeg | 22b985d59c007c4422aefe3ef3fca0aa0daafa9f | static void denoise_depth(HQDN3DContext *s,
uint8_t *src, uint8_t *dst,
uint16_t *line_ant, uint16_t **frame_ant_ptr,
int w, int h, int sstride, int dstride,
int16_t *spatial, int16_t *temporal, int depth)
{
long x, y;
uint16_t *frame_ant = *frame_ant_ptr;
if (!frame_ant) {
uint8_t *frame_src = src;
*frame_ant_ptr = frame_ant = av_malloc(w*h*sizeof(uint16_t));
for (y = 0; y < h; y++, src += sstride, frame_ant += w)
for (x = 0; x < w; x++)
frame_ant[x] = LOAD(x);
src = frame_src;
frame_ant = *frame_ant_ptr;
}
if (spatial[0])
denoise_spatial(s, src, dst, line_ant, frame_ant,
w, h, sstride, dstride, spatial, temporal, depth);
else
denoise_temporal(src, dst, frame_ant,
w, h, sstride, dstride, temporal, depth);
emms_c();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HQDN3DContext *VAR_0,
uint8_t *VAR_1, uint8_t *VAR_2,
uint16_t *VAR_3, uint16_t **VAR_4,
int VAR_5, int VAR_6, int VAR_7, int VAR_8,
int16_t *VAR_9, int16_t *VAR_10, int VAR_11)
{
long VAR_12, VAR_13;
uint16_t *frame_ant = *VAR_4;
if (!frame_ant) {
uint8_t *frame_src = VAR_1;
*VAR_4 = frame_ant = av_malloc(VAR_5*VAR_6*sizeof(uint16_t));
for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++, VAR_1 += VAR_7, frame_ant += VAR_5)
for (VAR_12 = 0; VAR_12 < VAR_5; VAR_12++)
frame_ant[VAR_12] = LOAD(VAR_12);
VAR_1 = frame_src;
frame_ant = *VAR_4;
}
if (VAR_9[0])
denoise_spatial(VAR_0, VAR_1, VAR_2, VAR_3, frame_ant,
VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11);
else
denoise_temporal(VAR_1, VAR_2, frame_ant,
VAR_5, VAR_6, VAR_7, VAR_8, VAR_10, VAR_11);
emms_c();
}
| [
"static void FUNC_0(HQDN3DContext *VAR_0,\nuint8_t *VAR_1, uint8_t *VAR_2,\nuint16_t *VAR_3, uint16_t **VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int VAR_8,\nint16_t *VAR_9, int16_t *VAR_10, int VAR_11)\n{",
"long VAR_12, VAR_13;",
"uint16_t *frame_ant = *VAR_4;",
"if (!frame_ant) {",
"uint8_t *frame_src = VAR_1;",
"*VAR_4 = frame_ant = av_malloc(VAR_5*VAR_6*sizeof(uint16_t));",
"for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++, VAR_1 += VAR_7, frame_ant += VAR_5)",
"for (VAR_12 = 0; VAR_12 < VAR_5; VAR_12++)",
"frame_ant[VAR_12] = LOAD(VAR_12);",
"VAR_1 = frame_src;",
"frame_ant = *VAR_4;",
"}",
"if (VAR_9[0])\ndenoise_spatial(VAR_0, VAR_1, VAR_2, VAR_3, frame_ant,\nVAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11);",
"else\ndenoise_temporal(VAR_1, VAR_2, frame_ant,\nVAR_5, VAR_6, VAR_7, VAR_8, VAR_10, VAR_11);",
"emms_c();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43,
45
],
[
47,
49,
51
],
[
53
],
[
55
]
] |
2,470 | static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
int x, y;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
dst[x] += *coeffs;
coeffs++;
}
dst += stride;
}
}
| false | FFmpeg | a246d06fe0dc6c2ea65e95327624b4537ff9bd0d | static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
int x, y;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
dst[x] += *coeffs;
coeffs++;
}
dst += stride;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
ptrdiff_t stride)
{
int VAR_0, VAR_1;
pixel *dst = (pixel *)_dst;
stride /= sizeof(pixel);
for (VAR_1 = 0; VAR_1 < 8; VAR_1++) {
for (VAR_0 = 0; VAR_0 < 8; VAR_0++) {
dst[VAR_0] += *coeffs;
coeffs++;
}
dst += stride;
}
}
| [
"static void FUNC_0(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,\nptrdiff_t stride)\n{",
"int VAR_0, VAR_1;",
"pixel *dst = (pixel *)_dst;",
"stride /= sizeof(pixel);",
"for (VAR_1 = 0; VAR_1 < 8; VAR_1++) {",
"for (VAR_0 = 0; VAR_0 < 8; VAR_0++) {",
"dst[VAR_0] += *coeffs;",
"coeffs++;",
"}",
"dst += stride;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
2,472 | static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
{
int addr_reg, r0, r1, rbase, data_reg, mem_index, bswap;
#ifdef CONFIG_SOFTMMU
int r2;
void *label1_ptr, *label2_ptr;
#endif
data_reg = *args++;
addr_reg = *args++;
mem_index = *args;
#ifdef CONFIG_SOFTMMU
r0 = 3;
r1 = 4;
r2 = 0;
rbase = 0;
tcg_out_tlb_read (s, r0, r1, r2, addr_reg, opc,
offsetof (CPUState, tlb_table[mem_index][0].addr_write));
tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1) | CMP_L);
label1_ptr = s->code_ptr;
#ifdef FAST_PATH
tcg_out32 (s, BC | BI (7, CR_EQ) | BO_COND_TRUE);
#endif
/* slow path */
tcg_out_mov (s, 3, addr_reg);
tcg_out_rld (s, RLDICL, 4, data_reg, 0, 64 - (1 << (3 + opc)));
tcg_out_movi (s, TCG_TYPE_I64, 5, mem_index);
tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1);
label2_ptr = s->code_ptr;
tcg_out32 (s, B);
/* label1: fast path */
#ifdef FAST_PATH
reloc_pc14 (label1_ptr, (tcg_target_long) s->code_ptr);
#endif
tcg_out32 (s, (LD_ADDEND
| RT (r0)
| RA (r0)
| (offsetof (CPUTLBEntry, addend)
- offsetof (CPUTLBEntry, addr_write))
));
/* r0 = env->tlb_table[mem_index][index].addend */
tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (addr_reg));
/* r0 = env->tlb_table[mem_index][index].addend + addr */
#else /* !CONFIG_SOFTMMU */
#if TARGET_LONG_BITS == 32
tcg_out_rld (s, RLDICL, addr_reg, addr_reg, 0, 32);
#endif
r1 = 3;
r0 = addr_reg;
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
#endif
#ifdef TARGET_WORDS_BIGENDIAN
bswap = 0;
#else
bswap = 1;
#endif
switch (opc) {
case 0:
tcg_out32 (s, STBX | SAB (data_reg, rbase, r0));
break;
case 1:
if (bswap)
tcg_out32 (s, STHBRX | SAB (data_reg, rbase, r0));
else
tcg_out32 (s, STHX | SAB (data_reg, rbase, r0));
break;
case 2:
if (bswap)
tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0));
else
tcg_out32 (s, STWX | SAB (data_reg, rbase, r0));
break;
case 3:
if (bswap) {
tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0));
tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4);
tcg_out_rld (s, RLDICL, 0, data_reg, 32, 0);
tcg_out32 (s, STWBRX | SAB (0, rbase, r1));
}
else tcg_out32 (s, STDX | SAB (data_reg, rbase, r0));
break;
}
#ifdef CONFIG_SOFTMMU
reloc_pc24 (label2_ptr, (tcg_target_long) s->code_ptr);
#endif
}
| false | qemu | 355b194369d02df7a97d554eef2a9cffe98d736f | static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
{
int addr_reg, r0, r1, rbase, data_reg, mem_index, bswap;
#ifdef CONFIG_SOFTMMU
int r2;
void *label1_ptr, *label2_ptr;
#endif
data_reg = *args++;
addr_reg = *args++;
mem_index = *args;
#ifdef CONFIG_SOFTMMU
r0 = 3;
r1 = 4;
r2 = 0;
rbase = 0;
tcg_out_tlb_read (s, r0, r1, r2, addr_reg, opc,
offsetof (CPUState, tlb_table[mem_index][0].addr_write));
tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1) | CMP_L);
label1_ptr = s->code_ptr;
#ifdef FAST_PATH
tcg_out32 (s, BC | BI (7, CR_EQ) | BO_COND_TRUE);
#endif
tcg_out_mov (s, 3, addr_reg);
tcg_out_rld (s, RLDICL, 4, data_reg, 0, 64 - (1 << (3 + opc)));
tcg_out_movi (s, TCG_TYPE_I64, 5, mem_index);
tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1);
label2_ptr = s->code_ptr;
tcg_out32 (s, B);
#ifdef FAST_PATH
reloc_pc14 (label1_ptr, (tcg_target_long) s->code_ptr);
#endif
tcg_out32 (s, (LD_ADDEND
| RT (r0)
| RA (r0)
| (offsetof (CPUTLBEntry, addend)
- offsetof (CPUTLBEntry, addr_write))
));
tcg_out32 (s, ADD | RT (r0) | RA (r0) | RB (addr_reg));
#else
#if TARGET_LONG_BITS == 32
tcg_out_rld (s, RLDICL, addr_reg, addr_reg, 0, 32);
#endif
r1 = 3;
r0 = addr_reg;
rbase = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
#endif
#ifdef TARGET_WORDS_BIGENDIAN
bswap = 0;
#else
bswap = 1;
#endif
switch (opc) {
case 0:
tcg_out32 (s, STBX | SAB (data_reg, rbase, r0));
break;
case 1:
if (bswap)
tcg_out32 (s, STHBRX | SAB (data_reg, rbase, r0));
else
tcg_out32 (s, STHX | SAB (data_reg, rbase, r0));
break;
case 2:
if (bswap)
tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0));
else
tcg_out32 (s, STWX | SAB (data_reg, rbase, r0));
break;
case 3:
if (bswap) {
tcg_out32 (s, STWBRX | SAB (data_reg, rbase, r0));
tcg_out32 (s, ADDI | RT (r1) | RA (r0) | 4);
tcg_out_rld (s, RLDICL, 0, data_reg, 32, 0);
tcg_out32 (s, STWBRX | SAB (0, rbase, r1));
}
else tcg_out32 (s, STDX | SAB (data_reg, rbase, r0));
break;
}
#ifdef CONFIG_SOFTMMU
reloc_pc24 (label2_ptr, (tcg_target_long) s->code_ptr);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (TCGContext *VAR_0, const TCGArg *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
#ifdef CONFIG_SOFTMMU
int r2;
void *label1_ptr, *label2_ptr;
#endif
VAR_7 = *VAR_1++;
VAR_3 = *VAR_1++;
VAR_8 = *VAR_1;
#ifdef CONFIG_SOFTMMU
VAR_4 = 3;
VAR_5 = 4;
r2 = 0;
VAR_6 = 0;
tcg_out_tlb_read (VAR_0, VAR_4, VAR_5, r2, VAR_3, VAR_2,
offsetof (CPUState, tlb_table[VAR_8][0].addr_write));
tcg_out32 (VAR_0, CMP | BF (7) | RA (r2) | RB (VAR_5) | CMP_L);
label1_ptr = VAR_0->code_ptr;
#ifdef FAST_PATH
tcg_out32 (VAR_0, BC | BI (7, CR_EQ) | BO_COND_TRUE);
#endif
tcg_out_mov (VAR_0, 3, VAR_3);
tcg_out_rld (VAR_0, RLDICL, 4, VAR_7, 0, 64 - (1 << (3 + VAR_2)));
tcg_out_movi (VAR_0, TCG_TYPE_I64, 5, VAR_8);
tcg_out_call (VAR_0, (tcg_target_long) qemu_st_helpers[VAR_2], 1);
label2_ptr = VAR_0->code_ptr;
tcg_out32 (VAR_0, B);
#ifdef FAST_PATH
reloc_pc14 (label1_ptr, (tcg_target_long) VAR_0->code_ptr);
#endif
tcg_out32 (VAR_0, (LD_ADDEND
| RT (VAR_4)
| RA (VAR_4)
| (offsetof (CPUTLBEntry, addend)
- offsetof (CPUTLBEntry, addr_write))
));
tcg_out32 (VAR_0, ADD | RT (VAR_4) | RA (VAR_4) | RB (VAR_3));
#else
#if TARGET_LONG_BITS == 32
tcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_3, 0, 32);
#endif
VAR_5 = 3;
VAR_4 = VAR_3;
VAR_6 = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;
#endif
#ifdef TARGET_WORDS_BIGENDIAN
VAR_9 = 0;
#else
VAR_9 = 1;
#endif
switch (VAR_2) {
case 0:
tcg_out32 (VAR_0, STBX | SAB (VAR_7, VAR_6, VAR_4));
break;
case 1:
if (VAR_9)
tcg_out32 (VAR_0, STHBRX | SAB (VAR_7, VAR_6, VAR_4));
else
tcg_out32 (VAR_0, STHX | SAB (VAR_7, VAR_6, VAR_4));
break;
case 2:
if (VAR_9)
tcg_out32 (VAR_0, STWBRX | SAB (VAR_7, VAR_6, VAR_4));
else
tcg_out32 (VAR_0, STWX | SAB (VAR_7, VAR_6, VAR_4));
break;
case 3:
if (VAR_9) {
tcg_out32 (VAR_0, STWBRX | SAB (VAR_7, VAR_6, VAR_4));
tcg_out32 (VAR_0, ADDI | RT (VAR_5) | RA (VAR_4) | 4);
tcg_out_rld (VAR_0, RLDICL, 0, VAR_7, 32, 0);
tcg_out32 (VAR_0, STWBRX | SAB (0, VAR_6, VAR_5));
}
else tcg_out32 (VAR_0, STDX | SAB (VAR_7, VAR_6, VAR_4));
break;
}
#ifdef CONFIG_SOFTMMU
reloc_pc24 (label2_ptr, (tcg_target_long) VAR_0->code_ptr);
#endif
}
| [
"static void FUNC_0 (TCGContext *VAR_0, const TCGArg *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"#ifdef CONFIG_SOFTMMU\nint r2;",
"void *label1_ptr, *label2_ptr;",
"#endif\nVAR_7 = *VAR_1++;",
"VAR_3 = *VAR_1++;",
"VAR_8 = *VAR_1;",
"#ifdef CONFIG_SOFTMMU\nVAR_4 = 3;",
"VAR_5 = 4;",
"r2 = 0;",
"VAR_6 = 0;",
"tcg_out_tlb_read (VAR_0, VAR_4, VAR_5, r2, VAR_3, VAR_2,\noffsetof (CPUState, tlb_table[VAR_8][0].addr_write));",
"tcg_out32 (VAR_0, CMP | BF (7) | RA (r2) | RB (VAR_5) | CMP_L);",
"label1_ptr = VAR_0->code_ptr;",
"#ifdef FAST_PATH\ntcg_out32 (VAR_0, BC | BI (7, CR_EQ) | BO_COND_TRUE);",
"#endif\ntcg_out_mov (VAR_0, 3, VAR_3);",
"tcg_out_rld (VAR_0, RLDICL, 4, VAR_7, 0, 64 - (1 << (3 + VAR_2)));",
"tcg_out_movi (VAR_0, TCG_TYPE_I64, 5, VAR_8);",
"tcg_out_call (VAR_0, (tcg_target_long) qemu_st_helpers[VAR_2], 1);",
"label2_ptr = VAR_0->code_ptr;",
"tcg_out32 (VAR_0, B);",
"#ifdef FAST_PATH\nreloc_pc14 (label1_ptr, (tcg_target_long) VAR_0->code_ptr);",
"#endif\ntcg_out32 (VAR_0, (LD_ADDEND\n| RT (VAR_4)\n| RA (VAR_4)\n| (offsetof (CPUTLBEntry, addend)\n- offsetof (CPUTLBEntry, addr_write))\n));",
"tcg_out32 (VAR_0, ADD | RT (VAR_4) | RA (VAR_4) | RB (VAR_3));",
"#else\n#if TARGET_LONG_BITS == 32\ntcg_out_rld (VAR_0, RLDICL, VAR_3, VAR_3, 0, 32);",
"#endif\nVAR_5 = 3;",
"VAR_4 = VAR_3;",
"VAR_6 = GUEST_BASE ? TCG_GUEST_BASE_REG : 0;",
"#endif\n#ifdef TARGET_WORDS_BIGENDIAN\nVAR_9 = 0;",
"#else\nVAR_9 = 1;",
"#endif\nswitch (VAR_2) {",
"case 0:\ntcg_out32 (VAR_0, STBX | SAB (VAR_7, VAR_6, VAR_4));",
"break;",
"case 1:\nif (VAR_9)\ntcg_out32 (VAR_0, STHBRX | SAB (VAR_7, VAR_6, VAR_4));",
"else\ntcg_out32 (VAR_0, STHX | SAB (VAR_7, VAR_6, VAR_4));",
"break;",
"case 2:\nif (VAR_9)\ntcg_out32 (VAR_0, STWBRX | SAB (VAR_7, VAR_6, VAR_4));",
"else\ntcg_out32 (VAR_0, STWX | SAB (VAR_7, VAR_6, VAR_4));",
"break;",
"case 3:\nif (VAR_9) {",
"tcg_out32 (VAR_0, STWBRX | SAB (VAR_7, VAR_6, VAR_4));",
"tcg_out32 (VAR_0, ADDI | RT (VAR_5) | RA (VAR_4) | 4);",
"tcg_out_rld (VAR_0, RLDICL, 0, VAR_7, 32, 0);",
"tcg_out32 (VAR_0, STWBRX | SAB (0, VAR_6, VAR_5));",
"}",
"else tcg_out32 (VAR_0, STDX | SAB (VAR_7, VAR_6, VAR_4));",
"break;",
"}",
"#ifdef CONFIG_SOFTMMU\nreloc_pc24 (label2_ptr, (tcg_target_long) VAR_0->code_ptr);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13,
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
47
],
[
49,
51
],
[
53,
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
73
],
[
79,
81
],
[
83,
87,
89,
91,
93,
95,
97
],
[
101
],
[
107,
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
121,
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,
191
],
[
193,
195
]
] |
2,473 | int omap_validate_imif_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= OMAP_IMIF_BASE && addr < OMAP_IMIF_BASE + s->sram_size;
}
| false | qemu | b854bc196f5c4b4e3299c0b0ee63cf828ece9e77 | int omap_validate_imif_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return addr >= OMAP_IMIF_BASE && addr < OMAP_IMIF_BASE + s->sram_size;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(struct omap_mpu_state_s *VAR_0,
target_phys_addr_t VAR_1)
{
return VAR_1 >= OMAP_IMIF_BASE && VAR_1 < OMAP_IMIF_BASE + VAR_0->sram_size;
}
| [
"int FUNC_0(struct omap_mpu_state_s *VAR_0,\ntarget_phys_addr_t VAR_1)\n{",
"return VAR_1 >= OMAP_IMIF_BASE && VAR_1 < OMAP_IMIF_BASE + VAR_0->sram_size;",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
2,474 | static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
CPUState *cs)
{
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
sPAPRCapabilities caps;
caps = smc->default_caps;
/* TODO: clamp according to cpu model */
return caps;
}
| false | qemu | ee76a09fc72cfbfab2bb5529320ef7e460adffd8 | static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
CPUState *cs)
{
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
sPAPRCapabilities caps;
caps = smc->default_caps;
return caps;
}
| {
"code": [],
"line_no": []
} | static sPAPRCapabilities FUNC_0(sPAPRMachineState *spapr,
CPUState *cs)
{
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
sPAPRCapabilities caps;
caps = smc->default_caps;
return caps;
}
| [
"static sPAPRCapabilities FUNC_0(sPAPRMachineState *spapr,\nCPUState *cs)\n{",
"sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);",
"sPAPRCapabilities caps;",
"caps = smc->default_caps;",
"return caps;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
21
],
[
23
]
] |
2,475 | int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
SocketAddressLegacy *addr,
Error **errp)
{
int fd;
trace_qio_channel_socket_listen_sync(ioc, addr);
fd = socket_listen(addr, errp);
if (fd < 0) {
trace_qio_channel_socket_listen_fail(ioc);
return -1;
}
trace_qio_channel_socket_listen_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN);
return 0;
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
SocketAddressLegacy *addr,
Error **errp)
{
int fd;
trace_qio_channel_socket_listen_sync(ioc, addr);
fd = socket_listen(addr, errp);
if (fd < 0) {
trace_qio_channel_socket_listen_fail(ioc);
return -1;
}
trace_qio_channel_socket_listen_complete(ioc, fd);
if (qio_channel_socket_set_fd(ioc, fd, errp) < 0) {
close(fd);
return -1;
}
qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_LISTEN);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QIOChannelSocket *VAR_0,
SocketAddressLegacy *VAR_1,
Error **VAR_2)
{
int VAR_3;
trace_qio_channel_socket_listen_sync(VAR_0, VAR_1);
VAR_3 = socket_listen(VAR_1, VAR_2);
if (VAR_3 < 0) {
trace_qio_channel_socket_listen_fail(VAR_0);
return -1;
}
trace_qio_channel_socket_listen_complete(VAR_0, VAR_3);
if (qio_channel_socket_set_fd(VAR_0, VAR_3, VAR_2) < 0) {
close(VAR_3);
return -1;
}
qio_channel_set_feature(QIO_CHANNEL(VAR_0), QIO_CHANNEL_FEATURE_LISTEN);
return 0;
}
| [
"int FUNC_0(QIOChannelSocket *VAR_0,\nSocketAddressLegacy *VAR_1,\nError **VAR_2)\n{",
"int VAR_3;",
"trace_qio_channel_socket_listen_sync(VAR_0, VAR_1);",
"VAR_3 = socket_listen(VAR_1, VAR_2);",
"if (VAR_3 < 0) {",
"trace_qio_channel_socket_listen_fail(VAR_0);",
"return -1;",
"}",
"trace_qio_channel_socket_listen_complete(VAR_0, VAR_3);",
"if (qio_channel_socket_set_fd(VAR_0, VAR_3, VAR_2) < 0) {",
"close(VAR_3);",
"return -1;",
"}",
"qio_channel_set_feature(QIO_CHANNEL(VAR_0), QIO_CHANNEL_FEATURE_LISTEN);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
2,476 | uint64_t ptimer_get_count(ptimer_state *s)
{
int64_t now;
uint64_t counter;
if (s->enabled) {
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
/* Figure out the current counter value. */
if (now - s->next_event > 0
|| s->period == 0) {
/* Prevent timer underflowing if it should already have
triggered. */
counter = 0;
} else {
uint64_t rem;
uint64_t div;
int clz1, clz2;
int shift;
/* We need to divide time by period, where time is stored in
rem (64-bit integer) and period is stored in period/period_frac
(64.32 fixed point).
Doing full precision division is hard, so scale values and
do a 64-bit division. The result should be rounded down,
so that the rounding error never causes the timer to go
backwards.
*/
rem = s->next_event - now;
div = s->period;
clz1 = clz64(rem);
clz2 = clz64(div);
shift = clz1 < clz2 ? clz1 : clz2;
rem <<= shift;
div <<= shift;
if (shift >= 32) {
div |= ((uint64_t)s->period_frac << (shift - 32));
} else {
if (shift != 0)
div |= (s->period_frac >> (32 - shift));
/* Look at remaining bits of period_frac and round div up if
necessary. */
if ((uint32_t)(s->period_frac << shift))
div += 1;
}
counter = rem / div;
}
} else {
counter = s->delta;
}
return counter;
}
| false | qemu | e91171e30235ae99ab8060988aa3c9536692bba8 | uint64_t ptimer_get_count(ptimer_state *s)
{
int64_t now;
uint64_t counter;
if (s->enabled) {
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (now - s->next_event > 0
|| s->period == 0) {
counter = 0;
} else {
uint64_t rem;
uint64_t div;
int clz1, clz2;
int shift;
rem = s->next_event - now;
div = s->period;
clz1 = clz64(rem);
clz2 = clz64(div);
shift = clz1 < clz2 ? clz1 : clz2;
rem <<= shift;
div <<= shift;
if (shift >= 32) {
div |= ((uint64_t)s->period_frac << (shift - 32));
} else {
if (shift != 0)
div |= (s->period_frac >> (32 - shift));
if ((uint32_t)(s->period_frac << shift))
div += 1;
}
counter = rem / div;
}
} else {
counter = s->delta;
}
return counter;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(ptimer_state *s)
{
int64_t now;
uint64_t counter;
if (s->enabled) {
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (now - s->next_event > 0
|| s->period == 0) {
counter = 0;
} else {
uint64_t rem;
uint64_t div;
int VAR_0, VAR_1;
int VAR_2;
rem = s->next_event - now;
div = s->period;
VAR_0 = clz64(rem);
VAR_1 = clz64(div);
VAR_2 = VAR_0 < VAR_1 ? VAR_0 : VAR_1;
rem <<= VAR_2;
div <<= VAR_2;
if (VAR_2 >= 32) {
div |= ((uint64_t)s->period_frac << (VAR_2 - 32));
} else {
if (VAR_2 != 0)
div |= (s->period_frac >> (32 - VAR_2));
if ((uint32_t)(s->period_frac << VAR_2))
div += 1;
}
counter = rem / div;
}
} else {
counter = s->delta;
}
return counter;
}
| [
"uint64_t FUNC_0(ptimer_state *s)\n{",
"int64_t now;",
"uint64_t counter;",
"if (s->enabled) {",
"now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);",
"if (now - s->next_event > 0\n|| s->period == 0) {",
"counter = 0;",
"} else {",
"uint64_t rem;",
"uint64_t div;",
"int VAR_0, VAR_1;",
"int VAR_2;",
"rem = s->next_event - now;",
"div = s->period;",
"VAR_0 = clz64(rem);",
"VAR_1 = clz64(div);",
"VAR_2 = VAR_0 < VAR_1 ? VAR_0 : VAR_1;",
"rem <<= VAR_2;",
"div <<= VAR_2;",
"if (VAR_2 >= 32) {",
"div |= ((uint64_t)s->period_frac << (VAR_2 - 32));",
"} else {",
"if (VAR_2 != 0)\ndiv |= (s->period_frac >> (32 - VAR_2));",
"if ((uint32_t)(s->period_frac << VAR_2))\ndiv += 1;",
"}",
"counter = rem / div;",
"}",
"} else {",
"counter = s->delta;",
"}",
"return counter;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
2,477 | int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
int is_write1, int is_user, int is_softmmu)
{
uint64_t ptep, pte;
uint32_t pdpe_addr, pde_addr, pte_addr;
int error_code, is_dirty, prot, page_size, ret, is_write;
unsigned long paddr, page_offset;
target_ulong vaddr, virt_addr;
#if defined(DEBUG_MMU)
printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
addr, is_write1, is_user, env->eip);
#endif
is_write = is_write1 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
virt_addr = addr & TARGET_PAGE_MASK;
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
page_size = 4096;
goto do_mapping;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
/* XXX: we only use 32 bit physical addresses */
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint32_t pml4e_addr;
uint64_t pml4e;
int32_t sext;
/* test virtual address sign extension */
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1) {
error_code = 0;
goto do_fault;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(pdpe_addr, pdpe);
}
} else
#endif
{
/* XXX: load them when cr3 is loaded ? */
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 30) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
/* 2 MB page */
page_size = 2048 * 1024;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
/* align to page_size */
pte = pde & ((PHYS_ADDR_MASK & ~(page_size - 1)) | 0xfff);
virt_addr = addr & ~(page_size - 1);
} else {
/* 4 KB page */
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & PHYS_ADDR_MASK) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
/* combine pde and pte nx, user and rw protections */
ptep &= pte ^ PG_NX_MASK;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
pte = pte & (PHYS_ADDR_MASK | 0xfff);
}
} else {
uint32_t pde;
/* page directory entry */
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) &
env->a20_mask;
pde = ldl_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
/* if PSE bit is set, then we use a 4MB page */
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
page_size = 4096 * 1024;
if (is_user) {
if (!(pde & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ~( (page_size - 1) & ~0xfff); /* align to page_size */
ptep = pte;
virt_addr = addr & ~(page_size - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
/* page directory entry */
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
/* combine pde and pte user and rw protections */
ptep = pte & pde;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
}
}
/* the page can be put in the TLB */
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
prot |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
/* only set write access if already dirty... otherwise wait
for dirty access */
if (is_user) {
if (ptep & PG_RW_MASK)
prot |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
prot |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
/* Even if 4MB pages, we map only one 4KB page in the cache to
avoid filling it too fast */
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
vaddr = virt_addr + page_offset;
ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
return ret;
do_fault_protect:
error_code = PG_ERROR_P_MASK;
do_fault:
env->cr[2] = addr;
error_code |= (is_write << PG_ERROR_W_BIT);
if (is_user)
error_code |= PG_ERROR_U_MASK;
if (is_write1 == 2 &&
(env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK))
error_code |= PG_ERROR_I_D_MASK;
env->error_code = error_code;
return 1;
}
| false | qemu | 54ca9095f046dfa03c3d093cc55f6d76b61864e1 | int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
int is_write1, int is_user, int is_softmmu)
{
uint64_t ptep, pte;
uint32_t pdpe_addr, pde_addr, pte_addr;
int error_code, is_dirty, prot, page_size, ret, is_write;
unsigned long paddr, page_offset;
target_ulong vaddr, virt_addr;
#if defined(DEBUG_MMU)
printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
addr, is_write1, is_user, env->eip);
#endif
is_write = is_write1 & 1;
if (!(env->cr[0] & CR0_PG_MASK)) {
pte = addr;
virt_addr = addr & TARGET_PAGE_MASK;
prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
page_size = 4096;
goto do_mapping;
}
if (env->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
#ifdef TARGET_X86_64
if (env->hflags & HF_LMA_MASK) {
uint32_t pml4e_addr;
uint64_t pml4e;
int32_t sext;
sext = (int64_t)addr >> 47;
if (sext != 0 && sext != -1) {
error_code = 0;
goto do_fault;
}
pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) &
env->a20_mask;
pml4e = ldq_phys(pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((addr >> 30) & 0x1ff) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(pdpe_addr, pdpe);
}
} else
#endif
{
pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 30) << 3)) &
env->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((addr >> 21) & 0x1ff) << 3)) &
env->a20_mask;
pde = ldq_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
page_size = 2048 * 1024;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ((PHYS_ADDR_MASK & ~(page_size - 1)) | 0xfff);
virt_addr = addr & ~(page_size - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & PHYS_ADDR_MASK) + (((addr >> 12) & 0x1ff) << 3)) &
env->a20_mask;
pte = ldq_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {
error_code = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pte ^ PG_NX_MASK;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && is_write1 == 2)
goto do_fault_protect;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
pte = pte & (PHYS_ADDR_MASK | 0xfff);
}
} else {
uint32_t pde;
pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & ~3)) &
env->a20_mask;
pde = ldl_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
page_size = 4096 * 1024;
if (is_user) {
if (!(pde & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(pde & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
pde |= PG_ACCESSED_MASK;
if (is_dirty)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ~( (page_size - 1) & ~0xfff);
ptep = pte;
virt_addr = addr & ~(page_size - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) &
env->a20_mask;
pte = ldl_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
error_code = 0;
goto do_fault;
}
ptep = pte & pde;
if (is_user) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((env->cr[0] & CR0_WP_MASK) &&
is_write && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
is_dirty = is_write && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || is_dirty) {
pte |= PG_ACCESSED_MASK;
if (is_dirty)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
page_size = 4096;
virt_addr = addr & ~0xfff;
}
}
prot = PAGE_READ;
if (!(ptep & PG_NX_MASK))
prot |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
if (is_user) {
if (ptep & PG_RW_MASK)
prot |= PAGE_WRITE;
} else {
if (!(env->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
prot |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & env->a20_mask;
page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1);
paddr = (pte & TARGET_PAGE_MASK) + page_offset;
vaddr = virt_addr + page_offset;
ret = tlb_set_page_exec(env, vaddr, paddr, prot, is_user, is_softmmu);
return ret;
do_fault_protect:
error_code = PG_ERROR_P_MASK;
do_fault:
env->cr[2] = addr;
error_code |= (is_write << PG_ERROR_W_BIT);
if (is_user)
error_code |= PG_ERROR_U_MASK;
if (is_write1 == 2 &&
(env->efer & MSR_EFER_NXE) &&
(env->cr[4] & CR4_PAE_MASK))
error_code |= PG_ERROR_I_D_MASK;
env->error_code = error_code;
return 1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUX86State *VAR_0, target_ulong VAR_1,
int VAR_2, int VAR_3, int VAR_4)
{
uint64_t ptep, pte;
uint32_t pdpe_addr, pde_addr, pte_addr;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
unsigned long VAR_11, VAR_12;
target_ulong vaddr, virt_addr;
#if defined(DEBUG_MMU)
printf("MMU fault: VAR_1=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n",
VAR_1, VAR_2, VAR_3, VAR_0->eip);
#endif
VAR_10 = VAR_2 & 1;
if (!(VAR_0->cr[0] & CR0_PG_MASK)) {
pte = VAR_1;
virt_addr = VAR_1 & TARGET_PAGE_MASK;
VAR_7 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
VAR_8 = 4096;
goto do_mapping;
}
if (VAR_0->cr[4] & CR4_PAE_MASK) {
uint64_t pde, pdpe;
#ifdef TARGET_X86_64
if (VAR_0->hflags & HF_LMA_MASK) {
uint32_t pml4e_addr;
uint64_t pml4e;
int32_t sext;
sext = (int64_t)VAR_1 >> 47;
if (sext != 0 && sext != -1) {
VAR_5 = 0;
goto do_fault;
}
pml4e_addr = ((VAR_0->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) &
VAR_0->a20_mask;
pml4e = ldq_phys(pml4e_addr);
if (!(pml4e & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
if (!(VAR_0->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {
VAR_5 = PG_ERROR_RSVD_MASK;
goto do_fault;
}
if (!(pml4e & PG_ACCESSED_MASK)) {
pml4e |= PG_ACCESSED_MASK;
stl_phys_notdirty(pml4e_addr, pml4e);
}
ptep = pml4e ^ PG_NX_MASK;
pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) &
VAR_0->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
if (!(VAR_0->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {
VAR_5 = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pdpe ^ PG_NX_MASK;
if (!(pdpe & PG_ACCESSED_MASK)) {
pdpe |= PG_ACCESSED_MASK;
stl_phys_notdirty(pdpe_addr, pdpe);
}
} else
#endif
{
pdpe_addr = ((VAR_0->cr[3] & ~0x1f) + ((VAR_1 >> 30) << 3)) &
VAR_0->a20_mask;
pdpe = ldq_phys(pdpe_addr);
if (!(pdpe & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;
}
pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) &
VAR_0->a20_mask;
pde = ldq_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
if (!(VAR_0->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {
VAR_5 = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pde ^ PG_NX_MASK;
if (pde & PG_PSE_MASK) {
VAR_8 = 2048 * 1024;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && VAR_2 == 2)
goto do_fault_protect;
if (VAR_3) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((VAR_0->cr[0] & CR0_WP_MASK) &&
VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
VAR_6 = VAR_10 && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || VAR_6) {
pde |= PG_ACCESSED_MASK;
if (VAR_6)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ((PHYS_ADDR_MASK & ~(VAR_8 - 1)) | 0xfff);
virt_addr = VAR_1 & ~(VAR_8 - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & PHYS_ADDR_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) &
VAR_0->a20_mask;
pte = ldq_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
if (!(VAR_0->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {
VAR_5 = PG_ERROR_RSVD_MASK;
goto do_fault;
}
ptep &= pte ^ PG_NX_MASK;
ptep ^= PG_NX_MASK;
if ((ptep & PG_NX_MASK) && VAR_2 == 2)
goto do_fault_protect;
if (VAR_3) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((VAR_0->cr[0] & CR0_WP_MASK) &&
VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
VAR_6 = VAR_10 && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || VAR_6) {
pte |= PG_ACCESSED_MASK;
if (VAR_6)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
VAR_8 = 4096;
virt_addr = VAR_1 & ~0xfff;
pte = pte & (PHYS_ADDR_MASK | 0xfff);
}
} else {
uint32_t pde;
pde_addr = ((VAR_0->cr[3] & ~0xfff) + ((VAR_1 >> 20) & ~3)) &
VAR_0->a20_mask;
pde = ldl_phys(pde_addr);
if (!(pde & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
if ((pde & PG_PSE_MASK) && (VAR_0->cr[4] & CR4_PSE_MASK)) {
VAR_8 = 4096 * 1024;
if (VAR_3) {
if (!(pde & PG_USER_MASK))
goto do_fault_protect;
if (VAR_10 && !(pde & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((VAR_0->cr[0] & CR0_WP_MASK) &&
VAR_10 && !(pde & PG_RW_MASK))
goto do_fault_protect;
}
VAR_6 = VAR_10 && !(pde & PG_DIRTY_MASK);
if (!(pde & PG_ACCESSED_MASK) || VAR_6) {
pde |= PG_ACCESSED_MASK;
if (VAR_6)
pde |= PG_DIRTY_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte = pde & ~( (VAR_8 - 1) & ~0xfff);
ptep = pte;
virt_addr = VAR_1 & ~(VAR_8 - 1);
} else {
if (!(pde & PG_ACCESSED_MASK)) {
pde |= PG_ACCESSED_MASK;
stl_phys_notdirty(pde_addr, pde);
}
pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) &
VAR_0->a20_mask;
pte = ldl_phys(pte_addr);
if (!(pte & PG_PRESENT_MASK)) {
VAR_5 = 0;
goto do_fault;
}
ptep = pte & pde;
if (VAR_3) {
if (!(ptep & PG_USER_MASK))
goto do_fault_protect;
if (VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
} else {
if ((VAR_0->cr[0] & CR0_WP_MASK) &&
VAR_10 && !(ptep & PG_RW_MASK))
goto do_fault_protect;
}
VAR_6 = VAR_10 && !(pte & PG_DIRTY_MASK);
if (!(pte & PG_ACCESSED_MASK) || VAR_6) {
pte |= PG_ACCESSED_MASK;
if (VAR_6)
pte |= PG_DIRTY_MASK;
stl_phys_notdirty(pte_addr, pte);
}
VAR_8 = 4096;
virt_addr = VAR_1 & ~0xfff;
}
}
VAR_7 = PAGE_READ;
if (!(ptep & PG_NX_MASK))
VAR_7 |= PAGE_EXEC;
if (pte & PG_DIRTY_MASK) {
if (VAR_3) {
if (ptep & PG_RW_MASK)
VAR_7 |= PAGE_WRITE;
} else {
if (!(VAR_0->cr[0] & CR0_WP_MASK) ||
(ptep & PG_RW_MASK))
VAR_7 |= PAGE_WRITE;
}
}
do_mapping:
pte = pte & VAR_0->a20_mask;
VAR_12 = (VAR_1 & TARGET_PAGE_MASK) & (VAR_8 - 1);
VAR_11 = (pte & TARGET_PAGE_MASK) + VAR_12;
vaddr = virt_addr + VAR_12;
VAR_9 = tlb_set_page_exec(VAR_0, vaddr, VAR_11, VAR_7, VAR_3, VAR_4);
return VAR_9;
do_fault_protect:
VAR_5 = PG_ERROR_P_MASK;
do_fault:
VAR_0->cr[2] = VAR_1;
VAR_5 |= (VAR_10 << PG_ERROR_W_BIT);
if (VAR_3)
VAR_5 |= PG_ERROR_U_MASK;
if (VAR_2 == 2 &&
(VAR_0->efer & MSR_EFER_NXE) &&
(VAR_0->cr[4] & CR4_PAE_MASK))
VAR_5 |= PG_ERROR_I_D_MASK;
VAR_0->VAR_5 = VAR_5;
return 1;
}
| [
"int FUNC_0(CPUX86State *VAR_0, target_ulong VAR_1,\nint VAR_2, int VAR_3, int VAR_4)\n{",
"uint64_t ptep, pte;",
"uint32_t pdpe_addr, pde_addr, pte_addr;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"unsigned long VAR_11, VAR_12;",
"target_ulong vaddr, virt_addr;",
"#if defined(DEBUG_MMU)\nprintf(\"MMU fault: VAR_1=\" TARGET_FMT_lx \" w=%d u=%d eip=\" TARGET_FMT_lx \"\\n\",\nVAR_1, VAR_2, VAR_3, VAR_0->eip);",
"#endif\nVAR_10 = VAR_2 & 1;",
"if (!(VAR_0->cr[0] & CR0_PG_MASK)) {",
"pte = VAR_1;",
"virt_addr = VAR_1 & TARGET_PAGE_MASK;",
"VAR_7 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;",
"VAR_8 = 4096;",
"goto do_mapping;",
"}",
"if (VAR_0->cr[4] & CR4_PAE_MASK) {",
"uint64_t pde, pdpe;",
"#ifdef TARGET_X86_64\nif (VAR_0->hflags & HF_LMA_MASK) {",
"uint32_t pml4e_addr;",
"uint64_t pml4e;",
"int32_t sext;",
"sext = (int64_t)VAR_1 >> 47;",
"if (sext != 0 && sext != -1) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"pml4e_addr = ((VAR_0->cr[3] & ~0xfff) + (((VAR_1 >> 39) & 0x1ff) << 3)) &\nVAR_0->a20_mask;",
"pml4e = ldq_phys(pml4e_addr);",
"if (!(pml4e & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"if (!(VAR_0->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) {",
"VAR_5 = PG_ERROR_RSVD_MASK;",
"goto do_fault;",
"}",
"if (!(pml4e & PG_ACCESSED_MASK)) {",
"pml4e |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(pml4e_addr, pml4e);",
"}",
"ptep = pml4e ^ PG_NX_MASK;",
"pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((VAR_1 >> 30) & 0x1ff) << 3)) &\nVAR_0->a20_mask;",
"pdpe = ldq_phys(pdpe_addr);",
"if (!(pdpe & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"if (!(VAR_0->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) {",
"VAR_5 = PG_ERROR_RSVD_MASK;",
"goto do_fault;",
"}",
"ptep &= pdpe ^ PG_NX_MASK;",
"if (!(pdpe & PG_ACCESSED_MASK)) {",
"pdpe |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(pdpe_addr, pdpe);",
"}",
"} else",
"#endif\n{",
"pdpe_addr = ((VAR_0->cr[3] & ~0x1f) + ((VAR_1 >> 30) << 3)) &\nVAR_0->a20_mask;",
"pdpe = ldq_phys(pdpe_addr);",
"if (!(pdpe & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK;",
"}",
"pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((VAR_1 >> 21) & 0x1ff) << 3)) &\nVAR_0->a20_mask;",
"pde = ldq_phys(pde_addr);",
"if (!(pde & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"if (!(VAR_0->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) {",
"VAR_5 = PG_ERROR_RSVD_MASK;",
"goto do_fault;",
"}",
"ptep &= pde ^ PG_NX_MASK;",
"if (pde & PG_PSE_MASK) {",
"VAR_8 = 2048 * 1024;",
"ptep ^= PG_NX_MASK;",
"if ((ptep & PG_NX_MASK) && VAR_2 == 2)\ngoto do_fault_protect;",
"if (VAR_3) {",
"if (!(ptep & PG_USER_MASK))\ngoto do_fault_protect;",
"if (VAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"} else {",
"if ((VAR_0->cr[0] & CR0_WP_MASK) &&\nVAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"}",
"VAR_6 = VAR_10 && !(pde & PG_DIRTY_MASK);",
"if (!(pde & PG_ACCESSED_MASK) || VAR_6) {",
"pde |= PG_ACCESSED_MASK;",
"if (VAR_6)\npde |= PG_DIRTY_MASK;",
"stl_phys_notdirty(pde_addr, pde);",
"}",
"pte = pde & ((PHYS_ADDR_MASK & ~(VAR_8 - 1)) | 0xfff);",
"virt_addr = VAR_1 & ~(VAR_8 - 1);",
"} else {",
"if (!(pde & PG_ACCESSED_MASK)) {",
"pde |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(pde_addr, pde);",
"}",
"pte_addr = ((pde & PHYS_ADDR_MASK) + (((VAR_1 >> 12) & 0x1ff) << 3)) &\nVAR_0->a20_mask;",
"pte = ldq_phys(pte_addr);",
"if (!(pte & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"if (!(VAR_0->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) {",
"VAR_5 = PG_ERROR_RSVD_MASK;",
"goto do_fault;",
"}",
"ptep &= pte ^ PG_NX_MASK;",
"ptep ^= PG_NX_MASK;",
"if ((ptep & PG_NX_MASK) && VAR_2 == 2)\ngoto do_fault_protect;",
"if (VAR_3) {",
"if (!(ptep & PG_USER_MASK))\ngoto do_fault_protect;",
"if (VAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"} else {",
"if ((VAR_0->cr[0] & CR0_WP_MASK) &&\nVAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"}",
"VAR_6 = VAR_10 && !(pte & PG_DIRTY_MASK);",
"if (!(pte & PG_ACCESSED_MASK) || VAR_6) {",
"pte |= PG_ACCESSED_MASK;",
"if (VAR_6)\npte |= PG_DIRTY_MASK;",
"stl_phys_notdirty(pte_addr, pte);",
"}",
"VAR_8 = 4096;",
"virt_addr = VAR_1 & ~0xfff;",
"pte = pte & (PHYS_ADDR_MASK | 0xfff);",
"}",
"} else {",
"uint32_t pde;",
"pde_addr = ((VAR_0->cr[3] & ~0xfff) + ((VAR_1 >> 20) & ~3)) &\nVAR_0->a20_mask;",
"pde = ldl_phys(pde_addr);",
"if (!(pde & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"if ((pde & PG_PSE_MASK) && (VAR_0->cr[4] & CR4_PSE_MASK)) {",
"VAR_8 = 4096 * 1024;",
"if (VAR_3) {",
"if (!(pde & PG_USER_MASK))\ngoto do_fault_protect;",
"if (VAR_10 && !(pde & PG_RW_MASK))\ngoto do_fault_protect;",
"} else {",
"if ((VAR_0->cr[0] & CR0_WP_MASK) &&\nVAR_10 && !(pde & PG_RW_MASK))\ngoto do_fault_protect;",
"}",
"VAR_6 = VAR_10 && !(pde & PG_DIRTY_MASK);",
"if (!(pde & PG_ACCESSED_MASK) || VAR_6) {",
"pde |= PG_ACCESSED_MASK;",
"if (VAR_6)\npde |= PG_DIRTY_MASK;",
"stl_phys_notdirty(pde_addr, pde);",
"}",
"pte = pde & ~( (VAR_8 - 1) & ~0xfff);",
"ptep = pte;",
"virt_addr = VAR_1 & ~(VAR_8 - 1);",
"} else {",
"if (!(pde & PG_ACCESSED_MASK)) {",
"pde |= PG_ACCESSED_MASK;",
"stl_phys_notdirty(pde_addr, pde);",
"}",
"pte_addr = ((pde & ~0xfff) + ((VAR_1 >> 10) & 0xffc)) &\nVAR_0->a20_mask;",
"pte = ldl_phys(pte_addr);",
"if (!(pte & PG_PRESENT_MASK)) {",
"VAR_5 = 0;",
"goto do_fault;",
"}",
"ptep = pte & pde;",
"if (VAR_3) {",
"if (!(ptep & PG_USER_MASK))\ngoto do_fault_protect;",
"if (VAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"} else {",
"if ((VAR_0->cr[0] & CR0_WP_MASK) &&\nVAR_10 && !(ptep & PG_RW_MASK))\ngoto do_fault_protect;",
"}",
"VAR_6 = VAR_10 && !(pte & PG_DIRTY_MASK);",
"if (!(pte & PG_ACCESSED_MASK) || VAR_6) {",
"pte |= PG_ACCESSED_MASK;",
"if (VAR_6)\npte |= PG_DIRTY_MASK;",
"stl_phys_notdirty(pte_addr, pte);",
"}",
"VAR_8 = 4096;",
"virt_addr = VAR_1 & ~0xfff;",
"}",
"}",
"VAR_7 = PAGE_READ;",
"if (!(ptep & PG_NX_MASK))\nVAR_7 |= PAGE_EXEC;",
"if (pte & PG_DIRTY_MASK) {",
"if (VAR_3) {",
"if (ptep & PG_RW_MASK)\nVAR_7 |= PAGE_WRITE;",
"} else {",
"if (!(VAR_0->cr[0] & CR0_WP_MASK) ||\n(ptep & PG_RW_MASK))\nVAR_7 |= PAGE_WRITE;",
"}",
"}",
"do_mapping:\npte = pte & VAR_0->a20_mask;",
"VAR_12 = (VAR_1 & TARGET_PAGE_MASK) & (VAR_8 - 1);",
"VAR_11 = (pte & TARGET_PAGE_MASK) + VAR_12;",
"vaddr = virt_addr + VAR_12;",
"VAR_9 = tlb_set_page_exec(VAR_0, vaddr, VAR_11, VAR_7, VAR_3, VAR_4);",
"return VAR_9;",
"do_fault_protect:\nVAR_5 = PG_ERROR_P_MASK;",
"do_fault:\nVAR_0->cr[2] = VAR_1;",
"VAR_5 |= (VAR_10 << PG_ERROR_W_BIT);",
"if (VAR_3)\nVAR_5 |= PG_ERROR_U_MASK;",
"if (VAR_2 == 2 &&\n(VAR_0->efer & MSR_EFER_NXE) &&\n(VAR_0->cr[4] & CR4_PAE_MASK))\nVAR_5 |= PG_ERROR_I_D_MASK;",
"VAR_0->VAR_5 = VAR_5;",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
49
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
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
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211,
213
],
[
215,
217
],
[
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261,
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295,
297
],
[
299,
301
],
[
303
],
[
305,
307,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
343,
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
365,
367
],
[
369,
371
],
[
373
],
[
375,
377,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389,
391
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
435
],
[
437
],
[
439,
441
],
[
443,
445
],
[
447
],
[
449,
451,
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
481
],
[
483,
485
],
[
487
],
[
493
],
[
495,
497
],
[
499
],
[
501,
503,
505
],
[
507
],
[
509
],
[
511,
513
],
[
521
],
[
523
],
[
525
],
[
529
],
[
531
],
[
533,
535
],
[
537,
539
],
[
541
],
[
543,
545
],
[
547,
549,
551,
553
],
[
555
],
[
557
],
[
559
]
] |
2,478 | static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)
{
unsigned char response[VNC_AUTH_CHALLENGE_SIZE];
int i, j, pwlen;
unsigned char key[8];
time_t now = time(NULL);
if (!vs->vd->password || !vs->vd->password[0]) {
VNC_DEBUG("No password configured on server");
goto reject;
}
if (vs->vd->expires < now) {
VNC_DEBUG("Password is expired");
goto reject;
}
memcpy(response, vs->challenge, VNC_AUTH_CHALLENGE_SIZE);
/* Calculate the expected challenge response */
pwlen = strlen(vs->vd->password);
for (i=0; i<sizeof(key); i++)
key[i] = i<pwlen ? vs->vd->password[i] : 0;
deskey(key, EN0);
for (j = 0; j < VNC_AUTH_CHALLENGE_SIZE; j += 8)
des(response+j, response+j);
/* Compare expected vs actual challenge response */
if (memcmp(response, data, VNC_AUTH_CHALLENGE_SIZE) != 0) {
VNC_DEBUG("Client challenge reponse did not match\n");
goto reject;
} else {
VNC_DEBUG("Accepting VNC challenge response\n");
vnc_write_u32(vs, 0); /* Accept auth */
vnc_flush(vs);
start_client_init(vs);
}
return 0;
reject:
vnc_write_u32(vs, 1); /* Reject auth */
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_flush(vs);
vnc_client_error(vs);
return 0;
}
| false | qemu | 1cd20f8bf0ecb9d1d1bd5e2ffab3b88835380c9b | static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)
{
unsigned char response[VNC_AUTH_CHALLENGE_SIZE];
int i, j, pwlen;
unsigned char key[8];
time_t now = time(NULL);
if (!vs->vd->password || !vs->vd->password[0]) {
VNC_DEBUG("No password configured on server");
goto reject;
}
if (vs->vd->expires < now) {
VNC_DEBUG("Password is expired");
goto reject;
}
memcpy(response, vs->challenge, VNC_AUTH_CHALLENGE_SIZE);
pwlen = strlen(vs->vd->password);
for (i=0; i<sizeof(key); i++)
key[i] = i<pwlen ? vs->vd->password[i] : 0;
deskey(key, EN0);
for (j = 0; j < VNC_AUTH_CHALLENGE_SIZE; j += 8)
des(response+j, response+j);
if (memcmp(response, data, VNC_AUTH_CHALLENGE_SIZE) != 0) {
VNC_DEBUG("Client challenge reponse did not match\n");
goto reject;
} else {
VNC_DEBUG("Accepting VNC challenge response\n");
vnc_write_u32(vs, 0);
vnc_flush(vs);
start_client_init(vs);
}
return 0;
reject:
vnc_write_u32(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_flush(vs);
vnc_client_error(vs);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)
{
unsigned char VAR_3[VNC_AUTH_CHALLENGE_SIZE];
int VAR_4, VAR_5, VAR_6;
unsigned char VAR_7[8];
time_t now = time(NULL);
if (!VAR_0->vd->password || !VAR_0->vd->password[0]) {
VNC_DEBUG("No password configured on server");
goto reject;
}
if (VAR_0->vd->expires < now) {
VNC_DEBUG("Password is expired");
goto reject;
}
memcpy(VAR_3, VAR_0->challenge, VNC_AUTH_CHALLENGE_SIZE);
VAR_6 = strlen(VAR_0->vd->password);
for (VAR_4=0; VAR_4<sizeof(VAR_7); VAR_4++)
VAR_7[VAR_4] = VAR_4<VAR_6 ? VAR_0->vd->password[VAR_4] : 0;
deskey(VAR_7, EN0);
for (VAR_5 = 0; VAR_5 < VNC_AUTH_CHALLENGE_SIZE; VAR_5 += 8)
des(VAR_3+VAR_5, VAR_3+VAR_5);
if (memcmp(VAR_3, VAR_1, VNC_AUTH_CHALLENGE_SIZE) != 0) {
VNC_DEBUG("Client challenge reponse did not match\n");
goto reject;
} else {
VNC_DEBUG("Accepting VNC challenge VAR_3\n");
vnc_write_u32(VAR_0, 0);
vnc_flush(VAR_0);
start_client_init(VAR_0);
}
return 0;
reject:
vnc_write_u32(VAR_0, 1);
if (VAR_0->minor >= 8) {
static const char VAR_8[] = "Authentication failed";
vnc_write_u32(VAR_0, sizeof(VAR_8));
vnc_write(VAR_0, VAR_8, sizeof(VAR_8));
}
vnc_flush(VAR_0);
vnc_client_error(VAR_0);
return 0;
}
| [
"static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{",
"unsigned char VAR_3[VNC_AUTH_CHALLENGE_SIZE];",
"int VAR_4, VAR_5, VAR_6;",
"unsigned char VAR_7[8];",
"time_t now = time(NULL);",
"if (!VAR_0->vd->password || !VAR_0->vd->password[0]) {",
"VNC_DEBUG(\"No password configured on server\");",
"goto reject;",
"}",
"if (VAR_0->vd->expires < now) {",
"VNC_DEBUG(\"Password is expired\");",
"goto reject;",
"}",
"memcpy(VAR_3, VAR_0->challenge, VNC_AUTH_CHALLENGE_SIZE);",
"VAR_6 = strlen(VAR_0->vd->password);",
"for (VAR_4=0; VAR_4<sizeof(VAR_7); VAR_4++)",
"VAR_7[VAR_4] = VAR_4<VAR_6 ? VAR_0->vd->password[VAR_4] : 0;",
"deskey(VAR_7, EN0);",
"for (VAR_5 = 0; VAR_5 < VNC_AUTH_CHALLENGE_SIZE; VAR_5 += 8)",
"des(VAR_3+VAR_5, VAR_3+VAR_5);",
"if (memcmp(VAR_3, VAR_1, VNC_AUTH_CHALLENGE_SIZE) != 0) {",
"VNC_DEBUG(\"Client challenge reponse did not match\\n\");",
"goto reject;",
"} else {",
"VNC_DEBUG(\"Accepting VNC challenge VAR_3\\n\");",
"vnc_write_u32(VAR_0, 0);",
"vnc_flush(VAR_0);",
"start_client_init(VAR_0);",
"}",
"return 0;",
"reject:\nvnc_write_u32(VAR_0, 1);",
"if (VAR_0->minor >= 8) {",
"static const char VAR_8[] = \"Authentication failed\";",
"vnc_write_u32(VAR_0, sizeof(VAR_8));",
"vnc_write(VAR_0, VAR_8, sizeof(VAR_8));",
"}",
"vnc_flush(VAR_0);",
"vnc_client_error(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
2,479 | static void img_copy(uint8_t *dst, int dst_wrap,
uint8_t *src, int src_wrap,
int width, int height)
{
for(;height > 0; height--) {
memcpy(dst, src, width);
dst += dst_wrap;
src += src_wrap;
}
}
| false | FFmpeg | 7e7e59409294af9caa63808e56c5cc824c98b4fc | static void img_copy(uint8_t *dst, int dst_wrap,
uint8_t *src, int src_wrap,
int width, int height)
{
for(;height > 0; height--) {
memcpy(dst, src, width);
dst += dst_wrap;
src += src_wrap;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1,
uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
for(;VAR_5 > 0; VAR_5--) {
memcpy(VAR_0, VAR_2, VAR_4);
VAR_0 += VAR_1;
VAR_2 += VAR_3;
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1,\nuint8_t *VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"for(;VAR_5 > 0; VAR_5--) {",
"memcpy(VAR_0, VAR_2, VAR_4);",
"VAR_0 += VAR_1;",
"VAR_2 += VAR_3;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
2,480 | static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
{
CPUState *cs = CPU(cpu);
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &s->rom_state.up;
} else {
handlers = &s->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89: /* mov r32 to r/m32 */
patch_byte(cpu, ip, 0x50 + modrm_reg(opcode[1])); /* push reg */
patch_call(s, cpu, ip + 1, handlers->set_tpr);
break;
case 0x8b: /* mov r/m32 to r32 */
patch_byte(cpu, ip, 0x90);
patch_call(s, cpu, ip + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1: /* mov abs to eax */
patch_call(s, cpu, ip, handlers->get_tpr[0]);
break;
case 0xa3: /* mov eax to abs */
patch_call(s, cpu, ip, handlers->set_tpr_eax);
break;
case 0xc7: /* mov imm32, r/m32 (c7/0) */
patch_byte(cpu, ip, 0x68); /* push imm32 */
cpu_memory_rw_debug(cs, ip + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, ip + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(s, cpu, ip + 5, handlers->set_tpr);
break;
case 0xff: /* push r/m32 */
patch_byte(cpu, ip, 0x50); /* push eax */
patch_call(s, cpu, ip + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(cs, NULL);
}
}
| false | qemu | 6886b98036a8f8f5bce8b10756ce080084cef11b | static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
{
CPUState *cs = CPU(cpu);
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &s->rom_state.up;
} else {
handlers = &s->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89:
patch_byte(cpu, ip, 0x50 + modrm_reg(opcode[1]));
patch_call(s, cpu, ip + 1, handlers->set_tpr);
break;
case 0x8b:
patch_byte(cpu, ip, 0x90);
patch_call(s, cpu, ip + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1:
patch_call(s, cpu, ip, handlers->get_tpr[0]);
break;
case 0xa3:
patch_call(s, cpu, ip, handlers->set_tpr_eax);
break;
case 0xc7:
patch_byte(cpu, ip, 0x68);
cpu_memory_rw_debug(cs, ip + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, ip + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(s, cpu, ip + 5, handlers->set_tpr);
break;
case 0xff:
patch_byte(cpu, ip, 0x50);
patch_call(s, cpu, ip + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(cs, NULL);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VAPICROMState *VAR_0, X86CPU *VAR_1, target_ulong VAR_2)
{
CPUState *cs = CPU(VAR_1);
CPUX86State *env = &VAR_1->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0;
if (smp_cpus == 1) {
handlers = &VAR_0->rom_state.up;
} else {
handlers = &VAR_0->rom_state.mp;
}
if (!kvm_enabled()) {
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
pause_all_vcpus();
cpu_memory_rw_debug(cs, VAR_2, opcode, sizeof(opcode), 0);
switch (opcode[0]) {
case 0x89:
patch_byte(VAR_1, VAR_2, 0x50 + modrm_reg(opcode[1]));
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->set_tpr);
break;
case 0x8b:
patch_byte(VAR_1, VAR_2, 0x90);
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr[modrm_reg(opcode[1])]);
break;
case 0xa1:
patch_call(VAR_0, VAR_1, VAR_2, handlers->get_tpr[0]);
break;
case 0xa3:
patch_call(VAR_0, VAR_1, VAR_2, handlers->set_tpr_eax);
break;
case 0xc7:
patch_byte(VAR_1, VAR_2, 0x68);
cpu_memory_rw_debug(cs, VAR_2 + 6, (void *)&imm32, sizeof(imm32), 0);
cpu_memory_rw_debug(cs, VAR_2 + 1, (void *)&imm32, sizeof(imm32), 1);
patch_call(VAR_0, VAR_1, VAR_2 + 5, handlers->set_tpr);
break;
case 0xff:
patch_byte(VAR_1, VAR_2, 0x50);
patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr_stack);
break;
default:
abort();
}
resume_all_vcpus();
if (!kvm_enabled()) {
tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(cs, NULL);
}
}
| [
"static void FUNC_0(VAPICROMState *VAR_0, X86CPU *VAR_1, target_ulong VAR_2)\n{",
"CPUState *cs = CPU(VAR_1);",
"CPUX86State *env = &VAR_1->env;",
"VAPICHandlers *handlers;",
"uint8_t opcode[2];",
"uint32_t imm32 = 0;",
"target_ulong current_pc = 0;",
"target_ulong current_cs_base = 0;",
"uint32_t current_flags = 0;",
"if (smp_cpus == 1) {",
"handlers = &VAR_0->rom_state.up;",
"} else {",
"handlers = &VAR_0->rom_state.mp;",
"}",
"if (!kvm_enabled()) {",
"cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,\n¤t_flags);",
"}",
"pause_all_vcpus();",
"cpu_memory_rw_debug(cs, VAR_2, opcode, sizeof(opcode), 0);",
"switch (opcode[0]) {",
"case 0x89:\npatch_byte(VAR_1, VAR_2, 0x50 + modrm_reg(opcode[1]));",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->set_tpr);",
"break;",
"case 0x8b:\npatch_byte(VAR_1, VAR_2, 0x90);",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr[modrm_reg(opcode[1])]);",
"break;",
"case 0xa1:\npatch_call(VAR_0, VAR_1, VAR_2, handlers->get_tpr[0]);",
"break;",
"case 0xa3:\npatch_call(VAR_0, VAR_1, VAR_2, handlers->set_tpr_eax);",
"break;",
"case 0xc7:\npatch_byte(VAR_1, VAR_2, 0x68);",
"cpu_memory_rw_debug(cs, VAR_2 + 6, (void *)&imm32, sizeof(imm32), 0);",
"cpu_memory_rw_debug(cs, VAR_2 + 1, (void *)&imm32, sizeof(imm32), 1);",
"patch_call(VAR_0, VAR_1, VAR_2 + 5, handlers->set_tpr);",
"break;",
"case 0xff:\npatch_byte(VAR_1, VAR_2, 0x50);",
"patch_call(VAR_0, VAR_1, VAR_2 + 1, handlers->get_tpr_stack);",
"break;",
"default:\nabort();",
"}",
"resume_all_vcpus();",
"if (!kvm_enabled()) {",
"tb_gen_code(cs, current_pc, current_cs_base, current_flags, 1);",
"cpu_resume_from_signal(cs, NULL);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
45
],
[
49
],
[
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
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
2,481 | static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
qcrypto_cipher_free(s->cipher);
s->cipher = NULL;
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| false | qemu | d85f4222b4681da7ebf8a90b26e085a68fa2c55a | static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
qcrypto_cipher_free(s->cipher);
s->cipher = NULL;
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
BDRVQcowState *s = VAR_0->opaque;
qcrypto_cipher_free(s->cipher);
s->cipher = NULL;
g_free(s->l1_table);
qemu_vfree(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"qcrypto_cipher_free(s->cipher);",
"s->cipher = NULL;",
"g_free(s->l1_table);",
"qemu_vfree(s->l2_cache);",
"g_free(s->cluster_cache);",
"g_free(s->cluster_data);",
"migrate_del_blocker(s->migration_blocker);",
"error_free(s->migration_blocker);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
]
] |
2,482 | static void qmp_input_free(Visitor *v)
{
QmpInputVisitor *qiv = to_qiv(v);
while (!QSLIST_EMPTY(&qiv->stack)) {
StackObject *tos = QSLIST_FIRST(&qiv->stack);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
qmp_input_stack_object_free(tos);
}
qobject_decref(qiv->root);
g_free(qiv);
}
| false | qemu | 09e68369a88d7de0f988972bf28eec1b80cc47f9 | static void qmp_input_free(Visitor *v)
{
QmpInputVisitor *qiv = to_qiv(v);
while (!QSLIST_EMPTY(&qiv->stack)) {
StackObject *tos = QSLIST_FIRST(&qiv->stack);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
qmp_input_stack_object_free(tos);
}
qobject_decref(qiv->root);
g_free(qiv);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0)
{
QmpInputVisitor *qiv = to_qiv(VAR_0);
while (!QSLIST_EMPTY(&qiv->stack)) {
StackObject *tos = QSLIST_FIRST(&qiv->stack);
QSLIST_REMOVE_HEAD(&qiv->stack, node);
qmp_input_stack_object_free(tos);
}
qobject_decref(qiv->root);
g_free(qiv);
}
| [
"static void FUNC_0(Visitor *VAR_0)\n{",
"QmpInputVisitor *qiv = to_qiv(VAR_0);",
"while (!QSLIST_EMPTY(&qiv->stack)) {",
"StackObject *tos = QSLIST_FIRST(&qiv->stack);",
"QSLIST_REMOVE_HEAD(&qiv->stack, node);",
"qmp_input_stack_object_free(tos);",
"}",
"qobject_decref(qiv->root);",
"g_free(qiv);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
]
] |
2,484 | static void qcow_aio_write_cb(void *opaque, int ret)
{
QCowAIOCB *acb = opaque;
BlockDriverState *bs = acb->common.bs;
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
const uint8_t *src_buf;
int n_end;
acb->hd_aiocb = NULL;
if (ret >= 0) {
ret = qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta);
}
run_dependent_requests(&acb->l2meta);
if (ret < 0)
goto done;
acb->nb_sectors -= acb->n;
acb->sector_num += acb->n;
acb->buf += acb->n * 512;
if (acb->nb_sectors == 0) {
/* request completed */
ret = 0;
goto done;
}
index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
n_end = index_in_cluster + acb->nb_sectors;
if (s->crypt_method &&
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
index_in_cluster,
n_end, &acb->n, &acb->l2meta);
/* Need to wait for another request? If so, we are done for now. */
if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
LIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests,
acb, next_depend);
return;
}
if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {
ret = -EIO;
goto done;
}
if (s->crypt_method) {
if (!acb->cluster_data) {
acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
s->cluster_size);
}
qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
acb->n, 1, &s->aes_encrypt_key);
src_buf = acb->cluster_data;
} else {
src_buf = acb->buf;
}
acb->hd_iov.iov_base = (void *)src_buf;
acb->hd_iov.iov_len = acb->n * 512;
qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1);
acb->hd_aiocb = bdrv_aio_writev(s->hd,
(acb->cluster_offset >> 9) + index_in_cluster,
&acb->hd_qiov, acb->n,
qcow_aio_write_cb, acb);
if (acb->hd_aiocb == NULL)
goto done;
return;
done:
if (acb->qiov->niov > 1)
qemu_vfree(acb->orig_buf);
acb->common.cb(acb->common.opaque, ret);
qemu_aio_release(acb);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void qcow_aio_write_cb(void *opaque, int ret)
{
QCowAIOCB *acb = opaque;
BlockDriverState *bs = acb->common.bs;
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
const uint8_t *src_buf;
int n_end;
acb->hd_aiocb = NULL;
if (ret >= 0) {
ret = qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta);
}
run_dependent_requests(&acb->l2meta);
if (ret < 0)
goto done;
acb->nb_sectors -= acb->n;
acb->sector_num += acb->n;
acb->buf += acb->n * 512;
if (acb->nb_sectors == 0) {
ret = 0;
goto done;
}
index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
n_end = index_in_cluster + acb->nb_sectors;
if (s->crypt_method &&
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
index_in_cluster,
n_end, &acb->n, &acb->l2meta);
if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
LIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests,
acb, next_depend);
return;
}
if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {
ret = -EIO;
goto done;
}
if (s->crypt_method) {
if (!acb->cluster_data) {
acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
s->cluster_size);
}
qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
acb->n, 1, &s->aes_encrypt_key);
src_buf = acb->cluster_data;
} else {
src_buf = acb->buf;
}
acb->hd_iov.iov_base = (void *)src_buf;
acb->hd_iov.iov_len = acb->n * 512;
qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1);
acb->hd_aiocb = bdrv_aio_writev(s->hd,
(acb->cluster_offset >> 9) + index_in_cluster,
&acb->hd_qiov, acb->n,
qcow_aio_write_cb, acb);
if (acb->hd_aiocb == NULL)
goto done;
return;
done:
if (acb->qiov->niov > 1)
qemu_vfree(acb->orig_buf);
acb->common.cb(acb->common.opaque, ret);
qemu_aio_release(acb);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
QCowAIOCB *acb = VAR_0;
BlockDriverState *bs = acb->common.bs;
BDRVQcowState *s = bs->VAR_0;
int VAR_2;
const uint8_t *VAR_3;
int VAR_4;
acb->hd_aiocb = NULL;
if (VAR_1 >= 0) {
VAR_1 = qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta);
}
run_dependent_requests(&acb->l2meta);
if (VAR_1 < 0)
goto done;
acb->nb_sectors -= acb->n;
acb->sector_num += acb->n;
acb->buf += acb->n * 512;
if (acb->nb_sectors == 0) {
VAR_1 = 0;
goto done;
}
VAR_2 = acb->sector_num & (s->cluster_sectors - 1);
VAR_4 = VAR_2 + acb->nb_sectors;
if (s->crypt_method &&
VAR_4 > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
VAR_4 = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
VAR_2,
VAR_4, &acb->n, &acb->l2meta);
if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
LIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests,
acb, next_depend);
return;
}
if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {
VAR_1 = -EIO;
goto done;
}
if (s->crypt_method) {
if (!acb->cluster_data) {
acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
s->cluster_size);
}
qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
acb->n, 1, &s->aes_encrypt_key);
VAR_3 = acb->cluster_data;
} else {
VAR_3 = acb->buf;
}
acb->hd_iov.iov_base = (void *)VAR_3;
acb->hd_iov.iov_len = acb->n * 512;
qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1);
acb->hd_aiocb = bdrv_aio_writev(s->hd,
(acb->cluster_offset >> 9) + VAR_2,
&acb->hd_qiov, acb->n,
FUNC_0, acb);
if (acb->hd_aiocb == NULL)
goto done;
return;
done:
if (acb->qiov->niov > 1)
qemu_vfree(acb->orig_buf);
acb->common.cb(acb->common.VAR_0, VAR_1);
qemu_aio_release(acb);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"QCowAIOCB *acb = VAR_0;",
"BlockDriverState *bs = acb->common.bs;",
"BDRVQcowState *s = bs->VAR_0;",
"int VAR_2;",
"const uint8_t *VAR_3;",
"int VAR_4;",
"acb->hd_aiocb = NULL;",
"if (VAR_1 >= 0) {",
"VAR_1 = qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta);",
"}",
"run_dependent_requests(&acb->l2meta);",
"if (VAR_1 < 0)\ngoto done;",
"acb->nb_sectors -= acb->n;",
"acb->sector_num += acb->n;",
"acb->buf += acb->n * 512;",
"if (acb->nb_sectors == 0) {",
"VAR_1 = 0;",
"goto done;",
"}",
"VAR_2 = acb->sector_num & (s->cluster_sectors - 1);",
"VAR_4 = VAR_2 + acb->nb_sectors;",
"if (s->crypt_method &&\nVAR_4 > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)\nVAR_4 = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;",
"acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,\nVAR_2,\nVAR_4, &acb->n, &acb->l2meta);",
"if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {",
"LIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests,\nacb, next_depend);",
"return;",
"}",
"if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {",
"VAR_1 = -EIO;",
"goto done;",
"}",
"if (s->crypt_method) {",
"if (!acb->cluster_data) {",
"acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *\ns->cluster_size);",
"}",
"qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,\nacb->n, 1, &s->aes_encrypt_key);",
"VAR_3 = acb->cluster_data;",
"} else {",
"VAR_3 = acb->buf;",
"}",
"acb->hd_iov.iov_base = (void *)VAR_3;",
"acb->hd_iov.iov_len = acb->n * 512;",
"qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1);",
"acb->hd_aiocb = bdrv_aio_writev(s->hd,\n(acb->cluster_offset >> 9) + VAR_2,\n&acb->hd_qiov, acb->n,\nFUNC_0, acb);",
"if (acb->hd_aiocb == NULL)\ngoto done;",
"return;",
"done:\nif (acb->qiov->niov > 1)\nqemu_vfree(acb->orig_buf);",
"acb->common.cb(acb->common.VAR_0, VAR_1);",
"qemu_aio_release(acb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65,
67,
69
],
[
73,
75,
77
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133,
135,
137
],
[
139,
141
],
[
145
],
[
149,
151,
153
],
[
155
],
[
157
],
[
159
]
] |
2,485 | int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_preadv(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
/* throttling disk I/O */
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, false);
}
return bdrv_co_preadv(blk_bs(blk), offset, bytes, qiov, flags);
}
| false | qemu | a03ef88f77af045a2eb9629b5ce774a3fb973c5e | int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_preadv(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, false);
}
return bdrv_co_preadv(blk_bs(blk), offset, bytes, qiov, flags);
}
| {
"code": [],
"line_no": []
} | int VAR_0 blk_co_preadv(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_preadv(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, false);
}
return bdrv_co_preadv(blk_bs(blk), offset, bytes, qiov, flags);
}
| [
"int VAR_0 blk_co_preadv(BlockBackend *blk, int64_t offset,\nunsigned int bytes, QEMUIOVector *qiov,\nBdrvRequestFlags flags)\n{",
"int ret;",
"trace_blk_co_preadv(blk, blk_bs(blk), offset, bytes, flags);",
"ret = blk_check_byte_request(blk, offset, bytes);",
"if (ret < 0) {",
"return ret;",
"}",
"if (blk->public.throttle_state) {",
"throttle_group_co_io_limits_intercept(blk, bytes, false);",
"}",
"return bdrv_co_preadv(blk_bs(blk), offset, bytes, qiov, flags);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
2,486 | bool virtio_disk_is_scsi(void)
{
if (guessed_disk_nature) {
return (blk_cfg.blk_size == 512);
}
return (blk_cfg.geometry.heads == 255)
&& (blk_cfg.geometry.sectors == 63)
&& (blk_cfg.blk_size == 512);
}
| false | qemu | 92cb05574b7bd489be81f9c58497dc7dfe5d8859 | bool virtio_disk_is_scsi(void)
{
if (guessed_disk_nature) {
return (blk_cfg.blk_size == 512);
}
return (blk_cfg.geometry.heads == 255)
&& (blk_cfg.geometry.sectors == 63)
&& (blk_cfg.blk_size == 512);
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(void)
{
if (guessed_disk_nature) {
return (blk_cfg.blk_size == 512);
}
return (blk_cfg.geometry.heads == 255)
&& (blk_cfg.geometry.sectors == 63)
&& (blk_cfg.blk_size == 512);
}
| [
"bool FUNC_0(void)\n{",
"if (guessed_disk_nature) {",
"return (blk_cfg.blk_size == 512);",
"}",
"return (blk_cfg.geometry.heads == 255)\n&& (blk_cfg.geometry.sectors == 63)\n&& (blk_cfg.blk_size == 512);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13,
15
],
[
17
]
] |
2,487 | iscsi_aio_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
struct unmap_list list[1];
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
acb->iscsilun = iscsilun;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
list[0].lba = sector_qemu2lun(sector_num, iscsilun);
list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size;
acb->task = iscsi_unmap_task(iscsi, iscsilun->lun,
0, 0, &list[0], 1,
iscsi_unmap_cb,
acb);
if (acb->task == NULL) {
error_report("iSCSI: Failed to send unmap command. %s",
iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
iscsi_set_events(iscsilun);
return &acb->common;
}
| false | qemu | 1dde716ed6719c341c1bfa427781f0715af90cbc | iscsi_aio_discard(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
struct unmap_list list[1];
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
acb->iscsilun = iscsilun;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
list[0].lba = sector_qemu2lun(sector_num, iscsilun);
list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size;
acb->task = iscsi_unmap_task(iscsi, iscsilun->lun,
0, 0, &list[0], 1,
iscsi_unmap_cb,
acb);
if (acb->task == NULL) {
error_report("iSCSI: Failed to send unmap command. %s",
iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
iscsi_set_events(iscsilun);
return &acb->common;
}
| {
"code": [],
"line_no": []
} | FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1, int VAR_2,
BlockDriverCompletionFunc *VAR_3, void *VAR_4)
{
IscsiLun *iscsilun = VAR_0->VAR_4;
struct iscsi_context *VAR_5 = iscsilun->VAR_5;
IscsiAIOCB *acb;
struct unmap_list VAR_6[1];
acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_3, VAR_4);
acb->iscsilun = iscsilun;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
VAR_6[0].lba = sector_qemu2lun(VAR_1, iscsilun);
VAR_6[0].num = VAR_2 * BDRV_SECTOR_SIZE / iscsilun->block_size;
acb->task = iscsi_unmap_task(VAR_5, iscsilun->lun,
0, 0, &VAR_6[0], 1,
iscsi_unmap_cb,
acb);
if (acb->task == NULL) {
error_report("iSCSI: Failed to send unmap command. %s",
iscsi_get_error(VAR_5));
qemu_aio_release(acb);
return NULL;
}
iscsi_set_events(iscsilun);
return &acb->common;
}
| [
"FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1, int VAR_2,\nBlockDriverCompletionFunc *VAR_3, void *VAR_4)\n{",
"IscsiLun *iscsilun = VAR_0->VAR_4;",
"struct iscsi_context *VAR_5 = iscsilun->VAR_5;",
"IscsiAIOCB *acb;",
"struct unmap_list VAR_6[1];",
"acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_3, VAR_4);",
"acb->iscsilun = iscsilun;",
"acb->canceled = 0;",
"acb->bh = NULL;",
"acb->status = -EINPROGRESS;",
"acb->buf = NULL;",
"VAR_6[0].lba = sector_qemu2lun(VAR_1, iscsilun);",
"VAR_6[0].num = VAR_2 * BDRV_SECTOR_SIZE / iscsilun->block_size;",
"acb->task = iscsi_unmap_task(VAR_5, iscsilun->lun,\n0, 0, &VAR_6[0], 1,\niscsi_unmap_cb,\nacb);",
"if (acb->task == NULL) {",
"error_report(\"iSCSI: Failed to send unmap command. %s\",\niscsi_get_error(VAR_5));",
"qemu_aio_release(acb);",
"return NULL;",
"}",
"iscsi_set_events(iscsilun);",
"return &acb->common;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43,
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
]
] |
2,488 | static void stream_desc_store(struct Stream *s, hwaddr addr)
{
struct SDesc *d = &s->desc;
int i;
/* Convert from host endianness into LE. */
d->buffer_address = cpu_to_le64(d->buffer_address);
d->nxtdesc = cpu_to_le64(d->nxtdesc);
d->control = cpu_to_le32(d->control);
d->status = cpu_to_le32(d->status);
for (i = 0; i < ARRAY_SIZE(d->app); i++) {
d->app[i] = cpu_to_le32(d->app[i]);
}
cpu_physical_memory_write(addr, (void *) d, sizeof *d);
}
| false | qemu | 42bb9c9178ae7ac4c439172b1ae99cc29188a5c6 | static void stream_desc_store(struct Stream *s, hwaddr addr)
{
struct SDesc *d = &s->desc;
int i;
d->buffer_address = cpu_to_le64(d->buffer_address);
d->nxtdesc = cpu_to_le64(d->nxtdesc);
d->control = cpu_to_le32(d->control);
d->status = cpu_to_le32(d->status);
for (i = 0; i < ARRAY_SIZE(d->app); i++) {
d->app[i] = cpu_to_le32(d->app[i]);
}
cpu_physical_memory_write(addr, (void *) d, sizeof *d);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct Stream *VAR_0, hwaddr VAR_1)
{
struct SDesc *VAR_2 = &VAR_0->desc;
int VAR_3;
VAR_2->buffer_address = cpu_to_le64(VAR_2->buffer_address);
VAR_2->nxtdesc = cpu_to_le64(VAR_2->nxtdesc);
VAR_2->control = cpu_to_le32(VAR_2->control);
VAR_2->status = cpu_to_le32(VAR_2->status);
for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(VAR_2->app); VAR_3++) {
VAR_2->app[VAR_3] = cpu_to_le32(VAR_2->app[VAR_3]);
}
cpu_physical_memory_write(VAR_1, (void *) VAR_2, sizeof *VAR_2);
}
| [
"static void FUNC_0(struct Stream *VAR_0, hwaddr VAR_1)\n{",
"struct SDesc *VAR_2 = &VAR_0->desc;",
"int VAR_3;",
"VAR_2->buffer_address = cpu_to_le64(VAR_2->buffer_address);",
"VAR_2->nxtdesc = cpu_to_le64(VAR_2->nxtdesc);",
"VAR_2->control = cpu_to_le32(VAR_2->control);",
"VAR_2->status = cpu_to_le32(VAR_2->status);",
"for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(VAR_2->app); VAR_3++) {",
"VAR_2->app[VAR_3] = cpu_to_le32(VAR_2->app[VAR_3]);",
"}",
"cpu_physical_memory_write(VAR_1, (void *) VAR_2, sizeof *VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
2,489 | static void cs_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
CSState *s = opaque;
uint32_t saddr;
saddr = addr >> 2;
trace_cs4231_mem_writel_reg(saddr, s->regs[saddr], val);
switch (saddr) {
case 1:
trace_cs4231_mem_writel_dreg(CS_RAP(s), s->dregs[CS_RAP(s)], val);
switch(CS_RAP(s)) {
case 11:
case 25: // Read only
break;
case 12:
val &= 0x40;
val |= CS_CDC_VER; // Codec version
s->dregs[CS_RAP(s)] = val;
break;
default:
s->dregs[CS_RAP(s)] = val;
break;
}
break;
case 2: // Read only
break;
case 4:
if (val & 1) {
cs_reset(&s->busdev.qdev);
}
val &= 0x7f;
s->regs[saddr] = val;
break;
default:
s->regs[saddr] = val;
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void cs_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
CSState *s = opaque;
uint32_t saddr;
saddr = addr >> 2;
trace_cs4231_mem_writel_reg(saddr, s->regs[saddr], val);
switch (saddr) {
case 1:
trace_cs4231_mem_writel_dreg(CS_RAP(s), s->dregs[CS_RAP(s)], val);
switch(CS_RAP(s)) {
case 11:
case 25:
break;
case 12:
val &= 0x40;
val |= CS_CDC_VER;
s->dregs[CS_RAP(s)] = val;
break;
default:
s->dregs[CS_RAP(s)] = val;
break;
}
break;
case 2:
break;
case 4:
if (val & 1) {
cs_reset(&s->busdev.qdev);
}
val &= 0x7f;
s->regs[saddr] = val;
break;
default:
s->regs[saddr] = val;
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
CSState *s = VAR_0;
uint32_t saddr;
saddr = VAR_1 >> 2;
trace_cs4231_mem_writel_reg(saddr, s->regs[saddr], VAR_2);
switch (saddr) {
case 1:
trace_cs4231_mem_writel_dreg(CS_RAP(s), s->dregs[CS_RAP(s)], VAR_2);
switch(CS_RAP(s)) {
case 11:
case 25:
break;
case 12:
VAR_2 &= 0x40;
VAR_2 |= CS_CDC_VER;
s->dregs[CS_RAP(s)] = VAR_2;
break;
default:
s->dregs[CS_RAP(s)] = VAR_2;
break;
}
break;
case 2:
break;
case 4:
if (VAR_2 & 1) {
cs_reset(&s->busdev.qdev);
}
VAR_2 &= 0x7f;
s->regs[saddr] = VAR_2;
break;
default:
s->regs[saddr] = VAR_2;
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"CSState *s = VAR_0;",
"uint32_t saddr;",
"saddr = VAR_1 >> 2;",
"trace_cs4231_mem_writel_reg(saddr, s->regs[saddr], VAR_2);",
"switch (saddr) {",
"case 1:\ntrace_cs4231_mem_writel_dreg(CS_RAP(s), s->dregs[CS_RAP(s)], VAR_2);",
"switch(CS_RAP(s)) {",
"case 11:\ncase 25:\nbreak;",
"case 12:\nVAR_2 &= 0x40;",
"VAR_2 |= CS_CDC_VER;",
"s->dregs[CS_RAP(s)] = VAR_2;",
"break;",
"default:\ns->dregs[CS_RAP(s)] = VAR_2;",
"break;",
"}",
"break;",
"case 2:\nbreak;",
"case 4:\nif (VAR_2 & 1) {",
"cs_reset(&s->busdev.qdev);",
"}",
"VAR_2 &= 0x7f;",
"s->regs[saddr] = VAR_2;",
"break;",
"default:\ns->regs[saddr] = VAR_2;",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25,
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
]
] |
2,490 | static int mxf_parse_structural_metadata(MXFContext *mxf)
{
MXFPackage *material_package = NULL;
MXFPackage *source_package = NULL;
MXFPackage *temp_package = NULL;
int i, j, k;
dprintf("metadata sets count %d\n", mxf->metadata_sets_count);
/* TODO: handle multiple material packages (OP3x) */
for (i = 0; i < mxf->packages_count; i++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve package strong ref\n");
return -1;
}
if (temp_package->type == MaterialPackage) {
material_package = temp_package;
break;
}
}
if (!material_package) {
av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n");
return -1;
}
for (i = 0; i < material_package->tracks_count; i++) {
MXFTrack *material_track = NULL;
MXFTrack *source_track = NULL;
MXFTrack *temp_track = NULL;
MXFDescriptor *descriptor = NULL;
MXFStructuralComponent *component = NULL;
const MXFCodecUL *codec_ul = NULL;
const MXFCodecUL *container_ul = NULL;
AVStream *st;
if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n");
continue;
}
if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n");
return -1;
}
/* TODO: handle multiple source clips */
for (j = 0; j < material_track->sequence->structural_components_count; j++) {
/* TODO: handle timecode component */
component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j]);
if (!component || component->type != SourceClip)
continue;
for (k = 0; k < mxf->packages_count; k++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {
source_package = temp_package;
break;
}
}
if (!source_package) {
av_log(mxf->fc, AV_LOG_ERROR, "material track %d: no corresponding source package found\n", material_track->track_id);
break;
}
for (k = 0; k < source_package->tracks_count; k++) {
if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (temp_track->track_id == component->source_track_id) {
source_track = temp_track;
break;
}
}
if (!source_track) {
av_log(mxf->fc, AV_LOG_ERROR, "material track %d: no corresponding source track found\n", material_track->track_id);
break;
}
}
if (!source_track)
continue;
st = av_new_stream(mxf->fc, source_track->track_id);
st->priv_data = source_track;
st->duration = component->duration;
if (st->duration == -1)
st->duration = AV_NOPTS_VALUE;
st->start_time = component->start_position;
av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);
if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
return -1;
}
#ifdef DEBUG
PRINT_KEY("data definition ul", source_track->sequence->data_definition_ul);
#endif
st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref);
if (source_package->descriptor) {
if (source_package->descriptor->type == MultipleDescriptor) {
for (j = 0; j < source_package->descriptor->sub_descriptors_count; j++) {
MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j]);
if (!sub_descriptor) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n");
continue;
}
if (sub_descriptor->linked_track_id == source_track->track_id) {
descriptor = sub_descriptor;
break;
}
}
} else
descriptor = source_package->descriptor;
}
if (!descriptor) {
av_log(mxf->fc, AV_LOG_INFO, "source track %d: stream %d, no descriptor found\n", source_track->track_id, st->index);
continue;
}
#ifdef DEBUG
PRINT_KEY("essence codec ul", descriptor->essence_codec_ul);
PRINT_KEY("essence container ul", descriptor->essence_container_ul);
#endif
/* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */
codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);
st->codec->codec_id = codec_ul->id;
if (descriptor->extradata) {
st->codec->extradata = descriptor->extradata;
st->codec->extradata_size = descriptor->extradata_size;
}
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->width = descriptor->width;
st->codec->height = descriptor->height;
st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
st->need_parsing = 2; /* only parse headers */
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->channels = descriptor->channels;
st->codec->bits_per_sample = descriptor->bits_per_sample;
st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
/* TODO: implement CODEC_ID_RAWAUDIO */
if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24LE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32LE;
} else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24BE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32BE;
if (descriptor->essence_container_ul[13] == 0x01) /* D-10 Mapping */
st->codec->channels = 8; /* force channels to 8 */
} else if (st->codec->codec_id == CODEC_ID_MP2) {
st->need_parsing = 1;
}
}
if (container_ul && container_ul->wrapping == Clip) {
dprintf("stream %d: clip wrapped essence\n", st->index);
st->need_parsing = 1;
}
}
return 0;
}
| false | FFmpeg | 7f25df4cd38fe9de6dd88f806a3994be5302a823 | static int mxf_parse_structural_metadata(MXFContext *mxf)
{
MXFPackage *material_package = NULL;
MXFPackage *source_package = NULL;
MXFPackage *temp_package = NULL;
int i, j, k;
dprintf("metadata sets count %d\n", mxf->metadata_sets_count);
for (i = 0; i < mxf->packages_count; i++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve package strong ref\n");
return -1;
}
if (temp_package->type == MaterialPackage) {
material_package = temp_package;
break;
}
}
if (!material_package) {
av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n");
return -1;
}
for (i = 0; i < material_package->tracks_count; i++) {
MXFTrack *material_track = NULL;
MXFTrack *source_track = NULL;
MXFTrack *temp_track = NULL;
MXFDescriptor *descriptor = NULL;
MXFStructuralComponent *component = NULL;
const MXFCodecUL *codec_ul = NULL;
const MXFCodecUL *container_ul = NULL;
AVStream *st;
if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n");
continue;
}
if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n");
return -1;
}
for (j = 0; j < material_track->sequence->structural_components_count; j++) {
component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j]);
if (!component || component->type != SourceClip)
continue;
for (k = 0; k < mxf->packages_count; k++) {
if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {
source_package = temp_package;
break;
}
}
if (!source_package) {
av_log(mxf->fc, AV_LOG_ERROR, "material track %d: no corresponding source package found\n", material_track->track_id);
break;
}
for (k = 0; k < source_package->tracks_count; k++) {
if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k]))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (temp_track->track_id == component->source_track_id) {
source_track = temp_track;
break;
}
}
if (!source_track) {
av_log(mxf->fc, AV_LOG_ERROR, "material track %d: no corresponding source track found\n", material_track->track_id);
break;
}
}
if (!source_track)
continue;
st = av_new_stream(mxf->fc, source_track->track_id);
st->priv_data = source_track;
st->duration = component->duration;
if (st->duration == -1)
st->duration = AV_NOPTS_VALUE;
st->start_time = component->start_position;
av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);
if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
return -1;
}
#ifdef DEBUG
PRINT_KEY("data definition ul", source_track->sequence->data_definition_ul);
#endif
st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref);
if (source_package->descriptor) {
if (source_package->descriptor->type == MultipleDescriptor) {
for (j = 0; j < source_package->descriptor->sub_descriptors_count; j++) {
MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j]);
if (!sub_descriptor) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n");
continue;
}
if (sub_descriptor->linked_track_id == source_track->track_id) {
descriptor = sub_descriptor;
break;
}
}
} else
descriptor = source_package->descriptor;
}
if (!descriptor) {
av_log(mxf->fc, AV_LOG_INFO, "source track %d: stream %d, no descriptor found\n", source_track->track_id, st->index);
continue;
}
#ifdef DEBUG
PRINT_KEY("essence codec ul", descriptor->essence_codec_ul);
PRINT_KEY("essence container ul", descriptor->essence_container_ul);
#endif
codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);
st->codec->codec_id = codec_ul->id;
if (descriptor->extradata) {
st->codec->extradata = descriptor->extradata;
st->codec->extradata_size = descriptor->extradata_size;
}
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->width = descriptor->width;
st->codec->height = descriptor->height;
st->codec->bits_per_sample = descriptor->bits_per_sample;
st->need_parsing = 2;
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->channels = descriptor->channels;
st->codec->bits_per_sample = descriptor->bits_per_sample;
st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24LE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32LE;
} else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24BE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32BE;
if (descriptor->essence_container_ul[13] == 0x01)
st->codec->channels = 8;
} else if (st->codec->codec_id == CODEC_ID_MP2) {
st->need_parsing = 1;
}
}
if (container_ul && container_ul->wrapping == Clip) {
dprintf("stream %d: clip wrapped essence\n", st->index);
st->need_parsing = 1;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MXFContext *VAR_0)
{
MXFPackage *material_package = NULL;
MXFPackage *source_package = NULL;
MXFPackage *temp_package = NULL;
int VAR_1, VAR_2, VAR_3;
dprintf("metadata sets count %d\n", VAR_0->metadata_sets_count);
for (VAR_1 = 0; VAR_1 < VAR_0->packages_count; VAR_1++) {
if (!(temp_package = mxf_resolve_strong_ref(VAR_0, &VAR_0->packages_refs[VAR_1]))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve package strong ref\n");
return -1;
}
if (temp_package->type == MaterialPackage) {
material_package = temp_package;
break;
}
}
if (!material_package) {
av_log(VAR_0->fc, AV_LOG_ERROR, "no material package found\n");
return -1;
}
for (VAR_1 = 0; VAR_1 < material_package->tracks_count; VAR_1++) {
MXFTrack *material_track = NULL;
MXFTrack *source_track = NULL;
MXFTrack *temp_track = NULL;
MXFDescriptor *descriptor = NULL;
MXFStructuralComponent *component = NULL;
const MXFCodecUL *codec_ul = NULL;
const MXFCodecUL *container_ul = NULL;
AVStream *st;
if (!(material_track = mxf_resolve_strong_ref(VAR_0, &material_package->tracks_refs[VAR_1]))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n");
continue;
}
if (!(material_track->sequence = mxf_resolve_strong_ref(VAR_0, &material_track->sequence_ref))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n");
return -1;
}
for (VAR_2 = 0; VAR_2 < material_track->sequence->structural_components_count; VAR_2++) {
component = mxf_resolve_strong_ref(VAR_0, &material_track->sequence->structural_components_refs[VAR_2]);
if (!component || component->type != SourceClip)
continue;
for (VAR_3 = 0; VAR_3 < VAR_0->packages_count; VAR_3++) {
if (!(temp_package = mxf_resolve_strong_ref(VAR_0, &VAR_0->packages_refs[VAR_3]))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {
source_package = temp_package;
break;
}
}
if (!source_package) {
av_log(VAR_0->fc, AV_LOG_ERROR, "material track %d: no corresponding source package found\n", material_track->track_id);
break;
}
for (VAR_3 = 0; VAR_3 < source_package->tracks_count; VAR_3++) {
if (!(temp_track = mxf_resolve_strong_ref(VAR_0, &source_package->tracks_refs[VAR_3]))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
if (temp_track->track_id == component->source_track_id) {
source_track = temp_track;
break;
}
}
if (!source_track) {
av_log(VAR_0->fc, AV_LOG_ERROR, "material track %d: no corresponding source track found\n", material_track->track_id);
break;
}
}
if (!source_track)
continue;
st = av_new_stream(VAR_0->fc, source_track->track_id);
st->priv_data = source_track;
st->duration = component->duration;
if (st->duration == -1)
st->duration = AV_NOPTS_VALUE;
st->start_time = component->start_position;
av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);
if (!(source_track->sequence = mxf_resolve_strong_ref(VAR_0, &source_track->sequence_ref))) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
return -1;
}
#ifdef DEBUG
PRINT_KEY("data definition ul", source_track->sequence->data_definition_ul);
#endif
st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
source_package->descriptor = mxf_resolve_strong_ref(VAR_0, &source_package->descriptor_ref);
if (source_package->descriptor) {
if (source_package->descriptor->type == MultipleDescriptor) {
for (VAR_2 = 0; VAR_2 < source_package->descriptor->sub_descriptors_count; VAR_2++) {
MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(VAR_0, &source_package->descriptor->sub_descriptors_refs[VAR_2]);
if (!sub_descriptor) {
av_log(VAR_0->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n");
continue;
}
if (sub_descriptor->linked_track_id == source_track->track_id) {
descriptor = sub_descriptor;
break;
}
}
} else
descriptor = source_package->descriptor;
}
if (!descriptor) {
av_log(VAR_0->fc, AV_LOG_INFO, "source track %d: stream %d, no descriptor found\n", source_track->track_id, st->index);
continue;
}
#ifdef DEBUG
PRINT_KEY("essence codec ul", descriptor->essence_codec_ul);
PRINT_KEY("essence container ul", descriptor->essence_container_ul);
#endif
codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);
st->codec->codec_id = codec_ul->id;
if (descriptor->extradata) {
st->codec->extradata = descriptor->extradata;
st->codec->extradata_size = descriptor->extradata_size;
}
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->width = descriptor->width;
st->codec->height = descriptor->height;
st->codec->bits_per_sample = descriptor->bits_per_sample;
st->need_parsing = 2;
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->channels = descriptor->channels;
st->codec->bits_per_sample = descriptor->bits_per_sample;
st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24LE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32LE;
} else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {
if (descriptor->bits_per_sample == 24)
st->codec->codec_id = CODEC_ID_PCM_S24BE;
else if (descriptor->bits_per_sample == 32)
st->codec->codec_id = CODEC_ID_PCM_S32BE;
if (descriptor->essence_container_ul[13] == 0x01)
st->codec->channels = 8;
} else if (st->codec->codec_id == CODEC_ID_MP2) {
st->need_parsing = 1;
}
}
if (container_ul && container_ul->wrapping == Clip) {
dprintf("stream %d: clip wrapped essence\n", st->index);
st->need_parsing = 1;
}
}
return 0;
}
| [
"static int FUNC_0(MXFContext *VAR_0)\n{",
"MXFPackage *material_package = NULL;",
"MXFPackage *source_package = NULL;",
"MXFPackage *temp_package = NULL;",
"int VAR_1, VAR_2, VAR_3;",
"dprintf(\"metadata sets count %d\\n\", VAR_0->metadata_sets_count);",
"for (VAR_1 = 0; VAR_1 < VAR_0->packages_count; VAR_1++) {",
"if (!(temp_package = mxf_resolve_strong_ref(VAR_0, &VAR_0->packages_refs[VAR_1]))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve package strong ref\\n\");",
"return -1;",
"}",
"if (temp_package->type == MaterialPackage) {",
"material_package = temp_package;",
"break;",
"}",
"}",
"if (!material_package) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"no material package found\\n\");",
"return -1;",
"}",
"for (VAR_1 = 0; VAR_1 < material_package->tracks_count; VAR_1++) {",
"MXFTrack *material_track = NULL;",
"MXFTrack *source_track = NULL;",
"MXFTrack *temp_track = NULL;",
"MXFDescriptor *descriptor = NULL;",
"MXFStructuralComponent *component = NULL;",
"const MXFCodecUL *codec_ul = NULL;",
"const MXFCodecUL *container_ul = NULL;",
"AVStream *st;",
"if (!(material_track = mxf_resolve_strong_ref(VAR_0, &material_package->tracks_refs[VAR_1]))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve material track strong ref\\n\");",
"continue;",
"}",
"if (!(material_track->sequence = mxf_resolve_strong_ref(VAR_0, &material_track->sequence_ref))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve material track sequence strong ref\\n\");",
"return -1;",
"}",
"for (VAR_2 = 0; VAR_2 < material_track->sequence->structural_components_count; VAR_2++) {",
"component = mxf_resolve_strong_ref(VAR_0, &material_track->sequence->structural_components_refs[VAR_2]);",
"if (!component || component->type != SourceClip)\ncontinue;",
"for (VAR_3 = 0; VAR_3 < VAR_0->packages_count; VAR_3++) {",
"if (!(temp_package = mxf_resolve_strong_ref(VAR_0, &VAR_0->packages_refs[VAR_3]))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve source track strong ref\\n\");",
"return -1;",
"}",
"if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {",
"source_package = temp_package;",
"break;",
"}",
"}",
"if (!source_package) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"material track %d: no corresponding source package found\\n\", material_track->track_id);",
"break;",
"}",
"for (VAR_3 = 0; VAR_3 < source_package->tracks_count; VAR_3++) {",
"if (!(temp_track = mxf_resolve_strong_ref(VAR_0, &source_package->tracks_refs[VAR_3]))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve source track strong ref\\n\");",
"return -1;",
"}",
"if (temp_track->track_id == component->source_track_id) {",
"source_track = temp_track;",
"break;",
"}",
"}",
"if (!source_track) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"material track %d: no corresponding source track found\\n\", material_track->track_id);",
"break;",
"}",
"}",
"if (!source_track)\ncontinue;",
"st = av_new_stream(VAR_0->fc, source_track->track_id);",
"st->priv_data = source_track;",
"st->duration = component->duration;",
"if (st->duration == -1)\nst->duration = AV_NOPTS_VALUE;",
"st->start_time = component->start_position;",
"av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);",
"if (!(source_track->sequence = mxf_resolve_strong_ref(VAR_0, &source_track->sequence_ref))) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve source track sequence strong ref\\n\");",
"return -1;",
"}",
"#ifdef DEBUG\nPRINT_KEY(\"data definition ul\", source_track->sequence->data_definition_ul);",
"#endif\nst->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);",
"source_package->descriptor = mxf_resolve_strong_ref(VAR_0, &source_package->descriptor_ref);",
"if (source_package->descriptor) {",
"if (source_package->descriptor->type == MultipleDescriptor) {",
"for (VAR_2 = 0; VAR_2 < source_package->descriptor->sub_descriptors_count; VAR_2++) {",
"MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(VAR_0, &source_package->descriptor->sub_descriptors_refs[VAR_2]);",
"if (!sub_descriptor) {",
"av_log(VAR_0->fc, AV_LOG_ERROR, \"could not resolve sub descriptor strong ref\\n\");",
"continue;",
"}",
"if (sub_descriptor->linked_track_id == source_track->track_id) {",
"descriptor = sub_descriptor;",
"break;",
"}",
"}",
"} else",
"descriptor = source_package->descriptor;",
"}",
"if (!descriptor) {",
"av_log(VAR_0->fc, AV_LOG_INFO, \"source track %d: stream %d, no descriptor found\\n\", source_track->track_id, st->index);",
"continue;",
"}",
"#ifdef DEBUG\nPRINT_KEY(\"essence codec ul\", descriptor->essence_codec_ul);",
"PRINT_KEY(\"essence container ul\", descriptor->essence_container_ul);",
"#endif\ncodec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);",
"st->codec->codec_id = codec_ul->id;",
"if (descriptor->extradata) {",
"st->codec->extradata = descriptor->extradata;",
"st->codec->extradata_size = descriptor->extradata_size;",
"}",
"if (st->codec->codec_type == CODEC_TYPE_VIDEO) {",
"container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);",
"if (st->codec->codec_id == CODEC_ID_NONE)\nst->codec->codec_id = container_ul->id;",
"st->codec->width = descriptor->width;",
"st->codec->height = descriptor->height;",
"st->codec->bits_per_sample = descriptor->bits_per_sample;",
"st->need_parsing = 2;",
"} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {",
"container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);",
"if (st->codec->codec_id == CODEC_ID_NONE)\nst->codec->codec_id = container_ul->id;",
"st->codec->channels = descriptor->channels;",
"st->codec->bits_per_sample = descriptor->bits_per_sample;",
"st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;",
"if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {",
"if (descriptor->bits_per_sample == 24)\nst->codec->codec_id = CODEC_ID_PCM_S24LE;",
"else if (descriptor->bits_per_sample == 32)\nst->codec->codec_id = CODEC_ID_PCM_S32LE;",
"} else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {",
"if (descriptor->bits_per_sample == 24)\nst->codec->codec_id = CODEC_ID_PCM_S24BE;",
"else if (descriptor->bits_per_sample == 32)\nst->codec->codec_id = CODEC_ID_PCM_S32BE;",
"if (descriptor->essence_container_ul[13] == 0x01)\nst->codec->channels = 8;",
"} else if (st->codec->codec_id == CODEC_ID_MP2) {",
"st->need_parsing = 1;",
"}",
"}",
"if (container_ul && container_ul->wrapping == Clip) {",
"dprintf(\"stream %d: clip wrapped essence\\n\", st->index);",
"st->need_parsing = 1;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
91
],
[
95
],
[
97,
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193,
195
],
[
197,
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251
],
[
253,
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303,
305
],
[
307,
309
],
[
311
],
[
313,
315
],
[
317,
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
]
] |
2,491 | void virtqueue_map(VirtQueueElement *elem)
{
virtqueue_map_iovec(elem->in_sg, elem->in_addr, &elem->in_num,
VIRTQUEUE_MAX_SIZE, 1);
virtqueue_map_iovec(elem->out_sg, elem->out_addr, &elem->out_num,
VIRTQUEUE_MAX_SIZE, 0);
}
| false | qemu | 8607f5c3072caeebbe0217df28651fffd3a79fd9 | void virtqueue_map(VirtQueueElement *elem)
{
virtqueue_map_iovec(elem->in_sg, elem->in_addr, &elem->in_num,
VIRTQUEUE_MAX_SIZE, 1);
virtqueue_map_iovec(elem->out_sg, elem->out_addr, &elem->out_num,
VIRTQUEUE_MAX_SIZE, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtQueueElement *VAR_0)
{
virtqueue_map_iovec(VAR_0->in_sg, VAR_0->in_addr, &VAR_0->in_num,
VIRTQUEUE_MAX_SIZE, 1);
virtqueue_map_iovec(VAR_0->out_sg, VAR_0->out_addr, &VAR_0->out_num,
VIRTQUEUE_MAX_SIZE, 0);
}
| [
"void FUNC_0(VirtQueueElement *VAR_0)\n{",
"virtqueue_map_iovec(VAR_0->in_sg, VAR_0->in_addr, &VAR_0->in_num,\nVIRTQUEUE_MAX_SIZE, 1);",
"virtqueue_map_iovec(VAR_0->out_sg, VAR_0->out_addr, &VAR_0->out_num,\nVIRTQUEUE_MAX_SIZE, 0);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
]
] |
2,492 | static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag,
uint32_t lun)
{
SCSIRequest *req;
SCSIDiskReq *r;
req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun);
r = DO_UPCAST(SCSIDiskReq, req, req);
r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);
return r;
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag,
uint32_t lun)
{
SCSIRequest *req;
SCSIDiskReq *r;
req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun);
r = DO_UPCAST(SCSIDiskReq, req, req);
r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);
return r;
}
| {
"code": [
" SCSIRequest *req;",
"static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag,",
" return r;",
" SCSIDiskReq *r;",
" SCSIDiskReq *r;",
" SCSIDiskReq *r;",
" SCSIDiskReq *r;",
" SCSIDiskReq *r;"
],
"line_no": [
7,
1,
19,
9,
9,
9,
9,
9
]
} | static SCSIDiskReq *FUNC_0(SCSIDiskState *s, uint32_t tag,
uint32_t lun)
{
SCSIRequest *req;
SCSIDiskReq *r;
req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun);
r = DO_UPCAST(SCSIDiskReq, req, req);
r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);
return r;
}
| [
"static SCSIDiskReq *FUNC_0(SCSIDiskState *s, uint32_t tag,\nuint32_t lun)\n{",
"SCSIRequest *req;",
"SCSIDiskReq *r;",
"req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun);",
"r = DO_UPCAST(SCSIDiskReq, req, req);",
"r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);",
"return r;",
"}"
] | [
1,
1,
1,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
2,494 | static int disas_vfp_insn(CPUARMState * env, DisasContext *s, uint32_t insn)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int dp, veclen;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(env, ARM_FEATURE_VFP))
return 1;
if (!s->vfp_enabled) {
/* VFP disabled. Only allow fmxr/fmrx to/from some control regs. */
if ((insn & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (insn >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
dp = ((insn & 0xf00) == 0xb00);
switch ((insn >> 24) & 0xf) {
case 0xe:
if (insn & (1 << 4)) {
/* single register transfer */
rd = (insn >> 12) & 0xf;
if (dp) {
int size;
int pass;
VFP_DREG_N(rn, insn);
if (insn & 0xf)
return 1;
if (insn & 0x00c00060
&& !arm_feature(env, ARM_FEATURE_NEON))
return 1;
pass = (insn >> 21) & 1;
if (insn & (1 << 22)) {
size = 0;
offset = ((insn >> 5) & 3) * 8;
} else if (insn & (1 << 5)) {
size = 1;
offset = (insn & (1 << 6)) ? 16 : 0;
} else {
size = 2;
offset = 0;
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
tmp = neon_load_reg(rn, pass);
switch (size) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (insn & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (insn & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(s, rd, tmp);
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 23)) {
/* VDUP */
if (size == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (size == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= pass * 2; n++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
/* VMOV */
switch (size) {
case 0:
tmp2 = neon_load_reg(rn, pass);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);
tcg_temp_free_i32(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, pass);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);
tcg_temp_free_i32(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, pass, tmp);
}
}
} else { /* !dp */
if ((insn & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(insn);
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (insn & (1 << 21)) {
/* system register */
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
/* VFP2 allows access to FSID from userspace.
VFP3 restricts all id registers to privileged
accesses. */
if (IS_USER(s)
&& arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
/* Not present in VFP3. */
if (IS_USER(s)
|| arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = tcg_temp_new_i32();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(s)
|| !arm_feature(env, ARM_FEATURE_MVFR))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
/* Set the 4 flag bits in the CPSR. */
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
}
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 21)) {
rn >>= 1;
/* system register */
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
/* Writes are ignored. */
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
/* TODO: VFP subarchitecture support.
* For now, keep the EN bit only */
tcg_gen_andi_i32(tmp, tmp, 1 << 30);
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(s);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
/* data processing */
/* The opcode is in bits 23, 21, 20 and 6. */
op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1);
if (dp) {
if (op == 15) {
/* rn is opcode */
rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1);
} else {
/* rn is register number */
VFP_DREG_N(rn, insn);
}
if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) {
/* Integer or single precision destination. */
rd = VFP_SREG_D(insn);
} else {
VFP_DREG_D(rd, insn);
}
if (op == 15 &&
(((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) {
/* VCVT from int is always from S reg regardless of dp bit.
* VCVT with immediate frac_bits has same format as SREG_M
*/
rm = VFP_SREG_M(insn);
} else {
VFP_DREG_M(rm, insn);
}
} else {
rn = VFP_SREG_N(insn);
if (op == 15 && rn == 15) {
/* Double precision destination. */
VFP_DREG_D(rd, insn);
} else {
rd = VFP_SREG_D(insn);
}
/* NB that we implicitly rely on the encoding for the frac_bits
* in VCVT of fixed to float being the same as that of an SREG_M
*/
rm = VFP_SREG_M(insn);
}
veclen = s->vec_len;
if (op == 15 && rn > 3)
veclen = 0;
/* Shut up compiler warnings. */
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (veclen > 0) {
if (dp)
bank_mask = 0xc;
else
bank_mask = 0x18;
/* Figure out what type of vector operation this is. */
if ((rd & bank_mask) == 0) {
/* scalar */
veclen = 0;
} else {
if (dp)
delta_d = (s->vec_stride >> 1) + 1;
else
delta_d = s->vec_stride + 1;
if ((rm & bank_mask) == 0) {
/* mixed scalar/vector */
delta_m = 0;
} else {
/* vector */
delta_m = delta_d;
}
}
}
/* Load the initial operands. */
if (op == 15) {
switch (rn) {
case 16:
case 17:
/* Integer source */
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
/* Compare */
gen_mov_F0_vreg(dp, rd);
gen_mov_F1_vreg(dp, rm);
break;
case 10:
case 11:
/* Compare with zero */
gen_mov_F0_vreg(dp, rd);
gen_vfp_F1_ld0(dp);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
/* Source and destination the same. */
gen_mov_F0_vreg(dp, rd);
break;
case 4:
case 5:
case 6:
case 7:
/* VCVTB, VCVTT: only present with the halfprec extension,
* UNPREDICTABLE if bit 8 is set (we choose to UNDEF)
*/
if (dp || !arm_feature(env, ARM_FEATURE_VFP_FP16)) {
return 1;
}
/* Otherwise fall through */
default:
/* One source operand. */
gen_mov_F0_vreg(dp, rm);
break;
}
} else {
/* Two source operands. */
gen_mov_F0_vreg(dp, rn);
gen_mov_F1_vreg(dp, rm);
}
for (;;) {
/* Perform the calculation. */
switch (op) {
case 0: /* VMLA: fd + (fn * fm) */
/* Note that order of inputs to the add matters for NaNs */
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 1: /* VMLS: fd + -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 2: /* VNMLS: -fd + (fn * fm) */
/* Note that it isn't valid to replace (-A + B) with (B - A)
* or similar plausible looking simplifications
* because this will give wrong results for NaNs.
*/
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 3: /* VNMLA: -fd + -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 4: /* mul: fn * fm */
gen_vfp_mul(dp);
break;
case 5: /* nmul: -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_neg(dp);
break;
case 6: /* add: fn + fm */
gen_vfp_add(dp);
break;
case 7: /* sub: fn - fm */
gen_vfp_sub(dp);
break;
case 8: /* div: fn / fm */
gen_vfp_div(dp);
break;
case 10: /* VFNMA : fd = muladd(-fd, fn, fm) */
case 11: /* VFNMS : fd = muladd(-fd, -fn, fm) */
case 12: /* VFMA : fd = muladd( fd, fn, fm) */
case 13: /* VFMS : fd = muladd( fd, -fn, fm) */
/* These are fused multiply-add, and must be done as one
* floating point operation with no rounding between the
* multiplication and addition steps.
* NB that doing the negations here as separate steps is
* correct : an input NaN should come out with its sign bit
* flipped if it is a negated-input.
*/
if (!arm_feature(env, ARM_FEATURE_VFP4)) {
return 1;
}
if (dp) {
TCGv_ptr fpst;
TCGv_i64 frd;
if (op & 1) {
/* VFNMS, VFMS */
gen_helper_vfp_negd(cpu_F0d, cpu_F0d);
}
frd = tcg_temp_new_i64();
tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(dp, rd));
if (op & 2) {
/* VFNMA, VFNMS */
gen_helper_vfp_negd(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d,
cpu_F1d, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i64(frd);
} else {
TCGv_ptr fpst;
TCGv_i32 frd;
if (op & 1) {
/* VFNMS, VFMS */
gen_helper_vfp_negs(cpu_F0s, cpu_F0s);
}
frd = tcg_temp_new_i32();
tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(dp, rd));
if (op & 2) {
gen_helper_vfp_negs(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladds(cpu_F0s, cpu_F0s,
cpu_F1s, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i32(frd);
}
break;
case 14: /* fconst */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
n = (insn << 12) & 0x80000000;
i = ((insn >> 12) & 0x70) | (insn & 0xf);
if (dp) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15: /* extension space */
switch (rn) {
case 0: /* cpy */
/* no-op */
break;
case 1: /* abs */
gen_vfp_abs(dp);
break;
case 2: /* neg */
gen_vfp_neg(dp);
break;
case 3: /* sqrt */
gen_vfp_sqrt(dp);
break;
case 4: /* vcvtb.f32.f16 */
tmp = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp, tmp);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 5: /* vcvtt.f32.f16 */
tmp = gen_vfp_mrs();
tcg_gen_shri_i32(tmp, tmp, 16);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 6: /* vcvtb.f16.f32 */
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 7: /* vcvtt.f16.f32 */
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp, tmp, 16);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp2, tmp2);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 8: /* cmp */
gen_vfp_cmp(dp);
break;
case 9: /* cmpe */
gen_vfp_cmpe(dp);
break;
case 10: /* cmpz */
gen_vfp_cmp(dp);
break;
case 11: /* cmpez */
gen_vfp_F1_ld0(dp);
gen_vfp_cmpe(dp);
break;
case 15: /* single<->double conversion */
if (dp)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16: /* fuito */
gen_vfp_uito(dp, 0);
break;
case 17: /* fsito */
gen_vfp_sito(dp, 0);
break;
case 20: /* fshto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(dp, 16 - rm, 0);
break;
case 21: /* fslto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(dp, 32 - rm, 0);
break;
case 22: /* fuhto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(dp, 16 - rm, 0);
break;
case 23: /* fulto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(dp, 32 - rm, 0);
break;
case 24: /* ftoui */
gen_vfp_toui(dp, 0);
break;
case 25: /* ftouiz */
gen_vfp_touiz(dp, 0);
break;
case 26: /* ftosi */
gen_vfp_tosi(dp, 0);
break;
case 27: /* ftosiz */
gen_vfp_tosiz(dp, 0);
break;
case 28: /* ftosh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(dp, 16 - rm, 0);
break;
case 29: /* ftosl */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(dp, 32 - rm, 0);
break;
case 30: /* ftouh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(dp, 16 - rm, 0);
break;
case 31: /* ftoul */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(dp, 32 - rm, 0);
break;
default: /* undefined */
return 1;
}
break;
default: /* undefined */
return 1;
}
/* Write back the result. */
if (op == 15 && (rn >= 8 && rn <= 11))
; /* Comparison, do nothing. */
else if (op == 15 && dp && ((rn & 0x1c) == 0x18))
/* VCVT double to int: always integer result. */
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
/* conversion */
gen_mov_vreg_F0(!dp, rd);
else
gen_mov_vreg_F0(dp, rd);
/* break out of the loop if we have finished */
if (veclen == 0)
break;
if (op == 15 && delta_m == 0) {
/* single source one-many */
while (veclen--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(dp, rd);
}
break;
}
/* Setup the next operands. */
veclen--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
/* One source operand. */
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(dp, rm);
} else {
/* Two source operands. */
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(dp, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(dp, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if ((insn & 0x03e00000) == 0x00400000) {
/* two-register transfer */
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (dp) {
VFP_DREG_M(rm, insn);
} else {
rm = VFP_SREG_M(insn);
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (dp) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
}
} else {
/* arm->vfp */
if (dp) {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
/* Load/store */
rn = (insn >> 16) & 0xf;
if (dp)
VFP_DREG_D(rd, insn);
else
rd = VFP_SREG_D(insn);
if ((insn & 0x01200000) == 0x01000000) {
/* Single load/store */
offset = (insn & 0xff) << 2;
if ((insn & (1 << 23)) == 0)
offset = -offset;
if (s->thumb && rn == 15) {
/* This is actually UNPREDICTABLE */
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
tcg_gen_addi_i32(addr, addr, offset);
if (insn & (1 << 20)) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd);
} else {
gen_mov_F0_vreg(dp, rd);
gen_vfp_st(s, dp, addr);
}
tcg_temp_free_i32(addr);
} else {
/* load/store multiple */
int w = insn & (1 << 21);
if (dp)
n = (insn >> 1) & 0x7f;
else
n = insn & 0xff;
if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) {
/* P == U , W == 1 => UNDEF */
return 1;
}
if (n == 0 || (rd + n) > 32 || (dp && n > 16)) {
/* UNPREDICTABLE cases for bad immediates: we choose to
* UNDEF to avoid generating huge numbers of TCG ops
*/
return 1;
}
if (rn == 15 && w) {
/* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
return 1;
}
if (s->thumb && rn == 15) {
/* This is actually UNPREDICTABLE */
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
if (insn & (1 << 24)) /* pre-decrement */
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
if (dp)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (insn & ARM_CP_RW_BIT) {
/* load */
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd + i);
} else {
/* store */
gen_mov_F0_vreg(dp, rd + i);
gen_vfp_st(s, dp, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (w) {
/* writeback */
if (insn & (1 << 24))
offset = -offset * n;
else if (dp && (insn & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
default:
/* Should never happen. */
return 1;
}
return 0;
}
| true | qemu | e4c1cfa5cb8f8bfbbfd949f2fabbe2be35e60c99 | static int disas_vfp_insn(CPUARMState * env, DisasContext *s, uint32_t insn)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int dp, veclen;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(env, ARM_FEATURE_VFP))
return 1;
if (!s->vfp_enabled) {
if ((insn & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (insn >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
dp = ((insn & 0xf00) == 0xb00);
switch ((insn >> 24) & 0xf) {
case 0xe:
if (insn & (1 << 4)) {
rd = (insn >> 12) & 0xf;
if (dp) {
int size;
int pass;
VFP_DREG_N(rn, insn);
if (insn & 0xf)
return 1;
if (insn & 0x00c00060
&& !arm_feature(env, ARM_FEATURE_NEON))
return 1;
pass = (insn >> 21) & 1;
if (insn & (1 << 22)) {
size = 0;
offset = ((insn >> 5) & 3) * 8;
} else if (insn & (1 << 5)) {
size = 1;
offset = (insn & (1 << 6)) ? 16 : 0;
} else {
size = 2;
offset = 0;
}
if (insn & ARM_CP_RW_BIT) {
tmp = neon_load_reg(rn, pass);
switch (size) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (insn & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (insn & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
if (insn & (1 << 23)) {
if (size == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (size == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= pass * 2; n++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
switch (size) {
case 0:
tmp2 = neon_load_reg(rn, pass);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);
tcg_temp_free_i32(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, pass);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);
tcg_temp_free_i32(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, pass, tmp);
}
}
} else {
if ((insn & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(insn);
if (insn & ARM_CP_RW_BIT) {
if (insn & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
if (IS_USER(s)
&& arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
if (IS_USER(s)
|| arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = tcg_temp_new_i32();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(s)
|| !arm_feature(env, ARM_FEATURE_MVFR))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
}
} else {
tmp = load_reg(s, rd);
if (insn & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tcg_gen_andi_i32(tmp, tmp, 1 << 30);
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(s);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1);
if (dp) {
if (op == 15) {
rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1);
} else {
VFP_DREG_N(rn, insn);
}
if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) {
rd = VFP_SREG_D(insn);
} else {
VFP_DREG_D(rd, insn);
}
if (op == 15 &&
(((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) {
rm = VFP_SREG_M(insn);
} else {
VFP_DREG_M(rm, insn);
}
} else {
rn = VFP_SREG_N(insn);
if (op == 15 && rn == 15) {
VFP_DREG_D(rd, insn);
} else {
rd = VFP_SREG_D(insn);
}
rm = VFP_SREG_M(insn);
}
veclen = s->vec_len;
if (op == 15 && rn > 3)
veclen = 0;
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (veclen > 0) {
if (dp)
bank_mask = 0xc;
else
bank_mask = 0x18;
if ((rd & bank_mask) == 0) {
veclen = 0;
} else {
if (dp)
delta_d = (s->vec_stride >> 1) + 1;
else
delta_d = s->vec_stride + 1;
if ((rm & bank_mask) == 0) {
delta_m = 0;
} else {
delta_m = delta_d;
}
}
}
if (op == 15) {
switch (rn) {
case 16:
case 17:
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
gen_mov_F0_vreg(dp, rd);
gen_mov_F1_vreg(dp, rm);
break;
case 10:
case 11:
gen_mov_F0_vreg(dp, rd);
gen_vfp_F1_ld0(dp);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
gen_mov_F0_vreg(dp, rd);
break;
case 4:
case 5:
case 6:
case 7:
if (dp || !arm_feature(env, ARM_FEATURE_VFP_FP16)) {
return 1;
}
default:
gen_mov_F0_vreg(dp, rm);
break;
}
} else {
gen_mov_F0_vreg(dp, rn);
gen_mov_F1_vreg(dp, rm);
}
for (;;) {
switch (op) {
case 0:
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 1:
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 2:
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 3:
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 4:
gen_vfp_mul(dp);
break;
case 5:
gen_vfp_mul(dp);
gen_vfp_neg(dp);
break;
case 6:
gen_vfp_add(dp);
break;
case 7:
gen_vfp_sub(dp);
break;
case 8:
gen_vfp_div(dp);
break;
case 10:
case 11:
case 12:
case 13:
if (!arm_feature(env, ARM_FEATURE_VFP4)) {
return 1;
}
if (dp) {
TCGv_ptr fpst;
TCGv_i64 frd;
if (op & 1) {
gen_helper_vfp_negd(cpu_F0d, cpu_F0d);
}
frd = tcg_temp_new_i64();
tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(dp, rd));
if (op & 2) {
gen_helper_vfp_negd(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d,
cpu_F1d, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i64(frd);
} else {
TCGv_ptr fpst;
TCGv_i32 frd;
if (op & 1) {
gen_helper_vfp_negs(cpu_F0s, cpu_F0s);
}
frd = tcg_temp_new_i32();
tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(dp, rd));
if (op & 2) {
gen_helper_vfp_negs(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladds(cpu_F0s, cpu_F0s,
cpu_F1s, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i32(frd);
}
break;
case 14:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
n = (insn << 12) & 0x80000000;
i = ((insn >> 12) & 0x70) | (insn & 0xf);
if (dp) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15:
switch (rn) {
case 0:
break;
case 1:
gen_vfp_abs(dp);
break;
case 2:
gen_vfp_neg(dp);
break;
case 3:
gen_vfp_sqrt(dp);
break;
case 4:
tmp = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp, tmp);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 5:
tmp = gen_vfp_mrs();
tcg_gen_shri_i32(tmp, tmp, 16);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 6:
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 7:
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp, tmp, 16);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp2, tmp2);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 8:
gen_vfp_cmp(dp);
break;
case 9:
gen_vfp_cmpe(dp);
break;
case 10:
gen_vfp_cmp(dp);
break;
case 11:
gen_vfp_F1_ld0(dp);
gen_vfp_cmpe(dp);
break;
case 15:
if (dp)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16:
gen_vfp_uito(dp, 0);
break;
case 17:
gen_vfp_sito(dp, 0);
break;
case 20:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(dp, 16 - rm, 0);
break;
case 21:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(dp, 32 - rm, 0);
break;
case 22:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(dp, 16 - rm, 0);
break;
case 23:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(dp, 32 - rm, 0);
break;
case 24:
gen_vfp_toui(dp, 0);
break;
case 25:
gen_vfp_touiz(dp, 0);
break;
case 26:
gen_vfp_tosi(dp, 0);
break;
case 27:
gen_vfp_tosiz(dp, 0);
break;
case 28:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(dp, 16 - rm, 0);
break;
case 29:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(dp, 32 - rm, 0);
break;
case 30:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(dp, 16 - rm, 0);
break;
case 31:
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(dp, 32 - rm, 0);
break;
default:
return 1;
}
break;
default:
return 1;
}
if (op == 15 && (rn >= 8 && rn <= 11))
;
else if (op == 15 && dp && ((rn & 0x1c) == 0x18))
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
gen_mov_vreg_F0(!dp, rd);
else
gen_mov_vreg_F0(dp, rd);
if (veclen == 0)
break;
if (op == 15 && delta_m == 0) {
while (veclen--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(dp, rd);
}
break;
}
veclen--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(dp, rm);
} else {
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(dp, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(dp, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if ((insn & 0x03e00000) == 0x00400000) {
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (dp) {
VFP_DREG_M(rm, insn);
} else {
rm = VFP_SREG_M(insn);
}
if (insn & ARM_CP_RW_BIT) {
if (dp) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
}
} else {
if (dp) {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
rn = (insn >> 16) & 0xf;
if (dp)
VFP_DREG_D(rd, insn);
else
rd = VFP_SREG_D(insn);
if ((insn & 0x01200000) == 0x01000000) {
offset = (insn & 0xff) << 2;
if ((insn & (1 << 23)) == 0)
offset = -offset;
if (s->thumb && rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
tcg_gen_addi_i32(addr, addr, offset);
if (insn & (1 << 20)) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd);
} else {
gen_mov_F0_vreg(dp, rd);
gen_vfp_st(s, dp, addr);
}
tcg_temp_free_i32(addr);
} else {
int w = insn & (1 << 21);
if (dp)
n = (insn >> 1) & 0x7f;
else
n = insn & 0xff;
if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) {
return 1;
}
if (n == 0 || (rd + n) > 32 || (dp && n > 16)) {
return 1;
}
if (rn == 15 && w) {
return 1;
}
if (s->thumb && rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
if (insn & (1 << 24))
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
if (dp)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (insn & ARM_CP_RW_BIT) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd + i);
} else {
gen_mov_F0_vreg(dp, rd + i);
gen_vfp_st(s, dp, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (w) {
if (insn & (1 << 24))
offset = -offset * n;
else if (dp && (insn & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
default:
return 1;
}
return 0;
}
| {
"code": [
" tmp = load_reg(s, rd);"
],
"line_no": [
163
]
} | static int FUNC_0(CPUARMState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int VAR_3, VAR_4;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(VAR_0, ARM_FEATURE_VFP))
return 1;
if (!VAR_1->vfp_enabled) {
if ((VAR_2 & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (VAR_2 >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
VAR_3 = ((VAR_2 & 0xf00) == 0xb00);
switch ((VAR_2 >> 24) & 0xf) {
case 0xe:
if (VAR_2 & (1 << 4)) {
rd = (VAR_2 >> 12) & 0xf;
if (VAR_3) {
int VAR_5;
int VAR_6;
VFP_DREG_N(rn, VAR_2);
if (VAR_2 & 0xf)
return 1;
if (VAR_2 & 0x00c00060
&& !arm_feature(VAR_0, ARM_FEATURE_NEON))
return 1;
VAR_6 = (VAR_2 >> 21) & 1;
if (VAR_2 & (1 << 22)) {
VAR_5 = 0;
offset = ((VAR_2 >> 5) & 3) * 8;
} else if (VAR_2 & (1 << 5)) {
VAR_5 = 1;
offset = (VAR_2 & (1 << 6)) ? 16 : 0;
} else {
VAR_5 = 2;
offset = 0;
}
if (VAR_2 & ARM_CP_RW_BIT) {
tmp = neon_load_reg(rn, VAR_6);
switch (VAR_5) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (VAR_2 & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (VAR_2 & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
if (VAR_2 & (1 << 23)) {
if (VAR_5 == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (VAR_5 == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= VAR_6 * 2; n++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
switch (VAR_5) {
case 0:
tmp2 = neon_load_reg(rn, VAR_6);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);
tcg_temp_free_i32(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, VAR_6);
tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);
tcg_temp_free_i32(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, VAR_6, tmp);
}
}
} else {
if ((VAR_2 & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(VAR_2);
if (VAR_2 & ARM_CP_RW_BIT) {
if (VAR_2 & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
if (IS_USER(VAR_1)
&& arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(VAR_1))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
if (IS_USER(VAR_1)
|| arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = tcg_temp_new_i32();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(VAR_1)
|| !arm_feature(VAR_0, ARM_FEATURE_MVFR))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp);
} else {
store_reg(VAR_1, rd, tmp);
}
} else {
tmp = load_reg(VAR_1, rd);
if (VAR_2 & (1 << 21)) {
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
tcg_temp_free_i32(tmp);
gen_lookup_tb(VAR_1);
break;
case ARM_VFP_FPEXC:
if (IS_USER(VAR_1))
return 1;
tcg_gen_andi_i32(tmp, tmp, 1 << 30);
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(VAR_1);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
op = ((VAR_2 >> 20) & 8) | ((VAR_2 >> 19) & 6) | ((VAR_2 >> 6) & 1);
if (VAR_3) {
if (op == 15) {
rn = ((VAR_2 >> 15) & 0x1e) | ((VAR_2 >> 7) & 1);
} else {
VFP_DREG_N(rn, VAR_2);
}
if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) {
rd = VFP_SREG_D(VAR_2);
} else {
VFP_DREG_D(rd, VAR_2);
}
if (op == 15 &&
(((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) {
rm = VFP_SREG_M(VAR_2);
} else {
VFP_DREG_M(rm, VAR_2);
}
} else {
rn = VFP_SREG_N(VAR_2);
if (op == 15 && rn == 15) {
VFP_DREG_D(rd, VAR_2);
} else {
rd = VFP_SREG_D(VAR_2);
}
rm = VFP_SREG_M(VAR_2);
}
VAR_4 = VAR_1->vec_len;
if (op == 15 && rn > 3)
VAR_4 = 0;
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (VAR_4 > 0) {
if (VAR_3)
bank_mask = 0xc;
else
bank_mask = 0x18;
if ((rd & bank_mask) == 0) {
VAR_4 = 0;
} else {
if (VAR_3)
delta_d = (VAR_1->vec_stride >> 1) + 1;
else
delta_d = VAR_1->vec_stride + 1;
if ((rm & bank_mask) == 0) {
delta_m = 0;
} else {
delta_m = delta_d;
}
}
}
if (op == 15) {
switch (rn) {
case 16:
case 17:
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
gen_mov_F0_vreg(VAR_3, rd);
gen_mov_F1_vreg(VAR_3, rm);
break;
case 10:
case 11:
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_F1_ld0(VAR_3);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
gen_mov_F0_vreg(VAR_3, rd);
break;
case 4:
case 5:
case 6:
case 7:
if (VAR_3 || !arm_feature(VAR_0, ARM_FEATURE_VFP_FP16)) {
return 1;
}
default:
gen_mov_F0_vreg(VAR_3, rm);
break;
}
} else {
gen_mov_F0_vreg(VAR_3, rn);
gen_mov_F1_vreg(VAR_3, rm);
}
for (;;) {
switch (op) {
case 0:
gen_vfp_F1_mul(VAR_3);
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_add(VAR_3);
break;
case 1:
gen_vfp_mul(VAR_3);
gen_vfp_F1_neg(VAR_3);
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_add(VAR_3);
break;
case 2:
gen_vfp_F1_mul(VAR_3);
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_neg(VAR_3);
gen_vfp_add(VAR_3);
break;
case 3:
gen_vfp_mul(VAR_3);
gen_vfp_F1_neg(VAR_3);
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_neg(VAR_3);
gen_vfp_add(VAR_3);
break;
case 4:
gen_vfp_mul(VAR_3);
break;
case 5:
gen_vfp_mul(VAR_3);
gen_vfp_neg(VAR_3);
break;
case 6:
gen_vfp_add(VAR_3);
break;
case 7:
gen_vfp_sub(VAR_3);
break;
case 8:
gen_vfp_div(VAR_3);
break;
case 10:
case 11:
case 12:
case 13:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP4)) {
return 1;
}
if (VAR_3) {
TCGv_ptr fpst;
TCGv_i64 frd;
if (op & 1) {
gen_helper_vfp_negd(cpu_F0d, cpu_F0d);
}
frd = tcg_temp_new_i64();
tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(VAR_3, rd));
if (op & 2) {
gen_helper_vfp_negd(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d,
cpu_F1d, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i64(frd);
} else {
TCGv_ptr fpst;
TCGv_i32 frd;
if (op & 1) {
gen_helper_vfp_negs(cpu_F0s, cpu_F0s);
}
frd = tcg_temp_new_i32();
tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(VAR_3, rd));
if (op & 2) {
gen_helper_vfp_negs(frd, frd);
}
fpst = get_fpstatus_ptr(0);
gen_helper_vfp_muladds(cpu_F0s, cpu_F0s,
cpu_F1s, frd, fpst);
tcg_temp_free_ptr(fpst);
tcg_temp_free_i32(frd);
}
break;
case 14:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
n = (VAR_2 << 12) & 0x80000000;
i = ((VAR_2 >> 12) & 0x70) | (VAR_2 & 0xf);
if (VAR_3) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15:
switch (rn) {
case 0:
break;
case 1:
gen_vfp_abs(VAR_3);
break;
case 2:
gen_vfp_neg(VAR_3);
break;
case 3:
gen_vfp_sqrt(VAR_3);
break;
case 4:
tmp = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp, tmp);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 5:
tmp = gen_vfp_mrs();
tcg_gen_shri_i32(tmp, tmp, 16);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 6:
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 7:
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp, tmp, 16);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp2, tmp2);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 8:
gen_vfp_cmp(VAR_3);
break;
case 9:
gen_vfp_cmpe(VAR_3);
break;
case 10:
gen_vfp_cmp(VAR_3);
break;
case 11:
gen_vfp_F1_ld0(VAR_3);
gen_vfp_cmpe(VAR_3);
break;
case 15:
if (VAR_3)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16:
gen_vfp_uito(VAR_3, 0);
break;
case 17:
gen_vfp_sito(VAR_3, 0);
break;
case 20:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(VAR_3, 16 - rm, 0);
break;
case 21:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(VAR_3, 32 - rm, 0);
break;
case 22:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(VAR_3, 16 - rm, 0);
break;
case 23:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(VAR_3, 32 - rm, 0);
break;
case 24:
gen_vfp_toui(VAR_3, 0);
break;
case 25:
gen_vfp_touiz(VAR_3, 0);
break;
case 26:
gen_vfp_tosi(VAR_3, 0);
break;
case 27:
gen_vfp_tosiz(VAR_3, 0);
break;
case 28:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(VAR_3, 16 - rm, 0);
break;
case 29:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(VAR_3, 32 - rm, 0);
break;
case 30:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(VAR_3, 16 - rm, 0);
break;
case 31:
if (!arm_feature(VAR_0, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(VAR_3, 32 - rm, 0);
break;
default:
return 1;
}
break;
default:
return 1;
}
if (op == 15 && (rn >= 8 && rn <= 11))
;
else if (op == 15 && VAR_3 && ((rn & 0x1c) == 0x18))
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
gen_mov_vreg_F0(!VAR_3, rd);
else
gen_mov_vreg_F0(VAR_3, rd);
if (VAR_4 == 0)
break;
if (op == 15 && delta_m == 0) {
while (VAR_4--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(VAR_3, rd);
}
break;
}
VAR_4--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(VAR_3, rm);
} else {
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(VAR_3, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(VAR_3, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if ((VAR_2 & 0x03e00000) == 0x00400000) {
rn = (VAR_2 >> 16) & 0xf;
rd = (VAR_2 >> 12) & 0xf;
if (VAR_3) {
VFP_DREG_M(rm, VAR_2);
} else {
rm = VFP_SREG_M(VAR_2);
}
if (VAR_2 & ARM_CP_RW_BIT) {
if (VAR_3) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rd, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(VAR_1, rn, tmp);
}
} else {
if (VAR_3) {
tmp = load_reg(VAR_1, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(VAR_1, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(VAR_1, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(VAR_1, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
rn = (VAR_2 >> 16) & 0xf;
if (VAR_3)
VFP_DREG_D(rd, VAR_2);
else
rd = VFP_SREG_D(VAR_2);
if ((VAR_2 & 0x01200000) == 0x01000000) {
offset = (VAR_2 & 0xff) << 2;
if ((VAR_2 & (1 << 23)) == 0)
offset = -offset;
if (VAR_1->thumb && rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, VAR_1->pc & ~2);
} else {
addr = load_reg(VAR_1, rn);
}
tcg_gen_addi_i32(addr, addr, offset);
if (VAR_2 & (1 << 20)) {
gen_vfp_ld(VAR_1, VAR_3, addr);
gen_mov_vreg_F0(VAR_3, rd);
} else {
gen_mov_F0_vreg(VAR_3, rd);
gen_vfp_st(VAR_1, VAR_3, addr);
}
tcg_temp_free_i32(addr);
} else {
int VAR_7 = VAR_2 & (1 << 21);
if (VAR_3)
n = (VAR_2 >> 1) & 0x7f;
else
n = VAR_2 & 0xff;
if (VAR_7 && !(((VAR_2 >> 23) ^ (VAR_2 >> 24)) & 1)) {
return 1;
}
if (n == 0 || (rd + n) > 32 || (VAR_3 && n > 16)) {
return 1;
}
if (rn == 15 && VAR_7) {
return 1;
}
if (VAR_1->thumb && rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, VAR_1->pc & ~2);
} else {
addr = load_reg(VAR_1, rn);
}
if (VAR_2 & (1 << 24))
tcg_gen_addi_i32(addr, addr, -((VAR_2 & 0xff) << 2));
if (VAR_3)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (VAR_2 & ARM_CP_RW_BIT) {
gen_vfp_ld(VAR_1, VAR_3, addr);
gen_mov_vreg_F0(VAR_3, rd + i);
} else {
gen_mov_F0_vreg(VAR_3, rd + i);
gen_vfp_st(VAR_1, VAR_3, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (VAR_7) {
if (VAR_2 & (1 << 24))
offset = -offset * n;
else if (VAR_3 && (VAR_2 & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(VAR_1, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
default:
return 1;
}
return 0;
}
| [
"static int FUNC_0(CPUARMState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2)\n{",
"uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;",
"int VAR_3, VAR_4;",
"TCGv addr;",
"TCGv tmp;",
"TCGv tmp2;",
"if (!arm_feature(VAR_0, ARM_FEATURE_VFP))\nreturn 1;",
"if (!VAR_1->vfp_enabled) {",
"if ((VAR_2 & 0x0fe00fff) != 0x0ee00a10)\nreturn 1;",
"rn = (VAR_2 >> 16) & 0xf;",
"if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC\n&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)\nreturn 1;",
"}",
"VAR_3 = ((VAR_2 & 0xf00) == 0xb00);",
"switch ((VAR_2 >> 24) & 0xf) {",
"case 0xe:\nif (VAR_2 & (1 << 4)) {",
"rd = (VAR_2 >> 12) & 0xf;",
"if (VAR_3) {",
"int VAR_5;",
"int VAR_6;",
"VFP_DREG_N(rn, VAR_2);",
"if (VAR_2 & 0xf)\nreturn 1;",
"if (VAR_2 & 0x00c00060\n&& !arm_feature(VAR_0, ARM_FEATURE_NEON))\nreturn 1;",
"VAR_6 = (VAR_2 >> 21) & 1;",
"if (VAR_2 & (1 << 22)) {",
"VAR_5 = 0;",
"offset = ((VAR_2 >> 5) & 3) * 8;",
"} else if (VAR_2 & (1 << 5)) {",
"VAR_5 = 1;",
"offset = (VAR_2 & (1 << 6)) ? 16 : 0;",
"} else {",
"VAR_5 = 2;",
"offset = 0;",
"}",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"tmp = neon_load_reg(rn, VAR_6);",
"switch (VAR_5) {",
"case 0:\nif (offset)\ntcg_gen_shri_i32(tmp, tmp, offset);",
"if (VAR_2 & (1 << 23))\ngen_uxtb(tmp);",
"else\ngen_sxtb(tmp);",
"break;",
"case 1:\nif (VAR_2 & (1 << 23)) {",
"if (offset) {",
"tcg_gen_shri_i32(tmp, tmp, 16);",
"} else {",
"gen_uxth(tmp);",
"}",
"} else {",
"if (offset) {",
"tcg_gen_sari_i32(tmp, tmp, 16);",
"} else {",
"gen_sxth(tmp);",
"}",
"}",
"break;",
"case 2:\nbreak;",
"}",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"if (VAR_2 & (1 << 23)) {",
"if (VAR_5 == 0) {",
"gen_neon_dup_u8(tmp, 0);",
"} else if (VAR_5 == 1) {",
"gen_neon_dup_low16(tmp);",
"}",
"for (n = 0; n <= VAR_6 * 2; n++) {",
"tmp2 = tcg_temp_new_i32();",
"tcg_gen_mov_i32(tmp2, tmp);",
"neon_store_reg(rn, n, tmp2);",
"}",
"neon_store_reg(rn, n, tmp);",
"} else {",
"switch (VAR_5) {",
"case 0:\ntmp2 = neon_load_reg(rn, VAR_6);",
"tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8);",
"tcg_temp_free_i32(tmp2);",
"break;",
"case 1:\ntmp2 = neon_load_reg(rn, VAR_6);",
"tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16);",
"tcg_temp_free_i32(tmp2);",
"break;",
"case 2:\nbreak;",
"}",
"neon_store_reg(rn, VAR_6, tmp);",
"}",
"}",
"} else {",
"if ((VAR_2 & 0x6f) != 0x00)\nreturn 1;",
"rn = VFP_SREG_N(VAR_2);",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"if (VAR_2 & (1 << 21)) {",
"rn >>= 1;",
"switch (rn) {",
"case ARM_VFP_FPSID:\nif (IS_USER(VAR_1)\n&& arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPEXC:\nif (IS_USER(VAR_1))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPINST:\ncase ARM_VFP_FPINST2:\nif (IS_USER(VAR_1)\n|| arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"case ARM_VFP_FPSCR:\nif (rd == 15) {",
"tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);",
"tcg_gen_andi_i32(tmp, tmp, 0xf0000000);",
"} else {",
"tmp = tcg_temp_new_i32();",
"gen_helper_vfp_get_fpscr(tmp, cpu_env);",
"}",
"break;",
"case ARM_VFP_MVFR0:\ncase ARM_VFP_MVFR1:\nif (IS_USER(VAR_1)\n|| !arm_feature(VAR_0, ARM_FEATURE_MVFR))\nreturn 1;",
"tmp = load_cpu_field(vfp.xregs[rn]);",
"break;",
"default:\nreturn 1;",
"}",
"} else {",
"gen_mov_F0_vreg(0, rn);",
"tmp = gen_vfp_mrs();",
"}",
"if (rd == 15) {",
"gen_set_nzcv(tmp);",
"tcg_temp_free_i32(tmp);",
"} else {",
"store_reg(VAR_1, rd, tmp);",
"}",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"if (VAR_2 & (1 << 21)) {",
"rn >>= 1;",
"switch (rn) {",
"case ARM_VFP_FPSID:\ncase ARM_VFP_MVFR0:\ncase ARM_VFP_MVFR1:\nbreak;",
"case ARM_VFP_FPSCR:\ngen_helper_vfp_set_fpscr(cpu_env, tmp);",
"tcg_temp_free_i32(tmp);",
"gen_lookup_tb(VAR_1);",
"break;",
"case ARM_VFP_FPEXC:\nif (IS_USER(VAR_1))\nreturn 1;",
"tcg_gen_andi_i32(tmp, tmp, 1 << 30);",
"store_cpu_field(tmp, vfp.xregs[rn]);",
"gen_lookup_tb(VAR_1);",
"break;",
"case ARM_VFP_FPINST:\ncase ARM_VFP_FPINST2:\nstore_cpu_field(tmp, vfp.xregs[rn]);",
"break;",
"default:\nreturn 1;",
"}",
"} else {",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rn);",
"}",
"}",
"}",
"} else {",
"op = ((VAR_2 >> 20) & 8) | ((VAR_2 >> 19) & 6) | ((VAR_2 >> 6) & 1);",
"if (VAR_3) {",
"if (op == 15) {",
"rn = ((VAR_2 >> 15) & 0x1e) | ((VAR_2 >> 7) & 1);",
"} else {",
"VFP_DREG_N(rn, VAR_2);",
"}",
"if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) {",
"rd = VFP_SREG_D(VAR_2);",
"} else {",
"VFP_DREG_D(rd, VAR_2);",
"}",
"if (op == 15 &&\n(((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) {",
"rm = VFP_SREG_M(VAR_2);",
"} else {",
"VFP_DREG_M(rm, VAR_2);",
"}",
"} else {",
"rn = VFP_SREG_N(VAR_2);",
"if (op == 15 && rn == 15) {",
"VFP_DREG_D(rd, VAR_2);",
"} else {",
"rd = VFP_SREG_D(VAR_2);",
"}",
"rm = VFP_SREG_M(VAR_2);",
"}",
"VAR_4 = VAR_1->vec_len;",
"if (op == 15 && rn > 3)\nVAR_4 = 0;",
"delta_m = 0;",
"delta_d = 0;",
"bank_mask = 0;",
"if (VAR_4 > 0) {",
"if (VAR_3)\nbank_mask = 0xc;",
"else\nbank_mask = 0x18;",
"if ((rd & bank_mask) == 0) {",
"VAR_4 = 0;",
"} else {",
"if (VAR_3)\ndelta_d = (VAR_1->vec_stride >> 1) + 1;",
"else\ndelta_d = VAR_1->vec_stride + 1;",
"if ((rm & bank_mask) == 0) {",
"delta_m = 0;",
"} else {",
"delta_m = delta_d;",
"}",
"}",
"}",
"if (op == 15) {",
"switch (rn) {",
"case 16:\ncase 17:\ngen_mov_F0_vreg(0, rm);",
"break;",
"case 8:\ncase 9:\ngen_mov_F0_vreg(VAR_3, rd);",
"gen_mov_F1_vreg(VAR_3, rm);",
"break;",
"case 10:\ncase 11:\ngen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_F1_ld0(VAR_3);",
"break;",
"case 20:\ncase 21:\ncase 22:\ncase 23:\ncase 28:\ncase 29:\ncase 30:\ncase 31:\ngen_mov_F0_vreg(VAR_3, rd);",
"break;",
"case 4:\ncase 5:\ncase 6:\ncase 7:\nif (VAR_3 || !arm_feature(VAR_0, ARM_FEATURE_VFP_FP16)) {",
"return 1;",
"}",
"default:\ngen_mov_F0_vreg(VAR_3, rm);",
"break;",
"}",
"} else {",
"gen_mov_F0_vreg(VAR_3, rn);",
"gen_mov_F1_vreg(VAR_3, rm);",
"}",
"for (;;) {",
"switch (op) {",
"case 0:\ngen_vfp_F1_mul(VAR_3);",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_add(VAR_3);",
"break;",
"case 1:\ngen_vfp_mul(VAR_3);",
"gen_vfp_F1_neg(VAR_3);",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_add(VAR_3);",
"break;",
"case 2:\ngen_vfp_F1_mul(VAR_3);",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_neg(VAR_3);",
"gen_vfp_add(VAR_3);",
"break;",
"case 3:\ngen_vfp_mul(VAR_3);",
"gen_vfp_F1_neg(VAR_3);",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_neg(VAR_3);",
"gen_vfp_add(VAR_3);",
"break;",
"case 4:\ngen_vfp_mul(VAR_3);",
"break;",
"case 5:\ngen_vfp_mul(VAR_3);",
"gen_vfp_neg(VAR_3);",
"break;",
"case 6:\ngen_vfp_add(VAR_3);",
"break;",
"case 7:\ngen_vfp_sub(VAR_3);",
"break;",
"case 8:\ngen_vfp_div(VAR_3);",
"break;",
"case 10:\ncase 11:\ncase 12:\ncase 13:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP4)) {",
"return 1;",
"}",
"if (VAR_3) {",
"TCGv_ptr fpst;",
"TCGv_i64 frd;",
"if (op & 1) {",
"gen_helper_vfp_negd(cpu_F0d, cpu_F0d);",
"}",
"frd = tcg_temp_new_i64();",
"tcg_gen_ld_f64(frd, cpu_env, vfp_reg_offset(VAR_3, rd));",
"if (op & 2) {",
"gen_helper_vfp_negd(frd, frd);",
"}",
"fpst = get_fpstatus_ptr(0);",
"gen_helper_vfp_muladdd(cpu_F0d, cpu_F0d,\ncpu_F1d, frd, fpst);",
"tcg_temp_free_ptr(fpst);",
"tcg_temp_free_i64(frd);",
"} else {",
"TCGv_ptr fpst;",
"TCGv_i32 frd;",
"if (op & 1) {",
"gen_helper_vfp_negs(cpu_F0s, cpu_F0s);",
"}",
"frd = tcg_temp_new_i32();",
"tcg_gen_ld_f32(frd, cpu_env, vfp_reg_offset(VAR_3, rd));",
"if (op & 2) {",
"gen_helper_vfp_negs(frd, frd);",
"}",
"fpst = get_fpstatus_ptr(0);",
"gen_helper_vfp_muladds(cpu_F0s, cpu_F0s,\ncpu_F1s, frd, fpst);",
"tcg_temp_free_ptr(fpst);",
"tcg_temp_free_i32(frd);",
"}",
"break;",
"case 14:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"n = (VAR_2 << 12) & 0x80000000;",
"i = ((VAR_2 >> 12) & 0x70) | (VAR_2 & 0xf);",
"if (VAR_3) {",
"if (i & 0x40)\ni |= 0x3f80;",
"else\ni |= 0x4000;",
"n |= i << 16;",
"tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);",
"} else {",
"if (i & 0x40)\ni |= 0x780;",
"else\ni |= 0x800;",
"n |= i << 19;",
"tcg_gen_movi_i32(cpu_F0s, n);",
"}",
"break;",
"case 15:\nswitch (rn) {",
"case 0:\nbreak;",
"case 1:\ngen_vfp_abs(VAR_3);",
"break;",
"case 2:\ngen_vfp_neg(VAR_3);",
"break;",
"case 3:\ngen_vfp_sqrt(VAR_3);",
"break;",
"case 4:\ntmp = gen_vfp_mrs();",
"tcg_gen_ext16u_i32(tmp, tmp);",
"gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);",
"tcg_temp_free_i32(tmp);",
"break;",
"case 5:\ntmp = gen_vfp_mrs();",
"tcg_gen_shri_i32(tmp, tmp, 16);",
"gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);",
"tcg_temp_free_i32(tmp);",
"break;",
"case 6:\ntmp = tcg_temp_new_i32();",
"gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);",
"gen_mov_F0_vreg(0, rd);",
"tmp2 = gen_vfp_mrs();",
"tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);",
"tcg_gen_or_i32(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"gen_vfp_msr(tmp);",
"break;",
"case 7:\ntmp = tcg_temp_new_i32();",
"gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);",
"tcg_gen_shli_i32(tmp, tmp, 16);",
"gen_mov_F0_vreg(0, rd);",
"tmp2 = gen_vfp_mrs();",
"tcg_gen_ext16u_i32(tmp2, tmp2);",
"tcg_gen_or_i32(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"gen_vfp_msr(tmp);",
"break;",
"case 8:\ngen_vfp_cmp(VAR_3);",
"break;",
"case 9:\ngen_vfp_cmpe(VAR_3);",
"break;",
"case 10:\ngen_vfp_cmp(VAR_3);",
"break;",
"case 11:\ngen_vfp_F1_ld0(VAR_3);",
"gen_vfp_cmpe(VAR_3);",
"break;",
"case 15:\nif (VAR_3)\ngen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);",
"else\ngen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);",
"break;",
"case 16:\ngen_vfp_uito(VAR_3, 0);",
"break;",
"case 17:\ngen_vfp_sito(VAR_3, 0);",
"break;",
"case 20:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_shto(VAR_3, 16 - rm, 0);",
"break;",
"case 21:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_slto(VAR_3, 32 - rm, 0);",
"break;",
"case 22:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_uhto(VAR_3, 16 - rm, 0);",
"break;",
"case 23:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_ulto(VAR_3, 32 - rm, 0);",
"break;",
"case 24:\ngen_vfp_toui(VAR_3, 0);",
"break;",
"case 25:\ngen_vfp_touiz(VAR_3, 0);",
"break;",
"case 26:\ngen_vfp_tosi(VAR_3, 0);",
"break;",
"case 27:\ngen_vfp_tosiz(VAR_3, 0);",
"break;",
"case 28:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_tosh(VAR_3, 16 - rm, 0);",
"break;",
"case 29:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_tosl(VAR_3, 32 - rm, 0);",
"break;",
"case 30:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_touh(VAR_3, 16 - rm, 0);",
"break;",
"case 31:\nif (!arm_feature(VAR_0, ARM_FEATURE_VFP3))\nreturn 1;",
"gen_vfp_toul(VAR_3, 32 - rm, 0);",
"break;",
"default:\nreturn 1;",
"}",
"break;",
"default:\nreturn 1;",
"}",
"if (op == 15 && (rn >= 8 && rn <= 11))\n;",
"else if (op == 15 && VAR_3 && ((rn & 0x1c) == 0x18))\ngen_mov_vreg_F0(0, rd);",
"else if (op == 15 && rn == 15)\ngen_mov_vreg_F0(!VAR_3, rd);",
"else\ngen_mov_vreg_F0(VAR_3, rd);",
"if (VAR_4 == 0)\nbreak;",
"if (op == 15 && delta_m == 0) {",
"while (VAR_4--) {",
"rd = ((rd + delta_d) & (bank_mask - 1))\n| (rd & bank_mask);",
"gen_mov_vreg_F0(VAR_3, rd);",
"}",
"break;",
"}",
"VAR_4--;",
"rd = ((rd + delta_d) & (bank_mask - 1))\n| (rd & bank_mask);",
"if (op == 15) {",
"rm = ((rm + delta_m) & (bank_mask - 1))\n| (rm & bank_mask);",
"gen_mov_F0_vreg(VAR_3, rm);",
"} else {",
"rn = ((rn + delta_d) & (bank_mask - 1))\n| (rn & bank_mask);",
"gen_mov_F0_vreg(VAR_3, rn);",
"if (delta_m) {",
"rm = ((rm + delta_m) & (bank_mask - 1))\n| (rm & bank_mask);",
"gen_mov_F1_vreg(VAR_3, rm);",
"}",
"}",
"}",
"}",
"break;",
"case 0xc:\ncase 0xd:\nif ((VAR_2 & 0x03e00000) == 0x00400000) {",
"rn = (VAR_2 >> 16) & 0xf;",
"rd = (VAR_2 >> 12) & 0xf;",
"if (VAR_3) {",
"VFP_DREG_M(rm, VAR_2);",
"} else {",
"rm = VFP_SREG_M(VAR_2);",
"}",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"if (VAR_3) {",
"gen_mov_F0_vreg(0, rm * 2);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rd, tmp);",
"gen_mov_F0_vreg(0, rm * 2 + 1);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rn, tmp);",
"} else {",
"gen_mov_F0_vreg(0, rm);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rd, tmp);",
"gen_mov_F0_vreg(0, rm + 1);",
"tmp = gen_vfp_mrs();",
"store_reg(VAR_1, rn, tmp);",
"}",
"} else {",
"if (VAR_3) {",
"tmp = load_reg(VAR_1, rd);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm * 2);",
"tmp = load_reg(VAR_1, rn);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm * 2 + 1);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm);",
"tmp = load_reg(VAR_1, rn);",
"gen_vfp_msr(tmp);",
"gen_mov_vreg_F0(0, rm + 1);",
"}",
"}",
"} else {",
"rn = (VAR_2 >> 16) & 0xf;",
"if (VAR_3)\nVFP_DREG_D(rd, VAR_2);",
"else\nrd = VFP_SREG_D(VAR_2);",
"if ((VAR_2 & 0x01200000) == 0x01000000) {",
"offset = (VAR_2 & 0xff) << 2;",
"if ((VAR_2 & (1 << 23)) == 0)\noffset = -offset;",
"if (VAR_1->thumb && rn == 15) {",
"addr = tcg_temp_new_i32();",
"tcg_gen_movi_i32(addr, VAR_1->pc & ~2);",
"} else {",
"addr = load_reg(VAR_1, rn);",
"}",
"tcg_gen_addi_i32(addr, addr, offset);",
"if (VAR_2 & (1 << 20)) {",
"gen_vfp_ld(VAR_1, VAR_3, addr);",
"gen_mov_vreg_F0(VAR_3, rd);",
"} else {",
"gen_mov_F0_vreg(VAR_3, rd);",
"gen_vfp_st(VAR_1, VAR_3, addr);",
"}",
"tcg_temp_free_i32(addr);",
"} else {",
"int VAR_7 = VAR_2 & (1 << 21);",
"if (VAR_3)\nn = (VAR_2 >> 1) & 0x7f;",
"else\nn = VAR_2 & 0xff;",
"if (VAR_7 && !(((VAR_2 >> 23) ^ (VAR_2 >> 24)) & 1)) {",
"return 1;",
"}",
"if (n == 0 || (rd + n) > 32 || (VAR_3 && n > 16)) {",
"return 1;",
"}",
"if (rn == 15 && VAR_7) {",
"return 1;",
"}",
"if (VAR_1->thumb && rn == 15) {",
"addr = tcg_temp_new_i32();",
"tcg_gen_movi_i32(addr, VAR_1->pc & ~2);",
"} else {",
"addr = load_reg(VAR_1, rn);",
"}",
"if (VAR_2 & (1 << 24))\ntcg_gen_addi_i32(addr, addr, -((VAR_2 & 0xff) << 2));",
"if (VAR_3)\noffset = 8;",
"else\noffset = 4;",
"for (i = 0; i < n; i++) {",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"gen_vfp_ld(VAR_1, VAR_3, addr);",
"gen_mov_vreg_F0(VAR_3, rd + i);",
"} else {",
"gen_mov_F0_vreg(VAR_3, rd + i);",
"gen_vfp_st(VAR_1, VAR_3, addr);",
"}",
"tcg_gen_addi_i32(addr, addr, offset);",
"}",
"if (VAR_7) {",
"if (VAR_2 & (1 << 24))\noffset = -offset * n;",
"else if (VAR_3 && (VAR_2 & 1))\noffset = 4;",
"else\noffset = 0;",
"if (offset != 0)\ntcg_gen_addi_i32(addr, addr, offset);",
"store_reg(VAR_1, rn, addr);",
"} else {",
"tcg_temp_free_i32(addr);",
"}",
"}",
"}",
"break;",
"default:\nreturn 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
27,
29
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67,
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111,
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
241
],
[
245
],
[
249
],
[
251,
259,
261,
263
],
[
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
277
],
[
279,
281,
285,
287,
289
],
[
291
],
[
293
],
[
295,
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313,
315,
317,
319,
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
367
],
[
369,
371,
373,
377
],
[
379,
381
],
[
383
],
[
385
],
[
387
],
[
389,
391,
393
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409,
411
],
[
413
],
[
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
439
],
[
441
],
[
443
],
[
447
],
[
449
],
[
453
],
[
455
],
[
459
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471,
473
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497
],
[
499
],
[
501
],
[
503
],
[
511
],
[
513
],
[
517
],
[
519,
521
],
[
527
],
[
529
],
[
531
],
[
535
],
[
537,
539
],
[
541,
543
],
[
549
],
[
553
],
[
555
],
[
557,
559
],
[
561,
563
],
[
567
],
[
571
],
[
573
],
[
577
],
[
579
],
[
581
],
[
583
],
[
589
],
[
591
],
[
593,
595,
599
],
[
601
],
[
603,
605,
609
],
[
611
],
[
613
],
[
615,
617,
621
],
[
623
],
[
625
],
[
627,
629,
631,
633,
635,
637,
639,
641,
645
],
[
647
],
[
649,
651,
653,
655,
663
],
[
665
],
[
667
],
[
671,
675
],
[
677
],
[
679
],
[
681
],
[
685
],
[
687
],
[
689
],
[
693
],
[
697
],
[
699,
703
],
[
705
],
[
707
],
[
709
],
[
711,
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723,
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743,
745
],
[
747
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757,
759
],
[
761
],
[
763,
765
],
[
767
],
[
769
],
[
771,
773
],
[
775
],
[
777,
779
],
[
781
],
[
783,
785
],
[
787
],
[
789,
791,
793,
795,
811
],
[
813
],
[
815
],
[
817
],
[
819
],
[
821
],
[
823
],
[
827
],
[
829
],
[
831
],
[
833
],
[
835
],
[
839
],
[
841
],
[
843
],
[
845,
847
],
[
849
],
[
851
],
[
853
],
[
855
],
[
857
],
[
859
],
[
863
],
[
865
],
[
867
],
[
869
],
[
871
],
[
873
],
[
875
],
[
877
],
[
879,
881
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891,
893,
895
],
[
899
],
[
901
],
[
903
],
[
905,
907
],
[
909,
911
],
[
913
],
[
915
],
[
917
],
[
919,
921
],
[
923,
925
],
[
927
],
[
929
],
[
931
],
[
933
],
[
935,
937
],
[
939,
943
],
[
945,
947
],
[
949
],
[
951,
953
],
[
955
],
[
957,
959
],
[
961
],
[
963,
965
],
[
967
],
[
969
],
[
971
],
[
973
],
[
975,
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987,
989
],
[
991
],
[
993
],
[
995
],
[
997
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007,
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1021
],
[
1023
],
[
1025
],
[
1027
],
[
1029,
1031
],
[
1033
],
[
1035,
1037
],
[
1039
],
[
1041,
1043
],
[
1045
],
[
1047,
1049
],
[
1051
],
[
1053
],
[
1055,
1057,
1059
],
[
1061,
1063
],
[
1065
],
[
1067,
1069
],
[
1071
],
[
1073,
1075
],
[
1077
],
[
1079,
1081,
1083
],
[
1085
],
[
1087
],
[
1089,
1091,
1093
],
[
1095
],
[
1097
],
[
1099,
1101,
1103
],
[
1105
],
[
1107
],
[
1109,
1111,
1113
],
[
1115
],
[
1117
],
[
1119,
1121
],
[
1123
],
[
1125,
1127
],
[
1129
],
[
1131,
1133
],
[
1135
],
[
1137,
1139
],
[
1141
],
[
1143,
1145,
1147
],
[
1149
],
[
1151
],
[
1153,
1155,
1157
],
[
1159
],
[
1161
],
[
1163,
1165,
1167
],
[
1169
],
[
1171
],
[
1173,
1175,
1177
],
[
1179
],
[
1181
],
[
1183,
1185
],
[
1187
],
[
1189
],
[
1191,
1193
],
[
1195
],
[
1201,
1203
],
[
1205,
1209
],
[
1211,
1215
],
[
1217,
1219
],
[
1225,
1227
],
[
1231
],
[
1235
],
[
1237,
1239
],
[
1241
],
[
1243
],
[
1245
],
[
1247
],
[
1251
],
[
1253,
1255
],
[
1259
],
[
1263,
1265
],
[
1267
],
[
1269
],
[
1273,
1275
],
[
1277
],
[
1279
],
[
1281,
1283
],
[
1285
],
[
1287
],
[
1289
],
[
1291
],
[
1293
],
[
1295
],
[
1297,
1299,
1301
],
[
1305
],
[
1307
],
[
1309
],
[
1311
],
[
1313
],
[
1315
],
[
1317
],
[
1321
],
[
1325
],
[
1327
],
[
1329
],
[
1331
],
[
1333
],
[
1335
],
[
1337
],
[
1339
],
[
1341
],
[
1343
],
[
1345
],
[
1347
],
[
1349
],
[
1351
],
[
1353
],
[
1355
],
[
1359
],
[
1361
],
[
1363
],
[
1365
],
[
1367
],
[
1369
],
[
1371
],
[
1373
],
[
1375
],
[
1377
],
[
1379
],
[
1381
],
[
1383
],
[
1385
],
[
1387
],
[
1389
],
[
1391
],
[
1395
],
[
1397,
1399
],
[
1401,
1403
],
[
1405
],
[
1409
],
[
1411,
1413
],
[
1415
],
[
1419
],
[
1421
],
[
1423
],
[
1425
],
[
1427
],
[
1429
],
[
1431
],
[
1433
],
[
1435
],
[
1437
],
[
1439
],
[
1441
],
[
1443
],
[
1445
],
[
1447
],
[
1451
],
[
1453,
1455
],
[
1457,
1459
],
[
1463
],
[
1467
],
[
1469
],
[
1471
],
[
1479
],
[
1481
],
[
1483
],
[
1487
],
[
1489
],
[
1493
],
[
1497
],
[
1499
],
[
1501
],
[
1503
],
[
1505
],
[
1507,
1509
],
[
1513,
1515
],
[
1517,
1519
],
[
1521
],
[
1523
],
[
1527
],
[
1529
],
[
1531
],
[
1535
],
[
1537
],
[
1539
],
[
1541
],
[
1543
],
[
1545
],
[
1549,
1551
],
[
1553,
1555
],
[
1557,
1559
],
[
1563,
1565
],
[
1567
],
[
1569
],
[
1571
],
[
1573
],
[
1575
],
[
1577
],
[
1579
],
[
1581,
1585
],
[
1587
],
[
1589
],
[
1591
]
] |
2,495 | static void do_address_space_destroy(AddressSpace *as)
{
MemoryListener *listener;
address_space_destroy_dispatch(as);
QTAILQ_FOREACH(listener, &memory_listeners, link) {
assert(listener->address_space_filter != as);
}
flatview_unref(as->current_map);
g_free(as->name);
g_free(as->ioeventfds);
} | true | qemu | ac95190ea92f7625bb0065c2864321607b95c26b | static void do_address_space_destroy(AddressSpace *as)
{
MemoryListener *listener;
address_space_destroy_dispatch(as);
QTAILQ_FOREACH(listener, &memory_listeners, link) {
assert(listener->address_space_filter != as);
}
flatview_unref(as->current_map);
g_free(as->name);
g_free(as->ioeventfds);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(AddressSpace *VAR_0)
{
MemoryListener *listener;
address_space_destroy_dispatch(VAR_0);
QTAILQ_FOREACH(listener, &memory_listeners, link) {
assert(listener->address_space_filter != VAR_0);
}
flatview_unref(VAR_0->current_map);
g_free(VAR_0->name);
g_free(VAR_0->ioeventfds);
} | [
"static void FUNC_0(AddressSpace *VAR_0)\n{",
"MemoryListener *listener;",
"address_space_destroy_dispatch(VAR_0);",
"QTAILQ_FOREACH(listener, &memory_listeners, link) {",
"assert(listener->address_space_filter != VAR_0);",
"}",
"flatview_unref(VAR_0->current_map);",
"g_free(VAR_0->name);",
"g_free(VAR_0->ioeventfds);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
]
] |
2,497 | static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {
int i;
int cur = 0;
int skip = 0;
int len, toks;
TM2Codes codes;
/* get stream length in dwords */
len = AV_RB32(buf); buf += 4; cur += 4;
skip = len * 4 + 4;
if(len == 0)
return 4;
toks = AV_RB32(buf); buf += 4; cur += 4;
if(toks & 1) {
len = AV_RB32(buf); buf += 4; cur += 4;
if(len == TM2_ESCAPE) {
len = AV_RB32(buf); buf += 4; cur += 4;
}
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
if(tm2_read_deltas(ctx, stream_id) == -1)
return -1;
buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
}
}
/* skip unused fields */
if(AV_RB32(buf) == TM2_ESCAPE) {
buf += 4; cur += 4; /* some unknown length - could be escaped too */
}
buf += 4; cur += 4;
buf += 4; cur += 4; /* unused by decoder */
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
if(tm2_build_huff_table(ctx, &codes) == -1)
return -1;
buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
toks >>= 1;
/* check if we have sane number of tokens */
if((toks < 0) || (toks > 0xFFFFFF)){
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
tm2_free_codes(&codes);
return -1;
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
len = AV_RB32(buf); buf += 4; cur += 4;
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
for(i = 0; i < toks; i++)
ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
} else {
for(i = 0; i < toks; i++)
ctx->tokens[stream_id][i] = codes.recode[0];
}
tm2_free_codes(&codes);
return skip;
}
| true | FFmpeg | b89f4fb1908f26d2704b9496952131fffd4dafae | static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {
int i;
int cur = 0;
int skip = 0;
int len, toks;
TM2Codes codes;
len = AV_RB32(buf); buf += 4; cur += 4;
skip = len * 4 + 4;
if(len == 0)
return 4;
toks = AV_RB32(buf); buf += 4; cur += 4;
if(toks & 1) {
len = AV_RB32(buf); buf += 4; cur += 4;
if(len == TM2_ESCAPE) {
len = AV_RB32(buf); buf += 4; cur += 4;
}
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
if(tm2_read_deltas(ctx, stream_id) == -1)
return -1;
buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
}
}
if(AV_RB32(buf) == TM2_ESCAPE) {
buf += 4; cur += 4;
}
buf += 4; cur += 4;
buf += 4; cur += 4;
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
if(tm2_build_huff_table(ctx, &codes) == -1)
return -1;
buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2;
toks >>= 1;
if((toks < 0) || (toks > 0xFFFFFF)){
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
tm2_free_codes(&codes);
return -1;
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
len = AV_RB32(buf); buf += 4; cur += 4;
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
for(i = 0; i < toks; i++)
ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
} else {
for(i = 0; i < toks; i++)
ctx->tokens[stream_id][i] = codes.recode[0];
}
tm2_free_codes(&codes);
return skip;
}
| {
"code": [
"static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {",
" for(i = 0; i < toks; i++)"
],
"line_no": [
1,
107
]
} | static int FUNC_0(TM2Context *VAR_0, const uint8_t *VAR_1, int VAR_2) {
int VAR_3;
int VAR_4 = 0;
int VAR_5 = 0;
int VAR_6, VAR_7;
TM2Codes codes;
VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;
VAR_5 = VAR_6 * 4 + 4;
if(VAR_6 == 0)
return 4;
VAR_7 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;
if(VAR_7 & 1) {
VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;
if(VAR_6 == TM2_ESCAPE) {
VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;
}
if(VAR_6 > 0) {
init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);
if(tm2_read_deltas(VAR_0, VAR_2) == -1)
return -1;
VAR_1 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;
VAR_4 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;
}
}
if(AV_RB32(VAR_1) == TM2_ESCAPE) {
VAR_1 += 4; VAR_4 += 4;
}
VAR_1 += 4; VAR_4 += 4;
VAR_1 += 4; VAR_4 += 4;
init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);
if(tm2_build_huff_table(VAR_0, &codes) == -1)
return -1;
VAR_1 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;
VAR_4 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;
VAR_7 >>= 1;
if((VAR_7 < 0) || (VAR_7 > 0xFFFFFF)){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %VAR_3\n", VAR_7);
tm2_free_codes(&codes);
return -1;
}
VAR_0->tokens[VAR_2] = av_realloc(VAR_0->tokens[VAR_2], VAR_7 * sizeof(int));
VAR_0->tok_lens[VAR_2] = VAR_7;
VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;
if(VAR_6 > 0) {
init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);
for(VAR_3 = 0; VAR_3 < VAR_7; VAR_3++)
VAR_0->tokens[VAR_2][VAR_3] = tm2_get_token(&VAR_0->gb, &codes);
} else {
for(VAR_3 = 0; VAR_3 < VAR_7; VAR_3++)
VAR_0->tokens[VAR_2][VAR_3] = codes.recode[0];
}
tm2_free_codes(&codes);
return VAR_5;
}
| [
"static int FUNC_0(TM2Context *VAR_0, const uint8_t *VAR_1, int VAR_2) {",
"int VAR_3;",
"int VAR_4 = 0;",
"int VAR_5 = 0;",
"int VAR_6, VAR_7;",
"TM2Codes codes;",
"VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;",
"VAR_5 = VAR_6 * 4 + 4;",
"if(VAR_6 == 0)\nreturn 4;",
"VAR_7 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;",
"if(VAR_7 & 1) {",
"VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;",
"if(VAR_6 == TM2_ESCAPE) {",
"VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;",
"}",
"if(VAR_6 > 0) {",
"init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);",
"if(tm2_read_deltas(VAR_0, VAR_2) == -1)\nreturn -1;",
"VAR_1 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;",
"VAR_4 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;",
"}",
"}",
"if(AV_RB32(VAR_1) == TM2_ESCAPE) {",
"VAR_1 += 4; VAR_4 += 4;",
"}",
"VAR_1 += 4; VAR_4 += 4;",
"VAR_1 += 4; VAR_4 += 4;",
"init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);",
"if(tm2_build_huff_table(VAR_0, &codes) == -1)\nreturn -1;",
"VAR_1 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;",
"VAR_4 += ((get_bits_count(&VAR_0->gb) + 31) >> 5) << 2;",
"VAR_7 >>= 1;",
"if((VAR_7 < 0) || (VAR_7 > 0xFFFFFF)){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect number of tokens: %VAR_3\\n\", VAR_7);",
"tm2_free_codes(&codes);",
"return -1;",
"}",
"VAR_0->tokens[VAR_2] = av_realloc(VAR_0->tokens[VAR_2], VAR_7 * sizeof(int));",
"VAR_0->tok_lens[VAR_2] = VAR_7;",
"VAR_6 = AV_RB32(VAR_1); VAR_1 += 4; VAR_4 += 4;",
"if(VAR_6 > 0) {",
"init_get_bits(&VAR_0->gb, VAR_1, (VAR_5 - VAR_4) * 8);",
"for(VAR_3 = 0; VAR_3 < VAR_7; VAR_3++)",
"VAR_0->tokens[VAR_2][VAR_3] = tm2_get_token(&VAR_0->gb, &codes);",
"} else {",
"for(VAR_3 = 0; VAR_3 < VAR_7; VAR_3++)",
"VAR_0->tokens[VAR_2][VAR_3] = codes.recode[0];",
"}",
"tm2_free_codes(&codes);",
"return VAR_5;",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
]
] |
2,498 | static void do_dma_memory_set(dma_addr_t addr, uint8_t c, dma_addr_t len)
{
#define FILLBUF_SIZE 512
uint8_t fillbuf[FILLBUF_SIZE];
int l;
memset(fillbuf, c, FILLBUF_SIZE);
while (len > 0) {
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
cpu_physical_memory_rw(addr, fillbuf, l, true);
len -= len;
addr += len;
}
}
| true | qemu | bc9b78debf63c9be051abe51403736d386092d09 | static void do_dma_memory_set(dma_addr_t addr, uint8_t c, dma_addr_t len)
{
#define FILLBUF_SIZE 512
uint8_t fillbuf[FILLBUF_SIZE];
int l;
memset(fillbuf, c, FILLBUF_SIZE);
while (len > 0) {
l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
cpu_physical_memory_rw(addr, fillbuf, l, true);
len -= len;
addr += len;
}
}
| {
"code": [
" len -= len;",
" addr += len;"
],
"line_no": [
21,
23
]
} | static void FUNC_0(dma_addr_t VAR_0, uint8_t VAR_1, dma_addr_t VAR_2)
{
#define FILLBUF_SIZE 512
uint8_t fillbuf[FILLBUF_SIZE];
int VAR_3;
memset(fillbuf, VAR_1, FILLBUF_SIZE);
while (VAR_2 > 0) {
VAR_3 = VAR_2 < FILLBUF_SIZE ? VAR_2 : FILLBUF_SIZE;
cpu_physical_memory_rw(VAR_0, fillbuf, VAR_3, true);
VAR_2 -= VAR_2;
VAR_0 += VAR_2;
}
}
| [
"static void FUNC_0(dma_addr_t VAR_0, uint8_t VAR_1, dma_addr_t VAR_2)\n{",
"#define FILLBUF_SIZE 512\nuint8_t fillbuf[FILLBUF_SIZE];",
"int VAR_3;",
"memset(fillbuf, VAR_1, FILLBUF_SIZE);",
"while (VAR_2 > 0) {",
"VAR_3 = VAR_2 < FILLBUF_SIZE ? VAR_2 : FILLBUF_SIZE;",
"cpu_physical_memory_rw(VAR_0, fillbuf, VAR_3, true);",
"VAR_2 -= VAR_2;",
"VAR_0 += VAR_2;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
2,499 | static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
{
int nearest_delta_ms = (delta + 999999) / 1000000;
if (nearest_delta_ms < 1) {
nearest_delta_ms = 1;
}
timeKillEvent(mm_timer);
mm_timer = timeSetEvent(nearest_delta_ms,
mm_period,
mm_alarm_handler,
(DWORD_PTR)t,
TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
if (!mm_timer) {
fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
GetLastError());
timeEndPeriod(mm_period);
exit(1);
}
}
| true | qemu | 5bfb723f07fde2caafa90cb40c102a4e36dfea9e | static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
{
int nearest_delta_ms = (delta + 999999) / 1000000;
if (nearest_delta_ms < 1) {
nearest_delta_ms = 1;
}
timeKillEvent(mm_timer);
mm_timer = timeSetEvent(nearest_delta_ms,
mm_period,
mm_alarm_handler,
(DWORD_PTR)t,
TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
if (!mm_timer) {
fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
GetLastError());
timeEndPeriod(mm_period);
exit(1);
}
}
| {
"code": [
" int nearest_delta_ms = (delta + 999999) / 1000000;",
" mm_timer = timeSetEvent(nearest_delta_ms,"
],
"line_no": [
5,
17
]
} | static void FUNC_0(struct qemu_alarm_timer *VAR_0, int64_t VAR_1)
{
int VAR_2 = (VAR_1 + 999999) / 1000000;
if (VAR_2 < 1) {
VAR_2 = 1;
}
timeKillEvent(mm_timer);
mm_timer = timeSetEvent(VAR_2,
mm_period,
mm_alarm_handler,
(DWORD_PTR)VAR_0,
TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
if (!mm_timer) {
fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
GetLastError());
timeEndPeriod(mm_period);
exit(1);
}
}
| [
"static void FUNC_0(struct qemu_alarm_timer *VAR_0, int64_t VAR_1)\n{",
"int VAR_2 = (VAR_1 + 999999) / 1000000;",
"if (VAR_2 < 1) {",
"VAR_2 = 1;",
"}",
"timeKillEvent(mm_timer);",
"mm_timer = timeSetEvent(VAR_2,\nmm_period,\nmm_alarm_handler,\n(DWORD_PTR)VAR_0,\nTIME_ONESHOT | TIME_CALLBACK_FUNCTION);",
"if (!mm_timer) {",
"fprintf(stderr, \"Failed to re-arm win32 alarm timer %ld\\n\",\nGetLastError());",
"timeEndPeriod(mm_period);",
"exit(1);",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19,
21,
23,
25
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
2,500 | static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
do {
__asm__ volatile(
"movq %1, %%mm0 \n\t"
"movq 1%1, %%mm1 \n\t"
"movq %0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, %0 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 9%1, %%mm1 \n\t"
"movq 8%0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, 8%0 \n\t"
:"+m"(*block)
:"m"(*pixels)
:"memory");
pixels += line_size;
block += line_size;
} while (--h);
}
| false | FFmpeg | 7292b0477ac8a864af9bf97b63362c40062ab805 | static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
do {
__asm__ volatile(
"movq %1, %%mm0 \n\t"
"movq 1%1, %%mm1 \n\t"
"movq %0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, %0 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 9%1, %%mm1 \n\t"
"movq 8%0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, 8%0 \n\t"
:"+m"(*block)
:"m"(*pixels)
:"memory");
pixels += line_size;
block += line_size;
} while (--h);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
do {
__asm__ volatile(
"movq %1, %%mm0 \n\t"
"movq 1%1, %%mm1 \n\t"
"movq %0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, %0 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 9%1, %%mm1 \n\t"
"movq 8%0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, 8%0 \n\t"
:"+m"(*block)
:"m"(*pixels)
:"memory");
pixels += line_size;
block += line_size;
} while (--h);
}
| [
"static void FUNC_0(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\n{",
"MOVQ_BFE(mm6);",
"JUMPALIGN();",
"do {",
"__asm__ volatile(\n\"movq %1, %%mm0 \\n\\t\"\n\"movq 1%1, %%mm1 \\n\\t\"\n\"movq %0, %%mm3 \\n\\t\"\nPAVGB(%%mm0, %%mm1, %%mm2, %%mm6)\nPAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)\n\"movq %%mm0, %0 \\n\\t\"\n\"movq 8%1, %%mm0 \\n\\t\"\n\"movq 9%1, %%mm1 \\n\\t\"\n\"movq 8%0, %%mm3 \\n\\t\"\nPAVGB(%%mm0, %%mm1, %%mm2, %%mm6)\nPAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)\n\"movq %%mm0, 8%0 \\n\\t\"\n:\"+m\"(*block)\n:\"m\"(*pixels)\n:\"memory\");",
"pixels += line_size;",
"block += line_size;",
"} while (--h);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
2,501 | static int config_output(AVFilterLink *outlink) {
static const char hdcd_baduse[] =
"The HDCD filter is unlikely to produce a desirable result in this context.";
AVFilterContext *ctx = outlink->src;
HDCDContext *s = ctx->priv;
AVFilterLink *lk = outlink;
while(lk != NULL) {
AVFilterContext *nextf = lk->dst;
if (lk->type == AVMEDIA_TYPE_AUDIO) {
if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) {
av_log(ctx, AV_LOG_WARNING, "s24 output is being truncated to %s at %s.\n",
av_get_sample_fmt_name(lk->format),
(nextf->name) ? nextf->name : "<unknown>"
);
s->bad_config = 1;
break;
}
}
lk = (nextf->outputs) ? nextf->outputs[0] : NULL;
}
if (s->bad_config)
av_log(ctx, AV_LOG_WARNING, "%s\n", hdcd_baduse);
return 0;
}
| false | FFmpeg | 2c3d93648768cf2c00ea1731e096f698c0fae7f6 | static int config_output(AVFilterLink *outlink) {
static const char hdcd_baduse[] =
"The HDCD filter is unlikely to produce a desirable result in this context.";
AVFilterContext *ctx = outlink->src;
HDCDContext *s = ctx->priv;
AVFilterLink *lk = outlink;
while(lk != NULL) {
AVFilterContext *nextf = lk->dst;
if (lk->type == AVMEDIA_TYPE_AUDIO) {
if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) {
av_log(ctx, AV_LOG_WARNING, "s24 output is being truncated to %s at %s.\n",
av_get_sample_fmt_name(lk->format),
(nextf->name) ? nextf->name : "<unknown>"
);
s->bad_config = 1;
break;
}
}
lk = (nextf->outputs) ? nextf->outputs[0] : NULL;
}
if (s->bad_config)
av_log(ctx, AV_LOG_WARNING, "%s\n", hdcd_baduse);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0) {
static const char VAR_1[] =
"The HDCD filter is unlikely to produce a desirable result in this context.";
AVFilterContext *ctx = VAR_0->src;
HDCDContext *s = ctx->priv;
AVFilterLink *lk = VAR_0;
while(lk != NULL) {
AVFilterContext *nextf = lk->dst;
if (lk->type == AVMEDIA_TYPE_AUDIO) {
if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) {
av_log(ctx, AV_LOG_WARNING, "s24 output is being truncated to %s at %s.\n",
av_get_sample_fmt_name(lk->format),
(nextf->name) ? nextf->name : "<unknown>"
);
s->bad_config = 1;
break;
}
}
lk = (nextf->outputs) ? nextf->outputs[0] : NULL;
}
if (s->bad_config)
av_log(ctx, AV_LOG_WARNING, "%s\n", VAR_1);
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0) {",
"static const char VAR_1[] =\n\"The HDCD filter is unlikely to produce a desirable result in this context.\";",
"AVFilterContext *ctx = VAR_0->src;",
"HDCDContext *s = ctx->priv;",
"AVFilterLink *lk = VAR_0;",
"while(lk != NULL) {",
"AVFilterContext *nextf = lk->dst;",
"if (lk->type == AVMEDIA_TYPE_AUDIO) {",
"if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) {",
"av_log(ctx, AV_LOG_WARNING, \"s24 output is being truncated to %s at %s.\\n\",\nav_get_sample_fmt_name(lk->format),\n(nextf->name) ? nextf->name : \"<unknown>\"\n);",
"s->bad_config = 1;",
"break;",
"}",
"}",
"lk = (nextf->outputs) ? nextf->outputs[0] : NULL;",
"}",
"if (s->bad_config)\nav_log(ctx, AV_LOG_WARNING, \"%s\\n\", VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
]
] |
2,504 | static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
const target_siginfo_t *info)
{
tswap_siginfo(tinfo, info);
return 0;
}
| false | qemu | b0fd8d18683f0d77a8e6b482771ebea82234d727 | static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
const target_siginfo_t *info)
{
tswap_siginfo(tinfo, info);
return 0;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(target_siginfo_t *VAR_0,
const target_siginfo_t *VAR_1)
{
tswap_siginfo(VAR_0, VAR_1);
return 0;
}
| [
"static inline int FUNC_0(target_siginfo_t *VAR_0,\nconst target_siginfo_t *VAR_1)\n{",
"tswap_siginfo(VAR_0, VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
2,505 | iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
size_t size;
uint32_t num_sectors;
uint64_t lba;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
struct iscsi_data data;
#endif
int ret;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_writev(iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
/* this will allow us to get rid of 'buf' completely */
size = nb_sectors * BDRV_SECTOR_SIZE;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
data.size = MIN(size, acb->qiov->size);
/* if the iovec only contains one buffer we can pass it directly */
if (acb->qiov->niov == 1) {
data.data = acb->qiov->iov[0].iov_base;
} else {
acb->buf = g_malloc(data.size);
qemu_iovec_to_buf(acb->qiov, 0, acb->buf, data.size);
data.data = acb->buf;
}
#endif
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi WRITE16 "
"command. %s", iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_WRITE;
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x8a;
lba = sector_qemu2lun(sector_num, iscsilun);
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
num_sectors = size / iscsilun->block_size;
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
acb->task->expxferlen = size;
#if defined(LIBISCSI_FEATURE_IOVECTOR)
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
NULL,
acb);
#else
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
&data,
acb);
#endif
if (ret != 0) {
scsi_free_scsi_task(acb->task);
g_free(acb->buf);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov);
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| false | qemu | 1dde716ed6719c341c1bfa427781f0715af90cbc | iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb,
void *opaque)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = iscsilun->iscsi;
IscsiAIOCB *acb;
size_t size;
uint32_t num_sectors;
uint64_t lba;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
struct iscsi_data data;
#endif
int ret;
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_writev(iscsi, sector_num, nb_sectors, opaque, acb);
acb->iscsilun = iscsilun;
acb->qiov = qiov;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
size = nb_sectors * BDRV_SECTOR_SIZE;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
data.size = MIN(size, acb->qiov->size);
if (acb->qiov->niov == 1) {
data.data = acb->qiov->iov[0].iov_base;
} else {
acb->buf = g_malloc(data.size);
qemu_iovec_to_buf(acb->qiov, 0, acb->buf, data.size);
data.data = acb->buf;
}
#endif
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi WRITE16 "
"command. %s", iscsi_get_error(iscsi));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_WRITE;
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x8a;
lba = sector_qemu2lun(sector_num, iscsilun);
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
num_sectors = size / iscsilun->block_size;
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
acb->task->expxferlen = size;
#if defined(LIBISCSI_FEATURE_IOVECTOR)
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
NULL,
acb);
#else
ret = iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
&data,
acb);
#endif
if (ret != 0) {
scsi_free_scsi_task(acb->task);
g_free(acb->buf);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov);
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| {
"code": [],
"line_no": []
} | FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
QEMUIOVector *VAR_2, int VAR_3,
BlockDriverCompletionFunc *VAR_4,
void *VAR_5)
{
IscsiLun *iscsilun = VAR_0->VAR_5;
struct iscsi_context *VAR_6 = iscsilun->VAR_6;
IscsiAIOCB *acb;
size_t size;
uint32_t num_sectors;
uint64_t lba;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
struct iscsi_data VAR_7;
#endif
int VAR_8;
acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);
trace_iscsi_aio_writev(VAR_6, VAR_1, VAR_3, VAR_5, acb);
acb->iscsilun = iscsilun;
acb->VAR_2 = VAR_2;
acb->canceled = 0;
acb->bh = NULL;
acb->status = -EINPROGRESS;
acb->buf = NULL;
size = VAR_3 * BDRV_SECTOR_SIZE;
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
VAR_7.size = MIN(size, acb->VAR_2->size);
if (acb->VAR_2->niov == 1) {
VAR_7.VAR_7 = acb->VAR_2->iov[0].iov_base;
} else {
acb->buf = g_malloc(VAR_7.size);
qemu_iovec_to_buf(acb->VAR_2, 0, acb->buf, VAR_7.size);
VAR_7.VAR_7 = acb->buf;
}
#endif
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
error_report("iSCSI: Failed to allocate task for scsi WRITE16 "
"command. %s", iscsi_get_error(VAR_6));
qemu_aio_release(acb);
return NULL;
}
memset(acb->task, 0, sizeof(struct scsi_task));
acb->task->xfer_dir = SCSI_XFER_WRITE;
acb->task->cdb_size = 16;
acb->task->cdb[0] = 0x8a;
lba = sector_qemu2lun(VAR_1, iscsilun);
*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);
num_sectors = size / iscsilun->block_size;
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
acb->task->expxferlen = size;
#if defined(LIBISCSI_FEATURE_IOVECTOR)
VAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
NULL,
acb);
#else
VAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
&VAR_7,
acb);
#endif
if (VAR_8 != 0) {
scsi_free_scsi_task(acb->task);
g_free(acb->buf);
qemu_aio_release(acb);
return NULL;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(acb->task, (struct scsi_iovec*) acb->VAR_2->iov, acb->VAR_2->niov);
#endif
iscsi_set_events(iscsilun);
return &acb->common;
}
| [
"FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nQEMUIOVector *VAR_2, int VAR_3,\nBlockDriverCompletionFunc *VAR_4,\nvoid *VAR_5)\n{",
"IscsiLun *iscsilun = VAR_0->VAR_5;",
"struct iscsi_context *VAR_6 = iscsilun->VAR_6;",
"IscsiAIOCB *acb;",
"size_t size;",
"uint32_t num_sectors;",
"uint64_t lba;",
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)\nstruct iscsi_data VAR_7;",
"#endif\nint VAR_8;",
"acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_4, VAR_5);",
"trace_iscsi_aio_writev(VAR_6, VAR_1, VAR_3, VAR_5, acb);",
"acb->iscsilun = iscsilun;",
"acb->VAR_2 = VAR_2;",
"acb->canceled = 0;",
"acb->bh = NULL;",
"acb->status = -EINPROGRESS;",
"acb->buf = NULL;",
"size = VAR_3 * BDRV_SECTOR_SIZE;",
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)\nVAR_7.size = MIN(size, acb->VAR_2->size);",
"if (acb->VAR_2->niov == 1) {",
"VAR_7.VAR_7 = acb->VAR_2->iov[0].iov_base;",
"} else {",
"acb->buf = g_malloc(VAR_7.size);",
"qemu_iovec_to_buf(acb->VAR_2, 0, acb->buf, VAR_7.size);",
"VAR_7.VAR_7 = acb->buf;",
"}",
"#endif\nacb->task = malloc(sizeof(struct scsi_task));",
"if (acb->task == NULL) {",
"error_report(\"iSCSI: Failed to allocate task for scsi WRITE16 \"\n\"command. %s\", iscsi_get_error(VAR_6));",
"qemu_aio_release(acb);",
"return NULL;",
"}",
"memset(acb->task, 0, sizeof(struct scsi_task));",
"acb->task->xfer_dir = SCSI_XFER_WRITE;",
"acb->task->cdb_size = 16;",
"acb->task->cdb[0] = 0x8a;",
"lba = sector_qemu2lun(VAR_1, iscsilun);",
"*(uint32_t *)&acb->task->cdb[2] = htonl(lba >> 32);",
"*(uint32_t *)&acb->task->cdb[6] = htonl(lba & 0xffffffff);",
"num_sectors = size / iscsilun->block_size;",
"*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);",
"acb->task->expxferlen = size;",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)\nVAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,\niscsi_aio_write16_cb,\nNULL,\nacb);",
"#else\nVAR_8 = iscsi_scsi_command_async(VAR_6, iscsilun->lun, acb->task,\niscsi_aio_write16_cb,\n&VAR_7,\nacb);",
"#endif\nif (VAR_8 != 0) {",
"scsi_free_scsi_task(acb->task);",
"g_free(acb->buf);",
"qemu_aio_release(acb);",
"return NULL;",
"}",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)\nscsi_task_set_iov_out(acb->task, (struct scsi_iovec*) acb->VAR_2->iov, acb->VAR_2->niov);",
"#endif\niscsi_set_events(iscsilun);",
"return &acb->common;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
61,
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125,
127,
129,
131,
133
],
[
135,
137,
139,
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161,
163
],
[
165,
169
],
[
173
],
[
175
]
] |
2,506 | static void mtree_print_flatview(fprintf_function p, void *f,
AddressSpace *as)
{
FlatView *view = address_space_get_flatview(as);
FlatRange *range = &view->ranges[0];
MemoryRegion *mr;
int n = view->nr;
if (n <= 0) {
p(f, MTREE_INDENT "No rendered FlatView for "
"address space '%s'\n", as->name);
flatview_unref(view);
return;
}
while (n--) {
mr = range->mr;
p(f, MTREE_INDENT TARGET_FMT_plx "-"
TARGET_FMT_plx " (prio %d, %s): %s\n",
int128_get64(range->addr.start),
int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
mr->priority,
memory_region_type(mr),
memory_region_name(mr));
range++;
}
flatview_unref(view);
}
| false | qemu | 377a07aa0d1617736289bfa9a9cbdc73de4e6542 | static void mtree_print_flatview(fprintf_function p, void *f,
AddressSpace *as)
{
FlatView *view = address_space_get_flatview(as);
FlatRange *range = &view->ranges[0];
MemoryRegion *mr;
int n = view->nr;
if (n <= 0) {
p(f, MTREE_INDENT "No rendered FlatView for "
"address space '%s'\n", as->name);
flatview_unref(view);
return;
}
while (n--) {
mr = range->mr;
p(f, MTREE_INDENT TARGET_FMT_plx "-"
TARGET_FMT_plx " (prio %d, %s): %s\n",
int128_get64(range->addr.start),
int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
mr->priority,
memory_region_type(mr),
memory_region_name(mr));
range++;
}
flatview_unref(view);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(fprintf_function VAR_0, void *VAR_1,
AddressSpace *VAR_2)
{
FlatView *view = address_space_get_flatview(VAR_2);
FlatRange *range = &view->ranges[0];
MemoryRegion *mr;
int VAR_3 = view->nr;
if (VAR_3 <= 0) {
VAR_0(VAR_1, MTREE_INDENT "No rendered FlatView for "
"address space '%s'\VAR_3", VAR_2->name);
flatview_unref(view);
return;
}
while (VAR_3--) {
mr = range->mr;
VAR_0(VAR_1, MTREE_INDENT TARGET_FMT_plx "-"
TARGET_FMT_plx " (prio %d, %s): %s\VAR_3",
int128_get64(range->addr.start),
int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
mr->priority,
memory_region_type(mr),
memory_region_name(mr));
range++;
}
flatview_unref(view);
}
| [
"static void FUNC_0(fprintf_function VAR_0, void *VAR_1,\nAddressSpace *VAR_2)\n{",
"FlatView *view = address_space_get_flatview(VAR_2);",
"FlatRange *range = &view->ranges[0];",
"MemoryRegion *mr;",
"int VAR_3 = view->nr;",
"if (VAR_3 <= 0) {",
"VAR_0(VAR_1, MTREE_INDENT \"No rendered FlatView for \"\n\"address space '%s'\\VAR_3\", VAR_2->name);",
"flatview_unref(view);",
"return;",
"}",
"while (VAR_3--) {",
"mr = range->mr;",
"VAR_0(VAR_1, MTREE_INDENT TARGET_FMT_plx \"-\"\nTARGET_FMT_plx \" (prio %d, %s): %s\\VAR_3\",\nint128_get64(range->addr.start),\nint128_get64(range->addr.start) + MR_SIZE(range->addr.size),\nmr->priority,\nmemory_region_type(mr),\nmemory_region_name(mr));",
"range++;",
"}",
"flatview_unref(view);",
"}"
] | [
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
],
[
31
],
[
33
],
[
35,
37,
39,
41,
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
2,509 | static inline uint32_t efsctuf(uint32_t val)
{
CPU_FloatU u;
float32 tmp;
u.l = val;
/* NaN are not treated the same way IEEE 754 does */
if (unlikely(float32_is_nan(u.f)))
return 0;
tmp = uint64_to_float32(1ULL << 32, &env->vec_status);
u.f = float32_mul(u.f, tmp, &env->vec_status);
return float32_to_uint32(u.f, &env->vec_status);
}
| false | qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | static inline uint32_t efsctuf(uint32_t val)
{
CPU_FloatU u;
float32 tmp;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
tmp = uint64_to_float32(1ULL << 32, &env->vec_status);
u.f = float32_mul(u.f, tmp, &env->vec_status);
return float32_to_uint32(u.f, &env->vec_status);
}
| {
"code": [],
"line_no": []
} | static inline uint32_t FUNC_0(uint32_t val)
{
CPU_FloatU u;
float32 tmp;
u.l = val;
if (unlikely(float32_is_nan(u.f)))
return 0;
tmp = uint64_to_float32(1ULL << 32, &env->vec_status);
u.f = float32_mul(u.f, tmp, &env->vec_status);
return float32_to_uint32(u.f, &env->vec_status);
}
| [
"static inline uint32_t FUNC_0(uint32_t val)\n{",
"CPU_FloatU u;",
"float32 tmp;",
"u.l = val;",
"if (unlikely(float32_is_nan(u.f)))\nreturn 0;",
"tmp = uint64_to_float32(1ULL << 32, &env->vec_status);",
"u.f = float32_mul(u.f, tmp, &env->vec_status);",
"return float32_to_uint32(u.f, &env->vec_status);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
2,510 | void ppce500_init(PPCE500Params *params)
{
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
CPUPPCState *env = NULL;
uint64_t elf_entry;
uint64_t elf_lowaddr;
hwaddr entry=0;
hwaddr loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
target_ulong dt_base = 0;
target_ulong initrd_base = 0;
target_long initrd_size=0;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq **irqs, *mpic;
DeviceState *dev;
CPUPPCState *firstenv = NULL;
MemoryRegion *ccsr_addr_space;
SysBusDevice *s;
PPCE500CCSRState *ccsr;
/* Setup CPUs */
if (params->cpu_model == NULL) {
params->cpu_model = "e500v2_v30";
}
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
PowerPCCPU *cpu;
qemu_irq *input;
cpu = cpu_ppc_init(params->cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
env = &cpu->env;
if (!firstenv) {
firstenv = env;
}
irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
input = (qemu_irq *)env->irq_inputs;
irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
env->mpic_cpu_base = MPC8544_CCSRBAR_BASE +
MPC8544_MPIC_REGS_OFFSET + 0x20000;
ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);
/* Register reset handler */
if (!i) {
/* Primary CPU */
struct boot_info *boot_info;
boot_info = g_malloc0(sizeof(struct boot_info));
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = boot_info;
} else {
/* Secondary CPUs */
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
}
}
env = firstenv;
/* Fixup Memory size on a alignment boundary */
ram_size &= ~(RAM_SIZES_ALIGN - 1);
/* Register Memory */
memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space_mem, 0, ram);
dev = qdev_create(NULL, "e500-ccsr");
object_property_add_child(qdev_get_machine(), "e500-ccsr",
OBJECT(dev), NULL);
qdev_init_nofail(dev);
ccsr = CCSR(dev);
ccsr_addr_space = &ccsr->ccsr_space;
memory_region_add_subregion(address_space_mem, MPC8544_CCSRBAR_BASE,
ccsr_addr_space);
/* MPIC */
mpic = mpic_init(ccsr_addr_space, MPC8544_MPIC_REGS_OFFSET,
smp_cpus, irqs, NULL);
if (!mpic) {
cpu_abort(env, "MPIC failed to initialize\n");
}
/* Serial */
if (serial_hds[0]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[0], DEVICE_BIG_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[1], DEVICE_BIG_ENDIAN);
}
/* General Utility device */
dev = qdev_create(NULL, "mpc8544-guts");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
sysbus_mmio_get_region(s, 0));
/* PCI */
dev = qdev_create(NULL, "e500-pcihost");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(s, 0, mpic[pci_irq_nrs[0]]);
sysbus_connect_irq(s, 1, mpic[pci_irq_nrs[1]]);
sysbus_connect_irq(s, 2, mpic[pci_irq_nrs[2]]);
sysbus_connect_irq(s, 3, mpic[pci_irq_nrs[3]]);
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
sysbus_mmio_get_region(s, 0));
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");
sysbus_mmio_map(sysbus_from_qdev(dev), 1, MPC8544_PCI_IO);
if (pci_bus) {
/* Register network interfaces. */
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
}
}
/* Register spinning region */
sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
/* Load kernel. */
if (params->kernel_filename) {
kernel_size = load_uimage(params->kernel_filename, &entry,
&loadaddr, NULL);
if (kernel_size < 0) {
kernel_size = load_elf(params->kernel_filename, NULL, NULL,
&elf_entry, &elf_lowaddr, NULL, 1,
ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
/* XXX try again as binary */
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
params->kernel_filename);
exit(1);
}
}
/* Load initrd. */
if (params->initrd_filename) {
initrd_base = (loadaddr + kernel_size + INITRD_LOAD_PAD) &
~INITRD_PAD_MASK;
initrd_size = load_image_targphys(params->initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
params->initrd_filename);
exit(1);
}
}
/* If we're loading a kernel directly, we must load the device tree too. */
if (params->kernel_filename) {
struct boot_info *boot_info;
int dt_size;
dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
dt_size = ppce500_load_device_tree(env, params, dt_base, initrd_base,
initrd_size);
if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
boot_info = env->load_info;
boot_info->entry = entry;
boot_info->dt_base = dt_base;
boot_info->dt_size = dt_size;
}
if (kvm_enabled()) {
kvmppc_init();
}
}
| false | qemu | 5bac0701113f4de4fee053a3939b0f569a04b88c | void ppce500_init(PPCE500Params *params)
{
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
CPUPPCState *env = NULL;
uint64_t elf_entry;
uint64_t elf_lowaddr;
hwaddr entry=0;
hwaddr loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
target_ulong dt_base = 0;
target_ulong initrd_base = 0;
target_long initrd_size=0;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq **irqs, *mpic;
DeviceState *dev;
CPUPPCState *firstenv = NULL;
MemoryRegion *ccsr_addr_space;
SysBusDevice *s;
PPCE500CCSRState *ccsr;
if (params->cpu_model == NULL) {
params->cpu_model = "e500v2_v30";
}
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (i = 0; i < smp_cpus; i++) {
PowerPCCPU *cpu;
qemu_irq *input;
cpu = cpu_ppc_init(params->cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
env = &cpu->env;
if (!firstenv) {
firstenv = env;
}
irqs[i] = irqs[0] + (i * OPENPIC_OUTPUT_NB);
input = (qemu_irq *)env->irq_inputs;
irqs[i][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
irqs[i][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
env->mpic_cpu_base = MPC8544_CCSRBAR_BASE +
MPC8544_MPIC_REGS_OFFSET + 0x20000;
ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);
if (!i) {
struct boot_info *boot_info;
boot_info = g_malloc0(sizeof(struct boot_info));
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = boot_info;
} else {
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
}
}
env = firstenv;
ram_size &= ~(RAM_SIZES_ALIGN - 1);
memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space_mem, 0, ram);
dev = qdev_create(NULL, "e500-ccsr");
object_property_add_child(qdev_get_machine(), "e500-ccsr",
OBJECT(dev), NULL);
qdev_init_nofail(dev);
ccsr = CCSR(dev);
ccsr_addr_space = &ccsr->ccsr_space;
memory_region_add_subregion(address_space_mem, MPC8544_CCSRBAR_BASE,
ccsr_addr_space);
mpic = mpic_init(ccsr_addr_space, MPC8544_MPIC_REGS_OFFSET,
smp_cpus, irqs, NULL);
if (!mpic) {
cpu_abort(env, "MPIC failed to initialize\n");
}
if (serial_hds[0]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[0], DEVICE_BIG_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[1], DEVICE_BIG_ENDIAN);
}
dev = qdev_create(NULL, "mpc8544-guts");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
sysbus_mmio_get_region(s, 0));
dev = qdev_create(NULL, "e500-pcihost");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(s, 0, mpic[pci_irq_nrs[0]]);
sysbus_connect_irq(s, 1, mpic[pci_irq_nrs[1]]);
sysbus_connect_irq(s, 2, mpic[pci_irq_nrs[2]]);
sysbus_connect_irq(s, 3, mpic[pci_irq_nrs[3]]);
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
sysbus_mmio_get_region(s, 0));
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");
sysbus_mmio_map(sysbus_from_qdev(dev), 1, MPC8544_PCI_IO);
if (pci_bus) {
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
}
}
sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
if (params->kernel_filename) {
kernel_size = load_uimage(params->kernel_filename, &entry,
&loadaddr, NULL);
if (kernel_size < 0) {
kernel_size = load_elf(params->kernel_filename, NULL, NULL,
&elf_entry, &elf_lowaddr, NULL, 1,
ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
params->kernel_filename);
exit(1);
}
}
if (params->initrd_filename) {
initrd_base = (loadaddr + kernel_size + INITRD_LOAD_PAD) &
~INITRD_PAD_MASK;
initrd_size = load_image_targphys(params->initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
params->initrd_filename);
exit(1);
}
}
if (params->kernel_filename) {
struct boot_info *boot_info;
int dt_size;
dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
dt_size = ppce500_load_device_tree(env, params, dt_base, initrd_base,
initrd_size);
if (dt_size < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
boot_info = env->load_info;
boot_info->entry = entry;
boot_info->dt_base = dt_base;
boot_info->dt_size = dt_size;
}
if (kvm_enabled()) {
kvmppc_init();
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PPCE500Params *VAR_0)
{
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
CPUPPCState *env = NULL;
uint64_t elf_entry;
uint64_t elf_lowaddr;
hwaddr entry=0;
hwaddr loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
target_ulong dt_base = 0;
target_ulong initrd_base = 0;
target_long initrd_size=0;
int VAR_1=0;
unsigned int VAR_2[4] = {1, 2, 3, 4};
qemu_irq **irqs, *mpic;
DeviceState *dev;
CPUPPCState *firstenv = NULL;
MemoryRegion *ccsr_addr_space;
SysBusDevice *s;
PPCE500CCSRState *ccsr;
if (VAR_0->cpu_model == NULL) {
VAR_0->cpu_model = "e500v2_v30";
}
irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
for (VAR_1 = 0; VAR_1 < smp_cpus; VAR_1++) {
PowerPCCPU *cpu;
qemu_irq *input;
cpu = cpu_ppc_init(VAR_0->cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
env = &cpu->env;
if (!firstenv) {
firstenv = env;
}
irqs[VAR_1] = irqs[0] + (VAR_1 * OPENPIC_OUTPUT_NB);
input = (qemu_irq *)env->irq_inputs;
irqs[VAR_1][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];
irqs[VAR_1][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];
env->spr[SPR_BOOKE_PIR] = env->cpu_index = VAR_1;
env->mpic_cpu_base = MPC8544_CCSRBAR_BASE +
MPC8544_MPIC_REGS_OFFSET + 0x20000;
ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);
if (!VAR_1) {
struct VAR_3 *VAR_3;
VAR_3 = g_malloc0(sizeof(struct VAR_3));
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = VAR_3;
} else {
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
}
}
env = firstenv;
ram_size &= ~(RAM_SIZES_ALIGN - 1);
memory_region_init_ram(ram, "mpc8544ds.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space_mem, 0, ram);
dev = qdev_create(NULL, "e500-ccsr");
object_property_add_child(qdev_get_machine(), "e500-ccsr",
OBJECT(dev), NULL);
qdev_init_nofail(dev);
ccsr = CCSR(dev);
ccsr_addr_space = &ccsr->ccsr_space;
memory_region_add_subregion(address_space_mem, MPC8544_CCSRBAR_BASE,
ccsr_addr_space);
mpic = mpic_init(ccsr_addr_space, MPC8544_MPIC_REGS_OFFSET,
smp_cpus, irqs, NULL);
if (!mpic) {
cpu_abort(env, "MPIC failed to initialize\n");
}
if (serial_hds[0]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[0], DEVICE_BIG_ENDIAN);
}
if (serial_hds[1]) {
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
0, mpic[42], 399193,
serial_hds[1], DEVICE_BIG_ENDIAN);
}
dev = qdev_create(NULL, "mpc8544-guts");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
sysbus_mmio_get_region(s, 0));
dev = qdev_create(NULL, "e500-pcihost");
qdev_init_nofail(dev);
s = SYS_BUS_DEVICE(dev);
sysbus_connect_irq(s, 0, mpic[VAR_2[0]]);
sysbus_connect_irq(s, 1, mpic[VAR_2[1]]);
sysbus_connect_irq(s, 2, mpic[VAR_2[2]]);
sysbus_connect_irq(s, 3, mpic[VAR_2[3]]);
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
sysbus_mmio_get_region(s, 0));
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");
sysbus_mmio_map(sysbus_from_qdev(dev), 1, MPC8544_PCI_IO);
if (pci_bus) {
for (VAR_1 = 0; VAR_1 < nb_nics; VAR_1++) {
pci_nic_init_nofail(&nd_table[VAR_1], "virtio", NULL);
}
}
sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
if (VAR_0->kernel_filename) {
kernel_size = load_uimage(VAR_0->kernel_filename, &entry,
&loadaddr, NULL);
if (kernel_size < 0) {
kernel_size = load_elf(VAR_0->kernel_filename, NULL, NULL,
&elf_entry, &elf_lowaddr, NULL, 1,
ELF_MACHINE, 0);
entry = elf_entry;
loadaddr = elf_lowaddr;
}
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_0->kernel_filename);
exit(1);
}
}
if (VAR_0->initrd_filename) {
initrd_base = (loadaddr + kernel_size + INITRD_LOAD_PAD) &
~INITRD_PAD_MASK;
initrd_size = load_image_targphys(VAR_0->initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
VAR_0->initrd_filename);
exit(1);
}
}
if (VAR_0->kernel_filename) {
struct VAR_3 *VAR_3;
int VAR_4;
dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
VAR_4 = ppce500_load_device_tree(env, VAR_0, dt_base, initrd_base,
initrd_size);
if (VAR_4 < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
VAR_3 = env->load_info;
VAR_3->entry = entry;
VAR_3->dt_base = dt_base;
VAR_3->VAR_4 = VAR_4;
}
if (kvm_enabled()) {
kvmppc_init();
}
}
| [
"void FUNC_0(PPCE500Params *VAR_0)\n{",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"PCIBus *pci_bus;",
"CPUPPCState *env = NULL;",
"uint64_t elf_entry;",
"uint64_t elf_lowaddr;",
"hwaddr entry=0;",
"hwaddr loadaddr=UIMAGE_LOAD_BASE;",
"target_long kernel_size=0;",
"target_ulong dt_base = 0;",
"target_ulong initrd_base = 0;",
"target_long initrd_size=0;",
"int VAR_1=0;",
"unsigned int VAR_2[4] = {1, 2, 3, 4};",
"qemu_irq **irqs, *mpic;",
"DeviceState *dev;",
"CPUPPCState *firstenv = NULL;",
"MemoryRegion *ccsr_addr_space;",
"SysBusDevice *s;",
"PPCE500CCSRState *ccsr;",
"if (VAR_0->cpu_model == NULL) {",
"VAR_0->cpu_model = \"e500v2_v30\";",
"}",
"irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));",
"irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);",
"for (VAR_1 = 0; VAR_1 < smp_cpus; VAR_1++) {",
"PowerPCCPU *cpu;",
"qemu_irq *input;",
"cpu = cpu_ppc_init(VAR_0->cpu_model);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to initialize CPU!\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"if (!firstenv) {",
"firstenv = env;",
"}",
"irqs[VAR_1] = irqs[0] + (VAR_1 * OPENPIC_OUTPUT_NB);",
"input = (qemu_irq *)env->irq_inputs;",
"irqs[VAR_1][OPENPIC_OUTPUT_INT] = input[PPCE500_INPUT_INT];",
"irqs[VAR_1][OPENPIC_OUTPUT_CINT] = input[PPCE500_INPUT_CINT];",
"env->spr[SPR_BOOKE_PIR] = env->cpu_index = VAR_1;",
"env->mpic_cpu_base = MPC8544_CCSRBAR_BASE +\nMPC8544_MPIC_REGS_OFFSET + 0x20000;",
"ppc_booke_timers_init(env, 400000000, PPC_TIMER_E500);",
"if (!VAR_1) {",
"struct VAR_3 *VAR_3;",
"VAR_3 = g_malloc0(sizeof(struct VAR_3));",
"qemu_register_reset(ppce500_cpu_reset, cpu);",
"env->load_info = VAR_3;",
"} else {",
"qemu_register_reset(ppce500_cpu_reset_sec, cpu);",
"}",
"}",
"env = firstenv;",
"ram_size &= ~(RAM_SIZES_ALIGN - 1);",
"memory_region_init_ram(ram, \"mpc8544ds.ram\", ram_size);",
"vmstate_register_ram_global(ram);",
"memory_region_add_subregion(address_space_mem, 0, ram);",
"dev = qdev_create(NULL, \"e500-ccsr\");",
"object_property_add_child(qdev_get_machine(), \"e500-ccsr\",\nOBJECT(dev), NULL);",
"qdev_init_nofail(dev);",
"ccsr = CCSR(dev);",
"ccsr_addr_space = &ccsr->ccsr_space;",
"memory_region_add_subregion(address_space_mem, MPC8544_CCSRBAR_BASE,\nccsr_addr_space);",
"mpic = mpic_init(ccsr_addr_space, MPC8544_MPIC_REGS_OFFSET,\nsmp_cpus, irqs, NULL);",
"if (!mpic) {",
"cpu_abort(env, \"MPIC failed to initialize\\n\");",
"}",
"if (serial_hds[0]) {",
"serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,\n0, mpic[42], 399193,\nserial_hds[0], DEVICE_BIG_ENDIAN);",
"}",
"if (serial_hds[1]) {",
"serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,\n0, mpic[42], 399193,\nserial_hds[1], DEVICE_BIG_ENDIAN);",
"}",
"dev = qdev_create(NULL, \"mpc8544-guts\");",
"qdev_init_nofail(dev);",
"s = SYS_BUS_DEVICE(dev);",
"memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,\nsysbus_mmio_get_region(s, 0));",
"dev = qdev_create(NULL, \"e500-pcihost\");",
"qdev_init_nofail(dev);",
"s = SYS_BUS_DEVICE(dev);",
"sysbus_connect_irq(s, 0, mpic[VAR_2[0]]);",
"sysbus_connect_irq(s, 1, mpic[VAR_2[1]]);",
"sysbus_connect_irq(s, 2, mpic[VAR_2[2]]);",
"sysbus_connect_irq(s, 3, mpic[VAR_2[3]]);",
"memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,\nsysbus_mmio_get_region(s, 0));",
"pci_bus = (PCIBus *)qdev_get_child_bus(dev, \"pci.0\");",
"if (!pci_bus)\nprintf(\"couldn't create PCI controller!\\n\");",
"sysbus_mmio_map(sysbus_from_qdev(dev), 1, MPC8544_PCI_IO);",
"if (pci_bus) {",
"for (VAR_1 = 0; VAR_1 < nb_nics; VAR_1++) {",
"pci_nic_init_nofail(&nd_table[VAR_1], \"virtio\", NULL);",
"}",
"}",
"sysbus_create_simple(\"e500-spin\", MPC8544_SPIN_BASE, NULL);",
"if (VAR_0->kernel_filename) {",
"kernel_size = load_uimage(VAR_0->kernel_filename, &entry,\n&loadaddr, NULL);",
"if (kernel_size < 0) {",
"kernel_size = load_elf(VAR_0->kernel_filename, NULL, NULL,\n&elf_entry, &elf_lowaddr, NULL, 1,\nELF_MACHINE, 0);",
"entry = elf_entry;",
"loadaddr = elf_lowaddr;",
"}",
"if (kernel_size < 0) {",
"fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_0->kernel_filename);",
"exit(1);",
"}",
"}",
"if (VAR_0->initrd_filename) {",
"initrd_base = (loadaddr + kernel_size + INITRD_LOAD_PAD) &\n~INITRD_PAD_MASK;",
"initrd_size = load_image_targphys(VAR_0->initrd_filename, initrd_base,\nram_size - initrd_base);",
"if (initrd_size < 0) {",
"fprintf(stderr, \"qemu: could not load initial ram disk '%s'\\n\",\nVAR_0->initrd_filename);",
"exit(1);",
"}",
"}",
"if (VAR_0->kernel_filename) {",
"struct VAR_3 *VAR_3;",
"int VAR_4;",
"dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;",
"VAR_4 = ppce500_load_device_tree(env, VAR_0, dt_base, initrd_base,\ninitrd_size);",
"if (VAR_4 < 0) {",
"fprintf(stderr, \"couldn't load device tree\\n\");",
"exit(1);",
"}",
"VAR_3 = env->load_info;",
"VAR_3->entry = entry;",
"VAR_3->dt_base = dt_base;",
"VAR_3->VAR_4 = VAR_4;",
"}",
"if (kvm_enabled()) {",
"kvmppc_init();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
107
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
137
],
[
143
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169,
171
],
[
177,
179
],
[
183
],
[
185
],
[
187
],
[
193
],
[
195,
197,
199
],
[
201
],
[
205
],
[
207,
209,
211
],
[
213
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
253
],
[
255,
257
],
[
261
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
281
],
[
287
],
[
289,
291
],
[
293
],
[
295,
297,
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311,
313
],
[
315
],
[
317
],
[
319
],
[
325
],
[
327,
329
],
[
331,
333
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
395
]
] |
2,511 | int nbd_trip(BlockDriverState *bs, int csock, off_t size,
uint64_t dev_offset, uint32_t nbdflags,
uint8_t *data)
{
struct nbd_request request;
struct nbd_reply reply;
int ret;
TRACE("Reading request.");
if (nbd_receive_request(csock, &request) == -1)
return -1;
if (request.len + NBD_REPLY_SIZE > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request.len + NBD_REPLY_SIZE, NBD_BUFFER_SIZE);
errno = EINVAL;
return -1;
}
if ((request.from + request.len) < request.from) {
LOG("integer overflow detected! "
"you're probably being attacked");
errno = EINVAL;
return -1;
}
if ((request.from + request.len) > size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len, (uint64_t)size, dev_offset);
LOG("requested operation past EOF--bad client?");
errno = EINVAL;
return -1;
}
TRACE("Decoding type");
reply.handle = request.handle;
reply.error = 0;
switch (request.type & NBD_CMD_MASK_COMMAND) {
case NBD_CMD_READ:
TRACE("Request type is READ");
ret = bdrv_read(bs, (request.from + dev_offset) / 512,
data + NBD_REPLY_SIZE,
request.len / 512);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
request.len = 0;
}
TRACE("Read %u byte(s)", request.len);
/* Reply
[ 0 .. 3] magic (NBD_REPLY_MAGIC)
[ 4 .. 7] error (0 == no error)
[ 7 .. 15] handle
*/
cpu_to_be32w((uint32_t*)data, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(data + 4), reply.error);
cpu_to_be64w((uint64_t*)(data + 8), reply.handle);
TRACE("Sending data to client");
if (write_sync(csock, data,
request.len + NBD_REPLY_SIZE) !=
request.len + NBD_REPLY_SIZE) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
TRACE("Reading %u byte(s)", request.len);
if (read_sync(csock, data, request.len) != request.len) {
LOG("reading from socket failed");
errno = EINVAL;
return -1;
}
if (nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = 1;
} else {
TRACE("Writing to device");
ret = bdrv_write(bs, (request.from + dev_offset) / 512,
data, request.len / 512);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
request.len = 0;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
}
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
return 1;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = bdrv_discard(bs, (request.from + dev_offset) / 512,
request.len / 512);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
default:
LOG("invalid request type (%u) received", request.type);
errno = EINVAL;
return -1;
}
TRACE("Request/Reply complete");
return 0;
}
| false | qemu | a478f6e595dab1801931d56d097623d65f5b6d1d | int nbd_trip(BlockDriverState *bs, int csock, off_t size,
uint64_t dev_offset, uint32_t nbdflags,
uint8_t *data)
{
struct nbd_request request;
struct nbd_reply reply;
int ret;
TRACE("Reading request.");
if (nbd_receive_request(csock, &request) == -1)
return -1;
if (request.len + NBD_REPLY_SIZE > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request.len + NBD_REPLY_SIZE, NBD_BUFFER_SIZE);
errno = EINVAL;
return -1;
}
if ((request.from + request.len) < request.from) {
LOG("integer overflow detected! "
"you're probably being attacked");
errno = EINVAL;
return -1;
}
if ((request.from + request.len) > size) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
request.from, request.len, (uint64_t)size, dev_offset);
LOG("requested operation past EOF--bad client?");
errno = EINVAL;
return -1;
}
TRACE("Decoding type");
reply.handle = request.handle;
reply.error = 0;
switch (request.type & NBD_CMD_MASK_COMMAND) {
case NBD_CMD_READ:
TRACE("Request type is READ");
ret = bdrv_read(bs, (request.from + dev_offset) / 512,
data + NBD_REPLY_SIZE,
request.len / 512);
if (ret < 0) {
LOG("reading from file failed");
reply.error = -ret;
request.len = 0;
}
TRACE("Read %u byte(s)", request.len);
cpu_to_be32w((uint32_t*)data, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(data + 4), reply.error);
cpu_to_be64w((uint64_t*)(data + 8), reply.handle);
TRACE("Sending data to client");
if (write_sync(csock, data,
request.len + NBD_REPLY_SIZE) !=
request.len + NBD_REPLY_SIZE) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
TRACE("Reading %u byte(s)", request.len);
if (read_sync(csock, data, request.len) != request.len) {
LOG("reading from socket failed");
errno = EINVAL;
return -1;
}
if (nbdflags & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
reply.error = 1;
} else {
TRACE("Writing to device");
ret = bdrv_write(bs, (request.from + dev_offset) / 512,
data, request.len / 512);
if (ret < 0) {
LOG("writing to file failed");
reply.error = -ret;
request.len = 0;
}
if (request.type & NBD_CMD_FLAG_FUA) {
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
}
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
return 1;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
ret = bdrv_flush(bs);
if (ret < 0) {
LOG("flush failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
ret = bdrv_discard(bs, (request.from + dev_offset) / 512,
request.len / 512);
if (ret < 0) {
LOG("discard failed");
reply.error = -ret;
}
if (nbd_send_reply(csock, &reply) == -1)
return -1;
break;
default:
LOG("invalid request type (%u) received", request.type);
errno = EINVAL;
return -1;
}
TRACE("Request/Reply complete");
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, int VAR_1, off_t VAR_2,
uint64_t VAR_3, uint32_t VAR_4,
uint8_t *VAR_5)
{
struct nbd_request VAR_6;
struct nbd_reply VAR_7;
int VAR_8;
TRACE("Reading VAR_6.");
if (nbd_receive_request(VAR_1, &VAR_6) == -1)
return -1;
if (VAR_6.len + NBD_REPLY_SIZE > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
VAR_6.len + NBD_REPLY_SIZE, NBD_BUFFER_SIZE);
errno = EINVAL;
return -1;
}
if ((VAR_6.from + VAR_6.len) < VAR_6.from) {
LOG("integer overflow detected! "
"you're probably being attacked");
errno = EINVAL;
return -1;
}
if ((VAR_6.from + VAR_6.len) > VAR_2) {
LOG("From: %" PRIu64 ", Len: %u, Size: %" PRIu64
", Offset: %" PRIu64 "\n",
VAR_6.from, VAR_6.len, (uint64_t)VAR_2, VAR_3);
LOG("requested operation past EOF--bad client?");
errno = EINVAL;
return -1;
}
TRACE("Decoding type");
VAR_7.handle = VAR_6.handle;
VAR_7.error = 0;
switch (VAR_6.type & NBD_CMD_MASK_COMMAND) {
case NBD_CMD_READ:
TRACE("Request type is READ");
VAR_8 = bdrv_read(VAR_0, (VAR_6.from + VAR_3) / 512,
VAR_5 + NBD_REPLY_SIZE,
VAR_6.len / 512);
if (VAR_8 < 0) {
LOG("reading from file failed");
VAR_7.error = -VAR_8;
VAR_6.len = 0;
}
TRACE("Read %u byte(s)", VAR_6.len);
cpu_to_be32w((uint32_t*)VAR_5, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(VAR_5 + 4), VAR_7.error);
cpu_to_be64w((uint64_t*)(VAR_5 + 8), VAR_7.handle);
TRACE("Sending VAR_5 to client");
if (write_sync(VAR_1, VAR_5,
VAR_6.len + NBD_REPLY_SIZE) !=
VAR_6.len + NBD_REPLY_SIZE) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
break;
case NBD_CMD_WRITE:
TRACE("Request type is WRITE");
TRACE("Reading %u byte(s)", VAR_6.len);
if (read_sync(VAR_1, VAR_5, VAR_6.len) != VAR_6.len) {
LOG("reading from socket failed");
errno = EINVAL;
return -1;
}
if (VAR_4 & NBD_FLAG_READ_ONLY) {
TRACE("Server is read-only, return error");
VAR_7.error = 1;
} else {
TRACE("Writing to device");
VAR_8 = bdrv_write(VAR_0, (VAR_6.from + VAR_3) / 512,
VAR_5, VAR_6.len / 512);
if (VAR_8 < 0) {
LOG("writing to file failed");
VAR_7.error = -VAR_8;
VAR_6.len = 0;
}
if (VAR_6.type & NBD_CMD_FLAG_FUA) {
VAR_8 = bdrv_flush(VAR_0);
if (VAR_8 < 0) {
LOG("flush failed");
VAR_7.error = -VAR_8;
}
}
}
if (nbd_send_reply(VAR_1, &VAR_7) == -1)
return -1;
break;
case NBD_CMD_DISC:
TRACE("Request type is DISCONNECT");
errno = 0;
return 1;
case NBD_CMD_FLUSH:
TRACE("Request type is FLUSH");
VAR_8 = bdrv_flush(VAR_0);
if (VAR_8 < 0) {
LOG("flush failed");
VAR_7.error = -VAR_8;
}
if (nbd_send_reply(VAR_1, &VAR_7) == -1)
return -1;
break;
case NBD_CMD_TRIM:
TRACE("Request type is TRIM");
VAR_8 = bdrv_discard(VAR_0, (VAR_6.from + VAR_3) / 512,
VAR_6.len / 512);
if (VAR_8 < 0) {
LOG("discard failed");
VAR_7.error = -VAR_8;
}
if (nbd_send_reply(VAR_1, &VAR_7) == -1)
return -1;
break;
default:
LOG("invalid VAR_6 type (%u) received", VAR_6.type);
errno = EINVAL;
return -1;
}
TRACE("Request/Reply complete");
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int VAR_1, off_t VAR_2,\nuint64_t VAR_3, uint32_t VAR_4,\nuint8_t *VAR_5)\n{",
"struct nbd_request VAR_6;",
"struct nbd_reply VAR_7;",
"int VAR_8;",
"TRACE(\"Reading VAR_6.\");",
"if (nbd_receive_request(VAR_1, &VAR_6) == -1)\nreturn -1;",
"if (VAR_6.len + NBD_REPLY_SIZE > NBD_BUFFER_SIZE) {",
"LOG(\"len (%u) is larger than max len (%u)\",\nVAR_6.len + NBD_REPLY_SIZE, NBD_BUFFER_SIZE);",
"errno = EINVAL;",
"return -1;",
"}",
"if ((VAR_6.from + VAR_6.len) < VAR_6.from) {",
"LOG(\"integer overflow detected! \"\n\"you're probably being attacked\");",
"errno = EINVAL;",
"return -1;",
"}",
"if ((VAR_6.from + VAR_6.len) > VAR_2) {",
"LOG(\"From: %\" PRIu64 \", Len: %u, Size: %\" PRIu64\n\", Offset: %\" PRIu64 \"\\n\",\nVAR_6.from, VAR_6.len, (uint64_t)VAR_2, VAR_3);",
"LOG(\"requested operation past EOF--bad client?\");",
"errno = EINVAL;",
"return -1;",
"}",
"TRACE(\"Decoding type\");",
"VAR_7.handle = VAR_6.handle;",
"VAR_7.error = 0;",
"switch (VAR_6.type & NBD_CMD_MASK_COMMAND) {",
"case NBD_CMD_READ:\nTRACE(\"Request type is READ\");",
"VAR_8 = bdrv_read(VAR_0, (VAR_6.from + VAR_3) / 512,\nVAR_5 + NBD_REPLY_SIZE,\nVAR_6.len / 512);",
"if (VAR_8 < 0) {",
"LOG(\"reading from file failed\");",
"VAR_7.error = -VAR_8;",
"VAR_6.len = 0;",
"}",
"TRACE(\"Read %u byte(s)\", VAR_6.len);",
"cpu_to_be32w((uint32_t*)VAR_5, NBD_REPLY_MAGIC);",
"cpu_to_be32w((uint32_t*)(VAR_5 + 4), VAR_7.error);",
"cpu_to_be64w((uint64_t*)(VAR_5 + 8), VAR_7.handle);",
"TRACE(\"Sending VAR_5 to client\");",
"if (write_sync(VAR_1, VAR_5,\nVAR_6.len + NBD_REPLY_SIZE) !=\nVAR_6.len + NBD_REPLY_SIZE) {",
"LOG(\"writing to socket failed\");",
"errno = EINVAL;",
"return -1;",
"}",
"break;",
"case NBD_CMD_WRITE:\nTRACE(\"Request type is WRITE\");",
"TRACE(\"Reading %u byte(s)\", VAR_6.len);",
"if (read_sync(VAR_1, VAR_5, VAR_6.len) != VAR_6.len) {",
"LOG(\"reading from socket failed\");",
"errno = EINVAL;",
"return -1;",
"}",
"if (VAR_4 & NBD_FLAG_READ_ONLY) {",
"TRACE(\"Server is read-only, return error\");",
"VAR_7.error = 1;",
"} else {",
"TRACE(\"Writing to device\");",
"VAR_8 = bdrv_write(VAR_0, (VAR_6.from + VAR_3) / 512,\nVAR_5, VAR_6.len / 512);",
"if (VAR_8 < 0) {",
"LOG(\"writing to file failed\");",
"VAR_7.error = -VAR_8;",
"VAR_6.len = 0;",
"}",
"if (VAR_6.type & NBD_CMD_FLAG_FUA) {",
"VAR_8 = bdrv_flush(VAR_0);",
"if (VAR_8 < 0) {",
"LOG(\"flush failed\");",
"VAR_7.error = -VAR_8;",
"}",
"}",
"}",
"if (nbd_send_reply(VAR_1, &VAR_7) == -1)\nreturn -1;",
"break;",
"case NBD_CMD_DISC:\nTRACE(\"Request type is DISCONNECT\");",
"errno = 0;",
"return 1;",
"case NBD_CMD_FLUSH:\nTRACE(\"Request type is FLUSH\");",
"VAR_8 = bdrv_flush(VAR_0);",
"if (VAR_8 < 0) {",
"LOG(\"flush failed\");",
"VAR_7.error = -VAR_8;",
"}",
"if (nbd_send_reply(VAR_1, &VAR_7) == -1)\nreturn -1;",
"break;",
"case NBD_CMD_TRIM:\nTRACE(\"Request type is TRIM\");",
"VAR_8 = bdrv_discard(VAR_0, (VAR_6.from + VAR_3) / 512,\nVAR_6.len / 512);",
"if (VAR_8 < 0) {",
"LOG(\"discard failed\");",
"VAR_7.error = -VAR_8;",
"}",
"if (nbd_send_reply(VAR_1, &VAR_7) == -1)\nreturn -1;",
"break;",
"default:\nLOG(\"invalid VAR_6 type (%u) received\", VAR_6.type);",
"errno = EINVAL;",
"return -1;",
"}",
"TRACE(\"Request/Reply complete\");",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137,
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221,
223
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
235,
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253,
255
],
[
257
],
[
259,
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275,
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
297
],
[
299
]
] |
2,512 | test_opts_range_unvisited(void)
{
intList *list = NULL;
intList *tail;
QemuOpts *opts;
Visitor *v;
opts = qemu_opts_parse(qemu_find_opts("userdef"), "ilist=0-2", false,
&error_abort);
v = opts_visitor_new(opts);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
/* Would be simpler if the visitor genuinely supported virtual walks */
visit_start_list(v, "ilist", (GenericList **)&list, sizeof(*list),
&error_abort);
tail = list;
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 0);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 1);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_end_list(v, (void **)&list);
/* BUG: unvisited tail not reported; actually not reportable by design */
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
qapi_free_intList(list);
visit_free(v);
qemu_opts_del(opts);
}
| false | qemu | a4a1c70dc759e5b81627e96564f344ab43ea86eb | test_opts_range_unvisited(void)
{
intList *list = NULL;
intList *tail;
QemuOpts *opts;
Visitor *v;
opts = qemu_opts_parse(qemu_find_opts("userdef"), "ilist=0-2", false,
&error_abort);
v = opts_visitor_new(opts);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_start_list(v, "ilist", (GenericList **)&list, sizeof(*list),
&error_abort);
tail = list;
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 0);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 1);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_end_list(v, (void **)&list);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
qapi_free_intList(list);
visit_free(v);
qemu_opts_del(opts);
}
| {
"code": [],
"line_no": []
} | FUNC_0(void)
{
intList *list = NULL;
intList *tail;
QemuOpts *opts;
Visitor *v;
opts = qemu_opts_parse(qemu_find_opts("userdef"), "ilist=0-2", false,
&error_abort);
v = opts_visitor_new(opts);
visit_start_struct(v, NULL, NULL, 0, &error_abort);
visit_start_list(v, "ilist", (GenericList **)&list, sizeof(*list),
&error_abort);
tail = list;
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 0);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_type_int(v, NULL, &tail->value, &error_abort);
g_assert_cmpint(tail->value, ==, 1);
tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));
g_assert(tail);
visit_end_list(v, (void **)&list);
visit_check_struct(v, &error_abort);
visit_end_struct(v, NULL);
qapi_free_intList(list);
visit_free(v);
qemu_opts_del(opts);
}
| [
"FUNC_0(void)\n{",
"intList *list = NULL;",
"intList *tail;",
"QemuOpts *opts;",
"Visitor *v;",
"opts = qemu_opts_parse(qemu_find_opts(\"userdef\"), \"ilist=0-2\", false,\n&error_abort);",
"v = opts_visitor_new(opts);",
"visit_start_struct(v, NULL, NULL, 0, &error_abort);",
"visit_start_list(v, \"ilist\", (GenericList **)&list, sizeof(*list),\n&error_abort);",
"tail = list;",
"visit_type_int(v, NULL, &tail->value, &error_abort);",
"g_assert_cmpint(tail->value, ==, 0);",
"tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));",
"g_assert(tail);",
"visit_type_int(v, NULL, &tail->value, &error_abort);",
"g_assert_cmpint(tail->value, ==, 1);",
"tail = (intList *)visit_next_list(v, (GenericList *)tail, sizeof(*list));",
"g_assert(tail);",
"visit_end_list(v, (void **)&list);",
"visit_check_struct(v, &error_abort);",
"visit_end_struct(v, NULL);",
"qapi_free_intList(list);",
"visit_free(v);",
"qemu_opts_del(opts);",
"}"
] | [
0,
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
],
[
25
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
2,513 | static int mpeg_decode_mb(MpegEncContext *s,
DCTELEM block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skiped==0);
if (s->mb_skip_run-- != 0) {
if(s->pict_type == I_TYPE){
av_log(s->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
/* skip mb */
s->mb_intra = 0;
for(i=0;i<12;i++)
s->block_last_index[i] = -1;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == P_TYPE) {
/* if P type, zero motion vector is implied */
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0]= s->picture_structure - 1;
s->mb_skiped = 1;
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
/* if B type, reuse previous vectors and directions */
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP;
// assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
s->mb_skiped = 1;
}
return 0;
}
switch(s->pict_type) {
default:
case I_TYPE:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case P_TYPE:
mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = ptype2mb_type[ mb_type ];
break;
case B_TYPE:
mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = btype2mb_type[ mb_type ];
break;
}
dprintf("mb_type=%x\n", mb_type);
// motion_type = 0; /* avoid warning */
if (IS_INTRA(mb_type)) {
/* compute dct type */
if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
/* just parse them */
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb); /* field select */
s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
skip_bits1(&s->gb); /* marker */
}else
memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
s->mb_intra = 1;
#ifdef HAVE_XVMC
//one 1 we memcpy blocks in xvmcvideo
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,-1);//inter are always full blocks
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<4+(1<<s->chroma_format);i++) {
if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
} else {
for(i=0;i<6;i++) {
if (mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV){
assert(mb_type & MB_TYPE_CBP);
/* compute dct type */
if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = MV_DIR_FORWARD;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else{
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0]= s->picture_structure - 1;
}
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
}else{
assert(mb_type & MB_TYPE_L0L1);
//FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED
/* get additionnal motion vector type */
if (s->frame_pred_frame_dct)
motion_type = MT_FRAME;
else{
motion_type = get_bits(&s->gb, 2);
}
/* compute dct type */
if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
!s->frame_pred_frame_dct && HAS_CBP(mb_type)) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
/* motion vectors */
s->mv_dir = 0;
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
dprintf("motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME: /* or MT_16X8 */
if (s->picture_structure == PICT_FRAME) {
/* MT_FRAME */
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
/* full_pel: only for mpeg1 */
if (s->full_pel[i]){
s->mv[i][0][0] <<= 1;
s->mv[i][0][1] <<= 1;
}
} else {
/* MT_16X8 */
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
dprintf("fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = val << 1;
s->mv[i][j][1] = val;
dprintf("fmy=%d\n", val);
}
} else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
s->field_select[i][0] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
break;
case MT_DMV:
{
int dmx, dmy, mx, my, m;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> 1);
dmy = get_dmv(s);
s->mv_type = MV_TYPE_DMV;
s->last_mv[i][0][1] = my<<1;
s->last_mv[i][1][1] = my<<1;
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;//not used
s->mv[i][1][1] = my;//not used
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
//m = 1 + 2 * s->top_field_first;
m = s->top_field_first ? 1 : 3;
/* top -> top pred */
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if(s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (cbp < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
cbp++;
if(s->chroma_format == 2){//CHROMA422
cbp|= ( get_bits(&s->gb,2) ) << 6;
}else
if(s->chroma_format > 2){//CHROMA444
cbp|= ( get_bits(&s->gb,6) ) << 6;
}
#ifdef HAVE_XVMC
//on 1 we memcpy blocks in xvmcvideo
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,cbp);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<6;i++) {
if (cbp & (1<<(5-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
if (s->chroma_format >= 2) {
if (s->chroma_format == 2) {//CHROMA_422)
for(i=6;i<8;i++) {
if (cbp & (1<<(6+7-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}else{ /*CHROMA_444*/
for(i=6;i<12;i++) {
if (cbp & (1<<(6+11-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}
}
} else {
for(i=0;i<6;i++) {
if (cbp & 32) {
if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}
}else{
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
return 0;
}
| false | FFmpeg | 461cd5bfb5c38e48a81b4a9a5912dfd65da1ba3d | static int mpeg_decode_mb(MpegEncContext *s,
DCTELEM block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skiped==0);
if (s->mb_skip_run-- != 0) {
if(s->pict_type == I_TYPE){
av_log(s->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
s->mb_intra = 0;
for(i=0;i<12;i++)
s->block_last_index[i] = -1;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == P_TYPE) {
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0]= s->picture_structure - 1;
s->mb_skiped = 1;
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP;
if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
s->mb_skiped = 1;
}
return 0;
}
switch(s->pict_type) {
default:
case I_TYPE:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case P_TYPE:
mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = ptype2mb_type[ mb_type ];
break;
case B_TYPE:
mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
mb_type = btype2mb_type[ mb_type ];
break;
}
dprintf("mb_type=%x\n", mb_type);
if (IS_INTRA(mb_type)) {
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb);
s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
skip_bits1(&s->gb);
}else
memset(s->last_mv, 0, sizeof(s->last_mv));
s->mb_intra = 1;
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,-1);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<4+(1<<s->chroma_format);i++) {
if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
} else {
for(i=0;i<6;i++) {
if (mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0)
return -1;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV){
assert(mb_type & MB_TYPE_CBP);
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = MV_DIR_FORWARD;
if(s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else{
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0]= s->picture_structure - 1;
}
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
}else{
assert(mb_type & MB_TYPE_L0L1);
if (s->frame_pred_frame_dct)
motion_type = MT_FRAME;
else{
motion_type = get_bits(&s->gb, 2);
}
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct && HAS_CBP(mb_type)) {
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = 0;
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
dprintf("motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME:
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
if (s->full_pel[i]){
s->mv[i][0][0] <<= 1;
s->mv[i][0][1] <<= 1;
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(j=0;j<2;j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
dprintf("fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = val << 1;
s->mv[i][j][1] = val;
dprintf("fmy=%d\n", val);
}
} else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
s->field_select[i][0] = get_bits1(&s->gb);
for(k=0;k<2;k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
break;
case MT_DMV:
{
int dmx, dmy, mx, my, m;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> 1);
dmy = get_dmv(s);
s->mv_type = MV_TYPE_DMV;
s->last_mv[i][0][1] = my<<1;
s->last_mv[i][1][1] = my<<1;
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;
s->mv[i][1][1] = my;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
m = s->top_field_first ? 1 : 3;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if(s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
}
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (cbp < 0){
av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
cbp++;
if(s->chroma_format == 2){
cbp|= ( get_bits(&s->gb,2) ) << 6;
}else
if(s->chroma_format > 2){
cbp|= ( get_bits(&s->gb,6) ) << 6;
}
#ifdef HAVE_XVMC
if(s->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(s,cbp);
if(s->swap_uv){
exchange_uv(s);
}
}
#endif
if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
for(i=0;i<6;i++) {
if (cbp & (1<<(5-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
if (s->chroma_format >= 2) {
if (s->chroma_format == 2) {
for(i=6;i<8;i++) {
if (cbp & (1<<(6+7-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}else{
for(i=6;i<12;i++) {
if (cbp & (1<<(6+11-i)) ) {
if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
}
}
}
} else {
for(i=0;i<6;i++) {
if (cbp & 32) {
if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0)
return -1;
} else {
s->block_last_index[i] = -1;
}
cbp+=cbp;
}
}
}else{
for(i=0;i<6;i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0,
DCTELEM VAR_1[12][64])
{
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
dprintf("decode_mb: x=%d y=%d\n", VAR_0->mb_x, VAR_0->mb_y);
assert(VAR_0->mb_skiped==0);
if (VAR_0->mb_skip_run-- != 0) {
if(VAR_0->pict_type == I_TYPE){
av_log(VAR_0->avctx, AV_LOG_ERROR, "skiped MB in I frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_0->mb_intra = 0;
for(VAR_2=0;VAR_2<12;VAR_2++)
VAR_0->block_last_index[VAR_2] = -1;
if(VAR_0->picture_structure == PICT_FRAME)
VAR_0->mv_type = MV_TYPE_16X16;
else
VAR_0->mv_type = MV_TYPE_FIELD;
if (VAR_0->pict_type == P_TYPE) {
VAR_0->mv_dir = MV_DIR_FORWARD;
VAR_0->mv[0][0][0] = VAR_0->mv[0][0][1] = 0;
VAR_0->last_mv[0][0][0] = VAR_0->last_mv[0][0][1] = 0;
VAR_0->last_mv[0][1][0] = VAR_0->last_mv[0][1][1] = 0;
VAR_0->field_select[0][0]= VAR_0->picture_structure - 1;
VAR_0->mb_skiped = 1;
VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
VAR_0->mv[0][0][0] = VAR_0->last_mv[0][0][0];
VAR_0->mv[0][0][1] = VAR_0->last_mv[0][0][1];
VAR_0->mv[1][0][0] = VAR_0->last_mv[1][0][0];
VAR_0->mv[1][0][1] = VAR_0->last_mv[1][0][1];
VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]=
VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride - 1] | MB_TYPE_SKIP;
if((VAR_0->mv[0][0][0]|VAR_0->mv[0][0][1]|VAR_0->mv[1][0][0]|VAR_0->mv[1][0][1])==0)
VAR_0->mb_skiped = 1;
}
return 0;
}
switch(VAR_0->pict_type) {
default:
case I_TYPE:
if (get_bits1(&VAR_0->gb) == 0) {
if (get_bits1(&VAR_0->gb) == 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_7 = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
VAR_7 = MB_TYPE_INTRA;
}
break;
case P_TYPE:
VAR_7 = get_vlc2(&VAR_0->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (VAR_7 < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_7 = ptype2mb_type[ VAR_7 ];
break;
case B_TYPE:
VAR_7 = get_vlc2(&VAR_0->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (VAR_7 < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_7 = btype2mb_type[ VAR_7 ];
break;
}
dprintf("VAR_7=%x\n", VAR_7);
if (IS_INTRA(VAR_7)) {
if (VAR_0->picture_structure == PICT_FRAME &&
!VAR_0->frame_pred_frame_dct) {
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
}
if (IS_QUANT(VAR_7))
VAR_0->qscale = get_qscale(VAR_0);
if (VAR_0->concealment_motion_vectors) {
if (VAR_0->picture_structure != PICT_FRAME)
skip_bits1(&VAR_0->gb);
VAR_0->mv[0][0][0]= VAR_0->last_mv[0][0][0]= VAR_0->last_mv[0][1][0] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][0], VAR_0->last_mv[0][0][0]);
VAR_0->mv[0][0][1]= VAR_0->last_mv[0][0][1]= VAR_0->last_mv[0][1][1] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][1], VAR_0->last_mv[0][0][1]);
skip_bits1(&VAR_0->gb);
}else
memset(VAR_0->last_mv, 0, sizeof(VAR_0->last_mv));
VAR_0->mb_intra = 1;
#ifdef HAVE_XVMC
if(VAR_0->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(VAR_0,-1);
if(VAR_0->swap_uv){
exchange_uv(VAR_0);
}
}
#endif
if (VAR_0->codec_id == CODEC_ID_MPEG2VIDEO) {
for(VAR_2=0;VAR_2<4+(1<<VAR_0->chroma_format);VAR_2++) {
if (mpeg2_decode_block_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
}
} else {
for(VAR_2=0;VAR_2<6;VAR_2++) {
if (mpeg1_decode_block_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
}
}
} else {
if (VAR_7 & MB_TYPE_ZERO_MV){
assert(VAR_7 & MB_TYPE_CBP);
if (VAR_0->picture_structure == PICT_FRAME &&
!VAR_0->frame_pred_frame_dct) {
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
}
if (IS_QUANT(VAR_7))
VAR_0->qscale = get_qscale(VAR_0);
VAR_0->mv_dir = MV_DIR_FORWARD;
if(VAR_0->picture_structure == PICT_FRAME)
VAR_0->mv_type = MV_TYPE_16X16;
else{
VAR_0->mv_type = MV_TYPE_FIELD;
VAR_7 |= MB_TYPE_INTERLACED;
VAR_0->field_select[0][0]= VAR_0->picture_structure - 1;
}
VAR_0->last_mv[0][0][0] = 0;
VAR_0->last_mv[0][0][1] = 0;
VAR_0->last_mv[0][1][0] = 0;
VAR_0->last_mv[0][1][1] = 0;
VAR_0->mv[0][0][0] = 0;
VAR_0->mv[0][0][1] = 0;
}else{
assert(VAR_7 & MB_TYPE_L0L1);
if (VAR_0->frame_pred_frame_dct)
VAR_8 = MT_FRAME;
else{
VAR_8 = get_bits(&VAR_0->gb, 2);
}
if (VAR_0->picture_structure == PICT_FRAME &&
!VAR_0->frame_pred_frame_dct && HAS_CBP(VAR_7)) {
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
}
if (IS_QUANT(VAR_7))
VAR_0->qscale = get_qscale(VAR_0);
VAR_0->mv_dir = 0;
for(VAR_2=0;VAR_2<2;VAR_2++) {
if (USES_LIST(VAR_7, VAR_2)) {
VAR_0->mv_dir |= (MV_DIR_FORWARD >> VAR_2);
dprintf("VAR_8=%d\n", VAR_8);
switch(VAR_8) {
case MT_FRAME:
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_7 |= MB_TYPE_16x16;
VAR_0->mv_type = MV_TYPE_16X16;
VAR_0->mv[VAR_2][0][0]= VAR_0->last_mv[VAR_2][0][0]= VAR_0->last_mv[VAR_2][1][0] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0], VAR_0->last_mv[VAR_2][0][0]);
VAR_0->mv[VAR_2][0][1]= VAR_0->last_mv[VAR_2][0][1]= VAR_0->last_mv[VAR_2][1][1] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1], VAR_0->last_mv[VAR_2][0][1]);
if (VAR_0->full_pel[VAR_2]){
VAR_0->mv[VAR_2][0][0] <<= 1;
VAR_0->mv[VAR_2][0][1] <<= 1;
}
} else {
VAR_7 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
VAR_0->mv_type = MV_TYPE_16X8;
for(VAR_3=0;VAR_3<2;VAR_3++) {
VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);
for(VAR_4=0;VAR_4<2;VAR_4++) {
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],
VAR_0->last_mv[VAR_2][VAR_3][VAR_4]);
VAR_0->last_mv[VAR_2][VAR_3][VAR_4] = VAR_6;
VAR_0->mv[VAR_2][VAR_3][VAR_4] = VAR_6;
}
}
}
break;
case MT_FIELD:
VAR_0->mv_type = MV_TYPE_FIELD;
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_7 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(VAR_3=0;VAR_3<2;VAR_3++) {
VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],
VAR_0->last_mv[VAR_2][VAR_3][0]);
VAR_0->last_mv[VAR_2][VAR_3][0] = VAR_6;
VAR_0->mv[VAR_2][VAR_3][0] = VAR_6;
dprintf("fmx=%d\n", VAR_6);
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],
VAR_0->last_mv[VAR_2][VAR_3][1] >> 1);
VAR_0->last_mv[VAR_2][VAR_3][1] = VAR_6 << 1;
VAR_0->mv[VAR_2][VAR_3][1] = VAR_6;
dprintf("fmy=%d\n", VAR_6);
}
} else {
VAR_7 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
VAR_0->field_select[VAR_2][0] = get_bits1(&VAR_0->gb);
for(VAR_4=0;VAR_4<2;VAR_4++) {
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],
VAR_0->last_mv[VAR_2][0][VAR_4]);
VAR_0->last_mv[VAR_2][0][VAR_4] = VAR_6;
VAR_0->last_mv[VAR_2][1][VAR_4] = VAR_6;
VAR_0->mv[VAR_2][0][VAR_4] = VAR_6;
}
}
break;
case MT_DMV:
{
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
VAR_11 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],
VAR_0->last_mv[VAR_2][0][0]);
VAR_0->last_mv[VAR_2][0][0] = VAR_11;
VAR_0->last_mv[VAR_2][1][0] = VAR_11;
VAR_9 = get_dmv(VAR_0);
VAR_12 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],
VAR_0->last_mv[VAR_2][0][1] >> 1);
VAR_10 = get_dmv(VAR_0);
VAR_0->mv_type = MV_TYPE_DMV;
VAR_0->last_mv[VAR_2][0][1] = VAR_12<<1;
VAR_0->last_mv[VAR_2][1][1] = VAR_12<<1;
VAR_0->mv[VAR_2][0][0] = VAR_11;
VAR_0->mv[VAR_2][0][1] = VAR_12;
VAR_0->mv[VAR_2][1][0] = VAR_11;
VAR_0->mv[VAR_2][1][1] = VAR_12;
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_7 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
VAR_13 = VAR_0->top_field_first ? 1 : 3;
VAR_0->mv[VAR_2][2][0] = ((VAR_11 * VAR_13 + (VAR_11 > 0)) >> 1) + VAR_9;
VAR_0->mv[VAR_2][2][1] = ((VAR_12 * VAR_13 + (VAR_12 > 0)) >> 1) + VAR_10 - 1;
VAR_13 = 4 - VAR_13;
VAR_0->mv[VAR_2][3][0] = ((VAR_11 * VAR_13 + (VAR_11 > 0)) >> 1) + VAR_9;
VAR_0->mv[VAR_2][3][1] = ((VAR_12 * VAR_13 + (VAR_12 > 0)) >> 1) + VAR_10 + 1;
} else {
VAR_7 |= MB_TYPE_16x16;
VAR_0->mv[VAR_2][2][0] = ((VAR_11 + (VAR_11 > 0)) >> 1) + VAR_9;
VAR_0->mv[VAR_2][2][1] = ((VAR_12 + (VAR_12 > 0)) >> 1) + VAR_10;
if(VAR_0->picture_structure == PICT_TOP_FIELD)
VAR_0->mv[VAR_2][2][1]--;
else
VAR_0->mv[VAR_2][2][1]++;
}
}
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "00 VAR_8 at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
}
}
}
VAR_0->mb_intra = 0;
if (HAS_CBP(VAR_7)) {
VAR_5 = get_vlc2(&VAR_0->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (VAR_5 < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid VAR_5 at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return -1;
}
VAR_5++;
if(VAR_0->chroma_format == 2){
VAR_5|= ( get_bits(&VAR_0->gb,2) ) << 6;
}else
if(VAR_0->chroma_format > 2){
VAR_5|= ( get_bits(&VAR_0->gb,6) ) << 6;
}
#ifdef HAVE_XVMC
if(VAR_0->avctx->xvmc_acceleration > 1){
XVMC_pack_pblocks(VAR_0,VAR_5);
if(VAR_0->swap_uv){
exchange_uv(VAR_0);
}
}
#endif
if (VAR_0->codec_id == CODEC_ID_MPEG2VIDEO) {
for(VAR_2=0;VAR_2<6;VAR_2++) {
if (VAR_5 & (1<<(5-VAR_2)) ) {
if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
}
if (VAR_0->chroma_format >= 2) {
if (VAR_0->chroma_format == 2) {
for(VAR_2=6;VAR_2<8;VAR_2++) {
if (VAR_5 & (1<<(6+7-VAR_2)) ) {
if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
}
}else{
for(VAR_2=6;VAR_2<12;VAR_2++) {
if (VAR_5 & (1<<(6+11-VAR_2)) ) {
if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
}
}
}
} else {
for(VAR_2=0;VAR_2<6;VAR_2++) {
if (VAR_5 & 32) {
if (mpeg1_decode_block_inter(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)
return -1;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
VAR_5+=VAR_5;
}
}
}else{
for(VAR_2=0;VAR_2<6;VAR_2++)
VAR_0->block_last_index[VAR_2] = -1;
}
}
VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]= VAR_7;
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0,\nDCTELEM VAR_1[12][64])\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"dprintf(\"decode_mb: x=%d y=%d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"assert(VAR_0->mb_skiped==0);",
"if (VAR_0->mb_skip_run-- != 0) {",
"if(VAR_0->pict_type == I_TYPE){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"skiped MB in I frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_0->mb_intra = 0;",
"for(VAR_2=0;VAR_2<12;VAR_2++)",
"VAR_0->block_last_index[VAR_2] = -1;",
"if(VAR_0->picture_structure == PICT_FRAME)\nVAR_0->mv_type = MV_TYPE_16X16;",
"else\nVAR_0->mv_type = MV_TYPE_FIELD;",
"if (VAR_0->pict_type == P_TYPE) {",
"VAR_0->mv_dir = MV_DIR_FORWARD;",
"VAR_0->mv[0][0][0] = VAR_0->mv[0][0][1] = 0;",
"VAR_0->last_mv[0][0][0] = VAR_0->last_mv[0][0][1] = 0;",
"VAR_0->last_mv[0][1][0] = VAR_0->last_mv[0][1][1] = 0;",
"VAR_0->field_select[0][0]= VAR_0->picture_structure - 1;",
"VAR_0->mb_skiped = 1;",
"VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;",
"} else {",
"VAR_0->mv[0][0][0] = VAR_0->last_mv[0][0][0];",
"VAR_0->mv[0][0][1] = VAR_0->last_mv[0][0][1];",
"VAR_0->mv[1][0][0] = VAR_0->last_mv[1][0][0];",
"VAR_0->mv[1][0][1] = VAR_0->last_mv[1][0][1];",
"VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]=\nVAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride - 1] | MB_TYPE_SKIP;",
"if((VAR_0->mv[0][0][0]|VAR_0->mv[0][0][1]|VAR_0->mv[1][0][0]|VAR_0->mv[1][0][1])==0)\nVAR_0->mb_skiped = 1;",
"}",
"return 0;",
"}",
"switch(VAR_0->pict_type) {",
"default:\ncase I_TYPE:\nif (get_bits1(&VAR_0->gb) == 0) {",
"if (get_bits1(&VAR_0->gb) == 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid mb type in I Frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_7 = MB_TYPE_QUANT | MB_TYPE_INTRA;",
"} else {",
"VAR_7 = MB_TYPE_INTRA;",
"}",
"break;",
"case P_TYPE:\nVAR_7 = get_vlc2(&VAR_0->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);",
"if (VAR_7 < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid mb type in P Frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_7 = ptype2mb_type[ VAR_7 ];",
"break;",
"case B_TYPE:\nVAR_7 = get_vlc2(&VAR_0->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);",
"if (VAR_7 < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid mb type in B Frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_7 = btype2mb_type[ VAR_7 ];",
"break;",
"}",
"dprintf(\"VAR_7=%x\\n\", VAR_7);",
"if (IS_INTRA(VAR_7)) {",
"if (VAR_0->picture_structure == PICT_FRAME &&\n!VAR_0->frame_pred_frame_dct) {",
"VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"}",
"if (IS_QUANT(VAR_7))\nVAR_0->qscale = get_qscale(VAR_0);",
"if (VAR_0->concealment_motion_vectors) {",
"if (VAR_0->picture_structure != PICT_FRAME)\nskip_bits1(&VAR_0->gb);",
"VAR_0->mv[0][0][0]= VAR_0->last_mv[0][0][0]= VAR_0->last_mv[0][1][0] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][0], VAR_0->last_mv[0][0][0]);",
"VAR_0->mv[0][0][1]= VAR_0->last_mv[0][0][1]= VAR_0->last_mv[0][1][1] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][1], VAR_0->last_mv[0][0][1]);",
"skip_bits1(&VAR_0->gb);",
"}else",
"memset(VAR_0->last_mv, 0, sizeof(VAR_0->last_mv));",
"VAR_0->mb_intra = 1;",
"#ifdef HAVE_XVMC\nif(VAR_0->avctx->xvmc_acceleration > 1){",
"XVMC_pack_pblocks(VAR_0,-1);",
"if(VAR_0->swap_uv){",
"exchange_uv(VAR_0);",
"}",
"}",
"#endif\nif (VAR_0->codec_id == CODEC_ID_MPEG2VIDEO) {",
"for(VAR_2=0;VAR_2<4+(1<<VAR_0->chroma_format);VAR_2++) {",
"if (mpeg2_decode_block_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"}",
"} else {",
"for(VAR_2=0;VAR_2<6;VAR_2++) {",
"if (mpeg1_decode_block_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"}",
"}",
"} else {",
"if (VAR_7 & MB_TYPE_ZERO_MV){",
"assert(VAR_7 & MB_TYPE_CBP);",
"if (VAR_0->picture_structure == PICT_FRAME &&\n!VAR_0->frame_pred_frame_dct) {",
"VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"}",
"if (IS_QUANT(VAR_7))\nVAR_0->qscale = get_qscale(VAR_0);",
"VAR_0->mv_dir = MV_DIR_FORWARD;",
"if(VAR_0->picture_structure == PICT_FRAME)\nVAR_0->mv_type = MV_TYPE_16X16;",
"else{",
"VAR_0->mv_type = MV_TYPE_FIELD;",
"VAR_7 |= MB_TYPE_INTERLACED;",
"VAR_0->field_select[0][0]= VAR_0->picture_structure - 1;",
"}",
"VAR_0->last_mv[0][0][0] = 0;",
"VAR_0->last_mv[0][0][1] = 0;",
"VAR_0->last_mv[0][1][0] = 0;",
"VAR_0->last_mv[0][1][1] = 0;",
"VAR_0->mv[0][0][0] = 0;",
"VAR_0->mv[0][0][1] = 0;",
"}else{",
"assert(VAR_7 & MB_TYPE_L0L1);",
"if (VAR_0->frame_pred_frame_dct)\nVAR_8 = MT_FRAME;",
"else{",
"VAR_8 = get_bits(&VAR_0->gb, 2);",
"}",
"if (VAR_0->picture_structure == PICT_FRAME &&\n!VAR_0->frame_pred_frame_dct && HAS_CBP(VAR_7)) {",
"VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"}",
"if (IS_QUANT(VAR_7))\nVAR_0->qscale = get_qscale(VAR_0);",
"VAR_0->mv_dir = 0;",
"for(VAR_2=0;VAR_2<2;VAR_2++) {",
"if (USES_LIST(VAR_7, VAR_2)) {",
"VAR_0->mv_dir |= (MV_DIR_FORWARD >> VAR_2);",
"dprintf(\"VAR_8=%d\\n\", VAR_8);",
"switch(VAR_8) {",
"case MT_FRAME:\nif (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_7 |= MB_TYPE_16x16;",
"VAR_0->mv_type = MV_TYPE_16X16;",
"VAR_0->mv[VAR_2][0][0]= VAR_0->last_mv[VAR_2][0][0]= VAR_0->last_mv[VAR_2][1][0] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0], VAR_0->last_mv[VAR_2][0][0]);",
"VAR_0->mv[VAR_2][0][1]= VAR_0->last_mv[VAR_2][0][1]= VAR_0->last_mv[VAR_2][1][1] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1], VAR_0->last_mv[VAR_2][0][1]);",
"if (VAR_0->full_pel[VAR_2]){",
"VAR_0->mv[VAR_2][0][0] <<= 1;",
"VAR_0->mv[VAR_2][0][1] <<= 1;",
"}",
"} else {",
"VAR_7 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;",
"VAR_0->mv_type = MV_TYPE_16X8;",
"for(VAR_3=0;VAR_3<2;VAR_3++) {",
"VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);",
"for(VAR_4=0;VAR_4<2;VAR_4++) {",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],\nVAR_0->last_mv[VAR_2][VAR_3][VAR_4]);",
"VAR_0->last_mv[VAR_2][VAR_3][VAR_4] = VAR_6;",
"VAR_0->mv[VAR_2][VAR_3][VAR_4] = VAR_6;",
"}",
"}",
"}",
"break;",
"case MT_FIELD:\nVAR_0->mv_type = MV_TYPE_FIELD;",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_7 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;",
"for(VAR_3=0;VAR_3<2;VAR_3++) {",
"VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],\nVAR_0->last_mv[VAR_2][VAR_3][0]);",
"VAR_0->last_mv[VAR_2][VAR_3][0] = VAR_6;",
"VAR_0->mv[VAR_2][VAR_3][0] = VAR_6;",
"dprintf(\"fmx=%d\\n\", VAR_6);",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],\nVAR_0->last_mv[VAR_2][VAR_3][1] >> 1);",
"VAR_0->last_mv[VAR_2][VAR_3][1] = VAR_6 << 1;",
"VAR_0->mv[VAR_2][VAR_3][1] = VAR_6;",
"dprintf(\"fmy=%d\\n\", VAR_6);",
"}",
"} else {",
"VAR_7 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;",
"VAR_0->field_select[VAR_2][0] = get_bits1(&VAR_0->gb);",
"for(VAR_4=0;VAR_4<2;VAR_4++) {",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],\nVAR_0->last_mv[VAR_2][0][VAR_4]);",
"VAR_0->last_mv[VAR_2][0][VAR_4] = VAR_6;",
"VAR_0->last_mv[VAR_2][1][VAR_4] = VAR_6;",
"VAR_0->mv[VAR_2][0][VAR_4] = VAR_6;",
"}",
"}",
"break;",
"case MT_DMV:\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"VAR_11 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],\nVAR_0->last_mv[VAR_2][0][0]);",
"VAR_0->last_mv[VAR_2][0][0] = VAR_11;",
"VAR_0->last_mv[VAR_2][1][0] = VAR_11;",
"VAR_9 = get_dmv(VAR_0);",
"VAR_12 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],\nVAR_0->last_mv[VAR_2][0][1] >> 1);",
"VAR_10 = get_dmv(VAR_0);",
"VAR_0->mv_type = MV_TYPE_DMV;",
"VAR_0->last_mv[VAR_2][0][1] = VAR_12<<1;",
"VAR_0->last_mv[VAR_2][1][1] = VAR_12<<1;",
"VAR_0->mv[VAR_2][0][0] = VAR_11;",
"VAR_0->mv[VAR_2][0][1] = VAR_12;",
"VAR_0->mv[VAR_2][1][0] = VAR_11;",
"VAR_0->mv[VAR_2][1][1] = VAR_12;",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_7 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;",
"VAR_13 = VAR_0->top_field_first ? 1 : 3;",
"VAR_0->mv[VAR_2][2][0] = ((VAR_11 * VAR_13 + (VAR_11 > 0)) >> 1) + VAR_9;",
"VAR_0->mv[VAR_2][2][1] = ((VAR_12 * VAR_13 + (VAR_12 > 0)) >> 1) + VAR_10 - 1;",
"VAR_13 = 4 - VAR_13;",
"VAR_0->mv[VAR_2][3][0] = ((VAR_11 * VAR_13 + (VAR_11 > 0)) >> 1) + VAR_9;",
"VAR_0->mv[VAR_2][3][1] = ((VAR_12 * VAR_13 + (VAR_12 > 0)) >> 1) + VAR_10 + 1;",
"} else {",
"VAR_7 |= MB_TYPE_16x16;",
"VAR_0->mv[VAR_2][2][0] = ((VAR_11 + (VAR_11 > 0)) >> 1) + VAR_9;",
"VAR_0->mv[VAR_2][2][1] = ((VAR_12 + (VAR_12 > 0)) >> 1) + VAR_10;",
"if(VAR_0->picture_structure == PICT_TOP_FIELD)\nVAR_0->mv[VAR_2][2][1]--;",
"else\nVAR_0->mv[VAR_2][2][1]++;",
"}",
"}",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"00 VAR_8 at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"}",
"}",
"}",
"VAR_0->mb_intra = 0;",
"if (HAS_CBP(VAR_7)) {",
"VAR_5 = get_vlc2(&VAR_0->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);",
"if (VAR_5 < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid VAR_5 at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return -1;",
"}",
"VAR_5++;",
"if(VAR_0->chroma_format == 2){",
"VAR_5|= ( get_bits(&VAR_0->gb,2) ) << 6;",
"}else",
"if(VAR_0->chroma_format > 2){",
"VAR_5|= ( get_bits(&VAR_0->gb,6) ) << 6;",
"}",
"#ifdef HAVE_XVMC\nif(VAR_0->avctx->xvmc_acceleration > 1){",
"XVMC_pack_pblocks(VAR_0,VAR_5);",
"if(VAR_0->swap_uv){",
"exchange_uv(VAR_0);",
"}",
"}",
"#endif\nif (VAR_0->codec_id == CODEC_ID_MPEG2VIDEO) {",
"for(VAR_2=0;VAR_2<6;VAR_2++) {",
"if (VAR_5 & (1<<(5-VAR_2)) ) {",
"if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"}",
"if (VAR_0->chroma_format >= 2) {",
"if (VAR_0->chroma_format == 2) {",
"for(VAR_2=6;VAR_2<8;VAR_2++) {",
"if (VAR_5 & (1<<(6+7-VAR_2)) ) {",
"if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"}",
"}else{",
"for(VAR_2=6;VAR_2<12;VAR_2++) {",
"if (VAR_5 & (1<<(6+11-VAR_2)) ) {",
"if (mpeg2_decode_block_non_intra(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"}",
"}",
"}",
"} else {",
"for(VAR_2=0;VAR_2<6;VAR_2++) {",
"if (VAR_5 & 32) {",
"if (mpeg1_decode_block_inter(VAR_0, VAR_0->pblocks[VAR_2], VAR_2) < 0)\nreturn -1;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"VAR_5+=VAR_5;",
"}",
"}",
"}else{",
"for(VAR_2=0;VAR_2<6;VAR_2++)",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"}",
"VAR_0->current_picture.VAR_7[ VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride ]= 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
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
],
[
165
],
[
169,
171
],
[
173
],
[
175
],
[
179,
181
],
[
185
],
[
189,
191
],
[
195,
197
],
[
199,
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
265,
267
],
[
269
],
[
271
],
[
275,
277
],
[
281
],
[
283,
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
317,
319
],
[
321
],
[
323
],
[
325
],
[
331,
333
],
[
335
],
[
337
],
[
341,
343
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361,
363
],
[
367
],
[
369
],
[
371,
373
],
[
375,
377
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419,
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431,
433
],
[
435
],
[
437
],
[
439
],
[
441,
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461,
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
485,
487
],
[
489
],
[
491
],
[
493
],
[
495,
497
],
[
499
],
[
501
],
[
507
],
[
509
],
[
513
],
[
515
],
[
517
],
[
519
],
[
523
],
[
525
],
[
531
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555
],
[
557,
559
],
[
561,
563
],
[
565
],
[
567
],
[
569
],
[
571,
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
587
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
619,
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635,
639
],
[
641
],
[
643
],
[
645,
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665,
667
],
[
669
],
[
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683,
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705,
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
733
],
[
737
],
[
739
]
] |
2,514 | static av_cold int rv10_decode_init(AVCodecContext *avctx)
{
RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m;
static int done=0;
int major_ver, minor_ver, micro_ver;
if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
}
ff_MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->orig_width = s->width = avctx->coded_width;
s->orig_height= s->height = avctx->coded_height;
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);
major_ver = RV_GET_MAJOR_VER(rv->sub_id);
minor_ver = RV_GET_MINOR_VER(rv->sub_id);
micro_ver = RV_GET_MICRO_VER(rv->sub_id);
s->low_delay = 1;
switch (major_ver) {
case 1:
s->rv10_version = micro_ver ? 3 : 1;
s->obmc = micro_ver == 2;
break;
case 2:
if (minor_ver >= 2) {
s->low_delay = 0;
s->avctx->has_b_frames = 1;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
av_log_missing_feature(avctx, "RV1/2 version", 1);
return AVERROR_PATCHWELCOME;
}
if(avctx->debug & FF_DEBUG_PICT_INFO){
av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_MPV_common_init(s) < 0)
return -1;
ff_h263_decode_init_vlc();
/* init rv vlc */
if (!done) {
INIT_VLC_STATIC(&rv_dc_lum, DC_VLC_BITS, 256,
rv_lum_bits, 1, 1,
rv_lum_code, 2, 2, 16384);
INIT_VLC_STATIC(&rv_dc_chrom, DC_VLC_BITS, 256,
rv_chrom_bits, 1, 1,
rv_chrom_code, 2, 2, 16388);
done = 1;
}
return 0;
}
| false | FFmpeg | 350128b28fe181087178d128eed84fa269589ffd | static av_cold int rv10_decode_init(AVCodecContext *avctx)
{
RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m;
static int done=0;
int major_ver, minor_ver, micro_ver;
if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
}
ff_MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->orig_width = s->width = avctx->coded_width;
s->orig_height= s->height = avctx->coded_height;
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);
major_ver = RV_GET_MAJOR_VER(rv->sub_id);
minor_ver = RV_GET_MINOR_VER(rv->sub_id);
micro_ver = RV_GET_MICRO_VER(rv->sub_id);
s->low_delay = 1;
switch (major_ver) {
case 1:
s->rv10_version = micro_ver ? 3 : 1;
s->obmc = micro_ver == 2;
break;
case 2:
if (minor_ver >= 2) {
s->low_delay = 0;
s->avctx->has_b_frames = 1;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
av_log_missing_feature(avctx, "RV1/2 version", 1);
return AVERROR_PATCHWELCOME;
}
if(avctx->debug & FF_DEBUG_PICT_INFO){
av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_MPV_common_init(s) < 0)
return -1;
ff_h263_decode_init_vlc();
if (!done) {
INIT_VLC_STATIC(&rv_dc_lum, DC_VLC_BITS, 256,
rv_lum_bits, 1, 1,
rv_lum_code, 2, 2, 16384);
INIT_VLC_STATIC(&rv_dc_chrom, DC_VLC_BITS, 256,
rv_chrom_bits, 1, 1,
rv_chrom_code, 2, 2, 16388);
done = 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m;
static int VAR_0=0;
int VAR_1, VAR_2, VAR_3;
if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
}
ff_MPV_decode_defaults(s);
s->avctx= avctx;
s->out_format = FMT_H263;
s->codec_id= avctx->codec_id;
s->orig_width = s->width = avctx->coded_width;
s->orig_height= s->height = avctx->coded_height;
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);
VAR_1 = RV_GET_MAJOR_VER(rv->sub_id);
VAR_2 = RV_GET_MINOR_VER(rv->sub_id);
VAR_3 = RV_GET_MICRO_VER(rv->sub_id);
s->low_delay = 1;
switch (VAR_1) {
case 1:
s->rv10_version = VAR_3 ? 3 : 1;
s->obmc = VAR_3 == 2;
break;
case 2:
if (VAR_2 >= 2) {
s->low_delay = 0;
s->avctx->has_b_frames = 1;
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
av_log_missing_feature(avctx, "RV1/2 version", 1);
return AVERROR_PATCHWELCOME;
}
if(avctx->debug & FF_DEBUG_PICT_INFO){
av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_MPV_common_init(s) < 0)
return -1;
ff_h263_decode_init_vlc();
if (!VAR_0) {
INIT_VLC_STATIC(&rv_dc_lum, DC_VLC_BITS, 256,
rv_lum_bits, 1, 1,
rv_lum_code, 2, 2, 16384);
INIT_VLC_STATIC(&rv_dc_chrom, DC_VLC_BITS, 256,
rv_chrom_bits, 1, 1,
rv_chrom_code, 2, 2, 16388);
VAR_0 = 1;
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"RVDecContext *rv = avctx->priv_data;",
"MpegEncContext *s = &rv->m;",
"static int VAR_0=0;",
"int VAR_1, VAR_2, VAR_3;",
"if (avctx->extradata_size < 8) {",
"av_log(avctx, AV_LOG_ERROR, \"Extradata is too small.\\n\");",
"return -1;",
"}",
"ff_MPV_decode_defaults(s);",
"s->avctx= avctx;",
"s->out_format = FMT_H263;",
"s->codec_id= avctx->codec_id;",
"s->orig_width = s->width = avctx->coded_width;",
"s->orig_height= s->height = avctx->coded_height;",
"s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;",
"rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);",
"VAR_1 = RV_GET_MAJOR_VER(rv->sub_id);",
"VAR_2 = RV_GET_MINOR_VER(rv->sub_id);",
"VAR_3 = RV_GET_MICRO_VER(rv->sub_id);",
"s->low_delay = 1;",
"switch (VAR_1) {",
"case 1:\ns->rv10_version = VAR_3 ? 3 : 1;",
"s->obmc = VAR_3 == 2;",
"break;",
"case 2:\nif (VAR_2 >= 2) {",
"s->low_delay = 0;",
"s->avctx->has_b_frames = 1;",
"}",
"break;",
"default:\nav_log(s->avctx, AV_LOG_ERROR, \"unknown header %X\\n\", rv->sub_id);",
"av_log_missing_feature(avctx, \"RV1/2 version\", 1);",
"return AVERROR_PATCHWELCOME;",
"}",
"if(avctx->debug & FF_DEBUG_PICT_INFO){",
"av_log(avctx, AV_LOG_DEBUG, \"ver:%X ver0:%X\\n\", rv->sub_id, avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);",
"}",
"avctx->pix_fmt = AV_PIX_FMT_YUV420P;",
"if (ff_MPV_common_init(s) < 0)\nreturn -1;",
"ff_h263_decode_init_vlc();",
"if (!VAR_0) {",
"INIT_VLC_STATIC(&rv_dc_lum, DC_VLC_BITS, 256,\nrv_lum_bits, 1, 1,\nrv_lum_code, 2, 2, 16384);",
"INIT_VLC_STATIC(&rv_dc_chrom, DC_VLC_BITS, 256,\nrv_chrom_bits, 1, 1,\nrv_chrom_code, 2, 2, 16388);",
"VAR_0 = 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105,
107
],
[
111
],
[
117
],
[
119,
121,
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
137
],
[
139
]
] |
2,515 | static inline float32 ucf64_itos(uint32_t i)
{
union {
uint32_t i;
float32 s;
} v;
v.i = i;
return v.s;
}
| false | qemu | e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe | static inline float32 ucf64_itos(uint32_t i)
{
union {
uint32_t i;
float32 s;
} v;
v.i = i;
return v.s;
}
| {
"code": [],
"line_no": []
} | static inline float32 FUNC_0(uint32_t i)
{
union {
uint32_t i;
float32 s;
} VAR_0;
VAR_0.i = i;
return VAR_0.s;
}
| [
"static inline float32 FUNC_0(uint32_t i)\n{",
"union {",
"uint32_t i;",
"float32 s;",
"} VAR_0;",
"VAR_0.i = i;",
"return VAR_0.s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
]
] |
2,516 | static int get_whole_cluster(BlockDriverState *bs,
VmdkExtent *extent,
uint64_t cluster_offset,
uint64_t offset,
bool allocate)
{
/* 128 sectors * 512 bytes each = grain size 64KB */
uint8_t whole_grain[extent->cluster_sectors * 512];
/* we will be here if it's first write on non-exist grain(cluster).
* try to read from parent image, if exist */
if (bs->backing_hd) {
int ret;
if (!vmdk_is_cid_valid(bs))
return -1;
/* floor offset to cluster */
offset -= offset % (extent->cluster_sectors * 512);
ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
extent->cluster_sectors);
if (ret < 0) {
return -1;
}
/* Write grain only into the active image */
ret = bdrv_write(extent->file, cluster_offset, whole_grain,
extent->cluster_sectors);
if (ret < 0) {
return -1;
}
}
return 0;
}
| false | qemu | ae261c86aaed62e7acddafab8262a2bf286d40b7 | static int get_whole_cluster(BlockDriverState *bs,
VmdkExtent *extent,
uint64_t cluster_offset,
uint64_t offset,
bool allocate)
{
uint8_t whole_grain[extent->cluster_sectors * 512];
if (bs->backing_hd) {
int ret;
if (!vmdk_is_cid_valid(bs))
return -1;
offset -= offset % (extent->cluster_sectors * 512);
ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
extent->cluster_sectors);
if (ret < 0) {
return -1;
}
ret = bdrv_write(extent->file, cluster_offset, whole_grain,
extent->cluster_sectors);
if (ret < 0) {
return -1;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0,
VmdkExtent *VAR_1,
uint64_t VAR_2,
uint64_t VAR_3,
bool VAR_4)
{
uint8_t whole_grain[VAR_1->cluster_sectors * 512];
if (VAR_0->backing_hd) {
int VAR_5;
if (!vmdk_is_cid_valid(VAR_0))
return -1;
VAR_3 -= VAR_3 % (VAR_1->cluster_sectors * 512);
VAR_5 = bdrv_read(VAR_0->backing_hd, VAR_3 >> 9, whole_grain,
VAR_1->cluster_sectors);
if (VAR_5 < 0) {
return -1;
}
VAR_5 = bdrv_write(VAR_1->file, VAR_2, whole_grain,
VAR_1->cluster_sectors);
if (VAR_5 < 0) {
return -1;
}
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nVmdkExtent *VAR_1,\nuint64_t VAR_2,\nuint64_t VAR_3,\nbool VAR_4)\n{",
"uint8_t whole_grain[VAR_1->cluster_sectors * 512];",
"if (VAR_0->backing_hd) {",
"int VAR_5;",
"if (!vmdk_is_cid_valid(VAR_0))\nreturn -1;",
"VAR_3 -= VAR_3 % (VAR_1->cluster_sectors * 512);",
"VAR_5 = bdrv_read(VAR_0->backing_hd, VAR_3 >> 9, whole_grain,\nVAR_1->cluster_sectors);",
"if (VAR_5 < 0) {",
"return -1;",
"}",
"VAR_5 = bdrv_write(VAR_1->file, VAR_2, whole_grain,\nVAR_1->cluster_sectors);",
"if (VAR_5 < 0) {",
"return -1;",
"}",
"}",
"return 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
],
[
23
],
[
25
],
[
29,
31
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
2,517 | static void virtio_pci_reset(DeviceState *qdev)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev);
VirtioBusState *bus = VIRTIO_BUS(&proxy->bus);
virtio_pci_stop_ioeventfd(proxy);
virtio_bus_reset(bus);
msix_unuse_all_vectors(&proxy->pci_dev);
proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
}
| false | qemu | 4d43d3f3c8147ade184df9a1e9e82826edd39e19 | static void virtio_pci_reset(DeviceState *qdev)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev);
VirtioBusState *bus = VIRTIO_BUS(&proxy->bus);
virtio_pci_stop_ioeventfd(proxy);
virtio_bus_reset(bus);
msix_unuse_all_vectors(&proxy->pci_dev);
proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);
VirtioBusState *bus = VIRTIO_BUS(&proxy->bus);
virtio_pci_stop_ioeventfd(proxy);
virtio_bus_reset(bus);
msix_unuse_all_vectors(&proxy->pci_dev);
proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
}
| [
"static void FUNC_0(DeviceState *VAR_0)\n{",
"VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);",
"VirtioBusState *bus = VIRTIO_BUS(&proxy->bus);",
"virtio_pci_stop_ioeventfd(proxy);",
"virtio_bus_reset(bus);",
"msix_unuse_all_vectors(&proxy->pci_dev);",
"proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
2,518 | void nbd_client_session_attach_aio_context(NbdClientSession *client,
AioContext *new_context)
{
aio_set_fd_handler(new_context, client->sock,
nbd_reply_ready, NULL, client);
}
| false | qemu | f53a829bb9ef14be800556cbc02d8b20fc1050a7 | void nbd_client_session_attach_aio_context(NbdClientSession *client,
AioContext *new_context)
{
aio_set_fd_handler(new_context, client->sock,
nbd_reply_ready, NULL, client);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(NbdClientSession *VAR_0,
AioContext *VAR_1)
{
aio_set_fd_handler(VAR_1, VAR_0->sock,
nbd_reply_ready, NULL, VAR_0);
}
| [
"void FUNC_0(NbdClientSession *VAR_0,\nAioContext *VAR_1)\n{",
"aio_set_fd_handler(VAR_1, VAR_0->sock,\nnbd_reply_ready, NULL, VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
11
]
] |
2,519 | int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
{
ram_addr_t addr;
uint64_t bytes_transferred_last;
double bwidth = 0;
uint64_t expected_time = 0;
if (stage < 0) {
cpu_physical_memory_set_dirty_tracking(0);
return 0;
}
if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
qemu_file_set_error(f, -EINVAL);
return 0;
}
if (stage == 1) {
RAMBlock *block;
bytes_transferred = 0;
last_block = NULL;
last_offset = 0;
sort_ram_list();
/* Make sure all dirty bits are set */
QLIST_FOREACH(block, &ram_list.blocks, next) {
for (addr = block->offset; addr < block->offset + block->length;
addr += TARGET_PAGE_SIZE) {
if (!cpu_physical_memory_get_dirty(addr,
MIGRATION_DIRTY_FLAG)) {
cpu_physical_memory_set_dirty(addr);
}
}
}
/* Enable dirty memory tracking */
cpu_physical_memory_set_dirty_tracking(1);
qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
QLIST_FOREACH(block, &ram_list.blocks, next) {
qemu_put_byte(f, strlen(block->idstr));
qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
qemu_put_be64(f, block->length);
}
}
bytes_transferred_last = bytes_transferred;
bwidth = qemu_get_clock_ns(rt_clock);
while (!qemu_file_rate_limit(f)) {
int bytes_sent;
bytes_sent = ram_save_block(f);
bytes_transferred += bytes_sent;
if (bytes_sent == 0) { /* no more blocks */
break;
}
}
bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
/* if we haven't transferred anything this round, force expected_time to a
* a very high value, but without crashing */
if (bwidth == 0) {
bwidth = 0.000001;
}
/* try transferring iterative blocks of memory */
if (stage == 3) {
int bytes_sent;
/* flush all remaining blocks regardless of rate limiting */
while ((bytes_sent = ram_save_block(f)) != 0) {
bytes_transferred += bytes_sent;
}
cpu_physical_memory_set_dirty_tracking(0);
}
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
return (stage == 2) && (expected_time <= migrate_max_downtime());
}
| false | qemu | 2975725f6b3d634dbe924ea9d9f4d86b8a5b217d | int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
{
ram_addr_t addr;
uint64_t bytes_transferred_last;
double bwidth = 0;
uint64_t expected_time = 0;
if (stage < 0) {
cpu_physical_memory_set_dirty_tracking(0);
return 0;
}
if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
qemu_file_set_error(f, -EINVAL);
return 0;
}
if (stage == 1) {
RAMBlock *block;
bytes_transferred = 0;
last_block = NULL;
last_offset = 0;
sort_ram_list();
QLIST_FOREACH(block, &ram_list.blocks, next) {
for (addr = block->offset; addr < block->offset + block->length;
addr += TARGET_PAGE_SIZE) {
if (!cpu_physical_memory_get_dirty(addr,
MIGRATION_DIRTY_FLAG)) {
cpu_physical_memory_set_dirty(addr);
}
}
}
cpu_physical_memory_set_dirty_tracking(1);
qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
QLIST_FOREACH(block, &ram_list.blocks, next) {
qemu_put_byte(f, strlen(block->idstr));
qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
qemu_put_be64(f, block->length);
}
}
bytes_transferred_last = bytes_transferred;
bwidth = qemu_get_clock_ns(rt_clock);
while (!qemu_file_rate_limit(f)) {
int bytes_sent;
bytes_sent = ram_save_block(f);
bytes_transferred += bytes_sent;
if (bytes_sent == 0) {
break;
}
}
bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
if (bwidth == 0) {
bwidth = 0.000001;
}
if (stage == 3) {
int bytes_sent;
while ((bytes_sent = ram_save_block(f)) != 0) {
bytes_transferred += bytes_sent;
}
cpu_physical_memory_set_dirty_tracking(0);
}
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
return (stage == 2) && (expected_time <= migrate_max_downtime());
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1, int VAR_2, void *VAR_3)
{
ram_addr_t addr;
uint64_t bytes_transferred_last;
double VAR_4 = 0;
uint64_t expected_time = 0;
if (VAR_2 < 0) {
cpu_physical_memory_set_dirty_tracking(0);
return 0;
}
if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
qemu_file_set_error(VAR_1, -EINVAL);
return 0;
}
if (VAR_2 == 1) {
RAMBlock *block;
bytes_transferred = 0;
last_block = NULL;
last_offset = 0;
sort_ram_list();
QLIST_FOREACH(block, &ram_list.blocks, next) {
for (addr = block->offset; addr < block->offset + block->length;
addr += TARGET_PAGE_SIZE) {
if (!cpu_physical_memory_get_dirty(addr,
MIGRATION_DIRTY_FLAG)) {
cpu_physical_memory_set_dirty(addr);
}
}
}
cpu_physical_memory_set_dirty_tracking(1);
qemu_put_be64(VAR_1, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
QLIST_FOREACH(block, &ram_list.blocks, next) {
qemu_put_byte(VAR_1, strlen(block->idstr));
qemu_put_buffer(VAR_1, (uint8_t *)block->idstr, strlen(block->idstr));
qemu_put_be64(VAR_1, block->length);
}
}
bytes_transferred_last = bytes_transferred;
VAR_4 = qemu_get_clock_ns(rt_clock);
while (!qemu_file_rate_limit(VAR_1)) {
int VAR_6;
VAR_6 = ram_save_block(VAR_1);
bytes_transferred += VAR_6;
if (VAR_6 == 0) {
break;
}
}
VAR_4 = qemu_get_clock_ns(rt_clock) - VAR_4;
VAR_4 = (bytes_transferred - bytes_transferred_last) / VAR_4;
if (VAR_4 == 0) {
VAR_4 = 0.000001;
}
if (VAR_2 == 3) {
int VAR_6;
while ((VAR_6 = ram_save_block(VAR_1)) != 0) {
bytes_transferred += VAR_6;
}
cpu_physical_memory_set_dirty_tracking(0);
}
qemu_put_be64(VAR_1, RAM_SAVE_FLAG_EOS);
expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / VAR_4;
return (VAR_2 == 2) && (expected_time <= migrate_max_downtime());
}
| [
"int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1, int VAR_2, void *VAR_3)\n{",
"ram_addr_t addr;",
"uint64_t bytes_transferred_last;",
"double VAR_4 = 0;",
"uint64_t expected_time = 0;",
"if (VAR_2 < 0) {",
"cpu_physical_memory_set_dirty_tracking(0);",
"return 0;",
"}",
"if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {",
"qemu_file_set_error(VAR_1, -EINVAL);",
"return 0;",
"}",
"if (VAR_2 == 1) {",
"RAMBlock *block;",
"bytes_transferred = 0;",
"last_block = NULL;",
"last_offset = 0;",
"sort_ram_list();",
"QLIST_FOREACH(block, &ram_list.blocks, next) {",
"for (addr = block->offset; addr < block->offset + block->length;",
"addr += TARGET_PAGE_SIZE) {",
"if (!cpu_physical_memory_get_dirty(addr,\nMIGRATION_DIRTY_FLAG)) {",
"cpu_physical_memory_set_dirty(addr);",
"}",
"}",
"}",
"cpu_physical_memory_set_dirty_tracking(1);",
"qemu_put_be64(VAR_1, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);",
"QLIST_FOREACH(block, &ram_list.blocks, next) {",
"qemu_put_byte(VAR_1, strlen(block->idstr));",
"qemu_put_buffer(VAR_1, (uint8_t *)block->idstr, strlen(block->idstr));",
"qemu_put_be64(VAR_1, block->length);",
"}",
"}",
"bytes_transferred_last = bytes_transferred;",
"VAR_4 = qemu_get_clock_ns(rt_clock);",
"while (!qemu_file_rate_limit(VAR_1)) {",
"int VAR_6;",
"VAR_6 = ram_save_block(VAR_1);",
"bytes_transferred += VAR_6;",
"if (VAR_6 == 0) {",
"break;",
"}",
"}",
"VAR_4 = qemu_get_clock_ns(rt_clock) - VAR_4;",
"VAR_4 = (bytes_transferred - bytes_transferred_last) / VAR_4;",
"if (VAR_4 == 0) {",
"VAR_4 = 0.000001;",
"}",
"if (VAR_2 == 3) {",
"int VAR_6;",
"while ((VAR_6 = ram_save_block(VAR_1)) != 0) {",
"bytes_transferred += VAR_6;",
"}",
"cpu_physical_memory_set_dirty_tracking(0);",
"}",
"qemu_put_be64(VAR_1, RAM_SAVE_FLAG_EOS);",
"expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / VAR_4;",
"return (VAR_2 == 2) && (expected_time <= migrate_max_downtime());",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
165
],
[
169
],
[
171
]
] |
2,520 | static void test_submit(void)
{
WorkerTestData data = { .n = 0 };
thread_pool_submit(worker_cb, &data);
qemu_aio_flush();
g_assert_cmpint(data.n, ==, 1);
}
| false | qemu | 8a805c222caa0e20bf11d2267f726d0bb5917d94 | static void test_submit(void)
{
WorkerTestData data = { .n = 0 };
thread_pool_submit(worker_cb, &data);
qemu_aio_flush();
g_assert_cmpint(data.n, ==, 1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
WorkerTestData data = { .n = 0 };
thread_pool_submit(worker_cb, &data);
qemu_aio_flush();
g_assert_cmpint(data.n, ==, 1);
}
| [
"static void FUNC_0(void)\n{",
"WorkerTestData data = { .n = 0 };",
"thread_pool_submit(worker_cb, &data);",
"qemu_aio_flush();",
"g_assert_cmpint(data.n, ==, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
2,522 | int bdrv_commit(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
int64_t sector, total_sectors, length, backing_length;
int n, ro, open_flags;
int ret = 0;
uint8_t *buf = NULL;
char filename[PATH_MAX];
if (!drv)
return -ENOMEDIUM;
if (!bs->backing_hd) {
return -ENOTSUP;
}
if (bdrv_in_use(bs) || bdrv_in_use(bs->backing_hd)) {
return -EBUSY;
}
ro = bs->backing_hd->read_only;
/* Use pstrcpy (not strncpy): filename must be NUL-terminated. */
pstrcpy(filename, sizeof(filename), bs->backing_hd->filename);
open_flags = bs->backing_hd->open_flags;
if (ro) {
if (bdrv_reopen(bs->backing_hd, open_flags | BDRV_O_RDWR, NULL)) {
return -EACCES;
}
}
length = bdrv_getlength(bs);
if (length < 0) {
ret = length;
goto ro_cleanup;
}
backing_length = bdrv_getlength(bs->backing_hd);
if (backing_length < 0) {
ret = backing_length;
goto ro_cleanup;
}
/* If our top snapshot is larger than the backing file image,
* grow the backing file image if possible. If not possible,
* we must return an error */
if (length > backing_length) {
ret = bdrv_truncate(bs->backing_hd, length);
if (ret < 0) {
goto ro_cleanup;
}
}
total_sectors = length >> BDRV_SECTOR_BITS;
buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
for (sector = 0; sector < total_sectors; sector += n) {
ret = bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n);
if (ret < 0) {
goto ro_cleanup;
}
if (ret) {
ret = bdrv_read(bs, sector, buf, n);
if (ret < 0) {
goto ro_cleanup;
}
ret = bdrv_write(bs->backing_hd, sector, buf, n);
if (ret < 0) {
goto ro_cleanup;
}
}
}
if (drv->bdrv_make_empty) {
ret = drv->bdrv_make_empty(bs);
if (ret < 0) {
goto ro_cleanup;
}
bdrv_flush(bs);
}
/*
* Make sure all data we wrote to the backing device is actually
* stable on disk.
*/
if (bs->backing_hd) {
bdrv_flush(bs->backing_hd);
}
ret = 0;
ro_cleanup:
g_free(buf);
if (ro) {
/* ignoring error return here */
bdrv_reopen(bs->backing_hd, open_flags & ~BDRV_O_RDWR, NULL);
}
return ret;
}
| false | qemu | 3718d8ab65f68de2acccbe6a315907805f54e3cc | int bdrv_commit(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
int64_t sector, total_sectors, length, backing_length;
int n, ro, open_flags;
int ret = 0;
uint8_t *buf = NULL;
char filename[PATH_MAX];
if (!drv)
return -ENOMEDIUM;
if (!bs->backing_hd) {
return -ENOTSUP;
}
if (bdrv_in_use(bs) || bdrv_in_use(bs->backing_hd)) {
return -EBUSY;
}
ro = bs->backing_hd->read_only;
pstrcpy(filename, sizeof(filename), bs->backing_hd->filename);
open_flags = bs->backing_hd->open_flags;
if (ro) {
if (bdrv_reopen(bs->backing_hd, open_flags | BDRV_O_RDWR, NULL)) {
return -EACCES;
}
}
length = bdrv_getlength(bs);
if (length < 0) {
ret = length;
goto ro_cleanup;
}
backing_length = bdrv_getlength(bs->backing_hd);
if (backing_length < 0) {
ret = backing_length;
goto ro_cleanup;
}
if (length > backing_length) {
ret = bdrv_truncate(bs->backing_hd, length);
if (ret < 0) {
goto ro_cleanup;
}
}
total_sectors = length >> BDRV_SECTOR_BITS;
buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
for (sector = 0; sector < total_sectors; sector += n) {
ret = bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n);
if (ret < 0) {
goto ro_cleanup;
}
if (ret) {
ret = bdrv_read(bs, sector, buf, n);
if (ret < 0) {
goto ro_cleanup;
}
ret = bdrv_write(bs->backing_hd, sector, buf, n);
if (ret < 0) {
goto ro_cleanup;
}
}
}
if (drv->bdrv_make_empty) {
ret = drv->bdrv_make_empty(bs);
if (ret < 0) {
goto ro_cleanup;
}
bdrv_flush(bs);
}
if (bs->backing_hd) {
bdrv_flush(bs->backing_hd);
}
ret = 0;
ro_cleanup:
g_free(buf);
if (ro) {
bdrv_reopen(bs->backing_hd, open_flags & ~BDRV_O_RDWR, NULL);
}
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0)
{
BlockDriver *drv = VAR_0->drv;
int64_t sector, total_sectors, length, backing_length;
int VAR_1, VAR_2, VAR_3;
int VAR_4 = 0;
uint8_t *buf = NULL;
char VAR_5[PATH_MAX];
if (!drv)
return -ENOMEDIUM;
if (!VAR_0->backing_hd) {
return -ENOTSUP;
}
if (bdrv_in_use(VAR_0) || bdrv_in_use(VAR_0->backing_hd)) {
return -EBUSY;
}
VAR_2 = VAR_0->backing_hd->read_only;
pstrcpy(VAR_5, sizeof(VAR_5), VAR_0->backing_hd->VAR_5);
VAR_3 = VAR_0->backing_hd->VAR_3;
if (VAR_2) {
if (bdrv_reopen(VAR_0->backing_hd, VAR_3 | BDRV_O_RDWR, NULL)) {
return -EACCES;
}
}
length = bdrv_getlength(VAR_0);
if (length < 0) {
VAR_4 = length;
goto ro_cleanup;
}
backing_length = bdrv_getlength(VAR_0->backing_hd);
if (backing_length < 0) {
VAR_4 = backing_length;
goto ro_cleanup;
}
if (length > backing_length) {
VAR_4 = bdrv_truncate(VAR_0->backing_hd, length);
if (VAR_4 < 0) {
goto ro_cleanup;
}
}
total_sectors = length >> BDRV_SECTOR_BITS;
buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
for (sector = 0; sector < total_sectors; sector += VAR_1) {
VAR_4 = bdrv_is_allocated(VAR_0, sector, COMMIT_BUF_SECTORS, &VAR_1);
if (VAR_4 < 0) {
goto ro_cleanup;
}
if (VAR_4) {
VAR_4 = bdrv_read(VAR_0, sector, buf, VAR_1);
if (VAR_4 < 0) {
goto ro_cleanup;
}
VAR_4 = bdrv_write(VAR_0->backing_hd, sector, buf, VAR_1);
if (VAR_4 < 0) {
goto ro_cleanup;
}
}
}
if (drv->bdrv_make_empty) {
VAR_4 = drv->bdrv_make_empty(VAR_0);
if (VAR_4 < 0) {
goto ro_cleanup;
}
bdrv_flush(VAR_0);
}
if (VAR_0->backing_hd) {
bdrv_flush(VAR_0->backing_hd);
}
VAR_4 = 0;
ro_cleanup:
g_free(buf);
if (VAR_2) {
bdrv_reopen(VAR_0->backing_hd, VAR_3 & ~BDRV_O_RDWR, NULL);
}
return VAR_4;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"BlockDriver *drv = VAR_0->drv;",
"int64_t sector, total_sectors, length, backing_length;",
"int VAR_1, VAR_2, VAR_3;",
"int VAR_4 = 0;",
"uint8_t *buf = NULL;",
"char VAR_5[PATH_MAX];",
"if (!drv)\nreturn -ENOMEDIUM;",
"if (!VAR_0->backing_hd) {",
"return -ENOTSUP;",
"}",
"if (bdrv_in_use(VAR_0) || bdrv_in_use(VAR_0->backing_hd)) {",
"return -EBUSY;",
"}",
"VAR_2 = VAR_0->backing_hd->read_only;",
"pstrcpy(VAR_5, sizeof(VAR_5), VAR_0->backing_hd->VAR_5);",
"VAR_3 = VAR_0->backing_hd->VAR_3;",
"if (VAR_2) {",
"if (bdrv_reopen(VAR_0->backing_hd, VAR_3 | BDRV_O_RDWR, NULL)) {",
"return -EACCES;",
"}",
"}",
"length = bdrv_getlength(VAR_0);",
"if (length < 0) {",
"VAR_4 = length;",
"goto ro_cleanup;",
"}",
"backing_length = bdrv_getlength(VAR_0->backing_hd);",
"if (backing_length < 0) {",
"VAR_4 = backing_length;",
"goto ro_cleanup;",
"}",
"if (length > backing_length) {",
"VAR_4 = bdrv_truncate(VAR_0->backing_hd, length);",
"if (VAR_4 < 0) {",
"goto ro_cleanup;",
"}",
"}",
"total_sectors = length >> BDRV_SECTOR_BITS;",
"buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);",
"for (sector = 0; sector < total_sectors; sector += VAR_1) {",
"VAR_4 = bdrv_is_allocated(VAR_0, sector, COMMIT_BUF_SECTORS, &VAR_1);",
"if (VAR_4 < 0) {",
"goto ro_cleanup;",
"}",
"if (VAR_4) {",
"VAR_4 = bdrv_read(VAR_0, sector, buf, VAR_1);",
"if (VAR_4 < 0) {",
"goto ro_cleanup;",
"}",
"VAR_4 = bdrv_write(VAR_0->backing_hd, sector, buf, VAR_1);",
"if (VAR_4 < 0) {",
"goto ro_cleanup;",
"}",
"}",
"}",
"if (drv->bdrv_make_empty) {",
"VAR_4 = drv->bdrv_make_empty(VAR_0);",
"if (VAR_4 < 0) {",
"goto ro_cleanup;",
"}",
"bdrv_flush(VAR_0);",
"}",
"if (VAR_0->backing_hd) {",
"bdrv_flush(VAR_0->backing_hd);",
"}",
"VAR_4 = 0;",
"ro_cleanup:\ng_free(buf);",
"if (VAR_2) {",
"bdrv_reopen(VAR_0->backing_hd, VAR_3 & ~BDRV_O_RDWR, NULL);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183,
185
],
[
189
],
[
193
],
[
195
],
[
199
],
[
201
]
] |
2,524 | static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
{
/* binary search */
uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
while(chunk1!=chunk2) {
chunk3 = (chunk1+chunk2)/2;
if(s->sectors[chunk3]>sector_num)
chunk2 = chunk3;
else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
return chunk3;
else
chunk1 = chunk3;
}
return s->n_chunks; /* error */
}
| false | qemu | 2c1885adcf0312da80c7317b09f9adad97fa0fc6 | static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
{
uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
while(chunk1!=chunk2) {
chunk3 = (chunk1+chunk2)/2;
if(s->sectors[chunk3]>sector_num)
chunk2 = chunk3;
else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
return chunk3;
else
chunk1 = chunk3;
}
return s->n_chunks;
}
| {
"code": [],
"line_no": []
} | static inline uint32_t FUNC_0(BDRVDMGState* s,int sector_num)
{
uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
while(chunk1!=chunk2) {
chunk3 = (chunk1+chunk2)/2;
if(s->sectors[chunk3]>sector_num)
chunk2 = chunk3;
else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
return chunk3;
else
chunk1 = chunk3;
}
return s->n_chunks;
}
| [
"static inline uint32_t FUNC_0(BDRVDMGState* s,int sector_num)\n{",
"uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;",
"while(chunk1!=chunk2) {",
"chunk3 = (chunk1+chunk2)/2;",
"if(s->sectors[chunk3]>sector_num)\nchunk2 = chunk3;",
"else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)\nreturn chunk3;",
"else\nchunk1 = chunk3;",
"}",
"return s->n_chunks;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
]
] |
2,525 | static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
| {
"code": [
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#endif",
"#endif",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 16;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 16;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\t\t*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 16;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t4%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 8%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 12%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 16;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tregister int rgb = *(uint32_t*)s; s += 4;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t__asm __volatile(",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"#endif"
],
"line_no": [
109,
109,
109,
109,
9,
13,
9,
13,
13,
13,
23,
49,
93,
23,
49,
61,
69,
81,
93,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
29,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
13,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
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,
103,
105,
13,
109,
113,
115,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
99,
13,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
99,
103,
105,
13,
109,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
33,
37,
39,
41,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
37,
39,
41,
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,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
33,
37,
39,
41,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
23,
13,
103,
105,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
39,
93,
13,
39,
93,
13,
13
]
} | static inline void FUNC_0(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = VAR_1 - 15;
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_16mask):"memory");
d += 4;
VAR_0 += 16;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;
*d++ = ((VAR_2&0xF8)<<8) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>19);
}
}
| [
"static inline void FUNC_0(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"mm_end = VAR_1 - 15;",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t4%1, %%mm3\\n\\t\"\n\"punpckldq 8%1, %%mm0\\n\\t\"\n\"punpckldq 12%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm3\\n\\t\"\n\"pand\t%%mm7, %%mm0\\n\\t\"\n\"pand\t%%mm7, %%mm3\\n\\t\"\n\"psrlq\t$5, %%mm1\\n\\t\"\n\"psrlq\t$5, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$19, %%mm2\\n\\t\"\n\"psrlq\t$19, %%mm5\\n\\t\"\n\"pand\t%2, %%mm2\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_16mask):\"memory\");",
"d += 4;",
"VAR_0 += 16;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;",
"*d++ = ((VAR_2&0xF8)<<8) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>19);",
"}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23,
25,
27,
29
],
[
31
],
[
33,
35
],
[
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
]
] |
2,526 | static void conv411(uint8_t *dst, int dst_wrap,
uint8_t *src, int src_wrap,
int width, int height)
{
int w, c;
uint8_t *s1, *s2, *d;
for(;height > 0; height--) {
s1 = src;
s2 = src + src_wrap;
d = dst;
for(w = width;w > 0; w--) {
c = (s1[0] + s2[0]) >> 1;
d[0] = c;
d[1] = c;
s1++;
s2++;
d += 2;
}
src += src_wrap * 2;
dst += dst_wrap;
}
} | true | FFmpeg | 5064357588a187672ca64c169dc6e6e406777629 | static void conv411(uint8_t *dst, int dst_wrap,
uint8_t *src, int src_wrap,
int width, int height)
{
int w, c;
uint8_t *s1, *s2, *d;
for(;height > 0; height--) {
s1 = src;
s2 = src + src_wrap;
d = dst;
for(w = width;w > 0; w--) {
c = (s1[0] + s2[0]) >> 1;
d[0] = c;
d[1] = c;
s1++;
s2++;
d += 2;
}
src += src_wrap * 2;
dst += dst_wrap;
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int VAR_1,
uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5)
{
int VAR_6, VAR_7;
uint8_t *s1, *s2, *d;
for(;VAR_5 > 0; VAR_5--) {
s1 = VAR_2;
s2 = VAR_2 + VAR_3;
d = VAR_0;
for(VAR_6 = VAR_4;VAR_6 > 0; VAR_6--) {
VAR_7 = (s1[0] + s2[0]) >> 1;
d[0] = VAR_7;
d[1] = VAR_7;
s1++;
s2++;
d += 2;
}
VAR_2 += VAR_3 * 2;
VAR_0 += VAR_1;
}
} | [
"static void FUNC_0(uint8_t *VAR_0, int VAR_1,\nuint8_t *VAR_2, int VAR_3,\nint VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7;",
"uint8_t *s1, *s2, *d;",
"for(;VAR_5 > 0; VAR_5--) {",
"s1 = VAR_2;",
"s2 = VAR_2 + VAR_3;",
"d = VAR_0;",
"for(VAR_6 = VAR_4;VAR_6 > 0; VAR_6--) {",
"VAR_7 = (s1[0] + s2[0]) >> 1;",
"d[0] = VAR_7;",
"d[1] = VAR_7;",
"s1++;",
"s2++;",
"d += 2;",
"}",
"VAR_2 += VAR_3 * 2;",
"VAR_0 += VAR_1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
]
] |
2,527 | static void *acpi_set_bsel(PCIBus *bus, void *opaque)
{
unsigned *bsel_alloc = opaque;
unsigned *bus_bsel;
if (qbus_is_hotpluggable(BUS(bus))) {
bus_bsel = g_malloc(sizeof *bus_bsel);
*bus_bsel = (*bsel_alloc)++;
object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
return bsel_alloc;
}
| true | qemu | f0c9d64a68b776374ec4732424a3e27753ce37b6 | static void *acpi_set_bsel(PCIBus *bus, void *opaque)
{
unsigned *bsel_alloc = opaque;
unsigned *bus_bsel;
if (qbus_is_hotpluggable(BUS(bus))) {
bus_bsel = g_malloc(sizeof *bus_bsel);
*bus_bsel = (*bsel_alloc)++;
object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
return bsel_alloc;
}
| {
"code": [
" bus_bsel, NULL);",
" bus_bsel, NULL);"
],
"line_no": [
21,
21
]
} | static void *FUNC_0(PCIBus *VAR_0, void *VAR_1)
{
unsigned *VAR_2 = VAR_1;
unsigned *VAR_3;
if (qbus_is_hotpluggable(BUS(VAR_0))) {
VAR_3 = g_malloc(sizeof *VAR_3);
*VAR_3 = (*VAR_2)++;
object_property_add_uint32_ptr(OBJECT(VAR_0), ACPI_PCIHP_PROP_BSEL,
VAR_3, NULL);
}
return VAR_2;
}
| [
"static void *FUNC_0(PCIBus *VAR_0, void *VAR_1)\n{",
"unsigned *VAR_2 = VAR_1;",
"unsigned *VAR_3;",
"if (qbus_is_hotpluggable(BUS(VAR_0))) {",
"VAR_3 = g_malloc(sizeof *VAR_3);",
"*VAR_3 = (*VAR_2)++;",
"object_property_add_uint32_ptr(OBJECT(VAR_0), ACPI_PCIHP_PROP_BSEL,\nVAR_3, NULL);",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
]
] |
2,528 | static void vncws_send_handshake_response(VncState *vs, const char* key)
{
char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
char hash[SHA1_DIGEST_LEN];
size_t hash_size = SHA1_DIGEST_LEN;
char *accept = NULL, *response = NULL;
gnutls_datum_t in;
g_strlcpy(combined_key, key, WS_CLIENT_KEY_LEN + 1);
g_strlcat(combined_key, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);
/* hash and encode it */
in.data = (void *)combined_key;
in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;
if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size)
== GNUTLS_E_SUCCESS) {
accept = g_base64_encode((guchar *)hash, SHA1_DIGEST_LEN);
}
if (accept == NULL) {
VNC_DEBUG("Hashing Websocket combined key failed\n");
vnc_client_error(vs);
return;
}
response = g_strdup_printf(WS_HANDSHAKE, accept);
vnc_write(vs, response, strlen(response));
vnc_flush(vs);
g_free(accept);
g_free(response);
vs->encode_ws = 1;
vnc_init_state(vs);
}
| true | qemu | cfba8e6f92d45a2374622c3dc57499e42a1c07e1 | static void vncws_send_handshake_response(VncState *vs, const char* key)
{
char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
char hash[SHA1_DIGEST_LEN];
size_t hash_size = SHA1_DIGEST_LEN;
char *accept = NULL, *response = NULL;
gnutls_datum_t in;
g_strlcpy(combined_key, key, WS_CLIENT_KEY_LEN + 1);
g_strlcat(combined_key, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);
in.data = (void *)combined_key;
in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;
if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size)
== GNUTLS_E_SUCCESS) {
accept = g_base64_encode((guchar *)hash, SHA1_DIGEST_LEN);
}
if (accept == NULL) {
VNC_DEBUG("Hashing Websocket combined key failed\n");
vnc_client_error(vs);
return;
}
response = g_strdup_printf(WS_HANDSHAKE, accept);
vnc_write(vs, response, strlen(response));
vnc_flush(vs);
g_free(accept);
g_free(response);
vs->encode_ws = 1;
vnc_init_state(vs);
}
| {
"code": [
" char hash[SHA1_DIGEST_LEN];",
" size_t hash_size = SHA1_DIGEST_LEN;",
" if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size)",
" == GNUTLS_E_SUCCESS) {",
" accept = g_base64_encode((guchar *)hash, SHA1_DIGEST_LEN);"
],
"line_no": [
7,
9,
29,
31,
33
]
} | static void FUNC_0(VncState *VAR_0, const char* VAR_1)
{
char VAR_2[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
char VAR_3[SHA1_DIGEST_LEN];
size_t hash_size = SHA1_DIGEST_LEN;
char *VAR_4 = NULL, *VAR_5 = NULL;
gnutls_datum_t in;
g_strlcpy(VAR_2, VAR_1, WS_CLIENT_KEY_LEN + 1);
g_strlcat(VAR_2, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);
in.data = (void *)VAR_2;
in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;
if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, VAR_3, &hash_size)
== GNUTLS_E_SUCCESS) {
VAR_4 = g_base64_encode((guchar *)VAR_3, SHA1_DIGEST_LEN);
}
if (VAR_4 == NULL) {
VNC_DEBUG("Hashing Websocket combined VAR_1 failed\n");
vnc_client_error(VAR_0);
return;
}
VAR_5 = g_strdup_printf(WS_HANDSHAKE, VAR_4);
vnc_write(VAR_0, VAR_5, strlen(VAR_5));
vnc_flush(VAR_0);
g_free(VAR_4);
g_free(VAR_5);
VAR_0->encode_ws = 1;
vnc_init_state(VAR_0);
}
| [
"static void FUNC_0(VncState *VAR_0, const char* VAR_1)\n{",
"char VAR_2[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];",
"char VAR_3[SHA1_DIGEST_LEN];",
"size_t hash_size = SHA1_DIGEST_LEN;",
"char *VAR_4 = NULL, *VAR_5 = NULL;",
"gnutls_datum_t in;",
"g_strlcpy(VAR_2, VAR_1, WS_CLIENT_KEY_LEN + 1);",
"g_strlcat(VAR_2, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);",
"in.data = (void *)VAR_2;",
"in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;",
"if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, VAR_3, &hash_size)\n== GNUTLS_E_SUCCESS) {",
"VAR_4 = g_base64_encode((guchar *)VAR_3, SHA1_DIGEST_LEN);",
"}",
"if (VAR_4 == NULL) {",
"VNC_DEBUG(\"Hashing Websocket combined VAR_1 failed\\n\");",
"vnc_client_error(VAR_0);",
"return;",
"}",
"VAR_5 = g_strdup_printf(WS_HANDSHAKE, VAR_4);",
"vnc_write(VAR_0, VAR_5, strlen(VAR_5));",
"vnc_flush(VAR_0);",
"g_free(VAR_4);",
"g_free(VAR_5);",
"VAR_0->encode_ws = 1;",
"vnc_init_state(VAR_0);",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
]
] |
2,530 | int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride)
{
int i, o, i0, o0, ret;
char in_layout_name[128];
char out_layout_name[128];
if ( am->in_channels <= 0 || am->in_channels > AVRESAMPLE_MAX_CHANNELS ||
am->out_channels <= 0 || am->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(am->avr, AV_LOG_ERROR, "Invalid channel counts\n");
return AVERROR(EINVAL);
}
if (am->matrix) {
av_free(am->matrix[0]);
am->matrix = NULL;
}
am->in_matrix_channels = am->in_channels;
am->out_matrix_channels = am->out_channels;
reduce_matrix(am, matrix, stride);
#define CONVERT_MATRIX(type, expr) \
am->matrix_## type[0] = av_mallocz(am->out_matrix_channels * \
am->in_matrix_channels * \
sizeof(*am->matrix_## type[0])); \
if (!am->matrix_## type[0]) \
return AVERROR(ENOMEM); \
for (o = 0, o0 = 0; o < am->out_channels; o++) { \
if (am->output_zero[o] || am->output_skip[o]) \
continue; \
if (o0 > 0) \
am->matrix_## type[o0] = am->matrix_## type[o0 - 1] + \
am->in_matrix_channels; \
for (i = 0, i0 = 0; i < am->in_channels; i++) { \
double v; \
if (am->input_skip[i]) \
continue; \
v = matrix[o * stride + i]; \
am->matrix_## type[o0][i0] = expr; \
i0++; \
} \
o0++; \
} \
am->matrix = (void **)am->matrix_## type;
if (am->in_matrix_channels && am->out_matrix_channels) {
switch (am->coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
break;
case AV_MIX_COEFF_TYPE_Q15:
CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
break;
case AV_MIX_COEFF_TYPE_FLT:
CONVERT_MATRIX(flt, v)
break;
default:
av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
}
ret = mix_function_init(am);
if (ret < 0)
return ret;
av_get_channel_layout_string(in_layout_name, sizeof(in_layout_name),
am->in_channels, am->in_layout);
av_get_channel_layout_string(out_layout_name, sizeof(out_layout_name),
am->out_channels, am->out_layout);
av_log(am->avr, AV_LOG_DEBUG, "audio_mix: %s to %s\n",
in_layout_name, out_layout_name);
av_log(am->avr, AV_LOG_DEBUG, "matrix size: %d x %d\n",
am->in_matrix_channels, am->out_matrix_channels);
for (o = 0; o < am->out_channels; o++) {
for (i = 0; i < am->in_channels; i++) {
if (am->output_zero[o])
av_log(am->avr, AV_LOG_DEBUG, " (ZERO)");
else if (am->input_skip[i] || am->output_skip[o])
av_log(am->avr, AV_LOG_DEBUG, " (SKIP)");
else
av_log(am->avr, AV_LOG_DEBUG, " %0.3f ",
matrix[o * am->in_channels + i]);
}
av_log(am->avr, AV_LOG_DEBUG, "\n");
}
return 0;
}
| true | FFmpeg | fc6a3ef40d34ce8443ae57c2452f3f273d7d4891 | int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride)
{
int i, o, i0, o0, ret;
char in_layout_name[128];
char out_layout_name[128];
if ( am->in_channels <= 0 || am->in_channels > AVRESAMPLE_MAX_CHANNELS ||
am->out_channels <= 0 || am->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(am->avr, AV_LOG_ERROR, "Invalid channel counts\n");
return AVERROR(EINVAL);
}
if (am->matrix) {
av_free(am->matrix[0]);
am->matrix = NULL;
}
am->in_matrix_channels = am->in_channels;
am->out_matrix_channels = am->out_channels;
reduce_matrix(am, matrix, stride);
#define CONVERT_MATRIX(type, expr) \
am->matrix_## type[0] = av_mallocz(am->out_matrix_channels * \
am->in_matrix_channels * \
sizeof(*am->matrix_## type[0])); \
if (!am->matrix_## type[0]) \
return AVERROR(ENOMEM); \
for (o = 0, o0 = 0; o < am->out_channels; o++) { \
if (am->output_zero[o] || am->output_skip[o]) \
continue; \
if (o0 > 0) \
am->matrix_## type[o0] = am->matrix_## type[o0 - 1] + \
am->in_matrix_channels; \
for (i = 0, i0 = 0; i < am->in_channels; i++) { \
double v; \
if (am->input_skip[i]) \
continue; \
v = matrix[o * stride + i]; \
am->matrix_## type[o0][i0] = expr; \
i0++; \
} \
o0++; \
} \
am->matrix = (void **)am->matrix_## type;
if (am->in_matrix_channels && am->out_matrix_channels) {
switch (am->coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
break;
case AV_MIX_COEFF_TYPE_Q15:
CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
break;
case AV_MIX_COEFF_TYPE_FLT:
CONVERT_MATRIX(flt, v)
break;
default:
av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
}
ret = mix_function_init(am);
if (ret < 0)
return ret;
av_get_channel_layout_string(in_layout_name, sizeof(in_layout_name),
am->in_channels, am->in_layout);
av_get_channel_layout_string(out_layout_name, sizeof(out_layout_name),
am->out_channels, am->out_layout);
av_log(am->avr, AV_LOG_DEBUG, "audio_mix: %s to %s\n",
in_layout_name, out_layout_name);
av_log(am->avr, AV_LOG_DEBUG, "matrix size: %d x %d\n",
am->in_matrix_channels, am->out_matrix_channels);
for (o = 0; o < am->out_channels; o++) {
for (i = 0; i < am->in_channels; i++) {
if (am->output_zero[o])
av_log(am->avr, AV_LOG_DEBUG, " (ZERO)");
else if (am->input_skip[i] || am->output_skip[o])
av_log(am->avr, AV_LOG_DEBUG, " (SKIP)");
else
av_log(am->avr, AV_LOG_DEBUG, " %0.3f ",
matrix[o * am->in_channels + i]);
}
av_log(am->avr, AV_LOG_DEBUG, "\n");
}
return 0;
}
| {
"code": [
" if (am->input_skip[i]) \\"
],
"line_no": [
73
]
} | int FUNC_0(AudioMix *VAR_0, const double *VAR_1, int VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
char VAR_8[128];
char VAR_9[128];
if ( VAR_0->in_channels <= 0 || VAR_0->in_channels > AVRESAMPLE_MAX_CHANNELS ||
VAR_0->out_channels <= 0 || VAR_0->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(VAR_0->avr, AV_LOG_ERROR, "Invalid channel counts\n");
return AVERROR(EINVAL);
}
if (VAR_0->VAR_1) {
av_free(VAR_0->VAR_1[0]);
VAR_0->VAR_1 = NULL;
}
VAR_0->in_matrix_channels = VAR_0->in_channels;
VAR_0->out_matrix_channels = VAR_0->out_channels;
reduce_matrix(VAR_0, VAR_1, VAR_2);
#define CONVERT_MATRIX(type, expr) \
VAR_0->matrix_## type[0] = av_mallocz(VAR_0->out_matrix_channels * \
VAR_0->in_matrix_channels * \
sizeof(*VAR_0->matrix_## type[0])); \
if (!VAR_0->matrix_## type[0]) \
return AVERROR(ENOMEM); \
for (VAR_4 = 0, VAR_6 = 0; VAR_4 < VAR_0->out_channels; VAR_4++) { \
if (VAR_0->output_zero[VAR_4] || VAR_0->output_skip[VAR_4]) \
continue; \
if (VAR_6 > 0) \
VAR_0->matrix_## type[VAR_6] = VAR_0->matrix_## type[VAR_6 - 1] + \
VAR_0->in_matrix_channels; \
for (VAR_3 = 0, VAR_5 = 0; VAR_3 < VAR_0->in_channels; VAR_3++) { \
double v; \
if (VAR_0->input_skip[VAR_3]) \
continue; \
v = VAR_1[VAR_4 * VAR_2 + VAR_3]; \
VAR_0->matrix_## type[VAR_6][VAR_5] = expr; \
VAR_5++; \
} \
VAR_6++; \
} \
VAR_0->VAR_1 = (void **)VAR_0->matrix_## type;
if (VAR_0->in_matrix_channels && VAR_0->out_matrix_channels) {
switch (VAR_0->coeff_type) {
case AV_MIX_COEFF_TYPE_Q8:
CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
break;
case AV_MIX_COEFF_TYPE_Q15:
CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
break;
case AV_MIX_COEFF_TYPE_FLT:
CONVERT_MATRIX(flt, v)
break;
default:
av_log(VAR_0->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
return AVERROR(EINVAL);
}
}
VAR_7 = mix_function_init(VAR_0);
if (VAR_7 < 0)
return VAR_7;
av_get_channel_layout_string(VAR_8, sizeof(VAR_8),
VAR_0->in_channels, VAR_0->in_layout);
av_get_channel_layout_string(VAR_9, sizeof(VAR_9),
VAR_0->out_channels, VAR_0->out_layout);
av_log(VAR_0->avr, AV_LOG_DEBUG, "audio_mix: %s to %s\n",
VAR_8, VAR_9);
av_log(VAR_0->avr, AV_LOG_DEBUG, "VAR_1 size: %d x %d\n",
VAR_0->in_matrix_channels, VAR_0->out_matrix_channels);
for (VAR_4 = 0; VAR_4 < VAR_0->out_channels; VAR_4++) {
for (VAR_3 = 0; VAR_3 < VAR_0->in_channels; VAR_3++) {
if (VAR_0->output_zero[VAR_4])
av_log(VAR_0->avr, AV_LOG_DEBUG, " (ZERO)");
else if (VAR_0->input_skip[VAR_3] || VAR_0->output_skip[VAR_4])
av_log(VAR_0->avr, AV_LOG_DEBUG, " (SKIP)");
else
av_log(VAR_0->avr, AV_LOG_DEBUG, " %0.3f ",
VAR_1[VAR_4 * VAR_0->in_channels + VAR_3]);
}
av_log(VAR_0->avr, AV_LOG_DEBUG, "\n");
}
return 0;
}
| [
"int FUNC_0(AudioMix *VAR_0, const double *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"char VAR_8[128];",
"char VAR_9[128];",
"if ( VAR_0->in_channels <= 0 || VAR_0->in_channels > AVRESAMPLE_MAX_CHANNELS ||\nVAR_0->out_channels <= 0 || VAR_0->out_channels > AVRESAMPLE_MAX_CHANNELS) {",
"av_log(VAR_0->avr, AV_LOG_ERROR, \"Invalid channel counts\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (VAR_0->VAR_1) {",
"av_free(VAR_0->VAR_1[0]);",
"VAR_0->VAR_1 = NULL;",
"}",
"VAR_0->in_matrix_channels = VAR_0->in_channels;",
"VAR_0->out_matrix_channels = VAR_0->out_channels;",
"reduce_matrix(VAR_0, VAR_1, VAR_2);",
"#define CONVERT_MATRIX(type, expr) \\\nVAR_0->matrix_## type[0] = av_mallocz(VAR_0->out_matrix_channels * \\\nVAR_0->in_matrix_channels * \\\nsizeof(*VAR_0->matrix_## type[0])); \\",
"if (!VAR_0->matrix_## type[0]) \\\nreturn AVERROR(ENOMEM); \\",
"for (VAR_4 = 0, VAR_6 = 0; VAR_4 < VAR_0->out_channels; VAR_4++) { \\",
"if (VAR_0->output_zero[VAR_4] || VAR_0->output_skip[VAR_4]) \\\ncontinue; \\",
"if (VAR_6 > 0) \\\nVAR_0->matrix_## type[VAR_6] = VAR_0->matrix_## type[VAR_6 - 1] + \\\nVAR_0->in_matrix_channels; \\",
"for (VAR_3 = 0, VAR_5 = 0; VAR_3 < VAR_0->in_channels; VAR_3++) { \\",
"double v; \\",
"if (VAR_0->input_skip[VAR_3]) \\\ncontinue; \\",
"v = VAR_1[VAR_4 * VAR_2 + VAR_3]; \\",
"VAR_0->matrix_## type[VAR_6][VAR_5] = expr; \\",
"VAR_5++; \\",
"} \\",
"VAR_6++; \\",
"} \\",
"VAR_0->VAR_1 = (void **)VAR_0->matrix_## type;",
"if (VAR_0->in_matrix_channels && VAR_0->out_matrix_channels) {",
"switch (VAR_0->coeff_type) {",
"case AV_MIX_COEFF_TYPE_Q8:\nCONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))\nbreak;",
"case AV_MIX_COEFF_TYPE_Q15:\nCONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))\nbreak;",
"case AV_MIX_COEFF_TYPE_FLT:\nCONVERT_MATRIX(flt, v)\nbreak;",
"default:\nav_log(VAR_0->avr, AV_LOG_ERROR, \"Invalid mix coeff type\\n\");",
"return AVERROR(EINVAL);",
"}",
"}",
"VAR_7 = mix_function_init(VAR_0);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"av_get_channel_layout_string(VAR_8, sizeof(VAR_8),\nVAR_0->in_channels, VAR_0->in_layout);",
"av_get_channel_layout_string(VAR_9, sizeof(VAR_9),\nVAR_0->out_channels, VAR_0->out_layout);",
"av_log(VAR_0->avr, AV_LOG_DEBUG, \"audio_mix: %s to %s\\n\",\nVAR_8, VAR_9);",
"av_log(VAR_0->avr, AV_LOG_DEBUG, \"VAR_1 size: %d x %d\\n\",\nVAR_0->in_matrix_channels, VAR_0->out_matrix_channels);",
"for (VAR_4 = 0; VAR_4 < VAR_0->out_channels; VAR_4++) {",
"for (VAR_3 = 0; VAR_3 < VAR_0->in_channels; VAR_3++) {",
"if (VAR_0->output_zero[VAR_4])\nav_log(VAR_0->avr, AV_LOG_DEBUG, \" (ZERO)\");",
"else if (VAR_0->input_skip[VAR_3] || VAR_0->output_skip[VAR_4])\nav_log(VAR_0->avr, AV_LOG_DEBUG, \" (SKIP)\");",
"else\nav_log(VAR_0->avr, AV_LOG_DEBUG, \" %0.3f \",\nVAR_1[VAR_4 * VAR_0->in_channels + VAR_3]);",
"}",
"av_log(VAR_0->avr, AV_LOG_DEBUG, \"\\n\");",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
45,
47,
49,
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63,
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97,
99,
101
],
[
103,
105,
107
],
[
109,
111,
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
135,
137
],
[
139,
141
],
[
143,
145
],
[
147,
149
],
[
151
],
[
153
],
[
155,
157
],
[
159,
161
],
[
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
]
] |
2,531 | BlockBackend *blk_new_open(const char *filename, const char *reference,
QDict *options, int flags, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
uint64_t perm;
/* blk_new_open() is mainly used in .bdrv_create implementations and the
* tools where sharing isn't a concern because the BDS stays private, so we
* just request permission according to the flags.
*
* The exceptions are xen_disk and blockdev_init(); in these cases, the
* caller of blk_new_open() doesn't make use of the permissions, but they
* shouldn't hurt either. We can still share everything here because the
* guest devices will add their own blockers if they can't share. */
perm = BLK_PERM_CONSISTENT_READ;
if (flags & BDRV_O_RDWR) {
perm |= BLK_PERM_WRITE;
}
if (flags & BDRV_O_RESIZE) {
perm |= BLK_PERM_RESIZE;
}
blk = blk_new(perm, BLK_PERM_ALL);
bs = bdrv_open(filename, reference, options, flags, errp);
if (!bs) {
blk_unref(blk);
return NULL;
}
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
perm, BLK_PERM_ALL, blk, &error_abort);
return blk;
}
| true | qemu | 50bfbe93b2ca0ab795f3de305bec5ab1df620be4 | BlockBackend *blk_new_open(const char *filename, const char *reference,
QDict *options, int flags, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
uint64_t perm;
perm = BLK_PERM_CONSISTENT_READ;
if (flags & BDRV_O_RDWR) {
perm |= BLK_PERM_WRITE;
}
if (flags & BDRV_O_RESIZE) {
perm |= BLK_PERM_RESIZE;
}
blk = blk_new(perm, BLK_PERM_ALL);
bs = bdrv_open(filename, reference, options, flags, errp);
if (!bs) {
blk_unref(blk);
return NULL;
}
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
perm, BLK_PERM_ALL, blk, &error_abort);
return blk;
}
| {
"code": [
" perm, BLK_PERM_ALL, blk, &error_abort);"
],
"line_no": [
63
]
} | BlockBackend *FUNC_0(const char *filename, const char *reference,
QDict *options, int flags, Error **errp)
{
BlockBackend *blk;
BlockDriverState *bs;
uint64_t perm;
perm = BLK_PERM_CONSISTENT_READ;
if (flags & BDRV_O_RDWR) {
perm |= BLK_PERM_WRITE;
}
if (flags & BDRV_O_RESIZE) {
perm |= BLK_PERM_RESIZE;
}
blk = blk_new(perm, BLK_PERM_ALL);
bs = bdrv_open(filename, reference, options, flags, errp);
if (!bs) {
blk_unref(blk);
return NULL;
}
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
perm, BLK_PERM_ALL, blk, &error_abort);
return blk;
}
| [
"BlockBackend *FUNC_0(const char *filename, const char *reference,\nQDict *options, int flags, Error **errp)\n{",
"BlockBackend *blk;",
"BlockDriverState *bs;",
"uint64_t perm;",
"perm = BLK_PERM_CONSISTENT_READ;",
"if (flags & BDRV_O_RDWR) {",
"perm |= BLK_PERM_WRITE;",
"}",
"if (flags & BDRV_O_RESIZE) {",
"perm |= BLK_PERM_RESIZE;",
"}",
"blk = blk_new(perm, BLK_PERM_ALL);",
"bs = bdrv_open(filename, reference, options, flags, errp);",
"if (!bs) {",
"blk_unref(blk);",
"return NULL;",
"}",
"blk->root = bdrv_root_attach_child(bs, \"root\", &child_root,\nperm, BLK_PERM_ALL, blk, &error_abort);",
"return blk;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
67
],
[
69
]
] |
2,532 | static int pci_dec_21154_init_device(SysBusDevice *dev)
{
UNINState *s;
int pci_mem_config, pci_mem_data;
/* Uninorth bridge */
s = FROM_SYSBUS(UNINState, dev);
// XXX: s = &pci_bridge[2];
pci_mem_config = cpu_register_io_memory(pci_unin_config_read,
pci_unin_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_unin_main_read,
pci_unin_main_write, &s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
return 0;
}
| false | qemu | 4f5e19e6c570459cd524b29b24374f03860f5149 | static int pci_dec_21154_init_device(SysBusDevice *dev)
{
UNINState *s;
int pci_mem_config, pci_mem_data;
s = FROM_SYSBUS(UNINState, dev);
pci_mem_config = cpu_register_io_memory(pci_unin_config_read,
pci_unin_config_write, s);
pci_mem_data = cpu_register_io_memory(pci_unin_main_read,
pci_unin_main_write, &s->host_state);
sysbus_init_mmio(dev, 0x1000, pci_mem_config);
sysbus_init_mmio(dev, 0x1000, pci_mem_data);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SysBusDevice *VAR_0)
{
UNINState *s;
int VAR_1, VAR_2;
s = FROM_SYSBUS(UNINState, VAR_0);
VAR_1 = cpu_register_io_memory(pci_unin_config_read,
pci_unin_config_write, s);
VAR_2 = cpu_register_io_memory(pci_unin_main_read,
pci_unin_main_write, &s->host_state);
sysbus_init_mmio(VAR_0, 0x1000, VAR_1);
sysbus_init_mmio(VAR_0, 0x1000, VAR_2);
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"UNINState *s;",
"int VAR_1, VAR_2;",
"s = FROM_SYSBUS(UNINState, VAR_0);",
"VAR_1 = cpu_register_io_memory(pci_unin_config_read,\npci_unin_config_write, s);",
"VAR_2 = cpu_register_io_memory(pci_unin_main_read,\npci_unin_main_write, &s->host_state);",
"sysbus_init_mmio(VAR_0, 0x1000, VAR_1);",
"sysbus_init_mmio(VAR_0, 0x1000, VAR_2);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
2,533 | static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state)
{
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
sPAPRDRConnectorClass *drck;
if (!drc) {
return RTAS_OUT_PARAM_ERROR;
}
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
return drck->set_isolation_state(drc, state);
}
| false | qemu | 0dfabd39d523fc3f6f0f8c441f41c013cc429b52 | static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state)
{
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
sPAPRDRConnectorClass *drck;
if (!drc) {
return RTAS_OUT_PARAM_ERROR;
}
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
return drck->set_isolation_state(drc, state);
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(uint32_t idx, uint32_t state)
{
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
sPAPRDRConnectorClass *drck;
if (!drc) {
return RTAS_OUT_PARAM_ERROR;
}
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
return drck->set_isolation_state(drc, state);
}
| [
"static uint32_t FUNC_0(uint32_t idx, uint32_t state)\n{",
"sPAPRDRConnector *drc = spapr_drc_by_index(idx);",
"sPAPRDRConnectorClass *drck;",
"if (!drc) {",
"return RTAS_OUT_PARAM_ERROR;",
"}",
"drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"return drck->set_isolation_state(drc, state);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
2,536 | static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
{
NFSClient *client = bs->opaque;
NFSRPC task = {0};
struct stat st;
if (bdrv_is_read_only(bs) &&
!(bs->open_flags & BDRV_O_NOCACHE)) {
return client->st_blocks * 512;
}
task.st = &st;
if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb,
&task) != 0) {
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
aio_poll(client->aio_context, true);
}
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
}
| false | qemu | aa92d6c4609e174fc6884e4b7b87367fac33cbe9 | static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
{
NFSClient *client = bs->opaque;
NFSRPC task = {0};
struct stat st;
if (bdrv_is_read_only(bs) &&
!(bs->open_flags & BDRV_O_NOCACHE)) {
return client->st_blocks * 512;
}
task.st = &st;
if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb,
&task) != 0) {
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
aio_poll(client->aio_context, true);
}
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(BlockDriverState *bs)
{
NFSClient *client = bs->opaque;
NFSRPC task = {0};
struct stat VAR_0;
if (bdrv_is_read_only(bs) &&
!(bs->open_flags & BDRV_O_NOCACHE)) {
return client->st_blocks * 512;
}
task.VAR_0 = &VAR_0;
if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb,
&task) != 0) {
return -ENOMEM;
}
while (!task.complete) {
nfs_set_events(client);
aio_poll(client->aio_context, true);
}
return (task.ret < 0 ? task.ret : VAR_0.st_blocks * 512);
}
| [
"static int64_t FUNC_0(BlockDriverState *bs)\n{",
"NFSClient *client = bs->opaque;",
"NFSRPC task = {0};",
"struct stat VAR_0;",
"if (bdrv_is_read_only(bs) &&\n!(bs->open_flags & BDRV_O_NOCACHE)) {",
"return client->st_blocks * 512;",
"}",
"task.VAR_0 = &VAR_0;",
"if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb,\n&task) != 0) {",
"return -ENOMEM;",
"}",
"while (!task.complete) {",
"nfs_set_events(client);",
"aio_poll(client->aio_context, true);",
"}",
"return (task.ret < 0 ? task.ret : VAR_0.st_blocks * 512);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
2,537 | static CadenceTimerState *cadence_timer_from_addr(void *opaque,
target_phys_addr_t offset)
{
unsigned int index;
CadenceTTCState *s = (CadenceTTCState *)opaque;
index = (offset >> 2) % 3;
return &s->timer[index];
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static CadenceTimerState *cadence_timer_from_addr(void *opaque,
target_phys_addr_t offset)
{
unsigned int index;
CadenceTTCState *s = (CadenceTTCState *)opaque;
index = (offset >> 2) % 3;
return &s->timer[index];
}
| {
"code": [],
"line_no": []
} | static CadenceTimerState *FUNC_0(void *opaque,
target_phys_addr_t offset)
{
unsigned int VAR_0;
CadenceTTCState *s = (CadenceTTCState *)opaque;
VAR_0 = (offset >> 2) % 3;
return &s->timer[VAR_0];
}
| [
"static CadenceTimerState *FUNC_0(void *opaque,\ntarget_phys_addr_t offset)\n{",
"unsigned int VAR_0;",
"CadenceTTCState *s = (CadenceTTCState *)opaque;",
"VAR_0 = (offset >> 2) % 3;",
"return &s->timer[VAR_0];",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
]
] |
2,539 | static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *page;
if (netdev->xendev.be_state != XenbusStateConnected) {
return -1;
}
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
return -1;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return -1;
}
memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));
netdev->rx_ring.req_cons = ++rc;
page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
rxreq.gref, PROT_WRITE);
if (page == NULL) {
xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return -1;
}
memcpy(page + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);
net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
return size;
}
| false | qemu | 7bba83bf80eae9c9e323319ff40d0ca477b0a77a | static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *page;
if (netdev->xendev.be_state != XenbusStateConnected) {
return -1;
}
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
return -1;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return -1;
}
memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));
netdev->rx_ring.req_cons = ++rc;
page = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev,
netdev->xendev.dom,
rxreq.gref, PROT_WRITE);
if (page == NULL) {
xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return -1;
}
memcpy(page + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);
net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
return size;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)
{
struct XenNetDev *VAR_0 = qemu_get_nic_opaque(nc);
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *VAR_1;
if (VAR_0->xendev.be_state != XenbusStateConnected) {
return -1;
}
rc = VAR_0->rx_ring.req_cons;
rp = VAR_0->rx_ring.sring->req_prod;
xen_rmb();
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&VAR_0->rx_ring, rc)) {
xen_be_printf(&VAR_0->xendev, 2, "no buffer, drop packet\n");
return -1;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&VAR_0->xendev, 0, "packet too big (%lu > %ld)",
(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return -1;
}
memcpy(&rxreq, RING_GET_REQUEST(&VAR_0->rx_ring, rc), sizeof(rxreq));
VAR_0->rx_ring.req_cons = ++rc;
VAR_1 = xc_gnttab_map_grant_ref(VAR_0->xendev.gnttabdev,
VAR_0->xendev.dom,
rxreq.gref, PROT_WRITE);
if (VAR_1 == NULL) {
xen_be_printf(&VAR_0->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(VAR_0, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
return -1;
}
memcpy(VAR_1 + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(VAR_0->xendev.gnttabdev, VAR_1, 1);
net_rx_response(VAR_0, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
return size;
}
| [
"static ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size)\n{",
"struct XenNetDev *VAR_0 = qemu_get_nic_opaque(nc);",
"netif_rx_request_t rxreq;",
"RING_IDX rc, rp;",
"void *VAR_1;",
"if (VAR_0->xendev.be_state != XenbusStateConnected) {",
"return -1;",
"}",
"rc = VAR_0->rx_ring.req_cons;",
"rp = VAR_0->rx_ring.sring->req_prod;",
"xen_rmb();",
"if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&VAR_0->rx_ring, rc)) {",
"xen_be_printf(&VAR_0->xendev, 2, \"no buffer, drop packet\\n\");",
"return -1;",
"}",
"if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {",
"xen_be_printf(&VAR_0->xendev, 0, \"packet too big (%lu > %ld)\",\n(unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);",
"return -1;",
"}",
"memcpy(&rxreq, RING_GET_REQUEST(&VAR_0->rx_ring, rc), sizeof(rxreq));",
"VAR_0->rx_ring.req_cons = ++rc;",
"VAR_1 = xc_gnttab_map_grant_ref(VAR_0->xendev.gnttabdev,\nVAR_0->xendev.dom,\nrxreq.gref, PROT_WRITE);",
"if (VAR_1 == NULL) {",
"xen_be_printf(&VAR_0->xendev, 0, \"error: rx gref dereference failed (%d)\\n\",\nrxreq.gref);",
"net_rx_response(VAR_0, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);",
"return -1;",
"}",
"memcpy(VAR_1 + NET_IP_ALIGN, buf, size);",
"xc_gnttab_munmap(VAR_0->xendev.gnttabdev, VAR_1, 1);",
"net_rx_response(VAR_0, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);",
"return size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57,
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
2,540 | static void mb_add_mod(MultibootState *s,
target_phys_addr_t start, target_phys_addr_t end,
target_phys_addr_t cmdline_phys)
{
char *p;
assert(s->mb_mods_count < s->mb_mods_avail);
p = (char *)s->mb_buf + s->offset_mbinfo + MB_MOD_SIZE * s->mb_mods_count;
stl_p(p + MB_MOD_START, start);
stl_p(p + MB_MOD_END, end);
stl_p(p + MB_MOD_CMDLINE, cmdline_phys);
mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n",
s->mb_mods_count, start, end);
s->mb_mods_count++;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void mb_add_mod(MultibootState *s,
target_phys_addr_t start, target_phys_addr_t end,
target_phys_addr_t cmdline_phys)
{
char *p;
assert(s->mb_mods_count < s->mb_mods_avail);
p = (char *)s->mb_buf + s->offset_mbinfo + MB_MOD_SIZE * s->mb_mods_count;
stl_p(p + MB_MOD_START, start);
stl_p(p + MB_MOD_END, end);
stl_p(p + MB_MOD_CMDLINE, cmdline_phys);
mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n",
s->mb_mods_count, start, end);
s->mb_mods_count++;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MultibootState *VAR_0,
target_phys_addr_t VAR_1, target_phys_addr_t VAR_2,
target_phys_addr_t VAR_3)
{
char *VAR_4;
assert(VAR_0->mb_mods_count < VAR_0->mb_mods_avail);
VAR_4 = (char *)VAR_0->mb_buf + VAR_0->offset_mbinfo + MB_MOD_SIZE * VAR_0->mb_mods_count;
stl_p(VAR_4 + MB_MOD_START, VAR_1);
stl_p(VAR_4 + MB_MOD_END, VAR_2);
stl_p(VAR_4 + MB_MOD_CMDLINE, VAR_3);
mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n",
VAR_0->mb_mods_count, VAR_1, VAR_2);
VAR_0->mb_mods_count++;
}
| [
"static void FUNC_0(MultibootState *VAR_0,\ntarget_phys_addr_t VAR_1, target_phys_addr_t VAR_2,\ntarget_phys_addr_t VAR_3)\n{",
"char *VAR_4;",
"assert(VAR_0->mb_mods_count < VAR_0->mb_mods_avail);",
"VAR_4 = (char *)VAR_0->mb_buf + VAR_0->offset_mbinfo + MB_MOD_SIZE * VAR_0->mb_mods_count;",
"stl_p(VAR_4 + MB_MOD_START, VAR_1);",
"stl_p(VAR_4 + MB_MOD_END, VAR_2);",
"stl_p(VAR_4 + MB_MOD_CMDLINE, VAR_3);",
"mb_debug(\"mod%02d: \"TARGET_FMT_plx\" - \"TARGET_FMT_plx\"\\n\",\nVAR_0->mb_mods_count, VAR_1, VAR_2);",
"VAR_0->mb_mods_count++;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33
],
[
35
]
] |
2,541 | static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
VncBasicInfo *info,
Error **errp)
{
SocketAddress *addr = NULL;
if (!ioc) {
error_setg(errp, "No listener socket available");
return;
}
addr = qio_channel_socket_get_local_address(ioc, errp);
if (!addr) {
return;
}
vnc_init_basic_info(addr, info, errp);
qapi_free_SocketAddress(addr);
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
VncBasicInfo *info,
Error **errp)
{
SocketAddress *addr = NULL;
if (!ioc) {
error_setg(errp, "No listener socket available");
return;
}
addr = qio_channel_socket_get_local_address(ioc, errp);
if (!addr) {
return;
}
vnc_init_basic_info(addr, info, errp);
qapi_free_SocketAddress(addr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QIOChannelSocket *VAR_0,
VncBasicInfo *VAR_1,
Error **VAR_2)
{
SocketAddress *addr = NULL;
if (!VAR_0) {
error_setg(VAR_2, "No listener socket available");
return;
}
addr = qio_channel_socket_get_local_address(VAR_0, VAR_2);
if (!addr) {
return;
}
vnc_init_basic_info(addr, VAR_1, VAR_2);
qapi_free_SocketAddress(addr);
}
| [
"static void FUNC_0(QIOChannelSocket *VAR_0,\nVncBasicInfo *VAR_1,\nError **VAR_2)\n{",
"SocketAddress *addr = NULL;",
"if (!VAR_0) {",
"error_setg(VAR_2, \"No listener socket available\");",
"return;",
"}",
"addr = qio_channel_socket_get_local_address(VAR_0, VAR_2);",
"if (!addr) {",
"return;",
"}",
"vnc_init_basic_info(addr, VAR_1, VAR_2);",
"qapi_free_SocketAddress(addr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
2,542 | static void nbd_teardown_connection(NbdClientSession *client)
{
/* finish any pending coroutines */
shutdown(client->sock, 2);
nbd_recv_coroutines_enter_all(client);
nbd_client_session_detach_aio_context(client);
closesocket(client->sock);
client->sock = -1;
}
| false | qemu | f53a829bb9ef14be800556cbc02d8b20fc1050a7 | static void nbd_teardown_connection(NbdClientSession *client)
{
shutdown(client->sock, 2);
nbd_recv_coroutines_enter_all(client);
nbd_client_session_detach_aio_context(client);
closesocket(client->sock);
client->sock = -1;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NbdClientSession *VAR_0)
{
shutdown(VAR_0->sock, 2);
nbd_recv_coroutines_enter_all(VAR_0);
nbd_client_session_detach_aio_context(VAR_0);
closesocket(VAR_0->sock);
VAR_0->sock = -1;
}
| [
"static void FUNC_0(NbdClientSession *VAR_0)\n{",
"shutdown(VAR_0->sock, 2);",
"nbd_recv_coroutines_enter_all(VAR_0);",
"nbd_client_session_detach_aio_context(VAR_0);",
"closesocket(VAR_0->sock);",
"VAR_0->sock = -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
2,543 | static int usb_uhci_common_initfn(UHCIState *s)
{
uint8_t *pci_conf = s->dev.config;
int i;
pci_conf[PCI_REVISION_ID] = 0x01; // revision number
pci_conf[PCI_CLASS_PROG] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
/* TODO: reset value should be 0. */
pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
pci_conf[0x60] = 0x10; // release number
usb_bus_new(&s->bus, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
usb_port_location(&s->ports[i].port, NULL, i+1);
}
s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
s->expire_time = qemu_get_clock_ns(vm_clock) +
(get_ticks_per_sec() / FRAME_TIMER_FREQ);
s->num_ports_vmstate = NB_PORTS;
qemu_register_reset(uhci_reset, s);
/* Use region 4 for consistency with real hardware. BSD guests seem
to rely on this. */
pci_register_bar(&s->dev, 4, 0x20,
PCI_BASE_ADDRESS_SPACE_IO, uhci_map);
return 0;
}
| false | qemu | dc638fadb54c911019227ae37656560c49a209b9 | static int usb_uhci_common_initfn(UHCIState *s)
{
uint8_t *pci_conf = s->dev.config;
int i;
pci_conf[PCI_REVISION_ID] = 0x01;
pci_conf[PCI_CLASS_PROG] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
pci_conf[PCI_INTERRUPT_PIN] = 4;
pci_conf[0x60] = 0x10;
usb_bus_new(&s->bus, &s->dev.qdev);
for(i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
usb_port_location(&s->ports[i].port, NULL, i+1);
}
s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
s->expire_time = qemu_get_clock_ns(vm_clock) +
(get_ticks_per_sec() / FRAME_TIMER_FREQ);
s->num_ports_vmstate = NB_PORTS;
qemu_register_reset(uhci_reset, s);
pci_register_bar(&s->dev, 4, 0x20,
PCI_BASE_ADDRESS_SPACE_IO, uhci_map);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(UHCIState *VAR_0)
{
uint8_t *pci_conf = VAR_0->dev.config;
int VAR_1;
pci_conf[PCI_REVISION_ID] = 0x01;
pci_conf[PCI_CLASS_PROG] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
pci_conf[PCI_INTERRUPT_PIN] = 4;
pci_conf[0x60] = 0x10;
usb_bus_new(&VAR_0->bus, &VAR_0->dev.qdev);
for(VAR_1 = 0; VAR_1 < NB_PORTS; VAR_1++) {
usb_register_port(&VAR_0->bus, &VAR_0->ports[VAR_1].port, VAR_0, VAR_1, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
usb_port_location(&VAR_0->ports[VAR_1].port, NULL, VAR_1+1);
}
VAR_0->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, VAR_0);
VAR_0->expire_time = qemu_get_clock_ns(vm_clock) +
(get_ticks_per_sec() / FRAME_TIMER_FREQ);
VAR_0->num_ports_vmstate = NB_PORTS;
qemu_register_reset(uhci_reset, VAR_0);
pci_register_bar(&VAR_0->dev, 4, 0x20,
PCI_BASE_ADDRESS_SPACE_IO, uhci_map);
return 0;
}
| [
"static int FUNC_0(UHCIState *VAR_0)\n{",
"uint8_t *pci_conf = VAR_0->dev.config;",
"int VAR_1;",
"pci_conf[PCI_REVISION_ID] = 0x01;",
"pci_conf[PCI_CLASS_PROG] = 0x00;",
"pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);",
"pci_conf[PCI_INTERRUPT_PIN] = 4;",
"pci_conf[0x60] = 0x10;",
"usb_bus_new(&VAR_0->bus, &VAR_0->dev.qdev);",
"for(VAR_1 = 0; VAR_1 < NB_PORTS; VAR_1++) {",
"usb_register_port(&VAR_0->bus, &VAR_0->ports[VAR_1].port, VAR_0, VAR_1, &uhci_port_ops,\nUSB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);",
"usb_port_location(&VAR_0->ports[VAR_1].port, NULL, VAR_1+1);",
"}",
"VAR_0->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, VAR_0);",
"VAR_0->expire_time = qemu_get_clock_ns(vm_clock) +\n(get_ticks_per_sec() / FRAME_TIMER_FREQ);",
"VAR_0->num_ports_vmstate = NB_PORTS;",
"qemu_register_reset(uhci_reset, VAR_0);",
"pci_register_bar(&VAR_0->dev, 4, 0x20,\nPCI_BASE_ADDRESS_SPACE_IO, uhci_map);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
55,
57
],
[
61
],
[
63
]
] |
2,544 | Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
{
Visitor *v;
QDict *pdict;
Object *obj;
const char *id = qemu_opts_id(opts);
const char *type = qemu_opt_get(opts, "qom-type");
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
return NULL;
}
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
return NULL;
}
pdict = qemu_opts_to_qdict(opts, NULL);
qdict_del(pdict, "qom-type");
qdict_del(pdict, "id");
v = opts_visitor_new(opts);
obj = user_creatable_add_type(type, id, pdict, v, errp);
visit_free(v);
QDECREF(pdict);
return obj;
}
| false | qemu | 9a6d1acb3e752e1e0b693cc0491fa12875b76be0 | Object *user_creatable_add_opts(QemuOpts *opts, Error **errp)
{
Visitor *v;
QDict *pdict;
Object *obj;
const char *id = qemu_opts_id(opts);
const char *type = qemu_opt_get(opts, "qom-type");
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
return NULL;
}
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
return NULL;
}
pdict = qemu_opts_to_qdict(opts, NULL);
qdict_del(pdict, "qom-type");
qdict_del(pdict, "id");
v = opts_visitor_new(opts);
obj = user_creatable_add_type(type, id, pdict, v, errp);
visit_free(v);
QDECREF(pdict);
return obj;
}
| {
"code": [],
"line_no": []
} | Object *FUNC_0(QemuOpts *opts, Error **errp)
{
Visitor *v;
QDict *pdict;
Object *obj;
const char *VAR_0 = qemu_opts_id(opts);
const char *VAR_1 = qemu_opt_get(opts, "qom-VAR_1");
if (!VAR_1) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-VAR_1");
return NULL;
}
if (!VAR_0) {
error_setg(errp, QERR_MISSING_PARAMETER, "VAR_0");
return NULL;
}
pdict = qemu_opts_to_qdict(opts, NULL);
qdict_del(pdict, "qom-VAR_1");
qdict_del(pdict, "VAR_0");
v = opts_visitor_new(opts);
obj = user_creatable_add_type(VAR_1, VAR_0, pdict, v, errp);
visit_free(v);
QDECREF(pdict);
return obj;
}
| [
"Object *FUNC_0(QemuOpts *opts, Error **errp)\n{",
"Visitor *v;",
"QDict *pdict;",
"Object *obj;",
"const char *VAR_0 = qemu_opts_id(opts);",
"const char *VAR_1 = qemu_opt_get(opts, \"qom-VAR_1\");",
"if (!VAR_1) {",
"error_setg(errp, QERR_MISSING_PARAMETER, \"qom-VAR_1\");",
"return NULL;",
"}",
"if (!VAR_0) {",
"error_setg(errp, QERR_MISSING_PARAMETER, \"VAR_0\");",
"return NULL;",
"}",
"pdict = qemu_opts_to_qdict(opts, NULL);",
"qdict_del(pdict, \"qom-VAR_1\");",
"qdict_del(pdict, \"VAR_0\");",
"v = opts_visitor_new(opts);",
"obj = user_creatable_add_type(VAR_1, VAR_0, pdict, v, errp);",
"visit_free(v);",
"QDECREF(pdict);",
"return obj;",
"}"
] | [
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
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
] |
2,545 | int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i = 0;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
return 0;
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i = 0;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE(h) && !h->first_field && h->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE(h)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(H264Context *VAR_0, int VAR_1)
{
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp;
int VAR_2 = 0, VAR_3 = 0;
assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);
if (VAR_0->short_ref_count &&
VAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&
!(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num;
VAR_2 = 1;
if (FIELD_PICTURE(VAR_0)) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
VAR_2 = 2;
}
}
if (VAR_1) {
VAR_0->VAR_2 = VAR_2;
} else if (!VAR_1 && VAR_2 >= 0 &&
(VAR_2 != VAR_0->VAR_2 ||
(VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
VAR_2, VAR_0->VAR_2, VAR_3);
return AVERROR_INVALIDDATA;
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0, int VAR_1)\n{",
"MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = VAR_1 ? VAR_0->mmco : mmco_temp;",
"int VAR_2 = 0, VAR_3 = 0;",
"assert(VAR_0->long_ref_count + VAR_0->short_ref_count <= VAR_0->sps.ref_frame_count);",
"if (VAR_0->short_ref_count &&\nVAR_0->long_ref_count + VAR_0->short_ref_count == VAR_0->sps.ref_frame_count &&\n!(FIELD_PICTURE(VAR_0) && !VAR_0->first_field && VAR_0->cur_pic_ptr->reference)) {",
"mmco[0].opcode = MMCO_SHORT2UNUSED;",
"mmco[0].short_pic_num = VAR_0->short_ref[VAR_0->short_ref_count - 1]->frame_num;",
"VAR_2 = 1;",
"if (FIELD_PICTURE(VAR_0)) {",
"mmco[0].short_pic_num *= 2;",
"mmco[1].opcode = MMCO_SHORT2UNUSED;",
"mmco[1].short_pic_num = mmco[0].short_pic_num + 1;",
"VAR_2 = 2;",
"}",
"}",
"if (VAR_1) {",
"VAR_0->VAR_2 = VAR_2;",
"} else if (!VAR_1 && VAR_2 >= 0 &&",
"(VAR_2 != VAR_0->VAR_2 ||\n(VAR_3 = check_opcodes(VAR_0->mmco, mmco_temp, VAR_2)))) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Inconsistent MMCO state between slices [%d, %d, %d]\\n\",\nVAR_2, VAR_0->VAR_2, VAR_3);",
"return AVERROR_INVALIDDATA;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
2,546 | static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int ret;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
*host_offset, *nb_clusters);
ret = handle_dependencies(bs, guest_offset, nb_clusters);
if (ret < 0) {
return ret;
}
/* Allocate new clusters */
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*host_offset == 0) {
int64_t cluster_offset =
qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
if (cluster_offset < 0) {
return cluster_offset;
}
*host_offset = cluster_offset;
return 0;
} else {
ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters);
if (ret < 0) {
return ret;
}
*nb_clusters = ret;
return 0;
}
}
| false | qemu | 17a71e58238138c3f02be7e9f5dc8de5d72a9a9d | static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int ret;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
*host_offset, *nb_clusters);
ret = handle_dependencies(bs, guest_offset, nb_clusters);
if (ret < 0) {
return ret;
}
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*host_offset == 0) {
int64_t cluster_offset =
qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
if (cluster_offset < 0) {
return cluster_offset;
}
*host_offset = cluster_offset;
return 0;
} else {
ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters);
if (ret < 0) {
return ret;
}
*nb_clusters = ret;
return 0;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t *VAR_2, unsigned int *VAR_3)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_4;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), VAR_1,
*VAR_2, *VAR_3);
VAR_4 = handle_dependencies(VAR_0, VAR_1, VAR_3);
if (VAR_4 < 0) {
return VAR_4;
}
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*VAR_2 == 0) {
int64_t cluster_offset =
qcow2_alloc_clusters(VAR_0, *VAR_3 * s->cluster_size);
if (cluster_offset < 0) {
return cluster_offset;
}
*VAR_2 = cluster_offset;
return 0;
} else {
VAR_4 = qcow2_alloc_clusters_at(VAR_0, *VAR_2, *VAR_3);
if (VAR_4 < 0) {
return VAR_4;
}
*VAR_3 = VAR_4;
return 0;
}
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t *VAR_2, unsigned int *VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_4;",
"trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), VAR_1,\n*VAR_2, *VAR_3);",
"VAR_4 = handle_dependencies(VAR_0, VAR_1, VAR_3);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());",
"if (*VAR_2 == 0) {",
"int64_t cluster_offset =\nqcow2_alloc_clusters(VAR_0, *VAR_3 * s->cluster_size);",
"if (cluster_offset < 0) {",
"return cluster_offset;",
"}",
"*VAR_2 = cluster_offset;",
"return 0;",
"} else {",
"VAR_4 = qcow2_alloc_clusters_at(VAR_0, *VAR_2, *VAR_3);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"*VAR_3 = VAR_4;",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
2,547 | static int pit_initfn(ISADevice *dev)
{
PITState *pit = DO_UPCAST(PITState, dev, dev);
PITChannelState *s;
s = &pit->channels[0];
/* the timer 0 is connected to an IRQ */
s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
s->irq = isa_reserve_irq(pit->irq);
register_ioport_write(pit->iobase, 4, 1, pit_ioport_write, pit);
register_ioport_read(pit->iobase, 3, 1, pit_ioport_read, pit);
isa_init_ioport(dev, pit->iobase);
return 0;
}
| false | qemu | ee951a37d8873bff7aa58e23222dfd984111b6cb | static int pit_initfn(ISADevice *dev)
{
PITState *pit = DO_UPCAST(PITState, dev, dev);
PITChannelState *s;
s = &pit->channels[0];
s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
s->irq = isa_reserve_irq(pit->irq);
register_ioport_write(pit->iobase, 4, 1, pit_ioport_write, pit);
register_ioport_read(pit->iobase, 3, 1, pit_ioport_read, pit);
isa_init_ioport(dev, pit->iobase);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ISADevice *VAR_0)
{
PITState *pit = DO_UPCAST(PITState, VAR_0, VAR_0);
PITChannelState *s;
s = &pit->channels[0];
s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
s->irq = isa_reserve_irq(pit->irq);
register_ioport_write(pit->iobase, 4, 1, pit_ioport_write, pit);
register_ioport_read(pit->iobase, 3, 1, pit_ioport_read, pit);
isa_init_ioport(VAR_0, pit->iobase);
return 0;
}
| [
"static int FUNC_0(ISADevice *VAR_0)\n{",
"PITState *pit = DO_UPCAST(PITState, VAR_0, VAR_0);",
"PITChannelState *s;",
"s = &pit->channels[0];",
"s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);",
"s->irq = isa_reserve_irq(pit->irq);",
"register_ioport_write(pit->iobase, 4, 1, pit_ioport_write, pit);",
"register_ioport_read(pit->iobase, 3, 1, pit_ioport_read, pit);",
"isa_init_ioport(VAR_0, pit->iobase);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
2,549 | int64_t bdrv_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.base = base,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
/* Fast-path if already in coroutine context */
bdrv_get_block_status_above_co_entry(&data);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
aio_poll(aio_context, true);
}
}
return data.ret;
}
| false | qemu | 67a0fd2a9bca204d2b39f910a97c7137636a0715 | int64_t bdrv_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.base = base,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
bdrv_get_block_status_above_co_entry(&data);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
aio_poll(aio_context, true);
}
}
return data.ret;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(BlockDriverState *bs,
BlockDriverState *base,
int64_t sector_num,
int nb_sectors, int *pnum)
{
Coroutine *co;
BdrvCoGetBlockStatusData data = {
.bs = bs,
.base = base,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.pnum = pnum,
.done = false,
};
if (qemu_in_coroutine()) {
bdrv_get_block_status_above_co_entry(&data);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);
qemu_coroutine_enter(co, &data);
while (!data.done) {
aio_poll(aio_context, true);
}
}
return data.ret;
}
| [
"int64_t FUNC_0(BlockDriverState *bs,\nBlockDriverState *base,\nint64_t sector_num,\nint nb_sectors, int *pnum)\n{",
"Coroutine *co;",
"BdrvCoGetBlockStatusData data = {",
".bs = bs,\n.base = base,\n.sector_num = sector_num,\n.nb_sectors = nb_sectors,\n.pnum = pnum,\n.done = false,\n};",
"if (qemu_in_coroutine()) {",
"bdrv_get_block_status_above_co_entry(&data);",
"} else {",
"AioContext *aio_context = bdrv_get_aio_context(bs);",
"co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry);",
"qemu_coroutine_enter(co, &data);",
"while (!data.done) {",
"aio_poll(aio_context, true);",
"}",
"}",
"return data.ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15,
17,
19,
21,
23,
25,
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
2,550 | static int usb_linux_update_endp_table(USBHostDevice *s)
{
uint8_t *descriptors;
uint8_t devep, type, alt_interface;
int interface, length, i, ep, pid;
struct endp_data *epd;
for (i = 0; i < MAX_ENDPOINTS; i++) {
s->ep_in[i].type = INVALID_EP_TYPE;
s->ep_out[i].type = INVALID_EP_TYPE;
}
if (s->configuration == 0) {
/* not configured yet -- leave all endpoints disabled */
return 0;
}
/* get the desired configuration, interface, and endpoint descriptors
* from device description */
descriptors = &s->descr[18];
length = s->descr_len - 18;
i = 0;
if (descriptors[i + 1] != USB_DT_CONFIG ||
descriptors[i + 5] != s->configuration) {
fprintf(stderr, "invalid descriptor data - configuration %d\n",
s->configuration);
return 1;
}
i += descriptors[i];
while (i < length) {
if (descriptors[i + 1] != USB_DT_INTERFACE ||
(descriptors[i + 1] == USB_DT_INTERFACE &&
descriptors[i + 4] == 0)) {
i += descriptors[i];
continue;
}
interface = descriptors[i + 2];
alt_interface = usb_linux_get_alt_setting(s, s->configuration,
interface);
/* the current interface descriptor is the active interface
* and has endpoints */
if (descriptors[i + 3] != alt_interface) {
i += descriptors[i];
continue;
}
/* advance to the endpoints */
while (i < length && descriptors[i +1] != USB_DT_ENDPOINT) {
i += descriptors[i];
}
if (i >= length)
break;
while (i < length) {
if (descriptors[i + 1] != USB_DT_ENDPOINT) {
break;
}
devep = descriptors[i + 2];
pid = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
ep = devep & 0xf;
if (ep == 0) {
fprintf(stderr, "usb-linux: invalid ep descriptor, ep == 0\n");
return 1;
}
switch (descriptors[i + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
break;
case 0x01:
type = USBDEVFS_URB_TYPE_ISO;
set_max_packet_size(s, pid, ep, descriptors + i);
break;
case 0x02:
type = USBDEVFS_URB_TYPE_BULK;
break;
case 0x03:
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
default:
DPRINTF("usb_host: malformed endpoint type\n");
type = USBDEVFS_URB_TYPE_BULK;
}
epd = get_endp(s, pid, ep);
assert(epd->type == INVALID_EP_TYPE);
epd->type = type;
epd->halted = 0;
i += descriptors[i];
}
}
return 0;
}
| false | qemu | 7279a85f37a9cf20b15c86159f0a1f01ce9cead4 | static int usb_linux_update_endp_table(USBHostDevice *s)
{
uint8_t *descriptors;
uint8_t devep, type, alt_interface;
int interface, length, i, ep, pid;
struct endp_data *epd;
for (i = 0; i < MAX_ENDPOINTS; i++) {
s->ep_in[i].type = INVALID_EP_TYPE;
s->ep_out[i].type = INVALID_EP_TYPE;
}
if (s->configuration == 0) {
return 0;
}
descriptors = &s->descr[18];
length = s->descr_len - 18;
i = 0;
if (descriptors[i + 1] != USB_DT_CONFIG ||
descriptors[i + 5] != s->configuration) {
fprintf(stderr, "invalid descriptor data - configuration %d\n",
s->configuration);
return 1;
}
i += descriptors[i];
while (i < length) {
if (descriptors[i + 1] != USB_DT_INTERFACE ||
(descriptors[i + 1] == USB_DT_INTERFACE &&
descriptors[i + 4] == 0)) {
i += descriptors[i];
continue;
}
interface = descriptors[i + 2];
alt_interface = usb_linux_get_alt_setting(s, s->configuration,
interface);
if (descriptors[i + 3] != alt_interface) {
i += descriptors[i];
continue;
}
while (i < length && descriptors[i +1] != USB_DT_ENDPOINT) {
i += descriptors[i];
}
if (i >= length)
break;
while (i < length) {
if (descriptors[i + 1] != USB_DT_ENDPOINT) {
break;
}
devep = descriptors[i + 2];
pid = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
ep = devep & 0xf;
if (ep == 0) {
fprintf(stderr, "usb-linux: invalid ep descriptor, ep == 0\n");
return 1;
}
switch (descriptors[i + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
break;
case 0x01:
type = USBDEVFS_URB_TYPE_ISO;
set_max_packet_size(s, pid, ep, descriptors + i);
break;
case 0x02:
type = USBDEVFS_URB_TYPE_BULK;
break;
case 0x03:
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
default:
DPRINTF("usb_host: malformed endpoint type\n");
type = USBDEVFS_URB_TYPE_BULK;
}
epd = get_endp(s, pid, ep);
assert(epd->type == INVALID_EP_TYPE);
epd->type = type;
epd->halted = 0;
i += descriptors[i];
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBHostDevice *VAR_0)
{
uint8_t *descriptors;
uint8_t devep, type, alt_interface;
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;
struct endp_data *VAR_6;
for (VAR_3 = 0; VAR_3 < MAX_ENDPOINTS; VAR_3++) {
VAR_0->ep_in[VAR_3].type = INVALID_EP_TYPE;
VAR_0->ep_out[VAR_3].type = INVALID_EP_TYPE;
}
if (VAR_0->configuration == 0) {
return 0;
}
descriptors = &VAR_0->descr[18];
VAR_2 = VAR_0->descr_len - 18;
VAR_3 = 0;
if (descriptors[VAR_3 + 1] != USB_DT_CONFIG ||
descriptors[VAR_3 + 5] != VAR_0->configuration) {
fprintf(stderr, "invalid descriptor data - configuration %d\n",
VAR_0->configuration);
return 1;
}
VAR_3 += descriptors[VAR_3];
while (VAR_3 < VAR_2) {
if (descriptors[VAR_3 + 1] != USB_DT_INTERFACE ||
(descriptors[VAR_3 + 1] == USB_DT_INTERFACE &&
descriptors[VAR_3 + 4] == 0)) {
VAR_3 += descriptors[VAR_3];
continue;
}
VAR_1 = descriptors[VAR_3 + 2];
alt_interface = usb_linux_get_alt_setting(VAR_0, VAR_0->configuration,
VAR_1);
if (descriptors[VAR_3 + 3] != alt_interface) {
VAR_3 += descriptors[VAR_3];
continue;
}
while (VAR_3 < VAR_2 && descriptors[VAR_3 +1] != USB_DT_ENDPOINT) {
VAR_3 += descriptors[VAR_3];
}
if (VAR_3 >= VAR_2)
break;
while (VAR_3 < VAR_2) {
if (descriptors[VAR_3 + 1] != USB_DT_ENDPOINT) {
break;
}
devep = descriptors[VAR_3 + 2];
VAR_5 = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
VAR_4 = devep & 0xf;
if (VAR_4 == 0) {
fprintf(stderr, "usb-linux: invalid VAR_4 descriptor, VAR_4 == 0\n");
return 1;
}
switch (descriptors[VAR_3 + 3] & 0x3) {
case 0x00:
type = USBDEVFS_URB_TYPE_CONTROL;
break;
case 0x01:
type = USBDEVFS_URB_TYPE_ISO;
set_max_packet_size(VAR_0, VAR_5, VAR_4, descriptors + VAR_3);
break;
case 0x02:
type = USBDEVFS_URB_TYPE_BULK;
break;
case 0x03:
type = USBDEVFS_URB_TYPE_INTERRUPT;
break;
default:
DPRINTF("usb_host: malformed endpoint type\n");
type = USBDEVFS_URB_TYPE_BULK;
}
VAR_6 = get_endp(VAR_0, VAR_5, VAR_4);
assert(VAR_6->type == INVALID_EP_TYPE);
VAR_6->type = type;
VAR_6->halted = 0;
VAR_3 += descriptors[VAR_3];
}
}
return 0;
}
| [
"static int FUNC_0(USBHostDevice *VAR_0)\n{",
"uint8_t *descriptors;",
"uint8_t devep, type, alt_interface;",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;",
"struct endp_data *VAR_6;",
"for (VAR_3 = 0; VAR_3 < MAX_ENDPOINTS; VAR_3++) {",
"VAR_0->ep_in[VAR_3].type = INVALID_EP_TYPE;",
"VAR_0->ep_out[VAR_3].type = INVALID_EP_TYPE;",
"}",
"if (VAR_0->configuration == 0) {",
"return 0;",
"}",
"descriptors = &VAR_0->descr[18];",
"VAR_2 = VAR_0->descr_len - 18;",
"VAR_3 = 0;",
"if (descriptors[VAR_3 + 1] != USB_DT_CONFIG ||\ndescriptors[VAR_3 + 5] != VAR_0->configuration) {",
"fprintf(stderr, \"invalid descriptor data - configuration %d\\n\",\nVAR_0->configuration);",
"return 1;",
"}",
"VAR_3 += descriptors[VAR_3];",
"while (VAR_3 < VAR_2) {",
"if (descriptors[VAR_3 + 1] != USB_DT_INTERFACE ||\n(descriptors[VAR_3 + 1] == USB_DT_INTERFACE &&\ndescriptors[VAR_3 + 4] == 0)) {",
"VAR_3 += descriptors[VAR_3];",
"continue;",
"}",
"VAR_1 = descriptors[VAR_3 + 2];",
"alt_interface = usb_linux_get_alt_setting(VAR_0, VAR_0->configuration,\nVAR_1);",
"if (descriptors[VAR_3 + 3] != alt_interface) {",
"VAR_3 += descriptors[VAR_3];",
"continue;",
"}",
"while (VAR_3 < VAR_2 && descriptors[VAR_3 +1] != USB_DT_ENDPOINT) {",
"VAR_3 += descriptors[VAR_3];",
"}",
"if (VAR_3 >= VAR_2)\nbreak;",
"while (VAR_3 < VAR_2) {",
"if (descriptors[VAR_3 + 1] != USB_DT_ENDPOINT) {",
"break;",
"}",
"devep = descriptors[VAR_3 + 2];",
"VAR_5 = (devep & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;",
"VAR_4 = devep & 0xf;",
"if (VAR_4 == 0) {",
"fprintf(stderr, \"usb-linux: invalid VAR_4 descriptor, VAR_4 == 0\\n\");",
"return 1;",
"}",
"switch (descriptors[VAR_3 + 3] & 0x3) {",
"case 0x00:\ntype = USBDEVFS_URB_TYPE_CONTROL;",
"break;",
"case 0x01:\ntype = USBDEVFS_URB_TYPE_ISO;",
"set_max_packet_size(VAR_0, VAR_5, VAR_4, descriptors + VAR_3);",
"break;",
"case 0x02:\ntype = USBDEVFS_URB_TYPE_BULK;",
"break;",
"case 0x03:\ntype = USBDEVFS_URB_TYPE_INTERRUPT;",
"break;",
"default:\nDPRINTF(\"usb_host: malformed endpoint type\\n\");",
"type = USBDEVFS_URB_TYPE_BULK;",
"}",
"VAR_6 = get_endp(VAR_0, VAR_5, VAR_4);",
"assert(VAR_6->type == INVALID_EP_TYPE);",
"VAR_6->type = type;",
"VAR_6->halted = 0;",
"VAR_3 += descriptors[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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81,
83
],
[
91
],
[
93
],
[
95
],
[
97
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145,
147
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
]
] |
2,551 | pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)
{
int i;
uint32_t len_log2;
uint32_t ring_size;
if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
return -1;
}
ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
len_log2 = pvscsi_log2(ring_size - 1);
m->msg_len_mask = MASK(len_log2);
m->filled_msg_ptr = 0;
for (i = 0; i < ri->numPages; i++) {
m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT;
}
RS_SET_FIELD(m, msgProdIdx, 0);
RS_SET_FIELD(m, msgConsIdx, 0);
RS_SET_FIELD(m, msgNumEntriesLog2, len_log2);
trace_pvscsi_ring_init_msg(len_log2);
/* Flush ring state page changes */
smp_wmb();
return 0;
}
| false | qemu | f68826989cd4d1217797251339579c57b3c0934e | pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)
{
int i;
uint32_t len_log2;
uint32_t ring_size;
if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
return -1;
}
ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
len_log2 = pvscsi_log2(ring_size - 1);
m->msg_len_mask = MASK(len_log2);
m->filled_msg_ptr = 0;
for (i = 0; i < ri->numPages; i++) {
m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT;
}
RS_SET_FIELD(m, msgProdIdx, 0);
RS_SET_FIELD(m, msgConsIdx, 0);
RS_SET_FIELD(m, msgNumEntriesLog2, len_log2);
trace_pvscsi_ring_init_msg(len_log2);
smp_wmb();
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupMsgRing *VAR_1)
{
int VAR_2;
uint32_t len_log2;
uint32_t ring_size;
if (VAR_1->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
return -1;
}
ring_size = VAR_1->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
len_log2 = pvscsi_log2(ring_size - 1);
VAR_0->msg_len_mask = MASK(len_log2);
VAR_0->filled_msg_ptr = 0;
for (VAR_2 = 0; VAR_2 < VAR_1->numPages; VAR_2++) {
VAR_0->msg_ring_pages_pa[VAR_2] = VAR_1->ringPPNs[VAR_2] << VMW_PAGE_SHIFT;
}
RS_SET_FIELD(VAR_0, msgProdIdx, 0);
RS_SET_FIELD(VAR_0, msgConsIdx, 0);
RS_SET_FIELD(VAR_0, msgNumEntriesLog2, len_log2);
trace_pvscsi_ring_init_msg(len_log2);
smp_wmb();
return 0;
}
| [
"FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupMsgRing *VAR_1)\n{",
"int VAR_2;",
"uint32_t len_log2;",
"uint32_t ring_size;",
"if (VAR_1->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {",
"return -1;",
"}",
"ring_size = VAR_1->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;",
"len_log2 = pvscsi_log2(ring_size - 1);",
"VAR_0->msg_len_mask = MASK(len_log2);",
"VAR_0->filled_msg_ptr = 0;",
"for (VAR_2 = 0; VAR_2 < VAR_1->numPages; VAR_2++) {",
"VAR_0->msg_ring_pages_pa[VAR_2] = VAR_1->ringPPNs[VAR_2] << VMW_PAGE_SHIFT;",
"}",
"RS_SET_FIELD(VAR_0, msgProdIdx, 0);",
"RS_SET_FIELD(VAR_0, msgConsIdx, 0);",
"RS_SET_FIELD(VAR_0, msgNumEntriesLog2, len_log2);",
"trace_pvscsi_ring_init_msg(len_log2);",
"smp_wmb();",
"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
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
55
],
[
59
],
[
61
]
] |
2,552 | void ppc_hash64_stop_access(PowerPCCPU *cpu, uint64_t token)
{
if (cpu->env.external_htab == MMU_HASH64_KVM_MANAGED_HPT) {
kvmppc_hash64_free_pteg(token);
}
}
| false | qemu | 1ad9f0a464fe78d30ee60b3629f7a825cf2fab13 | void ppc_hash64_stop_access(PowerPCCPU *cpu, uint64_t token)
{
if (cpu->env.external_htab == MMU_HASH64_KVM_MANAGED_HPT) {
kvmppc_hash64_free_pteg(token);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PowerPCCPU *VAR_0, uint64_t VAR_1)
{
if (VAR_0->env.external_htab == MMU_HASH64_KVM_MANAGED_HPT) {
kvmppc_hash64_free_pteg(VAR_1);
}
}
| [
"void FUNC_0(PowerPCCPU *VAR_0, uint64_t VAR_1)\n{",
"if (VAR_0->env.external_htab == MMU_HASH64_KVM_MANAGED_HPT) {",
"kvmppc_hash64_free_pteg(VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
2,553 | static void puv3_load_kernel(const char *kernel_filename)
{
int size;
assert(kernel_filename != NULL);
/* only zImage format supported */
size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
KERNEL_MAX_SIZE);
if (size < 0) {
hw_error("Load kernel error: '%s'\n", kernel_filename);
}
/* cheat curses that we have a graphic console, only under ocd console */
graphic_console_init(NULL, NULL, NULL, NULL, NULL);
}
| false | qemu | 2c62f08ddbf3fa80dc7202eb9a2ea60ae44e2cc5 | static void puv3_load_kernel(const char *kernel_filename)
{
int size;
assert(kernel_filename != NULL);
size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
KERNEL_MAX_SIZE);
if (size < 0) {
hw_error("Load kernel error: '%s'\n", kernel_filename);
}
graphic_console_init(NULL, NULL, NULL, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
int VAR_1;
assert(VAR_0 != NULL);
VAR_1 = load_image_targphys(VAR_0, KERNEL_LOAD_ADDR,
KERNEL_MAX_SIZE);
if (VAR_1 < 0) {
hw_error("Load kernel error: '%s'\n", VAR_0);
}
graphic_console_init(NULL, NULL, NULL, NULL, NULL);
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"int VAR_1;",
"assert(VAR_0 != NULL);",
"VAR_1 = load_image_targphys(VAR_0, KERNEL_LOAD_ADDR,\nKERNEL_MAX_SIZE);",
"if (VAR_1 < 0) {",
"hw_error(\"Load kernel error: '%s'\\n\", VAR_0);",
"}",
"graphic_console_init(NULL, NULL, NULL, NULL, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
]
] |
2,554 | static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma,
int current_index, uint64_t current_addr,
uint64_t length)
{
struct ibv_sge sge;
struct ibv_send_wr send_wr = { 0 };
struct ibv_send_wr *bad_wr;
int reg_result_idx, ret, count = 0;
uint64_t chunk, chunks;
uint8_t *chunk_start, *chunk_end;
RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]);
RDMARegister reg;
RDMARegisterResult *reg_result;
RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT };
RDMAControlHeader head = { .len = sizeof(RDMARegister),
.type = RDMA_CONTROL_REGISTER_REQUEST,
.repeat = 1,
};
retry:
sge.addr = (uint64_t)(block->local_host_addr +
(current_addr - block->offset));
sge.length = length;
chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) sge.addr);
chunk_start = ram_chunk_start(block, chunk);
if (block->is_ram_block) {
chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
} else {
chunks = block->length / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((block->length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
}
DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n",
chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);
chunk_end = ram_chunk_end(block, chunk + chunks);
if (!rdma->pin_all) {
#ifdef RDMA_UNREGISTRATION_EXAMPLE
qemu_rdma_unregister_waiting(rdma);
#endif
}
while (test_bit(chunk, block->transit_bitmap)) {
(void)count;
DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d %d\n",
count++, current_index, chunk,
sge.addr, length, rdma->nb_sent, block->nb_chunks);
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
if (ret < 0) {
fprintf(stderr, "Failed to Wait for previous write to complete "
"block %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d\n",
current_index, chunk, sge.addr, length, rdma->nb_sent);
return ret;
}
}
if (!rdma->pin_all || !block->is_ram_block) {
if (!block->remote_keys[chunk]) {
/*
* This chunk has not yet been registered, so first check to see
* if the entire chunk is zero. If so, tell the other size to
* memset() + madvise() the entire chunk without RDMA.
*/
if (can_use_buffer_find_nonzero_offset((void *)sge.addr, length)
&& buffer_find_nonzero_offset((void *)sge.addr,
length) == length) {
RDMACompress comp = {
.offset = current_addr,
.value = 0,
.block_idx = current_index,
.length = length,
};
head.len = sizeof(comp);
head.type = RDMA_CONTROL_COMPRESS;
DDPRINTF("Entire chunk is zero, sending compress: %"
PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, sge.length, current_index, current_addr);
compress_to_network(&comp);
ret = qemu_rdma_exchange_send(rdma, &head,
(uint8_t *) &comp, NULL, NULL, NULL);
if (ret < 0) {
return -EIO;
}
acct_update_position(f, sge.length, true);
return 1;
}
/*
* Otherwise, tell other side to register.
*/
reg.current_index = current_index;
if (block->is_ram_block) {
reg.key.current_addr = current_addr;
} else {
reg.key.chunk = chunk;
}
reg.chunks = chunks;
DDPRINTF("Sending registration request chunk %" PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, sge.length, current_index, current_addr);
register_to_network(®);
ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®,
&resp, ®_result_idx, NULL);
if (ret < 0) {
return ret;
}
/* try to overlap this single registration with the one we sent. */
if (qemu_rdma_register_and_get_keys(rdma, block,
(uint8_t *) sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
reg_result = (RDMARegisterResult *)
rdma->wr_data[reg_result_idx].control_curr;
network_to_result(reg_result);
DDPRINTF("Received registration result:"
" my key: %x their key %x, chunk %" PRIu64 "\n",
block->remote_keys[chunk], reg_result->rkey, chunk);
block->remote_keys[chunk] = reg_result->rkey;
block->remote_host_addr = reg_result->host_addr;
} else {
/* already registered before */
if (qemu_rdma_register_and_get_keys(rdma, block,
(uint8_t *)sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
send_wr.wr.rdma.rkey = block->remote_keys[chunk];
} else {
send_wr.wr.rdma.rkey = block->remote_rkey;
if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
/*
* Encode the ram block index and chunk within this wrid.
* We will use this information at the time of completion
* to figure out which bitmap to check against and then which
* chunk in the bitmap to look for.
*/
send_wr.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE,
current_index, chunk);
send_wr.opcode = IBV_WR_RDMA_WRITE;
send_wr.send_flags = IBV_SEND_SIGNALED;
send_wr.sg_list = &sge;
send_wr.num_sge = 1;
send_wr.wr.rdma.remote_addr = block->remote_host_addr +
(current_addr - block->offset);
DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx"
" remote: %lx, bytes %" PRIu32 "\n",
chunk, sge.addr, send_wr.wr.rdma.remote_addr,
sge.length);
/*
* ibv_post_send() does not return negative error numbers,
* per the specification they are positive - no idea why.
*/
ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
if (ret == ENOMEM) {
DDPRINTF("send queue is full. wait a little....\n");
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
if (ret < 0) {
fprintf(stderr, "rdma migration: failed to make "
"room in full send queue! %d\n", ret);
return ret;
}
goto retry;
} else if (ret > 0) {
perror("rdma migration: post rdma write failed");
return -ret;
}
set_bit(chunk, block->transit_bitmap);
acct_update_position(f, sge.length, false);
rdma->total_writes++;
return 0;
}
| false | qemu | 88571882516a7cb4291a329c537eb79fd126e1f2 | static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma,
int current_index, uint64_t current_addr,
uint64_t length)
{
struct ibv_sge sge;
struct ibv_send_wr send_wr = { 0 };
struct ibv_send_wr *bad_wr;
int reg_result_idx, ret, count = 0;
uint64_t chunk, chunks;
uint8_t *chunk_start, *chunk_end;
RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]);
RDMARegister reg;
RDMARegisterResult *reg_result;
RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT };
RDMAControlHeader head = { .len = sizeof(RDMARegister),
.type = RDMA_CONTROL_REGISTER_REQUEST,
.repeat = 1,
};
retry:
sge.addr = (uint64_t)(block->local_host_addr +
(current_addr - block->offset));
sge.length = length;
chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) sge.addr);
chunk_start = ram_chunk_start(block, chunk);
if (block->is_ram_block) {
chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
} else {
chunks = block->length / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((block->length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
}
DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n",
chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);
chunk_end = ram_chunk_end(block, chunk + chunks);
if (!rdma->pin_all) {
#ifdef RDMA_UNREGISTRATION_EXAMPLE
qemu_rdma_unregister_waiting(rdma);
#endif
}
while (test_bit(chunk, block->transit_bitmap)) {
(void)count;
DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d %d\n",
count++, current_index, chunk,
sge.addr, length, rdma->nb_sent, block->nb_chunks);
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
if (ret < 0) {
fprintf(stderr, "Failed to Wait for previous write to complete "
"block %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d\n",
current_index, chunk, sge.addr, length, rdma->nb_sent);
return ret;
}
}
if (!rdma->pin_all || !block->is_ram_block) {
if (!block->remote_keys[chunk]) {
if (can_use_buffer_find_nonzero_offset((void *)sge.addr, length)
&& buffer_find_nonzero_offset((void *)sge.addr,
length) == length) {
RDMACompress comp = {
.offset = current_addr,
.value = 0,
.block_idx = current_index,
.length = length,
};
head.len = sizeof(comp);
head.type = RDMA_CONTROL_COMPRESS;
DDPRINTF("Entire chunk is zero, sending compress: %"
PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, sge.length, current_index, current_addr);
compress_to_network(&comp);
ret = qemu_rdma_exchange_send(rdma, &head,
(uint8_t *) &comp, NULL, NULL, NULL);
if (ret < 0) {
return -EIO;
}
acct_update_position(f, sge.length, true);
return 1;
}
reg.current_index = current_index;
if (block->is_ram_block) {
reg.key.current_addr = current_addr;
} else {
reg.key.chunk = chunk;
}
reg.chunks = chunks;
DDPRINTF("Sending registration request chunk %" PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, sge.length, current_index, current_addr);
register_to_network(®);
ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®,
&resp, ®_result_idx, NULL);
if (ret < 0) {
return ret;
}
if (qemu_rdma_register_and_get_keys(rdma, block,
(uint8_t *) sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
reg_result = (RDMARegisterResult *)
rdma->wr_data[reg_result_idx].control_curr;
network_to_result(reg_result);
DDPRINTF("Received registration result:"
" my key: %x their key %x, chunk %" PRIu64 "\n",
block->remote_keys[chunk], reg_result->rkey, chunk);
block->remote_keys[chunk] = reg_result->rkey;
block->remote_host_addr = reg_result->host_addr;
} else {
if (qemu_rdma_register_and_get_keys(rdma, block,
(uint8_t *)sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
send_wr.wr.rdma.rkey = block->remote_keys[chunk];
} else {
send_wr.wr.rdma.rkey = block->remote_rkey;
if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr,
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
send_wr.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE,
current_index, chunk);
send_wr.opcode = IBV_WR_RDMA_WRITE;
send_wr.send_flags = IBV_SEND_SIGNALED;
send_wr.sg_list = &sge;
send_wr.num_sge = 1;
send_wr.wr.rdma.remote_addr = block->remote_host_addr +
(current_addr - block->offset);
DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx"
" remote: %lx, bytes %" PRIu32 "\n",
chunk, sge.addr, send_wr.wr.rdma.remote_addr,
sge.length);
ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);
if (ret == ENOMEM) {
DDPRINTF("send queue is full. wait a little....\n");
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE);
if (ret < 0) {
fprintf(stderr, "rdma migration: failed to make "
"room in full send queue! %d\n", ret);
return ret;
}
goto retry;
} else if (ret > 0) {
perror("rdma migration: post rdma write failed");
return -ret;
}
set_bit(chunk, block->transit_bitmap);
acct_update_position(f, sge.length, false);
rdma->total_writes++;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, RDMAContext *VAR_1,
int VAR_2, uint64_t VAR_3,
uint64_t VAR_4)
{
struct ibv_sge VAR_5;
struct ibv_send_wr VAR_6 = { 0 };
struct ibv_send_wr *VAR_7;
int VAR_8, VAR_9, VAR_10 = 0;
uint64_t chunk, chunks;
uint8_t *chunk_start, *chunk_end;
RDMALocalBlock *block = &(VAR_1->local_ram_blocks.block[VAR_2]);
RDMARegister reg;
RDMARegisterResult *reg_result;
RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT };
RDMAControlHeader head = { .len = sizeof(RDMARegister),
.type = RDMA_CONTROL_REGISTER_REQUEST,
.repeat = 1,
};
retry:
VAR_5.addr = (uint64_t)(block->local_host_addr +
(VAR_3 - block->offset));
VAR_5.VAR_4 = VAR_4;
chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) VAR_5.addr);
chunk_start = ram_chunk_start(block, chunk);
if (block->is_ram_block) {
chunks = VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
} else {
chunks = block->VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);
if (chunks && ((block->VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {
chunks--;
}
}
DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n",
chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);
chunk_end = ram_chunk_end(block, chunk + chunks);
if (!VAR_1->pin_all) {
#ifdef RDMA_UNREGISTRATION_EXAMPLE
qemu_rdma_unregister_waiting(VAR_1);
#endif
}
while (test_bit(chunk, block->transit_bitmap)) {
(void)VAR_10;
DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d %d\n",
VAR_10++, VAR_2, chunk,
VAR_5.addr, VAR_4, VAR_1->nb_sent, block->nb_chunks);
VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE);
if (VAR_9 < 0) {
fprintf(stderr, "Failed to Wait for previous write to complete "
"block %d chunk %" PRIu64
" current %" PRIu64 " len %" PRIu64 " %d\n",
VAR_2, chunk, VAR_5.addr, VAR_4, VAR_1->nb_sent);
return VAR_9;
}
}
if (!VAR_1->pin_all || !block->is_ram_block) {
if (!block->remote_keys[chunk]) {
if (can_use_buffer_find_nonzero_offset((void *)VAR_5.addr, VAR_4)
&& buffer_find_nonzero_offset((void *)VAR_5.addr,
VAR_4) == VAR_4) {
RDMACompress comp = {
.offset = VAR_3,
.value = 0,
.block_idx = VAR_2,
.VAR_4 = VAR_4,
};
head.len = sizeof(comp);
head.type = RDMA_CONTROL_COMPRESS;
DDPRINTF("Entire chunk is zero, sending compress: %"
PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, VAR_5.VAR_4, VAR_2, VAR_3);
compress_to_network(&comp);
VAR_9 = qemu_rdma_exchange_send(VAR_1, &head,
(uint8_t *) &comp, NULL, NULL, NULL);
if (VAR_9 < 0) {
return -EIO;
}
acct_update_position(VAR_0, VAR_5.VAR_4, true);
return 1;
}
reg.VAR_2 = VAR_2;
if (block->is_ram_block) {
reg.key.VAR_3 = VAR_3;
} else {
reg.key.chunk = chunk;
}
reg.chunks = chunks;
DDPRINTF("Sending registration request chunk %" PRIu64 " for %d "
"bytes, index: %d, offset: %" PRId64 "...\n",
chunk, VAR_5.VAR_4, VAR_2, VAR_3);
register_to_network(®);
VAR_9 = qemu_rdma_exchange_send(VAR_1, &head, (uint8_t *) ®,
&resp, &VAR_8, NULL);
if (VAR_9 < 0) {
return VAR_9;
}
if (qemu_rdma_register_and_get_keys(VAR_1, block,
(uint8_t *) VAR_5.addr,
&VAR_5.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
reg_result = (RDMARegisterResult *)
VAR_1->wr_data[VAR_8].control_curr;
network_to_result(reg_result);
DDPRINTF("Received registration result:"
" my key: %x their key %x, chunk %" PRIu64 "\n",
block->remote_keys[chunk], reg_result->rkey, chunk);
block->remote_keys[chunk] = reg_result->rkey;
block->remote_host_addr = reg_result->host_addr;
} else {
if (qemu_rdma_register_and_get_keys(VAR_1, block,
(uint8_t *)VAR_5.addr,
&VAR_5.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
VAR_6.wr.VAR_1.rkey = block->remote_keys[chunk];
} else {
VAR_6.wr.VAR_1.rkey = block->remote_rkey;
if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *)VAR_5.addr,
&VAR_5.lkey, NULL, chunk,
chunk_start, chunk_end)) {
fprintf(stderr, "cannot get lkey!\n");
return -EINVAL;
}
}
VAR_6.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE,
VAR_2, chunk);
VAR_6.opcode = IBV_WR_RDMA_WRITE;
VAR_6.send_flags = IBV_SEND_SIGNALED;
VAR_6.sg_list = &VAR_5;
VAR_6.num_sge = 1;
VAR_6.wr.VAR_1.remote_addr = block->remote_host_addr +
(VAR_3 - block->offset);
DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx"
" remote: %lx, bytes %" PRIu32 "\n",
chunk, VAR_5.addr, VAR_6.wr.VAR_1.remote_addr,
VAR_5.VAR_4);
VAR_9 = ibv_post_send(VAR_1->qp, &VAR_6, &VAR_7);
if (VAR_9 == ENOMEM) {
DDPRINTF("send queue is full. wait a little....\n");
VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE);
if (VAR_9 < 0) {
fprintf(stderr, "VAR_1 migration: failed to make "
"room in full send queue! %d\n", VAR_9);
return VAR_9;
}
goto retry;
} else if (VAR_9 > 0) {
perror("VAR_1 migration: post VAR_1 write failed");
return -VAR_9;
}
set_bit(chunk, block->transit_bitmap);
acct_update_position(VAR_0, VAR_5.VAR_4, false);
VAR_1->total_writes++;
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, RDMAContext *VAR_1,\nint VAR_2, uint64_t VAR_3,\nuint64_t VAR_4)\n{",
"struct ibv_sge VAR_5;",
"struct ibv_send_wr VAR_6 = { 0 };",
"struct ibv_send_wr *VAR_7;",
"int VAR_8, VAR_9, VAR_10 = 0;",
"uint64_t chunk, chunks;",
"uint8_t *chunk_start, *chunk_end;",
"RDMALocalBlock *block = &(VAR_1->local_ram_blocks.block[VAR_2]);",
"RDMARegister reg;",
"RDMARegisterResult *reg_result;",
"RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT };",
"RDMAControlHeader head = { .len = sizeof(RDMARegister),",
".type = RDMA_CONTROL_REGISTER_REQUEST,\n.repeat = 1,\n};",
"retry:\nVAR_5.addr = (uint64_t)(block->local_host_addr +\n(VAR_3 - block->offset));",
"VAR_5.VAR_4 = VAR_4;",
"chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) VAR_5.addr);",
"chunk_start = ram_chunk_start(block, chunk);",
"if (block->is_ram_block) {",
"chunks = VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);",
"if (chunks && ((VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {",
"chunks--;",
"}",
"} else {",
"chunks = block->VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);",
"if (chunks && ((block->VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {",
"chunks--;",
"}",
"}",
"DDPRINTF(\"Writing %\" PRIu64 \" chunks, (%\" PRIu64 \" MB)\\n\",\nchunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);",
"chunk_end = ram_chunk_end(block, chunk + chunks);",
"if (!VAR_1->pin_all) {",
"#ifdef RDMA_UNREGISTRATION_EXAMPLE\nqemu_rdma_unregister_waiting(VAR_1);",
"#endif\n}",
"while (test_bit(chunk, block->transit_bitmap)) {",
"(void)VAR_10;",
"DDPRINTF(\"(%d) Not clobbering: block: %d chunk %\" PRIu64\n\" current %\" PRIu64 \" len %\" PRIu64 \" %d %d\\n\",\nVAR_10++, VAR_2, chunk,\nVAR_5.addr, VAR_4, VAR_1->nb_sent, block->nb_chunks);",
"VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE);",
"if (VAR_9 < 0) {",
"fprintf(stderr, \"Failed to Wait for previous write to complete \"\n\"block %d chunk %\" PRIu64\n\" current %\" PRIu64 \" len %\" PRIu64 \" %d\\n\",\nVAR_2, chunk, VAR_5.addr, VAR_4, VAR_1->nb_sent);",
"return VAR_9;",
"}",
"}",
"if (!VAR_1->pin_all || !block->is_ram_block) {",
"if (!block->remote_keys[chunk]) {",
"if (can_use_buffer_find_nonzero_offset((void *)VAR_5.addr, VAR_4)\n&& buffer_find_nonzero_offset((void *)VAR_5.addr,\nVAR_4) == VAR_4) {",
"RDMACompress comp = {",
".offset = VAR_3,\n.value = 0,\n.block_idx = VAR_2,\n.VAR_4 = VAR_4,\n};",
"head.len = sizeof(comp);",
"head.type = RDMA_CONTROL_COMPRESS;",
"DDPRINTF(\"Entire chunk is zero, sending compress: %\"\nPRIu64 \" for %d \"\n\"bytes, index: %d, offset: %\" PRId64 \"...\\n\",\nchunk, VAR_5.VAR_4, VAR_2, VAR_3);",
"compress_to_network(&comp);",
"VAR_9 = qemu_rdma_exchange_send(VAR_1, &head,\n(uint8_t *) &comp, NULL, NULL, NULL);",
"if (VAR_9 < 0) {",
"return -EIO;",
"}",
"acct_update_position(VAR_0, VAR_5.VAR_4, true);",
"return 1;",
"}",
"reg.VAR_2 = VAR_2;",
"if (block->is_ram_block) {",
"reg.key.VAR_3 = VAR_3;",
"} else {",
"reg.key.chunk = chunk;",
"}",
"reg.chunks = chunks;",
"DDPRINTF(\"Sending registration request chunk %\" PRIu64 \" for %d \"\n\"bytes, index: %d, offset: %\" PRId64 \"...\\n\",\nchunk, VAR_5.VAR_4, VAR_2, VAR_3);",
"register_to_network(®);",
"VAR_9 = qemu_rdma_exchange_send(VAR_1, &head, (uint8_t *) ®,\n&resp, &VAR_8, NULL);",
"if (VAR_9 < 0) {",
"return VAR_9;",
"}",
"if (qemu_rdma_register_and_get_keys(VAR_1, block,\n(uint8_t *) VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {",
"fprintf(stderr, \"cannot get lkey!\\n\");",
"return -EINVAL;",
"}",
"reg_result = (RDMARegisterResult *)\nVAR_1->wr_data[VAR_8].control_curr;",
"network_to_result(reg_result);",
"DDPRINTF(\"Received registration result:\"\n\" my key: %x their key %x, chunk %\" PRIu64 \"\\n\",\nblock->remote_keys[chunk], reg_result->rkey, chunk);",
"block->remote_keys[chunk] = reg_result->rkey;",
"block->remote_host_addr = reg_result->host_addr;",
"} else {",
"if (qemu_rdma_register_and_get_keys(VAR_1, block,\n(uint8_t *)VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {",
"fprintf(stderr, \"cannot get lkey!\\n\");",
"return -EINVAL;",
"}",
"}",
"VAR_6.wr.VAR_1.rkey = block->remote_keys[chunk];",
"} else {",
"VAR_6.wr.VAR_1.rkey = block->remote_rkey;",
"if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *)VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {",
"fprintf(stderr, \"cannot get lkey!\\n\");",
"return -EINVAL;",
"}",
"}",
"VAR_6.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE,\nVAR_2, chunk);",
"VAR_6.opcode = IBV_WR_RDMA_WRITE;",
"VAR_6.send_flags = IBV_SEND_SIGNALED;",
"VAR_6.sg_list = &VAR_5;",
"VAR_6.num_sge = 1;",
"VAR_6.wr.VAR_1.remote_addr = block->remote_host_addr +\n(VAR_3 - block->offset);",
"DDDPRINTF(\"Posting chunk: %\" PRIu64 \", addr: %lx\"\n\" remote: %lx, bytes %\" PRIu32 \"\\n\",\nchunk, VAR_5.addr, VAR_6.wr.VAR_1.remote_addr,\nVAR_5.VAR_4);",
"VAR_9 = ibv_post_send(VAR_1->qp, &VAR_6, &VAR_7);",
"if (VAR_9 == ENOMEM) {",
"DDPRINTF(\"send queue is full. wait a little....\\n\");",
"VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE);",
"if (VAR_9 < 0) {",
"fprintf(stderr, \"VAR_1 migration: failed to make \"\n\"room in full send queue! %d\\n\", VAR_9);",
"return VAR_9;",
"}",
"goto retry;",
"} else if (VAR_9 > 0) {",
"perror(\"VAR_1 migration: post VAR_1 write failed\");",
"return -VAR_9;",
"}",
"set_bit(chunk, block->transit_bitmap);",
"acct_update_position(VAR_0, VAR_5.VAR_4, false);",
"VAR_1->total_writes++;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33,
35
],
[
39,
41,
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
89
],
[
93
],
[
95,
97
],
[
99,
101
],
[
105
],
[
107
],
[
109,
111,
113,
115
],
[
119
],
[
123
],
[
125,
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
157,
159,
161
],
[
163
],
[
165,
167,
169,
171,
173
],
[
177
],
[
179
],
[
183,
185,
187,
189
],
[
193
],
[
195,
197
],
[
201
],
[
203
],
[
205
],
[
209
],
[
213
],
[
215
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241,
243,
245
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
265,
267,
269,
271
],
[
273
],
[
275
],
[
277
],
[
281,
283
],
[
287
],
[
291,
293,
295
],
[
299
],
[
301
],
[
303
],
[
307,
309,
311,
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
333,
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
361,
363
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
381,
383,
385,
387
],
[
399
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411,
413
],
[
415
],
[
417
],
[
421
],
[
425
],
[
427
],
[
429
],
[
431
],
[
435
],
[
437
],
[
439
],
[
443
],
[
445
]
] |
2,555 | void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
bool has_base, const char *base,
bool has_top, const char *top,
bool has_backing_file, const char *backing_file,
bool has_speed, int64_t speed,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *base_bs, *top_bs;
AioContext *aio_context;
Error *local_err = NULL;
/* This will be part of the QMP command, if/when the
* BlockdevOnError change for blkmirror makes it in
*/
BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
if (!has_speed) {
speed = 0;
}
/* Important Note:
* libvirt relies on the DeviceNotFound error class in order to probe for
* live commit feature versions; for this to work, we must make sure to
* perform the device lookup before any generic errors that may occur in a
* scenario in which all optional arguments are omitted. */
bs = qmp_get_root_bs(device, &local_err);
if (!bs) {
bs = bdrv_lookup_bs(device, device, NULL);
if (!bs) {
error_free(local_err);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
} else {
error_propagate(errp, local_err);
}
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, errp)) {
goto out;
}
/* default top_bs is the active layer */
top_bs = bs;
if (has_top && top) {
if (strcmp(bs->filename, top) != 0) {
top_bs = bdrv_find_backing_image(bs, top);
}
}
if (top_bs == NULL) {
error_setg(errp, "Top image file %s not found", top ? top : "NULL");
goto out;
}
assert(bdrv_get_aio_context(top_bs) == aio_context);
if (has_base && base) {
base_bs = bdrv_find_backing_image(top_bs, base);
} else {
base_bs = bdrv_find_base(top_bs);
}
if (base_bs == NULL) {
error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) {
goto out;
}
/* Do not allow attempts to commit an image into itself */
if (top_bs == base_bs) {
error_setg(errp, "cannot commit an image into itself");
goto out;
}
if (top_bs == bs) {
if (has_backing_file) {
error_setg(errp, "'backing-file' specified,"
" but 'top' is the active layer");
goto out;
}
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed,
on_error, block_job_cb, bs, &local_err, false);
} else {
commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
on_error, block_job_cb, bs,
has_backing_file ? backing_file : NULL, &local_err);
}
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| false | qemu | 058223a6e3b73cdf7f56b8d0a55032f99c5f11ac | void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
bool has_base, const char *base,
bool has_top, const char *top,
bool has_backing_file, const char *backing_file,
bool has_speed, int64_t speed,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *base_bs, *top_bs;
AioContext *aio_context;
Error *local_err = NULL;
BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
if (!has_speed) {
speed = 0;
}
bs = qmp_get_root_bs(device, &local_err);
if (!bs) {
bs = bdrv_lookup_bs(device, device, NULL);
if (!bs) {
error_free(local_err);
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", device);
} else {
error_propagate(errp, local_err);
}
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, errp)) {
goto out;
}
top_bs = bs;
if (has_top && top) {
if (strcmp(bs->filename, top) != 0) {
top_bs = bdrv_find_backing_image(bs, top);
}
}
if (top_bs == NULL) {
error_setg(errp, "Top image file %s not found", top ? top : "NULL");
goto out;
}
assert(bdrv_get_aio_context(top_bs) == aio_context);
if (has_base && base) {
base_bs = bdrv_find_backing_image(top_bs, base);
} else {
base_bs = bdrv_find_base(top_bs);
}
if (base_bs == NULL) {
error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) {
goto out;
}
if (top_bs == base_bs) {
error_setg(errp, "cannot commit an image into itself");
goto out;
}
if (top_bs == bs) {
if (has_backing_file) {
error_setg(errp, "'backing-file' specified,"
" but 'top' is the active layer");
goto out;
}
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed,
on_error, block_job_cb, bs, &local_err, false);
} else {
commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
on_error, block_job_cb, bs,
has_backing_file ? backing_file : NULL, &local_err);
}
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(bool VAR_0, const char *VAR_1, const char *VAR_2,
bool VAR_3, const char *VAR_4,
bool VAR_5, const char *VAR_6,
bool VAR_7, const char *VAR_8,
bool VAR_9, int64_t VAR_10,
Error **VAR_11)
{
BlockDriverState *bs;
BlockDriverState *base_bs, *top_bs;
AioContext *aio_context;
Error *local_err = NULL;
BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
if (!VAR_9) {
VAR_10 = 0;
}
bs = qmp_get_root_bs(VAR_2, &local_err);
if (!bs) {
bs = bdrv_lookup_bs(VAR_2, VAR_2, NULL);
if (!bs) {
error_free(local_err);
error_set(VAR_11, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", VAR_2);
} else {
error_propagate(VAR_11, local_err);
}
return;
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, VAR_11)) {
goto out;
}
top_bs = bs;
if (VAR_5 && VAR_6) {
if (strcmp(bs->filename, VAR_6) != 0) {
top_bs = bdrv_find_backing_image(bs, VAR_6);
}
}
if (top_bs == NULL) {
error_setg(VAR_11, "Top image file %s not found", VAR_6 ? VAR_6 : "NULL");
goto out;
}
assert(bdrv_get_aio_context(top_bs) == aio_context);
if (VAR_3 && VAR_4) {
base_bs = bdrv_find_backing_image(top_bs, VAR_4);
} else {
base_bs = bdrv_find_base(top_bs);
}
if (base_bs == NULL) {
error_setg(VAR_11, QERR_BASE_NOT_FOUND, VAR_4 ? VAR_4 : "NULL");
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, VAR_11)) {
goto out;
}
if (top_bs == base_bs) {
error_setg(VAR_11, "cannot commit an image into itself");
goto out;
}
if (top_bs == bs) {
if (VAR_7) {
error_setg(VAR_11, "'backing-file' specified,"
" but 'VAR_6' is the active layer");
goto out;
}
commit_active_start(VAR_0 ? VAR_1 : NULL, bs, base_bs, VAR_10,
on_error, block_job_cb, bs, &local_err, false);
} else {
commit_start(VAR_0 ? VAR_1 : NULL, bs, base_bs, top_bs, VAR_10,
on_error, block_job_cb, bs,
VAR_7 ? VAR_8 : NULL, &local_err);
}
if (local_err != NULL) {
error_propagate(VAR_11, local_err);
goto out;
}
out:
aio_context_release(aio_context);
}
| [
"void FUNC_0(bool VAR_0, const char *VAR_1, const char *VAR_2,\nbool VAR_3, const char *VAR_4,\nbool VAR_5, const char *VAR_6,\nbool VAR_7, const char *VAR_8,\nbool VAR_9, int64_t VAR_10,\nError **VAR_11)\n{",
"BlockDriverState *bs;",
"BlockDriverState *base_bs, *top_bs;",
"AioContext *aio_context;",
"Error *local_err = NULL;",
"BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;",
"if (!VAR_9) {",
"VAR_10 = 0;",
"}",
"bs = qmp_get_root_bs(VAR_2, &local_err);",
"if (!bs) {",
"bs = bdrv_lookup_bs(VAR_2, VAR_2, NULL);",
"if (!bs) {",
"error_free(local_err);",
"error_set(VAR_11, ERROR_CLASS_DEVICE_NOT_FOUND,\n\"Device '%s' not found\", VAR_2);",
"} else {",
"error_propagate(VAR_11, local_err);",
"}",
"return;",
"}",
"aio_context = bdrv_get_aio_context(bs);",
"aio_context_acquire(aio_context);",
"if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, VAR_11)) {",
"goto out;",
"}",
"top_bs = bs;",
"if (VAR_5 && VAR_6) {",
"if (strcmp(bs->filename, VAR_6) != 0) {",
"top_bs = bdrv_find_backing_image(bs, VAR_6);",
"}",
"}",
"if (top_bs == NULL) {",
"error_setg(VAR_11, \"Top image file %s not found\", VAR_6 ? VAR_6 : \"NULL\");",
"goto out;",
"}",
"assert(bdrv_get_aio_context(top_bs) == aio_context);",
"if (VAR_3 && VAR_4) {",
"base_bs = bdrv_find_backing_image(top_bs, VAR_4);",
"} else {",
"base_bs = bdrv_find_base(top_bs);",
"}",
"if (base_bs == NULL) {",
"error_setg(VAR_11, QERR_BASE_NOT_FOUND, VAR_4 ? VAR_4 : \"NULL\");",
"goto out;",
"}",
"assert(bdrv_get_aio_context(base_bs) == aio_context);",
"if (bdrv_op_is_blocked(base_bs, BLOCK_OP_TYPE_COMMIT_TARGET, VAR_11)) {",
"goto out;",
"}",
"if (top_bs == base_bs) {",
"error_setg(VAR_11, \"cannot commit an image into itself\");",
"goto out;",
"}",
"if (top_bs == bs) {",
"if (VAR_7) {",
"error_setg(VAR_11, \"'backing-file' specified,\"\n\" but 'VAR_6' is the active layer\");",
"goto out;",
"}",
"commit_active_start(VAR_0 ? VAR_1 : NULL, bs, base_bs, VAR_10,\non_error, block_job_cb, bs, &local_err, false);",
"} else {",
"commit_start(VAR_0 ? VAR_1 : NULL, bs, base_bs, top_bs, VAR_10,\non_error, block_job_cb, bs,\nVAR_7 ? VAR_8 : NULL, &local_err);",
"}",
"if (local_err != NULL) {",
"error_propagate(VAR_11, local_err);",
"goto out;",
"}",
"out:\naio_context_release(aio_context);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
33
],
[
35
],
[
37
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181,
183
],
[
185
],
[
187,
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205,
207
],
[
209
]
] |
2,556 | static void ffmpeg_cleanup(int ret)
{
int i, j;
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
printf("bench: maxrss=%ikB\n", maxrss);
}
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
av_freep(&fg->outputs[j]->name);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
/* close files */
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[i]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
} else if (ret && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
}
| false | FFmpeg | 04091552616e6c5bea754ebbee26f77cb8ba416e | static void ffmpeg_cleanup(int ret)
{
int i, j;
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
printf("bench: maxrss=%ikB\n", maxrss);
}
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
av_freep(&fg->outputs[j]->name);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[i]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
} else if (ret && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
int VAR_1, VAR_2;
if (do_benchmark) {
int VAR_3 = getmaxrss() / 1024;
printf("bench: VAR_3=%ikB\n", VAR_3);
}
for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) {
FilterGraph *fg = filtergraphs[VAR_1];
avfilter_graph_free(&fg->graph);
for (VAR_2 = 0; VAR_2 < fg->nb_inputs; VAR_2++) {
av_freep(&fg->inputs[VAR_2]->name);
av_freep(&fg->inputs[VAR_2]);
}
av_freep(&fg->inputs);
for (VAR_2 = 0; VAR_2 < fg->nb_outputs; VAR_2++) {
av_freep(&fg->outputs[VAR_2]->name);
av_freep(&fg->outputs[VAR_2]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[VAR_1]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {
OutputFile *of = output_files[VAR_1];
AVFormatContext *s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[VAR_1]);
}
for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {
OutputStream *ost = output_streams[VAR_1];
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[VAR_1]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {
avformat_close_input(&input_files[VAR_1]->ctx);
av_freep(&input_files[VAR_1]);
}
for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {
InputStream *ist = input_streams[VAR_1];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[VAR_1]);
}
if (vstats_file)
fclose(vstats_file);
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
} else if (VAR_0 && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
}
| [
"static void FUNC_0(int VAR_0)\n{",
"int VAR_1, VAR_2;",
"if (do_benchmark) {",
"int VAR_3 = getmaxrss() / 1024;",
"printf(\"bench: VAR_3=%ikB\\n\", VAR_3);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_filtergraphs; VAR_1++) {",
"FilterGraph *fg = filtergraphs[VAR_1];",
"avfilter_graph_free(&fg->graph);",
"for (VAR_2 = 0; VAR_2 < fg->nb_inputs; VAR_2++) {",
"av_freep(&fg->inputs[VAR_2]->name);",
"av_freep(&fg->inputs[VAR_2]);",
"}",
"av_freep(&fg->inputs);",
"for (VAR_2 = 0; VAR_2 < fg->nb_outputs; VAR_2++) {",
"av_freep(&fg->outputs[VAR_2]->name);",
"av_freep(&fg->outputs[VAR_2]);",
"}",
"av_freep(&fg->outputs);",
"av_freep(&fg->graph_desc);",
"av_freep(&filtergraphs[VAR_1]);",
"}",
"av_freep(&filtergraphs);",
"av_freep(&subtitle_out);",
"for (VAR_1 = 0; VAR_1 < nb_output_files; VAR_1++) {",
"OutputFile *of = output_files[VAR_1];",
"AVFormatContext *s = of->ctx;",
"if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)\navio_closep(&s->pb);",
"avformat_free_context(s);",
"av_dict_free(&of->opts);",
"av_freep(&output_files[VAR_1]);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_output_streams; VAR_1++) {",
"OutputStream *ost = output_streams[VAR_1];",
"AVBitStreamFilterContext *bsfc = ost->bitstream_filters;",
"while (bsfc) {",
"AVBitStreamFilterContext *next = bsfc->next;",
"av_bitstream_filter_close(bsfc);",
"bsfc = next;",
"}",
"ost->bitstream_filters = NULL;",
"av_frame_free(&ost->filtered_frame);",
"av_frame_free(&ost->last_frame);",
"av_parser_close(ost->parser);",
"av_freep(&ost->forced_keyframes);",
"av_expr_free(ost->forced_keyframes_pexpr);",
"av_freep(&ost->avfilter);",
"av_freep(&ost->logfile_prefix);",
"av_freep(&ost->audio_channels_map);",
"ost->audio_channels_mapped = 0;",
"avcodec_free_context(&ost->enc_ctx);",
"av_freep(&output_streams[VAR_1]);",
"}",
"#if HAVE_PTHREADS\nfree_input_threads();",
"#endif\nfor (VAR_1 = 0; VAR_1 < nb_input_files; VAR_1++) {",
"avformat_close_input(&input_files[VAR_1]->ctx);",
"av_freep(&input_files[VAR_1]);",
"}",
"for (VAR_1 = 0; VAR_1 < nb_input_streams; VAR_1++) {",
"InputStream *ist = input_streams[VAR_1];",
"av_frame_free(&ist->decoded_frame);",
"av_frame_free(&ist->filter_frame);",
"av_dict_free(&ist->decoder_opts);",
"avsubtitle_free(&ist->prev_sub.subtitle);",
"av_frame_free(&ist->sub2video.frame);",
"av_freep(&ist->filters);",
"av_freep(&ist->hwaccel_device);",
"avcodec_free_context(&ist->dec_ctx);",
"av_freep(&input_streams[VAR_1]);",
"}",
"if (vstats_file)\nfclose(vstats_file);",
"av_freep(&vstats_filename);",
"av_freep(&input_streams);",
"av_freep(&input_files);",
"av_freep(&output_streams);",
"av_freep(&output_files);",
"uninit_opts();",
"avformat_network_deinit();",
"if (received_sigterm) {",
"av_log(NULL, AV_LOG_INFO, \"Received signal %d: terminating.\\n\",\n(int) received_sigterm);",
"} else if (VAR_0 && transcode_init_done) {",
"av_log(NULL, AV_LOG_INFO, \"Conversion failed!\\n\");",
"}",
"term_exit();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
175
],
[
177
],
[
181,
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
203
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
]
] |
2,557 | Aml *aml_local(int num)
{
Aml *var;
uint8_t op = 0x60 /* Local0Op */ + num;
assert(num <= 7);
var = aml_opcode(op);
return var;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | Aml *aml_local(int num)
{
Aml *var;
uint8_t op = 0x60 + num;
assert(num <= 7);
var = aml_opcode(op);
return var;
}
| {
"code": [],
"line_no": []
} | Aml *FUNC_0(int num)
{
Aml *var;
uint8_t op = 0x60 + num;
assert(num <= 7);
var = aml_opcode(op);
return var;
}
| [
"Aml *FUNC_0(int num)\n{",
"Aml *var;",
"uint8_t op = 0x60 + num;",
"assert(num <= 7);",
"var = aml_opcode(op);",
"return var;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.