id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
25,136 | static void xhci_check_iso_kick(XHCIState *xhci, XHCITransfer *xfer,
XHCIEPContext *epctx, uint64_t mfindex)
{
if (xfer->mfindex_kick > mfindex) {
timer_mod(epctx->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
(xfer->mfindex_kick - mfindex) * 125000);
xfer->running_retry = 1;
} else {
epctx->mfindex_last = xfer->mfindex_kick;
timer_del(epctx->kick_timer);
xfer->running_retry = 0;
}
}
| true | qemu | 4d7a81c06f5f17e019a2d3a18300500bd64f6f40 | static void xhci_check_iso_kick(XHCIState *xhci, XHCITransfer *xfer,
XHCIEPContext *epctx, uint64_t mfindex)
{
if (xfer->mfindex_kick > mfindex) {
timer_mod(epctx->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
(xfer->mfindex_kick - mfindex) * 125000);
xfer->running_retry = 1;
} else {
epctx->mfindex_last = xfer->mfindex_kick;
timer_del(epctx->kick_timer);
xfer->running_retry = 0;
}
}
| {
"code": [
"static void xhci_check_iso_kick(XHCIState *xhci, XHCITransfer *xfer,",
" XHCIEPContext *epctx, uint64_t mfindex)"
],
"line_no": [
1,
3
]
} | static void FUNC_0(XHCIState *VAR_0, XHCITransfer *VAR_1,
XHCIEPContext *VAR_2, uint64_t VAR_3)
{
if (VAR_1->mfindex_kick > VAR_3) {
timer_mod(VAR_2->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
(VAR_1->mfindex_kick - VAR_3) * 125000);
VAR_1->running_retry = 1;
} else {
VAR_2->mfindex_last = VAR_1->mfindex_kick;
timer_del(VAR_2->kick_timer);
VAR_1->running_retry = 0;
}
}
| [
"static void FUNC_0(XHCIState *VAR_0, XHCITransfer *VAR_1,\nXHCIEPContext *VAR_2, uint64_t VAR_3)\n{",
"if (VAR_1->mfindex_kick > VAR_3) {",
"timer_mod(VAR_2->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +\n(VAR_1->mfindex_kick - VAR_3) * 125000);",
"VAR_1->running_retry = 1;",
"} else {",
"VAR_2->mfindex_last = VAR_1->mfindex_kick;",
"timer_del(VAR_2->kick_timer);",
"VAR_1->running_retry = 0;",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
25,137 | static void watch_mem_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
check_watchpoint(addr & ~TARGET_PAGE_MASK, size, BP_MEM_WRITE);
switch (size) {
case 1:
stb_phys(&address_space_memory, addr, val);
break;
case 2:
stw_phys(&address_space_memory, addr, val);
break;
case 4:
stl_phys(&address_space_memory, addr, val);
break;
default: abort();
}
}
| true | qemu | 66b9b43c42049bcae37668e890fedde9a72c8167 | static void watch_mem_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
check_watchpoint(addr & ~TARGET_PAGE_MASK, size, BP_MEM_WRITE);
switch (size) {
case 1:
stb_phys(&address_space_memory, addr, val);
break;
case 2:
stw_phys(&address_space_memory, addr, val);
break;
case 4:
stl_phys(&address_space_memory, addr, val);
break;
default: abort();
}
}
| {
"code": [
"static void watch_mem_write(void *opaque, hwaddr addr,",
" uint64_t val, unsigned size)",
" check_watchpoint(addr & ~TARGET_PAGE_MASK, size, BP_MEM_WRITE);",
" stb_phys(&address_space_memory, addr, val);",
" stw_phys(&address_space_memory, addr, val);",
" stl_phys(&address_space_memory, addr, val);"
],
"line_no": [
1,
3,
7,
13,
19,
25
]
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
check_watchpoint(VAR_1 & ~TARGET_PAGE_MASK, VAR_3, BP_MEM_WRITE);
switch (VAR_3) {
case 1:
stb_phys(&address_space_memory, VAR_1, VAR_2);
break;
case 2:
stw_phys(&address_space_memory, VAR_1, VAR_2);
break;
case 4:
stl_phys(&address_space_memory, VAR_1, VAR_2);
break;
default: abort();
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"check_watchpoint(VAR_1 & ~TARGET_PAGE_MASK, VAR_3, BP_MEM_WRITE);",
"switch (VAR_3) {",
"case 1:\nstb_phys(&address_space_memory, VAR_1, VAR_2);",
"break;",
"case 2:\nstw_phys(&address_space_memory, VAR_1, VAR_2);",
"break;",
"case 4:\nstl_phys(&address_space_memory, VAR_1, VAR_2);",
"break;",
"default: abort();",
"}",
"}"
] | [
1,
1,
0,
1,
0,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
25,138 | static void compute_rematrixing_strategy(AC3EncodeContext *s)
{
int nb_coefs;
int blk, bnd, i;
AC3Block *block, *av_uninit(block0);
if (s->channel_mode != AC3_CHMODE_STEREO)
return;
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
block = &s->blocks[blk];
block->new_rematrixing_strategy = !blk;
if (!s->rematrixing_enabled) {
block0 = block;
continue;
}
block->num_rematrixing_bands = 4;
if (block->cpl_in_use) {
block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61);
block->num_rematrixing_bands -= (s->start_freq[CPL_CH] == 37);
if (blk && block->num_rematrixing_bands != block0->num_rematrixing_bands)
block->new_rematrixing_strategy = 1;
}
nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]);
for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) {
/* calculate calculate sum of squared coeffs for one band in one block */
int start = ff_ac3_rematrix_band_tab[bnd];
int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
CoefSumType sum[4] = {0,};
for (i = start; i < end; i++) {
CoefType lt = block->mdct_coef[1][i];
CoefType rt = block->mdct_coef[2][i];
CoefType md = lt + rt;
CoefType sd = lt - rt;
MAC_COEF(sum[0], lt, lt);
MAC_COEF(sum[1], rt, rt);
MAC_COEF(sum[2], md, md);
MAC_COEF(sum[3], sd, sd);
}
/* compare sums to determine if rematrixing will be used for this band */
if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))
block->rematrixing_flags[bnd] = 1;
else
block->rematrixing_flags[bnd] = 0;
/* determine if new rematrixing flags will be sent */
if (blk &&
block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {
block->new_rematrixing_strategy = 1;
}
}
block0 = block;
}
}
| false | FFmpeg | f507a9fe002c6a444cbd38a1326ee4f9df8c10a1 | static void compute_rematrixing_strategy(AC3EncodeContext *s)
{
int nb_coefs;
int blk, bnd, i;
AC3Block *block, *av_uninit(block0);
if (s->channel_mode != AC3_CHMODE_STEREO)
return;
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
block = &s->blocks[blk];
block->new_rematrixing_strategy = !blk;
if (!s->rematrixing_enabled) {
block0 = block;
continue;
}
block->num_rematrixing_bands = 4;
if (block->cpl_in_use) {
block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61);
block->num_rematrixing_bands -= (s->start_freq[CPL_CH] == 37);
if (blk && block->num_rematrixing_bands != block0->num_rematrixing_bands)
block->new_rematrixing_strategy = 1;
}
nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]);
for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) {
int start = ff_ac3_rematrix_band_tab[bnd];
int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
CoefSumType sum[4] = {0,};
for (i = start; i < end; i++) {
CoefType lt = block->mdct_coef[1][i];
CoefType rt = block->mdct_coef[2][i];
CoefType md = lt + rt;
CoefType sd = lt - rt;
MAC_COEF(sum[0], lt, lt);
MAC_COEF(sum[1], rt, rt);
MAC_COEF(sum[2], md, md);
MAC_COEF(sum[3], sd, sd);
}
if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))
block->rematrixing_flags[bnd] = 1;
else
block->rematrixing_flags[bnd] = 0;
if (blk &&
block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {
block->new_rematrixing_strategy = 1;
}
}
block0 = block;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3EncodeContext *VAR_0)
{
int VAR_1;
int VAR_2, VAR_3, VAR_4;
AC3Block *block, *av_uninit(block0);
if (VAR_0->channel_mode != AC3_CHMODE_STEREO)
return;
for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) {
block = &VAR_0->blocks[VAR_2];
block->new_rematrixing_strategy = !VAR_2;
if (!VAR_0->rematrixing_enabled) {
block0 = block;
continue;
}
block->num_rematrixing_bands = 4;
if (block->cpl_in_use) {
block->num_rematrixing_bands -= (VAR_0->start_freq[CPL_CH] <= 61);
block->num_rematrixing_bands -= (VAR_0->start_freq[CPL_CH] == 37);
if (VAR_2 && block->num_rematrixing_bands != block0->num_rematrixing_bands)
block->new_rematrixing_strategy = 1;
}
VAR_1 = FFMIN(block->end_freq[1], block->end_freq[2]);
for (VAR_3 = 0; VAR_3 < block->num_rematrixing_bands; VAR_3++) {
int start = ff_ac3_rematrix_band_tab[VAR_3];
int end = FFMIN(VAR_1, ff_ac3_rematrix_band_tab[VAR_3+1]);
CoefSumType sum[4] = {0,};
for (VAR_4 = start; VAR_4 < end; VAR_4++) {
CoefType lt = block->mdct_coef[1][VAR_4];
CoefType rt = block->mdct_coef[2][VAR_4];
CoefType md = lt + rt;
CoefType sd = lt - rt;
MAC_COEF(sum[0], lt, lt);
MAC_COEF(sum[1], rt, rt);
MAC_COEF(sum[2], md, md);
MAC_COEF(sum[3], sd, sd);
}
if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))
block->rematrixing_flags[VAR_3] = 1;
else
block->rematrixing_flags[VAR_3] = 0;
if (VAR_2 &&
block->rematrixing_flags[VAR_3] != block0->rematrixing_flags[VAR_3]) {
block->new_rematrixing_strategy = 1;
}
}
block0 = block;
}
}
| [
"static void FUNC_0(AC3EncodeContext *VAR_0)\n{",
"int VAR_1;",
"int VAR_2, VAR_3, VAR_4;",
"AC3Block *block, *av_uninit(block0);",
"if (VAR_0->channel_mode != AC3_CHMODE_STEREO)\nreturn;",
"for (VAR_2 = 0; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) {",
"block = &VAR_0->blocks[VAR_2];",
"block->new_rematrixing_strategy = !VAR_2;",
"if (!VAR_0->rematrixing_enabled) {",
"block0 = block;",
"continue;",
"}",
"block->num_rematrixing_bands = 4;",
"if (block->cpl_in_use) {",
"block->num_rematrixing_bands -= (VAR_0->start_freq[CPL_CH] <= 61);",
"block->num_rematrixing_bands -= (VAR_0->start_freq[CPL_CH] == 37);",
"if (VAR_2 && block->num_rematrixing_bands != block0->num_rematrixing_bands)\nblock->new_rematrixing_strategy = 1;",
"}",
"VAR_1 = FFMIN(block->end_freq[1], block->end_freq[2]);",
"for (VAR_3 = 0; VAR_3 < block->num_rematrixing_bands; VAR_3++) {",
"int start = ff_ac3_rematrix_band_tab[VAR_3];",
"int end = FFMIN(VAR_1, ff_ac3_rematrix_band_tab[VAR_3+1]);",
"CoefSumType sum[4] = {0,};",
"for (VAR_4 = start; VAR_4 < end; VAR_4++) {",
"CoefType lt = block->mdct_coef[1][VAR_4];",
"CoefType rt = block->mdct_coef[2][VAR_4];",
"CoefType md = lt + rt;",
"CoefType sd = lt - rt;",
"MAC_COEF(sum[0], lt, lt);",
"MAC_COEF(sum[1], rt, rt);",
"MAC_COEF(sum[2], md, md);",
"MAC_COEF(sum[3], sd, sd);",
"}",
"if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))\nblock->rematrixing_flags[VAR_3] = 1;",
"else\nblock->rematrixing_flags[VAR_3] = 0;",
"if (VAR_2 &&\nblock->rematrixing_flags[VAR_3] != block0->rematrixing_flags[VAR_3]) {",
"block->new_rematrixing_strategy = 1;",
"}",
"}",
"block0 = block;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
89,
91
],
[
93,
95
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
] |
25,139 | long vnc_client_read_ws(VncState *vs)
{
int ret, err;
uint8_t *payload;
size_t payload_size, frame_size;
VNC_DEBUG("Read websocket %p size %zd offset %zd\n", vs->ws_input.buffer,
vs->ws_input.capacity, vs->ws_input.offset);
buffer_reserve(&vs->ws_input, 4096);
ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096);
if (!ret) {
return 0;
}
vs->ws_input.offset += ret;
/* make sure that nothing is left in the ws_input buffer */
do {
err = vncws_decode_frame(&vs->ws_input, &payload,
&payload_size, &frame_size);
if (err <= 0) {
return err;
}
buffer_reserve(&vs->input, payload_size);
buffer_append(&vs->input, payload, payload_size);
buffer_advance(&vs->ws_input, frame_size);
} while (vs->ws_input.offset > 0);
return ret;
}
| true | qemu | a2bebfd6e09d285aa793cae3fb0fc3a39a9fee6e | long vnc_client_read_ws(VncState *vs)
{
int ret, err;
uint8_t *payload;
size_t payload_size, frame_size;
VNC_DEBUG("Read websocket %p size %zd offset %zd\n", vs->ws_input.buffer,
vs->ws_input.capacity, vs->ws_input.offset);
buffer_reserve(&vs->ws_input, 4096);
ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096);
if (!ret) {
return 0;
}
vs->ws_input.offset += ret;
do {
err = vncws_decode_frame(&vs->ws_input, &payload,
&payload_size, &frame_size);
if (err <= 0) {
return err;
}
buffer_reserve(&vs->input, payload_size);
buffer_append(&vs->input, payload, payload_size);
buffer_advance(&vs->ws_input, frame_size);
} while (vs->ws_input.offset > 0);
return ret;
}
| {
"code": [
" size_t payload_size, frame_size;",
" err = vncws_decode_frame(&vs->ws_input, &payload,",
" &payload_size, &frame_size);",
" if (err <= 0) {",
" return err;",
" buffer_reserve(&vs->input, payload_size);",
" buffer_append(&vs->input, payload, payload_size);",
" buffer_advance(&vs->ws_input, frame_size);"
],
"line_no": [
9,
33,
35,
37,
39,
45,
47,
51
]
} | long FUNC_0(VncState *VAR_0)
{
int VAR_1, VAR_2;
uint8_t *payload;
size_t payload_size, frame_size;
VNC_DEBUG("Read websocket %p size %zd offset %zd\n", VAR_0->ws_input.buffer,
VAR_0->ws_input.capacity, VAR_0->ws_input.offset);
buffer_reserve(&VAR_0->ws_input, 4096);
VAR_1 = vnc_client_read_buf(VAR_0, buffer_end(&VAR_0->ws_input), 4096);
if (!VAR_1) {
return 0;
}
VAR_0->ws_input.offset += VAR_1;
do {
VAR_2 = vncws_decode_frame(&VAR_0->ws_input, &payload,
&payload_size, &frame_size);
if (VAR_2 <= 0) {
return VAR_2;
}
buffer_reserve(&VAR_0->input, payload_size);
buffer_append(&VAR_0->input, payload, payload_size);
buffer_advance(&VAR_0->ws_input, frame_size);
} while (VAR_0->ws_input.offset > 0);
return VAR_1;
}
| [
"long FUNC_0(VncState *VAR_0)\n{",
"int VAR_1, VAR_2;",
"uint8_t *payload;",
"size_t payload_size, frame_size;",
"VNC_DEBUG(\"Read websocket %p size %zd offset %zd\\n\", VAR_0->ws_input.buffer,\nVAR_0->ws_input.capacity, VAR_0->ws_input.offset);",
"buffer_reserve(&VAR_0->ws_input, 4096);",
"VAR_1 = vnc_client_read_buf(VAR_0, buffer_end(&VAR_0->ws_input), 4096);",
"if (!VAR_1) {",
"return 0;",
"}",
"VAR_0->ws_input.offset += VAR_1;",
"do {",
"VAR_2 = vncws_decode_frame(&VAR_0->ws_input, &payload,\n&payload_size, &frame_size);",
"if (VAR_2 <= 0) {",
"return VAR_2;",
"}",
"buffer_reserve(&VAR_0->input, payload_size);",
"buffer_append(&VAR_0->input, payload, payload_size);",
"buffer_advance(&VAR_0->ws_input, frame_size);",
"} while (VAR_0->ws_input.offset > 0);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
25,140 | int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
int16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred, scale;
int16_t *dc_val;
/* find prediction */
if (n < 4) {
scale = s->y_dc_scale;
} else {
scale = s->c_dc_scale;
}
wrap = s->block_wrap[n];
dc_val= s->dc_val[0] + s->block_index[n];
/* B C
* A X
*/
a = dc_val[ - 1];
b = dc_val[ - 1 - wrap];
c = dc_val[ - wrap];
if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
b=c=1024;
}
/* XXX: the following solution consumes divisions, but it does not
necessitate to modify mpegvideo.c. The problem comes from the
fact they decided to store the quantized DC (which would lead
to problems if Q could vary !) */
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
__asm__ volatile(
"movl %3, %%eax \n\t"
"shrl $1, %%eax \n\t"
"addl %%eax, %2 \n\t"
"addl %%eax, %1 \n\t"
"addl %0, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %0 \n\t"
"movl %1, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %1 \n\t"
"movl %2, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %2 \n\t"
: "+b" (a), "+c" (b), "+D" (c)
: "g" (scale), "S" (ff_inverse[scale])
: "%eax", "%edx"
);
#else
/* Divisions are costly everywhere; optimize the most common case. */
if (scale == 8) {
a = (a + (8 >> 1)) / 8;
b = (b + (8 >> 1)) / 8;
c = (c + (8 >> 1)) / 8;
} else {
a = FASTDIV((a + (scale >> 1)), scale);
b = FASTDIV((b + (scale >> 1)), scale);
c = FASTDIV((c + (scale >> 1)), scale);
}
#endif
/* XXX: WARNING: they did not choose the same test as MPEG4. This
is very important ! */
if(s->msmpeg4_version>3){
if(s->inter_intra_pred){
uint8_t *dest;
int wrap;
if(n==1){
pred=a;
*dir_ptr = 0;
}else if(n==2){
pred=c;
*dir_ptr = 1;
}else if(n==3){
if (abs(a - b) < abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}else{
if(n<4){
wrap= s->linesize;
dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
}else{
wrap= s->uvlinesize;
dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
}
if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
else a= get_dc(dest-8, wrap, scale*8);
if(s->mb_y==0) c= (1024 + (scale>>1))/scale;
else c= get_dc(dest-8*wrap, wrap, scale*8);
if (s->h263_aic_dir==0) {
pred= a;
*dir_ptr = 0;
}else if (s->h263_aic_dir==1) {
if(n==0){
pred= c;
*dir_ptr = 1;
}else{
pred= a;
*dir_ptr = 0;
}
}else if (s->h263_aic_dir==2) {
if(n==0){
pred= a;
*dir_ptr = 0;
}else{
pred= c;
*dir_ptr = 1;
}
} else {
pred= c;
*dir_ptr = 1;
}
}
}else{
if (abs(a - b) < abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}
}else{
if (abs(a - b) <= abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}
/* update predictor */
*dc_val_ptr = &dc_val[0];
return pred;
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
int16_t **dc_val_ptr, int *dir_ptr)
{
int a, b, c, wrap, pred, scale;
int16_t *dc_val;
if (n < 4) {
scale = s->y_dc_scale;
} else {
scale = s->c_dc_scale;
}
wrap = s->block_wrap[n];
dc_val= s->dc_val[0] + s->block_index[n];
a = dc_val[ - 1];
b = dc_val[ - 1 - wrap];
c = dc_val[ - wrap];
if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
b=c=1024;
}
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
__asm__ volatile(
"movl %3, %%eax \n\t"
"shrl $1, %%eax \n\t"
"addl %%eax, %2 \n\t"
"addl %%eax, %1 \n\t"
"addl %0, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %0 \n\t"
"movl %1, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %1 \n\t"
"movl %2, %%eax \n\t"
"mull %4 \n\t"
"movl %%edx, %2 \n\t"
: "+b" (a), "+c" (b), "+D" (c)
: "g" (scale), "S" (ff_inverse[scale])
: "%eax", "%edx"
);
#else
if (scale == 8) {
a = (a + (8 >> 1)) / 8;
b = (b + (8 >> 1)) / 8;
c = (c + (8 >> 1)) / 8;
} else {
a = FASTDIV((a + (scale >> 1)), scale);
b = FASTDIV((b + (scale >> 1)), scale);
c = FASTDIV((c + (scale >> 1)), scale);
}
#endif
if(s->msmpeg4_version>3){
if(s->inter_intra_pred){
uint8_t *dest;
int wrap;
if(n==1){
pred=a;
*dir_ptr = 0;
}else if(n==2){
pred=c;
*dir_ptr = 1;
}else if(n==3){
if (abs(a - b) < abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}else{
if(n<4){
wrap= s->linesize;
dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
}else{
wrap= s->uvlinesize;
dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
}
if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
else a= get_dc(dest-8, wrap, scale*8);
if(s->mb_y==0) c= (1024 + (scale>>1))/scale;
else c= get_dc(dest-8*wrap, wrap, scale*8);
if (s->h263_aic_dir==0) {
pred= a;
*dir_ptr = 0;
}else if (s->h263_aic_dir==1) {
if(n==0){
pred= c;
*dir_ptr = 1;
}else{
pred= a;
*dir_ptr = 0;
}
}else if (s->h263_aic_dir==2) {
if(n==0){
pred= a;
*dir_ptr = 0;
}else{
pred= c;
*dir_ptr = 1;
}
} else {
pred= c;
*dir_ptr = 1;
}
}
}else{
if (abs(a - b) < abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}
}else{
if (abs(a - b) <= abs(b - c)) {
pred = c;
*dir_ptr = 1;
} else {
pred = a;
*dir_ptr = 0;
}
}
*dc_val_ptr = &dc_val[0];
return pred;
}
| {
"code": [
" dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;",
" dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;"
],
"line_no": [
173,
179
]
} | int FUNC_0(MpegEncContext *VAR_0, int VAR_1,
int16_t **VAR_2, int *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_10, VAR_8, VAR_9;
int16_t *dc_val;
if (VAR_1 < 4) {
VAR_9 = VAR_0->y_dc_scale;
} else {
VAR_9 = VAR_0->c_dc_scale;
}
VAR_10 = VAR_0->block_wrap[VAR_1];
dc_val= VAR_0->dc_val[0] + VAR_0->block_index[VAR_1];
VAR_4 = dc_val[ - 1];
VAR_5 = dc_val[ - 1 - VAR_10];
VAR_6 = dc_val[ - VAR_10];
if(VAR_0->first_slice_line && (VAR_1&2)==0 && VAR_0->msmpeg4_version<4){
VAR_5=VAR_6=1024;
}
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
__asm__ volatile(
"movl %3, %%eax \VAR_1\t"
"shrl $1, %%eax \VAR_1\t"
"addl %%eax, %2 \VAR_1\t"
"addl %%eax, %1 \VAR_1\t"
"addl %0, %%eax \VAR_1\t"
"mull %4 \VAR_1\t"
"movl %%edx, %0 \VAR_1\t"
"movl %1, %%eax \VAR_1\t"
"mull %4 \VAR_1\t"
"movl %%edx, %1 \VAR_1\t"
"movl %2, %%eax \VAR_1\t"
"mull %4 \VAR_1\t"
"movl %%edx, %2 \VAR_1\t"
: "+VAR_5" (VAR_4), "+VAR_6" (VAR_5), "+D" (VAR_6)
: "g" (VAR_9), "S" (ff_inverse[VAR_9])
: "%eax", "%edx"
);
#else
if (VAR_9 == 8) {
VAR_4 = (VAR_4 + (8 >> 1)) / 8;
VAR_5 = (VAR_5 + (8 >> 1)) / 8;
VAR_6 = (VAR_6 + (8 >> 1)) / 8;
} else {
VAR_4 = FASTDIV((VAR_4 + (VAR_9 >> 1)), VAR_9);
VAR_5 = FASTDIV((VAR_5 + (VAR_9 >> 1)), VAR_9);
VAR_6 = FASTDIV((VAR_6 + (VAR_9 >> 1)), VAR_9);
}
#endif
if(VAR_0->msmpeg4_version>3){
if(VAR_0->inter_intra_pred){
uint8_t *dest;
int VAR_10;
if(VAR_1==1){
VAR_8=VAR_4;
*VAR_3 = 0;
}else if(VAR_1==2){
VAR_8=VAR_6;
*VAR_3 = 1;
}else if(VAR_1==3){
if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {
VAR_8 = VAR_6;
*VAR_3 = 1;
} else {
VAR_8 = VAR_4;
*VAR_3 = 0;
}
}else{
if(VAR_1<4){
VAR_10= VAR_0->linesize;
dest= VAR_0->current_picture.f.data[0] + (((VAR_1 >> 1) + 2*VAR_0->mb_y) * 8* VAR_10 ) + ((VAR_1 & 1) + 2*VAR_0->mb_x) * 8;
}else{
VAR_10= VAR_0->uvlinesize;
dest= VAR_0->current_picture.f.data[VAR_1 - 3] + (VAR_0->mb_y * 8 * VAR_10) + VAR_0->mb_x * 8;
}
if(VAR_0->mb_x==0) VAR_4= (1024 + (VAR_9>>1))/VAR_9;
else VAR_4= get_dc(dest-8, VAR_10, VAR_9*8);
if(VAR_0->mb_y==0) VAR_6= (1024 + (VAR_9>>1))/VAR_9;
else VAR_6= get_dc(dest-8*VAR_10, VAR_10, VAR_9*8);
if (VAR_0->h263_aic_dir==0) {
VAR_8= VAR_4;
*VAR_3 = 0;
}else if (VAR_0->h263_aic_dir==1) {
if(VAR_1==0){
VAR_8= VAR_6;
*VAR_3 = 1;
}else{
VAR_8= VAR_4;
*VAR_3 = 0;
}
}else if (VAR_0->h263_aic_dir==2) {
if(VAR_1==0){
VAR_8= VAR_4;
*VAR_3 = 0;
}else{
VAR_8= VAR_6;
*VAR_3 = 1;
}
} else {
VAR_8= VAR_6;
*VAR_3 = 1;
}
}
}else{
if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {
VAR_8 = VAR_6;
*VAR_3 = 1;
} else {
VAR_8 = VAR_4;
*VAR_3 = 0;
}
}
}else{
if (abs(VAR_4 - VAR_5) <= abs(VAR_5 - VAR_6)) {
VAR_8 = VAR_6;
*VAR_3 = 1;
} else {
VAR_8 = VAR_4;
*VAR_3 = 0;
}
}
*VAR_2 = &dc_val[0];
return VAR_8;
}
| [
"int FUNC_0(MpegEncContext *VAR_0, int VAR_1,\nint16_t **VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_10, VAR_8, VAR_9;",
"int16_t *dc_val;",
"if (VAR_1 < 4) {",
"VAR_9 = VAR_0->y_dc_scale;",
"} else {",
"VAR_9 = VAR_0->c_dc_scale;",
"}",
"VAR_10 = VAR_0->block_wrap[VAR_1];",
"dc_val= VAR_0->dc_val[0] + VAR_0->block_index[VAR_1];",
"VAR_4 = dc_val[ - 1];",
"VAR_5 = dc_val[ - 1 - VAR_10];",
"VAR_6 = dc_val[ - VAR_10];",
"if(VAR_0->first_slice_line && (VAR_1&2)==0 && VAR_0->msmpeg4_version<4){",
"VAR_5=VAR_6=1024;",
"}",
"#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE\n__asm__ volatile(\n\"movl %3, %%eax \\VAR_1\\t\"\n\"shrl $1, %%eax \\VAR_1\\t\"\n\"addl %%eax, %2 \\VAR_1\\t\"\n\"addl %%eax, %1 \\VAR_1\\t\"\n\"addl %0, %%eax \\VAR_1\\t\"\n\"mull %4 \\VAR_1\\t\"\n\"movl %%edx, %0 \\VAR_1\\t\"\n\"movl %1, %%eax \\VAR_1\\t\"\n\"mull %4 \\VAR_1\\t\"\n\"movl %%edx, %1 \\VAR_1\\t\"\n\"movl %2, %%eax \\VAR_1\\t\"\n\"mull %4 \\VAR_1\\t\"\n\"movl %%edx, %2 \\VAR_1\\t\"\n: \"+VAR_5\" (VAR_4), \"+VAR_6\" (VAR_5), \"+D\" (VAR_6)\n: \"g\" (VAR_9), \"S\" (ff_inverse[VAR_9])\n: \"%eax\", \"%edx\"\n);",
"#else\nif (VAR_9 == 8) {",
"VAR_4 = (VAR_4 + (8 >> 1)) / 8;",
"VAR_5 = (VAR_5 + (8 >> 1)) / 8;",
"VAR_6 = (VAR_6 + (8 >> 1)) / 8;",
"} else {",
"VAR_4 = FASTDIV((VAR_4 + (VAR_9 >> 1)), VAR_9);",
"VAR_5 = FASTDIV((VAR_5 + (VAR_9 >> 1)), VAR_9);",
"VAR_6 = FASTDIV((VAR_6 + (VAR_9 >> 1)), VAR_9);",
"}",
"#endif\nif(VAR_0->msmpeg4_version>3){",
"if(VAR_0->inter_intra_pred){",
"uint8_t *dest;",
"int VAR_10;",
"if(VAR_1==1){",
"VAR_8=VAR_4;",
"*VAR_3 = 0;",
"}else if(VAR_1==2){",
"VAR_8=VAR_6;",
"*VAR_3 = 1;",
"}else if(VAR_1==3){",
"if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {",
"VAR_8 = VAR_6;",
"*VAR_3 = 1;",
"} else {",
"VAR_8 = VAR_4;",
"*VAR_3 = 0;",
"}",
"}else{",
"if(VAR_1<4){",
"VAR_10= VAR_0->linesize;",
"dest= VAR_0->current_picture.f.data[0] + (((VAR_1 >> 1) + 2*VAR_0->mb_y) * 8* VAR_10 ) + ((VAR_1 & 1) + 2*VAR_0->mb_x) * 8;",
"}else{",
"VAR_10= VAR_0->uvlinesize;",
"dest= VAR_0->current_picture.f.data[VAR_1 - 3] + (VAR_0->mb_y * 8 * VAR_10) + VAR_0->mb_x * 8;",
"}",
"if(VAR_0->mb_x==0) VAR_4= (1024 + (VAR_9>>1))/VAR_9;",
"else VAR_4= get_dc(dest-8, VAR_10, VAR_9*8);",
"if(VAR_0->mb_y==0) VAR_6= (1024 + (VAR_9>>1))/VAR_9;",
"else VAR_6= get_dc(dest-8*VAR_10, VAR_10, VAR_9*8);",
"if (VAR_0->h263_aic_dir==0) {",
"VAR_8= VAR_4;",
"*VAR_3 = 0;",
"}else if (VAR_0->h263_aic_dir==1) {",
"if(VAR_1==0){",
"VAR_8= VAR_6;",
"*VAR_3 = 1;",
"}else{",
"VAR_8= VAR_4;",
"*VAR_3 = 0;",
"}",
"}else if (VAR_0->h263_aic_dir==2) {",
"if(VAR_1==0){",
"VAR_8= VAR_4;",
"*VAR_3 = 0;",
"}else{",
"VAR_8= VAR_6;",
"*VAR_3 = 1;",
"}",
"} else {",
"VAR_8= VAR_6;",
"*VAR_3 = 1;",
"}",
"}",
"}else{",
"if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {",
"VAR_8 = VAR_6;",
"*VAR_3 = 1;",
"} else {",
"VAR_8 = VAR_4;",
"*VAR_3 = 0;",
"}",
"}",
"}else{",
"if (abs(VAR_4 - VAR_5) <= abs(VAR_5 - VAR_6)) {",
"VAR_8 = VAR_6;",
"*VAR_3 = 1;",
"} else {",
"VAR_8 = VAR_4;",
"*VAR_3 = 0;",
"}",
"}",
"*VAR_2 = &dc_val[0];",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99
],
[
101,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
129
],
[
131
],
[
133
],
[
135
],
[
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
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
281
],
[
283
],
[
285
]
] |
25,141 | int url_open(URLContext **puc, const char *filename, int flags)
{
URLProtocol *up;
const char *p;
char proto_str[128], *q;
p = filename;
q = proto_str;
while (*p != '\0' && *p != ':') {
/* protocols can only contain alphabetic chars */
if (!isalpha(*p))
goto file_proto;
if ((q - proto_str) < sizeof(proto_str) - 1)
*q++ = *p;
p++;
}
/* if the protocol has length 1, we consider it is a dos drive */
if (*p == '\0' || (q - proto_str) <= 1) {
file_proto:
strcpy(proto_str, "file");
} else {
*q = '\0';
}
up = first_protocol;
while (up != NULL) {
if (!strcmp(proto_str, up->name))
return url_open_protocol (puc, up, filename, flags);
up = up->next;
}
*puc = NULL;
return AVERROR(ENOENT);
}
| true | FFmpeg | bc574408dc011943b82de012451f95266bed9989 | int url_open(URLContext **puc, const char *filename, int flags)
{
URLProtocol *up;
const char *p;
char proto_str[128], *q;
p = filename;
q = proto_str;
while (*p != '\0' && *p != ':') {
if (!isalpha(*p))
goto file_proto;
if ((q - proto_str) < sizeof(proto_str) - 1)
*q++ = *p;
p++;
}
if (*p == '\0' || (q - proto_str) <= 1) {
file_proto:
strcpy(proto_str, "file");
} else {
*q = '\0';
}
up = first_protocol;
while (up != NULL) {
if (!strcmp(proto_str, up->name))
return url_open_protocol (puc, up, filename, flags);
up = up->next;
}
*puc = NULL;
return AVERROR(ENOENT);
}
| {
"code": [
" if (*p == '\\0' || (q - proto_str) <= 1) {"
],
"line_no": [
35
]
} | int FUNC_0(URLContext **VAR_0, const char *VAR_1, int VAR_2)
{
URLProtocol *up;
const char *VAR_3;
char VAR_4[128], *VAR_5;
VAR_3 = VAR_1;
VAR_5 = VAR_4;
while (*VAR_3 != '\0' && *VAR_3 != ':') {
if (!isalpha(*VAR_3))
goto file_proto;
if ((VAR_5 - VAR_4) < sizeof(VAR_4) - 1)
*VAR_5++ = *VAR_3;
VAR_3++;
}
if (*VAR_3 == '\0' || (VAR_5 - VAR_4) <= 1) {
file_proto:
strcpy(VAR_4, "file");
} else {
*VAR_5 = '\0';
}
up = first_protocol;
while (up != NULL) {
if (!strcmp(VAR_4, up->name))
return url_open_protocol (VAR_0, up, VAR_1, VAR_2);
up = up->next;
}
*VAR_0 = NULL;
return AVERROR(ENOENT);
}
| [
"int FUNC_0(URLContext **VAR_0, const char *VAR_1, int VAR_2)\n{",
"URLProtocol *up;",
"const char *VAR_3;",
"char VAR_4[128], *VAR_5;",
"VAR_3 = VAR_1;",
"VAR_5 = VAR_4;",
"while (*VAR_3 != '\\0' && *VAR_3 != ':') {",
"if (!isalpha(*VAR_3))\ngoto file_proto;",
"if ((VAR_5 - VAR_4) < sizeof(VAR_4) - 1)\n*VAR_5++ = *VAR_3;",
"VAR_3++;",
"}",
"if (*VAR_3 == '\\0' || (VAR_5 - VAR_4) <= 1) {",
"file_proto:\nstrcpy(VAR_4, \"file\");",
"} else {",
"*VAR_5 = '\\0';",
"}",
"up = first_protocol;",
"while (up != NULL) {",
"if (!strcmp(VAR_4, up->name))\nreturn url_open_protocol (VAR_0, up, VAR_1, VAR_2);",
"up = up->next;",
"}",
"*VAR_0 = NULL;",
"return AVERROR(ENOENT);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
25,142 | static void gen_mfsrin_64b(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
t0 = tcg_temp_new();
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
tcg_gen_andi_tl(t0, t0, 0xF);
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_mfsrin_64b(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
return;
}
t0 = tcg_temp_new();
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
tcg_gen_andi_tl(t0, t0, 0xF);
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
#endif
}
| {
"code": [
" if (unlikely(ctx->pr)) {",
" if (unlikely(ctx->pr)) {",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif"
],
"line_no": [
13,
13,
5,
7,
9,
13,
15,
31,
5,
7,
9,
13,
15,
31,
31,
5,
7,
9,
13,
15,
13,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
31,
13,
31,
31,
31,
13,
31,
13,
31,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
7,
13,
15,
31,
5,
9,
13,
31,
13,
31,
5,
9,
13,
31,
5,
9,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
5,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31,
13,
31
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);
#else
TCGv t0;
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);
return;
}
t0 = tcg_temp_new();
tcg_gen_shri_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 28);
tcg_gen_andi_tl(t0, t0, 0xF);
gen_helper_load_sr(cpu_gpr[rD(VAR_0->opcode)], cpu_env, t0);
tcg_temp_free(t0);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);",
"#else\nTCGv t0;",
"if (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);",
"return;",
"}",
"t0 = tcg_temp_new();",
"tcg_gen_shri_tl(t0, cpu_gpr[rB(VAR_0->opcode)], 28);",
"tcg_gen_andi_tl(t0, t0, 0xF);",
"gen_helper_load_sr(cpu_gpr[rD(VAR_0->opcode)], cpu_env, t0);",
"tcg_temp_free(t0);",
"#endif\n}"
] | [
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
1
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
]
] |
25,143 | struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
int dstW, int dstH, int dstFormat,
int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, double *param)
{
struct SwsContext *ctx;
ctx = av_malloc(sizeof(struct SwsContext));
if (ctx)
ctx->av_class = av_mallocz(sizeof(AVClass));
if (!ctx || !ctx->av_class) {
av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n");
return NULL;
}
if ((srcH != dstH) || (srcW != dstW)) {
if ((srcFormat != PIX_FMT_YUV420P) || (dstFormat != PIX_FMT_YUV420P)) {
av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n");
}
ctx->resampling_ctx = img_resample_init(dstW, dstH, srcW, srcH);
} else {
ctx->resampling_ctx = av_malloc(sizeof(ImgReSampleContext));
ctx->resampling_ctx->iheight = srcH;
ctx->resampling_ctx->iwidth = srcW;
ctx->resampling_ctx->oheight = dstH;
ctx->resampling_ctx->owidth = dstW;
}
ctx->src_pix_fmt = srcFormat;
ctx->dst_pix_fmt = dstFormat;
return ctx;
}
| true | FFmpeg | f15e6b869fc1ff3ffef1b1ac7b394e2155b5fafe | struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
int dstW, int dstH, int dstFormat,
int flags, SwsFilter *srcFilter,
SwsFilter *dstFilter, double *param)
{
struct SwsContext *ctx;
ctx = av_malloc(sizeof(struct SwsContext));
if (ctx)
ctx->av_class = av_mallocz(sizeof(AVClass));
if (!ctx || !ctx->av_class) {
av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n");
return NULL;
}
if ((srcH != dstH) || (srcW != dstW)) {
if ((srcFormat != PIX_FMT_YUV420P) || (dstFormat != PIX_FMT_YUV420P)) {
av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n");
}
ctx->resampling_ctx = img_resample_init(dstW, dstH, srcW, srcH);
} else {
ctx->resampling_ctx = av_malloc(sizeof(ImgReSampleContext));
ctx->resampling_ctx->iheight = srcH;
ctx->resampling_ctx->iwidth = srcW;
ctx->resampling_ctx->oheight = dstH;
ctx->resampling_ctx->owidth = dstW;
}
ctx->src_pix_fmt = srcFormat;
ctx->dst_pix_fmt = dstFormat;
return ctx;
}
| {
"code": [
" if (ctx)",
" ctx->av_class = av_mallocz(sizeof(AVClass));",
" if (!ctx || !ctx->av_class) {"
],
"line_no": [
17,
19,
21
]
} | struct SwsContext *FUNC_0(int VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5,
int VAR_6, SwsFilter *VAR_7,
SwsFilter *VAR_8, double *VAR_9)
{
struct SwsContext *VAR_10;
VAR_10 = av_malloc(sizeof(struct SwsContext));
if (VAR_10)
VAR_10->av_class = av_mallocz(sizeof(AVClass));
if (!VAR_10 || !VAR_10->av_class) {
av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n");
return NULL;
}
if ((VAR_1 != VAR_4) || (VAR_0 != VAR_3)) {
if ((VAR_2 != PIX_FMT_YUV420P) || (VAR_5 != PIX_FMT_YUV420P)) {
av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n");
}
VAR_10->resampling_ctx = img_resample_init(VAR_3, VAR_4, VAR_0, VAR_1);
} else {
VAR_10->resampling_ctx = av_malloc(sizeof(ImgReSampleContext));
VAR_10->resampling_ctx->iheight = VAR_1;
VAR_10->resampling_ctx->iwidth = VAR_0;
VAR_10->resampling_ctx->oheight = VAR_4;
VAR_10->resampling_ctx->owidth = VAR_3;
}
VAR_10->src_pix_fmt = VAR_2;
VAR_10->dst_pix_fmt = VAR_5;
return VAR_10;
}
| [
"struct SwsContext *FUNC_0(int VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5,\nint VAR_6, SwsFilter *VAR_7,\nSwsFilter *VAR_8, double *VAR_9)\n{",
"struct SwsContext *VAR_10;",
"VAR_10 = av_malloc(sizeof(struct SwsContext));",
"if (VAR_10)\nVAR_10->av_class = av_mallocz(sizeof(AVClass));",
"if (!VAR_10 || !VAR_10->av_class) {",
"av_log(NULL, AV_LOG_ERROR, \"Cannot allocate a resampling context!\\n\");",
"return NULL;",
"}",
"if ((VAR_1 != VAR_4) || (VAR_0 != VAR_3)) {",
"if ((VAR_2 != PIX_FMT_YUV420P) || (VAR_5 != PIX_FMT_YUV420P)) {",
"av_log(NULL, AV_LOG_INFO, \"PIX_FMT_YUV420P will be used as an intermediate format for rescaling\\n\");",
"}",
"VAR_10->resampling_ctx = img_resample_init(VAR_3, VAR_4, VAR_0, VAR_1);",
"} else {",
"VAR_10->resampling_ctx = av_malloc(sizeof(ImgReSampleContext));",
"VAR_10->resampling_ctx->iheight = VAR_1;",
"VAR_10->resampling_ctx->iwidth = VAR_0;",
"VAR_10->resampling_ctx->oheight = VAR_4;",
"VAR_10->resampling_ctx->owidth = VAR_3;",
"}",
"VAR_10->src_pix_fmt = VAR_2;",
"VAR_10->dst_pix_fmt = VAR_5;",
"return VAR_10;",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
]
] |
25,144 | static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
VP8Context *ctx = avctx->priv_data;
struct vpx_image *rawimg = NULL;
struct vpx_image *rawimg_alpha = NULL;
int64_t timestamp = 0;
int res, coded_size;
vpx_enc_frame_flags_t flags = 0;
if (frame) {
rawimg = &ctx->rawimg;
rawimg->planes[VPX_PLANE_Y] = frame->data[0];
rawimg->planes[VPX_PLANE_U] = frame->data[1];
rawimg->planes[VPX_PLANE_V] = frame->data[2];
rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
if (ctx->is_alpha) {
uint8_t *u_plane, *v_plane;
rawimg_alpha = &ctx->rawimg_alpha;
rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3];
u_plane = av_malloc(frame->linesize[1] * frame->height);
memset(u_plane, 0x80, frame->linesize[1] * frame->height);
rawimg_alpha->planes[VPX_PLANE_U] = u_plane;
v_plane = av_malloc(frame->linesize[2] * frame->height);
memset(v_plane, 0x80, frame->linesize[2] * frame->height);
rawimg_alpha->planes[VPX_PLANE_V] = v_plane;
rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];
rawimg_alpha->stride[VPX_PLANE_U] = frame->linesize[1];
rawimg_alpha->stride[VPX_PLANE_V] = frame->linesize[2];
}
timestamp = frame->pts;
if (frame->pict_type == AV_PICTURE_TYPE_I)
flags |= VPX_EFLAG_FORCE_KF;
}
res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
avctx->ticks_per_frame, flags, ctx->deadline);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Error encoding frame");
return AVERROR_INVALIDDATA;
}
if (ctx->is_alpha) {
res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp,
avctx->ticks_per_frame, flags, ctx->deadline);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Error encoding alpha frame");
return AVERROR_INVALIDDATA;
}
}
coded_size = queue_frames(avctx, pkt, avctx->coded_frame);
if (!frame && avctx->flags & CODEC_FLAG_PASS1) {
unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
avctx->stats_out = av_malloc(b64_size);
if (!avctx->stats_out) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n",
b64_size);
return AVERROR(ENOMEM);
}
av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
ctx->twopass_stats.sz);
}
if (rawimg_alpha) {
av_freep(&rawimg_alpha->planes[VPX_PLANE_U]);
av_freep(&rawimg_alpha->planes[VPX_PLANE_V]);
}
*got_packet = !!coded_size;
return 0;
}
| true | FFmpeg | 21518f5a0a6b644d1dedda5650c15bc3df62a567 | static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
VP8Context *ctx = avctx->priv_data;
struct vpx_image *rawimg = NULL;
struct vpx_image *rawimg_alpha = NULL;
int64_t timestamp = 0;
int res, coded_size;
vpx_enc_frame_flags_t flags = 0;
if (frame) {
rawimg = &ctx->rawimg;
rawimg->planes[VPX_PLANE_Y] = frame->data[0];
rawimg->planes[VPX_PLANE_U] = frame->data[1];
rawimg->planes[VPX_PLANE_V] = frame->data[2];
rawimg->stride[VPX_PLANE_Y] = frame->linesize[0];
rawimg->stride[VPX_PLANE_U] = frame->linesize[1];
rawimg->stride[VPX_PLANE_V] = frame->linesize[2];
if (ctx->is_alpha) {
uint8_t *u_plane, *v_plane;
rawimg_alpha = &ctx->rawimg_alpha;
rawimg_alpha->planes[VPX_PLANE_Y] = frame->data[3];
u_plane = av_malloc(frame->linesize[1] * frame->height);
memset(u_plane, 0x80, frame->linesize[1] * frame->height);
rawimg_alpha->planes[VPX_PLANE_U] = u_plane;
v_plane = av_malloc(frame->linesize[2] * frame->height);
memset(v_plane, 0x80, frame->linesize[2] * frame->height);
rawimg_alpha->planes[VPX_PLANE_V] = v_plane;
rawimg_alpha->stride[VPX_PLANE_Y] = frame->linesize[0];
rawimg_alpha->stride[VPX_PLANE_U] = frame->linesize[1];
rawimg_alpha->stride[VPX_PLANE_V] = frame->linesize[2];
}
timestamp = frame->pts;
if (frame->pict_type == AV_PICTURE_TYPE_I)
flags |= VPX_EFLAG_FORCE_KF;
}
res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
avctx->ticks_per_frame, flags, ctx->deadline);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Error encoding frame");
return AVERROR_INVALIDDATA;
}
if (ctx->is_alpha) {
res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp,
avctx->ticks_per_frame, flags, ctx->deadline);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Error encoding alpha frame");
return AVERROR_INVALIDDATA;
}
}
coded_size = queue_frames(avctx, pkt, avctx->coded_frame);
if (!frame && avctx->flags & CODEC_FLAG_PASS1) {
unsigned int b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz);
avctx->stats_out = av_malloc(b64_size);
if (!avctx->stats_out) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n",
b64_size);
return AVERROR(ENOMEM);
}
av_base64_encode(avctx->stats_out, b64_size, ctx->twopass_stats.buf,
ctx->twopass_stats.sz);
}
if (rawimg_alpha) {
av_freep(&rawimg_alpha->planes[VPX_PLANE_U]);
av_freep(&rawimg_alpha->planes[VPX_PLANE_V]);
}
*got_packet = !!coded_size;
return 0;
}
| {
"code": [
" v_plane = av_malloc(frame->linesize[2] * frame->height);"
],
"line_no": [
51
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
VP8Context *ctx = VAR_0->priv_data;
struct vpx_image *VAR_4 = NULL;
struct vpx_image *VAR_5 = NULL;
int64_t timestamp = 0;
int VAR_6, VAR_7;
vpx_enc_frame_flags_t flags = 0;
if (VAR_2) {
VAR_4 = &ctx->VAR_4;
VAR_4->planes[VPX_PLANE_Y] = VAR_2->data[0];
VAR_4->planes[VPX_PLANE_U] = VAR_2->data[1];
VAR_4->planes[VPX_PLANE_V] = VAR_2->data[2];
VAR_4->stride[VPX_PLANE_Y] = VAR_2->linesize[0];
VAR_4->stride[VPX_PLANE_U] = VAR_2->linesize[1];
VAR_4->stride[VPX_PLANE_V] = VAR_2->linesize[2];
if (ctx->is_alpha) {
uint8_t *u_plane, *v_plane;
VAR_5 = &ctx->VAR_5;
VAR_5->planes[VPX_PLANE_Y] = VAR_2->data[3];
u_plane = av_malloc(VAR_2->linesize[1] * VAR_2->height);
memset(u_plane, 0x80, VAR_2->linesize[1] * VAR_2->height);
VAR_5->planes[VPX_PLANE_U] = u_plane;
v_plane = av_malloc(VAR_2->linesize[2] * VAR_2->height);
memset(v_plane, 0x80, VAR_2->linesize[2] * VAR_2->height);
VAR_5->planes[VPX_PLANE_V] = v_plane;
VAR_5->stride[VPX_PLANE_Y] = VAR_2->linesize[0];
VAR_5->stride[VPX_PLANE_U] = VAR_2->linesize[1];
VAR_5->stride[VPX_PLANE_V] = VAR_2->linesize[2];
}
timestamp = VAR_2->pts;
if (VAR_2->pict_type == AV_PICTURE_TYPE_I)
flags |= VPX_EFLAG_FORCE_KF;
}
VAR_6 = vpx_codec_encode(&ctx->encoder, VAR_4, timestamp,
VAR_0->ticks_per_frame, flags, ctx->deadline);
if (VAR_6 != VPX_CODEC_OK) {
log_encoder_error(VAR_0, "Error encoding VAR_2");
return AVERROR_INVALIDDATA;
}
if (ctx->is_alpha) {
VAR_6 = vpx_codec_encode(&ctx->encoder_alpha, VAR_5, timestamp,
VAR_0->ticks_per_frame, flags, ctx->deadline);
if (VAR_6 != VPX_CODEC_OK) {
log_encoder_error(VAR_0, "Error encoding alpha VAR_2");
return AVERROR_INVALIDDATA;
}
}
VAR_7 = queue_frames(VAR_0, VAR_1, VAR_0->coded_frame);
if (!VAR_2 && VAR_0->flags & CODEC_FLAG_PASS1) {
unsigned int VAR_8 = AV_BASE64_SIZE(ctx->twopass_stats.sz);
VAR_0->stats_out = av_malloc(VAR_8);
if (!VAR_0->stats_out) {
av_log(VAR_0, AV_LOG_ERROR, "Stat buffer alloc (%d bytes) failed\n",
VAR_8);
return AVERROR(ENOMEM);
}
av_base64_encode(VAR_0->stats_out, VAR_8, ctx->twopass_stats.buf,
ctx->twopass_stats.sz);
}
if (VAR_5) {
av_freep(&VAR_5->planes[VPX_PLANE_U]);
av_freep(&VAR_5->planes[VPX_PLANE_V]);
}
*VAR_3 = !!VAR_7;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"VP8Context *ctx = VAR_0->priv_data;",
"struct vpx_image *VAR_4 = NULL;",
"struct vpx_image *VAR_5 = NULL;",
"int64_t timestamp = 0;",
"int VAR_6, VAR_7;",
"vpx_enc_frame_flags_t flags = 0;",
"if (VAR_2) {",
"VAR_4 = &ctx->VAR_4;",
"VAR_4->planes[VPX_PLANE_Y] = VAR_2->data[0];",
"VAR_4->planes[VPX_PLANE_U] = VAR_2->data[1];",
"VAR_4->planes[VPX_PLANE_V] = VAR_2->data[2];",
"VAR_4->stride[VPX_PLANE_Y] = VAR_2->linesize[0];",
"VAR_4->stride[VPX_PLANE_U] = VAR_2->linesize[1];",
"VAR_4->stride[VPX_PLANE_V] = VAR_2->linesize[2];",
"if (ctx->is_alpha) {",
"uint8_t *u_plane, *v_plane;",
"VAR_5 = &ctx->VAR_5;",
"VAR_5->planes[VPX_PLANE_Y] = VAR_2->data[3];",
"u_plane = av_malloc(VAR_2->linesize[1] * VAR_2->height);",
"memset(u_plane, 0x80, VAR_2->linesize[1] * VAR_2->height);",
"VAR_5->planes[VPX_PLANE_U] = u_plane;",
"v_plane = av_malloc(VAR_2->linesize[2] * VAR_2->height);",
"memset(v_plane, 0x80, VAR_2->linesize[2] * VAR_2->height);",
"VAR_5->planes[VPX_PLANE_V] = v_plane;",
"VAR_5->stride[VPX_PLANE_Y] = VAR_2->linesize[0];",
"VAR_5->stride[VPX_PLANE_U] = VAR_2->linesize[1];",
"VAR_5->stride[VPX_PLANE_V] = VAR_2->linesize[2];",
"}",
"timestamp = VAR_2->pts;",
"if (VAR_2->pict_type == AV_PICTURE_TYPE_I)\nflags |= VPX_EFLAG_FORCE_KF;",
"}",
"VAR_6 = vpx_codec_encode(&ctx->encoder, VAR_4, timestamp,\nVAR_0->ticks_per_frame, flags, ctx->deadline);",
"if (VAR_6 != VPX_CODEC_OK) {",
"log_encoder_error(VAR_0, \"Error encoding VAR_2\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (ctx->is_alpha) {",
"VAR_6 = vpx_codec_encode(&ctx->encoder_alpha, VAR_5, timestamp,\nVAR_0->ticks_per_frame, flags, ctx->deadline);",
"if (VAR_6 != VPX_CODEC_OK) {",
"log_encoder_error(VAR_0, \"Error encoding alpha VAR_2\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"VAR_7 = queue_frames(VAR_0, VAR_1, VAR_0->coded_frame);",
"if (!VAR_2 && VAR_0->flags & CODEC_FLAG_PASS1) {",
"unsigned int VAR_8 = AV_BASE64_SIZE(ctx->twopass_stats.sz);",
"VAR_0->stats_out = av_malloc(VAR_8);",
"if (!VAR_0->stats_out) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Stat buffer alloc (%d bytes) failed\\n\",\nVAR_8);",
"return AVERROR(ENOMEM);",
"}",
"av_base64_encode(VAR_0->stats_out, VAR_8, ctx->twopass_stats.buf,\nctx->twopass_stats.sz);",
"}",
"if (VAR_5) {",
"av_freep(&VAR_5->planes[VPX_PLANE_U]);",
"av_freep(&VAR_5->planes[VPX_PLANE_V]);",
"}",
"*VAR_3 = !!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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
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
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
]
] |
25,145 | void av_opt_freep_ranges(AVOptionRanges **rangesp)
{
int i;
AVOptionRanges *ranges = *rangesp;
if (!ranges)
return;
for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) {
AVOptionRange *range = ranges->range[i];
av_freep(&range->str);
av_freep(&ranges->range[i]);
}
av_freep(&ranges->range);
av_freep(rangesp);
}
| true | FFmpeg | 3aac5fcfa9d3748659d78ab2a66d0ccce22cfd4f | void av_opt_freep_ranges(AVOptionRanges **rangesp)
{
int i;
AVOptionRanges *ranges = *rangesp;
if (!ranges)
return;
for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) {
AVOptionRange *range = ranges->range[i];
av_freep(&range->str);
av_freep(&ranges->range[i]);
}
av_freep(&ranges->range);
av_freep(rangesp);
}
| {
"code": [
" av_freep(&range->str);",
" av_freep(&ranges->range[i]);"
],
"line_no": [
21,
23
]
} | void FUNC_0(AVOptionRanges **VAR_0)
{
int VAR_1;
AVOptionRanges *ranges = *VAR_0;
if (!ranges)
return;
for (VAR_1 = 0; VAR_1 < ranges->nb_ranges * ranges->nb_components; VAR_1++) {
AVOptionRange *range = ranges->range[VAR_1];
av_freep(&range->str);
av_freep(&ranges->range[VAR_1]);
}
av_freep(&ranges->range);
av_freep(VAR_0);
}
| [
"void FUNC_0(AVOptionRanges **VAR_0)\n{",
"int VAR_1;",
"AVOptionRanges *ranges = *VAR_0;",
"if (!ranges)\nreturn;",
"for (VAR_1 = 0; VAR_1 < ranges->nb_ranges * ranges->nb_components; VAR_1++) {",
"AVOptionRange *range = ranges->range[VAR_1];",
"av_freep(&range->str);",
"av_freep(&ranges->range[VAR_1]);",
"}",
"av_freep(&ranges->range);",
"av_freep(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
25,147 | static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
OggVorbisEncContext *s = avctx->priv_data;
ogg_packet op;
int ret, duration;
/* send samples to libvorbis */
if (frame) {
const int samples = frame->nb_samples;
float **buffer;
int c, channels = s->vi.channels;
buffer = vorbis_analysis_buffer(&s->vd, samples);
for (c = 0; c < channels; c++) {
int co = (channels > 8) ? c :
ff_vorbis_encoding_channel_layout_offsets[channels - 1][c];
memcpy(buffer[c], frame->extended_data[co],
samples * sizeof(*buffer[c]));
}
if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
}
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
return ret;
} else {
if (!s->eof)
if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
}
s->eof = 1;
}
/* retrieve available packets from libvorbis */
while ((ret = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) {
if ((ret = vorbis_analysis(&s->vb, NULL)) < 0)
break;
if ((ret = vorbis_bitrate_addblock(&s->vb)) < 0)
break;
/* add any available packets to the output packet buffer */
while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {
if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {
av_log(avctx, AV_LOG_ERROR, "packet buffer is too small\n");
return AVERROR_BUG;
}
av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);
}
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
break;
}
}
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
return vorbis_error_to_averror(ret);
}
/* check for available packets */
if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet))
return 0;
av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
if ((ret = ff_alloc_packet2(avctx, avpkt, op.bytes)))
return ret;
av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL);
avpkt->pts = ff_samples_to_time_base(avctx, op.granulepos);
duration = avpriv_vorbis_parse_frame(&s->vp, avpkt->data, avpkt->size);
if (duration > 0) {
/* we do not know encoder delay until we get the first packet from
* libvorbis, so we have to update the AudioFrameQueue counts */
if (!avctx->delay && s->afq.frames) {
avctx->delay = duration;
av_assert0(!s->afq.remaining_delay);
s->afq.frames->duration += duration;
s->afq.frames->pts -= duration;
s->afq.remaining_samples += duration;
}
ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration);
}
*got_packet_ptr = 1;
return 0;
}
| false | FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
OggVorbisEncContext *s = avctx->priv_data;
ogg_packet op;
int ret, duration;
if (frame) {
const int samples = frame->nb_samples;
float **buffer;
int c, channels = s->vi.channels;
buffer = vorbis_analysis_buffer(&s->vd, samples);
for (c = 0; c < channels; c++) {
int co = (channels > 8) ? c :
ff_vorbis_encoding_channel_layout_offsets[channels - 1][c];
memcpy(buffer[c], frame->extended_data[co],
samples * sizeof(*buffer[c]));
}
if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
}
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
return ret;
} else {
if (!s->eof)
if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
}
s->eof = 1;
}
while ((ret = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) {
if ((ret = vorbis_analysis(&s->vb, NULL)) < 0)
break;
if ((ret = vorbis_bitrate_addblock(&s->vb)) < 0)
break;
while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {
if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {
av_log(avctx, AV_LOG_ERROR, "packet buffer is too small\n");
return AVERROR_BUG;
}
av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);
}
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
break;
}
}
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
return vorbis_error_to_averror(ret);
}
if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet))
return 0;
av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
if ((ret = ff_alloc_packet2(avctx, avpkt, op.bytes)))
return ret;
av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL);
avpkt->pts = ff_samples_to_time_base(avctx, op.granulepos);
duration = avpriv_vorbis_parse_frame(&s->vp, avpkt->data, avpkt->size);
if (duration > 0) {
if (!avctx->delay && s->afq.frames) {
avctx->delay = duration;
av_assert0(!s->afq.remaining_delay);
s->afq.frames->duration += duration;
s->afq.frames->pts -= duration;
s->afq.remaining_samples += duration;
}
ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration);
}
*got_packet_ptr = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
OggVorbisEncContext *s = VAR_0->priv_data;
ogg_packet op;
int VAR_4, VAR_5;
if (VAR_2) {
const int VAR_6 = VAR_2->nb_samples;
float **VAR_7;
int VAR_8, VAR_9 = s->vi.VAR_9;
VAR_7 = vorbis_analysis_buffer(&s->vd, VAR_6);
for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {
int VAR_10 = (VAR_9 > 8) ? VAR_8 :
ff_vorbis_encoding_channel_layout_offsets[VAR_9 - 1][VAR_8];
memcpy(VAR_7[VAR_8], VAR_2->extended_data[VAR_10],
VAR_6 * sizeof(*VAR_7[VAR_8]));
}
if ((VAR_4 = vorbis_analysis_wrote(&s->vd, VAR_6)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(VAR_4);
}
if ((VAR_4 = ff_af_queue_add(&s->afq, VAR_2)) < 0)
return VAR_4;
} else {
if (!s->eof)
if ((VAR_4 = vorbis_analysis_wrote(&s->vd, 0)) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(VAR_4);
}
s->eof = 1;
}
while ((VAR_4 = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) {
if ((VAR_4 = vorbis_analysis(&s->vb, NULL)) < 0)
break;
if ((VAR_4 = vorbis_bitrate_addblock(&s->vb)) < 0)
break;
while ((VAR_4 = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {
if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {
av_log(VAR_0, AV_LOG_ERROR, "packet VAR_7 is too small\n");
return AVERROR_BUG;
}
av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);
}
if (VAR_4 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "error getting available packets\n");
break;
}
}
if (VAR_4 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "error getting available packets\n");
return vorbis_error_to_averror(VAR_4);
}
if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet))
return 0;
av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, op.bytes)))
return VAR_4;
av_fifo_generic_read(s->pkt_fifo, VAR_1->data, op.bytes, NULL);
VAR_1->pts = ff_samples_to_time_base(VAR_0, op.granulepos);
VAR_5 = avpriv_vorbis_parse_frame(&s->vp, VAR_1->data, VAR_1->size);
if (VAR_5 > 0) {
if (!VAR_0->delay && s->afq.frames) {
VAR_0->delay = VAR_5;
av_assert0(!s->afq.remaining_delay);
s->afq.frames->VAR_5 += VAR_5;
s->afq.frames->pts -= VAR_5;
s->afq.remaining_samples += VAR_5;
}
ff_af_queue_remove(&s->afq, VAR_5, &VAR_1->pts, &VAR_1->VAR_5);
}
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"OggVorbisEncContext *s = VAR_0->priv_data;",
"ogg_packet op;",
"int VAR_4, VAR_5;",
"if (VAR_2) {",
"const int VAR_6 = VAR_2->nb_samples;",
"float **VAR_7;",
"int VAR_8, VAR_9 = s->vi.VAR_9;",
"VAR_7 = vorbis_analysis_buffer(&s->vd, VAR_6);",
"for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {",
"int VAR_10 = (VAR_9 > 8) ? VAR_8 :\nff_vorbis_encoding_channel_layout_offsets[VAR_9 - 1][VAR_8];",
"memcpy(VAR_7[VAR_8], VAR_2->extended_data[VAR_10],\nVAR_6 * sizeof(*VAR_7[VAR_8]));",
"}",
"if ((VAR_4 = vorbis_analysis_wrote(&s->vd, VAR_6)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error in vorbis_analysis_wrote()\\n\");",
"return vorbis_error_to_averror(VAR_4);",
"}",
"if ((VAR_4 = ff_af_queue_add(&s->afq, VAR_2)) < 0)\nreturn VAR_4;",
"} else {",
"if (!s->eof)\nif ((VAR_4 = vorbis_analysis_wrote(&s->vd, 0)) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error in vorbis_analysis_wrote()\\n\");",
"return vorbis_error_to_averror(VAR_4);",
"}",
"s->eof = 1;",
"}",
"while ((VAR_4 = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) {",
"if ((VAR_4 = vorbis_analysis(&s->vb, NULL)) < 0)\nbreak;",
"if ((VAR_4 = vorbis_bitrate_addblock(&s->vb)) < 0)\nbreak;",
"while ((VAR_4 = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {",
"if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {",
"av_log(VAR_0, AV_LOG_ERROR, \"packet VAR_7 is too small\\n\");",
"return AVERROR_BUG;",
"}",
"av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);",
"av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);",
"}",
"if (VAR_4 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error getting available packets\\n\");",
"break;",
"}",
"}",
"if (VAR_4 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"error getting available packets\\n\");",
"return vorbis_error_to_averror(VAR_4);",
"}",
"if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet))\nreturn 0;",
"av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);",
"if ((VAR_4 = ff_alloc_packet2(VAR_0, VAR_1, op.bytes)))\nreturn VAR_4;",
"av_fifo_generic_read(s->pkt_fifo, VAR_1->data, op.bytes, NULL);",
"VAR_1->pts = ff_samples_to_time_base(VAR_0, op.granulepos);",
"VAR_5 = avpriv_vorbis_parse_frame(&s->vp, VAR_1->data, VAR_1->size);",
"if (VAR_5 > 0) {",
"if (!VAR_0->delay && s->afq.frames) {",
"VAR_0->delay = VAR_5;",
"av_assert0(!s->afq.remaining_delay);",
"s->afq.frames->VAR_5 += VAR_5;",
"s->afq.frames->pts -= VAR_5;",
"s->afq.remaining_samples += VAR_5;",
"}",
"ff_af_queue_remove(&s->afq, VAR_5, &VAR_1->pts, &VAR_1->VAR_5);",
"}",
"*VAR_3 = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75,
77
],
[
79,
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
125,
127
],
[
131
],
[
135,
137
],
[
139
],
[
143
],
[
147
],
[
149
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
]
] |
25,148 | static void scsi_req_dequeue(SCSIRequest *req)
{
trace_scsi_req_dequeue(req->dev->id, req->lun, req->tag);
if (req->enqueued) {
QTAILQ_REMOVE(&req->dev->requests, req, next);
req->enqueued = false;
}
}
| true | qemu | ad2d30f79d3b0812f02c741be2189796b788d6d7 | static void scsi_req_dequeue(SCSIRequest *req)
{
trace_scsi_req_dequeue(req->dev->id, req->lun, req->tag);
if (req->enqueued) {
QTAILQ_REMOVE(&req->dev->requests, req, next);
req->enqueued = false;
}
}
| {
"code": [
"static void scsi_req_dequeue(SCSIRequest *req)"
],
"line_no": [
1
]
} | static void FUNC_0(SCSIRequest *VAR_0)
{
trace_scsi_req_dequeue(VAR_0->dev->id, VAR_0->lun, VAR_0->tag);
if (VAR_0->enqueued) {
QTAILQ_REMOVE(&VAR_0->dev->requests, VAR_0, next);
VAR_0->enqueued = false;
}
}
| [
"static void FUNC_0(SCSIRequest *VAR_0)\n{",
"trace_scsi_req_dequeue(VAR_0->dev->id, VAR_0->lun, VAR_0->tag);",
"if (VAR_0->enqueued) {",
"QTAILQ_REMOVE(&VAR_0->dev->requests, VAR_0, next);",
"VAR_0->enqueued = false;",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,150 | void check_aligned_anonymous_unfixed_colliding_mmaps(void)
{
char *p1;
char *p2;
char *p3;
uintptr_t p;
int i;
fprintf (stderr, "%s", __func__);
for (i = 0; i < 0x2fff; i++)
{
int nlen;
p1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (p1 != MAP_FAILED);
p = (uintptr_t) p1;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, p1, pagesize);
p2 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (p2 != MAP_FAILED);
p = (uintptr_t) p2;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, p2, pagesize);
munmap (p1, pagesize);
nlen = pagesize * 8;
p3 = mmap(NULL, nlen, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
/* Check if the mmaped areas collide. */
if (p3 < p2
&& (p3 + nlen) > p2)
fail_unless (0);
memcpy (dummybuf, p3, pagesize);
/* Make sure we get pages aligned with the pagesize. The
target expects this. */
fail_unless (p3 != MAP_FAILED);
p = (uintptr_t) p3;
fail_unless ((p & pagemask) == 0);
munmap (p2, pagesize);
munmap (p3, nlen);
}
fprintf (stderr, " passed\n");
}
| true | qemu | 420b6c317de87890e06225de6e2f8af7bf714df0 | void check_aligned_anonymous_unfixed_colliding_mmaps(void)
{
char *p1;
char *p2;
char *p3;
uintptr_t p;
int i;
fprintf (stderr, "%s", __func__);
for (i = 0; i < 0x2fff; i++)
{
int nlen;
p1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (p1 != MAP_FAILED);
p = (uintptr_t) p1;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, p1, pagesize);
p2 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (p2 != MAP_FAILED);
p = (uintptr_t) p2;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, p2, pagesize);
munmap (p1, pagesize);
nlen = pagesize * 8;
p3 = mmap(NULL, nlen, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (p3 < p2
&& (p3 + nlen) > p2)
fail_unless (0);
memcpy (dummybuf, p3, pagesize);
fail_unless (p3 != MAP_FAILED);
p = (uintptr_t) p3;
fail_unless ((p & pagemask) == 0);
munmap (p2, pagesize);
munmap (p3, nlen);
}
fprintf (stderr, " passed\n");
}
| {
"code": [
"\t\tfail_unless (p3 != MAP_FAILED);"
],
"line_no": [
83
]
} | void FUNC_0(void)
{
char *VAR_0;
char *VAR_1;
char *VAR_2;
uintptr_t p;
int VAR_3;
fprintf (stderr, "%s", __func__);
for (VAR_3 = 0; VAR_3 < 0x2fff; VAR_3++)
{
int VAR_4;
VAR_0 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (VAR_0 != MAP_FAILED);
p = (uintptr_t) VAR_0;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, VAR_0, pagesize);
VAR_1 = mmap(NULL, pagesize, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
fail_unless (VAR_1 != MAP_FAILED);
p = (uintptr_t) VAR_1;
fail_unless ((p & pagemask) == 0);
memcpy (dummybuf, VAR_1, pagesize);
munmap (VAR_0, pagesize);
VAR_4 = pagesize * 8;
VAR_2 = mmap(NULL, VAR_4, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (VAR_2 < VAR_1
&& (VAR_2 + VAR_4) > VAR_1)
fail_unless (0);
memcpy (dummybuf, VAR_2, pagesize);
fail_unless (VAR_2 != MAP_FAILED);
p = (uintptr_t) VAR_2;
fail_unless ((p & pagemask) == 0);
munmap (VAR_1, pagesize);
munmap (VAR_2, VAR_4);
}
fprintf (stderr, " passed\n");
}
| [
"void FUNC_0(void)\n{",
"char *VAR_0;",
"char *VAR_1;",
"char *VAR_2;",
"uintptr_t p;",
"int VAR_3;",
"fprintf (stderr, \"%s\", __func__);",
"for (VAR_3 = 0; VAR_3 < 0x2fff; VAR_3++)",
"{",
"int VAR_4;",
"VAR_0 = mmap(NULL, pagesize, PROT_READ,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);",
"fail_unless (VAR_0 != MAP_FAILED);",
"p = (uintptr_t) VAR_0;",
"fail_unless ((p & pagemask) == 0);",
"memcpy (dummybuf, VAR_0, pagesize);",
"VAR_1 = mmap(NULL, pagesize, PROT_READ,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);",
"fail_unless (VAR_1 != MAP_FAILED);",
"p = (uintptr_t) VAR_1;",
"fail_unless ((p & pagemask) == 0);",
"memcpy (dummybuf, VAR_1, pagesize);",
"munmap (VAR_0, pagesize);",
"VAR_4 = pagesize * 8;",
"VAR_2 = mmap(NULL, VAR_4, PROT_READ,\nMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);",
"if (VAR_2 < VAR_1\n&& (VAR_2 + VAR_4) > VAR_1)\nfail_unless (0);",
"memcpy (dummybuf, VAR_2, pagesize);",
"fail_unless (VAR_2 != MAP_FAILED);",
"p = (uintptr_t) VAR_2;",
"fail_unless ((p & pagemask) == 0);",
"munmap (VAR_1, pagesize);",
"munmap (VAR_2, VAR_4);",
"}",
"fprintf (stderr, \" passed\\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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59,
61
],
[
67,
69,
71
],
[
75
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
]
] |
25,151 | void ff_er_add_slice(ERContext *s, int startx, int starty,
int endx, int endy, int status)
{
const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
const int start_xy = s->mb_index2xy[start_i];
const int end_xy = s->mb_index2xy[end_i];
int mask = -1;
if (s->avctx->hwaccel)
return;
if (start_i > end_i || start_xy > end_xy) {
av_log(s->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!s->avctx->err_recognition)
return;
mask &= ~VP_START;
if (status & (ER_AC_ERROR | ER_AC_END)) {
mask &= ~(ER_AC_ERROR | ER_AC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_DC_ERROR | ER_DC_END)) {
mask &= ~(ER_DC_ERROR | ER_DC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_MV_ERROR | ER_MV_END)) {
mask &= ~(ER_MV_ERROR | ER_MV_END);
s->error_count -= end_i - start_i + 1;
}
if (status & ER_MB_ERROR) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
if (mask == ~0x7F) {
memset(&s->error_status_table[start_xy], 0,
(end_xy - start_xy) * sizeof(uint8_t));
} else {
int i;
for (i = start_xy; i < end_xy; i++)
s->error_status_table[i] &= mask;
}
if (end_i == s->mb_num)
s->error_count = INT_MAX;
else {
s->error_status_table[end_xy] &= mask;
s->error_status_table[end_xy] |= status;
}
s->error_status_table[start_xy] |= VP_START;
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
s->avctx->skip_top * s->mb_width < start_i) {
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
}
}
| false | FFmpeg | 346e09638cc159a3c3e4cf971a5b795644faac16 | void ff_er_add_slice(ERContext *s, int startx, int starty,
int endx, int endy, int status)
{
const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
const int start_xy = s->mb_index2xy[start_i];
const int end_xy = s->mb_index2xy[end_i];
int mask = -1;
if (s->avctx->hwaccel)
return;
if (start_i > end_i || start_xy > end_xy) {
av_log(s->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!s->avctx->err_recognition)
return;
mask &= ~VP_START;
if (status & (ER_AC_ERROR | ER_AC_END)) {
mask &= ~(ER_AC_ERROR | ER_AC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_DC_ERROR | ER_DC_END)) {
mask &= ~(ER_DC_ERROR | ER_DC_END);
s->error_count -= end_i - start_i + 1;
}
if (status & (ER_MV_ERROR | ER_MV_END)) {
mask &= ~(ER_MV_ERROR | ER_MV_END);
s->error_count -= end_i - start_i + 1;
}
if (status & ER_MB_ERROR) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
if (mask == ~0x7F) {
memset(&s->error_status_table[start_xy], 0,
(end_xy - start_xy) * sizeof(uint8_t));
} else {
int i;
for (i = start_xy; i < end_xy; i++)
s->error_status_table[i] &= mask;
}
if (end_i == s->mb_num)
s->error_count = INT_MAX;
else {
s->error_status_table[end_xy] &= mask;
s->error_status_table[end_xy] |= status;
}
s->error_status_table[start_xy] |= VP_START;
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
s->avctx->skip_top * s->mb_width < start_i) {
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
s->error_occurred = 1;
s->error_count = INT_MAX;
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
const int VAR_6 = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1);
const int VAR_7 = av_clip(VAR_3 + VAR_4 * VAR_0->mb_width, 0, VAR_0->mb_num);
const int VAR_8 = VAR_0->mb_index2xy[VAR_6];
const int VAR_9 = VAR_0->mb_index2xy[VAR_7];
int VAR_10 = -1;
if (VAR_0->avctx->hwaccel)
return;
if (VAR_6 > VAR_7 || VAR_8 > VAR_9) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n");
return;
}
if (!VAR_0->avctx->err_recognition)
return;
VAR_10 &= ~VP_START;
if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) {
VAR_10 &= ~(ER_AC_ERROR | ER_AC_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) {
VAR_10 &= ~(ER_DC_ERROR | ER_DC_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) {
VAR_10 &= ~(ER_MV_ERROR | ER_MV_END);
VAR_0->error_count -= VAR_7 - VAR_6 + 1;
}
if (VAR_5 & ER_MB_ERROR) {
VAR_0->error_occurred = 1;
VAR_0->error_count = INT_MAX;
}
if (VAR_10 == ~0x7F) {
memset(&VAR_0->error_status_table[VAR_8], 0,
(VAR_9 - VAR_8) * sizeof(uint8_t));
} else {
int VAR_11;
for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++)
VAR_0->error_status_table[VAR_11] &= VAR_10;
}
if (VAR_7 == VAR_0->mb_num)
VAR_0->error_count = INT_MAX;
else {
VAR_0->error_status_table[VAR_9] &= VAR_10;
VAR_0->error_status_table[VAR_9] |= VAR_5;
}
VAR_0->error_status_table[VAR_8] |= VP_START;
if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&
VAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) {
int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]];
VAR_12 &= ~ VP_START;
if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) {
VAR_0->error_occurred = 1;
VAR_0->error_count = INT_MAX;
}
}
}
| [
"void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"const int VAR_6 = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1);",
"const int VAR_7 = av_clip(VAR_3 + VAR_4 * VAR_0->mb_width, 0, VAR_0->mb_num);",
"const int VAR_8 = VAR_0->mb_index2xy[VAR_6];",
"const int VAR_9 = VAR_0->mb_index2xy[VAR_7];",
"int VAR_10 = -1;",
"if (VAR_0->avctx->hwaccel)\nreturn;",
"if (VAR_6 > VAR_7 || VAR_8 > VAR_9) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"internal error, slice end before start\\n\");",
"return;",
"}",
"if (!VAR_0->avctx->err_recognition)\nreturn;",
"VAR_10 &= ~VP_START;",
"if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) {",
"VAR_10 &= ~(ER_AC_ERROR | ER_AC_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) {",
"VAR_10 &= ~(ER_DC_ERROR | ER_DC_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) {",
"VAR_10 &= ~(ER_MV_ERROR | ER_MV_END);",
"VAR_0->error_count -= VAR_7 - VAR_6 + 1;",
"}",
"if (VAR_5 & ER_MB_ERROR) {",
"VAR_0->error_occurred = 1;",
"VAR_0->error_count = INT_MAX;",
"}",
"if (VAR_10 == ~0x7F) {",
"memset(&VAR_0->error_status_table[VAR_8], 0,\n(VAR_9 - VAR_8) * sizeof(uint8_t));",
"} else {",
"int VAR_11;",
"for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++)",
"VAR_0->error_status_table[VAR_11] &= VAR_10;",
"}",
"if (VAR_7 == VAR_0->mb_num)\nVAR_0->error_count = INT_MAX;",
"else {",
"VAR_0->error_status_table[VAR_9] &= VAR_10;",
"VAR_0->error_status_table[VAR_9] |= VAR_5;",
"}",
"VAR_0->error_status_table[VAR_8] |= VP_START;",
"if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&\nVAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) {",
"int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]];",
"VAR_12 &= ~ VP_START;",
"if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) {",
"VAR_0->error_occurred = 1;",
"VAR_0->error_count = INT_MAX;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
25,152 | static void avc_luma_hv_qrt_4w_msa(const uint8_t *src_x, const uint8_t *src_y,
int32_t src_stride, uint8_t *dst,
int32_t dst_stride, int32_t height)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, vert_out0, vert_out1;
v8i16 out0, out1;
v16u8 out;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
src_y += (5 * src_stride);
src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1);
src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2);
src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3);
src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3);
src_x += (4 * src_stride);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0,
src_hz1, mask0,
mask1, mask2);
hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2,
src_hz3, mask0,
mask1, mask2);
SRARI_H2_SH(hz_out0, hz_out1, 5);
SAT_SH2_SH(hz_out0, hz_out1, 7);
LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8);
src_y += (4 * src_stride);
src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5);
src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6);
src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7);
src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
/* filter calc */
vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1,
src_vt2, src_vt3,
src_vt4, src_vt5);
vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3,
src_vt4, src_vt5,
src_vt6, src_vt7);
SRARI_H2_SH(vert_out0, vert_out1, 5);
SAT_SH2_SH(vert_out0, vert_out1, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
SAT_SH2_SH(out0, out1, 7);
out = PCKEV_XORI128_UB(out0, out1);
ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride);
dst += (4 * dst_stride);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt0 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
}
}
| false | FFmpeg | 2aab7c2dfaca4386c38e5d565cd2bf73096bcc86 | static void avc_luma_hv_qrt_4w_msa(const uint8_t *src_x, const uint8_t *src_y,
int32_t src_stride, uint8_t *dst,
int32_t dst_stride, int32_t height)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, vert_out0, vert_out1;
v8i16 out0, out1;
v16u8 out;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(src_y, src_stride, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
src_y += (5 * src_stride);
src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1);
src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2);
src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3);
src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src_x, src_stride, src_hz0, src_hz1, src_hz2, src_hz3);
src_x += (4 * src_stride);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0,
src_hz1, mask0,
mask1, mask2);
hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2,
src_hz3, mask0,
mask1, mask2);
SRARI_H2_SH(hz_out0, hz_out1, 5);
SAT_SH2_SH(hz_out0, hz_out1, 7);
LD_SB4(src_y, src_stride, src_vt5, src_vt6, src_vt7, src_vt8);
src_y += (4 * src_stride);
src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5);
src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6);
src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7);
src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1,
src_vt2, src_vt3,
src_vt4, src_vt5);
vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3,
src_vt4, src_vt5,
src_vt6, src_vt7);
SRARI_H2_SH(vert_out0, vert_out1, 5);
SAT_SH2_SH(vert_out0, vert_out1, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
SAT_SH2_SH(out0, out1, 7);
out = PCKEV_XORI128_UB(out0, out1);
ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride);
dst += (4 * dst_stride);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt0 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,
int32_t VAR_2, uint8_t *VAR_3,
int32_t VAR_4, int32_t VAR_5)
{
uint32_t loop_cnt;
v16i8 src_hz0, src_hz1, src_hz2, src_hz3;
v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;
v16i8 src_vt5, src_vt6, src_vt7, src_vt8;
v16i8 mask0, mask1, mask2;
v8i16 hz_out0, hz_out1, vert_out0, vert_out1;
v8i16 out0, out1;
v16u8 out;
LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);
LD_SB5(VAR_1, VAR_2, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);
VAR_1 += (5 * VAR_2);
src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1);
src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2);
src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3);
src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4);
XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);
for (loop_cnt = (VAR_5 >> 2); loop_cnt--;) {
LD_SB4(VAR_0, VAR_2, src_hz0, src_hz1, src_hz2, src_hz3);
VAR_0 += (4 * VAR_2);
XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);
hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0,
src_hz1, mask0,
mask1, mask2);
hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2,
src_hz3, mask0,
mask1, mask2);
SRARI_H2_SH(hz_out0, hz_out1, 5);
SAT_SH2_SH(hz_out0, hz_out1, 7);
LD_SB4(VAR_1, VAR_2, src_vt5, src_vt6, src_vt7, src_vt8);
VAR_1 += (4 * VAR_2);
src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5);
src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6);
src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7);
src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8);
XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);
vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1,
src_vt2, src_vt3,
src_vt4, src_vt5);
vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3,
src_vt4, src_vt5,
src_vt6, src_vt7);
SRARI_H2_SH(vert_out0, vert_out1, 5);
SAT_SH2_SH(vert_out0, vert_out1, 7);
out0 = __msa_srari_h((hz_out0 + vert_out0), 1);
out1 = __msa_srari_h((hz_out1 + vert_out1), 1);
SAT_SH2_SH(out0, out1, 7);
out = PCKEV_XORI128_UB(out0, out1);
ST4x4_UB(out, out, 0, 1, 2, 3, VAR_3, VAR_4);
VAR_3 += (4 * VAR_4);
src_vt3 = src_vt7;
src_vt1 = src_vt5;
src_vt0 = src_vt4;
src_vt4 = src_vt8;
src_vt2 = src_vt6;
}
}
| [
"static void FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,\nint32_t VAR_2, uint8_t *VAR_3,\nint32_t VAR_4, int32_t VAR_5)\n{",
"uint32_t loop_cnt;",
"v16i8 src_hz0, src_hz1, src_hz2, src_hz3;",
"v16i8 src_vt0, src_vt1, src_vt2, src_vt3, src_vt4;",
"v16i8 src_vt5, src_vt6, src_vt7, src_vt8;",
"v16i8 mask0, mask1, mask2;",
"v8i16 hz_out0, hz_out1, vert_out0, vert_out1;",
"v8i16 out0, out1;",
"v16u8 out;",
"LD_SB3(&luma_mask_arr[48], 16, mask0, mask1, mask2);",
"LD_SB5(VAR_1, VAR_2, src_vt0, src_vt1, src_vt2, src_vt3, src_vt4);",
"VAR_1 += (5 * VAR_2);",
"src_vt0 = (v16i8) __msa_insve_w((v4i32) src_vt0, 1, (v4i32) src_vt1);",
"src_vt1 = (v16i8) __msa_insve_w((v4i32) src_vt1, 1, (v4i32) src_vt2);",
"src_vt2 = (v16i8) __msa_insve_w((v4i32) src_vt2, 1, (v4i32) src_vt3);",
"src_vt3 = (v16i8) __msa_insve_w((v4i32) src_vt3, 1, (v4i32) src_vt4);",
"XORI_B4_128_SB(src_vt0, src_vt1, src_vt2, src_vt3);",
"for (loop_cnt = (VAR_5 >> 2); loop_cnt--;) {",
"LD_SB4(VAR_0, VAR_2, src_hz0, src_hz1, src_hz2, src_hz3);",
"VAR_0 += (4 * VAR_2);",
"XORI_B4_128_SB(src_hz0, src_hz1, src_hz2, src_hz3);",
"hz_out0 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz0,\nsrc_hz1, mask0,\nmask1, mask2);",
"hz_out1 = AVC_XOR_VSHF_B_AND_APPLY_6TAP_HORIZ_FILT_SH(src_hz2,\nsrc_hz3, mask0,\nmask1, mask2);",
"SRARI_H2_SH(hz_out0, hz_out1, 5);",
"SAT_SH2_SH(hz_out0, hz_out1, 7);",
"LD_SB4(VAR_1, VAR_2, src_vt5, src_vt6, src_vt7, src_vt8);",
"VAR_1 += (4 * VAR_2);",
"src_vt4 = (v16i8) __msa_insve_w((v4i32) src_vt4, 1, (v4i32) src_vt5);",
"src_vt5 = (v16i8) __msa_insve_w((v4i32) src_vt5, 1, (v4i32) src_vt6);",
"src_vt6 = (v16i8) __msa_insve_w((v4i32) src_vt6, 1, (v4i32) src_vt7);",
"src_vt7 = (v16i8) __msa_insve_w((v4i32) src_vt7, 1, (v4i32) src_vt8);",
"XORI_B4_128_SB(src_vt4, src_vt5, src_vt6, src_vt7);",
"vert_out0 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt0, src_vt1,\nsrc_vt2, src_vt3,\nsrc_vt4, src_vt5);",
"vert_out1 = AVC_CALC_DPADD_B_6PIX_2COEFF_R_SH(src_vt2, src_vt3,\nsrc_vt4, src_vt5,\nsrc_vt6, src_vt7);",
"SRARI_H2_SH(vert_out0, vert_out1, 5);",
"SAT_SH2_SH(vert_out0, vert_out1, 7);",
"out0 = __msa_srari_h((hz_out0 + vert_out0), 1);",
"out1 = __msa_srari_h((hz_out1 + vert_out1), 1);",
"SAT_SH2_SH(out0, out1, 7);",
"out = PCKEV_XORI128_UB(out0, out1);",
"ST4x4_UB(out, out, 0, 1, 2, 3, VAR_3, VAR_4);",
"VAR_3 += (4 * VAR_4);",
"src_vt3 = src_vt7;",
"src_vt1 = src_vt5;",
"src_vt0 = src_vt4;",
"src_vt4 = src_vt8;",
"src_vt2 = src_vt6;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63,
65,
67
],
[
69,
71,
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
105,
107,
109
],
[
111,
113,
115
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
]
] |
25,153 | void qmp_migrate_set_downtime(double value, Error **errp)
{
value *= 1e9;
value = MAX(0, MIN(UINT64_MAX, value));
max_downtime = (uint64_t)value;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void qmp_migrate_set_downtime(double value, Error **errp)
{
value *= 1e9;
value = MAX(0, MIN(UINT64_MAX, value));
max_downtime = (uint64_t)value;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(double VAR_0, Error **VAR_1)
{
VAR_0 *= 1e9;
VAR_0 = MAX(0, MIN(UINT64_MAX, VAR_0));
max_downtime = (uint64_t)VAR_0;
}
| [
"void FUNC_0(double VAR_0, Error **VAR_1)\n{",
"VAR_0 *= 1e9;",
"VAR_0 = MAX(0, MIN(UINT64_MAX, VAR_0));",
"max_downtime = (uint64_t)VAR_0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
25,154 | static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
Error *err = NULL;
int fdt_offset_next, fdt_offset, fdt_depth;
void *fdt;
if (!drc->fdt) {
visit_start_struct(v, name, NULL, 0, &err);
if (!err) {
visit_end_struct(v, &err);
}
error_propagate(errp, err);
return;
}
fdt = drc->fdt;
fdt_offset = drc->fdt_start_offset;
fdt_depth = 0;
do {
const char *name = NULL;
const struct fdt_property *prop = NULL;
int prop_len = 0, name_len = 0;
uint32_t tag;
tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
switch (tag) {
case FDT_BEGIN_NODE:
fdt_depth++;
name = fdt_get_name(fdt, fdt_offset, &name_len);
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
error_propagate(errp, err);
return;
}
break;
case FDT_END_NODE:
/* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
g_assert(fdt_depth > 0);
visit_end_struct(v, &err);
if (err) {
error_propagate(errp, err);
return;
}
fdt_depth--;
break;
case FDT_PROP: {
int i;
prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
visit_start_list(v, name, &err);
if (err) {
error_propagate(errp, err);
return;
}
for (i = 0; i < prop_len; i++) {
visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
if (err) {
error_propagate(errp, err);
return;
}
}
visit_end_list(v);
break;
}
default:
error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
}
fdt_offset = fdt_offset_next;
} while (fdt_depth != 0);
}
| true | qemu | a543a554cfffa4bbed2c74ac56c1abf046821377 | static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
Error *err = NULL;
int fdt_offset_next, fdt_offset, fdt_depth;
void *fdt;
if (!drc->fdt) {
visit_start_struct(v, name, NULL, 0, &err);
if (!err) {
visit_end_struct(v, &err);
}
error_propagate(errp, err);
return;
}
fdt = drc->fdt;
fdt_offset = drc->fdt_start_offset;
fdt_depth = 0;
do {
const char *name = NULL;
const struct fdt_property *prop = NULL;
int prop_len = 0, name_len = 0;
uint32_t tag;
tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
switch (tag) {
case FDT_BEGIN_NODE:
fdt_depth++;
name = fdt_get_name(fdt, fdt_offset, &name_len);
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
error_propagate(errp, err);
return;
}
break;
case FDT_END_NODE:
g_assert(fdt_depth > 0);
visit_end_struct(v, &err);
if (err) {
error_propagate(errp, err);
return;
}
fdt_depth--;
break;
case FDT_PROP: {
int i;
prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
visit_start_list(v, name, &err);
if (err) {
error_propagate(errp, err);
return;
}
for (i = 0; i < prop_len; i++) {
visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
if (err) {
error_propagate(errp, err);
return;
}
}
visit_end_list(v);
break;
}
default:
error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
}
fdt_offset = fdt_offset_next;
} while (fdt_depth != 0);
}
| {
"code": [
" visit_start_struct(v, name, NULL, 0, &err);",
" if (!err) {",
" visit_end_struct(v, &err);",
" error_propagate(errp, err);"
],
"line_no": [
19,
21,
23,
27
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_9,
void *VAR_3, Error **VAR_4)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(VAR_0);
Error *err = NULL;
int VAR_5, VAR_6, VAR_7;
void *VAR_8;
if (!drc->VAR_8) {
visit_start_struct(VAR_1, VAR_9, NULL, 0, &err);
if (!err) {
visit_end_struct(VAR_1, &err);
}
error_propagate(VAR_4, err);
return;
}
VAR_8 = drc->VAR_8;
VAR_6 = drc->fdt_start_offset;
VAR_7 = 0;
do {
const char *VAR_9 = NULL;
const struct fdt_property *VAR_9 = NULL;
int VAR_10 = 0, VAR_11 = 0;
uint32_t tag;
tag = fdt_next_tag(VAR_8, VAR_6, &VAR_5);
switch (tag) {
case FDT_BEGIN_NODE:
VAR_7++;
VAR_9 = fdt_get_name(VAR_8, VAR_6, &VAR_11);
visit_start_struct(VAR_1, VAR_9, NULL, 0, &err);
if (err) {
error_propagate(VAR_4, err);
return;
}
break;
case FDT_END_NODE:
g_assert(VAR_7 > 0);
visit_end_struct(VAR_1, &err);
if (err) {
error_propagate(VAR_4, err);
return;
}
VAR_7--;
break;
case FDT_PROP: {
int VAR_12;
VAR_9 = fdt_get_property_by_offset(VAR_8, VAR_6, &VAR_10);
VAR_9 = fdt_string(VAR_8, fdt32_to_cpu(VAR_9->nameoff));
visit_start_list(VAR_1, VAR_9, &err);
if (err) {
error_propagate(VAR_4, err);
return;
}
for (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++) {
visit_type_uint8(VAR_1, NULL, (uint8_t *)&VAR_9->data[VAR_12], &err);
if (err) {
error_propagate(VAR_4, err);
return;
}
}
visit_end_list(VAR_1);
break;
}
default:
error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
}
VAR_6 = VAR_5;
} while (VAR_7 != 0);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_9,\nvoid *VAR_3, Error **VAR_4)\n{",
"sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(VAR_0);",
"Error *err = NULL;",
"int VAR_5, VAR_6, VAR_7;",
"void *VAR_8;",
"if (!drc->VAR_8) {",
"visit_start_struct(VAR_1, VAR_9, NULL, 0, &err);",
"if (!err) {",
"visit_end_struct(VAR_1, &err);",
"}",
"error_propagate(VAR_4, err);",
"return;",
"}",
"VAR_8 = drc->VAR_8;",
"VAR_6 = drc->fdt_start_offset;",
"VAR_7 = 0;",
"do {",
"const char *VAR_9 = NULL;",
"const struct fdt_property *VAR_9 = NULL;",
"int VAR_10 = 0, VAR_11 = 0;",
"uint32_t tag;",
"tag = fdt_next_tag(VAR_8, VAR_6, &VAR_5);",
"switch (tag) {",
"case FDT_BEGIN_NODE:\nVAR_7++;",
"VAR_9 = fdt_get_name(VAR_8, VAR_6, &VAR_11);",
"visit_start_struct(VAR_1, VAR_9, NULL, 0, &err);",
"if (err) {",
"error_propagate(VAR_4, err);",
"return;",
"}",
"break;",
"case FDT_END_NODE:\ng_assert(VAR_7 > 0);",
"visit_end_struct(VAR_1, &err);",
"if (err) {",
"error_propagate(VAR_4, err);",
"return;",
"}",
"VAR_7--;",
"break;",
"case FDT_PROP: {",
"int VAR_12;",
"VAR_9 = fdt_get_property_by_offset(VAR_8, VAR_6, &VAR_10);",
"VAR_9 = fdt_string(VAR_8, fdt32_to_cpu(VAR_9->nameoff));",
"visit_start_list(VAR_1, VAR_9, &err);",
"if (err) {",
"error_propagate(VAR_4, err);",
"return;",
"}",
"for (VAR_12 = 0; VAR_12 < VAR_10; VAR_12++) {",
"visit_type_uint8(VAR_1, NULL, (uint8_t *)&VAR_9->data[VAR_12], &err);",
"if (err) {",
"error_propagate(VAR_4, err);",
"return;",
"}",
"}",
"visit_end_list(VAR_1);",
"break;",
"}",
"default:\nerror_setg(&error_abort, \"device FDT in unexpected state: %d\", tag);",
"}",
"VAR_6 = VAR_5;",
"} while (VAR_7 != 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
]
] |
25,155 | static void qtrle_decode_24bpp(QtrleContext *s)
{
int stream_ptr;
int header;
int start_line;
int lines_to_change;
signed char rle_code;
int row_ptr, pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char r, g, b;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
/* check if this frame is even supposed to change */
if (s->size < 8)
return;
/* start after the chunk size */
stream_ptr = 4;
/* fetch the header */
CHECK_STREAM_PTR(2);
header = BE_16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
start_line = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
lines_to_change = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
lines_to_change = s->avctx->height;
}
row_ptr = row_inc * start_line;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3;
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
/* there's another skip code in the stream */
CHECK_STREAM_PTR(1);
pixel_ptr += (s->buf[stream_ptr++] - 1) * 3;
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
} else if (rle_code < 0) {
/* decode the run length code */
rle_code = -rle_code;
CHECK_STREAM_PTR(3);
r = s->buf[stream_ptr++];
g = s->buf[stream_ptr++];
b = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 3);
while (rle_code--) {
rgb[pixel_ptr++] = r;
rgb[pixel_ptr++] = g;
rgb[pixel_ptr++] = b;
}
} else {
CHECK_STREAM_PTR(rle_code * 3);
CHECK_PIXEL_PTR(rle_code * 3);
/* copy pixels directly to output */
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| true | FFmpeg | 5b0e811a65737463c7e4206b68a23e19d4473519 | static void qtrle_decode_24bpp(QtrleContext *s)
{
int stream_ptr;
int header;
int start_line;
int lines_to_change;
signed char rle_code;
int row_ptr, pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char r, g, b;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
if (s->size < 8)
return;
stream_ptr = 4;
CHECK_STREAM_PTR(2);
header = BE_16(&s->buf[stream_ptr]);
stream_ptr += 2;
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
start_line = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
lines_to_change = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
lines_to_change = s->avctx->height;
}
row_ptr = row_inc * start_line;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3;
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (s->buf[stream_ptr++] - 1) * 3;
CHECK_PIXEL_PTR(0);
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(3);
r = s->buf[stream_ptr++];
g = s->buf[stream_ptr++];
b = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 3);
while (rle_code--) {
rgb[pixel_ptr++] = r;
rgb[pixel_ptr++] = g;
rgb[pixel_ptr++] = b;
}
} else {
CHECK_STREAM_PTR(rle_code * 3);
CHECK_PIXEL_PTR(rle_code * 3);
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| {
"code": [
" signed char rle_code;",
" signed char rle_code;",
" signed char rle_code;"
],
"line_no": [
13,
13,
13
]
} | static void FUNC_0(QtrleContext *VAR_0)
{
int VAR_1;
int VAR_2;
int VAR_3;
int VAR_4;
signed char VAR_5;
int VAR_6, VAR_7;
int VAR_8 = VAR_0->frame.linesize[0];
unsigned char VAR_9, VAR_10, VAR_11;
unsigned char *VAR_12 = VAR_0->frame.data[0];
int VAR_13 = VAR_0->frame.linesize[0] * VAR_0->avctx->height;
if (VAR_0->size < 8)
return;
VAR_1 = 4;
CHECK_STREAM_PTR(2);
VAR_2 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 2;
if (VAR_2 & 0x0008) {
CHECK_STREAM_PTR(8);
VAR_3 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 4;
VAR_4 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 4;
} else {
VAR_3 = 0;
VAR_4 = VAR_0->avctx->height;
}
VAR_6 = VAR_8 * VAR_3;
while (VAR_4--) {
CHECK_STREAM_PTR(2);
VAR_7 = VAR_6 + (VAR_0->buf[VAR_1++] - 1) * 3;
while ((VAR_5 = (signed char)VAR_0->buf[VAR_1++]) != -1) {
if (VAR_5 == 0) {
CHECK_STREAM_PTR(1);
VAR_7 += (VAR_0->buf[VAR_1++] - 1) * 3;
CHECK_PIXEL_PTR(0);
} else if (VAR_5 < 0) {
VAR_5 = -VAR_5;
CHECK_STREAM_PTR(3);
VAR_9 = VAR_0->buf[VAR_1++];
VAR_10 = VAR_0->buf[VAR_1++];
VAR_11 = VAR_0->buf[VAR_1++];
CHECK_PIXEL_PTR(VAR_5 * 3);
while (VAR_5--) {
VAR_12[VAR_7++] = VAR_9;
VAR_12[VAR_7++] = VAR_10;
VAR_12[VAR_7++] = VAR_11;
}
} else {
CHECK_STREAM_PTR(VAR_5 * 3);
CHECK_PIXEL_PTR(VAR_5 * 3);
while (VAR_5--) {
VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];
VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];
VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];
}
}
}
VAR_6 += VAR_8;
}
}
| [
"static void FUNC_0(QtrleContext *VAR_0)\n{",
"int VAR_1;",
"int VAR_2;",
"int VAR_3;",
"int VAR_4;",
"signed char VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8 = VAR_0->frame.linesize[0];",
"unsigned char VAR_9, VAR_10, VAR_11;",
"unsigned char *VAR_12 = VAR_0->frame.data[0];",
"int VAR_13 = VAR_0->frame.linesize[0] * VAR_0->avctx->height;",
"if (VAR_0->size < 8)\nreturn;",
"VAR_1 = 4;",
"CHECK_STREAM_PTR(2);",
"VAR_2 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 2;",
"if (VAR_2 & 0x0008) {",
"CHECK_STREAM_PTR(8);",
"VAR_3 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 4;",
"VAR_4 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 4;",
"} else {",
"VAR_3 = 0;",
"VAR_4 = VAR_0->avctx->height;",
"}",
"VAR_6 = VAR_8 * VAR_3;",
"while (VAR_4--) {",
"CHECK_STREAM_PTR(2);",
"VAR_7 = VAR_6 + (VAR_0->buf[VAR_1++] - 1) * 3;",
"while ((VAR_5 = (signed char)VAR_0->buf[VAR_1++]) != -1) {",
"if (VAR_5 == 0) {",
"CHECK_STREAM_PTR(1);",
"VAR_7 += (VAR_0->buf[VAR_1++] - 1) * 3;",
"CHECK_PIXEL_PTR(0);",
"} else if (VAR_5 < 0) {",
"VAR_5 = -VAR_5;",
"CHECK_STREAM_PTR(3);",
"VAR_9 = VAR_0->buf[VAR_1++];",
"VAR_10 = VAR_0->buf[VAR_1++];",
"VAR_11 = VAR_0->buf[VAR_1++];",
"CHECK_PIXEL_PTR(VAR_5 * 3);",
"while (VAR_5--) {",
"VAR_12[VAR_7++] = VAR_9;",
"VAR_12[VAR_7++] = VAR_10;",
"VAR_12[VAR_7++] = VAR_11;",
"}",
"} else {",
"CHECK_STREAM_PTR(VAR_5 * 3);",
"CHECK_PIXEL_PTR(VAR_5 * 3);",
"while (VAR_5--) {",
"VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];",
"VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];",
"VAR_12[VAR_7++] = VAR_0->buf[VAR_1++];",
"}",
"}",
"}",
"VAR_6 += VAR_8;",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29,
31
],
[
37
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
]
] |
25,156 | static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
{
RTPDemuxContext *s = s1->priv_data;
uint32_t rtp_ts;
#if defined(DEBUG)
printf("RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
#endif
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_time;
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,
s1->streams[0]->time_base) + s->base_timestamp;
put_byte(s1->pb, (RTP_VERSION << 6));
put_byte(s1->pb, 200);
put_be16(s1->pb, 6); /* length in words - 1 */
put_be32(s1->pb, s->ssrc);
put_be32(s1->pb, ntp_time / 1000000);
put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
put_be32(s1->pb, rtp_ts);
put_be32(s1->pb, s->packet_count);
put_be32(s1->pb, s->octet_count);
put_flush_packet(s1->pb);
}
| true | FFmpeg | a4696aa2fe88c21927835e59d543eb2efbfabaef | static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time)
{
RTPDemuxContext *s = s1->priv_data;
uint32_t rtp_ts;
#if defined(DEBUG)
printf("RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
#endif
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_time;
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,
s1->streams[0]->time_base) + s->base_timestamp;
put_byte(s1->pb, (RTP_VERSION << 6));
put_byte(s1->pb, 200);
put_be16(s1->pb, 6);
put_be32(s1->pb, s->ssrc);
put_be32(s1->pb, ntp_time / 1000000);
put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000);
put_be32(s1->pb, rtp_ts);
put_be32(s1->pb, s->packet_count);
put_be32(s1->pb, s->octet_count);
put_flush_packet(s1->pb);
}
| {
"code": [
" rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,"
],
"line_no": [
23
]
} | static void FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1)
{
RTPDemuxContext *s = VAR_0->priv_data;
uint32_t rtp_ts;
#if defined(DEBUG)
printf("RTCP: %02x %"PRIx64" %x\n", s->payload_type, VAR_1, s->timestamp);
#endif
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = VAR_1;
s->last_rtcp_ntp_time = VAR_1;
rtp_ts = av_rescale_q(VAR_1 - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,
VAR_0->streams[0]->time_base) + s->base_timestamp;
put_byte(VAR_0->pb, (RTP_VERSION << 6));
put_byte(VAR_0->pb, 200);
put_be16(VAR_0->pb, 6);
put_be32(VAR_0->pb, s->ssrc);
put_be32(VAR_0->pb, VAR_1 / 1000000);
put_be32(VAR_0->pb, ((VAR_1 % 1000000) << 32) / 1000000);
put_be32(VAR_0->pb, rtp_ts);
put_be32(VAR_0->pb, s->packet_count);
put_be32(VAR_0->pb, s->octet_count);
put_flush_packet(VAR_0->pb);
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, int64_t VAR_1)\n{",
"RTPDemuxContext *s = VAR_0->priv_data;",
"uint32_t rtp_ts;",
"#if defined(DEBUG)\nprintf(\"RTCP: %02x %\"PRIx64\" %x\\n\", s->payload_type, VAR_1, s->timestamp);",
"#endif\nif (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = VAR_1;",
"s->last_rtcp_ntp_time = VAR_1;",
"rtp_ts = av_rescale_q(VAR_1 - s->first_rtcp_ntp_time, AV_TIME_BASE_Q,\nVAR_0->streams[0]->time_base) + s->base_timestamp;",
"put_byte(VAR_0->pb, (RTP_VERSION << 6));",
"put_byte(VAR_0->pb, 200);",
"put_be16(VAR_0->pb, 6);",
"put_be32(VAR_0->pb, s->ssrc);",
"put_be32(VAR_0->pb, VAR_1 / 1000000);",
"put_be32(VAR_0->pb, ((VAR_1 % 1000000) << 32) / 1000000);",
"put_be32(VAR_0->pb, rtp_ts);",
"put_be32(VAR_0->pb, s->packet_count);",
"put_be32(VAR_0->pb, s->octet_count);",
"put_flush_packet(VAR_0->pb);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
25,158 | static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Error *err = NULL;
VirtIOBalloon *s = opaque;
int i;
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int(v, "last-update", &s->stats_last_update, &err);
if (err) {
goto out_end;
}
visit_start_struct(v, "stats", NULL, 0, &err);
if (err) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err);
if (err) {
break;
}
}
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, &err);
out_end:
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, &err);
out:
error_propagate(errp, err);
}
| true | qemu | 15c2f669e3fb2bc97f7b42d1871f595c0ac24af8 | static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Error *err = NULL;
VirtIOBalloon *s = opaque;
int i;
visit_start_struct(v, name, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int(v, "last-update", &s->stats_last_update, &err);
if (err) {
goto out_end;
}
visit_start_struct(v, "stats", NULL, 0, &err);
if (err) {
goto out_end;
}
for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err);
if (err) {
break;
}
}
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, &err);
out_end:
error_propagate(errp, err);
err = NULL;
visit_end_struct(v, &err);
out:
error_propagate(errp, err);
}
| {
"code": [
" break;",
" error_propagate(errp, err);",
" err = NULL;",
" visit_end_struct(v, &err);",
" error_propagate(errp, err);",
" err = NULL;",
" visit_end_struct(v, &err);",
" error_propagate(errp, err);",
" err = NULL;",
" goto out;",
" error_propagate(errp, err);",
" err = NULL;",
" visit_end_struct(v, &err);"
],
"line_no": [
47,
53,
55,
57,
53,
55,
57,
53,
55,
19,
53,
55,
57
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,
void *VAR_3, Error **VAR_4)
{
Error *err = NULL;
VirtIOBalloon *s = VAR_3;
int VAR_5;
visit_start_struct(VAR_1, VAR_2, NULL, 0, &err);
if (err) {
goto out;
}
visit_type_int(VAR_1, "last-update", &s->stats_last_update, &err);
if (err) {
goto out_end;
}
visit_start_struct(VAR_1, "stats", NULL, 0, &err);
if (err) {
goto out_end;
}
for (VAR_5 = 0; VAR_5 < VIRTIO_BALLOON_S_NR; VAR_5++) {
visit_type_uint64(VAR_1, balloon_stat_names[VAR_5], &s->stats[VAR_5], &err);
if (err) {
break;
}
}
error_propagate(VAR_4, err);
err = NULL;
visit_end_struct(VAR_1, &err);
out_end:
error_propagate(VAR_4, err);
err = NULL;
visit_end_struct(VAR_1, &err);
out:
error_propagate(VAR_4, err);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"Error *err = NULL;",
"VirtIOBalloon *s = VAR_3;",
"int VAR_5;",
"visit_start_struct(VAR_1, VAR_2, NULL, 0, &err);",
"if (err) {",
"goto out;",
"}",
"visit_type_int(VAR_1, \"last-update\", &s->stats_last_update, &err);",
"if (err) {",
"goto out_end;",
"}",
"visit_start_struct(VAR_1, \"stats\", NULL, 0, &err);",
"if (err) {",
"goto out_end;",
"}",
"for (VAR_5 = 0; VAR_5 < VIRTIO_BALLOON_S_NR; VAR_5++) {",
"visit_type_uint64(VAR_1, balloon_stat_names[VAR_5], &s->stats[VAR_5], &err);",
"if (err) {",
"break;",
"}",
"}",
"error_propagate(VAR_4, err);",
"err = NULL;",
"visit_end_struct(VAR_1, &err);",
"out_end:\nerror_propagate(VAR_4, err);",
"err = NULL;",
"visit_end_struct(VAR_1, &err);",
"out:\nerror_propagate(VAR_4, err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
]
] |
25,159 | envlist_setenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry = NULL;
const char *eq_sign;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
/* find out first equals sign in given env */
if ((eq_sign = strchr(env, '=')) == NULL)
return (EINVAL);
envname_len = eq_sign - env + 1;
/*
* If there already exists variable with given name
* we remove and release it before allocating a whole
* new entry.
*/
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
QLIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
} else {
envlist->el_count++;
}
if ((entry = malloc(sizeof (*entry))) == NULL)
return (errno);
if ((entry->ev_var = strdup(env)) == NULL) {
free(entry);
return (errno);
}
QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
return (0);
}
| true | qemu | ec45bbe5f1921c6553fbf9c0c76b358b0403c22d | envlist_setenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry = NULL;
const char *eq_sign;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
if ((eq_sign = strchr(env, '=')) == NULL)
return (EINVAL);
envname_len = eq_sign - env + 1;
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
QLIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
} else {
envlist->el_count++;
}
if ((entry = malloc(sizeof (*entry))) == NULL)
return (errno);
if ((entry->ev_var = strdup(env)) == NULL) {
free(entry);
return (errno);
}
QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
return (0);
}
| {
"code": [
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);",
"\t\treturn (errno);",
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);",
"\tif ((entry = malloc(sizeof (*entry))) == NULL)",
"\t\treturn (errno);",
"\tif ((entry->ev_var = strdup(env)) == NULL) {",
"\t\tfree(entry);",
"\t\treturn (errno);",
"\t\tfree((char *)entry->ev_var);",
"\t\tfree(entry);"
],
"line_no": [
55,
57,
69,
55,
57,
67,
69,
71,
57,
69,
55,
57
]
} | FUNC_0(envlist_t *VAR_0, const char *VAR_1)
{
struct envlist_entry *VAR_2 = NULL;
const char *VAR_3;
size_t envname_len;
if ((VAR_0 == NULL) || (VAR_1 == NULL))
return (EINVAL);
if ((VAR_3 = strchr(VAR_1, '=')) == NULL)
return (EINVAL);
envname_len = VAR_3 - VAR_1 + 1;
for (VAR_2 = VAR_0->el_entries.lh_first; VAR_2 != NULL;
VAR_2 = VAR_2->ev_link.le_next) {
if (strncmp(VAR_2->ev_var, VAR_1, envname_len) == 0)
break;
}
if (VAR_2 != NULL) {
QLIST_REMOVE(VAR_2, ev_link);
free((char *)VAR_2->ev_var);
free(VAR_2);
} else {
VAR_0->el_count++;
}
if ((VAR_2 = malloc(sizeof (*VAR_2))) == NULL)
return (errno);
if ((VAR_2->ev_var = strdup(VAR_1)) == NULL) {
free(VAR_2);
return (errno);
}
QLIST_INSERT_HEAD(&VAR_0->el_entries, VAR_2, ev_link);
return (0);
}
| [
"FUNC_0(envlist_t *VAR_0, const char *VAR_1)\n{",
"struct envlist_entry *VAR_2 = NULL;",
"const char *VAR_3;",
"size_t envname_len;",
"if ((VAR_0 == NULL) || (VAR_1 == NULL))\nreturn (EINVAL);",
"if ((VAR_3 = strchr(VAR_1, '=')) == NULL)\nreturn (EINVAL);",
"envname_len = VAR_3 - VAR_1 + 1;",
"for (VAR_2 = VAR_0->el_entries.lh_first; VAR_2 != NULL;",
"VAR_2 = VAR_2->ev_link.le_next) {",
"if (strncmp(VAR_2->ev_var, VAR_1, envname_len) == 0)\nbreak;",
"}",
"if (VAR_2 != NULL) {",
"QLIST_REMOVE(VAR_2, ev_link);",
"free((char *)VAR_2->ev_var);",
"free(VAR_2);",
"} else {",
"VAR_0->el_count++;",
"}",
"if ((VAR_2 = malloc(sizeof (*VAR_2))) == NULL)\nreturn (errno);",
"if ((VAR_2->ev_var = strdup(VAR_1)) == NULL) {",
"free(VAR_2);",
"return (errno);",
"}",
"QLIST_INSERT_HEAD(&VAR_0->el_entries, VAR_2, ev_link);",
"return (0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
21,
23
],
[
25
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
25,160 | static inline int check_ap(CPUARMState *env, int ap, int domain_prot,
int access_type, int is_user)
{
int prot_ro;
if (domain_prot == 3) {
return PAGE_READ | PAGE_WRITE;
}
if (access_type == 1)
prot_ro = 0;
else
prot_ro = PAGE_READ;
switch (ap) {
case 0:
if (access_type == 1)
return 0;
switch ((env->cp15.c1_sys >> 8) & 3) {
case 1:
return is_user ? 0 : PAGE_READ;
case 2:
return PAGE_READ;
default:
return 0;
}
case 1:
return is_user ? 0 : PAGE_READ | PAGE_WRITE;
case 2:
if (is_user)
return prot_ro;
else
return PAGE_READ | PAGE_WRITE;
case 3:
return PAGE_READ | PAGE_WRITE;
case 4: /* Reserved. */
return 0;
case 5:
return is_user ? 0 : prot_ro;
case 6:
return prot_ro;
case 7:
if (!arm_feature (env, ARM_FEATURE_V6K))
return 0;
return prot_ro;
default:
abort();
}
}
| false | qemu | 76e3e1bcaefe0da394f328854cb72f9449f23732 | static inline int check_ap(CPUARMState *env, int ap, int domain_prot,
int access_type, int is_user)
{
int prot_ro;
if (domain_prot == 3) {
return PAGE_READ | PAGE_WRITE;
}
if (access_type == 1)
prot_ro = 0;
else
prot_ro = PAGE_READ;
switch (ap) {
case 0:
if (access_type == 1)
return 0;
switch ((env->cp15.c1_sys >> 8) & 3) {
case 1:
return is_user ? 0 : PAGE_READ;
case 2:
return PAGE_READ;
default:
return 0;
}
case 1:
return is_user ? 0 : PAGE_READ | PAGE_WRITE;
case 2:
if (is_user)
return prot_ro;
else
return PAGE_READ | PAGE_WRITE;
case 3:
return PAGE_READ | PAGE_WRITE;
case 4:
return 0;
case 5:
return is_user ? 0 : prot_ro;
case 6:
return prot_ro;
case 7:
if (!arm_feature (env, ARM_FEATURE_V6K))
return 0;
return prot_ro;
default:
abort();
}
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(CPUARMState *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4)
{
int VAR_5;
if (VAR_2 == 3) {
return PAGE_READ | PAGE_WRITE;
}
if (VAR_3 == 1)
VAR_5 = 0;
else
VAR_5 = PAGE_READ;
switch (VAR_1) {
case 0:
if (VAR_3 == 1)
return 0;
switch ((VAR_0->cp15.c1_sys >> 8) & 3) {
case 1:
return VAR_4 ? 0 : PAGE_READ;
case 2:
return PAGE_READ;
default:
return 0;
}
case 1:
return VAR_4 ? 0 : PAGE_READ | PAGE_WRITE;
case 2:
if (VAR_4)
return VAR_5;
else
return PAGE_READ | PAGE_WRITE;
case 3:
return PAGE_READ | PAGE_WRITE;
case 4:
return 0;
case 5:
return VAR_4 ? 0 : VAR_5;
case 6:
return VAR_5;
case 7:
if (!arm_feature (VAR_0, ARM_FEATURE_V6K))
return 0;
return VAR_5;
default:
abort();
}
}
| [
"static inline int FUNC_0(CPUARMState *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4)\n{",
"int VAR_5;",
"if (VAR_2 == 3) {",
"return PAGE_READ | PAGE_WRITE;",
"}",
"if (VAR_3 == 1)\nVAR_5 = 0;",
"else\nVAR_5 = PAGE_READ;",
"switch (VAR_1) {",
"case 0:\nif (VAR_3 == 1)\nreturn 0;",
"switch ((VAR_0->cp15.c1_sys >> 8) & 3) {",
"case 1:\nreturn VAR_4 ? 0 : PAGE_READ;",
"case 2:\nreturn PAGE_READ;",
"default:\nreturn 0;",
"}",
"case 1:\nreturn VAR_4 ? 0 : PAGE_READ | PAGE_WRITE;",
"case 2:\nif (VAR_4)\nreturn VAR_5;",
"else\nreturn PAGE_READ | PAGE_WRITE;",
"case 3:\nreturn PAGE_READ | PAGE_WRITE;",
"case 4:\nreturn 0;",
"case 5:\nreturn VAR_4 ? 0 : VAR_5;",
"case 6:\nreturn VAR_5;",
"case 7:\nif (!arm_feature (VAR_0, ARM_FEATURE_V6K))\nreturn 0;",
"return VAR_5;",
"default:\nabort();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23,
25
],
[
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
]
] |
25,161 | static void test_mirror(void)
{
int send_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello! filter-mirror~";
char sock_path[] = "filter-mirror.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, send_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device e1000,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=mirror0,path=%s,server,nowait "
"-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
, send_sock[1], sock_path);
qtest_start(cmdline);
g_free(cmdline);
recv_sock = unix_connect(sock_path, NULL);
g_assert_cmpint(recv_sock, !=, -1);
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
/* send a qmp command to guarantee that 'connected' is setting to true. */
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
close(recv_sock);
unlink(sock_path);
}
| false | qemu | ea5bef49eadd240c7924f287f2da1bb457a3f92c | static void test_mirror(void)
{
int send_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
char send_buf[] = "Hello! filter-mirror~";
char sock_path[] = "filter-mirror.XXXXXX";
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, send_sock);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(sock_path);
g_assert_cmpint(ret, !=, -1);
cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device e1000,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=mirror0,path=%s,server,nowait "
"-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
, send_sock[1], sock_path);
qtest_start(cmdline);
g_free(cmdline);
recv_sock = unix_connect(sock_path, NULL);
g_assert_cmpint(recv_sock, !=, -1);
struct iovec iov[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = send_buf,
.iov_len = sizeof(send_buf),
},
};
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock[0]);
ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
ret = qemu_recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
close(recv_sock);
unlink(sock_path);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0[2], VAR_1;
char *VAR_2;
uint32_t ret = 0, len = 0;
char VAR_3[] = "Hello! filter-mirror~";
char VAR_4[] = "filter-mirror.XXXXXX";
char *VAR_5;
uint32_t size = sizeof(VAR_3);
size = htonl(size);
ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);
g_assert_cmpint(ret, !=, -1);
ret = mkstemp(VAR_4);
g_assert_cmpint(ret, !=, -1);
VAR_2 = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device e1000,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=mirror0,path=%s,server,nowait "
"-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
, VAR_0[1], VAR_4);
qtest_start(VAR_2);
g_free(VAR_2);
VAR_1 = unix_connect(VAR_4, NULL);
g_assert_cmpint(VAR_1, !=, -1);
struct iovec VAR_6[] = {
{
.iov_base = &size,
.iov_len = sizeof(size),
}, {
.iov_base = VAR_3,
.iov_len = sizeof(VAR_3),
},
};
qmp_discard_response("{ 'execute' : 'query-status'}");
ret = iov_send(VAR_0[0], VAR_6, 2, 0, sizeof(size) + sizeof(VAR_3));
g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));
close(VAR_0[0]);
ret = qemu_recv(VAR_1, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(VAR_3));
VAR_5 = g_malloc(len);
ret = qemu_recv(VAR_1, VAR_5, len, 0);
g_assert_cmpstr(VAR_5, ==, VAR_3);
g_free(VAR_5);
close(VAR_1);
unlink(VAR_4);
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0[2], VAR_1;",
"char *VAR_2;",
"uint32_t ret = 0, len = 0;",
"char VAR_3[] = \"Hello! filter-mirror~\";",
"char VAR_4[] = \"filter-mirror.XXXXXX\";",
"char *VAR_5;",
"uint32_t size = sizeof(VAR_3);",
"size = htonl(size);",
"ret = socketpair(PF_UNIX, SOCK_STREAM, 0, VAR_0);",
"g_assert_cmpint(ret, !=, -1);",
"ret = mkstemp(VAR_4);",
"g_assert_cmpint(ret, !=, -1);",
"VAR_2 = g_strdup_printf(\"-netdev socket,id=qtest-bn0,fd=%d \"\n\"-device e1000,netdev=qtest-bn0,id=qtest-e0 \"\n\"-chardev socket,id=mirror0,path=%s,server,nowait \"\n\"-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 \"\n, VAR_0[1], VAR_4);",
"qtest_start(VAR_2);",
"g_free(VAR_2);",
"VAR_1 = unix_connect(VAR_4, NULL);",
"g_assert_cmpint(VAR_1, !=, -1);",
"struct iovec VAR_6[] = {",
"{",
".iov_base = &size,\n.iov_len = sizeof(size),\n}, {",
".iov_base = VAR_3,\n.iov_len = sizeof(VAR_3),\n},",
"};",
"qmp_discard_response(\"{ 'execute' : 'query-status'}\");",
"ret = iov_send(VAR_0[0], VAR_6, 2, 0, sizeof(size) + sizeof(VAR_3));",
"g_assert_cmpint(ret, ==, sizeof(VAR_3) + sizeof(size));",
"close(VAR_0[0]);",
"ret = qemu_recv(VAR_1, &len, sizeof(len), 0);",
"g_assert_cmpint(ret, ==, sizeof(len));",
"len = ntohl(len);",
"g_assert_cmpint(len, ==, sizeof(VAR_3));",
"VAR_5 = g_malloc(len);",
"ret = qemu_recv(VAR_1, VAR_5, len, 0);",
"g_assert_cmpstr(VAR_5, ==, VAR_3);",
"g_free(VAR_5);",
"close(VAR_1);",
"unlink(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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35,
37,
39,
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67,
69,
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
]
] |
25,162 | S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
{
S390PCIBusDevice *pbdev;
int i;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s || !fh) {
return NULL;
}
for (i = 0; i < PCI_SLOT_MAX; i++) {
pbdev = &s->pbdev[i];
if (pbdev->fh == fh) {
return pbdev;
}
}
return NULL;
}
| false | qemu | e7d336959b7c01699702dcda4b54a822972d74a8 | S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
{
S390PCIBusDevice *pbdev;
int i;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s || !fh) {
return NULL;
}
for (i = 0; i < PCI_SLOT_MAX; i++) {
pbdev = &s->pbdev[i];
if (pbdev->fh == fh) {
return pbdev;
}
}
return NULL;
}
| {
"code": [],
"line_no": []
} | S390PCIBusDevice *FUNC_0(uint32_t fh)
{
S390PCIBusDevice *pbdev;
int VAR_0;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s || !fh) {
return NULL;
}
for (VAR_0 = 0; VAR_0 < PCI_SLOT_MAX; VAR_0++) {
pbdev = &s->pbdev[VAR_0];
if (pbdev->fh == fh) {
return pbdev;
}
}
return NULL;
}
| [
"S390PCIBusDevice *FUNC_0(uint32_t fh)\n{",
"S390PCIBusDevice *pbdev;",
"int VAR_0;",
"S390pciState *s = S390_PCI_HOST_BRIDGE(\nobject_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));",
"if (!s || !fh) {",
"return NULL;",
"}",
"for (VAR_0 = 0; VAR_0 < PCI_SLOT_MAX; VAR_0++) {",
"pbdev = &s->pbdev[VAR_0];",
"if (pbdev->fh == fh) {",
"return pbdev;",
"}",
"}",
"return NULL;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
25,164 | static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) {
static const int significant_coeff_flag_offset[2][6] = {
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
};
static const int last_coeff_flag_offset[2][6] = {
{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
};
static const int coeff_abs_level_m1_offset[6] = {
227+0, 227+10, 227+20, 227+30, 227+39, 426
};
static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
};
/* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
* 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
* map node ctx => cabac ctx for level=1 */
static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
/* map node ctx => cabac ctx for level>1 */
static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
static const uint8_t coeff_abs_level_transition[2][8] = {
/* update node ctx after decoding a level=1 */
{ 1, 2, 3, 3, 4, 5, 6, 7 },
/* update node ctx after decoding a level>1 */
{ 4, 4, 4, 4, 5, 6, 7, 7 }
};
int index[64];
int av_unused last;
int coeff_count = 0;
int node_ctx = 0;
uint8_t *significant_coeff_ctx_base;
uint8_t *last_coeff_ctx_base;
uint8_t *abs_level_m1_ctx_base;
#ifndef ARCH_X86
#define CABAC_ON_STACK
#endif
#ifdef CABAC_ON_STACK
#define CC &cc
CABACContext cc;
cc.range = h->cabac.range;
cc.low = h->cabac.low;
cc.bytestream= h->cabac.bytestream;
#else
#define CC &h->cabac
#endif
/* cat: 0-> DC 16x16 n = 0
* 1-> AC 16x16 n = luma4x4idx
* 2-> Luma4x4 n = luma4x4idx
* 3-> DC Chroma n = iCbCr
* 4-> AC Chroma n = 4 * iCbCr + chroma4x4idx
* 5-> Luma8x8 n = 4 * luma8x8idx
*/
/* read coded block flag */
if( cat != 5 ) {
if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n ) ] ) == 0 ) {
if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = 0;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = 0;
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
return;
}
}
significant_coeff_ctx_base = h->cabac_state
+ significant_coeff_flag_offset[MB_FIELD][cat];
last_coeff_ctx_base = h->cabac_state
+ last_coeff_flag_offset[MB_FIELD][cat];
abs_level_m1_ctx_base = h->cabac_state
+ coeff_abs_level_m1_offset[cat];
if( cat == 5 ) {
#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
if( get_cabac( CC, sig_ctx )) { \
uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
index[coeff_count++] = last; \
if( get_cabac( CC, last_ctx ) ) { \
last= max_coeff; \
break; \
} \
} \
}\
if( last == max_coeff -1 ) {\
index[coeff_count++] = last;\
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
#if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS)
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, sig_off);
} else {
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index);
#else
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
} else {
DECODE_SIGNIFICANCE( max_coeff - 1, last, last );
#endif
}
assert(coeff_count > 0);
if( cat == 0 )
h->cbp_table[h->mb_xy] |= 0x100;
else if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = coeff_count;
else if( cat == 3 )
h->cbp_table[h->mb_xy] |= 0x40 << n;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = coeff_count;
else {
assert( cat == 5 );
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
}
for( coeff_count--; coeff_count >= 0; coeff_count-- ) {
uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;
int j= scantable[index[coeff_count]];
if( get_cabac( CC, ctx ) == 0 ) {
node_ctx = coeff_abs_level_transition[0][node_ctx];
if( !qmul ) {
block[j] = get_cabac_bypass_sign( CC, -1);
}else{
block[j] = (get_cabac_bypass_sign( CC, -qmul[j]) + 32) >> 6;
}
} else {
int coeff_abs = 2;
ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base;
node_ctx = coeff_abs_level_transition[1][node_ctx];
while( coeff_abs < 15 && get_cabac( CC, ctx ) ) {
coeff_abs++;
}
if( coeff_abs >= 15 ) {
int j = 0;
while( get_cabac_bypass( CC ) ) {
j++;
}
coeff_abs=1;
while( j-- ) {
coeff_abs += coeff_abs + get_cabac_bypass( CC );
}
coeff_abs+= 14;
}
if( !qmul ) {
if( get_cabac_bypass( CC ) ) block[j] = -coeff_abs;
else block[j] = coeff_abs;
}else{
if( get_cabac_bypass( CC ) ) block[j] = (-coeff_abs * qmul[j] + 32) >> 6;
else block[j] = ( coeff_abs * qmul[j] + 32) >> 6;
}
}
}
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
}
| false | FFmpeg | 9588ec340c3f33c7474b4cd2893046cfdaee42bf | static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) {
static const int significant_coeff_flag_offset[2][6] = {
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
};
static const int last_coeff_flag_offset[2][6] = {
{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
};
static const int coeff_abs_level_m1_offset[6] = {
227+0, 227+10, 227+20, 227+30, 227+39, 426
};
static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
};
static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
static const uint8_t coeff_abs_level_transition[2][8] = {
{ 1, 2, 3, 3, 4, 5, 6, 7 },
{ 4, 4, 4, 4, 5, 6, 7, 7 }
};
int index[64];
int av_unused last;
int coeff_count = 0;
int node_ctx = 0;
uint8_t *significant_coeff_ctx_base;
uint8_t *last_coeff_ctx_base;
uint8_t *abs_level_m1_ctx_base;
#ifndef ARCH_X86
#define CABAC_ON_STACK
#endif
#ifdef CABAC_ON_STACK
#define CC &cc
CABACContext cc;
cc.range = h->cabac.range;
cc.low = h->cabac.low;
cc.bytestream= h->cabac.bytestream;
#else
#define CC &h->cabac
#endif
if( cat != 5 ) {
if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n ) ] ) == 0 ) {
if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = 0;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = 0;
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
return;
}
}
significant_coeff_ctx_base = h->cabac_state
+ significant_coeff_flag_offset[MB_FIELD][cat];
last_coeff_ctx_base = h->cabac_state
+ last_coeff_flag_offset[MB_FIELD][cat];
abs_level_m1_ctx_base = h->cabac_state
+ coeff_abs_level_m1_offset[cat];
if( cat == 5 ) {
#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
if( get_cabac( CC, sig_ctx )) { \
uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
index[coeff_count++] = last; \
if( get_cabac( CC, last_ctx ) ) { \
last= max_coeff; \
break; \
} \
} \
}\
if( last == max_coeff -1 ) {\
index[coeff_count++] = last;\
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
#if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS)
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, sig_off);
} else {
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index);
#else
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
} else {
DECODE_SIGNIFICANCE( max_coeff - 1, last, last );
#endif
}
assert(coeff_count > 0);
if( cat == 0 )
h->cbp_table[h->mb_xy] |= 0x100;
else if( cat == 1 || cat == 2 )
h->non_zero_count_cache[scan8[n]] = coeff_count;
else if( cat == 3 )
h->cbp_table[h->mb_xy] |= 0x40 << n;
else if( cat == 4 )
h->non_zero_count_cache[scan8[16+n]] = coeff_count;
else {
assert( cat == 5 );
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
}
for( coeff_count--; coeff_count >= 0; coeff_count-- ) {
uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;
int j= scantable[index[coeff_count]];
if( get_cabac( CC, ctx ) == 0 ) {
node_ctx = coeff_abs_level_transition[0][node_ctx];
if( !qmul ) {
block[j] = get_cabac_bypass_sign( CC, -1);
}else{
block[j] = (get_cabac_bypass_sign( CC, -qmul[j]) + 32) >> 6;
}
} else {
int coeff_abs = 2;
ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base;
node_ctx = coeff_abs_level_transition[1][node_ctx];
while( coeff_abs < 15 && get_cabac( CC, ctx ) ) {
coeff_abs++;
}
if( coeff_abs >= 15 ) {
int j = 0;
while( get_cabac_bypass( CC ) ) {
j++;
}
coeff_abs=1;
while( j-- ) {
coeff_abs += coeff_abs + get_cabac_bypass( CC );
}
coeff_abs+= 14;
}
if( !qmul ) {
if( get_cabac_bypass( CC ) ) block[j] = -coeff_abs;
else block[j] = coeff_abs;
}else{
if( get_cabac_bypass( CC ) ) block[j] = (-coeff_abs * qmul[j] + 32) >> 6;
else block[j] = ( coeff_abs * qmul[j] + 32) >> 6;
}
}
}
#ifdef CABAC_ON_STACK
h->cabac.range = cc.range ;
h->cabac.low = cc.low ;
h->cabac.bytestream= cc.bytestream;
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, DCTELEM *VAR_1, int VAR_2, int VAR_3, const uint8_t *VAR_4, const uint32_t *VAR_5, int VAR_6) {
static const int VAR_7[2][6] = {
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
};
static const int VAR_8[2][6] = {
{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },
{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }
};
static const int VAR_9[6] = {
227+0, 227+10, 227+20, 227+30, 227+39, 426
};
static const uint8_t VAR_10[2][63] = {
{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
};
static const uint8_t VAR_11[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
static const uint8_t VAR_12[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
static const uint8_t VAR_13[2][8] = {
{ 1, 2, 3, 3, 4, 5, 6, 7 },
{ 4, 4, 4, 4, 5, 6, 7, 7 }
};
int VAR_14[64];
int VAR_15 last;
int VAR_16 = 0;
int VAR_17 = 0;
uint8_t *significant_coeff_ctx_base;
uint8_t *last_coeff_ctx_base;
uint8_t *abs_level_m1_ctx_base;
#ifndef ARCH_X86
#define CABAC_ON_STACK
#endif
#ifdef CABAC_ON_STACK
#define CC &cc
CABACContext cc;
cc.range = VAR_0->cabac.range;
cc.low = VAR_0->cabac.low;
cc.bytestream= VAR_0->cabac.bytestream;
#else
#define CC &VAR_0->cabac
#endif
if( VAR_2 != 5 ) {
if( get_cabac( CC, &VAR_0->cabac_state[85 + get_cabac_cbf_ctx( VAR_0, VAR_2, VAR_3 ) ] ) == 0 ) {
if( VAR_2 == 1 || VAR_2 == 2 )
VAR_0->non_zero_count_cache[scan8[VAR_3]] = 0;
else if( VAR_2 == 4 )
VAR_0->non_zero_count_cache[scan8[16+VAR_3]] = 0;
#ifdef CABAC_ON_STACK
VAR_0->cabac.range = cc.range ;
VAR_0->cabac.low = cc.low ;
VAR_0->cabac.bytestream= cc.bytestream;
#endif
return;
}
}
significant_coeff_ctx_base = VAR_0->cabac_state
+ VAR_7[MB_FIELD][VAR_2];
last_coeff_ctx_base = VAR_0->cabac_state
+ VAR_8[MB_FIELD][VAR_2];
abs_level_m1_ctx_base = VAR_0->cabac_state
+ VAR_9[VAR_2];
if( VAR_2 == 5 ) {
#define DECODE_SIGNIFICANCE( coefs, VAR_18, last_off ) \
for(last= 0; last < coefs; last++) { \
uint8_t *sig_ctx = significant_coeff_ctx_base + VAR_18; \
if( get_cabac( CC, sig_ctx )) { \
uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
VAR_14[VAR_16++] = last; \
if( get_cabac( CC, last_ctx ) ) { \
last= VAR_6; \
break; \
} \
} \
}\
if( last == VAR_6 -1 ) {\
VAR_14[VAR_16++] = last;\
}
const uint8_t *VAR_18 = VAR_10[MB_FIELD];
#if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS)
VAR_16= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, VAR_14, VAR_18);
} else {
VAR_16= decode_significance_x86(CC, VAR_6, significant_coeff_ctx_base, VAR_14);
#else
DECODE_SIGNIFICANCE( 63, VAR_18[last], last_coeff_flag_offset_8x8[last] );
} else {
DECODE_SIGNIFICANCE( VAR_6 - 1, last, last );
#endif
}
assert(VAR_16 > 0);
if( VAR_2 == 0 )
VAR_0->cbp_table[VAR_0->mb_xy] |= 0x100;
else if( VAR_2 == 1 || VAR_2 == 2 )
VAR_0->non_zero_count_cache[scan8[VAR_3]] = VAR_16;
else if( VAR_2 == 3 )
VAR_0->cbp_table[VAR_0->mb_xy] |= 0x40 << VAR_3;
else if( VAR_2 == 4 )
VAR_0->non_zero_count_cache[scan8[16+VAR_3]] = VAR_16;
else {
assert( VAR_2 == 5 );
fill_rectangle(&VAR_0->non_zero_count_cache[scan8[VAR_3]], 2, 2, 8, VAR_16, 1);
}
for( VAR_16--; VAR_16 >= 0; VAR_16-- ) {
uint8_t *ctx = VAR_11[VAR_17] + abs_level_m1_ctx_base;
int VAR_21= VAR_4[VAR_14[VAR_16]];
if( get_cabac( CC, ctx ) == 0 ) {
VAR_17 = VAR_13[0][VAR_17];
if( !VAR_5 ) {
VAR_1[VAR_21] = get_cabac_bypass_sign( CC, -1);
}else{
VAR_1[VAR_21] = (get_cabac_bypass_sign( CC, -VAR_5[VAR_21]) + 32) >> 6;
}
} else {
int VAR_20 = 2;
ctx = VAR_12[VAR_17] + abs_level_m1_ctx_base;
VAR_17 = VAR_13[1][VAR_17];
while( VAR_20 < 15 && get_cabac( CC, ctx ) ) {
VAR_20++;
}
if( VAR_20 >= 15 ) {
int VAR_21 = 0;
while( get_cabac_bypass( CC ) ) {
VAR_21++;
}
VAR_20=1;
while( VAR_21-- ) {
VAR_20 += VAR_20 + get_cabac_bypass( CC );
}
VAR_20+= 14;
}
if( !VAR_5 ) {
if( get_cabac_bypass( CC ) ) VAR_1[VAR_21] = -VAR_20;
else VAR_1[VAR_21] = VAR_20;
}else{
if( get_cabac_bypass( CC ) ) VAR_1[VAR_21] = (-VAR_20 * VAR_5[VAR_21] + 32) >> 6;
else VAR_1[VAR_21] = ( VAR_20 * VAR_5[VAR_21] + 32) >> 6;
}
}
}
#ifdef CABAC_ON_STACK
VAR_0->cabac.range = cc.range ;
VAR_0->cabac.low = cc.low ;
VAR_0->cabac.bytestream= cc.bytestream;
#endif
}
| [
"static void FUNC_0( H264Context *VAR_0, DCTELEM *VAR_1, int VAR_2, int VAR_3, const uint8_t *VAR_4, const uint32_t *VAR_5, int VAR_6) {",
"static const int VAR_7[2][6] = {",
"{ 105+0, 105+15, 105+29, 105+44, 105+47, 402 },",
"{ 277+0, 277+15, 277+29, 277+44, 277+47, 436 }",
"};",
"static const int VAR_8[2][6] = {",
"{ 166+0, 166+15, 166+29, 166+44, 166+47, 417 },",
"{ 338+0, 338+15, 338+29, 338+44, 338+47, 451 }",
"};",
"static const int VAR_9[6] = {",
"227+0, 227+10, 227+20, 227+30, 227+39, 426\n};",
"static const uint8_t VAR_10[2][63] = {",
"{ 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,",
"4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,\n7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,\n12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },",
"{ 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,",
"6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,\n9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,\n9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }",
"};",
"static const uint8_t VAR_11[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };",
"static const uint8_t VAR_12[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };",
"static const uint8_t VAR_13[2][8] = {",
"{ 1, 2, 3, 3, 4, 5, 6, 7 },",
"{ 4, 4, 4, 4, 5, 6, 7, 7 }",
"};",
"int VAR_14[64];",
"int VAR_15 last;",
"int VAR_16 = 0;",
"int VAR_17 = 0;",
"uint8_t *significant_coeff_ctx_base;",
"uint8_t *last_coeff_ctx_base;",
"uint8_t *abs_level_m1_ctx_base;",
"#ifndef ARCH_X86\n#define CABAC_ON_STACK\n#endif\n#ifdef CABAC_ON_STACK\n#define CC &cc\nCABACContext cc;",
"cc.range = VAR_0->cabac.range;",
"cc.low = VAR_0->cabac.low;",
"cc.bytestream= VAR_0->cabac.bytestream;",
"#else\n#define CC &VAR_0->cabac\n#endif\nif( VAR_2 != 5 ) {",
"if( get_cabac( CC, &VAR_0->cabac_state[85 + get_cabac_cbf_ctx( VAR_0, VAR_2, VAR_3 ) ] ) == 0 ) {",
"if( VAR_2 == 1 || VAR_2 == 2 )\nVAR_0->non_zero_count_cache[scan8[VAR_3]] = 0;",
"else if( VAR_2 == 4 )\nVAR_0->non_zero_count_cache[scan8[16+VAR_3]] = 0;",
"#ifdef CABAC_ON_STACK\nVAR_0->cabac.range = cc.range ;",
"VAR_0->cabac.low = cc.low ;",
"VAR_0->cabac.bytestream= cc.bytestream;",
"#endif\nreturn;",
"}",
"}",
"significant_coeff_ctx_base = VAR_0->cabac_state\n+ VAR_7[MB_FIELD][VAR_2];",
"last_coeff_ctx_base = VAR_0->cabac_state\n+ VAR_8[MB_FIELD][VAR_2];",
"abs_level_m1_ctx_base = VAR_0->cabac_state\n+ VAR_9[VAR_2];",
"if( VAR_2 == 5 ) {",
"#define DECODE_SIGNIFICANCE( coefs, VAR_18, last_off ) \\\nfor(last= 0; last < coefs; last++) { \\",
"uint8_t *sig_ctx = significant_coeff_ctx_base + VAR_18; \\",
"if( get_cabac( CC, sig_ctx )) { \\",
"uint8_t *last_ctx = last_coeff_ctx_base + last_off; \\",
"VAR_14[VAR_16++] = last; \\",
"if( get_cabac( CC, last_ctx ) ) { \\",
"last= VAR_6; \\",
"break; \\",
"} \\",
"} \\",
"}\\",
"if( last == VAR_6 -1 ) {\\",
"VAR_14[VAR_16++] = last;\\",
"}",
"const uint8_t *VAR_18 = VAR_10[MB_FIELD];",
"#if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS)\nVAR_16= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, VAR_14, VAR_18);",
"} else {",
"VAR_16= decode_significance_x86(CC, VAR_6, significant_coeff_ctx_base, VAR_14);",
"#else\nDECODE_SIGNIFICANCE( 63, VAR_18[last], last_coeff_flag_offset_8x8[last] );",
"} else {",
"DECODE_SIGNIFICANCE( VAR_6 - 1, last, last );",
"#endif\n}",
"assert(VAR_16 > 0);",
"if( VAR_2 == 0 )\nVAR_0->cbp_table[VAR_0->mb_xy] |= 0x100;",
"else if( VAR_2 == 1 || VAR_2 == 2 )\nVAR_0->non_zero_count_cache[scan8[VAR_3]] = VAR_16;",
"else if( VAR_2 == 3 )\nVAR_0->cbp_table[VAR_0->mb_xy] |= 0x40 << VAR_3;",
"else if( VAR_2 == 4 )\nVAR_0->non_zero_count_cache[scan8[16+VAR_3]] = VAR_16;",
"else {",
"assert( VAR_2 == 5 );",
"fill_rectangle(&VAR_0->non_zero_count_cache[scan8[VAR_3]], 2, 2, 8, VAR_16, 1);",
"}",
"for( VAR_16--; VAR_16 >= 0; VAR_16-- ) {",
"uint8_t *ctx = VAR_11[VAR_17] + abs_level_m1_ctx_base;",
"int VAR_21= VAR_4[VAR_14[VAR_16]];",
"if( get_cabac( CC, ctx ) == 0 ) {",
"VAR_17 = VAR_13[0][VAR_17];",
"if( !VAR_5 ) {",
"VAR_1[VAR_21] = get_cabac_bypass_sign( CC, -1);",
"}else{",
"VAR_1[VAR_21] = (get_cabac_bypass_sign( CC, -VAR_5[VAR_21]) + 32) >> 6;",
"}",
"} else {",
"int VAR_20 = 2;",
"ctx = VAR_12[VAR_17] + abs_level_m1_ctx_base;",
"VAR_17 = VAR_13[1][VAR_17];",
"while( VAR_20 < 15 && get_cabac( CC, ctx ) ) {",
"VAR_20++;",
"}",
"if( VAR_20 >= 15 ) {",
"int VAR_21 = 0;",
"while( get_cabac_bypass( CC ) ) {",
"VAR_21++;",
"}",
"VAR_20=1;",
"while( VAR_21-- ) {",
"VAR_20 += VAR_20 + get_cabac_bypass( CC );",
"}",
"VAR_20+= 14;",
"}",
"if( !VAR_5 ) {",
"if( get_cabac_bypass( CC ) ) VAR_1[VAR_21] = -VAR_20;",
"else VAR_1[VAR_21] = VAR_20;",
"}else{",
"if( get_cabac_bypass( CC ) ) VAR_1[VAR_21] = (-VAR_20 * VAR_5[VAR_21] + 32) >> 6;",
"else VAR_1[VAR_21] = ( VAR_20 * VAR_5[VAR_21] + 32) >> 6;",
"}",
"}",
"}",
"#ifdef CABAC_ON_STACK\nVAR_0->cabac.range = cc.range ;",
"VAR_0->cabac.low = cc.low ;",
"VAR_0->cabac.bytestream= cc.bytestream;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
51
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91,
93,
95,
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109,
111,
113,
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
167,
169
],
[
171,
173
],
[
175,
177
],
[
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
],
[
239,
241
],
[
243,
245
],
[
247,
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
265
],
[
267
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351,
353
],
[
355
],
[
357
],
[
359,
363
]
] |
25,165 | static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
SerialState *s = opaque;
addr &= 7;
DPRINTF("write addr=0x%" HWADDR_PRIx " val=0x%" PRIx64 "\n", addr, val);
switch(addr) {
default:
case 0:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0xff00) | val;
serial_update_parameters(s);
} else {
s->thr = (uint8_t) val;
if(s->fcr & UART_FCR_FE) {
/* xmit overruns overwrite data, so make space if needed */
if (fifo8_is_full(&s->xmit_fifo)) {
fifo8_pop(&s->xmit_fifo);
}
fifo8_push(&s->xmit_fifo, s->thr);
}
s->thr_ipending = 0;
s->lsr &= ~UART_LSR_THRE;
s->lsr &= ~UART_LSR_TEMT;
serial_update_irq(s);
if (s->tsr_retry <= 0) {
serial_xmit(NULL, G_IO_OUT, s);
}
}
break;
case 1:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0x00ff) | (val << 8);
serial_update_parameters(s);
} else {
uint8_t changed = (s->ier ^ val) & 0x0f;
s->ier = val & 0x0f;
/* If the backend device is a real serial port, turn polling of the modem
* status lines on physical port on or off depending on UART_IER_MSI state.
*/
if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {
if (s->ier & UART_IER_MSI) {
s->poll_msl = 1;
serial_update_msl(s);
} else {
timer_del(s->modem_status_poll);
s->poll_msl = 0;
}
}
/* Turning on the THRE interrupt on IER can trigger the interrupt
* if LSR.THRE=1, even if it had been masked before by reading IIR.
* This is not in the datasheet, but Windows relies on it. It is
* unclear if THRE has to be resampled every time THRI becomes
* 1, or only on the rising edge. Bochs does the latter, and Windows
* always toggles IER to all zeroes and back to all ones, so do the
* same.
*
* If IER.THRI is zero, thr_ipending is not used. Set it to zero
* so that the thr_ipending subsection is not migrated.
*/
if (changed & UART_IER_THRI) {
if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
s->thr_ipending = 1;
} else {
s->thr_ipending = 0;
}
}
if (changed) {
serial_update_irq(s);
}
}
break;
case 2:
/* Did the enable/disable flag change? If so, make sure FIFOs get flushed */
if ((val ^ s->fcr) & UART_FCR_FE) {
val |= UART_FCR_XFR | UART_FCR_RFR;
}
/* FIFO clear */
if (val & UART_FCR_RFR) {
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
timer_del(s->fifo_timeout_timer);
s->timeout_ipending = 0;
fifo8_reset(&s->recv_fifo);
}
if (val & UART_FCR_XFR) {
s->lsr |= UART_LSR_THRE;
s->thr_ipending = 1;
fifo8_reset(&s->xmit_fifo);
}
serial_write_fcr(s, val & 0xC9);
serial_update_irq(s);
break;
case 3:
{
int break_enable;
s->lcr = val;
serial_update_parameters(s);
break_enable = (val >> 6) & 1;
if (break_enable != s->last_break_enable) {
s->last_break_enable = break_enable;
qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
&break_enable);
}
}
break;
case 4:
{
int flags;
int old_mcr = s->mcr;
s->mcr = val & 0x1f;
if (val & UART_MCR_LOOP)
break;
if (s->poll_msl >= 0 && old_mcr != s->mcr) {
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_GET_TIOCM, &flags);
flags &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR);
if (val & UART_MCR_RTS)
flags |= CHR_TIOCM_RTS;
if (val & UART_MCR_DTR)
flags |= CHR_TIOCM_DTR;
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_SET_TIOCM, &flags);
/* Update the modem status after a one-character-send wait-time, since there may be a response
from the device/computer at the other end of the serial line */
timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time);
}
}
break;
case 5:
break;
case 6:
break;
case 7:
s->scr = val;
break;
}
}
| false | qemu | 807464d8a7326e1025a2f392bf41636b0809d6da | static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
SerialState *s = opaque;
addr &= 7;
DPRINTF("write addr=0x%" HWADDR_PRIx " val=0x%" PRIx64 "\n", addr, val);
switch(addr) {
default:
case 0:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0xff00) | val;
serial_update_parameters(s);
} else {
s->thr = (uint8_t) val;
if(s->fcr & UART_FCR_FE) {
if (fifo8_is_full(&s->xmit_fifo)) {
fifo8_pop(&s->xmit_fifo);
}
fifo8_push(&s->xmit_fifo, s->thr);
}
s->thr_ipending = 0;
s->lsr &= ~UART_LSR_THRE;
s->lsr &= ~UART_LSR_TEMT;
serial_update_irq(s);
if (s->tsr_retry <= 0) {
serial_xmit(NULL, G_IO_OUT, s);
}
}
break;
case 1:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0x00ff) | (val << 8);
serial_update_parameters(s);
} else {
uint8_t changed = (s->ier ^ val) & 0x0f;
s->ier = val & 0x0f;
if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {
if (s->ier & UART_IER_MSI) {
s->poll_msl = 1;
serial_update_msl(s);
} else {
timer_del(s->modem_status_poll);
s->poll_msl = 0;
}
}
if (changed & UART_IER_THRI) {
if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
s->thr_ipending = 1;
} else {
s->thr_ipending = 0;
}
}
if (changed) {
serial_update_irq(s);
}
}
break;
case 2:
if ((val ^ s->fcr) & UART_FCR_FE) {
val |= UART_FCR_XFR | UART_FCR_RFR;
}
if (val & UART_FCR_RFR) {
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
timer_del(s->fifo_timeout_timer);
s->timeout_ipending = 0;
fifo8_reset(&s->recv_fifo);
}
if (val & UART_FCR_XFR) {
s->lsr |= UART_LSR_THRE;
s->thr_ipending = 1;
fifo8_reset(&s->xmit_fifo);
}
serial_write_fcr(s, val & 0xC9);
serial_update_irq(s);
break;
case 3:
{
int break_enable;
s->lcr = val;
serial_update_parameters(s);
break_enable = (val >> 6) & 1;
if (break_enable != s->last_break_enable) {
s->last_break_enable = break_enable;
qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
&break_enable);
}
}
break;
case 4:
{
int flags;
int old_mcr = s->mcr;
s->mcr = val & 0x1f;
if (val & UART_MCR_LOOP)
break;
if (s->poll_msl >= 0 && old_mcr != s->mcr) {
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_GET_TIOCM, &flags);
flags &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR);
if (val & UART_MCR_RTS)
flags |= CHR_TIOCM_RTS;
if (val & UART_MCR_DTR)
flags |= CHR_TIOCM_DTR;
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_SET_TIOCM, &flags);
timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time);
}
}
break;
case 5:
break;
case 6:
break;
case 7:
s->scr = val;
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,
unsigned VAR_3)
{
SerialState *s = VAR_0;
VAR_1 &= 7;
DPRINTF("write VAR_1=0x%" HWADDR_PRIx " VAR_2=0x%" PRIx64 "\n", VAR_1, VAR_2);
switch(VAR_1) {
default:
case 0:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0xff00) | VAR_2;
serial_update_parameters(s);
} else {
s->thr = (uint8_t) VAR_2;
if(s->fcr & UART_FCR_FE) {
if (fifo8_is_full(&s->xmit_fifo)) {
fifo8_pop(&s->xmit_fifo);
}
fifo8_push(&s->xmit_fifo, s->thr);
}
s->thr_ipending = 0;
s->lsr &= ~UART_LSR_THRE;
s->lsr &= ~UART_LSR_TEMT;
serial_update_irq(s);
if (s->tsr_retry <= 0) {
serial_xmit(NULL, G_IO_OUT, s);
}
}
break;
case 1:
if (s->lcr & UART_LCR_DLAB) {
s->divider = (s->divider & 0x00ff) | (VAR_2 << 8);
serial_update_parameters(s);
} else {
uint8_t changed = (s->ier ^ VAR_2) & 0x0f;
s->ier = VAR_2 & 0x0f;
if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {
if (s->ier & UART_IER_MSI) {
s->poll_msl = 1;
serial_update_msl(s);
} else {
timer_del(s->modem_status_poll);
s->poll_msl = 0;
}
}
if (changed & UART_IER_THRI) {
if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
s->thr_ipending = 1;
} else {
s->thr_ipending = 0;
}
}
if (changed) {
serial_update_irq(s);
}
}
break;
case 2:
if ((VAR_2 ^ s->fcr) & UART_FCR_FE) {
VAR_2 |= UART_FCR_XFR | UART_FCR_RFR;
}
if (VAR_2 & UART_FCR_RFR) {
s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);
timer_del(s->fifo_timeout_timer);
s->timeout_ipending = 0;
fifo8_reset(&s->recv_fifo);
}
if (VAR_2 & UART_FCR_XFR) {
s->lsr |= UART_LSR_THRE;
s->thr_ipending = 1;
fifo8_reset(&s->xmit_fifo);
}
serial_write_fcr(s, VAR_2 & 0xC9);
serial_update_irq(s);
break;
case 3:
{
int VAR_4;
s->lcr = VAR_2;
serial_update_parameters(s);
VAR_4 = (VAR_2 >> 6) & 1;
if (VAR_4 != s->last_break_enable) {
s->last_break_enable = VAR_4;
qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
&VAR_4);
}
}
break;
case 4:
{
int VAR_5;
int VAR_6 = s->mcr;
s->mcr = VAR_2 & 0x1f;
if (VAR_2 & UART_MCR_LOOP)
break;
if (s->poll_msl >= 0 && VAR_6 != s->mcr) {
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_GET_TIOCM, &VAR_5);
VAR_5 &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR);
if (VAR_2 & UART_MCR_RTS)
VAR_5 |= CHR_TIOCM_RTS;
if (VAR_2 & UART_MCR_DTR)
VAR_5 |= CHR_TIOCM_DTR;
qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_SET_TIOCM, &VAR_5);
timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time);
}
}
break;
case 5:
break;
case 6:
break;
case 7:
s->scr = VAR_2;
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2,\nunsigned VAR_3)\n{",
"SerialState *s = VAR_0;",
"VAR_1 &= 7;",
"DPRINTF(\"write VAR_1=0x%\" HWADDR_PRIx \" VAR_2=0x%\" PRIx64 \"\\n\", VAR_1, VAR_2);",
"switch(VAR_1) {",
"default:\ncase 0:\nif (s->lcr & UART_LCR_DLAB) {",
"s->divider = (s->divider & 0xff00) | VAR_2;",
"serial_update_parameters(s);",
"} else {",
"s->thr = (uint8_t) VAR_2;",
"if(s->fcr & UART_FCR_FE) {",
"if (fifo8_is_full(&s->xmit_fifo)) {",
"fifo8_pop(&s->xmit_fifo);",
"}",
"fifo8_push(&s->xmit_fifo, s->thr);",
"}",
"s->thr_ipending = 0;",
"s->lsr &= ~UART_LSR_THRE;",
"s->lsr &= ~UART_LSR_TEMT;",
"serial_update_irq(s);",
"if (s->tsr_retry <= 0) {",
"serial_xmit(NULL, G_IO_OUT, s);",
"}",
"}",
"break;",
"case 1:\nif (s->lcr & UART_LCR_DLAB) {",
"s->divider = (s->divider & 0x00ff) | (VAR_2 << 8);",
"serial_update_parameters(s);",
"} else {",
"uint8_t changed = (s->ier ^ VAR_2) & 0x0f;",
"s->ier = VAR_2 & 0x0f;",
"if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {",
"if (s->ier & UART_IER_MSI) {",
"s->poll_msl = 1;",
"serial_update_msl(s);",
"} else {",
"timer_del(s->modem_status_poll);",
"s->poll_msl = 0;",
"}",
"}",
"if (changed & UART_IER_THRI) {",
"if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {",
"s->thr_ipending = 1;",
"} else {",
"s->thr_ipending = 0;",
"}",
"}",
"if (changed) {",
"serial_update_irq(s);",
"}",
"}",
"break;",
"case 2:\nif ((VAR_2 ^ s->fcr) & UART_FCR_FE) {",
"VAR_2 |= UART_FCR_XFR | UART_FCR_RFR;",
"}",
"if (VAR_2 & UART_FCR_RFR) {",
"s->lsr &= ~(UART_LSR_DR | UART_LSR_BI);",
"timer_del(s->fifo_timeout_timer);",
"s->timeout_ipending = 0;",
"fifo8_reset(&s->recv_fifo);",
"}",
"if (VAR_2 & UART_FCR_XFR) {",
"s->lsr |= UART_LSR_THRE;",
"s->thr_ipending = 1;",
"fifo8_reset(&s->xmit_fifo);",
"}",
"serial_write_fcr(s, VAR_2 & 0xC9);",
"serial_update_irq(s);",
"break;",
"case 3:\n{",
"int VAR_4;",
"s->lcr = VAR_2;",
"serial_update_parameters(s);",
"VAR_4 = (VAR_2 >> 6) & 1;",
"if (VAR_4 != s->last_break_enable) {",
"s->last_break_enable = VAR_4;",
"qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,\n&VAR_4);",
"}",
"}",
"break;",
"case 4:\n{",
"int VAR_5;",
"int VAR_6 = s->mcr;",
"s->mcr = VAR_2 & 0x1f;",
"if (VAR_2 & UART_MCR_LOOP)\nbreak;",
"if (s->poll_msl >= 0 && VAR_6 != s->mcr) {",
"qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_GET_TIOCM, &VAR_5);",
"VAR_5 &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR);",
"if (VAR_2 & UART_MCR_RTS)\nVAR_5 |= CHR_TIOCM_RTS;",
"if (VAR_2 & UART_MCR_DTR)\nVAR_5 |= CHR_TIOCM_DTR;",
"qemu_chr_fe_ioctl(s->chr,CHR_IOCTL_SERIAL_SET_TIOCM, &VAR_5);",
"timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->char_transmit_time);",
"}",
"}",
"break;",
"case 5:\nbreak;",
"case 6:\nbreak;",
"case 7:\ns->scr = 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
155
],
[
157
],
[
159
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
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
],
[
253,
255
],
[
257,
259
],
[
263
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279
],
[
281,
283
],
[
285,
287
],
[
289
],
[
291
],
[
293
]
] |
25,166 | void bdrv_drain(BlockDriverState *bs)
{
while (bdrv_drain_one(bs)) {
/* Keep iterating */
}
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | void bdrv_drain(BlockDriverState *bs)
{
while (bdrv_drain_one(bs)) {
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0)
{
while (bdrv_drain_one(VAR_0)) {
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"while (bdrv_drain_one(VAR_0)) {",
"}",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
25,168 | static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
hwaddr dsm_mem_addr)
{
NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm);
NvdimmFuncSetLabelDataIn *set_label_data;
uint32_t status;
set_label_data = (NvdimmFuncSetLabelDataIn *)in->arg3;
le32_to_cpus(&set_label_data->offset);
le32_to_cpus(&set_label_data->length);
nvdimm_debug("Write Label Data: offset %#x length %#x.\n",
set_label_data->offset, set_label_data->length);
status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,
set_label_data->length);
if (status != 0 /* Success */) {
nvdimm_dsm_no_payload(status, dsm_mem_addr);
return;
}
assert(offsetof(NvdimmDsmIn, arg3) +
sizeof(*set_label_data) + set_label_data->length <= 4096);
nvc->write_label_data(nvdimm, set_label_data->in_buf,
set_label_data->length, set_label_data->offset);
nvdimm_dsm_no_payload(0 /* Success */, dsm_mem_addr);
}
| false | qemu | c2fa30757a2ba1bb5b053883773a9a61fbdd7082 | static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
hwaddr dsm_mem_addr)
{
NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm);
NvdimmFuncSetLabelDataIn *set_label_data;
uint32_t status;
set_label_data = (NvdimmFuncSetLabelDataIn *)in->arg3;
le32_to_cpus(&set_label_data->offset);
le32_to_cpus(&set_label_data->length);
nvdimm_debug("Write Label Data: offset %#x length %#x.\n",
set_label_data->offset, set_label_data->length);
status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset,
set_label_data->length);
if (status != 0 ) {
nvdimm_dsm_no_payload(status, dsm_mem_addr);
return;
}
assert(offsetof(NvdimmDsmIn, arg3) +
sizeof(*set_label_data) + set_label_data->length <= 4096);
nvc->write_label_data(nvdimm, set_label_data->in_buf,
set_label_data->length, set_label_data->offset);
nvdimm_dsm_no_payload(0 , dsm_mem_addr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NVDIMMDevice *VAR_0, NvdimmDsmIn *VAR_1,
hwaddr VAR_2)
{
NVDIMMClass *nvc = NVDIMM_GET_CLASS(VAR_0);
NvdimmFuncSetLabelDataIn *set_label_data;
uint32_t status;
set_label_data = (NvdimmFuncSetLabelDataIn *)VAR_1->arg3;
le32_to_cpus(&set_label_data->offset);
le32_to_cpus(&set_label_data->length);
nvdimm_debug("Write Label Data: offset %#x length %#x.\n",
set_label_data->offset, set_label_data->length);
status = nvdimm_rw_label_data_check(VAR_0, set_label_data->offset,
set_label_data->length);
if (status != 0 ) {
nvdimm_dsm_no_payload(status, VAR_2);
return;
}
assert(offsetof(NvdimmDsmIn, arg3) +
sizeof(*set_label_data) + set_label_data->length <= 4096);
nvc->write_label_data(VAR_0, set_label_data->in_buf,
set_label_data->length, set_label_data->offset);
nvdimm_dsm_no_payload(0 , VAR_2);
}
| [
"static void FUNC_0(NVDIMMDevice *VAR_0, NvdimmDsmIn *VAR_1,\nhwaddr VAR_2)\n{",
"NVDIMMClass *nvc = NVDIMM_GET_CLASS(VAR_0);",
"NvdimmFuncSetLabelDataIn *set_label_data;",
"uint32_t status;",
"set_label_data = (NvdimmFuncSetLabelDataIn *)VAR_1->arg3;",
"le32_to_cpus(&set_label_data->offset);",
"le32_to_cpus(&set_label_data->length);",
"nvdimm_debug(\"Write Label Data: offset %#x length %#x.\\n\",\nset_label_data->offset, set_label_data->length);",
"status = nvdimm_rw_label_data_check(VAR_0, set_label_data->offset,\nset_label_data->length);",
"if (status != 0 ) {",
"nvdimm_dsm_no_payload(status, VAR_2);",
"return;",
"}",
"assert(offsetof(NvdimmDsmIn, arg3) +\nsizeof(*set_label_data) + set_label_data->length <= 4096);",
"nvc->write_label_data(VAR_0, set_label_data->in_buf,\nset_label_data->length, set_label_data->offset);",
"nvdimm_dsm_no_payload(0 , VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
25,
27
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
51,
53
],
[
55
],
[
57
]
] |
25,169 | static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
{
#ifdef DEBUG_SLIRP
printf("slirp input:\n");
hex_dump(stdout, buf, size);
#endif
slirp_input(buf, size);
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
{
#ifdef DEBUG_SLIRP
printf("slirp input:\n");
hex_dump(stdout, buf, size);
#endif
slirp_input(buf, size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{
#ifdef DEBUG_SLIRP
printf("slirp input:\n");
hex_dump(stdout, VAR_1, VAR_2);
#endif
slirp_input(VAR_1, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{",
"#ifdef DEBUG_SLIRP\nprintf(\"slirp input:\\n\");",
"hex_dump(stdout, VAR_1, VAR_2);",
"#endif\nslirp_input(VAR_1, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11,
13
],
[
15
]
] |
25,170 | void op_dmfc0_ebase (void)
{
T0 = env->CP0_EBase;
RETURN();
}
| false | qemu | b29a0341d7ed7e7df4bf77a41db8e614f1ddb645 | void op_dmfc0_ebase (void)
{
T0 = env->CP0_EBase;
RETURN();
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (void)
{
T0 = env->CP0_EBase;
RETURN();
}
| [
"void FUNC_0 (void)\n{",
"T0 = env->CP0_EBase;",
"RETURN();",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,171 | void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
(*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x NWINS %d ",
sparc_defs[i].name,
sparc_defs[i].iu_version,
sparc_defs[i].fpu_version,
sparc_defs[i].mmu_version,
sparc_defs[i].nwindows);
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES &
~sparc_defs[i].features, "-");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES &
sparc_defs[i].features, "+");
(*cpu_fprintf)(f, "\n");
}
(*cpu_fprintf)(f, "Default CPU feature flags (use '-' to remove): ");
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Available CPU feature flags (use '+' to add): ");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Numerical features (use '=' to set): iu_version "
"fpu_version mmu_version nwindows\n");
}
| false | qemu | 9a78eead0c74333a394c0f7bbfc4423ac746fcd5 | void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
(*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x NWINS %d ",
sparc_defs[i].name,
sparc_defs[i].iu_version,
sparc_defs[i].fpu_version,
sparc_defs[i].mmu_version,
sparc_defs[i].nwindows);
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES &
~sparc_defs[i].features, "-");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES &
sparc_defs[i].features, "+");
(*cpu_fprintf)(f, "\n");
}
(*cpu_fprintf)(f, "Default CPU feature flags (use '-' to remove): ");
print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Available CPU feature flags (use '+' to add): ");
print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL);
(*cpu_fprintf)(f, "\n");
(*cpu_fprintf)(f, "Numerical features (use '=' to set): iu_version "
"fpu_version mmu_version nwindows\n");
}
| {
"code": [],
"line_no": []
} | void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))
{
unsigned int VAR_3;
for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(sparc_defs); VAR_3++) {
(*VAR_1)(VAR_2, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x NWINS %d ",
sparc_defs[VAR_3].name,
sparc_defs[VAR_3].iu_version,
sparc_defs[VAR_3].fpu_version,
sparc_defs[VAR_3].mmu_version,
sparc_defs[VAR_3].nwindows);
print_features(VAR_2, VAR_1, CPU_DEFAULT_FEATURES &
~sparc_defs[VAR_3].features, "-");
print_features(VAR_2, VAR_1, ~CPU_DEFAULT_FEATURES &
sparc_defs[VAR_3].features, "+");
(*VAR_1)(VAR_2, "\n");
}
(*VAR_1)(VAR_2, "Default CPU feature flags (use '-' to remove): ");
print_features(VAR_2, VAR_1, CPU_DEFAULT_FEATURES, NULL);
(*VAR_1)(VAR_2, "\n");
(*VAR_1)(VAR_2, "Available CPU feature flags (use '+' to add): ");
print_features(VAR_2, VAR_1, ~CPU_DEFAULT_FEATURES, NULL);
(*VAR_1)(VAR_2, "\n");
(*VAR_1)(VAR_2, "Numerical features (use '=' to set): iu_version "
"fpu_version mmu_version nwindows\n");
}
| [
"void FUNC_0(FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{",
"unsigned int VAR_3;",
"for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(sparc_defs); VAR_3++) {",
"(*VAR_1)(VAR_2, \"Sparc %16s IU \" TARGET_FMT_lx \" FPU %08x MMU %08x NWINS %d \",\nsparc_defs[VAR_3].name,\nsparc_defs[VAR_3].iu_version,\nsparc_defs[VAR_3].fpu_version,\nsparc_defs[VAR_3].mmu_version,\nsparc_defs[VAR_3].nwindows);",
"print_features(VAR_2, VAR_1, CPU_DEFAULT_FEATURES &\n~sparc_defs[VAR_3].features, \"-\");",
"print_features(VAR_2, VAR_1, ~CPU_DEFAULT_FEATURES &\nsparc_defs[VAR_3].features, \"+\");",
"(*VAR_1)(VAR_2, \"\\n\");",
"}",
"(*VAR_1)(VAR_2, \"Default CPU feature flags (use '-' to remove): \");",
"print_features(VAR_2, VAR_1, CPU_DEFAULT_FEATURES, NULL);",
"(*VAR_1)(VAR_2, \"\\n\");",
"(*VAR_1)(VAR_2, \"Available CPU feature flags (use '+' to add): \");",
"print_features(VAR_2, VAR_1, ~CPU_DEFAULT_FEATURES, NULL);",
"(*VAR_1)(VAR_2, \"\\n\");",
"(*VAR_1)(VAR_2, \"Numerical features (use '=' to set): iu_version \"\n\"fpu_version mmu_version nwindows\\n\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13,
15,
17,
19,
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
]
] |
25,172 | static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)
{
hw_error("Unsupported short raccess. reg=" TARGET_FMT_plx "\n", addr);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t dma_rinvalid (void *opaque, target_phys_addr_t addr)
{
hw_error("Unsupported short raccess. reg=" TARGET_FMT_plx "\n", addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)
{
hw_error("Unsupported short raccess. reg=" TARGET_FMT_plx "\n", addr);
return 0;
}
| [
"static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)\n{",
"hw_error(\"Unsupported short raccess. reg=\" TARGET_FMT_plx \"\\n\", addr);",
"return 0;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,173 | static void scsi_hd_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->init = scsi_hd_initfn;
sc->destroy = scsi_destroy;
sc->alloc_req = scsi_new_request;
sc->unit_attention_reported = scsi_disk_unit_attention_reported;
dc->fw_name = "disk";
dc->desc = "virtual SCSI disk";
dc->reset = scsi_disk_reset;
dc->props = scsi_hd_properties;
dc->vmsd = &vmstate_scsi_disk_state;
}
| false | qemu | a818a4b69d47ca3826dee36878074395aeac2083 | static void scsi_hd_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->init = scsi_hd_initfn;
sc->destroy = scsi_destroy;
sc->alloc_req = scsi_new_request;
sc->unit_attention_reported = scsi_disk_unit_attention_reported;
dc->fw_name = "disk";
dc->desc = "virtual SCSI disk";
dc->reset = scsi_disk_reset;
dc->props = scsi_hd_properties;
dc->vmsd = &vmstate_scsi_disk_state;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(VAR_0);
sc->init = scsi_hd_initfn;
sc->destroy = scsi_destroy;
sc->alloc_req = scsi_new_request;
sc->unit_attention_reported = scsi_disk_unit_attention_reported;
dc->fw_name = "disk";
dc->desc = "virtual SCSI disk";
dc->reset = scsi_disk_reset;
dc->props = scsi_hd_properties;
dc->vmsd = &vmstate_scsi_disk_state;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(VAR_0);",
"sc->init = scsi_hd_initfn;",
"sc->destroy = scsi_destroy;",
"sc->alloc_req = scsi_new_request;",
"sc->unit_attention_reported = scsi_disk_unit_attention_reported;",
"dc->fw_name = \"disk\";",
"dc->desc = \"virtual SCSI disk\";",
"dc->reset = scsi_disk_reset;",
"dc->props = scsi_hd_properties;",
"dc->vmsd = &vmstate_scsi_disk_state;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
25,174 | static int qxl_init_secondary(PCIDevice *dev)
{
static int device_id = 1;
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->id = device_id++;
if (ram_size < 16 * 1024 * 1024) {
ram_size = 16 * 1024 * 1024;
}
qxl->vga.vram_size = ram_size;
qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vgavram",
qxl->vga.vram_size);
qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);
pci_config_set_class(dev->config, PCI_CLASS_DISPLAY_OTHER);
return qxl_init_common(qxl);
}
| false | qemu | 96c05abc904c6f74b60981d956cee531920e4cdf | static int qxl_init_secondary(PCIDevice *dev)
{
static int device_id = 1;
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->id = device_id++;
if (ram_size < 16 * 1024 * 1024) {
ram_size = 16 * 1024 * 1024;
}
qxl->vga.vram_size = ram_size;
qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vgavram",
qxl->vga.vram_size);
qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);
pci_config_set_class(dev->config, PCI_CLASS_DISPLAY_OTHER);
return qxl_init_common(qxl);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
static int VAR_1 = 1;
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, VAR_0);
ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
qxl->id = VAR_1++;
if (ram_size < 16 * 1024 * 1024) {
ram_size = 16 * 1024 * 1024;
}
qxl->vga.vram_size = ram_size;
qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vgavram",
qxl->vga.vram_size);
qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);
pci_config_set_class(VAR_0->config, PCI_CLASS_DISPLAY_OTHER);
return qxl_init_common(qxl);
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"static int VAR_1 = 1;",
"PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, VAR_0);",
"ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);",
"qxl->id = VAR_1++;",
"if (ram_size < 16 * 1024 * 1024) {",
"ram_size = 16 * 1024 * 1024;",
"}",
"qxl->vga.vram_size = ram_size;",
"qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, \"qxl.vgavram\",\nqxl->vga.vram_size);",
"qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);",
"pci_config_set_class(VAR_0->config, PCI_CLASS_DISPLAY_OTHER);",
"return qxl_init_common(qxl);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
25,175 | static inline void downmix_2f_2r_to_dolby(float *samples)
{
int i;
for (i = 0; i < 256; i++) {
samples[i] -= samples[i + 512];
samples[i + 256] += samples[i + 768];
samples[i + 512] = samples[i + 768] = 0;
}
}
| false | FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | static inline void downmix_2f_2r_to_dolby(float *samples)
{
int i;
for (i = 0; i < 256; i++) {
samples[i] -= samples[i + 512];
samples[i + 256] += samples[i + 768];
samples[i + 512] = samples[i + 768] = 0;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(float *VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {
VAR_0[VAR_1] -= VAR_0[VAR_1 + 512];
VAR_0[VAR_1 + 256] += VAR_0[VAR_1 + 768];
VAR_0[VAR_1 + 512] = VAR_0[VAR_1 + 768] = 0;
}
}
| [
"static inline void FUNC_0(float *VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {",
"VAR_0[VAR_1] -= VAR_0[VAR_1 + 512];",
"VAR_0[VAR_1 + 256] += VAR_0[VAR_1 + 768];",
"VAR_0[VAR_1 + 512] = VAR_0[VAR_1 + 768] = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
25,176 | static void disas_simd_3same_logic(DisasContext *s, uint32_t insn)
{
int rd = extract32(insn, 0, 5);
int rn = extract32(insn, 5, 5);
int rm = extract32(insn, 16, 5);
int size = extract32(insn, 22, 2);
bool is_u = extract32(insn, 29, 1);
bool is_q = extract32(insn, 30, 1);
TCGv_i64 tcg_op1 = tcg_temp_new_i64();
TCGv_i64 tcg_op2 = tcg_temp_new_i64();
TCGv_i64 tcg_res[2];
int pass;
tcg_res[0] = tcg_temp_new_i64();
tcg_res[1] = tcg_temp_new_i64();
for (pass = 0; pass < (is_q ? 2 : 1); pass++) {
read_vec_element(s, tcg_op1, rn, pass, MO_64);
read_vec_element(s, tcg_op2, rm, pass, MO_64);
if (!is_u) {
switch (size) {
case 0: /* AND */
tcg_gen_and_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 1: /* BIC */
tcg_gen_andc_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 2: /* ORR */
tcg_gen_or_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 3: /* ORN */
tcg_gen_orc_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
}
} else {
if (size != 0) {
/* B* ops need res loaded to operate on */
read_vec_element(s, tcg_res[pass], rd, pass, MO_64);
}
switch (size) {
case 0: /* EOR */
tcg_gen_xor_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 1: /* BSL bitwise select */
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_xor_i64(tcg_res[pass], tcg_op2, tcg_op1);
break;
case 2: /* BIT, bitwise insert if true */
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1);
break;
case 3: /* BIF, bitwise insert if false */
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1);
break;
}
}
}
write_vec_element(s, tcg_res[0], rd, 0, MO_64);
if (!is_q) {
tcg_gen_movi_i64(tcg_res[1], 0);
}
write_vec_element(s, tcg_res[1], rd, 1, MO_64);
tcg_temp_free_i64(tcg_op1);
tcg_temp_free_i64(tcg_op2);
tcg_temp_free_i64(tcg_res[0]);
tcg_temp_free_i64(tcg_res[1]);
}
| false | qemu | 8c6afa6ab158467d1938cc92022135bc7a872006 | static void disas_simd_3same_logic(DisasContext *s, uint32_t insn)
{
int rd = extract32(insn, 0, 5);
int rn = extract32(insn, 5, 5);
int rm = extract32(insn, 16, 5);
int size = extract32(insn, 22, 2);
bool is_u = extract32(insn, 29, 1);
bool is_q = extract32(insn, 30, 1);
TCGv_i64 tcg_op1 = tcg_temp_new_i64();
TCGv_i64 tcg_op2 = tcg_temp_new_i64();
TCGv_i64 tcg_res[2];
int pass;
tcg_res[0] = tcg_temp_new_i64();
tcg_res[1] = tcg_temp_new_i64();
for (pass = 0; pass < (is_q ? 2 : 1); pass++) {
read_vec_element(s, tcg_op1, rn, pass, MO_64);
read_vec_element(s, tcg_op2, rm, pass, MO_64);
if (!is_u) {
switch (size) {
case 0:
tcg_gen_and_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 1:
tcg_gen_andc_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 2:
tcg_gen_or_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 3:
tcg_gen_orc_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
}
} else {
if (size != 0) {
read_vec_element(s, tcg_res[pass], rd, pass, MO_64);
}
switch (size) {
case 0:
tcg_gen_xor_i64(tcg_res[pass], tcg_op1, tcg_op2);
break;
case 1:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_xor_i64(tcg_res[pass], tcg_op2, tcg_op1);
break;
case 2:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1);
break;
case 3:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]);
tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1);
break;
}
}
}
write_vec_element(s, tcg_res[0], rd, 0, MO_64);
if (!is_q) {
tcg_gen_movi_i64(tcg_res[1], 0);
}
write_vec_element(s, tcg_res[1], rd, 1, MO_64);
tcg_temp_free_i64(tcg_op1);
tcg_temp_free_i64(tcg_op2);
tcg_temp_free_i64(tcg_res[0]);
tcg_temp_free_i64(tcg_res[1]);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
int VAR_2 = extract32(VAR_1, 0, 5);
int VAR_3 = extract32(VAR_1, 5, 5);
int VAR_4 = extract32(VAR_1, 16, 5);
int VAR_5 = extract32(VAR_1, 22, 2);
bool is_u = extract32(VAR_1, 29, 1);
bool is_q = extract32(VAR_1, 30, 1);
TCGv_i64 tcg_op1 = tcg_temp_new_i64();
TCGv_i64 tcg_op2 = tcg_temp_new_i64();
TCGv_i64 tcg_res[2];
int VAR_6;
tcg_res[0] = tcg_temp_new_i64();
tcg_res[1] = tcg_temp_new_i64();
for (VAR_6 = 0; VAR_6 < (is_q ? 2 : 1); VAR_6++) {
read_vec_element(VAR_0, tcg_op1, VAR_3, VAR_6, MO_64);
read_vec_element(VAR_0, tcg_op2, VAR_4, VAR_6, MO_64);
if (!is_u) {
switch (VAR_5) {
case 0:
tcg_gen_and_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);
break;
case 1:
tcg_gen_andc_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);
break;
case 2:
tcg_gen_or_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);
break;
case 3:
tcg_gen_orc_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);
break;
}
} else {
if (VAR_5 != 0) {
read_vec_element(VAR_0, tcg_res[VAR_6], VAR_2, VAR_6, MO_64);
}
switch (VAR_5) {
case 0:
tcg_gen_xor_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);
break;
case 1:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);
tcg_gen_xor_i64(tcg_res[VAR_6], tcg_op2, tcg_op1);
break;
case 2:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);
tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[VAR_6], tcg_res[VAR_6], tcg_op1);
break;
case 3:
tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);
tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2);
tcg_gen_xor_i64(tcg_res[VAR_6], tcg_res[VAR_6], tcg_op1);
break;
}
}
}
write_vec_element(VAR_0, tcg_res[0], VAR_2, 0, MO_64);
if (!is_q) {
tcg_gen_movi_i64(tcg_res[1], 0);
}
write_vec_element(VAR_0, tcg_res[1], VAR_2, 1, MO_64);
tcg_temp_free_i64(tcg_op1);
tcg_temp_free_i64(tcg_op2);
tcg_temp_free_i64(tcg_res[0]);
tcg_temp_free_i64(tcg_res[1]);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"int VAR_2 = extract32(VAR_1, 0, 5);",
"int VAR_3 = extract32(VAR_1, 5, 5);",
"int VAR_4 = extract32(VAR_1, 16, 5);",
"int VAR_5 = extract32(VAR_1, 22, 2);",
"bool is_u = extract32(VAR_1, 29, 1);",
"bool is_q = extract32(VAR_1, 30, 1);",
"TCGv_i64 tcg_op1 = tcg_temp_new_i64();",
"TCGv_i64 tcg_op2 = tcg_temp_new_i64();",
"TCGv_i64 tcg_res[2];",
"int VAR_6;",
"tcg_res[0] = tcg_temp_new_i64();",
"tcg_res[1] = tcg_temp_new_i64();",
"for (VAR_6 = 0; VAR_6 < (is_q ? 2 : 1); VAR_6++) {",
"read_vec_element(VAR_0, tcg_op1, VAR_3, VAR_6, MO_64);",
"read_vec_element(VAR_0, tcg_op2, VAR_4, VAR_6, MO_64);",
"if (!is_u) {",
"switch (VAR_5) {",
"case 0:\ntcg_gen_and_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);",
"break;",
"case 1:\ntcg_gen_andc_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);",
"break;",
"case 2:\ntcg_gen_or_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);",
"break;",
"case 3:\ntcg_gen_orc_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);",
"break;",
"}",
"} else {",
"if (VAR_5 != 0) {",
"read_vec_element(VAR_0, tcg_res[VAR_6], VAR_2, VAR_6, MO_64);",
"}",
"switch (VAR_5) {",
"case 0:\ntcg_gen_xor_i64(tcg_res[VAR_6], tcg_op1, tcg_op2);",
"break;",
"case 1:\ntcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2);",
"tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);",
"tcg_gen_xor_i64(tcg_res[VAR_6], tcg_op2, tcg_op1);",
"break;",
"case 2:\ntcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);",
"tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2);",
"tcg_gen_xor_i64(tcg_res[VAR_6], tcg_res[VAR_6], tcg_op1);",
"break;",
"case 3:\ntcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[VAR_6]);",
"tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2);",
"tcg_gen_xor_i64(tcg_res[VAR_6], tcg_res[VAR_6], tcg_op1);",
"break;",
"}",
"}",
"}",
"write_vec_element(VAR_0, tcg_res[0], VAR_2, 0, MO_64);",
"if (!is_q) {",
"tcg_gen_movi_i64(tcg_res[1], 0);",
"}",
"write_vec_element(VAR_0, tcg_res[1], VAR_2, 1, MO_64);",
"tcg_temp_free_i64(tcg_op1);",
"tcg_temp_free_i64(tcg_op2);",
"tcg_temp_free_i64(tcg_res[0]);",
"tcg_temp_free_i64(tcg_res[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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
]
] |
25,177 | void net_check_clients(void)
{
VLANState *vlan;
VLANClientState *vc;
int i;
/* Don't warn about the default network setup that you get if
* no command line -net or -netdev options are specified. There
* are two cases that we would otherwise complain about:
* (1) board doesn't support a NIC but the implicit "-net nic"
* requested one
* (2) CONFIG_SLIRP not set, in which case the implicit "-net nic"
* sets up a nic that isn't connected to anything.
*/
if (default_net) {
return;
}
QTAILQ_FOREACH(vlan, &vlans, next) {
int has_nic = 0, has_host_dev = 0;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_OPTIONS_KIND_NIC:
has_nic = 1;
break;
case NET_CLIENT_OPTIONS_KIND_USER:
case NET_CLIENT_OPTIONS_KIND_TAP:
case NET_CLIENT_OPTIONS_KIND_SOCKET:
case NET_CLIENT_OPTIONS_KIND_VDE:
has_host_dev = 1;
break;
default: ;
}
}
if (has_host_dev && !has_nic)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (has_nic && !has_host_dev)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? "nic" : "netdev",
vc->name);
}
}
/* Check that all NICs requested via -net nic actually got created.
* NICs created via -device don't need to be checked here because
* they are always instantiated.
*/
for (i = 0; i < MAX_NICS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used && !nd->instantiated) {
fprintf(stderr, "Warning: requested NIC (%s, model %s) "
"was not created (not supported by this machine?)\n",
nd->name ? nd->name : "anonymous",
nd->model ? nd->model : "unspecified");
}
}
}
| false | qemu | 81017645e45bcb0b4d985e900c501f92f2c6fb60 | void net_check_clients(void)
{
VLANState *vlan;
VLANClientState *vc;
int i;
if (default_net) {
return;
}
QTAILQ_FOREACH(vlan, &vlans, next) {
int has_nic = 0, has_host_dev = 0;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_OPTIONS_KIND_NIC:
has_nic = 1;
break;
case NET_CLIENT_OPTIONS_KIND_USER:
case NET_CLIENT_OPTIONS_KIND_TAP:
case NET_CLIENT_OPTIONS_KIND_SOCKET:
case NET_CLIENT_OPTIONS_KIND_VDE:
has_host_dev = 1;
break;
default: ;
}
}
if (has_host_dev && !has_nic)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (has_nic && !has_host_dev)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? "nic" : "netdev",
vc->name);
}
}
for (i = 0; i < MAX_NICS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used && !nd->instantiated) {
fprintf(stderr, "Warning: requested NIC (%s, model %s) "
"was not created (not supported by this machine?)\n",
nd->name ? nd->name : "anonymous",
nd->model ? nd->model : "unspecified");
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
VLANState *vlan;
VLANClientState *vc;
int VAR_0;
if (default_net) {
return;
}
QTAILQ_FOREACH(vlan, &vlans, next) {
int has_nic = 0, has_host_dev = 0;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
switch (vc->info->type) {
case NET_CLIENT_OPTIONS_KIND_NIC:
has_nic = 1;
break;
case NET_CLIENT_OPTIONS_KIND_USER:
case NET_CLIENT_OPTIONS_KIND_TAP:
case NET_CLIENT_OPTIONS_KIND_SOCKET:
case NET_CLIENT_OPTIONS_KIND_VDE:
has_host_dev = 1;
break;
default: ;
}
}
if (has_host_dev && !has_nic)
fprintf(stderr, "Warning: vlan %d with no nics\n", vlan->id);
if (has_nic && !has_host_dev)
fprintf(stderr,
"Warning: vlan %d is not connected to host network\n",
vlan->id);
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!vc->peer) {
fprintf(stderr, "Warning: %s %s has no peer\n",
vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? "nic" : "netdev",
vc->name);
}
}
for (VAR_0 = 0; VAR_0 < MAX_NICS; VAR_0++) {
NICInfo *nd = &nd_table[VAR_0];
if (nd->used && !nd->instantiated) {
fprintf(stderr, "Warning: requested NIC (%s, model %s) "
"was not created (not supported by this machine?)\n",
nd->name ? nd->name : "anonymous",
nd->model ? nd->model : "unspecified");
}
}
}
| [
"void FUNC_0(void)\n{",
"VLANState *vlan;",
"VLANClientState *vc;",
"int VAR_0;",
"if (default_net) {",
"return;",
"}",
"QTAILQ_FOREACH(vlan, &vlans, next) {",
"int has_nic = 0, has_host_dev = 0;",
"QTAILQ_FOREACH(vc, &vlan->clients, next) {",
"switch (vc->info->type) {",
"case NET_CLIENT_OPTIONS_KIND_NIC:\nhas_nic = 1;",
"break;",
"case NET_CLIENT_OPTIONS_KIND_USER:\ncase NET_CLIENT_OPTIONS_KIND_TAP:\ncase NET_CLIENT_OPTIONS_KIND_SOCKET:\ncase NET_CLIENT_OPTIONS_KIND_VDE:\nhas_host_dev = 1;",
"break;",
"default: ;",
"}",
"}",
"if (has_host_dev && !has_nic)\nfprintf(stderr, \"Warning: vlan %d with no nics\\n\", vlan->id);",
"if (has_nic && !has_host_dev)\nfprintf(stderr,\n\"Warning: vlan %d is not connected to host network\\n\",\nvlan->id);",
"}",
"QTAILQ_FOREACH(vc, &non_vlan_clients, next) {",
"if (!vc->peer) {",
"fprintf(stderr, \"Warning: %s %s has no peer\\n\",\nvc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? \"nic\" : \"netdev\",\nvc->name);",
"}",
"}",
"for (VAR_0 = 0; VAR_0 < MAX_NICS; VAR_0++) {",
"NICInfo *nd = &nd_table[VAR_0];",
"if (nd->used && !nd->instantiated) {",
"fprintf(stderr, \"Warning: requested NIC (%s, model %s) \"\n\"was not created (not supported by this machine?)\\n\",\nnd->name ? nd->name : \"anonymous\",\nnd->model ? nd->model : \"unspecified\");",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
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
],
[
109
],
[
111
],
[
113
],
[
115,
117,
119,
121
],
[
123
],
[
125
],
[
127
]
] |
25,178 | static uint16_t read_u16(uint8_t *data, size_t offset)
{
return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
}
| false | qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | static uint16_t read_u16(uint8_t *data, size_t offset)
{
return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
}
| {
"code": [],
"line_no": []
} | static uint16_t FUNC_0(uint8_t *data, size_t offset)
{
return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
}
| [
"static uint16_t FUNC_0(uint8_t *data, size_t offset)\n{",
"return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,180 | av_cold void ff_psy_end(FFPsyContext *ctx)
{
if (ctx->model->end)
ctx->model->end(ctx);
av_freep(&ctx->bands);
av_freep(&ctx->num_bands);
av_freep(&ctx->group);
av_freep(&ctx->ch);
}
| true | FFmpeg | f4aa8085f23c3abff3114d7bf638698d42110526 | av_cold void ff_psy_end(FFPsyContext *ctx)
{
if (ctx->model->end)
ctx->model->end(ctx);
av_freep(&ctx->bands);
av_freep(&ctx->num_bands);
av_freep(&ctx->group);
av_freep(&ctx->ch);
}
| {
"code": [
" if (ctx->model->end)"
],
"line_no": [
5
]
} | av_cold void FUNC_0(FFPsyContext *ctx)
{
if (ctx->model->end)
ctx->model->end(ctx);
av_freep(&ctx->bands);
av_freep(&ctx->num_bands);
av_freep(&ctx->group);
av_freep(&ctx->ch);
}
| [
"av_cold void FUNC_0(FFPsyContext *ctx)\n{",
"if (ctx->model->end)\nctx->model->end(ctx);",
"av_freep(&ctx->bands);",
"av_freep(&ctx->num_bands);",
"av_freep(&ctx->group);",
"av_freep(&ctx->ch);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,183 | static void parse_str(StringInputVisitor *siv, Error **errp)
{
char *str = (char *) siv->string;
long long start, end;
Range *cur;
char *endptr;
if (siv->ranges) {
return;
}
do {
errno = 0;
start = strtoll(str, &endptr, 0);
if (errno == 0 && endptr > str) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = start + 1;
siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur,
range_compare);
cur = NULL;
str = NULL;
} else if (*endptr == '-') {
str = endptr + 1;
errno = 0;
end = strtoll(str, &endptr, 0);
if (errno == 0 && endptr > str && start <= end &&
(start > INT64_MAX - 65536 ||
end < start + 65536)) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = end + 1;
siv->ranges =
g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
str = NULL;
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = end + 1;
siv->ranges =
g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = start + 1;
siv->ranges = g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} while (str);
return;
error:
g_list_foreach(siv->ranges, free_range, NULL);
g_list_free(siv->ranges);
siv->ranges = NULL;
}
| true | qemu | 74f24cb6306d065045d0e2215a7d10533fa59c57 | static void parse_str(StringInputVisitor *siv, Error **errp)
{
char *str = (char *) siv->string;
long long start, end;
Range *cur;
char *endptr;
if (siv->ranges) {
return;
}
do {
errno = 0;
start = strtoll(str, &endptr, 0);
if (errno == 0 && endptr > str) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = start + 1;
siv->ranges = g_list_insert_sorted_merged(siv->ranges, cur,
range_compare);
cur = NULL;
str = NULL;
} else if (*endptr == '-') {
str = endptr + 1;
errno = 0;
end = strtoll(str, &endptr, 0);
if (errno == 0 && endptr > str && start <= end &&
(start > INT64_MAX - 65536 ||
end < start + 65536)) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = end + 1;
siv->ranges =
g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
str = NULL;
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = end + 1;
siv->ranges =
g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} else if (*endptr == ',') {
str = endptr + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = start;
cur->end = start + 1;
siv->ranges = g_list_insert_sorted_merged(siv->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} while (str);
return;
error:
g_list_foreach(siv->ranges, free_range, NULL);
g_list_free(siv->ranges);
siv->ranges = NULL;
}
| {
"code": [
"static void parse_str(StringInputVisitor *siv, Error **errp)"
],
"line_no": [
1
]
} | static void FUNC_0(StringInputVisitor *VAR_0, Error **VAR_1)
{
char *VAR_2 = (char *) VAR_0->string;
long long VAR_3, VAR_4;
Range *cur;
char *VAR_5;
if (VAR_0->ranges) {
return;
}
do {
errno = 0;
VAR_3 = strtoll(VAR_2, &VAR_5, 0);
if (errno == 0 && VAR_5 > VAR_2) {
if (*VAR_5 == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = VAR_3;
cur->VAR_4 = VAR_3 + 1;
VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, cur,
range_compare);
cur = NULL;
VAR_2 = NULL;
} else if (*VAR_5 == '-') {
VAR_2 = VAR_5 + 1;
errno = 0;
VAR_4 = strtoll(VAR_2, &VAR_5, 0);
if (errno == 0 && VAR_5 > VAR_2 && VAR_3 <= VAR_4 &&
(VAR_3 > INT64_MAX - 65536 ||
VAR_4 < VAR_3 + 65536)) {
if (*VAR_5 == '\0') {
cur = g_malloc0(sizeof(*cur));
cur->begin = VAR_3;
cur->VAR_4 = VAR_4 + 1;
VAR_0->ranges =
g_list_insert_sorted_merged(VAR_0->ranges,
cur,
range_compare);
cur = NULL;
VAR_2 = NULL;
} else if (*VAR_5 == ',') {
VAR_2 = VAR_5 + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = VAR_3;
cur->VAR_4 = VAR_4 + 1;
VAR_0->ranges =
g_list_insert_sorted_merged(VAR_0->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} else if (*VAR_5 == ',') {
VAR_2 = VAR_5 + 1;
cur = g_malloc0(sizeof(*cur));
cur->begin = VAR_3;
cur->VAR_4 = VAR_3 + 1;
VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges,
cur,
range_compare);
cur = NULL;
} else {
goto error;
}
} else {
goto error;
}
} while (VAR_2);
return;
error:
g_list_foreach(VAR_0->ranges, free_range, NULL);
g_list_free(VAR_0->ranges);
VAR_0->ranges = NULL;
}
| [
"static void FUNC_0(StringInputVisitor *VAR_0, Error **VAR_1)\n{",
"char *VAR_2 = (char *) VAR_0->string;",
"long long VAR_3, VAR_4;",
"Range *cur;",
"char *VAR_5;",
"if (VAR_0->ranges) {",
"return;",
"}",
"do {",
"errno = 0;",
"VAR_3 = strtoll(VAR_2, &VAR_5, 0);",
"if (errno == 0 && VAR_5 > VAR_2) {",
"if (*VAR_5 == '\\0') {",
"cur = g_malloc0(sizeof(*cur));",
"cur->begin = VAR_3;",
"cur->VAR_4 = VAR_3 + 1;",
"VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges, cur,\nrange_compare);",
"cur = NULL;",
"VAR_2 = NULL;",
"} else if (*VAR_5 == '-') {",
"VAR_2 = VAR_5 + 1;",
"errno = 0;",
"VAR_4 = strtoll(VAR_2, &VAR_5, 0);",
"if (errno == 0 && VAR_5 > VAR_2 && VAR_3 <= VAR_4 &&\n(VAR_3 > INT64_MAX - 65536 ||\nVAR_4 < VAR_3 + 65536)) {",
"if (*VAR_5 == '\\0') {",
"cur = g_malloc0(sizeof(*cur));",
"cur->begin = VAR_3;",
"cur->VAR_4 = VAR_4 + 1;",
"VAR_0->ranges =\ng_list_insert_sorted_merged(VAR_0->ranges,\ncur,\nrange_compare);",
"cur = NULL;",
"VAR_2 = NULL;",
"} else if (*VAR_5 == ',') {",
"VAR_2 = VAR_5 + 1;",
"cur = g_malloc0(sizeof(*cur));",
"cur->begin = VAR_3;",
"cur->VAR_4 = VAR_4 + 1;",
"VAR_0->ranges =\ng_list_insert_sorted_merged(VAR_0->ranges,\ncur,\nrange_compare);",
"cur = NULL;",
"} else {",
"goto error;",
"}",
"} else {",
"goto error;",
"}",
"} else if (*VAR_5 == ',') {",
"VAR_2 = VAR_5 + 1;",
"cur = g_malloc0(sizeof(*cur));",
"cur->begin = VAR_3;",
"cur->VAR_4 = VAR_3 + 1;",
"VAR_0->ranges = g_list_insert_sorted_merged(VAR_0->ranges,\ncur,\nrange_compare);",
"cur = NULL;",
"} else {",
"goto error;",
"}",
"} else {",
"goto error;",
"}",
"} while (VAR_2);",
"return;",
"error:\ng_list_foreach(VAR_0->ranges, free_range, NULL);",
"g_list_free(VAR_0->ranges);",
"VAR_0->ranges = NULL;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
]
] |
25,186 | int inet_nonblocking_connect(const char *str, bool *in_progress,
Error **errp)
{
QemuOpts *opts;
int sock = -1;
opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
if (inet_parse(opts, str) == 0) {
sock = inet_connect_opts(opts, false, in_progress, errp);
} else {
error_set(errp, QERR_SOCKET_CREATE_FAILED);
}
qemu_opts_del(opts);
return sock;
}
| true | qemu | 233aa5c2d1cf4655ffe335025a68cf5454f87dad | int inet_nonblocking_connect(const char *str, bool *in_progress,
Error **errp)
{
QemuOpts *opts;
int sock = -1;
opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
if (inet_parse(opts, str) == 0) {
sock = inet_connect_opts(opts, false, in_progress, errp);
} else {
error_set(errp, QERR_SOCKET_CREATE_FAILED);
}
qemu_opts_del(opts);
return sock;
}
| {
"code": [
" } else {",
"int inet_nonblocking_connect(const char *str, bool *in_progress,",
" Error **errp)",
" sock = inet_connect_opts(opts, false, in_progress, errp);",
"int inet_nonblocking_connect(const char *str, bool *in_progress,"
],
"line_no": [
19,
1,
3,
17,
1
]
} | int FUNC_0(const char *VAR_0, bool *VAR_1,
Error **VAR_2)
{
QemuOpts *opts;
int VAR_3 = -1;
opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
if (inet_parse(opts, VAR_0) == 0) {
VAR_3 = inet_connect_opts(opts, false, VAR_1, VAR_2);
} else {
error_set(VAR_2, QERR_SOCKET_CREATE_FAILED);
}
qemu_opts_del(opts);
return VAR_3;
}
| [
"int FUNC_0(const char *VAR_0, bool *VAR_1,\nError **VAR_2)\n{",
"QemuOpts *opts;",
"int VAR_3 = -1;",
"opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);",
"if (inet_parse(opts, VAR_0) == 0) {",
"VAR_3 = inet_connect_opts(opts, false, VAR_1, VAR_2);",
"} else {",
"error_set(VAR_2, QERR_SOCKET_CREATE_FAILED);",
"}",
"qemu_opts_del(opts);",
"return VAR_3;",
"}"
] | [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
25,187 | roundAndPackFloatx80(
int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
STATUS_PARAM)
{
int8 roundingMode;
flag roundNearestEven, increment, isTiny;
int64 roundIncrement, roundMask, roundBits;
roundingMode = STATUS(float_rounding_mode);
roundNearestEven = ( roundingMode == float_round_nearest_even );
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
roundIncrement = LIT64( 0x0000000000000400 );
roundMask = LIT64( 0x00000000000007FF );
}
else if ( roundingPrecision == 32 ) {
roundIncrement = LIT64( 0x0000008000000000 );
roundMask = LIT64( 0x000000FFFFFFFFFF );
}
else {
goto precision80;
}
zSig0 |= ( zSig1 != 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
roundIncrement = 0;
}
else {
roundIncrement = roundMask;
if ( zSign ) {
if ( roundingMode == float_round_up ) roundIncrement = 0;
}
else {
if ( roundingMode == float_round_down ) roundIncrement = 0;
}
}
}
roundBits = zSig0 & roundMask;
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
) {
goto overflow;
}
if ( zExp <= 0 ) {
if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ( zSig0 <= zSig0 + roundIncrement );
shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
zExp = 0;
roundBits = zSig0 & roundMask;
if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( (int64_t) zSig0 < 0 ) zExp = 1;
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( zSig0 < roundIncrement ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
if ( zSig0 == 0 ) zExp = 0;
return packFloatx80( zSign, zExp, zSig0 );
precision80:
increment = ( (int64_t) zSig1 < 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
increment = 0;
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
}
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE )
&& ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
&& increment
)
) {
roundMask = 0;
overflow:
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);
if ( ( roundingMode == float_round_to_zero )
|| ( zSign && ( roundingMode == float_round_up ) )
|| ( ! zSign && ( roundingMode == float_round_down ) )
) {
return packFloatx80( zSign, 0x7FFE, ~ roundMask );
}
return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
}
if ( zExp <= 0 ) {
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ! increment
|| ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
zExp = 0;
if ( isTiny && zSig1 ) float_raise( float_flag_underflow STATUS_VAR);
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundNearestEven ) {
increment = ( (int64_t) zSig1 < 0 );
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
if ( increment ) {
++zSig0;
zSig0 &=
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
if ( (int64_t) zSig0 < 0 ) zExp = 1;
}
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( increment ) {
++zSig0;
if ( zSig0 == 0 ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
else {
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
}
}
else {
if ( zSig0 == 0 ) zExp = 0;
}
return packFloatx80( zSign, zExp, zSig0 );
}
| true | qemu | e6afc87f804abee7d0479be5e8e31c56d885fafb | roundAndPackFloatx80(
int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
STATUS_PARAM)
{
int8 roundingMode;
flag roundNearestEven, increment, isTiny;
int64 roundIncrement, roundMask, roundBits;
roundingMode = STATUS(float_rounding_mode);
roundNearestEven = ( roundingMode == float_round_nearest_even );
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
roundIncrement = LIT64( 0x0000000000000400 );
roundMask = LIT64( 0x00000000000007FF );
}
else if ( roundingPrecision == 32 ) {
roundIncrement = LIT64( 0x0000008000000000 );
roundMask = LIT64( 0x000000FFFFFFFFFF );
}
else {
goto precision80;
}
zSig0 |= ( zSig1 != 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
roundIncrement = 0;
}
else {
roundIncrement = roundMask;
if ( zSign ) {
if ( roundingMode == float_round_up ) roundIncrement = 0;
}
else {
if ( roundingMode == float_round_down ) roundIncrement = 0;
}
}
}
roundBits = zSig0 & roundMask;
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
) {
goto overflow;
}
if ( zExp <= 0 ) {
if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ( zSig0 <= zSig0 + roundIncrement );
shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
zExp = 0;
roundBits = zSig0 & roundMask;
if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( (int64_t) zSig0 < 0 ) zExp = 1;
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( zSig0 < roundIncrement ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
if ( zSig0 == 0 ) zExp = 0;
return packFloatx80( zSign, zExp, zSig0 );
precision80:
increment = ( (int64_t) zSig1 < 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
increment = 0;
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
}
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE )
&& ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
&& increment
)
) {
roundMask = 0;
overflow:
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);
if ( ( roundingMode == float_round_to_zero )
|| ( zSign && ( roundingMode == float_round_up ) )
|| ( ! zSign && ( roundingMode == float_round_down ) )
) {
return packFloatx80( zSign, 0x7FFE, ~ roundMask );
}
return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
}
if ( zExp <= 0 ) {
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ! increment
|| ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
zExp = 0;
if ( isTiny && zSig1 ) float_raise( float_flag_underflow STATUS_VAR);
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundNearestEven ) {
increment = ( (int64_t) zSig1 < 0 );
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
if ( increment ) {
++zSig0;
zSig0 &=
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
if ( (int64_t) zSig0 < 0 ) zExp = 1;
}
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( increment ) {
++zSig0;
if ( zSig0 == 0 ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
else {
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
}
}
else {
if ( zSig0 == 0 ) zExp = 0;
}
return packFloatx80( zSign, zExp, zSig0 );
}
| {
"code": [
" if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );"
],
"line_no": [
91
]
} | FUNC_0(
int8 VAR_0, flag VAR_1, int32 VAR_2, uint64_t VAR_3, uint64_t VAR_4
STATUS_PARAM)
{
int8 roundingMode;
flag roundNearestEven, increment, isTiny;
int64 roundIncrement, roundMask, roundBits;
roundingMode = STATUS(float_rounding_mode);
roundNearestEven = ( roundingMode == float_round_nearest_even );
if ( VAR_0 == 80 ) goto precision80;
if ( VAR_0 == 64 ) {
roundIncrement = LIT64( 0x0000000000000400 );
roundMask = LIT64( 0x00000000000007FF );
}
else if ( VAR_0 == 32 ) {
roundIncrement = LIT64( 0x0000008000000000 );
roundMask = LIT64( 0x000000FFFFFFFFFF );
}
else {
goto precision80;
}
VAR_3 |= ( VAR_4 != 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
roundIncrement = 0;
}
else {
roundIncrement = roundMask;
if ( VAR_1 ) {
if ( roundingMode == float_round_up ) roundIncrement = 0;
}
else {
if ( roundingMode == float_round_down ) roundIncrement = 0;
}
}
}
roundBits = VAR_3 & roundMask;
if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {
if ( ( 0x7FFE < VAR_2 )
|| ( ( VAR_2 == 0x7FFE ) && ( VAR_3 + roundIncrement < VAR_3 ) )
) {
goto overflow;
}
if ( VAR_2 <= 0 ) {
if ( STATUS(flush_to_zero) ) return packFloatx80( VAR_1, 0, 0 );
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( VAR_2 < 0 )
|| ( VAR_3 <= VAR_3 + roundIncrement );
shift64RightJamming( VAR_3, 1 - VAR_2, &VAR_3 );
VAR_2 = 0;
roundBits = VAR_3 & roundMask;
if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
VAR_3 += roundIncrement;
if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
VAR_3 &= ~ roundMask;
return packFloatx80( VAR_1, VAR_2, VAR_3 );
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
VAR_3 += roundIncrement;
if ( VAR_3 < roundIncrement ) {
++VAR_2;
VAR_3 = LIT64( 0x8000000000000000 );
}
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
VAR_3 &= ~ roundMask;
if ( VAR_3 == 0 ) VAR_2 = 0;
return packFloatx80( VAR_1, VAR_2, VAR_3 );
precision80:
increment = ( (int64_t) VAR_4 < 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
increment = 0;
}
else {
if ( VAR_1 ) {
increment = ( roundingMode == float_round_down ) && VAR_4;
}
else {
increment = ( roundingMode == float_round_up ) && VAR_4;
}
}
}
if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {
if ( ( 0x7FFE < VAR_2 )
|| ( ( VAR_2 == 0x7FFE )
&& ( VAR_3 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
&& increment
)
) {
roundMask = 0;
overflow:
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);
if ( ( roundingMode == float_round_to_zero )
|| ( VAR_1 && ( roundingMode == float_round_up ) )
|| ( ! VAR_1 && ( roundingMode == float_round_down ) )
) {
return packFloatx80( VAR_1, 0x7FFE, ~ roundMask );
}
return packFloatx80( VAR_1, 0x7FFF, LIT64( 0x8000000000000000 ) );
}
if ( VAR_2 <= 0 ) {
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( VAR_2 < 0 )
|| ! increment
|| ( VAR_3 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
shift64ExtraRightJamming( VAR_3, VAR_4, 1 - VAR_2, &VAR_3, &VAR_4 );
VAR_2 = 0;
if ( isTiny && VAR_4 ) float_raise( float_flag_underflow STATUS_VAR);
if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundNearestEven ) {
increment = ( (int64_t) VAR_4 < 0 );
}
else {
if ( VAR_1 ) {
increment = ( roundingMode == float_round_down ) && VAR_4;
}
else {
increment = ( roundingMode == float_round_up ) && VAR_4;
}
}
if ( increment ) {
++VAR_3;
VAR_3 &=
~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );
if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;
}
return packFloatx80( VAR_1, VAR_2, VAR_3 );
}
}
if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( increment ) {
++VAR_3;
if ( VAR_3 == 0 ) {
++VAR_2;
VAR_3 = LIT64( 0x8000000000000000 );
}
else {
VAR_3 &= ~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );
}
}
else {
if ( VAR_3 == 0 ) VAR_2 = 0;
}
return packFloatx80( VAR_1, VAR_2, VAR_3 );
}
| [
"FUNC_0(\nint8 VAR_0, flag VAR_1, int32 VAR_2, uint64_t VAR_3, uint64_t VAR_4\nSTATUS_PARAM)\n{",
"int8 roundingMode;",
"flag roundNearestEven, increment, isTiny;",
"int64 roundIncrement, roundMask, roundBits;",
"roundingMode = STATUS(float_rounding_mode);",
"roundNearestEven = ( roundingMode == float_round_nearest_even );",
"if ( VAR_0 == 80 ) goto precision80;",
"if ( VAR_0 == 64 ) {",
"roundIncrement = LIT64( 0x0000000000000400 );",
"roundMask = LIT64( 0x00000000000007FF );",
"}",
"else if ( VAR_0 == 32 ) {",
"roundIncrement = LIT64( 0x0000008000000000 );",
"roundMask = LIT64( 0x000000FFFFFFFFFF );",
"}",
"else {",
"goto precision80;",
"}",
"VAR_3 |= ( VAR_4 != 0 );",
"if ( ! roundNearestEven ) {",
"if ( roundingMode == float_round_to_zero ) {",
"roundIncrement = 0;",
"}",
"else {",
"roundIncrement = roundMask;",
"if ( VAR_1 ) {",
"if ( roundingMode == float_round_up ) roundIncrement = 0;",
"}",
"else {",
"if ( roundingMode == float_round_down ) roundIncrement = 0;",
"}",
"}",
"}",
"roundBits = VAR_3 & roundMask;",
"if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {",
"if ( ( 0x7FFE < VAR_2 )\n|| ( ( VAR_2 == 0x7FFE ) && ( VAR_3 + roundIncrement < VAR_3 ) )\n) {",
"goto overflow;",
"}",
"if ( VAR_2 <= 0 ) {",
"if ( STATUS(flush_to_zero) ) return packFloatx80( VAR_1, 0, 0 );",
"isTiny =\n( STATUS(float_detect_tininess) == float_tininess_before_rounding )\n|| ( VAR_2 < 0 )\n|| ( VAR_3 <= VAR_3 + roundIncrement );",
"shift64RightJamming( VAR_3, 1 - VAR_2, &VAR_3 );",
"VAR_2 = 0;",
"roundBits = VAR_3 & roundMask;",
"if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);",
"if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;",
"VAR_3 += roundIncrement;",
"if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;",
"roundIncrement = roundMask + 1;",
"if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {",
"roundMask |= roundIncrement;",
"}",
"VAR_3 &= ~ roundMask;",
"return packFloatx80( VAR_1, VAR_2, VAR_3 );",
"}",
"}",
"if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;",
"VAR_3 += roundIncrement;",
"if ( VAR_3 < roundIncrement ) {",
"++VAR_2;",
"VAR_3 = LIT64( 0x8000000000000000 );",
"}",
"roundIncrement = roundMask + 1;",
"if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {",
"roundMask |= roundIncrement;",
"}",
"VAR_3 &= ~ roundMask;",
"if ( VAR_3 == 0 ) VAR_2 = 0;",
"return packFloatx80( VAR_1, VAR_2, VAR_3 );",
"precision80:\nincrement = ( (int64_t) VAR_4 < 0 );",
"if ( ! roundNearestEven ) {",
"if ( roundingMode == float_round_to_zero ) {",
"increment = 0;",
"}",
"else {",
"if ( VAR_1 ) {",
"increment = ( roundingMode == float_round_down ) && VAR_4;",
"}",
"else {",
"increment = ( roundingMode == float_round_up ) && VAR_4;",
"}",
"}",
"}",
"if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {",
"if ( ( 0x7FFE < VAR_2 )\n|| ( ( VAR_2 == 0x7FFE )\n&& ( VAR_3 == LIT64( 0xFFFFFFFFFFFFFFFF ) )\n&& increment\n)\n) {",
"roundMask = 0;",
"overflow:\nfloat_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);",
"if ( ( roundingMode == float_round_to_zero )\n|| ( VAR_1 && ( roundingMode == float_round_up ) )\n|| ( ! VAR_1 && ( roundingMode == float_round_down ) )\n) {",
"return packFloatx80( VAR_1, 0x7FFE, ~ roundMask );",
"}",
"return packFloatx80( VAR_1, 0x7FFF, LIT64( 0x8000000000000000 ) );",
"}",
"if ( VAR_2 <= 0 ) {",
"isTiny =\n( STATUS(float_detect_tininess) == float_tininess_before_rounding )\n|| ( VAR_2 < 0 )\n|| ! increment\n|| ( VAR_3 < LIT64( 0xFFFFFFFFFFFFFFFF ) );",
"shift64ExtraRightJamming( VAR_3, VAR_4, 1 - VAR_2, &VAR_3, &VAR_4 );",
"VAR_2 = 0;",
"if ( isTiny && VAR_4 ) float_raise( float_flag_underflow STATUS_VAR);",
"if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;",
"if ( roundNearestEven ) {",
"increment = ( (int64_t) VAR_4 < 0 );",
"}",
"else {",
"if ( VAR_1 ) {",
"increment = ( roundingMode == float_round_down ) && VAR_4;",
"}",
"else {",
"increment = ( roundingMode == float_round_up ) && VAR_4;",
"}",
"}",
"if ( increment ) {",
"++VAR_3;",
"VAR_3 &=\n~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );",
"if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;",
"}",
"return packFloatx80( VAR_1, VAR_2, VAR_3 );",
"}",
"}",
"if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;",
"if ( increment ) {",
"++VAR_3;",
"if ( VAR_3 == 0 ) {",
"++VAR_2;",
"VAR_3 = LIT64( 0x8000000000000000 );",
"}",
"else {",
"VAR_3 &= ~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );",
"}",
"}",
"else {",
"if ( VAR_3 == 0 ) VAR_2 = 0;",
"}",
"return packFloatx80( VAR_1, VAR_2, VAR_3 );",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
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
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191,
193,
195,
197,
199
],
[
201
],
[
203,
205
],
[
207,
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227,
229,
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315
]
] |
25,188 | static void win_stdio_close(CharDriverState *chr)
{
WinStdioCharState *stdio = chr->opaque;
if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputReadyEvent);
}
if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputDoneEvent);
}
if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
TerminateThread(stdio->hInputThread, 0);
}
g_free(chr->opaque);
g_free(chr);
}
| true | qemu | ba60e727b0a824baa1762264be5ef67dc30a6bac | static void win_stdio_close(CharDriverState *chr)
{
WinStdioCharState *stdio = chr->opaque;
if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputReadyEvent);
}
if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputDoneEvent);
}
if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
TerminateThread(stdio->hInputThread, 0);
}
g_free(chr->opaque);
g_free(chr);
}
| {
"code": [
" g_free(chr);"
],
"line_no": [
31
]
} | static void FUNC_0(CharDriverState *VAR_0)
{
WinStdioCharState *stdio = VAR_0->opaque;
if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputReadyEvent);
}
if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) {
CloseHandle(stdio->hInputDoneEvent);
}
if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
TerminateThread(stdio->hInputThread, 0);
}
g_free(VAR_0->opaque);
g_free(VAR_0);
}
| [
"static void FUNC_0(CharDriverState *VAR_0)\n{",
"WinStdioCharState *stdio = VAR_0->opaque;",
"if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {",
"CloseHandle(stdio->hInputReadyEvent);",
"}",
"if (stdio->hInputDoneEvent != INVALID_HANDLE_VALUE) {",
"CloseHandle(stdio->hInputDoneEvent);",
"}",
"if (stdio->hInputThread != INVALID_HANDLE_VALUE) {",
"TerminateThread(stdio->hInputThread, 0);",
"}",
"g_free(VAR_0->opaque);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
]
] |
25,190 | static int i2c_slave_post_load(void *opaque, int version_id)
{
I2CSlave *dev = opaque;
I2CBus *bus;
I2CNode *node;
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if ((bus->saved_address == dev->address) || (bus->broadcast)) {
node = g_malloc(sizeof(struct I2CNode));
node->elt = dev;
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
}
return 0;
}
| true | qemu | 71ae65e552fc6e03572e430009b98b80b40f1c4d | static int i2c_slave_post_load(void *opaque, int version_id)
{
I2CSlave *dev = opaque;
I2CBus *bus;
I2CNode *node;
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if ((bus->saved_address == dev->address) || (bus->broadcast)) {
node = g_malloc(sizeof(struct I2CNode));
node->elt = dev;
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
}
return 0;
}
| {
"code": [
" if ((bus->saved_address == dev->address) || (bus->broadcast)) {"
],
"line_no": [
15
]
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
I2CSlave *dev = VAR_0;
I2CBus *bus;
I2CNode *node;
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if ((bus->saved_address == dev->address) || (bus->broadcast)) {
node = g_malloc(sizeof(struct I2CNode));
node->elt = dev;
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"I2CSlave *dev = VAR_0;",
"I2CBus *bus;",
"I2CNode *node;",
"bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));",
"if ((bus->saved_address == dev->address) || (bus->broadcast)) {",
"node = g_malloc(sizeof(struct I2CNode));",
"node->elt = dev;",
"QLIST_INSERT_HEAD(&bus->current_devs, node, next);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,191 | int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
{
#ifdef CONFIG_PPOLL
if (timeout < 0) {
return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
} else {
struct timespec ts;
ts.tv_sec = timeout / 1000000000LL;
ts.tv_nsec = timeout % 1000000000LL;
return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
}
#else
return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
#endif
}
| true | qemu | 490309fcfbed9fa1ed357541f609975016a34628 | int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
{
#ifdef CONFIG_PPOLL
if (timeout < 0) {
return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
} else {
struct timespec ts;
ts.tv_sec = timeout / 1000000000LL;
ts.tv_nsec = timeout % 1000000000LL;
return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
}
#else
return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
#endif
}
| {
"code": [
" ts.tv_sec = timeout / 1000000000LL;"
],
"line_no": [
15
]
} | int FUNC_0(GPollFD *VAR_0, guint VAR_1, int64_t VAR_2)
{
#ifdef CONFIG_PPOLL
if (VAR_2 < 0) {
return ppoll((struct pollfd *)VAR_0, VAR_1, NULL, NULL);
} else {
struct timespec ts;
ts.tv_sec = VAR_2 / 1000000000LL;
ts.tv_nsec = VAR_2 % 1000000000LL;
return ppoll((struct pollfd *)VAR_0, VAR_1, &ts, NULL);
}
#else
return g_poll(VAR_0, VAR_1, qemu_timeout_ns_to_ms(VAR_2));
#endif
}
| [
"int FUNC_0(GPollFD *VAR_0, guint VAR_1, int64_t VAR_2)\n{",
"#ifdef CONFIG_PPOLL\nif (VAR_2 < 0) {",
"return ppoll((struct pollfd *)VAR_0, VAR_1, NULL, NULL);",
"} else {",
"struct timespec ts;",
"ts.tv_sec = VAR_2 / 1000000000LL;",
"ts.tv_nsec = VAR_2 % 1000000000LL;",
"return ppoll((struct pollfd *)VAR_0, VAR_1, &ts, NULL);",
"}",
"#else\nreturn g_poll(VAR_0, VAR_1, qemu_timeout_ns_to_ms(VAR_2));",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
]
] |
25,192 | const char *error_get_pretty(Error *err)
{
return err->msg;
}
| true | qemu | d59ce6f34434bf47a9b26138c908650bf9a24be1 | const char *error_get_pretty(Error *err)
{
return err->msg;
}
| {
"code": [
"const char *error_get_pretty(Error *err)"
],
"line_no": [
1
]
} | const char *FUNC_0(Error *VAR_0)
{
return VAR_0->msg;
}
| [
"const char *FUNC_0(Error *VAR_0)\n{",
"return VAR_0->msg;",
"}"
] | [
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,193 | static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUFileRDMA *r = opaque;
QEMUFile *f = r->file;
RDMAContext *rdma = r->rdma;
size_t remaining = size;
uint8_t * data = (void *) buf;
int ret;
CHECK_ERROR_STATE();
/*
* Push out any writes that
* we're queued up for VM's ram.
*/
ret = qemu_rdma_write_flush(f, rdma);
if (ret < 0) {
rdma->error_state = ret;
return ret;
}
while (remaining) {
RDMAControlHeader head;
r->len = MIN(remaining, RDMA_SEND_INCREMENT);
remaining -= r->len;
head.len = r->len;
head.type = RDMA_CONTROL_QEMU_FILE;
ret = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);
if (ret < 0) {
rdma->error_state = ret;
return ret;
}
data += r->len;
}
return size;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_put_buffer(void *opaque, const uint8_t *buf,
int64_t pos, int size)
{
QEMUFileRDMA *r = opaque;
QEMUFile *f = r->file;
RDMAContext *rdma = r->rdma;
size_t remaining = size;
uint8_t * data = (void *) buf;
int ret;
CHECK_ERROR_STATE();
ret = qemu_rdma_write_flush(f, rdma);
if (ret < 0) {
rdma->error_state = ret;
return ret;
}
while (remaining) {
RDMAControlHeader head;
r->len = MIN(remaining, RDMA_SEND_INCREMENT);
remaining -= r->len;
head.len = r->len;
head.type = RDMA_CONTROL_QEMU_FILE;
ret = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);
if (ret < 0) {
rdma->error_state = ret;
return ret;
}
data += r->len;
}
return size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, const uint8_t *VAR_1,
int64_t VAR_2, int VAR_3)
{
QEMUFileRDMA *r = VAR_0;
QEMUFile *f = r->file;
RDMAContext *rdma = r->rdma;
size_t remaining = VAR_3;
uint8_t * data = (void *) VAR_1;
int VAR_4;
CHECK_ERROR_STATE();
VAR_4 = qemu_rdma_write_flush(f, rdma);
if (VAR_4 < 0) {
rdma->error_state = VAR_4;
return VAR_4;
}
while (remaining) {
RDMAControlHeader head;
r->len = MIN(remaining, RDMA_SEND_INCREMENT);
remaining -= r->len;
head.len = r->len;
head.type = RDMA_CONTROL_QEMU_FILE;
VAR_4 = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);
if (VAR_4 < 0) {
rdma->error_state = VAR_4;
return VAR_4;
}
data += r->len;
}
return VAR_3;
}
| [
"static int FUNC_0(void *VAR_0, const uint8_t *VAR_1,\nint64_t VAR_2, int VAR_3)\n{",
"QEMUFileRDMA *r = VAR_0;",
"QEMUFile *f = r->file;",
"RDMAContext *rdma = r->rdma;",
"size_t remaining = VAR_3;",
"uint8_t * data = (void *) VAR_1;",
"int VAR_4;",
"CHECK_ERROR_STATE();",
"VAR_4 = qemu_rdma_write_flush(f, rdma);",
"if (VAR_4 < 0) {",
"rdma->error_state = VAR_4;",
"return VAR_4;",
"}",
"while (remaining) {",
"RDMAControlHeader head;",
"r->len = MIN(remaining, RDMA_SEND_INCREMENT);",
"remaining -= r->len;",
"head.len = r->len;",
"head.type = RDMA_CONTROL_QEMU_FILE;",
"VAR_4 = qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL, NULL);",
"if (VAR_4 < 0) {",
"rdma->error_state = VAR_4;",
"return VAR_4;",
"}",
"data += r->len;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
25,195 | static int peer_has_ufo(VirtIONet *n)
{
if (!peer_has_vnet_hdr(n))
return 0;
n->has_ufo = qemu_peer_has_ufo(qemu_get_queue(n->nic));
return n->has_ufo;
}
| false | qemu | d6085e3ace20bc9b0fa625d8d79b22668710e217 | static int peer_has_ufo(VirtIONet *n)
{
if (!peer_has_vnet_hdr(n))
return 0;
n->has_ufo = qemu_peer_has_ufo(qemu_get_queue(n->nic));
return n->has_ufo;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VirtIONet *VAR_0)
{
if (!peer_has_vnet_hdr(VAR_0))
return 0;
VAR_0->has_ufo = qemu_peer_has_ufo(qemu_get_queue(VAR_0->nic));
return VAR_0->has_ufo;
}
| [
"static int FUNC_0(VirtIONet *VAR_0)\n{",
"if (!peer_has_vnet_hdr(VAR_0))\nreturn 0;",
"VAR_0->has_ufo = qemu_peer_has_ufo(qemu_get_queue(VAR_0->nic));",
"return VAR_0->has_ufo;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
15
],
[
17
]
] |
25,196 | static uint64_t apb_pci_config_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
uint32_t ret;
APBState *s = opaque;
ret = pci_data_read(s->bus, addr, size);
ret = qemu_bswap_len(ret, size);
APB_DPRINTF("%s: addr " TARGET_FMT_lx " -> %x\n", __func__, addr, ret);
return ret;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t apb_pci_config_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
uint32_t ret;
APBState *s = opaque;
ret = pci_data_read(s->bus, addr, size);
ret = qemu_bswap_len(ret, size);
APB_DPRINTF("%s: addr " TARGET_FMT_lx " -> %x\n", __func__, addr, ret);
return ret;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
uint32_t ret;
APBState *s = opaque;
ret = pci_data_read(s->bus, addr, size);
ret = qemu_bswap_len(ret, size);
APB_DPRINTF("%s: addr " TARGET_FMT_lx " -> %x\n", __func__, addr, ret);
return ret;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"uint32_t ret;",
"APBState *s = opaque;",
"ret = pci_data_read(s->bus, addr, size);",
"ret = qemu_bswap_len(ret, size);",
"APB_DPRINTF(\"%s: addr \" TARGET_FMT_lx \" -> %x\\n\", __func__, addr, ret);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
25,198 | void s390_pci_sclp_deconfigure(SCCB *sccb)
{
PciCfgSccb *psccb = (PciCfgSccb *)sccb;
S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(s390_get_phb(),
be32_to_cpu(psccb->aid));
uint16_t rc;
if (be16_to_cpu(sccb->h.length) < 16) {
rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;
goto out;
}
if (!pbdev) {
DPRINTF("sclp deconfig no dev found\n");
rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
goto out;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
rc = SCLP_RC_ADAPTER_IN_RESERVED_STATE;
break;
case ZPCI_FS_STANDBY:
rc = SCLP_RC_NO_ACTION_REQUIRED;
break;
default:
if (pbdev->summary_ind) {
pci_dereg_irqs(pbdev);
}
if (pbdev->iommu->enabled) {
pci_dereg_ioat(pbdev->iommu);
}
pbdev->state = ZPCI_FS_STANDBY;
rc = SCLP_RC_NORMAL_COMPLETION;
if (pbdev->release_timer) {
qdev_unplug(DEVICE(pbdev->pdev), NULL);
}
}
out:
psccb->header.response_code = cpu_to_be16(rc);
}
| false | qemu | 80b7a265362c870f95fb5ca1f7e7a02c0fa0db3e | void s390_pci_sclp_deconfigure(SCCB *sccb)
{
PciCfgSccb *psccb = (PciCfgSccb *)sccb;
S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(s390_get_phb(),
be32_to_cpu(psccb->aid));
uint16_t rc;
if (be16_to_cpu(sccb->h.length) < 16) {
rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;
goto out;
}
if (!pbdev) {
DPRINTF("sclp deconfig no dev found\n");
rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
goto out;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
rc = SCLP_RC_ADAPTER_IN_RESERVED_STATE;
break;
case ZPCI_FS_STANDBY:
rc = SCLP_RC_NO_ACTION_REQUIRED;
break;
default:
if (pbdev->summary_ind) {
pci_dereg_irqs(pbdev);
}
if (pbdev->iommu->enabled) {
pci_dereg_ioat(pbdev->iommu);
}
pbdev->state = ZPCI_FS_STANDBY;
rc = SCLP_RC_NORMAL_COMPLETION;
if (pbdev->release_timer) {
qdev_unplug(DEVICE(pbdev->pdev), NULL);
}
}
out:
psccb->header.response_code = cpu_to_be16(rc);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(SCCB *VAR_0)
{
PciCfgSccb *psccb = (PciCfgSccb *)VAR_0;
S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(s390_get_phb(),
be32_to_cpu(psccb->aid));
uint16_t rc;
if (be16_to_cpu(VAR_0->h.length) < 16) {
rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;
goto out;
}
if (!pbdev) {
DPRINTF("sclp deconfig no dev found\n");
rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;
goto out;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
rc = SCLP_RC_ADAPTER_IN_RESERVED_STATE;
break;
case ZPCI_FS_STANDBY:
rc = SCLP_RC_NO_ACTION_REQUIRED;
break;
default:
if (pbdev->summary_ind) {
pci_dereg_irqs(pbdev);
}
if (pbdev->iommu->enabled) {
pci_dereg_ioat(pbdev->iommu);
}
pbdev->state = ZPCI_FS_STANDBY;
rc = SCLP_RC_NORMAL_COMPLETION;
if (pbdev->release_timer) {
qdev_unplug(DEVICE(pbdev->pdev), NULL);
}
}
out:
psccb->header.response_code = cpu_to_be16(rc);
}
| [
"void FUNC_0(SCCB *VAR_0)\n{",
"PciCfgSccb *psccb = (PciCfgSccb *)VAR_0;",
"S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(s390_get_phb(),\nbe32_to_cpu(psccb->aid));",
"uint16_t rc;",
"if (be16_to_cpu(VAR_0->h.length) < 16) {",
"rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;",
"goto out;",
"}",
"if (!pbdev) {",
"DPRINTF(\"sclp deconfig no dev found\\n\");",
"rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED;",
"goto out;",
"}",
"switch (pbdev->state) {",
"case ZPCI_FS_RESERVED:\nrc = SCLP_RC_ADAPTER_IN_RESERVED_STATE;",
"break;",
"case ZPCI_FS_STANDBY:\nrc = SCLP_RC_NO_ACTION_REQUIRED;",
"break;",
"default:\nif (pbdev->summary_ind) {",
"pci_dereg_irqs(pbdev);",
"}",
"if (pbdev->iommu->enabled) {",
"pci_dereg_ioat(pbdev->iommu);",
"}",
"pbdev->state = ZPCI_FS_STANDBY;",
"rc = SCLP_RC_NORMAL_COMPLETION;",
"if (pbdev->release_timer) {",
"qdev_unplug(DEVICE(pbdev->pdev), NULL);",
"}",
"}",
"out:\npsccb->header.response_code = cpu_to_be16(rc);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
]
] |
25,199 | void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
ram_addr_t region_offset)
{
target_phys_addr_t addr, end_addr;
PhysPageDesc *p;
CPUState *env;
ram_addr_t orig_size = size;
void *subpage;
#ifdef CONFIG_KQEMU
/* XXX: should not depend on cpu context */
env = first_cpu;
if (env->kqemu_enabled) {
kqemu_set_phys_mem(start_addr, size, phys_offset);
}
#endif
if (kvm_enabled())
kvm_set_phys_mem(start_addr, size, phys_offset);
if (phys_offset == IO_MEM_UNASSIGNED) {
region_offset = start_addr;
}
region_offset &= TARGET_PAGE_MASK;
size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
end_addr = start_addr + (target_phys_addr_t)size;
for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) {
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (p && p->phys_offset != IO_MEM_UNASSIGNED) {
ram_addr_t orig_memory = p->phys_offset;
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2,
need_subpage);
if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) {
if (!(orig_memory & IO_MEM_SUBPAGE)) {
subpage = subpage_init((addr & TARGET_PAGE_MASK),
&p->phys_offset, orig_memory,
p->region_offset);
} else {
subpage = io_mem_opaque[(orig_memory & ~TARGET_PAGE_MASK)
>> IO_MEM_SHIFT];
}
subpage_register(subpage, start_addr2, end_addr2, phys_offset,
region_offset);
p->region_offset = 0;
} else {
p->phys_offset = phys_offset;
if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(phys_offset & IO_MEM_ROMD))
phys_offset += TARGET_PAGE_SIZE;
}
} else {
p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
p->phys_offset = phys_offset;
p->region_offset = region_offset;
if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(phys_offset & IO_MEM_ROMD)) {
phys_offset += TARGET_PAGE_SIZE;
} else {
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr,
end_addr2, need_subpage);
if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) {
subpage = subpage_init((addr & TARGET_PAGE_MASK),
&p->phys_offset, IO_MEM_UNASSIGNED,
addr & TARGET_PAGE_MASK);
subpage_register(subpage, start_addr2, end_addr2,
phys_offset, region_offset);
p->region_offset = 0;
}
}
}
region_offset += TARGET_PAGE_SIZE;
}
/* since each CPU stores ram addresses in its TLB cache, we must
reset the modified entries */
/* XXX: slow ! */
for(env = first_cpu; env != NULL; env = env->next_cpu) {
tlb_flush(env, 1);
}
}
| false | qemu | 4a1418e07bdcfaa3177739e04707ecaec75d89e1 | void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
ram_addr_t region_offset)
{
target_phys_addr_t addr, end_addr;
PhysPageDesc *p;
CPUState *env;
ram_addr_t orig_size = size;
void *subpage;
#ifdef CONFIG_KQEMU
env = first_cpu;
if (env->kqemu_enabled) {
kqemu_set_phys_mem(start_addr, size, phys_offset);
}
#endif
if (kvm_enabled())
kvm_set_phys_mem(start_addr, size, phys_offset);
if (phys_offset == IO_MEM_UNASSIGNED) {
region_offset = start_addr;
}
region_offset &= TARGET_PAGE_MASK;
size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
end_addr = start_addr + (target_phys_addr_t)size;
for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) {
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (p && p->phys_offset != IO_MEM_UNASSIGNED) {
ram_addr_t orig_memory = p->phys_offset;
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr, end_addr2,
need_subpage);
if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) {
if (!(orig_memory & IO_MEM_SUBPAGE)) {
subpage = subpage_init((addr & TARGET_PAGE_MASK),
&p->phys_offset, orig_memory,
p->region_offset);
} else {
subpage = io_mem_opaque[(orig_memory & ~TARGET_PAGE_MASK)
>> IO_MEM_SHIFT];
}
subpage_register(subpage, start_addr2, end_addr2, phys_offset,
region_offset);
p->region_offset = 0;
} else {
p->phys_offset = phys_offset;
if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(phys_offset & IO_MEM_ROMD))
phys_offset += TARGET_PAGE_SIZE;
}
} else {
p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
p->phys_offset = phys_offset;
p->region_offset = region_offset;
if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(phys_offset & IO_MEM_ROMD)) {
phys_offset += TARGET_PAGE_SIZE;
} else {
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, start_addr, start_addr2, end_addr,
end_addr2, need_subpage);
if (need_subpage || phys_offset & IO_MEM_SUBWIDTH) {
subpage = subpage_init((addr & TARGET_PAGE_MASK),
&p->phys_offset, IO_MEM_UNASSIGNED,
addr & TARGET_PAGE_MASK);
subpage_register(subpage, start_addr2, end_addr2,
phys_offset, region_offset);
p->region_offset = 0;
}
}
}
region_offset += TARGET_PAGE_SIZE;
}
for(env = first_cpu; env != NULL; env = env->next_cpu) {
tlb_flush(env, 1);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_phys_addr_t VAR_0,
ram_addr_t VAR_1,
ram_addr_t VAR_2,
ram_addr_t VAR_3)
{
target_phys_addr_t addr, end_addr;
PhysPageDesc *p;
CPUState *env;
ram_addr_t orig_size = VAR_1;
void *VAR_4;
#ifdef CONFIG_KQEMU
env = first_cpu;
if (env->kqemu_enabled) {
kqemu_set_phys_mem(VAR_0, VAR_1, VAR_2);
}
#endif
if (kvm_enabled())
kvm_set_phys_mem(VAR_0, VAR_1, VAR_2);
if (VAR_2 == IO_MEM_UNASSIGNED) {
VAR_3 = VAR_0;
}
VAR_3 &= TARGET_PAGE_MASK;
VAR_1 = (VAR_1 + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
end_addr = VAR_0 + (target_phys_addr_t)VAR_1;
for(addr = VAR_0; addr != end_addr; addr += TARGET_PAGE_SIZE) {
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (p && p->VAR_2 != IO_MEM_UNASSIGNED) {
ram_addr_t orig_memory = p->VAR_2;
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, VAR_0, start_addr2, end_addr, end_addr2,
need_subpage);
if (need_subpage || VAR_2 & IO_MEM_SUBWIDTH) {
if (!(orig_memory & IO_MEM_SUBPAGE)) {
VAR_4 = subpage_init((addr & TARGET_PAGE_MASK),
&p->VAR_2, orig_memory,
p->VAR_3);
} else {
VAR_4 = io_mem_opaque[(orig_memory & ~TARGET_PAGE_MASK)
>> IO_MEM_SHIFT];
}
subpage_register(VAR_4, start_addr2, end_addr2, VAR_2,
VAR_3);
p->VAR_3 = 0;
} else {
p->VAR_2 = VAR_2;
if ((VAR_2 & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(VAR_2 & IO_MEM_ROMD))
VAR_2 += TARGET_PAGE_SIZE;
}
} else {
p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
p->VAR_2 = VAR_2;
p->VAR_3 = VAR_3;
if ((VAR_2 & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
(VAR_2 & IO_MEM_ROMD)) {
VAR_2 += TARGET_PAGE_SIZE;
} else {
target_phys_addr_t start_addr2, end_addr2;
int need_subpage = 0;
CHECK_SUBPAGE(addr, VAR_0, start_addr2, end_addr,
end_addr2, need_subpage);
if (need_subpage || VAR_2 & IO_MEM_SUBWIDTH) {
VAR_4 = subpage_init((addr & TARGET_PAGE_MASK),
&p->VAR_2, IO_MEM_UNASSIGNED,
addr & TARGET_PAGE_MASK);
subpage_register(VAR_4, start_addr2, end_addr2,
VAR_2, VAR_3);
p->VAR_3 = 0;
}
}
}
VAR_3 += TARGET_PAGE_SIZE;
}
for(env = first_cpu; env != NULL; env = env->next_cpu) {
tlb_flush(env, 1);
}
}
| [
"void FUNC_0(target_phys_addr_t VAR_0,\nram_addr_t VAR_1,\nram_addr_t VAR_2,\nram_addr_t VAR_3)\n{",
"target_phys_addr_t addr, end_addr;",
"PhysPageDesc *p;",
"CPUState *env;",
"ram_addr_t orig_size = VAR_1;",
"void *VAR_4;",
"#ifdef CONFIG_KQEMU\nenv = first_cpu;",
"if (env->kqemu_enabled) {",
"kqemu_set_phys_mem(VAR_0, VAR_1, VAR_2);",
"}",
"#endif\nif (kvm_enabled())\nkvm_set_phys_mem(VAR_0, VAR_1, VAR_2);",
"if (VAR_2 == IO_MEM_UNASSIGNED) {",
"VAR_3 = VAR_0;",
"}",
"VAR_3 &= TARGET_PAGE_MASK;",
"VAR_1 = (VAR_1 + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;",
"end_addr = VAR_0 + (target_phys_addr_t)VAR_1;",
"for(addr = VAR_0; addr != end_addr; addr += TARGET_PAGE_SIZE) {",
"p = phys_page_find(addr >> TARGET_PAGE_BITS);",
"if (p && p->VAR_2 != IO_MEM_UNASSIGNED) {",
"ram_addr_t orig_memory = p->VAR_2;",
"target_phys_addr_t start_addr2, end_addr2;",
"int need_subpage = 0;",
"CHECK_SUBPAGE(addr, VAR_0, start_addr2, end_addr, end_addr2,\nneed_subpage);",
"if (need_subpage || VAR_2 & IO_MEM_SUBWIDTH) {",
"if (!(orig_memory & IO_MEM_SUBPAGE)) {",
"VAR_4 = subpage_init((addr & TARGET_PAGE_MASK),\n&p->VAR_2, orig_memory,\np->VAR_3);",
"} else {",
"VAR_4 = io_mem_opaque[(orig_memory & ~TARGET_PAGE_MASK)\n>> IO_MEM_SHIFT];",
"}",
"subpage_register(VAR_4, start_addr2, end_addr2, VAR_2,\nVAR_3);",
"p->VAR_3 = 0;",
"} else {",
"p->VAR_2 = VAR_2;",
"if ((VAR_2 & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||\n(VAR_2 & IO_MEM_ROMD))\nVAR_2 += TARGET_PAGE_SIZE;",
"}",
"} else {",
"p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);",
"p->VAR_2 = VAR_2;",
"p->VAR_3 = VAR_3;",
"if ((VAR_2 & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||\n(VAR_2 & IO_MEM_ROMD)) {",
"VAR_2 += TARGET_PAGE_SIZE;",
"} else {",
"target_phys_addr_t start_addr2, end_addr2;",
"int need_subpage = 0;",
"CHECK_SUBPAGE(addr, VAR_0, start_addr2, end_addr,\nend_addr2, need_subpage);",
"if (need_subpage || VAR_2 & IO_MEM_SUBWIDTH) {",
"VAR_4 = subpage_init((addr & TARGET_PAGE_MASK),\n&p->VAR_2, IO_MEM_UNASSIGNED,\naddr & TARGET_PAGE_MASK);",
"subpage_register(VAR_4, start_addr2, end_addr2,\nVAR_2, VAR_3);",
"p->VAR_3 = 0;",
"}",
"}",
"}",
"VAR_3 += TARGET_PAGE_SIZE;",
"}",
"for(env = first_cpu; env != NULL; env = env->next_cpu) {",
"tlb_flush(env, 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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
27
],
[
29
],
[
31
],
[
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
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101,
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131,
133
],
[
137
],
[
139,
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
169
],
[
171
],
[
173
],
[
175
]
] |
25,200 | static void help(int exitcode)
{
const char *options_help =
#define QEMU_OPTIONS_GENERATE_HELP
#include "qemu-options-wrapper.h"
;
version();
printf("usage: %s [options] [disk_image]\n"
"\n"
"'disk_image' is a raw hard disk image for IDE hard disk 0\n"
"\n"
"%s\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
"ctrl-alt-n switch to virtual console 'n'\n"
"ctrl-alt toggle mouse and keyboard grab\n"
"\n"
"When using -nographic, press 'ctrl-a h' to get some help.\n",
error_get_progname(),
options_help);
exit(exitcode);
}
| false | qemu | a3adb7ad3bd9c517d569e7e23b249e7f7d616015 | static void help(int exitcode)
{
const char *options_help =
#define QEMU_OPTIONS_GENERATE_HELP
#include "qemu-options-wrapper.h"
;
version();
printf("usage: %s [options] [disk_image]\n"
"\n"
"'disk_image' is a raw hard disk image for IDE hard disk 0\n"
"\n"
"%s\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
"ctrl-alt-n switch to virtual console 'n'\n"
"ctrl-alt toggle mouse and keyboard grab\n"
"\n"
"When using -nographic, press 'ctrl-a h' to get some help.\n",
error_get_progname(),
options_help);
exit(exitcode);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0)
{
const char *VAR_1 =
#define QEMU_OPTIONS_GENERATE_HELP
#include "qemu-options-wrapper.h"
;
version();
printf("usage: %s [options] [disk_image]\n"
"\n"
"'disk_image' is a raw hard disk image for IDE hard disk 0\n"
"\n"
"%s\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
"ctrl-alt-n switch to virtual console 'n'\n"
"ctrl-alt toggle mouse and keyboard grab\n"
"\n"
"When using -nographic, press 'ctrl-a h' to get some FUNC_0.\n",
error_get_progname(),
VAR_1);
exit(VAR_0);
}
| [
"static void FUNC_0(int VAR_0)\n{",
"const char *VAR_1 =\n#define QEMU_OPTIONS_GENERATE_HELP\n#include \"qemu-options-wrapper.h\"\n;",
"version();",
"printf(\"usage: %s [options] [disk_image]\\n\"\n\"\\n\"\n\"'disk_image' is a raw hard disk image for IDE hard disk 0\\n\"\n\"\\n\"\n\"%s\\n\"\n\"During emulation, the following keys are useful:\\n\"\n\"ctrl-alt-f toggle full screen\\n\"\n\"ctrl-alt-n switch to virtual console 'n'\\n\"\n\"ctrl-alt toggle mouse and keyboard grab\\n\"\n\"\\n\"\n\"When using -nographic, press 'ctrl-a h' to get some FUNC_0.\\n\",\nerror_get_progname(),\nVAR_1);",
"exit(VAR_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
]
] |
25,201 | static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
unsigned dest, unsigned srca)
{
TCGv tdest, tsrca;
const char *mnemonic;
TCGMemOp memop;
TileExcp ret = TILEGX_EXCP_NONE;
/* Eliminate instructions with no output before doing anything else. */
switch (opext) {
case OE_RR_Y0(NOP):
case OE_RR_Y1(NOP):
case OE_RR_X0(NOP):
case OE_RR_X1(NOP):
mnemonic = "nop";
goto done0;
case OE_RR_Y0(FNOP):
case OE_RR_Y1(FNOP):
case OE_RR_X0(FNOP):
case OE_RR_X1(FNOP):
mnemonic = "fnop";
goto done0;
case OE_RR_X1(DRAIN):
mnemonic = "drain";
goto done0;
case OE_RR_X1(FLUSHWB):
mnemonic = "flushwb";
goto done0;
case OE_RR_X1(ILL):
if (dest == 0x1c && srca == 0x25) {
mnemonic = "bpt";
goto done2;
}
/* Fall through */
case OE_RR_Y1(ILL):
mnemonic = "ill";
done2:
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", mnemonic);
return TILEGX_EXCP_OPCODE_UNKNOWN;
case OE_RR_X1(MF):
mnemonic = "mf";
goto done0;
case OE_RR_X1(NAP):
/* ??? This should yield, especially in system mode. */
mnemonic = "nap";
goto done0;
case OE_RR_X1(SWINT0):
case OE_RR_X1(SWINT2):
case OE_RR_X1(SWINT3):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(SWINT1):
ret = TILEGX_EXCP_SYSCALL;
mnemonic = "swint1";
done0:
if (srca || dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", mnemonic);
return ret;
case OE_RR_X1(DTLBPR):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(FINV):
mnemonic = "finv";
goto done1;
case OE_RR_X1(FLUSH):
mnemonic = "flush";
goto done1;
case OE_RR_X1(ICOH):
mnemonic = "icoh";
goto done1;
case OE_RR_X1(INV):
mnemonic = "inv";
goto done1;
case OE_RR_X1(WH64):
mnemonic = "wh64";
goto done1;
case OE_RR_X1(JRP):
case OE_RR_Y1(JRP):
mnemonic = "jrp";
goto do_jr;
case OE_RR_X1(JR):
case OE_RR_Y1(JR):
mnemonic = "jr";
goto do_jr;
case OE_RR_X1(JALRP):
case OE_RR_Y1(JALRP):
mnemonic = "jalrp";
goto do_jalr;
case OE_RR_X1(JALR):
case OE_RR_Y1(JALR):
mnemonic = "jalr";
do_jalr:
tcg_gen_movi_tl(dest_gr(dc, TILEGX_R_LR),
dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
do_jr:
dc->jmp.cond = TCG_COND_ALWAYS;
dc->jmp.dest = tcg_temp_new();
tcg_gen_andi_tl(dc->jmp.dest, load_gr(dc, srca), ~7);
done1:
if (dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s", mnemonic, reg_names[srca]);
return ret;
}
tdest = dest_gr(dc, dest);
tsrca = load_gr(dc, srca);
switch (opext) {
case OE_RR_X0(CNTLZ):
case OE_RR_Y0(CNTLZ):
gen_helper_cntlz(tdest, tsrca);
mnemonic = "cntlz";
break;
case OE_RR_X0(CNTTZ):
case OE_RR_Y0(CNTTZ):
gen_helper_cnttz(tdest, tsrca);
mnemonic = "cnttz";
break;
case OE_RR_X0(FSINGLE_PACK1):
case OE_RR_Y0(FSINGLE_PACK1):
case OE_RR_X1(IRET):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(LD1S):
memop = MO_SB;
mnemonic = "ld1s";
goto do_load;
case OE_RR_X1(LD1U):
memop = MO_UB;
mnemonic = "ld1u";
goto do_load;
case OE_RR_X1(LD2S):
memop = MO_TESW;
mnemonic = "ld2s";
goto do_load;
case OE_RR_X1(LD2U):
memop = MO_TEUW;
mnemonic = "ld2u";
goto do_load;
case OE_RR_X1(LD4S):
memop = MO_TESL;
mnemonic = "ld4s";
goto do_load;
case OE_RR_X1(LD4U):
memop = MO_TEUL;
mnemonic = "ld4u";
goto do_load;
case OE_RR_X1(LDNT1S):
memop = MO_SB;
mnemonic = "ldnt1s";
goto do_load;
case OE_RR_X1(LDNT1U):
memop = MO_UB;
mnemonic = "ldnt1u";
goto do_load;
case OE_RR_X1(LDNT2S):
memop = MO_TESW;
mnemonic = "ldnt2s";
goto do_load;
case OE_RR_X1(LDNT2U):
memop = MO_TEUW;
mnemonic = "ldnt2u";
goto do_load;
case OE_RR_X1(LDNT4S):
memop = MO_TESL;
mnemonic = "ldnt4s";
goto do_load;
case OE_RR_X1(LDNT4U):
memop = MO_TEUL;
mnemonic = "ldnt4u";
goto do_load;
case OE_RR_X1(LDNT):
memop = MO_TEQ;
mnemonic = "ldnt";
goto do_load;
case OE_RR_X1(LD):
memop = MO_TEQ;
mnemonic = "ld";
do_load:
tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
break;
case OE_RR_X1(LDNA):
tcg_gen_andi_tl(tdest, tsrca, ~7);
tcg_gen_qemu_ld_tl(tdest, tdest, dc->mmuidx, MO_TEQ);
mnemonic = "ldna";
break;
case OE_RR_X1(LNK):
case OE_RR_Y1(LNK):
if (srca) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
tcg_gen_movi_tl(tdest, dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
mnemonic = "lnk";
break;
case OE_RR_X0(PCNT):
case OE_RR_Y0(PCNT):
gen_helper_pcnt(tdest, tsrca);
mnemonic = "pcnt";
break;
case OE_RR_X0(REVBITS):
case OE_RR_Y0(REVBITS):
gen_helper_revbits(tdest, tsrca);
mnemonic = "revbits";
break;
case OE_RR_X0(REVBYTES):
case OE_RR_Y0(REVBYTES):
tcg_gen_bswap64_tl(tdest, tsrca);
mnemonic = "revbytes";
break;
case OE_RR_X0(TBLIDXB0):
case OE_RR_Y0(TBLIDXB0):
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tsrca, 2, 8);
mnemonic = "tblidxb0";
break;
case OE_RR_X0(TBLIDXB1):
case OE_RR_Y0(TBLIDXB1):
tcg_gen_shri_tl(tdest, tsrca, 8);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb1";
break;
case OE_RR_X0(TBLIDXB2):
case OE_RR_Y0(TBLIDXB2):
tcg_gen_shri_tl(tdest, tsrca, 16);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb2";
break;
case OE_RR_X0(TBLIDXB3):
case OE_RR_Y0(TBLIDXB3):
tcg_gen_shri_tl(tdest, tsrca, 24);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb3";
break;
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s, %s", mnemonic,
reg_names[dest], reg_names[srca]);
return ret;
}
| false | qemu | dd8070d865ad1b32876931f812a80645f97112ff | static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
unsigned dest, unsigned srca)
{
TCGv tdest, tsrca;
const char *mnemonic;
TCGMemOp memop;
TileExcp ret = TILEGX_EXCP_NONE;
switch (opext) {
case OE_RR_Y0(NOP):
case OE_RR_Y1(NOP):
case OE_RR_X0(NOP):
case OE_RR_X1(NOP):
mnemonic = "nop";
goto done0;
case OE_RR_Y0(FNOP):
case OE_RR_Y1(FNOP):
case OE_RR_X0(FNOP):
case OE_RR_X1(FNOP):
mnemonic = "fnop";
goto done0;
case OE_RR_X1(DRAIN):
mnemonic = "drain";
goto done0;
case OE_RR_X1(FLUSHWB):
mnemonic = "flushwb";
goto done0;
case OE_RR_X1(ILL):
if (dest == 0x1c && srca == 0x25) {
mnemonic = "bpt";
goto done2;
}
case OE_RR_Y1(ILL):
mnemonic = "ill";
done2:
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", mnemonic);
return TILEGX_EXCP_OPCODE_UNKNOWN;
case OE_RR_X1(MF):
mnemonic = "mf";
goto done0;
case OE_RR_X1(NAP):
mnemonic = "nap";
goto done0;
case OE_RR_X1(SWINT0):
case OE_RR_X1(SWINT2):
case OE_RR_X1(SWINT3):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(SWINT1):
ret = TILEGX_EXCP_SYSCALL;
mnemonic = "swint1";
done0:
if (srca || dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", mnemonic);
return ret;
case OE_RR_X1(DTLBPR):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(FINV):
mnemonic = "finv";
goto done1;
case OE_RR_X1(FLUSH):
mnemonic = "flush";
goto done1;
case OE_RR_X1(ICOH):
mnemonic = "icoh";
goto done1;
case OE_RR_X1(INV):
mnemonic = "inv";
goto done1;
case OE_RR_X1(WH64):
mnemonic = "wh64";
goto done1;
case OE_RR_X1(JRP):
case OE_RR_Y1(JRP):
mnemonic = "jrp";
goto do_jr;
case OE_RR_X1(JR):
case OE_RR_Y1(JR):
mnemonic = "jr";
goto do_jr;
case OE_RR_X1(JALRP):
case OE_RR_Y1(JALRP):
mnemonic = "jalrp";
goto do_jalr;
case OE_RR_X1(JALR):
case OE_RR_Y1(JALR):
mnemonic = "jalr";
do_jalr:
tcg_gen_movi_tl(dest_gr(dc, TILEGX_R_LR),
dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
do_jr:
dc->jmp.cond = TCG_COND_ALWAYS;
dc->jmp.dest = tcg_temp_new();
tcg_gen_andi_tl(dc->jmp.dest, load_gr(dc, srca), ~7);
done1:
if (dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s", mnemonic, reg_names[srca]);
return ret;
}
tdest = dest_gr(dc, dest);
tsrca = load_gr(dc, srca);
switch (opext) {
case OE_RR_X0(CNTLZ):
case OE_RR_Y0(CNTLZ):
gen_helper_cntlz(tdest, tsrca);
mnemonic = "cntlz";
break;
case OE_RR_X0(CNTTZ):
case OE_RR_Y0(CNTTZ):
gen_helper_cnttz(tdest, tsrca);
mnemonic = "cnttz";
break;
case OE_RR_X0(FSINGLE_PACK1):
case OE_RR_Y0(FSINGLE_PACK1):
case OE_RR_X1(IRET):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(LD1S):
memop = MO_SB;
mnemonic = "ld1s";
goto do_load;
case OE_RR_X1(LD1U):
memop = MO_UB;
mnemonic = "ld1u";
goto do_load;
case OE_RR_X1(LD2S):
memop = MO_TESW;
mnemonic = "ld2s";
goto do_load;
case OE_RR_X1(LD2U):
memop = MO_TEUW;
mnemonic = "ld2u";
goto do_load;
case OE_RR_X1(LD4S):
memop = MO_TESL;
mnemonic = "ld4s";
goto do_load;
case OE_RR_X1(LD4U):
memop = MO_TEUL;
mnemonic = "ld4u";
goto do_load;
case OE_RR_X1(LDNT1S):
memop = MO_SB;
mnemonic = "ldnt1s";
goto do_load;
case OE_RR_X1(LDNT1U):
memop = MO_UB;
mnemonic = "ldnt1u";
goto do_load;
case OE_RR_X1(LDNT2S):
memop = MO_TESW;
mnemonic = "ldnt2s";
goto do_load;
case OE_RR_X1(LDNT2U):
memop = MO_TEUW;
mnemonic = "ldnt2u";
goto do_load;
case OE_RR_X1(LDNT4S):
memop = MO_TESL;
mnemonic = "ldnt4s";
goto do_load;
case OE_RR_X1(LDNT4U):
memop = MO_TEUL;
mnemonic = "ldnt4u";
goto do_load;
case OE_RR_X1(LDNT):
memop = MO_TEQ;
mnemonic = "ldnt";
goto do_load;
case OE_RR_X1(LD):
memop = MO_TEQ;
mnemonic = "ld";
do_load:
tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
break;
case OE_RR_X1(LDNA):
tcg_gen_andi_tl(tdest, tsrca, ~7);
tcg_gen_qemu_ld_tl(tdest, tdest, dc->mmuidx, MO_TEQ);
mnemonic = "ldna";
break;
case OE_RR_X1(LNK):
case OE_RR_Y1(LNK):
if (srca) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
tcg_gen_movi_tl(tdest, dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
mnemonic = "lnk";
break;
case OE_RR_X0(PCNT):
case OE_RR_Y0(PCNT):
gen_helper_pcnt(tdest, tsrca);
mnemonic = "pcnt";
break;
case OE_RR_X0(REVBITS):
case OE_RR_Y0(REVBITS):
gen_helper_revbits(tdest, tsrca);
mnemonic = "revbits";
break;
case OE_RR_X0(REVBYTES):
case OE_RR_Y0(REVBYTES):
tcg_gen_bswap64_tl(tdest, tsrca);
mnemonic = "revbytes";
break;
case OE_RR_X0(TBLIDXB0):
case OE_RR_Y0(TBLIDXB0):
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tsrca, 2, 8);
mnemonic = "tblidxb0";
break;
case OE_RR_X0(TBLIDXB1):
case OE_RR_Y0(TBLIDXB1):
tcg_gen_shri_tl(tdest, tsrca, 8);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb1";
break;
case OE_RR_X0(TBLIDXB2):
case OE_RR_Y0(TBLIDXB2):
tcg_gen_shri_tl(tdest, tsrca, 16);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb2";
break;
case OE_RR_X0(TBLIDXB3):
case OE_RR_Y0(TBLIDXB3):
tcg_gen_shri_tl(tdest, tsrca, 24);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
mnemonic = "tblidxb3";
break;
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s, %s", mnemonic,
reg_names[dest], reg_names[srca]);
return ret;
}
| {
"code": [],
"line_no": []
} | static TileExcp FUNC_0(DisasContext *dc, unsigned opext,
unsigned dest, unsigned srca)
{
TCGv tdest, tsrca;
const char *VAR_0;
TCGMemOp memop;
TileExcp ret = TILEGX_EXCP_NONE;
switch (opext) {
case OE_RR_Y0(NOP):
case OE_RR_Y1(NOP):
case OE_RR_X0(NOP):
case OE_RR_X1(NOP):
VAR_0 = "nop";
goto done0;
case OE_RR_Y0(FNOP):
case OE_RR_Y1(FNOP):
case OE_RR_X0(FNOP):
case OE_RR_X1(FNOP):
VAR_0 = "fnop";
goto done0;
case OE_RR_X1(DRAIN):
VAR_0 = "drain";
goto done0;
case OE_RR_X1(FLUSHWB):
VAR_0 = "flushwb";
goto done0;
case OE_RR_X1(ILL):
if (dest == 0x1c && srca == 0x25) {
VAR_0 = "bpt";
goto done2;
}
case OE_RR_Y1(ILL):
VAR_0 = "ill";
done2:
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", VAR_0);
return TILEGX_EXCP_OPCODE_UNKNOWN;
case OE_RR_X1(MF):
VAR_0 = "mf";
goto done0;
case OE_RR_X1(NAP):
VAR_0 = "nap";
goto done0;
case OE_RR_X1(SWINT0):
case OE_RR_X1(SWINT2):
case OE_RR_X1(SWINT3):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(SWINT1):
ret = TILEGX_EXCP_SYSCALL;
VAR_0 = "swint1";
done0:
if (srca || dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s", VAR_0);
return ret;
case OE_RR_X1(DTLBPR):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(FINV):
VAR_0 = "finv";
goto done1;
case OE_RR_X1(FLUSH):
VAR_0 = "flush";
goto done1;
case OE_RR_X1(ICOH):
VAR_0 = "icoh";
goto done1;
case OE_RR_X1(INV):
VAR_0 = "inv";
goto done1;
case OE_RR_X1(WH64):
VAR_0 = "wh64";
goto done1;
case OE_RR_X1(JRP):
case OE_RR_Y1(JRP):
VAR_0 = "jrp";
goto do_jr;
case OE_RR_X1(JR):
case OE_RR_Y1(JR):
VAR_0 = "jr";
goto do_jr;
case OE_RR_X1(JALRP):
case OE_RR_Y1(JALRP):
VAR_0 = "jalrp";
goto do_jalr;
case OE_RR_X1(JALR):
case OE_RR_Y1(JALR):
VAR_0 = "jalr";
do_jalr:
tcg_gen_movi_tl(dest_gr(dc, TILEGX_R_LR),
dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
do_jr:
dc->jmp.cond = TCG_COND_ALWAYS;
dc->jmp.dest = tcg_temp_new();
tcg_gen_andi_tl(dc->jmp.dest, load_gr(dc, srca), ~7);
done1:
if (dest) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s", VAR_0, reg_names[srca]);
return ret;
}
tdest = dest_gr(dc, dest);
tsrca = load_gr(dc, srca);
switch (opext) {
case OE_RR_X0(CNTLZ):
case OE_RR_Y0(CNTLZ):
gen_helper_cntlz(tdest, tsrca);
VAR_0 = "cntlz";
break;
case OE_RR_X0(CNTTZ):
case OE_RR_Y0(CNTTZ):
gen_helper_cnttz(tdest, tsrca);
VAR_0 = "cnttz";
break;
case OE_RR_X0(FSINGLE_PACK1):
case OE_RR_Y0(FSINGLE_PACK1):
case OE_RR_X1(IRET):
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
case OE_RR_X1(LD1S):
memop = MO_SB;
VAR_0 = "ld1s";
goto do_load;
case OE_RR_X1(LD1U):
memop = MO_UB;
VAR_0 = "ld1u";
goto do_load;
case OE_RR_X1(LD2S):
memop = MO_TESW;
VAR_0 = "ld2s";
goto do_load;
case OE_RR_X1(LD2U):
memop = MO_TEUW;
VAR_0 = "ld2u";
goto do_load;
case OE_RR_X1(LD4S):
memop = MO_TESL;
VAR_0 = "ld4s";
goto do_load;
case OE_RR_X1(LD4U):
memop = MO_TEUL;
VAR_0 = "ld4u";
goto do_load;
case OE_RR_X1(LDNT1S):
memop = MO_SB;
VAR_0 = "ldnt1s";
goto do_load;
case OE_RR_X1(LDNT1U):
memop = MO_UB;
VAR_0 = "ldnt1u";
goto do_load;
case OE_RR_X1(LDNT2S):
memop = MO_TESW;
VAR_0 = "ldnt2s";
goto do_load;
case OE_RR_X1(LDNT2U):
memop = MO_TEUW;
VAR_0 = "ldnt2u";
goto do_load;
case OE_RR_X1(LDNT4S):
memop = MO_TESL;
VAR_0 = "ldnt4s";
goto do_load;
case OE_RR_X1(LDNT4U):
memop = MO_TEUL;
VAR_0 = "ldnt4u";
goto do_load;
case OE_RR_X1(LDNT):
memop = MO_TEQ;
VAR_0 = "ldnt";
goto do_load;
case OE_RR_X1(LD):
memop = MO_TEQ;
VAR_0 = "ld";
do_load:
tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
break;
case OE_RR_X1(LDNA):
tcg_gen_andi_tl(tdest, tsrca, ~7);
tcg_gen_qemu_ld_tl(tdest, tdest, dc->mmuidx, MO_TEQ);
VAR_0 = "ldna";
break;
case OE_RR_X1(LNK):
case OE_RR_Y1(LNK):
if (srca) {
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
tcg_gen_movi_tl(tdest, dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);
VAR_0 = "lnk";
break;
case OE_RR_X0(PCNT):
case OE_RR_Y0(PCNT):
gen_helper_pcnt(tdest, tsrca);
VAR_0 = "pcnt";
break;
case OE_RR_X0(REVBITS):
case OE_RR_Y0(REVBITS):
gen_helper_revbits(tdest, tsrca);
VAR_0 = "revbits";
break;
case OE_RR_X0(REVBYTES):
case OE_RR_Y0(REVBYTES):
tcg_gen_bswap64_tl(tdest, tsrca);
VAR_0 = "revbytes";
break;
case OE_RR_X0(TBLIDXB0):
case OE_RR_Y0(TBLIDXB0):
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tsrca, 2, 8);
VAR_0 = "tblidxb0";
break;
case OE_RR_X0(TBLIDXB1):
case OE_RR_Y0(TBLIDXB1):
tcg_gen_shri_tl(tdest, tsrca, 8);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
VAR_0 = "tblidxb1";
break;
case OE_RR_X0(TBLIDXB2):
case OE_RR_Y0(TBLIDXB2):
tcg_gen_shri_tl(tdest, tsrca, 16);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
VAR_0 = "tblidxb2";
break;
case OE_RR_X0(TBLIDXB3):
case OE_RR_Y0(TBLIDXB3):
tcg_gen_shri_tl(tdest, tsrca, 24);
tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);
VAR_0 = "tblidxb3";
break;
default:
return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;
}
qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s, %s", VAR_0,
reg_names[dest], reg_names[srca]);
return ret;
}
| [
"static TileExcp FUNC_0(DisasContext *dc, unsigned opext,\nunsigned dest, unsigned srca)\n{",
"TCGv tdest, tsrca;",
"const char *VAR_0;",
"TCGMemOp memop;",
"TileExcp ret = TILEGX_EXCP_NONE;",
"switch (opext) {",
"case OE_RR_Y0(NOP):\ncase OE_RR_Y1(NOP):\ncase OE_RR_X0(NOP):\ncase OE_RR_X1(NOP):\nVAR_0 = \"nop\";",
"goto done0;",
"case OE_RR_Y0(FNOP):\ncase OE_RR_Y1(FNOP):\ncase OE_RR_X0(FNOP):\ncase OE_RR_X1(FNOP):\nVAR_0 = \"fnop\";",
"goto done0;",
"case OE_RR_X1(DRAIN):\nVAR_0 = \"drain\";",
"goto done0;",
"case OE_RR_X1(FLUSHWB):\nVAR_0 = \"flushwb\";",
"goto done0;",
"case OE_RR_X1(ILL):\nif (dest == 0x1c && srca == 0x25) {",
"VAR_0 = \"bpt\";",
"goto done2;",
"}",
"case OE_RR_Y1(ILL):\nVAR_0 = \"ill\";",
"done2:\nqemu_log_mask(CPU_LOG_TB_IN_ASM, \"%s\", VAR_0);",
"return TILEGX_EXCP_OPCODE_UNKNOWN;",
"case OE_RR_X1(MF):\nVAR_0 = \"mf\";",
"goto done0;",
"case OE_RR_X1(NAP):\nVAR_0 = \"nap\";",
"goto done0;",
"case OE_RR_X1(SWINT0):\ncase OE_RR_X1(SWINT2):\ncase OE_RR_X1(SWINT3):\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"case OE_RR_X1(SWINT1):\nret = TILEGX_EXCP_SYSCALL;",
"VAR_0 = \"swint1\";",
"done0:\nif (srca || dest) {",
"return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"qemu_log_mask(CPU_LOG_TB_IN_ASM, \"%s\", VAR_0);",
"return ret;",
"case OE_RR_X1(DTLBPR):\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"case OE_RR_X1(FINV):\nVAR_0 = \"finv\";",
"goto done1;",
"case OE_RR_X1(FLUSH):\nVAR_0 = \"flush\";",
"goto done1;",
"case OE_RR_X1(ICOH):\nVAR_0 = \"icoh\";",
"goto done1;",
"case OE_RR_X1(INV):\nVAR_0 = \"inv\";",
"goto done1;",
"case OE_RR_X1(WH64):\nVAR_0 = \"wh64\";",
"goto done1;",
"case OE_RR_X1(JRP):\ncase OE_RR_Y1(JRP):\nVAR_0 = \"jrp\";",
"goto do_jr;",
"case OE_RR_X1(JR):\ncase OE_RR_Y1(JR):\nVAR_0 = \"jr\";",
"goto do_jr;",
"case OE_RR_X1(JALRP):\ncase OE_RR_Y1(JALRP):\nVAR_0 = \"jalrp\";",
"goto do_jalr;",
"case OE_RR_X1(JALR):\ncase OE_RR_Y1(JALR):\nVAR_0 = \"jalr\";",
"do_jalr:\ntcg_gen_movi_tl(dest_gr(dc, TILEGX_R_LR),\ndc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);",
"do_jr:\ndc->jmp.cond = TCG_COND_ALWAYS;",
"dc->jmp.dest = tcg_temp_new();",
"tcg_gen_andi_tl(dc->jmp.dest, load_gr(dc, srca), ~7);",
"done1:\nif (dest) {",
"return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"qemu_log_mask(CPU_LOG_TB_IN_ASM, \"%s %s\", VAR_0, reg_names[srca]);",
"return ret;",
"}",
"tdest = dest_gr(dc, dest);",
"tsrca = load_gr(dc, srca);",
"switch (opext) {",
"case OE_RR_X0(CNTLZ):\ncase OE_RR_Y0(CNTLZ):\ngen_helper_cntlz(tdest, tsrca);",
"VAR_0 = \"cntlz\";",
"break;",
"case OE_RR_X0(CNTTZ):\ncase OE_RR_Y0(CNTTZ):\ngen_helper_cnttz(tdest, tsrca);",
"VAR_0 = \"cnttz\";",
"break;",
"case OE_RR_X0(FSINGLE_PACK1):\ncase OE_RR_Y0(FSINGLE_PACK1):\ncase OE_RR_X1(IRET):\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"case OE_RR_X1(LD1S):\nmemop = MO_SB;",
"VAR_0 = \"ld1s\";",
"goto do_load;",
"case OE_RR_X1(LD1U):\nmemop = MO_UB;",
"VAR_0 = \"ld1u\";",
"goto do_load;",
"case OE_RR_X1(LD2S):\nmemop = MO_TESW;",
"VAR_0 = \"ld2s\";",
"goto do_load;",
"case OE_RR_X1(LD2U):\nmemop = MO_TEUW;",
"VAR_0 = \"ld2u\";",
"goto do_load;",
"case OE_RR_X1(LD4S):\nmemop = MO_TESL;",
"VAR_0 = \"ld4s\";",
"goto do_load;",
"case OE_RR_X1(LD4U):\nmemop = MO_TEUL;",
"VAR_0 = \"ld4u\";",
"goto do_load;",
"case OE_RR_X1(LDNT1S):\nmemop = MO_SB;",
"VAR_0 = \"ldnt1s\";",
"goto do_load;",
"case OE_RR_X1(LDNT1U):\nmemop = MO_UB;",
"VAR_0 = \"ldnt1u\";",
"goto do_load;",
"case OE_RR_X1(LDNT2S):\nmemop = MO_TESW;",
"VAR_0 = \"ldnt2s\";",
"goto do_load;",
"case OE_RR_X1(LDNT2U):\nmemop = MO_TEUW;",
"VAR_0 = \"ldnt2u\";",
"goto do_load;",
"case OE_RR_X1(LDNT4S):\nmemop = MO_TESL;",
"VAR_0 = \"ldnt4s\";",
"goto do_load;",
"case OE_RR_X1(LDNT4U):\nmemop = MO_TEUL;",
"VAR_0 = \"ldnt4u\";",
"goto do_load;",
"case OE_RR_X1(LDNT):\nmemop = MO_TEQ;",
"VAR_0 = \"ldnt\";",
"goto do_load;",
"case OE_RR_X1(LD):\nmemop = MO_TEQ;",
"VAR_0 = \"ld\";",
"do_load:\ntcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);",
"break;",
"case OE_RR_X1(LDNA):\ntcg_gen_andi_tl(tdest, tsrca, ~7);",
"tcg_gen_qemu_ld_tl(tdest, tdest, dc->mmuidx, MO_TEQ);",
"VAR_0 = \"ldna\";",
"break;",
"case OE_RR_X1(LNK):\ncase OE_RR_Y1(LNK):\nif (srca) {",
"return TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"tcg_gen_movi_tl(tdest, dc->pc + TILEGX_BUNDLE_SIZE_IN_BYTES);",
"VAR_0 = \"lnk\";",
"break;",
"case OE_RR_X0(PCNT):\ncase OE_RR_Y0(PCNT):\ngen_helper_pcnt(tdest, tsrca);",
"VAR_0 = \"pcnt\";",
"break;",
"case OE_RR_X0(REVBITS):\ncase OE_RR_Y0(REVBITS):\ngen_helper_revbits(tdest, tsrca);",
"VAR_0 = \"revbits\";",
"break;",
"case OE_RR_X0(REVBYTES):\ncase OE_RR_Y0(REVBYTES):\ntcg_gen_bswap64_tl(tdest, tsrca);",
"VAR_0 = \"revbytes\";",
"break;",
"case OE_RR_X0(TBLIDXB0):\ncase OE_RR_Y0(TBLIDXB0):\ntcg_gen_deposit_tl(tdest, load_gr(dc, dest), tsrca, 2, 8);",
"VAR_0 = \"tblidxb0\";",
"break;",
"case OE_RR_X0(TBLIDXB1):\ncase OE_RR_Y0(TBLIDXB1):\ntcg_gen_shri_tl(tdest, tsrca, 8);",
"tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);",
"VAR_0 = \"tblidxb1\";",
"break;",
"case OE_RR_X0(TBLIDXB2):\ncase OE_RR_Y0(TBLIDXB2):\ntcg_gen_shri_tl(tdest, tsrca, 16);",
"tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);",
"VAR_0 = \"tblidxb2\";",
"break;",
"case OE_RR_X0(TBLIDXB3):\ncase OE_RR_Y0(TBLIDXB3):\ntcg_gen_shri_tl(tdest, tsrca, 24);",
"tcg_gen_deposit_tl(tdest, load_gr(dc, dest), tdest, 2, 8);",
"VAR_0 = \"tblidxb3\";",
"break;",
"default:\nreturn TILEGX_EXCP_OPCODE_UNIMPLEMENTED;",
"}",
"qemu_log_mask(CPU_LOG_TB_IN_ASM, \"%s %s, %s\", VAR_0,\nreg_names[dest], reg_names[srca]);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23,
25,
27,
29
],
[
31
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
89
],
[
91
],
[
93,
95,
97,
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
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
],
[
215
],
[
217
],
[
221
],
[
223,
225,
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
239
],
[
241
],
[
243,
245,
247,
249
],
[
251,
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267,
269
],
[
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283,
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307,
309
],
[
311
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355,
357
],
[
359
],
[
361,
363
],
[
365
],
[
367,
369
],
[
371
],
[
373
],
[
375
],
[
377,
379,
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393,
395,
397
],
[
399
],
[
401
],
[
403,
405,
407
],
[
409
],
[
411
],
[
413,
415,
417
],
[
419
],
[
421
],
[
423,
425,
427
],
[
429
],
[
431
],
[
433,
435,
437
],
[
439
],
[
441
],
[
443
],
[
445,
447,
449
],
[
451
],
[
453
],
[
455
],
[
457,
459,
461
],
[
463
],
[
465
],
[
467
],
[
469,
471
],
[
473
],
[
477,
479
],
[
481
],
[
483
]
] |
25,202 | static void etsec_cleanup(NetClientState *nc)
{
/* qemu_log("eTSEC cleanup\n"); */
}
| false | qemu | 57407ea44cc0a3d630b9b89a2be011f1955ce5c1 | static void etsec_cleanup(NetClientState *nc)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(NetClientState *VAR_0)
{
}
| [
"static void FUNC_0(NetClientState *VAR_0)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
7
]
] |
25,203 | static void qmp_input_push(QmpInputVisitor *qiv, const QObject *obj, Error **errp)
{
qiv->stack[qiv->nb_stack].obj = obj;
if (qobject_type(obj) == QTYPE_QLIST) {
qiv->stack[qiv->nb_stack].entry = qlist_first(qobject_to_qlist(obj));
}
qiv->nb_stack++;
if (qiv->nb_stack >= QIV_STACK_SIZE) {
error_set(errp, QERR_BUFFER_OVERRUN);
return;
}
}
| false | qemu | 3a86a0fa76b5103a122b6e817b3827b2837f4956 | static void qmp_input_push(QmpInputVisitor *qiv, const QObject *obj, Error **errp)
{
qiv->stack[qiv->nb_stack].obj = obj;
if (qobject_type(obj) == QTYPE_QLIST) {
qiv->stack[qiv->nb_stack].entry = qlist_first(qobject_to_qlist(obj));
}
qiv->nb_stack++;
if (qiv->nb_stack >= QIV_STACK_SIZE) {
error_set(errp, QERR_BUFFER_OVERRUN);
return;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QmpInputVisitor *VAR_0, const QObject *VAR_1, Error **VAR_2)
{
VAR_0->stack[VAR_0->nb_stack].VAR_1 = VAR_1;
if (qobject_type(VAR_1) == QTYPE_QLIST) {
VAR_0->stack[VAR_0->nb_stack].entry = qlist_first(qobject_to_qlist(VAR_1));
}
VAR_0->nb_stack++;
if (VAR_0->nb_stack >= QIV_STACK_SIZE) {
error_set(VAR_2, QERR_BUFFER_OVERRUN);
return;
}
}
| [
"static void FUNC_0(QmpInputVisitor *VAR_0, const QObject *VAR_1, Error **VAR_2)\n{",
"VAR_0->stack[VAR_0->nb_stack].VAR_1 = VAR_1;",
"if (qobject_type(VAR_1) == QTYPE_QLIST) {",
"VAR_0->stack[VAR_0->nb_stack].entry = qlist_first(qobject_to_qlist(VAR_1));",
"}",
"VAR_0->nb_stack++;",
"if (VAR_0->nb_stack >= QIV_STACK_SIZE) {",
"error_set(VAR_2, QERR_BUFFER_OVERRUN);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
25,204 | static const IntelHDAReg *intel_hda_reg_find(IntelHDAState *d, target_phys_addr_t addr)
{
const IntelHDAReg *reg;
if (addr >= sizeof(regtab)/sizeof(regtab[0])) {
goto noreg;
}
reg = regtab+addr;
if (reg->name == NULL) {
goto noreg;
}
return reg;
noreg:
dprint(d, 1, "unknown register, addr 0x%x\n", (int) addr);
return NULL;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static const IntelHDAReg *intel_hda_reg_find(IntelHDAState *d, target_phys_addr_t addr)
{
const IntelHDAReg *reg;
if (addr >= sizeof(regtab)/sizeof(regtab[0])) {
goto noreg;
}
reg = regtab+addr;
if (reg->name == NULL) {
goto noreg;
}
return reg;
noreg:
dprint(d, 1, "unknown register, addr 0x%x\n", (int) addr);
return NULL;
}
| {
"code": [],
"line_no": []
} | static const IntelHDAReg *FUNC_0(IntelHDAState *d, target_phys_addr_t addr)
{
const IntelHDAReg *VAR_0;
if (addr >= sizeof(regtab)/sizeof(regtab[0])) {
goto noreg;
}
VAR_0 = regtab+addr;
if (VAR_0->name == NULL) {
goto noreg;
}
return VAR_0;
noreg:
dprint(d, 1, "unknown register, addr 0x%x\n", (int) addr);
return NULL;
}
| [
"static const IntelHDAReg *FUNC_0(IntelHDAState *d, target_phys_addr_t addr)\n{",
"const IntelHDAReg *VAR_0;",
"if (addr >= sizeof(regtab)/sizeof(regtab[0])) {",
"goto noreg;",
"}",
"VAR_0 = regtab+addr;",
"if (VAR_0->name == NULL) {",
"goto noreg;",
"}",
"return VAR_0;",
"noreg:\ndprint(d, 1, \"unknown register, addr 0x%x\\n\", (int) addr);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
33
]
] |
25,205 | build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
{
AcpiSystemResourceAffinityTable *srat;
AcpiSratProcessorGiccAffinity *core;
AcpiSratMemoryAffinity *numamem;
int i, srat_start;
uint64_t mem_base;
MachineClass *mc = MACHINE_GET_CLASS(vms);
const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms));
srat_start = table_data->len;
srat = acpi_data_push(table_data, sizeof(*srat));
srat->reserved1 = cpu_to_le32(1);
for (i = 0; i < cpu_list->len; ++i) {
int node_id = cpu_list->cpus[i].props.has_node_id ?
cpu_list->cpus[i].props.node_id : 0;
core = acpi_data_push(table_data, sizeof(*core));
core->type = ACPI_SRAT_PROCESSOR_GICC;
core->length = sizeof(*core);
core->proximity = cpu_to_le32(node_id);
core->acpi_processor_uid = cpu_to_le32(i);
core->flags = cpu_to_le32(1);
}
mem_base = vms->memmap[VIRT_MEM].base;
for (i = 0; i < nb_numa_nodes; ++i) {
numamem = acpi_data_push(table_data, sizeof(*numamem));
build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,
MEM_AFFINITY_ENABLED);
mem_base += numa_info[i].node_mem;
}
build_header(linker, table_data, (void *)srat, "SRAT",
table_data->len - srat_start, 3, NULL, NULL);
}
| false | qemu | d41f3e750d2c06c613cb1b8db7724f0fbc0a2b14 | build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
{
AcpiSystemResourceAffinityTable *srat;
AcpiSratProcessorGiccAffinity *core;
AcpiSratMemoryAffinity *numamem;
int i, srat_start;
uint64_t mem_base;
MachineClass *mc = MACHINE_GET_CLASS(vms);
const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms));
srat_start = table_data->len;
srat = acpi_data_push(table_data, sizeof(*srat));
srat->reserved1 = cpu_to_le32(1);
for (i = 0; i < cpu_list->len; ++i) {
int node_id = cpu_list->cpus[i].props.has_node_id ?
cpu_list->cpus[i].props.node_id : 0;
core = acpi_data_push(table_data, sizeof(*core));
core->type = ACPI_SRAT_PROCESSOR_GICC;
core->length = sizeof(*core);
core->proximity = cpu_to_le32(node_id);
core->acpi_processor_uid = cpu_to_le32(i);
core->flags = cpu_to_le32(1);
}
mem_base = vms->memmap[VIRT_MEM].base;
for (i = 0; i < nb_numa_nodes; ++i) {
numamem = acpi_data_push(table_data, sizeof(*numamem));
build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i,
MEM_AFFINITY_ENABLED);
mem_base += numa_info[i].node_mem;
}
build_header(linker, table_data, (void *)srat, "SRAT",
table_data->len - srat_start, 3, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1, VirtMachineState *VAR_2)
{
AcpiSystemResourceAffinityTable *srat;
AcpiSratProcessorGiccAffinity *core;
AcpiSratMemoryAffinity *numamem;
int VAR_3, VAR_4;
uint64_t mem_base;
MachineClass *mc = MACHINE_GET_CLASS(VAR_2);
const CPUArchIdList *VAR_5 = mc->possible_cpu_arch_ids(MACHINE(VAR_2));
VAR_4 = VAR_0->len;
srat = acpi_data_push(VAR_0, sizeof(*srat));
srat->reserved1 = cpu_to_le32(1);
for (VAR_3 = 0; VAR_3 < VAR_5->len; ++VAR_3) {
int node_id = VAR_5->cpus[VAR_3].props.has_node_id ?
VAR_5->cpus[VAR_3].props.node_id : 0;
core = acpi_data_push(VAR_0, sizeof(*core));
core->type = ACPI_SRAT_PROCESSOR_GICC;
core->length = sizeof(*core);
core->proximity = cpu_to_le32(node_id);
core->acpi_processor_uid = cpu_to_le32(VAR_3);
core->flags = cpu_to_le32(1);
}
mem_base = VAR_2->memmap[VIRT_MEM].base;
for (VAR_3 = 0; VAR_3 < nb_numa_nodes; ++VAR_3) {
numamem = acpi_data_push(VAR_0, sizeof(*numamem));
build_srat_memory(numamem, mem_base, numa_info[VAR_3].node_mem, VAR_3,
MEM_AFFINITY_ENABLED);
mem_base += numa_info[VAR_3].node_mem;
}
build_header(VAR_1, VAR_0, (void *)srat, "SRAT",
VAR_0->len - VAR_4, 3, NULL, NULL);
}
| [
"FUNC_0(GArray *VAR_0, BIOSLinker *VAR_1, VirtMachineState *VAR_2)\n{",
"AcpiSystemResourceAffinityTable *srat;",
"AcpiSratProcessorGiccAffinity *core;",
"AcpiSratMemoryAffinity *numamem;",
"int VAR_3, VAR_4;",
"uint64_t mem_base;",
"MachineClass *mc = MACHINE_GET_CLASS(VAR_2);",
"const CPUArchIdList *VAR_5 = mc->possible_cpu_arch_ids(MACHINE(VAR_2));",
"VAR_4 = VAR_0->len;",
"srat = acpi_data_push(VAR_0, sizeof(*srat));",
"srat->reserved1 = cpu_to_le32(1);",
"for (VAR_3 = 0; VAR_3 < VAR_5->len; ++VAR_3) {",
"int node_id = VAR_5->cpus[VAR_3].props.has_node_id ?\nVAR_5->cpus[VAR_3].props.node_id : 0;",
"core = acpi_data_push(VAR_0, sizeof(*core));",
"core->type = ACPI_SRAT_PROCESSOR_GICC;",
"core->length = sizeof(*core);",
"core->proximity = cpu_to_le32(node_id);",
"core->acpi_processor_uid = cpu_to_le32(VAR_3);",
"core->flags = cpu_to_le32(1);",
"}",
"mem_base = VAR_2->memmap[VIRT_MEM].base;",
"for (VAR_3 = 0; VAR_3 < nb_numa_nodes; ++VAR_3) {",
"numamem = acpi_data_push(VAR_0, sizeof(*numamem));",
"build_srat_memory(numamem, mem_base, numa_info[VAR_3].node_mem, VAR_3,\nMEM_AFFINITY_ENABLED);",
"mem_base += numa_info[VAR_3].node_mem;",
"}",
"build_header(VAR_1, VAR_0, (void *)srat, \"SRAT\",\nVAR_0->len - VAR_4, 3, NULL, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
]
] |
25,207 | void acpi_pcihp_init(AcpiPciHpState *s, PCIBus *root_bus,
MemoryRegion *address_space_io, bool bridges_enabled)
{
uint16_t io_size = ACPI_PCIHP_SIZE;
s->root= root_bus;
s->legacy_piix = !bridges_enabled;
if (s->legacy_piix) {
unsigned *bus_bsel = g_malloc(sizeof *bus_bsel);
io_size = ACPI_PCIHP_LEGACY_SIZE;
*bus_bsel = ACPI_PCIHP_BSEL_DEFAULT;
object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
memory_region_init_io(&s->io, NULL, &acpi_pcihp_io_ops, s,
"acpi-pci-hotplug", io_size);
memory_region_add_subregion(address_space_io, ACPI_PCIHP_ADDR, &s->io);
}
| false | qemu | 78c2d8722b9118509e3d4ed8bae67c3e4eaa443e | void acpi_pcihp_init(AcpiPciHpState *s, PCIBus *root_bus,
MemoryRegion *address_space_io, bool bridges_enabled)
{
uint16_t io_size = ACPI_PCIHP_SIZE;
s->root= root_bus;
s->legacy_piix = !bridges_enabled;
if (s->legacy_piix) {
unsigned *bus_bsel = g_malloc(sizeof *bus_bsel);
io_size = ACPI_PCIHP_LEGACY_SIZE;
*bus_bsel = ACPI_PCIHP_BSEL_DEFAULT;
object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PROP_BSEL,
bus_bsel, NULL);
}
memory_region_init_io(&s->io, NULL, &acpi_pcihp_io_ops, s,
"acpi-pci-hotplug", io_size);
memory_region_add_subregion(address_space_io, ACPI_PCIHP_ADDR, &s->io);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AcpiPciHpState *VAR_0, PCIBus *VAR_1,
MemoryRegion *VAR_2, bool VAR_3)
{
uint16_t io_size = ACPI_PCIHP_SIZE;
VAR_0->root= VAR_1;
VAR_0->legacy_piix = !VAR_3;
if (VAR_0->legacy_piix) {
unsigned *VAR_4 = g_malloc(sizeof *VAR_4);
io_size = ACPI_PCIHP_LEGACY_SIZE;
*VAR_4 = ACPI_PCIHP_BSEL_DEFAULT;
object_property_add_uint32_ptr(OBJECT(VAR_1), ACPI_PCIHP_PROP_BSEL,
VAR_4, NULL);
}
memory_region_init_io(&VAR_0->io, NULL, &acpi_pcihp_io_ops, VAR_0,
"acpi-pci-hotplug", io_size);
memory_region_add_subregion(VAR_2, ACPI_PCIHP_ADDR, &VAR_0->io);
}
| [
"void FUNC_0(AcpiPciHpState *VAR_0, PCIBus *VAR_1,\nMemoryRegion *VAR_2, bool VAR_3)\n{",
"uint16_t io_size = ACPI_PCIHP_SIZE;",
"VAR_0->root= VAR_1;",
"VAR_0->legacy_piix = !VAR_3;",
"if (VAR_0->legacy_piix) {",
"unsigned *VAR_4 = g_malloc(sizeof *VAR_4);",
"io_size = ACPI_PCIHP_LEGACY_SIZE;",
"*VAR_4 = ACPI_PCIHP_BSEL_DEFAULT;",
"object_property_add_uint32_ptr(OBJECT(VAR_1), ACPI_PCIHP_PROP_BSEL,\nVAR_4, NULL);",
"}",
"memory_region_init_io(&VAR_0->io, NULL, &acpi_pcihp_io_ops, VAR_0,\n\"acpi-pci-hotplug\", io_size);",
"memory_region_add_subregion(VAR_2, ACPI_PCIHP_ADDR, &VAR_0->io);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
]
] |
25,208 | static unsigned tget_short(GetByteContext *gb, int le)
{
unsigned v = le ? bytestream2_get_le16u(gb) : bytestream2_get_be16u(gb);
return v;
}
| false | FFmpeg | ce1ebb31a9a0e556a89cd7681082af19fbc1cced | static unsigned tget_short(GetByteContext *gb, int le)
{
unsigned v = le ? bytestream2_get_le16u(gb) : bytestream2_get_be16u(gb);
return v;
}
| {
"code": [],
"line_no": []
} | static unsigned FUNC_0(GetByteContext *VAR_0, int VAR_1)
{
unsigned VAR_2 = VAR_1 ? bytestream2_get_le16u(VAR_0) : bytestream2_get_be16u(VAR_0);
return VAR_2;
}
| [
"static unsigned FUNC_0(GetByteContext *VAR_0, int VAR_1)\n{",
"unsigned VAR_2 = VAR_1 ? bytestream2_get_le16u(VAR_0) : bytestream2_get_be16u(VAR_0);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
25,209 | static void omap_lpg_tick(void *opaque)
{
struct omap_lpg_s *s = opaque;
if (s->cycle)
timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->period - s->on);
else
timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->on);
s->cycle = !s->cycle;
printf("%s: LED is %s\n", __FUNCTION__, s->cycle ? "on" : "off");
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void omap_lpg_tick(void *opaque)
{
struct omap_lpg_s *s = opaque;
if (s->cycle)
timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->period - s->on);
else
timer_mod(s->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + s->on);
s->cycle = !s->cycle;
printf("%s: LED is %s\n", __FUNCTION__, s->cycle ? "on" : "off");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
struct omap_lpg_s *VAR_1 = VAR_0;
if (VAR_1->cycle)
timer_mod(VAR_1->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + VAR_1->period - VAR_1->on);
else
timer_mod(VAR_1->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + VAR_1->on);
VAR_1->cycle = !VAR_1->cycle;
printf("%VAR_1: LED is %VAR_1\n", __FUNCTION__, VAR_1->cycle ? "on" : "off");
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct omap_lpg_s *VAR_1 = VAR_0;",
"if (VAR_1->cycle)\ntimer_mod(VAR_1->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + VAR_1->period - VAR_1->on);",
"else\ntimer_mod(VAR_1->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + VAR_1->on);",
"VAR_1->cycle = !VAR_1->cycle;",
"printf(\"%VAR_1: LED is %VAR_1\\n\", __FUNCTION__, VAR_1->cycle ? \"on\" : \"off\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
]
] |
25,210 | static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
int completion)
{
int dir;
size_t len = 0;
#ifdef DEBUG_ISOCH
const char *str = NULL;
#endif
int pid;
int ret;
int i;
USBDevice *dev;
struct ohci_iso_td iso_td;
uint32_t addr;
uint16_t starting_frame;
int16_t relative_frame_number;
int frame_count;
uint32_t start_offset, next_offset, end_offset = 0;
uint32_t start_addr, end_addr;
addr = ed->head & OHCI_DPTR_MASK;
if (!ohci_read_iso_td(ohci, addr, &iso_td)) {
printf("usb-ohci: ISO_TD read error at %x\n", addr);
return 0;
}
starting_frame = OHCI_BM(iso_td.flags, TD_SF);
frame_count = OHCI_BM(iso_td.flags, TD_FC);
relative_frame_number = USUB(ohci->frame_number, starting_frame);
#ifdef DEBUG_ISOCH
printf("--- ISO_TD ED head 0x%.8x tailp 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"frame_number 0x%.8x starting_frame 0x%.8x\n"
"frame_count 0x%.8x relative %d\n"
"di 0x%.8x cc 0x%.8x\n",
ed->head & OHCI_DPTR_MASK, ed->tail & OHCI_DPTR_MASK,
iso_td.flags, iso_td.bp, iso_td.next, iso_td.be,
iso_td.offset[0], iso_td.offset[1], iso_td.offset[2], iso_td.offset[3],
iso_td.offset[4], iso_td.offset[5], iso_td.offset[6], iso_td.offset[7],
ohci->frame_number, starting_frame,
frame_count, relative_frame_number,
OHCI_BM(iso_td.flags, TD_DI), OHCI_BM(iso_td.flags, TD_CC));
#endif
if (relative_frame_number < 0) {
DPRINTF("usb-ohci: ISO_TD R=%d < 0\n", relative_frame_number);
return 1;
} else if (relative_frame_number > frame_count) {
/* ISO TD expired - retire the TD to the Done Queue and continue with
the next ISO TD of the same ED */
DPRINTF("usb-ohci: ISO_TD R=%d > FC=%d\n", relative_frame_number,
frame_count);
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
ohci_put_iso_td(ohci, addr, &iso_td);
return 0;
}
dir = OHCI_BM(ed->flags, ED_D);
switch (dir) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_ISOCH
str = "in";
#endif
pid = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_ISOCH
str = "out";
#endif
pid = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_ISOCH
str = "setup";
#endif
pid = USB_TOKEN_SETUP;
break;
default:
printf("usb-ohci: Bad direction %d\n", dir);
return 1;
}
if (!iso_td.bp || !iso_td.be) {
printf("usb-ohci: ISO_TD bp 0x%.8x be 0x%.8x\n", iso_td.bp, iso_td.be);
return 1;
}
start_offset = iso_td.offset[relative_frame_number];
next_offset = iso_td.offset[relative_frame_number + 1];
if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xe) ||
((relative_frame_number < frame_count) &&
!(OHCI_BM(next_offset, TD_PSW_CC) & 0xe))) {
printf("usb-ohci: ISO_TD cc != not accessed 0x%.8x 0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((relative_frame_number < frame_count) && (start_offset > next_offset)) {
printf("usb-ohci: ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((start_offset & 0x1000) == 0) {
start_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
} else {
start_addr = (iso_td.be & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
}
if (relative_frame_number < frame_count) {
end_offset = next_offset - 1;
if ((end_offset & 0x1000) == 0) {
end_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
} else {
end_addr = (iso_td.be & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
}
} else {
/* Last packet in the ISO TD */
end_addr = iso_td.be;
}
if ((start_addr & OHCI_PAGE_MASK) != (end_addr & OHCI_PAGE_MASK)) {
len = (end_addr & OHCI_OFFSET_MASK) + 0x1001
- (start_addr & OHCI_OFFSET_MASK);
} else {
len = end_addr - start_addr + 1;
}
if (len && dir != OHCI_TD_DIR_IN) {
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len, 0);
}
if (completion) {
ret = ohci->usb_packet.result;
} else {
usb_packet_setup(&ohci->usb_packet, pid,
OHCI_BM(ed->flags, ED_FA),
OHCI_BM(ed->flags, ED_EN));
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
dev = ohci_find_device(ohci, ohci->usb_packet.devaddr);
ret = usb_handle_packet(dev, &ohci->usb_packet);
if (ret == USB_RET_ASYNC) {
return 1;
}
}
#ifdef DEBUG_ISOCH
printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu ret %d\n",
start_offset, end_offset, start_addr, end_addr, str, len, ret);
#endif
/* Writeback */
if (dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len) {
/* IN transfer succeeded */
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret, 1);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, ret);
} else if (dir == OHCI_TD_DIR_OUT && ret == len) {
/* OUT transfer succeeded */
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, 0);
} else {
if (ret > (ssize_t) len) {
printf("usb-ohci: DataOverrun %d > %zu\n", ret, len);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAOVERRUN);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
len);
} else if (ret >= 0) {
printf("usb-ohci: DataUnderrun %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAUNDERRUN);
} else {
switch (ret) {
case USB_RET_NODEV:
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DEVICENOTRESPONDING);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
case USB_RET_NAK:
case USB_RET_STALL:
printf("usb-ohci: got NAK/STALL %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_STALL);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
default:
printf("usb-ohci: Bad device response %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_UNDEXPETEDPID);
break;
}
}
}
if (relative_frame_number == frame_count) {
/* Last data packet of ISO TD - retire the TD to the Done Queue */
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_NOERROR);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
}
ohci_put_iso_td(ohci, addr, &iso_td);
return 1;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
int completion)
{
int dir;
size_t len = 0;
#ifdef DEBUG_ISOCH
const char *str = NULL;
#endif
int pid;
int ret;
int i;
USBDevice *dev;
struct ohci_iso_td iso_td;
uint32_t addr;
uint16_t starting_frame;
int16_t relative_frame_number;
int frame_count;
uint32_t start_offset, next_offset, end_offset = 0;
uint32_t start_addr, end_addr;
addr = ed->head & OHCI_DPTR_MASK;
if (!ohci_read_iso_td(ohci, addr, &iso_td)) {
printf("usb-ohci: ISO_TD read error at %x\n", addr);
return 0;
}
starting_frame = OHCI_BM(iso_td.flags, TD_SF);
frame_count = OHCI_BM(iso_td.flags, TD_FC);
relative_frame_number = USUB(ohci->frame_number, starting_frame);
#ifdef DEBUG_ISOCH
printf("--- ISO_TD ED head 0x%.8x tailp 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"frame_number 0x%.8x starting_frame 0x%.8x\n"
"frame_count 0x%.8x relative %d\n"
"di 0x%.8x cc 0x%.8x\n",
ed->head & OHCI_DPTR_MASK, ed->tail & OHCI_DPTR_MASK,
iso_td.flags, iso_td.bp, iso_td.next, iso_td.be,
iso_td.offset[0], iso_td.offset[1], iso_td.offset[2], iso_td.offset[3],
iso_td.offset[4], iso_td.offset[5], iso_td.offset[6], iso_td.offset[7],
ohci->frame_number, starting_frame,
frame_count, relative_frame_number,
OHCI_BM(iso_td.flags, TD_DI), OHCI_BM(iso_td.flags, TD_CC));
#endif
if (relative_frame_number < 0) {
DPRINTF("usb-ohci: ISO_TD R=%d < 0\n", relative_frame_number);
return 1;
} else if (relative_frame_number > frame_count) {
DPRINTF("usb-ohci: ISO_TD R=%d > FC=%d\n", relative_frame_number,
frame_count);
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
ohci_put_iso_td(ohci, addr, &iso_td);
return 0;
}
dir = OHCI_BM(ed->flags, ED_D);
switch (dir) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_ISOCH
str = "in";
#endif
pid = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_ISOCH
str = "out";
#endif
pid = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_ISOCH
str = "setup";
#endif
pid = USB_TOKEN_SETUP;
break;
default:
printf("usb-ohci: Bad direction %d\n", dir);
return 1;
}
if (!iso_td.bp || !iso_td.be) {
printf("usb-ohci: ISO_TD bp 0x%.8x be 0x%.8x\n", iso_td.bp, iso_td.be);
return 1;
}
start_offset = iso_td.offset[relative_frame_number];
next_offset = iso_td.offset[relative_frame_number + 1];
if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xe) ||
((relative_frame_number < frame_count) &&
!(OHCI_BM(next_offset, TD_PSW_CC) & 0xe))) {
printf("usb-ohci: ISO_TD cc != not accessed 0x%.8x 0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((relative_frame_number < frame_count) && (start_offset > next_offset)) {
printf("usb-ohci: ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((start_offset & 0x1000) == 0) {
start_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
} else {
start_addr = (iso_td.be & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
}
if (relative_frame_number < frame_count) {
end_offset = next_offset - 1;
if ((end_offset & 0x1000) == 0) {
end_addr = (iso_td.bp & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
} else {
end_addr = (iso_td.be & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
}
} else {
end_addr = iso_td.be;
}
if ((start_addr & OHCI_PAGE_MASK) != (end_addr & OHCI_PAGE_MASK)) {
len = (end_addr & OHCI_OFFSET_MASK) + 0x1001
- (start_addr & OHCI_OFFSET_MASK);
} else {
len = end_addr - start_addr + 1;
}
if (len && dir != OHCI_TD_DIR_IN) {
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len, 0);
}
if (completion) {
ret = ohci->usb_packet.result;
} else {
usb_packet_setup(&ohci->usb_packet, pid,
OHCI_BM(ed->flags, ED_FA),
OHCI_BM(ed->flags, ED_EN));
usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
dev = ohci_find_device(ohci, ohci->usb_packet.devaddr);
ret = usb_handle_packet(dev, &ohci->usb_packet);
if (ret == USB_RET_ASYNC) {
return 1;
}
}
#ifdef DEBUG_ISOCH
printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu ret %d\n",
start_offset, end_offset, start_addr, end_addr, str, len, ret);
#endif
if (dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len) {
ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret, 1);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, ret);
} else if (dir == OHCI_TD_DIR_OUT && ret == len) {
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE, 0);
} else {
if (ret > (ssize_t) len) {
printf("usb-ohci: DataOverrun %d > %zu\n", ret, len);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAOVERRUN);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
len);
} else if (ret >= 0) {
printf("usb-ohci: DataUnderrun %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAUNDERRUN);
} else {
switch (ret) {
case USB_RET_NODEV:
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DEVICENOTRESPONDING);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
case USB_RET_NAK:
case USB_RET_STALL:
printf("usb-ohci: got NAK/STALL %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_STALL);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
default:
printf("usb-ohci: Bad device response %d\n", ret);
OHCI_SET_BM(iso_td.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_UNDEXPETEDPID);
break;
}
}
}
if (relative_frame_number == frame_count) {
OHCI_SET_BM(iso_td.flags, TD_CC, OHCI_CC_NOERROR);
ed->head &= ~OHCI_DPTR_MASK;
ed->head |= (iso_td.next & OHCI_DPTR_MASK);
iso_td.next = ohci->done;
ohci->done = addr;
i = OHCI_BM(iso_td.flags, TD_DI);
if (i < ohci->done_count)
ohci->done_count = i;
}
ohci_put_iso_td(ohci, addr, &iso_td);
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(OHCIState *VAR_0, struct ohci_ed *VAR_1,
int VAR_2)
{
int VAR_3;
size_t len = 0;
#ifdef DEBUG_ISOCH
const char *str = NULL;
#endif
int VAR_4;
int VAR_5;
int VAR_6;
USBDevice *dev;
struct ohci_iso_td VAR_7;
uint32_t addr;
uint16_t starting_frame;
int16_t relative_frame_number;
int VAR_8;
uint32_t start_offset, next_offset, end_offset = 0;
uint32_t start_addr, end_addr;
addr = VAR_1->head & OHCI_DPTR_MASK;
if (!ohci_read_iso_td(VAR_0, addr, &VAR_7)) {
printf("usb-VAR_0: ISO_TD read error at %x\n", addr);
return 0;
}
starting_frame = OHCI_BM(VAR_7.flags, TD_SF);
VAR_8 = OHCI_BM(VAR_7.flags, TD_FC);
relative_frame_number = USUB(VAR_0->frame_number, starting_frame);
#ifdef DEBUG_ISOCH
printf("--- ISO_TD ED head 0x%.8x tailp 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"frame_number 0x%.8x starting_frame 0x%.8x\n"
"VAR_8 0x%.8x relative %d\n"
"di 0x%.8x cc 0x%.8x\n",
VAR_1->head & OHCI_DPTR_MASK, VAR_1->tail & OHCI_DPTR_MASK,
VAR_7.flags, VAR_7.bp, VAR_7.next, VAR_7.be,
VAR_7.offset[0], VAR_7.offset[1], VAR_7.offset[2], VAR_7.offset[3],
VAR_7.offset[4], VAR_7.offset[5], VAR_7.offset[6], VAR_7.offset[7],
VAR_0->frame_number, starting_frame,
VAR_8, relative_frame_number,
OHCI_BM(VAR_7.flags, TD_DI), OHCI_BM(VAR_7.flags, TD_CC));
#endif
if (relative_frame_number < 0) {
DPRINTF("usb-VAR_0: ISO_TD R=%d < 0\n", relative_frame_number);
return 1;
} else if (relative_frame_number > VAR_8) {
DPRINTF("usb-VAR_0: ISO_TD R=%d > FC=%d\n", relative_frame_number,
VAR_8);
OHCI_SET_BM(VAR_7.flags, TD_CC, OHCI_CC_DATAOVERRUN);
VAR_1->head &= ~OHCI_DPTR_MASK;
VAR_1->head |= (VAR_7.next & OHCI_DPTR_MASK);
VAR_7.next = VAR_0->done;
VAR_0->done = addr;
VAR_6 = OHCI_BM(VAR_7.flags, TD_DI);
if (VAR_6 < VAR_0->done_count)
VAR_0->done_count = VAR_6;
ohci_put_iso_td(VAR_0, addr, &VAR_7);
return 0;
}
VAR_3 = OHCI_BM(VAR_1->flags, ED_D);
switch (VAR_3) {
case OHCI_TD_DIR_IN:
#ifdef DEBUG_ISOCH
str = "in";
#endif
VAR_4 = USB_TOKEN_IN;
break;
case OHCI_TD_DIR_OUT:
#ifdef DEBUG_ISOCH
str = "out";
#endif
VAR_4 = USB_TOKEN_OUT;
break;
case OHCI_TD_DIR_SETUP:
#ifdef DEBUG_ISOCH
str = "setup";
#endif
VAR_4 = USB_TOKEN_SETUP;
break;
default:
printf("usb-VAR_0: Bad direction %d\n", VAR_3);
return 1;
}
if (!VAR_7.bp || !VAR_7.be) {
printf("usb-VAR_0: ISO_TD bp 0x%.8x be 0x%.8x\n", VAR_7.bp, VAR_7.be);
return 1;
}
start_offset = VAR_7.offset[relative_frame_number];
next_offset = VAR_7.offset[relative_frame_number + 1];
if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xe) ||
((relative_frame_number < VAR_8) &&
!(OHCI_BM(next_offset, TD_PSW_CC) & 0xe))) {
printf("usb-VAR_0: ISO_TD cc != not accessed 0x%.8x 0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((relative_frame_number < VAR_8) && (start_offset > next_offset)) {
printf("usb-VAR_0: ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\n",
start_offset, next_offset);
return 1;
}
if ((start_offset & 0x1000) == 0) {
start_addr = (VAR_7.bp & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
} else {
start_addr = (VAR_7.be & OHCI_PAGE_MASK) |
(start_offset & OHCI_OFFSET_MASK);
}
if (relative_frame_number < VAR_8) {
end_offset = next_offset - 1;
if ((end_offset & 0x1000) == 0) {
end_addr = (VAR_7.bp & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
} else {
end_addr = (VAR_7.be & OHCI_PAGE_MASK) |
(end_offset & OHCI_OFFSET_MASK);
}
} else {
end_addr = VAR_7.be;
}
if ((start_addr & OHCI_PAGE_MASK) != (end_addr & OHCI_PAGE_MASK)) {
len = (end_addr & OHCI_OFFSET_MASK) + 0x1001
- (start_addr & OHCI_OFFSET_MASK);
} else {
len = end_addr - start_addr + 1;
}
if (len && VAR_3 != OHCI_TD_DIR_IN) {
ohci_copy_iso_td(VAR_0, start_addr, end_addr, VAR_0->usb_buf, len, 0);
}
if (VAR_2) {
VAR_5 = VAR_0->usb_packet.result;
} else {
usb_packet_setup(&VAR_0->usb_packet, VAR_4,
OHCI_BM(VAR_1->flags, ED_FA),
OHCI_BM(VAR_1->flags, ED_EN));
usb_packet_addbuf(&VAR_0->usb_packet, VAR_0->usb_buf, len);
dev = ohci_find_device(VAR_0, VAR_0->usb_packet.devaddr);
VAR_5 = usb_handle_packet(dev, &VAR_0->usb_packet);
if (VAR_5 == USB_RET_ASYNC) {
return 1;
}
}
#ifdef DEBUG_ISOCH
printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu VAR_5 %d\n",
start_offset, end_offset, start_addr, end_addr, str, len, VAR_5);
#endif
if (VAR_3 == OHCI_TD_DIR_IN && VAR_5 >= 0 && VAR_5 <= len) {
ohci_copy_iso_td(VAR_0, start_addr, end_addr, VAR_0->usb_buf, VAR_5, 1);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE, VAR_5);
} else if (VAR_3 == OHCI_TD_DIR_OUT && VAR_5 == len) {
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_NOERROR);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE, 0);
} else {
if (VAR_5 > (ssize_t) len) {
printf("usb-VAR_0: DataOverrun %d > %zu\n", VAR_5, len);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAOVERRUN);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,
len);
} else if (VAR_5 >= 0) {
printf("usb-VAR_0: DataUnderrun %d\n", VAR_5);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DATAUNDERRUN);
} else {
switch (VAR_5) {
case USB_RET_NODEV:
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_DEVICENOTRESPONDING);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
case USB_RET_NAK:
case USB_RET_STALL:
printf("usb-VAR_0: got NAK/STALL %d\n", VAR_5);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_STALL);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,
0);
break;
default:
printf("usb-VAR_0: Bad device response %d\n", VAR_5);
OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,
OHCI_CC_UNDEXPETEDPID);
break;
}
}
}
if (relative_frame_number == VAR_8) {
OHCI_SET_BM(VAR_7.flags, TD_CC, OHCI_CC_NOERROR);
VAR_1->head &= ~OHCI_DPTR_MASK;
VAR_1->head |= (VAR_7.next & OHCI_DPTR_MASK);
VAR_7.next = VAR_0->done;
VAR_0->done = addr;
VAR_6 = OHCI_BM(VAR_7.flags, TD_DI);
if (VAR_6 < VAR_0->done_count)
VAR_0->done_count = VAR_6;
}
ohci_put_iso_td(VAR_0, addr, &VAR_7);
return 1;
}
| [
"static int FUNC_0(OHCIState *VAR_0, struct ohci_ed *VAR_1,\nint VAR_2)\n{",
"int VAR_3;",
"size_t len = 0;",
"#ifdef DEBUG_ISOCH\nconst char *str = NULL;",
"#endif\nint VAR_4;",
"int VAR_5;",
"int VAR_6;",
"USBDevice *dev;",
"struct ohci_iso_td VAR_7;",
"uint32_t addr;",
"uint16_t starting_frame;",
"int16_t relative_frame_number;",
"int VAR_8;",
"uint32_t start_offset, next_offset, end_offset = 0;",
"uint32_t start_addr, end_addr;",
"addr = VAR_1->head & OHCI_DPTR_MASK;",
"if (!ohci_read_iso_td(VAR_0, addr, &VAR_7)) {",
"printf(\"usb-VAR_0: ISO_TD read error at %x\\n\", addr);",
"return 0;",
"}",
"starting_frame = OHCI_BM(VAR_7.flags, TD_SF);",
"VAR_8 = OHCI_BM(VAR_7.flags, TD_FC);",
"relative_frame_number = USUB(VAR_0->frame_number, starting_frame);",
"#ifdef DEBUG_ISOCH\nprintf(\"--- ISO_TD ED head 0x%.8x tailp 0x%.8x\\n\"\n\"0x%.8x 0x%.8x 0x%.8x 0x%.8x\\n\"\n\"0x%.8x 0x%.8x 0x%.8x 0x%.8x\\n\"\n\"0x%.8x 0x%.8x 0x%.8x 0x%.8x\\n\"\n\"frame_number 0x%.8x starting_frame 0x%.8x\\n\"\n\"VAR_8 0x%.8x relative %d\\n\"\n\"di 0x%.8x cc 0x%.8x\\n\",\nVAR_1->head & OHCI_DPTR_MASK, VAR_1->tail & OHCI_DPTR_MASK,\nVAR_7.flags, VAR_7.bp, VAR_7.next, VAR_7.be,\nVAR_7.offset[0], VAR_7.offset[1], VAR_7.offset[2], VAR_7.offset[3],\nVAR_7.offset[4], VAR_7.offset[5], VAR_7.offset[6], VAR_7.offset[7],\nVAR_0->frame_number, starting_frame,\nVAR_8, relative_frame_number,\nOHCI_BM(VAR_7.flags, TD_DI), OHCI_BM(VAR_7.flags, TD_CC));",
"#endif\nif (relative_frame_number < 0) {",
"DPRINTF(\"usb-VAR_0: ISO_TD R=%d < 0\\n\", relative_frame_number);",
"return 1;",
"} else if (relative_frame_number > VAR_8) {",
"DPRINTF(\"usb-VAR_0: ISO_TD R=%d > FC=%d\\n\", relative_frame_number,\nVAR_8);",
"OHCI_SET_BM(VAR_7.flags, TD_CC, OHCI_CC_DATAOVERRUN);",
"VAR_1->head &= ~OHCI_DPTR_MASK;",
"VAR_1->head |= (VAR_7.next & OHCI_DPTR_MASK);",
"VAR_7.next = VAR_0->done;",
"VAR_0->done = addr;",
"VAR_6 = OHCI_BM(VAR_7.flags, TD_DI);",
"if (VAR_6 < VAR_0->done_count)\nVAR_0->done_count = VAR_6;",
"ohci_put_iso_td(VAR_0, addr, &VAR_7);",
"return 0;",
"}",
"VAR_3 = OHCI_BM(VAR_1->flags, ED_D);",
"switch (VAR_3) {",
"case OHCI_TD_DIR_IN:\n#ifdef DEBUG_ISOCH\nstr = \"in\";",
"#endif\nVAR_4 = USB_TOKEN_IN;",
"break;",
"case OHCI_TD_DIR_OUT:\n#ifdef DEBUG_ISOCH\nstr = \"out\";",
"#endif\nVAR_4 = USB_TOKEN_OUT;",
"break;",
"case OHCI_TD_DIR_SETUP:\n#ifdef DEBUG_ISOCH\nstr = \"setup\";",
"#endif\nVAR_4 = USB_TOKEN_SETUP;",
"break;",
"default:\nprintf(\"usb-VAR_0: Bad direction %d\\n\", VAR_3);",
"return 1;",
"}",
"if (!VAR_7.bp || !VAR_7.be) {",
"printf(\"usb-VAR_0: ISO_TD bp 0x%.8x be 0x%.8x\\n\", VAR_7.bp, VAR_7.be);",
"return 1;",
"}",
"start_offset = VAR_7.offset[relative_frame_number];",
"next_offset = VAR_7.offset[relative_frame_number + 1];",
"if (!(OHCI_BM(start_offset, TD_PSW_CC) & 0xe) ||\n((relative_frame_number < VAR_8) &&\n!(OHCI_BM(next_offset, TD_PSW_CC) & 0xe))) {",
"printf(\"usb-VAR_0: ISO_TD cc != not accessed 0x%.8x 0x%.8x\\n\",\nstart_offset, next_offset);",
"return 1;",
"}",
"if ((relative_frame_number < VAR_8) && (start_offset > next_offset)) {",
"printf(\"usb-VAR_0: ISO_TD start_offset=0x%.8x > next_offset=0x%.8x\\n\",\nstart_offset, next_offset);",
"return 1;",
"}",
"if ((start_offset & 0x1000) == 0) {",
"start_addr = (VAR_7.bp & OHCI_PAGE_MASK) |\n(start_offset & OHCI_OFFSET_MASK);",
"} else {",
"start_addr = (VAR_7.be & OHCI_PAGE_MASK) |\n(start_offset & OHCI_OFFSET_MASK);",
"}",
"if (relative_frame_number < VAR_8) {",
"end_offset = next_offset - 1;",
"if ((end_offset & 0x1000) == 0) {",
"end_addr = (VAR_7.bp & OHCI_PAGE_MASK) |\n(end_offset & OHCI_OFFSET_MASK);",
"} else {",
"end_addr = (VAR_7.be & OHCI_PAGE_MASK) |\n(end_offset & OHCI_OFFSET_MASK);",
"}",
"} else {",
"end_addr = VAR_7.be;",
"}",
"if ((start_addr & OHCI_PAGE_MASK) != (end_addr & OHCI_PAGE_MASK)) {",
"len = (end_addr & OHCI_OFFSET_MASK) + 0x1001\n- (start_addr & OHCI_OFFSET_MASK);",
"} else {",
"len = end_addr - start_addr + 1;",
"}",
"if (len && VAR_3 != OHCI_TD_DIR_IN) {",
"ohci_copy_iso_td(VAR_0, start_addr, end_addr, VAR_0->usb_buf, len, 0);",
"}",
"if (VAR_2) {",
"VAR_5 = VAR_0->usb_packet.result;",
"} else {",
"usb_packet_setup(&VAR_0->usb_packet, VAR_4,\nOHCI_BM(VAR_1->flags, ED_FA),\nOHCI_BM(VAR_1->flags, ED_EN));",
"usb_packet_addbuf(&VAR_0->usb_packet, VAR_0->usb_buf, len);",
"dev = ohci_find_device(VAR_0, VAR_0->usb_packet.devaddr);",
"VAR_5 = usb_handle_packet(dev, &VAR_0->usb_packet);",
"if (VAR_5 == USB_RET_ASYNC) {",
"return 1;",
"}",
"}",
"#ifdef DEBUG_ISOCH\nprintf(\"so 0x%.8x eo 0x%.8x\\nsa 0x%.8x ea 0x%.8x\\ndir %s len %zu VAR_5 %d\\n\",\nstart_offset, end_offset, start_addr, end_addr, str, len, VAR_5);",
"#endif\nif (VAR_3 == OHCI_TD_DIR_IN && VAR_5 >= 0 && VAR_5 <= len) {",
"ohci_copy_iso_td(VAR_0, start_addr, end_addr, VAR_0->usb_buf, VAR_5, 1);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_NOERROR);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE, VAR_5);",
"} else if (VAR_3 == OHCI_TD_DIR_OUT && VAR_5 == len) {",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_NOERROR);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE, 0);",
"} else {",
"if (VAR_5 > (ssize_t) len) {",
"printf(\"usb-VAR_0: DataOverrun %d > %zu\\n\", VAR_5, len);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_DATAOVERRUN);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,\nlen);",
"} else if (VAR_5 >= 0) {",
"printf(\"usb-VAR_0: DataUnderrun %d\\n\", VAR_5);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_DATAUNDERRUN);",
"} else {",
"switch (VAR_5) {",
"case USB_RET_NODEV:\nOHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_DEVICENOTRESPONDING);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,\n0);",
"break;",
"case USB_RET_NAK:\ncase USB_RET_STALL:\nprintf(\"usb-VAR_0: got NAK/STALL %d\\n\", VAR_5);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_STALL);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_SIZE,\n0);",
"break;",
"default:\nprintf(\"usb-VAR_0: Bad device response %d\\n\", VAR_5);",
"OHCI_SET_BM(VAR_7.offset[relative_frame_number], TD_PSW_CC,\nOHCI_CC_UNDEXPETEDPID);",
"break;",
"}",
"}",
"}",
"if (relative_frame_number == VAR_8) {",
"OHCI_SET_BM(VAR_7.flags, TD_CC, OHCI_CC_NOERROR);",
"VAR_1->head &= ~OHCI_DPTR_MASK;",
"VAR_1->head |= (VAR_7.next & OHCI_DPTR_MASK);",
"VAR_7.next = VAR_0->done;",
"VAR_0->done = addr;",
"VAR_6 = OHCI_BM(VAR_7.flags, TD_DI);",
"if (VAR_6 < VAR_0->done_count)\nVAR_0->done_count = VAR_6;",
"}",
"ohci_put_iso_td(VAR_0, addr, &VAR_7);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93,
97
],
[
99
],
[
101
],
[
103
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141,
143,
145
],
[
147,
149
],
[
151
],
[
153,
155,
157
],
[
159,
161
],
[
163
],
[
165,
167,
169
],
[
171,
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
203,
205,
207
],
[
209,
211
],
[
213
],
[
215
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
],
[
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303,
305,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325,
327,
329
],
[
331,
337
],
[
341
],
[
343,
345
],
[
347
],
[
349
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365,
367
],
[
369,
371
],
[
373
],
[
375
],
[
377,
379
],
[
381
],
[
383
],
[
385,
387,
389
],
[
391,
393
],
[
395
],
[
397,
399,
401
],
[
403,
405
],
[
407,
409
],
[
411
],
[
413,
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447,
449
],
[
451
],
[
453
],
[
455
],
[
457
]
] |
25,211 | static QObject *parse_literal(JSONParserContext *ctxt, QList **tokens)
{
QObject *token, *obj;
QList *working = qlist_copy(*tokens);
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
switch (token_get_type(token)) {
case JSON_STRING:
obj = QOBJECT(qstring_from_escaped_str(ctxt, token));
break;
case JSON_INTEGER:
obj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10)));
break;
case JSON_FLOAT:
/* FIXME dependent on locale */
obj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL)));
break;
default:
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| false | qemu | 65c0f1e9558c7c762cdb333406243fff1d687117 | static QObject *parse_literal(JSONParserContext *ctxt, QList **tokens)
{
QObject *token, *obj;
QList *working = qlist_copy(*tokens);
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
switch (token_get_type(token)) {
case JSON_STRING:
obj = QOBJECT(qstring_from_escaped_str(ctxt, token));
break;
case JSON_INTEGER:
obj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10)));
break;
case JSON_FLOAT:
obj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL)));
break;
default:
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| {
"code": [],
"line_no": []
} | static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens)
{
QObject *token, *obj;
QList *working = qlist_copy(*tokens);
token = qlist_pop(working);
if (token == NULL) {
goto out;
}
switch (token_get_type(token)) {
case JSON_STRING:
obj = QOBJECT(qstring_from_escaped_str(ctxt, token));
break;
case JSON_INTEGER:
obj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10)));
break;
case JSON_FLOAT:
obj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL)));
break;
default:
goto out;
}
qobject_decref(token);
QDECREF(*tokens);
*tokens = working;
return obj;
out:
qobject_decref(token);
QDECREF(working);
return NULL;
}
| [
"static QObject *FUNC_0(JSONParserContext *ctxt, QList **tokens)\n{",
"QObject *token, *obj;",
"QList *working = qlist_copy(*tokens);",
"token = qlist_pop(working);",
"if (token == NULL) {",
"goto out;",
"}",
"switch (token_get_type(token)) {",
"case JSON_STRING:\nobj = QOBJECT(qstring_from_escaped_str(ctxt, token));",
"break;",
"case JSON_INTEGER:\nobj = QOBJECT(qint_from_int(strtoll(token_get_value(token), NULL, 10)));",
"break;",
"case JSON_FLOAT:\nobj = QOBJECT(qfloat_from_double(strtod(token_get_value(token), NULL)));",
"break;",
"default:\ngoto out;",
"}",
"qobject_decref(token);",
"QDECREF(*tokens);",
"*tokens = working;",
"return obj;",
"out:\nqobject_decref(token);",
"QDECREF(working);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
63,
65
],
[
67
],
[
71
],
[
73
]
] |
25,212 | static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
int phb_index, int drc_index,
sPAPRPHBState *sphb)
{
ResourceProps rp;
bool is_bridge = false;
int pci_status, err;
char *buf = NULL;
if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) ==
PCI_HEADER_TYPE_BRIDGE) {
is_bridge = true;
}
/* in accordance with PAPR+ v2.7 13.6.3, Table 181 */
_FDT(fdt_setprop_cell(fdt, offset, "vendor-id",
pci_default_read_config(dev, PCI_VENDOR_ID, 2)));
_FDT(fdt_setprop_cell(fdt, offset, "device-id",
pci_default_read_config(dev, PCI_DEVICE_ID, 2)));
_FDT(fdt_setprop_cell(fdt, offset, "revision-id",
pci_default_read_config(dev, PCI_REVISION_ID, 1)));
_FDT(fdt_setprop_cell(fdt, offset, "class-code",
pci_default_read_config(dev, PCI_CLASS_PROG, 3)));
if (pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)) {
_FDT(fdt_setprop_cell(fdt, offset, "interrupts",
pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)));
}
if (!is_bridge) {
_FDT(fdt_setprop_cell(fdt, offset, "min-grant",
pci_default_read_config(dev, PCI_MIN_GNT, 1)));
_FDT(fdt_setprop_cell(fdt, offset, "max-latency",
pci_default_read_config(dev, PCI_MAX_LAT, 1)));
}
if (pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)) {
_FDT(fdt_setprop_cell(fdt, offset, "subsystem-id",
pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)));
}
if (pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)) {
_FDT(fdt_setprop_cell(fdt, offset, "subsystem-vendor-id",
pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)));
}
_FDT(fdt_setprop_cell(fdt, offset, "cache-line-size",
pci_default_read_config(dev, PCI_CACHE_LINE_SIZE, 1)));
/* the following fdt cells are masked off the pci status register */
pci_status = pci_default_read_config(dev, PCI_STATUS, 2);
_FDT(fdt_setprop_cell(fdt, offset, "devsel-speed",
PCI_STATUS_DEVSEL_MASK & pci_status));
if (pci_status & PCI_STATUS_FAST_BACK) {
_FDT(fdt_setprop(fdt, offset, "fast-back-to-back", NULL, 0));
}
if (pci_status & PCI_STATUS_66MHZ) {
_FDT(fdt_setprop(fdt, offset, "66mhz-capable", NULL, 0));
}
if (pci_status & PCI_STATUS_UDF) {
_FDT(fdt_setprop(fdt, offset, "udf-supported", NULL, 0));
}
/* NOTE: this is normally generated by firmware via path/unit name,
* but in our case we must set it manually since it does not get
* processed by OF beforehand
*/
_FDT(fdt_setprop_string(fdt, offset, "name", "pci"));
buf = spapr_phb_get_loc_code(sphb, dev);
if (!buf) {
error_report("Failed setting the ibm,loc-code");
return -1;
}
err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf);
g_free(buf);
if (err < 0) {
return err;
}
_FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index));
_FDT(fdt_setprop_cell(fdt, offset, "#address-cells",
RESOURCE_CELLS_ADDRESS));
_FDT(fdt_setprop_cell(fdt, offset, "#size-cells",
RESOURCE_CELLS_SIZE));
_FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi-x",
RESOURCE_CELLS_SIZE));
populate_resource_props(dev, &rp);
_FDT(fdt_setprop(fdt, offset, "reg", (uint8_t *)rp.reg, rp.reg_len));
_FDT(fdt_setprop(fdt, offset, "assigned-addresses",
(uint8_t *)rp.assigned, rp.assigned_len));
return 0;
}
| false | qemu | e634b89c6ed2309814de7a89bd7c5ced96f59291 | static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
int phb_index, int drc_index,
sPAPRPHBState *sphb)
{
ResourceProps rp;
bool is_bridge = false;
int pci_status, err;
char *buf = NULL;
if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) ==
PCI_HEADER_TYPE_BRIDGE) {
is_bridge = true;
}
_FDT(fdt_setprop_cell(fdt, offset, "vendor-id",
pci_default_read_config(dev, PCI_VENDOR_ID, 2)));
_FDT(fdt_setprop_cell(fdt, offset, "device-id",
pci_default_read_config(dev, PCI_DEVICE_ID, 2)));
_FDT(fdt_setprop_cell(fdt, offset, "revision-id",
pci_default_read_config(dev, PCI_REVISION_ID, 1)));
_FDT(fdt_setprop_cell(fdt, offset, "class-code",
pci_default_read_config(dev, PCI_CLASS_PROG, 3)));
if (pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)) {
_FDT(fdt_setprop_cell(fdt, offset, "interrupts",
pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)));
}
if (!is_bridge) {
_FDT(fdt_setprop_cell(fdt, offset, "min-grant",
pci_default_read_config(dev, PCI_MIN_GNT, 1)));
_FDT(fdt_setprop_cell(fdt, offset, "max-latency",
pci_default_read_config(dev, PCI_MAX_LAT, 1)));
}
if (pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)) {
_FDT(fdt_setprop_cell(fdt, offset, "subsystem-id",
pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)));
}
if (pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)) {
_FDT(fdt_setprop_cell(fdt, offset, "subsystem-vendor-id",
pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)));
}
_FDT(fdt_setprop_cell(fdt, offset, "cache-line-size",
pci_default_read_config(dev, PCI_CACHE_LINE_SIZE, 1)));
pci_status = pci_default_read_config(dev, PCI_STATUS, 2);
_FDT(fdt_setprop_cell(fdt, offset, "devsel-speed",
PCI_STATUS_DEVSEL_MASK & pci_status));
if (pci_status & PCI_STATUS_FAST_BACK) {
_FDT(fdt_setprop(fdt, offset, "fast-back-to-back", NULL, 0));
}
if (pci_status & PCI_STATUS_66MHZ) {
_FDT(fdt_setprop(fdt, offset, "66mhz-capable", NULL, 0));
}
if (pci_status & PCI_STATUS_UDF) {
_FDT(fdt_setprop(fdt, offset, "udf-supported", NULL, 0));
}
_FDT(fdt_setprop_string(fdt, offset, "name", "pci"));
buf = spapr_phb_get_loc_code(sphb, dev);
if (!buf) {
error_report("Failed setting the ibm,loc-code");
return -1;
}
err = fdt_setprop_string(fdt, offset, "ibm,loc-code", buf);
g_free(buf);
if (err < 0) {
return err;
}
_FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index));
_FDT(fdt_setprop_cell(fdt, offset, "#address-cells",
RESOURCE_CELLS_ADDRESS));
_FDT(fdt_setprop_cell(fdt, offset, "#size-cells",
RESOURCE_CELLS_SIZE));
_FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi-x",
RESOURCE_CELLS_SIZE));
populate_resource_props(dev, &rp);
_FDT(fdt_setprop(fdt, offset, "reg", (uint8_t *)rp.reg, rp.reg_len));
_FDT(fdt_setprop(fdt, offset, "assigned-addresses",
(uint8_t *)rp.assigned, rp.assigned_len));
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0, void *VAR_1, int VAR_2,
int VAR_3, int VAR_4,
sPAPRPHBState *VAR_5)
{
ResourceProps rp;
bool is_bridge = false;
int VAR_6, VAR_7;
char *VAR_8 = NULL;
if (pci_default_read_config(VAR_0, PCI_HEADER_TYPE, 1) ==
PCI_HEADER_TYPE_BRIDGE) {
is_bridge = true;
}
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "vendor-id",
pci_default_read_config(VAR_0, PCI_VENDOR_ID, 2)));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "device-id",
pci_default_read_config(VAR_0, PCI_DEVICE_ID, 2)));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "revision-id",
pci_default_read_config(VAR_0, PCI_REVISION_ID, 1)));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "class-code",
pci_default_read_config(VAR_0, PCI_CLASS_PROG, 3)));
if (pci_default_read_config(VAR_0, PCI_INTERRUPT_PIN, 1)) {
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "interrupts",
pci_default_read_config(VAR_0, PCI_INTERRUPT_PIN, 1)));
}
if (!is_bridge) {
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "min-grant",
pci_default_read_config(VAR_0, PCI_MIN_GNT, 1)));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "max-latency",
pci_default_read_config(VAR_0, PCI_MAX_LAT, 1)));
}
if (pci_default_read_config(VAR_0, PCI_SUBSYSTEM_ID, 2)) {
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "subsystem-id",
pci_default_read_config(VAR_0, PCI_SUBSYSTEM_ID, 2)));
}
if (pci_default_read_config(VAR_0, PCI_SUBSYSTEM_VENDOR_ID, 2)) {
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "subsystem-vendor-id",
pci_default_read_config(VAR_0, PCI_SUBSYSTEM_VENDOR_ID, 2)));
}
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "cache-line-size",
pci_default_read_config(VAR_0, PCI_CACHE_LINE_SIZE, 1)));
VAR_6 = pci_default_read_config(VAR_0, PCI_STATUS, 2);
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "devsel-speed",
PCI_STATUS_DEVSEL_MASK & VAR_6));
if (VAR_6 & PCI_STATUS_FAST_BACK) {
_FDT(fdt_setprop(VAR_1, VAR_2, "fast-back-to-back", NULL, 0));
}
if (VAR_6 & PCI_STATUS_66MHZ) {
_FDT(fdt_setprop(VAR_1, VAR_2, "66mhz-capable", NULL, 0));
}
if (VAR_6 & PCI_STATUS_UDF) {
_FDT(fdt_setprop(VAR_1, VAR_2, "udf-supported", NULL, 0));
}
_FDT(fdt_setprop_string(VAR_1, VAR_2, "name", "pci"));
VAR_8 = spapr_phb_get_loc_code(VAR_5, VAR_0);
if (!VAR_8) {
error_report("Failed setting the ibm,loc-code");
return -1;
}
VAR_7 = fdt_setprop_string(VAR_1, VAR_2, "ibm,loc-code", VAR_8);
g_free(VAR_8);
if (VAR_7 < 0) {
return VAR_7;
}
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "ibm,my-drc-index", VAR_4));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "#address-cells",
RESOURCE_CELLS_ADDRESS));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "#size-cells",
RESOURCE_CELLS_SIZE));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "ibm,req#msi-x",
RESOURCE_CELLS_SIZE));
populate_resource_props(VAR_0, &rp);
_FDT(fdt_setprop(VAR_1, VAR_2, "reg", (uint8_t *)rp.reg, rp.reg_len));
_FDT(fdt_setprop(VAR_1, VAR_2, "assigned-addresses",
(uint8_t *)rp.assigned, rp.assigned_len));
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, void *VAR_1, int VAR_2,\nint VAR_3, int VAR_4,\nsPAPRPHBState *VAR_5)\n{",
"ResourceProps rp;",
"bool is_bridge = false;",
"int VAR_6, VAR_7;",
"char *VAR_8 = NULL;",
"if (pci_default_read_config(VAR_0, PCI_HEADER_TYPE, 1) ==\nPCI_HEADER_TYPE_BRIDGE) {",
"is_bridge = true;",
"}",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"vendor-id\",\npci_default_read_config(VAR_0, PCI_VENDOR_ID, 2)));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"device-id\",\npci_default_read_config(VAR_0, PCI_DEVICE_ID, 2)));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"revision-id\",\npci_default_read_config(VAR_0, PCI_REVISION_ID, 1)));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"class-code\",\npci_default_read_config(VAR_0, PCI_CLASS_PROG, 3)));",
"if (pci_default_read_config(VAR_0, PCI_INTERRUPT_PIN, 1)) {",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"interrupts\",\npci_default_read_config(VAR_0, PCI_INTERRUPT_PIN, 1)));",
"}",
"if (!is_bridge) {",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"min-grant\",\npci_default_read_config(VAR_0, PCI_MIN_GNT, 1)));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"max-latency\",\npci_default_read_config(VAR_0, PCI_MAX_LAT, 1)));",
"}",
"if (pci_default_read_config(VAR_0, PCI_SUBSYSTEM_ID, 2)) {",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"subsystem-id\",\npci_default_read_config(VAR_0, PCI_SUBSYSTEM_ID, 2)));",
"}",
"if (pci_default_read_config(VAR_0, PCI_SUBSYSTEM_VENDOR_ID, 2)) {",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"subsystem-vendor-id\",\npci_default_read_config(VAR_0, PCI_SUBSYSTEM_VENDOR_ID, 2)));",
"}",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"cache-line-size\",\npci_default_read_config(VAR_0, PCI_CACHE_LINE_SIZE, 1)));",
"VAR_6 = pci_default_read_config(VAR_0, PCI_STATUS, 2);",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"devsel-speed\",\nPCI_STATUS_DEVSEL_MASK & VAR_6));",
"if (VAR_6 & PCI_STATUS_FAST_BACK) {",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"fast-back-to-back\", NULL, 0));",
"}",
"if (VAR_6 & PCI_STATUS_66MHZ) {",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"66mhz-capable\", NULL, 0));",
"}",
"if (VAR_6 & PCI_STATUS_UDF) {",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"udf-supported\", NULL, 0));",
"}",
"_FDT(fdt_setprop_string(VAR_1, VAR_2, \"name\", \"pci\"));",
"VAR_8 = spapr_phb_get_loc_code(VAR_5, VAR_0);",
"if (!VAR_8) {",
"error_report(\"Failed setting the ibm,loc-code\");",
"return -1;",
"}",
"VAR_7 = fdt_setprop_string(VAR_1, VAR_2, \"ibm,loc-code\", VAR_8);",
"g_free(VAR_8);",
"if (VAR_7 < 0) {",
"return VAR_7;",
"}",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"ibm,my-drc-index\", VAR_4));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"#address-cells\",\nRESOURCE_CELLS_ADDRESS));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"#size-cells\",\nRESOURCE_CELLS_SIZE));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"ibm,req#msi-x\",\nRESOURCE_CELLS_SIZE));",
"populate_resource_props(VAR_0, &rp);",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"reg\", (uint8_t *)rp.reg, rp.reg_len));",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"assigned-addresses\",\n(uint8_t *)rp.assigned, rp.assigned_len));",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
57
],
[
59,
61
],
[
63,
65
],
[
67
],
[
71
],
[
73,
75
],
[
77
],
[
81
],
[
83,
85
],
[
87
],
[
91,
93
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
165,
167
],
[
169,
171
],
[
173,
175
],
[
179
],
[
181
],
[
183,
185
],
[
189
],
[
191
]
] |
25,213 | static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)
{
int rc;
trace_usb_host_set_config(s->bus_num, s->addr, config);
usb_host_release_interfaces(s);
usb_host_detach_kernel(s);
rc = libusb_set_configuration(s->dh, config);
if (rc != 0) {
usb_host_libusb_error("libusb_set_configuration", rc);
p->status = USB_RET_STALL;
if (rc == LIBUSB_ERROR_NO_DEVICE) {
usb_host_nodev(s);
}
return;
}
p->status = usb_host_claim_interfaces(s, config);
if (p->status != USB_RET_SUCCESS) {
return;
}
usb_host_ep_update(s);
}
| false | qemu | f34d5c750897abb3853910ce73f63d88d74dc827 | static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)
{
int rc;
trace_usb_host_set_config(s->bus_num, s->addr, config);
usb_host_release_interfaces(s);
usb_host_detach_kernel(s);
rc = libusb_set_configuration(s->dh, config);
if (rc != 0) {
usb_host_libusb_error("libusb_set_configuration", rc);
p->status = USB_RET_STALL;
if (rc == LIBUSB_ERROR_NO_DEVICE) {
usb_host_nodev(s);
}
return;
}
p->status = usb_host_claim_interfaces(s, config);
if (p->status != USB_RET_SUCCESS) {
return;
}
usb_host_ep_update(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(USBHostDevice *VAR_0, int VAR_1, USBPacket *VAR_2)
{
int VAR_3;
trace_usb_host_set_config(VAR_0->bus_num, VAR_0->addr, VAR_1);
usb_host_release_interfaces(VAR_0);
usb_host_detach_kernel(VAR_0);
VAR_3 = libusb_set_configuration(VAR_0->dh, VAR_1);
if (VAR_3 != 0) {
usb_host_libusb_error("libusb_set_configuration", VAR_3);
VAR_2->status = USB_RET_STALL;
if (VAR_3 == LIBUSB_ERROR_NO_DEVICE) {
usb_host_nodev(VAR_0);
}
return;
}
VAR_2->status = usb_host_claim_interfaces(VAR_0, VAR_1);
if (VAR_2->status != USB_RET_SUCCESS) {
return;
}
usb_host_ep_update(VAR_0);
}
| [
"static void FUNC_0(USBHostDevice *VAR_0, int VAR_1, USBPacket *VAR_2)\n{",
"int VAR_3;",
"trace_usb_host_set_config(VAR_0->bus_num, VAR_0->addr, VAR_1);",
"usb_host_release_interfaces(VAR_0);",
"usb_host_detach_kernel(VAR_0);",
"VAR_3 = libusb_set_configuration(VAR_0->dh, VAR_1);",
"if (VAR_3 != 0) {",
"usb_host_libusb_error(\"libusb_set_configuration\", VAR_3);",
"VAR_2->status = USB_RET_STALL;",
"if (VAR_3 == LIBUSB_ERROR_NO_DEVICE) {",
"usb_host_nodev(VAR_0);",
"}",
"return;",
"}",
"VAR_2->status = usb_host_claim_interfaces(VAR_0, VAR_1);",
"if (VAR_2->status != USB_RET_SUCCESS) {",
"return;",
"}",
"usb_host_ep_update(VAR_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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
25,214 | static __attribute__((unused)) void map_exec(void *addr, long size)
{
unsigned long start, end, page_size;
page_size = getpagesize();
start = (unsigned long)addr;
start &= ~(page_size - 1);
end = (unsigned long)addr + size;
end += page_size - 1;
end &= ~(page_size - 1);
mprotect((void *)start, end - start,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
| true | qemu | f293709c6af7a65a9bcec09cdba7a60183657a3e | static __attribute__((unused)) void map_exec(void *addr, long size)
{
unsigned long start, end, page_size;
page_size = getpagesize();
start = (unsigned long)addr;
start &= ~(page_size - 1);
end = (unsigned long)addr + size;
end += page_size - 1;
end &= ~(page_size - 1);
mprotect((void *)start, end - start,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
| {
"code": [
"static __attribute__((unused)) void map_exec(void *addr, long size)",
"static __attribute__((unused)) void map_exec(void *addr, long size)",
" unsigned long start, end, page_size;",
" page_size = getpagesize();",
" start = (unsigned long)addr;",
" start &= ~(page_size - 1);",
" end = (unsigned long)addr + size;",
" end += page_size - 1;",
" end &= ~(page_size - 1);",
" mprotect((void *)start, end - start,",
" PROT_READ | PROT_WRITE | PROT_EXEC);"
],
"line_no": [
1,
1,
5,
9,
11,
13,
17,
19,
21,
25,
27
]
} | static __attribute__((unused)) void FUNC_0(void *VAR_0, long VAR_1)
{
unsigned long VAR_2, VAR_3, VAR_4;
VAR_4 = getpagesize();
VAR_2 = (unsigned long)VAR_0;
VAR_2 &= ~(VAR_4 - 1);
VAR_3 = (unsigned long)VAR_0 + VAR_1;
VAR_3 += VAR_4 - 1;
VAR_3 &= ~(VAR_4 - 1);
mprotect((void *)VAR_2, VAR_3 - VAR_2,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
| [
"static __attribute__((unused)) void FUNC_0(void *VAR_0, long VAR_1)\n{",
"unsigned long VAR_2, VAR_3, VAR_4;",
"VAR_4 = getpagesize();",
"VAR_2 = (unsigned long)VAR_0;",
"VAR_2 &= ~(VAR_4 - 1);",
"VAR_3 = (unsigned long)VAR_0 + VAR_1;",
"VAR_3 += VAR_4 - 1;",
"VAR_3 &= ~(VAR_4 - 1);",
"mprotect((void *)VAR_2, VAR_3 - VAR_2,\nPROT_READ | PROT_WRITE | PROT_EXEC);",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
]
] |
25,215 | static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
int64_t offset, int64_t length, int addend)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
int64_t refcount_block_offset = 0;
int64_t table_index = -1, old_table_index;
int first_index = -1, last_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n",
offset, length, addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
start = offset & ~(s->cluster_size - 1);
last = (offset + length - 1) & ~(s->cluster_size - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index, refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t new_block;
/* Only write refcount block to disk when we are done with it */
old_table_index = table_index;
table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if ((old_table_index >= 0) && (table_index != old_table_index)) {
ret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (ret < 0) {
return ret;
}
first_index = -1;
last_index = -1;
}
/* Load the refcount block and allocate it if needed */
new_block = alloc_refcount_block(bs, cluster_index);
if (new_block < 0) {
ret = new_block;
goto fail;
}
refcount_block_offset = new_block;
/* we can update the count and save it */
block_index = cluster_index &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
if (first_index == -1 || block_index < first_index) {
first_index = block_index;
}
if (block_index > last_index) {
last_index = block_index;
}
refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
refcount += addend;
if (refcount < 0 || refcount > 0xffff) {
ret = -EINVAL;
goto fail;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
}
ret = 0;
fail:
/* Write last changed block to disk */
if (refcount_block_offset != 0) {
int wret;
wret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
/*
* Try do undo any updates if an error is returned (This may succeed in
* some cases like ENOSPC for allocating a new refcount block)
*/
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
}
bdrv_flush(bs->file);
return ret;
}
| true | qemu | 1c4c28149fff77b8c983fdabe4e76bdc8cadd572 | static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
int64_t offset, int64_t length, int addend)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
int64_t refcount_block_offset = 0;
int64_t table_index = -1, old_table_index;
int first_index = -1, last_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n",
offset, length, addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
start = offset & ~(s->cluster_size - 1);
last = (offset + length - 1) & ~(s->cluster_size - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index, refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t new_block;
old_table_index = table_index;
table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if ((old_table_index >= 0) && (table_index != old_table_index)) {
ret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (ret < 0) {
return ret;
}
first_index = -1;
last_index = -1;
}
new_block = alloc_refcount_block(bs, cluster_index);
if (new_block < 0) {
ret = new_block;
goto fail;
}
refcount_block_offset = new_block;
block_index = cluster_index &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
if (first_index == -1 || block_index < first_index) {
first_index = block_index;
}
if (block_index > last_index) {
last_index = block_index;
}
refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
refcount += addend;
if (refcount < 0 || refcount > 0xffff) {
ret = -EINVAL;
goto fail;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
}
ret = 0;
fail:
if (refcount_block_offset != 0) {
int wret;
wret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
}
bdrv_flush(bs->file);
return ret;
}
| {
"code": [
" bdrv_flush(bs->file);"
],
"line_no": [
193
]
} | static int VAR_0 update_refcount(BlockDriverState *bs,
int64_t offset, int64_t length, int addend)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
int64_t refcount_block_offset = 0;
int64_t table_index = -1, old_table_index;
int first_index = -1, last_index = -1;
int ret;
#ifdef DEBUG_ALLOC2
printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n",
offset, length, addend);
#endif
if (length < 0) {
return -EINVAL;
} else if (length == 0) {
return 0;
}
start = offset & ~(s->cluster_size - 1);
last = (offset + length - 1) & ~(s->cluster_size - 1);
for(cluster_offset = start; cluster_offset <= last;
cluster_offset += s->cluster_size)
{
int block_index, refcount;
int64_t cluster_index = cluster_offset >> s->cluster_bits;
int64_t new_block;
old_table_index = table_index;
table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
if ((old_table_index >= 0) && (table_index != old_table_index)) {
ret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (ret < 0) {
return ret;
}
first_index = -1;
last_index = -1;
}
new_block = alloc_refcount_block(bs, cluster_index);
if (new_block < 0) {
ret = new_block;
goto fail;
}
refcount_block_offset = new_block;
block_index = cluster_index &
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
if (first_index == -1 || block_index < first_index) {
first_index = block_index;
}
if (block_index > last_index) {
last_index = block_index;
}
refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
refcount += addend;
if (refcount < 0 || refcount > 0xffff) {
ret = -EINVAL;
goto fail;
}
if (refcount == 0 && cluster_index < s->free_cluster_index) {
s->free_cluster_index = cluster_index;
}
s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
}
ret = 0;
fail:
if (refcount_block_offset != 0) {
int wret;
wret = write_refcount_block_entries(bs, refcount_block_offset,
first_index, last_index);
if (wret < 0) {
return ret < 0 ? ret : wret;
}
}
if (ret < 0) {
int dummy;
dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
}
bdrv_flush(bs->file);
return ret;
}
| [
"static int VAR_0 update_refcount(BlockDriverState *bs,\nint64_t offset, int64_t length, int addend)\n{",
"BDRVQcowState *s = bs->opaque;",
"int64_t start, last, cluster_offset;",
"int64_t refcount_block_offset = 0;",
"int64_t table_index = -1, old_table_index;",
"int first_index = -1, last_index = -1;",
"int ret;",
"#ifdef DEBUG_ALLOC2\nprintf(\"update_refcount: offset=%\" PRId64 \" size=%\" PRId64 \" addend=%d\\n\",\noffset, length, addend);",
"#endif\nif (length < 0) {",
"return -EINVAL;",
"} else if (length == 0) {",
"return 0;",
"}",
"start = offset & ~(s->cluster_size - 1);",
"last = (offset + length - 1) & ~(s->cluster_size - 1);",
"for(cluster_offset = start; cluster_offset <= last;",
"cluster_offset += s->cluster_size)\n{",
"int block_index, refcount;",
"int64_t cluster_index = cluster_offset >> s->cluster_bits;",
"int64_t new_block;",
"old_table_index = table_index;",
"table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);",
"if ((old_table_index >= 0) && (table_index != old_table_index)) {",
"ret = write_refcount_block_entries(bs, refcount_block_offset,\nfirst_index, last_index);",
"if (ret < 0) {",
"return ret;",
"}",
"first_index = -1;",
"last_index = -1;",
"}",
"new_block = alloc_refcount_block(bs, cluster_index);",
"if (new_block < 0) {",
"ret = new_block;",
"goto fail;",
"}",
"refcount_block_offset = new_block;",
"block_index = cluster_index &\n((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);",
"if (first_index == -1 || block_index < first_index) {",
"first_index = block_index;",
"}",
"if (block_index > last_index) {",
"last_index = block_index;",
"}",
"refcount = be16_to_cpu(s->refcount_block_cache[block_index]);",
"refcount += addend;",
"if (refcount < 0 || refcount > 0xffff) {",
"ret = -EINVAL;",
"goto fail;",
"}",
"if (refcount == 0 && cluster_index < s->free_cluster_index) {",
"s->free_cluster_index = cluster_index;",
"}",
"s->refcount_block_cache[block_index] = cpu_to_be16(refcount);",
"}",
"ret = 0;",
"fail:\nif (refcount_block_offset != 0) {",
"int wret;",
"wret = write_refcount_block_entries(bs, refcount_block_offset,\nfirst_index, last_index);",
"if (wret < 0) {",
"return ret < 0 ? ret : wret;",
"}",
"}",
"if (ret < 0) {",
"int dummy;",
"dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);",
"}",
"bdrv_flush(bs->file);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
197
],
[
199
]
] |
25,216 | int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| true | qemu | 4cad3867b6df2c0826ae508a9fe15dd0b9d8936a | int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
copy = g_malloc(sizeof(value));
*copy = cpu_to_le16(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
| {
"code": [
"int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)",
" return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));",
" return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));",
" return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));"
],
"line_no": [
1,
13,
13,
13
]
} | int FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint16_t VAR_2)
{
uint16_t *copy;
copy = g_malloc(sizeof(VAR_2));
*copy = cpu_to_le16(VAR_2);
return fw_cfg_add_bytes(VAR_0, VAR_1, (uint8_t *)copy, sizeof(VAR_2));
}
| [
"int FUNC_0(FWCfgState *VAR_0, uint16_t VAR_1, uint16_t VAR_2)\n{",
"uint16_t *copy;",
"copy = g_malloc(sizeof(VAR_2));",
"*copy = cpu_to_le16(VAR_2);",
"return fw_cfg_add_bytes(VAR_0, VAR_1, (uint8_t *)copy, sizeof(VAR_2));",
"}"
] | [
1,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,217 | int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
CPUS390XState *env = &cpu->env;
uint64_t offset, data;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
uint8_t len;
uint32_t fh;
uint8_t pcias;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 4);
return 0;
}
if (r2 & 0x1) {
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
fh = env->regs[r2] >> 32;
pcias = (env->regs[r2] >> 16) & 0xf;
len = env->regs[r2] & 0xf;
offset = env->regs[r2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
DPRINTF("pcistg no pci dev\n");
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
data = env->regs[r1];
if (pcias < 6) {
if ((8 - (offset & 0x7)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
if (trap_msix(pbdev, offset, pcias)) {
offset = offset - pbdev->msix.table_offset;
mr = &pbdev->pdev->msix_table_mmio;
update_msix_table_msg_data(pbdev, offset, &data, len);
} else {
mr = pbdev->pdev->io_regions[pcias].memory;
}
memory_region_dispatch_write(mr, offset, data, len,
MEMTXATTRS_UNSPECIFIED);
} else if (pcias == 15) {
if ((4 - (offset & 0x3)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
switch (len) {
case 1:
break;
case 2:
data = bswap16(data);
break;
case 4:
data = bswap32(data);
break;
case 8:
data = bswap64(data);
break;
default:
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
pci_host_config_write_common(pbdev->pdev, offset,
pci_config_size(pbdev->pdev),
data, len);
} else {
DPRINTF("pcistg invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| true | qemu | 88ee13c7b656e5504613b527f3a51591e9afae69 | int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
CPUS390XState *env = &cpu->env;
uint64_t offset, data;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
uint8_t len;
uint32_t fh;
uint8_t pcias;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 4);
return 0;
}
if (r2 & 0x1) {
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
fh = env->regs[r2] >> 32;
pcias = (env->regs[r2] >> 16) & 0xf;
len = env->regs[r2] & 0xf;
offset = env->regs[r2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
DPRINTF("pcistg no pci dev\n");
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
data = env->regs[r1];
if (pcias < 6) {
if ((8 - (offset & 0x7)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
if (trap_msix(pbdev, offset, pcias)) {
offset = offset - pbdev->msix.table_offset;
mr = &pbdev->pdev->msix_table_mmio;
update_msix_table_msg_data(pbdev, offset, &data, len);
} else {
mr = pbdev->pdev->io_regions[pcias].memory;
}
memory_region_dispatch_write(mr, offset, data, len,
MEMTXATTRS_UNSPECIFIED);
} else if (pcias == 15) {
if ((4 - (offset & 0x3)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
switch (len) {
case 1:
break;
case 2:
data = bswap16(data);
break;
case 4:
data = bswap32(data);
break;
case 8:
data = bswap64(data);
break;
default:
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
pci_host_config_write_common(pbdev->pdev, offset,
pci_config_size(pbdev->pdev),
data, len);
} else {
DPRINTF("pcistg invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| {
"code": [
" memory_region_dispatch_write(mr, offset, data, len,"
],
"line_no": [
129
]
} | int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2)
{
CPUS390XState *env = &VAR_0->env;
uint64_t offset, data;
S390PCIBusDevice *pbdev;
MemoryRegion *mr;
uint8_t len;
uint32_t fh;
uint8_t pcias;
cpu_synchronize_state(CPU(VAR_0));
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 4);
return 0;
}
if (VAR_2 & 0x1) {
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
fh = env->regs[VAR_2] >> 32;
pcias = (env->regs[VAR_2] >> 16) & 0xf;
len = env->regs[VAR_2] & 0xf;
offset = env->regs[VAR_2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
DPRINTF("pcistg no pci dev\n");
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(VAR_0, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
data = env->regs[VAR_1];
if (pcias < 6) {
if ((8 - (offset & 0x7)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
if (trap_msix(pbdev, offset, pcias)) {
offset = offset - pbdev->msix.table_offset;
mr = &pbdev->pdev->msix_table_mmio;
update_msix_table_msg_data(pbdev, offset, &data, len);
} else {
mr = pbdev->pdev->io_regions[pcias].memory;
}
memory_region_dispatch_write(mr, offset, data, len,
MEMTXATTRS_UNSPECIFIED);
} else if (pcias == 15) {
if ((4 - (offset & 0x3)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
switch (len) {
case 1:
break;
case 2:
data = bswap16(data);
break;
case 4:
data = bswap32(data);
break;
case 8:
data = bswap64(data);
break;
default:
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
pci_host_config_write_common(pbdev->pdev, offset,
pci_config_size(pbdev->pdev),
data, len);
} else {
DPRINTF("pcistg invalid space\n");
setcc(VAR_0, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
setcc(VAR_0, ZPCI_PCI_LS_OK);
return 0;
}
| [
"int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2)\n{",
"CPUS390XState *env = &VAR_0->env;",
"uint64_t offset, data;",
"S390PCIBusDevice *pbdev;",
"MemoryRegion *mr;",
"uint8_t len;",
"uint32_t fh;",
"uint8_t pcias;",
"cpu_synchronize_state(CPU(VAR_0));",
"if (env->psw.mask & PSW_MASK_PSTATE) {",
"program_interrupt(env, PGM_PRIVILEGED, 4);",
"return 0;",
"}",
"if (VAR_2 & 0x1) {",
"program_interrupt(env, PGM_SPECIFICATION, 4);",
"return 0;",
"}",
"fh = env->regs[VAR_2] >> 32;",
"pcias = (env->regs[VAR_2] >> 16) & 0xf;",
"len = env->regs[VAR_2] & 0xf;",
"offset = env->regs[VAR_2 + 1];",
"pbdev = s390_pci_find_dev_by_fh(fh);",
"if (!pbdev) {",
"DPRINTF(\"pcistg no pci dev\\n\");",
"setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"}",
"switch (pbdev->state) {",
"case ZPCI_FS_RESERVED:\ncase ZPCI_FS_STANDBY:\ncase ZPCI_FS_DISABLED:\ncase ZPCI_FS_PERMANENT_ERROR:\nsetcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);",
"return 0;",
"case ZPCI_FS_ERROR:\nsetcc(VAR_0, ZPCI_PCI_LS_ERR);",
"s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_BLOCKED);",
"return 0;",
"default:\nbreak;",
"}",
"data = env->regs[VAR_1];",
"if (pcias < 6) {",
"if ((8 - (offset & 0x7)) < len) {",
"program_interrupt(env, PGM_OPERAND, 4);",
"return 0;",
"}",
"if (trap_msix(pbdev, offset, pcias)) {",
"offset = offset - pbdev->msix.table_offset;",
"mr = &pbdev->pdev->msix_table_mmio;",
"update_msix_table_msg_data(pbdev, offset, &data, len);",
"} else {",
"mr = pbdev->pdev->io_regions[pcias].memory;",
"}",
"memory_region_dispatch_write(mr, offset, data, len,\nMEMTXATTRS_UNSPECIFIED);",
"} else if (pcias == 15) {",
"if ((4 - (offset & 0x3)) < len) {",
"program_interrupt(env, PGM_OPERAND, 4);",
"return 0;",
"}",
"switch (len) {",
"case 1:\nbreak;",
"case 2:\ndata = bswap16(data);",
"break;",
"case 4:\ndata = bswap32(data);",
"break;",
"case 8:\ndata = bswap64(data);",
"break;",
"default:\nprogram_interrupt(env, PGM_OPERAND, 4);",
"return 0;",
"}",
"pci_host_config_write_common(pbdev->pdev, offset,\npci_config_size(pbdev->pdev),\ndata, len);",
"} else {",
"DPRINTF(\"pcistg invalid space\\n\");",
"setcc(VAR_0, ZPCI_PCI_LS_ERR);",
"s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_INVAL_AS);",
"return 0;",
"}",
"setcc(VAR_0, ZPCI_PCI_LS_OK);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71,
73,
75,
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149,
151
],
[
153
],
[
155,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
177,
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
]
] |
25,218 | static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
{
DVVideoContext *s = avctx->priv_data;
DVwork_chunk *work_chunk = arg;
int quant, dc, dct_mode, class1, j;
int mb_index, mb_x, mb_y, last_index;
int y_stride, linesize;
DCTELEM *block, *block1;
int c_offset;
uint8_t *y_ptr;
const uint8_t *buf_ptr;
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]); /* allow some slack */
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]); /* allow some slack */
const int log2_blocksize = 3-s->avctx->lowres;
int is_field_mode[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
/* pass 1: read DC and AC coefficients in blocks */
buf_ptr = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {
/* skip header */
quant = buf_ptr[3] & 0x0f;
buf_ptr += 4;
init_put_bits(&pb, mb_bit_buffer, 80);
mb = mb1;
block = block1;
is_field_mode[mb_index] = 0;
for (j = 0; j < s->sys->bpm; j++) {
last_index = s->sys->block_sizes[j];
init_get_bits(&gb, buf_ptr, last_index);
/* get the DC */
dc = get_sbits(&gb, 9);
dct_mode = get_bits1(&gb);
class1 = get_bits(&gb, 2);
if (DV_PROFILE_IS_HD(s->sys)) {
mb->idct_put = s->idct_put[0];
mb->scan_table = s->dv_zigzag[0];
mb->factor_table = &s->sys->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64];
is_field_mode[mb_index] |= !j && dct_mode;
} else {
mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3];
mb->scan_table = s->dv_zigzag[dct_mode];
mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 +
(quant + dv_quant_offset[class1])*64];
}
dc = dc << 2;
/* convert to unsigned because 128 is not added in the
standard IDCT */
dc += 1024;
block[0] = dc;
buf_ptr += last_index >> 3;
mb->pos = 0;
mb->partial_bit_count = 0;
av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
dv_decode_ac(&gb, mb, block);
/* write the remaining bits in a new buffer only if the
block is finished */
if (mb->pos >= 64)
bit_copy(&pb, &gb);
block += 64;
mb++;
}
/* pass 2: we can do it just after */
av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
flush_put_bits(&pb);
for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
dv_decode_ac(&gb, mb, block);
/* if still not finished, no need to parse other blocks */
if (mb->pos < 64)
break;
}
}
/* all blocks are finished, so the extra bytes can be used at
the video segment level */
if (j >= s->sys->bpm)
bit_copy(&vs_pb, &gb);
}
/* we need a pass over the whole video segment */
av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
flush_put_bits(&vs_pb);
for (mb_index = 0; mb_index < 5; mb_index++) {
for (j = 0; j < s->sys->bpm; j++) {
if (mb->pos < 64) {
av_dlog(avctx, "start %d:%d\n", mb_index, j);
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
}
/* compute idct and place blocks */
block = &sblock[0][0];
mb = mb_data;
for (mb_index = 0; mb_index < 5; mb_index++) {
dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);
/* idct_put'ting luminance */
if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||
(s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
(s->sys->height >= 720 && mb_y != 134)) {
y_stride = (s->picture.linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
} else {
y_stride = (2 << log2_blocksize);
}
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << log2_blocksize);
linesize = s->picture.linesize[0] << is_field_mode[mb_index];
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
if (s->sys->video_stype == 4) { /* SD 422 */
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
} else {
mb[1].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 1*64);
mb[2].idct_put(y_ptr + y_stride, linesize, block + 2*64);
mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize, block + 3*64);
}
mb += 4;
block += 4*64;
/* idct_put'ting chrominance */
c_offset = (((mb_y >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
(mb_x >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
for (j = 2; j; j--) {
uint8_t *c_ptr = s->picture.data[j] + c_offset;
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint64_t aligned_pixels[64/8];
uint8_t *pixels = (uint8_t*)aligned_pixels;
uint8_t *c_ptr1, *ptr1;
int x, y;
mb->idct_put(pixels, 8, block);
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) {
ptr1 = pixels + (1 << (log2_blocksize - 1));
c_ptr1 = c_ptr + (s->picture.linesize[j] << log2_blocksize);
for (x = 0; x < (1 << (log2_blocksize - 1)); x++) {
c_ptr[x] = pixels[x];
c_ptr1[x] = ptr1[x];
}
}
block += 64; mb++;
} else {
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
s->picture.linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
linesize = s->picture.linesize[j] << is_field_mode[mb_index];
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
if (s->sys->bpm == 8) {
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
}
}
}
}
return 0;
}
| true | FFmpeg | 68e39d6efeacbf95144e3fd47b34fc79f907df3c | static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
{
DVVideoContext *s = avctx->priv_data;
DVwork_chunk *work_chunk = arg;
int quant, dc, dct_mode, class1, j;
int mb_index, mb_x, mb_y, last_index;
int y_stride, linesize;
DCTELEM *block, *block1;
int c_offset;
uint8_t *y_ptr;
const uint8_t *buf_ptr;
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]);
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]);
const int log2_blocksize = 3-s->avctx->lowres;
int is_field_mode[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
buf_ptr = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {
quant = buf_ptr[3] & 0x0f;
buf_ptr += 4;
init_put_bits(&pb, mb_bit_buffer, 80);
mb = mb1;
block = block1;
is_field_mode[mb_index] = 0;
for (j = 0; j < s->sys->bpm; j++) {
last_index = s->sys->block_sizes[j];
init_get_bits(&gb, buf_ptr, last_index);
dc = get_sbits(&gb, 9);
dct_mode = get_bits1(&gb);
class1 = get_bits(&gb, 2);
if (DV_PROFILE_IS_HD(s->sys)) {
mb->idct_put = s->idct_put[0];
mb->scan_table = s->dv_zigzag[0];
mb->factor_table = &s->sys->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64];
is_field_mode[mb_index] |= !j && dct_mode;
} else {
mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3];
mb->scan_table = s->dv_zigzag[dct_mode];
mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 +
(quant + dv_quant_offset[class1])*64];
}
dc = dc << 2;
dc += 1024;
block[0] = dc;
buf_ptr += last_index >> 3;
mb->pos = 0;
mb->partial_bit_count = 0;
av_dlog(avctx, "MB block: %d, %d ", mb_index, j);
dv_decode_ac(&gb, mb, block);
if (mb->pos >= 64)
bit_copy(&pb, &gb);
block += 64;
mb++;
}
av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
flush_put_bits(&pb);
for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
dv_decode_ac(&gb, mb, block);
if (mb->pos < 64)
break;
}
}
if (j >= s->sys->bpm)
bit_copy(&vs_pb, &gb);
}
av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
flush_put_bits(&vs_pb);
for (mb_index = 0; mb_index < 5; mb_index++) {
for (j = 0; j < s->sys->bpm; j++) {
if (mb->pos < 64) {
av_dlog(avctx, "start %d:%d\n", mb_index, j);
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
av_log(avctx, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
}
block = &sblock[0][0];
mb = mb_data;
for (mb_index = 0; mb_index < 5; mb_index++) {
dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);
if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||
(s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
(s->sys->height >= 720 && mb_y != 134)) {
y_stride = (s->picture.linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
} else {
y_stride = (2 << log2_blocksize);
}
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << log2_blocksize);
linesize = s->picture.linesize[0] << is_field_mode[mb_index];
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
if (s->sys->video_stype == 4) {
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
} else {
mb[1].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 1*64);
mb[2].idct_put(y_ptr + y_stride, linesize, block + 2*64);
mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize, block + 3*64);
}
mb += 4;
block += 4*64;
c_offset = (((mb_y >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
(mb_x >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
for (j = 2; j; j--) {
uint8_t *c_ptr = s->picture.data[j] + c_offset;
if (s->sys->pix_fmt == PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
uint64_t aligned_pixels[64/8];
uint8_t *pixels = (uint8_t*)aligned_pixels;
uint8_t *c_ptr1, *ptr1;
int x, y;
mb->idct_put(pixels, 8, block);
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) {
ptr1 = pixels + (1 << (log2_blocksize - 1));
c_ptr1 = c_ptr + (s->picture.linesize[j] << log2_blocksize);
for (x = 0; x < (1 << (log2_blocksize - 1)); x++) {
c_ptr[x] = pixels[x];
c_ptr1[x] = ptr1[x];
}
}
block += 64; mb++;
} else {
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
s->picture.linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
linesize = s->picture.linesize[j] << is_field_mode[mb_index];
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
if (s->sys->bpm == 8) {
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
}
}
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1)
{
DVVideoContext *s = VAR_0->priv_data;
DVwork_chunk *work_chunk = VAR_1;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
int VAR_7, VAR_8, VAR_9, VAR_10;
int VAR_11, VAR_12;
DCTELEM *block, *block1;
int VAR_13;
uint8_t *y_ptr;
const uint8_t *VAR_14;
PutBitContext pb, vs_pb;
GetBitContext gb;
BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]);
LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]);
const int VAR_15 = 3-s->VAR_0->lowres;
int VAR_16[5];
assert((((int)mb_bit_buffer) & 7) == 0);
assert((((int)vs_bit_buffer) & 7) == 0);
memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));
VAR_14 = &s->buf[work_chunk->buf_offset*80];
block1 = &sblock[0][0];
mb1 = mb_data;
init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);
for (VAR_7 = 0; VAR_7 < 5; VAR_7++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {
VAR_2 = VAR_14[3] & 0x0f;
VAR_14 += 4;
init_put_bits(&pb, mb_bit_buffer, 80);
mb = mb1;
block = block1;
VAR_16[VAR_7] = 0;
for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++) {
VAR_10 = s->sys->block_sizes[VAR_6];
init_get_bits(&gb, VAR_14, VAR_10);
VAR_3 = get_sbits(&gb, 9);
VAR_4 = get_bits1(&gb);
VAR_5 = get_bits(&gb, 2);
if (DV_PROFILE_IS_HD(s->sys)) {
mb->idct_put = s->idct_put[0];
mb->scan_table = s->dv_zigzag[0];
mb->factor_table = &s->sys->idct_factor[(VAR_6 >= 4)*4*16*64 + VAR_5*16*64 + VAR_2*64];
VAR_16[VAR_7] |= !VAR_6 && VAR_4;
} else {
mb->idct_put = s->idct_put[VAR_4 && VAR_15 == 3];
mb->scan_table = s->dv_zigzag[VAR_4];
mb->factor_table = &s->sys->idct_factor[(VAR_5 == 3)*2*22*64 + VAR_4*22*64 +
(VAR_2 + dv_quant_offset[VAR_5])*64];
}
VAR_3 = VAR_3 << 2;
VAR_3 += 1024;
block[0] = VAR_3;
VAR_14 += VAR_10 >> 3;
mb->pos = 0;
mb->partial_bit_count = 0;
av_dlog(VAR_0, "MB block: %d, %d ", VAR_7, VAR_6);
dv_decode_ac(&gb, mb, block);
if (mb->pos >= 64)
bit_copy(&pb, &gb);
block += 64;
mb++;
}
av_dlog(VAR_0, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), VAR_7);
block = block1;
mb = mb1;
init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));
flush_put_bits(&pb);
for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++, block += 64, mb++) {
if (mb->pos < 64 && get_bits_left(&gb) > 0) {
dv_decode_ac(&gb, mb, block);
if (mb->pos < 64)
break;
}
}
if (VAR_6 >= s->sys->bpm)
bit_copy(&vs_pb, &gb);
}
av_dlog(VAR_0, "***pass 3 size=%d\n", put_bits_count(&vs_pb));
block = &sblock[0][0];
mb = mb_data;
init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));
flush_put_bits(&vs_pb);
for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {
for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++) {
if (mb->pos < 64) {
av_dlog(VAR_0, "start %d:%d\n", VAR_7, VAR_6);
dv_decode_ac(&gb, mb, block);
}
if (mb->pos >= 64 && mb->pos < 127)
av_log(VAR_0, AV_LOG_ERROR, "AC EOB marker is absent pos=%d\n", mb->pos);
block += 64;
mb++;
}
}
block = &sblock[0][0];
mb = mb_data;
for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {
dv_calculate_mb_xy(s, work_chunk, VAR_7, &VAR_8, &VAR_9);
if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||
(s->sys->pix_fmt == PIX_FMT_YUV411P && VAR_8 >= (704 / 8)) ||
(s->sys->height >= 720 && VAR_9 != 134)) {
VAR_11 = (s->picture.VAR_12[0] << ((!VAR_16[VAR_7]) * VAR_15));
} else {
VAR_11 = (2 << VAR_15);
}
y_ptr = s->picture.data[0] + ((VAR_9 * s->picture.VAR_12[0] + VAR_8) << VAR_15);
VAR_12 = s->picture.VAR_12[0] << VAR_16[VAR_7];
mb[0] .idct_put(y_ptr , VAR_12, block + 0*64);
if (s->sys->video_stype == 4) {
mb[2].idct_put(y_ptr + (1 << VAR_15) , VAR_12, block + 2*64);
} else {
mb[1].idct_put(y_ptr + (1 << VAR_15) , VAR_12, block + 1*64);
mb[2].idct_put(y_ptr + VAR_11, VAR_12, block + 2*64);
mb[3].idct_put(y_ptr + (1 << VAR_15) + VAR_11, VAR_12, block + 3*64);
}
mb += 4;
block += 4*64;
VAR_13 = (((VAR_9 >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.VAR_12[1] +
(VAR_8 >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << VAR_15);
for (VAR_6 = 2; VAR_6; VAR_6--) {
uint8_t *c_ptr = s->picture.data[VAR_6] + VAR_13;
if (s->sys->pix_fmt == PIX_FMT_YUV411P && VAR_8 >= (704 / 8)) {
uint64_t aligned_pixels[64/8];
uint8_t *pixels = (uint8_t*)aligned_pixels;
uint8_t *c_ptr1, *ptr1;
int VAR_17, VAR_18;
mb->idct_put(pixels, 8, block);
for (VAR_18 = 0; VAR_18 < (1 << VAR_15); VAR_18++, c_ptr += s->picture.VAR_12[VAR_6], pixels += 8) {
ptr1 = pixels + (1 << (VAR_15 - 1));
c_ptr1 = c_ptr + (s->picture.VAR_12[VAR_6] << VAR_15);
for (VAR_17 = 0; VAR_17 < (1 << (VAR_15 - 1)); VAR_17++) {
c_ptr[VAR_17] = pixels[VAR_17];
c_ptr1[VAR_17] = ptr1[VAR_17];
}
}
block += 64; mb++;
} else {
VAR_11 = (VAR_9 == 134) ? (1 << VAR_15) :
s->picture.VAR_12[VAR_6] << ((!VAR_16[VAR_7]) * VAR_15);
VAR_12 = s->picture.VAR_12[VAR_6] << VAR_16[VAR_7];
(mb++)-> idct_put(c_ptr , VAR_12, block); block += 64;
if (s->sys->bpm == 8) {
(mb++)->idct_put(c_ptr + VAR_11, VAR_12, block); block += 64;
}
}
}
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1)\n{",
"DVVideoContext *s = VAR_0->priv_data;",
"DVwork_chunk *work_chunk = VAR_1;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"int VAR_7, VAR_8, VAR_9, VAR_10;",
"int VAR_11, VAR_12;",
"DCTELEM *block, *block1;",
"int VAR_13;",
"uint8_t *y_ptr;",
"const uint8_t *VAR_14;",
"PutBitContext pb, vs_pb;",
"GetBitContext gb;",
"BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;",
"LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);",
"LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]);",
"LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]);",
"const int VAR_15 = 3-s->VAR_0->lowres;",
"int VAR_16[5];",
"assert((((int)mb_bit_buffer) & 7) == 0);",
"assert((((int)vs_bit_buffer) & 7) == 0);",
"memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock));",
"VAR_14 = &s->buf[work_chunk->buf_offset*80];",
"block1 = &sblock[0][0];",
"mb1 = mb_data;",
"init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);",
"for (VAR_7 = 0; VAR_7 < 5; VAR_7++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {",
"VAR_2 = VAR_14[3] & 0x0f;",
"VAR_14 += 4;",
"init_put_bits(&pb, mb_bit_buffer, 80);",
"mb = mb1;",
"block = block1;",
"VAR_16[VAR_7] = 0;",
"for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++) {",
"VAR_10 = s->sys->block_sizes[VAR_6];",
"init_get_bits(&gb, VAR_14, VAR_10);",
"VAR_3 = get_sbits(&gb, 9);",
"VAR_4 = get_bits1(&gb);",
"VAR_5 = get_bits(&gb, 2);",
"if (DV_PROFILE_IS_HD(s->sys)) {",
"mb->idct_put = s->idct_put[0];",
"mb->scan_table = s->dv_zigzag[0];",
"mb->factor_table = &s->sys->idct_factor[(VAR_6 >= 4)*4*16*64 + VAR_5*16*64 + VAR_2*64];",
"VAR_16[VAR_7] |= !VAR_6 && VAR_4;",
"} else {",
"mb->idct_put = s->idct_put[VAR_4 && VAR_15 == 3];",
"mb->scan_table = s->dv_zigzag[VAR_4];",
"mb->factor_table = &s->sys->idct_factor[(VAR_5 == 3)*2*22*64 + VAR_4*22*64 +\n(VAR_2 + dv_quant_offset[VAR_5])*64];",
"}",
"VAR_3 = VAR_3 << 2;",
"VAR_3 += 1024;",
"block[0] = VAR_3;",
"VAR_14 += VAR_10 >> 3;",
"mb->pos = 0;",
"mb->partial_bit_count = 0;",
"av_dlog(VAR_0, \"MB block: %d, %d \", VAR_7, VAR_6);",
"dv_decode_ac(&gb, mb, block);",
"if (mb->pos >= 64)\nbit_copy(&pb, &gb);",
"block += 64;",
"mb++;",
"}",
"av_dlog(VAR_0, \"***pass 2 size=%d MB#=%d\\n\", put_bits_count(&pb), VAR_7);",
"block = block1;",
"mb = mb1;",
"init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb));",
"flush_put_bits(&pb);",
"for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++, block += 64, mb++) {",
"if (mb->pos < 64 && get_bits_left(&gb) > 0) {",
"dv_decode_ac(&gb, mb, block);",
"if (mb->pos < 64)\nbreak;",
"}",
"}",
"if (VAR_6 >= s->sys->bpm)\nbit_copy(&vs_pb, &gb);",
"}",
"av_dlog(VAR_0, \"***pass 3 size=%d\\n\", put_bits_count(&vs_pb));",
"block = &sblock[0][0];",
"mb = mb_data;",
"init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb));",
"flush_put_bits(&vs_pb);",
"for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < s->sys->bpm; VAR_6++) {",
"if (mb->pos < 64) {",
"av_dlog(VAR_0, \"start %d:%d\\n\", VAR_7, VAR_6);",
"dv_decode_ac(&gb, mb, block);",
"}",
"if (mb->pos >= 64 && mb->pos < 127)\nav_log(VAR_0, AV_LOG_ERROR, \"AC EOB marker is absent pos=%d\\n\", mb->pos);",
"block += 64;",
"mb++;",
"}",
"}",
"block = &sblock[0][0];",
"mb = mb_data;",
"for (VAR_7 = 0; VAR_7 < 5; VAR_7++) {",
"dv_calculate_mb_xy(s, work_chunk, VAR_7, &VAR_8, &VAR_9);",
"if ((s->sys->pix_fmt == PIX_FMT_YUV420P) ||\n(s->sys->pix_fmt == PIX_FMT_YUV411P && VAR_8 >= (704 / 8)) ||\n(s->sys->height >= 720 && VAR_9 != 134)) {",
"VAR_11 = (s->picture.VAR_12[0] << ((!VAR_16[VAR_7]) * VAR_15));",
"} else {",
"VAR_11 = (2 << VAR_15);",
"}",
"y_ptr = s->picture.data[0] + ((VAR_9 * s->picture.VAR_12[0] + VAR_8) << VAR_15);",
"VAR_12 = s->picture.VAR_12[0] << VAR_16[VAR_7];",
"mb[0] .idct_put(y_ptr , VAR_12, block + 0*64);",
"if (s->sys->video_stype == 4) {",
"mb[2].idct_put(y_ptr + (1 << VAR_15) , VAR_12, block + 2*64);",
"} else {",
"mb[1].idct_put(y_ptr + (1 << VAR_15) , VAR_12, block + 1*64);",
"mb[2].idct_put(y_ptr + VAR_11, VAR_12, block + 2*64);",
"mb[3].idct_put(y_ptr + (1 << VAR_15) + VAR_11, VAR_12, block + 3*64);",
"}",
"mb += 4;",
"block += 4*64;",
"VAR_13 = (((VAR_9 >> (s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.VAR_12[1] +\n(VAR_8 >> ((s->sys->pix_fmt == PIX_FMT_YUV411P) ? 2 : 1))) << VAR_15);",
"for (VAR_6 = 2; VAR_6; VAR_6--) {",
"uint8_t *c_ptr = s->picture.data[VAR_6] + VAR_13;",
"if (s->sys->pix_fmt == PIX_FMT_YUV411P && VAR_8 >= (704 / 8)) {",
"uint64_t aligned_pixels[64/8];",
"uint8_t *pixels = (uint8_t*)aligned_pixels;",
"uint8_t *c_ptr1, *ptr1;",
"int VAR_17, VAR_18;",
"mb->idct_put(pixels, 8, block);",
"for (VAR_18 = 0; VAR_18 < (1 << VAR_15); VAR_18++, c_ptr += s->picture.VAR_12[VAR_6], pixels += 8) {",
"ptr1 = pixels + (1 << (VAR_15 - 1));",
"c_ptr1 = c_ptr + (s->picture.VAR_12[VAR_6] << VAR_15);",
"for (VAR_17 = 0; VAR_17 < (1 << (VAR_15 - 1)); VAR_17++) {",
"c_ptr[VAR_17] = pixels[VAR_17];",
"c_ptr1[VAR_17] = ptr1[VAR_17];",
"}",
"}",
"block += 64; mb++;",
"} else {",
"VAR_11 = (VAR_9 == 134) ? (1 << VAR_15) :\ns->picture.VAR_12[VAR_6] << ((!VAR_16[VAR_7]) * VAR_15);",
"VAR_12 = s->picture.VAR_12[VAR_6] << VAR_16[VAR_7];",
"(mb++)-> idct_put(c_ptr , VAR_12, block); block += 64;",
"if (s->sys->bpm == 8) {",
"(mb++)->idct_put(c_ptr + VAR_11, VAR_12, block); block += 64;",
"}",
"}",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
143,
145
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177,
179
],
[
181
],
[
183
],
[
189,
191
],
[
193
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
237
],
[
239
],
[
241
],
[
243
],
[
249,
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
]
] |
25,220 | void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
uint16_t io_base)
{
Aml *dev;
Aml *crs;
Aml *pkg;
Aml *field;
Aml *method;
Aml *if_ctx;
Aml *else_ctx;
int i, apic_idx;
Aml *sb_scope = aml_scope("_SB");
uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};
Aml *cpu_id = aml_arg(1);
Aml *apic_id = aml_arg(0);
Aml *cpu_on = aml_local(0);
Aml *madt = aml_local(1);
Aml *cpus_map = aml_name(CPU_ON_BITMAP);
Aml *zero = aml_int(0);
Aml *one = aml_int(1);
MachineClass *mc = MACHINE_GET_CLASS(machine);
CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
PCMachineState *pcms = PC_MACHINE(machine);
/*
* _MAT method - creates an madt apic buffer
* apic_id = Arg0 = Local APIC ID
* cpu_id = Arg1 = Processor ID
* cpu_on = Local0 = CPON flag for this cpu
* madt = Local1 = Buffer (in madt apic form) to return
*/
method = aml_method(CPU_MAT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
aml_append(method,
aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));
/* Update the processor id, lapic id, and enable/disable status */
aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));
aml_append(method, aml_store(apic_id, aml_index(madt, aml_int(3))));
aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));
aml_append(method, aml_return(madt));
aml_append(sb_scope, method);
/*
* _STA method - return ON status of cpu
* apic_id = Arg0 = Local APIC ID
* cpu_on = Local0 = CPON flag for this cpu
*/
method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
if_ctx = aml_if(cpu_on);
{
aml_append(if_ctx, aml_return(aml_int(0xF)));
}
aml_append(method, if_ctx);
else_ctx = aml_else();
{
aml_append(else_ctx, aml_return(zero));
}
aml_append(method, else_ctx);
aml_append(sb_scope, method);
method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method, aml_sleep(200));
aml_append(sb_scope, method);
method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *while_ctx, *if_ctx2, *else_ctx2;
Aml *bus_check_evt = aml_int(1);
Aml *remove_evt = aml_int(3);
Aml *status_map = aml_local(5); /* Local5 = active cpu bitmap */
Aml *byte = aml_local(2); /* Local2 = last read byte from bitmap */
Aml *idx = aml_local(0); /* Processor ID / APIC ID iterator */
Aml *is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */
Aml *status = aml_local(3); /* Local3 = active state for cpu */
aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));
aml_append(method, aml_store(zero, byte));
aml_append(method, aml_store(zero, idx));
/* While (idx < SizeOf(CPON)) */
while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));
aml_append(while_ctx,
aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));
if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));
{
/* Shift down previously read bitmap byte */
aml_append(if_ctx, aml_shiftright(byte, one, byte));
}
aml_append(while_ctx, if_ctx);
else_ctx = aml_else();
{
/* Read next byte from cpu bitmap */
aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,
aml_shiftright(idx, aml_int(3), NULL))), byte));
}
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));
if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));
{
/* State change - update CPON with new state */
aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));
if_ctx2 = aml_if(aml_equal(status, one));
{
aml_append(if_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));
}
aml_append(if_ctx, if_ctx2);
else_ctx2 = aml_else();
{
aml_append(else_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));
}
}
aml_append(if_ctx, else_ctx2);
aml_append(while_ctx, if_ctx);
aml_append(while_ctx, aml_increment(idx)); /* go to next cpu */
aml_append(method, while_ctx);
}
aml_append(sb_scope, method);
/* The current AML generator can cover the APIC ID range [0..255],
* inclusive, for VCPU hotplug. */
QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);
/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */
dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("CPU Hotplug resources"))
);
/* device present, functioning, decoding, not shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, io_base, io_base, 1, ACPI_GPE_PROC_LEN)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(sb_scope, dev);
/* declare CPU hotplug MMIO region and PRS field to access it */
aml_append(sb_scope, aml_operation_region(
"PRST", AML_SYSTEM_IO, aml_int(io_base), ACPI_GPE_PROC_LEN));
field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PRS", 256));
aml_append(sb_scope, field);
/* build Processor object for each processor */
for (i = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
dev = aml_processor(i, 0, 0, "CP%.02X", apic_id);
method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(i))
));
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),
aml_arg(0)))
);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
/* build this code:
* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}
*/
/* Arg0 = APIC ID */
method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (i = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
aml_append(if_ctx,
aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
);
aml_append(method, if_ctx);
}
aml_append(sb_scope, method);
/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })"
*
* Note: The ability to create variable-sized packages was first
* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages
* ith up to 255 elements. Windows guests up to win2k8 fail when
* VarPackageOp is used.
*/
pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :
aml_varpackage(pcms->apic_id_limit);
for (i = 0, apic_idx = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
for (; apic_idx < apic_id; apic_idx++) {
aml_append(pkg, aml_int(0));
}
aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0));
apic_idx = apic_id + 1;
}
aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));
g_free(apic_ids);
aml_append(ctx, sb_scope);
method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
aml_append(ctx, method);
}
| false | qemu | 6a91cf04a1177f47a18d3c25873513a1ebfc2fcb | void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,
uint16_t io_base)
{
Aml *dev;
Aml *crs;
Aml *pkg;
Aml *field;
Aml *method;
Aml *if_ctx;
Aml *else_ctx;
int i, apic_idx;
Aml *sb_scope = aml_scope("_SB");
uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};
Aml *cpu_id = aml_arg(1);
Aml *apic_id = aml_arg(0);
Aml *cpu_on = aml_local(0);
Aml *madt = aml_local(1);
Aml *cpus_map = aml_name(CPU_ON_BITMAP);
Aml *zero = aml_int(0);
Aml *one = aml_int(1);
MachineClass *mc = MACHINE_GET_CLASS(machine);
CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
PCMachineState *pcms = PC_MACHINE(machine);
method = aml_method(CPU_MAT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
aml_append(method,
aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));
aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));
aml_append(method, aml_store(apic_id, aml_index(madt, aml_int(3))));
aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));
aml_append(method, aml_return(madt));
aml_append(sb_scope, method);
method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
if_ctx = aml_if(cpu_on);
{
aml_append(if_ctx, aml_return(aml_int(0xF)));
}
aml_append(method, if_ctx);
else_ctx = aml_else();
{
aml_append(else_ctx, aml_return(zero));
}
aml_append(method, else_ctx);
aml_append(sb_scope, method);
method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method, aml_sleep(200));
aml_append(sb_scope, method);
method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *while_ctx, *if_ctx2, *else_ctx2;
Aml *bus_check_evt = aml_int(1);
Aml *remove_evt = aml_int(3);
Aml *status_map = aml_local(5);
Aml *byte = aml_local(2);
Aml *idx = aml_local(0);
Aml *is_cpu_on = aml_local(1);
Aml *status = aml_local(3);
aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));
aml_append(method, aml_store(zero, byte));
aml_append(method, aml_store(zero, idx));
while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));
aml_append(while_ctx,
aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));
if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));
{
aml_append(if_ctx, aml_shiftright(byte, one, byte));
}
aml_append(while_ctx, if_ctx);
else_ctx = aml_else();
{
aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,
aml_shiftright(idx, aml_int(3), NULL))), byte));
}
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));
if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));
{
aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));
if_ctx2 = aml_if(aml_equal(status, one));
{
aml_append(if_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));
}
aml_append(if_ctx, if_ctx2);
else_ctx2 = aml_else();
{
aml_append(else_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));
}
}
aml_append(if_ctx, else_ctx2);
aml_append(while_ctx, if_ctx);
aml_append(while_ctx, aml_increment(idx));
aml_append(method, while_ctx);
}
aml_append(sb_scope, method);
QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);
dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("CPU Hotplug resources"))
);
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, io_base, io_base, 1, ACPI_GPE_PROC_LEN)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(sb_scope, dev);
aml_append(sb_scope, aml_operation_region(
"PRST", AML_SYSTEM_IO, aml_int(io_base), ACPI_GPE_PROC_LEN));
field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PRS", 256));
aml_append(sb_scope, field);
for (i = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
dev = aml_processor(i, 0, 0, "CP%.02X", apic_id);
method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(i))
));
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),
aml_arg(0)))
);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (i = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
aml_append(if_ctx,
aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
);
aml_append(method, if_ctx);
}
aml_append(sb_scope, method);
pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :
aml_varpackage(pcms->apic_id_limit);
for (i = 0, apic_idx = 0; i < apic_ids->len; i++) {
int apic_id = apic_ids->cpus[i].arch_id;
for (; apic_idx < apic_id; apic_idx++) {
aml_append(pkg, aml_int(0));
}
aml_append(pkg, aml_int(apic_ids->cpus[i].cpu ? 1 : 0));
apic_idx = apic_id + 1;
}
aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));
g_free(apic_ids);
aml_append(ctx, sb_scope);
method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
aml_append(ctx, method);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Aml *VAR_0, MachineState *VAR_1,
uint16_t VAR_2)
{
Aml *dev;
Aml *crs;
Aml *pkg;
Aml *field;
Aml *method;
Aml *if_ctx;
Aml *else_ctx;
int VAR_3, VAR_4;
Aml *sb_scope = aml_scope("_SB");
uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};
Aml *cpu_id = aml_arg(1);
Aml *apic_id = aml_arg(0);
Aml *cpu_on = aml_local(0);
Aml *madt = aml_local(1);
Aml *cpus_map = aml_name(CPU_ON_BITMAP);
Aml *zero = aml_int(0);
Aml *one = aml_int(1);
MachineClass *mc = MACHINE_GET_CLASS(VAR_1);
CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(VAR_1);
PCMachineState *pcms = PC_MACHINE(VAR_1);
method = aml_method(CPU_MAT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
aml_append(method,
aml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));
aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));
aml_append(method, aml_store(apic_id, aml_index(madt, aml_int(3))));
aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));
aml_append(method, aml_return(madt));
aml_append(sb_scope, method);
method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);
aml_append(method,
aml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));
if_ctx = aml_if(cpu_on);
{
aml_append(if_ctx, aml_return(aml_int(0xF)));
}
aml_append(method, if_ctx);
else_ctx = aml_else();
{
aml_append(else_ctx, aml_return(zero));
}
aml_append(method, else_ctx);
aml_append(sb_scope, method);
method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);
aml_append(method, aml_sleep(200));
aml_append(sb_scope, method);
method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);
{
Aml *while_ctx, *if_ctx2, *else_ctx2;
Aml *bus_check_evt = aml_int(1);
Aml *remove_evt = aml_int(3);
Aml *status_map = aml_local(5);
Aml *byte = aml_local(2);
Aml *idx = aml_local(0);
Aml *is_cpu_on = aml_local(1);
Aml *status = aml_local(3);
aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));
aml_append(method, aml_store(zero, byte));
aml_append(method, aml_store(zero, idx));
while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));
aml_append(while_ctx,
aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));
if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));
{
aml_append(if_ctx, aml_shiftright(byte, one, byte));
}
aml_append(while_ctx, if_ctx);
else_ctx = aml_else();
{
aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,
aml_shiftright(idx, aml_int(3), NULL))), byte));
}
aml_append(while_ctx, else_ctx);
aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));
if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));
{
aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));
if_ctx2 = aml_if(aml_equal(status, one));
{
aml_append(if_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));
}
aml_append(if_ctx, if_ctx2);
else_ctx2 = aml_else();
{
aml_append(else_ctx2,
aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));
}
}
aml_append(if_ctx, else_ctx2);
aml_append(while_ctx, if_ctx);
aml_append(while_ctx, aml_increment(idx));
aml_append(method, while_ctx);
}
aml_append(sb_scope, method);
QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);
dev = aml_device("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));
aml_append(dev,
aml_name_decl("_UID", aml_string("CPU Hotplug resources"))
);
aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
crs = aml_resource_template();
aml_append(crs,
aml_io(AML_DECODE16, VAR_2, VAR_2, 1, ACPI_GPE_PROC_LEN)
);
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(sb_scope, dev);
aml_append(sb_scope, aml_operation_region(
"PRST", AML_SYSTEM_IO, aml_int(VAR_2), ACPI_GPE_PROC_LEN));
field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
aml_append(field, aml_named_field("PRS", 256));
aml_append(sb_scope, field);
for (VAR_3 = 0; VAR_3 < apic_ids->len; VAR_3++) {
int apic_id = apic_ids->cpus[VAR_3].arch_id;
assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);
dev = aml_processor(VAR_3, 0, 0, "CP%.02X", apic_id);
method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(VAR_3))
));
aml_append(dev, method);
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));
aml_append(dev, method);
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),
aml_arg(0)))
);
aml_append(dev, method);
aml_append(sb_scope, dev);
}
method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);
for (VAR_3 = 0; VAR_3 < apic_ids->len; VAR_3++) {
int apic_id = apic_ids->cpus[VAR_3].arch_id;
if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
aml_append(if_ctx,
aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
);
aml_append(method, if_ctx);
}
aml_append(sb_scope, method);
pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :
aml_varpackage(pcms->apic_id_limit);
for (VAR_3 = 0, VAR_4 = 0; VAR_3 < apic_ids->len; VAR_3++) {
int apic_id = apic_ids->cpus[VAR_3].arch_id;
for (; VAR_4 < apic_id; VAR_4++) {
aml_append(pkg, aml_int(0));
}
aml_append(pkg, aml_int(apic_ids->cpus[VAR_3].cpu ? 1 : 0));
VAR_4 = apic_id + 1;
}
aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));
g_free(apic_ids);
aml_append(VAR_0, sb_scope);
method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);
aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
aml_append(VAR_0, method);
}
| [
"void FUNC_0(Aml *VAR_0, MachineState *VAR_1,\nuint16_t VAR_2)\n{",
"Aml *dev;",
"Aml *crs;",
"Aml *pkg;",
"Aml *field;",
"Aml *method;",
"Aml *if_ctx;",
"Aml *else_ctx;",
"int VAR_3, VAR_4;",
"Aml *sb_scope = aml_scope(\"_SB\");",
"uint8_t madt_tmpl[8] = {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0};",
"Aml *cpu_id = aml_arg(1);",
"Aml *apic_id = aml_arg(0);",
"Aml *cpu_on = aml_local(0);",
"Aml *madt = aml_local(1);",
"Aml *cpus_map = aml_name(CPU_ON_BITMAP);",
"Aml *zero = aml_int(0);",
"Aml *one = aml_int(1);",
"MachineClass *mc = MACHINE_GET_CLASS(VAR_1);",
"CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(VAR_1);",
"PCMachineState *pcms = PC_MACHINE(VAR_1);",
"method = aml_method(CPU_MAT_METHOD, 2, AML_NOTSERIALIZED);",
"aml_append(method,\naml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));",
"aml_append(method,\naml_store(aml_buffer(sizeof(madt_tmpl), madt_tmpl), madt));",
"aml_append(method, aml_store(cpu_id, aml_index(madt, aml_int(2))));",
"aml_append(method, aml_store(apic_id, aml_index(madt, aml_int(3))));",
"aml_append(method, aml_store(cpu_on, aml_index(madt, aml_int(4))));",
"aml_append(method, aml_return(madt));",
"aml_append(sb_scope, method);",
"method = aml_method(CPU_STATUS_METHOD, 1, AML_NOTSERIALIZED);",
"aml_append(method,\naml_store(aml_derefof(aml_index(cpus_map, apic_id)), cpu_on));",
"if_ctx = aml_if(cpu_on);",
"{",
"aml_append(if_ctx, aml_return(aml_int(0xF)));",
"}",
"aml_append(method, if_ctx);",
"else_ctx = aml_else();",
"{",
"aml_append(else_ctx, aml_return(zero));",
"}",
"aml_append(method, else_ctx);",
"aml_append(sb_scope, method);",
"method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);",
"aml_append(method, aml_sleep(200));",
"aml_append(sb_scope, method);",
"method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);",
"{",
"Aml *while_ctx, *if_ctx2, *else_ctx2;",
"Aml *bus_check_evt = aml_int(1);",
"Aml *remove_evt = aml_int(3);",
"Aml *status_map = aml_local(5);",
"Aml *byte = aml_local(2);",
"Aml *idx = aml_local(0);",
"Aml *is_cpu_on = aml_local(1);",
"Aml *status = aml_local(3);",
"aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));",
"aml_append(method, aml_store(zero, byte));",
"aml_append(method, aml_store(zero, idx));",
"while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));",
"aml_append(while_ctx,\naml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));",
"if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));",
"{",
"aml_append(if_ctx, aml_shiftright(byte, one, byte));",
"}",
"aml_append(while_ctx, if_ctx);",
"else_ctx = aml_else();",
"{",
"aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,\naml_shiftright(idx, aml_int(3), NULL))), byte));",
"}",
"aml_append(while_ctx, else_ctx);",
"aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));",
"if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));",
"{",
"aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));",
"if_ctx2 = aml_if(aml_equal(status, one));",
"{",
"aml_append(if_ctx2,\naml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));",
"}",
"aml_append(if_ctx, if_ctx2);",
"else_ctx2 = aml_else();",
"{",
"aml_append(else_ctx2,\naml_call2(AML_NOTIFY_METHOD, idx, remove_evt));",
"}",
"}",
"aml_append(if_ctx, else_ctx2);",
"aml_append(while_ctx, if_ctx);",
"aml_append(while_ctx, aml_increment(idx));",
"aml_append(method, while_ctx);",
"}",
"aml_append(sb_scope, method);",
"QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);",
"g_assert(pcms->apic_id_limit <= ACPI_CPU_HOTPLUG_ID_LIMIT);",
"dev = aml_device(\"PCI0.\" stringify(CPU_HOTPLUG_RESOURCE_DEVICE));",
"aml_append(dev, aml_name_decl(\"_HID\", aml_eisaid(\"PNP0A06\")));",
"aml_append(dev,\naml_name_decl(\"_UID\", aml_string(\"CPU Hotplug resources\"))\n);",
"aml_append(dev, aml_name_decl(\"_STA\", aml_int(0xB)));",
"crs = aml_resource_template();",
"aml_append(crs,\naml_io(AML_DECODE16, VAR_2, VAR_2, 1, ACPI_GPE_PROC_LEN)\n);",
"aml_append(dev, aml_name_decl(\"_CRS\", crs));",
"aml_append(sb_scope, dev);",
"aml_append(sb_scope, aml_operation_region(\n\"PRST\", AML_SYSTEM_IO, aml_int(VAR_2), ACPI_GPE_PROC_LEN));",
"field = aml_field(\"PRST\", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);",
"aml_append(field, aml_named_field(\"PRS\", 256));",
"aml_append(sb_scope, field);",
"for (VAR_3 = 0; VAR_3 < apic_ids->len; VAR_3++) {",
"int apic_id = apic_ids->cpus[VAR_3].arch_id;",
"assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT);",
"dev = aml_processor(VAR_3, 0, 0, \"CP%.02X\", apic_id);",
"method = aml_method(\"_MAT\", 0, AML_NOTSERIALIZED);",
"aml_append(method,\naml_return(aml_call2(CPU_MAT_METHOD, aml_int(apic_id), aml_int(VAR_3))\n));",
"aml_append(dev, method);",
"method = aml_method(\"_STA\", 0, AML_NOTSERIALIZED);",
"aml_append(method,\naml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id))));",
"aml_append(dev, method);",
"method = aml_method(\"_EJ0\", 1, AML_NOTSERIALIZED);",
"aml_append(method,\naml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id),\naml_arg(0)))\n);",
"aml_append(dev, method);",
"aml_append(sb_scope, dev);",
"}",
"method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED);",
"for (VAR_3 = 0; VAR_3 < apic_ids->len; VAR_3++) {",
"int apic_id = apic_ids->cpus[VAR_3].arch_id;",
"if_ctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));",
"aml_append(if_ctx,\naml_notify(aml_name(\"CP%.02X\", apic_id), aml_arg(1))\n);",
"aml_append(method, if_ctx);",
"}",
"aml_append(sb_scope, method);",
"pkg = pcms->apic_id_limit <= 255 ? aml_package(pcms->apic_id_limit) :\naml_varpackage(pcms->apic_id_limit);",
"for (VAR_3 = 0, VAR_4 = 0; VAR_3 < apic_ids->len; VAR_3++) {",
"int apic_id = apic_ids->cpus[VAR_3].arch_id;",
"for (; VAR_4 < apic_id; VAR_4++) {",
"aml_append(pkg, aml_int(0));",
"}",
"aml_append(pkg, aml_int(apic_ids->cpus[VAR_3].cpu ? 1 : 0));",
"VAR_4 = apic_id + 1;",
"}",
"aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg));",
"g_free(apic_ids);",
"aml_append(VAR_0, sb_scope);",
"method = aml_method(\"\\\\_GPE._E02\", 0, AML_NOTSERIALIZED);",
"aml_append(method, aml_call0(\"\\\\_SB.\" CPU_SCAN_METHOD));",
"aml_append(VAR_0, method);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
63
],
[
65,
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
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
],
[
157
],
[
159
],
[
161
],
[
167
],
[
169,
171
],
[
175
],
[
177
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
195,
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
259
],
[
261
],
[
267
],
[
269
],
[
271,
273,
275
],
[
279
],
[
281
],
[
283,
285,
287
],
[
289
],
[
291
],
[
295,
297
],
[
299
],
[
301
],
[
303
],
[
309
],
[
311
],
[
315
],
[
319
],
[
323
],
[
325,
327,
329
],
[
331
],
[
335
],
[
337,
339
],
[
341
],
[
345
],
[
347,
349,
351,
353
],
[
355
],
[
359
],
[
361
],
[
373
],
[
375
],
[
377
],
[
381
],
[
383,
385,
387
],
[
389
],
[
391
],
[
393
],
[
411,
413
],
[
417
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
441
],
[
445
],
[
447
],
[
449
],
[
451
]
] |
25,221 | static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret3);
QDECREF(req);
}
| false | qemu | b6fcf32d9b851a83dedcb609091236b97cc4a985 | static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret3);
QDECREF(req);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret3);
QDECREF(req);
}
| [
"static void FUNC_0(void)\n{",
"QDict *req = qdict_new();",
"QDict *args = qdict_new();",
"QDict *args3 = qdict_new();",
"QDict *ud1a = qdict_new();",
"QDict *ud1b = qdict_new();",
"QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;",
"QDict *ret_dict_dict2, *ret_dict_dict2_userdef;",
"QInt *ret3;",
"qdict_put_obj(ud1a, \"integer\", QOBJECT(qint_from_int(42)));",
"qdict_put_obj(ud1a, \"string\", QOBJECT(qstring_from_str(\"hello\")));",
"qdict_put_obj(ud1b, \"integer\", QOBJECT(qint_from_int(422)));",
"qdict_put_obj(ud1b, \"string\", QOBJECT(qstring_from_str(\"hello2\")));",
"qdict_put_obj(args, \"ud1a\", QOBJECT(ud1a));",
"qdict_put_obj(args, \"ud1b\", QOBJECT(ud1b));",
"qdict_put_obj(req, \"arguments\", QOBJECT(args));",
"qdict_put_obj(req, \"execute\", QOBJECT(qstring_from_str(\"user_def_cmd2\")));",
"ret = qobject_to_qdict(test_qmp_dispatch(req));",
"assert(!strcmp(qdict_get_str(ret, \"string\"), \"blah1\"));",
"ret_dict = qdict_get_qdict(ret, \"dict\");",
"assert(!strcmp(qdict_get_str(ret_dict, \"string\"), \"blah2\"));",
"ret_dict_dict = qdict_get_qdict(ret_dict, \"dict\");",
"ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, \"userdef\");",
"assert(qdict_get_int(ret_dict_dict_userdef, \"integer\") == 42);",
"assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, \"string\"), \"hello\"));",
"assert(!strcmp(qdict_get_str(ret_dict_dict, \"string\"), \"blah3\"));",
"ret_dict_dict2 = qdict_get_qdict(ret_dict, \"dict2\");",
"ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, \"userdef\");",
"assert(qdict_get_int(ret_dict_dict2_userdef, \"integer\") == 422);",
"assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, \"string\"), \"hello2\"));",
"assert(!strcmp(qdict_get_str(ret_dict_dict2, \"string\"), \"blah4\"));",
"QDECREF(ret);",
"qdict_put(args3, \"a\", qint_from_int(66));",
"qdict_put(req, \"arguments\", args3);",
"qdict_put(req, \"execute\", qstring_from_str(\"user_def_cmd3\"));",
"ret3 = qobject_to_qint(test_qmp_dispatch(req));",
"assert(qint_get_int(ret3) == 66);",
"QDECREF(ret3);",
"QDECREF(req);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
25,222 | static void coroutine_fn bdrv_flush_co_entry(void *opaque)
{
RwCo *rwco = opaque;
rwco->ret = bdrv_co_flush(rwco->bs);
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | static void coroutine_fn bdrv_flush_co_entry(void *opaque)
{
RwCo *rwco = opaque;
rwco->ret = bdrv_co_flush(rwco->bs);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 bdrv_flush_co_entry(void *opaque)
{
RwCo *rwco = opaque;
rwco->ret = bdrv_co_flush(rwco->bs);
}
| [
"static void VAR_0 bdrv_flush_co_entry(void *opaque)\n{",
"RwCo *rwco = opaque;",
"rwco->ret = bdrv_co_flush(rwco->bs);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
]
] |
25,224 | static inline void t_gen_add_flag(TCGv d, int flag)
{
TCGv c;
c = tcg_temp_new(TCG_TYPE_TL);
t_gen_mov_TN_preg(c, PR_CCS);
/* Propagate carry into d. */
tcg_gen_andi_tl(c, c, 1 << flag);
if (flag)
tcg_gen_shri_tl(c, c, flag);
tcg_gen_add_tl(d, d, c);
tcg_temp_free(c);
}
| false | qemu | a7812ae412311d7d47f8aa85656faadac9d64b56 | static inline void t_gen_add_flag(TCGv d, int flag)
{
TCGv c;
c = tcg_temp_new(TCG_TYPE_TL);
t_gen_mov_TN_preg(c, PR_CCS);
tcg_gen_andi_tl(c, c, 1 << flag);
if (flag)
tcg_gen_shri_tl(c, c, flag);
tcg_gen_add_tl(d, d, c);
tcg_temp_free(c);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, int VAR_1)
{
TCGv c;
c = tcg_temp_new(TCG_TYPE_TL);
t_gen_mov_TN_preg(c, PR_CCS);
tcg_gen_andi_tl(c, c, 1 << VAR_1);
if (VAR_1)
tcg_gen_shri_tl(c, c, VAR_1);
tcg_gen_add_tl(VAR_0, VAR_0, c);
tcg_temp_free(c);
}
| [
"static inline void FUNC_0(TCGv VAR_0, int VAR_1)\n{",
"TCGv c;",
"c = tcg_temp_new(TCG_TYPE_TL);",
"t_gen_mov_TN_preg(c, PR_CCS);",
"tcg_gen_andi_tl(c, c, 1 << VAR_1);",
"if (VAR_1)\ntcg_gen_shri_tl(c, c, VAR_1);",
"tcg_gen_add_tl(VAR_0, VAR_0, c);",
"tcg_temp_free(c);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
]
] |
25,225 | void console_select(unsigned int index)
{
TextConsole *s;
if (index >= MAX_CONSOLES)
return;
s = consoles[index];
if (s) {
active_console = s;
if (s->g_width && s->g_height
&& (s->g_width != s->ds->width || s->g_height != s->ds->height))
dpy_resize(s->ds, s->g_width, s->g_height);
vga_hw_invalidate();
}
}
| false | qemu | c21bbcfa3ff4f6dc49fb01080ef598851aa424dd | void console_select(unsigned int index)
{
TextConsole *s;
if (index >= MAX_CONSOLES)
return;
s = consoles[index];
if (s) {
active_console = s;
if (s->g_width && s->g_height
&& (s->g_width != s->ds->width || s->g_height != s->ds->height))
dpy_resize(s->ds, s->g_width, s->g_height);
vga_hw_invalidate();
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(unsigned int VAR_0)
{
TextConsole *s;
if (VAR_0 >= MAX_CONSOLES)
return;
s = consoles[VAR_0];
if (s) {
active_console = s;
if (s->g_width && s->g_height
&& (s->g_width != s->ds->width || s->g_height != s->ds->height))
dpy_resize(s->ds, s->g_width, s->g_height);
vga_hw_invalidate();
}
}
| [
"void FUNC_0(unsigned int VAR_0)\n{",
"TextConsole *s;",
"if (VAR_0 >= MAX_CONSOLES)\nreturn;",
"s = consoles[VAR_0];",
"if (s) {",
"active_console = s;",
"if (s->g_width && s->g_height\n&& (s->g_width != s->ds->width || s->g_height != s->ds->height))\ndpy_resize(s->ds, s->g_width, s->g_height);",
"vga_hw_invalidate();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29
]
] |
25,226 | static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk,
uint32_t *max_compressed_size,
uint32_t *max_sectors_per_chunk)
{
uint32_t compressed_size = 0;
uint32_t uncompressed_sectors = 0;
switch (s->types[chunk]) {
case 0x80000005: /* zlib compressed */
case 0x80000006: /* bzip2 compressed */
compressed_size = s->lengths[chunk];
uncompressed_sectors = s->sectorcounts[chunk];
break;
case 1: /* copy */
uncompressed_sectors = (s->lengths[chunk] + 511) / 512;
break;
case 2: /* zero */
uncompressed_sectors = s->sectorcounts[chunk];
break;
}
if (compressed_size > *max_compressed_size) {
*max_compressed_size = compressed_size;
}
if (uncompressed_sectors > *max_sectors_per_chunk) {
*max_sectors_per_chunk = uncompressed_sectors;
}
}
| false | qemu | 177b75104da3e3a9af84975c32a44782d903c41f | static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk,
uint32_t *max_compressed_size,
uint32_t *max_sectors_per_chunk)
{
uint32_t compressed_size = 0;
uint32_t uncompressed_sectors = 0;
switch (s->types[chunk]) {
case 0x80000005:
case 0x80000006:
compressed_size = s->lengths[chunk];
uncompressed_sectors = s->sectorcounts[chunk];
break;
case 1:
uncompressed_sectors = (s->lengths[chunk] + 511) / 512;
break;
case 2:
uncompressed_sectors = s->sectorcounts[chunk];
break;
}
if (compressed_size > *max_compressed_size) {
*max_compressed_size = compressed_size;
}
if (uncompressed_sectors > *max_sectors_per_chunk) {
*max_sectors_per_chunk = uncompressed_sectors;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BDRVDMGState *VAR_0, uint32_t VAR_1,
uint32_t *VAR_2,
uint32_t *VAR_3)
{
uint32_t compressed_size = 0;
uint32_t uncompressed_sectors = 0;
switch (VAR_0->types[VAR_1]) {
case 0x80000005:
case 0x80000006:
compressed_size = VAR_0->lengths[VAR_1];
uncompressed_sectors = VAR_0->sectorcounts[VAR_1];
break;
case 1:
uncompressed_sectors = (VAR_0->lengths[VAR_1] + 511) / 512;
break;
case 2:
uncompressed_sectors = VAR_0->sectorcounts[VAR_1];
break;
}
if (compressed_size > *VAR_2) {
*VAR_2 = compressed_size;
}
if (uncompressed_sectors > *VAR_3) {
*VAR_3 = uncompressed_sectors;
}
}
| [
"static void FUNC_0(BDRVDMGState *VAR_0, uint32_t VAR_1,\nuint32_t *VAR_2,\nuint32_t *VAR_3)\n{",
"uint32_t compressed_size = 0;",
"uint32_t uncompressed_sectors = 0;",
"switch (VAR_0->types[VAR_1]) {",
"case 0x80000005:\ncase 0x80000006:\ncompressed_size = VAR_0->lengths[VAR_1];",
"uncompressed_sectors = VAR_0->sectorcounts[VAR_1];",
"break;",
"case 1:\nuncompressed_sectors = (VAR_0->lengths[VAR_1] + 511) / 512;",
"break;",
"case 2:\nuncompressed_sectors = VAR_0->sectorcounts[VAR_1];",
"break;",
"}",
"if (compressed_size > *VAR_2) {",
"*VAR_2 = compressed_size;",
"}",
"if (uncompressed_sectors > *VAR_3) {",
"*VAR_3 = uncompressed_sectors;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
25,227 | static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = &s->pb;
int64_t end, tmp;
AVRational time_base;
nut->last_syncpoint_pos= url_ftell(bc)-8;
end= get_packetheader(nut, bc, 1);
end += url_ftell(bc);
tmp= get_v(bc);
*back_ptr= nut->last_syncpoint_pos - 16*get_v(bc);
if(*back_ptr < 0)
return -1;
ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp);
if(skip_reserved(bc, end) || get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
return -1;
}
*ts= tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
return 0;
}
| false | FFmpeg | 073811cdd29e365498b3455ee4e0eda4b957a957 | static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = &s->pb;
int64_t end, tmp;
AVRational time_base;
nut->last_syncpoint_pos= url_ftell(bc)-8;
end= get_packetheader(nut, bc, 1);
end += url_ftell(bc);
tmp= get_v(bc);
*back_ptr= nut->last_syncpoint_pos - 16*get_v(bc);
if(*back_ptr < 0)
return -1;
ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp);
if(skip_reserved(bc, end) || get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
return -1;
}
*ts= tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(NUTContext *VAR_0, int64_t *VAR_1, int64_t *VAR_2){
AVFormatContext *s= VAR_0->avf;
ByteIOContext *bc = &s->pb;
int64_t end, tmp;
AVRational time_base;
VAR_0->last_syncpoint_pos= url_ftell(bc)-8;
end= get_packetheader(VAR_0, bc, 1);
end += url_ftell(bc);
tmp= get_v(bc);
*VAR_2= VAR_0->last_syncpoint_pos - 16*get_v(bc);
if(*VAR_2 < 0)
return -1;
ff_nut_reset_ts(VAR_0, VAR_0->time_base[tmp % VAR_0->time_base_count], tmp);
if(skip_reserved(bc, end) || get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
return -1;
}
*VAR_1= tmp / s->nb_streams * av_q2d(VAR_0->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
add_sp(VAR_0, VAR_0->last_syncpoint_pos, *VAR_2, *VAR_1);
return 0;
}
| [
"static int FUNC_0(NUTContext *VAR_0, int64_t *VAR_1, int64_t *VAR_2){",
"AVFormatContext *s= VAR_0->avf;",
"ByteIOContext *bc = &s->pb;",
"int64_t end, tmp;",
"AVRational time_base;",
"VAR_0->last_syncpoint_pos= url_ftell(bc)-8;",
"end= get_packetheader(VAR_0, bc, 1);",
"end += url_ftell(bc);",
"tmp= get_v(bc);",
"*VAR_2= VAR_0->last_syncpoint_pos - 16*get_v(bc);",
"if(*VAR_2 < 0)\nreturn -1;",
"ff_nut_reset_ts(VAR_0, VAR_0->time_base[tmp % VAR_0->time_base_count], tmp);",
"if(skip_reserved(bc, end) || get_checksum(bc)){",
"av_log(s, AV_LOG_ERROR, \"sync point checksum mismatch\\n\");",
"return -1;",
"}",
"*VAR_1= tmp / s->nb_streams * av_q2d(VAR_0->time_base[tmp % s->nb_streams])*AV_TIME_BASE;",
"add_sp(VAR_0, VAR_0->last_syncpoint_pos, *VAR_2, *VAR_1);",
"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
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
]
] |
25,228 | int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
{
int i;
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
int max_step [4]; /* max pixel step for each plane */
int max_step_comp[4]; /* the component for each plane which has the max pixel step */
memset(linesizes, 0, 4*sizeof(linesizes[0]));
if (desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (desc->flags & PIX_FMT_BITSTREAM) {
linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
for (i = 0; i < 4; i++) {
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
linesizes[i] = max_step[i] * (((width + (1 << s) - 1)) >> s);
}
return 0;
}
| false | FFmpeg | 6950cca97fed890ec56259a2f868f37b65513d92 | int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
{
int i;
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
int max_step [4];
int max_step_comp[4];
memset(linesizes, 0, 4*sizeof(linesizes[0]));
if (desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (desc->flags & PIX_FMT_BITSTREAM) {
linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
for (i = 0; i < 4; i++) {
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
linesizes[i] = max_step[i] * (((width + (1 << s) - 1)) >> s);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0[4], enum PixelFormat VAR_1, int VAR_2)
{
int VAR_3;
const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1];
int VAR_5 [4];
int VAR_6[4];
memset(VAR_0, 0, 4*sizeof(VAR_0[0]));
if (VAR_4->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (VAR_4->flags & PIX_FMT_BITSTREAM) {
VAR_0[0] = (VAR_2 * (VAR_4->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(VAR_5, VAR_6, VAR_4);
for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {
int VAR_7 = (VAR_6[VAR_3] == 1 || VAR_6[VAR_3] == 2) ? VAR_4->log2_chroma_w : 0;
VAR_0[VAR_3] = VAR_5[VAR_3] * (((VAR_2 + (1 << VAR_7) - 1)) >> VAR_7);
}
return 0;
}
| [
"int FUNC_0(int VAR_0[4], enum PixelFormat VAR_1, int VAR_2)\n{",
"int VAR_3;",
"const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1];",
"int VAR_5 [4];",
"int VAR_6[4];",
"memset(VAR_0, 0, 4*sizeof(VAR_0[0]));",
"if (VAR_4->flags & PIX_FMT_HWACCEL)\nreturn AVERROR(EINVAL);",
"if (VAR_4->flags & PIX_FMT_BITSTREAM) {",
"VAR_0[0] = (VAR_2 * (VAR_4->comp[0].step_minus1+1) + 7) >> 3;",
"return 0;",
"}",
"av_image_fill_max_pixsteps(VAR_5, VAR_6, VAR_4);",
"for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {",
"int VAR_7 = (VAR_6[VAR_3] == 1 || VAR_6[VAR_3] == 2) ? VAR_4->log2_chroma_w : 0;",
"VAR_0[VAR_3] = VAR_5[VAR_3] * (((VAR_2 + (1 << VAR_7) - 1)) >> VAR_7);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
25,229 | static void qmp_output_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QmpOutputVisitor *qov = to_qov(v);
qmp_output_add(qov, name, qint_from_int(*obj));
}
| false | qemu | 7d5e199ade76c53ec316ab6779800581bb47c50a | static void qmp_output_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QmpOutputVisitor *qov = to_qov(v);
qmp_output_add(qov, name, qint_from_int(*obj));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2,
Error **VAR_3)
{
QmpOutputVisitor *qov = to_qov(VAR_0);
qmp_output_add(qov, VAR_1, qint_from_int(*VAR_2));
}
| [
"static void FUNC_0(Visitor *VAR_0, const char *VAR_1, int64_t *VAR_2,\nError **VAR_3)\n{",
"QmpOutputVisitor *qov = to_qov(VAR_0);",
"qmp_output_add(qov, VAR_1, qint_from_int(*VAR_2));",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
25,230 | void qemu_bh_cancel(QEMUBH *bh)
{
bh->scheduled = 0;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | void qemu_bh_cancel(QEMUBH *bh)
{
bh->scheduled = 0;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUBH *VAR_0)
{
VAR_0->scheduled = 0;
}
| [
"void FUNC_0(QEMUBH *VAR_0)\n{",
"VAR_0->scheduled = 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,231 | static int cdrom_probe_device(const char *filename)
{
int fd, ret;
int prio = 0;
if (strstart(filename, "/dev/cd", NULL))
prio = 50;
fd = open(filename, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
goto out;
}
/* Attempt to detect via a CDROM specific ioctl */
ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
if (ret >= 0)
prio = 100;
close(fd);
out:
return prio;
}
| false | qemu | 897804d6299af372a43110799cbe1d6804d5e1bc | static int cdrom_probe_device(const char *filename)
{
int fd, ret;
int prio = 0;
if (strstart(filename, "/dev/cd", NULL))
prio = 50;
fd = open(filename, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
goto out;
}
ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
if (ret >= 0)
prio = 100;
close(fd);
out:
return prio;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0)
{
int VAR_1, VAR_2;
int VAR_3 = 0;
if (strstart(VAR_0, "/dev/cd", NULL))
VAR_3 = 50;
VAR_1 = open(VAR_0, O_RDONLY | O_NONBLOCK);
if (VAR_1 < 0) {
goto out;
}
VAR_2 = ioctl(VAR_1, CDROM_DRIVE_STATUS, CDSL_CURRENT);
if (VAR_2 >= 0)
VAR_3 = 100;
close(VAR_1);
out:
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0)\n{",
"int VAR_1, VAR_2;",
"int VAR_3 = 0;",
"if (strstart(VAR_0, \"/dev/cd\", NULL))\nVAR_3 = 50;",
"VAR_1 = open(VAR_0, O_RDONLY | O_NONBLOCK);",
"if (VAR_1 < 0) {",
"goto out;",
"}",
"VAR_2 = ioctl(VAR_1, CDROM_DRIVE_STATUS, CDSL_CURRENT);",
"if (VAR_2 >= 0)\nVAR_3 = 100;",
"close(VAR_1);",
"out:\nreturn VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31,
33
],
[
37
],
[
39,
41
],
[
43
]
] |
25,233 | static uint64_t megasas_mmio_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MegasasState *s = opaque;
uint32_t retval = 0;
switch (addr) {
case MFI_IDB:
retval = 0;
break;
case MFI_OMSG0:
case MFI_OSP0:
retval = (megasas_use_msix(s) ? MFI_FWSTATE_MSIX_SUPPORTED : 0) |
(s->fw_state & MFI_FWSTATE_MASK) |
((s->fw_sge & 0xff) << 16) |
(s->fw_cmds & 0xFFFF);
break;
case MFI_OSTS:
if (megasas_intr_enabled(s) && s->doorbell) {
retval = MFI_1078_RM | 1;
}
break;
case MFI_OMSK:
retval = s->intr_mask;
break;
case MFI_ODCR0:
retval = s->doorbell;
break;
default:
trace_megasas_mmio_invalid_readl(addr);
break;
}
trace_megasas_mmio_readl(addr, retval);
return retval;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t megasas_mmio_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MegasasState *s = opaque;
uint32_t retval = 0;
switch (addr) {
case MFI_IDB:
retval = 0;
break;
case MFI_OMSG0:
case MFI_OSP0:
retval = (megasas_use_msix(s) ? MFI_FWSTATE_MSIX_SUPPORTED : 0) |
(s->fw_state & MFI_FWSTATE_MASK) |
((s->fw_sge & 0xff) << 16) |
(s->fw_cmds & 0xFFFF);
break;
case MFI_OSTS:
if (megasas_intr_enabled(s) && s->doorbell) {
retval = MFI_1078_RM | 1;
}
break;
case MFI_OMSK:
retval = s->intr_mask;
break;
case MFI_ODCR0:
retval = s->doorbell;
break;
default:
trace_megasas_mmio_invalid_readl(addr);
break;
}
trace_megasas_mmio_readl(addr, retval);
return retval;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MegasasState *s = opaque;
uint32_t retval = 0;
switch (addr) {
case MFI_IDB:
retval = 0;
break;
case MFI_OMSG0:
case MFI_OSP0:
retval = (megasas_use_msix(s) ? MFI_FWSTATE_MSIX_SUPPORTED : 0) |
(s->fw_state & MFI_FWSTATE_MASK) |
((s->fw_sge & 0xff) << 16) |
(s->fw_cmds & 0xFFFF);
break;
case MFI_OSTS:
if (megasas_intr_enabled(s) && s->doorbell) {
retval = MFI_1078_RM | 1;
}
break;
case MFI_OMSK:
retval = s->intr_mask;
break;
case MFI_ODCR0:
retval = s->doorbell;
break;
default:
trace_megasas_mmio_invalid_readl(addr);
break;
}
trace_megasas_mmio_readl(addr, retval);
return retval;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"MegasasState *s = opaque;",
"uint32_t retval = 0;",
"switch (addr) {",
"case MFI_IDB:\nretval = 0;",
"break;",
"case MFI_OMSG0:\ncase MFI_OSP0:\nretval = (megasas_use_msix(s) ? MFI_FWSTATE_MSIX_SUPPORTED : 0) |\n(s->fw_state & MFI_FWSTATE_MASK) |\n((s->fw_sge & 0xff) << 16) |\n(s->fw_cmds & 0xFFFF);",
"break;",
"case MFI_OSTS:\nif (megasas_intr_enabled(s) && s->doorbell) {",
"retval = MFI_1078_RM | 1;",
"}",
"break;",
"case MFI_OMSK:\nretval = s->intr_mask;",
"break;",
"case MFI_ODCR0:\nretval = s->doorbell;",
"break;",
"default:\ntrace_megasas_mmio_invalid_readl(addr);",
"break;",
"}",
"trace_megasas_mmio_readl(addr, retval);",
"return retval;",
"}"
] | [
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
]
] |
25,235 | static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;
switch (addr) {
case RTTR:
return s->rttr;
case RTSR:
return s->rtsr;
case RTAR:
return s->rtar;
case RDAR1:
return s->rdar1;
case RDAR2:
return s->rdar2;
case RYAR1:
return s->ryar1;
case RYAR2:
return s->ryar2;
case SWAR1:
return s->swar1;
case SWAR2:
return s->swar2;
case PIAR:
return s->piar;
case RCNR:
return s->last_rcnr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RDCR:
return s->last_rdcr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RYCR:
return s->last_rycr;
case SWCR:
if (s->rtsr & (1 << 12))
return s->last_swcr +
(qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10;
else
return s->last_swcr;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;
switch (addr) {
case RTTR:
return s->rttr;
case RTSR:
return s->rtsr;
case RTAR:
return s->rtar;
case RDAR1:
return s->rdar1;
case RDAR2:
return s->rdar2;
case RYAR1:
return s->ryar1;
case RYAR2:
return s->ryar2;
case SWAR1:
return s->swar1;
case SWAR2:
return s->swar2;
case PIAR:
return s->piar;
case RCNR:
return s->last_rcnr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RDCR:
return s->last_rdcr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RYCR:
return s->last_rycr;
case SWCR:
if (s->rtsr & (1 << 12))
return s->last_swcr +
(qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10;
else
return s->last_swcr;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;
switch (addr) {
case RTTR:
return s->rttr;
case RTSR:
return s->rtsr;
case RTAR:
return s->rtar;
case RDAR1:
return s->rdar1;
case RDAR2:
return s->rdar2;
case RYAR1:
return s->ryar1;
case RYAR2:
return s->ryar2;
case SWAR1:
return s->swar1;
case SWAR2:
return s->swar2;
case PIAR:
return s->piar;
case RCNR:
return s->last_rcnr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RDCR:
return s->last_rdcr +
((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /
(1000 * ((s->rttr & 0xffff) + 1));
case RYCR:
return s->last_rycr;
case SWCR:
if (s->rtsr & (1 << 12))
return s->last_swcr +
(qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10;
else
return s->last_swcr;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;",
"switch (addr) {",
"case RTTR:\nreturn s->rttr;",
"case RTSR:\nreturn s->rtsr;",
"case RTAR:\nreturn s->rtar;",
"case RDAR1:\nreturn s->rdar1;",
"case RDAR2:\nreturn s->rdar2;",
"case RYAR1:\nreturn s->ryar1;",
"case RYAR2:\nreturn s->ryar2;",
"case SWAR1:\nreturn s->swar1;",
"case SWAR2:\nreturn s->swar2;",
"case PIAR:\nreturn s->piar;",
"case RCNR:\nreturn s->last_rcnr +\n((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /\n(1000 * ((s->rttr & 0xffff) + 1));",
"case RDCR:\nreturn s->last_rdcr +\n((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) /\n(1000 * ((s->rttr & 0xffff) + 1));",
"case RYCR:\nreturn s->last_rycr;",
"case SWCR:\nif (s->rtsr & (1 << 12))\nreturn s->last_swcr +\n(qemu_clock_get_ms(rtc_clock) - s->last_sw) / 10;",
"else\nreturn s->last_swcr;",
"default:\nprintf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, addr);",
"break;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
53,
55,
57,
59
],
[
61,
63,
65,
67
],
[
69,
71
],
[
73,
75,
77,
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
25,236 | static void test_visitor_out_union_flat(TestOutputVisitorData *data,
const void *unused)
{
QObject *arg;
QDict *qdict;
Error *err = NULL;
UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));
tmp->enum1 = ENUM_ONE_VALUE1;
tmp->string = g_strdup("str");
tmp->value1 = g_malloc0(sizeof(UserDefA));
/* TODO when generator bug is fixed: tmp->integer = 41; */
tmp->value1->boolean = true;
visit_type_UserDefFlatUnion(data->ov, &tmp, NULL, &err);
g_assert(err == NULL);
arg = qmp_output_get_qobject(data->qov);
g_assert(qobject_type(arg) == QTYPE_QDICT);
qdict = qobject_to_qdict(arg);
g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1");
g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str");
/* TODO g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 41); */
g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, true);
qapi_free_UserDefFlatUnion(tmp);
QDECREF(qdict);
}
| false | qemu | c363acef772647f66becdbf46dd54e70e67f3cc9 | static void test_visitor_out_union_flat(TestOutputVisitorData *data,
const void *unused)
{
QObject *arg;
QDict *qdict;
Error *err = NULL;
UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));
tmp->enum1 = ENUM_ONE_VALUE1;
tmp->string = g_strdup("str");
tmp->value1 = g_malloc0(sizeof(UserDefA));
tmp->value1->boolean = true;
visit_type_UserDefFlatUnion(data->ov, &tmp, NULL, &err);
g_assert(err == NULL);
arg = qmp_output_get_qobject(data->qov);
g_assert(qobject_type(arg) == QTYPE_QDICT);
qdict = qobject_to_qdict(arg);
g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1");
g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str");
g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, true);
qapi_free_UserDefFlatUnion(tmp);
QDECREF(qdict);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestOutputVisitorData *VAR_0,
const void *VAR_1)
{
QObject *arg;
QDict *qdict;
Error *err = NULL;
UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));
tmp->enum1 = ENUM_ONE_VALUE1;
tmp->string = g_strdup("str");
tmp->value1 = g_malloc0(sizeof(UserDefA));
tmp->value1->boolean = true;
visit_type_UserDefFlatUnion(VAR_0->ov, &tmp, NULL, &err);
g_assert(err == NULL);
arg = qmp_output_get_qobject(VAR_0->qov);
g_assert(qobject_type(arg) == QTYPE_QDICT);
qdict = qobject_to_qdict(arg);
g_assert_cmpstr(qdict_get_str(qdict, "enum1"), ==, "value1");
g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "str");
g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, true);
qapi_free_UserDefFlatUnion(tmp);
QDECREF(qdict);
}
| [
"static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"QObject *arg;",
"QDict *qdict;",
"Error *err = NULL;",
"UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));",
"tmp->enum1 = ENUM_ONE_VALUE1;",
"tmp->string = g_strdup(\"str\");",
"tmp->value1 = g_malloc0(sizeof(UserDefA));",
"tmp->value1->boolean = true;",
"visit_type_UserDefFlatUnion(VAR_0->ov, &tmp, NULL, &err);",
"g_assert(err == NULL);",
"arg = qmp_output_get_qobject(VAR_0->qov);",
"g_assert(qobject_type(arg) == QTYPE_QDICT);",
"qdict = qobject_to_qdict(arg);",
"g_assert_cmpstr(qdict_get_str(qdict, \"enum1\"), ==, \"value1\");",
"g_assert_cmpstr(qdict_get_str(qdict, \"string\"), ==, \"str\");",
"g_assert_cmpint(qdict_get_bool(qdict, \"boolean\"), ==, true);",
"qapi_free_UserDefFlatUnion(tmp);",
"QDECREF(qdict);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
]
] |
25,237 | static SaveStateEntry *find_se(const char *idstr, int instance_id)
{
SaveStateEntry *se;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (!strcmp(se->idstr, idstr) &&
instance_id == se->instance_id)
return se;
}
return NULL;
}
| false | qemu | 4d2ffa08b601bdd40d9ccf225480c0a7e90ca078 | static SaveStateEntry *find_se(const char *idstr, int instance_id)
{
SaveStateEntry *se;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (!strcmp(se->idstr, idstr) &&
instance_id == se->instance_id)
return se;
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static SaveStateEntry *FUNC_0(const char *idstr, int instance_id)
{
SaveStateEntry *se;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (!strcmp(se->idstr, idstr) &&
instance_id == se->instance_id)
return se;
}
return NULL;
}
| [
"static SaveStateEntry *FUNC_0(const char *idstr, int instance_id)\n{",
"SaveStateEntry *se;",
"QTAILQ_FOREACH(se, &savevm_handlers, entry) {",
"if (!strcmp(se->idstr, idstr) &&\ninstance_id == se->instance_id)\nreturn se;",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
]
] |
25,239 | av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
if (cpu_flags & AV_CPU_FLAG_3DNOW)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_3dnow;
#endif /* ARCH_X86_32 */
if (cpu_flags & AV_CPU_FLAG_SSE)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;
#endif /* HAVE_YASM */
}
| false | FFmpeg | 6369ba3c9cc74becfaad2a8882dff3dd3e7ae3c0 | av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
if (cpu_flags & AV_CPU_FLAG_3DNOW)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_3dnow;
#endif
if (cpu_flags & AV_CPU_FLAG_SSE)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(VorbisDSPContext *dsp)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
if (cpu_flags & AV_CPU_FLAG_3DNOW)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_3dnow;
#endif
if (cpu_flags & AV_CPU_FLAG_SSE)
dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;
#endif
}
| [
"av_cold void FUNC_0(VorbisDSPContext *dsp)\n{",
"#if HAVE_YASM\nint cpu_flags = av_get_cpu_flags();",
"#if ARCH_X86_32\nif (cpu_flags & AV_CPU_FLAG_3DNOW)\ndsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_3dnow;",
"#endif\nif (cpu_flags & AV_CPU_FLAG_SSE)\ndsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;",
"#endif\n}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11,
13,
15
],
[
17,
19,
21
],
[
23,
25
]
] |
25,240 | static void output_packet(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
{
int ret = 0;
/* apply the output bitstream filters, if any */
if (ost->nb_bitstream_filters) {
int idx;
ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt);
if (ret < 0)
goto finish;
idx = 1;
while (idx) {
/* get a packet from the previous filter up the chain */
ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt);
if (ret == AVERROR(EAGAIN)) {
ret = 0;
idx--;
continue;
} else if (ret < 0)
goto finish;
/* send it to the next filter down the chain or to the muxer */
if (idx < ost->nb_bitstream_filters) {
ret = av_bsf_send_packet(ost->bsf_ctx[idx], pkt);
if (ret < 0)
goto finish;
idx++;
} else
write_packet(s, pkt, ost);
}
} else
write_packet(s, pkt, ost);
finish:
if (ret < 0 && ret != AVERROR_EOF) {
av_log(NULL, AV_LOG_FATAL, "Error applying bitstream filters to an output "
"packet for stream #%d:%d.\n", ost->file_index, ost->index);
exit_program(1);
}
}
| false | FFmpeg | 398f015f077c6a2406deffd9e37ff34b9c7bb3bc | static void output_packet(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
{
int ret = 0;
if (ost->nb_bitstream_filters) {
int idx;
ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt);
if (ret < 0)
goto finish;
idx = 1;
while (idx) {
ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt);
if (ret == AVERROR(EAGAIN)) {
ret = 0;
idx--;
continue;
} else if (ret < 0)
goto finish;
if (idx < ost->nb_bitstream_filters) {
ret = av_bsf_send_packet(ost->bsf_ctx[idx], pkt);
if (ret < 0)
goto finish;
idx++;
} else
write_packet(s, pkt, ost);
}
} else
write_packet(s, pkt, ost);
finish:
if (ret < 0 && ret != AVERROR_EOF) {
av_log(NULL, AV_LOG_FATAL, "Error applying bitstream filters to an output "
"packet for stream #%d:%d.\n", ost->file_index, ost->index);
exit_program(1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, OutputStream *VAR_2)
{
int VAR_3 = 0;
if (VAR_2->nb_bitstream_filters) {
int VAR_4;
VAR_3 = av_bsf_send_packet(VAR_2->bsf_ctx[0], VAR_1);
if (VAR_3 < 0)
goto finish;
VAR_4 = 1;
while (VAR_4) {
VAR_3 = av_bsf_receive_packet(VAR_2->bsf_ctx[VAR_4 - 1], VAR_1);
if (VAR_3 == AVERROR(EAGAIN)) {
VAR_3 = 0;
VAR_4--;
continue;
} else if (VAR_3 < 0)
goto finish;
if (VAR_4 < VAR_2->nb_bitstream_filters) {
VAR_3 = av_bsf_send_packet(VAR_2->bsf_ctx[VAR_4], VAR_1);
if (VAR_3 < 0)
goto finish;
VAR_4++;
} else
write_packet(VAR_0, VAR_1, VAR_2);
}
} else
write_packet(VAR_0, VAR_1, VAR_2);
finish:
if (VAR_3 < 0 && VAR_3 != AVERROR_EOF) {
av_log(NULL, AV_LOG_FATAL, "Error applying bitstream filters to an output "
"packet for stream #%d:%d.\n", VAR_2->file_index, VAR_2->index);
exit_program(1);
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, OutputStream *VAR_2)\n{",
"int VAR_3 = 0;",
"if (VAR_2->nb_bitstream_filters) {",
"int VAR_4;",
"VAR_3 = av_bsf_send_packet(VAR_2->bsf_ctx[0], VAR_1);",
"if (VAR_3 < 0)\ngoto finish;",
"VAR_4 = 1;",
"while (VAR_4) {",
"VAR_3 = av_bsf_receive_packet(VAR_2->bsf_ctx[VAR_4 - 1], VAR_1);",
"if (VAR_3 == AVERROR(EAGAIN)) {",
"VAR_3 = 0;",
"VAR_4--;",
"continue;",
"} else if (VAR_3 < 0)",
"goto finish;",
"if (VAR_4 < VAR_2->nb_bitstream_filters) {",
"VAR_3 = av_bsf_send_packet(VAR_2->bsf_ctx[VAR_4], VAR_1);",
"if (VAR_3 < 0)\ngoto finish;",
"VAR_4++;",
"} else",
"write_packet(VAR_0, VAR_1, VAR_2);",
"}",
"} else",
"write_packet(VAR_0, VAR_1, VAR_2);",
"finish:\nif (VAR_3 < 0 && VAR_3 != AVERROR_EOF) {",
"av_log(NULL, AV_LOG_FATAL, \"Error applying bitstream filters to an output \"\n\"packet for stream #%d:%d.\\n\", VAR_2->file_index, VAR_2->index);",
"exit_program(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
] |
25,241 | static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type)
{
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = sl->mb_xy, mb_y = sl->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, sl->ref_list[1][0].parent,
sl->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = sl->mb_x +
((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0;
} else {
mb_y += sl->col_fieldoff;
mb_xy += h->mb_stride * sl->col_fieldoff; // non-zero for FL -> FL & differ parity
}
goto single_col;
} else { // AFL/AFR/FR/FL -> AFR/FR
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = sl->mb_y & ~1;
mb_xy = sl->mb_x + (sl->mb_y & ~1) * h->mb_stride;
mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) !=
IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
}
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) &&
(mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) &&
!is_b8x8) {
*mb_type |= MB_TYPE_16x8 | MB_TYPE_L0L1 |
MB_TYPE_DIRECT2; /* B_16x8 */
} else {
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
} else { // AFR/FR -> AFR/FR
single_col:
mb_type_col[0] =
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
*mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2; /* B_16x16 */
} else if (!is_b8x8 &&
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 |
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!h->sps.direct_8x8_inference_flag) {
/* FIXME: save sub mb types from previous frames (or derive
* from MVs) so we know exactly what block size to use */
sub_mb_type = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2; /* B_SUB_4x4 */
}
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
}
}
await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy];
if (!b8_stride) {
if (sl->mb_y & 1) {
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2 * b4_stride;
l1mv1 += 2 * b4_stride;
}
}
{
const int *map_col_to_list0[2] = { sl->map_col_to_list0[0],
sl->map_col_to_list0[1] };
const int *dist_scale_factor = sl->dist_scale_factor;
int ref_offset;
if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) {
map_col_to_list0[0] = sl->map_col_to_list0_field[sl->mb_y & 1][0];
map_col_to_list0[1] = sl->map_col_to_list0_field[sl->mb_y & 1][1];
dist_scale_factor = sl->dist_scale_factor_field[sl->mb_y & 1];
}
ref_offset = (sl->ref_list[1][0].parent->mbaff << 4) & (mb_type_col[0] >> 3);
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int y_shift = 2 * !IS_INTERLACED(*mb_type);
assert(h->sps.direct_8x8_inference_flag);
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[y8])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8 * b8_stride];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
{
const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
int my_col = (mv_col[1] << y_shift) / 2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - my_col), 4);
}
}
return;
}
/* one-to-one mv scaling */
if (IS_16X16(*mb_type)) {
int ref, mv0, mv1;
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
ref = mv0 = mv1 = 0;
} else {
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref = ref0;
mv0 = pack16to32(mv_l0[0], mv_l0[1]);
mv1 = pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
}
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
} else {
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
assert(b8_stride == 2);
ref0 = l1ref0[i8];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
if (IS_SUB_8X8(sub_mb_type)) {
const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - mv_col[1]), 4);
} else {
for (i4 = 0; i4 < 4; i4++) {
const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
(y8 * 2 + (i4 >> 1)) * b4_stride];
int16_t *mv_l0 = sl->mv_cache[0][scan8[i8 * 4 + i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(sl->mv_cache[1][scan8[i8 * 4 + i4]],
pack16to32(mv_l0[0] - mv_col[0],
mv_l0[1] - mv_col[1]));
}
}
}
}
}
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext *sl,
int *mb_type)
{
int b8_stride = 2;
int b4_stride = h->b_stride;
int mb_xy = sl->mb_xy, mb_y = sl->mb_y;
int mb_type_col[2];
const int16_t (*l1mv0)[2], (*l1mv1)[2];
const int8_t *l1ref0, *l1ref1;
const int is_b8x8 = IS_8X8(*mb_type);
unsigned int sub_mb_type;
int i8, i4;
assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, sl->ref_list[1][0].parent,
sl->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) {
if (!IS_INTERLACED(*mb_type)) {
mb_y = (sl->mb_y & ~1) + sl->col_parity;
mb_xy = sl->mb_x +
((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride;
b8_stride = 0;
} else {
mb_y += sl->col_fieldoff;
mb_xy += h->mb_stride * sl->col_fieldoff;
}
goto single_col;
} else {
if (IS_INTERLACED(*mb_type)) {
mb_y = sl->mb_y & ~1;
mb_xy = sl->mb_x + (sl->mb_y & ~1) * h->mb_stride;
mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy];
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) !=
IS_INTERLACED(mb_type_col[1])) {
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
}
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) &&
(mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) &&
!is_b8x8) {
*mb_type |= MB_TYPE_16x8 | MB_TYPE_L0L1 |
MB_TYPE_DIRECT2;
} else {
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
} else {
single_col:
mb_type_col[0] =
mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
*mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
} else if (!is_b8x8 &&
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 |
(mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!h->sps.direct_8x8_inference_flag) {
sub_mb_type = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
}
*mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
}
}
await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy];
l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy];
if (!b8_stride) {
if (sl->mb_y & 1) {
l1ref0 += 2;
l1ref1 += 2;
l1mv0 += 2 * b4_stride;
l1mv1 += 2 * b4_stride;
}
}
{
const int *map_col_to_list0[2] = { sl->map_col_to_list0[0],
sl->map_col_to_list0[1] };
const int *dist_scale_factor = sl->dist_scale_factor;
int ref_offset;
if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) {
map_col_to_list0[0] = sl->map_col_to_list0_field[sl->mb_y & 1][0];
map_col_to_list0[1] = sl->map_col_to_list0_field[sl->mb_y & 1][1];
dist_scale_factor = sl->dist_scale_factor_field[sl->mb_y & 1];
}
ref_offset = (sl->ref_list[1][0].parent->mbaff << 4) & (mb_type_col[0] >> 3);
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int y_shift = 2 * !IS_INTERLACED(*mb_type);
assert(h->sps.direct_8x8_inference_flag);
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[y8])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
ref0 = l1ref0[x8 + y8 * b8_stride];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
{
const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
int my_col = (mv_col[1] << y_shift) / 2;
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * my_col + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - my_col), 4);
}
}
return;
}
if (IS_16X16(*mb_type)) {
int ref, mv0, mv1;
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
ref = mv0 = mv1 = 0;
} else {
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
: map_col_to_list0[1][l1ref1[0] + ref_offset];
const int scale = dist_scale_factor[ref0];
const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
ref = ref0;
mv0 = pack16to32(mv_l0[0], mv_l0[1]);
mv1 = pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
}
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
} else {
for (i8 = 0; i8 < 4; i8++) {
const int x8 = i8 & 1;
const int y8 = i8 >> 1;
int ref0, scale;
const int16_t (*l1mv)[2] = l1mv0;
if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8]))
continue;
sl->sub_mb_type[i8] = sub_mb_type;
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(mb_type_col[0])) {
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4);
continue;
}
assert(b8_stride == 2);
ref0 = l1ref0[i8];
if (ref0 >= 0)
ref0 = map_col_to_list0[0][ref0 + ref_offset];
else {
ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
l1mv = l1mv1;
}
scale = dist_scale_factor[ref0];
fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8,
ref0, 1);
if (IS_SUB_8X8(sub_mb_type)) {
const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
int mx = (scale * mv_col[0] + 128) >> 8;
int my = (scale * mv_col[1] + 128) >> 8;
fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx, my), 4);
fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8,
pack16to32(mx - mv_col[0], my - mv_col[1]), 4);
} else {
for (i4 = 0; i4 < 4; i4++) {
const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
(y8 * 2 + (i4 >> 1)) * b4_stride];
int16_t *mv_l0 = sl->mv_cache[0][scan8[i8 * 4 + i4]];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
AV_WN32A(sl->mv_cache[1][scan8[i8 * 4 + i4]],
pack16to32(mv_l0[0] - mv_col[0],
mv_l0[1] - mv_col[1]));
}
}
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const H264Context *const VAR_0, H264SliceContext *VAR_1,
int *VAR_2)
{
int VAR_3 = 2;
int VAR_4 = VAR_0->b_stride;
int VAR_5 = VAR_1->VAR_5, VAR_6 = VAR_1->VAR_6;
int VAR_7[2];
const FUNC_2 (*l1mv0)[2], (*l1mv1)[2];
const int8_t *VAR_8, *l1ref1;
const int VAR_9 = IS_8X8(*VAR_2);
unsigned int VAR_10;
int VAR_11, VAR_12;
assert(VAR_1->ref_list[1][0].reference & 3);
await_reference_mb_row(VAR_0, VAR_1->ref_list[1][0].parent,
VAR_1->VAR_6 + !!IS_INTERLACED(*VAR_2));
if (IS_INTERLACED(VAR_1->ref_list[1][0].parent->VAR_2[VAR_5])) {
if (!IS_INTERLACED(*VAR_2)) {
VAR_6 = (VAR_1->VAR_6 & ~1) + VAR_1->col_parity;
VAR_5 = VAR_1->mb_x +
((VAR_1->VAR_6 & ~1) + VAR_1->col_parity) * VAR_0->mb_stride;
VAR_3 = 0;
} else {
VAR_6 += VAR_1->col_fieldoff;
VAR_5 += VAR_0->mb_stride * VAR_1->col_fieldoff;
}
goto single_col;
} else {
if (IS_INTERLACED(*VAR_2)) {
VAR_6 = VAR_1->VAR_6 & ~1;
VAR_5 = VAR_1->mb_x + (VAR_1->VAR_6 & ~1) * VAR_0->mb_stride;
VAR_7[0] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5];
VAR_7[1] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5 + VAR_0->mb_stride];
VAR_3 = 2 + 4 * VAR_0->mb_stride;
VAR_4 *= 6;
if (IS_INTERLACED(VAR_7[0]) !=
IS_INTERLACED(VAR_7[1])) {
VAR_7[0] &= ~MB_TYPE_INTERLACED;
VAR_7[1] &= ~MB_TYPE_INTERLACED;
}
VAR_10 = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if ((VAR_7[0] & MB_TYPE_16x16_OR_INTRA) &&
(VAR_7[1] & MB_TYPE_16x16_OR_INTRA) &&
!VAR_9) {
*VAR_2 |= MB_TYPE_16x8 | MB_TYPE_L0L1 |
MB_TYPE_DIRECT2;
} else {
*VAR_2 |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
} else {
single_col:
VAR_7[0] =
VAR_7[1] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5];
VAR_10 = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
if (!VAR_9 && (VAR_7[0] & MB_TYPE_16x16_OR_INTRA)) {
*VAR_2 |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
} else if (!VAR_9 &&
(VAR_7[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {
*VAR_2 |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 |
(VAR_7[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));
} else {
if (!VAR_0->sps.direct_8x8_inference_flag) {
VAR_10 = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2;
}
*VAR_2 |= MB_TYPE_8x8 | MB_TYPE_L0L1;
}
}
}
await_reference_mb_row(VAR_0, VAR_1->ref_list[1][0].parent, VAR_6);
l1mv0 = &VAR_1->ref_list[1][0].parent->motion_val[0][VAR_0->mb2b_xy[VAR_5]];
l1mv1 = &VAR_1->ref_list[1][0].parent->motion_val[1][VAR_0->mb2b_xy[VAR_5]];
VAR_8 = &VAR_1->ref_list[1][0].parent->ref_index[0][4 * VAR_5];
l1ref1 = &VAR_1->ref_list[1][0].parent->ref_index[1][4 * VAR_5];
if (!VAR_3) {
if (VAR_1->VAR_6 & 1) {
VAR_8 += 2;
l1ref1 += 2;
l1mv0 += 2 * VAR_4;
l1mv1 += 2 * VAR_4;
}
}
{
const int *VAR_13[2] = { VAR_1->VAR_13[0],
VAR_1->VAR_13[1] };
const int *VAR_14 = VAR_1->VAR_14;
int VAR_15;
if (FRAME_MBAFF(VAR_0) && IS_INTERLACED(*VAR_2)) {
VAR_13[0] = VAR_1->map_col_to_list0_field[VAR_1->VAR_6 & 1][0];
VAR_13[1] = VAR_1->map_col_to_list0_field[VAR_1->VAR_6 & 1][1];
VAR_14 = VAR_1->dist_scale_factor_field[VAR_1->VAR_6 & 1];
}
VAR_15 = (VAR_1->ref_list[1][0].parent->mbaff << 4) & (VAR_7[0] >> 3);
if (IS_INTERLACED(*VAR_2) != IS_INTERLACED(VAR_7[0])) {
int VAR_16 = 2 * !IS_INTERLACED(*VAR_2);
assert(VAR_0->sps.direct_8x8_inference_flag);
for (VAR_11 = 0; VAR_11 < 4; VAR_11++) {
const int VAR_29 = VAR_11 & 1;
const int VAR_29 = VAR_11 >> 1;
int VAR_29, VAR_29;
const FUNC_2 (*l1mv)[2] = l1mv0;
if (VAR_9 && !IS_DIRECT(VAR_1->VAR_10[VAR_11]))
continue;
VAR_1->VAR_10[VAR_11] = VAR_10;
fill_rectangle(&VAR_1->ref_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(VAR_7[VAR_29])) {
fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);
continue;
}
VAR_29 = VAR_8[VAR_29 + VAR_29 * VAR_3];
if (VAR_29 >= 0)
VAR_29 = VAR_13[0][VAR_29 + VAR_15];
else {
VAR_29 = VAR_13[1][l1ref1[VAR_29 + VAR_29 * VAR_3] +
VAR_15];
l1mv = l1mv1;
}
VAR_29 = VAR_14[VAR_29];
fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,
VAR_29, 1);
{
const FUNC_2 *VAR_29 = l1mv[VAR_29 * 3 + VAR_29 * VAR_4];
int VAR_22 = (VAR_29[1] << VAR_16) / 2;
int VAR_29 = (VAR_29 * VAR_29[0] + 128) >> 8;
int VAR_29 = (VAR_29 * VAR_22 + 128) >> 8;
fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,
pack16to32(VAR_29, VAR_29), 4);
fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8,
pack16to32(VAR_29 - VAR_29[0], VAR_29 - VAR_22), 4);
}
}
return;
}
if (IS_16X16(*VAR_2)) {
int VAR_25, VAR_26, VAR_27;
fill_rectangle(&VAR_1->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if (IS_INTRA(VAR_7[0])) {
VAR_25 = VAR_26 = VAR_27 = 0;
} else {
const int VAR_29 = VAR_8[0] >= 0 ? VAR_13[0][VAR_8[0] + VAR_15]
: VAR_13[1][l1ref1[0] + VAR_15];
const int VAR_29 = VAR_14[VAR_29];
const FUNC_2 *VAR_29 = VAR_8[0] >= 0 ? l1mv0[0] : l1mv1[0];
int VAR_28[2];
VAR_28[0] = (VAR_29 * VAR_29[0] + 128) >> 8;
VAR_28[1] = (VAR_29 * VAR_29[1] + 128) >> 8;
VAR_25 = VAR_29;
VAR_26 = pack16to32(VAR_28[0], VAR_28[1]);
VAR_27 = pack16to32(VAR_28[0] - VAR_29[0], VAR_28[1] - VAR_29[1]);
}
fill_rectangle(&VAR_1->ref_cache[0][scan8[0]], 4, 4, 8, VAR_25, 1);
fill_rectangle(&VAR_1->mv_cache[0][scan8[0]], 4, 4, 8, VAR_26, 4);
fill_rectangle(&VAR_1->mv_cache[1][scan8[0]], 4, 4, 8, VAR_27, 4);
} else {
for (VAR_11 = 0; VAR_11 < 4; VAR_11++) {
const int VAR_29 = VAR_11 & 1;
const int VAR_29 = VAR_11 >> 1;
int VAR_29, VAR_29;
const FUNC_2 (*l1mv)[2] = l1mv0;
if (VAR_9 && !IS_DIRECT(VAR_1->VAR_10[VAR_11]))
continue;
VAR_1->VAR_10[VAR_11] = VAR_10;
fill_rectangle(&VAR_1->ref_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);
if (IS_INTRA(VAR_7[0])) {
fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);
fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);
fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);
continue;
}
assert(VAR_3 == 2);
VAR_29 = VAR_8[VAR_11];
if (VAR_29 >= 0)
VAR_29 = VAR_13[0][VAR_29 + VAR_15];
else {
VAR_29 = VAR_13[1][l1ref1[VAR_11] + VAR_15];
l1mv = l1mv1;
}
VAR_29 = VAR_14[VAR_29];
fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,
VAR_29, 1);
if (IS_SUB_8X8(VAR_10)) {
const FUNC_2 *VAR_29 = l1mv[VAR_29 * 3 + VAR_29 * 3 * VAR_4];
int VAR_29 = (VAR_29 * VAR_29[0] + 128) >> 8;
int VAR_29 = (VAR_29 * VAR_29[1] + 128) >> 8;
fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,
pack16to32(VAR_29, VAR_29), 4);
fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8,
pack16to32(VAR_29 - VAR_29[0], VAR_29 - VAR_29[1]), 4);
} else {
for (VAR_12 = 0; VAR_12 < 4; VAR_12++) {
const FUNC_2 *VAR_29 = l1mv[VAR_29 * 2 + (VAR_12 & 1) +
(VAR_29 * 2 + (VAR_12 >> 1)) * VAR_4];
FUNC_2 *VAR_28 = VAR_1->mv_cache[0][scan8[VAR_11 * 4 + VAR_12]];
VAR_28[0] = (VAR_29 * VAR_29[0] + 128) >> 8;
VAR_28[1] = (VAR_29 * VAR_29[1] + 128) >> 8;
AV_WN32A(VAR_1->mv_cache[1][scan8[VAR_11 * 4 + VAR_12]],
pack16to32(VAR_28[0] - VAR_29[0],
VAR_28[1] - VAR_29[1]));
}
}
}
}
}
}
| [
"static void FUNC_0(const H264Context *const VAR_0, H264SliceContext *VAR_1,\nint *VAR_2)\n{",
"int VAR_3 = 2;",
"int VAR_4 = VAR_0->b_stride;",
"int VAR_5 = VAR_1->VAR_5, VAR_6 = VAR_1->VAR_6;",
"int VAR_7[2];",
"const FUNC_2 (*l1mv0)[2], (*l1mv1)[2];",
"const int8_t *VAR_8, *l1ref1;",
"const int VAR_9 = IS_8X8(*VAR_2);",
"unsigned int VAR_10;",
"int VAR_11, VAR_12;",
"assert(VAR_1->ref_list[1][0].reference & 3);",
"await_reference_mb_row(VAR_0, VAR_1->ref_list[1][0].parent,\nVAR_1->VAR_6 + !!IS_INTERLACED(*VAR_2));",
"if (IS_INTERLACED(VAR_1->ref_list[1][0].parent->VAR_2[VAR_5])) {",
"if (!IS_INTERLACED(*VAR_2)) {",
"VAR_6 = (VAR_1->VAR_6 & ~1) + VAR_1->col_parity;",
"VAR_5 = VAR_1->mb_x +\n((VAR_1->VAR_6 & ~1) + VAR_1->col_parity) * VAR_0->mb_stride;",
"VAR_3 = 0;",
"} else {",
"VAR_6 += VAR_1->col_fieldoff;",
"VAR_5 += VAR_0->mb_stride * VAR_1->col_fieldoff;",
"}",
"goto single_col;",
"} else {",
"if (IS_INTERLACED(*VAR_2)) {",
"VAR_6 = VAR_1->VAR_6 & ~1;",
"VAR_5 = VAR_1->mb_x + (VAR_1->VAR_6 & ~1) * VAR_0->mb_stride;",
"VAR_7[0] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5];",
"VAR_7[1] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5 + VAR_0->mb_stride];",
"VAR_3 = 2 + 4 * VAR_0->mb_stride;",
"VAR_4 *= 6;",
"if (IS_INTERLACED(VAR_7[0]) !=\nIS_INTERLACED(VAR_7[1])) {",
"VAR_7[0] &= ~MB_TYPE_INTERLACED;",
"VAR_7[1] &= ~MB_TYPE_INTERLACED;",
"}",
"VAR_10 = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |\nMB_TYPE_DIRECT2;",
"if ((VAR_7[0] & MB_TYPE_16x16_OR_INTRA) &&\n(VAR_7[1] & MB_TYPE_16x16_OR_INTRA) &&\n!VAR_9) {",
"*VAR_2 |= MB_TYPE_16x8 | MB_TYPE_L0L1 |\nMB_TYPE_DIRECT2;",
"} else {",
"*VAR_2 |= MB_TYPE_8x8 | MB_TYPE_L0L1;",
"}",
"} else {",
"single_col:\nVAR_7[0] =\nVAR_7[1] = VAR_1->ref_list[1][0].parent->VAR_2[VAR_5];",
"VAR_10 = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |\nMB_TYPE_DIRECT2;",
"if (!VAR_9 && (VAR_7[0] & MB_TYPE_16x16_OR_INTRA)) {",
"*VAR_2 |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |\nMB_TYPE_DIRECT2;",
"} else if (!VAR_9 &&",
"(VAR_7[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) {",
"*VAR_2 |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 |\n(VAR_7[0] & (MB_TYPE_16x8 | MB_TYPE_8x16));",
"} else {",
"if (!VAR_0->sps.direct_8x8_inference_flag) {",
"VAR_10 = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |\nMB_TYPE_DIRECT2;",
"}",
"*VAR_2 |= MB_TYPE_8x8 | MB_TYPE_L0L1;",
"}",
"}",
"}",
"await_reference_mb_row(VAR_0, VAR_1->ref_list[1][0].parent, VAR_6);",
"l1mv0 = &VAR_1->ref_list[1][0].parent->motion_val[0][VAR_0->mb2b_xy[VAR_5]];",
"l1mv1 = &VAR_1->ref_list[1][0].parent->motion_val[1][VAR_0->mb2b_xy[VAR_5]];",
"VAR_8 = &VAR_1->ref_list[1][0].parent->ref_index[0][4 * VAR_5];",
"l1ref1 = &VAR_1->ref_list[1][0].parent->ref_index[1][4 * VAR_5];",
"if (!VAR_3) {",
"if (VAR_1->VAR_6 & 1) {",
"VAR_8 += 2;",
"l1ref1 += 2;",
"l1mv0 += 2 * VAR_4;",
"l1mv1 += 2 * VAR_4;",
"}",
"}",
"{",
"const int *VAR_13[2] = { VAR_1->VAR_13[0],",
"VAR_1->VAR_13[1] };",
"const int *VAR_14 = VAR_1->VAR_14;",
"int VAR_15;",
"if (FRAME_MBAFF(VAR_0) && IS_INTERLACED(*VAR_2)) {",
"VAR_13[0] = VAR_1->map_col_to_list0_field[VAR_1->VAR_6 & 1][0];",
"VAR_13[1] = VAR_1->map_col_to_list0_field[VAR_1->VAR_6 & 1][1];",
"VAR_14 = VAR_1->dist_scale_factor_field[VAR_1->VAR_6 & 1];",
"}",
"VAR_15 = (VAR_1->ref_list[1][0].parent->mbaff << 4) & (VAR_7[0] >> 3);",
"if (IS_INTERLACED(*VAR_2) != IS_INTERLACED(VAR_7[0])) {",
"int VAR_16 = 2 * !IS_INTERLACED(*VAR_2);",
"assert(VAR_0->sps.direct_8x8_inference_flag);",
"for (VAR_11 = 0; VAR_11 < 4; VAR_11++) {",
"const int VAR_29 = VAR_11 & 1;",
"const int VAR_29 = VAR_11 >> 1;",
"int VAR_29, VAR_29;",
"const FUNC_2 (*l1mv)[2] = l1mv0;",
"if (VAR_9 && !IS_DIRECT(VAR_1->VAR_10[VAR_11]))\ncontinue;",
"VAR_1->VAR_10[VAR_11] = VAR_10;",
"fill_rectangle(&VAR_1->ref_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);",
"if (IS_INTRA(VAR_7[VAR_29])) {",
"fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);",
"fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);",
"fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);",
"continue;",
"}",
"VAR_29 = VAR_8[VAR_29 + VAR_29 * VAR_3];",
"if (VAR_29 >= 0)\nVAR_29 = VAR_13[0][VAR_29 + VAR_15];",
"else {",
"VAR_29 = VAR_13[1][l1ref1[VAR_29 + VAR_29 * VAR_3] +\nVAR_15];",
"l1mv = l1mv1;",
"}",
"VAR_29 = VAR_14[VAR_29];",
"fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,\nVAR_29, 1);",
"{",
"const FUNC_2 *VAR_29 = l1mv[VAR_29 * 3 + VAR_29 * VAR_4];",
"int VAR_22 = (VAR_29[1] << VAR_16) / 2;",
"int VAR_29 = (VAR_29 * VAR_29[0] + 128) >> 8;",
"int VAR_29 = (VAR_29 * VAR_22 + 128) >> 8;",
"fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,\npack16to32(VAR_29, VAR_29), 4);",
"fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8,\npack16to32(VAR_29 - VAR_29[0], VAR_29 - VAR_22), 4);",
"}",
"}",
"return;",
"}",
"if (IS_16X16(*VAR_2)) {",
"int VAR_25, VAR_26, VAR_27;",
"fill_rectangle(&VAR_1->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);",
"if (IS_INTRA(VAR_7[0])) {",
"VAR_25 = VAR_26 = VAR_27 = 0;",
"} else {",
"const int VAR_29 = VAR_8[0] >= 0 ? VAR_13[0][VAR_8[0] + VAR_15]\n: VAR_13[1][l1ref1[0] + VAR_15];",
"const int VAR_29 = VAR_14[VAR_29];",
"const FUNC_2 *VAR_29 = VAR_8[0] >= 0 ? l1mv0[0] : l1mv1[0];",
"int VAR_28[2];",
"VAR_28[0] = (VAR_29 * VAR_29[0] + 128) >> 8;",
"VAR_28[1] = (VAR_29 * VAR_29[1] + 128) >> 8;",
"VAR_25 = VAR_29;",
"VAR_26 = pack16to32(VAR_28[0], VAR_28[1]);",
"VAR_27 = pack16to32(VAR_28[0] - VAR_29[0], VAR_28[1] - VAR_29[1]);",
"}",
"fill_rectangle(&VAR_1->ref_cache[0][scan8[0]], 4, 4, 8, VAR_25, 1);",
"fill_rectangle(&VAR_1->mv_cache[0][scan8[0]], 4, 4, 8, VAR_26, 4);",
"fill_rectangle(&VAR_1->mv_cache[1][scan8[0]], 4, 4, 8, VAR_27, 4);",
"} else {",
"for (VAR_11 = 0; VAR_11 < 4; VAR_11++) {",
"const int VAR_29 = VAR_11 & 1;",
"const int VAR_29 = VAR_11 >> 1;",
"int VAR_29, VAR_29;",
"const FUNC_2 (*l1mv)[2] = l1mv0;",
"if (VAR_9 && !IS_DIRECT(VAR_1->VAR_10[VAR_11]))\ncontinue;",
"VAR_1->VAR_10[VAR_11] = VAR_10;",
"fill_rectangle(&VAR_1->ref_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);",
"if (IS_INTRA(VAR_7[0])) {",
"fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 1);",
"fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);",
"fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8, 0, 4);",
"continue;",
"}",
"assert(VAR_3 == 2);",
"VAR_29 = VAR_8[VAR_11];",
"if (VAR_29 >= 0)\nVAR_29 = VAR_13[0][VAR_29 + VAR_15];",
"else {",
"VAR_29 = VAR_13[1][l1ref1[VAR_11] + VAR_15];",
"l1mv = l1mv1;",
"}",
"VAR_29 = VAR_14[VAR_29];",
"fill_rectangle(&VAR_1->ref_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,\nVAR_29, 1);",
"if (IS_SUB_8X8(VAR_10)) {",
"const FUNC_2 *VAR_29 = l1mv[VAR_29 * 3 + VAR_29 * 3 * VAR_4];",
"int VAR_29 = (VAR_29 * VAR_29[0] + 128) >> 8;",
"int VAR_29 = (VAR_29 * VAR_29[1] + 128) >> 8;",
"fill_rectangle(&VAR_1->mv_cache[0][scan8[VAR_11 * 4]], 2, 2, 8,\npack16to32(VAR_29, VAR_29), 4);",
"fill_rectangle(&VAR_1->mv_cache[1][scan8[VAR_11 * 4]], 2, 2, 8,\npack16to32(VAR_29 - VAR_29[0], VAR_29 - VAR_29[1]), 4);",
"} else {",
"for (VAR_12 = 0; VAR_12 < 4; VAR_12++) {",
"const FUNC_2 *VAR_29 = l1mv[VAR_29 * 2 + (VAR_12 & 1) +\n(VAR_29 * 2 + (VAR_12 >> 1)) * VAR_4];",
"FUNC_2 *VAR_28 = VAR_1->mv_cache[0][scan8[VAR_11 * 4 + VAR_12]];",
"VAR_28[0] = (VAR_29 * VAR_29[0] + 128) >> 8;",
"VAR_28[1] = (VAR_29 * VAR_29[1] + 128) >> 8;",
"AV_WN32A(VAR_1->mv_cache[1][scan8[VAR_11 * 4 + VAR_12]],\npack16to32(VAR_28[0] - VAR_29[0],\nVAR_28[1] - VAR_29[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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
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
],
[
87,
89
],
[
93,
95,
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113,
115
],
[
119,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
317
],
[
319
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395
],
[
397
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
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
]
] |
25,242 | static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
{
const VC1Context *v = avctx->priv_data;
const MpegEncContext *s = &v->s;
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferVC1 *pic_param;
vactx->slice_param_size = sizeof(VASliceParameterBufferVC1);
/* Fill in VAPictureParameterBufferVC1 */
pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1));
if (!pic_param)
return -1;
pic_param->forward_reference_picture = VA_INVALID_ID;
pic_param->backward_reference_picture = VA_INVALID_ID;
pic_param->inloop_decoded_picture = VA_INVALID_ID;
pic_param->sequence_fields.value = 0; /* reset all bits */
pic_param->sequence_fields.bits.pulldown = v->broadcast;
pic_param->sequence_fields.bits.interlace = v->interlace;
pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag;
pic_param->sequence_fields.bits.finterpflag = v->finterpflag;
pic_param->sequence_fields.bits.psf = v->psf;
pic_param->sequence_fields.bits.multires = v->multires;
pic_param->sequence_fields.bits.overlap = v->overlap;
pic_param->sequence_fields.bits.syncmarker = v->resync_marker;
pic_param->sequence_fields.bits.rangered = v->rangered;
pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames;
#if VA_CHECK_VERSION(0,32,0)
pic_param->sequence_fields.bits.profile = v->profile;
#endif
pic_param->coded_width = s->avctx->coded_width;
pic_param->coded_height = s->avctx->coded_height;
pic_param->entrypoint_fields.value = 0; /* reset all bits */
pic_param->entrypoint_fields.bits.broken_link = v->broken_link;
pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry;
pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag;
pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter;
pic_param->conditional_overlap_flag = v->condover;
pic_param->fast_uvmc_flag = v->fastuvmc;
pic_param->range_mapping_fields.value = 0; /* reset all bits */
pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag;
pic_param->range_mapping_fields.bits.luma = v->range_mapy;
pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag;
pic_param->range_mapping_fields.bits.chroma = v->range_mapuv;
pic_param->b_picture_fraction = v->bfraction_lut_index;
pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;
pic_param->mb_mode_table = 0; /* XXX: interlaced frame */
pic_param->range_reduction_frame = v->rangeredfrm;
pic_param->rounding_control = v->rnd;
pic_param->post_processing = v->postproc;
pic_param->picture_resolution_index = v->respic;
pic_param->luma_scale = v->lumscale;
pic_param->luma_shift = v->lumshift;
pic_param->picture_fields.value = 0; /* reset all bits */
pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v);
pic_param->picture_fields.bits.frame_coding_mode = v->fcm;
pic_param->picture_fields.bits.top_field_first = v->tff;
pic_param->picture_fields.bits.is_first_field = v->fcm == 0; /* XXX: interlaced frame */
pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP;
pic_param->raw_coding.value = 0; /* reset all bits */
pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw;
pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw;
pic_param->raw_coding.flags.skip_mb = v->skip_is_raw;
pic_param->raw_coding.flags.field_tx = 0; /* XXX: interlaced frame */
pic_param->raw_coding.flags.forward_mb = 0; /* XXX: interlaced frame */
pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw;
pic_param->raw_coding.flags.overflags = v->overflg_is_raw;
pic_param->bitplane_present.value = 0; /* reset all bits */
pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v);
pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v);
pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v);
pic_param->bitplane_present.flags.bp_field_tx = 0; /* XXX: interlaced frame */
pic_param->bitplane_present.flags.bp_forward_mb = 0; /* XXX: interlaced frame */
pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v);
pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v);
pic_param->reference_fields.value = 0; /* reset all bits */
pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag;
pic_param->reference_fields.bits.reference_distance = 0; /* XXX: interlaced frame */
pic_param->reference_fields.bits.num_reference_pictures = 0; /* XXX: interlaced frame */
pic_param->reference_fields.bits.reference_field_pic_indicator = 0; /* XXX: interlaced frame */
pic_param->mv_fields.value = 0; /* reset all bits */
pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v);
pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v);
pic_param->mv_fields.bits.mv_table = s->mv_table_index;
pic_param->mv_fields.bits.two_mv_block_pattern_table = 0; /* XXX: interlaced frame */
pic_param->mv_fields.bits.four_mv_switch = 0; /* XXX: interlaced frame */
pic_param->mv_fields.bits.four_mv_block_pattern_table = 0; /* XXX: interlaced frame */
pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv;
pic_param->mv_fields.bits.extended_mv_range = v->mvrange;
pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv;
pic_param->mv_fields.bits.extended_dmv_range = 0; /* XXX: interlaced frame */
pic_param->pic_quantizer_fields.value = 0; /* reset all bits */
pic_param->pic_quantizer_fields.bits.dquant = v->dquant;
pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode;
pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer;
pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm;
pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile;
pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel;
pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq;
pic_param->transform_fields.value = 0; /* reset all bits */
pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf;
pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v);
pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index;
pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index;
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f);
// fall-through
case AV_PICTURE_TYPE_P:
pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f);
break;
}
if (pic_param->bitplane_present.value) {
uint8_t *bitplane;
const uint8_t *ff_bp[3];
int x, y, n;
switch (s->pict_type) {
case AV_PICTURE_TYPE_P:
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL;
break;
case AV_PICTURE_TYPE_B:
if (!v->bi_type) {
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
ff_bp[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */
break;
}
/* fall-through (BI-type) */
case AV_PICTURE_TYPE_I:
ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */
ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL;
break;
default:
ff_bp[0] = NULL;
ff_bp[1] = NULL;
ff_bp[2] = NULL;
break;
}
bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2);
if (!bitplane)
return -1;
n = 0;
for (y = 0; y < s->mb_height; y++)
for (x = 0; x < s->mb_width; x++, n++)
vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride);
if (n & 1) /* move last nibble to the high order */
bitplane[n/2] <<= 4;
}
return 0;
}
| false | FFmpeg | 5a667322f5cb0e77c15891fc06725c19d8f3314f | static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
{
const VC1Context *v = avctx->priv_data;
const MpegEncContext *s = &v->s;
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferVC1 *pic_param;
vactx->slice_param_size = sizeof(VASliceParameterBufferVC1);
pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1));
if (!pic_param)
return -1;
pic_param->forward_reference_picture = VA_INVALID_ID;
pic_param->backward_reference_picture = VA_INVALID_ID;
pic_param->inloop_decoded_picture = VA_INVALID_ID;
pic_param->sequence_fields.value = 0;
pic_param->sequence_fields.bits.pulldown = v->broadcast;
pic_param->sequence_fields.bits.interlace = v->interlace;
pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag;
pic_param->sequence_fields.bits.finterpflag = v->finterpflag;
pic_param->sequence_fields.bits.psf = v->psf;
pic_param->sequence_fields.bits.multires = v->multires;
pic_param->sequence_fields.bits.overlap = v->overlap;
pic_param->sequence_fields.bits.syncmarker = v->resync_marker;
pic_param->sequence_fields.bits.rangered = v->rangered;
pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames;
#if VA_CHECK_VERSION(0,32,0)
pic_param->sequence_fields.bits.profile = v->profile;
#endif
pic_param->coded_width = s->avctx->coded_width;
pic_param->coded_height = s->avctx->coded_height;
pic_param->entrypoint_fields.value = 0;
pic_param->entrypoint_fields.bits.broken_link = v->broken_link;
pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry;
pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag;
pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter;
pic_param->conditional_overlap_flag = v->condover;
pic_param->fast_uvmc_flag = v->fastuvmc;
pic_param->range_mapping_fields.value = 0;
pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag;
pic_param->range_mapping_fields.bits.luma = v->range_mapy;
pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag;
pic_param->range_mapping_fields.bits.chroma = v->range_mapuv;
pic_param->b_picture_fraction = v->bfraction_lut_index;
pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;
pic_param->mb_mode_table = 0;
pic_param->range_reduction_frame = v->rangeredfrm;
pic_param->rounding_control = v->rnd;
pic_param->post_processing = v->postproc;
pic_param->picture_resolution_index = v->respic;
pic_param->luma_scale = v->lumscale;
pic_param->luma_shift = v->lumshift;
pic_param->picture_fields.value = 0;
pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v);
pic_param->picture_fields.bits.frame_coding_mode = v->fcm;
pic_param->picture_fields.bits.top_field_first = v->tff;
pic_param->picture_fields.bits.is_first_field = v->fcm == 0;
pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP;
pic_param->raw_coding.value = 0;
pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw;
pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw;
pic_param->raw_coding.flags.skip_mb = v->skip_is_raw;
pic_param->raw_coding.flags.field_tx = 0;
pic_param->raw_coding.flags.forward_mb = 0;
pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw;
pic_param->raw_coding.flags.overflags = v->overflg_is_raw;
pic_param->bitplane_present.value = 0;
pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v);
pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v);
pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v);
pic_param->bitplane_present.flags.bp_field_tx = 0;
pic_param->bitplane_present.flags.bp_forward_mb = 0;
pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v);
pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v);
pic_param->reference_fields.value = 0;
pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag;
pic_param->reference_fields.bits.reference_distance = 0;
pic_param->reference_fields.bits.num_reference_pictures = 0;
pic_param->reference_fields.bits.reference_field_pic_indicator = 0;
pic_param->mv_fields.value = 0;
pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v);
pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v);
pic_param->mv_fields.bits.mv_table = s->mv_table_index;
pic_param->mv_fields.bits.two_mv_block_pattern_table = 0;
pic_param->mv_fields.bits.four_mv_switch = 0;
pic_param->mv_fields.bits.four_mv_block_pattern_table = 0;
pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv;
pic_param->mv_fields.bits.extended_mv_range = v->mvrange;
pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv;
pic_param->mv_fields.bits.extended_dmv_range = 0;
pic_param->pic_quantizer_fields.value = 0;
pic_param->pic_quantizer_fields.bits.dquant = v->dquant;
pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode;
pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer;
pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm;
pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile;
pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel;
pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq;
pic_param->transform_fields.value = 0;
pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf;
pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v);
pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index;
pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index;
switch (s->pict_type) {
case AV_PICTURE_TYPE_B:
pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f);
case AV_PICTURE_TYPE_P:
pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f);
break;
}
if (pic_param->bitplane_present.value) {
uint8_t *bitplane;
const uint8_t *ff_bp[3];
int x, y, n;
switch (s->pict_type) {
case AV_PICTURE_TYPE_P:
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL;
break;
case AV_PICTURE_TYPE_B:
if (!v->bi_type) {
ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL;
ff_bp[2] = NULL;
break;
}
case AV_PICTURE_TYPE_I:
ff_bp[0] = NULL;
ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL;
ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL;
break;
default:
ff_bp[0] = NULL;
ff_bp[1] = NULL;
ff_bp[2] = NULL;
break;
}
bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2);
if (!bitplane)
return -1;
n = 0;
for (y = 0; y < s->mb_height; y++)
for (x = 0; x < s->mb_width; x++, n++)
vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride);
if (n & 1)
bitplane[n/2] <<= 4;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, av_unused const VAR_1 *buffer, av_unused uint32_t size)
{
const VC1Context *VAR_2 = VAR_0->priv_data;
const MpegEncContext *VAR_3 = &VAR_2->VAR_3;
struct vaapi_context * const VAR_4 = VAR_0->hwaccel_context;
VAPictureParameterBufferVC1 *pic_param;
VAR_4->slice_param_size = sizeof(VASliceParameterBufferVC1);
pic_param = ff_vaapi_alloc_pic_param(VAR_4, sizeof(VAPictureParameterBufferVC1));
if (!pic_param)
return -1;
pic_param->forward_reference_picture = VA_INVALID_ID;
pic_param->backward_reference_picture = VA_INVALID_ID;
pic_param->inloop_decoded_picture = VA_INVALID_ID;
pic_param->sequence_fields.value = 0;
pic_param->sequence_fields.bits.pulldown = VAR_2->broadcast;
pic_param->sequence_fields.bits.interlace = VAR_2->interlace;
pic_param->sequence_fields.bits.tfcntrflag = VAR_2->tfcntrflag;
pic_param->sequence_fields.bits.finterpflag = VAR_2->finterpflag;
pic_param->sequence_fields.bits.psf = VAR_2->psf;
pic_param->sequence_fields.bits.multires = VAR_2->multires;
pic_param->sequence_fields.bits.overlap = VAR_2->overlap;
pic_param->sequence_fields.bits.syncmarker = VAR_2->resync_marker;
pic_param->sequence_fields.bits.rangered = VAR_2->rangered;
pic_param->sequence_fields.bits.max_b_frames = VAR_3->VAR_0->max_b_frames;
#if VA_CHECK_VERSION(0,32,0)
pic_param->sequence_fields.bits.profile = VAR_2->profile;
#endif
pic_param->coded_width = VAR_3->VAR_0->coded_width;
pic_param->coded_height = VAR_3->VAR_0->coded_height;
pic_param->entrypoint_fields.value = 0;
pic_param->entrypoint_fields.bits.broken_link = VAR_2->broken_link;
pic_param->entrypoint_fields.bits.closed_entry = VAR_2->closed_entry;
pic_param->entrypoint_fields.bits.panscan_flag = VAR_2->panscanflag;
pic_param->entrypoint_fields.bits.loopfilter = VAR_3->loop_filter;
pic_param->conditional_overlap_flag = VAR_2->condover;
pic_param->fast_uvmc_flag = VAR_2->fastuvmc;
pic_param->range_mapping_fields.value = 0;
pic_param->range_mapping_fields.bits.luma_flag = VAR_2->range_mapy_flag;
pic_param->range_mapping_fields.bits.luma = VAR_2->range_mapy;
pic_param->range_mapping_fields.bits.chroma_flag = VAR_2->range_mapuv_flag;
pic_param->range_mapping_fields.bits.chroma = VAR_2->range_mapuv;
pic_param->b_picture_fraction = VAR_2->bfraction_lut_index;
pic_param->cbp_table = VAR_2->cbpcy_vlc ? VAR_2->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;
pic_param->mb_mode_table = 0;
pic_param->range_reduction_frame = VAR_2->rangeredfrm;
pic_param->rounding_control = VAR_2->rnd;
pic_param->post_processing = VAR_2->postproc;
pic_param->picture_resolution_index = VAR_2->respic;
pic_param->luma_scale = VAR_2->lumscale;
pic_param->luma_shift = VAR_2->lumshift;
pic_param->picture_fields.value = 0;
pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(VAR_2);
pic_param->picture_fields.bits.frame_coding_mode = VAR_2->fcm;
pic_param->picture_fields.bits.top_field_first = VAR_2->tff;
pic_param->picture_fields.bits.is_first_field = VAR_2->fcm == 0;
pic_param->picture_fields.bits.intensity_compensation = VAR_2->mv_mode == MV_PMODE_INTENSITY_COMP;
pic_param->raw_coding.value = 0;
pic_param->raw_coding.flags.mv_type_mb = VAR_2->mv_type_is_raw;
pic_param->raw_coding.flags.direct_mb = VAR_2->dmb_is_raw;
pic_param->raw_coding.flags.skip_mb = VAR_2->skip_is_raw;
pic_param->raw_coding.flags.field_tx = 0;
pic_param->raw_coding.flags.forward_mb = 0;
pic_param->raw_coding.flags.ac_pred = VAR_2->acpred_is_raw;
pic_param->raw_coding.flags.overflags = VAR_2->overflg_is_raw;
pic_param->bitplane_present.value = 0;
pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(VAR_2);
pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(VAR_2);
pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(VAR_2);
pic_param->bitplane_present.flags.bp_field_tx = 0;
pic_param->bitplane_present.flags.bp_forward_mb = 0;
pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(VAR_2);
pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(VAR_2);
pic_param->reference_fields.value = 0;
pic_param->reference_fields.bits.reference_distance_flag = VAR_2->refdist_flag;
pic_param->reference_fields.bits.reference_distance = 0;
pic_param->reference_fields.bits.num_reference_pictures = 0;
pic_param->reference_fields.bits.reference_field_pic_indicator = 0;
pic_param->mv_fields.value = 0;
pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(VAR_2);
pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(VAR_2);
pic_param->mv_fields.bits.mv_table = VAR_3->mv_table_index;
pic_param->mv_fields.bits.two_mv_block_pattern_table = 0;
pic_param->mv_fields.bits.four_mv_switch = 0;
pic_param->mv_fields.bits.four_mv_block_pattern_table = 0;
pic_param->mv_fields.bits.extended_mv_flag = VAR_2->extended_mv;
pic_param->mv_fields.bits.extended_mv_range = VAR_2->mvrange;
pic_param->mv_fields.bits.extended_dmv_flag = VAR_2->extended_dmv;
pic_param->mv_fields.bits.extended_dmv_range = 0;
pic_param->pic_quantizer_fields.value = 0;
pic_param->pic_quantizer_fields.bits.dquant = VAR_2->dquant;
pic_param->pic_quantizer_fields.bits.quantizer = VAR_2->quantizer_mode;
pic_param->pic_quantizer_fields.bits.half_qp = VAR_2->halfpq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = VAR_2->pq;
pic_param->pic_quantizer_fields.bits.pic_quantizer_type = VAR_2->pquantizer;
pic_param->pic_quantizer_fields.bits.dq_frame = VAR_2->dquantfrm;
pic_param->pic_quantizer_fields.bits.dq_profile = VAR_2->dqprofile;
pic_param->pic_quantizer_fields.bits.dq_sb_edge = VAR_2->dqprofile == DQPROFILE_SINGLE_EDGE ? VAR_2->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_db_edge = VAR_2->dqprofile == DQPROFILE_DOUBLE_EDGES ? VAR_2->dqsbedge : 0;
pic_param->pic_quantizer_fields.bits.dq_binary_level = VAR_2->dqbilevel;
pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = VAR_2->altpq;
pic_param->transform_fields.value = 0;
pic_param->transform_fields.bits.variable_sized_transform_flag = VAR_2->vstransform;
pic_param->transform_fields.bits.mb_level_transform_type_flag = VAR_2->ttmbf;
pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(VAR_2);
pic_param->transform_fields.bits.transform_ac_codingset_idx1 = VAR_2->c_ac_table_index;
pic_param->transform_fields.bits.transform_ac_codingset_idx2 = VAR_2->y_ac_table_index;
pic_param->transform_fields.bits.intra_transform_dc_table = VAR_2->VAR_3.dc_table_index;
switch (VAR_3->pict_type) {
case AV_PICTURE_TYPE_B:
pic_param->backward_reference_picture = ff_vaapi_get_surface_id(VAR_3->next_picture.f);
case AV_PICTURE_TYPE_P:
pic_param->forward_reference_picture = ff_vaapi_get_surface_id(VAR_3->last_picture.f);
break;
}
if (pic_param->bitplane_present.value) {
VAR_1 *bitplane;
const VAR_1 *VAR_5[3];
int VAR_6, VAR_7, VAR_8;
switch (VAR_3->pict_type) {
case AV_PICTURE_TYPE_P:
VAR_5[0] = pic_param->bitplane_present.flags.bp_direct_mb ? VAR_2->direct_mb_plane : NULL;
VAR_5[1] = pic_param->bitplane_present.flags.bp_skip_mb ? VAR_3->mbskip_table : NULL;
VAR_5[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? VAR_2->mv_type_mb_plane : NULL;
break;
case AV_PICTURE_TYPE_B:
if (!VAR_2->bi_type) {
VAR_5[0] = pic_param->bitplane_present.flags.bp_direct_mb ? VAR_2->direct_mb_plane : NULL;
VAR_5[1] = pic_param->bitplane_present.flags.bp_skip_mb ? VAR_3->mbskip_table : NULL;
VAR_5[2] = NULL;
break;
}
case AV_PICTURE_TYPE_I:
VAR_5[0] = NULL;
VAR_5[1] = pic_param->bitplane_present.flags.bp_ac_pred ? VAR_2->acpred_plane : NULL;
VAR_5[2] = pic_param->bitplane_present.flags.bp_overflags ? VAR_2->over_flags_plane : NULL;
break;
default:
VAR_5[0] = NULL;
VAR_5[1] = NULL;
VAR_5[2] = NULL;
break;
}
bitplane = ff_vaapi_alloc_bitplane(VAR_4, (VAR_3->mb_width * VAR_3->mb_height + 1) / 2);
if (!bitplane)
return -1;
VAR_8 = 0;
for (VAR_7 = 0; VAR_7 < VAR_3->mb_height; VAR_7++)
for (VAR_6 = 0; VAR_6 < VAR_3->mb_width; VAR_6++, VAR_8++)
vc1_pack_bitplanes(bitplane, VAR_8, VAR_5, VAR_6, VAR_7, VAR_3->mb_stride);
if (VAR_8 & 1)
bitplane[VAR_8/2] <<= 4;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, av_unused const VAR_1 *buffer, av_unused uint32_t size)\n{",
"const VC1Context *VAR_2 = VAR_0->priv_data;",
"const MpegEncContext *VAR_3 = &VAR_2->VAR_3;",
"struct vaapi_context * const VAR_4 = VAR_0->hwaccel_context;",
"VAPictureParameterBufferVC1 *pic_param;",
"VAR_4->slice_param_size = sizeof(VASliceParameterBufferVC1);",
"pic_param = ff_vaapi_alloc_pic_param(VAR_4, sizeof(VAPictureParameterBufferVC1));",
"if (!pic_param)\nreturn -1;",
"pic_param->forward_reference_picture = VA_INVALID_ID;",
"pic_param->backward_reference_picture = VA_INVALID_ID;",
"pic_param->inloop_decoded_picture = VA_INVALID_ID;",
"pic_param->sequence_fields.value = 0;",
"pic_param->sequence_fields.bits.pulldown = VAR_2->broadcast;",
"pic_param->sequence_fields.bits.interlace = VAR_2->interlace;",
"pic_param->sequence_fields.bits.tfcntrflag = VAR_2->tfcntrflag;",
"pic_param->sequence_fields.bits.finterpflag = VAR_2->finterpflag;",
"pic_param->sequence_fields.bits.psf = VAR_2->psf;",
"pic_param->sequence_fields.bits.multires = VAR_2->multires;",
"pic_param->sequence_fields.bits.overlap = VAR_2->overlap;",
"pic_param->sequence_fields.bits.syncmarker = VAR_2->resync_marker;",
"pic_param->sequence_fields.bits.rangered = VAR_2->rangered;",
"pic_param->sequence_fields.bits.max_b_frames = VAR_3->VAR_0->max_b_frames;",
"#if VA_CHECK_VERSION(0,32,0)\npic_param->sequence_fields.bits.profile = VAR_2->profile;",
"#endif\npic_param->coded_width = VAR_3->VAR_0->coded_width;",
"pic_param->coded_height = VAR_3->VAR_0->coded_height;",
"pic_param->entrypoint_fields.value = 0;",
"pic_param->entrypoint_fields.bits.broken_link = VAR_2->broken_link;",
"pic_param->entrypoint_fields.bits.closed_entry = VAR_2->closed_entry;",
"pic_param->entrypoint_fields.bits.panscan_flag = VAR_2->panscanflag;",
"pic_param->entrypoint_fields.bits.loopfilter = VAR_3->loop_filter;",
"pic_param->conditional_overlap_flag = VAR_2->condover;",
"pic_param->fast_uvmc_flag = VAR_2->fastuvmc;",
"pic_param->range_mapping_fields.value = 0;",
"pic_param->range_mapping_fields.bits.luma_flag = VAR_2->range_mapy_flag;",
"pic_param->range_mapping_fields.bits.luma = VAR_2->range_mapy;",
"pic_param->range_mapping_fields.bits.chroma_flag = VAR_2->range_mapuv_flag;",
"pic_param->range_mapping_fields.bits.chroma = VAR_2->range_mapuv;",
"pic_param->b_picture_fraction = VAR_2->bfraction_lut_index;",
"pic_param->cbp_table = VAR_2->cbpcy_vlc ? VAR_2->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0;",
"pic_param->mb_mode_table = 0;",
"pic_param->range_reduction_frame = VAR_2->rangeredfrm;",
"pic_param->rounding_control = VAR_2->rnd;",
"pic_param->post_processing = VAR_2->postproc;",
"pic_param->picture_resolution_index = VAR_2->respic;",
"pic_param->luma_scale = VAR_2->lumscale;",
"pic_param->luma_shift = VAR_2->lumshift;",
"pic_param->picture_fields.value = 0;",
"pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(VAR_2);",
"pic_param->picture_fields.bits.frame_coding_mode = VAR_2->fcm;",
"pic_param->picture_fields.bits.top_field_first = VAR_2->tff;",
"pic_param->picture_fields.bits.is_first_field = VAR_2->fcm == 0;",
"pic_param->picture_fields.bits.intensity_compensation = VAR_2->mv_mode == MV_PMODE_INTENSITY_COMP;",
"pic_param->raw_coding.value = 0;",
"pic_param->raw_coding.flags.mv_type_mb = VAR_2->mv_type_is_raw;",
"pic_param->raw_coding.flags.direct_mb = VAR_2->dmb_is_raw;",
"pic_param->raw_coding.flags.skip_mb = VAR_2->skip_is_raw;",
"pic_param->raw_coding.flags.field_tx = 0;",
"pic_param->raw_coding.flags.forward_mb = 0;",
"pic_param->raw_coding.flags.ac_pred = VAR_2->acpred_is_raw;",
"pic_param->raw_coding.flags.overflags = VAR_2->overflg_is_raw;",
"pic_param->bitplane_present.value = 0;",
"pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(VAR_2);",
"pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(VAR_2);",
"pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(VAR_2);",
"pic_param->bitplane_present.flags.bp_field_tx = 0;",
"pic_param->bitplane_present.flags.bp_forward_mb = 0;",
"pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(VAR_2);",
"pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(VAR_2);",
"pic_param->reference_fields.value = 0;",
"pic_param->reference_fields.bits.reference_distance_flag = VAR_2->refdist_flag;",
"pic_param->reference_fields.bits.reference_distance = 0;",
"pic_param->reference_fields.bits.num_reference_pictures = 0;",
"pic_param->reference_fields.bits.reference_field_pic_indicator = 0;",
"pic_param->mv_fields.value = 0;",
"pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(VAR_2);",
"pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(VAR_2);",
"pic_param->mv_fields.bits.mv_table = VAR_3->mv_table_index;",
"pic_param->mv_fields.bits.two_mv_block_pattern_table = 0;",
"pic_param->mv_fields.bits.four_mv_switch = 0;",
"pic_param->mv_fields.bits.four_mv_block_pattern_table = 0;",
"pic_param->mv_fields.bits.extended_mv_flag = VAR_2->extended_mv;",
"pic_param->mv_fields.bits.extended_mv_range = VAR_2->mvrange;",
"pic_param->mv_fields.bits.extended_dmv_flag = VAR_2->extended_dmv;",
"pic_param->mv_fields.bits.extended_dmv_range = 0;",
"pic_param->pic_quantizer_fields.value = 0;",
"pic_param->pic_quantizer_fields.bits.dquant = VAR_2->dquant;",
"pic_param->pic_quantizer_fields.bits.quantizer = VAR_2->quantizer_mode;",
"pic_param->pic_quantizer_fields.bits.half_qp = VAR_2->halfpq;",
"pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = VAR_2->pq;",
"pic_param->pic_quantizer_fields.bits.pic_quantizer_type = VAR_2->pquantizer;",
"pic_param->pic_quantizer_fields.bits.dq_frame = VAR_2->dquantfrm;",
"pic_param->pic_quantizer_fields.bits.dq_profile = VAR_2->dqprofile;",
"pic_param->pic_quantizer_fields.bits.dq_sb_edge = VAR_2->dqprofile == DQPROFILE_SINGLE_EDGE ? VAR_2->dqsbedge : 0;",
"pic_param->pic_quantizer_fields.bits.dq_db_edge = VAR_2->dqprofile == DQPROFILE_DOUBLE_EDGES ? VAR_2->dqsbedge : 0;",
"pic_param->pic_quantizer_fields.bits.dq_binary_level = VAR_2->dqbilevel;",
"pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = VAR_2->altpq;",
"pic_param->transform_fields.value = 0;",
"pic_param->transform_fields.bits.variable_sized_transform_flag = VAR_2->vstransform;",
"pic_param->transform_fields.bits.mb_level_transform_type_flag = VAR_2->ttmbf;",
"pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(VAR_2);",
"pic_param->transform_fields.bits.transform_ac_codingset_idx1 = VAR_2->c_ac_table_index;",
"pic_param->transform_fields.bits.transform_ac_codingset_idx2 = VAR_2->y_ac_table_index;",
"pic_param->transform_fields.bits.intra_transform_dc_table = VAR_2->VAR_3.dc_table_index;",
"switch (VAR_3->pict_type) {",
"case AV_PICTURE_TYPE_B:\npic_param->backward_reference_picture = ff_vaapi_get_surface_id(VAR_3->next_picture.f);",
"case AV_PICTURE_TYPE_P:\npic_param->forward_reference_picture = ff_vaapi_get_surface_id(VAR_3->last_picture.f);",
"break;",
"}",
"if (pic_param->bitplane_present.value) {",
"VAR_1 *bitplane;",
"const VAR_1 *VAR_5[3];",
"int VAR_6, VAR_7, VAR_8;",
"switch (VAR_3->pict_type) {",
"case AV_PICTURE_TYPE_P:\nVAR_5[0] = pic_param->bitplane_present.flags.bp_direct_mb ? VAR_2->direct_mb_plane : NULL;",
"VAR_5[1] = pic_param->bitplane_present.flags.bp_skip_mb ? VAR_3->mbskip_table : NULL;",
"VAR_5[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? VAR_2->mv_type_mb_plane : NULL;",
"break;",
"case AV_PICTURE_TYPE_B:\nif (!VAR_2->bi_type) {",
"VAR_5[0] = pic_param->bitplane_present.flags.bp_direct_mb ? VAR_2->direct_mb_plane : NULL;",
"VAR_5[1] = pic_param->bitplane_present.flags.bp_skip_mb ? VAR_3->mbskip_table : NULL;",
"VAR_5[2] = NULL;",
"break;",
"}",
"case AV_PICTURE_TYPE_I:\nVAR_5[0] = NULL;",
"VAR_5[1] = pic_param->bitplane_present.flags.bp_ac_pred ? VAR_2->acpred_plane : NULL;",
"VAR_5[2] = pic_param->bitplane_present.flags.bp_overflags ? VAR_2->over_flags_plane : NULL;",
"break;",
"default:\nVAR_5[0] = NULL;",
"VAR_5[1] = NULL;",
"VAR_5[2] = NULL;",
"break;",
"}",
"bitplane = ff_vaapi_alloc_bitplane(VAR_4, (VAR_3->mb_width * VAR_3->mb_height + 1) / 2);",
"if (!bitplane)\nreturn -1;",
"VAR_8 = 0;",
"for (VAR_7 = 0; VAR_7 < VAR_3->mb_height; VAR_7++)",
"for (VAR_6 = 0; VAR_6 < VAR_3->mb_width; VAR_6++, VAR_8++)",
"vc1_pack_bitplanes(bitplane, VAR_8, VAR_5, VAR_6, VAR_7, VAR_3->mb_stride);",
"if (VAR_8 & 1)\nbitplane[VAR_8/2] <<= 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
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
],
[
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
],
[
223
],
[
225,
227
],
[
231,
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305,
307
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327
]
] |
25,243 | static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
GetBitContext gb;
int i;
init_get_bits(&gb, src, length);
for(i=0; i<3; i++){
read_len_table(s->len[i], &gb);
if(generate_bits_table(s->bits[i], s->len[i])<0){
return -1;
}
#if 0
for(j=0; j<256; j++){
printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j);
}
#endif
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4);
}
return 0;
}
| false | FFmpeg | 68f593b48433842f3407586679fe07f3e5199ab9 | static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
GetBitContext gb;
int i;
init_get_bits(&gb, src, length);
for(i=0; i<3; i++){
read_len_table(s->len[i], &gb);
if(generate_bits_table(s->bits[i], s->len[i])<0){
return -1;
}
#if 0
for(j=0; j<256; j++){
printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j);
}
#endif
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(HYuvContext *VAR_0, uint8_t *VAR_1, int VAR_2){
GetBitContext gb;
int VAR_3;
init_get_bits(&gb, VAR_1, VAR_2);
for(VAR_3=0; VAR_3<3; VAR_3++){
read_len_table(VAR_0->len[VAR_3], &gb);
if(generate_bits_table(VAR_0->bits[VAR_3], VAR_0->len[VAR_3])<0){
return -1;
}
#if 0
for(j=0; j<256; j++){
printf("%6X, %2d, %3d\n", VAR_0->bits[VAR_3][j], VAR_0->len[VAR_3][j], j);
}
#endif
init_vlc(&VAR_0->vlc[VAR_3], VLC_BITS, 256, VAR_0->len[VAR_3], 1, 1, VAR_0->bits[VAR_3], 4, 4);
}
return 0;
}
| [
"static int FUNC_0(HYuvContext *VAR_0, uint8_t *VAR_1, int VAR_2){",
"GetBitContext gb;",
"int VAR_3;",
"init_get_bits(&gb, VAR_1, VAR_2);",
"for(VAR_3=0; VAR_3<3; VAR_3++){",
"read_len_table(VAR_0->len[VAR_3], &gb);",
"if(generate_bits_table(VAR_0->bits[VAR_3], VAR_0->len[VAR_3])<0){",
"return -1;",
"}",
"#if 0\nfor(j=0; j<256; j++){",
"printf(\"%6X, %2d, %3d\\n\", VAR_0->bits[VAR_3][j], VAR_0->len[VAR_3][j], j);",
"}",
"#endif\ninit_vlc(&VAR_0->vlc[VAR_3], VLC_BITS, 256, VAR_0->len[VAR_3], 1, 1, VAR_0->bits[VAR_3], 4, 4);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
]
] |
25,244 | static void test_source_notify(void)
{
while (g_main_context_iteration(NULL, false));
aio_notify(ctx);
g_assert(g_main_context_iteration(NULL, true));
g_assert(!g_main_context_iteration(NULL, false));
}
| true | qemu | eabc977973103527bbb8fed69c91cfaa6691f8ab | static void test_source_notify(void)
{
while (g_main_context_iteration(NULL, false));
aio_notify(ctx);
g_assert(g_main_context_iteration(NULL, true));
g_assert(!g_main_context_iteration(NULL, false));
}
| {
"code": [
" aio_notify(ctx);",
"static void test_source_notify(void)",
" while (g_main_context_iteration(NULL, false));",
" aio_notify(ctx);",
" g_assert(g_main_context_iteration(NULL, true));",
" g_assert(!g_main_context_iteration(NULL, false));"
],
"line_no": [
7,
1,
5,
7,
9,
11
]
} | static void FUNC_0(void)
{
while (g_main_context_iteration(NULL, false));
aio_notify(ctx);
g_assert(g_main_context_iteration(NULL, true));
g_assert(!g_main_context_iteration(NULL, false));
}
| [
"static void FUNC_0(void)\n{",
"while (g_main_context_iteration(NULL, false));",
"aio_notify(ctx);",
"g_assert(g_main_context_iteration(NULL, true));",
"g_assert(!g_main_context_iteration(NULL, false));",
"}"
] | [
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,246 | static void virtio_crypto_dataq_bh(void *opaque)
{
VirtIOCryptoQueue *q = opaque;
VirtIOCrypto *vcrypto = q->vcrypto;
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
/* This happens when device was stopped but BH wasn't. */
if (!vdev->vm_running) {
return;
}
/* Just in case the driver is not ready on more */
if (unlikely(!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) {
return;
}
virtio_crypto_handle_dataq(vdev, q->dataq);
virtio_queue_set_notification(q->dataq, 1);
}
| true | qemu | 600f5ce356b44d8fa5a611ff6b034eb95ecf04e7 | static void virtio_crypto_dataq_bh(void *opaque)
{
VirtIOCryptoQueue *q = opaque;
VirtIOCrypto *vcrypto = q->vcrypto;
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
if (!vdev->vm_running) {
return;
}
if (unlikely(!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) {
return;
}
virtio_crypto_handle_dataq(vdev, q->dataq);
virtio_queue_set_notification(q->dataq, 1);
}
| {
"code": [
" virtio_crypto_handle_dataq(vdev, q->dataq);",
" virtio_queue_set_notification(q->dataq, 1);"
],
"line_no": [
33,
35
]
} | static void FUNC_0(void *VAR_0)
{
VirtIOCryptoQueue *q = VAR_0;
VirtIOCrypto *vcrypto = q->vcrypto;
VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);
if (!vdev->vm_running) {
return;
}
if (unlikely(!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) {
return;
}
virtio_crypto_handle_dataq(vdev, q->dataq);
virtio_queue_set_notification(q->dataq, 1);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"VirtIOCryptoQueue *q = VAR_0;",
"VirtIOCrypto *vcrypto = q->vcrypto;",
"VirtIODevice *vdev = VIRTIO_DEVICE(vcrypto);",
"if (!vdev->vm_running) {",
"return;",
"}",
"if (unlikely(!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK))) {",
"return;",
"}",
"virtio_crypto_handle_dataq(vdev, q->dataq);",
"virtio_queue_set_notification(q->dataq, 1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
25,248 | static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
hwaddr addr_limit)
{
void *fdt = NULL;
int size, rc;
uint32_t acells, scells;
if (binfo->dtb_filename) {
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
if (!filename) {
fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
goto fail;
}
fdt = load_device_tree(filename, &size);
if (!fdt) {
fprintf(stderr, "Couldn't open dtb file %s\n", filename);
g_free(filename);
goto fail;
}
g_free(filename);
} else if (binfo->get_dtb) {
fdt = binfo->get_dtb(binfo, &size);
if (!fdt) {
fprintf(stderr, "Board was unable to create a dtb blob\n");
goto fail;
}
}
if (addr_limit > addr && size > (addr_limit - addr)) {
/* Installing the device tree blob at addr would exceed addr_limit.
* Whether this constitutes failure is up to the caller to decide,
* so just return 0 as size, i.e., no error.
*/
g_free(fdt);
return 0;
}
acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells");
scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells");
if (acells == 0 || scells == 0) {
fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
goto fail;
}
if (scells < 2 && binfo->ram_size >= (1ULL << 32)) {
/* This is user error so deserves a friendlier error message
* than the failure of setprop_sized_cells would provide
*/
fprintf(stderr, "qemu: dtb file not compatible with "
"RAM size > 4GB\n");
goto fail;
}
rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg",
acells, binfo->loader_start,
scells, binfo->ram_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /memory/reg\n");
goto fail;
}
if (binfo->kernel_cmdline && *binfo->kernel_cmdline) {
rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
binfo->kernel_cmdline);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/bootargs\n");
goto fail;
}
}
if (binfo->initrd_size) {
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
binfo->initrd_start);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
goto fail;
}
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
binfo->initrd_start + binfo->initrd_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
goto fail;
}
}
if (binfo->modify_dtb) {
binfo->modify_dtb(binfo, fdt);
}
qemu_fdt_dumpdtb(fdt, size);
/* Put the DTB into the memory map as a ROM image: this will ensure
* the DTB is copied again upon reset, even if addr points into RAM.
*/
rom_add_blob_fixed("dtb", fdt, size, addr);
g_free(fdt);
return size;
fail:
g_free(fdt);
return -1;
}
| true | qemu | a554ecb49d0021fd8bb0fd4f2f6be807b3c8b54f | static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
hwaddr addr_limit)
{
void *fdt = NULL;
int size, rc;
uint32_t acells, scells;
if (binfo->dtb_filename) {
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
if (!filename) {
fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
goto fail;
}
fdt = load_device_tree(filename, &size);
if (!fdt) {
fprintf(stderr, "Couldn't open dtb file %s\n", filename);
g_free(filename);
goto fail;
}
g_free(filename);
} else if (binfo->get_dtb) {
fdt = binfo->get_dtb(binfo, &size);
if (!fdt) {
fprintf(stderr, "Board was unable to create a dtb blob\n");
goto fail;
}
}
if (addr_limit > addr && size > (addr_limit - addr)) {
g_free(fdt);
return 0;
}
acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells");
scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells");
if (acells == 0 || scells == 0) {
fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n");
goto fail;
}
if (scells < 2 && binfo->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: dtb file not compatible with "
"RAM size > 4GB\n");
goto fail;
}
rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg",
acells, binfo->loader_start,
scells, binfo->ram_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /memory/reg\n");
goto fail;
}
if (binfo->kernel_cmdline && *binfo->kernel_cmdline) {
rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
binfo->kernel_cmdline);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/bootargs\n");
goto fail;
}
}
if (binfo->initrd_size) {
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
binfo->initrd_start);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
goto fail;
}
rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
binfo->initrd_start + binfo->initrd_size);
if (rc < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
goto fail;
}
}
if (binfo->modify_dtb) {
binfo->modify_dtb(binfo, fdt);
}
qemu_fdt_dumpdtb(fdt, size);
rom_add_blob_fixed("dtb", fdt, size, addr);
g_free(fdt);
return size;
fail:
g_free(fdt);
return -1;
}
| {
"code": [
" } else if (binfo->get_dtb) {"
],
"line_no": [
45
]
} | static int FUNC_0(hwaddr VAR_0, const struct arm_boot_info *VAR_1,
hwaddr VAR_2)
{
void *VAR_3 = NULL;
int VAR_4, VAR_5;
uint32_t acells, scells;
if (VAR_1->dtb_filename) {
char *VAR_6;
VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_1->dtb_filename);
if (!VAR_6) {
fprintf(stderr, "Couldn't open dtb file %s\n", VAR_1->dtb_filename);
goto fail;
}
VAR_3 = load_device_tree(VAR_6, &VAR_4);
if (!VAR_3) {
fprintf(stderr, "Couldn't open dtb file %s\n", VAR_6);
g_free(VAR_6);
goto fail;
}
g_free(VAR_6);
} else if (VAR_1->get_dtb) {
VAR_3 = VAR_1->get_dtb(VAR_1, &VAR_4);
if (!VAR_3) {
fprintf(stderr, "Board was unable to create a dtb blob\n");
goto fail;
}
}
if (VAR_2 > VAR_0 && VAR_4 > (VAR_2 - VAR_0)) {
g_free(VAR_3);
return 0;
}
acells = qemu_fdt_getprop_cell(VAR_3, "/", "#address-cells");
scells = qemu_fdt_getprop_cell(VAR_3, "/", "#VAR_4-cells");
if (acells == 0 || scells == 0) {
fprintf(stderr, "dtb file invalid (#address-cells or #VAR_4-cells 0)\n");
goto fail;
}
if (scells < 2 && VAR_1->ram_size >= (1ULL << 32)) {
fprintf(stderr, "qemu: dtb file not compatible with "
"RAM VAR_4 > 4GB\n");
goto fail;
}
VAR_5 = qemu_fdt_setprop_sized_cells(VAR_3, "/memory", "reg",
acells, VAR_1->loader_start,
scells, VAR_1->ram_size);
if (VAR_5 < 0) {
fprintf(stderr, "couldn't set /memory/reg\n");
goto fail;
}
if (VAR_1->kernel_cmdline && *VAR_1->kernel_cmdline) {
VAR_5 = qemu_fdt_setprop_string(VAR_3, "/chosen", "bootargs",
VAR_1->kernel_cmdline);
if (VAR_5 < 0) {
fprintf(stderr, "couldn't set /chosen/bootargs\n");
goto fail;
}
}
if (VAR_1->initrd_size) {
VAR_5 = qemu_fdt_setprop_cell(VAR_3, "/chosen", "linux,initrd-start",
VAR_1->initrd_start);
if (VAR_5 < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
goto fail;
}
VAR_5 = qemu_fdt_setprop_cell(VAR_3, "/chosen", "linux,initrd-end",
VAR_1->initrd_start + VAR_1->initrd_size);
if (VAR_5 < 0) {
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
goto fail;
}
}
if (VAR_1->modify_dtb) {
VAR_1->modify_dtb(VAR_1, VAR_3);
}
qemu_fdt_dumpdtb(VAR_3, VAR_4);
rom_add_blob_fixed("dtb", VAR_3, VAR_4, VAR_0);
g_free(VAR_3);
return VAR_4;
fail:
g_free(VAR_3);
return -1;
}
| [
"static int FUNC_0(hwaddr VAR_0, const struct arm_boot_info *VAR_1,\nhwaddr VAR_2)\n{",
"void *VAR_3 = NULL;",
"int VAR_4, VAR_5;",
"uint32_t acells, scells;",
"if (VAR_1->dtb_filename) {",
"char *VAR_6;",
"VAR_6 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_1->dtb_filename);",
"if (!VAR_6) {",
"fprintf(stderr, \"Couldn't open dtb file %s\\n\", VAR_1->dtb_filename);",
"goto fail;",
"}",
"VAR_3 = load_device_tree(VAR_6, &VAR_4);",
"if (!VAR_3) {",
"fprintf(stderr, \"Couldn't open dtb file %s\\n\", VAR_6);",
"g_free(VAR_6);",
"goto fail;",
"}",
"g_free(VAR_6);",
"} else if (VAR_1->get_dtb) {",
"VAR_3 = VAR_1->get_dtb(VAR_1, &VAR_4);",
"if (!VAR_3) {",
"fprintf(stderr, \"Board was unable to create a dtb blob\\n\");",
"goto fail;",
"}",
"}",
"if (VAR_2 > VAR_0 && VAR_4 > (VAR_2 - VAR_0)) {",
"g_free(VAR_3);",
"return 0;",
"}",
"acells = qemu_fdt_getprop_cell(VAR_3, \"/\", \"#address-cells\");",
"scells = qemu_fdt_getprop_cell(VAR_3, \"/\", \"#VAR_4-cells\");",
"if (acells == 0 || scells == 0) {",
"fprintf(stderr, \"dtb file invalid (#address-cells or #VAR_4-cells 0)\\n\");",
"goto fail;",
"}",
"if (scells < 2 && VAR_1->ram_size >= (1ULL << 32)) {",
"fprintf(stderr, \"qemu: dtb file not compatible with \"\n\"RAM VAR_4 > 4GB\\n\");",
"goto fail;",
"}",
"VAR_5 = qemu_fdt_setprop_sized_cells(VAR_3, \"/memory\", \"reg\",\nacells, VAR_1->loader_start,\nscells, VAR_1->ram_size);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"couldn't set /memory/reg\\n\");",
"goto fail;",
"}",
"if (VAR_1->kernel_cmdline && *VAR_1->kernel_cmdline) {",
"VAR_5 = qemu_fdt_setprop_string(VAR_3, \"/chosen\", \"bootargs\",\nVAR_1->kernel_cmdline);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"couldn't set /chosen/bootargs\\n\");",
"goto fail;",
"}",
"}",
"if (VAR_1->initrd_size) {",
"VAR_5 = qemu_fdt_setprop_cell(VAR_3, \"/chosen\", \"linux,initrd-start\",\nVAR_1->initrd_start);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"couldn't set /chosen/linux,initrd-start\\n\");",
"goto fail;",
"}",
"VAR_5 = qemu_fdt_setprop_cell(VAR_3, \"/chosen\", \"linux,initrd-end\",\nVAR_1->initrd_start + VAR_1->initrd_size);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"couldn't set /chosen/linux,initrd-end\\n\");",
"goto fail;",
"}",
"}",
"if (VAR_1->modify_dtb) {",
"VAR_1->modify_dtb(VAR_1, VAR_3);",
"}",
"qemu_fdt_dumpdtb(VAR_3, VAR_4);",
"rom_add_blob_fixed(\"dtb\", VAR_3, VAR_4, VAR_0);",
"g_free(VAR_3);",
"return VAR_4;",
"fail:\ng_free(VAR_3);",
"return -1;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
101,
103
],
[
105
],
[
107
],
[
111,
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
185
],
[
195
],
[
199
],
[
203
],
[
207,
209
],
[
211
],
[
213
]
] |
25,249 | static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len = sizeof(saddr);
NetClientState *nc;
NetSocketState *s;
/* fd passed: multicast: "learn" dgram_dst address from bound address and save it
* Because this may be "shared" socket from a "master" process, datagrams would be recv()
* by ONLY ONE process: we must "clone" this dgram socket --jjo
*/
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
/* must be bound */
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
/* clone dgram socket */
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
/* error already reported by net_socket_mcast_create() */
goto err;
}
/* clone newfd to fd, close newfd */
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
/* mcast: save bound address as dst */
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| true | qemu | 8db804ac412010fc96397c2d67ee6417eccd9d34 | static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in saddr;
int newfd;
socklen_t saddr_len = sizeof(saddr);
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) {
if (saddr.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
newfd = net_socket_mcast_create(&saddr, NULL);
if (newfd < 0) {
goto err;
}
dup2(newfd, fd);
close(newfd);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = saddr;
}
return s;
err:
closesocket(fd);
return NULL;
}
| {
"code": [
" snprintf(nc->info_str, sizeof(nc->info_str),",
" \"socket: fd=%d (%s mcast=%s:%d)\",",
" fd, is_connected ? \"cloned\" : \"\",",
" inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));"
],
"line_no": [
89,
91,
93,
95
]
} | static NetSocketState *FUNC_0(NetClientState *peer,
const char *model,
const char *name,
int fd, int is_connected)
{
struct sockaddr_in VAR_0;
int VAR_1;
socklen_t saddr_len = sizeof(VAR_0);
NetClientState *nc;
NetSocketState *s;
if (is_connected) {
if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) {
if (VAR_0.sin_addr.s_addr == 0) {
fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, "
"cannot setup multicast dst addr\n", fd);
goto err;
}
VAR_1 = net_socket_mcast_create(&VAR_0, NULL);
if (VAR_1 < 0) {
goto err;
}
dup2(VAR_1, fd);
close(VAR_1);
} else {
fprintf(stderr,
"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n",
fd, strerror(errno));
goto err;
}
}
nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
snprintf(nc->info_str, sizeof(nc->info_str),
"socket: fd=%d (%s mcast=%s:%d)",
fd, is_connected ? "cloned" : "",
inet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port));
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = fd;
s->listen_fd = -1;
s->send_fn = net_socket_send_dgram;
net_socket_read_poll(s, true);
if (is_connected) {
s->dgram_dst = VAR_0;
}
return s;
err:
closesocket(fd);
return NULL;
}
| [
"static NetSocketState *FUNC_0(NetClientState *peer,\nconst char *model,\nconst char *name,\nint fd, int is_connected)\n{",
"struct sockaddr_in VAR_0;",
"int VAR_1;",
"socklen_t saddr_len = sizeof(VAR_0);",
"NetClientState *nc;",
"NetSocketState *s;",
"if (is_connected) {",
"if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) {",
"if (VAR_0.sin_addr.s_addr == 0) {",
"fprintf(stderr, \"qemu: error: init_dgram: fd=%d unbound, \"\n\"cannot setup multicast dst addr\\n\", fd);",
"goto err;",
"}",
"VAR_1 = net_socket_mcast_create(&VAR_0, NULL);",
"if (VAR_1 < 0) {",
"goto err;",
"}",
"dup2(VAR_1, fd);",
"close(VAR_1);",
"} else {",
"fprintf(stderr,\n\"qemu: error: init_dgram: fd=%d failed getsockname(): %s\\n\",\nfd, strerror(errno));",
"goto err;",
"}",
"}",
"nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);",
"snprintf(nc->info_str, sizeof(nc->info_str),\n\"socket: fd=%d (%s mcast=%s:%d)\",\nfd, is_connected ? \"cloned\" : \"\",\ninet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port));",
"s = DO_UPCAST(NetSocketState, nc, nc);",
"s->fd = fd;",
"s->listen_fd = -1;",
"s->send_fn = net_socket_send_dgram;",
"net_socket_read_poll(s, true);",
"if (is_connected) {",
"s->dgram_dst = VAR_0;",
"}",
"return s;",
"err:\nclosesocket(fd);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89,
91,
93,
95
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
115
],
[
117
],
[
119
],
[
123
],
[
127,
129
],
[
131
],
[
133
]
] |
25,250 | static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
Wc3DemuxContext *wc3 = s->priv_data;
ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
int ret = 0;
unsigned char text[1024];
unsigned int palette_number;
int i;
unsigned char r, g, b;
int base_palette_index;
while (!packet_read) {
fourcc_tag = get_le32(pb);
/* chunk sizes are 16-bit aligned */
size = (get_be32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
switch (fourcc_tag) {
case BRCH_TAG:
/* no-op */
break;
case SHOT_TAG:
/* load up new palette */
palette_number = get_le32(pb);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
base_palette_index = palette_number * PALETTE_COUNT * 3;
for (i = 0; i < PALETTE_COUNT; i++) {
r = wc3->palettes[base_palette_index + i * 3 + 0];
g = wc3->palettes[base_palette_index + i * 3 + 1];
b = wc3->palettes[base_palette_index + i * 3 + 2];
wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
}
wc3->palette_control.palette_changed = 1;
break;
case VGA__TAG:
/* send out video chunk */
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->video_stream_index;
pkt->pts = wc3->pts;
packet_read = 1;
break;
case TEXT_TAG:
/* subtitle chunk */
#if 0
url_fseek(pb, size, SEEK_CUR);
#else
if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
av_log (s, AV_LOG_DEBUG, " inglish: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " doytsch: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " fronsay: %s\n", &text[i + 1]);
}
#endif
break;
case AUDI_TAG:
/* send out audio chunk */
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->audio_stream_index;
pkt->pts = wc3->pts;
/* time to advance pts */
wc3->pts++;
packet_read = 1;
break;
default:
av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24),
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24));
ret = AVERROR_INVALIDDATA;
packet_read = 1;
break;
}
}
return ret;
}
| true | FFmpeg | 24ae353dfbe61019a86093a9c5cd15476aabef49 | static int wc3_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
Wc3DemuxContext *wc3 = s->priv_data;
ByteIOContext *pb = s->pb;
unsigned int fourcc_tag;
unsigned int size;
int packet_read = 0;
int ret = 0;
unsigned char text[1024];
unsigned int palette_number;
int i;
unsigned char r, g, b;
int base_palette_index;
while (!packet_read) {
fourcc_tag = get_le32(pb);
size = (get_be32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
switch (fourcc_tag) {
case BRCH_TAG:
break;
case SHOT_TAG:
palette_number = get_le32(pb);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
base_palette_index = palette_number * PALETTE_COUNT * 3;
for (i = 0; i < PALETTE_COUNT; i++) {
r = wc3->palettes[base_palette_index + i * 3 + 0];
g = wc3->palettes[base_palette_index + i * 3 + 1];
b = wc3->palettes[base_palette_index + i * 3 + 2];
wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
}
wc3->palette_control.palette_changed = 1;
break;
case VGA__TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->video_stream_index;
pkt->pts = wc3->pts;
packet_read = 1;
break;
case TEXT_TAG:
#if 0
url_fseek(pb, size, SEEK_CUR);
#else
if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size)
ret = AVERROR(EIO);
else {
int i = 0;
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
av_log (s, AV_LOG_DEBUG, " inglish: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " doytsch: %s\n", &text[i + 1]);
i += text[i] + 1;
av_log (s, AV_LOG_DEBUG, " fronsay: %s\n", &text[i + 1]);
}
#endif
break;
case AUDI_TAG:
ret= av_get_packet(pb, pkt, size);
pkt->stream_index = wc3->audio_stream_index;
pkt->pts = wc3->pts;
wc3->pts++;
packet_read = 1;
break;
default:
av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24),
(uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24));
ret = AVERROR_INVALIDDATA;
packet_read = 1;
break;
}
}
return ret;
}
| {
"code": [
" int i;",
" return AVERROR_INVALIDDATA;",
" unsigned int palette_number;",
" int i;",
" unsigned char r, g, b;",
" int base_palette_index;",
" palette_number = get_le32(pb);",
" if (palette_number >= wc3->palette_count)",
" return AVERROR_INVALIDDATA;",
" base_palette_index = palette_number * PALETTE_COUNT * 3;",
" for (i = 0; i < PALETTE_COUNT; i++) {",
" r = wc3->palettes[base_palette_index + i * 3 + 0];",
" g = wc3->palettes[base_palette_index + i * 3 + 1];",
" b = wc3->palettes[base_palette_index + i * 3 + 2];",
" wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b);",
" wc3->palette_control.palette_changed = 1;",
" ret= av_get_packet(pb, pkt, size);"
],
"line_no": [
23,
67,
21,
23,
25,
27,
63,
65,
67,
69,
71,
73,
75,
77,
79,
83,
93
]
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
Wc3DemuxContext *wc3 = VAR_0->priv_data;
ByteIOContext *pb = VAR_0->pb;
unsigned int VAR_2;
unsigned int VAR_3;
int VAR_4 = 0;
int VAR_5 = 0;
unsigned char VAR_6[1024];
unsigned int VAR_7;
int VAR_13;
unsigned char VAR_9, VAR_10, VAR_11;
int VAR_12;
while (!VAR_4) {
VAR_2 = get_le32(pb);
VAR_3 = (get_be32(pb) + 1) & (~1);
if (url_feof(pb))
return AVERROR(EIO);
switch (VAR_2) {
case BRCH_TAG:
break;
case SHOT_TAG:
VAR_7 = get_le32(pb);
if (VAR_7 >= wc3->palette_count)
return AVERROR_INVALIDDATA;
VAR_12 = VAR_7 * PALETTE_COUNT * 3;
for (VAR_13 = 0; VAR_13 < PALETTE_COUNT; VAR_13++) {
VAR_9 = wc3->palettes[VAR_12 + VAR_13 * 3 + 0];
VAR_10 = wc3->palettes[VAR_12 + VAR_13 * 3 + 1];
VAR_11 = wc3->palettes[VAR_12 + VAR_13 * 3 + 2];
wc3->palette_control.palette[VAR_13] = (VAR_9 << 16) | (VAR_10 << 8) | (VAR_11);
}
wc3->palette_control.palette_changed = 1;
break;
case VGA__TAG:
VAR_5= av_get_packet(pb, VAR_1, VAR_3);
VAR_1->stream_index = wc3->video_stream_index;
VAR_1->pts = wc3->pts;
VAR_4 = 1;
break;
case TEXT_TAG:
#if 0
url_fseek(pb, VAR_3, SEEK_CUR);
#else
if ((unsigned)VAR_3 > sizeof(VAR_6) || (VAR_5 = get_buffer(pb, VAR_6, VAR_3)) != VAR_3)
VAR_5 = AVERROR(EIO);
else {
int VAR_13 = 0;
av_log (VAR_0, AV_LOG_DEBUG, "Subtitle time!\n");
av_log (VAR_0, AV_LOG_DEBUG, " inglish: %VAR_0\n", &VAR_6[VAR_13 + 1]);
VAR_13 += VAR_6[VAR_13] + 1;
av_log (VAR_0, AV_LOG_DEBUG, " doytsch: %VAR_0\n", &VAR_6[VAR_13 + 1]);
VAR_13 += VAR_6[VAR_13] + 1;
av_log (VAR_0, AV_LOG_DEBUG, " fronsay: %VAR_0\n", &VAR_6[VAR_13 + 1]);
}
#endif
break;
case AUDI_TAG:
VAR_5= av_get_packet(pb, VAR_1, VAR_3);
VAR_1->stream_index = wc3->audio_stream_index;
VAR_1->pts = wc3->pts;
wc3->pts++;
VAR_4 = 1;
break;
default:
av_log (VAR_0, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n",
(uint8_t)VAR_2, (uint8_t)(VAR_2 >> 8), (uint8_t)(VAR_2 >> 16), (uint8_t)(VAR_2 >> 24),
(uint8_t)VAR_2, (uint8_t)(VAR_2 >> 8), (uint8_t)(VAR_2 >> 16), (uint8_t)(VAR_2 >> 24));
VAR_5 = AVERROR_INVALIDDATA;
VAR_4 = 1;
break;
}
}
return VAR_5;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"Wc3DemuxContext *wc3 = VAR_0->priv_data;",
"ByteIOContext *pb = VAR_0->pb;",
"unsigned int VAR_2;",
"unsigned int VAR_3;",
"int VAR_4 = 0;",
"int VAR_5 = 0;",
"unsigned char VAR_6[1024];",
"unsigned int VAR_7;",
"int VAR_13;",
"unsigned char VAR_9, VAR_10, VAR_11;",
"int VAR_12;",
"while (!VAR_4) {",
"VAR_2 = get_le32(pb);",
"VAR_3 = (get_be32(pb) + 1) & (~1);",
"if (url_feof(pb))\nreturn AVERROR(EIO);",
"switch (VAR_2) {",
"case BRCH_TAG:\nbreak;",
"case SHOT_TAG:\nVAR_7 = get_le32(pb);",
"if (VAR_7 >= wc3->palette_count)\nreturn AVERROR_INVALIDDATA;",
"VAR_12 = VAR_7 * PALETTE_COUNT * 3;",
"for (VAR_13 = 0; VAR_13 < PALETTE_COUNT; VAR_13++) {",
"VAR_9 = wc3->palettes[VAR_12 + VAR_13 * 3 + 0];",
"VAR_10 = wc3->palettes[VAR_12 + VAR_13 * 3 + 1];",
"VAR_11 = wc3->palettes[VAR_12 + VAR_13 * 3 + 2];",
"wc3->palette_control.palette[VAR_13] = (VAR_9 << 16) | (VAR_10 << 8) | (VAR_11);",
"}",
"wc3->palette_control.palette_changed = 1;",
"break;",
"case VGA__TAG:\nVAR_5= av_get_packet(pb, VAR_1, VAR_3);",
"VAR_1->stream_index = wc3->video_stream_index;",
"VAR_1->pts = wc3->pts;",
"VAR_4 = 1;",
"break;",
"case TEXT_TAG:\n#if 0\nurl_fseek(pb, VAR_3, SEEK_CUR);",
"#else\nif ((unsigned)VAR_3 > sizeof(VAR_6) || (VAR_5 = get_buffer(pb, VAR_6, VAR_3)) != VAR_3)\nVAR_5 = AVERROR(EIO);",
"else {",
"int VAR_13 = 0;",
"av_log (VAR_0, AV_LOG_DEBUG, \"Subtitle time!\\n\");",
"av_log (VAR_0, AV_LOG_DEBUG, \" inglish: %VAR_0\\n\", &VAR_6[VAR_13 + 1]);",
"VAR_13 += VAR_6[VAR_13] + 1;",
"av_log (VAR_0, AV_LOG_DEBUG, \" doytsch: %VAR_0\\n\", &VAR_6[VAR_13 + 1]);",
"VAR_13 += VAR_6[VAR_13] + 1;",
"av_log (VAR_0, AV_LOG_DEBUG, \" fronsay: %VAR_0\\n\", &VAR_6[VAR_13 + 1]);",
"}",
"#endif\nbreak;",
"case AUDI_TAG:\nVAR_5= av_get_packet(pb, VAR_1, VAR_3);",
"VAR_1->stream_index = wc3->audio_stream_index;",
"VAR_1->pts = wc3->pts;",
"wc3->pts++;",
"VAR_4 = 1;",
"break;",
"default:\nav_log (VAR_0, AV_LOG_ERROR, \" unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\\n\",\n(uint8_t)VAR_2, (uint8_t)(VAR_2 >> 8), (uint8_t)(VAR_2 >> 16), (uint8_t)(VAR_2 >> 24),\n(uint8_t)VAR_2, (uint8_t)(VAR_2 >> 8), (uint8_t)(VAR_2 >> 16), (uint8_t)(VAR_2 >> 24));",
"VAR_5 = AVERROR_INVALIDDATA;",
"VAR_4 = 1;",
"break;",
"}",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
39
],
[
41,
43
],
[
47
],
[
51,
55
],
[
59,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
109,
111
],
[
113,
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137,
139
],
[
143,
147
],
[
149
],
[
151
],
[
157
],
[
161
],
[
163
],
[
167,
169,
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
]
] |
25,251 | void hmp_info_memdev(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemdevList *memdev_list = qmp_query_memdev(&err);
MemdevList *m = memdev_list;
StringOutputVisitor *ov;
char *str;
int i = 0;
while (m) {
ov = string_output_visitor_new(false);
visit_type_uint16List(string_output_get_visitor(ov),
&m->value->host_nodes, NULL, NULL);
monitor_printf(mon, "memory backend: %d\n", i);
monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
monitor_printf(mon, " merge: %s\n",
m->value->merge ? "true" : "false");
monitor_printf(mon, " dump: %s\n",
m->value->dump ? "true" : "false");
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " policy: %s\n",
HostMemPolicy_lookup[m->value->policy]);
str = string_output_get_string(ov);
monitor_printf(mon, " host nodes: %s\n", str);
g_free(str);
string_output_visitor_cleanup(ov);
m = m->next;
i++;
}
monitor_printf(mon, "\n");
} | true | qemu | ecaf54a052c357e0bacb93c3f178fed34e4821ec | void hmp_info_memdev(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
MemdevList *memdev_list = qmp_query_memdev(&err);
MemdevList *m = memdev_list;
StringOutputVisitor *ov;
char *str;
int i = 0;
while (m) {
ov = string_output_visitor_new(false);
visit_type_uint16List(string_output_get_visitor(ov),
&m->value->host_nodes, NULL, NULL);
monitor_printf(mon, "memory backend: %d\n", i);
monitor_printf(mon, " size: %" PRId64 "\n", m->value->size);
monitor_printf(mon, " merge: %s\n",
m->value->merge ? "true" : "false");
monitor_printf(mon, " dump: %s\n",
m->value->dump ? "true" : "false");
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " policy: %s\n",
HostMemPolicy_lookup[m->value->policy]);
str = string_output_get_string(ov);
monitor_printf(mon, " host nodes: %s\n", str);
g_free(str);
string_output_visitor_cleanup(ov);
m = m->next;
i++;
}
monitor_printf(mon, "\n");
} | {
"code": [],
"line_no": []
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
Error *err = NULL;
MemdevList *memdev_list = qmp_query_memdev(&err);
MemdevList *m = memdev_list;
StringOutputVisitor *ov;
char *VAR_2;
int VAR_3 = 0;
while (m) {
ov = string_output_visitor_new(false);
visit_type_uint16List(string_output_get_visitor(ov),
&m->value->host_nodes, NULL, NULL);
monitor_printf(VAR_0, "memory backend: %d\n", VAR_3);
monitor_printf(VAR_0, " size: %" PRId64 "\n", m->value->size);
monitor_printf(VAR_0, " merge: %s\n",
m->value->merge ? "true" : "false");
monitor_printf(VAR_0, " dump: %s\n",
m->value->dump ? "true" : "false");
monitor_printf(VAR_0, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(VAR_0, " policy: %s\n",
HostMemPolicy_lookup[m->value->policy]);
VAR_2 = string_output_get_string(ov);
monitor_printf(VAR_0, " host nodes: %s\n", VAR_2);
g_free(VAR_2);
string_output_visitor_cleanup(ov);
m = m->next;
VAR_3++;
}
monitor_printf(VAR_0, "\n");
} | [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"Error *err = NULL;",
"MemdevList *memdev_list = qmp_query_memdev(&err);",
"MemdevList *m = memdev_list;",
"StringOutputVisitor *ov;",
"char *VAR_2;",
"int VAR_3 = 0;",
"while (m) {",
"ov = string_output_visitor_new(false);",
"visit_type_uint16List(string_output_get_visitor(ov),\n&m->value->host_nodes, NULL, NULL);",
"monitor_printf(VAR_0, \"memory backend: %d\\n\", VAR_3);",
"monitor_printf(VAR_0, \" size: %\" PRId64 \"\\n\", m->value->size);",
"monitor_printf(VAR_0, \" merge: %s\\n\",\nm->value->merge ? \"true\" : \"false\");",
"monitor_printf(VAR_0, \" dump: %s\\n\",\nm->value->dump ? \"true\" : \"false\");",
"monitor_printf(VAR_0, \" prealloc: %s\\n\",\nm->value->prealloc ? \"true\" : \"false\");",
"monitor_printf(VAR_0, \" policy: %s\\n\",\nHostMemPolicy_lookup[m->value->policy]);",
"VAR_2 = string_output_get_string(ov);",
"monitor_printf(VAR_0, \" host nodes: %s\\n\", VAR_2);",
"g_free(VAR_2);",
"string_output_visitor_cleanup(ov);",
"m = m->next;",
"VAR_3++;",
"}",
"monitor_printf(VAR_0, \"\\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
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12
],
[
13
],
[
14
],
[
15,
16
],
[
17,
18
],
[
19,
20
],
[
21,
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
]
] |
25,253 | static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
Error **err)
{
pid_t pid;
char *pmutils_path;
pmutils_path = g_find_program_in_path(pmutils_bin);
pid = fork();
if (pid == 0) {
/* child */
int fd;
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
if (pmutils_path) {
execle(pmutils_path, pmutils_bin, NULL, environ);
}
/*
* If we get here either pm-utils is not installed or execle() has
* failed. Let's try the manual method if the caller wants it.
*/
if (!sysfile_str) {
_exit(EXIT_FAILURE);
}
fd = open(LINUX_SYS_STATE_FILE, O_WRONLY);
if (fd < 0) {
_exit(EXIT_FAILURE);
}
if (write(fd, sysfile_str, strlen(sysfile_str)) < 0) {
_exit(EXIT_FAILURE);
}
_exit(EXIT_SUCCESS);
}
g_free(pmutils_path);
if (pid < 0) {
error_set(err, QERR_UNDEFINED_ERROR);
return;
}
}
| true | qemu | dc8764f06155a7b3e635e02281b747a9e292127e | static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
Error **err)
{
pid_t pid;
char *pmutils_path;
pmutils_path = g_find_program_in_path(pmutils_bin);
pid = fork();
if (pid == 0) {
int fd;
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
if (pmutils_path) {
execle(pmutils_path, pmutils_bin, NULL, environ);
}
if (!sysfile_str) {
_exit(EXIT_FAILURE);
}
fd = open(LINUX_SYS_STATE_FILE, O_WRONLY);
if (fd < 0) {
_exit(EXIT_FAILURE);
}
if (write(fd, sysfile_str, strlen(sysfile_str)) < 0) {
_exit(EXIT_FAILURE);
}
_exit(EXIT_SUCCESS);
}
g_free(pmutils_path);
if (pid < 0) {
error_set(err, QERR_UNDEFINED_ERROR);
return;
}
}
| {
"code": [
" pid_t pid;",
" error_set(err, QERR_UNDEFINED_ERROR);",
" _exit(EXIT_FAILURE);",
" _exit(EXIT_SUCCESS);",
" error_set(err, QERR_UNDEFINED_ERROR);",
" pid_t pid;",
" error_set(err, QERR_UNDEFINED_ERROR);"
],
"line_no": [
7,
93,
57,
81,
93,
7,
93
]
} | static void FUNC_0(const char *VAR_0, const char *VAR_1,
Error **VAR_2)
{
pid_t pid;
char *VAR_3;
VAR_3 = g_find_program_in_path(VAR_0);
pid = fork();
if (pid == 0) {
int VAR_4;
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
if (VAR_3) {
execle(VAR_3, VAR_0, NULL, environ);
}
if (!VAR_1) {
_exit(EXIT_FAILURE);
}
VAR_4 = open(LINUX_SYS_STATE_FILE, O_WRONLY);
if (VAR_4 < 0) {
_exit(EXIT_FAILURE);
}
if (write(VAR_4, VAR_1, strlen(VAR_1)) < 0) {
_exit(EXIT_FAILURE);
}
_exit(EXIT_SUCCESS);
}
g_free(VAR_3);
if (pid < 0) {
error_set(VAR_2, QERR_UNDEFINED_ERROR);
return;
}
}
| [
"static void FUNC_0(const char *VAR_0, const char *VAR_1,\nError **VAR_2)\n{",
"pid_t pid;",
"char *VAR_3;",
"VAR_3 = g_find_program_in_path(VAR_0);",
"pid = fork();",
"if (pid == 0) {",
"int VAR_4;",
"setsid();",
"reopen_fd_to_null(0);",
"reopen_fd_to_null(1);",
"reopen_fd_to_null(2);",
"if (VAR_3) {",
"execle(VAR_3, VAR_0, NULL, environ);",
"}",
"if (!VAR_1) {",
"_exit(EXIT_FAILURE);",
"}",
"VAR_4 = open(LINUX_SYS_STATE_FILE, O_WRONLY);",
"if (VAR_4 < 0) {",
"_exit(EXIT_FAILURE);",
"}",
"if (write(VAR_4, VAR_1, strlen(VAR_1)) < 0) {",
"_exit(EXIT_FAILURE);",
"}",
"_exit(EXIT_SUCCESS);",
"}",
"g_free(VAR_3);",
"if (pid < 0) {",
"error_set(VAR_2, QERR_UNDEFINED_ERROR);",
"return;",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
25,254 | static void test_qemu_strtoull_max(void)
{
const char *str = g_strdup_printf("%llu", ULLONG_MAX);
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
g_assert(endptr == str + strlen(str));
}
| true | qemu | d6f723b513a0c3c4e58343b7c52a2f9850861fa0 | static void test_qemu_strtoull_max(void)
{
const char *str = g_strdup_printf("%llu", ULLONG_MAX);
char f = 'X';
const char *endptr = &f;
uint64_t res = 999;
int err;
err = qemu_strtoull(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
g_assert(endptr == str + strlen(str));
}
| {
"code": [
" const char *str = g_strdup_printf(\"%llu\", ULLONG_MAX);"
],
"line_no": [
5
]
} | static void FUNC_0(void)
{
const char *VAR_0 = g_strdup_printf("%llu", ULLONG_MAX);
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
uint64_t res = 999;
int VAR_3;
VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert_cmpint(res, ==, ULLONG_MAX);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = g_strdup_printf(\"%llu\", ULLONG_MAX);",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"uint64_t res = 999;",
"int VAR_3;",
"VAR_3 = qemu_strtoull(VAR_0, &VAR_2, 0, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert_cmpint(res, ==, ULLONG_MAX);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,255 | static int rate_control(AVCodecContext *avctx, void *arg)
{
SliceArgs *slice_dat = arg;
VC2EncContext *s = slice_dat->ctx;
const int sx = slice_dat->x;
const int sy = slice_dat->y;
int quant_buf[2], bits_buf[2], quant = s->q_start, range = s->q_start/3;
const int64_t top = slice_dat->bits_ceil;
const double percent = s->tolerance;
const double bottom = top - top*(percent/100.0f);
int bits = count_hq_slice(s, sx, sy, quant);
range -= range & 1; /* Make it an even number */
while ((bits > top) || (bits < bottom)) {
range *= bits > top ? +1 : -1;
quant = av_clip(quant + range, 0, s->q_ceil);
bits = count_hq_slice(s, sx, sy, quant);
range = av_clip(range/2, 1, s->q_ceil);
if (quant_buf[1] == quant) {
quant = bits_buf[0] < bits ? quant_buf[0] : quant;
bits = bits_buf[0] < bits ? bits_buf[0] : bits;
break;
}
quant_buf[1] = quant_buf[0];
quant_buf[0] = quant;
bits_buf[1] = bits_buf[0];
bits_buf[0] = bits;
}
slice_dat->quant_idx = av_clip(quant, 0, s->q_ceil);
slice_dat->bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
return 0;
}
| true | FFmpeg | 7cdea450c67d24a3503a0eb64f491f58e474973f | static int rate_control(AVCodecContext *avctx, void *arg)
{
SliceArgs *slice_dat = arg;
VC2EncContext *s = slice_dat->ctx;
const int sx = slice_dat->x;
const int sy = slice_dat->y;
int quant_buf[2], bits_buf[2], quant = s->q_start, range = s->q_start/3;
const int64_t top = slice_dat->bits_ceil;
const double percent = s->tolerance;
const double bottom = top - top*(percent/100.0f);
int bits = count_hq_slice(s, sx, sy, quant);
range -= range & 1;
while ((bits > top) || (bits < bottom)) {
range *= bits > top ? +1 : -1;
quant = av_clip(quant + range, 0, s->q_ceil);
bits = count_hq_slice(s, sx, sy, quant);
range = av_clip(range/2, 1, s->q_ceil);
if (quant_buf[1] == quant) {
quant = bits_buf[0] < bits ? quant_buf[0] : quant;
bits = bits_buf[0] < bits ? bits_buf[0] : bits;
break;
}
quant_buf[1] = quant_buf[0];
quant_buf[0] = quant;
bits_buf[1] = bits_buf[0];
bits_buf[0] = bits;
}
slice_dat->quant_idx = av_clip(quant, 0, s->q_ceil);
slice_dat->bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
return 0;
}
| {
"code": [
" int quant_buf[2], bits_buf[2], quant = s->q_start, range = s->q_start/3;",
" quant = bits_buf[0] < bits ? quant_buf[0] : quant;",
" bits = bits_buf[0] < bits ? bits_buf[0] : bits;",
" bits_buf[1] = bits_buf[0];",
" bits_buf[0] = bits;"
],
"line_no": [
13,
37,
39,
49,
51
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1)
{
SliceArgs *slice_dat = VAR_1;
VC2EncContext *s = slice_dat->ctx;
const int VAR_2 = slice_dat->x;
const int VAR_3 = slice_dat->y;
int VAR_4[2], VAR_5[2], VAR_6 = s->q_start, VAR_7 = s->q_start/3;
const int64_t VAR_8 = slice_dat->bits_ceil;
const double VAR_9 = s->tolerance;
const double VAR_10 = VAR_8 - VAR_8*(VAR_9/100.0f);
int VAR_11 = count_hq_slice(s, VAR_2, VAR_3, VAR_6);
VAR_7 -= VAR_7 & 1;
while ((VAR_11 > VAR_8) || (VAR_11 < VAR_10)) {
VAR_7 *= VAR_11 > VAR_8 ? +1 : -1;
VAR_6 = av_clip(VAR_6 + VAR_7, 0, s->q_ceil);
VAR_11 = count_hq_slice(s, VAR_2, VAR_3, VAR_6);
VAR_7 = av_clip(VAR_7/2, 1, s->q_ceil);
if (VAR_4[1] == VAR_6) {
VAR_6 = VAR_5[0] < VAR_11 ? VAR_4[0] : VAR_6;
VAR_11 = VAR_5[0] < VAR_11 ? VAR_5[0] : VAR_11;
break;
}
VAR_4[1] = VAR_4[0];
VAR_4[0] = VAR_6;
VAR_5[1] = VAR_5[0];
VAR_5[0] = VAR_11;
}
slice_dat->quant_idx = av_clip(VAR_6, 0, s->q_ceil);
slice_dat->bytes = FFALIGN((VAR_11 >> 3), s->size_scaler) + 4 + s->prefix_bytes;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1)\n{",
"SliceArgs *slice_dat = VAR_1;",
"VC2EncContext *s = slice_dat->ctx;",
"const int VAR_2 = slice_dat->x;",
"const int VAR_3 = slice_dat->y;",
"int VAR_4[2], VAR_5[2], VAR_6 = s->q_start, VAR_7 = s->q_start/3;",
"const int64_t VAR_8 = slice_dat->bits_ceil;",
"const double VAR_9 = s->tolerance;",
"const double VAR_10 = VAR_8 - VAR_8*(VAR_9/100.0f);",
"int VAR_11 = count_hq_slice(s, VAR_2, VAR_3, VAR_6);",
"VAR_7 -= VAR_7 & 1;",
"while ((VAR_11 > VAR_8) || (VAR_11 < VAR_10)) {",
"VAR_7 *= VAR_11 > VAR_8 ? +1 : -1;",
"VAR_6 = av_clip(VAR_6 + VAR_7, 0, s->q_ceil);",
"VAR_11 = count_hq_slice(s, VAR_2, VAR_3, VAR_6);",
"VAR_7 = av_clip(VAR_7/2, 1, s->q_ceil);",
"if (VAR_4[1] == VAR_6) {",
"VAR_6 = VAR_5[0] < VAR_11 ? VAR_4[0] : VAR_6;",
"VAR_11 = VAR_5[0] < VAR_11 ? VAR_5[0] : VAR_11;",
"break;",
"}",
"VAR_4[1] = VAR_4[0];",
"VAR_4[0] = VAR_6;",
"VAR_5[1] = VAR_5[0];",
"VAR_5[0] = VAR_11;",
"}",
"slice_dat->quant_idx = av_clip(VAR_6, 0, s->q_ceil);",
"slice_dat->bytes = FFALIGN((VAR_11 >> 3), s->size_scaler) + 4 + s->prefix_bytes;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
25,257 | static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds,
uint64_t info_begin, uint64_t info_length)
{
BDRVDMGState *s = bs->opaque;
int ret;
uint32_t count, rsrc_data_offset;
uint8_t *buffer = NULL;
uint64_t info_end;
uint64_t offset;
/* read offset from begin of resource fork (info_begin) to resource data */
ret = read_uint32(bs, info_begin, &rsrc_data_offset);
if (ret < 0) {
goto fail;
} else if (rsrc_data_offset > info_length) {
ret = -EINVAL;
goto fail;
}
/* read length of resource data */
ret = read_uint32(bs, info_begin + 8, &count);
if (ret < 0) {
goto fail;
} else if (count == 0 || rsrc_data_offset + count > info_length) {
ret = -EINVAL;
goto fail;
}
/* begin of resource data (consisting of one or more resources) */
offset = info_begin + rsrc_data_offset;
/* end of resource data (there is possibly a following resource map
* which will be ignored). */
info_end = offset + count;
/* read offsets (mish blocks) from one or more resources in resource data */
while (offset < info_end) {
/* size of following resource */
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
goto fail;
} else if (count == 0) {
ret = -EINVAL;
goto fail;
}
offset += 4;
buffer = g_realloc(buffer, count);
ret = bdrv_pread(bs->file, offset, buffer, count);
if (ret < 0) {
goto fail;
}
ret = dmg_read_mish_block(s, ds, buffer, count);
if (ret < 0) {
goto fail;
}
/* advance offset by size of resource */
offset += count;
}
ret = 0;
fail:
g_free(buffer);
return ret;
}
| true | qemu | f6e6652d7c9251236fc1ecc6cece36104c7af15b | static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds,
uint64_t info_begin, uint64_t info_length)
{
BDRVDMGState *s = bs->opaque;
int ret;
uint32_t count, rsrc_data_offset;
uint8_t *buffer = NULL;
uint64_t info_end;
uint64_t offset;
ret = read_uint32(bs, info_begin, &rsrc_data_offset);
if (ret < 0) {
goto fail;
} else if (rsrc_data_offset > info_length) {
ret = -EINVAL;
goto fail;
}
ret = read_uint32(bs, info_begin + 8, &count);
if (ret < 0) {
goto fail;
} else if (count == 0 || rsrc_data_offset + count > info_length) {
ret = -EINVAL;
goto fail;
}
offset = info_begin + rsrc_data_offset;
info_end = offset + count;
while (offset < info_end) {
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
goto fail;
} else if (count == 0) {
ret = -EINVAL;
goto fail;
}
offset += 4;
buffer = g_realloc(buffer, count);
ret = bdrv_pread(bs->file, offset, buffer, count);
if (ret < 0) {
goto fail;
}
ret = dmg_read_mish_block(s, ds, buffer, count);
if (ret < 0) {
goto fail;
}
offset += count;
}
ret = 0;
fail:
g_free(buffer);
return ret;
}
| {
"code": [
" } else if (count == 0) {"
],
"line_no": [
83
]
} | static int FUNC_0(BlockDriverState *VAR_0, DmgHeaderState *VAR_1,
uint64_t VAR_2, uint64_t VAR_3)
{
BDRVDMGState *s = VAR_0->opaque;
int VAR_4;
uint32_t count, rsrc_data_offset;
uint8_t *buffer = NULL;
uint64_t info_end;
uint64_t offset;
VAR_4 = read_uint32(VAR_0, VAR_2, &rsrc_data_offset);
if (VAR_4 < 0) {
goto fail;
} else if (rsrc_data_offset > VAR_3) {
VAR_4 = -EINVAL;
goto fail;
}
VAR_4 = read_uint32(VAR_0, VAR_2 + 8, &count);
if (VAR_4 < 0) {
goto fail;
} else if (count == 0 || rsrc_data_offset + count > VAR_3) {
VAR_4 = -EINVAL;
goto fail;
}
offset = VAR_2 + rsrc_data_offset;
info_end = offset + count;
while (offset < info_end) {
VAR_4 = read_uint32(VAR_0, offset, &count);
if (VAR_4 < 0) {
goto fail;
} else if (count == 0) {
VAR_4 = -EINVAL;
goto fail;
}
offset += 4;
buffer = g_realloc(buffer, count);
VAR_4 = bdrv_pread(VAR_0->file, offset, buffer, count);
if (VAR_4 < 0) {
goto fail;
}
VAR_4 = dmg_read_mish_block(s, VAR_1, buffer, count);
if (VAR_4 < 0) {
goto fail;
}
offset += count;
}
VAR_4 = 0;
fail:
g_free(buffer);
return VAR_4;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, DmgHeaderState *VAR_1,\nuint64_t VAR_2, uint64_t VAR_3)\n{",
"BDRVDMGState *s = VAR_0->opaque;",
"int VAR_4;",
"uint32_t count, rsrc_data_offset;",
"uint8_t *buffer = NULL;",
"uint64_t info_end;",
"uint64_t offset;",
"VAR_4 = read_uint32(VAR_0, VAR_2, &rsrc_data_offset);",
"if (VAR_4 < 0) {",
"goto fail;",
"} else if (rsrc_data_offset > VAR_3) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"VAR_4 = read_uint32(VAR_0, VAR_2 + 8, &count);",
"if (VAR_4 < 0) {",
"goto fail;",
"} else if (count == 0 || rsrc_data_offset + count > VAR_3) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"offset = VAR_2 + rsrc_data_offset;",
"info_end = offset + count;",
"while (offset < info_end) {",
"VAR_4 = read_uint32(VAR_0, offset, &count);",
"if (VAR_4 < 0) {",
"goto fail;",
"} else if (count == 0) {",
"VAR_4 = -EINVAL;",
"goto fail;",
"}",
"offset += 4;",
"buffer = g_realloc(buffer, count);",
"VAR_4 = bdrv_pread(VAR_0->file, offset, buffer, count);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"VAR_4 = dmg_read_mish_block(s, VAR_1, buffer, count);",
"if (VAR_4 < 0) {",
"goto fail;",
"}",
"offset += count;",
"}",
"VAR_4 = 0;",
"fail:\ng_free(buffer);",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
67
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129
],
[
131
]
] |
25,258 | static int ogg_read_page(AVFormatContext *s, int *str)
{
AVIOContext *bc = s->pb;
struct ogg *ogg = s->priv_data;
struct ogg_stream *os;
int ret, i = 0;
int flags, nsegs;
uint64_t gp;
uint32_t serial;
int size, idx;
uint8_t sync[4];
int sp = 0;
ret = avio_read(bc, sync, 4);
if (ret < 4)
return ret < 0 ? ret : AVERROR_EOF;
do{
int c;
if (sync[sp & 3] == 'O' &&
sync[(sp + 1) & 3] == 'g' &&
sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
break;
c = avio_r8(bc);
if (bc->eof_reached)
return AVERROR_EOF;
sync[sp++ & 3] = c;
}while (i++ < MAX_PAGE_SIZE);
if (i >= MAX_PAGE_SIZE){
av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
return AVERROR_INVALIDDATA;
}
if (avio_r8(bc) != 0) /* version */
return AVERROR_INVALIDDATA;
flags = avio_r8(bc);
gp = avio_rl64 (bc);
serial = avio_rl32 (bc);
avio_skip(bc, 8); /* seq, crc */
nsegs = avio_r8(bc);
idx = ogg_find_stream (ogg, serial);
if (idx < 0){
if (ogg->headers) {
int n;
for (n = 0; n < ogg->nstreams; n++) {
av_freep(&ogg->streams[n].buf);
if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private)
av_freep(&ogg->streams[n].private);
}
ogg->curidx = -1;
ogg->nstreams = 0;
idx = ogg_new_stream(s, serial, 0);
} else {
idx = ogg_new_stream(s, serial, 1);
}
if (idx < 0)
return idx;
}
os = ogg->streams + idx;
os->page_pos = avio_tell(bc) - 27;
if(os->psize > 0)
ogg_new_buf(ogg, idx);
ret = avio_read(bc, os->segments, nsegs);
if (ret < nsegs)
return ret < 0 ? ret : AVERROR_EOF;
os->nsegs = nsegs;
os->segp = 0;
size = 0;
for (i = 0; i < nsegs; i++)
size += os->segments[i];
if (flags & OGG_FLAG_CONT || os->incomplete){
if (!os->psize){
while (os->segp < os->nsegs){
int seg = os->segments[os->segp++];
os->pstart += seg;
if (seg < 255)
break;
}
os->sync_pos = os->page_pos;
}
}else{
os->psize = 0;
os->sync_pos = os->page_pos;
}
if (os->bufsize - os->bufpos < size){
uint8_t *nb = av_malloc (os->bufsize *= 2);
memcpy (nb, os->buf, os->bufpos);
av_free (os->buf);
os->buf = nb;
}
ret = avio_read(bc, os->buf + os->bufpos, size);
if (ret < size)
return ret < 0 ? ret : AVERROR_EOF;
os->bufpos += size;
os->granule = gp;
os->flags = flags;
if (str)
*str = idx;
return 0;
}
| true | FFmpeg | ef0d779706c77ca9007527bd8d41e9400682f4e4 | static int ogg_read_page(AVFormatContext *s, int *str)
{
AVIOContext *bc = s->pb;
struct ogg *ogg = s->priv_data;
struct ogg_stream *os;
int ret, i = 0;
int flags, nsegs;
uint64_t gp;
uint32_t serial;
int size, idx;
uint8_t sync[4];
int sp = 0;
ret = avio_read(bc, sync, 4);
if (ret < 4)
return ret < 0 ? ret : AVERROR_EOF;
do{
int c;
if (sync[sp & 3] == 'O' &&
sync[(sp + 1) & 3] == 'g' &&
sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
break;
c = avio_r8(bc);
if (bc->eof_reached)
return AVERROR_EOF;
sync[sp++ & 3] = c;
}while (i++ < MAX_PAGE_SIZE);
if (i >= MAX_PAGE_SIZE){
av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
return AVERROR_INVALIDDATA;
}
if (avio_r8(bc) != 0)
return AVERROR_INVALIDDATA;
flags = avio_r8(bc);
gp = avio_rl64 (bc);
serial = avio_rl32 (bc);
avio_skip(bc, 8);
nsegs = avio_r8(bc);
idx = ogg_find_stream (ogg, serial);
if (idx < 0){
if (ogg->headers) {
int n;
for (n = 0; n < ogg->nstreams; n++) {
av_freep(&ogg->streams[n].buf);
if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private)
av_freep(&ogg->streams[n].private);
}
ogg->curidx = -1;
ogg->nstreams = 0;
idx = ogg_new_stream(s, serial, 0);
} else {
idx = ogg_new_stream(s, serial, 1);
}
if (idx < 0)
return idx;
}
os = ogg->streams + idx;
os->page_pos = avio_tell(bc) - 27;
if(os->psize > 0)
ogg_new_buf(ogg, idx);
ret = avio_read(bc, os->segments, nsegs);
if (ret < nsegs)
return ret < 0 ? ret : AVERROR_EOF;
os->nsegs = nsegs;
os->segp = 0;
size = 0;
for (i = 0; i < nsegs; i++)
size += os->segments[i];
if (flags & OGG_FLAG_CONT || os->incomplete){
if (!os->psize){
while (os->segp < os->nsegs){
int seg = os->segments[os->segp++];
os->pstart += seg;
if (seg < 255)
break;
}
os->sync_pos = os->page_pos;
}
}else{
os->psize = 0;
os->sync_pos = os->page_pos;
}
if (os->bufsize - os->bufpos < size){
uint8_t *nb = av_malloc (os->bufsize *= 2);
memcpy (nb, os->buf, os->bufpos);
av_free (os->buf);
os->buf = nb;
}
ret = avio_read(bc, os->buf + os->bufpos, size);
if (ret < size)
return ret < 0 ? ret : AVERROR_EOF;
os->bufpos += size;
os->granule = gp;
os->flags = flags;
if (str)
*str = idx;
return 0;
}
| {
"code": [
" uint8_t *nb = av_malloc (os->bufsize *= 2);"
],
"line_no": [
197
]
} | static int FUNC_0(AVFormatContext *VAR_0, int *VAR_1)
{
AVIOContext *bc = VAR_0->pb;
struct VAR_2 *VAR_2 = VAR_0->priv_data;
struct ogg_stream *VAR_3;
int VAR_4, VAR_5 = 0;
int VAR_6, VAR_7;
uint64_t gp;
uint32_t serial;
int VAR_8, VAR_9;
uint8_t sync[4];
int VAR_10 = 0;
VAR_4 = avio_read(bc, sync, 4);
if (VAR_4 < 4)
return VAR_4 < 0 ? VAR_4 : AVERROR_EOF;
do{
int VAR_11;
if (sync[VAR_10 & 3] == 'O' &&
sync[(VAR_10 + 1) & 3] == 'g' &&
sync[(VAR_10 + 2) & 3] == 'g' && sync[(VAR_10 + 3) & 3] == 'S')
break;
VAR_11 = avio_r8(bc);
if (bc->eof_reached)
return AVERROR_EOF;
sync[VAR_10++ & 3] = VAR_11;
}while (VAR_5++ < MAX_PAGE_SIZE);
if (VAR_5 >= MAX_PAGE_SIZE){
av_log (VAR_0, AV_LOG_INFO, "VAR_2, can't find sync word\VAR_12");
return AVERROR_INVALIDDATA;
}
if (avio_r8(bc) != 0)
return AVERROR_INVALIDDATA;
VAR_6 = avio_r8(bc);
gp = avio_rl64 (bc);
serial = avio_rl32 (bc);
avio_skip(bc, 8);
VAR_7 = avio_r8(bc);
VAR_9 = ogg_find_stream (VAR_2, serial);
if (VAR_9 < 0){
if (VAR_2->headers) {
int VAR_12;
for (VAR_12 = 0; VAR_12 < VAR_2->nstreams; VAR_12++) {
av_freep(&VAR_2->streams[VAR_12].buf);
if (!VAR_2->state || VAR_2->state->streams[VAR_12].private != VAR_2->streams[VAR_12].private)
av_freep(&VAR_2->streams[VAR_12].private);
}
VAR_2->curidx = -1;
VAR_2->nstreams = 0;
VAR_9 = ogg_new_stream(VAR_0, serial, 0);
} else {
VAR_9 = ogg_new_stream(VAR_0, serial, 1);
}
if (VAR_9 < 0)
return VAR_9;
}
VAR_3 = VAR_2->streams + VAR_9;
VAR_3->page_pos = avio_tell(bc) - 27;
if(VAR_3->psize > 0)
ogg_new_buf(VAR_2, VAR_9);
VAR_4 = avio_read(bc, VAR_3->segments, VAR_7);
if (VAR_4 < VAR_7)
return VAR_4 < 0 ? VAR_4 : AVERROR_EOF;
VAR_3->VAR_7 = VAR_7;
VAR_3->segp = 0;
VAR_8 = 0;
for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)
VAR_8 += VAR_3->segments[VAR_5];
if (VAR_6 & OGG_FLAG_CONT || VAR_3->incomplete){
if (!VAR_3->psize){
while (VAR_3->segp < VAR_3->VAR_7){
int VAR_13 = VAR_3->segments[VAR_3->segp++];
VAR_3->pstart += VAR_13;
if (VAR_13 < 255)
break;
}
VAR_3->sync_pos = VAR_3->page_pos;
}
}else{
VAR_3->psize = 0;
VAR_3->sync_pos = VAR_3->page_pos;
}
if (VAR_3->bufsize - VAR_3->bufpos < VAR_8){
uint8_t *nb = av_malloc (VAR_3->bufsize *= 2);
memcpy (nb, VAR_3->buf, VAR_3->bufpos);
av_free (VAR_3->buf);
VAR_3->buf = nb;
}
VAR_4 = avio_read(bc, VAR_3->buf + VAR_3->bufpos, VAR_8);
if (VAR_4 < VAR_8)
return VAR_4 < 0 ? VAR_4 : AVERROR_EOF;
VAR_3->bufpos += VAR_8;
VAR_3->granule = gp;
VAR_3->VAR_6 = VAR_6;
if (VAR_1)
*VAR_1 = VAR_9;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int *VAR_1)\n{",
"AVIOContext *bc = VAR_0->pb;",
"struct VAR_2 *VAR_2 = VAR_0->priv_data;",
"struct ogg_stream *VAR_3;",
"int VAR_4, VAR_5 = 0;",
"int VAR_6, VAR_7;",
"uint64_t gp;",
"uint32_t serial;",
"int VAR_8, VAR_9;",
"uint8_t sync[4];",
"int VAR_10 = 0;",
"VAR_4 = avio_read(bc, sync, 4);",
"if (VAR_4 < 4)\nreturn VAR_4 < 0 ? VAR_4 : AVERROR_EOF;",
"do{",
"int VAR_11;",
"if (sync[VAR_10 & 3] == 'O' &&\nsync[(VAR_10 + 1) & 3] == 'g' &&\nsync[(VAR_10 + 2) & 3] == 'g' && sync[(VAR_10 + 3) & 3] == 'S')\nbreak;",
"VAR_11 = avio_r8(bc);",
"if (bc->eof_reached)\nreturn AVERROR_EOF;",
"sync[VAR_10++ & 3] = VAR_11;",
"}while (VAR_5++ < MAX_PAGE_SIZE);",
"if (VAR_5 >= MAX_PAGE_SIZE){",
"av_log (VAR_0, AV_LOG_INFO, \"VAR_2, can't find sync word\\VAR_12\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (avio_r8(bc) != 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_6 = avio_r8(bc);",
"gp = avio_rl64 (bc);",
"serial = avio_rl32 (bc);",
"avio_skip(bc, 8);",
"VAR_7 = avio_r8(bc);",
"VAR_9 = ogg_find_stream (VAR_2, serial);",
"if (VAR_9 < 0){",
"if (VAR_2->headers) {",
"int VAR_12;",
"for (VAR_12 = 0; VAR_12 < VAR_2->nstreams; VAR_12++) {",
"av_freep(&VAR_2->streams[VAR_12].buf);",
"if (!VAR_2->state || VAR_2->state->streams[VAR_12].private != VAR_2->streams[VAR_12].private)\nav_freep(&VAR_2->streams[VAR_12].private);",
"}",
"VAR_2->curidx = -1;",
"VAR_2->nstreams = 0;",
"VAR_9 = ogg_new_stream(VAR_0, serial, 0);",
"} else {",
"VAR_9 = ogg_new_stream(VAR_0, serial, 1);",
"}",
"if (VAR_9 < 0)\nreturn VAR_9;",
"}",
"VAR_3 = VAR_2->streams + VAR_9;",
"VAR_3->page_pos = avio_tell(bc) - 27;",
"if(VAR_3->psize > 0)\nogg_new_buf(VAR_2, VAR_9);",
"VAR_4 = avio_read(bc, VAR_3->segments, VAR_7);",
"if (VAR_4 < VAR_7)\nreturn VAR_4 < 0 ? VAR_4 : AVERROR_EOF;",
"VAR_3->VAR_7 = VAR_7;",
"VAR_3->segp = 0;",
"VAR_8 = 0;",
"for (VAR_5 = 0; VAR_5 < VAR_7; VAR_5++)",
"VAR_8 += VAR_3->segments[VAR_5];",
"if (VAR_6 & OGG_FLAG_CONT || VAR_3->incomplete){",
"if (!VAR_3->psize){",
"while (VAR_3->segp < VAR_3->VAR_7){",
"int VAR_13 = VAR_3->segments[VAR_3->segp++];",
"VAR_3->pstart += VAR_13;",
"if (VAR_13 < 255)\nbreak;",
"}",
"VAR_3->sync_pos = VAR_3->page_pos;",
"}",
"}else{",
"VAR_3->psize = 0;",
"VAR_3->sync_pos = VAR_3->page_pos;",
"}",
"if (VAR_3->bufsize - VAR_3->bufpos < VAR_8){",
"uint8_t *nb = av_malloc (VAR_3->bufsize *= 2);",
"memcpy (nb, VAR_3->buf, VAR_3->bufpos);",
"av_free (VAR_3->buf);",
"VAR_3->buf = nb;",
"}",
"VAR_4 = avio_read(bc, VAR_3->buf + VAR_3->bufpos, VAR_8);",
"if (VAR_4 < VAR_8)\nreturn VAR_4 < 0 ? VAR_4 : AVERROR_EOF;",
"VAR_3->bufpos += VAR_8;",
"VAR_3->granule = gp;",
"VAR_3->VAR_6 = VAR_6;",
"if (VAR_1)\n*VAR_1 = VAR_9;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
41,
43,
45,
47
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
131
],
[
133
],
[
137,
139
],
[
143
],
[
145,
147
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211,
213
],
[
217
],
[
219
],
[
221
],
[
225,
227
],
[
231
],
[
233
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.