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
|
---|---|---|---|---|---|---|---|---|---|---|
18,995 | ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
Error **errp)
{
ChardevReturn *ret = g_new0(ChardevReturn, 1);
CharDriverState *base, *chr = NULL;
chr = qemu_chr_find(id);
if (chr) {
error_setg(errp, "Chardev '%s' already exists", id);
g_free(ret);
return NULL;
}
switch (backend->kind) {
case CHARDEV_BACKEND_KIND_FILE:
chr = qmp_chardev_open_file(backend->file, errp);
break;
case CHARDEV_BACKEND_KIND_SERIAL:
chr = qmp_chardev_open_serial(backend->serial, errp);
break;
case CHARDEV_BACKEND_KIND_PARALLEL:
chr = qmp_chardev_open_parallel(backend->parallel, errp);
break;
case CHARDEV_BACKEND_KIND_SOCKET:
chr = qmp_chardev_open_socket(backend->socket, errp);
break;
#ifdef HAVE_CHARDEV_TTY
case CHARDEV_BACKEND_KIND_PTY:
{
/* qemu_chr_open_pty sets "path" in opts */
QemuOpts *opts;
opts = qemu_opts_create_nofail(qemu_find_opts("chardev"));
chr = qemu_chr_open_pty(opts);
ret->pty = g_strdup(qemu_opt_get(opts, "path"));
ret->has_pty = true;
qemu_opts_del(opts);
break;
}
#endif
case CHARDEV_BACKEND_KIND_NULL:
chr = qemu_chr_open_null();
break;
case CHARDEV_BACKEND_KIND_MUX:
base = qemu_chr_find(backend->mux->chardev);
if (base == NULL) {
error_setg(errp, "mux: base chardev %s not found",
backend->mux->chardev);
break;
}
chr = qemu_chr_open_mux(base);
break;
case CHARDEV_BACKEND_KIND_MSMOUSE:
chr = qemu_chr_open_msmouse();
break;
#ifdef CONFIG_BRLAPI
case CHARDEV_BACKEND_KIND_BRAILLE:
chr = chr_baum_init();
break;
#endif
case CHARDEV_BACKEND_KIND_STDIO:
chr = qemu_chr_open_stdio(backend->stdio);
break;
default:
error_setg(errp, "unknown chardev backend (%d)", backend->kind);
break;
}
if (chr == NULL && !error_is_set(errp)) {
error_setg(errp, "Failed to create chardev");
}
if (chr) {
chr->label = g_strdup(id);
chr->avail_connections =
(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret;
} else {
g_free(ret);
return NULL;
}
}
| false | qemu | e68c5958668596a5023e30ddf8368410878f7682 | ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
Error **errp)
{
ChardevReturn *ret = g_new0(ChardevReturn, 1);
CharDriverState *base, *chr = NULL;
chr = qemu_chr_find(id);
if (chr) {
error_setg(errp, "Chardev '%s' already exists", id);
g_free(ret);
return NULL;
}
switch (backend->kind) {
case CHARDEV_BACKEND_KIND_FILE:
chr = qmp_chardev_open_file(backend->file, errp);
break;
case CHARDEV_BACKEND_KIND_SERIAL:
chr = qmp_chardev_open_serial(backend->serial, errp);
break;
case CHARDEV_BACKEND_KIND_PARALLEL:
chr = qmp_chardev_open_parallel(backend->parallel, errp);
break;
case CHARDEV_BACKEND_KIND_SOCKET:
chr = qmp_chardev_open_socket(backend->socket, errp);
break;
#ifdef HAVE_CHARDEV_TTY
case CHARDEV_BACKEND_KIND_PTY:
{
QemuOpts *opts;
opts = qemu_opts_create_nofail(qemu_find_opts("chardev"));
chr = qemu_chr_open_pty(opts);
ret->pty = g_strdup(qemu_opt_get(opts, "path"));
ret->has_pty = true;
qemu_opts_del(opts);
break;
}
#endif
case CHARDEV_BACKEND_KIND_NULL:
chr = qemu_chr_open_null();
break;
case CHARDEV_BACKEND_KIND_MUX:
base = qemu_chr_find(backend->mux->chardev);
if (base == NULL) {
error_setg(errp, "mux: base chardev %s not found",
backend->mux->chardev);
break;
}
chr = qemu_chr_open_mux(base);
break;
case CHARDEV_BACKEND_KIND_MSMOUSE:
chr = qemu_chr_open_msmouse();
break;
#ifdef CONFIG_BRLAPI
case CHARDEV_BACKEND_KIND_BRAILLE:
chr = chr_baum_init();
break;
#endif
case CHARDEV_BACKEND_KIND_STDIO:
chr = qemu_chr_open_stdio(backend->stdio);
break;
default:
error_setg(errp, "unknown chardev backend (%d)", backend->kind);
break;
}
if (chr == NULL && !error_is_set(errp)) {
error_setg(errp, "Failed to create chardev");
}
if (chr) {
chr->label = g_strdup(id);
chr->avail_connections =
(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret;
} else {
g_free(ret);
return NULL;
}
}
| {
"code": [],
"line_no": []
} | ChardevReturn *FUNC_0(const char *id, ChardevBackend *backend,
Error **errp)
{
ChardevReturn *ret = g_new0(ChardevReturn, 1);
CharDriverState *base, *chr = NULL;
chr = qemu_chr_find(id);
if (chr) {
error_setg(errp, "Chardev '%s' already exists", id);
g_free(ret);
return NULL;
}
switch (backend->kind) {
case CHARDEV_BACKEND_KIND_FILE:
chr = qmp_chardev_open_file(backend->file, errp);
break;
case CHARDEV_BACKEND_KIND_SERIAL:
chr = qmp_chardev_open_serial(backend->serial, errp);
break;
case CHARDEV_BACKEND_KIND_PARALLEL:
chr = qmp_chardev_open_parallel(backend->parallel, errp);
break;
case CHARDEV_BACKEND_KIND_SOCKET:
chr = qmp_chardev_open_socket(backend->socket, errp);
break;
#ifdef HAVE_CHARDEV_TTY
case CHARDEV_BACKEND_KIND_PTY:
{
QemuOpts *opts;
opts = qemu_opts_create_nofail(qemu_find_opts("chardev"));
chr = qemu_chr_open_pty(opts);
ret->pty = g_strdup(qemu_opt_get(opts, "path"));
ret->has_pty = true;
qemu_opts_del(opts);
break;
}
#endif
case CHARDEV_BACKEND_KIND_NULL:
chr = qemu_chr_open_null();
break;
case CHARDEV_BACKEND_KIND_MUX:
base = qemu_chr_find(backend->mux->chardev);
if (base == NULL) {
error_setg(errp, "mux: base chardev %s not found",
backend->mux->chardev);
break;
}
chr = qemu_chr_open_mux(base);
break;
case CHARDEV_BACKEND_KIND_MSMOUSE:
chr = qemu_chr_open_msmouse();
break;
#ifdef CONFIG_BRLAPI
case CHARDEV_BACKEND_KIND_BRAILLE:
chr = chr_baum_init();
break;
#endif
case CHARDEV_BACKEND_KIND_STDIO:
chr = qemu_chr_open_stdio(backend->stdio);
break;
default:
error_setg(errp, "unknown chardev backend (%d)", backend->kind);
break;
}
if (chr == NULL && !error_is_set(errp)) {
error_setg(errp, "Failed to create chardev");
}
if (chr) {
chr->label = g_strdup(id);
chr->avail_connections =
(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;
QTAILQ_INSERT_TAIL(&chardevs, chr, next);
return ret;
} else {
g_free(ret);
return NULL;
}
}
| [
"ChardevReturn *FUNC_0(const char *id, ChardevBackend *backend,\nError **errp)\n{",
"ChardevReturn *ret = g_new0(ChardevReturn, 1);",
"CharDriverState *base, *chr = NULL;",
"chr = qemu_chr_find(id);",
"if (chr) {",
"error_setg(errp, \"Chardev '%s' already exists\", id);",
"g_free(ret);",
"return NULL;",
"}",
"switch (backend->kind) {",
"case CHARDEV_BACKEND_KIND_FILE:\nchr = qmp_chardev_open_file(backend->file, errp);",
"break;",
"case CHARDEV_BACKEND_KIND_SERIAL:\nchr = qmp_chardev_open_serial(backend->serial, errp);",
"break;",
"case CHARDEV_BACKEND_KIND_PARALLEL:\nchr = qmp_chardev_open_parallel(backend->parallel, errp);",
"break;",
"case CHARDEV_BACKEND_KIND_SOCKET:\nchr = qmp_chardev_open_socket(backend->socket, errp);",
"break;",
"#ifdef HAVE_CHARDEV_TTY\ncase CHARDEV_BACKEND_KIND_PTY:\n{",
"QemuOpts *opts;",
"opts = qemu_opts_create_nofail(qemu_find_opts(\"chardev\"));",
"chr = qemu_chr_open_pty(opts);",
"ret->pty = g_strdup(qemu_opt_get(opts, \"path\"));",
"ret->has_pty = true;",
"qemu_opts_del(opts);",
"break;",
"}",
"#endif\ncase CHARDEV_BACKEND_KIND_NULL:\nchr = qemu_chr_open_null();",
"break;",
"case CHARDEV_BACKEND_KIND_MUX:\nbase = qemu_chr_find(backend->mux->chardev);",
"if (base == NULL) {",
"error_setg(errp, \"mux: base chardev %s not found\",\nbackend->mux->chardev);",
"break;",
"}",
"chr = qemu_chr_open_mux(base);",
"break;",
"case CHARDEV_BACKEND_KIND_MSMOUSE:\nchr = qemu_chr_open_msmouse();",
"break;",
"#ifdef CONFIG_BRLAPI\ncase CHARDEV_BACKEND_KIND_BRAILLE:\nchr = chr_baum_init();",
"break;",
"#endif\ncase CHARDEV_BACKEND_KIND_STDIO:\nchr = qemu_chr_open_stdio(backend->stdio);",
"break;",
"default:\nerror_setg(errp, \"unknown chardev backend (%d)\", backend->kind);",
"break;",
"}",
"if (chr == NULL && !error_is_set(errp)) {",
"error_setg(errp, \"Failed to create chardev\");",
"}",
"if (chr) {",
"chr->label = g_strdup(id);",
"chr->avail_connections =\n(backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1;",
"QTAILQ_INSERT_TAIL(&chardevs, chr, next);",
"return ret;",
"} else {",
"g_free(ret);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53,
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109,
111,
113
],
[
115
],
[
117,
119,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
]
] |
18,996 | static int pbm_pci_host_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_SUN);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_SUN_SABRE);
pci_set_word(d->config + PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
pci_set_word(d->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
return 0;
}
| false | qemu | 92f9a4f13ea29de4644bd0b077643e1dff96ab29 | static int pbm_pci_host_init(PCIDevice *d)
{
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_SUN);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_SUN_SABRE);
pci_set_word(d->config + PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
pci_set_word(d->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_SUN);
pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_SUN_SABRE);
pci_set_word(VAR_0->config + PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
pci_set_word(VAR_0->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_HOST);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"pci_config_set_vendor_id(VAR_0->config, PCI_VENDOR_ID_SUN);",
"pci_config_set_device_id(VAR_0->config, PCI_DEVICE_ID_SUN_SABRE);",
"pci_set_word(VAR_0->config + PCI_COMMAND,\nPCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);",
"pci_set_word(VAR_0->config + PCI_STATUS,\nPCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |\nPCI_STATUS_DEVSEL_MEDIUM);",
"pci_config_set_class(VAR_0->config, PCI_CLASS_BRIDGE_HOST);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15,
17
],
[
19
],
[
21
],
[
23
]
] |
18,998 | static int32_t read_s32(uint8_t *data, size_t offset)
{
return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
}
| false | qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | static int32_t read_s32(uint8_t *data, size_t offset)
{
return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
}
| {
"code": [],
"line_no": []
} | static int32_t FUNC_0(uint8_t *data, size_t offset)
{
return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]);
}
| [
"static int32_t FUNC_0(uint8_t *data, size_t offset)\n{",
"return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |\n(data[offset + 2] << 8) | data[offset + 3]);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
]
] |
19,000 | CPUSPARCState *cpu_sparc_init(void)
{
CPUSPARCState *env;
cpu_exec_init();
if (!(env = malloc(sizeof(CPUSPARCState))))
return (NULL);
memset(env, 0, sizeof(*env));
env->cwp = 0;
env->wim = 1;
env->regwptr = env->regbase + (env->cwp * 16);
env->access_type = ACCESS_DATA;
#if defined(CONFIG_USER_ONLY)
env->user_mode_only = 1;
#else
/* Emulate Prom */
env->psrs = 1;
env->pc = 0x4000;
env->npc = env->pc + 4;
env->mmuregs[0] = (0x10<<24) | MMU_E; /* Impl 1, ver 0, MMU Enabled */
env->mmuregs[1] = 0x3000 >> 4; /* MMU Context table */
#endif
cpu_single_env = env;
return (env);
}
| false | qemu | b769d8fef6c06ddb39ef0337882a4f8872b9c2bc | CPUSPARCState *cpu_sparc_init(void)
{
CPUSPARCState *env;
cpu_exec_init();
if (!(env = malloc(sizeof(CPUSPARCState))))
return (NULL);
memset(env, 0, sizeof(*env));
env->cwp = 0;
env->wim = 1;
env->regwptr = env->regbase + (env->cwp * 16);
env->access_type = ACCESS_DATA;
#if defined(CONFIG_USER_ONLY)
env->user_mode_only = 1;
#else
env->psrs = 1;
env->pc = 0x4000;
env->npc = env->pc + 4;
env->mmuregs[0] = (0x10<<24) | MMU_E;
env->mmuregs[1] = 0x3000 >> 4;
#endif
cpu_single_env = env;
return (env);
}
| {
"code": [],
"line_no": []
} | CPUSPARCState *FUNC_0(void)
{
CPUSPARCState *env;
cpu_exec_init();
if (!(env = malloc(sizeof(CPUSPARCState))))
return (NULL);
memset(env, 0, sizeof(*env));
env->cwp = 0;
env->wim = 1;
env->regwptr = env->regbase + (env->cwp * 16);
env->access_type = ACCESS_DATA;
#if defined(CONFIG_USER_ONLY)
env->user_mode_only = 1;
#else
env->psrs = 1;
env->pc = 0x4000;
env->npc = env->pc + 4;
env->mmuregs[0] = (0x10<<24) | MMU_E;
env->mmuregs[1] = 0x3000 >> 4;
#endif
cpu_single_env = env;
return (env);
}
| [
"CPUSPARCState *FUNC_0(void)\n{",
"CPUSPARCState *env;",
"cpu_exec_init();",
"if (!(env = malloc(sizeof(CPUSPARCState))))\nreturn (NULL);",
"memset(env, 0, sizeof(*env));",
"env->cwp = 0;",
"env->wim = 1;",
"env->regwptr = env->regbase + (env->cwp * 16);",
"env->access_type = ACCESS_DATA;",
"#if defined(CONFIG_USER_ONLY)\nenv->user_mode_only = 1;",
"#else\nenv->psrs = 1;",
"env->pc = 0x4000;",
"env->npc = env->pc + 4;",
"env->mmuregs[0] = (0x10<<24) | MMU_E;",
"env->mmuregs[1] = 0x3000 >> 4;",
"#endif\ncpu_single_env = env;",
"return (env);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
]
] |
19,001 | void timer_init_tl(QEMUTimer *ts,
QEMUTimerList *timer_list, int scale,
QEMUTimerCB *cb, void *opaque)
{
ts->timer_list = timer_list;
ts->cb = cb;
ts->opaque = opaque;
ts->scale = scale;
ts->expire_time = -1;
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | void timer_init_tl(QEMUTimer *ts,
QEMUTimerList *timer_list, int scale,
QEMUTimerCB *cb, void *opaque)
{
ts->timer_list = timer_list;
ts->cb = cb;
ts->opaque = opaque;
ts->scale = scale;
ts->expire_time = -1;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QEMUTimer *VAR_0,
QEMUTimerList *VAR_1, int VAR_2,
QEMUTimerCB *VAR_3, void *VAR_4)
{
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_3 = VAR_3;
VAR_0->VAR_4 = VAR_4;
VAR_0->VAR_2 = VAR_2;
VAR_0->expire_time = -1;
}
| [
"void FUNC_0(QEMUTimer *VAR_0,\nQEMUTimerList *VAR_1, int VAR_2,\nQEMUTimerCB *VAR_3, void *VAR_4)\n{",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->expire_time = -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,004 | static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
NetClientState *nc = qemu_get_queue(n->nic);
features |= (1 << VIRTIO_NET_F_MAC);
if (!peer_has_vnet_hdr(n)) {
features &= ~(0x1 << VIRTIO_NET_F_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN);
}
if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO);
features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
}
if (!get_vhost_net(nc->peer)) {
return features;
}
return vhost_net_get_features(get_vhost_net(nc->peer), features);
}
| false | qemu | 0cd09c3a6cc2230ba38c462fc410b4acce59eb6f | static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
NetClientState *nc = qemu_get_queue(n->nic);
features |= (1 << VIRTIO_NET_F_MAC);
if (!peer_has_vnet_hdr(n)) {
features &= ~(0x1 << VIRTIO_NET_F_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN);
}
if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO);
features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
}
if (!get_vhost_net(nc->peer)) {
return features;
}
return vhost_net_get_features(get_vhost_net(nc->peer), features);
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(VirtIODevice *vdev, uint32_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
NetClientState *nc = qemu_get_queue(n->nic);
features |= (1 << VIRTIO_NET_F_MAC);
if (!peer_has_vnet_hdr(n)) {
features &= ~(0x1 << VIRTIO_NET_F_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6);
features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN);
}
if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO);
features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
}
if (!get_vhost_net(nc->peer)) {
return features;
}
return vhost_net_get_features(get_vhost_net(nc->peer), features);
}
| [
"static uint32_t FUNC_0(VirtIODevice *vdev, uint32_t features)\n{",
"VirtIONet *n = VIRTIO_NET(vdev);",
"NetClientState *nc = qemu_get_queue(n->nic);",
"features |= (1 << VIRTIO_NET_F_MAC);",
"if (!peer_has_vnet_hdr(n)) {",
"features &= ~(0x1 << VIRTIO_NET_F_CSUM);",
"features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4);",
"features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6);",
"features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN);",
"features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM);",
"features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4);",
"features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6);",
"features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN);",
"}",
"if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {",
"features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO);",
"features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);",
"}",
"if (!get_vhost_net(nc->peer)) {",
"return features;",
"}",
"return vhost_net_get_features(get_vhost_net(nc->peer), features);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
19,007 | static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *dyn_cp, *pb = s->pb;
ebml_master cues_element;
int64_t currentpos;
int i, j, ret;
currentpos = avio_tell(pb);
ret = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0);
if (ret < 0)
return ret;
for (i = 0; i < cues->num_entries; i++) {
ebml_master cuepoint, track_positions;
mkv_cuepoint *entry = &cues->entries[i];
uint64_t pts = entry->pts;
int ctp_nb = 0;
// Calculate the number of entries, so we know the element size
for (j = 0; j < num_tracks; j++)
tracks[j].has_cue = 0;
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
ctp_nb ++;
}
cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts);
// put all the entries from different tracks that have the exact same
// timestamp into the same CuePoint
for (j = 0; j < num_tracks; j++)
tracks[j].has_cue = 0;
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[j].tracknum );
put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos);
if (entry[j].duration != -1)
put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[j].duration);
end_ebml_master(dyn_cp, track_positions);
}
i += j - 1;
end_ebml_master(dyn_cp, cuepoint);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element);
return currentpos;
}
| false | FFmpeg | eabbc64728c2fdb74f565aededec2ab023d20699 | static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *dyn_cp, *pb = s->pb;
ebml_master cues_element;
int64_t currentpos;
int i, j, ret;
currentpos = avio_tell(pb);
ret = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0);
if (ret < 0)
return ret;
for (i = 0; i < cues->num_entries; i++) {
ebml_master cuepoint, track_positions;
mkv_cuepoint *entry = &cues->entries[i];
uint64_t pts = entry->pts;
int ctp_nb = 0;
for (j = 0; j < num_tracks; j++)
tracks[j].has_cue = 0;
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
ctp_nb ++;
}
cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts);
for (j = 0; j < num_tracks; j++)
tracks[j].has_cue = 0;
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[j].tracknum );
put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[j].cluster_pos);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[j].relative_pos);
if (entry[j].duration != -1)
put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[j].duration);
end_ebml_master(dyn_cp, track_positions);
}
i += j - 1;
end_ebml_master(dyn_cp, cuepoint);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element);
return currentpos;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *dyn_cp, *pb = s->pb;
ebml_master cues_element;
int64_t currentpos;
int VAR_0, VAR_1, VAR_2;
currentpos = avio_tell(pb);
VAR_2 = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0);
if (VAR_2 < 0)
return VAR_2;
for (VAR_0 = 0; VAR_0 < cues->num_entries; VAR_0++) {
ebml_master cuepoint, track_positions;
mkv_cuepoint *entry = &cues->entries[VAR_0];
uint64_t pts = entry->pts;
int ctp_nb = 0;
for (VAR_1 = 0; VAR_1 < num_tracks; VAR_1++)
tracks[VAR_1].has_cue = 0;
for (VAR_1 = 0; VAR_1 < cues->num_entries - VAR_0 && entry[VAR_1].pts == pts; VAR_1++) {
int tracknum = entry[VAR_1].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
ctp_nb ++;
}
cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts);
for (VAR_1 = 0; VAR_1 < num_tracks; VAR_1++)
tracks[VAR_1].has_cue = 0;
for (VAR_1 = 0; VAR_1 < cues->num_entries - VAR_0 && entry[VAR_1].pts == pts; VAR_1++) {
int tracknum = entry[VAR_1].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[VAR_1].tracknum );
put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[VAR_1].cluster_pos);
put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[VAR_1].relative_pos);
if (entry[VAR_1].duration != -1)
put_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[VAR_1].duration);
end_ebml_master(dyn_cp, track_positions);
}
VAR_0 += VAR_1 - 1;
end_ebml_master(dyn_cp, cuepoint);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element);
return currentpos;
}
| [
"static int64_t FUNC_0(AVFormatContext *s, mkv_cues *cues, mkv_track *tracks, int num_tracks)\n{",
"MatroskaMuxContext *mkv = s->priv_data;",
"AVIOContext *dyn_cp, *pb = s->pb;",
"ebml_master cues_element;",
"int64_t currentpos;",
"int VAR_0, VAR_1, VAR_2;",
"currentpos = avio_tell(pb);",
"VAR_2 = start_ebml_master_crc32(pb, &dyn_cp, &cues_element, MATROSKA_ID_CUES, 0);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"for (VAR_0 = 0; VAR_0 < cues->num_entries; VAR_0++) {",
"ebml_master cuepoint, track_positions;",
"mkv_cuepoint *entry = &cues->entries[VAR_0];",
"uint64_t pts = entry->pts;",
"int ctp_nb = 0;",
"for (VAR_1 = 0; VAR_1 < num_tracks; VAR_1++)",
"tracks[VAR_1].has_cue = 0;",
"for (VAR_1 = 0; VAR_1 < cues->num_entries - VAR_0 && entry[VAR_1].pts == pts; VAR_1++) {",
"int tracknum = entry[VAR_1].stream_idx;",
"av_assert0(tracknum>=0 && tracknum<num_tracks);",
"if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)\ncontinue;",
"tracks[tracknum].has_cue = 1;",
"ctp_nb ++;",
"}",
"cuepoint = start_ebml_master(dyn_cp, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb));",
"put_ebml_uint(dyn_cp, MATROSKA_ID_CUETIME, pts);",
"for (VAR_1 = 0; VAR_1 < num_tracks; VAR_1++)",
"tracks[VAR_1].has_cue = 0;",
"for (VAR_1 = 0; VAR_1 < cues->num_entries - VAR_0 && entry[VAR_1].pts == pts; VAR_1++) {",
"int tracknum = entry[VAR_1].stream_idx;",
"av_assert0(tracknum>=0 && tracknum<num_tracks);",
"if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)\ncontinue;",
"tracks[tracknum].has_cue = 1;",
"track_positions = start_ebml_master(dyn_cp, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);",
"put_ebml_uint(dyn_cp, MATROSKA_ID_CUETRACK , entry[VAR_1].tracknum );",
"put_ebml_uint(dyn_cp, MATROSKA_ID_CUECLUSTERPOSITION , entry[VAR_1].cluster_pos);",
"put_ebml_uint(dyn_cp, MATROSKA_ID_CUERELATIVEPOSITION, entry[VAR_1].relative_pos);",
"if (entry[VAR_1].duration != -1)\nput_ebml_uint(dyn_cp, MATROSKA_ID_CUEDURATION , entry[VAR_1].duration);",
"end_ebml_master(dyn_cp, track_positions);",
"}",
"VAR_0 += VAR_1 - 1;",
"end_ebml_master(dyn_cp, cuepoint);",
"}",
"end_ebml_master_crc32(pb, &dyn_cp, mkv, cues_element);",
"return currentpos;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
]
] |
19,008 | av_cold int ff_vaapi_encode_init(AVCodecContext *avctx,
const VAAPIEncodeType *type)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
AVVAAPIFramesContext *recon_hwctx = NULL;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
enum AVPixelFormat recon_format;
VAStatus vas;
int err, i;
if (!avctx->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
"required to associate the encoding device.\n");
return AVERROR(EINVAL);
}
ctx->codec = type;
ctx->codec_options = ctx->codec_options_data;
ctx->va_config = VA_INVALID_ID;
ctx->va_context = VA_INVALID_ID;
ctx->priv_data = av_mallocz(type->priv_data_size);
if (!ctx->priv_data) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
if (!ctx->input_frames_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
if (!ctx->device_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
ctx->hwctx = ctx->device->hwctx;
err = ctx->codec->init(avctx);
if (err < 0)
goto fail;
err = vaapi_encode_check_config(avctx);
if (err < 0)
goto fail;
vas = vaCreateConfig(ctx->hwctx->display,
ctx->va_profile, ctx->va_entrypoint,
ctx->config_attributes, ctx->nb_config_attributes,
&ctx->va_config);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"configuration: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref);
if (!hwconfig) {
err = AVERROR(ENOMEM);
goto fail;
}
hwconfig->config_id = ctx->va_config;
constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref,
hwconfig);
if (!constraints) {
err = AVERROR(ENOMEM);
goto fail;
}
// Probably we can use the input surface format as the surface format
// of the reconstructed frames. If not, we just pick the first (only?)
// format in the valid list and hope that it all works.
recon_format = AV_PIX_FMT_NONE;
if (constraints->valid_sw_formats) {
for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) {
if (ctx->input_frames->sw_format ==
constraints->valid_sw_formats[i]) {
recon_format = ctx->input_frames->sw_format;
break;
}
}
if (recon_format == AV_PIX_FMT_NONE) {
// No match. Just use the first in the supported list and
// hope for the best.
recon_format = constraints->valid_sw_formats[0];
}
} else {
// No idea what to use; copy input format.
recon_format = ctx->input_frames->sw_format;
}
av_log(avctx, AV_LOG_DEBUG, "Using %s as format of "
"reconstructed frames.\n", av_get_pix_fmt_name(recon_format));
if (ctx->aligned_width < constraints->min_width ||
ctx->aligned_height < constraints->min_height ||
ctx->aligned_width > constraints->max_width ||
ctx->aligned_height > constraints->max_height) {
av_log(avctx, AV_LOG_ERROR, "Hardware does not support encoding at "
"size %dx%d (constraints: width %d-%d height %d-%d).\n",
ctx->aligned_width, ctx->aligned_height,
constraints->min_width, constraints->max_width,
constraints->min_height, constraints->max_height);
err = AVERROR(EINVAL);
goto fail;
}
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ctx->recon_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
if (!ctx->recon_frames_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data;
ctx->recon_frames->format = AV_PIX_FMT_VAAPI;
ctx->recon_frames->sw_format = recon_format;
ctx->recon_frames->width = ctx->aligned_width;
ctx->recon_frames->height = ctx->aligned_height;
ctx->recon_frames->initial_pool_size = ctx->nb_recon_frames;
err = av_hwframe_ctx_init(ctx->recon_frames_ref);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed "
"frame context: %d.\n", err);
goto fail;
}
recon_hwctx = ctx->recon_frames->hwctx;
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
ctx->aligned_width, ctx->aligned_height,
VA_PROGRESSIVE,
recon_hwctx->surface_ids,
recon_hwctx->nb_surfaces,
&ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"context: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
ctx->input_order = 0;
ctx->output_delay = avctx->max_b_frames;
ctx->decode_delay = 1;
ctx->output_order = - ctx->output_delay - 1;
if (ctx->codec->sequence_params_size > 0) {
ctx->codec_sequence_params =
av_mallocz(ctx->codec->sequence_params_size);
if (!ctx->codec_sequence_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->picture_params_size > 0) {
ctx->codec_picture_params =
av_mallocz(ctx->codec->picture_params_size);
if (!ctx->codec_picture_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_sequence_params) {
err = ctx->codec->init_sequence_params(avctx);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Codec sequence initialisation "
"failed: %d.\n", err);
goto fail;
}
}
ctx->output_buffer_pool =
av_buffer_pool_init2(sizeof(VABufferID), avctx,
&vaapi_encode_alloc_output_buffer, NULL);
if (!ctx->output_buffer_pool) {
err = AVERROR(ENOMEM);
goto fail;
}
// All I are IDR for now.
ctx->i_per_idr = 0;
ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
(avctx->max_b_frames + 1));
ctx->b_per_p = avctx->max_b_frames;
// This should be configurable somehow. (Needs testing on a machine
// where it actually overlaps properly, though.)
ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;
return 0;
fail:
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ff_vaapi_encode_close(avctx);
return err;
}
| false | FFmpeg | c8241e730f116f1c9cfc0b34110aa7f052e05332 | av_cold int ff_vaapi_encode_init(AVCodecContext *avctx,
const VAAPIEncodeType *type)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
AVVAAPIFramesContext *recon_hwctx = NULL;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
enum AVPixelFormat recon_format;
VAStatus vas;
int err, i;
if (!avctx->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
"required to associate the encoding device.\n");
return AVERROR(EINVAL);
}
ctx->codec = type;
ctx->codec_options = ctx->codec_options_data;
ctx->va_config = VA_INVALID_ID;
ctx->va_context = VA_INVALID_ID;
ctx->priv_data = av_mallocz(type->priv_data_size);
if (!ctx->priv_data) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
if (!ctx->input_frames_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
if (!ctx->device_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
ctx->hwctx = ctx->device->hwctx;
err = ctx->codec->init(avctx);
if (err < 0)
goto fail;
err = vaapi_encode_check_config(avctx);
if (err < 0)
goto fail;
vas = vaCreateConfig(ctx->hwctx->display,
ctx->va_profile, ctx->va_entrypoint,
ctx->config_attributes, ctx->nb_config_attributes,
&ctx->va_config);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"configuration: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref);
if (!hwconfig) {
err = AVERROR(ENOMEM);
goto fail;
}
hwconfig->config_id = ctx->va_config;
constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref,
hwconfig);
if (!constraints) {
err = AVERROR(ENOMEM);
goto fail;
}
recon_format = AV_PIX_FMT_NONE;
if (constraints->valid_sw_formats) {
for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) {
if (ctx->input_frames->sw_format ==
constraints->valid_sw_formats[i]) {
recon_format = ctx->input_frames->sw_format;
break;
}
}
if (recon_format == AV_PIX_FMT_NONE) {
recon_format = constraints->valid_sw_formats[0];
}
} else {
recon_format = ctx->input_frames->sw_format;
}
av_log(avctx, AV_LOG_DEBUG, "Using %s as format of "
"reconstructed frames.\n", av_get_pix_fmt_name(recon_format));
if (ctx->aligned_width < constraints->min_width ||
ctx->aligned_height < constraints->min_height ||
ctx->aligned_width > constraints->max_width ||
ctx->aligned_height > constraints->max_height) {
av_log(avctx, AV_LOG_ERROR, "Hardware does not support encoding at "
"size %dx%d (constraints: width %d-%d height %d-%d).\n",
ctx->aligned_width, ctx->aligned_height,
constraints->min_width, constraints->max_width,
constraints->min_height, constraints->max_height);
err = AVERROR(EINVAL);
goto fail;
}
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ctx->recon_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
if (!ctx->recon_frames_ref) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data;
ctx->recon_frames->format = AV_PIX_FMT_VAAPI;
ctx->recon_frames->sw_format = recon_format;
ctx->recon_frames->width = ctx->aligned_width;
ctx->recon_frames->height = ctx->aligned_height;
ctx->recon_frames->initial_pool_size = ctx->nb_recon_frames;
err = av_hwframe_ctx_init(ctx->recon_frames_ref);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed "
"frame context: %d.\n", err);
goto fail;
}
recon_hwctx = ctx->recon_frames->hwctx;
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
ctx->aligned_width, ctx->aligned_height,
VA_PROGRESSIVE,
recon_hwctx->surface_ids,
recon_hwctx->nb_surfaces,
&ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"context: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
ctx->input_order = 0;
ctx->output_delay = avctx->max_b_frames;
ctx->decode_delay = 1;
ctx->output_order = - ctx->output_delay - 1;
if (ctx->codec->sequence_params_size > 0) {
ctx->codec_sequence_params =
av_mallocz(ctx->codec->sequence_params_size);
if (!ctx->codec_sequence_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->picture_params_size > 0) {
ctx->codec_picture_params =
av_mallocz(ctx->codec->picture_params_size);
if (!ctx->codec_picture_params) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_sequence_params) {
err = ctx->codec->init_sequence_params(avctx);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Codec sequence initialisation "
"failed: %d.\n", err);
goto fail;
}
}
ctx->output_buffer_pool =
av_buffer_pool_init2(sizeof(VABufferID), avctx,
&vaapi_encode_alloc_output_buffer, NULL);
if (!ctx->output_buffer_pool) {
err = AVERROR(ENOMEM);
goto fail;
}
ctx->i_per_idr = 0;
ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
(avctx->max_b_frames + 1));
ctx->b_per_p = avctx->max_b_frames;
ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;
return 0;
fail:
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ff_vaapi_encode_close(avctx);
return err;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(AVCodecContext *avctx,
const VAAPIEncodeType *type)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
AVVAAPIFramesContext *recon_hwctx = NULL;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
enum AVPixelFormat VAR_0;
VAStatus vas;
int VAR_1, VAR_2;
if (!avctx->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
"required to associate the encoding device.\n");
return AVERROR(EINVAL);
}
ctx->codec = type;
ctx->codec_options = ctx->codec_options_data;
ctx->va_config = VA_INVALID_ID;
ctx->va_context = VA_INVALID_ID;
ctx->priv_data = av_mallocz(type->priv_data_size);
if (!ctx->priv_data) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
if (!ctx->input_frames_ref) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
if (!ctx->device_ref) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
ctx->hwctx = ctx->device->hwctx;
VAR_1 = ctx->codec->init(avctx);
if (VAR_1 < 0)
goto fail;
VAR_1 = vaapi_encode_check_config(avctx);
if (VAR_1 < 0)
goto fail;
vas = vaCreateConfig(ctx->hwctx->display,
ctx->va_profile, ctx->va_entrypoint,
ctx->config_attributes, ctx->nb_config_attributes,
&ctx->va_config);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"configuration: %d (%s).\n", vas, vaErrorStr(vas));
VAR_1 = AVERROR(EIO);
goto fail;
}
hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref);
if (!hwconfig) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
hwconfig->config_id = ctx->va_config;
constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref,
hwconfig);
if (!constraints) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
VAR_0 = AV_PIX_FMT_NONE;
if (constraints->valid_sw_formats) {
for (VAR_2 = 0; constraints->valid_sw_formats[VAR_2] != AV_PIX_FMT_NONE; VAR_2++) {
if (ctx->input_frames->sw_format ==
constraints->valid_sw_formats[VAR_2]) {
VAR_0 = ctx->input_frames->sw_format;
break;
}
}
if (VAR_0 == AV_PIX_FMT_NONE) {
VAR_0 = constraints->valid_sw_formats[0];
}
} else {
VAR_0 = ctx->input_frames->sw_format;
}
av_log(avctx, AV_LOG_DEBUG, "Using %s as format of "
"reconstructed frames.\n", av_get_pix_fmt_name(VAR_0));
if (ctx->aligned_width < constraints->min_width ||
ctx->aligned_height < constraints->min_height ||
ctx->aligned_width > constraints->max_width ||
ctx->aligned_height > constraints->max_height) {
av_log(avctx, AV_LOG_ERROR, "Hardware does not support encoding at "
"size %dx%d (constraints: width %d-%d height %d-%d).\n",
ctx->aligned_width, ctx->aligned_height,
constraints->min_width, constraints->max_width,
constraints->min_height, constraints->max_height);
VAR_1 = AVERROR(EINVAL);
goto fail;
}
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ctx->recon_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
if (!ctx->recon_frames_ref) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data;
ctx->recon_frames->format = AV_PIX_FMT_VAAPI;
ctx->recon_frames->sw_format = VAR_0;
ctx->recon_frames->width = ctx->aligned_width;
ctx->recon_frames->height = ctx->aligned_height;
ctx->recon_frames->initial_pool_size = ctx->nb_recon_frames;
VAR_1 = av_hwframe_ctx_init(ctx->recon_frames_ref);
if (VAR_1 < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed "
"frame context: %d.\n", VAR_1);
goto fail;
}
recon_hwctx = ctx->recon_frames->hwctx;
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
ctx->aligned_width, ctx->aligned_height,
VA_PROGRESSIVE,
recon_hwctx->surface_ids,
recon_hwctx->nb_surfaces,
&ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
"context: %d (%s).\n", vas, vaErrorStr(vas));
VAR_1 = AVERROR(EIO);
goto fail;
}
ctx->input_order = 0;
ctx->output_delay = avctx->max_b_frames;
ctx->decode_delay = 1;
ctx->output_order = - ctx->output_delay - 1;
if (ctx->codec->sequence_params_size > 0) {
ctx->codec_sequence_params =
av_mallocz(ctx->codec->sequence_params_size);
if (!ctx->codec_sequence_params) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->picture_params_size > 0) {
ctx->codec_picture_params =
av_mallocz(ctx->codec->picture_params_size);
if (!ctx->codec_picture_params) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
}
if (ctx->codec->init_sequence_params) {
VAR_1 = ctx->codec->init_sequence_params(avctx);
if (VAR_1 < 0) {
av_log(avctx, AV_LOG_ERROR, "Codec sequence initialisation "
"failed: %d.\n", VAR_1);
goto fail;
}
}
ctx->output_buffer_pool =
av_buffer_pool_init2(sizeof(VABufferID), avctx,
&vaapi_encode_alloc_output_buffer, NULL);
if (!ctx->output_buffer_pool) {
VAR_1 = AVERROR(ENOMEM);
goto fail;
}
ctx->i_per_idr = 0;
ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
(avctx->max_b_frames + 1));
ctx->b_per_p = avctx->max_b_frames;
ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;
return 0;
fail:
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
ff_vaapi_encode_close(avctx);
return VAR_1;
}
| [
"av_cold int FUNC_0(AVCodecContext *avctx,\nconst VAAPIEncodeType *type)\n{",
"VAAPIEncodeContext *ctx = avctx->priv_data;",
"AVVAAPIFramesContext *recon_hwctx = NULL;",
"AVVAAPIHWConfig *hwconfig = NULL;",
"AVHWFramesConstraints *constraints = NULL;",
"enum AVPixelFormat VAR_0;",
"VAStatus vas;",
"int VAR_1, VAR_2;",
"if (!avctx->hw_frames_ctx) {",
"av_log(avctx, AV_LOG_ERROR, \"A hardware frames reference is \"\n\"required to associate the encoding device.\\n\");",
"return AVERROR(EINVAL);",
"}",
"ctx->codec = type;",
"ctx->codec_options = ctx->codec_options_data;",
"ctx->va_config = VA_INVALID_ID;",
"ctx->va_context = VA_INVALID_ID;",
"ctx->priv_data = av_mallocz(type->priv_data_size);",
"if (!ctx->priv_data) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);",
"if (!ctx->input_frames_ref) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;",
"ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);",
"if (!ctx->device_ref) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;",
"ctx->hwctx = ctx->device->hwctx;",
"VAR_1 = ctx->codec->init(avctx);",
"if (VAR_1 < 0)\ngoto fail;",
"VAR_1 = vaapi_encode_check_config(avctx);",
"if (VAR_1 < 0)\ngoto fail;",
"vas = vaCreateConfig(ctx->hwctx->display,\nctx->va_profile, ctx->va_entrypoint,\nctx->config_attributes, ctx->nb_config_attributes,\n&ctx->va_config);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to create encode pipeline \"\n\"configuration: %d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_1 = AVERROR(EIO);",
"goto fail;",
"}",
"hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref);",
"if (!hwconfig) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"hwconfig->config_id = ctx->va_config;",
"constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref,\nhwconfig);",
"if (!constraints) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_0 = AV_PIX_FMT_NONE;",
"if (constraints->valid_sw_formats) {",
"for (VAR_2 = 0; constraints->valid_sw_formats[VAR_2] != AV_PIX_FMT_NONE; VAR_2++) {",
"if (ctx->input_frames->sw_format ==\nconstraints->valid_sw_formats[VAR_2]) {",
"VAR_0 = ctx->input_frames->sw_format;",
"break;",
"}",
"}",
"if (VAR_0 == AV_PIX_FMT_NONE) {",
"VAR_0 = constraints->valid_sw_formats[0];",
"}",
"} else {",
"VAR_0 = ctx->input_frames->sw_format;",
"}",
"av_log(avctx, AV_LOG_DEBUG, \"Using %s as format of \"\n\"reconstructed frames.\\n\", av_get_pix_fmt_name(VAR_0));",
"if (ctx->aligned_width < constraints->min_width ||\nctx->aligned_height < constraints->min_height ||\nctx->aligned_width > constraints->max_width ||\nctx->aligned_height > constraints->max_height) {",
"av_log(avctx, AV_LOG_ERROR, \"Hardware does not support encoding at \"\n\"size %dx%d (constraints: width %d-%d height %d-%d).\\n\",\nctx->aligned_width, ctx->aligned_height,\nconstraints->min_width, constraints->max_width,\nconstraints->min_height, constraints->max_height);",
"VAR_1 = AVERROR(EINVAL);",
"goto fail;",
"}",
"av_freep(&hwconfig);",
"av_hwframe_constraints_free(&constraints);",
"ctx->recon_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);",
"if (!ctx->recon_frames_ref) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data;",
"ctx->recon_frames->format = AV_PIX_FMT_VAAPI;",
"ctx->recon_frames->sw_format = VAR_0;",
"ctx->recon_frames->width = ctx->aligned_width;",
"ctx->recon_frames->height = ctx->aligned_height;",
"ctx->recon_frames->initial_pool_size = ctx->nb_recon_frames;",
"VAR_1 = av_hwframe_ctx_init(ctx->recon_frames_ref);",
"if (VAR_1 < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to initialise reconstructed \"\n\"frame context: %d.\\n\", VAR_1);",
"goto fail;",
"}",
"recon_hwctx = ctx->recon_frames->hwctx;",
"vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,\nctx->aligned_width, ctx->aligned_height,\nVA_PROGRESSIVE,\nrecon_hwctx->surface_ids,\nrecon_hwctx->nb_surfaces,\n&ctx->va_context);",
"if (vas != VA_STATUS_SUCCESS) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to create encode pipeline \"\n\"context: %d (%s).\\n\", vas, vaErrorStr(vas));",
"VAR_1 = AVERROR(EIO);",
"goto fail;",
"}",
"ctx->input_order = 0;",
"ctx->output_delay = avctx->max_b_frames;",
"ctx->decode_delay = 1;",
"ctx->output_order = - ctx->output_delay - 1;",
"if (ctx->codec->sequence_params_size > 0) {",
"ctx->codec_sequence_params =\nav_mallocz(ctx->codec->sequence_params_size);",
"if (!ctx->codec_sequence_params) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"if (ctx->codec->picture_params_size > 0) {",
"ctx->codec_picture_params =\nav_mallocz(ctx->codec->picture_params_size);",
"if (!ctx->codec_picture_params) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"if (ctx->codec->init_sequence_params) {",
"VAR_1 = ctx->codec->init_sequence_params(avctx);",
"if (VAR_1 < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Codec sequence initialisation \"\n\"failed: %d.\\n\", VAR_1);",
"goto fail;",
"}",
"}",
"ctx->output_buffer_pool =\nav_buffer_pool_init2(sizeof(VABufferID), avctx,\n&vaapi_encode_alloc_output_buffer, NULL);",
"if (!ctx->output_buffer_pool) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"ctx->i_per_idr = 0;",
"ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /\n(avctx->max_b_frames + 1));",
"ctx->b_per_p = avctx->max_b_frames;",
"ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;",
"return 0;",
"fail:\nav_freep(&hwconfig);",
"av_hwframe_constraints_free(&constraints);",
"ff_vaapi_encode_close(avctx);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
97
],
[
99,
101
],
[
105,
107,
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197,
199
],
[
203,
205,
207,
209
],
[
211,
213,
215,
217,
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265,
267
],
[
269
],
[
271
],
[
273
],
[
277,
279,
281,
283,
285,
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
365,
367,
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
383
],
[
385,
387
],
[
389
],
[
397
],
[
401
],
[
405,
407
],
[
409
],
[
411
],
[
413
],
[
415
]
] |
19,010 | void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
{
if ( s->avctx->hwaccel || !pict || !pict->mb_type
|| (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
return;
if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
int x,y;
av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
av_get_picture_type_char(pict->pict_type));
for (y = 0; y < s->mb_height; y++) {
for (x = 0; x < s->mb_width; x++) {
if (s->avctx->debug & FF_DEBUG_SKIP) {
int count = s->mbskip_table[x + y * s->mb_stride];
if (count > 9)
count = 9;
av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
}
if (s->avctx->debug & FF_DEBUG_QP) {
av_log(s->avctx, AV_LOG_DEBUG, "%2d",
pict->qscale_table[x + y * s->mb_stride]);
}
if (s->avctx->debug & FF_DEBUG_MB_TYPE) {
int mb_type = pict->mb_type[x + y * s->mb_stride];
// Type & MV direction
if (IS_PCM(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "P");
else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "A");
else if (IS_INTRA4x4(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "i");
else if (IS_INTRA16x16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "I");
else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "d");
else if (IS_DIRECT(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "D");
else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "g");
else if (IS_GMC(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "G");
else if (IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "S");
else if (!USES_LIST(mb_type, 1))
av_log(s->avctx, AV_LOG_DEBUG, ">");
else if (!USES_LIST(mb_type, 0))
av_log(s->avctx, AV_LOG_DEBUG, "<");
else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
av_log(s->avctx, AV_LOG_DEBUG, "X");
}
// segmentation
if (IS_8X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "+");
else if (IS_16X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "-");
else if (IS_8X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "|");
else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, " ");
else
av_log(s->avctx, AV_LOG_DEBUG, "?");
if (IS_INTERLACED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "=");
else
av_log(s->avctx, AV_LOG_DEBUG, " ");
}
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
(s->avctx->debug_mv)) {
const int shift = 1 + s->quarter_sample;
int mb_y;
uint8_t *ptr;
int i;
int h_chroma_shift, v_chroma_shift, block_height;
const int width = s->avctx->width;
const int height = s->avctx->height;
const int mv_sample_log2 = 4 - pict->motion_subsample_log2;
const int mv_stride = (s->mb_width << mv_sample_log2) +
(s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
s->low_delay = 0; // needed to see the vectors without trashing the buffers
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
for (i = 0; i < 3; i++) {
size_t size= (i == 0) ? pict->linesize[i] * FFALIGN(height, 16):
pict->linesize[i] * FFALIGN(height, 16) >> v_chroma_shift;
s->visualization_buffer[i]= av_realloc(s->visualization_buffer[i], size);
memcpy(s->visualization_buffer[i], pict->data[i], size);
pict->data[i] = s->visualization_buffer[i];
}
pict->type = FF_BUFFER_TYPE_COPY;
pict->opaque= NULL;
ptr = pict->data[0];
block_height = 16 >> v_chroma_shift;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
int mb_x;
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_index = mb_x + mb_y * s->mb_stride;
if ((s->avctx->debug_mv) && pict->motion_val) {
int type;
for (type = 0; type < 3; type++) {
int direction = 0;
switch (type) {
case 0:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_P))
continue;
direction = 0;
break;
case 1:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 0;
break;
case 2:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 1;
break;
}
if (!USES_LIST(pict->mb_type[mb_index], direction))
continue;
if (IS_8X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 4 + 8 * (i & 1);
int sy = mb_y * 16 + 4 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift) + sx;
int my = (pict->motion_val[direction][xy][1] >> shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width,
height, s->linesize, 100);
}
} else if (IS_16X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 8;
int sy = mb_y * 16 + 4 + 8 * i;
int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift);
int my = (pict->motion_val[direction][xy][1] >> shift);
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else if (IS_8X16(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 4 + 8 * i;
int sy = mb_y * 16 + 8;
int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
int mx = pict->motion_val[direction][xy][0] >> shift;
int my = pict->motion_val[direction][xy][1] >> shift;
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else {
int sx= mb_x * 16 + 8;
int sy= mb_y * 16 + 8;
int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
}
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_QP) && pict->motion_val) {
uint64_t c = (pict->qscale_table[mb_index] * 128 / 31) *
0x0101010101010101ULL;
int y;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[1]) = c;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[2]) = c;
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
pict->motion_val) {
int mb_type = pict->mb_type[mb_index];
uint64_t u,v;
int y;
#define COLOR(theta, r) \
u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
v = (int)(128 + r * sin(theta * 3.141592 / 180));
u = v = 128;
if (IS_PCM(mb_type)) {
COLOR(120, 48)
} else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
IS_INTRA16x16(mb_type)) {
COLOR(30, 48)
} else if (IS_INTRA4x4(mb_type)) {
COLOR(90, 48)
} else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
// COLOR(120, 48)
} else if (IS_DIRECT(mb_type)) {
COLOR(150, 48)
} else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
COLOR(170, 48)
} else if (IS_GMC(mb_type)) {
COLOR(190, 48)
} else if (IS_SKIP(mb_type)) {
// COLOR(180, 48)
} else if (!USES_LIST(mb_type, 1)) {
COLOR(240, 48)
} else if (!USES_LIST(mb_type, 0)) {
COLOR(0, 48)
} else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
COLOR(300,48)
}
u *= 0x0101010101010101ULL;
v *= 0x0101010101010101ULL;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[1]) = u;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[2]) = v;
}
// segmentation
if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
*(uint64_t *)(pict->data[0] + 16 * mb_x + 0 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
*(uint64_t *)(pict->data[0] + 16 * mb_x + 8 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
}
if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
for (y = 0; y < 16; y++)
pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) *
pict->linesize[0]] ^= 0x80;
}
if (IS_8X8(mb_type) && mv_sample_log2 >= 2) {
int dm = 1 << (mv_sample_log2 - 2);
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 8 * (i & 1);
int sy = mb_y * 16 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
// FIXME bidir
int32_t *mv = (int32_t *) &pict->motion_val[0][xy];
if (mv[0] != mv[dm] ||
mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
for (y = 0; y < 8; y++)
pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80;
if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
*(uint64_t *)(pict->data[0] + sx + (sy + 4) *
pict->linesize[0]) ^= 0x8080808080808080ULL;
}
}
if (IS_INTERLACED(mb_type) &&
s->codec_id == AV_CODEC_ID_H264) {
// hmm
}
}
s->mbskip_table[mb_index] = 0;
}
}
}
}
| false | FFmpeg | 20ec0d2a750a804f50c090cf6e6509db8ff9cadd | void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
{
if ( s->avctx->hwaccel || !pict || !pict->mb_type
|| (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
return;
if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
int x,y;
av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
av_get_picture_type_char(pict->pict_type));
for (y = 0; y < s->mb_height; y++) {
for (x = 0; x < s->mb_width; x++) {
if (s->avctx->debug & FF_DEBUG_SKIP) {
int count = s->mbskip_table[x + y * s->mb_stride];
if (count > 9)
count = 9;
av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
}
if (s->avctx->debug & FF_DEBUG_QP) {
av_log(s->avctx, AV_LOG_DEBUG, "%2d",
pict->qscale_table[x + y * s->mb_stride]);
}
if (s->avctx->debug & FF_DEBUG_MB_TYPE) {
int mb_type = pict->mb_type[x + y * s->mb_stride];
if (IS_PCM(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "P");
else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "A");
else if (IS_INTRA4x4(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "i");
else if (IS_INTRA16x16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "I");
else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "d");
else if (IS_DIRECT(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "D");
else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "g");
else if (IS_GMC(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "G");
else if (IS_SKIP(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "S");
else if (!USES_LIST(mb_type, 1))
av_log(s->avctx, AV_LOG_DEBUG, ">");
else if (!USES_LIST(mb_type, 0))
av_log(s->avctx, AV_LOG_DEBUG, "<");
else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
av_log(s->avctx, AV_LOG_DEBUG, "X");
}
if (IS_8X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "+");
else if (IS_16X8(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "-");
else if (IS_8X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "|");
else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, " ");
else
av_log(s->avctx, AV_LOG_DEBUG, "?");
if (IS_INTERLACED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "=");
else
av_log(s->avctx, AV_LOG_DEBUG, " ");
}
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
(s->avctx->debug_mv)) {
const int shift = 1 + s->quarter_sample;
int mb_y;
uint8_t *ptr;
int i;
int h_chroma_shift, v_chroma_shift, block_height;
const int width = s->avctx->width;
const int height = s->avctx->height;
const int mv_sample_log2 = 4 - pict->motion_subsample_log2;
const int mv_stride = (s->mb_width << mv_sample_log2) +
(s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
s->low_delay = 0;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
&h_chroma_shift, &v_chroma_shift);
for (i = 0; i < 3; i++) {
size_t size= (i == 0) ? pict->linesize[i] * FFALIGN(height, 16):
pict->linesize[i] * FFALIGN(height, 16) >> v_chroma_shift;
s->visualization_buffer[i]= av_realloc(s->visualization_buffer[i], size);
memcpy(s->visualization_buffer[i], pict->data[i], size);
pict->data[i] = s->visualization_buffer[i];
}
pict->type = FF_BUFFER_TYPE_COPY;
pict->opaque= NULL;
ptr = pict->data[0];
block_height = 16 >> v_chroma_shift;
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
int mb_x;
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
const int mb_index = mb_x + mb_y * s->mb_stride;
if ((s->avctx->debug_mv) && pict->motion_val) {
int type;
for (type = 0; type < 3; type++) {
int direction = 0;
switch (type) {
case 0:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_P))
continue;
direction = 0;
break;
case 1:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 0;
break;
case 2:
if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||
(pict->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 1;
break;
}
if (!USES_LIST(pict->mb_type[mb_index], direction))
continue;
if (IS_8X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 4 + 8 * (i & 1);
int sy = mb_y * 16 + 4 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift) + sx;
int my = (pict->motion_val[direction][xy][1] >> shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width,
height, s->linesize, 100);
}
} else if (IS_16X8(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 8;
int sy = mb_y * 16 + 4 + 8 * i;
int xy = (mb_x * 2 + (mb_y * 2 + i) * mv_stride) << (mv_sample_log2 - 1);
int mx = (pict->motion_val[direction][xy][0] >> shift);
int my = (pict->motion_val[direction][xy][1] >> shift);
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else if (IS_8X16(pict->mb_type[mb_index])) {
int i;
for (i = 0; i < 2; i++) {
int sx = mb_x * 16 + 4 + 8 * i;
int sy = mb_y * 16 + 8;
int xy = (mb_x * 2 + i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
int mx = pict->motion_val[direction][xy][0] >> shift;
int my = pict->motion_val[direction][xy][1] >> shift;
if (IS_INTERLACED(pict->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
height, s->linesize, 100);
}
} else {
int sx= mb_x * 16 + 8;
int sy= mb_y * 16 + 8;
int xy= (mb_x + mb_y * mv_stride) << mv_sample_log2;
int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
}
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_QP) && pict->motion_val) {
uint64_t c = (pict->qscale_table[mb_index] * 128 / 31) *
0x0101010101010101ULL;
int y;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[1]) = c;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) *
pict->linesize[2]) = c;
}
}
if ((s->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
pict->motion_val) {
int mb_type = pict->mb_type[mb_index];
uint64_t u,v;
int y;
#define COLOR(theta, r) \
u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
v = (int)(128 + r * sin(theta * 3.141592 / 180));
u = v = 128;
if (IS_PCM(mb_type)) {
COLOR(120, 48)
} else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
IS_INTRA16x16(mb_type)) {
COLOR(30, 48)
} else if (IS_INTRA4x4(mb_type)) {
COLOR(90, 48)
} else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
} else if (IS_DIRECT(mb_type)) {
COLOR(150, 48)
} else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
COLOR(170, 48)
} else if (IS_GMC(mb_type)) {
COLOR(190, 48)
} else if (IS_SKIP(mb_type)) {
} else if (!USES_LIST(mb_type, 1)) {
COLOR(240, 48)
} else if (!USES_LIST(mb_type, 0)) {
COLOR(0, 48)
} else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
COLOR(300,48)
}
u *= 0x0101010101010101ULL;
v *= 0x0101010101010101ULL;
for (y = 0; y < block_height; y++) {
*(uint64_t *)(pict->data[1] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[1]) = u;
*(uint64_t *)(pict->data[2] + 8 * mb_x +
(block_height * mb_y + y) * pict->linesize[2]) = v;
}
if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
*(uint64_t *)(pict->data[0] + 16 * mb_x + 0 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
*(uint64_t *)(pict->data[0] + 16 * mb_x + 8 +
(16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
}
if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
for (y = 0; y < 16; y++)
pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) *
pict->linesize[0]] ^= 0x80;
}
if (IS_8X8(mb_type) && mv_sample_log2 >= 2) {
int dm = 1 << (mv_sample_log2 - 2);
for (i = 0; i < 4; i++) {
int sx = mb_x * 16 + 8 * (i & 1);
int sy = mb_y * 16 + 8 * (i >> 1);
int xy = (mb_x * 2 + (i & 1) +
(mb_y * 2 + (i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
int32_t *mv = (int32_t *) &pict->motion_val[0][xy];
if (mv[0] != mv[dm] ||
mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
for (y = 0; y < 8; y++)
pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80;
if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
*(uint64_t *)(pict->data[0] + sx + (sy + 4) *
pict->linesize[0]) ^= 0x8080808080808080ULL;
}
}
if (IS_INTERLACED(mb_type) &&
s->codec_id == AV_CODEC_ID_H264) {
}
}
s->mbskip_table[mb_index] = 0;
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MpegEncContext *VAR_0, AVFrame *VAR_1)
{
if ( VAR_0->avctx->hwaccel || !VAR_1 || !VAR_1->mb_type
|| (VAR_0->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
return;
if (VAR_0->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
int VAR_2,VAR_3;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
av_get_picture_type_char(VAR_1->pict_type));
for (VAR_3 = 0; VAR_3 < VAR_0->mb_height; VAR_3++) {
for (VAR_2 = 0; VAR_2 < VAR_0->mb_width; VAR_2++) {
if (VAR_0->avctx->debug & FF_DEBUG_SKIP) {
int count = VAR_0->mbskip_table[VAR_2 + VAR_3 * VAR_0->mb_stride];
if (count > 9)
count = 9;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "%1d", count);
}
if (VAR_0->avctx->debug & FF_DEBUG_QP) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "%2d",
VAR_1->qscale_table[VAR_2 + VAR_3 * VAR_0->mb_stride]);
}
if (VAR_0->avctx->debug & FF_DEBUG_MB_TYPE) {
int mb_type = VAR_1->mb_type[VAR_2 + VAR_3 * VAR_0->mb_stride];
if (IS_PCM(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "P");
else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "A");
else if (IS_INTRA4x4(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "VAR_6");
else if (IS_INTRA16x16(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "I");
else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "d");
else if (IS_DIRECT(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "D");
else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "g");
else if (IS_GMC(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "G");
else if (IS_SKIP(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "S");
else if (!USES_LIST(mb_type, 1))
av_log(VAR_0->avctx, AV_LOG_DEBUG, ">");
else if (!USES_LIST(mb_type, 0))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "<");
else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
av_log(VAR_0->avctx, AV_LOG_DEBUG, "X");
}
if (IS_8X8(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "+");
else if (IS_16X8(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "-");
else if (IS_8X16(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "|");
else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, " ");
else
av_log(VAR_0->avctx, AV_LOG_DEBUG, "?");
if (IS_INTERLACED(mb_type))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "=");
else
av_log(VAR_0->avctx, AV_LOG_DEBUG, " ");
}
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
}
if ((VAR_0->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
(VAR_0->avctx->debug_mv)) {
const int VAR_4 = 1 + VAR_0->quarter_sample;
int VAR_5;
uint8_t *ptr;
int VAR_6;
int VAR_7, VAR_8, VAR_9;
const int VAR_10 = VAR_0->avctx->VAR_10;
const int VAR_11 = VAR_0->avctx->VAR_11;
const int VAR_12 = 4 - VAR_1->motion_subsample_log2;
const int VAR_13 = (VAR_0->mb_width << VAR_12) +
(VAR_0->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
VAR_0->low_delay = 0;
avcodec_get_chroma_sub_sample(VAR_0->avctx->pix_fmt,
&VAR_7, &VAR_8);
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
size_t size= (VAR_6 == 0) ? VAR_1->linesize[VAR_6] * FFALIGN(VAR_11, 16):
VAR_1->linesize[VAR_6] * FFALIGN(VAR_11, 16) >> VAR_8;
VAR_0->visualization_buffer[VAR_6]= av_realloc(VAR_0->visualization_buffer[VAR_6], size);
memcpy(VAR_0->visualization_buffer[VAR_6], VAR_1->data[VAR_6], size);
VAR_1->data[VAR_6] = VAR_0->visualization_buffer[VAR_6];
}
VAR_1->type = FF_BUFFER_TYPE_COPY;
VAR_1->opaque= NULL;
ptr = VAR_1->data[0];
VAR_9 = 16 >> VAR_8;
for (VAR_5 = 0; VAR_5 < VAR_0->mb_height; VAR_5++) {
int mb_x;
for (mb_x = 0; mb_x < VAR_0->mb_width; mb_x++) {
const int mb_index = mb_x + VAR_5 * VAR_0->mb_stride;
if ((VAR_0->avctx->debug_mv) && VAR_1->motion_val) {
int type;
for (type = 0; type < 3; type++) {
int direction = 0;
switch (type) {
case 0:
if ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||
(VAR_1->pict_type!= AV_PICTURE_TYPE_P))
continue;
direction = 0;
break;
case 1:
if ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||
(VAR_1->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 0;
break;
case 2:
if ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||
(VAR_1->pict_type!= AV_PICTURE_TYPE_B))
continue;
direction = 1;
break;
}
if (!USES_LIST(VAR_1->mb_type[mb_index], direction))
continue;
if (IS_8X8(VAR_1->mb_type[mb_index])) {
int VAR_6;
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
int sx = mb_x * 16 + 4 + 8 * (VAR_6 & 1);
int sy = VAR_5 * 16 + 4 + 8 * (VAR_6 >> 1);
int xy = (mb_x * 2 + (VAR_6 & 1) +
(VAR_5 * 2 + (VAR_6 >> 1)) * VAR_13) << (VAR_12 - 1);
int mx = (VAR_1->motion_val[direction][xy][0] >> VAR_4) + sx;
int my = (VAR_1->motion_val[direction][xy][1] >> VAR_4) + sy;
draw_arrow(ptr, sx, sy, mx, my, VAR_10,
VAR_11, VAR_0->linesize, 100);
}
} else if (IS_16X8(VAR_1->mb_type[mb_index])) {
int VAR_6;
for (VAR_6 = 0; VAR_6 < 2; VAR_6++) {
int sx = mb_x * 16 + 8;
int sy = VAR_5 * 16 + 4 + 8 * VAR_6;
int xy = (mb_x * 2 + (VAR_5 * 2 + VAR_6) * VAR_13) << (VAR_12 - 1);
int mx = (VAR_1->motion_val[direction][xy][0] >> VAR_4);
int my = (VAR_1->motion_val[direction][xy][1] >> VAR_4);
if (IS_INTERLACED(VAR_1->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, VAR_10,
VAR_11, VAR_0->linesize, 100);
}
} else if (IS_8X16(VAR_1->mb_type[mb_index])) {
int VAR_6;
for (VAR_6 = 0; VAR_6 < 2; VAR_6++) {
int sx = mb_x * 16 + 4 + 8 * VAR_6;
int sy = VAR_5 * 16 + 8;
int xy = (mb_x * 2 + VAR_6 + VAR_5 * 2 * VAR_13) << (VAR_12 - 1);
int mx = VAR_1->motion_val[direction][xy][0] >> VAR_4;
int my = VAR_1->motion_val[direction][xy][1] >> VAR_4;
if (IS_INTERLACED(VAR_1->mb_type[mb_index]))
my *= 2;
draw_arrow(ptr, sx, sy, mx + sx, my + sy, VAR_10,
VAR_11, VAR_0->linesize, 100);
}
} else {
int sx= mb_x * 16 + 8;
int sy= VAR_5 * 16 + 8;
int xy= (mb_x + VAR_5 * VAR_13) << VAR_12;
int mx= (VAR_1->motion_val[direction][xy][0]>>VAR_4) + sx;
int my= (VAR_1->motion_val[direction][xy][1]>>VAR_4) + sy;
draw_arrow(ptr, sx, sy, mx, my, VAR_10, VAR_11, VAR_0->linesize, 100);
}
}
}
if ((VAR_0->avctx->debug & FF_DEBUG_VIS_QP) && VAR_1->motion_val) {
uint64_t c = (VAR_1->qscale_table[mb_index] * 128 / 31) *
0x0101010101010101ULL;
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_9; VAR_3++) {
*(uint64_t *)(VAR_1->data[1] + 8 * mb_x +
(VAR_9 * VAR_5 + VAR_3) *
VAR_1->linesize[1]) = c;
*(uint64_t *)(VAR_1->data[2] + 8 * mb_x +
(VAR_9 * VAR_5 + VAR_3) *
VAR_1->linesize[2]) = c;
}
}
if ((VAR_0->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
VAR_1->motion_val) {
int mb_type = VAR_1->mb_type[mb_index];
uint64_t u,v;
int VAR_3;
#define COLOR(theta, r) \
u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
v = (int)(128 + r * sin(theta * 3.141592 / 180));
u = v = 128;
if (IS_PCM(mb_type)) {
COLOR(120, 48)
} else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
IS_INTRA16x16(mb_type)) {
COLOR(30, 48)
} else if (IS_INTRA4x4(mb_type)) {
COLOR(90, 48)
} else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
} else if (IS_DIRECT(mb_type)) {
COLOR(150, 48)
} else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
COLOR(170, 48)
} else if (IS_GMC(mb_type)) {
COLOR(190, 48)
} else if (IS_SKIP(mb_type)) {
} else if (!USES_LIST(mb_type, 1)) {
COLOR(240, 48)
} else if (!USES_LIST(mb_type, 0)) {
COLOR(0, 48)
} else {
av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
COLOR(300,48)
}
u *= 0x0101010101010101ULL;
v *= 0x0101010101010101ULL;
for (VAR_3 = 0; VAR_3 < VAR_9; VAR_3++) {
*(uint64_t *)(VAR_1->data[1] + 8 * mb_x +
(VAR_9 * VAR_5 + VAR_3) * VAR_1->linesize[1]) = u;
*(uint64_t *)(VAR_1->data[2] + 8 * mb_x +
(VAR_9 * VAR_5 + VAR_3) * VAR_1->linesize[2]) = v;
}
if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
*(uint64_t *)(VAR_1->data[0] + 16 * mb_x + 0 +
(16 * VAR_5 + 8) * VAR_1->linesize[0]) ^= 0x8080808080808080ULL;
*(uint64_t *)(VAR_1->data[0] + 16 * mb_x + 8 +
(16 * VAR_5 + 8) * VAR_1->linesize[0]) ^= 0x8080808080808080ULL;
}
if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
for (VAR_3 = 0; VAR_3 < 16; VAR_3++)
VAR_1->data[0][16 * mb_x + 8 + (16 * VAR_5 + VAR_3) *
VAR_1->linesize[0]] ^= 0x80;
}
if (IS_8X8(mb_type) && VAR_12 >= 2) {
int dm = 1 << (VAR_12 - 2);
for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {
int sx = mb_x * 16 + 8 * (VAR_6 & 1);
int sy = VAR_5 * 16 + 8 * (VAR_6 >> 1);
int xy = (mb_x * 2 + (VAR_6 & 1) +
(VAR_5 * 2 + (VAR_6 >> 1)) * VAR_13) << (VAR_12 - 1);
int32_t *mv = (int32_t *) &VAR_1->motion_val[0][xy];
if (mv[0] != mv[dm] ||
mv[dm * VAR_13] != mv[dm * (VAR_13 + 1)])
for (VAR_3 = 0; VAR_3 < 8; VAR_3++)
VAR_1->data[0][sx + 4 + (sy + VAR_3) * VAR_1->linesize[0]] ^= 0x80;
if (mv[0] != mv[dm * VAR_13] || mv[dm] != mv[dm * (VAR_13 + 1)])
*(uint64_t *)(VAR_1->data[0] + sx + (sy + 4) *
VAR_1->linesize[0]) ^= 0x8080808080808080ULL;
}
}
if (IS_INTERLACED(mb_type) &&
VAR_0->codec_id == AV_CODEC_ID_H264) {
}
}
VAR_0->mbskip_table[mb_index] = 0;
}
}
}
}
| [
"void FUNC_0(MpegEncContext *VAR_0, AVFrame *VAR_1)\n{",
"if ( VAR_0->avctx->hwaccel || !VAR_1 || !VAR_1->mb_type\n|| (VAR_0->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))\nreturn;",
"if (VAR_0->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {",
"int VAR_2,VAR_3;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"New frame, type: %c\\n\",\nav_get_picture_type_char(VAR_1->pict_type));",
"for (VAR_3 = 0; VAR_3 < VAR_0->mb_height; VAR_3++) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->mb_width; VAR_2++) {",
"if (VAR_0->avctx->debug & FF_DEBUG_SKIP) {",
"int count = VAR_0->mbskip_table[VAR_2 + VAR_3 * VAR_0->mb_stride];",
"if (count > 9)\ncount = 9;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%1d\", count);",
"}",
"if (VAR_0->avctx->debug & FF_DEBUG_QP) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%2d\",\nVAR_1->qscale_table[VAR_2 + VAR_3 * VAR_0->mb_stride]);",
"}",
"if (VAR_0->avctx->debug & FF_DEBUG_MB_TYPE) {",
"int mb_type = VAR_1->mb_type[VAR_2 + VAR_3 * VAR_0->mb_stride];",
"if (IS_PCM(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"P\");",
"else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"A\");",
"else if (IS_INTRA4x4(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"VAR_6\");",
"else if (IS_INTRA16x16(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"I\");",
"else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"d\");",
"else if (IS_DIRECT(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"D\");",
"else if (IS_GMC(mb_type) && IS_SKIP(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"g\");",
"else if (IS_GMC(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"G\");",
"else if (IS_SKIP(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"S\");",
"else if (!USES_LIST(mb_type, 1))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \">\");",
"else if (!USES_LIST(mb_type, 0))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"<\");",
"else {",
"av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"X\");",
"}",
"if (IS_8X8(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"+\");",
"else if (IS_16X8(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"-\");",
"else if (IS_8X16(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"|\");",
"else if (IS_INTRA(mb_type) || IS_16X16(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \" \");",
"else\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"?\");",
"if (IS_INTERLACED(mb_type))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"=\");",
"else\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \" \");",
"}",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"}",
"if ((VAR_0->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||\n(VAR_0->avctx->debug_mv)) {",
"const int VAR_4 = 1 + VAR_0->quarter_sample;",
"int VAR_5;",
"uint8_t *ptr;",
"int VAR_6;",
"int VAR_7, VAR_8, VAR_9;",
"const int VAR_10 = VAR_0->avctx->VAR_10;",
"const int VAR_11 = VAR_0->avctx->VAR_11;",
"const int VAR_12 = 4 - VAR_1->motion_subsample_log2;",
"const int VAR_13 = (VAR_0->mb_width << VAR_12) +\n(VAR_0->codec_id == AV_CODEC_ID_H264 ? 0 : 1);",
"VAR_0->low_delay = 0;",
"avcodec_get_chroma_sub_sample(VAR_0->avctx->pix_fmt,\n&VAR_7, &VAR_8);",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"size_t size= (VAR_6 == 0) ? VAR_1->linesize[VAR_6] * FFALIGN(VAR_11, 16):\nVAR_1->linesize[VAR_6] * FFALIGN(VAR_11, 16) >> VAR_8;",
"VAR_0->visualization_buffer[VAR_6]= av_realloc(VAR_0->visualization_buffer[VAR_6], size);",
"memcpy(VAR_0->visualization_buffer[VAR_6], VAR_1->data[VAR_6], size);",
"VAR_1->data[VAR_6] = VAR_0->visualization_buffer[VAR_6];",
"}",
"VAR_1->type = FF_BUFFER_TYPE_COPY;",
"VAR_1->opaque= NULL;",
"ptr = VAR_1->data[0];",
"VAR_9 = 16 >> VAR_8;",
"for (VAR_5 = 0; VAR_5 < VAR_0->mb_height; VAR_5++) {",
"int mb_x;",
"for (mb_x = 0; mb_x < VAR_0->mb_width; mb_x++) {",
"const int mb_index = mb_x + VAR_5 * VAR_0->mb_stride;",
"if ((VAR_0->avctx->debug_mv) && VAR_1->motion_val) {",
"int type;",
"for (type = 0; type < 3; type++) {",
"int direction = 0;",
"switch (type) {",
"case 0:\nif ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||\n(VAR_1->pict_type!= AV_PICTURE_TYPE_P))\ncontinue;",
"direction = 0;",
"break;",
"case 1:\nif ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||\n(VAR_1->pict_type!= AV_PICTURE_TYPE_B))\ncontinue;",
"direction = 0;",
"break;",
"case 2:\nif ((!(VAR_0->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||\n(VAR_1->pict_type!= AV_PICTURE_TYPE_B))\ncontinue;",
"direction = 1;",
"break;",
"}",
"if (!USES_LIST(VAR_1->mb_type[mb_index], direction))\ncontinue;",
"if (IS_8X8(VAR_1->mb_type[mb_index])) {",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"int sx = mb_x * 16 + 4 + 8 * (VAR_6 & 1);",
"int sy = VAR_5 * 16 + 4 + 8 * (VAR_6 >> 1);",
"int xy = (mb_x * 2 + (VAR_6 & 1) +\n(VAR_5 * 2 + (VAR_6 >> 1)) * VAR_13) << (VAR_12 - 1);",
"int mx = (VAR_1->motion_val[direction][xy][0] >> VAR_4) + sx;",
"int my = (VAR_1->motion_val[direction][xy][1] >> VAR_4) + sy;",
"draw_arrow(ptr, sx, sy, mx, my, VAR_10,\nVAR_11, VAR_0->linesize, 100);",
"}",
"} else if (IS_16X8(VAR_1->mb_type[mb_index])) {",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < 2; VAR_6++) {",
"int sx = mb_x * 16 + 8;",
"int sy = VAR_5 * 16 + 4 + 8 * VAR_6;",
"int xy = (mb_x * 2 + (VAR_5 * 2 + VAR_6) * VAR_13) << (VAR_12 - 1);",
"int mx = (VAR_1->motion_val[direction][xy][0] >> VAR_4);",
"int my = (VAR_1->motion_val[direction][xy][1] >> VAR_4);",
"if (IS_INTERLACED(VAR_1->mb_type[mb_index]))\nmy *= 2;",
"draw_arrow(ptr, sx, sy, mx + sx, my + sy, VAR_10,\nVAR_11, VAR_0->linesize, 100);",
"}",
"} else if (IS_8X16(VAR_1->mb_type[mb_index])) {",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < 2; VAR_6++) {",
"int sx = mb_x * 16 + 4 + 8 * VAR_6;",
"int sy = VAR_5 * 16 + 8;",
"int xy = (mb_x * 2 + VAR_6 + VAR_5 * 2 * VAR_13) << (VAR_12 - 1);",
"int mx = VAR_1->motion_val[direction][xy][0] >> VAR_4;",
"int my = VAR_1->motion_val[direction][xy][1] >> VAR_4;",
"if (IS_INTERLACED(VAR_1->mb_type[mb_index]))\nmy *= 2;",
"draw_arrow(ptr, sx, sy, mx + sx, my + sy, VAR_10,\nVAR_11, VAR_0->linesize, 100);",
"}",
"} else {",
"int sx= mb_x * 16 + 8;",
"int sy= VAR_5 * 16 + 8;",
"int xy= (mb_x + VAR_5 * VAR_13) << VAR_12;",
"int mx= (VAR_1->motion_val[direction][xy][0]>>VAR_4) + sx;",
"int my= (VAR_1->motion_val[direction][xy][1]>>VAR_4) + sy;",
"draw_arrow(ptr, sx, sy, mx, my, VAR_10, VAR_11, VAR_0->linesize, 100);",
"}",
"}",
"}",
"if ((VAR_0->avctx->debug & FF_DEBUG_VIS_QP) && VAR_1->motion_val) {",
"uint64_t c = (VAR_1->qscale_table[mb_index] * 128 / 31) *\n0x0101010101010101ULL;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_9; VAR_3++) {",
"*(uint64_t *)(VAR_1->data[1] + 8 * mb_x +\n(VAR_9 * VAR_5 + VAR_3) *\nVAR_1->linesize[1]) = c;",
"*(uint64_t *)(VAR_1->data[2] + 8 * mb_x +\n(VAR_9 * VAR_5 + VAR_3) *\nVAR_1->linesize[2]) = c;",
"}",
"}",
"if ((VAR_0->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&\nVAR_1->motion_val) {",
"int mb_type = VAR_1->mb_type[mb_index];",
"uint64_t u,v;",
"int VAR_3;",
"#define COLOR(theta, r) \\\nu = (int)(128 + r * cos(theta * 3.141592 / 180)); \\",
"v = (int)(128 + r * sin(theta * 3.141592 / 180));",
"u = v = 128;",
"if (IS_PCM(mb_type)) {",
"COLOR(120, 48)\n} else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||",
"IS_INTRA16x16(mb_type)) {",
"COLOR(30, 48)\n} else if (IS_INTRA4x4(mb_type)) {",
"COLOR(90, 48)\n} else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {",
"} else if (IS_DIRECT(mb_type)) {",
"COLOR(150, 48)\n} else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {",
"COLOR(170, 48)\n} else if (IS_GMC(mb_type)) {",
"COLOR(190, 48)\n} else if (IS_SKIP(mb_type)) {",
"} else if (!USES_LIST(mb_type, 1)) {",
"COLOR(240, 48)\n} else if (!USES_LIST(mb_type, 0)) {",
"COLOR(0, 48)\n} else {",
"av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));",
"COLOR(300,48)\n}",
"u *= 0x0101010101010101ULL;",
"v *= 0x0101010101010101ULL;",
"for (VAR_3 = 0; VAR_3 < VAR_9; VAR_3++) {",
"*(uint64_t *)(VAR_1->data[1] + 8 * mb_x +\n(VAR_9 * VAR_5 + VAR_3) * VAR_1->linesize[1]) = u;",
"*(uint64_t *)(VAR_1->data[2] + 8 * mb_x +\n(VAR_9 * VAR_5 + VAR_3) * VAR_1->linesize[2]) = v;",
"}",
"if (IS_8X8(mb_type) || IS_16X8(mb_type)) {",
"*(uint64_t *)(VAR_1->data[0] + 16 * mb_x + 0 +\n(16 * VAR_5 + 8) * VAR_1->linesize[0]) ^= 0x8080808080808080ULL;",
"*(uint64_t *)(VAR_1->data[0] + 16 * mb_x + 8 +\n(16 * VAR_5 + 8) * VAR_1->linesize[0]) ^= 0x8080808080808080ULL;",
"}",
"if (IS_8X8(mb_type) || IS_8X16(mb_type)) {",
"for (VAR_3 = 0; VAR_3 < 16; VAR_3++)",
"VAR_1->data[0][16 * mb_x + 8 + (16 * VAR_5 + VAR_3) *\nVAR_1->linesize[0]] ^= 0x80;",
"}",
"if (IS_8X8(mb_type) && VAR_12 >= 2) {",
"int dm = 1 << (VAR_12 - 2);",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++) {",
"int sx = mb_x * 16 + 8 * (VAR_6 & 1);",
"int sy = VAR_5 * 16 + 8 * (VAR_6 >> 1);",
"int xy = (mb_x * 2 + (VAR_6 & 1) +\n(VAR_5 * 2 + (VAR_6 >> 1)) * VAR_13) << (VAR_12 - 1);",
"int32_t *mv = (int32_t *) &VAR_1->motion_val[0][xy];",
"if (mv[0] != mv[dm] ||\nmv[dm * VAR_13] != mv[dm * (VAR_13 + 1)])\nfor (VAR_3 = 0; VAR_3 < 8; VAR_3++)",
"VAR_1->data[0][sx + 4 + (sy + VAR_3) * VAR_1->linesize[0]] ^= 0x80;",
"if (mv[0] != mv[dm * VAR_13] || mv[dm] != mv[dm * (VAR_13 + 1)])\n*(uint64_t *)(VAR_1->data[0] + sx + (sy + 4) *\nVAR_1->linesize[0]) ^= 0x8080808080808080ULL;",
"}",
"}",
"if (IS_INTERLACED(mb_type) &&\nVAR_0->codec_id == AV_CODEC_ID_H264) {",
"}",
"}",
"VAR_0->mbskip_table[mb_index] = 0;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
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
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
135,
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231,
233,
235
],
[
237
],
[
239
],
[
241,
243,
245,
247
],
[
249
],
[
251
],
[
253,
255,
257,
259
],
[
261
],
[
263
],
[
265
],
[
267,
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283,
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315,
317
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
345,
347
],
[
351,
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
387,
389,
391
],
[
393,
395,
397
],
[
399
],
[
401
],
[
403,
405
],
[
407
],
[
409
],
[
411
],
[
413,
415
],
[
417
],
[
423
],
[
425
],
[
427,
429
],
[
431
],
[
433,
435
],
[
437,
439
],
[
443
],
[
445,
447
],
[
449,
451
],
[
453,
455
],
[
459
],
[
461,
463
],
[
465,
467
],
[
469
],
[
471,
473
],
[
477
],
[
479
],
[
481
],
[
483,
485
],
[
487,
489
],
[
491
],
[
497
],
[
499,
501
],
[
503,
505
],
[
507
],
[
509
],
[
511
],
[
513,
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529,
531
],
[
535
],
[
537,
539,
541
],
[
543
],
[
545,
547,
549
],
[
551
],
[
553
],
[
557,
559
],
[
563
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
]
] |
19,013 | static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);
}
| {
"code": [
" return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);"
],
"line_no": [
7
]
} | static uint8_t FUNC_0(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);
}
| [
"static uint8_t FUNC_0(QVirtioDevice *d, uint64_t off)\n{",
"QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;",
"return qpci_io_readb(dev->pdev, CONFIG_BASE(dev) + off);",
"}"
] | [
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
19,015 | int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)
{
env->msr_mask = def->msr_mask;
env->mmu_model = def->mmu_model;
env->excp_model = def->excp_model;
env->bus_model = def->bus_model;
env->insns_flags = def->insns_flags;
env->insns_flags2 = def->insns_flags2;
env->flags = def->flags;
env->bfd_mach = def->bfd_mach;
env->check_pow = def->check_pow;
if (kvm_enabled()) {
if (kvmppc_fixup_cpu(env) != 0) {
fprintf(stderr, "Unable to virtualize selected CPU with KVM\n");
exit(1);
} else {
if (ppc_fixup_cpu(env) != 0) {
fprintf(stderr, "Unable to emulate selected CPU with TCG\n");
exit(1);
if (create_ppc_opcodes(env, def) < 0)
return -1;
init_ppc_proc(env, def);
if (def->insns_flags & PPC_FLOAT) {
gdb_register_coprocessor(env, gdb_get_float_reg, gdb_set_float_reg,
33, "power-fpu.xml", 0);
if (def->insns_flags & PPC_ALTIVEC) {
gdb_register_coprocessor(env, gdb_get_avr_reg, gdb_set_avr_reg,
34, "power-altivec.xml", 0);
if (def->insns_flags & PPC_SPE) {
gdb_register_coprocessor(env, gdb_get_spe_reg, gdb_set_spe_reg,
34, "power-spe.xml", 0);
#if defined(PPC_DUMP_CPU)
{
const char *mmu_model, *excp_model, *bus_model;
switch (env->mmu_model) {
case POWERPC_MMU_32B:
mmu_model = "PowerPC 32";
break;
case POWERPC_MMU_SOFT_6xx:
mmu_model = "PowerPC 6xx/7xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_74xx:
mmu_model = "PowerPC 74xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx:
mmu_model = "PowerPC 4xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx_Z:
mmu_model = "PowerPC 4xx with software driven TLBs "
"and zones protections";
break;
case POWERPC_MMU_REAL:
mmu_model = "PowerPC real mode only";
break;
case POWERPC_MMU_MPC8xx:
mmu_model = "PowerPC MPC8xx";
break;
case POWERPC_MMU_BOOKE:
mmu_model = "PowerPC BookE";
break;
case POWERPC_MMU_BOOKE206:
mmu_model = "PowerPC BookE 2.06";
break;
case POWERPC_MMU_601:
mmu_model = "PowerPC 601";
break;
#if defined (TARGET_PPC64)
case POWERPC_MMU_64B:
mmu_model = "PowerPC 64";
break;
case POWERPC_MMU_620:
mmu_model = "PowerPC 620";
break;
#endif
default:
mmu_model = "Unknown or invalid";
break;
switch (env->excp_model) {
case POWERPC_EXCP_STD:
excp_model = "PowerPC";
break;
case POWERPC_EXCP_40x:
excp_model = "PowerPC 40x";
break;
case POWERPC_EXCP_601:
excp_model = "PowerPC 601";
break;
case POWERPC_EXCP_602:
excp_model = "PowerPC 602";
break;
case POWERPC_EXCP_603:
excp_model = "PowerPC 603";
break;
case POWERPC_EXCP_603E:
excp_model = "PowerPC 603e";
break;
case POWERPC_EXCP_604:
excp_model = "PowerPC 604";
break;
case POWERPC_EXCP_7x0:
excp_model = "PowerPC 740/750";
break;
case POWERPC_EXCP_7x5:
excp_model = "PowerPC 745/755";
break;
case POWERPC_EXCP_74xx:
excp_model = "PowerPC 74xx";
break;
case POWERPC_EXCP_BOOKE:
excp_model = "PowerPC BookE";
break;
#if defined (TARGET_PPC64)
case POWERPC_EXCP_970:
excp_model = "PowerPC 970";
break;
#endif
default:
excp_model = "Unknown or invalid";
break;
switch (env->bus_model) {
case PPC_FLAGS_INPUT_6xx:
bus_model = "PowerPC 6xx";
break;
case PPC_FLAGS_INPUT_BookE:
bus_model = "PowerPC BookE";
break;
case PPC_FLAGS_INPUT_405:
bus_model = "PowerPC 405";
break;
case PPC_FLAGS_INPUT_401:
bus_model = "PowerPC 401/403";
break;
case PPC_FLAGS_INPUT_RCPU:
bus_model = "RCPU / MPC8xx";
break;
#if defined (TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
bus_model = "PowerPC 970";
break;
#endif
default:
bus_model = "Unknown or invalid";
break;
printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n"
" MMU model : %s\n",
def->name, def->pvr, def->msr_mask, mmu_model);
#if !defined(CONFIG_USER_ONLY)
if (env->tlb != NULL) {
printf(" %d %s TLB in %d ways\n",
env->nb_tlb, env->id_tlbs ? "splitted" : "merged",
env->nb_ways);
#endif
printf(" Exceptions model : %s\n"
" Bus model : %s\n",
excp_model, bus_model);
printf(" MSR features :\n");
if (env->flags & POWERPC_FLAG_SPE)
printf(" signal processing engine enable"
"\n");
else if (env->flags & POWERPC_FLAG_VRE)
printf(" vector processor enable\n");
if (env->flags & POWERPC_FLAG_TGPR)
printf(" temporary GPRs\n");
else if (env->flags & POWERPC_FLAG_CE)
printf(" critical input enable\n");
if (env->flags & POWERPC_FLAG_SE)
printf(" single-step trace mode\n");
else if (env->flags & POWERPC_FLAG_DWE)
printf(" debug wait enable\n");
else if (env->flags & POWERPC_FLAG_UBLE)
printf(" user BTB lock enable\n");
if (env->flags & POWERPC_FLAG_BE)
printf(" branch-step trace mode\n");
else if (env->flags & POWERPC_FLAG_DE)
printf(" debug interrupt enable\n");
if (env->flags & POWERPC_FLAG_PX)
printf(" inclusive protection\n");
else if (env->flags & POWERPC_FLAG_PMM)
printf(" performance monitor mark\n");
if (env->flags == POWERPC_FLAG_NONE)
printf(" none\n");
printf(" Time-base/decrementer clock source: %s\n",
env->flags & POWERPC_FLAG_RTC_CLK ? "RTC clock" : "bus clock");
dump_ppc_insns(env);
dump_ppc_sprs(env);
fflush(stdout);
#endif
return 0; | true | qemu | 4656e1f01289cc3aa20986deb6a407165826abe5 | int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)
{
env->msr_mask = def->msr_mask;
env->mmu_model = def->mmu_model;
env->excp_model = def->excp_model;
env->bus_model = def->bus_model;
env->insns_flags = def->insns_flags;
env->insns_flags2 = def->insns_flags2;
env->flags = def->flags;
env->bfd_mach = def->bfd_mach;
env->check_pow = def->check_pow;
if (kvm_enabled()) {
if (kvmppc_fixup_cpu(env) != 0) {
fprintf(stderr, "Unable to virtualize selected CPU with KVM\n");
exit(1);
} else {
if (ppc_fixup_cpu(env) != 0) {
fprintf(stderr, "Unable to emulate selected CPU with TCG\n");
exit(1);
if (create_ppc_opcodes(env, def) < 0)
return -1;
init_ppc_proc(env, def);
if (def->insns_flags & PPC_FLOAT) {
gdb_register_coprocessor(env, gdb_get_float_reg, gdb_set_float_reg,
33, "power-fpu.xml", 0);
if (def->insns_flags & PPC_ALTIVEC) {
gdb_register_coprocessor(env, gdb_get_avr_reg, gdb_set_avr_reg,
34, "power-altivec.xml", 0);
if (def->insns_flags & PPC_SPE) {
gdb_register_coprocessor(env, gdb_get_spe_reg, gdb_set_spe_reg,
34, "power-spe.xml", 0);
#if defined(PPC_DUMP_CPU)
{
const char *mmu_model, *excp_model, *bus_model;
switch (env->mmu_model) {
case POWERPC_MMU_32B:
mmu_model = "PowerPC 32";
break;
case POWERPC_MMU_SOFT_6xx:
mmu_model = "PowerPC 6xx/7xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_74xx:
mmu_model = "PowerPC 74xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx:
mmu_model = "PowerPC 4xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx_Z:
mmu_model = "PowerPC 4xx with software driven TLBs "
"and zones protections";
break;
case POWERPC_MMU_REAL:
mmu_model = "PowerPC real mode only";
break;
case POWERPC_MMU_MPC8xx:
mmu_model = "PowerPC MPC8xx";
break;
case POWERPC_MMU_BOOKE:
mmu_model = "PowerPC BookE";
break;
case POWERPC_MMU_BOOKE206:
mmu_model = "PowerPC BookE 2.06";
break;
case POWERPC_MMU_601:
mmu_model = "PowerPC 601";
break;
#if defined (TARGET_PPC64)
case POWERPC_MMU_64B:
mmu_model = "PowerPC 64";
break;
case POWERPC_MMU_620:
mmu_model = "PowerPC 620";
break;
#endif
default:
mmu_model = "Unknown or invalid";
break;
switch (env->excp_model) {
case POWERPC_EXCP_STD:
excp_model = "PowerPC";
break;
case POWERPC_EXCP_40x:
excp_model = "PowerPC 40x";
break;
case POWERPC_EXCP_601:
excp_model = "PowerPC 601";
break;
case POWERPC_EXCP_602:
excp_model = "PowerPC 602";
break;
case POWERPC_EXCP_603:
excp_model = "PowerPC 603";
break;
case POWERPC_EXCP_603E:
excp_model = "PowerPC 603e";
break;
case POWERPC_EXCP_604:
excp_model = "PowerPC 604";
break;
case POWERPC_EXCP_7x0:
excp_model = "PowerPC 740/750";
break;
case POWERPC_EXCP_7x5:
excp_model = "PowerPC 745/755";
break;
case POWERPC_EXCP_74xx:
excp_model = "PowerPC 74xx";
break;
case POWERPC_EXCP_BOOKE:
excp_model = "PowerPC BookE";
break;
#if defined (TARGET_PPC64)
case POWERPC_EXCP_970:
excp_model = "PowerPC 970";
break;
#endif
default:
excp_model = "Unknown or invalid";
break;
switch (env->bus_model) {
case PPC_FLAGS_INPUT_6xx:
bus_model = "PowerPC 6xx";
break;
case PPC_FLAGS_INPUT_BookE:
bus_model = "PowerPC BookE";
break;
case PPC_FLAGS_INPUT_405:
bus_model = "PowerPC 405";
break;
case PPC_FLAGS_INPUT_401:
bus_model = "PowerPC 401/403";
break;
case PPC_FLAGS_INPUT_RCPU:
bus_model = "RCPU / MPC8xx";
break;
#if defined (TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
bus_model = "PowerPC 970";
break;
#endif
default:
bus_model = "Unknown or invalid";
break;
printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n"
" MMU model : %s\n",
def->name, def->pvr, def->msr_mask, mmu_model);
#if !defined(CONFIG_USER_ONLY)
if (env->tlb != NULL) {
printf(" %d %s TLB in %d ways\n",
env->nb_tlb, env->id_tlbs ? "splitted" : "merged",
env->nb_ways);
#endif
printf(" Exceptions model : %s\n"
" Bus model : %s\n",
excp_model, bus_model);
printf(" MSR features :\n");
if (env->flags & POWERPC_FLAG_SPE)
printf(" signal processing engine enable"
"\n");
else if (env->flags & POWERPC_FLAG_VRE)
printf(" vector processor enable\n");
if (env->flags & POWERPC_FLAG_TGPR)
printf(" temporary GPRs\n");
else if (env->flags & POWERPC_FLAG_CE)
printf(" critical input enable\n");
if (env->flags & POWERPC_FLAG_SE)
printf(" single-step trace mode\n");
else if (env->flags & POWERPC_FLAG_DWE)
printf(" debug wait enable\n");
else if (env->flags & POWERPC_FLAG_UBLE)
printf(" user BTB lock enable\n");
if (env->flags & POWERPC_FLAG_BE)
printf(" branch-step trace mode\n");
else if (env->flags & POWERPC_FLAG_DE)
printf(" debug interrupt enable\n");
if (env->flags & POWERPC_FLAG_PX)
printf(" inclusive protection\n");
else if (env->flags & POWERPC_FLAG_PMM)
printf(" performance monitor mark\n");
if (env->flags == POWERPC_FLAG_NONE)
printf(" none\n");
printf(" Time-base/decrementer clock source: %s\n",
env->flags & POWERPC_FLAG_RTC_CLK ? "RTC clock" : "bus clock");
dump_ppc_insns(env);
dump_ppc_sprs(env);
fflush(stdout);
#endif
return 0; | {
"code": [],
"line_no": []
} | int FUNC_0 (CPUPPCState *VAR_0, const ppc_def_t *VAR_1)
{
VAR_0->msr_mask = VAR_1->msr_mask;
VAR_0->mmu_model = VAR_1->mmu_model;
VAR_0->excp_model = VAR_1->excp_model;
VAR_0->bus_model = VAR_1->bus_model;
VAR_0->insns_flags = VAR_1->insns_flags;
VAR_0->insns_flags2 = VAR_1->insns_flags2;
VAR_0->flags = VAR_1->flags;
VAR_0->bfd_mach = VAR_1->bfd_mach;
VAR_0->check_pow = VAR_1->check_pow;
if (kvm_enabled()) {
if (kvmppc_fixup_cpu(VAR_0) != 0) {
fprintf(stderr, "Unable to virtualize selected CPU with KVM\n");
exit(1);
} else {
if (ppc_fixup_cpu(VAR_0) != 0) {
fprintf(stderr, "Unable to emulate selected CPU with TCG\n");
exit(1);
if (create_ppc_opcodes(VAR_0, VAR_1) < 0)
return -1;
init_ppc_proc(VAR_0, VAR_1);
if (VAR_1->insns_flags & PPC_FLOAT) {
gdb_register_coprocessor(VAR_0, gdb_get_float_reg, gdb_set_float_reg,
33, "power-fpu.xml", 0);
if (VAR_1->insns_flags & PPC_ALTIVEC) {
gdb_register_coprocessor(VAR_0, gdb_get_avr_reg, gdb_set_avr_reg,
34, "power-altivec.xml", 0);
if (VAR_1->insns_flags & PPC_SPE) {
gdb_register_coprocessor(VAR_0, gdb_get_spe_reg, gdb_set_spe_reg,
34, "power-spe.xml", 0);
#if defined(PPC_DUMP_CPU)
{
const char *mmu_model, *excp_model, *bus_model;
switch (VAR_0->mmu_model) {
case POWERPC_MMU_32B:
mmu_model = "PowerPC 32";
break;
case POWERPC_MMU_SOFT_6xx:
mmu_model = "PowerPC 6xx/7xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_74xx:
mmu_model = "PowerPC 74xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx:
mmu_model = "PowerPC 4xx with software driven TLBs";
break;
case POWERPC_MMU_SOFT_4xx_Z:
mmu_model = "PowerPC 4xx with software driven TLBs "
"and zones protections";
break;
case POWERPC_MMU_REAL:
mmu_model = "PowerPC real mode only";
break;
case POWERPC_MMU_MPC8xx:
mmu_model = "PowerPC MPC8xx";
break;
case POWERPC_MMU_BOOKE:
mmu_model = "PowerPC BookE";
break;
case POWERPC_MMU_BOOKE206:
mmu_model = "PowerPC BookE 2.06";
break;
case POWERPC_MMU_601:
mmu_model = "PowerPC 601";
break;
#if defined (TARGET_PPC64)
case POWERPC_MMU_64B:
mmu_model = "PowerPC 64";
break;
case POWERPC_MMU_620:
mmu_model = "PowerPC 620";
break;
#endif
default:
mmu_model = "Unknown or invalid";
break;
switch (VAR_0->excp_model) {
case POWERPC_EXCP_STD:
excp_model = "PowerPC";
break;
case POWERPC_EXCP_40x:
excp_model = "PowerPC 40x";
break;
case POWERPC_EXCP_601:
excp_model = "PowerPC 601";
break;
case POWERPC_EXCP_602:
excp_model = "PowerPC 602";
break;
case POWERPC_EXCP_603:
excp_model = "PowerPC 603";
break;
case POWERPC_EXCP_603E:
excp_model = "PowerPC 603e";
break;
case POWERPC_EXCP_604:
excp_model = "PowerPC 604";
break;
case POWERPC_EXCP_7x0:
excp_model = "PowerPC 740/750";
break;
case POWERPC_EXCP_7x5:
excp_model = "PowerPC 745/755";
break;
case POWERPC_EXCP_74xx:
excp_model = "PowerPC 74xx";
break;
case POWERPC_EXCP_BOOKE:
excp_model = "PowerPC BookE";
break;
#if defined (TARGET_PPC64)
case POWERPC_EXCP_970:
excp_model = "PowerPC 970";
break;
#endif
default:
excp_model = "Unknown or invalid";
break;
switch (VAR_0->bus_model) {
case PPC_FLAGS_INPUT_6xx:
bus_model = "PowerPC 6xx";
break;
case PPC_FLAGS_INPUT_BookE:
bus_model = "PowerPC BookE";
break;
case PPC_FLAGS_INPUT_405:
bus_model = "PowerPC 405";
break;
case PPC_FLAGS_INPUT_401:
bus_model = "PowerPC 401/403";
break;
case PPC_FLAGS_INPUT_RCPU:
bus_model = "RCPU / MPC8xx";
break;
#if defined (TARGET_PPC64)
case PPC_FLAGS_INPUT_970:
bus_model = "PowerPC 970";
break;
#endif
default:
bus_model = "Unknown or invalid";
break;
printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n"
" MMU model : %s\n",
VAR_1->name, VAR_1->pvr, VAR_1->msr_mask, mmu_model);
#if !defined(CONFIG_USER_ONLY)
if (VAR_0->tlb != NULL) {
printf(" %d %s TLB in %d ways\n",
VAR_0->nb_tlb, VAR_0->id_tlbs ? "splitted" : "merged",
VAR_0->nb_ways);
#endif
printf(" Exceptions model : %s\n"
" Bus model : %s\n",
excp_model, bus_model);
printf(" MSR features :\n");
if (VAR_0->flags & POWERPC_FLAG_SPE)
printf(" signal processing engine enable"
"\n");
else if (VAR_0->flags & POWERPC_FLAG_VRE)
printf(" vector processor enable\n");
if (VAR_0->flags & POWERPC_FLAG_TGPR)
printf(" temporary GPRs\n");
else if (VAR_0->flags & POWERPC_FLAG_CE)
printf(" critical input enable\n");
if (VAR_0->flags & POWERPC_FLAG_SE)
printf(" single-step trace mode\n");
else if (VAR_0->flags & POWERPC_FLAG_DWE)
printf(" debug wait enable\n");
else if (VAR_0->flags & POWERPC_FLAG_UBLE)
printf(" user BTB lock enable\n");
if (VAR_0->flags & POWERPC_FLAG_BE)
printf(" branch-step trace mode\n");
else if (VAR_0->flags & POWERPC_FLAG_DE)
printf(" debug interrupt enable\n");
if (VAR_0->flags & POWERPC_FLAG_PX)
printf(" inclusive protection\n");
else if (VAR_0->flags & POWERPC_FLAG_PMM)
printf(" performance monitor mark\n");
if (VAR_0->flags == POWERPC_FLAG_NONE)
printf(" none\n");
printf(" Time-base/decrementer clock source: %s\n",
VAR_0->flags & POWERPC_FLAG_RTC_CLK ? "RTC clock" : "bus clock");
dump_ppc_insns(VAR_0);
dump_ppc_sprs(VAR_0);
fflush(stdout);
#endif
return 0; | [
"int FUNC_0 (CPUPPCState *VAR_0, const ppc_def_t *VAR_1)\n{",
"VAR_0->msr_mask = VAR_1->msr_mask;",
"VAR_0->mmu_model = VAR_1->mmu_model;",
"VAR_0->excp_model = VAR_1->excp_model;",
"VAR_0->bus_model = VAR_1->bus_model;",
"VAR_0->insns_flags = VAR_1->insns_flags;",
"VAR_0->insns_flags2 = VAR_1->insns_flags2;",
"VAR_0->flags = VAR_1->flags;",
"VAR_0->bfd_mach = VAR_1->bfd_mach;",
"VAR_0->check_pow = VAR_1->check_pow;",
"if (kvm_enabled()) {",
"if (kvmppc_fixup_cpu(VAR_0) != 0) {",
"fprintf(stderr, \"Unable to virtualize selected CPU with KVM\\n\");",
"exit(1);",
"} else {",
"if (ppc_fixup_cpu(VAR_0) != 0) {",
"fprintf(stderr, \"Unable to emulate selected CPU with TCG\\n\");",
"exit(1);",
"if (create_ppc_opcodes(VAR_0, VAR_1) < 0)\nreturn -1;",
"init_ppc_proc(VAR_0, VAR_1);",
"if (VAR_1->insns_flags & PPC_FLOAT) {",
"gdb_register_coprocessor(VAR_0, gdb_get_float_reg, gdb_set_float_reg,\n33, \"power-fpu.xml\", 0);",
"if (VAR_1->insns_flags & PPC_ALTIVEC) {",
"gdb_register_coprocessor(VAR_0, gdb_get_avr_reg, gdb_set_avr_reg,\n34, \"power-altivec.xml\", 0);",
"if (VAR_1->insns_flags & PPC_SPE) {",
"gdb_register_coprocessor(VAR_0, gdb_get_spe_reg, gdb_set_spe_reg,\n34, \"power-spe.xml\", 0);",
"#if defined(PPC_DUMP_CPU)\n{",
"const char *mmu_model, *excp_model, *bus_model;",
"switch (VAR_0->mmu_model) {",
"case POWERPC_MMU_32B:\nmmu_model = \"PowerPC 32\";",
"break;",
"case POWERPC_MMU_SOFT_6xx:\nmmu_model = \"PowerPC 6xx/7xx with software driven TLBs\";",
"break;",
"case POWERPC_MMU_SOFT_74xx:\nmmu_model = \"PowerPC 74xx with software driven TLBs\";",
"break;",
"case POWERPC_MMU_SOFT_4xx:\nmmu_model = \"PowerPC 4xx with software driven TLBs\";",
"break;",
"case POWERPC_MMU_SOFT_4xx_Z:\nmmu_model = \"PowerPC 4xx with software driven TLBs \"\n\"and zones protections\";",
"break;",
"case POWERPC_MMU_REAL:\nmmu_model = \"PowerPC real mode only\";",
"break;",
"case POWERPC_MMU_MPC8xx:\nmmu_model = \"PowerPC MPC8xx\";",
"break;",
"case POWERPC_MMU_BOOKE:\nmmu_model = \"PowerPC BookE\";",
"break;",
"case POWERPC_MMU_BOOKE206:\nmmu_model = \"PowerPC BookE 2.06\";",
"break;",
"case POWERPC_MMU_601:\nmmu_model = \"PowerPC 601\";",
"break;",
"#if defined (TARGET_PPC64)\ncase POWERPC_MMU_64B:\nmmu_model = \"PowerPC 64\";",
"break;",
"case POWERPC_MMU_620:\nmmu_model = \"PowerPC 620\";",
"break;",
"#endif\ndefault:\nmmu_model = \"Unknown or invalid\";",
"break;",
"switch (VAR_0->excp_model) {",
"case POWERPC_EXCP_STD:\nexcp_model = \"PowerPC\";",
"break;",
"case POWERPC_EXCP_40x:\nexcp_model = \"PowerPC 40x\";",
"break;",
"case POWERPC_EXCP_601:\nexcp_model = \"PowerPC 601\";",
"break;",
"case POWERPC_EXCP_602:\nexcp_model = \"PowerPC 602\";",
"break;",
"case POWERPC_EXCP_603:\nexcp_model = \"PowerPC 603\";",
"break;",
"case POWERPC_EXCP_603E:\nexcp_model = \"PowerPC 603e\";",
"break;",
"case POWERPC_EXCP_604:\nexcp_model = \"PowerPC 604\";",
"break;",
"case POWERPC_EXCP_7x0:\nexcp_model = \"PowerPC 740/750\";",
"break;",
"case POWERPC_EXCP_7x5:\nexcp_model = \"PowerPC 745/755\";",
"break;",
"case POWERPC_EXCP_74xx:\nexcp_model = \"PowerPC 74xx\";",
"break;",
"case POWERPC_EXCP_BOOKE:\nexcp_model = \"PowerPC BookE\";",
"break;",
"#if defined (TARGET_PPC64)\ncase POWERPC_EXCP_970:\nexcp_model = \"PowerPC 970\";",
"break;",
"#endif\ndefault:\nexcp_model = \"Unknown or invalid\";",
"break;",
"switch (VAR_0->bus_model) {",
"case PPC_FLAGS_INPUT_6xx:\nbus_model = \"PowerPC 6xx\";",
"break;",
"case PPC_FLAGS_INPUT_BookE:\nbus_model = \"PowerPC BookE\";",
"break;",
"case PPC_FLAGS_INPUT_405:\nbus_model = \"PowerPC 405\";",
"break;",
"case PPC_FLAGS_INPUT_401:\nbus_model = \"PowerPC 401/403\";",
"break;",
"case PPC_FLAGS_INPUT_RCPU:\nbus_model = \"RCPU / MPC8xx\";",
"break;",
"#if defined (TARGET_PPC64)\ncase PPC_FLAGS_INPUT_970:\nbus_model = \"PowerPC 970\";",
"break;",
"#endif\ndefault:\nbus_model = \"Unknown or invalid\";",
"break;",
"printf(\"PowerPC %-12s : PVR %08x MSR %016\" PRIx64 \"\\n\"\n\" MMU model : %s\\n\",\nVAR_1->name, VAR_1->pvr, VAR_1->msr_mask, mmu_model);",
"#if !defined(CONFIG_USER_ONLY)\nif (VAR_0->tlb != NULL) {",
"printf(\" %d %s TLB in %d ways\\n\",\nVAR_0->nb_tlb, VAR_0->id_tlbs ? \"splitted\" : \"merged\",\nVAR_0->nb_ways);",
"#endif\nprintf(\" Exceptions model : %s\\n\"\n\" Bus model : %s\\n\",\nexcp_model, bus_model);",
"printf(\" MSR features :\\n\");",
"if (VAR_0->flags & POWERPC_FLAG_SPE)\nprintf(\" signal processing engine enable\"\n\"\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_VRE)\nprintf(\" vector processor enable\\n\");",
"if (VAR_0->flags & POWERPC_FLAG_TGPR)\nprintf(\" temporary GPRs\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_CE)\nprintf(\" critical input enable\\n\");",
"if (VAR_0->flags & POWERPC_FLAG_SE)\nprintf(\" single-step trace mode\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_DWE)\nprintf(\" debug wait enable\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_UBLE)\nprintf(\" user BTB lock enable\\n\");",
"if (VAR_0->flags & POWERPC_FLAG_BE)\nprintf(\" branch-step trace mode\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_DE)\nprintf(\" debug interrupt enable\\n\");",
"if (VAR_0->flags & POWERPC_FLAG_PX)\nprintf(\" inclusive protection\\n\");",
"else if (VAR_0->flags & POWERPC_FLAG_PMM)\nprintf(\" performance monitor mark\\n\");",
"if (VAR_0->flags == POWERPC_FLAG_NONE)\nprintf(\" none\\n\");",
"printf(\" Time-base/decrementer clock source: %s\\n\",\nVAR_0->flags & POWERPC_FLAG_RTC_CLK ? \"RTC clock\" : \"bus clock\");",
"dump_ppc_insns(VAR_0);",
"dump_ppc_sprs(VAR_0);",
"fflush(stdout);",
"#endif\nreturn 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20,
21
],
[
22
],
[
23
],
[
24,
25
],
[
26
],
[
27,
28
],
[
29
],
[
30,
31
],
[
32,
33
],
[
34
],
[
35
],
[
36,
37
],
[
38
],
[
39,
40
],
[
41
],
[
42,
43
],
[
44
],
[
45,
46
],
[
47
],
[
48,
49,
50
],
[
51
],
[
52,
53
],
[
54
],
[
55,
56
],
[
57
],
[
58,
59
],
[
60
],
[
61,
62
],
[
63
],
[
64,
65
],
[
66
],
[
67,
68,
69
],
[
70
],
[
71,
72
],
[
73
],
[
74,
75,
76
],
[
77
],
[
78
],
[
79,
80
],
[
81
],
[
82,
83
],
[
84
],
[
85,
86
],
[
87
],
[
88,
89
],
[
90
],
[
91,
92
],
[
93
],
[
94,
95
],
[
96
],
[
97,
98
],
[
99
],
[
100,
101
],
[
102
],
[
103,
104
],
[
105
],
[
106,
107
],
[
108
],
[
109,
110
],
[
111
],
[
112,
113,
114
],
[
115
],
[
116,
117,
118
],
[
119
],
[
120
],
[
121,
122
],
[
123
],
[
124,
125
],
[
126
],
[
127,
128
],
[
129
],
[
130,
131
],
[
132
],
[
133,
134
],
[
135
],
[
136,
137,
138
],
[
139
],
[
140,
141,
142
],
[
143
],
[
144,
145,
146
],
[
147,
148
],
[
149,
150,
151
],
[
152,
153,
154,
155
],
[
156
],
[
157,
158,
159
],
[
160,
161
],
[
162,
163
],
[
164,
165
],
[
166,
167
],
[
168,
169
],
[
170,
171
],
[
172,
173
],
[
174,
175
],
[
176,
177
],
[
178,
179
],
[
180,
181
],
[
182,
183
],
[
184
],
[
185
],
[
186
],
[
187,
188
]
] |
19,016 | static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int dirty)
{
int64_t start, end;
start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK;
end = (sector_num + nb_sectors) / BDRV_SECTORS_PER_DIRTY_CHUNK;
for (; start <= end; start++) {
bs->dirty_bitmap[start] = dirty;
}
}
| true | qemu | c6d2283068026035a6468aae9dcde953bd7521ac | static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int dirty)
{
int64_t start, end;
start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK;
end = (sector_num + nb_sectors) / BDRV_SECTORS_PER_DIRTY_CHUNK;
for (; start <= end; start++) {
bs->dirty_bitmap[start] = dirty;
}
}
| {
"code": [
" end = (sector_num + nb_sectors) / BDRV_SECTORS_PER_DIRTY_CHUNK;",
" bs->dirty_bitmap[start] = dirty;"
],
"line_no": [
13,
19
]
} | static void FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, int VAR_3)
{
int64_t start, end;
start = VAR_1 / BDRV_SECTORS_PER_DIRTY_CHUNK;
end = (VAR_1 + VAR_2) / BDRV_SECTORS_PER_DIRTY_CHUNK;
for (; start <= end; start++) {
VAR_0->dirty_bitmap[start] = VAR_3;
}
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nint VAR_2, int VAR_3)\n{",
"int64_t start, end;",
"start = VAR_1 / BDRV_SECTORS_PER_DIRTY_CHUNK;",
"end = (VAR_1 + VAR_2) / BDRV_SECTORS_PER_DIRTY_CHUNK;",
"for (; start <= end; start++) {",
"VAR_0->dirty_bitmap[start] = VAR_3;",
"}",
"}"
] | [
0,
0,
0,
1,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,017 | static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *mr = ddc->get_memory_region(dimm);
HotplugHandlerClass *hhc;
Error *local_err = NULL;
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
if (local_err) {
goto out;
}
pc_dimm_memory_unplug(dev, &pcms->hotplug_memory, mr);
object_unparent(OBJECT(dev));
out:
error_propagate(errp, local_err);
}
| true | qemu | 0479097859372a760843ad1b9c6ed3705c6423ca | static void pc_dimm_unplug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *mr = ddc->get_memory_region(dimm);
HotplugHandlerClass *hhc;
Error *local_err = NULL;
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
if (local_err) {
goto out;
}
pc_dimm_memory_unplug(dev, &pcms->hotplug_memory, mr);
object_unparent(OBJECT(dev));
out:
error_propagate(errp, local_err);
}
| {
"code": [
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);",
" MemoryRegion *mr = ddc->get_memory_region(dimm);"
],
"line_no": [
13,
13,
13,
13,
13,
13,
13
]
} | static void FUNC_0(HotplugHandler *VAR_0,
DeviceState *VAR_1, Error **VAR_2)
{
PCMachineState *pcms = PC_MACHINE(VAR_0);
PCDIMMDevice *dimm = PC_DIMM(VAR_1);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *mr = ddc->get_memory_region(dimm);
HotplugHandlerClass *hhc;
Error *local_err = NULL;
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), VAR_1, &local_err);
if (local_err) {
goto out;
}
pc_dimm_memory_unplug(VAR_1, &pcms->hotplug_memory, mr);
object_unparent(OBJECT(VAR_1));
out:
error_propagate(VAR_2, local_err);
}
| [
"static void FUNC_0(HotplugHandler *VAR_0,\nDeviceState *VAR_1, Error **VAR_2)\n{",
"PCMachineState *pcms = PC_MACHINE(VAR_0);",
"PCDIMMDevice *dimm = PC_DIMM(VAR_1);",
"PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);",
"MemoryRegion *mr = ddc->get_memory_region(dimm);",
"HotplugHandlerClass *hhc;",
"Error *local_err = NULL;",
"hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);",
"hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), VAR_1, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"pc_dimm_memory_unplug(VAR_1, &pcms->hotplug_memory, mr);",
"object_unparent(OBJECT(VAR_1));",
"out:\nerror_propagate(VAR_2, local_err);",
"}"
] | [
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
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43
],
[
45
]
] |
19,018 | uint64_t ram_bytes_remaining(void)
{
return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;
}
| true | qemu | bae416e5ba65701d3c5238164517158066d615e5 | uint64_t ram_bytes_remaining(void)
{
return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;
}
| {
"code": [
" return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;"
],
"line_no": [
5
]
} | uint64_t FUNC_0(void)
{
return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;
}
| [
"uint64_t FUNC_0(void)\n{",
"return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
19,019 | QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
/**
* monitor_protocol_event(): Generate a Monitor event
*
* Event-specific data can be emitted through the (optional) 'data' parameter.
*/
void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
event_name = monitor_event_names[event];
assert(event_name != NULL);
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
monitor_json_emitter(mon, QOBJECT(qmp));
}
}
QDECREF(qmp);
}
| true | qemu | afeecec2e8e99ba184c487633d5d0dde68a002ac | QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
event_name = monitor_event_names[event];
assert(event_name != NULL);
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
monitor_json_emitter(mon, QOBJECT(qmp));
}
}
QDECREF(qmp);
}
| {
"code": [
" Monitor *mon;",
" QLIST_FOREACH(mon, &mon_list, entry) {",
" if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {",
" monitor_json_emitter(mon, QOBJECT(qmp));"
],
"line_no": [
23,
53,
55,
57
]
} | FUNC_0(VAR_0(monitor_event_names) != QEVENT_MAX)
void FUNC_1(MonitorEvent VAR_1, QObject *VAR_2)
{
QDict *qmp;
const char *VAR_3;
Monitor *mon;
assert(VAR_1 < QEVENT_MAX);
VAR_3 = monitor_event_names[VAR_1];
assert(VAR_3 != NULL);
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "VAR_1", qstring_from_str(VAR_3));
if (VAR_2) {
qobject_incref(VAR_2);
qdict_put_obj(qmp, "VAR_2", VAR_2);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
monitor_json_emitter(mon, QOBJECT(qmp));
}
}
QDECREF(qmp);
}
| [
"FUNC_0(VAR_0(monitor_event_names) != QEVENT_MAX)\nvoid FUNC_1(MonitorEvent VAR_1, QObject *VAR_2)\n{",
"QDict *qmp;",
"const char *VAR_3;",
"Monitor *mon;",
"assert(VAR_1 < QEVENT_MAX);",
"VAR_3 = monitor_event_names[VAR_1];",
"assert(VAR_3 != NULL);",
"qmp = qdict_new();",
"timestamp_put(qmp);",
"qdict_put(qmp, \"VAR_1\", qstring_from_str(VAR_3));",
"if (VAR_2) {",
"qobject_incref(VAR_2);",
"qdict_put_obj(qmp, \"VAR_2\", VAR_2);",
"}",
"QLIST_FOREACH(mon, &mon_list, entry) {",
"if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {",
"monitor_json_emitter(mon, QOBJECT(qmp));",
"}",
"}",
"QDECREF(qmp);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0
] | [
[
1,
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
19,020 | static int preallocate(BlockDriverState *bs)
{
uint64_t nb_sectors;
uint64_t offset;
int num;
int ret;
QCowL2Meta meta;
nb_sectors = bdrv_getlength(bs) >> 9;
offset = 0;
QLIST_INIT(&meta.dependent_requests);
meta.cluster_offset = 0;
while (nb_sectors) {
num = MIN(nb_sectors, INT_MAX >> 9);
ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta);
if (ret < 0) {
return -1;
}
if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {
qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters);
return -1;
}
/* There are no dependent requests, but we need to remove our request
* from the list of in-flight requests */
run_dependent_requests(&meta);
/* TODO Preallocate data if requested */
nb_sectors -= num;
offset += num << 9;
}
/*
* It is expected that the image file is large enough to actually contain
* all of the allocated clusters (otherwise we get failing reads after
* EOF). Extend the image to the last allocated sector.
*/
if (meta.cluster_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);
}
return 0;
}
| true | qemu | 19dbcbf7cc1892f5130b4edd5a4bb4ca800ef7d8 | static int preallocate(BlockDriverState *bs)
{
uint64_t nb_sectors;
uint64_t offset;
int num;
int ret;
QCowL2Meta meta;
nb_sectors = bdrv_getlength(bs) >> 9;
offset = 0;
QLIST_INIT(&meta.dependent_requests);
meta.cluster_offset = 0;
while (nb_sectors) {
num = MIN(nb_sectors, INT_MAX >> 9);
ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta);
if (ret < 0) {
return -1;
}
if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {
qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters);
return -1;
}
run_dependent_requests(&meta);
nb_sectors -= num;
offset += num << 9;
}
if (meta.cluster_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);
}
return 0;
}
| {
"code": [
" return -1;",
" if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {",
" return -1;",
" bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);"
],
"line_no": [
37,
43,
37,
89
]
} | static int FUNC_0(BlockDriverState *VAR_0)
{
uint64_t nb_sectors;
uint64_t offset;
int VAR_1;
int VAR_2;
QCowL2Meta meta;
nb_sectors = bdrv_getlength(VAR_0) >> 9;
offset = 0;
QLIST_INIT(&meta.dependent_requests);
meta.cluster_offset = 0;
while (nb_sectors) {
VAR_1 = MIN(nb_sectors, INT_MAX >> 9);
VAR_2 = qcow2_alloc_cluster_offset(VAR_0, offset, 0, VAR_1, &VAR_1, &meta);
if (VAR_2 < 0) {
return -1;
}
if (qcow2_alloc_cluster_link_l2(VAR_0, &meta) < 0) {
qcow2_free_any_clusters(VAR_0, meta.cluster_offset, meta.nb_clusters);
return -1;
}
run_dependent_requests(&meta);
nb_sectors -= VAR_1;
offset += VAR_1 << 9;
}
if (meta.cluster_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
bdrv_write(VAR_0->file, (meta.cluster_offset >> 9) + VAR_1 - 1, buf, 1);
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"uint64_t nb_sectors;",
"uint64_t offset;",
"int VAR_1;",
"int VAR_2;",
"QCowL2Meta meta;",
"nb_sectors = bdrv_getlength(VAR_0) >> 9;",
"offset = 0;",
"QLIST_INIT(&meta.dependent_requests);",
"meta.cluster_offset = 0;",
"while (nb_sectors) {",
"VAR_1 = MIN(nb_sectors, INT_MAX >> 9);",
"VAR_2 = qcow2_alloc_cluster_offset(VAR_0, offset, 0, VAR_1, &VAR_1, &meta);",
"if (VAR_2 < 0) {",
"return -1;",
"}",
"if (qcow2_alloc_cluster_link_l2(VAR_0, &meta) < 0) {",
"qcow2_free_any_clusters(VAR_0, meta.cluster_offset, meta.nb_clusters);",
"return -1;",
"}",
"run_dependent_requests(&meta);",
"nb_sectors -= VAR_1;",
"offset += VAR_1 << 9;",
"}",
"if (meta.cluster_offset != 0) {",
"uint8_t buf[512];",
"memset(buf, 0, 512);",
"bdrv_write(VAR_0->file, (meta.cluster_offset >> 9) + VAR_1 - 1, buf, 1);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
57
],
[
65
],
[
67
],
[
69
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
]
] |
19,021 | static int msix_is_masked(PCIDevice *dev, int vector)
{
unsigned offset =
vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
return dev->msix_function_masked ||
dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
}
| true | qemu | ae392c416c69a020226c768d9c3af08b29dd6d96 | static int msix_is_masked(PCIDevice *dev, int vector)
{
unsigned offset =
vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
return dev->msix_function_masked ||
dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
}
| {
"code": [
"static int msix_is_masked(PCIDevice *dev, int vector)",
" unsigned offset =",
" vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;",
" return dev->msix_function_masked ||",
"\t dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT;"
],
"line_no": [
1,
5,
7,
9,
11
]
} | static int FUNC_0(PCIDevice *VAR_0, int VAR_1)
{
unsigned VAR_2 =
VAR_1 * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;
return VAR_0->msix_function_masked ||
VAR_0->msix_table_page[VAR_2] & PCI_MSIX_ENTRY_CTRL_MASKBIT;
}
| [
"static int FUNC_0(PCIDevice *VAR_0, int VAR_1)\n{",
"unsigned VAR_2 =\nVAR_1 * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL;",
"return VAR_0->msix_function_masked ||\nVAR_0->msix_table_page[VAR_2] & PCI_MSIX_ENTRY_CTRL_MASKBIT;",
"}"
] | [
1,
1,
1,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
]
] |
19,022 | static int vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, uint64_t cluster_sectors,
VmdkExtent **new_extent)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
if (cluster_sectors > 0x200000) {
/* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
error_report("invalid granularity, image may be corrupt");
return -EINVAL;
}
if (l1_size > 512 * 1024 * 1024) {
/* Although with big capacity and small l1_entry_sectors, we can get a
* big l1_size, we don't want unbounded value to allocate the table.
* Limit it to 512M, which is 16PB for default cluster and L2 table
* size */
error_report("L1 size too big");
return -EFBIG;
}
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = cluster_sectors;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
if (new_extent) {
*new_extent = extent;
}
return 0;
}
| true | qemu | 301c7d38a0c359b91526391d13617386f3d9bb29 | static int vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, uint64_t cluster_sectors,
VmdkExtent **new_extent)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
if (cluster_sectors > 0x200000) {
error_report("invalid granularity, image may be corrupt");
return -EINVAL;
}
if (l1_size > 512 * 1024 * 1024) {
error_report("L1 size too big");
return -EFBIG;
}
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = cluster_sectors;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
if (new_extent) {
*new_extent = extent;
}
return 0;
}
| {
"code": [
" extent->cluster_sectors = cluster_sectors;"
],
"line_no": [
77
]
} | static int FUNC_0(BlockDriverState *VAR_0,
BlockDriverState *VAR_1, bool VAR_2, int64_t VAR_3,
int64_t VAR_4, int64_t VAR_5,
uint32_t VAR_6,
int VAR_7, uint64_t VAR_8,
VmdkExtent **VAR_9)
{
VmdkExtent *extent;
BDRVVmdkState *s = VAR_0->opaque;
if (VAR_8 > 0x200000) {
error_report("invalid granularity, image may be corrupt");
return -EINVAL;
}
if (VAR_6 > 512 * 1024 * 1024) {
error_report("L1 size too big");
return -EFBIG;
}
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->VAR_1 = VAR_1;
extent->VAR_2 = VAR_2;
extent->VAR_3 = VAR_3;
extent->l1_table_offset = VAR_4;
extent->l1_backup_table_offset = VAR_5;
extent->VAR_6 = VAR_6;
extent->l1_entry_sectors = VAR_7 * VAR_8;
extent->VAR_7 = VAR_7;
extent->VAR_8 = VAR_8;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->VAR_3;
} else {
extent->end_sector = extent->VAR_3;
}
VAR_0->total_sectors = extent->end_sector;
if (VAR_9) {
*VAR_9 = extent;
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nBlockDriverState *VAR_1, bool VAR_2, int64_t VAR_3,\nint64_t VAR_4, int64_t VAR_5,\nuint32_t VAR_6,\nint VAR_7, uint64_t VAR_8,\nVmdkExtent **VAR_9)\n{",
"VmdkExtent *extent;",
"BDRVVmdkState *s = VAR_0->opaque;",
"if (VAR_8 > 0x200000) {",
"error_report(\"invalid granularity, image may be corrupt\");",
"return -EINVAL;",
"}",
"if (VAR_6 > 512 * 1024 * 1024) {",
"error_report(\"L1 size too big\");",
"return -EFBIG;",
"}",
"s->extents = g_realloc(s->extents,\n(s->num_extents + 1) * sizeof(VmdkExtent));",
"extent = &s->extents[s->num_extents];",
"s->num_extents++;",
"memset(extent, 0, sizeof(VmdkExtent));",
"extent->VAR_1 = VAR_1;",
"extent->VAR_2 = VAR_2;",
"extent->VAR_3 = VAR_3;",
"extent->l1_table_offset = VAR_4;",
"extent->l1_backup_table_offset = VAR_5;",
"extent->VAR_6 = VAR_6;",
"extent->l1_entry_sectors = VAR_7 * VAR_8;",
"extent->VAR_7 = VAR_7;",
"extent->VAR_8 = VAR_8;",
"if (s->num_extents > 1) {",
"extent->end_sector = (*(extent - 1)).end_sector + extent->VAR_3;",
"} else {",
"extent->end_sector = extent->VAR_3;",
"}",
"VAR_0->total_sectors = extent->end_sector;",
"if (VAR_9) {",
"*VAR_9 = extent;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
19,024 | static int get_stream_info(AVCodecContext *avctx)
{
FDKAACDecContext *s = avctx->priv_data;
CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle);
int channel_counts[0x24] = { 0 };
int i, ch_error = 0;
uint64_t ch_layout = 0;
if (!info) {
av_log(avctx, AV_LOG_ERROR, "Unable to get stream info\n");
return AVERROR_UNKNOWN;
}
if (info->sampleRate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Stream info not initialized\n");
return AVERROR_UNKNOWN;
}
avctx->sample_rate = info->sampleRate;
avctx->frame_size = info->frameSize;
for (i = 0; i < info->numChannels; i++) {
AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) {
av_log(avctx, AV_LOG_WARNING, "unknown channel type\n");
break;
}
channel_counts[ctype]++;
}
av_log(avctx, AV_LOG_DEBUG,
"%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
info->numChannels,
channel_counts[ACT_FRONT], channel_counts[ACT_SIDE],
channel_counts[ACT_BACK], channel_counts[ACT_LFE],
channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] +
channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]);
switch (channel_counts[ACT_FRONT]) {
case 4:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER |
AV_CH_FRONT_RIGHT_OF_CENTER;
break;
case 3:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER;
break;
case 2:
ch_layout |= AV_CH_LAYOUT_STEREO;
break;
case 1:
ch_layout |= AV_CH_FRONT_CENTER;
break;
default:
av_log(avctx, AV_LOG_WARNING,
"unsupported number of front channels: %d\n",
channel_counts[ACT_FRONT]);
ch_error = 1;
break;
}
if (channel_counts[ACT_SIDE] > 0) {
if (channel_counts[ACT_SIDE] == 2) {
ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
} else {
av_log(avctx, AV_LOG_WARNING,
"unsupported number of side channels: %d\n",
channel_counts[ACT_SIDE]);
ch_error = 1;
}
}
if (channel_counts[ACT_BACK] > 0) {
switch (channel_counts[ACT_BACK]) {
case 3:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER;
break;
case 2:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
break;
case 1:
ch_layout |= AV_CH_BACK_CENTER;
break;
default:
av_log(avctx, AV_LOG_WARNING,
"unsupported number of back channels: %d\n",
channel_counts[ACT_BACK]);
ch_error = 1;
break;
}
}
if (channel_counts[ACT_LFE] > 0) {
if (channel_counts[ACT_LFE] == 1) {
ch_layout |= AV_CH_LOW_FREQUENCY;
} else {
av_log(avctx, AV_LOG_WARNING,
"unsupported number of LFE channels: %d\n",
channel_counts[ACT_LFE]);
ch_error = 1;
}
}
if (!ch_error &&
av_get_channel_layout_nb_channels(ch_layout) != info->numChannels) {
av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n");
ch_error = 1;
}
if (ch_error)
avctx->channel_layout = 0;
else
avctx->channel_layout = ch_layout;
avctx->channels = info->numChannels;
return 0;
}
| true | FFmpeg | c7921a480467876ece06566e0efd8f6bce9d1903 | static int get_stream_info(AVCodecContext *avctx)
{
FDKAACDecContext *s = avctx->priv_data;
CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle);
int channel_counts[0x24] = { 0 };
int i, ch_error = 0;
uint64_t ch_layout = 0;
if (!info) {
av_log(avctx, AV_LOG_ERROR, "Unable to get stream info\n");
return AVERROR_UNKNOWN;
}
if (info->sampleRate <= 0) {
av_log(avctx, AV_LOG_ERROR, "Stream info not initialized\n");
return AVERROR_UNKNOWN;
}
avctx->sample_rate = info->sampleRate;
avctx->frame_size = info->frameSize;
for (i = 0; i < info->numChannels; i++) {
AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) {
av_log(avctx, AV_LOG_WARNING, "unknown channel type\n");
break;
}
channel_counts[ctype]++;
}
av_log(avctx, AV_LOG_DEBUG,
"%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
info->numChannels,
channel_counts[ACT_FRONT], channel_counts[ACT_SIDE],
channel_counts[ACT_BACK], channel_counts[ACT_LFE],
channel_counts[ACT_FRONT_TOP] + channel_counts[ACT_SIDE_TOP] +
channel_counts[ACT_BACK_TOP] + channel_counts[ACT_TOP]);
switch (channel_counts[ACT_FRONT]) {
case 4:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER |
AV_CH_FRONT_RIGHT_OF_CENTER;
break;
case 3:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER;
break;
case 2:
ch_layout |= AV_CH_LAYOUT_STEREO;
break;
case 1:
ch_layout |= AV_CH_FRONT_CENTER;
break;
default:
av_log(avctx, AV_LOG_WARNING,
"unsupported number of front channels: %d\n",
channel_counts[ACT_FRONT]);
ch_error = 1;
break;
}
if (channel_counts[ACT_SIDE] > 0) {
if (channel_counts[ACT_SIDE] == 2) {
ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
} else {
av_log(avctx, AV_LOG_WARNING,
"unsupported number of side channels: %d\n",
channel_counts[ACT_SIDE]);
ch_error = 1;
}
}
if (channel_counts[ACT_BACK] > 0) {
switch (channel_counts[ACT_BACK]) {
case 3:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER;
break;
case 2:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
break;
case 1:
ch_layout |= AV_CH_BACK_CENTER;
break;
default:
av_log(avctx, AV_LOG_WARNING,
"unsupported number of back channels: %d\n",
channel_counts[ACT_BACK]);
ch_error = 1;
break;
}
}
if (channel_counts[ACT_LFE] > 0) {
if (channel_counts[ACT_LFE] == 1) {
ch_layout |= AV_CH_LOW_FREQUENCY;
} else {
av_log(avctx, AV_LOG_WARNING,
"unsupported number of LFE channels: %d\n",
channel_counts[ACT_LFE]);
ch_error = 1;
}
}
if (!ch_error &&
av_get_channel_layout_nb_channels(ch_layout) != info->numChannels) {
av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n");
ch_error = 1;
}
if (ch_error)
avctx->channel_layout = 0;
else
avctx->channel_layout = ch_layout;
avctx->channels = info->numChannels;
return 0;
}
| {
"code": [
" if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) {"
],
"line_no": [
45
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
FDKAACDecContext *s = VAR_0->priv_data;
CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle);
int VAR_1[0x24] = { 0 };
int VAR_2, VAR_3 = 0;
uint64_t ch_layout = 0;
if (!info) {
av_log(VAR_0, AV_LOG_ERROR, "Unable to get stream info\n");
return AVERROR_UNKNOWN;
}
if (info->sampleRate <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Stream info not initialized\n");
return AVERROR_UNKNOWN;
}
VAR_0->sample_rate = info->sampleRate;
VAR_0->frame_size = info->frameSize;
for (VAR_2 = 0; VAR_2 < info->numChannels; VAR_2++) {
AUDIO_CHANNEL_TYPE ctype = info->pChannelType[VAR_2];
if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(VAR_1)) {
av_log(VAR_0, AV_LOG_WARNING, "unknown channel type\n");
break;
}
VAR_1[ctype]++;
}
av_log(VAR_0, AV_LOG_DEBUG,
"%d channels - front:%d side:%d back:%d lfe:%d top:%d\n",
info->numChannels,
VAR_1[ACT_FRONT], VAR_1[ACT_SIDE],
VAR_1[ACT_BACK], VAR_1[ACT_LFE],
VAR_1[ACT_FRONT_TOP] + VAR_1[ACT_SIDE_TOP] +
VAR_1[ACT_BACK_TOP] + VAR_1[ACT_TOP]);
switch (VAR_1[ACT_FRONT]) {
case 4:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER |
AV_CH_FRONT_RIGHT_OF_CENTER;
break;
case 3:
ch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER;
break;
case 2:
ch_layout |= AV_CH_LAYOUT_STEREO;
break;
case 1:
ch_layout |= AV_CH_FRONT_CENTER;
break;
default:
av_log(VAR_0, AV_LOG_WARNING,
"unsupported number of front channels: %d\n",
VAR_1[ACT_FRONT]);
VAR_3 = 1;
break;
}
if (VAR_1[ACT_SIDE] > 0) {
if (VAR_1[ACT_SIDE] == 2) {
ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
} else {
av_log(VAR_0, AV_LOG_WARNING,
"unsupported number of side channels: %d\n",
VAR_1[ACT_SIDE]);
VAR_3 = 1;
}
}
if (VAR_1[ACT_BACK] > 0) {
switch (VAR_1[ACT_BACK]) {
case 3:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER;
break;
case 2:
ch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
break;
case 1:
ch_layout |= AV_CH_BACK_CENTER;
break;
default:
av_log(VAR_0, AV_LOG_WARNING,
"unsupported number of back channels: %d\n",
VAR_1[ACT_BACK]);
VAR_3 = 1;
break;
}
}
if (VAR_1[ACT_LFE] > 0) {
if (VAR_1[ACT_LFE] == 1) {
ch_layout |= AV_CH_LOW_FREQUENCY;
} else {
av_log(VAR_0, AV_LOG_WARNING,
"unsupported number of LFE channels: %d\n",
VAR_1[ACT_LFE]);
VAR_3 = 1;
}
}
if (!VAR_3 &&
av_get_channel_layout_nb_channels(ch_layout) != info->numChannels) {
av_log(VAR_0, AV_LOG_WARNING, "unsupported channel configuration\n");
VAR_3 = 1;
}
if (VAR_3)
VAR_0->channel_layout = 0;
else
VAR_0->channel_layout = ch_layout;
VAR_0->channels = info->numChannels;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"FDKAACDecContext *s = VAR_0->priv_data;",
"CStreamInfo *info = aacDecoder_GetStreamInfo(s->handle);",
"int VAR_1[0x24] = { 0 };",
"int VAR_2, VAR_3 = 0;",
"uint64_t ch_layout = 0;",
"if (!info) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unable to get stream info\\n\");",
"return AVERROR_UNKNOWN;",
"}",
"if (info->sampleRate <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Stream info not initialized\\n\");",
"return AVERROR_UNKNOWN;",
"}",
"VAR_0->sample_rate = info->sampleRate;",
"VAR_0->frame_size = info->frameSize;",
"for (VAR_2 = 0; VAR_2 < info->numChannels; VAR_2++) {",
"AUDIO_CHANNEL_TYPE ctype = info->pChannelType[VAR_2];",
"if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(VAR_1)) {",
"av_log(VAR_0, AV_LOG_WARNING, \"unknown channel type\\n\");",
"break;",
"}",
"VAR_1[ctype]++;",
"}",
"av_log(VAR_0, AV_LOG_DEBUG,\n\"%d channels - front:%d side:%d back:%d lfe:%d top:%d\\n\",\ninfo->numChannels,\nVAR_1[ACT_FRONT], VAR_1[ACT_SIDE],\nVAR_1[ACT_BACK], VAR_1[ACT_LFE],\nVAR_1[ACT_FRONT_TOP] + VAR_1[ACT_SIDE_TOP] +\nVAR_1[ACT_BACK_TOP] + VAR_1[ACT_TOP]);",
"switch (VAR_1[ACT_FRONT]) {",
"case 4:\nch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_LEFT_OF_CENTER |\nAV_CH_FRONT_RIGHT_OF_CENTER;",
"break;",
"case 3:\nch_layout |= AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER;",
"break;",
"case 2:\nch_layout |= AV_CH_LAYOUT_STEREO;",
"break;",
"case 1:\nch_layout |= AV_CH_FRONT_CENTER;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_WARNING,\n\"unsupported number of front channels: %d\\n\",\nVAR_1[ACT_FRONT]);",
"VAR_3 = 1;",
"break;",
"}",
"if (VAR_1[ACT_SIDE] > 0) {",
"if (VAR_1[ACT_SIDE] == 2) {",
"ch_layout |= AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"unsupported number of side channels: %d\\n\",\nVAR_1[ACT_SIDE]);",
"VAR_3 = 1;",
"}",
"}",
"if (VAR_1[ACT_BACK] > 0) {",
"switch (VAR_1[ACT_BACK]) {",
"case 3:\nch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT | AV_CH_BACK_CENTER;",
"break;",
"case 2:\nch_layout |= AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;",
"break;",
"case 1:\nch_layout |= AV_CH_BACK_CENTER;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_WARNING,\n\"unsupported number of back channels: %d\\n\",\nVAR_1[ACT_BACK]);",
"VAR_3 = 1;",
"break;",
"}",
"}",
"if (VAR_1[ACT_LFE] > 0) {",
"if (VAR_1[ACT_LFE] == 1) {",
"ch_layout |= AV_CH_LOW_FREQUENCY;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"unsupported number of LFE channels: %d\\n\",\nVAR_1[ACT_LFE]);",
"VAR_3 = 1;",
"}",
"}",
"if (!VAR_3 &&\nav_get_channel_layout_nb_channels(ch_layout) != info->numChannels) {",
"av_log(VAR_0, AV_LOG_WARNING, \"unsupported channel configuration\\n\");",
"VAR_3 = 1;",
"}",
"if (VAR_3)\nVAR_0->channel_layout = 0;",
"else\nVAR_0->channel_layout = ch_layout;",
"VAR_0->channels = info->numChannels;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59,
61,
63,
65,
67,
69
],
[
73
],
[
75,
77,
79
],
[
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
151,
153
],
[
155
],
[
157,
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183,
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207,
209
],
[
213
],
[
217
],
[
219
]
] |
19,025 | static void *qemu_rdma_data_init(const char *host_port, Error **errp)
{
RDMAContext *rdma = NULL;
InetSocketAddress *addr;
if (host_port) {
rdma = g_malloc0(sizeof(RDMAContext));
memset(rdma, 0, sizeof(RDMAContext));
rdma->current_index = -1;
rdma->current_chunk = -1;
addr = inet_parse(host_port, NULL);
if (addr != NULL) {
rdma->port = atoi(addr->port);
rdma->host = g_strdup(addr->host);
} else {
ERROR(errp, "bad RDMA migration address '%s'", host_port);
g_free(rdma);
rdma = NULL;
}
qapi_free_InetSocketAddress(addr);
}
return rdma;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void *qemu_rdma_data_init(const char *host_port, Error **errp)
{
RDMAContext *rdma = NULL;
InetSocketAddress *addr;
if (host_port) {
rdma = g_malloc0(sizeof(RDMAContext));
memset(rdma, 0, sizeof(RDMAContext));
rdma->current_index = -1;
rdma->current_chunk = -1;
addr = inet_parse(host_port, NULL);
if (addr != NULL) {
rdma->port = atoi(addr->port);
rdma->host = g_strdup(addr->host);
} else {
ERROR(errp, "bad RDMA migration address '%s'", host_port);
g_free(rdma);
rdma = NULL;
}
qapi_free_InetSocketAddress(addr);
}
return rdma;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(const char *VAR_0, Error **VAR_1)
{
RDMAContext *rdma = NULL;
InetSocketAddress *addr;
if (VAR_0) {
rdma = g_malloc0(sizeof(RDMAContext));
memset(rdma, 0, sizeof(RDMAContext));
rdma->current_index = -1;
rdma->current_chunk = -1;
addr = inet_parse(VAR_0, NULL);
if (addr != NULL) {
rdma->port = atoi(addr->port);
rdma->host = g_strdup(addr->host);
} else {
ERROR(VAR_1, "bad RDMA migration address '%s'", VAR_0);
g_free(rdma);
rdma = NULL;
}
qapi_free_InetSocketAddress(addr);
}
return rdma;
}
| [
"static void *FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"RDMAContext *rdma = NULL;",
"InetSocketAddress *addr;",
"if (VAR_0) {",
"rdma = g_malloc0(sizeof(RDMAContext));",
"memset(rdma, 0, sizeof(RDMAContext));",
"rdma->current_index = -1;",
"rdma->current_chunk = -1;",
"addr = inet_parse(VAR_0, NULL);",
"if (addr != NULL) {",
"rdma->port = atoi(addr->port);",
"rdma->host = g_strdup(addr->host);",
"} else {",
"ERROR(VAR_1, \"bad RDMA migration address '%s'\", VAR_0);",
"g_free(rdma);",
"rdma = NULL;",
"}",
"qapi_free_InetSocketAddress(addr);",
"}",
"return rdma;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
19,026 | static void test_tco_second_timeout_pause(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(32);
QDict *ad;
td.args = "-watchdog-action pause";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "pause"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| true | qemu | 34779e8c3991f7fcd74b2045478abcef67dbeb15 | static void test_tco_second_timeout_pause(void)
{
TestData td;
const uint16_t ticks = TCO_SECS_TO_TICKS(32);
QDict *ad;
td.args = "-watchdog-action pause";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(ticks * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "pause"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| {
"code": [
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();",
" qtest_end();"
],
"line_no": [
45,
45,
45,
45,
45,
45,
45,
45,
45,
45,
45
]
} | static void FUNC_0(void)
{
TestData td;
const uint16_t VAR_0 = TCO_SECS_TO_TICKS(32);
QDict *ad;
td.args = "-watchdog-action pause";
td.noreboot = false;
test_init(&td);
stop_tco(&td);
clear_tco_status(&td);
reset_on_second_timeout(true);
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
load_tco(&td);
start_tco(&td);
clock_step(VAR_0 * TCO_TICK_NSEC * 2);
ad = get_watchdog_action();
g_assert(!strcmp(qdict_get_str(ad, "action"), "pause"));
QDECREF(ad);
stop_tco(&td);
qtest_end();
}
| [
"static void FUNC_0(void)\n{",
"TestData td;",
"const uint16_t VAR_0 = TCO_SECS_TO_TICKS(32);",
"QDict *ad;",
"td.args = \"-watchdog-action pause\";",
"td.noreboot = false;",
"test_init(&td);",
"stop_tco(&td);",
"clear_tco_status(&td);",
"reset_on_second_timeout(true);",
"set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));",
"load_tco(&td);",
"start_tco(&td);",
"clock_step(VAR_0 * TCO_TICK_NSEC * 2);",
"ad = get_watchdog_action();",
"g_assert(!strcmp(qdict_get_str(ad, \"action\"), \"pause\"));",
"QDECREF(ad);",
"stop_tco(&td);",
"qtest_end();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
] |
19,028 | static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
int alpha = alpha_table[index_a];
int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0*bsi]];
tc[1] = tc0_table[index_a][bS[1*bsi]];
tc[2] = tc0_table[index_a][bS[2*bsi]];
tc[3] = tc0_table[index_a][bS[3*bsi]];
h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
}
}
| false | FFmpeg | a4f6be86d67ae30d494fbe8a470bc32b715d75a9 | static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp ) {
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
int alpha = alpha_table[index_a];
int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
if (alpha ==0 || beta == 0) return;
if( bS[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[index_a][bS[0*bsi]];
tc[1] = tc0_table[index_a][bS[1*bsi]];
tc[2] = tc0_table[index_a][bS[2*bsi]];
tc[3] = tc0_table[index_a][bS[3*bsi]];
h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
} else {
h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, const int16_t VAR_3[7], int VAR_4, int VAR_5 ) {
const int VAR_6 = 6 * (VAR_0->sps.bit_depth_luma - 8);
int VAR_7 = VAR_5 - VAR_6 + VAR_0->slice_alpha_c0_offset;
int VAR_8 = alpha_table[VAR_7];
int VAR_9 = beta_table[VAR_5 - VAR_6 + VAR_0->slice_beta_offset];
if (VAR_8 ==0 || VAR_9 == 0) return;
if( VAR_3[0] < 4 ) {
int8_t tc[4];
tc[0] = tc0_table[VAR_7][VAR_3[0*VAR_4]];
tc[1] = tc0_table[VAR_7][VAR_3[1*VAR_4]];
tc[2] = tc0_table[VAR_7][VAR_3[2*VAR_4]];
tc[3] = tc0_table[VAR_7][VAR_3[3*VAR_4]];
VAR_0->h264dsp.h264_h_loop_filter_luma_mbaff(VAR_1, VAR_2, VAR_8, VAR_9, tc);
} else {
VAR_0->h264dsp.h264_h_loop_filter_luma_mbaff_intra(VAR_1, VAR_2, VAR_8, VAR_9);
}
}
| [
"static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, const int16_t VAR_3[7], int VAR_4, int VAR_5 ) {",
"const int VAR_6 = 6 * (VAR_0->sps.bit_depth_luma - 8);",
"int VAR_7 = VAR_5 - VAR_6 + VAR_0->slice_alpha_c0_offset;",
"int VAR_8 = alpha_table[VAR_7];",
"int VAR_9 = beta_table[VAR_5 - VAR_6 + VAR_0->slice_beta_offset];",
"if (VAR_8 ==0 || VAR_9 == 0) return;",
"if( VAR_3[0] < 4 ) {",
"int8_t tc[4];",
"tc[0] = tc0_table[VAR_7][VAR_3[0*VAR_4]];",
"tc[1] = tc0_table[VAR_7][VAR_3[1*VAR_4]];",
"tc[2] = tc0_table[VAR_7][VAR_3[2*VAR_4]];",
"tc[3] = tc0_table[VAR_7][VAR_3[3*VAR_4]];",
"VAR_0->h264dsp.h264_h_loop_filter_luma_mbaff(VAR_1, VAR_2, VAR_8, VAR_9, tc);",
"} else {",
"VAR_0->h264dsp.h264_h_loop_filter_luma_mbaff_intra(VAR_1, VAR_2, VAR_8, VAR_9);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
19,029 | static int rtsp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
RTSPState *rt = s->priv_data;
int ret;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[1024];
if (rt->server_type == RTSP_SERVER_REAL) {
int i;
enum AVDiscard cache[MAX_STREAMS];
for (i = 0; i < s->nb_streams; i++)
cache[i] = s->streams[i]->discard;
if (!rt->need_subscription) {
if (memcmp (cache, rt->real_setup_cache,
sizeof(enum AVDiscard) * s->nb_streams)) {
av_strlcatf(cmd, sizeof(cmd),
"SET_PARAMETER %s RTSP/1.0\r\n"
"Unsubscribe: %s\r\n",
s->filename, rt->last_subscription);
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 1;
}
}
if (rt->need_subscription) {
int r, rule_nr, first = 1;
memcpy(rt->real_setup_cache, cache,
sizeof(enum AVDiscard) * s->nb_streams);
rt->last_subscription[0] = 0;
snprintf(cmd, sizeof(cmd),
"SET_PARAMETER %s RTSP/1.0\r\n"
"Subscribe: ",
s->filename);
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rule_nr = 0;
for (r = 0; r < s->nb_streams; r++) {
if (s->streams[r]->priv_data == rt->rtsp_streams[i]) {
if (s->streams[r]->discard != AVDISCARD_ALL) {
if (!first)
av_strlcat(rt->last_subscription, ",",
sizeof(rt->last_subscription));
ff_rdt_subscribe_rule(
rt->last_subscription,
sizeof(rt->last_subscription), i, rule_nr);
first = 0;
}
rule_nr++;
}
}
}
av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription);
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 0;
if (rt->state == RTSP_STATE_PLAYING)
rtsp_read_play (s);
}
}
ret = rtsp_fetch_packet(s, pkt);
if (ret < 0) {
return ret;
}
/* send dummy request to keep TCP connection alive */
if ((rt->server_type == RTSP_SERVER_WMS ||
rt->server_type == RTSP_SERVER_REAL) &&
(av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {
if (rt->server_type == RTSP_SERVER_WMS) {
snprintf(cmd, sizeof(cmd) - 1,
"GET_PARAMETER %s RTSP/1.0\r\n",
s->filename);
rtsp_send_cmd_async(s, cmd, reply, NULL);
} else {
rtsp_send_cmd_async(s, "OPTIONS * RTSP/1.0\r\n",
reply, NULL);
}
}
return 0;
}
| false | FFmpeg | c89658008705d949c319df3fa6f400c481ad73e1 | static int rtsp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
RTSPState *rt = s->priv_data;
int ret;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[1024];
if (rt->server_type == RTSP_SERVER_REAL) {
int i;
enum AVDiscard cache[MAX_STREAMS];
for (i = 0; i < s->nb_streams; i++)
cache[i] = s->streams[i]->discard;
if (!rt->need_subscription) {
if (memcmp (cache, rt->real_setup_cache,
sizeof(enum AVDiscard) * s->nb_streams)) {
av_strlcatf(cmd, sizeof(cmd),
"SET_PARAMETER %s RTSP/1.0\r\n"
"Unsubscribe: %s\r\n",
s->filename, rt->last_subscription);
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 1;
}
}
if (rt->need_subscription) {
int r, rule_nr, first = 1;
memcpy(rt->real_setup_cache, cache,
sizeof(enum AVDiscard) * s->nb_streams);
rt->last_subscription[0] = 0;
snprintf(cmd, sizeof(cmd),
"SET_PARAMETER %s RTSP/1.0\r\n"
"Subscribe: ",
s->filename);
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rule_nr = 0;
for (r = 0; r < s->nb_streams; r++) {
if (s->streams[r]->priv_data == rt->rtsp_streams[i]) {
if (s->streams[r]->discard != AVDISCARD_ALL) {
if (!first)
av_strlcat(rt->last_subscription, ",",
sizeof(rt->last_subscription));
ff_rdt_subscribe_rule(
rt->last_subscription,
sizeof(rt->last_subscription), i, rule_nr);
first = 0;
}
rule_nr++;
}
}
}
av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription);
rtsp_send_cmd(s, cmd, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 0;
if (rt->state == RTSP_STATE_PLAYING)
rtsp_read_play (s);
}
}
ret = rtsp_fetch_packet(s, pkt);
if (ret < 0) {
return ret;
}
if ((rt->server_type == RTSP_SERVER_WMS ||
rt->server_type == RTSP_SERVER_REAL) &&
(av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {
if (rt->server_type == RTSP_SERVER_WMS) {
snprintf(cmd, sizeof(cmd) - 1,
"GET_PARAMETER %s RTSP/1.0\r\n",
s->filename);
rtsp_send_cmd_async(s, cmd, reply, NULL);
} else {
rtsp_send_cmd_async(s, "OPTIONS * RTSP/1.0\r\n",
reply, NULL);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
RTSPState *rt = VAR_0->priv_data;
int VAR_2;
RTSPMessageHeader reply1, *reply = &reply1;
char VAR_3[1024];
if (rt->server_type == RTSP_SERVER_REAL) {
int VAR_4;
enum AVDiscard VAR_5[MAX_STREAMS];
for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++)
VAR_5[VAR_4] = VAR_0->streams[VAR_4]->discard;
if (!rt->need_subscription) {
if (memcmp (VAR_5, rt->real_setup_cache,
sizeof(enum AVDiscard) * VAR_0->nb_streams)) {
av_strlcatf(VAR_3, sizeof(VAR_3),
"SET_PARAMETER %VAR_0 RTSP/1.0\VAR_6\n"
"Unsubscribe: %VAR_0\VAR_6\n",
VAR_0->filename, rt->last_subscription);
rtsp_send_cmd(VAR_0, VAR_3, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 1;
}
}
if (rt->need_subscription) {
int VAR_6, VAR_7, VAR_8 = 1;
memcpy(rt->real_setup_cache, VAR_5,
sizeof(enum AVDiscard) * VAR_0->nb_streams);
rt->last_subscription[0] = 0;
snprintf(VAR_3, sizeof(VAR_3),
"SET_PARAMETER %VAR_0 RTSP/1.0\VAR_6\n"
"Subscribe: ",
VAR_0->filename);
for (VAR_4 = 0; VAR_4 < rt->nb_rtsp_streams; VAR_4++) {
VAR_7 = 0;
for (VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) {
if (VAR_0->streams[VAR_6]->priv_data == rt->rtsp_streams[VAR_4]) {
if (VAR_0->streams[VAR_6]->discard != AVDISCARD_ALL) {
if (!VAR_8)
av_strlcat(rt->last_subscription, ",",
sizeof(rt->last_subscription));
ff_rdt_subscribe_rule(
rt->last_subscription,
sizeof(rt->last_subscription), VAR_4, VAR_7);
VAR_8 = 0;
}
VAR_7++;
}
}
}
av_strlcatf(VAR_3, sizeof(VAR_3), "%VAR_0\VAR_6\n", rt->last_subscription);
rtsp_send_cmd(VAR_0, VAR_3, reply, NULL);
if (reply->status_code != RTSP_STATUS_OK)
return AVERROR_INVALIDDATA;
rt->need_subscription = 0;
if (rt->state == RTSP_STATE_PLAYING)
rtsp_read_play (VAR_0);
}
}
VAR_2 = rtsp_fetch_packet(VAR_0, VAR_1);
if (VAR_2 < 0) {
return VAR_2;
}
if ((rt->server_type == RTSP_SERVER_WMS ||
rt->server_type == RTSP_SERVER_REAL) &&
(av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {
if (rt->server_type == RTSP_SERVER_WMS) {
snprintf(VAR_3, sizeof(VAR_3) - 1,
"GET_PARAMETER %VAR_0 RTSP/1.0\VAR_6\n",
VAR_0->filename);
rtsp_send_cmd_async(VAR_0, VAR_3, reply, NULL);
} else {
rtsp_send_cmd_async(VAR_0, "OPTIONS * RTSP/1.0\VAR_6\n",
reply, NULL);
}
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"int VAR_2;",
"RTSPMessageHeader reply1, *reply = &reply1;",
"char VAR_3[1024];",
"if (rt->server_type == RTSP_SERVER_REAL) {",
"int VAR_4;",
"enum AVDiscard VAR_5[MAX_STREAMS];",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++)",
"VAR_5[VAR_4] = VAR_0->streams[VAR_4]->discard;",
"if (!rt->need_subscription) {",
"if (memcmp (VAR_5, rt->real_setup_cache,\nsizeof(enum AVDiscard) * VAR_0->nb_streams)) {",
"av_strlcatf(VAR_3, sizeof(VAR_3),\n\"SET_PARAMETER %VAR_0 RTSP/1.0\\VAR_6\\n\"\n\"Unsubscribe: %VAR_0\\VAR_6\\n\",\nVAR_0->filename, rt->last_subscription);",
"rtsp_send_cmd(VAR_0, VAR_3, reply, NULL);",
"if (reply->status_code != RTSP_STATUS_OK)\nreturn AVERROR_INVALIDDATA;",
"rt->need_subscription = 1;",
"}",
"}",
"if (rt->need_subscription) {",
"int VAR_6, VAR_7, VAR_8 = 1;",
"memcpy(rt->real_setup_cache, VAR_5,\nsizeof(enum AVDiscard) * VAR_0->nb_streams);",
"rt->last_subscription[0] = 0;",
"snprintf(VAR_3, sizeof(VAR_3),\n\"SET_PARAMETER %VAR_0 RTSP/1.0\\VAR_6\\n\"\n\"Subscribe: \",\nVAR_0->filename);",
"for (VAR_4 = 0; VAR_4 < rt->nb_rtsp_streams; VAR_4++) {",
"VAR_7 = 0;",
"for (VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) {",
"if (VAR_0->streams[VAR_6]->priv_data == rt->rtsp_streams[VAR_4]) {",
"if (VAR_0->streams[VAR_6]->discard != AVDISCARD_ALL) {",
"if (!VAR_8)\nav_strlcat(rt->last_subscription, \",\",\nsizeof(rt->last_subscription));",
"ff_rdt_subscribe_rule(\nrt->last_subscription,\nsizeof(rt->last_subscription), VAR_4, VAR_7);",
"VAR_8 = 0;",
"}",
"VAR_7++;",
"}",
"}",
"}",
"av_strlcatf(VAR_3, sizeof(VAR_3), \"%VAR_0\\VAR_6\\n\", rt->last_subscription);",
"rtsp_send_cmd(VAR_0, VAR_3, reply, NULL);",
"if (reply->status_code != RTSP_STATUS_OK)\nreturn AVERROR_INVALIDDATA;",
"rt->need_subscription = 0;",
"if (rt->state == RTSP_STATE_PLAYING)\nrtsp_read_play (VAR_0);",
"}",
"}",
"VAR_2 = rtsp_fetch_packet(VAR_0, VAR_1);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"if ((rt->server_type == RTSP_SERVER_WMS ||\nrt->server_type == RTSP_SERVER_REAL) &&\n(av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) {",
"if (rt->server_type == RTSP_SERVER_WMS) {",
"snprintf(VAR_3, sizeof(VAR_3) - 1,\n\"GET_PARAMETER %VAR_0 RTSP/1.0\\VAR_6\\n\",\nVAR_0->filename);",
"rtsp_send_cmd_async(VAR_0, VAR_3, reply, NULL);",
"} else {",
"rtsp_send_cmd_async(VAR_0, \"OPTIONS * RTSP/1.0\\VAR_6\\n\",\nreply, NULL);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37,
39,
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65,
67
],
[
69
],
[
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
],
[
127,
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149,
151,
153
],
[
155
],
[
157,
159,
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
177
],
[
179
]
] |
19,030 | static int cudaupload_query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat input_pix_fmts[] = {
AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat output_pix_fmts[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
AVFilterFormats *in_fmts = ff_make_format_list(input_pix_fmts);
AVFilterFormats *out_fmts = ff_make_format_list(output_pix_fmts);
ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);
ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);
return 0;
}
| false | FFmpeg | 0faf3c3a25ede9ecfdb1cf68a0f8aef23c25197a | static int cudaupload_query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat input_pix_fmts[] = {
AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat output_pix_fmts[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
AVFilterFormats *in_fmts = ff_make_format_list(input_pix_fmts);
AVFilterFormats *out_fmts = ff_make_format_list(output_pix_fmts);
ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);
ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterContext *VAR_0)
{
static const enum AVPixelFormat VAR_1[] = {
AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat VAR_2[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
AVFilterFormats *in_fmts = ff_make_format_list(VAR_1);
AVFilterFormats *out_fmts = ff_make_format_list(VAR_2);
ff_formats_ref(in_fmts, &VAR_0->inputs[0]->out_formats);
ff_formats_ref(out_fmts, &VAR_0->outputs[0]->in_formats);
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0)\n{",
"static const enum AVPixelFormat VAR_1[] = {",
"AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P,\nAV_PIX_FMT_NONE,\n};",
"static const enum AVPixelFormat VAR_2[] = {",
"AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,\n};",
"AVFilterFormats *in_fmts = ff_make_format_list(VAR_1);",
"AVFilterFormats *out_fmts = ff_make_format_list(VAR_2);",
"ff_formats_ref(in_fmts, &VAR_0->inputs[0]->out_formats);",
"ff_formats_ref(out_fmts, &VAR_0->outputs[0]->in_formats);",
"return 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
],
[
31
],
[
33
]
] |
19,032 | static void opt_audio_sample_fmt(const char *arg)
{
if (strcmp(arg, "list"))
audio_sample_fmt = av_get_sample_fmt(arg);
else {
list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB);
ffmpeg_exit(0);
}
}
| false | FFmpeg | 6c18f1cda2e2b2471ebf75d30d552cb0cb61b6ad | static void opt_audio_sample_fmt(const char *arg)
{
if (strcmp(arg, "list"))
audio_sample_fmt = av_get_sample_fmt(arg);
else {
list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB);
ffmpeg_exit(0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
if (strcmp(VAR_0, "list"))
audio_sample_fmt = av_get_sample_fmt(VAR_0);
else {
list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB);
ffmpeg_exit(0);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"if (strcmp(VAR_0, \"list\"))\naudio_sample_fmt = av_get_sample_fmt(VAR_0);",
"else {",
"list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB);",
"ffmpeg_exit(0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,033 | static int wsvqa_read_header(AVFormatContext *s)
{
WsVqaDemuxContext *wsvqa = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
unsigned char *header;
unsigned char scratch[VQA_PREAMBLE_SIZE];
unsigned int chunk_tag;
unsigned int chunk_size;
int fps;
/* initialize the video decoder stream */
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->start_time = 0;
wsvqa->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_WS_VQA;
st->codec->codec_tag = 0; /* no fourcc */
/* skip to the start of the VQA header */
avio_seek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */
st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
header = (unsigned char *)st->codec->extradata;
if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
}
st->codec->width = AV_RL16(&header[6]);
st->codec->height = AV_RL16(&header[8]);
fps = header[12];
st->nb_frames =
st->duration = AV_RL16(&header[4]);
if (fps < 1 || fps > 30) {
av_log(s, AV_LOG_ERROR, "invalid fps: %d\n", fps);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(st, 64, 1, fps);
wsvqa->version = AV_RL16(&header[ 0]);
wsvqa->sample_rate = AV_RL16(&header[24]);
wsvqa->channels = header[26];
wsvqa->bps = header[27];
wsvqa->audio_stream_index = -1;
s->ctx_flags |= AVFMTCTX_NOHEADER;
/* there are 0 or more chunks before the FINF chunk; iterate until
* FINF has been skipped and the file will be ready to be demuxed */
do {
if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_tag = AV_RB32(&scratch[0]);
chunk_size = AV_RB32(&scratch[4]);
/* catch any unknown header tags, for curiousity */
switch (chunk_tag) {
case CINF_TAG:
case CINH_TAG:
case CIND_TAG:
case PINF_TAG:
case PINH_TAG:
case PIND_TAG:
case FINF_TAG:
case CMDS_TAG:
break;
default:
av_log (s, AV_LOG_ERROR, " note: unknown chunk seen (%c%c%c%c)\n",
scratch[0], scratch[1],
scratch[2], scratch[3]);
break;
}
avio_skip(pb, chunk_size);
} while (chunk_tag != FINF_TAG);
return 0;
}
| false | FFmpeg | e1b0d3a389ff7050c66f43891539200eddf4af15 | static int wsvqa_read_header(AVFormatContext *s)
{
WsVqaDemuxContext *wsvqa = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
unsigned char *header;
unsigned char scratch[VQA_PREAMBLE_SIZE];
unsigned int chunk_tag;
unsigned int chunk_size;
int fps;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->start_time = 0;
wsvqa->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_WS_VQA;
st->codec->codec_tag = 0;
avio_seek(pb, 20, SEEK_SET);
st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
header = (unsigned char *)st->codec->extradata;
if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
}
st->codec->width = AV_RL16(&header[6]);
st->codec->height = AV_RL16(&header[8]);
fps = header[12];
st->nb_frames =
st->duration = AV_RL16(&header[4]);
if (fps < 1 || fps > 30) {
av_log(s, AV_LOG_ERROR, "invalid fps: %d\n", fps);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(st, 64, 1, fps);
wsvqa->version = AV_RL16(&header[ 0]);
wsvqa->sample_rate = AV_RL16(&header[24]);
wsvqa->channels = header[26];
wsvqa->bps = header[27];
wsvqa->audio_stream_index = -1;
s->ctx_flags |= AVFMTCTX_NOHEADER;
do {
if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
return AVERROR(EIO);
chunk_tag = AV_RB32(&scratch[0]);
chunk_size = AV_RB32(&scratch[4]);
switch (chunk_tag) {
case CINF_TAG:
case CINH_TAG:
case CIND_TAG:
case PINF_TAG:
case PINH_TAG:
case PIND_TAG:
case FINF_TAG:
case CMDS_TAG:
break;
default:
av_log (s, AV_LOG_ERROR, " note: unknown chunk seen (%c%c%c%c)\n",
scratch[0], scratch[1],
scratch[2], scratch[3]);
break;
}
avio_skip(pb, chunk_size);
} while (chunk_tag != FINF_TAG);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
WsVqaDemuxContext *wsvqa = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
AVStream *st;
unsigned char *VAR_1;
unsigned char VAR_2[VQA_PREAMBLE_SIZE];
unsigned int VAR_3;
unsigned int VAR_4;
int VAR_5;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->start_time = 0;
wsvqa->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_WS_VQA;
st->codec->codec_tag = 0;
avio_seek(pb, 20, SEEK_SET);
st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
VAR_1 = (unsigned char *)st->codec->extradata;
if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) {
av_free(st->codec->extradata);
return AVERROR(EIO);
}
st->codec->width = AV_RL16(&VAR_1[6]);
st->codec->height = AV_RL16(&VAR_1[8]);
VAR_5 = VAR_1[12];
st->nb_frames =
st->duration = AV_RL16(&VAR_1[4]);
if (VAR_5 < 1 || VAR_5 > 30) {
av_log(VAR_0, AV_LOG_ERROR, "invalid VAR_5: %d\n", VAR_5);
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(st, 64, 1, VAR_5);
wsvqa->version = AV_RL16(&VAR_1[ 0]);
wsvqa->sample_rate = AV_RL16(&VAR_1[24]);
wsvqa->channels = VAR_1[26];
wsvqa->bps = VAR_1[27];
wsvqa->audio_stream_index = -1;
VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;
do {
if (avio_read(pb, VAR_2, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
return AVERROR(EIO);
VAR_3 = AV_RB32(&VAR_2[0]);
VAR_4 = AV_RB32(&VAR_2[4]);
switch (VAR_3) {
case CINF_TAG:
case CINH_TAG:
case CIND_TAG:
case PINF_TAG:
case PINH_TAG:
case PIND_TAG:
case FINF_TAG:
case CMDS_TAG:
break;
default:
av_log (VAR_0, AV_LOG_ERROR, " note: unknown chunk seen (%c%c%c%c)\n",
VAR_2[0], VAR_2[1],
VAR_2[2], VAR_2[3]);
break;
}
avio_skip(pb, VAR_4);
} while (VAR_3 != FINF_TAG);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"WsVqaDemuxContext *wsvqa = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"AVStream *st;",
"unsigned char *VAR_1;",
"unsigned char VAR_2[VQA_PREAMBLE_SIZE];",
"unsigned int VAR_3;",
"unsigned int VAR_4;",
"int VAR_5;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->start_time = 0;",
"wsvqa->video_stream_index = st->index;",
"st->codec->codec_type = AVMEDIA_TYPE_VIDEO;",
"st->codec->codec_id = AV_CODEC_ID_WS_VQA;",
"st->codec->codec_tag = 0;",
"avio_seek(pb, 20, SEEK_SET);",
"st->codec->extradata_size = VQA_HEADER_SIZE;",
"st->codec->extradata = av_mallocz(VQA_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);",
"VAR_1 = (unsigned char *)st->codec->extradata;",
"if (avio_read(pb, st->codec->extradata, VQA_HEADER_SIZE) !=\nVQA_HEADER_SIZE) {",
"av_free(st->codec->extradata);",
"return AVERROR(EIO);",
"}",
"st->codec->width = AV_RL16(&VAR_1[6]);",
"st->codec->height = AV_RL16(&VAR_1[8]);",
"VAR_5 = VAR_1[12];",
"st->nb_frames =\nst->duration = AV_RL16(&VAR_1[4]);",
"if (VAR_5 < 1 || VAR_5 > 30) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid VAR_5: %d\\n\", VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"avpriv_set_pts_info(st, 64, 1, VAR_5);",
"wsvqa->version = AV_RL16(&VAR_1[ 0]);",
"wsvqa->sample_rate = AV_RL16(&VAR_1[24]);",
"wsvqa->channels = VAR_1[26];",
"wsvqa->bps = VAR_1[27];",
"wsvqa->audio_stream_index = -1;",
"VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;",
"do {",
"if (avio_read(pb, VAR_2, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)\nreturn AVERROR(EIO);",
"VAR_3 = AV_RB32(&VAR_2[0]);",
"VAR_4 = AV_RB32(&VAR_2[4]);",
"switch (VAR_3) {",
"case CINF_TAG:\ncase CINH_TAG:\ncase CIND_TAG:\ncase PINF_TAG:\ncase PINH_TAG:\ncase PIND_TAG:\ncase FINF_TAG:\ncase CMDS_TAG:\nbreak;",
"default:\nav_log (VAR_0, AV_LOG_ERROR, \" note: unknown chunk seen (%c%c%c%c)\\n\",\nVAR_2[0], VAR_2[1],\nVAR_2[2], VAR_2[3]);",
"break;",
"}",
"avio_skip(pb, VAR_4);",
"} while (VAR_3 != FINF_TAG);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
123
],
[
125,
127,
129,
131,
133,
135,
137,
139,
141
],
[
145,
147,
149,
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
165
],
[
167
]
] |
19,034 | static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
{
FlatContext *flat = wctx->priv;
AVBPrint buf;
flat_print_key_prefix(wctx);
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
printf("%s=", flat_escape_key_str(&buf, key, flat->sep));
av_bprint_clear(&buf);
printf("\"%s\"\n", flat_escape_value_str(&buf, value));
av_bprint_finalize(&buf, NULL);
}
| false | FFmpeg | 01e4537f66c6d054f8c7bdbdd5b3cfb4220d12fe | static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
{
FlatContext *flat = wctx->priv;
AVBPrint buf;
flat_print_key_prefix(wctx);
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
printf("%s=", flat_escape_key_str(&buf, key, flat->sep));
av_bprint_clear(&buf);
printf("\"%s\"\n", flat_escape_value_str(&buf, value));
av_bprint_finalize(&buf, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, const char *VAR_2)
{
FlatContext *flat = VAR_0->priv;
AVBPrint buf;
flat_print_key_prefix(VAR_0);
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
printf("%s=", flat_escape_key_str(&buf, VAR_1, flat->sep));
av_bprint_clear(&buf);
printf("\"%s\"\n", flat_escape_value_str(&buf, VAR_2));
av_bprint_finalize(&buf, NULL);
}
| [
"static void FUNC_0(WriterContext *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"FlatContext *flat = VAR_0->priv;",
"AVBPrint buf;",
"flat_print_key_prefix(VAR_0);",
"av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);",
"printf(\"%s=\", flat_escape_key_str(&buf, VAR_1, flat->sep));",
"av_bprint_clear(&buf);",
"printf(\"\\\"%s\\\"\\n\", flat_escape_value_str(&buf, VAR_2));",
"av_bprint_finalize(&buf, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,035 | static int nut_write_packet(AVFormatContext *s, AVPacket *pkt){
NUTContext *nut = s->priv_data;
StreamContext *nus= &nut->stream[pkt->stream_index];
AVIOContext *bc = s->pb, *dyn_bc;
FrameCode *fc;
int64_t coded_pts;
int best_length, frame_code, flags, needed_flags, i, header_idx, best_header_idx;
int key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY);
int store_sp=0;
int ret;
if(pkt->pts < 0)
return -1;
if(1LL<<(20+3*nut->header_count) <= avio_tell(bc))
write_headers(s, bc);
if(key_frame && !(nus->last_flags & FLAG_KEY))
store_sp= 1;
if(pkt->size + 30/*FIXME check*/ + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
store_sp= 1;
//FIXME: Ensure store_sp is 1 in the first place.
if(store_sp){
Syncpoint *sp, dummy= {.pos= INT64_MAX};
ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
for(i=0; i<s->nb_streams; i++){
AVStream *st= s->streams[i];
int64_t dts_tb = av_rescale_rnd(pkt->dts,
nus->time_base->num * (int64_t)nut->stream[i].time_base->den,
nus->time_base->den * (int64_t)nut->stream[i].time_base->num,
AV_ROUND_DOWN);
int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD);
if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);
}
if(dummy.pos == INT64_MAX)
dummy.pos= 0;
sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
NULL);
nut->last_syncpoint_pos= avio_tell(bc);
ret = avio_open_dyn_buf(&dyn_bc);
if(ret < 0)
return ret;
put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts);
}
av_assert0(nus->last_pts != AV_NOPTS_VALUE);
coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1);
if(ff_lsb2full(nus, coded_pts) != pkt->pts)
coded_pts= pkt->pts + (1<<nus->msb_pts_shift);
best_header_idx= find_best_header_idx(nut, pkt);
best_length=INT_MAX;
frame_code= -1;
for(i=0; i<256; i++){
int length= 0;
FrameCode *fc= &nut->frame_code[i];
int flags= fc->flags;
if(flags & FLAG_INVALID)
continue;
needed_flags= get_needed_flags(nut, nus, fc, pkt);
if(flags & FLAG_CODED){
length++;
flags = needed_flags;
}
if((flags & needed_flags) != needed_flags)
continue;
if((flags ^ needed_flags) & FLAG_KEY)
continue;
if(flags & FLAG_STREAM_ID)
length+= ff_get_v_length(pkt->stream_index);
if(pkt->size % fc->size_mul != fc->size_lsb)
continue;
if(flags & FLAG_SIZE_MSB)
length += ff_get_v_length(pkt->size / fc->size_mul);
if(flags & FLAG_CHECKSUM)
length+=4;
if(flags & FLAG_CODED_PTS)
length += ff_get_v_length(coded_pts);
if( (flags & FLAG_CODED)
&& nut->header_len[best_header_idx] > nut->header_len[fc->header_idx]+1){
flags |= FLAG_HEADER_IDX;
}
if(flags & FLAG_HEADER_IDX){
length += 1 - nut->header_len[best_header_idx];
}else{
length -= nut->header_len[fc->header_idx];
}
length*=4;
length+= !(flags & FLAG_CODED_PTS);
length+= !(flags & FLAG_CHECKSUM);
if(length < best_length){
best_length= length;
frame_code=i;
}
}
av_assert0(frame_code != -1);
fc= &nut->frame_code[frame_code];
flags= fc->flags;
needed_flags= get_needed_flags(nut, nus, fc, pkt);
header_idx= fc->header_idx;
ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
avio_w8(bc, frame_code);
if(flags & FLAG_CODED){
ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
flags = needed_flags;
}
if(flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index);
if(flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);
if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
if(flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
else ffio_get_checksum(bc);
avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
nus->last_flags= flags;
nus->last_pts= pkt->pts;
//FIXME just store one per syncpoint
if(flags & FLAG_KEY)
av_add_index_entry(
s->streams[pkt->stream_index],
nut->last_syncpoint_pos,
pkt->pts,
0,
0,
AVINDEX_KEYFRAME);
return 0;
}
| false | FFmpeg | b010d9b58651379883b42e58494aaefbab4df648 | static int nut_write_packet(AVFormatContext *s, AVPacket *pkt){
NUTContext *nut = s->priv_data;
StreamContext *nus= &nut->stream[pkt->stream_index];
AVIOContext *bc = s->pb, *dyn_bc;
FrameCode *fc;
int64_t coded_pts;
int best_length, frame_code, flags, needed_flags, i, header_idx, best_header_idx;
int key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY);
int store_sp=0;
int ret;
if(pkt->pts < 0)
return -1;
if(1LL<<(20+3*nut->header_count) <= avio_tell(bc))
write_headers(s, bc);
if(key_frame && !(nus->last_flags & FLAG_KEY))
store_sp= 1;
if(pkt->size + 30 + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
store_sp= 1;
if(store_sp){
Syncpoint *sp, dummy= {.pos= INT64_MAX};
ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
for(i=0; i<s->nb_streams; i++){
AVStream *st= s->streams[i];
int64_t dts_tb = av_rescale_rnd(pkt->dts,
nus->time_base->num * (int64_t)nut->stream[i].time_base->den,
nus->time_base->den * (int64_t)nut->stream[i].time_base->num,
AV_ROUND_DOWN);
int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD);
if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);
}
if(dummy.pos == INT64_MAX)
dummy.pos= 0;
sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
NULL);
nut->last_syncpoint_pos= avio_tell(bc);
ret = avio_open_dyn_buf(&dyn_bc);
if(ret < 0)
return ret;
put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0, pkt->dts);
}
av_assert0(nus->last_pts != AV_NOPTS_VALUE);
coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1);
if(ff_lsb2full(nus, coded_pts) != pkt->pts)
coded_pts= pkt->pts + (1<<nus->msb_pts_shift);
best_header_idx= find_best_header_idx(nut, pkt);
best_length=INT_MAX;
frame_code= -1;
for(i=0; i<256; i++){
int length= 0;
FrameCode *fc= &nut->frame_code[i];
int flags= fc->flags;
if(flags & FLAG_INVALID)
continue;
needed_flags= get_needed_flags(nut, nus, fc, pkt);
if(flags & FLAG_CODED){
length++;
flags = needed_flags;
}
if((flags & needed_flags) != needed_flags)
continue;
if((flags ^ needed_flags) & FLAG_KEY)
continue;
if(flags & FLAG_STREAM_ID)
length+= ff_get_v_length(pkt->stream_index);
if(pkt->size % fc->size_mul != fc->size_lsb)
continue;
if(flags & FLAG_SIZE_MSB)
length += ff_get_v_length(pkt->size / fc->size_mul);
if(flags & FLAG_CHECKSUM)
length+=4;
if(flags & FLAG_CODED_PTS)
length += ff_get_v_length(coded_pts);
if( (flags & FLAG_CODED)
&& nut->header_len[best_header_idx] > nut->header_len[fc->header_idx]+1){
flags |= FLAG_HEADER_IDX;
}
if(flags & FLAG_HEADER_IDX){
length += 1 - nut->header_len[best_header_idx];
}else{
length -= nut->header_len[fc->header_idx];
}
length*=4;
length+= !(flags & FLAG_CODED_PTS);
length+= !(flags & FLAG_CHECKSUM);
if(length < best_length){
best_length= length;
frame_code=i;
}
}
av_assert0(frame_code != -1);
fc= &nut->frame_code[frame_code];
flags= fc->flags;
needed_flags= get_needed_flags(nut, nus, fc, pkt);
header_idx= fc->header_idx;
ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
avio_w8(bc, frame_code);
if(flags & FLAG_CODED){
ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
flags = needed_flags;
}
if(flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index);
if(flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);
if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
if(flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
else ffio_get_checksum(bc);
avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
nus->last_flags= flags;
nus->last_pts= pkt->pts;
if(flags & FLAG_KEY)
av_add_index_entry(
s->streams[pkt->stream_index],
nut->last_syncpoint_pos,
pkt->pts,
0,
0,
AVINDEX_KEYFRAME);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1){
NUTContext *nut = VAR_0->priv_data;
StreamContext *nus= &nut->stream[VAR_1->stream_index];
AVIOContext *bc = VAR_0->pb, *dyn_bc;
FrameCode *fc;
int64_t coded_pts;
int VAR_2, VAR_3, VAR_13, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9 = !!(VAR_1->VAR_13 & AV_PKT_FLAG_KEY);
int VAR_10=0;
int VAR_11;
if(VAR_1->pts < 0)
return -1;
if(1LL<<(20+3*nut->header_count) <= avio_tell(bc))
write_headers(VAR_0, bc);
if(VAR_9 && !(nus->last_flags & FLAG_KEY))
VAR_10= 1;
if(VAR_1->size + 30 + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
VAR_10= 1;
if(VAR_10){
Syncpoint *sp, dummy= {.pos= INT64_MAX};
ff_nut_reset_ts(nut, *nus->time_base, VAR_1->dts);
for(VAR_6=0; VAR_6<VAR_0->nb_streams; VAR_6++){
AVStream *st= VAR_0->streams[VAR_6];
int64_t dts_tb = av_rescale_rnd(VAR_1->dts,
nus->time_base->num * (int64_t)nut->stream[VAR_6].time_base->den,
nus->time_base->den * (int64_t)nut->stream[VAR_6].time_base->num,
AV_ROUND_DOWN);
int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD);
if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);
}
if(dummy.pos == INT64_MAX)
dummy.pos= 0;
sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
NULL);
nut->last_syncpoint_pos= avio_tell(bc);
VAR_11 = avio_open_dyn_buf(&dyn_bc);
if(VAR_11 < 0)
return VAR_11;
put_tt(nut, nus->time_base, dyn_bc, VAR_1->dts);
ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0, VAR_1->dts);
}
av_assert0(nus->last_pts != AV_NOPTS_VALUE);
coded_pts = VAR_1->pts & ((1<<nus->msb_pts_shift)-1);
if(ff_lsb2full(nus, coded_pts) != VAR_1->pts)
coded_pts= VAR_1->pts + (1<<nus->msb_pts_shift);
VAR_8= find_best_header_idx(nut, VAR_1);
VAR_2=INT_MAX;
VAR_3= -1;
for(VAR_6=0; VAR_6<256; VAR_6++){
int VAR_12= 0;
FrameCode *fc= &nut->VAR_3[VAR_6];
int VAR_13= fc->VAR_13;
if(VAR_13 & FLAG_INVALID)
continue;
VAR_5= get_needed_flags(nut, nus, fc, VAR_1);
if(VAR_13 & FLAG_CODED){
VAR_12++;
VAR_13 = VAR_5;
}
if((VAR_13 & VAR_5) != VAR_5)
continue;
if((VAR_13 ^ VAR_5) & FLAG_KEY)
continue;
if(VAR_13 & FLAG_STREAM_ID)
VAR_12+= ff_get_v_length(VAR_1->stream_index);
if(VAR_1->size % fc->size_mul != fc->size_lsb)
continue;
if(VAR_13 & FLAG_SIZE_MSB)
VAR_12 += ff_get_v_length(VAR_1->size / fc->size_mul);
if(VAR_13 & FLAG_CHECKSUM)
VAR_12+=4;
if(VAR_13 & FLAG_CODED_PTS)
VAR_12 += ff_get_v_length(coded_pts);
if( (VAR_13 & FLAG_CODED)
&& nut->header_len[VAR_8] > nut->header_len[fc->VAR_7]+1){
VAR_13 |= FLAG_HEADER_IDX;
}
if(VAR_13 & FLAG_HEADER_IDX){
VAR_12 += 1 - nut->header_len[VAR_8];
}else{
VAR_12 -= nut->header_len[fc->VAR_7];
}
VAR_12*=4;
VAR_12+= !(VAR_13 & FLAG_CODED_PTS);
VAR_12+= !(VAR_13 & FLAG_CHECKSUM);
if(VAR_12 < VAR_2){
VAR_2= VAR_12;
VAR_3=VAR_6;
}
}
av_assert0(VAR_3 != -1);
fc= &nut->VAR_3[VAR_3];
VAR_13= fc->VAR_13;
VAR_5= get_needed_flags(nut, nus, fc, VAR_1);
VAR_7= fc->VAR_7;
ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
avio_w8(bc, VAR_3);
if(VAR_13 & FLAG_CODED){
ff_put_v(bc, (VAR_13^VAR_5) & ~(FLAG_CODED));
VAR_13 = VAR_5;
}
if(VAR_13 & FLAG_STREAM_ID) ff_put_v(bc, VAR_1->stream_index);
if(VAR_13 & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);
if(VAR_13 & FLAG_SIZE_MSB) ff_put_v(bc, VAR_1->size / fc->size_mul);
if(VAR_13 & FLAG_HEADER_IDX) ff_put_v(bc, VAR_7= VAR_8);
if(VAR_13 & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
else ffio_get_checksum(bc);
avio_write(bc, VAR_1->data + nut->header_len[VAR_7], VAR_1->size - nut->header_len[VAR_7]);
nus->last_flags= VAR_13;
nus->last_pts= VAR_1->pts;
if(VAR_13 & FLAG_KEY)
av_add_index_entry(
VAR_0->streams[VAR_1->stream_index],
nut->last_syncpoint_pos,
VAR_1->pts,
0,
0,
AVINDEX_KEYFRAME);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1){",
"NUTContext *nut = VAR_0->priv_data;",
"StreamContext *nus= &nut->stream[VAR_1->stream_index];",
"AVIOContext *bc = VAR_0->pb, *dyn_bc;",
"FrameCode *fc;",
"int64_t coded_pts;",
"int VAR_2, VAR_3, VAR_13, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9 = !!(VAR_1->VAR_13 & AV_PKT_FLAG_KEY);",
"int VAR_10=0;",
"int VAR_11;",
"if(VAR_1->pts < 0)\nreturn -1;",
"if(1LL<<(20+3*nut->header_count) <= avio_tell(bc))\nwrite_headers(VAR_0, bc);",
"if(VAR_9 && !(nus->last_flags & FLAG_KEY))\nVAR_10= 1;",
"if(VAR_1->size + 30 + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)\nVAR_10= 1;",
"if(VAR_10){",
"Syncpoint *sp, dummy= {.pos= INT64_MAX};",
"ff_nut_reset_ts(nut, *nus->time_base, VAR_1->dts);",
"for(VAR_6=0; VAR_6<VAR_0->nb_streams; VAR_6++){",
"AVStream *st= VAR_0->streams[VAR_6];",
"int64_t dts_tb = av_rescale_rnd(VAR_1->dts,\nnus->time_base->num * (int64_t)nut->stream[VAR_6].time_base->den,\nnus->time_base->den * (int64_t)nut->stream[VAR_6].time_base->num,\nAV_ROUND_DOWN);",
"int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD);",
"if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);",
"}",
"if(dummy.pos == INT64_MAX)\ndummy.pos= 0;",
"sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,\nNULL);",
"nut->last_syncpoint_pos= avio_tell(bc);",
"VAR_11 = avio_open_dyn_buf(&dyn_bc);",
"if(VAR_11 < 0)\nreturn VAR_11;",
"put_tt(nut, nus->time_base, dyn_bc, VAR_1->dts);",
"ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);",
"put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);",
"ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0, VAR_1->dts);",
"}",
"av_assert0(nus->last_pts != AV_NOPTS_VALUE);",
"coded_pts = VAR_1->pts & ((1<<nus->msb_pts_shift)-1);",
"if(ff_lsb2full(nus, coded_pts) != VAR_1->pts)\ncoded_pts= VAR_1->pts + (1<<nus->msb_pts_shift);",
"VAR_8= find_best_header_idx(nut, VAR_1);",
"VAR_2=INT_MAX;",
"VAR_3= -1;",
"for(VAR_6=0; VAR_6<256; VAR_6++){",
"int VAR_12= 0;",
"FrameCode *fc= &nut->VAR_3[VAR_6];",
"int VAR_13= fc->VAR_13;",
"if(VAR_13 & FLAG_INVALID)\ncontinue;",
"VAR_5= get_needed_flags(nut, nus, fc, VAR_1);",
"if(VAR_13 & FLAG_CODED){",
"VAR_12++;",
"VAR_13 = VAR_5;",
"}",
"if((VAR_13 & VAR_5) != VAR_5)\ncontinue;",
"if((VAR_13 ^ VAR_5) & FLAG_KEY)\ncontinue;",
"if(VAR_13 & FLAG_STREAM_ID)\nVAR_12+= ff_get_v_length(VAR_1->stream_index);",
"if(VAR_1->size % fc->size_mul != fc->size_lsb)\ncontinue;",
"if(VAR_13 & FLAG_SIZE_MSB)\nVAR_12 += ff_get_v_length(VAR_1->size / fc->size_mul);",
"if(VAR_13 & FLAG_CHECKSUM)\nVAR_12+=4;",
"if(VAR_13 & FLAG_CODED_PTS)\nVAR_12 += ff_get_v_length(coded_pts);",
"if( (VAR_13 & FLAG_CODED)\n&& nut->header_len[VAR_8] > nut->header_len[fc->VAR_7]+1){",
"VAR_13 |= FLAG_HEADER_IDX;",
"}",
"if(VAR_13 & FLAG_HEADER_IDX){",
"VAR_12 += 1 - nut->header_len[VAR_8];",
"}else{",
"VAR_12 -= nut->header_len[fc->VAR_7];",
"}",
"VAR_12*=4;",
"VAR_12+= !(VAR_13 & FLAG_CODED_PTS);",
"VAR_12+= !(VAR_13 & FLAG_CHECKSUM);",
"if(VAR_12 < VAR_2){",
"VAR_2= VAR_12;",
"VAR_3=VAR_6;",
"}",
"}",
"av_assert0(VAR_3 != -1);",
"fc= &nut->VAR_3[VAR_3];",
"VAR_13= fc->VAR_13;",
"VAR_5= get_needed_flags(nut, nus, fc, VAR_1);",
"VAR_7= fc->VAR_7;",
"ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);",
"avio_w8(bc, VAR_3);",
"if(VAR_13 & FLAG_CODED){",
"ff_put_v(bc, (VAR_13^VAR_5) & ~(FLAG_CODED));",
"VAR_13 = VAR_5;",
"}",
"if(VAR_13 & FLAG_STREAM_ID) ff_put_v(bc, VAR_1->stream_index);",
"if(VAR_13 & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);",
"if(VAR_13 & FLAG_SIZE_MSB) ff_put_v(bc, VAR_1->size / fc->size_mul);",
"if(VAR_13 & FLAG_HEADER_IDX) ff_put_v(bc, VAR_7= VAR_8);",
"if(VAR_13 & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));",
"else ffio_get_checksum(bc);",
"avio_write(bc, VAR_1->data + nut->header_len[VAR_7], VAR_1->size - nut->header_len[VAR_7]);",
"nus->last_flags= VAR_13;",
"nus->last_pts= VAR_1->pts;",
"if(VAR_13 & FLAG_KEY)\nav_add_index_entry(\nVAR_0->streams[VAR_1->stream_index],\nnut->last_syncpoint_pos,\nVAR_1->pts,\n0,\n0,\nAVINDEX_KEYFRAME);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
29,
31
],
[
35,
37
],
[
41,
43
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63,
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81,
83
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113,
115
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
157
],
[
161,
163
],
[
167,
169
],
[
173,
175
],
[
177,
179
],
[
183,
185
],
[
189,
191
],
[
195,
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
285,
287,
289,
291,
293,
295,
297,
299
],
[
303
],
[
305
]
] |
19,036 | ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
int *seq, int *flags, int64_t *timestamp)
{
RMDemuxContext *rm = s->priv_data;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
rm->current_stream= st->id;
if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len))
return -1; //got partial frame
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
(st->codec->codec_id == CODEC_ID_COOK) ||
(st->codec->codec_id == CODEC_ID_ATRAC3) ||
(st->codec->codec_id == CODEC_ID_SIPR)) {
int x;
int sps = ast->sub_packet_size;
int cfs = ast->coded_framesize;
int h = ast->sub_packet_h;
int y = ast->sub_packet_cnt;
int w = ast->audio_framesize;
if (*flags & 2)
y = ast->sub_packet_cnt = 0;
if (!y)
ast->audiotimestamp = *timestamp;
switch(st->codec->codec_id) {
case CODEC_ID_RA_288:
for (x = 0; x < h/2; x++)
get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (x = 0; x < w/sps; x++)
get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
}
if (++(ast->sub_packet_cnt) < h)
return -1;
else {
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
rm->audio_pkt_cnt = h * w / st->codec->block_align - 1;
// Release first audio packet
av_new_packet(pkt, st->codec->block_align);
memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this
*timestamp = ast->audiotimestamp;
*flags = 2; // Mark first packet as keyframe
}
} else if (st->codec->codec_id == CODEC_ID_AAC) {
int x;
rm->audio_stream_num = st->index;
ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
ast->sub_packet_lengths[x] = get_be16(pb);
// Release first audio packet
rm->audio_pkt_cnt = ast->sub_packet_cnt - 1;
av_get_packet(pb, pkt, ast->sub_packet_lengths[0]);
*flags = 2; // Mark first packet as keyframe
}
} else {
av_get_packet(pb, pkt, len);
rm_ac3_swap_bytes(st, pkt);
}
} else
av_get_packet(pb, pkt, len);
if( (st->discard >= AVDISCARD_NONKEY && !(*flags&2))
|| st->discard >= AVDISCARD_ALL){
av_free_packet(pkt);
return -1;
}
pkt->stream_index = st->index;
#if 0
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec->codec_id == CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
seq |= (*timestamp&~0x3FFF);
if(seq - *timestamp > 0x2000) seq -= 0x4000;
if(seq - *timestamp < -0x2000) seq += 0x4000;
}
}
#endif
pkt->pts= *timestamp;
if (*flags & 2)
pkt->flags |= PKT_FLAG_KEY;
return st->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
| false | FFmpeg | dc3685e12999f106dd8e576e5b7d5543d4f70fa1 | ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
AVStream *st, RMStream *ast, int len, AVPacket *pkt,
int *seq, int *flags, int64_t *timestamp)
{
RMDemuxContext *rm = s->priv_data;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
rm->current_stream= st->id;
if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len))
return -1;
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
(st->codec->codec_id == CODEC_ID_COOK) ||
(st->codec->codec_id == CODEC_ID_ATRAC3) ||
(st->codec->codec_id == CODEC_ID_SIPR)) {
int x;
int sps = ast->sub_packet_size;
int cfs = ast->coded_framesize;
int h = ast->sub_packet_h;
int y = ast->sub_packet_cnt;
int w = ast->audio_framesize;
if (*flags & 2)
y = ast->sub_packet_cnt = 0;
if (!y)
ast->audiotimestamp = *timestamp;
switch(st->codec->codec_id) {
case CODEC_ID_RA_288:
for (x = 0; x < h/2; x++)
get_buffer(pb, ast->pkt.data+x*2*w+y*cfs, cfs);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (x = 0; x < w/sps; x++)
get_buffer(pb, ast->pkt.data+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps);
break;
}
if (++(ast->sub_packet_cnt) < h)
return -1;
else {
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
rm->audio_pkt_cnt = h * w / st->codec->block_align - 1;
av_new_packet(pkt, st->codec->block_align);
memcpy(pkt->data, ast->pkt.data, st->codec->block_align);
*timestamp = ast->audiotimestamp;
*flags = 2;
}
} else if (st->codec->codec_id == CODEC_ID_AAC) {
int x;
rm->audio_stream_num = st->index;
ast->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4;
if (ast->sub_packet_cnt) {
for (x = 0; x < ast->sub_packet_cnt; x++)
ast->sub_packet_lengths[x] = get_be16(pb);
rm->audio_pkt_cnt = ast->sub_packet_cnt - 1;
av_get_packet(pb, pkt, ast->sub_packet_lengths[0]);
*flags = 2;
}
} else {
av_get_packet(pb, pkt, len);
rm_ac3_swap_bytes(st, pkt);
}
} else
av_get_packet(pb, pkt, len);
if( (st->discard >= AVDISCARD_NONKEY && !(*flags&2))
|| st->discard >= AVDISCARD_ALL){
av_free_packet(pkt);
return -1;
}
pkt->stream_index = st->index;
#if 0
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec->codec_id == CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
seq |= (*timestamp&~0x3FFF);
if(seq - *timestamp > 0x2000) seq -= 0x4000;
if(seq - *timestamp < -0x2000) seq += 0x4000;
}
}
#endif
pkt->pts= *timestamp;
if (*flags & 2)
pkt->flags |= PKT_FLAG_KEY;
return st->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0 (AVFormatContext *VAR_0, ByteIOContext *VAR_1,
AVStream *VAR_2, RMStream *VAR_3, int VAR_4, AVPacket *VAR_5,
int *VAR_6, int *VAR_7, int64_t *VAR_8)
{
RMDemuxContext *rm = VAR_0->priv_data;
if (VAR_2->codec->codec_type == CODEC_TYPE_VIDEO) {
rm->current_stream= VAR_2->id;
if(rm_assemble_video_frame(VAR_0, VAR_1, rm, VAR_3, VAR_5, VAR_4))
return -1;
} else if (VAR_2->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((VAR_2->codec->codec_id == CODEC_ID_RA_288) ||
(VAR_2->codec->codec_id == CODEC_ID_COOK) ||
(VAR_2->codec->codec_id == CODEC_ID_ATRAC3) ||
(VAR_2->codec->codec_id == CODEC_ID_SIPR)) {
int VAR_15;
int VAR_10 = VAR_3->sub_packet_size;
int VAR_11 = VAR_3->coded_framesize;
int VAR_12 = VAR_3->sub_packet_h;
int VAR_13 = VAR_3->sub_packet_cnt;
int VAR_14 = VAR_3->audio_framesize;
if (*VAR_7 & 2)
VAR_13 = VAR_3->sub_packet_cnt = 0;
if (!VAR_13)
VAR_3->audiotimestamp = *VAR_8;
switch(VAR_2->codec->codec_id) {
case CODEC_ID_RA_288:
for (VAR_15 = 0; VAR_15 < VAR_12/2; VAR_15++)
get_buffer(VAR_1, VAR_3->VAR_5.data+VAR_15*2*VAR_14+VAR_13*VAR_11, VAR_11);
break;
case CODEC_ID_ATRAC3:
case CODEC_ID_COOK:
for (VAR_15 = 0; VAR_15 < VAR_14/VAR_10; VAR_15++)
get_buffer(VAR_1, VAR_3->VAR_5.data+VAR_10*(VAR_12*VAR_15+((VAR_12+1)/2)*(VAR_13&1)+(VAR_13>>1)), VAR_10);
break;
}
if (++(VAR_3->sub_packet_cnt) < VAR_12)
return -1;
else {
VAR_3->sub_packet_cnt = 0;
rm->audio_stream_num = VAR_2->index;
rm->audio_pkt_cnt = VAR_12 * VAR_14 / VAR_2->codec->block_align - 1;
av_new_packet(VAR_5, VAR_2->codec->block_align);
memcpy(VAR_5->data, VAR_3->VAR_5.data, VAR_2->codec->block_align);
*VAR_8 = VAR_3->audiotimestamp;
*VAR_7 = 2;
}
} else if (VAR_2->codec->codec_id == CODEC_ID_AAC) {
int VAR_15;
rm->audio_stream_num = VAR_2->index;
VAR_3->sub_packet_cnt = (get_be16(VAR_1) & 0xf0) >> 4;
if (VAR_3->sub_packet_cnt) {
for (VAR_15 = 0; VAR_15 < VAR_3->sub_packet_cnt; VAR_15++)
VAR_3->sub_packet_lengths[VAR_15] = get_be16(VAR_1);
rm->audio_pkt_cnt = VAR_3->sub_packet_cnt - 1;
av_get_packet(VAR_1, VAR_5, VAR_3->sub_packet_lengths[0]);
*VAR_7 = 2;
}
} else {
av_get_packet(VAR_1, VAR_5, VAR_4);
rm_ac3_swap_bytes(VAR_2, VAR_5);
}
} else
av_get_packet(VAR_1, VAR_5, VAR_4);
if( (VAR_2->discard >= AVDISCARD_NONKEY && !(*VAR_7&2))
|| VAR_2->discard >= AVDISCARD_ALL){
av_free_packet(VAR_5);
return -1;
}
VAR_5->stream_index = VAR_2->index;
#if 0
if (VAR_2->codec->codec_type == CODEC_TYPE_VIDEO) {
if(VAR_2->codec->codec_id == CODEC_ID_RV20){
int VAR_6= 128*(VAR_5->data[2]&0x7F) + (VAR_5->data[3]>>1);
av_log(VAR_0, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *VAR_8, *VAR_8*512LL/25, VAR_6);
VAR_6 |= (*VAR_8&~0x3FFF);
if(VAR_6 - *VAR_8 > 0x2000) VAR_6 -= 0x4000;
if(VAR_6 - *VAR_8 < -0x2000) VAR_6 += 0x4000;
}
}
#endif
VAR_5->pts= *VAR_8;
if (*VAR_7 & 2)
VAR_5->VAR_7 |= PKT_FLAG_KEY;
return VAR_2->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
| [
"FUNC_0 (AVFormatContext *VAR_0, ByteIOContext *VAR_1,\nAVStream *VAR_2, RMStream *VAR_3, int VAR_4, AVPacket *VAR_5,\nint *VAR_6, int *VAR_7, int64_t *VAR_8)\n{",
"RMDemuxContext *rm = VAR_0->priv_data;",
"if (VAR_2->codec->codec_type == CODEC_TYPE_VIDEO) {",
"rm->current_stream= VAR_2->id;",
"if(rm_assemble_video_frame(VAR_0, VAR_1, rm, VAR_3, VAR_5, VAR_4))\nreturn -1;",
"} else if (VAR_2->codec->codec_type == CODEC_TYPE_AUDIO) {",
"if ((VAR_2->codec->codec_id == CODEC_ID_RA_288) ||\n(VAR_2->codec->codec_id == CODEC_ID_COOK) ||\n(VAR_2->codec->codec_id == CODEC_ID_ATRAC3) ||\n(VAR_2->codec->codec_id == CODEC_ID_SIPR)) {",
"int VAR_15;",
"int VAR_10 = VAR_3->sub_packet_size;",
"int VAR_11 = VAR_3->coded_framesize;",
"int VAR_12 = VAR_3->sub_packet_h;",
"int VAR_13 = VAR_3->sub_packet_cnt;",
"int VAR_14 = VAR_3->audio_framesize;",
"if (*VAR_7 & 2)\nVAR_13 = VAR_3->sub_packet_cnt = 0;",
"if (!VAR_13)\nVAR_3->audiotimestamp = *VAR_8;",
"switch(VAR_2->codec->codec_id) {",
"case CODEC_ID_RA_288:\nfor (VAR_15 = 0; VAR_15 < VAR_12/2; VAR_15++)",
"get_buffer(VAR_1, VAR_3->VAR_5.data+VAR_15*2*VAR_14+VAR_13*VAR_11, VAR_11);",
"break;",
"case CODEC_ID_ATRAC3:\ncase CODEC_ID_COOK:\nfor (VAR_15 = 0; VAR_15 < VAR_14/VAR_10; VAR_15++)",
"get_buffer(VAR_1, VAR_3->VAR_5.data+VAR_10*(VAR_12*VAR_15+((VAR_12+1)/2)*(VAR_13&1)+(VAR_13>>1)), VAR_10);",
"break;",
"}",
"if (++(VAR_3->sub_packet_cnt) < VAR_12)\nreturn -1;",
"else {",
"VAR_3->sub_packet_cnt = 0;",
"rm->audio_stream_num = VAR_2->index;",
"rm->audio_pkt_cnt = VAR_12 * VAR_14 / VAR_2->codec->block_align - 1;",
"av_new_packet(VAR_5, VAR_2->codec->block_align);",
"memcpy(VAR_5->data, VAR_3->VAR_5.data, VAR_2->codec->block_align);",
"*VAR_8 = VAR_3->audiotimestamp;",
"*VAR_7 = 2;",
"}",
"} else if (VAR_2->codec->codec_id == CODEC_ID_AAC) {",
"int VAR_15;",
"rm->audio_stream_num = VAR_2->index;",
"VAR_3->sub_packet_cnt = (get_be16(VAR_1) & 0xf0) >> 4;",
"if (VAR_3->sub_packet_cnt) {",
"for (VAR_15 = 0; VAR_15 < VAR_3->sub_packet_cnt; VAR_15++)",
"VAR_3->sub_packet_lengths[VAR_15] = get_be16(VAR_1);",
"rm->audio_pkt_cnt = VAR_3->sub_packet_cnt - 1;",
"av_get_packet(VAR_1, VAR_5, VAR_3->sub_packet_lengths[0]);",
"*VAR_7 = 2;",
"}",
"} else {",
"av_get_packet(VAR_1, VAR_5, VAR_4);",
"rm_ac3_swap_bytes(VAR_2, VAR_5);",
"}",
"} else",
"av_get_packet(VAR_1, VAR_5, VAR_4);",
"if( (VAR_2->discard >= AVDISCARD_NONKEY && !(*VAR_7&2))\n|| VAR_2->discard >= AVDISCARD_ALL){",
"av_free_packet(VAR_5);",
"return -1;",
"}",
"VAR_5->stream_index = VAR_2->index;",
"#if 0\nif (VAR_2->codec->codec_type == CODEC_TYPE_VIDEO) {",
"if(VAR_2->codec->codec_id == CODEC_ID_RV20){",
"int VAR_6= 128*(VAR_5->data[2]&0x7F) + (VAR_5->data[3]>>1);",
"av_log(VAR_0, AV_LOG_DEBUG, \"%d %\"PRId64\" %d\\n\", *VAR_8, *VAR_8*512LL/25, VAR_6);",
"VAR_6 |= (*VAR_8&~0x3FFF);",
"if(VAR_6 - *VAR_8 > 0x2000) VAR_6 -= 0x4000;",
"if(VAR_6 - *VAR_8 < -0x2000) VAR_6 += 0x4000;",
"}",
"}",
"#endif\nVAR_5->pts= *VAR_8;",
"if (*VAR_7 & 2)\nVAR_5->VAR_7 |= PKT_FLAG_KEY;",
"return VAR_2->codec->codec_type == CODEC_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49,
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179,
183
],
[
185,
187
],
[
191
],
[
193
]
] |
19,037 | static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
int c, line, pixels, code;
const uint8_t *ssrc = src;
int width = ((s->width * s->bpp) + 7) >> 3;
#if CONFIG_ZLIB
uint8_t *zbuf; unsigned long outlen;
if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){
int ret;
outlen = width * lines;
zbuf = av_malloc(outlen);
ret = tiff_uncompress(zbuf, &outlen, src, size);
if(ret != Z_OK){
av_log(s->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)width * lines, ret);
av_free(zbuf);
return -1;
}
src = zbuf;
for(line = 0; line < lines; line++){
memcpy(dst, src, width);
dst += stride;
src += width;
}
av_free(zbuf);
return 0;
}
#endif
if(s->compr == TIFF_LZW){
if(ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0){
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
return -1;
}
}
if(s->compr == TIFF_CCITT_RLE || s->compr == TIFF_G3 || s->compr == TIFF_G4){
int i, ret = 0;
uint8_t *src2 = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if(!src2 || (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE < (unsigned)size){
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return -1;
}
if(s->fax_opts & 2){
av_log(s->avctx, AV_LOG_ERROR, "Uncompressed fax mode is not supported (yet)\n");
av_free(src2);
return -1;
}
if(!s->fill_order){
memcpy(src2, src, size);
}else{
for(i = 0; i < size; i++)
src2[i] = av_reverse[src[i]];
}
memset(src2+size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
switch(s->compr){
case TIFF_CCITT_RLE:
case TIFF_G3:
case TIFF_G4:
ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts);
break;
}
av_free(src2);
return ret;
}
for(line = 0; line < lines; line++){
if(src - ssrc > size){
av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
return -1;
}
switch(s->compr){
case TIFF_RAW:
if (ssrc + size - src < width)
return AVERROR_INVALIDDATA;
if (!s->fill_order) {
memcpy(dst, src, width);
} else {
int i;
for (i = 0; i < width; i++)
dst[i] = av_reverse[src[i]];
}
src += width;
break;
case TIFF_PACKBITS:
for(pixels = 0; pixels < width;){
code = (int8_t)*src++;
if(code >= 0){
code++;
if(pixels + code > width){
av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n");
return -1;
}
memcpy(dst + pixels, src, code);
src += code;
pixels += code;
}else if(code != -128){ // -127..-1
code = (-code) + 1;
if(pixels + code > width){
av_log(s->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
c = *src++;
memset(dst + pixels, c, code);
pixels += code;
}
}
break;
case TIFF_LZW:
pixels = ff_lzw_decode(s->lzw, dst, width);
if(pixels < width){
av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width);
return -1;
}
break;
}
dst += stride;
}
return 0;
}
| false | FFmpeg | 90a43060077dbbca7ef161a584e95cbc7466264d | static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
int c, line, pixels, code;
const uint8_t *ssrc = src;
int width = ((s->width * s->bpp) + 7) >> 3;
#if CONFIG_ZLIB
uint8_t *zbuf; unsigned long outlen;
if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){
int ret;
outlen = width * lines;
zbuf = av_malloc(outlen);
ret = tiff_uncompress(zbuf, &outlen, src, size);
if(ret != Z_OK){
av_log(s->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)width * lines, ret);
av_free(zbuf);
return -1;
}
src = zbuf;
for(line = 0; line < lines; line++){
memcpy(dst, src, width);
dst += stride;
src += width;
}
av_free(zbuf);
return 0;
}
#endif
if(s->compr == TIFF_LZW){
if(ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0){
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
return -1;
}
}
if(s->compr == TIFF_CCITT_RLE || s->compr == TIFF_G3 || s->compr == TIFF_G4){
int i, ret = 0;
uint8_t *src2 = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
if(!src2 || (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE < (unsigned)size){
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return -1;
}
if(s->fax_opts & 2){
av_log(s->avctx, AV_LOG_ERROR, "Uncompressed fax mode is not supported (yet)\n");
av_free(src2);
return -1;
}
if(!s->fill_order){
memcpy(src2, src, size);
}else{
for(i = 0; i < size; i++)
src2[i] = av_reverse[src[i]];
}
memset(src2+size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
switch(s->compr){
case TIFF_CCITT_RLE:
case TIFF_G3:
case TIFF_G4:
ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts);
break;
}
av_free(src2);
return ret;
}
for(line = 0; line < lines; line++){
if(src - ssrc > size){
av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
return -1;
}
switch(s->compr){
case TIFF_RAW:
if (ssrc + size - src < width)
return AVERROR_INVALIDDATA;
if (!s->fill_order) {
memcpy(dst, src, width);
} else {
int i;
for (i = 0; i < width; i++)
dst[i] = av_reverse[src[i]];
}
src += width;
break;
case TIFF_PACKBITS:
for(pixels = 0; pixels < width;){
code = (int8_t)*src++;
if(code >= 0){
code++;
if(pixels + code > width){
av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n");
return -1;
}
memcpy(dst + pixels, src, code);
src += code;
pixels += code;
}else if(code != -128){
code = (-code) + 1;
if(pixels + code > width){
av_log(s->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
c = *src++;
memset(dst + pixels, c, code);
pixels += code;
}
}
break;
case TIFF_LZW:
pixels = ff_lzw_decode(s->lzw, dst, width);
if(pixels < width){
av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width);
return -1;
}
break;
}
dst += stride;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(TiffContext *VAR_0, uint8_t* VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4, int VAR_5){
int VAR_6, VAR_7, VAR_8, VAR_9;
const uint8_t *VAR_10 = VAR_3;
int VAR_11 = ((VAR_0->VAR_11 * VAR_0->bpp) + 7) >> 3;
#if CONFIG_ZLIB
uint8_t *zbuf; unsigned long outlen;
if(VAR_0->compr == TIFF_DEFLATE || VAR_0->compr == TIFF_ADOBE_DEFLATE){
int VAR_13;
outlen = VAR_11 * VAR_5;
zbuf = av_malloc(outlen);
VAR_13 = tiff_uncompress(zbuf, &outlen, VAR_3, VAR_4);
if(VAR_13 != Z_OK){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)VAR_11 * VAR_5, VAR_13);
av_free(zbuf);
return -1;
}
VAR_3 = zbuf;
for(VAR_7 = 0; VAR_7 < VAR_5; VAR_7++){
memcpy(VAR_1, VAR_3, VAR_11);
VAR_1 += VAR_2;
VAR_3 += VAR_11;
}
av_free(zbuf);
return 0;
}
#endif
if(VAR_0->compr == TIFF_LZW){
if(ff_lzw_decode_init(VAR_0->lzw, 8, VAR_3, VAR_4, FF_LZW_TIFF) < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
return -1;
}
}
if(VAR_0->compr == TIFF_CCITT_RLE || VAR_0->compr == TIFF_G3 || VAR_0->compr == TIFF_G4){
int VAR_14, VAR_13 = 0;
uint8_t *src2 = av_malloc(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);
if(!src2 || (unsigned)VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE < (unsigned)VAR_4){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return -1;
}
if(VAR_0->fax_opts & 2){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Uncompressed fax mode is not supported (yet)\n");
av_free(src2);
return -1;
}
if(!VAR_0->fill_order){
memcpy(src2, VAR_3, VAR_4);
}else{
for(VAR_14 = 0; VAR_14 < VAR_4; VAR_14++)
src2[VAR_14] = av_reverse[VAR_3[VAR_14]];
}
memset(src2+VAR_4, 0, FF_INPUT_BUFFER_PADDING_SIZE);
switch(VAR_0->compr){
case TIFF_CCITT_RLE:
case TIFF_G3:
case TIFF_G4:
VAR_13 = ff_ccitt_unpack(VAR_0->avctx, src2, VAR_4, VAR_1, VAR_5, VAR_2, VAR_0->compr, VAR_0->fax_opts);
break;
}
av_free(src2);
return VAR_13;
}
for(VAR_7 = 0; VAR_7 < VAR_5; VAR_7++){
if(VAR_3 - VAR_10 > VAR_4){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Source data overread\n");
return -1;
}
switch(VAR_0->compr){
case TIFF_RAW:
if (VAR_10 + VAR_4 - VAR_3 < VAR_11)
return AVERROR_INVALIDDATA;
if (!VAR_0->fill_order) {
memcpy(VAR_1, VAR_3, VAR_11);
} else {
int VAR_14;
for (VAR_14 = 0; VAR_14 < VAR_11; VAR_14++)
VAR_1[VAR_14] = av_reverse[VAR_3[VAR_14]];
}
VAR_3 += VAR_11;
break;
case TIFF_PACKBITS:
for(VAR_8 = 0; VAR_8 < VAR_11;){
VAR_9 = (int8_t)*VAR_3++;
if(VAR_9 >= 0){
VAR_9++;
if(VAR_8 + VAR_9 > VAR_11){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Copy went out of bounds\n");
return -1;
}
memcpy(VAR_1 + VAR_8, VAR_3, VAR_9);
VAR_3 += VAR_9;
VAR_8 += VAR_9;
}else if(VAR_9 != -128){
VAR_9 = (-VAR_9) + 1;
if(VAR_8 + VAR_9 > VAR_11){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
VAR_6 = *VAR_3++;
memset(VAR_1 + VAR_8, VAR_6, VAR_9);
VAR_8 += VAR_9;
}
}
break;
case TIFF_LZW:
VAR_8 = ff_lzw_decode(VAR_0->lzw, VAR_1, VAR_11);
if(VAR_8 < VAR_11){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Decoded only %VAR_14 bytes of %VAR_14\n", VAR_8, VAR_11);
return -1;
}
break;
}
VAR_1 += VAR_2;
}
return 0;
}
| [
"static int FUNC_0(TiffContext *VAR_0, uint8_t* VAR_1, int VAR_2, const uint8_t *VAR_3, int VAR_4, int VAR_5){",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"const uint8_t *VAR_10 = VAR_3;",
"int VAR_11 = ((VAR_0->VAR_11 * VAR_0->bpp) + 7) >> 3;",
"#if CONFIG_ZLIB\nuint8_t *zbuf; unsigned long outlen;",
"if(VAR_0->compr == TIFF_DEFLATE || VAR_0->compr == TIFF_ADOBE_DEFLATE){",
"int VAR_13;",
"outlen = VAR_11 * VAR_5;",
"zbuf = av_malloc(outlen);",
"VAR_13 = tiff_uncompress(zbuf, &outlen, VAR_3, VAR_4);",
"if(VAR_13 != Z_OK){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Uncompressing failed (%lu of %lu) with error %d\\n\", outlen, (unsigned long)VAR_11 * VAR_5, VAR_13);",
"av_free(zbuf);",
"return -1;",
"}",
"VAR_3 = zbuf;",
"for(VAR_7 = 0; VAR_7 < VAR_5; VAR_7++){",
"memcpy(VAR_1, VAR_3, VAR_11);",
"VAR_1 += VAR_2;",
"VAR_3 += VAR_11;",
"}",
"av_free(zbuf);",
"return 0;",
"}",
"#endif\nif(VAR_0->compr == TIFF_LZW){",
"if(ff_lzw_decode_init(VAR_0->lzw, 8, VAR_3, VAR_4, FF_LZW_TIFF) < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error initializing LZW decoder\\n\");",
"return -1;",
"}",
"}",
"if(VAR_0->compr == TIFF_CCITT_RLE || VAR_0->compr == TIFF_G3 || VAR_0->compr == TIFF_G4){",
"int VAR_14, VAR_13 = 0;",
"uint8_t *src2 = av_malloc(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if(!src2 || (unsigned)VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE < (unsigned)VAR_4){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");",
"return -1;",
"}",
"if(VAR_0->fax_opts & 2){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Uncompressed fax mode is not supported (yet)\\n\");",
"av_free(src2);",
"return -1;",
"}",
"if(!VAR_0->fill_order){",
"memcpy(src2, VAR_3, VAR_4);",
"}else{",
"for(VAR_14 = 0; VAR_14 < VAR_4; VAR_14++)",
"src2[VAR_14] = av_reverse[VAR_3[VAR_14]];",
"}",
"memset(src2+VAR_4, 0, FF_INPUT_BUFFER_PADDING_SIZE);",
"switch(VAR_0->compr){",
"case TIFF_CCITT_RLE:\ncase TIFF_G3:\ncase TIFF_G4:\nVAR_13 = ff_ccitt_unpack(VAR_0->avctx, src2, VAR_4, VAR_1, VAR_5, VAR_2, VAR_0->compr, VAR_0->fax_opts);",
"break;",
"}",
"av_free(src2);",
"return VAR_13;",
"}",
"for(VAR_7 = 0; VAR_7 < VAR_5; VAR_7++){",
"if(VAR_3 - VAR_10 > VAR_4){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Source data overread\\n\");",
"return -1;",
"}",
"switch(VAR_0->compr){",
"case TIFF_RAW:\nif (VAR_10 + VAR_4 - VAR_3 < VAR_11)\nreturn AVERROR_INVALIDDATA;",
"if (!VAR_0->fill_order) {",
"memcpy(VAR_1, VAR_3, VAR_11);",
"} else {",
"int VAR_14;",
"for (VAR_14 = 0; VAR_14 < VAR_11; VAR_14++)",
"VAR_1[VAR_14] = av_reverse[VAR_3[VAR_14]];",
"}",
"VAR_3 += VAR_11;",
"break;",
"case TIFF_PACKBITS:\nfor(VAR_8 = 0; VAR_8 < VAR_11;){",
"VAR_9 = (int8_t)*VAR_3++;",
"if(VAR_9 >= 0){",
"VAR_9++;",
"if(VAR_8 + VAR_9 > VAR_11){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Copy went out of bounds\\n\");",
"return -1;",
"}",
"memcpy(VAR_1 + VAR_8, VAR_3, VAR_9);",
"VAR_3 += VAR_9;",
"VAR_8 += VAR_9;",
"}else if(VAR_9 != -128){",
"VAR_9 = (-VAR_9) + 1;",
"if(VAR_8 + VAR_9 > VAR_11){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return -1;",
"}",
"VAR_6 = *VAR_3++;",
"memset(VAR_1 + VAR_8, VAR_6, VAR_9);",
"VAR_8 += VAR_9;",
"}",
"}",
"break;",
"case TIFF_LZW:\nVAR_8 = ff_lzw_decode(VAR_0->lzw, VAR_1, VAR_11);",
"if(VAR_8 < VAR_11){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Decoded only %VAR_14 bytes of %VAR_14\\n\", VAR_8, VAR_11);",
"return -1;",
"}",
"break;",
"}",
"VAR_1 += VAR_2;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111,
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
]
] |
19,038 | inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, int flags, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos;
int16_t av_unused *mmx2Filter = c->chrMmx2Filter;
int av_unused canMMX2BeUsed = c->canMMX2BeUsed;
void av_unused *mmx2FilterCode= c->chrMmx2FilterCode;
if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
return;
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->hcscale_internal) {
c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (!c->hcscale_fast)
{
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale
#if ARCH_X86 && CONFIG_GPL
#if COMPILE_TEMPLATE_MMX2
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %1, %%"REG_D" \n\t" // buf1
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (mmx2FilterCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
//printf("%d %d %d\n", dstWidth, i, srcW);
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif /* COMPILE_TEMPLATE_MMX2 */
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_d", %%"REG_d" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // xalpha
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t" //xalpha += xInc&0xFFFF
"adc %3, %%"REG_d" \n\t" //xx+= xInc>>16 + carry
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
/* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC 4.0. */
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
} //if MMX2 can't be used
#endif
#else
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
#endif /* ARCH_X86 */
}
if (c->chrConvertRange)
c->chrConvertRange(dst, dstWidth);
}
| false | FFmpeg | e7a47515abbcf2c8a07c280ea3d04129fc3aaaf6 | inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, int flags, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos;
int16_t av_unused *mmx2Filter = c->chrMmx2Filter;
int av_unused canMMX2BeUsed = c->canMMX2BeUsed;
void av_unused *mmx2FilterCode= c->chrMmx2FilterCode;
if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
return;
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->hcscale_internal) {
c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (!c->hcscale_fast)
{
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else {
#if ARCH_X86 && CONFIG_GPL
#if COMPILE_TEMPLATE_MMX2
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (mmx2FilterCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
#endif
}
if (c->chrConvertRange)
c->chrConvertRange(dst, dstWidth);
}
| {
"code": [],
"line_no": []
} | inline static void FUNC_0(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, int flags, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
int32_t VAR_1 *mmx2FilterPos = c->chrMmx2FilterPos;
int16_t VAR_1 *mmx2Filter = c->chrMmx2Filter;
int VAR_1 canMMX2BeUsed = c->canMMX2BeUsed;
void VAR_1 *mmx2FilterCode= c->chrMmx2FilterCode;
if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
return;
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->hcscale_internal) {
c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (!c->hcscale_fast)
{
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else {
#if ARCH_X86 && CONFIG_GPL
#if COMPILE_TEMPLATE_MMX2
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (mmx2Filter), "m" (mmx2FilterPos),
"m" (mmx2FilterCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t"
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t"
"movzbl 1(%5, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
#endif
}
if (c->chrConvertRange)
c->chrConvertRange(dst, dstWidth);
}
| [
"inline static void FUNC_0(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,\nint srcW, int xInc, int flags, const int16_t *hChrFilter,\nconst int16_t *hChrFilterPos, int hChrFilterSize,\nenum PixelFormat srcFormat, uint8_t *formatConvBuffer,\nuint32_t *pal)\n{",
"int32_t VAR_1 *mmx2FilterPos = c->chrMmx2FilterPos;",
"int16_t VAR_1 *mmx2Filter = c->chrMmx2Filter;",
"int VAR_1 canMMX2BeUsed = c->canMMX2BeUsed;",
"void VAR_1 *mmx2FilterCode= c->chrMmx2FilterCode;",
"if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)\nreturn;",
"src1 += c->chrSrcOffset;",
"src2 += c->chrSrcOffset;",
"if (c->hcscale_internal) {",
"c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);",
"src1= formatConvBuffer;",
"src2= formatConvBuffer+VOFW;",
"}",
"if (!c->hcscale_fast)\n{",
"c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);",
"} else {",
"#if ARCH_X86 && CONFIG_GPL\n#if COMPILE_TEMPLATE_MMX2\nint i;",
"#if defined(PIC)\nDECLARE_ALIGNED(8, uint64_t, ebxsave);",
"#endif\nif (canMMX2BeUsed) {",
"__asm__ volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %6 \\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"mov %5, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"add $\"AV_STRINGIFY(VOF)\", %%\"REG_D\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n#if defined(PIC)\n\"mov %6, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src1), \"m\" (dst), \"m\" (mmx2Filter), \"m\" (mmx2FilterPos),\n\"m\" (mmx2FilterCode), \"m\" (src2)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);",
"for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {",
"dst[i] = src1[srcW-1]*128;",
"dst[i+VOFW] = src2[srcW-1]*128;",
"}",
"} else {",
"#endif\nx86_reg xInc_shr16 = (x86_reg) (xInc >> 16);",
"uint16_t xInc_mask = xInc & 0xffff;",
"__asm__ volatile(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"xor %%\"REG_d\", %%\"REG_d\" \\n\\t\"\n\"xorl %%ecx, %%ecx \\n\\t\"\nASMALIGN(4)\n\"1: \\n\\t\"\n\"mov %0, %%\"REG_S\" \\n\\t\"\n\"movzbl (%%\"REG_S\", %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%%\"REG_S\", %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"movzbl (%5, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%5, %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, \"AV_STRINGIFY(VOF)\"(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"add $1, %%\"REG_a\" \\n\\t\"\n\"cmp %2, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)\n:: \"m\" (src1), \"m\" (dst), \"g\" (dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" (dstWidth), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#endif\n\"r\" (src2)\n: \"%\"REG_a, \"%\"REG_d, \"%ecx\", \"%\"REG_D, \"%esi\"\n);",
"#if COMPILE_TEMPLATE_MMX2\n}",
"#endif\n#else\nc->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);",
"#endif\n}",
"if (c->chrConvertRange)\nc->chrConvertRange(dst, dstWidth);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
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,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
119,
123,
125,
127,
129,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177,
179,
181,
183,
185,
187,
189,
191,
193,
195,
197,
201,
203,
205,
207,
211,
213,
215,
217,
219,
227,
229,
231,
233,
235,
237,
239,
241
],
[
243,
245
],
[
247,
249,
251
],
[
253,
255
],
[
259,
261
],
[
263
]
] |
19,039 | static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
int ret;
MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));
cb_data->mon = mon;
cb_data->user_print = cmd->user_print;
monitor_suspend(mon);
ret = cmd->mhandler.cmd_async(mon, params,
user_monitor_complete, cb_data);
if (ret < 0) {
monitor_resume(mon);
g_free(cb_data);
}
}
| true | qemu | 65207c59d99f2260c5f1d3b9c491146616a522aa | static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
const QDict *params)
{
int ret;
MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));
cb_data->mon = mon;
cb_data->user_print = cmd->user_print;
monitor_suspend(mon);
ret = cmd->mhandler.cmd_async(mon, params,
user_monitor_complete, cb_data);
if (ret < 0) {
monitor_resume(mon);
g_free(cb_data);
}
}
| {
"code": [
"static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,",
" const QDict *params)",
" int ret;",
" MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));",
" cb_data->mon = mon;",
" cb_data->user_print = cmd->user_print;",
" monitor_suspend(mon);",
" ret = cmd->mhandler.cmd_async(mon, params,",
" user_monitor_complete, cb_data);",
" if (ret < 0) {",
" monitor_resume(mon);",
" g_free(cb_data);"
],
"line_no": [
1,
3,
7,
11,
13,
15,
17,
19,
21,
23,
25,
27
]
} | static void FUNC_0(Monitor *VAR_0, const mon_cmd_t *VAR_1,
const QDict *VAR_2)
{
int VAR_3;
MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));
cb_data->VAR_0 = VAR_0;
cb_data->user_print = VAR_1->user_print;
monitor_suspend(VAR_0);
VAR_3 = VAR_1->mhandler.cmd_async(VAR_0, VAR_2,
user_monitor_complete, cb_data);
if (VAR_3 < 0) {
monitor_resume(VAR_0);
g_free(cb_data);
}
}
| [
"static void FUNC_0(Monitor *VAR_0, const mon_cmd_t *VAR_1,\nconst QDict *VAR_2)\n{",
"int VAR_3;",
"MonitorCompletionData *cb_data = g_malloc(sizeof(*cb_data));",
"cb_data->VAR_0 = VAR_0;",
"cb_data->user_print = VAR_1->user_print;",
"monitor_suspend(VAR_0);",
"VAR_3 = VAR_1->mhandler.cmd_async(VAR_0, VAR_2,\nuser_monitor_complete, cb_data);",
"if (VAR_3 < 0) {",
"monitor_resume(VAR_0);",
"g_free(cb_data);",
"}",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
19,040 | static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
{
uint8_t *buf1;
RMMuxContext *rm = s->priv_data;
AVIOContext *pb = s->pb;
StreamInfo *stream = rm->audio_stream;
int i;
/* XXX: suppress this malloc */
buf1 = av_malloc(size * sizeof(uint8_t));
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
if (stream->enc->codec_id == AV_CODEC_ID_AC3) {
/* for AC-3, the words seem to be reversed */
for(i=0;i<size;i+=2) {
buf1[i] = buf[i+1];
buf1[i+1] = buf[i];
}
avio_write(pb, buf1, size);
} else {
avio_write(pb, buf, size);
}
stream->nb_frames++;
av_free(buf1);
return 0;
} | true | FFmpeg | 56838103020385020469d1da076f0e4a6cbe15e5 | static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
{
uint8_t *buf1;
RMMuxContext *rm = s->priv_data;
AVIOContext *pb = s->pb;
StreamInfo *stream = rm->audio_stream;
int i;
buf1 = av_malloc(size * sizeof(uint8_t));
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
if (stream->enc->codec_id == AV_CODEC_ID_AC3) {
for(i=0;i<size;i+=2) {
buf1[i] = buf[i+1];
buf1[i+1] = buf[i];
}
avio_write(pb, buf1, size);
} else {
avio_write(pb, buf, size);
}
stream->nb_frames++;
av_free(buf1);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2, int VAR_3)
{
uint8_t *buf1;
RMMuxContext *rm = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
StreamInfo *stream = rm->audio_stream;
int VAR_4;
buf1 = av_malloc(VAR_2 * sizeof(uint8_t));
write_packet_header(VAR_0, stream, VAR_2, !!(VAR_3 & AV_PKT_FLAG_KEY));
if (stream->enc->codec_id == AV_CODEC_ID_AC3) {
for(VAR_4=0;VAR_4<VAR_2;VAR_4+=2) {
buf1[VAR_4] = VAR_1[VAR_4+1];
buf1[VAR_4+1] = VAR_1[VAR_4];
}
avio_write(pb, buf1, VAR_2);
} else {
avio_write(pb, VAR_1, VAR_2);
}
stream->nb_frames++;
av_free(buf1);
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2, int VAR_3)\n{",
"uint8_t *buf1;",
"RMMuxContext *rm = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"StreamInfo *stream = rm->audio_stream;",
"int VAR_4;",
"buf1 = av_malloc(VAR_2 * sizeof(uint8_t));",
"write_packet_header(VAR_0, stream, VAR_2, !!(VAR_3 & AV_PKT_FLAG_KEY));",
"if (stream->enc->codec_id == AV_CODEC_ID_AC3) {",
"for(VAR_4=0;VAR_4<VAR_2;VAR_4+=2) {",
"buf1[VAR_4] = VAR_1[VAR_4+1];",
"buf1[VAR_4+1] = VAR_1[VAR_4];",
"}",
"avio_write(pb, buf1, VAR_2);",
"} else {",
"avio_write(pb, VAR_1, VAR_2);",
"}",
"stream->nb_frames++;",
"av_free(buf1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
19,042 | static int lag_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
LagarithContext *l = avctx->priv_data;
ThreadFrame frame = { .f = data };
AVFrame *const p = data;
uint8_t frametype = 0;
uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
uint32_t offs[4];
uint8_t *srcs[4], *dst;
int i, j, planes = 3;
p->key_frame = 1;
frametype = buf[0];
offset_gu = AV_RL32(buf + 1);
offset_bv = AV_RL32(buf + 5);
switch (frametype) {
case FRAME_SOLID_RGBA:
avctx->pix_fmt = AV_PIX_FMT_RGB32;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
dst = p->data[0];
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++)
AV_WN32(dst + i * 4, offset_gu);
dst += p->linesize[0];
}
break;
case FRAME_ARITH_RGBA:
avctx->pix_fmt = AV_PIX_FMT_RGB32;
planes = 4;
offset_ry += 4;
offs[3] = AV_RL32(buf + 9);
case FRAME_ARITH_RGB24:
case FRAME_U_RGB24:
if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24)
avctx->pix_fmt = AV_PIX_FMT_RGB24;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
offs[0] = offset_bv;
offs[1] = offset_gu;
offs[2] = offset_ry;
if (!l->rgb_planes) {
l->rgb_stride = FFALIGN(avctx->width, 16);
l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1);
if (!l->rgb_planes) {
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
}
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size ||
(planes == 4 && offs[3] >= buf_size)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < planes; i++)
lag_decode_arith_plane(l, srcs[i],
avctx->width, avctx->height,
-l->rgb_stride, buf + offs[i],
buf_size - offs[i]);
dst = p->data[0];
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height;
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++) {
uint8_t r, g, b, a;
r = srcs[0][i];
g = srcs[1][i];
b = srcs[2][i];
r += g;
b += g;
if (frametype == FRAME_ARITH_RGBA) {
a = srcs[3][i];
AV_WN32(dst + i * 4, MKBETAG(a, r, g, b));
} else {
dst[i * 3 + 0] = r;
dst[i * 3 + 1] = g;
dst[i * 3 + 2] = b;
}
}
dst += p->linesize[0];
for (i = 0; i < planes; i++)
srcs[i] += l->rgb_stride;
}
break;
case FRAME_ARITH_YUY2:
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
p->linesize[0], buf + offset_ry,
buf_size - offset_ry);
lag_decode_arith_plane(l, p->data[1], avctx->width / 2,
avctx->height, p->linesize[1],
buf + offset_gu, buf_size - offset_gu);
lag_decode_arith_plane(l, p->data[2], avctx->width / 2,
avctx->height, p->linesize[2],
buf + offset_bv, buf_size - offset_bv);
break;
case FRAME_ARITH_YV12:
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
p->linesize[0], buf + offset_ry,
buf_size - offset_ry);
lag_decode_arith_plane(l, p->data[2], avctx->width / 2,
avctx->height / 2, p->linesize[2],
buf + offset_gu, buf_size - offset_gu);
lag_decode_arith_plane(l, p->data[1], avctx->width / 2,
avctx->height / 2, p->linesize[1],
buf + offset_bv, buf_size - offset_bv);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported Lagarith frame type: %#x\n", frametype);
return -1;
}
*got_frame = 1;
return buf_size;
}
| true | FFmpeg | 4c3e1956ee35fdcc5ffdb28782050164b4623c0b | static int lag_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
LagarithContext *l = avctx->priv_data;
ThreadFrame frame = { .f = data };
AVFrame *const p = data;
uint8_t frametype = 0;
uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
uint32_t offs[4];
uint8_t *srcs[4], *dst;
int i, j, planes = 3;
p->key_frame = 1;
frametype = buf[0];
offset_gu = AV_RL32(buf + 1);
offset_bv = AV_RL32(buf + 5);
switch (frametype) {
case FRAME_SOLID_RGBA:
avctx->pix_fmt = AV_PIX_FMT_RGB32;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
dst = p->data[0];
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++)
AV_WN32(dst + i * 4, offset_gu);
dst += p->linesize[0];
}
break;
case FRAME_ARITH_RGBA:
avctx->pix_fmt = AV_PIX_FMT_RGB32;
planes = 4;
offset_ry += 4;
offs[3] = AV_RL32(buf + 9);
case FRAME_ARITH_RGB24:
case FRAME_U_RGB24:
if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24)
avctx->pix_fmt = AV_PIX_FMT_RGB24;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
offs[0] = offset_bv;
offs[1] = offset_gu;
offs[2] = offset_ry;
if (!l->rgb_planes) {
l->rgb_stride = FFALIGN(avctx->width, 16);
l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1);
if (!l->rgb_planes) {
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
}
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size ||
(planes == 4 && offs[3] >= buf_size)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < planes; i++)
lag_decode_arith_plane(l, srcs[i],
avctx->width, avctx->height,
-l->rgb_stride, buf + offs[i],
buf_size - offs[i]);
dst = p->data[0];
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height;
for (j = 0; j < avctx->height; j++) {
for (i = 0; i < avctx->width; i++) {
uint8_t r, g, b, a;
r = srcs[0][i];
g = srcs[1][i];
b = srcs[2][i];
r += g;
b += g;
if (frametype == FRAME_ARITH_RGBA) {
a = srcs[3][i];
AV_WN32(dst + i * 4, MKBETAG(a, r, g, b));
} else {
dst[i * 3 + 0] = r;
dst[i * 3 + 1] = g;
dst[i * 3 + 2] = b;
}
}
dst += p->linesize[0];
for (i = 0; i < planes; i++)
srcs[i] += l->rgb_stride;
}
break;
case FRAME_ARITH_YUY2:
avctx->pix_fmt = AV_PIX_FMT_YUV422P;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
p->linesize[0], buf + offset_ry,
buf_size - offset_ry);
lag_decode_arith_plane(l, p->data[1], avctx->width / 2,
avctx->height, p->linesize[1],
buf + offset_gu, buf_size - offset_gu);
lag_decode_arith_plane(l, p->data[2], avctx->width / 2,
avctx->height, p->linesize[2],
buf + offset_bv, buf_size - offset_bv);
break;
case FRAME_ARITH_YV12:
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= buf_size ||
offset_gu >= buf_size ||
offset_bv >= buf_size) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
p->linesize[0], buf + offset_ry,
buf_size - offset_ry);
lag_decode_arith_plane(l, p->data[2], avctx->width / 2,
avctx->height / 2, p->linesize[2],
buf + offset_gu, buf_size - offset_gu);
lag_decode_arith_plane(l, p->data[1], avctx->width / 2,
avctx->height / 2, p->linesize[1],
buf + offset_bv, buf_size - offset_bv);
break;
default:
av_log(avctx, AV_LOG_ERROR,
"Unsupported Lagarith frame type: %#x\n", frametype);
return -1;
}
*got_frame = 1;
return buf_size;
}
| {
"code": [
" l->rgb_stride = FFALIGN(avctx->width, 16);",
" l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1);",
" if (!l->rgb_planes) {",
" av_log(avctx, AV_LOG_ERROR, \"cannot allocate temporary buffer\\n\");",
" return AVERROR(ENOMEM);"
],
"line_no": [
115,
117,
119,
121,
123
]
} | 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;
LagarithContext *l = VAR_0->priv_data;
ThreadFrame frame = { .f = VAR_1 };
AVFrame *const p = VAR_1;
uint8_t frametype = 0;
uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
uint32_t offs[4];
uint8_t *srcs[4], *dst;
int VAR_6, VAR_7, VAR_8 = 3;
p->key_frame = 1;
frametype = VAR_4[0];
offset_gu = AV_RL32(VAR_4 + 1);
offset_bv = AV_RL32(VAR_4 + 5);
switch (frametype) {
case FRAME_SOLID_RGBA:
VAR_0->pix_fmt = AV_PIX_FMT_RGB32;
if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
dst = p->VAR_1[0];
for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {
for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6++)
AV_WN32(dst + VAR_6 * 4, offset_gu);
dst += p->linesize[0];
}
break;
case FRAME_ARITH_RGBA:
VAR_0->pix_fmt = AV_PIX_FMT_RGB32;
VAR_8 = 4;
offset_ry += 4;
offs[3] = AV_RL32(VAR_4 + 9);
case FRAME_ARITH_RGB24:
case FRAME_U_RGB24:
if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24)
VAR_0->pix_fmt = AV_PIX_FMT_RGB24;
if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
offs[0] = offset_bv;
offs[1] = offset_gu;
offs[2] = offset_ry;
if (!l->rgb_planes) {
l->rgb_stride = FFALIGN(VAR_0->width, 16);
l->rgb_planes = av_malloc(l->rgb_stride * VAR_0->height * VAR_8 + 1);
if (!l->rgb_planes) {
av_log(VAR_0, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
return AVERROR(ENOMEM);
}
}
for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)
srcs[VAR_6] = l->rgb_planes + (VAR_6 + 1) * l->rgb_stride * VAR_0->height - l->rgb_stride;
if (offset_ry >= VAR_5 ||
offset_gu >= VAR_5 ||
offset_bv >= VAR_5 ||
(VAR_8 == 4 && offs[3] >= VAR_5)) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)
lag_decode_arith_plane(l, srcs[VAR_6],
VAR_0->width, VAR_0->height,
-l->rgb_stride, VAR_4 + offs[VAR_6],
VAR_5 - offs[VAR_6]);
dst = p->VAR_1[0];
for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)
srcs[VAR_6] = l->rgb_planes + VAR_6 * l->rgb_stride * VAR_0->height;
for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {
for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6++) {
uint8_t r, g, b, a;
r = srcs[0][VAR_6];
g = srcs[1][VAR_6];
b = srcs[2][VAR_6];
r += g;
b += g;
if (frametype == FRAME_ARITH_RGBA) {
a = srcs[3][VAR_6];
AV_WN32(dst + VAR_6 * 4, MKBETAG(a, r, g, b));
} else {
dst[VAR_6 * 3 + 0] = r;
dst[VAR_6 * 3 + 1] = g;
dst[VAR_6 * 3 + 2] = b;
}
}
dst += p->linesize[0];
for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)
srcs[VAR_6] += l->rgb_stride;
}
break;
case FRAME_ARITH_YUY2:
VAR_0->pix_fmt = AV_PIX_FMT_YUV422P;
if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= VAR_5 ||
offset_gu >= VAR_5 ||
offset_bv >= VAR_5) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->VAR_1[0], VAR_0->width, VAR_0->height,
p->linesize[0], VAR_4 + offset_ry,
VAR_5 - offset_ry);
lag_decode_arith_plane(l, p->VAR_1[1], VAR_0->width / 2,
VAR_0->height, p->linesize[1],
VAR_4 + offset_gu, VAR_5 - offset_gu);
lag_decode_arith_plane(l, p->VAR_1[2], VAR_0->width / 2,
VAR_0->height, p->linesize[2],
VAR_4 + offset_bv, VAR_5 - offset_bv);
break;
case FRAME_ARITH_YV12:
VAR_0->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (offset_ry >= VAR_5 ||
offset_gu >= VAR_5 ||
offset_bv >= VAR_5) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
lag_decode_arith_plane(l, p->VAR_1[0], VAR_0->width, VAR_0->height,
p->linesize[0], VAR_4 + offset_ry,
VAR_5 - offset_ry);
lag_decode_arith_plane(l, p->VAR_1[2], VAR_0->width / 2,
VAR_0->height / 2, p->linesize[2],
VAR_4 + offset_gu, VAR_5 - offset_gu);
lag_decode_arith_plane(l, p->VAR_1[1], VAR_0->width / 2,
VAR_0->height / 2, p->linesize[1],
VAR_4 + offset_bv, VAR_5 - offset_bv);
break;
default:
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported Lagarith frame type: %#x\n", frametype);
return -1;
}
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"LagarithContext *l = VAR_0->priv_data;",
"ThreadFrame frame = { .f = VAR_1 };",
"AVFrame *const p = VAR_1;",
"uint8_t frametype = 0;",
"uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;",
"uint32_t offs[4];",
"uint8_t *srcs[4], *dst;",
"int VAR_6, VAR_7, VAR_8 = 3;",
"p->key_frame = 1;",
"frametype = VAR_4[0];",
"offset_gu = AV_RL32(VAR_4 + 1);",
"offset_bv = AV_RL32(VAR_4 + 5);",
"switch (frametype) {",
"case FRAME_SOLID_RGBA:\nVAR_0->pix_fmt = AV_PIX_FMT_RGB32;",
"if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"dst = p->VAR_1[0];",
"for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6++)",
"AV_WN32(dst + VAR_6 * 4, offset_gu);",
"dst += p->linesize[0];",
"}",
"break;",
"case FRAME_ARITH_RGBA:\nVAR_0->pix_fmt = AV_PIX_FMT_RGB32;",
"VAR_8 = 4;",
"offset_ry += 4;",
"offs[3] = AV_RL32(VAR_4 + 9);",
"case FRAME_ARITH_RGB24:\ncase FRAME_U_RGB24:\nif (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24)\nVAR_0->pix_fmt = AV_PIX_FMT_RGB24;",
"if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"offs[0] = offset_bv;",
"offs[1] = offset_gu;",
"offs[2] = offset_ry;",
"if (!l->rgb_planes) {",
"l->rgb_stride = FFALIGN(VAR_0->width, 16);",
"l->rgb_planes = av_malloc(l->rgb_stride * VAR_0->height * VAR_8 + 1);",
"if (!l->rgb_planes) {",
"av_log(VAR_0, AV_LOG_ERROR, \"cannot allocate temporary buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)",
"srcs[VAR_6] = l->rgb_planes + (VAR_6 + 1) * l->rgb_stride * VAR_0->height - l->rgb_stride;",
"if (offset_ry >= VAR_5 ||\noffset_gu >= VAR_5 ||\noffset_bv >= VAR_5 ||\n(VAR_8 == 4 && offs[3] >= VAR_5)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid frame offsets\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)",
"lag_decode_arith_plane(l, srcs[VAR_6],\nVAR_0->width, VAR_0->height,\n-l->rgb_stride, VAR_4 + offs[VAR_6],\nVAR_5 - offs[VAR_6]);",
"dst = p->VAR_1[0];",
"for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)",
"srcs[VAR_6] = l->rgb_planes + VAR_6 * l->rgb_stride * VAR_0->height;",
"for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6++) {",
"uint8_t r, g, b, a;",
"r = srcs[0][VAR_6];",
"g = srcs[1][VAR_6];",
"b = srcs[2][VAR_6];",
"r += g;",
"b += g;",
"if (frametype == FRAME_ARITH_RGBA) {",
"a = srcs[3][VAR_6];",
"AV_WN32(dst + VAR_6 * 4, MKBETAG(a, r, g, b));",
"} else {",
"dst[VAR_6 * 3 + 0] = r;",
"dst[VAR_6 * 3 + 1] = g;",
"dst[VAR_6 * 3 + 2] = b;",
"}",
"}",
"dst += p->linesize[0];",
"for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++)",
"srcs[VAR_6] += l->rgb_stride;",
"}",
"break;",
"case FRAME_ARITH_YUY2:\nVAR_0->pix_fmt = AV_PIX_FMT_YUV422P;",
"if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"if (offset_ry >= VAR_5 ||\noffset_gu >= VAR_5 ||\noffset_bv >= VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid frame offsets\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"lag_decode_arith_plane(l, p->VAR_1[0], VAR_0->width, VAR_0->height,\np->linesize[0], VAR_4 + offset_ry,\nVAR_5 - offset_ry);",
"lag_decode_arith_plane(l, p->VAR_1[1], VAR_0->width / 2,\nVAR_0->height, p->linesize[1],\nVAR_4 + offset_gu, VAR_5 - offset_gu);",
"lag_decode_arith_plane(l, p->VAR_1[2], VAR_0->width / 2,\nVAR_0->height, p->linesize[2],\nVAR_4 + offset_bv, VAR_5 - offset_bv);",
"break;",
"case FRAME_ARITH_YV12:\nVAR_0->pix_fmt = AV_PIX_FMT_YUV420P;",
"if (ff_thread_get_buffer(VAR_0, &frame, 0) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"if (offset_ry >= VAR_5 ||\noffset_gu >= VAR_5 ||\noffset_bv >= VAR_5) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid frame offsets\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"lag_decode_arith_plane(l, p->VAR_1[0], VAR_0->width, VAR_0->height,\np->linesize[0], VAR_4 + offset_ry,\nVAR_5 - offset_ry);",
"lag_decode_arith_plane(l, p->VAR_1[2], VAR_0->width / 2,\nVAR_0->height / 2, p->linesize[2],\nVAR_4 + offset_gu, VAR_5 - offset_gu);",
"lag_decode_arith_plane(l, p->VAR_1[1], VAR_0->width / 2,\nVAR_0->height / 2, p->linesize[1],\nVAR_4 + offset_bv, VAR_5 - offset_bv);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported Lagarith frame type: %#x\\n\", frametype);",
"return -1;",
"}",
"*VAR_2 = 1;",
"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,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85,
87,
89,
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135,
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151,
153,
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
225,
227,
229
],
[
231,
233
],
[
235
],
[
237
],
[
241,
243,
245
],
[
247,
249,
251
],
[
253,
255,
257
],
[
259
],
[
261,
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277,
279,
281
],
[
283,
285
],
[
287
],
[
289
],
[
293,
295,
297
],
[
299,
301,
303
],
[
305,
307,
309
],
[
311
],
[
313,
315,
317
],
[
319
],
[
321
],
[
325
],
[
329
],
[
331
]
] |
19,043 | void do_divdo (void)
{
if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) ||
(int64_t)T1 == 0))) {
xer_ov = 0;
T0 = (int64_t)T0 / (int64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = (-1ULL) * ((uint64_t)T0 >> 63);
}
}
| true | qemu | 966439a67830239a6c520c5df6c55627b8153c8b | void do_divdo (void)
{
if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) ||
(int64_t)T1 == 0))) {
xer_ov = 0;
T0 = (int64_t)T0 / (int64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = (-1ULL) * ((uint64_t)T0 >> 63);
}
}
| {
"code": [
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;",
" xer_so = 1;"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15
]
} | void FUNC_0 (void)
{
if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) ||
(int64_t)T1 == 0))) {
xer_ov = 0;
T0 = (int64_t)T0 / (int64_t)T1;
} else {
xer_so = 1;
xer_ov = 1;
T0 = (-1ULL) * ((uint64_t)T0 >> 63);
}
}
| [
"void FUNC_0 (void)\n{",
"if (likely(!(((int64_t)T0 == INT64_MIN && (int64_t)T1 == -1ULL) ||\n(int64_t)T1 == 0))) {",
"xer_ov = 0;",
"T0 = (int64_t)T0 / (int64_t)T1;",
"} else {",
"xer_so = 1;",
"xer_ov = 1;",
"T0 = (-1ULL) * ((uint64_t)T0 >> 63);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,044 | void framebuffer_update_display(
DisplaySurface *ds,
MemoryRegionSection *mem_section,
int cols, /* Width in pixels. */
int rows, /* Height in pixels. */
int src_width, /* Length of source line, in bytes. */
int dest_row_pitch, /* Bytes between adjacent horizontal output pixels. */
int dest_col_pitch, /* Bytes between adjacent vertical output pixels. */
int invalidate, /* nonzero to redraw the whole image. */
drawfn fn,
void *opaque,
int *first_row, /* Input and output. */
int *last_row /* Output only */)
{
hwaddr src_len;
uint8_t *dest;
uint8_t *src;
int first, last = 0;
int dirty;
int i;
ram_addr_t addr;
MemoryRegion *mem;
i = *first_row;
*first_row = -1;
src_len = src_width * rows;
mem = mem_section->mr;
if (!mem) {
return;
}
memory_region_sync_dirty_bitmap(mem);
addr = mem_section->offset_within_region;
src = memory_region_get_ram_ptr(mem) + addr;
dest = surface_data(ds);
if (dest_col_pitch < 0) {
dest -= dest_col_pitch * (cols - 1);
}
if (dest_row_pitch < 0) {
dest -= dest_row_pitch * (rows - 1);
}
first = -1;
addr += i * src_width;
src += i * src_width;
dest += i * dest_row_pitch;
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
first = i;
last = i;
}
addr += src_width;
src += src_width;
dest += dest_row_pitch;
}
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}
| true | qemu | ba56e4cad41ea2b2fb68d18a632ebc7d4e4b1051 | void framebuffer_update_display(
DisplaySurface *ds,
MemoryRegionSection *mem_section,
int cols,
int rows,
int src_width,
int dest_row_pitch,
int dest_col_pitch,
int invalidate,
drawfn fn,
void *opaque,
int *first_row,
int *last_row )
{
hwaddr src_len;
uint8_t *dest;
uint8_t *src;
int first, last = 0;
int dirty;
int i;
ram_addr_t addr;
MemoryRegion *mem;
i = *first_row;
*first_row = -1;
src_len = src_width * rows;
mem = mem_section->mr;
if (!mem) {
return;
}
memory_region_sync_dirty_bitmap(mem);
addr = mem_section->offset_within_region;
src = memory_region_get_ram_ptr(mem) + addr;
dest = surface_data(ds);
if (dest_col_pitch < 0) {
dest -= dest_col_pitch * (cols - 1);
}
if (dest_row_pitch < 0) {
dest -= dest_row_pitch * (rows - 1);
}
first = -1;
addr += i * src_width;
src += i * src_width;
dest += i * dest_row_pitch;
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
first = i;
last = i;
}
addr += src_width;
src += src_width;
dest += dest_row_pitch;
}
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section->offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}
| {
"code": [
" src_len = src_width * rows;"
],
"line_no": [
51
]
} | void FUNC_0(
DisplaySurface *VAR_0,
MemoryRegionSection *VAR_1,
int VAR_2,
int VAR_3,
int VAR_4,
int VAR_5,
int VAR_6,
int VAR_7,
drawfn VAR_8,
void *VAR_9,
int *VAR_10,
int *VAR_11 )
{
hwaddr src_len;
uint8_t *dest;
uint8_t *src;
int VAR_12, VAR_13 = 0;
int VAR_14;
int VAR_15;
ram_addr_t addr;
MemoryRegion *mem;
VAR_15 = *VAR_10;
*VAR_10 = -1;
src_len = VAR_4 * VAR_3;
mem = VAR_1->mr;
if (!mem) {
return;
}
memory_region_sync_dirty_bitmap(mem);
addr = VAR_1->offset_within_region;
src = memory_region_get_ram_ptr(mem) + addr;
dest = surface_data(VAR_0);
if (VAR_6 < 0) {
dest -= VAR_6 * (VAR_2 - 1);
}
if (VAR_5 < 0) {
dest -= VAR_5 * (VAR_3 - 1);
}
VAR_12 = -1;
addr += VAR_15 * VAR_4;
src += VAR_15 * VAR_4;
dest += VAR_15 * VAR_5;
for (; VAR_15 < VAR_3; VAR_15++) {
VAR_14 = memory_region_get_dirty(mem, addr, VAR_4,
DIRTY_MEMORY_VGA);
if (VAR_14 || VAR_7) {
VAR_8(VAR_9, dest, src, VAR_2, VAR_6);
if (VAR_12 == -1)
VAR_12 = VAR_15;
VAR_13 = VAR_15;
}
addr += VAR_4;
src += VAR_4;
dest += VAR_5;
}
if (VAR_12 < 0) {
return;
}
memory_region_reset_dirty(mem, VAR_1->offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*VAR_10 = VAR_12;
*VAR_11 = VAR_13;
}
| [
"void FUNC_0(\nDisplaySurface *VAR_0,\nMemoryRegionSection *VAR_1,\nint VAR_2,\nint VAR_3,\nint VAR_4,\nint VAR_5,\nint VAR_6,\nint VAR_7,\ndrawfn VAR_8,\nvoid *VAR_9,\nint *VAR_10,\nint *VAR_11 )\n{",
"hwaddr src_len;",
"uint8_t *dest;",
"uint8_t *src;",
"int VAR_12, VAR_13 = 0;",
"int VAR_14;",
"int VAR_15;",
"ram_addr_t addr;",
"MemoryRegion *mem;",
"VAR_15 = *VAR_10;",
"*VAR_10 = -1;",
"src_len = VAR_4 * VAR_3;",
"mem = VAR_1->mr;",
"if (!mem) {",
"return;",
"}",
"memory_region_sync_dirty_bitmap(mem);",
"addr = VAR_1->offset_within_region;",
"src = memory_region_get_ram_ptr(mem) + addr;",
"dest = surface_data(VAR_0);",
"if (VAR_6 < 0) {",
"dest -= VAR_6 * (VAR_2 - 1);",
"}",
"if (VAR_5 < 0) {",
"dest -= VAR_5 * (VAR_3 - 1);",
"}",
"VAR_12 = -1;",
"addr += VAR_15 * VAR_4;",
"src += VAR_15 * VAR_4;",
"dest += VAR_15 * VAR_5;",
"for (; VAR_15 < VAR_3; VAR_15++) {",
"VAR_14 = memory_region_get_dirty(mem, addr, VAR_4,\nDIRTY_MEMORY_VGA);",
"if (VAR_14 || VAR_7) {",
"VAR_8(VAR_9, dest, src, VAR_2, VAR_6);",
"if (VAR_12 == -1)\nVAR_12 = VAR_15;",
"VAR_13 = VAR_15;",
"}",
"addr += VAR_4;",
"src += VAR_4;",
"dest += VAR_5;",
"}",
"if (VAR_12 < 0) {",
"return;",
"}",
"memory_region_reset_dirty(mem, VAR_1->offset_within_region, src_len,\nDIRTY_MEMORY_VGA);",
"*VAR_10 = VAR_12;",
"*VAR_11 = VAR_13;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
]
] |
19,045 | SPARCCPU *sparc64_cpu_devinit(const char *cpu_model,
const char *default_cpu_model, uint64_t prom_addr)
{
SPARCCPU *cpu;
CPUSPARCState *env;
ResetData *reset_info;
uint32_t tick_frequency = 100 * 1000000;
uint32_t stick_frequency = 100 * 1000000;
uint32_t hstick_frequency = 100 * 1000000;
if (cpu_model == NULL) {
cpu_model = default_cpu_model;
}
cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "Unable to find Sparc CPU definition\n");
exit(1);
}
env = &cpu->env;
env->tick = cpu_timer_create("tick", cpu, tick_irq,
tick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->stick = cpu_timer_create("stick", cpu, stick_irq,
stick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->hstick = cpu_timer_create("hstick", cpu, hstick_irq,
hstick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->prom_addr = prom_addr;
qemu_register_reset(main_cpu_reset, reset_info);
return cpu;
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | SPARCCPU *sparc64_cpu_devinit(const char *cpu_model,
const char *default_cpu_model, uint64_t prom_addr)
{
SPARCCPU *cpu;
CPUSPARCState *env;
ResetData *reset_info;
uint32_t tick_frequency = 100 * 1000000;
uint32_t stick_frequency = 100 * 1000000;
uint32_t hstick_frequency = 100 * 1000000;
if (cpu_model == NULL) {
cpu_model = default_cpu_model;
}
cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "Unable to find Sparc CPU definition\n");
exit(1);
}
env = &cpu->env;
env->tick = cpu_timer_create("tick", cpu, tick_irq,
tick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->stick = cpu_timer_create("stick", cpu, stick_irq,
stick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->hstick = cpu_timer_create("hstick", cpu, hstick_irq,
hstick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->prom_addr = prom_addr;
qemu_register_reset(main_cpu_reset, reset_info);
return cpu;
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" exit(1);",
" if (cpu == NULL) {",
" fprintf(stderr, \"Unable to find Sparc CPU definition\\n\");",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
35,
35,
35,
35,
35,
35,
35,
31,
35,
31,
35,
31,
35,
35,
35,
31,
35,
31,
35,
31,
35,
31,
35,
35,
31,
35,
31,
35,
35,
31,
35,
31,
35,
31,
35,
31,
35,
31,
35,
31,
33,
35,
35,
35
]
} | SPARCCPU *FUNC_0(const char *cpu_model,
const char *default_cpu_model, uint64_t prom_addr)
{
SPARCCPU *cpu;
CPUSPARCState *env;
ResetData *reset_info;
uint32_t tick_frequency = 100 * 1000000;
uint32_t stick_frequency = 100 * 1000000;
uint32_t hstick_frequency = 100 * 1000000;
if (cpu_model == NULL) {
cpu_model = default_cpu_model;
}
cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));
if (cpu == NULL) {
fprintf(stderr, "Unable to find Sparc CPU definition\n");
exit(1);
}
env = &cpu->env;
env->tick = cpu_timer_create("tick", cpu, tick_irq,
tick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->stick = cpu_timer_create("stick", cpu, stick_irq,
stick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
env->hstick = cpu_timer_create("hstick", cpu, hstick_irq,
hstick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->prom_addr = prom_addr;
qemu_register_reset(main_cpu_reset, reset_info);
return cpu;
}
| [
"SPARCCPU *FUNC_0(const char *cpu_model,\nconst char *default_cpu_model, uint64_t prom_addr)\n{",
"SPARCCPU *cpu;",
"CPUSPARCState *env;",
"ResetData *reset_info;",
"uint32_t tick_frequency = 100 * 1000000;",
"uint32_t stick_frequency = 100 * 1000000;",
"uint32_t hstick_frequency = 100 * 1000000;",
"if (cpu_model == NULL) {",
"cpu_model = default_cpu_model;",
"}",
"cpu = SPARC_CPU(cpu_generic_init(TYPE_SPARC_CPU, cpu_model));",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find Sparc CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"env->tick = cpu_timer_create(\"tick\", cpu, tick_irq,\ntick_frequency, TICK_INT_DIS,\nTICK_NPT_MASK);",
"env->stick = cpu_timer_create(\"stick\", cpu, stick_irq,\nstick_frequency, TICK_INT_DIS,\nTICK_NPT_MASK);",
"env->hstick = cpu_timer_create(\"hstick\", cpu, hstick_irq,\nhstick_frequency, TICK_INT_DIS,\nTICK_NPT_MASK);",
"reset_info = g_malloc0(sizeof(ResetData));",
"reset_info->cpu = cpu;",
"reset_info->prom_addr = prom_addr;",
"qemu_register_reset(main_cpu_reset, reset_info);",
"return cpu;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
51,
53,
55
],
[
59,
61,
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
]
] |
19,046 | int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
int l, c, code, oc, fc;
uint8_t *sp;
struct LZWState *s = (struct LZWState *)p;
if (s->end_code < 0)
return 0;
l = len;
sp = s->sp;
oc = s->oc;
fc = s->fc;
for (;;) {
while (sp > s->stack) {
*buf++ = *(--sp);
if ((--l) == 0)
goto the_end;
}
c = lzw_get_code(s);
if (c == s->end_code) {
s->end_code = -1;
break;
} else if (c == s->clear_code) {
s->cursize = s->codesize + 1;
s->curmask = mask[s->cursize];
s->slot = s->newcodes;
s->top_slot = 1 << s->cursize;
fc= oc= -1;
} else {
code = c;
if (code >= s->slot) {
*sp++ = fc;
code = oc;
}
while (code >= s->newcodes) {
*sp++ = s->suffix[code];
code = s->prefix[code];
}
*sp++ = code;
if (s->slot < s->top_slot && oc>=0) {
s->suffix[s->slot] = code;
s->prefix[s->slot++] = oc;
}
fc = code;
oc = c;
if (s->slot >= s->top_slot - s->extra_slot) {
if (s->cursize < LZW_MAXBITS) {
s->top_slot <<= 1;
s->curmask = mask[++s->cursize];
}
}
}
}
the_end:
s->sp = sp;
s->oc = oc;
s->fc = fc;
return len - l;
}
| true | FFmpeg | 0cb7f8a26094c533b7dbe25897198953b6660f15 | int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
int l, c, code, oc, fc;
uint8_t *sp;
struct LZWState *s = (struct LZWState *)p;
if (s->end_code < 0)
return 0;
l = len;
sp = s->sp;
oc = s->oc;
fc = s->fc;
for (;;) {
while (sp > s->stack) {
*buf++ = *(--sp);
if ((--l) == 0)
goto the_end;
}
c = lzw_get_code(s);
if (c == s->end_code) {
s->end_code = -1;
break;
} else if (c == s->clear_code) {
s->cursize = s->codesize + 1;
s->curmask = mask[s->cursize];
s->slot = s->newcodes;
s->top_slot = 1 << s->cursize;
fc= oc= -1;
} else {
code = c;
if (code >= s->slot) {
*sp++ = fc;
code = oc;
}
while (code >= s->newcodes) {
*sp++ = s->suffix[code];
code = s->prefix[code];
}
*sp++ = code;
if (s->slot < s->top_slot && oc>=0) {
s->suffix[s->slot] = code;
s->prefix[s->slot++] = oc;
}
fc = code;
oc = c;
if (s->slot >= s->top_slot - s->extra_slot) {
if (s->cursize < LZW_MAXBITS) {
s->top_slot <<= 1;
s->curmask = mask[++s->cursize];
}
}
}
}
the_end:
s->sp = sp;
s->oc = oc;
s->fc = fc;
return len - l;
}
| {
"code": [
" s->end_code = -1;",
" if (code >= s->slot) {"
],
"line_no": [
43,
63
]
} | int FUNC_0(LZWState *VAR_0, uint8_t *VAR_1, int VAR_2){
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
uint8_t *sp;
struct LZWState *VAR_8 = (struct LZWState *)VAR_0;
if (VAR_8->end_code < 0)
return 0;
VAR_3 = VAR_2;
sp = VAR_8->sp;
VAR_6 = VAR_8->VAR_6;
VAR_7 = VAR_8->VAR_7;
for (;;) {
while (sp > VAR_8->stack) {
*VAR_1++ = *(--sp);
if ((--VAR_3) == 0)
goto the_end;
}
VAR_4 = lzw_get_code(VAR_8);
if (VAR_4 == VAR_8->end_code) {
VAR_8->end_code = -1;
break;
} else if (VAR_4 == VAR_8->clear_code) {
VAR_8->cursize = VAR_8->codesize + 1;
VAR_8->curmask = mask[VAR_8->cursize];
VAR_8->slot = VAR_8->newcodes;
VAR_8->top_slot = 1 << VAR_8->cursize;
VAR_7= VAR_6= -1;
} else {
VAR_5 = VAR_4;
if (VAR_5 >= VAR_8->slot) {
*sp++ = VAR_7;
VAR_5 = VAR_6;
}
while (VAR_5 >= VAR_8->newcodes) {
*sp++ = VAR_8->suffix[VAR_5];
VAR_5 = VAR_8->prefix[VAR_5];
}
*sp++ = VAR_5;
if (VAR_8->slot < VAR_8->top_slot && VAR_6>=0) {
VAR_8->suffix[VAR_8->slot] = VAR_5;
VAR_8->prefix[VAR_8->slot++] = VAR_6;
}
VAR_7 = VAR_5;
VAR_6 = VAR_4;
if (VAR_8->slot >= VAR_8->top_slot - VAR_8->extra_slot) {
if (VAR_8->cursize < LZW_MAXBITS) {
VAR_8->top_slot <<= 1;
VAR_8->curmask = mask[++VAR_8->cursize];
}
}
}
}
the_end:
VAR_8->sp = sp;
VAR_8->VAR_6 = VAR_6;
VAR_8->VAR_7 = VAR_7;
return VAR_2 - VAR_3;
}
| [
"int FUNC_0(LZWState *VAR_0, uint8_t *VAR_1, int VAR_2){",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"uint8_t *sp;",
"struct LZWState *VAR_8 = (struct LZWState *)VAR_0;",
"if (VAR_8->end_code < 0)\nreturn 0;",
"VAR_3 = VAR_2;",
"sp = VAR_8->sp;",
"VAR_6 = VAR_8->VAR_6;",
"VAR_7 = VAR_8->VAR_7;",
"for (;;) {",
"while (sp > VAR_8->stack) {",
"*VAR_1++ = *(--sp);",
"if ((--VAR_3) == 0)\ngoto the_end;",
"}",
"VAR_4 = lzw_get_code(VAR_8);",
"if (VAR_4 == VAR_8->end_code) {",
"VAR_8->end_code = -1;",
"break;",
"} else if (VAR_4 == VAR_8->clear_code) {",
"VAR_8->cursize = VAR_8->codesize + 1;",
"VAR_8->curmask = mask[VAR_8->cursize];",
"VAR_8->slot = VAR_8->newcodes;",
"VAR_8->top_slot = 1 << VAR_8->cursize;",
"VAR_7= VAR_6= -1;",
"} else {",
"VAR_5 = VAR_4;",
"if (VAR_5 >= VAR_8->slot) {",
"*sp++ = VAR_7;",
"VAR_5 = VAR_6;",
"}",
"while (VAR_5 >= VAR_8->newcodes) {",
"*sp++ = VAR_8->suffix[VAR_5];",
"VAR_5 = VAR_8->prefix[VAR_5];",
"}",
"*sp++ = VAR_5;",
"if (VAR_8->slot < VAR_8->top_slot && VAR_6>=0) {",
"VAR_8->suffix[VAR_8->slot] = VAR_5;",
"VAR_8->prefix[VAR_8->slot++] = VAR_6;",
"}",
"VAR_7 = VAR_5;",
"VAR_6 = VAR_4;",
"if (VAR_8->slot >= VAR_8->top_slot - VAR_8->extra_slot) {",
"if (VAR_8->cursize < LZW_MAXBITS) {",
"VAR_8->top_slot <<= 1;",
"VAR_8->curmask = mask[++VAR_8->cursize];",
"}",
"}",
"}",
"}",
"the_end:\nVAR_8->sp = sp;",
"VAR_8->VAR_6 = VAR_6;",
"VAR_8->VAR_7 = VAR_7;",
"return VAR_2 - VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
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
]
] |
19,047 | void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src,
int srcW, int xInc)
{
int32_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *mmxextFilterCode = c->lumMmxextFilterCode;
int i;
#if ARCH_X86_64
uint64_t retsave;
#else
#if defined(PIC)
uint64_t ebxsave;
#endif
#endif
__asm__ volatile(
#if ARCH_X86_64
"mov -8(%%rsp), %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", %5 \n\t" // retsave
#else
#if defined(PIC)
"mov %%"FF_REG_b", %5 \n\t" // ebxsave
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"FF_REG_c" \n\t"
"mov %1, %%"FF_REG_D" \n\t"
"mov %2, %%"FF_REG_d" \n\t"
"mov %3, %%"FF_REG_b" \n\t"
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t" // i
PREFETCH" (%%"FF_REG_c") \n\t"
PREFETCH" 32(%%"FF_REG_c") \n\t"
PREFETCH" 64(%%"FF_REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"FF_REG_b", %%"FF_REG_a"), %%esi \n\t"\
"add %%"FF_REG_S", %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#else
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"FF_REG_b", %%"FF_REG_a"), %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#endif /* ARCH_X86_64 */
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
#if ARCH_X86_64
"mov %5, %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", -8(%%rsp) \n\t"
#else
#if defined(PIC)
"mov %5, %%"FF_REG_b" \n\t"
#endif
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmxextFilterCode)
#if ARCH_X86_64
,"m"(retsave)
#else
#if defined(PIC)
,"m" (ebxsave)
#endif
#endif
: "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_D
#if ARCH_X86_64 || !defined(PIC)
,"%"FF_REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
dst[i] = src[srcW-1]*128;
}
| true | FFmpeg | 319438e2f206036ee0cddf401dd50f3b2a3ae117 | void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src,
int srcW, int xInc)
{
int32_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
void *mmxextFilterCode = c->lumMmxextFilterCode;
int i;
#if ARCH_X86_64
uint64_t retsave;
#else
#if defined(PIC)
uint64_t ebxsave;
#endif
#endif
__asm__ volatile(
#if ARCH_X86_64
"mov -8(%%rsp), %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", %5 \n\t"
#else
#if defined(PIC)
"mov %%"FF_REG_b", %5 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"FF_REG_c" \n\t"
"mov %1, %%"FF_REG_D" \n\t"
"mov %2, %%"FF_REG_d" \n\t"
"mov %3, %%"FF_REG_b" \n\t"
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"
PREFETCH" (%%"FF_REG_c") \n\t"
PREFETCH" 32(%%"FF_REG_c") \n\t"
PREFETCH" 64(%%"FF_REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"FF_REG_b", %%"FF_REG_a"), %%esi \n\t"\
"add %%"FF_REG_S", %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#else
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"FF_REG_b", %%"FF_REG_a"), %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#endif
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
#if ARCH_X86_64
"mov %5, %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", -8(%%rsp) \n\t"
#else
#if defined(PIC)
"mov %5, %%"FF_REG_b" \n\t"
#endif
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmxextFilterCode)
#if ARCH_X86_64
,"m"(retsave)
#else
#if defined(PIC)
,"m" (ebxsave)
#endif
#endif
: "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_D
#if ARCH_X86_64 || !defined(PIC)
,"%"FF_REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
dst[i] = src[srcW-1]*128;
}
| {
"code": [
"#if defined(PIC)",
"#if defined(PIC)",
"#if defined(PIC)",
"#if defined(PIC)",
"#if ARCH_X86_64 || !defined(PIC)",
"#if defined(PIC)",
"#if defined(PIC)",
"#if defined(PIC)",
"#if defined(PIC)",
"#if ARCH_X86_64 || !defined(PIC)"
],
"line_no": [
23,
23,
23,
23,
163,
23,
23,
23,
23,
163
]
} | void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1,
int VAR_2, const uint8_t *VAR_3,
int VAR_4, int VAR_5)
{
int32_t *filterPos = VAR_0->hLumFilterPos;
int16_t *filter = VAR_0->hLumFilter;
void *VAR_6 = VAR_0->lumMmxextFilterCode;
int VAR_7;
#if ARCH_X86_64
uint64_t retsave;
#else
#if defined(PIC)
uint64_t ebxsave;
#endif
#endif
__asm__ volatile(
#if ARCH_X86_64
"mov -8(%%rsp), %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", %5 \n\t"
#else
#if defined(PIC)
"mov %%"FF_REG_b", %5 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"FF_REG_c" \n\t"
"mov %1, %%"FF_REG_D" \n\t"
"mov %2, %%"FF_REG_d" \n\t"
"mov %3, %%"FF_REG_b" \n\t"
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"
PREFETCH" (%%"FF_REG_c") \n\t"
PREFETCH" 32(%%"FF_REG_c") \n\t"
PREFETCH" 64(%%"FF_REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"FF_REG_b", %%"FF_REG_a"), %%esi \n\t"\
"add %%"FF_REG_S", %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#else
#define CALL_MMXEXT_FILTER_CODE \
"movl (%%"FF_REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"FF_REG_b", %%"FF_REG_a"), %%"FF_REG_c" \n\t"\
"add %%"FF_REG_a", %%"FF_REG_D" \n\t"\
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
#endif
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
#if ARCH_X86_64
"mov %5, %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", -8(%%rsp) \n\t"
#else
#if defined(PIC)
"mov %5, %%"FF_REG_b" \n\t"
#endif
#endif
:: "m" (VAR_3), "m" (VAR_1), "m" (filter), "m" (filterPos),
"m" (VAR_6)
#if ARCH_X86_64
,"m"(retsave)
#else
#if defined(PIC)
,"m" (ebxsave)
#endif
#endif
: "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_D
#if ARCH_X86_64 || !defined(PIC)
,"%"FF_REG_b
#endif
);
for (VAR_7=VAR_2-1; (VAR_7*VAR_5)>>16 >=VAR_4-1; VAR_7--)
VAR_1[VAR_7] = VAR_3[VAR_4-1]*128;
}
| [
"void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1,\nint VAR_2, const uint8_t *VAR_3,\nint VAR_4, int VAR_5)\n{",
"int32_t *filterPos = VAR_0->hLumFilterPos;",
"int16_t *filter = VAR_0->hLumFilter;",
"void *VAR_6 = VAR_0->lumMmxextFilterCode;",
"int VAR_7;",
"#if ARCH_X86_64\nuint64_t retsave;",
"#else\n#if defined(PIC)\nuint64_t ebxsave;",
"#endif\n#endif\n__asm__ volatile(\n#if ARCH_X86_64\n\"mov -8(%%rsp), %%\"FF_REG_a\" \\n\\t\"\n\"mov %%\"FF_REG_a\", %5 \\n\\t\"\n#else\n#if defined(PIC)\n\"mov %%\"FF_REG_b\", %5 \\n\\t\"\n#endif\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"FF_REG_c\" \\n\\t\"\n\"mov %1, %%\"FF_REG_D\" \\n\\t\"\n\"mov %2, %%\"FF_REG_d\" \\n\\t\"\n\"mov %3, %%\"FF_REG_b\" \\n\\t\"\n\"xor %%\"FF_REG_a\", %%\"FF_REG_a\" \\n\\t\"\nPREFETCH\" (%%\"FF_REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"FF_REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"FF_REG_c\") \\n\\t\"\n#if ARCH_X86_64\n#define CALL_MMXEXT_FILTER_CODE \\\n\"movl (%%\"FF_REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"movl (%%\"FF_REG_b\", %%\"FF_REG_a\"), %%esi \\n\\t\"\\\n\"add %%\"FF_REG_S\", %%\"FF_REG_c\" \\n\\t\"\\\n\"add %%\"FF_REG_a\", %%\"FF_REG_D\" \\n\\t\"\\\n\"xor %%\"FF_REG_a\", %%\"FF_REG_a\" \\n\\t\"\\\n#else\n#define CALL_MMXEXT_FILTER_CODE \\\n\"movl (%%\"FF_REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"addl (%%\"FF_REG_b\", %%\"FF_REG_a\"), %%\"FF_REG_c\" \\n\\t\"\\\n\"add %%\"FF_REG_a\", %%\"FF_REG_D\" \\n\\t\"\\\n\"xor %%\"FF_REG_a\", %%\"FF_REG_a\" \\n\\t\"\\\n#endif\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\nCALL_MMXEXT_FILTER_CODE\n#if ARCH_X86_64\n\"mov %5, %%\"FF_REG_a\" \\n\\t\"\n\"mov %%\"FF_REG_a\", -8(%%rsp) \\n\\t\"\n#else\n#if defined(PIC)\n\"mov %5, %%\"FF_REG_b\" \\n\\t\"\n#endif\n#endif\n:: \"m\" (VAR_3), \"m\" (VAR_1), \"m\" (filter), \"m\" (filterPos),\n\"m\" (VAR_6)\n#if ARCH_X86_64\n,\"m\"(retsave)\n#else\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n#endif\n: \"%\"FF_REG_a, \"%\"FF_REG_c, \"%\"FF_REG_d, \"%\"FF_REG_S, \"%\"FF_REG_D\n#if ARCH_X86_64 || !defined(PIC)\n,\"%\"FF_REG_b\n#endif\n);",
"for (VAR_7=VAR_2-1; (VAR_7*VAR_5)>>16 >=VAR_4-1; VAR_7--)",
"VAR_1[VAR_7] = VAR_3[VAR_4-1]*128;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21,
23,
25
],
[
27,
29,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
71,
73,
75,
77,
79,
81,
83,
85,
89,
91,
93,
95,
97,
99,
101,
105,
109,
111,
113,
115,
117,
119,
121,
123,
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163,
165,
167,
169
],
[
173
],
[
175
],
[
177
]
] |
19,048 | static int get_int32_equal(QEMUFile *f, void *pv, size_t size)
{
int32_t *v = pv;
int32_t v2;
qemu_get_sbe32s(f, &v2);
if (*v == v2) {
return 0;
}
return -EINVAL;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int get_int32_equal(QEMUFile *f, void *pv, size_t size)
{
int32_t *v = pv;
int32_t v2;
qemu_get_sbe32s(f, &v2);
if (*v == v2) {
return 0;
}
return -EINVAL;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
int32_t *v = VAR_1;
int32_t v2;
qemu_get_sbe32s(VAR_0, &v2);
if (*v == v2) {
return 0;
}
return -EINVAL;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"int32_t *v = VAR_1;",
"int32_t v2;",
"qemu_get_sbe32s(VAR_0, &v2);",
"if (*v == v2) {",
"return 0;",
"}",
"return -EINVAL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,049 | static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
const pixel4 a= ((pixel4*)(src-stride))[0];
((pixel4*)(src+0*stride))[0]= a;
((pixel4*)(src+1*stride))[0]= a;
((pixel4*)(src+2*stride))[0]= a;
((pixel4*)(src+3*stride))[0]= a;
}
| true | FFmpeg | 2caf19e90f270abe1e80a3e85acaf0eb5c9d0aac | static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
const pixel4 a= ((pixel4*)(src-stride))[0];
((pixel4*)(src+0*stride))[0]= a;
((pixel4*)(src+1*stride))[0]= a;
((pixel4*)(src+2*stride))[0]= a;
((pixel4*)(src+3*stride))[0]= a;
}
| {
"code": [
" const pixel4 a= ((pixel4*)(src-stride))[0];",
" ((pixel4*)(src+0*stride))[0]= a;",
" ((pixel4*)(src+1*stride))[0]= a;",
" ((pixel4*)(src+2*stride))[0]= a;",
" ((pixel4*)(src+3*stride))[0]= a;",
" const pixel4 a= ((pixel4*)(src-stride))[0];"
],
"line_no": [
7,
9,
11,
13,
15,
7
]
} | static void FUNC_0(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int VAR_0 = _stride/sizeof(pixel);
const pixel4 VAR_1= ((pixel4*)(src-VAR_0))[0];
((pixel4*)(src+0*VAR_0))[0]= VAR_1;
((pixel4*)(src+1*VAR_0))[0]= VAR_1;
((pixel4*)(src+2*VAR_0))[0]= VAR_1;
((pixel4*)(src+3*VAR_0))[0]= VAR_1;
}
| [
"static void FUNC_0(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){",
"pixel *src = (pixel*)_src;",
"int VAR_0 = _stride/sizeof(pixel);",
"const pixel4 VAR_1= ((pixel4*)(src-VAR_0))[0];",
"((pixel4*)(src+0*VAR_0))[0]= VAR_1;",
"((pixel4*)(src+1*VAR_0))[0]= VAR_1;",
"((pixel4*)(src+2*VAR_0))[0]= VAR_1;",
"((pixel4*)(src+3*VAR_0))[0]= VAR_1;",
"}"
] | [
0,
0,
0,
1,
1,
1,
1,
1,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,050 | static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
{
OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup));
if (!group) {
return NULL;
}
group->id = id;
return group;
}
| true | qemu | 778358d0a8f74a76488daea3c1b6fb327d8135b4 | static OfDpaGroup *of_dpa_group_alloc(uint32_t id)
{
OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup));
if (!group) {
return NULL;
}
group->id = id;
return group;
}
| {
"code": [
" OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup));"
],
"line_no": [
5
]
} | static OfDpaGroup *FUNC_0(uint32_t id)
{
OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup));
if (!group) {
return NULL;
}
group->id = id;
return group;
}
| [
"static OfDpaGroup *FUNC_0(uint32_t id)\n{",
"OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup));",
"if (!group) {",
"return NULL;",
"}",
"group->id = id;",
"return group;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
]
] |
19,052 | static float get_band_cost_UQUAD_mips(struct AACEncContext *s,
PutBitContext *pb, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits)
{
const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
int i;
float cost = 0;
int curbits = 0;
int qc1, qc2, qc3, qc4;
uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1];
float *p_codes = (float *)ff_aac_codebook_vectors[cb-1];
for (i = 0; i < size; i += 4) {
const float *vec;
int curidx;
float *in_pos = (float *)&in[i];
float di0, di1, di2, di3;
int t0, t1, t2, t3, t4;
qc1 = scaled[i ] * Q34 + ROUND_STANDARD;
qc2 = scaled[i+1] * Q34 + ROUND_STANDARD;
qc3 = scaled[i+2] * Q34 + ROUND_STANDARD;
qc4 = scaled[i+3] * Q34 + ROUND_STANDARD;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 2 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
);
curidx = qc1;
curidx *= 3;
curidx += qc2;
curidx *= 3;
curidx += qc3;
curidx *= 3;
curidx += qc4;
curbits += p_bits[curidx];
curbits += uquad_sign_bits[curidx];
vec = &p_codes[curidx*4];
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"lwc1 %[di0], 0(%[in_pos]) \n\t"
"lwc1 %[di1], 4(%[in_pos]) \n\t"
"lwc1 %[di2], 8(%[in_pos]) \n\t"
"lwc1 %[di3], 12(%[in_pos]) \n\t"
"abs.s %[di0], %[di0] \n\t"
"abs.s %[di1], %[di1] \n\t"
"abs.s %[di2], %[di2] \n\t"
"abs.s %[di3], %[di3] \n\t"
"lwc1 $f0, 0(%[vec]) \n\t"
"lwc1 $f1, 4(%[vec]) \n\t"
"lwc1 $f2, 8(%[vec]) \n\t"
"lwc1 $f3, 12(%[vec]) \n\t"
"nmsub.s %[di0], %[di0], $f0, %[IQ] \n\t"
"nmsub.s %[di1], %[di1], $f1, %[IQ] \n\t"
"nmsub.s %[di2], %[di2], $f2, %[IQ] \n\t"
"nmsub.s %[di3], %[di3], $f3, %[IQ] \n\t"
".set pop \n\t"
: [di0]"=&f"(di0), [di1]"=&f"(di1),
[di2]"=&f"(di2), [di3]"=&f"(di3)
: [in_pos]"r"(in_pos), [vec]"r"(vec),
[IQ]"f"(IQ)
: "$f0", "$f1", "$f2", "$f3",
"memory"
);
cost += di0 * di0 + di1 * di1
+ di2 * di2 + di3 * di3;
}
if (bits)
*bits = curbits;
return cost * lambda + curbits;
}
| true | FFmpeg | 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec | static float get_band_cost_UQUAD_mips(struct AACEncContext *s,
PutBitContext *pb, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits)
{
const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
int i;
float cost = 0;
int curbits = 0;
int qc1, qc2, qc3, qc4;
uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1];
float *p_codes = (float *)ff_aac_codebook_vectors[cb-1];
for (i = 0; i < size; i += 4) {
const float *vec;
int curidx;
float *in_pos = (float *)&in[i];
float di0, di1, di2, di3;
int t0, t1, t2, t3, t4;
qc1 = scaled[i ] * Q34 + ROUND_STANDARD;
qc2 = scaled[i+1] * Q34 + ROUND_STANDARD;
qc3 = scaled[i+2] * Q34 + ROUND_STANDARD;
qc4 = scaled[i+3] * Q34 + ROUND_STANDARD;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[t4], $zero, 2 \n\t"
"slt %[t0], %[t4], %[qc1] \n\t"
"slt %[t1], %[t4], %[qc2] \n\t"
"slt %[t2], %[t4], %[qc3] \n\t"
"slt %[t3], %[t4], %[qc4] \n\t"
"movn %[qc1], %[t4], %[t0] \n\t"
"movn %[qc2], %[t4], %[t1] \n\t"
"movn %[qc3], %[t4], %[t2] \n\t"
"movn %[qc4], %[t4], %[t3] \n\t"
".set pop \n\t"
: [qc1]"+r"(qc1), [qc2]"+r"(qc2),
[qc3]"+r"(qc3), [qc4]"+r"(qc4),
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3),
[t4]"=&r"(t4)
);
curidx = qc1;
curidx *= 3;
curidx += qc2;
curidx *= 3;
curidx += qc3;
curidx *= 3;
curidx += qc4;
curbits += p_bits[curidx];
curbits += uquad_sign_bits[curidx];
vec = &p_codes[curidx*4];
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"lwc1 %[di0], 0(%[in_pos]) \n\t"
"lwc1 %[di1], 4(%[in_pos]) \n\t"
"lwc1 %[di2], 8(%[in_pos]) \n\t"
"lwc1 %[di3], 12(%[in_pos]) \n\t"
"abs.s %[di0], %[di0] \n\t"
"abs.s %[di1], %[di1] \n\t"
"abs.s %[di2], %[di2] \n\t"
"abs.s %[di3], %[di3] \n\t"
"lwc1 $f0, 0(%[vec]) \n\t"
"lwc1 $f1, 4(%[vec]) \n\t"
"lwc1 $f2, 8(%[vec]) \n\t"
"lwc1 $f3, 12(%[vec]) \n\t"
"nmsub.s %[di0], %[di0], $f0, %[IQ] \n\t"
"nmsub.s %[di1], %[di1], $f1, %[IQ] \n\t"
"nmsub.s %[di2], %[di2], $f2, %[IQ] \n\t"
"nmsub.s %[di3], %[di3], $f3, %[IQ] \n\t"
".set pop \n\t"
: [di0]"=&f"(di0), [di1]"=&f"(di1),
[di2]"=&f"(di2), [di3]"=&f"(di3)
: [in_pos]"r"(in_pos), [vec]"r"(vec),
[IQ]"f"(IQ)
: "$f0", "$f1", "$f2", "$f3",
"memory"
);
cost += di0 * di0 + di1 * di1
+ di2 * di2 + di3 * di3;
}
if (bits)
*bits = curbits;
return cost * lambda + curbits;
}
| {
"code": [
" int *bits)",
" int *bits)",
" int *bits)"
],
"line_no": [
9,
9,
9
]
} | static float FUNC_0(struct AACEncContext *VAR_0,
PutBitContext *VAR_1, const float *VAR_2,
const float *VAR_3, int VAR_4, int VAR_5,
int VAR_6, const float VAR_7, const float VAR_8,
int *VAR_9)
{
const float VAR_10 = ff_aac_pow34sf_tab[POW_SF2_ZERO - VAR_5 + SCALE_ONE_POS - SCALE_DIV_512];
const float VAR_11 = ff_aac_pow2sf_tab [POW_SF2_ZERO + VAR_5 - SCALE_ONE_POS + SCALE_DIV_512];
int VAR_12;
float VAR_13 = 0;
int VAR_14 = 0;
int VAR_15, VAR_16, VAR_17, VAR_18;
uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[VAR_6-1];
float *VAR_19 = (float *)ff_aac_codebook_vectors[VAR_6-1];
for (VAR_12 = 0; VAR_12 < VAR_4; VAR_12 += 4) {
const float *VAR_20;
int VAR_21;
float *VAR_22 = (float *)&VAR_2[VAR_12];
float VAR_23, VAR_24, VAR_25, VAR_26;
int VAR_27, VAR_28, VAR_29, VAR_30, VAR_31;
VAR_15 = VAR_3[VAR_12 ] * VAR_10 + ROUND_STANDARD;
VAR_16 = VAR_3[VAR_12+1] * VAR_10 + ROUND_STANDARD;
VAR_17 = VAR_3[VAR_12+2] * VAR_10 + ROUND_STANDARD;
VAR_18 = VAR_3[VAR_12+3] * VAR_10 + ROUND_STANDARD;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"ori %[VAR_31], $zero, 2 \n\t"
"slt %[VAR_27], %[VAR_31], %[VAR_15] \n\t"
"slt %[VAR_28], %[VAR_31], %[VAR_16] \n\t"
"slt %[VAR_29], %[VAR_31], %[VAR_17] \n\t"
"slt %[VAR_30], %[VAR_31], %[VAR_18] \n\t"
"movn %[VAR_15], %[VAR_31], %[VAR_27] \n\t"
"movn %[VAR_16], %[VAR_31], %[VAR_28] \n\t"
"movn %[VAR_17], %[VAR_31], %[VAR_29] \n\t"
"movn %[VAR_18], %[VAR_31], %[VAR_30] \n\t"
".set pop \n\t"
: [VAR_15]"+r"(VAR_15), [VAR_16]"+r"(VAR_16),
[VAR_17]"+r"(VAR_17), [VAR_18]"+r"(VAR_18),
[VAR_27]"=&r"(VAR_27), [VAR_28]"=&r"(VAR_28), [VAR_29]"=&r"(VAR_29), [VAR_30]"=&r"(VAR_30),
[VAR_31]"=&r"(VAR_31)
);
VAR_21 = VAR_15;
VAR_21 *= 3;
VAR_21 += VAR_16;
VAR_21 *= 3;
VAR_21 += VAR_17;
VAR_21 *= 3;
VAR_21 += VAR_18;
VAR_14 += p_bits[VAR_21];
VAR_14 += uquad_sign_bits[VAR_21];
VAR_20 = &VAR_19[VAR_21*4];
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
"lwc1 %[VAR_23], 0(%[VAR_22]) \n\t"
"lwc1 %[VAR_24], 4(%[VAR_22]) \n\t"
"lwc1 %[VAR_25], 8(%[VAR_22]) \n\t"
"lwc1 %[VAR_26], 12(%[VAR_22]) \n\t"
"abs.VAR_0 %[VAR_23], %[VAR_23] \n\t"
"abs.VAR_0 %[VAR_24], %[VAR_24] \n\t"
"abs.VAR_0 %[VAR_25], %[VAR_25] \n\t"
"abs.VAR_0 %[VAR_26], %[VAR_26] \n\t"
"lwc1 $f0, 0(%[VAR_20]) \n\t"
"lwc1 $f1, 4(%[VAR_20]) \n\t"
"lwc1 $f2, 8(%[VAR_20]) \n\t"
"lwc1 $f3, 12(%[VAR_20]) \n\t"
"nmsub.VAR_0 %[VAR_23], %[VAR_23], $f0, %[VAR_11] \n\t"
"nmsub.VAR_0 %[VAR_24], %[VAR_24], $f1, %[VAR_11] \n\t"
"nmsub.VAR_0 %[VAR_25], %[VAR_25], $f2, %[VAR_11] \n\t"
"nmsub.VAR_0 %[VAR_26], %[VAR_26], $f3, %[VAR_11] \n\t"
".set pop \n\t"
: [VAR_23]"=&f"(VAR_23), [VAR_24]"=&f"(VAR_24),
[VAR_25]"=&f"(VAR_25), [VAR_26]"=&f"(VAR_26)
: [VAR_22]"r"(VAR_22), [VAR_20]"r"(VAR_20),
[VAR_11]"f"(VAR_11)
: "$f0", "$f1", "$f2", "$f3",
"memory"
);
VAR_13 += VAR_23 * VAR_23 + VAR_24 * VAR_24
+ VAR_25 * VAR_25 + VAR_26 * VAR_26;
}
if (VAR_9)
*VAR_9 = VAR_14;
return VAR_13 * VAR_7 + VAR_14;
}
| [
"static float FUNC_0(struct AACEncContext *VAR_0,\nPutBitContext *VAR_1, const float *VAR_2,\nconst float *VAR_3, int VAR_4, int VAR_5,\nint VAR_6, const float VAR_7, const float VAR_8,\nint *VAR_9)\n{",
"const float VAR_10 = ff_aac_pow34sf_tab[POW_SF2_ZERO - VAR_5 + SCALE_ONE_POS - SCALE_DIV_512];",
"const float VAR_11 = ff_aac_pow2sf_tab [POW_SF2_ZERO + VAR_5 - SCALE_ONE_POS + SCALE_DIV_512];",
"int VAR_12;",
"float VAR_13 = 0;",
"int VAR_14 = 0;",
"int VAR_15, VAR_16, VAR_17, VAR_18;",
"uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[VAR_6-1];",
"float *VAR_19 = (float *)ff_aac_codebook_vectors[VAR_6-1];",
"for (VAR_12 = 0; VAR_12 < VAR_4; VAR_12 += 4) {",
"const float *VAR_20;",
"int VAR_21;",
"float *VAR_22 = (float *)&VAR_2[VAR_12];",
"float VAR_23, VAR_24, VAR_25, VAR_26;",
"int VAR_27, VAR_28, VAR_29, VAR_30, VAR_31;",
"VAR_15 = VAR_3[VAR_12 ] * VAR_10 + ROUND_STANDARD;",
"VAR_16 = VAR_3[VAR_12+1] * VAR_10 + ROUND_STANDARD;",
"VAR_17 = VAR_3[VAR_12+2] * VAR_10 + ROUND_STANDARD;",
"VAR_18 = VAR_3[VAR_12+3] * VAR_10 + ROUND_STANDARD;",
"__asm__ volatile (\n\".set push \\n\\t\"\n\".set noreorder \\n\\t\"\n\"ori %[VAR_31], $zero, 2 \\n\\t\"\n\"slt %[VAR_27], %[VAR_31], %[VAR_15] \\n\\t\"\n\"slt %[VAR_28], %[VAR_31], %[VAR_16] \\n\\t\"\n\"slt %[VAR_29], %[VAR_31], %[VAR_17] \\n\\t\"\n\"slt %[VAR_30], %[VAR_31], %[VAR_18] \\n\\t\"\n\"movn %[VAR_15], %[VAR_31], %[VAR_27] \\n\\t\"\n\"movn %[VAR_16], %[VAR_31], %[VAR_28] \\n\\t\"\n\"movn %[VAR_17], %[VAR_31], %[VAR_29] \\n\\t\"\n\"movn %[VAR_18], %[VAR_31], %[VAR_30] \\n\\t\"\n\".set pop \\n\\t\"\n: [VAR_15]\"+r\"(VAR_15), [VAR_16]\"+r\"(VAR_16),\n[VAR_17]\"+r\"(VAR_17), [VAR_18]\"+r\"(VAR_18),\n[VAR_27]\"=&r\"(VAR_27), [VAR_28]\"=&r\"(VAR_28), [VAR_29]\"=&r\"(VAR_29), [VAR_30]\"=&r\"(VAR_30),\n[VAR_31]\"=&r\"(VAR_31)\n);",
"VAR_21 = VAR_15;",
"VAR_21 *= 3;",
"VAR_21 += VAR_16;",
"VAR_21 *= 3;",
"VAR_21 += VAR_17;",
"VAR_21 *= 3;",
"VAR_21 += VAR_18;",
"VAR_14 += p_bits[VAR_21];",
"VAR_14 += uquad_sign_bits[VAR_21];",
"VAR_20 = &VAR_19[VAR_21*4];",
"__asm__ volatile (\n\".set push \\n\\t\"\n\".set noreorder \\n\\t\"\n\"lwc1 %[VAR_23], 0(%[VAR_22]) \\n\\t\"\n\"lwc1 %[VAR_24], 4(%[VAR_22]) \\n\\t\"\n\"lwc1 %[VAR_25], 8(%[VAR_22]) \\n\\t\"\n\"lwc1 %[VAR_26], 12(%[VAR_22]) \\n\\t\"\n\"abs.VAR_0 %[VAR_23], %[VAR_23] \\n\\t\"\n\"abs.VAR_0 %[VAR_24], %[VAR_24] \\n\\t\"\n\"abs.VAR_0 %[VAR_25], %[VAR_25] \\n\\t\"\n\"abs.VAR_0 %[VAR_26], %[VAR_26] \\n\\t\"\n\"lwc1 $f0, 0(%[VAR_20]) \\n\\t\"\n\"lwc1 $f1, 4(%[VAR_20]) \\n\\t\"\n\"lwc1 $f2, 8(%[VAR_20]) \\n\\t\"\n\"lwc1 $f3, 12(%[VAR_20]) \\n\\t\"\n\"nmsub.VAR_0 %[VAR_23], %[VAR_23], $f0, %[VAR_11] \\n\\t\"\n\"nmsub.VAR_0 %[VAR_24], %[VAR_24], $f1, %[VAR_11] \\n\\t\"\n\"nmsub.VAR_0 %[VAR_25], %[VAR_25], $f2, %[VAR_11] \\n\\t\"\n\"nmsub.VAR_0 %[VAR_26], %[VAR_26], $f3, %[VAR_11] \\n\\t\"\n\".set pop \\n\\t\"\n: [VAR_23]\"=&f\"(VAR_23), [VAR_24]\"=&f\"(VAR_24),\n[VAR_25]\"=&f\"(VAR_25), [VAR_26]\"=&f\"(VAR_26)\n: [VAR_22]\"r\"(VAR_22), [VAR_20]\"r\"(VAR_20),\n[VAR_11]\"f\"(VAR_11)\n: \"$f0\", \"$f1\", \"$f2\", \"$f3\",\n\"memory\"\n);",
"VAR_13 += VAR_23 * VAR_23 + VAR_24 * VAR_24\n+ VAR_25 * VAR_25 + VAR_26 * VAR_26;",
"}",
"if (VAR_9)\n*VAR_9 = VAR_14;",
"return VAR_13 * VAR_7 + VAR_14;",
"}"
] | [
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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59,
61,
65,
67,
69,
71,
73,
75,
77,
79,
81,
85,
89,
91,
93,
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125,
127,
129,
133,
135,
137,
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163,
167,
171,
173,
175,
177,
179,
181,
183
],
[
187,
189
],
[
191
],
[
195,
197
],
[
199
],
[
201
]
] |
19,053 | static void sdl_grab_start(void)
{
/*
* If the application is not active, do not try to enter grab state. This
* prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
* application (SDL bug).
*/
if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
return;
}
if (guest_cursor) {
SDL_SetCursor(guest_sprite);
if (!kbd_mouse_is_absolute() && !absolute_enabled)
SDL_WarpMouse(guest_x, guest_y);
} else
sdl_hide_cursor();
if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {
gui_grab = 1;
sdl_update_caption();
} else
sdl_show_cursor();
}
| true | qemu | eaa2e027b73c9afca623d877c91150a94c83049d | static void sdl_grab_start(void)
{
if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
return;
}
if (guest_cursor) {
SDL_SetCursor(guest_sprite);
if (!kbd_mouse_is_absolute() && !absolute_enabled)
SDL_WarpMouse(guest_x, guest_y);
} else
sdl_hide_cursor();
if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {
gui_grab = 1;
sdl_update_caption();
} else
sdl_show_cursor();
}
| {
"code": [
" if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {",
" gui_grab = 1;",
" sdl_update_caption();",
" } else",
" sdl_show_cursor();"
],
"line_no": [
35,
37,
39,
29,
43
]
} | static void FUNC_0(void)
{
if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
return;
}
if (guest_cursor) {
SDL_SetCursor(guest_sprite);
if (!kbd_mouse_is_absolute() && !absolute_enabled)
SDL_WarpMouse(guest_x, guest_y);
} else
sdl_hide_cursor();
if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {
gui_grab = 1;
sdl_update_caption();
} else
sdl_show_cursor();
}
| [
"static void FUNC_0(void)\n{",
"if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {",
"return;",
"}",
"if (guest_cursor) {",
"SDL_SetCursor(guest_sprite);",
"if (!kbd_mouse_is_absolute() && !absolute_enabled)\nSDL_WarpMouse(guest_x, guest_y);",
"} else",
"sdl_hide_cursor();",
"if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) {",
"gui_grab = 1;",
"sdl_update_caption();",
"} else",
"sdl_show_cursor();",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
19,054 | static void libschroedinger_free_frame(void *data)
{
FFSchroEncodedFrame *enc_frame = data;
av_freep(&enc_frame->p_encbuf);
av_free(enc_frame);
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static void libschroedinger_free_frame(void *data)
{
FFSchroEncodedFrame *enc_frame = data;
av_freep(&enc_frame->p_encbuf);
av_free(enc_frame);
}
| {
"code": [
"static void libschroedinger_free_frame(void *data)",
" FFSchroEncodedFrame *enc_frame = data;",
" av_freep(&enc_frame->p_encbuf);",
" av_free(enc_frame);"
],
"line_no": [
1,
5,
9,
11
]
} | static void FUNC_0(void *VAR_0)
{
FFSchroEncodedFrame *enc_frame = VAR_0;
av_freep(&enc_frame->p_encbuf);
av_free(enc_frame);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"FFSchroEncodedFrame *enc_frame = VAR_0;",
"av_freep(&enc_frame->p_encbuf);",
"av_free(enc_frame);",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
19,055 | static float quantize_band_cost(struct AACEncContext *s, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits, int rtz)
{
return get_band_cost(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits);
}
| true | FFmpeg | 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec | static float quantize_band_cost(struct AACEncContext *s, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits, int rtz)
{
return get_band_cost(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits);
}
| {
"code": [
" int *bits, int rtz)",
" int *bits, int rtz)",
" int *bits, int rtz)",
" return get_band_cost(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits);"
],
"line_no": [
7,
7,
7,
11
]
} | static float FUNC_0(struct AACEncContext *VAR_0, const float *VAR_1,
const float *VAR_2, int VAR_3, int VAR_4,
int VAR_5, const float VAR_6, const float VAR_7,
int *VAR_8, int VAR_9)
{
return get_band_cost(VAR_0, NULL, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);
}
| [
"static float FUNC_0(struct AACEncContext *VAR_0, const float *VAR_1,\nconst float *VAR_2, int VAR_3, int VAR_4,\nint VAR_5, const float VAR_6, const float VAR_7,\nint *VAR_8, int VAR_9)\n{",
"return get_band_cost(VAR_0, NULL, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);",
"}"
] | [
1,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
]
] |
19,056 | static void xhci_er_reset(XHCIState *xhci, int v)
{
XHCIInterrupter *intr = &xhci->intr[v];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
/* disabled */
intr->er_start = 0;
intr->er_size = 0;
return;
}
/* cache the (sole) event ring segment location */
if (intr->erstsz != 1) {
DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(xhci);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("xhci: invalid value for segment size: %d\n", seg.size);
xhci_die(xhci);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
intr->er_full = 0;
DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
v, intr->er_start, intr->er_size);
}
| true | qemu | 898248a32915024a4f01ce4f0c3519509fb703cb | static void xhci_er_reset(XHCIState *xhci, int v)
{
XHCIInterrupter *intr = &xhci->intr[v];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
intr->er_start = 0;
intr->er_size = 0;
return;
}
if (intr->erstsz != 1) {
DPRINTF("xhci: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(xhci);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("xhci: invalid value for segment size: %d\n", seg.size);
xhci_die(xhci);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
intr->er_full = 0;
DPRINTF("xhci: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
v, intr->er_start, intr->er_size);
}
| {
"code": [
" XHCIInterrupter *intr = &xhci->intr[v];",
" xhci_die(xhci);",
" intr->er_full = 0;"
],
"line_no": [
5,
29,
65
]
} | static void FUNC_0(XHCIState *VAR_0, int VAR_1)
{
XHCIInterrupter *intr = &VAR_0->intr[VAR_1];
XHCIEvRingSeg seg;
if (intr->erstsz == 0) {
intr->er_start = 0;
intr->er_size = 0;
return;
}
if (intr->erstsz != 1) {
DPRINTF("VAR_0: invalid value for ERSTSZ: %d\n", intr->erstsz);
xhci_die(VAR_0);
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
pci_dma_read(PCI_DEVICE(VAR_0), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
if (seg.size < 16 || seg.size > 4096) {
DPRINTF("VAR_0: invalid value for segment size: %d\n", seg.size);
xhci_die(VAR_0);
return;
}
intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);
intr->er_size = seg.size;
intr->er_ep_idx = 0;
intr->er_pcs = 1;
intr->er_full = 0;
DPRINTF("VAR_0: event ring[%d]:" DMA_ADDR_FMT " [%d]\n",
VAR_1, intr->er_start, intr->er_size);
}
| [
"static void FUNC_0(XHCIState *VAR_0, int VAR_1)\n{",
"XHCIInterrupter *intr = &VAR_0->intr[VAR_1];",
"XHCIEvRingSeg seg;",
"if (intr->erstsz == 0) {",
"intr->er_start = 0;",
"intr->er_size = 0;",
"return;",
"}",
"if (intr->erstsz != 1) {",
"DPRINTF(\"VAR_0: invalid value for ERSTSZ: %d\\n\", intr->erstsz);",
"xhci_die(VAR_0);",
"return;",
"}",
"dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);",
"pci_dma_read(PCI_DEVICE(VAR_0), erstba, &seg, sizeof(seg));",
"le32_to_cpus(&seg.addr_low);",
"le32_to_cpus(&seg.addr_high);",
"le32_to_cpus(&seg.size);",
"if (seg.size < 16 || seg.size > 4096) {",
"DPRINTF(\"VAR_0: invalid value for segment size: %d\\n\", seg.size);",
"xhci_die(VAR_0);",
"return;",
"}",
"intr->er_start = xhci_addr64(seg.addr_low, seg.addr_high);",
"intr->er_size = seg.size;",
"intr->er_ep_idx = 0;",
"intr->er_pcs = 1;",
"intr->er_full = 0;",
"DPRINTF(\"VAR_0: event ring[%d]:\" DMA_ADDR_FMT \" [%d]\\n\",\nVAR_1, intr->er_start, intr->er_size);",
"}"
] | [
0,
1,
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,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
]
] |
19,057 | DeviceState *qdev_try_create(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
if (!bus) {
bus = sysbus_get_default();
}
qdev_set_parent_bus(dev, bus);
object_unref(OBJECT(dev));
return dev;
} | true | qemu | 7474f1be701f136b224af5e1abe55e97dc3f29a5 | DeviceState *qdev_try_create(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
if (!bus) {
bus = sysbus_get_default();
}
qdev_set_parent_bus(dev, bus);
object_unref(OBJECT(dev));
return dev;
} | {
"code": [],
"line_no": []
} | DeviceState *FUNC_0(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
if (!bus) {
bus = sysbus_get_default();
}
qdev_set_parent_bus(dev, bus);
object_unref(OBJECT(dev));
return dev;
} | [
"DeviceState *FUNC_0(BusState *bus, const char *type)\n{",
"DeviceState *dev;",
"if (object_class_by_name(type) == NULL) {",
"return NULL;",
"}",
"dev = DEVICE(object_new(type));",
"if (!dev) {",
"return NULL;",
"}",
"if (!bus) {",
"bus = sysbus_get_default();",
"}",
"qdev_set_parent_bus(dev, bus);",
"object_unref(OBJECT(dev));",
"return dev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
19,058 | static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = NULL;
struct iscsi_url *iscsi_url = NULL;
struct scsi_task *task = NULL;
struct scsi_inquiry_standard *inq = NULL;
struct scsi_inquiry_supported_pages *inq_vpd;
char *initiator_name = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *filename;
int i, ret;
if ((BDRV_SECTOR_SIZE % 512) != 0) {
error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
"BDRV_SECTOR_SIZE(%lld) is not a multiple "
"of 512", BDRV_SECTOR_SIZE);
return -EINVAL;
}
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
filename = qemu_opt_get(opts, "filename");
iscsi_url = iscsi_parse_full_url(iscsi, filename);
if (iscsi_url == NULL) {
error_setg(errp, "Failed to parse URL : %s", filename);
ret = -EINVAL;
goto out;
}
memset(iscsilun, 0, sizeof(IscsiLun));
initiator_name = parse_initiator_name(iscsi_url->target);
iscsi = iscsi_create_context(initiator_name);
if (iscsi == NULL) {
error_setg(errp, "iSCSI: Failed to create iSCSI context.");
ret = -ENOMEM;
goto out;
}
if (iscsi_set_targetname(iscsi, iscsi_url->target)) {
error_setg(errp, "iSCSI: Failed to set target name.");
ret = -EINVAL;
goto out;
}
if (iscsi_url->user != NULL) {
ret = iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user,
iscsi_url->passwd);
if (ret != 0) {
error_setg(errp, "Failed to set initiator username and password");
ret = -EINVAL;
goto out;
}
}
/* check if we got CHAP username/password via the options */
parse_chap(iscsi, iscsi_url->target, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
if (iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL) != 0) {
error_setg(errp, "iSCSI: Failed to set session type to normal.");
ret = -EINVAL;
goto out;
}
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
/* check if we got HEADER_DIGEST via the options */
parse_header_digest(iscsi, iscsi_url->target, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) {
error_setg(errp, "iSCSI: Failed to connect to LUN : %s",
iscsi_get_error(iscsi));
ret = -EINVAL;
goto out;
}
iscsilun->iscsi = iscsi;
iscsilun->aio_context = bdrv_get_aio_context(bs);
iscsilun->lun = iscsi_url->lun;
iscsilun->has_write_same = true;
task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 0, 0,
(void **) &inq, errp);
if (task == NULL) {
ret = -EINVAL;
goto out;
}
iscsilun->type = inq->periperal_device_type;
scsi_free_scsi_task(task);
task = NULL;
/* Check the write protect flag of the LUN if we want to write */
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
iscsi_is_write_protected(iscsilun)) {
error_setg(errp, "Cannot open a write protected LUN as read-write");
ret = -EACCES;
goto out;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);
bs->request_alignment = iscsilun->block_size;
/* We don't have any emulation for devices other than disks and CD-ROMs, so
* this must be sg ioctl compatible. We force it to be sg, otherwise qemu
* will try to read from the device to guess the image format.
*/
if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) {
bs->sg = 1;
}
task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
(void **) &inq_vpd, errp);
if (task == NULL) {
ret = -EINVAL;
goto out;
}
for (i = 0; i < inq_vpd->num_pages; i++) {
struct scsi_task *inq_task;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
struct scsi_inquiry_block_limits *inq_bl;
switch (inq_vpd->pages[i]) {
case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING:
inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
(void **) &inq_lbp, errp);
if (inq_task == NULL) {
ret = -EINVAL;
goto out;
}
memcpy(&iscsilun->lbp, inq_lbp,
sizeof(struct scsi_inquiry_logical_block_provisioning));
scsi_free_scsi_task(inq_task);
break;
case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS:
inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
(void **) &inq_bl, errp);
if (inq_task == NULL) {
ret = -EINVAL;
goto out;
}
memcpy(&iscsilun->bl, inq_bl,
sizeof(struct scsi_inquiry_block_limits));
scsi_free_scsi_task(inq_task);
break;
default:
break;
}
}
scsi_free_scsi_task(task);
task = NULL;
iscsi_attach_aio_context(bs, iscsilun->aio_context);
/* Guess the internal cluster (page) size of the iscsi target by the means
* of opt_unmap_gran. Transfer the unmap granularity only if it has a
* reasonable size */
if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 &&
iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
iscsilun->block_size) >> BDRV_SECTOR_BITS;
if (iscsilun->lbprz && !(bs->open_flags & BDRV_O_NOCACHE)) {
iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
if (iscsilun->allocationmap == NULL) {
ret = -ENOMEM;
}
}
}
out:
qemu_opts_del(opts);
g_free(initiator_name);
if (iscsi_url != NULL) {
iscsi_destroy_url(iscsi_url);
}
if (task != NULL) {
scsi_free_scsi_task(task);
}
if (ret) {
if (iscsi != NULL) {
iscsi_destroy_context(iscsi);
}
memset(iscsilun, 0, sizeof(IscsiLun));
}
return ret;
}
| true | qemu | debfb917a4f9c0784772c86f110f2bcd22e5a14f | static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
IscsiLun *iscsilun = bs->opaque;
struct iscsi_context *iscsi = NULL;
struct iscsi_url *iscsi_url = NULL;
struct scsi_task *task = NULL;
struct scsi_inquiry_standard *inq = NULL;
struct scsi_inquiry_supported_pages *inq_vpd;
char *initiator_name = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *filename;
int i, ret;
if ((BDRV_SECTOR_SIZE % 512) != 0) {
error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
"BDRV_SECTOR_SIZE(%lld) is not a multiple "
"of 512", BDRV_SECTOR_SIZE);
return -EINVAL;
}
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
filename = qemu_opt_get(opts, "filename");
iscsi_url = iscsi_parse_full_url(iscsi, filename);
if (iscsi_url == NULL) {
error_setg(errp, "Failed to parse URL : %s", filename);
ret = -EINVAL;
goto out;
}
memset(iscsilun, 0, sizeof(IscsiLun));
initiator_name = parse_initiator_name(iscsi_url->target);
iscsi = iscsi_create_context(initiator_name);
if (iscsi == NULL) {
error_setg(errp, "iSCSI: Failed to create iSCSI context.");
ret = -ENOMEM;
goto out;
}
if (iscsi_set_targetname(iscsi, iscsi_url->target)) {
error_setg(errp, "iSCSI: Failed to set target name.");
ret = -EINVAL;
goto out;
}
if (iscsi_url->user != NULL) {
ret = iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user,
iscsi_url->passwd);
if (ret != 0) {
error_setg(errp, "Failed to set initiator username and password");
ret = -EINVAL;
goto out;
}
}
parse_chap(iscsi, iscsi_url->target, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
if (iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL) != 0) {
error_setg(errp, "iSCSI: Failed to set session type to normal.");
ret = -EINVAL;
goto out;
}
iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
parse_header_digest(iscsi, iscsi_url->target, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) {
error_setg(errp, "iSCSI: Failed to connect to LUN : %s",
iscsi_get_error(iscsi));
ret = -EINVAL;
goto out;
}
iscsilun->iscsi = iscsi;
iscsilun->aio_context = bdrv_get_aio_context(bs);
iscsilun->lun = iscsi_url->lun;
iscsilun->has_write_same = true;
task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 0, 0,
(void **) &inq, errp);
if (task == NULL) {
ret = -EINVAL;
goto out;
}
iscsilun->type = inq->periperal_device_type;
scsi_free_scsi_task(task);
task = NULL;
if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
iscsi_is_write_protected(iscsilun)) {
error_setg(errp, "Cannot open a write protected LUN as read-write");
ret = -EACCES;
goto out;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto out;
}
bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);
bs->request_alignment = iscsilun->block_size;
if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) {
bs->sg = 1;
}
task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
(void **) &inq_vpd, errp);
if (task == NULL) {
ret = -EINVAL;
goto out;
}
for (i = 0; i < inq_vpd->num_pages; i++) {
struct scsi_task *inq_task;
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
struct scsi_inquiry_block_limits *inq_bl;
switch (inq_vpd->pages[i]) {
case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING:
inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
(void **) &inq_lbp, errp);
if (inq_task == NULL) {
ret = -EINVAL;
goto out;
}
memcpy(&iscsilun->lbp, inq_lbp,
sizeof(struct scsi_inquiry_logical_block_provisioning));
scsi_free_scsi_task(inq_task);
break;
case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS:
inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
(void **) &inq_bl, errp);
if (inq_task == NULL) {
ret = -EINVAL;
goto out;
}
memcpy(&iscsilun->bl, inq_bl,
sizeof(struct scsi_inquiry_block_limits));
scsi_free_scsi_task(inq_task);
break;
default:
break;
}
}
scsi_free_scsi_task(task);
task = NULL;
iscsi_attach_aio_context(bs, iscsilun->aio_context);
if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 &&
iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
iscsilun->block_size) >> BDRV_SECTOR_BITS;
if (iscsilun->lbprz && !(bs->open_flags & BDRV_O_NOCACHE)) {
iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
if (iscsilun->allocationmap == NULL) {
ret = -ENOMEM;
}
}
}
out:
qemu_opts_del(opts);
g_free(initiator_name);
if (iscsi_url != NULL) {
iscsi_destroy_url(iscsi_url);
}
if (task != NULL) {
scsi_free_scsi_task(task);
}
if (ret) {
if (iscsi != NULL) {
iscsi_destroy_context(iscsi);
}
memset(iscsilun, 0, sizeof(IscsiLun));
}
return ret;
}
| {
"code": [
" int i, ret;"
],
"line_no": [
27
]
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
IscsiLun *iscsilun = VAR_0->opaque;
struct iscsi_context *VAR_4 = NULL;
struct VAR_5 *VAR_5 = NULL;
struct scsi_task *VAR_6 = NULL;
struct scsi_inquiry_standard *VAR_7 = NULL;
struct scsi_inquiry_supported_pages *VAR_8;
char *VAR_9 = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *VAR_10;
int VAR_11, VAR_12;
if ((BDRV_SECTOR_SIZE % 512) != 0) {
error_setg(VAR_3, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
"BDRV_SECTOR_SIZE(%lld) is not a multiple "
"of 512", BDRV_SECTOR_SIZE);
return -EINVAL;
}
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_1, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_12 = -EINVAL;
goto out;
}
VAR_10 = qemu_opt_get(opts, "VAR_10");
VAR_5 = iscsi_parse_full_url(VAR_4, VAR_10);
if (VAR_5 == NULL) {
error_setg(VAR_3, "Failed to parse URL : %s", VAR_10);
VAR_12 = -EINVAL;
goto out;
}
memset(iscsilun, 0, sizeof(IscsiLun));
VAR_9 = parse_initiator_name(VAR_5->target);
VAR_4 = iscsi_create_context(VAR_9);
if (VAR_4 == NULL) {
error_setg(VAR_3, "iSCSI: Failed to create iSCSI context.");
VAR_12 = -ENOMEM;
goto out;
}
if (iscsi_set_targetname(VAR_4, VAR_5->target)) {
error_setg(VAR_3, "iSCSI: Failed to set target name.");
VAR_12 = -EINVAL;
goto out;
}
if (VAR_5->user != NULL) {
VAR_12 = iscsi_set_initiator_username_pwd(VAR_4, VAR_5->user,
VAR_5->passwd);
if (VAR_12 != 0) {
error_setg(VAR_3, "Failed to set initiator username and password");
VAR_12 = -EINVAL;
goto out;
}
}
parse_chap(VAR_4, VAR_5->target, &local_err);
if (local_err != NULL) {
error_propagate(VAR_3, local_err);
VAR_12 = -EINVAL;
goto out;
}
if (iscsi_set_session_type(VAR_4, ISCSI_SESSION_NORMAL) != 0) {
error_setg(VAR_3, "iSCSI: Failed to set session type to normal.");
VAR_12 = -EINVAL;
goto out;
}
iscsi_set_header_digest(VAR_4, ISCSI_HEADER_DIGEST_NONE_CRC32C);
parse_header_digest(VAR_4, VAR_5->target, &local_err);
if (local_err != NULL) {
error_propagate(VAR_3, local_err);
VAR_12 = -EINVAL;
goto out;
}
if (iscsi_full_connect_sync(VAR_4, VAR_5->portal, VAR_5->lun) != 0) {
error_setg(VAR_3, "iSCSI: Failed to connect to LUN : %s",
iscsi_get_error(VAR_4));
VAR_12 = -EINVAL;
goto out;
}
iscsilun->VAR_4 = VAR_4;
iscsilun->aio_context = bdrv_get_aio_context(VAR_0);
iscsilun->lun = VAR_5->lun;
iscsilun->has_write_same = true;
VAR_6 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 0, 0,
(void **) &VAR_7, VAR_3);
if (VAR_6 == NULL) {
VAR_12 = -EINVAL;
goto out;
}
iscsilun->type = VAR_7->periperal_device_type;
scsi_free_scsi_task(VAR_6);
VAR_6 = NULL;
if (iscsilun->type == TYPE_DISK && (VAR_2 & BDRV_O_RDWR) &&
iscsi_is_write_protected(iscsilun)) {
error_setg(VAR_3, "Cannot open a write protected LUN as read-write");
VAR_12 = -EACCES;
goto out;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
if (local_err != NULL) {
error_propagate(VAR_3, local_err);
VAR_12 = -EINVAL;
goto out;
}
VAR_0->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);
VAR_0->request_alignment = iscsilun->block_size;
if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) {
VAR_0->sg = 1;
}
VAR_6 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,
(void **) &VAR_8, VAR_3);
if (VAR_6 == NULL) {
VAR_12 = -EINVAL;
goto out;
}
for (VAR_11 = 0; VAR_11 < VAR_8->num_pages; VAR_11++) {
struct scsi_task *VAR_13;
struct scsi_inquiry_logical_block_provisioning *VAR_14;
struct scsi_inquiry_block_limits *VAR_15;
switch (VAR_8->pages[VAR_11]) {
case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING:
VAR_13 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
(void **) &VAR_14, VAR_3);
if (VAR_13 == NULL) {
VAR_12 = -EINVAL;
goto out;
}
memcpy(&iscsilun->lbp, VAR_14,
sizeof(struct scsi_inquiry_logical_block_provisioning));
scsi_free_scsi_task(VAR_13);
break;
case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS:
VAR_13 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,
SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,
(void **) &VAR_15, VAR_3);
if (VAR_13 == NULL) {
VAR_12 = -EINVAL;
goto out;
}
memcpy(&iscsilun->bl, VAR_15,
sizeof(struct scsi_inquiry_block_limits));
scsi_free_scsi_task(VAR_13);
break;
default:
break;
}
}
scsi_free_scsi_task(VAR_6);
VAR_6 = NULL;
iscsi_attach_aio_context(VAR_0, iscsilun->aio_context);
if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 &&
iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {
iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
iscsilun->block_size) >> BDRV_SECTOR_BITS;
if (iscsilun->lbprz && !(VAR_0->open_flags & BDRV_O_NOCACHE)) {
iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
if (iscsilun->allocationmap == NULL) {
VAR_12 = -ENOMEM;
}
}
}
out:
qemu_opts_del(opts);
g_free(VAR_9);
if (VAR_5 != NULL) {
iscsi_destroy_url(VAR_5);
}
if (VAR_6 != NULL) {
scsi_free_scsi_task(VAR_6);
}
if (VAR_12) {
if (VAR_4 != NULL) {
iscsi_destroy_context(VAR_4);
}
memset(iscsilun, 0, sizeof(IscsiLun));
}
return VAR_12;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"IscsiLun *iscsilun = VAR_0->opaque;",
"struct iscsi_context *VAR_4 = NULL;",
"struct VAR_5 *VAR_5 = NULL;",
"struct scsi_task *VAR_6 = NULL;",
"struct scsi_inquiry_standard *VAR_7 = NULL;",
"struct scsi_inquiry_supported_pages *VAR_8;",
"char *VAR_9 = NULL;",
"QemuOpts *opts;",
"Error *local_err = NULL;",
"const char *VAR_10;",
"int VAR_11, VAR_12;",
"if ((BDRV_SECTOR_SIZE % 512) != 0) {",
"error_setg(VAR_3, \"iSCSI: Invalid BDRV_SECTOR_SIZE. \"\n\"BDRV_SECTOR_SIZE(%lld) is not a multiple \"\n\"of 512\", BDRV_SECTOR_SIZE);",
"return -EINVAL;",
"}",
"opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_1, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"VAR_10 = qemu_opt_get(opts, \"VAR_10\");",
"VAR_5 = iscsi_parse_full_url(VAR_4, VAR_10);",
"if (VAR_5 == NULL) {",
"error_setg(VAR_3, \"Failed to parse URL : %s\", VAR_10);",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"memset(iscsilun, 0, sizeof(IscsiLun));",
"VAR_9 = parse_initiator_name(VAR_5->target);",
"VAR_4 = iscsi_create_context(VAR_9);",
"if (VAR_4 == NULL) {",
"error_setg(VAR_3, \"iSCSI: Failed to create iSCSI context.\");",
"VAR_12 = -ENOMEM;",
"goto out;",
"}",
"if (iscsi_set_targetname(VAR_4, VAR_5->target)) {",
"error_setg(VAR_3, \"iSCSI: Failed to set target name.\");",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"if (VAR_5->user != NULL) {",
"VAR_12 = iscsi_set_initiator_username_pwd(VAR_4, VAR_5->user,\nVAR_5->passwd);",
"if (VAR_12 != 0) {",
"error_setg(VAR_3, \"Failed to set initiator username and password\");",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"}",
"parse_chap(VAR_4, VAR_5->target, &local_err);",
"if (local_err != NULL) {",
"error_propagate(VAR_3, local_err);",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"if (iscsi_set_session_type(VAR_4, ISCSI_SESSION_NORMAL) != 0) {",
"error_setg(VAR_3, \"iSCSI: Failed to set session type to normal.\");",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"iscsi_set_header_digest(VAR_4, ISCSI_HEADER_DIGEST_NONE_CRC32C);",
"parse_header_digest(VAR_4, VAR_5->target, &local_err);",
"if (local_err != NULL) {",
"error_propagate(VAR_3, local_err);",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"if (iscsi_full_connect_sync(VAR_4, VAR_5->portal, VAR_5->lun) != 0) {",
"error_setg(VAR_3, \"iSCSI: Failed to connect to LUN : %s\",\niscsi_get_error(VAR_4));",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"iscsilun->VAR_4 = VAR_4;",
"iscsilun->aio_context = bdrv_get_aio_context(VAR_0);",
"iscsilun->lun = VAR_5->lun;",
"iscsilun->has_write_same = true;",
"VAR_6 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 0, 0,\n(void **) &VAR_7, VAR_3);",
"if (VAR_6 == NULL) {",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"iscsilun->type = VAR_7->periperal_device_type;",
"scsi_free_scsi_task(VAR_6);",
"VAR_6 = NULL;",
"if (iscsilun->type == TYPE_DISK && (VAR_2 & BDRV_O_RDWR) &&\niscsi_is_write_protected(iscsilun)) {",
"error_setg(VAR_3, \"Cannot open a write protected LUN as read-write\");",
"VAR_12 = -EACCES;",
"goto out;",
"}",
"iscsi_readcapacity_sync(iscsilun, &local_err);",
"if (local_err != NULL) {",
"error_propagate(VAR_3, local_err);",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"VAR_0->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun);",
"VAR_0->request_alignment = iscsilun->block_size;",
"if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) {",
"VAR_0->sg = 1;",
"}",
"VAR_6 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,\nSCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES,\n(void **) &VAR_8, VAR_3);",
"if (VAR_6 == NULL) {",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"for (VAR_11 = 0; VAR_11 < VAR_8->num_pages; VAR_11++) {",
"struct scsi_task *VAR_13;",
"struct scsi_inquiry_logical_block_provisioning *VAR_14;",
"struct scsi_inquiry_block_limits *VAR_15;",
"switch (VAR_8->pages[VAR_11]) {",
"case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING:\nVAR_13 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,\nSCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,\n(void **) &VAR_14, VAR_3);",
"if (VAR_13 == NULL) {",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"memcpy(&iscsilun->lbp, VAR_14,\nsizeof(struct scsi_inquiry_logical_block_provisioning));",
"scsi_free_scsi_task(VAR_13);",
"break;",
"case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS:\nVAR_13 = iscsi_do_inquiry(iscsilun->VAR_4, iscsilun->lun, 1,\nSCSI_INQUIRY_PAGECODE_BLOCK_LIMITS,\n(void **) &VAR_15, VAR_3);",
"if (VAR_13 == NULL) {",
"VAR_12 = -EINVAL;",
"goto out;",
"}",
"memcpy(&iscsilun->bl, VAR_15,\nsizeof(struct scsi_inquiry_block_limits));",
"scsi_free_scsi_task(VAR_13);",
"break;",
"default:\nbreak;",
"}",
"}",
"scsi_free_scsi_task(VAR_6);",
"VAR_6 = NULL;",
"iscsi_attach_aio_context(VAR_0, iscsilun->aio_context);",
"if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 &&\niscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) {",
"iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *\niscsilun->block_size) >> BDRV_SECTOR_BITS;",
"if (iscsilun->lbprz && !(VAR_0->open_flags & BDRV_O_NOCACHE)) {",
"iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);",
"if (iscsilun->allocationmap == NULL) {",
"VAR_12 = -ENOMEM;",
"}",
"}",
"}",
"out:\nqemu_opts_del(opts);",
"g_free(VAR_9);",
"if (VAR_5 != NULL) {",
"iscsi_destroy_url(VAR_5);",
"}",
"if (VAR_6 != NULL) {",
"scsi_free_scsi_task(VAR_6);",
"}",
"if (VAR_12) {",
"if (VAR_4 != NULL) {",
"iscsi_destroy_context(VAR_4);",
"}",
"memset(iscsilun, 0, sizeof(IscsiLun));",
"}",
"return VAR_12;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
267
],
[
269
],
[
271
],
[
275,
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299,
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315,
317
],
[
319
],
[
321
],
[
323,
325,
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
371,
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
395,
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
]
] |
19,059 | type_init(macio_register_types)
void macio_init(PCIDevice *d,
MemoryRegion *pic_mem,
MemoryRegion *escc_mem)
{
MacIOState *macio_state = MACIO(d);
macio_state->pic_mem = pic_mem;
macio_state->escc_mem = escc_mem;
/* Note: this code is strongly inspirated from the corresponding code
in PearPC */
qdev_init_nofail(DEVICE(d));
} | true | qemu | b981289c493c7ddabc1cdf7de99daa24642c7739 | type_init(macio_register_types)
void macio_init(PCIDevice *d,
MemoryRegion *pic_mem,
MemoryRegion *escc_mem)
{
MacIOState *macio_state = MACIO(d);
macio_state->pic_mem = pic_mem;
macio_state->escc_mem = escc_mem;
qdev_init_nofail(DEVICE(d));
} | {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
void macio_init(PCIDevice *d,
MemoryRegion *pic_mem,
MemoryRegion *escc_mem)
{
MacIOState *macio_state = MACIO(d);
macio_state->pic_mem = pic_mem;
macio_state->escc_mem = escc_mem;
qdev_init_nofail(DEVICE(d));
} | [
"FUNC_0(VAR_0)\nvoid macio_init(PCIDevice *d,\nMemoryRegion *pic_mem,\nMemoryRegion *escc_mem)\n{",
"MacIOState *macio_state = MACIO(d);",
"macio_state->pic_mem = pic_mem;",
"macio_state->escc_mem = escc_mem;",
"qdev_init_nofail(DEVICE(d));",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
5,
7,
9,
11
],
[
13
],
[
17
],
[
19
],
[
29
],
[
31
]
] |
19,060 | int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
{
const char *name;
const char *type;
int i;
type = qemu_opt_get(opts, "type");
if (!type) {
error_set(errp, QERR_MISSING_PARAMETER, "type");
return -1;
}
if (is_netdev) {
if (strcmp(type, "tap") != 0 &&
#ifdef CONFIG_NET_BRIDGE
strcmp(type, "bridge") != 0 &&
#endif
#ifdef CONFIG_SLIRP
strcmp(type, "user") != 0 &&
#endif
#ifdef CONFIG_VDE
strcmp(type, "vde") != 0 &&
#endif
strcmp(type, "socket") != 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
"a netdev backend type");
return -1;
}
if (qemu_opt_get(opts, "vlan")) {
error_set(errp, QERR_INVALID_PARAMETER, "vlan");
return -1;
}
if (qemu_opt_get(opts, "name")) {
error_set(errp, QERR_INVALID_PARAMETER, "name");
return -1;
}
if (!qemu_opts_id(opts)) {
error_set(errp, QERR_MISSING_PARAMETER, "id");
return -1;
}
}
name = qemu_opts_id(opts);
if (!name) {
name = qemu_opt_get(opts, "name");
}
for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) {
if (net_client_types[i].type != NULL &&
!strcmp(net_client_types[i].type, type)) {
Error *local_err = NULL;
VLANState *vlan = NULL;
int ret;
qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return -1;
}
/* Do not add to a vlan if it's a -netdev or a nic with a
* netdev= parameter. */
if (!(is_netdev ||
(strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {
vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
}
ret = 0;
if (net_client_types[i].init) {
ret = net_client_types[i].init(opts, name, vlan);
if (ret < 0) {
/* TODO push error reporting into init() methods */
error_set(errp, QERR_DEVICE_INIT_FAILED, type);
return -1;
}
}
return ret;
}
}
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
"a network client type");
return -1;
}
| true | qemu | 6687b79d636cd60ed9adb1177d0d946b58fa7717 | int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)
{
const char *name;
const char *type;
int i;
type = qemu_opt_get(opts, "type");
if (!type) {
error_set(errp, QERR_MISSING_PARAMETER, "type");
return -1;
}
if (is_netdev) {
if (strcmp(type, "tap") != 0 &&
#ifdef CONFIG_NET_BRIDGE
strcmp(type, "bridge") != 0 &&
#endif
#ifdef CONFIG_SLIRP
strcmp(type, "user") != 0 &&
#endif
#ifdef CONFIG_VDE
strcmp(type, "vde") != 0 &&
#endif
strcmp(type, "socket") != 0) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
"a netdev backend type");
return -1;
}
if (qemu_opt_get(opts, "vlan")) {
error_set(errp, QERR_INVALID_PARAMETER, "vlan");
return -1;
}
if (qemu_opt_get(opts, "name")) {
error_set(errp, QERR_INVALID_PARAMETER, "name");
return -1;
}
if (!qemu_opts_id(opts)) {
error_set(errp, QERR_MISSING_PARAMETER, "id");
return -1;
}
}
name = qemu_opts_id(opts);
if (!name) {
name = qemu_opt_get(opts, "name");
}
for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) {
if (net_client_types[i].type != NULL &&
!strcmp(net_client_types[i].type, type)) {
Error *local_err = NULL;
VLANState *vlan = NULL;
int ret;
qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return -1;
}
if (!(is_netdev ||
(strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {
vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
}
ret = 0;
if (net_client_types[i].init) {
ret = net_client_types[i].init(opts, name, vlan);
if (ret < 0) {
error_set(errp, QERR_DEVICE_INIT_FAILED, type);
return -1;
}
}
return ret;
}
}
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
"a network client type");
return -1;
}
| {
"code": [
" const char *type;",
"#endif",
"#ifdef CONFIG_NET_BRIDGE",
"int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)",
" const char *type;",
" int i;",
" type = qemu_opt_get(opts, \"type\");",
" if (!type) {",
" error_set(errp, QERR_MISSING_PARAMETER, \"type\");",
" return -1;",
" if (strcmp(type, \"tap\") != 0 &&",
"#ifdef CONFIG_NET_BRIDGE",
" strcmp(type, \"bridge\") != 0 &&",
"#endif",
" strcmp(type, \"user\") != 0 &&",
" strcmp(type, \"vde\") != 0 &&",
" strcmp(type, \"socket\") != 0) {",
" if (qemu_opt_get(opts, \"vlan\")) {",
" error_set(errp, QERR_INVALID_PARAMETER, \"vlan\");",
" return -1;",
" if (qemu_opt_get(opts, \"name\")) {",
" error_set(errp, QERR_INVALID_PARAMETER, \"name\");",
" return -1;",
" if (!qemu_opts_id(opts)) {",
" error_set(errp, QERR_MISSING_PARAMETER, \"id\");",
" name = qemu_opts_id(opts);",
" if (!name) {",
" name = qemu_opt_get(opts, \"name\");",
" for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) {",
" if (net_client_types[i].type != NULL &&",
" !strcmp(net_client_types[i].type, type)) {",
" Error *local_err = NULL;",
" VLANState *vlan = NULL;",
" int ret;",
" qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);",
" if (error_is_set(&local_err)) {",
" error_propagate(errp, local_err);",
" return -1;",
" if (!(is_netdev ||",
" (strcmp(type, \"nic\") == 0 && qemu_opt_get(opts, \"netdev\")))) {",
" vlan = qemu_find_vlan(qemu_opt_get_number(opts, \"vlan\", 0), 1);",
" ret = 0;",
" if (net_client_types[i].init) {",
" ret = net_client_types[i].init(opts, name, vlan);",
" if (ret < 0) {",
" error_set(errp, QERR_DEVICE_INIT_FAILED, type);",
" return -1;",
" return ret;",
" error_set(errp, QERR_INVALID_PARAMETER_VALUE, \"type\",",
" \"a network client type\");",
" return -1;"
],
"line_no": [
7,
33,
29,
1,
7,
9,
13,
15,
17,
19,
27,
29,
31,
33,
37,
43,
47,
59,
61,
53,
67,
69,
53,
75,
77,
87,
89,
91,
97,
99,
101,
103,
105,
107,
111,
113,
115,
117,
127,
129,
131,
137,
139,
141,
143,
147,
149,
155,
163,
165,
167
]
} | int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)
{
const char *VAR_3;
const char *VAR_4;
int VAR_5;
VAR_4 = qemu_opt_get(VAR_0, "VAR_4");
if (!VAR_4) {
error_set(VAR_2, QERR_MISSING_PARAMETER, "VAR_4");
return -1;
}
if (VAR_1) {
if (strcmp(VAR_4, "tap") != 0 &&
#ifdef CONFIG_NET_BRIDGE
strcmp(VAR_4, "bridge") != 0 &&
#endif
#ifdef CONFIG_SLIRP
strcmp(VAR_4, "user") != 0 &&
#endif
#ifdef CONFIG_VDE
strcmp(VAR_4, "vde") != 0 &&
#endif
strcmp(VAR_4, "socket") != 0) {
error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a netdev backend VAR_4");
return -1;
}
if (qemu_opt_get(VAR_0, "vlan")) {
error_set(VAR_2, QERR_INVALID_PARAMETER, "vlan");
return -1;
}
if (qemu_opt_get(VAR_0, "VAR_3")) {
error_set(VAR_2, QERR_INVALID_PARAMETER, "VAR_3");
return -1;
}
if (!qemu_opts_id(VAR_0)) {
error_set(VAR_2, QERR_MISSING_PARAMETER, "id");
return -1;
}
}
VAR_3 = qemu_opts_id(VAR_0);
if (!VAR_3) {
VAR_3 = qemu_opt_get(VAR_0, "VAR_3");
}
for (VAR_5 = 0; VAR_5 < NET_CLIENT_OPTIONS_KIND_MAX; VAR_5++) {
if (net_client_types[VAR_5].VAR_4 != NULL &&
!strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) {
Error *local_err = NULL;
VLANState *vlan = NULL;
int ret;
qemu_opts_validate(VAR_0, &net_client_types[VAR_5].desc[0], &local_err);
if (error_is_set(&local_err)) {
error_propagate(VAR_2, local_err);
return -1;
}
if (!(VAR_1 ||
(strcmp(VAR_4, "nic") == 0 && qemu_opt_get(VAR_0, "netdev")))) {
vlan = qemu_find_vlan(qemu_opt_get_number(VAR_0, "vlan", 0), 1);
}
ret = 0;
if (net_client_types[VAR_5].init) {
ret = net_client_types[VAR_5].init(VAR_0, VAR_3, vlan);
if (ret < 0) {
error_set(VAR_2, QERR_DEVICE_INIT_FAILED, VAR_4);
return -1;
}
}
return ret;
}
}
error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a network client VAR_4");
return -1;
}
| [
"int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)\n{",
"const char *VAR_3;",
"const char *VAR_4;",
"int VAR_5;",
"VAR_4 = qemu_opt_get(VAR_0, \"VAR_4\");",
"if (!VAR_4) {",
"error_set(VAR_2, QERR_MISSING_PARAMETER, \"VAR_4\");",
"return -1;",
"}",
"if (VAR_1) {",
"if (strcmp(VAR_4, \"tap\") != 0 &&\n#ifdef CONFIG_NET_BRIDGE\nstrcmp(VAR_4, \"bridge\") != 0 &&\n#endif\n#ifdef CONFIG_SLIRP\nstrcmp(VAR_4, \"user\") != 0 &&\n#endif\n#ifdef CONFIG_VDE\nstrcmp(VAR_4, \"vde\") != 0 &&\n#endif\nstrcmp(VAR_4, \"socket\") != 0) {",
"error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, \"VAR_4\",\n\"a netdev backend VAR_4\");",
"return -1;",
"}",
"if (qemu_opt_get(VAR_0, \"vlan\")) {",
"error_set(VAR_2, QERR_INVALID_PARAMETER, \"vlan\");",
"return -1;",
"}",
"if (qemu_opt_get(VAR_0, \"VAR_3\")) {",
"error_set(VAR_2, QERR_INVALID_PARAMETER, \"VAR_3\");",
"return -1;",
"}",
"if (!qemu_opts_id(VAR_0)) {",
"error_set(VAR_2, QERR_MISSING_PARAMETER, \"id\");",
"return -1;",
"}",
"}",
"VAR_3 = qemu_opts_id(VAR_0);",
"if (!VAR_3) {",
"VAR_3 = qemu_opt_get(VAR_0, \"VAR_3\");",
"}",
"for (VAR_5 = 0; VAR_5 < NET_CLIENT_OPTIONS_KIND_MAX; VAR_5++) {",
"if (net_client_types[VAR_5].VAR_4 != NULL &&\n!strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) {",
"Error *local_err = NULL;",
"VLANState *vlan = NULL;",
"int ret;",
"qemu_opts_validate(VAR_0, &net_client_types[VAR_5].desc[0], &local_err);",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_2, local_err);",
"return -1;",
"}",
"if (!(VAR_1 ||\n(strcmp(VAR_4, \"nic\") == 0 && qemu_opt_get(VAR_0, \"netdev\")))) {",
"vlan = qemu_find_vlan(qemu_opt_get_number(VAR_0, \"vlan\", 0), 1);",
"}",
"ret = 0;",
"if (net_client_types[VAR_5].init) {",
"ret = net_client_types[VAR_5].init(VAR_0, VAR_3, vlan);",
"if (ret < 0) {",
"error_set(VAR_2, QERR_DEVICE_INIT_FAILED, VAR_4);",
"return -1;",
"}",
"}",
"return ret;",
"}",
"}",
"error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, \"VAR_4\",\n\"a network client VAR_4\");",
"return -1;",
"}"
] | [
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
1,
0,
1,
1,
0,
0,
1,
1,
0,
0,
1,
1,
0,
0,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
127,
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163,
165
],
[
167
],
[
169
]
] |
19,061 | static void usbredir_handle_interrupt_out_data(USBRedirDevice *dev,
USBPacket *p, uint8_t ep)
{
/* Output interrupt endpoint, normal async operation */
struct usb_redir_interrupt_packet_header interrupt_packet;
uint8_t buf[p->iov.size];
DPRINTF("interrupt-out ep %02X len %zd id %"PRIu64"\n", ep,
p->iov.size, p->id);
if (usbredir_already_in_flight(dev, p->id)) {
p->status = USB_RET_ASYNC;
return;
}
interrupt_packet.endpoint = ep;
interrupt_packet.length = p->iov.size;
usb_packet_copy(p, buf, p->iov.size);
usbredir_log_data(dev, "interrupt data out:", buf, p->iov.size);
usbredirparser_send_interrupt_packet(dev->parser, p->id,
&interrupt_packet, buf, p->iov.size);
usbredirparser_do_write(dev->parser);
p->status = USB_RET_ASYNC;
}
| true | qemu | 723aedd53281cfa0997457cb156a59909a75f5a8 | static void usbredir_handle_interrupt_out_data(USBRedirDevice *dev,
USBPacket *p, uint8_t ep)
{
struct usb_redir_interrupt_packet_header interrupt_packet;
uint8_t buf[p->iov.size];
DPRINTF("interrupt-out ep %02X len %zd id %"PRIu64"\n", ep,
p->iov.size, p->id);
if (usbredir_already_in_flight(dev, p->id)) {
p->status = USB_RET_ASYNC;
return;
}
interrupt_packet.endpoint = ep;
interrupt_packet.length = p->iov.size;
usb_packet_copy(p, buf, p->iov.size);
usbredir_log_data(dev, "interrupt data out:", buf, p->iov.size);
usbredirparser_send_interrupt_packet(dev->parser, p->id,
&interrupt_packet, buf, p->iov.size);
usbredirparser_do_write(dev->parser);
p->status = USB_RET_ASYNC;
}
| {
"code": [
" if (usbredir_already_in_flight(dev, p->id)) {",
" p->status = USB_RET_ASYNC;",
" p->status = USB_RET_ASYNC;"
],
"line_no": [
21,
23,
47
]
} | static void FUNC_0(USBRedirDevice *VAR_0,
USBPacket *VAR_1, uint8_t VAR_2)
{
struct usb_redir_interrupt_packet_header VAR_3;
uint8_t buf[VAR_1->iov.size];
DPRINTF("interrupt-out VAR_2 %02X len %zd id %"PRIu64"\n", VAR_2,
VAR_1->iov.size, VAR_1->id);
if (usbredir_already_in_flight(VAR_0, VAR_1->id)) {
VAR_1->status = USB_RET_ASYNC;
return;
}
VAR_3.endpoint = VAR_2;
VAR_3.length = VAR_1->iov.size;
usb_packet_copy(VAR_1, buf, VAR_1->iov.size);
usbredir_log_data(VAR_0, "interrupt data out:", buf, VAR_1->iov.size);
usbredirparser_send_interrupt_packet(VAR_0->parser, VAR_1->id,
&VAR_3, buf, VAR_1->iov.size);
usbredirparser_do_write(VAR_0->parser);
VAR_1->status = USB_RET_ASYNC;
}
| [
"static void FUNC_0(USBRedirDevice *VAR_0,\nUSBPacket *VAR_1, uint8_t VAR_2)\n{",
"struct usb_redir_interrupt_packet_header VAR_3;",
"uint8_t buf[VAR_1->iov.size];",
"DPRINTF(\"interrupt-out VAR_2 %02X len %zd id %\"PRIu64\"\\n\", VAR_2,\nVAR_1->iov.size, VAR_1->id);",
"if (usbredir_already_in_flight(VAR_0, VAR_1->id)) {",
"VAR_1->status = USB_RET_ASYNC;",
"return;",
"}",
"VAR_3.endpoint = VAR_2;",
"VAR_3.length = VAR_1->iov.size;",
"usb_packet_copy(VAR_1, buf, VAR_1->iov.size);",
"usbredir_log_data(VAR_0, \"interrupt data out:\", buf, VAR_1->iov.size);",
"usbredirparser_send_interrupt_packet(VAR_0->parser, VAR_1->id,\n&VAR_3, buf, VAR_1->iov.size);",
"usbredirparser_do_write(VAR_0->parser);",
"VAR_1->status = USB_RET_ASYNC;",
"}"
] | [
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
]
] |
19,063 | static void push_output_configuration(AACContext *ac) {
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
ac->oc[0] = ac->oc[1];
}
ac->oc[1].status = OC_NONE;
}
| true | FFmpeg | a5e0dbf530d447f36099aed575b34e9258c5d75a | static void push_output_configuration(AACContext *ac) {
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
ac->oc[0] = ac->oc[1];
}
ac->oc[1].status = OC_NONE;
}
| {
"code": [
"static void push_output_configuration(AACContext *ac) {"
],
"line_no": [
1
]
} | static void FUNC_0(AACContext *VAR_0) {
if (VAR_0->oc[1].status == OC_LOCKED || VAR_0->oc[0].status == OC_NONE) {
VAR_0->oc[0] = VAR_0->oc[1];
}
VAR_0->oc[1].status = OC_NONE;
}
| [
"static void FUNC_0(AACContext *VAR_0) {",
"if (VAR_0->oc[1].status == OC_LOCKED || VAR_0->oc[0].status == OC_NONE) {",
"VAR_0->oc[0] = VAR_0->oc[1];",
"}",
"VAR_0->oc[1].status = OC_NONE;",
"}"
] | [
1,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
19,064 | dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
enum dshowDeviceType devtype, IBaseFilter **pfilter)
{
struct dshow_ctx *ctx = avctx->priv_data;
IBaseFilter *device_filter = NULL;
IEnumMoniker *classenum = NULL;
IMoniker *m = NULL;
const char *device_name = ctx->device_name[devtype];
int r;
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
&CLSID_AudioInputDeviceCategory };
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[devtype],
(IEnumMoniker **) &classenum, 0);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices.\n",
devtypename);
return AVERROR(EIO);
}
while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) {
IPropertyBag *bag = NULL;
char *buf = NULL;
VARIANT var;
r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);
if (r != S_OK)
goto fail1;
var.vt = VT_BSTR;
r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL);
if (r != S_OK)
goto fail1;
buf = dup_wchar_to_utf8(var.bstrVal);
if (pfilter) {
if (strcmp(device_name, buf))
goto fail1;
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
} else {
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf);
}
fail1:
if (buf)
av_free(buf);
if (bag)
IPropertyBag_Release(bag);
IMoniker_Release(m);
}
IEnumMoniker_Release(classenum);
if (pfilter) {
if (!device_filter) {
av_log(avctx, AV_LOG_ERROR, "Could not find %s device.\n",
devtypename);
return AVERROR(EIO);
}
*pfilter = device_filter;
}
return 0;
}
| true | FFmpeg | 215e197942e33d5c5749d786e938bf7abe856c1d | dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
enum dshowDeviceType devtype, IBaseFilter **pfilter)
{
struct dshow_ctx *ctx = avctx->priv_data;
IBaseFilter *device_filter = NULL;
IEnumMoniker *classenum = NULL;
IMoniker *m = NULL;
const char *device_name = ctx->device_name[devtype];
int r;
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
&CLSID_AudioInputDeviceCategory };
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[devtype],
(IEnumMoniker **) &classenum, 0);
if (r != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices.\n",
devtypename);
return AVERROR(EIO);
}
while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) {
IPropertyBag *bag = NULL;
char *buf = NULL;
VARIANT var;
r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);
if (r != S_OK)
goto fail1;
var.vt = VT_BSTR;
r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL);
if (r != S_OK)
goto fail1;
buf = dup_wchar_to_utf8(var.bstrVal);
if (pfilter) {
if (strcmp(device_name, buf))
goto fail1;
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
} else {
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf);
}
fail1:
if (buf)
av_free(buf);
if (bag)
IPropertyBag_Release(bag);
IMoniker_Release(m);
}
IEnumMoniker_Release(classenum);
if (pfilter) {
if (!device_filter) {
av_log(avctx, AV_LOG_ERROR, "Could not find %s device.\n",
devtypename);
return AVERROR(EIO);
}
*pfilter = device_filter;
}
return 0;
}
| {
"code": [
" while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) {"
],
"line_no": [
45
]
} | FUNC_0(AVFormatContext *VAR_0, ICreateDevEnum *VAR_1,
enum dshowDeviceType VAR_2, IBaseFilter **VAR_3)
{
struct dshow_ctx *VAR_4 = VAR_0->priv_data;
IBaseFilter *device_filter = NULL;
IEnumMoniker *classenum = NULL;
IMoniker *m = NULL;
const char *VAR_5 = VAR_4->VAR_5[VAR_2];
int VAR_6;
const GUID *VAR_7[2] = { &CLSID_VideoInputDeviceCategory,
&CLSID_AudioInputDeviceCategory };
const char *VAR_8 = (VAR_2 == VideoDevice) ? "video" : "audio";
VAR_6 = ICreateDevEnum_CreateClassEnumerator(VAR_1, VAR_7[VAR_2],
(IEnumMoniker **) &classenum, 0);
if (VAR_6 != S_OK) {
av_log(VAR_0, AV_LOG_ERROR, "Could not enumerate %s devices.\n",
VAR_8);
return AVERROR(EIO);
}
while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) {
IPropertyBag *bag = NULL;
char *VAR_9 = NULL;
VARIANT var;
VAR_6 = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);
if (VAR_6 != S_OK)
goto fail1;
var.vt = VT_BSTR;
VAR_6 = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL);
if (VAR_6 != S_OK)
goto fail1;
VAR_9 = dup_wchar_to_utf8(var.bstrVal);
if (VAR_3) {
if (strcmp(VAR_5, VAR_9))
goto fail1;
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
} else {
av_log(VAR_0, AV_LOG_INFO, " \"%s\"\n", VAR_9);
}
fail1:
if (VAR_9)
av_free(VAR_9);
if (bag)
IPropertyBag_Release(bag);
IMoniker_Release(m);
}
IEnumMoniker_Release(classenum);
if (VAR_3) {
if (!device_filter) {
av_log(VAR_0, AV_LOG_ERROR, "Could not find %s device.\n",
VAR_8);
return AVERROR(EIO);
}
*VAR_3 = device_filter;
}
return 0;
}
| [
"FUNC_0(AVFormatContext *VAR_0, ICreateDevEnum *VAR_1,\nenum dshowDeviceType VAR_2, IBaseFilter **VAR_3)\n{",
"struct dshow_ctx *VAR_4 = VAR_0->priv_data;",
"IBaseFilter *device_filter = NULL;",
"IEnumMoniker *classenum = NULL;",
"IMoniker *m = NULL;",
"const char *VAR_5 = VAR_4->VAR_5[VAR_2];",
"int VAR_6;",
"const GUID *VAR_7[2] = { &CLSID_VideoInputDeviceCategory,",
"&CLSID_AudioInputDeviceCategory };",
"const char *VAR_8 = (VAR_2 == VideoDevice) ? \"video\" : \"audio\";",
"VAR_6 = ICreateDevEnum_CreateClassEnumerator(VAR_1, VAR_7[VAR_2],\n(IEnumMoniker **) &classenum, 0);",
"if (VAR_6 != S_OK) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not enumerate %s devices.\\n\",\nVAR_8);",
"return AVERROR(EIO);",
"}",
"while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) {",
"IPropertyBag *bag = NULL;",
"char *VAR_9 = NULL;",
"VARIANT var;",
"VAR_6 = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag);",
"if (VAR_6 != S_OK)\ngoto fail1;",
"var.vt = VT_BSTR;",
"VAR_6 = IPropertyBag_Read(bag, L\"FriendlyName\", &var, NULL);",
"if (VAR_6 != S_OK)\ngoto fail1;",
"VAR_9 = dup_wchar_to_utf8(var.bstrVal);",
"if (VAR_3) {",
"if (strcmp(VAR_5, VAR_9))\ngoto fail1;",
"IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);",
"} else {",
"av_log(VAR_0, AV_LOG_INFO, \" \\\"%s\\\"\\n\", VAR_9);",
"}",
"fail1:\nif (VAR_9)\nav_free(VAR_9);",
"if (bag)\nIPropertyBag_Release(bag);",
"IMoniker_Release(m);",
"}",
"IEnumMoniker_Release(classenum);",
"if (VAR_3) {",
"if (!device_filter) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not find %s device.\\n\",\nVAR_8);",
"return AVERROR(EIO);",
"}",
"*VAR_3 = device_filter;",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
63
],
[
65
],
[
67,
69
],
[
73
],
[
77
],
[
79,
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
]
] |
19,066 | pp_context *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= av_mallocz(sizeof(PPContext));
int stride= FFALIGN(width, 16); //assumed / will realloc if needed
int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed
c->av_class = &av_codec_context_class;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
if (cpuCaps & PP_CPU_CAPS_AUTO) {
c->cpuCaps = av_get_cpu_flags();
} else {
c->cpuCaps = 0;
if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
}
reallocBuffers(c, width, height, stride, qpStride);
c->frameNum=-1;
return c;
} | true | FFmpeg | ac424b23e404a53bb88e36496fac94d2ff9dd775 | pp_context *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= av_mallocz(sizeof(PPContext));
int stride= FFALIGN(width, 16);
int qpStride= (width+15)/16 + 2;
c->av_class = &av_codec_context_class;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
if (cpuCaps & PP_CPU_CAPS_AUTO) {
c->cpuCaps = av_get_cpu_flags();
} else {
c->cpuCaps = 0;
if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
}
reallocBuffers(c, width, height, stride, qpStride);
c->frameNum=-1;
return c;
} | {
"code": [],
"line_no": []
} | pp_context *FUNC_0(int width, int height, int cpuCaps){
PPContext *c= av_mallocz(sizeof(PPContext));
int VAR_0= FFALIGN(width, 16);
int VAR_1= (width+15)/16 + 2;
c->av_class = &av_codec_context_class;
if(cpuCaps&PP_FORMAT){
c->hChromaSubSample= cpuCaps&0x3;
c->vChromaSubSample= (cpuCaps>>4)&0x3;
}else{
c->hChromaSubSample= 1;
c->vChromaSubSample= 1;
}
if (cpuCaps & PP_CPU_CAPS_AUTO) {
c->cpuCaps = av_get_cpu_flags();
} else {
c->cpuCaps = 0;
if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;
if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;
if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
}
reallocBuffers(c, width, height, VAR_0, VAR_1);
c->frameNum=-1;
return c;
} | [
"pp_context *FUNC_0(int width, int height, int cpuCaps){",
"PPContext *c= av_mallocz(sizeof(PPContext));",
"int VAR_0= FFALIGN(width, 16);",
"int VAR_1= (width+15)/16 + 2;",
"c->av_class = &av_codec_context_class;",
"if(cpuCaps&PP_FORMAT){",
"c->hChromaSubSample= cpuCaps&0x3;",
"c->vChromaSubSample= (cpuCaps>>4)&0x3;",
"}else{",
"c->hChromaSubSample= 1;",
"c->vChromaSubSample= 1;",
"}",
"if (cpuCaps & PP_CPU_CAPS_AUTO) {",
"c->cpuCaps = av_get_cpu_flags();",
"} else {",
"c->cpuCaps = 0;",
"if (cpuCaps & PP_CPU_CAPS_MMX) c->cpuCaps |= AV_CPU_FLAG_MMX;",
"if (cpuCaps & PP_CPU_CAPS_MMX2) c->cpuCaps |= AV_CPU_FLAG_MMXEXT;",
"if (cpuCaps & PP_CPU_CAPS_3DNOW) c->cpuCaps |= AV_CPU_FLAG_3DNOW;",
"if (cpuCaps & PP_CPU_CAPS_ALTIVEC) c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;",
"}",
"reallocBuffers(c, width, height, VAR_0, VAR_1);",
"c->frameNum=-1;",
"return c;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
]
] |
19,067 | static void store_slice_c(uint8_t *dst, const int16_t *src,
int dst_stride, int src_stride,
int width, int height, int log2_scale)
{
int y, x;
#define STORE(pos) do { \
temp = ((src[x + y * src_stride + pos] << log2_scale) + d[pos]) >> 8; \
if (temp & 0x100) temp = ~(temp >> 31); \
dst[x + y * dst_stride + pos] = temp; \
} while (0)
for (y = 0; y < height; y++) {
const uint8_t *d = dither[y&7];
for (x = 0; x < width; x += 8) {
int temp;
STORE(0);
STORE(1);
STORE(2);
STORE(3);
STORE(4);
STORE(5);
STORE(6);
STORE(7);
}
}
}
| true | FFmpeg | e07c82688e8187dbafac489b7c15427252974021 | static void store_slice_c(uint8_t *dst, const int16_t *src,
int dst_stride, int src_stride,
int width, int height, int log2_scale)
{
int y, x;
#define STORE(pos) do { \
temp = ((src[x + y * src_stride + pos] << log2_scale) + d[pos]) >> 8; \
if (temp & 0x100) temp = ~(temp >> 31); \
dst[x + y * dst_stride + pos] = temp; \
} while (0)
for (y = 0; y < height; y++) {
const uint8_t *d = dither[y&7];
for (x = 0; x < width; x += 8) {
int temp;
STORE(0);
STORE(1);
STORE(2);
STORE(3);
STORE(4);
STORE(5);
STORE(6);
STORE(7);
}
}
}
| {
"code": [
"static void store_slice_c(uint8_t *dst, const int16_t *src,"
],
"line_no": [
1
]
} | static void FUNC_0(uint8_t *VAR_0, const int16_t *VAR_1,
int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{
int VAR_7, VAR_8;
#define STORE(pos) do { \
temp = ((VAR_1[VAR_8 + VAR_7 * VAR_3 + pos] << VAR_6) + d[pos]) >> 8; \
if (temp & 0x100) temp = ~(temp >> 31); \
VAR_0[VAR_8 + VAR_7 * VAR_2 + pos] = temp; \
} while (0)
for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {
const uint8_t *d = dither[VAR_7&7];
for (VAR_8 = 0; VAR_8 < VAR_4; VAR_8 += 8) {
int temp;
STORE(0);
STORE(1);
STORE(2);
STORE(3);
STORE(4);
STORE(5);
STORE(6);
STORE(7);
}
}
}
| [
"static void FUNC_0(uint8_t *VAR_0, const int16_t *VAR_1,\nint VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7, VAR_8;",
"#define STORE(pos) do { \\",
"temp = ((VAR_1[VAR_8 + VAR_7 * VAR_3 + pos] << VAR_6) + d[pos]) >> 8; \\",
"if (temp & 0x100) temp = ~(temp >> 31); \\",
"VAR_0[VAR_8 + VAR_7 * VAR_2 + pos] = temp; \\",
"} while (0)",
"for (VAR_7 = 0; VAR_7 < VAR_5; VAR_7++) {",
"const uint8_t *d = dither[VAR_7&7];",
"for (VAR_8 = 0; VAR_8 < VAR_4; VAR_8 += 8) {",
"int temp;",
"STORE(0);",
"STORE(1);",
"STORE(2);",
"STORE(3);",
"STORE(4);",
"STORE(5);",
"STORE(6);",
"STORE(7);",
"}",
"}",
"}"
] | [
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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
19,068 | void helper_fxtract(void)
{
CPU86_LDoubleU temp;
unsigned int expdif;
temp.d = ST0;
expdif = EXPD(temp) - EXPBIAS;
/*DP exponent bias*/
ST0 = expdif;
fpush();
BIASEXPONENT(temp);
ST0 = temp.d;
}
| true | qemu | c9ad19c57b4e35dda507ec636443069048a4ad72 | void helper_fxtract(void)
{
CPU86_LDoubleU temp;
unsigned int expdif;
temp.d = ST0;
expdif = EXPD(temp) - EXPBIAS;
ST0 = expdif;
fpush();
BIASEXPONENT(temp);
ST0 = temp.d;
}
| {
"code": [
" unsigned int expdif;",
" expdif = EXPD(temp) - EXPBIAS;",
" ST0 = expdif;",
" fpush();",
" BIASEXPONENT(temp);",
" ST0 = temp.d;"
],
"line_no": [
7,
13,
17,
19,
21,
23
]
} | void FUNC_0(void)
{
CPU86_LDoubleU temp;
unsigned int VAR_0;
temp.d = ST0;
VAR_0 = EXPD(temp) - EXPBIAS;
ST0 = VAR_0;
fpush();
BIASEXPONENT(temp);
ST0 = temp.d;
}
| [
"void FUNC_0(void)\n{",
"CPU86_LDoubleU temp;",
"unsigned int VAR_0;",
"temp.d = ST0;",
"VAR_0 = EXPD(temp) - EXPBIAS;",
"ST0 = VAR_0;",
"fpush();",
"BIASEXPONENT(temp);",
"ST0 = temp.d;",
"}"
] | [
0,
0,
1,
0,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
19,069 | static void usb_msd_cancel_io(USBPacket *p, void *opaque)
{
MSDState *s = opaque;
s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);
s->packet = NULL;
s->scsi_len = 0;
}
| true | qemu | 5c6c0e513600ba57c3e73b7151d3c0664438f7b5 | static void usb_msd_cancel_io(USBPacket *p, void *opaque)
{
MSDState *s = opaque;
s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);
s->packet = NULL;
s->scsi_len = 0;
}
| {
"code": [
" s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);"
],
"line_no": [
7
]
} | static void FUNC_0(USBPacket *VAR_0, void *VAR_1)
{
MSDState *s = VAR_1;
s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);
s->packet = NULL;
s->scsi_len = 0;
}
| [
"static void FUNC_0(USBPacket *VAR_0, void *VAR_1)\n{",
"MSDState *s = VAR_1;",
"s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);",
"s->packet = NULL;",
"s->scsi_len = 0;",
"}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
19,070 | static CharDriverState *qmp_chardev_open_udp(ChardevUdp *udp,
Error **errp)
{
int fd;
fd = socket_dgram(udp->remote, udp->local, errp);
if (error_is_set(errp)) {
return NULL;
}
return qemu_chr_open_udp_fd(fd);
}
| true | qemu | 5f758366c0710d23e43f4d0f83816b98616a13d0 | static CharDriverState *qmp_chardev_open_udp(ChardevUdp *udp,
Error **errp)
{
int fd;
fd = socket_dgram(udp->remote, udp->local, errp);
if (error_is_set(errp)) {
return NULL;
}
return qemu_chr_open_udp_fd(fd);
}
| {
"code": [
" if (error_is_set(errp)) {",
" if (error_is_set(errp)) {",
" if (error_is_set(errp)) {",
" if (error_is_set(errp)) {",
" if (error_is_set(errp)) {"
],
"line_no": [
13,
13,
13,
13,
13
]
} | static CharDriverState *FUNC_0(ChardevUdp *udp,
Error **errp)
{
int VAR_0;
VAR_0 = socket_dgram(udp->remote, udp->local, errp);
if (error_is_set(errp)) {
return NULL;
}
return qemu_chr_open_udp_fd(VAR_0);
}
| [
"static CharDriverState *FUNC_0(ChardevUdp *udp,\nError **errp)\n{",
"int VAR_0;",
"VAR_0 = socket_dgram(udp->remote, udp->local, errp);",
"if (error_is_set(errp)) {",
"return NULL;",
"}",
"return qemu_chr_open_udp_fd(VAR_0);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
19,071 | static av_always_inline void MPV_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int is_mpeg12)
{
int i;
int mb_y = s->mb_y;
prefetch_motion(s, ref_picture, dir);
if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {
apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
return;
}
switch (s->mv_type) {
case MV_TYPE_16X16:
if (s->mcsel) {
if (s->real_sprite_warping_points == 1) {
gmc1_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
} else {
gmc_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
}
} else if (!is_mpeg12 && s->quarter_sample) {
qpel_motion(s, dest_y, dest_cb, dest_cr,
0, 0, 0,
ref_picture, pix_op, qpix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else {
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
}
break;
case MV_TYPE_8X8:
if (!is_mpeg12)
apply_8x8(s, dest_y, dest_cb, dest_cr,
dir, ref_picture, qpix_op, pix_op);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
if (!is_mpeg12 && s->quarter_sample) {
for (i = 0; i < 2; i++)
qpel_motion(s, dest_y, dest_cb, dest_cr,
1, i, s->field_select[dir][i],
ref_picture, pix_op, qpix_op,
s->mv[dir][i][0], s->mv[dir][i][1], 8);
} else {
/* top field */
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
/* bottom field */
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
}
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y >> 1);
}
break;
case MV_TYPE_16X8:
for (i = 0; i < 2; i++) {
uint8_t **ref2picture;
if (s->picture_structure == s->field_select[dir][i] + 1
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
ref2picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][i],
ref2picture, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i,
8, mb_y >> 1);
dest_y += 16 * s->linesize;
dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
}
break;
case MV_TYPE_DMV:
if (s->picture_structure == PICT_FRAME) {
for (i = 0; i < 2; i++) {
int j;
for (j = 0; j < 2; j++)
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
j, j ^ i, ref_picture, pix_op,
s->mv[dir][2 * i + j][0],
s->mv[dir][2 * i + j][1], 8, mb_y);
pix_op = s->hdsp.avg_pixels_tab;
}
} else {
for (i = 0; i < 2; i++) {
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->picture_structure != i + 1,
ref_picture, pix_op,
s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
16, mb_y >> 1);
// after put we make avg of the same block
pix_op = s->hdsp.avg_pixels_tab;
/* opposite parity is always in the same frame if this is
* second field */
if (!s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
}
}
break;
default: assert(0);
}
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | static av_always_inline void MPV_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int is_mpeg12)
{
int i;
int mb_y = s->mb_y;
prefetch_motion(s, ref_picture, dir);
if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {
apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
return;
}
switch (s->mv_type) {
case MV_TYPE_16X16:
if (s->mcsel) {
if (s->real_sprite_warping_points == 1) {
gmc1_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
} else {
gmc_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
}
} else if (!is_mpeg12 && s->quarter_sample) {
qpel_motion(s, dest_y, dest_cb, dest_cr,
0, 0, 0,
ref_picture, pix_op, qpix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else {
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
}
break;
case MV_TYPE_8X8:
if (!is_mpeg12)
apply_8x8(s, dest_y, dest_cb, dest_cr,
dir, ref_picture, qpix_op, pix_op);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
if (!is_mpeg12 && s->quarter_sample) {
for (i = 0; i < 2; i++)
qpel_motion(s, dest_y, dest_cb, dest_cr,
1, i, s->field_select[dir][i],
ref_picture, pix_op, qpix_op,
s->mv[dir][i][0], s->mv[dir][i][1], 8);
} else {
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
}
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y >> 1);
}
break;
case MV_TYPE_16X8:
for (i = 0; i < 2; i++) {
uint8_t **ref2picture;
if (s->picture_structure == s->field_select[dir][i] + 1
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
ref2picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][i],
ref2picture, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1] + 16 * i,
8, mb_y >> 1);
dest_y += 16 * s->linesize;
dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
}
break;
case MV_TYPE_DMV:
if (s->picture_structure == PICT_FRAME) {
for (i = 0; i < 2; i++) {
int j;
for (j = 0; j < 2; j++)
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
j, j ^ i, ref_picture, pix_op,
s->mv[dir][2 * i + j][0],
s->mv[dir][2 * i + j][1], 8, mb_y);
pix_op = s->hdsp.avg_pixels_tab;
}
} else {
for (i = 0; i < 2; i++) {
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->picture_structure != i + 1,
ref_picture, pix_op,
s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
16, mb_y >> 1);
pix_op = s->hdsp.avg_pixels_tab;
if (!s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
}
}
break;
default: assert(0);
}
}
| {
"code": [
" ref_picture = s->current_picture_ptr->f.data;",
" ref2picture = s->current_picture_ptr->f.data;",
" ref_picture = s->current_picture_ptr->f.data;"
],
"line_no": [
149,
183,
261
]
} | static av_always_inline void FUNC_0(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int dir,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int is_mpeg12)
{
int VAR_0;
int VAR_1 = s->VAR_1;
prefetch_motion(s, ref_picture, dir);
if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {
apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
return;
}
switch (s->mv_type) {
case MV_TYPE_16X16:
if (s->mcsel) {
if (s->real_sprite_warping_points == 1) {
gmc1_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
} else {
gmc_motion(s, dest_y, dest_cb, dest_cr,
ref_picture);
}
} else if (!is_mpeg12 && s->quarter_sample) {
qpel_motion(s, dest_y, dest_cb, dest_cr,
0, 0, 0,
ref_picture, pix_op, qpix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16);
} else {
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, VAR_1);
}
break;
case MV_TYPE_8X8:
if (!is_mpeg12)
apply_8x8(s, dest_y, dest_cb, dest_cr,
dir, ref_picture, qpix_op, pix_op);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
if (!is_mpeg12 && s->quarter_sample) {
for (VAR_0 = 0; VAR_0 < 2; VAR_0++)
qpel_motion(s, dest_y, dest_cb, dest_cr,
1, VAR_0, s->field_select[dir][VAR_0],
ref_picture, pix_op, qpix_op,
s->mv[dir][VAR_0][0], s->mv[dir][VAR_0][1], 8);
} else {
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, VAR_1);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, VAR_1);
}
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, VAR_1 >> 1);
}
break;
case MV_TYPE_16X8:
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
uint8_t **ref2picture;
if (s->picture_structure == s->field_select[dir][VAR_0] + 1
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
ref2picture = s->current_picture_ptr->f.data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->field_select[dir][VAR_0],
ref2picture, pix_op,
s->mv[dir][VAR_0][0], s->mv[dir][VAR_0][1] + 16 * VAR_0,
8, VAR_1 >> 1);
dest_y += 16 * s->linesize;
dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
}
break;
case MV_TYPE_DMV:
if (s->picture_structure == PICT_FRAME) {
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
int VAR_2;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++)
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
VAR_2, VAR_2 ^ VAR_0, ref_picture, pix_op,
s->mv[dir][2 * VAR_0 + VAR_2][0],
s->mv[dir][2 * VAR_0 + VAR_2][1], 8, VAR_1);
pix_op = s->hdsp.avg_pixels_tab;
}
} else {
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
mpeg_motion(s, dest_y, dest_cb, dest_cr,
s->picture_structure != VAR_0 + 1,
ref_picture, pix_op,
s->mv[dir][2 * VAR_0][0], s->mv[dir][2 * VAR_0][1],
16, VAR_1 >> 1);
pix_op = s->hdsp.avg_pixels_tab;
if (!s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
}
}
}
break;
default: assert(0);
}
}
| [
"static av_always_inline void FUNC_0(MpegEncContext *s,\nuint8_t *dest_y,\nuint8_t *dest_cb,\nuint8_t *dest_cr,\nint dir,\nuint8_t **ref_picture,\nop_pixels_func (*pix_op)[4],\nqpel_mc_func (*qpix_op)[16],\nint is_mpeg12)\n{",
"int VAR_0;",
"int VAR_1 = s->VAR_1;",
"prefetch_motion(s, ref_picture, dir);",
"if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {",
"apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);",
"return;",
"}",
"switch (s->mv_type) {",
"case MV_TYPE_16X16:\nif (s->mcsel) {",
"if (s->real_sprite_warping_points == 1) {",
"gmc1_motion(s, dest_y, dest_cb, dest_cr,\nref_picture);",
"} else {",
"gmc_motion(s, dest_y, dest_cb, dest_cr,\nref_picture);",
"}",
"} else if (!is_mpeg12 && s->quarter_sample) {",
"qpel_motion(s, dest_y, dest_cb, dest_cr,\n0, 0, 0,\nref_picture, pix_op, qpix_op,\ns->mv[dir][0][0], s->mv[dir][0][1], 16);",
"} else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&",
"s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {",
"ff_mspel_motion(s, dest_y, dest_cb, dest_cr,\nref_picture, pix_op,\ns->mv[dir][0][0], s->mv[dir][0][1], 16);",
"} else {",
"mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,\nref_picture, pix_op,\ns->mv[dir][0][0], s->mv[dir][0][1], 16, VAR_1);",
"}",
"break;",
"case MV_TYPE_8X8:\nif (!is_mpeg12)\napply_8x8(s, dest_y, dest_cb, dest_cr,\ndir, ref_picture, qpix_op, pix_op);",
"break;",
"case MV_TYPE_FIELD:\nif (s->picture_structure == PICT_FRAME) {",
"if (!is_mpeg12 && s->quarter_sample) {",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++)",
"qpel_motion(s, dest_y, dest_cb, dest_cr,\n1, VAR_0, s->field_select[dir][VAR_0],\nref_picture, pix_op, qpix_op,\ns->mv[dir][VAR_0][0], s->mv[dir][VAR_0][1], 8);",
"} else {",
"mpeg_motion_field(s, dest_y, dest_cb, dest_cr,\n0, s->field_select[dir][0],\nref_picture, pix_op,\ns->mv[dir][0][0], s->mv[dir][0][1], 8, VAR_1);",
"mpeg_motion_field(s, dest_y, dest_cb, dest_cr,\n1, s->field_select[dir][1],\nref_picture, pix_op,\ns->mv[dir][1][0], s->mv[dir][1][1], 8, VAR_1);",
"}",
"} else {",
"if (s->picture_structure != s->field_select[dir][0] + 1 &&\ns->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {",
"ref_picture = s->current_picture_ptr->f.data;",
"}",
"mpeg_motion(s, dest_y, dest_cb, dest_cr,\ns->field_select[dir][0],\nref_picture, pix_op,\ns->mv[dir][0][0], s->mv[dir][0][1], 16, VAR_1 >> 1);",
"}",
"break;",
"case MV_TYPE_16X8:\nfor (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"uint8_t **ref2picture;",
"if (s->picture_structure == s->field_select[dir][VAR_0] + 1\n|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {",
"ref2picture = ref_picture;",
"} else {",
"ref2picture = s->current_picture_ptr->f.data;",
"}",
"mpeg_motion(s, dest_y, dest_cb, dest_cr,\ns->field_select[dir][VAR_0],\nref2picture, pix_op,\ns->mv[dir][VAR_0][0], s->mv[dir][VAR_0][1] + 16 * VAR_0,\n8, VAR_1 >> 1);",
"dest_y += 16 * s->linesize;",
"dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;",
"dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;",
"}",
"break;",
"case MV_TYPE_DMV:\nif (s->picture_structure == PICT_FRAME) {",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++)",
"mpeg_motion_field(s, dest_y, dest_cb, dest_cr,\nVAR_2, VAR_2 ^ VAR_0, ref_picture, pix_op,\ns->mv[dir][2 * VAR_0 + VAR_2][0],\ns->mv[dir][2 * VAR_0 + VAR_2][1], 8, VAR_1);",
"pix_op = s->hdsp.avg_pixels_tab;",
"}",
"} else {",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"mpeg_motion(s, dest_y, dest_cb, dest_cr,\ns->picture_structure != VAR_0 + 1,\nref_picture, pix_op,\ns->mv[dir][2 * VAR_0][0], s->mv[dir][2 * VAR_0][1],\n16, VAR_1 >> 1);",
"pix_op = s->hdsp.avg_pixels_tab;",
"if (!s->first_field) {",
"ref_picture = s->current_picture_ptr->f.data;",
"}",
"}",
"}",
"break;",
"default: assert(0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
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
],
[
123,
125,
127,
129
],
[
133,
135,
137,
139
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
155,
157,
159,
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189,
191,
193,
195,
197
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
217
],
[
219
],
[
221,
223,
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239,
241,
243,
245
],
[
251
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
]
] |
19,072 | static av_cold int imc_decode_init(AVCodecContext * avctx)
{
int i, j;
IMCContext *q = avctx->priv_data;
double r1, r2;
q->decoder_reset = 1;
for(i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
/* Build mdct window, a simple sine window normalized with sqrt(2) */
ff_sine_window_init(q->mdct_sine_window, COEFFS);
for(i = 0; i < COEFFS; i++)
q->mdct_sine_window[i] *= sqrt(2.0);
for(i = 0; i < COEFFS/2; i++){
q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
if (i & 0x1)
{
q->pre_coef1[i] = (r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
}
else
{
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0);
}
q->last_fft_im[i] = 0;
}
/* Generate a square root table */
for(i = 0; i < 30; i++) {
q->sqrt_tab[i] = sqrt(i);
}
/* initialize the VLC tables */
for(i = 0; i < 4 ; i++) {
for(j = 0; j < 4; j++) {
huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]];
huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i],
imc_huffman_lens[i][j], 1, 1,
imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
}
}
q->one_div_log2 = 1/log(2);
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
| true | FFmpeg | 95fee70d6773fde1c34ff6422f48e5e66f37f263 | static av_cold int imc_decode_init(AVCodecContext * avctx)
{
int i, j;
IMCContext *q = avctx->priv_data;
double r1, r2;
q->decoder_reset = 1;
for(i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
ff_sine_window_init(q->mdct_sine_window, COEFFS);
for(i = 0; i < COEFFS; i++)
q->mdct_sine_window[i] *= sqrt(2.0);
for(i = 0; i < COEFFS/2; i++){
q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
if (i & 0x1)
{
q->pre_coef1[i] = (r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
}
else
{
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0);
}
q->last_fft_im[i] = 0;
}
for(i = 0; i < 30; i++) {
q->sqrt_tab[i] = sqrt(i);
}
for(i = 0; i < 4 ; i++) {
for(j = 0; j < 4; j++) {
huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]];
huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j];
init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i],
imc_huffman_lens[i][j], 1, 1,
imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
}
}
q->one_div_log2 = 1/log(2);
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
| {
"code": [
" int i, j;",
" ff_fft_init(&q->fft, 7, 1);"
],
"line_no": [
5,
109
]
} | static av_cold int FUNC_0(AVCodecContext * avctx)
{
int VAR_0, VAR_1;
IMCContext *q = avctx->priv_data;
double VAR_2, VAR_3;
q->decoder_reset = 1;
for(VAR_0 = 0; VAR_0 < BANDS; VAR_0++)
q->old_floor[VAR_0] = 1.0;
ff_sine_window_init(q->mdct_sine_window, COEFFS);
for(VAR_0 = 0; VAR_0 < COEFFS; VAR_0++)
q->mdct_sine_window[VAR_0] *= sqrt(2.0);
for(VAR_0 = 0; VAR_0 < COEFFS/2; VAR_0++){
q->post_cos[VAR_0] = (1.0f / 32768) * cos(VAR_0 / 256.0 * M_PI);
q->post_sin[VAR_0] = (1.0f / 32768) * sin(VAR_0 / 256.0 * M_PI);
VAR_2 = sin((VAR_0 * 4.0 + 1.0) / 1024.0 * M_PI);
VAR_3 = cos((VAR_0 * 4.0 + 1.0) / 1024.0 * M_PI);
if (VAR_0 & 0x1)
{
q->pre_coef1[VAR_0] = (VAR_2 + VAR_3) * sqrt(2.0);
q->pre_coef2[VAR_0] = -(VAR_2 - VAR_3) * sqrt(2.0);
}
else
{
q->pre_coef1[VAR_0] = -(VAR_2 + VAR_3) * sqrt(2.0);
q->pre_coef2[VAR_0] = (VAR_2 - VAR_3) * sqrt(2.0);
}
q->last_fft_im[VAR_0] = 0;
}
for(VAR_0 = 0; VAR_0 < 30; VAR_0++) {
q->sqrt_tab[VAR_0] = sqrt(VAR_0);
}
for(VAR_0 = 0; VAR_0 < 4 ; VAR_0++) {
for(VAR_1 = 0; VAR_1 < 4; VAR_1++) {
huffman_vlc[VAR_0][VAR_1].table = &vlc_tables[vlc_offsets[VAR_0 * 4 + VAR_1]];
huffman_vlc[VAR_0][VAR_1].table_allocated = vlc_offsets[VAR_0 * 4 + VAR_1 + 1] - vlc_offsets[VAR_0 * 4 + VAR_1];
init_vlc(&huffman_vlc[VAR_0][VAR_1], 9, imc_huffman_sizes[VAR_0],
imc_huffman_lens[VAR_0][VAR_1], 1, 1,
imc_huffman_bits[VAR_0][VAR_1], 2, 2, INIT_VLC_USE_NEW_STATIC);
}
}
q->one_div_log2 = 1/log(2);
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext * avctx)\n{",
"int VAR_0, VAR_1;",
"IMCContext *q = avctx->priv_data;",
"double VAR_2, VAR_3;",
"q->decoder_reset = 1;",
"for(VAR_0 = 0; VAR_0 < BANDS; VAR_0++)",
"q->old_floor[VAR_0] = 1.0;",
"ff_sine_window_init(q->mdct_sine_window, COEFFS);",
"for(VAR_0 = 0; VAR_0 < COEFFS; VAR_0++)",
"q->mdct_sine_window[VAR_0] *= sqrt(2.0);",
"for(VAR_0 = 0; VAR_0 < COEFFS/2; VAR_0++){",
"q->post_cos[VAR_0] = (1.0f / 32768) * cos(VAR_0 / 256.0 * M_PI);",
"q->post_sin[VAR_0] = (1.0f / 32768) * sin(VAR_0 / 256.0 * M_PI);",
"VAR_2 = sin((VAR_0 * 4.0 + 1.0) / 1024.0 * M_PI);",
"VAR_3 = cos((VAR_0 * 4.0 + 1.0) / 1024.0 * M_PI);",
"if (VAR_0 & 0x1)\n{",
"q->pre_coef1[VAR_0] = (VAR_2 + VAR_3) * sqrt(2.0);",
"q->pre_coef2[VAR_0] = -(VAR_2 - VAR_3) * sqrt(2.0);",
"}",
"else\n{",
"q->pre_coef1[VAR_0] = -(VAR_2 + VAR_3) * sqrt(2.0);",
"q->pre_coef2[VAR_0] = (VAR_2 - VAR_3) * sqrt(2.0);",
"}",
"q->last_fft_im[VAR_0] = 0;",
"}",
"for(VAR_0 = 0; VAR_0 < 30; VAR_0++) {",
"q->sqrt_tab[VAR_0] = sqrt(VAR_0);",
"}",
"for(VAR_0 = 0; VAR_0 < 4 ; VAR_0++) {",
"for(VAR_1 = 0; VAR_1 < 4; VAR_1++) {",
"huffman_vlc[VAR_0][VAR_1].table = &vlc_tables[vlc_offsets[VAR_0 * 4 + VAR_1]];",
"huffman_vlc[VAR_0][VAR_1].table_allocated = vlc_offsets[VAR_0 * 4 + VAR_1 + 1] - vlc_offsets[VAR_0 * 4 + VAR_1];",
"init_vlc(&huffman_vlc[VAR_0][VAR_1], 9, imc_huffman_sizes[VAR_0],\nimc_huffman_lens[VAR_0][VAR_1], 1, 1,\nimc_huffman_bits[VAR_0][VAR_1], 2, 2, INIT_VLC_USE_NEW_STATIC);",
"}",
"}",
"q->one_div_log2 = 1/log(2);",
"ff_fft_init(&q->fft, 7, 1);",
"dsputil_init(&q->dsp, avctx);",
"avctx->sample_fmt = AV_SAMPLE_FMT_FLT;",
"avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
]
] |
19,073 | int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
int old_size;
if (!pkt->size)
return av_get_packet(s, pkt, size);
old_size = pkt->size;
ret = av_grow_packet(pkt, size);
if (ret < 0)
return ret;
ret = avio_read(s, pkt->data + old_size, size);
av_shrink_packet(pkt, old_size + FFMAX(ret, 0));
return ret;
}
| true | FFmpeg | aa3c77998404cc32233cb76e961ca27db8565459 | int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
int old_size;
if (!pkt->size)
return av_get_packet(s, pkt, size);
old_size = pkt->size;
ret = av_grow_packet(pkt, size);
if (ret < 0)
return ret;
ret = avio_read(s, pkt->data + old_size, size);
av_shrink_packet(pkt, old_size + FFMAX(ret, 0));
return ret;
}
| {
"code": [
" return ret;",
" return ret;",
" int ret;",
" int old_size;",
" old_size = pkt->size;",
" ret = av_grow_packet(pkt, size);",
" if (ret < 0)",
" return ret;",
" ret = avio_read(s, pkt->data + old_size, size);",
" av_shrink_packet(pkt, old_size + FFMAX(ret, 0));",
" return ret;"
],
"line_no": [
19,
25,
5,
7,
13,
15,
17,
19,
21,
23,
25
]
} | int FUNC_0(AVIOContext *VAR_0, AVPacket *VAR_1, int VAR_2)
{
int VAR_3;
int VAR_4;
if (!VAR_1->VAR_2)
return av_get_packet(VAR_0, VAR_1, VAR_2);
VAR_4 = VAR_1->VAR_2;
VAR_3 = av_grow_packet(VAR_1, VAR_2);
if (VAR_3 < 0)
return VAR_3;
VAR_3 = avio_read(VAR_0, VAR_1->data + VAR_4, VAR_2);
av_shrink_packet(VAR_1, VAR_4 + FFMAX(VAR_3, 0));
return VAR_3;
}
| [
"int FUNC_0(AVIOContext *VAR_0, AVPacket *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"int VAR_4;",
"if (!VAR_1->VAR_2)\nreturn av_get_packet(VAR_0, VAR_1, VAR_2);",
"VAR_4 = VAR_1->VAR_2;",
"VAR_3 = av_grow_packet(VAR_1, VAR_2);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"VAR_3 = avio_read(VAR_0, VAR_1->data + VAR_4, VAR_2);",
"av_shrink_packet(VAR_1, VAR_4 + FFMAX(VAR_3, 0));",
"return VAR_3;",
"}"
] | [
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
19,074 | int ff_j2k_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
if (ret=ff_jpeg2000_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels2decode-1, codsty->transform))
return ret;
for (i = 0; i < 2; i++)
csize *= comp->coord[i][1] - comp->coord[i][0];
comp->data = av_malloc_array(csize, sizeof(*comp->data));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
/* LOOP on resolution levels */
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
/* Compute borders for each resolution level.
* Computation of trx_0, trx_1, try_0 and try_1.
* see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
// update precincts size: 2^n value
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
/* Number of bands for each resolution level */
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
/* Number of precincts wich span the tile for resolution level reslevelno
* see B.6 in ISO/IEC 15444-1:2002 eq. B-16
* num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width)
* num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width)
* for Dcinema profiles in JPEG 2000
* num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -|
* num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| */
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
switch (qntsty->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
/* TODO: to verify. No quantization in this case */
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
/*TODO: Compute formula to implement. */
numbps = cbps +
lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SE:
/* Exponent quantization step.
* Formula:
* delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
* R_b = R_I + log2 (gain_b )
* see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
/* TODO/WARN: value of log2 (gain_b ) not taken into account
* but it works (compared to OpenJPEG). Why?
* Further investigation needed. */
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= (qntsty->mant[gbandno] / 2048.0 + 1.0);
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
/* computation of tbx_0, tbx_1, tby_0, tby_1
* see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
* codeblock width and height is computed for
* DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
if (reslevelno == 0) {
/* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height);
} else {
/* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
/* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
/* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
/* TODO: Manage case of 3 band offsets here or
* in coding/decoding function? */
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
/* TODO: Explain formula for JPEG200 DCINEMA. */
/* TODO: Verify with previous count of codeblocks per band */
/* Compute P_x0 */
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
/* Compute P_y0 */
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
/* Compute P_x1 */
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
/* Compute P_y1 */
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
/* Tag trees initialization */
prec->cblkincl =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_malloc_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
/* Compute coordinates of codeblocks */
/* Compute Cx0*/
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
/* Compute Cy0*/
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
/* Compute Cx1 */
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
/* Compute Cy1 */
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if((bandno + !!reslevelno) & 1) {
cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
}
if((bandno + !!reslevelno) & 2) {
cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| true | FFmpeg | 8bedbb82cee4463a43e60eb22674c8bf927280ef | int ff_j2k_init_component(Jpeg2000Component *comp,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int cbps, int dx, int dy,
AVCodecContext *avctx)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
if (ret=ff_jpeg2000_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels2decode-1, codsty->transform))
return ret;
for (i = 0; i < 2; i++)
csize *= comp->coord[i][1] - comp->coord[i][0];
comp->data = av_malloc_array(csize, sizeof(*comp->data));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc_array(codsty->nreslevels, sizeof(*comp->reslevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);
reslevel->log2_prec_width = codsty->log2_prec_widths[reslevelno];
reslevel->log2_prec_height = codsty->log2_prec_heights[reslevelno];
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
switch (qntsty->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
numbps = cbps +
lut_gain[codsty->transform == FF_DWT53][bandno + (reslevelno > 0)];
band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SE:
gain = cbps;
band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
band->f_stepsize *= (qntsty->mant[gbandno] / 2048.0 + 1.0);
break;
default:
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (!av_codec_is_encoder(avctx->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
if (reslevelno == 0) {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height);
} else {
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] - comp->coord_o[i][0] -
(((bandno + 1 >> i) & 1) << declvl - 1),
declvl);
band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
prec->cblkincl =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_malloc_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if((bandno + !!reslevelno) & 1) {
cblk->coord[0][0] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
cblk->coord[0][1] += comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
}
if((bandno + !!reslevelno) & 2) {
cblk->coord[1][0] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
cblk->coord[1][1] += comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| {
"code": [
" comp->data = av_malloc_array(csize, sizeof(*comp->data));",
" if (!comp->data)",
" return AVERROR(ENOMEM);",
" comp->data = av_malloc_array(csize, sizeof(*comp->data));",
" if (!comp->data)",
" return AVERROR(ENOMEM);"
],
"line_no": [
29,
31,
33,
29,
31,
33
]
} | int FUNC_0(Jpeg2000Component *VAR_0,
Jpeg2000CodingStyle *VAR_1,
Jpeg2000QuantStyle *VAR_2,
int VAR_3, int VAR_4, int VAR_5,
AVCodecContext *VAR_6)
{
uint8_t log2_band_prec_width, log2_band_prec_height;
int VAR_7, VAR_8, VAR_9 = 0, VAR_10, VAR_11, VAR_12, VAR_13 = 1;
if (VAR_10=ff_jpeg2000_dwt_init(&VAR_0->dwt, VAR_0->coord, VAR_1->nreslevels2decode-1, VAR_1->transform))
return VAR_10;
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
VAR_13 *= VAR_0->coord[VAR_11][1] - VAR_0->coord[VAR_11][0];
VAR_0->data = av_malloc_array(VAR_13, sizeof(*VAR_0->data));
if (!VAR_0->data)
return AVERROR(ENOMEM);
VAR_0->reslevel = av_malloc_array(VAR_1->nreslevels, sizeof(*VAR_0->reslevel));
if (!VAR_0->reslevel)
return AVERROR(ENOMEM);
for (VAR_7 = 0; VAR_7 < VAR_1->nreslevels; VAR_7++) {
int declvl = VAR_1->nreslevels - VAR_7;
Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_7;
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
reslevel->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12], declvl - 1);
reslevel->log2_prec_width = VAR_1->log2_prec_widths[VAR_7];
reslevel->log2_prec_height = VAR_1->log2_prec_heights[VAR_7];
if (VAR_7 == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x =
ff_jpeg2000_ceildivpow2(reslevel->coord[0][1],
reslevel->log2_prec_width) -
(reslevel->coord[0][0] >> reslevel->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y =
ff_jpeg2000_ceildivpow2(reslevel->coord[1][1],
reslevel->log2_prec_height) -
(reslevel->coord[1][0] >> reslevel->log2_prec_height);
reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (VAR_8 = 0; VAR_8 < reslevel->nbands; VAR_8++, VAR_9++) {
Jpeg2000Band *band = reslevel->band + VAR_8;
int cblkno, precno;
int nb_precincts;
switch (VAR_2->quantsty) {
uint8_t gain;
int numbps;
case JPEG2000_QSTY_NONE:
band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
numbps = VAR_3 +
lut_gain[VAR_1->transform == FF_DWT53][VAR_8 + (VAR_7 > 0)];
band->f_stepsize = SHL(2048 + VAR_2->mant[VAR_9],
2 + numbps - VAR_2->expn[VAR_9]);
break;
case JPEG2000_QSTY_SE:
gain = VAR_3;
band->f_stepsize = pow(2.0, gain - VAR_2->expn[VAR_9]);
band->f_stepsize *= (VAR_2->mant[VAR_9] / 2048.0 + 1.0);
break;
default:
band->f_stepsize = 0;
av_log(VAR_6, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
if (!av_codec_is_encoder(VAR_6->codec))
band->f_stepsize *= 0.5;
band->i_stepsize = band->f_stepsize * (1 << 16);
if (VAR_7 == 0) {
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0],
declvl - 1);
log2_band_prec_width = reslevel->log2_prec_width;
log2_band_prec_height = reslevel->log2_prec_height;
band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,
reslevel->log2_prec_width);
band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,
reslevel->log2_prec_height);
} else {
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[VAR_11][VAR_12] =
ff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0] -
(((VAR_8 + 1 >> VAR_11) & 1) << declvl - 1),
declvl);
band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,
reslevel->log2_prec_width - 1);
band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,
reslevel->log2_prec_height - 1);
log2_band_prec_width = reslevel->log2_prec_width - 1;
log2_band_prec_height = reslevel->log2_prec_height - 1;
}
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[0][VAR_12] = ff_jpeg2000_ceildiv(band->coord[0][VAR_12], VAR_4);
for (VAR_12 = 0; VAR_12 < 2; VAR_12++)
band->coord[1][VAR_12] = ff_jpeg2000_ceildiv(band->coord[1][VAR_12], VAR_5);
band->prec = av_malloc_array(reslevel->num_precincts_x *
reslevel->num_precincts_y,
sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
prec->coord[0][0] = (precno % reslevel->num_precincts_x) *
(1 << log2_band_prec_width);
prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);
prec->coord[1][0] = (precno / reslevel->num_precincts_x) *
(1 << log2_band_prec_height);
prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);
prec->coord[0][1] = prec->coord[0][0] +
(1 << log2_band_prec_width);
prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);
prec->coord[1][1] = prec->coord[1][0] +
(1 << log2_band_prec_height);
prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);
prec->nb_codeblocks_width =
ff_jpeg2000_ceildivpow2(prec->coord[0][1] -
prec->coord[0][0],
band->log2_cblk_width);
prec->nb_codeblocks_height =
ff_jpeg2000_ceildivpow2(prec->coord[1][1] -
prec->coord[1][0],
band->log2_cblk_height);
prec->cblkincl =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->cblkincl)
return AVERROR(ENOMEM);
prec->zerobits =
ff_j2k_tag_tree_init(prec->nb_codeblocks_width,
prec->nb_codeblocks_height);
if (!prec->zerobits)
return AVERROR(ENOMEM);
prec->cblk = av_malloc_array(prec->nb_codeblocks_width *
prec->nb_codeblocks_height,
sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;
Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);
cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);
Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;
Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);
cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);
cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),
prec->coord[0][1]);
cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),
prec->coord[1][1]);
if((VAR_8 + !!VAR_7) & 1) {
cblk->coord[0][0] += VAR_0->reslevel[VAR_7-1].coord[0][1] - VAR_0->reslevel[VAR_7-1].coord[0][0];
cblk->coord[0][1] += VAR_0->reslevel[VAR_7-1].coord[0][1] - VAR_0->reslevel[VAR_7-1].coord[0][0];
}
if((VAR_8 + !!VAR_7) & 2) {
cblk->coord[1][0] += VAR_0->reslevel[VAR_7-1].coord[1][1] - VAR_0->reslevel[VAR_7-1].coord[1][0];
cblk->coord[1][1] += VAR_0->reslevel[VAR_7-1].coord[1][1] - VAR_0->reslevel[VAR_7-1].coord[1][0];
}
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
}
}
}
return 0;
}
| [
"int FUNC_0(Jpeg2000Component *VAR_0,\nJpeg2000CodingStyle *VAR_1,\nJpeg2000QuantStyle *VAR_2,\nint VAR_3, int VAR_4, int VAR_5,\nAVCodecContext *VAR_6)\n{",
"uint8_t log2_band_prec_width, log2_band_prec_height;",
"int VAR_7, VAR_8, VAR_9 = 0, VAR_10, VAR_11, VAR_12, VAR_13 = 1;",
"if (VAR_10=ff_jpeg2000_dwt_init(&VAR_0->dwt, VAR_0->coord, VAR_1->nreslevels2decode-1, VAR_1->transform))\nreturn VAR_10;",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"VAR_13 *= VAR_0->coord[VAR_11][1] - VAR_0->coord[VAR_11][0];",
"VAR_0->data = av_malloc_array(VAR_13, sizeof(*VAR_0->data));",
"if (!VAR_0->data)\nreturn AVERROR(ENOMEM);",
"VAR_0->reslevel = av_malloc_array(VAR_1->nreslevels, sizeof(*VAR_0->reslevel));",
"if (!VAR_0->reslevel)\nreturn AVERROR(ENOMEM);",
"for (VAR_7 = 0; VAR_7 < VAR_1->nreslevels; VAR_7++) {",
"int declvl = VAR_1->nreslevels - VAR_7;",
"Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_7;",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"reslevel->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12], declvl - 1);",
"reslevel->log2_prec_width = VAR_1->log2_prec_widths[VAR_7];",
"reslevel->log2_prec_height = VAR_1->log2_prec_heights[VAR_7];",
"if (VAR_7 == 0)\nreslevel->nbands = 1;",
"else\nreslevel->nbands = 3;",
"if (reslevel->coord[0][1] == reslevel->coord[0][0])\nreslevel->num_precincts_x = 0;",
"else\nreslevel->num_precincts_x =\nff_jpeg2000_ceildivpow2(reslevel->coord[0][1],\nreslevel->log2_prec_width) -\n(reslevel->coord[0][0] >> reslevel->log2_prec_width);",
"if (reslevel->coord[1][1] == reslevel->coord[1][0])\nreslevel->num_precincts_y = 0;",
"else\nreslevel->num_precincts_y =\nff_jpeg2000_ceildivpow2(reslevel->coord[1][1],\nreslevel->log2_prec_height) -\n(reslevel->coord[1][0] >> reslevel->log2_prec_height);",
"reslevel->band = av_malloc_array(reslevel->nbands, sizeof(*reslevel->band));",
"if (!reslevel->band)\nreturn AVERROR(ENOMEM);",
"for (VAR_8 = 0; VAR_8 < reslevel->nbands; VAR_8++, VAR_9++) {",
"Jpeg2000Band *band = reslevel->band + VAR_8;",
"int cblkno, precno;",
"int nb_precincts;",
"switch (VAR_2->quantsty) {",
"uint8_t gain;",
"int numbps;",
"case JPEG2000_QSTY_NONE:\nband->f_stepsize = 1;",
"break;",
"case JPEG2000_QSTY_SI:\nnumbps = VAR_3 +\nlut_gain[VAR_1->transform == FF_DWT53][VAR_8 + (VAR_7 > 0)];",
"band->f_stepsize = SHL(2048 + VAR_2->mant[VAR_9],\n2 + numbps - VAR_2->expn[VAR_9]);",
"break;",
"case JPEG2000_QSTY_SE:\ngain = VAR_3;",
"band->f_stepsize = pow(2.0, gain - VAR_2->expn[VAR_9]);",
"band->f_stepsize *= (VAR_2->mant[VAR_9] / 2048.0 + 1.0);",
"break;",
"default:\nband->f_stepsize = 0;",
"av_log(VAR_6, AV_LOG_ERROR, \"Unknown quantization format\\n\");",
"break;",
"}",
"if (!av_codec_is_encoder(VAR_6->codec))\nband->f_stepsize *= 0.5;",
"band->i_stepsize = band->f_stepsize * (1 << 16);",
"if (VAR_7 == 0) {",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0],\ndeclvl - 1);",
"log2_band_prec_width = reslevel->log2_prec_width;",
"log2_band_prec_height = reslevel->log2_prec_height;",
"band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,\nreslevel->log2_prec_width);",
"band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,\nreslevel->log2_prec_height);",
"} else {",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[VAR_11][VAR_12] =\nff_jpeg2000_ceildivpow2(VAR_0->coord_o[VAR_11][VAR_12] - VAR_0->coord_o[VAR_11][0] -\n(((VAR_8 + 1 >> VAR_11) & 1) << declvl - 1),\ndeclvl);",
"band->log2_cblk_width = FFMIN(VAR_1->log2_cblk_width,\nreslevel->log2_prec_width - 1);",
"band->log2_cblk_height = FFMIN(VAR_1->log2_cblk_height,\nreslevel->log2_prec_height - 1);",
"log2_band_prec_width = reslevel->log2_prec_width - 1;",
"log2_band_prec_height = reslevel->log2_prec_height - 1;",
"}",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[0][VAR_12] = ff_jpeg2000_ceildiv(band->coord[0][VAR_12], VAR_4);",
"for (VAR_12 = 0; VAR_12 < 2; VAR_12++)",
"band->coord[1][VAR_12] = ff_jpeg2000_ceildiv(band->coord[1][VAR_12], VAR_5);",
"band->prec = av_malloc_array(reslevel->num_precincts_x *\nreslevel->num_precincts_y,\nsizeof(*band->prec));",
"if (!band->prec)\nreturn AVERROR(ENOMEM);",
"nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;",
"for (precno = 0; precno < nb_precincts; precno++) {",
"Jpeg2000Prec *prec = band->prec + precno;",
"prec->coord[0][0] = (precno % reslevel->num_precincts_x) *\n(1 << log2_band_prec_width);",
"prec->coord[0][0] = FFMAX(prec->coord[0][0], band->coord[0][0]);",
"prec->coord[1][0] = (precno / reslevel->num_precincts_x) *\n(1 << log2_band_prec_height);",
"prec->coord[1][0] = FFMAX(prec->coord[1][0], band->coord[1][0]);",
"prec->coord[0][1] = prec->coord[0][0] +\n(1 << log2_band_prec_width);",
"prec->coord[0][1] = FFMIN(prec->coord[0][1], band->coord[0][1]);",
"prec->coord[1][1] = prec->coord[1][0] +\n(1 << log2_band_prec_height);",
"prec->coord[1][1] = FFMIN(prec->coord[1][1], band->coord[1][1]);",
"prec->nb_codeblocks_width =\nff_jpeg2000_ceildivpow2(prec->coord[0][1] -\nprec->coord[0][0],\nband->log2_cblk_width);",
"prec->nb_codeblocks_height =\nff_jpeg2000_ceildivpow2(prec->coord[1][1] -\nprec->coord[1][0],\nband->log2_cblk_height);",
"prec->cblkincl =\nff_j2k_tag_tree_init(prec->nb_codeblocks_width,\nprec->nb_codeblocks_height);",
"if (!prec->cblkincl)\nreturn AVERROR(ENOMEM);",
"prec->zerobits =\nff_j2k_tag_tree_init(prec->nb_codeblocks_width,\nprec->nb_codeblocks_height);",
"if (!prec->zerobits)\nreturn AVERROR(ENOMEM);",
"prec->cblk = av_malloc_array(prec->nb_codeblocks_width *\nprec->nb_codeblocks_height,\nsizeof(*prec->cblk));",
"if (!prec->cblk)\nreturn AVERROR(ENOMEM);",
"for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {",
"Jpeg2000Cblk *cblk = prec->cblk + cblkno;",
"uint16_t Cx0, Cy0;",
"Cx0 = (prec->coord[0][0] >> band->log2_cblk_width) << band->log2_cblk_width;",
"Cx0 = Cx0 + ((cblkno % prec->nb_codeblocks_width) << band->log2_cblk_width);",
"cblk->coord[0][0] = FFMAX(Cx0, prec->coord[0][0]);",
"Cy0 = (prec->coord[1][0] >> band->log2_cblk_height) << band->log2_cblk_height;",
"Cy0 = Cy0 + ((cblkno / prec->nb_codeblocks_width) << band->log2_cblk_height);",
"cblk->coord[1][0] = FFMAX(Cy0, prec->coord[1][0]);",
"cblk->coord[0][1] = FFMIN(Cx0 + (1 << band->log2_cblk_width),\nprec->coord[0][1]);",
"cblk->coord[1][1] = FFMIN(Cy0 + (1 << band->log2_cblk_height),\nprec->coord[1][1]);",
"if((VAR_8 + !!VAR_7) & 1) {",
"cblk->coord[0][0] += VAR_0->reslevel[VAR_7-1].coord[0][1] - VAR_0->reslevel[VAR_7-1].coord[0][0];",
"cblk->coord[0][1] += VAR_0->reslevel[VAR_7-1].coord[0][1] - VAR_0->reslevel[VAR_7-1].coord[0][0];",
"}",
"if((VAR_8 + !!VAR_7) & 2) {",
"cblk->coord[1][0] += VAR_0->reslevel[VAR_7-1].coord[1][1] - VAR_0->reslevel[VAR_7-1].coord[1][0];",
"cblk->coord[1][1] += VAR_0->reslevel[VAR_7-1].coord[1][1] - VAR_0->reslevel[VAR_7-1].coord[1][0];",
"}",
"cblk->zero = 0;",
"cblk->lblock = 3;",
"cblk->length = 0;",
"cblk->lengthinc = 0;",
"cblk->npasses = 0;",
"}",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
57
],
[
59
],
[
61,
63
],
[
67
],
[
69
],
[
75,
77
],
[
79,
81
],
[
99,
101
],
[
103,
105,
107,
109,
111
],
[
115,
117
],
[
119,
121,
123,
125,
127
],
[
131
],
[
133,
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
153
],
[
155
],
[
157
],
[
159,
163
],
[
165
],
[
167,
171,
173
],
[
175,
177
],
[
179
],
[
181,
199
],
[
201
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
221,
223
],
[
227
],
[
239
],
[
243
],
[
245
],
[
247,
249,
251
],
[
253
],
[
255
],
[
259,
261
],
[
263,
265
],
[
267
],
[
273
],
[
275
],
[
279,
281,
283,
285
],
[
295,
297
],
[
299,
301
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323,
325,
327
],
[
329,
331
],
[
335
],
[
339
],
[
341
],
[
353,
355
],
[
357
],
[
363,
365
],
[
367
],
[
373,
375
],
[
377
],
[
383,
385
],
[
387
],
[
391,
393,
395,
397
],
[
399,
401,
403,
405
],
[
411,
413,
415
],
[
417,
419
],
[
423,
425,
427
],
[
429,
431
],
[
435,
437,
439
],
[
441,
443
],
[
445
],
[
447
],
[
449
],
[
457
],
[
459
],
[
461
],
[
467
],
[
469
],
[
471
],
[
477,
479
],
[
485,
487
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
]
] |
19,076 | static void gen_stx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGv val = load_gpr(dc, instr.b);
TCGv addr = tcg_temp_new();
tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);
tcg_gen_qemu_st_tl(val, addr, dc->mem_idx, flags);
tcg_temp_free(addr);
}
| true | qemu | 4ae4b609ee2d5bcc9df6c03c21dc1fed527aada1 | static void gen_stx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGv val = load_gpr(dc, instr.b);
TCGv addr = tcg_temp_new();
tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);
tcg_gen_qemu_st_tl(val, addr, dc->mem_idx, flags);
tcg_temp_free(addr);
}
| {
"code": [
" tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);",
" tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);"
],
"line_no": [
13,
13
]
} | static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
I_TYPE(instr, VAR_1);
TCGv val = load_gpr(VAR_0, instr.b);
TCGv addr = tcg_temp_new();
tcg_gen_addi_tl(addr, load_gpr(VAR_0, instr.a), instr.imm16s);
tcg_gen_qemu_st_tl(val, addr, VAR_0->mem_idx, VAR_2);
tcg_temp_free(addr);
}
| [
"static void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"I_TYPE(instr, VAR_1);",
"TCGv val = load_gpr(VAR_0, instr.b);",
"TCGv addr = tcg_temp_new();",
"tcg_gen_addi_tl(addr, load_gpr(VAR_0, instr.a), instr.imm16s);",
"tcg_gen_qemu_st_tl(val, addr, VAR_0->mem_idx, VAR_2);",
"tcg_temp_free(addr);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
19,077 | static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights)
{
uint32_t val = 1;
uint32_t val2;
uint32_t initial_val = heap[val];
while (1) {
val2 = val << 1;
if (val2 > nr_heap)
break;
if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]])
val2++;
if (weights[initial_val] < weights[heap[val2]])
break;
heap[val] = heap[val2];
val = val2;
}
heap[val] = initial_val;
}
| true | FFmpeg | f92f4935acd7d974adfd1deebdf1bb06cbe107ca | static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights)
{
uint32_t val = 1;
uint32_t val2;
uint32_t initial_val = heap[val];
while (1) {
val2 = val << 1;
if (val2 > nr_heap)
break;
if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]])
val2++;
if (weights[initial_val] < weights[heap[val2]])
break;
heap[val] = heap[val2];
val = val2;
}
heap[val] = initial_val;
}
| {
"code": [
" uint32_t initial_val = heap[val];",
" heap[val] = initial_val;",
"static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights)",
" uint32_t val = 1;",
" uint32_t val2;",
" uint32_t initial_val = heap[val];",
" while (1) {",
" val2 = val << 1;",
" if (val2 > nr_heap)",
" break;",
" if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]])",
" val2++;",
" if (weights[initial_val] < weights[heap[val2]])",
" break;",
" heap[val] = heap[val2];",
" val = val2;",
" heap[val] = initial_val;"
],
"line_no": [
9,
47,
1,
5,
7,
9,
13,
15,
19,
21,
25,
27,
31,
21,
37,
41,
47
]
} | static void FUNC_0(uint32_t VAR_0, uint32_t *VAR_1, uint32_t *VAR_2)
{
uint32_t val = 1;
uint32_t val2;
uint32_t initial_val = VAR_1[val];
while (1) {
val2 = val << 1;
if (val2 > VAR_0)
break;
if (val2 < VAR_0 && VAR_2[VAR_1[val2 + 1]] < VAR_2[VAR_1[val2]])
val2++;
if (VAR_2[initial_val] < VAR_2[VAR_1[val2]])
break;
VAR_1[val] = VAR_1[val2];
val = val2;
}
VAR_1[val] = initial_val;
}
| [
"static void FUNC_0(uint32_t VAR_0, uint32_t *VAR_1, uint32_t *VAR_2)\n{",
"uint32_t val = 1;",
"uint32_t val2;",
"uint32_t initial_val = VAR_1[val];",
"while (1) {",
"val2 = val << 1;",
"if (val2 > VAR_0)\nbreak;",
"if (val2 < VAR_0 && VAR_2[VAR_1[val2 + 1]] < VAR_2[VAR_1[val2]])\nval2++;",
"if (VAR_2[initial_val] < VAR_2[VAR_1[val2]])\nbreak;",
"VAR_1[val] = VAR_1[val2];",
"val = val2;",
"}",
"VAR_1[val] = initial_val;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19,
21
],
[
25,
27
],
[
31,
33
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
]
] |
19,078 | static void dct_unquantize_mpeg1_mmx(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int nCoeffs;
const UINT16 *quant_matrix;
if(s->alternate_scan) nCoeffs= 64;
else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ];
if (s->mb_intra) {
int block0;
if (n < 4)
block0 = block[0] * s->y_dc_scale;
else
block0 = block[0] * s->c_dc_scale;
/* XXX: only mpeg1 */
quant_matrix = s->intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $15, %%mm7 \n\t"
"movd %2, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"movl %3, %%eax \n\t"
".balign 16\n\t"
"1: \n\t"
"movq (%0, %%eax), %%mm0 \n\t"
"movq 8(%0, %%eax), %%mm1 \n\t"
"movq (%1, %%eax), %%mm4 \n\t"
"movq 8(%1, %%eax), %%mm5 \n\t"
"pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
"pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
"pxor %%mm2, %%mm2 \n\t"
"pxor %%mm3, %%mm3 \n\t"
"pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
"pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t" // abs(block[i])
"psubw %%mm3, %%mm1 \n\t" // abs(block[i])
"pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
"pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t" // FIXME slow
"pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
"pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
"psraw $3, %%mm0 \n\t"
"psraw $3, %%mm1 \n\t"
"psubw %%mm7, %%mm0 \n\t"
"psubw %%mm7, %%mm1 \n\t"
"por %%mm7, %%mm0 \n\t"
"por %%mm7, %%mm1 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"pandn %%mm0, %%mm4 \n\t"
"pandn %%mm1, %%mm5 \n\t"
"movq %%mm4, (%0, %%eax) \n\t"
"movq %%mm5, 8(%0, %%eax) \n\t"
"addl $16, %%eax \n\t"
"js 1b \n\t"
::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
: "%eax", "memory"
);
block[0]= block0;
} else {
quant_matrix = s->non_intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $15, %%mm7 \n\t"
"movd %2, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"movl %3, %%eax \n\t"
".balign 16\n\t"
"1: \n\t"
"movq (%0, %%eax), %%mm0 \n\t"
"movq 8(%0, %%eax), %%mm1 \n\t"
"movq (%1, %%eax), %%mm4 \n\t"
"movq 8(%1, %%eax), %%mm5 \n\t"
"pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
"pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
"pxor %%mm2, %%mm2 \n\t"
"pxor %%mm3, %%mm3 \n\t"
"pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
"pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t" // abs(block[i])
"psubw %%mm3, %%mm1 \n\t" // abs(block[i])
"paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
"paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
"paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1
"paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1
"pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
"pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t" // FIXME slow
"pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
"pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
"psraw $4, %%mm0 \n\t"
"psraw $4, %%mm1 \n\t"
"psubw %%mm7, %%mm0 \n\t"
"psubw %%mm7, %%mm1 \n\t"
"por %%mm7, %%mm0 \n\t"
"por %%mm7, %%mm1 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"pandn %%mm0, %%mm4 \n\t"
"pandn %%mm1, %%mm5 \n\t"
"movq %%mm4, (%0, %%eax) \n\t"
"movq %%mm5, 8(%0, %%eax) \n\t"
"addl $16, %%eax \n\t"
"js 1b \n\t"
::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
: "%eax", "memory"
);
}
}
| true | FFmpeg | d7e9533aa06f4073a27812349b35ba5fede11ca1 | static void dct_unquantize_mpeg1_mmx(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int nCoeffs;
const UINT16 *quant_matrix;
if(s->alternate_scan) nCoeffs= 64;
else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ];
if (s->mb_intra) {
int block0;
if (n < 4)
block0 = block[0] * s->y_dc_scale;
else
block0 = block[0] * s->c_dc_scale;
quant_matrix = s->intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $15, %%mm7 \n\t"
"movd %2, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"movl %3, %%eax \n\t"
".balign 16\n\t"
"1: \n\t"
"movq (%0, %%eax), %%mm0 \n\t"
"movq 8(%0, %%eax), %%mm1 \n\t"
"movq (%1, %%eax), %%mm4 \n\t"
"movq 8(%1, %%eax), %%mm5 \n\t"
"pmullw %%mm6, %%mm4 \n\t"
"pmullw %%mm6, %%mm5 \n\t"
"pxor %%mm2, %%mm2 \n\t"
"pxor %%mm3, %%mm3 \n\t"
"pcmpgtw %%mm0, %%mm2 \n\t"
"pcmpgtw %%mm1, %%mm3 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"pmullw %%mm4, %%mm0 \n\t" *q
"pmullw %%mm5, %%mm1 \n\t" *q
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"pcmpeqw (%0, %%eax), %%mm4 \n\t"
"pcmpeqw 8(%0, %%eax), %%mm5 \n\t"
"psraw $3, %%mm0 \n\t"
"psraw $3, %%mm1 \n\t"
"psubw %%mm7, %%mm0 \n\t"
"psubw %%mm7, %%mm1 \n\t"
"por %%mm7, %%mm0 \n\t"
"por %%mm7, %%mm1 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"pandn %%mm0, %%mm4 \n\t"
"pandn %%mm1, %%mm5 \n\t"
"movq %%mm4, (%0, %%eax) \n\t"
"movq %%mm5, 8(%0, %%eax) \n\t"
"addl $16, %%eax \n\t"
"js 1b \n\t"
::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
: "%eax", "memory"
);
block[0]= block0;
} else {
quant_matrix = s->non_intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $15, %%mm7 \n\t"
"movd %2, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"movl %3, %%eax \n\t"
".balign 16\n\t"
"1: \n\t"
"movq (%0, %%eax), %%mm0 \n\t"
"movq 8(%0, %%eax), %%mm1 \n\t"
"movq (%1, %%eax), %%mm4 \n\t"
"movq 8(%1, %%eax), %%mm5 \n\t"
"pmullw %%mm6, %%mm4 \n\t"
"pmullw %%mm6, %%mm5 \n\t"
"pxor %%mm2, %%mm2 \n\t"
"pxor %%mm3, %%mm3 \n\t"
"pcmpgtw %%mm0, %%mm2 \n\t"
"pcmpgtw %%mm1, %%mm3 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"paddw %%mm0, %%mm0 \n\t" *2
"paddw %%mm1, %%mm1 \n\t" *2
"paddw %%mm7, %%mm0 \n\t" *2 + 1
"paddw %%mm7, %%mm1 \n\t" *2 + 1
"pmullw %%mm4, %%mm0 \n\t"
"pmullw %%mm5, %%mm1 \n\t"
"pxor %%mm4, %%mm4 \n\t"
"pxor %%mm5, %%mm5 \n\t"
"pcmpeqw (%0, %%eax), %%mm4 \n\t"
"pcmpeqw 8(%0, %%eax), %%mm5 \n\t"
"psraw $4, %%mm0 \n\t"
"psraw $4, %%mm1 \n\t"
"psubw %%mm7, %%mm0 \n\t"
"psubw %%mm7, %%mm1 \n\t"
"por %%mm7, %%mm0 \n\t"
"por %%mm7, %%mm1 \n\t"
"pxor %%mm2, %%mm0 \n\t"
"pxor %%mm3, %%mm1 \n\t"
"psubw %%mm2, %%mm0 \n\t"
"psubw %%mm3, %%mm1 \n\t"
"pandn %%mm0, %%mm4 \n\t"
"pandn %%mm1, %%mm5 \n\t"
"movq %%mm4, (%0, %%eax) \n\t"
"movq %%mm5, 8(%0, %%eax) \n\t"
"addl $16, %%eax \n\t"
"js 1b \n\t"
::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
: "%eax", "memory"
);
}
}
| {
"code": [
" quant_matrix = s->non_intra_matrix;",
" quant_matrix = s->non_intra_matrix;",
"\t);",
"\t);",
" } else {",
" } else {",
" } else {",
" quant_matrix = s->non_intra_matrix;",
" quant_matrix = s->non_intra_matrix;"
],
"line_no": [
139,
139,
245,
245,
137,
137,
137,
139,
139
]
} | static void FUNC_0(MpegEncContext *VAR_0,
DCTELEM *VAR_1, int VAR_2, int VAR_3)
{
int VAR_4;
const UINT16 *VAR_5;
if(VAR_0->alternate_scan) VAR_4= 64;
else VAR_4= VAR_4= zigzag_end[ VAR_0->block_last_index[VAR_2] ];
if (VAR_0->mb_intra) {
int VAR_6;
if (VAR_2 < 4)
VAR_6 = VAR_1[0] * VAR_0->y_dc_scale;
else
VAR_6 = VAR_1[0] * VAR_0->c_dc_scale;
VAR_5 = VAR_0->intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \VAR_2\t"
"psrlw $15, %%mm7 \VAR_2\t"
"movd %2, %%mm6 \VAR_2\t"
"packssdw %%mm6, %%mm6 \VAR_2\t"
"packssdw %%mm6, %%mm6 \VAR_2\t"
"movl %3, %%eax \VAR_2\t"
".balign 16\VAR_2\t"
"1: \VAR_2\t"
"movq (%0, %%eax), %%mm0 \VAR_2\t"
"movq 8(%0, %%eax), %%mm1 \VAR_2\t"
"movq (%1, %%eax), %%mm4 \VAR_2\t"
"movq 8(%1, %%eax), %%mm5 \VAR_2\t"
"pmullw %%mm6, %%mm4 \VAR_2\t"
"pmullw %%mm6, %%mm5 \VAR_2\t"
"pxor %%mm2, %%mm2 \VAR_2\t"
"pxor %%mm3, %%mm3 \VAR_2\t"
"pcmpgtw %%mm0, %%mm2 \VAR_2\t"
"pcmpgtw %%mm1, %%mm3 \VAR_2\t"
"pxor %%mm2, %%mm0 \VAR_2\t"
"pxor %%mm3, %%mm1 \VAR_2\t"
"psubw %%mm2, %%mm0 \VAR_2\t"
"psubw %%mm3, %%mm1 \VAR_2\t"
"pmullw %%mm4, %%mm0 \VAR_2\t" *q
"pmullw %%mm5, %%mm1 \VAR_2\t" *q
"pxor %%mm4, %%mm4 \VAR_2\t"
"pxor %%mm5, %%mm5 \VAR_2\t"
"pcmpeqw (%0, %%eax), %%mm4 \VAR_2\t"
"pcmpeqw 8(%0, %%eax), %%mm5 \VAR_2\t"
"psraw $3, %%mm0 \VAR_2\t"
"psraw $3, %%mm1 \VAR_2\t"
"psubw %%mm7, %%mm0 \VAR_2\t"
"psubw %%mm7, %%mm1 \VAR_2\t"
"por %%mm7, %%mm0 \VAR_2\t"
"por %%mm7, %%mm1 \VAR_2\t"
"pxor %%mm2, %%mm0 \VAR_2\t"
"pxor %%mm3, %%mm1 \VAR_2\t"
"psubw %%mm2, %%mm0 \VAR_2\t"
"psubw %%mm3, %%mm1 \VAR_2\t"
"pandn %%mm0, %%mm4 \VAR_2\t"
"pandn %%mm1, %%mm5 \VAR_2\t"
"movq %%mm4, (%0, %%eax) \VAR_2\t"
"movq %%mm5, 8(%0, %%eax) \VAR_2\t"
"addl $16, %%eax \VAR_2\t"
"js 1b \VAR_2\t"
::"r" (VAR_1+VAR_4), "r"(VAR_5+VAR_4), "g" (VAR_3), "g" (-2*VAR_4)
: "%eax", "memory"
);
VAR_1[0]= VAR_6;
} else {
VAR_5 = VAR_0->non_intra_matrix;
asm volatile(
"pcmpeqw %%mm7, %%mm7 \VAR_2\t"
"psrlw $15, %%mm7 \VAR_2\t"
"movd %2, %%mm6 \VAR_2\t"
"packssdw %%mm6, %%mm6 \VAR_2\t"
"packssdw %%mm6, %%mm6 \VAR_2\t"
"movl %3, %%eax \VAR_2\t"
".balign 16\VAR_2\t"
"1: \VAR_2\t"
"movq (%0, %%eax), %%mm0 \VAR_2\t"
"movq 8(%0, %%eax), %%mm1 \VAR_2\t"
"movq (%1, %%eax), %%mm4 \VAR_2\t"
"movq 8(%1, %%eax), %%mm5 \VAR_2\t"
"pmullw %%mm6, %%mm4 \VAR_2\t"
"pmullw %%mm6, %%mm5 \VAR_2\t"
"pxor %%mm2, %%mm2 \VAR_2\t"
"pxor %%mm3, %%mm3 \VAR_2\t"
"pcmpgtw %%mm0, %%mm2 \VAR_2\t"
"pcmpgtw %%mm1, %%mm3 \VAR_2\t"
"pxor %%mm2, %%mm0 \VAR_2\t"
"pxor %%mm3, %%mm1 \VAR_2\t"
"psubw %%mm2, %%mm0 \VAR_2\t"
"psubw %%mm3, %%mm1 \VAR_2\t"
"paddw %%mm0, %%mm0 \VAR_2\t" *2
"paddw %%mm1, %%mm1 \VAR_2\t" *2
"paddw %%mm7, %%mm0 \VAR_2\t" *2 + 1
"paddw %%mm7, %%mm1 \VAR_2\t" *2 + 1
"pmullw %%mm4, %%mm0 \VAR_2\t"
"pmullw %%mm5, %%mm1 \VAR_2\t"
"pxor %%mm4, %%mm4 \VAR_2\t"
"pxor %%mm5, %%mm5 \VAR_2\t"
"pcmpeqw (%0, %%eax), %%mm4 \VAR_2\t"
"pcmpeqw 8(%0, %%eax), %%mm5 \VAR_2\t"
"psraw $4, %%mm0 \VAR_2\t"
"psraw $4, %%mm1 \VAR_2\t"
"psubw %%mm7, %%mm0 \VAR_2\t"
"psubw %%mm7, %%mm1 \VAR_2\t"
"por %%mm7, %%mm0 \VAR_2\t"
"por %%mm7, %%mm1 \VAR_2\t"
"pxor %%mm2, %%mm0 \VAR_2\t"
"pxor %%mm3, %%mm1 \VAR_2\t"
"psubw %%mm2, %%mm0 \VAR_2\t"
"psubw %%mm3, %%mm1 \VAR_2\t"
"pandn %%mm0, %%mm4 \VAR_2\t"
"pandn %%mm1, %%mm5 \VAR_2\t"
"movq %%mm4, (%0, %%eax) \VAR_2\t"
"movq %%mm5, 8(%0, %%eax) \VAR_2\t"
"addl $16, %%eax \VAR_2\t"
"js 1b \VAR_2\t"
::"r" (VAR_1+VAR_4), "r"(VAR_5+VAR_4), "g" (VAR_3), "g" (-2*VAR_4)
: "%eax", "memory"
);
}
}
| [
"static void FUNC_0(MpegEncContext *VAR_0,\nDCTELEM *VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4;",
"const UINT16 *VAR_5;",
"if(VAR_0->alternate_scan) VAR_4= 64;",
"else VAR_4= VAR_4= zigzag_end[ VAR_0->block_last_index[VAR_2] ];",
"if (VAR_0->mb_intra) {",
"int VAR_6;",
"if (VAR_2 < 4)\nVAR_6 = VAR_1[0] * VAR_0->y_dc_scale;",
"else\nVAR_6 = VAR_1[0] * VAR_0->c_dc_scale;",
"VAR_5 = VAR_0->intra_matrix;",
"asm volatile(\n\"pcmpeqw %%mm7, %%mm7\t\t\\VAR_2\\t\"\n\"psrlw $15, %%mm7\t\t\\VAR_2\\t\"\n\"movd %2, %%mm6\t\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"movl %3, %%eax\t\t\t\\VAR_2\\t\"\n\".balign 16\\VAR_2\\t\"\n\"1:\t\t\t\t\\VAR_2\\t\"\n\"movq (%0, %%eax), %%mm0\t\\VAR_2\\t\"\n\"movq 8(%0, %%eax), %%mm1\t\\VAR_2\\t\"\n\"movq (%1, %%eax), %%mm4\t\\VAR_2\\t\"\n\"movq 8(%1, %%eax), %%mm5\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm4\t\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm5\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm2\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm3\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm0, %%mm2\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm1, %%mm3\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"pmullw %%mm4, %%mm0\t\t\\VAR_2\\t\" *q\n\"pmullw %%mm5, %%mm1\t\t\\VAR_2\\t\" *q\n\"pxor %%mm4, %%mm4\t\t\\VAR_2\\t\"\n\"pxor %%mm5, %%mm5\t\t\\VAR_2\\t\"\n\"pcmpeqw (%0, %%eax), %%mm4\t\\VAR_2\\t\"\n\"pcmpeqw 8(%0, %%eax), %%mm5\t\\VAR_2\\t\"\n\"psraw $3, %%mm0\t\t\\VAR_2\\t\"\n\"psraw $3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"pandn %%mm0, %%mm4\t\t\\VAR_2\\t\"\n\"pandn %%mm1, %%mm5\t\t\\VAR_2\\t\"\n\"movq %%mm4, (%0, %%eax)\t\\VAR_2\\t\"\n\"movq %%mm5, 8(%0, %%eax)\t\\VAR_2\\t\"\n\"addl $16, %%eax\t\t\\VAR_2\\t\"\n\"js 1b\t\t\t\t\\VAR_2\\t\"\n::\"r\" (VAR_1+VAR_4), \"r\"(VAR_5+VAR_4), \"g\" (VAR_3), \"g\" (-2*VAR_4)\n: \"%eax\", \"memory\"\n);",
"VAR_1[0]= VAR_6;",
"} else {",
"VAR_5 = VAR_0->non_intra_matrix;",
"asm volatile(\n\"pcmpeqw %%mm7, %%mm7\t\t\\VAR_2\\t\"\n\"psrlw $15, %%mm7\t\t\\VAR_2\\t\"\n\"movd %2, %%mm6\t\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"movl %3, %%eax\t\t\t\\VAR_2\\t\"\n\".balign 16\\VAR_2\\t\"\n\"1:\t\t\t\t\\VAR_2\\t\"\n\"movq (%0, %%eax), %%mm0\t\\VAR_2\\t\"\n\"movq 8(%0, %%eax), %%mm1\t\\VAR_2\\t\"\n\"movq (%1, %%eax), %%mm4\t\\VAR_2\\t\"\n\"movq 8(%1, %%eax), %%mm5\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm4\t\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm5\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm2\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm3\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm0, %%mm2\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm1, %%mm3\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"paddw %%mm0, %%mm0\t\t\\VAR_2\\t\" *2\n\"paddw %%mm1, %%mm1\t\t\\VAR_2\\t\" *2\n\"paddw %%mm7, %%mm0\t\t\\VAR_2\\t\" *2 + 1\n\"paddw %%mm7, %%mm1\t\t\\VAR_2\\t\" *2 + 1\n\"pmullw %%mm4, %%mm0\t\t\\VAR_2\\t\"\n\"pmullw %%mm5, %%mm1\t\t\\VAR_2\\t\"\n\"pxor %%mm4, %%mm4\t\t\\VAR_2\\t\"\n\"pxor %%mm5, %%mm5\t\t\\VAR_2\\t\"\n\"pcmpeqw (%0, %%eax), %%mm4\t\\VAR_2\\t\"\n\"pcmpeqw 8(%0, %%eax), %%mm5\t\\VAR_2\\t\"\n\"psraw $4, %%mm0\t\t\\VAR_2\\t\"\n\"psraw $4, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"pandn %%mm0, %%mm4\t\t\\VAR_2\\t\"\n\"pandn %%mm1, %%mm5\t\t\\VAR_2\\t\"\n\"movq %%mm4, (%0, %%eax)\t\\VAR_2\\t\"\n\"movq %%mm5, 8(%0, %%eax)\t\\VAR_2\\t\"\n\"addl $16, %%eax\t\t\\VAR_2\\t\"\n\"js 1b\t\t\t\t\\VAR_2\\t\"\n::\"r\" (VAR_1+VAR_4), \"r\"(VAR_5+VAR_4), \"g\" (VAR_3), \"g\" (-2*VAR_4)\n: \"%eax\", \"memory\"\n);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
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,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
119,
123,
125,
127,
129,
131
],
[
133
],
[
137
],
[
139
],
[
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
181,
183,
185,
187,
189,
191,
193,
195,
197,
199,
201,
203,
205,
207,
209,
211,
213,
215,
217,
219,
221,
223,
225,
227,
229,
231,
233,
237,
239,
241,
243,
245
],
[
247
],
[
249
]
] |
19,079 | void RENAME(ff_init_mpadsp_tabs)(void)
{
int i, j;
/* compute mdct windows */
for (i = 0; i < 36; i++) {
for (j = 0; j < 4; j++) {
double d;
if (j == 2 && i % 3 != 1)
continue;
d = sin(M_PI * (i + 0.5) / 36.0);
if (j == 1) {
if (i >= 30) d = 0;
else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
else if (i >= 18) d = 1;
} else if (j == 3) {
if (i < 6) d = 0;
else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
else if (i < 18) d = 1;
}
//merge last stage of imdct into the window coefficients
d *= 0.5 / cos(M_PI * (2 * i + 19) / 72);
if (j == 2)
RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5)));
else {
int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5)));
}
}
}
/* NOTE: we do frequency inversion adter the MDCT by changing
the sign of the right window coefs */
for (j = 0; j < 4; j++) {
for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ];
RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1];
}
}
}
| true | FFmpeg | 571572fcddc16ebe3d60054ae5a2db05800c1d6d | void RENAME(ff_init_mpadsp_tabs)(void)
{
int i, j;
for (i = 0; i < 36; i++) {
for (j = 0; j < 4; j++) {
double d;
if (j == 2 && i % 3 != 1)
continue;
d = sin(M_PI * (i + 0.5) / 36.0);
if (j == 1) {
if (i >= 30) d = 0;
else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
else if (i >= 18) d = 1;
} else if (j == 3) {
if (i < 6) d = 0;
else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
else if (i < 18) d = 1;
}
d *= 0.5 / cos(M_PI * (2 * i + 19) / 72);
if (j == 2)
RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5)));
else {
int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5)));
}
}
}
for (j = 0; j < 4; j++) {
for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ];
RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1];
}
}
}
| {
"code": [
" d *= 0.5 / cos(M_PI * (2 * i + 19) / 72);"
],
"line_no": [
45
]
} | void FUNC_0(ff_init_mpadsp_tabs)(void)
{
int VAR_0, VAR_1;
for (VAR_0 = 0; VAR_0 < 36; VAR_0++) {
for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {
double VAR_2;
if (VAR_1 == 2 && VAR_0 % 3 != 1)
continue;
VAR_2 = sin(M_PI * (VAR_0 + 0.5) / 36.0);
if (VAR_1 == 1) {
if (VAR_0 >= 30) VAR_2 = 0;
else if (VAR_0 >= 24) VAR_2 = sin(M_PI * (VAR_0 - 18 + 0.5) / 12.0);
else if (VAR_0 >= 18) VAR_2 = 1;
} else if (VAR_1 == 3) {
if (VAR_0 < 6) VAR_2 = 0;
else if (VAR_0 < 12) VAR_2 = sin(M_PI * (VAR_0 - 6 + 0.5) / 12.0);
else if (VAR_0 < 18) VAR_2 = 1;
}
VAR_2 *= 0.5 / cos(M_PI * (2 * VAR_0 + 19) / 72);
if (VAR_1 == 2)
FUNC_0(ff_mdct_win)[VAR_1][VAR_0/3] = FIXHR((VAR_2 / (1<<5)));
else {
int VAR_3 = VAR_0 < 18 ? VAR_0 : VAR_0 + (MDCT_BUF_SIZE/2 - 18);
FUNC_0(ff_mdct_win)[VAR_1][VAR_3] = FIXHR((VAR_2 / (1<<5)));
}
}
}
for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {
for (VAR_0 = 0; VAR_0 < MDCT_BUF_SIZE; VAR_0 += 2) {
FUNC_0(ff_mdct_win)[VAR_1 + 4][VAR_0 ] = FUNC_0(ff_mdct_win)[VAR_1][VAR_0 ];
FUNC_0(ff_mdct_win)[VAR_1 + 4][VAR_0 + 1] = -FUNC_0(ff_mdct_win)[VAR_1][VAR_0 + 1];
}
}
}
| [
"void FUNC_0(ff_init_mpadsp_tabs)(void)\n{",
"int VAR_0, VAR_1;",
"for (VAR_0 = 0; VAR_0 < 36; VAR_0++) {",
"for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {",
"double VAR_2;",
"if (VAR_1 == 2 && VAR_0 % 3 != 1)\ncontinue;",
"VAR_2 = sin(M_PI * (VAR_0 + 0.5) / 36.0);",
"if (VAR_1 == 1) {",
"if (VAR_0 >= 30) VAR_2 = 0;",
"else if (VAR_0 >= 24) VAR_2 = sin(M_PI * (VAR_0 - 18 + 0.5) / 12.0);",
"else if (VAR_0 >= 18) VAR_2 = 1;",
"} else if (VAR_1 == 3) {",
"if (VAR_0 < 6) VAR_2 = 0;",
"else if (VAR_0 < 12) VAR_2 = sin(M_PI * (VAR_0 - 6 + 0.5) / 12.0);",
"else if (VAR_0 < 18) VAR_2 = 1;",
"}",
"VAR_2 *= 0.5 / cos(M_PI * (2 * VAR_0 + 19) / 72);",
"if (VAR_1 == 2)\nFUNC_0(ff_mdct_win)[VAR_1][VAR_0/3] = FIXHR((VAR_2 / (1<<5)));",
"else {",
"int VAR_3 = VAR_0 < 18 ? VAR_0 : VAR_0 + (MDCT_BUF_SIZE/2 - 18);",
"FUNC_0(ff_mdct_win)[VAR_1][VAR_3] = FIXHR((VAR_2 / (1<<5)));",
"}",
"}",
"}",
"for (VAR_1 = 0; VAR_1 < 4; VAR_1++) {",
"for (VAR_0 = 0; VAR_0 < MDCT_BUF_SIZE; VAR_0 += 2) {",
"FUNC_0(ff_mdct_win)[VAR_1 + 4][VAR_0 ] = FUNC_0(ff_mdct_win)[VAR_1][VAR_0 ];",
"FUNC_0(ff_mdct_win)[VAR_1 + 4][VAR_0 + 1] = -FUNC_0(ff_mdct_win)[VAR_1][VAR_0 + 1];",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
19,080 | static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
{
/* Perform I/O through a temporary buffer so that users who scribble over
* their read buffer while the operation is in progress do not end up
* modifying the image file. This is critical for zero-copy guest I/O
* where anything might happen inside guest memory.
*/
void *bounce_buffer;
BlockDriver *drv = bs->drv;
struct iovec iov;
QEMUIOVector bounce_qiov;
int64_t cluster_sector_num;
int cluster_nb_sectors;
size_t skip_bytes;
int ret;
/* Cover entire cluster so no additional backing file I/O is required when
* allocating cluster in the image file.
*/
bdrv_round_to_clusters(bs, sector_num, nb_sectors,
&cluster_sector_num, &cluster_nb_sectors);
trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors,
cluster_sector_num, cluster_nb_sectors);
iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE;
iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&bounce_qiov, &iov, 1);
ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
if (ret < 0) {
goto err;
}
if (drv->bdrv_co_write_zeroes &&
buffer_is_zero(bounce_buffer, iov.iov_len)) {
ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,
cluster_nb_sectors, 0);
} else {
/* This does not change the data on the disk, it is not necessary
* to flush even in cache=writethrough mode.
*/
ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
}
if (ret < 0) {
/* It might be okay to ignore write errors for guest requests. If this
* is a deliberate copy-on-read then we don't want to ignore the error.
* Simply report it in all cases.
*/
goto err;
}
skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE;
qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes,
nb_sectors * BDRV_SECTOR_SIZE);
err:
qemu_vfree(bounce_buffer);
return ret;
}
| true | qemu | 857d4f46c31d2f4d57d2f0fad9dfb584262bf9b9 | static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
{
void *bounce_buffer;
BlockDriver *drv = bs->drv;
struct iovec iov;
QEMUIOVector bounce_qiov;
int64_t cluster_sector_num;
int cluster_nb_sectors;
size_t skip_bytes;
int ret;
bdrv_round_to_clusters(bs, sector_num, nb_sectors,
&cluster_sector_num, &cluster_nb_sectors);
trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors,
cluster_sector_num, cluster_nb_sectors);
iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE;
iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&bounce_qiov, &iov, 1);
ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
if (ret < 0) {
goto err;
}
if (drv->bdrv_co_write_zeroes &&
buffer_is_zero(bounce_buffer, iov.iov_len)) {
ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,
cluster_nb_sectors, 0);
} else {
ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
}
if (ret < 0) {
goto err;
}
skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE;
qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes,
nb_sectors * BDRV_SECTOR_SIZE);
err:
qemu_vfree(bounce_buffer);
return ret;
}
| {
"code": [
" iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);"
],
"line_no": [
57
]
} | static int VAR_0 bdrv_co_do_copy_on_readv(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
{
void *bounce_buffer;
BlockDriver *drv = bs->drv;
struct iovec iov;
QEMUIOVector bounce_qiov;
int64_t cluster_sector_num;
int cluster_nb_sectors;
size_t skip_bytes;
int ret;
bdrv_round_to_clusters(bs, sector_num, nb_sectors,
&cluster_sector_num, &cluster_nb_sectors);
trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors,
cluster_sector_num, cluster_nb_sectors);
iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE;
iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);
qemu_iovec_init_external(&bounce_qiov, &iov, 1);
ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
if (ret < 0) {
goto err;
}
if (drv->bdrv_co_write_zeroes &&
buffer_is_zero(bounce_buffer, iov.iov_len)) {
ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,
cluster_nb_sectors, 0);
} else {
ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors,
&bounce_qiov);
}
if (ret < 0) {
goto err;
}
skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE;
qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes,
nb_sectors * BDRV_SECTOR_SIZE);
err:
qemu_vfree(bounce_buffer);
return ret;
}
| [
"static int VAR_0 bdrv_co_do_copy_on_readv(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors, QEMUIOVector *qiov)\n{",
"void *bounce_buffer;",
"BlockDriver *drv = bs->drv;",
"struct iovec iov;",
"QEMUIOVector bounce_qiov;",
"int64_t cluster_sector_num;",
"int cluster_nb_sectors;",
"size_t skip_bytes;",
"int ret;",
"bdrv_round_to_clusters(bs, sector_num, nb_sectors,\n&cluster_sector_num, &cluster_nb_sectors);",
"trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors,\ncluster_sector_num, cluster_nb_sectors);",
"iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE;",
"iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len);",
"qemu_iovec_init_external(&bounce_qiov, &iov, 1);",
"ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors,\n&bounce_qiov);",
"if (ret < 0) {",
"goto err;",
"}",
"if (drv->bdrv_co_write_zeroes &&\nbuffer_is_zero(bounce_buffer, iov.iov_len)) {",
"ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,\ncluster_nb_sectors, 0);",
"} else {",
"ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors,\n&bounce_qiov);",
"}",
"if (ret < 0) {",
"goto err;",
"}",
"skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE;",
"qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes,\nnb_sectors * BDRV_SECTOR_SIZE);",
"err:\nqemu_vfree(bounce_buffer);",
"return ret;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
43,
45
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
79,
81
],
[
83
],
[
91,
93
],
[
95
],
[
99
],
[
109
],
[
111
],
[
115
],
[
117,
119
],
[
123,
125
],
[
127
],
[
129
]
] |
19,081 | static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
{
int err;
char attr_dir[PATH_MAX];
char *tmp_path = strdup(path);
snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
err = mkdir(attr_dir, 0700);
if (err < 0 && errno == EEXIST) {
err = 0;
}
free(tmp_path);
return err;
}
| true | qemu | d3f8e138c23ba082f87c96634d06b978473c1e9b | static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
{
int err;
char attr_dir[PATH_MAX];
char *tmp_path = strdup(path);
snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
err = mkdir(attr_dir, 0700);
if (err < 0 && errno == EEXIST) {
err = 0;
}
free(tmp_path);
return err;
}
| {
"code": [
" char *tmp_path = strdup(path);",
" free(tmp_path);",
" char *tmp_path = strdup(path);",
" free(tmp_path);"
],
"line_no": [
9,
27,
9,
27
]
} | static int FUNC_0(FsContext *VAR_0, const char *VAR_1)
{
int VAR_2;
char VAR_3[PATH_MAX];
char *VAR_4 = strdup(VAR_1);
snprintf(VAR_3, PATH_MAX, "%s/%s/%s",
VAR_0->fs_root, dirname(VAR_4), VIRTFS_META_DIR);
VAR_2 = mkdir(VAR_3, 0700);
if (VAR_2 < 0 && errno == EEXIST) {
VAR_2 = 0;
}
free(VAR_4);
return VAR_2;
}
| [
"static int FUNC_0(FsContext *VAR_0, const char *VAR_1)\n{",
"int VAR_2;",
"char VAR_3[PATH_MAX];",
"char *VAR_4 = strdup(VAR_1);",
"snprintf(VAR_3, PATH_MAX, \"%s/%s/%s\",\nVAR_0->fs_root, dirname(VAR_4), VIRTFS_META_DIR);",
"VAR_2 = mkdir(VAR_3, 0700);",
"if (VAR_2 < 0 && errno == EEXIST) {",
"VAR_2 = 0;",
"}",
"free(VAR_4);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
19,083 | static int openpic_init(SysBusDevice *dev)
{
OpenPICState *opp = FROM_SYSBUS(typeof (*opp), dev);
int i, j;
struct memreg list_le[] = {
{"glb", &openpic_glb_ops_le, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_le, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_le, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_le, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_le, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg list_be[] = {
{"glb", &openpic_glb_ops_be, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_be, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_be, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_be, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_be, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg *list;
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
default:
opp->flags |= OPENPIC_FLAG_IDE_CRIT;
opp->nb_irqs = 80;
opp->vid = VID_REVISION_1_2;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFFFF;
opp->tifr_reset = 0;
opp->ipvp_reset = IPVP_MASK_MASK;
opp->ide_reset = 1 << 0;
opp->max_irq = FSL_MPIC_20_MAX_IRQ;
opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ;
opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ;
opp->irq_msi = FSL_MPIC_20_MSI_IRQ;
opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
msi_supported = true;
list = list_be;
break;
case OPENPIC_MODEL_RAVEN:
opp->nb_irqs = RAVEN_MAX_EXT;
opp->vid = VID_REVISION_1_3;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFF;
opp->tifr_reset = 4160000;
opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK;
opp->ide_reset = 0;
opp->max_irq = RAVEN_MAX_IRQ;
opp->irq_ipi0 = RAVEN_IPI_IRQ;
opp->irq_tim0 = RAVEN_TMR_IRQ;
opp->brr1 = -1;
list = list_le;
/* Don't map MSI region */
list[2].map = false;
/* Only UP supported today */
if (opp->nb_cpus != 1) {
return -EINVAL;
}
break;
}
memory_region_init(&opp->mem, "openpic", 0x40000);
for (i = 0; i < ARRAY_SIZE(list_le); i++) {
if (!list[i].map) {
continue;
}
memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp,
list[i].name, list[i].size);
memory_region_add_subregion(&opp->mem, list[i].start_addr,
&opp->sub_io_mem[i]);
}
for (i = 0; i < opp->nb_cpus; i++) {
opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB);
for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {
sysbus_init_irq(dev, &opp->dst[i].irqs[j]);
}
}
register_savevm(&opp->busdev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
sysbus_init_mmio(dev, &opp->mem);
qdev_init_gpio_in(&dev->qdev, openpic_set_irq, opp->max_irq);
return 0;
}
| true | qemu | af7e9e74c6a62a5bcd911726a9e88d28b61490e0 | static int openpic_init(SysBusDevice *dev)
{
OpenPICState *opp = FROM_SYSBUS(typeof (*opp), dev);
int i, j;
struct memreg list_le[] = {
{"glb", &openpic_glb_ops_le, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_le, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_le, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_le, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_le, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg list_be[] = {
{"glb", &openpic_glb_ops_be, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_be, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_be, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_be, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_be, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg *list;
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
default:
opp->flags |= OPENPIC_FLAG_IDE_CRIT;
opp->nb_irqs = 80;
opp->vid = VID_REVISION_1_2;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFFFF;
opp->tifr_reset = 0;
opp->ipvp_reset = IPVP_MASK_MASK;
opp->ide_reset = 1 << 0;
opp->max_irq = FSL_MPIC_20_MAX_IRQ;
opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ;
opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ;
opp->irq_msi = FSL_MPIC_20_MSI_IRQ;
opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
msi_supported = true;
list = list_be;
break;
case OPENPIC_MODEL_RAVEN:
opp->nb_irqs = RAVEN_MAX_EXT;
opp->vid = VID_REVISION_1_3;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFF;
opp->tifr_reset = 4160000;
opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK;
opp->ide_reset = 0;
opp->max_irq = RAVEN_MAX_IRQ;
opp->irq_ipi0 = RAVEN_IPI_IRQ;
opp->irq_tim0 = RAVEN_TMR_IRQ;
opp->brr1 = -1;
list = list_le;
list[2].map = false;
if (opp->nb_cpus != 1) {
return -EINVAL;
}
break;
}
memory_region_init(&opp->mem, "openpic", 0x40000);
for (i = 0; i < ARRAY_SIZE(list_le); i++) {
if (!list[i].map) {
continue;
}
memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp,
list[i].name, list[i].size);
memory_region_add_subregion(&opp->mem, list[i].start_addr,
&opp->sub_io_mem[i]);
}
for (i = 0; i < opp->nb_cpus; i++) {
opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB);
for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {
sysbus_init_irq(dev, &opp->dst[i].irqs[j]);
}
}
register_savevm(&opp->busdev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
sysbus_init_mmio(dev, &opp->mem);
qdev_init_gpio_in(&dev->qdev, openpic_set_irq, opp->max_irq);
return 0;
}
| {
"code": [
" struct memreg list_le[] = {",
" struct memreg list_be[] = {",
" struct memreg *list;"
],
"line_no": [
9,
33,
57
]
} | static int FUNC_0(SysBusDevice *VAR_0)
{
OpenPICState *opp = FROM_SYSBUS(typeof (*opp), VAR_0);
int VAR_1, VAR_2;
struct memreg VAR_3[] = {
{"glb", &openpic_glb_ops_le, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_le, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_le, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_le, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_le, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg VAR_4[] = {
{"glb", &openpic_glb_ops_be, true,
OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},
{"tmr", &openpic_tmr_ops_be, true,
OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},
{"msi", &openpic_msi_ops_be, true,
OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},
{"src", &openpic_src_ops_be, true,
OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},
{"cpu", &openpic_cpu_ops_be, true,
OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},
};
struct memreg *VAR_5;
switch (opp->model) {
case OPENPIC_MODEL_FSL_MPIC_20:
default:
opp->flags |= OPENPIC_FLAG_IDE_CRIT;
opp->nb_irqs = 80;
opp->vid = VID_REVISION_1_2;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFFFF;
opp->tifr_reset = 0;
opp->ipvp_reset = IPVP_MASK_MASK;
opp->ide_reset = 1 << 0;
opp->max_irq = FSL_MPIC_20_MAX_IRQ;
opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ;
opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ;
opp->irq_msi = FSL_MPIC_20_MSI_IRQ;
opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;
msi_supported = true;
VAR_5 = VAR_4;
break;
case OPENPIC_MODEL_RAVEN:
opp->nb_irqs = RAVEN_MAX_EXT;
opp->vid = VID_REVISION_1_3;
opp->veni = VENI_GENERIC;
opp->vector_mask = 0xFF;
opp->tifr_reset = 4160000;
opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK;
opp->ide_reset = 0;
opp->max_irq = RAVEN_MAX_IRQ;
opp->irq_ipi0 = RAVEN_IPI_IRQ;
opp->irq_tim0 = RAVEN_TMR_IRQ;
opp->brr1 = -1;
VAR_5 = VAR_3;
VAR_5[2].map = false;
if (opp->nb_cpus != 1) {
return -EINVAL;
}
break;
}
memory_region_init(&opp->mem, "openpic", 0x40000);
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_3); VAR_1++) {
if (!VAR_5[VAR_1].map) {
continue;
}
memory_region_init_io(&opp->sub_io_mem[VAR_1], VAR_5[VAR_1].ops, opp,
VAR_5[VAR_1].name, VAR_5[VAR_1].size);
memory_region_add_subregion(&opp->mem, VAR_5[VAR_1].start_addr,
&opp->sub_io_mem[VAR_1]);
}
for (VAR_1 = 0; VAR_1 < opp->nb_cpus; VAR_1++) {
opp->dst[VAR_1].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB);
for (VAR_2 = 0; VAR_2 < OPENPIC_OUTPUT_NB; VAR_2++) {
sysbus_init_irq(VAR_0, &opp->dst[VAR_1].irqs[VAR_2]);
}
}
register_savevm(&opp->busdev.qdev, "openpic", 0, 2,
openpic_save, openpic_load, opp);
sysbus_init_mmio(VAR_0, &opp->mem);
qdev_init_gpio_in(&VAR_0->qdev, openpic_set_irq, opp->max_irq);
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"OpenPICState *opp = FROM_SYSBUS(typeof (*opp), VAR_0);",
"int VAR_1, VAR_2;",
"struct memreg VAR_3[] = {",
"{\"glb\", &openpic_glb_ops_le, true,",
"OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},",
"{\"tmr\", &openpic_tmr_ops_le, true,",
"OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},",
"{\"msi\", &openpic_msi_ops_le, true,",
"OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},",
"{\"src\", &openpic_src_ops_le, true,",
"OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},",
"{\"cpu\", &openpic_cpu_ops_le, true,",
"OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},",
"};",
"struct memreg VAR_4[] = {",
"{\"glb\", &openpic_glb_ops_be, true,",
"OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE},",
"{\"tmr\", &openpic_tmr_ops_be, true,",
"OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE},",
"{\"msi\", &openpic_msi_ops_be, true,",
"OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE},",
"{\"src\", &openpic_src_ops_be, true,",
"OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE},",
"{\"cpu\", &openpic_cpu_ops_be, true,",
"OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE},",
"};",
"struct memreg *VAR_5;",
"switch (opp->model) {",
"case OPENPIC_MODEL_FSL_MPIC_20:\ndefault:\nopp->flags |= OPENPIC_FLAG_IDE_CRIT;",
"opp->nb_irqs = 80;",
"opp->vid = VID_REVISION_1_2;",
"opp->veni = VENI_GENERIC;",
"opp->vector_mask = 0xFFFF;",
"opp->tifr_reset = 0;",
"opp->ipvp_reset = IPVP_MASK_MASK;",
"opp->ide_reset = 1 << 0;",
"opp->max_irq = FSL_MPIC_20_MAX_IRQ;",
"opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ;",
"opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ;",
"opp->irq_msi = FSL_MPIC_20_MSI_IRQ;",
"opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN;",
"msi_supported = true;",
"VAR_5 = VAR_4;",
"break;",
"case OPENPIC_MODEL_RAVEN:\nopp->nb_irqs = RAVEN_MAX_EXT;",
"opp->vid = VID_REVISION_1_3;",
"opp->veni = VENI_GENERIC;",
"opp->vector_mask = 0xFF;",
"opp->tifr_reset = 4160000;",
"opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK;",
"opp->ide_reset = 0;",
"opp->max_irq = RAVEN_MAX_IRQ;",
"opp->irq_ipi0 = RAVEN_IPI_IRQ;",
"opp->irq_tim0 = RAVEN_TMR_IRQ;",
"opp->brr1 = -1;",
"VAR_5 = VAR_3;",
"VAR_5[2].map = false;",
"if (opp->nb_cpus != 1) {",
"return -EINVAL;",
"}",
"break;",
"}",
"memory_region_init(&opp->mem, \"openpic\", 0x40000);",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_3); VAR_1++) {",
"if (!VAR_5[VAR_1].map) {",
"continue;",
"}",
"memory_region_init_io(&opp->sub_io_mem[VAR_1], VAR_5[VAR_1].ops, opp,\nVAR_5[VAR_1].name, VAR_5[VAR_1].size);",
"memory_region_add_subregion(&opp->mem, VAR_5[VAR_1].start_addr,\n&opp->sub_io_mem[VAR_1]);",
"}",
"for (VAR_1 = 0; VAR_1 < opp->nb_cpus; VAR_1++) {",
"opp->dst[VAR_1].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB);",
"for (VAR_2 = 0; VAR_2 < OPENPIC_OUTPUT_NB; VAR_2++) {",
"sysbus_init_irq(VAR_0, &opp->dst[VAR_1].irqs[VAR_2]);",
"}",
"}",
"register_savevm(&opp->busdev.qdev, \"openpic\", 0, 2,\nopenpic_save, openpic_load, opp);",
"sysbus_init_mmio(VAR_0, &opp->mem);",
"qdev_init_gpio_in(&VAR_0->qdev, openpic_set_irq, opp->max_irq);",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
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
],
[
127
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
165,
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
193
],
[
195
],
[
199
],
[
201
]
] |
19,084 | static int tgq_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt){
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_start = buf;
const uint8_t *buf_end = buf + buf_size;
TgqContext *s = avctx->priv_data;
int x,y;
int big_endian = AV_RL32(&buf[4]) > 0x000FFFFF;
buf += 8;
if(8>buf_end-buf) {
av_log(avctx, AV_LOG_WARNING, "truncated header\n");
return -1;
}
s->width = big_endian ? AV_RB16(&buf[0]) : AV_RL16(&buf[0]);
s->height = big_endian ? AV_RB16(&buf[2]) : AV_RL16(&buf[2]);
if (s->avctx->width!=s->width || s->avctx->height!=s->height) {
avcodec_set_dimensions(s->avctx, s->width, s->height);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
}
tgq_calculate_qtable(s, buf[4]);
buf += 8;
if (!s->frame.data[0]) {
s->frame.key_frame = 1;
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
if (avctx->get_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
for (y=0; y<(avctx->height+15)/16; y++)
for (x=0; x<(avctx->width+15)/16; x++)
tgq_decode_mb(s, y, x, &buf, buf_end);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf-buf_start;
}
| true | FFmpeg | 1255eed533b4069db7f205601953ca54c0dc42c9 | static int tgq_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt){
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
const uint8_t *buf_start = buf;
const uint8_t *buf_end = buf + buf_size;
TgqContext *s = avctx->priv_data;
int x,y;
int big_endian = AV_RL32(&buf[4]) > 0x000FFFFF;
buf += 8;
if(8>buf_end-buf) {
av_log(avctx, AV_LOG_WARNING, "truncated header\n");
return -1;
}
s->width = big_endian ? AV_RB16(&buf[0]) : AV_RL16(&buf[0]);
s->height = big_endian ? AV_RB16(&buf[2]) : AV_RL16(&buf[2]);
if (s->avctx->width!=s->width || s->avctx->height!=s->height) {
avcodec_set_dimensions(s->avctx, s->width, s->height);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
}
tgq_calculate_qtable(s, buf[4]);
buf += 8;
if (!s->frame.data[0]) {
s->frame.key_frame = 1;
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
if (avctx->get_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
for (y=0; y<(avctx->height+15)/16; y++)
for (x=0; x<(avctx->width+15)/16; x++)
tgq_decode_mb(s, y, x, &buf, buf_end);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf-buf_start;
}
| {
"code": [
" const uint8_t *buf_start = buf;",
" const uint8_t *buf_end = buf + buf_size;",
" buf += 8;",
" if(8>buf_end-buf) {",
" s->width = big_endian ? AV_RB16(&buf[0]) : AV_RL16(&buf[0]);",
" s->height = big_endian ? AV_RB16(&buf[2]) : AV_RL16(&buf[2]);",
" tgq_calculate_qtable(s, buf[4]);",
" buf += 8;",
" for (y=0; y<(avctx->height+15)/16; y++)",
" for (x=0; x<(avctx->width+15)/16; x++)",
" tgq_decode_mb(s, y, x, &buf, buf_end);",
" return buf-buf_start;"
],
"line_no": [
11,
13,
23,
27,
35,
37,
51,
23,
77,
79,
81,
91
]
} | 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;
const uint8_t *VAR_6 = VAR_4;
const uint8_t *VAR_7 = VAR_4 + VAR_5;
TgqContext *s = VAR_0->priv_data;
int VAR_8,VAR_9;
int VAR_10 = AV_RL32(&VAR_4[4]) > 0x000FFFFF;
VAR_4 += 8;
if(8>VAR_7-VAR_4) {
av_log(VAR_0, AV_LOG_WARNING, "truncated header\n");
return -1;
}
s->width = VAR_10 ? AV_RB16(&VAR_4[0]) : AV_RL16(&VAR_4[0]);
s->height = VAR_10 ? AV_RB16(&VAR_4[2]) : AV_RL16(&VAR_4[2]);
if (s->VAR_0->width!=s->width || s->VAR_0->height!=s->height) {
avcodec_set_dimensions(s->VAR_0, s->width, s->height);
if (s->frame.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->frame);
}
tgq_calculate_qtable(s, VAR_4[4]);
VAR_4 += 8;
if (!s->frame.VAR_1[0]) {
s->frame.key_frame = 1;
s->frame.pict_type = AV_PICTURE_TYPE_I;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
if (VAR_0->get_buffer(VAR_0, &s->frame)) {
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
for (VAR_9=0; VAR_9<(VAR_0->height+15)/16; VAR_9++)
for (VAR_8=0; VAR_8<(VAR_0->width+15)/16; VAR_8++)
tgq_decode_mb(s, VAR_9, VAR_8, &VAR_4, VAR_7);
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1 = s->frame;
return VAR_4-VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3){",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"const uint8_t *VAR_6 = VAR_4;",
"const uint8_t *VAR_7 = VAR_4 + VAR_5;",
"TgqContext *s = VAR_0->priv_data;",
"int VAR_8,VAR_9;",
"int VAR_10 = AV_RL32(&VAR_4[4]) > 0x000FFFFF;",
"VAR_4 += 8;",
"if(8>VAR_7-VAR_4) {",
"av_log(VAR_0, AV_LOG_WARNING, \"truncated header\\n\");",
"return -1;",
"}",
"s->width = VAR_10 ? AV_RB16(&VAR_4[0]) : AV_RL16(&VAR_4[0]);",
"s->height = VAR_10 ? AV_RB16(&VAR_4[2]) : AV_RL16(&VAR_4[2]);",
"if (s->VAR_0->width!=s->width || s->VAR_0->height!=s->height) {",
"avcodec_set_dimensions(s->VAR_0, s->width, s->height);",
"if (s->frame.VAR_1[0])\nVAR_0->release_buffer(VAR_0, &s->frame);",
"}",
"tgq_calculate_qtable(s, VAR_4[4]);",
"VAR_4 += 8;",
"if (!s->frame.VAR_1[0]) {",
"s->frame.key_frame = 1;",
"s->frame.pict_type = AV_PICTURE_TYPE_I;",
"s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;",
"if (VAR_0->get_buffer(VAR_0, &s->frame)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"}",
"for (VAR_9=0; VAR_9<(VAR_0->height+15)/16; VAR_9++)",
"for (VAR_8=0; VAR_8<(VAR_0->width+15)/16; VAR_8++)",
"tgq_decode_mb(s, VAR_9, VAR_8, &VAR_4, VAR_7);",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1 = s->frame;",
"return VAR_4-VAR_6;",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
19,085 | static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
MpegTSFilter *tss;
int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity,
has_adaptation, has_payload;
const uint8_t *p, *p_end;
int64_t pos;
pid = AV_RB16(packet + 1) & 0x1fff;
if (pid && discard_pid(ts, pid))
return 0;
is_start = packet[1] & 0x40;
tss = ts->pids[pid];
if (ts->auto_guess && !tss && is_start) {
add_pes_stream(ts, pid, -1);
tss = ts->pids[pid];
if (!tss)
return 0;
ts->current_pid = pid;
afc = (packet[3] >> 4) & 3;
if (afc == 0) /* reserved value */
return 0;
has_adaptation = afc & 2;
has_payload = afc & 1;
is_discontinuity = has_adaptation &&
packet[4] != 0 && /* with length > 0 */
(packet[5] & 0x80); /* and discontinuity indicated */
/* continuity check (currently not used) */
cc = (packet[3] & 0xf);
expected_cc = has_payload ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
cc_ok = pid == 0x1FFF || // null packet PID
is_discontinuity ||
tss->last_cc < 0 ||
expected_cc == cc;
tss->last_cc = cc;
if (!cc_ok) {
av_log(ts->stream, AV_LOG_DEBUG,
"Continuity check failed for pid %d expected %d got %d\n",
pid, expected_cc, cc);
p = packet + 4;
if (has_adaptation) {
int64_t pcr_h;
int pcr_l;
if (parse_pcr(&pcr_h, &pcr_l, packet) == 0)
tss->last_pcr = pcr_h * 300 + pcr_l;
/* skip adaptation field */
p += p[0] + 1;
/* if past the end of packet, ignore */
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end || !has_payload)
return 0;
pos = avio_tell(ts->stream->pb);
if (pos >= 0) {
av_assert0(pos >= TS_PACKET_SIZE);
ts->pos47_full = pos - TS_PACKET_SIZE;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
/* pointer field present */
len = *p++;
if (len > p_end - p)
return 0;
if (len && cc_ok) {
/* write remaining section bytes */
write_section_data(ts, tss,
p, len, 0);
/* check whether filter has been closed */
if (!ts->pids[pid])
return 0;
p += len;
if (p < p_end) {
write_section_data(ts, tss,
p, p_end - p, 1);
} else {
if (cc_ok) {
write_section_data(ts, tss,
p, p_end - p, 0);
// stop find_stream_info from waiting for more streams
// when all programs have received a PMT
if (ts->stream->ctx_flags & AVFMTCTX_NOHEADER && ts->scan_all_pmts <= 0) {
int i;
for (i = 0; i < ts->nb_prg; i++) {
if (!ts->prg[i].pmt_found)
break;
if (i == ts->nb_prg && ts->nb_prg > 0) {
int types = 0;
for (i = 0; i < ts->stream->nb_streams; i++) {
AVStream *st = ts->stream->streams[i];
if (st->codecpar->codec_type >= 0)
types |= 1<<st->codecpar->codec_type;
if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) {
av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n");
ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;
} else {
int ret;
// Note: The position here points actually behind the current packet.
if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start,
pos - ts->raw_packet_size)) < 0)
return ret;
return 0; | true | FFmpeg | 2e391a576c1fc2e8816990924c6e4c21ccf75a82 | static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
MpegTSFilter *tss;
int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity,
has_adaptation, has_payload;
const uint8_t *p, *p_end;
int64_t pos;
pid = AV_RB16(packet + 1) & 0x1fff;
if (pid && discard_pid(ts, pid))
return 0;
is_start = packet[1] & 0x40;
tss = ts->pids[pid];
if (ts->auto_guess && !tss && is_start) {
add_pes_stream(ts, pid, -1);
tss = ts->pids[pid];
if (!tss)
return 0;
ts->current_pid = pid;
afc = (packet[3] >> 4) & 3;
if (afc == 0)
return 0;
has_adaptation = afc & 2;
has_payload = afc & 1;
is_discontinuity = has_adaptation &&
packet[4] != 0 &&
(packet[5] & 0x80);
cc = (packet[3] & 0xf);
expected_cc = has_payload ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
cc_ok = pid == 0x1FFF ||
is_discontinuity ||
tss->last_cc < 0 ||
expected_cc == cc;
tss->last_cc = cc;
if (!cc_ok) {
av_log(ts->stream, AV_LOG_DEBUG,
"Continuity check failed for pid %d expected %d got %d\n",
pid, expected_cc, cc);
p = packet + 4;
if (has_adaptation) {
int64_t pcr_h;
int pcr_l;
if (parse_pcr(&pcr_h, &pcr_l, packet) == 0)
tss->last_pcr = pcr_h * 300 + pcr_l;
p += p[0] + 1;
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end || !has_payload)
return 0;
pos = avio_tell(ts->stream->pb);
if (pos >= 0) {
av_assert0(pos >= TS_PACKET_SIZE);
ts->pos47_full = pos - TS_PACKET_SIZE;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
len = *p++;
if (len > p_end - p)
return 0;
if (len && cc_ok) {
write_section_data(ts, tss,
p, len, 0);
if (!ts->pids[pid])
return 0;
p += len;
if (p < p_end) {
write_section_data(ts, tss,
p, p_end - p, 1);
} else {
if (cc_ok) {
write_section_data(ts, tss,
p, p_end - p, 0);
if (ts->stream->ctx_flags & AVFMTCTX_NOHEADER && ts->scan_all_pmts <= 0) {
int i;
for (i = 0; i < ts->nb_prg; i++) {
if (!ts->prg[i].pmt_found)
break;
if (i == ts->nb_prg && ts->nb_prg > 0) {
int types = 0;
for (i = 0; i < ts->stream->nb_streams; i++) {
AVStream *st = ts->stream->streams[i];
if (st->codecpar->codec_type >= 0)
types |= 1<<st->codecpar->codec_type;
if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) {
av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n");
ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;
} else {
int ret;
if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start,
pos - ts->raw_packet_size)) < 0)
return ret;
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(MpegTSContext *VAR_0, const uint8_t *VAR_1)
{
MpegTSFilter *tss;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9,
VAR_10, VAR_11;
const uint8_t *VAR_12, *p_end;
int64_t pos;
VAR_3 = AV_RB16(VAR_1 + 1) & 0x1fff;
if (VAR_3 && discard_pid(VAR_0, VAR_3))
return 0;
VAR_8 = VAR_1[1] & 0x40;
tss = VAR_0->pids[VAR_3];
if (VAR_0->auto_guess && !tss && VAR_8) {
add_pes_stream(VAR_0, VAR_3, -1);
tss = VAR_0->pids[VAR_3];
if (!tss)
return 0;
VAR_0->current_pid = VAR_3;
VAR_7 = (VAR_1[3] >> 4) & 3;
if (VAR_7 == 0)
return 0;
VAR_10 = VAR_7 & 2;
VAR_11 = VAR_7 & 1;
VAR_9 = VAR_10 &&
VAR_1[4] != 0 &&
(VAR_1[5] & 0x80);
VAR_4 = (VAR_1[3] & 0xf);
VAR_5 = VAR_11 ? (tss->last_cc + 1) & 0x0f : tss->last_cc;
VAR_6 = VAR_3 == 0x1FFF ||
VAR_9 ||
tss->last_cc < 0 ||
VAR_5 == VAR_4;
tss->last_cc = VAR_4;
if (!VAR_6) {
av_log(VAR_0->stream, AV_LOG_DEBUG,
"Continuity check failed for VAR_3 %d expected %d got %d\n",
VAR_3, VAR_5, VAR_4);
VAR_12 = VAR_1 + 4;
if (VAR_10) {
int64_t pcr_h;
int VAR_13;
if (parse_pcr(&pcr_h, &VAR_13, VAR_1) == 0)
tss->last_pcr = pcr_h * 300 + VAR_13;
VAR_12 += VAR_12[0] + 1;
p_end = VAR_1 + TS_PACKET_SIZE;
if (VAR_12 >= p_end || !VAR_11)
return 0;
pos = avio_tell(VAR_0->stream->pb);
if (pos >= 0) {
av_assert0(pos >= TS_PACKET_SIZE);
VAR_0->pos47_full = pos - TS_PACKET_SIZE;
if (tss->type == MPEGTS_SECTION) {
if (VAR_8) {
VAR_2 = *VAR_12++;
if (VAR_2 > p_end - VAR_12)
return 0;
if (VAR_2 && VAR_6) {
write_section_data(VAR_0, tss,
VAR_12, VAR_2, 0);
if (!VAR_0->pids[VAR_3])
return 0;
VAR_12 += VAR_2;
if (VAR_12 < p_end) {
write_section_data(VAR_0, tss,
VAR_12, p_end - VAR_12, 1);
} else {
if (VAR_6) {
write_section_data(VAR_0, tss,
VAR_12, p_end - VAR_12, 0);
if (VAR_0->stream->ctx_flags & AVFMTCTX_NOHEADER && VAR_0->scan_all_pmts <= 0) {
int VAR_14;
for (VAR_14 = 0; VAR_14 < VAR_0->nb_prg; VAR_14++) {
if (!VAR_0->prg[VAR_14].pmt_found)
break;
if (VAR_14 == VAR_0->nb_prg && VAR_0->nb_prg > 0) {
int types = 0;
for (VAR_14 = 0; VAR_14 < VAR_0->stream->nb_streams; VAR_14++) {
AVStream *st = VAR_0->stream->streams[VAR_14];
if (st->codecpar->codec_type >= 0)
types |= 1<<st->codecpar->codec_type;
if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) {
av_log(VAR_0->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n");
VAR_0->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;
} else {
int ret;
if ((ret = tss->u.pes_filter.pes_cb(tss, VAR_12, p_end - VAR_12, VAR_8,
pos - VAR_0->raw_packet_size)) < 0)
return ret;
return 0; | [
"static int FUNC_0(MpegTSContext *VAR_0, const uint8_t *VAR_1)\n{",
"MpegTSFilter *tss;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9,\nVAR_10, VAR_11;",
"const uint8_t *VAR_12, *p_end;",
"int64_t pos;",
"VAR_3 = AV_RB16(VAR_1 + 1) & 0x1fff;",
"if (VAR_3 && discard_pid(VAR_0, VAR_3))\nreturn 0;",
"VAR_8 = VAR_1[1] & 0x40;",
"tss = VAR_0->pids[VAR_3];",
"if (VAR_0->auto_guess && !tss && VAR_8) {",
"add_pes_stream(VAR_0, VAR_3, -1);",
"tss = VAR_0->pids[VAR_3];",
"if (!tss)\nreturn 0;",
"VAR_0->current_pid = VAR_3;",
"VAR_7 = (VAR_1[3] >> 4) & 3;",
"if (VAR_7 == 0)\nreturn 0;",
"VAR_10 = VAR_7 & 2;",
"VAR_11 = VAR_7 & 1;",
"VAR_9 = VAR_10 &&\nVAR_1[4] != 0 &&\n(VAR_1[5] & 0x80);",
"VAR_4 = (VAR_1[3] & 0xf);",
"VAR_5 = VAR_11 ? (tss->last_cc + 1) & 0x0f : tss->last_cc;",
"VAR_6 = VAR_3 == 0x1FFF ||\nVAR_9 ||\ntss->last_cc < 0 ||\nVAR_5 == VAR_4;",
"tss->last_cc = VAR_4;",
"if (!VAR_6) {",
"av_log(VAR_0->stream, AV_LOG_DEBUG,\n\"Continuity check failed for VAR_3 %d expected %d got %d\\n\",\nVAR_3, VAR_5, VAR_4);",
"VAR_12 = VAR_1 + 4;",
"if (VAR_10) {",
"int64_t pcr_h;",
"int VAR_13;",
"if (parse_pcr(&pcr_h, &VAR_13, VAR_1) == 0)\ntss->last_pcr = pcr_h * 300 + VAR_13;",
"VAR_12 += VAR_12[0] + 1;",
"p_end = VAR_1 + TS_PACKET_SIZE;",
"if (VAR_12 >= p_end || !VAR_11)\nreturn 0;",
"pos = avio_tell(VAR_0->stream->pb);",
"if (pos >= 0) {",
"av_assert0(pos >= TS_PACKET_SIZE);",
"VAR_0->pos47_full = pos - TS_PACKET_SIZE;",
"if (tss->type == MPEGTS_SECTION) {",
"if (VAR_8) {",
"VAR_2 = *VAR_12++;",
"if (VAR_2 > p_end - VAR_12)\nreturn 0;",
"if (VAR_2 && VAR_6) {",
"write_section_data(VAR_0, tss,\nVAR_12, VAR_2, 0);",
"if (!VAR_0->pids[VAR_3])\nreturn 0;",
"VAR_12 += VAR_2;",
"if (VAR_12 < p_end) {",
"write_section_data(VAR_0, tss,\nVAR_12, p_end - VAR_12, 1);",
"} else {",
"if (VAR_6) {",
"write_section_data(VAR_0, tss,\nVAR_12, p_end - VAR_12, 0);",
"if (VAR_0->stream->ctx_flags & AVFMTCTX_NOHEADER && VAR_0->scan_all_pmts <= 0) {",
"int VAR_14;",
"for (VAR_14 = 0; VAR_14 < VAR_0->nb_prg; VAR_14++) {",
"if (!VAR_0->prg[VAR_14].pmt_found)\nbreak;",
"if (VAR_14 == VAR_0->nb_prg && VAR_0->nb_prg > 0) {",
"int types = 0;",
"for (VAR_14 = 0; VAR_14 < VAR_0->stream->nb_streams; VAR_14++) {",
"AVStream *st = VAR_0->stream->streams[VAR_14];",
"if (st->codecpar->codec_type >= 0)\ntypes |= 1<<st->codecpar->codec_type;",
"if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) {",
"av_log(VAR_0->stream, AV_LOG_DEBUG, \"All programs have pmt, headers found\\n\");",
"VAR_0->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;",
"} else {",
"int ret;",
"if ((ret = tss->u.pes_filter.pes_cb(tss, VAR_12, p_end - VAR_12, VAR_8,\npos - VAR_0->raw_packet_size)) < 0)\nreturn ret;",
"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
] | [
[
1,
2
],
[
3
],
[
4,
5
],
[
6
],
[
7
],
[
8
],
[
9,
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16,
17
],
[
18
],
[
19
],
[
20,
21
],
[
22
],
[
23
],
[
24,
25,
26
],
[
28
],
[
29
],
[
30,
31,
32,
33
],
[
34
],
[
35
],
[
36,
37,
38
],
[
39
],
[
40
],
[
41
],
[
42
],
[
43,
44
],
[
46
],
[
48
],
[
49,
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
58
],
[
59,
60
],
[
61
],
[
63,
64
],
[
66,
67
],
[
68
],
[
69
],
[
70,
71
],
[
72
],
[
73
],
[
74,
75
],
[
78
],
[
79
],
[
80
],
[
81,
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87,
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
95,
96,
97
],
[
98
]
] |
19,086 | void qmp_guest_suspend_disk(Error **errp)
{
Error *local_err = NULL;
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
*mode = GUEST_SUSPEND_MODE_DISK;
check_suspend_mode(*mode, &local_err);
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
execute_async(do_suspend, mode, &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(mode);
}
}
| true | qemu | f3a06403b82c7f036564e4caf18b52ce6885fcfb | void qmp_guest_suspend_disk(Error **errp)
{
Error *local_err = NULL;
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
*mode = GUEST_SUSPEND_MODE_DISK;
check_suspend_mode(*mode, &local_err);
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
execute_async(do_suspend, mode, &local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(mode);
}
}
| {
"code": [
" GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));",
" GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));"
],
"line_no": [
7,
7
]
} | void FUNC_0(Error **VAR_0)
{
Error *local_err = NULL;
GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
*mode = GUEST_SUSPEND_MODE_DISK;
check_suspend_mode(*mode, &local_err);
acquire_privilege(SE_SHUTDOWN_NAME, &local_err);
execute_async(do_suspend, mode, &local_err);
if (local_err) {
error_propagate(VAR_0, local_err);
g_free(mode);
}
}
| [
"void FUNC_0(Error **VAR_0)\n{",
"Error *local_err = NULL;",
"GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));",
"*mode = GUEST_SUSPEND_MODE_DISK;",
"check_suspend_mode(*mode, &local_err);",
"acquire_privilege(SE_SHUTDOWN_NAME, &local_err);",
"execute_async(do_suspend, mode, &local_err);",
"if (local_err) {",
"error_propagate(VAR_0, local_err);",
"g_free(mode);",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
19,088 | static void kvm_pit_put(PITCommonState *pit)
{
KVMPITState *s = KVM_PIT(pit);
struct kvm_pit_state2 kpit;
struct kvm_pit_channel_state *kchan;
struct PITChannelState *sc;
int i, ret;
/* The offset keeps changing as long as the VM is stopped. */
if (s->vm_stopped) {
kvm_pit_update_clock_offset(s);
}
kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;
for (i = 0; i < 3; i++) {
kchan = &kpit.channels[i];
sc = &pit->channels[i];
kchan->count = sc->count;
kchan->latched_count = sc->latched_count;
kchan->count_latched = sc->count_latched;
kchan->status_latched = sc->status_latched;
kchan->status = sc->status;
kchan->read_state = sc->read_state;
kchan->write_state = sc->write_state;
kchan->write_latch = sc->write_latch;
kchan->rw_mode = sc->rw_mode;
kchan->mode = sc->mode;
kchan->bcd = sc->bcd;
kchan->gate = sc->gate;
kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset;
}
ret = kvm_vm_ioctl(kvm_state,
kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,
&kpit);
if (ret < 0) {
fprintf(stderr, "%s failed: %s\n",
kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
strerror(ret));
abort();
}
}
| false | qemu | b0a0551283076c6f3e57cf2bdd525334009b2677 | static void kvm_pit_put(PITCommonState *pit)
{
KVMPITState *s = KVM_PIT(pit);
struct kvm_pit_state2 kpit;
struct kvm_pit_channel_state *kchan;
struct PITChannelState *sc;
int i, ret;
if (s->vm_stopped) {
kvm_pit_update_clock_offset(s);
}
kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;
for (i = 0; i < 3; i++) {
kchan = &kpit.channels[i];
sc = &pit->channels[i];
kchan->count = sc->count;
kchan->latched_count = sc->latched_count;
kchan->count_latched = sc->count_latched;
kchan->status_latched = sc->status_latched;
kchan->status = sc->status;
kchan->read_state = sc->read_state;
kchan->write_state = sc->write_state;
kchan->write_latch = sc->write_latch;
kchan->rw_mode = sc->rw_mode;
kchan->mode = sc->mode;
kchan->bcd = sc->bcd;
kchan->gate = sc->gate;
kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset;
}
ret = kvm_vm_ioctl(kvm_state,
kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,
&kpit);
if (ret < 0) {
fprintf(stderr, "%s failed: %s\n",
kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
strerror(ret));
abort();
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PITCommonState *VAR_0)
{
KVMPITState *s = KVM_PIT(VAR_0);
struct kvm_pit_state2 VAR_1;
struct kvm_pit_channel_state *VAR_2;
struct PITChannelState *VAR_3;
int VAR_4, VAR_5;
if (s->vm_stopped) {
kvm_pit_update_clock_offset(s);
}
VAR_1.flags = VAR_0->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;
for (VAR_4 = 0; VAR_4 < 3; VAR_4++) {
VAR_2 = &VAR_1.channels[VAR_4];
VAR_3 = &VAR_0->channels[VAR_4];
VAR_2->count = VAR_3->count;
VAR_2->latched_count = VAR_3->latched_count;
VAR_2->count_latched = VAR_3->count_latched;
VAR_2->status_latched = VAR_3->status_latched;
VAR_2->status = VAR_3->status;
VAR_2->read_state = VAR_3->read_state;
VAR_2->write_state = VAR_3->write_state;
VAR_2->write_latch = VAR_3->write_latch;
VAR_2->rw_mode = VAR_3->rw_mode;
VAR_2->mode = VAR_3->mode;
VAR_2->bcd = VAR_3->bcd;
VAR_2->gate = VAR_3->gate;
VAR_2->count_load_time = VAR_3->count_load_time - s->kernel_clock_offset;
}
VAR_5 = kvm_vm_ioctl(kvm_state,
kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,
&VAR_1);
if (VAR_5 < 0) {
fprintf(stderr, "%s failed: %s\n",
kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT",
strerror(VAR_5));
abort();
}
}
| [
"static void FUNC_0(PITCommonState *VAR_0)\n{",
"KVMPITState *s = KVM_PIT(VAR_0);",
"struct kvm_pit_state2 VAR_1;",
"struct kvm_pit_channel_state *VAR_2;",
"struct PITChannelState *VAR_3;",
"int VAR_4, VAR_5;",
"if (s->vm_stopped) {",
"kvm_pit_update_clock_offset(s);",
"}",
"VAR_1.flags = VAR_0->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0;",
"for (VAR_4 = 0; VAR_4 < 3; VAR_4++) {",
"VAR_2 = &VAR_1.channels[VAR_4];",
"VAR_3 = &VAR_0->channels[VAR_4];",
"VAR_2->count = VAR_3->count;",
"VAR_2->latched_count = VAR_3->latched_count;",
"VAR_2->count_latched = VAR_3->count_latched;",
"VAR_2->status_latched = VAR_3->status_latched;",
"VAR_2->status = VAR_3->status;",
"VAR_2->read_state = VAR_3->read_state;",
"VAR_2->write_state = VAR_3->write_state;",
"VAR_2->write_latch = VAR_3->write_latch;",
"VAR_2->rw_mode = VAR_3->rw_mode;",
"VAR_2->mode = VAR_3->mode;",
"VAR_2->bcd = VAR_3->bcd;",
"VAR_2->gate = VAR_3->gate;",
"VAR_2->count_load_time = VAR_3->count_load_time - s->kernel_clock_offset;",
"}",
"VAR_5 = kvm_vm_ioctl(kvm_state,\nkvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT,\n&VAR_1);",
"if (VAR_5 < 0) {",
"fprintf(stderr, \"%s failed: %s\\n\",\nkvm_has_pit_state2() ? \"KVM_SET_PIT2\" : \"KVM_SET_PIT\",\nstrerror(VAR_5));",
"abort();",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67,
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
]
] |
19,089 | static void vfio_rtl8168_window_quirk_write(void *opaque, hwaddr addr,
uint64_t data, unsigned size)
{
VFIOQuirk *quirk = opaque;
VFIOPCIDevice *vdev = quirk->vdev;
switch (addr) {
case 4: /* address */
if ((data & 0x7fff0000) == 0x10000) {
if (data & 0x10000000U &&
vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) {
trace_vfio_rtl8168_window_quirk_write_table(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
memory_region_dispatch_write(&vdev->pdev.msix_table_mmio,
(hwaddr)(quirk->data.address_match
& 0xfff),
data,
size,
MEMTXATTRS_UNSPECIFIED);
}
quirk->data.flags = 1;
quirk->data.address_match = data;
return;
}
quirk->data.flags = 0;
break;
case 0: /* data */
quirk->data.address_mask = data;
break;
}
trace_vfio_rtl8168_window_quirk_write_direct(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
vfio_region_write(&vdev->bars[quirk->data.bar].region,
addr + 0x70, data, size);
}
| false | qemu | 69970fcef937bddd7f745efe39501c7716fdfe56 | static void vfio_rtl8168_window_quirk_write(void *opaque, hwaddr addr,
uint64_t data, unsigned size)
{
VFIOQuirk *quirk = opaque;
VFIOPCIDevice *vdev = quirk->vdev;
switch (addr) {
case 4:
if ((data & 0x7fff0000) == 0x10000) {
if (data & 0x10000000U &&
vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) {
trace_vfio_rtl8168_window_quirk_write_table(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
memory_region_dispatch_write(&vdev->pdev.msix_table_mmio,
(hwaddr)(quirk->data.address_match
& 0xfff),
data,
size,
MEMTXATTRS_UNSPECIFIED);
}
quirk->data.flags = 1;
quirk->data.address_match = data;
return;
}
quirk->data.flags = 0;
break;
case 0:
quirk->data.address_mask = data;
break;
}
trace_vfio_rtl8168_window_quirk_write_direct(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
vfio_region_write(&vdev->bars[quirk->data.bar].region,
addr + 0x70, data, size);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
VFIOQuirk *quirk = VAR_0;
VFIOPCIDevice *vdev = quirk->vdev;
switch (VAR_1) {
case 4:
if ((VAR_2 & 0x7fff0000) == 0x10000) {
if (VAR_2 & 0x10000000U &&
vdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) {
trace_vfio_rtl8168_window_quirk_write_table(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
memory_region_dispatch_write(&vdev->pdev.msix_table_mmio,
(hwaddr)(quirk->VAR_2.address_match
& 0xfff),
VAR_2,
VAR_3,
MEMTXATTRS_UNSPECIFIED);
}
quirk->VAR_2.flags = 1;
quirk->VAR_2.address_match = VAR_2;
return;
}
quirk->VAR_2.flags = 0;
break;
case 0:
quirk->VAR_2.address_mask = VAR_2;
break;
}
trace_vfio_rtl8168_window_quirk_write_direct(
memory_region_name(&quirk->mem),
vdev->vbasedev.name);
vfio_region_write(&vdev->bars[quirk->VAR_2.bar].region,
VAR_1 + 0x70, VAR_2, VAR_3);
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"VFIOQuirk *quirk = VAR_0;",
"VFIOPCIDevice *vdev = quirk->vdev;",
"switch (VAR_1) {",
"case 4:\nif ((VAR_2 & 0x7fff0000) == 0x10000) {",
"if (VAR_2 & 0x10000000U &&\nvdev->pdev.cap_present & QEMU_PCI_CAP_MSIX) {",
"trace_vfio_rtl8168_window_quirk_write_table(\nmemory_region_name(&quirk->mem),\nvdev->vbasedev.name);",
"memory_region_dispatch_write(&vdev->pdev.msix_table_mmio,\n(hwaddr)(quirk->VAR_2.address_match\n& 0xfff),\nVAR_2,\nVAR_3,\nMEMTXATTRS_UNSPECIFIED);",
"}",
"quirk->VAR_2.flags = 1;",
"quirk->VAR_2.address_match = VAR_2;",
"return;",
"}",
"quirk->VAR_2.flags = 0;",
"break;",
"case 0:\nquirk->VAR_2.address_mask = VAR_2;",
"break;",
"}",
"trace_vfio_rtl8168_window_quirk_write_direct(\nmemory_region_name(&quirk->mem),\nvdev->vbasedev.name);",
"vfio_region_write(&vdev->bars[quirk->VAR_2.bar].region,\nVAR_1 + 0x70, VAR_2, VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19,
21
],
[
25,
27,
29
],
[
33,
35,
37,
39,
41,
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
73,
75,
77
],
[
81,
83
],
[
85
]
] |
19,091 | static void hash32_bat_601_size(CPUPPCState *env, target_ulong *blp, int *validp,
target_ulong batu, target_ulong batl)
{
target_ulong bl;
int valid;
bl = (batl & BATL32_601_BL) << 17;
LOG_BATS("b %02x ==> bl " TARGET_FMT_lx " msk " TARGET_FMT_lx "\n",
(uint8_t)(batl & BATL32_601_BL), bl, ~bl);
valid = !!(batl & BATL32_601_V);
*blp = bl;
*validp = valid;
}
| false | qemu | 6fc76aa9adc1c8896a97059f12a1e5e6c1820c64 | static void hash32_bat_601_size(CPUPPCState *env, target_ulong *blp, int *validp,
target_ulong batu, target_ulong batl)
{
target_ulong bl;
int valid;
bl = (batl & BATL32_601_BL) << 17;
LOG_BATS("b %02x ==> bl " TARGET_FMT_lx " msk " TARGET_FMT_lx "\n",
(uint8_t)(batl & BATL32_601_BL), bl, ~bl);
valid = !!(batl & BATL32_601_V);
*blp = bl;
*validp = valid;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUPPCState *VAR_0, target_ulong *VAR_1, int *VAR_2,
target_ulong VAR_3, target_ulong VAR_4)
{
target_ulong bl;
int VAR_5;
bl = (VAR_4 & BATL32_601_BL) << 17;
LOG_BATS("b %02x ==> bl " TARGET_FMT_lx " msk " TARGET_FMT_lx "\n",
(uint8_t)(VAR_4 & BATL32_601_BL), bl, ~bl);
VAR_5 = !!(VAR_4 & BATL32_601_V);
*VAR_1 = bl;
*VAR_2 = VAR_5;
}
| [
"static void FUNC_0(CPUPPCState *VAR_0, target_ulong *VAR_1, int *VAR_2,\ntarget_ulong VAR_3, target_ulong VAR_4)\n{",
"target_ulong bl;",
"int VAR_5;",
"bl = (VAR_4 & BATL32_601_BL) << 17;",
"LOG_BATS(\"b %02x ==> bl \" TARGET_FMT_lx \" msk \" TARGET_FMT_lx \"\\n\",\n(uint8_t)(VAR_4 & BATL32_601_BL), bl, ~bl);",
"VAR_5 = !!(VAR_4 & BATL32_601_V);",
"*VAR_1 = bl;",
"*VAR_2 = VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
19,092 | static size_t cache_get_cache_pos(const PageCache *cache,
uint64_t address)
{
size_t pos;
g_assert(cache->max_num_items);
pos = (address / cache->page_size) & (cache->max_num_items - 1);
return pos;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | static size_t cache_get_cache_pos(const PageCache *cache,
uint64_t address)
{
size_t pos;
g_assert(cache->max_num_items);
pos = (address / cache->page_size) & (cache->max_num_items - 1);
return pos;
}
| {
"code": [],
"line_no": []
} | static size_t FUNC_0(const PageCache *cache,
uint64_t address)
{
size_t pos;
g_assert(cache->max_num_items);
pos = (address / cache->page_size) & (cache->max_num_items - 1);
return pos;
}
| [
"static size_t FUNC_0(const PageCache *cache,\nuint64_t address)\n{",
"size_t pos;",
"g_assert(cache->max_num_items);",
"pos = (address / cache->page_size) & (cache->max_num_items - 1);",
"return pos;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,093 | void vnc_display_init(DisplayState *ds)
{
VncState *vs;
vs = qemu_mallocz(sizeof(VncState));
if (!vs)
exit(1);
ds->opaque = vs;
vnc_state = vs;
vs->display = NULL;
vs->password = NULL;
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
vs->last_x = -1;
vs->last_y = -1;
vs->ds = ds;
if (!keyboard_layout)
keyboard_layout = "en-us";
vs->kbd_layout = init_keyboard_layout(keyboard_layout);
if (!vs->kbd_layout)
exit(1);
vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;
vs->ds->dpy_resize = vnc_dpy_resize;
vs->ds->dpy_refresh = NULL;
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
vnc_dpy_resize(vs->ds, 640, 400);
}
| false | qemu | 8bba5c81b1febeb20cdd60f1c18eb0e695cad6d6 | void vnc_display_init(DisplayState *ds)
{
VncState *vs;
vs = qemu_mallocz(sizeof(VncState));
if (!vs)
exit(1);
ds->opaque = vs;
vnc_state = vs;
vs->display = NULL;
vs->password = NULL;
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
vs->last_x = -1;
vs->last_y = -1;
vs->ds = ds;
if (!keyboard_layout)
keyboard_layout = "en-us";
vs->kbd_layout = init_keyboard_layout(keyboard_layout);
if (!vs->kbd_layout)
exit(1);
vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;
vs->ds->dpy_resize = vnc_dpy_resize;
vs->ds->dpy_refresh = NULL;
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
vnc_dpy_resize(vs->ds, 640, 400);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DisplayState *VAR_0)
{
VncState *vs;
vs = qemu_mallocz(sizeof(VncState));
if (!vs)
exit(1);
VAR_0->opaque = vs;
vnc_state = vs;
vs->display = NULL;
vs->password = NULL;
vs->lsock = -1;
vs->csock = -1;
vs->depth = 4;
vs->last_x = -1;
vs->last_y = -1;
vs->VAR_0 = VAR_0;
if (!keyboard_layout)
keyboard_layout = "en-us";
vs->kbd_layout = init_keyboard_layout(keyboard_layout);
if (!vs->kbd_layout)
exit(1);
vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);
vs->VAR_0->data = NULL;
vs->VAR_0->dpy_update = vnc_dpy_update;
vs->VAR_0->dpy_resize = vnc_dpy_resize;
vs->VAR_0->dpy_refresh = NULL;
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
vnc_dpy_resize(vs->VAR_0, 640, 400);
}
| [
"void FUNC_0(DisplayState *VAR_0)\n{",
"VncState *vs;",
"vs = qemu_mallocz(sizeof(VncState));",
"if (!vs)\nexit(1);",
"VAR_0->opaque = vs;",
"vnc_state = vs;",
"vs->display = NULL;",
"vs->password = NULL;",
"vs->lsock = -1;",
"vs->csock = -1;",
"vs->depth = 4;",
"vs->last_x = -1;",
"vs->last_y = -1;",
"vs->VAR_0 = VAR_0;",
"if (!keyboard_layout)\nkeyboard_layout = \"en-us\";",
"vs->kbd_layout = init_keyboard_layout(keyboard_layout);",
"if (!vs->kbd_layout)\nexit(1);",
"vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs);",
"vs->VAR_0->data = NULL;",
"vs->VAR_0->dpy_update = vnc_dpy_update;",
"vs->VAR_0->dpy_resize = vnc_dpy_resize;",
"vs->VAR_0->dpy_refresh = NULL;",
"memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));",
"vnc_dpy_resize(vs->VAR_0, 640, 400);",
"}"
] | [
0,
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
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43,
45
],
[
49
],
[
51,
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
77
]
] |
19,094 | QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
{
QemuOpts *opts;
TAILQ_FOREACH(opts, &list->head, next) {
if (!opts->id) {
continue;
}
if (strcmp(opts->id, id) != 0) {
continue;
}
return opts;
}
return NULL;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
{
QemuOpts *opts;
TAILQ_FOREACH(opts, &list->head, next) {
if (!opts->id) {
continue;
}
if (strcmp(opts->id, id) != 0) {
continue;
}
return opts;
}
return NULL;
}
| {
"code": [],
"line_no": []
} | QemuOpts *FUNC_0(QemuOptsList *list, const char *id)
{
QemuOpts *opts;
TAILQ_FOREACH(opts, &list->head, next) {
if (!opts->id) {
continue;
}
if (strcmp(opts->id, id) != 0) {
continue;
}
return opts;
}
return NULL;
}
| [
"QemuOpts *FUNC_0(QemuOptsList *list, const char *id)\n{",
"QemuOpts *opts;",
"TAILQ_FOREACH(opts, &list->head, next) {",
"if (!opts->id) {",
"continue;",
"}",
"if (strcmp(opts->id, id) != 0) {",
"continue;",
"}",
"return opts;",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
19,095 | static inline TranslationBlock *tb_find_fast(void)
{
TranslationBlock *tb;
target_ulong cs_base, pc;
int flags;
/* we record a subset of the CPU state. It will
always be the same before a given translated block
is executed. */
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags)) {
tb = tb_find_slow(pc, cs_base, flags);
}
return tb;
}
| false | qemu | cea5f9a28faa528b6b1b117c9ab2d8828f473fef | static inline TranslationBlock *tb_find_fast(void)
{
TranslationBlock *tb;
target_ulong cs_base, pc;
int flags;
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags)) {
tb = tb_find_slow(pc, cs_base, flags);
}
return tb;
}
| {
"code": [],
"line_no": []
} | static inline TranslationBlock *FUNC_0(void)
{
TranslationBlock *tb;
target_ulong cs_base, pc;
int VAR_0;
cpu_get_tb_cpu_state(env, &pc, &cs_base, &VAR_0);
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->VAR_0 != VAR_0)) {
tb = tb_find_slow(pc, cs_base, VAR_0);
}
return tb;
}
| [
"static inline TranslationBlock *FUNC_0(void)\n{",
"TranslationBlock *tb;",
"target_ulong cs_base, pc;",
"int VAR_0;",
"cpu_get_tb_cpu_state(env, &pc, &cs_base, &VAR_0);",
"tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];",
"if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||\ntb->VAR_0 != VAR_0)) {",
"tb = tb_find_slow(pc, cs_base, VAR_0);",
"}",
"return tb;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
19,096 | static void aio_timerlist_notify(void *opaque)
{
aio_notify(opaque);
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | static void aio_timerlist_notify(void *opaque)
{
aio_notify(opaque);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
aio_notify(VAR_0);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"aio_notify(VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
19,097 | void qdev_free(DeviceState *dev)
{
#if 0 /* FIXME: need sane vmstate_unregister function */
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
#endif
if (dev->info->reset)
qemu_unregister_reset(dev->info->reset, dev);
LIST_REMOVE(dev, sibling);
qemu_free(dev);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void qdev_free(DeviceState *dev)
{
#if 0
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
#endif
if (dev->info->reset)
qemu_unregister_reset(dev->info->reset, dev);
LIST_REMOVE(dev, sibling);
qemu_free(dev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DeviceState *VAR_0)
{
#if 0
if (VAR_0->info->vmsd)
vmstate_unregister(VAR_0->info->vmsd, VAR_0);
#endif
if (VAR_0->info->reset)
qemu_unregister_reset(VAR_0->info->reset, VAR_0);
LIST_REMOVE(VAR_0, sibling);
qemu_free(VAR_0);
}
| [
"void FUNC_0(DeviceState *VAR_0)\n{",
"#if 0\nif (VAR_0->info->vmsd)\nvmstate_unregister(VAR_0->info->vmsd, VAR_0);",
"#endif\nif (VAR_0->info->reset)\nqemu_unregister_reset(VAR_0->info->reset, VAR_0);",
"LIST_REMOVE(VAR_0, sibling);",
"qemu_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
]
] |
19,098 | static inline void write_back_motion(H264Context *h, int mb_type){
MpegEncContext * const s = &h->s;
const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
const int b8_xy= 2*s->mb_x + 2*s->mb_y*h->b8_stride;
int list;
if(!USES_LIST(mb_type, 0))
fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, h->b8_stride, (uint8_t)LIST_NOT_USED, 1);
for(list=0; list<2; list++){
int y;
if(!USES_LIST(mb_type, list))
continue;
for(y=0; y<4; y++){
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y];
}
if( h->pps.cabac ) {
if(IS_SKIP(mb_type))
fill_rectangle(h->mvd_table[list][b_xy], 4, 4, h->b_stride, 0, 4);
else
for(y=0; y<4; y++){
*(uint64_t*)h->mvd_table[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)h->mvd_table[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+2 + 8*y];
}
}
{
int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy];
ref_index[0+0*h->b8_stride]= h->ref_cache[list][scan8[0]];
ref_index[1+0*h->b8_stride]= h->ref_cache[list][scan8[4]];
ref_index[0+1*h->b8_stride]= h->ref_cache[list][scan8[8]];
ref_index[1+1*h->b8_stride]= h->ref_cache[list][scan8[12]];
}
}
if(h->slice_type == B_TYPE && h->pps.cabac){
if(IS_8X8(mb_type)){
uint8_t *direct_table = &h->direct_table[b8_xy];
direct_table[1+0*h->b8_stride] = IS_DIRECT(h->sub_mb_type[1]) ? 1 : 0;
direct_table[0+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[2]) ? 1 : 0;
direct_table[1+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[3]) ? 1 : 0;
}
}
}
| false | FFmpeg | 3425501d3b09650c6b295ba225e02e97c002372c | static inline void write_back_motion(H264Context *h, int mb_type){
MpegEncContext * const s = &h->s;
const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
const int b8_xy= 2*s->mb_x + 2*s->mb_y*h->b8_stride;
int list;
if(!USES_LIST(mb_type, 0))
fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, h->b8_stride, (uint8_t)LIST_NOT_USED, 1);
for(list=0; list<2; list++){
int y;
if(!USES_LIST(mb_type, list))
continue;
for(y=0; y<4; y++){
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y];
}
if( h->pps.cabac ) {
if(IS_SKIP(mb_type))
fill_rectangle(h->mvd_table[list][b_xy], 4, 4, h->b_stride, 0, 4);
else
for(y=0; y<4; y++){
*(uint64_t*)h->mvd_table[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+0 + 8*y];
*(uint64_t*)h->mvd_table[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mvd_cache[list][scan8[0]+2 + 8*y];
}
}
{
int8_t *ref_index = &s->current_picture.ref_index[list][b8_xy];
ref_index[0+0*h->b8_stride]= h->ref_cache[list][scan8[0]];
ref_index[1+0*h->b8_stride]= h->ref_cache[list][scan8[4]];
ref_index[0+1*h->b8_stride]= h->ref_cache[list][scan8[8]];
ref_index[1+1*h->b8_stride]= h->ref_cache[list][scan8[12]];
}
}
if(h->slice_type == B_TYPE && h->pps.cabac){
if(IS_8X8(mb_type)){
uint8_t *direct_table = &h->direct_table[b8_xy];
direct_table[1+0*h->b8_stride] = IS_DIRECT(h->sub_mb_type[1]) ? 1 : 0;
direct_table[0+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[2]) ? 1 : 0;
direct_table[1+1*h->b8_stride] = IS_DIRECT(h->sub_mb_type[3]) ? 1 : 0;
}
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(H264Context *VAR_0, int VAR_1){
MpegEncContext * const s = &VAR_0->s;
const int VAR_2 = 4*s->mb_x + 4*s->mb_y*VAR_0->b_stride;
const int VAR_3= 2*s->mb_x + 2*s->mb_y*VAR_0->b8_stride;
int VAR_4;
if(!USES_LIST(VAR_1, 0))
fill_rectangle(&s->current_picture.ref_index[0][VAR_3], 2, 2, VAR_0->b8_stride, (uint8_t)LIST_NOT_USED, 1);
for(VAR_4=0; VAR_4<2; VAR_4++){
int VAR_5;
if(!USES_LIST(VAR_1, VAR_4))
continue;
for(VAR_5=0; VAR_5<4; VAR_5++){
*(uint64_t*)s->current_picture.motion_val[VAR_4][VAR_2 + 0 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mv_cache[VAR_4][scan8[0]+0 + 8*VAR_5];
*(uint64_t*)s->current_picture.motion_val[VAR_4][VAR_2 + 2 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mv_cache[VAR_4][scan8[0]+2 + 8*VAR_5];
}
if( VAR_0->pps.cabac ) {
if(IS_SKIP(VAR_1))
fill_rectangle(VAR_0->mvd_table[VAR_4][VAR_2], 4, 4, VAR_0->b_stride, 0, 4);
else
for(VAR_5=0; VAR_5<4; VAR_5++){
*(uint64_t*)VAR_0->mvd_table[VAR_4][VAR_2 + 0 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mvd_cache[VAR_4][scan8[0]+0 + 8*VAR_5];
*(uint64_t*)VAR_0->mvd_table[VAR_4][VAR_2 + 2 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mvd_cache[VAR_4][scan8[0]+2 + 8*VAR_5];
}
}
{
int8_t *ref_index = &s->current_picture.ref_index[VAR_4][VAR_3];
ref_index[0+0*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[0]];
ref_index[1+0*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[4]];
ref_index[0+1*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[8]];
ref_index[1+1*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[12]];
}
}
if(VAR_0->slice_type == B_TYPE && VAR_0->pps.cabac){
if(IS_8X8(VAR_1)){
uint8_t *direct_table = &VAR_0->direct_table[VAR_3];
direct_table[1+0*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[1]) ? 1 : 0;
direct_table[0+1*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[2]) ? 1 : 0;
direct_table[1+1*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[3]) ? 1 : 0;
}
}
}
| [
"static inline void FUNC_0(H264Context *VAR_0, int VAR_1){",
"MpegEncContext * const s = &VAR_0->s;",
"const int VAR_2 = 4*s->mb_x + 4*s->mb_y*VAR_0->b_stride;",
"const int VAR_3= 2*s->mb_x + 2*s->mb_y*VAR_0->b8_stride;",
"int VAR_4;",
"if(!USES_LIST(VAR_1, 0))\nfill_rectangle(&s->current_picture.ref_index[0][VAR_3], 2, 2, VAR_0->b8_stride, (uint8_t)LIST_NOT_USED, 1);",
"for(VAR_4=0; VAR_4<2; VAR_4++){",
"int VAR_5;",
"if(!USES_LIST(VAR_1, VAR_4))\ncontinue;",
"for(VAR_5=0; VAR_5<4; VAR_5++){",
"*(uint64_t*)s->current_picture.motion_val[VAR_4][VAR_2 + 0 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mv_cache[VAR_4][scan8[0]+0 + 8*VAR_5];",
"*(uint64_t*)s->current_picture.motion_val[VAR_4][VAR_2 + 2 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mv_cache[VAR_4][scan8[0]+2 + 8*VAR_5];",
"}",
"if( VAR_0->pps.cabac ) {",
"if(IS_SKIP(VAR_1))\nfill_rectangle(VAR_0->mvd_table[VAR_4][VAR_2], 4, 4, VAR_0->b_stride, 0, 4);",
"else\nfor(VAR_5=0; VAR_5<4; VAR_5++){",
"*(uint64_t*)VAR_0->mvd_table[VAR_4][VAR_2 + 0 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mvd_cache[VAR_4][scan8[0]+0 + 8*VAR_5];",
"*(uint64_t*)VAR_0->mvd_table[VAR_4][VAR_2 + 2 + VAR_5*VAR_0->b_stride]= *(uint64_t*)VAR_0->mvd_cache[VAR_4][scan8[0]+2 + 8*VAR_5];",
"}",
"}",
"{",
"int8_t *ref_index = &s->current_picture.ref_index[VAR_4][VAR_3];",
"ref_index[0+0*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[0]];",
"ref_index[1+0*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[4]];",
"ref_index[0+1*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[8]];",
"ref_index[1+1*VAR_0->b8_stride]= VAR_0->ref_cache[VAR_4][scan8[12]];",
"}",
"}",
"if(VAR_0->slice_type == B_TYPE && VAR_0->pps.cabac){",
"if(IS_8X8(VAR_1)){",
"uint8_t *direct_table = &VAR_0->direct_table[VAR_3];",
"direct_table[1+0*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[1]) ? 1 : 0;",
"direct_table[0+1*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[2]) ? 1 : 0;",
"direct_table[1+1*VAR_0->b8_stride] = IS_DIRECT(VAR_0->sub_mb_type[3]) ? 1 : 0;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
19,100 | cac_new_pki_applet(int i, const unsigned char *cert,
int cert_len, VCardKey *key)
{
VCardAppletPrivate *applet_private = NULL;
VCardApplet *applet = NULL;
unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };
int pki_aid_len = sizeof(pki_aid);
pki_aid[pki_aid_len-1] = i;
applet_private = cac_new_pki_applet_private(cert, cert_len, key);
if (applet_private == NULL) {
goto failure;
}
applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset,
pki_aid, pki_aid_len);
if (applet == NULL) {
goto failure;
}
vcard_set_applet_private(applet, applet_private,
cac_delete_pki_applet_private);
applet_private = NULL;
return applet;
failure:
if (applet_private != NULL) {
cac_delete_pki_applet_private(applet_private);
}
return NULL;
}
| false | qemu | 1687a089f103f9b7a1b4a1555068054cb46ee9e9 | cac_new_pki_applet(int i, const unsigned char *cert,
int cert_len, VCardKey *key)
{
VCardAppletPrivate *applet_private = NULL;
VCardApplet *applet = NULL;
unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };
int pki_aid_len = sizeof(pki_aid);
pki_aid[pki_aid_len-1] = i;
applet_private = cac_new_pki_applet_private(cert, cert_len, key);
if (applet_private == NULL) {
goto failure;
}
applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset,
pki_aid, pki_aid_len);
if (applet == NULL) {
goto failure;
}
vcard_set_applet_private(applet, applet_private,
cac_delete_pki_applet_private);
applet_private = NULL;
return applet;
failure:
if (applet_private != NULL) {
cac_delete_pki_applet_private(applet_private);
}
return NULL;
}
| {
"code": [],
"line_no": []
} | FUNC_0(int VAR_0, const unsigned char *VAR_1,
int VAR_2, VCardKey *VAR_3)
{
VCardAppletPrivate *applet_private = NULL;
VCardApplet *applet = NULL;
unsigned char VAR_4[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };
int VAR_5 = sizeof(VAR_4);
VAR_4[VAR_5-1] = VAR_0;
applet_private = cac_new_pki_applet_private(VAR_1, VAR_2, VAR_3);
if (applet_private == NULL) {
goto failure;
}
applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset,
VAR_4, VAR_5);
if (applet == NULL) {
goto failure;
}
vcard_set_applet_private(applet, applet_private,
cac_delete_pki_applet_private);
applet_private = NULL;
return applet;
failure:
if (applet_private != NULL) {
cac_delete_pki_applet_private(applet_private);
}
return NULL;
}
| [
"FUNC_0(int VAR_0, const unsigned char *VAR_1,\nint VAR_2, VCardKey *VAR_3)\n{",
"VCardAppletPrivate *applet_private = NULL;",
"VCardApplet *applet = NULL;",
"unsigned char VAR_4[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };",
"int VAR_5 = sizeof(VAR_4);",
"VAR_4[VAR_5-1] = VAR_0;",
"applet_private = cac_new_pki_applet_private(VAR_1, VAR_2, VAR_3);",
"if (applet_private == NULL) {",
"goto failure;",
"}",
"applet = vcard_new_applet(cac_applet_pki_process_apdu, cac_applet_pki_reset,\nVAR_4, VAR_5);",
"if (applet == NULL) {",
"goto failure;",
"}",
"vcard_set_applet_private(applet, applet_private,\ncac_delete_pki_applet_private);",
"applet_private = NULL;",
"return applet;",
"failure:\nif (applet_private != NULL) {",
"cac_delete_pki_applet_private(applet_private);",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
19,101 | static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
struct tm new_tm;
time_t ti[2];
if (size != 1) {
return omap_badwidth_write8(opaque, addr, value);
}
switch (offset) {
case 0x00: /* SECONDS_REG */
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_sec;
s->ti += from_bcd(value);
return;
case 0x04: /* MINUTES_REG */
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_min * 60;
s->ti += from_bcd(value) * 60;
return;
case 0x08: /* HOURS_REG */
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_hour * 3600;
if (s->pm_am) {
s->ti += (from_bcd(value & 0x3f) & 12) * 3600;
s->ti += ((value >> 7) & 1) * 43200;
} else
s->ti += from_bcd(value & 0x3f) * 3600;
return;
case 0x0c: /* DAYS_REG */
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_mday * 86400;
s->ti += from_bcd(value) * 86400;
return;
case 0x10: /* MONTHS_REG */
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_mon = from_bcd(value);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
/* A less accurate version */
s->ti -= s->current_tm.tm_mon * 2592000;
s->ti += from_bcd(value) * 2592000;
}
return;
case 0x14: /* YEARS_REG */
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
/* A less accurate version */
s->ti -= (s->current_tm.tm_year % 100) * 31536000;
s->ti += from_bcd(value) * 31536000;
}
return;
case 0x18: /* WEEK_REG */
return; /* Ignored */
case 0x20: /* ALARM_SECONDS_REG */
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_sec = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x24: /* ALARM_MINUTES_REG */
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_min = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x28: /* ALARM_HOURS_REG */
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", value);
#endif
if (s->pm_am)
s->alarm_tm.tm_hour =
((from_bcd(value & 0x3f)) % 12) +
((value >> 7) & 1) * 12;
else
s->alarm_tm.tm_hour = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x2c: /* ALARM_DAYS_REG */
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mday = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x30: /* ALARM_MONTHS_REG */
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mon = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x34: /* ALARM_YEARS_REG */
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_year = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x40: /* RTC_CTRL_REG */
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", value);
#endif
s->pm_am = (value >> 3) & 1;
s->auto_comp = (value >> 2) & 1;
s->round = (value >> 1) & 1;
s->running = value & 1;
s->status &= 0xfd;
s->status |= s->running << 1;
return;
case 0x44: /* RTC_STATUS_REG */
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", value);
#endif
s->status &= ~((value & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(s);
return;
case 0x48: /* RTC_INTERRUPTS_REG */
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", value);
#endif
s->interrupts = value;
return;
case 0x4c: /* RTC_COMP_LSB_REG */
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", value);
#endif
s->comp_reg &= 0xff00;
s->comp_reg |= 0x00ff & value;
return;
case 0x50: /* RTC_COMP_MSB_REG */
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", value);
#endif
s->comp_reg &= 0x00ff;
s->comp_reg |= 0xff00 & (value << 8);
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void omap_rtc_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
struct tm new_tm;
time_t ti[2];
if (size != 1) {
return omap_badwidth_write8(opaque, addr, value);
}
switch (offset) {
case 0x00:
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_sec;
s->ti += from_bcd(value);
return;
case 0x04:
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_min * 60;
s->ti += from_bcd(value) * 60;
return;
case 0x08:
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_hour * 3600;
if (s->pm_am) {
s->ti += (from_bcd(value & 0x3f) & 12) * 3600;
s->ti += ((value >> 7) & 1) * 43200;
} else
s->ti += from_bcd(value & 0x3f) * 3600;
return;
case 0x0c:
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", value);
#endif
s->ti -= s->current_tm.tm_mday * 86400;
s->ti += from_bcd(value) * 86400;
return;
case 0x10:
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_mon = from_bcd(value);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
s->ti -= s->current_tm.tm_mon * 2592000;
s->ti += from_bcd(value) * 2592000;
}
return;
case 0x14:
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", value);
#endif
memcpy(&new_tm, &s->current_tm, sizeof(new_tm));
new_tm.tm_year += from_bcd(value) - (new_tm.tm_year % 100);
ti[0] = mktimegm(&s->current_tm);
ti[1] = mktimegm(&new_tm);
if (ti[0] != -1 && ti[1] != -1) {
s->ti -= ti[0];
s->ti += ti[1];
} else {
s->ti -= (s->current_tm.tm_year % 100) * 31536000;
s->ti += from_bcd(value) * 31536000;
}
return;
case 0x18:
return;
case 0x20:
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_sec = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x24:
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_min = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x28:
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", value);
#endif
if (s->pm_am)
s->alarm_tm.tm_hour =
((from_bcd(value & 0x3f)) % 12) +
((value >> 7) & 1) * 12;
else
s->alarm_tm.tm_hour = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x2c:
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mday = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x30:
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_mon = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x34:
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", value);
#endif
s->alarm_tm.tm_year = from_bcd(value);
omap_rtc_alarm_update(s);
return;
case 0x40:
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", value);
#endif
s->pm_am = (value >> 3) & 1;
s->auto_comp = (value >> 2) & 1;
s->round = (value >> 1) & 1;
s->running = value & 1;
s->status &= 0xfd;
s->status |= s->running << 1;
return;
case 0x44:
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", value);
#endif
s->status &= ~((value & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(s);
return;
case 0x48:
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", value);
#endif
s->interrupts = value;
return;
case 0x4c:
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", value);
#endif
s->comp_reg &= 0xff00;
s->comp_reg |= 0x00ff & value;
return;
case 0x50:
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", value);
#endif
s->comp_reg &= 0x00ff;
s->comp_reg |= 0xff00 & (value << 8);
return;
default:
OMAP_BAD_REG(addr);
return;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
struct omap_rtc_s *VAR_4 = (struct omap_rtc_s *) VAR_0;
int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK;
struct tm VAR_6;
time_t ti[2];
if (VAR_3 != 1) {
return omap_badwidth_write8(VAR_0, VAR_1, VAR_2);
}
switch (VAR_5) {
case 0x00:
#ifdef ALMDEBUG
printf("RTC SEC_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_sec;
VAR_4->ti += from_bcd(VAR_2);
return;
case 0x04:
#ifdef ALMDEBUG
printf("RTC MIN_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_min * 60;
VAR_4->ti += from_bcd(VAR_2) * 60;
return;
case 0x08:
#ifdef ALMDEBUG
printf("RTC HRS_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_hour * 3600;
if (VAR_4->pm_am) {
VAR_4->ti += (from_bcd(VAR_2 & 0x3f) & 12) * 3600;
VAR_4->ti += ((VAR_2 >> 7) & 1) * 43200;
} else
VAR_4->ti += from_bcd(VAR_2 & 0x3f) * 3600;
return;
case 0x0c:
#ifdef ALMDEBUG
printf("RTC DAY_REG <-- %02x\n", VAR_2);
#endif
VAR_4->ti -= VAR_4->current_tm.tm_mday * 86400;
VAR_4->ti += from_bcd(VAR_2) * 86400;
return;
case 0x10:
#ifdef ALMDEBUG
printf("RTC MTH_REG <-- %02x\n", VAR_2);
#endif
memcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));
VAR_6.tm_mon = from_bcd(VAR_2);
ti[0] = mktimegm(&VAR_4->current_tm);
ti[1] = mktimegm(&VAR_6);
if (ti[0] != -1 && ti[1] != -1) {
VAR_4->ti -= ti[0];
VAR_4->ti += ti[1];
} else {
VAR_4->ti -= VAR_4->current_tm.tm_mon * 2592000;
VAR_4->ti += from_bcd(VAR_2) * 2592000;
}
return;
case 0x14:
#ifdef ALMDEBUG
printf("RTC YRS_REG <-- %02x\n", VAR_2);
#endif
memcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));
VAR_6.tm_year += from_bcd(VAR_2) - (VAR_6.tm_year % 100);
ti[0] = mktimegm(&VAR_4->current_tm);
ti[1] = mktimegm(&VAR_6);
if (ti[0] != -1 && ti[1] != -1) {
VAR_4->ti -= ti[0];
VAR_4->ti += ti[1];
} else {
VAR_4->ti -= (VAR_4->current_tm.tm_year % 100) * 31536000;
VAR_4->ti += from_bcd(VAR_2) * 31536000;
}
return;
case 0x18:
return;
case 0x20:
#ifdef ALMDEBUG
printf("ALM SEC_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_sec = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x24:
#ifdef ALMDEBUG
printf("ALM MIN_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_min = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x28:
#ifdef ALMDEBUG
printf("ALM HRS_REG <-- %02x\n", VAR_2);
#endif
if (VAR_4->pm_am)
VAR_4->alarm_tm.tm_hour =
((from_bcd(VAR_2 & 0x3f)) % 12) +
((VAR_2 >> 7) & 1) * 12;
else
VAR_4->alarm_tm.tm_hour = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x2c:
#ifdef ALMDEBUG
printf("ALM DAY_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_mday = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x30:
#ifdef ALMDEBUG
printf("ALM MON_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_mon = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x34:
#ifdef ALMDEBUG
printf("ALM YRS_REG <-- %02x\n", VAR_2);
#endif
VAR_4->alarm_tm.tm_year = from_bcd(VAR_2);
omap_rtc_alarm_update(VAR_4);
return;
case 0x40:
#ifdef ALMDEBUG
printf("RTC CONTROL <-- %02x\n", VAR_2);
#endif
VAR_4->pm_am = (VAR_2 >> 3) & 1;
VAR_4->auto_comp = (VAR_2 >> 2) & 1;
VAR_4->round = (VAR_2 >> 1) & 1;
VAR_4->running = VAR_2 & 1;
VAR_4->status &= 0xfd;
VAR_4->status |= VAR_4->running << 1;
return;
case 0x44:
#ifdef ALMDEBUG
printf("RTC STATUSL <-- %02x\n", VAR_2);
#endif
VAR_4->status &= ~((VAR_2 & 0xc0) ^ 0x80);
omap_rtc_interrupts_update(VAR_4);
return;
case 0x48:
#ifdef ALMDEBUG
printf("RTC INTRS <-- %02x\n", VAR_2);
#endif
VAR_4->interrupts = VAR_2;
return;
case 0x4c:
#ifdef ALMDEBUG
printf("RTC COMPLSB <-- %02x\n", VAR_2);
#endif
VAR_4->comp_reg &= 0xff00;
VAR_4->comp_reg |= 0x00ff & VAR_2;
return;
case 0x50:
#ifdef ALMDEBUG
printf("RTC COMPMSB <-- %02x\n", VAR_2);
#endif
VAR_4->comp_reg &= 0x00ff;
VAR_4->comp_reg |= 0xff00 & (VAR_2 << 8);
return;
default:
OMAP_BAD_REG(VAR_1);
return;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"struct omap_rtc_s *VAR_4 = (struct omap_rtc_s *) VAR_0;",
"int VAR_5 = VAR_1 & OMAP_MPUI_REG_MASK;",
"struct tm VAR_6;",
"time_t ti[2];",
"if (VAR_3 != 1) {",
"return omap_badwidth_write8(VAR_0, VAR_1, VAR_2);",
"}",
"switch (VAR_5) {",
"case 0x00:\n#ifdef ALMDEBUG\nprintf(\"RTC SEC_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_sec;",
"VAR_4->ti += from_bcd(VAR_2);",
"return;",
"case 0x04:\n#ifdef ALMDEBUG\nprintf(\"RTC MIN_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_min * 60;",
"VAR_4->ti += from_bcd(VAR_2) * 60;",
"return;",
"case 0x08:\n#ifdef ALMDEBUG\nprintf(\"RTC HRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_hour * 3600;",
"if (VAR_4->pm_am) {",
"VAR_4->ti += (from_bcd(VAR_2 & 0x3f) & 12) * 3600;",
"VAR_4->ti += ((VAR_2 >> 7) & 1) * 43200;",
"} else",
"VAR_4->ti += from_bcd(VAR_2 & 0x3f) * 3600;",
"return;",
"case 0x0c:\n#ifdef ALMDEBUG\nprintf(\"RTC DAY_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->ti -= VAR_4->current_tm.tm_mday * 86400;",
"VAR_4->ti += from_bcd(VAR_2) * 86400;",
"return;",
"case 0x10:\n#ifdef ALMDEBUG\nprintf(\"RTC MTH_REG <-- %02x\\n\", VAR_2);",
"#endif\nmemcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));",
"VAR_6.tm_mon = from_bcd(VAR_2);",
"ti[0] = mktimegm(&VAR_4->current_tm);",
"ti[1] = mktimegm(&VAR_6);",
"if (ti[0] != -1 && ti[1] != -1) {",
"VAR_4->ti -= ti[0];",
"VAR_4->ti += ti[1];",
"} else {",
"VAR_4->ti -= VAR_4->current_tm.tm_mon * 2592000;",
"VAR_4->ti += from_bcd(VAR_2) * 2592000;",
"}",
"return;",
"case 0x14:\n#ifdef ALMDEBUG\nprintf(\"RTC YRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nmemcpy(&VAR_6, &VAR_4->current_tm, sizeof(VAR_6));",
"VAR_6.tm_year += from_bcd(VAR_2) - (VAR_6.tm_year % 100);",
"ti[0] = mktimegm(&VAR_4->current_tm);",
"ti[1] = mktimegm(&VAR_6);",
"if (ti[0] != -1 && ti[1] != -1) {",
"VAR_4->ti -= ti[0];",
"VAR_4->ti += ti[1];",
"} else {",
"VAR_4->ti -= (VAR_4->current_tm.tm_year % 100) * 31536000;",
"VAR_4->ti += from_bcd(VAR_2) * 31536000;",
"}",
"return;",
"case 0x18:\nreturn;",
"case 0x20:\n#ifdef ALMDEBUG\nprintf(\"ALM SEC_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_sec = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x24:\n#ifdef ALMDEBUG\nprintf(\"ALM MIN_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_min = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x28:\n#ifdef ALMDEBUG\nprintf(\"ALM HRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nif (VAR_4->pm_am)\nVAR_4->alarm_tm.tm_hour =\n((from_bcd(VAR_2 & 0x3f)) % 12) +\n((VAR_2 >> 7) & 1) * 12;",
"else\nVAR_4->alarm_tm.tm_hour = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x2c:\n#ifdef ALMDEBUG\nprintf(\"ALM DAY_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_mday = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x30:\n#ifdef ALMDEBUG\nprintf(\"ALM MON_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_mon = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x34:\n#ifdef ALMDEBUG\nprintf(\"ALM YRS_REG <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->alarm_tm.tm_year = from_bcd(VAR_2);",
"omap_rtc_alarm_update(VAR_4);",
"return;",
"case 0x40:\n#ifdef ALMDEBUG\nprintf(\"RTC CONTROL <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->pm_am = (VAR_2 >> 3) & 1;",
"VAR_4->auto_comp = (VAR_2 >> 2) & 1;",
"VAR_4->round = (VAR_2 >> 1) & 1;",
"VAR_4->running = VAR_2 & 1;",
"VAR_4->status &= 0xfd;",
"VAR_4->status |= VAR_4->running << 1;",
"return;",
"case 0x44:\n#ifdef ALMDEBUG\nprintf(\"RTC STATUSL <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->status &= ~((VAR_2 & 0xc0) ^ 0x80);",
"omap_rtc_interrupts_update(VAR_4);",
"return;",
"case 0x48:\n#ifdef ALMDEBUG\nprintf(\"RTC INTRS <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->interrupts = VAR_2;",
"return;",
"case 0x4c:\n#ifdef ALMDEBUG\nprintf(\"RTC COMPLSB <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->comp_reg &= 0xff00;",
"VAR_4->comp_reg |= 0x00ff & VAR_2;",
"return;",
"case 0x50:\n#ifdef ALMDEBUG\nprintf(\"RTC COMPMSB <-- %02x\\n\", VAR_2);",
"#endif\nVAR_4->comp_reg &= 0x00ff;",
"VAR_4->comp_reg |= 0xff00 & (VAR_2 << 8);",
"return;",
"default:\nOMAP_BAD_REG(VAR_1);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83,
85,
87
],
[
89,
91
],
[
93
],
[
95
],
[
99,
101,
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137,
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
181,
183,
185
],
[
187,
189
],
[
191
],
[
193
],
[
197,
199,
201
],
[
203,
205
],
[
207
],
[
209
],
[
213,
215,
217
],
[
219,
221,
223,
225,
227
],
[
229,
231
],
[
233
],
[
235
],
[
239,
241,
243
],
[
245,
247
],
[
249
],
[
251
],
[
255,
257,
259
],
[
261,
263
],
[
265
],
[
267
],
[
271,
273,
275
],
[
277,
279
],
[
281
],
[
283
],
[
287,
289,
291
],
[
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
311,
313,
315
],
[
317,
319
],
[
321
],
[
323
],
[
327,
329,
331
],
[
333,
335
],
[
337
],
[
341,
343,
345
],
[
347,
349
],
[
351
],
[
353
],
[
357,
359,
361
],
[
363,
365
],
[
367
],
[
369
],
[
373,
375
],
[
377
],
[
379
],
[
381
]
] |
19,103 | static void nbd_recv_coroutines_enter_all(BlockDriverState *bs)
{
NBDClientSession *s = nbd_get_client_session(bs);
int i;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
if (s->recv_coroutine[i]) {
qemu_coroutine_enter(s->recv_coroutine[i]);
}
}
BDRV_POLL_WHILE(bs, s->read_reply_co);
}
| false | qemu | a12a712a7dfbd2e2f4882ef2c90a9b2162166dd7 | static void nbd_recv_coroutines_enter_all(BlockDriverState *bs)
{
NBDClientSession *s = nbd_get_client_session(bs);
int i;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
if (s->recv_coroutine[i]) {
qemu_coroutine_enter(s->recv_coroutine[i]);
}
}
BDRV_POLL_WHILE(bs, s->read_reply_co);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0)
{
NBDClientSession *s = nbd_get_client_session(VAR_0);
int VAR_1;
for (VAR_1 = 0; VAR_1 < MAX_NBD_REQUESTS; VAR_1++) {
if (s->recv_coroutine[VAR_1]) {
qemu_coroutine_enter(s->recv_coroutine[VAR_1]);
}
}
BDRV_POLL_WHILE(VAR_0, s->read_reply_co);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"NBDClientSession *s = nbd_get_client_session(VAR_0);",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < MAX_NBD_REQUESTS; VAR_1++) {",
"if (s->recv_coroutine[VAR_1]) {",
"qemu_coroutine_enter(s->recv_coroutine[VAR_1]);",
"}",
"}",
"BDRV_POLL_WHILE(VAR_0, s->read_reply_co);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,104 | static void serial_xmit(void *opaque)
{
SerialState *s = opaque;
uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);
if (s->tsr_retry <= 0) {
if (s->fcr & UART_FCR_FE) {
s->tsr = fifo_get(s,XMIT_FIFO);
if (!s->xmit_fifo.count)
s->lsr |= UART_LSR_THRE;
} else {
s->tsr = s->thr;
s->lsr |= UART_LSR_THRE;
}
}
if (s->mcr & UART_MCR_LOOP) {
/* in loopback mode, say that we just received a char */
serial_receive1(s, &s->tsr, 1);
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) {
s->tsr_retry++;
qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);
return;
} else if (s->poll_msl < 0) {
/* If we exceed MAX_XMIT_RETRY and the backend is not a real serial port, then
drop any further failed writes instantly, until we get one that goes through.
This is to prevent guests that log to unconnected pipes or pty's from stalling. */
s->tsr_retry = -1;
}
}
else {
s->tsr_retry = 0;
}
s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
if (!(s->lsr & UART_LSR_THRE))
qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);
if (s->lsr & UART_LSR_THRE) {
s->lsr |= UART_LSR_TEMT;
s->thr_ipending = 1;
serial_update_irq(s);
}
}
| false | qemu | 67c5322d7000fd105a926eec44bc1765b7d70bdd | static void serial_xmit(void *opaque)
{
SerialState *s = opaque;
uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);
if (s->tsr_retry <= 0) {
if (s->fcr & UART_FCR_FE) {
s->tsr = fifo_get(s,XMIT_FIFO);
if (!s->xmit_fifo.count)
s->lsr |= UART_LSR_THRE;
} else {
s->tsr = s->thr;
s->lsr |= UART_LSR_THRE;
}
}
if (s->mcr & UART_MCR_LOOP) {
serial_receive1(s, &s->tsr, 1);
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) {
s->tsr_retry++;
qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);
return;
} else if (s->poll_msl < 0) {
s->tsr_retry = -1;
}
}
else {
s->tsr_retry = 0;
}
s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
if (!(s->lsr & UART_LSR_THRE))
qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);
if (s->lsr & UART_LSR_THRE) {
s->lsr |= UART_LSR_TEMT;
s->thr_ipending = 1;
serial_update_irq(s);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
SerialState *s = VAR_0;
uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);
if (s->tsr_retry <= 0) {
if (s->fcr & UART_FCR_FE) {
s->tsr = fifo_get(s,XMIT_FIFO);
if (!s->xmit_fifo.count)
s->lsr |= UART_LSR_THRE;
} else {
s->tsr = s->thr;
s->lsr |= UART_LSR_THRE;
}
}
if (s->mcr & UART_MCR_LOOP) {
serial_receive1(s, &s->tsr, 1);
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) {
s->tsr_retry++;
qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);
return;
} else if (s->poll_msl < 0) {
s->tsr_retry = -1;
}
}
else {
s->tsr_retry = 0;
}
s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
if (!(s->lsr & UART_LSR_THRE))
qemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);
if (s->lsr & UART_LSR_THRE) {
s->lsr |= UART_LSR_TEMT;
s->thr_ipending = 1;
serial_update_irq(s);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"SerialState *s = VAR_0;",
"uint64_t new_xmit_ts = qemu_get_clock_ns(vm_clock);",
"if (s->tsr_retry <= 0) {",
"if (s->fcr & UART_FCR_FE) {",
"s->tsr = fifo_get(s,XMIT_FIFO);",
"if (!s->xmit_fifo.count)\ns->lsr |= UART_LSR_THRE;",
"} else {",
"s->tsr = s->thr;",
"s->lsr |= UART_LSR_THRE;",
"}",
"}",
"if (s->mcr & UART_MCR_LOOP) {",
"serial_receive1(s, &s->tsr, 1);",
"} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {",
"if ((s->tsr_retry > 0) && (s->tsr_retry <= MAX_XMIT_RETRY)) {",
"s->tsr_retry++;",
"qemu_mod_timer(s->transmit_timer, new_xmit_ts + s->char_transmit_time);",
"return;",
"} else if (s->poll_msl < 0) {",
"s->tsr_retry = -1;",
"}",
"}",
"else {",
"s->tsr_retry = 0;",
"}",
"s->last_xmit_ts = qemu_get_clock_ns(vm_clock);",
"if (!(s->lsr & UART_LSR_THRE))\nqemu_mod_timer(s->transmit_timer, s->last_xmit_ts + s->char_transmit_time);",
"if (s->lsr & UART_LSR_THRE) {",
"s->lsr |= UART_LSR_TEMT;",
"s->thr_ipending = 1;",
"serial_update_irq(s);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
]
] |
19,105 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
bool want_zero,
int64_t sector_num,
int nb_sectors,
int *pnum,
BlockDriverState **file)
{
BlockDriverState *p;
int64_t ret = 0;
bool first = true;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors,
pnum, file);
if (ret < 0) {
break;
}
if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
/*
* Reading beyond the end of the file continues to read
* zeroes, but we can only widen the result to the
* unallocated length we learned from an earlier
* iteration.
*/
*pnum = nb_sectors;
}
if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {
break;
}
/* [sector_num, pnum] unallocated on this layer, which could be only
* the first part of [sector_num, nb_sectors]. */
nb_sectors = MIN(nb_sectors, *pnum);
first = false;
}
return ret;
}
| false | qemu | 2e8bc7874bb674b7d6837706b1249bf871941637 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
bool want_zero,
int64_t sector_num,
int nb_sectors,
int *pnum,
BlockDriverState **file)
{
BlockDriverState *p;
int64_t ret = 0;
bool first = true;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors,
pnum, file);
if (ret < 0) {
break;
}
if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
*pnum = nb_sectors;
}
if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {
break;
}
nb_sectors = MIN(nb_sectors, *pnum);
first = false;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int64_t VAR_0 bdrv_co_get_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
bool want_zero,
int64_t sector_num,
int nb_sectors,
int *pnum,
BlockDriverState **file)
{
BlockDriverState *p;
int64_t ret = 0;
bool first = true;
assert(bs != base);
for (p = bs; p != base; p = backing_bs(p)) {
ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors,
pnum, file);
if (ret < 0) {
break;
}
if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
*pnum = nb_sectors;
}
if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {
break;
}
nb_sectors = MIN(nb_sectors, *pnum);
first = false;
}
return ret;
}
| [
"static int64_t VAR_0 bdrv_co_get_block_status_above(BlockDriverState *bs,\nBlockDriverState *base,\nbool want_zero,\nint64_t sector_num,\nint nb_sectors,\nint *pnum,\nBlockDriverState **file)\n{",
"BlockDriverState *p;",
"int64_t ret = 0;",
"bool first = true;",
"assert(bs != base);",
"for (p = bs; p != base; p = backing_bs(p)) {",
"ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors,\npnum, file);",
"if (ret < 0) {",
"break;",
"}",
"if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {",
"*pnum = nb_sectors;",
"}",
"if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {",
"break;",
"}",
"nb_sectors = MIN(nb_sectors, *pnum);",
"first = false;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
]
] |
19,106 | static void socket_start_incoming_migration(SocketAddressLegacy *saddr,
Error **errp)
{
QIOChannelSocket *listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(listen_ioc),
"migration-socket-listener");
if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
object_unref(OBJECT(listen_ioc));
qapi_free_SocketAddressLegacy(saddr);
return;
}
qio_channel_add_watch(QIO_CHANNEL(listen_ioc),
G_IO_IN,
socket_accept_incoming_migration,
listen_ioc,
(GDestroyNotify)object_unref);
qapi_free_SocketAddressLegacy(saddr);
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static void socket_start_incoming_migration(SocketAddressLegacy *saddr,
Error **errp)
{
QIOChannelSocket *listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(listen_ioc),
"migration-socket-listener");
if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
object_unref(OBJECT(listen_ioc));
qapi_free_SocketAddressLegacy(saddr);
return;
}
qio_channel_add_watch(QIO_CHANNEL(listen_ioc),
G_IO_IN,
socket_accept_incoming_migration,
listen_ioc,
(GDestroyNotify)object_unref);
qapi_free_SocketAddressLegacy(saddr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SocketAddressLegacy *VAR_0,
Error **VAR_1)
{
QIOChannelSocket *listen_ioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(listen_ioc),
"migration-socket-listener");
if (qio_channel_socket_listen_sync(listen_ioc, VAR_0, VAR_1) < 0) {
object_unref(OBJECT(listen_ioc));
qapi_free_SocketAddressLegacy(VAR_0);
return;
}
qio_channel_add_watch(QIO_CHANNEL(listen_ioc),
G_IO_IN,
socket_accept_incoming_migration,
listen_ioc,
(GDestroyNotify)object_unref);
qapi_free_SocketAddressLegacy(VAR_0);
}
| [
"static void FUNC_0(SocketAddressLegacy *VAR_0,\nError **VAR_1)\n{",
"QIOChannelSocket *listen_ioc = qio_channel_socket_new();",
"qio_channel_set_name(QIO_CHANNEL(listen_ioc),\n\"migration-socket-listener\");",
"if (qio_channel_socket_listen_sync(listen_ioc, VAR_0, VAR_1) < 0) {",
"object_unref(OBJECT(listen_ioc));",
"qapi_free_SocketAddressLegacy(VAR_0);",
"return;",
"}",
"qio_channel_add_watch(QIO_CHANNEL(listen_ioc),\nG_IO_IN,\nsocket_accept_incoming_migration,\nlisten_ioc,\n(GDestroyNotify)object_unref);",
"qapi_free_SocketAddressLegacy(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31,
33,
35,
37
],
[
39
],
[
41
]
] |
19,107 | QemuOpts *vnc_parse_func(const char *str)
{
QemuOptsList *olist = qemu_find_opts("vnc");
QemuOpts *opts = qemu_opts_parse(olist, str, 1);
const char *id = qemu_opts_id(opts);
if (!id) {
/* auto-assign id if not present */
vnc_auto_assign_id(olist, opts);
}
return opts;
}
| false | qemu | 81607cbfa433272d1f09bd0f0ae6c3b14f818972 | QemuOpts *vnc_parse_func(const char *str)
{
QemuOptsList *olist = qemu_find_opts("vnc");
QemuOpts *opts = qemu_opts_parse(olist, str, 1);
const char *id = qemu_opts_id(opts);
if (!id) {
vnc_auto_assign_id(olist, opts);
}
return opts;
}
| {
"code": [],
"line_no": []
} | QemuOpts *FUNC_0(const char *str)
{
QemuOptsList *olist = qemu_find_opts("vnc");
QemuOpts *opts = qemu_opts_parse(olist, str, 1);
const char *VAR_0 = qemu_opts_id(opts);
if (!VAR_0) {
vnc_auto_assign_id(olist, opts);
}
return opts;
}
| [
"QemuOpts *FUNC_0(const char *str)\n{",
"QemuOptsList *olist = qemu_find_opts(\"vnc\");",
"QemuOpts *opts = qemu_opts_parse(olist, str, 1);",
"const char *VAR_0 = qemu_opts_id(opts);",
"if (!VAR_0) {",
"vnc_auto_assign_id(olist, opts);",
"}",
"return opts;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
19,109 | static void flush_dpb(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
int i;
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
ff_h264_flush_change(h);
if (h->DPB)
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
ff_h264_unref_picture(h, &h->DPB[i]);
h->cur_pic_ptr = NULL;
ff_h264_unref_picture(h, &h->cur_pic);
h->mb_y = 0;
ff_h264_free_tables(h);
h->context_initialized = 0;
}
| false | FFmpeg | 7a4f74eed51f914e9bbfebaffd4a92ac6791f819 | static void flush_dpb(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
int i;
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
ff_h264_flush_change(h);
if (h->DPB)
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
ff_h264_unref_picture(h, &h->DPB[i]);
h->cur_pic_ptr = NULL;
ff_h264_unref_picture(h, &h->cur_pic);
h->mb_y = 0;
ff_h264_free_tables(h);
h->context_initialized = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0)
{
H264Context *h = VAR_0->priv_data;
int VAR_1;
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
ff_h264_flush_change(h);
if (h->DPB)
for (VAR_1 = 0; VAR_1 < H264_MAX_PICTURE_COUNT; VAR_1++)
ff_h264_unref_picture(h, &h->DPB[VAR_1]);
h->cur_pic_ptr = NULL;
ff_h264_unref_picture(h, &h->cur_pic);
h->mb_y = 0;
ff_h264_free_tables(h);
h->context_initialized = 0;
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"H264Context *h = VAR_0->priv_data;",
"int VAR_1;",
"memset(h->delayed_pic, 0, sizeof(h->delayed_pic));",
"ff_h264_flush_change(h);",
"if (h->DPB)\nfor (VAR_1 = 0; VAR_1 < H264_MAX_PICTURE_COUNT; VAR_1++)",
"ff_h264_unref_picture(h, &h->DPB[VAR_1]);",
"h->cur_pic_ptr = NULL;",
"ff_h264_unref_picture(h, &h->cur_pic);",
"h->mb_y = 0;",
"ff_h264_free_tables(h);",
"h->context_initialized = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
19,110 | static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *pnum)
{
/* TODO: Check for too large sector_num (in bdrv_is_allocated or here). */
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
size_t bmap_index = sector_num / s->block_sectors;
size_t sector_in_block = sector_num % s->block_sectors;
int n_sectors = s->block_sectors - sector_in_block;
uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]);
uint64_t offset;
int result;
logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum);
if (n_sectors > nb_sectors) {
n_sectors = nb_sectors;
}
*pnum = n_sectors;
result = VDI_IS_ALLOCATED(bmap_entry);
if (!result) {
return 0;
}
offset = s->header.offset_data +
(uint64_t)bmap_entry * s->block_size +
sector_in_block * SECTOR_SIZE;
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;
}
| false | qemu | 67a0fd2a9bca204d2b39f910a97c7137636a0715 | static int64_t coroutine_fn vdi_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *pnum)
{
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
size_t bmap_index = sector_num / s->block_sectors;
size_t sector_in_block = sector_num % s->block_sectors;
int n_sectors = s->block_sectors - sector_in_block;
uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]);
uint64_t offset;
int result;
logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum);
if (n_sectors > nb_sectors) {
n_sectors = nb_sectors;
}
*pnum = n_sectors;
result = VDI_IS_ALLOCATED(bmap_entry);
if (!result) {
return 0;
}
offset = s->header.offset_data +
(uint64_t)bmap_entry * s->block_size +
sector_in_block * SECTOR_SIZE;
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;
}
| {
"code": [],
"line_no": []
} | static int64_t VAR_0 vdi_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *pnum)
{
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
size_t bmap_index = sector_num / s->block_sectors;
size_t sector_in_block = sector_num % s->block_sectors;
int n_sectors = s->block_sectors - sector_in_block;
uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]);
uint64_t offset;
int result;
logout("%p, %" PRId64 ", %d, %p\n", bs, sector_num, nb_sectors, pnum);
if (n_sectors > nb_sectors) {
n_sectors = nb_sectors;
}
*pnum = n_sectors;
result = VDI_IS_ALLOCATED(bmap_entry);
if (!result) {
return 0;
}
offset = s->header.offset_data +
(uint64_t)bmap_entry * s->block_size +
sector_in_block * SECTOR_SIZE;
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;
}
| [
"static int64_t VAR_0 vdi_co_get_block_status(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors, int *pnum)\n{",
"BDRVVdiState *s = (BDRVVdiState *)bs->opaque;",
"size_t bmap_index = sector_num / s->block_sectors;",
"size_t sector_in_block = sector_num % s->block_sectors;",
"int n_sectors = s->block_sectors - sector_in_block;",
"uint32_t bmap_entry = le32_to_cpu(s->bmap[bmap_index]);",
"uint64_t offset;",
"int result;",
"logout(\"%p, %\" PRId64 \", %d, %p\\n\", bs, sector_num, nb_sectors, pnum);",
"if (n_sectors > nb_sectors) {",
"n_sectors = nb_sectors;",
"}",
"*pnum = n_sectors;",
"result = VDI_IS_ALLOCATED(bmap_entry);",
"if (!result) {",
"return 0;",
"}",
"offset = s->header.offset_data +\n(uint64_t)bmap_entry * s->block_size +\nsector_in_block * SECTOR_SIZE;",
"return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | offset;",
"}"
] | [
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
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47,
49
],
[
51
],
[
53
]
] |
19,111 | static void coroutine_fn bdrv_aio_flush_co_entry(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_flush(bs);
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| false | qemu | 0b5a24454fc551f0294fe93821e8c643214a55f5 | static void coroutine_fn bdrv_aio_flush_co_entry(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_flush(bs);
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| {
"code": [],
"line_no": []
} | static void VAR_0 bdrv_aio_flush_co_entry(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
BlockDriverState *bs = acb->common.bs;
acb->req.error = bdrv_co_flush(bs);
acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);
qemu_bh_schedule(acb->bh);
}
| [
"static void VAR_0 bdrv_aio_flush_co_entry(void *opaque)\n{",
"BlockAIOCBCoroutine *acb = opaque;",
"BlockDriverState *bs = acb->common.bs;",
"acb->req.error = bdrv_co_flush(bs);",
"acb->bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_em_bh, acb);",
"qemu_bh_schedule(acb->bh);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
19,112 | int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
const char *name, v9fs_synth_read read,
v9fs_synth_write write, void *arg)
{
int ret;
V9fsSynthNode *node, *tmp;
if (!v9fs_synth_fs) {
return EAGAIN;
}
if (!name || (strlen(name) >= NAME_MAX)) {
return EINVAL;
}
if (!parent) {
parent = &v9fs_synth_root;
}
qemu_mutex_lock(&v9fs_synth_mutex);
QLIST_FOREACH(tmp, &parent->child, sibling) {
if (!strcmp(tmp->name, name)) {
ret = EEXIST;
goto err_out;
}
}
/* Add file type and remove write bits */
mode = ((mode & 0777) | S_IFREG);
node = g_malloc0(sizeof(V9fsSynthNode));
node->attr = &node->actual_attr;
node->attr->inode = v9fs_synth_node_count++;
node->attr->nlink = 1;
node->attr->read = read;
node->attr->write = write;
node->attr->mode = mode;
node->private = arg;
pstrcpy(node->name, sizeof(node->name), name);
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
ret = 0;
err_out:
qemu_mutex_unlock(&v9fs_synth_mutex);
return ret;
}
| false | qemu | 364031f17932814484657e5551ba12957d993d7e | int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
const char *name, v9fs_synth_read read,
v9fs_synth_write write, void *arg)
{
int ret;
V9fsSynthNode *node, *tmp;
if (!v9fs_synth_fs) {
return EAGAIN;
}
if (!name || (strlen(name) >= NAME_MAX)) {
return EINVAL;
}
if (!parent) {
parent = &v9fs_synth_root;
}
qemu_mutex_lock(&v9fs_synth_mutex);
QLIST_FOREACH(tmp, &parent->child, sibling) {
if (!strcmp(tmp->name, name)) {
ret = EEXIST;
goto err_out;
}
}
mode = ((mode & 0777) | S_IFREG);
node = g_malloc0(sizeof(V9fsSynthNode));
node->attr = &node->actual_attr;
node->attr->inode = v9fs_synth_node_count++;
node->attr->nlink = 1;
node->attr->read = read;
node->attr->write = write;
node->attr->mode = mode;
node->private = arg;
pstrcpy(node->name, sizeof(node->name), name);
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
ret = 0;
err_out:
qemu_mutex_unlock(&v9fs_synth_mutex);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(V9fsSynthNode *VAR_0, int VAR_1,
const char *VAR_2, v9fs_synth_read VAR_3,
v9fs_synth_write VAR_4, void *VAR_5)
{
int VAR_6;
V9fsSynthNode *node, *tmp;
if (!v9fs_synth_fs) {
return EAGAIN;
}
if (!VAR_2 || (strlen(VAR_2) >= NAME_MAX)) {
return EINVAL;
}
if (!VAR_0) {
VAR_0 = &v9fs_synth_root;
}
qemu_mutex_lock(&v9fs_synth_mutex);
QLIST_FOREACH(tmp, &VAR_0->child, sibling) {
if (!strcmp(tmp->VAR_2, VAR_2)) {
VAR_6 = EEXIST;
goto err_out;
}
}
VAR_1 = ((VAR_1 & 0777) | S_IFREG);
node = g_malloc0(sizeof(V9fsSynthNode));
node->attr = &node->actual_attr;
node->attr->inode = v9fs_synth_node_count++;
node->attr->nlink = 1;
node->attr->VAR_3 = VAR_3;
node->attr->VAR_4 = VAR_4;
node->attr->VAR_1 = VAR_1;
node->private = VAR_5;
pstrcpy(node->VAR_2, sizeof(node->VAR_2), VAR_2);
QLIST_INSERT_HEAD_RCU(&VAR_0->child, node, sibling);
VAR_6 = 0;
err_out:
qemu_mutex_unlock(&v9fs_synth_mutex);
return VAR_6;
}
| [
"int FUNC_0(V9fsSynthNode *VAR_0, int VAR_1,\nconst char *VAR_2, v9fs_synth_read VAR_3,\nv9fs_synth_write VAR_4, void *VAR_5)\n{",
"int VAR_6;",
"V9fsSynthNode *node, *tmp;",
"if (!v9fs_synth_fs) {",
"return EAGAIN;",
"}",
"if (!VAR_2 || (strlen(VAR_2) >= NAME_MAX)) {",
"return EINVAL;",
"}",
"if (!VAR_0) {",
"VAR_0 = &v9fs_synth_root;",
"}",
"qemu_mutex_lock(&v9fs_synth_mutex);",
"QLIST_FOREACH(tmp, &VAR_0->child, sibling) {",
"if (!strcmp(tmp->VAR_2, VAR_2)) {",
"VAR_6 = EEXIST;",
"goto err_out;",
"}",
"}",
"VAR_1 = ((VAR_1 & 0777) | S_IFREG);",
"node = g_malloc0(sizeof(V9fsSynthNode));",
"node->attr = &node->actual_attr;",
"node->attr->inode = v9fs_synth_node_count++;",
"node->attr->nlink = 1;",
"node->attr->VAR_3 = VAR_3;",
"node->attr->VAR_4 = VAR_4;",
"node->attr->VAR_1 = VAR_1;",
"node->private = VAR_5;",
"pstrcpy(node->VAR_2, sizeof(node->VAR_2), VAR_2);",
"QLIST_INSERT_HEAD_RCU(&VAR_0->child, node, sibling);",
"VAR_6 = 0;",
"err_out:\nqemu_mutex_unlock(&v9fs_synth_mutex);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
]
] |
19,113 | static void usage(const char *name)
{
(printf) (
"Usage: %s [OPTIONS] FILE\n"
"QEMU Disk Network Block Device Server\n"
"\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
"\n"
"Connection properties:\n"
" -p, --port=PORT port to listen on (default `%d')\n"
" -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n"
" -k, --socket=PATH path to the unix socket\n"
" (default '"SOCKET_PATH"')\n"
" -e, --shared=NUM device can be shared by NUM clients (default '1')\n"
" -t, --persistent don't exit on the last connection\n"
" -v, --verbose display extra debugging information\n"
"\n"
"Exposing part of the image:\n"
" -o, --offset=OFFSET offset into the image\n"
" -P, --partition=NUM only expose partition NUM\n"
"\n"
#ifdef __linux__
"Kernel NBD client support:\n"
" -c, --connect=DEV connect FILE to the local NBD device DEV\n"
" -d, --disconnect disconnect the specified device\n"
"\n"
#endif
"\n"
"Block device options:\n"
" -f, --format=FORMAT set image format (raw, qcow2, ...)\n"
" -r, --read-only export read-only\n"
" -s, --snapshot use FILE as an external snapshot, create a temporary\n"
" file with backing_file=FILE, redirect the write to\n"
" the temporary one\n"
" -l, --load-snapshot=SNAPSHOT_PARAM\n"
" load an internal snapshot inside FILE and export it\n"
" as an read-only device, SNAPSHOT_PARAM format is\n"
" 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
" '[ID_OR_NAME]'\n"
" -n, --nocache disable host cache\n"
" --cache=MODE set cache mode (none, writeback, ...)\n"
#ifdef CONFIG_LINUX_AIO
" --aio=MODE set AIO mode (native or threads)\n"
#endif
" --discard=MODE set discard mode (ignore, unmap)\n"
" --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n"
"\n"
"Report bugs to <[email protected]>\n"
, name, NBD_DEFAULT_PORT, "DEVICE");
}
| false | qemu | bb628e1af8b8b5ecf6420e50123cb696ee18b09f | static void usage(const char *name)
{
(printf) (
"Usage: %s [OPTIONS] FILE\n"
"QEMU Disk Network Block Device Server\n"
"\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
"\n"
"Connection properties:\n"
" -p, --port=PORT port to listen on (default `%d')\n"
" -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n"
" -k, --socket=PATH path to the unix socket\n"
" (default '"SOCKET_PATH"')\n"
" -e, --shared=NUM device can be shared by NUM clients (default '1')\n"
" -t, --persistent don't exit on the last connection\n"
" -v, --verbose display extra debugging information\n"
"\n"
"Exposing part of the image:\n"
" -o, --offset=OFFSET offset into the image\n"
" -P, --partition=NUM only expose partition NUM\n"
"\n"
#ifdef __linux__
"Kernel NBD client support:\n"
" -c, --connect=DEV connect FILE to the local NBD device DEV\n"
" -d, --disconnect disconnect the specified device\n"
"\n"
#endif
"\n"
"Block device options:\n"
" -f, --format=FORMAT set image format (raw, qcow2, ...)\n"
" -r, --read-only export read-only\n"
" -s, --snapshot use FILE as an external snapshot, create a temporary\n"
" file with backing_file=FILE, redirect the write to\n"
" the temporary one\n"
" -l, --load-snapshot=SNAPSHOT_PARAM\n"
" load an internal snapshot inside FILE and export it\n"
" as an read-only device, SNAPSHOT_PARAM format is\n"
" 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
" '[ID_OR_NAME]'\n"
" -n, --nocache disable host cache\n"
" --cache=MODE set cache mode (none, writeback, ...)\n"
#ifdef CONFIG_LINUX_AIO
" --aio=MODE set AIO mode (native or threads)\n"
#endif
" --discard=MODE set discard mode (ignore, unmap)\n"
" --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n"
"\n"
"Report bugs to <[email protected]>\n"
, name, NBD_DEFAULT_PORT, "DEVICE");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
(printf) (
"Usage: %s [OPTIONS] FILE\n"
"QEMU Disk Network Block Device Server\n"
"\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
"\n"
"Connection properties:\n"
" -p, --port=PORT port to listen on (default `%d')\n"
" -b, --bind=IFACE interface to bind to (default `0.0.0.0')\n"
" -k, --socket=PATH path to the unix socket\n"
" (default '"SOCKET_PATH"')\n"
" -e, --shared=NUM device can be shared by NUM clients (default '1')\n"
" -t, --persistent don't exit on the last connection\n"
" -v, --verbose display extra debugging information\n"
"\n"
"Exposing part of the image:\n"
" -o, --offset=OFFSET offset into the image\n"
" -P, --partition=NUM only expose partition NUM\n"
"\n"
#ifdef __linux__
"Kernel NBD client support:\n"
" -c, --connect=DEV connect FILE to the local NBD device DEV\n"
" -d, --disconnect disconnect the specified device\n"
"\n"
#endif
"\n"
"Block device options:\n"
" -f, --format=FORMAT set image format (raw, qcow2, ...)\n"
" -r, --read-only export read-only\n"
" -s, --snapshot use FILE as an external snapshot, create a temporary\n"
" file with backing_file=FILE, redirect the write to\n"
" the temporary one\n"
" -l, --load-snapshot=SNAPSHOT_PARAM\n"
" load an internal snapshot inside FILE and export it\n"
" as an read-only device, SNAPSHOT_PARAM format is\n"
" 'snapshot.id=[ID],snapshot.VAR_0=[NAME]', or\n"
" '[ID_OR_NAME]'\n"
" -n, --nocache disable host cache\n"
" --cache=MODE set cache mode (none, writeback, ...)\n"
#ifdef CONFIG_LINUX_AIO
" --aio=MODE set AIO mode (native or threads)\n"
#endif
" --discard=MODE set discard mode (ignore, unmap)\n"
" --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\n"
"\n"
"Report bugs to <[email protected]>\n"
, VAR_0, NBD_DEFAULT_PORT, "DEVICE");
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"(printf) (\n\"Usage: %s [OPTIONS] FILE\\n\"\n\"QEMU Disk Network Block Device Server\\n\"\n\"\\n\"\n\" -h, --help display this help and exit\\n\"\n\" -V, --version output version information and exit\\n\"\n\"\\n\"\n\"Connection properties:\\n\"\n\" -p, --port=PORT port to listen on (default `%d')\\n\"\n\" -b, --bind=IFACE interface to bind to (default `0.0.0.0')\\n\"\n\" -k, --socket=PATH path to the unix socket\\n\"\n\" (default '\"SOCKET_PATH\"')\\n\"\n\" -e, --shared=NUM device can be shared by NUM clients (default '1')\\n\"\n\" -t, --persistent don't exit on the last connection\\n\"\n\" -v, --verbose display extra debugging information\\n\"\n\"\\n\"\n\"Exposing part of the image:\\n\"\n\" -o, --offset=OFFSET offset into the image\\n\"\n\" -P, --partition=NUM only expose partition NUM\\n\"\n\"\\n\"\n#ifdef __linux__\n\"Kernel NBD client support:\\n\"\n\" -c, --connect=DEV connect FILE to the local NBD device DEV\\n\"\n\" -d, --disconnect disconnect the specified device\\n\"\n\"\\n\"\n#endif\n\"\\n\"\n\"Block device options:\\n\"\n\" -f, --format=FORMAT set image format (raw, qcow2, ...)\\n\"\n\" -r, --read-only export read-only\\n\"\n\" -s, --snapshot use FILE as an external snapshot, create a temporary\\n\"\n\" file with backing_file=FILE, redirect the write to\\n\"\n\" the temporary one\\n\"\n\" -l, --load-snapshot=SNAPSHOT_PARAM\\n\"\n\" load an internal snapshot inside FILE and export it\\n\"\n\" as an read-only device, SNAPSHOT_PARAM format is\\n\"\n\" 'snapshot.id=[ID],snapshot.VAR_0=[NAME]', or\\n\"\n\" '[ID_OR_NAME]'\\n\"\n\" -n, --nocache disable host cache\\n\"\n\" --cache=MODE set cache mode (none, writeback, ...)\\n\"\n#ifdef CONFIG_LINUX_AIO\n\" --aio=MODE set AIO mode (native or threads)\\n\"\n#endif\n\" --discard=MODE set discard mode (ignore, unmap)\\n\"\n\" --detect-zeroes=MODE set detect-zeroes mode (off, on, unmap)\\n\"\n\"\\n\"\n\"Report bugs to <[email protected]>\\n\"\n, VAR_0, NBD_DEFAULT_PORT, \"DEVICE\");",
"}"
] | [
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
]
] |
19,114 | static void run_dependent_requests(QCowL2Meta *m)
{
QCowAIOCB *req;
QCowAIOCB *next;
/* Take the request off the list of running requests */
if (m->nb_clusters != 0) {
LIST_REMOVE(m, next_in_flight);
}
/*
* Restart all dependent requests.
* Can't use LIST_FOREACH here - the next link might not be the same
* any more after the callback (request could depend on a different
* request now)
*/
for (req = m->dependent_requests.lh_first; req != NULL; req = next) {
next = req->next_depend.le_next;
qcow_aio_write_cb(req, 0);
}
/* Empty the list for the next part of the request */
LIST_INIT(&m->dependent_requests);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void run_dependent_requests(QCowL2Meta *m)
{
QCowAIOCB *req;
QCowAIOCB *next;
if (m->nb_clusters != 0) {
LIST_REMOVE(m, next_in_flight);
}
for (req = m->dependent_requests.lh_first; req != NULL; req = next) {
next = req->next_depend.le_next;
qcow_aio_write_cb(req, 0);
}
LIST_INIT(&m->dependent_requests);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QCowL2Meta *VAR_0)
{
QCowAIOCB *req;
QCowAIOCB *next;
if (VAR_0->nb_clusters != 0) {
LIST_REMOVE(VAR_0, next_in_flight);
}
for (req = VAR_0->dependent_requests.lh_first; req != NULL; req = next) {
next = req->next_depend.le_next;
qcow_aio_write_cb(req, 0);
}
LIST_INIT(&VAR_0->dependent_requests);
}
| [
"static void FUNC_0(QCowL2Meta *VAR_0)\n{",
"QCowAIOCB *req;",
"QCowAIOCB *next;",
"if (VAR_0->nb_clusters != 0) {",
"LIST_REMOVE(VAR_0, next_in_flight);",
"}",
"for (req = VAR_0->dependent_requests.lh_first; req != NULL; req = next) {",
"next = req->next_depend.le_next;",
"qcow_aio_write_cb(req, 0);",
"}",
"LIST_INIT(&VAR_0->dependent_requests);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
]
] |
19,117 | static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{
VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, 0);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |
PCI_STATUS_DEVSEL_MEDIUM);
/* 0x48-0x4B is Power Management I/O Base */
pci_set_long(pci_conf + 0x48, 0x00000001);
/* SMB ports:0xeee0~0xeeef */
s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x90;
pm_smbus_init(&s->dev.qdev, &s->smb);
memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
apm_init(dev, &s->apm, NULL, s);
memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, 2);
}
| false | qemu | 9a10bbb4e83b184faef6fa744396a6775283c0aa | static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{
VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, 0);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + 0x48, 0x00000001);
s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x90;
pm_smbus_init(&s->dev.qdev, &s->smb);
memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
apm_init(dev, &s->apm, NULL, s);
memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, 2);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)
{
VT686PMState *s = DO_UPCAST(VT686PMState, VAR_0, VAR_0);
uint8_t *pci_conf;
pci_conf = s->VAR_0.config;
pci_set_word(pci_conf + PCI_COMMAND, 0);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |
PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + 0x48, 0x00000001);
s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);
pci_conf[0x90] = s->smb_io_base | 1;
pci_conf[0x91] = s->smb_io_base >> 8;
pci_conf[0xd2] = 0x90;
pm_smbus_init(&s->VAR_0.qdev, &s->smb);
memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
apm_init(VAR_0, &s->apm, NULL, s);
memory_region_init(&s->io, OBJECT(VAR_0), "vt82c686-pm", 64);
memory_region_set_enabled(&s->io, false);
memory_region_add_subregion(get_system_io(), 0, &s->io);
acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
acpi_pm1_cnt_init(&s->ar, &s->io, 2);
}
| [
"static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{",
"VT686PMState *s = DO_UPCAST(VT686PMState, VAR_0, VAR_0);",
"uint8_t *pci_conf;",
"pci_conf = s->VAR_0.config;",
"pci_set_word(pci_conf + PCI_COMMAND, 0);",
"pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK |\nPCI_STATUS_DEVSEL_MEDIUM);",
"pci_set_long(pci_conf + 0x48, 0x00000001);",
"s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0);",
"pci_conf[0x90] = s->smb_io_base | 1;",
"pci_conf[0x91] = s->smb_io_base >> 8;",
"pci_conf[0xd2] = 0x90;",
"pm_smbus_init(&s->VAR_0.qdev, &s->smb);",
"memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);",
"apm_init(VAR_0, &s->apm, NULL, s);",
"memory_region_init(&s->io, OBJECT(VAR_0), \"vt82c686-pm\", 64);",
"memory_region_set_enabled(&s->io, false);",
"memory_region_add_subregion(get_system_io(), 0, &s->io);",
"acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);",
"acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);",
"acpi_pm1_cnt_init(&s->ar, &s->io, 2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
19,118 | static int load_refcount_block(BlockDriverState *bs,
int64_t refcount_block_offset,
void **refcount_block)
{
BDRVQcow2State *s = bs->opaque;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD);
ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
refcount_block);
return ret;
}
| false | qemu | 9be385980d37e8f4fd33f605f5fb1c3d144170a8 | static int load_refcount_block(BlockDriverState *bs,
int64_t refcount_block_offset,
void **refcount_block)
{
BDRVQcow2State *s = bs->opaque;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD);
ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
refcount_block);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0,
int64_t VAR_1,
void **VAR_2)
{
BDRVQcow2State *s = VAR_0->opaque;
int VAR_3;
BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_LOAD);
VAR_3 = qcow2_cache_get(VAR_0, s->refcount_block_cache, VAR_1,
VAR_2);
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nint64_t VAR_1,\nvoid **VAR_2)\n{",
"BDRVQcow2State *s = VAR_0->opaque;",
"int VAR_3;",
"BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_LOAD);",
"VAR_3 = qcow2_cache_get(VAR_0, s->refcount_block_cache, VAR_1,\nVAR_2);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
]
] |
19,121 | static inline void gen_branch_cond(DisasContext *ctx, TCGCond cond, TCGv r1,
TCGv r2, int16_t address)
{
int jumpLabel;
jumpLabel = gen_new_label();
tcg_gen_brcond_tl(cond, r1, r2, jumpLabel);
gen_goto_tb(ctx, 1, ctx->next_pc);
gen_set_label(jumpLabel);
gen_goto_tb(ctx, 0, ctx->pc + address * 2);
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static inline void gen_branch_cond(DisasContext *ctx, TCGCond cond, TCGv r1,
TCGv r2, int16_t address)
{
int jumpLabel;
jumpLabel = gen_new_label();
tcg_gen_brcond_tl(cond, r1, r2, jumpLabel);
gen_goto_tb(ctx, 1, ctx->next_pc);
gen_set_label(jumpLabel);
gen_goto_tb(ctx, 0, ctx->pc + address * 2);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(DisasContext *VAR_0, TCGCond VAR_1, TCGv VAR_2,
TCGv VAR_3, int16_t VAR_4)
{
int VAR_5;
VAR_5 = gen_new_label();
tcg_gen_brcond_tl(VAR_1, VAR_2, VAR_3, VAR_5);
gen_goto_tb(VAR_0, 1, VAR_0->next_pc);
gen_set_label(VAR_5);
gen_goto_tb(VAR_0, 0, VAR_0->pc + VAR_4 * 2);
}
| [
"static inline void FUNC_0(DisasContext *VAR_0, TCGCond VAR_1, TCGv VAR_2,\nTCGv VAR_3, int16_t VAR_4)\n{",
"int VAR_5;",
"VAR_5 = gen_new_label();",
"tcg_gen_brcond_tl(VAR_1, VAR_2, VAR_3, VAR_5);",
"gen_goto_tb(VAR_0, 1, VAR_0->next_pc);",
"gen_set_label(VAR_5);",
"gen_goto_tb(VAR_0, 0, VAR_0->pc + VAR_4 * 2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
19,123 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
bool has_node_name, const char *node_name,
bool has_replaces, const char *replaces,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
QDict *options = NULL;
int flags;
int64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
"a value in range [512B, 64MB]");
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) {
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
if (sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
if (has_replaces) {
BlockDriverState *to_replace_bs;
if (!has_node_name) {
error_setg(errp, "a node-name must be provided when replacing a"
" named node of the graph");
return;
}
to_replace_bs = check_to_replace_node(replaces, &local_err);
if (!to_replace_bs) {
error_propagate(errp, local_err);
return;
}
if (size != bdrv_getlength(to_replace_bs)) {
error_setg(errp, "cannot replace image with a mirror image of "
"different size");
return;
}
}
if ((sync == MIRROR_SYNC_MODE_FULL || !source)
&& mode != NEW_IMAGE_MODE_EXISTING)
{
/* create new image w/o backing file */
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
/* create new image with backing file */
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (has_node_name) {
options = qdict_new();
qdict_put(options, "node-name", qstring_from_str(node_name));
}
/* Mirroring takes care of copy-on-write using the source's backing
* file.
*/
target_bs = NULL;
ret = bdrv_open(&target_bs, target, NULL, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return;
}
/* pass the node name to replace to mirror start since it's loose coupling
* and will allow to check whether the node still exist at mirror completion
*/
mirror_start(bs, target_bs,
has_replaces ? replaces : NULL,
speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
}
| false | qemu | 5a7e7a0bad17c96e03f55ed7019e2d7545e21a96 | void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
bool has_node_name, const char *node_name,
bool has_replaces, const char *replaces,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
bool has_granularity, uint32_t granularity,
bool has_buf_size, int64_t buf_size,
bool has_on_source_error, BlockdevOnError on_source_error,
bool has_on_target_error, BlockdevOnError on_target_error,
Error **errp)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
QDict *options = NULL;
int flags;
int64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_on_source_error) {
on_source_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_on_target_error) {
on_target_error = BLOCKDEV_ON_ERROR_REPORT;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!has_granularity) {
granularity = 0;
}
if (!has_buf_size) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
"a value in range [512B, 64MB]");
return;
}
if (granularity & (granularity - 1)) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) {
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
if (sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(errp, -size, "bdrv_getlength failed");
return;
}
if (has_replaces) {
BlockDriverState *to_replace_bs;
if (!has_node_name) {
error_setg(errp, "a node-name must be provided when replacing a"
" named node of the graph");
return;
}
to_replace_bs = check_to_replace_node(replaces, &local_err);
if (!to_replace_bs) {
error_propagate(errp, local_err);
return;
}
if (size != bdrv_getlength(to_replace_bs)) {
error_setg(errp, "cannot replace image with a mirror image of "
"different size");
return;
}
}
if ((sync == MIRROR_SYNC_MODE_FULL || !source)
&& mode != NEW_IMAGE_MODE_EXISTING)
{
assert(format && drv);
bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags, &local_err, false);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, size, flags, &local_err, false);
break;
default:
abort();
}
}
if (local_err) {
error_propagate(errp, local_err);
return;
}
if (has_node_name) {
options = qdict_new();
qdict_put(options, "node-name", qstring_from_str(node_name));
}
target_bs = NULL;
ret = bdrv_open(&target_bs, target, NULL, options,
flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return;
}
mirror_start(bs, target_bs,
has_replaces ? replaces : NULL,
speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(errp, local_err);
return;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, const char *VAR_3,
bool VAR_4, const char *VAR_5,
bool VAR_6, const char *VAR_7,
enum MirrorSyncMode VAR_8,
bool VAR_9, enum NewImageMode VAR_10,
bool VAR_11, int64_t VAR_12,
bool VAR_13, uint32_t VAR_14,
bool VAR_15, int64_t VAR_16,
bool VAR_17, BlockdevOnError VAR_18,
bool VAR_19, BlockdevOnError VAR_20,
Error **VAR_21)
{
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL;
Error *local_err = NULL;
QDict *options = NULL;
int VAR_22;
int64_t size;
int VAR_23;
if (!VAR_11) {
VAR_12 = 0;
}
if (!VAR_17) {
VAR_18 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_19) {
VAR_20 = BLOCKDEV_ON_ERROR_REPORT;
}
if (!VAR_9) {
VAR_10 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
if (!VAR_13) {
VAR_14 = 0;
}
if (!VAR_15) {
VAR_16 = DEFAULT_MIRROR_BUF_SIZE;
}
if (VAR_14 != 0 && (VAR_14 < 512 || VAR_14 > 1048576 * 64)) {
error_set(VAR_21, QERR_INVALID_PARAMETER_VALUE, "VAR_14",
"a value in range [512B, 64MB]");
return;
}
if (VAR_14 & (VAR_14 - 1)) {
error_set(VAR_21, QERR_INVALID_PARAMETER_VALUE, "VAR_14", "power of 2");
return;
}
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_21, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(VAR_21, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);
return;
}
if (!VAR_2) {
VAR_3 = VAR_10 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (VAR_3) {
drv = bdrv_find_format(VAR_3);
if (!drv) {
error_set(VAR_21, QERR_INVALID_BLOCK_FORMAT, VAR_3);
return;
}
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, VAR_21)) {
return;
}
VAR_22 = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && VAR_8 == MIRROR_SYNC_MODE_TOP) {
VAR_8 = MIRROR_SYNC_MODE_FULL;
}
if (VAR_8 == MIRROR_SYNC_MODE_NONE) {
source = bs;
}
size = bdrv_getlength(bs);
if (size < 0) {
error_setg_errno(VAR_21, -size, "bdrv_getlength failed");
return;
}
if (VAR_6) {
BlockDriverState *to_replace_bs;
if (!VAR_4) {
error_setg(VAR_21, "a node-name must be provided when replacing a"
" named node of the graph");
return;
}
to_replace_bs = check_to_replace_node(VAR_7, &local_err);
if (!to_replace_bs) {
error_propagate(VAR_21, local_err);
return;
}
if (size != bdrv_getlength(to_replace_bs)) {
error_setg(VAR_21, "cannot replace image with a mirror image of "
"different size");
return;
}
}
if ((VAR_8 == MIRROR_SYNC_MODE_FULL || !source)
&& VAR_10 != NEW_IMAGE_MODE_EXISTING)
{
assert(VAR_3 && drv);
bdrv_img_create(VAR_1, VAR_3,
NULL, NULL, NULL, size, VAR_22, &local_err, false);
} else {
switch (VAR_10) {
case NEW_IMAGE_MODE_EXISTING:
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
bdrv_img_create(VAR_1, VAR_3,
source->filename,
source->drv->format_name,
NULL, size, VAR_22, &local_err, false);
break;
default:
abort();
}
}
if (local_err) {
error_propagate(VAR_21, local_err);
return;
}
if (VAR_4) {
options = qdict_new();
qdict_put(options, "node-name", qstring_from_str(VAR_5));
}
target_bs = NULL;
VAR_23 = bdrv_open(&target_bs, VAR_1, NULL, options,
VAR_22 | BDRV_O_NO_BACKING, drv, &local_err);
if (VAR_23 < 0) {
error_propagate(VAR_21, local_err);
return;
}
mirror_start(bs, target_bs,
VAR_6 ? VAR_7 : NULL,
VAR_12, VAR_14, VAR_16, VAR_8,
VAR_18, VAR_20,
block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_unref(target_bs);
error_propagate(VAR_21, local_err);
return;
}
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nbool VAR_4, const char *VAR_5,\nbool VAR_6, const char *VAR_7,\nenum MirrorSyncMode VAR_8,\nbool VAR_9, enum NewImageMode VAR_10,\nbool VAR_11, int64_t VAR_12,\nbool VAR_13, uint32_t VAR_14,\nbool VAR_15, int64_t VAR_16,\nbool VAR_17, BlockdevOnError VAR_18,\nbool VAR_19, BlockdevOnError VAR_20,\nError **VAR_21)\n{",
"BlockDriverState *bs;",
"BlockDriverState *source, *target_bs;",
"BlockDriver *drv = NULL;",
"Error *local_err = NULL;",
"QDict *options = NULL;",
"int VAR_22;",
"int64_t size;",
"int VAR_23;",
"if (!VAR_11) {",
"VAR_12 = 0;",
"}",
"if (!VAR_17) {",
"VAR_18 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_19) {",
"VAR_20 = BLOCKDEV_ON_ERROR_REPORT;",
"}",
"if (!VAR_9) {",
"VAR_10 = NEW_IMAGE_MODE_ABSOLUTE_PATHS;",
"}",
"if (!VAR_13) {",
"VAR_14 = 0;",
"}",
"if (!VAR_15) {",
"VAR_16 = DEFAULT_MIRROR_BUF_SIZE;",
"}",
"if (VAR_14 != 0 && (VAR_14 < 512 || VAR_14 > 1048576 * 64)) {",
"error_set(VAR_21, QERR_INVALID_PARAMETER_VALUE, \"VAR_14\",\n\"a value in range [512B, 64MB]\");",
"return;",
"}",
"if (VAR_14 & (VAR_14 - 1)) {",
"error_set(VAR_21, QERR_INVALID_PARAMETER_VALUE, \"VAR_14\", \"power of 2\");",
"return;",
"}",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_21, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"if (!bdrv_is_inserted(bs)) {",
"error_set(VAR_21, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);",
"return;",
"}",
"if (!VAR_2) {",
"VAR_3 = VAR_10 == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;",
"}",
"if (VAR_3) {",
"drv = bdrv_find_format(VAR_3);",
"if (!drv) {",
"error_set(VAR_21, QERR_INVALID_BLOCK_FORMAT, VAR_3);",
"return;",
"}",
"}",
"if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, VAR_21)) {",
"return;",
"}",
"VAR_22 = bs->open_flags | BDRV_O_RDWR;",
"source = bs->backing_hd;",
"if (!source && VAR_8 == MIRROR_SYNC_MODE_TOP) {",
"VAR_8 = MIRROR_SYNC_MODE_FULL;",
"}",
"if (VAR_8 == MIRROR_SYNC_MODE_NONE) {",
"source = bs;",
"}",
"size = bdrv_getlength(bs);",
"if (size < 0) {",
"error_setg_errno(VAR_21, -size, \"bdrv_getlength failed\");",
"return;",
"}",
"if (VAR_6) {",
"BlockDriverState *to_replace_bs;",
"if (!VAR_4) {",
"error_setg(VAR_21, \"a node-name must be provided when replacing a\"\n\" named node of the graph\");",
"return;",
"}",
"to_replace_bs = check_to_replace_node(VAR_7, &local_err);",
"if (!to_replace_bs) {",
"error_propagate(VAR_21, local_err);",
"return;",
"}",
"if (size != bdrv_getlength(to_replace_bs)) {",
"error_setg(VAR_21, \"cannot replace image with a mirror image of \"\n\"different size\");",
"return;",
"}",
"}",
"if ((VAR_8 == MIRROR_SYNC_MODE_FULL || !source)\n&& VAR_10 != NEW_IMAGE_MODE_EXISTING)\n{",
"assert(VAR_3 && drv);",
"bdrv_img_create(VAR_1, VAR_3,\nNULL, NULL, NULL, size, VAR_22, &local_err, false);",
"} else {",
"switch (VAR_10) {",
"case NEW_IMAGE_MODE_EXISTING:\nbreak;",
"case NEW_IMAGE_MODE_ABSOLUTE_PATHS:\nbdrv_img_create(VAR_1, VAR_3,\nsource->filename,\nsource->drv->format_name,\nNULL, size, VAR_22, &local_err, false);",
"break;",
"default:\nabort();",
"}",
"}",
"if (local_err) {",
"error_propagate(VAR_21, local_err);",
"return;",
"}",
"if (VAR_4) {",
"options = qdict_new();",
"qdict_put(options, \"node-name\", qstring_from_str(VAR_5));",
"}",
"target_bs = NULL;",
"VAR_23 = bdrv_open(&target_bs, VAR_1, NULL, options,\nVAR_22 | BDRV_O_NO_BACKING, drv, &local_err);",
"if (VAR_23 < 0) {",
"error_propagate(VAR_21, local_err);",
"return;",
"}",
"mirror_start(bs, target_bs,\nVAR_6 ? VAR_7 : NULL,\nVAR_12, VAR_14, VAR_16, VAR_8,\nVAR_18, VAR_20,\nblock_job_cb, bs, &local_err);",
"if (local_err != NULL) {",
"bdrv_unref(target_bs);",
"error_propagate(VAR_21, local_err);",
"return;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227
],
[
231,
233,
235
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
249,
251
],
[
253,
257,
259,
261,
263
],
[
265
],
[
267,
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
293
],
[
303
],
[
305,
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
325,
327,
329,
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.