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
|
---|---|---|---|---|---|---|---|---|---|---|
23,101 | static BlockDriver *find_hdev_driver(const char *filename)
{
int score_max = 0, score;
BlockDriver *drv = NULL, *d;
QLIST_FOREACH(d, &bdrv_drivers, list) {
if (d->bdrv_probe_device) {
score = d->bdrv_probe_device(filename);
if (score > score_max) {
score_max = score;
drv = d;
}
}
}
return drv;
}
| false | qemu | 84a12e6648444f517055138a7d7f25a22d7e1029 | static BlockDriver *find_hdev_driver(const char *filename)
{
int score_max = 0, score;
BlockDriver *drv = NULL, *d;
QLIST_FOREACH(d, &bdrv_drivers, list) {
if (d->bdrv_probe_device) {
score = d->bdrv_probe_device(filename);
if (score > score_max) {
score_max = score;
drv = d;
}
}
}
return drv;
}
| {
"code": [],
"line_no": []
} | static BlockDriver *FUNC_0(const char *filename)
{
int VAR_0 = 0, VAR_1;
BlockDriver *drv = NULL, *d;
QLIST_FOREACH(d, &bdrv_drivers, list) {
if (d->bdrv_probe_device) {
VAR_1 = d->bdrv_probe_device(filename);
if (VAR_1 > VAR_0) {
VAR_0 = VAR_1;
drv = d;
}
}
}
return drv;
}
| [
"static BlockDriver *FUNC_0(const char *filename)\n{",
"int VAR_0 = 0, VAR_1;",
"BlockDriver *drv = NULL, *d;",
"QLIST_FOREACH(d, &bdrv_drivers, list) {",
"if (d->bdrv_probe_device) {",
"VAR_1 = d->bdrv_probe_device(filename);",
"if (VAR_1 > VAR_0) {",
"VAR_0 = VAR_1;",
"drv = d;",
"}",
"}",
"}",
"return drv;",
"}"
] | [
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
],
[
31
],
[
33
]
] |
23,103 | static void apb_pci_bridge_init(PCIBus *b)
{
PCIDevice *dev = pci_bridge_get_device(b);
/*
* command register:
* According to PCI bridge spec, after reset
* bus master bit is off
* memory space enable bit is off
* According to manual (805-1251.pdf).
* the reset value should be zero unless the boot pin is tied high
* (which is true) and thus it should be PCI_COMMAND_MEMORY.
*/
pci_set_word(dev->config + PCI_COMMAND,
PCI_COMMAND_MEMORY);
pci_set_word(dev->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);
pci_set_byte(dev->config + PCI_HEADER_TYPE,
pci_get_byte(dev->config + PCI_HEADER_TYPE) |
PCI_HEADER_TYPE_MULTI_FUNCTION);
}
| false | qemu | 6eab3de16d36c48a983366b09d0a0029a5260bc3 | static void apb_pci_bridge_init(PCIBus *b)
{
PCIDevice *dev = pci_bridge_get_device(b);
pci_set_word(dev->config + PCI_COMMAND,
PCI_COMMAND_MEMORY);
pci_set_word(dev->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);
pci_set_byte(dev->config + PCI_HEADER_TYPE,
pci_get_byte(dev->config + PCI_HEADER_TYPE) |
PCI_HEADER_TYPE_MULTI_FUNCTION);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIBus *VAR_0)
{
PCIDevice *dev = pci_bridge_get_device(VAR_0);
pci_set_word(dev->config + PCI_COMMAND,
PCI_COMMAND_MEMORY);
pci_set_word(dev->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);
pci_set_byte(dev->config + PCI_HEADER_TYPE,
pci_get_byte(dev->config + PCI_HEADER_TYPE) |
PCI_HEADER_TYPE_MULTI_FUNCTION);
}
| [
"static void FUNC_0(PCIBus *VAR_0)\n{",
"PCIDevice *dev = pci_bridge_get_device(VAR_0);",
"pci_set_word(dev->config + PCI_COMMAND,\nPCI_COMMAND_MEMORY);",
"pci_set_word(dev->config + PCI_STATUS,\nPCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |\nPCI_STATUS_DEVSEL_MEDIUM);",
"pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);",
"pci_set_byte(dev->config + PCI_HEADER_TYPE,\npci_get_byte(dev->config + PCI_HEADER_TYPE) |\nPCI_HEADER_TYPE_MULTI_FUNCTION);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
27,
29
],
[
31,
33,
35
],
[
37
],
[
39,
41,
43
],
[
45
]
] |
23,106 | static void tcg_out_setcond2(TCGContext *s, const TCGArg *args,
const int *const_args)
{
TCGArg new_args[6];
int label_true, label_over;
memcpy(new_args, args+1, 5*sizeof(TCGArg));
if (args[0] == args[1] || args[0] == args[2]
|| (!const_args[3] && args[0] == args[3])
|| (!const_args[4] && args[0] == args[4])) {
/* When the destination overlaps with one of the argument
registers, don't do anything tricky. */
label_true = label_arg(gen_new_label());
label_over = label_arg(gen_new_label());
new_args[5] = label_true;
tcg_out_brcond2(s, new_args, const_args+1, 1);
tcg_out_movi(s, TCG_TYPE_I32, args[0], 0);
tcg_out_jxx(s, JCC_JMP, label_over, 1);
tcg_out_label(s, label_true, s->code_ptr);
tcg_out_movi(s, TCG_TYPE_I32, args[0], 1);
tcg_out_label(s, label_over, s->code_ptr);
} else {
/* When the destination does not overlap one of the arguments,
clear the destination first, jump if cond false, and emit an
increment in the true case. This results in smaller code. */
tcg_out_movi(s, TCG_TYPE_I32, args[0], 0);
label_over = label_arg(gen_new_label());
new_args[4] = tcg_invert_cond(new_args[4]);
new_args[5] = label_over;
tcg_out_brcond2(s, new_args, const_args+1, 1);
tgen_arithi(s, ARITH_ADD, args[0], 1, 0);
tcg_out_label(s, label_over, s->code_ptr);
}
}
| false | qemu | bec1631100323fac0900aea71043d5c4e22fc2fa | static void tcg_out_setcond2(TCGContext *s, const TCGArg *args,
const int *const_args)
{
TCGArg new_args[6];
int label_true, label_over;
memcpy(new_args, args+1, 5*sizeof(TCGArg));
if (args[0] == args[1] || args[0] == args[2]
|| (!const_args[3] && args[0] == args[3])
|| (!const_args[4] && args[0] == args[4])) {
label_true = label_arg(gen_new_label());
label_over = label_arg(gen_new_label());
new_args[5] = label_true;
tcg_out_brcond2(s, new_args, const_args+1, 1);
tcg_out_movi(s, TCG_TYPE_I32, args[0], 0);
tcg_out_jxx(s, JCC_JMP, label_over, 1);
tcg_out_label(s, label_true, s->code_ptr);
tcg_out_movi(s, TCG_TYPE_I32, args[0], 1);
tcg_out_label(s, label_over, s->code_ptr);
} else {
tcg_out_movi(s, TCG_TYPE_I32, args[0], 0);
label_over = label_arg(gen_new_label());
new_args[4] = tcg_invert_cond(new_args[4]);
new_args[5] = label_over;
tcg_out_brcond2(s, new_args, const_args+1, 1);
tgen_arithi(s, ARITH_ADD, args[0], 1, 0);
tcg_out_label(s, label_over, s->code_ptr);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,
const int *VAR_2)
{
TCGArg new_args[6];
int VAR_3, VAR_4;
memcpy(new_args, VAR_1+1, 5*sizeof(TCGArg));
if (VAR_1[0] == VAR_1[1] || VAR_1[0] == VAR_1[2]
|| (!VAR_2[3] && VAR_1[0] == VAR_1[3])
|| (!VAR_2[4] && VAR_1[0] == VAR_1[4])) {
VAR_3 = label_arg(gen_new_label());
VAR_4 = label_arg(gen_new_label());
new_args[5] = VAR_3;
tcg_out_brcond2(VAR_0, new_args, VAR_2+1, 1);
tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 0);
tcg_out_jxx(VAR_0, JCC_JMP, VAR_4, 1);
tcg_out_label(VAR_0, VAR_3, VAR_0->code_ptr);
tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 1);
tcg_out_label(VAR_0, VAR_4, VAR_0->code_ptr);
} else {
tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 0);
VAR_4 = label_arg(gen_new_label());
new_args[4] = tcg_invert_cond(new_args[4]);
new_args[5] = VAR_4;
tcg_out_brcond2(VAR_0, new_args, VAR_2+1, 1);
tgen_arithi(VAR_0, ARITH_ADD, VAR_1[0], 1, 0);
tcg_out_label(VAR_0, VAR_4, VAR_0->code_ptr);
}
}
| [
"static void FUNC_0(TCGContext *VAR_0, const TCGArg *VAR_1,\nconst int *VAR_2)\n{",
"TCGArg new_args[6];",
"int VAR_3, VAR_4;",
"memcpy(new_args, VAR_1+1, 5*sizeof(TCGArg));",
"if (VAR_1[0] == VAR_1[1] || VAR_1[0] == VAR_1[2]\n|| (!VAR_2[3] && VAR_1[0] == VAR_1[3])\n|| (!VAR_2[4] && VAR_1[0] == VAR_1[4])) {",
"VAR_3 = label_arg(gen_new_label());",
"VAR_4 = label_arg(gen_new_label());",
"new_args[5] = VAR_3;",
"tcg_out_brcond2(VAR_0, new_args, VAR_2+1, 1);",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 0);",
"tcg_out_jxx(VAR_0, JCC_JMP, VAR_4, 1);",
"tcg_out_label(VAR_0, VAR_3, VAR_0->code_ptr);",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 1);",
"tcg_out_label(VAR_0, VAR_4, VAR_0->code_ptr);",
"} else {",
"tcg_out_movi(VAR_0, TCG_TYPE_I32, VAR_1[0], 0);",
"VAR_4 = label_arg(gen_new_label());",
"new_args[4] = tcg_invert_cond(new_args[4]);",
"new_args[5] = VAR_4;",
"tcg_out_brcond2(VAR_0, new_args, VAR_2+1, 1);",
"tgen_arithi(VAR_0, ARITH_ADD, VAR_1[0], 1, 0);",
"tcg_out_label(VAR_0, VAR_4, VAR_0->code_ptr);",
"}",
"}"
] | [
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
],
[
17,
19,
21
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
]
] |
23,107 | static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
QCowL2Meta *old_alloc;
QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {
uint64_t start = guest_offset >> s->cluster_bits;
uint64_t end = start + *nb_clusters;
uint64_t old_start = old_alloc->offset >> s->cluster_bits;
uint64_t old_end = old_start + old_alloc->nb_clusters;
if (end < old_start || start > old_end) {
/* No intersection */
} else {
if (start < old_start) {
/* Stop at the start of a running allocation */
*nb_clusters = old_start - start;
} else {
*nb_clusters = 0;
}
if (*nb_clusters == 0) {
/* Wait for the dependency to complete. We need to recheck
* the free/allocated clusters when we continue. */
qemu_co_mutex_unlock(&s->lock);
qemu_co_queue_wait(&old_alloc->dependent_requests);
qemu_co_mutex_lock(&s->lock);
return -EAGAIN;
}
}
}
if (!*nb_clusters) {
abort();
}
return 0;
}
| false | qemu | d9d74f4177af59bec23baa480d640709f56df0aa | static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
QCowL2Meta *old_alloc;
QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {
uint64_t start = guest_offset >> s->cluster_bits;
uint64_t end = start + *nb_clusters;
uint64_t old_start = old_alloc->offset >> s->cluster_bits;
uint64_t old_end = old_start + old_alloc->nb_clusters;
if (end < old_start || start > old_end) {
} else {
if (start < old_start) {
*nb_clusters = old_start - start;
} else {
*nb_clusters = 0;
}
if (*nb_clusters == 0) {
qemu_co_mutex_unlock(&s->lock);
qemu_co_queue_wait(&old_alloc->dependent_requests);
qemu_co_mutex_lock(&s->lock);
return -EAGAIN;
}
}
}
if (!*nb_clusters) {
abort();
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
unsigned int *VAR_2)
{
BDRVQcowState *s = VAR_0->opaque;
QCowL2Meta *old_alloc;
QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {
uint64_t start = VAR_1 >> s->cluster_bits;
uint64_t end = start + *VAR_2;
uint64_t old_start = old_alloc->offset >> s->cluster_bits;
uint64_t old_end = old_start + old_alloc->VAR_2;
if (end < old_start || start > old_end) {
} else {
if (start < old_start) {
*VAR_2 = old_start - start;
} else {
*VAR_2 = 0;
}
if (*VAR_2 == 0) {
qemu_co_mutex_unlock(&s->lock);
qemu_co_queue_wait(&old_alloc->dependent_requests);
qemu_co_mutex_lock(&s->lock);
return -EAGAIN;
}
}
}
if (!*VAR_2) {
abort();
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nunsigned int *VAR_2)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"QCowL2Meta *old_alloc;",
"QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {",
"uint64_t start = VAR_1 >> s->cluster_bits;",
"uint64_t end = start + *VAR_2;",
"uint64_t old_start = old_alloc->offset >> s->cluster_bits;",
"uint64_t old_end = old_start + old_alloc->VAR_2;",
"if (end < old_start || start > old_end) {",
"} else {",
"if (start < old_start) {",
"*VAR_2 = old_start - start;",
"} else {",
"*VAR_2 = 0;",
"}",
"if (*VAR_2 == 0) {",
"qemu_co_mutex_unlock(&s->lock);",
"qemu_co_queue_wait(&old_alloc->dependent_requests);",
"qemu_co_mutex_lock(&s->lock);",
"return -EAGAIN;",
"}",
"}",
"}",
"if (!*VAR_2) {",
"abort();",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
23,110 | char *g_strdup(const char *s)
{
char *dup;
size_t i;
if (!s) {
return NULL;
}
__coverity_string_null_sink__(s);
__coverity_string_size_sink__(s);
dup = __coverity_alloc_nosize__();
__coverity_mark_as_afm_allocated__(dup, AFM_free);
for (i = 0; (dup[i] = s[i]); i++) ;
return dup;
}
| false | qemu | 7ad4c7200111d20eb97eed4f46b6026e3f0b0eef | char *g_strdup(const char *s)
{
char *dup;
size_t i;
if (!s) {
return NULL;
}
__coverity_string_null_sink__(s);
__coverity_string_size_sink__(s);
dup = __coverity_alloc_nosize__();
__coverity_mark_as_afm_allocated__(dup, AFM_free);
for (i = 0; (dup[i] = s[i]); i++) ;
return dup;
}
| {
"code": [],
"line_no": []
} | char *FUNC_0(const char *VAR_0)
{
char *VAR_1;
size_t i;
if (!VAR_0) {
return NULL;
}
__coverity_string_null_sink__(VAR_0);
__coverity_string_size_sink__(VAR_0);
VAR_1 = __coverity_alloc_nosize__();
__coverity_mark_as_afm_allocated__(VAR_1, AFM_free);
for (i = 0; (VAR_1[i] = VAR_0[i]); i++) ;
return VAR_1;
}
| [
"char *FUNC_0(const char *VAR_0)\n{",
"char *VAR_1;",
"size_t i;",
"if (!VAR_0) {",
"return NULL;",
"}",
"__coverity_string_null_sink__(VAR_0);",
"__coverity_string_size_sink__(VAR_0);",
"VAR_1 = __coverity_alloc_nosize__();",
"__coverity_mark_as_afm_allocated__(VAR_1, AFM_free);",
"for (i = 0; (VAR_1[i] = VAR_0[i]); i++) ;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
23,111 | void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width4_msa(src, stride, dst, stride, 4);
}
| false | FFmpeg | 0105ed551cb9610c62b6920a301125781e1161a0 | void ff_avg_h264_qpel4_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width4_msa(src, stride, dst, stride, 4);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avg_width4_msa(VAR_1, VAR_2, VAR_0, VAR_2, 4);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avg_width4_msa(VAR_1, VAR_2, VAR_0, VAR_2, 4);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
23,113 | static int net_vhost_user_init(NetClientState *peer, const char *device,
const char *name, CharDriverState *chr)
{
NetClientState *nc;
VhostUserState *s;
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user to %s",
chr->label);
s = DO_UPCAST(VhostUserState, nc, nc);
/* We don't provide a receive callback */
s->nc.receive_disabled = 1;
s->chr = chr;
qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s);
return 0;
}
| false | qemu | b931bfbf042983f311b3b09894d8030b2755a638 | static int net_vhost_user_init(NetClientState *peer, const char *device,
const char *name, CharDriverState *chr)
{
NetClientState *nc;
VhostUserState *s;
nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user to %s",
chr->label);
s = DO_UPCAST(VhostUserState, nc, nc);
s->nc.receive_disabled = 1;
s->chr = chr;
qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,
const char *VAR_2, CharDriverState *VAR_3)
{
NetClientState *nc;
VhostUserState *s;
nc = qemu_new_net_client(&net_vhost_user_info, VAR_0, VAR_1, VAR_2);
snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user to %s",
VAR_3->label);
s = DO_UPCAST(VhostUserState, nc, nc);
s->nc.receive_disabled = 1;
s->VAR_3 = VAR_3;
qemu_chr_add_handlers(s->VAR_3, NULL, NULL, net_vhost_user_event, s);
return 0;
}
| [
"static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,\nconst char *VAR_2, CharDriverState *VAR_3)\n{",
"NetClientState *nc;",
"VhostUserState *s;",
"nc = qemu_new_net_client(&net_vhost_user_info, VAR_0, VAR_1, VAR_2);",
"snprintf(nc->info_str, sizeof(nc->info_str), \"vhost-user to %s\",\nVAR_3->label);",
"s = DO_UPCAST(VhostUserState, nc, nc);",
"s->nc.receive_disabled = 1;",
"s->VAR_3 = VAR_3;",
"qemu_chr_add_handlers(s->VAR_3, NULL, NULL, net_vhost_user_event, s);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17,
19
],
[
23
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
]
] |
23,114 | static int megasas_build_sense(MegasasCmd *cmd, uint8_t *sense_ptr,
uint8_t sense_len)
{
uint32_t pa_hi = 0, pa_lo;
target_phys_addr_t pa;
if (sense_len > cmd->frame->header.sense_len) {
sense_len = cmd->frame->header.sense_len;
}
if (sense_len) {
pa_lo = le32_to_cpu(cmd->frame->pass.sense_addr_lo);
if (megasas_frame_is_sense64(cmd)) {
pa_hi = le32_to_cpu(cmd->frame->pass.sense_addr_hi);
}
pa = ((uint64_t) pa_hi << 32) | pa_lo;
cpu_physical_memory_write(pa, sense_ptr, sense_len);
cmd->frame->header.sense_len = sense_len;
}
return sense_len;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static int megasas_build_sense(MegasasCmd *cmd, uint8_t *sense_ptr,
uint8_t sense_len)
{
uint32_t pa_hi = 0, pa_lo;
target_phys_addr_t pa;
if (sense_len > cmd->frame->header.sense_len) {
sense_len = cmd->frame->header.sense_len;
}
if (sense_len) {
pa_lo = le32_to_cpu(cmd->frame->pass.sense_addr_lo);
if (megasas_frame_is_sense64(cmd)) {
pa_hi = le32_to_cpu(cmd->frame->pass.sense_addr_hi);
}
pa = ((uint64_t) pa_hi << 32) | pa_lo;
cpu_physical_memory_write(pa, sense_ptr, sense_len);
cmd->frame->header.sense_len = sense_len;
}
return sense_len;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MegasasCmd *VAR_0, uint8_t *VAR_1,
uint8_t VAR_2)
{
uint32_t pa_hi = 0, pa_lo;
target_phys_addr_t pa;
if (VAR_2 > VAR_0->frame->header.VAR_2) {
VAR_2 = VAR_0->frame->header.VAR_2;
}
if (VAR_2) {
pa_lo = le32_to_cpu(VAR_0->frame->pass.sense_addr_lo);
if (megasas_frame_is_sense64(VAR_0)) {
pa_hi = le32_to_cpu(VAR_0->frame->pass.sense_addr_hi);
}
pa = ((uint64_t) pa_hi << 32) | pa_lo;
cpu_physical_memory_write(pa, VAR_1, VAR_2);
VAR_0->frame->header.VAR_2 = VAR_2;
}
return VAR_2;
}
| [
"static int FUNC_0(MegasasCmd *VAR_0, uint8_t *VAR_1,\nuint8_t VAR_2)\n{",
"uint32_t pa_hi = 0, pa_lo;",
"target_phys_addr_t pa;",
"if (VAR_2 > VAR_0->frame->header.VAR_2) {",
"VAR_2 = VAR_0->frame->header.VAR_2;",
"}",
"if (VAR_2) {",
"pa_lo = le32_to_cpu(VAR_0->frame->pass.sense_addr_lo);",
"if (megasas_frame_is_sense64(VAR_0)) {",
"pa_hi = le32_to_cpu(VAR_0->frame->pass.sense_addr_hi);",
"}",
"pa = ((uint64_t) pa_hi << 32) | pa_lo;",
"cpu_physical_memory_write(pa, VAR_1, VAR_2);",
"VAR_0->frame->header.VAR_2 = VAR_2;",
"}",
"return VAR_2;",
"}"
] | [
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
]
] |
23,115 | MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
size_t max_len, hwaddr addr, const char *fw_file_name,
FWCfgReadCallback fw_callback, void *callback_opaque)
{
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
Rom *rom;
MemoryRegion *mr = NULL;
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(name);
rom->addr = addr;
rom->romsize = max_len ? max_len : len;
rom->datasize = len;
rom->data = g_malloc0(rom->datasize);
memcpy(rom->data, blob, len);
rom_insert(rom);
if (fw_file_name && fw_cfg) {
char devpath[100];
void *data;
snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
if (mc->rom_file_has_mr) {
data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
mr = rom->mr;
} else {
data = rom->data;
}
fw_cfg_add_file_callback(fw_cfg, fw_file_name,
fw_callback, callback_opaque,
data, rom->datasize);
}
return mr;
}
| false | qemu | aa6c6ae843cbdc251224bc6170d2663ac929b04f | MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
size_t max_len, hwaddr addr, const char *fw_file_name,
FWCfgReadCallback fw_callback, void *callback_opaque)
{
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
Rom *rom;
MemoryRegion *mr = NULL;
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(name);
rom->addr = addr;
rom->romsize = max_len ? max_len : len;
rom->datasize = len;
rom->data = g_malloc0(rom->datasize);
memcpy(rom->data, blob, len);
rom_insert(rom);
if (fw_file_name && fw_cfg) {
char devpath[100];
void *data;
snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
if (mc->rom_file_has_mr) {
data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
mr = rom->mr;
} else {
data = rom->data;
}
fw_cfg_add_file_callback(fw_cfg, fw_file_name,
fw_callback, callback_opaque,
data, rom->datasize);
}
return mr;
}
| {
"code": [],
"line_no": []
} | MemoryRegion *FUNC_0(const char *name, const void *blob, size_t len,
size_t max_len, hwaddr addr, const char *fw_file_name,
FWCfgReadCallback fw_callback, void *callback_opaque)
{
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
Rom *rom;
MemoryRegion *mr = NULL;
rom = g_malloc0(sizeof(*rom));
rom->name = g_strdup(name);
rom->addr = addr;
rom->romsize = max_len ? max_len : len;
rom->datasize = len;
rom->VAR_1 = g_malloc0(rom->datasize);
memcpy(rom->VAR_1, blob, len);
rom_insert(rom);
if (fw_file_name && fw_cfg) {
char VAR_0[100];
void *VAR_1;
snprintf(VAR_0, sizeof(VAR_0), "/rom@%s", fw_file_name);
if (mc->rom_file_has_mr) {
VAR_1 = rom_set_mr(rom, OBJECT(fw_cfg), VAR_0);
mr = rom->mr;
} else {
VAR_1 = rom->VAR_1;
}
fw_cfg_add_file_callback(fw_cfg, fw_file_name,
fw_callback, callback_opaque,
VAR_1, rom->datasize);
}
return mr;
}
| [
"MemoryRegion *FUNC_0(const char *name, const void *blob, size_t len,\nsize_t max_len, hwaddr addr, const char *fw_file_name,\nFWCfgReadCallback fw_callback, void *callback_opaque)\n{",
"MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());",
"Rom *rom;",
"MemoryRegion *mr = NULL;",
"rom = g_malloc0(sizeof(*rom));",
"rom->name = g_strdup(name);",
"rom->addr = addr;",
"rom->romsize = max_len ? max_len : len;",
"rom->datasize = len;",
"rom->VAR_1 = g_malloc0(rom->datasize);",
"memcpy(rom->VAR_1, blob, len);",
"rom_insert(rom);",
"if (fw_file_name && fw_cfg) {",
"char VAR_0[100];",
"void *VAR_1;",
"snprintf(VAR_0, sizeof(VAR_0), \"/rom@%s\", fw_file_name);",
"if (mc->rom_file_has_mr) {",
"VAR_1 = rom_set_mr(rom, OBJECT(fw_cfg), VAR_0);",
"mr = rom->mr;",
"} else {",
"VAR_1 = rom->VAR_1;",
"}",
"fw_cfg_add_file_callback(fw_cfg, fw_file_name,\nfw_callback, callback_opaque,\nVAR_1, rom->datasize);",
"}",
"return mr;",
"}"
] | [
0,
0,
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
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
65
],
[
67
],
[
69
]
] |
23,117 | static uint64_t sysctl_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistSysctlState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_TIMER0_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer0);
/* milkymist timer counts up */
r = s->regs[R_TIMER0_COMPARE] - r;
break;
case R_TIMER1_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer1);
/* milkymist timer counts up */
r = s->regs[R_TIMER1_COMPARE] - r;
break;
case R_GPIO_IN:
case R_GPIO_OUT:
case R_GPIO_INTEN:
case R_TIMER0_CONTROL:
case R_TIMER0_COMPARE:
case R_TIMER1_CONTROL:
case R_TIMER1_COMPARE:
case R_ICAP:
case R_DBG_SCRATCHPAD:
case R_DBG_WRITE_LOCK:
case R_CLK_FREQUENCY:
case R_CAPABILITIES:
case R_SYSTEM_ID:
r = s->regs[addr];
break;
default:
error_report("milkymist_sysctl: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_sysctl_memory_read(addr << 2, r);
return r;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t sysctl_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistSysctlState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_TIMER0_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer0);
r = s->regs[R_TIMER0_COMPARE] - r;
break;
case R_TIMER1_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer1);
r = s->regs[R_TIMER1_COMPARE] - r;
break;
case R_GPIO_IN:
case R_GPIO_OUT:
case R_GPIO_INTEN:
case R_TIMER0_CONTROL:
case R_TIMER0_COMPARE:
case R_TIMER1_CONTROL:
case R_TIMER1_COMPARE:
case R_ICAP:
case R_DBG_SCRATCHPAD:
case R_DBG_WRITE_LOCK:
case R_CLK_FREQUENCY:
case R_CAPABILITIES:
case R_SYSTEM_ID:
r = s->regs[addr];
break;
default:
error_report("milkymist_sysctl: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_sysctl_memory_read(addr << 2, r);
return r;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MilkymistSysctlState *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_TIMER0_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer0);
r = s->regs[R_TIMER0_COMPARE] - r;
break;
case R_TIMER1_COUNTER:
r = (uint32_t)ptimer_get_count(s->ptimer1);
r = s->regs[R_TIMER1_COMPARE] - r;
break;
case R_GPIO_IN:
case R_GPIO_OUT:
case R_GPIO_INTEN:
case R_TIMER0_CONTROL:
case R_TIMER0_COMPARE:
case R_TIMER1_CONTROL:
case R_TIMER1_COMPARE:
case R_ICAP:
case R_DBG_SCRATCHPAD:
case R_DBG_WRITE_LOCK:
case R_CLK_FREQUENCY:
case R_CAPABILITIES:
case R_SYSTEM_ID:
r = s->regs[addr];
break;
default:
error_report("milkymist_sysctl: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_sysctl_memory_read(addr << 2, r);
return r;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"MilkymistSysctlState *s = opaque;",
"uint32_t r = 0;",
"addr >>= 2;",
"switch (addr) {",
"case R_TIMER0_COUNTER:\nr = (uint32_t)ptimer_get_count(s->ptimer0);",
"r = s->regs[R_TIMER0_COMPARE] - r;",
"break;",
"case R_TIMER1_COUNTER:\nr = (uint32_t)ptimer_get_count(s->ptimer1);",
"r = s->regs[R_TIMER1_COMPARE] - r;",
"break;",
"case R_GPIO_IN:\ncase R_GPIO_OUT:\ncase R_GPIO_INTEN:\ncase R_TIMER0_CONTROL:\ncase R_TIMER0_COMPARE:\ncase R_TIMER1_CONTROL:\ncase R_TIMER1_COMPARE:\ncase R_ICAP:\ncase R_DBG_SCRATCHPAD:\ncase R_DBG_WRITE_LOCK:\ncase R_CLK_FREQUENCY:\ncase R_CAPABILITIES:\ncase R_SYSTEM_ID:\nr = s->regs[addr];",
"break;",
"default:\nerror_report(\"milkymist_sysctl: read access to unknown register 0x\"\nTARGET_FMT_plx, addr << 2);",
"break;",
"}",
"trace_milkymist_sysctl_memory_read(addr << 2, r);",
"return r;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27,
29
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63
],
[
65
],
[
69,
71,
73
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87
]
] |
23,118 | static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
BDRVVmdkState *s = bs->opaque;
int64_t index_in_cluster, n, ret;
uint64_t offset;
VmdkExtent *extent;
extent = find_extent(s, sector_num, NULL);
if (!extent) {
return 0;
}
ret = get_cluster_offset(bs, extent, NULL,
sector_num * 512, 0, &offset);
/* get_cluster_offset returning 0 means success */
ret = !ret;
index_in_cluster = sector_num % extent->cluster_sectors;
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
*pnum = n;
return ret;
}
| false | qemu | f8a2e5e3ca6146d4cc66a4750daf44a0cf043319 | static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
BDRVVmdkState *s = bs->opaque;
int64_t index_in_cluster, n, ret;
uint64_t offset;
VmdkExtent *extent;
extent = find_extent(s, sector_num, NULL);
if (!extent) {
return 0;
}
ret = get_cluster_offset(bs, extent, NULL,
sector_num * 512, 0, &offset);
ret = !ret;
index_in_cluster = sector_num % extent->cluster_sectors;
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
*pnum = n;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, int *VAR_3)
{
BDRVVmdkState *s = VAR_0->opaque;
int64_t index_in_cluster, n, ret;
uint64_t offset;
VmdkExtent *extent;
extent = find_extent(s, VAR_1, NULL);
if (!extent) {
return 0;
}
ret = get_cluster_offset(VAR_0, extent, NULL,
VAR_1 * 512, 0, &offset);
ret = !ret;
index_in_cluster = VAR_1 % extent->cluster_sectors;
n = extent->cluster_sectors - index_in_cluster;
if (n > VAR_2) {
n = VAR_2;
}
*VAR_3 = n;
return ret;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nint VAR_2, int *VAR_3)\n{",
"BDRVVmdkState *s = VAR_0->opaque;",
"int64_t index_in_cluster, n, ret;",
"uint64_t offset;",
"VmdkExtent *extent;",
"extent = find_extent(s, VAR_1, NULL);",
"if (!extent) {",
"return 0;",
"}",
"ret = get_cluster_offset(VAR_0, extent, NULL,\nVAR_1 * 512, 0, &offset);",
"ret = !ret;",
"index_in_cluster = VAR_1 % extent->cluster_sectors;",
"n = extent->cluster_sectors - index_in_cluster;",
"if (n > VAR_2) {",
"n = VAR_2;",
"}",
"*VAR_3 = n;",
"return ret;",
"}"
] | [
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
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
23,119 | void acpi_setup(PcGuestInfo *guest_info)
{
AcpiBuildTables tables;
AcpiBuildState *build_state;
if (!guest_info->fw_cfg) {
ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
return;
}
if (!guest_info->has_acpi_build) {
ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n");
return;
}
if (!acpi_enabled) {
ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
return;
}
build_state = g_malloc0(sizeof *build_state);
build_state->guest_info = guest_info;
acpi_set_pci_info();
acpi_build_tables_init(&tables);
acpi_build(build_state->guest_info, &tables);
/* Now expose it all to Guest */
build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_MAX_SIZE);
assert(build_state->table_ram != RAM_ADDR_MAX);
build_state->table_size = acpi_data_len(tables.table_data);
build_state->linker_ram =
acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0);
build_state->linker_size = acpi_data_len(tables.linker);
fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
tables.tcpalog->data, acpi_data_len(tables.tcpalog));
if (guest_info->has_immutable_rsdp) {
/*
* Keep for compatibility with old machine types.
* Though RSDP is small, its contents isn't immutable, so
* update it along with the rest of tables on guest access.
*/
fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
acpi_build_update, build_state,
tables.rsdp->data, acpi_data_len(tables.rsdp));
build_state->rsdp = tables.rsdp->data;
} else {
build_state->rsdp = qemu_get_ram_ptr(
acpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0)
);
}
qemu_register_reset(acpi_build_reset, build_state);
acpi_build_reset(build_state);
vmstate_register(NULL, 0, &vmstate_acpi_build, build_state);
/* Cleanup tables but don't free the memory: we track it
* in build_state.
*/
acpi_build_tables_cleanup(&tables, false);
}
| false | qemu | 42d859001d180ea788aa2d34a7be021ac8c447f2 | void acpi_setup(PcGuestInfo *guest_info)
{
AcpiBuildTables tables;
AcpiBuildState *build_state;
if (!guest_info->fw_cfg) {
ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
return;
}
if (!guest_info->has_acpi_build) {
ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n");
return;
}
if (!acpi_enabled) {
ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
return;
}
build_state = g_malloc0(sizeof *build_state);
build_state->guest_info = guest_info;
acpi_set_pci_info();
acpi_build_tables_init(&tables);
acpi_build(build_state->guest_info, &tables);
build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_MAX_SIZE);
assert(build_state->table_ram != RAM_ADDR_MAX);
build_state->table_size = acpi_data_len(tables.table_data);
build_state->linker_ram =
acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0);
build_state->linker_size = acpi_data_len(tables.linker);
fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
tables.tcpalog->data, acpi_data_len(tables.tcpalog));
if (guest_info->has_immutable_rsdp) {
fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
acpi_build_update, build_state,
tables.rsdp->data, acpi_data_len(tables.rsdp));
build_state->rsdp = tables.rsdp->data;
} else {
build_state->rsdp = qemu_get_ram_ptr(
acpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0)
);
}
qemu_register_reset(acpi_build_reset, build_state);
acpi_build_reset(build_state);
vmstate_register(NULL, 0, &vmstate_acpi_build, build_state);
acpi_build_tables_cleanup(&tables, false);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PcGuestInfo *VAR_0)
{
AcpiBuildTables tables;
AcpiBuildState *build_state;
if (!VAR_0->fw_cfg) {
ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n");
return;
}
if (!VAR_0->has_acpi_build) {
ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n");
return;
}
if (!acpi_enabled) {
ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n");
return;
}
build_state = g_malloc0(sizeof *build_state);
build_state->VAR_0 = VAR_0;
acpi_set_pci_info();
acpi_build_tables_init(&tables);
acpi_build(build_state->VAR_0, &tables);
build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_MAX_SIZE);
assert(build_state->table_ram != RAM_ADDR_MAX);
build_state->table_size = acpi_data_len(tables.table_data);
build_state->linker_ram =
acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0);
build_state->linker_size = acpi_data_len(tables.linker);
fw_cfg_add_file(VAR_0->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
tables.tcpalog->data, acpi_data_len(tables.tcpalog));
if (VAR_0->has_immutable_rsdp) {
fw_cfg_add_file_callback(VAR_0->fw_cfg, ACPI_BUILD_RSDP_FILE,
acpi_build_update, build_state,
tables.rsdp->data, acpi_data_len(tables.rsdp));
build_state->rsdp = tables.rsdp->data;
} else {
build_state->rsdp = qemu_get_ram_ptr(
acpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0)
);
}
qemu_register_reset(acpi_build_reset, build_state);
acpi_build_reset(build_state);
vmstate_register(NULL, 0, &vmstate_acpi_build, build_state);
acpi_build_tables_cleanup(&tables, false);
}
| [
"void FUNC_0(PcGuestInfo *VAR_0)\n{",
"AcpiBuildTables tables;",
"AcpiBuildState *build_state;",
"if (!VAR_0->fw_cfg) {",
"ACPI_BUILD_DPRINTF(\"No fw cfg. Bailing out.\\n\");",
"return;",
"}",
"if (!VAR_0->has_acpi_build) {",
"ACPI_BUILD_DPRINTF(\"ACPI build disabled. Bailing out.\\n\");",
"return;",
"}",
"if (!acpi_enabled) {",
"ACPI_BUILD_DPRINTF(\"ACPI disabled. Bailing out.\\n\");",
"return;",
"}",
"build_state = g_malloc0(sizeof *build_state);",
"build_state->VAR_0 = VAR_0;",
"acpi_set_pci_info();",
"acpi_build_tables_init(&tables);",
"acpi_build(build_state->VAR_0, &tables);",
"build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,\nACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_MAX_SIZE);",
"assert(build_state->table_ram != RAM_ADDR_MAX);",
"build_state->table_size = acpi_data_len(tables.table_data);",
"build_state->linker_ram =\nacpi_add_rom_blob(build_state, tables.linker, \"etc/table-loader\", 0);",
"build_state->linker_size = acpi_data_len(tables.linker);",
"fw_cfg_add_file(VAR_0->fw_cfg, ACPI_BUILD_TPMLOG_FILE,\ntables.tcpalog->data, acpi_data_len(tables.tcpalog));",
"if (VAR_0->has_immutable_rsdp) {",
"fw_cfg_add_file_callback(VAR_0->fw_cfg, ACPI_BUILD_RSDP_FILE,\nacpi_build_update, build_state,\ntables.rsdp->data, acpi_data_len(tables.rsdp));",
"build_state->rsdp = tables.rsdp->data;",
"} else {",
"build_state->rsdp = qemu_get_ram_ptr(\nacpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0)\n);",
"}",
"qemu_register_reset(acpi_build_reset, build_state);",
"acpi_build_reset(build_state);",
"vmstate_register(NULL, 0, &vmstate_acpi_build, build_state);",
"acpi_build_tables_cleanup(&tables, false);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
49
],
[
53
],
[
55
],
[
61,
63,
65
],
[
67
],
[
69
],
[
73,
75
],
[
77
],
[
81,
83
],
[
87
],
[
99,
101,
103
],
[
105
],
[
107
],
[
109,
111,
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
133
],
[
135
]
] |
23,120 | static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
smbios_legacy_mode = true;
has_reserved_memory = false;
pc_set_legacy_acpi_data_size();
}
| false | qemu | 7102fa7073b2cefb33ab4012a11f15fbf297a74b | static void pc_compat_2_0(MachineState *machine)
{
pc_compat_2_1(machine);
smbios_legacy_mode = true;
has_reserved_memory = false;
pc_set_legacy_acpi_data_size();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MachineState *VAR_0)
{
pc_compat_2_1(VAR_0);
smbios_legacy_mode = true;
has_reserved_memory = false;
pc_set_legacy_acpi_data_size();
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"pc_compat_2_1(VAR_0);",
"smbios_legacy_mode = true;",
"has_reserved_memory = false;",
"pc_set_legacy_acpi_data_size();",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
23,121 | static void apic_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void apic_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"}"
] | [
0,
0
] | [
[
1,
3
],
[
5
]
] |
23,122 | static int cdrom_read_toc_raw(IDEState *s, uint8_t *buf, int msf,
int session_num)
{
uint8_t *q;
int nb_sectors, len;
q = buf + 2;
*q++ = 1; /* first session */
*q++ = 1; /* last session */
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa0; /* lead-in */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
*q++ = 1; /* first track */
*q++ = 0x00; /* disk type */
*q++ = 0x00;
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa1;
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
*q++ = 1; /* last track */
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1; /* session number */
*q++ = 0x14; /* data track */
*q++ = 0; /* track number */
*q++ = 0xa2; /* lead-out */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
nb_sectors = s->nb_sectors >> 2;
if (msf) {
*q++ = 0; /* reserved */
lba_to_msf(q, nb_sectors);
q += 3;
} else {
cpu_to_ube32(q, nb_sectors);
q += 4;
}
*q++ = 1; /* session number */
*q++ = 0x14; /* ADR, control */
*q++ = 0; /* track number */
*q++ = 1; /* point */
*q++ = 0; /* min */
*q++ = 0; /* sec */
*q++ = 0; /* frame */
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
len = q - buf;
cpu_to_ube16(buf, len - 2);
return len;
}
| false | qemu | a368741bf2508b7ca29d9ade73ec1b0f29ae2286 | static int cdrom_read_toc_raw(IDEState *s, uint8_t *buf, int msf,
int session_num)
{
uint8_t *q;
int nb_sectors, len;
q = buf + 2;
*q++ = 1;
*q++ = 1;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 1;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa1;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 1;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa2;
*q++ = 0;
*q++ = 0;
*q++ = 0;
nb_sectors = s->nb_sectors >> 2;
if (msf) {
*q++ = 0;
lba_to_msf(q, nb_sectors);
q += 3;
} else {
cpu_to_ube32(q, nb_sectors);
q += 4;
}
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 1;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
len = q - buf;
cpu_to_ube16(buf, len - 2);
return len;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IDEState *VAR_0, uint8_t *VAR_1, int VAR_2,
int VAR_3)
{
uint8_t *q;
int VAR_4, VAR_5;
q = VAR_1 + 2;
*q++ = 1;
*q++ = 1;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 1;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa1;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 1;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 0xa2;
*q++ = 0;
*q++ = 0;
*q++ = 0;
VAR_4 = VAR_0->VAR_4 >> 2;
if (VAR_2) {
*q++ = 0;
lba_to_msf(q, VAR_4);
q += 3;
} else {
cpu_to_ube32(q, VAR_4);
q += 4;
}
*q++ = 1;
*q++ = 0x14;
*q++ = 0;
*q++ = 1;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
*q++ = 0;
VAR_5 = q - VAR_1;
cpu_to_ube16(VAR_1, VAR_5 - 2);
return VAR_5;
}
| [
"static int FUNC_0(IDEState *VAR_0, uint8_t *VAR_1, int VAR_2,\nint VAR_3)\n{",
"uint8_t *q;",
"int VAR_4, VAR_5;",
"q = VAR_1 + 2;",
"*q++ = 1;",
"*q++ = 1;",
"*q++ = 1;",
"*q++ = 0x14;",
"*q++ = 0;",
"*q++ = 0xa0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 1;",
"*q++ = 0x00;",
"*q++ = 0x00;",
"*q++ = 1;",
"*q++ = 0x14;",
"*q++ = 0;",
"*q++ = 0xa1;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 1;",
"*q++ = 0x00;",
"*q++ = 0x00;",
"*q++ = 1;",
"*q++ = 0x14;",
"*q++ = 0;",
"*q++ = 0xa2;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"VAR_4 = VAR_0->VAR_4 >> 2;",
"if (VAR_2) {",
"*q++ = 0;",
"lba_to_msf(q, VAR_4);",
"q += 3;",
"} else {",
"cpu_to_ube32(q, VAR_4);",
"q += 4;",
"}",
"*q++ = 1;",
"*q++ = 0x14;",
"*q++ = 0;",
"*q++ = 1;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"*q++ = 0;",
"VAR_5 = q - VAR_1;",
"cpu_to_ube16(VAR_1, VAR_5 - 2);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
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
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
23,124 | static void virtio_ccw_rng_instance_init(Object *obj)
{
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
}
| true | qemu | 9561fda8d90e176bef598ba87c42a1bd6ad03ef7 | static void virtio_ccw_rng_instance_init(Object *obj)
{
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
}
| {
"code": [
" (Object **)&dev->vdev.conf.rng, NULL);",
" (Object **)&dev->vdev.conf.rng, NULL);",
" (Object **)&dev->vdev.conf.rng, NULL);"
],
"line_no": [
13,
13,
13
]
} | static void FUNC_0(Object *VAR_0)
{
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(VAR_0);
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(VAR_0, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(VAR_0, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"VirtIORNGCcw *dev = VIRTIO_RNG_CCW(VAR_0);",
"object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);",
"object_property_add_child(VAR_0, \"virtio-backend\", OBJECT(&dev->vdev), NULL);",
"object_property_add_link(VAR_0, \"rng\", TYPE_RNG_BACKEND,\n(Object **)&dev->vdev.conf.rng, NULL);",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
]
] |
23,125 | static int apic_init_common(SysBusDevice *dev)
{
APICCommonState *s = APIC_COMMON(dev);
APICCommonClass *info;
static DeviceState *vapic;
static int apic_no;
if (apic_no >= MAX_APICS) {
return -1;
}
s->idx = apic_no++;
info = APIC_COMMON_GET_CLASS(s);
info->init(s);
sysbus_init_mmio(dev, &s->io_memory);
if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->vapic = vapic;
if (apic_report_tpr_access && info->enable_tpr_reporting) {
info->enable_tpr_reporting(s, true);
}
return 0;
}
| true | qemu | a9605e0317c7a6d5e68f3a3b6708c8ef1096f4bc | static int apic_init_common(SysBusDevice *dev)
{
APICCommonState *s = APIC_COMMON(dev);
APICCommonClass *info;
static DeviceState *vapic;
static int apic_no;
if (apic_no >= MAX_APICS) {
return -1;
}
s->idx = apic_no++;
info = APIC_COMMON_GET_CLASS(s);
info->init(s);
sysbus_init_mmio(dev, &s->io_memory);
if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->vapic = vapic;
if (apic_report_tpr_access && info->enable_tpr_reporting) {
info->enable_tpr_reporting(s, true);
}
return 0;
}
| {
"code": [
" if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) {"
],
"line_no": [
35
]
} | static int FUNC_0(SysBusDevice *VAR_0)
{
APICCommonState *s = APIC_COMMON(VAR_0);
APICCommonClass *info;
static DeviceState *VAR_1;
static int VAR_2;
if (VAR_2 >= MAX_APICS) {
return -1;
}
s->idx = VAR_2++;
info = APIC_COMMON_GET_CLASS(s);
info->init(s);
sysbus_init_mmio(VAR_0, &s->io_memory);
if (!VAR_1 && s->vapic_control & VAPIC_ENABLE_MASK) {
VAR_1 = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->VAR_1 = VAR_1;
if (apic_report_tpr_access && info->enable_tpr_reporting) {
info->enable_tpr_reporting(s, true);
}
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"APICCommonState *s = APIC_COMMON(VAR_0);",
"APICCommonClass *info;",
"static DeviceState *VAR_1;",
"static int VAR_2;",
"if (VAR_2 >= MAX_APICS) {",
"return -1;",
"}",
"s->idx = VAR_2++;",
"info = APIC_COMMON_GET_CLASS(s);",
"info->init(s);",
"sysbus_init_mmio(VAR_0, &s->io_memory);",
"if (!VAR_1 && s->vapic_control & VAPIC_ENABLE_MASK) {",
"VAR_1 = sysbus_create_simple(\"kvmvapic\", -1, NULL);",
"}",
"s->VAR_1 = VAR_1;",
"if (apic_report_tpr_access && info->enable_tpr_reporting) {",
"info->enable_tpr_reporting(s, true);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
] |
23,126 | static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
bs->bl.request_alignment);
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);
assert(alignment % bs->bl.request_alignment == 0);
head = offset % alignment;
tail = (offset + bytes) % alignment;
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
assert(max_write_zeroes >= bs->bl.request_alignment);
while (bytes > 0 && !ret) {
int num = bytes;
/* Align request. Block drivers can expect the "bulk" of the request
* to be aligned, and that unaligned requests do not cross cluster
* boundaries.
*/
if (head) {
/* Make a small request up to the first aligned sector. For
* convenience, limit this request to max_transfer even if
* we don't need to fall back to writes. */
num = MIN(MIN(bytes, max_transfer), alignment - head);
head = (head + num) % alignment;
assert(num < max_write_zeroes);
} else if (tail && num > alignment) {
/* Shorten the request to the last aligned sector. */
num -= tail;
/* limit request size */
if (num > max_write_zeroes) {
num = max_write_zeroes;
ret = -ENOTSUP;
/* First try the efficient write zeroes operation */
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
} else {
assert(!bs->supported_zero_flags);
if (ret == -ENOTSUP) {
/* Fall back to bounce buffer if write zeroes is unsupported */
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
/* No need for bdrv_driver_pwrite() to do a fallback
* flush on each chunk; use just one at the end */
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
num = MIN(num, max_transfer);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
memset(iov.iov_base, 0, num);
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
/* Keep bounce buffer around if it is big enough for all
* all future requests.
*/
if (num < max_transfer) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
offset += num;
bytes -= num;
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
qemu_vfree(iov.iov_base);
return ret; | true | qemu | d470ad42acfc73c45d3e8ed5311a491160b4c100 | static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
bs->bl.request_alignment);
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);
assert(alignment % bs->bl.request_alignment == 0);
head = offset % alignment;
tail = (offset + bytes) % alignment;
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
assert(max_write_zeroes >= bs->bl.request_alignment);
while (bytes > 0 && !ret) {
int num = bytes;
if (head) {
num = MIN(MIN(bytes, max_transfer), alignment - head);
head = (head + num) % alignment;
assert(num < max_write_zeroes);
} else if (tail && num > alignment) {
num -= tail;
if (num > max_write_zeroes) {
num = max_write_zeroes;
ret = -ENOTSUP;
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
} else {
assert(!bs->supported_zero_flags);
if (ret == -ENOTSUP) {
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
num = MIN(num, max_transfer);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
memset(iov.iov_base, 0, num);
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
if (num < max_transfer) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
offset += num;
bytes -= num;
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
qemu_vfree(iov.iov_base);
return ret; | {
"code": [],
"line_no": []
} | static int VAR_0 bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int bytes, BdrvRequestFlags flags)
{
BlockDriver *drv = bs->drv;
QEMUIOVector qiov;
struct iovec iov = {0};
int ret = 0;
bool need_flush = false;
int head = 0;
int tail = 0;
int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);
int alignment = MAX(bs->bl.pwrite_zeroes_alignment,
bs->bl.request_alignment);
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);
assert(alignment % bs->bl.request_alignment == 0);
head = offset % alignment;
tail = (offset + bytes) % alignment;
max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);
assert(max_write_zeroes >= bs->bl.request_alignment);
while (bytes > 0 && !ret) {
int num = bytes;
if (head) {
num = MIN(MIN(bytes, max_transfer), alignment - head);
head = (head + num) % alignment;
assert(num < max_write_zeroes);
} else if (tail && num > alignment) {
num -= tail;
if (num > max_write_zeroes) {
num = max_write_zeroes;
ret = -ENOTSUP;
if (drv->bdrv_co_pwrite_zeroes) {
ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,
flags & bs->supported_zero_flags);
if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&
!(bs->supported_zero_flags & BDRV_REQ_FUA)) {
need_flush = true;
} else {
assert(!bs->supported_zero_flags);
if (ret == -ENOTSUP) {
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
if ((flags & BDRV_REQ_FUA) &&
!(bs->supported_write_flags & BDRV_REQ_FUA)) {
write_flags &= ~BDRV_REQ_FUA;
need_flush = true;
num = MIN(num, max_transfer);
iov.iov_len = num;
if (iov.iov_base == NULL) {
iov.iov_base = qemu_try_blockalign(bs, num);
if (iov.iov_base == NULL) {
ret = -ENOMEM;
goto fail;
memset(iov.iov_base, 0, num);
qemu_iovec_init_external(&qiov, &iov, 1);
ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);
if (num < max_transfer) {
qemu_vfree(iov.iov_base);
iov.iov_base = NULL;
offset += num;
bytes -= num;
fail:
if (ret == 0 && need_flush) {
ret = bdrv_co_flush(bs);
qemu_vfree(iov.iov_base);
return ret; | [
"static int VAR_0 bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,\nint64_t offset, int bytes, BdrvRequestFlags flags)\n{",
"BlockDriver *drv = bs->drv;",
"QEMUIOVector qiov;",
"struct iovec iov = {0};",
"int ret = 0;",
"bool need_flush = false;",
"int head = 0;",
"int tail = 0;",
"int max_write_zeroes = MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, INT_MAX);",
"int alignment = MAX(bs->bl.pwrite_zeroes_alignment,\nbs->bl.request_alignment);",
"int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);",
"assert(alignment % bs->bl.request_alignment == 0);",
"head = offset % alignment;",
"tail = (offset + bytes) % alignment;",
"max_write_zeroes = QEMU_ALIGN_DOWN(max_write_zeroes, alignment);",
"assert(max_write_zeroes >= bs->bl.request_alignment);",
"while (bytes > 0 && !ret) {",
"int num = bytes;",
"if (head) {",
"num = MIN(MIN(bytes, max_transfer), alignment - head);",
"head = (head + num) % alignment;",
"assert(num < max_write_zeroes);",
"} else if (tail && num > alignment) {",
"num -= tail;",
"if (num > max_write_zeroes) {",
"num = max_write_zeroes;",
"ret = -ENOTSUP;",
"if (drv->bdrv_co_pwrite_zeroes) {",
"ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num,\nflags & bs->supported_zero_flags);",
"if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) &&\n!(bs->supported_zero_flags & BDRV_REQ_FUA)) {",
"need_flush = true;",
"} else {",
"assert(!bs->supported_zero_flags);",
"if (ret == -ENOTSUP) {",
"BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;",
"if ((flags & BDRV_REQ_FUA) &&\n!(bs->supported_write_flags & BDRV_REQ_FUA)) {",
"write_flags &= ~BDRV_REQ_FUA;",
"need_flush = true;",
"num = MIN(num, max_transfer);",
"iov.iov_len = num;",
"if (iov.iov_base == NULL) {",
"iov.iov_base = qemu_try_blockalign(bs, num);",
"if (iov.iov_base == NULL) {",
"ret = -ENOMEM;",
"goto fail;",
"memset(iov.iov_base, 0, num);",
"qemu_iovec_init_external(&qiov, &iov, 1);",
"ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags);",
"if (num < max_transfer) {",
"qemu_vfree(iov.iov_base);",
"iov.iov_base = NULL;",
"offset += num;",
"bytes -= num;",
"fail:\nif (ret == 0 && need_flush) {",
"ret = bdrv_co_flush(bs);",
"qemu_vfree(iov.iov_base);",
"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
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12,
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
26
],
[
30
],
[
31
],
[
32
],
[
33
],
[
35
],
[
37
],
[
38
],
[
39
],
[
41
],
[
42,
43
],
[
44,
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
51
],
[
52,
53
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76,
77
],
[
78
],
[
79
],
[
80
]
] |
23,127 | static av_cold int decode_close(AVCodecContext *avctx)
{
IVI5DecContext *ctx = avctx->priv_data;
ff_ivi_free_buffers(&ctx->planes[0]);
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
return 0;
} | true | FFmpeg | 60819e694ee5733741da91ebc237b20621de5bc3 | static av_cold int decode_close(AVCodecContext *avctx)
{
IVI5DecContext *ctx = avctx->priv_data;
ff_ivi_free_buffers(&ctx->planes[0]);
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
return 0;
} | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
IVI5DecContext *ctx = avctx->priv_data;
ff_ivi_free_buffers(&ctx->planes[0]);
if (ctx->frame.data[0])
avctx->release_buffer(avctx, &ctx->frame);
return 0;
} | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"IVI5DecContext *ctx = avctx->priv_data;",
"ff_ivi_free_buffers(&ctx->planes[0]);",
"if (ctx->frame.data[0])\navctx->release_buffer(avctx, &ctx->frame);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5,
6
],
[
7
],
[
8
]
] |
23,128 | static void ioreq_release(struct ioreq *ioreq, bool finish)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
QLIST_REMOVE(ioreq, list);
memset(ioreq, 0, sizeof(*ioreq));
ioreq->blkdev = blkdev;
QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list);
if (finish) {
blkdev->requests_finished--;
} else {
blkdev->requests_inflight--;
}
}
| true | qemu | 282c6a2f292705f823554447ca0b7731b6f81a97 | static void ioreq_release(struct ioreq *ioreq, bool finish)
{
struct XenBlkDev *blkdev = ioreq->blkdev;
QLIST_REMOVE(ioreq, list);
memset(ioreq, 0, sizeof(*ioreq));
ioreq->blkdev = blkdev;
QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list);
if (finish) {
blkdev->requests_finished--;
} else {
blkdev->requests_inflight--;
}
}
| {
"code": [
" memset(ioreq, 0, sizeof(*ioreq));"
],
"line_no": [
11
]
} | static void FUNC_0(struct VAR_0 *VAR_0, bool VAR_1)
{
struct XenBlkDev *VAR_2 = VAR_0->VAR_2;
QLIST_REMOVE(VAR_0, list);
memset(VAR_0, 0, sizeof(*VAR_0));
VAR_0->VAR_2 = VAR_2;
QLIST_INSERT_HEAD(&VAR_2->freelist, VAR_0, list);
if (VAR_1) {
VAR_2->requests_finished--;
} else {
VAR_2->requests_inflight--;
}
}
| [
"static void FUNC_0(struct VAR_0 *VAR_0, bool VAR_1)\n{",
"struct XenBlkDev *VAR_2 = VAR_0->VAR_2;",
"QLIST_REMOVE(VAR_0, list);",
"memset(VAR_0, 0, sizeof(*VAR_0));",
"VAR_0->VAR_2 = VAR_2;",
"QLIST_INSERT_HEAD(&VAR_2->freelist, VAR_0, list);",
"if (VAR_1) {",
"VAR_2->requests_finished--;",
"} else {",
"VAR_2->requests_inflight--;",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
23,129 | int bdrv_open_backing_file(BlockDriverState *bs)
{
char backing_filename[PATH_MAX];
int back_flags, ret;
BlockDriver *back_drv = NULL;
if (bs->backing_hd != NULL) {
return 0;
}
bs->open_flags &= ~BDRV_O_NO_BACKING;
if (bs->backing_file[0] == '\0') {
return 0;
}
bs->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(bs, backing_filename,
sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
}
/* backing files always opened read-only */
back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
ret = bdrv_open(bs->backing_hd, backing_filename, NULL,
back_flags, back_drv);
if (ret < 0) {
bdrv_delete(bs->backing_hd);
bs->backing_hd = NULL;
bs->open_flags |= BDRV_O_NO_BACKING;
return ret;
}
return 0;
}
| true | qemu | 31ca6d077c24b7aaa322d8930e3e5debbdb4a047 | int bdrv_open_backing_file(BlockDriverState *bs)
{
char backing_filename[PATH_MAX];
int back_flags, ret;
BlockDriver *back_drv = NULL;
if (bs->backing_hd != NULL) {
return 0;
}
bs->open_flags &= ~BDRV_O_NO_BACKING;
if (bs->backing_file[0] == '\0') {
return 0;
}
bs->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(bs, backing_filename,
sizeof(backing_filename));
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
}
back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
ret = bdrv_open(bs->backing_hd, backing_filename, NULL,
back_flags, back_drv);
if (ret < 0) {
bdrv_delete(bs->backing_hd);
bs->backing_hd = NULL;
bs->open_flags |= BDRV_O_NO_BACKING;
return ret;
}
return 0;
}
| {
"code": [
"int bdrv_open_backing_file(BlockDriverState *bs)",
" if (bs->backing_file[0] == '\\0') {",
" ret = bdrv_open(bs->backing_hd, backing_filename, NULL,"
],
"line_no": [
1,
23,
53
]
} | int FUNC_0(BlockDriverState *VAR_0)
{
char VAR_1[PATH_MAX];
int VAR_2, VAR_3;
BlockDriver *back_drv = NULL;
if (VAR_0->backing_hd != NULL) {
return 0;
}
VAR_0->open_flags &= ~BDRV_O_NO_BACKING;
if (VAR_0->backing_file[0] == '\0') {
return 0;
}
VAR_0->backing_hd = bdrv_new("");
bdrv_get_full_backing_filename(VAR_0, VAR_1,
sizeof(VAR_1));
if (VAR_0->backing_format[0] != '\0') {
back_drv = bdrv_find_format(VAR_0->backing_format);
}
VAR_2 = VAR_0->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
VAR_3 = bdrv_open(VAR_0->backing_hd, VAR_1, NULL,
VAR_2, back_drv);
if (VAR_3 < 0) {
bdrv_delete(VAR_0->backing_hd);
VAR_0->backing_hd = NULL;
VAR_0->open_flags |= BDRV_O_NO_BACKING;
return VAR_3;
}
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"char VAR_1[PATH_MAX];",
"int VAR_2, VAR_3;",
"BlockDriver *back_drv = NULL;",
"if (VAR_0->backing_hd != NULL) {",
"return 0;",
"}",
"VAR_0->open_flags &= ~BDRV_O_NO_BACKING;",
"if (VAR_0->backing_file[0] == '\\0') {",
"return 0;",
"}",
"VAR_0->backing_hd = bdrv_new(\"\");",
"bdrv_get_full_backing_filename(VAR_0, VAR_1,\nsizeof(VAR_1));",
"if (VAR_0->backing_format[0] != '\\0') {",
"back_drv = bdrv_find_format(VAR_0->backing_format);",
"}",
"VAR_2 = VAR_0->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);",
"VAR_3 = bdrv_open(VAR_0->backing_hd, VAR_1, NULL,\nVAR_2, back_drv);",
"if (VAR_3 < 0) {",
"bdrv_delete(VAR_0->backing_hd);",
"VAR_0->backing_hd = NULL;",
"VAR_0->open_flags |= BDRV_O_NO_BACKING;",
"return VAR_3;",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
39
],
[
41
],
[
43
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
23,130 | static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
s->cluster_cache_offset = -1; /* disable compressed cache */
/* We must always copy the iov when encrypting, so we
* don't modify the original data buffer during encryption */
if (bs->encrypted || qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
orig_buf = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
index_in_cluster,
index_in_cluster + n);
if (!cluster_offset || (cluster_offset & 511) != 0) {
ret = -EIO;
break;
}
if (bs->encrypted) {
assert(s->crypto);
if (qcrypto_block_encrypt(s->crypto, sector_num, buf,
n * BDRV_SECTOR_SIZE, NULL) < 0) {
ret = -EIO;
break;
}
}
hd_iov.iov_base = (void *)buf;
hd_iov.iov_len = n * 512;
qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + index_in_cluster,
n, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
break;
}
ret = 0;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(orig_buf);
return ret;
}
| true | qemu | 56439e9d55626b65ecb887f1ac3714652555312e | static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster;
uint64_t cluster_offset;
int ret = 0, n;
struct iovec hd_iov;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *orig_buf;
s->cluster_cache_offset = -1;
if (bs->encrypted || qiov->niov > 1) {
buf = orig_buf = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
orig_buf = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
index_in_cluster,
index_in_cluster + n);
if (!cluster_offset || (cluster_offset & 511) != 0) {
ret = -EIO;
break;
}
if (bs->encrypted) {
assert(s->crypto);
if (qcrypto_block_encrypt(s->crypto, sector_num, buf,
n * BDRV_SECTOR_SIZE, NULL) < 0) {
ret = -EIO;
break;
}
}
hd_iov.iov_base = (void *)buf;
hd_iov.iov_len = n * 512;
qemu_iovec_init_external(&hd_qiov, &hd_iov, 1);
qemu_co_mutex_unlock(&s->lock);
ret = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + index_in_cluster,
n, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (ret < 0) {
break;
}
ret = 0;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(orig_buf);
return ret;
}
| {
"code": [
" cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,",
" index_in_cluster,",
" index_in_cluster + n);"
],
"line_no": [
73,
75,
77
]
} | static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BDRVQcowState *s = bs->opaque;
int VAR_0;
uint64_t cluster_offset;
int VAR_1 = 0, VAR_2;
struct iovec VAR_3;
QEMUIOVector hd_qiov;
uint8_t *buf;
void *VAR_4;
s->cluster_cache_offset = -1;
if (bs->encrypted || qiov->niov > 1) {
buf = VAR_4 = qemu_try_blockalign(bs, qiov->size);
if (buf == NULL) {
return -ENOMEM;
}
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
} else {
VAR_4 = NULL;
buf = (uint8_t *)qiov->iov->iov_base;
}
qemu_co_mutex_lock(&s->lock);
while (nb_sectors != 0) {
VAR_0 = sector_num & (s->cluster_sectors - 1);
VAR_2 = s->cluster_sectors - VAR_0;
if (VAR_2 > nb_sectors) {
VAR_2 = nb_sectors;
}
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
VAR_0,
VAR_0 + VAR_2);
if (!cluster_offset || (cluster_offset & 511) != 0) {
VAR_1 = -EIO;
break;
}
if (bs->encrypted) {
assert(s->crypto);
if (qcrypto_block_encrypt(s->crypto, sector_num, buf,
VAR_2 * BDRV_SECTOR_SIZE, NULL) < 0) {
VAR_1 = -EIO;
break;
}
}
VAR_3.iov_base = (void *)buf;
VAR_3.iov_len = VAR_2 * 512;
qemu_iovec_init_external(&hd_qiov, &VAR_3, 1);
qemu_co_mutex_unlock(&s->lock);
VAR_1 = bdrv_co_writev(bs->file,
(cluster_offset >> 9) + VAR_0,
VAR_2, &hd_qiov);
qemu_co_mutex_lock(&s->lock);
if (VAR_1 < 0) {
break;
}
VAR_1 = 0;
nb_sectors -= VAR_2;
sector_num += VAR_2;
buf += VAR_2 * 512;
}
qemu_co_mutex_unlock(&s->lock);
qemu_vfree(VAR_4);
return VAR_1;
}
| [
"static coroutine_fn int FUNC_0(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors, QEMUIOVector *qiov)\n{",
"BDRVQcowState *s = bs->opaque;",
"int VAR_0;",
"uint64_t cluster_offset;",
"int VAR_1 = 0, VAR_2;",
"struct iovec VAR_3;",
"QEMUIOVector hd_qiov;",
"uint8_t *buf;",
"void *VAR_4;",
"s->cluster_cache_offset = -1;",
"if (bs->encrypted || qiov->niov > 1) {",
"buf = VAR_4 = qemu_try_blockalign(bs, qiov->size);",
"if (buf == NULL) {",
"return -ENOMEM;",
"}",
"qemu_iovec_to_buf(qiov, 0, buf, qiov->size);",
"} else {",
"VAR_4 = NULL;",
"buf = (uint8_t *)qiov->iov->iov_base;",
"}",
"qemu_co_mutex_lock(&s->lock);",
"while (nb_sectors != 0) {",
"VAR_0 = sector_num & (s->cluster_sectors - 1);",
"VAR_2 = s->cluster_sectors - VAR_0;",
"if (VAR_2 > nb_sectors) {",
"VAR_2 = nb_sectors;",
"}",
"cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,\nVAR_0,\nVAR_0 + VAR_2);",
"if (!cluster_offset || (cluster_offset & 511) != 0) {",
"VAR_1 = -EIO;",
"break;",
"}",
"if (bs->encrypted) {",
"assert(s->crypto);",
"if (qcrypto_block_encrypt(s->crypto, sector_num, buf,\nVAR_2 * BDRV_SECTOR_SIZE, NULL) < 0) {",
"VAR_1 = -EIO;",
"break;",
"}",
"}",
"VAR_3.iov_base = (void *)buf;",
"VAR_3.iov_len = VAR_2 * 512;",
"qemu_iovec_init_external(&hd_qiov, &VAR_3, 1);",
"qemu_co_mutex_unlock(&s->lock);",
"VAR_1 = bdrv_co_writev(bs->file,\n(cluster_offset >> 9) + VAR_0,\nVAR_2, &hd_qiov);",
"qemu_co_mutex_lock(&s->lock);",
"if (VAR_1 < 0) {",
"break;",
"}",
"VAR_1 = 0;",
"nb_sectors -= VAR_2;",
"sector_num += VAR_2;",
"buf += VAR_2 * 512;",
"}",
"qemu_co_mutex_unlock(&s->lock);",
"qemu_vfree(VAR_4);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
59
],
[
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
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
147
],
[
149
]
] |
23,131 | static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict)
{
Monitor *mon;
trace_monitor_protocol_event_emit(event, qdict);
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {
monitor_json_emitter(mon, QOBJECT(qdict));
}
}
}
| true | qemu | 635db18f68ded6abec11cd4cf64ebc15c1c6b190 | static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict)
{
Monitor *mon;
trace_monitor_protocol_event_emit(event, qdict);
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {
monitor_json_emitter(mon, QOBJECT(qdict));
}
}
}
| {
"code": [
" if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {"
],
"line_no": [
13
]
} | static void FUNC_0(QAPIEvent VAR_0, QDict *VAR_1)
{
Monitor *mon;
trace_monitor_protocol_event_emit(VAR_0, VAR_1);
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {
monitor_json_emitter(mon, QOBJECT(VAR_1));
}
}
}
| [
"static void FUNC_0(QAPIEvent VAR_0, QDict *VAR_1)\n{",
"Monitor *mon;",
"trace_monitor_protocol_event_emit(VAR_0, VAR_1);",
"QLIST_FOREACH(mon, &mon_list, entry) {",
"if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) {",
"monitor_json_emitter(mon, QOBJECT(VAR_1));",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
23,132 | static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
{
AVFilterContext *ctx = codec->opaque;
AVFilterBufferRef *ref;
int perms = AV_PERM_WRITE;
int i, w, h, stride[4];
unsigned edge;
int pixel_size;
av_assert0(codec->flags & CODEC_FLAG_EMU_EDGE);
if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES)
perms |= AV_PERM_NEG_LINESIZES;
if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) {
if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ;
if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE;
if(pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2;
}
if(pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE;
w = codec->width;
h = codec->height;
if(av_image_check_size(w, h, 0, codec))
return -1;
avcodec_align_dimensions2(codec, &w, &h, stride);
edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width();
w += edge << 1;
h += edge << 1;
if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h)))
return -1;
pixel_size = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1+1;
ref->video->w = codec->width;
ref->video->h = codec->height;
for(i = 0; i < 4; i ++) {
unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;
unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
if (ref->data[i]) {
ref->data[i] += ((edge * pixel_size) >> hshift) + ((edge * ref->linesize[i]) >> vshift);
}
pic->data[i] = ref->data[i];
pic->linesize[i] = ref->linesize[i];
}
pic->opaque = ref;
pic->age = INT_MAX;
pic->type = FF_BUFFER_TYPE_USER;
pic->reordered_opaque = codec->reordered_opaque;
if(codec->pkt) pic->pkt_pts = codec->pkt->pts;
else pic->pkt_pts = AV_NOPTS_VALUE;
return 0;
}
| true | FFmpeg | 2c28e26913df927e71d87fa851c9d950f281523b | static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
{
AVFilterContext *ctx = codec->opaque;
AVFilterBufferRef *ref;
int perms = AV_PERM_WRITE;
int i, w, h, stride[4];
unsigned edge;
int pixel_size;
av_assert0(codec->flags & CODEC_FLAG_EMU_EDGE);
if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES)
perms |= AV_PERM_NEG_LINESIZES;
if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) {
if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ;
if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE;
if(pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2;
}
if(pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE;
w = codec->width;
h = codec->height;
if(av_image_check_size(w, h, 0, codec))
return -1;
avcodec_align_dimensions2(codec, &w, &h, stride);
edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width();
w += edge << 1;
h += edge << 1;
if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h)))
return -1;
pixel_size = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1+1;
ref->video->w = codec->width;
ref->video->h = codec->height;
for(i = 0; i < 4; i ++) {
unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;
unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
if (ref->data[i]) {
ref->data[i] += ((edge * pixel_size) >> hshift) + ((edge * ref->linesize[i]) >> vshift);
}
pic->data[i] = ref->data[i];
pic->linesize[i] = ref->linesize[i];
}
pic->opaque = ref;
pic->age = INT_MAX;
pic->type = FF_BUFFER_TYPE_USER;
pic->reordered_opaque = codec->reordered_opaque;
if(codec->pkt) pic->pkt_pts = codec->pkt->pts;
else pic->pkt_pts = AV_NOPTS_VALUE;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{
AVFilterContext *ctx = VAR_0->opaque;
AVFilterBufferRef *ref;
int VAR_2 = AV_PERM_WRITE;
int VAR_3, VAR_4, VAR_5, VAR_6[4];
unsigned VAR_7;
int VAR_8;
av_assert0(VAR_0->flags & CODEC_FLAG_EMU_EDGE);
if (VAR_0->VAR_0->capabilities & CODEC_CAP_NEG_LINESIZES)
VAR_2 |= AV_PERM_NEG_LINESIZES;
if(VAR_1->buffer_hints & FF_BUFFER_HINTS_VALID) {
if(VAR_1->buffer_hints & FF_BUFFER_HINTS_READABLE) VAR_2 |= AV_PERM_READ;
if(VAR_1->buffer_hints & FF_BUFFER_HINTS_PRESERVE) VAR_2 |= AV_PERM_PRESERVE;
if(VAR_1->buffer_hints & FF_BUFFER_HINTS_REUSABLE) VAR_2 |= AV_PERM_REUSE2;
}
if(VAR_1->reference) VAR_2 |= AV_PERM_READ | AV_PERM_PRESERVE;
VAR_4 = VAR_0->width;
VAR_5 = VAR_0->height;
if(av_image_check_size(VAR_4, VAR_5, 0, VAR_0))
return -1;
avcodec_align_dimensions2(VAR_0, &VAR_4, &VAR_5, VAR_6);
VAR_7 = VAR_0->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width();
VAR_4 += VAR_7 << 1;
VAR_5 += VAR_7 << 1;
if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], VAR_2, VAR_4, VAR_5)))
return -1;
VAR_8 = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1+1;
ref->video->VAR_4 = VAR_0->width;
ref->video->VAR_5 = VAR_0->height;
for(VAR_3 = 0; VAR_3 < 4; VAR_3 ++) {
unsigned VAR_9 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;
unsigned VAR_10 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
if (ref->data[VAR_3]) {
ref->data[VAR_3] += ((VAR_7 * VAR_8) >> VAR_9) + ((VAR_7 * ref->linesize[VAR_3]) >> VAR_10);
}
VAR_1->data[VAR_3] = ref->data[VAR_3];
VAR_1->linesize[VAR_3] = ref->linesize[VAR_3];
}
VAR_1->opaque = ref;
VAR_1->age = INT_MAX;
VAR_1->type = FF_BUFFER_TYPE_USER;
VAR_1->reordered_opaque = VAR_0->reordered_opaque;
if(VAR_0->pkt) VAR_1->pkt_pts = VAR_0->pkt->pts;
else VAR_1->pkt_pts = AV_NOPTS_VALUE;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->opaque;",
"AVFilterBufferRef *ref;",
"int VAR_2 = AV_PERM_WRITE;",
"int VAR_3, VAR_4, VAR_5, VAR_6[4];",
"unsigned VAR_7;",
"int VAR_8;",
"av_assert0(VAR_0->flags & CODEC_FLAG_EMU_EDGE);",
"if (VAR_0->VAR_0->capabilities & CODEC_CAP_NEG_LINESIZES)\nVAR_2 |= AV_PERM_NEG_LINESIZES;",
"if(VAR_1->buffer_hints & FF_BUFFER_HINTS_VALID) {",
"if(VAR_1->buffer_hints & FF_BUFFER_HINTS_READABLE) VAR_2 |= AV_PERM_READ;",
"if(VAR_1->buffer_hints & FF_BUFFER_HINTS_PRESERVE) VAR_2 |= AV_PERM_PRESERVE;",
"if(VAR_1->buffer_hints & FF_BUFFER_HINTS_REUSABLE) VAR_2 |= AV_PERM_REUSE2;",
"}",
"if(VAR_1->reference) VAR_2 |= AV_PERM_READ | AV_PERM_PRESERVE;",
"VAR_4 = VAR_0->width;",
"VAR_5 = VAR_0->height;",
"if(av_image_check_size(VAR_4, VAR_5, 0, VAR_0))\nreturn -1;",
"avcodec_align_dimensions2(VAR_0, &VAR_4, &VAR_5, VAR_6);",
"VAR_7 = VAR_0->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width();",
"VAR_4 += VAR_7 << 1;",
"VAR_5 += VAR_7 << 1;",
"if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], VAR_2, VAR_4, VAR_5)))\nreturn -1;",
"VAR_8 = av_pix_fmt_descriptors[ref->format].comp[0].step_minus1+1;",
"ref->video->VAR_4 = VAR_0->width;",
"ref->video->VAR_5 = VAR_0->height;",
"for(VAR_3 = 0; VAR_3 < 4; VAR_3 ++) {",
"unsigned VAR_9 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;",
"unsigned VAR_10 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;",
"if (ref->data[VAR_3]) {",
"ref->data[VAR_3] += ((VAR_7 * VAR_8) >> VAR_9) + ((VAR_7 * ref->linesize[VAR_3]) >> VAR_10);",
"}",
"VAR_1->data[VAR_3] = ref->data[VAR_3];",
"VAR_1->linesize[VAR_3] = ref->linesize[VAR_3];",
"}",
"VAR_1->opaque = ref;",
"VAR_1->age = INT_MAX;",
"VAR_1->type = FF_BUFFER_TYPE_USER;",
"VAR_1->reordered_opaque = VAR_0->reordered_opaque;",
"if(VAR_0->pkt) VAR_1->pkt_pts = VAR_0->pkt->pts;",
"else VAR_1->pkt_pts = AV_NOPTS_VALUE;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
23,133 | static void gen_lea_v_seg(DisasContext *s, TCGMemOp aflag, TCGv a0,
int def_seg, int ovr_seg)
{
switch (aflag) {
#ifdef TARGET_X86_64
case MO_64:
if (ovr_seg < 0) {
tcg_gen_mov_tl(cpu_A0, a0);
return;
}
break;
#endif
case MO_32:
/* 32 bit address */
if (ovr_seg < 0) {
if (s->addseg) {
ovr_seg = def_seg;
} else {
tcg_gen_ext32u_tl(cpu_A0, a0);
return;
}
}
break;
case MO_16:
/* 16 bit address */
if (ovr_seg < 0) {
ovr_seg = def_seg;
}
tcg_gen_ext16u_tl(cpu_A0, a0);
/* ADDSEG will only be false in 16-bit mode for LEA. */
if (!s->addseg) {
return;
}
a0 = cpu_A0;
break;
default:
tcg_abort();
}
if (ovr_seg >= 0) {
TCGv seg = tcg_temp_new();
tcg_gen_ld_tl(seg, cpu_env, offsetof(CPUX86State, segs[ovr_seg].base));
if (aflag == MO_64) {
tcg_gen_add_tl(cpu_A0, a0, seg);
} else if (CODE64(s)) {
tcg_gen_ext32u_tl(cpu_A0, a0);
tcg_gen_add_tl(cpu_A0, cpu_A0, seg);
} else {
tcg_gen_add_tl(cpu_A0, a0, seg);
tcg_gen_ext32u_tl(cpu_A0, cpu_A0);
}
tcg_temp_free(seg);
}
}
| false | qemu | 3558f8055f37a34762b7a2a0f02687e6eeab893d | static void gen_lea_v_seg(DisasContext *s, TCGMemOp aflag, TCGv a0,
int def_seg, int ovr_seg)
{
switch (aflag) {
#ifdef TARGET_X86_64
case MO_64:
if (ovr_seg < 0) {
tcg_gen_mov_tl(cpu_A0, a0);
return;
}
break;
#endif
case MO_32:
if (ovr_seg < 0) {
if (s->addseg) {
ovr_seg = def_seg;
} else {
tcg_gen_ext32u_tl(cpu_A0, a0);
return;
}
}
break;
case MO_16:
if (ovr_seg < 0) {
ovr_seg = def_seg;
}
tcg_gen_ext16u_tl(cpu_A0, a0);
if (!s->addseg) {
return;
}
a0 = cpu_A0;
break;
default:
tcg_abort();
}
if (ovr_seg >= 0) {
TCGv seg = tcg_temp_new();
tcg_gen_ld_tl(seg, cpu_env, offsetof(CPUX86State, segs[ovr_seg].base));
if (aflag == MO_64) {
tcg_gen_add_tl(cpu_A0, a0, seg);
} else if (CODE64(s)) {
tcg_gen_ext32u_tl(cpu_A0, a0);
tcg_gen_add_tl(cpu_A0, cpu_A0, seg);
} else {
tcg_gen_add_tl(cpu_A0, a0, seg);
tcg_gen_ext32u_tl(cpu_A0, cpu_A0);
}
tcg_temp_free(seg);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, TCGMemOp VAR_1, TCGv VAR_2,
int VAR_3, int VAR_4)
{
switch (VAR_1) {
#ifdef TARGET_X86_64
case MO_64:
if (VAR_4 < 0) {
tcg_gen_mov_tl(cpu_A0, VAR_2);
return;
}
break;
#endif
case MO_32:
if (VAR_4 < 0) {
if (VAR_0->addseg) {
VAR_4 = VAR_3;
} else {
tcg_gen_ext32u_tl(cpu_A0, VAR_2);
return;
}
}
break;
case MO_16:
if (VAR_4 < 0) {
VAR_4 = VAR_3;
}
tcg_gen_ext16u_tl(cpu_A0, VAR_2);
if (!VAR_0->addseg) {
return;
}
VAR_2 = cpu_A0;
break;
default:
tcg_abort();
}
if (VAR_4 >= 0) {
TCGv seg = tcg_temp_new();
tcg_gen_ld_tl(seg, cpu_env, offsetof(CPUX86State, segs[VAR_4].base));
if (VAR_1 == MO_64) {
tcg_gen_add_tl(cpu_A0, VAR_2, seg);
} else if (CODE64(VAR_0)) {
tcg_gen_ext32u_tl(cpu_A0, VAR_2);
tcg_gen_add_tl(cpu_A0, cpu_A0, seg);
} else {
tcg_gen_add_tl(cpu_A0, VAR_2, seg);
tcg_gen_ext32u_tl(cpu_A0, cpu_A0);
}
tcg_temp_free(seg);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, TCGMemOp VAR_1, TCGv VAR_2,\nint VAR_3, int VAR_4)\n{",
"switch (VAR_1) {",
"#ifdef TARGET_X86_64\ncase MO_64:\nif (VAR_4 < 0) {",
"tcg_gen_mov_tl(cpu_A0, VAR_2);",
"return;",
"}",
"break;",
"#endif\ncase MO_32:\nif (VAR_4 < 0) {",
"if (VAR_0->addseg) {",
"VAR_4 = VAR_3;",
"} else {",
"tcg_gen_ext32u_tl(cpu_A0, VAR_2);",
"return;",
"}",
"}",
"break;",
"case MO_16:\nif (VAR_4 < 0) {",
"VAR_4 = VAR_3;",
"}",
"tcg_gen_ext16u_tl(cpu_A0, VAR_2);",
"if (!VAR_0->addseg) {",
"return;",
"}",
"VAR_2 = cpu_A0;",
"break;",
"default:\ntcg_abort();",
"}",
"if (VAR_4 >= 0) {",
"TCGv seg = tcg_temp_new();",
"tcg_gen_ld_tl(seg, cpu_env, offsetof(CPUX86State, segs[VAR_4].base));",
"if (VAR_1 == MO_64) {",
"tcg_gen_add_tl(cpu_A0, VAR_2, seg);",
"} else if (CODE64(VAR_0)) {",
"tcg_gen_ext32u_tl(cpu_A0, VAR_2);",
"tcg_gen_add_tl(cpu_A0, cpu_A0, seg);",
"} else {",
"tcg_gen_add_tl(cpu_A0, VAR_2, seg);",
"tcg_gen_ext32u_tl(cpu_A0, cpu_A0);",
"}",
"tcg_temp_free(seg);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
]
] |
23,134 | static void coroutine_fn mirror_run(void *opaque)
{
MirrorBlockJob *s = opaque;
MirrorExitData *data;
BlockDriverState *bs = blk_bs(s->common.blk);
BlockDriverState *target_bs = blk_bs(s->target);
int64_t length;
BlockDriverInfo bdi;
char backing_filename[2]; /* we only need 2 characters because we are only
checking for a NULL string */
int ret = 0;
int target_cluster_size = BDRV_SECTOR_SIZE;
if (block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
s->bdev_length = bdrv_getlength(bs);
if (s->bdev_length < 0) {
ret = s->bdev_length;
goto immediate_exit;
} else if (s->bdev_length == 0) {
/* Report BLOCK_JOB_READY and wait for complete. */
block_job_event_ready(&s->common);
s->synced = true;
while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
block_job_yield(&s->common);
}
s->common.cancelled = false;
goto immediate_exit;
}
length = DIV_ROUND_UP(s->bdev_length, s->granularity);
s->in_flight_bitmap = bitmap_new(length);
/* If we have no backing file yet in the destination, we cannot let
* the destination do COW. Instead, we copy sectors around the
* dirty data if needed. We need a bitmap to do that.
*/
bdrv_get_backing_filename(target_bs, backing_filename,
sizeof(backing_filename));
if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) {
target_cluster_size = bdi.cluster_size;
}
if (backing_filename[0] && !target_bs->backing
&& s->granularity < target_cluster_size) {
s->buf_size = MAX(s->buf_size, target_cluster_size);
s->cow_bitmap = bitmap_new(length);
}
s->target_cluster_sectors = target_cluster_size >> BDRV_SECTOR_BITS;
s->max_iov = MIN(bs->bl.max_iov, target_bs->bl.max_iov);
s->buf = qemu_try_blockalign(bs, s->buf_size);
if (s->buf == NULL) {
ret = -ENOMEM;
goto immediate_exit;
}
mirror_free_init(s);
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
if (!s->is_none_mode) {
ret = mirror_dirty_init(s);
if (ret < 0 || block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
}
assert(!s->dbi);
s->dbi = bdrv_dirty_iter_new(s->dirty_bitmap, 0);
for (;;) {
uint64_t delay_ns = 0;
int64_t cnt, delta;
bool should_complete;
if (s->ret < 0) {
ret = s->ret;
goto immediate_exit;
}
block_job_pause_point(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
/* s->common.offset contains the number of bytes already processed so
* far, cnt is the number of dirty sectors remaining and
* s->sectors_in_flight is the number of sectors currently being
* processed; together those are the current total operation length */
s->common.len = s->common.offset +
(cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE;
/* Note that even when no rate limit is applied we need to yield
* periodically with no pending I/O so that bdrv_drain_all() returns.
* We do so every SLICE_TIME nanoseconds, or when there is an error,
* or when the source is clean, whichever comes first.
*/
delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns;
if (delta < SLICE_TIME &&
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 ||
(cnt == 0 && s->in_flight > 0)) {
trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt);
mirror_wait_for_io(s);
continue;
} else if (cnt != 0) {
delay_ns = mirror_iteration(s);
}
}
should_complete = false;
if (s->in_flight == 0 && cnt == 0) {
trace_mirror_before_flush(s);
ret = blk_flush(s->target);
if (ret < 0) {
if (mirror_error_action(s, false, -ret) ==
BLOCK_ERROR_ACTION_REPORT) {
goto immediate_exit;
}
} else {
/* We're out of the streaming phase. From now on, if the job
* is cancelled we will actually complete all pending I/O and
* report completion. This way, block-job-cancel will leave
* the target in a consistent state.
*/
if (!s->synced) {
block_job_event_ready(&s->common);
s->synced = true;
}
should_complete = s->should_complete ||
block_job_is_cancelled(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
}
if (cnt == 0 && should_complete) {
/* The dirty bitmap is not updated while operations are pending.
* If we're about to exit, wait for pending operations before
* calling bdrv_get_dirty_count(bs), or we may exit while the
* source has dirty data to copy!
*
* Note that I/O can be submitted by the guest while
* mirror_populate runs.
*/
trace_mirror_before_drain(s, cnt);
bdrv_co_drain(bs);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
ret = 0;
trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
if (!s->synced) {
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
} else if (!should_complete) {
delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
} else if (cnt == 0) {
/* The two disks are in sync. Exit and report successful
* completion.
*/
assert(QLIST_EMPTY(&bs->tracked_requests));
s->common.cancelled = false;
break;
}
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
immediate_exit:
if (s->in_flight > 0) {
/* We get here only if something went wrong. Either the job failed,
* or it was cancelled prematurely so that we do not guarantee that
* the target is a copy of the source.
*/
assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common)));
mirror_drain(s);
}
assert(s->in_flight == 0);
qemu_vfree(s->buf);
g_free(s->cow_bitmap);
g_free(s->in_flight_bitmap);
bdrv_dirty_iter_free(s->dbi);
bdrv_release_dirty_bitmap(bs, s->dirty_bitmap);
data = g_malloc(sizeof(*data));
data->ret = ret;
/* Before we switch to target in mirror_exit, make sure data doesn't
* change. */
bdrv_drained_begin(bs);
block_job_defer_to_main_loop(&s->common, mirror_exit, data);
}
| false | qemu | bae8196d9f97916de6323e70e3e374362ee16ec4 | static void coroutine_fn mirror_run(void *opaque)
{
MirrorBlockJob *s = opaque;
MirrorExitData *data;
BlockDriverState *bs = blk_bs(s->common.blk);
BlockDriverState *target_bs = blk_bs(s->target);
int64_t length;
BlockDriverInfo bdi;
char backing_filename[2];
int ret = 0;
int target_cluster_size = BDRV_SECTOR_SIZE;
if (block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
s->bdev_length = bdrv_getlength(bs);
if (s->bdev_length < 0) {
ret = s->bdev_length;
goto immediate_exit;
} else if (s->bdev_length == 0) {
block_job_event_ready(&s->common);
s->synced = true;
while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
block_job_yield(&s->common);
}
s->common.cancelled = false;
goto immediate_exit;
}
length = DIV_ROUND_UP(s->bdev_length, s->granularity);
s->in_flight_bitmap = bitmap_new(length);
bdrv_get_backing_filename(target_bs, backing_filename,
sizeof(backing_filename));
if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) {
target_cluster_size = bdi.cluster_size;
}
if (backing_filename[0] && !target_bs->backing
&& s->granularity < target_cluster_size) {
s->buf_size = MAX(s->buf_size, target_cluster_size);
s->cow_bitmap = bitmap_new(length);
}
s->target_cluster_sectors = target_cluster_size >> BDRV_SECTOR_BITS;
s->max_iov = MIN(bs->bl.max_iov, target_bs->bl.max_iov);
s->buf = qemu_try_blockalign(bs, s->buf_size);
if (s->buf == NULL) {
ret = -ENOMEM;
goto immediate_exit;
}
mirror_free_init(s);
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
if (!s->is_none_mode) {
ret = mirror_dirty_init(s);
if (ret < 0 || block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
}
assert(!s->dbi);
s->dbi = bdrv_dirty_iter_new(s->dirty_bitmap, 0);
for (;;) {
uint64_t delay_ns = 0;
int64_t cnt, delta;
bool should_complete;
if (s->ret < 0) {
ret = s->ret;
goto immediate_exit;
}
block_job_pause_point(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
s->common.len = s->common.offset +
(cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE;
delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns;
if (delta < SLICE_TIME &&
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 ||
(cnt == 0 && s->in_flight > 0)) {
trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt);
mirror_wait_for_io(s);
continue;
} else if (cnt != 0) {
delay_ns = mirror_iteration(s);
}
}
should_complete = false;
if (s->in_flight == 0 && cnt == 0) {
trace_mirror_before_flush(s);
ret = blk_flush(s->target);
if (ret < 0) {
if (mirror_error_action(s, false, -ret) ==
BLOCK_ERROR_ACTION_REPORT) {
goto immediate_exit;
}
} else {
if (!s->synced) {
block_job_event_ready(&s->common);
s->synced = true;
}
should_complete = s->should_complete ||
block_job_is_cancelled(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
}
if (cnt == 0 && should_complete) {
trace_mirror_before_drain(s, cnt);
bdrv_co_drain(bs);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
ret = 0;
trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
if (!s->synced) {
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
} else if (!should_complete) {
delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
} else if (cnt == 0) {
assert(QLIST_EMPTY(&bs->tracked_requests));
s->common.cancelled = false;
break;
}
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
immediate_exit:
if (s->in_flight > 0) {
assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common)));
mirror_drain(s);
}
assert(s->in_flight == 0);
qemu_vfree(s->buf);
g_free(s->cow_bitmap);
g_free(s->in_flight_bitmap);
bdrv_dirty_iter_free(s->dbi);
bdrv_release_dirty_bitmap(bs, s->dirty_bitmap);
data = g_malloc(sizeof(*data));
data->ret = ret;
bdrv_drained_begin(bs);
block_job_defer_to_main_loop(&s->common, mirror_exit, data);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 mirror_run(void *opaque)
{
MirrorBlockJob *s = opaque;
MirrorExitData *data;
BlockDriverState *bs = blk_bs(s->common.blk);
BlockDriverState *target_bs = blk_bs(s->target);
int64_t length;
BlockDriverInfo bdi;
char backing_filename[2];
int ret = 0;
int target_cluster_size = BDRV_SECTOR_SIZE;
if (block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
s->bdev_length = bdrv_getlength(bs);
if (s->bdev_length < 0) {
ret = s->bdev_length;
goto immediate_exit;
} else if (s->bdev_length == 0) {
block_job_event_ready(&s->common);
s->synced = true;
while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
block_job_yield(&s->common);
}
s->common.cancelled = false;
goto immediate_exit;
}
length = DIV_ROUND_UP(s->bdev_length, s->granularity);
s->in_flight_bitmap = bitmap_new(length);
bdrv_get_backing_filename(target_bs, backing_filename,
sizeof(backing_filename));
if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) {
target_cluster_size = bdi.cluster_size;
}
if (backing_filename[0] && !target_bs->backing
&& s->granularity < target_cluster_size) {
s->buf_size = MAX(s->buf_size, target_cluster_size);
s->cow_bitmap = bitmap_new(length);
}
s->target_cluster_sectors = target_cluster_size >> BDRV_SECTOR_BITS;
s->max_iov = MIN(bs->bl.max_iov, target_bs->bl.max_iov);
s->buf = qemu_try_blockalign(bs, s->buf_size);
if (s->buf == NULL) {
ret = -ENOMEM;
goto immediate_exit;
}
mirror_free_init(s);
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
if (!s->is_none_mode) {
ret = mirror_dirty_init(s);
if (ret < 0 || block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
}
assert(!s->dbi);
s->dbi = bdrv_dirty_iter_new(s->dirty_bitmap, 0);
for (;;) {
uint64_t delay_ns = 0;
int64_t cnt, delta;
bool should_complete;
if (s->ret < 0) {
ret = s->ret;
goto immediate_exit;
}
block_job_pause_point(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
s->common.len = s->common.offset +
(cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE;
delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns;
if (delta < SLICE_TIME &&
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 ||
(cnt == 0 && s->in_flight > 0)) {
trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt);
mirror_wait_for_io(s);
continue;
} else if (cnt != 0) {
delay_ns = mirror_iteration(s);
}
}
should_complete = false;
if (s->in_flight == 0 && cnt == 0) {
trace_mirror_before_flush(s);
ret = blk_flush(s->target);
if (ret < 0) {
if (mirror_error_action(s, false, -ret) ==
BLOCK_ERROR_ACTION_REPORT) {
goto immediate_exit;
}
} else {
if (!s->synced) {
block_job_event_ready(&s->common);
s->synced = true;
}
should_complete = s->should_complete ||
block_job_is_cancelled(&s->common);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
}
if (cnt == 0 && should_complete) {
trace_mirror_before_drain(s, cnt);
bdrv_co_drain(bs);
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
}
ret = 0;
trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
if (!s->synced) {
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
} else if (!should_complete) {
delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
} else if (cnt == 0) {
assert(QLIST_EMPTY(&bs->tracked_requests));
s->common.cancelled = false;
break;
}
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
immediate_exit:
if (s->in_flight > 0) {
assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common)));
mirror_drain(s);
}
assert(s->in_flight == 0);
qemu_vfree(s->buf);
g_free(s->cow_bitmap);
g_free(s->in_flight_bitmap);
bdrv_dirty_iter_free(s->dbi);
bdrv_release_dirty_bitmap(bs, s->dirty_bitmap);
data = g_malloc(sizeof(*data));
data->ret = ret;
bdrv_drained_begin(bs);
block_job_defer_to_main_loop(&s->common, mirror_exit, data);
}
| [
"static void VAR_0 mirror_run(void *opaque)\n{",
"MirrorBlockJob *s = opaque;",
"MirrorExitData *data;",
"BlockDriverState *bs = blk_bs(s->common.blk);",
"BlockDriverState *target_bs = blk_bs(s->target);",
"int64_t length;",
"BlockDriverInfo bdi;",
"char backing_filename[2];",
"int ret = 0;",
"int target_cluster_size = BDRV_SECTOR_SIZE;",
"if (block_job_is_cancelled(&s->common)) {",
"goto immediate_exit;",
"}",
"s->bdev_length = bdrv_getlength(bs);",
"if (s->bdev_length < 0) {",
"ret = s->bdev_length;",
"goto immediate_exit;",
"} else if (s->bdev_length == 0) {",
"block_job_event_ready(&s->common);",
"s->synced = true;",
"while (!block_job_is_cancelled(&s->common) && !s->should_complete) {",
"block_job_yield(&s->common);",
"}",
"s->common.cancelled = false;",
"goto immediate_exit;",
"}",
"length = DIV_ROUND_UP(s->bdev_length, s->granularity);",
"s->in_flight_bitmap = bitmap_new(length);",
"bdrv_get_backing_filename(target_bs, backing_filename,\nsizeof(backing_filename));",
"if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) {",
"target_cluster_size = bdi.cluster_size;",
"}",
"if (backing_filename[0] && !target_bs->backing\n&& s->granularity < target_cluster_size) {",
"s->buf_size = MAX(s->buf_size, target_cluster_size);",
"s->cow_bitmap = bitmap_new(length);",
"}",
"s->target_cluster_sectors = target_cluster_size >> BDRV_SECTOR_BITS;",
"s->max_iov = MIN(bs->bl.max_iov, target_bs->bl.max_iov);",
"s->buf = qemu_try_blockalign(bs, s->buf_size);",
"if (s->buf == NULL) {",
"ret = -ENOMEM;",
"goto immediate_exit;",
"}",
"mirror_free_init(s);",
"s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);",
"if (!s->is_none_mode) {",
"ret = mirror_dirty_init(s);",
"if (ret < 0 || block_job_is_cancelled(&s->common)) {",
"goto immediate_exit;",
"}",
"}",
"assert(!s->dbi);",
"s->dbi = bdrv_dirty_iter_new(s->dirty_bitmap, 0);",
"for (;;) {",
"uint64_t delay_ns = 0;",
"int64_t cnt, delta;",
"bool should_complete;",
"if (s->ret < 0) {",
"ret = s->ret;",
"goto immediate_exit;",
"}",
"block_job_pause_point(&s->common);",
"cnt = bdrv_get_dirty_count(s->dirty_bitmap);",
"s->common.len = s->common.offset +\n(cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE;",
"delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns;",
"if (delta < SLICE_TIME &&\ns->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {",
"if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 ||\n(cnt == 0 && s->in_flight > 0)) {",
"trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt);",
"mirror_wait_for_io(s);",
"continue;",
"} else if (cnt != 0) {",
"delay_ns = mirror_iteration(s);",
"}",
"}",
"should_complete = false;",
"if (s->in_flight == 0 && cnt == 0) {",
"trace_mirror_before_flush(s);",
"ret = blk_flush(s->target);",
"if (ret < 0) {",
"if (mirror_error_action(s, false, -ret) ==\nBLOCK_ERROR_ACTION_REPORT) {",
"goto immediate_exit;",
"}",
"} else {",
"if (!s->synced) {",
"block_job_event_ready(&s->common);",
"s->synced = true;",
"}",
"should_complete = s->should_complete ||\nblock_job_is_cancelled(&s->common);",
"cnt = bdrv_get_dirty_count(s->dirty_bitmap);",
"}",
"}",
"if (cnt == 0 && should_complete) {",
"trace_mirror_before_drain(s, cnt);",
"bdrv_co_drain(bs);",
"cnt = bdrv_get_dirty_count(s->dirty_bitmap);",
"}",
"ret = 0;",
"trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);",
"if (!s->synced) {",
"block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);",
"if (block_job_is_cancelled(&s->common)) {",
"break;",
"}",
"} else if (!should_complete) {",
"delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);",
"block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);",
"} else if (cnt == 0) {",
"assert(QLIST_EMPTY(&bs->tracked_requests));",
"s->common.cancelled = false;",
"break;",
"}",
"s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);",
"}",
"immediate_exit:\nif (s->in_flight > 0) {",
"assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common)));",
"mirror_drain(s);",
"}",
"assert(s->in_flight == 0);",
"qemu_vfree(s->buf);",
"g_free(s->cow_bitmap);",
"g_free(s->in_flight_bitmap);",
"bdrv_dirty_iter_free(s->dbi);",
"bdrv_release_dirty_bitmap(bs, s->dirty_bitmap);",
"data = g_malloc(sizeof(*data));",
"data->ret = ret;",
"bdrv_drained_begin(bs);",
"block_job_defer_to_main_loop(&s->common, mirror_exit, data);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
165
],
[
175,
177
],
[
191
],
[
193,
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
287
],
[
289
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339,
341
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373
],
[
375
],
[
381
],
[
383
],
[
385
]
] |
23,137 | int check_params(const char * const *params, const char *str)
{
int name_buf_size = 1;
const char *p;
char *name_buf;
int i, len;
int ret = 0;
for (i = 0; params[i] != NULL; i++) {
len = strlen(params[i]) + 1;
if (len > name_buf_size) {
name_buf_size = len;
}
}
name_buf = qemu_malloc(name_buf_size);
p = str;
while (*p != '\0') {
p = get_opt_name(name_buf, name_buf_size, p, '=');
if (*p != '=') {
ret = -1;
break;
}
p++;
for(i = 0; params[i] != NULL; i++)
if (!strcmp(params[i], name_buf))
break;
if (params[i] == NULL) {
ret = -1;
break;
}
p = get_opt_value(NULL, 0, p);
if (*p != ',')
break;
p++;
}
qemu_free(name_buf);
return ret;
}
| false | qemu | 0aa7a205c899c516d906673efbe9457f7af0dd3c | int check_params(const char * const *params, const char *str)
{
int name_buf_size = 1;
const char *p;
char *name_buf;
int i, len;
int ret = 0;
for (i = 0; params[i] != NULL; i++) {
len = strlen(params[i]) + 1;
if (len > name_buf_size) {
name_buf_size = len;
}
}
name_buf = qemu_malloc(name_buf_size);
p = str;
while (*p != '\0') {
p = get_opt_name(name_buf, name_buf_size, p, '=');
if (*p != '=') {
ret = -1;
break;
}
p++;
for(i = 0; params[i] != NULL; i++)
if (!strcmp(params[i], name_buf))
break;
if (params[i] == NULL) {
ret = -1;
break;
}
p = get_opt_value(NULL, 0, p);
if (*p != ',')
break;
p++;
}
qemu_free(name_buf);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char * const *VAR_0, const char *VAR_1)
{
int VAR_2 = 1;
const char *VAR_3;
char *VAR_4;
int VAR_5, VAR_6;
int VAR_7 = 0;
for (VAR_5 = 0; VAR_0[VAR_5] != NULL; VAR_5++) {
VAR_6 = strlen(VAR_0[VAR_5]) + 1;
if (VAR_6 > VAR_2) {
VAR_2 = VAR_6;
}
}
VAR_4 = qemu_malloc(VAR_2);
VAR_3 = VAR_1;
while (*VAR_3 != '\0') {
VAR_3 = get_opt_name(VAR_4, VAR_2, VAR_3, '=');
if (*VAR_3 != '=') {
VAR_7 = -1;
break;
}
VAR_3++;
for(VAR_5 = 0; VAR_0[VAR_5] != NULL; VAR_5++)
if (!strcmp(VAR_0[VAR_5], VAR_4))
break;
if (VAR_0[VAR_5] == NULL) {
VAR_7 = -1;
break;
}
VAR_3 = get_opt_value(NULL, 0, VAR_3);
if (*VAR_3 != ',')
break;
VAR_3++;
}
qemu_free(VAR_4);
return VAR_7;
}
| [
"int FUNC_0(const char * const *VAR_0, const char *VAR_1)\n{",
"int VAR_2 = 1;",
"const char *VAR_3;",
"char *VAR_4;",
"int VAR_5, VAR_6;",
"int VAR_7 = 0;",
"for (VAR_5 = 0; VAR_0[VAR_5] != NULL; VAR_5++) {",
"VAR_6 = strlen(VAR_0[VAR_5]) + 1;",
"if (VAR_6 > VAR_2) {",
"VAR_2 = VAR_6;",
"}",
"}",
"VAR_4 = qemu_malloc(VAR_2);",
"VAR_3 = VAR_1;",
"while (*VAR_3 != '\\0') {",
"VAR_3 = get_opt_name(VAR_4, VAR_2, VAR_3, '=');",
"if (*VAR_3 != '=') {",
"VAR_7 = -1;",
"break;",
"}",
"VAR_3++;",
"for(VAR_5 = 0; VAR_0[VAR_5] != NULL; VAR_5++)",
"if (!strcmp(VAR_0[VAR_5], VAR_4))\nbreak;",
"if (VAR_0[VAR_5] == NULL) {",
"VAR_7 = -1;",
"break;",
"}",
"VAR_3 = get_opt_value(NULL, 0, VAR_3);",
"if (*VAR_3 != ',')\nbreak;",
"VAR_3++;",
"}",
"qemu_free(VAR_4);",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
]
] |
23,138 | static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
fw_cfg_write(opaque, (uint8_t)value);
}
| false | qemu | cfaadf0e89e7c2a47462d5f96390c9a9b4de037c | static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
fw_cfg_write(opaque, (uint8_t)value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
fw_cfg_write(VAR_0, (uint8_t)VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"fw_cfg_write(VAR_0, (uint8_t)VAR_2);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
23,139 | static void simple_whitespace(void)
{
int i;
struct {
const char *encoded;
LiteralQObject decoded;
} test_cases[] = {
{
.encoded = " [ 43 , 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ "a", QLIT_QINT(32) },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{ }
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| false | qemu | 9eaaf971683c99ed197fa1b7d1a3ca9baabfb3ee | static void simple_whitespace(void)
{
int i;
struct {
const char *encoded;
LiteralQObject decoded;
} test_cases[] = {
{
.encoded = " [ 43 , 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ "a", QLIT_QINT(32) },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{ }
};
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
QString *str;
obj = qobject_from_json(test_cases[i].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0;
struct {
const char *encoded;
LiteralQObject decoded;
} VAR_1[] = {
{
.encoded = " [ 43 , 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
QLIT_QINT(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ "a", QLIT_QINT(32) },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
QLIT_QINT(42),
{ }
})),
},
{ }
};
for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {
QObject *obj;
QString *str;
obj = qobject_from_json(VAR_1[VAR_0].encoded);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);
str = qobject_to_json(obj);
qobject_decref(obj);
obj = qobject_from_json(qstring_get_str(str));
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QLIST);
g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);
qobject_decref(obj);
QDECREF(str);
}
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"struct {",
"const char *encoded;",
"LiteralQObject decoded;",
"} VAR_1[] = {",
"{",
".encoded = \" [ 43 , 42 ]\",\n.decoded = QLIT_QLIST(((LiteralQObject[]){",
"QLIT_QINT(43),\nQLIT_QINT(42),\n{ }",
"})),",
"},",
"{",
".encoded = \" [ 43 , { 'h' : 'b' }, [ ], 42 ]\",",
".decoded = QLIT_QLIST(((LiteralQObject[]){",
"QLIT_QINT(43),\nQLIT_QDICT(((LiteralQDictEntry[]){",
"{ \"h\", QLIT_QSTR(\"b\") },",
"{ }})),",
"QLIT_QLIST(((LiteralQObject[]){",
"{ }})),",
"QLIT_QINT(42),\n{ }",
"})),",
"},",
"{",
".encoded = \" [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]\",",
".decoded = QLIT_QLIST(((LiteralQObject[]){",
"QLIT_QINT(43),\nQLIT_QDICT(((LiteralQDictEntry[]){",
"{ \"h\", QLIT_QSTR(\"b\") },",
"{ \"a\", QLIT_QINT(32) },",
"{ }})),",
"QLIT_QLIST(((LiteralQObject[]){",
"{ }})),",
"QLIT_QINT(42),\n{ }",
"})),",
"},",
"{ }",
"};",
"for (VAR_0 = 0; VAR_1[VAR_0].encoded; VAR_0++) {",
"QObject *obj;",
"QString *str;",
"obj = qobject_from_json(VAR_1[VAR_0].encoded);",
"g_assert(obj != NULL);",
"g_assert(qobject_type(obj) == QTYPE_QLIST);",
"g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);",
"str = qobject_to_json(obj);",
"qobject_decref(obj);",
"obj = qobject_from_json(qstring_get_str(str));",
"g_assert(obj != NULL);",
"g_assert(qobject_type(obj) == QTYPE_QLIST);",
"g_assert(compare_litqobj_to_qobj(&VAR_1[VAR_0].decoded, obj) == 1);",
"qobject_decref(obj);",
"QDECREF(str);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
]
] |
23,141 | void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)
{
CPUX86State *saved_env;
saved_env = env;
env = s;
helper_fsave(ptr, data32);
env = saved_env;
}
| false | qemu | e4533c7a8cdcc79ccdf695f0aaa2e23a5b926ed0 | void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)
{
CPUX86State *saved_env;
saved_env = env;
env = s;
helper_fsave(ptr, data32);
env = saved_env;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUX86State *VAR_0, uint8_t *VAR_1, int VAR_2)
{
CPUX86State *saved_env;
saved_env = env;
env = VAR_0;
helper_fsave(VAR_1, VAR_2);
env = saved_env;
}
| [
"void FUNC_0(CPUX86State *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"CPUX86State *saved_env;",
"saved_env = env;",
"env = VAR_0;",
"helper_fsave(VAR_1, VAR_2);",
"env = saved_env;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
]
] |
23,142 | int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
int64_t d;
FdMigrationState *s;
d = qdict_get_int(qdict, "value");
d = MAX(0, MIN(UINT32_MAX, d));
max_throttle = d;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
return 0;
}
| false | qemu | 3d002df33eb034757d98e1ae529318f57df78f91 | int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
int64_t d;
FdMigrationState *s;
d = qdict_get_int(qdict, "value");
d = MAX(0, MIN(UINT32_MAX, d));
max_throttle = d;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{
int64_t d;
FdMigrationState *s;
d = qdict_get_int(VAR_1, "value");
d = MAX(0, MIN(UINT32_MAX, d));
max_throttle = d;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
return 0;
}
| [
"int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{",
"int64_t d;",
"FdMigrationState *s;",
"d = qdict_get_int(VAR_1, \"value\");",
"d = MAX(0, MIN(UINT32_MAX, d));",
"max_throttle = d;",
"s = migrate_to_fms(current_migration);",
"if (s && s->file) {",
"qemu_file_set_rate_limit(s->file, max_throttle);",
"}",
"return 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
]
] |
23,143 | static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,
const char *old_name, V9fsPath *newdir,
const char *new_name)
{
int ret;
V9fsString old_full_name, new_full_name;
v9fs_string_init(&old_full_name);
v9fs_string_init(&new_full_name);
v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);
v9fs_string_free(&old_full_name);
v9fs_string_free(&new_full_name);
return ret;
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,
const char *old_name, V9fsPath *newdir,
const char *new_name)
{
int ret;
V9fsString old_full_name, new_full_name;
v9fs_string_init(&old_full_name);
v9fs_string_init(&new_full_name);
v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);
v9fs_string_free(&old_full_name);
v9fs_string_free(&new_full_name);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, V9fsPath *VAR_3,
const char *VAR_4)
{
int VAR_5;
V9fsString old_full_name, new_full_name;
v9fs_string_init(&old_full_name);
v9fs_string_init(&new_full_name);
v9fs_string_sprintf(&old_full_name, "%s/%s", VAR_1->data, VAR_2);
v9fs_string_sprintf(&new_full_name, "%s/%s", VAR_3->data, VAR_4);
VAR_5 = proxy_rename(VAR_0, old_full_name.data, new_full_name.data);
v9fs_string_free(&old_full_name);
v9fs_string_free(&new_full_name);
return VAR_5;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst char *VAR_2, V9fsPath *VAR_3,\nconst char *VAR_4)\n{",
"int VAR_5;",
"V9fsString old_full_name, new_full_name;",
"v9fs_string_init(&old_full_name);",
"v9fs_string_init(&new_full_name);",
"v9fs_string_sprintf(&old_full_name, \"%s/%s\", VAR_1->data, VAR_2);",
"v9fs_string_sprintf(&new_full_name, \"%s/%s\", VAR_3->data, VAR_4);",
"VAR_5 = proxy_rename(VAR_0, old_full_name.data, new_full_name.data);",
"v9fs_string_free(&old_full_name);",
"v9fs_string_free(&new_full_name);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
23,144 | PCIBus *pci_register_bus(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq)
{
PCIBus *bus;
static int nbus = 0;
bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, parent, name));
bus->set_irq = set_irq;
bus->map_irq = map_irq;
bus->irq_opaque = pic;
bus->devfn_min = devfn_min;
bus->nirq = nirq;
bus->irq_count = qemu_malloc(nirq * sizeof(bus->irq_count[0]));
bus->next = first_bus;
first_bus = bus;
register_savevm("PCIBUS", nbus++, 1, pcibus_save, pcibus_load, bus);
qemu_register_reset(pci_bus_reset, bus);
return bus;
}
| false | qemu | 616cbc78a50c638b94cc4756a565f11bb10dbfeb | PCIBus *pci_register_bus(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq)
{
PCIBus *bus;
static int nbus = 0;
bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, parent, name));
bus->set_irq = set_irq;
bus->map_irq = map_irq;
bus->irq_opaque = pic;
bus->devfn_min = devfn_min;
bus->nirq = nirq;
bus->irq_count = qemu_malloc(nirq * sizeof(bus->irq_count[0]));
bus->next = first_bus;
first_bus = bus;
register_savevm("PCIBUS", nbus++, 1, pcibus_save, pcibus_load, bus);
qemu_register_reset(pci_bus_reset, bus);
return bus;
}
| {
"code": [],
"line_no": []
} | PCIBus *FUNC_0(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
qemu_irq *pic, int devfn_min, int nirq)
{
PCIBus *bus;
static int VAR_0 = 0;
bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, parent, name));
bus->set_irq = set_irq;
bus->map_irq = map_irq;
bus->irq_opaque = pic;
bus->devfn_min = devfn_min;
bus->nirq = nirq;
bus->irq_count = qemu_malloc(nirq * sizeof(bus->irq_count[0]));
bus->next = first_bus;
first_bus = bus;
register_savevm("PCIBUS", VAR_0++, 1, pcibus_save, pcibus_load, bus);
qemu_register_reset(pci_bus_reset, bus);
return bus;
}
| [
"PCIBus *FUNC_0(DeviceState *parent, const char *name,\npci_set_irq_fn set_irq, pci_map_irq_fn map_irq,\nqemu_irq *pic, int devfn_min, int nirq)\n{",
"PCIBus *bus;",
"static int VAR_0 = 0;",
"bus = FROM_QBUS(PCIBus, qbus_create(&pci_bus_info, parent, name));",
"bus->set_irq = set_irq;",
"bus->map_irq = map_irq;",
"bus->irq_opaque = pic;",
"bus->devfn_min = devfn_min;",
"bus->nirq = nirq;",
"bus->irq_count = qemu_malloc(nirq * sizeof(bus->irq_count[0]));",
"bus->next = first_bus;",
"first_bus = bus;",
"register_savevm(\"PCIBUS\", VAR_0++, 1, pcibus_save, pcibus_load, bus);",
"qemu_register_reset(pci_bus_reset, bus);",
"return bus;",
"}"
] | [
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
]
] |
23,147 | static int idcin_probe(AVProbeData *p)
{
unsigned int number;
/*
* This is what you could call a "probabilistic" file check: Id CIN
* files don't have a definite file signature. In lieu of such a marker,
* perform sanity checks on the 5 32-bit header fields:
* width, height: greater than 0, less than or equal to 1024
* audio sample rate: greater than or equal to 8000, less than or
* equal to 48000, or 0 for no audio
* audio sample width (bytes/sample): 0 for no audio, or 1 or 2
* audio channels: 0 for no audio, or 1 or 2
*/
/* cannot proceed without 20 bytes */
if (p->buf_size < 20)
return 0;
/* check the video width */
number = AV_RL32(&p->buf[0]);
if ((number == 0) || (number > 1024))
return 0;
/* check the video height */
number = AV_RL32(&p->buf[4]);
if ((number == 0) || (number > 1024))
return 0;
/* check the audio sample rate */
number = AV_RL32(&p->buf[8]);
if ((number != 0) && ((number < 8000) | (number > 48000)))
return 0;
/* check the audio bytes/sample */
number = AV_RL32(&p->buf[12]);
if (number > 2)
return 0;
/* check the audio channels */
number = AV_RL32(&p->buf[16]);
if (number > 2)
return 0;
/* return half certainly since this check is a bit sketchy */
return AVPROBE_SCORE_MAX / 2;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int idcin_probe(AVProbeData *p)
{
unsigned int number;
if (p->buf_size < 20)
return 0;
number = AV_RL32(&p->buf[0]);
if ((number == 0) || (number > 1024))
return 0;
number = AV_RL32(&p->buf[4]);
if ((number == 0) || (number > 1024))
return 0;
number = AV_RL32(&p->buf[8]);
if ((number != 0) && ((number < 8000) | (number > 48000)))
return 0;
number = AV_RL32(&p->buf[12]);
if (number > 2)
return 0;
number = AV_RL32(&p->buf[16]);
if (number > 2)
return 0;
return AVPROBE_SCORE_MAX / 2;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
unsigned int VAR_1;
if (VAR_0->buf_size < 20)
return 0;
VAR_1 = AV_RL32(&VAR_0->buf[0]);
if ((VAR_1 == 0) || (VAR_1 > 1024))
return 0;
VAR_1 = AV_RL32(&VAR_0->buf[4]);
if ((VAR_1 == 0) || (VAR_1 > 1024))
return 0;
VAR_1 = AV_RL32(&VAR_0->buf[8]);
if ((VAR_1 != 0) && ((VAR_1 < 8000) | (VAR_1 > 48000)))
return 0;
VAR_1 = AV_RL32(&VAR_0->buf[12]);
if (VAR_1 > 2)
return 0;
VAR_1 = AV_RL32(&VAR_0->buf[16]);
if (VAR_1 > 2)
return 0;
return AVPROBE_SCORE_MAX / 2;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"unsigned int VAR_1;",
"if (VAR_0->buf_size < 20)\nreturn 0;",
"VAR_1 = AV_RL32(&VAR_0->buf[0]);",
"if ((VAR_1 == 0) || (VAR_1 > 1024))\nreturn 0;",
"VAR_1 = AV_RL32(&VAR_0->buf[4]);",
"if ((VAR_1 == 0) || (VAR_1 > 1024))\nreturn 0;",
"VAR_1 = AV_RL32(&VAR_0->buf[8]);",
"if ((VAR_1 != 0) && ((VAR_1 < 8000) | (VAR_1 > 48000)))\nreturn 0;",
"VAR_1 = AV_RL32(&VAR_0->buf[12]);",
"if (VAR_1 > 2)\nreturn 0;",
"VAR_1 = AV_RL32(&VAR_0->buf[16]);",
"if (VAR_1 > 2)\nreturn 0;",
"return AVPROBE_SCORE_MAX / 2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
33,
35
],
[
41
],
[
43,
45
],
[
51
],
[
53,
55
],
[
61
],
[
63,
65
],
[
71
],
[
73,
75
],
[
81
],
[
83,
85
],
[
91
],
[
93
]
] |
23,148 | ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
{
FdMigrationState *s = opaque;
ssize_t ret;
do {
ret = s->write(s, data, size);
} while (ret == -1 && ((s->get_error(s)) == EINTR || (s->get_error(s)) == EWOULDBLOCK));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EAGAIN)
qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
return ret;
}
| false | qemu | 95b134ea02a3e2c2508f907db4ab1379ffdb0bef | ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
{
FdMigrationState *s = opaque;
ssize_t ret;
do {
ret = s->write(s, data, size);
} while (ret == -1 && ((s->get_error(s)) == EINTR || (s->get_error(s)) == EWOULDBLOCK));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EAGAIN)
qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
return ret;
}
| {
"code": [],
"line_no": []
} | ssize_t FUNC_0(void *opaque, const void *data, size_t size)
{
FdMigrationState *s = opaque;
ssize_t ret;
do {
ret = s->write(s, data, size);
} while (ret == -1 && ((s->get_error(s)) == EINTR || (s->get_error(s)) == EWOULDBLOCK));
if (ret == -1)
ret = -(s->get_error(s));
if (ret == -EAGAIN)
qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
return ret;
}
| [
"ssize_t FUNC_0(void *opaque, const void *data, size_t size)\n{",
"FdMigrationState *s = opaque;",
"ssize_t ret;",
"do {",
"ret = s->write(s, data, size);",
"} while (ret == -1 && ((s->get_error(s)) == EINTR || (s->get_error(s)) == EWOULDBLOCK));",
"if (ret == -1)\nret = -(s->get_error(s));",
"if (ret == -EAGAIN)\nqemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25,
27
],
[
31
],
[
33
]
] |
23,149 | static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
DeviceState *d;
APICCommonState *s;
int index = (addr >> 4) & 0xff;
if (addr > 0xfff || !index) {
/* MSI and MMIO APIC are at the same memory location,
* but actually not on the global bus: MSI is on PCI bus
* APIC is connected directly to the CPU.
* Mapping them on the global bus happens to work because
* MSI registers are reserved in APIC MMIO and vice versa. */
apic_send_msi(addr, val);
return;
}
d = cpu_get_current_apic();
if (!d) {
return;
}
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
trace_apic_mem_writel(addr, val);
switch(index) {
case 0x02:
s->id = (val >> 24);
break;
case 0x03:
break;
case 0x08:
if (apic_report_tpr_access) {
cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE);
}
s->tpr = val;
apic_sync_vapic(s, SYNC_TO_VAPIC);
apic_update_irq(s);
break;
case 0x09:
case 0x0a:
break;
case 0x0b: /* EOI */
apic_eoi(s);
break;
case 0x0d:
s->log_dest = val >> 24;
break;
case 0x0e:
s->dest_mode = val >> 28;
break;
case 0x0f:
s->spurious_vec = val & 0x1ff;
apic_update_irq(s);
break;
case 0x10 ... 0x17:
case 0x18 ... 0x1f:
case 0x20 ... 0x27:
case 0x28:
break;
case 0x30:
s->icr[0] = val;
apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
(s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
(s->icr[0] >> 15) & 1);
break;
case 0x31:
s->icr[1] = val;
break;
case 0x32 ... 0x37:
{
int n = index - 0x32;
s->lvt[n] = val;
if (n == APIC_LVT_TIMER) {
apic_timer_update(s, qemu_get_clock_ns(vm_clock));
} else if (n == APIC_LVT_LINT0 && apic_check_pic(s)) {
apic_update_irq(s);
}
}
break;
case 0x38:
s->initial_count = val;
s->initial_count_load_time = qemu_get_clock_ns(vm_clock);
apic_timer_update(s, s->initial_count_load_time);
break;
case 0x39:
break;
case 0x3e:
{
int v;
s->divide_conf = val & 0xb;
v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
s->count_shift = (v + 1) & 7;
}
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
DeviceState *d;
APICCommonState *s;
int index = (addr >> 4) & 0xff;
if (addr > 0xfff || !index) {
apic_send_msi(addr, val);
return;
}
d = cpu_get_current_apic();
if (!d) {
return;
}
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
trace_apic_mem_writel(addr, val);
switch(index) {
case 0x02:
s->id = (val >> 24);
break;
case 0x03:
break;
case 0x08:
if (apic_report_tpr_access) {
cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE);
}
s->tpr = val;
apic_sync_vapic(s, SYNC_TO_VAPIC);
apic_update_irq(s);
break;
case 0x09:
case 0x0a:
break;
case 0x0b:
apic_eoi(s);
break;
case 0x0d:
s->log_dest = val >> 24;
break;
case 0x0e:
s->dest_mode = val >> 28;
break;
case 0x0f:
s->spurious_vec = val & 0x1ff;
apic_update_irq(s);
break;
case 0x10 ... 0x17:
case 0x18 ... 0x1f:
case 0x20 ... 0x27:
case 0x28:
break;
case 0x30:
s->icr[0] = val;
apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
(s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
(s->icr[0] >> 15) & 1);
break;
case 0x31:
s->icr[1] = val;
break;
case 0x32 ... 0x37:
{
int n = index - 0x32;
s->lvt[n] = val;
if (n == APIC_LVT_TIMER) {
apic_timer_update(s, qemu_get_clock_ns(vm_clock));
} else if (n == APIC_LVT_LINT0 && apic_check_pic(s)) {
apic_update_irq(s);
}
}
break;
case 0x38:
s->initial_count = val;
s->initial_count_load_time = qemu_get_clock_ns(vm_clock);
apic_timer_update(s, s->initial_count_load_time);
break;
case 0x39:
break;
case 0x3e:
{
int v;
s->divide_conf = val & 0xb;
v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
s->count_shift = (v + 1) & 7;
}
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
DeviceState *d;
APICCommonState *s;
int VAR_3 = (VAR_1 >> 4) & 0xff;
if (VAR_1 > 0xfff || !VAR_3) {
apic_send_msi(VAR_1, VAR_2);
return;
}
d = cpu_get_current_apic();
if (!d) {
return;
}
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
trace_apic_mem_writel(VAR_1, VAR_2);
switch(VAR_3) {
case 0x02:
s->id = (VAR_2 >> 24);
break;
case 0x03:
break;
case 0x08:
if (apic_report_tpr_access) {
cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE);
}
s->tpr = VAR_2;
apic_sync_vapic(s, SYNC_TO_VAPIC);
apic_update_irq(s);
break;
case 0x09:
case 0x0a:
break;
case 0x0b:
apic_eoi(s);
break;
case 0x0d:
s->log_dest = VAR_2 >> 24;
break;
case 0x0e:
s->dest_mode = VAR_2 >> 28;
break;
case 0x0f:
s->spurious_vec = VAR_2 & 0x1ff;
apic_update_irq(s);
break;
case 0x10 ... 0x17:
case 0x18 ... 0x1f:
case 0x20 ... 0x27:
case 0x28:
break;
case 0x30:
s->icr[0] = VAR_2;
apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
(s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
(s->icr[0] >> 15) & 1);
break;
case 0x31:
s->icr[1] = VAR_2;
break;
case 0x32 ... 0x37:
{
int VAR_4 = VAR_3 - 0x32;
s->lvt[VAR_4] = VAR_2;
if (VAR_4 == APIC_LVT_TIMER) {
apic_timer_update(s, qemu_get_clock_ns(vm_clock));
} else if (VAR_4 == APIC_LVT_LINT0 && apic_check_pic(s)) {
apic_update_irq(s);
}
}
break;
case 0x38:
s->initial_count = VAR_2;
s->initial_count_load_time = qemu_get_clock_ns(vm_clock);
apic_timer_update(s, s->initial_count_load_time);
break;
case 0x39:
break;
case 0x3e:
{
int VAR_5;
s->divide_conf = VAR_2 & 0xb;
VAR_5 = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
s->count_shift = (VAR_5 + 1) & 7;
}
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"DeviceState *d;",
"APICCommonState *s;",
"int VAR_3 = (VAR_1 >> 4) & 0xff;",
"if (VAR_1 > 0xfff || !VAR_3) {",
"apic_send_msi(VAR_1, VAR_2);",
"return;",
"}",
"d = cpu_get_current_apic();",
"if (!d) {",
"return;",
"}",
"s = DO_UPCAST(APICCommonState, busdev.qdev, d);",
"trace_apic_mem_writel(VAR_1, VAR_2);",
"switch(VAR_3) {",
"case 0x02:\ns->id = (VAR_2 >> 24);",
"break;",
"case 0x03:\nbreak;",
"case 0x08:\nif (apic_report_tpr_access) {",
"cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE);",
"}",
"s->tpr = VAR_2;",
"apic_sync_vapic(s, SYNC_TO_VAPIC);",
"apic_update_irq(s);",
"break;",
"case 0x09:\ncase 0x0a:\nbreak;",
"case 0x0b:\napic_eoi(s);",
"break;",
"case 0x0d:\ns->log_dest = VAR_2 >> 24;",
"break;",
"case 0x0e:\ns->dest_mode = VAR_2 >> 28;",
"break;",
"case 0x0f:\ns->spurious_vec = VAR_2 & 0x1ff;",
"apic_update_irq(s);",
"break;",
"case 0x10 ... 0x17:\ncase 0x18 ... 0x1f:\ncase 0x20 ... 0x27:\ncase 0x28:\nbreak;",
"case 0x30:\ns->icr[0] = VAR_2;",
"apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,\n(s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),\n(s->icr[0] >> 15) & 1);",
"break;",
"case 0x31:\ns->icr[1] = VAR_2;",
"break;",
"case 0x32 ... 0x37:\n{",
"int VAR_4 = VAR_3 - 0x32;",
"s->lvt[VAR_4] = VAR_2;",
"if (VAR_4 == APIC_LVT_TIMER) {",
"apic_timer_update(s, qemu_get_clock_ns(vm_clock));",
"} else if (VAR_4 == APIC_LVT_LINT0 && apic_check_pic(s)) {",
"apic_update_irq(s);",
"}",
"}",
"break;",
"case 0x38:\ns->initial_count = VAR_2;",
"s->initial_count_load_time = qemu_get_clock_ns(vm_clock);",
"apic_timer_update(s, s->initial_count_load_time);",
"break;",
"case 0x39:\nbreak;",
"case 0x3e:\n{",
"int VAR_5;",
"s->divide_conf = VAR_2 & 0xb;",
"VAR_5 = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);",
"s->count_shift = (VAR_5 + 1) & 7;",
"}",
"break;",
"default:\ns->esr |= ESR_ILLEGAL_ADDRESS;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
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
]
] |
23,150 | static void pxa2xx_gpio_set(void *opaque, int line, int level)
{
PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;
CPUState *cpu = CPU(s->cpu);
int bank;
uint32_t mask;
if (line >= s->lines) {
printf("%s: No GPIO pin %i\n", __FUNCTION__, line);
return;
}
bank = line >> 5;
mask = 1U << (line & 31);
if (level) {
s->status[bank] |= s->rising[bank] & mask &
~s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] |= mask;
} else {
s->status[bank] |= s->falling[bank] & mask &
s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] &= ~mask;
}
if (s->status[bank] & mask)
pxa2xx_gpio_irq_update(s);
/* Wake-up GPIOs */
if (cpu->halted && (mask & ~s->dir[bank] & pxa2xx_gpio_wake[bank])) {
cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);
}
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void pxa2xx_gpio_set(void *opaque, int line, int level)
{
PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) opaque;
CPUState *cpu = CPU(s->cpu);
int bank;
uint32_t mask;
if (line >= s->lines) {
printf("%s: No GPIO pin %i\n", __FUNCTION__, line);
return;
}
bank = line >> 5;
mask = 1U << (line & 31);
if (level) {
s->status[bank] |= s->rising[bank] & mask &
~s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] |= mask;
} else {
s->status[bank] |= s->falling[bank] & mask &
s->ilevel[bank] & ~s->dir[bank];
s->ilevel[bank] &= ~mask;
}
if (s->status[bank] & mask)
pxa2xx_gpio_irq_update(s);
if (cpu->halted && (mask & ~s->dir[bank] & pxa2xx_gpio_wake[bank])) {
cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)
{
PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) VAR_0;
CPUState *cpu = CPU(s->cpu);
int VAR_3;
uint32_t mask;
if (VAR_1 >= s->lines) {
printf("%s: No GPIO pin %i\n", __FUNCTION__, VAR_1);
return;
}
VAR_3 = VAR_1 >> 5;
mask = 1U << (VAR_1 & 31);
if (VAR_2) {
s->status[VAR_3] |= s->rising[VAR_3] & mask &
~s->ilevel[VAR_3] & ~s->dir[VAR_3];
s->ilevel[VAR_3] |= mask;
} else {
s->status[VAR_3] |= s->falling[VAR_3] & mask &
s->ilevel[VAR_3] & ~s->dir[VAR_3];
s->ilevel[VAR_3] &= ~mask;
}
if (s->status[VAR_3] & mask)
pxa2xx_gpio_irq_update(s);
if (cpu->halted && (mask & ~s->dir[VAR_3] & pxa2xx_gpio_wake[VAR_3])) {
cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);
}
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1, int VAR_2)\n{",
"PXA2xxGPIOInfo *s = (PXA2xxGPIOInfo *) VAR_0;",
"CPUState *cpu = CPU(s->cpu);",
"int VAR_3;",
"uint32_t mask;",
"if (VAR_1 >= s->lines) {",
"printf(\"%s: No GPIO pin %i\\n\", __FUNCTION__, VAR_1);",
"return;",
"}",
"VAR_3 = VAR_1 >> 5;",
"mask = 1U << (VAR_1 & 31);",
"if (VAR_2) {",
"s->status[VAR_3] |= s->rising[VAR_3] & mask &\n~s->ilevel[VAR_3] & ~s->dir[VAR_3];",
"s->ilevel[VAR_3] |= mask;",
"} else {",
"s->status[VAR_3] |= s->falling[VAR_3] & mask &\ns->ilevel[VAR_3] & ~s->dir[VAR_3];",
"s->ilevel[VAR_3] &= ~mask;",
"}",
"if (s->status[VAR_3] & mask)\npxa2xx_gpio_irq_update(s);",
"if (cpu->halted && (mask & ~s->dir[VAR_3] & pxa2xx_gpio_wake[VAR_3])) {",
"cpu_interrupt(cpu, CPU_INTERRUPT_EXITTB);",
"}",
"}"
] | [
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
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51,
53
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
23,151 | int vhost_net_start(struct vhost_net *net,
VirtIODevice *dev)
{
struct vhost_vring_file file = { };
int r;
if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(net->vc,
sizeof(struct virtio_net_hdr_mrg_rxbuf));
}
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
r = vhost_dev_start(&net->dev, dev);
if (r < 0) {
return r;
}
net->vc->info->poll(net->vc, false);
qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
file.fd = net->backend;
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
if (r < 0) {
r = -errno;
goto fail;
}
}
return 0;
fail:
file.fd = -1;
while (--file.index >= 0) {
int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
assert(r >= 0);
}
net->vc->info->poll(net->vc, true);
vhost_dev_stop(&net->dev, dev);
if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(net->vc, sizeof(struct virtio_net_hdr));
}
return r;
}
| false | qemu | 6b37c87c96a5b148685e8e6bf09d0aca953cb1a8 | int vhost_net_start(struct vhost_net *net,
VirtIODevice *dev)
{
struct vhost_vring_file file = { };
int r;
if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(net->vc,
sizeof(struct virtio_net_hdr_mrg_rxbuf));
}
net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
r = vhost_dev_start(&net->dev, dev);
if (r < 0) {
return r;
}
net->vc->info->poll(net->vc, false);
qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
file.fd = net->backend;
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
if (r < 0) {
r = -errno;
goto fail;
}
}
return 0;
fail:
file.fd = -1;
while (--file.index >= 0) {
int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
assert(r >= 0);
}
net->vc->info->poll(net->vc, true);
vhost_dev_stop(&net->dev, dev);
if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(net->vc, sizeof(struct virtio_net_hdr));
}
return r;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(struct vhost_net *VAR_0,
VirtIODevice *VAR_1)
{
struct vhost_vring_file VAR_2 = { };
int VAR_4;
if (VAR_0->VAR_1.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(VAR_0->vc,
sizeof(struct virtio_net_hdr_mrg_rxbuf));
}
VAR_0->VAR_1.nvqs = 2;
VAR_0->VAR_1.vqs = VAR_0->vqs;
VAR_4 = vhost_dev_start(&VAR_0->VAR_1, VAR_1);
if (VAR_4 < 0) {
return VAR_4;
}
VAR_0->vc->info->poll(VAR_0->vc, false);
qemu_set_fd_handler(VAR_0->backend, NULL, NULL, NULL);
VAR_2.fd = VAR_0->backend;
for (VAR_2.index = 0; VAR_2.index < VAR_0->VAR_1.nvqs; ++VAR_2.index) {
VAR_4 = ioctl(VAR_0->VAR_1.control, VHOST_NET_SET_BACKEND, &VAR_2);
if (VAR_4 < 0) {
VAR_4 = -errno;
goto fail;
}
}
return 0;
fail:
VAR_2.fd = -1;
while (--VAR_2.index >= 0) {
int VAR_4 = ioctl(VAR_0->VAR_1.control, VHOST_NET_SET_BACKEND, &VAR_2);
assert(VAR_4 >= 0);
}
VAR_0->vc->info->poll(VAR_0->vc, true);
vhost_dev_stop(&VAR_0->VAR_1, VAR_1);
if (VAR_0->VAR_1.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
tap_set_vnet_hdr_len(VAR_0->vc, sizeof(struct virtio_net_hdr));
}
return VAR_4;
}
| [
"int FUNC_0(struct vhost_net *VAR_0,\nVirtIODevice *VAR_1)\n{",
"struct vhost_vring_file VAR_2 = { };",
"int VAR_4;",
"if (VAR_0->VAR_1.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {",
"tap_set_vnet_hdr_len(VAR_0->vc,\nsizeof(struct virtio_net_hdr_mrg_rxbuf));",
"}",
"VAR_0->VAR_1.nvqs = 2;",
"VAR_0->VAR_1.vqs = VAR_0->vqs;",
"VAR_4 = vhost_dev_start(&VAR_0->VAR_1, VAR_1);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"VAR_0->vc->info->poll(VAR_0->vc, false);",
"qemu_set_fd_handler(VAR_0->backend, NULL, NULL, NULL);",
"VAR_2.fd = VAR_0->backend;",
"for (VAR_2.index = 0; VAR_2.index < VAR_0->VAR_1.nvqs; ++VAR_2.index) {",
"VAR_4 = ioctl(VAR_0->VAR_1.control, VHOST_NET_SET_BACKEND, &VAR_2);",
"if (VAR_4 < 0) {",
"VAR_4 = -errno;",
"goto fail;",
"}",
"}",
"return 0;",
"fail:\nVAR_2.fd = -1;",
"while (--VAR_2.index >= 0) {",
"int VAR_4 = ioctl(VAR_0->VAR_1.control, VHOST_NET_SET_BACKEND, &VAR_2);",
"assert(VAR_4 >= 0);",
"}",
"VAR_0->vc->info->poll(VAR_0->vc, true);",
"vhost_dev_stop(&VAR_0->VAR_1, VAR_1);",
"if (VAR_0->VAR_1.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {",
"tap_set_vnet_hdr_len(VAR_0->vc, sizeof(struct virtio_net_hdr));",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
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
],
[
77
],
[
79
],
[
81
]
] |
23,152 | static int iscsi_create(const char *filename, QEMUOptionParameter *options,
Error **errp)
{
int ret = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("");
/* Read out options */
while (options && options->name) {
if (!strcmp(options->name, "size")) {
total_size = options->value.n / BDRV_SECTOR_SIZE;
}
options++;
}
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "filename", qstring_from_str(filename));
ret = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (ret != 0) {
goto out;
}
if (iscsilun->nop_timer) {
timer_del(iscsilun->nop_timer);
timer_free(iscsilun->nop_timer);
}
if (iscsilun->type != TYPE_DISK) {
ret = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
ret = -ENOSPC;
goto out;
}
ret = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return ret;
}
| false | qemu | 98522f63f40adaebc412481e1d2e9170160d4539 | static int iscsi_create(const char *filename, QEMUOptionParameter *options,
Error **errp)
{
int ret = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("");
while (options && options->name) {
if (!strcmp(options->name, "size")) {
total_size = options->value.n / BDRV_SECTOR_SIZE;
}
options++;
}
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "filename", qstring_from_str(filename));
ret = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (ret != 0) {
goto out;
}
if (iscsilun->nop_timer) {
timer_del(iscsilun->nop_timer);
timer_free(iscsilun->nop_timer);
}
if (iscsilun->type != TYPE_DISK) {
ret = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
ret = -ENOSPC;
goto out;
}
ret = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1,
Error **VAR_2)
{
int VAR_3 = 0;
int64_t total_size = 0;
BlockDriverState *bs;
IscsiLun *iscsilun = NULL;
QDict *bs_options;
bs = bdrv_new("");
while (VAR_1 && VAR_1->name) {
if (!strcmp(VAR_1->name, "size")) {
total_size = VAR_1->value.n / BDRV_SECTOR_SIZE;
}
VAR_1++;
}
bs->opaque = g_malloc0(sizeof(struct IscsiLun));
iscsilun = bs->opaque;
bs_options = qdict_new();
qdict_put(bs_options, "VAR_0", qstring_from_str(VAR_0));
VAR_3 = iscsi_open(bs, bs_options, 0, NULL);
QDECREF(bs_options);
if (VAR_3 != 0) {
goto out;
}
if (iscsilun->nop_timer) {
timer_del(iscsilun->nop_timer);
timer_free(iscsilun->nop_timer);
}
if (iscsilun->type != TYPE_DISK) {
VAR_3 = -ENODEV;
goto out;
}
if (bs->total_sectors < total_size) {
VAR_3 = -ENOSPC;
goto out;
}
VAR_3 = 0;
out:
if (iscsilun->iscsi != NULL) {
iscsi_destroy_context(iscsilun->iscsi);
}
g_free(bs->opaque);
bs->opaque = NULL;
bdrv_unref(bs);
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0, QEMUOptionParameter *VAR_1,\nError **VAR_2)\n{",
"int VAR_3 = 0;",
"int64_t total_size = 0;",
"BlockDriverState *bs;",
"IscsiLun *iscsilun = NULL;",
"QDict *bs_options;",
"bs = bdrv_new(\"\");",
"while (VAR_1 && VAR_1->name) {",
"if (!strcmp(VAR_1->name, \"size\")) {",
"total_size = VAR_1->value.n / BDRV_SECTOR_SIZE;",
"}",
"VAR_1++;",
"}",
"bs->opaque = g_malloc0(sizeof(struct IscsiLun));",
"iscsilun = bs->opaque;",
"bs_options = qdict_new();",
"qdict_put(bs_options, \"VAR_0\", qstring_from_str(VAR_0));",
"VAR_3 = iscsi_open(bs, bs_options, 0, NULL);",
"QDECREF(bs_options);",
"if (VAR_3 != 0) {",
"goto out;",
"}",
"if (iscsilun->nop_timer) {",
"timer_del(iscsilun->nop_timer);",
"timer_free(iscsilun->nop_timer);",
"}",
"if (iscsilun->type != TYPE_DISK) {",
"VAR_3 = -ENODEV;",
"goto out;",
"}",
"if (bs->total_sectors < total_size) {",
"VAR_3 = -ENOSPC;",
"goto out;",
"}",
"VAR_3 = 0;",
"out:\nif (iscsilun->iscsi != NULL) {",
"iscsi_destroy_context(iscsilun->iscsi);",
"}",
"g_free(bs->opaque);",
"bs->opaque = NULL;",
"bdrv_unref(bs);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
]
] |
23,153 | static void virtio_init_region_cache(VirtIODevice *vdev, int n)
{
VirtQueue *vq = &vdev->vq[n];
VRingMemoryRegionCaches *old = vq->vring.caches;
VRingMemoryRegionCaches *new;
hwaddr addr, size;
int event_size;
event_size = virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
addr = vq->vring.desc;
if (!addr) {
return;
}
new = g_new0(VRingMemoryRegionCaches, 1);
size = virtio_queue_get_desc_size(vdev, n);
address_space_cache_init(&new->desc, vdev->dma_as,
addr, size, false);
size = virtio_queue_get_used_size(vdev, n) + event_size;
address_space_cache_init(&new->used, vdev->dma_as,
vq->vring.used, size, true);
size = virtio_queue_get_avail_size(vdev, n) + event_size;
address_space_cache_init(&new->avail, vdev->dma_as,
vq->vring.avail, size, false);
atomic_rcu_set(&vq->vring.caches, new);
if (old) {
call_rcu(old, virtio_free_region_cache, rcu);
}
}
| false | qemu | e45da653223869849877ee8f4b86f511f891d4f8 | static void virtio_init_region_cache(VirtIODevice *vdev, int n)
{
VirtQueue *vq = &vdev->vq[n];
VRingMemoryRegionCaches *old = vq->vring.caches;
VRingMemoryRegionCaches *new;
hwaddr addr, size;
int event_size;
event_size = virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
addr = vq->vring.desc;
if (!addr) {
return;
}
new = g_new0(VRingMemoryRegionCaches, 1);
size = virtio_queue_get_desc_size(vdev, n);
address_space_cache_init(&new->desc, vdev->dma_as,
addr, size, false);
size = virtio_queue_get_used_size(vdev, n) + event_size;
address_space_cache_init(&new->used, vdev->dma_as,
vq->vring.used, size, true);
size = virtio_queue_get_avail_size(vdev, n) + event_size;
address_space_cache_init(&new->avail, vdev->dma_as,
vq->vring.avail, size, false);
atomic_rcu_set(&vq->vring.caches, new);
if (old) {
call_rcu(old, virtio_free_region_cache, rcu);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtIODevice *VAR_0, int VAR_1)
{
VirtQueue *vq = &VAR_0->vq[VAR_1];
VRingMemoryRegionCaches *old = vq->vring.caches;
VRingMemoryRegionCaches *new;
hwaddr addr, size;
int VAR_2;
VAR_2 = virtio_vdev_has_feature(vq->VAR_0, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
addr = vq->vring.desc;
if (!addr) {
return;
}
new = g_new0(VRingMemoryRegionCaches, 1);
size = virtio_queue_get_desc_size(VAR_0, VAR_1);
address_space_cache_init(&new->desc, VAR_0->dma_as,
addr, size, false);
size = virtio_queue_get_used_size(VAR_0, VAR_1) + VAR_2;
address_space_cache_init(&new->used, VAR_0->dma_as,
vq->vring.used, size, true);
size = virtio_queue_get_avail_size(VAR_0, VAR_1) + VAR_2;
address_space_cache_init(&new->avail, VAR_0->dma_as,
vq->vring.avail, size, false);
atomic_rcu_set(&vq->vring.caches, new);
if (old) {
call_rcu(old, virtio_free_region_cache, rcu);
}
}
| [
"static void FUNC_0(VirtIODevice *VAR_0, int VAR_1)\n{",
"VirtQueue *vq = &VAR_0->vq[VAR_1];",
"VRingMemoryRegionCaches *old = vq->vring.caches;",
"VRingMemoryRegionCaches *new;",
"hwaddr addr, size;",
"int VAR_2;",
"VAR_2 = virtio_vdev_has_feature(vq->VAR_0, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;",
"addr = vq->vring.desc;",
"if (!addr) {",
"return;",
"}",
"new = g_new0(VRingMemoryRegionCaches, 1);",
"size = virtio_queue_get_desc_size(VAR_0, VAR_1);",
"address_space_cache_init(&new->desc, VAR_0->dma_as,\naddr, size, false);",
"size = virtio_queue_get_used_size(VAR_0, VAR_1) + VAR_2;",
"address_space_cache_init(&new->used, VAR_0->dma_as,\nvq->vring.used, size, true);",
"size = virtio_queue_get_avail_size(VAR_0, VAR_1) + VAR_2;",
"address_space_cache_init(&new->avail, VAR_0->dma_as,\nvq->vring.avail, size, false);",
"atomic_rcu_set(&vq->vring.caches, new);",
"if (old) {",
"call_rcu(old, virtio_free_region_cache, rcu);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
39
],
[
41,
43
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
23,154 | static void xilinx_spips_realize(DeviceState *dev, Error **errp)
{
XilinxSPIPS *s = XILINX_SPIPS(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
XilinxSPIPSClass *xsc = XILINX_SPIPS_GET_CLASS(s);
int i;
DB_PRINT("realized spips\n");
s->spi = g_new(SSIBus *, s->num_busses);
for (i = 0; i < s->num_busses; ++i) {
char bus_name[16];
snprintf(bus_name, 16, "spi%d", i);
s->spi[i] = ssi_create_bus(dev, bus_name);
}
s->cs_lines = g_new0(qemu_irq, s->num_cs * s->num_busses);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[0]);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[1]);
sysbus_init_irq(sbd, &s->irq);
for (i = 0; i < s->num_cs * s->num_busses; ++i) {
sysbus_init_irq(sbd, &s->cs_lines[i]);
}
memory_region_init_io(&s->iomem, &spips_ops, s, "spi", R_MAX*4);
sysbus_init_mmio(sbd, &s->iomem);
s->irqline = -1;
fifo8_create(&s->rx_fifo, xsc->rx_fifo_size);
fifo8_create(&s->tx_fifo, xsc->tx_fifo_size);
}
| false | qemu | b5cd9143e78da8ea9e17fa523aacbedd267aae54 | static void xilinx_spips_realize(DeviceState *dev, Error **errp)
{
XilinxSPIPS *s = XILINX_SPIPS(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
XilinxSPIPSClass *xsc = XILINX_SPIPS_GET_CLASS(s);
int i;
DB_PRINT("realized spips\n");
s->spi = g_new(SSIBus *, s->num_busses);
for (i = 0; i < s->num_busses; ++i) {
char bus_name[16];
snprintf(bus_name, 16, "spi%d", i);
s->spi[i] = ssi_create_bus(dev, bus_name);
}
s->cs_lines = g_new0(qemu_irq, s->num_cs * s->num_busses);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[0]);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[1]);
sysbus_init_irq(sbd, &s->irq);
for (i = 0; i < s->num_cs * s->num_busses; ++i) {
sysbus_init_irq(sbd, &s->cs_lines[i]);
}
memory_region_init_io(&s->iomem, &spips_ops, s, "spi", R_MAX*4);
sysbus_init_mmio(sbd, &s->iomem);
s->irqline = -1;
fifo8_create(&s->rx_fifo, xsc->rx_fifo_size);
fifo8_create(&s->tx_fifo, xsc->tx_fifo_size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
XilinxSPIPS *s = XILINX_SPIPS(VAR_0);
SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);
XilinxSPIPSClass *xsc = XILINX_SPIPS_GET_CLASS(s);
int VAR_2;
DB_PRINT("realized spips\n");
s->spi = g_new(SSIBus *, s->num_busses);
for (VAR_2 = 0; VAR_2 < s->num_busses; ++VAR_2) {
char bus_name[16];
snprintf(bus_name, 16, "spi%d", VAR_2);
s->spi[VAR_2] = ssi_create_bus(VAR_0, bus_name);
}
s->cs_lines = g_new0(qemu_irq, s->num_cs * s->num_busses);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[0]);
ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[1]);
sysbus_init_irq(sbd, &s->irq);
for (VAR_2 = 0; VAR_2 < s->num_cs * s->num_busses; ++VAR_2) {
sysbus_init_irq(sbd, &s->cs_lines[VAR_2]);
}
memory_region_init_io(&s->iomem, &spips_ops, s, "spi", R_MAX*4);
sysbus_init_mmio(sbd, &s->iomem);
s->irqline = -1;
fifo8_create(&s->rx_fifo, xsc->rx_fifo_size);
fifo8_create(&s->tx_fifo, xsc->tx_fifo_size);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"XilinxSPIPS *s = XILINX_SPIPS(VAR_0);",
"SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);",
"XilinxSPIPSClass *xsc = XILINX_SPIPS_GET_CLASS(s);",
"int VAR_2;",
"DB_PRINT(\"realized spips\\n\");",
"s->spi = g_new(SSIBus *, s->num_busses);",
"for (VAR_2 = 0; VAR_2 < s->num_busses; ++VAR_2) {",
"char bus_name[16];",
"snprintf(bus_name, 16, \"spi%d\", VAR_2);",
"s->spi[VAR_2] = ssi_create_bus(VAR_0, bus_name);",
"}",
"s->cs_lines = g_new0(qemu_irq, s->num_cs * s->num_busses);",
"ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[0]);",
"ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[1]);",
"sysbus_init_irq(sbd, &s->irq);",
"for (VAR_2 = 0; VAR_2 < s->num_cs * s->num_busses; ++VAR_2) {",
"sysbus_init_irq(sbd, &s->cs_lines[VAR_2]);",
"}",
"memory_region_init_io(&s->iomem, &spips_ops, s, \"spi\", R_MAX*4);",
"sysbus_init_mmio(sbd, &s->iomem);",
"s->irqline = -1;",
"fifo8_create(&s->rx_fifo, xsc->rx_fifo_size);",
"fifo8_create(&s->tx_fifo, xsc->tx_fifo_size);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
59
],
[
61
],
[
63
]
] |
23,157 | static int read_key(void)
{
#if defined(HAVE_CONIO_H)
if(kbhit())
return(getch());
#elif defined(HAVE_TERMIOS_H)
int n = 1;
unsigned char ch;
#ifndef CONFIG_BEOS_NETSERVER
struct timeval tv;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
#endif
if (n > 0) {
n = read(0, &ch, 1);
if (n == 1)
return ch;
return n;
}
#endif
return -1;
}
| false | FFmpeg | 4b54c6d08437e5e3dd9359f29b247be58fef965f | static int read_key(void)
{
#if defined(HAVE_CONIO_H)
if(kbhit())
return(getch());
#elif defined(HAVE_TERMIOS_H)
int n = 1;
unsigned char ch;
#ifndef CONFIG_BEOS_NETSERVER
struct timeval tv;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
#endif
if (n > 0) {
n = read(0, &ch, 1);
if (n == 1)
return ch;
return n;
}
#endif
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void)
{
#if defined(HAVE_CONIO_H)
if(kbhit())
return(getch());
#elif defined(HAVE_TERMIOS_H)
int n = 1;
unsigned char ch;
#ifndef CONFIG_BEOS_NETSERVER
struct timeval tv;
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
n = select(1, &rfds, NULL, NULL, &tv);
#endif
if (n > 0) {
n = read(0, &ch, 1);
if (n == 1)
return ch;
return n;
}
#endif
return -1;
}
| [
"static int FUNC_0(void)\n{",
"#if defined(HAVE_CONIO_H)\nif(kbhit())\nreturn(getch());",
"#elif defined(HAVE_TERMIOS_H)\nint n = 1;",
"unsigned char ch;",
"#ifndef CONFIG_BEOS_NETSERVER\nstruct timeval tv;",
"fd_set rfds;",
"FD_ZERO(&rfds);",
"FD_SET(0, &rfds);",
"tv.tv_sec = 0;",
"tv.tv_usec = 0;",
"n = select(1, &rfds, NULL, NULL, &tv);",
"#endif\nif (n > 0) {",
"n = read(0, &ch, 1);",
"if (n == 1)\nreturn ch;",
"return n;",
"}",
"#endif\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
47
],
[
49
],
[
51,
53
],
[
55
]
] |
23,158 | static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_event_vq(s, vq);
}
| true | qemu | 71407786054cad26de7ef66718b2a57a4bcb49b5 | static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_event_vq(s, vq);
}
| {
"code": [
" return virtio_scsi_handle_event_vq(s, vq);"
],
"line_no": [
13
]
} | static bool FUNC_0(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_event_vq(s, vq);
}
| [
"static bool FUNC_0(VirtIODevice *vdev,\nVirtQueue *vq)\n{",
"VirtIOSCSI *s = VIRTIO_SCSI(vdev);",
"assert(s->ctx && s->dataplane_started);",
"return virtio_scsi_handle_event_vq(s, vq);",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
23,162 | opts_next_list(Visitor *v, GenericList **list, size_t size)
{
OptsVisitor *ov = to_ov(v);
GenericList **link;
switch (ov->list_mode) {
case LM_STARTED:
ov->list_mode = LM_IN_PROGRESS;
link = list;
break;
case LM_SIGNED_INTERVAL:
case LM_UNSIGNED_INTERVAL:
link = &(*list)->next;
if (ov->list_mode == LM_SIGNED_INTERVAL) {
if (ov->range_next.s < ov->range_limit.s) {
++ov->range_next.s;
break;
}
} else if (ov->range_next.u < ov->range_limit.u) {
++ov->range_next.u;
break;
}
ov->list_mode = LM_IN_PROGRESS;
/* range has been completed, fall through in order to pop option */
case LM_IN_PROGRESS: {
const QemuOpt *opt;
opt = g_queue_pop_head(ov->repeated_opts);
if (g_queue_is_empty(ov->repeated_opts)) {
g_hash_table_remove(ov->unprocessed_opts, opt->name);
return NULL;
}
link = &(*list)->next;
break;
}
default:
abort();
}
*link = g_malloc0(size);
return *link;
}
| false | qemu | d9f62dde1303286b24ac8ce88be27e2b9b9c5f46 | opts_next_list(Visitor *v, GenericList **list, size_t size)
{
OptsVisitor *ov = to_ov(v);
GenericList **link;
switch (ov->list_mode) {
case LM_STARTED:
ov->list_mode = LM_IN_PROGRESS;
link = list;
break;
case LM_SIGNED_INTERVAL:
case LM_UNSIGNED_INTERVAL:
link = &(*list)->next;
if (ov->list_mode == LM_SIGNED_INTERVAL) {
if (ov->range_next.s < ov->range_limit.s) {
++ov->range_next.s;
break;
}
} else if (ov->range_next.u < ov->range_limit.u) {
++ov->range_next.u;
break;
}
ov->list_mode = LM_IN_PROGRESS;
case LM_IN_PROGRESS: {
const QemuOpt *opt;
opt = g_queue_pop_head(ov->repeated_opts);
if (g_queue_is_empty(ov->repeated_opts)) {
g_hash_table_remove(ov->unprocessed_opts, opt->name);
return NULL;
}
link = &(*list)->next;
break;
}
default:
abort();
}
*link = g_malloc0(size);
return *link;
}
| {
"code": [],
"line_no": []
} | FUNC_0(Visitor *VAR_0, GenericList **VAR_1, size_t VAR_2)
{
OptsVisitor *ov = to_ov(VAR_0);
GenericList **link;
switch (ov->list_mode) {
case LM_STARTED:
ov->list_mode = LM_IN_PROGRESS;
link = VAR_1;
break;
case LM_SIGNED_INTERVAL:
case LM_UNSIGNED_INTERVAL:
link = &(*VAR_1)->next;
if (ov->list_mode == LM_SIGNED_INTERVAL) {
if (ov->range_next.s < ov->range_limit.s) {
++ov->range_next.s;
break;
}
} else if (ov->range_next.u < ov->range_limit.u) {
++ov->range_next.u;
break;
}
ov->list_mode = LM_IN_PROGRESS;
case LM_IN_PROGRESS: {
const QemuOpt *VAR_3;
VAR_3 = g_queue_pop_head(ov->repeated_opts);
if (g_queue_is_empty(ov->repeated_opts)) {
g_hash_table_remove(ov->unprocessed_opts, VAR_3->name);
return NULL;
}
link = &(*VAR_1)->next;
break;
}
default:
abort();
}
*link = g_malloc0(VAR_2);
return *link;
}
| [
"FUNC_0(Visitor *VAR_0, GenericList **VAR_1, size_t VAR_2)\n{",
"OptsVisitor *ov = to_ov(VAR_0);",
"GenericList **link;",
"switch (ov->list_mode) {",
"case LM_STARTED:\nov->list_mode = LM_IN_PROGRESS;",
"link = VAR_1;",
"break;",
"case LM_SIGNED_INTERVAL:\ncase LM_UNSIGNED_INTERVAL:\nlink = &(*VAR_1)->next;",
"if (ov->list_mode == LM_SIGNED_INTERVAL) {",
"if (ov->range_next.s < ov->range_limit.s) {",
"++ov->range_next.s;",
"break;",
"}",
"} else if (ov->range_next.u < ov->range_limit.u) {",
"++ov->range_next.u;",
"break;",
"}",
"ov->list_mode = LM_IN_PROGRESS;",
"case LM_IN_PROGRESS: {",
"const QemuOpt *VAR_3;",
"VAR_3 = g_queue_pop_head(ov->repeated_opts);",
"if (g_queue_is_empty(ov->repeated_opts)) {",
"g_hash_table_remove(ov->unprocessed_opts, VAR_3->name);",
"return NULL;",
"}",
"link = &(*VAR_1)->next;",
"break;",
"}",
"default:\nabort();",
"}",
"*link = g_malloc0(VAR_2);",
"return *link;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23,
25,
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
87
],
[
89
],
[
91
]
] |
23,164 | static int vnc_display_get_addresses(QemuOpts *opts,
bool reverse,
SocketAddress ***retsaddr,
size_t *retnsaddr,
SocketAddress ***retwsaddr,
size_t *retnwsaddr,
Error **errp)
{
SocketAddress *saddr = NULL;
SocketAddress *wsaddr = NULL;
QemuOptsIter addriter;
const char *addr;
int to = qemu_opt_get_number(opts, "to", 0);
bool has_ipv4 = qemu_opt_get(opts, "ipv4");
bool has_ipv6 = qemu_opt_get(opts, "ipv6");
bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false);
bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false);
size_t i;
int displaynum = -1;
int ret = -1;
*retsaddr = NULL;
*retnsaddr = 0;
*retwsaddr = NULL;
*retnwsaddr = 0;
addr = qemu_opt_get(opts, "vnc");
if (addr == NULL || g_str_equal(addr, "none")) {
ret = 0;
goto cleanup;
}
if (qemu_opt_get(opts, "websocket") &&
!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) {
error_setg(errp,
"SHA1 hash support is required for websockets");
goto cleanup;
}
qemu_opt_iter_init(&addriter, opts, "vnc");
while ((addr = qemu_opt_iter_next(&addriter)) != NULL) {
int rv;
rv = vnc_display_get_address(addr, false, reverse, 0, to,
has_ipv4, has_ipv6,
ipv4, ipv6,
&saddr, errp);
if (rv < 0) {
goto cleanup;
}
/* Historical compat - first listen address can be used
* to set the default websocket port
*/
if (displaynum == -1) {
displaynum = rv;
}
*retsaddr = g_renew(SocketAddress *, *retsaddr, *retnsaddr + 1);
(*retsaddr)[(*retnsaddr)++] = saddr;
}
/* If we had multiple primary displays, we don't do defaults
* for websocket, and require explicit config instead. */
if (*retnsaddr > 1) {
displaynum = -1;
}
qemu_opt_iter_init(&addriter, opts, "websocket");
while ((addr = qemu_opt_iter_next(&addriter)) != NULL) {
if (vnc_display_get_address(addr, true, reverse, displaynum, to,
has_ipv4, has_ipv6,
ipv4, ipv6,
&wsaddr, errp) < 0) {
goto cleanup;
}
/* Historical compat - if only a single listen address was
* provided, then this is used to set the default listen
* address for websocket too
*/
if (*retnsaddr == 1 &&
(*retsaddr)[0]->type == SOCKET_ADDRESS_KIND_INET &&
wsaddr->type == SOCKET_ADDRESS_KIND_INET &&
g_str_equal(wsaddr->u.inet.data->host, "") &&
!g_str_equal((*retsaddr)[0]->u.inet.data->host, "")) {
g_free(wsaddr->u.inet.data->host);
wsaddr->u.inet.data->host =
g_strdup((*retsaddr)[0]->u.inet.data->host);
}
*retwsaddr = g_renew(SocketAddress *, *retwsaddr, *retnwsaddr + 1);
(*retwsaddr)[(*retnwsaddr)++] = wsaddr;
}
ret = 0;
cleanup:
if (ret < 0) {
for (i = 0; i < *retnsaddr; i++) {
qapi_free_SocketAddress((*retsaddr)[i]);
}
g_free(*retsaddr);
for (i = 0; i < *retnwsaddr; i++) {
qapi_free_SocketAddress((*retwsaddr)[i]);
}
g_free(*retwsaddr);
*retsaddr = *retwsaddr = NULL;
*retnsaddr = *retnwsaddr = 0;
}
return ret;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | static int vnc_display_get_addresses(QemuOpts *opts,
bool reverse,
SocketAddress ***retsaddr,
size_t *retnsaddr,
SocketAddress ***retwsaddr,
size_t *retnwsaddr,
Error **errp)
{
SocketAddress *saddr = NULL;
SocketAddress *wsaddr = NULL;
QemuOptsIter addriter;
const char *addr;
int to = qemu_opt_get_number(opts, "to", 0);
bool has_ipv4 = qemu_opt_get(opts, "ipv4");
bool has_ipv6 = qemu_opt_get(opts, "ipv6");
bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false);
bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false);
size_t i;
int displaynum = -1;
int ret = -1;
*retsaddr = NULL;
*retnsaddr = 0;
*retwsaddr = NULL;
*retnwsaddr = 0;
addr = qemu_opt_get(opts, "vnc");
if (addr == NULL || g_str_equal(addr, "none")) {
ret = 0;
goto cleanup;
}
if (qemu_opt_get(opts, "websocket") &&
!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) {
error_setg(errp,
"SHA1 hash support is required for websockets");
goto cleanup;
}
qemu_opt_iter_init(&addriter, opts, "vnc");
while ((addr = qemu_opt_iter_next(&addriter)) != NULL) {
int rv;
rv = vnc_display_get_address(addr, false, reverse, 0, to,
has_ipv4, has_ipv6,
ipv4, ipv6,
&saddr, errp);
if (rv < 0) {
goto cleanup;
}
if (displaynum == -1) {
displaynum = rv;
}
*retsaddr = g_renew(SocketAddress *, *retsaddr, *retnsaddr + 1);
(*retsaddr)[(*retnsaddr)++] = saddr;
}
if (*retnsaddr > 1) {
displaynum = -1;
}
qemu_opt_iter_init(&addriter, opts, "websocket");
while ((addr = qemu_opt_iter_next(&addriter)) != NULL) {
if (vnc_display_get_address(addr, true, reverse, displaynum, to,
has_ipv4, has_ipv6,
ipv4, ipv6,
&wsaddr, errp) < 0) {
goto cleanup;
}
if (*retnsaddr == 1 &&
(*retsaddr)[0]->type == SOCKET_ADDRESS_KIND_INET &&
wsaddr->type == SOCKET_ADDRESS_KIND_INET &&
g_str_equal(wsaddr->u.inet.data->host, "") &&
!g_str_equal((*retsaddr)[0]->u.inet.data->host, "")) {
g_free(wsaddr->u.inet.data->host);
wsaddr->u.inet.data->host =
g_strdup((*retsaddr)[0]->u.inet.data->host);
}
*retwsaddr = g_renew(SocketAddress *, *retwsaddr, *retnwsaddr + 1);
(*retwsaddr)[(*retnwsaddr)++] = wsaddr;
}
ret = 0;
cleanup:
if (ret < 0) {
for (i = 0; i < *retnsaddr; i++) {
qapi_free_SocketAddress((*retsaddr)[i]);
}
g_free(*retsaddr);
for (i = 0; i < *retnwsaddr; i++) {
qapi_free_SocketAddress((*retwsaddr)[i]);
}
g_free(*retwsaddr);
*retsaddr = *retwsaddr = NULL;
*retnsaddr = *retnwsaddr = 0;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QemuOpts *VAR_0,
bool VAR_1,
SocketAddress ***VAR_2,
size_t *VAR_3,
SocketAddress ***VAR_4,
size_t *VAR_5,
Error **VAR_6)
{
SocketAddress *saddr = NULL;
SocketAddress *wsaddr = NULL;
QemuOptsIter addriter;
const char *VAR_7;
int VAR_8 = qemu_opt_get_number(VAR_0, "VAR_8", 0);
bool has_ipv4 = qemu_opt_get(VAR_0, "ipv4");
bool has_ipv6 = qemu_opt_get(VAR_0, "ipv6");
bool ipv4 = qemu_opt_get_bool(VAR_0, "ipv4", false);
bool ipv6 = qemu_opt_get_bool(VAR_0, "ipv6", false);
size_t i;
int VAR_9 = -1;
int VAR_10 = -1;
*VAR_2 = NULL;
*VAR_3 = 0;
*VAR_4 = NULL;
*VAR_5 = 0;
VAR_7 = qemu_opt_get(VAR_0, "vnc");
if (VAR_7 == NULL || g_str_equal(VAR_7, "none")) {
VAR_10 = 0;
goto cleanup;
}
if (qemu_opt_get(VAR_0, "websocket") &&
!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) {
error_setg(VAR_6,
"SHA1 hash support is required for websockets");
goto cleanup;
}
qemu_opt_iter_init(&addriter, VAR_0, "vnc");
while ((VAR_7 = qemu_opt_iter_next(&addriter)) != NULL) {
int VAR_11;
VAR_11 = vnc_display_get_address(VAR_7, false, VAR_1, 0, VAR_8,
has_ipv4, has_ipv6,
ipv4, ipv6,
&saddr, VAR_6);
if (VAR_11 < 0) {
goto cleanup;
}
if (VAR_9 == -1) {
VAR_9 = VAR_11;
}
*VAR_2 = g_renew(SocketAddress *, *VAR_2, *VAR_3 + 1);
(*VAR_2)[(*VAR_3)++] = saddr;
}
if (*VAR_3 > 1) {
VAR_9 = -1;
}
qemu_opt_iter_init(&addriter, VAR_0, "websocket");
while ((VAR_7 = qemu_opt_iter_next(&addriter)) != NULL) {
if (vnc_display_get_address(VAR_7, true, VAR_1, VAR_9, VAR_8,
has_ipv4, has_ipv6,
ipv4, ipv6,
&wsaddr, VAR_6) < 0) {
goto cleanup;
}
if (*VAR_3 == 1 &&
(*VAR_2)[0]->type == SOCKET_ADDRESS_KIND_INET &&
wsaddr->type == SOCKET_ADDRESS_KIND_INET &&
g_str_equal(wsaddr->u.inet.data->host, "") &&
!g_str_equal((*VAR_2)[0]->u.inet.data->host, "")) {
g_free(wsaddr->u.inet.data->host);
wsaddr->u.inet.data->host =
g_strdup((*VAR_2)[0]->u.inet.data->host);
}
*VAR_4 = g_renew(SocketAddress *, *VAR_4, *VAR_5 + 1);
(*VAR_4)[(*VAR_5)++] = wsaddr;
}
VAR_10 = 0;
cleanup:
if (VAR_10 < 0) {
for (i = 0; i < *VAR_3; i++) {
qapi_free_SocketAddress((*VAR_2)[i]);
}
g_free(*VAR_2);
for (i = 0; i < *VAR_5; i++) {
qapi_free_SocketAddress((*VAR_4)[i]);
}
g_free(*VAR_4);
*VAR_2 = *VAR_4 = NULL;
*VAR_3 = *VAR_5 = 0;
}
return VAR_10;
}
| [
"static int FUNC_0(QemuOpts *VAR_0,\nbool VAR_1,\nSocketAddress ***VAR_2,\nsize_t *VAR_3,\nSocketAddress ***VAR_4,\nsize_t *VAR_5,\nError **VAR_6)\n{",
"SocketAddress *saddr = NULL;",
"SocketAddress *wsaddr = NULL;",
"QemuOptsIter addriter;",
"const char *VAR_7;",
"int VAR_8 = qemu_opt_get_number(VAR_0, \"VAR_8\", 0);",
"bool has_ipv4 = qemu_opt_get(VAR_0, \"ipv4\");",
"bool has_ipv6 = qemu_opt_get(VAR_0, \"ipv6\");",
"bool ipv4 = qemu_opt_get_bool(VAR_0, \"ipv4\", false);",
"bool ipv6 = qemu_opt_get_bool(VAR_0, \"ipv6\", false);",
"size_t i;",
"int VAR_9 = -1;",
"int VAR_10 = -1;",
"*VAR_2 = NULL;",
"*VAR_3 = 0;",
"*VAR_4 = NULL;",
"*VAR_5 = 0;",
"VAR_7 = qemu_opt_get(VAR_0, \"vnc\");",
"if (VAR_7 == NULL || g_str_equal(VAR_7, \"none\")) {",
"VAR_10 = 0;",
"goto cleanup;",
"}",
"if (qemu_opt_get(VAR_0, \"websocket\") &&\n!qcrypto_hash_supports(QCRYPTO_HASH_ALG_SHA1)) {",
"error_setg(VAR_6,\n\"SHA1 hash support is required for websockets\");",
"goto cleanup;",
"}",
"qemu_opt_iter_init(&addriter, VAR_0, \"vnc\");",
"while ((VAR_7 = qemu_opt_iter_next(&addriter)) != NULL) {",
"int VAR_11;",
"VAR_11 = vnc_display_get_address(VAR_7, false, VAR_1, 0, VAR_8,\nhas_ipv4, has_ipv6,\nipv4, ipv6,\n&saddr, VAR_6);",
"if (VAR_11 < 0) {",
"goto cleanup;",
"}",
"if (VAR_9 == -1) {",
"VAR_9 = VAR_11;",
"}",
"*VAR_2 = g_renew(SocketAddress *, *VAR_2, *VAR_3 + 1);",
"(*VAR_2)[(*VAR_3)++] = saddr;",
"}",
"if (*VAR_3 > 1) {",
"VAR_9 = -1;",
"}",
"qemu_opt_iter_init(&addriter, VAR_0, \"websocket\");",
"while ((VAR_7 = qemu_opt_iter_next(&addriter)) != NULL) {",
"if (vnc_display_get_address(VAR_7, true, VAR_1, VAR_9, VAR_8,\nhas_ipv4, has_ipv6,\nipv4, ipv6,\n&wsaddr, VAR_6) < 0) {",
"goto cleanup;",
"}",
"if (*VAR_3 == 1 &&\n(*VAR_2)[0]->type == SOCKET_ADDRESS_KIND_INET &&\nwsaddr->type == SOCKET_ADDRESS_KIND_INET &&\ng_str_equal(wsaddr->u.inet.data->host, \"\") &&\n!g_str_equal((*VAR_2)[0]->u.inet.data->host, \"\")) {",
"g_free(wsaddr->u.inet.data->host);",
"wsaddr->u.inet.data->host =\ng_strdup((*VAR_2)[0]->u.inet.data->host);",
"}",
"*VAR_4 = g_renew(SocketAddress *, *VAR_4, *VAR_5 + 1);",
"(*VAR_4)[(*VAR_5)++] = wsaddr;",
"}",
"VAR_10 = 0;",
"cleanup:\nif (VAR_10 < 0) {",
"for (i = 0; i < *VAR_3; i++) {",
"qapi_free_SocketAddress((*VAR_2)[i]);",
"}",
"g_free(*VAR_2);",
"for (i = 0; i < *VAR_5; i++) {",
"qapi_free_SocketAddress((*VAR_4)[i]);",
"}",
"g_free(*VAR_4);",
"*VAR_2 = *VAR_4 = NULL;",
"*VAR_3 = *VAR_5 = 0;",
"}",
"return VAR_10;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83,
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133,
135,
137,
139
],
[
141
],
[
143
],
[
155,
157,
159,
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
]
] |
23,165 | static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
void *fdt, int node_offset)
{
int offset, ret;
char nodename[FDT_NAME_MAX];
pci_get_node_name(nodename, FDT_NAME_MAX, dev);
offset = fdt_add_subnode(fdt, node_offset, nodename);
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
g_assert(!ret);
if (ret) {
return 0;
}
return offset;
}
| false | qemu | 549ce59e2b9ed7f41d2f88524bd5e01b0d7db2e9 | static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
void *fdt, int node_offset)
{
int offset, ret;
char nodename[FDT_NAME_MAX];
pci_get_node_name(nodename, FDT_NAME_MAX, dev);
offset = fdt_add_subnode(fdt, node_offset, nodename);
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
g_assert(!ret);
if (ret) {
return 0;
}
return offset;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(sPAPRPHBState *VAR_0, PCIDevice *VAR_1,
void *VAR_2, int VAR_3)
{
int VAR_4, VAR_5;
char VAR_6[FDT_NAME_MAX];
pci_get_node_name(VAR_6, FDT_NAME_MAX, VAR_1);
VAR_4 = fdt_add_subnode(VAR_2, VAR_3, VAR_6);
VAR_5 = spapr_populate_pci_child_dt(VAR_1, VAR_2, VAR_4, VAR_0);
g_assert(!VAR_5);
if (VAR_5) {
return 0;
}
return VAR_4;
}
| [
"static int FUNC_0(sPAPRPHBState *VAR_0, PCIDevice *VAR_1,\nvoid *VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5;",
"char VAR_6[FDT_NAME_MAX];",
"pci_get_node_name(VAR_6, FDT_NAME_MAX, VAR_1);",
"VAR_4 = fdt_add_subnode(VAR_2, VAR_3, VAR_6);",
"VAR_5 = spapr_populate_pci_child_dt(VAR_1, VAR_2, VAR_4, VAR_0);",
"g_assert(!VAR_5);",
"if (VAR_5) {",
"return 0;",
"}",
"return VAR_4;",
"}"
] | [
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
]
] |
23,166 | static void slavio_timer_irq(void *opaque)
{
TimerContext *tc = opaque;
SLAVIO_TIMERState *s = tc->s;
CPUTimerState *t = &s->cputimer[tc->timer_index];
slavio_timer_get_out(t);
DPRINTF("callback: count %x%08x\n", t->counthigh, t->count);
t->reached = TIMER_REACHED;
/* there is no interrupt if user timer or free-run */
if (!slavio_timer_is_user(tc) && t->limit != 0) {
qemu_irq_raise(t->irq);
}
}
| false | qemu | 68fb89a2c07b6ad1e69a9a45f664d533f2662ec6 | static void slavio_timer_irq(void *opaque)
{
TimerContext *tc = opaque;
SLAVIO_TIMERState *s = tc->s;
CPUTimerState *t = &s->cputimer[tc->timer_index];
slavio_timer_get_out(t);
DPRINTF("callback: count %x%08x\n", t->counthigh, t->count);
t->reached = TIMER_REACHED;
if (!slavio_timer_is_user(tc) && t->limit != 0) {
qemu_irq_raise(t->irq);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
TimerContext *tc = VAR_0;
SLAVIO_TIMERState *s = tc->s;
CPUTimerState *t = &s->cputimer[tc->timer_index];
slavio_timer_get_out(t);
DPRINTF("callback: count %x%08x\n", t->counthigh, t->count);
t->reached = TIMER_REACHED;
if (!slavio_timer_is_user(tc) && t->limit != 0) {
qemu_irq_raise(t->irq);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"TimerContext *tc = VAR_0;",
"SLAVIO_TIMERState *s = tc->s;",
"CPUTimerState *t = &s->cputimer[tc->timer_index];",
"slavio_timer_get_out(t);",
"DPRINTF(\"callback: count %x%08x\\n\", t->counthigh, t->count);",
"t->reached = TIMER_REACHED;",
"if (!slavio_timer_is_user(tc) && t->limit != 0) {",
"qemu_irq_raise(t->irq);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
23,168 | uint64_t helper_fre (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL; /* 1.0 */
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
/* sNaN reciprocal */
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_zero(farg.d))) {
/* Zero reciprocal */
farg.ll = float_zero_divide_excp(fone.d, farg.d);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x8000000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.d;
}
| false | qemu | 6c01bf6c7ba7539460fcaeb99fbe1776ba137aa8 | uint64_t helper_fre (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_zero(farg.d))) {
farg.ll = float_zero_divide_excp(fone.d, farg.d);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x8000000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.d;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (uint64_t arg)
{
CPU_DoubleU fone, farg;
fone.ll = 0x3FF0000000000000ULL;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
} else if (unlikely(float64_is_zero(farg.d))) {
farg.ll = float_zero_divide_excp(fone.d, farg.d);
} else if (likely(isnormal(farg.d))) {
farg.d = float64_div(fone.d, farg.d, &env->fp_status);
} else {
if (farg.ll == 0x8000000000000000ULL) {
farg.ll = 0xFFF0000000000000ULL;
} else if (farg.ll == 0x0000000000000000ULL) {
farg.ll = 0x7FF0000000000000ULL;
} else if (float64_is_nan(farg.d)) {
farg.ll = 0x7FF8000000000000ULL;
} else if (float64_is_neg(farg.d)) {
farg.ll = 0x8000000000000000ULL;
} else {
farg.ll = 0x0000000000000000ULL;
}
}
return farg.d;
}
| [
"uint64_t FUNC_0 (uint64_t arg)\n{",
"CPU_DoubleU fone, farg;",
"fone.ll = 0x3FF0000000000000ULL;",
"farg.ll = arg;",
"if (unlikely(float64_is_signaling_nan(farg.d))) {",
"farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);",
"} else if (unlikely(float64_is_zero(farg.d))) {",
"farg.ll = float_zero_divide_excp(fone.d, farg.d);",
"} else if (likely(isnormal(farg.d))) {",
"farg.d = float64_div(fone.d, farg.d, &env->fp_status);",
"} else {",
"if (farg.ll == 0x8000000000000000ULL) {",
"farg.ll = 0xFFF0000000000000ULL;",
"} else if (farg.ll == 0x0000000000000000ULL) {",
"farg.ll = 0x7FF0000000000000ULL;",
"} else if (float64_is_nan(farg.d)) {",
"farg.ll = 0x7FF8000000000000ULL;",
"} else if (float64_is_neg(farg.d)) {",
"farg.ll = 0x8000000000000000ULL;",
"} else {",
"farg.ll = 0x0000000000000000ULL;",
"}",
"}",
"return farg.d;",
"}"
] | [
0,
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
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
23,169 | static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
{
int64_t ret;
int n;
convert_select_part(s, sector_num);
assert(s->total_sectors > sector_num);
n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS);
if (s->sector_next_status <= sector_num) {
BlockDriverState *file;
ret = bdrv_get_block_status(blk_bs(s->src[s->src_cur]),
sector_num - s->src_cur_offset,
n, &n, &file);
if (ret < 0) {
return ret;
}
if (ret & BDRV_BLOCK_ZERO) {
s->status = BLK_ZERO;
} else if (ret & BDRV_BLOCK_DATA) {
s->status = BLK_DATA;
} else if (!s->target_has_backing) {
/* Without a target backing file we must copy over the contents of
* the backing file as well. */
/* TODO Check block status of the backing file chain to avoid
* needlessly reading zeroes and limiting the iteration to the
* buffer size */
s->status = BLK_DATA;
} else {
s->status = BLK_BACKING_FILE;
}
s->sector_next_status = sector_num + n;
}
n = MIN(n, s->sector_next_status - sector_num);
if (s->status == BLK_DATA) {
n = MIN(n, s->buf_sectors);
}
/* We need to write complete clusters for compressed images, so if an
* unallocated area is shorter than that, we must consider the whole
* cluster allocated. */
if (s->compressed) {
if (n < s->cluster_sectors) {
n = MIN(s->cluster_sectors, s->total_sectors - sector_num);
s->status = BLK_DATA;
} else {
n = QEMU_ALIGN_DOWN(n, s->cluster_sectors);
}
}
return n;
}
| false | qemu | 263a6f4c3aa9b6cd9f58d1368b318d948156a4e8 | static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num)
{
int64_t ret;
int n;
convert_select_part(s, sector_num);
assert(s->total_sectors > sector_num);
n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS);
if (s->sector_next_status <= sector_num) {
BlockDriverState *file;
ret = bdrv_get_block_status(blk_bs(s->src[s->src_cur]),
sector_num - s->src_cur_offset,
n, &n, &file);
if (ret < 0) {
return ret;
}
if (ret & BDRV_BLOCK_ZERO) {
s->status = BLK_ZERO;
} else if (ret & BDRV_BLOCK_DATA) {
s->status = BLK_DATA;
} else if (!s->target_has_backing) {
s->status = BLK_DATA;
} else {
s->status = BLK_BACKING_FILE;
}
s->sector_next_status = sector_num + n;
}
n = MIN(n, s->sector_next_status - sector_num);
if (s->status == BLK_DATA) {
n = MIN(n, s->buf_sectors);
}
if (s->compressed) {
if (n < s->cluster_sectors) {
n = MIN(s->cluster_sectors, s->total_sectors - sector_num);
s->status = BLK_DATA;
} else {
n = QEMU_ALIGN_DOWN(n, s->cluster_sectors);
}
}
return n;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(ImgConvertState *VAR_0, int64_t VAR_1)
{
int64_t ret;
int VAR_2;
convert_select_part(VAR_0, VAR_1);
assert(VAR_0->total_sectors > VAR_1);
VAR_2 = MIN(VAR_0->total_sectors - VAR_1, BDRV_REQUEST_MAX_SECTORS);
if (VAR_0->sector_next_status <= VAR_1) {
BlockDriverState *file;
ret = bdrv_get_block_status(blk_bs(VAR_0->src[VAR_0->src_cur]),
VAR_1 - VAR_0->src_cur_offset,
VAR_2, &VAR_2, &file);
if (ret < 0) {
return ret;
}
if (ret & BDRV_BLOCK_ZERO) {
VAR_0->status = BLK_ZERO;
} else if (ret & BDRV_BLOCK_DATA) {
VAR_0->status = BLK_DATA;
} else if (!VAR_0->target_has_backing) {
VAR_0->status = BLK_DATA;
} else {
VAR_0->status = BLK_BACKING_FILE;
}
VAR_0->sector_next_status = VAR_1 + VAR_2;
}
VAR_2 = MIN(VAR_2, VAR_0->sector_next_status - VAR_1);
if (VAR_0->status == BLK_DATA) {
VAR_2 = MIN(VAR_2, VAR_0->buf_sectors);
}
if (VAR_0->compressed) {
if (VAR_2 < VAR_0->cluster_sectors) {
VAR_2 = MIN(VAR_0->cluster_sectors, VAR_0->total_sectors - VAR_1);
VAR_0->status = BLK_DATA;
} else {
VAR_2 = QEMU_ALIGN_DOWN(VAR_2, VAR_0->cluster_sectors);
}
}
return VAR_2;
}
| [
"static int FUNC_0(ImgConvertState *VAR_0, int64_t VAR_1)\n{",
"int64_t ret;",
"int VAR_2;",
"convert_select_part(VAR_0, VAR_1);",
"assert(VAR_0->total_sectors > VAR_1);",
"VAR_2 = MIN(VAR_0->total_sectors - VAR_1, BDRV_REQUEST_MAX_SECTORS);",
"if (VAR_0->sector_next_status <= VAR_1) {",
"BlockDriverState *file;",
"ret = bdrv_get_block_status(blk_bs(VAR_0->src[VAR_0->src_cur]),\nVAR_1 - VAR_0->src_cur_offset,\nVAR_2, &VAR_2, &file);",
"if (ret < 0) {",
"return ret;",
"}",
"if (ret & BDRV_BLOCK_ZERO) {",
"VAR_0->status = BLK_ZERO;",
"} else if (ret & BDRV_BLOCK_DATA) {",
"VAR_0->status = BLK_DATA;",
"} else if (!VAR_0->target_has_backing) {",
"VAR_0->status = BLK_DATA;",
"} else {",
"VAR_0->status = BLK_BACKING_FILE;",
"}",
"VAR_0->sector_next_status = VAR_1 + VAR_2;",
"}",
"VAR_2 = MIN(VAR_2, VAR_0->sector_next_status - VAR_1);",
"if (VAR_0->status == BLK_DATA) {",
"VAR_2 = MIN(VAR_2, VAR_0->buf_sectors);",
"}",
"if (VAR_0->compressed) {",
"if (VAR_2 < VAR_0->cluster_sectors) {",
"VAR_2 = MIN(VAR_0->cluster_sectors, VAR_0->total_sectors - VAR_1);",
"VAR_0->status = BLK_DATA;",
"} else {",
"VAR_2 = QEMU_ALIGN_DOWN(VAR_2, VAR_0->cluster_sectors);",
"}",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
23,170 | uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2)
{
HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n",
__func__, l, a1, a2);
return mvc_asc(env, l, a1, PSW_ASC_SECONDARY, a2, PSW_ASC_PRIMARY);
}
| false | qemu | a3084e8055067b3fe8ed653a609021d2ab368564 | uint32_t HELPER(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2)
{
HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n",
__func__, l, a1, a2);
return mvc_asc(env, l, a1, PSW_ASC_SECONDARY, a2, PSW_ASC_PRIMARY);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2)
{
HELPER_LOG("%s: %16" PRIx64 " %16" PRIx64 " %16" PRIx64 "\n",
__func__, l, a1, a2);
return mvc_asc(env, l, a1, PSW_ASC_SECONDARY, a2, PSW_ASC_PRIMARY);
}
| [
"uint32_t FUNC_0(mvcs)(CPUS390XState *env, uint64_t l, uint64_t a1, uint64_t a2)\n{",
"HELPER_LOG(\"%s: %16\" PRIx64 \" %16\" PRIx64 \" %16\" PRIx64 \"\\n\",\n__func__, l, a1, a2);",
"return mvc_asc(env, l, a1, PSW_ASC_SECONDARY, a2, PSW_ASC_PRIMARY);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
]
] |
23,171 | static int oss_run_out (HWVoiceOut *hw)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
int err, rpos, live, decr;
int samples;
uint8_t *dst;
st_sample_t *src;
struct audio_buf_info abinfo;
struct count_info cntinfo;
int bufsize;
live = audio_pcm_hw_get_live_out (hw);
if (!live) {
return 0;
}
bufsize = hw->samples << hw->info.shift;
if (oss->mmapped) {
int bytes;
err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
if (err < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (cntinfo.ptr == oss->old_optr) {
if (abs (hw->samples - live) < 64) {
dolog ("warning: Overrun\n");
}
return 0;
}
if (cntinfo.ptr > oss->old_optr) {
bytes = cntinfo.ptr - oss->old_optr;
}
else {
bytes = bufsize + cntinfo.ptr - oss->old_optr;
}
decr = audio_MIN (bytes >> hw->info.shift, live);
}
else {
err = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo);
if (err < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (abinfo.bytes > bufsize) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d bufsize=%d\n"
"please report your OS/audio hw to [email protected]\n",
abinfo.bytes, bufsize);
}
abinfo.bytes = bufsize;
}
if (abinfo.bytes < 0) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d bufsize=%d\n",
abinfo.bytes, bufsize);
}
return 0;
}
decr = audio_MIN (abinfo.bytes >> hw->info.shift, live);
if (!decr) {
return 0;
}
}
samples = decr;
rpos = hw->rpos;
while (samples) {
int left_till_end_samples = hw->samples - rpos;
int convert_samples = audio_MIN (samples, left_till_end_samples);
src = hw->mix_buf + rpos;
dst = advance (oss->pcm_buf, rpos << hw->info.shift);
hw->clip (dst, src, convert_samples);
if (!oss->mmapped) {
int written;
written = write (oss->fd, dst, convert_samples << hw->info.shift);
/* XXX: follow errno recommendations ? */
if (written == -1) {
oss_logerr (
errno,
"Failed to write %d bytes of audio data from %p\n",
convert_samples << hw->info.shift,
dst
);
continue;
}
if (written != convert_samples << hw->info.shift) {
int wsamples = written >> hw->info.shift;
int wbytes = wsamples << hw->info.shift;
if (wbytes != written) {
dolog ("warning: Misaligned write %d (requested %d), "
"alignment %d\n",
wbytes, written, hw->info.align + 1);
}
decr -= wsamples;
rpos = (rpos + wsamples) % hw->samples;
break;
}
}
rpos = (rpos + convert_samples) % hw->samples;
samples -= convert_samples;
}
if (oss->mmapped) {
oss->old_optr = cntinfo.ptr;
}
hw->rpos = rpos;
return decr;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static int oss_run_out (HWVoiceOut *hw)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
int err, rpos, live, decr;
int samples;
uint8_t *dst;
st_sample_t *src;
struct audio_buf_info abinfo;
struct count_info cntinfo;
int bufsize;
live = audio_pcm_hw_get_live_out (hw);
if (!live) {
return 0;
}
bufsize = hw->samples << hw->info.shift;
if (oss->mmapped) {
int bytes;
err = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo);
if (err < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (cntinfo.ptr == oss->old_optr) {
if (abs (hw->samples - live) < 64) {
dolog ("warning: Overrun\n");
}
return 0;
}
if (cntinfo.ptr > oss->old_optr) {
bytes = cntinfo.ptr - oss->old_optr;
}
else {
bytes = bufsize + cntinfo.ptr - oss->old_optr;
}
decr = audio_MIN (bytes >> hw->info.shift, live);
}
else {
err = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &abinfo);
if (err < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (abinfo.bytes > bufsize) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d bufsize=%d\n"
"please report your OS/audio hw to [email protected]\n",
abinfo.bytes, bufsize);
}
abinfo.bytes = bufsize;
}
if (abinfo.bytes < 0) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d bufsize=%d\n",
abinfo.bytes, bufsize);
}
return 0;
}
decr = audio_MIN (abinfo.bytes >> hw->info.shift, live);
if (!decr) {
return 0;
}
}
samples = decr;
rpos = hw->rpos;
while (samples) {
int left_till_end_samples = hw->samples - rpos;
int convert_samples = audio_MIN (samples, left_till_end_samples);
src = hw->mix_buf + rpos;
dst = advance (oss->pcm_buf, rpos << hw->info.shift);
hw->clip (dst, src, convert_samples);
if (!oss->mmapped) {
int written;
written = write (oss->fd, dst, convert_samples << hw->info.shift);
if (written == -1) {
oss_logerr (
errno,
"Failed to write %d bytes of audio data from %p\n",
convert_samples << hw->info.shift,
dst
);
continue;
}
if (written != convert_samples << hw->info.shift) {
int wsamples = written >> hw->info.shift;
int wbytes = wsamples << hw->info.shift;
if (wbytes != written) {
dolog ("warning: Misaligned write %d (requested %d), "
"alignment %d\n",
wbytes, written, hw->info.align + 1);
}
decr -= wsamples;
rpos = (rpos + wsamples) % hw->samples;
break;
}
}
rpos = (rpos + convert_samples) % hw->samples;
samples -= convert_samples;
}
if (oss->mmapped) {
oss->old_optr = cntinfo.ptr;
}
hw->rpos = rpos;
return decr;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (HWVoiceOut *VAR_0)
{
OSSVoiceOut *oss = (OSSVoiceOut *) VAR_0;
int VAR_1, VAR_2, VAR_3, VAR_4;
int VAR_5;
uint8_t *dst;
st_sample_t *src;
struct audio_buf_info VAR_6;
struct count_info VAR_7;
int VAR_8;
VAR_3 = audio_pcm_hw_get_live_out (VAR_0);
if (!VAR_3) {
return 0;
}
VAR_8 = VAR_0->VAR_5 << VAR_0->info.shift;
if (oss->mmapped) {
int VAR_9;
VAR_1 = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &VAR_7);
if (VAR_1 < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (VAR_7.ptr == oss->old_optr) {
if (abs (VAR_0->VAR_5 - VAR_3) < 64) {
dolog ("warning: Overrun\n");
}
return 0;
}
if (VAR_7.ptr > oss->old_optr) {
VAR_9 = VAR_7.ptr - oss->old_optr;
}
else {
VAR_9 = VAR_8 + VAR_7.ptr - oss->old_optr;
}
VAR_4 = audio_MIN (VAR_9 >> VAR_0->info.shift, VAR_3);
}
else {
VAR_1 = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &VAR_6);
if (VAR_1 < 0) {
oss_logerr (errno, "SNDCTL_DSP_GETOPTR failed\n");
return 0;
}
if (VAR_6.VAR_9 > VAR_8) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d VAR_8=%d\n"
"please report your OS/audio VAR_0 to [email protected]\n",
VAR_6.VAR_9, VAR_8);
}
VAR_6.VAR_9 = VAR_8;
}
if (VAR_6.VAR_9 < 0) {
if (conf.debug) {
dolog ("warning: Invalid available size, size=%d VAR_8=%d\n",
VAR_6.VAR_9, VAR_8);
}
return 0;
}
VAR_4 = audio_MIN (VAR_6.VAR_9 >> VAR_0->info.shift, VAR_3);
if (!VAR_4) {
return 0;
}
}
VAR_5 = VAR_4;
VAR_2 = VAR_0->VAR_2;
while (VAR_5) {
int VAR_10 = VAR_0->VAR_5 - VAR_2;
int VAR_11 = audio_MIN (VAR_5, VAR_10);
src = VAR_0->mix_buf + VAR_2;
dst = advance (oss->pcm_buf, VAR_2 << VAR_0->info.shift);
VAR_0->clip (dst, src, VAR_11);
if (!oss->mmapped) {
int VAR_12;
VAR_12 = write (oss->fd, dst, VAR_11 << VAR_0->info.shift);
if (VAR_12 == -1) {
oss_logerr (
errno,
"Failed to write %d VAR_9 of audio data from %p\n",
VAR_11 << VAR_0->info.shift,
dst
);
continue;
}
if (VAR_12 != VAR_11 << VAR_0->info.shift) {
int VAR_13 = VAR_12 >> VAR_0->info.shift;
int VAR_14 = VAR_13 << VAR_0->info.shift;
if (VAR_14 != VAR_12) {
dolog ("warning: Misaligned write %d (requested %d), "
"alignment %d\n",
VAR_14, VAR_12, VAR_0->info.align + 1);
}
VAR_4 -= VAR_13;
VAR_2 = (VAR_2 + VAR_13) % VAR_0->VAR_5;
break;
}
}
VAR_2 = (VAR_2 + VAR_11) % VAR_0->VAR_5;
VAR_5 -= VAR_11;
}
if (oss->mmapped) {
oss->old_optr = VAR_7.ptr;
}
VAR_0->VAR_2 = VAR_2;
return VAR_4;
}
| [
"static int FUNC_0 (HWVoiceOut *VAR_0)\n{",
"OSSVoiceOut *oss = (OSSVoiceOut *) VAR_0;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"int VAR_5;",
"uint8_t *dst;",
"st_sample_t *src;",
"struct audio_buf_info VAR_6;",
"struct count_info VAR_7;",
"int VAR_8;",
"VAR_3 = audio_pcm_hw_get_live_out (VAR_0);",
"if (!VAR_3) {",
"return 0;",
"}",
"VAR_8 = VAR_0->VAR_5 << VAR_0->info.shift;",
"if (oss->mmapped) {",
"int VAR_9;",
"VAR_1 = ioctl (oss->fd, SNDCTL_DSP_GETOPTR, &VAR_7);",
"if (VAR_1 < 0) {",
"oss_logerr (errno, \"SNDCTL_DSP_GETOPTR failed\\n\");",
"return 0;",
"}",
"if (VAR_7.ptr == oss->old_optr) {",
"if (abs (VAR_0->VAR_5 - VAR_3) < 64) {",
"dolog (\"warning: Overrun\\n\");",
"}",
"return 0;",
"}",
"if (VAR_7.ptr > oss->old_optr) {",
"VAR_9 = VAR_7.ptr - oss->old_optr;",
"}",
"else {",
"VAR_9 = VAR_8 + VAR_7.ptr - oss->old_optr;",
"}",
"VAR_4 = audio_MIN (VAR_9 >> VAR_0->info.shift, VAR_3);",
"}",
"else {",
"VAR_1 = ioctl (oss->fd, SNDCTL_DSP_GETOSPACE, &VAR_6);",
"if (VAR_1 < 0) {",
"oss_logerr (errno, \"SNDCTL_DSP_GETOPTR failed\\n\");",
"return 0;",
"}",
"if (VAR_6.VAR_9 > VAR_8) {",
"if (conf.debug) {",
"dolog (\"warning: Invalid available size, size=%d VAR_8=%d\\n\"\n\"please report your OS/audio VAR_0 to [email protected]\\n\",\nVAR_6.VAR_9, VAR_8);",
"}",
"VAR_6.VAR_9 = VAR_8;",
"}",
"if (VAR_6.VAR_9 < 0) {",
"if (conf.debug) {",
"dolog (\"warning: Invalid available size, size=%d VAR_8=%d\\n\",\nVAR_6.VAR_9, VAR_8);",
"}",
"return 0;",
"}",
"VAR_4 = audio_MIN (VAR_6.VAR_9 >> VAR_0->info.shift, VAR_3);",
"if (!VAR_4) {",
"return 0;",
"}",
"}",
"VAR_5 = VAR_4;",
"VAR_2 = VAR_0->VAR_2;",
"while (VAR_5) {",
"int VAR_10 = VAR_0->VAR_5 - VAR_2;",
"int VAR_11 = audio_MIN (VAR_5, VAR_10);",
"src = VAR_0->mix_buf + VAR_2;",
"dst = advance (oss->pcm_buf, VAR_2 << VAR_0->info.shift);",
"VAR_0->clip (dst, src, VAR_11);",
"if (!oss->mmapped) {",
"int VAR_12;",
"VAR_12 = write (oss->fd, dst, VAR_11 << VAR_0->info.shift);",
"if (VAR_12 == -1) {",
"oss_logerr (\nerrno,\n\"Failed to write %d VAR_9 of audio data from %p\\n\",\nVAR_11 << VAR_0->info.shift,\ndst\n);",
"continue;",
"}",
"if (VAR_12 != VAR_11 << VAR_0->info.shift) {",
"int VAR_13 = VAR_12 >> VAR_0->info.shift;",
"int VAR_14 = VAR_13 << VAR_0->info.shift;",
"if (VAR_14 != VAR_12) {",
"dolog (\"warning: Misaligned write %d (requested %d), \"\n\"alignment %d\\n\",\nVAR_14, VAR_12, VAR_0->info.align + 1);",
"}",
"VAR_4 -= VAR_13;",
"VAR_2 = (VAR_2 + VAR_13) % VAR_0->VAR_5;",
"break;",
"}",
"}",
"VAR_2 = (VAR_2 + VAR_11) % VAR_0->VAR_5;",
"VAR_5 -= VAR_11;",
"}",
"if (oss->mmapped) {",
"oss->old_optr = VAR_7.ptr;",
"}",
"VAR_0->VAR_2 = VAR_2;",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
173
],
[
177
],
[
179,
181,
183,
185,
187,
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
243
]
] |
23,172 | SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
{
SwsContext *c;
int i;
int usesVFilter, usesHFilter;
int unscaled;
int srcRange, dstRange;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#if ARCH_X86
if (flags & SWS_CPU_CAPS_MMX)
__asm__ volatile("emms\n\t"::: "memory");
#endif
#if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
flags |= ff_hardcodedcpuflags();
#endif /* CONFIG_RUNTIME_CPUDETECT */
if (!rgb15to16) sws_rgb2rgb_init(flags);
unscaled = (srcW == dstW && srcH == dstH);
srcRange = handle_jpeg(&srcFormat);
dstRange = handle_jpeg(&dstFormat);
if (!isSupportedIn(srcFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input pixel format\n", sws_format_name(srcFormat));
return NULL;
}
if (!isSupportedOut(dstFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output pixel format\n", sws_format_name(dstFormat));
return NULL;
}
i= flags & ( SWS_POINT
|SWS_AREA
|SWS_BILINEAR
|SWS_FAST_BILINEAR
|SWS_BICUBIC
|SWS_X
|SWS_GAUSS
|SWS_LANCZOS
|SWS_SINC
|SWS_SPLINE
|SWS_BICUBLIN);
if(!i || (i & (i-1))) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n");
return NULL;
}
/* sanity check */
if (srcW<4 || srcH<1 || dstW<8 || dstH<1) { //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code
av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
srcW, srcH, dstW, dstH);
return NULL;
}
if(srcW > VOFW || dstW > VOFW) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
return NULL;
}
if (!dstFilter) dstFilter= &dummyFilter;
if (!srcFilter) srcFilter= &dummyFilter;
FF_ALLOCZ_OR_GOTO(NULL, c, sizeof(SwsContext), fail);
c->av_class = &sws_context_class;
c->srcW= srcW;
c->srcH= srcH;
c->dstW= dstW;
c->dstH= dstH;
c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW;
c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH;
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
c->vRounder= 4* 0x0001000100010001ULL;
usesVFilter = (srcFilter->lumV && srcFilter->lumV->length>1) ||
(srcFilter->chrV && srcFilter->chrV->length>1) ||
(dstFilter->lumV && dstFilter->lumV->length>1) ||
(dstFilter->chrV && dstFilter->chrV->length>1);
usesHFilter = (srcFilter->lumH && srcFilter->lumH->length>1) ||
(srcFilter->chrH && srcFilter->chrH->length>1) ||
(dstFilter->lumH && dstFilter->lumH->length>1) ||
(dstFilter->chrH && dstFilter->chrH->length>1);
getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
// reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation
if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
// drop some chroma lines if the user wants it
c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
c->chrSrcVSubSample+= c->vChrDrop;
// drop every other pixel for chroma calculation unless user wants full chroma
if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP)
&& srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8
&& srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4
&& srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE
&& ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|SWS_POINT))))
c->chrSrcHSubSample=1;
if (param) {
c->param[0] = param[0];
c->param[1] = param[1];
} else {
c->param[0] =
c->param[1] = SWS_PARAM_DEFAULT;
}
// Note the -((-x)>>y) is so that we always round toward +inf.
c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample);
c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample);
c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
/* unscaled special cases */
if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isAnyRGB(dstFormat))) {
ff_get_unscaled_swscale(c);
if (c->swScale) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "using unscaled %s -> %s special converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
return c;
}
}
if (flags & SWS_CPU_CAPS_MMX2) {
c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "output width is not a multiple of 32 -> no MMX2 scaler\n");
}
if (usesHFilter) c->canMMX2BeUsed=0;
}
else
c->canMMX2BeUsed=0;
c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW;
c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH;
// match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst
// but only for the FAST_BILINEAR mode otherwise do correct scaling
// n-2 is the last chrominance sample available
// this is not perfect, but no one should notice the difference, the more correct variant
// would be like the vertical one, but that would require some special code for the
// first and last pixel
if (flags&SWS_FAST_BILINEAR) {
if (c->canMMX2BeUsed) {
c->lumXInc+= 20;
c->chrXInc+= 20;
}
//we don't use the x86 asm scaler if MMX is available
else if (flags & SWS_CPU_CAPS_MMX) {
c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;
}
}
/* precalculate horizontal scaler filter coefficients */
{
#if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
// can't downscale !!!
if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) {
c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8);
c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4);
#ifdef MAP_ANONYMOUS
c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#elif HAVE_VIRTUALALLOC
c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize);
c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);
#endif
if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode)
goto fail;
FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int32_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail);
initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLumFilter, c->hLumFilterPos, 8);
initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4);
#ifdef MAP_ANONYMOUS
mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
#endif
} else
#endif /* ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL */
{
const int filterAlign=
(flags & SWS_CPU_CAPS_MMX) ? 4 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc,
srcW , dstW, filterAlign, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumH, dstFilter->lumH, c->param) < 0)
goto fail;
if (initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc,
c->chrSrcW, c->chrDstW, filterAlign, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrH, dstFilter->chrH, c->param) < 0)
goto fail;
}
} // initialize horizontal stuff
/* precalculate vertical scaler filter coefficients */
{
const int filterAlign=
(flags & SWS_CPU_CAPS_MMX) && (flags & SWS_ACCURATE_RND) ? 2 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc,
srcH , dstH, filterAlign, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumV, dstFilter->lumV, c->param) < 0)
goto fail;
if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc,
c->chrSrcH, c->chrDstH, filterAlign, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrV, dstFilter->chrV, c->param) < 0)
goto fail;
#if ARCH_PPC && HAVE_ALTIVEC
FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail);
FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail);
for (i=0;i<c->vLumFilterSize*c->dstH;i++) {
int j;
short *p = (short *)&c->vYCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = c->vLumFilter[i];
}
for (i=0;i<c->vChrFilterSize*c->chrDstH;i++) {
int j;
short *p = (short *)&c->vCCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = c->vChrFilter[i];
}
#endif
}
// calculate buffer sizes so that they won't run out while handling these damn slices
c->vLumBufSize= c->vLumFilterSize;
c->vChrBufSize= c->vChrFilterSize;
for (i=0; i<dstH; i++) {
int chrI= i*c->chrDstH / dstH;
int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1,
((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample));
nextSlice>>= c->chrSrcVSubSample;
nextSlice<<= c->chrSrcVSubSample;
if (c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice)
c->vLumBufSize= nextSlice - c->vLumFilterPos[i];
if (c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample))
c->vChrBufSize= (nextSlice>>c->chrSrcVSubSample) - c->vChrFilterPos[chrI];
}
// allocate pixbufs (we use dynamic allocation because otherwise we would need to
// allocate several megabytes to handle all possible cases)
FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail);
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
//Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000)
/* align at 16 bytes for AltiVec */
for (i=0; i<c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize];
}
for (i=0; i<c->vChrBufSize; i++) {
FF_ALLOC_OR_GOTO(c, c->chrPixBuf[i+c->vChrBufSize], (VOF+1)*2, fail);
c->chrPixBuf[i] = c->chrPixBuf[i+c->vChrBufSize];
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
for (i=0; i<c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->alpPixBuf[i] = c->alpPixBuf[i+c->vLumBufSize];
}
//try to avoid drawing green stuff between the right end and the stride end
for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, (VOF+1)*2);
assert(2*VOFW == VOF);
assert(c->chrDstH <= dstH);
if (flags&SWS_PRINT_INFO) {
if (flags&SWS_FAST_BILINEAR)
av_log(c, AV_LOG_INFO, "FAST_BILINEAR scaler, ");
else if (flags&SWS_BILINEAR)
av_log(c, AV_LOG_INFO, "BILINEAR scaler, ");
else if (flags&SWS_BICUBIC)
av_log(c, AV_LOG_INFO, "BICUBIC scaler, ");
else if (flags&SWS_X)
av_log(c, AV_LOG_INFO, "Experimental scaler, ");
else if (flags&SWS_POINT)
av_log(c, AV_LOG_INFO, "Nearest Neighbor / POINT scaler, ");
else if (flags&SWS_AREA)
av_log(c, AV_LOG_INFO, "Area Averaging scaler, ");
else if (flags&SWS_BICUBLIN)
av_log(c, AV_LOG_INFO, "luma BICUBIC / chroma BILINEAR scaler, ");
else if (flags&SWS_GAUSS)
av_log(c, AV_LOG_INFO, "Gaussian scaler, ");
else if (flags&SWS_SINC)
av_log(c, AV_LOG_INFO, "Sinc scaler, ");
else if (flags&SWS_LANCZOS)
av_log(c, AV_LOG_INFO, "Lanczos scaler, ");
else if (flags&SWS_SPLINE)
av_log(c, AV_LOG_INFO, "Bicubic spline scaler, ");
else
av_log(c, AV_LOG_INFO, "ehh flags invalid?! ");
av_log(c, AV_LOG_INFO, "from %s to %s%s ",
sws_format_name(srcFormat),
#ifdef DITHER1XBPP
dstFormat == PIX_FMT_BGR555 || dstFormat == PIX_FMT_BGR565 ||
dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE ? "dithered " : "",
#else
"",
#endif
sws_format_name(dstFormat));
if (flags & SWS_CPU_CAPS_MMX2)
av_log(c, AV_LOG_INFO, "using MMX2\n");
else if (flags & SWS_CPU_CAPS_3DNOW)
av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if (flags & SWS_CPU_CAPS_MMX)
av_log(c, AV_LOG_INFO, "using MMX\n");
else if (flags & SWS_CPU_CAPS_ALTIVEC)
av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
av_log(c, AV_LOG_INFO, "using C\n");
if (flags & SWS_CPU_CAPS_MMX) {
if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else {
if (c->hLumFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal luminance scaling\n");
else if (c->hLumFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal luminance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal luminance scaling\n");
if (c->hChrFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if (c->hChrFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal chrominance scaling\n");
}
} else {
#if ARCH_X86
av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n");
#else
if (flags & SWS_FAST_BILINEAR)
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using C scaler for horizontal scaling\n");
#endif
}
if (isPlanarYUV(dstFormat)) {
if (c->vLumFilterSize==1)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
} else {
if (c->vLumFilterSize==1 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
" 2-tap scaler for vertical chrominance scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (c->vLumFilterSize==2 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
if (dstFormat==PIX_FMT_BGR24)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if (dstFormat==PIX_FMT_RGB32)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR565)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR555)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR12 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
c->swScale= ff_getSwsFunc(c);
return c;
fail:
sws_freeContext(c);
return NULL;
}
| false | FFmpeg | f684f3c58a77a20f18b80f888d69c2bacb53ca9b | SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
{
SwsContext *c;
int i;
int usesVFilter, usesHFilter;
int unscaled;
int srcRange, dstRange;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#if ARCH_X86
if (flags & SWS_CPU_CAPS_MMX)
__asm__ volatile("emms\n\t"::: "memory");
#endif
#if !CONFIG_RUNTIME_CPUDETECT
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
flags |= ff_hardcodedcpuflags();
#endif
if (!rgb15to16) sws_rgb2rgb_init(flags);
unscaled = (srcW == dstW && srcH == dstH);
srcRange = handle_jpeg(&srcFormat);
dstRange = handle_jpeg(&dstFormat);
if (!isSupportedIn(srcFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input pixel format\n", sws_format_name(srcFormat));
return NULL;
}
if (!isSupportedOut(dstFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output pixel format\n", sws_format_name(dstFormat));
return NULL;
}
i= flags & ( SWS_POINT
|SWS_AREA
|SWS_BILINEAR
|SWS_FAST_BILINEAR
|SWS_BICUBIC
|SWS_X
|SWS_GAUSS
|SWS_LANCZOS
|SWS_SINC
|SWS_SPLINE
|SWS_BICUBLIN);
if(!i || (i & (i-1))) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n");
return NULL;
}
if (srcW<4 || srcH<1 || dstW<8 || dstH<1) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
srcW, srcH, dstW, dstH);
return NULL;
}
if(srcW > VOFW || dstW > VOFW) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
return NULL;
}
if (!dstFilter) dstFilter= &dummyFilter;
if (!srcFilter) srcFilter= &dummyFilter;
FF_ALLOCZ_OR_GOTO(NULL, c, sizeof(SwsContext), fail);
c->av_class = &sws_context_class;
c->srcW= srcW;
c->srcH= srcH;
c->dstW= dstW;
c->dstH= dstH;
c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW;
c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH;
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
c->vRounder= 4* 0x0001000100010001ULL;
usesVFilter = (srcFilter->lumV && srcFilter->lumV->length>1) ||
(srcFilter->chrV && srcFilter->chrV->length>1) ||
(dstFilter->lumV && dstFilter->lumV->length>1) ||
(dstFilter->chrV && dstFilter->chrV->length>1);
usesHFilter = (srcFilter->lumH && srcFilter->lumH->length>1) ||
(srcFilter->chrH && srcFilter->chrH->length>1) ||
(dstFilter->lumH && dstFilter->lumH->length>1) ||
(dstFilter->chrH && dstFilter->chrH->length>1);
getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
c->chrSrcVSubSample+= c->vChrDrop;
if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP)
&& srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8
&& srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4
&& srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE
&& ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|SWS_POINT))))
c->chrSrcHSubSample=1;
if (param) {
c->param[0] = param[0];
c->param[1] = param[1];
} else {
c->param[0] =
c->param[1] = SWS_PARAM_DEFAULT;
}
c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample);
c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample);
c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] , dstRange, 0, 1<<16, 1<<16);
if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isAnyRGB(dstFormat))) {
ff_get_unscaled_swscale(c);
if (c->swScale) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "using unscaled %s -> %s special converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
return c;
}
}
if (flags & SWS_CPU_CAPS_MMX2) {
c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "output width is not a multiple of 32 -> no MMX2 scaler\n");
}
if (usesHFilter) c->canMMX2BeUsed=0;
}
else
c->canMMX2BeUsed=0;
c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW;
c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH;
if (flags&SWS_FAST_BILINEAR) {
if (c->canMMX2BeUsed) {
c->lumXInc+= 20;
c->chrXInc+= 20;
}
else if (flags & SWS_CPU_CAPS_MMX) {
c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;
}
}
{
#if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) {
c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8);
c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4);
#ifdef MAP_ANONYMOUS
c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#elif HAVE_VIRTUALALLOC
c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize);
c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);
#endif
if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode)
goto fail;
FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int32_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail);
initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLumFilter, c->hLumFilterPos, 8);
initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4);
#ifdef MAP_ANONYMOUS
mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
#endif
} else
#endif
{
const int filterAlign=
(flags & SWS_CPU_CAPS_MMX) ? 4 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc,
srcW , dstW, filterAlign, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumH, dstFilter->lumH, c->param) < 0)
goto fail;
if (initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc,
c->chrSrcW, c->chrDstW, filterAlign, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrH, dstFilter->chrH, c->param) < 0)
goto fail;
}
}
{
const int filterAlign=
(flags & SWS_CPU_CAPS_MMX) && (flags & SWS_ACCURATE_RND) ? 2 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc,
srcH , dstH, filterAlign, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumV, dstFilter->lumV, c->param) < 0)
goto fail;
if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc,
c->chrSrcH, c->chrDstH, filterAlign, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrV, dstFilter->chrV, c->param) < 0)
goto fail;
#if ARCH_PPC && HAVE_ALTIVEC
FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail);
FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail);
for (i=0;i<c->vLumFilterSize*c->dstH;i++) {
int j;
short *p = (short *)&c->vYCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = c->vLumFilter[i];
}
for (i=0;i<c->vChrFilterSize*c->chrDstH;i++) {
int j;
short *p = (short *)&c->vCCoeffsBank[i];
for (j=0;j<8;j++)
p[j] = c->vChrFilter[i];
}
#endif
}
c->vLumBufSize= c->vLumFilterSize;
c->vChrBufSize= c->vChrFilterSize;
for (i=0; i<dstH; i++) {
int chrI= i*c->chrDstH / dstH;
int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1,
((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample));
nextSlice>>= c->chrSrcVSubSample;
nextSlice<<= c->chrSrcVSubSample;
if (c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice)
c->vLumBufSize= nextSlice - c->vLumFilterPos[i];
if (c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample))
c->vChrBufSize= (nextSlice>>c->chrSrcVSubSample) - c->vChrFilterPos[chrI];
}
FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail);
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
for (i=0; i<c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize];
}
for (i=0; i<c->vChrBufSize; i++) {
FF_ALLOC_OR_GOTO(c, c->chrPixBuf[i+c->vChrBufSize], (VOF+1)*2, fail);
c->chrPixBuf[i] = c->chrPixBuf[i+c->vChrBufSize];
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
for (i=0; i<c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->alpPixBuf[i] = c->alpPixBuf[i+c->vLumBufSize];
}
for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, (VOF+1)*2);
assert(2*VOFW == VOF);
assert(c->chrDstH <= dstH);
if (flags&SWS_PRINT_INFO) {
if (flags&SWS_FAST_BILINEAR)
av_log(c, AV_LOG_INFO, "FAST_BILINEAR scaler, ");
else if (flags&SWS_BILINEAR)
av_log(c, AV_LOG_INFO, "BILINEAR scaler, ");
else if (flags&SWS_BICUBIC)
av_log(c, AV_LOG_INFO, "BICUBIC scaler, ");
else if (flags&SWS_X)
av_log(c, AV_LOG_INFO, "Experimental scaler, ");
else if (flags&SWS_POINT)
av_log(c, AV_LOG_INFO, "Nearest Neighbor / POINT scaler, ");
else if (flags&SWS_AREA)
av_log(c, AV_LOG_INFO, "Area Averaging scaler, ");
else if (flags&SWS_BICUBLIN)
av_log(c, AV_LOG_INFO, "luma BICUBIC / chroma BILINEAR scaler, ");
else if (flags&SWS_GAUSS)
av_log(c, AV_LOG_INFO, "Gaussian scaler, ");
else if (flags&SWS_SINC)
av_log(c, AV_LOG_INFO, "Sinc scaler, ");
else if (flags&SWS_LANCZOS)
av_log(c, AV_LOG_INFO, "Lanczos scaler, ");
else if (flags&SWS_SPLINE)
av_log(c, AV_LOG_INFO, "Bicubic spline scaler, ");
else
av_log(c, AV_LOG_INFO, "ehh flags invalid?! ");
av_log(c, AV_LOG_INFO, "from %s to %s%s ",
sws_format_name(srcFormat),
#ifdef DITHER1XBPP
dstFormat == PIX_FMT_BGR555 || dstFormat == PIX_FMT_BGR565 ||
dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE ? "dithered " : "",
#else
"",
#endif
sws_format_name(dstFormat));
if (flags & SWS_CPU_CAPS_MMX2)
av_log(c, AV_LOG_INFO, "using MMX2\n");
else if (flags & SWS_CPU_CAPS_3DNOW)
av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if (flags & SWS_CPU_CAPS_MMX)
av_log(c, AV_LOG_INFO, "using MMX\n");
else if (flags & SWS_CPU_CAPS_ALTIVEC)
av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
av_log(c, AV_LOG_INFO, "using C\n");
if (flags & SWS_CPU_CAPS_MMX) {
if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else {
if (c->hLumFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal luminance scaling\n");
else if (c->hLumFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal luminance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal luminance scaling\n");
if (c->hChrFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if (c->hChrFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal chrominance scaling\n");
}
} else {
#if ARCH_X86
av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n");
#else
if (flags & SWS_FAST_BILINEAR)
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using C scaler for horizontal scaling\n");
#endif
}
if (isPlanarYUV(dstFormat)) {
if (c->vLumFilterSize==1)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
} else {
if (c->vLumFilterSize==1 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
" 2-tap scaler for vertical chrominance scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (c->vLumFilterSize==2 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
if (dstFormat==PIX_FMT_BGR24)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if (dstFormat==PIX_FMT_RGB32)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR565)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR555)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR12 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
c->swScale= ff_getSwsFunc(c);
return c;
fail:
sws_freeContext(c);
return NULL;
}
| {
"code": [],
"line_no": []
} | SwsContext *FUNC_0(int srcW, int srcH, enum PixelFormat srcFormat,
int dstW, int dstH, enum PixelFormat dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
{
SwsContext *c;
int VAR_0;
int VAR_1, VAR_2;
int VAR_3;
int VAR_4, VAR_5;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#if ARCH_X86
if (flags & SWS_CPU_CAPS_MMX)
__asm__ volatile("emms\n\t"::: "memory");
#endif
#if !CONFIG_RUNTIME_CPUDETECT
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
flags |= ff_hardcodedcpuflags();
#endif
if (!rgb15to16) sws_rgb2rgb_init(flags);
VAR_3 = (srcW == dstW && srcH == dstH);
VAR_4 = handle_jpeg(&srcFormat);
VAR_5 = handle_jpeg(&dstFormat);
if (!isSupportedIn(srcFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input pixel format\n", sws_format_name(srcFormat));
return NULL;
}
if (!isSupportedOut(dstFormat)) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output pixel format\n", sws_format_name(dstFormat));
return NULL;
}
VAR_0= flags & ( SWS_POINT
|SWS_AREA
|SWS_BILINEAR
|SWS_FAST_BILINEAR
|SWS_BICUBIC
|SWS_X
|SWS_GAUSS
|SWS_LANCZOS
|SWS_SINC
|SWS_SPLINE
|SWS_BICUBLIN);
if(!VAR_0 || (VAR_0 & (VAR_0-1))) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n");
return NULL;
}
if (srcW<4 || srcH<1 || dstW<8 || dstH<1) {
av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
srcW, srcH, dstW, dstH);
return NULL;
}
if(srcW > VOFW || dstW > VOFW) {
av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
return NULL;
}
if (!dstFilter) dstFilter= &dummyFilter;
if (!srcFilter) srcFilter= &dummyFilter;
FF_ALLOCZ_OR_GOTO(NULL, c, sizeof(SwsContext), fail);
c->av_class = &sws_context_class;
c->srcW= srcW;
c->srcH= srcH;
c->dstW= dstW;
c->dstH= dstH;
c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW;
c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH;
c->flags= flags;
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);
c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);
c->vRounder= 4* 0x0001000100010001ULL;
VAR_1 = (srcFilter->lumV && srcFilter->lumV->length>1) ||
(srcFilter->chrV && srcFilter->chrV->length>1) ||
(dstFilter->lumV && dstFilter->lumV->length>1) ||
(dstFilter->chrV && dstFilter->chrV->length>1);
VAR_2 = (srcFilter->lumH && srcFilter->lumH->length>1) ||
(srcFilter->chrH && srcFilter->chrH->length>1) ||
(dstFilter->lumH && dstFilter->lumH->length>1) ||
(dstFilter->chrH && dstFilter->chrH->length>1);
getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
c->chrSrcVSubSample+= c->vChrDrop;
if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP)
&& srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8
&& srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4
&& srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE
&& ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|SWS_POINT))))
c->chrSrcHSubSample=1;
if (param) {
c->param[0] = param[0];
c->param[1] = param[1];
} else {
c->param[0] =
c->param[1] = SWS_PARAM_DEFAULT;
}
c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample);
c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample);
c->chrDstW= -((-dstW) >> c->chrDstHSubSample);
c->chrDstH= -((-dstH) >> c->chrDstVSubSample);
sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], VAR_4, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] , VAR_5, 0, 1<<16, 1<<16);
if (VAR_3 && !VAR_2 && !VAR_1 && (VAR_4 == VAR_5 || isAnyRGB(dstFormat))) {
ff_get_unscaled_swscale(c);
if (c->swScale) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "using VAR_3 %s -> %s special converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
return c;
}
}
if (flags & SWS_CPU_CAPS_MMX2) {
c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) {
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "output width is not a multiple of 32 -> no MMX2 scaler\n");
}
if (VAR_2) c->canMMX2BeUsed=0;
}
else
c->canMMX2BeUsed=0;
c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW;
c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH;
if (flags&SWS_FAST_BILINEAR) {
if (c->canMMX2BeUsed) {
c->lumXInc+= 20;
c->chrXInc+= 20;
}
else if (flags & SWS_CPU_CAPS_MMX) {
c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;
}
}
{
#if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) {
c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8);
c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4);
#ifdef MAP_ANONYMOUS
c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#elif HAVE_VIRTUALALLOC
c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize);
c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);
#endif
if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode)
goto fail;
FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int32_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail);
initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLumFilter, c->hLumFilterPos, 8);
initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4);
#ifdef MAP_ANONYMOUS
mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ);
#endif
} else
#endif
{
const int VAR_7=
(flags & SWS_CPU_CAPS_MMX) ? 4 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc,
srcW , dstW, VAR_7, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumH, dstFilter->lumH, c->param) < 0)
goto fail;
if (initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc,
c->chrSrcW, c->chrDstW, VAR_7, 1<<14,
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrH, dstFilter->chrH, c->param) < 0)
goto fail;
}
}
{
const int VAR_7=
(flags & SWS_CPU_CAPS_MMX) && (flags & SWS_ACCURATE_RND) ? 2 :
(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :
1;
if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc,
srcH , dstH, VAR_7, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,
srcFilter->lumV, dstFilter->lumV, c->param) < 0)
goto fail;
if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc,
c->chrSrcH, c->chrDstH, VAR_7, (1<<12),
(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,
srcFilter->chrV, dstFilter->chrV, c->param) < 0)
goto fail;
#if ARCH_PPC && HAVE_ALTIVEC
FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail);
FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail);
for (VAR_0=0;VAR_0<c->vLumFilterSize*c->dstH;VAR_0++) {
int j;
short *p = (short *)&c->vYCoeffsBank[VAR_0];
for (j=0;j<8;j++)
p[j] = c->vLumFilter[VAR_0];
}
for (VAR_0=0;VAR_0<c->vChrFilterSize*c->chrDstH;VAR_0++) {
int j;
short *p = (short *)&c->vCCoeffsBank[VAR_0];
for (j=0;j<8;j++)
p[j] = c->vChrFilter[VAR_0];
}
#endif
}
c->vLumBufSize= c->vLumFilterSize;
c->vChrBufSize= c->vChrFilterSize;
for (VAR_0=0; VAR_0<dstH; VAR_0++) {
int VAR_7= VAR_0*c->chrDstH / dstH;
int VAR_8= FFMAX(c->vLumFilterPos[VAR_0 ] + c->vLumFilterSize - 1,
((c->vChrFilterPos[VAR_7] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample));
VAR_8>>= c->chrSrcVSubSample;
VAR_8<<= c->chrSrcVSubSample;
if (c->vLumFilterPos[VAR_0 ] + c->vLumBufSize < VAR_8)
c->vLumBufSize= VAR_8 - c->vLumFilterPos[VAR_0];
if (c->vChrFilterPos[VAR_7] + c->vChrBufSize < (VAR_8>>c->chrSrcVSubSample))
c->vChrBufSize= (VAR_8>>c->chrSrcVSubSample) - c->vChrFilterPos[VAR_7];
}
FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail);
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
for (VAR_0=0; VAR_0<c->vLumBufSize; VAR_0++) {
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[VAR_0+c->vLumBufSize], VOF+1, fail);
c->lumPixBuf[VAR_0] = c->lumPixBuf[VAR_0+c->vLumBufSize];
}
for (VAR_0=0; VAR_0<c->vChrBufSize; VAR_0++) {
FF_ALLOC_OR_GOTO(c, c->chrPixBuf[VAR_0+c->vChrBufSize], (VOF+1)*2, fail);
c->chrPixBuf[VAR_0] = c->chrPixBuf[VAR_0+c->vChrBufSize];
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
for (VAR_0=0; VAR_0<c->vLumBufSize; VAR_0++) {
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[VAR_0+c->vLumBufSize], VOF+1, fail);
c->alpPixBuf[VAR_0] = c->alpPixBuf[VAR_0+c->vLumBufSize];
}
for (VAR_0=0; VAR_0<c->vChrBufSize; VAR_0++) memset(c->chrPixBuf[VAR_0], 64, (VOF+1)*2);
assert(2*VOFW == VOF);
assert(c->chrDstH <= dstH);
if (flags&SWS_PRINT_INFO) {
if (flags&SWS_FAST_BILINEAR)
av_log(c, AV_LOG_INFO, "FAST_BILINEAR scaler, ");
else if (flags&SWS_BILINEAR)
av_log(c, AV_LOG_INFO, "BILINEAR scaler, ");
else if (flags&SWS_BICUBIC)
av_log(c, AV_LOG_INFO, "BICUBIC scaler, ");
else if (flags&SWS_X)
av_log(c, AV_LOG_INFO, "Experimental scaler, ");
else if (flags&SWS_POINT)
av_log(c, AV_LOG_INFO, "Nearest Neighbor / POINT scaler, ");
else if (flags&SWS_AREA)
av_log(c, AV_LOG_INFO, "Area Averaging scaler, ");
else if (flags&SWS_BICUBLIN)
av_log(c, AV_LOG_INFO, "luma BICUBIC / chroma BILINEAR scaler, ");
else if (flags&SWS_GAUSS)
av_log(c, AV_LOG_INFO, "Gaussian scaler, ");
else if (flags&SWS_SINC)
av_log(c, AV_LOG_INFO, "Sinc scaler, ");
else if (flags&SWS_LANCZOS)
av_log(c, AV_LOG_INFO, "Lanczos scaler, ");
else if (flags&SWS_SPLINE)
av_log(c, AV_LOG_INFO, "Bicubic spline scaler, ");
else
av_log(c, AV_LOG_INFO, "ehh flags invalid?! ");
av_log(c, AV_LOG_INFO, "from %s to %s%s ",
sws_format_name(srcFormat),
#ifdef DITHER1XBPP
dstFormat == PIX_FMT_BGR555 || dstFormat == PIX_FMT_BGR565 ||
dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE ? "dithered " : "",
#else
"",
#endif
sws_format_name(dstFormat));
if (flags & SWS_CPU_CAPS_MMX2)
av_log(c, AV_LOG_INFO, "using MMX2\n");
else if (flags & SWS_CPU_CAPS_3DNOW)
av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if (flags & SWS_CPU_CAPS_MMX)
av_log(c, AV_LOG_INFO, "using MMX\n");
else if (flags & SWS_CPU_CAPS_ALTIVEC)
av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
av_log(c, AV_LOG_INFO, "using C\n");
if (flags & SWS_CPU_CAPS_MMX) {
if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else {
if (c->hLumFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal luminance scaling\n");
else if (c->hLumFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal luminance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal luminance scaling\n");
if (c->hChrFilterSize==4)
av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if (c->hChrFilterSize==8)
av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal chrominance scaling\n");
}
} else {
#if ARCH_X86
av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n");
#else
if (flags & SWS_FAST_BILINEAR)
av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n");
else
av_log(c, AV_LOG_VERBOSE, "using C scaler for horizontal scaling\n");
#endif
}
if (isPlanarYUV(dstFormat)) {
if (c->vLumFilterSize==1)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
} else {
if (c->vLumFilterSize==1 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
" 2-tap scaler for vertical chrominance scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (c->vLumFilterSize==2 && c->vChrFilterSize==2)
av_log(c, AV_LOG_VERBOSE, "using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
if (dstFormat==PIX_FMT_BGR24)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if (dstFormat==PIX_FMT_RGB32)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR565)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat==PIX_FMT_BGR555)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if (dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||
dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE)
av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR12 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
c->swScale= ff_getSwsFunc(c);
return c;
fail:
sws_freeContext(c);
return NULL;
}
| [
"SwsContext *FUNC_0(int srcW, int srcH, enum PixelFormat srcFormat,\nint dstW, int dstH, enum PixelFormat dstFormat, int flags,\nSwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)\n{",
"SwsContext *c;",
"int VAR_0;",
"int VAR_1, VAR_2;",
"int VAR_3;",
"int VAR_4, VAR_5;",
"SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};",
"#if ARCH_X86\nif (flags & SWS_CPU_CAPS_MMX)\n__asm__ volatile(\"emms\\n\\t\"::: \"memory\");",
"#endif\n#if !CONFIG_RUNTIME_CPUDETECT\nflags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);",
"flags |= ff_hardcodedcpuflags();",
"#endif\nif (!rgb15to16) sws_rgb2rgb_init(flags);",
"VAR_3 = (srcW == dstW && srcH == dstH);",
"VAR_4 = handle_jpeg(&srcFormat);",
"VAR_5 = handle_jpeg(&dstFormat);",
"if (!isSupportedIn(srcFormat)) {",
"av_log(NULL, AV_LOG_ERROR, \"swScaler: %s is not supported as input pixel format\\n\", sws_format_name(srcFormat));",
"return NULL;",
"}",
"if (!isSupportedOut(dstFormat)) {",
"av_log(NULL, AV_LOG_ERROR, \"swScaler: %s is not supported as output pixel format\\n\", sws_format_name(dstFormat));",
"return NULL;",
"}",
"VAR_0= flags & ( SWS_POINT\n|SWS_AREA\n|SWS_BILINEAR\n|SWS_FAST_BILINEAR\n|SWS_BICUBIC\n|SWS_X\n|SWS_GAUSS\n|SWS_LANCZOS\n|SWS_SINC\n|SWS_SPLINE\n|SWS_BICUBLIN);",
"if(!VAR_0 || (VAR_0 & (VAR_0-1))) {",
"av_log(NULL, AV_LOG_ERROR, \"swScaler: Exactly one scaler algorithm must be chosen\\n\");",
"return NULL;",
"}",
"if (srcW<4 || srcH<1 || dstW<8 || dstH<1) {",
"av_log(NULL, AV_LOG_ERROR, \"swScaler: %dx%d -> %dx%d is invalid scaling dimension\\n\",\nsrcW, srcH, dstW, dstH);",
"return NULL;",
"}",
"if(srcW > VOFW || dstW > VOFW) {",
"av_log(NULL, AV_LOG_ERROR, \"swScaler: Compile-time maximum width is \"AV_STRINGIFY(VOFW)\" change VOF/VOFW and recompile\\n\");",
"return NULL;",
"}",
"if (!dstFilter) dstFilter= &dummyFilter;",
"if (!srcFilter) srcFilter= &dummyFilter;",
"FF_ALLOCZ_OR_GOTO(NULL, c, sizeof(SwsContext), fail);",
"c->av_class = &sws_context_class;",
"c->srcW= srcW;",
"c->srcH= srcH;",
"c->dstW= dstW;",
"c->dstH= dstH;",
"c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW;",
"c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH;",
"c->flags= flags;",
"c->dstFormat= dstFormat;",
"c->srcFormat= srcFormat;",
"c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]);",
"c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]);",
"c->vRounder= 4* 0x0001000100010001ULL;",
"VAR_1 = (srcFilter->lumV && srcFilter->lumV->length>1) ||\n(srcFilter->chrV && srcFilter->chrV->length>1) ||\n(dstFilter->lumV && dstFilter->lumV->length>1) ||\n(dstFilter->chrV && dstFilter->chrV->length>1);",
"VAR_2 = (srcFilter->lumH && srcFilter->lumH->length>1) ||\n(srcFilter->chrH && srcFilter->chrH->length>1) ||\n(dstFilter->lumH && dstFilter->lumH->length>1) ||\n(dstFilter->chrH && dstFilter->chrH->length>1);",
"getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);",
"getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);",
"if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;",
"c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;",
"c->chrSrcVSubSample+= c->vChrDrop;",
"if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP)\n&& srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8\n&& srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4\n&& srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE\n&& ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&(SWS_FAST_BILINEAR|SWS_POINT))))\nc->chrSrcHSubSample=1;",
"if (param) {",
"c->param[0] = param[0];",
"c->param[1] = param[1];",
"} else {",
"c->param[0] =\nc->param[1] = SWS_PARAM_DEFAULT;",
"}",
"c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample);",
"c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample);",
"c->chrDstW= -((-dstW) >> c->chrDstHSubSample);",
"c->chrDstH= -((-dstH) >> c->chrDstVSubSample);",
"sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], VAR_4, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] , VAR_5, 0, 1<<16, 1<<16);",
"if (VAR_3 && !VAR_2 && !VAR_1 && (VAR_4 == VAR_5 || isAnyRGB(dstFormat))) {",
"ff_get_unscaled_swscale(c);",
"if (c->swScale) {",
"if (flags&SWS_PRINT_INFO)\nav_log(c, AV_LOG_INFO, \"using VAR_3 %s -> %s special converter\\n\",\nsws_format_name(srcFormat), sws_format_name(dstFormat));",
"return c;",
"}",
"}",
"if (flags & SWS_CPU_CAPS_MMX2) {",
"c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;",
"if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) {",
"if (flags&SWS_PRINT_INFO)\nav_log(c, AV_LOG_INFO, \"output width is not a multiple of 32 -> no MMX2 scaler\\n\");",
"}",
"if (VAR_2) c->canMMX2BeUsed=0;",
"}",
"else\nc->canMMX2BeUsed=0;",
"c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW;",
"c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH;",
"if (flags&SWS_FAST_BILINEAR) {",
"if (c->canMMX2BeUsed) {",
"c->lumXInc+= 20;",
"c->chrXInc+= 20;",
"}",
"else if (flags & SWS_CPU_CAPS_MMX) {",
"c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;",
"c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20;",
"}",
"}",
"{",
"#if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL\nif (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) {",
"c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8);",
"c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4);",
"#ifdef MAP_ANONYMOUS\nc->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);",
"c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);",
"#elif HAVE_VIRTUALALLOC\nc->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);",
"c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);",
"#else\nc->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize);",
"c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);",
"#endif\nif (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode)\ngoto fail;",
"FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail);",
"FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail);",
"FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int32_t), fail);",
"FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail);",
"initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLumFilter, c->hLumFilterPos, 8);",
"initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4);",
"#ifdef MAP_ANONYMOUS\nmprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ);",
"mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ);",
"#endif\n} else",
"#endif\n{",
"const int VAR_7=\n(flags & SWS_CPU_CAPS_MMX) ? 4 :\n(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :\n1;",
"if (initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc,\nsrcW , dstW, VAR_7, 1<<14,\n(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,\nsrcFilter->lumH, dstFilter->lumH, c->param) < 0)\ngoto fail;",
"if (initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc,\nc->chrSrcW, c->chrDstW, VAR_7, 1<<14,\n(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,\nsrcFilter->chrH, dstFilter->chrH, c->param) < 0)\ngoto fail;",
"}",
"}",
"{",
"const int VAR_7=\n(flags & SWS_CPU_CAPS_MMX) && (flags & SWS_ACCURATE_RND) ? 2 :\n(flags & SWS_CPU_CAPS_ALTIVEC) ? 8 :\n1;",
"if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc,\nsrcH , dstH, VAR_7, (1<<12),\n(flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags,\nsrcFilter->lumV, dstFilter->lumV, c->param) < 0)\ngoto fail;",
"if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc,\nc->chrSrcH, c->chrDstH, VAR_7, (1<<12),\n(flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags,\nsrcFilter->chrV, dstFilter->chrV, c->param) < 0)\ngoto fail;",
"#if ARCH_PPC && HAVE_ALTIVEC\nFF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail);",
"FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail);",
"for (VAR_0=0;VAR_0<c->vLumFilterSize*c->dstH;VAR_0++) {",
"int j;",
"short *p = (short *)&c->vYCoeffsBank[VAR_0];",
"for (j=0;j<8;j++)",
"p[j] = c->vLumFilter[VAR_0];",
"}",
"for (VAR_0=0;VAR_0<c->vChrFilterSize*c->chrDstH;VAR_0++) {",
"int j;",
"short *p = (short *)&c->vCCoeffsBank[VAR_0];",
"for (j=0;j<8;j++)",
"p[j] = c->vChrFilter[VAR_0];",
"}",
"#endif\n}",
"c->vLumBufSize= c->vLumFilterSize;",
"c->vChrBufSize= c->vChrFilterSize;",
"for (VAR_0=0; VAR_0<dstH; VAR_0++) {",
"int VAR_7= VAR_0*c->chrDstH / dstH;",
"int VAR_8= FFMAX(c->vLumFilterPos[VAR_0 ] + c->vLumFilterSize - 1,\n((c->vChrFilterPos[VAR_7] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample));",
"VAR_8>>= c->chrSrcVSubSample;",
"VAR_8<<= c->chrSrcVSubSample;",
"if (c->vLumFilterPos[VAR_0 ] + c->vLumBufSize < VAR_8)\nc->vLumBufSize= VAR_8 - c->vLumFilterPos[VAR_0];",
"if (c->vChrFilterPos[VAR_7] + c->vChrBufSize < (VAR_8>>c->chrSrcVSubSample))\nc->vChrBufSize= (VAR_8>>c->chrSrcVSubSample) - c->vChrFilterPos[VAR_7];",
"}",
"FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);",
"FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail);",
"if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))\nFF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);",
"for (VAR_0=0; VAR_0<c->vLumBufSize; VAR_0++) {",
"FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[VAR_0+c->vLumBufSize], VOF+1, fail);",
"c->lumPixBuf[VAR_0] = c->lumPixBuf[VAR_0+c->vLumBufSize];",
"}",
"for (VAR_0=0; VAR_0<c->vChrBufSize; VAR_0++) {",
"FF_ALLOC_OR_GOTO(c, c->chrPixBuf[VAR_0+c->vChrBufSize], (VOF+1)*2, fail);",
"c->chrPixBuf[VAR_0] = c->chrPixBuf[VAR_0+c->vChrBufSize];",
"}",
"if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)\nfor (VAR_0=0; VAR_0<c->vLumBufSize; VAR_0++) {",
"FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[VAR_0+c->vLumBufSize], VOF+1, fail);",
"c->alpPixBuf[VAR_0] = c->alpPixBuf[VAR_0+c->vLumBufSize];",
"}",
"for (VAR_0=0; VAR_0<c->vChrBufSize; VAR_0++) memset(c->chrPixBuf[VAR_0], 64, (VOF+1)*2);",
"assert(2*VOFW == VOF);",
"assert(c->chrDstH <= dstH);",
"if (flags&SWS_PRINT_INFO) {",
"if (flags&SWS_FAST_BILINEAR)\nav_log(c, AV_LOG_INFO, \"FAST_BILINEAR scaler, \");",
"else if (flags&SWS_BILINEAR)\nav_log(c, AV_LOG_INFO, \"BILINEAR scaler, \");",
"else if (flags&SWS_BICUBIC)\nav_log(c, AV_LOG_INFO, \"BICUBIC scaler, \");",
"else if (flags&SWS_X)\nav_log(c, AV_LOG_INFO, \"Experimental scaler, \");",
"else if (flags&SWS_POINT)\nav_log(c, AV_LOG_INFO, \"Nearest Neighbor / POINT scaler, \");",
"else if (flags&SWS_AREA)\nav_log(c, AV_LOG_INFO, \"Area Averaging scaler, \");",
"else if (flags&SWS_BICUBLIN)\nav_log(c, AV_LOG_INFO, \"luma BICUBIC / chroma BILINEAR scaler, \");",
"else if (flags&SWS_GAUSS)\nav_log(c, AV_LOG_INFO, \"Gaussian scaler, \");",
"else if (flags&SWS_SINC)\nav_log(c, AV_LOG_INFO, \"Sinc scaler, \");",
"else if (flags&SWS_LANCZOS)\nav_log(c, AV_LOG_INFO, \"Lanczos scaler, \");",
"else if (flags&SWS_SPLINE)\nav_log(c, AV_LOG_INFO, \"Bicubic spline scaler, \");",
"else\nav_log(c, AV_LOG_INFO, \"ehh flags invalid?! \");",
"av_log(c, AV_LOG_INFO, \"from %s to %s%s \",\nsws_format_name(srcFormat),\n#ifdef DITHER1XBPP\ndstFormat == PIX_FMT_BGR555 || dstFormat == PIX_FMT_BGR565 ||\ndstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||\ndstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE ? \"dithered \" : \"\",\n#else\n\"\",\n#endif\nsws_format_name(dstFormat));",
"if (flags & SWS_CPU_CAPS_MMX2)\nav_log(c, AV_LOG_INFO, \"using MMX2\\n\");",
"else if (flags & SWS_CPU_CAPS_3DNOW)\nav_log(c, AV_LOG_INFO, \"using 3DNOW\\n\");",
"else if (flags & SWS_CPU_CAPS_MMX)\nav_log(c, AV_LOG_INFO, \"using MMX\\n\");",
"else if (flags & SWS_CPU_CAPS_ALTIVEC)\nav_log(c, AV_LOG_INFO, \"using AltiVec\\n\");",
"else\nav_log(c, AV_LOG_INFO, \"using C\\n\");",
"if (flags & SWS_CPU_CAPS_MMX) {",
"if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))\nav_log(c, AV_LOG_VERBOSE, \"using FAST_BILINEAR MMX2 scaler for horizontal scaling\\n\");",
"else {",
"if (c->hLumFilterSize==4)\nav_log(c, AV_LOG_VERBOSE, \"using 4-tap MMX scaler for horizontal luminance scaling\\n\");",
"else if (c->hLumFilterSize==8)\nav_log(c, AV_LOG_VERBOSE, \"using 8-tap MMX scaler for horizontal luminance scaling\\n\");",
"else\nav_log(c, AV_LOG_VERBOSE, \"using n-tap MMX scaler for horizontal luminance scaling\\n\");",
"if (c->hChrFilterSize==4)\nav_log(c, AV_LOG_VERBOSE, \"using 4-tap MMX scaler for horizontal chrominance scaling\\n\");",
"else if (c->hChrFilterSize==8)\nav_log(c, AV_LOG_VERBOSE, \"using 8-tap MMX scaler for horizontal chrominance scaling\\n\");",
"else\nav_log(c, AV_LOG_VERBOSE, \"using n-tap MMX scaler for horizontal chrominance scaling\\n\");",
"}",
"} else {",
"#if ARCH_X86\nav_log(c, AV_LOG_VERBOSE, \"using x86 asm scaler for horizontal scaling\\n\");",
"#else\nif (flags & SWS_FAST_BILINEAR)\nav_log(c, AV_LOG_VERBOSE, \"using FAST_BILINEAR C scaler for horizontal scaling\\n\");",
"else\nav_log(c, AV_LOG_VERBOSE, \"using C scaler for horizontal scaling\\n\");",
"#endif\n}",
"if (isPlanarYUV(dstFormat)) {",
"if (c->vLumFilterSize==1)\nav_log(c, AV_LOG_VERBOSE, \"using 1-tap %s \\\"scaler\\\" for vertical scaling (YV12 like)\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else\nav_log(c, AV_LOG_VERBOSE, \"using n-tap %s scaler for vertical scaling (YV12 like)\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"} else {",
"if (c->vLumFilterSize==1 && c->vChrFilterSize==2)\nav_log(c, AV_LOG_VERBOSE, \"using 1-tap %s \\\"scaler\\\" for vertical luminance scaling (BGR)\\n\"\n\" 2-tap scaler for vertical chrominance scaling (BGR)\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else if (c->vLumFilterSize==2 && c->vChrFilterSize==2)\nav_log(c, AV_LOG_VERBOSE, \"using 2-tap linear %s scaler for vertical scaling (BGR)\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else\nav_log(c, AV_LOG_VERBOSE, \"using n-tap %s scaler for vertical scaling (BGR)\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"}",
"if (dstFormat==PIX_FMT_BGR24)\nav_log(c, AV_LOG_VERBOSE, \"using %s YV12->BGR24 converter\\n\",\n(flags & SWS_CPU_CAPS_MMX2) ? \"MMX2\" : ((flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\"));",
"else if (dstFormat==PIX_FMT_RGB32)\nav_log(c, AV_LOG_VERBOSE, \"using %s YV12->BGR32 converter\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else if (dstFormat==PIX_FMT_BGR565)\nav_log(c, AV_LOG_VERBOSE, \"using %s YV12->BGR16 converter\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else if (dstFormat==PIX_FMT_BGR555)\nav_log(c, AV_LOG_VERBOSE, \"using %s YV12->BGR15 converter\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"else if (dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE ||\ndstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE)\nav_log(c, AV_LOG_VERBOSE, \"using %s YV12->BGR12 converter\\n\", (flags & SWS_CPU_CAPS_MMX) ? \"MMX\" : \"C\");",
"av_log(c, AV_LOG_VERBOSE, \"%dx%d -> %dx%d\\n\", srcW, srcH, dstW, dstH);",
"av_log(c, AV_LOG_DEBUG, \"lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\\n\",\nc->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);",
"av_log(c, AV_LOG_DEBUG, \"chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\\n\",\nc->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);",
"}",
"c->swScale= ff_getSwsFunc(c);",
"return c;",
"fail:\nsws_freeContext(c);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
33
],
[
35
],
[
37,
39
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163,
165,
167,
169
],
[
171,
173,
175,
177
],
[
181
],
[
183
],
[
189
],
[
195
],
[
197
],
[
203,
205,
207,
209,
211,
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
251
],
[
253
],
[
257
],
[
259,
261,
263
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
295
],
[
297
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
339
],
[
341,
345
],
[
347
],
[
349
],
[
353,
355
],
[
357
],
[
359,
361
],
[
363
],
[
365,
367
],
[
369
],
[
371,
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
395,
397
],
[
399
],
[
401,
403
],
[
405,
407
],
[
409,
411,
413,
415
],
[
419,
421,
423,
425,
427
],
[
429,
431,
433,
435,
437
],
[
439
],
[
441
],
[
447
],
[
449,
451,
453,
455
],
[
459,
461,
463,
465,
467
],
[
469,
471,
473,
475,
477
],
[
481,
483
],
[
485
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515,
517
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531,
533
],
[
537
],
[
539
],
[
541,
543
],
[
545,
547
],
[
549
],
[
557
],
[
559
],
[
561,
563
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585,
587
],
[
589
],
[
591
],
[
593
],
[
599
],
[
603
],
[
607
],
[
611
],
[
613,
615
],
[
617,
619
],
[
621,
623
],
[
625,
627
],
[
629,
631
],
[
633,
635
],
[
637,
639
],
[
641,
643
],
[
645,
647
],
[
649,
651
],
[
653,
655
],
[
657,
659
],
[
663,
665,
667,
669,
671,
673,
675,
677,
679,
681
],
[
685,
687
],
[
689,
691
],
[
693,
695
],
[
697,
699
],
[
701,
703
],
[
707
],
[
709,
711
],
[
713
],
[
715,
717
],
[
719,
721
],
[
723,
725
],
[
729,
731
],
[
733,
735
],
[
737,
739
],
[
741
],
[
743
],
[
745,
747
],
[
749,
751,
753
],
[
755,
757
],
[
759,
761
],
[
763
],
[
765,
767
],
[
769,
771
],
[
773
],
[
775,
777,
779
],
[
781,
783
],
[
785,
787
],
[
789
],
[
793,
795,
797
],
[
799,
801
],
[
803,
805
],
[
807,
809
],
[
811,
813,
815
],
[
819
],
[
821,
823
],
[
825,
827
],
[
829
],
[
833
],
[
835
],
[
839,
841
],
[
843
],
[
845
]
] |
23,175 | IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
{
DeviceState *dev;
dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
qdev_prop_set_uint32(dev, "unit", unit);
qdev_prop_set_drive_nofail(dev, "drive",
blk_bs(blk_by_legacy_dinfo(drive)));
qdev_init_nofail(dev);
return DO_UPCAST(IDEDevice, qdev, dev);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
{
DeviceState *dev;
dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
qdev_prop_set_uint32(dev, "unit", unit);
qdev_prop_set_drive_nofail(dev, "drive",
blk_bs(blk_by_legacy_dinfo(drive)));
qdev_init_nofail(dev);
return DO_UPCAST(IDEDevice, qdev, dev);
}
| {
"code": [],
"line_no": []
} | IDEDevice *FUNC_0(IDEBus *bus, int unit, DriveInfo *drive)
{
DeviceState *dev;
dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
qdev_prop_set_uint32(dev, "unit", unit);
qdev_prop_set_drive_nofail(dev, "drive",
blk_bs(blk_by_legacy_dinfo(drive)));
qdev_init_nofail(dev);
return DO_UPCAST(IDEDevice, qdev, dev);
}
| [
"IDEDevice *FUNC_0(IDEBus *bus, int unit, DriveInfo *drive)\n{",
"DeviceState *dev;",
"dev = qdev_create(&bus->qbus, drive->media_cd ? \"ide-cd\" : \"ide-hd\");",
"qdev_prop_set_uint32(dev, \"unit\", unit);",
"qdev_prop_set_drive_nofail(dev, \"drive\",\nblk_bs(blk_by_legacy_dinfo(drive)));",
"qdev_init_nofail(dev);",
"return DO_UPCAST(IDEDevice, qdev, dev);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
]
] |
23,176 | void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr, int64_t iops, int64_t iops_rd,
int64_t iops_wr, Error **errp)
{
BlockIOLimit io_limits;
BlockDriverState *bs;
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = bps;
io_limits.bps[BLOCK_IO_LIMIT_READ] = bps_rd;
io_limits.bps[BLOCK_IO_LIMIT_WRITE] = bps_wr;
io_limits.iops[BLOCK_IO_LIMIT_TOTAL]= iops;
io_limits.iops[BLOCK_IO_LIMIT_READ] = iops_rd;
io_limits.iops[BLOCK_IO_LIMIT_WRITE]= iops_wr;
if (!do_check_io_limits(&io_limits)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
return;
}
bs->io_limits = io_limits;
bs->slice_time = BLOCK_IO_SLICE_TIME;
if (!bs->io_limits_enabled && bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_disable(bs);
} else {
if (bs->block_timer) {
qemu_mod_timer(bs->block_timer, qemu_get_clock_ns(vm_clock));
}
}
}
| false | qemu | c546194f260fb3e391193cb8cc33505618077ecb | void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
int64_t bps_wr, int64_t iops, int64_t iops_rd,
int64_t iops_wr, Error **errp)
{
BlockIOLimit io_limits;
BlockDriverState *bs;
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = bps;
io_limits.bps[BLOCK_IO_LIMIT_READ] = bps_rd;
io_limits.bps[BLOCK_IO_LIMIT_WRITE] = bps_wr;
io_limits.iops[BLOCK_IO_LIMIT_TOTAL]= iops;
io_limits.iops[BLOCK_IO_LIMIT_READ] = iops_rd;
io_limits.iops[BLOCK_IO_LIMIT_WRITE]= iops_wr;
if (!do_check_io_limits(&io_limits)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
return;
}
bs->io_limits = io_limits;
bs->slice_time = BLOCK_IO_SLICE_TIME;
if (!bs->io_limits_enabled && bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_disable(bs);
} else {
if (bs->block_timer) {
qemu_mod_timer(bs->block_timer, qemu_get_clock_ns(vm_clock));
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,
int64_t VAR_3, int64_t VAR_4, int64_t VAR_5,
int64_t VAR_6, Error **VAR_7)
{
BlockIOLimit io_limits;
BlockDriverState *bs;
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_7, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
io_limits.VAR_1[BLOCK_IO_LIMIT_TOTAL] = VAR_1;
io_limits.VAR_1[BLOCK_IO_LIMIT_READ] = VAR_2;
io_limits.VAR_1[BLOCK_IO_LIMIT_WRITE] = VAR_3;
io_limits.VAR_4[BLOCK_IO_LIMIT_TOTAL]= VAR_4;
io_limits.VAR_4[BLOCK_IO_LIMIT_READ] = VAR_5;
io_limits.VAR_4[BLOCK_IO_LIMIT_WRITE]= VAR_6;
if (!do_check_io_limits(&io_limits)) {
error_set(VAR_7, QERR_INVALID_PARAMETER_COMBINATION);
return;
}
bs->io_limits = io_limits;
bs->slice_time = BLOCK_IO_SLICE_TIME;
if (!bs->io_limits_enabled && bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_enable(bs);
} else if (bs->io_limits_enabled && !bdrv_io_limits_enabled(bs)) {
bdrv_io_limits_disable(bs);
} else {
if (bs->block_timer) {
qemu_mod_timer(bs->block_timer, qemu_get_clock_ns(vm_clock));
}
}
}
| [
"void FUNC_0(const char *VAR_0, int64_t VAR_1, int64_t VAR_2,\nint64_t VAR_3, int64_t VAR_4, int64_t VAR_5,\nint64_t VAR_6, Error **VAR_7)\n{",
"BlockIOLimit io_limits;",
"BlockDriverState *bs;",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_7, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"io_limits.VAR_1[BLOCK_IO_LIMIT_TOTAL] = VAR_1;",
"io_limits.VAR_1[BLOCK_IO_LIMIT_READ] = VAR_2;",
"io_limits.VAR_1[BLOCK_IO_LIMIT_WRITE] = VAR_3;",
"io_limits.VAR_4[BLOCK_IO_LIMIT_TOTAL]= VAR_4;",
"io_limits.VAR_4[BLOCK_IO_LIMIT_READ] = VAR_5;",
"io_limits.VAR_4[BLOCK_IO_LIMIT_WRITE]= VAR_6;",
"if (!do_check_io_limits(&io_limits)) {",
"error_set(VAR_7, QERR_INVALID_PARAMETER_COMBINATION);",
"return;",
"}",
"bs->io_limits = io_limits;",
"bs->slice_time = BLOCK_IO_SLICE_TIME;",
"if (!bs->io_limits_enabled && bdrv_io_limits_enabled(bs)) {",
"bdrv_io_limits_enable(bs);",
"} else if (bs->io_limits_enabled && !bdrv_io_limits_enabled(bs)) {",
"bdrv_io_limits_disable(bs);",
"} else {",
"if (bs->block_timer) {",
"qemu_mod_timer(bs->block_timer, qemu_get_clock_ns(vm_clock));",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
23,177 | void os_host_main_loop_wait(int *timeout)
{
int ret, ret2, i;
PollingEntry *pe;
/* XXX: need to suppress polling by better using win32 events */
ret = 0;
for(pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret == 0) {
int err;
WaitObjects *w = &wait_objects;
qemu_mutex_unlock_iothread();
ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout);
qemu_mutex_lock_iothread();
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {
if (w->func[ret - WAIT_OBJECT_0])
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);
/* Check for additional signaled events */
for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {
/* Check if event is signaled */
ret2 = WaitForSingleObject(w->events[i], 0);
if(ret2 == WAIT_OBJECT_0) {
if (w->func[i])
w->func[i](w->opaque[i]);
} else if (ret2 == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err);
}
}
} else if (ret == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err);
}
}
*timeout = 0;
}
| false | qemu | d3b12f5dec4b27ebab58fb5797cb67bacced773b | void os_host_main_loop_wait(int *timeout)
{
int ret, ret2, i;
PollingEntry *pe;
ret = 0;
for(pe = first_polling_entry; pe != NULL; pe = pe->next) {
ret |= pe->func(pe->opaque);
}
if (ret == 0) {
int err;
WaitObjects *w = &wait_objects;
qemu_mutex_unlock_iothread();
ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout);
qemu_mutex_lock_iothread();
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {
if (w->func[ret - WAIT_OBJECT_0])
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);
for(i = (ret - WAIT_OBJECT_0 + 1); i < w->num; i++) {
ret2 = WaitForSingleObject(w->events[i], 0);
if(ret2 == WAIT_OBJECT_0) {
if (w->func[i])
w->func[i](w->opaque[i]);
} else if (ret2 == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForSingleObject error %d %d\n", i, err);
}
}
} else if (ret == WAIT_TIMEOUT) {
} else {
err = GetLastError();
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", ret, err);
}
}
*timeout = 0;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
PollingEntry *pe;
VAR_1 = 0;
for(pe = first_polling_entry; pe != NULL; pe = pe->next) {
VAR_1 |= pe->func(pe->opaque);
}
if (VAR_1 == 0) {
int VAR_4;
WaitObjects *w = &wait_objects;
qemu_mutex_unlock_iothread();
VAR_1 = WaitForMultipleObjects(w->num, w->events, FALSE, *VAR_0);
qemu_mutex_lock_iothread();
if (WAIT_OBJECT_0 + 0 <= VAR_1 && VAR_1 <= WAIT_OBJECT_0 + w->num - 1) {
if (w->func[VAR_1 - WAIT_OBJECT_0])
w->func[VAR_1 - WAIT_OBJECT_0](w->opaque[VAR_1 - WAIT_OBJECT_0]);
for(VAR_3 = (VAR_1 - WAIT_OBJECT_0 + 1); VAR_3 < w->num; VAR_3++) {
VAR_2 = WaitForSingleObject(w->events[VAR_3], 0);
if(VAR_2 == WAIT_OBJECT_0) {
if (w->func[VAR_3])
w->func[VAR_3](w->opaque[VAR_3]);
} else if (VAR_2 == WAIT_TIMEOUT) {
} else {
VAR_4 = GetLastError();
fprintf(stderr, "WaitForSingleObject error %d %d\n", VAR_3, VAR_4);
}
}
} else if (VAR_1 == WAIT_TIMEOUT) {
} else {
VAR_4 = GetLastError();
fprintf(stderr, "WaitForMultipleObjects error %d %d\n", VAR_1, VAR_4);
}
}
*VAR_0 = 0;
}
| [
"void FUNC_0(int *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"PollingEntry *pe;",
"VAR_1 = 0;",
"for(pe = first_polling_entry; pe != NULL; pe = pe->next) {",
"VAR_1 |= pe->func(pe->opaque);",
"}",
"if (VAR_1 == 0) {",
"int VAR_4;",
"WaitObjects *w = &wait_objects;",
"qemu_mutex_unlock_iothread();",
"VAR_1 = WaitForMultipleObjects(w->num, w->events, FALSE, *VAR_0);",
"qemu_mutex_lock_iothread();",
"if (WAIT_OBJECT_0 + 0 <= VAR_1 && VAR_1 <= WAIT_OBJECT_0 + w->num - 1) {",
"if (w->func[VAR_1 - WAIT_OBJECT_0])\nw->func[VAR_1 - WAIT_OBJECT_0](w->opaque[VAR_1 - WAIT_OBJECT_0]);",
"for(VAR_3 = (VAR_1 - WAIT_OBJECT_0 + 1); VAR_3 < w->num; VAR_3++) {",
"VAR_2 = WaitForSingleObject(w->events[VAR_3], 0);",
"if(VAR_2 == WAIT_OBJECT_0) {",
"if (w->func[VAR_3])\nw->func[VAR_3](w->opaque[VAR_3]);",
"} else if (VAR_2 == WAIT_TIMEOUT) {",
"} else {",
"VAR_4 = GetLastError();",
"fprintf(stderr, \"WaitForSingleObject error %d %d\\n\", VAR_3, VAR_4);",
"}",
"}",
"} else if (VAR_1 == WAIT_TIMEOUT) {",
"} else {",
"VAR_4 = GetLastError();",
"fprintf(stderr, \"WaitForMultipleObjects error %d %d\\n\", VAR_1, VAR_4);",
"}",
"}",
"*VAR_0 = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
45
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
23,178 | static void thread_pool_completion_bh(void *opaque)
{
ThreadPool *pool = opaque;
ThreadPoolElement *elem, *next;
restart:
QLIST_FOREACH_SAFE(elem, &pool->head, all, next) {
if (elem->state != THREAD_DONE) {
continue;
}
trace_thread_pool_complete(pool, elem, elem->common.opaque,
elem->ret);
QLIST_REMOVE(elem, all);
if (elem->common.cb) {
/* Read state before ret. */
smp_rmb();
/* Schedule ourselves in case elem->common.cb() calls aio_poll() to
* wait for another request that completed at the same time.
*/
qemu_bh_schedule(pool->completion_bh);
elem->common.cb(elem->common.opaque, elem->ret);
qemu_aio_unref(elem);
goto restart;
} else {
qemu_aio_unref(elem);
}
}
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | static void thread_pool_completion_bh(void *opaque)
{
ThreadPool *pool = opaque;
ThreadPoolElement *elem, *next;
restart:
QLIST_FOREACH_SAFE(elem, &pool->head, all, next) {
if (elem->state != THREAD_DONE) {
continue;
}
trace_thread_pool_complete(pool, elem, elem->common.opaque,
elem->ret);
QLIST_REMOVE(elem, all);
if (elem->common.cb) {
smp_rmb();
qemu_bh_schedule(pool->completion_bh);
elem->common.cb(elem->common.opaque, elem->ret);
qemu_aio_unref(elem);
goto restart;
} else {
qemu_aio_unref(elem);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
ThreadPool *pool = VAR_0;
ThreadPoolElement *elem, *next;
restart:
QLIST_FOREACH_SAFE(elem, &pool->head, all, next) {
if (elem->state != THREAD_DONE) {
continue;
}
trace_thread_pool_complete(pool, elem, elem->common.VAR_0,
elem->ret);
QLIST_REMOVE(elem, all);
if (elem->common.cb) {
smp_rmb();
qemu_bh_schedule(pool->completion_bh);
elem->common.cb(elem->common.VAR_0, elem->ret);
qemu_aio_unref(elem);
goto restart;
} else {
qemu_aio_unref(elem);
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"ThreadPool *pool = VAR_0;",
"ThreadPoolElement *elem, *next;",
"restart:\nQLIST_FOREACH_SAFE(elem, &pool->head, all, next) {",
"if (elem->state != THREAD_DONE) {",
"continue;",
"}",
"trace_thread_pool_complete(pool, elem, elem->common.VAR_0,\nelem->ret);",
"QLIST_REMOVE(elem, all);",
"if (elem->common.cb) {",
"smp_rmb();",
"qemu_bh_schedule(pool->completion_bh);",
"elem->common.cb(elem->common.VAR_0, elem->ret);",
"qemu_aio_unref(elem);",
"goto restart;",
"} else {",
"qemu_aio_unref(elem);",
"}",
"}",
"}"
] | [
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
],
[
23,
25
],
[
27
],
[
31
],
[
35
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
23,179 | static void test_commands(void)
{
char *response;
int i;
for (i = 0; hmp_cmds[i] != NULL; i++) {
if (verbose) {
fprintf(stderr, "\t%s\n", hmp_cmds[i]);
}
response = hmp(hmp_cmds[i]);
g_free(response);
}
}
| false | qemu | 7b899f4dd596dbb7d271f7fab36fbfffec84868e | static void test_commands(void)
{
char *response;
int i;
for (i = 0; hmp_cmds[i] != NULL; i++) {
if (verbose) {
fprintf(stderr, "\t%s\n", hmp_cmds[i]);
}
response = hmp(hmp_cmds[i]);
g_free(response);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
char *VAR_0;
int VAR_1;
for (VAR_1 = 0; hmp_cmds[VAR_1] != NULL; VAR_1++) {
if (verbose) {
fprintf(stderr, "\t%s\n", hmp_cmds[VAR_1]);
}
VAR_0 = hmp(hmp_cmds[VAR_1]);
g_free(VAR_0);
}
}
| [
"static void FUNC_0(void)\n{",
"char *VAR_0;",
"int VAR_1;",
"for (VAR_1 = 0; hmp_cmds[VAR_1] != NULL; VAR_1++) {",
"if (verbose) {",
"fprintf(stderr, \"\\t%s\\n\", hmp_cmds[VAR_1]);",
"}",
"VAR_0 = hmp(hmp_cmds[VAR_1]);",
"g_free(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
]
] |
23,180 | static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
tcg_target_long value)
{
AArch64Insn insn;
if (type == TCG_TYPE_I32) {
value = (uint32_t)value;
}
/* count trailing zeros in 16 bit steps, mapping 64 to 0. Emit the
first MOVZ with the half-word immediate skipping the zeros, with a shift
(LSL) equal to this number. Then all next instructions use MOVKs.
Zero the processed half-word in the value, continue until empty.
We build the final result 16bits at a time with up to 4 instructions,
but do not emit instructions for 16bit zero holes. */
insn = I3405_MOVZ;
do {
unsigned shift = ctz64(value) & (63 & -16);
tcg_out_insn_3405(s, insn, shift >= 32, rd, value >> shift, shift);
value &= ~(0xffffUL << shift);
insn = I3405_MOVK;
} while (value);
}
| false | qemu | dfeb5fe7700d5e29a276f571aee7f6fc4267ee96 | static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
tcg_target_long value)
{
AArch64Insn insn;
if (type == TCG_TYPE_I32) {
value = (uint32_t)value;
}
insn = I3405_MOVZ;
do {
unsigned shift = ctz64(value) & (63 & -16);
tcg_out_insn_3405(s, insn, shift >= 32, rd, value >> shift, shift);
value &= ~(0xffffUL << shift);
insn = I3405_MOVK;
} while (value);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2,
tcg_target_long VAR_3)
{
AArch64Insn insn;
if (VAR_1 == TCG_TYPE_I32) {
VAR_3 = (uint32_t)VAR_3;
}
insn = I3405_MOVZ;
do {
unsigned VAR_4 = ctz64(VAR_3) & (63 & -16);
tcg_out_insn_3405(VAR_0, insn, VAR_4 >= 32, VAR_2, VAR_3 >> VAR_4, VAR_4);
VAR_3 &= ~(0xffffUL << VAR_4);
insn = I3405_MOVK;
} while (VAR_3);
}
| [
"static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2,\ntcg_target_long VAR_3)\n{",
"AArch64Insn insn;",
"if (VAR_1 == TCG_TYPE_I32) {",
"VAR_3 = (uint32_t)VAR_3;",
"}",
"insn = I3405_MOVZ;",
"do {",
"unsigned VAR_4 = ctz64(VAR_3) & (63 & -16);",
"tcg_out_insn_3405(VAR_0, insn, VAR_4 >= 32, VAR_2, VAR_3 >> VAR_4, VAR_4);",
"VAR_3 &= ~(0xffffUL << VAR_4);",
"insn = I3405_MOVK;",
"} while (VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
23,181 | static void exynos4210_uart_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
Exynos4210UartState *s = (Exynos4210UartState *)opaque;
uint8_t ch;
PRINT_DEBUG_EXTEND("UART%d: <0x%04x> %s <- 0x%08llx\n", s->channel,
offset, exynos4210_uart_regname(offset), (long long unsigned int)val);
switch (offset) {
case ULCON:
case UBRDIV:
case UFRACVAL:
s->reg[I_(offset)] = val;
exynos4210_uart_update_parameters(s);
break;
case UFCON:
s->reg[I_(UFCON)] = val;
if (val & UFCON_Rx_FIFO_RESET) {
fifo_reset(&s->rx);
s->reg[I_(UFCON)] &= ~UFCON_Rx_FIFO_RESET;
PRINT_DEBUG("UART%d: Rx FIFO Reset\n", s->channel);
}
if (val & UFCON_Tx_FIFO_RESET) {
fifo_reset(&s->tx);
s->reg[I_(UFCON)] &= ~UFCON_Tx_FIFO_RESET;
PRINT_DEBUG("UART%d: Tx FIFO Reset\n", s->channel);
}
break;
case UTXH:
if (s->chr) {
s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY);
ch = (uint8_t)val;
qemu_chr_fe_write(s->chr, &ch, 1);
#if DEBUG_Tx_DATA
fprintf(stderr, "%c", ch);
#endif
s->reg[I_(UTRSTAT)] |= UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY;
s->reg[I_(UINTSP)] |= UINTSP_TXD;
exynos4210_uart_update_irq(s);
}
break;
case UINTP:
s->reg[I_(UINTP)] &= ~val;
s->reg[I_(UINTSP)] &= ~val;
PRINT_DEBUG("UART%d: UINTP [%04x] have been cleared: %08x\n",
s->channel, offset, s->reg[I_(UINTP)]);
exynos4210_uart_update_irq(s);
break;
case UTRSTAT:
case UERSTAT:
case UFSTAT:
case UMSTAT:
case URXH:
PRINT_DEBUG("UART%d: Trying to write into RO register: %s [%04x]\n",
s->channel, exynos4210_uart_regname(offset), offset);
break;
case UINTSP:
s->reg[I_(UINTSP)] &= ~val;
break;
case UINTM:
s->reg[I_(UINTM)] = val;
exynos4210_uart_update_irq(s);
break;
case UCON:
case UMCON:
default:
s->reg[I_(offset)] = val;
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void exynos4210_uart_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
Exynos4210UartState *s = (Exynos4210UartState *)opaque;
uint8_t ch;
PRINT_DEBUG_EXTEND("UART%d: <0x%04x> %s <- 0x%08llx\n", s->channel,
offset, exynos4210_uart_regname(offset), (long long unsigned int)val);
switch (offset) {
case ULCON:
case UBRDIV:
case UFRACVAL:
s->reg[I_(offset)] = val;
exynos4210_uart_update_parameters(s);
break;
case UFCON:
s->reg[I_(UFCON)] = val;
if (val & UFCON_Rx_FIFO_RESET) {
fifo_reset(&s->rx);
s->reg[I_(UFCON)] &= ~UFCON_Rx_FIFO_RESET;
PRINT_DEBUG("UART%d: Rx FIFO Reset\n", s->channel);
}
if (val & UFCON_Tx_FIFO_RESET) {
fifo_reset(&s->tx);
s->reg[I_(UFCON)] &= ~UFCON_Tx_FIFO_RESET;
PRINT_DEBUG("UART%d: Tx FIFO Reset\n", s->channel);
}
break;
case UTXH:
if (s->chr) {
s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY);
ch = (uint8_t)val;
qemu_chr_fe_write(s->chr, &ch, 1);
#if DEBUG_Tx_DATA
fprintf(stderr, "%c", ch);
#endif
s->reg[I_(UTRSTAT)] |= UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY;
s->reg[I_(UINTSP)] |= UINTSP_TXD;
exynos4210_uart_update_irq(s);
}
break;
case UINTP:
s->reg[I_(UINTP)] &= ~val;
s->reg[I_(UINTSP)] &= ~val;
PRINT_DEBUG("UART%d: UINTP [%04x] have been cleared: %08x\n",
s->channel, offset, s->reg[I_(UINTP)]);
exynos4210_uart_update_irq(s);
break;
case UTRSTAT:
case UERSTAT:
case UFSTAT:
case UMSTAT:
case URXH:
PRINT_DEBUG("UART%d: Trying to write into RO register: %s [%04x]\n",
s->channel, exynos4210_uart_regname(offset), offset);
break;
case UINTSP:
s->reg[I_(UINTSP)] &= ~val;
break;
case UINTM:
s->reg[I_(UINTM)] = val;
exynos4210_uart_update_irq(s);
break;
case UCON:
case UMCON:
default:
s->reg[I_(offset)] = val;
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
Exynos4210UartState *s = (Exynos4210UartState *)VAR_0;
uint8_t ch;
PRINT_DEBUG_EXTEND("UART%d: <0x%04x> %s <- 0x%08llx\n", s->channel,
VAR_1, exynos4210_uart_regname(VAR_1), (long long unsigned int)VAR_2);
switch (VAR_1) {
case ULCON:
case UBRDIV:
case UFRACVAL:
s->reg[I_(VAR_1)] = VAR_2;
exynos4210_uart_update_parameters(s);
break;
case UFCON:
s->reg[I_(UFCON)] = VAR_2;
if (VAR_2 & UFCON_Rx_FIFO_RESET) {
fifo_reset(&s->rx);
s->reg[I_(UFCON)] &= ~UFCON_Rx_FIFO_RESET;
PRINT_DEBUG("UART%d: Rx FIFO Reset\n", s->channel);
}
if (VAR_2 & UFCON_Tx_FIFO_RESET) {
fifo_reset(&s->tx);
s->reg[I_(UFCON)] &= ~UFCON_Tx_FIFO_RESET;
PRINT_DEBUG("UART%d: Tx FIFO Reset\n", s->channel);
}
break;
case UTXH:
if (s->chr) {
s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY);
ch = (uint8_t)VAR_2;
qemu_chr_fe_write(s->chr, &ch, 1);
#if DEBUG_Tx_DATA
fprintf(stderr, "%c", ch);
#endif
s->reg[I_(UTRSTAT)] |= UTRSTAT_TRANSMITTER_EMPTY |
UTRSTAT_Tx_BUFFER_EMPTY;
s->reg[I_(UINTSP)] |= UINTSP_TXD;
exynos4210_uart_update_irq(s);
}
break;
case UINTP:
s->reg[I_(UINTP)] &= ~VAR_2;
s->reg[I_(UINTSP)] &= ~VAR_2;
PRINT_DEBUG("UART%d: UINTP [%04x] have been cleared: %08x\n",
s->channel, VAR_1, s->reg[I_(UINTP)]);
exynos4210_uart_update_irq(s);
break;
case UTRSTAT:
case UERSTAT:
case UFSTAT:
case UMSTAT:
case URXH:
PRINT_DEBUG("UART%d: Trying to write into RO register: %s [%04x]\n",
s->channel, exynos4210_uart_regname(VAR_1), VAR_1);
break;
case UINTSP:
s->reg[I_(UINTSP)] &= ~VAR_2;
break;
case UINTM:
s->reg[I_(UINTM)] = VAR_2;
exynos4210_uart_update_irq(s);
break;
case UCON:
case UMCON:
default:
s->reg[I_(VAR_1)] = VAR_2;
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"Exynos4210UartState *s = (Exynos4210UartState *)VAR_0;",
"uint8_t ch;",
"PRINT_DEBUG_EXTEND(\"UART%d: <0x%04x> %s <- 0x%08llx\\n\", s->channel,\nVAR_1, exynos4210_uart_regname(VAR_1), (long long unsigned int)VAR_2);",
"switch (VAR_1) {",
"case ULCON:\ncase UBRDIV:\ncase UFRACVAL:\ns->reg[I_(VAR_1)] = VAR_2;",
"exynos4210_uart_update_parameters(s);",
"break;",
"case UFCON:\ns->reg[I_(UFCON)] = VAR_2;",
"if (VAR_2 & UFCON_Rx_FIFO_RESET) {",
"fifo_reset(&s->rx);",
"s->reg[I_(UFCON)] &= ~UFCON_Rx_FIFO_RESET;",
"PRINT_DEBUG(\"UART%d: Rx FIFO Reset\\n\", s->channel);",
"}",
"if (VAR_2 & UFCON_Tx_FIFO_RESET) {",
"fifo_reset(&s->tx);",
"s->reg[I_(UFCON)] &= ~UFCON_Tx_FIFO_RESET;",
"PRINT_DEBUG(\"UART%d: Tx FIFO Reset\\n\", s->channel);",
"}",
"break;",
"case UTXH:\nif (s->chr) {",
"s->reg[I_(UTRSTAT)] &= ~(UTRSTAT_TRANSMITTER_EMPTY |\nUTRSTAT_Tx_BUFFER_EMPTY);",
"ch = (uint8_t)VAR_2;",
"qemu_chr_fe_write(s->chr, &ch, 1);",
"#if DEBUG_Tx_DATA\nfprintf(stderr, \"%c\", ch);",
"#endif\ns->reg[I_(UTRSTAT)] |= UTRSTAT_TRANSMITTER_EMPTY |\nUTRSTAT_Tx_BUFFER_EMPTY;",
"s->reg[I_(UINTSP)] |= UINTSP_TXD;",
"exynos4210_uart_update_irq(s);",
"}",
"break;",
"case UINTP:\ns->reg[I_(UINTP)] &= ~VAR_2;",
"s->reg[I_(UINTSP)] &= ~VAR_2;",
"PRINT_DEBUG(\"UART%d: UINTP [%04x] have been cleared: %08x\\n\",\ns->channel, VAR_1, s->reg[I_(UINTP)]);",
"exynos4210_uart_update_irq(s);",
"break;",
"case UTRSTAT:\ncase UERSTAT:\ncase UFSTAT:\ncase UMSTAT:\ncase URXH:\nPRINT_DEBUG(\"UART%d: Trying to write into RO register: %s [%04x]\\n\",\ns->channel, exynos4210_uart_regname(VAR_1), VAR_1);",
"break;",
"case UINTSP:\ns->reg[I_(UINTSP)] &= ~VAR_2;",
"break;",
"case UINTM:\ns->reg[I_(UINTM)] = VAR_2;",
"exynos4210_uart_update_irq(s);",
"break;",
"case UCON:\ncase UMCON:\ndefault:\ns->reg[I_(VAR_1)] = 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23,
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
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
]
] |
23,182 | void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h){
int x, y;
int start_y, start_x, end_y, end_x;
if(src_y>= h){
src+= (h-1-src_y)*linesize;
src_y=h-1;
}else if(src_y<=-block_h){
src+= (1-block_h-src_y)*linesize;
src_y=1-block_h;
}
if(src_x>= w){
src+= (w-1-src_x)*sizeof(pixel);
src_x=w-1;
}else if(src_x<=-block_w){
src+= (1-block_w-src_x)*sizeof(pixel);
src_x=1-block_w;
}
start_y= FFMAX(0, -src_y);
start_x= FFMAX(0, -src_x);
end_y= FFMIN(block_h, h-src_y);
end_x= FFMIN(block_w, w-src_x);
av_assert2(start_y < end_y && block_h);
av_assert2(start_x < end_x && block_w);
w = end_x - start_x;
src += start_y*linesize + start_x*sizeof(pixel);
buf += start_x*sizeof(pixel);
//top
for(y=0; y<start_y; y++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
// copy existing part
for(; y<end_y; y++){
memcpy(buf, src, w*sizeof(pixel));
src += linesize;
buf += linesize;
}
//bottom
src -= linesize;
for(; y<block_h; y++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
buf -= block_h * linesize + start_x*sizeof(pixel);
while (block_h--){
pixel *bufp = (pixel*)buf;
//left
for(x=0; x<start_x; x++){
bufp[x] = bufp[start_x];
}
//right
for(x=end_x; x<block_w; x++){
bufp[x] = bufp[end_x - 1];
}
buf += linesize;
}
}
| false | FFmpeg | 2207ea44fb4fad4d47646a789bc244e3e84c1726 | void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h){
int x, y;
int start_y, start_x, end_y, end_x;
if(src_y>= h){
src+= (h-1-src_y)*linesize;
src_y=h-1;
}else if(src_y<=-block_h){
src+= (1-block_h-src_y)*linesize;
src_y=1-block_h;
}
if(src_x>= w){
src+= (w-1-src_x)*sizeof(pixel);
src_x=w-1;
}else if(src_x<=-block_w){
src+= (1-block_w-src_x)*sizeof(pixel);
src_x=1-block_w;
}
start_y= FFMAX(0, -src_y);
start_x= FFMAX(0, -src_x);
end_y= FFMIN(block_h, h-src_y);
end_x= FFMIN(block_w, w-src_x);
av_assert2(start_y < end_y && block_h);
av_assert2(start_x < end_x && block_w);
w = end_x - start_x;
src += start_y*linesize + start_x*sizeof(pixel);
buf += start_x*sizeof(pixel);
for(y=0; y<start_y; y++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
for(; y<end_y; y++){
memcpy(buf, src, w*sizeof(pixel));
src += linesize;
buf += linesize;
}
src -= linesize;
for(; y<block_h; y++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
buf -= block_h * linesize + start_x*sizeof(pixel);
while (block_h--){
pixel *bufp = (pixel*)buf;
for(x=0; x<start_x; x++){
bufp[x] = bufp[start_x];
}
for(x=end_x; x<block_w; x++){
bufp[x] = bufp[end_x - 1];
}
buf += linesize;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h){
int VAR_0, VAR_1;
int VAR_2, VAR_3, VAR_4, VAR_5;
if(src_y>= h){
src+= (h-1-src_y)*linesize;
src_y=h-1;
}else if(src_y<=-block_h){
src+= (1-block_h-src_y)*linesize;
src_y=1-block_h;
}
if(src_x>= w){
src+= (w-1-src_x)*sizeof(pixel);
src_x=w-1;
}else if(src_x<=-block_w){
src+= (1-block_w-src_x)*sizeof(pixel);
src_x=1-block_w;
}
VAR_2= FFMAX(0, -src_y);
VAR_3= FFMAX(0, -src_x);
VAR_4= FFMIN(block_h, h-src_y);
VAR_5= FFMIN(block_w, w-src_x);
av_assert2(VAR_2 < VAR_4 && block_h);
av_assert2(VAR_3 < VAR_5 && block_w);
w = VAR_5 - VAR_3;
src += VAR_2*linesize + VAR_3*sizeof(pixel);
buf += VAR_3*sizeof(pixel);
for(VAR_1=0; VAR_1<VAR_2; VAR_1++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
for(; VAR_1<VAR_4; VAR_1++){
memcpy(buf, src, w*sizeof(pixel));
src += linesize;
buf += linesize;
}
src -= linesize;
for(; VAR_1<block_h; VAR_1++){
memcpy(buf, src, w*sizeof(pixel));
buf += linesize;
}
buf -= block_h * linesize + VAR_3*sizeof(pixel);
while (block_h--){
pixel *bufp = (pixel*)buf;
for(VAR_0=0; VAR_0<VAR_3; VAR_0++){
bufp[VAR_0] = bufp[VAR_3];
}
for(VAR_0=VAR_5; VAR_0<block_w; VAR_0++){
bufp[VAR_0] = bufp[VAR_5 - 1];
}
buf += linesize;
}
}
| [
"void FUNC_0(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,\nint src_x, int src_y, int w, int h){",
"int VAR_0, VAR_1;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"if(src_y>= h){",
"src+= (h-1-src_y)*linesize;",
"src_y=h-1;",
"}else if(src_y<=-block_h){",
"src+= (1-block_h-src_y)*linesize;",
"src_y=1-block_h;",
"}",
"if(src_x>= w){",
"src+= (w-1-src_x)*sizeof(pixel);",
"src_x=w-1;",
"}else if(src_x<=-block_w){",
"src+= (1-block_w-src_x)*sizeof(pixel);",
"src_x=1-block_w;",
"}",
"VAR_2= FFMAX(0, -src_y);",
"VAR_3= FFMAX(0, -src_x);",
"VAR_4= FFMIN(block_h, h-src_y);",
"VAR_5= FFMIN(block_w, w-src_x);",
"av_assert2(VAR_2 < VAR_4 && block_h);",
"av_assert2(VAR_3 < VAR_5 && block_w);",
"w = VAR_5 - VAR_3;",
"src += VAR_2*linesize + VAR_3*sizeof(pixel);",
"buf += VAR_3*sizeof(pixel);",
"for(VAR_1=0; VAR_1<VAR_2; VAR_1++){",
"memcpy(buf, src, w*sizeof(pixel));",
"buf += linesize;",
"}",
"for(; VAR_1<VAR_4; VAR_1++){",
"memcpy(buf, src, w*sizeof(pixel));",
"src += linesize;",
"buf += linesize;",
"}",
"src -= linesize;",
"for(; VAR_1<block_h; VAR_1++){",
"memcpy(buf, src, w*sizeof(pixel));",
"buf += linesize;",
"}",
"buf -= block_h * linesize + VAR_3*sizeof(pixel);",
"while (block_h--){",
"pixel *bufp = (pixel*)buf;",
"for(VAR_0=0; VAR_0<VAR_3; VAR_0++){",
"bufp[VAR_0] = bufp[VAR_3];",
"}",
"for(VAR_0=VAR_5; VAR_0<block_w; VAR_0++){",
"bufp[VAR_0] = bufp[VAR_5 - 1];",
"}",
"buf += linesize;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
]
] |
23,183 | static void test_separators(const AVDictionary *m, const char pair, const char val)
{
AVDictionary *dict = NULL;
char pairs[] = {pair , '\0'};
char vals[] = {val, '\0'};
char *buffer = NULL;
av_dict_copy(&dict, m, 0);
print_dict(dict);
av_dict_get_string(dict, &buffer, val, pair);
printf("%s\n", buffer);
av_dict_free(&dict);
av_dict_parse_string(&dict, buffer, vals, pairs, 0);
av_freep(&buffer);
print_dict(dict);
av_dict_free(&dict);
}
| false | FFmpeg | afebf470ca73c17cc8393bfd7eeebfdf6809c2b8 | static void test_separators(const AVDictionary *m, const char pair, const char val)
{
AVDictionary *dict = NULL;
char pairs[] = {pair , '\0'};
char vals[] = {val, '\0'};
char *buffer = NULL;
av_dict_copy(&dict, m, 0);
print_dict(dict);
av_dict_get_string(dict, &buffer, val, pair);
printf("%s\n", buffer);
av_dict_free(&dict);
av_dict_parse_string(&dict, buffer, vals, pairs, 0);
av_freep(&buffer);
print_dict(dict);
av_dict_free(&dict);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const AVDictionary *VAR_0, const char VAR_1, const char VAR_2)
{
AVDictionary *dict = NULL;
char VAR_3[] = {VAR_1 , '\0'};
char VAR_4[] = {VAR_2, '\0'};
char *VAR_5 = NULL;
av_dict_copy(&dict, VAR_0, 0);
print_dict(dict);
av_dict_get_string(dict, &VAR_5, VAR_2, VAR_1);
printf("%s\n", VAR_5);
av_dict_free(&dict);
av_dict_parse_string(&dict, VAR_5, VAR_4, VAR_3, 0);
av_freep(&VAR_5);
print_dict(dict);
av_dict_free(&dict);
}
| [
"static void FUNC_0(const AVDictionary *VAR_0, const char VAR_1, const char VAR_2)\n{",
"AVDictionary *dict = NULL;",
"char VAR_3[] = {VAR_1 , '\\0'};",
"char VAR_4[] = {VAR_2, '\\0'};",
"char *VAR_5 = NULL;",
"av_dict_copy(&dict, VAR_0, 0);",
"print_dict(dict);",
"av_dict_get_string(dict, &VAR_5, VAR_2, VAR_1);",
"printf(\"%s\\n\", VAR_5);",
"av_dict_free(&dict);",
"av_dict_parse_string(&dict, VAR_5, VAR_4, VAR_3, 0);",
"av_freep(&VAR_5);",
"print_dict(dict);",
"av_dict_free(&dict);",
"}"
] | [
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
]
] |
23,185 | static int flac_read_header(AVFormatContext *s)
{
int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
uint8_t header[4];
uint8_t *buffer=NULL;
FLACDecContext *flac = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
/* the parameters will be extracted from the compressed bitstream */
/* if fLaC marker is not found, assume there is no header */
if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
avio_seek(s->pb, -4, SEEK_CUR);
return 0;
}
/* process metadata blocks */
while (!avio_feof(s->pb) && !metadata_last) {
avio_read(s->pb, header, 4);
flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
/* allocate and read metadata block for supported types */
case FLAC_METADATA_TYPE_STREAMINFO:
case FLAC_METADATA_TYPE_CUESHEET:
case FLAC_METADATA_TYPE_PICTURE:
case FLAC_METADATA_TYPE_VORBIS_COMMENT:
case FLAC_METADATA_TYPE_SEEKTABLE:
buffer = av_mallocz(metadata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!buffer) {
return AVERROR(ENOMEM);
}
if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
RETURN_ERROR(AVERROR(EIO));
}
break;
/* skip metadata block for unsupported types */
default:
ret = avio_skip(s->pb, metadata_size);
if (ret < 0)
return ret;
}
if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
uint32_t samplerate;
uint64_t samples;
/* STREAMINFO can only occur once */
if (found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (metadata_size != FLAC_STREAMINFO_SIZE) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
found_streaminfo = 1;
st->codecpar->extradata = buffer;
st->codecpar->extradata_size = metadata_size;
buffer = NULL;
/* get sample rate and sample count from STREAMINFO header;
* other parameters will be extracted by the parser */
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
/* set time base and duration */
if (samplerate > 0) {
avpriv_set_pts_info(st, 64, 1, samplerate);
if (samples > 0)
st->duration = samples;
}
} else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) {
uint8_t isrc[13];
uint64_t start;
const uint8_t *offset;
int i, chapters, track, ti;
if (metadata_size < 431)
RETURN_ERROR(AVERROR_INVALIDDATA);
offset = buffer + 395;
chapters = bytestream_get_byte(&offset) - 1;
if (chapters <= 0)
RETURN_ERROR(AVERROR_INVALIDDATA);
for (i = 0; i < chapters; i++) {
if (offset + 36 - buffer > metadata_size)
RETURN_ERROR(AVERROR_INVALIDDATA);
start = bytestream_get_be64(&offset);
track = bytestream_get_byte(&offset);
bytestream_get_buffer(&offset, isrc, 12);
isrc[12] = 0;
offset += 14;
ti = bytestream_get_byte(&offset);
if (ti <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);
offset += ti * 12;
avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc);
}
av_freep(&buffer);
} else if (metadata_type == FLAC_METADATA_TYPE_PICTURE) {
ret = ff_flac_parse_picture(s, buffer, metadata_size);
av_freep(&buffer);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error parsing attached picture.\n");
return ret;
}
} else if (metadata_type == FLAC_METADATA_TYPE_SEEKTABLE) {
const uint8_t *seekpoint = buffer;
int i, seek_point_count = metadata_size/SEEKPOINT_SIZE;
flac->found_seektable = 1;
if ((s->flags&AVFMT_FLAG_FAST_SEEK)) {
for(i=0; i<seek_point_count; i++) {
int64_t timestamp = bytestream_get_be64(&seekpoint);
int64_t pos = bytestream_get_be64(&seekpoint);
/* skip number of samples */
bytestream_get_be16(&seekpoint);
av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
}
}
av_freep(&buffer);
}
else {
/* STREAMINFO must be the first block */
if (!found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
/* process supported blocks other than STREAMINFO */
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
} else if (ret > 0) {
s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
/* parse the channels mask if present */
chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
if (chmask) {
uint64_t mask = strtol(chmask->value, NULL, 0);
if (!mask || mask & ~0x3ffffULL) {
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else {
st->codecpar->channel_layout = mask;
av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
}
}
}
av_freep(&buffer);
}
}
ret = ff_replaygain_export(st, s->metadata);
if (ret < 0)
return ret;
reset_index_position(avio_tell(s->pb), st);
return 0;
fail:
av_free(buffer);
return ret;
}
| false | FFmpeg | 95bde49982a82bc10470c0adab5969ffe635d064 | static int flac_read_header(AVFormatContext *s)
{
int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
uint8_t header[4];
uint8_t *buffer=NULL;
FLACDecContext *flac = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
avio_seek(s->pb, -4, SEEK_CUR);
return 0;
}
while (!avio_feof(s->pb) && !metadata_last) {
avio_read(s->pb, header, 4);
flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
case FLAC_METADATA_TYPE_STREAMINFO:
case FLAC_METADATA_TYPE_CUESHEET:
case FLAC_METADATA_TYPE_PICTURE:
case FLAC_METADATA_TYPE_VORBIS_COMMENT:
case FLAC_METADATA_TYPE_SEEKTABLE:
buffer = av_mallocz(metadata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!buffer) {
return AVERROR(ENOMEM);
}
if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
RETURN_ERROR(AVERROR(EIO));
}
break;
default:
ret = avio_skip(s->pb, metadata_size);
if (ret < 0)
return ret;
}
if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
uint32_t samplerate;
uint64_t samples;
if (found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (metadata_size != FLAC_STREAMINFO_SIZE) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
found_streaminfo = 1;
st->codecpar->extradata = buffer;
st->codecpar->extradata_size = metadata_size;
buffer = NULL;
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
if (samplerate > 0) {
avpriv_set_pts_info(st, 64, 1, samplerate);
if (samples > 0)
st->duration = samples;
}
} else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) {
uint8_t isrc[13];
uint64_t start;
const uint8_t *offset;
int i, chapters, track, ti;
if (metadata_size < 431)
RETURN_ERROR(AVERROR_INVALIDDATA);
offset = buffer + 395;
chapters = bytestream_get_byte(&offset) - 1;
if (chapters <= 0)
RETURN_ERROR(AVERROR_INVALIDDATA);
for (i = 0; i < chapters; i++) {
if (offset + 36 - buffer > metadata_size)
RETURN_ERROR(AVERROR_INVALIDDATA);
start = bytestream_get_be64(&offset);
track = bytestream_get_byte(&offset);
bytestream_get_buffer(&offset, isrc, 12);
isrc[12] = 0;
offset += 14;
ti = bytestream_get_byte(&offset);
if (ti <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);
offset += ti * 12;
avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc);
}
av_freep(&buffer);
} else if (metadata_type == FLAC_METADATA_TYPE_PICTURE) {
ret = ff_flac_parse_picture(s, buffer, metadata_size);
av_freep(&buffer);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error parsing attached picture.\n");
return ret;
}
} else if (metadata_type == FLAC_METADATA_TYPE_SEEKTABLE) {
const uint8_t *seekpoint = buffer;
int i, seek_point_count = metadata_size/SEEKPOINT_SIZE;
flac->found_seektable = 1;
if ((s->flags&AVFMT_FLAG_FAST_SEEK)) {
for(i=0; i<seek_point_count; i++) {
int64_t timestamp = bytestream_get_be64(&seekpoint);
int64_t pos = bytestream_get_be64(&seekpoint);
bytestream_get_be16(&seekpoint);
av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
}
}
av_freep(&buffer);
}
else {
if (!found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
} else if (ret > 0) {
s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
if (chmask) {
uint64_t mask = strtol(chmask->value, NULL, 0);
if (!mask || mask & ~0x3ffffULL) {
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else {
st->codecpar->channel_layout = mask;
av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
}
}
}
av_freep(&buffer);
}
}
ret = ff_replaygain_export(st, s->metadata);
if (ret < 0)
return ret;
reset_index_position(avio_tell(s->pb), st);
return 0;
fail:
av_free(buffer);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
int VAR_1, VAR_2=0, VAR_3, VAR_4, VAR_5=0;
uint8_t header[4];
uint8_t *buffer=NULL;
FLACDecContext *flac = VAR_0->priv_data;
AVStream *st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
if (avio_rl32(VAR_0->pb) != MKTAG('f','L','a','C')) {
avio_seek(VAR_0->pb, -4, SEEK_CUR);
return 0;
}
while (!avio_feof(VAR_0->pb) && !VAR_2) {
avio_read(VAR_0->pb, header, 4);
flac_parse_block_header(header, &VAR_2, &VAR_3,
&VAR_4);
switch (VAR_3) {
case FLAC_METADATA_TYPE_STREAMINFO:
case FLAC_METADATA_TYPE_CUESHEET:
case FLAC_METADATA_TYPE_PICTURE:
case FLAC_METADATA_TYPE_VORBIS_COMMENT:
case FLAC_METADATA_TYPE_SEEKTABLE:
buffer = av_mallocz(VAR_4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!buffer) {
return AVERROR(ENOMEM);
}
if (avio_read(VAR_0->pb, buffer, VAR_4) != VAR_4) {
RETURN_ERROR(AVERROR(EIO));
}
break;
default:
VAR_1 = avio_skip(VAR_0->pb, VAR_4);
if (VAR_1 < 0)
return VAR_1;
}
if (VAR_3 == FLAC_METADATA_TYPE_STREAMINFO) {
uint32_t samplerate;
uint64_t samples;
if (VAR_5) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (VAR_4 != FLAC_STREAMINFO_SIZE) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
VAR_5 = 1;
st->codecpar->extradata = buffer;
st->codecpar->extradata_size = VAR_4;
buffer = NULL;
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
if (samplerate > 0) {
avpriv_set_pts_info(st, 64, 1, samplerate);
if (samples > 0)
st->duration = samples;
}
} else if (VAR_3 == FLAC_METADATA_TYPE_CUESHEET) {
uint8_t isrc[13];
uint64_t start;
const uint8_t *VAR_6;
int VAR_12, VAR_8, VAR_9, VAR_10;
if (VAR_4 < 431)
RETURN_ERROR(AVERROR_INVALIDDATA);
VAR_6 = buffer + 395;
VAR_8 = bytestream_get_byte(&VAR_6) - 1;
if (VAR_8 <= 0)
RETURN_ERROR(AVERROR_INVALIDDATA);
for (VAR_12 = 0; VAR_12 < VAR_8; VAR_12++) {
if (VAR_6 + 36 - buffer > VAR_4)
RETURN_ERROR(AVERROR_INVALIDDATA);
start = bytestream_get_be64(&VAR_6);
VAR_9 = bytestream_get_byte(&VAR_6);
bytestream_get_buffer(&VAR_6, isrc, 12);
isrc[12] = 0;
VAR_6 += 14;
VAR_10 = bytestream_get_byte(&VAR_6);
if (VAR_10 <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);
VAR_6 += VAR_10 * 12;
avpriv_new_chapter(VAR_0, VAR_9, st->time_base, start, AV_NOPTS_VALUE, isrc);
}
av_freep(&buffer);
} else if (VAR_3 == FLAC_METADATA_TYPE_PICTURE) {
VAR_1 = ff_flac_parse_picture(VAR_0, buffer, VAR_4);
av_freep(&buffer);
if (VAR_1 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Error parsing attached picture.\n");
return VAR_1;
}
} else if (VAR_3 == FLAC_METADATA_TYPE_SEEKTABLE) {
const uint8_t *VAR_11 = buffer;
int VAR_12, VAR_12 = VAR_4/SEEKPOINT_SIZE;
flac->found_seektable = 1;
if ((VAR_0->flags&AVFMT_FLAG_FAST_SEEK)) {
for(VAR_12=0; VAR_12<VAR_12; VAR_12++) {
int64_t timestamp = bytestream_get_be64(&VAR_11);
int64_t pos = bytestream_get_be64(&VAR_11);
bytestream_get_be16(&VAR_11);
av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
}
}
av_freep(&buffer);
}
else {
if (!VAR_5) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (VAR_3 == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
VAR_1 = ff_vorbis_comment(VAR_0, &VAR_0->metadata, buffer, VAR_4, 1);
if (VAR_1 < 0) {
av_log(VAR_0, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
} else if (VAR_1 > 0) {
VAR_0->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
chmask = av_dict_get(VAR_0->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
if (chmask) {
uint64_t mask = strtol(chmask->value, NULL, 0);
if (!mask || mask & ~0x3ffffULL) {
av_log(VAR_0, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else {
st->codecpar->channel_layout = mask;
av_dict_set(&VAR_0->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
}
}
}
av_freep(&buffer);
}
}
VAR_1 = ff_replaygain_export(st, VAR_0->metadata);
if (VAR_1 < 0)
return VAR_1;
reset_index_position(avio_tell(VAR_0->pb), st);
return 0;
fail:
av_free(buffer);
return VAR_1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"int VAR_1, VAR_2=0, VAR_3, VAR_4, VAR_5=0;",
"uint8_t header[4];",
"uint8_t *buffer=NULL;",
"FLACDecContext *flac = VAR_0->priv_data;",
"AVStream *st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->codec_id = AV_CODEC_ID_FLAC;",
"st->need_parsing = AVSTREAM_PARSE_FULL_RAW;",
"if (avio_rl32(VAR_0->pb) != MKTAG('f','L','a','C')) {",
"avio_seek(VAR_0->pb, -4, SEEK_CUR);",
"return 0;",
"}",
"while (!avio_feof(VAR_0->pb) && !VAR_2) {",
"avio_read(VAR_0->pb, header, 4);",
"flac_parse_block_header(header, &VAR_2, &VAR_3,\n&VAR_4);",
"switch (VAR_3) {",
"case FLAC_METADATA_TYPE_STREAMINFO:\ncase FLAC_METADATA_TYPE_CUESHEET:\ncase FLAC_METADATA_TYPE_PICTURE:\ncase FLAC_METADATA_TYPE_VORBIS_COMMENT:\ncase FLAC_METADATA_TYPE_SEEKTABLE:\nbuffer = av_mallocz(VAR_4 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (!buffer) {",
"return AVERROR(ENOMEM);",
"}",
"if (avio_read(VAR_0->pb, buffer, VAR_4) != VAR_4) {",
"RETURN_ERROR(AVERROR(EIO));",
"}",
"break;",
"default:\nVAR_1 = avio_skip(VAR_0->pb, VAR_4);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"}",
"if (VAR_3 == FLAC_METADATA_TYPE_STREAMINFO) {",
"uint32_t samplerate;",
"uint64_t samples;",
"if (VAR_5) {",
"RETURN_ERROR(AVERROR_INVALIDDATA);",
"}",
"if (VAR_4 != FLAC_STREAMINFO_SIZE) {",
"RETURN_ERROR(AVERROR_INVALIDDATA);",
"}",
"VAR_5 = 1;",
"st->codecpar->extradata = buffer;",
"st->codecpar->extradata_size = VAR_4;",
"buffer = NULL;",
"samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;",
"samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);",
"if (samplerate > 0) {",
"avpriv_set_pts_info(st, 64, 1, samplerate);",
"if (samples > 0)\nst->duration = samples;",
"}",
"} else if (VAR_3 == FLAC_METADATA_TYPE_CUESHEET) {",
"uint8_t isrc[13];",
"uint64_t start;",
"const uint8_t *VAR_6;",
"int VAR_12, VAR_8, VAR_9, VAR_10;",
"if (VAR_4 < 431)\nRETURN_ERROR(AVERROR_INVALIDDATA);",
"VAR_6 = buffer + 395;",
"VAR_8 = bytestream_get_byte(&VAR_6) - 1;",
"if (VAR_8 <= 0)\nRETURN_ERROR(AVERROR_INVALIDDATA);",
"for (VAR_12 = 0; VAR_12 < VAR_8; VAR_12++) {",
"if (VAR_6 + 36 - buffer > VAR_4)\nRETURN_ERROR(AVERROR_INVALIDDATA);",
"start = bytestream_get_be64(&VAR_6);",
"VAR_9 = bytestream_get_byte(&VAR_6);",
"bytestream_get_buffer(&VAR_6, isrc, 12);",
"isrc[12] = 0;",
"VAR_6 += 14;",
"VAR_10 = bytestream_get_byte(&VAR_6);",
"if (VAR_10 <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);",
"VAR_6 += VAR_10 * 12;",
"avpriv_new_chapter(VAR_0, VAR_9, st->time_base, start, AV_NOPTS_VALUE, isrc);",
"}",
"av_freep(&buffer);",
"} else if (VAR_3 == FLAC_METADATA_TYPE_PICTURE) {",
"VAR_1 = ff_flac_parse_picture(VAR_0, buffer, VAR_4);",
"av_freep(&buffer);",
"if (VAR_1 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Error parsing attached picture.\\n\");",
"return VAR_1;",
"}",
"} else if (VAR_3 == FLAC_METADATA_TYPE_SEEKTABLE) {",
"const uint8_t *VAR_11 = buffer;",
"int VAR_12, VAR_12 = VAR_4/SEEKPOINT_SIZE;",
"flac->found_seektable = 1;",
"if ((VAR_0->flags&AVFMT_FLAG_FAST_SEEK)) {",
"for(VAR_12=0; VAR_12<VAR_12; VAR_12++) {",
"int64_t timestamp = bytestream_get_be64(&VAR_11);",
"int64_t pos = bytestream_get_be64(&VAR_11);",
"bytestream_get_be16(&VAR_11);",
"av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);",
"}",
"}",
"av_freep(&buffer);",
"}",
"else {",
"if (!VAR_5) {",
"RETURN_ERROR(AVERROR_INVALIDDATA);",
"}",
"if (VAR_3 == FLAC_METADATA_TYPE_VORBIS_COMMENT) {",
"AVDictionaryEntry *chmask;",
"VAR_1 = ff_vorbis_comment(VAR_0, &VAR_0->metadata, buffer, VAR_4, 1);",
"if (VAR_1 < 0) {",
"av_log(VAR_0, AV_LOG_WARNING, \"error parsing VorbisComment metadata\\n\");",
"} else if (VAR_1 > 0) {",
"VAR_0->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;",
"}",
"chmask = av_dict_get(VAR_0->metadata, \"WAVEFORMATEXTENSIBLE_CHANNEL_MASK\", NULL, 0);",
"if (chmask) {",
"uint64_t mask = strtol(chmask->value, NULL, 0);",
"if (!mask || mask & ~0x3ffffULL) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\\n\");",
"} else {",
"st->codecpar->channel_layout = mask;",
"av_dict_set(&VAR_0->metadata, \"WAVEFORMATEXTENSIBLE_CHANNEL_MASK\", NULL, 0);",
"}",
"}",
"}",
"av_freep(&buffer);",
"}",
"}",
"VAR_1 = ff_replaygain_export(st, VAR_0->metadata);",
"if (VAR_1 < 0)\nreturn VAR_1;",
"reset_index_position(avio_tell(VAR_0->pb), st);",
"return 0;",
"fail:\nav_free(buffer);",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
55,
57,
59,
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
87,
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
131
],
[
133
],
[
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
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313,
315
],
[
319
],
[
321
],
[
325,
327
],
[
329
],
[
331
]
] |
23,188 | static int ogg_write_packet(AVFormatContext *avfcontext,
int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
OggContext *context = avfcontext->priv_data ;
AVCodecContext *avctx= &avfcontext->streams[stream_index]->codec;
ogg_packet *op= &context->op;
ogg_page og ;
pts= av_rescale(pts, avctx->sample_rate, AV_TIME_BASE);
if(!size){
// av_log(avfcontext, AV_LOG_DEBUG, "zero packet\n");
return 0;
}
// av_log(avfcontext, AV_LOG_DEBUG, "M%d\n", size);
/* flush header packets so audio starts on a new page */
if(!context->header_handled) {
while(ogg_stream_flush(&context->os, &og)) {
put_buffer(&avfcontext->pb, og.header, og.header_len) ;
put_buffer(&avfcontext->pb, og.body, og.body_len) ;
put_flush_packet(&avfcontext->pb);
}
context->header_handled = 1 ;
}
op->packet = (uint8_t*) buf;
op->bytes = size;
op->b_o_s = op->packetno == 0;
op->granulepos= pts;
/* correct the fields in the packet -- essential for streaming */
ogg_stream_packetin(&context->os, op);
while(ogg_stream_pageout(&context->os, &og)) {
put_buffer(&avfcontext->pb, og.header, og.header_len);
put_buffer(&avfcontext->pb, og.body, og.body_len);
put_flush_packet(&avfcontext->pb);
}
op->packetno++;
return 0;
}
| false | FFmpeg | b0c7f5a9d82feb7f4c4cdf77f1537193670ab58b | static int ogg_write_packet(AVFormatContext *avfcontext,
int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
OggContext *context = avfcontext->priv_data ;
AVCodecContext *avctx= &avfcontext->streams[stream_index]->codec;
ogg_packet *op= &context->op;
ogg_page og ;
pts= av_rescale(pts, avctx->sample_rate, AV_TIME_BASE);
if(!size){
return 0;
}
if(!context->header_handled) {
while(ogg_stream_flush(&context->os, &og)) {
put_buffer(&avfcontext->pb, og.header, og.header_len) ;
put_buffer(&avfcontext->pb, og.body, og.body_len) ;
put_flush_packet(&avfcontext->pb);
}
context->header_handled = 1 ;
}
op->packet = (uint8_t*) buf;
op->bytes = size;
op->b_o_s = op->packetno == 0;
op->granulepos= pts;
ogg_stream_packetin(&context->os, op);
while(ogg_stream_pageout(&context->os, &og)) {
put_buffer(&avfcontext->pb, og.header, og.header_len);
put_buffer(&avfcontext->pb, og.body, og.body_len);
put_flush_packet(&avfcontext->pb);
}
op->packetno++;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
int VAR_1,
const uint8_t *VAR_2, int VAR_3, int64_t VAR_4)
{
OggContext *context = VAR_0->priv_data ;
AVCodecContext *avctx= &VAR_0->streams[VAR_1]->codec;
ogg_packet *op= &context->op;
ogg_page og ;
VAR_4= av_rescale(VAR_4, avctx->sample_rate, AV_TIME_BASE);
if(!VAR_3){
return 0;
}
if(!context->header_handled) {
while(ogg_stream_flush(&context->os, &og)) {
put_buffer(&VAR_0->pb, og.header, og.header_len) ;
put_buffer(&VAR_0->pb, og.body, og.body_len) ;
put_flush_packet(&VAR_0->pb);
}
context->header_handled = 1 ;
}
op->packet = (uint8_t*) VAR_2;
op->bytes = VAR_3;
op->b_o_s = op->packetno == 0;
op->granulepos= VAR_4;
ogg_stream_packetin(&context->os, op);
while(ogg_stream_pageout(&context->os, &og)) {
put_buffer(&VAR_0->pb, og.header, og.header_len);
put_buffer(&VAR_0->pb, og.body, og.body_len);
put_flush_packet(&VAR_0->pb);
}
op->packetno++;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nint VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"OggContext *context = VAR_0->priv_data ;",
"AVCodecContext *avctx= &VAR_0->streams[VAR_1]->codec;",
"ogg_packet *op= &context->op;",
"ogg_page og ;",
"VAR_4= av_rescale(VAR_4, avctx->sample_rate, AV_TIME_BASE);",
"if(!VAR_3){",
"return 0;",
"}",
"if(!context->header_handled) {",
"while(ogg_stream_flush(&context->os, &og)) {",
"put_buffer(&VAR_0->pb, og.header, og.header_len) ;",
"put_buffer(&VAR_0->pb, og.body, og.body_len) ;",
"put_flush_packet(&VAR_0->pb);",
"}",
"context->header_handled = 1 ;",
"}",
"op->packet = (uint8_t*) VAR_2;",
"op->bytes = VAR_3;",
"op->b_o_s = op->packetno == 0;",
"op->granulepos= VAR_4;",
"ogg_stream_packetin(&context->os, op);",
"while(ogg_stream_pageout(&context->os, &og)) {",
"put_buffer(&VAR_0->pb, og.header, og.header_len);",
"put_buffer(&VAR_0->pb, og.body, og.body_len);",
"put_flush_packet(&VAR_0->pb);",
"}",
"op->packetno++;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
27
],
[
29
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
]
] |
23,189 | uint64_t helper_cvttq_svic(CPUAlphaState *env, uint64_t a)
{
return inline_cvttq(env, a, float_round_to_zero, 1);
}
| true | qemu | c24a8a0b6dad5a33d84f5fb846edb28c43312c71 | uint64_t helper_cvttq_svic(CPUAlphaState *env, uint64_t a)
{
return inline_cvttq(env, a, float_round_to_zero, 1);
}
| {
"code": [
"uint64_t helper_cvttq_svic(CPUAlphaState *env, uint64_t a)",
" return inline_cvttq(env, a, float_round_to_zero, 1);"
],
"line_no": [
1,
5
]
} | uint64_t FUNC_0(CPUAlphaState *env, uint64_t a)
{
return inline_cvttq(env, a, float_round_to_zero, 1);
}
| [
"uint64_t FUNC_0(CPUAlphaState *env, uint64_t a)\n{",
"return inline_cvttq(env, a, float_round_to_zero, 1);",
"}"
] | [
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
23,190 | void rdma_start_incoming_migration(const char *host_port, Error **errp)
{
int ret;
RDMAContext *rdma;
Error *local_err = NULL;
DPRINTF("Starting RDMA-based incoming migration\n");
rdma = qemu_rdma_data_init(host_port, &local_err);
if (rdma == NULL) {
goto err;
}
ret = qemu_rdma_dest_init(rdma, &local_err);
if (ret) {
goto err;
}
DPRINTF("qemu_rdma_dest_init success\n");
ret = rdma_listen(rdma->listen_id, 5);
if (ret) {
ERROR(errp, "listening on socket!");
goto err;
}
DPRINTF("rdma_listen success\n");
qemu_set_fd_handler2(rdma->channel->fd, NULL,
rdma_accept_incoming_migration, NULL,
(void *)(intptr_t) rdma);
return;
err:
error_propagate(errp, local_err);
g_free(rdma);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void rdma_start_incoming_migration(const char *host_port, Error **errp)
{
int ret;
RDMAContext *rdma;
Error *local_err = NULL;
DPRINTF("Starting RDMA-based incoming migration\n");
rdma = qemu_rdma_data_init(host_port, &local_err);
if (rdma == NULL) {
goto err;
}
ret = qemu_rdma_dest_init(rdma, &local_err);
if (ret) {
goto err;
}
DPRINTF("qemu_rdma_dest_init success\n");
ret = rdma_listen(rdma->listen_id, 5);
if (ret) {
ERROR(errp, "listening on socket!");
goto err;
}
DPRINTF("rdma_listen success\n");
qemu_set_fd_handler2(rdma->channel->fd, NULL,
rdma_accept_incoming_migration, NULL,
(void *)(intptr_t) rdma);
return;
err:
error_propagate(errp, local_err);
g_free(rdma);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, Error **VAR_1)
{
int VAR_2;
RDMAContext *rdma;
Error *local_err = NULL;
DPRINTF("Starting RDMA-based incoming migration\n");
rdma = qemu_rdma_data_init(VAR_0, &local_err);
if (rdma == NULL) {
goto err;
}
VAR_2 = qemu_rdma_dest_init(rdma, &local_err);
if (VAR_2) {
goto err;
}
DPRINTF("qemu_rdma_dest_init success\n");
VAR_2 = rdma_listen(rdma->listen_id, 5);
if (VAR_2) {
ERROR(VAR_1, "listening on socket!");
goto err;
}
DPRINTF("rdma_listen success\n");
qemu_set_fd_handler2(rdma->channel->fd, NULL,
rdma_accept_incoming_migration, NULL,
(void *)(intptr_t) rdma);
return;
err:
error_propagate(VAR_1, local_err);
g_free(rdma);
}
| [
"void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"int VAR_2;",
"RDMAContext *rdma;",
"Error *local_err = NULL;",
"DPRINTF(\"Starting RDMA-based incoming migration\\n\");",
"rdma = qemu_rdma_data_init(VAR_0, &local_err);",
"if (rdma == NULL) {",
"goto err;",
"}",
"VAR_2 = qemu_rdma_dest_init(rdma, &local_err);",
"if (VAR_2) {",
"goto err;",
"}",
"DPRINTF(\"qemu_rdma_dest_init success\\n\");",
"VAR_2 = rdma_listen(rdma->listen_id, 5);",
"if (VAR_2) {",
"ERROR(VAR_1, \"listening on socket!\");",
"goto err;",
"}",
"DPRINTF(\"rdma_listen success\\n\");",
"qemu_set_fd_handler2(rdma->channel->fd, NULL,\nrdma_accept_incoming_migration, NULL,\n(void *)(intptr_t) rdma);",
"return;",
"err:\nerror_propagate(VAR_1, local_err);",
"g_free(rdma);",
"}"
] | [
0,
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
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61,
63,
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
]
] |
23,191 | int hmp_pcie_aer_inject_error(Monitor *mon,
const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
const char *error_name;
uint32_t error_status;
bool correctable;
PCIDevice *dev;
PCIEAERErr err;
int ret;
ret = pci_qdev_find_device(id, &dev);
if (ret < 0) {
monitor_printf(mon,
"id or pci device path is invalid or device not "
"found. %s\n", id);
return ret;
}
if (!pci_is_express(dev)) {
monitor_printf(mon, "the device doesn't support pci express. %s\n",
id);
return -ENOSYS;
}
error_name = qdict_get_str(qdict, "error_status");
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL;
error_status = strtoul(error_name, &e, 0);
correctable = qdict_get_try_bool(qdict, "correctable", 0);
if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"",
error_name);
return -EINVAL;
}
}
err.status = error_status;
err.source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn;
err.flags = 0;
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(qdict, "header0")) {
err.flags |= PCIE_AER_ERR_HEADER_VALID;
}
if (qdict_haskey(qdict, "prefix0")) {
err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;
}
err.header[0] = qdict_get_try_int(qdict, "header0", 0);
err.header[1] = qdict_get_try_int(qdict, "header1", 0);
err.header[2] = qdict_get_try_int(qdict, "header2", 0);
err.header[3] = qdict_get_try_int(qdict, "header3", 0);
err.prefix[0] = qdict_get_try_int(qdict, "prefix0", 0);
err.prefix[1] = qdict_get_try_int(qdict, "prefix1", 0);
err.prefix[2] = qdict_get_try_int(qdict, "prefix2", 0);
err.prefix[3] = qdict_get_try_int(qdict, "prefix3", 0);
ret = pcie_aer_inject_error(dev, &err);
*ret_data = qobject_from_jsonf("{'id': %s, "
"'root_bus': %s, 'bus': %d, 'devfn': %d, "
"'ret': %d}",
id, pci_root_bus_path(dev),
pci_bus_num(dev->bus), dev->devfn,
ret);
assert(*ret_data);
return 0;
}
| true | qemu | 04e00c92ef75629a241ebc50537f75de0867928d | int hmp_pcie_aer_inject_error(Monitor *mon,
const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
const char *error_name;
uint32_t error_status;
bool correctable;
PCIDevice *dev;
PCIEAERErr err;
int ret;
ret = pci_qdev_find_device(id, &dev);
if (ret < 0) {
monitor_printf(mon,
"id or pci device path is invalid or device not "
"found. %s\n", id);
return ret;
}
if (!pci_is_express(dev)) {
monitor_printf(mon, "the device doesn't support pci express. %s\n",
id);
return -ENOSYS;
}
error_name = qdict_get_str(qdict, "error_status");
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL;
error_status = strtoul(error_name, &e, 0);
correctable = qdict_get_try_bool(qdict, "correctable", 0);
if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"",
error_name);
return -EINVAL;
}
}
err.status = error_status;
err.source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn;
err.flags = 0;
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(qdict, "header0")) {
err.flags |= PCIE_AER_ERR_HEADER_VALID;
}
if (qdict_haskey(qdict, "prefix0")) {
err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;
}
err.header[0] = qdict_get_try_int(qdict, "header0", 0);
err.header[1] = qdict_get_try_int(qdict, "header1", 0);
err.header[2] = qdict_get_try_int(qdict, "header2", 0);
err.header[3] = qdict_get_try_int(qdict, "header3", 0);
err.prefix[0] = qdict_get_try_int(qdict, "prefix0", 0);
err.prefix[1] = qdict_get_try_int(qdict, "prefix1", 0);
err.prefix[2] = qdict_get_try_int(qdict, "prefix2", 0);
err.prefix[3] = qdict_get_try_int(qdict, "prefix3", 0);
ret = pcie_aer_inject_error(dev, &err);
*ret_data = qobject_from_jsonf("{'id': %s, "
"'root_bus': %s, 'bus': %d, 'devfn': %d, "
"'ret': %d}",
id, pci_root_bus_path(dev),
pci_bus_num(dev->bus), dev->devfn,
ret);
assert(*ret_data);
return 0;
}
| {
"code": [
"int hmp_pcie_aer_inject_error(Monitor *mon,",
" const QDict *qdict, QObject **ret_data)",
"int hmp_pcie_aer_inject_error(Monitor *mon,",
" const QDict *qdict, QObject **ret_data)",
"int hmp_pcie_aer_inject_error(Monitor *mon,"
],
"line_no": [
1,
3,
1,
3,
1
]
} | int FUNC_0(Monitor *VAR_0,
const QDict *VAR_1, QObject **VAR_2)
{
const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");
const char *VAR_4;
uint32_t error_status;
bool correctable;
PCIDevice *dev;
PCIEAERErr err;
int VAR_5;
VAR_5 = pci_qdev_find_device(VAR_3, &dev);
if (VAR_5 < 0) {
monitor_printf(VAR_0,
"VAR_3 or pci device path is invalid or device not "
"found. %s\n", VAR_3);
return VAR_5;
}
if (!pci_is_express(dev)) {
monitor_printf(VAR_0, "the device doesn't support pci express. %s\n",
VAR_3);
return -ENOSYS;
}
VAR_4 = qdict_get_str(VAR_1, "error_status");
if (pcie_aer_parse_error_string(VAR_4, &error_status, &correctable)) {
char *VAR_6 = NULL;
error_status = strtoul(VAR_4, &VAR_6, 0);
correctable = qdict_get_try_bool(VAR_1, "correctable", 0);
if (!VAR_6 || *VAR_6 != '\0') {
monitor_printf(VAR_0, "invalid error status value. \"%s\"",
VAR_4);
return -EINVAL;
}
}
err.status = error_status;
err.source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn;
err.flags = 0;
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
if (qdict_get_try_bool(VAR_1, "advisory_non_fatal", 0)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(VAR_1, "header0")) {
err.flags |= PCIE_AER_ERR_HEADER_VALID;
}
if (qdict_haskey(VAR_1, "prefix0")) {
err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;
}
err.header[0] = qdict_get_try_int(VAR_1, "header0", 0);
err.header[1] = qdict_get_try_int(VAR_1, "header1", 0);
err.header[2] = qdict_get_try_int(VAR_1, "header2", 0);
err.header[3] = qdict_get_try_int(VAR_1, "header3", 0);
err.prefix[0] = qdict_get_try_int(VAR_1, "prefix0", 0);
err.prefix[1] = qdict_get_try_int(VAR_1, "prefix1", 0);
err.prefix[2] = qdict_get_try_int(VAR_1, "prefix2", 0);
err.prefix[3] = qdict_get_try_int(VAR_1, "prefix3", 0);
VAR_5 = pcie_aer_inject_error(dev, &err);
*VAR_2 = qobject_from_jsonf("{'VAR_3': %s, "
"'root_bus': %s, 'bus': %d, 'devfn': %d, "
"'VAR_5': %d}",
VAR_3, pci_root_bus_path(dev),
pci_bus_num(dev->bus), dev->devfn,
VAR_5);
assert(*VAR_2);
return 0;
}
| [
"int FUNC_0(Monitor *VAR_0,\nconst QDict *VAR_1, QObject **VAR_2)\n{",
"const char *VAR_3 = qdict_get_str(VAR_1, \"VAR_3\");",
"const char *VAR_4;",
"uint32_t error_status;",
"bool correctable;",
"PCIDevice *dev;",
"PCIEAERErr err;",
"int VAR_5;",
"VAR_5 = pci_qdev_find_device(VAR_3, &dev);",
"if (VAR_5 < 0) {",
"monitor_printf(VAR_0,\n\"VAR_3 or pci device path is invalid or device not \"\n\"found. %s\\n\", VAR_3);",
"return VAR_5;",
"}",
"if (!pci_is_express(dev)) {",
"monitor_printf(VAR_0, \"the device doesn't support pci express. %s\\n\",\nVAR_3);",
"return -ENOSYS;",
"}",
"VAR_4 = qdict_get_str(VAR_1, \"error_status\");",
"if (pcie_aer_parse_error_string(VAR_4, &error_status, &correctable)) {",
"char *VAR_6 = NULL;",
"error_status = strtoul(VAR_4, &VAR_6, 0);",
"correctable = qdict_get_try_bool(VAR_1, \"correctable\", 0);",
"if (!VAR_6 || *VAR_6 != '\\0') {",
"monitor_printf(VAR_0, \"invalid error status value. \\\"%s\\\"\",\nVAR_4);",
"return -EINVAL;",
"}",
"}",
"err.status = error_status;",
"err.source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn;",
"err.flags = 0;",
"if (correctable) {",
"err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;",
"}",
"if (qdict_get_try_bool(VAR_1, \"advisory_non_fatal\", 0)) {",
"err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;",
"}",
"if (qdict_haskey(VAR_1, \"header0\")) {",
"err.flags |= PCIE_AER_ERR_HEADER_VALID;",
"}",
"if (qdict_haskey(VAR_1, \"prefix0\")) {",
"err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT;",
"}",
"err.header[0] = qdict_get_try_int(VAR_1, \"header0\", 0);",
"err.header[1] = qdict_get_try_int(VAR_1, \"header1\", 0);",
"err.header[2] = qdict_get_try_int(VAR_1, \"header2\", 0);",
"err.header[3] = qdict_get_try_int(VAR_1, \"header3\", 0);",
"err.prefix[0] = qdict_get_try_int(VAR_1, \"prefix0\", 0);",
"err.prefix[1] = qdict_get_try_int(VAR_1, \"prefix1\", 0);",
"err.prefix[2] = qdict_get_try_int(VAR_1, \"prefix2\", 0);",
"err.prefix[3] = qdict_get_try_int(VAR_1, \"prefix3\", 0);",
"VAR_5 = pcie_aer_inject_error(dev, &err);",
"*VAR_2 = qobject_from_jsonf(\"{'VAR_3': %s, \"",
"\"'root_bus': %s, 'bus': %d, 'devfn': %d, \"\n\"'VAR_5': %d}\",",
"VAR_3, pci_root_bus_path(dev),\npci_bus_num(dev->bus), dev->devfn,\nVAR_5);",
"assert(*VAR_2);",
"return 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129,
131
],
[
133,
135,
137
],
[
139
],
[
143
],
[
145
]
] |
23,192 | static void test_opts_parse_number(void)
{
Error *err = NULL;
QemuOpts *opts;
/* Lower limit zero */
opts = qemu_opts_parse(&opts_list_01, "number1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
/* Upper limit 2^64-1 */
opts = qemu_opts_parse(&opts_list_01,
"number1=18446744073709551615,number2=-1",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
g_assert_cmphex(qemu_opt_get_number(opts, "number2", 0), ==, UINT64_MAX);
/* Above upper limit */
opts = qemu_opts_parse(&opts_list_01, "number1=18446744073709551616",
false, &error_abort);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
/* Below lower limit */
opts = qemu_opts_parse(&opts_list_01, "number1=-18446744073709551616",
false, &error_abort);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
/* Hex and octal */
opts = qemu_opts_parse(&opts_list_01, "number1=0x2a,number2=052",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
g_assert_cmpuint(qemu_opt_get_number(opts, "number2", 0), ==, 42);
/* Invalid */
opts = qemu_opts_parse(&opts_list_01, "number1=", false, &err);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_01, "number1=eins", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
/* Leading whitespace */
opts = qemu_opts_parse(&opts_list_01, "number1= \t42",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
/* Trailing crap */
opts = qemu_opts_parse(&opts_list_01, "number1=3.14", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=08", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=0 ", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
qemu_opts_reset(&opts_list_01);
}
| true | qemu | 3403e5eb884f3a74c40fe7cccc103f848c040215 | static void test_opts_parse_number(void)
{
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_parse(&opts_list_01, "number1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_01,
"number1=18446744073709551615,number2=-1",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
g_assert_cmphex(qemu_opt_get_number(opts, "number2", 0), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=18446744073709551616",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=-18446744073709551616",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=0x2a,number2=052",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
g_assert_cmpuint(qemu_opt_get_number(opts, "number2", 0), ==, 42);
opts = qemu_opts_parse(&opts_list_01, "number1=", false, &err);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_01, "number1=eins", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1= \t42",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
opts = qemu_opts_parse(&opts_list_01, "number1=3.14", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=08", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=0 ", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
qemu_opts_reset(&opts_list_01);
}
| {
"code": [
" false, &error_abort);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, UINT64_MAX);",
" false, &error_abort);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, UINT64_MAX);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, 0);"
],
"line_no": [
27,
15,
47,
27,
15,
47,
15,
17
]
} | static void FUNC_0(void)
{
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_parse(&opts_list_01, "number1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_01,
"number1=18446744073709551615,number2=-1",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
g_assert_cmphex(qemu_opt_get_number(opts, "number2", 0), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=18446744073709551616",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=-18446744073709551616",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, UINT64_MAX);
opts = qemu_opts_parse(&opts_list_01, "number1=0x2a,number2=052",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
g_assert_cmpuint(qemu_opt_get_number(opts, "number2", 0), ==, 42);
opts = qemu_opts_parse(&opts_list_01, "number1=", false, &err);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_01, "number1=eins", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1= \t42",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_number(opts, "number1", 1), ==, 42);
opts = qemu_opts_parse(&opts_list_01, "number1=3.14", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=08", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_01, "number1=0 ", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
qemu_opts_reset(&opts_list_01);
}
| [
"static void FUNC_0(void)\n{",
"Error *err = NULL;",
"QemuOpts *opts;",
"opts = qemu_opts_parse(&opts_list_01, \"number1=0\", false, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, 0);",
"opts = qemu_opts_parse(&opts_list_01,\n\"number1=18446744073709551615,number2=-1\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 2);",
"g_assert_cmphex(qemu_opt_get_number(opts, \"number1\", 1), ==, UINT64_MAX);",
"g_assert_cmphex(qemu_opt_get_number(opts, \"number2\", 0), ==, UINT64_MAX);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=18446744073709551616\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, UINT64_MAX);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=-18446744073709551616\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, UINT64_MAX);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=0x2a,number2=052\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 2);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, 42);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number2\", 0), ==, 42);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=\", false, &err);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, 0);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=eins\", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"opts = qemu_opts_parse(&opts_list_01, \"number1= \\t42\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_number(opts, \"number1\", 1), ==, 42);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=3.14\", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=08\", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"opts = qemu_opts_parse(&opts_list_01, \"number1=0 \", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"qemu_opts_reset(&opts_list_01);",
"}"
] | [
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
39,
41
],
[
45
],
[
47
],
[
53,
55
],
[
59
],
[
61
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
99,
101
],
[
103
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
]
] |
23,194 | static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
{
AcpiSdtTable *temp;
GError *error = NULL;
GString *command_line = g_string_new(iasl);
gint fd;
gchar *out, *out_err;
gboolean ret;
int i;
fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
g_assert_no_error(error);
close(fd);
/* build command line */
g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */
temp = &g_array_index(sdts, AcpiSdtTable, i);
g_string_append_printf(command_line, "-e %s ", temp->aml_file);
}
g_string_append_printf(command_line, "-d %s", sdt->aml_file);
/* pass 'out' and 'out_err' in order to be redirected */
g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
g_assert_no_error(error);
ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
&sdt->asl_len, &error);
g_assert(ret);
g_assert_no_error(error);
g_assert(sdt->asl_len);
g_free(out);
g_free(out_err);
g_string_free(command_line, true);
}
| true | qemu | 69d09245d19765fd461cc3d3a7d79686007c4474 | static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
{
AcpiSdtTable *temp;
GError *error = NULL;
GString *command_line = g_string_new(iasl);
gint fd;
gchar *out, *out_err;
gboolean ret;
int i;
fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
g_assert_no_error(error);
close(fd);
g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
for (i = 0; i < 2; ++i) {
temp = &g_array_index(sdts, AcpiSdtTable, i);
g_string_append_printf(command_line, "-e %s ", temp->aml_file);
}
g_string_append_printf(command_line, "-d %s", sdt->aml_file);
g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
g_assert_no_error(error);
ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
&sdt->asl_len, &error);
g_assert(ret);
g_assert_no_error(error);
g_assert(sdt->asl_len);
g_free(out);
g_free(out_err);
g_string_free(command_line, true);
}
| {
"code": [
" temp = &g_array_index(sdts, AcpiSdtTable, i);",
" g_string_append_printf(command_line, \"-e %s \", temp->aml_file);"
],
"line_no": [
35,
37
]
} | static void FUNC_0(GArray *VAR_0, AcpiSdtTable *VAR_1)
{
AcpiSdtTable *temp;
GError *error = NULL;
GString *command_line = g_string_new(iasl);
gint fd;
gchar *out, *out_err;
gboolean ret;
int VAR_2;
fd = g_file_open_tmp("asl-XXXXXX.dsl", &VAR_1->asl_file, &error);
g_assert_no_error(error);
close(fd);
g_string_append_printf(command_line, " -p %s ", VAR_1->asl_file);
for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {
temp = &g_array_index(VAR_0, AcpiSdtTable, VAR_2);
g_string_append_printf(command_line, "-e %s ", temp->aml_file);
}
g_string_append_printf(command_line, "-d %s", VAR_1->aml_file);
g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
g_assert_no_error(error);
ret = g_file_get_contents(VAR_1->asl_file, (gchar **)&VAR_1->asl,
&VAR_1->asl_len, &error);
g_assert(ret);
g_assert_no_error(error);
g_assert(VAR_1->asl_len);
g_free(out);
g_free(out_err);
g_string_free(command_line, true);
}
| [
"static void FUNC_0(GArray *VAR_0, AcpiSdtTable *VAR_1)\n{",
"AcpiSdtTable *temp;",
"GError *error = NULL;",
"GString *command_line = g_string_new(iasl);",
"gint fd;",
"gchar *out, *out_err;",
"gboolean ret;",
"int VAR_2;",
"fd = g_file_open_tmp(\"asl-XXXXXX.dsl\", &VAR_1->asl_file, &error);",
"g_assert_no_error(error);",
"close(fd);",
"g_string_append_printf(command_line, \" -p %s \", VAR_1->asl_file);",
"for (VAR_2 = 0; VAR_2 < 2; ++VAR_2) {",
"temp = &g_array_index(VAR_0, AcpiSdtTable, VAR_2);",
"g_string_append_printf(command_line, \"-e %s \", temp->aml_file);",
"}",
"g_string_append_printf(command_line, \"-d %s\", VAR_1->aml_file);",
"g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);",
"g_assert_no_error(error);",
"ret = g_file_get_contents(VAR_1->asl_file, (gchar **)&VAR_1->asl,\n&VAR_1->asl_len, &error);",
"g_assert(ret);",
"g_assert_no_error(error);",
"g_assert(VAR_1->asl_len);",
"g_free(out);",
"g_free(out_err);",
"g_string_free(command_line, true);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
23,195 | static int timebase_post_load(void *opaque, int version_id)
{
PPCTimebase *tb_remote = opaque;
CPUState *cpu;
PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
int64_t tb_off_adj, tb_off, ns_diff;
int64_t migration_duration_ns, migration_duration_tb, guest_tb, host_ns;
unsigned long freq;
if (!first_ppc_cpu->env.tb_env) {
error_report("No timebase object");
return -1;
}
freq = first_ppc_cpu->env.tb_env->tb_freq;
/*
* Calculate timebase on the destination side of migration.
* The destination timebase must be not less than the source timebase.
* We try to adjust timebase by downtime if host clocks are not
* too much out of sync (1 second for now).
*/
host_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
ns_diff = MAX(0, host_ns - tb_remote->time_of_the_day_ns);
migration_duration_ns = MIN(NANOSECONDS_PER_SECOND, ns_diff);
migration_duration_tb = muldiv64(migration_duration_ns, freq,
NANOSECONDS_PER_SECOND);
guest_tb = tb_remote->guest_timebase + MIN(0, migration_duration_tb);
tb_off_adj = guest_tb - cpu_get_host_ticks();
tb_off = first_ppc_cpu->env.tb_env->tb_offset;
trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
(tb_off_adj - tb_off) / freq);
/* Set new offset to all CPUs */
CPU_FOREACH(cpu) {
PowerPCCPU *pcpu = POWERPC_CPU(cpu);
pcpu->env.tb_env->tb_offset = tb_off_adj;
}
return 0;
}
| true | qemu | a2c5eaf7a9f6172e8dc5cfeb283e086f592cf50a | static int timebase_post_load(void *opaque, int version_id)
{
PPCTimebase *tb_remote = opaque;
CPUState *cpu;
PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
int64_t tb_off_adj, tb_off, ns_diff;
int64_t migration_duration_ns, migration_duration_tb, guest_tb, host_ns;
unsigned long freq;
if (!first_ppc_cpu->env.tb_env) {
error_report("No timebase object");
return -1;
}
freq = first_ppc_cpu->env.tb_env->tb_freq;
host_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
ns_diff = MAX(0, host_ns - tb_remote->time_of_the_day_ns);
migration_duration_ns = MIN(NANOSECONDS_PER_SECOND, ns_diff);
migration_duration_tb = muldiv64(migration_duration_ns, freq,
NANOSECONDS_PER_SECOND);
guest_tb = tb_remote->guest_timebase + MIN(0, migration_duration_tb);
tb_off_adj = guest_tb - cpu_get_host_ticks();
tb_off = first_ppc_cpu->env.tb_env->tb_offset;
trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
(tb_off_adj - tb_off) / freq);
CPU_FOREACH(cpu) {
PowerPCCPU *pcpu = POWERPC_CPU(cpu);
pcpu->env.tb_env->tb_offset = tb_off_adj;
}
return 0;
}
| {
"code": [
" migration_duration_tb = muldiv64(migration_duration_ns, freq,"
],
"line_no": [
49
]
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
PPCTimebase *tb_remote = VAR_0;
CPUState *cpu;
PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
int64_t tb_off_adj, tb_off, ns_diff;
int64_t migration_duration_ns, migration_duration_tb, guest_tb, host_ns;
unsigned long VAR_2;
if (!first_ppc_cpu->env.tb_env) {
error_report("No timebase object");
return -1;
}
VAR_2 = first_ppc_cpu->env.tb_env->tb_freq;
host_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);
ns_diff = MAX(0, host_ns - tb_remote->time_of_the_day_ns);
migration_duration_ns = MIN(NANOSECONDS_PER_SECOND, ns_diff);
migration_duration_tb = muldiv64(migration_duration_ns, VAR_2,
NANOSECONDS_PER_SECOND);
guest_tb = tb_remote->guest_timebase + MIN(0, migration_duration_tb);
tb_off_adj = guest_tb - cpu_get_host_ticks();
tb_off = first_ppc_cpu->env.tb_env->tb_offset;
trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,
(tb_off_adj - tb_off) / VAR_2);
CPU_FOREACH(cpu) {
PowerPCCPU *pcpu = POWERPC_CPU(cpu);
pcpu->env.tb_env->tb_offset = tb_off_adj;
}
return 0;
}
| [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"PPCTimebase *tb_remote = VAR_0;",
"CPUState *cpu;",
"PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);",
"int64_t tb_off_adj, tb_off, ns_diff;",
"int64_t migration_duration_ns, migration_duration_tb, guest_tb, host_ns;",
"unsigned long VAR_2;",
"if (!first_ppc_cpu->env.tb_env) {",
"error_report(\"No timebase object\");",
"return -1;",
"}",
"VAR_2 = first_ppc_cpu->env.tb_env->tb_freq;",
"host_ns = qemu_clock_get_ns(QEMU_CLOCK_HOST);",
"ns_diff = MAX(0, host_ns - tb_remote->time_of_the_day_ns);",
"migration_duration_ns = MIN(NANOSECONDS_PER_SECOND, ns_diff);",
"migration_duration_tb = muldiv64(migration_duration_ns, VAR_2,\nNANOSECONDS_PER_SECOND);",
"guest_tb = tb_remote->guest_timebase + MIN(0, migration_duration_tb);",
"tb_off_adj = guest_tb - cpu_get_host_ticks();",
"tb_off = first_ppc_cpu->env.tb_env->tb_offset;",
"trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off,\n(tb_off_adj - tb_off) / VAR_2);",
"CPU_FOREACH(cpu) {",
"PowerPCCPU *pcpu = POWERPC_CPU(cpu);",
"pcpu->env.tb_env->tb_offset = tb_off_adj;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
57
],
[
61
],
[
63,
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
]
] |
23,196 | void *av_malloc(size_t size)
{
void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
/* let's disallow possible ambiguous cases */
if(size > (INT_MAX-32) )
return NULL;
#if CONFIG_MEMALIGN_HACK
ptr = malloc(size+32);
if(!ptr)
return ptr;
diff= ((-(long)ptr - 1)&31) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
if (posix_memalign(&ptr,32,size))
ptr = NULL;
#elif HAVE_MEMALIGN
ptr = memalign(32,size);
/* Why 64?
Indeed, we should align it:
on 4 for 386
on 16 for 486
on 32 for 586, PPro - K6-III
on 64 for K7 (maybe for P3 too).
Because L1 and L2 caches are aligned on those values.
But I don't want to code such logic here!
*/
/* Why 32?
For AVX ASM. SSE / NEON needs only 16.
Why not larger? Because I did not see a difference in benchmarks ...
*/
/* benchmarks with P3
memalign(64)+1 3071,3051,3032
memalign(64)+2 3051,3032,3041
memalign(64)+4 2911,2896,2915
memalign(64)+8 2545,2554,2550
memalign(64)+16 2543,2572,2563
memalign(64)+32 2546,2545,2571
memalign(64)+64 2570,2533,2558
BTW, malloc seems to do 8-byte alignment by default here.
*/
#else
ptr = malloc(size);
#endif
return ptr;
}
| true | FFmpeg | 14f063d294a18a31928d2167a66b1087910e14c8 | void *av_malloc(size_t size)
{
void *ptr = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
if(size > (INT_MAX-32) )
return NULL;
#if CONFIG_MEMALIGN_HACK
ptr = malloc(size+32);
if(!ptr)
return ptr;
diff= ((-(long)ptr - 1)&31) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
if (posix_memalign(&ptr,32,size))
ptr = NULL;
#elif HAVE_MEMALIGN
ptr = memalign(32,size);
#else
ptr = malloc(size);
#endif
return ptr;
}
| {
"code": [
" if(size > (INT_MAX-32) )"
],
"line_no": [
17
]
} | void *FUNC_0(size_t VAR_0)
{
void *VAR_1 = NULL;
#if CONFIG_MEMALIGN_HACK
long diff;
#endif
if(VAR_0 > (INT_MAX-32) )
return NULL;
#if CONFIG_MEMALIGN_HACK
VAR_1 = malloc(VAR_0+32);
if(!VAR_1)
return VAR_1;
diff= ((-(long)VAR_1 - 1)&31) + 1;
VAR_1 = (char*)VAR_1 + diff;
((char*)VAR_1)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
if (posix_memalign(&VAR_1,32,VAR_0))
VAR_1 = NULL;
#elif HAVE_MEMALIGN
VAR_1 = memalign(32,VAR_0);
#else
VAR_1 = malloc(VAR_0);
#endif
return VAR_1;
}
| [
"void *FUNC_0(size_t VAR_0)\n{",
"void *VAR_1 = NULL;",
"#if CONFIG_MEMALIGN_HACK\nlong diff;",
"#endif\nif(VAR_0 > (INT_MAX-32) )\nreturn NULL;",
"#if CONFIG_MEMALIGN_HACK\nVAR_1 = malloc(VAR_0+32);",
"if(!VAR_1)\nreturn VAR_1;",
"diff= ((-(long)VAR_1 - 1)&31) + 1;",
"VAR_1 = (char*)VAR_1 + diff;",
"((char*)VAR_1)[-1]= diff;",
"#elif HAVE_POSIX_MEMALIGN\nif (posix_memalign(&VAR_1,32,VAR_0))\nVAR_1 = NULL;",
"#elif HAVE_MEMALIGN\nVAR_1 = memalign(32,VAR_0);",
"#else\nVAR_1 = malloc(VAR_0);",
"#endif\nreturn VAR_1;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
17,
19
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41
],
[
43,
45
],
[
95,
97
],
[
99,
101
],
[
103
]
] |
23,197 | static void decor_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] += (int)(src[i] * (SUINT)coeff + (1 << 2)) >> 3;
}
| true | FFmpeg | 949d2176ef0a37c6ecbb65be0f1199536a2d9278 | static void decor_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
{
int i;
for (i = 0; i < len; i++)
dst[i] += (int)(src[i] * (SUINT)coeff + (1 << 2)) >> 3;
}
| {
"code": [
" dst[i] += (int)(src[i] * (SUINT)coeff + (1 << 2)) >> 3;"
],
"line_no": [
11
]
} | static void FUNC_0(int32_t *VAR_0, const int32_t *VAR_1, int VAR_2, ptrdiff_t VAR_3)
{
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)
VAR_0[VAR_4] += (int)(VAR_1[VAR_4] * (SUINT)VAR_2 + (1 << 2)) >> 3;
}
| [
"static void FUNC_0(int32_t *VAR_0, const int32_t *VAR_1, int VAR_2, ptrdiff_t VAR_3)\n{",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++)",
"VAR_0[VAR_4] += (int)(VAR_1[VAR_4] * (SUINT)VAR_2 + (1 << 2)) >> 3;",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
23,198 | static void msix_mmio_writel(void *opaque, target_phys_addr_t addr,
uint32_t val)
{
PCIDevice *dev = opaque;
unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);
int vector = offset / MSIX_ENTRY_SIZE;
memcpy(dev->msix_table_page + offset, &val, 4);
if (!msix_is_masked(dev, vector) && msix_is_pending(dev, vector)) {
msix_clr_pending(dev, vector);
msix_notify(dev, vector);
}
}
| true | qemu | 76f5159d7fc4cdea9574dfbb54307735b280bc66 | static void msix_mmio_writel(void *opaque, target_phys_addr_t addr,
uint32_t val)
{
PCIDevice *dev = opaque;
unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);
int vector = offset / MSIX_ENTRY_SIZE;
memcpy(dev->msix_table_page + offset, &val, 4);
if (!msix_is_masked(dev, vector) && msix_is_pending(dev, vector)) {
msix_clr_pending(dev, vector);
msix_notify(dev, vector);
}
}
| {
"code": [
" unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);",
" unsigned int offset = addr & (MSIX_PAGE_SIZE - 1);",
" memcpy(dev->msix_table_page + offset, &val, 4);"
],
"line_no": [
9,
9,
13
]
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{
PCIDevice *dev = VAR_0;
unsigned int VAR_3 = VAR_1 & (MSIX_PAGE_SIZE - 1);
int VAR_4 = VAR_3 / MSIX_ENTRY_SIZE;
memcpy(dev->msix_table_page + VAR_3, &VAR_2, 4);
if (!msix_is_masked(dev, VAR_4) && msix_is_pending(dev, VAR_4)) {
msix_clr_pending(dev, VAR_4);
msix_notify(dev, VAR_4);
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{",
"PCIDevice *dev = VAR_0;",
"unsigned int VAR_3 = VAR_1 & (MSIX_PAGE_SIZE - 1);",
"int VAR_4 = VAR_3 / MSIX_ENTRY_SIZE;",
"memcpy(dev->msix_table_page + VAR_3, &VAR_2, 4);",
"if (!msix_is_masked(dev, VAR_4) && msix_is_pending(dev, VAR_4)) {",
"msix_clr_pending(dev, VAR_4);",
"msix_notify(dev, VAR_4);",
"}",
"}"
] | [
0,
0,
1,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
23,199 | QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
{
QEMUFile *f;
f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->ops = ops;
return f;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
{
QEMUFile *f;
f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->ops = ops;
return f;
}
| {
"code": [],
"line_no": []
} | QEMUFile *FUNC_0(void *opaque, const QEMUFileOps *ops)
{
QEMUFile *f;
f = g_malloc0(sizeof(QEMUFile));
f->opaque = opaque;
f->ops = ops;
return f;
}
| [
"QEMUFile *FUNC_0(void *opaque, const QEMUFileOps *ops)\n{",
"QEMUFile *f;",
"f = g_malloc0(sizeof(QEMUFile));",
"f->opaque = opaque;",
"f->ops = ops;",
"return f;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
23,200 | void tcg_exec_init(unsigned long tb_size)
{
cpu_gen_init();
code_gen_alloc(tb_size);
page_init();
#if defined(CONFIG_SOFTMMU)
/* There's no guest base to take into account, so go ahead and
initialize the prologue now. */
tcg_prologue_init(&tcg_ctx);
#endif
}
| true | qemu | f293709c6af7a65a9bcec09cdba7a60183657a3e | void tcg_exec_init(unsigned long tb_size)
{
cpu_gen_init();
code_gen_alloc(tb_size);
page_init();
#if defined(CONFIG_SOFTMMU)
tcg_prologue_init(&tcg_ctx);
#endif
}
| {
"code": [
"#endif",
"#endif",
"#endif",
" code_gen_alloc(tb_size);"
],
"line_no": [
19,
19,
19,
7
]
} | void FUNC_0(unsigned long VAR_0)
{
cpu_gen_init();
code_gen_alloc(VAR_0);
page_init();
#if defined(CONFIG_SOFTMMU)
tcg_prologue_init(&tcg_ctx);
#endif
}
| [
"void FUNC_0(unsigned long VAR_0)\n{",
"cpu_gen_init();",
"code_gen_alloc(VAR_0);",
"page_init();",
"#if defined(CONFIG_SOFTMMU)\ntcg_prologue_init(&tcg_ctx);",
"#endif\n}"
] | [
0,
0,
1,
0,
0,
1
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
17
],
[
19,
21
]
] |
23,201 | static void bufp_free(USBRedirDevice *dev, struct buf_packet *bufp,
uint8_t ep)
{
QTAILQ_REMOVE(&dev->endpoint[EP2I(ep)].bufpq, bufp, next);
dev->endpoint[EP2I(ep)].bufpq_size--;
free(bufp->data);
g_free(bufp);
}
| true | qemu | b2d1fe67d09d2b6c7da647fbcea6ca0148c206d3 | static void bufp_free(USBRedirDevice *dev, struct buf_packet *bufp,
uint8_t ep)
{
QTAILQ_REMOVE(&dev->endpoint[EP2I(ep)].bufpq, bufp, next);
dev->endpoint[EP2I(ep)].bufpq_size--;
free(bufp->data);
g_free(bufp);
}
| {
"code": [
" free(bufp->data);"
],
"line_no": [
11
]
} | static void FUNC_0(USBRedirDevice *VAR_0, struct buf_packet *VAR_1,
uint8_t VAR_2)
{
QTAILQ_REMOVE(&VAR_0->endpoint[EP2I(VAR_2)].bufpq, VAR_1, next);
VAR_0->endpoint[EP2I(VAR_2)].bufpq_size--;
free(VAR_1->data);
g_free(VAR_1);
}
| [
"static void FUNC_0(USBRedirDevice *VAR_0, struct buf_packet *VAR_1,\nuint8_t VAR_2)\n{",
"QTAILQ_REMOVE(&VAR_0->endpoint[EP2I(VAR_2)].bufpq, VAR_1, next);",
"VAR_0->endpoint[EP2I(VAR_2)].bufpq_size--;",
"free(VAR_1->data);",
"g_free(VAR_1);",
"}"
] | [
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
23,202 | static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
int ret = 0;
struct usb_msd_cbw cbw;
uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (len != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
memcpy(&cbw, data, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
s->tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, cbw.cmd);
/* ??? Should check that USB and SCSI data transfer
directions match. */
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
ret = len;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %d/%d\n", len, s->data_len);
if (len > s->data_len)
goto fail;
s->usb_buf = data;
s->usb_len = len;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break;
default:
DPRINTF("Unexpected write (len %d)\n", len);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || len < 13)
goto fail;
/* Waiting for SCSI write to complete. */
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %d\n",
s->result, s->tag, len);
if (len < 13)
goto fail;
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %d/%d, scsi_len %d\n", len, s->data_len, s->scsi_len);
if (len > s->data_len)
len = s->data_len;
s->usb_buf = data;
s->usb_len = len;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
memset(s->usb_buf, 0, s->usb_len);
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break;
default:
DPRINTF("Unexpected read (len %d)\n", len);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
{
MSDState *s = (MSDState *)dev;
int ret = 0;
struct usb_msd_cbw cbw;
uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
switch (p->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (len != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
memcpy(&cbw, data, 31);
if (le32_to_cpu(cbw.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(cbw.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", cbw.lun);
if (cbw.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
goto fail;
}
s->tag = le32_to_cpu(cbw.tag);
s->data_len = le32_to_cpu(cbw.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (cbw.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, cbw.cmd);
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
ret = len;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %d/%d\n", len, s->data_len);
if (len > s->data_len)
goto fail;
s->usb_buf = data;
s->usb_len = len;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break;
default:
DPRINTF("Unexpected write (len %d)\n", len);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || len < 13)
goto fail;
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %d\n",
s->result, s->tag, len);
if (len < 13)
goto fail;
usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %d/%d, scsi_len %d\n", len, s->data_len, s->scsi_len);
if (len > s->data_len)
len = s->data_len;
s->usb_buf = data;
s->usb_len = len;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
memset(s->usb_buf, 0, s->usb_len);
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break;
default:
DPRINTF("Unexpected read (len %d)\n", len);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [
" uint8_t *data = p->data;",
" int len = p->len;",
" uint8_t *data = p->data;",
" int len = p->len;",
" uint8_t *data = p->data;",
" int len = p->len;"
],
"line_no": [
13,
15,
13,
15,
13,
15
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
MSDState *s = (MSDState *)VAR_0;
int VAR_2 = 0;
struct usb_msd_cbw VAR_3;
uint8_t devep = VAR_1->devep;
uint8_t *data = VAR_1->data;
int VAR_4 = VAR_1->VAR_4;
switch (VAR_1->pid) {
case USB_TOKEN_OUT:
if (devep != 2)
goto fail;
switch (s->mode) {
case USB_MSDM_CBW:
if (VAR_4 != 31) {
fprintf(stderr, "usb-msd: Bad CBW size");
goto fail;
}
memcpy(&VAR_3, data, 31);
if (le32_to_cpu(VAR_3.sig) != 0x43425355) {
fprintf(stderr, "usb-msd: Bad signature %08x\n",
le32_to_cpu(VAR_3.sig));
goto fail;
}
DPRINTF("Command on LUN %d\n", VAR_3.lun);
if (VAR_3.lun != 0) {
fprintf(stderr, "usb-msd: Bad LUN %d\n", VAR_3.lun);
goto fail;
}
s->tag = le32_to_cpu(VAR_3.tag);
s->data_len = le32_to_cpu(VAR_3.data_len);
if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
} else if (VAR_3.flags & 0x80) {
s->mode = USB_MSDM_DATAIN;
} else {
s->mode = USB_MSDM_DATAOUT;
}
DPRINTF("Command tag 0x%x flags %08x VAR_4 %d data %d\n",
s->tag, VAR_3.flags, VAR_3.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
scsi_req_enqueue(s->req, VAR_3.cmd);
if (s->mode != USB_MSDM_CSW && s->residue == 0) {
scsi_req_continue(s->req);
}
VAR_2 = VAR_4;
break;
case USB_MSDM_DATAOUT:
DPRINTF("Data out %d/%d\n", VAR_4, s->data_len);
if (VAR_4 > s->data_len)
goto fail;
s->usb_buf = data;
s->usb_len = VAR_4;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %VAR_1\n", VAR_1);
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
} else {
VAR_2 = VAR_4;
}
break;
default:
DPRINTF("Unexpected write (VAR_4 %d)\n", VAR_4);
goto fail;
}
break;
case USB_TOKEN_IN:
if (devep != 1)
goto fail;
switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || VAR_4 < 13)
goto fail;
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
break;
case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, VAR_4 %d\n",
s->result, s->tag, VAR_4);
if (VAR_4 < 13)
goto fail;
usb_msd_send_status(s, VAR_1);
s->mode = USB_MSDM_CBW;
VAR_2 = 13;
break;
case USB_MSDM_DATAIN:
DPRINTF("Data in %d/%d, scsi_len %d\n", VAR_4, s->data_len, s->scsi_len);
if (VAR_4 > s->data_len)
VAR_4 = s->data_len;
s->usb_buf = data;
s->usb_len = VAR_4;
if (s->scsi_len) {
usb_msd_copy_data(s);
}
if (s->residue && s->usb_len) {
s->data_len -= s->usb_len;
memset(s->usb_buf, 0, s->usb_len);
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %VAR_1\n", VAR_1);
s->packet = VAR_1;
VAR_2 = USB_RET_ASYNC;
} else {
VAR_2 = VAR_4;
}
break;
default:
DPRINTF("Unexpected read (VAR_4 %d)\n", VAR_4);
goto fail;
}
break;
default:
DPRINTF("Bad token\n");
fail:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"MSDState *s = (MSDState *)VAR_0;",
"int VAR_2 = 0;",
"struct usb_msd_cbw VAR_3;",
"uint8_t devep = VAR_1->devep;",
"uint8_t *data = VAR_1->data;",
"int VAR_4 = VAR_1->VAR_4;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_OUT:\nif (devep != 2)\ngoto fail;",
"switch (s->mode) {",
"case USB_MSDM_CBW:\nif (VAR_4 != 31) {",
"fprintf(stderr, \"usb-msd: Bad CBW size\");",
"goto fail;",
"}",
"memcpy(&VAR_3, data, 31);",
"if (le32_to_cpu(VAR_3.sig) != 0x43425355) {",
"fprintf(stderr, \"usb-msd: Bad signature %08x\\n\",\nle32_to_cpu(VAR_3.sig));",
"goto fail;",
"}",
"DPRINTF(\"Command on LUN %d\\n\", VAR_3.lun);",
"if (VAR_3.lun != 0) {",
"fprintf(stderr, \"usb-msd: Bad LUN %d\\n\", VAR_3.lun);",
"goto fail;",
"}",
"s->tag = le32_to_cpu(VAR_3.tag);",
"s->data_len = le32_to_cpu(VAR_3.data_len);",
"if (s->data_len == 0) {",
"s->mode = USB_MSDM_CSW;",
"} else if (VAR_3.flags & 0x80) {",
"s->mode = USB_MSDM_DATAIN;",
"} else {",
"s->mode = USB_MSDM_DATAOUT;",
"}",
"DPRINTF(\"Command tag 0x%x flags %08x VAR_4 %d data %d\\n\",\ns->tag, VAR_3.flags, VAR_3.cmd_len, s->data_len);",
"s->residue = 0;",
"s->scsi_len = 0;",
"s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);",
"scsi_req_enqueue(s->req, VAR_3.cmd);",
"if (s->mode != USB_MSDM_CSW && s->residue == 0) {",
"scsi_req_continue(s->req);",
"}",
"VAR_2 = VAR_4;",
"break;",
"case USB_MSDM_DATAOUT:\nDPRINTF(\"Data out %d/%d\\n\", VAR_4, s->data_len);",
"if (VAR_4 > s->data_len)\ngoto fail;",
"s->usb_buf = data;",
"s->usb_len = VAR_4;",
"if (s->scsi_len) {",
"usb_msd_copy_data(s);",
"}",
"if (s->residue && s->usb_len) {",
"s->data_len -= s->usb_len;",
"if (s->data_len == 0)\ns->mode = USB_MSDM_CSW;",
"s->usb_len = 0;",
"}",
"if (s->usb_len) {",
"DPRINTF(\"Deferring packet %VAR_1\\n\", VAR_1);",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"} else {",
"VAR_2 = VAR_4;",
"}",
"break;",
"default:\nDPRINTF(\"Unexpected write (VAR_4 %d)\\n\", VAR_4);",
"goto fail;",
"}",
"break;",
"case USB_TOKEN_IN:\nif (devep != 1)\ngoto fail;",
"switch (s->mode) {",
"case USB_MSDM_DATAOUT:\nif (s->data_len != 0 || VAR_4 < 13)\ngoto fail;",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"break;",
"case USB_MSDM_CSW:\nDPRINTF(\"Command status %d tag 0x%x, VAR_4 %d\\n\",\ns->result, s->tag, VAR_4);",
"if (VAR_4 < 13)\ngoto fail;",
"usb_msd_send_status(s, VAR_1);",
"s->mode = USB_MSDM_CBW;",
"VAR_2 = 13;",
"break;",
"case USB_MSDM_DATAIN:\nDPRINTF(\"Data in %d/%d, scsi_len %d\\n\", VAR_4, s->data_len, s->scsi_len);",
"if (VAR_4 > s->data_len)\nVAR_4 = s->data_len;",
"s->usb_buf = data;",
"s->usb_len = VAR_4;",
"if (s->scsi_len) {",
"usb_msd_copy_data(s);",
"}",
"if (s->residue && s->usb_len) {",
"s->data_len -= s->usb_len;",
"memset(s->usb_buf, 0, s->usb_len);",
"if (s->data_len == 0)\ns->mode = USB_MSDM_CSW;",
"s->usb_len = 0;",
"}",
"if (s->usb_len) {",
"DPRINTF(\"Deferring packet %VAR_1\\n\", VAR_1);",
"s->packet = VAR_1;",
"VAR_2 = USB_RET_ASYNC;",
"} else {",
"VAR_2 = VAR_4;",
"}",
"break;",
"default:\nDPRINTF(\"Unexpected read (VAR_4 %d)\\n\", VAR_4);",
"goto fail;",
"}",
"break;",
"default:\nDPRINTF(\"Bad token\\n\");",
"fail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
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
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
171,
173,
175
],
[
179
],
[
181,
183,
185
],
[
189
],
[
191
],
[
193
],
[
197,
199,
201
],
[
203,
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219,
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
281,
283
],
[
285,
287
],
[
289
],
[
291
],
[
295
],
[
297
]
] |
23,203 | static Visitor *validate_test_init_internal(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
Visitor *v;
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv);
v = qmp_input_get_visitor(data->qiv);
g_assert(v);
return v;
} | true | qemu | b18f1141d0afa00de11a8e079f4f5305c9e36893 | static Visitor *validate_test_init_internal(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
Visitor *v;
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv);
v = qmp_input_get_visitor(data->qiv);
g_assert(v);
return v;
} | {
"code": [],
"line_no": []
} | static Visitor *FUNC_0(TestInputVisitorData *data,
const char *json_string,
va_list *ap)
{
Visitor *v;
data->obj = qobject_from_jsonv(json_string, ap);
g_assert(data->obj);
data->qiv = qmp_input_visitor_new_strict(data->obj);
g_assert(data->qiv);
v = qmp_input_get_visitor(data->qiv);
g_assert(v);
return v;
} | [
"static Visitor *FUNC_0(TestInputVisitorData *data,\nconst char *json_string,\nva_list *ap)\n{",
"Visitor *v;",
"data->obj = qobject_from_jsonv(json_string, ap);",
"g_assert(data->obj);",
"data->qiv = qmp_input_visitor_new_strict(data->obj);",
"g_assert(data->qiv);",
"v = qmp_input_get_visitor(data->qiv);",
"g_assert(v);",
"return v;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
]
] |
23,205 | static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1 //is faster only if multiplies are reasonable fast (FIXME figure out on which cpus this is faster, on Athlon its slightly faster)
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
mm_end = end - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(s)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register int rgb = *(uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
}
}
| {
"code": [
"static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)"
],
"line_no": [
1
]
} | static inline void FUNC_0(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
mm_end = VAR_1 - 15;
#if 1
asm volatile(
"movq %3, %%mm5 \n\t"
"movq %4, %%mm6 \n\t"
"movq %5, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 32(%1) \n\t"
"movd (%1), %%mm0 \n\t"
"movd 4(%1), %%mm3 \n\t"
"punpckldq 8(%1), %%mm0 \n\t"
"punpckldq 12(%1), %%mm3 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm3, %%mm4 \n\t"
"pand %%mm6, %%mm0 \n\t"
"pand %%mm6, %%mm3 \n\t"
"pmaddwd %%mm7, %%mm0 \n\t"
"pmaddwd %%mm7, %%mm3 \n\t"
"pand %%mm5, %%mm1 \n\t"
"pand %%mm5, %%mm4 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm4, %%mm3 \n\t"
"psrld $5, %%mm0 \n\t"
"pslld $11, %%mm3 \n\t"
"por %%mm3, %%mm0 \n\t"
MOVNTQ" %%mm0, (%0) \n\t"
"add $16, %1 \n\t"
"add $8, %0 \n\t"
"cmp %2, %1 \n\t"
" jb 1b \n\t"
: "+r" (d), "+r"(VAR_0)
: "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
);
#else
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 4%1, %%mm3\n\t"
"punpckldq 8%1, %%mm0\n\t"
"punpckldq 12%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psrlq $3, %%mm0\n\t"
"psrlq $3, %%mm3\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm5\n\t"
"pand %%mm7, %%mm2\n\t"
"pand %%mm7, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_16mask):"memory");
d += 4;
VAR_0 += 16;
}
#endif
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;
*d++ = ((VAR_2&0xFF)>>3) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>8);
}
}
| [
"static inline void FUNC_0(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\nmm_end = VAR_1 - 15;",
"#if 1\nasm volatile(\n\"movq %3, %%mm5\t\t\t\\n\\t\"\n\"movq %4, %%mm6\t\t\t\\n\\t\"\n\"movq %5, %%mm7\t\t\t\\n\\t\"\n\".balign 16\t\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 32(%1)\t\t\\n\\t\"\n\"movd\t(%1), %%mm0\t\t\\n\\t\"\n\"movd\t4(%1), %%mm3\t\t\\n\\t\"\n\"punpckldq 8(%1), %%mm0\t\t\\n\\t\"\n\"punpckldq 12(%1), %%mm3\t\\n\\t\"\n\"movq %%mm0, %%mm1\t\t\\n\\t\"\n\"movq %%mm3, %%mm4\t\t\\n\\t\"\n\"pand %%mm6, %%mm0\t\t\\n\\t\"\n\"pand %%mm6, %%mm3\t\t\\n\\t\"\n\"pmaddwd %%mm7, %%mm0\t\t\\n\\t\"\n\"pmaddwd %%mm7, %%mm3\t\t\\n\\t\"\n\"pand %%mm5, %%mm1\t\t\\n\\t\"\n\"pand %%mm5, %%mm4\t\t\\n\\t\"\n\"por %%mm1, %%mm0\t\t\\n\\t\"\n\"por %%mm4, %%mm3\t\t\\n\\t\"\n\"psrld $5, %%mm0\t\t\\n\\t\"\n\"pslld $11, %%mm3\t\t\\n\\t\"\n\"por %%mm3, %%mm0\t\t\\n\\t\"\nMOVNTQ\"\t%%mm0, (%0)\t\t\\n\\t\"\n\"add $16, %1\t\t\t\\n\\t\"\n\"add $8, %0\t\t\t\\n\\t\"\n\"cmp %2, %1\t\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n: \"+r\" (d), \"+r\"(VAR_0)\n: \"r\" (mm_end), \"m\" (mask3216g), \"m\" (mask3216br), \"m\" (mul3216)\n);",
"#else\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t4%1, %%mm3\\n\\t\"\n\"punpckldq 8%1, %%mm0\\n\\t\"\n\"punpckldq 12%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psrlq\t$3, %%mm0\\n\\t\"\n\"psrlq\t$3, %%mm3\\n\\t\"\n\"pand\t%2, %%mm0\\n\\t\"\n\"pand\t%2, %%mm3\\n\\t\"\n\"psrlq\t$5, %%mm1\\n\\t\"\n\"psrlq\t$5, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$8, %%mm2\\n\\t\"\n\"psrlq\t$8, %%mm5\\n\\t\"\n\"pand\t%%mm7, %%mm2\\n\\t\"\n\"pand\t%%mm7, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_16mask):\"memory\");",
"d += 4;",
"VAR_0 += 16;",
"}",
"#endif\n__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"register int VAR_2 = *(uint32_t*)VAR_0; VAR_0 += 4;",
"*d++ = ((VAR_2&0xFF)>>3) + ((VAR_2&0xFC00)>>5) + ((VAR_2&0xF80000)>>8);",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87
],
[
89,
91
],
[
93,
95,
97,
99
],
[
101,
103
],
[
105,
107,
109,
111,
113,
115,
117,
119,
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
]
] |
23,207 | static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
MachineState *machine = MACHINE(OBJECT(hotplug_dev));
MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
Error *local_err = NULL;
CPUCore *cc = CPU_CORE(dev);
char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
const char *type = object_get_typename(OBJECT(dev));
CPUArchId *core_slot;
int index;
if (dev->hotplugged && !mc->has_hotpluggable_cpus) {
error_setg(&local_err, "CPU hotplug not supported for this machine");
goto out;
}
if (strcmp(base_core_type, type)) {
error_setg(&local_err, "CPU core type should be %s", base_core_type);
goto out;
}
if (cc->core_id % smp_threads) {
error_setg(&local_err, "invalid core id %d", cc->core_id);
goto out;
}
/*
* In general we should have homogeneous threads-per-core, but old
* (pre hotplug support) machine types allow the last core to have
* reduced threads as a compatibility hack for when we allowed
* total vcpus not a multiple of threads-per-core.
*/
if (mc->has_hotpluggable_cpus && (cc->nr_threads != smp_threads)) {
error_setg(errp, "invalid nr-threads %d, must be %d",
cc->nr_threads, smp_threads);
return;
}
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
if (!core_slot) {
error_setg(&local_err, "core id %d out of range", cc->core_id);
goto out;
}
if (core_slot->cpu) {
error_setg(&local_err, "core %d already populated", cc->core_id);
goto out;
}
numa_cpu_pre_plug(core_slot, dev, &local_err);
out:
g_free(base_core_type);
error_propagate(errp, local_err);
}
| true | qemu | df8658de43db242ea82183d75cc957c2b0fa013a | static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
MachineState *machine = MACHINE(OBJECT(hotplug_dev));
MachineClass *mc = MACHINE_GET_CLASS(hotplug_dev);
Error *local_err = NULL;
CPUCore *cc = CPU_CORE(dev);
char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model);
const char *type = object_get_typename(OBJECT(dev));
CPUArchId *core_slot;
int index;
if (dev->hotplugged && !mc->has_hotpluggable_cpus) {
error_setg(&local_err, "CPU hotplug not supported for this machine");
goto out;
}
if (strcmp(base_core_type, type)) {
error_setg(&local_err, "CPU core type should be %s", base_core_type);
goto out;
}
if (cc->core_id % smp_threads) {
error_setg(&local_err, "invalid core id %d", cc->core_id);
goto out;
}
if (mc->has_hotpluggable_cpus && (cc->nr_threads != smp_threads)) {
error_setg(errp, "invalid nr-threads %d, must be %d",
cc->nr_threads, smp_threads);
return;
}
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
if (!core_slot) {
error_setg(&local_err, "core id %d out of range", cc->core_id);
goto out;
}
if (core_slot->cpu) {
error_setg(&local_err, "core %d already populated", cc->core_id);
goto out;
}
numa_cpu_pre_plug(core_slot, dev, &local_err);
out:
g_free(base_core_type);
error_propagate(errp, local_err);
}
| {
"code": [
" error_setg(errp, \"invalid nr-threads %d, must be %d\","
],
"line_no": [
69
]
} | static void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,
Error **VAR_2)
{
MachineState *machine = MACHINE(OBJECT(VAR_0));
MachineClass *mc = MACHINE_GET_CLASS(VAR_0);
Error *local_err = NULL;
CPUCore *cc = CPU_CORE(VAR_1);
char *VAR_3 = spapr_get_cpu_core_type(machine->cpu_model);
const char *VAR_4 = object_get_typename(OBJECT(VAR_1));
CPUArchId *core_slot;
int VAR_5;
if (VAR_1->hotplugged && !mc->has_hotpluggable_cpus) {
error_setg(&local_err, "CPU hotplug not supported for this machine");
goto out;
}
if (strcmp(VAR_3, VAR_4)) {
error_setg(&local_err, "CPU core VAR_4 should be %s", VAR_3);
goto out;
}
if (cc->core_id % smp_threads) {
error_setg(&local_err, "invalid core id %d", cc->core_id);
goto out;
}
if (mc->has_hotpluggable_cpus && (cc->nr_threads != smp_threads)) {
error_setg(VAR_2, "invalid nr-threads %d, must be %d",
cc->nr_threads, smp_threads);
return;
}
core_slot = spapr_find_cpu_slot(MACHINE(VAR_0), cc->core_id, &VAR_5);
if (!core_slot) {
error_setg(&local_err, "core id %d out of range", cc->core_id);
goto out;
}
if (core_slot->cpu) {
error_setg(&local_err, "core %d already populated", cc->core_id);
goto out;
}
numa_cpu_pre_plug(core_slot, VAR_1, &local_err);
out:
g_free(VAR_3);
error_propagate(VAR_2, local_err);
}
| [
"static void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,\nError **VAR_2)\n{",
"MachineState *machine = MACHINE(OBJECT(VAR_0));",
"MachineClass *mc = MACHINE_GET_CLASS(VAR_0);",
"Error *local_err = NULL;",
"CPUCore *cc = CPU_CORE(VAR_1);",
"char *VAR_3 = spapr_get_cpu_core_type(machine->cpu_model);",
"const char *VAR_4 = object_get_typename(OBJECT(VAR_1));",
"CPUArchId *core_slot;",
"int VAR_5;",
"if (VAR_1->hotplugged && !mc->has_hotpluggable_cpus) {",
"error_setg(&local_err, \"CPU hotplug not supported for this machine\");",
"goto out;",
"}",
"if (strcmp(VAR_3, VAR_4)) {",
"error_setg(&local_err, \"CPU core VAR_4 should be %s\", VAR_3);",
"goto out;",
"}",
"if (cc->core_id % smp_threads) {",
"error_setg(&local_err, \"invalid core id %d\", cc->core_id);",
"goto out;",
"}",
"if (mc->has_hotpluggable_cpus && (cc->nr_threads != smp_threads)) {",
"error_setg(VAR_2, \"invalid nr-threads %d, must be %d\",\ncc->nr_threads, smp_threads);",
"return;",
"}",
"core_slot = spapr_find_cpu_slot(MACHINE(VAR_0), cc->core_id, &VAR_5);",
"if (!core_slot) {",
"error_setg(&local_err, \"core id %d out of range\", cc->core_id);",
"goto out;",
"}",
"if (core_slot->cpu) {",
"error_setg(&local_err, \"core %d already populated\", cc->core_id);",
"goto out;",
"}",
"numa_cpu_pre_plug(core_slot, VAR_1, &local_err);",
"out:\ng_free(VAR_3);",
"error_propagate(VAR_2, local_err);",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105,
107
],
[
109
],
[
111
]
] |
23,208 | static av_cold int pulse_write_header(AVFormatContext *h)
{
PulseData *s = h->priv_data;
AVStream *st = NULL;
int ret;
unsigned int i;
pa_sample_spec ss;
pa_buffer_attr attr = { -1, -1, -1, -1, -1 };
const char *stream_name = s->stream_name;
for (i = 0; i < h->nb_streams; i++) {
if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
st = h->streams[i];
s->stream_index = i;
break;
}
}
if (!st) {
av_log(s, AV_LOG_ERROR, "No audio stream found.\n");
return AVERROR(EINVAL);
}
if (!stream_name) {
if (h->filename[0])
stream_name = h->filename;
else
stream_name = "Playback";
}
ss.format = codec_id_to_pulse_format(st->codec->codec_id);
ss.rate = st->codec->sample_rate;
ss.channels = st->codec->channels;
s->pa = pa_simple_new(s->server, // Server
s->name, // Application name
PA_STREAM_PLAYBACK,
s->device, // Device
stream_name, // Description of a stream
&ss, // Sample format
NULL, // Use default channel map
&attr, // Buffering attributes
&ret); // Result
if (!s->pa) {
av_log(s, AV_LOG_ERROR, "pa_simple_new failed: %s\n", pa_strerror(ret));
return AVERROR(EIO);
}
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
return 0;
}
| false | FFmpeg | 7f5e75eea94020aaddeda1960186ceee73ca1c36 | static av_cold int pulse_write_header(AVFormatContext *h)
{
PulseData *s = h->priv_data;
AVStream *st = NULL;
int ret;
unsigned int i;
pa_sample_spec ss;
pa_buffer_attr attr = { -1, -1, -1, -1, -1 };
const char *stream_name = s->stream_name;
for (i = 0; i < h->nb_streams; i++) {
if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
st = h->streams[i];
s->stream_index = i;
break;
}
}
if (!st) {
av_log(s, AV_LOG_ERROR, "No audio stream found.\n");
return AVERROR(EINVAL);
}
if (!stream_name) {
if (h->filename[0])
stream_name = h->filename;
else
stream_name = "Playback";
}
ss.format = codec_id_to_pulse_format(st->codec->codec_id);
ss.rate = st->codec->sample_rate;
ss.channels = st->codec->channels;
s->pa = pa_simple_new(s->server,
s->name,
PA_STREAM_PLAYBACK,
s->device,
stream_name,
&ss,
NULL,
&attr,
&ret);
if (!s->pa) {
av_log(s, AV_LOG_ERROR, "pa_simple_new failed: %s\n", pa_strerror(ret));
return AVERROR(EIO);
}
avpriv_set_pts_info(st, 64, 1, 1000000);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVFormatContext *h)
{
PulseData *s = h->priv_data;
AVStream *st = NULL;
int VAR_0;
unsigned int VAR_1;
pa_sample_spec ss;
pa_buffer_attr attr = { -1, -1, -1, -1, -1 };
const char *VAR_2 = s->VAR_2;
for (VAR_1 = 0; VAR_1 < h->nb_streams; VAR_1++) {
if (h->streams[VAR_1]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
st = h->streams[VAR_1];
s->stream_index = VAR_1;
break;
}
}
if (!st) {
av_log(s, AV_LOG_ERROR, "No audio stream found.\n");
return AVERROR(EINVAL);
}
if (!VAR_2) {
if (h->filename[0])
VAR_2 = h->filename;
else
VAR_2 = "Playback";
}
ss.format = codec_id_to_pulse_format(st->codec->codec_id);
ss.rate = st->codec->sample_rate;
ss.channels = st->codec->channels;
s->pa = pa_simple_new(s->server,
s->name,
PA_STREAM_PLAYBACK,
s->device,
VAR_2,
&ss,
NULL,
&attr,
&VAR_0);
if (!s->pa) {
av_log(s, AV_LOG_ERROR, "pa_simple_new failed: %s\n", pa_strerror(VAR_0));
return AVERROR(EIO);
}
avpriv_set_pts_info(st, 64, 1, 1000000);
return 0;
}
| [
"static av_cold int FUNC_0(AVFormatContext *h)\n{",
"PulseData *s = h->priv_data;",
"AVStream *st = NULL;",
"int VAR_0;",
"unsigned int VAR_1;",
"pa_sample_spec ss;",
"pa_buffer_attr attr = { -1, -1, -1, -1, -1 };",
"const char *VAR_2 = s->VAR_2;",
"for (VAR_1 = 0; VAR_1 < h->nb_streams; VAR_1++) {",
"if (h->streams[VAR_1]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {",
"st = h->streams[VAR_1];",
"s->stream_index = VAR_1;",
"break;",
"}",
"}",
"if (!st) {",
"av_log(s, AV_LOG_ERROR, \"No audio stream found.\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (!VAR_2) {",
"if (h->filename[0])\nVAR_2 = h->filename;",
"else\nVAR_2 = \"Playback\";",
"}",
"ss.format = codec_id_to_pulse_format(st->codec->codec_id);",
"ss.rate = st->codec->sample_rate;",
"ss.channels = st->codec->channels;",
"s->pa = pa_simple_new(s->server,\ns->name,\nPA_STREAM_PLAYBACK,\ns->device,\nVAR_2,\n&ss,\nNULL,\n&attr,\n&VAR_0);",
"if (!s->pa) {",
"av_log(s, AV_LOG_ERROR, \"pa_simple_new failed: %s\\n\", pa_strerror(VAR_0));",
"return AVERROR(EIO);",
"}",
"avpriv_set_pts_info(st, 64, 1, 1000000);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69,
71,
73,
75,
77,
79,
81,
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
]
] |
23,209 | static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
AVStream *st = s->streams[pkt->stream_index];
int64_t end_pts = seg->recording_time * seg->number;
int ret, can_split = 1;
if (!oc)
return AVERROR(EINVAL);
if (seg->has_video) {
can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
pkt->flags & AV_PKT_FLAG_KEY;
}
if (can_split && av_compare_ts(pkt->pts, st->time_base, end_pts,
AV_TIME_BASE_Q) >= 0) {
av_log(s, AV_LOG_DEBUG, "Next segment starts at %d %"PRId64"\n",
pkt->stream_index, pkt->pts);
ret = segment_end(oc, seg->individual_header_trailer);
if (!ret)
ret = segment_start(s, seg->individual_header_trailer);
if (ret)
goto fail;
oc = seg->avf;
if (seg->list) {
if (seg->list_type == LIST_HLS) {
if ((ret = segment_hls_window(s, 0)) < 0)
goto fail;
} else {
avio_printf(seg->pb, "%s\n", oc->filename);
avio_flush(seg->pb);
if (seg->size && !(seg->number % seg->size)) {
avio_closep(&seg->pb);
if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
}
}
}
}
ret = ff_write_chained(oc, pkt->stream_index, pkt, s);
fail:
if (ret < 0)
seg_free_context(seg);
return ret;
}
| false | FFmpeg | 9f61abc8111c7c43f49ca012e957a108b9cc7610 | static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
AVStream *st = s->streams[pkt->stream_index];
int64_t end_pts = seg->recording_time * seg->number;
int ret, can_split = 1;
if (!oc)
return AVERROR(EINVAL);
if (seg->has_video) {
can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
pkt->flags & AV_PKT_FLAG_KEY;
}
if (can_split && av_compare_ts(pkt->pts, st->time_base, end_pts,
AV_TIME_BASE_Q) >= 0) {
av_log(s, AV_LOG_DEBUG, "Next segment starts at %d %"PRId64"\n",
pkt->stream_index, pkt->pts);
ret = segment_end(oc, seg->individual_header_trailer);
if (!ret)
ret = segment_start(s, seg->individual_header_trailer);
if (ret)
goto fail;
oc = seg->avf;
if (seg->list) {
if (seg->list_type == LIST_HLS) {
if ((ret = segment_hls_window(s, 0)) < 0)
goto fail;
} else {
avio_printf(seg->pb, "%s\n", oc->filename);
avio_flush(seg->pb);
if (seg->size && !(seg->number % seg->size)) {
avio_closep(&seg->pb);
if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
}
}
}
}
ret = ff_write_chained(oc, pkt->stream_index, pkt, s);
fail:
if (ret < 0)
seg_free_context(seg);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
SegmentContext *seg = VAR_0->priv_data;
AVFormatContext *oc = seg->avf;
AVStream *st = VAR_0->streams[VAR_1->stream_index];
int64_t end_pts = seg->recording_time * seg->number;
int VAR_2, VAR_3 = 1;
if (!oc)
return AVERROR(EINVAL);
if (seg->has_video) {
VAR_3 = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
VAR_1->flags & AV_PKT_FLAG_KEY;
}
if (VAR_3 && av_compare_ts(VAR_1->pts, st->time_base, end_pts,
AV_TIME_BASE_Q) >= 0) {
av_log(VAR_0, AV_LOG_DEBUG, "Next segment starts at %d %"PRId64"\n",
VAR_1->stream_index, VAR_1->pts);
VAR_2 = segment_end(oc, seg->individual_header_trailer);
if (!VAR_2)
VAR_2 = segment_start(VAR_0, seg->individual_header_trailer);
if (VAR_2)
goto fail;
oc = seg->avf;
if (seg->list) {
if (seg->list_type == LIST_HLS) {
if ((VAR_2 = segment_hls_window(VAR_0, 0)) < 0)
goto fail;
} else {
avio_printf(seg->pb, "%VAR_0\n", oc->filename);
avio_flush(seg->pb);
if (seg->size && !(seg->number % seg->size)) {
avio_closep(&seg->pb);
if ((VAR_2 = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,
&VAR_0->interrupt_callback, NULL)) < 0)
goto fail;
}
}
}
}
VAR_2 = ff_write_chained(oc, VAR_1->stream_index, VAR_1, VAR_0);
fail:
if (VAR_2 < 0)
seg_free_context(seg);
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"SegmentContext *seg = VAR_0->priv_data;",
"AVFormatContext *oc = seg->avf;",
"AVStream *st = VAR_0->streams[VAR_1->stream_index];",
"int64_t end_pts = seg->recording_time * seg->number;",
"int VAR_2, VAR_3 = 1;",
"if (!oc)\nreturn AVERROR(EINVAL);",
"if (seg->has_video) {",
"VAR_3 = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\nVAR_1->flags & AV_PKT_FLAG_KEY;",
"}",
"if (VAR_3 && av_compare_ts(VAR_1->pts, st->time_base, end_pts,\nAV_TIME_BASE_Q) >= 0) {",
"av_log(VAR_0, AV_LOG_DEBUG, \"Next segment starts at %d %\"PRId64\"\\n\",\nVAR_1->stream_index, VAR_1->pts);",
"VAR_2 = segment_end(oc, seg->individual_header_trailer);",
"if (!VAR_2)\nVAR_2 = segment_start(VAR_0, seg->individual_header_trailer);",
"if (VAR_2)\ngoto fail;",
"oc = seg->avf;",
"if (seg->list) {",
"if (seg->list_type == LIST_HLS) {",
"if ((VAR_2 = segment_hls_window(VAR_0, 0)) < 0)\ngoto fail;",
"} else {",
"avio_printf(seg->pb, \"%VAR_0\\n\", oc->filename);",
"avio_flush(seg->pb);",
"if (seg->size && !(seg->number % seg->size)) {",
"avio_closep(&seg->pb);",
"if ((VAR_2 = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE,\n&VAR_0->interrupt_callback, NULL)) < 0)\ngoto fail;",
"}",
"}",
"}",
"}",
"VAR_2 = ff_write_chained(oc, VAR_1->stream_index, VAR_1, VAR_0);",
"fail:\nif (VAR_2 < 0)\nseg_free_context(seg);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25,
27
],
[
29
],
[
33,
35
],
[
37,
39
],
[
43
],
[
47,
49
],
[
53,
55
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101,
103,
105
],
[
109
],
[
111
]
] |
23,210 | avs_decode_frame(AVCodecContext * avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
AvsContext *const avs = avctx->priv_data;
AVFrame *picture = data;
AVFrame *const p = &avs->picture;
const uint8_t *table, *vect;
uint8_t *out;
int i, j, x, y, stride, vect_w = 3, vect_h = 3;
AvsVideoSubType sub_type;
AvsBlockType type;
GetBitContext change_map;
if (avctx->reget_buffer(avctx, p)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
p->reference = 3;
p->pict_type = AV_PICTURE_TYPE_P;
p->key_frame = 0;
out = avs->picture.data[0];
stride = avs->picture.linesize[0];
if (buf_end - buf < 4)
return AVERROR_INVALIDDATA;
sub_type = buf[0];
type = buf[1];
buf += 4;
if (type == AVS_PALETTE) {
int first, last;
uint32_t *pal = (uint32_t *) avs->picture.data[1];
first = AV_RL16(buf);
last = first + AV_RL16(buf + 2);
if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first))
return AVERROR_INVALIDDATA;
buf += 4;
for (i=first; i<last; i++, buf+=3) {
pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
pal[i] |= 0xFFU << 24 | (pal[i] >> 6) & 0x30303;
}
sub_type = buf[0];
type = buf[1];
buf += 4;
}
if (type != AVS_VIDEO)
return -1;
switch (sub_type) {
case AVS_I_FRAME:
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
case AVS_P_FRAME_3X3:
vect_w = 3;
vect_h = 3;
break;
case AVS_P_FRAME_2X2:
vect_w = 2;
vect_h = 2;
break;
case AVS_P_FRAME_2X3:
vect_w = 2;
vect_h = 3;
break;
default:
return -1;
}
if (buf_end - buf < 256 * vect_w * vect_h)
return AVERROR_INVALIDDATA;
table = buf + (256 * vect_w * vect_h);
if (sub_type != AVS_I_FRAME) {
int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
if (buf_end - table < map_size)
return AVERROR_INVALIDDATA;
init_get_bits(&change_map, table, map_size * 8);
table += map_size;
}
for (y=0; y<198; y+=vect_h) {
for (x=0; x<318; x+=vect_w) {
if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {
if (buf_end - table < 1)
return AVERROR_INVALIDDATA;
vect = &buf[*table++ * (vect_w * vect_h)];
for (j=0; j<vect_w; j++) {
out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j];
out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j];
if (vect_h == 3)
out[(y + 2) * stride + x + j] =
vect[(2 * vect_w) + j];
}
}
}
if (sub_type != AVS_I_FRAME)
align_get_bits(&change_map);
}
*picture = avs->picture;
*got_frame = 1;
return buf_size;
}
| true | FFmpeg | 76e65a1b731e28d8382d500c3a7740b65df9f7b2 | avs_decode_frame(AVCodecContext * avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
AvsContext *const avs = avctx->priv_data;
AVFrame *picture = data;
AVFrame *const p = &avs->picture;
const uint8_t *table, *vect;
uint8_t *out;
int i, j, x, y, stride, vect_w = 3, vect_h = 3;
AvsVideoSubType sub_type;
AvsBlockType type;
GetBitContext change_map;
if (avctx->reget_buffer(avctx, p)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
p->reference = 3;
p->pict_type = AV_PICTURE_TYPE_P;
p->key_frame = 0;
out = avs->picture.data[0];
stride = avs->picture.linesize[0];
if (buf_end - buf < 4)
return AVERROR_INVALIDDATA;
sub_type = buf[0];
type = buf[1];
buf += 4;
if (type == AVS_PALETTE) {
int first, last;
uint32_t *pal = (uint32_t *) avs->picture.data[1];
first = AV_RL16(buf);
last = first + AV_RL16(buf + 2);
if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first))
return AVERROR_INVALIDDATA;
buf += 4;
for (i=first; i<last; i++, buf+=3) {
pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
pal[i] |= 0xFFU << 24 | (pal[i] >> 6) & 0x30303;
}
sub_type = buf[0];
type = buf[1];
buf += 4;
}
if (type != AVS_VIDEO)
return -1;
switch (sub_type) {
case AVS_I_FRAME:
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
case AVS_P_FRAME_3X3:
vect_w = 3;
vect_h = 3;
break;
case AVS_P_FRAME_2X2:
vect_w = 2;
vect_h = 2;
break;
case AVS_P_FRAME_2X3:
vect_w = 2;
vect_h = 3;
break;
default:
return -1;
}
if (buf_end - buf < 256 * vect_w * vect_h)
return AVERROR_INVALIDDATA;
table = buf + (256 * vect_w * vect_h);
if (sub_type != AVS_I_FRAME) {
int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
if (buf_end - table < map_size)
return AVERROR_INVALIDDATA;
init_get_bits(&change_map, table, map_size * 8);
table += map_size;
}
for (y=0; y<198; y+=vect_h) {
for (x=0; x<318; x+=vect_w) {
if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {
if (buf_end - table < 1)
return AVERROR_INVALIDDATA;
vect = &buf[*table++ * (vect_w * vect_h)];
for (j=0; j<vect_w; j++) {
out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j];
out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j];
if (vect_h == 3)
out[(y + 2) * stride + x + j] =
vect[(2 * vect_w) + j];
}
}
}
if (sub_type != AVS_I_FRAME)
align_get_bits(&change_map);
}
*picture = avs->picture;
*got_frame = 1;
return buf_size;
}
| {
"code": [
" GetBitContext change_map;"
],
"line_no": [
29
]
} | FUNC_0(AVCodecContext * VAR_0,
void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;
int VAR_6 = VAR_3->size;
AvsContext *const avs = VAR_0->priv_data;
AVFrame *picture = VAR_1;
AVFrame *const p = &avs->picture;
const uint8_t *VAR_7, *vect;
uint8_t *out;
int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 3, VAR_14 = 3;
AvsVideoSubType sub_type;
AvsBlockType type;
GetBitContext change_map;
if (VAR_0->reget_buffer(VAR_0, p)) {
av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
p->reference = 3;
p->pict_type = AV_PICTURE_TYPE_P;
p->key_frame = 0;
out = avs->picture.VAR_1[0];
VAR_12 = avs->picture.linesize[0];
if (VAR_5 - VAR_4 < 4)
return AVERROR_INVALIDDATA;
sub_type = VAR_4[0];
type = VAR_4[1];
VAR_4 += 4;
if (type == AVS_PALETTE) {
int VAR_15, VAR_16;
uint32_t *pal = (uint32_t *) avs->picture.VAR_1[1];
VAR_15 = AV_RL16(VAR_4);
VAR_16 = VAR_15 + AV_RL16(VAR_4 + 2);
if (VAR_15 >= 256 || VAR_16 > 256 || VAR_5 - VAR_4 < 4 + 4 + 3 * (VAR_16 - VAR_15))
return AVERROR_INVALIDDATA;
VAR_4 += 4;
for (VAR_8=VAR_15; VAR_8<VAR_16; VAR_8++, VAR_4+=3) {
pal[VAR_8] = (VAR_4[0] << 18) | (VAR_4[1] << 10) | (VAR_4[2] << 2);
pal[VAR_8] |= 0xFFU << 24 | (pal[VAR_8] >> 6) & 0x30303;
}
sub_type = VAR_4[0];
type = VAR_4[1];
VAR_4 += 4;
}
if (type != AVS_VIDEO)
return -1;
switch (sub_type) {
case AVS_I_FRAME:
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
case AVS_P_FRAME_3X3:
VAR_13 = 3;
VAR_14 = 3;
break;
case AVS_P_FRAME_2X2:
VAR_13 = 2;
VAR_14 = 2;
break;
case AVS_P_FRAME_2X3:
VAR_13 = 2;
VAR_14 = 3;
break;
default:
return -1;
}
if (VAR_5 - VAR_4 < 256 * VAR_13 * VAR_14)
return AVERROR_INVALIDDATA;
VAR_7 = VAR_4 + (256 * VAR_13 * VAR_14);
if (sub_type != AVS_I_FRAME) {
int VAR_17 = ((318 / VAR_13 + 7) / 8) * (198 / VAR_14);
if (VAR_5 - VAR_7 < VAR_17)
return AVERROR_INVALIDDATA;
init_get_bits(&change_map, VAR_7, VAR_17 * 8);
VAR_7 += VAR_17;
}
for (VAR_11=0; VAR_11<198; VAR_11+=VAR_14) {
for (VAR_10=0; VAR_10<318; VAR_10+=VAR_13) {
if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {
if (VAR_5 - VAR_7 < 1)
return AVERROR_INVALIDDATA;
vect = &VAR_4[*VAR_7++ * (VAR_13 * VAR_14)];
for (VAR_9=0; VAR_9<VAR_13; VAR_9++) {
out[(VAR_11 + 0) * VAR_12 + VAR_10 + VAR_9] = vect[(0 * VAR_13) + VAR_9];
out[(VAR_11 + 1) * VAR_12 + VAR_10 + VAR_9] = vect[(1 * VAR_13) + VAR_9];
if (VAR_14 == 3)
out[(VAR_11 + 2) * VAR_12 + VAR_10 + VAR_9] =
vect[(2 * VAR_13) + VAR_9];
}
}
}
if (sub_type != AVS_I_FRAME)
align_get_bits(&change_map);
}
*picture = avs->picture;
*VAR_2 = 1;
return VAR_6;
}
| [
"FUNC_0(AVCodecContext * VAR_0,\nvoid *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;",
"int VAR_6 = VAR_3->size;",
"AvsContext *const avs = VAR_0->priv_data;",
"AVFrame *picture = VAR_1;",
"AVFrame *const p = &avs->picture;",
"const uint8_t *VAR_7, *vect;",
"uint8_t *out;",
"int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13 = 3, VAR_14 = 3;",
"AvsVideoSubType sub_type;",
"AvsBlockType type;",
"GetBitContext change_map;",
"if (VAR_0->reget_buffer(VAR_0, p)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");",
"return -1;",
"}",
"p->reference = 3;",
"p->pict_type = AV_PICTURE_TYPE_P;",
"p->key_frame = 0;",
"out = avs->picture.VAR_1[0];",
"VAR_12 = avs->picture.linesize[0];",
"if (VAR_5 - VAR_4 < 4)\nreturn AVERROR_INVALIDDATA;",
"sub_type = VAR_4[0];",
"type = VAR_4[1];",
"VAR_4 += 4;",
"if (type == AVS_PALETTE) {",
"int VAR_15, VAR_16;",
"uint32_t *pal = (uint32_t *) avs->picture.VAR_1[1];",
"VAR_15 = AV_RL16(VAR_4);",
"VAR_16 = VAR_15 + AV_RL16(VAR_4 + 2);",
"if (VAR_15 >= 256 || VAR_16 > 256 || VAR_5 - VAR_4 < 4 + 4 + 3 * (VAR_16 - VAR_15))\nreturn AVERROR_INVALIDDATA;",
"VAR_4 += 4;",
"for (VAR_8=VAR_15; VAR_8<VAR_16; VAR_8++, VAR_4+=3) {",
"pal[VAR_8] = (VAR_4[0] << 18) | (VAR_4[1] << 10) | (VAR_4[2] << 2);",
"pal[VAR_8] |= 0xFFU << 24 | (pal[VAR_8] >> 6) & 0x30303;",
"}",
"sub_type = VAR_4[0];",
"type = VAR_4[1];",
"VAR_4 += 4;",
"}",
"if (type != AVS_VIDEO)\nreturn -1;",
"switch (sub_type) {",
"case AVS_I_FRAME:\np->pict_type = AV_PICTURE_TYPE_I;",
"p->key_frame = 1;",
"case AVS_P_FRAME_3X3:\nVAR_13 = 3;",
"VAR_14 = 3;",
"break;",
"case AVS_P_FRAME_2X2:\nVAR_13 = 2;",
"VAR_14 = 2;",
"break;",
"case AVS_P_FRAME_2X3:\nVAR_13 = 2;",
"VAR_14 = 3;",
"break;",
"default:\nreturn -1;",
"}",
"if (VAR_5 - VAR_4 < 256 * VAR_13 * VAR_14)\nreturn AVERROR_INVALIDDATA;",
"VAR_7 = VAR_4 + (256 * VAR_13 * VAR_14);",
"if (sub_type != AVS_I_FRAME) {",
"int VAR_17 = ((318 / VAR_13 + 7) / 8) * (198 / VAR_14);",
"if (VAR_5 - VAR_7 < VAR_17)\nreturn AVERROR_INVALIDDATA;",
"init_get_bits(&change_map, VAR_7, VAR_17 * 8);",
"VAR_7 += VAR_17;",
"}",
"for (VAR_11=0; VAR_11<198; VAR_11+=VAR_14) {",
"for (VAR_10=0; VAR_10<318; VAR_10+=VAR_13) {",
"if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {",
"if (VAR_5 - VAR_7 < 1)\nreturn AVERROR_INVALIDDATA;",
"vect = &VAR_4[*VAR_7++ * (VAR_13 * VAR_14)];",
"for (VAR_9=0; VAR_9<VAR_13; VAR_9++) {",
"out[(VAR_11 + 0) * VAR_12 + VAR_10 + VAR_9] = vect[(0 * VAR_13) + VAR_9];",
"out[(VAR_11 + 1) * VAR_12 + VAR_10 + VAR_9] = vect[(1 * VAR_13) + VAR_9];",
"if (VAR_14 == 3)\nout[(VAR_11 + 2) * VAR_12 + VAR_10 + VAR_9] =\nvect[(2 * VAR_13) + VAR_9];",
"}",
"}",
"}",
"if (sub_type != AVS_I_FRAME)\nalign_get_bits(&change_map);",
"}",
"*picture = avs->picture;",
"*VAR_2 = 1;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
129,
131
],
[
133
],
[
135
],
[
139,
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
217
],
[
219
],
[
223
],
[
225
]
] |
23,211 | int av_asrc_buffer_add_buffer(AVFilterContext *ctx,
uint8_t *buf, int buf_size, int sample_rate,
int sample_fmt, int64_t channel_layout, int planar,
int64_t pts, int av_unused flags)
{
uint8_t *data[8];
int linesize[8];
int nb_channels = av_get_channel_layout_nb_channels(channel_layout),
nb_samples = buf_size / nb_channels / av_get_bytes_per_sample(sample_fmt);
av_samples_fill_arrays(data, linesize,
buf, nb_channels, nb_samples,
sample_fmt, 16);
return av_asrc_buffer_add_samples(ctx,
data, linesize, nb_samples,
sample_rate,
sample_fmt, channel_layout, planar,
pts, flags);
}
| true | FFmpeg | 241f8465d07ecc0696bcda994a1f44d836b8809c | int av_asrc_buffer_add_buffer(AVFilterContext *ctx,
uint8_t *buf, int buf_size, int sample_rate,
int sample_fmt, int64_t channel_layout, int planar,
int64_t pts, int av_unused flags)
{
uint8_t *data[8];
int linesize[8];
int nb_channels = av_get_channel_layout_nb_channels(channel_layout),
nb_samples = buf_size / nb_channels / av_get_bytes_per_sample(sample_fmt);
av_samples_fill_arrays(data, linesize,
buf, nb_channels, nb_samples,
sample_fmt, 16);
return av_asrc_buffer_add_samples(ctx,
data, linesize, nb_samples,
sample_rate,
sample_fmt, channel_layout, planar,
pts, flags);
}
| {
"code": [
" uint8_t *data[8];"
],
"line_no": [
11
]
} | int FUNC_0(AVFilterContext *VAR_0,
uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int64_t VAR_5, int VAR_6,
int64_t VAR_7, int VAR_8 flags)
{
uint8_t *data[8];
int VAR_9[8];
int VAR_10 = av_get_channel_layout_nb_channels(VAR_5),
VAR_11 = VAR_2 / VAR_10 / av_get_bytes_per_sample(VAR_4);
av_samples_fill_arrays(data, VAR_9,
VAR_1, VAR_10, VAR_11,
VAR_4, 16);
return av_asrc_buffer_add_samples(VAR_0,
data, VAR_9, VAR_11,
VAR_3,
VAR_4, VAR_5, VAR_6,
VAR_7, flags);
}
| [
"int FUNC_0(AVFilterContext *VAR_0,\nuint8_t *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int64_t VAR_5, int VAR_6,\nint64_t VAR_7, int VAR_8 flags)\n{",
"uint8_t *data[8];",
"int VAR_9[8];",
"int VAR_10 = av_get_channel_layout_nb_channels(VAR_5),\nVAR_11 = VAR_2 / VAR_10 / av_get_bytes_per_sample(VAR_4);",
"av_samples_fill_arrays(data, VAR_9,\nVAR_1, VAR_10, VAR_11,\nVAR_4, 16);",
"return av_asrc_buffer_add_samples(VAR_0,\ndata, VAR_9, VAR_11,\nVAR_3,\nVAR_4, VAR_5, VAR_6,\nVAR_7, flags);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15,
17
],
[
21,
23,
25
],
[
29,
31,
33,
35,
37
],
[
39
]
] |
23,212 | static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0; // should already be zero but set it just to be sure
}
/* ensure output buffer is large enough */
if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
return avpkt->size;
}
| true | FFmpeg | 00cbe9e4053fd562b6f21e76aca6636ff926b637 | static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type, silent_chunks;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
silent_chunks = 0;
if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(buf);
silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
} else if (block_type == BLOCK_TYPE_SILENCE) {
silent_chunks = 1;
buf_size = 0;
}
if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
return avpkt->size;
}
| {
"code": [
" uint32_t flags = AV_RB32(buf);"
],
"line_no": [
53
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
VmdAudioContext *s = VAR_0->priv_data;
int VAR_6, VAR_7;
unsigned char *VAR_8 = (unsigned char *)VAR_1;
if (VAR_5 < 16) {
av_log(VAR_0, AV_LOG_WARNING, "skipping small junk packet\n");
*VAR_2 = 0;
return VAR_5;
}
VAR_6 = VAR_4[6];
if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) {
av_log(VAR_0, AV_LOG_ERROR, "unknown block type: %d\n", VAR_6);
return AVERROR(EINVAL);
}
VAR_4 += 16;
VAR_5 -= 16;
VAR_7 = 0;
if (VAR_6 == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(VAR_4);
VAR_7 = av_popcount(flags);
VAR_4 += 4;
VAR_5 -= 4;
} else if (VAR_6 == BLOCK_TYPE_SILENCE) {
VAR_7 = 1;
VAR_5 = 0;
}
if (*VAR_2 < (VAR_0->block_align*VAR_7 + VAR_5) * s->out_bps)
return -1;
*VAR_2 = vmdaudio_loadsound(s, VAR_8, VAR_4, VAR_7, VAR_5);
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"VmdAudioContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7;",
"unsigned char *VAR_8 = (unsigned char *)VAR_1;",
"if (VAR_5 < 16) {",
"av_log(VAR_0, AV_LOG_WARNING, \"skipping small junk packet\\n\");",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"VAR_6 = VAR_4[6];",
"if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unknown block type: %d\\n\", VAR_6);",
"return AVERROR(EINVAL);",
"}",
"VAR_4 += 16;",
"VAR_5 -= 16;",
"VAR_7 = 0;",
"if (VAR_6 == BLOCK_TYPE_INITIAL) {",
"uint32_t flags = AV_RB32(VAR_4);",
"VAR_7 = av_popcount(flags);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"} else if (VAR_6 == BLOCK_TYPE_SILENCE) {",
"VAR_7 = 1;",
"VAR_5 = 0;",
"}",
"if (*VAR_2 < (VAR_0->block_align*VAR_7 + VAR_5) * s->out_bps)\nreturn -1;",
"*VAR_2 = vmdaudio_loadsound(s, VAR_8, VAR_4, VAR_7, VAR_5);",
"return VAR_3->size;",
"}"
] | [
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73,
75
],
[
79
],
[
83
],
[
85
]
] |
23,214 | static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2],
INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2],
const INTFLOAT *transient_gain,
INTFLOAT g_decay_slope,
int len)
{
static const INTFLOAT a[] = { Q31(0.65143905753106f),
Q31(0.56471812200776f),
Q31(0.48954165955695f) };
INTFLOAT ag[PS_AP_LINKS];
int m, n;
for (m = 0; m < PS_AP_LINKS; m++)
ag[m] = AAC_MUL30(a[m], g_decay_slope);
for (n = 0; n < len; n++) {
INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]);
INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]);
for (m = 0; m < PS_AP_LINKS; m++) {
INTFLOAT a_re = AAC_MUL31(ag[m], in_re);
INTFLOAT a_im = AAC_MUL31(ag[m], in_im);
INTFLOAT link_delay_re = ap_delay[m][n+2-m][0];
INTFLOAT link_delay_im = ap_delay[m][n+2-m][1];
INTFLOAT fractional_delay_re = Q_fract[m][0];
INTFLOAT fractional_delay_im = Q_fract[m][1];
INTFLOAT apd_re = in_re;
INTFLOAT apd_im = in_im;
in_re = AAC_MSUB30(link_delay_re, fractional_delay_re,
link_delay_im, fractional_delay_im);
in_re -= a_re;
in_im = AAC_MADD30(link_delay_re, fractional_delay_im,
link_delay_im, fractional_delay_re);
in_im -= a_im;
ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re);
ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im);
}
out[n][0] = AAC_MUL16(transient_gain[n], in_re);
out[n][1] = AAC_MUL16(transient_gain[n], in_im);
}
}
| true | FFmpeg | 2afe05402f05d485f0c356b04dc562f0510d317d | static void ps_decorrelate_c(INTFLOAT (*out)[2], INTFLOAT (*delay)[2],
INTFLOAT (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
const INTFLOAT phi_fract[2], const INTFLOAT (*Q_fract)[2],
const INTFLOAT *transient_gain,
INTFLOAT g_decay_slope,
int len)
{
static const INTFLOAT a[] = { Q31(0.65143905753106f),
Q31(0.56471812200776f),
Q31(0.48954165955695f) };
INTFLOAT ag[PS_AP_LINKS];
int m, n;
for (m = 0; m < PS_AP_LINKS; m++)
ag[m] = AAC_MUL30(a[m], g_decay_slope);
for (n = 0; n < len; n++) {
INTFLOAT in_re = AAC_MSUB30(delay[n][0], phi_fract[0], delay[n][1], phi_fract[1]);
INTFLOAT in_im = AAC_MADD30(delay[n][0], phi_fract[1], delay[n][1], phi_fract[0]);
for (m = 0; m < PS_AP_LINKS; m++) {
INTFLOAT a_re = AAC_MUL31(ag[m], in_re);
INTFLOAT a_im = AAC_MUL31(ag[m], in_im);
INTFLOAT link_delay_re = ap_delay[m][n+2-m][0];
INTFLOAT link_delay_im = ap_delay[m][n+2-m][1];
INTFLOAT fractional_delay_re = Q_fract[m][0];
INTFLOAT fractional_delay_im = Q_fract[m][1];
INTFLOAT apd_re = in_re;
INTFLOAT apd_im = in_im;
in_re = AAC_MSUB30(link_delay_re, fractional_delay_re,
link_delay_im, fractional_delay_im);
in_re -= a_re;
in_im = AAC_MADD30(link_delay_re, fractional_delay_im,
link_delay_im, fractional_delay_re);
in_im -= a_im;
ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re);
ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im);
}
out[n][0] = AAC_MUL16(transient_gain[n], in_re);
out[n][1] = AAC_MUL16(transient_gain[n], in_im);
}
}
| {
"code": [
" in_re -= a_re;",
" in_im -= a_im;",
" ap_delay[m][n+5][0] = apd_re + AAC_MUL31(ag[m], in_re);",
" ap_delay[m][n+5][1] = apd_im + AAC_MUL31(ag[m], in_im);"
],
"line_no": [
61,
67,
69,
71
]
} | VAR_3staticVAR_3 VAR_3voidVAR_3 VAR_3ps_decorrelate_cVAR_3(VAR_3VAR_0VAR_3 (*VAR_3outVAR_3)[VAR_32VAR_3], VAR_3VAR_0VAR_3 (*VAR_3delayVAR_3)[VAR_32VAR_3],
VAR_3VAR_0VAR_3 (*VAR_3ap_delayVAR_3)[VAR_3PS_QMF_TIME_SLOTSVAR_3 + VAR_3PS_MAX_AP_DELAYVAR_3][VAR_32VAR_3],
VAR_3constVAR_3 VAR_3VAR_0VAR_3 VAR_3phi_fractVAR_3[VAR_32VAR_3], VAR_3constVAR_3 VAR_3VAR_0VAR_3 (*VAR_3Q_fractVAR_3)[VAR_32VAR_3],
VAR_3constVAR_3 VAR_3VAR_0VAR_3 *VAR_3transient_gainVAR_3,
VAR_3VAR_0VAR_3 VAR_3g_decay_slopeVAR_3,
VAR_3intVAR_3 VAR_3lenVAR_3)
{
VAR_3staticVAR_3 VAR_3constVAR_3 VAR_3VAR_0VAR_3 VAR_3aVAR_3[] = { VAR_3Q31VAR_3(VAR_30VAR_3.VAR_365143905753106fVAR_3),
VAR_3Q31VAR_3(VAR_30VAR_3.VAR_356471812200776fVAR_3),
VAR_3Q31VAR_3(VAR_30VAR_3.VAR_348954165955695fVAR_3) };
VAR_3VAR_0VAR_3 VAR_3agVAR_3[VAR_3PS_AP_LINKSVAR_3];
VAR_3intVAR_3 VAR_3mVAR_3, VAR_3nVAR_3;
VAR_3forVAR_3 (VAR_3mVAR_3 = VAR_30VAR_3; VAR_3mVAR_3 < VAR_3PS_AP_LINKSVAR_3; VAR_3mVAR_3++)
VAR_3agVAR_3[VAR_3mVAR_3] = VAR_3AAC_MUL30VAR_3(VAR_3aVAR_3[VAR_3mVAR_3], VAR_3g_decay_slopeVAR_3);
VAR_3forVAR_3 (VAR_3nVAR_3 = VAR_30VAR_3; VAR_3nVAR_3 < VAR_3lenVAR_3; VAR_3nVAR_3++) {
VAR_3VAR_0VAR_3 VAR_3in_reVAR_3 = VAR_3AAC_MSUB30VAR_3(VAR_3delayVAR_3[VAR_3nVAR_3][VAR_30VAR_3], VAR_3phi_fractVAR_3[VAR_30VAR_3], VAR_3delayVAR_3[VAR_3nVAR_3][VAR_31VAR_3], VAR_3phi_fractVAR_3[VAR_31VAR_3]);
VAR_3VAR_0VAR_3 VAR_3in_imVAR_3 = VAR_3AAC_MADD30VAR_3(VAR_3delayVAR_3[VAR_3nVAR_3][VAR_30VAR_3], VAR_3phi_fractVAR_3[VAR_31VAR_3], VAR_3delayVAR_3[VAR_3nVAR_3][VAR_31VAR_3], VAR_3phi_fractVAR_3[VAR_30VAR_3]);
VAR_3forVAR_3 (VAR_3mVAR_3 = VAR_30VAR_3; VAR_3mVAR_3 < VAR_3PS_AP_LINKSVAR_3; VAR_3mVAR_3++) {
VAR_3VAR_0VAR_3 VAR_3a_reVAR_3 = VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_reVAR_3);
VAR_3VAR_0VAR_3 VAR_3a_imVAR_3 = VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_imVAR_3);
VAR_3VAR_0VAR_3 VAR_3link_delay_reVAR_3 = VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_32VAR_3-VAR_3mVAR_3][VAR_30VAR_3];
VAR_3VAR_0VAR_3 VAR_3link_delay_imVAR_3 = VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_32VAR_3-VAR_3mVAR_3][VAR_31VAR_3];
VAR_3VAR_0VAR_3 VAR_3fractional_delay_reVAR_3 = VAR_3Q_fractVAR_3[VAR_3mVAR_3][VAR_30VAR_3];
VAR_3VAR_0VAR_3 VAR_3fractional_delay_imVAR_3 = VAR_3Q_fractVAR_3[VAR_3mVAR_3][VAR_31VAR_3];
VAR_3VAR_0VAR_3 VAR_3apd_reVAR_3 = VAR_3in_reVAR_3;
VAR_3VAR_0VAR_3 VAR_3apd_imVAR_3 = VAR_3in_imVAR_3;
VAR_3in_reVAR_3 = VAR_3AAC_MSUB30VAR_3(VAR_3link_delay_reVAR_3, VAR_3fractional_delay_reVAR_3,
VAR_3link_delay_imVAR_3, VAR_3fractional_delay_imVAR_3);
VAR_3in_reVAR_3 -= VAR_3a_reVAR_3;
VAR_3in_imVAR_3 = VAR_3AAC_MADD30VAR_3(VAR_3link_delay_reVAR_3, VAR_3fractional_delay_imVAR_3,
VAR_3link_delay_imVAR_3, VAR_3fractional_delay_reVAR_3);
VAR_3in_imVAR_3 -= VAR_3a_imVAR_3;
VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_35VAR_3][VAR_30VAR_3] = VAR_3apd_reVAR_3 + VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_reVAR_3);
VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_35VAR_3][VAR_31VAR_3] = VAR_3apd_imVAR_3 + VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_imVAR_3);
}
VAR_3outVAR_3[VAR_3nVAR_3][VAR_30VAR_3] = VAR_3AAC_MUL16VAR_3(VAR_3transient_gainVAR_3[VAR_3nVAR_3], VAR_3in_reVAR_3);
VAR_3outVAR_3[VAR_3nVAR_3][VAR_31VAR_3] = VAR_3AAC_MUL16VAR_3(VAR_3transient_gainVAR_3[VAR_3nVAR_3], VAR_3in_imVAR_3);
}
}
| [
"VAR_3staticVAR_3 VAR_3voidVAR_3 VAR_3ps_decorrelate_cVAR_3(VAR_3VAR_0VAR_3 (*VAR_3outVAR_3)[VAR_32VAR_3], VAR_3VAR_0VAR_3 (*VAR_3delayVAR_3)[VAR_32VAR_3],\nVAR_3VAR_0VAR_3 (*VAR_3ap_delayVAR_3)[VAR_3PS_QMF_TIME_SLOTSVAR_3 + VAR_3PS_MAX_AP_DELAYVAR_3][VAR_32VAR_3],\nVAR_3constVAR_3 VAR_3VAR_0VAR_3 VAR_3phi_fractVAR_3[VAR_32VAR_3], VAR_3constVAR_3 VAR_3VAR_0VAR_3 (*VAR_3Q_fractVAR_3)[VAR_32VAR_3],\nVAR_3constVAR_3 VAR_3VAR_0VAR_3 *VAR_3transient_gainVAR_3,\nVAR_3VAR_0VAR_3 VAR_3g_decay_slopeVAR_3,\nVAR_3intVAR_3 VAR_3lenVAR_3)\n{",
"VAR_3staticVAR_3 VAR_3constVAR_3 VAR_3VAR_0VAR_3 VAR_3aVAR_3[] = { VAR_3Q31VAR_3(VAR_30VAR_3.VAR_365143905753106fVAR_3),",
"VAR_3Q31VAR_3(VAR_30VAR_3.VAR_356471812200776fVAR_3),\nVAR_3Q31VAR_3(VAR_30VAR_3.VAR_348954165955695fVAR_3) };",
"VAR_3VAR_0VAR_3 VAR_3agVAR_3[VAR_3PS_AP_LINKSVAR_3];",
"VAR_3intVAR_3 VAR_3mVAR_3, VAR_3nVAR_3;",
"VAR_3forVAR_3 (VAR_3mVAR_3 = VAR_30VAR_3; VAR_3mVAR_3 < VAR_3PS_AP_LINKSVAR_3; VAR_3mVAR_3++)",
"VAR_3agVAR_3[VAR_3mVAR_3] = VAR_3AAC_MUL30VAR_3(VAR_3aVAR_3[VAR_3mVAR_3], VAR_3g_decay_slopeVAR_3);",
"VAR_3forVAR_3 (VAR_3nVAR_3 = VAR_30VAR_3; VAR_3nVAR_3 < VAR_3lenVAR_3; VAR_3nVAR_3++) {",
"VAR_3VAR_0VAR_3 VAR_3in_reVAR_3 = VAR_3AAC_MSUB30VAR_3(VAR_3delayVAR_3[VAR_3nVAR_3][VAR_30VAR_3], VAR_3phi_fractVAR_3[VAR_30VAR_3], VAR_3delayVAR_3[VAR_3nVAR_3][VAR_31VAR_3], VAR_3phi_fractVAR_3[VAR_31VAR_3]);",
"VAR_3VAR_0VAR_3 VAR_3in_imVAR_3 = VAR_3AAC_MADD30VAR_3(VAR_3delayVAR_3[VAR_3nVAR_3][VAR_30VAR_3], VAR_3phi_fractVAR_3[VAR_31VAR_3], VAR_3delayVAR_3[VAR_3nVAR_3][VAR_31VAR_3], VAR_3phi_fractVAR_3[VAR_30VAR_3]);",
"VAR_3forVAR_3 (VAR_3mVAR_3 = VAR_30VAR_3; VAR_3mVAR_3 < VAR_3PS_AP_LINKSVAR_3; VAR_3mVAR_3++) {",
"VAR_3VAR_0VAR_3 VAR_3a_reVAR_3 = VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_reVAR_3);",
"VAR_3VAR_0VAR_3 VAR_3a_imVAR_3 = VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_imVAR_3);",
"VAR_3VAR_0VAR_3 VAR_3link_delay_reVAR_3 = VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_32VAR_3-VAR_3mVAR_3][VAR_30VAR_3];",
"VAR_3VAR_0VAR_3 VAR_3link_delay_imVAR_3 = VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_32VAR_3-VAR_3mVAR_3][VAR_31VAR_3];",
"VAR_3VAR_0VAR_3 VAR_3fractional_delay_reVAR_3 = VAR_3Q_fractVAR_3[VAR_3mVAR_3][VAR_30VAR_3];",
"VAR_3VAR_0VAR_3 VAR_3fractional_delay_imVAR_3 = VAR_3Q_fractVAR_3[VAR_3mVAR_3][VAR_31VAR_3];",
"VAR_3VAR_0VAR_3 VAR_3apd_reVAR_3 = VAR_3in_reVAR_3;",
"VAR_3VAR_0VAR_3 VAR_3apd_imVAR_3 = VAR_3in_imVAR_3;",
"VAR_3in_reVAR_3 = VAR_3AAC_MSUB30VAR_3(VAR_3link_delay_reVAR_3, VAR_3fractional_delay_reVAR_3,\nVAR_3link_delay_imVAR_3, VAR_3fractional_delay_imVAR_3);",
"VAR_3in_reVAR_3 -= VAR_3a_reVAR_3;",
"VAR_3in_imVAR_3 = VAR_3AAC_MADD30VAR_3(VAR_3link_delay_reVAR_3, VAR_3fractional_delay_imVAR_3,\nVAR_3link_delay_imVAR_3, VAR_3fractional_delay_reVAR_3);",
"VAR_3in_imVAR_3 -= VAR_3a_imVAR_3;",
"VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_35VAR_3][VAR_30VAR_3] = VAR_3apd_reVAR_3 + VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_reVAR_3);",
"VAR_3ap_delayVAR_3[VAR_3mVAR_3][VAR_3nVAR_3+VAR_35VAR_3][VAR_31VAR_3] = VAR_3apd_imVAR_3 + VAR_3AAC_MUL31VAR_3(VAR_3agVAR_3[VAR_3mVAR_3], VAR_3in_imVAR_3);",
"}",
"VAR_3outVAR_3[VAR_3nVAR_3][VAR_30VAR_3] = VAR_3AAC_MUL16VAR_3(VAR_3transient_gainVAR_3[VAR_3nVAR_3], VAR_3in_reVAR_3);",
"VAR_3outVAR_3[VAR_3nVAR_3][VAR_31VAR_3] = VAR_3AAC_MUL16VAR_3(VAR_3transient_gainVAR_3[VAR_3nVAR_3], VAR_3in_imVAR_3);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
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
]
] |
23,215 | void nand_setpins(DeviceState *dev, uint8_t cle, uint8_t ale,
uint8_t ce, uint8_t wp, uint8_t gnd)
{
NANDFlashState *s = (NANDFlashState *) dev;
s->cle = cle;
s->ale = ale;
s->ce = ce;
s->wp = wp;
s->gnd = gnd;
if (wp)
s->status |= NAND_IOSTATUS_UNPROTCT;
else
s->status &= ~NAND_IOSTATUS_UNPROTCT;
}
| true | qemu | 1984745ea8ad309a06690a83e91d031d21d709ff | void nand_setpins(DeviceState *dev, uint8_t cle, uint8_t ale,
uint8_t ce, uint8_t wp, uint8_t gnd)
{
NANDFlashState *s = (NANDFlashState *) dev;
s->cle = cle;
s->ale = ale;
s->ce = ce;
s->wp = wp;
s->gnd = gnd;
if (wp)
s->status |= NAND_IOSTATUS_UNPROTCT;
else
s->status &= ~NAND_IOSTATUS_UNPROTCT;
}
| {
"code": [
" if (wp)"
],
"line_no": [
19
]
} | void FUNC_0(DeviceState *VAR_0, uint8_t VAR_1, uint8_t VAR_2,
uint8_t VAR_3, uint8_t VAR_4, uint8_t VAR_5)
{
NANDFlashState *s = (NANDFlashState *) VAR_0;
s->VAR_1 = VAR_1;
s->VAR_2 = VAR_2;
s->VAR_3 = VAR_3;
s->VAR_4 = VAR_4;
s->VAR_5 = VAR_5;
if (VAR_4)
s->status |= NAND_IOSTATUS_UNPROTCT;
else
s->status &= ~NAND_IOSTATUS_UNPROTCT;
}
| [
"void FUNC_0(DeviceState *VAR_0, uint8_t VAR_1, uint8_t VAR_2,\nuint8_t VAR_3, uint8_t VAR_4, uint8_t VAR_5)\n{",
"NANDFlashState *s = (NANDFlashState *) VAR_0;",
"s->VAR_1 = VAR_1;",
"s->VAR_2 = VAR_2;",
"s->VAR_3 = VAR_3;",
"s->VAR_4 = VAR_4;",
"s->VAR_5 = VAR_5;",
"if (VAR_4)\ns->status |= NAND_IOSTATUS_UNPROTCT;",
"else\ns->status &= ~NAND_IOSTATUS_UNPROTCT;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
]
] |
23,216 | static int parse_presentation_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size,
int64_t pts)
{
PGSSubContext *ctx = avctx->priv_data;
int i, state, ret;
const uint8_t *buf_end = buf + buf_size;
// Video descriptor
int w = bytestream_get_be16(&buf);
int h = bytestream_get_be16(&buf);
uint16_t object_index;
ctx->presentation.pts = pts;
av_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
/* Skip 1 bytes of unknown, frame rate */
buf++;
// Composition descriptor
ctx->presentation.id_number = bytestream_get_be16(&buf);
/*
* state is a 2 bit field that defines pgs epoch boundaries
* 00 - Normal, previously defined objects and palettes are still valid
* 01 - Acquisition point, previous objects and palettes can be released
* 10 - Epoch start, previous objects and palettes can be released
* 11 - Epoch continue, previous objects and palettes can be released
*
* reserved 6 bits discarded
*/
state = bytestream_get_byte(&buf) >> 6;
if (state != 0) {
flush_cache(avctx);
/*
* skip palette_update_flag (0x80),
*/
buf += 1;
ctx->presentation.palette_id = bytestream_get_byte(&buf);
ctx->presentation.object_count = bytestream_get_byte(&buf);
if (ctx->presentation.object_count > MAX_OBJECT_REFS) {
av_log(avctx, AV_LOG_ERROR,
"Invalid number of presentation objects %d\n",
ctx->presentation.object_count);
ctx->presentation.object_count = 2;
if (avctx->err_recognition & AV_EF_EXPLODE) {
for (i = 0; i < ctx->presentation.object_count; i++)
{
ctx->presentation.objects[i].id = bytestream_get_be16(&buf);
ctx->presentation.objects[i].window_id = bytestream_get_byte(&buf);
ctx->presentation.objects[i].composition_flag = bytestream_get_byte(&buf);
ctx->presentation.objects[i].x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].y = bytestream_get_be16(&buf);
// If cropping
if (ctx->presentation.objects[i].composition_flag & 0x80) {
ctx->presentation.objects[i].crop_x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_y = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_w = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf);
av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n",
ctx->presentation.objects[i].x, ctx->presentation.objects[i].y);
if (ctx->presentation.objects[i].x > avctx->width ||
ctx->presentation.objects[i].y > avctx->height) {
av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
ctx->presentation.objects[i].x,
ctx->presentation.objects[i].y,
avctx->width, avctx->height);
ctx->presentation.objects[i].x = 0;
ctx->presentation.objects[i].y = 0;
if (avctx->err_recognition & AV_EF_EXPLODE) {
return 0; | true | FFmpeg | 89bcb77726e222aee9d8536f0310d805f7d39fac | static int parse_presentation_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size,
int64_t pts)
{
PGSSubContext *ctx = avctx->priv_data;
int i, state, ret;
const uint8_t *buf_end = buf + buf_size;
int w = bytestream_get_be16(&buf);
int h = bytestream_get_be16(&buf);
uint16_t object_index;
ctx->presentation.pts = pts;
av_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
return ret;
buf++;
ctx->presentation.id_number = bytestream_get_be16(&buf);
state = bytestream_get_byte(&buf) >> 6;
if (state != 0) {
flush_cache(avctx);
buf += 1;
ctx->presentation.palette_id = bytestream_get_byte(&buf);
ctx->presentation.object_count = bytestream_get_byte(&buf);
if (ctx->presentation.object_count > MAX_OBJECT_REFS) {
av_log(avctx, AV_LOG_ERROR,
"Invalid number of presentation objects %d\n",
ctx->presentation.object_count);
ctx->presentation.object_count = 2;
if (avctx->err_recognition & AV_EF_EXPLODE) {
for (i = 0; i < ctx->presentation.object_count; i++)
{
ctx->presentation.objects[i].id = bytestream_get_be16(&buf);
ctx->presentation.objects[i].window_id = bytestream_get_byte(&buf);
ctx->presentation.objects[i].composition_flag = bytestream_get_byte(&buf);
ctx->presentation.objects[i].x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].y = bytestream_get_be16(&buf);
if (ctx->presentation.objects[i].composition_flag & 0x80) {
ctx->presentation.objects[i].crop_x = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_y = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_w = bytestream_get_be16(&buf);
ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf);
av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n",
ctx->presentation.objects[i].x, ctx->presentation.objects[i].y);
if (ctx->presentation.objects[i].x > avctx->width ||
ctx->presentation.objects[i].y > avctx->height) {
av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
ctx->presentation.objects[i].x,
ctx->presentation.objects[i].y,
avctx->width, avctx->height);
ctx->presentation.objects[i].x = 0;
ctx->presentation.objects[i].y = 0;
if (avctx->err_recognition & AV_EF_EXPLODE) {
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2,
int64_t VAR_3)
{
PGSSubContext *ctx = VAR_0->priv_data;
int VAR_4, VAR_5, VAR_6;
const uint8_t *VAR_7 = VAR_1 + VAR_2;
int VAR_8 = bytestream_get_be16(&VAR_1);
int VAR_9 = bytestream_get_be16(&VAR_1);
uint16_t object_index;
ctx->presentation.VAR_3 = VAR_3;
av_dlog(VAR_0, "Video Dimensions %dx%d\n",
VAR_8, VAR_9);
VAR_6 = ff_set_dimensions(VAR_0, VAR_8, VAR_9);
if (VAR_6 < 0)
return VAR_6;
VAR_1++;
ctx->presentation.id_number = bytestream_get_be16(&VAR_1);
VAR_5 = bytestream_get_byte(&VAR_1) >> 6;
if (VAR_5 != 0) {
flush_cache(VAR_0);
VAR_1 += 1;
ctx->presentation.palette_id = bytestream_get_byte(&VAR_1);
ctx->presentation.object_count = bytestream_get_byte(&VAR_1);
if (ctx->presentation.object_count > MAX_OBJECT_REFS) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid number of presentation objects %d\n",
ctx->presentation.object_count);
ctx->presentation.object_count = 2;
if (VAR_0->err_recognition & AV_EF_EXPLODE) {
for (VAR_4 = 0; VAR_4 < ctx->presentation.object_count; VAR_4++)
{
ctx->presentation.objects[VAR_4].id = bytestream_get_be16(&VAR_1);
ctx->presentation.objects[VAR_4].window_id = bytestream_get_byte(&VAR_1);
ctx->presentation.objects[VAR_4].composition_flag = bytestream_get_byte(&VAR_1);
ctx->presentation.objects[VAR_4].x = bytestream_get_be16(&VAR_1);
ctx->presentation.objects[VAR_4].y = bytestream_get_be16(&VAR_1);
if (ctx->presentation.objects[VAR_4].composition_flag & 0x80) {
ctx->presentation.objects[VAR_4].crop_x = bytestream_get_be16(&VAR_1);
ctx->presentation.objects[VAR_4].crop_y = bytestream_get_be16(&VAR_1);
ctx->presentation.objects[VAR_4].crop_w = bytestream_get_be16(&VAR_1);
ctx->presentation.objects[VAR_4].crop_h = bytestream_get_be16(&VAR_1);
av_dlog(VAR_0, "Subtitle Placement x=%d, y=%d\n",
ctx->presentation.objects[VAR_4].x, ctx->presentation.objects[VAR_4].y);
if (ctx->presentation.objects[VAR_4].x > VAR_0->width ||
ctx->presentation.objects[VAR_4].y > VAR_0->height) {
av_log(VAR_0, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
ctx->presentation.objects[VAR_4].x,
ctx->presentation.objects[VAR_4].y,
VAR_0->width, VAR_0->height);
ctx->presentation.objects[VAR_4].x = 0;
ctx->presentation.objects[VAR_4].y = 0;
if (VAR_0->err_recognition & AV_EF_EXPLODE) {
return 0; | [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2,\nint64_t VAR_3)\n{",
"PGSSubContext *ctx = VAR_0->priv_data;",
"int VAR_4, VAR_5, VAR_6;",
"const uint8_t *VAR_7 = VAR_1 + VAR_2;",
"int VAR_8 = bytestream_get_be16(&VAR_1);",
"int VAR_9 = bytestream_get_be16(&VAR_1);",
"uint16_t object_index;",
"ctx->presentation.VAR_3 = VAR_3;",
"av_dlog(VAR_0, \"Video Dimensions %dx%d\\n\",\nVAR_8, VAR_9);",
"VAR_6 = ff_set_dimensions(VAR_0, VAR_8, VAR_9);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"VAR_1++;",
"ctx->presentation.id_number = bytestream_get_be16(&VAR_1);",
"VAR_5 = bytestream_get_byte(&VAR_1) >> 6;",
"if (VAR_5 != 0) {",
"flush_cache(VAR_0);",
"VAR_1 += 1;",
"ctx->presentation.palette_id = bytestream_get_byte(&VAR_1);",
"ctx->presentation.object_count = bytestream_get_byte(&VAR_1);",
"if (ctx->presentation.object_count > MAX_OBJECT_REFS) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid number of presentation objects %d\\n\",\nctx->presentation.object_count);",
"ctx->presentation.object_count = 2;",
"if (VAR_0->err_recognition & AV_EF_EXPLODE) {",
"for (VAR_4 = 0; VAR_4 < ctx->presentation.object_count; VAR_4++)",
"{",
"ctx->presentation.objects[VAR_4].id = bytestream_get_be16(&VAR_1);",
"ctx->presentation.objects[VAR_4].window_id = bytestream_get_byte(&VAR_1);",
"ctx->presentation.objects[VAR_4].composition_flag = bytestream_get_byte(&VAR_1);",
"ctx->presentation.objects[VAR_4].x = bytestream_get_be16(&VAR_1);",
"ctx->presentation.objects[VAR_4].y = bytestream_get_be16(&VAR_1);",
"if (ctx->presentation.objects[VAR_4].composition_flag & 0x80) {",
"ctx->presentation.objects[VAR_4].crop_x = bytestream_get_be16(&VAR_1);",
"ctx->presentation.objects[VAR_4].crop_y = bytestream_get_be16(&VAR_1);",
"ctx->presentation.objects[VAR_4].crop_w = bytestream_get_be16(&VAR_1);",
"ctx->presentation.objects[VAR_4].crop_h = bytestream_get_be16(&VAR_1);",
"av_dlog(VAR_0, \"Subtitle Placement x=%d, y=%d\\n\",\nctx->presentation.objects[VAR_4].x, ctx->presentation.objects[VAR_4].y);",
"if (ctx->presentation.objects[VAR_4].x > VAR_0->width ||\nctx->presentation.objects[VAR_4].y > VAR_0->height) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\\n\",\nctx->presentation.objects[VAR_4].x,\nctx->presentation.objects[VAR_4].y,\nVAR_0->width, VAR_0->height);",
"ctx->presentation.objects[VAR_4].x = 0;",
"ctx->presentation.objects[VAR_4].y = 0;",
"if (VAR_0->err_recognition & AV_EF_EXPLODE) {",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13,
14
],
[
15
],
[
16,
17
],
[
19
],
[
21
],
[
31
],
[
32
],
[
33
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41,
42,
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59,
60
],
[
61,
62
],
[
63,
64,
65,
66
],
[
67
],
[
68
],
[
69
],
[
70
]
] |
23,217 | PROTO4(_pack_2ch_)
PROTO4(_pack_6ch_)
PROTO4(_unpack_2ch_)
av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
enum AVSampleFormat out_fmt,
enum AVSampleFormat in_fmt,
int channels){
int mm_flags = av_get_cpu_flags();
ac->simd_f= NULL;
//FIXME add memcpy case
#define MULTI_CAPS_FUNC(flag, cap) \
if (mm_flags & flag) {\
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
ac->simd_f = ff_int16_to_int32_a_ ## cap;\
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
ac->simd_f = ff_int32_to_int16_a_ ## cap;\
}
MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
if(mm_flags & AV_CPU_FLAG_MMX) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_mmx;
}
}
if(mm_flags & AV_CPU_FLAG_SSE2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int16_a_sse2;
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
}
}
if(mm_flags & AV_CPU_FLAG_SSSE3) {
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
}
}
if(mm_flags & AV_CPU_FLAG_SSE4) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;
}
}
if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_avx;
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
}
}
}
| false | FFmpeg | 9937362c54be085e75c90c55dad443329be59e69 | PROTO4(_pack_2ch_)
PROTO4(_pack_6ch_)
PROTO4(_unpack_2ch_)
av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
enum AVSampleFormat out_fmt,
enum AVSampleFormat in_fmt,
int channels){
int mm_flags = av_get_cpu_flags();
ac->simd_f= NULL;
#define MULTI_CAPS_FUNC(flag, cap) \
if (mm_flags & flag) {\
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
ac->simd_f = ff_int16_to_int32_a_ ## cap;\
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
ac->simd_f = ff_int32_to_int16_a_ ## cap;\
}
MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
if(mm_flags & AV_CPU_FLAG_MMX) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_mmx;
}
}
if(mm_flags & AV_CPU_FLAG_SSE2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int16_a_sse2;
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
}
}
if(mm_flags & AV_CPU_FLAG_SSSE3) {
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
}
}
if(mm_flags & AV_CPU_FLAG_SSE4) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;
}
}
if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_avx;
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
}
}
}
| {
"code": [],
"line_no": []
} | PROTO4(_pack_2ch_)
PROTO4(_pack_6ch_)
PROTO4(_unpack_2ch_)
av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
enum AVSampleFormat out_fmt,
enum AVSampleFormat in_fmt,
int channels){
int mm_flags = av_get_cpu_flags();
ac->simd_f= NULL;
#define MULTI_CAPS_FUNC(flag, cap) \
if (mm_flags & flag) {\
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
ac->simd_f = ff_int16_to_int32_a_ ## cap;\
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
ac->simd_f = ff_int32_to_int16_a_ ## cap;\
}
MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)
if(mm_flags & AV_CPU_FLAG_MMX) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_mmx;
}
}
if(mm_flags & AV_CPU_FLAG_SSE2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_float_to_int16_a_sse2;
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
}
}
if(mm_flags & AV_CPU_FLAG_SSSE3) {
if(channels == 2) {
if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
}
}
if(mm_flags & AV_CPU_FLAG_SSE4) {
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;
}
}
if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_int32_to_float_a_avx;
if(channels == 6) {
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
}
}
}
| [
"PROTO4(_pack_2ch_)\nPROTO4(_pack_6ch_)\nPROTO4(_unpack_2ch_)\nav_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,\nenum AVSampleFormat out_fmt,\nenum AVSampleFormat in_fmt,\nint channels){",
"int mm_flags = av_get_cpu_flags();",
"ac->simd_f= NULL;",
"#define MULTI_CAPS_FUNC(flag, cap) \\\nif (mm_flags & flag) {\\",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\\\nac->simd_f = ff_int16_to_int32_a_ ## cap;\\",
"if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\\\nac->simd_f = ff_int32_to_int16_a_ ## cap;\\",
"}",
"MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)\nMULTI_CAPS_FUNC(AV_CPU_FLAG_SSE2, sse2)\nif(mm_flags & AV_CPU_FLAG_MMX) {",
"if(channels == 6) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_6ch_float_to_float_a_mmx;",
"}",
"}",
"if(mm_flags & AV_CPU_FLAG_SSE2) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_int32_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)\nac->simd_f = ff_int16_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_float_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_float_to_int16_a_sse2;",
"if(channels == 2) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)\nac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)\nac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)\nac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)\nac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)\nac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)\nac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)\nac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;",
"if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)\nac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;",
"}",
"}",
"if(mm_flags & AV_CPU_FLAG_SSSE3) {",
"if(channels == 2) {",
"if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;",
"if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;",
"if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)\nac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;",
"}",
"}",
"if(mm_flags & AV_CPU_FLAG_SSE4) {",
"if(channels == 6) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_6ch_float_to_float_a_sse4;",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_6ch_int32_to_float_a_sse4;",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_pack_6ch_float_to_int32_a_sse4;",
"}",
"}",
"if(HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_int32_to_float_a_avx;",
"if(channels == 6) {",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_6ch_float_to_float_a_avx;",
"if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)\nac->simd_f = ff_pack_6ch_int32_to_float_a_avx;",
"if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)\nac->simd_f = ff_pack_6ch_float_to_int32_a_avx;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
9,
11,
13,
15
],
[
17
],
[
21
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41
],
[
45,
47,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79,
81
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
99,
101
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
117,
119
],
[
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
]
] |
23,218 | static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
{
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
ctx->lambda = 2<<LAMBDA_FRAC_BITS; // qscale 2
return 0;
fail:
return -1;
}
| false | FFmpeg | f1caaa1c61310beba705957e6366f0392a0b005b | static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
{
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
ctx->lambda = 2<<LAMBDA_FRAC_BITS;
return 0;
fail:
return -1;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(DNXHDEncContext *ctx)
{
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;
ctx->qscale = 1;
ctx->lambda = 2<<LAMBDA_FRAC_BITS;
return 0;
fail:
return -1;
}
| [
"static av_cold int FUNC_0(DNXHDEncContext *ctx)\n{",
"FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);",
"if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)\nFF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);",
"ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8;",
"ctx->qscale = 1;",
"ctx->lambda = 2<<LAMBDA_FRAC_BITS;",
"return 0;",
"fail:\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
]
] |
23,219 | void qemu_system_killed(int signal, pid_t pid)
{
shutdown_signal = signal;
shutdown_pid = pid;
no_shutdown = 0;
/* Cannot call qemu_system_shutdown_request directly because
* we are in a signal handler.
*/
shutdown_requested = 1;
qemu_notify_event();
}
| true | qemu | aedbe19297907143f17b733a7ff0e0534377bed1 | void qemu_system_killed(int signal, pid_t pid)
{
shutdown_signal = signal;
shutdown_pid = pid;
no_shutdown = 0;
shutdown_requested = 1;
qemu_notify_event();
}
| {
"code": [
" shutdown_requested = 1;",
" shutdown_requested = 1;"
],
"line_no": [
19,
19
]
} | void FUNC_0(int VAR_0, pid_t VAR_1)
{
shutdown_signal = VAR_0;
shutdown_pid = VAR_1;
no_shutdown = 0;
shutdown_requested = 1;
qemu_notify_event();
}
| [
"void FUNC_0(int VAR_0, pid_t VAR_1)\n{",
"shutdown_signal = VAR_0;",
"shutdown_pid = VAR_1;",
"no_shutdown = 0;",
"shutdown_requested = 1;",
"qemu_notify_event();",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19
],
[
21
],
[
23
]
] |
23,220 | static int qemu_chr_open_tty(QemuOpts *opts, CharDriverState **_chr)
{
const char *filename = qemu_opt_get(opts, "path");
CharDriverState *chr;
int fd;
TFR(fd = qemu_open(filename, O_RDWR | O_NONBLOCK));
if (fd < 0) {
return -errno;
}
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
*_chr = chr;
return 0;
}
| true | qemu | 1f51470d044852592922f91000e741c381582cdc | static int qemu_chr_open_tty(QemuOpts *opts, CharDriverState **_chr)
{
const char *filename = qemu_opt_get(opts, "path");
CharDriverState *chr;
int fd;
TFR(fd = qemu_open(filename, O_RDWR | O_NONBLOCK));
if (fd < 0) {
return -errno;
}
tty_serial_init(fd, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(fd, fd);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
*_chr = chr;
return 0;
}
| {
"code": [
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return 0;",
" return -errno;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return -errno;",
" *_chr = chr;",
" return 0;",
"static int qemu_chr_open_tty(QemuOpts *opts, CharDriverState **_chr)",
" TFR(fd = qemu_open(filename, O_RDWR | O_NONBLOCK));",
" return -errno;",
" *_chr = chr;",
" return 0;",
" if (fd < 0) {",
" return -errno;",
" return -errno;",
" *_chr = chr;",
" return 0;",
" if (fd < 0) {",
" return -errno;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" return 0;",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;",
" if (fd < 0) {",
" *_chr = chr;",
" return 0;",
" *_chr = chr;",
" return 0;"
],
"line_no": [
31,
33,
31,
33,
31,
33,
33,
17,
33,
33,
31,
33,
17,
31,
33,
1,
13,
17,
31,
33,
15,
17,
17,
31,
33,
15,
17,
31,
33,
31,
33,
31,
33,
33,
31,
33,
31,
33,
15,
31,
33,
31,
33
]
} | static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{
const char *VAR_2 = qemu_opt_get(VAR_0, "path");
CharDriverState *chr;
int VAR_3;
TFR(VAR_3 = qemu_open(VAR_2, O_RDWR | O_NONBLOCK));
if (VAR_3 < 0) {
return -errno;
}
tty_serial_init(VAR_3, 115200, 'N', 8, 1);
chr = qemu_chr_open_fd(VAR_3, VAR_3);
chr->chr_ioctl = tty_serial_ioctl;
chr->chr_close = qemu_chr_close_tty;
*VAR_1 = chr;
return 0;
}
| [
"static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{",
"const char *VAR_2 = qemu_opt_get(VAR_0, \"path\");",
"CharDriverState *chr;",
"int VAR_3;",
"TFR(VAR_3 = qemu_open(VAR_2, O_RDWR | O_NONBLOCK));",
"if (VAR_3 < 0) {",
"return -errno;",
"}",
"tty_serial_init(VAR_3, 115200, 'N', 8, 1);",
"chr = qemu_chr_open_fd(VAR_3, VAR_3);",
"chr->chr_ioctl = tty_serial_ioctl;",
"chr->chr_close = qemu_chr_close_tty;",
"*VAR_1 = chr;",
"return 0;",
"}"
] | [
1,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
]
] |
23,221 | static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
{
USBHubState *s = (USBHubState *)dev;
int ret;
switch(p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
USBHubPort *port;
unsigned int status;
uint8_t buf[4];
int i, n;
n = (NUM_PORTS + 1 + 7) / 8;
if (p->iov.size == 1) { /* FreeBSD workaround */
n = 1;
} else if (n > p->iov.size) {
return USB_RET_BABBLE;
}
status = 0;
for(i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
if (port->wPortChange)
status |= (1 << (i + 1));
}
if (status != 0) {
for(i = 0; i < n; i++) {
buf[i] = status >> (8 * i);
}
usb_packet_copy(p, buf, n);
ret = n;
} else {
ret = USB_RET_NAK; /* usb11 11.13.1 */
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
{
USBHubState *s = (USBHubState *)dev;
int ret;
switch(p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
USBHubPort *port;
unsigned int status;
uint8_t buf[4];
int i, n;
n = (NUM_PORTS + 1 + 7) / 8;
if (p->iov.size == 1) {
n = 1;
} else if (n > p->iov.size) {
return USB_RET_BABBLE;
}
status = 0;
for(i = 0; i < NUM_PORTS; i++) {
port = &s->ports[i];
if (port->wPortChange)
status |= (1 << (i + 1));
}
if (status != 0) {
for(i = 0; i < n; i++) {
buf[i] = status >> (8 * i);
}
usb_packet_copy(p, buf, n);
ret = n;
} else {
ret = USB_RET_NAK;
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBHubState *s = (USBHubState *)VAR_0;
int VAR_2;
switch(VAR_1->pid) {
case USB_TOKEN_IN:
if (VAR_1->devep == 1) {
USBHubPort *port;
unsigned int VAR_3;
uint8_t buf[4];
int VAR_4, VAR_5;
VAR_5 = (NUM_PORTS + 1 + 7) / 8;
if (VAR_1->iov.size == 1) {
VAR_5 = 1;
} else if (VAR_5 > VAR_1->iov.size) {
return USB_RET_BABBLE;
}
VAR_3 = 0;
for(VAR_4 = 0; VAR_4 < NUM_PORTS; VAR_4++) {
port = &s->ports[VAR_4];
if (port->wPortChange)
VAR_3 |= (1 << (VAR_4 + 1));
}
if (VAR_3 != 0) {
for(VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {
buf[VAR_4] = VAR_3 >> (8 * VAR_4);
}
usb_packet_copy(VAR_1, buf, VAR_5);
VAR_2 = VAR_5;
} else {
VAR_2 = USB_RET_NAK;
}
} else {
goto fail;
}
break;
case USB_TOKEN_OUT:
default:
fail:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBHubState *s = (USBHubState *)VAR_0;",
"int VAR_2;",
"switch(VAR_1->pid) {",
"case USB_TOKEN_IN:\nif (VAR_1->devep == 1) {",
"USBHubPort *port;",
"unsigned int VAR_3;",
"uint8_t buf[4];",
"int VAR_4, VAR_5;",
"VAR_5 = (NUM_PORTS + 1 + 7) / 8;",
"if (VAR_1->iov.size == 1) {",
"VAR_5 = 1;",
"} else if (VAR_5 > VAR_1->iov.size) {",
"return USB_RET_BABBLE;",
"}",
"VAR_3 = 0;",
"for(VAR_4 = 0; VAR_4 < NUM_PORTS; VAR_4++) {",
"port = &s->ports[VAR_4];",
"if (port->wPortChange)\nVAR_3 |= (1 << (VAR_4 + 1));",
"}",
"if (VAR_3 != 0) {",
"for(VAR_4 = 0; VAR_4 < VAR_5; VAR_4++) {",
"buf[VAR_4] = VAR_3 >> (8 * VAR_4);",
"}",
"usb_packet_copy(VAR_1, buf, VAR_5);",
"VAR_2 = VAR_5;",
"} else {",
"VAR_2 = USB_RET_NAK;",
"}",
"} else {",
"goto fail;",
"}",
"break;",
"case USB_TOKEN_OUT:\ndefault:\nfail:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
]
] |
23,222 | static char *vio_format_dev_name(VIOsPAPRDevice *dev)
{
VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
char *name;
/* Device tree style name device@reg */
if (asprintf(&name, "%s@%x", info->dt_name, dev->reg) < 0) {
return NULL;
}
return name;
}
| false | qemu | 3954d33ab7f82f5a5fa0ced231849920265a5fec | static char *vio_format_dev_name(VIOsPAPRDevice *dev)
{
VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
char *name;
if (asprintf(&name, "%s@%x", info->dt_name, dev->reg) < 0) {
return NULL;
}
return name;
}
| {
"code": [],
"line_no": []
} | static char *FUNC_0(VIOsPAPRDevice *VAR_0)
{
VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&VAR_0->qdev);
char *VAR_1;
if (asprintf(&VAR_1, "%s@%x", info->dt_name, VAR_0->reg) < 0) {
return NULL;
}
return VAR_1;
}
| [
"static char *FUNC_0(VIOsPAPRDevice *VAR_0)\n{",
"VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&VAR_0->qdev);",
"char *VAR_1;",
"if (asprintf(&VAR_1, \"%s@%x\", info->dt_name, VAR_0->reg) < 0) {",
"return NULL;",
"}",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
23,223 | static int load_option_rom(const char *oprom, target_phys_addr_t start,
target_phys_addr_t end)
{
int size;
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, oprom);
if (filename) {
size = get_image_size(filename);
if (size > 0 && start + size > end) {
fprintf(stderr, "Not enough space to load option rom '%s'\n",
oprom);
exit(1);
}
size = load_image_targphys(filename, start, end - start);
qemu_free(filename);
} else {
size = -1;
}
if (size < 0) {
fprintf(stderr, "Could not load option rom '%s'\n", oprom);
exit(1);
}
/* Round up optiom rom size to the next 2k boundary */
size = (size + 2047) & ~2047;
option_rom_setup_reset(start, size);
return size;
}
| false | qemu | 45a50b1668822c23afc2a89f724654e176518bc4 | static int load_option_rom(const char *oprom, target_phys_addr_t start,
target_phys_addr_t end)
{
int size;
char *filename;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, oprom);
if (filename) {
size = get_image_size(filename);
if (size > 0 && start + size > end) {
fprintf(stderr, "Not enough space to load option rom '%s'\n",
oprom);
exit(1);
}
size = load_image_targphys(filename, start, end - start);
qemu_free(filename);
} else {
size = -1;
}
if (size < 0) {
fprintf(stderr, "Could not load option rom '%s'\n", oprom);
exit(1);
}
size = (size + 2047) & ~2047;
option_rom_setup_reset(start, size);
return size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, target_phys_addr_t VAR_1,
target_phys_addr_t VAR_2)
{
int VAR_3;
char *VAR_4;
VAR_4 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0);
if (VAR_4) {
VAR_3 = get_image_size(VAR_4);
if (VAR_3 > 0 && VAR_1 + VAR_3 > VAR_2) {
fprintf(stderr, "Not enough space to load option rom '%s'\n",
VAR_0);
exit(1);
}
VAR_3 = load_image_targphys(VAR_4, VAR_1, VAR_2 - VAR_1);
qemu_free(VAR_4);
} else {
VAR_3 = -1;
}
if (VAR_3 < 0) {
fprintf(stderr, "Could not load option rom '%s'\n", VAR_0);
exit(1);
}
VAR_3 = (VAR_3 + 2047) & ~2047;
option_rom_setup_reset(VAR_1, VAR_3);
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0, target_phys_addr_t VAR_1,\ntarget_phys_addr_t VAR_2)\n{",
"int VAR_3;",
"char *VAR_4;",
"VAR_4 = qemu_find_file(QEMU_FILE_TYPE_BIOS, VAR_0);",
"if (VAR_4) {",
"VAR_3 = get_image_size(VAR_4);",
"if (VAR_3 > 0 && VAR_1 + VAR_3 > VAR_2) {",
"fprintf(stderr, \"Not enough space to load option rom '%s'\\n\",\nVAR_0);",
"exit(1);",
"}",
"VAR_3 = load_image_targphys(VAR_4, VAR_1, VAR_2 - VAR_1);",
"qemu_free(VAR_4);",
"} else {",
"VAR_3 = -1;",
"}",
"if (VAR_3 < 0) {",
"fprintf(stderr, \"Could not load option rom '%s'\\n\", VAR_0);",
"exit(1);",
"}",
"VAR_3 = (VAR_3 + 2047) & ~2047;",
"option_rom_setup_reset(VAR_1, VAR_3);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
23,224 | static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
BlockDriverState *bs,
QDict *options,
int flags,
const BdrvChildRole *role,
QDict *parent_options,
int parent_flags)
{
assert(bs != NULL);
BlockReopenQueueEntry *bs_entry;
BdrvChild *child;
QDict *old_options, *explicit_options;
if (bs_queue == NULL) {
bs_queue = g_new0(BlockReopenQueue, 1);
QSIMPLEQ_INIT(bs_queue);
}
if (!options) {
options = qdict_new();
}
/*
* Precedence of options:
* 1. Explicitly passed in options (highest)
* 2. Set in flags (only for top level)
* 3. Retained from explicitly set options of bs
* 4. Inherited from parent node
* 5. Retained from effective options of bs
*/
if (!parent_options) {
/*
* Any setting represented by flags is always updated. If the
* corresponding QDict option is set, it takes precedence. Otherwise
* the flag is translated into a QDict option. The old setting of bs is
* not considered.
*/
update_options_from_flags(options, flags);
}
/* Old explicitly set values (don't overwrite by inherited value) */
old_options = qdict_clone_shallow(bs->explicit_options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
explicit_options = qdict_clone_shallow(options);
/* Inherit from parent node */
if (parent_options) {
assert(!flags);
role->inherit_options(&flags, options, parent_flags, parent_options);
}
/* Old values are used for options that aren't set yet */
old_options = qdict_clone_shallow(bs->options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
/* bdrv_open() masks this flag out */
flags &= ~BDRV_O_PROTOCOL;
QLIST_FOREACH(child, &bs->children, next) {
QDict *new_child_options;
char *child_key_dot;
/* reopen can only change the options of block devices that were
* implicitly created and inherited options. For other (referenced)
* block devices, a syntax like "backing.foo" results in an error. */
if (child->bs->inherits_from != bs) {
continue;
}
child_key_dot = g_strdup_printf("%s.", child->name);
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0,
child->role, options, flags);
}
bs_entry = g_new0(BlockReopenQueueEntry, 1);
QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
bs_entry->state.bs = bs;
bs_entry->state.options = options;
bs_entry->state.explicit_options = explicit_options;
bs_entry->state.flags = flags;
return bs_queue;
}
| false | qemu | 5b7ba05fe7313b03712e129a86fa70c2c215e908 | static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
BlockDriverState *bs,
QDict *options,
int flags,
const BdrvChildRole *role,
QDict *parent_options,
int parent_flags)
{
assert(bs != NULL);
BlockReopenQueueEntry *bs_entry;
BdrvChild *child;
QDict *old_options, *explicit_options;
if (bs_queue == NULL) {
bs_queue = g_new0(BlockReopenQueue, 1);
QSIMPLEQ_INIT(bs_queue);
}
if (!options) {
options = qdict_new();
}
if (!parent_options) {
update_options_from_flags(options, flags);
}
old_options = qdict_clone_shallow(bs->explicit_options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
explicit_options = qdict_clone_shallow(options);
if (parent_options) {
assert(!flags);
role->inherit_options(&flags, options, parent_flags, parent_options);
}
old_options = qdict_clone_shallow(bs->options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
flags &= ~BDRV_O_PROTOCOL;
QLIST_FOREACH(child, &bs->children, next) {
QDict *new_child_options;
char *child_key_dot;
if (child->bs->inherits_from != bs) {
continue;
}
child_key_dot = g_strdup_printf("%s.", child->name);
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0,
child->role, options, flags);
}
bs_entry = g_new0(BlockReopenQueueEntry, 1);
QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
bs_entry->state.bs = bs;
bs_entry->state.options = options;
bs_entry->state.explicit_options = explicit_options;
bs_entry->state.flags = flags;
return bs_queue;
}
| {
"code": [],
"line_no": []
} | static BlockReopenQueue *FUNC_0(BlockReopenQueue *bs_queue,
BlockDriverState *bs,
QDict *options,
int flags,
const BdrvChildRole *role,
QDict *parent_options,
int parent_flags)
{
assert(bs != NULL);
BlockReopenQueueEntry *bs_entry;
BdrvChild *child;
QDict *old_options, *explicit_options;
if (bs_queue == NULL) {
bs_queue = g_new0(BlockReopenQueue, 1);
QSIMPLEQ_INIT(bs_queue);
}
if (!options) {
options = qdict_new();
}
if (!parent_options) {
update_options_from_flags(options, flags);
}
old_options = qdict_clone_shallow(bs->explicit_options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
explicit_options = qdict_clone_shallow(options);
if (parent_options) {
assert(!flags);
role->inherit_options(&flags, options, parent_flags, parent_options);
}
old_options = qdict_clone_shallow(bs->options);
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
flags &= ~BDRV_O_PROTOCOL;
QLIST_FOREACH(child, &bs->children, next) {
QDict *new_child_options;
char *child_key_dot;
if (child->bs->inherits_from != bs) {
continue;
}
child_key_dot = g_strdup_printf("%s.", child->name);
qdict_extract_subqdict(options, &new_child_options, child_key_dot);
g_free(child_key_dot);
FUNC_0(bs_queue, child->bs, new_child_options, 0,
child->role, options, flags);
}
bs_entry = g_new0(BlockReopenQueueEntry, 1);
QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
bs_entry->state.bs = bs;
bs_entry->state.options = options;
bs_entry->state.explicit_options = explicit_options;
bs_entry->state.flags = flags;
return bs_queue;
}
| [
"static BlockReopenQueue *FUNC_0(BlockReopenQueue *bs_queue,\nBlockDriverState *bs,\nQDict *options,\nint flags,\nconst BdrvChildRole *role,\nQDict *parent_options,\nint parent_flags)\n{",
"assert(bs != NULL);",
"BlockReopenQueueEntry *bs_entry;",
"BdrvChild *child;",
"QDict *old_options, *explicit_options;",
"if (bs_queue == NULL) {",
"bs_queue = g_new0(BlockReopenQueue, 1);",
"QSIMPLEQ_INIT(bs_queue);",
"}",
"if (!options) {",
"options = qdict_new();",
"}",
"if (!parent_options) {",
"update_options_from_flags(options, flags);",
"}",
"old_options = qdict_clone_shallow(bs->explicit_options);",
"bdrv_join_options(bs, options, old_options);",
"QDECREF(old_options);",
"explicit_options = qdict_clone_shallow(options);",
"if (parent_options) {",
"assert(!flags);",
"role->inherit_options(&flags, options, parent_flags, parent_options);",
"}",
"old_options = qdict_clone_shallow(bs->options);",
"bdrv_join_options(bs, options, old_options);",
"QDECREF(old_options);",
"flags &= ~BDRV_O_PROTOCOL;",
"QLIST_FOREACH(child, &bs->children, next) {",
"QDict *new_child_options;",
"char *child_key_dot;",
"if (child->bs->inherits_from != bs) {",
"continue;",
"}",
"child_key_dot = g_strdup_printf(\"%s.\", child->name);",
"qdict_extract_subqdict(options, &new_child_options, child_key_dot);",
"g_free(child_key_dot);",
"FUNC_0(bs_queue, child->bs, new_child_options, 0,\nchild->role, options, flags);",
"}",
"bs_entry = g_new0(BlockReopenQueueEntry, 1);",
"QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);",
"bs_entry->state.bs = bs;",
"bs_entry->state.options = options;",
"bs_entry->state.explicit_options = explicit_options;",
"bs_entry->state.flags = flags;",
"return bs_queue;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
43
],
[
65
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
95
],
[
101
],
[
103
],
[
105
],
[
107
],
[
113
],
[
115
],
[
117
],
[
123
],
[
127
],
[
129
],
[
131
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
157,
159
],
[
161
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183
]
] |
23,225 | static void xilinx_axidma_init(Object *obj)
{
XilinxAXIDMA *s = XILINX_AXI_DMA(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
Error *errp = NULL;
object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE,
(Object **) &s->tx_dev, NULL);
object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &errp);
assert_no_error(errp);
sysbus_init_irq(sbd, &s->streams[0].irq);
sysbus_init_irq(sbd, &s->streams[1].irq);
memory_region_init_io(&s->iomem, &axidma_ops, s,
"xlnx.axi-dma", R_MAX * 4 * 2);
sysbus_init_mmio(sbd, &s->iomem);
}
| false | qemu | 42bb9c9178ae7ac4c439172b1ae99cc29188a5c6 | static void xilinx_axidma_init(Object *obj)
{
XilinxAXIDMA *s = XILINX_AXI_DMA(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
Error *errp = NULL;
object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE,
(Object **) &s->tx_dev, NULL);
object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &errp);
assert_no_error(errp);
sysbus_init_irq(sbd, &s->streams[0].irq);
sysbus_init_irq(sbd, &s->streams[1].irq);
memory_region_init_io(&s->iomem, &axidma_ops, s,
"xlnx.axi-dma", R_MAX * 4 * 2);
sysbus_init_mmio(sbd, &s->iomem);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
XilinxAXIDMA *s = XILINX_AXI_DMA(VAR_0);
SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);
Error *errp = NULL;
object_property_add_link(VAR_0, "axistream-connected", TYPE_STREAM_SLAVE,
(Object **) &s->tx_dev, NULL);
object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &errp);
assert_no_error(errp);
sysbus_init_irq(sbd, &s->streams[0].irq);
sysbus_init_irq(sbd, &s->streams[1].irq);
memory_region_init_io(&s->iomem, &axidma_ops, s,
"xlnx.axi-dma", R_MAX * 4 * 2);
sysbus_init_mmio(sbd, &s->iomem);
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"XilinxAXIDMA *s = XILINX_AXI_DMA(VAR_0);",
"SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);",
"Error *errp = NULL;",
"object_property_add_link(VAR_0, \"axistream-connected\", TYPE_STREAM_SLAVE,\n(Object **) &s->tx_dev, NULL);",
"object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);",
"object_property_add_child(OBJECT(s), \"axistream-connected-target\",\n(Object *)&s->rx_data_dev, &errp);",
"assert_no_error(errp);",
"sysbus_init_irq(sbd, &s->streams[0].irq);",
"sysbus_init_irq(sbd, &s->streams[1].irq);",
"memory_region_init_io(&s->iomem, &axidma_ops, s,\n\"xlnx.axi-dma\", R_MAX * 4 * 2);",
"sysbus_init_mmio(sbd, &s->iomem);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
25
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
]
] |
23,226 | void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
{
TranslationBlock *tb;
CPUState *saved_env;
unsigned long pc;
int ret;
/* XXX: hack to restore env in all cases, even if not called from
generated code */
saved_env = env;
env = cpu_single_env;
D_LOG("%s pc=%x tpc=%x ra=%x\n", __func__,
env->pc, env->debug1, retaddr);
ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx);
if (unlikely(ret)) {
if (retaddr) {
/* now we have a real cpu fault */
pc = (unsigned long)retaddr;
tb = tb_find_pc(pc);
if (tb) {
/* the PC is inside the translated code. It means that we have
a virtual CPU fault */
cpu_restore_state(tb, env, pc);
/* Evaluate flags after retranslation. */
helper_top_evaluate_flags();
}
}
cpu_loop_exit(env);
}
env = saved_env;
}
| false | qemu | bccd9ec5f098668576342c83d90d6d6833d61d33 | void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr)
{
TranslationBlock *tb;
CPUState *saved_env;
unsigned long pc;
int ret;
saved_env = env;
env = cpu_single_env;
D_LOG("%s pc=%x tpc=%x ra=%x\n", __func__,
env->pc, env->debug1, retaddr);
ret = cpu_cris_handle_mmu_fault(env, addr, is_write, mmu_idx);
if (unlikely(ret)) {
if (retaddr) {
pc = (unsigned long)retaddr;
tb = tb_find_pc(pc);
if (tb) {
cpu_restore_state(tb, env, pc);
helper_top_evaluate_flags();
}
}
cpu_loop_exit(env);
}
env = saved_env;
}
| {
"code": [],
"line_no": []
} | void FUNC_0 (target_ulong VAR_0, int VAR_1, int VAR_2, void *VAR_3)
{
TranslationBlock *tb;
CPUState *saved_env;
unsigned long VAR_4;
int VAR_5;
saved_env = env;
env = cpu_single_env;
D_LOG("%s VAR_4=%x tpc=%x ra=%x\n", __func__,
env->VAR_4, env->debug1, VAR_3);
VAR_5 = cpu_cris_handle_mmu_fault(env, VAR_0, VAR_1, VAR_2);
if (unlikely(VAR_5)) {
if (VAR_3) {
VAR_4 = (unsigned long)VAR_3;
tb = tb_find_pc(VAR_4);
if (tb) {
cpu_restore_state(tb, env, VAR_4);
helper_top_evaluate_flags();
}
}
cpu_loop_exit(env);
}
env = saved_env;
}
| [
"void FUNC_0 (target_ulong VAR_0, int VAR_1, int VAR_2, void *VAR_3)\n{",
"TranslationBlock *tb;",
"CPUState *saved_env;",
"unsigned long VAR_4;",
"int VAR_5;",
"saved_env = env;",
"env = cpu_single_env;",
"D_LOG(\"%s VAR_4=%x tpc=%x ra=%x\\n\", __func__,\nenv->VAR_4, env->debug1, VAR_3);",
"VAR_5 = cpu_cris_handle_mmu_fault(env, VAR_0, VAR_1, VAR_2);",
"if (unlikely(VAR_5)) {",
"if (VAR_3) {",
"VAR_4 = (unsigned long)VAR_3;",
"tb = tb_find_pc(VAR_4);",
"if (tb) {",
"cpu_restore_state(tb, env, VAR_4);",
"helper_top_evaluate_flags();",
"}",
"}",
"cpu_loop_exit(env);",
"}",
"env = saved_env;",
"}"
] | [
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
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
23,228 | static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
{
DiracContext *s = avctx->priv_data;
DiracFrame *picture = data;
uint8_t *buf = pkt->data;
int buf_size = pkt->size;
int i, data_unit_size, buf_idx = 0;
/* release unused frames */
for (i = 0; i < MAX_FRAMES; i++)
if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
avctx->release_buffer(avctx, &s->all_frames[i].avframe);
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
}
s->current_picture = NULL;
*data_size = 0;
/* end of stream, so flush delayed pics */
if (buf_size == 0)
return get_delayed_pic(s, (AVFrame *)data, data_size);
for (;;) {
/*[DIRAC_STD] Here starts the code from parse_info() defined in 9.6
[DIRAC_STD] PARSE_INFO_PREFIX = "BBCD" as defined in ISO/IEC 646
BBCD start code search */
for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) {
if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' &&
buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D')
break;
}
/* BBCD found or end of data */
if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size)
break;
data_unit_size = AV_RB32(buf+buf_idx+5);
if (buf_idx + data_unit_size > buf_size || !data_unit_size) {
if(buf_idx + data_unit_size > buf_size)
av_log(s->avctx, AV_LOG_ERROR,
"Data unit with size %d is larger than input buffer, discarding\n",
data_unit_size);
buf_idx += 4;
continue;
}
/* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence() */
if (dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size))
{
av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
return -1;
}
buf_idx += data_unit_size;
}
if (!s->current_picture)
return 0;
if (s->current_picture->avframe.display_picture_number > s->frame_number) {
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
s->current_picture->avframe.reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
int min_num = s->delay_frames[0]->avframe.display_picture_number;
/* Too many delayed frames, so we display the frame with the lowest pts */
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
delayed_frame = s->delay_frames[0];
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->avframe.display_picture_number < min_num)
min_num = s->delay_frames[i]->avframe.display_picture_number;
delayed_frame = remove_frame(s->delay_frames, min_num);
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
}
if (delayed_frame) {
delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
*(AVFrame*)data = delayed_frame->avframe;
*data_size = sizeof(AVFrame);
}
} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
/* The right frame at the right time :-) */
*(AVFrame*)data = s->current_picture->avframe;
*data_size = sizeof(AVFrame);
}
if (*data_size)
s->frame_number = picture->avframe.display_picture_number + 1;
return buf_idx;
}
| false | FFmpeg | 6a052e64b5d14ce2800eb45c699857347d9a78c9 | static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
{
DiracContext *s = avctx->priv_data;
DiracFrame *picture = data;
uint8_t *buf = pkt->data;
int buf_size = pkt->size;
int i, data_unit_size, buf_idx = 0;
for (i = 0; i < MAX_FRAMES; i++)
if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
avctx->release_buffer(avctx, &s->all_frames[i].avframe);
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
}
s->current_picture = NULL;
*data_size = 0;
if (buf_size == 0)
return get_delayed_pic(s, (AVFrame *)data, data_size);
for (;;) {
for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) {
if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' &&
buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D')
break;
}
if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size)
break;
data_unit_size = AV_RB32(buf+buf_idx+5);
if (buf_idx + data_unit_size > buf_size || !data_unit_size) {
if(buf_idx + data_unit_size > buf_size)
av_log(s->avctx, AV_LOG_ERROR,
"Data unit with size %d is larger than input buffer, discarding\n",
data_unit_size);
buf_idx += 4;
continue;
}
if (dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size))
{
av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
return -1;
}
buf_idx += data_unit_size;
}
if (!s->current_picture)
return 0;
if (s->current_picture->avframe.display_picture_number > s->frame_number) {
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
s->current_picture->avframe.reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
int min_num = s->delay_frames[0]->avframe.display_picture_number;
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
delayed_frame = s->delay_frames[0];
for (i = 1; s->delay_frames[i]; i++)
if (s->delay_frames[i]->avframe.display_picture_number < min_num)
min_num = s->delay_frames[i]->avframe.display_picture_number;
delayed_frame = remove_frame(s->delay_frames, min_num);
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
}
if (delayed_frame) {
delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
*(AVFrame*)data = delayed_frame->avframe;
*data_size = sizeof(AVFrame);
}
} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
*(AVFrame*)data = s->current_picture->avframe;
*data_size = sizeof(AVFrame);
}
if (*data_size)
s->frame_number = picture->avframe.display_picture_number + 1;
return buf_idx;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
DiracContext *s = VAR_0->priv_data;
DiracFrame *picture = VAR_1;
uint8_t *buf = VAR_3->VAR_1;
int VAR_4 = VAR_3->size;
int VAR_5, VAR_6, VAR_7 = 0;
for (VAR_5 = 0; VAR_5 < MAX_FRAMES; VAR_5++)
if (s->all_frames[VAR_5].avframe.VAR_1[0] && !s->all_frames[VAR_5].avframe.reference) {
VAR_0->release_buffer(VAR_0, &s->all_frames[VAR_5].avframe);
memset(s->all_frames[VAR_5].interpolated, 0, sizeof(s->all_frames[VAR_5].interpolated));
}
s->current_picture = NULL;
*VAR_2 = 0;
if (VAR_4 == 0)
return get_delayed_pic(s, (AVFrame *)VAR_1, VAR_2);
for (;;) {
for (; VAR_7 + DATA_UNIT_HEADER_SIZE < VAR_4; VAR_7++) {
if (buf[VAR_7 ] == 'B' && buf[VAR_7+1] == 'B' &&
buf[VAR_7+2] == 'C' && buf[VAR_7+3] == 'D')
break;
}
if (VAR_7 + DATA_UNIT_HEADER_SIZE >= VAR_4)
break;
VAR_6 = AV_RB32(buf+VAR_7+5);
if (VAR_7 + VAR_6 > VAR_4 || !VAR_6) {
if(VAR_7 + VAR_6 > VAR_4)
av_log(s->VAR_0, AV_LOG_ERROR,
"Data unit with size %d is larger than input buffer, discarding\n",
VAR_6);
VAR_7 += 4;
continue;
}
if (dirac_decode_data_unit(VAR_0, buf+VAR_7, VAR_6))
{
av_log(s->VAR_0, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
return -1;
}
VAR_7 += VAR_6;
}
if (!s->current_picture)
return 0;
if (s->current_picture->avframe.display_picture_number > s->frame_number) {
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
s->current_picture->avframe.reference |= DELAYED_PIC_REF;
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
int VAR_8 = s->delay_frames[0]->avframe.display_picture_number;
av_log(VAR_0, AV_LOG_ERROR, "Delay frame overflow\n");
delayed_frame = s->delay_frames[0];
for (VAR_5 = 1; s->delay_frames[VAR_5]; VAR_5++)
if (s->delay_frames[VAR_5]->avframe.display_picture_number < VAR_8)
VAR_8 = s->delay_frames[VAR_5]->avframe.display_picture_number;
delayed_frame = remove_frame(s->delay_frames, VAR_8);
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
}
if (delayed_frame) {
delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
*(AVFrame*)VAR_1 = delayed_frame->avframe;
*VAR_2 = sizeof(AVFrame);
}
} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
*(AVFrame*)VAR_1 = s->current_picture->avframe;
*VAR_2 = sizeof(AVFrame);
}
if (*VAR_2)
s->frame_number = picture->avframe.display_picture_number + 1;
return VAR_7;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"DiracContext *s = VAR_0->priv_data;",
"DiracFrame *picture = VAR_1;",
"uint8_t *buf = VAR_3->VAR_1;",
"int VAR_4 = VAR_3->size;",
"int VAR_5, VAR_6, VAR_7 = 0;",
"for (VAR_5 = 0; VAR_5 < MAX_FRAMES; VAR_5++)",
"if (s->all_frames[VAR_5].avframe.VAR_1[0] && !s->all_frames[VAR_5].avframe.reference) {",
"VAR_0->release_buffer(VAR_0, &s->all_frames[VAR_5].avframe);",
"memset(s->all_frames[VAR_5].interpolated, 0, sizeof(s->all_frames[VAR_5].interpolated));",
"}",
"s->current_picture = NULL;",
"*VAR_2 = 0;",
"if (VAR_4 == 0)\nreturn get_delayed_pic(s, (AVFrame *)VAR_1, VAR_2);",
"for (;;) {",
"for (; VAR_7 + DATA_UNIT_HEADER_SIZE < VAR_4; VAR_7++) {",
"if (buf[VAR_7 ] == 'B' && buf[VAR_7+1] == 'B' &&\nbuf[VAR_7+2] == 'C' && buf[VAR_7+3] == 'D')\nbreak;",
"}",
"if (VAR_7 + DATA_UNIT_HEADER_SIZE >= VAR_4)\nbreak;",
"VAR_6 = AV_RB32(buf+VAR_7+5);",
"if (VAR_7 + VAR_6 > VAR_4 || !VAR_6) {",
"if(VAR_7 + VAR_6 > VAR_4)\nav_log(s->VAR_0, AV_LOG_ERROR,\n\"Data unit with size %d is larger than input buffer, discarding\\n\",\nVAR_6);",
"VAR_7 += 4;",
"continue;",
"}",
"if (dirac_decode_data_unit(VAR_0, buf+VAR_7, VAR_6))\n{",
"av_log(s->VAR_0, AV_LOG_ERROR,\"Error in dirac_decode_data_unit\\n\");",
"return -1;",
"}",
"VAR_7 += VAR_6;",
"}",
"if (!s->current_picture)\nreturn 0;",
"if (s->current_picture->avframe.display_picture_number > s->frame_number) {",
"DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);",
"s->current_picture->avframe.reference |= DELAYED_PIC_REF;",
"if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {",
"int VAR_8 = s->delay_frames[0]->avframe.display_picture_number;",
"av_log(VAR_0, AV_LOG_ERROR, \"Delay frame overflow\\n\");",
"delayed_frame = s->delay_frames[0];",
"for (VAR_5 = 1; s->delay_frames[VAR_5]; VAR_5++)",
"if (s->delay_frames[VAR_5]->avframe.display_picture_number < VAR_8)\nVAR_8 = s->delay_frames[VAR_5]->avframe.display_picture_number;",
"delayed_frame = remove_frame(s->delay_frames, VAR_8);",
"add_frame(s->delay_frames, MAX_DELAY, s->current_picture);",
"}",
"if (delayed_frame) {",
"delayed_frame->avframe.reference ^= DELAYED_PIC_REF;",
"*(AVFrame*)VAR_1 = delayed_frame->avframe;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {",
"*(AVFrame*)VAR_1 = s->current_picture->avframe;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"if (*VAR_2)\ns->frame_number = picture->avframe.display_picture_number + 1;",
"return VAR_7;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
39,
41
],
[
45
],
[
53
],
[
55,
57,
59
],
[
61
],
[
65,
67
],
[
71
],
[
73
],
[
75,
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
113
],
[
115
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
179
],
[
181
]
] |
23,229 | int vfio_spapr_create_window(VFIOContainer *container,
MemoryRegionSection *section,
hwaddr *pgsize)
{
int ret;
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
unsigned pagesize = memory_region_iommu_get_min_page_size(iommu_mr);
unsigned entries, pages;
struct vfio_iommu_spapr_tce_create create = { .argsz = sizeof(create) };
/*
* FIXME: For VFIO iommu types which have KVM acceleration to
* avoid bouncing all map/unmaps through qemu this way, this
* would be the right place to wire that up (tell the KVM
* device emulation the VFIO iommu handles to use).
*/
create.window_size = int128_get64(section->size);
create.page_shift = ctz64(pagesize);
/*
* SPAPR host supports multilevel TCE tables, there is some
* heuristic to decide how many levels we want for our table:
* 0..64 = 1; 65..4096 = 2; 4097..262144 = 3; 262145.. = 4
*/
entries = create.window_size >> create.page_shift;
pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
pages = MAX(pow2ceil(pages) - 1, 1); /* Round up */
create.levels = ctz64(pages) / 6 + 1;
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
if (ret) {
error_report("Failed to create a window, ret = %d (%m)", ret);
return -errno;
}
if (create.start_addr != section->offset_within_address_space) {
vfio_spapr_remove_window(container, create.start_addr);
error_report("Host doesn't support DMA window at %"HWADDR_PRIx", must be %"PRIx64,
section->offset_within_address_space,
(uint64_t)create.start_addr);
return -EINVAL;
}
trace_vfio_spapr_create_window(create.page_shift,
create.window_size,
create.start_addr);
*pgsize = pagesize;
return 0;
}
| false | qemu | e100161b69f8cf56dae866912dfffe7dcd7140af | int vfio_spapr_create_window(VFIOContainer *container,
MemoryRegionSection *section,
hwaddr *pgsize)
{
int ret;
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
unsigned pagesize = memory_region_iommu_get_min_page_size(iommu_mr);
unsigned entries, pages;
struct vfio_iommu_spapr_tce_create create = { .argsz = sizeof(create) };
create.window_size = int128_get64(section->size);
create.page_shift = ctz64(pagesize);
entries = create.window_size >> create.page_shift;
pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
pages = MAX(pow2ceil(pages) - 1, 1);
create.levels = ctz64(pages) / 6 + 1;
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
if (ret) {
error_report("Failed to create a window, ret = %d (%m)", ret);
return -errno;
}
if (create.start_addr != section->offset_within_address_space) {
vfio_spapr_remove_window(container, create.start_addr);
error_report("Host doesn't support DMA window at %"HWADDR_PRIx", must be %"PRIx64,
section->offset_within_address_space,
(uint64_t)create.start_addr);
return -EINVAL;
}
trace_vfio_spapr_create_window(create.page_shift,
create.window_size,
create.start_addr);
*pgsize = pagesize;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(VFIOContainer *VAR_0,
MemoryRegionSection *VAR_1,
hwaddr *VAR_2)
{
int VAR_3;
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(VAR_1->mr);
unsigned VAR_4 = memory_region_iommu_get_min_page_size(iommu_mr);
unsigned VAR_5, VAR_6;
struct vfio_iommu_spapr_tce_create VAR_7 = { .argsz = sizeof(VAR_7) };
VAR_7.window_size = int128_get64(VAR_1->size);
VAR_7.page_shift = ctz64(VAR_4);
VAR_5 = VAR_7.window_size >> VAR_7.page_shift;
VAR_6 = MAX((VAR_5 * sizeof(uint64_t)) / getpagesize(), 1);
VAR_6 = MAX(pow2ceil(VAR_6) - 1, 1);
VAR_7.levels = ctz64(VAR_6) / 6 + 1;
VAR_3 = ioctl(VAR_0->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &VAR_7);
if (VAR_3) {
error_report("Failed to VAR_7 a window, VAR_3 = %d (%m)", VAR_3);
return -errno;
}
if (VAR_7.start_addr != VAR_1->offset_within_address_space) {
vfio_spapr_remove_window(VAR_0, VAR_7.start_addr);
error_report("Host doesn't support DMA window at %"HWADDR_PRIx", must be %"PRIx64,
VAR_1->offset_within_address_space,
(uint64_t)VAR_7.start_addr);
return -EINVAL;
}
trace_vfio_spapr_create_window(VAR_7.page_shift,
VAR_7.window_size,
VAR_7.start_addr);
*VAR_2 = VAR_4;
return 0;
}
| [
"int FUNC_0(VFIOContainer *VAR_0,\nMemoryRegionSection *VAR_1,\nhwaddr *VAR_2)\n{",
"int VAR_3;",
"IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(VAR_1->mr);",
"unsigned VAR_4 = memory_region_iommu_get_min_page_size(iommu_mr);",
"unsigned VAR_5, VAR_6;",
"struct vfio_iommu_spapr_tce_create VAR_7 = { .argsz = sizeof(VAR_7) };",
"VAR_7.window_size = int128_get64(VAR_1->size);",
"VAR_7.page_shift = ctz64(VAR_4);",
"VAR_5 = VAR_7.window_size >> VAR_7.page_shift;",
"VAR_6 = MAX((VAR_5 * sizeof(uint64_t)) / getpagesize(), 1);",
"VAR_6 = MAX(pow2ceil(VAR_6) - 1, 1);",
"VAR_7.levels = ctz64(VAR_6) / 6 + 1;",
"VAR_3 = ioctl(VAR_0->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &VAR_7);",
"if (VAR_3) {",
"error_report(\"Failed to VAR_7 a window, VAR_3 = %d (%m)\", VAR_3);",
"return -errno;",
"}",
"if (VAR_7.start_addr != VAR_1->offset_within_address_space) {",
"vfio_spapr_remove_window(VAR_0, VAR_7.start_addr);",
"error_report(\"Host doesn't support DMA window at %\"HWADDR_PRIx\", must be %\"PRIx64,\nVAR_1->offset_within_address_space,\n(uint64_t)VAR_7.start_addr);",
"return -EINVAL;",
"}",
"trace_vfio_spapr_create_window(VAR_7.page_shift,\nVAR_7.window_size,\nVAR_7.start_addr);",
"*VAR_2 = VAR_4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
33
],
[
35
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
75,
77,
79
],
[
81
],
[
83
],
[
85,
87,
89
],
[
91
],
[
95
],
[
97
]
] |
23,230 | main(
int argc,
char *argv[]
) {
GMainLoop *loop;
GIOChannel *channel_stdin;
char *qemu_host;
char *qemu_port;
VCardEmulOptions *command_line_options = NULL;
char *cert_names[MAX_CERTS];
char *emul_args = NULL;
int cert_count = 0;
int c, sock;
if (socket_init() != 0)
return 1;
while ((c = getopt(argc, argv, "c:e:pd:")) != -1) {
switch (c) {
case 'c':
if (cert_count >= MAX_CERTS) {
printf("too many certificates (max = %d)\n", MAX_CERTS);
exit(5);
}
cert_names[cert_count++] = optarg;
break;
case 'e':
emul_args = optarg;
break;
case 'p':
print_usage();
exit(4);
break;
case 'd':
verbose = get_id_from_string(optarg, 1);
break;
}
}
if (argc - optind != 2) {
print_usage();
exit(4);
}
if (cert_count > 0) {
char *new_args;
int len, i;
/* if we've given some -c options, we clearly we want do so some
* software emulation. add that emulation now. this is NSS Emulator
* specific */
if (emul_args == NULL) {
emul_args = (char *)"db=\"/etc/pki/nssdb\"";
}
#define SOFT_STRING ",soft=(,Virtual Reader,CAC,,"
/* 2 == close paren & null */
len = strlen(emul_args) + strlen(SOFT_STRING) + 2;
for (i = 0; i < cert_count; i++) {
len += strlen(cert_names[i])+1; /* 1 == comma */
}
new_args = g_malloc(len);
strcpy(new_args, emul_args);
strcat(new_args, SOFT_STRING);
for (i = 0; i < cert_count; i++) {
strcat(new_args, cert_names[i]);
strcat(new_args, ",");
}
strcat(new_args, ")");
emul_args = new_args;
}
if (emul_args) {
command_line_options = vcard_emul_options(emul_args);
}
qemu_host = g_strdup(argv[argc - 2]);
qemu_port = g_strdup(argv[argc - 1]);
sock = connect_to_qemu(qemu_host, qemu_port);
if (sock == -1) {
fprintf(stderr, "error opening socket, exiting.\n");
exit(5);
}
socket_to_send = g_byte_array_new();
qemu_mutex_init(&socket_to_send_lock);
qemu_mutex_init(&pending_reader_lock);
qemu_cond_init(&pending_reader_condition);
vcard_emul_init(command_line_options);
loop = g_main_loop_new(NULL, true);
printf("> ");
fflush(stdout);
#ifdef _WIN32
channel_stdin = g_io_channel_win32_new_fd(STDIN_FILENO);
#else
channel_stdin = g_io_channel_unix_new(STDIN_FILENO);
#endif
g_io_add_watch(channel_stdin, G_IO_IN, do_command, NULL);
#ifdef _WIN32
channel_socket = g_io_channel_win32_new_socket(sock);
#else
channel_socket = g_io_channel_unix_new(sock);
#endif
g_io_channel_set_encoding(channel_socket, NULL, NULL);
/* we buffer ourself for thread safety reasons */
g_io_channel_set_buffered(channel_socket, FALSE);
/* Send init message, Host responds (and then we send reader attachments) */
VSCMsgInit init = {
.version = htonl(VSCARD_VERSION),
.magic = VSCARD_MAGIC,
.capabilities = {0}
};
send_msg(VSC_Init, 0, &init, sizeof(init));
g_main_loop_run(loop);
g_main_loop_unref(loop);
g_io_channel_unref(channel_stdin);
g_io_channel_unref(channel_socket);
g_byte_array_free(socket_to_send, TRUE);
closesocket(sock);
return 0;
}
| false | qemu | 2a0c46da967e5dc8cfe73b1b6fe7a1600c04f461 | main(
int argc,
char *argv[]
) {
GMainLoop *loop;
GIOChannel *channel_stdin;
char *qemu_host;
char *qemu_port;
VCardEmulOptions *command_line_options = NULL;
char *cert_names[MAX_CERTS];
char *emul_args = NULL;
int cert_count = 0;
int c, sock;
if (socket_init() != 0)
return 1;
while ((c = getopt(argc, argv, "c:e:pd:")) != -1) {
switch (c) {
case 'c':
if (cert_count >= MAX_CERTS) {
printf("too many certificates (max = %d)\n", MAX_CERTS);
exit(5);
}
cert_names[cert_count++] = optarg;
break;
case 'e':
emul_args = optarg;
break;
case 'p':
print_usage();
exit(4);
break;
case 'd':
verbose = get_id_from_string(optarg, 1);
break;
}
}
if (argc - optind != 2) {
print_usage();
exit(4);
}
if (cert_count > 0) {
char *new_args;
int len, i;
if (emul_args == NULL) {
emul_args = (char *)"db=\"/etc/pki/nssdb\"";
}
#define SOFT_STRING ",soft=(,Virtual Reader,CAC,,"
len = strlen(emul_args) + strlen(SOFT_STRING) + 2;
for (i = 0; i < cert_count; i++) {
len += strlen(cert_names[i])+1;
}
new_args = g_malloc(len);
strcpy(new_args, emul_args);
strcat(new_args, SOFT_STRING);
for (i = 0; i < cert_count; i++) {
strcat(new_args, cert_names[i]);
strcat(new_args, ",");
}
strcat(new_args, ")");
emul_args = new_args;
}
if (emul_args) {
command_line_options = vcard_emul_options(emul_args);
}
qemu_host = g_strdup(argv[argc - 2]);
qemu_port = g_strdup(argv[argc - 1]);
sock = connect_to_qemu(qemu_host, qemu_port);
if (sock == -1) {
fprintf(stderr, "error opening socket, exiting.\n");
exit(5);
}
socket_to_send = g_byte_array_new();
qemu_mutex_init(&socket_to_send_lock);
qemu_mutex_init(&pending_reader_lock);
qemu_cond_init(&pending_reader_condition);
vcard_emul_init(command_line_options);
loop = g_main_loop_new(NULL, true);
printf("> ");
fflush(stdout);
#ifdef _WIN32
channel_stdin = g_io_channel_win32_new_fd(STDIN_FILENO);
#else
channel_stdin = g_io_channel_unix_new(STDIN_FILENO);
#endif
g_io_add_watch(channel_stdin, G_IO_IN, do_command, NULL);
#ifdef _WIN32
channel_socket = g_io_channel_win32_new_socket(sock);
#else
channel_socket = g_io_channel_unix_new(sock);
#endif
g_io_channel_set_encoding(channel_socket, NULL, NULL);
g_io_channel_set_buffered(channel_socket, FALSE);
VSCMsgInit init = {
.version = htonl(VSCARD_VERSION),
.magic = VSCARD_MAGIC,
.capabilities = {0}
};
send_msg(VSC_Init, 0, &init, sizeof(init));
g_main_loop_run(loop);
g_main_loop_unref(loop);
g_io_channel_unref(channel_stdin);
g_io_channel_unref(channel_socket);
g_byte_array_free(socket_to_send, TRUE);
closesocket(sock);
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(
int VAR_0,
char *VAR_1[]
) {
GMainLoop *loop;
GIOChannel *channel_stdin;
char *VAR_2;
char *VAR_3;
VCardEmulOptions *command_line_options = NULL;
char *VAR_4[MAX_CERTS];
char *VAR_5 = NULL;
int VAR_6 = 0;
int VAR_7, VAR_8;
if (socket_init() != 0)
return 1;
while ((VAR_7 = getopt(VAR_0, VAR_1, "VAR_7:e:pd:")) != -1) {
switch (VAR_7) {
case 'VAR_7':
if (VAR_6 >= MAX_CERTS) {
printf("too many certificates (max = %d)\n", MAX_CERTS);
exit(5);
}
VAR_4[VAR_6++] = optarg;
break;
case 'e':
VAR_5 = optarg;
break;
case 'p':
print_usage();
exit(4);
break;
case 'd':
verbose = get_id_from_string(optarg, 1);
break;
}
}
if (VAR_0 - optind != 2) {
print_usage();
exit(4);
}
if (VAR_6 > 0) {
char *VAR_9;
int VAR_10, VAR_11;
if (VAR_5 == NULL) {
VAR_5 = (char *)"db=\"/etc/pki/nssdb\"";
}
#define SOFT_STRING ",soft=(,Virtual Reader,CAC,,"
VAR_10 = strlen(VAR_5) + strlen(SOFT_STRING) + 2;
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {
VAR_10 += strlen(VAR_4[VAR_11])+1;
}
VAR_9 = g_malloc(VAR_10);
strcpy(VAR_9, VAR_5);
strcat(VAR_9, SOFT_STRING);
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {
strcat(VAR_9, VAR_4[VAR_11]);
strcat(VAR_9, ",");
}
strcat(VAR_9, ")");
VAR_5 = VAR_9;
}
if (VAR_5) {
command_line_options = vcard_emul_options(VAR_5);
}
VAR_2 = g_strdup(VAR_1[VAR_0 - 2]);
VAR_3 = g_strdup(VAR_1[VAR_0 - 1]);
VAR_8 = connect_to_qemu(VAR_2, VAR_3);
if (VAR_8 == -1) {
fprintf(stderr, "error opening socket, exiting.\n");
exit(5);
}
socket_to_send = g_byte_array_new();
qemu_mutex_init(&socket_to_send_lock);
qemu_mutex_init(&pending_reader_lock);
qemu_cond_init(&pending_reader_condition);
vcard_emul_init(command_line_options);
loop = g_main_loop_new(NULL, true);
printf("> ");
fflush(stdout);
#ifdef _WIN32
channel_stdin = g_io_channel_win32_new_fd(STDIN_FILENO);
#else
channel_stdin = g_io_channel_unix_new(STDIN_FILENO);
#endif
g_io_add_watch(channel_stdin, G_IO_IN, do_command, NULL);
#ifdef _WIN32
channel_socket = g_io_channel_win32_new_socket(VAR_8);
#else
channel_socket = g_io_channel_unix_new(VAR_8);
#endif
g_io_channel_set_encoding(channel_socket, NULL, NULL);
g_io_channel_set_buffered(channel_socket, FALSE);
VSCMsgInit init = {
.version = htonl(VSCARD_VERSION),
.magic = VSCARD_MAGIC,
.capabilities = {0}
};
send_msg(VSC_Init, 0, &init, sizeof(init));
g_main_loop_run(loop);
g_main_loop_unref(loop);
g_io_channel_unref(channel_stdin);
g_io_channel_unref(channel_socket);
g_byte_array_free(socket_to_send, TRUE);
closesocket(VAR_8);
return 0;
}
| [
"FUNC_0(\nint VAR_0,\nchar *VAR_1[]\n) {",
"GMainLoop *loop;",
"GIOChannel *channel_stdin;",
"char *VAR_2;",
"char *VAR_3;",
"VCardEmulOptions *command_line_options = NULL;",
"char *VAR_4[MAX_CERTS];",
"char *VAR_5 = NULL;",
"int VAR_6 = 0;",
"int VAR_7, VAR_8;",
"if (socket_init() != 0)\nreturn 1;",
"while ((VAR_7 = getopt(VAR_0, VAR_1, \"VAR_7:e:pd:\")) != -1) {",
"switch (VAR_7) {",
"case 'VAR_7':\nif (VAR_6 >= MAX_CERTS) {",
"printf(\"too many certificates (max = %d)\\n\", MAX_CERTS);",
"exit(5);",
"}",
"VAR_4[VAR_6++] = optarg;",
"break;",
"case 'e':\nVAR_5 = optarg;",
"break;",
"case 'p':\nprint_usage();",
"exit(4);",
"break;",
"case 'd':\nverbose = get_id_from_string(optarg, 1);",
"break;",
"}",
"}",
"if (VAR_0 - optind != 2) {",
"print_usage();",
"exit(4);",
"}",
"if (VAR_6 > 0) {",
"char *VAR_9;",
"int VAR_10, VAR_11;",
"if (VAR_5 == NULL) {",
"VAR_5 = (char *)\"db=\\\"/etc/pki/nssdb\\\"\";",
"}",
"#define SOFT_STRING \",soft=(,Virtual Reader,CAC,,\"\nVAR_10 = strlen(VAR_5) + strlen(SOFT_STRING) + 2;",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {",
"VAR_10 += strlen(VAR_4[VAR_11])+1;",
"}",
"VAR_9 = g_malloc(VAR_10);",
"strcpy(VAR_9, VAR_5);",
"strcat(VAR_9, SOFT_STRING);",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {",
"strcat(VAR_9, VAR_4[VAR_11]);",
"strcat(VAR_9, \",\");",
"}",
"strcat(VAR_9, \")\");",
"VAR_5 = VAR_9;",
"}",
"if (VAR_5) {",
"command_line_options = vcard_emul_options(VAR_5);",
"}",
"VAR_2 = g_strdup(VAR_1[VAR_0 - 2]);",
"VAR_3 = g_strdup(VAR_1[VAR_0 - 1]);",
"VAR_8 = connect_to_qemu(VAR_2, VAR_3);",
"if (VAR_8 == -1) {",
"fprintf(stderr, \"error opening socket, exiting.\\n\");",
"exit(5);",
"}",
"socket_to_send = g_byte_array_new();",
"qemu_mutex_init(&socket_to_send_lock);",
"qemu_mutex_init(&pending_reader_lock);",
"qemu_cond_init(&pending_reader_condition);",
"vcard_emul_init(command_line_options);",
"loop = g_main_loop_new(NULL, true);",
"printf(\"> \");",
"fflush(stdout);",
"#ifdef _WIN32\nchannel_stdin = g_io_channel_win32_new_fd(STDIN_FILENO);",
"#else\nchannel_stdin = g_io_channel_unix_new(STDIN_FILENO);",
"#endif\ng_io_add_watch(channel_stdin, G_IO_IN, do_command, NULL);",
"#ifdef _WIN32\nchannel_socket = g_io_channel_win32_new_socket(VAR_8);",
"#else\nchannel_socket = g_io_channel_unix_new(VAR_8);",
"#endif\ng_io_channel_set_encoding(channel_socket, NULL, NULL);",
"g_io_channel_set_buffered(channel_socket, FALSE);",
"VSCMsgInit init = {",
".version = htonl(VSCARD_VERSION),\n.magic = VSCARD_MAGIC,\n.capabilities = {0}",
"};",
"send_msg(VSC_Init, 0, &init, sizeof(init));",
"g_main_loop_run(loop);",
"g_main_loop_unref(loop);",
"g_io_channel_unref(channel_stdin);",
"g_io_channel_unref(channel_socket);",
"g_byte_array_free(socket_to_send, TRUE);",
"closesocket(VAR_8);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
105
],
[
107
],
[
109
],
[
111,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
181
],
[
185
],
[
187
],
[
191,
193
],
[
195,
197
],
[
199,
201
],
[
203,
205
],
[
207,
209
],
[
211,
213
],
[
217
],
[
223
],
[
225,
227,
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.