id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
23,231 | static void test_visitor_in_wrong_type(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
strList *q = NULL;
int64_t i;
Error *err = NULL;
/* Make sure arrays and structs cannot be confused */
v = visitor_input_test_init(data, "[]");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
/* Make sure primitives and struct cannot be confused */
v = visitor_input_test_init(data, "1");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
/* Make sure primitives and arrays cannot be confused */
v = visitor_input_test_init(data, "1");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(data, "[]");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_in_wrong_type(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
strList *q = NULL;
int64_t i;
Error *err = NULL;
v = visitor_input_test_init(data, "[]");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(data, "1");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
v = visitor_input_test_init(data, "1");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(data, "[]");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
TestStruct *p = NULL;
Visitor *v;
strList *q = NULL;
int64_t i;
Error *err = NULL;
v = visitor_input_test_init(VAR_0, "[]");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(VAR_0, "{}");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(VAR_0, "1");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(VAR_0, "{}");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
v = visitor_input_test_init(VAR_0, "1");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(VAR_0, "[]");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"TestStruct *p = NULL;",
"Visitor *v;",
"strList *q = NULL;",
"int64_t i;",
"Error *err = NULL;",
"v = visitor_input_test_init(VAR_0, \"[]\");",
"visit_type_TestStruct(v, NULL, &p, &err);",
"error_free_or_abort(&err);",
"g_assert(!p);",
"v = visitor_input_test_init(VAR_0, \"{}\");",
"visit_type_strList(v, NULL, &q, &err);",
"error_free_or_abort(&err);",
"assert(!q);",
"v = visitor_input_test_init(VAR_0, \"1\");",
"visit_type_TestStruct(v, NULL, &p, &err);",
"error_free_or_abort(&err);",
"g_assert(!p);",
"v = visitor_input_test_init(VAR_0, \"{}\");",
"visit_type_int(v, NULL, &i, &err);",
"error_free_or_abort(&err);",
"v = visitor_input_test_init(VAR_0, \"1\");",
"visit_type_strList(v, NULL, &q, &err);",
"error_free_or_abort(&err);",
"assert(!q);",
"v = visitor_input_test_init(VAR_0, \"[]\");",
"visit_type_int(v, NULL, &i, &err);",
"error_free_or_abort(&err);",
"}"
] | [
0,
0,
0,
0,
0,
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
23,232 | static int buffered_close(void *opaque)
{
MigrationState *s = opaque;
DPRINTF("closing\n");
s->xfer_limit = INT_MAX;
while (!qemu_file_get_error(s->file) && s->buffer_size) {
buffered_flush(s);
}
return migrate_fd_close(s);
}
| false | qemu | a3fa1d78cbae2259491b17689812edcb643a3b30 | static int buffered_close(void *opaque)
{
MigrationState *s = opaque;
DPRINTF("closing\n");
s->xfer_limit = INT_MAX;
while (!qemu_file_get_error(s->file) && s->buffer_size) {
buffered_flush(s);
}
return migrate_fd_close(s);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0)
{
MigrationState *s = VAR_0;
DPRINTF("closing\n");
s->xfer_limit = INT_MAX;
while (!qemu_file_get_error(s->file) && s->buffer_size) {
buffered_flush(s);
}
return migrate_fd_close(s);
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"MigrationState *s = VAR_0;",
"DPRINTF(\"closing\\n\");",
"s->xfer_limit = INT_MAX;",
"while (!qemu_file_get_error(s->file) && s->buffer_size) {",
"buffered_flush(s);",
"}",
"return migrate_fd_close(s);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
23,233 | static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f)
{
int64_t completed_sector_sum = 0;
BlkMigDevState *bmds;
int progress;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->bulk_completed == 0) {
if (mig_save_device_bulk(mon, f, bmds) == 1) {
/* completed bulk section for this device */
bmds->bulk_completed = 1;
}
completed_sector_sum += bmds->completed_sectors;
ret = 1;
break;
} else {
completed_sector_sum += bmds->completed_sectors;
}
}
if (block_mig_state.total_sector_sum != 0) {
progress = completed_sector_sum * 100 /
block_mig_state.total_sector_sum;
} else {
progress = 100;
}
if (progress != block_mig_state.prev_progress) {
block_mig_state.prev_progress = progress;
qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS);
monitor_printf(mon, "Completed %d %%\r", progress);
monitor_flush(mon);
}
return ret;
}
| false | qemu | 539de1246d355d3b8aa33fb7cde732352d8827c7 | static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f)
{
int64_t completed_sector_sum = 0;
BlkMigDevState *bmds;
int progress;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->bulk_completed == 0) {
if (mig_save_device_bulk(mon, f, bmds) == 1) {
bmds->bulk_completed = 1;
}
completed_sector_sum += bmds->completed_sectors;
ret = 1;
break;
} else {
completed_sector_sum += bmds->completed_sectors;
}
}
if (block_mig_state.total_sector_sum != 0) {
progress = completed_sector_sum * 100 /
block_mig_state.total_sector_sum;
} else {
progress = 100;
}
if (progress != block_mig_state.prev_progress) {
block_mig_state.prev_progress = progress;
qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS);
monitor_printf(mon, "Completed %d %%\r", progress);
monitor_flush(mon);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1)
{
int64_t completed_sector_sum = 0;
BlkMigDevState *bmds;
int VAR_2;
int VAR_3 = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->bulk_completed == 0) {
if (mig_save_device_bulk(VAR_0, VAR_1, bmds) == 1) {
bmds->bulk_completed = 1;
}
completed_sector_sum += bmds->completed_sectors;
VAR_3 = 1;
break;
} else {
completed_sector_sum += bmds->completed_sectors;
}
}
if (block_mig_state.total_sector_sum != 0) {
VAR_2 = completed_sector_sum * 100 /
block_mig_state.total_sector_sum;
} else {
VAR_2 = 100;
}
if (VAR_2 != block_mig_state.prev_progress) {
block_mig_state.prev_progress = VAR_2;
qemu_put_be64(VAR_1, (VAR_2 << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS);
monitor_printf(VAR_0, "Completed %d %%\r", VAR_2);
monitor_flush(VAR_0);
}
return VAR_3;
}
| [
"static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1)\n{",
"int64_t completed_sector_sum = 0;",
"BlkMigDevState *bmds;",
"int VAR_2;",
"int VAR_3 = 0;",
"QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {",
"if (bmds->bulk_completed == 0) {",
"if (mig_save_device_bulk(VAR_0, VAR_1, bmds) == 1) {",
"bmds->bulk_completed = 1;",
"}",
"completed_sector_sum += bmds->completed_sectors;",
"VAR_3 = 1;",
"break;",
"} else {",
"completed_sector_sum += bmds->completed_sectors;",
"}",
"}",
"if (block_mig_state.total_sector_sum != 0) {",
"VAR_2 = completed_sector_sum * 100 /\nblock_mig_state.total_sector_sum;",
"} else {",
"VAR_2 = 100;",
"}",
"if (VAR_2 != block_mig_state.prev_progress) {",
"block_mig_state.prev_progress = VAR_2;",
"qemu_put_be64(VAR_1, (VAR_2 << BDRV_SECTOR_BITS)\n| BLK_MIG_FLAG_PROGRESS);",
"monitor_printf(VAR_0, \"Completed %d %%\\r\", VAR_2);",
"monitor_flush(VAR_0);",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
]
] |
23,234 | static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
/*
* Attempt to enable route through KVM irqchip,
* default to userspace handling if unavailable.
*/
vfio_add_kvm_msi_virq(vector, &msg, false);
}
/* Set interrupt type prior to possible interrupts */
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
/*
* Failing to setup MSI doesn't really fall within any specification.
* Let's try leaving interrupts disabled and hope the guest figures
* out to fall back to INTx for this device.
*/
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| false | qemu | 46746dbaa8c2c421b9bda78193caad57d7fb1136 | static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
vfio_add_kvm_msi_virq(vector, &msg, false);
}
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VFIOPCIDevice *VAR_0)
{
int VAR_1, VAR_2;
vfio_disable_interrupts(VAR_0);
VAR_0->nr_vectors = msi_nr_vectors_allocated(&VAR_0->pdev);
retry:
VAR_0->msi_vectors = g_malloc0(VAR_0->nr_vectors * sizeof(VFIOMSIVector));
for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {
VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];
MSIMessage msg = msi_get_message(&VAR_0->pdev, VAR_2);
vector->VAR_0 = VAR_0;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
vfio_add_kvm_msi_virq(vector, &msg, false);
}
VAR_0->interrupt = VFIO_INT_MSI;
VAR_1 = vfio_enable_vectors(VAR_0, false);
if (VAR_1) {
if (VAR_1 < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (VAR_1 != VAR_0->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", VAR_0->nr_vectors, VAR_1);
}
for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {
VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(VAR_0->msi_vectors);
if (VAR_1 > 0 && VAR_1 != VAR_0->nr_vectors) {
VAR_0->nr_vectors = VAR_1;
goto retry;
}
VAR_0->nr_vectors = 0;
error_report("vfio: Error: Failed to enable MSI");
VAR_0->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(VAR_0->vbasedev.name, VAR_0->nr_vectors);
}
| [
"static void FUNC_0(VFIOPCIDevice *VAR_0)\n{",
"int VAR_1, VAR_2;",
"vfio_disable_interrupts(VAR_0);",
"VAR_0->nr_vectors = msi_nr_vectors_allocated(&VAR_0->pdev);",
"retry:\nVAR_0->msi_vectors = g_malloc0(VAR_0->nr_vectors * sizeof(VFIOMSIVector));",
"for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {",
"VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];",
"MSIMessage msg = msi_get_message(&VAR_0->pdev, VAR_2);",
"vector->VAR_0 = VAR_0;",
"vector->virq = -1;",
"vector->use = true;",
"if (event_notifier_init(&vector->interrupt, 0)) {",
"error_report(\"vfio: Error: event_notifier_init failed\");",
"}",
"qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),\nvfio_msi_interrupt, NULL, vector);",
"vfio_add_kvm_msi_virq(vector, &msg, false);",
"}",
"VAR_0->interrupt = VFIO_INT_MSI;",
"VAR_1 = vfio_enable_vectors(VAR_0, false);",
"if (VAR_1) {",
"if (VAR_1 < 0) {",
"error_report(\"vfio: Error: Failed to setup MSI fds: %m\");",
"} else if (VAR_1 != VAR_0->nr_vectors) {",
"error_report(\"vfio: Error: Failed to enable %d \"\n\"MSI vectors, retry with %d\", VAR_0->nr_vectors, VAR_1);",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->nr_vectors; VAR_2++) {",
"VFIOMSIVector *vector = &VAR_0->msi_vectors[VAR_2];",
"if (vector->virq >= 0) {",
"vfio_remove_kvm_msi_virq(vector);",
"}",
"qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),\nNULL, NULL, NULL);",
"event_notifier_cleanup(&vector->interrupt);",
"}",
"g_free(VAR_0->msi_vectors);",
"if (VAR_1 > 0 && VAR_1 != VAR_0->nr_vectors) {",
"VAR_0->nr_vectors = VAR_1;",
"goto retry;",
"}",
"VAR_0->nr_vectors = 0;",
"error_report(\"vfio: Error: Failed to enable MSI\");",
"VAR_0->interrupt = VFIO_INT_NONE;",
"return;",
"}",
"trace_vfio_msi_enable(VAR_0->vbasedev.name, VAR_0->nr_vectors);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
59
],
[
61
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
135
],
[
137
],
[
141
],
[
143
],
[
147
],
[
149
]
] |
23,235 | build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap;
const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int i;
madt = acpi_data_push(table_data, sizeof *madt);
gicd = acpi_data_push(table_data, sizeof *gicd);
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base;
for (i = 0; i < guest_info->smp_cpus; i++) {
AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data,
sizeof *gicc);
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
gicc->length = sizeof(*gicc);
if (guest_info->gic_version == 2) {
gicc->base_address = memmap[VIRT_GIC_CPU].base;
}
gicc->cpu_interface_number = i;
gicc->arm_mpidr = armcpu->mp_affinity;
gicc->uid = i;
gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);
}
if (guest_info->gic_version == 3) {
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
sizeof *gicr);
gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
gicr->length = sizeof(*gicr);
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
} else {
gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
}
build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 3, NULL, NULL);
}
| false | qemu | 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd | build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap;
const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int i;
madt = acpi_data_push(table_data, sizeof *madt);
gicd = acpi_data_push(table_data, sizeof *gicd);
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base;
for (i = 0; i < guest_info->smp_cpus; i++) {
AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data,
sizeof *gicc);
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
gicc->length = sizeof(*gicc);
if (guest_info->gic_version == 2) {
gicc->base_address = memmap[VIRT_GIC_CPU].base;
}
gicc->cpu_interface_number = i;
gicc->arm_mpidr = armcpu->mp_affinity;
gicc->uid = i;
gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);
}
if (guest_info->gic_version == 3) {
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
sizeof *gicr);
gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
gicr->length = sizeof(*gicr);
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
} else {
gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
}
build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 3, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, VirtGuestInfo *VAR_2)
{
int VAR_3 = VAR_0->len;
const MemMapEntry *VAR_4 = VAR_2->VAR_4;
const int *VAR_5 = VAR_2->VAR_5;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int VAR_6;
madt = acpi_data_push(VAR_0, sizeof *madt);
gicd = acpi_data_push(VAR_0, sizeof *gicd);
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
gicd->length = sizeof(*gicd);
gicd->base_address = VAR_4[VIRT_GIC_DIST].base;
for (VAR_6 = 0; VAR_6 < VAR_2->smp_cpus; VAR_6++) {
AcpiMadtGenericInterrupt *gicc = acpi_data_push(VAR_0,
sizeof *gicc);
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_6));
gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
gicc->length = sizeof(*gicc);
if (VAR_2->gic_version == 2) {
gicc->base_address = VAR_4[VIRT_GIC_CPU].base;
}
gicc->cpu_interface_number = VAR_6;
gicc->arm_mpidr = armcpu->mp_affinity;
gicc->uid = VAR_6;
gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);
}
if (VAR_2->gic_version == 3) {
AcpiMadtGenericRedistributor *gicr = acpi_data_push(VAR_0,
sizeof *gicr);
gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
gicr->length = sizeof(*gicr);
gicr->base_address = cpu_to_le64(VAR_4[VIRT_GIC_REDIST].base);
gicr->range_length = cpu_to_le32(VAR_4[VIRT_GIC_REDIST].size);
} else {
gic_msi = acpi_data_push(VAR_0, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(VAR_4[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(VAR_5[VIRT_GIC_V2M] + ARM_SPI_BASE);
}
build_header(VAR_1, VAR_0,
(void *)(VAR_0->data + VAR_3), "APIC",
VAR_0->len - VAR_3, 3, NULL, NULL);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, VirtGuestInfo *VAR_2)\n{",
"int VAR_3 = VAR_0->len;",
"const MemMapEntry *VAR_4 = VAR_2->VAR_4;",
"const int *VAR_5 = VAR_2->VAR_5;",
"AcpiMultipleApicTable *madt;",
"AcpiMadtGenericDistributor *gicd;",
"AcpiMadtGenericMsiFrame *gic_msi;",
"int VAR_6;",
"madt = acpi_data_push(VAR_0, sizeof *madt);",
"gicd = acpi_data_push(VAR_0, sizeof *gicd);",
"gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;",
"gicd->length = sizeof(*gicd);",
"gicd->base_address = VAR_4[VIRT_GIC_DIST].base;",
"for (VAR_6 = 0; VAR_6 < VAR_2->smp_cpus; VAR_6++) {",
"AcpiMadtGenericInterrupt *gicc = acpi_data_push(VAR_0,\nsizeof *gicc);",
"ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(VAR_6));",
"gicc->type = ACPI_APIC_GENERIC_INTERRUPT;",
"gicc->length = sizeof(*gicc);",
"if (VAR_2->gic_version == 2) {",
"gicc->base_address = VAR_4[VIRT_GIC_CPU].base;",
"}",
"gicc->cpu_interface_number = VAR_6;",
"gicc->arm_mpidr = armcpu->mp_affinity;",
"gicc->uid = VAR_6;",
"gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);",
"}",
"if (VAR_2->gic_version == 3) {",
"AcpiMadtGenericRedistributor *gicr = acpi_data_push(VAR_0,\nsizeof *gicr);",
"gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;",
"gicr->length = sizeof(*gicr);",
"gicr->base_address = cpu_to_le64(VAR_4[VIRT_GIC_REDIST].base);",
"gicr->range_length = cpu_to_le32(VAR_4[VIRT_GIC_REDIST].size);",
"} else {",
"gic_msi = acpi_data_push(VAR_0, sizeof *gic_msi);",
"gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;",
"gic_msi->length = sizeof(*gic_msi);",
"gic_msi->gic_msi_frame_id = 0;",
"gic_msi->base_address = cpu_to_le64(VAR_4[VIRT_GIC_V2M].base);",
"gic_msi->flags = cpu_to_le32(1);",
"gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);",
"gic_msi->spi_base = cpu_to_le16(VAR_5[VIRT_GIC_V2M] + ARM_SPI_BASE);",
"}",
"build_header(VAR_1, VAR_0,\n(void *)(VAR_0->data + VAR_3), \"APIC\",\nVAR_0->len - VAR_3, 3, NULL, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107,
109
],
[
111
]
] |
23,236 | void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(addr1)) {
/* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(addr1)) {
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_phys_addr_t VAR_0, uint32_t VAR_1)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, VAR_0 >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
VAR_0 = memory_region_section_addr(section, VAR_0);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, VAR_0, VAR_1, 4);
} else {
unsigned long VAR_2 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, VAR_0);
ptr = qemu_get_ram_ptr(VAR_2);
stl_p(ptr, VAR_1);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(VAR_2)) {
tb_invalidate_phys_page_range(VAR_2, VAR_2 + 4, 0);
cpu_physical_memory_set_dirty_flags(
VAR_2, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
| [
"void FUNC_0(target_phys_addr_t VAR_0, uint32_t VAR_1)\n{",
"uint8_t *ptr;",
"MemoryRegionSection *section;",
"section = phys_page_find(address_space_memory.dispatch, VAR_0 >> TARGET_PAGE_BITS);",
"if (!memory_region_is_ram(section->mr) || section->readonly) {",
"VAR_0 = memory_region_section_addr(section, VAR_0);",
"if (memory_region_is_ram(section->mr)) {",
"section = &phys_sections[phys_section_rom];",
"}",
"io_mem_write(section->mr, VAR_0, VAR_1, 4);",
"} else {",
"unsigned long VAR_2 = (memory_region_get_ram_addr(section->mr)\n& TARGET_PAGE_MASK)\n+ memory_region_section_addr(section, VAR_0);",
"ptr = qemu_get_ram_ptr(VAR_2);",
"stl_p(ptr, VAR_1);",
"if (unlikely(in_migration)) {",
"if (!cpu_physical_memory_is_dirty(VAR_2)) {",
"tb_invalidate_phys_page_range(VAR_2, VAR_2 + 4, 0);",
"cpu_physical_memory_set_dirty_flags(\nVAR_2, (0xff & ~CODE_DIRTY_FLAG));",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
23,238 | static void compare_pri_rs_finalize(SocketReadState *pri_rs)
{
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
if (packet_enqueue(s, PRIMARY_IN)) {
trace_colo_compare_main("primary: unsupported packet in");
compare_chr_send(s,
pri_rs->buf,
pri_rs->packet_len,
pri_rs->vnet_hdr_len);
} else {
/* compare connection */
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
}
}
| false | qemu | 8ec14402029d783720f4312ed8a925548e1dad61 | static void compare_pri_rs_finalize(SocketReadState *pri_rs)
{
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
if (packet_enqueue(s, PRIMARY_IN)) {
trace_colo_compare_main("primary: unsupported packet in");
compare_chr_send(s,
pri_rs->buf,
pri_rs->packet_len,
pri_rs->vnet_hdr_len);
} else {
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SocketReadState *VAR_0)
{
CompareState *s = container_of(VAR_0, CompareState, VAR_0);
if (packet_enqueue(s, PRIMARY_IN)) {
trace_colo_compare_main("primary: unsupported packet in");
compare_chr_send(s,
VAR_0->buf,
VAR_0->packet_len,
VAR_0->vnet_hdr_len);
} else {
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
}
}
| [
"static void FUNC_0(SocketReadState *VAR_0)\n{",
"CompareState *s = container_of(VAR_0, CompareState, VAR_0);",
"if (packet_enqueue(s, PRIMARY_IN)) {",
"trace_colo_compare_main(\"primary: unsupported packet in\");",
"compare_chr_send(s,\nVAR_0->buf,\nVAR_0->packet_len,\nVAR_0->vnet_hdr_len);",
"} else {",
"g_queue_foreach(&s->conn_list, colo_compare_connection, s);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13,
15,
17,
19
],
[
21
],
[
25
],
[
27
],
[
29
]
] |
23,239 | static int opt_default(const char *opt, const char *arg){
int type;
const AVOption *o= NULL;
int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
for(type=0; type<CODEC_TYPE_NB; type++){
const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
if(o2)
o = av_set_string(avctx_opts[type], opt, arg);
}
if(!o)
o = av_set_string(avformat_opts, opt, arg);
if(!o)
o = av_set_string(sws_opts, opt, arg);
if(!o){
if(opt[0] == 'a')
o = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg);
else if(opt[0] == 'v')
o = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg);
else if(opt[0] == 's')
o = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg);
}
if(!o)
return -1;
// av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avctx_opts, opt, NULL), (int)av_get_int(avctx_opts, opt, NULL));
//FIXME we should always use avctx_opts, ... for storing options so there wont be any need to keep track of whats set over this
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
opt_names[opt_name_count++]= o->name;
#ifdef CONFIG_FFM_MUXER
/* disable generate of real time pts in ffm (need to be supressed anyway) */
if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
if(avctx_opts[0]->debug)
av_log_set_level(AV_LOG_DEBUG);
return 0;
}
| false | FFmpeg | 3438d82d4b3bd987304975961e2a42e82767107d | static int opt_default(const char *opt, const char *arg){
int type;
const AVOption *o= NULL;
int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
for(type=0; type<CODEC_TYPE_NB; type++){
const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
if(o2)
o = av_set_string(avctx_opts[type], opt, arg);
}
if(!o)
o = av_set_string(avformat_opts, opt, arg);
if(!o)
o = av_set_string(sws_opts, opt, arg);
if(!o){
if(opt[0] == 'a')
o = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg);
else if(opt[0] == 'v')
o = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg);
else if(opt[0] == 's')
o = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg);
}
if(!o)
return -1;
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
opt_names[opt_name_count++]= o->name;
#ifdef CONFIG_FFM_MUXER
if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
if(avctx_opts[0]->debug)
av_log_set_level(AV_LOG_DEBUG);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, const char *VAR_1){
int VAR_2;
const AVOption *VAR_3= NULL;
int VAR_4[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
for(VAR_2=0; VAR_2<CODEC_TYPE_NB; VAR_2++){
const AVOption *o2 = av_find_opt(avctx_opts[0], VAR_0, NULL, VAR_4[VAR_2], VAR_4[VAR_2]);
if(o2)
VAR_3 = av_set_string(avctx_opts[VAR_2], VAR_0, VAR_1);
}
if(!VAR_3)
VAR_3 = av_set_string(avformat_opts, VAR_0, VAR_1);
if(!VAR_3)
VAR_3 = av_set_string(sws_opts, VAR_0, VAR_1);
if(!VAR_3){
if(VAR_0[0] == 'a')
VAR_3 = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], VAR_0+1, VAR_1);
else if(VAR_0[0] == 'v')
VAR_3 = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], VAR_0+1, VAR_1);
else if(VAR_0[0] == 's')
VAR_3 = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], VAR_0+1, VAR_1);
}
if(!VAR_3)
return -1;
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
opt_names[opt_name_count++]= VAR_3->name;
#ifdef CONFIG_FFM_MUXER
if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
if(avctx_opts[0]->debug)
av_log_set_level(AV_LOG_DEBUG);
return 0;
}
| [
"static int FUNC_0(const char *VAR_0, const char *VAR_1){",
"int VAR_2;",
"const AVOption *VAR_3= NULL;",
"int VAR_4[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};",
"for(VAR_2=0; VAR_2<CODEC_TYPE_NB; VAR_2++){",
"const AVOption *o2 = av_find_opt(avctx_opts[0], VAR_0, NULL, VAR_4[VAR_2], VAR_4[VAR_2]);",
"if(o2)\nVAR_3 = av_set_string(avctx_opts[VAR_2], VAR_0, VAR_1);",
"}",
"if(!VAR_3)\nVAR_3 = av_set_string(avformat_opts, VAR_0, VAR_1);",
"if(!VAR_3)\nVAR_3 = av_set_string(sws_opts, VAR_0, VAR_1);",
"if(!VAR_3){",
"if(VAR_0[0] == 'a')\nVAR_3 = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], VAR_0+1, VAR_1);",
"else if(VAR_0[0] == 'v')\nVAR_3 = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], VAR_0+1, VAR_1);",
"else if(VAR_0[0] == 's')\nVAR_3 = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], VAR_0+1, VAR_1);",
"}",
"if(!VAR_3)\nreturn -1;",
"opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));",
"opt_names[opt_name_count++]= VAR_3->name;",
"#ifdef CONFIG_FFM_MUXER\nif(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)\nffm_nopts = 1;",
"#endif\nif(avctx_opts[0]->debug)\nav_log_set_level(AV_LOG_DEBUG);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
57
],
[
59
],
[
63,
67,
69
],
[
71,
75,
77
],
[
79
],
[
81
]
] |
23,240 | static void test_qemu_strtoul_overflow(void)
{
const char *str = "99999999999999999999999999999999999999999999";
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, -ERANGE);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
}
| false | qemu | bc7c08a2c375acb7ae4d433054415588b176d34c | static void test_qemu_strtoul_overflow(void)
{
const char *str = "99999999999999999999999999999999999999999999";
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, -ERANGE);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
const char *VAR_0 = "99999999999999999999999999999999999999999999";
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
unsigned long VAR_3 = 999;
int VAR_4;
VAR_4 = qemu_strtoul(VAR_0, &VAR_2, 0, &VAR_3);
g_assert_cmpint(VAR_4, ==, -ERANGE);
g_assert_cmpint(VAR_3, ==, ULONG_MAX);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"99999999999999999999999999999999999999999999\";",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"unsigned long VAR_3 = 999;",
"int VAR_4;",
"VAR_4 = qemu_strtoul(VAR_0, &VAR_2, 0, &VAR_3);",
"g_assert_cmpint(VAR_4, ==, -ERANGE);",
"g_assert_cmpint(VAR_3, ==, ULONG_MAX);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
23,241 | int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
{
Property *prop;
int ret;
prop = qdev_prop_find(dev, name);
if (!prop) {
fprintf(stderr, "property \"%s.%s\" not found\n",
dev->info->name, name);
return -1;
}
if (!prop->info->parse) {
fprintf(stderr, "property \"%s.%s\" has no parser\n",
dev->info->name, name);
return -1;
}
ret = prop->info->parse(dev, prop, value);
if (ret < 0) {
switch (ret) {
case -EEXIST:
fprintf(stderr, "property \"%s.%s\": \"%s\" is already in use\n",
dev->info->name, name, value);
break;
default:
case -EINVAL:
fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
dev->info->name, name, value);
break;
case -ENOENT:
fprintf(stderr, "property \"%s.%s\": could not find \"%s\"\n",
dev->info->name, name, value);
break;
}
return -1;
}
return 0;
}
| false | qemu | 036f7166c73a9e0cc1b2f10c03763e61894a1033 | int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
{
Property *prop;
int ret;
prop = qdev_prop_find(dev, name);
if (!prop) {
fprintf(stderr, "property \"%s.%s\" not found\n",
dev->info->name, name);
return -1;
}
if (!prop->info->parse) {
fprintf(stderr, "property \"%s.%s\" has no parser\n",
dev->info->name, name);
return -1;
}
ret = prop->info->parse(dev, prop, value);
if (ret < 0) {
switch (ret) {
case -EEXIST:
fprintf(stderr, "property \"%s.%s\": \"%s\" is already in use\n",
dev->info->name, name, value);
break;
default:
case -EINVAL:
fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
dev->info->name, name, value);
break;
case -ENOENT:
fprintf(stderr, "property \"%s.%s\": could not find \"%s\"\n",
dev->info->name, name, value);
break;
}
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(DeviceState *VAR_0, const char *VAR_1, const char *VAR_2)
{
Property *prop;
int VAR_3;
prop = qdev_prop_find(VAR_0, VAR_1);
if (!prop) {
fprintf(stderr, "property \"%s.%s\" not found\n",
VAR_0->info->VAR_1, VAR_1);
return -1;
}
if (!prop->info->parse) {
fprintf(stderr, "property \"%s.%s\" has no parser\n",
VAR_0->info->VAR_1, VAR_1);
return -1;
}
VAR_3 = prop->info->parse(VAR_0, prop, VAR_2);
if (VAR_3 < 0) {
switch (VAR_3) {
case -EEXIST:
fprintf(stderr, "property \"%s.%s\": \"%s\" is already in use\n",
VAR_0->info->VAR_1, VAR_1, VAR_2);
break;
default:
case -EINVAL:
fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
VAR_0->info->VAR_1, VAR_1, VAR_2);
break;
case -ENOENT:
fprintf(stderr, "property \"%s.%s\": could not find \"%s\"\n",
VAR_0->info->VAR_1, VAR_1, VAR_2);
break;
}
return -1;
}
return 0;
}
| [
"int FUNC_0(DeviceState *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"Property *prop;",
"int VAR_3;",
"prop = qdev_prop_find(VAR_0, VAR_1);",
"if (!prop) {",
"fprintf(stderr, \"property \\\"%s.%s\\\" not found\\n\",\nVAR_0->info->VAR_1, VAR_1);",
"return -1;",
"}",
"if (!prop->info->parse) {",
"fprintf(stderr, \"property \\\"%s.%s\\\" has no parser\\n\",\nVAR_0->info->VAR_1, VAR_1);",
"return -1;",
"}",
"VAR_3 = prop->info->parse(VAR_0, prop, VAR_2);",
"if (VAR_3 < 0) {",
"switch (VAR_3) {",
"case -EEXIST:\nfprintf(stderr, \"property \\\"%s.%s\\\": \\\"%s\\\" is already in use\\n\",\nVAR_0->info->VAR_1, VAR_1, VAR_2);",
"break;",
"default:\ncase -EINVAL:\nfprintf(stderr, \"property \\\"%s.%s\\\": failed to parse \\\"%s\\\"\\n\",\nVAR_0->info->VAR_1, VAR_1, VAR_2);",
"break;",
"case -ENOENT:\nfprintf(stderr, \"property \\\"%s.%s\\\": could not find \\\"%s\\\"\\n\",\nVAR_0->info->VAR_1, VAR_1, VAR_2);",
"break;",
"}",
"return -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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41,
43
],
[
45
],
[
47,
49,
51,
53
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
23,242 | uint32_t ldub_phys(target_phys_addr_t addr)
{
uint8_t val;
cpu_physical_memory_read(addr, &val, 1);
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | uint32_t ldub_phys(target_phys_addr_t addr)
{
uint8_t val;
cpu_physical_memory_read(addr, &val, 1);
return val;
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(target_phys_addr_t addr)
{
uint8_t val;
cpu_physical_memory_read(addr, &val, 1);
return val;
}
| [
"uint32_t FUNC_0(target_phys_addr_t addr)\n{",
"uint8_t val;",
"cpu_physical_memory_read(addr, &val, 1);",
"return val;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
23,243 | static int get_physical_address_data(CPUState *env,
target_phys_addr_t *physical, int *prot,
target_ulong address, int rw, int mmu_idx)
{
unsigned int i;
uint64_t context;
int is_user = (mmu_idx == MMU_USER_IDX ||
mmu_idx == MMU_USER_SECONDARY_IDX);
if ((env->lsu & DMMU_E) == 0) { /* DMMU disabled */
*physical = ultrasparc_truncate_physical(address);
*prot = PAGE_READ | PAGE_WRITE;
return 0;
}
switch(mmu_idx) {
case MMU_USER_IDX:
case MMU_KERNEL_IDX:
context = env->dmmu.mmu_primary_context & 0x1fff;
break;
case MMU_USER_SECONDARY_IDX:
case MMU_KERNEL_SECONDARY_IDX:
context = env->dmmu.mmu_secondary_context & 0x1fff;
break;
case MMU_NUCLEUS_IDX:
default:
context = 0;
break;
}
for (i = 0; i < 64; i++) {
// ctx match, vaddr match, valid?
if (ultrasparc_tag_match(&env->dtlb[i],
address, context, physical)) {
// access ok?
if (((env->dtlb[i].tte & 0x4) && is_user) ||
(!(env->dtlb[i].tte & 0x2) && (rw == 1))) {
uint8_t fault_type = 0;
if ((env->dtlb[i].tte & 0x4) && is_user) {
fault_type |= 1; /* privilege violation */
}
if (env->dmmu.sfsr & 1) /* Fault status register */
env->dmmu.sfsr = 2; /* overflow (not read before
another fault) */
env->dmmu.sfsr |= (is_user << 3) | ((rw == 1) << 2) | 1;
env->dmmu.sfsr |= (fault_type << 7);
env->dmmu.sfar = address; /* Fault address register */
env->exception_index = TT_DFAULT;
#ifdef DEBUG_MMU
printf("DFAULT at 0x%" PRIx64 "\n", address);
#endif
return 1;
}
*prot = PAGE_READ;
if (env->dtlb[i].tte & 0x2)
*prot |= PAGE_WRITE;
TTE_SET_USED(env->dtlb[i].tte);
return 0;
}
}
#ifdef DEBUG_MMU
printf("DMISS at 0x%" PRIx64 "\n", address);
#endif
env->dmmu.tag_access = (address & ~0x1fffULL) | context;
env->exception_index = TT_DMISS;
return 1;
}
| false | qemu | b8e9fc0625c49404d63b4391f6dc5cf27be8b45b | static int get_physical_address_data(CPUState *env,
target_phys_addr_t *physical, int *prot,
target_ulong address, int rw, int mmu_idx)
{
unsigned int i;
uint64_t context;
int is_user = (mmu_idx == MMU_USER_IDX ||
mmu_idx == MMU_USER_SECONDARY_IDX);
if ((env->lsu & DMMU_E) == 0) {
*physical = ultrasparc_truncate_physical(address);
*prot = PAGE_READ | PAGE_WRITE;
return 0;
}
switch(mmu_idx) {
case MMU_USER_IDX:
case MMU_KERNEL_IDX:
context = env->dmmu.mmu_primary_context & 0x1fff;
break;
case MMU_USER_SECONDARY_IDX:
case MMU_KERNEL_SECONDARY_IDX:
context = env->dmmu.mmu_secondary_context & 0x1fff;
break;
case MMU_NUCLEUS_IDX:
default:
context = 0;
break;
}
for (i = 0; i < 64; i++) {
if (ultrasparc_tag_match(&env->dtlb[i],
address, context, physical)) {
if (((env->dtlb[i].tte & 0x4) && is_user) ||
(!(env->dtlb[i].tte & 0x2) && (rw == 1))) {
uint8_t fault_type = 0;
if ((env->dtlb[i].tte & 0x4) && is_user) {
fault_type |= 1;
}
if (env->dmmu.sfsr & 1)
env->dmmu.sfsr = 2;
env->dmmu.sfsr |= (is_user << 3) | ((rw == 1) << 2) | 1;
env->dmmu.sfsr |= (fault_type << 7);
env->dmmu.sfar = address;
env->exception_index = TT_DFAULT;
#ifdef DEBUG_MMU
printf("DFAULT at 0x%" PRIx64 "\n", address);
#endif
return 1;
}
*prot = PAGE_READ;
if (env->dtlb[i].tte & 0x2)
*prot |= PAGE_WRITE;
TTE_SET_USED(env->dtlb[i].tte);
return 0;
}
}
#ifdef DEBUG_MMU
printf("DMISS at 0x%" PRIx64 "\n", address);
#endif
env->dmmu.tag_access = (address & ~0x1fffULL) | context;
env->exception_index = TT_DMISS;
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState *VAR_0,
target_phys_addr_t *VAR_1, int *VAR_2,
target_ulong VAR_3, int VAR_4, int VAR_5)
{
unsigned int VAR_6;
uint64_t context;
int VAR_7 = (VAR_5 == MMU_USER_IDX ||
VAR_5 == MMU_USER_SECONDARY_IDX);
if ((VAR_0->lsu & DMMU_E) == 0) {
*VAR_1 = ultrasparc_truncate_physical(VAR_3);
*VAR_2 = PAGE_READ | PAGE_WRITE;
return 0;
}
switch(VAR_5) {
case MMU_USER_IDX:
case MMU_KERNEL_IDX:
context = VAR_0->dmmu.mmu_primary_context & 0x1fff;
break;
case MMU_USER_SECONDARY_IDX:
case MMU_KERNEL_SECONDARY_IDX:
context = VAR_0->dmmu.mmu_secondary_context & 0x1fff;
break;
case MMU_NUCLEUS_IDX:
default:
context = 0;
break;
}
for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {
if (ultrasparc_tag_match(&VAR_0->dtlb[VAR_6],
VAR_3, context, VAR_1)) {
if (((VAR_0->dtlb[VAR_6].tte & 0x4) && VAR_7) ||
(!(VAR_0->dtlb[VAR_6].tte & 0x2) && (VAR_4 == 1))) {
uint8_t fault_type = 0;
if ((VAR_0->dtlb[VAR_6].tte & 0x4) && VAR_7) {
fault_type |= 1;
}
if (VAR_0->dmmu.sfsr & 1)
VAR_0->dmmu.sfsr = 2;
VAR_0->dmmu.sfsr |= (VAR_7 << 3) | ((VAR_4 == 1) << 2) | 1;
VAR_0->dmmu.sfsr |= (fault_type << 7);
VAR_0->dmmu.sfar = VAR_3;
VAR_0->exception_index = TT_DFAULT;
#ifdef DEBUG_MMU
printf("DFAULT at 0x%" PRIx64 "\n", VAR_3);
#endif
return 1;
}
*VAR_2 = PAGE_READ;
if (VAR_0->dtlb[VAR_6].tte & 0x2)
*VAR_2 |= PAGE_WRITE;
TTE_SET_USED(VAR_0->dtlb[VAR_6].tte);
return 0;
}
}
#ifdef DEBUG_MMU
printf("DMISS at 0x%" PRIx64 "\n", VAR_3);
#endif
VAR_0->dmmu.tag_access = (VAR_3 & ~0x1fffULL) | context;
VAR_0->exception_index = TT_DMISS;
return 1;
}
| [
"static int FUNC_0(CPUState *VAR_0,\ntarget_phys_addr_t *VAR_1, int *VAR_2,\ntarget_ulong VAR_3, int VAR_4, int VAR_5)\n{",
"unsigned int VAR_6;",
"uint64_t context;",
"int VAR_7 = (VAR_5 == MMU_USER_IDX ||\nVAR_5 == MMU_USER_SECONDARY_IDX);",
"if ((VAR_0->lsu & DMMU_E) == 0) {",
"*VAR_1 = ultrasparc_truncate_physical(VAR_3);",
"*VAR_2 = PAGE_READ | PAGE_WRITE;",
"return 0;",
"}",
"switch(VAR_5) {",
"case MMU_USER_IDX:\ncase MMU_KERNEL_IDX:\ncontext = VAR_0->dmmu.mmu_primary_context & 0x1fff;",
"break;",
"case MMU_USER_SECONDARY_IDX:\ncase MMU_KERNEL_SECONDARY_IDX:\ncontext = VAR_0->dmmu.mmu_secondary_context & 0x1fff;",
"break;",
"case MMU_NUCLEUS_IDX:\ndefault:\ncontext = 0;",
"break;",
"}",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++) {",
"if (ultrasparc_tag_match(&VAR_0->dtlb[VAR_6],\nVAR_3, context, VAR_1)) {",
"if (((VAR_0->dtlb[VAR_6].tte & 0x4) && VAR_7) ||\n(!(VAR_0->dtlb[VAR_6].tte & 0x2) && (VAR_4 == 1))) {",
"uint8_t fault_type = 0;",
"if ((VAR_0->dtlb[VAR_6].tte & 0x4) && VAR_7) {",
"fault_type |= 1;",
"}",
"if (VAR_0->dmmu.sfsr & 1)\nVAR_0->dmmu.sfsr = 2;",
"VAR_0->dmmu.sfsr |= (VAR_7 << 3) | ((VAR_4 == 1) << 2) | 1;",
"VAR_0->dmmu.sfsr |= (fault_type << 7);",
"VAR_0->dmmu.sfar = VAR_3;",
"VAR_0->exception_index = TT_DFAULT;",
"#ifdef DEBUG_MMU\nprintf(\"DFAULT at 0x%\" PRIx64 \"\\n\", VAR_3);",
"#endif\nreturn 1;",
"}",
"*VAR_2 = PAGE_READ;",
"if (VAR_0->dtlb[VAR_6].tte & 0x2)\n*VAR_2 |= PAGE_WRITE;",
"TTE_SET_USED(VAR_0->dtlb[VAR_6].tte);",
"return 0;",
"}",
"}",
"#ifdef DEBUG_MMU\nprintf(\"DMISS at 0x%\" PRIx64 \"\\n\", VAR_3);",
"#endif\nVAR_0->dmmu.tag_access = (VAR_3 & ~0x1fffULL) | context;",
"VAR_0->exception_index = TT_DMISS;",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51,
53,
55
],
[
57
],
[
59
],
[
63
],
[
67,
69
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
97
],
[
101
],
[
105
],
[
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
]
] |
23,246 | static void vfio_pci_reset(DeviceState *dev)
{
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
if (!vdev->reset_works) {
return;
}
if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
error_report("vfio: Error unable to reset physical device "
"(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
}
}
| false | qemu | 5834a83f4803de88949162346e6dfa2060d3fca6 | static void vfio_pci_reset(DeviceState *dev)
{
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
if (!vdev->reset_works) {
return;
}
if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
error_report("vfio: Error unable to reset physical device "
"(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0)
{
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, VAR_0);
VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
if (!vdev->reset_works) {
return;
}
if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
error_report("vfio: Error unable to reset physical device "
"(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0)\n{",
"PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, VAR_0);",
"VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);",
"if (!vdev->reset_works) {",
"return;",
"}",
"if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {",
"error_report(\"vfio: Error unable to reset physical device \"\n\"(%04x:%02x:%02x.%x): %m\\n\", vdev->host.domain,\nvdev->host.bus, vdev->host.slot, vdev->host.function);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
]
] |
23,248 | void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table)
{
unsigned int i;
for (i = 0; i < n_tcg_ctxs; i++) {
const TCGProfile *orig = &tcg_ctxs[i]->prof;
if (counters) {
PROF_ADD(prof, orig, tb_count1);
PROF_ADD(prof, orig, tb_count);
PROF_ADD(prof, orig, op_count);
PROF_MAX(prof, orig, op_count_max);
PROF_ADD(prof, orig, temp_count);
PROF_MAX(prof, orig, temp_count_max);
PROF_ADD(prof, orig, del_op_count);
PROF_ADD(prof, orig, code_in_len);
PROF_ADD(prof, orig, code_out_len);
PROF_ADD(prof, orig, search_out_len);
PROF_ADD(prof, orig, interm_time);
PROF_ADD(prof, orig, code_time);
PROF_ADD(prof, orig, la_time);
PROF_ADD(prof, orig, opt_time);
PROF_ADD(prof, orig, restore_count);
PROF_ADD(prof, orig, restore_time);
}
if (table) {
int i;
for (i = 0; i < NB_OPS; i++) {
PROF_ADD(prof, orig, table_op_count[i]);
}
}
}
}
| false | qemu | 3468b59e18b179bc63c7ce934de912dfa9596122 | void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table)
{
unsigned int i;
for (i = 0; i < n_tcg_ctxs; i++) {
const TCGProfile *orig = &tcg_ctxs[i]->prof;
if (counters) {
PROF_ADD(prof, orig, tb_count1);
PROF_ADD(prof, orig, tb_count);
PROF_ADD(prof, orig, op_count);
PROF_MAX(prof, orig, op_count_max);
PROF_ADD(prof, orig, temp_count);
PROF_MAX(prof, orig, temp_count_max);
PROF_ADD(prof, orig, del_op_count);
PROF_ADD(prof, orig, code_in_len);
PROF_ADD(prof, orig, code_out_len);
PROF_ADD(prof, orig, search_out_len);
PROF_ADD(prof, orig, interm_time);
PROF_ADD(prof, orig, code_time);
PROF_ADD(prof, orig, la_time);
PROF_ADD(prof, orig, opt_time);
PROF_ADD(prof, orig, restore_count);
PROF_ADD(prof, orig, restore_time);
}
if (table) {
int i;
for (i = 0; i < NB_OPS; i++) {
PROF_ADD(prof, orig, table_op_count[i]);
}
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(TCGProfile *VAR_0, bool VAR_1, bool VAR_2)
{
unsigned int VAR_3;
for (VAR_3 = 0; VAR_3 < n_tcg_ctxs; VAR_3++) {
const TCGProfile *orig = &tcg_ctxs[VAR_3]->VAR_0;
if (VAR_1) {
PROF_ADD(VAR_0, orig, tb_count1);
PROF_ADD(VAR_0, orig, tb_count);
PROF_ADD(VAR_0, orig, op_count);
PROF_MAX(VAR_0, orig, op_count_max);
PROF_ADD(VAR_0, orig, temp_count);
PROF_MAX(VAR_0, orig, temp_count_max);
PROF_ADD(VAR_0, orig, del_op_count);
PROF_ADD(VAR_0, orig, code_in_len);
PROF_ADD(VAR_0, orig, code_out_len);
PROF_ADD(VAR_0, orig, search_out_len);
PROF_ADD(VAR_0, orig, interm_time);
PROF_ADD(VAR_0, orig, code_time);
PROF_ADD(VAR_0, orig, la_time);
PROF_ADD(VAR_0, orig, opt_time);
PROF_ADD(VAR_0, orig, restore_count);
PROF_ADD(VAR_0, orig, restore_time);
}
if (VAR_2) {
int VAR_3;
for (VAR_3 = 0; VAR_3 < NB_OPS; VAR_3++) {
PROF_ADD(VAR_0, orig, table_op_count[VAR_3]);
}
}
}
}
| [
"void FUNC_0(TCGProfile *VAR_0, bool VAR_1, bool VAR_2)\n{",
"unsigned int VAR_3;",
"for (VAR_3 = 0; VAR_3 < n_tcg_ctxs; VAR_3++) {",
"const TCGProfile *orig = &tcg_ctxs[VAR_3]->VAR_0;",
"if (VAR_1) {",
"PROF_ADD(VAR_0, orig, tb_count1);",
"PROF_ADD(VAR_0, orig, tb_count);",
"PROF_ADD(VAR_0, orig, op_count);",
"PROF_MAX(VAR_0, orig, op_count_max);",
"PROF_ADD(VAR_0, orig, temp_count);",
"PROF_MAX(VAR_0, orig, temp_count_max);",
"PROF_ADD(VAR_0, orig, del_op_count);",
"PROF_ADD(VAR_0, orig, code_in_len);",
"PROF_ADD(VAR_0, orig, code_out_len);",
"PROF_ADD(VAR_0, orig, search_out_len);",
"PROF_ADD(VAR_0, orig, interm_time);",
"PROF_ADD(VAR_0, orig, code_time);",
"PROF_ADD(VAR_0, orig, la_time);",
"PROF_ADD(VAR_0, orig, opt_time);",
"PROF_ADD(VAR_0, orig, restore_count);",
"PROF_ADD(VAR_0, orig, restore_time);",
"}",
"if (VAR_2) {",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < NB_OPS; VAR_3++) {",
"PROF_ADD(VAR_0, orig, table_op_count[VAR_3]);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
23,252 | static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
{
char *pix_fmts;
OutputStream *ost = ofilter->ost;
OutputFile *of = output_files[ost->file_index];
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
int ret;
char name[255];
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&ofilter->filter,
avfilter_get_by_name("buffersink"),
name, NULL, NULL, fg->graph);
if (ret < 0)
return ret;
if (!hw_device_ctx && (ofilter->width || ofilter->height)) {
char args[255];
AVFilterContext *filter;
snprintf(args, sizeof(args), "%d:%d:0x%X",
ofilter->width, ofilter->height,
(unsigned)ost->sws_flags);
snprintf(name, sizeof(name), "scaler for output stream %d:%d",
ost->file_index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
name, args, NULL, fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if ((pix_fmts = choose_pix_fmts(ofilter))) {
AVFilterContext *filter;
snprintf(name, sizeof(name), "pixel format for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL, fg->graph);
av_freep(&pix_fmts);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if (ost->frame_rate.num) {
AVFilterContext *fps;
char args[255];
snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
ost->frame_rate.den);
snprintf(name, sizeof(name), "fps for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
name, args, NULL, fg->graph);
if (ret < 0)
return ret;
ret = avfilter_link(last_filter, pad_idx, fps, 0);
if (ret < 0)
return ret;
last_filter = fps;
pad_idx = 0;
}
snprintf(name, sizeof(name), "trim for output stream %d:%d",
ost->file_index, ost->index);
ret = insert_trim(of->start_time, of->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
return ret;
return 0;
}
| false | FFmpeg | bd31c61cf94d01dbe1051cf65874e7b2c0ac5454 | static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
{
char *pix_fmts;
OutputStream *ost = ofilter->ost;
OutputFile *of = output_files[ost->file_index];
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
int ret;
char name[255];
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&ofilter->filter,
avfilter_get_by_name("buffersink"),
name, NULL, NULL, fg->graph);
if (ret < 0)
return ret;
if (!hw_device_ctx && (ofilter->width || ofilter->height)) {
char args[255];
AVFilterContext *filter;
snprintf(args, sizeof(args), "%d:%d:0x%X",
ofilter->width, ofilter->height,
(unsigned)ost->sws_flags);
snprintf(name, sizeof(name), "scaler for output stream %d:%d",
ost->file_index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
name, args, NULL, fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if ((pix_fmts = choose_pix_fmts(ofilter))) {
AVFilterContext *filter;
snprintf(name, sizeof(name), "pixel format for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL, fg->graph);
av_freep(&pix_fmts);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if (ost->frame_rate.num) {
AVFilterContext *fps;
char args[255];
snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
ost->frame_rate.den);
snprintf(name, sizeof(name), "fps for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
name, args, NULL, fg->graph);
if (ret < 0)
return ret;
ret = avfilter_link(last_filter, pad_idx, fps, 0);
if (ret < 0)
return ret;
last_filter = fps;
pad_idx = 0;
}
snprintf(name, sizeof(name), "trim for output stream %d:%d",
ost->file_index, ost->index);
ret = insert_trim(of->start_time, of->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
return ret;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FilterGraph *VAR_0, OutputFilter *VAR_1, AVFilterInOut *VAR_2)
{
char *VAR_3;
OutputStream *ost = VAR_1->ost;
OutputFile *of = output_files[ost->file_index];
AVFilterContext *last_filter = VAR_2->filter_ctx;
int VAR_4 = VAR_2->VAR_4;
int VAR_5;
char VAR_6[255];
snprintf(VAR_6, sizeof(VAR_6), "output stream %d:%d", ost->file_index, ost->index);
VAR_5 = avfilter_graph_create_filter(&VAR_1->filter,
avfilter_get_by_name("buffersink"),
VAR_6, NULL, NULL, VAR_0->graph);
if (VAR_5 < 0)
return VAR_5;
if (!hw_device_ctx && (VAR_1->width || VAR_1->height)) {
char VAR_8[255];
AVFilterContext *filter;
snprintf(VAR_8, sizeof(VAR_8), "%d:%d:0x%X",
VAR_1->width, VAR_1->height,
(unsigned)ost->sws_flags);
snprintf(VAR_6, sizeof(VAR_6), "scaler for output stream %d:%d",
ost->file_index, ost->index);
if ((VAR_5 = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
VAR_6, VAR_8, NULL, VAR_0->graph)) < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, VAR_4, filter, 0)) < 0)
return VAR_5;
last_filter = filter;
VAR_4 = 0;
}
if ((VAR_3 = choose_pix_fmts(VAR_1))) {
AVFilterContext *filter;
snprintf(VAR_6, sizeof(VAR_6), "pixel format for output stream %d:%d",
ost->file_index, ost->index);
VAR_5 = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", VAR_3, NULL, VAR_0->graph);
av_freep(&VAR_3);
if (VAR_5 < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, VAR_4, filter, 0)) < 0)
return VAR_5;
last_filter = filter;
VAR_4 = 0;
}
if (ost->frame_rate.num) {
AVFilterContext *fps;
char VAR_8[255];
snprintf(VAR_8, sizeof(VAR_8), "fps=%d/%d", ost->frame_rate.num,
ost->frame_rate.den);
snprintf(VAR_6, sizeof(VAR_6), "fps for output stream %d:%d",
ost->file_index, ost->index);
VAR_5 = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
VAR_6, VAR_8, NULL, VAR_0->graph);
if (VAR_5 < 0)
return VAR_5;
VAR_5 = avfilter_link(last_filter, VAR_4, fps, 0);
if (VAR_5 < 0)
return VAR_5;
last_filter = fps;
VAR_4 = 0;
}
snprintf(VAR_6, sizeof(VAR_6), "trim for output stream %d:%d",
ost->file_index, ost->index);
VAR_5 = insert_trim(of->start_time, of->recording_time,
&last_filter, &VAR_4, VAR_6);
if (VAR_5 < 0)
return VAR_5;
if ((VAR_5 = avfilter_link(last_filter, VAR_4, VAR_1->filter, 0)) < 0)
return VAR_5;
return 0;
}
| [
"static int FUNC_0(FilterGraph *VAR_0, OutputFilter *VAR_1, AVFilterInOut *VAR_2)\n{",
"char *VAR_3;",
"OutputStream *ost = VAR_1->ost;",
"OutputFile *of = output_files[ost->file_index];",
"AVFilterContext *last_filter = VAR_2->filter_ctx;",
"int VAR_4 = VAR_2->VAR_4;",
"int VAR_5;",
"char VAR_6[255];",
"snprintf(VAR_6, sizeof(VAR_6), \"output stream %d:%d\", ost->file_index, ost->index);",
"VAR_5 = avfilter_graph_create_filter(&VAR_1->filter,\navfilter_get_by_name(\"buffersink\"),\nVAR_6, NULL, NULL, VAR_0->graph);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if (!hw_device_ctx && (VAR_1->width || VAR_1->height)) {",
"char VAR_8[255];",
"AVFilterContext *filter;",
"snprintf(VAR_8, sizeof(VAR_8), \"%d:%d:0x%X\",\nVAR_1->width, VAR_1->height,\n(unsigned)ost->sws_flags);",
"snprintf(VAR_6, sizeof(VAR_6), \"scaler for output stream %d:%d\",\nost->file_index, ost->index);",
"if ((VAR_5 = avfilter_graph_create_filter(&filter, avfilter_get_by_name(\"scale\"),\nVAR_6, VAR_8, NULL, VAR_0->graph)) < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, VAR_4, filter, 0)) < 0)\nreturn VAR_5;",
"last_filter = filter;",
"VAR_4 = 0;",
"}",
"if ((VAR_3 = choose_pix_fmts(VAR_1))) {",
"AVFilterContext *filter;",
"snprintf(VAR_6, sizeof(VAR_6), \"pixel format for output stream %d:%d\",\nost->file_index, ost->index);",
"VAR_5 = avfilter_graph_create_filter(&filter,\navfilter_get_by_name(\"format\"),\n\"format\", VAR_3, NULL, VAR_0->graph);",
"av_freep(&VAR_3);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, VAR_4, filter, 0)) < 0)\nreturn VAR_5;",
"last_filter = filter;",
"VAR_4 = 0;",
"}",
"if (ost->frame_rate.num) {",
"AVFilterContext *fps;",
"char VAR_8[255];",
"snprintf(VAR_8, sizeof(VAR_8), \"fps=%d/%d\", ost->frame_rate.num,\nost->frame_rate.den);",
"snprintf(VAR_6, sizeof(VAR_6), \"fps for output stream %d:%d\",\nost->file_index, ost->index);",
"VAR_5 = avfilter_graph_create_filter(&fps, avfilter_get_by_name(\"fps\"),\nVAR_6, VAR_8, NULL, VAR_0->graph);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_5 = avfilter_link(last_filter, VAR_4, fps, 0);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"last_filter = fps;",
"VAR_4 = 0;",
"}",
"snprintf(VAR_6, sizeof(VAR_6), \"trim for output stream %d:%d\",\nost->file_index, ost->index);",
"VAR_5 = insert_trim(of->start_time, of->recording_time,\n&last_filter, &VAR_4, VAR_6);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"if ((VAR_5 = avfilter_link(last_filter, VAR_4, VAR_1->filter, 0)) < 0)\nreturn VAR_5;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25,
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
43,
45,
47
],
[
49,
51
],
[
53,
55,
57
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77,
79
],
[
81,
83,
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
147,
149
],
[
151,
153
],
[
155,
157
],
[
163,
165
],
[
169
],
[
171
]
] |
23,253 | static void vfio_exitfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
VFIOGroup *group = vdev->vbasedev.group;
vfio_unregister_err_notifier(vdev);
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
timer_free(vdev->intx.mmap_timer);
}
vfio_teardown_msi(vdev);
vfio_unmap_bars(vdev);
g_free(vdev->emulated_config_bits);
g_free(vdev->rom);
vfio_put_device(vdev);
vfio_put_group(group);
}
| true | qemu | 77a10d04d033484a913a5ee76eed31a9acc57bae | static void vfio_exitfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
VFIOGroup *group = vdev->vbasedev.group;
vfio_unregister_err_notifier(vdev);
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
timer_free(vdev->intx.mmap_timer);
}
vfio_teardown_msi(vdev);
vfio_unmap_bars(vdev);
g_free(vdev->emulated_config_bits);
g_free(vdev->rom);
vfio_put_device(vdev);
vfio_put_group(group);
}
| {
"code": [
" VFIOGroup *group = vdev->vbasedev.group;",
" g_free(vdev->emulated_config_bits);",
" g_free(vdev->rom);",
" vfio_put_device(vdev);",
" vfio_put_group(group);"
],
"line_no": [
7,
27,
29,
31,
33
]
} | static void FUNC_0(PCIDevice *VAR_0)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, VAR_0, VAR_0);
VFIOGroup *group = vdev->vbasedev.group;
vfio_unregister_err_notifier(vdev);
pci_device_set_intx_routing_notifier(&vdev->VAR_0, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
timer_free(vdev->intx.mmap_timer);
}
vfio_teardown_msi(vdev);
vfio_unmap_bars(vdev);
g_free(vdev->emulated_config_bits);
g_free(vdev->rom);
vfio_put_device(vdev);
vfio_put_group(group);
}
| [
"static void FUNC_0(PCIDevice *VAR_0)\n{",
"VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, VAR_0, VAR_0);",
"VFIOGroup *group = vdev->vbasedev.group;",
"vfio_unregister_err_notifier(vdev);",
"pci_device_set_intx_routing_notifier(&vdev->VAR_0, NULL);",
"vfio_disable_interrupts(vdev);",
"if (vdev->intx.mmap_timer) {",
"timer_free(vdev->intx.mmap_timer);",
"}",
"vfio_teardown_msi(vdev);",
"vfio_unmap_bars(vdev);",
"g_free(vdev->emulated_config_bits);",
"g_free(vdev->rom);",
"vfio_put_device(vdev);",
"vfio_put_group(group);",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
23,254 | static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
((pixel4*)(src+0*stride))[0]=
((pixel4*)(src+1*stride))[0]=
((pixel4*)(src+2*stride))[0]=
((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
}
| true | FFmpeg | 2caf19e90f270abe1e80a3e85acaf0eb5c9d0aac | static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
((pixel4*)(src+0*stride))[0]=
((pixel4*)(src+1*stride))[0]=
((pixel4*)(src+2*stride))[0]=
((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
}
| {
"code": [
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]=",
" ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);",
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]=",
" ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);",
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]=",
" ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);",
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]=",
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]=",
" ((pixel4*)(src+0*stride))[0]=",
" ((pixel4*)(src+1*stride))[0]=",
" ((pixel4*)(src+2*stride))[0]="
],
"line_no": [
11,
13,
15,
17,
11,
13,
15,
17,
11,
13,
15,
17,
11,
13,
15,
11,
13,
15,
11,
13,
15
]
} | static void FUNC_0(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int VAR_0 = _stride/sizeof(pixel);
const int VAR_1= ( src[-1+0*VAR_0] + src[-1+1*VAR_0] + src[-1+2*VAR_0] + src[-1+3*VAR_0] + 2) >>2;
((pixel4*)(src+0*VAR_0))[0]=
((pixel4*)(src+1*VAR_0))[0]=
((pixel4*)(src+2*VAR_0))[0]=
((pixel4*)(src+3*VAR_0))[0]= PIXEL_SPLAT_X4(VAR_1);
}
| [
"static void FUNC_0(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){",
"pixel *src = (pixel*)_src;",
"int VAR_0 = _stride/sizeof(pixel);",
"const int VAR_1= ( src[-1+0*VAR_0] + src[-1+1*VAR_0] + src[-1+2*VAR_0] + src[-1+3*VAR_0] + 2) >>2;",
"((pixel4*)(src+0*VAR_0))[0]=\n((pixel4*)(src+1*VAR_0))[0]=\n((pixel4*)(src+2*VAR_0))[0]=\n((pixel4*)(src+3*VAR_0))[0]= PIXEL_SPLAT_X4(VAR_1);",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11,
13,
15,
17
],
[
19
]
] |
23,255 | static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
{
int cIdx, i;
uint8_t hash_type;
//uint16_t picture_crc;
//uint32_t picture_checksum;
GetBitContext *gb = &s->HEVClc->gb;
hash_type = get_bits(gb, 8);
for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; cIdx++) {
if (hash_type == 0) {
s->is_md5 = 1;
for (i = 0; i < 16; i++)
s->md5[cIdx][i] = get_bits(gb, 8);
} else if (hash_type == 1) {
// picture_crc = get_bits(gb, 16);
skip_bits(gb, 16);
} else if (hash_type == 2) {
// picture_checksum = get_bits(gb, 32);
skip_bits(gb, 32);
}
}
}
| true | FFmpeg | 5183fac92fc5c574a053dd06b84e735a1ec1cfa6 | static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
{
int cIdx, i;
uint8_t hash_type;
GetBitContext *gb = &s->HEVClc->gb;
hash_type = get_bits(gb, 8);
for (cIdx = 0; cIdx < 3; cIdx++) {
if (hash_type == 0) {
s->is_md5 = 1;
for (i = 0; i < 16; i++)
s->md5[cIdx][i] = get_bits(gb, 8);
} else if (hash_type == 1) {
skip_bits(gb, 16);
} else if (hash_type == 2) {
skip_bits(gb, 32);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(HEVCContext *VAR_0)
{
int VAR_1, VAR_2;
uint8_t hash_type;
GetBitContext *gb = &VAR_0->HEVClc->gb;
hash_type = get_bits(gb, 8);
for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {
if (hash_type == 0) {
VAR_0->is_md5 = 1;
for (VAR_2 = 0; VAR_2 < 16; VAR_2++)
VAR_0->md5[VAR_1][VAR_2] = get_bits(gb, 8);
} else if (hash_type == 1) {
skip_bits(gb, 16);
} else if (hash_type == 2) {
skip_bits(gb, 32);
}
}
}
| [
"static void FUNC_0(HEVCContext *VAR_0)\n{",
"int VAR_1, VAR_2;",
"uint8_t hash_type;",
"GetBitContext *gb = &VAR_0->HEVClc->gb;",
"hash_type = get_bits(gb, 8);",
"for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {",
"if (hash_type == 0) {",
"VAR_0->is_md5 = 1;",
"for (VAR_2 = 0; VAR_2 < 16; VAR_2++)",
"VAR_0->md5[VAR_1][VAR_2] = get_bits(gb, 8);",
"} else if (hash_type == 1) {",
"skip_bits(gb, 16);",
"} else if (hash_type == 2) {",
"skip_bits(gb, 32);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
23,257 | static av_cold void dcadec_flush(AVCodecContext *avctx)
{
DCAContext *s = avctx->priv_data;
ff_dca_core_flush(&s->core);
ff_dca_xll_flush(&s->xll);
ff_dca_lbr_flush(&s->lbr);
s->core_residual_valid = 0;
}
| false | FFmpeg | 801dbf0269b1bb5bc70c550e971491e0aea9eb70 | static av_cold void dcadec_flush(AVCodecContext *avctx)
{
DCAContext *s = avctx->priv_data;
ff_dca_core_flush(&s->core);
ff_dca_xll_flush(&s->xll);
ff_dca_lbr_flush(&s->lbr);
s->core_residual_valid = 0;
}
| {
"code": [],
"line_no": []
} | static av_cold void FUNC_0(AVCodecContext *avctx)
{
DCAContext *s = avctx->priv_data;
ff_dca_core_flush(&s->core);
ff_dca_xll_flush(&s->xll);
ff_dca_lbr_flush(&s->lbr);
s->core_residual_valid = 0;
}
| [
"static av_cold void FUNC_0(AVCodecContext *avctx)\n{",
"DCAContext *s = avctx->priv_data;",
"ff_dca_core_flush(&s->core);",
"ff_dca_xll_flush(&s->xll);",
"ff_dca_lbr_flush(&s->lbr);",
"s->core_residual_valid = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
23,258 | static int amf_parse_object(AVFormatContext *s, AVStream *astream,
AVStream *vstream, const char *key,
int64_t max_pos, int depth)
{
AVCodecContext *acodec, *vcodec;
FLVContext *flv = s->priv_data;
AVIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
num_val = 0;
ioc = s->pb;
amf_type = avio_r8(ioc);
switch (amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2double(avio_rb64(ioc));
break;
case AMF_DATA_TYPE_BOOL:
num_val = avio_r8(ioc);
break;
case AMF_DATA_TYPE_STRING:
if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT:
if ((vstream || astream) && key &&
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
max_pos) < 0)
return -1;
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1; // if we couldn't skip, bomb out.
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break; // these take up no additional space
case AMF_DATA_TYPE_MIXEDARRAY:
avio_skip(ioc, 4); // skip 32-bit max array index
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
// this is the only case in which we would want a nested
// parse to not skip over the object
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY:
{
unsigned int arraylen, i;
arraylen = avio_rb32(ioc);
for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++)
if (amf_parse_object(s, NULL, NULL, NULL, max_pos,
depth + 1) < 0)
return -1; // if we couldn't skip, bomb out.
}
break;
case AMF_DATA_TYPE_DATE:
avio_skip(ioc, 8 + 2); // timestamp (double) and UTC offset (int16)
break;
default: // unsupported type, we couldn't skip
return -1;
}
// only look for metadata values when we are not nested and key != NULL
if (depth == 1 && key) {
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(key, "duration"))
s->duration = num_val * AV_TIME_BASE;
else if (!strcmp(key, "videodatarate") && vcodec &&
0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "audiodatarate") && acodec &&
0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "datastream")) {
AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(key, "videocodecid") && vcodec) {
flv_set_video_codec(s, vstream, num_val, 0);
} else if (!strcmp(key, "audiocodecid") && acodec) {
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(s, astream, acodec, id);
} else if (!strcmp(key, "audiosamplerate") && acodec) {
acodec->sample_rate = num_val;
} else if (!strcmp(key, "audiosamplesize") && acodec) {
acodec->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && acodec) {
acodec->channels = num_val + 1;
acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(key, "width") && vcodec) {
vcodec->width = num_val;
} else if (!strcmp(key, "height") && vcodec) {
vcodec->height = num_val;
}
}
}
if (!strcmp(key, "duration") ||
!strcmp(key, "filesize") ||
!strcmp(key, "width") ||
!strcmp(key, "height") ||
!strcmp(key, "videodatarate") ||
!strcmp(key, "framerate") ||
!strcmp(key, "videocodecid") ||
!strcmp(key, "audiodatarate") ||
!strcmp(key, "audiosamplerate") ||
!strcmp(key, "audiosamplesize") ||
!strcmp(key, "stereo") ||
!strcmp(key, "audiocodecid") ||
!strcmp(key, "datastream"))
return 0;
if (amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false",
sizeof(str_val));
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_dict_set(&s->metadata, key, str_val, 0);
}
return 0;
}
| false | FFmpeg | 93c04e095dc37ebdab22174e88cfa91e24940866 | static int amf_parse_object(AVFormatContext *s, AVStream *astream,
AVStream *vstream, const char *key,
int64_t max_pos, int depth)
{
AVCodecContext *acodec, *vcodec;
FLVContext *flv = s->priv_data;
AVIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
num_val = 0;
ioc = s->pb;
amf_type = avio_r8(ioc);
switch (amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2double(avio_rb64(ioc));
break;
case AMF_DATA_TYPE_BOOL:
num_val = avio_r8(ioc);
break;
case AMF_DATA_TYPE_STRING:
if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT:
if ((vstream || astream) && key &&
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
max_pos) < 0)
return -1;
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break;
case AMF_DATA_TYPE_MIXEDARRAY:
avio_skip(ioc, 4);
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY:
{
unsigned int arraylen, i;
arraylen = avio_rb32(ioc);
for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++)
if (amf_parse_object(s, NULL, NULL, NULL, max_pos,
depth + 1) < 0)
return -1;
}
break;
case AMF_DATA_TYPE_DATE:
avio_skip(ioc, 8 + 2);
break;
default:
return -1;
}
if (depth == 1 && key) {
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(key, "duration"))
s->duration = num_val * AV_TIME_BASE;
else if (!strcmp(key, "videodatarate") && vcodec &&
0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "audiodatarate") && acodec &&
0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "datastream")) {
AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(key, "videocodecid") && vcodec) {
flv_set_video_codec(s, vstream, num_val, 0);
} else if (!strcmp(key, "audiocodecid") && acodec) {
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(s, astream, acodec, id);
} else if (!strcmp(key, "audiosamplerate") && acodec) {
acodec->sample_rate = num_val;
} else if (!strcmp(key, "audiosamplesize") && acodec) {
acodec->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && acodec) {
acodec->channels = num_val + 1;
acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(key, "width") && vcodec) {
vcodec->width = num_val;
} else if (!strcmp(key, "height") && vcodec) {
vcodec->height = num_val;
}
}
}
if (!strcmp(key, "duration") ||
!strcmp(key, "filesize") ||
!strcmp(key, "width") ||
!strcmp(key, "height") ||
!strcmp(key, "videodatarate") ||
!strcmp(key, "framerate") ||
!strcmp(key, "videocodecid") ||
!strcmp(key, "audiodatarate") ||
!strcmp(key, "audiosamplerate") ||
!strcmp(key, "audiosamplesize") ||
!strcmp(key, "stereo") ||
!strcmp(key, "audiocodecid") ||
!strcmp(key, "datastream"))
return 0;
if (amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false",
sizeof(str_val));
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_dict_set(&s->metadata, key, str_val, 0);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,
AVStream *VAR_2, const char *VAR_3,
int64_t VAR_4, int VAR_5)
{
AVCodecContext *acodec, *vcodec;
FLVContext *flv = VAR_0->priv_data;
AVIOContext *ioc;
AMFDataType amf_type;
char VAR_6[256];
double VAR_7;
VAR_7 = 0;
ioc = VAR_0->pb;
amf_type = avio_r8(ioc);
switch (amf_type) {
case AMF_DATA_TYPE_NUMBER:
VAR_7 = av_int2double(avio_rb64(ioc));
break;
case AMF_DATA_TYPE_BOOL:
VAR_7 = avio_r8(ioc);
break;
case AMF_DATA_TYPE_STRING:
if (amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT:
if ((VAR_2 || VAR_1) && VAR_3 &&
!strcmp(KEYFRAMES_TAG, VAR_3) && VAR_5 == 1)
if (parse_keyframes_index(VAR_0, ioc, VAR_2 ? VAR_2 : VAR_1,
VAR_4) < 0)
return -1;
while (avio_tell(ioc) < VAR_4 - 2 &&
amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)
if (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,
VAR_5 + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break;
case AMF_DATA_TYPE_MIXEDARRAY:
avio_skip(ioc, 4);
while (avio_tell(ioc) < VAR_4 - 2 &&
amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)
if (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,
VAR_5 + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY:
{
unsigned int VAR_8, VAR_9;
VAR_8 = avio_rb32(ioc);
for (VAR_9 = 0; VAR_9 < VAR_8 && avio_tell(ioc) < VAR_4 - 1; VAR_9++)
if (FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4,
VAR_5 + 1) < 0)
return -1;
}
break;
case AMF_DATA_TYPE_DATE:
avio_skip(ioc, 8 + 2);
break;
default:
return -1;
}
if (VAR_5 == 1 && VAR_3) {
acodec = VAR_1 ? VAR_1->codec : NULL;
vcodec = VAR_2 ? VAR_2->codec : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(VAR_3, "duration"))
VAR_0->duration = VAR_7 * AV_TIME_BASE;
else if (!strcmp(VAR_3, "videodatarate") && vcodec &&
0 <= (int)(VAR_7 * 1024.0))
vcodec->bit_rate = VAR_7 * 1024.0;
else if (!strcmp(VAR_3, "audiodatarate") && acodec &&
0 <= (int)(VAR_7 * 1024.0))
acodec->bit_rate = VAR_7 * 1024.0;
else if (!strcmp(VAR_3, "datastream")) {
AVStream *st = create_stream(VAR_0, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(VAR_3, "videocodecid") && vcodec) {
flv_set_video_codec(VAR_0, VAR_2, VAR_7, 0);
} else if (!strcmp(VAR_3, "audiocodecid") && acodec) {
int VAR_10 = ((int)VAR_7) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(VAR_0, VAR_1, acodec, VAR_10);
} else if (!strcmp(VAR_3, "audiosamplerate") && acodec) {
acodec->sample_rate = VAR_7;
} else if (!strcmp(VAR_3, "audiosamplesize") && acodec) {
acodec->bits_per_coded_sample = VAR_7;
} else if (!strcmp(VAR_3, "stereo") && acodec) {
acodec->channels = VAR_7 + 1;
acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(VAR_3, "width") && vcodec) {
vcodec->width = VAR_7;
} else if (!strcmp(VAR_3, "height") && vcodec) {
vcodec->height = VAR_7;
}
}
}
if (!strcmp(VAR_3, "duration") ||
!strcmp(VAR_3, "filesize") ||
!strcmp(VAR_3, "width") ||
!strcmp(VAR_3, "height") ||
!strcmp(VAR_3, "videodatarate") ||
!strcmp(VAR_3, "framerate") ||
!strcmp(VAR_3, "videocodecid") ||
!strcmp(VAR_3, "audiodatarate") ||
!strcmp(VAR_3, "audiosamplerate") ||
!strcmp(VAR_3, "audiosamplesize") ||
!strcmp(VAR_3, "stereo") ||
!strcmp(VAR_3, "audiocodecid") ||
!strcmp(VAR_3, "datastream"))
return 0;
if (amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(VAR_6, VAR_7 > 0 ? "true" : "false",
sizeof(VAR_6));
av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);
} else if (amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(VAR_6, sizeof(VAR_6), "%.f", VAR_7);
av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,\nAVStream *VAR_2, const char *VAR_3,\nint64_t VAR_4, int VAR_5)\n{",
"AVCodecContext *acodec, *vcodec;",
"FLVContext *flv = VAR_0->priv_data;",
"AVIOContext *ioc;",
"AMFDataType amf_type;",
"char VAR_6[256];",
"double VAR_7;",
"VAR_7 = 0;",
"ioc = VAR_0->pb;",
"amf_type = avio_r8(ioc);",
"switch (amf_type) {",
"case AMF_DATA_TYPE_NUMBER:\nVAR_7 = av_int2double(avio_rb64(ioc));",
"break;",
"case AMF_DATA_TYPE_BOOL:\nVAR_7 = avio_r8(ioc);",
"break;",
"case AMF_DATA_TYPE_STRING:\nif (amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0)\nreturn -1;",
"break;",
"case AMF_DATA_TYPE_OBJECT:\nif ((VAR_2 || VAR_1) && VAR_3 &&\n!strcmp(KEYFRAMES_TAG, VAR_3) && VAR_5 == 1)\nif (parse_keyframes_index(VAR_0, ioc, VAR_2 ? VAR_2 : VAR_1,\nVAR_4) < 0)\nreturn -1;",
"while (avio_tell(ioc) < VAR_4 - 2 &&\namf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)\nif (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;",
"if (avio_r8(ioc) != AMF_END_OF_OBJECT)\nreturn -1;",
"break;",
"case AMF_DATA_TYPE_NULL:\ncase AMF_DATA_TYPE_UNDEFINED:\ncase AMF_DATA_TYPE_UNSUPPORTED:\nbreak;",
"case AMF_DATA_TYPE_MIXEDARRAY:\navio_skip(ioc, 4);",
"while (avio_tell(ioc) < VAR_4 - 2 &&\namf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0)\nif (FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;",
"if (avio_r8(ioc) != AMF_END_OF_OBJECT)\nreturn -1;",
"break;",
"case AMF_DATA_TYPE_ARRAY:\n{",
"unsigned int VAR_8, VAR_9;",
"VAR_8 = avio_rb32(ioc);",
"for (VAR_9 = 0; VAR_9 < VAR_8 && avio_tell(ioc) < VAR_4 - 1; VAR_9++)",
"if (FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4,\nVAR_5 + 1) < 0)\nreturn -1;",
"}",
"break;",
"case AMF_DATA_TYPE_DATE:\navio_skip(ioc, 8 + 2);",
"break;",
"default:\nreturn -1;",
"}",
"if (VAR_5 == 1 && VAR_3) {",
"acodec = VAR_1 ? VAR_1->codec : NULL;",
"vcodec = VAR_2 ? VAR_2->codec : NULL;",
"if (amf_type == AMF_DATA_TYPE_NUMBER ||\namf_type == AMF_DATA_TYPE_BOOL) {",
"if (!strcmp(VAR_3, \"duration\"))\nVAR_0->duration = VAR_7 * AV_TIME_BASE;",
"else if (!strcmp(VAR_3, \"videodatarate\") && vcodec &&\n0 <= (int)(VAR_7 * 1024.0))\nvcodec->bit_rate = VAR_7 * 1024.0;",
"else if (!strcmp(VAR_3, \"audiodatarate\") && acodec &&\n0 <= (int)(VAR_7 * 1024.0))\nacodec->bit_rate = VAR_7 * 1024.0;",
"else if (!strcmp(VAR_3, \"datastream\")) {",
"AVStream *st = create_stream(VAR_0, AVMEDIA_TYPE_DATA);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->codec->codec_id = AV_CODEC_ID_TEXT;",
"} else if (flv->trust_metadata) {",
"if (!strcmp(VAR_3, \"videocodecid\") && vcodec) {",
"flv_set_video_codec(VAR_0, VAR_2, VAR_7, 0);",
"} else if (!strcmp(VAR_3, \"audiocodecid\") && acodec) {",
"int VAR_10 = ((int)VAR_7) << FLV_AUDIO_CODECID_OFFSET;",
"flv_set_audio_codec(VAR_0, VAR_1, acodec, VAR_10);",
"} else if (!strcmp(VAR_3, \"audiosamplerate\") && acodec) {",
"acodec->sample_rate = VAR_7;",
"} else if (!strcmp(VAR_3, \"audiosamplesize\") && acodec) {",
"acodec->bits_per_coded_sample = VAR_7;",
"} else if (!strcmp(VAR_3, \"stereo\") && acodec) {",
"acodec->channels = VAR_7 + 1;",
"acodec->channel_layout = acodec->channels == 2 ?\nAV_CH_LAYOUT_STEREO :\nAV_CH_LAYOUT_MONO;",
"} else if (!strcmp(VAR_3, \"width\") && vcodec) {",
"vcodec->width = VAR_7;",
"} else if (!strcmp(VAR_3, \"height\") && vcodec) {",
"vcodec->height = VAR_7;",
"}",
"}",
"}",
"if (!strcmp(VAR_3, \"duration\") ||\n!strcmp(VAR_3, \"filesize\") ||\n!strcmp(VAR_3, \"width\") ||\n!strcmp(VAR_3, \"height\") ||\n!strcmp(VAR_3, \"videodatarate\") ||\n!strcmp(VAR_3, \"framerate\") ||\n!strcmp(VAR_3, \"videocodecid\") ||\n!strcmp(VAR_3, \"audiodatarate\") ||\n!strcmp(VAR_3, \"audiosamplerate\") ||\n!strcmp(VAR_3, \"audiosamplesize\") ||\n!strcmp(VAR_3, \"stereo\") ||\n!strcmp(VAR_3, \"audiocodecid\") ||\n!strcmp(VAR_3, \"datastream\"))\nreturn 0;",
"if (amf_type == AMF_DATA_TYPE_BOOL) {",
"av_strlcpy(VAR_6, VAR_7 > 0 ? \"true\" : \"false\",\nsizeof(VAR_6));",
"av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);",
"} else if (amf_type == AMF_DATA_TYPE_NUMBER) {",
"snprintf(VAR_6, sizeof(VAR_6), \"%.f\", VAR_7);",
"av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);",
"} else if (amf_type == AMF_DATA_TYPE_STRING)",
"av_dict_set(&VAR_0->metadata, VAR_3, VAR_6, 0);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47,
49
],
[
51
],
[
53,
55,
57,
59,
61,
63
],
[
67,
69,
71,
73,
75
],
[
77,
79
],
[
81
],
[
83,
85,
87,
89
],
[
91,
93
],
[
95,
97,
103,
105,
107
],
[
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
153
],
[
155
],
[
157
],
[
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,
251,
253,
255,
257,
259,
261,
263
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
]
] |
23,261 | static int check(AVIOContext *pb, int64_t pos, int64_t *out_pos)
{
MPADecodeHeader mh = { 0 };
int i;
uint32_t header;
int64_t off = 0;
for (i = 0; i < SEEK_PACKETS; i++) {
off = avio_seek(pb, pos + mh.frame_size, SEEK_SET);
if (off < 0)
break;
header = avio_rb32(pb);
if (ff_mpa_check_header(header) < 0 ||
avpriv_mpegaudio_decode_header(&mh, header))
break;
out_pos[i] = off;
}
return i;
}
| false | FFmpeg | 955aec3c7c7be39b659197e1ec379a09f2b7c41c | static int check(AVIOContext *pb, int64_t pos, int64_t *out_pos)
{
MPADecodeHeader mh = { 0 };
int i;
uint32_t header;
int64_t off = 0;
for (i = 0; i < SEEK_PACKETS; i++) {
off = avio_seek(pb, pos + mh.frame_size, SEEK_SET);
if (off < 0)
break;
header = avio_rb32(pb);
if (ff_mpa_check_header(header) < 0 ||
avpriv_mpegaudio_decode_header(&mh, header))
break;
out_pos[i] = off;
}
return i;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVIOContext *VAR_0, int64_t VAR_1, int64_t *VAR_2)
{
MPADecodeHeader mh = { 0 };
int VAR_3;
uint32_t header;
int64_t off = 0;
for (VAR_3 = 0; VAR_3 < SEEK_PACKETS; VAR_3++) {
off = avio_seek(VAR_0, VAR_1 + mh.frame_size, SEEK_SET);
if (off < 0)
break;
header = avio_rb32(VAR_0);
if (ff_mpa_check_header(header) < 0 ||
avpriv_mpegaudio_decode_header(&mh, header))
break;
VAR_2[VAR_3] = off;
}
return VAR_3;
}
| [
"static int FUNC_0(AVIOContext *VAR_0, int64_t VAR_1, int64_t *VAR_2)\n{",
"MPADecodeHeader mh = { 0 };",
"int VAR_3;",
"uint32_t header;",
"int64_t off = 0;",
"for (VAR_3 = 0; VAR_3 < SEEK_PACKETS; VAR_3++) {",
"off = avio_seek(VAR_0, VAR_1 + mh.frame_size, SEEK_SET);",
"if (off < 0)\nbreak;",
"header = avio_rb32(VAR_0);",
"if (ff_mpa_check_header(header) < 0 ||\navpriv_mpegaudio_decode_header(&mh, header))\nbreak;",
"VAR_2[VAR_3] = off;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21,
23
],
[
27
],
[
31,
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
]
] |
23,262 | int av_read_play(AVFormatContext *s)
{
if (s->iformat->read_play)
return s->iformat->read_play(s);
if (s->pb && s->pb->read_pause)
return av_url_read_fpause(s->pb, 0);
return AVERROR(ENOSYS);
}
| false | FFmpeg | fd2982a0a01942091b2f08e17486ff4562f675a6 | int av_read_play(AVFormatContext *s)
{
if (s->iformat->read_play)
return s->iformat->read_play(s);
if (s->pb && s->pb->read_pause)
return av_url_read_fpause(s->pb, 0);
return AVERROR(ENOSYS);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0)
{
if (VAR_0->iformat->read_play)
return VAR_0->iformat->read_play(VAR_0);
if (VAR_0->pb && VAR_0->pb->read_pause)
return av_url_read_fpause(VAR_0->pb, 0);
return AVERROR(ENOSYS);
}
| [
"int FUNC_0(AVFormatContext *VAR_0)\n{",
"if (VAR_0->iformat->read_play)\nreturn VAR_0->iformat->read_play(VAR_0);",
"if (VAR_0->pb && VAR_0->pb->read_pause)\nreturn av_url_read_fpause(VAR_0->pb, 0);",
"return AVERROR(ENOSYS);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
]
] |
23,264 | int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
HEVCNAL *nal)
{
int i, si, di;
uint8_t *dst;
if (s)
nal->skipped_bytes = 0;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
/* startcode, so we must be past the end */ \
length = i; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
i--; \
while (src[i]) \
i++
#if HAVE_FAST_64BIT
for (i = 0; i + 1 < length; i += 9) {
if (!((~AV_RN64A(src + i) &
(AV_RN64A(src + i) - 0x0100010001000101ULL)) &
0x8000800080008080ULL))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 7;
}
#else
for (i = 0; i + 1 < length; i += 5) {
if (!((~AV_RN32A(src + i) &
(AV_RN32A(src + i) - 0x01000101U)) &
0x80008080U))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 3;
}
#endif /* HAVE_FAST_64BIT */
#else
for (i = 0; i + 1 < length; i += 2) {
if (src[i])
continue;
if (i > 0 && src[i - 1] == 0)
i--;
STARTCODE_TEST;
}
#endif /* HAVE_FAST_UNALIGNED */
if (i >= length - 1) { // no escaped 0
nal->data =
nal->raw_data = src;
nal->size =
nal->raw_size = length;
return length;
}
av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size,
length + AV_INPUT_BUFFER_PADDING_SIZE);
if (!nal->rbsp_buffer)
return AVERROR(ENOMEM);
dst = nal->rbsp_buffer;
memcpy(dst, src, i);
si = di = i;
while (si + 2 < length) {
// remove escapes (very rare 1:2^22)
if (src[si + 2] > 3) {
dst[di++] = src[si++];
dst[di++] = src[si++];
} else if (src[si] == 0 && src[si + 1] == 0) {
if (src[si + 2] == 3) { // escape
dst[di++] = 0;
dst[di++] = 0;
si += 3;
if (s && nal->skipped_bytes_pos) {
nal->skipped_bytes++;
if (nal->skipped_bytes_pos_size < nal->skipped_bytes) {
nal->skipped_bytes_pos_size *= 2;
av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes);
av_reallocp_array(&nal->skipped_bytes_pos,
nal->skipped_bytes_pos_size,
sizeof(*nal->skipped_bytes_pos));
if (!nal->skipped_bytes_pos) {
nal->skipped_bytes_pos_size = 0;
return AVERROR(ENOMEM);
}
}
if (nal->skipped_bytes_pos)
nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1;
}
continue;
} else // next start code
goto nsc;
}
dst[di++] = src[si++];
}
while (si < length)
dst[di++] = src[si++];
nsc:
memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE);
nal->data = dst;
nal->size = di;
nal->raw_data = src;
nal->raw_size = si;
return si;
}
| false | FFmpeg | 4791a910c0dc3dd5861d38202457c9fb9bf1154c | int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
HEVCNAL *nal)
{
int i, si, di;
uint8_t *dst;
if (s)
nal->skipped_bytes = 0;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
\
length = i; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
i--; \
while (src[i]) \
i++
#if HAVE_FAST_64BIT
for (i = 0; i + 1 < length; i += 9) {
if (!((~AV_RN64A(src + i) &
(AV_RN64A(src + i) - 0x0100010001000101ULL)) &
0x8000800080008080ULL))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 7;
}
#else
for (i = 0; i + 1 < length; i += 5) {
if (!((~AV_RN32A(src + i) &
(AV_RN32A(src + i) - 0x01000101U)) &
0x80008080U))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 3;
}
#endif
#else
for (i = 0; i + 1 < length; i += 2) {
if (src[i])
continue;
if (i > 0 && src[i - 1] == 0)
i--;
STARTCODE_TEST;
}
#endif
if (i >= length - 1) {
nal->data =
nal->raw_data = src;
nal->size =
nal->raw_size = length;
return length;
}
av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size,
length + AV_INPUT_BUFFER_PADDING_SIZE);
if (!nal->rbsp_buffer)
return AVERROR(ENOMEM);
dst = nal->rbsp_buffer;
memcpy(dst, src, i);
si = di = i;
while (si + 2 < length) {
if (src[si + 2] > 3) {
dst[di++] = src[si++];
dst[di++] = src[si++];
} else if (src[si] == 0 && src[si + 1] == 0) {
if (src[si + 2] == 3) {
dst[di++] = 0;
dst[di++] = 0;
si += 3;
if (s && nal->skipped_bytes_pos) {
nal->skipped_bytes++;
if (nal->skipped_bytes_pos_size < nal->skipped_bytes) {
nal->skipped_bytes_pos_size *= 2;
av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes);
av_reallocp_array(&nal->skipped_bytes_pos,
nal->skipped_bytes_pos_size,
sizeof(*nal->skipped_bytes_pos));
if (!nal->skipped_bytes_pos) {
nal->skipped_bytes_pos_size = 0;
return AVERROR(ENOMEM);
}
}
if (nal->skipped_bytes_pos)
nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1;
}
continue;
} else
goto nsc;
}
dst[di++] = src[si++];
}
while (si < length)
dst[di++] = src[si++];
nsc:
memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE);
nal->data = dst;
nal->size = di;
nal->raw_data = src;
nal->raw_size = si;
return si;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2,
HEVCNAL *VAR_3)
{
int VAR_4, VAR_5, VAR_6;
uint8_t *dst;
if (VAR_0)
VAR_3->skipped_bytes = 0;
#define STARTCODE_TEST \
if (VAR_4 + 2 < VAR_2 && VAR_1[VAR_4 + 1] == 0 && VAR_1[VAR_4 + 2] <= 3) { \
if (VAR_1[VAR_4 + 2] != 3) { \
\
VAR_2 = VAR_4; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (VAR_4 > 0 && !VAR_1[VAR_4]) \
VAR_4--; \
while (VAR_1[VAR_4]) \
VAR_4++
#if HAVE_FAST_64BIT
for (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 9) {
if (!((~AV_RN64A(VAR_1 + VAR_4) &
(AV_RN64A(VAR_1 + VAR_4) - 0x0100010001000101ULL)) &
0x8000800080008080ULL))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
VAR_4 -= 7;
}
#else
for (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 5) {
if (!((~AV_RN32A(VAR_1 + VAR_4) &
(AV_RN32A(VAR_1 + VAR_4) - 0x01000101U)) &
0x80008080U))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
VAR_4 -= 3;
}
#endif
#else
for (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 2) {
if (VAR_1[VAR_4])
continue;
if (VAR_4 > 0 && VAR_1[VAR_4 - 1] == 0)
VAR_4--;
STARTCODE_TEST;
}
#endif
if (VAR_4 >= VAR_2 - 1) {
VAR_3->data =
VAR_3->raw_data = VAR_1;
VAR_3->size =
VAR_3->raw_size = VAR_2;
return VAR_2;
}
av_fast_malloc(&VAR_3->rbsp_buffer, &VAR_3->rbsp_buffer_size,
VAR_2 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!VAR_3->rbsp_buffer)
return AVERROR(ENOMEM);
dst = VAR_3->rbsp_buffer;
memcpy(dst, VAR_1, VAR_4);
VAR_5 = VAR_6 = VAR_4;
while (VAR_5 + 2 < VAR_2) {
if (VAR_1[VAR_5 + 2] > 3) {
dst[VAR_6++] = VAR_1[VAR_5++];
dst[VAR_6++] = VAR_1[VAR_5++];
} else if (VAR_1[VAR_5] == 0 && VAR_1[VAR_5 + 1] == 0) {
if (VAR_1[VAR_5 + 2] == 3) {
dst[VAR_6++] = 0;
dst[VAR_6++] = 0;
VAR_5 += 3;
if (VAR_0 && VAR_3->skipped_bytes_pos) {
VAR_3->skipped_bytes++;
if (VAR_3->skipped_bytes_pos_size < VAR_3->skipped_bytes) {
VAR_3->skipped_bytes_pos_size *= 2;
av_assert0(VAR_3->skipped_bytes_pos_size >= VAR_3->skipped_bytes);
av_reallocp_array(&VAR_3->skipped_bytes_pos,
VAR_3->skipped_bytes_pos_size,
sizeof(*VAR_3->skipped_bytes_pos));
if (!VAR_3->skipped_bytes_pos) {
VAR_3->skipped_bytes_pos_size = 0;
return AVERROR(ENOMEM);
}
}
if (VAR_3->skipped_bytes_pos)
VAR_3->skipped_bytes_pos[VAR_3->skipped_bytes-1] = VAR_6 - 1;
}
continue;
} else
goto nsc;
}
dst[VAR_6++] = VAR_1[VAR_5++];
}
while (VAR_5 < VAR_2)
dst[VAR_6++] = VAR_1[VAR_5++];
nsc:
memset(dst + VAR_6, 0, AV_INPUT_BUFFER_PADDING_SIZE);
VAR_3->data = dst;
VAR_3->size = VAR_6;
VAR_3->raw_data = VAR_1;
VAR_3->raw_size = VAR_5;
return VAR_5;
}
| [
"int FUNC_0(HEVCContext *VAR_0, const uint8_t *VAR_1, int VAR_2,\nHEVCNAL *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6;",
"uint8_t *dst;",
"if (VAR_0)\nVAR_3->skipped_bytes = 0;",
"#define STARTCODE_TEST \\\nif (VAR_4 + 2 < VAR_2 && VAR_1[VAR_4 + 1] == 0 && VAR_1[VAR_4 + 2] <= 3) { \\",
"if (VAR_1[VAR_4 + 2] != 3) { \\",
"\\\nVAR_2 = VAR_4; \\",
"} \\",
"break; \\",
"}",
"#if HAVE_FAST_UNALIGNED\n#define FIND_FIRST_ZERO \\\nif (VAR_4 > 0 && !VAR_1[VAR_4]) \\\nVAR_4--; \\",
"while (VAR_1[VAR_4]) \\\nVAR_4++\n#if HAVE_FAST_64BIT\nfor (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 9) {",
"if (!((~AV_RN64A(VAR_1 + VAR_4) &\n(AV_RN64A(VAR_1 + VAR_4) - 0x0100010001000101ULL)) &\n0x8000800080008080ULL))\ncontinue;",
"FIND_FIRST_ZERO;",
"STARTCODE_TEST;",
"VAR_4 -= 7;",
"}",
"#else\nfor (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 5) {",
"if (!((~AV_RN32A(VAR_1 + VAR_4) &\n(AV_RN32A(VAR_1 + VAR_4) - 0x01000101U)) &\n0x80008080U))\ncontinue;",
"FIND_FIRST_ZERO;",
"STARTCODE_TEST;",
"VAR_4 -= 3;",
"}",
"#endif\n#else\nfor (VAR_4 = 0; VAR_4 + 1 < VAR_2; VAR_4 += 2) {",
"if (VAR_1[VAR_4])\ncontinue;",
"if (VAR_4 > 0 && VAR_1[VAR_4 - 1] == 0)\nVAR_4--;",
"STARTCODE_TEST;",
"}",
"#endif\nif (VAR_4 >= VAR_2 - 1) {",
"VAR_3->data =\nVAR_3->raw_data = VAR_1;",
"VAR_3->size =\nVAR_3->raw_size = VAR_2;",
"return VAR_2;",
"}",
"av_fast_malloc(&VAR_3->rbsp_buffer, &VAR_3->rbsp_buffer_size,\nVAR_2 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (!VAR_3->rbsp_buffer)\nreturn AVERROR(ENOMEM);",
"dst = VAR_3->rbsp_buffer;",
"memcpy(dst, VAR_1, VAR_4);",
"VAR_5 = VAR_6 = VAR_4;",
"while (VAR_5 + 2 < VAR_2) {",
"if (VAR_1[VAR_5 + 2] > 3) {",
"dst[VAR_6++] = VAR_1[VAR_5++];",
"dst[VAR_6++] = VAR_1[VAR_5++];",
"} else if (VAR_1[VAR_5] == 0 && VAR_1[VAR_5 + 1] == 0) {",
"if (VAR_1[VAR_5 + 2] == 3) {",
"dst[VAR_6++] = 0;",
"dst[VAR_6++] = 0;",
"VAR_5 += 3;",
"if (VAR_0 && VAR_3->skipped_bytes_pos) {",
"VAR_3->skipped_bytes++;",
"if (VAR_3->skipped_bytes_pos_size < VAR_3->skipped_bytes) {",
"VAR_3->skipped_bytes_pos_size *= 2;",
"av_assert0(VAR_3->skipped_bytes_pos_size >= VAR_3->skipped_bytes);",
"av_reallocp_array(&VAR_3->skipped_bytes_pos,\nVAR_3->skipped_bytes_pos_size,\nsizeof(*VAR_3->skipped_bytes_pos));",
"if (!VAR_3->skipped_bytes_pos) {",
"VAR_3->skipped_bytes_pos_size = 0;",
"return AVERROR(ENOMEM);",
"}",
"}",
"if (VAR_3->skipped_bytes_pos)\nVAR_3->skipped_bytes_pos[VAR_3->skipped_bytes-1] = VAR_6 - 1;",
"}",
"continue;",
"} else",
"goto nsc;",
"}",
"dst[VAR_6++] = VAR_1[VAR_5++];",
"}",
"while (VAR_5 < VAR_2)\ndst[VAR_6++] = VAR_1[VAR_5++];",
"nsc:\nmemset(dst + VAR_6, 0, AV_INPUT_BUFFER_PADDING_SIZE);",
"VAR_3->data = dst;",
"VAR_3->size = VAR_6;",
"VAR_3->raw_data = VAR_1;",
"VAR_3->raw_size = VAR_5;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37,
39
],
[
41,
43,
45,
47
],
[
49,
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69,
71,
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87,
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103,
107
],
[
109,
111
],
[
113,
115
],
[
117
],
[
119
],
[
123,
125
],
[
127,
129
],
[
133
],
[
137
],
[
139
],
[
141
],
[
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
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209,
211
],
[
215,
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
]
] |
23,265 | static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i, j;
int ret;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
double *dp;
if (end_buf - buf < 12)
return -1;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4) {
buf -= 4;
} else {
buf = start + off;
}
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return -1;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n");
return -1;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return -1;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");
return AVERROR_PATCHWELCOME;
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return -1;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return -1;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
j = 0xff << 24;
j |= (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8;
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
if (ret = add_metadata(&buf, count, type, name, sep, s) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return ret;\
}
case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(count, "ModelPixelScaleTag", NULL);
break;
case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(count, "ModelTransformationTag", NULL);
break;
case TIFF_MODEL_TIEPOINT:
ADD_METADATA(count, "ModelTiepointTag", NULL);
break;
case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL);
ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");
s->geotag_count = tget_short(&buf, s->le);
if (s->geotag_count > count / 4 - 1) {
s->geotag_count = count / 4 - 1;
av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
}
s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < s->geotag_count; i++) {
s->geotags[i].key = tget_short(&buf, s->le);
s->geotags[i].type = tget_short(&buf, s->le);
s->geotags[i].count = tget_short(&buf, s->le);
if (!s->geotags[i].type)
s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&buf, s->le));
else
s->geotags[i].offset = tget_short(&buf, s->le);
}
break;
case TIFF_GEO_DOUBLE_PARAMS:
dp = av_malloc(count * sizeof(double));
if (!dp) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < count; i++)
dp[i] = tget_double(&buf, s->le);
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
av_freep(&dp);
return AVERROR(ENOMEM);
}
s->geotags[i].val = ap;
}
}
}
av_freep(&dp);
break;
case TIFF_GEO_ASCII_PARAMS:
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = av_malloc(s->geotags[i].count);
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
memcpy(ap, &buf[s->geotags[i].offset], s->geotags[i].count);
ap[s->geotags[i].count - 1] = '\0'; //replace the "|" delimiter with a 0 byte
s->geotags[i].val = ap;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
}
return 0;
}
| false | FFmpeg | 1ec83d9a9e472f485897ac92bad9631d551a8c5b | static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i, j;
int ret;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
double *dp;
if (end_buf - buf < 12)
return -1;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4) {
buf -= 4;
} else {
buf = start + off;
}
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return -1;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n");
return -1;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return -1;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");
return AVERROR_PATCHWELCOME;
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return -1;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return -1;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
j = 0xff << 24;
j |= (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8;
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
if (ret = add_metadata(&buf, count, type, name, sep, s) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return ret;\
}
case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(count, "ModelPixelScaleTag", NULL);
break;
case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(count, "ModelTransformationTag", NULL);
break;
case TIFF_MODEL_TIEPOINT:
ADD_METADATA(count, "ModelTiepointTag", NULL);
break;
case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL);
ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");
s->geotag_count = tget_short(&buf, s->le);
if (s->geotag_count > count / 4 - 1) {
s->geotag_count = count / 4 - 1;
av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
}
s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < s->geotag_count; i++) {
s->geotags[i].key = tget_short(&buf, s->le);
s->geotags[i].type = tget_short(&buf, s->le);
s->geotags[i].count = tget_short(&buf, s->le);
if (!s->geotags[i].type)
s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&buf, s->le));
else
s->geotags[i].offset = tget_short(&buf, s->le);
}
break;
case TIFF_GEO_DOUBLE_PARAMS:
dp = av_malloc(count * sizeof(double));
if (!dp) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < count; i++)
dp[i] = tget_double(&buf, s->le);
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
av_freep(&dp);
return AVERROR(ENOMEM);
}
s->geotags[i].val = ap;
}
}
}
av_freep(&dp);
break;
case TIFF_GEO_ASCII_PARAMS:
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = av_malloc(s->geotags[i].count);
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
memcpy(ap, &buf[s->geotags[i].offset], s->geotags[i].count);
ap[s->geotags[i].count - 1] = '\0';
s->geotags[i].val = ap;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, const uint8_t *VAR_3)
{
unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;
int VAR_9, VAR_10;
int VAR_11;
uint32_t *pal;
const uint8_t *VAR_12, *gp, *bp;
double *VAR_13;
if (VAR_3 - VAR_2 < 12)
return -1;
VAR_4 = tget_short(&VAR_2, VAR_0->le);
VAR_5 = tget_short(&VAR_2, VAR_0->le);
VAR_6 = tget_long(&VAR_2, VAR_0->le);
VAR_7 = tget_long(&VAR_2, VAR_0->le);
if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown tiff VAR_5 (%u) encountered\n",
VAR_5);
return 0;
}
if (VAR_6 == 1) {
switch (VAR_5) {
case TIFF_BYTE:
case TIFF_SHORT:
VAR_2 -= 4;
VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le);
VAR_2 = NULL;
break;
case TIFF_LONG:
VAR_8 = VAR_7;
VAR_2 = NULL;
break;
case TIFF_STRING:
if (VAR_6 <= 4) {
VAR_2 -= 4;
break;
}
default:
VAR_8 = UINT_MAX;
VAR_2 = VAR_1 + VAR_7;
}
} else {
if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4) {
VAR_2 -= 4;
} else {
VAR_2 = VAR_1 + VAR_7;
}
}
if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
switch (VAR_4) {
case TIFF_WIDTH:
VAR_0->width = VAR_8;
break;
case TIFF_HEIGHT:
VAR_0->height = VAR_8;
break;
case TIFF_BPP:
VAR_0->bppcount = VAR_6;
if (VAR_6 > 4) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
VAR_0->bpp, VAR_6);
return -1;
}
if (VAR_6 == 1)
VAR_0->bpp = VAR_8;
else {
switch (VAR_5) {
case TIFF_BYTE:
VAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +
((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
VAR_0->bpp = 0;
for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++)
VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le);
break;
default:
VAR_0->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (VAR_6 != 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single VAR_8, many provided\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->bppcount == 1)
VAR_0->bpp *= VAR_8;
VAR_0->bppcount = VAR_8;
break;
case TIFF_COMPR:
VAR_0->compr = VAR_8;
VAR_0->predictor = 0;
switch (VAR_0->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
VAR_0->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(VAR_0->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(VAR_0->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n");
return -1;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown compression method %VAR_9\n",
VAR_0->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)
VAR_8 = VAR_0->avctx->height;
if (VAR_8 < 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Incorrect VAR_8 of rows per strip\n");
return -1;
}
VAR_0->rps = VAR_8;
break;
case TIFF_STRIP_OFFS:
if (VAR_6 == 1) {
VAR_0->stripdata = NULL;
VAR_0->stripoff = VAR_8;
} else
VAR_0->stripdata = VAR_1 + VAR_7;
VAR_0->strips = VAR_6;
if (VAR_0->strips == 1)
VAR_0->rps = VAR_0->height;
VAR_0->sot = VAR_5;
if (VAR_0->stripdata > VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if (VAR_6 == 1) {
VAR_0->stripsizes = NULL;
VAR_0->stripsize = VAR_8;
VAR_0->strips = 1;
} else {
VAR_0->stripsizes = VAR_1 + VAR_7;
}
VAR_0->strips = VAR_6;
VAR_0->sstype = VAR_5;
if (VAR_0->stripsizes > VAR_3) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");
return AVERROR_PATCHWELCOME;
break;
case TIFF_PREDICTOR:
VAR_0->predictor = VAR_8;
break;
case TIFF_INVERT:
switch (VAR_8) {
case 0:
VAR_0->invert = 1;
break;
case 1:
VAR_0->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
VAR_8);
return -1;
}
break;
case TIFF_FILL_ORDER:
if (VAR_8 < 1 || VAR_8 > 2) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Unknown FillOrder VAR_8 %d, trying default one\n", VAR_8);
VAR_8 = 1;
}
VAR_0->fill_order = VAR_8 - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) VAR_0->palette;
VAR_7 = type_sizes[VAR_5];
if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)
return -1;
VAR_12 = VAR_2;
gp = VAR_2 + VAR_6 / 3 * VAR_7;
bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2;
VAR_7 = (type_sizes[VAR_5] - 1) << 3;
for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) {
VAR_10 = 0xff << 24;
VAR_10 |= (tget(&VAR_12, VAR_5, VAR_0->le) >> VAR_7) << 16;
VAR_10 |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8;
VAR_10 |= tget(&bp, VAR_5, VAR_0->le) >> VAR_7;
pal[VAR_9] = VAR_10;
}
VAR_0->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (VAR_8 == 2) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if (VAR_0->compr == TIFF_G3)
VAR_0->fax_opts = VAR_8;
break;
case TIFF_T6OPTIONS:
if (VAR_0->compr == TIFF_G4)
VAR_0->fax_opts = VAR_8;
break;
#define ADD_METADATA(VAR_6, name, sep)\
if (VAR_11 = add_metadata(&VAR_2, VAR_6, VAR_5, name, sep, VAR_0) < 0) {\
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return VAR_11;\
}
case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(VAR_6, "ModelPixelScaleTag", NULL);
break;
case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(VAR_6, "ModelTransformationTag", NULL);
break;
case TIFF_MODEL_TIEPOINT:
ADD_METADATA(VAR_6, "ModelTiepointTag", NULL);
break;
case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL);
ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");
VAR_0->geotag_count = tget_short(&VAR_2, VAR_0->le);
if (VAR_0->geotag_count > VAR_6 / 4 - 1) {
VAR_0->geotag_count = VAR_6 / 4 - 1;
av_log(VAR_0->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
}
VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count);
if (!VAR_0->geotags) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {
VAR_0->geotags[VAR_9].key = tget_short(&VAR_2, VAR_0->le);
VAR_0->geotags[VAR_9].VAR_5 = tget_short(&VAR_2, VAR_0->le);
VAR_0->geotags[VAR_9].VAR_6 = tget_short(&VAR_2, VAR_0->le);
if (!VAR_0->geotags[VAR_9].VAR_5)
VAR_0->geotags[VAR_9].val = get_geokey_val(VAR_0->geotags[VAR_9].key, tget_short(&VAR_2, VAR_0->le));
else
VAR_0->geotags[VAR_9].offset = tget_short(&VAR_2, VAR_0->le);
}
break;
case TIFF_GEO_DOUBLE_PARAMS:
VAR_13 = av_malloc(VAR_6 * sizeof(double));
if (!VAR_13) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++)
VAR_13[VAR_9] = tget_double(&VAR_2, VAR_0->le);
for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {
if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_DOUBLE_PARAMS) {
if (VAR_0->geotags[VAR_9].VAR_6 == 0
|| VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key);
} else {
char *ap = doubles2str(&VAR_13[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6, ", ");
if (!ap) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
av_freep(&VAR_13);
return AVERROR(ENOMEM);
}
VAR_0->geotags[VAR_9].val = ap;
}
}
}
av_freep(&VAR_13);
break;
case TIFF_GEO_ASCII_PARAMS:
for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {
if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_ASCII_PARAMS) {
if (VAR_0->geotags[VAR_9].VAR_6 == 0
|| VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", VAR_0->geotags[VAR_9].key);
} else {
char *ap = av_malloc(VAR_0->geotags[VAR_9].VAR_6);
if (!ap) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
memcpy(ap, &VAR_2[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6);
ap[VAR_0->geotags[VAR_9].VAR_6 - 1] = '\0';
VAR_0->geotags[VAR_9].val = ap;
}
}
}
break;
default:
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Unknown or unsupported VAR_4 %d/0X%0X\n",
VAR_4, VAR_4);
}
return 0;
}
| [
"static int FUNC_0(TiffContext *VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2, const uint8_t *VAR_3)\n{",
"unsigned VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;",
"int VAR_9, VAR_10;",
"int VAR_11;",
"uint32_t *pal;",
"const uint8_t *VAR_12, *gp, *bp;",
"double *VAR_13;",
"if (VAR_3 - VAR_2 < 12)\nreturn -1;",
"VAR_4 = tget_short(&VAR_2, VAR_0->le);",
"VAR_5 = tget_short(&VAR_2, VAR_0->le);",
"VAR_6 = tget_long(&VAR_2, VAR_0->le);",
"VAR_7 = tget_long(&VAR_2, VAR_0->le);",
"if (VAR_5 == 0 || VAR_5 >= FF_ARRAY_ELEMS(type_sizes)) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Unknown tiff VAR_5 (%u) encountered\\n\",\nVAR_5);",
"return 0;",
"}",
"if (VAR_6 == 1) {",
"switch (VAR_5) {",
"case TIFF_BYTE:\ncase TIFF_SHORT:\nVAR_2 -= 4;",
"VAR_8 = tget(&VAR_2, VAR_5, VAR_0->le);",
"VAR_2 = NULL;",
"break;",
"case TIFF_LONG:\nVAR_8 = VAR_7;",
"VAR_2 = NULL;",
"break;",
"case TIFF_STRING:\nif (VAR_6 <= 4) {",
"VAR_2 -= 4;",
"break;",
"}",
"default:\nVAR_8 = UINT_MAX;",
"VAR_2 = VAR_1 + VAR_7;",
"}",
"} else {",
"if (VAR_6 <= 4 && type_sizes[VAR_5] * VAR_6 <= 4) {",
"VAR_2 -= 4;",
"} else {",
"VAR_2 = VAR_1 + VAR_7;",
"}",
"}",
"if (VAR_2 && (VAR_2 < VAR_1 || VAR_2 > VAR_3)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return -1;",
"}",
"switch (VAR_4) {",
"case TIFF_WIDTH:\nVAR_0->width = VAR_8;",
"break;",
"case TIFF_HEIGHT:\nVAR_0->height = VAR_8;",
"break;",
"case TIFF_BPP:\nVAR_0->bppcount = VAR_6;",
"if (VAR_6 > 4) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"This format is not supported (bpp=%d, %d components)\\n\",\nVAR_0->bpp, VAR_6);",
"return -1;",
"}",
"if (VAR_6 == 1)\nVAR_0->bpp = VAR_8;",
"else {",
"switch (VAR_5) {",
"case TIFF_BYTE:\nVAR_0->bpp = (VAR_7 & 0xFF) + ((VAR_7 >> 8) & 0xFF) +\n((VAR_7 >> 16) & 0xFF) + ((VAR_7 >> 24) & 0xFF);",
"break;",
"case TIFF_SHORT:\ncase TIFF_LONG:\nVAR_0->bpp = 0;",
"for (VAR_9 = 0; VAR_9 < VAR_6 && VAR_2 < VAR_3; VAR_9++)",
"VAR_0->bpp += tget(&VAR_2, VAR_5, VAR_0->le);",
"break;",
"default:\nVAR_0->bpp = -1;",
"}",
"}",
"break;",
"case TIFF_SAMPLES_PER_PIXEL:\nif (VAR_6 != 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Samples per pixel requires a single VAR_8, many provided\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->bppcount == 1)\nVAR_0->bpp *= VAR_8;",
"VAR_0->bppcount = VAR_8;",
"break;",
"case TIFF_COMPR:\nVAR_0->compr = VAR_8;",
"VAR_0->predictor = 0;",
"switch (VAR_0->compr) {",
"case TIFF_RAW:\ncase TIFF_PACKBITS:\ncase TIFF_LZW:\ncase TIFF_CCITT_RLE:\nbreak;",
"case TIFF_G3:\ncase TIFF_G4:\nVAR_0->fax_opts = 0;",
"break;",
"case TIFF_DEFLATE:\ncase TIFF_ADOBE_DEFLATE:\n#if CONFIG_ZLIB\nbreak;",
"#else\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Deflate: ZLib not compiled in\\n\");",
"return -1;",
"#endif\ncase TIFF_JPEG:\ncase TIFF_NEWJPEG:\nav_log(VAR_0->avctx, AV_LOG_ERROR,\n\"JPEG compression is not supported\\n\");",
"return -1;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown compression method %VAR_9\\n\",\nVAR_0->compr);",
"return -1;",
"}",
"break;",
"case TIFF_ROWSPERSTRIP:\nif (VAR_5 == TIFF_LONG && VAR_8 == UINT_MAX)\nVAR_8 = VAR_0->avctx->height;",
"if (VAR_8 < 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Incorrect VAR_8 of rows per strip\\n\");",
"return -1;",
"}",
"VAR_0->rps = VAR_8;",
"break;",
"case TIFF_STRIP_OFFS:\nif (VAR_6 == 1) {",
"VAR_0->stripdata = NULL;",
"VAR_0->stripoff = VAR_8;",
"} else",
"VAR_0->stripdata = VAR_1 + VAR_7;",
"VAR_0->strips = VAR_6;",
"if (VAR_0->strips == 1)\nVAR_0->rps = VAR_0->height;",
"VAR_0->sot = VAR_5;",
"if (VAR_0->stripdata > VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return -1;",
"}",
"break;",
"case TIFF_STRIP_SIZE:\nif (VAR_6 == 1) {",
"VAR_0->stripsizes = NULL;",
"VAR_0->stripsize = VAR_8;",
"VAR_0->strips = 1;",
"} else {",
"VAR_0->stripsizes = VAR_1 + VAR_7;",
"}",
"VAR_0->strips = VAR_6;",
"VAR_0->sstype = VAR_5;",
"if (VAR_0->stripsizes > VAR_3) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Tag referencing position outside the image\\n\");",
"return -1;",
"}",
"break;",
"case TIFF_TILE_BYTE_COUNTS:\ncase TIFF_TILE_LENGTH:\ncase TIFF_TILE_OFFSETS:\ncase TIFF_TILE_WIDTH:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Tiled images are not supported\\n\");",
"return AVERROR_PATCHWELCOME;",
"break;",
"case TIFF_PREDICTOR:\nVAR_0->predictor = VAR_8;",
"break;",
"case TIFF_INVERT:\nswitch (VAR_8) {",
"case 0:\nVAR_0->invert = 1;",
"break;",
"case 1:\nVAR_0->invert = 0;",
"break;",
"case 2:\ncase 3:\nbreak;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Color mode %d is not supported\\n\",\nVAR_8);",
"return -1;",
"}",
"break;",
"case TIFF_FILL_ORDER:\nif (VAR_8 < 1 || VAR_8 > 2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Unknown FillOrder VAR_8 %d, trying default one\\n\", VAR_8);",
"VAR_8 = 1;",
"}",
"VAR_0->fill_order = VAR_8 - 1;",
"break;",
"case TIFF_PAL:\npal = (uint32_t *) VAR_0->palette;",
"VAR_7 = type_sizes[VAR_5];",
"if (VAR_6 / 3 > 256 || VAR_3 - VAR_2 < VAR_6 / 3 * VAR_7 * 3)\nreturn -1;",
"VAR_12 = VAR_2;",
"gp = VAR_2 + VAR_6 / 3 * VAR_7;",
"bp = VAR_2 + VAR_6 / 3 * VAR_7 * 2;",
"VAR_7 = (type_sizes[VAR_5] - 1) << 3;",
"for (VAR_9 = 0; VAR_9 < VAR_6 / 3; VAR_9++) {",
"VAR_10 = 0xff << 24;",
"VAR_10 |= (tget(&VAR_12, VAR_5, VAR_0->le) >> VAR_7) << 16;",
"VAR_10 |= (tget(&gp, VAR_5, VAR_0->le) >> VAR_7) << 8;",
"VAR_10 |= tget(&bp, VAR_5, VAR_0->le) >> VAR_7;",
"pal[VAR_9] = VAR_10;",
"}",
"VAR_0->palette_is_set = 1;",
"break;",
"case TIFF_PLANAR:\nif (VAR_8 == 2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Planar format is not supported\\n\");",
"return -1;",
"}",
"break;",
"case TIFF_T4OPTIONS:\nif (VAR_0->compr == TIFF_G3)\nVAR_0->fax_opts = VAR_8;",
"break;",
"case TIFF_T6OPTIONS:\nif (VAR_0->compr == TIFF_G4)\nVAR_0->fax_opts = VAR_8;",
"break;",
"#define ADD_METADATA(VAR_6, name, sep)\\\nif (VAR_11 = add_metadata(&VAR_2, VAR_6, VAR_5, name, sep, VAR_0) < 0) {\\",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");\\",
"return VAR_11;\\",
"}",
"case TIFF_MODEL_PIXEL_SCALE:\nADD_METADATA(VAR_6, \"ModelPixelScaleTag\", NULL);",
"break;",
"case TIFF_MODEL_TRANSFORMATION:\nADD_METADATA(VAR_6, \"ModelTransformationTag\", NULL);",
"break;",
"case TIFF_MODEL_TIEPOINT:\nADD_METADATA(VAR_6, \"ModelTiepointTag\", NULL);",
"break;",
"case TIFF_GEO_KEY_DIRECTORY:\nADD_METADATA(1, \"GeoTIFF_Version\", NULL);",
"ADD_METADATA(2, \"GeoTIFF_Key_Revision\", \".\");",
"VAR_0->geotag_count = tget_short(&VAR_2, VAR_0->le);",
"if (VAR_0->geotag_count > VAR_6 / 4 - 1) {",
"VAR_0->geotag_count = VAR_6 / 4 - 1;",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"GeoTIFF key directory buffer shorter than specified\\n\");",
"}",
"VAR_0->geotags = av_mallocz(sizeof(TiffGeoTag) * VAR_0->geotag_count);",
"if (!VAR_0->geotags) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {",
"VAR_0->geotags[VAR_9].key = tget_short(&VAR_2, VAR_0->le);",
"VAR_0->geotags[VAR_9].VAR_5 = tget_short(&VAR_2, VAR_0->le);",
"VAR_0->geotags[VAR_9].VAR_6 = tget_short(&VAR_2, VAR_0->le);",
"if (!VAR_0->geotags[VAR_9].VAR_5)\nVAR_0->geotags[VAR_9].val = get_geokey_val(VAR_0->geotags[VAR_9].key, tget_short(&VAR_2, VAR_0->le));",
"else\nVAR_0->geotags[VAR_9].offset = tget_short(&VAR_2, VAR_0->le);",
"}",
"break;",
"case TIFF_GEO_DOUBLE_PARAMS:\nVAR_13 = av_malloc(VAR_6 * sizeof(double));",
"if (!VAR_13) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++)",
"VAR_13[VAR_9] = tget_double(&VAR_2, VAR_0->le);",
"for (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {",
"if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_DOUBLE_PARAMS) {",
"if (VAR_0->geotags[VAR_9].VAR_6 == 0\n|| VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid GeoTIFF key %d\\n\", VAR_0->geotags[VAR_9].key);",
"} else {",
"char *ap = doubles2str(&VAR_13[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6, \", \");",
"if (!ap) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");",
"av_freep(&VAR_13);",
"return AVERROR(ENOMEM);",
"}",
"VAR_0->geotags[VAR_9].val = ap;",
"}",
"}",
"}",
"av_freep(&VAR_13);",
"break;",
"case TIFF_GEO_ASCII_PARAMS:\nfor (VAR_9 = 0; VAR_9 < VAR_0->geotag_count; VAR_9++) {",
"if (VAR_0->geotags[VAR_9].VAR_5 == TIFF_GEO_ASCII_PARAMS) {",
"if (VAR_0->geotags[VAR_9].VAR_6 == 0\n|| VAR_0->geotags[VAR_9].offset + VAR_0->geotags[VAR_9].VAR_6 > VAR_6) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid GeoTIFF key %d\\n\", VAR_0->geotags[VAR_9].key);",
"} else {",
"char *ap = av_malloc(VAR_0->geotags[VAR_9].VAR_6);",
"if (!ap) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating temporary buffer\\n\");",
"return AVERROR(ENOMEM);",
"}",
"memcpy(ap, &VAR_2[VAR_0->geotags[VAR_9].offset], VAR_0->geotags[VAR_9].VAR_6);",
"ap[VAR_0->geotags[VAR_9].VAR_6 - 1] = '\\0';",
"VAR_0->geotags[VAR_9].val = ap;",
"}",
"}",
"}",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"Unknown or unsupported VAR_4 %d/0X%0X\\n\",\nVAR_4, VAR_4);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
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
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
117
],
[
119,
121
],
[
123
],
[
125,
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155,
157,
159
],
[
161
],
[
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
189,
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
213,
215,
217,
219,
221
],
[
223,
225,
227
],
[
229
],
[
231,
233,
235,
237
],
[
239,
241
],
[
243
],
[
245,
247,
249,
251,
253
],
[
255
],
[
257,
259,
261
],
[
263
],
[
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
311,
313
],
[
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343,
345
],
[
347
],
[
349
],
[
351
],
[
353,
355,
357,
359,
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
373,
375
],
[
377,
379
],
[
381
],
[
383,
385
],
[
387
],
[
389,
391,
393
],
[
395,
397,
399
],
[
401
],
[
403
],
[
405
],
[
407,
409
],
[
411,
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423,
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471,
473,
475
],
[
477
],
[
479,
481,
483
],
[
485
],
[
487,
489
],
[
491
],
[
493
],
[
495
],
[
497,
499
],
[
501
],
[
503,
505
],
[
507
],
[
509,
511
],
[
513
],
[
515,
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
551,
553
],
[
555,
557
],
[
559
],
[
561
],
[
563,
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615,
617
],
[
619
],
[
621,
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653,
655,
657
],
[
659
],
[
661
],
[
663
]
] |
23,266 | static int bit_allocation(IMCContext *q, IMCChannel *chctx,
int stream_format_code, int freebits, int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
int indx;
int t1 = 0;
int t2 = 1;
float summa = 0.0;
int iacc = 0;
int summer = 0;
int rres, cwlen;
float lowest = 1.e10;
int low_indx = 0;
float workT[32];
int flg;
int found_indx = 0;
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, chctx->flcoeffs1[i]);
for (i = 0; i < BANDS - 1; i++)
chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
chctx->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
for (i = 0; i < BANDS; i++) {
indx = -1;
if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
indx = 0;
if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
indx = 1;
if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
indx = 2;
if (indx == -1)
return AVERROR_INVALIDDATA;
chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
chctx->flcoeffs4[0] = limit;
chctx->flcoeffs4[1] = limit;
chctx->flcoeffs4[2] = limit;
chctx->flcoeffs4[3] = limit;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
iacc += chctx->bandWidthT[i];
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
}
if (!iacc)
return AVERROR_INVALIDDATA;
chctx->bandWidthT[BANDS - 1] = 0;
summa = (summa * 0.5 - freebits) / iacc;
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
chctx->bitsBandT[j] = cwlen;
summer += chctx->bandWidthT[j] * cwlen;
if (cwlen > 0)
iacc += chctx->bandWidthT[j];
}
flg = t2;
t2 = 1;
if (freebits < summer)
t2 = -1;
if (i == 0)
flg = t2;
if (flg != t2)
t1++;
summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
chctx->CWlengthT[j] = chctx->bitsBandT[i];
}
if (freebits > summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
: (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
}
highest = 0.0;
do {
if (highest <= -1.e20)
break;
found_indx = 0;
highest = -1.e20;
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
}
}
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++chctx->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
chctx->CWlengthT[j]++;
summer++;
}
}
} while (freebits > summer);
}
if (freebits < summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
workT[1] = 1.e20;
workT[2] = 1.e20;
workT[3] = 1.e20;
}
while (freebits < summer) {
lowest = 1.e10;
low_indx = 0;
for (i = 0; i < BANDS; i++) {
if (workT[i] < lowest) {
lowest = workT[i];
low_indx = i;
}
}
// if (lowest >= 1.e10)
// break;
workT[low_indx] = lowest + 2.0;
if (!--chctx->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
if (chctx->CWlengthT[j] > 0) {
chctx->CWlengthT[j]--;
summer--;
}
}
}
}
return 0;
}
| false | FFmpeg | 3e0c78bac63c213649c3e8c2fa49e9f3c9848d5a | static int bit_allocation(IMCContext *q, IMCChannel *chctx,
int stream_format_code, int freebits, int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
int indx;
int t1 = 0;
int t2 = 1;
float summa = 0.0;
int iacc = 0;
int summer = 0;
int rres, cwlen;
float lowest = 1.e10;
int low_indx = 0;
float workT[32];
int flg;
int found_indx = 0;
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, chctx->flcoeffs1[i]);
for (i = 0; i < BANDS - 1; i++)
chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
chctx->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
for (i = 0; i < BANDS; i++) {
indx = -1;
if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
indx = 0;
if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
indx = 1;
if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
indx = 2;
if (indx == -1)
return AVERROR_INVALIDDATA;
chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
chctx->flcoeffs4[0] = limit;
chctx->flcoeffs4[1] = limit;
chctx->flcoeffs4[2] = limit;
chctx->flcoeffs4[3] = limit;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
iacc += chctx->bandWidthT[i];
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
}
if (!iacc)
return AVERROR_INVALIDDATA;
chctx->bandWidthT[BANDS - 1] = 0;
summa = (summa * 0.5 - freebits) / iacc;
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
chctx->bitsBandT[j] = cwlen;
summer += chctx->bandWidthT[j] * cwlen;
if (cwlen > 0)
iacc += chctx->bandWidthT[j];
}
flg = t2;
t2 = 1;
if (freebits < summer)
t2 = -1;
if (i == 0)
flg = t2;
if (flg != t2)
t1++;
summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
chctx->CWlengthT[j] = chctx->bitsBandT[i];
}
if (freebits > summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
: (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
}
highest = 0.0;
do {
if (highest <= -1.e20)
break;
found_indx = 0;
highest = -1.e20;
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
}
}
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++chctx->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
chctx->CWlengthT[j]++;
summer++;
}
}
} while (freebits > summer);
}
if (freebits < summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
workT[1] = 1.e20;
workT[2] = 1.e20;
workT[3] = 1.e20;
}
while (freebits < summer) {
lowest = 1.e10;
low_indx = 0;
for (i = 0; i < BANDS; i++) {
if (workT[i] < lowest) {
lowest = workT[i];
low_indx = i;
}
}
workT[low_indx] = lowest + 2.0;
if (!--chctx->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
if (chctx->CWlengthT[j] > 0) {
chctx->CWlengthT[j]--;
summer--;
}
}
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(IMCContext *VAR_0, IMCChannel *VAR_1,
int VAR_2, int VAR_3, int VAR_4)
{
int VAR_5, VAR_6;
const float VAR_7 = -1.e20;
float VAR_8 = 0.0;
int VAR_9;
int VAR_10 = 0;
int VAR_11 = 1;
float VAR_12 = 0.0;
int VAR_13 = 0;
int VAR_14 = 0;
int VAR_15, VAR_16;
float VAR_17 = 1.e10;
int VAR_18 = 0;
float VAR_19[32];
int VAR_20;
int VAR_21 = 0;
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++)
VAR_8 = FFMAX(VAR_8, VAR_1->flcoeffs1[VAR_5]);
for (VAR_5 = 0; VAR_5 < BANDS - 1; VAR_5++)
VAR_1->flcoeffs4[VAR_5] = VAR_1->flcoeffs3[VAR_5] - log2f(VAR_1->flcoeffs5[VAR_5]);
VAR_1->flcoeffs4[BANDS - 1] = VAR_7;
VAR_8 = VAR_8 * 0.25;
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {
VAR_9 = -1;
if ((band_tab[VAR_5 + 1] - band_tab[VAR_5]) == VAR_1->bandWidthT[VAR_5])
VAR_9 = 0;
if ((band_tab[VAR_5 + 1] - band_tab[VAR_5]) > VAR_1->bandWidthT[VAR_5])
VAR_9 = 1;
if (((band_tab[VAR_5 + 1] - band_tab[VAR_5]) / 2) >= VAR_1->bandWidthT[VAR_5])
VAR_9 = 2;
if (VAR_9 == -1)
return AVERROR_INVALIDDATA;
VAR_1->flcoeffs4[VAR_5] += xTab[(VAR_9 * 2 + (VAR_1->flcoeffs1[VAR_5] < VAR_8)) * 2 + VAR_4];
}
if (VAR_2 & 0x2) {
VAR_1->flcoeffs4[0] = VAR_7;
VAR_1->flcoeffs4[1] = VAR_7;
VAR_1->flcoeffs4[2] = VAR_7;
VAR_1->flcoeffs4[3] = VAR_7;
}
for (VAR_5 = (VAR_2 & 0x2) ? 4 : 0; VAR_5 < BANDS - 1; VAR_5++) {
VAR_13 += VAR_1->bandWidthT[VAR_5];
VAR_12 += VAR_1->bandWidthT[VAR_5] * VAR_1->flcoeffs4[VAR_5];
}
if (!VAR_13)
return AVERROR_INVALIDDATA;
VAR_1->bandWidthT[BANDS - 1] = 0;
VAR_12 = (VAR_12 * 0.5 - VAR_3) / VAR_13;
for (VAR_5 = 0; VAR_5 < BANDS / 2; VAR_5++) {
VAR_15 = VAR_14 - VAR_3;
if ((VAR_15 >= -8) && (VAR_15 <= 8))
break;
VAR_14 = 0;
VAR_13 = 0;
for (VAR_6 = (VAR_2 & 0x2) ? 4 : 0; VAR_6 < BANDS; VAR_6++) {
VAR_16 = av_clipf(((VAR_1->flcoeffs4[VAR_6] * 0.5) - VAR_12 + 0.5), 0, 6);
VAR_1->bitsBandT[VAR_6] = VAR_16;
VAR_14 += VAR_1->bandWidthT[VAR_6] * VAR_16;
if (VAR_16 > 0)
VAR_13 += VAR_1->bandWidthT[VAR_6];
}
VAR_20 = VAR_11;
VAR_11 = 1;
if (VAR_3 < VAR_14)
VAR_11 = -1;
if (VAR_5 == 0)
VAR_20 = VAR_11;
if (VAR_20 != VAR_11)
VAR_10++;
VAR_12 = (float)(VAR_14 - VAR_3) / ((VAR_10 + 1) * VAR_13) + VAR_12;
}
for (VAR_5 = (VAR_2 & 0x2) ? 4 : 0; VAR_5 < BANDS; VAR_5++) {
for (VAR_6 = band_tab[VAR_5]; VAR_6 < band_tab[VAR_5 + 1]; VAR_6++)
VAR_1->CWlengthT[VAR_6] = VAR_1->bitsBandT[VAR_5];
}
if (VAR_3 > VAR_14) {
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {
VAR_19[VAR_5] = (VAR_1->bitsBandT[VAR_5] == 6) ? -1.e20
: (VAR_1->bitsBandT[VAR_5] * -2 + VAR_1->flcoeffs4[VAR_5] - 0.415);
}
VAR_8 = 0.0;
do {
if (VAR_8 <= -1.e20)
break;
VAR_21 = 0;
VAR_8 = -1.e20;
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {
if (VAR_19[VAR_5] > VAR_8) {
VAR_8 = VAR_19[VAR_5];
VAR_21 = VAR_5;
}
}
if (VAR_8 > -1.e20) {
VAR_19[VAR_21] -= 2.0;
if (++VAR_1->bitsBandT[VAR_21] == 6)
VAR_19[VAR_21] = -1.e20;
for (VAR_6 = band_tab[VAR_21]; VAR_6 < band_tab[VAR_21 + 1] && (VAR_3 > VAR_14); VAR_6++) {
VAR_1->CWlengthT[VAR_6]++;
VAR_14++;
}
}
} while (VAR_3 > VAR_14);
}
if (VAR_3 < VAR_14) {
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {
VAR_19[VAR_5] = VAR_1->bitsBandT[VAR_5] ? (VAR_1->bitsBandT[VAR_5] * -2 + VAR_1->flcoeffs4[VAR_5] + 1.585)
: 1.e20;
}
if (VAR_2 & 0x2) {
VAR_19[0] = 1.e20;
VAR_19[1] = 1.e20;
VAR_19[2] = 1.e20;
VAR_19[3] = 1.e20;
}
while (VAR_3 < VAR_14) {
VAR_17 = 1.e10;
VAR_18 = 0;
for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {
if (VAR_19[VAR_5] < VAR_17) {
VAR_17 = VAR_19[VAR_5];
VAR_18 = VAR_5;
}
}
VAR_19[VAR_18] = VAR_17 + 2.0;
if (!--VAR_1->bitsBandT[VAR_18])
VAR_19[VAR_18] = 1.e20;
for (VAR_6 = band_tab[VAR_18]; VAR_6 < band_tab[VAR_18+1] && (VAR_3 < VAR_14); VAR_6++) {
if (VAR_1->CWlengthT[VAR_6] > 0) {
VAR_1->CWlengthT[VAR_6]--;
VAR_14--;
}
}
}
}
return 0;
}
| [
"static int FUNC_0(IMCContext *VAR_0, IMCChannel *VAR_1,\nint VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6;",
"const float VAR_7 = -1.e20;",
"float VAR_8 = 0.0;",
"int VAR_9;",
"int VAR_10 = 0;",
"int VAR_11 = 1;",
"float VAR_12 = 0.0;",
"int VAR_13 = 0;",
"int VAR_14 = 0;",
"int VAR_15, VAR_16;",
"float VAR_17 = 1.e10;",
"int VAR_18 = 0;",
"float VAR_19[32];",
"int VAR_20;",
"int VAR_21 = 0;",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++)",
"VAR_8 = FFMAX(VAR_8, VAR_1->flcoeffs1[VAR_5]);",
"for (VAR_5 = 0; VAR_5 < BANDS - 1; VAR_5++)",
"VAR_1->flcoeffs4[VAR_5] = VAR_1->flcoeffs3[VAR_5] - log2f(VAR_1->flcoeffs5[VAR_5]);",
"VAR_1->flcoeffs4[BANDS - 1] = VAR_7;",
"VAR_8 = VAR_8 * 0.25;",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {",
"VAR_9 = -1;",
"if ((band_tab[VAR_5 + 1] - band_tab[VAR_5]) == VAR_1->bandWidthT[VAR_5])\nVAR_9 = 0;",
"if ((band_tab[VAR_5 + 1] - band_tab[VAR_5]) > VAR_1->bandWidthT[VAR_5])\nVAR_9 = 1;",
"if (((band_tab[VAR_5 + 1] - band_tab[VAR_5]) / 2) >= VAR_1->bandWidthT[VAR_5])\nVAR_9 = 2;",
"if (VAR_9 == -1)\nreturn AVERROR_INVALIDDATA;",
"VAR_1->flcoeffs4[VAR_5] += xTab[(VAR_9 * 2 + (VAR_1->flcoeffs1[VAR_5] < VAR_8)) * 2 + VAR_4];",
"}",
"if (VAR_2 & 0x2) {",
"VAR_1->flcoeffs4[0] = VAR_7;",
"VAR_1->flcoeffs4[1] = VAR_7;",
"VAR_1->flcoeffs4[2] = VAR_7;",
"VAR_1->flcoeffs4[3] = VAR_7;",
"}",
"for (VAR_5 = (VAR_2 & 0x2) ? 4 : 0; VAR_5 < BANDS - 1; VAR_5++) {",
"VAR_13 += VAR_1->bandWidthT[VAR_5];",
"VAR_12 += VAR_1->bandWidthT[VAR_5] * VAR_1->flcoeffs4[VAR_5];",
"}",
"if (!VAR_13)\nreturn AVERROR_INVALIDDATA;",
"VAR_1->bandWidthT[BANDS - 1] = 0;",
"VAR_12 = (VAR_12 * 0.5 - VAR_3) / VAR_13;",
"for (VAR_5 = 0; VAR_5 < BANDS / 2; VAR_5++) {",
"VAR_15 = VAR_14 - VAR_3;",
"if ((VAR_15 >= -8) && (VAR_15 <= 8))\nbreak;",
"VAR_14 = 0;",
"VAR_13 = 0;",
"for (VAR_6 = (VAR_2 & 0x2) ? 4 : 0; VAR_6 < BANDS; VAR_6++) {",
"VAR_16 = av_clipf(((VAR_1->flcoeffs4[VAR_6] * 0.5) - VAR_12 + 0.5), 0, 6);",
"VAR_1->bitsBandT[VAR_6] = VAR_16;",
"VAR_14 += VAR_1->bandWidthT[VAR_6] * VAR_16;",
"if (VAR_16 > 0)\nVAR_13 += VAR_1->bandWidthT[VAR_6];",
"}",
"VAR_20 = VAR_11;",
"VAR_11 = 1;",
"if (VAR_3 < VAR_14)\nVAR_11 = -1;",
"if (VAR_5 == 0)\nVAR_20 = VAR_11;",
"if (VAR_20 != VAR_11)\nVAR_10++;",
"VAR_12 = (float)(VAR_14 - VAR_3) / ((VAR_10 + 1) * VAR_13) + VAR_12;",
"}",
"for (VAR_5 = (VAR_2 & 0x2) ? 4 : 0; VAR_5 < BANDS; VAR_5++) {",
"for (VAR_6 = band_tab[VAR_5]; VAR_6 < band_tab[VAR_5 + 1]; VAR_6++)",
"VAR_1->CWlengthT[VAR_6] = VAR_1->bitsBandT[VAR_5];",
"}",
"if (VAR_3 > VAR_14) {",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {",
"VAR_19[VAR_5] = (VAR_1->bitsBandT[VAR_5] == 6) ? -1.e20\n: (VAR_1->bitsBandT[VAR_5] * -2 + VAR_1->flcoeffs4[VAR_5] - 0.415);",
"}",
"VAR_8 = 0.0;",
"do {",
"if (VAR_8 <= -1.e20)\nbreak;",
"VAR_21 = 0;",
"VAR_8 = -1.e20;",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {",
"if (VAR_19[VAR_5] > VAR_8) {",
"VAR_8 = VAR_19[VAR_5];",
"VAR_21 = VAR_5;",
"}",
"}",
"if (VAR_8 > -1.e20) {",
"VAR_19[VAR_21] -= 2.0;",
"if (++VAR_1->bitsBandT[VAR_21] == 6)\nVAR_19[VAR_21] = -1.e20;",
"for (VAR_6 = band_tab[VAR_21]; VAR_6 < band_tab[VAR_21 + 1] && (VAR_3 > VAR_14); VAR_6++) {",
"VAR_1->CWlengthT[VAR_6]++;",
"VAR_14++;",
"}",
"}",
"} while (VAR_3 > VAR_14);",
"}",
"if (VAR_3 < VAR_14) {",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {",
"VAR_19[VAR_5] = VAR_1->bitsBandT[VAR_5] ? (VAR_1->bitsBandT[VAR_5] * -2 + VAR_1->flcoeffs4[VAR_5] + 1.585)\n: 1.e20;",
"}",
"if (VAR_2 & 0x2) {",
"VAR_19[0] = 1.e20;",
"VAR_19[1] = 1.e20;",
"VAR_19[2] = 1.e20;",
"VAR_19[3] = 1.e20;",
"}",
"while (VAR_3 < VAR_14) {",
"VAR_17 = 1.e10;",
"VAR_18 = 0;",
"for (VAR_5 = 0; VAR_5 < BANDS; VAR_5++) {",
"if (VAR_19[VAR_5] < VAR_17) {",
"VAR_17 = VAR_19[VAR_5];",
"VAR_18 = VAR_5;",
"}",
"}",
"VAR_19[VAR_18] = VAR_17 + 2.0;",
"if (!--VAR_1->bitsBandT[VAR_18])\nVAR_19[VAR_18] = 1.e20;",
"for (VAR_6 = band_tab[VAR_18]; VAR_6 < band_tab[VAR_18+1] && (VAR_3 < VAR_14); VAR_6++) {",
"if (VAR_1->CWlengthT[VAR_6] > 0) {",
"VAR_1->CWlengthT[VAR_6]--;",
"VAR_14--;",
"}",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
61,
63
],
[
67,
69
],
[
73,
75
],
[
79,
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115,
117
],
[
121
],
[
123
],
[
129
],
[
131
],
[
133,
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157,
159
],
[
161
],
[
165
],
[
167
],
[
169,
171
],
[
173,
175
],
[
177,
179
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
211
],
[
215
],
[
217,
219
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247,
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
311
],
[
315,
317
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
]
] |
23,267 | static av_cold int g722_decode_init(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
c->band[0].scale_factor = 8;
c->band[1].scale_factor = 2;
c->prev_samples_pos = 22;
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0;
}
| false | FFmpeg | ec2694d25905c217e5815947cda896aa25398388 | static av_cold int g722_decode_init(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
c->band[0].scale_factor = 8;
c->band[1].scale_factor = 2;
c->prev_samples_pos = 22;
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
c->band[0].scale_factor = 8;
c->band[1].scale_factor = 2;
c->prev_samples_pos = 22;
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext * avctx)\n{",
"G722Context *c = avctx->priv_data;",
"if (avctx->channels != 1) {",
"av_log(avctx, AV_LOG_ERROR, \"Only mono tracks are allowed.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"avctx->sample_fmt = AV_SAMPLE_FMT_S16;",
"c->band[0].scale_factor = 8;",
"c->band[1].scale_factor = 2;",
"c->prev_samples_pos = 22;",
"avcodec_get_frame_defaults(&c->frame);",
"avctx->coded_frame = &c->frame;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
23,268 | static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
AVFormatContext *s = ts->stream;
MpegTSFilter *tss;
int len, pid, cc, cc_ok, afc, is_start;
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 == NULL && is_start) {
add_pes_stream(ts, pid, -1, 0);
tss = ts->pids[pid];
}
if (!tss)
return 0;
/* continuity check (currently not used) */
cc = (packet[3] & 0xf);
cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
tss->last_cc = cc;
/* skip adaptation field */
afc = (packet[3] >> 4) & 3;
p = packet + 4;
if (afc == 0) /* reserved value */
return 0;
if (afc == 2) /* adaptation field only */
return 0;
if (afc == 3) {
/* skip adapation field */
p += p[0] + 1;
}
/* if past the end of packet, ignore */
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end)
return 0;
pos = url_ftell(ts->stream->pb);
ts->pos47= pos % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
/* pointer field present */
len = *p++;
if (p + len > p_end)
return 0;
if (len && cc_ok) {
/* write remaining section bytes */
write_section_data(s, 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(s, tss,
p, p_end - p, 1);
}
} else {
if (cc_ok) {
write_section_data(s, tss,
p, p_end - p, 0);
}
}
} 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;
}
| false | FFmpeg | b3f9f7a33337e9b64e6044b0010e2722fa0b2f9c | static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
AVFormatContext *s = ts->stream;
MpegTSFilter *tss;
int len, pid, cc, cc_ok, afc, is_start;
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 == NULL && is_start) {
add_pes_stream(ts, pid, -1, 0);
tss = ts->pids[pid];
}
if (!tss)
return 0;
cc = (packet[3] & 0xf);
cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
tss->last_cc = cc;
afc = (packet[3] >> 4) & 3;
p = packet + 4;
if (afc == 0)
return 0;
if (afc == 2)
return 0;
if (afc == 3) {
p += p[0] + 1;
}
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end)
return 0;
pos = url_ftell(ts->stream->pb);
ts->pos47= pos % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
len = *p++;
if (p + len > p_end)
return 0;
if (len && cc_ok) {
write_section_data(s, tss,
p, len, 0);
if (!ts->pids[pid])
return 0;
}
p += len;
if (p < p_end) {
write_section_data(s, tss,
p, p_end - p, 1);
}
} else {
if (cc_ok) {
write_section_data(s, tss,
p, p_end - p, 0);
}
}
} 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)
{
AVFormatContext *s = VAR_0->stream;
MpegTSFilter *tss;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
const uint8_t *VAR_8, *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_7 = VAR_1[1] & 0x40;
tss = VAR_0->pids[VAR_3];
if (VAR_0->auto_guess && tss == NULL && VAR_7) {
add_pes_stream(VAR_0, VAR_3, -1, 0);
tss = VAR_0->pids[VAR_3];
}
if (!tss)
return 0;
VAR_4 = (VAR_1[3] & 0xf);
VAR_5 = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == VAR_4));
tss->last_cc = VAR_4;
VAR_6 = (VAR_1[3] >> 4) & 3;
VAR_8 = VAR_1 + 4;
if (VAR_6 == 0)
return 0;
if (VAR_6 == 2)
return 0;
if (VAR_6 == 3) {
VAR_8 += VAR_8[0] + 1;
}
p_end = VAR_1 + TS_PACKET_SIZE;
if (VAR_8 >= p_end)
return 0;
pos = url_ftell(VAR_0->stream->pb);
VAR_0->pos47= pos % VAR_0->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
if (VAR_7) {
VAR_2 = *VAR_8++;
if (VAR_8 + VAR_2 > p_end)
return 0;
if (VAR_2 && VAR_5) {
write_section_data(s, tss,
VAR_8, VAR_2, 0);
if (!VAR_0->pids[VAR_3])
return 0;
}
VAR_8 += VAR_2;
if (VAR_8 < p_end) {
write_section_data(s, tss,
VAR_8, p_end - VAR_8, 1);
}
} else {
if (VAR_5) {
write_section_data(s, tss,
VAR_8, p_end - VAR_8, 0);
}
}
} else {
int VAR_9;
if ((VAR_9 = tss->u.pes_filter.pes_cb(tss, VAR_8, p_end - VAR_8, VAR_7,
pos - VAR_0->raw_packet_size)) < 0)
return VAR_9;
}
return 0;
}
| [
"static int FUNC_0(MpegTSContext *VAR_0, const uint8_t *VAR_1)\n{",
"AVFormatContext *s = VAR_0->stream;",
"MpegTSFilter *tss;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"const uint8_t *VAR_8, *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_7 = VAR_1[1] & 0x40;",
"tss = VAR_0->pids[VAR_3];",
"if (VAR_0->auto_guess && tss == NULL && VAR_7) {",
"add_pes_stream(VAR_0, VAR_3, -1, 0);",
"tss = VAR_0->pids[VAR_3];",
"}",
"if (!tss)\nreturn 0;",
"VAR_4 = (VAR_1[3] & 0xf);",
"VAR_5 = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == VAR_4));",
"tss->last_cc = VAR_4;",
"VAR_6 = (VAR_1[3] >> 4) & 3;",
"VAR_8 = VAR_1 + 4;",
"if (VAR_6 == 0)\nreturn 0;",
"if (VAR_6 == 2)\nreturn 0;",
"if (VAR_6 == 3) {",
"VAR_8 += VAR_8[0] + 1;",
"}",
"p_end = VAR_1 + TS_PACKET_SIZE;",
"if (VAR_8 >= p_end)\nreturn 0;",
"pos = url_ftell(VAR_0->stream->pb);",
"VAR_0->pos47= pos % VAR_0->raw_packet_size;",
"if (tss->type == MPEGTS_SECTION) {",
"if (VAR_7) {",
"VAR_2 = *VAR_8++;",
"if (VAR_8 + VAR_2 > p_end)\nreturn 0;",
"if (VAR_2 && VAR_5) {",
"write_section_data(s, tss,\nVAR_8, VAR_2, 0);",
"if (!VAR_0->pids[VAR_3])\nreturn 0;",
"}",
"VAR_8 += VAR_2;",
"if (VAR_8 < p_end) {",
"write_section_data(s, tss,\nVAR_8, p_end - VAR_8, 1);",
"}",
"} else {",
"if (VAR_5) {",
"write_section_data(s, tss,\nVAR_8, p_end - VAR_8, 0);",
"}",
"}",
"} else {",
"int VAR_9;",
"if ((VAR_9 = tss->u.pes_filter.pes_cb(tss, VAR_8, p_end - VAR_8, VAR_7,\npos - VAR_0->raw_packet_size)) < 0)\nreturn VAR_9;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77,
79
],
[
83
],
[
85
],
[
89
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
105,
107
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147,
149
],
[
151
],
[
155
],
[
157
]
] |
23,269 | static void buffer_release(void *opaque, uint8_t *data)
{
*(uint8_t*)opaque = 0;
}
| false | FFmpeg | 03cef34aa66662e2ab3681d290e7c5a6634f4058 | static void buffer_release(void *opaque, uint8_t *data)
{
*(uint8_t*)opaque = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, uint8_t *VAR_1)
{
*(uint8_t*)VAR_0 = 0;
}
| [
"static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{",
"*(uint8_t*)VAR_0 = 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
23,270 | static void float_to_int16_3dnow(int16_t *dst, const float *src, int len){
// not bit-exact: pf2id uses different rounding than C and SSE
int i;
for(i=0; i<len; i+=4) {
asm volatile(
"pf2id %1, %%mm0 \n\t"
"pf2id %2, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"movq %%mm0, %0 \n\t"
:"=m"(dst[i])
:"m"(src[i]), "m"(src[i+2])
);
}
asm volatile("femms");
}
| false | FFmpeg | 63b737d4f9c118853a4f8d9af641335629bdf3ab | static void float_to_int16_3dnow(int16_t *dst, const float *src, int len){
int i;
for(i=0; i<len; i+=4) {
asm volatile(
"pf2id %1, %%mm0 \n\t"
"pf2id %2, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"movq %%mm0, %0 \n\t"
:"=m"(dst[i])
:"m"(src[i]), "m"(src[i+2])
);
}
asm volatile("femms");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int16_t *VAR_0, const float *VAR_1, int VAR_2){
int VAR_3;
for(VAR_3=0; VAR_3<VAR_2; VAR_3+=4) {
asm volatile(
"pf2id %1, %%mm0 \n\t"
"pf2id %2, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"movq %%mm0, %0 \n\t"
:"=m"(VAR_0[VAR_3])
:"m"(VAR_1[VAR_3]), "m"(VAR_1[VAR_3+2])
);
}
asm volatile("femms");
}
| [
"static void FUNC_0(int16_t *VAR_0, const float *VAR_1, int VAR_2){",
"int VAR_3;",
"for(VAR_3=0; VAR_3<VAR_2; VAR_3+=4) {",
"asm volatile(\n\"pf2id %1, %%mm0 \\n\\t\"\n\"pf2id %2, %%mm1 \\n\\t\"\n\"packssdw %%mm1, %%mm0 \\n\\t\"\n\"movq %%mm0, %0 \\n\\t\"\n:\"=m\"(VAR_0[VAR_3])\n:\"m\"(VAR_1[VAR_3]), \"m\"(VAR_1[VAR_3+2])\n);",
"}",
"asm volatile(\"femms\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
5
],
[
7
],
[
9,
11,
13,
15,
17,
19,
21,
23
],
[
25
],
[
27
],
[
29
]
] |
23,271 | static int add_shorts_metadata(const uint8_t **buf, int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int *sp = av_malloc(count * sizeof(int));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(buf, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| false | FFmpeg | 1ec83d9a9e472f485897ac92bad9631d551a8c5b | static int add_shorts_metadata(const uint8_t **buf, int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int *sp = av_malloc(count * sizeof(int));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(buf, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t **VAR_0, int VAR_1, const char *VAR_2,
const char *VAR_3, TiffContext *VAR_4)
{
char *VAR_5;
int VAR_6;
int *VAR_7 = av_malloc(VAR_1 * sizeof(int));
if (!VAR_7)
return AVERROR(ENOMEM);
for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++)
VAR_7[VAR_6] = tget_short(VAR_0, VAR_4->le);
VAR_5 = shorts2str(VAR_7, VAR_1, VAR_3);
av_freep(&VAR_7);
if (!VAR_5)
return AVERROR(ENOMEM);
av_dict_set(&VAR_4->picture.metadata, VAR_2, VAR_5, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| [
"static int FUNC_0(const uint8_t **VAR_0, int VAR_1, const char *VAR_2,\nconst char *VAR_3, TiffContext *VAR_4)\n{",
"char *VAR_5;",
"int VAR_6;",
"int *VAR_7 = av_malloc(VAR_1 * sizeof(int));",
"if (!VAR_7)\nreturn AVERROR(ENOMEM);",
"for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++)",
"VAR_7[VAR_6] = tget_short(VAR_0, VAR_4->le);",
"VAR_5 = shorts2str(VAR_7, VAR_1, VAR_3);",
"av_freep(&VAR_7);",
"if (!VAR_5)\nreturn AVERROR(ENOMEM);",
"av_dict_set(&VAR_4->picture.metadata, VAR_2, VAR_5, AV_DICT_DONT_STRDUP_VAL);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
]
] |
23,272 | int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
const uint8_t *mb_bitmask, const AVFrame *reference)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id;
const int block_size= s->lossless ? 1 : 8;
int ilv, prev_shift;
/* XXX: verify len field validity */
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (nb_components == 0 || nb_components > MAX_COMPONENTS){
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components);
return -1;
}
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
return -1;
}
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
/* find component index */
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
/* Metasoft MJPEG codec has Cb and Cr swapped */
if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
&& nb_components == 3 && s->nb_components == 3 && i)
index = 3 - i;
if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
index = (i+2)%3;
s->comp_index[i] = index;
s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
s->h_scount[i] = s->h_count[index];
s->v_scount[i] = s->v_count[index];
s->dc_index[i] = get_bits(&s->gb, 4);
s->ac_index[i] = get_bits(&s->gb, 4);
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
goto out_of_range;
}
predictor= get_bits(&s->gb, 8); /* JPEG Ss / lossless JPEG predictor /JPEG-LS NEAR */
ilv= get_bits(&s->gb, 8); /* JPEG Se / JPEG-LS ILV */
if(s->avctx->codec_tag != AV_RL32("CJPG")){
prev_shift = get_bits(&s->gb, 4); /* Ah */
point_transform= get_bits(&s->gb, 4); /* Al */
}else
prev_shift= point_transform= 0;
for(i=0;i<nb_components;i++)
s->last_dc[i] = 1024;
if (nb_components > 1) {
/* interleaved stream */
s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else if(!s->ls) { /* skip this for JPEG-LS */
h = s->h_max / s->h_scount[0];
v = s->v_max / s->v_scount[0];
s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
s->nb_blocks[0] = 1;
s->h_scount[0] = 1;
s->v_scount[0] = 1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components);
/* mjpeg-b can have padding bytes between sos and image data, skip them */
for (i = s->mjpb_skiptosod; i > 0; i--)
skip_bits(&s->gb, 8);
if(s->lossless){
av_assert0(s->picture_ptr == &s->picture);
if(CONFIG_JPEGLS_DECODER && s->ls){
// for(){
// reset_ls_coding_parameters(s, 0);
if(ff_jpegls_decode_picture(s, predictor, point_transform, ilv) < 0)
return -1;
}else{
if(s->rgb){
if(ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform) < 0)
return -1;
}else{
if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
return -1;
}
}
}else{
if(s->progressive && predictor) {
av_assert0(s->picture_ptr == &s->picture);
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
return -1;
} else {
if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform,
mb_bitmask, reference) < 0)
return -1;
}
}
if (s->yuv421) {
uint8_t *line = s->picture_ptr->data[2];
for (i = 0; i < s->height / 2; i++) {
for (index = s->width - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
line += s->linesize[2];
}
} else if (s->yuv442) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[2])[(s->height - 1) * s->linesize[2]];
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[2])[i / 2 * s->linesize[2]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[2])[(i + 1) / 2 * s->linesize[2]];
if (src1 == src2) {
memcpy(dst, src1, s->width);
} else {
for (index = 0; index < s->width; index++)
dst[index] = (src1[index] + src2[index]) >> 1;
}
dst -= s->linesize[2];
}
}
emms_c();
return 0;
out_of_range:
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
return -1;
}
| false | FFmpeg | 15b219fae9da1691dfb264f51637805e1ca63d1a | int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
const uint8_t *mb_bitmask, const AVFrame *reference)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id;
const int block_size= s->lossless ? 1 : 8;
int ilv, prev_shift;
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (nb_components == 0 || nb_components > MAX_COMPONENTS){
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components);
return -1;
}
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
return -1;
}
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
&& nb_components == 3 && s->nb_components == 3 && i)
index = 3 - i;
if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
index = (i+2)%3;
s->comp_index[i] = index;
s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
s->h_scount[i] = s->h_count[index];
s->v_scount[i] = s->v_count[index];
s->dc_index[i] = get_bits(&s->gb, 4);
s->ac_index[i] = get_bits(&s->gb, 4);
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
goto out_of_range;
}
predictor= get_bits(&s->gb, 8);
ilv= get_bits(&s->gb, 8);
if(s->avctx->codec_tag != AV_RL32("CJPG")){
prev_shift = get_bits(&s->gb, 4);
point_transform= get_bits(&s->gb, 4);
}else
prev_shift= point_transform= 0;
for(i=0;i<nb_components;i++)
s->last_dc[i] = 1024;
if (nb_components > 1) {
s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else if(!s->ls) {
h = s->h_max / s->h_scount[0];
v = s->v_max / s->v_scount[0];
s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
s->nb_blocks[0] = 1;
s->h_scount[0] = 1;
s->v_scount[0] = 1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components);
for (i = s->mjpb_skiptosod; i > 0; i--)
skip_bits(&s->gb, 8);
if(s->lossless){
av_assert0(s->picture_ptr == &s->picture);
if(CONFIG_JPEGLS_DECODER && s->ls){
if(ff_jpegls_decode_picture(s, predictor, point_transform, ilv) < 0)
return -1;
}else{
if(s->rgb){
if(ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform) < 0)
return -1;
}else{
if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
return -1;
}
}
}else{
if(s->progressive && predictor) {
av_assert0(s->picture_ptr == &s->picture);
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
return -1;
} else {
if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform,
mb_bitmask, reference) < 0)
return -1;
}
}
if (s->yuv421) {
uint8_t *line = s->picture_ptr->data[2];
for (i = 0; i < s->height / 2; i++) {
for (index = s->width - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
line += s->linesize[2];
}
} else if (s->yuv442) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[2])[(s->height - 1) * s->linesize[2]];
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[2])[i / 2 * s->linesize[2]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[2])[(i + 1) / 2 * s->linesize[2]];
if (src1 == src2) {
memcpy(dst, src1, s->width);
} else {
for (index = 0; index < s->width; index++)
dst[index] = (src1[index] + src2[index]) >> 1;
}
dst -= s->linesize[2];
}
}
emms_c();
return 0;
out_of_range:
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
return -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MJpegDecodeContext *VAR_0,
const uint8_t *VAR_1, const AVFrame *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10, VAR_11;
const int VAR_12= VAR_0->lossless ? 1 : 8;
int VAR_13, VAR_14;
VAR_3 = get_bits(&VAR_0->gb, 16);
VAR_4 = get_bits(&VAR_0->gb, 8);
if (VAR_4 == 0 || VAR_4 > MAX_COMPONENTS){
av_log(VAR_0->avctx, AV_LOG_ERROR, "decode_sos: VAR_4 (%d) unsupported\n", VAR_4);
return -1;
}
if (VAR_3 != 6+2*VAR_4)
{
av_log(VAR_0->avctx, AV_LOG_ERROR, "decode_sos: invalid VAR_3 (%d)\n", VAR_3);
return -1;
}
for(VAR_5=0;VAR_5<VAR_4;VAR_5++) {
VAR_11 = get_bits(&VAR_0->gb, 8) - 1;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "component: %d\n", VAR_11);
for(VAR_10=0;VAR_10<VAR_0->VAR_4;VAR_10++)
if (VAR_11 == VAR_0->component_id[VAR_10])
break;
if (VAR_10 == VAR_0->VAR_4)
{
av_log(VAR_0->avctx, AV_LOG_ERROR, "decode_sos: VAR_10(%d) out of components\n", VAR_10);
return -1;
}
if (VAR_0->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
&& VAR_4 == 3 && VAR_0->VAR_4 == 3 && VAR_5)
VAR_10 = 3 - VAR_5;
if(VAR_4 == 3 && VAR_0->VAR_4 == 3 && VAR_0->avctx->pix_fmt == PIX_FMT_GBR24P)
VAR_10 = (VAR_5+2)%3;
VAR_0->comp_index[VAR_5] = VAR_10;
VAR_0->nb_blocks[VAR_5] = VAR_0->h_count[VAR_10] * VAR_0->v_count[VAR_10];
VAR_0->h_scount[VAR_5] = VAR_0->h_count[VAR_10];
VAR_0->v_scount[VAR_5] = VAR_0->v_count[VAR_10];
VAR_0->dc_index[VAR_5] = get_bits(&VAR_0->gb, 4);
VAR_0->ac_index[VAR_5] = get_bits(&VAR_0->gb, 4);
if (VAR_0->dc_index[VAR_5] < 0 || VAR_0->ac_index[VAR_5] < 0 ||
VAR_0->dc_index[VAR_5] >= 4 || VAR_0->ac_index[VAR_5] >= 4)
goto out_of_range;
if (!VAR_0->vlcs[0][VAR_0->dc_index[VAR_5]].table || !VAR_0->vlcs[1][VAR_0->ac_index[VAR_5]].table)
goto out_of_range;
}
VAR_8= get_bits(&VAR_0->gb, 8);
VAR_13= get_bits(&VAR_0->gb, 8);
if(VAR_0->avctx->codec_tag != AV_RL32("CJPG")){
VAR_14 = get_bits(&VAR_0->gb, 4);
VAR_9= get_bits(&VAR_0->gb, 4);
}else
VAR_14= VAR_9= 0;
for(VAR_5=0;VAR_5<VAR_4;VAR_5++)
VAR_0->last_dc[VAR_5] = 1024;
if (VAR_4 > 1) {
VAR_0->mb_width = (VAR_0->width + VAR_0->h_max * VAR_12 - 1) / (VAR_0->h_max * VAR_12);
VAR_0->mb_height = (VAR_0->height + VAR_0->v_max * VAR_12 - 1) / (VAR_0->v_max * VAR_12);
} else if(!VAR_0->ls) {
VAR_6 = VAR_0->h_max / VAR_0->h_scount[0];
VAR_7 = VAR_0->v_max / VAR_0->v_scount[0];
VAR_0->mb_width = (VAR_0->width + VAR_6 * VAR_12 - 1) / (VAR_6 * VAR_12);
VAR_0->mb_height = (VAR_0->height + VAR_7 * VAR_12 - 1) / (VAR_7 * VAR_12);
VAR_0->nb_blocks[0] = 1;
VAR_0->h_scount[0] = 1;
VAR_0->v_scount[0] = 1;
}
if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "%VAR_0 %VAR_0 p:%d >>:%d VAR_13:%d bits:%d skip:%d %VAR_0 comp:%d\n", VAR_0->lossless ? "lossless" : "sequential DCT", VAR_0->rgb ? "RGB" : "",
VAR_8, VAR_9, VAR_13, VAR_0->bits, VAR_0->mjpb_skiptosod,
VAR_0->pegasus_rct ? "PRCT" : (VAR_0->rct ? "RCT" : ""), VAR_4);
for (VAR_5 = VAR_0->mjpb_skiptosod; VAR_5 > 0; VAR_5--)
skip_bits(&VAR_0->gb, 8);
if(VAR_0->lossless){
av_assert0(VAR_0->picture_ptr == &VAR_0->picture);
if(CONFIG_JPEGLS_DECODER && VAR_0->ls){
if(ff_jpegls_decode_picture(VAR_0, VAR_8, VAR_9, VAR_13) < 0)
return -1;
}else{
if(VAR_0->rgb){
if(ljpeg_decode_rgb_scan(VAR_0, VAR_4, VAR_8, VAR_9) < 0)
return -1;
}else{
if(ljpeg_decode_yuv_scan(VAR_0, VAR_8, VAR_9) < 0)
return -1;
}
}
}else{
if(VAR_0->progressive && VAR_8) {
av_assert0(VAR_0->picture_ptr == &VAR_0->picture);
if(mjpeg_decode_scan_progressive_ac(VAR_0, VAR_8, VAR_13, VAR_14, VAR_9) < 0)
return -1;
} else {
if(mjpeg_decode_scan(VAR_0, VAR_4, VAR_14, VAR_9,
VAR_1, VAR_2) < 0)
return -1;
}
}
if (VAR_0->yuv421) {
uint8_t *line = VAR_0->picture_ptr->data[2];
for (VAR_5 = 0; VAR_5 < VAR_0->height / 2; VAR_5++) {
for (VAR_10 = VAR_0->width - 1; VAR_10; VAR_10--)
line[VAR_10] = (line[VAR_10 / 2] + line[(VAR_10 + 1) / 2]) >> 1;
line += VAR_0->linesize[2];
}
} else if (VAR_0->yuv442) {
uint8_t *dst = &((uint8_t *)VAR_0->picture_ptr->data[2])[(VAR_0->height - 1) * VAR_0->linesize[2]];
for (VAR_5 = VAR_0->height - 1; VAR_5; VAR_5--) {
uint8_t *src1 = &((uint8_t *)VAR_0->picture_ptr->data[2])[VAR_5 / 2 * VAR_0->linesize[2]];
uint8_t *src2 = &((uint8_t *)VAR_0->picture_ptr->data[2])[(VAR_5 + 1) / 2 * VAR_0->linesize[2]];
if (src1 == src2) {
memcpy(dst, src1, VAR_0->width);
} else {
for (VAR_10 = 0; VAR_10 < VAR_0->width; VAR_10++)
dst[VAR_10] = (src1[VAR_10] + src2[VAR_10]) >> 1;
}
dst -= VAR_0->linesize[2];
}
}
emms_c();
return 0;
out_of_range:
av_log(VAR_0->avctx, AV_LOG_ERROR, "decode_sos: ac/dc VAR_10 out of range\n");
return -1;
}
| [
"int FUNC_0(MJpegDecodeContext *VAR_0,\nconst uint8_t *VAR_1, const AVFrame *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10, VAR_11;",
"const int VAR_12= VAR_0->lossless ? 1 : 8;",
"int VAR_13, VAR_14;",
"VAR_3 = get_bits(&VAR_0->gb, 16);",
"VAR_4 = get_bits(&VAR_0->gb, 8);",
"if (VAR_4 == 0 || VAR_4 > MAX_COMPONENTS){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"decode_sos: VAR_4 (%d) unsupported\\n\", VAR_4);",
"return -1;",
"}",
"if (VAR_3 != 6+2*VAR_4)\n{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"decode_sos: invalid VAR_3 (%d)\\n\", VAR_3);",
"return -1;",
"}",
"for(VAR_5=0;VAR_5<VAR_4;VAR_5++) {",
"VAR_11 = get_bits(&VAR_0->gb, 8) - 1;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"component: %d\\n\", VAR_11);",
"for(VAR_10=0;VAR_10<VAR_0->VAR_4;VAR_10++)",
"if (VAR_11 == VAR_0->component_id[VAR_10])\nbreak;",
"if (VAR_10 == VAR_0->VAR_4)\n{",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"decode_sos: VAR_10(%d) out of components\\n\", VAR_10);",
"return -1;",
"}",
"if (VAR_0->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')\n&& VAR_4 == 3 && VAR_0->VAR_4 == 3 && VAR_5)\nVAR_10 = 3 - VAR_5;",
"if(VAR_4 == 3 && VAR_0->VAR_4 == 3 && VAR_0->avctx->pix_fmt == PIX_FMT_GBR24P)\nVAR_10 = (VAR_5+2)%3;",
"VAR_0->comp_index[VAR_5] = VAR_10;",
"VAR_0->nb_blocks[VAR_5] = VAR_0->h_count[VAR_10] * VAR_0->v_count[VAR_10];",
"VAR_0->h_scount[VAR_5] = VAR_0->h_count[VAR_10];",
"VAR_0->v_scount[VAR_5] = VAR_0->v_count[VAR_10];",
"VAR_0->dc_index[VAR_5] = get_bits(&VAR_0->gb, 4);",
"VAR_0->ac_index[VAR_5] = get_bits(&VAR_0->gb, 4);",
"if (VAR_0->dc_index[VAR_5] < 0 || VAR_0->ac_index[VAR_5] < 0 ||\nVAR_0->dc_index[VAR_5] >= 4 || VAR_0->ac_index[VAR_5] >= 4)\ngoto out_of_range;",
"if (!VAR_0->vlcs[0][VAR_0->dc_index[VAR_5]].table || !VAR_0->vlcs[1][VAR_0->ac_index[VAR_5]].table)\ngoto out_of_range;",
"}",
"VAR_8= get_bits(&VAR_0->gb, 8);",
"VAR_13= get_bits(&VAR_0->gb, 8);",
"if(VAR_0->avctx->codec_tag != AV_RL32(\"CJPG\")){",
"VAR_14 = get_bits(&VAR_0->gb, 4);",
"VAR_9= get_bits(&VAR_0->gb, 4);",
"}else",
"VAR_14= VAR_9= 0;",
"for(VAR_5=0;VAR_5<VAR_4;VAR_5++)",
"VAR_0->last_dc[VAR_5] = 1024;",
"if (VAR_4 > 1) {",
"VAR_0->mb_width = (VAR_0->width + VAR_0->h_max * VAR_12 - 1) / (VAR_0->h_max * VAR_12);",
"VAR_0->mb_height = (VAR_0->height + VAR_0->v_max * VAR_12 - 1) / (VAR_0->v_max * VAR_12);",
"} else if(!VAR_0->ls) {",
"VAR_6 = VAR_0->h_max / VAR_0->h_scount[0];",
"VAR_7 = VAR_0->v_max / VAR_0->v_scount[0];",
"VAR_0->mb_width = (VAR_0->width + VAR_6 * VAR_12 - 1) / (VAR_6 * VAR_12);",
"VAR_0->mb_height = (VAR_0->height + VAR_7 * VAR_12 - 1) / (VAR_7 * VAR_12);",
"VAR_0->nb_blocks[0] = 1;",
"VAR_0->h_scount[0] = 1;",
"VAR_0->v_scount[0] = 1;",
"}",
"if(VAR_0->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"%VAR_0 %VAR_0 p:%d >>:%d VAR_13:%d bits:%d skip:%d %VAR_0 comp:%d\\n\", VAR_0->lossless ? \"lossless\" : \"sequential DCT\", VAR_0->rgb ? \"RGB\" : \"\",\nVAR_8, VAR_9, VAR_13, VAR_0->bits, VAR_0->mjpb_skiptosod,\nVAR_0->pegasus_rct ? \"PRCT\" : (VAR_0->rct ? \"RCT\" : \"\"), VAR_4);",
"for (VAR_5 = VAR_0->mjpb_skiptosod; VAR_5 > 0; VAR_5--)",
"skip_bits(&VAR_0->gb, 8);",
"if(VAR_0->lossless){",
"av_assert0(VAR_0->picture_ptr == &VAR_0->picture);",
"if(CONFIG_JPEGLS_DECODER && VAR_0->ls){",
"if(ff_jpegls_decode_picture(VAR_0, VAR_8, VAR_9, VAR_13) < 0)\nreturn -1;",
"}else{",
"if(VAR_0->rgb){",
"if(ljpeg_decode_rgb_scan(VAR_0, VAR_4, VAR_8, VAR_9) < 0)\nreturn -1;",
"}else{",
"if(ljpeg_decode_yuv_scan(VAR_0, VAR_8, VAR_9) < 0)\nreturn -1;",
"}",
"}",
"}else{",
"if(VAR_0->progressive && VAR_8) {",
"av_assert0(VAR_0->picture_ptr == &VAR_0->picture);",
"if(mjpeg_decode_scan_progressive_ac(VAR_0, VAR_8, VAR_13, VAR_14, VAR_9) < 0)\nreturn -1;",
"} else {",
"if(mjpeg_decode_scan(VAR_0, VAR_4, VAR_14, VAR_9,\nVAR_1, VAR_2) < 0)\nreturn -1;",
"}",
"}",
"if (VAR_0->yuv421) {",
"uint8_t *line = VAR_0->picture_ptr->data[2];",
"for (VAR_5 = 0; VAR_5 < VAR_0->height / 2; VAR_5++) {",
"for (VAR_10 = VAR_0->width - 1; VAR_10; VAR_10--)",
"line[VAR_10] = (line[VAR_10 / 2] + line[(VAR_10 + 1) / 2]) >> 1;",
"line += VAR_0->linesize[2];",
"}",
"} else if (VAR_0->yuv442) {",
"uint8_t *dst = &((uint8_t *)VAR_0->picture_ptr->data[2])[(VAR_0->height - 1) * VAR_0->linesize[2]];",
"for (VAR_5 = VAR_0->height - 1; VAR_5; VAR_5--) {",
"uint8_t *src1 = &((uint8_t *)VAR_0->picture_ptr->data[2])[VAR_5 / 2 * VAR_0->linesize[2]];",
"uint8_t *src2 = &((uint8_t *)VAR_0->picture_ptr->data[2])[(VAR_5 + 1) / 2 * VAR_0->linesize[2]];",
"if (src1 == src2) {",
"memcpy(dst, src1, VAR_0->width);",
"} else {",
"for (VAR_10 = 0; VAR_10 < VAR_0->width; VAR_10++)",
"dst[VAR_10] = (src1[VAR_10] + src2[VAR_10]) >> 1;",
"}",
"dst -= VAR_0->linesize[2];",
"}",
"}",
"emms_c();",
"return 0;",
"out_of_range:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"decode_sos: ac/dc VAR_10 out of range\\n\");",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67,
69,
71
],
[
75,
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
99,
101,
103
],
[
105,
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163,
165,
167,
169
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
195,
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229,
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285,
287
],
[
289
],
[
291
]
] |
23,273 | static int is_intra_more_likely(MpegEncContext *s){
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1; //no previous frame available -> use spatial prediction
undamaged_count=0;
for(i=0; i<s->mb_num; i++){
const int mb_xy= s->mb_index2xy[i];
const int error= s->error_status_table[mb_xy];
if(!((error&DC_ERROR) && (error&MV_ERROR)))
undamaged_count++;
}
if(s->codec_id == CODEC_ID_H264){
H264Context *h= (void*)s;
if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])
return 1;
}
if(undamaged_count < 5) return 0; //almost all MBs damaged -> use temporal prediction
//prevent dsp.sad() check, that requires access to the image
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I)
return 1;
skip_amount= FFMAX(undamaged_count/50, 1); //check only upto 50 MBs
is_intra_likely=0;
j=0;
for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){
for(mb_x= 0; mb_x<s->mb_width; mb_x++){
int error;
const int mb_xy= mb_x + mb_y*s->mb_stride;
error= s->error_status_table[mb_xy];
if((error&DC_ERROR) && (error&MV_ERROR))
continue; //skip damaged
j++;
if((j%skip_amount) != 0) continue; //skip a few to speed things up
if(s->pict_type==AV_PICTURE_TYPE_I){
uint8_t *mb_ptr = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize;
uint8_t *last_mb_ptr= s->last_picture.f.data [0] + mb_x*16 + mb_y*16*s->linesize;
if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME
} else {
ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
mb_y, 0);
}
is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
// FIXME need await_progress() here
is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
}else{
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
is_intra_likely++;
else
is_intra_likely--;
}
}
}
//printf("is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type);
return is_intra_likely > 0;
}
| false | FFmpeg | e1d5bbeb39501a3271c6422390d13bf9391872d1 | static int is_intra_more_likely(MpegEncContext *s){
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1;
undamaged_count=0;
for(i=0; i<s->mb_num; i++){
const int mb_xy= s->mb_index2xy[i];
const int error= s->error_status_table[mb_xy];
if(!((error&DC_ERROR) && (error&MV_ERROR)))
undamaged_count++;
}
if(s->codec_id == CODEC_ID_H264){
H264Context *h= (void*)s;
if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])
return 1;
}
if(undamaged_count < 5) return 0;
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I)
return 1;
skip_amount= FFMAX(undamaged_count/50, 1);
is_intra_likely=0;
j=0;
for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){
for(mb_x= 0; mb_x<s->mb_width; mb_x++){
int error;
const int mb_xy= mb_x + mb_y*s->mb_stride;
error= s->error_status_table[mb_xy];
if((error&DC_ERROR) && (error&MV_ERROR))
continue;
j++;
if((j%skip_amount) != 0) continue;
if(s->pict_type==AV_PICTURE_TYPE_I){
uint8_t *mb_ptr = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize;
uint8_t *last_mb_ptr= s->last_picture.f.data [0] + mb_x*16 + mb_y*16*s->linesize;
if (s->avctx->codec_id == CODEC_ID_H264) {
} else {
ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
mb_y, 0);
}
is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
need await_progress() here
is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
}else{
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
is_intra_likely++;
else
is_intra_likely--;
}
}
}
return is_intra_likely > 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0){
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
if (!VAR_0->last_picture_ptr || !VAR_0->last_picture_ptr->f.data[0]) return 1;
VAR_4=0;
for(VAR_2=0; VAR_2<VAR_0->mb_num; VAR_2++){
const int mb_xy= VAR_0->mb_index2xy[VAR_2];
const int error= VAR_0->error_status_table[mb_xy];
if(!((error&DC_ERROR) && (error&MV_ERROR)))
VAR_4++;
}
if(VAR_0->codec_id == CODEC_ID_H264){
H264Context *h= (void*)VAR_0;
if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])
return 1;
}
if(VAR_4 < 5) return 0;
if(CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration && VAR_0->pict_type == AV_PICTURE_TYPE_I)
return 1;
VAR_5= FFMAX(VAR_4/50, 1);
VAR_1=0;
VAR_3=0;
for(VAR_7= 0; VAR_7<VAR_0->mb_height-1; VAR_7++){
for(VAR_6= 0; VAR_6<VAR_0->mb_width; VAR_6++){
int error;
const int mb_xy= VAR_6 + VAR_7*VAR_0->mb_stride;
error= VAR_0->error_status_table[mb_xy];
if((error&DC_ERROR) && (error&MV_ERROR))
continue;
VAR_3++;
if((VAR_3%VAR_5) != 0) continue;
if(VAR_0->pict_type==AV_PICTURE_TYPE_I){
uint8_t *mb_ptr = VAR_0->current_picture.f.data[0] + VAR_6*16 + VAR_7*16*VAR_0->linesize;
uint8_t *last_mb_ptr= VAR_0->last_picture.f.data [0] + VAR_6*16 + VAR_7*16*VAR_0->linesize;
if (VAR_0->avctx->codec_id == CODEC_ID_H264) {
} else {
ff_thread_await_progress((AVFrame *) VAR_0->last_picture_ptr,
VAR_7, 0);
}
VAR_1 += VAR_0->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , VAR_0->linesize, 16);
need await_progress() here
VAR_1 -= VAR_0->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+VAR_0->linesize*16, VAR_0->linesize, 16);
}else{
if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))
VAR_1++;
else
VAR_1--;
}
}
}
return VAR_1 > 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0){",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"if (!VAR_0->last_picture_ptr || !VAR_0->last_picture_ptr->f.data[0]) return 1;",
"VAR_4=0;",
"for(VAR_2=0; VAR_2<VAR_0->mb_num; VAR_2++){",
"const int mb_xy= VAR_0->mb_index2xy[VAR_2];",
"const int error= VAR_0->error_status_table[mb_xy];",
"if(!((error&DC_ERROR) && (error&MV_ERROR)))\nVAR_4++;",
"}",
"if(VAR_0->codec_id == CODEC_ID_H264){",
"H264Context *h= (void*)VAR_0;",
"if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])\nreturn 1;",
"}",
"if(VAR_4 < 5) return 0;",
"if(CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration && VAR_0->pict_type == AV_PICTURE_TYPE_I)\nreturn 1;",
"VAR_5= FFMAX(VAR_4/50, 1);",
"VAR_1=0;",
"VAR_3=0;",
"for(VAR_7= 0; VAR_7<VAR_0->mb_height-1; VAR_7++){",
"for(VAR_6= 0; VAR_6<VAR_0->mb_width; VAR_6++){",
"int error;",
"const int mb_xy= VAR_6 + VAR_7*VAR_0->mb_stride;",
"error= VAR_0->error_status_table[mb_xy];",
"if((error&DC_ERROR) && (error&MV_ERROR))\ncontinue;",
"VAR_3++;",
"if((VAR_3%VAR_5) != 0) continue;",
"if(VAR_0->pict_type==AV_PICTURE_TYPE_I){",
"uint8_t *mb_ptr = VAR_0->current_picture.f.data[0] + VAR_6*16 + VAR_7*16*VAR_0->linesize;",
"uint8_t *last_mb_ptr= VAR_0->last_picture.f.data [0] + VAR_6*16 + VAR_7*16*VAR_0->linesize;",
"if (VAR_0->avctx->codec_id == CODEC_ID_H264) {",
"} else {",
"ff_thread_await_progress((AVFrame *) VAR_0->last_picture_ptr,\nVAR_7, 0);",
"}",
"VAR_1 += VAR_0->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , VAR_0->linesize, 16);",
"need await_progress() here\nVAR_1 -= VAR_0->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+VAR_0->linesize*16, VAR_0->linesize, 16);",
"}else{",
"if (IS_INTRA(VAR_0->current_picture.f.mb_type[mb_xy]))\nVAR_1++;",
"else\nVAR_1--;",
"}",
"}",
"}",
"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
] | [
[
1
],
[
3
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
39
],
[
45,
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
]
] |
23,275 | I2CAdapter *omap_i2c_create(uint64_t addr)
{
OMAPI2C *s = g_malloc0(sizeof(*s));
I2CAdapter *i2c = (I2CAdapter *)s;
uint16_t data;
s->addr = addr;
i2c->send = omap_i2c_send;
i2c->recv = omap_i2c_recv;
/* verify the mmio address by looking for a known signature */
memread(addr + OMAP_I2C_REV, &data, 2);
g_assert_cmphex(data, ==, 0x34);
return i2c;
}
| true | qemu | d0bce760e04b1658a3b4ac95be2839ae20fd86db | I2CAdapter *omap_i2c_create(uint64_t addr)
{
OMAPI2C *s = g_malloc0(sizeof(*s));
I2CAdapter *i2c = (I2CAdapter *)s;
uint16_t data;
s->addr = addr;
i2c->send = omap_i2c_send;
i2c->recv = omap_i2c_recv;
memread(addr + OMAP_I2C_REV, &data, 2);
g_assert_cmphex(data, ==, 0x34);
return i2c;
}
| {
"code": [
" memread(addr + OMAP_I2C_REV, &data, 2);"
],
"line_no": [
25
]
} | I2CAdapter *FUNC_0(uint64_t addr)
{
OMAPI2C *s = g_malloc0(sizeof(*s));
I2CAdapter *i2c = (I2CAdapter *)s;
uint16_t data;
s->addr = addr;
i2c->send = omap_i2c_send;
i2c->recv = omap_i2c_recv;
memread(addr + OMAP_I2C_REV, &data, 2);
g_assert_cmphex(data, ==, 0x34);
return i2c;
}
| [
"I2CAdapter *FUNC_0(uint64_t addr)\n{",
"OMAPI2C *s = g_malloc0(sizeof(*s));",
"I2CAdapter *i2c = (I2CAdapter *)s;",
"uint16_t data;",
"s->addr = addr;",
"i2c->send = omap_i2c_send;",
"i2c->recv = omap_i2c_recv;",
"memread(addr + OMAP_I2C_REV, &data, 2);",
"g_assert_cmphex(data, ==, 0x34);",
"return i2c;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
23,276 | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH, int log2_cb_size, int part_idx,
int merge_idx, MvField *mv,
int mvp_lx_flag, int LX)
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int isScaledFlag_L0 = 0;
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
int xA1, yA1;
int is_available_a1;
int xB0, yB0;
int is_available_b0;
int xB1, yB1;
int is_available_b1;
int xB2, yB2;
int is_available_b2;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
int pred_flag_index_l1;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
const int cand_up_left = lc->na.cand_up_left;
const int cand_up = lc->na.cand_up;
const int cand_up_right = lc->na.cand_up_right_sap;
ref_idx_curr = LX;
ref_idx = mv->ref_idx[LX];
pred_flag_index_l0 = LX;
pred_flag_index_l1 = !LX;
// left bottom spatial candidate
xA0 = x0 - 1;
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
//left spatial merge candidate
xA1 = x0 - 1;
yA1 = y0 + nPbH - 1;
is_available_a1 = AVAILABLE(cand_left, A1);
if (is_available_a0 || is_available_a1)
isScaledFlag_L0 = 1;
if (is_available_a0) {
if (MP_MX(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a0) {
if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
availableFlagLXA0 = 0;
b_candidates:
// B candidates
// above right spatial merge candidate
xB0 = x0 + nPbW;
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
if (is_available_b0) {
if (MP_MX(B0, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B0, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above spatial merge candidate
xB1 = x0 + nPbW - 1;
yB1 = y0 - 1;
is_available_b1 = AVAILABLE(cand_up, B1);
if (is_available_b1) {
if (MP_MX(B1, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B1, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above left spatial merge candidate
xB2 = x0 - 1;
yB2 = y0 - 1;
is_available_b2 = AVAILABLE(cand_up_left, B2);
if (is_available_b2) {
if (MP_MX(B2, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B2, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
availableFlagLXB0 = 0;
scalef:
if (!isScaledFlag_L0) {
if (availableFlagLXB0) {
availableFlagLXA0 = 1;
mxA = mxB;
}
availableFlagLXB0 = 0;
// XB0 and L1
if (is_available_b0) {
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
}
if (is_available_b1 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
}
if (is_available_b2 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
}
}
if (availableFlagLXA0)
mvpcand_list[numMVPCandLX++] = mxA;
if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[numMVPCandLX++] = mxB;
//temporal motion vector prediction candidate
if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
mvp_lx_flag == numMVPCandLX) {
Mv mv_col;
int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
nPbH, ref_idx,
&mv_col, LX);
if (available_col)
mvpcand_list[numMVPCandLX++] = mv_col;
}
mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
| true | FFmpeg | 84bc45880ae14277cb804569401ddd34274f4764 | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH, int log2_cb_size, int part_idx,
int merge_idx, MvField *mv,
int mvp_lx_flag, int LX)
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int isScaledFlag_L0 = 0;
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
int xA1, yA1;
int is_available_a1;
int xB0, yB0;
int is_available_b0;
int xB1, yB1;
int is_available_b1;
int xB2, yB2;
int is_available_b2;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
int pred_flag_index_l1;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
const int cand_up_left = lc->na.cand_up_left;
const int cand_up = lc->na.cand_up;
const int cand_up_right = lc->na.cand_up_right_sap;
ref_idx_curr = LX;
ref_idx = mv->ref_idx[LX];
pred_flag_index_l0 = LX;
pred_flag_index_l1 = !LX;
xA0 = x0 - 1;
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
xA1 = x0 - 1;
yA1 = y0 + nPbH - 1;
is_available_a1 = AVAILABLE(cand_left, A1);
if (is_available_a0 || is_available_a1)
isScaledFlag_L0 = 1;
if (is_available_a0) {
if (MP_MX(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a0) {
if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
availableFlagLXA0 = 0;
b_candidates:
xB0 = x0 + nPbW;
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
if (is_available_b0) {
if (MP_MX(B0, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B0, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
xB1 = x0 + nPbW - 1;
yB1 = y0 - 1;
is_available_b1 = AVAILABLE(cand_up, B1);
if (is_available_b1) {
if (MP_MX(B1, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B1, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
xB2 = x0 - 1;
yB2 = y0 - 1;
is_available_b2 = AVAILABLE(cand_up_left, B2);
if (is_available_b2) {
if (MP_MX(B2, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B2, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
availableFlagLXB0 = 0;
scalef:
if (!isScaledFlag_L0) {
if (availableFlagLXB0) {
availableFlagLXA0 = 1;
mxA = mxB;
}
availableFlagLXB0 = 0;
if (is_available_b0) {
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
}
if (is_available_b1 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
}
if (is_available_b2 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
}
}
if (availableFlagLXA0)
mvpcand_list[numMVPCandLX++] = mxA;
if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[numMVPCandLX++] = mxB;
if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
mvp_lx_flag == numMVPCandLX) {
Mv mv_col;
int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
nPbH, ref_idx,
&mv_col, LX);
if (available_col)
mvpcand_list[numMVPCandLX++] = mv_col;
}
mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
| {
"code": [
" xB1 = x0 + nPbW - 1;",
" yB1 = y0 - 1;",
" is_available_b1 = AVAILABLE(cand_up, B1);",
" xB2 = x0 - 1;",
" yB2 = y0 - 1;",
" is_available_b2 = AVAILABLE(cand_up_left, B2);"
],
"line_no": [
231,
233,
237,
261,
263,
265
]
} | void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6,
int VAR_7, MvField *VAR_8,
int VAR_9, int VAR_10)
{
HEVCLocalContext *lc = VAR_0->HEVClc;
MvField *tab_mvf = VAR_0->ref->tab_mvf;
int VAR_11 = 0;
int VAR_12 = 1;
int VAR_13 = 1;
int VAR_14 = 0;
int VAR_15 = VAR_0->sps->VAR_15;
int VAR_16, VAR_17;
int VAR_18;
int VAR_19, VAR_20;
int VAR_21;
int VAR_22, VAR_23;
int VAR_24;
int VAR_25, VAR_26;
int VAR_27;
int VAR_28, VAR_29;
int VAR_30;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int VAR_31 = 0;
int VAR_32 = 0;
int VAR_33;
int VAR_34;
const int VAR_35 = lc->na.VAR_35;
const int VAR_36 = lc->na.VAR_36;
const int VAR_37 = lc->na.VAR_37;
const int VAR_38 = lc->na.VAR_38;
const int VAR_39 = lc->na.cand_up_right_sap;
VAR_31 = VAR_10;
VAR_32 = VAR_8->VAR_32[VAR_10];
VAR_33 = VAR_10;
VAR_34 = !VAR_10;
VAR_16 = VAR_1 - 1;
VAR_17 = VAR_2 + VAR_4;
VAR_18 = AVAILABLE(VAR_35, A0) &&
VAR_17 < VAR_0->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
VAR_19 = VAR_1 - 1;
VAR_20 = VAR_2 + VAR_4 - 1;
VAR_21 = AVAILABLE(VAR_36, A1);
if (VAR_18 || VAR_21)
VAR_11 = 1;
if (VAR_18) {
if (MP_MX(A0, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_21) {
if (MP_MX(A1, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_18) {
if (MP_MX_LT(A0, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, VAR_34, mxA)) {
goto b_candidates;
}
}
if (VAR_21) {
if (MP_MX_LT(A1, VAR_33, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, VAR_34, mxA)) {
goto b_candidates;
}
}
VAR_12 = 0;
b_candidates:
VAR_22 = VAR_1 + VAR_3;
VAR_23 = VAR_2 - 1;
VAR_24 = AVAILABLE(VAR_39, B0) &&
VAR_22 < VAR_0->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
if (VAR_24) {
if (MP_MX(B0, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B0, VAR_34, mxB)) {
goto scalef;
}
}
VAR_25 = VAR_1 + VAR_3 - 1;
VAR_26 = VAR_2 - 1;
VAR_27 = AVAILABLE(VAR_38, B1);
if (VAR_27) {
if (MP_MX(B1, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B1, VAR_34, mxB)) {
goto scalef;
}
}
VAR_28 = VAR_1 - 1;
VAR_29 = VAR_2 - 1;
VAR_30 = AVAILABLE(VAR_37, B2);
if (VAR_30) {
if (MP_MX(B2, VAR_33, mxB)) {
goto scalef;
}
if (MP_MX(B2, VAR_34, mxB)) {
goto scalef;
}
}
VAR_13 = 0;
scalef:
if (!VAR_11) {
if (VAR_13) {
VAR_12 = 1;
mxA = mxB;
}
VAR_13 = 0;
if (VAR_24) {
VAR_13 = MP_MX_LT(B0, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B0, VAR_34, mxB);
}
if (VAR_27 && !VAR_13) {
VAR_13 = MP_MX_LT(B1, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B1, VAR_34, mxB);
}
if (VAR_30 && !VAR_13) {
VAR_13 = MP_MX_LT(B2, VAR_33, mxB);
if (!VAR_13)
VAR_13 = MP_MX_LT(B2, VAR_34, mxB);
}
}
if (VAR_12)
mvpcand_list[VAR_14++] = mxA;
if (VAR_13 && (!VAR_12 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[VAR_14++] = mxB;
if (VAR_14 < 2 && VAR_0->sh.slice_temporal_mvp_enabled_flag &&
VAR_9 == VAR_14) {
Mv mv_col;
int VAR_40 = temporal_luma_motion_vector(VAR_0, VAR_1, VAR_2, VAR_3,
VAR_4, VAR_32,
&mv_col, VAR_10);
if (VAR_40)
mvpcand_list[VAR_14++] = mv_col;
}
VAR_8->VAR_8[VAR_10] = mvpcand_list[VAR_9];
}
| [
"void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,\nint VAR_4, int VAR_5, int VAR_6,\nint VAR_7, MvField *VAR_8,\nint VAR_9, int VAR_10)\n{",
"HEVCLocalContext *lc = VAR_0->HEVClc;",
"MvField *tab_mvf = VAR_0->ref->tab_mvf;",
"int VAR_11 = 0;",
"int VAR_12 = 1;",
"int VAR_13 = 1;",
"int VAR_14 = 0;",
"int VAR_15 = VAR_0->sps->VAR_15;",
"int VAR_16, VAR_17;",
"int VAR_18;",
"int VAR_19, VAR_20;",
"int VAR_21;",
"int VAR_22, VAR_23;",
"int VAR_24;",
"int VAR_25, VAR_26;",
"int VAR_27;",
"int VAR_28, VAR_29;",
"int VAR_30;",
"Mv mvpcand_list[2] = { { 0 } };",
"Mv mxA;",
"Mv mxB;",
"int VAR_31 = 0;",
"int VAR_32 = 0;",
"int VAR_33;",
"int VAR_34;",
"const int VAR_35 = lc->na.VAR_35;",
"const int VAR_36 = lc->na.VAR_36;",
"const int VAR_37 = lc->na.VAR_37;",
"const int VAR_38 = lc->na.VAR_38;",
"const int VAR_39 = lc->na.cand_up_right_sap;",
"VAR_31 = VAR_10;",
"VAR_32 = VAR_8->VAR_32[VAR_10];",
"VAR_33 = VAR_10;",
"VAR_34 = !VAR_10;",
"VAR_16 = VAR_1 - 1;",
"VAR_17 = VAR_2 + VAR_4;",
"VAR_18 = AVAILABLE(VAR_35, A0) &&\nVAR_17 < VAR_0->sps->height &&\nPRED_BLOCK_AVAILABLE(A0);",
"VAR_19 = VAR_1 - 1;",
"VAR_20 = VAR_2 + VAR_4 - 1;",
"VAR_21 = AVAILABLE(VAR_36, A1);",
"if (VAR_18 || VAR_21)\nVAR_11 = 1;",
"if (VAR_18) {",
"if (MP_MX(A0, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX(A0, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_21) {",
"if (MP_MX(A1, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX(A1, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_18) {",
"if (MP_MX_LT(A0, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX_LT(A0, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"if (VAR_21) {",
"if (MP_MX_LT(A1, VAR_33, mxA)) {",
"goto b_candidates;",
"}",
"if (MP_MX_LT(A1, VAR_34, mxA)) {",
"goto b_candidates;",
"}",
"}",
"VAR_12 = 0;",
"b_candidates:\nVAR_22 = VAR_1 + VAR_3;",
"VAR_23 = VAR_2 - 1;",
"VAR_24 = AVAILABLE(VAR_39, B0) &&\nVAR_22 < VAR_0->sps->width &&\nPRED_BLOCK_AVAILABLE(B0);",
"if (VAR_24) {",
"if (MP_MX(B0, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B0, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"VAR_25 = VAR_1 + VAR_3 - 1;",
"VAR_26 = VAR_2 - 1;",
"VAR_27 = AVAILABLE(VAR_38, B1);",
"if (VAR_27) {",
"if (MP_MX(B1, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B1, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"VAR_28 = VAR_1 - 1;",
"VAR_29 = VAR_2 - 1;",
"VAR_30 = AVAILABLE(VAR_37, B2);",
"if (VAR_30) {",
"if (MP_MX(B2, VAR_33, mxB)) {",
"goto scalef;",
"}",
"if (MP_MX(B2, VAR_34, mxB)) {",
"goto scalef;",
"}",
"}",
"VAR_13 = 0;",
"scalef:\nif (!VAR_11) {",
"if (VAR_13) {",
"VAR_12 = 1;",
"mxA = mxB;",
"}",
"VAR_13 = 0;",
"if (VAR_24) {",
"VAR_13 = MP_MX_LT(B0, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B0, VAR_34, mxB);",
"}",
"if (VAR_27 && !VAR_13) {",
"VAR_13 = MP_MX_LT(B1, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B1, VAR_34, mxB);",
"}",
"if (VAR_30 && !VAR_13) {",
"VAR_13 = MP_MX_LT(B2, VAR_33, mxB);",
"if (!VAR_13)\nVAR_13 = MP_MX_LT(B2, VAR_34, mxB);",
"}",
"}",
"if (VAR_12)\nmvpcand_list[VAR_14++] = mxA;",
"if (VAR_13 && (!VAR_12 || mxA.x != mxB.x || mxA.y != mxB.y))\nmvpcand_list[VAR_14++] = mxB;",
"if (VAR_14 < 2 && VAR_0->sh.slice_temporal_mvp_enabled_flag &&\nVAR_9 == VAR_14) {",
"Mv mv_col;",
"int VAR_40 = temporal_luma_motion_vector(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_32,\n&mv_col, VAR_10);",
"if (VAR_40)\nmvpcand_list[VAR_14++] = mv_col;",
"}",
"VAR_8->VAR_8[VAR_10] = mvpcand_list[VAR_9];",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
93,
95,
97
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
197
],
[
199
],
[
203,
205,
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
231
],
[
233
],
[
237
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
307
],
[
309
],
[
311,
313
],
[
315
],
[
319
],
[
321
],
[
323,
325
],
[
327
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
345,
347
],
[
351,
353
],
[
359,
361
],
[
363
],
[
365,
367,
369
],
[
371,
373
],
[
375
],
[
379
],
[
381
]
] |
23,278 | static void gen_ove_cyov(DisasContext *dc, TCGv cy, TCGv ov)
{
if (dc->tb_flags & SR_OVE) {
TCGv t0 = tcg_temp_new();
tcg_gen_or_tl(t0, cy, ov);
gen_helper_ove(cpu_env, t0);
tcg_temp_free(t0);
}
}
| true | qemu | 9745807191a81c45970f780166f44a7f93b18653 | static void gen_ove_cyov(DisasContext *dc, TCGv cy, TCGv ov)
{
if (dc->tb_flags & SR_OVE) {
TCGv t0 = tcg_temp_new();
tcg_gen_or_tl(t0, cy, ov);
gen_helper_ove(cpu_env, t0);
tcg_temp_free(t0);
}
}
| {
"code": [
"static void gen_ove_cyov(DisasContext *dc, TCGv cy, TCGv ov)",
" TCGv t0 = tcg_temp_new();",
" tcg_gen_or_tl(t0, cy, ov);",
" gen_helper_ove(cpu_env, t0);",
" tcg_temp_free(t0);"
],
"line_no": [
1,
7,
9,
11,
13
]
} | static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, TCGv VAR_2)
{
if (VAR_0->tb_flags & SR_OVE) {
TCGv t0 = tcg_temp_new();
tcg_gen_or_tl(t0, VAR_1, VAR_2);
gen_helper_ove(cpu_env, t0);
tcg_temp_free(t0);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0, TCGv VAR_1, TCGv VAR_2)\n{",
"if (VAR_0->tb_flags & SR_OVE) {",
"TCGv t0 = tcg_temp_new();",
"tcg_gen_or_tl(t0, VAR_1, VAR_2);",
"gen_helper_ove(cpu_env, t0);",
"tcg_temp_free(t0);",
"}",
"}"
] | [
1,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
23,280 | static void put_uint16(QEMUFile *f, void *pv, size_t size)
{
uint16_t *v = pv;
qemu_put_be16s(f, v);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void put_uint16(QEMUFile *f, void *pv, size_t size)
{
uint16_t *v = pv;
qemu_put_be16s(f, v);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
uint16_t *v = VAR_1;
qemu_put_be16s(VAR_0, v);
}
| [
"static void FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"uint16_t *v = VAR_1;",
"qemu_put_be16s(VAR_0, v);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
23,281 | static int vqa_decode_chunk(VqaContext *s)
{
unsigned int chunk_type;
unsigned int chunk_size;
int byte_skip;
unsigned int index = 0;
int i;
unsigned char r, g, b;
int index_shift;
int res;
int cbf0_chunk = -1;
int cbfz_chunk = -1;
int cbp0_chunk = -1;
int cbpz_chunk = -1;
int cpl0_chunk = -1;
int cplz_chunk = -1;
int vptz_chunk = -1;
int x, y;
int lines = 0;
int pixel_ptr;
int vector_index = 0;
int lobyte = 0;
int hibyte = 0;
int lobytes = 0;
int hibytes = s->decode_buffer_size / 2;
/* first, traverse through the frame and find the subchunks */
while (bytestream2_get_bytes_left(&s->gb) >= 8) {
chunk_type = bytestream2_get_be32u(&s->gb);
index = bytestream2_tell(&s->gb);
chunk_size = bytestream2_get_be32u(&s->gb);
switch (chunk_type) {
case CBF0_TAG:
cbf0_chunk = index;
break;
case CBFZ_TAG:
cbfz_chunk = index;
break;
case CBP0_TAG:
cbp0_chunk = index;
break;
case CBPZ_TAG:
cbpz_chunk = index;
break;
case CPL0_TAG:
cpl0_chunk = index;
break;
case CPLZ_TAG:
cplz_chunk = index;
break;
case VPTZ_TAG:
vptz_chunk = index;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Found unknown chunk type: %c%c%c%c (%08X)\n",
(chunk_type >> 24) & 0xFF,
(chunk_type >> 16) & 0xFF,
(chunk_type >> 8) & 0xFF,
(chunk_type >> 0) & 0xFF,
chunk_type);
break;
}
byte_skip = chunk_size & 0x01;
bytestream2_skip(&s->gb, chunk_size + byte_skip);
}
/* next, deal with the palette */
if ((cpl0_chunk != -1) && (cplz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CPL0 and CPLZ chunks\n");
return AVERROR_INVALIDDATA;
}
/* decompress the palette chunk */
if (cplz_chunk != -1) {
/* yet to be handled */
}
/* convert the RGB palette into the machine's endian format */
if (cpl0_chunk != -1) {
bytestream2_seek(&s->gb, cpl0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* sanity check the palette size */
if (chunk_size / 3 > 256 || chunk_size > bytestream2_get_bytes_left(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found a palette chunk with %d colors\n",
chunk_size / 3);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < chunk_size / 3; i++) {
/* scale by 4 to transform 6-bit palette -> 8-bit */
r = bytestream2_get_byteu(&s->gb) * 4;
g = bytestream2_get_byteu(&s->gb) * 4;
b = bytestream2_get_byteu(&s->gb) * 4;
s->palette[i] = 0xFF << 24 | r << 16 | g << 8 | b;
s->palette[i] |= s->palette[i] >> 6 & 0x30303;
}
}
/* next, look for a full codebook */
if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBF0 and CBFZ chunks\n");
return AVERROR_INVALIDDATA;
}
/* decompress the full codebook chunk */
if (cbfz_chunk != -1) {
bytestream2_seek(&s->gb, cbfz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size, s->codebook,
s->codebook_size, 0)) < 0)
return res;
}
/* copy a full codebook */
if (cbf0_chunk != -1) {
bytestream2_seek(&s->gb, cbf0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* sanity check the full codebook size */
if (chunk_size > MAX_CODEBOOK_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, "problem: CBF0 chunk too large (0x%X bytes)\n",
chunk_size);
return AVERROR_INVALIDDATA;
}
bytestream2_get_buffer(&s->gb, s->codebook, chunk_size);
}
/* decode the frame */
if (vptz_chunk == -1) {
/* something is wrong if there is no VPTZ chunk */
av_log(s->avctx, AV_LOG_ERROR, "problem: no VPTZ chunk found\n");
return AVERROR_INVALIDDATA;
}
bytestream2_seek(&s->gb, vptz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size,
s->decode_buffer, s->decode_buffer_size, 1)) < 0)
return res;
/* render the final PAL8 frame */
if (s->vector_height == 4)
index_shift = 4;
else
index_shift = 3;
for (y = 0; y < s->height; y += s->vector_height) {
for (x = 0; x < s->width; x += 4, lobytes++, hibytes++) {
pixel_ptr = y * s->frame.linesize[0] + x;
/* get the vector index, the method for which varies according to
* VQA file version */
switch (s->vqa_version) {
case 1:
lobyte = s->decode_buffer[lobytes * 2];
hibyte = s->decode_buffer[(lobytes * 2) + 1];
vector_index = ((hibyte << 8) | lobyte) >> 3;
vector_index <<= index_shift;
lines = s->vector_height;
/* uniform color fill - a quick hack */
if (hibyte == 0xFF) {
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 1] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 2] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 3] = 255 - lobyte;
pixel_ptr += s->frame.linesize[0];
}
lines=0;
}
break;
case 2:
lobyte = s->decode_buffer[lobytes];
hibyte = s->decode_buffer[hibytes];
vector_index = (hibyte << 8) | lobyte;
vector_index <<= index_shift;
lines = s->vector_height;
break;
case 3:
/* not implemented yet */
lines = 0;
break;
}
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++];
pixel_ptr += s->frame.linesize[0];
}
}
}
/* handle partial codebook */
if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBP0 and CBPZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (cbp0_chunk != -1) {
bytestream2_seek(&s->gb, cbp0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
/* time to replace codebook */
memcpy(s->codebook, s->next_codebook_buffer,
s->next_codebook_buffer_index);
/* reset accounting */
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
if (cbpz_chunk != -1) {
bytestream2_seek(&s->gb, cbpz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
GetByteContext gb;
bytestream2_init(&gb, s->next_codebook_buffer, s->next_codebook_buffer_index);
/* decompress codebook */
if ((res = decode_format80(s, s->next_codebook_buffer_index,
s->codebook, s->codebook_size, 0)) < 0)
return res;
/* reset accounting */
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
return 0;
}
| true | FFmpeg | b12d92efd6c0d48665383a9baecc13e7ebbd8a22 | static int vqa_decode_chunk(VqaContext *s)
{
unsigned int chunk_type;
unsigned int chunk_size;
int byte_skip;
unsigned int index = 0;
int i;
unsigned char r, g, b;
int index_shift;
int res;
int cbf0_chunk = -1;
int cbfz_chunk = -1;
int cbp0_chunk = -1;
int cbpz_chunk = -1;
int cpl0_chunk = -1;
int cplz_chunk = -1;
int vptz_chunk = -1;
int x, y;
int lines = 0;
int pixel_ptr;
int vector_index = 0;
int lobyte = 0;
int hibyte = 0;
int lobytes = 0;
int hibytes = s->decode_buffer_size / 2;
while (bytestream2_get_bytes_left(&s->gb) >= 8) {
chunk_type = bytestream2_get_be32u(&s->gb);
index = bytestream2_tell(&s->gb);
chunk_size = bytestream2_get_be32u(&s->gb);
switch (chunk_type) {
case CBF0_TAG:
cbf0_chunk = index;
break;
case CBFZ_TAG:
cbfz_chunk = index;
break;
case CBP0_TAG:
cbp0_chunk = index;
break;
case CBPZ_TAG:
cbpz_chunk = index;
break;
case CPL0_TAG:
cpl0_chunk = index;
break;
case CPLZ_TAG:
cplz_chunk = index;
break;
case VPTZ_TAG:
vptz_chunk = index;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Found unknown chunk type: %c%c%c%c (%08X)\n",
(chunk_type >> 24) & 0xFF,
(chunk_type >> 16) & 0xFF,
(chunk_type >> 8) & 0xFF,
(chunk_type >> 0) & 0xFF,
chunk_type);
break;
}
byte_skip = chunk_size & 0x01;
bytestream2_skip(&s->gb, chunk_size + byte_skip);
}
if ((cpl0_chunk != -1) && (cplz_chunk != -1)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CPL0 and CPLZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (cplz_chunk != -1) {
}
if (cpl0_chunk != -1) {
bytestream2_seek(&s->gb, cpl0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if (chunk_size / 3 > 256 || chunk_size > bytestream2_get_bytes_left(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found a palette chunk with %d colors\n",
chunk_size / 3);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < chunk_size / 3; i++) {
r = bytestream2_get_byteu(&s->gb) * 4;
g = bytestream2_get_byteu(&s->gb) * 4;
b = bytestream2_get_byteu(&s->gb) * 4;
s->palette[i] = 0xFF << 24 | r << 16 | g << 8 | b;
s->palette[i] |= s->palette[i] >> 6 & 0x30303;
}
}
if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBF0 and CBFZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (cbfz_chunk != -1) {
bytestream2_seek(&s->gb, cbfz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size, s->codebook,
s->codebook_size, 0)) < 0)
return res;
}
if (cbf0_chunk != -1) {
bytestream2_seek(&s->gb, cbf0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if (chunk_size > MAX_CODEBOOK_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, "problem: CBF0 chunk too large (0x%X bytes)\n",
chunk_size);
return AVERROR_INVALIDDATA;
}
bytestream2_get_buffer(&s->gb, s->codebook, chunk_size);
}
if (vptz_chunk == -1) {
av_log(s->avctx, AV_LOG_ERROR, "problem: no VPTZ chunk found\n");
return AVERROR_INVALIDDATA;
}
bytestream2_seek(&s->gb, vptz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size,
s->decode_buffer, s->decode_buffer_size, 1)) < 0)
return res;
if (s->vector_height == 4)
index_shift = 4;
else
index_shift = 3;
for (y = 0; y < s->height; y += s->vector_height) {
for (x = 0; x < s->width; x += 4, lobytes++, hibytes++) {
pixel_ptr = y * s->frame.linesize[0] + x;
switch (s->vqa_version) {
case 1:
lobyte = s->decode_buffer[lobytes * 2];
hibyte = s->decode_buffer[(lobytes * 2) + 1];
vector_index = ((hibyte << 8) | lobyte) >> 3;
vector_index <<= index_shift;
lines = s->vector_height;
if (hibyte == 0xFF) {
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 1] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 2] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 3] = 255 - lobyte;
pixel_ptr += s->frame.linesize[0];
}
lines=0;
}
break;
case 2:
lobyte = s->decode_buffer[lobytes];
hibyte = s->decode_buffer[hibytes];
vector_index = (hibyte << 8) | lobyte;
vector_index <<= index_shift;
lines = s->vector_height;
break;
case 3:
lines = 0;
break;
}
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++];
pixel_ptr += s->frame.linesize[0];
}
}
}
if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBP0 and CBPZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (cbp0_chunk != -1) {
bytestream2_seek(&s->gb, cbp0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
memcpy(s->codebook, s->next_codebook_buffer,
s->next_codebook_buffer_index);
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
if (cbpz_chunk != -1) {
bytestream2_seek(&s->gb, cbpz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
GetByteContext gb;
bytestream2_init(&gb, s->next_codebook_buffer, s->next_codebook_buffer_index);
if ((res = decode_format80(s, s->next_codebook_buffer_index,
s->codebook, s->codebook_size, 0)) < 0)
return res;
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
return 0;
}
| {
"code": [
" s->palette[i] = 0xFF << 24 | r << 16 | g << 8 | b;"
],
"line_no": [
221
]
} | static int FUNC_0(VqaContext *VAR_0)
{
unsigned int VAR_1;
unsigned int VAR_2;
int VAR_3;
unsigned int VAR_4 = 0;
int VAR_5;
unsigned char VAR_6, VAR_7, VAR_8;
int VAR_9;
int VAR_10;
int VAR_11 = -1;
int VAR_12 = -1;
int VAR_13 = -1;
int VAR_14 = -1;
int VAR_15 = -1;
int VAR_16 = -1;
int VAR_17 = -1;
int VAR_18, VAR_19;
int VAR_20 = 0;
int VAR_21;
int VAR_22 = 0;
int VAR_23 = 0;
int VAR_24 = 0;
int VAR_25 = 0;
int VAR_26 = VAR_0->decode_buffer_size / 2;
while (bytestream2_get_bytes_left(&VAR_0->gb) >= 8) {
VAR_1 = bytestream2_get_be32u(&VAR_0->gb);
VAR_4 = bytestream2_tell(&VAR_0->gb);
VAR_2 = bytestream2_get_be32u(&VAR_0->gb);
switch (VAR_1) {
case CBF0_TAG:
VAR_11 = VAR_4;
break;
case CBFZ_TAG:
VAR_12 = VAR_4;
break;
case CBP0_TAG:
VAR_13 = VAR_4;
break;
case CBPZ_TAG:
VAR_14 = VAR_4;
break;
case CPL0_TAG:
VAR_15 = VAR_4;
break;
case CPLZ_TAG:
VAR_16 = VAR_4;
break;
case VPTZ_TAG:
VAR_17 = VAR_4;
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Found unknown chunk type: %c%c%c%c (%08X)\n",
(VAR_1 >> 24) & 0xFF,
(VAR_1 >> 16) & 0xFF,
(VAR_1 >> 8) & 0xFF,
(VAR_1 >> 0) & 0xFF,
VAR_1);
break;
}
VAR_3 = VAR_2 & 0x01;
bytestream2_skip(&VAR_0->gb, VAR_2 + VAR_3);
}
if ((VAR_15 != -1) && (VAR_16 != -1)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: found both CPL0 and CPLZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (VAR_16 != -1) {
}
if (VAR_15 != -1) {
bytestream2_seek(&VAR_0->gb, VAR_15, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
if (VAR_2 / 3 > 256 || VAR_2 > bytestream2_get_bytes_left(&VAR_0->gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: found a palette chunk with %d colors\n",
VAR_2 / 3);
return AVERROR_INVALIDDATA;
}
for (VAR_5 = 0; VAR_5 < VAR_2 / 3; VAR_5++) {
VAR_6 = bytestream2_get_byteu(&VAR_0->gb) * 4;
VAR_7 = bytestream2_get_byteu(&VAR_0->gb) * 4;
VAR_8 = bytestream2_get_byteu(&VAR_0->gb) * 4;
VAR_0->palette[VAR_5] = 0xFF << 24 | VAR_6 << 16 | VAR_7 << 8 | VAR_8;
VAR_0->palette[VAR_5] |= VAR_0->palette[VAR_5] >> 6 & 0x30303;
}
}
if ((VAR_11 != -1) && (VAR_12 != -1)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: found both CBF0 and CBFZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (VAR_12 != -1) {
bytestream2_seek(&VAR_0->gb, VAR_12, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
if ((VAR_10 = decode_format80(VAR_0, VAR_2, VAR_0->codebook,
VAR_0->codebook_size, 0)) < 0)
return VAR_10;
}
if (VAR_11 != -1) {
bytestream2_seek(&VAR_0->gb, VAR_11, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
if (VAR_2 > MAX_CODEBOOK_SIZE) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: CBF0 chunk too large (0x%X bytes)\n",
VAR_2);
return AVERROR_INVALIDDATA;
}
bytestream2_get_buffer(&VAR_0->gb, VAR_0->codebook, VAR_2);
}
if (VAR_17 == -1) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: no VPTZ chunk found\n");
return AVERROR_INVALIDDATA;
}
bytestream2_seek(&VAR_0->gb, VAR_17, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
if ((VAR_10 = decode_format80(VAR_0, VAR_2,
VAR_0->decode_buffer, VAR_0->decode_buffer_size, 1)) < 0)
return VAR_10;
if (VAR_0->vector_height == 4)
VAR_9 = 4;
else
VAR_9 = 3;
for (VAR_19 = 0; VAR_19 < VAR_0->height; VAR_19 += VAR_0->vector_height) {
for (VAR_18 = 0; VAR_18 < VAR_0->width; VAR_18 += 4, VAR_25++, VAR_26++) {
VAR_21 = VAR_19 * VAR_0->frame.linesize[0] + VAR_18;
switch (VAR_0->vqa_version) {
case 1:
VAR_23 = VAR_0->decode_buffer[VAR_25 * 2];
VAR_24 = VAR_0->decode_buffer[(VAR_25 * 2) + 1];
VAR_22 = ((VAR_24 << 8) | VAR_23) >> 3;
VAR_22 <<= VAR_9;
VAR_20 = VAR_0->vector_height;
if (VAR_24 == 0xFF) {
while (VAR_20--) {
VAR_0->frame.data[0][VAR_21 + 0] = 255 - VAR_23;
VAR_0->frame.data[0][VAR_21 + 1] = 255 - VAR_23;
VAR_0->frame.data[0][VAR_21 + 2] = 255 - VAR_23;
VAR_0->frame.data[0][VAR_21 + 3] = 255 - VAR_23;
VAR_21 += VAR_0->frame.linesize[0];
}
VAR_20=0;
}
break;
case 2:
VAR_23 = VAR_0->decode_buffer[VAR_25];
VAR_24 = VAR_0->decode_buffer[VAR_26];
VAR_22 = (VAR_24 << 8) | VAR_23;
VAR_22 <<= VAR_9;
VAR_20 = VAR_0->vector_height;
break;
case 3:
VAR_20 = 0;
break;
}
while (VAR_20--) {
VAR_0->frame.data[0][VAR_21 + 0] = VAR_0->codebook[VAR_22++];
VAR_0->frame.data[0][VAR_21 + 1] = VAR_0->codebook[VAR_22++];
VAR_0->frame.data[0][VAR_21 + 2] = VAR_0->codebook[VAR_22++];
VAR_0->frame.data[0][VAR_21 + 3] = VAR_0->codebook[VAR_22++];
VAR_21 += VAR_0->frame.linesize[0];
}
}
}
if ((VAR_13 != -1) && (VAR_14 != -1)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "problem: found both CBP0 and CBPZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (VAR_13 != -1) {
bytestream2_seek(&VAR_0->gb, VAR_13, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
bytestream2_get_buffer(&VAR_0->gb, &VAR_0->next_codebook_buffer[VAR_0->next_codebook_buffer_index],
VAR_2);
VAR_0->next_codebook_buffer_index += VAR_2;
VAR_0->partial_countdown--;
if (VAR_0->partial_countdown <= 0) {
memcpy(VAR_0->codebook, VAR_0->next_codebook_buffer,
VAR_0->next_codebook_buffer_index);
VAR_0->next_codebook_buffer_index = 0;
VAR_0->partial_countdown = VAR_0->partial_count;
}
}
if (VAR_14 != -1) {
bytestream2_seek(&VAR_0->gb, VAR_14, SEEK_SET);
VAR_2 = bytestream2_get_be32(&VAR_0->gb);
bytestream2_get_buffer(&VAR_0->gb, &VAR_0->next_codebook_buffer[VAR_0->next_codebook_buffer_index],
VAR_2);
VAR_0->next_codebook_buffer_index += VAR_2;
VAR_0->partial_countdown--;
if (VAR_0->partial_countdown <= 0) {
GetByteContext gb;
bytestream2_init(&gb, VAR_0->next_codebook_buffer, VAR_0->next_codebook_buffer_index);
if ((VAR_10 = decode_format80(VAR_0, VAR_0->next_codebook_buffer_index,
VAR_0->codebook, VAR_0->codebook_size, 0)) < 0)
return VAR_10;
VAR_0->next_codebook_buffer_index = 0;
VAR_0->partial_countdown = VAR_0->partial_count;
}
}
return 0;
}
| [
"static int FUNC_0(VqaContext *VAR_0)\n{",
"unsigned int VAR_1;",
"unsigned int VAR_2;",
"int VAR_3;",
"unsigned int VAR_4 = 0;",
"int VAR_5;",
"unsigned char VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"int VAR_10;",
"int VAR_11 = -1;",
"int VAR_12 = -1;",
"int VAR_13 = -1;",
"int VAR_14 = -1;",
"int VAR_15 = -1;",
"int VAR_16 = -1;",
"int VAR_17 = -1;",
"int VAR_18, VAR_19;",
"int VAR_20 = 0;",
"int VAR_21;",
"int VAR_22 = 0;",
"int VAR_23 = 0;",
"int VAR_24 = 0;",
"int VAR_25 = 0;",
"int VAR_26 = VAR_0->decode_buffer_size / 2;",
"while (bytestream2_get_bytes_left(&VAR_0->gb) >= 8) {",
"VAR_1 = bytestream2_get_be32u(&VAR_0->gb);",
"VAR_4 = bytestream2_tell(&VAR_0->gb);",
"VAR_2 = bytestream2_get_be32u(&VAR_0->gb);",
"switch (VAR_1) {",
"case CBF0_TAG:\nVAR_11 = VAR_4;",
"break;",
"case CBFZ_TAG:\nVAR_12 = VAR_4;",
"break;",
"case CBP0_TAG:\nVAR_13 = VAR_4;",
"break;",
"case CBPZ_TAG:\nVAR_14 = VAR_4;",
"break;",
"case CPL0_TAG:\nVAR_15 = VAR_4;",
"break;",
"case CPLZ_TAG:\nVAR_16 = VAR_4;",
"break;",
"case VPTZ_TAG:\nVAR_17 = VAR_4;",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Found unknown chunk type: %c%c%c%c (%08X)\\n\",\n(VAR_1 >> 24) & 0xFF,\n(VAR_1 >> 16) & 0xFF,\n(VAR_1 >> 8) & 0xFF,\n(VAR_1 >> 0) & 0xFF,\nVAR_1);",
"break;",
"}",
"VAR_3 = VAR_2 & 0x01;",
"bytestream2_skip(&VAR_0->gb, VAR_2 + VAR_3);",
"}",
"if ((VAR_15 != -1) && (VAR_16 != -1)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: found both CPL0 and CPLZ chunks\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_16 != -1) {",
"}",
"if (VAR_15 != -1) {",
"bytestream2_seek(&VAR_0->gb, VAR_15, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"if (VAR_2 / 3 > 256 || VAR_2 > bytestream2_get_bytes_left(&VAR_0->gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: found a palette chunk with %d colors\\n\",\nVAR_2 / 3);",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_2 / 3; VAR_5++) {",
"VAR_6 = bytestream2_get_byteu(&VAR_0->gb) * 4;",
"VAR_7 = bytestream2_get_byteu(&VAR_0->gb) * 4;",
"VAR_8 = bytestream2_get_byteu(&VAR_0->gb) * 4;",
"VAR_0->palette[VAR_5] = 0xFF << 24 | VAR_6 << 16 | VAR_7 << 8 | VAR_8;",
"VAR_0->palette[VAR_5] |= VAR_0->palette[VAR_5] >> 6 & 0x30303;",
"}",
"}",
"if ((VAR_11 != -1) && (VAR_12 != -1)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: found both CBF0 and CBFZ chunks\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_12 != -1) {",
"bytestream2_seek(&VAR_0->gb, VAR_12, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"if ((VAR_10 = decode_format80(VAR_0, VAR_2, VAR_0->codebook,\nVAR_0->codebook_size, 0)) < 0)\nreturn VAR_10;",
"}",
"if (VAR_11 != -1) {",
"bytestream2_seek(&VAR_0->gb, VAR_11, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"if (VAR_2 > MAX_CODEBOOK_SIZE) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: CBF0 chunk too large (0x%X bytes)\\n\",\nVAR_2);",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_get_buffer(&VAR_0->gb, VAR_0->codebook, VAR_2);",
"}",
"if (VAR_17 == -1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: no VPTZ chunk found\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_seek(&VAR_0->gb, VAR_17, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"if ((VAR_10 = decode_format80(VAR_0, VAR_2,\nVAR_0->decode_buffer, VAR_0->decode_buffer_size, 1)) < 0)\nreturn VAR_10;",
"if (VAR_0->vector_height == 4)\nVAR_9 = 4;",
"else\nVAR_9 = 3;",
"for (VAR_19 = 0; VAR_19 < VAR_0->height; VAR_19 += VAR_0->vector_height) {",
"for (VAR_18 = 0; VAR_18 < VAR_0->width; VAR_18 += 4, VAR_25++, VAR_26++) {",
"VAR_21 = VAR_19 * VAR_0->frame.linesize[0] + VAR_18;",
"switch (VAR_0->vqa_version) {",
"case 1:\nVAR_23 = VAR_0->decode_buffer[VAR_25 * 2];",
"VAR_24 = VAR_0->decode_buffer[(VAR_25 * 2) + 1];",
"VAR_22 = ((VAR_24 << 8) | VAR_23) >> 3;",
"VAR_22 <<= VAR_9;",
"VAR_20 = VAR_0->vector_height;",
"if (VAR_24 == 0xFF) {",
"while (VAR_20--) {",
"VAR_0->frame.data[0][VAR_21 + 0] = 255 - VAR_23;",
"VAR_0->frame.data[0][VAR_21 + 1] = 255 - VAR_23;",
"VAR_0->frame.data[0][VAR_21 + 2] = 255 - VAR_23;",
"VAR_0->frame.data[0][VAR_21 + 3] = 255 - VAR_23;",
"VAR_21 += VAR_0->frame.linesize[0];",
"}",
"VAR_20=0;",
"}",
"break;",
"case 2:\nVAR_23 = VAR_0->decode_buffer[VAR_25];",
"VAR_24 = VAR_0->decode_buffer[VAR_26];",
"VAR_22 = (VAR_24 << 8) | VAR_23;",
"VAR_22 <<= VAR_9;",
"VAR_20 = VAR_0->vector_height;",
"break;",
"case 3:\nVAR_20 = 0;",
"break;",
"}",
"while (VAR_20--) {",
"VAR_0->frame.data[0][VAR_21 + 0] = VAR_0->codebook[VAR_22++];",
"VAR_0->frame.data[0][VAR_21 + 1] = VAR_0->codebook[VAR_22++];",
"VAR_0->frame.data[0][VAR_21 + 2] = VAR_0->codebook[VAR_22++];",
"VAR_0->frame.data[0][VAR_21 + 3] = VAR_0->codebook[VAR_22++];",
"VAR_21 += VAR_0->frame.linesize[0];",
"}",
"}",
"}",
"if ((VAR_13 != -1) && (VAR_14 != -1)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"problem: found both CBP0 and CBPZ chunks\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_13 != -1) {",
"bytestream2_seek(&VAR_0->gb, VAR_13, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"bytestream2_get_buffer(&VAR_0->gb, &VAR_0->next_codebook_buffer[VAR_0->next_codebook_buffer_index],\nVAR_2);",
"VAR_0->next_codebook_buffer_index += VAR_2;",
"VAR_0->partial_countdown--;",
"if (VAR_0->partial_countdown <= 0) {",
"memcpy(VAR_0->codebook, VAR_0->next_codebook_buffer,\nVAR_0->next_codebook_buffer_index);",
"VAR_0->next_codebook_buffer_index = 0;",
"VAR_0->partial_countdown = VAR_0->partial_count;",
"}",
"}",
"if (VAR_14 != -1) {",
"bytestream2_seek(&VAR_0->gb, VAR_14, SEEK_SET);",
"VAR_2 = bytestream2_get_be32(&VAR_0->gb);",
"bytestream2_get_buffer(&VAR_0->gb, &VAR_0->next_codebook_buffer[VAR_0->next_codebook_buffer_index],\nVAR_2);",
"VAR_0->next_codebook_buffer_index += VAR_2;",
"VAR_0->partial_countdown--;",
"if (VAR_0->partial_countdown <= 0) {",
"GetByteContext gb;",
"bytestream2_init(&gb, VAR_0->next_codebook_buffer, VAR_0->next_codebook_buffer_index);",
"if ((VAR_10 = decode_format80(VAR_0, VAR_0->next_codebook_buffer_index,\nVAR_0->codebook, VAR_0->codebook_size, 0)) < 0)\nreturn VAR_10;",
"VAR_0->next_codebook_buffer_index = 0;",
"VAR_0->partial_countdown = VAR_0->partial_count;",
"}",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75,
77
],
[
79
],
[
83,
85
],
[
87
],
[
91,
93
],
[
95
],
[
99,
101
],
[
103
],
[
107,
109
],
[
111
],
[
115,
117
],
[
119
],
[
123,
125
],
[
127
],
[
131,
133,
135,
137,
139,
141,
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
161
],
[
167
],
[
169
],
[
171
],
[
177
],
[
185
],
[
191
],
[
195
],
[
197
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
233
],
[
239
],
[
241
],
[
243
],
[
249
],
[
253
],
[
255
],
[
257,
259,
261
],
[
263
],
[
269
],
[
273
],
[
275
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
299
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315
],
[
317,
319,
321
],
[
327,
329
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
347
],
[
351,
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389,
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
405,
409
],
[
411
],
[
413
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
439
],
[
443
],
[
445
],
[
447
],
[
451
],
[
455
],
[
457
],
[
463,
465
],
[
467
],
[
471
],
[
473
],
[
479,
481
],
[
487
],
[
489
],
[
491
],
[
493
],
[
497
],
[
501
],
[
503
],
[
509,
511
],
[
513
],
[
517
],
[
519
],
[
521
],
[
525
],
[
529,
531,
533
],
[
539
],
[
541
],
[
543
],
[
545
],
[
549
],
[
551
]
] |
23,282 | static int hls_read(URLContext *h, uint8_t *buf, int size)
{
HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
start:
if (s->seg_hd) {
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}
if (s->seg_hd) {
ffurl_close(s->seg_hd);
s->seg_hd = NULL;
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret;
/* If we need to reload the playlist again below (if
* there's still no more segments), switch to a reload
* interval of half the target duration. */
reload_interval = s->target_duration * 500000;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(h, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL);
if (ret < 0) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
}
goto start;
}
| true | FFmpeg | 8fb8d539a4c594a58df226bc1bd7a4d149f39424 | static int hls_read(URLContext *h, uint8_t *buf, int size)
{
HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
start:
if (s->seg_hd) {
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}
if (s->seg_hd) {
ffurl_close(s->seg_hd);
s->seg_hd = NULL;
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret;
reload_interval = s->target_duration * 500000;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(h, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL);
if (ret < 0) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
}
goto start;
}
| {
"code": [
" reload_interval = s->target_duration * 500000;"
],
"line_no": [
63
]
} | static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{
HLSContext *s = VAR_0->priv_data;
const char *VAR_3;
int VAR_4;
int64_t reload_interval;
start:
if (s->seg_hd) {
VAR_4 = ffurl_read(s->seg_hd, VAR_1, VAR_2);
if (VAR_4 > 0)
return VAR_4;
}
if (s->seg_hd) {
ffurl_close(s->seg_hd);
s->seg_hd = NULL;
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
if (now - s->last_load_time >= reload_interval) {
if ((VAR_4 = parse_playlist(VAR_0, s->playlisturl)) < 0)
return VAR_4;
reload_interval = s->target_duration * 500000;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(VAR_0, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&VAR_0->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
VAR_3 = s->segments[s->cur_seq_no - s->start_seq_no]->VAR_3,
av_log(VAR_0, AV_LOG_DEBUG, "opening %s\n", VAR_3);
VAR_4 = ffurl_open(&s->seg_hd, VAR_3, AVIO_FLAG_READ,
&VAR_0->interrupt_callback, NULL);
if (VAR_4 < 0) {
if (ff_check_interrupt(&VAR_0->interrupt_callback))
return AVERROR_EXIT;
av_log(VAR_0, AV_LOG_WARNING, "Unable to open %s\n", VAR_3);
s->cur_seq_no++;
goto retry;
}
goto start;
}
| [
"static int FUNC_0(URLContext *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"HLSContext *s = VAR_0->priv_data;",
"const char *VAR_3;",
"int VAR_4;",
"int64_t reload_interval;",
"start:\nif (s->seg_hd) {",
"VAR_4 = ffurl_read(s->seg_hd, VAR_1, VAR_2);",
"if (VAR_4 > 0)\nreturn VAR_4;",
"}",
"if (s->seg_hd) {",
"ffurl_close(s->seg_hd);",
"s->seg_hd = NULL;",
"s->cur_seq_no++;",
"}",
"reload_interval = s->n_segments > 0 ?\ns->segments[s->n_segments - 1]->duration :\ns->target_duration;",
"reload_interval *= 1000000;",
"retry:\nif (!s->finished) {",
"int64_t now = av_gettime();",
"if (now - s->last_load_time >= reload_interval) {",
"if ((VAR_4 = parse_playlist(VAR_0, s->playlisturl)) < 0)\nreturn VAR_4;",
"reload_interval = s->target_duration * 500000;",
"}",
"}",
"if (s->cur_seq_no < s->start_seq_no) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"skipping %d segments ahead, expired from playlist\\n\",\ns->start_seq_no - s->cur_seq_no);",
"s->cur_seq_no = s->start_seq_no;",
"}",
"if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {",
"if (s->finished)\nreturn AVERROR_EOF;",
"while (av_gettime() - s->last_load_time < reload_interval) {",
"if (ff_check_interrupt(&VAR_0->interrupt_callback))\nreturn AVERROR_EXIT;",
"av_usleep(100*1000);",
"}",
"goto retry;",
"}",
"VAR_3 = s->segments[s->cur_seq_no - s->start_seq_no]->VAR_3,\nav_log(VAR_0, AV_LOG_DEBUG, \"opening %s\\n\", VAR_3);",
"VAR_4 = ffurl_open(&s->seg_hd, VAR_3, AVIO_FLAG_READ,\n&VAR_0->interrupt_callback, NULL);",
"if (VAR_4 < 0) {",
"if (ff_check_interrupt(&VAR_0->interrupt_callback))\nreturn AVERROR_EXIT;",
"av_log(VAR_0, AV_LOG_WARNING, \"Unable to open %s\\n\", VAR_3);",
"s->cur_seq_no++;",
"goto retry;",
"}",
"goto start;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
],
[
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
]
] |
23,283 | static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets, int w, int h)
{
int x, y;
int offset = ((offsets + offsetd + 1) | 1) << log2_denom;
asm volatile(
"movd %0, %%mm3 \n\t"
"movd %1, %%mm4 \n\t"
"movd %2, %%mm5 \n\t"
"movd %3, %%mm6 \n\t"
"pshufw $0, %%mm3, %%mm3 \n\t"
"pshufw $0, %%mm4, %%mm4 \n\t"
"pshufw $0, %%mm5, %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
:: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1)
);
for(y=0; y<h; y++){
for(x=0; x<w; x+=4){
asm volatile(
"movd %0, %%mm0 \n\t"
"movd %1, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"pmullw %%mm4, %%mm1 \n\t"
"paddw %%mm5, %%mm0 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"psraw %%mm6, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, %0 \n\t"
: "+m"(*(uint32_t*)(dst+x))
: "m"(*(uint32_t*)(src+x))
);
}
src += stride;
dst += stride;
}
}
| true | FFmpeg | cec939597722663f322941b4c12e00a583e63504 | static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets, int w, int h)
{
int x, y;
int offset = ((offsets + offsetd + 1) | 1) << log2_denom;
asm volatile(
"movd %0, %%mm3 \n\t"
"movd %1, %%mm4 \n\t"
"movd %2, %%mm5 \n\t"
"movd %3, %%mm6 \n\t"
"pshufw $0, %%mm3, %%mm3 \n\t"
"pshufw $0, %%mm4, %%mm4 \n\t"
"pshufw $0, %%mm5, %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
:: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1)
);
for(y=0; y<h; y++){
for(x=0; x<w; x+=4){
asm volatile(
"movd %0, %%mm0 \n\t"
"movd %1, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"pmullw %%mm4, %%mm1 \n\t"
"paddw %%mm5, %%mm0 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"psraw %%mm6, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, %0 \n\t"
: "+m"(*(uint32_t*)(dst+x))
: "m"(*(uint32_t*)(src+x))
);
}
src += stride;
dst += stride;
}
}
| {
"code": [
" \"paddw %%mm5, %%mm0 \\n\\t\"",
" \"paddw %%mm5, %%mm0 \\n\\t\"",
" \"paddw %%mm1, %%mm0 \\n\\t\""
],
"line_no": [
49,
49,
51
]
} | static inline void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9)
{
int VAR_10, VAR_11;
int VAR_12 = ((VAR_7 + VAR_6 + 1) | 1) << VAR_3;
asm volatile(
"movd %0, %%mm3 \n\t"
"movd %1, %%mm4 \n\t"
"movd %2, %%mm5 \n\t"
"movd %3, %%mm6 \n\t"
"pshufw $0, %%mm3, %%mm3 \n\t"
"pshufw $0, %%mm4, %%mm4 \n\t"
"pshufw $0, %%mm5, %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
:: "g"(VAR_4), "g"(VAR_5), "g"(VAR_12), "g"(VAR_3+1)
);
for(VAR_11=0; VAR_11<VAR_9; VAR_11++){
for(VAR_10=0; VAR_10<VAR_8; VAR_10+=4){
asm volatile(
"movd %0, %%mm0 \n\t"
"movd %1, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"pmullw %%mm4, %%mm1 \n\t"
"paddw %%mm5, %%mm0 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"psraw %%mm6, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, %0 \n\t"
: "+m"(*(uint32_t*)(VAR_0+VAR_10))
: "m"(*(uint32_t*)(VAR_1+VAR_10))
);
}
VAR_1 += VAR_2;
VAR_0 += VAR_2;
}
}
| [
"static inline void FUNC_0(uint8_t *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9)\n{",
"int VAR_10, VAR_11;",
"int VAR_12 = ((VAR_7 + VAR_6 + 1) | 1) << VAR_3;",
"asm volatile(\n\"movd %0, %%mm3 \\n\\t\"\n\"movd %1, %%mm4 \\n\\t\"\n\"movd %2, %%mm5 \\n\\t\"\n\"movd %3, %%mm6 \\n\\t\"\n\"pshufw $0, %%mm3, %%mm3 \\n\\t\"\n\"pshufw $0, %%mm4, %%mm4 \\n\\t\"\n\"pshufw $0, %%mm5, %%mm5 \\n\\t\"\n\"pxor %%mm7, %%mm7 \\n\\t\"\n:: \"g\"(VAR_4), \"g\"(VAR_5), \"g\"(VAR_12), \"g\"(VAR_3+1)\n);",
"for(VAR_11=0; VAR_11<VAR_9; VAR_11++){",
"for(VAR_10=0; VAR_10<VAR_8; VAR_10+=4){",
"asm volatile(\n\"movd %0, %%mm0 \\n\\t\"\n\"movd %1, %%mm1 \\n\\t\"\n\"punpcklbw %%mm7, %%mm0 \\n\\t\"\n\"punpcklbw %%mm7, %%mm1 \\n\\t\"\n\"pmullw %%mm3, %%mm0 \\n\\t\"\n\"pmullw %%mm4, %%mm1 \\n\\t\"\n\"paddw %%mm5, %%mm0 \\n\\t\"\n\"paddw %%mm1, %%mm0 \\n\\t\"\n\"psraw %%mm6, %%mm0 \\n\\t\"\n\"packuswb %%mm0, %%mm0 \\n\\t\"\n\"movd %%mm0, %0 \\n\\t\"\n: \"+m\"(*(uint32_t*)(VAR_0+VAR_10))\n: \"m\"(*(uint32_t*)(VAR_1+VAR_10))\n);",
"}",
"VAR_1 += VAR_2;",
"VAR_0 += VAR_2;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29
],
[
31
],
[
33
],
[
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
23,284 | static int dpx_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
if (AV_RN32(b) == AV_RN32("SDPX") || AV_RN32(b) == AV_RN32("XPDS"))
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| true | FFmpeg | 41ee459e88093a0b7ae13b8539ed9ccd0ebd0f0b | static int dpx_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
if (AV_RN32(b) == AV_RN32("SDPX") || AV_RN32(b) == AV_RN32("XPDS"))
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| {
"code": [
" if (AV_RN32(b) == AV_RN32(\"SDPX\") || AV_RN32(b) == AV_RN32(\"XPDS\"))"
],
"line_no": [
9
]
} | static int FUNC_0(AVProbeData *VAR_0)
{
const uint8_t *VAR_1 = VAR_0->buf;
if (AV_RN32(VAR_1) == AV_RN32("SDPX") || AV_RN32(VAR_1) == AV_RN32("XPDS"))
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"const uint8_t *VAR_1 = VAR_0->buf;",
"if (AV_RN32(VAR_1) == AV_RN32(\"SDPX\") || AV_RN32(VAR_1) == AV_RN32(\"XPDS\"))\nreturn AVPROBE_SCORE_EXTENSION + 1;",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
]
] |
23,285 | static int yop_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
YopDecContext *yop = s->priv_data;
int64_t frame_pos, pos_min, pos_max;
int frame_count;
av_free_packet(&yop->video_packet);
if (!stream_index)
return -1;
pos_min = s->data_offset;
pos_max = avio_size(s->pb) - yop->frame_size;
frame_count = (pos_max - pos_min) / yop->frame_size;
timestamp = FFMAX(0, FFMIN(frame_count, timestamp));
frame_pos = timestamp * yop->frame_size + pos_min;
yop->odd_frame = timestamp & 1;
avio_seek(s->pb, frame_pos, SEEK_SET);
return 0;
}
| true | FFmpeg | b69c2e0e6dab87bb90fece1d0de47c28394aa8e6 | static int yop_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
YopDecContext *yop = s->priv_data;
int64_t frame_pos, pos_min, pos_max;
int frame_count;
av_free_packet(&yop->video_packet);
if (!stream_index)
return -1;
pos_min = s->data_offset;
pos_max = avio_size(s->pb) - yop->frame_size;
frame_count = (pos_max - pos_min) / yop->frame_size;
timestamp = FFMAX(0, FFMIN(frame_count, timestamp));
frame_pos = timestamp * yop->frame_size + pos_min;
yop->odd_frame = timestamp & 1;
avio_seek(s->pb, frame_pos, SEEK_SET);
return 0;
}
| {
"code": [
" av_free_packet(&yop->video_packet);",
" avio_seek(s->pb, frame_pos, SEEK_SET);"
],
"line_no": [
15,
43
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int VAR_3)
{
YopDecContext *yop = VAR_0->priv_data;
int64_t frame_pos, pos_min, pos_max;
int VAR_4;
av_free_packet(&yop->video_packet);
if (!VAR_1)
return -1;
pos_min = VAR_0->data_offset;
pos_max = avio_size(VAR_0->pb) - yop->frame_size;
VAR_4 = (pos_max - pos_min) / yop->frame_size;
VAR_2 = FFMAX(0, FFMIN(VAR_4, VAR_2));
frame_pos = VAR_2 * yop->frame_size + pos_min;
yop->odd_frame = VAR_2 & 1;
avio_seek(VAR_0->pb, frame_pos, SEEK_SET);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nint64_t VAR_2, int VAR_3)\n{",
"YopDecContext *yop = VAR_0->priv_data;",
"int64_t frame_pos, pos_min, pos_max;",
"int VAR_4;",
"av_free_packet(&yop->video_packet);",
"if (!VAR_1)\nreturn -1;",
"pos_min = VAR_0->data_offset;",
"pos_max = avio_size(VAR_0->pb) - yop->frame_size;",
"VAR_4 = (pos_max - pos_min) / yop->frame_size;",
"VAR_2 = FFMAX(0, FFMIN(VAR_4, VAR_2));",
"frame_pos = VAR_2 * yop->frame_size + pos_min;",
"yop->odd_frame = VAR_2 & 1;",
"avio_seek(VAR_0->pb, frame_pos, SEEK_SET);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
]
] |
23,287 | static int film_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb;
film_sample *sample;
int ret = 0;
int i;
int left, right;
if (film->current_sample >= film->sample_count)
return AVERROR(EIO);
sample = &film->sample_table[film->current_sample];
/* position the stream (will probably be there anyway) */
avio_seek(pb, sample->sample_offset, SEEK_SET);
/* do a special song and dance when loading FILM Cinepak chunks */
if ((sample->stream == film->video_stream_index) &&
(film->video_type == AV_CODEC_ID_CINEPAK)) {
pkt->pos= avio_tell(pb);
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2) &&
(film->audio_type != AV_CODEC_ID_ADPCM_ADX)) {
/* stereo PCM needs to be interleaved */
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
/* make sure the interleave buffer is large enough */
if (sample->sample_size > film->stereo_buffer_size) {
av_free(film->stereo_buffer);
film->stereo_buffer_size = sample->sample_size;
film->stereo_buffer = av_malloc(film->stereo_buffer_size);
if (!film->stereo_buffer) {
film->stereo_buffer_size = 0;
return AVERROR(ENOMEM);
}
}
pkt->pos= avio_tell(pb);
ret = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
left = 0;
right = sample->sample_size / 2;
for (i = 0; i < sample->sample_size; ) {
if (film->audio_bits == 8) {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
} else {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
pkt->data[i++] = film->stereo_buffer[right++];
}
}
} else {
ret= av_get_packet(pb, pkt, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
}
pkt->stream_index = sample->stream;
pkt->pts = sample->pts;
film->current_sample++;
return ret;
}
| false | FFmpeg | ded5957d75def70d2f1fc1c1eae079230004974b | static int film_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb;
film_sample *sample;
int ret = 0;
int i;
int left, right;
if (film->current_sample >= film->sample_count)
return AVERROR(EIO);
sample = &film->sample_table[film->current_sample];
avio_seek(pb, sample->sample_offset, SEEK_SET);
if ((sample->stream == film->video_stream_index) &&
(film->video_type == AV_CODEC_ID_CINEPAK)) {
pkt->pos= avio_tell(pb);
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2) &&
(film->audio_type != AV_CODEC_ID_ADPCM_ADX)) {
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
if (sample->sample_size > film->stereo_buffer_size) {
av_free(film->stereo_buffer);
film->stereo_buffer_size = sample->sample_size;
film->stereo_buffer = av_malloc(film->stereo_buffer_size);
if (!film->stereo_buffer) {
film->stereo_buffer_size = 0;
return AVERROR(ENOMEM);
}
}
pkt->pos= avio_tell(pb);
ret = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
left = 0;
right = sample->sample_size / 2;
for (i = 0; i < sample->sample_size; ) {
if (film->audio_bits == 8) {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
} else {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
pkt->data[i++] = film->stereo_buffer[right++];
}
}
} else {
ret= av_get_packet(pb, pkt, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
}
pkt->stream_index = sample->stream;
pkt->pts = sample->pts;
film->current_sample++;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
FilmDemuxContext *film = VAR_0->priv_data;
AVIOContext *pb = VAR_0->pb;
film_sample *sample;
int VAR_2 = 0;
int VAR_3;
int VAR_4, VAR_5;
if (film->current_sample >= film->sample_count)
return AVERROR(EIO);
sample = &film->sample_table[film->current_sample];
avio_seek(pb, sample->sample_offset, SEEK_SET);
if ((sample->stream == film->video_stream_index) &&
(film->video_type == AV_CODEC_ID_CINEPAK)) {
VAR_1->pos= avio_tell(pb);
if (av_new_packet(VAR_1, sample->sample_size))
return AVERROR(ENOMEM);
avio_read(pb, VAR_1->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2) &&
(film->audio_type != AV_CODEC_ID_ADPCM_ADX)) {
if (av_new_packet(VAR_1, sample->sample_size))
return AVERROR(ENOMEM);
if (sample->sample_size > film->stereo_buffer_size) {
av_free(film->stereo_buffer);
film->stereo_buffer_size = sample->sample_size;
film->stereo_buffer = av_malloc(film->stereo_buffer_size);
if (!film->stereo_buffer) {
film->stereo_buffer_size = 0;
return AVERROR(ENOMEM);
}
}
VAR_1->pos= avio_tell(pb);
VAR_2 = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (VAR_2 != sample->sample_size)
VAR_2 = AVERROR(EIO);
VAR_4 = 0;
VAR_5 = sample->sample_size / 2;
for (VAR_3 = 0; VAR_3 < sample->sample_size; ) {
if (film->audio_bits == 8) {
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];
} else {
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];
VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];
}
}
} else {
VAR_2= av_get_packet(pb, VAR_1, sample->sample_size);
if (VAR_2 != sample->sample_size)
VAR_2 = AVERROR(EIO);
}
VAR_1->stream_index = sample->stream;
VAR_1->pts = sample->pts;
film->current_sample++;
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"FilmDemuxContext *film = VAR_0->priv_data;",
"AVIOContext *pb = VAR_0->pb;",
"film_sample *sample;",
"int VAR_2 = 0;",
"int VAR_3;",
"int VAR_4, VAR_5;",
"if (film->current_sample >= film->sample_count)\nreturn AVERROR(EIO);",
"sample = &film->sample_table[film->current_sample];",
"avio_seek(pb, sample->sample_offset, SEEK_SET);",
"if ((sample->stream == film->video_stream_index) &&\n(film->video_type == AV_CODEC_ID_CINEPAK)) {",
"VAR_1->pos= avio_tell(pb);",
"if (av_new_packet(VAR_1, sample->sample_size))\nreturn AVERROR(ENOMEM);",
"avio_read(pb, VAR_1->data, sample->sample_size);",
"} else if ((sample->stream == film->audio_stream_index) &&",
"(film->audio_channels == 2) &&\n(film->audio_type != AV_CODEC_ID_ADPCM_ADX)) {",
"if (av_new_packet(VAR_1, sample->sample_size))\nreturn AVERROR(ENOMEM);",
"if (sample->sample_size > film->stereo_buffer_size) {",
"av_free(film->stereo_buffer);",
"film->stereo_buffer_size = sample->sample_size;",
"film->stereo_buffer = av_malloc(film->stereo_buffer_size);",
"if (!film->stereo_buffer) {",
"film->stereo_buffer_size = 0;",
"return AVERROR(ENOMEM);",
"}",
"}",
"VAR_1->pos= avio_tell(pb);",
"VAR_2 = avio_read(pb, film->stereo_buffer, sample->sample_size);",
"if (VAR_2 != sample->sample_size)\nVAR_2 = AVERROR(EIO);",
"VAR_4 = 0;",
"VAR_5 = sample->sample_size / 2;",
"for (VAR_3 = 0; VAR_3 < sample->sample_size; ) {",
"if (film->audio_bits == 8) {",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];",
"} else {",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_4++];",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];",
"VAR_1->data[VAR_3++] = film->stereo_buffer[VAR_5++];",
"}",
"}",
"} else {",
"VAR_2= av_get_packet(pb, VAR_1, sample->sample_size);",
"if (VAR_2 != sample->sample_size)\nVAR_2 = AVERROR(EIO);",
"}",
"VAR_1->stream_index = sample->stream;",
"VAR_1->pts = sample->pts;",
"film->current_sample++;",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
33
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53,
55
],
[
61,
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
137
],
[
139
],
[
143
],
[
147
],
[
149
]
] |
23,288 | void qdist_init(struct qdist *dist)
{
dist->entries = g_malloc(sizeof(*dist->entries));
dist->size = 1;
dist->n = 0;
}
| true | qemu | 071d4054770205ddb8a58a9e2735069d8fe52af1 | void qdist_init(struct qdist *dist)
{
dist->entries = g_malloc(sizeof(*dist->entries));
dist->size = 1;
dist->n = 0;
}
| {
"code": [
" dist->entries = g_malloc(sizeof(*dist->entries));"
],
"line_no": [
5
]
} | void FUNC_0(struct qdist *VAR_0)
{
VAR_0->entries = g_malloc(sizeof(*VAR_0->entries));
VAR_0->size = 1;
VAR_0->n = 0;
}
| [
"void FUNC_0(struct qdist *VAR_0)\n{",
"VAR_0->entries = g_malloc(sizeof(*VAR_0->entries));",
"VAR_0->size = 1;",
"VAR_0->n = 0;",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
23,289 | void arm_v7m_cpu_do_interrupt(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t lr;
arm_log_exception(cs->exception_index);
/* For exceptions we just mark as pending on the NVIC, and let that
handle it. */
switch (cs->exception_index) {
case EXCP_UDEF:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
break;
case EXCP_NOCP:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
break;
case EXCP_INVSTATE:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
break;
case EXCP_SWI:
/* The PC already points to the next instruction. */
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
break;
case EXCP_PREFETCH_ABORT:
case EXCP_DATA_ABORT:
/* Note that for M profile we don't have a guest facing FSR, but
* the env->exception.fsr will be populated by the code that
* raises the fault, in the A profile short-descriptor format.
*/
switch (env->exception.fsr & 0xf) {
case 0x8: /* External Abort */
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[M_REG_NS] |=
(R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK);
env->v7m.bfar = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.PRECISERR and BFAR 0x%x\n",
env->v7m.bfar);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
break;
default:
/* All other FSR values are either MPU faults or "can't happen
* for M profile" cases.
*/
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[env->v7m.secure] |=
(R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK);
env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.DACCVIOL and MMFAR 0x%x\n",
env->v7m.mmfar[env->v7m.secure]);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,
env->v7m.secure);
break;
}
break;
case EXCP_BKPT:
if (semihosting_enabled()) {
int nr;
nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;
if (nr == 0xab) {
env->regs[15] += 2;
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%x\n",
env->regs[0]);
env->regs[0] = do_arm_semihosting(env);
return;
}
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
break;
case EXCP_IRQ:
break;
case EXCP_EXCEPTION_EXIT:
do_v7m_exception_exit(cpu);
return;
default:
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
return; /* Never happens. Keep compiler happy. */
}
lr = R_V7M_EXCRET_RES1_MASK |
R_V7M_EXCRET_S_MASK |
R_V7M_EXCRET_DCRS_MASK |
R_V7M_EXCRET_FTYPE_MASK |
R_V7M_EXCRET_ES_MASK;
if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {
lr |= R_V7M_EXCRET_SPSEL_MASK;
}
if (!arm_v7m_is_handler_mode(env)) {
lr |= R_V7M_EXCRET_MODE_MASK;
}
v7m_push_stack(cpu);
v7m_exception_taken(cpu, lr);
qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception);
}
| true | qemu | d3392718e1fcf0859fb7c0774a8e946bacb8419c | void arm_v7m_cpu_do_interrupt(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t lr;
arm_log_exception(cs->exception_index);
switch (cs->exception_index) {
case EXCP_UDEF:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
break;
case EXCP_NOCP:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
break;
case EXCP_INVSTATE:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
break;
case EXCP_SWI:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
break;
case EXCP_PREFETCH_ABORT:
case EXCP_DATA_ABORT:
switch (env->exception.fsr & 0xf) {
case 0x8:
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[M_REG_NS] |=
(R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK);
env->v7m.bfar = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.PRECISERR and BFAR 0x%x\n",
env->v7m.bfar);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
break;
default:
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[env->v7m.secure] |=
(R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK);
env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.DACCVIOL and MMFAR 0x%x\n",
env->v7m.mmfar[env->v7m.secure]);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,
env->v7m.secure);
break;
}
break;
case EXCP_BKPT:
if (semihosting_enabled()) {
int nr;
nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;
if (nr == 0xab) {
env->regs[15] += 2;
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%x\n",
env->regs[0]);
env->regs[0] = do_arm_semihosting(env);
return;
}
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
break;
case EXCP_IRQ:
break;
case EXCP_EXCEPTION_EXIT:
do_v7m_exception_exit(cpu);
return;
default:
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
return;
}
lr = R_V7M_EXCRET_RES1_MASK |
R_V7M_EXCRET_S_MASK |
R_V7M_EXCRET_DCRS_MASK |
R_V7M_EXCRET_FTYPE_MASK |
R_V7M_EXCRET_ES_MASK;
if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {
lr |= R_V7M_EXCRET_SPSEL_MASK;
}
if (!arm_v7m_is_handler_mode(env)) {
lr |= R_V7M_EXCRET_MODE_MASK;
}
v7m_push_stack(cpu);
v7m_exception_taken(cpu, lr);
qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception);
}
| {
"code": [
" lr = R_V7M_EXCRET_RES1_MASK |",
" R_V7M_EXCRET_S_MASK |",
" R_V7M_EXCRET_DCRS_MASK |",
" R_V7M_EXCRET_FTYPE_MASK |",
" R_V7M_EXCRET_ES_MASK;",
" if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {",
" lr |= R_V7M_EXCRET_SPSEL_MASK;",
" v7m_exception_taken(cpu, lr);"
],
"line_no": [
199,
201,
203,
205,
207,
209,
211,
225
]
} | void FUNC_0(CPUState *VAR_0)
{
ARMCPU *cpu = ARM_CPU(VAR_0);
CPUARMState *env = &cpu->env;
uint32_t lr;
arm_log_exception(VAR_0->exception_index);
switch (VAR_0->exception_index) {
case EXCP_UDEF:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
break;
case EXCP_NOCP:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
break;
case EXCP_INVSTATE:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
break;
case EXCP_SWI:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
break;
case EXCP_PREFETCH_ABORT:
case EXCP_DATA_ABORT:
switch (env->exception.fsr & 0xf) {
case 0x8:
switch (VAR_0->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[M_REG_NS] |=
(R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK);
env->v7m.bfar = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.PRECISERR and BFAR 0x%x\n",
env->v7m.bfar);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
break;
default:
switch (VAR_0->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[env->v7m.secure] |=
(R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK);
env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.DACCVIOL and MMFAR 0x%x\n",
env->v7m.mmfar[env->v7m.secure]);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,
env->v7m.secure);
break;
}
break;
case EXCP_BKPT:
if (semihosting_enabled()) {
int VAR_1;
VAR_1 = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;
if (VAR_1 == 0xab) {
env->regs[15] += 2;
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%x\n",
env->regs[0]);
env->regs[0] = do_arm_semihosting(env);
return;
}
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
break;
case EXCP_IRQ:
break;
case EXCP_EXCEPTION_EXIT:
do_v7m_exception_exit(cpu);
return;
default:
cpu_abort(VAR_0, "Unhandled exception 0x%x\n", VAR_0->exception_index);
return;
}
lr = R_V7M_EXCRET_RES1_MASK |
R_V7M_EXCRET_S_MASK |
R_V7M_EXCRET_DCRS_MASK |
R_V7M_EXCRET_FTYPE_MASK |
R_V7M_EXCRET_ES_MASK;
if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {
lr |= R_V7M_EXCRET_SPSEL_MASK;
}
if (!arm_v7m_is_handler_mode(env)) {
lr |= R_V7M_EXCRET_MODE_MASK;
}
v7m_push_stack(cpu);
v7m_exception_taken(cpu, lr);
qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception);
}
| [
"void FUNC_0(CPUState *VAR_0)\n{",
"ARMCPU *cpu = ARM_CPU(VAR_0);",
"CPUARMState *env = &cpu->env;",
"uint32_t lr;",
"arm_log_exception(VAR_0->exception_index);",
"switch (VAR_0->exception_index) {",
"case EXCP_UDEF:\narmv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);",
"env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;",
"break;",
"case EXCP_NOCP:\narmv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);",
"env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;",
"break;",
"case EXCP_INVSTATE:\narmv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);",
"env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;",
"break;",
"case EXCP_SWI:\narmv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);",
"break;",
"case EXCP_PREFETCH_ABORT:\ncase EXCP_DATA_ABORT:\nswitch (env->exception.fsr & 0xf) {",
"case 0x8:\nswitch (VAR_0->exception_index) {",
"case EXCP_PREFETCH_ABORT:\nenv->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;",
"qemu_log_mask(CPU_LOG_INT, \"...with CFSR.IBUSERR\\n\");",
"break;",
"case EXCP_DATA_ABORT:\nenv->v7m.cfsr[M_REG_NS] |=\n(R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK);",
"env->v7m.bfar = env->exception.vaddress;",
"qemu_log_mask(CPU_LOG_INT,\n\"...with CFSR.PRECISERR and BFAR 0x%x\\n\",\nenv->v7m.bfar);",
"break;",
"}",
"armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);",
"break;",
"default:\nswitch (VAR_0->exception_index) {",
"case EXCP_PREFETCH_ABORT:\nenv->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;",
"qemu_log_mask(CPU_LOG_INT, \"...with CFSR.IACCVIOL\\n\");",
"break;",
"case EXCP_DATA_ABORT:\nenv->v7m.cfsr[env->v7m.secure] |=\n(R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK);",
"env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress;",
"qemu_log_mask(CPU_LOG_INT,\n\"...with CFSR.DACCVIOL and MMFAR 0x%x\\n\",\nenv->v7m.mmfar[env->v7m.secure]);",
"break;",
"}",
"armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,\nenv->v7m.secure);",
"break;",
"}",
"break;",
"case EXCP_BKPT:\nif (semihosting_enabled()) {",
"int VAR_1;",
"VAR_1 = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;",
"if (VAR_1 == 0xab) {",
"env->regs[15] += 2;",
"qemu_log_mask(CPU_LOG_INT,\n\"...handling as semihosting call 0x%x\\n\",\nenv->regs[0]);",
"env->regs[0] = do_arm_semihosting(env);",
"return;",
"}",
"}",
"armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);",
"break;",
"case EXCP_IRQ:\nbreak;",
"case EXCP_EXCEPTION_EXIT:\ndo_v7m_exception_exit(cpu);",
"return;",
"default:\ncpu_abort(VAR_0, \"Unhandled exception 0x%x\\n\", VAR_0->exception_index);",
"return;",
"}",
"lr = R_V7M_EXCRET_RES1_MASK |\nR_V7M_EXCRET_S_MASK |\nR_V7M_EXCRET_DCRS_MASK |\nR_V7M_EXCRET_FTYPE_MASK |\nR_V7M_EXCRET_ES_MASK;",
"if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {",
"lr |= R_V7M_EXCRET_SPSEL_MASK;",
"}",
"if (!arm_v7m_is_handler_mode(env)) {",
"lr |= R_V7M_EXCRET_MODE_MASK;",
"}",
"v7m_push_stack(cpu);",
"v7m_exception_taken(cpu, lr);",
"qemu_log_mask(CPU_LOG_INT, \"... as %d\\n\", env->v7m.exception);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
51
],
[
53
],
[
55,
57,
67
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83,
85
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
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
],
[
199,
201,
203,
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
]
] |
23,290 | static void socket_sendf(int fd, const char *fmt, va_list ap)
{
gchar *str;
size_t size, offset;
str = g_strdup_vprintf(fmt, ap);
size = strlen(str);
offset = 0;
while (offset < size) {
ssize_t len;
len = write(fd, str + offset, size - offset);
if (len == -1 && errno == EINTR) {
continue;
}
g_assert_no_errno(len);
g_assert_cmpint(len, >, 0);
offset += len;
}
}
| true | qemu | 563890c7c7e977842e2a35afe7a24d06d2103242 | static void socket_sendf(int fd, const char *fmt, va_list ap)
{
gchar *str;
size_t size, offset;
str = g_strdup_vprintf(fmt, ap);
size = strlen(str);
offset = 0;
while (offset < size) {
ssize_t len;
len = write(fd, str + offset, size - offset);
if (len == -1 && errno == EINTR) {
continue;
}
g_assert_no_errno(len);
g_assert_cmpint(len, >, 0);
offset += len;
}
}
| {
"code": [
"static void socket_sendf(int fd, const char *fmt, va_list ap)",
" gchar *str;",
" size_t size, offset;",
" str = g_strdup_vprintf(fmt, ap);",
" size = strlen(str);",
" len = write(fd, str + offset, size - offset);"
],
"line_no": [
1,
5,
7,
11,
13,
25
]
} | static void FUNC_0(int VAR_0, const char *VAR_1, va_list VAR_2)
{
gchar *str;
size_t size, offset;
str = g_strdup_vprintf(VAR_1, VAR_2);
size = strlen(str);
offset = 0;
while (offset < size) {
ssize_t len;
len = write(VAR_0, str + offset, size - offset);
if (len == -1 && errno == EINTR) {
continue;
}
g_assert_no_errno(len);
g_assert_cmpint(len, >, 0);
offset += len;
}
}
| [
"static void FUNC_0(int VAR_0, const char *VAR_1, va_list VAR_2)\n{",
"gchar *str;",
"size_t size, offset;",
"str = g_strdup_vprintf(VAR_1, VAR_2);",
"size = strlen(str);",
"offset = 0;",
"while (offset < size) {",
"ssize_t len;",
"len = write(VAR_0, str + offset, size - offset);",
"if (len == -1 && errno == EINTR) {",
"continue;",
"}",
"g_assert_no_errno(len);",
"g_assert_cmpint(len, >, 0);",
"offset += len;",
"}",
"}"
] | [
1,
1,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
]
] |
23,291 | int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
{
uint64_t features;
int r;
if (devfd >= 0) {
hdev->control = devfd;
} else {
hdev->control = open("/dev/vhost-net", O_RDWR);
if (hdev->control < 0) {
return -errno;
}
}
r = ioctl(hdev->control, VHOST_SET_OWNER, NULL);
if (r < 0) {
goto fail;
}
r = ioctl(hdev->control, VHOST_GET_FEATURES, &features);
if (r < 0) {
goto fail;
}
hdev->features = features;
hdev->client.set_memory = vhost_client_set_memory;
hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
hdev->client.migration_log = vhost_client_migration_log;
hdev->client.log_start = NULL;
hdev->client.log_stop = NULL;
hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
hdev->log = NULL;
hdev->log_size = 0;
hdev->log_enabled = false;
hdev->started = false;
cpu_register_phys_memory_client(&hdev->client);
hdev->force = force;
return 0;
fail:
r = -errno;
close(hdev->control);
return r;
}
| true | qemu | 04097f7c5957273c578f72b9bd603ba6b1d69e33 | int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
{
uint64_t features;
int r;
if (devfd >= 0) {
hdev->control = devfd;
} else {
hdev->control = open("/dev/vhost-net", O_RDWR);
if (hdev->control < 0) {
return -errno;
}
}
r = ioctl(hdev->control, VHOST_SET_OWNER, NULL);
if (r < 0) {
goto fail;
}
r = ioctl(hdev->control, VHOST_GET_FEATURES, &features);
if (r < 0) {
goto fail;
}
hdev->features = features;
hdev->client.set_memory = vhost_client_set_memory;
hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
hdev->client.migration_log = vhost_client_migration_log;
hdev->client.log_start = NULL;
hdev->client.log_stop = NULL;
hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
hdev->log = NULL;
hdev->log_size = 0;
hdev->log_enabled = false;
hdev->started = false;
cpu_register_phys_memory_client(&hdev->client);
hdev->force = force;
return 0;
fail:
r = -errno;
close(hdev->control);
return r;
}
| {
"code": [
" hdev->client.set_memory = vhost_client_set_memory;",
" hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;",
" hdev->client.migration_log = vhost_client_migration_log;",
" hdev->client.log_start = NULL;",
" hdev->client.log_stop = NULL;",
" cpu_register_phys_memory_client(&hdev->client);"
],
"line_no": [
47,
49,
51,
53,
55,
67
]
} | int FUNC_0(struct vhost_dev *VAR_0, int VAR_1, bool VAR_2)
{
uint64_t features;
int VAR_3;
if (VAR_1 >= 0) {
VAR_0->control = VAR_1;
} else {
VAR_0->control = open("/dev/vhost-net", O_RDWR);
if (VAR_0->control < 0) {
return -errno;
}
}
VAR_3 = ioctl(VAR_0->control, VHOST_SET_OWNER, NULL);
if (VAR_3 < 0) {
goto fail;
}
VAR_3 = ioctl(VAR_0->control, VHOST_GET_FEATURES, &features);
if (VAR_3 < 0) {
goto fail;
}
VAR_0->features = features;
VAR_0->client.set_memory = vhost_client_set_memory;
VAR_0->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
VAR_0->client.migration_log = vhost_client_migration_log;
VAR_0->client.log_start = NULL;
VAR_0->client.log_stop = NULL;
VAR_0->mem = g_malloc0(offsetof(struct vhost_memory, regions));
VAR_0->log = NULL;
VAR_0->log_size = 0;
VAR_0->log_enabled = false;
VAR_0->started = false;
cpu_register_phys_memory_client(&VAR_0->client);
VAR_0->VAR_2 = VAR_2;
return 0;
fail:
VAR_3 = -errno;
close(VAR_0->control);
return VAR_3;
}
| [
"int FUNC_0(struct vhost_dev *VAR_0, int VAR_1, bool VAR_2)\n{",
"uint64_t features;",
"int VAR_3;",
"if (VAR_1 >= 0) {",
"VAR_0->control = VAR_1;",
"} else {",
"VAR_0->control = open(\"/dev/vhost-net\", O_RDWR);",
"if (VAR_0->control < 0) {",
"return -errno;",
"}",
"}",
"VAR_3 = ioctl(VAR_0->control, VHOST_SET_OWNER, NULL);",
"if (VAR_3 < 0) {",
"goto fail;",
"}",
"VAR_3 = ioctl(VAR_0->control, VHOST_GET_FEATURES, &features);",
"if (VAR_3 < 0) {",
"goto fail;",
"}",
"VAR_0->features = features;",
"VAR_0->client.set_memory = vhost_client_set_memory;",
"VAR_0->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;",
"VAR_0->client.migration_log = vhost_client_migration_log;",
"VAR_0->client.log_start = NULL;",
"VAR_0->client.log_stop = NULL;",
"VAR_0->mem = g_malloc0(offsetof(struct vhost_memory, regions));",
"VAR_0->log = NULL;",
"VAR_0->log_size = 0;",
"VAR_0->log_enabled = false;",
"VAR_0->started = false;",
"cpu_register_phys_memory_client(&VAR_0->client);",
"VAR_0->VAR_2 = VAR_2;",
"return 0;",
"fail:\nVAR_3 = -errno;",
"close(VAR_0->control);",
"return VAR_3;",
"}"
] | [
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,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
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
]
] |
23,293 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
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" (filter), "m" (filterPos),
"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 dstWidth_reg = dstWidth;
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_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "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
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif /* ARCH_X86 */
}
| true | FFmpeg | c3ab0004ae4dffc32494ae84dd15cfaa909a7884 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
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" (filter), "m" (filterPos),
"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 dstWidth_reg = dstWidth;
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_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
xpos+=xInc;
}
#endif
}
| {
"code": [
" int dstWidth, const uint8_t *src1,",
" x86_reg dstWidth_reg = dstWidth;",
" :: \"m\" (src1), \"m\" (dst), \"g\" (dstWidth_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask),",
" :: \"m\" (src1), \"m\" (dst), \"m\" (dstWidth_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask),"
],
"line_no": [
3,
133,
191,
195
]
} | static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int VAR_0;
#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" (filter), "m" (filterPos),
"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 (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) {
dst[VAR_0] = src1[srcW-1]*128;
dst[VAR_0+VOFW] = src2[srcW-1]*128;
}
} else {
#endif
x86_reg dstWidth_reg = dstWidth;
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_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
int VAR_0;
unsigned int VAR_1=0;
for (VAR_0=0;VAR_0<dstWidth;VAR_0++) {
register unsigned int xx=VAR_1>>16;
register unsigned int xalpha=(VAR_1&0xFFFF)>>9;
dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[VAR_0+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
VAR_1+=xInc;
}
#endif
}
| [
"static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst,\nint dstWidth, const uint8_t *src1,\nconst uint8_t *src2, int srcW, int xInc)\n{",
"#if ARCH_X86\n#if COMPILE_TEMPLATE_MMX2\nint32_t *filterPos = c->hChrFilterPos;",
"int16_t *filter = c->hChrFilter;",
"int canMMX2BeUsed = c->canMMX2BeUsed;",
"void *mmx2FilterCode= c->chrMmx2FilterCode;",
"int VAR_0;",
"#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\" (filter), \"m\" (filterPos),\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 (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) {",
"dst[VAR_0] = src1[srcW-1]*128;",
"dst[VAR_0+VOFW] = src2[srcW-1]*128;",
"}",
"} else {",
"#endif\nx86_reg dstWidth_reg = dstWidth;",
"x86_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_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask),\n#else\n:: \"m\" (src1), \"m\" (dst), \"m\" (dstWidth_reg), \"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\nint VAR_0;",
"unsigned int VAR_1=0;",
"for (VAR_0=0;VAR_0<dstWidth;VAR_0++) {",
"register unsigned int xx=VAR_1>>16;",
"register unsigned int xalpha=(VAR_1&0xFFFF)>>9;",
"dst[VAR_0]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);",
"dst[VAR_0+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);",
"VAR_1+=xInc;",
"}",
"#endif\n}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
83,
85,
87,
89,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139,
141,
143,
145,
147,
149,
151,
153,
155,
157,
159,
163,
165,
167,
169,
173,
175,
177,
179,
181,
189,
191,
193,
195,
197,
199,
201,
203
],
[
205,
207
],
[
209,
211,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
235
],
[
237
],
[
239,
241
]
] |
23,294 | static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
/* scale factor for motion vectors */
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
mb->type = 1; /* empty macroblocks are always INTER */
mb->cbp = 0; /* all blocks are empty */
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
if (band->inherit_mv){
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
if (band->inherit_mv) {
mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0; /* mb_type is always INTRA for intra-frames */
} else {
mb->type = get_bits1(&ctx->gb);
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
if (!mb->type) {
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
} else {
if (band->inherit_mv){
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
/* decode motion vector deltas */
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
offs += row_offset;
align_get_bits(&ctx->gb);
return 0; | true | FFmpeg | 2d09cdbaf2f449ba23d54e97e94bd97ca22208c6 | static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
mb->mv_x = mb->mv_y = 0;
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
if (band->inherit_mv) {
mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits1(&ctx->gb);
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
if (!mb->type) {
mb->mv_x = mb->mv_y = 0;
} else {
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
offs += row_offset;
align_get_bits(&ctx->gb);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(IVI45DecContext *VAR_0, IVIBandDesc *VAR_1,
IVITile *VAR_2, AVCodecContext *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10,
VAR_11, VAR_12;
IVIMbInfo *mb, *ref_mb;
int VAR_13 = VAR_1->mb_size * VAR_1->pitch;
mb = VAR_2->mbs;
ref_mb = VAR_2->ref_mbs;
VAR_9 = VAR_2->ypos * VAR_1->pitch + VAR_2->xpos;
if (!ref_mb &&
((VAR_1->qdelta_present && VAR_1->inherit_qdelta) || VAR_1->inherit_mv))
VAR_11 = (VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_1->mb_size >> 3);
VAR_6 = VAR_7 = 0;
for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) {
VAR_10 = VAR_9;
for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) {
mb->xpos = VAR_4;
mb->ypos = VAR_5;
mb->buf_offs = VAR_10;
if (get_bits1(&VAR_0->gb)) {
if (VAR_0->frame_type == FRAMETYPE_INTRA) {
av_log(VAR_3, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!VAR_1->plane && !VAR_1->band_num && (VAR_0->frame_flags & 8)) {
mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
mb->VAR_6 = mb->VAR_7 = 0;
if (VAR_1->inherit_mv){
if (VAR_11) {
mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_11);
mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_11);
} else {
mb->VAR_6 = ref_mb->VAR_6;
mb->VAR_7 = ref_mb->VAR_7;
} else {
if (VAR_1->inherit_mv) {
mb->type = ref_mb->type;
} else if (VAR_0->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits1(&VAR_0->gb);
VAR_12 = VAR_1->mb_size != VAR_1->blk_size ? 4 : 1;
mb->cbp = get_bits(&VAR_0->gb, VAR_12);
mb->q_delta = 0;
if (VAR_1->qdelta_present) {
if (VAR_1->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!VAR_1->plane && !VAR_1->band_num &&
(VAR_0->frame_flags & 8))) {
mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
if (!mb->type) {
mb->VAR_6 = mb->VAR_7 = 0;
} else {
if (VAR_1->inherit_mv){
if (VAR_11) {
mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_11);
mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_11);
} else {
mb->VAR_6 = ref_mb->VAR_6;
mb->VAR_7 = ref_mb->VAR_7;
} else {
VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
VAR_7 += IVI_TOSIGNED(VAR_8);
VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
VAR_6 += IVI_TOSIGNED(VAR_8);
mb->VAR_6 = VAR_6;
mb->VAR_7 = VAR_7;
mb++;
if (ref_mb)
ref_mb++;
VAR_10 += VAR_1->mb_size;
VAR_9 += VAR_13;
align_get_bits(&VAR_0->gb);
return 0; | [
"static int FUNC_0(IVI45DecContext *VAR_0, IVIBandDesc *VAR_1,\nIVITile *VAR_2, AVCodecContext *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10,\nVAR_11, VAR_12;",
"IVIMbInfo *mb, *ref_mb;",
"int VAR_13 = VAR_1->mb_size * VAR_1->pitch;",
"mb = VAR_2->mbs;",
"ref_mb = VAR_2->ref_mbs;",
"VAR_9 = VAR_2->ypos * VAR_1->pitch + VAR_2->xpos;",
"if (!ref_mb &&\n((VAR_1->qdelta_present && VAR_1->inherit_qdelta) || VAR_1->inherit_mv))\nVAR_11 = (VAR_0->planes[0].bands[0].mb_size >> 3) - (VAR_1->mb_size >> 3);",
"VAR_6 = VAR_7 = 0;",
"for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) {",
"VAR_10 = VAR_9;",
"for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) {",
"mb->xpos = VAR_4;",
"mb->ypos = VAR_5;",
"mb->buf_offs = VAR_10;",
"if (get_bits1(&VAR_0->gb)) {",
"if (VAR_0->frame_type == FRAMETYPE_INTRA) {",
"av_log(VAR_3, AV_LOG_ERROR, \"Empty macroblock in an INTRA picture!\\n\");",
"return -1;",
"mb->type = 1;",
"mb->cbp = 0;",
"mb->q_delta = 0;",
"if (!VAR_1->plane && !VAR_1->band_num && (VAR_0->frame_flags & 8)) {",
"mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"mb->q_delta = IVI_TOSIGNED(mb->q_delta);",
"mb->VAR_6 = mb->VAR_7 = 0;",
"if (VAR_1->inherit_mv){",
"if (VAR_11) {",
"mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_11);",
"mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_11);",
"} else {",
"mb->VAR_6 = ref_mb->VAR_6;",
"mb->VAR_7 = ref_mb->VAR_7;",
"} else {",
"if (VAR_1->inherit_mv) {",
"mb->type = ref_mb->type;",
"} else if (VAR_0->frame_type == FRAMETYPE_INTRA) {",
"mb->type = 0;",
"} else {",
"mb->type = get_bits1(&VAR_0->gb);",
"VAR_12 = VAR_1->mb_size != VAR_1->blk_size ? 4 : 1;",
"mb->cbp = get_bits(&VAR_0->gb, VAR_12);",
"mb->q_delta = 0;",
"if (VAR_1->qdelta_present) {",
"if (VAR_1->inherit_qdelta) {",
"if (ref_mb) mb->q_delta = ref_mb->q_delta;",
"} else if (mb->cbp || (!VAR_1->plane && !VAR_1->band_num &&",
"(VAR_0->frame_flags & 8))) {",
"mb->q_delta = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"mb->q_delta = IVI_TOSIGNED(mb->q_delta);",
"if (!mb->type) {",
"mb->VAR_6 = mb->VAR_7 = 0;",
"} else {",
"if (VAR_1->inherit_mv){",
"if (VAR_11) {",
"mb->VAR_6 = ivi_scale_mv(ref_mb->VAR_6, VAR_11);",
"mb->VAR_7 = ivi_scale_mv(ref_mb->VAR_7, VAR_11);",
"} else {",
"mb->VAR_6 = ref_mb->VAR_6;",
"mb->VAR_7 = ref_mb->VAR_7;",
"} else {",
"VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"VAR_7 += IVI_TOSIGNED(VAR_8);",
"VAR_8 = get_vlc2(&VAR_0->gb, VAR_0->mb_vlc.tab->table,\nIVI_VLC_BITS, 1);",
"VAR_6 += IVI_TOSIGNED(VAR_8);",
"mb->VAR_6 = VAR_6;",
"mb->VAR_7 = VAR_7;",
"mb++;",
"if (ref_mb)\nref_mb++;",
"VAR_10 += VAR_1->mb_size;",
"VAR_9 += VAR_13;",
"align_get_bits(&VAR_0->gb);",
"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
] | [
[
1,
2,
3
],
[
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12,
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30,
31
],
[
32
],
[
33
],
[
34
],
[
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
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
],
[
70
],
[
71
],
[
73,
74
],
[
75
],
[
76,
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82,
83
],
[
84
],
[
85
],
[
86
],
[
87
]
] |
23,295 | static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
int cancel, type, quincunx, content;
get_ue_golomb(gb); // frame_packing_arrangement_id
cancel = get_bits1(gb); // frame_packing_cancel_flag
if (cancel == 0) {
type = get_bits(gb, 7); // frame_packing_arrangement_type
quincunx = get_bits1(gb); // quincunx_sampling_flag
content = get_bits(gb, 6); // content_interpretation_type
// the following skips spatial_flipping_flag frame0_flipped_flag
// field_views_flag current_frame_is_frame0_flag
// frame0_self_contained_flag frame1_self_contained_flag
skip_bits(gb, 6);
if (quincunx == 0 && type != 5)
skip_bits(gb, 16); // frame[01]_grid_position_[xy]
skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
skip_bits1(gb); // frame_packing_arrangement_persistance_flag
}
skip_bits1(gb); // upsampled_aspect_ratio_flag
s->sei_frame_packing_present = (cancel == 0);
s->frame_packing_arrangement_type = type;
s->content_interpretation_type = content;
s->quincunx_subsampling = quincunx;
}
| true | FFmpeg | 180a0b1bcb522dab0ad828d8efb9673a6531d534 | static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
int cancel, type, quincunx, content;
get_ue_golomb(gb);
cancel = get_bits1(gb);
if (cancel == 0) {
type = get_bits(gb, 7);
quincunx = get_bits1(gb);
content = get_bits(gb, 6);
skip_bits(gb, 6);
if (quincunx == 0 && type != 5)
skip_bits(gb, 16);
skip_bits(gb, 8);
skip_bits1(gb);
}
skip_bits1(gb);
s->sei_frame_packing_present = (cancel == 0);
s->frame_packing_arrangement_type = type;
s->content_interpretation_type = content;
s->quincunx_subsampling = quincunx;
}
| {
"code": [
" int cancel, type, quincunx, content;"
],
"line_no": [
7
]
} | static void FUNC_0(HEVCContext *VAR_0)
{
GetBitContext *gb = &VAR_0->HEVClc->gb;
int VAR_1, VAR_2, VAR_3, VAR_4;
get_ue_golomb(gb);
VAR_1 = get_bits1(gb);
if (VAR_1 == 0) {
VAR_2 = get_bits(gb, 7);
VAR_3 = get_bits1(gb);
VAR_4 = get_bits(gb, 6);
skip_bits(gb, 6);
if (VAR_3 == 0 && VAR_2 != 5)
skip_bits(gb, 16);
skip_bits(gb, 8);
skip_bits1(gb);
}
skip_bits1(gb);
VAR_0->sei_frame_packing_present = (VAR_1 == 0);
VAR_0->frame_packing_arrangement_type = VAR_2;
VAR_0->content_interpretation_type = VAR_4;
VAR_0->quincunx_subsampling = VAR_3;
}
| [
"static void FUNC_0(HEVCContext *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->HEVClc->gb;",
"int VAR_1, VAR_2, VAR_3, VAR_4;",
"get_ue_golomb(gb);",
"VAR_1 = get_bits1(gb);",
"if (VAR_1 == 0) {",
"VAR_2 = get_bits(gb, 7);",
"VAR_3 = get_bits1(gb);",
"VAR_4 = get_bits(gb, 6);",
"skip_bits(gb, 6);",
"if (VAR_3 == 0 && VAR_2 != 5)\nskip_bits(gb, 16);",
"skip_bits(gb, 8);",
"skip_bits1(gb);",
"}",
"skip_bits1(gb);",
"VAR_0->sei_frame_packing_present = (VAR_1 == 0);",
"VAR_0->frame_packing_arrangement_type = VAR_2;",
"VAR_0->content_interpretation_type = VAR_4;",
"VAR_0->quincunx_subsampling = VAR_3;",
"}"
] | [
0,
0,
1,
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
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
23,296 | static int gdb_get_spe_reg(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
#if defined(TARGET_PPC64)
stl_p(mem_buf, env->gpr[n] >> 32);
#else
stl_p(mem_buf, env->gprh[n]);
#endif
return 4;
}
if (n == 33) {
stq_p(mem_buf, env->spe_acc);
return 8;
}
if (n == 34) {
/* SPEFSCR not implemented */
memset(mem_buf, 0, 4);
return 4;
}
return 0;
}
| true | qemu | 70976a7926b42d87e0c575412b85a8f5c1e48fad | static int gdb_get_spe_reg(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
#if defined(TARGET_PPC64)
stl_p(mem_buf, env->gpr[n] >> 32);
#else
stl_p(mem_buf, env->gprh[n]);
#endif
return 4;
}
if (n == 33) {
stq_p(mem_buf, env->spe_acc);
return 8;
}
if (n == 34) {
memset(mem_buf, 0, 4);
return 4;
}
return 0;
}
| {
"code": [
" if (n == 33) {",
" if (n == 34) {",
" if (n == 33) {",
" if (n == 34) {",
" if (n == 33) {",
" if (n == 34) {",
" if (n == 33) {",
" if (n == 34) {"
],
"line_no": [
21,
29,
21,
29,
21,
29,
21,
29
]
} | static int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)
{
if (VAR_2 < 32) {
#if defined(TARGET_PPC64)
stl_p(VAR_1, VAR_0->gpr[VAR_2] >> 32);
#else
stl_p(VAR_1, VAR_0->gprh[VAR_2]);
#endif
return 4;
}
if (VAR_2 == 33) {
stq_p(VAR_1, VAR_0->spe_acc);
return 8;
}
if (VAR_2 == 34) {
memset(VAR_1, 0, 4);
return 4;
}
return 0;
}
| [
"static int FUNC_0(CPUState *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"if (VAR_2 < 32) {",
"#if defined(TARGET_PPC64)\nstl_p(VAR_1, VAR_0->gpr[VAR_2] >> 32);",
"#else\nstl_p(VAR_1, VAR_0->gprh[VAR_2]);",
"#endif\nreturn 4;",
"}",
"if (VAR_2 == 33) {",
"stq_p(VAR_1, VAR_0->spe_acc);",
"return 8;",
"}",
"if (VAR_2 == 34) {",
"memset(VAR_1, 0, 4);",
"return 4;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
23,297 | static void virtio_pci_device_unplugged(DeviceState *d)
{
PCIDevice *pci_dev = PCI_DEVICE(d);
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
virtio_pci_stop_ioeventfd(proxy);
msix_uninit_exclusive_bar(pci_dev);
}
| true | qemu | 8b81bb3b069d4007bc44c8d5888d630b7f0b42ff | static void virtio_pci_device_unplugged(DeviceState *d)
{
PCIDevice *pci_dev = PCI_DEVICE(d);
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
virtio_pci_stop_ioeventfd(proxy);
msix_uninit_exclusive_bar(pci_dev);
}
| {
"code": [
" PCIDevice *pci_dev = PCI_DEVICE(d);",
" msix_uninit_exclusive_bar(pci_dev);"
],
"line_no": [
5,
13
]
} | static void FUNC_0(DeviceState *VAR_0)
{
PCIDevice *pci_dev = PCI_DEVICE(VAR_0);
VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);
virtio_pci_stop_ioeventfd(proxy);
msix_uninit_exclusive_bar(pci_dev);
}
| [
"static void FUNC_0(DeviceState *VAR_0)\n{",
"PCIDevice *pci_dev = PCI_DEVICE(VAR_0);",
"VirtIOPCIProxy *proxy = VIRTIO_PCI(VAR_0);",
"virtio_pci_stop_ioeventfd(proxy);",
"msix_uninit_exclusive_bar(pci_dev);",
"}"
] | [
0,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
23,300 | static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
{
int n;
if (!proxy->ioeventfd_started) {
return 0;
}
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, false);
virtio_pci_set_host_notifier_internal(proxy, n, false);
}
proxy->ioeventfd_started = false;
return 0;
}
| true | qemu | b36e391441906c36ed0856b69de84001860402bf | static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
{
int n;
if (!proxy->ioeventfd_started) {
return 0;
}
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, false);
virtio_pci_set_host_notifier_internal(proxy, n, false);
}
proxy->ioeventfd_started = false;
return 0;
}
| {
"code": [
" return 0;",
" return 0;",
" virtio_pci_set_host_notifier_internal(proxy, n, false);",
"static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)",
" return 0;",
" virtio_pci_set_host_notifier_internal(proxy, n, false);",
" return 0;"
],
"line_no": [
11,
35,
29,
1,
11,
29,
35
]
} | static int FUNC_0(VirtIOPCIProxy *VAR_0)
{
int VAR_1;
if (!VAR_0->ioeventfd_started) {
return 0;
}
for (VAR_1 = 0; VAR_1 < VIRTIO_PCI_QUEUE_MAX; VAR_1++) {
if (!virtio_queue_get_num(VAR_0->vdev, VAR_1)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(VAR_0, VAR_1, false);
virtio_pci_set_host_notifier_internal(VAR_0, VAR_1, false);
}
VAR_0->ioeventfd_started = false;
return 0;
}
| [
"static int FUNC_0(VirtIOPCIProxy *VAR_0)\n{",
"int VAR_1;",
"if (!VAR_0->ioeventfd_started) {",
"return 0;",
"}",
"for (VAR_1 = 0; VAR_1 < VIRTIO_PCI_QUEUE_MAX; VAR_1++) {",
"if (!virtio_queue_get_num(VAR_0->vdev, VAR_1)) {",
"continue;",
"}",
"virtio_pci_set_host_notifier_fd_handler(VAR_0, VAR_1, false);",
"virtio_pci_set_host_notifier_internal(VAR_0, VAR_1, false);",
"}",
"VAR_0->ioeventfd_started = false;",
"return 0;",
"}"
] | [
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
23,301 | static int ram_decompress_buf(RamDecompressState *s, uint8_t *buf, int len)
{
int ret, clen;
s->zstream.avail_out = len;
s->zstream.next_out = buf;
while (s->zstream.avail_out > 0) {
if (s->zstream.avail_in == 0) {
if (qemu_get_be16(s->f) != RAM_CBLOCK_MAGIC)
return -1;
clen = qemu_get_be16(s->f);
if (clen > IOBUF_SIZE)
return -1;
qemu_get_buffer(s->f, s->buf, clen);
s->zstream.avail_in = clen;
s->zstream.next_in = s->buf;
}
ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
return -1;
}
}
return 0;
}
| true | qemu | 94fb0909645de18481cc726ee0ec9b5afa861394 | static int ram_decompress_buf(RamDecompressState *s, uint8_t *buf, int len)
{
int ret, clen;
s->zstream.avail_out = len;
s->zstream.next_out = buf;
while (s->zstream.avail_out > 0) {
if (s->zstream.avail_in == 0) {
if (qemu_get_be16(s->f) != RAM_CBLOCK_MAGIC)
return -1;
clen = qemu_get_be16(s->f);
if (clen > IOBUF_SIZE)
return -1;
qemu_get_buffer(s->f, s->buf, clen);
s->zstream.avail_in = clen;
s->zstream.next_in = s->buf;
}
ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
return -1;
}
}
return 0;
}
| {
"code": [
" return 0;",
"static int ram_decompress_buf(RamDecompressState *s, uint8_t *buf, int len)",
" int ret, clen;",
" s->zstream.avail_out = len;",
" s->zstream.next_out = buf;",
" while (s->zstream.avail_out > 0) {",
" if (s->zstream.avail_in == 0) {",
" if (qemu_get_be16(s->f) != RAM_CBLOCK_MAGIC)",
" return -1;",
" clen = qemu_get_be16(s->f);",
" if (clen > IOBUF_SIZE)",
" return -1;",
" qemu_get_buffer(s->f, s->buf, clen);",
" s->zstream.avail_in = clen;",
" s->zstream.next_in = s->buf;",
" ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);",
" if (ret != Z_OK && ret != Z_STREAM_END) {",
" return -1;",
" return 0;",
" return 0;"
],
"line_no": [
45,
1,
5,
9,
11,
13,
15,
17,
19,
21,
23,
19,
27,
29,
31,
35,
37,
39,
45,
45
]
} | static int FUNC_0(RamDecompressState *VAR_0, uint8_t *VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
VAR_0->zstream.avail_out = VAR_2;
VAR_0->zstream.next_out = VAR_1;
while (VAR_0->zstream.avail_out > 0) {
if (VAR_0->zstream.avail_in == 0) {
if (qemu_get_be16(VAR_0->f) != RAM_CBLOCK_MAGIC)
return -1;
VAR_4 = qemu_get_be16(VAR_0->f);
if (VAR_4 > IOBUF_SIZE)
return -1;
qemu_get_buffer(VAR_0->f, VAR_0->VAR_1, VAR_4);
VAR_0->zstream.avail_in = VAR_4;
VAR_0->zstream.next_in = VAR_0->VAR_1;
}
VAR_3 = inflate(&VAR_0->zstream, Z_PARTIAL_FLUSH);
if (VAR_3 != Z_OK && VAR_3 != Z_STREAM_END) {
return -1;
}
}
return 0;
}
| [
"static int FUNC_0(RamDecompressState *VAR_0, uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"VAR_0->zstream.avail_out = VAR_2;",
"VAR_0->zstream.next_out = VAR_1;",
"while (VAR_0->zstream.avail_out > 0) {",
"if (VAR_0->zstream.avail_in == 0) {",
"if (qemu_get_be16(VAR_0->f) != RAM_CBLOCK_MAGIC)\nreturn -1;",
"VAR_4 = qemu_get_be16(VAR_0->f);",
"if (VAR_4 > IOBUF_SIZE)\nreturn -1;",
"qemu_get_buffer(VAR_0->f, VAR_0->VAR_1, VAR_4);",
"VAR_0->zstream.avail_in = VAR_4;",
"VAR_0->zstream.next_in = VAR_0->VAR_1;",
"}",
"VAR_3 = inflate(&VAR_0->zstream, Z_PARTIAL_FLUSH);",
"if (VAR_3 != Z_OK && VAR_3 != Z_STREAM_END) {",
"return -1;",
"}",
"}",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
23,302 | void avfilter_free(AVFilterContext *filter)
{
int i;
AVFilterLink *link;
if (filter->filter->uninit)
filter->filter->uninit(filter);
for (i = 0; i < filter->input_count; i++) {
if ((link = filter->inputs[i])) {
if (link->src)
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
for (i = 0; i < filter->output_count; i++) {
if ((link = filter->outputs[i])) {
if (link->dst)
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
av_freep(&filter->name);
av_freep(&filter->input_pads);
av_freep(&filter->output_pads);
av_freep(&filter->inputs);
av_freep(&filter->outputs);
av_freep(&filter->priv);
av_free(filter);
}
| true | FFmpeg | e977ca2645cc6b23589ddf97ab08861064ba8792 | void avfilter_free(AVFilterContext *filter)
{
int i;
AVFilterLink *link;
if (filter->filter->uninit)
filter->filter->uninit(filter);
for (i = 0; i < filter->input_count; i++) {
if ((link = filter->inputs[i])) {
if (link->src)
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
for (i = 0; i < filter->output_count; i++) {
if ((link = filter->outputs[i])) {
if (link->dst)
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
av_freep(&filter->name);
av_freep(&filter->input_pads);
av_freep(&filter->output_pads);
av_freep(&filter->inputs);
av_freep(&filter->outputs);
av_freep(&filter->priv);
av_free(filter);
}
| {
"code": [
" av_freep(&link);",
" av_freep(&link);"
],
"line_no": [
31,
31
]
} | void FUNC_0(AVFilterContext *VAR_0)
{
int VAR_1;
AVFilterLink *link;
if (VAR_0->VAR_0->uninit)
VAR_0->VAR_0->uninit(VAR_0);
for (VAR_1 = 0; VAR_1 < VAR_0->input_count; VAR_1++) {
if ((link = VAR_0->inputs[VAR_1])) {
if (link->src)
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
for (VAR_1 = 0; VAR_1 < VAR_0->output_count; VAR_1++) {
if ((link = VAR_0->outputs[VAR_1])) {
if (link->dst)
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
av_freep(&VAR_0->name);
av_freep(&VAR_0->input_pads);
av_freep(&VAR_0->output_pads);
av_freep(&VAR_0->inputs);
av_freep(&VAR_0->outputs);
av_freep(&VAR_0->priv);
av_free(VAR_0);
}
| [
"void FUNC_0(AVFilterContext *VAR_0)\n{",
"int VAR_1;",
"AVFilterLink *link;",
"if (VAR_0->VAR_0->uninit)\nVAR_0->VAR_0->uninit(VAR_0);",
"for (VAR_1 = 0; VAR_1 < VAR_0->input_count; VAR_1++) {",
"if ((link = VAR_0->inputs[VAR_1])) {",
"if (link->src)\nlink->src->outputs[link->srcpad - link->src->output_pads] = NULL;",
"avfilter_formats_unref(&link->in_formats);",
"avfilter_formats_unref(&link->out_formats);",
"}",
"av_freep(&link);",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_0->output_count; VAR_1++) {",
"if ((link = VAR_0->outputs[VAR_1])) {",
"if (link->dst)\nlink->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;",
"avfilter_formats_unref(&link->in_formats);",
"avfilter_formats_unref(&link->out_formats);",
"}",
"av_freep(&link);",
"}",
"av_freep(&VAR_0->name);",
"av_freep(&VAR_0->input_pads);",
"av_freep(&VAR_0->output_pads);",
"av_freep(&VAR_0->inputs);",
"av_freep(&VAR_0->outputs);",
"av_freep(&VAR_0->priv);",
"av_free(VAR_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
23,303 | void gtk_display_init(DisplayState *ds)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
gtk_init(NULL, NULL);
ds->opaque = s;
s->ds = ds;
s->dcl.ops = &dcl_ops;
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->drawing_area = gtk_drawing_area_new();
s->menu_bar = gtk_menu_bar_new();
s->scale_x = 1.0;
s->scale_y = 1.0;
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
gd_create_menus(s);
gd_connect_signals(s);
gtk_widget_add_events(s->drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
gtk_widget_set_can_focus(s->drawing_area, TRUE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
register_displaychangelistener(ds, &s->dcl);
global_state = s;
}
| true | qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 | void gtk_display_init(DisplayState *ds)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
gtk_init(NULL, NULL);
ds->opaque = s;
s->ds = ds;
s->dcl.ops = &dcl_ops;
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->drawing_area = gtk_drawing_area_new();
s->menu_bar = gtk_menu_bar_new();
s->scale_x = 1.0;
s->scale_y = 1.0;
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
gd_create_menus(s);
gd_connect_signals(s);
gtk_widget_add_events(s->drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
gtk_widget_set_can_focus(s->drawing_area, TRUE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
register_displaychangelistener(ds, &s->dcl);
global_state = s;
}
| {
"code": [
" ds->opaque = s;"
],
"line_no": [
13
]
} | void FUNC_0(DisplayState *VAR_0)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
gtk_init(NULL, NULL);
VAR_0->opaque = s;
s->VAR_0 = VAR_0;
s->dcl.ops = &dcl_ops;
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->drawing_area = gtk_drawing_area_new();
s->menu_bar = gtk_menu_bar_new();
s->scale_x = 1.0;
s->scale_y = 1.0;
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
gd_create_menus(s);
gd_connect_signals(s);
gtk_widget_add_events(s->drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
gtk_widget_set_can_focus(s->drawing_area, TRUE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
register_displaychangelistener(VAR_0, &s->dcl);
global_state = s;
}
| [
"void FUNC_0(DisplayState *VAR_0)\n{",
"GtkDisplayState *s = g_malloc0(sizeof(*s));",
"gtk_init(NULL, NULL);",
"VAR_0->opaque = s;",
"s->VAR_0 = VAR_0;",
"s->dcl.ops = &dcl_ops;",
"s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);",
"#if GTK_CHECK_VERSION(3, 2, 0)\ns->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);",
"#else\ns->vbox = gtk_vbox_new(FALSE, 0);",
"#endif\ns->notebook = gtk_notebook_new();",
"s->drawing_area = gtk_drawing_area_new();",
"s->menu_bar = gtk_menu_bar_new();",
"s->scale_x = 1.0;",
"s->scale_y = 1.0;",
"s->free_scale = FALSE;",
"setlocale(LC_ALL, \"\");",
"bindtextdomain(\"qemu\", CONFIG_QEMU_LOCALEDIR);",
"textdomain(\"qemu\");",
"s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);",
"s->mouse_mode_notifier.notify = gd_mouse_mode_change;",
"qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);",
"qemu_add_vm_change_state_handler(gd_change_runstate, s);",
"gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new(\"VGA\"));",
"gd_create_menus(s);",
"gd_connect_signals(s);",
"gtk_widget_add_events(s->drawing_area,\nGDK_POINTER_MOTION_MASK |\nGDK_BUTTON_PRESS_MASK |\nGDK_BUTTON_RELEASE_MASK |\nGDK_BUTTON_MOTION_MASK |\nGDK_ENTER_NOTIFY_MASK |\nGDK_LEAVE_NOTIFY_MASK |\nGDK_SCROLL_MASK |\nGDK_KEY_PRESS_MASK);",
"gtk_widget_set_double_buffered(s->drawing_area, FALSE);",
"gtk_widget_set_can_focus(s->drawing_area, TRUE);",
"gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);",
"gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);",
"gd_update_caption(s);",
"gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);",
"gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);",
"gtk_container_add(GTK_CONTAINER(s->window), s->vbox);",
"gtk_widget_show_all(s->window);",
"register_displaychangelistener(VAR_0, &s->dcl);",
"global_state = s;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
77
],
[
81,
83,
85,
87,
89,
91,
93,
95,
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
121
],
[
125
],
[
129
],
[
133
],
[
135
]
] |
23,304 | void vnc_display_init(DisplayState *ds)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
vnc_display = vs;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
vs->ds = ds;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout)
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
else
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
dcl->ops = &dcl_ops;
register_displaychangelistener(ds, dcl);
}
| true | qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 | void vnc_display_init(DisplayState *ds)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
vnc_display = vs;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
vs->ds = ds;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout)
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
else
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
dcl->ops = &dcl_ops;
register_displaychangelistener(ds, dcl);
}
| {
"code": [
" dcl = g_malloc0(sizeof(DisplayChangeListener));",
" ds->opaque = vs;",
" dcl->idle = 1;",
" dcl->ops = &dcl_ops;",
" register_displaychangelistener(ds, dcl);"
],
"line_no": [
9,
13,
15,
61,
63
]
} | void FUNC_0(DisplayState *VAR_0)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
dcl = g_malloc0(sizeof(DisplayChangeListener));
VAR_0->opaque = vs;
dcl->idle = 1;
vnc_display = vs;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
vs->VAR_0 = VAR_0;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout)
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
else
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
dcl->ops = &dcl_ops;
register_displaychangelistener(VAR_0, dcl);
}
| [
"void FUNC_0(DisplayState *VAR_0)\n{",
"VncDisplay *vs = g_malloc0(sizeof(*vs));",
"dcl = g_malloc0(sizeof(DisplayChangeListener));",
"VAR_0->opaque = vs;",
"dcl->idle = 1;",
"vnc_display = vs;",
"vs->lsock = -1;",
"#ifdef CONFIG_VNC_WS\nvs->lwebsock = -1;",
"#endif\nvs->VAR_0 = VAR_0;",
"QTAILQ_INIT(&vs->clients);",
"vs->expires = TIME_MAX;",
"if (keyboard_layout)\nvs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);",
"else\nvs->kbd_layout = init_keyboard_layout(name2keysym, \"en-us\");",
"if (!vs->kbd_layout)\nexit(1);",
"qemu_mutex_init(&vs->mutex);",
"vnc_start_worker_thread();",
"dcl->ops = &dcl_ops;",
"register_displaychangelistener(VAR_0, dcl);",
"}"
] | [
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
27,
31
],
[
33
],
[
35
],
[
39,
41
],
[
43,
45
],
[
49,
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
]
] |
23,305 | static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int ret;
// We don't want to use the RTP timestamps at all. If the mpegts demuxer
// doesn't set any pts/dts, the generic rtpdec code shouldn't try to
// fill it in either, since the mpegts and RTP timestamps are in totally
// different ranges.
*timestamp = RTP_NOTS_VALUE;
if (!data->ts)
return AVERROR(EINVAL);
if (!buf) {
if (data->read_buf_index >= data->read_buf_size)
return AVERROR(EAGAIN);
ret = ff_mpegts_parse_packet(data->ts, pkt, data->buf + data->read_buf_index,
data->read_buf_size - data->read_buf_index);
if (ret < 0)
return AVERROR(EAGAIN);
data->read_buf_index += ret;
if (data->read_buf_index < data->read_buf_size)
return 1;
else
return 0;
}
ret = ff_mpegts_parse_packet(data->ts, pkt, buf, len);
/* The only error that can be returned from ff_mpegts_parse_packet
* is "no more data to return from the provided buffer", so return
* AVERROR(EAGAIN) for all errors */
if (ret < 0)
return AVERROR(EAGAIN);
if (ret < len) {
data->read_buf_size = FFMIN(len - ret, sizeof(data->buf));
memcpy(data->buf, buf + ret, data->read_buf_size);
data->read_buf_index = 0;
return 1;
}
return 0;
}
| true | FFmpeg | 078d43e23a7a3d64aafee8a58b380d3e139b3020 | static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int ret;
*timestamp = RTP_NOTS_VALUE;
if (!data->ts)
return AVERROR(EINVAL);
if (!buf) {
if (data->read_buf_index >= data->read_buf_size)
return AVERROR(EAGAIN);
ret = ff_mpegts_parse_packet(data->ts, pkt, data->buf + data->read_buf_index,
data->read_buf_size - data->read_buf_index);
if (ret < 0)
return AVERROR(EAGAIN);
data->read_buf_index += ret;
if (data->read_buf_index < data->read_buf_size)
return 1;
else
return 0;
}
ret = ff_mpegts_parse_packet(data->ts, pkt, buf, len);
if (ret < 0)
return AVERROR(EAGAIN);
if (ret < len) {
data->read_buf_size = FFMIN(len - ret, sizeof(data->buf));
memcpy(data->buf, buf + ret, data->read_buf_size);
data->read_buf_index = 0;
return 1;
}
return 0;
}
| {
"code": [
" return AVERROR(EINVAL);",
" if (!data->ts)",
" return AVERROR(EINVAL);"
],
"line_no": [
29,
27,
29
]
} | static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,
AVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4,
const uint8_t *VAR_5, int VAR_6, uint16_t VAR_7,
int VAR_8)
{
int VAR_9;
*VAR_4 = RTP_NOTS_VALUE;
if (!VAR_1->ts)
return AVERROR(EINVAL);
if (!VAR_5) {
if (VAR_1->read_buf_index >= VAR_1->read_buf_size)
return AVERROR(EAGAIN);
VAR_9 = ff_mpegts_parse_packet(VAR_1->ts, VAR_3, VAR_1->VAR_5 + VAR_1->read_buf_index,
VAR_1->read_buf_size - VAR_1->read_buf_index);
if (VAR_9 < 0)
return AVERROR(EAGAIN);
VAR_1->read_buf_index += VAR_9;
if (VAR_1->read_buf_index < VAR_1->read_buf_size)
return 1;
else
return 0;
}
VAR_9 = ff_mpegts_parse_packet(VAR_1->ts, VAR_3, VAR_5, VAR_6);
if (VAR_9 < 0)
return AVERROR(EAGAIN);
if (VAR_9 < VAR_6) {
VAR_1->read_buf_size = FFMIN(VAR_6 - VAR_9, sizeof(VAR_1->VAR_5));
memcpy(VAR_1->VAR_5, VAR_5 + VAR_9, VAR_1->read_buf_size);
VAR_1->read_buf_index = 0;
return 1;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,\nAVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4,\nconst uint8_t *VAR_5, int VAR_6, uint16_t VAR_7,\nint VAR_8)\n{",
"int VAR_9;",
"*VAR_4 = RTP_NOTS_VALUE;",
"if (!VAR_1->ts)\nreturn AVERROR(EINVAL);",
"if (!VAR_5) {",
"if (VAR_1->read_buf_index >= VAR_1->read_buf_size)\nreturn AVERROR(EAGAIN);",
"VAR_9 = ff_mpegts_parse_packet(VAR_1->ts, VAR_3, VAR_1->VAR_5 + VAR_1->read_buf_index,\nVAR_1->read_buf_size - VAR_1->read_buf_index);",
"if (VAR_9 < 0)\nreturn AVERROR(EAGAIN);",
"VAR_1->read_buf_index += VAR_9;",
"if (VAR_1->read_buf_index < VAR_1->read_buf_size)\nreturn 1;",
"else\nreturn 0;",
"}",
"VAR_9 = ff_mpegts_parse_packet(VAR_1->ts, VAR_3, VAR_5, VAR_6);",
"if (VAR_9 < 0)\nreturn AVERROR(EAGAIN);",
"if (VAR_9 < VAR_6) {",
"VAR_1->read_buf_size = FFMIN(VAR_6 - VAR_9, sizeof(VAR_1->VAR_5));",
"memcpy(VAR_1->VAR_5, VAR_5 + VAR_9, VAR_1->read_buf_size);",
"VAR_1->read_buf_index = 0;",
"return 1;",
"}",
"return 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,
7,
9
],
[
11
],
[
23
],
[
27,
29
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53,
55
],
[
57
],
[
61
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
23,306 | static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)
{
MonFdset *mon_fdset;
MonFdsetFd *mon_fdset_fd_dup;
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {
if (mon_fdset_fd_dup->fd == dup_fd) {
if (remove) {
QLIST_REMOVE(mon_fdset_fd_dup, next);
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
monitor_fdset_cleanup(mon_fdset);
}
}
return mon_fdset->id;
}
}
}
return -1;
}
| true | qemu | b3dd1b8c295636e64ceb14cdc4db6420d7319e38 | static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)
{
MonFdset *mon_fdset;
MonFdsetFd *mon_fdset_fd_dup;
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {
if (mon_fdset_fd_dup->fd == dup_fd) {
if (remove) {
QLIST_REMOVE(mon_fdset_fd_dup, next);
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
monitor_fdset_cleanup(mon_fdset);
}
}
return mon_fdset->id;
}
}
}
return -1;
}
| {
"code": [
" return mon_fdset->id;",
" return -1;"
],
"line_no": [
29,
37
]
} | static int FUNC_0(int VAR_0, bool VAR_1)
{
MonFdset *mon_fdset;
MonFdsetFd *mon_fdset_fd_dup;
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {
if (mon_fdset_fd_dup->fd == VAR_0) {
if (VAR_1) {
QLIST_REMOVE(mon_fdset_fd_dup, next);
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
monitor_fdset_cleanup(mon_fdset);
}
}
return mon_fdset->id;
}
}
}
return -1;
}
| [
"static int FUNC_0(int VAR_0, bool VAR_1)\n{",
"MonFdset *mon_fdset;",
"MonFdsetFd *mon_fdset_fd_dup;",
"QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {",
"QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {",
"if (mon_fdset_fd_dup->fd == VAR_0) {",
"if (VAR_1) {",
"QLIST_REMOVE(mon_fdset_fd_dup, next);",
"if (QLIST_EMPTY(&mon_fdset->dup_fds)) {",
"monitor_fdset_cleanup(mon_fdset);",
"}",
"}",
"return mon_fdset->id;",
"}",
"}",
"}",
"return -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
23,310 | static always_inline void powerpc_excp (CPUState *env,
int excp_model, int excp)
{
target_ulong msr, new_msr, vector;
int srr0, srr1, asrr0, asrr1;
#if defined(TARGET_PPC64H)
int lpes0, lpes1, lev;
lpes0 = (env->spr[SPR_LPCR] >> 1) & 1;
lpes1 = (env->spr[SPR_LPCR] >> 2) & 1;
#endif
if (loglevel & CPU_LOG_INT) {
fprintf(logfile, "Raise exception at 0x" ADDRX " => 0x%08x (%02x)\n",
env->nip, excp, env->error_code);
}
msr = env->msr;
new_msr = msr;
srr0 = SPR_SRR0;
srr1 = SPR_SRR1;
asrr0 = -1;
asrr1 = -1;
msr &= ~((target_ulong)0x783F0000);
switch (excp) {
case POWERPC_EXCP_NONE:
/* Should never happen */
return;
case POWERPC_EXCP_CRITICAL: /* Critical input */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
case POWERPC_EXCP_G2:
break;
default:
goto excp_invalid;
}
goto store_next;
case POWERPC_EXCP_MCHECK: /* Machine check exception */
if (msr_me == 0) {
/* Machine check exception is not enabled.
* Enter checkstop state.
*/
if (loglevel != 0) {
fprintf(logfile, "Machine check while not allowed. "
"Entering checkstop state\n");
} else {
fprintf(stderr, "Machine check while not allowed. "
"Entering checkstop state\n");
}
env->halted = 1;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
new_msr &= ~((target_ulong)1 << MSR_ME);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: should also have something loaded in DAR / DSISR */
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_MCSRR0;
srr1 = SPR_BOOKE_MCSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
goto store_next;
case POWERPC_EXCP_DSI: /* Data storage exception */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX
"\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISI: /* Instruction storage exception */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "ISI exception: msr=0x" ADDRX ", nip=0x" ADDRX
"\n", msr, env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= env->error_code;
goto store_next;
case POWERPC_EXCP_EXTERNAL: /* External input */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes0 == 1)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ALIGN: /* Alignment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: this is false */
/* Get rS/rD and rA from faulting opcode */
env->spr[SPR_DSISR] |= (ldl_code((env->nip - 4)) & 0x03FF0000) >> 16;
goto store_current;
case POWERPC_EXCP_PROGRAM: /* Program exception */
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) {
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Ignore floating point exception\n");
}
#endif
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00100000;
if (msr_fe0 == msr_fe1)
goto store_next;
msr |= 0x00010000;
break;
case POWERPC_EXCP_INVAL:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Invalid instruction at 0x" ADDRX "\n",
env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00080000;
break;
case POWERPC_EXCP_PRIV:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00040000;
break;
case POWERPC_EXCP_TRAP:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00020000;
break;
default:
/* Should never occur */
cpu_abort(env, "Invalid program exception %d. Aborting\n",
env->error_code);
break;
}
goto store_current;
case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_SYSCALL: /* System call exception */
/* NOTE: this is a temporary hack to support graphics OSI
calls from the MOL driver */
/* XXX: To be removed */
if (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&
env->osi_call) {
if (env->osi_call(env) != 0) {
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
}
if (loglevel & CPU_LOG_INT) {
dump_syscall(env);
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
lev = env->error_code;
if (lev == 1 || (lpes0 == 0 && lpes1 == 0))
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_DECR: /* Decrementer exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt */
/* FIT on 4xx */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "FIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_WDT: /* Watchdog timer interrupt */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "WDT exception\n");
#endif
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_DTLB: /* Data TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_ITLB: /* Instruction TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_DEBUG: /* Debug interrupt */
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_DSRR0;
srr1 = SPR_BOOKE_DSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
/* XXX: TODO */
cpu_abort(env, "Debug exception is not implemented yet !\n");
goto store_next;
#if defined(TARGET_PPCEMB)
case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavailable */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_current;
case POWERPC_EXCP_EFPDI: /* Embedded floating-point data interrupt */
/* XXX: TODO */
cpu_abort(env, "Embedded floating point data exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EFPRI: /* Embedded floating-point round interrupt */
/* XXX: TODO */
cpu_abort(env, "Embedded floating point round exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EPERFM: /* Embedded performance monitor interrupt */
new_msr &= ~((target_ulong)1 << MSR_RI);
/* XXX: TODO */
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORI: /* Embedded doorbell interrupt */
/* XXX: TODO */
cpu_abort(env,
"Embedded doorbell interrupt is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORCI: /* Embedded doorbell critical interrupt */
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
/* XXX: TODO */
cpu_abort(env, "Embedded doorbell critical interrupt "
"is not implemented yet !\n");
goto store_next;
#endif /* defined(TARGET_PPCEMB) */
case POWERPC_EXCP_RESET: /* System reset exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64)
case POWERPC_EXCP_DSEG: /* Data segment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISEG: /* Instruction segment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#endif /* defined(TARGET_PPC64) */
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_TRACE: /* Trace exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISI: /* Hypervisor instruction storage exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HDSEG: /* Hypervisor data segment exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISEG: /* Hypervisor instruction segment exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif /* defined(TARGET_PPC64H) */
case POWERPC_EXCP_VPU: /* Vector unavailable exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_PIT: /* Programmable interval timer interrupt */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "PIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_IO: /* IO error exception */
/* XXX: TODO */
cpu_abort(env, "601 IO error exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_RUNM: /* Run mode exception */
/* XXX: TODO */
cpu_abort(env, "601 run mode exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EMUL: /* Emulation trap exception */
/* XXX: TODO */
cpu_abort(env, "602 emulation trap exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IFTLB: /* Instruction fetch TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid instruction TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DLTLB: /* Data load TLB miss */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid data load TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DSTLB: /* Data store TLB miss */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
tlb_miss_tgpr:
/* Swap temporary saved registers with GPRs */
if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) {
new_msr |= (target_ulong)1 << MSR_TGPR;
hreg_swap_gpr_tgpr(env);
}
goto tlb_miss;
case POWERPC_EXCP_7x5:
tlb_miss:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_IMISS];
cmp = &env->spr[SPR_ICMP];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_DMISS];
cmp = &env->spr[SPR_DCMP];
}
fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" H1 " ADDRX " H2 " ADDRX " %08x\n",
es, en, *miss, en, *cmp,
env->spr[SPR_HASH1], env->spr[SPR_HASH2],
env->error_code);
}
#endif
msr |= env->crf[0] << 28;
msr |= env->error_code; /* key, D/I, S/L bits */
/* Set way using a LRU mechanism */
msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17;
break;
case POWERPC_EXCP_74xx:
tlb_miss_74xx:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
}
fprintf(logfile, "74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" %08x\n",
es, en, *miss, en, *cmp, env->error_code);
}
#endif
msr |= env->error_code; /* key bit */
break;
default:
cpu_abort(env, "Invalid data store TLB miss exception\n");
break;
}
goto store_next;
case POWERPC_EXCP_FPA: /* Floating-point assist exception */
/* XXX: TODO */
cpu_abort(env, "Floating point assist exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IABR: /* Instruction address breakpoint */
/* XXX: TODO */
cpu_abort(env, "IABR exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SMI: /* System management interrupt */
/* XXX: TODO */
cpu_abort(env, "SMI exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_THERM: /* Thermal interrupt */
/* XXX: TODO */
cpu_abort(env, "Thermal management exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_PERFM: /* Embedded performance monitor interrupt */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: TODO */
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_VPUA: /* Vector assist exception */
/* XXX: TODO */
cpu_abort(env, "VPU assist exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SOFTP: /* Soft patch exception */
/* XXX: TODO */
cpu_abort(env,
"970 soft-patch exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_MAINT: /* Maintenance exception */
/* XXX: TODO */
cpu_abort(env,
"970 maintenance exception is not implemented yet !\n");
goto store_next;
default:
excp_invalid:
cpu_abort(env, "Invalid PowerPC exception %d. Aborting\n", excp);
break;
store_current:
/* save current instruction location */
env->spr[srr0] = env->nip - 4;
break;
store_next:
/* save next instruction location */
env->spr[srr0] = env->nip;
break;
}
/* Save MSR */
env->spr[srr1] = msr;
/* If any alternate SRR register are defined, duplicate saved values */
if (asrr0 != -1)
env->spr[asrr0] = env->spr[srr0];
if (asrr1 != -1)
env->spr[asrr1] = env->spr[srr1];
/* If we disactivated any translation, flush TLBs */
if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))
tlb_flush(env, 1);
/* reload MSR with correct bits */
new_msr &= ~((target_ulong)1 << MSR_EE);
new_msr &= ~((target_ulong)1 << MSR_PR);
new_msr &= ~((target_ulong)1 << MSR_FP);
new_msr &= ~((target_ulong)1 << MSR_FE0);
new_msr &= ~((target_ulong)1 << MSR_SE);
new_msr &= ~((target_ulong)1 << MSR_BE);
new_msr &= ~((target_ulong)1 << MSR_FE1);
new_msr &= ~((target_ulong)1 << MSR_IR);
new_msr &= ~((target_ulong)1 << MSR_DR);
#if 0 /* Fix this: not on all targets */
new_msr &= ~((target_ulong)1 << MSR_PMM);
#endif
new_msr &= ~((target_ulong)1 << MSR_LE);
if (msr_ile)
new_msr |= (target_ulong)1 << MSR_LE;
else
new_msr &= ~((target_ulong)1 << MSR_LE);
/* Jump to handler */
vector = env->excp_vectors[excp];
if (vector == (target_ulong)-1) {
cpu_abort(env, "Raised an exception without defined vector %d\n",
excp);
}
vector |= env->excp_prefix;
#if defined(TARGET_PPC64)
if (excp_model == POWERPC_EXCP_BOOKE) {
if (!msr_icm) {
new_msr &= ~((target_ulong)1 << MSR_CM);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_CM;
}
} else {
if (!msr_isf) {
new_msr &= ~((target_ulong)1 << MSR_SF);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_SF;
}
}
#endif
/* XXX: we don't use hreg_store_msr here as already have treated
* any special case that could occur. Just store MSR and update hflags
*/
env->msr = new_msr;
env->hflags_nmsr = 0x00000000;
hreg_compute_hflags(env);
env->nip = vector;
/* Reset exception state */
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
}
| true | qemu | 6f2d8978728c48ca46f5c01835438508aace5c64 | static always_inline void powerpc_excp (CPUState *env,
int excp_model, int excp)
{
target_ulong msr, new_msr, vector;
int srr0, srr1, asrr0, asrr1;
#if defined(TARGET_PPC64H)
int lpes0, lpes1, lev;
lpes0 = (env->spr[SPR_LPCR] >> 1) & 1;
lpes1 = (env->spr[SPR_LPCR] >> 2) & 1;
#endif
if (loglevel & CPU_LOG_INT) {
fprintf(logfile, "Raise exception at 0x" ADDRX " => 0x%08x (%02x)\n",
env->nip, excp, env->error_code);
}
msr = env->msr;
new_msr = msr;
srr0 = SPR_SRR0;
srr1 = SPR_SRR1;
asrr0 = -1;
asrr1 = -1;
msr &= ~((target_ulong)0x783F0000);
switch (excp) {
case POWERPC_EXCP_NONE:
return;
case POWERPC_EXCP_CRITICAL:
new_msr &= ~((target_ulong)1 << MSR_RI);
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
case POWERPC_EXCP_G2:
break;
default:
goto excp_invalid;
}
goto store_next;
case POWERPC_EXCP_MCHECK:
if (msr_me == 0) {
if (loglevel != 0) {
fprintf(logfile, "Machine check while not allowed. "
"Entering checkstop state\n");
} else {
fprintf(stderr, "Machine check while not allowed. "
"Entering checkstop state\n");
}
env->halted = 1;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
new_msr &= ~((target_ulong)1 << MSR_ME);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_MCSRR0;
srr1 = SPR_BOOKE_MCSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
goto store_next;
case POWERPC_EXCP_DSI:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX
"\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISI:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "ISI exception: msr=0x" ADDRX ", nip=0x" ADDRX
"\n", msr, env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= env->error_code;
goto store_next;
case POWERPC_EXCP_EXTERNAL:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes0 == 1)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ALIGN:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
env->spr[SPR_DSISR] |= (ldl_code((env->nip - 4)) & 0x03FF0000) >> 16;
goto store_current;
case POWERPC_EXCP_PROGRAM:
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) {
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Ignore floating point exception\n");
}
#endif
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00100000;
if (msr_fe0 == msr_fe1)
goto store_next;
msr |= 0x00010000;
break;
case POWERPC_EXCP_INVAL:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Invalid instruction at 0x" ADDRX "\n",
env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00080000;
break;
case POWERPC_EXCP_PRIV:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00040000;
break;
case POWERPC_EXCP_TRAP:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00020000;
break;
default:
cpu_abort(env, "Invalid program exception %d. Aborting\n",
env->error_code);
break;
}
goto store_current;
case POWERPC_EXCP_FPU:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_SYSCALL:
if (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&
env->osi_call) {
if (env->osi_call(env) != 0) {
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
}
if (loglevel & CPU_LOG_INT) {
dump_syscall(env);
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
lev = env->error_code;
if (lev == 1 || (lpes0 == 0 && lpes1 == 0))
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_APU:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_DECR:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_FIT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "FIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_WDT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "WDT exception\n");
#endif
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_DTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_ITLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_DEBUG:
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_DSRR0;
srr1 = SPR_BOOKE_DSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
cpu_abort(env, "Debug exception is not implemented yet !\n");
goto store_next;
#if defined(TARGET_PPCEMB)
case POWERPC_EXCP_SPEU:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_EFPDI:
cpu_abort(env, "Embedded floating point data exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EFPRI:
cpu_abort(env, "Embedded floating point round exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EPERFM:
new_msr &= ~((target_ulong)1 << MSR_RI);
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORI:
cpu_abort(env,
"Embedded doorbell interrupt is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORCI:
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
cpu_abort(env, "Embedded doorbell critical interrupt "
"is not implemented yet !\n");
goto store_next;
#endif
case POWERPC_EXCP_RESET:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64)
case POWERPC_EXCP_DSEG:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISEG:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#endif
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDECR:
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_TRACE:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDSI:
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISI:
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HDSEG:
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISEG:
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_VPU:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_PIT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "PIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_IO:
cpu_abort(env, "601 IO error exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_RUNM:
cpu_abort(env, "601 run mode exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EMUL:
cpu_abort(env, "602 emulation trap exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IFTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid instruction TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DLTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid data load TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DSTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
tlb_miss_tgpr:
if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) {
new_msr |= (target_ulong)1 << MSR_TGPR;
hreg_swap_gpr_tgpr(env);
}
goto tlb_miss;
case POWERPC_EXCP_7x5:
tlb_miss:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_IMISS];
cmp = &env->spr[SPR_ICMP];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_DMISS];
cmp = &env->spr[SPR_DCMP];
}
fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" H1 " ADDRX " H2 " ADDRX " %08x\n",
es, en, *miss, en, *cmp,
env->spr[SPR_HASH1], env->spr[SPR_HASH2],
env->error_code);
}
#endif
msr |= env->crf[0] << 28;
msr |= env->error_code;
msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17;
break;
case POWERPC_EXCP_74xx:
tlb_miss_74xx:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
}
fprintf(logfile, "74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" %08x\n",
es, en, *miss, en, *cmp, env->error_code);
}
#endif
msr |= env->error_code;
break;
default:
cpu_abort(env, "Invalid data store TLB miss exception\n");
break;
}
goto store_next;
case POWERPC_EXCP_FPA:
cpu_abort(env, "Floating point assist exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IABR:
cpu_abort(env, "IABR exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SMI:
cpu_abort(env, "SMI exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_THERM:
cpu_abort(env, "Thermal management exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_PERFM:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_VPUA:
cpu_abort(env, "VPU assist exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SOFTP:
cpu_abort(env,
"970 soft-patch exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_MAINT:
cpu_abort(env,
"970 maintenance exception is not implemented yet !\n");
goto store_next;
default:
excp_invalid:
cpu_abort(env, "Invalid PowerPC exception %d. Aborting\n", excp);
break;
store_current:
env->spr[srr0] = env->nip - 4;
break;
store_next:
env->spr[srr0] = env->nip;
break;
}
env->spr[srr1] = msr;
if (asrr0 != -1)
env->spr[asrr0] = env->spr[srr0];
if (asrr1 != -1)
env->spr[asrr1] = env->spr[srr1];
if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))
tlb_flush(env, 1);
new_msr &= ~((target_ulong)1 << MSR_EE);
new_msr &= ~((target_ulong)1 << MSR_PR);
new_msr &= ~((target_ulong)1 << MSR_FP);
new_msr &= ~((target_ulong)1 << MSR_FE0);
new_msr &= ~((target_ulong)1 << MSR_SE);
new_msr &= ~((target_ulong)1 << MSR_BE);
new_msr &= ~((target_ulong)1 << MSR_FE1);
new_msr &= ~((target_ulong)1 << MSR_IR);
new_msr &= ~((target_ulong)1 << MSR_DR);
#if 0
new_msr &= ~((target_ulong)1 << MSR_PMM);
#endif
new_msr &= ~((target_ulong)1 << MSR_LE);
if (msr_ile)
new_msr |= (target_ulong)1 << MSR_LE;
else
new_msr &= ~((target_ulong)1 << MSR_LE);
vector = env->excp_vectors[excp];
if (vector == (target_ulong)-1) {
cpu_abort(env, "Raised an exception without defined vector %d\n",
excp);
}
vector |= env->excp_prefix;
#if defined(TARGET_PPC64)
if (excp_model == POWERPC_EXCP_BOOKE) {
if (!msr_icm) {
new_msr &= ~((target_ulong)1 << MSR_CM);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_CM;
}
} else {
if (!msr_isf) {
new_msr &= ~((target_ulong)1 << MSR_SF);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_SF;
}
}
#endif
env->msr = new_msr;
env->hflags_nmsr = 0x00000000;
hreg_compute_hflags(env);
env->nip = vector;
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
}
| {
"code": [
" if (vector == (target_ulong)-1) {"
],
"line_no": [
1203
]
} | static always_inline void FUNC_0 (CPUState *env,
int excp_model, int excp)
{
target_ulong msr, new_msr, vector;
int VAR_0, VAR_1, VAR_2, VAR_3;
#if defined(TARGET_PPC64H)
int lpes0, lpes1, lev;
lpes0 = (env->spr[SPR_LPCR] >> 1) & 1;
lpes1 = (env->spr[SPR_LPCR] >> 2) & 1;
#endif
if (loglevel & CPU_LOG_INT) {
fprintf(logfile, "Raise exception at 0x" ADDRX " => 0x%08x (%02x)\n",
env->nip, excp, env->error_code);
}
msr = env->msr;
new_msr = msr;
VAR_0 = SPR_SRR0;
VAR_1 = SPR_SRR1;
VAR_2 = -1;
VAR_3 = -1;
msr &= ~((target_ulong)0x783F0000);
switch (excp) {
case POWERPC_EXCP_NONE:
return;
case POWERPC_EXCP_CRITICAL:
new_msr &= ~((target_ulong)1 << MSR_RI);
switch (excp_model) {
case POWERPC_EXCP_40x:
VAR_0 = SPR_40x_SRR2;
VAR_1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
VAR_0 = SPR_BOOKE_CSRR0;
VAR_1 = SPR_BOOKE_CSRR1;
break;
case POWERPC_EXCP_G2:
break;
default:
goto excp_invalid;
}
goto store_next;
case POWERPC_EXCP_MCHECK:
if (msr_me == 0) {
if (loglevel != 0) {
fprintf(logfile, "Machine check while not allowed. "
"Entering checkstop state\n");
} else {
fprintf(stderr, "Machine check while not allowed. "
"Entering checkstop state\n");
}
env->halted = 1;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
new_msr &= ~((target_ulong)1 << MSR_ME);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_40x:
VAR_0 = SPR_40x_SRR2;
VAR_1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
VAR_0 = SPR_BOOKE_MCSRR0;
VAR_1 = SPR_BOOKE_MCSRR1;
VAR_2 = SPR_BOOKE_CSRR0;
VAR_3 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
goto store_next;
case POWERPC_EXCP_DSI:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX
"\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISI:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "ISI exception: msr=0x" ADDRX ", nip=0x" ADDRX
"\n", msr, env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= env->error_code;
goto store_next;
case POWERPC_EXCP_EXTERNAL:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes0 == 1)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ALIGN:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
env->spr[SPR_DSISR] |= (ldl_code((env->nip - 4)) & 0x03FF0000) >> 16;
goto store_current;
case POWERPC_EXCP_PROGRAM:
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) {
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Ignore floating point exception\n");
}
#endif
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00100000;
if (msr_fe0 == msr_fe1)
goto store_next;
msr |= 0x00010000;
break;
case POWERPC_EXCP_INVAL:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Invalid instruction at 0x" ADDRX "\n",
env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00080000;
break;
case POWERPC_EXCP_PRIV:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00040000;
break;
case POWERPC_EXCP_TRAP:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00020000;
break;
default:
cpu_abort(env, "Invalid program exception %d. Aborting\n",
env->error_code);
break;
}
goto store_current;
case POWERPC_EXCP_FPU:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_SYSCALL:
if (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&
env->osi_call) {
if (env->osi_call(env) != 0) {
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
}
if (loglevel & CPU_LOG_INT) {
dump_syscall(env);
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
lev = env->error_code;
if (lev == 1 || (lpes0 == 0 && lpes1 == 0))
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_APU:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_DECR:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_FIT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "FIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_WDT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "WDT exception\n");
#endif
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
VAR_0 = SPR_BOOKE_CSRR0;
VAR_1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_DTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_ITLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_DEBUG:
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
VAR_0 = SPR_BOOKE_DSRR0;
VAR_1 = SPR_BOOKE_DSRR1;
VAR_2 = SPR_BOOKE_CSRR0;
VAR_3 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
cpu_abort(env, "Debug exception is not implemented yet !\n");
goto store_next;
#if defined(TARGET_PPCEMB)
case POWERPC_EXCP_SPEU:
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_EFPDI:
cpu_abort(env, "Embedded floating point data exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EFPRI:
cpu_abort(env, "Embedded floating point round exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EPERFM:
new_msr &= ~((target_ulong)1 << MSR_RI);
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORI:
cpu_abort(env,
"Embedded doorbell interrupt is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORCI:
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
VAR_0 = SPR_BOOKE_CSRR0;
VAR_1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
cpu_abort(env, "Embedded doorbell critical interrupt "
"is not implemented yet !\n");
goto store_next;
#endif
case POWERPC_EXCP_RESET:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64)
case POWERPC_EXCP_DSEG:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISEG:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#endif
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDECR:
VAR_0 = SPR_HSRR0;
VAR_1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_TRACE:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDSI:
VAR_0 = SPR_HSRR0;
VAR_1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISI:
VAR_0 = SPR_HSRR0;
VAR_1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HDSEG:
VAR_0 = SPR_HSRR0;
VAR_1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISEG:
VAR_0 = SPR_HSRR0;
VAR_1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_VPU:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_PIT:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "PIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_next;
case POWERPC_EXCP_IO:
cpu_abort(env, "601 IO error exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_RUNM:
cpu_abort(env, "601 run mode exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EMUL:
cpu_abort(env, "602 emulation trap exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IFTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid instruction TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DLTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid data load TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DSTLB:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
tlb_miss_tgpr:
if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) {
new_msr |= (target_ulong)1 << MSR_TGPR;
hreg_swap_gpr_tgpr(env);
}
goto tlb_miss;
case POWERPC_EXCP_7x5:
tlb_miss:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_IMISS];
cmp = &env->spr[SPR_ICMP];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_DMISS];
cmp = &env->spr[SPR_DCMP];
}
fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" H1 " ADDRX " H2 " ADDRX " %08x\n",
es, en, *miss, en, *cmp,
env->spr[SPR_HASH1], env->spr[SPR_HASH2],
env->error_code);
}
#endif
msr |= env->crf[0] << 28;
msr |= env->error_code;
msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17;
break;
case POWERPC_EXCP_74xx:
tlb_miss_74xx:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
}
fprintf(logfile, "74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" %08x\n",
es, en, *miss, en, *cmp, env->error_code);
}
#endif
msr |= env->error_code;
break;
default:
cpu_abort(env, "Invalid data store TLB miss exception\n");
break;
}
goto store_next;
case POWERPC_EXCP_FPA:
cpu_abort(env, "Floating point assist exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IABR:
cpu_abort(env, "IABR exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SMI:
cpu_abort(env, "SMI exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_THERM:
cpu_abort(env, "Thermal management exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_PERFM:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_VPUA:
cpu_abort(env, "VPU assist exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SOFTP:
cpu_abort(env,
"970 soft-patch exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_MAINT:
cpu_abort(env,
"970 maintenance exception is not implemented yet !\n");
goto store_next;
default:
excp_invalid:
cpu_abort(env, "Invalid PowerPC exception %d. Aborting\n", excp);
break;
store_current:
env->spr[VAR_0] = env->nip - 4;
break;
store_next:
env->spr[VAR_0] = env->nip;
break;
}
env->spr[VAR_1] = msr;
if (VAR_2 != -1)
env->spr[VAR_2] = env->spr[VAR_0];
if (VAR_3 != -1)
env->spr[VAR_3] = env->spr[VAR_1];
if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))
tlb_flush(env, 1);
new_msr &= ~((target_ulong)1 << MSR_EE);
new_msr &= ~((target_ulong)1 << MSR_PR);
new_msr &= ~((target_ulong)1 << MSR_FP);
new_msr &= ~((target_ulong)1 << MSR_FE0);
new_msr &= ~((target_ulong)1 << MSR_SE);
new_msr &= ~((target_ulong)1 << MSR_BE);
new_msr &= ~((target_ulong)1 << MSR_FE1);
new_msr &= ~((target_ulong)1 << MSR_IR);
new_msr &= ~((target_ulong)1 << MSR_DR);
#if 0
new_msr &= ~((target_ulong)1 << MSR_PMM);
#endif
new_msr &= ~((target_ulong)1 << MSR_LE);
if (msr_ile)
new_msr |= (target_ulong)1 << MSR_LE;
else
new_msr &= ~((target_ulong)1 << MSR_LE);
vector = env->excp_vectors[excp];
if (vector == (target_ulong)-1) {
cpu_abort(env, "Raised an exception without defined vector %d\n",
excp);
}
vector |= env->excp_prefix;
#if defined(TARGET_PPC64)
if (excp_model == POWERPC_EXCP_BOOKE) {
if (!msr_icm) {
new_msr &= ~((target_ulong)1 << MSR_CM);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_CM;
}
} else {
if (!msr_isf) {
new_msr &= ~((target_ulong)1 << MSR_SF);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_SF;
}
}
#endif
env->msr = new_msr;
env->hflags_nmsr = 0x00000000;
hreg_compute_hflags(env);
env->nip = vector;
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
}
| [
"static always_inline void FUNC_0 (CPUState *env,\nint excp_model, int excp)\n{",
"target_ulong msr, new_msr, vector;",
"int VAR_0, VAR_1, VAR_2, VAR_3;",
"#if defined(TARGET_PPC64H)\nint lpes0, lpes1, lev;",
"lpes0 = (env->spr[SPR_LPCR] >> 1) & 1;",
"lpes1 = (env->spr[SPR_LPCR] >> 2) & 1;",
"#endif\nif (loglevel & CPU_LOG_INT) {",
"fprintf(logfile, \"Raise exception at 0x\" ADDRX \" => 0x%08x (%02x)\\n\",\nenv->nip, excp, env->error_code);",
"}",
"msr = env->msr;",
"new_msr = msr;",
"VAR_0 = SPR_SRR0;",
"VAR_1 = SPR_SRR1;",
"VAR_2 = -1;",
"VAR_3 = -1;",
"msr &= ~((target_ulong)0x783F0000);",
"switch (excp) {",
"case POWERPC_EXCP_NONE:\nreturn;",
"case POWERPC_EXCP_CRITICAL:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"switch (excp_model) {",
"case POWERPC_EXCP_40x:\nVAR_0 = SPR_40x_SRR2;",
"VAR_1 = SPR_40x_SRR3;",
"break;",
"case POWERPC_EXCP_BOOKE:\nVAR_0 = SPR_BOOKE_CSRR0;",
"VAR_1 = SPR_BOOKE_CSRR1;",
"break;",
"case POWERPC_EXCP_G2:\nbreak;",
"default:\ngoto excp_invalid;",
"}",
"goto store_next;",
"case POWERPC_EXCP_MCHECK:\nif (msr_me == 0) {",
"if (loglevel != 0) {",
"fprintf(logfile, \"Machine check while not allowed. \"\n\"Entering checkstop state\\n\");",
"} else {",
"fprintf(stderr, \"Machine check while not allowed. \"\n\"Entering checkstop state\\n\");",
"}",
"env->halted = 1;",
"env->interrupt_request |= CPU_INTERRUPT_EXITTB;",
"}",
"new_msr &= ~((target_ulong)1 << MSR_RI);",
"new_msr &= ~((target_ulong)1 << MSR_ME);",
"#if defined(TARGET_PPC64H)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nswitch (excp_model) {",
"case POWERPC_EXCP_40x:\nVAR_0 = SPR_40x_SRR2;",
"VAR_1 = SPR_40x_SRR3;",
"break;",
"case POWERPC_EXCP_BOOKE:\nVAR_0 = SPR_BOOKE_MCSRR0;",
"VAR_1 = SPR_BOOKE_MCSRR1;",
"VAR_2 = SPR_BOOKE_CSRR0;",
"VAR_3 = SPR_BOOKE_CSRR1;",
"break;",
"default:\nbreak;",
"}",
"goto store_next;",
"case POWERPC_EXCP_DSI:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0) {",
"fprintf(logfile, \"DSI exception: DSISR=0x\" ADDRX\" DAR=0x\" ADDRX\n\"\\n\", env->spr[SPR_DSISR], env->spr[SPR_DAR]);",
"}",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"case POWERPC_EXCP_ISI:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0) {",
"fprintf(logfile, \"ISI exception: msr=0x\" ADDRX \", nip=0x\" ADDRX\n\"\\n\", msr, env->nip);",
"}",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nmsr |= env->error_code;",
"goto store_next;",
"case POWERPC_EXCP_EXTERNAL:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes0 == 1)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"case POWERPC_EXCP_ALIGN:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nenv->spr[SPR_DSISR] |= (ldl_code((env->nip - 4)) & 0x03FF0000) >> 16;",
"goto store_current;",
"case POWERPC_EXCP_PROGRAM:\nswitch (env->error_code & ~0xF) {",
"case POWERPC_EXCP_FP:\nif ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) {",
"#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0) {",
"fprintf(logfile, \"Ignore floating point exception\\n\");",
"}",
"#endif\nenv->exception_index = POWERPC_EXCP_NONE;",
"env->error_code = 0;",
"return;",
"}",
"new_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nmsr |= 0x00100000;",
"if (msr_fe0 == msr_fe1)\ngoto store_next;",
"msr |= 0x00010000;",
"break;",
"case POWERPC_EXCP_INVAL:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0) {",
"fprintf(logfile, \"Invalid instruction at 0x\" ADDRX \"\\n\",\nenv->nip);",
"}",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nmsr |= 0x00080000;",
"break;",
"case POWERPC_EXCP_PRIV:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nmsr |= 0x00040000;",
"break;",
"case POWERPC_EXCP_TRAP:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nmsr |= 0x00020000;",
"break;",
"default:\ncpu_abort(env, \"Invalid program exception %d. Aborting\\n\",\nenv->error_code);",
"break;",
"}",
"goto store_current;",
"case POWERPC_EXCP_FPU:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_current;",
"case POWERPC_EXCP_SYSCALL:\nif (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&\nenv->osi_call) {",
"if (env->osi_call(env) != 0) {",
"env->exception_index = POWERPC_EXCP_NONE;",
"env->error_code = 0;",
"return;",
"}",
"}",
"if (loglevel & CPU_LOG_INT) {",
"dump_syscall(env);",
"}",
"new_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nlev = env->error_code;",
"if (lev == 1 || (lpes0 == 0 && lpes1 == 0))\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"case POWERPC_EXCP_APU:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_current;",
"case POWERPC_EXCP_DECR:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"case POWERPC_EXCP_FIT:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0)\nfprintf(logfile, \"FIT exception\\n\");",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_next;",
"case POWERPC_EXCP_WDT:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0)\nfprintf(logfile, \"WDT exception\\n\");",
"#endif\nswitch (excp_model) {",
"case POWERPC_EXCP_BOOKE:\nVAR_0 = SPR_BOOKE_CSRR0;",
"VAR_1 = SPR_BOOKE_CSRR1;",
"break;",
"default:\nbreak;",
"}",
"new_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_next;",
"case POWERPC_EXCP_DTLB:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_next;",
"case POWERPC_EXCP_ITLB:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_next;",
"case POWERPC_EXCP_DEBUG:\nswitch (excp_model) {",
"case POWERPC_EXCP_BOOKE:\nVAR_0 = SPR_BOOKE_DSRR0;",
"VAR_1 = SPR_BOOKE_DSRR1;",
"VAR_2 = SPR_BOOKE_CSRR0;",
"VAR_3 = SPR_BOOKE_CSRR1;",
"break;",
"default:\nbreak;",
"}",
"cpu_abort(env, \"Debug exception is not implemented yet !\\n\");",
"goto store_next;",
"#if defined(TARGET_PPCEMB)\ncase POWERPC_EXCP_SPEU:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_current;",
"case POWERPC_EXCP_EFPDI:\ncpu_abort(env, \"Embedded floating point data exception \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_EFPRI:\ncpu_abort(env, \"Embedded floating point round exception \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_EPERFM:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"cpu_abort(env,\n\"Performance counter exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_DOORI:\ncpu_abort(env,\n\"Embedded doorbell interrupt is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_DOORCI:\nswitch (excp_model) {",
"case POWERPC_EXCP_BOOKE:\nVAR_0 = SPR_BOOKE_CSRR0;",
"VAR_1 = SPR_BOOKE_CSRR1;",
"break;",
"default:\nbreak;",
"}",
"cpu_abort(env, \"Embedded doorbell critical interrupt \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"#endif\ncase POWERPC_EXCP_RESET:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"#if defined(TARGET_PPC64)\ncase POWERPC_EXCP_DSEG:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"case POWERPC_EXCP_ISEG:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"#endif\n#if defined(TARGET_PPC64H)\ncase POWERPC_EXCP_HDECR:\nVAR_0 = SPR_HSRR0;",
"VAR_1 = SPR_HSRR1;",
"new_msr |= (target_ulong)1 << MSR_HV;",
"goto store_next;",
"#endif\ncase POWERPC_EXCP_TRACE:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_next;",
"#if defined(TARGET_PPC64H)\ncase POWERPC_EXCP_HDSI:\nVAR_0 = SPR_HSRR0;",
"VAR_1 = SPR_HSRR1;",
"new_msr |= (target_ulong)1 << MSR_HV;",
"goto store_next;",
"case POWERPC_EXCP_HISI:\nVAR_0 = SPR_HSRR0;",
"VAR_1 = SPR_HSRR1;",
"new_msr |= (target_ulong)1 << MSR_HV;",
"goto store_next;",
"case POWERPC_EXCP_HDSEG:\nVAR_0 = SPR_HSRR0;",
"VAR_1 = SPR_HSRR1;",
"new_msr |= (target_ulong)1 << MSR_HV;",
"goto store_next;",
"case POWERPC_EXCP_HISEG:\nVAR_0 = SPR_HSRR0;",
"VAR_1 = SPR_HSRR1;",
"new_msr |= (target_ulong)1 << MSR_HV;",
"goto store_next;",
"#endif\ncase POWERPC_EXCP_VPU:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ngoto store_current;",
"case POWERPC_EXCP_PIT:\n#if defined (DEBUG_EXCEPTIONS)\nif (loglevel != 0)\nfprintf(logfile, \"PIT exception\\n\");",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"goto store_next;",
"case POWERPC_EXCP_IO:\ncpu_abort(env, \"601 IO error exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_RUNM:\ncpu_abort(env, \"601 run mode exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_EMUL:\ncpu_abort(env, \"602 emulation trap exception \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_IFTLB:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nswitch (excp_model) {",
"case POWERPC_EXCP_602:\ncase POWERPC_EXCP_603:\ncase POWERPC_EXCP_603E:\ncase POWERPC_EXCP_G2:\ngoto tlb_miss_tgpr;",
"case POWERPC_EXCP_7x5:\ngoto tlb_miss;",
"case POWERPC_EXCP_74xx:\ngoto tlb_miss_74xx;",
"default:\ncpu_abort(env, \"Invalid instruction TLB miss exception\\n\");",
"break;",
"}",
"break;",
"case POWERPC_EXCP_DLTLB:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nswitch (excp_model) {",
"case POWERPC_EXCP_602:\ncase POWERPC_EXCP_603:\ncase POWERPC_EXCP_603E:\ncase POWERPC_EXCP_G2:\ngoto tlb_miss_tgpr;",
"case POWERPC_EXCP_7x5:\ngoto tlb_miss;",
"case POWERPC_EXCP_74xx:\ngoto tlb_miss_74xx;",
"default:\ncpu_abort(env, \"Invalid data load TLB miss exception\\n\");",
"break;",
"}",
"break;",
"case POWERPC_EXCP_DSTLB:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\nswitch (excp_model) {",
"case POWERPC_EXCP_602:\ncase POWERPC_EXCP_603:\ncase POWERPC_EXCP_603E:\ncase POWERPC_EXCP_G2:\ntlb_miss_tgpr:\nif (!(new_msr & ((target_ulong)1 << MSR_TGPR))) {",
"new_msr |= (target_ulong)1 << MSR_TGPR;",
"hreg_swap_gpr_tgpr(env);",
"}",
"goto tlb_miss;",
"case POWERPC_EXCP_7x5:\ntlb_miss:\n#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"const unsigned char *es;",
"target_ulong *miss, *cmp;",
"int en;",
"if (excp == POWERPC_EXCP_IFTLB) {",
"es = \"I\";",
"en = 'I';",
"miss = &env->spr[SPR_IMISS];",
"cmp = &env->spr[SPR_ICMP];",
"} else {",
"if (excp == POWERPC_EXCP_DLTLB)\nes = \"DL\";",
"else\nes = \"DS\";",
"en = 'D';",
"miss = &env->spr[SPR_DMISS];",
"cmp = &env->spr[SPR_DCMP];",
"}",
"fprintf(logfile, \"6xx %sTLB miss: %cM \" ADDRX \" %cC \" ADDRX\n\" H1 \" ADDRX \" H2 \" ADDRX \" %08x\\n\",\nes, en, *miss, en, *cmp,\nenv->spr[SPR_HASH1], env->spr[SPR_HASH2],\nenv->error_code);",
"}",
"#endif\nmsr |= env->crf[0] << 28;",
"msr |= env->error_code;",
"msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17;",
"break;",
"case POWERPC_EXCP_74xx:\ntlb_miss_74xx:\n#if defined (DEBUG_SOFTWARE_TLB)\nif (loglevel != 0) {",
"const unsigned char *es;",
"target_ulong *miss, *cmp;",
"int en;",
"if (excp == POWERPC_EXCP_IFTLB) {",
"es = \"I\";",
"en = 'I';",
"miss = &env->spr[SPR_TLBMISS];",
"cmp = &env->spr[SPR_PTEHI];",
"} else {",
"if (excp == POWERPC_EXCP_DLTLB)\nes = \"DL\";",
"else\nes = \"DS\";",
"en = 'D';",
"miss = &env->spr[SPR_TLBMISS];",
"cmp = &env->spr[SPR_PTEHI];",
"}",
"fprintf(logfile, \"74xx %sTLB miss: %cM \" ADDRX \" %cC \" ADDRX\n\" %08x\\n\",\nes, en, *miss, en, *cmp, env->error_code);",
"}",
"#endif\nmsr |= env->error_code;",
"break;",
"default:\ncpu_abort(env, \"Invalid data store TLB miss exception\\n\");",
"break;",
"}",
"goto store_next;",
"case POWERPC_EXCP_FPA:\ncpu_abort(env, \"Floating point assist exception \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_IABR:\ncpu_abort(env, \"IABR exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_SMI:\ncpu_abort(env, \"SMI exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_THERM:\ncpu_abort(env, \"Thermal management exception \"\n\"is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_PERFM:\nnew_msr &= ~((target_ulong)1 << MSR_RI);",
"#if defined(TARGET_PPC64H)\nif (lpes1 == 0)\nnew_msr |= (target_ulong)1 << MSR_HV;",
"#endif\ncpu_abort(env,\n\"Performance counter exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_VPUA:\ncpu_abort(env, \"VPU assist exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_SOFTP:\ncpu_abort(env,\n\"970 soft-patch exception is not implemented yet !\\n\");",
"goto store_next;",
"case POWERPC_EXCP_MAINT:\ncpu_abort(env,\n\"970 maintenance exception is not implemented yet !\\n\");",
"goto store_next;",
"default:\nexcp_invalid:\ncpu_abort(env, \"Invalid PowerPC exception %d. Aborting\\n\", excp);",
"break;",
"store_current:\nenv->spr[VAR_0] = env->nip - 4;",
"break;",
"store_next:\nenv->spr[VAR_0] = env->nip;",
"break;",
"}",
"env->spr[VAR_1] = msr;",
"if (VAR_2 != -1)\nenv->spr[VAR_2] = env->spr[VAR_0];",
"if (VAR_3 != -1)\nenv->spr[VAR_3] = env->spr[VAR_1];",
"if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))\ntlb_flush(env, 1);",
"new_msr &= ~((target_ulong)1 << MSR_EE);",
"new_msr &= ~((target_ulong)1 << MSR_PR);",
"new_msr &= ~((target_ulong)1 << MSR_FP);",
"new_msr &= ~((target_ulong)1 << MSR_FE0);",
"new_msr &= ~((target_ulong)1 << MSR_SE);",
"new_msr &= ~((target_ulong)1 << MSR_BE);",
"new_msr &= ~((target_ulong)1 << MSR_FE1);",
"new_msr &= ~((target_ulong)1 << MSR_IR);",
"new_msr &= ~((target_ulong)1 << MSR_DR);",
"#if 0\nnew_msr &= ~((target_ulong)1 << MSR_PMM);",
"#endif\nnew_msr &= ~((target_ulong)1 << MSR_LE);",
"if (msr_ile)\nnew_msr |= (target_ulong)1 << MSR_LE;",
"else\nnew_msr &= ~((target_ulong)1 << MSR_LE);",
"vector = env->excp_vectors[excp];",
"if (vector == (target_ulong)-1) {",
"cpu_abort(env, \"Raised an exception without defined vector %d\\n\",\nexcp);",
"}",
"vector |= env->excp_prefix;",
"#if defined(TARGET_PPC64)\nif (excp_model == POWERPC_EXCP_BOOKE) {",
"if (!msr_icm) {",
"new_msr &= ~((target_ulong)1 << MSR_CM);",
"vector = (uint32_t)vector;",
"} else {",
"new_msr |= (target_ulong)1 << MSR_CM;",
"}",
"} else {",
"if (!msr_isf) {",
"new_msr &= ~((target_ulong)1 << MSR_SF);",
"vector = (uint32_t)vector;",
"} else {",
"new_msr |= (target_ulong)1 << MSR_SF;",
"}",
"}",
"#endif\nenv->msr = new_msr;",
"env->hflags_nmsr = 0x00000000;",
"hreg_compute_hflags(env);",
"env->nip = vector;",
"env->exception_index = POWERPC_EXCP_NONE;",
"env->error_code = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89,
91
],
[
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127,
131
],
[
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161,
163,
165
],
[
167,
169
],
[
171
],
[
173,
175
],
[
177,
179,
181
],
[
183,
185
],
[
187,
189,
191
],
[
193,
195
],
[
197
],
[
199,
201
],
[
203,
205,
207
],
[
209,
211
],
[
213
],
[
215,
217
],
[
219,
221,
223
],
[
225,
227
],
[
229,
231
],
[
233,
235,
237
],
[
239,
245
],
[
247
],
[
249,
251
],
[
253,
255
],
[
257,
259
],
[
261
],
[
263
],
[
265,
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277,
279,
281
],
[
283,
285
],
[
287,
289
],
[
291
],
[
293
],
[
295,
297,
299
],
[
301,
303
],
[
305
],
[
307,
309
],
[
311,
313,
315
],
[
317,
319
],
[
321
],
[
323,
325
],
[
327,
329,
331
],
[
333,
335
],
[
337
],
[
339,
341
],
[
343,
345,
347
],
[
349,
351
],
[
353
],
[
355,
359,
361
],
[
363
],
[
365
],
[
367
],
[
369,
371
],
[
373,
375,
377
],
[
379,
381
],
[
383,
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
419,
421
],
[
423,
425
],
[
427,
429
],
[
431
],
[
433,
435
],
[
437,
439,
441
],
[
443,
445
],
[
447,
451,
453,
455
],
[
457,
459
],
[
461
],
[
463,
465,
467,
469
],
[
471,
473
],
[
475,
477
],
[
479
],
[
481
],
[
483,
485
],
[
487
],
[
489
],
[
491
],
[
493,
495
],
[
497
],
[
499,
501
],
[
503
],
[
505,
507
],
[
509,
511
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521,
523
],
[
525
],
[
529
],
[
531
],
[
533,
535,
537
],
[
539
],
[
541,
545,
547
],
[
549
],
[
551,
555,
557
],
[
559
],
[
561,
563
],
[
567,
569
],
[
571
],
[
573,
577,
579
],
[
581
],
[
583,
585
],
[
587,
589
],
[
591
],
[
593
],
[
595,
597
],
[
599
],
[
603,
605
],
[
607
],
[
609,
611,
613
],
[
615,
617
],
[
619,
621
],
[
623,
625,
627
],
[
629,
631,
633
],
[
635,
637
],
[
639,
641
],
[
643,
645,
647
],
[
649,
651
],
[
653,
655,
657,
659
],
[
661
],
[
663
],
[
665
],
[
667,
669,
671
],
[
673,
675,
677
],
[
679,
681
],
[
683,
685,
687
],
[
689
],
[
691
],
[
693
],
[
695,
697
],
[
699
],
[
701
],
[
703
],
[
705,
707
],
[
709
],
[
711
],
[
713
],
[
715,
717
],
[
719
],
[
721
],
[
723
],
[
725,
727,
729
],
[
731,
733,
735
],
[
737,
739
],
[
741,
743,
745,
747
],
[
749,
751
],
[
753
],
[
755,
759
],
[
761
],
[
763,
767
],
[
769
],
[
771,
775,
777
],
[
779
],
[
781,
783
],
[
785,
787,
789
],
[
791,
793
],
[
795,
797,
799,
801,
803
],
[
805,
807
],
[
809,
811
],
[
813,
815
],
[
817
],
[
819
],
[
821
],
[
823,
825
],
[
827,
829,
831
],
[
833,
835
],
[
837,
839,
841,
843,
845
],
[
847,
849
],
[
851,
853
],
[
855,
857
],
[
859
],
[
861
],
[
863
],
[
865,
867
],
[
869,
871,
873
],
[
875,
877
],
[
879,
881,
883,
885,
887,
891
],
[
893
],
[
895
],
[
897
],
[
899
],
[
901,
903,
905,
907
],
[
909
],
[
911
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
923
],
[
925
],
[
927,
929
],
[
931,
933
],
[
935
],
[
937
],
[
939
],
[
941
],
[
943,
945,
947,
949,
951
],
[
953
],
[
955,
957
],
[
959
],
[
963
],
[
965
],
[
967,
969,
971,
973
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
987
],
[
989
],
[
991
],
[
993,
995
],
[
997,
999
],
[
1001
],
[
1003
],
[
1005
],
[
1007
],
[
1009,
1011,
1013
],
[
1015
],
[
1017,
1019
],
[
1021
],
[
1023,
1025
],
[
1027
],
[
1029
],
[
1031
],
[
1033,
1037,
1039
],
[
1041
],
[
1043,
1047
],
[
1049
],
[
1051,
1055
],
[
1057
],
[
1059,
1063,
1065
],
[
1067
],
[
1069,
1071
],
[
1073,
1075,
1077
],
[
1079,
1083,
1085
],
[
1087
],
[
1089,
1093
],
[
1095
],
[
1097,
1101,
1103
],
[
1105
],
[
1107,
1111,
1113
],
[
1115
],
[
1117,
1119,
1121
],
[
1123
],
[
1125,
1129
],
[
1131
],
[
1133,
1137
],
[
1139
],
[
1141
],
[
1145
],
[
1149,
1151
],
[
1153,
1155
],
[
1159,
1161
],
[
1165
],
[
1167
],
[
1169
],
[
1171
],
[
1173
],
[
1175
],
[
1177
],
[
1179
],
[
1181
],
[
1183,
1185
],
[
1187,
1189
],
[
1191,
1193
],
[
1195,
1197
],
[
1201
],
[
1203
],
[
1205,
1207
],
[
1209
],
[
1211
],
[
1213,
1215
],
[
1217
],
[
1219
],
[
1221
],
[
1223
],
[
1225
],
[
1227
],
[
1229
],
[
1231
],
[
1233
],
[
1235
],
[
1237
],
[
1239
],
[
1241
],
[
1243
],
[
1245,
1253
],
[
1255
],
[
1257
],
[
1259
],
[
1263
],
[
1265
],
[
1267
]
] |
23,311 | static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
{
uint8_t list[256] = {0};
uint8_t list_inv[256];
int counttab[256] = {0};
int count, i, x, y;
#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]]
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = V(x,y) + 1;
int vl = x ? V(x-1,y) + 1 : 0;
int vr = x+1<w ? V(x+1,y) + 1 : 0;
int vt = y ? V(x,y-1) + 1 : 0;
int vb = y+1<h ? V(x,y+1) + 1 : 0;
counttab[v-1] += !!((v!=vl) + (v!=vr) + (v!=vt) + (v!=vb));
}
}
#define L(x,y) list[ rect->data[0][(x) + (y)*rect->linesize[0]] ]
for (i = 0; i<256; i++) {
int scoretab[256] = {0};
int bestscore = 0;
int bestv = 0;
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = rect->data[0][x + y*rect->linesize[0]];
int l_m = list[v];
int l_l = x ? L(x-1, y) : 1;
int l_r = x+1<w ? L(x+1, y) : 1;
int l_t = y ? L(x, y-1) : 1;
int l_b = y+1<h ? L(x, y+1) : 1;
int score;
if (l_m)
continue;
scoretab[v] += l_l + l_r + l_t + l_b;
score = 1024LL*scoretab[v] / counttab[v];
if (score > bestscore) {
bestscore = score;
bestv = v;
}
}
}
if (!bestscore)
break;
list [ bestv ] = 1;
list_inv[ i ] = bestv;
}
count = i - 1;
for (i--; i>=0; i--) {
int v = i*255/count;
AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
}
}
| true | FFmpeg | c82b8ef0e4f226423ddd644bfe37e6a15d070924 | static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
{
uint8_t list[256] = {0};
uint8_t list_inv[256];
int counttab[256] = {0};
int count, i, x, y;
#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]]
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = V(x,y) + 1;
int vl = x ? V(x-1,y) + 1 : 0;
int vr = x+1<w ? V(x+1,y) + 1 : 0;
int vt = y ? V(x,y-1) + 1 : 0;
int vb = y+1<h ? V(x,y+1) + 1 : 0;
counttab[v-1] += !!((v!=vl) + (v!=vr) + (v!=vt) + (v!=vb));
}
}
#define L(x,y) list[ rect->data[0][(x) + (y)*rect->linesize[0]] ]
for (i = 0; i<256; i++) {
int scoretab[256] = {0};
int bestscore = 0;
int bestv = 0;
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = rect->data[0][x + y*rect->linesize[0]];
int l_m = list[v];
int l_l = x ? L(x-1, y) : 1;
int l_r = x+1<w ? L(x+1, y) : 1;
int l_t = y ? L(x, y-1) : 1;
int l_b = y+1<h ? L(x, y+1) : 1;
int score;
if (l_m)
continue;
scoretab[v] += l_l + l_r + l_t + l_b;
score = 1024LL*scoretab[v] / counttab[v];
if (score > bestscore) {
bestscore = score;
bestv = v;
}
}
}
if (!bestscore)
break;
list [ bestv ] = 1;
list_inv[ i ] = bestv;
}
count = i - 1;
for (i--; i>=0; i--) {
int v = i*255/count;
AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
}
}
| {
"code": [
" count = i - 1;"
],
"line_no": [
99
]
} | static void FUNC_0(AVSubtitleRect *VAR_0, int VAR_1, int VAR_2)
{
uint8_t list[256] = {0};
uint8_t list_inv[256];
int VAR_3[256] = {0};
int VAR_4, VAR_5, VAR_6, VAR_7;
#define V(VAR_6,VAR_7) VAR_0->data[0][(VAR_6) + (VAR_7)*VAR_0->linesize[0]]
for (VAR_7 = 0; VAR_7<VAR_2; VAR_7++) {
for (VAR_6 = 0; VAR_6<VAR_1; VAR_6++) {
int VAR_22 = V(VAR_6,VAR_7) + 1;
int VAR_9 = VAR_6 ? V(VAR_6-1,VAR_7) + 1 : 0;
int VAR_10 = VAR_6+1<VAR_1 ? V(VAR_6+1,VAR_7) + 1 : 0;
int VAR_11 = VAR_7 ? V(VAR_6,VAR_7-1) + 1 : 0;
int VAR_12 = VAR_7+1<VAR_2 ? V(VAR_6,VAR_7+1) + 1 : 0;
VAR_3[VAR_22-1] += !!((VAR_22!=VAR_9) + (VAR_22!=VAR_10) + (VAR_22!=VAR_11) + (VAR_22!=VAR_12));
}
}
#define L(VAR_6,VAR_7) list[ VAR_0->data[0][(VAR_6) + (VAR_7)*VAR_0->linesize[0]] ]
for (VAR_5 = 0; VAR_5<256; VAR_5++) {
int VAR_13[256] = {0};
int VAR_14 = 0;
int VAR_15 = 0;
for (VAR_7 = 0; VAR_7<VAR_2; VAR_7++) {
for (VAR_6 = 0; VAR_6<VAR_1; VAR_6++) {
int VAR_22 = VAR_0->data[0][VAR_6 + VAR_7*VAR_0->linesize[0]];
int VAR_16 = list[VAR_22];
int VAR_17 = VAR_6 ? L(VAR_6-1, VAR_7) : 1;
int VAR_18 = VAR_6+1<VAR_1 ? L(VAR_6+1, VAR_7) : 1;
int VAR_19 = VAR_7 ? L(VAR_6, VAR_7-1) : 1;
int VAR_20 = VAR_7+1<VAR_2 ? L(VAR_6, VAR_7+1) : 1;
int VAR_21;
if (VAR_16)
continue;
VAR_13[VAR_22] += VAR_17 + VAR_18 + VAR_19 + VAR_20;
VAR_21 = 1024LL*VAR_13[VAR_22] / VAR_3[VAR_22];
if (VAR_21 > VAR_14) {
VAR_14 = VAR_21;
VAR_15 = VAR_22;
}
}
}
if (!VAR_14)
break;
list [ VAR_15 ] = 1;
list_inv[ VAR_5 ] = VAR_15;
}
VAR_4 = VAR_5 - 1;
for (VAR_5--; VAR_5>=0; VAR_5--) {
int VAR_22 = VAR_5*255/VAR_4;
AV_WN32(VAR_0->data[1] + 4*list_inv[VAR_5], RGBA(VAR_22/2,VAR_22,VAR_22/2,VAR_22));
}
}
| [
"static void FUNC_0(AVSubtitleRect *VAR_0, int VAR_1, int VAR_2)\n{",
"uint8_t list[256] = {0};",
"uint8_t list_inv[256];",
"int VAR_3[256] = {0};",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"#define V(VAR_6,VAR_7) VAR_0->data[0][(VAR_6) + (VAR_7)*VAR_0->linesize[0]]\nfor (VAR_7 = 0; VAR_7<VAR_2; VAR_7++) {",
"for (VAR_6 = 0; VAR_6<VAR_1; VAR_6++) {",
"int VAR_22 = V(VAR_6,VAR_7) + 1;",
"int VAR_9 = VAR_6 ? V(VAR_6-1,VAR_7) + 1 : 0;",
"int VAR_10 = VAR_6+1<VAR_1 ? V(VAR_6+1,VAR_7) + 1 : 0;",
"int VAR_11 = VAR_7 ? V(VAR_6,VAR_7-1) + 1 : 0;",
"int VAR_12 = VAR_7+1<VAR_2 ? V(VAR_6,VAR_7+1) + 1 : 0;",
"VAR_3[VAR_22-1] += !!((VAR_22!=VAR_9) + (VAR_22!=VAR_10) + (VAR_22!=VAR_11) + (VAR_22!=VAR_12));",
"}",
"}",
"#define L(VAR_6,VAR_7) list[ VAR_0->data[0][(VAR_6) + (VAR_7)*VAR_0->linesize[0]] ]\nfor (VAR_5 = 0; VAR_5<256; VAR_5++) {",
"int VAR_13[256] = {0};",
"int VAR_14 = 0;",
"int VAR_15 = 0;",
"for (VAR_7 = 0; VAR_7<VAR_2; VAR_7++) {",
"for (VAR_6 = 0; VAR_6<VAR_1; VAR_6++) {",
"int VAR_22 = VAR_0->data[0][VAR_6 + VAR_7*VAR_0->linesize[0]];",
"int VAR_16 = list[VAR_22];",
"int VAR_17 = VAR_6 ? L(VAR_6-1, VAR_7) : 1;",
"int VAR_18 = VAR_6+1<VAR_1 ? L(VAR_6+1, VAR_7) : 1;",
"int VAR_19 = VAR_7 ? L(VAR_6, VAR_7-1) : 1;",
"int VAR_20 = VAR_7+1<VAR_2 ? L(VAR_6, VAR_7+1) : 1;",
"int VAR_21;",
"if (VAR_16)\ncontinue;",
"VAR_13[VAR_22] += VAR_17 + VAR_18 + VAR_19 + VAR_20;",
"VAR_21 = 1024LL*VAR_13[VAR_22] / VAR_3[VAR_22];",
"if (VAR_21 > VAR_14) {",
"VAR_14 = VAR_21;",
"VAR_15 = VAR_22;",
"}",
"}",
"}",
"if (!VAR_14)\nbreak;",
"list [ VAR_15 ] = 1;",
"list_inv[ VAR_5 ] = VAR_15;",
"}",
"VAR_4 = VAR_5 - 1;",
"for (VAR_5--; VAR_5>=0; VAR_5--) {",
"int VAR_22 = VAR_5*255/VAR_4;",
"AV_WN32(VAR_0->data[1] + 4*list_inv[VAR_5], RGBA(VAR_22/2,VAR_22,VAR_22/2,VAR_22));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
23,312 | static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
g_free(s->l1_table);
g_free(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| true | qemu | 0df93305f21712e975ab5df260cc5a91e5daafca | static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
g_free(s->l1_table);
g_free(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| {
"code": [
" g_free(s->l2_cache);",
" g_free(s->l2_cache);"
],
"line_no": [
11,
11
]
} | static void FUNC_0(BlockDriverState *VAR_0)
{
BDRVQcowState *s = VAR_0->opaque;
g_free(s->l1_table);
g_free(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"g_free(s->l1_table);",
"g_free(s->l2_cache);",
"g_free(s->cluster_cache);",
"g_free(s->cluster_data);",
"migrate_del_blocker(s->migration_blocker);",
"error_free(s->migration_blocker);",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
23,313 | static int pvf_read_header(AVFormatContext *s)
{
char buffer[32];
AVStream *st;
int bps, channels, sample_rate;
avio_skip(s->pb, 5);
ff_get_line(s->pb, buffer, sizeof(buffer));
if (sscanf(buffer, "%d %d %d",
&channels,
&sample_rate,
&bps) != 3)
return AVERROR_INVALIDDATA;
if (channels <= 0 || bps <= 0 || sample_rate <= 0)
return AVERROR_INVALIDDATA;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = channels;
st->codecpar->sample_rate = sample_rate;
st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, 0xFFFF);
st->codecpar->bits_per_coded_sample = bps;
st->codecpar->block_align = bps * st->codecpar->channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
| true | FFmpeg | 169c1cfa928040b83f2ac8386333ec5e5cff3df7 | static int pvf_read_header(AVFormatContext *s)
{
char buffer[32];
AVStream *st;
int bps, channels, sample_rate;
avio_skip(s->pb, 5);
ff_get_line(s->pb, buffer, sizeof(buffer));
if (sscanf(buffer, "%d %d %d",
&channels,
&sample_rate,
&bps) != 3)
return AVERROR_INVALIDDATA;
if (channels <= 0 || bps <= 0 || sample_rate <= 0)
return AVERROR_INVALIDDATA;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = channels;
st->codecpar->sample_rate = sample_rate;
st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, 0xFFFF);
st->codecpar->bits_per_coded_sample = bps;
st->codecpar->block_align = bps * st->codecpar->channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
| {
"code": [
" if (channels <= 0 || bps <= 0 || sample_rate <= 0)"
],
"line_no": [
29
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
char VAR_1[32];
AVStream *st;
int VAR_2, VAR_3, VAR_4;
avio_skip(VAR_0->pb, 5);
ff_get_line(VAR_0->pb, VAR_1, sizeof(VAR_1));
if (sscanf(VAR_1, "%d %d %d",
&VAR_3,
&VAR_4,
&VAR_2) != 3)
return AVERROR_INVALIDDATA;
if (VAR_3 <= 0 || VAR_2 <= 0 || VAR_4 <= 0)
return AVERROR_INVALIDDATA;
st = avformat_new_stream(VAR_0, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->VAR_3 = VAR_3;
st->codecpar->VAR_4 = VAR_4;
st->codecpar->codec_id = ff_get_pcm_codec_id(VAR_2, 0, 1, 0xFFFF);
st->codecpar->bits_per_coded_sample = VAR_2;
st->codecpar->block_align = VAR_2 * st->codecpar->VAR_3 / 8;
avpriv_set_pts_info(st, 64, 1, st->codecpar->VAR_4);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"char VAR_1[32];",
"AVStream *st;",
"int VAR_2, VAR_3, VAR_4;",
"avio_skip(VAR_0->pb, 5);",
"ff_get_line(VAR_0->pb, VAR_1, sizeof(VAR_1));",
"if (sscanf(VAR_1, \"%d %d %d\",\n&VAR_3,\n&VAR_4,\n&VAR_2) != 3)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_3 <= 0 || VAR_2 <= 0 || VAR_4 <= 0)\nreturn AVERROR_INVALIDDATA;",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\nreturn AVERROR(ENOMEM);",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->VAR_3 = VAR_3;",
"st->codecpar->VAR_4 = VAR_4;",
"st->codecpar->codec_id = ff_get_pcm_codec_id(VAR_2, 0, 1, 0xFFFF);",
"st->codecpar->bits_per_coded_sample = VAR_2;",
"st->codecpar->block_align = VAR_2 * st->codecpar->VAR_3 / 8;",
"avpriv_set_pts_info(st, 64, 1, st->codecpar->VAR_4);",
"return 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
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25
],
[
29,
31
],
[
35
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
]
] |
23,315 | iscsi_readv_writev_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
if (!acb->canceled) {
acb->common.cb(acb->common.opaque, acb->status);
}
qemu_aio_release(acb);
if (acb->canceled) {
return;
}
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
| true | qemu | b20909195745c34a819aed14ae996b60ab0f591f | iscsi_readv_writev_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
if (!acb->canceled) {
acb->common.cb(acb->common.opaque, acb->status);
}
qemu_aio_release(acb);
if (acb->canceled) {
return;
}
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
| {
"code": [
" scsi_free_scsi_task(acb->task);",
" acb->task = NULL;",
" if (!acb->canceled) {",
" if (acb->canceled) {",
" scsi_free_scsi_task(acb->task);",
" acb->task = NULL;",
" if (acb->canceled) {",
" if (acb->canceled) {",
" if (acb->canceled) {",
" if (acb->canceled) {",
" if (acb->canceled) {"
],
"line_no": [
33,
35,
13,
25,
33,
35,
25,
25,
25,
25,
25
]
} | FUNC_0(void *VAR_0)
{
IscsiAIOCB *acb = VAR_0;
qemu_bh_delete(acb->bh);
if (!acb->canceled) {
acb->common.cb(acb->common.opaque, acb->status);
}
qemu_aio_release(acb);
if (acb->canceled) {
return;
}
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
| [
"FUNC_0(void *VAR_0)\n{",
"IscsiAIOCB *acb = VAR_0;",
"qemu_bh_delete(acb->bh);",
"if (!acb->canceled) {",
"acb->common.cb(acb->common.opaque, acb->status);",
"}",
"qemu_aio_release(acb);",
"if (acb->canceled) {",
"return;",
"}",
"scsi_free_scsi_task(acb->task);",
"acb->task = NULL;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
23,317 | static void vmmouse_reset(DeviceState *d)
{
VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
s->status = 0xffff;
s->queue_size = VMMOUSE_QUEUE_SIZE;
} | true | qemu | 069ab0eb8a46bc4ff6f4d4d81bf037d3441347da | static void vmmouse_reset(DeviceState *d)
{
VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
s->status = 0xffff;
s->queue_size = VMMOUSE_QUEUE_SIZE;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0)
{
VMMouseState *s = container_of(VAR_0, VMMouseState, dev.qdev);
s->status = 0xffff;
s->queue_size = VMMOUSE_QUEUE_SIZE;
} | [
"static void FUNC_0(DeviceState *VAR_0)\n{",
"VMMouseState *s = container_of(VAR_0, VMMouseState, dev.qdev);",
"s->status = 0xffff;",
"s->queue_size = VMMOUSE_QUEUE_SIZE;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
]
] |
23,318 | static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags,
struct Results *r)
{
static enum AVPixelFormat cur_srcFormat;
static int cur_srcW, cur_srcH;
static uint8_t *src[4];
static int srcStride[4];
uint8_t *dst[4] = { 0 };
uint8_t *out[4] = { 0 };
int dstStride[4];
int i;
uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
struct SwsContext *dstContext = NULL, *outContext = NULL;
uint32_t crc = 0;
int res = 0;
if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
struct SwsContext *srcContext = NULL;
int p;
for (p = 0; p < 4; p++)
av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
srcStride[p] = FFALIGN(srcStride[p], 16);
if (srcStride[p])
src[p] = av_mallocz(srcStride[p] * srcH + 16);
if (srcStride[p] && !src[p]) {
perror("Malloc");
res = -1;
goto end;
}
}
srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h, src, srcStride);
sws_freeContext(srcContext);
cur_srcFormat = srcFormat;
cur_srcW = srcW;
cur_srcH = srcH;
}
av_image_fill_linesizes(dstStride, dstFormat, dstW);
for (i = 0; i < 4; i++) {
/* Image buffers passed into libswscale can be allocated any way you
* prefer, as long as they're aligned enough for the architecture, and
* they're freed appropriately (such as using av_free for buffers
* allocated with av_malloc). */
/* An extra 16 bytes is being allocated because some scalers may write
* out of bounds. */
dstStride[i] = FFALIGN(dstStride[i], 16);
if (dstStride[i])
dst[i] = av_mallocz(dstStride[i] * dstH + 16);
if (dstStride[i] && !dst[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
res = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
flags);
fflush(stdout);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
for (i = 0; i < 4 && dstStride[i]; i++)
crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
dstStride[i] * dstH);
if (r && crc == r->crc) {
ssdY = r->ssdY;
ssdU = r->ssdU;
ssdV = r->ssdV;
ssdA = r->ssdA;
} else {
for (i = 0; i < 4; i++) {
refStride[i] = FFALIGN(refStride[i], 16);
if (refStride[i])
out[i] = av_mallocz(refStride[i] * h);
if (refStride[i] && !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
res = -1;
goto end;
}
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
//FIXME check that output is really gray
ssdU = getSSD(ref[1], out[1], refStride[1], refStride[1],
(w + 1) >> 1, (h + 1) >> 1);
ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
(w + 1) >> 1, (h + 1) >> 1);
}
if (isALPHA(srcFormat) && isALPHA(dstFormat))
ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
ssdY /= w * h;
ssdU /= w * h / 4;
ssdV /= w * h / 4;
ssdA /= w * h;
sws_freeContext(outContext);
for (i = 0; i < 4; i++)
if (refStride[i])
av_free(out[i]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
end:
sws_freeContext(dstContext);
for (i = 0; i < 4; i++)
if (dstStride[i])
av_free(dst[i]);
return res;
}
| true | FFmpeg | fac1ccbda1bb8441c7329a3ac18fbf04886da983 | static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags,
struct Results *r)
{
static enum AVPixelFormat cur_srcFormat;
static int cur_srcW, cur_srcH;
static uint8_t *src[4];
static int srcStride[4];
uint8_t *dst[4] = { 0 };
uint8_t *out[4] = { 0 };
int dstStride[4];
int i;
uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
struct SwsContext *dstContext = NULL, *outContext = NULL;
uint32_t crc = 0;
int res = 0;
if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
struct SwsContext *srcContext = NULL;
int p;
for (p = 0; p < 4; p++)
av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
srcStride[p] = FFALIGN(srcStride[p], 16);
if (srcStride[p])
src[p] = av_mallocz(srcStride[p] * srcH + 16);
if (srcStride[p] && !src[p]) {
perror("Malloc");
res = -1;
goto end;
}
}
srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h, src, srcStride);
sws_freeContext(srcContext);
cur_srcFormat = srcFormat;
cur_srcW = srcW;
cur_srcH = srcH;
}
av_image_fill_linesizes(dstStride, dstFormat, dstW);
for (i = 0; i < 4; i++) {
dstStride[i] = FFALIGN(dstStride[i], 16);
if (dstStride[i])
dst[i] = av_mallocz(dstStride[i] * dstH + 16);
if (dstStride[i] && !dst[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
res = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
flags);
fflush(stdout);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
for (i = 0; i < 4 && dstStride[i]; i++)
crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
dstStride[i] * dstH);
if (r && crc == r->crc) {
ssdY = r->ssdY;
ssdU = r->ssdU;
ssdV = r->ssdV;
ssdA = r->ssdA;
} else {
for (i = 0; i < 4; i++) {
refStride[i] = FFALIGN(refStride[i], 16);
if (refStride[i])
out[i] = av_mallocz(refStride[i] * h);
if (refStride[i] && !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
res = -1;
goto end;
}
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
ssdU = getSSD(ref[1], out[1], refStride[1], refStride[1],
(w + 1) >> 1, (h + 1) >> 1);
ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
(w + 1) >> 1, (h + 1) >> 1);
}
if (isALPHA(srcFormat) && isALPHA(dstFormat))
ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
ssdY /= w * h;
ssdU /= w * h / 4;
ssdV /= w * h / 4;
ssdA /= w * h;
sws_freeContext(outContext);
for (i = 0; i < 4; i++)
if (refStride[i])
av_free(out[i]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
end:
sws_freeContext(dstContext);
for (i = 0; i < 4; i++)
if (dstStride[i])
av_free(dst[i]);
return res;
}
| {
"code": [
" int dstStride[4];"
],
"line_no": [
23
]
} | static int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4], int VAR_2, int VAR_3,
enum AVPixelFormat VAR_4, enum AVPixelFormat VAR_5,
int VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10,
struct Results *VAR_11)
{
static enum AVPixelFormat VAR_12;
static int VAR_13, VAR_14;
static uint8_t *VAR_15[4];
static int VAR_16[4];
uint8_t *dst[4] = { 0 };
uint8_t *out[4] = { 0 };
int VAR_17[4];
int VAR_18;
uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
struct SwsContext *VAR_19 = NULL, *VAR_20 = NULL;
uint32_t crc = 0;
int VAR_21 = 0;
if (VAR_12 != VAR_4 || VAR_13 != VAR_6 || VAR_14 != VAR_7) {
struct SwsContext *VAR_22 = NULL;
int VAR_23;
for (VAR_23 = 0; VAR_23 < 4; VAR_23++)
av_freep(&VAR_15[VAR_23]);
av_image_fill_linesizes(VAR_16, VAR_4, VAR_6);
for (VAR_23 = 0; VAR_23 < 4; VAR_23++) {
VAR_16[VAR_23] = FFALIGN(VAR_16[VAR_23], 16);
if (VAR_16[VAR_23])
VAR_15[VAR_23] = av_mallocz(VAR_16[VAR_23] * VAR_7 + 16);
if (VAR_16[VAR_23] && !VAR_15[VAR_23]) {
perror("Malloc");
VAR_21 = -1;
goto end;
}
}
VAR_22 = sws_getContext(VAR_2, VAR_3, AV_PIX_FMT_YUVA420P, VAR_6, VAR_7,
VAR_4, SWS_BILINEAR, NULL, NULL, NULL);
if (!VAR_22) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[VAR_4].name);
VAR_21 = -1;
goto end;
}
sws_scale(VAR_22, VAR_0, VAR_1, 0, VAR_3, VAR_15, VAR_16);
sws_freeContext(VAR_22);
VAR_12 = VAR_4;
VAR_13 = VAR_6;
VAR_14 = VAR_7;
}
av_image_fill_linesizes(VAR_17, VAR_5, VAR_8);
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
VAR_17[VAR_18] = FFALIGN(VAR_17[VAR_18], 16);
if (VAR_17[VAR_18])
dst[VAR_18] = av_mallocz(VAR_17[VAR_18] * VAR_9 + 16);
if (VAR_17[VAR_18] && !dst[VAR_18]) {
perror("Malloc");
VAR_21 = -1;
goto end;
}
}
VAR_19 = sws_getContext(VAR_6, VAR_7, VAR_4, VAR_8, VAR_9, VAR_5,
VAR_10, NULL, NULL, NULL);
if (!VAR_19) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[VAR_4].name,
av_pix_fmt_descriptors[VAR_5].name);
VAR_21 = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d VAR_10=%2d",
av_pix_fmt_descriptors[VAR_4].name, VAR_6, VAR_7,
av_pix_fmt_descriptors[VAR_5].name, VAR_8, VAR_9,
VAR_10);
fflush(stdout);
sws_scale(VAR_19, VAR_15, VAR_16, 0, VAR_7, dst, VAR_17);
for (VAR_18 = 0; VAR_18 < 4 && VAR_17[VAR_18]; VAR_18++)
crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[VAR_18],
VAR_17[VAR_18] * VAR_9);
if (VAR_11 && crc == VAR_11->crc) {
ssdY = VAR_11->ssdY;
ssdU = VAR_11->ssdU;
ssdV = VAR_11->ssdV;
ssdA = VAR_11->ssdA;
} else {
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
VAR_1[VAR_18] = FFALIGN(VAR_1[VAR_18], 16);
if (VAR_1[VAR_18])
out[VAR_18] = av_mallocz(VAR_1[VAR_18] * VAR_3);
if (VAR_1[VAR_18] && !out[VAR_18]) {
perror("Malloc");
VAR_21 = -1;
goto end;
}
}
VAR_20 = sws_getContext(VAR_8, VAR_9, VAR_5, VAR_2, VAR_3,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
NULL, NULL, NULL);
if (!VAR_20) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[VAR_5].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
VAR_21 = -1;
goto end;
}
sws_scale(VAR_20, dst, VAR_17, 0, VAR_9, out, VAR_1);
ssdY = getSSD(VAR_0[0], out[0], VAR_1[0], VAR_1[0], VAR_2, VAR_3);
if (hasChroma(VAR_4) && hasChroma(VAR_5)) {
ssdU = getSSD(VAR_0[1], out[1], VAR_1[1], VAR_1[1],
(VAR_2 + 1) >> 1, (VAR_3 + 1) >> 1);
ssdV = getSSD(VAR_0[2], out[2], VAR_1[2], VAR_1[2],
(VAR_2 + 1) >> 1, (VAR_3 + 1) >> 1);
}
if (isALPHA(VAR_4) && isALPHA(VAR_5))
ssdA = getSSD(VAR_0[3], out[3], VAR_1[3], VAR_1[3], VAR_2, VAR_3);
ssdY /= VAR_2 * VAR_3;
ssdU /= VAR_2 * VAR_3 / 4;
ssdV /= VAR_2 * VAR_3 / 4;
ssdA /= VAR_2 * VAR_3;
sws_freeContext(VAR_20);
for (VAR_18 = 0; VAR_18 < 4; VAR_18++)
if (VAR_1[VAR_18])
av_free(out[VAR_18]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
end:
sws_freeContext(VAR_19);
for (VAR_18 = 0; VAR_18 < 4; VAR_18++)
if (VAR_17[VAR_18])
av_free(dst[VAR_18]);
return VAR_21;
}
| [
"static int FUNC_0(uint8_t *VAR_0[4], int VAR_1[4], int VAR_2, int VAR_3,\nenum AVPixelFormat VAR_4, enum AVPixelFormat VAR_5,\nint VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10,\nstruct Results *VAR_11)\n{",
"static enum AVPixelFormat VAR_12;",
"static int VAR_13, VAR_14;",
"static uint8_t *VAR_15[4];",
"static int VAR_16[4];",
"uint8_t *dst[4] = { 0 };",
"uint8_t *out[4] = { 0 };",
"int VAR_17[4];",
"int VAR_18;",
"uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;",
"struct SwsContext *VAR_19 = NULL, *VAR_20 = NULL;",
"uint32_t crc = 0;",
"int VAR_21 = 0;",
"if (VAR_12 != VAR_4 || VAR_13 != VAR_6 || VAR_14 != VAR_7) {",
"struct SwsContext *VAR_22 = NULL;",
"int VAR_23;",
"for (VAR_23 = 0; VAR_23 < 4; VAR_23++)",
"av_freep(&VAR_15[VAR_23]);",
"av_image_fill_linesizes(VAR_16, VAR_4, VAR_6);",
"for (VAR_23 = 0; VAR_23 < 4; VAR_23++) {",
"VAR_16[VAR_23] = FFALIGN(VAR_16[VAR_23], 16);",
"if (VAR_16[VAR_23])\nVAR_15[VAR_23] = av_mallocz(VAR_16[VAR_23] * VAR_7 + 16);",
"if (VAR_16[VAR_23] && !VAR_15[VAR_23]) {",
"perror(\"Malloc\");",
"VAR_21 = -1;",
"goto end;",
"}",
"}",
"VAR_22 = sws_getContext(VAR_2, VAR_3, AV_PIX_FMT_YUVA420P, VAR_6, VAR_7,\nVAR_4, SWS_BILINEAR, NULL, NULL, NULL);",
"if (!VAR_22) {",
"fprintf(stderr, \"Failed to get %s ---> %s\\n\",\nav_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,\nav_pix_fmt_descriptors[VAR_4].name);",
"VAR_21 = -1;",
"goto end;",
"}",
"sws_scale(VAR_22, VAR_0, VAR_1, 0, VAR_3, VAR_15, VAR_16);",
"sws_freeContext(VAR_22);",
"VAR_12 = VAR_4;",
"VAR_13 = VAR_6;",
"VAR_14 = VAR_7;",
"}",
"av_image_fill_linesizes(VAR_17, VAR_5, VAR_8);",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"VAR_17[VAR_18] = FFALIGN(VAR_17[VAR_18], 16);",
"if (VAR_17[VAR_18])\ndst[VAR_18] = av_mallocz(VAR_17[VAR_18] * VAR_9 + 16);",
"if (VAR_17[VAR_18] && !dst[VAR_18]) {",
"perror(\"Malloc\");",
"VAR_21 = -1;",
"goto end;",
"}",
"}",
"VAR_19 = sws_getContext(VAR_6, VAR_7, VAR_4, VAR_8, VAR_9, VAR_5,\nVAR_10, NULL, NULL, NULL);",
"if (!VAR_19) {",
"fprintf(stderr, \"Failed to get %s ---> %s\\n\",\nav_pix_fmt_descriptors[VAR_4].name,\nav_pix_fmt_descriptors[VAR_5].name);",
"VAR_21 = -1;",
"goto end;",
"}",
"printf(\" %s %dx%d -> %s %3dx%3d VAR_10=%2d\",\nav_pix_fmt_descriptors[VAR_4].name, VAR_6, VAR_7,\nav_pix_fmt_descriptors[VAR_5].name, VAR_8, VAR_9,\nVAR_10);",
"fflush(stdout);",
"sws_scale(VAR_19, VAR_15, VAR_16, 0, VAR_7, dst, VAR_17);",
"for (VAR_18 = 0; VAR_18 < 4 && VAR_17[VAR_18]; VAR_18++)",
"crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[VAR_18],\nVAR_17[VAR_18] * VAR_9);",
"if (VAR_11 && crc == VAR_11->crc) {",
"ssdY = VAR_11->ssdY;",
"ssdU = VAR_11->ssdU;",
"ssdV = VAR_11->ssdV;",
"ssdA = VAR_11->ssdA;",
"} else {",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"VAR_1[VAR_18] = FFALIGN(VAR_1[VAR_18], 16);",
"if (VAR_1[VAR_18])\nout[VAR_18] = av_mallocz(VAR_1[VAR_18] * VAR_3);",
"if (VAR_1[VAR_18] && !out[VAR_18]) {",
"perror(\"Malloc\");",
"VAR_21 = -1;",
"goto end;",
"}",
"}",
"VAR_20 = sws_getContext(VAR_8, VAR_9, VAR_5, VAR_2, VAR_3,\nAV_PIX_FMT_YUVA420P, SWS_BILINEAR,\nNULL, NULL, NULL);",
"if (!VAR_20) {",
"fprintf(stderr, \"Failed to get %s ---> %s\\n\",\nav_pix_fmt_descriptors[VAR_5].name,\nav_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);",
"VAR_21 = -1;",
"goto end;",
"}",
"sws_scale(VAR_20, dst, VAR_17, 0, VAR_9, out, VAR_1);",
"ssdY = getSSD(VAR_0[0], out[0], VAR_1[0], VAR_1[0], VAR_2, VAR_3);",
"if (hasChroma(VAR_4) && hasChroma(VAR_5)) {",
"ssdU = getSSD(VAR_0[1], out[1], VAR_1[1], VAR_1[1],\n(VAR_2 + 1) >> 1, (VAR_3 + 1) >> 1);",
"ssdV = getSSD(VAR_0[2], out[2], VAR_1[2], VAR_1[2],\n(VAR_2 + 1) >> 1, (VAR_3 + 1) >> 1);",
"}",
"if (isALPHA(VAR_4) && isALPHA(VAR_5))\nssdA = getSSD(VAR_0[3], out[3], VAR_1[3], VAR_1[3], VAR_2, VAR_3);",
"ssdY /= VAR_2 * VAR_3;",
"ssdU /= VAR_2 * VAR_3 / 4;",
"ssdV /= VAR_2 * VAR_3 / 4;",
"ssdA /= VAR_2 * VAR_3;",
"sws_freeContext(VAR_20);",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++)",
"if (VAR_1[VAR_18])\nav_free(out[VAR_18]);",
"}",
"printf(\" CRC=%08x SSD=%5\"PRId64 \",%5\"PRId64 \",%5\"PRId64 \",%5\"PRId64 \"\\n\",\ncrc, ssdY, ssdU, ssdV, ssdA);",
"end:\nsws_freeContext(VAR_19);",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++)",
"if (VAR_17[VAR_18])\nav_free(dst[VAR_18]);",
"return VAR_21;",
"}"
] | [
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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
149
],
[
151,
153,
155
],
[
157
],
[
159
],
[
161
],
[
165,
167,
169,
171
],
[
173
],
[
177
],
[
181
],
[
183,
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223,
225
],
[
227
],
[
229,
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
251,
253
],
[
255,
257
],
[
259
],
[
261,
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
281
],
[
283,
285
],
[
287
],
[
291,
293
],
[
297,
299
],
[
303
],
[
305,
307
],
[
311
],
[
313
]
] |
23,319 | char *object_property_get_str(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QString *qstring;
char *retval;
if (!ret) {
return NULL;
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
retval = NULL;
} else {
retval = g_strdup(qstring_get_str(qstring));
}
QDECREF(qstring);
return retval;
}
| true | qemu | 560f19f162529d691619ac69ed032321c7f5f1fb | char *object_property_get_str(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QString *qstring;
char *retval;
if (!ret) {
return NULL;
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
retval = NULL;
} else {
retval = g_strdup(qstring_get_str(qstring));
}
QDECREF(qstring);
return retval;
}
| {
"code": [
" QDECREF(qstring);"
],
"line_no": [
37
]
} | char *FUNC_0(Object *VAR_0, const char *VAR_1,
Error **VAR_2)
{
QObject *ret = object_property_get_qobject(VAR_0, VAR_1, VAR_2);
QString *qstring;
char *VAR_3;
if (!ret) {
return NULL;
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1, "string");
VAR_3 = NULL;
} else {
VAR_3 = g_strdup(qstring_get_str(qstring));
}
QDECREF(qstring);
return VAR_3;
}
| [
"char *FUNC_0(Object *VAR_0, const char *VAR_1,\nError **VAR_2)\n{",
"QObject *ret = object_property_get_qobject(VAR_0, VAR_1, VAR_2);",
"QString *qstring;",
"char *VAR_3;",
"if (!ret) {",
"return NULL;",
"}",
"qstring = qobject_to_qstring(ret);",
"if (!qstring) {",
"error_setg(VAR_2, QERR_INVALID_PARAMETER_TYPE, VAR_1, \"string\");",
"VAR_3 = NULL;",
"} else {",
"VAR_3 = g_strdup(qstring_get_str(qstring));",
"}",
"QDECREF(qstring);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
] |
23,320 | ip_input(struct mbuf *m)
{
Slirp *slirp = m->slirp;
register struct ip *ip;
int hlen;
DEBUG_CALL("ip_input");
DEBUG_ARG("m = %p", m);
DEBUG_ARG("m_len = %d", m->m_len);
if (m->m_len < sizeof (struct ip)) {
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
goto bad; /* or packet too short */
}
/* keep ip header intact for ICMP reply
* ip->ip_sum = cksum(m, hlen);
* if (ip->ip_sum) {
*/
if(cksum(m,hlen)) {
goto bad;
}
/*
* Convert fields to host representation.
*/
NTOHS(ip->ip_len);
if (ip->ip_len < hlen) {
goto bad;
}
NTOHS(ip->ip_id);
NTOHS(ip->ip_off);
/*
* Check that the amount of data in the buffers
* is as at least much as the IP header would have us expect.
* Trim mbufs if longer than we expect.
* Drop packet if shorter than we expect.
*/
if (m->m_len < ip->ip_len) {
goto bad;
}
/* Should drop packet if mbuf too long? hmmm... */
if (m->m_len > ip->ip_len)
m_adj(m, ip->ip_len - m->m_len);
/* check ip_ttl for a correct ICMP reply */
if (ip->ip_ttl == 0) {
icmp_send_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
goto bad;
}
/*
* If offset or IP_MF are set, must reassemble.
* Otherwise, nothing need be done.
* (We could look in the reassembly queue to see
* if the packet was previously fragmented,
* but it's not worth the time; just let them time out.)
*
* XXX This should fail, don't fragment yet
*/
if (ip->ip_off &~ IP_DF) {
register struct ipq *fp;
struct qlink *l;
/*
* Look for queue of fragments
* of this datagram.
*/
for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
l = l->next) {
fp = container_of(l, struct ipq, ip_link);
if (ip->ip_id == fp->ipq_id &&
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
ip->ip_p == fp->ipq_p)
goto found;
}
fp = NULL;
found:
/*
* Adjust ip_len to not reflect header,
* set ip_mff if more fragments are expected,
* convert offset of this to bytes.
*/
ip->ip_len -= hlen;
if (ip->ip_off & IP_MF)
ip->ip_tos |= 1;
else
ip->ip_tos &= ~1;
ip->ip_off <<= 3;
/*
* If datagram marked as having more fragments
* or if this is not the first fragment,
* attempt reassembly; if it succeeds, proceed.
*/
if (ip->ip_tos & 1 || ip->ip_off) {
ip = ip_reass(slirp, ip, fp);
if (ip == NULL)
return;
m = dtom(slirp, ip);
} else
if (fp)
ip_freef(slirp, fp);
} else
ip->ip_len -= hlen;
/*
* Switch out to protocol's input routine.
*/
switch (ip->ip_p) {
case IPPROTO_TCP:
tcp_input(m, hlen, (struct socket *)NULL, AF_INET);
break;
case IPPROTO_UDP:
udp_input(m, hlen);
break;
case IPPROTO_ICMP:
icmp_input(m, hlen);
break;
default:
m_free(m);
}
return;
bad:
m_free(m);
}
| true | qemu | 99787f69cdd8147d0be67d71ec3058cce21e2444 | ip_input(struct mbuf *m)
{
Slirp *slirp = m->slirp;
register struct ip *ip;
int hlen;
DEBUG_CALL("ip_input");
DEBUG_ARG("m = %p", m);
DEBUG_ARG("m_len = %d", m->m_len);
if (m->m_len < sizeof (struct ip)) {
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen<sizeof(struct ip ) || hlen>m->m_len) {
goto bad;
}
if(cksum(m,hlen)) {
goto bad;
}
NTOHS(ip->ip_len);
if (ip->ip_len < hlen) {
goto bad;
}
NTOHS(ip->ip_id);
NTOHS(ip->ip_off);
if (m->m_len < ip->ip_len) {
goto bad;
}
if (m->m_len > ip->ip_len)
m_adj(m, ip->ip_len - m->m_len);
if (ip->ip_ttl == 0) {
icmp_send_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
goto bad;
}
if (ip->ip_off &~ IP_DF) {
register struct ipq *fp;
struct qlink *l;
for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
l = l->next) {
fp = container_of(l, struct ipq, ip_link);
if (ip->ip_id == fp->ipq_id &&
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
ip->ip_p == fp->ipq_p)
goto found;
}
fp = NULL;
found:
ip->ip_len -= hlen;
if (ip->ip_off & IP_MF)
ip->ip_tos |= 1;
else
ip->ip_tos &= ~1;
ip->ip_off <<= 3;
if (ip->ip_tos & 1 || ip->ip_off) {
ip = ip_reass(slirp, ip, fp);
if (ip == NULL)
return;
m = dtom(slirp, ip);
} else
if (fp)
ip_freef(slirp, fp);
} else
ip->ip_len -= hlen;
switch (ip->ip_p) {
case IPPROTO_TCP:
tcp_input(m, hlen, (struct socket *)NULL, AF_INET);
break;
case IPPROTO_UDP:
udp_input(m, hlen);
break;
case IPPROTO_ICMP:
icmp_input(m, hlen);
break;
default:
m_free(m);
}
return;
bad:
m_free(m);
}
| {
"code": [],
"line_no": []
} | FUNC_0(struct mbuf *VAR_0)
{
Slirp *slirp = VAR_0->slirp;
register struct VAR_1 *VAR_1;
int VAR_2;
DEBUG_CALL("FUNC_0");
DEBUG_ARG("VAR_0 = %p", VAR_0);
DEBUG_ARG("m_len = %d", VAR_0->m_len);
if (VAR_0->m_len < sizeof (struct VAR_1)) {
return;
}
VAR_1 = mtod(VAR_0, struct VAR_1 *);
if (VAR_1->ip_v != IPVERSION) {
goto bad;
}
VAR_2 = VAR_1->ip_hl << 2;
if (VAR_2<sizeof(struct VAR_1 ) || VAR_2>VAR_0->m_len) {
goto bad;
}
if(cksum(VAR_0,VAR_2)) {
goto bad;
}
NTOHS(VAR_1->ip_len);
if (VAR_1->ip_len < VAR_2) {
goto bad;
}
NTOHS(VAR_1->ip_id);
NTOHS(VAR_1->ip_off);
if (VAR_0->m_len < VAR_1->ip_len) {
goto bad;
}
if (VAR_0->m_len > VAR_1->ip_len)
m_adj(VAR_0, VAR_1->ip_len - VAR_0->m_len);
if (VAR_1->ip_ttl == 0) {
icmp_send_error(VAR_0, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
goto bad;
}
if (VAR_1->ip_off &~ IP_DF) {
register struct ipq *VAR_3;
struct qlink *VAR_4;
for (VAR_4 = slirp->ipq.ip_link.next; VAR_4 != &slirp->ipq.ip_link;
VAR_4 = VAR_4->next) {
VAR_3 = container_of(VAR_4, struct ipq, ip_link);
if (VAR_1->ip_id == VAR_3->ipq_id &&
VAR_1->ip_src.s_addr == VAR_3->ipq_src.s_addr &&
VAR_1->ip_dst.s_addr == VAR_3->ipq_dst.s_addr &&
VAR_1->ip_p == VAR_3->ipq_p)
goto found;
}
VAR_3 = NULL;
found:
VAR_1->ip_len -= VAR_2;
if (VAR_1->ip_off & IP_MF)
VAR_1->ip_tos |= 1;
else
VAR_1->ip_tos &= ~1;
VAR_1->ip_off <<= 3;
if (VAR_1->ip_tos & 1 || VAR_1->ip_off) {
VAR_1 = ip_reass(slirp, VAR_1, VAR_3);
if (VAR_1 == NULL)
return;
VAR_0 = dtom(slirp, VAR_1);
} else
if (VAR_3)
ip_freef(slirp, VAR_3);
} else
VAR_1->ip_len -= VAR_2;
switch (VAR_1->ip_p) {
case IPPROTO_TCP:
tcp_input(VAR_0, VAR_2, (struct socket *)NULL, AF_INET);
break;
case IPPROTO_UDP:
udp_input(VAR_0, VAR_2);
break;
case IPPROTO_ICMP:
icmp_input(VAR_0, VAR_2);
break;
default:
m_free(VAR_0);
}
return;
bad:
m_free(VAR_0);
}
| [
"FUNC_0(struct mbuf *VAR_0)\n{",
"Slirp *slirp = VAR_0->slirp;",
"register struct VAR_1 *VAR_1;",
"int VAR_2;",
"DEBUG_CALL(\"FUNC_0\");",
"DEBUG_ARG(\"VAR_0 = %p\", VAR_0);",
"DEBUG_ARG(\"m_len = %d\", VAR_0->m_len);",
"if (VAR_0->m_len < sizeof (struct VAR_1)) {",
"return;",
"}",
"VAR_1 = mtod(VAR_0, struct VAR_1 *);",
"if (VAR_1->ip_v != IPVERSION) {",
"goto bad;",
"}",
"VAR_2 = VAR_1->ip_hl << 2;",
"if (VAR_2<sizeof(struct VAR_1 ) || VAR_2>VAR_0->m_len) {",
"goto bad;",
"}",
"if(cksum(VAR_0,VAR_2)) {",
"goto bad;",
"}",
"NTOHS(VAR_1->ip_len);",
"if (VAR_1->ip_len < VAR_2) {",
"goto bad;",
"}",
"NTOHS(VAR_1->ip_id);",
"NTOHS(VAR_1->ip_off);",
"if (VAR_0->m_len < VAR_1->ip_len) {",
"goto bad;",
"}",
"if (VAR_0->m_len > VAR_1->ip_len)\nm_adj(VAR_0, VAR_1->ip_len - VAR_0->m_len);",
"if (VAR_1->ip_ttl == 0) {",
"icmp_send_error(VAR_0, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, \"ttl\");",
"goto bad;",
"}",
"if (VAR_1->ip_off &~ IP_DF) {",
"register struct ipq *VAR_3;",
"struct qlink *VAR_4;",
"for (VAR_4 = slirp->ipq.ip_link.next; VAR_4 != &slirp->ipq.ip_link;",
"VAR_4 = VAR_4->next) {",
"VAR_3 = container_of(VAR_4, struct ipq, ip_link);",
"if (VAR_1->ip_id == VAR_3->ipq_id &&\nVAR_1->ip_src.s_addr == VAR_3->ipq_src.s_addr &&\nVAR_1->ip_dst.s_addr == VAR_3->ipq_dst.s_addr &&\nVAR_1->ip_p == VAR_3->ipq_p)\ngoto found;",
"}",
"VAR_3 = NULL;",
"found:\nVAR_1->ip_len -= VAR_2;",
"if (VAR_1->ip_off & IP_MF)\nVAR_1->ip_tos |= 1;",
"else\nVAR_1->ip_tos &= ~1;",
"VAR_1->ip_off <<= 3;",
"if (VAR_1->ip_tos & 1 || VAR_1->ip_off) {",
"VAR_1 = ip_reass(slirp, VAR_1, VAR_3);",
"if (VAR_1 == NULL)\nreturn;",
"VAR_0 = dtom(slirp, VAR_1);",
"} else",
"if (VAR_3)\nip_freef(slirp, VAR_3);",
"} else",
"VAR_1->ip_len -= VAR_2;",
"switch (VAR_1->ip_p) {",
"case IPPROTO_TCP:\ntcp_input(VAR_0, VAR_2, (struct socket *)NULL, AF_INET);",
"break;",
"case IPPROTO_UDP:\nudp_input(VAR_0, VAR_2);",
"break;",
"case IPPROTO_ICMP:\nicmp_input(VAR_0, VAR_2);",
"break;",
"default:\nm_free(VAR_0);",
"}",
"return;",
"bad:\nm_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61
],
[
63
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
99
],
[
101
],
[
103
],
[
109,
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
145
],
[
147
],
[
149
],
[
159
],
[
161
],
[
163
],
[
165,
167,
169,
171,
173
],
[
175
],
[
177
],
[
179,
193
],
[
195,
197
],
[
199,
201
],
[
205
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231,
233
],
[
237
],
[
239
],
[
249
],
[
251,
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
]
] |
23,321 | static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
}
asm volatile(
YSCALEYUV2YV121
:: "r" (lumSrc + dstW), "r" (dest + dstW),
"g" ((long)-dstW)
: "%"REG_a
);
#else
int i;
for(i=0; i<dstW; i++)
{
int val= lumSrc[i]>>7;
if(val&256){
if(val<0) val=0;
else val=255;
}
dest[i]= val;
}
if(uDest != NULL)
for(i=0; i<chrDstW; i++)
{
int u=chrSrc[i]>>7;
int v=chrSrc[i + 2048]>>7;
if((u|v)&256){
if(u<0) u=0;
else if (u>255) u=255;
if(v<0) v=0;
else if (v>255) v=255;
}
uDest[i]= u;
vDest[i]= v;
}
#endif
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
}
asm volatile(
YSCALEYUV2YV121
:: "r" (lumSrc + dstW), "r" (dest + dstW),
"g" ((long)-dstW)
: "%"REG_a
);
#else
int i;
for(i=0; i<dstW; i++)
{
int val= lumSrc[i]>>7;
if(val&256){
if(val<0) val=0;
else val=255;
}
dest[i]= val;
}
if(uDest != NULL)
for(i=0; i<chrDstW; i++)
{
int u=chrSrc[i]>>7;
int v=chrSrc[i + 2048]>>7;
if((u|v)&256){
if(u<0) u=0;
else if (u>255) u=255;
if(v<0) v=0;
else if (v>255) v=255;
}
uDest[i]= u;
vDest[i]= v;
}
#endif
}
| {
"code": [
"\t\t\t\t uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)",
"\t\t\t\t uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)",
"\t\t\t\t\"g\" ((long)-chrDstW)",
"\t\t\t\t\"g\" ((long)-chrDstW)",
"\t\t\"g\" ((long)-dstW)"
],
"line_no": [
3,
3,
19,
19,
49
]
} | static inline void FUNC_0(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
}
asm volatile(
YSCALEYUV2YV121
:: "r" (lumSrc + dstW), "r" (dest + dstW),
"g" ((long)-dstW)
: "%"REG_a
);
#else
int VAR_0;
for(VAR_0=0; VAR_0<dstW; VAR_0++)
{
int val= lumSrc[VAR_0]>>7;
if(val&256){
if(val<0) val=0;
else val=255;
}
dest[VAR_0]= val;
}
if(uDest != NULL)
for(VAR_0=0; VAR_0<chrDstW; VAR_0++)
{
int u=chrSrc[VAR_0]>>7;
int v=chrSrc[VAR_0 + 2048]>>7;
if((u|v)&256){
if(u<0) u=0;
else if (u>255) u=255;
if(v<0) v=0;
else if (v>255) v=255;
}
uDest[VAR_0]= u;
vDest[VAR_0]= v;
}
#endif
}
| [
"static inline void FUNC_0(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,\nuint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)\n{",
"#ifdef HAVE_MMX\nif(uDest != NULL)\n{",
"asm volatile(\nYSCALEYUV2YV121\n:: \"r\" (chrSrc + chrDstW), \"r\" (uDest + chrDstW),\n\"g\" ((long)-chrDstW)\n: \"%\"REG_a\n);",
"asm volatile(\nYSCALEYUV2YV121\n:: \"r\" (chrSrc + 2048 + chrDstW), \"r\" (vDest + chrDstW),\n\"g\" ((long)-chrDstW)\n: \"%\"REG_a\n);",
"}",
"asm volatile(\nYSCALEYUV2YV121\n:: \"r\" (lumSrc + dstW), \"r\" (dest + dstW),\n\"g\" ((long)-dstW)\n: \"%\"REG_a\n);",
"#else\nint VAR_0;",
"for(VAR_0=0; VAR_0<dstW; VAR_0++)",
"{",
"int val= lumSrc[VAR_0]>>7;",
"if(val&256){",
"if(val<0) val=0;",
"else val=255;",
"}",
"dest[VAR_0]= val;",
"}",
"if(uDest != NULL)\nfor(VAR_0=0; VAR_0<chrDstW; VAR_0++)",
"{",
"int u=chrSrc[VAR_0]>>7;",
"int v=chrSrc[VAR_0 + 2048]>>7;",
"if((u|v)&256){",
"if(u<0) u=0;",
"else if (u>255) u=255;",
"if(v<0) v=0;",
"else if (v>255) v=255;",
"}",
"uDest[VAR_0]= u;",
"vDest[VAR_0]= v;",
"}",
"#endif\n}"
] | [
1,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9,
11
],
[
13,
15,
17,
19,
21,
23
],
[
27,
29,
31,
33,
35,
37
],
[
39
],
[
43,
45,
47,
49,
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115,
117
]
] |
23,322 | static int read_dialogue(ASSContext *ass, AVBPrint *dst, const uint8_t *p,
int64_t *start, int *duration)
{
int pos;
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
if (sscanf(p, "Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n",
&hh1, &mm1, &ss1, &ms1,
&hh2, &mm2, &ss2, &ms2, &pos) >= 8) {
/* This is not part of the sscanf itself in order to handle an actual
* number (which would be the Layer) or the form "Marked=N" (which is
* the old SSA field, now replaced by Layer, and will be lead to Layer
* being 0 here). */
const int layer = atoi(p + 10);
end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
*duration = end - *start;
av_bprint_clear(dst);
av_bprintf(dst, "%u,%d,%s", ass->readorder++, layer, p + pos);
/* right strip the buffer */
while (dst->len > 0 &&
dst->str[dst->len - 1] == '\r' ||
dst->str[dst->len - 1] == '\n')
dst->str[--dst->len] = 0;
return 0;
}
return -1;
}
| true | FFmpeg | 138902dfb60fbb87fb65a8c4800f8ac661394b72 | static int read_dialogue(ASSContext *ass, AVBPrint *dst, const uint8_t *p,
int64_t *start, int *duration)
{
int pos;
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
if (sscanf(p, "Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n",
&hh1, &mm1, &ss1, &ms1,
&hh2, &mm2, &ss2, &ms2, &pos) >= 8) {
const int layer = atoi(p + 10);
end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
*duration = end - *start;
av_bprint_clear(dst);
av_bprintf(dst, "%u,%d,%s", ass->readorder++, layer, p + pos);
while (dst->len > 0 &&
dst->str[dst->len - 1] == '\r' ||
dst->str[dst->len - 1] == '\n')
dst->str[--dst->len] = 0;
return 0;
}
return -1;
}
| {
"code": [
" int pos;",
" &hh2, &mm2, &ss2, &ms2, &pos) >= 8) {"
],
"line_no": [
7,
21
]
} | static int FUNC_0(ASSContext *VAR_0, AVBPrint *VAR_1, const uint8_t *VAR_2,
int64_t *VAR_3, int *VAR_4)
{
int VAR_5;
int64_t end;
int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13;
if (sscanf(VAR_2, "Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n",
&VAR_6, &VAR_7, &VAR_8, &VAR_9,
&VAR_10, &VAR_11, &VAR_12, &VAR_13, &VAR_5) >= 8) {
const int VAR_14 = atoi(VAR_2 + 10);
end = (VAR_10*3600LL + VAR_11*60LL + VAR_12) * 100LL + VAR_13;
*VAR_3 = (VAR_6*3600LL + VAR_7*60LL + VAR_8) * 100LL + VAR_9;
*VAR_4 = end - *VAR_3;
av_bprint_clear(VAR_1);
av_bprintf(VAR_1, "%u,%d,%s", VAR_0->readorder++, VAR_14, VAR_2 + VAR_5);
while (VAR_1->len > 0 &&
VAR_1->str[VAR_1->len - 1] == '\r' ||
VAR_1->str[VAR_1->len - 1] == '\n')
VAR_1->str[--VAR_1->len] = 0;
return 0;
}
return -1;
}
| [
"static int FUNC_0(ASSContext *VAR_0, AVBPrint *VAR_1, const uint8_t *VAR_2,\nint64_t *VAR_3, int *VAR_4)\n{",
"int VAR_5;",
"int64_t end;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13;",
"if (sscanf(VAR_2, \"Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n\",\n&VAR_6, &VAR_7, &VAR_8, &VAR_9,\n&VAR_10, &VAR_11, &VAR_12, &VAR_13, &VAR_5) >= 8) {",
"const int VAR_14 = atoi(VAR_2 + 10);",
"end = (VAR_10*3600LL + VAR_11*60LL + VAR_12) * 100LL + VAR_13;",
"*VAR_3 = (VAR_6*3600LL + VAR_7*60LL + VAR_8) * 100LL + VAR_9;",
"*VAR_4 = end - *VAR_3;",
"av_bprint_clear(VAR_1);",
"av_bprintf(VAR_1, \"%u,%d,%s\", VAR_0->readorder++, VAR_14, VAR_2 + VAR_5);",
"while (VAR_1->len > 0 &&\nVAR_1->str[VAR_1->len - 1] == '\\r' ||\nVAR_1->str[VAR_1->len - 1] == '\\n')\nVAR_1->str[--VAR_1->len] = 0;",
"return 0;",
"}",
"return -1;",
"}"
] | [
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
53,
55,
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
23,324 | static void quantize_bands(int (*out)[2], const float *in, const float *scaled,
int size, float Q34, int is_signed, int maxval)
{
int i;
double qc;
for (i = 0; i < size; i++) {
qc = scaled[i] * Q34;
out[i][0] = (int)FFMIN((int)qc, maxval);
out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval);
if (is_signed && in[i] < 0.0f) {
out[i][0] = -out[i][0];
out[i][1] = -out[i][1];
}
}
}
| true | FFmpeg | 932e6a5a4c78250e3cab4f65215214fb0dbf51f7 | static void quantize_bands(int (*out)[2], const float *in, const float *scaled,
int size, float Q34, int is_signed, int maxval)
{
int i;
double qc;
for (i = 0; i < size; i++) {
qc = scaled[i] * Q34;
out[i][0] = (int)FFMIN((int)qc, maxval);
out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval);
if (is_signed && in[i] < 0.0f) {
out[i][0] = -out[i][0];
out[i][1] = -out[i][1];
}
}
}
| {
"code": [
" out[i][0] = (int)FFMIN((int)qc, maxval);",
" out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval);"
],
"line_no": [
15,
17
]
} | static void FUNC_0(int (*VAR_0)[2], const float *VAR_1, const float *VAR_2,
int VAR_3, float VAR_4, int VAR_5, int VAR_6)
{
int VAR_7;
double VAR_8;
for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {
VAR_8 = VAR_2[VAR_7] * VAR_4;
VAR_0[VAR_7][0] = (int)FFMIN((int)VAR_8, VAR_6);
VAR_0[VAR_7][1] = (int)FFMIN((int)(VAR_8 + 0.4054), VAR_6);
if (VAR_5 && VAR_1[VAR_7] < 0.0f) {
VAR_0[VAR_7][0] = -VAR_0[VAR_7][0];
VAR_0[VAR_7][1] = -VAR_0[VAR_7][1];
}
}
}
| [
"static void FUNC_0(int (*VAR_0)[2], const float *VAR_1, const float *VAR_2,\nint VAR_3, float VAR_4, int VAR_5, int VAR_6)\n{",
"int VAR_7;",
"double VAR_8;",
"for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {",
"VAR_8 = VAR_2[VAR_7] * VAR_4;",
"VAR_0[VAR_7][0] = (int)FFMIN((int)VAR_8, VAR_6);",
"VAR_0[VAR_7][1] = (int)FFMIN((int)(VAR_8 + 0.4054), VAR_6);",
"if (VAR_5 && VAR_1[VAR_7] < 0.0f) {",
"VAR_0[VAR_7][0] = -VAR_0[VAR_7][0];",
"VAR_0[VAR_7][1] = -VAR_0[VAR_7][1];",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
23,325 | av_cold int vaapi_device_init(const char *device)
{
int err;
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
device, NULL, 0);
if (err < 0) {
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
return err;
}
return 0;
} | true | FFmpeg | df3b17eba47e635a694acb18b74e389194355f45 | av_cold int vaapi_device_init(const char *device)
{
int err;
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
device, NULL, 0);
if (err < 0) {
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
return err;
}
return 0;
} | {
"code": [],
"line_no": []
} | av_cold int FUNC_0(const char *device)
{
int VAR_0;
VAR_0 = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
device, NULL, 0);
if (VAR_0 < 0) {
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
return VAR_0;
}
return 0;
} | [
"av_cold int FUNC_0(const char *device)\n{",
"int VAR_0;",
"VAR_0 = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,\ndevice, NULL, 0);",
"if (VAR_0 < 0) {",
"av_log(&vaapi_log, AV_LOG_ERROR, \"Failed to create a VAAPI device\\n\");",
"return VAR_0;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
]
] |
23,326 | static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
PtyCharDriver *s;
struct termios tty;
int slave_fd, len;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
#define q_ptsname(x) pty_name
#else
char *pty_name = NULL;
#define q_ptsname(x) ptsname(x)
#endif
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(PtyCharDriver));
if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return -errno;
}
/* Set raw attributes on the pty. */
tcgetattr(slave_fd, &tty);
cfmakeraw(&tty);
tcsetattr(slave_fd, TCSAFLUSH, &tty);
close(slave_fd);
len = strlen(q_ptsname(s->fd)) + 5;
chr->filename = g_malloc(len);
snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
qemu_opt_set(opts, "path", q_ptsname(s->fd));
fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
*_chr = chr;
return 0;
}
| true | qemu | a4e26048526d8d5b181f9a0a7d4f82b8441c5dfd | static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
PtyCharDriver *s;
struct termios tty;
int slave_fd, len;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
#define q_ptsname(x) pty_name
#else
char *pty_name = NULL;
#define q_ptsname(x) ptsname(x)
#endif
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(PtyCharDriver));
if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return -errno;
}
tcgetattr(slave_fd, &tty);
cfmakeraw(&tty);
tcsetattr(slave_fd, TCSAFLUSH, &tty);
close(slave_fd);
len = strlen(q_ptsname(s->fd)) + 5;
chr->filename = g_malloc(len);
snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
qemu_opt_set(opts, "path", q_ptsname(s->fd));
fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
*_chr = chr;
return 0;
}
| {
"code": [
" int slave_fd, len;",
" chr = g_malloc0(sizeof(CharDriverState));",
" s = g_malloc0(sizeof(PtyCharDriver));",
" if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {",
" len = strlen(q_ptsname(s->fd)) + 5;",
" snprintf(chr->filename, len, \"pty:%s\", q_ptsname(s->fd));",
" qemu_opt_set(opts, \"path\", q_ptsname(s->fd));",
" fprintf(stderr, \"char device redirected to %s\\n\", q_ptsname(s->fd));"
],
"line_no": [
11,
29,
31,
35,
55,
59,
61,
63
]
} | static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{
CharDriverState *chr;
PtyCharDriver *s;
struct termios VAR_2;
int VAR_3, VAR_4;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char VAR_5[PATH_MAX];
#define q_ptsname(x) VAR_5
#else
char *VAR_5 = NULL;
#define q_ptsname(x) ptsname(x)
#endif
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(PtyCharDriver));
if (openpty(&s->fd, &VAR_3, VAR_5, NULL, NULL) < 0) {
return -errno;
}
tcgetattr(VAR_3, &VAR_2);
cfmakeraw(&VAR_2);
tcsetattr(VAR_3, TCSAFLUSH, &VAR_2);
close(VAR_3);
VAR_4 = strlen(q_ptsname(s->fd)) + 5;
chr->filename = g_malloc(VAR_4);
snprintf(chr->filename, VAR_4, "pty:%s", q_ptsname(s->fd));
qemu_opt_set(VAR_0, "path", q_ptsname(s->fd));
fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
*VAR_1 = chr;
return 0;
}
| [
"static int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)\n{",
"CharDriverState *chr;",
"PtyCharDriver *s;",
"struct termios VAR_2;",
"int VAR_3, VAR_4;",
"#if defined(__OpenBSD__) || defined(__DragonFly__)\nchar VAR_5[PATH_MAX];",
"#define q_ptsname(x) VAR_5\n#else\nchar *VAR_5 = NULL;",
"#define q_ptsname(x) ptsname(x)\n#endif\nchr = g_malloc0(sizeof(CharDriverState));",
"s = g_malloc0(sizeof(PtyCharDriver));",
"if (openpty(&s->fd, &VAR_3, VAR_5, NULL, NULL) < 0) {",
"return -errno;",
"}",
"tcgetattr(VAR_3, &VAR_2);",
"cfmakeraw(&VAR_2);",
"tcsetattr(VAR_3, TCSAFLUSH, &VAR_2);",
"close(VAR_3);",
"VAR_4 = strlen(q_ptsname(s->fd)) + 5;",
"chr->filename = g_malloc(VAR_4);",
"snprintf(chr->filename, VAR_4, \"pty:%s\", q_ptsname(s->fd));",
"qemu_opt_set(VAR_0, \"path\", q_ptsname(s->fd));",
"fprintf(stderr, \"char device redirected to %s\\n\", q_ptsname(s->fd));",
"chr->opaque = s;",
"chr->chr_write = pty_chr_write;",
"chr->chr_update_read_handler = pty_chr_update_read_handler;",
"chr->chr_close = pty_chr_close;",
"s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);",
"*VAR_1 = chr;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19,
21
],
[
23,
25,
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
83
],
[
85
]
] |
23,327 | static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
/* Are we at the start of a block? */
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
if (desc && mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
/*use the last lot... */
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
/* We shouldn't get here if frames_per_jpeg <= 0 because this was rejected
in init */
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
/* ff_init_buffer_info(avctx, &s->picture[1]); */
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
}
| true | FFmpeg | df037fe107ccfae4b26ee0e46b638b052f6e49f8 | static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
if (desc && mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
}
| {
"code": [
" if (desc && mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {"
],
"line_no": [
45
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const AVPixFmtDescriptor *VAR_4;
SMVJpegDecodeContext *s = VAR_0->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int VAR_5, VAR_6 = 0, VAR_7 = 0;
VAR_6 = VAR_3->pts % s->frames_per_jpeg;
if (!VAR_6) {
av_frame_unref(mjpeg_data);
VAR_7 = avcodec_decode_video2(s->VAR_0, mjpeg_data, &s->mjpeg_data_size, VAR_3);
if (VAR_7 < 0) {
s->mjpeg_data_size = 0;
return VAR_7;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
VAR_4 = av_pix_fmt_desc_get(s->VAR_0->pix_fmt);
if (VAR_4 && mjpeg_data->height % (s->frames_per_jpeg << VAR_4->log2_chroma_h)) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
*VAR_2 = s->mjpeg_data_size;
VAR_0->pix_fmt = s->VAR_0->pix_fmt;
VAR_7 = ff_set_dimensions(VAR_0, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (VAR_7 < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return VAR_7;
}
if (*VAR_2) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = VAR_0->width;
s->picture[1]->height = VAR_0->height;
s->picture[1]->format = VAR_0->pix_fmt;
smv_img_pnt(s->picture[1]->VAR_1, mjpeg_data->VAR_1, mjpeg_data->linesize,
VAR_0->pix_fmt, VAR_0->width, VAR_0->height, VAR_6);
for (VAR_5 = 0; VAR_5 < AV_NUM_DATA_POINTERS; VAR_5++)
s->picture[1]->linesize[VAR_5] = mjpeg_data->linesize[VAR_5];
VAR_7 = av_frame_ref(VAR_1, s->picture[1]);
}
return VAR_7;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const AVPixFmtDescriptor *VAR_4;",
"SMVJpegDecodeContext *s = VAR_0->priv_data;",
"AVFrame* mjpeg_data = s->picture[0];",
"int VAR_5, VAR_6 = 0, VAR_7 = 0;",
"VAR_6 = VAR_3->pts % s->frames_per_jpeg;",
"if (!VAR_6) {",
"av_frame_unref(mjpeg_data);",
"VAR_7 = avcodec_decode_video2(s->VAR_0, mjpeg_data, &s->mjpeg_data_size, VAR_3);",
"if (VAR_7 < 0) {",
"s->mjpeg_data_size = 0;",
"return VAR_7;",
"}",
"} else if (!s->mjpeg_data_size)",
"return AVERROR(EINVAL);",
"VAR_4 = av_pix_fmt_desc_get(s->VAR_0->pix_fmt);",
"if (VAR_4 && mjpeg_data->height % (s->frames_per_jpeg << VAR_4->log2_chroma_h)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid height\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"*VAR_2 = s->mjpeg_data_size;",
"VAR_0->pix_fmt = s->VAR_0->pix_fmt;",
"VAR_7 = ff_set_dimensions(VAR_0, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);",
"if (VAR_7 < 0) {",
"av_log(s, AV_LOG_ERROR, \"Failed to set dimensions\\n\");",
"return VAR_7;",
"}",
"if (*VAR_2) {",
"s->picture[1]->extended_data = NULL;",
"s->picture[1]->width = VAR_0->width;",
"s->picture[1]->height = VAR_0->height;",
"s->picture[1]->format = VAR_0->pix_fmt;",
"smv_img_pnt(s->picture[1]->VAR_1, mjpeg_data->VAR_1, mjpeg_data->linesize,\nVAR_0->pix_fmt, VAR_0->width, VAR_0->height, VAR_6);",
"for (VAR_5 = 0; VAR_5 < AV_NUM_DATA_POINTERS; VAR_5++)",
"s->picture[1]->linesize[VAR_5] = mjpeg_data->linesize[VAR_5];",
"VAR_7 = av_frame_ref(VAR_1, s->picture[1]);",
"}",
"return VAR_7;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
61
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
111
]
] |
23,328 | static void tpm_display_backend_drivers(void)
{
int i;
fprintf(stderr, "Supported TPM types (choose only one):\n");
for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {
fprintf(stderr, "%12s %s\n",
TpmType_lookup[be_drivers[i]->type], be_drivers[i]->desc());
}
fprintf(stderr, "\n");
}
| true | qemu | a9a72aeefbd3ef8bcbbeeccaf174ee10db2978ac | static void tpm_display_backend_drivers(void)
{
int i;
fprintf(stderr, "Supported TPM types (choose only one):\n");
for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {
fprintf(stderr, "%12s %s\n",
TpmType_lookup[be_drivers[i]->type], be_drivers[i]->desc());
}
fprintf(stderr, "\n");
}
| {
"code": [
" int i;",
" for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {",
" int i;",
" for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {",
" TpmType_lookup[be_drivers[i]->type], be_drivers[i]->desc());",
" int i;",
" for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {"
],
"line_no": [
5,
13,
5,
13,
17,
5,
13
]
} | static void FUNC_0(void)
{
int VAR_0;
fprintf(stderr, "Supported TPM types (choose only one):\n");
for (VAR_0 = 0; VAR_0 < TPM_MAX_DRIVERS && be_drivers[VAR_0] != NULL; VAR_0++) {
fprintf(stderr, "%12s %s\n",
TpmType_lookup[be_drivers[VAR_0]->type], be_drivers[VAR_0]->desc());
}
fprintf(stderr, "\n");
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0;",
"fprintf(stderr, \"Supported TPM types (choose only one):\\n\");",
"for (VAR_0 = 0; VAR_0 < TPM_MAX_DRIVERS && be_drivers[VAR_0] != NULL; VAR_0++) {",
"fprintf(stderr, \"%12s %s\\n\",\nTpmType_lookup[be_drivers[VAR_0]->type], be_drivers[VAR_0]->desc());",
"}",
"fprintf(stderr, \"\\n\");",
"}"
] | [
0,
1,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
]
] |
23,329 | static void rtsp_parse_rtp_info(RTSPState *rt, const char *p)
{
int read = 0;
char key[20], value[1024], url[1024] = "";
uint32_t seq = 0, rtptime = 0;
for (;;) {
p += strspn(p, SPACE_CHARS);
if (!*p)
break;
get_word_sep(key, sizeof(key), "=", &p);
if (*p != '=')
break;
p++;
get_word_sep(value, sizeof(value), ";, ", &p);
read++;
if (!strcmp(key, "url"))
av_strlcpy(url, value, sizeof(url));
else if (!strcmp(key, "seq"))
seq = strtol(value, NULL, 10);
else if (!strcmp(key, "rtptime"))
rtptime = strtol(value, NULL, 10);
if (*p == ',') {
handle_rtp_info(rt, url, seq, rtptime);
url[0] = '\0';
seq = rtptime = 0;
read = 0;
}
if (*p)
p++;
}
if (read > 0)
handle_rtp_info(rt, url, seq, rtptime);
}
| false | FFmpeg | 907783f221ad9594a528681e30777705f11bf0b5 | static void rtsp_parse_rtp_info(RTSPState *rt, const char *p)
{
int read = 0;
char key[20], value[1024], url[1024] = "";
uint32_t seq = 0, rtptime = 0;
for (;;) {
p += strspn(p, SPACE_CHARS);
if (!*p)
break;
get_word_sep(key, sizeof(key), "=", &p);
if (*p != '=')
break;
p++;
get_word_sep(value, sizeof(value), ";, ", &p);
read++;
if (!strcmp(key, "url"))
av_strlcpy(url, value, sizeof(url));
else if (!strcmp(key, "seq"))
seq = strtol(value, NULL, 10);
else if (!strcmp(key, "rtptime"))
rtptime = strtol(value, NULL, 10);
if (*p == ',') {
handle_rtp_info(rt, url, seq, rtptime);
url[0] = '\0';
seq = rtptime = 0;
read = 0;
}
if (*p)
p++;
}
if (read > 0)
handle_rtp_info(rt, url, seq, rtptime);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RTSPState *VAR_0, const char *VAR_1)
{
int VAR_2 = 0;
char VAR_3[20], VAR_4[1024], VAR_5[1024] = "";
uint32_t seq = 0, rtptime = 0;
for (;;) {
VAR_1 += strspn(VAR_1, SPACE_CHARS);
if (!*VAR_1)
break;
get_word_sep(VAR_3, sizeof(VAR_3), "=", &VAR_1);
if (*VAR_1 != '=')
break;
VAR_1++;
get_word_sep(VAR_4, sizeof(VAR_4), ";, ", &VAR_1);
VAR_2++;
if (!strcmp(VAR_3, "VAR_5"))
av_strlcpy(VAR_5, VAR_4, sizeof(VAR_5));
else if (!strcmp(VAR_3, "seq"))
seq = strtol(VAR_4, NULL, 10);
else if (!strcmp(VAR_3, "rtptime"))
rtptime = strtol(VAR_4, NULL, 10);
if (*VAR_1 == ',') {
handle_rtp_info(VAR_0, VAR_5, seq, rtptime);
VAR_5[0] = '\0';
seq = rtptime = 0;
VAR_2 = 0;
}
if (*VAR_1)
VAR_1++;
}
if (VAR_2 > 0)
handle_rtp_info(VAR_0, VAR_5, seq, rtptime);
}
| [
"static void FUNC_0(RTSPState *VAR_0, const char *VAR_1)\n{",
"int VAR_2 = 0;",
"char VAR_3[20], VAR_4[1024], VAR_5[1024] = \"\";",
"uint32_t seq = 0, rtptime = 0;",
"for (;;) {",
"VAR_1 += strspn(VAR_1, SPACE_CHARS);",
"if (!*VAR_1)\nbreak;",
"get_word_sep(VAR_3, sizeof(VAR_3), \"=\", &VAR_1);",
"if (*VAR_1 != '=')\nbreak;",
"VAR_1++;",
"get_word_sep(VAR_4, sizeof(VAR_4), \";, \", &VAR_1);",
"VAR_2++;",
"if (!strcmp(VAR_3, \"VAR_5\"))\nav_strlcpy(VAR_5, VAR_4, sizeof(VAR_5));",
"else if (!strcmp(VAR_3, \"seq\"))\nseq = strtol(VAR_4, NULL, 10);",
"else if (!strcmp(VAR_3, \"rtptime\"))\nrtptime = strtol(VAR_4, NULL, 10);",
"if (*VAR_1 == ',') {",
"handle_rtp_info(VAR_0, VAR_5, seq, rtptime);",
"VAR_5[0] = '\\0';",
"seq = rtptime = 0;",
"VAR_2 = 0;",
"}",
"if (*VAR_1)\nVAR_1++;",
"}",
"if (VAR_2 > 0)\nhandle_rtp_info(VAR_0, VAR_5, seq, rtptime);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
]
] |
23,330 | static int bink_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,
int plane_idx, int is_chroma)
{
int blk, ret;
int i, j, bx, by;
uint8_t *dst, *prev, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
LOCAL_ALIGNED_16(int16_t, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = frame->linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(bc, c, i);
ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx];
ref_end = ref_start
+ (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_colors(bc, &c->bundle[BINK_SRC_COLORS], c)) < 0)
return ret;
if ((ret = read_patterns(c->avctx, bc, &c->bundle[BINK_SRC_PATTERN])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_X_OFF])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_Y_OFF])) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0)
return ret;
if ((ret = read_runs(c->avctx, bc, &c->bundle[BINK_SRC_RUN])) < 0)
return ret;
if (by == bh)
break;
dst = frame->data[plane_idx] + 8*by*stride;
prev = (c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx]) + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
// 16x16 block type on odd line means part of the already decoded block, so skip it
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
if (blk != FILL_BLOCK)
c->binkdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
break;
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
c->bdsp.clear_block(block);
v = bitstream_read(bc, 7);
read_residue(bc, block, v);
c->binkdsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_inter_quant, -1);
c->binkdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
}
}
if (bitstream_tell(bc) & 0x1F) // next plane data starts at 32-bit boundary
bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));
return 0;
}
| false | FFmpeg | fd92dafaff8844b5fedf94679b93d953939a7f7b | static int bink_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,
int plane_idx, int is_chroma)
{
int blk, ret;
int i, j, bx, by;
uint8_t *dst, *prev, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
LOCAL_ALIGNED_16(int16_t, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = frame->linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(bc, c, i);
ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx];
ref_end = ref_start
+ (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_colors(bc, &c->bundle[BINK_SRC_COLORS], c)) < 0)
return ret;
if ((ret = read_patterns(c->avctx, bc, &c->bundle[BINK_SRC_PATTERN])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_X_OFF])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_Y_OFF])) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0)
return ret;
if ((ret = read_runs(c->avctx, bc, &c->bundle[BINK_SRC_RUN])) < 0)
return ret;
if (by == bh)
break;
dst = frame->data[plane_idx] + 8*by*stride;
prev = (c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx]) + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
if (blk != FILL_BLOCK)
c->binkdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
break;
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
c->bdsp.clear_block(block);
v = bitstream_read(bc, 7);
read_residue(bc, block, v);
c->binkdsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_inter_quant, -1);
c->binkdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
}
}
if (bitstream_tell(bc) & 0x1F)
bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BinkContext *VAR_0, AVFrame *VAR_1, BitstreamContext *VAR_2,
int VAR_3, int VAR_4)
{
int VAR_5, VAR_6;
int VAR_7, VAR_8, VAR_9, VAR_10;
uint8_t *dst, *prev, *ref_start, *ref_end;
int VAR_11, VAR_12[2];
const uint8_t *VAR_13;
LOCAL_ALIGNED_16(int16_t, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int VAR_14[64];
const int VAR_15 = VAR_1->linesize[VAR_3];
int VAR_16 = VAR_4 ? (VAR_0->avctx->VAR_18 + 15) >> 4 : (VAR_0->avctx->VAR_18 + 7) >> 3;
int VAR_17 = VAR_4 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3;
int VAR_18 = VAR_0->avctx->VAR_18 >> VAR_4;
init_lengths(VAR_0, FFMAX(VAR_18, 8), VAR_16);
for (VAR_7 = 0; VAR_7 < BINK_NB_SRC; VAR_7++)
read_bundle(VAR_2, VAR_0, VAR_7);
ref_start = VAR_0->last->data[VAR_3] ? VAR_0->last->data[VAR_3]
: VAR_1->data[VAR_3];
ref_end = ref_start
+ (VAR_16 - 1 + VAR_0->last->linesize[VAR_3] * (VAR_17 - 1)) * 8;
for (VAR_7 = 0; VAR_7 < 64; VAR_7++)
VAR_14[VAR_7] = (VAR_7 & 7) + (VAR_7 >> 3) * VAR_15;
for (VAR_10 = 0; VAR_10 < VAR_17; VAR_10++) {
if ((VAR_6 = read_block_types(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_BLOCK_TYPES])) < 0)
return VAR_6;
if ((VAR_6 = read_block_types(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0)
return VAR_6;
if ((VAR_6 = read_colors(VAR_2, &VAR_0->bundle[BINK_SRC_COLORS], VAR_0)) < 0)
return VAR_6;
if ((VAR_6 = read_patterns(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_PATTERN])) < 0)
return VAR_6;
if ((VAR_6 = read_motion_values(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_X_OFF])) < 0)
return VAR_6;
if ((VAR_6 = read_motion_values(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_Y_OFF])) < 0)
return VAR_6;
if ((VAR_6 = read_dcs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0)
return VAR_6;
if ((VAR_6 = read_dcs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0)
return VAR_6;
if ((VAR_6 = read_runs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_RUN])) < 0)
return VAR_6;
if (VAR_10 == VAR_17)
break;
dst = VAR_1->data[VAR_3] + 8*VAR_10*VAR_15;
prev = (VAR_0->last->data[VAR_3] ? VAR_0->last->data[VAR_3]
: VAR_1->data[VAR_3]) + 8*VAR_10*VAR_15;
for (VAR_9 = 0; VAR_9 < VAR_16; VAR_9++, dst += 8, prev += 8) {
VAR_5 = get_value(VAR_0, BINK_SRC_BLOCK_TYPES);
if ((VAR_10 & 1) && VAR_5 == SCALED_BLOCK) {
VAR_9++;
dst += 8;
prev += 8;
continue;
}
switch (VAR_5) {
case SKIP_BLOCK:
VAR_0->hdsp.put_pixels_tab[1][0](dst, prev, VAR_15, 8);
break;
case SCALED_BLOCK:
VAR_5 = get_value(VAR_0, BINK_SRC_SUB_BLOCK_TYPES);
switch (VAR_5) {
case RUN_BLOCK:
VAR_13 = bink_patterns[bitstream_read(VAR_2, 4)];
VAR_7 = 0;
do {
int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;
VAR_7 += VAR_20;
if (VAR_7 > 64) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(VAR_2)) {
VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)
ublock[*VAR_13++] = VAR_11;
} else {
for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)
ublock[*VAR_13++] = get_value(VAR_0, BINK_SRC_COLORS);
}
} while (VAR_7 < 63);
if (VAR_7 == 63)
ublock[*VAR_13++] = get_value(VAR_0, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);
read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_intra_quant, -1);
VAR_0->binkdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);
VAR_0->bdsp.fill_block_tab[0](dst, VAR_11, VAR_15, 16);
break;
case PATTERN_BLOCK:
for (VAR_7 = 0; VAR_7 < 2; VAR_7++)
VAR_12[VAR_7] = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {
VAR_11 = get_value(VAR_0, BINK_SRC_PATTERN);
for (VAR_7 = 0; VAR_7 < 8; VAR_7++, VAR_11 >>= 1)
ublock[VAR_7 + VAR_8*8] = VAR_12[VAR_11 & 1];
}
break;
case RAW_BLOCK:
for (VAR_8 = 0; VAR_8 < 8; VAR_8++)
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
ublock[VAR_7 + VAR_8*8] = get_value(VAR_0, BINK_SRC_COLORS);
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", VAR_5);
return AVERROR_INVALIDDATA;
}
if (VAR_5 != FILL_BLOCK)
VAR_0->binkdsp.scale_block(ublock, dst, VAR_15);
VAR_9++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
VAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,
ref_start, ref_end);
if (VAR_6 < 0)
return VAR_6;
break;
case RUN_BLOCK:
VAR_13 = bink_patterns[bitstream_read(VAR_2, 4)];
VAR_7 = 0;
do {
int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;
VAR_7 += VAR_20;
if (VAR_7 > 64) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(VAR_2)) {
VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)
dst[VAR_14[*VAR_13++]] = VAR_11;
} else {
for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)
dst[VAR_14[*VAR_13++]] = get_value(VAR_0, BINK_SRC_COLORS);
}
} while (VAR_7 < 63);
if (VAR_7 == 63)
dst[VAR_14[*VAR_13++]] = get_value(VAR_0, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
VAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,
ref_start, ref_end);
if (VAR_6 < 0)
return VAR_6;
VAR_0->bdsp.clear_block(block);
VAR_11 = bitstream_read(VAR_2, 7);
read_residue(VAR_2, block, VAR_11);
VAR_0->binkdsp.add_pixels8(dst, block, VAR_15);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);
read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_intra_quant, -1);
VAR_0->binkdsp.idct_put(dst, VAR_15, dctblock);
break;
case FILL_BLOCK:
VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);
VAR_0->bdsp.fill_block_tab[1](dst, VAR_11, VAR_15, 8);
break;
case INTER_BLOCK:
VAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,
ref_start, ref_end);
if (VAR_6 < 0)
return VAR_6;
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTER_DC);
read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_inter_quant, -1);
VAR_0->binkdsp.idct_add(dst, VAR_15, dctblock);
break;
case PATTERN_BLOCK:
for (VAR_7 = 0; VAR_7 < 2; VAR_7++)
VAR_12[VAR_7] = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {
VAR_11 = get_value(VAR_0, BINK_SRC_PATTERN);
for (VAR_8 = 0; VAR_8 < 8; VAR_8++, VAR_11 >>= 1)
dst[VAR_7*VAR_15 + VAR_8] = VAR_12[VAR_11 & 1];
}
break;
case RAW_BLOCK:
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
memcpy(dst + VAR_7*VAR_15, VAR_0->bundle[BINK_SRC_COLORS].cur_ptr + VAR_7*8, 8);
VAR_0->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown block type %d\n", VAR_5);
return AVERROR_INVALIDDATA;
}
}
}
if (bitstream_tell(VAR_2) & 0x1F)
bitstream_skip(VAR_2, 32 - (bitstream_tell(VAR_2) & 0x1F));
return 0;
}
| [
"static int FUNC_0(BinkContext *VAR_0, AVFrame *VAR_1, BitstreamContext *VAR_2,\nint VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6;",
"int VAR_7, VAR_8, VAR_9, VAR_10;",
"uint8_t *dst, *prev, *ref_start, *ref_end;",
"int VAR_11, VAR_12[2];",
"const uint8_t *VAR_13;",
"LOCAL_ALIGNED_16(int16_t, block, [64]);",
"LOCAL_ALIGNED_16(uint8_t, ublock, [64]);",
"LOCAL_ALIGNED_16(int32_t, dctblock, [64]);",
"int VAR_14[64];",
"const int VAR_15 = VAR_1->linesize[VAR_3];",
"int VAR_16 = VAR_4 ? (VAR_0->avctx->VAR_18 + 15) >> 4 : (VAR_0->avctx->VAR_18 + 7) >> 3;",
"int VAR_17 = VAR_4 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3;",
"int VAR_18 = VAR_0->avctx->VAR_18 >> VAR_4;",
"init_lengths(VAR_0, FFMAX(VAR_18, 8), VAR_16);",
"for (VAR_7 = 0; VAR_7 < BINK_NB_SRC; VAR_7++)",
"read_bundle(VAR_2, VAR_0, VAR_7);",
"ref_start = VAR_0->last->data[VAR_3] ? VAR_0->last->data[VAR_3]\n: VAR_1->data[VAR_3];",
"ref_end = ref_start\n+ (VAR_16 - 1 + VAR_0->last->linesize[VAR_3] * (VAR_17 - 1)) * 8;",
"for (VAR_7 = 0; VAR_7 < 64; VAR_7++)",
"VAR_14[VAR_7] = (VAR_7 & 7) + (VAR_7 >> 3) * VAR_15;",
"for (VAR_10 = 0; VAR_10 < VAR_17; VAR_10++) {",
"if ((VAR_6 = read_block_types(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_BLOCK_TYPES])) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_block_types(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_colors(VAR_2, &VAR_0->bundle[BINK_SRC_COLORS], VAR_0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_patterns(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_PATTERN])) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_motion_values(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_X_OFF])) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_motion_values(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_Y_OFF])) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_dcs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_dcs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0)\nreturn VAR_6;",
"if ((VAR_6 = read_runs(VAR_0->avctx, VAR_2, &VAR_0->bundle[BINK_SRC_RUN])) < 0)\nreturn VAR_6;",
"if (VAR_10 == VAR_17)\nbreak;",
"dst = VAR_1->data[VAR_3] + 8*VAR_10*VAR_15;",
"prev = (VAR_0->last->data[VAR_3] ? VAR_0->last->data[VAR_3]\n: VAR_1->data[VAR_3]) + 8*VAR_10*VAR_15;",
"for (VAR_9 = 0; VAR_9 < VAR_16; VAR_9++, dst += 8, prev += 8) {",
"VAR_5 = get_value(VAR_0, BINK_SRC_BLOCK_TYPES);",
"if ((VAR_10 & 1) && VAR_5 == SCALED_BLOCK) {",
"VAR_9++;",
"dst += 8;",
"prev += 8;",
"continue;",
"}",
"switch (VAR_5) {",
"case SKIP_BLOCK:\nVAR_0->hdsp.put_pixels_tab[1][0](dst, prev, VAR_15, 8);",
"break;",
"case SCALED_BLOCK:\nVAR_5 = get_value(VAR_0, BINK_SRC_SUB_BLOCK_TYPES);",
"switch (VAR_5) {",
"case RUN_BLOCK:\nVAR_13 = bink_patterns[bitstream_read(VAR_2, 4)];",
"VAR_7 = 0;",
"do {",
"int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;",
"VAR_7 += VAR_20;",
"if (VAR_7 > 64) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (bitstream_read_bit(VAR_2)) {",
"VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)",
"ublock[*VAR_13++] = VAR_11;",
"} else {",
"for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)",
"ublock[*VAR_13++] = get_value(VAR_0, BINK_SRC_COLORS);",
"}",
"} while (VAR_7 < 63);",
"if (VAR_7 == 63)\nublock[*VAR_13++] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"case INTRA_BLOCK:\nmemset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);",
"read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_intra_quant, -1);",
"VAR_0->binkdsp.idct_put(ublock, 8, dctblock);",
"break;",
"case FILL_BLOCK:\nVAR_11 = get_value(VAR_0, BINK_SRC_COLORS);",
"VAR_0->bdsp.fill_block_tab[0](dst, VAR_11, VAR_15, 16);",
"break;",
"case PATTERN_BLOCK:\nfor (VAR_7 = 0; VAR_7 < 2; VAR_7++)",
"VAR_12[VAR_7] = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {",
"VAR_11 = get_value(VAR_0, BINK_SRC_PATTERN);",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++, VAR_11 >>= 1)",
"ublock[VAR_7 + VAR_8*8] = VAR_12[VAR_11 & 1];",
"}",
"break;",
"case RAW_BLOCK:\nfor (VAR_8 = 0; VAR_8 < 8; VAR_8++)",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"ublock[VAR_7 + VAR_8*8] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect 16x16 block type %d\\n\", VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_5 != FILL_BLOCK)\nVAR_0->binkdsp.scale_block(ublock, dst, VAR_15);",
"VAR_9++;",
"dst += 8;",
"prev += 8;",
"break;",
"case MOTION_BLOCK:\nVAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,\nref_start, ref_end);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"break;",
"case RUN_BLOCK:\nVAR_13 = bink_patterns[bitstream_read(VAR_2, 4)];",
"VAR_7 = 0;",
"do {",
"int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;",
"VAR_7 += VAR_20;",
"if (VAR_7 > 64) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (bitstream_read_bit(VAR_2)) {",
"VAR_11 = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)",
"dst[VAR_14[*VAR_13++]] = VAR_11;",
"} else {",
"for (VAR_8 = 0; VAR_8 < VAR_20; VAR_8++)",
"dst[VAR_14[*VAR_13++]] = get_value(VAR_0, BINK_SRC_COLORS);",
"}",
"} while (VAR_7 < 63);",
"if (VAR_7 == 63)\ndst[VAR_14[*VAR_13++]] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"case RESIDUE_BLOCK:\nVAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,\nref_start, ref_end);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"VAR_0->bdsp.clear_block(block);",
"VAR_11 = bitstream_read(VAR_2, 7);",
"read_residue(VAR_2, block, VAR_11);",
"VAR_0->binkdsp.add_pixels8(dst, block, VAR_15);",
"break;",
"case INTRA_BLOCK:\nmemset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);",
"read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_intra_quant, -1);",
"VAR_0->binkdsp.idct_put(dst, VAR_15, dctblock);",
"break;",
"case FILL_BLOCK:\nVAR_11 = get_value(VAR_0, BINK_SRC_COLORS);",
"VAR_0->bdsp.fill_block_tab[1](dst, VAR_11, VAR_15, 8);",
"break;",
"case INTER_BLOCK:\nVAR_6 = bink_put_pixels(VAR_0, dst, prev, VAR_15,\nref_start, ref_end);",
"if (VAR_6 < 0)\nreturn VAR_6;",
"memset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTER_DC);",
"read_dct_coeffs(VAR_2, dctblock, bink_scan, bink_inter_quant, -1);",
"VAR_0->binkdsp.idct_add(dst, VAR_15, dctblock);",
"break;",
"case PATTERN_BLOCK:\nfor (VAR_7 = 0; VAR_7 < 2; VAR_7++)",
"VAR_12[VAR_7] = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++) {",
"VAR_11 = get_value(VAR_0, BINK_SRC_PATTERN);",
"for (VAR_8 = 0; VAR_8 < 8; VAR_8++, VAR_11 >>= 1)",
"dst[VAR_7*VAR_15 + VAR_8] = VAR_12[VAR_11 & 1];",
"}",
"break;",
"case RAW_BLOCK:\nfor (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"memcpy(dst + VAR_7*VAR_15, VAR_0->bundle[BINK_SRC_COLORS].cur_ptr + VAR_7*8, 8);",
"VAR_0->bundle[BINK_SRC_COLORS].cur_ptr += 64;",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown block type %d\\n\", VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"if (bitstream_tell(VAR_2) & 0x1F)\nbitstream_skip(VAR_2, 32 - (bitstream_tell(VAR_2) & 0x1F));",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
49,
51
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79,
81
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227,
229
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259,
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309,
311
],
[
313
],
[
315,
317,
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355,
357,
359
],
[
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375,
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393,
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
421
],
[
423
]
] |
23,331 | static void opt_frame_pad_right(const char *arg)
{
frame_padright = atoi(arg);
if (frame_padright < 0) {
fprintf(stderr, "Incorrect right pad size\n");
av_exit(1);
}
}
| false | FFmpeg | 0c22311b56e66115675c4a96e4c78547886a4171 | static void opt_frame_pad_right(const char *arg)
{
frame_padright = atoi(arg);
if (frame_padright < 0) {
fprintf(stderr, "Incorrect right pad size\n");
av_exit(1);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
frame_padright = atoi(VAR_0);
if (frame_padright < 0) {
fprintf(stderr, "Incorrect right pad size\n");
av_exit(1);
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"frame_padright = atoi(VAR_0);",
"if (frame_padright < 0) {",
"fprintf(stderr, \"Incorrect right pad size\\n\");",
"av_exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
23,332 | static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
DCAContext *s = avctx->priv_data;
AVFrame *frame = data;
uint8_t *input = avpkt->data;
int input_size = avpkt->size;
int i, ret, prev_packet = s->packet;
if (input_size < MIN_PACKET_SIZE || input_size > MAX_PACKET_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n");
return AVERROR_INVALIDDATA;
}
av_fast_malloc(&s->buffer, &s->buffer_size,
FFALIGN(input_size, 4096) + DCA_BUFFER_PADDING_SIZE);
if (!s->buffer)
return AVERROR(ENOMEM);
for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++)
ret = convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
return ret;
}
input = s->buffer;
input_size = ret;
s->packet = 0;
// Parse backward compatible core sub-stream
if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) {
int frame_size;
if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0)
return ret;
s->packet |= DCA_PACKET_CORE;
// EXXS data must be aligned on 4-byte boundary
frame_size = FFALIGN(s->core.frame_size, 4);
if (input_size - 4 > frame_size) {
input += frame_size;
input_size -= frame_size;
}
}
if (!s->core_only) {
DCAExssAsset *asset = NULL;
// Parse extension sub-stream (EXSS)
if (AV_RB32(input) == DCA_SYNCWORD_SUBSTREAM) {
if ((ret = ff_dca_exss_parse(&s->exss, input, input_size)) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
} else {
s->packet |= DCA_PACKET_EXSS;
asset = &s->exss.assets[0];
}
}
// Parse XLL component in EXSS
if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {
if ((ret = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {
// Conceal XLL synchronization error
if (ret == AVERROR(EAGAIN)
&& (prev_packet & DCA_PACKET_XLL)
&& (s->packet & DCA_PACKET_CORE))
s->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;
else if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_XLL;
}
}
// Parse LBR component in EXSS
if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {
if ((ret = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {
if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_LBR;
}
}
// Parse core extensions in EXSS or backward compatible core sub-stream
if ((s->packet & DCA_PACKET_CORE)
&& (ret = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)
return ret;
}
// Filter the frame
if (s->packet & DCA_PACKET_LBR) {
if ((ret = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)
return ret;
} else if (s->packet & DCA_PACKET_XLL) {
if (s->packet & DCA_PACKET_CORE) {
int x96_synth = -1;
// Enable X96 synthesis if needed
if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)
x96_synth = 1;
if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0)
return ret;
// Force lossy downmixed output on the first core frame filtered.
// This prevents audible clicks when seeking and is consistent with
// what reference decoder does when there are multiple channel sets.
if (!(prev_packet & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0
&& s->xll.nchsets > 1) {
av_log(avctx, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n");
s->packet |= DCA_PACKET_RECOVERY;
}
// Set 'residual ok' flag for the next frame
s->packet |= DCA_PACKET_RESIDUAL;
}
if ((ret = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {
// Fall back to core unless hard error
if (!(s->packet & DCA_PACKET_CORE))
return ret;
if (ret != AVERROR_INVALIDDATA || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
}
} else if (s->packet & DCA_PACKET_CORE) {
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)
s->packet |= DCA_PACKET_RESIDUAL;
} else {
av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n");
if (s->core_only)
av_log(avctx, AV_LOG_WARNING, "Consider disabling 'core_only' option\n");
return AVERROR_INVALIDDATA;
}
*got_frame_ptr = 1;
return avpkt->size;
}
| false | FFmpeg | d1f558b3628d3ab99fd93a98b5758ef1be45a5da | static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
DCAContext *s = avctx->priv_data;
AVFrame *frame = data;
uint8_t *input = avpkt->data;
int input_size = avpkt->size;
int i, ret, prev_packet = s->packet;
if (input_size < MIN_PACKET_SIZE || input_size > MAX_PACKET_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n");
return AVERROR_INVALIDDATA;
}
av_fast_malloc(&s->buffer, &s->buffer_size,
FFALIGN(input_size, 4096) + DCA_BUFFER_PADDING_SIZE);
if (!s->buffer)
return AVERROR(ENOMEM);
for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++)
ret = convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
return ret;
}
input = s->buffer;
input_size = ret;
s->packet = 0;
if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) {
int frame_size;
if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0)
return ret;
s->packet |= DCA_PACKET_CORE;
frame_size = FFALIGN(s->core.frame_size, 4);
if (input_size - 4 > frame_size) {
input += frame_size;
input_size -= frame_size;
}
}
if (!s->core_only) {
DCAExssAsset *asset = NULL;
if (AV_RB32(input) == DCA_SYNCWORD_SUBSTREAM) {
if ((ret = ff_dca_exss_parse(&s->exss, input, input_size)) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
} else {
s->packet |= DCA_PACKET_EXSS;
asset = &s->exss.assets[0];
}
}
if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {
if ((ret = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {
if (ret == AVERROR(EAGAIN)
&& (prev_packet & DCA_PACKET_XLL)
&& (s->packet & DCA_PACKET_CORE))
s->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;
else if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_XLL;
}
}
if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {
if ((ret = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {
if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_LBR;
}
}
if ((s->packet & DCA_PACKET_CORE)
&& (ret = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)
return ret;
}
if (s->packet & DCA_PACKET_LBR) {
if ((ret = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)
return ret;
} else if (s->packet & DCA_PACKET_XLL) {
if (s->packet & DCA_PACKET_CORE) {
int x96_synth = -1;
if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)
x96_synth = 1;
if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0)
return ret;
if (!(prev_packet & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0
&& s->xll.nchsets > 1) {
av_log(avctx, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n");
s->packet |= DCA_PACKET_RECOVERY;
}
s->packet |= DCA_PACKET_RESIDUAL;
}
if ((ret = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {
if (!(s->packet & DCA_PACKET_CORE))
return ret;
if (ret != AVERROR_INVALIDDATA || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
}
} else if (s->packet & DCA_PACKET_CORE) {
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)
s->packet |= DCA_PACKET_RESIDUAL;
} else {
av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n");
if (s->core_only)
av_log(avctx, AV_LOG_WARNING, "Consider disabling 'core_only' option\n");
return AVERROR_INVALIDDATA;
}
*got_frame_ptr = 1;
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
DCAContext *s = VAR_0->priv_data;
AVFrame *frame = VAR_1;
uint8_t *input = VAR_3->VAR_1;
int VAR_4 = VAR_3->size;
int VAR_5, VAR_6, VAR_7 = s->packet;
if (VAR_4 < MIN_PACKET_SIZE || VAR_4 > MAX_PACKET_SIZE) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid packet size\n");
return AVERROR_INVALIDDATA;
}
av_fast_malloc(&s->buffer, &s->buffer_size,
FFALIGN(VAR_4, 4096) + DCA_BUFFER_PADDING_SIZE);
if (!s->buffer)
return AVERROR(ENOMEM);
for (VAR_5 = 0, VAR_6 = AVERROR_INVALIDDATA; VAR_5 < VAR_4 - MIN_PACKET_SIZE + 1 && VAR_6 < 0; VAR_5++)
VAR_6 = convert_bitstream(input + VAR_5, VAR_4 - VAR_5, s->buffer, s->buffer_size);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR, "Not a valid DCA frame\n");
return VAR_6;
}
input = s->buffer;
VAR_4 = VAR_6;
s->packet = 0;
if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) {
int VAR_8;
if ((VAR_6 = ff_dca_core_parse(&s->core, input, VAR_4)) < 0)
return VAR_6;
s->packet |= DCA_PACKET_CORE;
VAR_8 = FFALIGN(s->core.VAR_8, 4);
if (VAR_4 - 4 > VAR_8) {
input += VAR_8;
VAR_4 -= VAR_8;
}
}
if (!s->core_only) {
DCAExssAsset *asset = NULL;
if (AV_RB32(input) == DCA_SYNCWORD_SUBSTREAM) {
if ((VAR_6 = ff_dca_exss_parse(&s->exss, input, VAR_4)) < 0) {
if (VAR_0->err_recognition & AV_EF_EXPLODE)
return VAR_6;
} else {
s->packet |= DCA_PACKET_EXSS;
asset = &s->exss.assets[0];
}
}
if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {
if ((VAR_6 = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {
if (VAR_6 == AVERROR(EAGAIN)
&& (VAR_7 & DCA_PACKET_XLL)
&& (s->packet & DCA_PACKET_CORE))
s->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;
else if (VAR_6 == AVERROR(ENOMEM) || (VAR_0->err_recognition & AV_EF_EXPLODE))
return VAR_6;
} else {
s->packet |= DCA_PACKET_XLL;
}
}
if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {
if ((VAR_6 = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {
if (VAR_6 == AVERROR(ENOMEM) || (VAR_0->err_recognition & AV_EF_EXPLODE))
return VAR_6;
} else {
s->packet |= DCA_PACKET_LBR;
}
}
if ((s->packet & DCA_PACKET_CORE)
&& (VAR_6 = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)
return VAR_6;
}
if (s->packet & DCA_PACKET_LBR) {
if ((VAR_6 = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)
return VAR_6;
} else if (s->packet & DCA_PACKET_XLL) {
if (s->packet & DCA_PACKET_CORE) {
int VAR_9 = -1;
if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)
VAR_9 = 1;
if ((VAR_6 = ff_dca_core_filter_fixed(&s->core, VAR_9)) < 0)
return VAR_6;
if (!(VAR_7 & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0
&& s->xll.nchsets > 1) {
av_log(VAR_0, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n");
s->packet |= DCA_PACKET_RECOVERY;
}
s->packet |= DCA_PACKET_RESIDUAL;
}
if ((VAR_6 = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {
if (!(s->packet & DCA_PACKET_CORE))
return VAR_6;
if (VAR_6 != AVERROR_INVALIDDATA || (VAR_0->err_recognition & AV_EF_EXPLODE))
return VAR_6;
if ((VAR_6 = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return VAR_6;
}
} else if (s->packet & DCA_PACKET_CORE) {
if ((VAR_6 = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return VAR_6;
if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)
s->packet |= DCA_PACKET_RESIDUAL;
} else {
av_log(VAR_0, AV_LOG_ERROR, "No valid DCA sub-stream found\n");
if (s->core_only)
av_log(VAR_0, AV_LOG_WARNING, "Consider disabling 'core_only' option\n");
return AVERROR_INVALIDDATA;
}
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"DCAContext *s = VAR_0->priv_data;",
"AVFrame *frame = VAR_1;",
"uint8_t *input = VAR_3->VAR_1;",
"int VAR_4 = VAR_3->size;",
"int VAR_5, VAR_6, VAR_7 = s->packet;",
"if (VAR_4 < MIN_PACKET_SIZE || VAR_4 > MAX_PACKET_SIZE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid packet size\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"av_fast_malloc(&s->buffer, &s->buffer_size,\nFFALIGN(VAR_4, 4096) + DCA_BUFFER_PADDING_SIZE);",
"if (!s->buffer)\nreturn AVERROR(ENOMEM);",
"for (VAR_5 = 0, VAR_6 = AVERROR_INVALIDDATA; VAR_5 < VAR_4 - MIN_PACKET_SIZE + 1 && VAR_6 < 0; VAR_5++)",
"VAR_6 = convert_bitstream(input + VAR_5, VAR_4 - VAR_5, s->buffer, s->buffer_size);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Not a valid DCA frame\\n\");",
"return VAR_6;",
"}",
"input = s->buffer;",
"VAR_4 = VAR_6;",
"s->packet = 0;",
"if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) {",
"int VAR_8;",
"if ((VAR_6 = ff_dca_core_parse(&s->core, input, VAR_4)) < 0)\nreturn VAR_6;",
"s->packet |= DCA_PACKET_CORE;",
"VAR_8 = FFALIGN(s->core.VAR_8, 4);",
"if (VAR_4 - 4 > VAR_8) {",
"input += VAR_8;",
"VAR_4 -= VAR_8;",
"}",
"}",
"if (!s->core_only) {",
"DCAExssAsset *asset = NULL;",
"if (AV_RB32(input) == DCA_SYNCWORD_SUBSTREAM) {",
"if ((VAR_6 = ff_dca_exss_parse(&s->exss, input, VAR_4)) < 0) {",
"if (VAR_0->err_recognition & AV_EF_EXPLODE)\nreturn VAR_6;",
"} else {",
"s->packet |= DCA_PACKET_EXSS;",
"asset = &s->exss.assets[0];",
"}",
"}",
"if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {",
"if ((VAR_6 = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {",
"if (VAR_6 == AVERROR(EAGAIN)\n&& (VAR_7 & DCA_PACKET_XLL)\n&& (s->packet & DCA_PACKET_CORE))\ns->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;",
"else if (VAR_6 == AVERROR(ENOMEM) || (VAR_0->err_recognition & AV_EF_EXPLODE))\nreturn VAR_6;",
"} else {",
"s->packet |= DCA_PACKET_XLL;",
"}",
"}",
"if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {",
"if ((VAR_6 = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {",
"if (VAR_6 == AVERROR(ENOMEM) || (VAR_0->err_recognition & AV_EF_EXPLODE))\nreturn VAR_6;",
"} else {",
"s->packet |= DCA_PACKET_LBR;",
"}",
"}",
"if ((s->packet & DCA_PACKET_CORE)\n&& (VAR_6 = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)\nreturn VAR_6;",
"}",
"if (s->packet & DCA_PACKET_LBR) {",
"if ((VAR_6 = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)\nreturn VAR_6;",
"} else if (s->packet & DCA_PACKET_XLL) {",
"if (s->packet & DCA_PACKET_CORE) {",
"int VAR_9 = -1;",
"if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)\nVAR_9 = 1;",
"if ((VAR_6 = ff_dca_core_filter_fixed(&s->core, VAR_9)) < 0)\nreturn VAR_6;",
"if (!(VAR_7 & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0\n&& s->xll.nchsets > 1) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Forcing XLL recovery mode\\n\");",
"s->packet |= DCA_PACKET_RECOVERY;",
"}",
"s->packet |= DCA_PACKET_RESIDUAL;",
"}",
"if ((VAR_6 = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {",
"if (!(s->packet & DCA_PACKET_CORE))\nreturn VAR_6;",
"if (VAR_6 != AVERROR_INVALIDDATA || (VAR_0->err_recognition & AV_EF_EXPLODE))\nreturn VAR_6;",
"if ((VAR_6 = ff_dca_core_filter_frame(&s->core, frame)) < 0)\nreturn VAR_6;",
"}",
"} else if (s->packet & DCA_PACKET_CORE) {",
"if ((VAR_6 = ff_dca_core_filter_frame(&s->core, frame)) < 0)\nreturn VAR_6;",
"if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)\ns->packet |= DCA_PACKET_RESIDUAL;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"No valid DCA sub-stream found\\n\");",
"if (s->core_only)\nav_log(VAR_0, AV_LOG_WARNING, \"Consider disabling 'core_only' option\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
67
],
[
69
],
[
73,
75
],
[
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
135,
137,
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
159
],
[
161
],
[
163,
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
179,
181,
183
],
[
185
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
207,
209
],
[
213,
215
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
239
],
[
241
],
[
245
],
[
249,
251
],
[
253,
255
],
[
257,
259
],
[
261
],
[
263
],
[
265,
267
],
[
269,
271
],
[
273
],
[
275
],
[
277,
279
],
[
281
],
[
283
],
[
287
],
[
291
],
[
293
]
] |
23,333 | static int iszero(const int16_t *c, int sz)
{
int n;
for (n = 0; n < sz; n += 4)
if (AV_RN32A(&c[n]))
return 0;
return 1;
}
| false | FFmpeg | 69e456d7fbc5fff88acf747d135bf15c8e511c59 | static int iszero(const int16_t *c, int sz)
{
int n;
for (n = 0; n < sz; n += 4)
if (AV_RN32A(&c[n]))
return 0;
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const int16_t *VAR_0, int VAR_1)
{
int VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2 += 4)
if (AV_RN32A(&VAR_0[VAR_2]))
return 0;
return 1;
}
| [
"static int FUNC_0(const int16_t *VAR_0, int VAR_1)\n{",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2 += 4)",
"if (AV_RN32A(&VAR_0[VAR_2]))\nreturn 0;",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17
],
[
19
]
] |
23,334 | void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
AVRational new_tb;
if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){
if(new_tb.num != pts_num)
av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/new_tb.num);
}else
av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index);
if(new_tb.num <= 0 || new_tb.den <= 0) {
av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", s->index);
return;
}
s->time_base = new_tb;
s->pts_wrap_bits = pts_wrap_bits;
}
| false | FFmpeg | 121d3875b692c83866928e271c4b6d20d680d1a6 | void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
AVRational new_tb;
if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){
if(new_tb.num != pts_num)
av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/new_tb.num);
}else
av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index);
if(new_tb.num <= 0 || new_tb.den <= 0) {
av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", s->index);
return;
}
s->time_base = new_tb;
s->pts_wrap_bits = pts_wrap_bits;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVStream *VAR_0, int VAR_1,
unsigned int VAR_2, unsigned int VAR_3)
{
AVRational new_tb;
if(av_reduce(&new_tb.num, &new_tb.den, VAR_2, VAR_3, INT_MAX)){
if(new_tb.num != VAR_2)
av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", VAR_0->index, VAR_2/new_tb.num);
}else
av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", VAR_0->index);
if(new_tb.num <= 0 || new_tb.den <= 0) {
av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", VAR_0->index);
return;
}
VAR_0->time_base = new_tb;
VAR_0->VAR_1 = VAR_1;
}
| [
"void FUNC_0(AVStream *VAR_0, int VAR_1,\nunsigned int VAR_2, unsigned int VAR_3)\n{",
"AVRational new_tb;",
"if(av_reduce(&new_tb.num, &new_tb.den, VAR_2, VAR_3, INT_MAX)){",
"if(new_tb.num != VAR_2)\nav_log(NULL, AV_LOG_DEBUG, \"st:%d removing common factor %d from timebase\\n\", VAR_0->index, VAR_2/new_tb.num);",
"}else",
"av_log(NULL, AV_LOG_WARNING, \"st:%d has too large timebase, reducing\\n\", VAR_0->index);",
"if(new_tb.num <= 0 || new_tb.den <= 0) {",
"av_log(NULL, AV_LOG_ERROR, \"Ignoring attempt to set invalid timebase for st:%d\\n\", VAR_0->index);",
"return;",
"}",
"VAR_0->time_base = new_tb;",
"VAR_0->VAR_1 = VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
23,335 | static void pci_bridge_region_init(PCIBridge *br)
{
PCIBus *parent = br->dev.bus;
uint16_t cmd = pci_get_word(br->dev.config + PCI_COMMAND);
pci_bridge_init_alias(br, &br->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&br->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
/* TODO: optinal VGA and VGA palette snooping support. */
}
| true | qemu | b308c82cbda44e138ef990af64d44a5613c16092 | static void pci_bridge_region_init(PCIBridge *br)
{
PCIBus *parent = br->dev.bus;
uint16_t cmd = pci_get_word(br->dev.config + PCI_COMMAND);
pci_bridge_init_alias(br, &br->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&br->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
}
| {
"code": [
"static void pci_bridge_region_init(PCIBridge *br)",
" pci_bridge_init_alias(br, &br->alias_pref_mem,",
" pci_bridge_init_alias(br, &br->alias_mem,",
" pci_bridge_init_alias(br, &br->alias_io,"
],
"line_no": [
1,
11,
23,
35
]
} | static void FUNC_0(PCIBridge *VAR_0)
{
PCIBus *parent = VAR_0->dev.bus;
uint16_t cmd = pci_get_word(VAR_0->dev.config + PCI_COMMAND);
pci_bridge_init_alias(VAR_0, &VAR_0->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&VAR_0->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(VAR_0, &VAR_0->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&VAR_0->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(VAR_0, &VAR_0->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&VAR_0->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
}
| [
"static void FUNC_0(PCIBridge *VAR_0)\n{",
"PCIBus *parent = VAR_0->dev.bus;",
"uint16_t cmd = pci_get_word(VAR_0->dev.config + PCI_COMMAND);",
"pci_bridge_init_alias(VAR_0, &VAR_0->alias_pref_mem,\nPCI_BASE_ADDRESS_MEM_PREFETCH,\n\"pci_bridge_pref_mem\",\n&VAR_0->address_space_mem,\nparent->address_space_mem,\ncmd & PCI_COMMAND_MEMORY);",
"pci_bridge_init_alias(VAR_0, &VAR_0->alias_mem,\nPCI_BASE_ADDRESS_SPACE_MEMORY,\n\"pci_bridge_mem\",\n&VAR_0->address_space_mem,\nparent->address_space_mem,\ncmd & PCI_COMMAND_MEMORY);",
"pci_bridge_init_alias(VAR_0, &VAR_0->alias_io,\nPCI_BASE_ADDRESS_SPACE_IO,\n\"pci_bridge_io\",\n&VAR_0->address_space_io,\nparent->address_space_io,\ncmd & PCI_COMMAND_IO);",
"}"
] | [
1,
0,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15,
17,
19,
21
],
[
23,
25,
27,
29,
31,
33
],
[
35,
37,
39,
41,
43,
45
],
[
49
]
] |
23,336 | static void ecc_reset(void *opaque)
{
ECCState *s = opaque;
int i;
s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);
s->regs[ECC_MER] |= ECC_MER_MRR;
s->regs[ECC_MDR] = 0x20;
s->regs[ECC_MFSR] = 0;
s->regs[ECC_VCR] = 0;
s->regs[ECC_MFAR0] = 0x07c00000;
s->regs[ECC_MFAR1] = 0;
s->regs[ECC_DR] = 0;
s->regs[ECC_ECR0] = 0;
s->regs[ECC_ECR1] = 0;
for (i = 1; i < ECC_NREGS; i++)
s->regs[i] = 0;
}
| true | qemu | 8f2ad0a3fc5e3569183d44bf1c7fcb95294be4c0 | static void ecc_reset(void *opaque)
{
ECCState *s = opaque;
int i;
s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);
s->regs[ECC_MER] |= ECC_MER_MRR;
s->regs[ECC_MDR] = 0x20;
s->regs[ECC_MFSR] = 0;
s->regs[ECC_VCR] = 0;
s->regs[ECC_MFAR0] = 0x07c00000;
s->regs[ECC_MFAR1] = 0;
s->regs[ECC_DR] = 0;
s->regs[ECC_ECR0] = 0;
s->regs[ECC_ECR1] = 0;
for (i = 1; i < ECC_NREGS; i++)
s->regs[i] = 0;
}
| {
"code": [
" int i;",
" for (i = 1; i < ECC_NREGS; i++)",
" s->regs[i] = 0;"
],
"line_no": [
7,
33,
35
]
} | static void FUNC_0(void *VAR_0)
{
ECCState *s = VAR_0;
int VAR_1;
s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);
s->regs[ECC_MER] |= ECC_MER_MRR;
s->regs[ECC_MDR] = 0x20;
s->regs[ECC_MFSR] = 0;
s->regs[ECC_VCR] = 0;
s->regs[ECC_MFAR0] = 0x07c00000;
s->regs[ECC_MFAR1] = 0;
s->regs[ECC_DR] = 0;
s->regs[ECC_ECR0] = 0;
s->regs[ECC_ECR1] = 0;
for (VAR_1 = 1; VAR_1 < ECC_NREGS; VAR_1++)
s->regs[VAR_1] = 0;
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"ECCState *s = VAR_0;",
"int VAR_1;",
"s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);",
"s->regs[ECC_MER] |= ECC_MER_MRR;",
"s->regs[ECC_MDR] = 0x20;",
"s->regs[ECC_MFSR] = 0;",
"s->regs[ECC_VCR] = 0;",
"s->regs[ECC_MFAR0] = 0x07c00000;",
"s->regs[ECC_MFAR1] = 0;",
"s->regs[ECC_DR] = 0;",
"s->regs[ECC_ECR0] = 0;",
"s->regs[ECC_ECR1] = 0;",
"for (VAR_1 = 1; VAR_1 < ECC_NREGS; VAR_1++)",
"s->regs[VAR_1] = 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
23,337 | static inline int16_t mipsdsp_add_i16(int16_t a, int16_t b, CPUMIPSState *env)
{
int16_t tempI;
tempI = a + b;
if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {
set_DSPControl_overflow_flag(1, 20, env);
}
return tempI;
}
| true | qemu | 20c334a797bf46a4ee59a6e42be6d5e7c3cda585 | static inline int16_t mipsdsp_add_i16(int16_t a, int16_t b, CPUMIPSState *env)
{
int16_t tempI;
tempI = a + b;
if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {
set_DSPControl_overflow_flag(1, 20, env);
}
return tempI;
}
| {
"code": [
" if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {"
],
"line_no": [
13
]
} | static inline int16_t FUNC_0(int16_t a, int16_t b, CPUMIPSState *env)
{
int16_t tempI;
tempI = a + b;
if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {
set_DSPControl_overflow_flag(1, 20, env);
}
return tempI;
}
| [
"static inline int16_t FUNC_0(int16_t a, int16_t b, CPUMIPSState *env)\n{",
"int16_t tempI;",
"tempI = a + b;",
"if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {",
"set_DSPControl_overflow_flag(1, 20, env);",
"}",
"return tempI;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
23,338 | void cpu_loop(CPUMBState *env)
{
int trapnr, ret;
target_siginfo_t info;
while (1) {
trapnr = cpu_mb_exec (env);
switch (trapnr) {
case 0xaa:
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* XXX: check env->error_code */
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
case EXCP_BREAK:
/* Return address is 4 bytes after the call. */
env->regs[14] += 4;
ret = do_syscall(env,
env->regs[12],
env->regs[5],
env->regs[6],
env->regs[7],
env->regs[8],
env->regs[9],
env->regs[10],
0, 0);
env->regs[3] = ret;
env->sregs[SR_PC] = env->regs[14];
break;
case EXCP_HW_EXCP:
env->regs[17] = env->sregs[SR_PC] + 4;
if (env->iflags & D_FLAG) {
env->sregs[SR_ESR] |= 1 << 12;
env->sregs[SR_PC] -= 4;
/* FIXME: if branch was immed, replay the imm as well. */
}
env->iflags &= ~(IMM_FLAG | D_FLAG);
switch (env->sregs[SR_ESR] & 31) {
case ESR_EC_DIVZERO:
info.si_signo = SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTDIV;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
case ESR_EC_FPU:
info.si_signo = SIGFPE;
info.si_errno = 0;
if (env->sregs[SR_FSR] & FSR_IO) {
info.si_code = TARGET_FPE_FLTINV;
}
if (env->sregs[SR_FSR] & FSR_DZ) {
info.si_code = TARGET_FPE_FLTDIV;
}
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
default:
printf ("Unhandled hw-exception: 0x%x\n",
env->sregs[SR_ESR] & ESR_EC_MASK);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
break;
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| true | qemu | d7dce494769e47c9a1eec6f55578d3acdfab888b | void cpu_loop(CPUMBState *env)
{
int trapnr, ret;
target_siginfo_t info;
while (1) {
trapnr = cpu_mb_exec (env);
switch (trapnr) {
case 0xaa:
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_INTERRUPT:
break;
case EXCP_BREAK:
env->regs[14] += 4;
ret = do_syscall(env,
env->regs[12],
env->regs[5],
env->regs[6],
env->regs[7],
env->regs[8],
env->regs[9],
env->regs[10],
0, 0);
env->regs[3] = ret;
env->sregs[SR_PC] = env->regs[14];
break;
case EXCP_HW_EXCP:
env->regs[17] = env->sregs[SR_PC] + 4;
if (env->iflags & D_FLAG) {
env->sregs[SR_ESR] |= 1 << 12;
env->sregs[SR_PC] -= 4;
}
env->iflags &= ~(IMM_FLAG | D_FLAG);
switch (env->sregs[SR_ESR] & 31) {
case ESR_EC_DIVZERO:
info.si_signo = SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTDIV;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
case ESR_EC_FPU:
info.si_signo = SIGFPE;
info.si_errno = 0;
if (env->sregs[SR_FSR] & FSR_IO) {
info.si_code = TARGET_FPE_FLTINV;
}
if (env->sregs[SR_FSR] & FSR_DZ) {
info.si_code = TARGET_FPE_FLTDIV;
}
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
default:
printf ("Unhandled hw-exception: 0x%x\n",
env->sregs[SR_ESR] & ESR_EC_MASK);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
break;
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| {
"code": [
" env->sregs[SR_PC] = env->regs[14];"
],
"line_no": [
69
]
} | void FUNC_0(CPUMBState *VAR_0)
{
int VAR_1, VAR_2;
target_siginfo_t info;
while (1) {
VAR_1 = cpu_mb_exec (VAR_0);
switch (VAR_1) {
case 0xaa:
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = 0;
queue_signal(VAR_0, info.si_signo, &info);
}
break;
case EXCP_INTERRUPT:
break;
case EXCP_BREAK:
VAR_0->regs[14] += 4;
VAR_2 = do_syscall(VAR_0,
VAR_0->regs[12],
VAR_0->regs[5],
VAR_0->regs[6],
VAR_0->regs[7],
VAR_0->regs[8],
VAR_0->regs[9],
VAR_0->regs[10],
0, 0);
VAR_0->regs[3] = VAR_2;
VAR_0->sregs[SR_PC] = VAR_0->regs[14];
break;
case EXCP_HW_EXCP:
VAR_0->regs[17] = VAR_0->sregs[SR_PC] + 4;
if (VAR_0->iflags & D_FLAG) {
VAR_0->sregs[SR_ESR] |= 1 << 12;
VAR_0->sregs[SR_PC] -= 4;
}
VAR_0->iflags &= ~(IMM_FLAG | D_FLAG);
switch (VAR_0->sregs[SR_ESR] & 31) {
case ESR_EC_DIVZERO:
info.si_signo = SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTDIV;
info._sifields._sigfault._addr = 0;
queue_signal(VAR_0, info.si_signo, &info);
break;
case ESR_EC_FPU:
info.si_signo = SIGFPE;
info.si_errno = 0;
if (VAR_0->sregs[SR_FSR] & FSR_IO) {
info.si_code = TARGET_FPE_FLTINV;
}
if (VAR_0->sregs[SR_FSR] & FSR_DZ) {
info.si_code = TARGET_FPE_FLTDIV;
}
info._sifields._sigfault._addr = 0;
queue_signal(VAR_0, info.si_signo, &info);
break;
default:
printf ("Unhandled hw-exception: 0x%x\n",
VAR_0->sregs[SR_ESR] & ESR_EC_MASK);
cpu_dump_state(VAR_0, stderr, fprintf, 0);
exit (1);
break;
}
break;
case EXCP_DEBUG:
{
int VAR_3;
VAR_3 = gdb_handlesig (VAR_0, TARGET_SIGTRAP);
if (VAR_3)
{
info.si_signo = VAR_3;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(VAR_0, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", VAR_1);
cpu_dump_state(VAR_0, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (VAR_0);
}
}
| [
"void FUNC_0(CPUMBState *VAR_0)\n{",
"int VAR_1, VAR_2;",
"target_siginfo_t info;",
"while (1) {",
"VAR_1 = cpu_mb_exec (VAR_0);",
"switch (VAR_1) {",
"case 0xaa:\n{",
"info.si_signo = SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = TARGET_SEGV_MAPERR;",
"info._sifields._sigfault._addr = 0;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"break;",
"case EXCP_INTERRUPT:\nbreak;",
"case EXCP_BREAK:\nVAR_0->regs[14] += 4;",
"VAR_2 = do_syscall(VAR_0,\nVAR_0->regs[12],\nVAR_0->regs[5],\nVAR_0->regs[6],\nVAR_0->regs[7],\nVAR_0->regs[8],\nVAR_0->regs[9],\nVAR_0->regs[10],\n0, 0);",
"VAR_0->regs[3] = VAR_2;",
"VAR_0->sregs[SR_PC] = VAR_0->regs[14];",
"break;",
"case EXCP_HW_EXCP:\nVAR_0->regs[17] = VAR_0->sregs[SR_PC] + 4;",
"if (VAR_0->iflags & D_FLAG) {",
"VAR_0->sregs[SR_ESR] |= 1 << 12;",
"VAR_0->sregs[SR_PC] -= 4;",
"}",
"VAR_0->iflags &= ~(IMM_FLAG | D_FLAG);",
"switch (VAR_0->sregs[SR_ESR] & 31) {",
"case ESR_EC_DIVZERO:\ninfo.si_signo = SIGFPE;",
"info.si_errno = 0;",
"info.si_code = TARGET_FPE_FLTDIV;",
"info._sifields._sigfault._addr = 0;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case ESR_EC_FPU:\ninfo.si_signo = SIGFPE;",
"info.si_errno = 0;",
"if (VAR_0->sregs[SR_FSR] & FSR_IO) {",
"info.si_code = TARGET_FPE_FLTINV;",
"}",
"if (VAR_0->sregs[SR_FSR] & FSR_DZ) {",
"info.si_code = TARGET_FPE_FLTDIV;",
"}",
"info._sifields._sigfault._addr = 0;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"default:\nprintf (\"Unhandled hw-exception: 0x%x\\n\",\nVAR_0->sregs[SR_ESR] & ESR_EC_MASK);",
"cpu_dump_state(VAR_0, stderr, fprintf, 0);",
"exit (1);",
"break;",
"}",
"break;",
"case EXCP_DEBUG:\n{",
"int VAR_3;",
"VAR_3 = gdb_handlesig (VAR_0, TARGET_SIGTRAP);",
"if (VAR_3)\n{",
"info.si_signo = VAR_3;",
"info.si_errno = 0;",
"info.si_code = TARGET_TRAP_BRKPT;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"}",
"break;",
"default:\nprintf (\"Unhandled trap: 0x%x\\n\", VAR_1);",
"cpu_dump_state(VAR_0, stderr, fprintf, 0);",
"exit (1);",
"}",
"process_pending_signals (VAR_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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
41
],
[
43,
47
],
[
49,
51,
53,
55,
57,
59,
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
]
] |
23,340 | static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,
int width, int height, int src1Stride,
int src2Stride, int dstStride)
{
int h;
for (h=0; h < height; h++) {
int w;
if (width >= 16)
#if COMPILE_TEMPLATE_SSE2
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a
);
#else
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", "%"REG_a
);
#endif
for (w= (width&(~15)); w < width; w++) {
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
__asm__(
#if !COMPILE_TEMPLATE_SSE2
EMMS" \n\t"
#endif
SFENCE" \n\t"
::: "memory"
);
}
| true | FFmpeg | 80bfce35ccd11458e97f68f417fc094c5347070c | static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,
int width, int height, int src1Stride,
int src2Stride, int dstStride)
{
int h;
for (h=0; h < height; h++) {
int w;
if (width >= 16)
#if COMPILE_TEMPLATE_SSE2
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a
);
#else
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", "%"REG_a
);
#endif
for (w= (width&(~15)); w < width; w++) {
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
__asm__(
#if !COMPILE_TEMPLATE_SSE2
EMMS" \n\t"
#endif
SFENCE" \n\t"
::: "memory"
);
}
| {
"code": [
" if (width >= 16)"
],
"line_no": [
19
]
} | static void FUNC_0(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,
int width, int height, int src1Stride,
int src2Stride, int dstStride)
{
int VAR_0;
for (VAR_0=0; VAR_0 < height; VAR_0++) {
int w;
if (width >= 16)
#if COMPILE_TEMPLATE_SSE2
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a
);
#else
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", "%"REG_a
);
#endif
for (w= (width&(~15)); w < width; w++) {
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
__asm__(
#if !COMPILE_TEMPLATE_SSE2
EMMS" \n\t"
#endif
SFENCE" \n\t"
::: "memory"
);
}
| [
"static void FUNC_0(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,\nint width, int height, int src1Stride,\nint src2Stride, int dstStride)\n{",
"int VAR_0;",
"for (VAR_0=0; VAR_0 < height; VAR_0++) {",
"int w;",
"if (width >= 16)\n#if COMPILE_TEMPLATE_SSE2\n__asm__(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\") \\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\") \\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm0 \\n\\t\"\n\"movdqa (%1, %%\"REG_a\"), %%xmm1 \\n\\t\"\n\"movdqa (%2, %%\"REG_a\"), %%xmm2 \\n\\t\"\n\"punpcklbw %%xmm2, %%xmm0 \\n\\t\"\n\"punpckhbw %%xmm2, %%xmm1 \\n\\t\"\n\"movntdq %%xmm0, (%0, %%\"REG_a\", 2) \\n\\t\"\n\"movntdq %%xmm1, 16(%0, %%\"REG_a\", 2) \\n\\t\"\n\"add $16, %%\"REG_a\" \\n\\t\"\n\"cmp %3, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" ((x86_reg)width-15)\n: \"memory\", XMM_CLOBBERS(\"xmm0\", \"xmm1\", \"xmm2\",) \"%\"REG_a\n);",
"#else\n__asm__(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"1: \\n\\t\"\nPREFETCH\" 64(%1, %%\"REG_a\") \\n\\t\"\nPREFETCH\" 64(%2, %%\"REG_a\") \\n\\t\"\n\"movq (%1, %%\"REG_a\"), %%mm0 \\n\\t\"\n\"movq 8(%1, %%\"REG_a\"), %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm1 \\n\\t\"\n\"movq %%mm2, %%mm3 \\n\\t\"\n\"movq (%2, %%\"REG_a\"), %%mm4 \\n\\t\"\n\"movq 8(%2, %%\"REG_a\"), %%mm5 \\n\\t\"\n\"punpcklbw %%mm4, %%mm0 \\n\\t\"\n\"punpckhbw %%mm4, %%mm1 \\n\\t\"\n\"punpcklbw %%mm5, %%mm2 \\n\\t\"\n\"punpckhbw %%mm5, %%mm3 \\n\\t\"\nMOVNTQ\" %%mm0, (%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm1, 8(%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm2, 16(%0, %%\"REG_a\", 2) \\n\\t\"\nMOVNTQ\" %%mm3, 24(%0, %%\"REG_a\", 2) \\n\\t\"\n\"add $16, %%\"REG_a\" \\n\\t\"\n\"cmp %3, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n::\"r\"(dest), \"r\"(src1), \"r\"(src2), \"r\" ((x86_reg)width-15)\n: \"memory\", \"%\"REG_a\n);",
"#endif\nfor (w= (width&(~15)); w < width; w++) {",
"dest[2*w+0] = src1[w];",
"dest[2*w+1] = src2[w];",
"}",
"dest += dstStride;",
"src1 += src1Stride;",
"src2 += src2Stride;",
"}",
"__asm__(\n#if !COMPILE_TEMPLATE_SSE2\nEMMS\" \\n\\t\"\n#endif\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57
],
[
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131,
133,
135,
137,
139,
141
],
[
143
]
] |
23,341 | static int dvbsub_parse_page_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;
const uint8_t *buf_end = buf + buf_size;
int region_id;
int page_state;
int timeout;
int version;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
timeout = *buf++;
version = ((*buf)>>4) & 15;
page_state = ((*buf++) >> 2) & 3;
if (ctx->version == version) {
return 0;
ctx->time_out = timeout;
ctx->version = version;
ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if(ctx->compute_edt == 1)
save_subtitle_set(avctx, sub, got_output);
if (page_state == 1 || page_state == 2) {
delete_regions(ctx);
delete_objects(ctx);
delete_cluts(ctx);
tmp_display_list = ctx->display_list;
ctx->display_list = NULL;
while (buf + 5 < buf_end) {
region_id = *buf++;
buf += 1;
display = tmp_display_list;
tmp_ptr = &tmp_display_list;
tmp_ptr = &display->next;
if (!display) {
display = av_mallocz(sizeof(DVBSubRegionDisplay));
if (!display)
return AVERROR(ENOMEM);
display->region_id = region_id;
display->x_pos = AV_RB16(buf);
buf += 2;
display->y_pos = AV_RB16(buf);
buf += 2;
*tmp_ptr = display->next;
display->next = ctx->display_list;
ctx->display_list = display;
ff_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
while (tmp_display_list) {
display = tmp_display_list;
tmp_display_list = display->next;
av_freep(&display);
return 0; | true | FFmpeg | 7c10068da10aa288195f5eb5d7e34eb2d8ff7447 | static int dvbsub_parse_page_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;
const uint8_t *buf_end = buf + buf_size;
int region_id;
int page_state;
int timeout;
int version;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
timeout = *buf++;
version = ((*buf)>>4) & 15;
page_state = ((*buf++) >> 2) & 3;
if (ctx->version == version) {
return 0;
ctx->time_out = timeout;
ctx->version = version;
ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if(ctx->compute_edt == 1)
save_subtitle_set(avctx, sub, got_output);
if (page_state == 1 || page_state == 2) {
delete_regions(ctx);
delete_objects(ctx);
delete_cluts(ctx);
tmp_display_list = ctx->display_list;
ctx->display_list = NULL;
while (buf + 5 < buf_end) {
region_id = *buf++;
buf += 1;
display = tmp_display_list;
tmp_ptr = &tmp_display_list;
tmp_ptr = &display->next;
if (!display) {
display = av_mallocz(sizeof(DVBSubRegionDisplay));
if (!display)
return AVERROR(ENOMEM);
display->region_id = region_id;
display->x_pos = AV_RB16(buf);
buf += 2;
display->y_pos = AV_RB16(buf);
buf += 2;
*tmp_ptr = display->next;
display->next = ctx->display_list;
ctx->display_list = display;
ff_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
while (tmp_display_list) {
display = tmp_display_list;
tmp_display_list = display->next;
av_freep(&display);
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2, AVSubtitle *VAR_3, int *VAR_4)
{
DVBSubContext *ctx = VAR_0->priv_data;
DVBSubRegionDisplay *display;
DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;
const uint8_t *VAR_5 = VAR_1 + VAR_2;
int VAR_6;
int VAR_7;
int VAR_8;
int VAR_9;
if (VAR_2 < 1)
return AVERROR_INVALIDDATA;
VAR_8 = *VAR_1++;
VAR_9 = ((*VAR_1)>>4) & 15;
VAR_7 = ((*VAR_1++) >> 2) & 3;
if (ctx->VAR_9 == VAR_9) {
return 0;
ctx->time_out = VAR_8;
ctx->VAR_9 = VAR_9;
ff_dlog(VAR_0, "Page time out %ds, state %d\n", ctx->time_out, VAR_7);
if(ctx->compute_edt == 1)
save_subtitle_set(VAR_0, VAR_3, VAR_4);
if (VAR_7 == 1 || VAR_7 == 2) {
delete_regions(ctx);
delete_objects(ctx);
delete_cluts(ctx);
tmp_display_list = ctx->display_list;
ctx->display_list = NULL;
while (VAR_1 + 5 < VAR_5) {
VAR_6 = *VAR_1++;
VAR_1 += 1;
display = tmp_display_list;
tmp_ptr = &tmp_display_list;
tmp_ptr = &display->next;
if (!display) {
display = av_mallocz(sizeof(DVBSubRegionDisplay));
if (!display)
return AVERROR(ENOMEM);
display->VAR_6 = VAR_6;
display->x_pos = AV_RB16(VAR_1);
VAR_1 += 2;
display->y_pos = AV_RB16(VAR_1);
VAR_1 += 2;
*tmp_ptr = display->next;
display->next = ctx->display_list;
ctx->display_list = display;
ff_dlog(VAR_0, "Region %d, (%d,%d)\n", VAR_6, display->x_pos, display->y_pos);
while (tmp_display_list) {
display = tmp_display_list;
tmp_display_list = display->next;
av_freep(&display);
return 0; | [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2, AVSubtitle *VAR_3, int *VAR_4)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"DVBSubRegionDisplay *display;",
"DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;",
"const uint8_t *VAR_5 = VAR_1 + VAR_2;",
"int VAR_6;",
"int VAR_7;",
"int VAR_8;",
"int VAR_9;",
"if (VAR_2 < 1)\nreturn AVERROR_INVALIDDATA;",
"VAR_8 = *VAR_1++;",
"VAR_9 = ((*VAR_1)>>4) & 15;",
"VAR_7 = ((*VAR_1++) >> 2) & 3;",
"if (ctx->VAR_9 == VAR_9) {",
"return 0;",
"ctx->time_out = VAR_8;",
"ctx->VAR_9 = VAR_9;",
"ff_dlog(VAR_0, \"Page time out %ds, state %d\\n\", ctx->time_out, VAR_7);",
"if(ctx->compute_edt == 1)\nsave_subtitle_set(VAR_0, VAR_3, VAR_4);",
"if (VAR_7 == 1 || VAR_7 == 2) {",
"delete_regions(ctx);",
"delete_objects(ctx);",
"delete_cluts(ctx);",
"tmp_display_list = ctx->display_list;",
"ctx->display_list = NULL;",
"while (VAR_1 + 5 < VAR_5) {",
"VAR_6 = *VAR_1++;",
"VAR_1 += 1;",
"display = tmp_display_list;",
"tmp_ptr = &tmp_display_list;",
"tmp_ptr = &display->next;",
"if (!display) {",
"display = av_mallocz(sizeof(DVBSubRegionDisplay));",
"if (!display)\nreturn AVERROR(ENOMEM);",
"display->VAR_6 = VAR_6;",
"display->x_pos = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"display->y_pos = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"*tmp_ptr = display->next;",
"display->next = ctx->display_list;",
"ctx->display_list = display;",
"ff_dlog(VAR_0, \"Region %d, (%d,%d)\\n\", VAR_6, display->x_pos, display->y_pos);",
"while (tmp_display_list) {",
"display = tmp_display_list;",
"tmp_display_list = display->next;",
"av_freep(&display);",
"return 0;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
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
]
] |
23,342 | static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
void *last, void *dst, int last2, int w,
int stride, int comp, int bits)
{
int i, x = 0;
int Ra, Rb, Rc, Rd;
int D0, D1, D2;
while (x < w) {
int err, pred;
/* compute gradients */
Ra = x ? R(dst, x - stride) : R(last, x);
Rb = R(last, x);
Rc = x ? R(last, x - stride) : last2;
Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
D0 = Rd - Rb;
D1 = Rb - Rc;
D2 = Rc - Ra;
/* run mode */
if ((FFABS(D0) <= state->near) &&
(FFABS(D1) <= state->near) &&
(FFABS(D2) <= state->near)) {
int r;
int RItype;
/* decode full runs while available */
while (get_bits1(&s->gb)) {
int r;
r = 1 << ff_log2_run[state->run_index[comp]];
if (x + r * stride > w)
r = (w - x) / stride;
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
/* if EOL reached, we stop decoding */
if (r != 1 << ff_log2_run[state->run_index[comp]])
if (state->run_index[comp] < 31)
state->run_index[comp]++;
if (x + stride > w)
}
/* decode aborted run */
r = ff_log2_run[state->run_index[comp]];
if (r)
r = get_bits_long(&s->gb, r);
if (x + r * stride > w) {
r = (w - x) / stride;
}
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (x >= w) {
av_log(NULL, AV_LOG_ERROR, "run overflow\n");
av_assert0(x <= w);
}
/* decode run termination value */
Rb = R(last, x);
RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
err = ls_get_code_runterm(&s->gb, state, RItype,
ff_log2_run[state->run_index[comp]]);
if (state->run_index[comp])
state->run_index[comp]--;
if (state->near && RItype) {
pred = Ra + err;
} else {
if (Rb < Ra)
pred = Rb - err;
else
pred = Rb + err;
}
} else { /* regular mode */
int context, sign;
context = ff_jpegls_quantize(state, D0) * 81 +
ff_jpegls_quantize(state, D1) * 9 +
ff_jpegls_quantize(state, D2);
pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
if (context < 0) {
context = -context;
sign = 1;
} else {
sign = 0;
}
if (sign) {
pred = av_clip(pred - state->C[context], 0, state->maxval);
err = -ls_get_code_regular(&s->gb, state, context);
} else {
pred = av_clip(pred + state->C[context], 0, state->maxval);
err = ls_get_code_regular(&s->gb, state, context);
}
/* we have to do something more for near-lossless coding */
pred += err;
}
if (state->near) {
if (pred < -state->near)
pred += state->range * state->twonear;
else if (pred > state->maxval + state->near)
pred -= state->range * state->twonear;
pred = av_clip(pred, 0, state->maxval);
}
pred &= state->maxval;
W(dst, x, pred);
x += stride;
}
} | true | FFmpeg | f80224ed19a4c012549fd460d529c7c04e68cf21 | static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
void *last, void *dst, int last2, int w,
int stride, int comp, int bits)
{
int i, x = 0;
int Ra, Rb, Rc, Rd;
int D0, D1, D2;
while (x < w) {
int err, pred;
Ra = x ? R(dst, x - stride) : R(last, x);
Rb = R(last, x);
Rc = x ? R(last, x - stride) : last2;
Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
D0 = Rd - Rb;
D1 = Rb - Rc;
D2 = Rc - Ra;
if ((FFABS(D0) <= state->near) &&
(FFABS(D1) <= state->near) &&
(FFABS(D2) <= state->near)) {
int r;
int RItype;
while (get_bits1(&s->gb)) {
int r;
r = 1 << ff_log2_run[state->run_index[comp]];
if (x + r * stride > w)
r = (w - x) / stride;
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (r != 1 << ff_log2_run[state->run_index[comp]])
if (state->run_index[comp] < 31)
state->run_index[comp]++;
if (x + stride > w)
}
r = ff_log2_run[state->run_index[comp]];
if (r)
r = get_bits_long(&s->gb, r);
if (x + r * stride > w) {
r = (w - x) / stride;
}
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (x >= w) {
av_log(NULL, AV_LOG_ERROR, "run overflow\n");
av_assert0(x <= w);
}
Rb = R(last, x);
RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
err = ls_get_code_runterm(&s->gb, state, RItype,
ff_log2_run[state->run_index[comp]]);
if (state->run_index[comp])
state->run_index[comp]--;
if (state->near && RItype) {
pred = Ra + err;
} else {
if (Rb < Ra)
pred = Rb - err;
else
pred = Rb + err;
}
} else {
int context, sign;
context = ff_jpegls_quantize(state, D0) * 81 +
ff_jpegls_quantize(state, D1) * 9 +
ff_jpegls_quantize(state, D2);
pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
if (context < 0) {
context = -context;
sign = 1;
} else {
sign = 0;
}
if (sign) {
pred = av_clip(pred - state->C[context], 0, state->maxval);
err = -ls_get_code_regular(&s->gb, state, context);
} else {
pred = av_clip(pred + state->C[context], 0, state->maxval);
err = ls_get_code_regular(&s->gb, state, context);
}
pred += err;
}
if (state->near) {
if (pred < -state->near)
pred += state->range * state->twonear;
else if (pred > state->maxval + state->near)
pred -= state->range * state->twonear;
pred = av_clip(pred, 0, state->maxval);
}
pred &= state->maxval;
W(dst, x, pred);
x += stride;
}
} | {
"code": [],
"line_no": []
} | static inline void FUNC_0(JLSState *VAR_0, MJpegDecodeContext *VAR_1,
void *VAR_2, void *VAR_3, int VAR_4, int VAR_5,
int VAR_6, int VAR_7, int VAR_8)
{
int VAR_9, VAR_10 = 0;
int VAR_11, VAR_12, VAR_13, VAR_14;
int VAR_15, VAR_16, VAR_17;
while (VAR_10 < VAR_5) {
int VAR_18, VAR_19;
VAR_11 = VAR_10 ? R(VAR_3, VAR_10 - VAR_6) : R(VAR_2, VAR_10);
VAR_12 = R(VAR_2, VAR_10);
VAR_13 = VAR_10 ? R(VAR_2, VAR_10 - VAR_6) : VAR_4;
VAR_14 = (VAR_10 >= VAR_5 - VAR_6) ? R(VAR_2, VAR_10) : R(VAR_2, VAR_10 + VAR_6);
VAR_15 = VAR_14 - VAR_12;
VAR_16 = VAR_12 - VAR_13;
VAR_17 = VAR_13 - VAR_11;
if ((FFABS(VAR_15) <= VAR_0->near) &&
(FFABS(VAR_16) <= VAR_0->near) &&
(FFABS(VAR_17) <= VAR_0->near)) {
int VAR_22;
int VAR_21;
while (get_bits1(&VAR_1->gb)) {
int VAR_22;
VAR_22 = 1 << ff_log2_run[VAR_0->run_index[VAR_7]];
if (VAR_10 + VAR_22 * VAR_6 > VAR_5)
VAR_22 = (VAR_5 - VAR_10) / VAR_6;
for (VAR_9 = 0; VAR_9 < VAR_22; VAR_9++) {
W(VAR_3, VAR_10, VAR_11);
VAR_10 += VAR_6;
}
if (VAR_22 != 1 << ff_log2_run[VAR_0->run_index[VAR_7]])
if (VAR_0->run_index[VAR_7] < 31)
VAR_0->run_index[VAR_7]++;
if (VAR_10 + VAR_6 > VAR_5)
}
VAR_22 = ff_log2_run[VAR_0->run_index[VAR_7]];
if (VAR_22)
VAR_22 = get_bits_long(&VAR_1->gb, VAR_22);
if (VAR_10 + VAR_22 * VAR_6 > VAR_5) {
VAR_22 = (VAR_5 - VAR_10) / VAR_6;
}
for (VAR_9 = 0; VAR_9 < VAR_22; VAR_9++) {
W(VAR_3, VAR_10, VAR_11);
VAR_10 += VAR_6;
}
if (VAR_10 >= VAR_5) {
av_log(NULL, AV_LOG_ERROR, "run overflow\n");
av_assert0(VAR_10 <= VAR_5);
}
VAR_12 = R(VAR_2, VAR_10);
VAR_21 = (FFABS(VAR_11 - VAR_12) <= VAR_0->near) ? 1 : 0;
VAR_18 = ls_get_code_runterm(&VAR_1->gb, VAR_0, VAR_21,
ff_log2_run[VAR_0->run_index[VAR_7]]);
if (VAR_0->run_index[VAR_7])
VAR_0->run_index[VAR_7]--;
if (VAR_0->near && VAR_21) {
VAR_19 = VAR_11 + VAR_18;
} else {
if (VAR_12 < VAR_11)
VAR_19 = VAR_12 - VAR_18;
else
VAR_19 = VAR_12 + VAR_18;
}
} else {
int VAR_22, VAR_23;
VAR_22 = ff_jpegls_quantize(VAR_0, VAR_15) * 81 +
ff_jpegls_quantize(VAR_0, VAR_16) * 9 +
ff_jpegls_quantize(VAR_0, VAR_17);
VAR_19 = mid_pred(VAR_11, VAR_11 + VAR_12 - VAR_13, VAR_12);
if (VAR_22 < 0) {
VAR_22 = -VAR_22;
VAR_23 = 1;
} else {
VAR_23 = 0;
}
if (VAR_23) {
VAR_19 = av_clip(VAR_19 - VAR_0->C[VAR_22], 0, VAR_0->maxval);
VAR_18 = -ls_get_code_regular(&VAR_1->gb, VAR_0, VAR_22);
} else {
VAR_19 = av_clip(VAR_19 + VAR_0->C[VAR_22], 0, VAR_0->maxval);
VAR_18 = ls_get_code_regular(&VAR_1->gb, VAR_0, VAR_22);
}
VAR_19 += VAR_18;
}
if (VAR_0->near) {
if (VAR_19 < -VAR_0->near)
VAR_19 += VAR_0->range * VAR_0->twonear;
else if (VAR_19 > VAR_0->maxval + VAR_0->near)
VAR_19 -= VAR_0->range * VAR_0->twonear;
VAR_19 = av_clip(VAR_19, 0, VAR_0->maxval);
}
VAR_19 &= VAR_0->maxval;
W(VAR_3, VAR_10, VAR_19);
VAR_10 += VAR_6;
}
} | [
"static inline void FUNC_0(JLSState *VAR_0, MJpegDecodeContext *VAR_1,\nvoid *VAR_2, void *VAR_3, int VAR_4, int VAR_5,\nint VAR_6, int VAR_7, int VAR_8)\n{",
"int VAR_9, VAR_10 = 0;",
"int VAR_11, VAR_12, VAR_13, VAR_14;",
"int VAR_15, VAR_16, VAR_17;",
"while (VAR_10 < VAR_5) {",
"int VAR_18, VAR_19;",
"VAR_11 = VAR_10 ? R(VAR_3, VAR_10 - VAR_6) : R(VAR_2, VAR_10);",
"VAR_12 = R(VAR_2, VAR_10);",
"VAR_13 = VAR_10 ? R(VAR_2, VAR_10 - VAR_6) : VAR_4;",
"VAR_14 = (VAR_10 >= VAR_5 - VAR_6) ? R(VAR_2, VAR_10) : R(VAR_2, VAR_10 + VAR_6);",
"VAR_15 = VAR_14 - VAR_12;",
"VAR_16 = VAR_12 - VAR_13;",
"VAR_17 = VAR_13 - VAR_11;",
"if ((FFABS(VAR_15) <= VAR_0->near) &&\n(FFABS(VAR_16) <= VAR_0->near) &&\n(FFABS(VAR_17) <= VAR_0->near)) {",
"int VAR_22;",
"int VAR_21;",
"while (get_bits1(&VAR_1->gb)) {",
"int VAR_22;",
"VAR_22 = 1 << ff_log2_run[VAR_0->run_index[VAR_7]];",
"if (VAR_10 + VAR_22 * VAR_6 > VAR_5)\nVAR_22 = (VAR_5 - VAR_10) / VAR_6;",
"for (VAR_9 = 0; VAR_9 < VAR_22; VAR_9++) {",
"W(VAR_3, VAR_10, VAR_11);",
"VAR_10 += VAR_6;",
"}",
"if (VAR_22 != 1 << ff_log2_run[VAR_0->run_index[VAR_7]])\nif (VAR_0->run_index[VAR_7] < 31)\nVAR_0->run_index[VAR_7]++;",
"if (VAR_10 + VAR_6 > VAR_5)\n}",
"VAR_22 = ff_log2_run[VAR_0->run_index[VAR_7]];",
"if (VAR_22)\nVAR_22 = get_bits_long(&VAR_1->gb, VAR_22);",
"if (VAR_10 + VAR_22 * VAR_6 > VAR_5) {",
"VAR_22 = (VAR_5 - VAR_10) / VAR_6;",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_22; VAR_9++) {",
"W(VAR_3, VAR_10, VAR_11);",
"VAR_10 += VAR_6;",
"}",
"if (VAR_10 >= VAR_5) {",
"av_log(NULL, AV_LOG_ERROR, \"run overflow\\n\");",
"av_assert0(VAR_10 <= VAR_5);",
"}",
"VAR_12 = R(VAR_2, VAR_10);",
"VAR_21 = (FFABS(VAR_11 - VAR_12) <= VAR_0->near) ? 1 : 0;",
"VAR_18 = ls_get_code_runterm(&VAR_1->gb, VAR_0, VAR_21,\nff_log2_run[VAR_0->run_index[VAR_7]]);",
"if (VAR_0->run_index[VAR_7])\nVAR_0->run_index[VAR_7]--;",
"if (VAR_0->near && VAR_21) {",
"VAR_19 = VAR_11 + VAR_18;",
"} else {",
"if (VAR_12 < VAR_11)\nVAR_19 = VAR_12 - VAR_18;",
"else\nVAR_19 = VAR_12 + VAR_18;",
"}",
"} else {",
"int VAR_22, VAR_23;",
"VAR_22 = ff_jpegls_quantize(VAR_0, VAR_15) * 81 +\nff_jpegls_quantize(VAR_0, VAR_16) * 9 +\nff_jpegls_quantize(VAR_0, VAR_17);",
"VAR_19 = mid_pred(VAR_11, VAR_11 + VAR_12 - VAR_13, VAR_12);",
"if (VAR_22 < 0) {",
"VAR_22 = -VAR_22;",
"VAR_23 = 1;",
"} else {",
"VAR_23 = 0;",
"}",
"if (VAR_23) {",
"VAR_19 = av_clip(VAR_19 - VAR_0->C[VAR_22], 0, VAR_0->maxval);",
"VAR_18 = -ls_get_code_regular(&VAR_1->gb, VAR_0, VAR_22);",
"} else {",
"VAR_19 = av_clip(VAR_19 + VAR_0->C[VAR_22], 0, VAR_0->maxval);",
"VAR_18 = ls_get_code_regular(&VAR_1->gb, VAR_0, VAR_22);",
"}",
"VAR_19 += VAR_18;",
"}",
"if (VAR_0->near) {",
"if (VAR_19 < -VAR_0->near)\nVAR_19 += VAR_0->range * VAR_0->twonear;",
"else if (VAR_19 > VAR_0->maxval + VAR_0->near)\nVAR_19 -= VAR_0->range * VAR_0->twonear;",
"VAR_19 = av_clip(VAR_19, 0, VAR_0->maxval);",
"}",
"VAR_19 &= VAR_0->maxval;",
"W(VAR_3, VAR_10, VAR_19);",
"VAR_10 += 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
19,
20,
21
],
[
22
],
[
23
],
[
25
],
[
26
],
[
27
],
[
28,
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
35,
36,
37
],
[
38,
39
],
[
41
],
[
42,
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
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
],
[
90
],
[
91
],
[
92
],
[
93,
94
],
[
95,
96
],
[
97
],
[
98
],
[
99
],
[
100
],
[
101
],
[
102
],
[
103
]
] |
23,343 | static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
int got_picture = 0;
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
got_picture = 1;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
got_picture = 1;
}
if (got_picture)
ff_print_debug_info(s, pict);
return got_picture;
} | true | FFmpeg | 5484170ac729d739b2747979408f47bd9aa31c7c | static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
int got_picture = 0;
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
got_picture = 1;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
got_picture = 1;
}
if (got_picture)
ff_print_debug_info(s, pict);
return got_picture;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)
{
RV34DecContext *r = VAR_0->priv_data;
MpegEncContext *s = &r->s;
int VAR_2 = 0;
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (HAVE_THREADS && (s->VAR_0->active_thread_type & FF_THREAD_FRAME))
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*VAR_1 = s->current_picture_ptr->f;
VAR_2 = 1;
} else if (s->last_picture_ptr != NULL) {
*VAR_1 = s->last_picture_ptr->f;
VAR_2 = 1;
}
if (VAR_2)
ff_print_debug_info(s, VAR_1);
return VAR_2;
} | [
"static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{",
"RV34DecContext *r = VAR_0->priv_data;",
"MpegEncContext *s = &r->s;",
"int VAR_2 = 0;",
"ff_er_frame_end(s);",
"ff_MPV_frame_end(s);",
"if (HAVE_THREADS && (s->VAR_0->active_thread_type & FF_THREAD_FRAME))\nff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);",
"if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {",
"*VAR_1 = s->current_picture_ptr->f;",
"VAR_2 = 1;",
"} else if (s->last_picture_ptr != NULL) {",
"*VAR_1 = s->last_picture_ptr->f;",
"VAR_2 = 1;",
"}",
"if (VAR_2)\nff_print_debug_info(s, VAR_1);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
20,
22
],
[
26
],
[
28
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40,
42
],
[
46
],
[
48
]
] |
23,345 | static int s337m_probe(AVProbeData *p)
{
uint64_t state = 0;
int markers[3] = { 0 };
int i, sum, max, data_type, data_size, offset;
uint8_t *buf;
for (buf = p->buf; buf < p->buf + p->buf_size; buf++) {
state = (state << 8) | *buf;
if (!IS_LE_MARKER(state))
continue;
if (IS_16LE_MARKER(state)) {
data_type = AV_RL16(buf + 1);
data_size = AV_RL16(buf + 3);
buf += 4;
} else {
data_type = AV_RL24(buf + 1);
data_size = AV_RL24(buf + 4);
buf += 6;
}
if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL))
continue;
i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
markers[i]++;
buf += offset;
state = 0;
}
sum = max = 0;
for (i = 0; i < FF_ARRAY_ELEMS(markers); i++) {
sum += markers[i];
if (markers[max] < markers[i])
max = i;
}
if (markers[max] > 3 && markers[max] * 4 > sum * 3)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| false | FFmpeg | 6029b8a6bbc8bbf7799108582e71078ec0bde1cf | static int s337m_probe(AVProbeData *p)
{
uint64_t state = 0;
int markers[3] = { 0 };
int i, sum, max, data_type, data_size, offset;
uint8_t *buf;
for (buf = p->buf; buf < p->buf + p->buf_size; buf++) {
state = (state << 8) | *buf;
if (!IS_LE_MARKER(state))
continue;
if (IS_16LE_MARKER(state)) {
data_type = AV_RL16(buf + 1);
data_size = AV_RL16(buf + 3);
buf += 4;
} else {
data_type = AV_RL24(buf + 1);
data_size = AV_RL24(buf + 4);
buf += 6;
}
if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL))
continue;
i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
markers[i]++;
buf += offset;
state = 0;
}
sum = max = 0;
for (i = 0; i < FF_ARRAY_ELEMS(markers); i++) {
sum += markers[i];
if (markers[max] < markers[i])
max = i;
}
if (markers[max] > 3 && markers[max] * 4 > sum * 3)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
uint64_t state = 0;
int VAR_1[3] = { 0 };
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
uint8_t *buf;
for (buf = VAR_0->buf; buf < VAR_0->buf + VAR_0->buf_size; buf++) {
state = (state << 8) | *buf;
if (!IS_LE_MARKER(state))
continue;
if (IS_16LE_MARKER(state)) {
VAR_5 = AV_RL16(buf + 1);
VAR_6 = AV_RL16(buf + 3);
buf += 4;
} else {
VAR_5 = AV_RL24(buf + 1);
VAR_6 = AV_RL24(buf + 4);
buf += 6;
}
if (s337m_get_offset_and_codec(NULL, state, VAR_5, VAR_6, &VAR_7, NULL))
continue;
VAR_2 = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
VAR_1[VAR_2]++;
buf += VAR_7;
state = 0;
}
VAR_3 = VAR_4 = 0;
for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_1); VAR_2++) {
VAR_3 += VAR_1[VAR_2];
if (VAR_1[VAR_4] < VAR_1[VAR_2])
VAR_4 = VAR_2;
}
if (VAR_1[VAR_4] > 3 && VAR_1[VAR_4] * 4 > VAR_3 * 3)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"uint64_t state = 0;",
"int VAR_1[3] = { 0 };",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"uint8_t *buf;",
"for (buf = VAR_0->buf; buf < VAR_0->buf + VAR_0->buf_size; buf++) {",
"state = (state << 8) | *buf;",
"if (!IS_LE_MARKER(state))\ncontinue;",
"if (IS_16LE_MARKER(state)) {",
"VAR_5 = AV_RL16(buf + 1);",
"VAR_6 = AV_RL16(buf + 3);",
"buf += 4;",
"} else {",
"VAR_5 = AV_RL24(buf + 1);",
"VAR_6 = AV_RL24(buf + 4);",
"buf += 6;",
"}",
"if (s337m_get_offset_and_codec(NULL, state, VAR_5, VAR_6, &VAR_7, NULL))\ncontinue;",
"VAR_2 = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;",
"VAR_1[VAR_2]++;",
"buf += VAR_7;",
"state = 0;",
"}",
"VAR_3 = VAR_4 = 0;",
"for (VAR_2 = 0; VAR_2 < FF_ARRAY_ELEMS(VAR_1); VAR_2++) {",
"VAR_3 += VAR_1[VAR_2];",
"if (VAR_1[VAR_4] < VAR_1[VAR_2])\nVAR_4 = VAR_2;",
"}",
"if (VAR_1[VAR_4] > 3 && VAR_1[VAR_4] * 4 > VAR_3 * 3)\nreturn AVPROBE_SCORE_EXTENSION + 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
79,
81
],
[
85
],
[
87
]
] |
23,346 | static inline void RENAME(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat)
{
yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat)
{
yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat)
{
yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
| [
"static inline void FUNC_0(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,\nconst int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,\nuint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat)\n{",
"yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,\nchrFilter, chrSrc, chrFilterSize,\ndest, uDest, dstW, chrDstW, dstFormat);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11,
13
],
[
15
]
] |
23,347 | static int usb_bt_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret;
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
if (ret >= 0) {
switch (request) {
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
s->config = 0;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
s->config = 1;
usb_bt_fifo_reset(&s->evt);
usb_bt_fifo_reset(&s->acl);
usb_bt_fifo_reset(&s->sco);
break;
}
return ret;
}
ret = 0;
switch (request) {
case InterfaceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
data[0] = 0x00;
data[1] = 0x00;
ret = 2;
break;
case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
goto fail;
case InterfaceOutRequest | USB_REQ_SET_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
goto fail;
break;
case InterfaceRequest | USB_REQ_GET_INTERFACE:
if (value != 0 || (index & ~1) || length != 1)
goto fail;
if (index == 1)
data[0] = s->altsetting;
else
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
if ((index & ~1) || length != 0 ||
(index == 1 && (value < 0 || value > 4)) ||
(index == 0 && value != 0)) {
printf("%s: Wrong SET_INTERFACE request (%i, %i)\n",
__FUNCTION__, index, value);
goto fail;
}
s->altsetting = value;
ret = 0;
break;
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):
if (s->config)
usb_bt_fifo_out_enqueue(s, &s->outcmd, s->hci->cmd_send,
usb_bt_hci_cmd_complete, data, length);
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| true | qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | static int usb_bt_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret;
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
if (ret >= 0) {
switch (request) {
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
s->config = 0;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
s->config = 1;
usb_bt_fifo_reset(&s->evt);
usb_bt_fifo_reset(&s->acl);
usb_bt_fifo_reset(&s->sco);
break;
}
return ret;
}
ret = 0;
switch (request) {
case InterfaceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
data[0] = 0x00;
data[1] = 0x00;
ret = 2;
break;
case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
goto fail;
case InterfaceOutRequest | USB_REQ_SET_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
goto fail;
break;
case InterfaceRequest | USB_REQ_GET_INTERFACE:
if (value != 0 || (index & ~1) || length != 1)
goto fail;
if (index == 1)
data[0] = s->altsetting;
else
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
if ((index & ~1) || length != 0 ||
(index == 1 && (value < 0 || value > 4)) ||
(index == 0 && value != 0)) {
printf("%s: Wrong SET_INTERFACE request (%i, %i)\n",
__FUNCTION__, index, value);
goto fail;
}
s->altsetting = value;
ret = 0;
break;
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):
if (s->config)
usb_bt_fifo_out_enqueue(s, &s->outcmd, s->hci->cmd_send,
usb_bt_hci_cmd_complete, data, length);
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [
" usb_bt_hci_cmd_complete, data, length);"
],
"line_no": [
121
]
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5, uint8_t *VAR_6)
{
struct USBBtState *VAR_7 = (struct USBBtState *) VAR_0->opaque;
int VAR_8;
VAR_8 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6);
if (VAR_8 >= 0) {
switch (VAR_2) {
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
VAR_7->config = 0;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
VAR_7->config = 1;
usb_bt_fifo_reset(&VAR_7->evt);
usb_bt_fifo_reset(&VAR_7->acl);
usb_bt_fifo_reset(&VAR_7->sco);
break;
}
return VAR_8;
}
VAR_8 = 0;
switch (VAR_2) {
case InterfaceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
VAR_6[0] = 0x00;
VAR_6[1] = 0x00;
VAR_8 = 2;
break;
case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
goto fail;
case InterfaceOutRequest | USB_REQ_SET_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
goto fail;
break;
case InterfaceRequest | USB_REQ_GET_INTERFACE:
if (VAR_3 != 0 || (VAR_4 & ~1) || VAR_5 != 1)
goto fail;
if (VAR_4 == 1)
VAR_6[0] = VAR_7->altsetting;
else
VAR_6[0] = 0;
VAR_8 = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
if ((VAR_4 & ~1) || VAR_5 != 0 ||
(VAR_4 == 1 && (VAR_3 < 0 || VAR_3 > 4)) ||
(VAR_4 == 0 && VAR_3 != 0)) {
printf("%VAR_7: Wrong SET_INTERFACE VAR_2 (%i, %i)\n",
__FUNCTION__, VAR_4, VAR_3);
goto fail;
}
VAR_7->altsetting = VAR_3;
VAR_8 = 0;
break;
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):
if (VAR_7->config)
usb_bt_fifo_out_enqueue(VAR_7, &VAR_7->outcmd, VAR_7->hci->cmd_send,
usb_bt_hci_cmd_complete, VAR_6, VAR_5);
break;
default:
fail:
VAR_8 = USB_RET_STALL;
break;
}
return VAR_8;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1,\nint VAR_2, int VAR_3, int VAR_4, int VAR_5, uint8_t *VAR_6)\n{",
"struct USBBtState *VAR_7 = (struct USBBtState *) VAR_0->opaque;",
"int VAR_8;",
"VAR_8 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6);",
"if (VAR_8 >= 0) {",
"switch (VAR_2) {",
"case DeviceRequest | USB_REQ_GET_CONFIGURATION:\nVAR_7->config = 0;",
"break;",
"case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:\nVAR_7->config = 1;",
"usb_bt_fifo_reset(&VAR_7->evt);",
"usb_bt_fifo_reset(&VAR_7->acl);",
"usb_bt_fifo_reset(&VAR_7->sco);",
"break;",
"}",
"return VAR_8;",
"}",
"VAR_8 = 0;",
"switch (VAR_2) {",
"case InterfaceRequest | USB_REQ_GET_STATUS:\ncase EndpointRequest | USB_REQ_GET_STATUS:\nVAR_6[0] = 0x00;",
"VAR_6[1] = 0x00;",
"VAR_8 = 2;",
"break;",
"case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:\ncase EndpointOutRequest | USB_REQ_CLEAR_FEATURE:\ngoto fail;",
"case InterfaceOutRequest | USB_REQ_SET_FEATURE:\ncase EndpointOutRequest | USB_REQ_SET_FEATURE:\ngoto fail;",
"break;",
"case InterfaceRequest | USB_REQ_GET_INTERFACE:\nif (VAR_3 != 0 || (VAR_4 & ~1) || VAR_5 != 1)\ngoto fail;",
"if (VAR_4 == 1)\nVAR_6[0] = VAR_7->altsetting;",
"else\nVAR_6[0] = 0;",
"VAR_8 = 1;",
"break;",
"case InterfaceOutRequest | USB_REQ_SET_INTERFACE:\nif ((VAR_4 & ~1) || VAR_5 != 0 ||\n(VAR_4 == 1 && (VAR_3 < 0 || VAR_3 > 4)) ||\n(VAR_4 == 0 && VAR_3 != 0)) {",
"printf(\"%VAR_7: Wrong SET_INTERFACE VAR_2 (%i, %i)\\n\",\n__FUNCTION__, VAR_4, VAR_3);",
"goto fail;",
"}",
"VAR_7->altsetting = VAR_3;",
"VAR_8 = 0;",
"break;",
"case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):\nif (VAR_7->config)\nusb_bt_fifo_out_enqueue(VAR_7, &VAR_7->outcmd, VAR_7->hci->cmd_send,\nusb_bt_hci_cmd_complete, VAR_6, VAR_5);",
"break;",
"default:\nfail:\nVAR_8 = USB_RET_STALL;",
"break;",
"}",
"return VAR_8;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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,
53
],
[
55
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67,
69,
71
],
[
73
],
[
75,
77,
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91
],
[
93,
95,
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117,
119,
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
]
] |
23,348 | int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
if (!(picref = ctx->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
frame->pict_type = picref->video->pict_type;
frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
} | true | FFmpeg | 0d65e0f8cb0f924be95650f50f3d05d0b223aceb | int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
if (!(picref = ctx->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
frame->pict_type = picref->video->pict_type;
frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
} | {
"code": [],
"line_no": []
} | int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1,
AVFilterBufferRef **VAR_2, AVRational *VAR_3)
{
int VAR_4;
AVFilterBufferRef *picref;
if ((VAR_4 = avfilter_request_frame(VAR_0->inputs[0])) < 0)
return VAR_4;
if (!(picref = VAR_0->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*VAR_2 = picref;
VAR_0->inputs[0]->cur_buf = NULL;
*VAR_3 = VAR_0->inputs[0]->time_base;
memcpy(VAR_1->data, picref->data, sizeof(VAR_1->data));
memcpy(VAR_1->linesize, picref->linesize, sizeof(VAR_1->linesize));
VAR_1->pkt_pos = picref->pos;
VAR_1->interlaced_frame = picref->video->interlaced;
VAR_1->top_field_first = picref->video->top_field_first;
VAR_1->key_frame = picref->video->key_frame;
VAR_1->pict_type = picref->video->pict_type;
VAR_1->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
} | [
"int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1,\nAVFilterBufferRef **VAR_2, AVRational *VAR_3)\n{",
"int VAR_4;",
"AVFilterBufferRef *picref;",
"if ((VAR_4 = avfilter_request_frame(VAR_0->inputs[0])) < 0)\nreturn VAR_4;",
"if (!(picref = VAR_0->inputs[0]->cur_buf))\nreturn AVERROR(ENOENT);",
"*VAR_2 = picref;",
"VAR_0->inputs[0]->cur_buf = NULL;",
"*VAR_3 = VAR_0->inputs[0]->time_base;",
"memcpy(VAR_1->data, picref->data, sizeof(VAR_1->data));",
"memcpy(VAR_1->linesize, picref->linesize, sizeof(VAR_1->linesize));",
"VAR_1->pkt_pos = picref->pos;",
"VAR_1->interlaced_frame = picref->video->interlaced;",
"VAR_1->top_field_first = picref->video->top_field_first;",
"VAR_1->key_frame = picref->video->key_frame;",
"VAR_1->pict_type = picref->video->pict_type;",
"VAR_1->sample_aspect_ratio = picref->video->sample_aspect_ratio;",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
14,
16
],
[
18,
20
],
[
22
],
[
24
],
[
26
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
48
],
[
50
]
] |
23,349 | static int vmxnet3_post_load(void *opaque, int version_id)
{
VMXNET3State *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);
vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
if (s->msix_used) {
if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
VMW_WRPRN("Failed to re-use MSI-X vectors");
msix_uninit(d, &s->msix_bar, &s->msix_bar);
s->msix_used = false;
return -1;
}
}
return 0;
} | true | qemu | 3c99afc779c2c78718a565ad8c5e98de7c2c7484 | static int vmxnet3_post_load(void *opaque, int version_id)
{
VMXNET3State *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);
vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
if (s->msix_used) {
if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
VMW_WRPRN("Failed to re-use MSI-X vectors");
msix_uninit(d, &s->msix_bar, &s->msix_bar);
s->msix_used = false;
return -1;
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
VMXNET3State *s = VAR_0;
PCIDevice *d = PCI_DEVICE(s);
vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);
vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
if (s->msix_used) {
if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
VMW_WRPRN("Failed to re-use MSI-X vectors");
msix_uninit(d, &s->msix_bar, &s->msix_bar);
s->msix_used = false;
return -1;
}
}
return 0;
} | [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"VMXNET3State *s = VAR_0;",
"PCIDevice *d = PCI_DEVICE(s);",
"vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);",
"vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);",
"if (s->msix_used) {",
"if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {",
"VMW_WRPRN(\"Failed to re-use MSI-X vectors\");",
"msix_uninit(d, &s->msix_bar, &s->msix_bar);",
"s->msix_used = false;",
"return -1;",
"}",
"}",
"return 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
]
] |
23,350 | static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
int qsel, int is_chroma, int is_hqa)
{
const int32_t *q;
int val, pos = 1;
memset(block, 0, 64 * sizeof(*block));
if (!is_hqa) {
block[0] = get_sbits(gb, 9) * 64;
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
} else {
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
block[0] = get_sbits(gb, 9) * 64;
}
for (;;) {
val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);
if (val < 0)
return AVERROR_INVALIDDATA;
pos += ff_hq_ac_skips[val];
if (pos >= 64)
break;
block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12;
pos++;
}
return 0;
}
| true | FFmpeg | 3d9cb583c8f005a260d255853ef5f1c21e8599a0 | static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
int qsel, int is_chroma, int is_hqa)
{
const int32_t *q;
int val, pos = 1;
memset(block, 0, 64 * sizeof(*block));
if (!is_hqa) {
block[0] = get_sbits(gb, 9) * 64;
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
} else {
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
block[0] = get_sbits(gb, 9) * 64;
}
for (;;) {
val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);
if (val < 0)
return AVERROR_INVALIDDATA;
pos += ff_hq_ac_skips[val];
if (pos >= 64)
break;
block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12;
pos++;
}
return 0;
}
| {
"code": [
" block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12;"
],
"line_no": [
49
]
} | static int FUNC_0(HQContext *VAR_0, GetBitContext *VAR_1, int16_t VAR_2[64],
int VAR_3, int VAR_4, int VAR_5)
{
const int32_t *VAR_6;
int VAR_7, VAR_8 = 1;
memset(VAR_2, 0, 64 * sizeof(*VAR_2));
if (!VAR_5) {
VAR_2[0] = get_sbits(VAR_1, 9) * 64;
VAR_6 = ff_hq_quants[VAR_3][VAR_4][get_bits(VAR_1, 2)];
} else {
VAR_6 = ff_hq_quants[VAR_3][VAR_4][get_bits(VAR_1, 2)];
VAR_2[0] = get_sbits(VAR_1, 9) * 64;
}
for (;;) {
VAR_7 = get_vlc2(VAR_1, VAR_0->hq_ac_vlc.table, 9, 2);
if (VAR_7 < 0)
return AVERROR_INVALIDDATA;
VAR_8 += ff_hq_ac_skips[VAR_7];
if (VAR_8 >= 64)
break;
VAR_2[ff_zigzag_direct[VAR_8]] = (ff_hq_ac_syms[VAR_7] * VAR_6[VAR_8]) >> 12;
VAR_8++;
}
return 0;
}
| [
"static int FUNC_0(HQContext *VAR_0, GetBitContext *VAR_1, int16_t VAR_2[64],\nint VAR_3, int VAR_4, int VAR_5)\n{",
"const int32_t *VAR_6;",
"int VAR_7, VAR_8 = 1;",
"memset(VAR_2, 0, 64 * sizeof(*VAR_2));",
"if (!VAR_5) {",
"VAR_2[0] = get_sbits(VAR_1, 9) * 64;",
"VAR_6 = ff_hq_quants[VAR_3][VAR_4][get_bits(VAR_1, 2)];",
"} else {",
"VAR_6 = ff_hq_quants[VAR_3][VAR_4][get_bits(VAR_1, 2)];",
"VAR_2[0] = get_sbits(VAR_1, 9) * 64;",
"}",
"for (;;) {",
"VAR_7 = get_vlc2(VAR_1, VAR_0->hq_ac_vlc.table, 9, 2);",
"if (VAR_7 < 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_8 += ff_hq_ac_skips[VAR_7];",
"if (VAR_8 >= 64)\nbreak;",
"VAR_2[ff_zigzag_direct[VAR_8]] = (ff_hq_ac_syms[VAR_7] * VAR_6[VAR_8]) >> 12;",
"VAR_8++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
23,351 | void dsputil_init_alpha(void)
{
put_pixels_tab[0][0] = put_pixels16_axp_asm;
put_pixels_tab[0][1] = put_pixels16_x2_axp;
put_pixels_tab[0][2] = put_pixels16_y2_axp;
put_pixels_tab[0][3] = put_pixels16_xy2_axp;
put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
avg_pixels_tab[0][0] = avg_pixels16_axp;
avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
put_pixels_tab[1][0] = put_pixels_axp_asm;
put_pixels_tab[1][1] = put_pixels_x2_axp;
put_pixels_tab[1][2] = put_pixels_y2_axp;
put_pixels_tab[1][3] = put_pixels_xy2_axp;
put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
avg_pixels_tab[1][0] = avg_pixels_axp;
avg_pixels_tab[1][1] = avg_pixels_x2_axp;
avg_pixels_tab[1][2] = avg_pixels_y2_axp;
avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
clear_blocks = clear_blocks_axp;
/* amask clears all bits that correspond to present features. */
if (amask(AMASK_MVI) == 0) {
put_pixels_clamped = put_pixels_clamped_mvi_asm;
add_pixels_clamped = add_pixels_clamped_mvi_asm;
get_pixels = get_pixels_mvi;
diff_pixels = diff_pixels_mvi;
pix_abs8x8 = pix_abs8x8_mvi;
pix_abs16x16 = pix_abs16x16_mvi_asm;
pix_abs16x16_x2 = pix_abs16x16_x2_mvi;
pix_abs16x16_y2 = pix_abs16x16_y2_mvi;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;
}
}
| false | FFmpeg | af19f78f2fe2b969104d4419efd25fdee90a2814 | void dsputil_init_alpha(void)
{
put_pixels_tab[0][0] = put_pixels16_axp_asm;
put_pixels_tab[0][1] = put_pixels16_x2_axp;
put_pixels_tab[0][2] = put_pixels16_y2_axp;
put_pixels_tab[0][3] = put_pixels16_xy2_axp;
put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
avg_pixels_tab[0][0] = avg_pixels16_axp;
avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
put_pixels_tab[1][0] = put_pixels_axp_asm;
put_pixels_tab[1][1] = put_pixels_x2_axp;
put_pixels_tab[1][2] = put_pixels_y2_axp;
put_pixels_tab[1][3] = put_pixels_xy2_axp;
put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
avg_pixels_tab[1][0] = avg_pixels_axp;
avg_pixels_tab[1][1] = avg_pixels_x2_axp;
avg_pixels_tab[1][2] = avg_pixels_y2_axp;
avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
clear_blocks = clear_blocks_axp;
if (amask(AMASK_MVI) == 0) {
put_pixels_clamped = put_pixels_clamped_mvi_asm;
add_pixels_clamped = add_pixels_clamped_mvi_asm;
get_pixels = get_pixels_mvi;
diff_pixels = diff_pixels_mvi;
pix_abs8x8 = pix_abs8x8_mvi;
pix_abs16x16 = pix_abs16x16_mvi_asm;
pix_abs16x16_x2 = pix_abs16x16_x2_mvi;
pix_abs16x16_y2 = pix_abs16x16_y2_mvi;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
put_pixels_tab[0][0] = put_pixels16_axp_asm;
put_pixels_tab[0][1] = put_pixels16_x2_axp;
put_pixels_tab[0][2] = put_pixels16_y2_axp;
put_pixels_tab[0][3] = put_pixels16_xy2_axp;
put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
avg_pixels_tab[0][0] = avg_pixels16_axp;
avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
put_pixels_tab[1][0] = put_pixels_axp_asm;
put_pixels_tab[1][1] = put_pixels_x2_axp;
put_pixels_tab[1][2] = put_pixels_y2_axp;
put_pixels_tab[1][3] = put_pixels_xy2_axp;
put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
avg_pixels_tab[1][0] = avg_pixels_axp;
avg_pixels_tab[1][1] = avg_pixels_x2_axp;
avg_pixels_tab[1][2] = avg_pixels_y2_axp;
avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
clear_blocks = clear_blocks_axp;
if (amask(AMASK_MVI) == 0) {
put_pixels_clamped = put_pixels_clamped_mvi_asm;
add_pixels_clamped = add_pixels_clamped_mvi_asm;
get_pixels = get_pixels_mvi;
diff_pixels = diff_pixels_mvi;
pix_abs8x8 = pix_abs8x8_mvi;
pix_abs16x16 = pix_abs16x16_mvi_asm;
pix_abs16x16_x2 = pix_abs16x16_x2_mvi;
pix_abs16x16_y2 = pix_abs16x16_y2_mvi;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;
}
}
| [
"void FUNC_0(void)\n{",
"put_pixels_tab[0][0] = put_pixels16_axp_asm;",
"put_pixels_tab[0][1] = put_pixels16_x2_axp;",
"put_pixels_tab[0][2] = put_pixels16_y2_axp;",
"put_pixels_tab[0][3] = put_pixels16_xy2_axp;",
"put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;",
"put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;",
"put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;",
"put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;",
"avg_pixels_tab[0][0] = avg_pixels16_axp;",
"avg_pixels_tab[0][1] = avg_pixels16_x2_axp;",
"avg_pixels_tab[0][2] = avg_pixels16_y2_axp;",
"avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;",
"avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;",
"avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;",
"avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;",
"avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;",
"put_pixels_tab[1][0] = put_pixels_axp_asm;",
"put_pixels_tab[1][1] = put_pixels_x2_axp;",
"put_pixels_tab[1][2] = put_pixels_y2_axp;",
"put_pixels_tab[1][3] = put_pixels_xy2_axp;",
"put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;",
"put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;",
"put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;",
"put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;",
"avg_pixels_tab[1][0] = avg_pixels_axp;",
"avg_pixels_tab[1][1] = avg_pixels_x2_axp;",
"avg_pixels_tab[1][2] = avg_pixels_y2_axp;",
"avg_pixels_tab[1][3] = avg_pixels_xy2_axp;",
"avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;",
"avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;",
"avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;",
"avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;",
"clear_blocks = clear_blocks_axp;",
"if (amask(AMASK_MVI) == 0) {",
"put_pixels_clamped = put_pixels_clamped_mvi_asm;",
"add_pixels_clamped = add_pixels_clamped_mvi_asm;",
"get_pixels = get_pixels_mvi;",
"diff_pixels = diff_pixels_mvi;",
"pix_abs8x8 = pix_abs8x8_mvi;",
"pix_abs16x16 = pix_abs16x16_mvi_asm;",
"pix_abs16x16_x2 = pix_abs16x16_x2_mvi;",
"pix_abs16x16_y2 = pix_abs16x16_y2_mvi;",
"pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
] |
23,352 | address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
hwaddr *xlat, hwaddr *plen)
{
MemoryRegionSection *section;
AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
section = address_space_translate_internal(d, addr, xlat, plen, false);
assert(!section->mr->iommu_ops);
return section;
}
| true | qemu | f35e44e7645edbb08e35b111c10c2fc57e2905c7 | address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
hwaddr *xlat, hwaddr *plen)
{
MemoryRegionSection *section;
AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
section = address_space_translate_internal(d, addr, xlat, plen, false);
assert(!section->mr->iommu_ops);
return section;
}
| {
"code": [
" AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;"
],
"line_no": [
9
]
} | FUNC_0(CPUState *VAR_0, int VAR_1, hwaddr VAR_2,
hwaddr *VAR_3, hwaddr *VAR_4)
{
MemoryRegionSection *section;
AddressSpaceDispatch *d = VAR_0->cpu_ases[VAR_1].memory_dispatch;
section = address_space_translate_internal(d, VAR_2, VAR_3, VAR_4, false);
assert(!section->mr->iommu_ops);
return section;
}
| [
"FUNC_0(CPUState *VAR_0, int VAR_1, hwaddr VAR_2,\nhwaddr *VAR_3, hwaddr *VAR_4)\n{",
"MemoryRegionSection *section;",
"AddressSpaceDispatch *d = VAR_0->cpu_ases[VAR_1].memory_dispatch;",
"section = address_space_translate_internal(d, VAR_2, VAR_3, VAR_4, false);",
"assert(!section->mr->iommu_ops);",
"return section;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
23,353 | static struct pxa2xx_fir_s *pxa2xx_fir_init(target_phys_addr_t base,
qemu_irq irq, struct pxa2xx_dma_state_s *dma,
CharDriverState *chr)
{
int iomemtype;
struct pxa2xx_fir_s *s = (struct pxa2xx_fir_s *)
qemu_mallocz(sizeof(struct pxa2xx_fir_s));
s->base = base;
s->irq = irq;
s->dma = dma;
s->chr = chr;
pxa2xx_fir_reset(s);
iomemtype = cpu_register_io_memory(0, pxa2xx_fir_readfn,
pxa2xx_fir_writefn, s);
cpu_register_physical_memory(s->base, 0xfff, iomemtype);
if (chr)
qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
pxa2xx_fir_rx, pxa2xx_fir_event, s);
register_savevm("pxa2xx_fir", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, s);
return s;
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | static struct pxa2xx_fir_s *pxa2xx_fir_init(target_phys_addr_t base,
qemu_irq irq, struct pxa2xx_dma_state_s *dma,
CharDriverState *chr)
{
int iomemtype;
struct pxa2xx_fir_s *s = (struct pxa2xx_fir_s *)
qemu_mallocz(sizeof(struct pxa2xx_fir_s));
s->base = base;
s->irq = irq;
s->dma = dma;
s->chr = chr;
pxa2xx_fir_reset(s);
iomemtype = cpu_register_io_memory(0, pxa2xx_fir_readfn,
pxa2xx_fir_writefn, s);
cpu_register_physical_memory(s->base, 0xfff, iomemtype);
if (chr)
qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
pxa2xx_fir_rx, pxa2xx_fir_event, s);
register_savevm("pxa2xx_fir", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, s);
return s;
}
| {
"code": [
" cpu_register_physical_memory(s->base, 0xfff, iomemtype);"
],
"line_no": [
35
]
} | static struct pxa2xx_fir_s *FUNC_0(target_phys_addr_t VAR_0,
qemu_irq VAR_1, struct pxa2xx_dma_state_s *VAR_2,
CharDriverState *VAR_3)
{
int VAR_4;
struct pxa2xx_fir_s *VAR_5 = (struct pxa2xx_fir_s *)
qemu_mallocz(sizeof(struct pxa2xx_fir_s));
VAR_5->VAR_0 = VAR_0;
VAR_5->VAR_1 = VAR_1;
VAR_5->VAR_2 = VAR_2;
VAR_5->VAR_3 = VAR_3;
pxa2xx_fir_reset(VAR_5);
VAR_4 = cpu_register_io_memory(0, pxa2xx_fir_readfn,
pxa2xx_fir_writefn, VAR_5);
cpu_register_physical_memory(VAR_5->VAR_0, 0xfff, VAR_4);
if (VAR_3)
qemu_chr_add_handlers(VAR_3, pxa2xx_fir_is_empty,
pxa2xx_fir_rx, pxa2xx_fir_event, VAR_5);
register_savevm("pxa2xx_fir", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, VAR_5);
return VAR_5;
}
| [
"static struct pxa2xx_fir_s *FUNC_0(target_phys_addr_t VAR_0,\nqemu_irq VAR_1, struct pxa2xx_dma_state_s *VAR_2,\nCharDriverState *VAR_3)\n{",
"int VAR_4;",
"struct pxa2xx_fir_s *VAR_5 = (struct pxa2xx_fir_s *)\nqemu_mallocz(sizeof(struct pxa2xx_fir_s));",
"VAR_5->VAR_0 = VAR_0;",
"VAR_5->VAR_1 = VAR_1;",
"VAR_5->VAR_2 = VAR_2;",
"VAR_5->VAR_3 = VAR_3;",
"pxa2xx_fir_reset(VAR_5);",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_fir_readfn,\npxa2xx_fir_writefn, VAR_5);",
"cpu_register_physical_memory(VAR_5->VAR_0, 0xfff, VAR_4);",
"if (VAR_3)\nqemu_chr_add_handlers(VAR_3, pxa2xx_fir_is_empty,\npxa2xx_fir_rx, pxa2xx_fir_event, VAR_5);",
"register_savevm(\"pxa2xx_fir\", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, VAR_5);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41,
43
],
[
47
],
[
51
],
[
53
]
] |
23,355 | static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *request)
{
NBDClient *client = req->client;
int csock = client->sock;
ssize_t rc;
client->recv_coroutine = qemu_coroutine_self();
if (nbd_receive_request(csock, request) < 0) {
rc = -EIO;
goto out;
}
if (request->len > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request->len, NBD_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected! "
"you're probably being attacked");
rc = -EINVAL;
goto out;
}
TRACE("Decoding type");
if ((request->type & NBD_CMD_MASK_COMMAND) == NBD_CMD_WRITE) {
TRACE("Reading %u byte(s)", request->len);
if (qemu_co_recv(csock, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
}
rc = 0;
out:
client->recv_coroutine = NULL;
return rc;
}
| true | qemu | 7fe7b68b32ba609faeeee03556aac0eb1b187c91 | static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *request)
{
NBDClient *client = req->client;
int csock = client->sock;
ssize_t rc;
client->recv_coroutine = qemu_coroutine_self();
if (nbd_receive_request(csock, request) < 0) {
rc = -EIO;
goto out;
}
if (request->len > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request->len, NBD_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected! "
"you're probably being attacked");
rc = -EINVAL;
goto out;
}
TRACE("Decoding type");
if ((request->type & NBD_CMD_MASK_COMMAND) == NBD_CMD_WRITE) {
TRACE("Reading %u byte(s)", request->len);
if (qemu_co_recv(csock, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
}
rc = 0;
out:
client->recv_coroutine = NULL;
return rc;
}
| {
"code": [
" if (nbd_receive_request(csock, request) < 0) {",
" rc = -EIO;"
],
"line_no": [
15,
17
]
} | static ssize_t FUNC_0(NBDRequest *req, struct nbd_request *request)
{
NBDClient *client = req->client;
int VAR_0 = client->sock;
ssize_t rc;
client->recv_coroutine = qemu_coroutine_self();
if (nbd_receive_request(VAR_0, request) < 0) {
rc = -EIO;
goto out;
}
if (request->len > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request->len, NBD_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected! "
"you're probably being attacked");
rc = -EINVAL;
goto out;
}
TRACE("Decoding type");
if ((request->type & NBD_CMD_MASK_COMMAND) == NBD_CMD_WRITE) {
TRACE("Reading %u byte(s)", request->len);
if (qemu_co_recv(VAR_0, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
}
rc = 0;
out:
client->recv_coroutine = NULL;
return rc;
}
| [
"static ssize_t FUNC_0(NBDRequest *req, struct nbd_request *request)\n{",
"NBDClient *client = req->client;",
"int VAR_0 = client->sock;",
"ssize_t rc;",
"client->recv_coroutine = qemu_coroutine_self();",
"if (nbd_receive_request(VAR_0, request) < 0) {",
"rc = -EIO;",
"goto out;",
"}",
"if (request->len > NBD_BUFFER_SIZE) {",
"LOG(\"len (%u) is larger than max len (%u)\",\nrequest->len, NBD_BUFFER_SIZE);",
"rc = -EINVAL;",
"goto out;",
"}",
"if ((request->from + request->len) < request->from) {",
"LOG(\"integer overflow detected! \"\n\"you're probably being attacked\");",
"rc = -EINVAL;",
"goto out;",
"}",
"TRACE(\"Decoding type\");",
"if ((request->type & NBD_CMD_MASK_COMMAND) == NBD_CMD_WRITE) {",
"TRACE(\"Reading %u byte(s)\", request->len);",
"if (qemu_co_recv(VAR_0, req->data, request->len) != request->len) {",
"LOG(\"reading from socket failed\");",
"rc = -EIO;",
"goto out;",
"}",
"}",
"rc = 0;",
"out:\nclient->recv_coroutine = NULL;",
"return rc;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
]
] |
23,356 | ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
ram_addr_t start,
ram_addr_t *ram_addr_abs)
{
unsigned long base = rb->offset >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
unsigned long *bitmap;
unsigned long next;
bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
if (rs->ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(bitmap, size, nr);
}
*ram_addr_abs = next << TARGET_PAGE_BITS;
return (next - base) << TARGET_PAGE_BITS;
}
| true | qemu | 06b106889a09277617fc8c542397a9f595ee605a | ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
ram_addr_t start,
ram_addr_t *ram_addr_abs)
{
unsigned long base = rb->offset >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
unsigned long *bitmap;
unsigned long next;
bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
if (rs->ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(bitmap, size, nr);
}
*ram_addr_abs = next << TARGET_PAGE_BITS;
return (next - base) << TARGET_PAGE_BITS;
}
| {
"code": [
" ram_addr_t *ram_addr_abs)",
" *ram_addr_abs = next << TARGET_PAGE_BITS;"
],
"line_no": [
5,
39
]
} | ram_addr_t FUNC_0(RAMState *rs, RAMBlock *rb,
ram_addr_t start,
ram_addr_t *ram_addr_abs)
{
unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS;
unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS);
unsigned long *VAR_3;
unsigned long VAR_4;
VAR_3 = atomic_rcu_read(&rs->ram_bitmap)->bmap;
if (rs->ram_bulk_stage && VAR_1 > VAR_0) {
VAR_4 = VAR_1 + 1;
} else {
VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1);
}
*ram_addr_abs = VAR_4 << TARGET_PAGE_BITS;
return (VAR_4 - VAR_0) << TARGET_PAGE_BITS;
}
| [
"ram_addr_t FUNC_0(RAMState *rs, RAMBlock *rb,\nram_addr_t start,\nram_addr_t *ram_addr_abs)\n{",
"unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS;",
"unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS);",
"uint64_t rb_size = rb->used_length;",
"unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS);",
"unsigned long *VAR_3;",
"unsigned long VAR_4;",
"VAR_3 = atomic_rcu_read(&rs->ram_bitmap)->bmap;",
"if (rs->ram_bulk_stage && VAR_1 > VAR_0) {",
"VAR_4 = VAR_1 + 1;",
"} else {",
"VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1);",
"}",
"*ram_addr_abs = VAR_4 << TARGET_PAGE_BITS;",
"return (VAR_4 - VAR_0) << TARGET_PAGE_BITS;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
]
] |
23,357 | AVFrame *ff_framequeue_take(FFFrameQueue *fq)
{
FFFrameBucket *b;
check_consistency(fq);
av_assert1(fq->queued);
b = bucket(fq, 0);
fq->queued--;
fq->tail++;
fq->tail &= fq->allocated - 1;
fq->total_frames_tail++;
fq->total_samples_tail += b->frame->nb_samples;
check_consistency(fq);
return b->frame;
} | true | FFmpeg | fc3a03fcf9cd7eafe7342e2508e6128888efa0bb | AVFrame *ff_framequeue_take(FFFrameQueue *fq)
{
FFFrameBucket *b;
check_consistency(fq);
av_assert1(fq->queued);
b = bucket(fq, 0);
fq->queued--;
fq->tail++;
fq->tail &= fq->allocated - 1;
fq->total_frames_tail++;
fq->total_samples_tail += b->frame->nb_samples;
check_consistency(fq);
return b->frame;
} | {
"code": [],
"line_no": []
} | AVFrame *FUNC_0(FFFrameQueue *fq)
{
FFFrameBucket *b;
check_consistency(fq);
av_assert1(fq->queued);
b = bucket(fq, 0);
fq->queued--;
fq->tail++;
fq->tail &= fq->allocated - 1;
fq->total_frames_tail++;
fq->total_samples_tail += b->frame->nb_samples;
check_consistency(fq);
return b->frame;
} | [
"AVFrame *FUNC_0(FFFrameQueue *fq)\n{",
"FFFrameBucket *b;",
"check_consistency(fq);",
"av_assert1(fq->queued);",
"b = bucket(fq, 0);",
"fq->queued--;",
"fq->tail++;",
"fq->tail &= fq->allocated - 1;",
"fq->total_frames_tail++;",
"fq->total_samples_tail += b->frame->nb_samples;",
"check_consistency(fq);",
"return b->frame;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
26
],
[
28
],
[
30
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.