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
|
---|---|---|---|---|---|---|---|---|---|---|
21,856 | static void spapr_dt_rtas(sPAPRMachineState *spapr, void *fdt)
{
int rtas;
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
uint64_t max_hotplug_addr = spapr->hotplug_memory.base +
memory_region_size(&spapr->hotplug_memory.mr);
uint32_t lrdr_capacity[] = {
cpu_to_be32(max_hotplug_addr >> 32),
cpu_to_be32(max_hotplug_addr & 0xffffffff),
0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
cpu_to_be32(max_cpus / smp_threads),
};
_FDT(rtas = fdt_add_subnode(fdt, 0, "rtas"));
/* hypertas */
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(hypertas, "hcall-sprg0");
add_str(hypertas, "hcall-copy");
add_str(hypertas, "hcall-debug");
add_str(qemu_hypertas, "hcall-memop1");
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
if (spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {
add_str(hypertas, "hcall-hpt-resize");
}
_FDT(fdt_setprop(fdt, rtas, "ibm,hypertas-functions",
hypertas->str, hypertas->len));
g_string_free(hypertas, TRUE);
_FDT(fdt_setprop(fdt, rtas, "qemu,hypertas-functions",
qemu_hypertas->str, qemu_hypertas->len));
g_string_free(qemu_hypertas, TRUE);
_FDT(fdt_setprop(fdt, rtas, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints)));
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-error-log-max",
RTAS_ERROR_LOG_MAX));
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate",
RTAS_EVENT_SCAN_RATE));
if (msi_nonbroken) {
_FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0));
}
/*
* According to PAPR, rtas ibm,os-term does not guarantee a return
* back to the guest cpu.
*
* While an additional ibm,extended-os-term property indicates
* that rtas call return will always occur. Set this property.
*/
_FDT(fdt_setprop(fdt, rtas, "ibm,extended-os-term", NULL, 0));
_FDT(fdt_setprop(fdt, rtas, "ibm,lrdr-capacity",
lrdr_capacity, sizeof(lrdr_capacity)));
spapr_dt_rtas_tokens(fdt, rtas);
}
| false | qemu | 4f441474c61f317de7927edfdb1d042b0b6f3882 | static void spapr_dt_rtas(sPAPRMachineState *spapr, void *fdt)
{
int rtas;
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
uint64_t max_hotplug_addr = spapr->hotplug_memory.base +
memory_region_size(&spapr->hotplug_memory.mr);
uint32_t lrdr_capacity[] = {
cpu_to_be32(max_hotplug_addr >> 32),
cpu_to_be32(max_hotplug_addr & 0xffffffff),
0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
cpu_to_be32(max_cpus / smp_threads),
};
_FDT(rtas = fdt_add_subnode(fdt, 0, "rtas"));
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(hypertas, "hcall-sprg0");
add_str(hypertas, "hcall-copy");
add_str(hypertas, "hcall-debug");
add_str(qemu_hypertas, "hcall-memop1");
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
if (spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {
add_str(hypertas, "hcall-hpt-resize");
}
_FDT(fdt_setprop(fdt, rtas, "ibm,hypertas-functions",
hypertas->str, hypertas->len));
g_string_free(hypertas, TRUE);
_FDT(fdt_setprop(fdt, rtas, "qemu,hypertas-functions",
qemu_hypertas->str, qemu_hypertas->len));
g_string_free(qemu_hypertas, TRUE);
_FDT(fdt_setprop(fdt, rtas, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints)));
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-error-log-max",
RTAS_ERROR_LOG_MAX));
_FDT(fdt_setprop_cell(fdt, rtas, "rtas-event-scan-rate",
RTAS_EVENT_SCAN_RATE));
if (msi_nonbroken) {
_FDT(fdt_setprop(fdt, rtas, "ibm,change-msix-capable", NULL, 0));
}
_FDT(fdt_setprop(fdt, rtas, "ibm,extended-os-term", NULL, 0));
_FDT(fdt_setprop(fdt, rtas, "ibm,lrdr-capacity",
lrdr_capacity, sizeof(lrdr_capacity)));
spapr_dt_rtas_tokens(fdt, rtas);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPRMachineState *VAR_0, void *VAR_1)
{
int VAR_2;
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };
uint64_t max_hotplug_addr = VAR_0->hotplug_memory.base +
memory_region_size(&VAR_0->hotplug_memory.mr);
uint32_t lrdr_capacity[] = {
cpu_to_be32(max_hotplug_addr >> 32),
cpu_to_be32(max_hotplug_addr & 0xffffffff),
0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),
cpu_to_be32(max_cpus / smp_threads),
};
_FDT(VAR_2 = fdt_add_subnode(VAR_1, 0, "VAR_2"));
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(hypertas, "hcall-sprg0");
add_str(hypertas, "hcall-copy");
add_str(hypertas, "hcall-debug");
add_str(qemu_hypertas, "hcall-memop1");
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
if (VAR_0->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {
add_str(hypertas, "hcall-hpt-resize");
}
_FDT(fdt_setprop(VAR_1, VAR_2, "ibm,hypertas-functions",
hypertas->str, hypertas->len));
g_string_free(hypertas, TRUE);
_FDT(fdt_setprop(VAR_1, VAR_2, "qemu,hypertas-functions",
qemu_hypertas->str, qemu_hypertas->len));
g_string_free(qemu_hypertas, TRUE);
_FDT(fdt_setprop(VAR_1, VAR_2, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints)));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "VAR_2-error-log-max",
RTAS_ERROR_LOG_MAX));
_FDT(fdt_setprop_cell(VAR_1, VAR_2, "VAR_2-event-scan-rate",
RTAS_EVENT_SCAN_RATE));
if (msi_nonbroken) {
_FDT(fdt_setprop(VAR_1, VAR_2, "ibm,change-msix-capable", NULL, 0));
}
_FDT(fdt_setprop(VAR_1, VAR_2, "ibm,extended-os-term", NULL, 0));
_FDT(fdt_setprop(VAR_1, VAR_2, "ibm,lrdr-capacity",
lrdr_capacity, sizeof(lrdr_capacity)));
spapr_dt_rtas_tokens(VAR_1, VAR_2);
}
| [
"static void FUNC_0(sPAPRMachineState *VAR_0, void *VAR_1)\n{",
"int VAR_2;",
"GString *hypertas = g_string_sized_new(256);",
"GString *qemu_hypertas = g_string_sized_new(256);",
"uint32_t refpoints[] = { cpu_to_be32(0x4), cpu_to_be32(0x4) };",
"uint64_t max_hotplug_addr = VAR_0->hotplug_memory.base +\nmemory_region_size(&VAR_0->hotplug_memory.mr);",
"uint32_t lrdr_capacity[] = {",
"cpu_to_be32(max_hotplug_addr >> 32),\ncpu_to_be32(max_hotplug_addr & 0xffffffff),\n0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE),\ncpu_to_be32(max_cpus / smp_threads),\n};",
"_FDT(VAR_2 = fdt_add_subnode(VAR_1, 0, \"VAR_2\"));",
"add_str(hypertas, \"hcall-pft\");",
"add_str(hypertas, \"hcall-term\");",
"add_str(hypertas, \"hcall-dabr\");",
"add_str(hypertas, \"hcall-interrupt\");",
"add_str(hypertas, \"hcall-tce\");",
"add_str(hypertas, \"hcall-vio\");",
"add_str(hypertas, \"hcall-splpar\");",
"add_str(hypertas, \"hcall-bulk\");",
"add_str(hypertas, \"hcall-set-mode\");",
"add_str(hypertas, \"hcall-sprg0\");",
"add_str(hypertas, \"hcall-copy\");",
"add_str(hypertas, \"hcall-debug\");",
"add_str(qemu_hypertas, \"hcall-memop1\");",
"if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {",
"add_str(hypertas, \"hcall-multi-tce\");",
"}",
"if (VAR_0->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {",
"add_str(hypertas, \"hcall-hpt-resize\");",
"}",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"ibm,hypertas-functions\",\nhypertas->str, hypertas->len));",
"g_string_free(hypertas, TRUE);",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"qemu,hypertas-functions\",\nqemu_hypertas->str, qemu_hypertas->len));",
"g_string_free(qemu_hypertas, TRUE);",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"ibm,associativity-reference-points\",\nrefpoints, sizeof(refpoints)));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"VAR_2-error-log-max\",\nRTAS_ERROR_LOG_MAX));",
"_FDT(fdt_setprop_cell(VAR_1, VAR_2, \"VAR_2-event-scan-rate\",\nRTAS_EVENT_SCAN_RATE));",
"if (msi_nonbroken) {",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"ibm,change-msix-capable\", NULL, 0));",
"}",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"ibm,extended-os-term\", NULL, 0));",
"_FDT(fdt_setprop(VAR_1, VAR_2, \"ibm,lrdr-capacity\",\nlrdr_capacity, sizeof(lrdr_capacity)));",
"spapr_dt_rtas_tokens(VAR_1, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21,
23,
25,
27
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91
],
[
95,
97
],
[
101,
103
],
[
105,
107
],
[
111
],
[
113
],
[
115
],
[
133
],
[
137,
139
],
[
143
],
[
145
]
] |
21,857 | static ssize_t nbd_co_receive_request(NBDRequest *req,
struct nbd_request *request)
{
NBDClient *client = req->client;
uint32_t command;
ssize_t rc;
g_assert(qemu_in_coroutine());
client->recv_coroutine = qemu_coroutine_self();
nbd_update_can_read(client);
rc = nbd_receive_request(client->ioc, request);
if (rc < 0) {
if (rc != -EAGAIN) {
rc = -EIO;
}
goto out;
}
TRACE("Decoding type");
command = request->type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_WRITE) {
/* No payload, we are ready to read the next request. */
req->complete = true;
}
if (command == NBD_CMD_DISC) {
/* Special case: we're going to disconnect without a reply,
* whether or not flags, from, or len are bogus */
TRACE("Request type is DISCONNECT");
rc = -EIO;
goto out;
}
/* Check for sanity in the parameters, part 1. Defer as many
* checks as possible until after reading any NBD_CMD_WRITE
* payload, so we can try and keep the connection alive. */
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected, you're probably being attacked");
rc = -EINVAL;
goto out;
}
if (command == NBD_CMD_READ || command == NBD_CMD_WRITE) {
if (request->len > NBD_MAX_BUFFER_SIZE) {
LOG("len (%" PRIu32" ) is larger than max len (%u)",
request->len, NBD_MAX_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
req->data = blk_try_blockalign(client->exp->blk, request->len);
if (req->data == NULL) {
rc = -ENOMEM;
goto out;
}
}
if (command == NBD_CMD_WRITE) {
TRACE("Reading %" PRIu32 " byte(s)", request->len);
if (read_sync(client->ioc, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
req->complete = true;
}
/* Sanity checks, part 2. */
if (request->from + request->len > client->exp->size) {
LOG("operation past EOF; From: %" PRIu64 ", Len: %" PRIu32
", Size: %" PRIu64, request->from, request->len,
(uint64_t)client->exp->size);
rc = command == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;
goto out;
}
if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {
LOG("unsupported flags (got 0x%x)",
request->type & ~NBD_CMD_MASK_COMMAND);
rc = -EINVAL;
goto out;
}
rc = 0;
out:
client->recv_coroutine = NULL;
nbd_update_can_read(client);
return rc;
}
| false | qemu | b626b51a6721e53817155af720243f59072e424f | static ssize_t nbd_co_receive_request(NBDRequest *req,
struct nbd_request *request)
{
NBDClient *client = req->client;
uint32_t command;
ssize_t rc;
g_assert(qemu_in_coroutine());
client->recv_coroutine = qemu_coroutine_self();
nbd_update_can_read(client);
rc = nbd_receive_request(client->ioc, request);
if (rc < 0) {
if (rc != -EAGAIN) {
rc = -EIO;
}
goto out;
}
TRACE("Decoding type");
command = request->type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_WRITE) {
req->complete = true;
}
if (command == NBD_CMD_DISC) {
TRACE("Request type is DISCONNECT");
rc = -EIO;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected, you're probably being attacked");
rc = -EINVAL;
goto out;
}
if (command == NBD_CMD_READ || command == NBD_CMD_WRITE) {
if (request->len > NBD_MAX_BUFFER_SIZE) {
LOG("len (%" PRIu32" ) is larger than max len (%u)",
request->len, NBD_MAX_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
req->data = blk_try_blockalign(client->exp->blk, request->len);
if (req->data == NULL) {
rc = -ENOMEM;
goto out;
}
}
if (command == NBD_CMD_WRITE) {
TRACE("Reading %" PRIu32 " byte(s)", request->len);
if (read_sync(client->ioc, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
req->complete = true;
}
if (request->from + request->len > client->exp->size) {
LOG("operation past EOF; From: %" PRIu64 ", Len: %" PRIu32
", Size: %" PRIu64, request->from, request->len,
(uint64_t)client->exp->size);
rc = command == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;
goto out;
}
if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {
LOG("unsupported flags (got 0x%x)",
request->type & ~NBD_CMD_MASK_COMMAND);
rc = -EINVAL;
goto out;
}
rc = 0;
out:
client->recv_coroutine = NULL;
nbd_update_can_read(client);
return rc;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(NBDRequest *req,
struct nbd_request *request)
{
NBDClient *client = req->client;
uint32_t command;
ssize_t rc;
g_assert(qemu_in_coroutine());
client->recv_coroutine = qemu_coroutine_self();
nbd_update_can_read(client);
rc = nbd_receive_request(client->ioc, request);
if (rc < 0) {
if (rc != -EAGAIN) {
rc = -EIO;
}
goto out;
}
TRACE("Decoding type");
command = request->type & NBD_CMD_MASK_COMMAND;
if (command != NBD_CMD_WRITE) {
req->complete = true;
}
if (command == NBD_CMD_DISC) {
TRACE("Request type is DISCONNECT");
rc = -EIO;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected, you're probably being attacked");
rc = -EINVAL;
goto out;
}
if (command == NBD_CMD_READ || command == NBD_CMD_WRITE) {
if (request->len > NBD_MAX_BUFFER_SIZE) {
LOG("len (%" PRIu32" ) is larger than max len (%u)",
request->len, NBD_MAX_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
req->data = blk_try_blockalign(client->exp->blk, request->len);
if (req->data == NULL) {
rc = -ENOMEM;
goto out;
}
}
if (command == NBD_CMD_WRITE) {
TRACE("Reading %" PRIu32 " byte(s)", request->len);
if (read_sync(client->ioc, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
req->complete = true;
}
if (request->from + request->len > client->exp->size) {
LOG("operation past EOF; From: %" PRIu64 ", Len: %" PRIu32
", Size: %" PRIu64, request->from, request->len,
(uint64_t)client->exp->size);
rc = command == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;
goto out;
}
if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {
LOG("unsupported flags (got 0x%x)",
request->type & ~NBD_CMD_MASK_COMMAND);
rc = -EINVAL;
goto out;
}
rc = 0;
out:
client->recv_coroutine = NULL;
nbd_update_can_read(client);
return rc;
}
| [
"static ssize_t FUNC_0(NBDRequest *req,\nstruct nbd_request *request)\n{",
"NBDClient *client = req->client;",
"uint32_t command;",
"ssize_t rc;",
"g_assert(qemu_in_coroutine());",
"client->recv_coroutine = qemu_coroutine_self();",
"nbd_update_can_read(client);",
"rc = nbd_receive_request(client->ioc, request);",
"if (rc < 0) {",
"if (rc != -EAGAIN) {",
"rc = -EIO;",
"}",
"goto out;",
"}",
"TRACE(\"Decoding type\");",
"command = request->type & NBD_CMD_MASK_COMMAND;",
"if (command != NBD_CMD_WRITE) {",
"req->complete = true;",
"}",
"if (command == NBD_CMD_DISC) {",
"TRACE(\"Request type is DISCONNECT\");",
"rc = -EIO;",
"goto out;",
"}",
"if ((request->from + request->len) < request->from) {",
"LOG(\"integer overflow detected, you're probably being attacked\");",
"rc = -EINVAL;",
"goto out;",
"}",
"if (command == NBD_CMD_READ || command == NBD_CMD_WRITE) {",
"if (request->len > NBD_MAX_BUFFER_SIZE) {",
"LOG(\"len (%\" PRIu32\" ) is larger than max len (%u)\",\nrequest->len, NBD_MAX_BUFFER_SIZE);",
"rc = -EINVAL;",
"goto out;",
"}",
"req->data = blk_try_blockalign(client->exp->blk, request->len);",
"if (req->data == NULL) {",
"rc = -ENOMEM;",
"goto out;",
"}",
"}",
"if (command == NBD_CMD_WRITE) {",
"TRACE(\"Reading %\" PRIu32 \" byte(s)\", request->len);",
"if (read_sync(client->ioc, req->data, request->len) != request->len) {",
"LOG(\"reading from socket failed\");",
"rc = -EIO;",
"goto out;",
"}",
"req->complete = true;",
"}",
"if (request->from + request->len > client->exp->size) {",
"LOG(\"operation past EOF; From: %\" PRIu64 \", Len: %\" PRIu32",
"\", Size: %\" PRIu64, request->from, request->len,\n(uint64_t)client->exp->size);",
"rc = command == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;",
"goto out;",
"}",
"if (request->type & ~NBD_CMD_MASK_COMMAND & ~NBD_CMD_FLAG_FUA) {",
"LOG(\"unsupported flags (got 0x%x)\",\nrequest->type & ~NBD_CMD_MASK_COMMAND);",
"rc = -EINVAL;",
"goto out;",
"}",
"rc = 0;",
"out:\nclient->recv_coroutine = NULL;",
"nbd_update_can_read(client);",
"return rc;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
173,
175
],
[
177
],
[
181
],
[
183
]
] |
21,859 | static void qio_channel_socket_listen_worker(QIOTask *task,
gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddressLegacy *addr = opaque;
Error *err = NULL;
qio_channel_socket_listen_sync(ioc, addr, &err);
qio_task_set_error(task, err);
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static void qio_channel_socket_listen_worker(QIOTask *task,
gpointer opaque)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
SocketAddressLegacy *addr = opaque;
Error *err = NULL;
qio_channel_socket_listen_sync(ioc, addr, &err);
qio_task_set_error(task, err);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QIOTask *VAR_0,
gpointer VAR_1)
{
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(VAR_0));
SocketAddressLegacy *addr = VAR_1;
Error *err = NULL;
qio_channel_socket_listen_sync(ioc, addr, &err);
qio_task_set_error(VAR_0, err);
}
| [
"static void FUNC_0(QIOTask *VAR_0,\ngpointer VAR_1)\n{",
"QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(VAR_0));",
"SocketAddressLegacy *addr = VAR_1;",
"Error *err = NULL;",
"qio_channel_socket_listen_sync(ioc, addr, &err);",
"qio_task_set_error(VAR_0, err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
]
] |
21,861 | static void smp_parse(QemuOpts *opts)
{
if (opts) {
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
unsigned threads = qemu_opt_get_number(opts, "threads", 0);
/* compute missing values, prefer sockets over cores over threads */
if (cpus == 0 || sockets == 0) {
sockets = sockets > 0 ? sockets : 1;
cores = cores > 0 ? cores : 1;
threads = threads > 0 ? threads : 1;
if (cpus == 0) {
cpus = cores * threads * sockets;
}
} else if (cores == 0) {
threads = threads > 0 ? threads : 1;
cores = cpus / (sockets * threads);
} else if (threads == 0) {
threads = cpus / (cores * sockets);
} else if (sockets * cores * threads < cpus) {
error_report("cpu topology: "
"sockets (%u) * cores (%u) * threads (%u) < "
"smp_cpus (%u)",
sockets, cores, threads, cpus);
exit(1);
}
max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
if (sockets * cores * threads > max_cpus) {
error_report("cpu topology: "
"sockets (%u) * cores (%u) * threads (%u) > "
"maxcpus (%u)",
sockets, cores, threads, max_cpus);
exit(1);
}
smp_cpus = cpus;
smp_cores = cores > 0 ? cores : 1;
smp_threads = threads > 0 ? threads : 1;
}
if (max_cpus == 0) {
max_cpus = smp_cpus;
}
if (max_cpus > MAX_CPUMASK_BITS) {
error_report("unsupported number of maxcpus");
exit(1);
}
if (max_cpus < smp_cpus) {
error_report("maxcpus must be equal to or greater than smp");
exit(1);
}
if (smp_cpus > 1 || smp_cores > 1 || smp_threads > 1) {
Error *blocker = NULL;
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
replay_add_blocker(blocker);
}
}
| false | qemu | 0544edd88a6acea81aefe22fd0cd9a85d1eef093 | static void smp_parse(QemuOpts *opts)
{
if (opts) {
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
unsigned threads = qemu_opt_get_number(opts, "threads", 0);
if (cpus == 0 || sockets == 0) {
sockets = sockets > 0 ? sockets : 1;
cores = cores > 0 ? cores : 1;
threads = threads > 0 ? threads : 1;
if (cpus == 0) {
cpus = cores * threads * sockets;
}
} else if (cores == 0) {
threads = threads > 0 ? threads : 1;
cores = cpus / (sockets * threads);
} else if (threads == 0) {
threads = cpus / (cores * sockets);
} else if (sockets * cores * threads < cpus) {
error_report("cpu topology: "
"sockets (%u) * cores (%u) * threads (%u) < "
"smp_cpus (%u)",
sockets, cores, threads, cpus);
exit(1);
}
max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
if (sockets * cores * threads > max_cpus) {
error_report("cpu topology: "
"sockets (%u) * cores (%u) * threads (%u) > "
"maxcpus (%u)",
sockets, cores, threads, max_cpus);
exit(1);
}
smp_cpus = cpus;
smp_cores = cores > 0 ? cores : 1;
smp_threads = threads > 0 ? threads : 1;
}
if (max_cpus == 0) {
max_cpus = smp_cpus;
}
if (max_cpus > MAX_CPUMASK_BITS) {
error_report("unsupported number of maxcpus");
exit(1);
}
if (max_cpus < smp_cpus) {
error_report("maxcpus must be equal to or greater than smp");
exit(1);
}
if (smp_cpus > 1 || smp_cores > 1 || smp_threads > 1) {
Error *blocker = NULL;
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
replay_add_blocker(blocker);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QemuOpts *VAR_0)
{
if (VAR_0) {
unsigned VAR_1 = qemu_opt_get_number(VAR_0, "VAR_1", 0);
unsigned VAR_2 = qemu_opt_get_number(VAR_0, "VAR_2", 0);
unsigned VAR_3 = qemu_opt_get_number(VAR_0, "VAR_3", 0);
unsigned VAR_4 = qemu_opt_get_number(VAR_0, "VAR_4", 0);
if (VAR_1 == 0 || VAR_2 == 0) {
VAR_2 = VAR_2 > 0 ? VAR_2 : 1;
VAR_3 = VAR_3 > 0 ? VAR_3 : 1;
VAR_4 = VAR_4 > 0 ? VAR_4 : 1;
if (VAR_1 == 0) {
VAR_1 = VAR_3 * VAR_4 * VAR_2;
}
} else if (VAR_3 == 0) {
VAR_4 = VAR_4 > 0 ? VAR_4 : 1;
VAR_3 = VAR_1 / (VAR_2 * VAR_4);
} else if (VAR_4 == 0) {
VAR_4 = VAR_1 / (VAR_3 * VAR_2);
} else if (VAR_2 * VAR_3 * VAR_4 < VAR_1) {
error_report("cpu topology: "
"VAR_2 (%u) * VAR_3 (%u) * VAR_4 (%u) < "
"smp_cpus (%u)",
VAR_2, VAR_3, VAR_4, VAR_1);
exit(1);
}
max_cpus = qemu_opt_get_number(VAR_0, "maxcpus", VAR_1);
if (VAR_2 * VAR_3 * VAR_4 > max_cpus) {
error_report("cpu topology: "
"VAR_2 (%u) * VAR_3 (%u) * VAR_4 (%u) > "
"maxcpus (%u)",
VAR_2, VAR_3, VAR_4, max_cpus);
exit(1);
}
smp_cpus = VAR_1;
smp_cores = VAR_3 > 0 ? VAR_3 : 1;
smp_threads = VAR_4 > 0 ? VAR_4 : 1;
}
if (max_cpus == 0) {
max_cpus = smp_cpus;
}
if (max_cpus > MAX_CPUMASK_BITS) {
error_report("unsupported number of maxcpus");
exit(1);
}
if (max_cpus < smp_cpus) {
error_report("maxcpus must be equal to or greater than smp");
exit(1);
}
if (smp_cpus > 1 || smp_cores > 1 || smp_threads > 1) {
Error *blocker = NULL;
error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
replay_add_blocker(blocker);
}
}
| [
"static void FUNC_0(QemuOpts *VAR_0)\n{",
"if (VAR_0) {",
"unsigned VAR_1 = qemu_opt_get_number(VAR_0, \"VAR_1\", 0);",
"unsigned VAR_2 = qemu_opt_get_number(VAR_0, \"VAR_2\", 0);",
"unsigned VAR_3 = qemu_opt_get_number(VAR_0, \"VAR_3\", 0);",
"unsigned VAR_4 = qemu_opt_get_number(VAR_0, \"VAR_4\", 0);",
"if (VAR_1 == 0 || VAR_2 == 0) {",
"VAR_2 = VAR_2 > 0 ? VAR_2 : 1;",
"VAR_3 = VAR_3 > 0 ? VAR_3 : 1;",
"VAR_4 = VAR_4 > 0 ? VAR_4 : 1;",
"if (VAR_1 == 0) {",
"VAR_1 = VAR_3 * VAR_4 * VAR_2;",
"}",
"} else if (VAR_3 == 0) {",
"VAR_4 = VAR_4 > 0 ? VAR_4 : 1;",
"VAR_3 = VAR_1 / (VAR_2 * VAR_4);",
"} else if (VAR_4 == 0) {",
"VAR_4 = VAR_1 / (VAR_3 * VAR_2);",
"} else if (VAR_2 * VAR_3 * VAR_4 < VAR_1) {",
"error_report(\"cpu topology: \"\n\"VAR_2 (%u) * VAR_3 (%u) * VAR_4 (%u) < \"\n\"smp_cpus (%u)\",\nVAR_2, VAR_3, VAR_4, VAR_1);",
"exit(1);",
"}",
"max_cpus = qemu_opt_get_number(VAR_0, \"maxcpus\", VAR_1);",
"if (VAR_2 * VAR_3 * VAR_4 > max_cpus) {",
"error_report(\"cpu topology: \"\n\"VAR_2 (%u) * VAR_3 (%u) * VAR_4 (%u) > \"\n\"maxcpus (%u)\",\nVAR_2, VAR_3, VAR_4, max_cpus);",
"exit(1);",
"}",
"smp_cpus = VAR_1;",
"smp_cores = VAR_3 > 0 ? VAR_3 : 1;",
"smp_threads = VAR_4 > 0 ? VAR_4 : 1;",
"}",
"if (max_cpus == 0) {",
"max_cpus = smp_cpus;",
"}",
"if (max_cpus > MAX_CPUMASK_BITS) {",
"error_report(\"unsupported number of maxcpus\");",
"exit(1);",
"}",
"if (max_cpus < smp_cpus) {",
"error_report(\"maxcpus must be equal to or greater than smp\");",
"exit(1);",
"}",
"if (smp_cpus > 1 || smp_cores > 1 || smp_threads > 1) {",
"Error *blocker = NULL;",
"error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, \"smp\");",
"replay_add_blocker(blocker);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49,
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65,
67,
69,
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
]
] |
21,862 | static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
{
vp8_idct_dc_add_c(dst+ 0, block[0], stride);
vp8_idct_dc_add_c(dst+ 4, block[1], stride);
vp8_idct_dc_add_c(dst+ 8, block[2], stride);
vp8_idct_dc_add_c(dst+12, block[3], stride);
}
| false | FFmpeg | b8664c929437d6d079e16979c496a2db40cf2324 | static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
{
vp8_idct_dc_add_c(dst+ 0, block[0], stride);
vp8_idct_dc_add_c(dst+ 4, block[1], stride);
vp8_idct_dc_add_c(dst+ 8, block[2], stride);
vp8_idct_dc_add_c(dst+12, block[3], stride);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0, int16_t VAR_1[4][16], ptrdiff_t VAR_2)
{
vp8_idct_dc_add_c(VAR_0+ 0, VAR_1[0], VAR_2);
vp8_idct_dc_add_c(VAR_0+ 4, VAR_1[1], VAR_2);
vp8_idct_dc_add_c(VAR_0+ 8, VAR_1[2], VAR_2);
vp8_idct_dc_add_c(VAR_0+12, VAR_1[3], VAR_2);
}
| [
"static void FUNC_0(uint8_t *VAR_0, int16_t VAR_1[4][16], ptrdiff_t VAR_2)\n{",
"vp8_idct_dc_add_c(VAR_0+ 0, VAR_1[0], VAR_2);",
"vp8_idct_dc_add_c(VAR_0+ 4, VAR_1[1], VAR_2);",
"vp8_idct_dc_add_c(VAR_0+ 8, VAR_1[2], VAR_2);",
"vp8_idct_dc_add_c(VAR_0+12, VAR_1[3], VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
21,865 | static void rtl8139_io_writeb(void *opaque, uint8_t addr, uint32_t val)
{
RTL8139State *s = opaque;
switch (addr)
{
case MAC0 ... MAC0+5:
s->phys[addr - MAC0] = val;
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys);
break;
case MAC0+6 ... MAC0+7:
/* reserved */
break;
case MAR0 ... MAR0+7:
s->mult[addr - MAR0] = val;
break;
case ChipCmd:
rtl8139_ChipCmd_write(s, val);
break;
case Cfg9346:
rtl8139_Cfg9346_write(s, val);
break;
case TxConfig: /* windows driver sometimes writes using byte-lenth call */
rtl8139_TxConfig_writeb(s, val);
break;
case Config0:
rtl8139_Config0_write(s, val);
break;
case Config1:
rtl8139_Config1_write(s, val);
break;
case Config3:
rtl8139_Config3_write(s, val);
break;
case Config4:
rtl8139_Config4_write(s, val);
break;
case Config5:
rtl8139_Config5_write(s, val);
break;
case MediaStatus:
/* ignore */
DPRINTF("not implemented write(b) to MediaStatus val=0x%02x\n",
val);
break;
case HltClk:
DPRINTF("HltClk write val=0x%08x\n", val);
if (val == 'R')
{
s->clock_enabled = 1;
}
else if (val == 'H')
{
s->clock_enabled = 0;
}
break;
case TxThresh:
DPRINTF("C+ TxThresh write(b) val=0x%02x\n", val);
s->TxThresh = val;
break;
case TxPoll:
DPRINTF("C+ TxPoll write(b) val=0x%02x\n", val);
if (val & (1 << 7))
{
DPRINTF("C+ TxPoll high priority transmission (not "
"implemented)\n");
//rtl8139_cplus_transmit(s);
}
if (val & (1 << 6))
{
DPRINTF("C+ TxPoll normal priority transmission\n");
rtl8139_cplus_transmit(s);
}
break;
default:
DPRINTF("not implemented write(b) addr=0x%x val=0x%02x\n", addr,
val);
break;
}
}
| false | qemu | 90d131fb6504ed12a37dc8433375cc683c30e9da | static void rtl8139_io_writeb(void *opaque, uint8_t addr, uint32_t val)
{
RTL8139State *s = opaque;
switch (addr)
{
case MAC0 ... MAC0+5:
s->phys[addr - MAC0] = val;
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys);
break;
case MAC0+6 ... MAC0+7:
break;
case MAR0 ... MAR0+7:
s->mult[addr - MAR0] = val;
break;
case ChipCmd:
rtl8139_ChipCmd_write(s, val);
break;
case Cfg9346:
rtl8139_Cfg9346_write(s, val);
break;
case TxConfig:
rtl8139_TxConfig_writeb(s, val);
break;
case Config0:
rtl8139_Config0_write(s, val);
break;
case Config1:
rtl8139_Config1_write(s, val);
break;
case Config3:
rtl8139_Config3_write(s, val);
break;
case Config4:
rtl8139_Config4_write(s, val);
break;
case Config5:
rtl8139_Config5_write(s, val);
break;
case MediaStatus:
DPRINTF("not implemented write(b) to MediaStatus val=0x%02x\n",
val);
break;
case HltClk:
DPRINTF("HltClk write val=0x%08x\n", val);
if (val == 'R')
{
s->clock_enabled = 1;
}
else if (val == 'H')
{
s->clock_enabled = 0;
}
break;
case TxThresh:
DPRINTF("C+ TxThresh write(b) val=0x%02x\n", val);
s->TxThresh = val;
break;
case TxPoll:
DPRINTF("C+ TxPoll write(b) val=0x%02x\n", val);
if (val & (1 << 7))
{
DPRINTF("C+ TxPoll high priority transmission (not "
"implemented)\n");
}
if (val & (1 << 6))
{
DPRINTF("C+ TxPoll normal priority transmission\n");
rtl8139_cplus_transmit(s);
}
break;
default:
DPRINTF("not implemented write(b) addr=0x%x val=0x%02x\n", addr,
val);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, uint8_t VAR_1, uint32_t VAR_2)
{
RTL8139State *s = VAR_0;
switch (VAR_1)
{
case MAC0 ... MAC0+5:
s->phys[VAR_1 - MAC0] = VAR_2;
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys);
break;
case MAC0+6 ... MAC0+7:
break;
case MAR0 ... MAR0+7:
s->mult[VAR_1 - MAR0] = VAR_2;
break;
case ChipCmd:
rtl8139_ChipCmd_write(s, VAR_2);
break;
case Cfg9346:
rtl8139_Cfg9346_write(s, VAR_2);
break;
case TxConfig:
rtl8139_TxConfig_writeb(s, VAR_2);
break;
case Config0:
rtl8139_Config0_write(s, VAR_2);
break;
case Config1:
rtl8139_Config1_write(s, VAR_2);
break;
case Config3:
rtl8139_Config3_write(s, VAR_2);
break;
case Config4:
rtl8139_Config4_write(s, VAR_2);
break;
case Config5:
rtl8139_Config5_write(s, VAR_2);
break;
case MediaStatus:
DPRINTF("not implemented write(b) to MediaStatus VAR_2=0x%02x\n",
VAR_2);
break;
case HltClk:
DPRINTF("HltClk write VAR_2=0x%08x\n", VAR_2);
if (VAR_2 == 'R')
{
s->clock_enabled = 1;
}
else if (VAR_2 == 'H')
{
s->clock_enabled = 0;
}
break;
case TxThresh:
DPRINTF("C+ TxThresh write(b) VAR_2=0x%02x\n", VAR_2);
s->TxThresh = VAR_2;
break;
case TxPoll:
DPRINTF("C+ TxPoll write(b) VAR_2=0x%02x\n", VAR_2);
if (VAR_2 & (1 << 7))
{
DPRINTF("C+ TxPoll high priority transmission (not "
"implemented)\n");
}
if (VAR_2 & (1 << 6))
{
DPRINTF("C+ TxPoll normal priority transmission\n");
rtl8139_cplus_transmit(s);
}
break;
default:
DPRINTF("not implemented write(b) VAR_1=0x%x VAR_2=0x%02x\n", VAR_1,
VAR_2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, uint8_t VAR_1, uint32_t VAR_2)\n{",
"RTL8139State *s = VAR_0;",
"switch (VAR_1)\n{",
"case MAC0 ... MAC0+5:\ns->phys[VAR_1 - MAC0] = VAR_2;",
"qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys);",
"break;",
"case MAC0+6 ... MAC0+7:\nbreak;",
"case MAR0 ... MAR0+7:\ns->mult[VAR_1 - MAR0] = VAR_2;",
"break;",
"case ChipCmd:\nrtl8139_ChipCmd_write(s, VAR_2);",
"break;",
"case Cfg9346:\nrtl8139_Cfg9346_write(s, VAR_2);",
"break;",
"case TxConfig:\nrtl8139_TxConfig_writeb(s, VAR_2);",
"break;",
"case Config0:\nrtl8139_Config0_write(s, VAR_2);",
"break;",
"case Config1:\nrtl8139_Config1_write(s, VAR_2);",
"break;",
"case Config3:\nrtl8139_Config3_write(s, VAR_2);",
"break;",
"case Config4:\nrtl8139_Config4_write(s, VAR_2);",
"break;",
"case Config5:\nrtl8139_Config5_write(s, VAR_2);",
"break;",
"case MediaStatus:\nDPRINTF(\"not implemented write(b) to MediaStatus VAR_2=0x%02x\\n\",\nVAR_2);",
"break;",
"case HltClk:\nDPRINTF(\"HltClk write VAR_2=0x%08x\\n\", VAR_2);",
"if (VAR_2 == 'R')\n{",
"s->clock_enabled = 1;",
"}",
"else if (VAR_2 == 'H')\n{",
"s->clock_enabled = 0;",
"}",
"break;",
"case TxThresh:\nDPRINTF(\"C+ TxThresh write(b) VAR_2=0x%02x\\n\", VAR_2);",
"s->TxThresh = VAR_2;",
"break;",
"case TxPoll:\nDPRINTF(\"C+ TxPoll write(b) VAR_2=0x%02x\\n\", VAR_2);",
"if (VAR_2 & (1 << 7))\n{",
"DPRINTF(\"C+ TxPoll high priority transmission (not \"\n\"implemented)\\n\");",
"}",
"if (VAR_2 & (1 << 6))\n{",
"DPRINTF(\"C+ TxPoll normal priority transmission\\n\");",
"rtl8139_cplus_transmit(s);",
"}",
"break;",
"default:\nDPRINTF(\"not implemented write(b) VAR_1=0x%x VAR_2=0x%02x\\n\", VAR_1,\nVAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21,
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,
85,
87
],
[
89
],
[
93,
95
],
[
97,
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
127,
129
],
[
131,
133
],
[
135,
137
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169
]
] |
21,866 | static void test_validate_fail_union(TestInputVisitorData *data,
const void *unused)
{
UserDefUnion *tmp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(err);
qapi_free_UserDefUnion(tmp);
}
| false | qemu | 805017b7791200f1b72deef17dc98fd272b941eb | static void test_validate_fail_union(TestInputVisitorData *data,
const void *unused)
{
UserDefUnion *tmp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(err);
qapi_free_UserDefUnion(tmp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
UserDefUnion *tmp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(VAR_0, "{ 'type': 'b', 'VAR_0' : { 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(err);
qapi_free_UserDefUnion(tmp);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"UserDefUnion *tmp = NULL;",
"Error *err = NULL;",
"Visitor *v;",
"v = validate_test_init(VAR_0, \"{ 'type': 'b', 'VAR_0' : { 'integer': 42 } }\");",
"visit_type_UserDefUnion(v, &tmp, NULL, &err);",
"g_assert(err);",
"qapi_free_UserDefUnion(tmp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
21,867 | static void nabm_writew (void *opaque, uint32_t addr, uint32_t val)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
r->sr |= val & ~(SR_RO_MASK | SR_WCLEAR_MASK);
update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK));
dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), val, r->sr);
break;
default:
dolog ("U nabm writew %#x <- %#x\n", addr, val);
break;
}
}
| false | qemu | 10ee2aaa417d8d8978cdb2bbed55ebb152df5f6b | static void nabm_writew (void *opaque, uint32_t addr, uint32_t val)
{
PCIAC97LinkState *d = opaque;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = addr - s->base[1];
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
r->sr |= val & ~(SR_RO_MASK | SR_WCLEAR_MASK);
update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK));
dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), val, r->sr);
break;
default:
dolog ("U nabm writew %#x <- %#x\n", addr, val);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
PCIAC97LinkState *d = VAR_0;
AC97LinkState *s = &d->ac97;
AC97BusMasterRegs *r = NULL;
uint32_t index = VAR_1 - s->base[1];
switch (index) {
case PI_SR:
case PO_SR:
case MC_SR:
r = &s->bm_regs[GET_BM (index)];
r->sr |= VAR_2 & ~(SR_RO_MASK | SR_WCLEAR_MASK);
update_sr (s, r, r->sr & ~(VAR_2 & SR_WCLEAR_MASK));
dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), VAR_2, r->sr);
break;
default:
dolog ("U nabm writew %#x <- %#x\n", VAR_1, VAR_2);
break;
}
}
| [
"static void FUNC_0 (void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"PCIAC97LinkState *d = VAR_0;",
"AC97LinkState *s = &d->ac97;",
"AC97BusMasterRegs *r = NULL;",
"uint32_t index = VAR_1 - s->base[1];",
"switch (index) {",
"case PI_SR:\ncase PO_SR:\ncase MC_SR:\nr = &s->bm_regs[GET_BM (index)];",
"r->sr |= VAR_2 & ~(SR_RO_MASK | SR_WCLEAR_MASK);",
"update_sr (s, r, r->sr & ~(VAR_2 & SR_WCLEAR_MASK));",
"dolog (\"SR[%d] <- %#x (sr %#x)\\n\", GET_BM (index), VAR_2, r->sr);",
"break;",
"default:\ndolog (\"U nabm writew %#x <- %#x\\n\", VAR_1, VAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
]
] |
21,868 | static void musicpal_misc_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void musicpal_misc_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"}"
] | [
0,
0
] | [
[
1,
3,
5
],
[
7
]
] |
21,869 | void HELPER(ucf64_cmpd)(float64 a, float64 b, uint32_t c, CPUUniCore32State *env)
{
int flag;
flag = float64_compare_quiet(a, b, &env->ucf64.fp_status);
env->CF = 0;
switch (c & 0x7) {
case 0: /* F */
break;
case 1: /* UN */
if (flag == 2) {
env->CF = 1;
}
break;
case 2: /* EQ */
if (flag == 0) {
env->CF = 1;
}
break;
case 3: /* UEQ */
if ((flag == 0) || (flag == 2)) {
env->CF = 1;
}
break;
case 4: /* OLT */
if (flag == -1) {
env->CF = 1;
}
break;
case 5: /* ULT */
if ((flag == -1) || (flag == 2)) {
env->CF = 1;
}
break;
case 6: /* OLE */
if ((flag == -1) || (flag == 0)) {
env->CF = 1;
}
break;
case 7: /* ULE */
if (flag != 1) {
env->CF = 1;
}
break;
}
env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
| (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
}
| false | qemu | e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe | void HELPER(ucf64_cmpd)(float64 a, float64 b, uint32_t c, CPUUniCore32State *env)
{
int flag;
flag = float64_compare_quiet(a, b, &env->ucf64.fp_status);
env->CF = 0;
switch (c & 0x7) {
case 0:
break;
case 1:
if (flag == 2) {
env->CF = 1;
}
break;
case 2:
if (flag == 0) {
env->CF = 1;
}
break;
case 3:
if ((flag == 0) || (flag == 2)) {
env->CF = 1;
}
break;
case 4:
if (flag == -1) {
env->CF = 1;
}
break;
case 5:
if ((flag == -1) || (flag == 2)) {
env->CF = 1;
}
break;
case 6:
if ((flag == -1) || (flag == 0)) {
env->CF = 1;
}
break;
case 7:
if (flag != 1) {
env->CF = 1;
}
break;
}
env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
| (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ucf64_cmpd)(float64 a, float64 b, uint32_t c, CPUUniCore32State *env)
{
int VAR_0;
VAR_0 = float64_compare_quiet(a, b, &env->ucf64.fp_status);
env->CF = 0;
switch (c & 0x7) {
case 0:
break;
case 1:
if (VAR_0 == 2) {
env->CF = 1;
}
break;
case 2:
if (VAR_0 == 0) {
env->CF = 1;
}
break;
case 3:
if ((VAR_0 == 0) || (VAR_0 == 2)) {
env->CF = 1;
}
break;
case 4:
if (VAR_0 == -1) {
env->CF = 1;
}
break;
case 5:
if ((VAR_0 == -1) || (VAR_0 == 2)) {
env->CF = 1;
}
break;
case 6:
if ((VAR_0 == -1) || (VAR_0 == 0)) {
env->CF = 1;
}
break;
case 7:
if (VAR_0 != 1) {
env->CF = 1;
}
break;
}
env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)
| (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);
}
| [
"void FUNC_0(ucf64_cmpd)(float64 a, float64 b, uint32_t c, CPUUniCore32State *env)\n{",
"int VAR_0;",
"VAR_0 = float64_compare_quiet(a, b, &env->ucf64.fp_status);",
"env->CF = 0;",
"switch (c & 0x7) {",
"case 0:\nbreak;",
"case 1:\nif (VAR_0 == 2) {",
"env->CF = 1;",
"}",
"break;",
"case 2:\nif (VAR_0 == 0) {",
"env->CF = 1;",
"}",
"break;",
"case 3:\nif ((VAR_0 == 0) || (VAR_0 == 2)) {",
"env->CF = 1;",
"}",
"break;",
"case 4:\nif (VAR_0 == -1) {",
"env->CF = 1;",
"}",
"break;",
"case 5:\nif ((VAR_0 == -1) || (VAR_0 == 2)) {",
"env->CF = 1;",
"}",
"break;",
"case 6:\nif ((VAR_0 == -1) || (VAR_0 == 0)) {",
"env->CF = 1;",
"}",
"break;",
"case 7:\nif (VAR_0 != 1) {",
"env->CF = 1;",
"}",
"break;",
"}",
"env->ucf64.xregs[UC32_UCF64_FPSCR] = (env->CF << 29)\n| (env->ucf64.xregs[UC32_UCF64_FPSCR] & 0x0fffffff);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
]
] |
21,870 | static void acpi_align_size(GArray *blob, unsigned align)
{
/* Align size to multiple of given size. This reduces the chance
* we need to change size in the future (breaking cross version migration).
*/
g_array_set_size(blob, (ROUND_UP(acpi_data_len(blob), align) +
g_array_get_element_size(blob) - 1) /
g_array_get_element_size(blob));
}
| false | qemu | 134d42d614768b2803e551621f6654dab1fdc2d2 | static void acpi_align_size(GArray *blob, unsigned align)
{
g_array_set_size(blob, (ROUND_UP(acpi_data_len(blob), align) +
g_array_get_element_size(blob) - 1) /
g_array_get_element_size(blob));
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(GArray *VAR_0, unsigned VAR_1)
{
g_array_set_size(VAR_0, (ROUND_UP(acpi_data_len(VAR_0), VAR_1) +
g_array_get_element_size(VAR_0) - 1) /
g_array_get_element_size(VAR_0));
}
| [
"static void FUNC_0(GArray *VAR_0, unsigned VAR_1)\n{",
"g_array_set_size(VAR_0, (ROUND_UP(acpi_data_len(VAR_0), VAR_1) +\ng_array_get_element_size(VAR_0) - 1) /\ng_array_get_element_size(VAR_0));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
11,
13,
15
],
[
17
]
] |
21,872 | int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
{
s->fd = monitor_get_fd(s->mon, fdname);
if (s->fd == -1) {
DPRINTF("fd_migration: invalid file descriptor identifier\n");
goto err_after_get_fd;
}
if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {
DPRINTF("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
s->get_error = fd_errno;
s->write = fd_write;
s->close = fd_close;
migrate_fd_connect(s);
return 0;
err_after_open:
close(s->fd);
err_after_get_fd:
return -1;
}
| false | qemu | e1c37d0e94048502f9874e6356ce7136d4b05bdb | int fd_start_outgoing_migration(MigrationState *s, const char *fdname)
{
s->fd = monitor_get_fd(s->mon, fdname);
if (s->fd == -1) {
DPRINTF("fd_migration: invalid file descriptor identifier\n");
goto err_after_get_fd;
}
if (fcntl(s->fd, F_SETFL, O_NONBLOCK) == -1) {
DPRINTF("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
s->get_error = fd_errno;
s->write = fd_write;
s->close = fd_close;
migrate_fd_connect(s);
return 0;
err_after_open:
close(s->fd);
err_after_get_fd:
return -1;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MigrationState *VAR_0, const char *VAR_1)
{
VAR_0->fd = monitor_get_fd(VAR_0->mon, VAR_1);
if (VAR_0->fd == -1) {
DPRINTF("fd_migration: invalid file descriptor identifier\n");
goto err_after_get_fd;
}
if (fcntl(VAR_0->fd, F_SETFL, O_NONBLOCK) == -1) {
DPRINTF("Unable to set nonblocking mode on file descriptor\n");
goto err_after_open;
}
VAR_0->get_error = fd_errno;
VAR_0->write = fd_write;
VAR_0->close = fd_close;
migrate_fd_connect(VAR_0);
return 0;
err_after_open:
close(VAR_0->fd);
err_after_get_fd:
return -1;
}
| [
"int FUNC_0(MigrationState *VAR_0, const char *VAR_1)\n{",
"VAR_0->fd = monitor_get_fd(VAR_0->mon, VAR_1);",
"if (VAR_0->fd == -1) {",
"DPRINTF(\"fd_migration: invalid file descriptor identifier\\n\");",
"goto err_after_get_fd;",
"}",
"if (fcntl(VAR_0->fd, F_SETFL, O_NONBLOCK) == -1) {",
"DPRINTF(\"Unable to set nonblocking mode on file descriptor\\n\");",
"goto err_after_open;",
"}",
"VAR_0->get_error = fd_errno;",
"VAR_0->write = fd_write;",
"VAR_0->close = fd_close;",
"migrate_fd_connect(VAR_0);",
"return 0;",
"err_after_open:\nclose(VAR_0->fd);",
"err_after_get_fd:\nreturn -1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41,
43
],
[
45,
47
],
[
49
]
] |
21,873 | int msmpeg4_decode_picture_header(MpegEncContext * s)
{
int code;
#if 0
{
int i;
for(i=0; i<s->gb.size*8; i++)
printf("%d", get_bits1(&s->gb));
// get_bits1(&s->gb);
printf("END\n");
return -1;
}
#endif
if(s->msmpeg4_version==1){
int start_code, num;
start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
if(start_code!=0x00000100){
fprintf(stderr, "invalid startcode\n");
return -1;
}
num= get_bits(&s->gb, 5); // frame number */
}
s->pict_type = get_bits(&s->gb, 2) + 1;
if (s->pict_type != I_TYPE &&
s->pict_type != P_TYPE){
fprintf(stderr, "invalid picture type\n");
return -1;
}
#if 0
{
static int had_i=0;
if(s->pict_type == I_TYPE) had_i=1;
if(!had_i) return -1;
}
#endif
s->qscale = get_bits(&s->gb, 5);
if (s->pict_type == I_TYPE) {
code = get_bits(&s->gb, 5);
if(s->msmpeg4_version==1){
if(code==0 || code>s->mb_height){
fprintf(stderr, "invalid slice height %d\n", code);
return -1;
}
s->slice_height = code;
}else{
/* 0x17: one slice, 0x18: two slices, ... */
if (code < 0x17){
fprintf(stderr, "error, slice code was %X\n", code);
return -1;
}
s->slice_height = s->mb_height / (code - 0x16);
}
switch(s->msmpeg4_version){
case 1:
case 2:
s->rl_chroma_table_index = 2;
s->rl_table_index = 2;
s->dc_table_index = 0; //not used
break;
case 3:
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->dc_table_index = get_bits1(&s->gb);
break;
case 4:
msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
else s->per_mb_rl_table= 0;
if(!s->per_mb_rl_table){
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
}
s->dc_table_index = get_bits1(&s->gb);
s->inter_intra_pred= 0;
break;
}
s->no_rounding = 1;
/* printf("qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
s->qscale,
s->rl_chroma_table_index,
s->rl_table_index,
s->dc_table_index,
s->per_mb_rl_table,
s->slice_height);*/
} else {
switch(s->msmpeg4_version){
case 1:
case 2:
if(s->msmpeg4_version==1)
s->use_skip_mb_code = 1;
else
s->use_skip_mb_code = get_bits1(&s->gb);
s->rl_table_index = 2;
s->rl_chroma_table_index = s->rl_table_index;
s->dc_table_index = 0; //not used
s->mv_table_index = 0;
break;
case 3:
s->use_skip_mb_code = get_bits1(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits1(&s->gb);
break;
case 4:
s->use_skip_mb_code = get_bits1(&s->gb);
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
else s->per_mb_rl_table= 0;
if(!s->per_mb_rl_table){
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
}
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits1(&s->gb);
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
break;
}
/* printf("skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
s->use_skip_mb_code,
s->rl_table_index,
s->rl_chroma_table_index,
s->dc_table_index,
s->mv_table_index,
s->per_mb_rl_table,
s->qscale);*/
if(s->flipflop_rounding){
s->no_rounding ^= 1;
}else{
s->no_rounding = 0;
}
}
//printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
s->esc3_level_length= 0;
s->esc3_run_length= 0;
#ifdef DEBUG
printf("*****frame %d:\n", frame_count++);
#endif
return 0;
}
| false | FFmpeg | 68f593b48433842f3407586679fe07f3e5199ab9 | int msmpeg4_decode_picture_header(MpegEncContext * s)
{
int code;
#if 0
{
int i;
for(i=0; i<s->gb.size*8; i++)
printf("%d", get_bits1(&s->gb));
printf("END\n");
return -1;
}
#endif
if(s->msmpeg4_version==1){
int start_code, num;
start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
if(start_code!=0x00000100){
fprintf(stderr, "invalid startcode\n");
return -1;
}
num= get_bits(&s->gb, 5);
}
s->pict_type = get_bits(&s->gb, 2) + 1;
if (s->pict_type != I_TYPE &&
s->pict_type != P_TYPE){
fprintf(stderr, "invalid picture type\n");
return -1;
}
#if 0
{
static int had_i=0;
if(s->pict_type == I_TYPE) had_i=1;
if(!had_i) return -1;
}
#endif
s->qscale = get_bits(&s->gb, 5);
if (s->pict_type == I_TYPE) {
code = get_bits(&s->gb, 5);
if(s->msmpeg4_version==1){
if(code==0 || code>s->mb_height){
fprintf(stderr, "invalid slice height %d\n", code);
return -1;
}
s->slice_height = code;
}else{
if (code < 0x17){
fprintf(stderr, "error, slice code was %X\n", code);
return -1;
}
s->slice_height = s->mb_height / (code - 0x16);
}
switch(s->msmpeg4_version){
case 1:
case 2:
s->rl_chroma_table_index = 2;
s->rl_table_index = 2;
s->dc_table_index = 0;
break;
case 3:
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->dc_table_index = get_bits1(&s->gb);
break;
case 4:
msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
else s->per_mb_rl_table= 0;
if(!s->per_mb_rl_table){
s->rl_chroma_table_index = decode012(&s->gb);
s->rl_table_index = decode012(&s->gb);
}
s->dc_table_index = get_bits1(&s->gb);
s->inter_intra_pred= 0;
break;
}
s->no_rounding = 1;
} else {
switch(s->msmpeg4_version){
case 1:
case 2:
if(s->msmpeg4_version==1)
s->use_skip_mb_code = 1;
else
s->use_skip_mb_code = get_bits1(&s->gb);
s->rl_table_index = 2;
s->rl_chroma_table_index = s->rl_table_index;
s->dc_table_index = 0;
s->mv_table_index = 0;
break;
case 3:
s->use_skip_mb_code = get_bits1(&s->gb);
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits1(&s->gb);
break;
case 4:
s->use_skip_mb_code = get_bits1(&s->gb);
if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
else s->per_mb_rl_table= 0;
if(!s->per_mb_rl_table){
s->rl_table_index = decode012(&s->gb);
s->rl_chroma_table_index = s->rl_table_index;
}
s->dc_table_index = get_bits1(&s->gb);
s->mv_table_index = get_bits1(&s->gb);
s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
break;
}
if(s->flipflop_rounding){
s->no_rounding ^= 1;
}else{
s->no_rounding = 0;
}
}
s->esc3_level_length= 0;
s->esc3_run_length= 0;
#ifdef DEBUG
printf("*****frame %d:\n", frame_count++);
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MpegEncContext * VAR_0)
{
int VAR_1;
#if 0
{
int i;
for(i=0; i<VAR_0->gb.size*8; i++)
printf("%d", get_bits1(&VAR_0->gb));
printf("END\n");
return -1;
}
#endif
if(VAR_0->msmpeg4_version==1){
int VAR_2, VAR_3;
VAR_2 = (get_bits(&VAR_0->gb, 16)<<16) | get_bits(&VAR_0->gb, 16);
if(VAR_2!=0x00000100){
fprintf(stderr, "invalid startcode\n");
return -1;
}
VAR_3= get_bits(&VAR_0->gb, 5);
}
VAR_0->pict_type = get_bits(&VAR_0->gb, 2) + 1;
if (VAR_0->pict_type != I_TYPE &&
VAR_0->pict_type != P_TYPE){
fprintf(stderr, "invalid picture type\n");
return -1;
}
#if 0
{
static int had_i=0;
if(VAR_0->pict_type == I_TYPE) had_i=1;
if(!had_i) return -1;
}
#endif
VAR_0->qscale = get_bits(&VAR_0->gb, 5);
if (VAR_0->pict_type == I_TYPE) {
VAR_1 = get_bits(&VAR_0->gb, 5);
if(VAR_0->msmpeg4_version==1){
if(VAR_1==0 || VAR_1>VAR_0->mb_height){
fprintf(stderr, "invalid slice height %d\n", VAR_1);
return -1;
}
VAR_0->slice_height = VAR_1;
}else{
if (VAR_1 < 0x17){
fprintf(stderr, "error, slice VAR_1 was %X\n", VAR_1);
return -1;
}
VAR_0->slice_height = VAR_0->mb_height / (VAR_1 - 0x16);
}
switch(VAR_0->msmpeg4_version){
case 1:
case 2:
VAR_0->rl_chroma_table_index = 2;
VAR_0->rl_table_index = 2;
VAR_0->dc_table_index = 0;
break;
case 3:
VAR_0->rl_chroma_table_index = decode012(&VAR_0->gb);
VAR_0->rl_table_index = decode012(&VAR_0->gb);
VAR_0->dc_table_index = get_bits1(&VAR_0->gb);
break;
case 4:
msmpeg4_decode_ext_header(VAR_0, (2+5+5+17+7)/8);
if(VAR_0->bit_rate > MBAC_BITRATE) VAR_0->per_mb_rl_table= get_bits1(&VAR_0->gb);
else VAR_0->per_mb_rl_table= 0;
if(!VAR_0->per_mb_rl_table){
VAR_0->rl_chroma_table_index = decode012(&VAR_0->gb);
VAR_0->rl_table_index = decode012(&VAR_0->gb);
}
VAR_0->dc_table_index = get_bits1(&VAR_0->gb);
VAR_0->inter_intra_pred= 0;
break;
}
VAR_0->no_rounding = 1;
} else {
switch(VAR_0->msmpeg4_version){
case 1:
case 2:
if(VAR_0->msmpeg4_version==1)
VAR_0->use_skip_mb_code = 1;
else
VAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);
VAR_0->rl_table_index = 2;
VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;
VAR_0->dc_table_index = 0;
VAR_0->mv_table_index = 0;
break;
case 3:
VAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);
VAR_0->rl_table_index = decode012(&VAR_0->gb);
VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;
VAR_0->dc_table_index = get_bits1(&VAR_0->gb);
VAR_0->mv_table_index = get_bits1(&VAR_0->gb);
break;
case 4:
VAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);
if(VAR_0->bit_rate > MBAC_BITRATE) VAR_0->per_mb_rl_table= get_bits1(&VAR_0->gb);
else VAR_0->per_mb_rl_table= 0;
if(!VAR_0->per_mb_rl_table){
VAR_0->rl_table_index = decode012(&VAR_0->gb);
VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;
}
VAR_0->dc_table_index = get_bits1(&VAR_0->gb);
VAR_0->mv_table_index = get_bits1(&VAR_0->gb);
VAR_0->inter_intra_pred= (VAR_0->width*VAR_0->height < 320*240 && VAR_0->bit_rate<=II_BITRATE);
break;
}
if(VAR_0->flipflop_rounding){
VAR_0->no_rounding ^= 1;
}else{
VAR_0->no_rounding = 0;
}
}
VAR_0->esc3_level_length= 0;
VAR_0->esc3_run_length= 0;
#ifdef DEBUG
printf("*****frame %d:\n", frame_count++);
#endif
return 0;
}
| [
"int FUNC_0(MpegEncContext * VAR_0)\n{",
"int VAR_1;",
"#if 0\n{",
"int i;",
"for(i=0; i<VAR_0->gb.size*8; i++)",
"printf(\"%d\", get_bits1(&VAR_0->gb));",
"printf(\"END\\n\");",
"return -1;",
"}",
"#endif\nif(VAR_0->msmpeg4_version==1){",
"int VAR_2, VAR_3;",
"VAR_2 = (get_bits(&VAR_0->gb, 16)<<16) | get_bits(&VAR_0->gb, 16);",
"if(VAR_2!=0x00000100){",
"fprintf(stderr, \"invalid startcode\\n\");",
"return -1;",
"}",
"VAR_3= get_bits(&VAR_0->gb, 5);",
"}",
"VAR_0->pict_type = get_bits(&VAR_0->gb, 2) + 1;",
"if (VAR_0->pict_type != I_TYPE &&\nVAR_0->pict_type != P_TYPE){",
"fprintf(stderr, \"invalid picture type\\n\");",
"return -1;",
"}",
"#if 0\n{",
"static int had_i=0;",
"if(VAR_0->pict_type == I_TYPE) had_i=1;",
"if(!had_i) return -1;",
"}",
"#endif\nVAR_0->qscale = get_bits(&VAR_0->gb, 5);",
"if (VAR_0->pict_type == I_TYPE) {",
"VAR_1 = get_bits(&VAR_0->gb, 5);",
"if(VAR_0->msmpeg4_version==1){",
"if(VAR_1==0 || VAR_1>VAR_0->mb_height){",
"fprintf(stderr, \"invalid slice height %d\\n\", VAR_1);",
"return -1;",
"}",
"VAR_0->slice_height = VAR_1;",
"}else{",
"if (VAR_1 < 0x17){",
"fprintf(stderr, \"error, slice VAR_1 was %X\\n\", VAR_1);",
"return -1;",
"}",
"VAR_0->slice_height = VAR_0->mb_height / (VAR_1 - 0x16);",
"}",
"switch(VAR_0->msmpeg4_version){",
"case 1:\ncase 2:\nVAR_0->rl_chroma_table_index = 2;",
"VAR_0->rl_table_index = 2;",
"VAR_0->dc_table_index = 0;",
"break;",
"case 3:\nVAR_0->rl_chroma_table_index = decode012(&VAR_0->gb);",
"VAR_0->rl_table_index = decode012(&VAR_0->gb);",
"VAR_0->dc_table_index = get_bits1(&VAR_0->gb);",
"break;",
"case 4:\nmsmpeg4_decode_ext_header(VAR_0, (2+5+5+17+7)/8);",
"if(VAR_0->bit_rate > MBAC_BITRATE) VAR_0->per_mb_rl_table= get_bits1(&VAR_0->gb);",
"else VAR_0->per_mb_rl_table= 0;",
"if(!VAR_0->per_mb_rl_table){",
"VAR_0->rl_chroma_table_index = decode012(&VAR_0->gb);",
"VAR_0->rl_table_index = decode012(&VAR_0->gb);",
"}",
"VAR_0->dc_table_index = get_bits1(&VAR_0->gb);",
"VAR_0->inter_intra_pred= 0;",
"break;",
"}",
"VAR_0->no_rounding = 1;",
"} else {",
"switch(VAR_0->msmpeg4_version){",
"case 1:\ncase 2:\nif(VAR_0->msmpeg4_version==1)\nVAR_0->use_skip_mb_code = 1;",
"else\nVAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);",
"VAR_0->rl_table_index = 2;",
"VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;",
"VAR_0->dc_table_index = 0;",
"VAR_0->mv_table_index = 0;",
"break;",
"case 3:\nVAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);",
"VAR_0->rl_table_index = decode012(&VAR_0->gb);",
"VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;",
"VAR_0->dc_table_index = get_bits1(&VAR_0->gb);",
"VAR_0->mv_table_index = get_bits1(&VAR_0->gb);",
"break;",
"case 4:\nVAR_0->use_skip_mb_code = get_bits1(&VAR_0->gb);",
"if(VAR_0->bit_rate > MBAC_BITRATE) VAR_0->per_mb_rl_table= get_bits1(&VAR_0->gb);",
"else VAR_0->per_mb_rl_table= 0;",
"if(!VAR_0->per_mb_rl_table){",
"VAR_0->rl_table_index = decode012(&VAR_0->gb);",
"VAR_0->rl_chroma_table_index = VAR_0->rl_table_index;",
"}",
"VAR_0->dc_table_index = get_bits1(&VAR_0->gb);",
"VAR_0->mv_table_index = get_bits1(&VAR_0->gb);",
"VAR_0->inter_intra_pred= (VAR_0->width*VAR_0->height < 320*240 && VAR_0->bit_rate<=II_BITRATE);",
"break;",
"}",
"if(VAR_0->flipflop_rounding){",
"VAR_0->no_rounding ^= 1;",
"}else{",
"VAR_0->no_rounding = 0;",
"}",
"}",
"VAR_0->esc3_level_length= 0;",
"VAR_0->esc3_run_length= 0;",
"#ifdef DEBUG\nprintf(\"*****frame %d:\\n\", frame_count++);",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121
],
[
123,
125,
127
],
[
129
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149,
151
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
195
],
[
197
],
[
199,
201,
203,
205
],
[
207,
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
231
],
[
235
],
[
237
],
[
239,
241
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
265
],
[
267
],
[
269
],
[
271
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
305
],
[
307
],
[
311,
313
],
[
315,
317
],
[
319
]
] |
21,874 | static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
{
USBNetState *s = opaque;
struct rndis_packet_msg_type *msg;
if (s->rndis) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));
msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
msg->DataLength = cpu_to_le32(size);
/* msg->OOBDataOffset;
* msg->OOBDataLength;
* msg->NumOOBDataElements;
* msg->PerPacketInfoOffset;
* msg->PerPacketInfoLength;
* msg->VcHandle;
* msg->Reserved;
*/
memcpy(msg + 1, buf, size);
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
return;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
}
| false | qemu | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 | static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
{
USBNetState *s = opaque;
struct rndis_packet_msg_type *msg;
if (s->rndis) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type));
msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
msg->DataLength = cpu_to_le32(size);
memcpy(msg + 1, buf, size);
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
return;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{
USBNetState *s = VAR_0;
struct rndis_packet_msg_type *VAR_3;
if (s->rndis) {
VAR_3 = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
return;
if (VAR_2 + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
return;
memset(VAR_3, 0, sizeof(struct rndis_packet_msg_type));
VAR_3->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
VAR_3->MessageLength = cpu_to_le32(VAR_2 + sizeof(struct rndis_packet_msg_type));
VAR_3->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);
VAR_3->DataLength = cpu_to_le32(VAR_2);
memcpy(VAR_3 + 1, VAR_1, VAR_2);
s->in_len = VAR_2 + sizeof(struct rndis_packet_msg_type);
} else {
if (VAR_2 > sizeof(s->in_buf))
return;
memcpy(s->in_buf, VAR_1, VAR_2);
s->in_len = VAR_2;
}
s->in_ptr = 0;
}
| [
"static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{",
"USBNetState *s = VAR_0;",
"struct rndis_packet_msg_type *VAR_3;",
"if (s->rndis) {",
"VAR_3 = (struct rndis_packet_msg_type *) s->in_buf;",
"if (!s->rndis_state == RNDIS_DATA_INITIALIZED)\nreturn;",
"if (VAR_2 + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))\nreturn;",
"memset(VAR_3, 0, sizeof(struct rndis_packet_msg_type));",
"VAR_3->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);",
"VAR_3->MessageLength = cpu_to_le32(VAR_2 + sizeof(struct rndis_packet_msg_type));",
"VAR_3->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8);",
"VAR_3->DataLength = cpu_to_le32(VAR_2);",
"memcpy(VAR_3 + 1, VAR_1, VAR_2);",
"s->in_len = VAR_2 + sizeof(struct rndis_packet_msg_type);",
"} else {",
"if (VAR_2 > sizeof(s->in_buf))\nreturn;",
"memcpy(s->in_buf, VAR_1, VAR_2);",
"s->in_len = VAR_2;",
"}",
"s->in_ptr = 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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
21,877 | static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
{
int i;
size_t offset = 7;
offset += pdu_marshal(pdu, offset, "w", nwnames);
for (i = 0; i < nwnames; i++) {
offset += pdu_marshal(pdu, offset, "Q", &qids[i]);
}
return offset;
}
| false | qemu | ddca7f86ac022289840e0200fd4050b2b58e9176 | static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
{
int i;
size_t offset = 7;
offset += pdu_marshal(pdu, offset, "w", nwnames);
for (i = 0; i < nwnames; i++) {
offset += pdu_marshal(pdu, offset, "Q", &qids[i]);
}
return offset;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(V9fsPDU *VAR_0, uint16_t VAR_1, V9fsQID *VAR_2)
{
int VAR_3;
size_t offset = 7;
offset += pdu_marshal(VAR_0, offset, "w", VAR_1);
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {
offset += pdu_marshal(VAR_0, offset, "Q", &VAR_2[VAR_3]);
}
return offset;
}
| [
"static int FUNC_0(V9fsPDU *VAR_0, uint16_t VAR_1, V9fsQID *VAR_2)\n{",
"int VAR_3;",
"size_t offset = 7;",
"offset += pdu_marshal(VAR_0, offset, \"w\", VAR_1);",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {",
"offset += pdu_marshal(VAR_0, offset, \"Q\", &VAR_2[VAR_3]);",
"}",
"return offset;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
21,878 | static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
const char *base_id)
{
BlockDriverState *intermediate;
intermediate = top->backing_hd;
while (intermediate) {
BlockDriverState *unused;
/* reached base */
if (intermediate == base) {
break;
}
unused = intermediate;
intermediate = intermediate->backing_hd;
unused->backing_hd = NULL;
bdrv_delete(unused);
}
top->backing_hd = base;
}
| false | qemu | 88266f5aa70fa71fd5cc20aa4dbeb7a7bd8d2e92 | static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
const char *base_id)
{
BlockDriverState *intermediate;
intermediate = top->backing_hd;
while (intermediate) {
BlockDriverState *unused;
if (intermediate == base) {
break;
}
unused = intermediate;
intermediate = intermediate->backing_hd;
unused->backing_hd = NULL;
bdrv_delete(unused);
}
top->backing_hd = base;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
const char *VAR_2)
{
BlockDriverState *intermediate;
intermediate = VAR_0->backing_hd;
while (intermediate) {
BlockDriverState *unused;
if (intermediate == VAR_1) {
break;
}
unused = intermediate;
intermediate = intermediate->backing_hd;
unused->backing_hd = NULL;
bdrv_delete(unused);
}
VAR_0->backing_hd = VAR_1;
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nconst char *VAR_2)\n{",
"BlockDriverState *intermediate;",
"intermediate = VAR_0->backing_hd;",
"while (intermediate) {",
"BlockDriverState *unused;",
"if (intermediate == VAR_1) {",
"break;",
"}",
"unused = intermediate;",
"intermediate = intermediate->backing_hd;",
"unused->backing_hd = NULL;",
"bdrv_delete(unused);",
"}",
"VAR_0->backing_hd = VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
21,879 | static void qemu_paio_submit(struct qemu_paiocb *aiocb)
{
aiocb->ret = -EINPROGRESS;
aiocb->active = 0;
mutex_lock(&lock);
if (idle_threads == 0 && cur_threads < max_threads)
spawn_thread();
TAILQ_INSERT_TAIL(&request_list, aiocb, node);
mutex_unlock(&lock);
cond_signal(&cond);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | static void qemu_paio_submit(struct qemu_paiocb *aiocb)
{
aiocb->ret = -EINPROGRESS;
aiocb->active = 0;
mutex_lock(&lock);
if (idle_threads == 0 && cur_threads < max_threads)
spawn_thread();
TAILQ_INSERT_TAIL(&request_list, aiocb, node);
mutex_unlock(&lock);
cond_signal(&cond);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct qemu_paiocb *VAR_0)
{
VAR_0->ret = -EINPROGRESS;
VAR_0->active = 0;
mutex_lock(&lock);
if (idle_threads == 0 && cur_threads < max_threads)
spawn_thread();
TAILQ_INSERT_TAIL(&request_list, VAR_0, node);
mutex_unlock(&lock);
cond_signal(&cond);
}
| [
"static void FUNC_0(struct qemu_paiocb *VAR_0)\n{",
"VAR_0->ret = -EINPROGRESS;",
"VAR_0->active = 0;",
"mutex_lock(&lock);",
"if (idle_threads == 0 && cur_threads < max_threads)\nspawn_thread();",
"TAILQ_INSERT_TAIL(&request_list, VAR_0, node);",
"mutex_unlock(&lock);",
"cond_signal(&cond);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
21,881 | static int raw_media_changed(BlockDriverState *bs)
{
return bdrv_media_changed(bs->file->bs);
}
| false | qemu | 2e6fc7eb1a4af1b127df5f07b8bb28af891946fa | static int raw_media_changed(BlockDriverState *bs)
{
return bdrv_media_changed(bs->file->bs);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0)
{
return bdrv_media_changed(VAR_0->file->VAR_0);
}
| [
"static int FUNC_0(BlockDriverState *VAR_0)\n{",
"return bdrv_media_changed(VAR_0->file->VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
21,882 | bool is_tcg_gen_code(uintptr_t tc_ptr)
{
/* This can be called during code generation, code_gen_buffer_max_size
is used instead of code_gen_ptr for upper boundary checking */
return (tc_ptr >= (uintptr_t)tcg_ctx.code_gen_buffer &&
tc_ptr < (uintptr_t)(tcg_ctx.code_gen_buffer +
tcg_ctx.code_gen_buffer_max_size));
}
| false | qemu | 52ae646d4a3ebdcdcc973492c6a56f2c49b6578f | bool is_tcg_gen_code(uintptr_t tc_ptr)
{
return (tc_ptr >= (uintptr_t)tcg_ctx.code_gen_buffer &&
tc_ptr < (uintptr_t)(tcg_ctx.code_gen_buffer +
tcg_ctx.code_gen_buffer_max_size));
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(uintptr_t tc_ptr)
{
return (tc_ptr >= (uintptr_t)tcg_ctx.code_gen_buffer &&
tc_ptr < (uintptr_t)(tcg_ctx.code_gen_buffer +
tcg_ctx.code_gen_buffer_max_size));
}
| [
"bool FUNC_0(uintptr_t tc_ptr)\n{",
"return (tc_ptr >= (uintptr_t)tcg_ctx.code_gen_buffer &&\ntc_ptr < (uintptr_t)(tcg_ctx.code_gen_buffer +\ntcg_ctx.code_gen_buffer_max_size));",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
9,
11,
13
],
[
15
]
] |
21,884 | int ff_h264_decode_sei(H264Context *h)
{
while (get_bits_left(&h->gb) > 16) {
int size = 0;
int type = 0;
int ret = 0;
int last = 0;
while (get_bits_left(&h->gb) >= 8 &&
(last = get_bits(&h->gb, 8)) == 255) {
type += 255;
}
type += last;
last = 0;
while (get_bits_left(&h->gb) >= 8 &&
(last = get_bits(&h->gb, 8)) == 255) {
size += 255;
}
size += last;
if (size > get_bits_left(&h->gb) / 8) {
av_log(h->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",
type, get_bits_left(&h->gb));
return AVERROR_INVALIDDATA;
}
switch (type) {
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
ret = decode_picture_timing(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
ret = decode_unregistered_user_data(h, size);
if (ret < 0)
return ret;
break;
case SEI_TYPE_RECOVERY_POINT:
ret = decode_recovery_point(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_BUFFERING_PERIOD:
ret = decode_buffering_period(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_FRAME_PACKING:
ret = decode_frame_packing_arrangement(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
ret = decode_display_orientation(h);
if (ret < 0)
return ret;
break;
default:
av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
skip_bits(&h->gb, 8 * size);
}
// FIXME check bits here
align_get_bits(&h->gb);
}
return 0;
}
| false | FFmpeg | 0bfab80a0d9fce0180e8aa2a947267f89b725091 | int ff_h264_decode_sei(H264Context *h)
{
while (get_bits_left(&h->gb) > 16) {
int size = 0;
int type = 0;
int ret = 0;
int last = 0;
while (get_bits_left(&h->gb) >= 8 &&
(last = get_bits(&h->gb, 8)) == 255) {
type += 255;
}
type += last;
last = 0;
while (get_bits_left(&h->gb) >= 8 &&
(last = get_bits(&h->gb, 8)) == 255) {
size += 255;
}
size += last;
if (size > get_bits_left(&h->gb) / 8) {
av_log(h->avctx, AV_LOG_ERROR, "SEI type %d truncated at %d\n",
type, get_bits_left(&h->gb));
return AVERROR_INVALIDDATA;
}
switch (type) {
case SEI_TYPE_PIC_TIMING:
ret = decode_picture_timing(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
ret = decode_unregistered_user_data(h, size);
if (ret < 0)
return ret;
break;
case SEI_TYPE_RECOVERY_POINT:
ret = decode_recovery_point(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_BUFFERING_PERIOD:
ret = decode_buffering_period(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_FRAME_PACKING:
ret = decode_frame_packing_arrangement(h);
if (ret < 0)
return ret;
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
ret = decode_display_orientation(h);
if (ret < 0)
return ret;
break;
default:
av_log(h->avctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
skip_bits(&h->gb, 8 * size);
}
align_get_bits(&h->gb);
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(H264Context *VAR_0)
{
while (get_bits_left(&VAR_0->gb) > 16) {
int VAR_1 = 0;
int VAR_2 = 0;
int VAR_3 = 0;
int VAR_4 = 0;
while (get_bits_left(&VAR_0->gb) >= 8 &&
(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {
VAR_2 += 255;
}
VAR_2 += VAR_4;
VAR_4 = 0;
while (get_bits_left(&VAR_0->gb) >= 8 &&
(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {
VAR_1 += 255;
}
VAR_1 += VAR_4;
if (VAR_1 > get_bits_left(&VAR_0->gb) / 8) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "SEI VAR_2 %d truncated at %d\n",
VAR_2, get_bits_left(&VAR_0->gb));
return AVERROR_INVALIDDATA;
}
switch (VAR_2) {
case SEI_TYPE_PIC_TIMING:
VAR_3 = decode_picture_timing(VAR_0);
if (VAR_3 < 0)
return VAR_3;
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
VAR_3 = decode_unregistered_user_data(VAR_0, VAR_1);
if (VAR_3 < 0)
return VAR_3;
break;
case SEI_TYPE_RECOVERY_POINT:
VAR_3 = decode_recovery_point(VAR_0);
if (VAR_3 < 0)
return VAR_3;
break;
case SEI_TYPE_BUFFERING_PERIOD:
VAR_3 = decode_buffering_period(VAR_0);
if (VAR_3 < 0)
return VAR_3;
break;
case SEI_TYPE_FRAME_PACKING:
VAR_3 = decode_frame_packing_arrangement(VAR_0);
if (VAR_3 < 0)
return VAR_3;
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
VAR_3 = decode_display_orientation(VAR_0);
if (VAR_3 < 0)
return VAR_3;
break;
default:
av_log(VAR_0->avctx, AV_LOG_DEBUG, "unknown SEI VAR_2 %d\n", VAR_2);
skip_bits(&VAR_0->gb, 8 * VAR_1);
}
align_get_bits(&VAR_0->gb);
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0)\n{",
"while (get_bits_left(&VAR_0->gb) > 16) {",
"int VAR_1 = 0;",
"int VAR_2 = 0;",
"int VAR_3 = 0;",
"int VAR_4 = 0;",
"while (get_bits_left(&VAR_0->gb) >= 8 &&\n(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {",
"VAR_2 += 255;",
"}",
"VAR_2 += VAR_4;",
"VAR_4 = 0;",
"while (get_bits_left(&VAR_0->gb) >= 8 &&\n(VAR_4 = get_bits(&VAR_0->gb, 8)) == 255) {",
"VAR_1 += 255;",
"}",
"VAR_1 += VAR_4;",
"if (VAR_1 > get_bits_left(&VAR_0->gb) / 8) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"SEI VAR_2 %d truncated at %d\\n\",\nVAR_2, get_bits_left(&VAR_0->gb));",
"return AVERROR_INVALIDDATA;",
"}",
"switch (VAR_2) {",
"case SEI_TYPE_PIC_TIMING:\nVAR_3 = decode_picture_timing(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"case SEI_TYPE_USER_DATA_UNREGISTERED:\nVAR_3 = decode_unregistered_user_data(VAR_0, VAR_1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"case SEI_TYPE_RECOVERY_POINT:\nVAR_3 = decode_recovery_point(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"case SEI_TYPE_BUFFERING_PERIOD:\nVAR_3 = decode_buffering_period(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"case SEI_TYPE_FRAME_PACKING:\nVAR_3 = decode_frame_packing_arrangement(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"case SEI_TYPE_DISPLAY_ORIENTATION:\nVAR_3 = decode_display_orientation(VAR_0);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"unknown SEI VAR_2 %d\\n\", VAR_2);",
"skip_bits(&VAR_0->gb, 8 * VAR_1);",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
129
],
[
131
],
[
135
],
[
137
]
] |
21,886 | av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
int fullRange, int brightness,
int contrast, int saturation)
{
const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR24 ||
c->dstFormat == AV_PIX_FMT_RGB565BE ||
c->dstFormat == AV_PIX_FMT_RGB565LE ||
c->dstFormat == AV_PIX_FMT_RGB555BE ||
c->dstFormat == AV_PIX_FMT_RGB555LE ||
c->dstFormat == AV_PIX_FMT_RGB444BE ||
c->dstFormat == AV_PIX_FMT_RGB444LE ||
c->dstFormat == AV_PIX_FMT_RGB8 ||
c->dstFormat == AV_PIX_FMT_RGB4 ||
c->dstFormat == AV_PIX_FMT_RGB4_BYTE ||
c->dstFormat == AV_PIX_FMT_MONOBLACK;
const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int i, base, rbase, gbase, bbase, abase, needAlpha;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1 << 16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy * 255) / 219;
oy = 16 << 16;
} else {
crv = (crv * 224) / 255;
cbu = (cbu * 224) / 255;
cgu = (cgu * 224) / 255;
cgv = (cgv * 224) / 255;
}
cy = (cy * contrast) >> 16;
crv = (crv * contrast * saturation) >> 32;
cbu = (cbu * contrast * saturation) >> 32;
cgu = (cgu * contrast * saturation) >> 32;
cgv = (cgv * contrast * saturation) >> 32;
oy -= 256 * brightness;
c->uOffset = 0x0400040004000400LL;
c->vOffset = 0x0400040004000400LL;
c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
//scale coefficients by cy
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (bpp) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4 | 128:
rbase = isRgb ? 3 : 0;
gbase = 1;
bbase = isRgb ? 0 : 3;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 110] = (yval >> 7) << rbase;
y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
y_table[i + 110 + 2048] = (yval >> 7) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
rbase = isRgb ? 5 : 0;
gbase = isRgb ? 2 : 3;
bbase = isRgb ? 0 : 6;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 38; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 16] = ((yval + 18) / 36) << rbase;
y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
rbase = isRgb ? 8 : 0;
gbase = 4;
bbase = isRgb ? 0 : 8;
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 4) << rbase;
y_table16[i + 1024] = (yval >> 4) << gbase;
y_table16[i + 2048] = (yval >> 4) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
rbase = isRgb ? bpp - 5 : 0;
gbase = 5;
bbase = isRgb ? 0 : (bpp - 5);
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 3) << rbase;
y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
y_table16[i + 2048] = (yval >> 3) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = (base + 24) & 31;
c->yuvTable = av_malloc(1024 * 3 * 4);
y_table32 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i] = (yval << rbase) +
(needAlpha ? 0 : (255u << abase));
y_table32[i + 1024] = yval << gbase;
y_table32[i + 2048] = yval << bbase;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
if(!isPlanar(c->dstFormat) || bpp <= 24)
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
return 0;
}
| false | FFmpeg | 1dd797e3c9f179f957316a0becbec048b42df8aa | av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
int fullRange, int brightness,
int contrast, int saturation)
{
const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR24 ||
c->dstFormat == AV_PIX_FMT_RGB565BE ||
c->dstFormat == AV_PIX_FMT_RGB565LE ||
c->dstFormat == AV_PIX_FMT_RGB555BE ||
c->dstFormat == AV_PIX_FMT_RGB555LE ||
c->dstFormat == AV_PIX_FMT_RGB444BE ||
c->dstFormat == AV_PIX_FMT_RGB444LE ||
c->dstFormat == AV_PIX_FMT_RGB8 ||
c->dstFormat == AV_PIX_FMT_RGB4 ||
c->dstFormat == AV_PIX_FMT_RGB4_BYTE ||
c->dstFormat == AV_PIX_FMT_MONOBLACK;
const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
const int bpp = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int i, base, rbase, gbase, bbase, abase, needAlpha;
const int yoffs = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1 << 16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy * 255) / 219;
oy = 16 << 16;
} else {
crv = (crv * 224) / 255;
cbu = (cbu * 224) / 255;
cgu = (cgu * 224) / 255;
cgv = (cgv * 224) / 255;
}
cy = (cy * contrast) >> 16;
crv = (crv * contrast * saturation) >> 32;
cbu = (cbu * contrast * saturation) >> 32;
cgu = (cgu * contrast * saturation) >> 32;
cgv = (cgv * contrast * saturation) >> 32;
oy -= 256 * brightness;
c->uOffset = 0x0400040004000400LL;
c->vOffset = 0x0400040004000400LL;
c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (bpp) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4 | 128:
rbase = isRgb ? 3 : 0;
gbase = 1;
bbase = isRgb ? 0 : 3;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 110; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 110] = (yval >> 7) << rbase;
y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
y_table[i + 110 + 2048] = (yval >> 7) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
rbase = isRgb ? 5 : 0;
gbase = isRgb ? 2 : 3;
bbase = isRgb ? 0 : 6;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024 - 38; i++) {
int yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table[i + 16] = ((yval + 18) / 36) << rbase;
y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
rbase = isRgb ? 8 : 0;
gbase = 4;
bbase = isRgb ? 0 : 8;
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 4) << rbase;
y_table16[i + 1024] = (yval >> 4) << gbase;
y_table16[i + 2048] = (yval >> 4) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
rbase = isRgb ? bpp - 5 : 0;
gbase = 5;
bbase = isRgb ? 0 : (bpp - 5);
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[i] = (yval >> 3) << rbase;
y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
y_table16[i + 2048] = (yval >> 3) << bbase;
yb += cy;
}
if (isNotNe)
for (i = 0; i < 1024 * 3; i++)
y_table16[i] = av_bswap16(y_table16[i]);
fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + yoffs);
fill_table(c->table_gU, 1, cgu, y_table + yoffs);
fill_table(c->table_bU, 1, cbu, y_table + yoffs);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
gbase = base + 8;
bbase = base + (isRgb ? 0 : 16);
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!needAlpha)
abase = (base + 24) & 31;
c->yuvTable = av_malloc(1024 * 3 * 4);
y_table32 = c->yuvTable;
yb = -(384 << 16) - oy;
for (i = 0; i < 1024; i++) {
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[i] = (yval << rbase) +
(needAlpha ? 0 : (255u << abase));
y_table32[i + 1024] = yval << gbase;
y_table32[i + 2048] = yval << bbase;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
if(!isPlanar(c->dstFormat) || bpp <= 24)
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(SwsContext *c, const int inv_table[4],
int fullRange, int brightness,
int contrast, int saturation)
{
const int VAR_0 = c->dstFormat == AV_PIX_FMT_RGB32 ||
c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR24 ||
c->dstFormat == AV_PIX_FMT_RGB565BE ||
c->dstFormat == AV_PIX_FMT_RGB565LE ||
c->dstFormat == AV_PIX_FMT_RGB555BE ||
c->dstFormat == AV_PIX_FMT_RGB555LE ||
c->dstFormat == AV_PIX_FMT_RGB444BE ||
c->dstFormat == AV_PIX_FMT_RGB444LE ||
c->dstFormat == AV_PIX_FMT_RGB8 ||
c->dstFormat == AV_PIX_FMT_RGB4 ||
c->dstFormat == AV_PIX_FMT_RGB4_BYTE ||
c->dstFormat == AV_PIX_FMT_MONOBLACK;
const int VAR_1 = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
const int VAR_2 = c->dstFormatBpp;
uint8_t *y_table;
uint16_t *y_table16;
uint32_t *y_table32;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
const int VAR_10 = fullRange ? 384 : 326;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1 << 16;
int64_t oy = 0;
int64_t yb = 0;
if (!fullRange) {
cy = (cy * 255) / 219;
oy = 16 << 16;
} else {
crv = (crv * 224) / 255;
cbu = (cbu * 224) / 255;
cgu = (cgu * 224) / 255;
cgv = (cgv * 224) / 255;
}
cy = (cy * contrast) >> 16;
crv = (crv * contrast * saturation) >> 32;
cbu = (cbu * contrast * saturation) >> 32;
cgu = (cgu * contrast * saturation) >> 32;
cgv = (cgv * contrast * saturation) >> 32;
oy -= 256 * brightness;
c->uOffset = 0x0400040004000400LL;
c->vOffset = 0x0400040004000400LL;
c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
crv = ((crv << 16) + 0x8000) / cy;
cbu = ((cbu << 16) + 0x8000) / cy;
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
av_free(c->yuvTable);
switch (VAR_2) {
case 1:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024 - 110; VAR_3++) {
y_table[VAR_3 + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
yb += cy;
}
fill_table(c->table_gU, 1, cgu, y_table + VAR_10);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 4:
case 4 | 128:
VAR_5 = VAR_0 ? 3 : 0;
VAR_6 = 1;
VAR_7 = VAR_0 ? 0 : 3;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024 - 110; VAR_3++) {
int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table[VAR_3 + 110] = (VAR_12 >> 7) << VAR_5;
y_table[VAR_3 + 37 + 1024] = ((VAR_12 + 43) / 85) << VAR_6;
y_table[VAR_3 + 110 + 2048] = (VAR_12 >> 7) << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 8:
VAR_5 = VAR_0 ? 5 : 0;
VAR_6 = VAR_0 ? 2 : 3;
VAR_7 = VAR_0 ? 0 : 6;
c->yuvTable = av_malloc(1024 * 3);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024 - 38; VAR_3++) {
int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table[VAR_3 + 16] = ((VAR_12 + 18) / 36) << VAR_5;
y_table[VAR_3 + 16 + 1024] = ((VAR_12 + 18) / 36) << VAR_6;
y_table[VAR_3 + 37 + 2048] = ((VAR_12 + 43) / 85) << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 12:
VAR_5 = VAR_0 ? 8 : 0;
VAR_6 = 4;
VAR_7 = VAR_0 ? 0 : 8;
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[VAR_3] = (VAR_12 >> 4) << VAR_5;
y_table16[VAR_3 + 1024] = (VAR_12 >> 4) << VAR_6;
y_table16[VAR_3 + 2048] = (VAR_12 >> 4) << VAR_7;
yb += cy;
}
if (VAR_1)
for (VAR_3 = 0; VAR_3 < 1024 * 3; VAR_3++)
y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);
fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);
fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 15:
case 16:
VAR_5 = VAR_0 ? VAR_2 - 5 : 0;
VAR_6 = 5;
VAR_7 = VAR_0 ? 0 : (VAR_2 - 5);
c->yuvTable = av_malloc(1024 * 3 * 2);
y_table16 = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table16[VAR_3] = (VAR_12 >> 3) << VAR_5;
y_table16[VAR_3 + 1024] = (VAR_12 >> (18 - VAR_2)) << VAR_6;
y_table16[VAR_3 + 2048] = (VAR_12 >> 3) << VAR_7;
yb += cy;
}
if (VAR_1)
for (VAR_3 = 0; VAR_3 < 1024 * 3; VAR_3++)
y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);
fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);
fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);
fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 2, cgv);
break;
case 24:
case 48:
c->yuvTable = av_malloc(1024);
y_table = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
y_table[VAR_3] = av_clip_uint8((yb + 0x8000) >> 16);
yb += cy;
}
fill_table(c->table_rV, 1, crv, y_table + VAR_10);
fill_table(c->table_gU, 1, cgu, y_table + VAR_10);
fill_table(c->table_bU, 1, cbu, y_table + VAR_10);
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
VAR_4 = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
VAR_5 = VAR_4 + (VAR_0 ? 16 : 0);
VAR_6 = VAR_4 + 8;
VAR_7 = VAR_4 + (VAR_0 ? 0 : 16);
VAR_9 = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
if (!VAR_9)
VAR_8 = (VAR_4 + 24) & 31;
c->yuvTable = av_malloc(1024 * 3 * 4);
y_table32 = c->yuvTable;
yb = -(384 << 16) - oy;
for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {
unsigned VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);
y_table32[VAR_3] = (VAR_12 << VAR_5) +
(VAR_9 ? 0 : (255u << VAR_8));
y_table32[VAR_3 + 1024] = VAR_12 << VAR_6;
y_table32[VAR_3 + 2048] = VAR_12 << VAR_7;
yb += cy;
}
fill_table(c->table_rV, 4, crv, y_table32 + VAR_10);
fill_table(c->table_gU, 4, cgu, y_table32 + VAR_10 + 1024);
fill_table(c->table_bU, 4, cbu, y_table32 + VAR_10 + 2048);
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
c->yuvTable = NULL;
if(!isPlanar(c->dstFormat) || VAR_2 <= 24)
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", VAR_2);
return -1;
}
return 0;
}
| [
"av_cold int FUNC_0(SwsContext *c, const int inv_table[4],\nint fullRange, int brightness,\nint contrast, int saturation)\n{",
"const int VAR_0 = c->dstFormat == AV_PIX_FMT_RGB32 ||\nc->dstFormat == AV_PIX_FMT_RGB32_1 ||\nc->dstFormat == AV_PIX_FMT_BGR24 ||\nc->dstFormat == AV_PIX_FMT_RGB565BE ||\nc->dstFormat == AV_PIX_FMT_RGB565LE ||\nc->dstFormat == AV_PIX_FMT_RGB555BE ||\nc->dstFormat == AV_PIX_FMT_RGB555LE ||\nc->dstFormat == AV_PIX_FMT_RGB444BE ||\nc->dstFormat == AV_PIX_FMT_RGB444LE ||\nc->dstFormat == AV_PIX_FMT_RGB8 ||\nc->dstFormat == AV_PIX_FMT_RGB4 ||\nc->dstFormat == AV_PIX_FMT_RGB4_BYTE ||\nc->dstFormat == AV_PIX_FMT_MONOBLACK;",
"const int VAR_1 = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||\nc->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||\nc->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||\nc->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||\nc->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||\nc->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);",
"const int VAR_2 = c->dstFormatBpp;",
"uint8_t *y_table;",
"uint16_t *y_table16;",
"uint32_t *y_table32;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"const int VAR_10 = fullRange ? 384 : 326;",
"int64_t crv = inv_table[0];",
"int64_t cbu = inv_table[1];",
"int64_t cgu = -inv_table[2];",
"int64_t cgv = -inv_table[3];",
"int64_t cy = 1 << 16;",
"int64_t oy = 0;",
"int64_t yb = 0;",
"if (!fullRange) {",
"cy = (cy * 255) / 219;",
"oy = 16 << 16;",
"} else {",
"crv = (crv * 224) / 255;",
"cbu = (cbu * 224) / 255;",
"cgu = (cgu * 224) / 255;",
"cgv = (cgv * 224) / 255;",
"}",
"cy = (cy * contrast) >> 16;",
"crv = (crv * contrast * saturation) >> 32;",
"cbu = (cbu * contrast * saturation) >> 32;",
"cgu = (cgu * contrast * saturation) >> 32;",
"cgv = (cgv * contrast * saturation) >> 32;",
"oy -= 256 * brightness;",
"c->uOffset = 0x0400040004000400LL;",
"c->vOffset = 0x0400040004000400LL;",
"c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;",
"c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;",
"c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;",
"c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;",
"c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;",
"c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;",
"c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);",
"c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);",
"c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);",
"c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);",
"c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);",
"c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);",
"crv = ((crv << 16) + 0x8000) / cy;",
"cbu = ((cbu << 16) + 0x8000) / cy;",
"cgu = ((cgu << 16) + 0x8000) / cy;",
"cgv = ((cgv << 16) + 0x8000) / cy;",
"av_free(c->yuvTable);",
"switch (VAR_2) {",
"case 1:\nc->yuvTable = av_malloc(1024);",
"y_table = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024 - 110; VAR_3++) {",
"y_table[VAR_3 + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;",
"yb += cy;",
"}",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 4:\ncase 4 | 128:\nVAR_5 = VAR_0 ? 3 : 0;",
"VAR_6 = 1;",
"VAR_7 = VAR_0 ? 0 : 3;",
"c->yuvTable = av_malloc(1024 * 3);",
"y_table = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024 - 110; VAR_3++) {",
"int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table[VAR_3 + 110] = (VAR_12 >> 7) << VAR_5;",
"y_table[VAR_3 + 37 + 1024] = ((VAR_12 + 43) / 85) << VAR_6;",
"y_table[VAR_3 + 110 + 2048] = (VAR_12 >> 7) << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 8:\nVAR_5 = VAR_0 ? 5 : 0;",
"VAR_6 = VAR_0 ? 2 : 3;",
"VAR_7 = VAR_0 ? 0 : 6;",
"c->yuvTable = av_malloc(1024 * 3);",
"y_table = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024 - 38; VAR_3++) {",
"int VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table[VAR_3 + 16] = ((VAR_12 + 18) / 36) << VAR_5;",
"y_table[VAR_3 + 16 + 1024] = ((VAR_12 + 18) / 36) << VAR_6;",
"y_table[VAR_3 + 37 + 2048] = ((VAR_12 + 43) / 85) << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10 + 1024);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 12:\nVAR_5 = VAR_0 ? 8 : 0;",
"VAR_6 = 4;",
"VAR_7 = VAR_0 ? 0 : 8;",
"c->yuvTable = av_malloc(1024 * 3 * 2);",
"y_table16 = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table16[VAR_3] = (VAR_12 >> 4) << VAR_5;",
"y_table16[VAR_3 + 1024] = (VAR_12 >> 4) << VAR_6;",
"y_table16[VAR_3 + 2048] = (VAR_12 >> 4) << VAR_7;",
"yb += cy;",
"}",
"if (VAR_1)\nfor (VAR_3 = 0; VAR_3 < 1024 * 3; VAR_3++)",
"y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);",
"fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);",
"fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);",
"fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 2, cgv);",
"break;",
"case 15:\ncase 16:\nVAR_5 = VAR_0 ? VAR_2 - 5 : 0;",
"VAR_6 = 5;",
"VAR_7 = VAR_0 ? 0 : (VAR_2 - 5);",
"c->yuvTable = av_malloc(1024 * 3 * 2);",
"y_table16 = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"uint8_t VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table16[VAR_3] = (VAR_12 >> 3) << VAR_5;",
"y_table16[VAR_3 + 1024] = (VAR_12 >> (18 - VAR_2)) << VAR_6;",
"y_table16[VAR_3 + 2048] = (VAR_12 >> 3) << VAR_7;",
"yb += cy;",
"}",
"if (VAR_1)\nfor (VAR_3 = 0; VAR_3 < 1024 * 3; VAR_3++)",
"y_table16[VAR_3] = av_bswap16(y_table16[VAR_3]);",
"fill_table(c->table_rV, 2, crv, y_table16 + VAR_10);",
"fill_table(c->table_gU, 2, cgu, y_table16 + VAR_10 + 1024);",
"fill_table(c->table_bU, 2, cbu, y_table16 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 2, cgv);",
"break;",
"case 24:\ncase 48:\nc->yuvTable = av_malloc(1024);",
"y_table = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"y_table[VAR_3] = av_clip_uint8((yb + 0x8000) >> 16);",
"yb += cy;",
"}",
"fill_table(c->table_rV, 1, crv, y_table + VAR_10);",
"fill_table(c->table_gU, 1, cgu, y_table + VAR_10);",
"fill_table(c->table_bU, 1, cbu, y_table + VAR_10);",
"fill_gv_table(c->table_gV, 1, cgv);",
"break;",
"case 32:\nVAR_4 = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||\nc->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;",
"VAR_5 = VAR_4 + (VAR_0 ? 16 : 0);",
"VAR_6 = VAR_4 + 8;",
"VAR_7 = VAR_4 + (VAR_0 ? 0 : 16);",
"VAR_9 = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);",
"if (!VAR_9)\nVAR_8 = (VAR_4 + 24) & 31;",
"c->yuvTable = av_malloc(1024 * 3 * 4);",
"y_table32 = c->yuvTable;",
"yb = -(384 << 16) - oy;",
"for (VAR_3 = 0; VAR_3 < 1024; VAR_3++) {",
"unsigned VAR_12 = av_clip_uint8((yb + 0x8000) >> 16);",
"y_table32[VAR_3] = (VAR_12 << VAR_5) +\n(VAR_9 ? 0 : (255u << VAR_8));",
"y_table32[VAR_3 + 1024] = VAR_12 << VAR_6;",
"y_table32[VAR_3 + 2048] = VAR_12 << VAR_7;",
"yb += cy;",
"}",
"fill_table(c->table_rV, 4, crv, y_table32 + VAR_10);",
"fill_table(c->table_gU, 4, cgu, y_table32 + VAR_10 + 1024);",
"fill_table(c->table_bU, 4, cbu, y_table32 + VAR_10 + 2048);",
"fill_gv_table(c->table_gV, 4, cgv);",
"break;",
"default:\nc->yuvTable = NULL;",
"if(!isPlanar(c->dstFormat) || VAR_2 <= 24)\nav_log(c, AV_LOG_ERROR, \"%ibpp not supported by yuv2rgb\\n\", VAR_2);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33
],
[
35,
37,
39,
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
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
]
] |
21,887 | static int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
/* initialize to an impossible value which will force a recalculation
* in the first frame decode */
s->quality_index = -1;
s->superblock_width = (s->width + 31) / 32;
s->superblock_height = (s->height + 31) / 32;
s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;
s->u_superblock_start = s->superblock_width * s->superblock_height;
s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;
s->superblock_coding = av_malloc(s->superblock_count);
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width = s->width / FRAGMENT_PIXELS;
s->fragment_height = s->height / FRAGMENT_PIXELS;
/* fragment count covers all 8x8 blocks for all 3 planes */
s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
s->u_fragment_start = s->fragment_width * s->fragment_height;
s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;
debug_init(" width: %d x %d\n", s->width, s->height);
debug_init(" superblocks: %d x %d, %d total\n",
s->superblock_width, s->superblock_height, s->superblock_count);
debug_init(" macroblocks: %d x %d, %d total\n",
s->macroblock_width, s->macroblock_height, s->macroblock_count);
debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
s->fragment_count,
s->fragment_width,
s->fragment_height,
s->u_fragment_start,
s->v_fragment_start);
s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_inited = 0;
/* init VLC tables */
for (i = 0; i < 16; i++) {
/* Dc histograms */
init_vlc(&s->dc_vlc[i], 5, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2);
/* group 1 AC histograms */
init_vlc(&s->ac_vlc_1[i], 5, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2);
/* group 2 AC histograms */
init_vlc(&s->ac_vlc_2[i], 5, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2);
/* group 3 AC histograms */
init_vlc(&s->ac_vlc_3[i], 5, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2);
/* group 4 AC histograms */
init_vlc(&s->ac_vlc_4[i], 5, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2);
}
/* build quantization table */
for (i = 0; i < 64; i++)
quant_index[dequant_index[i]] = i;
/* work out the block mapping tables */
s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
s->macroblock_coded = av_malloc(s->macroblock_count + 1);
init_block_mapping(s);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return 0;
}
| false | FFmpeg | 892fc83e88a20f9543c6c5be3626712be7a2e6f2 | static int vp3_decode_init(AVCodecContext *avctx)
{
Vp3DecodeContext *s = avctx->priv_data;
int i;
s->avctx = avctx;
s->width = avctx->width;
s->height = avctx->height;
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
s->quality_index = -1;
s->superblock_width = (s->width + 31) / 32;
s->superblock_height = (s->height + 31) / 32;
s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;
s->u_superblock_start = s->superblock_width * s->superblock_height;
s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;
s->superblock_coding = av_malloc(s->superblock_count);
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width = s->width / FRAGMENT_PIXELS;
s->fragment_height = s->height / FRAGMENT_PIXELS;
s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
s->u_fragment_start = s->fragment_width * s->fragment_height;
s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;
debug_init(" width: %d x %d\n", s->width, s->height);
debug_init(" superblocks: %d x %d, %d total\n",
s->superblock_width, s->superblock_height, s->superblock_count);
debug_init(" macroblocks: %d x %d, %d total\n",
s->macroblock_width, s->macroblock_height, s->macroblock_count);
debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
s->fragment_count,
s->fragment_width,
s->fragment_height,
s->u_fragment_start,
s->v_fragment_start);
s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_inited = 0;
for (i = 0; i < 16; i++) {
init_vlc(&s->dc_vlc[i], 5, 32,
&dc_bias[i][0][1], 4, 2,
&dc_bias[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_1[i], 5, 32,
&ac_bias_0[i][0][1], 4, 2,
&ac_bias_0[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_2[i], 5, 32,
&ac_bias_1[i][0][1], 4, 2,
&ac_bias_1[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_3[i], 5, 32,
&ac_bias_2[i][0][1], 4, 2,
&ac_bias_2[i][0][0], 4, 2);
init_vlc(&s->ac_vlc_4[i], 5, 32,
&ac_bias_3[i][0][1], 4, 2,
&ac_bias_3[i][0][0], 4, 2);
}
for (i = 0; i < 64; i++)
quant_index[dequant_index[i]] = i;
s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
s->macroblock_coded = av_malloc(s->macroblock_count + 1);
init_block_mapping(s);
for (i = 0; i < 3; i++) {
s->current_frame.data[i] = NULL;
s->last_frame.data[i] = NULL;
s->golden_frame.data[i] = NULL;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
Vp3DecodeContext *s = VAR_0->priv_data;
int VAR_1;
s->VAR_0 = VAR_0;
s->width = VAR_0->width;
s->height = VAR_0->height;
VAR_0->pix_fmt = PIX_FMT_YUV420P;
VAR_0->has_b_frames = 0;
dsputil_init(&s->dsp, VAR_0);
s->quality_index = -1;
s->superblock_width = (s->width + 31) / 32;
s->superblock_height = (s->height + 31) / 32;
s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;
s->u_superblock_start = s->superblock_width * s->superblock_height;
s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;
s->superblock_coding = av_malloc(s->superblock_count);
s->macroblock_width = (s->width + 15) / 16;
s->macroblock_height = (s->height + 15) / 16;
s->macroblock_count = s->macroblock_width * s->macroblock_height;
s->fragment_width = s->width / FRAGMENT_PIXELS;
s->fragment_height = s->height / FRAGMENT_PIXELS;
s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
s->u_fragment_start = s->fragment_width * s->fragment_height;
s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;
debug_init(" width: %d x %d\n", s->width, s->height);
debug_init(" superblocks: %d x %d, %d total\n",
s->superblock_width, s->superblock_height, s->superblock_count);
debug_init(" macroblocks: %d x %d, %d total\n",
s->macroblock_width, s->macroblock_height, s->macroblock_count);
debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
s->fragment_count,
s->fragment_width,
s->fragment_height,
s->u_fragment_start,
s->v_fragment_start);
s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
s->pixel_addresses_inited = 0;
for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {
init_vlc(&s->dc_vlc[VAR_1], 5, 32,
&dc_bias[VAR_1][0][1], 4, 2,
&dc_bias[VAR_1][0][0], 4, 2);
init_vlc(&s->ac_vlc_1[VAR_1], 5, 32,
&ac_bias_0[VAR_1][0][1], 4, 2,
&ac_bias_0[VAR_1][0][0], 4, 2);
init_vlc(&s->ac_vlc_2[VAR_1], 5, 32,
&ac_bias_1[VAR_1][0][1], 4, 2,
&ac_bias_1[VAR_1][0][0], 4, 2);
init_vlc(&s->ac_vlc_3[VAR_1], 5, 32,
&ac_bias_2[VAR_1][0][1], 4, 2,
&ac_bias_2[VAR_1][0][0], 4, 2);
init_vlc(&s->ac_vlc_4[VAR_1], 5, 32,
&ac_bias_3[VAR_1][0][1], 4, 2,
&ac_bias_3[VAR_1][0][0], 4, 2);
}
for (VAR_1 = 0; VAR_1 < 64; VAR_1++)
quant_index[dequant_index[VAR_1]] = VAR_1;
s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
s->macroblock_coded = av_malloc(s->macroblock_count + 1);
init_block_mapping(s);
for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {
s->current_frame.data[VAR_1] = NULL;
s->last_frame.data[VAR_1] = NULL;
s->golden_frame.data[VAR_1] = NULL;
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"Vp3DecodeContext *s = VAR_0->priv_data;",
"int VAR_1;",
"s->VAR_0 = VAR_0;",
"s->width = VAR_0->width;",
"s->height = VAR_0->height;",
"VAR_0->pix_fmt = PIX_FMT_YUV420P;",
"VAR_0->has_b_frames = 0;",
"dsputil_init(&s->dsp, VAR_0);",
"s->quality_index = -1;",
"s->superblock_width = (s->width + 31) / 32;",
"s->superblock_height = (s->height + 31) / 32;",
"s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2;",
"s->u_superblock_start = s->superblock_width * s->superblock_height;",
"s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4;",
"s->superblock_coding = av_malloc(s->superblock_count);",
"s->macroblock_width = (s->width + 15) / 16;",
"s->macroblock_height = (s->height + 15) / 16;",
"s->macroblock_count = s->macroblock_width * s->macroblock_height;",
"s->fragment_width = s->width / FRAGMENT_PIXELS;",
"s->fragment_height = s->height / FRAGMENT_PIXELS;",
"s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;",
"s->u_fragment_start = s->fragment_width * s->fragment_height;",
"s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;",
"debug_init(\" width: %d x %d\\n\", s->width, s->height);",
"debug_init(\" superblocks: %d x %d, %d total\\n\",\ns->superblock_width, s->superblock_height, s->superblock_count);",
"debug_init(\" macroblocks: %d x %d, %d total\\n\",\ns->macroblock_width, s->macroblock_height, s->macroblock_count);",
"debug_init(\" %d fragments, %d x %d, u starts @ %d, v starts @ %d\\n\",\ns->fragment_count,\ns->fragment_width,\ns->fragment_height,\ns->u_fragment_start,\ns->v_fragment_start);",
"s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));",
"s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));",
"s->pixel_addresses_inited = 0;",
"for (VAR_1 = 0; VAR_1 < 16; VAR_1++) {",
"init_vlc(&s->dc_vlc[VAR_1], 5, 32,\n&dc_bias[VAR_1][0][1], 4, 2,\n&dc_bias[VAR_1][0][0], 4, 2);",
"init_vlc(&s->ac_vlc_1[VAR_1], 5, 32,\n&ac_bias_0[VAR_1][0][1], 4, 2,\n&ac_bias_0[VAR_1][0][0], 4, 2);",
"init_vlc(&s->ac_vlc_2[VAR_1], 5, 32,\n&ac_bias_1[VAR_1][0][1], 4, 2,\n&ac_bias_1[VAR_1][0][0], 4, 2);",
"init_vlc(&s->ac_vlc_3[VAR_1], 5, 32,\n&ac_bias_2[VAR_1][0][1], 4, 2,\n&ac_bias_2[VAR_1][0][0], 4, 2);",
"init_vlc(&s->ac_vlc_4[VAR_1], 5, 32,\n&ac_bias_3[VAR_1][0][1], 4, 2,\n&ac_bias_3[VAR_1][0][0], 4, 2);",
"}",
"for (VAR_1 = 0; VAR_1 < 64; VAR_1++)",
"quant_index[dequant_index[VAR_1]] = VAR_1;",
"s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));",
"s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));",
"s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));",
"s->macroblock_coded = av_malloc(s->macroblock_count + 1);",
"init_block_mapping(s);",
"for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {",
"s->current_frame.data[VAR_1] = NULL;",
"s->last_frame.data[VAR_1] = NULL;",
"s->golden_frame.data[VAR_1] = NULL;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77,
79
],
[
81,
83,
85,
87,
89,
91
],
[
95
],
[
97
],
[
99
],
[
105
],
[
111,
113,
115
],
[
121,
123,
125
],
[
131,
133,
135
],
[
141,
143,
145
],
[
151,
153,
155
],
[
157
],
[
163
],
[
165
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
]
] |
21,888 | static void gen_tlbsync(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_HV;
/* tlbsync is a nop for server, ptesync handles delayed tlb flush,
* embedded however needs to deal with tlbsync. We don't try to be
* fancy and swallow the overhead of checking for both.
*/
gen_check_tlb_flush(ctx);
#endif /* defined(CONFIG_USER_ONLY) */
}
| true | qemu | e3cffe6fad29e07d401eabb913a6d88501d5c143 | static void gen_tlbsync(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_HV;
gen_check_tlb_flush(ctx);
#endif
}
| {
"code": [
" gen_check_tlb_flush(ctx);"
],
"line_no": [
23
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
GEN_PRIV;
#else
CHK_HV;
gen_check_tlb_flush(VAR_0);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\nGEN_PRIV;",
"#else\nCHK_HV;",
"gen_check_tlb_flush(VAR_0);",
"#endif\n}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
23
],
[
25,
27
]
] |
21,890 | static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
{
int start = 0, i, w, w2, g, sid_sf_boost;
float M[128], S[128];
float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3;
const float lambda = s->lambda;
const float mslambda = FFMIN(1.0f, lambda / 120.f);
SingleChannelElement *sce0 = &cpe->ch[0];
SingleChannelElement *sce1 = &cpe->ch[1];
if (!cpe->common_window)
return;
for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
int min_sf_idx_mid = SCALE_MAX_POS;
int min_sf_idx_side = SCALE_MAX_POS;
for (g = 0; g < sce0->ics.num_swb; g++) {
if (!sce0->zeroes[w*16+g] && sce0->band_type[w*16+g] < RESERVED_BT)
min_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[w*16+g]);
if (!sce1->zeroes[w*16+g] && sce1->band_type[w*16+g] < RESERVED_BT)
min_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[w*16+g]);
}
start = 0;
for (g = 0; g < sce0->ics.num_swb; g++) {
float bmax = bval2bmax(g * 17.0f / sce0->ics.num_swb) / 0.0045f;
cpe->ms_mask[w*16+g] = 0;
if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {
float Mmax = 0.0f, Smax = 0.0f;
/* Must compute mid/side SF and book for the whole window group */
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
S[i] = M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
Mmax = FFMAX(Mmax, M34[i]);
Smax = FFMAX(Smax, S34[i]);
}
}
for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) {
float dist1 = 0.0f, dist2 = 0.0f;
int B0 = 0, B1 = 0;
int minidx;
int mididx, sididx;
int midcb, sidcb;
minidx = FFMIN(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]);
mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF);
sididx = av_clip(minidx - sid_sf_boost * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF);
midcb = find_min_book(Mmax, mididx);
sidcb = find_min_book(Smax, sididx);
if ((mididx > minidx) || (sididx > minidx)) {
/* scalefactor range violation, bad stuff, will decrease quality unacceptably */
continue;
}
/* No CB can be zero */
midcb = FFMAX(1,midcb);
sidcb = FFMAX(1,sidcb);
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
float minthr = FFMIN(band0->threshold, band1->threshold);
int b1,b2,b3,b4;
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
S[i] = M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
L34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[(w+w2)*16+g],
sce0->band_type[(w+w2)*16+g],
lambda / band0->threshold, INFINITY, &b1, NULL, 0);
dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
R34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[(w+w2)*16+g],
sce1->band_type[(w+w2)*16+g],
lambda / band1->threshold, INFINITY, &b2, NULL, 0);
dist2 += quantize_band_cost(s, M,
M34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[(w+w2)*16+g],
sce0->band_type[(w+w2)*16+g],
lambda / minthr, INFINITY, &b3, NULL, 0);
dist2 += quantize_band_cost(s, S,
S34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[(w+w2)*16+g],
sce1->band_type[(w+w2)*16+g],
mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0);
B0 += b1+b2;
B1 += b3+b4;
dist1 -= B0;
dist2 -= B1;
}
cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
if (cpe->ms_mask[w*16+g]) {
/* Setting the M/S mask is useful with I/S or PNS, but only the flag */
if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) {
sce0->sf_idx[w*16+g] = mididx;
sce1->sf_idx[w*16+g] = sididx;
sce0->band_type[w*16+g] = midcb;
sce1->band_type[w*16+g] = sidcb;
}
break;
} else if (B1 > B0) {
/* More boost won't fix this */
break;
}
}
}
start += sce0->ics.swb_sizes[g];
}
}
}
| true | FFmpeg | ca203e9985cd2dcf42a0c0853940850d3a8edf3a | static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
{
int start = 0, i, w, w2, g, sid_sf_boost;
float M[128], S[128];
float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3;
const float lambda = s->lambda;
const float mslambda = FFMIN(1.0f, lambda / 120.f);
SingleChannelElement *sce0 = &cpe->ch[0];
SingleChannelElement *sce1 = &cpe->ch[1];
if (!cpe->common_window)
return;
for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
int min_sf_idx_mid = SCALE_MAX_POS;
int min_sf_idx_side = SCALE_MAX_POS;
for (g = 0; g < sce0->ics.num_swb; g++) {
if (!sce0->zeroes[w*16+g] && sce0->band_type[w*16+g] < RESERVED_BT)
min_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[w*16+g]);
if (!sce1->zeroes[w*16+g] && sce1->band_type[w*16+g] < RESERVED_BT)
min_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[w*16+g]);
}
start = 0;
for (g = 0; g < sce0->ics.num_swb; g++) {
float bmax = bval2bmax(g * 17.0f / sce0->ics.num_swb) / 0.0045f;
cpe->ms_mask[w*16+g] = 0;
if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {
float Mmax = 0.0f, Smax = 0.0f;
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
S[i] = M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
Mmax = FFMAX(Mmax, M34[i]);
Smax = FFMAX(Smax, S34[i]);
}
}
for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) {
float dist1 = 0.0f, dist2 = 0.0f;
int B0 = 0, B1 = 0;
int minidx;
int mididx, sididx;
int midcb, sidcb;
minidx = FFMIN(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]);
mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF);
sididx = av_clip(minidx - sid_sf_boost * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF);
midcb = find_min_book(Mmax, mididx);
sidcb = find_min_book(Smax, sididx);
if ((mididx > minidx) || (sididx > minidx)) {
continue;
}
midcb = FFMAX(1,midcb);
sidcb = FFMAX(1,sidcb);
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
float minthr = FFMIN(band0->threshold, band1->threshold);
int b1,b2,b3,b4;
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
S[i] = M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
L34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[(w+w2)*16+g],
sce0->band_type[(w+w2)*16+g],
lambda / band0->threshold, INFINITY, &b1, NULL, 0);
dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
R34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[(w+w2)*16+g],
sce1->band_type[(w+w2)*16+g],
lambda / band1->threshold, INFINITY, &b2, NULL, 0);
dist2 += quantize_band_cost(s, M,
M34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[(w+w2)*16+g],
sce0->band_type[(w+w2)*16+g],
lambda / minthr, INFINITY, &b3, NULL, 0);
dist2 += quantize_band_cost(s, S,
S34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[(w+w2)*16+g],
sce1->band_type[(w+w2)*16+g],
mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0);
B0 += b1+b2;
B1 += b3+b4;
dist1 -= B0;
dist2 -= B1;
}
cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
if (cpe->ms_mask[w*16+g]) {
if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) {
sce0->sf_idx[w*16+g] = mididx;
sce1->sf_idx[w*16+g] = sididx;
sce0->band_type[w*16+g] = midcb;
sce1->band_type[w*16+g] = sidcb;
}
break;
} else if (B1 > B0) {
break;
}
}
}
start += sce0->ics.swb_sizes[g];
}
}
}
| {
"code": [
" int start = 0, i, w, w2, g, sid_sf_boost;",
" for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {",
" int min_sf_idx_mid = SCALE_MAX_POS;",
" int min_sf_idx_side = SCALE_MAX_POS;",
" for (g = 0; g < sce0->ics.num_swb; g++) {",
" if (!sce0->zeroes[w*16+g] && sce0->band_type[w*16+g] < RESERVED_BT)",
" min_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[w*16+g]);",
" if (!sce1->zeroes[w*16+g] && sce1->band_type[w*16+g] < RESERVED_BT)",
" min_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[w*16+g]);",
" if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {",
" mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF);",
" sididx = av_clip(minidx - sid_sf_boost * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF);",
" midcb = find_min_book(Mmax, mididx);",
" sidcb = find_min_book(Smax, sididx);",
" if ((mididx > minidx) || (sididx > minidx)) {",
" if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {"
],
"line_no": [
5,
23,
25,
27,
29,
31,
33,
35,
37,
51,
105,
107,
109,
111,
115,
51
]
} | static void FUNC_0(AACEncContext *VAR_0, ChannelElement *VAR_1)
{
int VAR_2 = 0, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
float VAR_8[128], VAR_9[128];
float *VAR_10 = VAR_0->scoefs, *VAR_11 = VAR_0->scoefs + 128, *VAR_12 = VAR_0->scoefs + 128*2, *VAR_13 = VAR_0->scoefs + 128*3;
const float VAR_14 = VAR_0->VAR_14;
const float VAR_15 = FFMIN(1.0f, VAR_14 / 120.f);
SingleChannelElement *sce0 = &VAR_1->ch[0];
SingleChannelElement *sce1 = &VAR_1->ch[1];
if (!VAR_1->common_window)
return;
for (VAR_4 = 0; VAR_4 < sce0->ics.num_windows; VAR_4 += sce0->ics.group_len[VAR_4]) {
int min_sf_idx_mid = SCALE_MAX_POS;
int min_sf_idx_side = SCALE_MAX_POS;
for (VAR_6 = 0; VAR_6 < sce0->ics.num_swb; VAR_6++) {
if (!sce0->zeroes[VAR_4*16+VAR_6] && sce0->band_type[VAR_4*16+VAR_6] < RESERVED_BT)
min_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[VAR_4*16+VAR_6]);
if (!sce1->zeroes[VAR_4*16+VAR_6] && sce1->band_type[VAR_4*16+VAR_6] < RESERVED_BT)
min_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[VAR_4*16+VAR_6]);
}
VAR_2 = 0;
for (VAR_6 = 0; VAR_6 < sce0->ics.num_swb; VAR_6++) {
float bmax = bval2bmax(VAR_6 * 17.0f / sce0->ics.num_swb) / 0.0045f;
VAR_1->ms_mask[VAR_4*16+VAR_6] = 0;
if (!VAR_1->ch[0].zeroes[VAR_4*16+VAR_6] && !VAR_1->ch[1].zeroes[VAR_4*16+VAR_6]) {
float Mmax = 0.0f, Smax = 0.0f;
for (VAR_5 = 0; VAR_5 < sce0->ics.group_len[VAR_4]; VAR_5++) {
for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++) {
VAR_8[VAR_3] = (sce0->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]
+ sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]) * 0.5;
VAR_9[VAR_3] = VAR_8[VAR_3]
- sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3];
}
abs_pow34_v(VAR_12, VAR_8, sce0->ics.swb_sizes[VAR_6]);
abs_pow34_v(VAR_13, VAR_9, sce0->ics.swb_sizes[VAR_6]);
for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++ ) {
Mmax = FFMAX(Mmax, VAR_12[VAR_3]);
Smax = FFMAX(Smax, VAR_13[VAR_3]);
}
}
for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {
float dist1 = 0.0f, dist2 = 0.0f;
int B0 = 0, B1 = 0;
int minidx;
int mididx, sididx;
int midcb, sidcb;
minidx = FFMIN(sce0->sf_idx[VAR_4*16+VAR_6], sce1->sf_idx[VAR_4*16+VAR_6]);
mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF);
sididx = av_clip(minidx - VAR_7 * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF);
midcb = find_min_book(Mmax, mididx);
sidcb = find_min_book(Smax, sididx);
if ((mididx > minidx) || (sididx > minidx)) {
continue;
}
midcb = FFMAX(1,midcb);
sidcb = FFMAX(1,sidcb);
for (VAR_5 = 0; VAR_5 < sce0->ics.group_len[VAR_4]; VAR_5++) {
FFPsyBand *band0 = &VAR_0->psy.ch[VAR_0->cur_channel+0].psy_bands[(VAR_4+VAR_5)*16+VAR_6];
FFPsyBand *band1 = &VAR_0->psy.ch[VAR_0->cur_channel+1].psy_bands[(VAR_4+VAR_5)*16+VAR_6];
float minthr = FFMIN(band0->threshold, band1->threshold);
int b1,b2,b3,b4;
for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++) {
VAR_8[VAR_3] = (sce0->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]
+ sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]) * 0.5;
VAR_9[VAR_3] = VAR_8[VAR_3]
- sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3];
}
abs_pow34_v(VAR_10, sce0->coeffs+VAR_2+(VAR_4+VAR_5)*128, sce0->ics.swb_sizes[VAR_6]);
abs_pow34_v(VAR_11, sce1->coeffs+VAR_2+(VAR_4+VAR_5)*128, sce0->ics.swb_sizes[VAR_6]);
abs_pow34_v(VAR_12, VAR_8, sce0->ics.swb_sizes[VAR_6]);
abs_pow34_v(VAR_13, VAR_9, sce0->ics.swb_sizes[VAR_6]);
dist1 += quantize_band_cost(VAR_0, &sce0->coeffs[VAR_2 + (VAR_4+VAR_5)*128],
VAR_10,
sce0->ics.swb_sizes[VAR_6],
sce0->sf_idx[(VAR_4+VAR_5)*16+VAR_6],
sce0->band_type[(VAR_4+VAR_5)*16+VAR_6],
VAR_14 / band0->threshold, INFINITY, &b1, NULL, 0);
dist1 += quantize_band_cost(VAR_0, &sce1->coeffs[VAR_2 + (VAR_4+VAR_5)*128],
VAR_11,
sce1->ics.swb_sizes[VAR_6],
sce1->sf_idx[(VAR_4+VAR_5)*16+VAR_6],
sce1->band_type[(VAR_4+VAR_5)*16+VAR_6],
VAR_14 / band1->threshold, INFINITY, &b2, NULL, 0);
dist2 += quantize_band_cost(VAR_0, VAR_8,
VAR_12,
sce0->ics.swb_sizes[VAR_6],
sce0->sf_idx[(VAR_4+VAR_5)*16+VAR_6],
sce0->band_type[(VAR_4+VAR_5)*16+VAR_6],
VAR_14 / minthr, INFINITY, &b3, NULL, 0);
dist2 += quantize_band_cost(VAR_0, VAR_9,
VAR_13,
sce1->ics.swb_sizes[VAR_6],
sce1->sf_idx[(VAR_4+VAR_5)*16+VAR_6],
sce1->band_type[(VAR_4+VAR_5)*16+VAR_6],
VAR_15 / (minthr * bmax), INFINITY, &b4, NULL, 0);
B0 += b1+b2;
B1 += b3+b4;
dist1 -= B0;
dist2 -= B1;
}
VAR_1->ms_mask[VAR_4*16+VAR_6] = dist2 <= dist1 && B1 < B0;
if (VAR_1->ms_mask[VAR_4*16+VAR_6]) {
if (!VAR_1->is_mask[VAR_4*16+VAR_6] && sce0->band_type[VAR_4*16+VAR_6] != NOISE_BT && sce1->band_type[VAR_4*16+VAR_6] != NOISE_BT) {
sce0->sf_idx[VAR_4*16+VAR_6] = mididx;
sce1->sf_idx[VAR_4*16+VAR_6] = sididx;
sce0->band_type[VAR_4*16+VAR_6] = midcb;
sce1->band_type[VAR_4*16+VAR_6] = sidcb;
}
break;
} else if (B1 > B0) {
break;
}
}
}
VAR_2 += sce0->ics.swb_sizes[VAR_6];
}
}
}
| [
"static void FUNC_0(AACEncContext *VAR_0, ChannelElement *VAR_1)\n{",
"int VAR_2 = 0, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"float VAR_8[128], VAR_9[128];",
"float *VAR_10 = VAR_0->scoefs, *VAR_11 = VAR_0->scoefs + 128, *VAR_12 = VAR_0->scoefs + 128*2, *VAR_13 = VAR_0->scoefs + 128*3;",
"const float VAR_14 = VAR_0->VAR_14;",
"const float VAR_15 = FFMIN(1.0f, VAR_14 / 120.f);",
"SingleChannelElement *sce0 = &VAR_1->ch[0];",
"SingleChannelElement *sce1 = &VAR_1->ch[1];",
"if (!VAR_1->common_window)\nreturn;",
"for (VAR_4 = 0; VAR_4 < sce0->ics.num_windows; VAR_4 += sce0->ics.group_len[VAR_4]) {",
"int min_sf_idx_mid = SCALE_MAX_POS;",
"int min_sf_idx_side = SCALE_MAX_POS;",
"for (VAR_6 = 0; VAR_6 < sce0->ics.num_swb; VAR_6++) {",
"if (!sce0->zeroes[VAR_4*16+VAR_6] && sce0->band_type[VAR_4*16+VAR_6] < RESERVED_BT)\nmin_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[VAR_4*16+VAR_6]);",
"if (!sce1->zeroes[VAR_4*16+VAR_6] && sce1->band_type[VAR_4*16+VAR_6] < RESERVED_BT)\nmin_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[VAR_4*16+VAR_6]);",
"}",
"VAR_2 = 0;",
"for (VAR_6 = 0; VAR_6 < sce0->ics.num_swb; VAR_6++) {",
"float bmax = bval2bmax(VAR_6 * 17.0f / sce0->ics.num_swb) / 0.0045f;",
"VAR_1->ms_mask[VAR_4*16+VAR_6] = 0;",
"if (!VAR_1->ch[0].zeroes[VAR_4*16+VAR_6] && !VAR_1->ch[1].zeroes[VAR_4*16+VAR_6]) {",
"float Mmax = 0.0f, Smax = 0.0f;",
"for (VAR_5 = 0; VAR_5 < sce0->ics.group_len[VAR_4]; VAR_5++) {",
"for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++) {",
"VAR_8[VAR_3] = (sce0->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]\n+ sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]) * 0.5;",
"VAR_9[VAR_3] = VAR_8[VAR_3]\n- sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3];",
"}",
"abs_pow34_v(VAR_12, VAR_8, sce0->ics.swb_sizes[VAR_6]);",
"abs_pow34_v(VAR_13, VAR_9, sce0->ics.swb_sizes[VAR_6]);",
"for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++ ) {",
"Mmax = FFMAX(Mmax, VAR_12[VAR_3]);",
"Smax = FFMAX(Smax, VAR_13[VAR_3]);",
"}",
"}",
"for (VAR_7 = 0; VAR_7 < 4; VAR_7++) {",
"float dist1 = 0.0f, dist2 = 0.0f;",
"int B0 = 0, B1 = 0;",
"int minidx;",
"int mididx, sididx;",
"int midcb, sidcb;",
"minidx = FFMIN(sce0->sf_idx[VAR_4*16+VAR_6], sce1->sf_idx[VAR_4*16+VAR_6]);",
"mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF);",
"sididx = av_clip(minidx - VAR_7 * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF);",
"midcb = find_min_book(Mmax, mididx);",
"sidcb = find_min_book(Smax, sididx);",
"if ((mididx > minidx) || (sididx > minidx)) {",
"continue;",
"}",
"midcb = FFMAX(1,midcb);",
"sidcb = FFMAX(1,sidcb);",
"for (VAR_5 = 0; VAR_5 < sce0->ics.group_len[VAR_4]; VAR_5++) {",
"FFPsyBand *band0 = &VAR_0->psy.ch[VAR_0->cur_channel+0].psy_bands[(VAR_4+VAR_5)*16+VAR_6];",
"FFPsyBand *band1 = &VAR_0->psy.ch[VAR_0->cur_channel+1].psy_bands[(VAR_4+VAR_5)*16+VAR_6];",
"float minthr = FFMIN(band0->threshold, band1->threshold);",
"int b1,b2,b3,b4;",
"for (VAR_3 = 0; VAR_3 < sce0->ics.swb_sizes[VAR_6]; VAR_3++) {",
"VAR_8[VAR_3] = (sce0->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]\n+ sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3]) * 0.5;",
"VAR_9[VAR_3] = VAR_8[VAR_3]\n- sce1->coeffs[VAR_2+(VAR_4+VAR_5)*128+VAR_3];",
"}",
"abs_pow34_v(VAR_10, sce0->coeffs+VAR_2+(VAR_4+VAR_5)*128, sce0->ics.swb_sizes[VAR_6]);",
"abs_pow34_v(VAR_11, sce1->coeffs+VAR_2+(VAR_4+VAR_5)*128, sce0->ics.swb_sizes[VAR_6]);",
"abs_pow34_v(VAR_12, VAR_8, sce0->ics.swb_sizes[VAR_6]);",
"abs_pow34_v(VAR_13, VAR_9, sce0->ics.swb_sizes[VAR_6]);",
"dist1 += quantize_band_cost(VAR_0, &sce0->coeffs[VAR_2 + (VAR_4+VAR_5)*128],\nVAR_10,\nsce0->ics.swb_sizes[VAR_6],\nsce0->sf_idx[(VAR_4+VAR_5)*16+VAR_6],\nsce0->band_type[(VAR_4+VAR_5)*16+VAR_6],\nVAR_14 / band0->threshold, INFINITY, &b1, NULL, 0);",
"dist1 += quantize_band_cost(VAR_0, &sce1->coeffs[VAR_2 + (VAR_4+VAR_5)*128],\nVAR_11,\nsce1->ics.swb_sizes[VAR_6],\nsce1->sf_idx[(VAR_4+VAR_5)*16+VAR_6],\nsce1->band_type[(VAR_4+VAR_5)*16+VAR_6],\nVAR_14 / band1->threshold, INFINITY, &b2, NULL, 0);",
"dist2 += quantize_band_cost(VAR_0, VAR_8,\nVAR_12,\nsce0->ics.swb_sizes[VAR_6],\nsce0->sf_idx[(VAR_4+VAR_5)*16+VAR_6],\nsce0->band_type[(VAR_4+VAR_5)*16+VAR_6],\nVAR_14 / minthr, INFINITY, &b3, NULL, 0);",
"dist2 += quantize_band_cost(VAR_0, VAR_9,\nVAR_13,\nsce1->ics.swb_sizes[VAR_6],\nsce1->sf_idx[(VAR_4+VAR_5)*16+VAR_6],\nsce1->band_type[(VAR_4+VAR_5)*16+VAR_6],\nVAR_15 / (minthr * bmax), INFINITY, &b4, NULL, 0);",
"B0 += b1+b2;",
"B1 += b3+b4;",
"dist1 -= B0;",
"dist2 -= B1;",
"}",
"VAR_1->ms_mask[VAR_4*16+VAR_6] = dist2 <= dist1 && B1 < B0;",
"if (VAR_1->ms_mask[VAR_4*16+VAR_6]) {",
"if (!VAR_1->is_mask[VAR_4*16+VAR_6] && sce0->band_type[VAR_4*16+VAR_6] != NOISE_BT && sce1->band_type[VAR_4*16+VAR_6] != NOISE_BT) {",
"sce0->sf_idx[VAR_4*16+VAR_6] = mididx;",
"sce1->sf_idx[VAR_4*16+VAR_6] = sididx;",
"sce0->band_type[VAR_4*16+VAR_6] = midcb;",
"sce1->band_type[VAR_4*16+VAR_6] = sidcb;",
"}",
"break;",
"} else if (B1 > B0) {",
"break;",
"}",
"}",
"}",
"VAR_2 += sce0->ics.swb_sizes[VAR_6];",
"}",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
127
],
[
129
],
[
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,
193,
195,
197,
199
],
[
201,
203,
205,
207,
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
]
] |
21,891 | static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
{
struct iovec *iov = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];
uint32_t csum_cntr;
uint16_t csum = 0;
uint32_t cso;
/* num of iovec without vhdr */
uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
uint16_t csl;
struct ip_header *iphdr;
size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;
/* Put zero to checksum field */
iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
/* Calculate L4 TCP/UDP checksum */
csl = pkt->payload_len;
/* add pseudo header to csum */
iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso);
/* data checksum */
csum_cntr +=
net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso);
/* Put the checksum obtained into the packet */
csum = cpu_to_be16(net_checksum_finish(csum_cntr));
iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
}
| true | qemu | 0dacea92d26c31d453c58de2e99c178fee554166 | static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt)
{
struct iovec *iov = &pkt->vec[NET_TX_PKT_L2HDR_FRAG];
uint32_t csum_cntr;
uint16_t csum = 0;
uint32_t cso;
uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
uint16_t csl;
struct ip_header *iphdr;
size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset;
iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
csl = pkt->payload_len;
iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso);
csum_cntr +=
net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso);
csum = cpu_to_be16(net_checksum_finish(csum_cntr));
iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum);
}
| {
"code": [
" csum = cpu_to_be16(net_checksum_finish(csum_cntr));"
],
"line_no": [
55
]
} | static void FUNC_0(struct NetTxPkt *VAR_0)
{
struct iovec *VAR_1 = &VAR_0->vec[NET_TX_PKT_L2HDR_FRAG];
uint32_t csum_cntr;
uint16_t csum = 0;
uint32_t cso;
uint32_t iov_len = VAR_0->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;
uint16_t csl;
struct ip_header *VAR_2;
size_t csum_offset = VAR_0->virt_hdr.csum_start + VAR_0->virt_hdr.csum_offset;
iov_from_buf(VAR_1, iov_len, csum_offset, &csum, sizeof csum);
csl = VAR_0->payload_len;
VAR_2 = VAR_0->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;
csum_cntr = eth_calc_ip4_pseudo_hdr_csum(VAR_2, csl, &cso);
csum_cntr +=
net_checksum_add_iov(VAR_1, iov_len, VAR_0->virt_hdr.csum_start, csl, cso);
csum = cpu_to_be16(net_checksum_finish(csum_cntr));
iov_from_buf(VAR_1, iov_len, csum_offset, &csum, sizeof csum);
}
| [
"static void FUNC_0(struct NetTxPkt *VAR_0)\n{",
"struct iovec *VAR_1 = &VAR_0->vec[NET_TX_PKT_L2HDR_FRAG];",
"uint32_t csum_cntr;",
"uint16_t csum = 0;",
"uint32_t cso;",
"uint32_t iov_len = VAR_0->payload_frags + NET_TX_PKT_PL_START_FRAG - 1;",
"uint16_t csl;",
"struct ip_header *VAR_2;",
"size_t csum_offset = VAR_0->virt_hdr.csum_start + VAR_0->virt_hdr.csum_offset;",
"iov_from_buf(VAR_1, iov_len, csum_offset, &csum, sizeof csum);",
"csl = VAR_0->payload_len;",
"VAR_2 = VAR_0->vec[NET_TX_PKT_L3HDR_FRAG].iov_base;",
"csum_cntr = eth_calc_ip4_pseudo_hdr_csum(VAR_2, csl, &cso);",
"csum_cntr +=\nnet_checksum_add_iov(VAR_1, iov_len, VAR_0->virt_hdr.csum_start, csl, cso);",
"csum = cpu_to_be16(net_checksum_finish(csum_cntr));",
"iov_from_buf(VAR_1, iov_len, csum_offset, &csum, sizeof csum);",
"}"
] | [
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
],
[
27
],
[
33
],
[
39
],
[
41
],
[
47,
49
],
[
55
],
[
57
],
[
59
]
] |
21,892 | static av_cold int xvid_encode_init(AVCodecContext *avctx)
{
int xerr, i, ret = -1;
int xvid_flags = avctx->flags;
struct xvid_context *x = avctx->priv_data;
uint16_t *intra, *inter;
int fd;
xvid_plugin_single_t single = { 0 };
struct xvid_ff_pass1 rc2pass1 = { 0 };
xvid_plugin_2pass2_t rc2pass2 = { 0 };
xvid_plugin_lumimasking_t masking_l = { 0 }; /* For lumi masking */
xvid_plugin_lumimasking_t masking_v = { 0 }; /* For variance AQ */
xvid_plugin_ssim_t ssim = { 0 };
xvid_gbl_init_t xvid_gbl_init = { 0 };
xvid_enc_create_t xvid_enc_create = { 0 };
xvid_enc_plugin_t plugins[4];
x->twopassfd = -1;
/* Bring in VOP flags from ffmpeg command-line */
x->vop_flags = XVID_VOP_HALFPEL; /* Bare minimum quality */
if (xvid_flags & AV_CODEC_FLAG_4MV)
x->vop_flags |= XVID_VOP_INTER4V; /* Level 3 */
if (avctx->trellis)
x->vop_flags |= XVID_VOP_TRELLISQUANT; /* Level 5 */
if (xvid_flags & AV_CODEC_FLAG_AC_PRED)
x->vop_flags |= XVID_VOP_HQACPRED; /* Level 6 */
if (xvid_flags & AV_CODEC_FLAG_GRAY)
x->vop_flags |= XVID_VOP_GREYSCALE;
/* Decide which ME quality setting to use */
x->me_flags = 0;
switch (x->me_quality) {
case 6:
case 5:
x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case 4:
case 3:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case 2:
case 1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
break;
default:
switch (avctx->me_method) {
case ME_FULL: /* Quality 6 */
x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case ME_EPZS: /* Quality 4 */
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case ME_LOG: /* Quality 2 */
case ME_PHODS:
case ME_X1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
case ME_ZERO: /* Quality 0 */
default:
break;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
/* Decide how we should decide blocks */
switch (avctx->mb_decision) {
case 2:
x->vop_flags |= XVID_VOP_MODEDECISION_RD;
x->me_flags |= XVID_ME_HALFPELREFINE8_RD |
XVID_ME_QUARTERPELREFINE8_RD |
XVID_ME_EXTSEARCH_RD |
XVID_ME_CHECKPREDICTION_RD;
case 1:
if (!(x->vop_flags & XVID_VOP_MODEDECISION_RD))
x->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD;
x->me_flags |= XVID_ME_HALFPELREFINE16_RD |
XVID_ME_QUARTERPELREFINE16_RD;
default:
break;
}
/* Bring in VOL flags from ffmpeg command-line */
#if FF_API_GMC
if (avctx->flags & CODEC_FLAG_GMC)
x->gmc = 1;
#endif
x->vol_flags = 0;
if (x->gmc) {
x->vol_flags |= XVID_VOL_GMC;
x->me_flags |= XVID_ME_GME_REFINE;
}
if (xvid_flags & AV_CODEC_FLAG_QPEL) {
x->vol_flags |= XVID_VOL_QUARTERPEL;
x->me_flags |= XVID_ME_QUARTERPELREFINE16;
if (x->vop_flags & XVID_VOP_INTER4V)
x->me_flags |= XVID_ME_QUARTERPELREFINE8;
}
xvid_gbl_init.version = XVID_VERSION;
xvid_gbl_init.debug = 0;
xvid_gbl_init.cpu_flags = 0;
/* Initialize */
xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
/* Create the encoder reference */
xvid_enc_create.version = XVID_VERSION;
/* Store the desired frame size */
xvid_enc_create.width =
x->xsize = avctx->width;
xvid_enc_create.height =
x->ysize = avctx->height;
/* Xvid can determine the proper profile to use */
/* xvid_enc_create.profile = XVID_PROFILE_S_L3; */
/* We don't use zones */
xvid_enc_create.zones = NULL;
xvid_enc_create.num_zones = 0;
xvid_enc_create.num_threads = avctx->thread_count;
#if (XVID_VERSION <= 0x010303) && (XVID_VERSION >= 0x010300)
/* workaround for a bug in libxvidcore */
if (avctx->height <= 16) {
if (avctx->thread_count < 2) {
xvid_enc_create.num_threads = 0;
} else {
av_log(avctx, AV_LOG_ERROR,
"Too small height for threads > 1.");
return AVERROR(EINVAL);
}
}
#endif
xvid_enc_create.plugins = plugins;
xvid_enc_create.num_plugins = 0;
/* Initialize Buffers */
x->twopassbuffer = NULL;
x->old_twopassbuffer = NULL;
x->twopassfile = NULL;
if (xvid_flags & AV_CODEC_FLAG_PASS1) {
rc2pass1.version = XVID_VERSION;
rc2pass1.context = x;
x->twopassbuffer = av_malloc(BUFFER_SIZE);
x->old_twopassbuffer = av_malloc(BUFFER_SIZE);
if (!x->twopassbuffer || !x->old_twopassbuffer) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: Cannot allocate 2-pass log buffers\n");
return AVERROR(ENOMEM);
}
x->twopassbuffer[0] =
x->old_twopassbuffer[0] = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;
plugins[xvid_enc_create.num_plugins].param = &rc2pass1;
xvid_enc_create.num_plugins++;
} else if (xvid_flags & AV_CODEC_FLAG_PASS2) {
rc2pass2.version = XVID_VERSION;
rc2pass2.bitrate = avctx->bit_rate;
fd = avpriv_tempfile("xvidff.", &x->twopassfile, 0, avctx);
if (fd < 0) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
return fd;
}
x->twopassfd = fd;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: No 2-pass information loaded for second pass\n");
return AVERROR(EINVAL);
}
ret = write(fd, avctx->stats_in, strlen(avctx->stats_in));
if (ret == -1)
ret = AVERROR(errno);
else if (strlen(avctx->stats_in) > ret) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n");
ret = AVERROR(EIO);
}
if (ret < 0)
return ret;
rc2pass2.filename = x->twopassfile;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
plugins[xvid_enc_create.num_plugins].param = &rc2pass2;
xvid_enc_create.num_plugins++;
} else if (!(xvid_flags & AV_CODEC_FLAG_QSCALE)) {
/* Single Pass Bitrate Control! */
single.version = XVID_VERSION;
single.bitrate = avctx->bit_rate;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;
plugins[xvid_enc_create.num_plugins].param = &single;
xvid_enc_create.num_plugins++;
}
if (avctx->lumi_masking != 0.0)
x->lumi_aq = 1;
/* Luminance Masking */
if (x->lumi_aq) {
masking_l.method = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
/* The old behavior is that when avctx->lumi_masking is specified,
* plugins[...].param = NULL. Trying to keep the old behavior here. */
plugins[xvid_enc_create.num_plugins].param =
avctx->lumi_masking ? NULL : &masking_l;
xvid_enc_create.num_plugins++;
}
/* Variance AQ */
if (x->variance_aq) {
masking_v.method = 1;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
plugins[xvid_enc_create.num_plugins].param = &masking_v;
xvid_enc_create.num_plugins++;
}
if (x->lumi_aq && x->variance_aq )
av_log(avctx, AV_LOG_INFO,
"Both lumi_aq and variance_aq are enabled. The resulting quality"
"will be the worse one of the two effects made by the AQ.\n");
/* SSIM */
if (x->ssim) {
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
ssim.b_printstat = x->ssim == 2;
ssim.acc = x->ssim_acc;
ssim.cpu_flags = xvid_gbl_init.cpu_flags;
ssim.b_visualize = 0;
plugins[xvid_enc_create.num_plugins].param = &ssim;
xvid_enc_create.num_plugins++;
}
/* Frame Rate and Key Frames */
xvid_correct_framerate(avctx);
xvid_enc_create.fincr = avctx->time_base.num;
xvid_enc_create.fbase = avctx->time_base.den;
if (avctx->gop_size > 0)
xvid_enc_create.max_key_interval = avctx->gop_size;
else
xvid_enc_create.max_key_interval = 240; /* Xvid's best default */
/* Quants */
if (xvid_flags & AV_CODEC_FLAG_QSCALE)
x->qscale = 1;
else
x->qscale = 0;
xvid_enc_create.min_quant[0] = avctx->qmin;
xvid_enc_create.min_quant[1] = avctx->qmin;
xvid_enc_create.min_quant[2] = avctx->qmin;
xvid_enc_create.max_quant[0] = avctx->qmax;
xvid_enc_create.max_quant[1] = avctx->qmax;
xvid_enc_create.max_quant[2] = avctx->qmax;
/* Quant Matrices */
x->intra_matrix =
x->inter_matrix = NULL;
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->mpeg_quant)
x->mpeg_quant = avctx->mpeg_quant;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (x->mpeg_quant)
x->vol_flags |= XVID_VOL_MPEGQUANT;
if ((avctx->intra_matrix || avctx->inter_matrix)) {
x->vol_flags |= XVID_VOL_MPEGQUANT;
if (avctx->intra_matrix) {
intra = avctx->intra_matrix;
x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->intra_matrix)
return AVERROR(ENOMEM);
} else
intra = NULL;
if (avctx->inter_matrix) {
inter = avctx->inter_matrix;
x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->inter_matrix)
return AVERROR(ENOMEM);
} else
inter = NULL;
for (i = 0; i < 64; i++) {
if (intra)
x->intra_matrix[i] = (unsigned char) intra[i];
if (inter)
x->inter_matrix[i] = (unsigned char) inter[i];
}
}
/* Misc Settings */
xvid_enc_create.frame_drop_ratio = 0;
xvid_enc_create.global = 0;
if (xvid_flags & AV_CODEC_FLAG_CLOSED_GOP)
xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;
/* Determines which codec mode we are operating in */
avctx->extradata = NULL;
avctx->extradata_size = 0;
if (xvid_flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
/* In this case, we are claiming to be MPEG4 */
x->quicktime_format = 1;
avctx->codec_id = AV_CODEC_ID_MPEG4;
} else {
/* We are claiming to be Xvid */
x->quicktime_format = 0;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("xvid");
}
/* Bframes */
xvid_enc_create.max_bframes = avctx->max_b_frames;
xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
if (avctx->max_b_frames > 0 && !x->quicktime_format)
xvid_enc_create.global |= XVID_GLOBAL_PACKED;
av_assert0(xvid_enc_create.num_plugins + (!!x->ssim) + (!!x->variance_aq) + (!!x->lumi_aq) <= FF_ARRAY_ELEMS(plugins));
/* Encode a dummy frame to get the extradata immediately */
if (x->quicktime_format) {
AVFrame *picture;
AVPacket packet;
int size, got_packet, ret;
av_init_packet(&packet);
picture = av_frame_alloc();
if (!picture)
return AVERROR(ENOMEM);
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if( xerr ) {
av_frame_free(&picture);
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
x->encoder_handle = xvid_enc_create.handle;
size = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
picture->data[0] = av_malloc(size + size / 2);
if (!picture->data[0]) {
av_frame_free(&picture);
return AVERROR(ENOMEM);
}
picture->data[1] = picture->data[0] + size;
picture->data[2] = picture->data[1] + size / 4;
memset(picture->data[0], 0, size);
memset(picture->data[1], 128, size / 2);
ret = xvid_encode_frame(avctx, &packet, picture, &got_packet);
if (!ret && got_packet)
av_packet_unref(&packet);
av_free(picture->data[0]);
av_frame_free(&picture);
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
}
/* Create encoder context */
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if (xerr) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
x->encoder_handle = xvid_enc_create.handle;
return 0;
}
| true | FFmpeg | 0b9b3163f2a9be54b986f1e7e7d55a88d1e2f2a8 | static av_cold int xvid_encode_init(AVCodecContext *avctx)
{
int xerr, i, ret = -1;
int xvid_flags = avctx->flags;
struct xvid_context *x = avctx->priv_data;
uint16_t *intra, *inter;
int fd;
xvid_plugin_single_t single = { 0 };
struct xvid_ff_pass1 rc2pass1 = { 0 };
xvid_plugin_2pass2_t rc2pass2 = { 0 };
xvid_plugin_lumimasking_t masking_l = { 0 };
xvid_plugin_lumimasking_t masking_v = { 0 };
xvid_plugin_ssim_t ssim = { 0 };
xvid_gbl_init_t xvid_gbl_init = { 0 };
xvid_enc_create_t xvid_enc_create = { 0 };
xvid_enc_plugin_t plugins[4];
x->twopassfd = -1;
x->vop_flags = XVID_VOP_HALFPEL;
if (xvid_flags & AV_CODEC_FLAG_4MV)
x->vop_flags |= XVID_VOP_INTER4V;
if (avctx->trellis)
x->vop_flags |= XVID_VOP_TRELLISQUANT;
if (xvid_flags & AV_CODEC_FLAG_AC_PRED)
x->vop_flags |= XVID_VOP_HQACPRED;
if (xvid_flags & AV_CODEC_FLAG_GRAY)
x->vop_flags |= XVID_VOP_GREYSCALE;
x->me_flags = 0;
switch (x->me_quality) {
case 6:
case 5:
x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case 4:
case 3:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case 2:
case 1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
break;
default:
switch (avctx->me_method) {
case ME_FULL:
x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case ME_EPZS:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case ME_LOG:
case ME_PHODS:
case ME_X1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
case ME_ZERO:
default:
break;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
switch (avctx->mb_decision) {
case 2:
x->vop_flags |= XVID_VOP_MODEDECISION_RD;
x->me_flags |= XVID_ME_HALFPELREFINE8_RD |
XVID_ME_QUARTERPELREFINE8_RD |
XVID_ME_EXTSEARCH_RD |
XVID_ME_CHECKPREDICTION_RD;
case 1:
if (!(x->vop_flags & XVID_VOP_MODEDECISION_RD))
x->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD;
x->me_flags |= XVID_ME_HALFPELREFINE16_RD |
XVID_ME_QUARTERPELREFINE16_RD;
default:
break;
}
#if FF_API_GMC
if (avctx->flags & CODEC_FLAG_GMC)
x->gmc = 1;
#endif
x->vol_flags = 0;
if (x->gmc) {
x->vol_flags |= XVID_VOL_GMC;
x->me_flags |= XVID_ME_GME_REFINE;
}
if (xvid_flags & AV_CODEC_FLAG_QPEL) {
x->vol_flags |= XVID_VOL_QUARTERPEL;
x->me_flags |= XVID_ME_QUARTERPELREFINE16;
if (x->vop_flags & XVID_VOP_INTER4V)
x->me_flags |= XVID_ME_QUARTERPELREFINE8;
}
xvid_gbl_init.version = XVID_VERSION;
xvid_gbl_init.debug = 0;
xvid_gbl_init.cpu_flags = 0;
xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
xvid_enc_create.version = XVID_VERSION;
xvid_enc_create.width =
x->xsize = avctx->width;
xvid_enc_create.height =
x->ysize = avctx->height;
xvid_enc_create.zones = NULL;
xvid_enc_create.num_zones = 0;
xvid_enc_create.num_threads = avctx->thread_count;
#if (XVID_VERSION <= 0x010303) && (XVID_VERSION >= 0x010300)
if (avctx->height <= 16) {
if (avctx->thread_count < 2) {
xvid_enc_create.num_threads = 0;
} else {
av_log(avctx, AV_LOG_ERROR,
"Too small height for threads > 1.");
return AVERROR(EINVAL);
}
}
#endif
xvid_enc_create.plugins = plugins;
xvid_enc_create.num_plugins = 0;
x->twopassbuffer = NULL;
x->old_twopassbuffer = NULL;
x->twopassfile = NULL;
if (xvid_flags & AV_CODEC_FLAG_PASS1) {
rc2pass1.version = XVID_VERSION;
rc2pass1.context = x;
x->twopassbuffer = av_malloc(BUFFER_SIZE);
x->old_twopassbuffer = av_malloc(BUFFER_SIZE);
if (!x->twopassbuffer || !x->old_twopassbuffer) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: Cannot allocate 2-pass log buffers\n");
return AVERROR(ENOMEM);
}
x->twopassbuffer[0] =
x->old_twopassbuffer[0] = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;
plugins[xvid_enc_create.num_plugins].param = &rc2pass1;
xvid_enc_create.num_plugins++;
} else if (xvid_flags & AV_CODEC_FLAG_PASS2) {
rc2pass2.version = XVID_VERSION;
rc2pass2.bitrate = avctx->bit_rate;
fd = avpriv_tempfile("xvidff.", &x->twopassfile, 0, avctx);
if (fd < 0) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
return fd;
}
x->twopassfd = fd;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: No 2-pass information loaded for second pass\n");
return AVERROR(EINVAL);
}
ret = write(fd, avctx->stats_in, strlen(avctx->stats_in));
if (ret == -1)
ret = AVERROR(errno);
else if (strlen(avctx->stats_in) > ret) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n");
ret = AVERROR(EIO);
}
if (ret < 0)
return ret;
rc2pass2.filename = x->twopassfile;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
plugins[xvid_enc_create.num_plugins].param = &rc2pass2;
xvid_enc_create.num_plugins++;
} else if (!(xvid_flags & AV_CODEC_FLAG_QSCALE)) {
single.version = XVID_VERSION;
single.bitrate = avctx->bit_rate;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;
plugins[xvid_enc_create.num_plugins].param = &single;
xvid_enc_create.num_plugins++;
}
if (avctx->lumi_masking != 0.0)
x->lumi_aq = 1;
if (x->lumi_aq) {
masking_l.method = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
plugins[xvid_enc_create.num_plugins].param =
avctx->lumi_masking ? NULL : &masking_l;
xvid_enc_create.num_plugins++;
}
if (x->variance_aq) {
masking_v.method = 1;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
plugins[xvid_enc_create.num_plugins].param = &masking_v;
xvid_enc_create.num_plugins++;
}
if (x->lumi_aq && x->variance_aq )
av_log(avctx, AV_LOG_INFO,
"Both lumi_aq and variance_aq are enabled. The resulting quality"
"will be the worse one of the two effects made by the AQ.\n");
if (x->ssim) {
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
ssim.b_printstat = x->ssim == 2;
ssim.acc = x->ssim_acc;
ssim.cpu_flags = xvid_gbl_init.cpu_flags;
ssim.b_visualize = 0;
plugins[xvid_enc_create.num_plugins].param = &ssim;
xvid_enc_create.num_plugins++;
}
xvid_correct_framerate(avctx);
xvid_enc_create.fincr = avctx->time_base.num;
xvid_enc_create.fbase = avctx->time_base.den;
if (avctx->gop_size > 0)
xvid_enc_create.max_key_interval = avctx->gop_size;
else
xvid_enc_create.max_key_interval = 240;
if (xvid_flags & AV_CODEC_FLAG_QSCALE)
x->qscale = 1;
else
x->qscale = 0;
xvid_enc_create.min_quant[0] = avctx->qmin;
xvid_enc_create.min_quant[1] = avctx->qmin;
xvid_enc_create.min_quant[2] = avctx->qmin;
xvid_enc_create.max_quant[0] = avctx->qmax;
xvid_enc_create.max_quant[1] = avctx->qmax;
xvid_enc_create.max_quant[2] = avctx->qmax;
x->intra_matrix =
x->inter_matrix = NULL;
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->mpeg_quant)
x->mpeg_quant = avctx->mpeg_quant;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (x->mpeg_quant)
x->vol_flags |= XVID_VOL_MPEGQUANT;
if ((avctx->intra_matrix || avctx->inter_matrix)) {
x->vol_flags |= XVID_VOL_MPEGQUANT;
if (avctx->intra_matrix) {
intra = avctx->intra_matrix;
x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->intra_matrix)
return AVERROR(ENOMEM);
} else
intra = NULL;
if (avctx->inter_matrix) {
inter = avctx->inter_matrix;
x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!x->inter_matrix)
return AVERROR(ENOMEM);
} else
inter = NULL;
for (i = 0; i < 64; i++) {
if (intra)
x->intra_matrix[i] = (unsigned char) intra[i];
if (inter)
x->inter_matrix[i] = (unsigned char) inter[i];
}
}
xvid_enc_create.frame_drop_ratio = 0;
xvid_enc_create.global = 0;
if (xvid_flags & AV_CODEC_FLAG_CLOSED_GOP)
xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;
avctx->extradata = NULL;
avctx->extradata_size = 0;
if (xvid_flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
x->quicktime_format = 1;
avctx->codec_id = AV_CODEC_ID_MPEG4;
} else {
x->quicktime_format = 0;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("xvid");
}
xvid_enc_create.max_bframes = avctx->max_b_frames;
xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
if (avctx->max_b_frames > 0 && !x->quicktime_format)
xvid_enc_create.global |= XVID_GLOBAL_PACKED;
av_assert0(xvid_enc_create.num_plugins + (!!x->ssim) + (!!x->variance_aq) + (!!x->lumi_aq) <= FF_ARRAY_ELEMS(plugins));
if (x->quicktime_format) {
AVFrame *picture;
AVPacket packet;
int size, got_packet, ret;
av_init_packet(&packet);
picture = av_frame_alloc();
if (!picture)
return AVERROR(ENOMEM);
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if( xerr ) {
av_frame_free(&picture);
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
x->encoder_handle = xvid_enc_create.handle;
size = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
picture->data[0] = av_malloc(size + size / 2);
if (!picture->data[0]) {
av_frame_free(&picture);
return AVERROR(ENOMEM);
}
picture->data[1] = picture->data[0] + size;
picture->data[2] = picture->data[1] + size / 4;
memset(picture->data[0], 0, size);
memset(picture->data[1], 128, size / 2);
ret = xvid_encode_frame(avctx, &packet, picture, &got_packet);
if (!ret && got_packet)
av_packet_unref(&packet);
av_free(picture->data[0]);
av_frame_free(&picture);
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
}
xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if (xerr) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
x->encoder_handle = xvid_enc_create.handle;
return 0;
}
| {
"code": [
" AVPacket packet;"
],
"line_no": [
687
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
int VAR_0, VAR_1, VAR_9 = -1;
int VAR_3 = avctx->flags;
struct xvid_context *VAR_4 = avctx->priv_data;
uint16_t *intra, *inter;
int VAR_5;
xvid_plugin_single_t single = { 0 };
struct xvid_ff_pass1 VAR_6 = { 0 };
xvid_plugin_2pass2_t rc2pass2 = { 0 };
xvid_plugin_lumimasking_t masking_l = { 0 };
xvid_plugin_lumimasking_t masking_v = { 0 };
xvid_plugin_ssim_t ssim = { 0 };
xvid_gbl_init_t xvid_gbl_init = { 0 };
xvid_enc_create_t xvid_enc_create = { 0 };
xvid_enc_plugin_t plugins[4];
VAR_4->twopassfd = -1;
VAR_4->vop_flags = XVID_VOP_HALFPEL;
if (VAR_3 & AV_CODEC_FLAG_4MV)
VAR_4->vop_flags |= XVID_VOP_INTER4V;
if (avctx->trellis)
VAR_4->vop_flags |= XVID_VOP_TRELLISQUANT;
if (VAR_3 & AV_CODEC_FLAG_AC_PRED)
VAR_4->vop_flags |= XVID_VOP_HQACPRED;
if (VAR_3 & AV_CODEC_FLAG_GRAY)
VAR_4->vop_flags |= XVID_VOP_GREYSCALE;
VAR_4->me_flags = 0;
switch (VAR_4->me_quality) {
case 6:
case 5:
VAR_4->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case 4:
case 3:
VAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case 2:
case 1:
VAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
break;
default:
switch (avctx->me_method) {
case ME_FULL:
VAR_4->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case ME_EPZS:
VAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case ME_LOG:
case ME_PHODS:
case ME_X1:
VAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
case ME_ZERO:
default:
break;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
switch (avctx->mb_decision) {
case 2:
VAR_4->vop_flags |= XVID_VOP_MODEDECISION_RD;
VAR_4->me_flags |= XVID_ME_HALFPELREFINE8_RD |
XVID_ME_QUARTERPELREFINE8_RD |
XVID_ME_EXTSEARCH_RD |
XVID_ME_CHECKPREDICTION_RD;
case 1:
if (!(VAR_4->vop_flags & XVID_VOP_MODEDECISION_RD))
VAR_4->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD;
VAR_4->me_flags |= XVID_ME_HALFPELREFINE16_RD |
XVID_ME_QUARTERPELREFINE16_RD;
default:
break;
}
#if FF_API_GMC
if (avctx->flags & CODEC_FLAG_GMC)
VAR_4->gmc = 1;
#endif
VAR_4->vol_flags = 0;
if (VAR_4->gmc) {
VAR_4->vol_flags |= XVID_VOL_GMC;
VAR_4->me_flags |= XVID_ME_GME_REFINE;
}
if (VAR_3 & AV_CODEC_FLAG_QPEL) {
VAR_4->vol_flags |= XVID_VOL_QUARTERPEL;
VAR_4->me_flags |= XVID_ME_QUARTERPELREFINE16;
if (VAR_4->vop_flags & XVID_VOP_INTER4V)
VAR_4->me_flags |= XVID_ME_QUARTERPELREFINE8;
}
xvid_gbl_init.version = XVID_VERSION;
xvid_gbl_init.debug = 0;
xvid_gbl_init.cpu_flags = 0;
xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
xvid_enc_create.version = XVID_VERSION;
xvid_enc_create.width =
VAR_4->xsize = avctx->width;
xvid_enc_create.height =
VAR_4->ysize = avctx->height;
xvid_enc_create.zones = NULL;
xvid_enc_create.num_zones = 0;
xvid_enc_create.num_threads = avctx->thread_count;
#if (XVID_VERSION <= 0x010303) && (XVID_VERSION >= 0x010300)
if (avctx->height <= 16) {
if (avctx->thread_count < 2) {
xvid_enc_create.num_threads = 0;
} else {
av_log(avctx, AV_LOG_ERROR,
"Too small height for threads > 1.");
return AVERROR(EINVAL);
}
}
#endif
xvid_enc_create.plugins = plugins;
xvid_enc_create.num_plugins = 0;
VAR_4->twopassbuffer = NULL;
VAR_4->old_twopassbuffer = NULL;
VAR_4->twopassfile = NULL;
if (VAR_3 & AV_CODEC_FLAG_PASS1) {
VAR_6.version = XVID_VERSION;
VAR_6.context = VAR_4;
VAR_4->twopassbuffer = av_malloc(BUFFER_SIZE);
VAR_4->old_twopassbuffer = av_malloc(BUFFER_SIZE);
if (!VAR_4->twopassbuffer || !VAR_4->old_twopassbuffer) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: Cannot allocate 2-pass log buffers\n");
return AVERROR(ENOMEM);
}
VAR_4->twopassbuffer[0] =
VAR_4->old_twopassbuffer[0] = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;
plugins[xvid_enc_create.num_plugins].param = &VAR_6;
xvid_enc_create.num_plugins++;
} else if (VAR_3 & AV_CODEC_FLAG_PASS2) {
rc2pass2.version = XVID_VERSION;
rc2pass2.bitrate = avctx->bit_rate;
VAR_5 = avpriv_tempfile("xvidff.", &VAR_4->twopassfile, 0, avctx);
if (VAR_5 < 0) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
return VAR_5;
}
VAR_4->twopassfd = VAR_5;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR,
"Xvid: No 2-pass information loaded for second pass\n");
return AVERROR(EINVAL);
}
VAR_9 = write(VAR_5, avctx->stats_in, strlen(avctx->stats_in));
if (VAR_9 == -1)
VAR_9 = AVERROR(errno);
else if (strlen(avctx->stats_in) > VAR_9) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n");
VAR_9 = AVERROR(EIO);
}
if (VAR_9 < 0)
return VAR_9;
rc2pass2.filename = VAR_4->twopassfile;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
plugins[xvid_enc_create.num_plugins].param = &rc2pass2;
xvid_enc_create.num_plugins++;
} else if (!(VAR_3 & AV_CODEC_FLAG_QSCALE)) {
single.version = XVID_VERSION;
single.bitrate = avctx->bit_rate;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;
plugins[xvid_enc_create.num_plugins].param = &single;
xvid_enc_create.num_plugins++;
}
if (avctx->lumi_masking != 0.0)
VAR_4->lumi_aq = 1;
if (VAR_4->lumi_aq) {
masking_l.method = 0;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
plugins[xvid_enc_create.num_plugins].param =
avctx->lumi_masking ? NULL : &masking_l;
xvid_enc_create.num_plugins++;
}
if (VAR_4->variance_aq) {
masking_v.method = 1;
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
plugins[xvid_enc_create.num_plugins].param = &masking_v;
xvid_enc_create.num_plugins++;
}
if (VAR_4->lumi_aq && VAR_4->variance_aq )
av_log(avctx, AV_LOG_INFO,
"Both lumi_aq and variance_aq are enabled. The resulting quality"
"will be the worse one of the two effects made by the AQ.\n");
if (VAR_4->ssim) {
plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
ssim.b_printstat = VAR_4->ssim == 2;
ssim.acc = VAR_4->ssim_acc;
ssim.cpu_flags = xvid_gbl_init.cpu_flags;
ssim.b_visualize = 0;
plugins[xvid_enc_create.num_plugins].param = &ssim;
xvid_enc_create.num_plugins++;
}
xvid_correct_framerate(avctx);
xvid_enc_create.fincr = avctx->time_base.num;
xvid_enc_create.fbase = avctx->time_base.den;
if (avctx->gop_size > 0)
xvid_enc_create.max_key_interval = avctx->gop_size;
else
xvid_enc_create.max_key_interval = 240;
if (VAR_3 & AV_CODEC_FLAG_QSCALE)
VAR_4->qscale = 1;
else
VAR_4->qscale = 0;
xvid_enc_create.min_quant[0] = avctx->qmin;
xvid_enc_create.min_quant[1] = avctx->qmin;
xvid_enc_create.min_quant[2] = avctx->qmin;
xvid_enc_create.max_quant[0] = avctx->qmax;
xvid_enc_create.max_quant[1] = avctx->qmax;
xvid_enc_create.max_quant[2] = avctx->qmax;
VAR_4->intra_matrix =
VAR_4->inter_matrix = NULL;
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->mpeg_quant)
VAR_4->mpeg_quant = avctx->mpeg_quant;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (VAR_4->mpeg_quant)
VAR_4->vol_flags |= XVID_VOL_MPEGQUANT;
if ((avctx->intra_matrix || avctx->inter_matrix)) {
VAR_4->vol_flags |= XVID_VOL_MPEGQUANT;
if (avctx->intra_matrix) {
intra = avctx->intra_matrix;
VAR_4->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!VAR_4->intra_matrix)
return AVERROR(ENOMEM);
} else
intra = NULL;
if (avctx->inter_matrix) {
inter = avctx->inter_matrix;
VAR_4->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
if (!VAR_4->inter_matrix)
return AVERROR(ENOMEM);
} else
inter = NULL;
for (VAR_1 = 0; VAR_1 < 64; VAR_1++) {
if (intra)
VAR_4->intra_matrix[VAR_1] = (unsigned char) intra[VAR_1];
if (inter)
VAR_4->inter_matrix[VAR_1] = (unsigned char) inter[VAR_1];
}
}
xvid_enc_create.frame_drop_ratio = 0;
xvid_enc_create.global = 0;
if (VAR_3 & AV_CODEC_FLAG_CLOSED_GOP)
xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;
avctx->extradata = NULL;
avctx->extradata_size = 0;
if (VAR_3 & AV_CODEC_FLAG_GLOBAL_HEADER) {
VAR_4->quicktime_format = 1;
avctx->codec_id = AV_CODEC_ID_MPEG4;
} else {
VAR_4->quicktime_format = 0;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("xvid");
}
xvid_enc_create.max_bframes = avctx->max_b_frames;
xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
if (avctx->max_b_frames > 0 && !VAR_4->quicktime_format)
xvid_enc_create.global |= XVID_GLOBAL_PACKED;
av_assert0(xvid_enc_create.num_plugins + (!!VAR_4->ssim) + (!!VAR_4->variance_aq) + (!!VAR_4->lumi_aq) <= FF_ARRAY_ELEMS(plugins));
if (VAR_4->quicktime_format) {
AVFrame *picture;
AVPacket packet;
int VAR_7, VAR_8, VAR_9;
av_init_packet(&packet);
picture = av_frame_alloc();
if (!picture)
return AVERROR(ENOMEM);
VAR_0 = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if( VAR_0 ) {
av_frame_free(&picture);
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
VAR_4->encoder_handle = xvid_enc_create.handle;
VAR_7 = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
picture->data[0] = av_malloc(VAR_7 + VAR_7 / 2);
if (!picture->data[0]) {
av_frame_free(&picture);
return AVERROR(ENOMEM);
}
picture->data[1] = picture->data[0] + VAR_7;
picture->data[2] = picture->data[1] + VAR_7 / 4;
memset(picture->data[0], 0, VAR_7);
memset(picture->data[1], 128, VAR_7 / 2);
VAR_9 = xvid_encode_frame(avctx, &packet, picture, &VAR_8);
if (!VAR_9 && VAR_8)
av_packet_unref(&packet);
av_free(picture->data[0]);
av_frame_free(&picture);
xvid_encore(VAR_4->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
}
VAR_0 = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
if (VAR_0) {
av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
return AVERROR_EXTERNAL;
}
VAR_4->encoder_handle = xvid_enc_create.handle;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"int VAR_0, VAR_1, VAR_9 = -1;",
"int VAR_3 = avctx->flags;",
"struct xvid_context *VAR_4 = avctx->priv_data;",
"uint16_t *intra, *inter;",
"int VAR_5;",
"xvid_plugin_single_t single = { 0 };",
"struct xvid_ff_pass1 VAR_6 = { 0 };",
"xvid_plugin_2pass2_t rc2pass2 = { 0 };",
"xvid_plugin_lumimasking_t masking_l = { 0 };",
"xvid_plugin_lumimasking_t masking_v = { 0 };",
"xvid_plugin_ssim_t ssim = { 0 };",
"xvid_gbl_init_t xvid_gbl_init = { 0 };",
"xvid_enc_create_t xvid_enc_create = { 0 };",
"xvid_enc_plugin_t plugins[4];",
"VAR_4->twopassfd = -1;",
"VAR_4->vop_flags = XVID_VOP_HALFPEL;",
"if (VAR_3 & AV_CODEC_FLAG_4MV)\nVAR_4->vop_flags |= XVID_VOP_INTER4V;",
"if (avctx->trellis)\nVAR_4->vop_flags |= XVID_VOP_TRELLISQUANT;",
"if (VAR_3 & AV_CODEC_FLAG_AC_PRED)\nVAR_4->vop_flags |= XVID_VOP_HQACPRED;",
"if (VAR_3 & AV_CODEC_FLAG_GRAY)\nVAR_4->vop_flags |= XVID_VOP_GREYSCALE;",
"VAR_4->me_flags = 0;",
"switch (VAR_4->me_quality) {",
"case 6:\ncase 5:\nVAR_4->me_flags |= XVID_ME_EXTSEARCH16 |\nXVID_ME_EXTSEARCH8;",
"case 4:\ncase 3:\nVAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |\nXVID_ME_HALFPELREFINE8 |\nXVID_ME_CHROMA_PVOP |\nXVID_ME_CHROMA_BVOP;",
"case 2:\ncase 1:\nVAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |\nXVID_ME_HALFPELREFINE16;",
"#if FF_API_MOTION_EST\nFF_DISABLE_DEPRECATION_WARNINGS\nbreak;",
"default:\nswitch (avctx->me_method) {",
"case ME_FULL:\nVAR_4->me_flags |= XVID_ME_EXTSEARCH16 |\nXVID_ME_EXTSEARCH8;",
"case ME_EPZS:\nVAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |\nXVID_ME_HALFPELREFINE8 |\nXVID_ME_CHROMA_PVOP |\nXVID_ME_CHROMA_BVOP;",
"case ME_LOG:\ncase ME_PHODS:\ncase ME_X1:\nVAR_4->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |\nXVID_ME_HALFPELREFINE16;",
"case ME_ZERO:\ndefault:\nbreak;",
"}",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\n}",
"switch (avctx->mb_decision) {",
"case 2:\nVAR_4->vop_flags |= XVID_VOP_MODEDECISION_RD;",
"VAR_4->me_flags |= XVID_ME_HALFPELREFINE8_RD |\nXVID_ME_QUARTERPELREFINE8_RD |\nXVID_ME_EXTSEARCH_RD |\nXVID_ME_CHECKPREDICTION_RD;",
"case 1:\nif (!(VAR_4->vop_flags & XVID_VOP_MODEDECISION_RD))\nVAR_4->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD;",
"VAR_4->me_flags |= XVID_ME_HALFPELREFINE16_RD |\nXVID_ME_QUARTERPELREFINE16_RD;",
"default:\nbreak;",
"}",
"#if FF_API_GMC\nif (avctx->flags & CODEC_FLAG_GMC)\nVAR_4->gmc = 1;",
"#endif\nVAR_4->vol_flags = 0;",
"if (VAR_4->gmc) {",
"VAR_4->vol_flags |= XVID_VOL_GMC;",
"VAR_4->me_flags |= XVID_ME_GME_REFINE;",
"}",
"if (VAR_3 & AV_CODEC_FLAG_QPEL) {",
"VAR_4->vol_flags |= XVID_VOL_QUARTERPEL;",
"VAR_4->me_flags |= XVID_ME_QUARTERPELREFINE16;",
"if (VAR_4->vop_flags & XVID_VOP_INTER4V)\nVAR_4->me_flags |= XVID_ME_QUARTERPELREFINE8;",
"}",
"xvid_gbl_init.version = XVID_VERSION;",
"xvid_gbl_init.debug = 0;",
"xvid_gbl_init.cpu_flags = 0;",
"xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);",
"xvid_enc_create.version = XVID_VERSION;",
"xvid_enc_create.width =\nVAR_4->xsize = avctx->width;",
"xvid_enc_create.height =\nVAR_4->ysize = avctx->height;",
"xvid_enc_create.zones = NULL;",
"xvid_enc_create.num_zones = 0;",
"xvid_enc_create.num_threads = avctx->thread_count;",
"#if (XVID_VERSION <= 0x010303) && (XVID_VERSION >= 0x010300)\nif (avctx->height <= 16) {",
"if (avctx->thread_count < 2) {",
"xvid_enc_create.num_threads = 0;",
"} else {",
"av_log(avctx, AV_LOG_ERROR,\n\"Too small height for threads > 1.\");",
"return AVERROR(EINVAL);",
"}",
"}",
"#endif\nxvid_enc_create.plugins = plugins;",
"xvid_enc_create.num_plugins = 0;",
"VAR_4->twopassbuffer = NULL;",
"VAR_4->old_twopassbuffer = NULL;",
"VAR_4->twopassfile = NULL;",
"if (VAR_3 & AV_CODEC_FLAG_PASS1) {",
"VAR_6.version = XVID_VERSION;",
"VAR_6.context = VAR_4;",
"VAR_4->twopassbuffer = av_malloc(BUFFER_SIZE);",
"VAR_4->old_twopassbuffer = av_malloc(BUFFER_SIZE);",
"if (!VAR_4->twopassbuffer || !VAR_4->old_twopassbuffer) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Xvid: Cannot allocate 2-pass log buffers\\n\");",
"return AVERROR(ENOMEM);",
"}",
"VAR_4->twopassbuffer[0] =\nVAR_4->old_twopassbuffer[0] = 0;",
"plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;",
"plugins[xvid_enc_create.num_plugins].param = &VAR_6;",
"xvid_enc_create.num_plugins++;",
"} else if (VAR_3 & AV_CODEC_FLAG_PASS2) {",
"rc2pass2.version = XVID_VERSION;",
"rc2pass2.bitrate = avctx->bit_rate;",
"VAR_5 = avpriv_tempfile(\"xvidff.\", &VAR_4->twopassfile, 0, avctx);",
"if (VAR_5 < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Xvid: Cannot write 2-pass pipe\\n\");",
"return VAR_5;",
"}",
"VAR_4->twopassfd = VAR_5;",
"if (!avctx->stats_in) {",
"av_log(avctx, AV_LOG_ERROR,\n\"Xvid: No 2-pass information loaded for second pass\\n\");",
"return AVERROR(EINVAL);",
"}",
"VAR_9 = write(VAR_5, avctx->stats_in, strlen(avctx->stats_in));",
"if (VAR_9 == -1)\nVAR_9 = AVERROR(errno);",
"else if (strlen(avctx->stats_in) > VAR_9) {",
"av_log(avctx, AV_LOG_ERROR, \"Xvid: Cannot write to 2-pass pipe\\n\");",
"VAR_9 = AVERROR(EIO);",
"}",
"if (VAR_9 < 0)\nreturn VAR_9;",
"rc2pass2.filename = VAR_4->twopassfile;",
"plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;",
"plugins[xvid_enc_create.num_plugins].param = &rc2pass2;",
"xvid_enc_create.num_plugins++;",
"} else if (!(VAR_3 & AV_CODEC_FLAG_QSCALE)) {",
"single.version = XVID_VERSION;",
"single.bitrate = avctx->bit_rate;",
"plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;",
"plugins[xvid_enc_create.num_plugins].param = &single;",
"xvid_enc_create.num_plugins++;",
"}",
"if (avctx->lumi_masking != 0.0)\nVAR_4->lumi_aq = 1;",
"if (VAR_4->lumi_aq) {",
"masking_l.method = 0;",
"plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;",
"plugins[xvid_enc_create.num_plugins].param =\navctx->lumi_masking ? NULL : &masking_l;",
"xvid_enc_create.num_plugins++;",
"}",
"if (VAR_4->variance_aq) {",
"masking_v.method = 1;",
"plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;",
"plugins[xvid_enc_create.num_plugins].param = &masking_v;",
"xvid_enc_create.num_plugins++;",
"}",
"if (VAR_4->lumi_aq && VAR_4->variance_aq )\nav_log(avctx, AV_LOG_INFO,\n\"Both lumi_aq and variance_aq are enabled. The resulting quality\"\n\"will be the worse one of the two effects made by the AQ.\\n\");",
"if (VAR_4->ssim) {",
"plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;",
"ssim.b_printstat = VAR_4->ssim == 2;",
"ssim.acc = VAR_4->ssim_acc;",
"ssim.cpu_flags = xvid_gbl_init.cpu_flags;",
"ssim.b_visualize = 0;",
"plugins[xvid_enc_create.num_plugins].param = &ssim;",
"xvid_enc_create.num_plugins++;",
"}",
"xvid_correct_framerate(avctx);",
"xvid_enc_create.fincr = avctx->time_base.num;",
"xvid_enc_create.fbase = avctx->time_base.den;",
"if (avctx->gop_size > 0)\nxvid_enc_create.max_key_interval = avctx->gop_size;",
"else\nxvid_enc_create.max_key_interval = 240;",
"if (VAR_3 & AV_CODEC_FLAG_QSCALE)\nVAR_4->qscale = 1;",
"else\nVAR_4->qscale = 0;",
"xvid_enc_create.min_quant[0] = avctx->qmin;",
"xvid_enc_create.min_quant[1] = avctx->qmin;",
"xvid_enc_create.min_quant[2] = avctx->qmin;",
"xvid_enc_create.max_quant[0] = avctx->qmax;",
"xvid_enc_create.max_quant[1] = avctx->qmax;",
"xvid_enc_create.max_quant[2] = avctx->qmax;",
"VAR_4->intra_matrix =\nVAR_4->inter_matrix = NULL;",
"#if FF_API_PRIVATE_OPT\nFF_DISABLE_DEPRECATION_WARNINGS\nif (avctx->mpeg_quant)\nVAR_4->mpeg_quant = avctx->mpeg_quant;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nif (VAR_4->mpeg_quant)\nVAR_4->vol_flags |= XVID_VOL_MPEGQUANT;",
"if ((avctx->intra_matrix || avctx->inter_matrix)) {",
"VAR_4->vol_flags |= XVID_VOL_MPEGQUANT;",
"if (avctx->intra_matrix) {",
"intra = avctx->intra_matrix;",
"VAR_4->intra_matrix = av_malloc(sizeof(unsigned char) * 64);",
"if (!VAR_4->intra_matrix)\nreturn AVERROR(ENOMEM);",
"} else",
"intra = NULL;",
"if (avctx->inter_matrix) {",
"inter = avctx->inter_matrix;",
"VAR_4->inter_matrix = av_malloc(sizeof(unsigned char) * 64);",
"if (!VAR_4->inter_matrix)\nreturn AVERROR(ENOMEM);",
"} else",
"inter = NULL;",
"for (VAR_1 = 0; VAR_1 < 64; VAR_1++) {",
"if (intra)\nVAR_4->intra_matrix[VAR_1] = (unsigned char) intra[VAR_1];",
"if (inter)\nVAR_4->inter_matrix[VAR_1] = (unsigned char) inter[VAR_1];",
"}",
"}",
"xvid_enc_create.frame_drop_ratio = 0;",
"xvid_enc_create.global = 0;",
"if (VAR_3 & AV_CODEC_FLAG_CLOSED_GOP)\nxvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;",
"avctx->extradata = NULL;",
"avctx->extradata_size = 0;",
"if (VAR_3 & AV_CODEC_FLAG_GLOBAL_HEADER) {",
"VAR_4->quicktime_format = 1;",
"avctx->codec_id = AV_CODEC_ID_MPEG4;",
"} else {",
"VAR_4->quicktime_format = 0;",
"if (!avctx->codec_tag)\navctx->codec_tag = AV_RL32(\"xvid\");",
"}",
"xvid_enc_create.max_bframes = avctx->max_b_frames;",
"xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;",
"xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;",
"if (avctx->max_b_frames > 0 && !VAR_4->quicktime_format)\nxvid_enc_create.global |= XVID_GLOBAL_PACKED;",
"av_assert0(xvid_enc_create.num_plugins + (!!VAR_4->ssim) + (!!VAR_4->variance_aq) + (!!VAR_4->lumi_aq) <= FF_ARRAY_ELEMS(plugins));",
"if (VAR_4->quicktime_format) {",
"AVFrame *picture;",
"AVPacket packet;",
"int VAR_7, VAR_8, VAR_9;",
"av_init_packet(&packet);",
"picture = av_frame_alloc();",
"if (!picture)\nreturn AVERROR(ENOMEM);",
"VAR_0 = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);",
"if( VAR_0 ) {",
"av_frame_free(&picture);",
"av_log(avctx, AV_LOG_ERROR, \"Xvid: Could not create encoder reference\\n\");",
"return AVERROR_EXTERNAL;",
"}",
"VAR_4->encoder_handle = xvid_enc_create.handle;",
"VAR_7 = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);",
"picture->data[0] = av_malloc(VAR_7 + VAR_7 / 2);",
"if (!picture->data[0]) {",
"av_frame_free(&picture);",
"return AVERROR(ENOMEM);",
"}",
"picture->data[1] = picture->data[0] + VAR_7;",
"picture->data[2] = picture->data[1] + VAR_7 / 4;",
"memset(picture->data[0], 0, VAR_7);",
"memset(picture->data[1], 128, VAR_7 / 2);",
"VAR_9 = xvid_encode_frame(avctx, &packet, picture, &VAR_8);",
"if (!VAR_9 && VAR_8)\nav_packet_unref(&packet);",
"av_free(picture->data[0]);",
"av_frame_free(&picture);",
"xvid_encore(VAR_4->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);",
"}",
"VAR_0 = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);",
"if (VAR_0) {",
"av_log(avctx, AV_LOG_ERROR, \"Xvid: Could not create encoder reference\\n\");",
"return AVERROR_EXTERNAL;",
"}",
"VAR_4->encoder_handle = xvid_enc_create.handle;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
43
],
[
45,
47
],
[
49,
51
],
[
53,
55
],
[
57,
59
],
[
65
],
[
67
],
[
69,
71,
73,
75
],
[
77,
79,
81,
83,
85,
87
],
[
89,
91,
93,
95
],
[
97,
99,
101
],
[
103,
105
],
[
107,
109,
111
],
[
113,
115,
117,
119,
121
],
[
123,
125,
127,
129,
131
],
[
133,
135,
137
],
[
139
],
[
141,
143,
145
],
[
151
],
[
153,
155
],
[
157,
159,
161,
163
],
[
165,
167,
169
],
[
171,
173
],
[
175,
177
],
[
179
],
[
185,
187,
189
],
[
191,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211,
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
229
],
[
235
],
[
241,
243
],
[
245,
247
],
[
259
],
[
261
],
[
265
],
[
267,
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289,
293
],
[
295
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
329,
331
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363
],
[
365,
367
],
[
369
],
[
371
],
[
375
],
[
377,
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389,
391
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
423,
425
],
[
431
],
[
433
],
[
435
],
[
443,
445
],
[
447
],
[
449
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
469,
471,
473,
475
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
503
],
[
505
],
[
507
],
[
509,
511
],
[
513,
515
],
[
521,
523
],
[
525,
527
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
541
],
[
547,
549
],
[
553,
555,
557,
559
],
[
561,
563,
567,
569
],
[
571
],
[
573
],
[
577
],
[
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597,
599
],
[
601
],
[
603
],
[
607
],
[
609,
611
],
[
613,
615
],
[
617
],
[
619
],
[
625
],
[
627
],
[
629,
631
],
[
637
],
[
639
],
[
641
],
[
645
],
[
647
],
[
649
],
[
653
],
[
655,
657
],
[
659
],
[
665
],
[
667
],
[
669
],
[
671,
673
],
[
677
],
[
683
],
[
685
],
[
687
],
[
689
],
[
693
],
[
697
],
[
699,
701
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741,
743
],
[
745
],
[
747
],
[
749
],
[
751
],
[
757
],
[
759
],
[
761
],
[
763
],
[
765
],
[
769
],
[
773
],
[
775
]
] |
21,893 | static void test_submit_co(void)
{
WorkerTestData data;
Coroutine *co = qemu_coroutine_create(co_test_cb);
qemu_coroutine_enter(co, &data);
/* Back here once the worker has started. */
g_assert_cmpint(active, ==, 1);
g_assert_cmpint(data.ret, ==, -EINPROGRESS);
/* qemu_aio_wait_all will execute the rest of the coroutine. */
qemu_aio_wait_all();
/* Back here after the coroutine has finished. */
g_assert_cmpint(active, ==, 0);
g_assert_cmpint(data.ret, ==, 0);
}
| true | qemu | 35ecde26018207fe723bec6efbd340db6e9c2d53 | static void test_submit_co(void)
{
WorkerTestData data;
Coroutine *co = qemu_coroutine_create(co_test_cb);
qemu_coroutine_enter(co, &data);
g_assert_cmpint(active, ==, 1);
g_assert_cmpint(data.ret, ==, -EINPROGRESS);
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
g_assert_cmpint(data.ret, ==, 0);
}
| {
"code": [
" qemu_aio_wait_all();",
" qemu_aio_wait_all();",
" qemu_aio_wait_all();",
" qemu_aio_wait_all();"
],
"line_no": [
29,
29,
29,
29
]
} | static void FUNC_0(void)
{
WorkerTestData data;
Coroutine *co = qemu_coroutine_create(co_test_cb);
qemu_coroutine_enter(co, &data);
g_assert_cmpint(active, ==, 1);
g_assert_cmpint(data.ret, ==, -EINPROGRESS);
qemu_aio_wait_all();
g_assert_cmpint(active, ==, 0);
g_assert_cmpint(data.ret, ==, 0);
}
| [
"static void FUNC_0(void)\n{",
"WorkerTestData data;",
"Coroutine *co = qemu_coroutine_create(co_test_cb);",
"qemu_coroutine_enter(co, &data);",
"g_assert_cmpint(active, ==, 1);",
"g_assert_cmpint(data.ret, ==, -EINPROGRESS);",
"qemu_aio_wait_all();",
"g_assert_cmpint(active, ==, 0);",
"g_assert_cmpint(data.ret, ==, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
19
],
[
21
],
[
29
],
[
37
],
[
39
],
[
41
]
] |
21,894 | static void pcnet_transmit(PCNetState *s)
{
hwaddr xmit_cxda = 0;
int count = CSR_XMTRL(s)-1;
int add_crc = 0;
int bcnt;
s->xmit_pos = -1;
if (!CSR_TXON(s)) {
s->csr[0] &= ~0x0008;
return;
}
s->tx_busy = 1;
txagain:
if (pcnet_tdte_poll(s)) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));
#ifdef PCNET_DEBUG_TMD
printf(" TMDLOAD 0x%08x\n", PHYSADDR(s,CSR_CXDA(s)));
PRINT_TMD(&tmd);
#endif
if (GET_FIELD(tmd.status, TMDS, STP)) {
s->xmit_pos = 0;
xmit_cxda = PHYSADDR(s,CSR_CXDA(s));
if (BCR_SWSTYLE(s) != 1)
add_crc = GET_FIELD(tmd.status, TMDS, ADDFCS);
}
if (s->lnkst == 0 &&
(!CSR_LOOP(s) || (!CSR_INTL(s) && !BCR_TMAULOOP(s)))) {
SET_FIELD(&tmd.misc, TMDM, LCAR, 1);
SET_FIELD(&tmd.status, TMDS, ERR, 1);
SET_FIELD(&tmd.status, TMDS, OWN, 0);
s->csr[0] |= 0xa000; /* ERR | CERR */
s->xmit_pos = -1;
goto txdone;
}
if (s->xmit_pos < 0) {
goto txdone;
}
bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
/* if multi-tmd packet outsizes s->buffer then skip it silently.
Note: this is not what real hw does */
if (s->xmit_pos + bcnt > sizeof(s->buffer)) {
s->xmit_pos = -1;
goto txdone;
}
s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr),
s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s));
s->xmit_pos += bcnt;
if (!GET_FIELD(tmd.status, TMDS, ENP)) {
goto txdone;
}
#ifdef PCNET_DEBUG
printf("pcnet_transmit size=%d\n", s->xmit_pos);
#endif
if (CSR_LOOP(s)) {
if (BCR_SWSTYLE(s) == 1)
add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS);
s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;
pcnet_receive(qemu_get_queue(s->nic), s->buffer, s->xmit_pos);
s->looptest = 0;
} else {
if (s->nic) {
qemu_send_packet(qemu_get_queue(s->nic), s->buffer,
s->xmit_pos);
}
}
s->csr[0] &= ~0x0008; /* clear TDMD */
s->csr[4] |= 0x0004; /* set TXSTRT */
s->xmit_pos = -1;
txdone:
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT)))
s->csr[0] |= 0x0200; /* set TINT */
if (CSR_XMTRC(s)<=1)
CSR_XMTRC(s) = CSR_XMTRL(s);
else
CSR_XMTRC(s)--;
if (count--)
goto txagain;
} else
if (s->xmit_pos >= 0) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, xmit_cxda);
SET_FIELD(&tmd.misc, TMDM, BUFF, 1);
SET_FIELD(&tmd.misc, TMDM, UFLO, 1);
SET_FIELD(&tmd.status, TMDS, ERR, 1);
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, xmit_cxda);
s->csr[0] |= 0x0200; /* set TINT */
if (!CSR_DXSUFLO(s)) {
s->csr[0] &= ~0x0010;
} else
if (count--)
goto txagain;
}
s->tx_busy = 0;
}
| true | qemu | 837f21aacf5a714c23ddaadbbc5212f9b661e3f7 | static void pcnet_transmit(PCNetState *s)
{
hwaddr xmit_cxda = 0;
int count = CSR_XMTRL(s)-1;
int add_crc = 0;
int bcnt;
s->xmit_pos = -1;
if (!CSR_TXON(s)) {
s->csr[0] &= ~0x0008;
return;
}
s->tx_busy = 1;
txagain:
if (pcnet_tdte_poll(s)) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));
#ifdef PCNET_DEBUG_TMD
printf(" TMDLOAD 0x%08x\n", PHYSADDR(s,CSR_CXDA(s)));
PRINT_TMD(&tmd);
#endif
if (GET_FIELD(tmd.status, TMDS, STP)) {
s->xmit_pos = 0;
xmit_cxda = PHYSADDR(s,CSR_CXDA(s));
if (BCR_SWSTYLE(s) != 1)
add_crc = GET_FIELD(tmd.status, TMDS, ADDFCS);
}
if (s->lnkst == 0 &&
(!CSR_LOOP(s) || (!CSR_INTL(s) && !BCR_TMAULOOP(s)))) {
SET_FIELD(&tmd.misc, TMDM, LCAR, 1);
SET_FIELD(&tmd.status, TMDS, ERR, 1);
SET_FIELD(&tmd.status, TMDS, OWN, 0);
s->csr[0] |= 0xa000;
s->xmit_pos = -1;
goto txdone;
}
if (s->xmit_pos < 0) {
goto txdone;
}
bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
if (s->xmit_pos + bcnt > sizeof(s->buffer)) {
s->xmit_pos = -1;
goto txdone;
}
s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr),
s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s));
s->xmit_pos += bcnt;
if (!GET_FIELD(tmd.status, TMDS, ENP)) {
goto txdone;
}
#ifdef PCNET_DEBUG
printf("pcnet_transmit size=%d\n", s->xmit_pos);
#endif
if (CSR_LOOP(s)) {
if (BCR_SWSTYLE(s) == 1)
add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS);
s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;
pcnet_receive(qemu_get_queue(s->nic), s->buffer, s->xmit_pos);
s->looptest = 0;
} else {
if (s->nic) {
qemu_send_packet(qemu_get_queue(s->nic), s->buffer,
s->xmit_pos);
}
}
s->csr[0] &= ~0x0008;
s->csr[4] |= 0x0004;
s->xmit_pos = -1;
txdone:
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT)))
s->csr[0] |= 0x0200;
if (CSR_XMTRC(s)<=1)
CSR_XMTRC(s) = CSR_XMTRL(s);
else
CSR_XMTRC(s)--;
if (count--)
goto txagain;
} else
if (s->xmit_pos >= 0) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, xmit_cxda);
SET_FIELD(&tmd.misc, TMDM, BUFF, 1);
SET_FIELD(&tmd.misc, TMDM, UFLO, 1);
SET_FIELD(&tmd.status, TMDS, ERR, 1);
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, xmit_cxda);
s->csr[0] |= 0x0200;
if (!CSR_DXSUFLO(s)) {
s->csr[0] &= ~0x0010;
} else
if (count--)
goto txagain;
}
s->tx_busy = 0;
}
| {
"code": [
" if (s->xmit_pos + bcnt > sizeof(s->buffer)) {"
],
"line_no": [
99
]
} | static void FUNC_0(PCNetState *VAR_0)
{
hwaddr xmit_cxda = 0;
int VAR_1 = CSR_XMTRL(VAR_0)-1;
int VAR_2 = 0;
int VAR_3;
VAR_0->xmit_pos = -1;
if (!CSR_TXON(VAR_0)) {
VAR_0->csr[0] &= ~0x0008;
return;
}
VAR_0->tx_busy = 1;
txagain:
if (pcnet_tdte_poll(VAR_0)) {
struct pcnet_TMD VAR_5;
TMDLOAD(&VAR_5, PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));
#ifdef PCNET_DEBUG_TMD
printf(" TMDLOAD 0x%08x\n", PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));
PRINT_TMD(&VAR_5);
#endif
if (GET_FIELD(VAR_5.status, TMDS, STP)) {
VAR_0->xmit_pos = 0;
xmit_cxda = PHYSADDR(VAR_0,CSR_CXDA(VAR_0));
if (BCR_SWSTYLE(VAR_0) != 1)
VAR_2 = GET_FIELD(VAR_5.status, TMDS, ADDFCS);
}
if (VAR_0->lnkst == 0 &&
(!CSR_LOOP(VAR_0) || (!CSR_INTL(VAR_0) && !BCR_TMAULOOP(VAR_0)))) {
SET_FIELD(&VAR_5.misc, TMDM, LCAR, 1);
SET_FIELD(&VAR_5.status, TMDS, ERR, 1);
SET_FIELD(&VAR_5.status, TMDS, OWN, 0);
VAR_0->csr[0] |= 0xa000;
VAR_0->xmit_pos = -1;
goto txdone;
}
if (VAR_0->xmit_pos < 0) {
goto txdone;
}
VAR_3 = 4096 - GET_FIELD(VAR_5.length, TMDL, BCNT);
if (VAR_0->xmit_pos + VAR_3 > sizeof(VAR_0->buffer)) {
VAR_0->xmit_pos = -1;
goto txdone;
}
VAR_0->phys_mem_read(VAR_0->dma_opaque, PHYSADDR(VAR_0, VAR_5.tbadr),
VAR_0->buffer + VAR_0->xmit_pos, VAR_3, CSR_BSWP(VAR_0));
VAR_0->xmit_pos += VAR_3;
if (!GET_FIELD(VAR_5.status, TMDS, ENP)) {
goto txdone;
}
#ifdef PCNET_DEBUG
printf("FUNC_0 size=%d\n", VAR_0->xmit_pos);
#endif
if (CSR_LOOP(VAR_0)) {
if (BCR_SWSTYLE(VAR_0) == 1)
VAR_2 = !GET_FIELD(VAR_5.status, TMDS, NOFCS);
VAR_0->looptest = VAR_2 ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;
pcnet_receive(qemu_get_queue(VAR_0->nic), VAR_0->buffer, VAR_0->xmit_pos);
VAR_0->looptest = 0;
} else {
if (VAR_0->nic) {
qemu_send_packet(qemu_get_queue(VAR_0->nic), VAR_0->buffer,
VAR_0->xmit_pos);
}
}
VAR_0->csr[0] &= ~0x0008;
VAR_0->csr[4] |= 0x0004;
VAR_0->xmit_pos = -1;
txdone:
SET_FIELD(&VAR_5.status, TMDS, OWN, 0);
TMDSTORE(&VAR_5, PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));
if (!CSR_TOKINTD(VAR_0) || (CSR_LTINTEN(VAR_0) && GET_FIELD(VAR_5.status, TMDS, LTINT)))
VAR_0->csr[0] |= 0x0200;
if (CSR_XMTRC(VAR_0)<=1)
CSR_XMTRC(VAR_0) = CSR_XMTRL(VAR_0);
else
CSR_XMTRC(VAR_0)--;
if (VAR_1--)
goto txagain;
} else
if (VAR_0->xmit_pos >= 0) {
struct pcnet_TMD VAR_5;
TMDLOAD(&VAR_5, xmit_cxda);
SET_FIELD(&VAR_5.misc, TMDM, BUFF, 1);
SET_FIELD(&VAR_5.misc, TMDM, UFLO, 1);
SET_FIELD(&VAR_5.status, TMDS, ERR, 1);
SET_FIELD(&VAR_5.status, TMDS, OWN, 0);
TMDSTORE(&VAR_5, xmit_cxda);
VAR_0->csr[0] |= 0x0200;
if (!CSR_DXSUFLO(VAR_0)) {
VAR_0->csr[0] &= ~0x0010;
} else
if (VAR_1--)
goto txagain;
}
VAR_0->tx_busy = 0;
}
| [
"static void FUNC_0(PCNetState *VAR_0)\n{",
"hwaddr xmit_cxda = 0;",
"int VAR_1 = CSR_XMTRL(VAR_0)-1;",
"int VAR_2 = 0;",
"int VAR_3;",
"VAR_0->xmit_pos = -1;",
"if (!CSR_TXON(VAR_0)) {",
"VAR_0->csr[0] &= ~0x0008;",
"return;",
"}",
"VAR_0->tx_busy = 1;",
"txagain:\nif (pcnet_tdte_poll(VAR_0)) {",
"struct pcnet_TMD VAR_5;",
"TMDLOAD(&VAR_5, PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));",
"#ifdef PCNET_DEBUG_TMD\nprintf(\" TMDLOAD 0x%08x\\n\", PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));",
"PRINT_TMD(&VAR_5);",
"#endif\nif (GET_FIELD(VAR_5.status, TMDS, STP)) {",
"VAR_0->xmit_pos = 0;",
"xmit_cxda = PHYSADDR(VAR_0,CSR_CXDA(VAR_0));",
"if (BCR_SWSTYLE(VAR_0) != 1)\nVAR_2 = GET_FIELD(VAR_5.status, TMDS, ADDFCS);",
"}",
"if (VAR_0->lnkst == 0 &&\n(!CSR_LOOP(VAR_0) || (!CSR_INTL(VAR_0) && !BCR_TMAULOOP(VAR_0)))) {",
"SET_FIELD(&VAR_5.misc, TMDM, LCAR, 1);",
"SET_FIELD(&VAR_5.status, TMDS, ERR, 1);",
"SET_FIELD(&VAR_5.status, TMDS, OWN, 0);",
"VAR_0->csr[0] |= 0xa000;",
"VAR_0->xmit_pos = -1;",
"goto txdone;",
"}",
"if (VAR_0->xmit_pos < 0) {",
"goto txdone;",
"}",
"VAR_3 = 4096 - GET_FIELD(VAR_5.length, TMDL, BCNT);",
"if (VAR_0->xmit_pos + VAR_3 > sizeof(VAR_0->buffer)) {",
"VAR_0->xmit_pos = -1;",
"goto txdone;",
"}",
"VAR_0->phys_mem_read(VAR_0->dma_opaque, PHYSADDR(VAR_0, VAR_5.tbadr),\nVAR_0->buffer + VAR_0->xmit_pos, VAR_3, CSR_BSWP(VAR_0));",
"VAR_0->xmit_pos += VAR_3;",
"if (!GET_FIELD(VAR_5.status, TMDS, ENP)) {",
"goto txdone;",
"}",
"#ifdef PCNET_DEBUG\nprintf(\"FUNC_0 size=%d\\n\", VAR_0->xmit_pos);",
"#endif\nif (CSR_LOOP(VAR_0)) {",
"if (BCR_SWSTYLE(VAR_0) == 1)\nVAR_2 = !GET_FIELD(VAR_5.status, TMDS, NOFCS);",
"VAR_0->looptest = VAR_2 ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;",
"pcnet_receive(qemu_get_queue(VAR_0->nic), VAR_0->buffer, VAR_0->xmit_pos);",
"VAR_0->looptest = 0;",
"} else {",
"if (VAR_0->nic) {",
"qemu_send_packet(qemu_get_queue(VAR_0->nic), VAR_0->buffer,\nVAR_0->xmit_pos);",
"}",
"}",
"VAR_0->csr[0] &= ~0x0008;",
"VAR_0->csr[4] |= 0x0004;",
"VAR_0->xmit_pos = -1;",
"txdone:\nSET_FIELD(&VAR_5.status, TMDS, OWN, 0);",
"TMDSTORE(&VAR_5, PHYSADDR(VAR_0,CSR_CXDA(VAR_0)));",
"if (!CSR_TOKINTD(VAR_0) || (CSR_LTINTEN(VAR_0) && GET_FIELD(VAR_5.status, TMDS, LTINT)))\nVAR_0->csr[0] |= 0x0200;",
"if (CSR_XMTRC(VAR_0)<=1)\nCSR_XMTRC(VAR_0) = CSR_XMTRL(VAR_0);",
"else\nCSR_XMTRC(VAR_0)--;",
"if (VAR_1--)\ngoto txagain;",
"} else",
"if (VAR_0->xmit_pos >= 0) {",
"struct pcnet_TMD VAR_5;",
"TMDLOAD(&VAR_5, xmit_cxda);",
"SET_FIELD(&VAR_5.misc, TMDM, BUFF, 1);",
"SET_FIELD(&VAR_5.misc, TMDM, UFLO, 1);",
"SET_FIELD(&VAR_5.status, TMDS, ERR, 1);",
"SET_FIELD(&VAR_5.status, TMDS, OWN, 0);",
"TMDSTORE(&VAR_5, xmit_cxda);",
"VAR_0->csr[0] |= 0x0200;",
"if (!CSR_DXSUFLO(VAR_0)) {",
"VAR_0->csr[0] &= ~0x0010;",
"} else",
"if (VAR_1--)\ngoto txagain;",
"}",
"VAR_0->tx_busy = 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31,
33
],
[
35
],
[
39
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125,
127
],
[
129,
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
165,
167
],
[
169
],
[
171,
173
],
[
177,
179
],
[
181,
183
],
[
185,
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
225
],
[
227
]
] |
21,895 | long do_sigreturn(CPUMBState *env)
{
struct target_signal_frame *frame;
abi_ulong frame_addr;
target_sigset_t target_set;
sigset_t set;
int i;
frame_addr = env->regs[R_SP];
trace_user_do_sigreturn(env, frame_addr);
/* Make sure the guest isn't playing games. */
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
goto badframe;
/* Restore blocked signals */
__get_user(target_set.sig[0], &frame->uc.tuc_mcontext.oldmask);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
__get_user(target_set.sig[i], &frame->extramask[i - 1]);
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
restore_sigcontext(&frame->uc.tuc_mcontext, env);
/* We got here through a sigreturn syscall, our path back is via an
rtb insn so setup r14 for that. */
env->regs[14] = env->sregs[SR_PC];
unlock_user_struct(frame, frame_addr, 0);
return env->regs[10];
badframe:
force_sig(TARGET_SIGSEGV);
}
| true | qemu | 4134ecfeb903c362558cb1cb594ff532fd83fb84 | long do_sigreturn(CPUMBState *env)
{
struct target_signal_frame *frame;
abi_ulong frame_addr;
target_sigset_t target_set;
sigset_t set;
int i;
frame_addr = env->regs[R_SP];
trace_user_do_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
goto badframe;
__get_user(target_set.sig[0], &frame->uc.tuc_mcontext.oldmask);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
__get_user(target_set.sig[i], &frame->extramask[i - 1]);
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
restore_sigcontext(&frame->uc.tuc_mcontext, env);
env->regs[14] = env->sregs[SR_PC];
unlock_user_struct(frame, frame_addr, 0);
return env->regs[10];
badframe:
force_sig(TARGET_SIGSEGV);
}
| {
"code": [
" return env->regs[10];"
],
"line_no": [
57
]
} | long FUNC_0(CPUMBState *VAR_0)
{
struct target_signal_frame *VAR_1;
abi_ulong frame_addr;
target_sigset_t target_set;
sigset_t set;
int VAR_2;
frame_addr = VAR_0->regs[R_SP];
trace_user_do_sigreturn(VAR_0, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, VAR_1, frame_addr, 1))
goto badframe;
__get_user(target_set.sig[0], &VAR_1->uc.tuc_mcontext.oldmask);
for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {
__get_user(target_set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1]);
}
target_to_host_sigset_internal(&set, &target_set);
do_sigprocmask(SIG_SETMASK, &set, NULL);
restore_sigcontext(&VAR_1->uc.tuc_mcontext, VAR_0);
VAR_0->regs[14] = VAR_0->sregs[SR_PC];
unlock_user_struct(VAR_1, frame_addr, 0);
return VAR_0->regs[10];
badframe:
force_sig(TARGET_SIGSEGV);
}
| [
"long FUNC_0(CPUMBState *VAR_0)\n{",
"struct target_signal_frame *VAR_1;",
"abi_ulong frame_addr;",
"target_sigset_t target_set;",
"sigset_t set;",
"int VAR_2;",
"frame_addr = VAR_0->regs[R_SP];",
"trace_user_do_sigreturn(VAR_0, frame_addr);",
"if (!lock_user_struct(VERIFY_WRITE, VAR_1, frame_addr, 1))\ngoto badframe;",
"__get_user(target_set.sig[0], &VAR_1->uc.tuc_mcontext.oldmask);",
"for(VAR_2 = 1; VAR_2 < TARGET_NSIG_WORDS; VAR_2++) {",
"__get_user(target_set.sig[VAR_2], &VAR_1->extramask[VAR_2 - 1]);",
"}",
"target_to_host_sigset_internal(&set, &target_set);",
"do_sigprocmask(SIG_SETMASK, &set, NULL);",
"restore_sigcontext(&VAR_1->uc.tuc_mcontext, VAR_0);",
"VAR_0->regs[14] = VAR_0->sregs[SR_PC];",
"unlock_user_struct(VAR_1, frame_addr, 0);",
"return VAR_0->regs[10];",
"badframe:\nforce_sig(TARGET_SIGSEGV);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23,
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
51
],
[
55
],
[
57
],
[
59,
61
],
[
63
]
] |
21,896 | static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
bool secondary, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int i;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (i = 0; i < HPTES_PER_GROUP; i++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
if ((pte0 & HPTE64_V_VALID)
&& (secondary == !!(pte0 & HPTE64_V_SECONDARY))
&& HPTE64_V_COMPARE(pte0, ptem)) {
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + i) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
/*
* We didn't find a valid entry.
*/
return -1;
}
| true | qemu | 4322e8ced5aaac7191958f09622d199fe61e2d87 | static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
bool secondary, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int i;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (i = 0; i < HPTES_PER_GROUP; i++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, i);
pte1 = ppc_hash64_load_hpte1(cpu, token, i);
if ((pte0 & HPTE64_V_VALID)
&& (secondary == !!(pte0 & HPTE64_V_SECONDARY))
&& HPTE64_V_COMPARE(pte0, ptem)) {
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + i) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
return -1;
}
| {
"code": [
" bool secondary, target_ulong ptem,",
" ppc_hash_pte64_t *pte)"
],
"line_no": [
3,
5
]
} | static hwaddr FUNC_0(PowerPCCPU *cpu, hwaddr hash,
bool secondary, target_ulong ptem,
ppc_hash_pte64_t *pte)
{
CPUPPCState *env = &cpu->env;
int VAR_0;
uint64_t token;
target_ulong pte0, pte1;
target_ulong pte_index;
pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;
token = ppc_hash64_start_access(cpu, pte_index);
if (!token) {
return -1;
}
for (VAR_0 = 0; VAR_0 < HPTES_PER_GROUP; VAR_0++) {
pte0 = ppc_hash64_load_hpte0(cpu, token, VAR_0);
pte1 = ppc_hash64_load_hpte1(cpu, token, VAR_0);
if ((pte0 & HPTE64_V_VALID)
&& (secondary == !!(pte0 & HPTE64_V_SECONDARY))
&& HPTE64_V_COMPARE(pte0, ptem)) {
pte->pte0 = pte0;
pte->pte1 = pte1;
ppc_hash64_stop_access(cpu, token);
return (pte_index + VAR_0) * HASH_PTE_SIZE_64;
}
}
ppc_hash64_stop_access(cpu, token);
return -1;
}
| [
"static hwaddr FUNC_0(PowerPCCPU *cpu, hwaddr hash,\nbool secondary, target_ulong ptem,\nppc_hash_pte64_t *pte)\n{",
"CPUPPCState *env = &cpu->env;",
"int VAR_0;",
"uint64_t token;",
"target_ulong pte0, pte1;",
"target_ulong pte_index;",
"pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP;",
"token = ppc_hash64_start_access(cpu, pte_index);",
"if (!token) {",
"return -1;",
"}",
"for (VAR_0 = 0; VAR_0 < HPTES_PER_GROUP; VAR_0++) {",
"pte0 = ppc_hash64_load_hpte0(cpu, token, VAR_0);",
"pte1 = ppc_hash64_load_hpte1(cpu, token, VAR_0);",
"if ((pte0 & HPTE64_V_VALID)\n&& (secondary == !!(pte0 & HPTE64_V_SECONDARY))\n&& HPTE64_V_COMPARE(pte0, ptem)) {",
"pte->pte0 = pte0;",
"pte->pte1 = pte1;",
"ppc_hash64_stop_access(cpu, token);",
"return (pte_index + VAR_0) * HASH_PTE_SIZE_64;",
"}",
"}",
"ppc_hash64_stop_access(cpu, token);",
"return -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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
65
],
[
67
]
] |
21,897 | static void qemu_kvm_eat_signal(CPUState *env, int timeout)
{
struct timespec ts;
int r, e;
siginfo_t siginfo;
sigset_t waitset;
ts.tv_sec = timeout / 1000;
ts.tv_nsec = (timeout % 1000) * 1000000;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
qemu_mutex_unlock(&qemu_global_mutex);
r = sigtimedwait(&waitset, &siginfo, &ts);
e = errno;
qemu_mutex_lock(&qemu_global_mutex);
if (r == -1 && !(e == EAGAIN || e == EINTR)) {
fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
exit(1);
}
}
| true | qemu | c0532a76b407af4b276dc5a62d8178db59857ea6 | static void qemu_kvm_eat_signal(CPUState *env, int timeout)
{
struct timespec ts;
int r, e;
siginfo_t siginfo;
sigset_t waitset;
ts.tv_sec = timeout / 1000;
ts.tv_nsec = (timeout % 1000) * 1000000;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
qemu_mutex_unlock(&qemu_global_mutex);
r = sigtimedwait(&waitset, &siginfo, &ts);
e = errno;
qemu_mutex_lock(&qemu_global_mutex);
if (r == -1 && !(e == EAGAIN || e == EINTR)) {
fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
exit(1);
}
}
| {
"code": [
" qemu_mutex_unlock(&qemu_global_mutex);",
" r = sigtimedwait(&waitset, &siginfo, &ts);",
" e = errno;",
" qemu_mutex_lock(&qemu_global_mutex);",
" if (r == -1 && !(e == EAGAIN || e == EINTR)) {",
" fprintf(stderr, \"sigtimedwait: %s\\n\", strerror(e));",
" exit(1);"
],
"line_no": [
27,
29,
31,
33,
37,
39,
41
]
} | static void FUNC_0(CPUState *VAR_0, int VAR_1)
{
struct timespec VAR_2;
int VAR_3, VAR_4;
siginfo_t siginfo;
sigset_t waitset;
VAR_2.tv_sec = VAR_1 / 1000;
VAR_2.tv_nsec = (VAR_1 % 1000) * 1000000;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
qemu_mutex_unlock(&qemu_global_mutex);
VAR_3 = sigtimedwait(&waitset, &siginfo, &VAR_2);
VAR_4 = errno;
qemu_mutex_lock(&qemu_global_mutex);
if (VAR_3 == -1 && !(VAR_4 == EAGAIN || VAR_4 == EINTR)) {
fprintf(stderr, "sigtimedwait: %s\n", strerror(VAR_4));
exit(1);
}
}
| [
"static void FUNC_0(CPUState *VAR_0, int VAR_1)\n{",
"struct timespec VAR_2;",
"int VAR_3, VAR_4;",
"siginfo_t siginfo;",
"sigset_t waitset;",
"VAR_2.tv_sec = VAR_1 / 1000;",
"VAR_2.tv_nsec = (VAR_1 % 1000) * 1000000;",
"sigemptyset(&waitset);",
"sigaddset(&waitset, SIG_IPI);",
"qemu_mutex_unlock(&qemu_global_mutex);",
"VAR_3 = sigtimedwait(&waitset, &siginfo, &VAR_2);",
"VAR_4 = errno;",
"qemu_mutex_lock(&qemu_global_mutex);",
"if (VAR_3 == -1 && !(VAR_4 == EAGAIN || VAR_4 == EINTR)) {",
"fprintf(stderr, \"sigtimedwait: %s\\n\", strerror(VAR_4));",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
21,898 | static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
int output_width, int output_height,
int output_sample_rate) {
WebMDashMuxContext *w = s->priv_data;
AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);
AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);
AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);
AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
if ((w->is_live && (!filename)) ||
(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
return -1;
}
avio_printf(s->pb, "<Representation id=\"%s\"", id);
// FIXME: For live, This should be obtained from the input file or as an AVOption.
avio_printf(s->pb, " bandwidth=\"%s\"",
w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
avio_printf(s->pb, " width=\"%d\"", stream->codec->width);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
avio_printf(s->pb, " height=\"%d\"", stream->codec->height);
if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)
avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);
if (w->is_live) {
// For live streams, Codec and Mime Type always go in the Representation tag.
avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));
avio_printf(s->pb, " mimeType=\"%s/webm\"",
stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
// For live streams, subsegments always start with key frames. So this
// is always 1.
avio_printf(s->pb, " startsWithSAP=\"1\"");
avio_printf(s->pb, ">");
} else {
avio_printf(s->pb, ">\n");
avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);
avio_printf(s->pb, "<SegmentBase\n");
avio_printf(s->pb, " indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);
avio_printf(s->pb, "<Initialization\n");
avio_printf(s->pb, " range=\"0-%s\" />\n", irange->value);
avio_printf(s->pb, "</SegmentBase>\n");
}
avio_printf(s->pb, "</Representation>\n");
return 0;
}
| true | FFmpeg | 1c37848f9029985d1271da9a0d161c2ebf0aca81 | static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
int output_width, int output_height,
int output_sample_rate) {
WebMDashMuxContext *w = s->priv_data;
AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);
AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);
AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);
AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
if ((w->is_live && (!filename)) ||
(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
return -1;
}
avio_printf(s->pb, "<Representation id=\"%s\"", id);
avio_printf(s->pb, " bandwidth=\"%s\"",
w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
avio_printf(s->pb, " width=\"%d\"", stream->codec->width);
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
avio_printf(s->pb, " height=\"%d\"", stream->codec->height);
if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)
avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);
if (w->is_live) {
avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));
avio_printf(s->pb, " mimeType=\"%s/webm\"",
stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
avio_printf(s->pb, " startsWithSAP=\"1\"");
avio_printf(s->pb, ">");
} else {
avio_printf(s->pb, ">\n");
avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);
avio_printf(s->pb, "<SegmentBase\n");
avio_printf(s->pb, " indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);
avio_printf(s->pb, "<Initialization\n");
avio_printf(s->pb, " range=\"0-%s\" />\n", irange->value);
avio_printf(s->pb, "</SegmentBase>\n");
}
avio_printf(s->pb, "</Representation>\n");
return 0;
}
| {
"code": [
" return -1;",
" WebMDashMuxContext *w = s->priv_data;"
],
"line_no": [
23,
7
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, char *VAR_2,
int VAR_3, int VAR_4,
int VAR_5) {
WebMDashMuxContext *w = VAR_0->priv_data;
AVDictionaryEntry *irange = av_dict_get(VAR_1->metadata, INITIALIZATION_RANGE, NULL, 0);
AVDictionaryEntry *cues_start = av_dict_get(VAR_1->metadata, CUES_START, NULL, 0);
AVDictionaryEntry *cues_end = av_dict_get(VAR_1->metadata, CUES_END, NULL, 0);
AVDictionaryEntry *filename = av_dict_get(VAR_1->metadata, FILENAME, NULL, 0);
AVDictionaryEntry *bandwidth = av_dict_get(VAR_1->metadata, BANDWIDTH, NULL, 0);
if ((w->is_live && (!filename)) ||
(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
return -1;
}
avio_printf(VAR_0->pb, "<Representation VAR_2=\"%VAR_0\"", VAR_2);
avio_printf(VAR_0->pb, " bandwidth=\"%VAR_0\"",
w->is_live ? (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_3)
avio_printf(VAR_0->pb, " width=\"%d\"", VAR_1->codec->width);
if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_4)
avio_printf(VAR_0->pb, " height=\"%d\"", VAR_1->codec->height);
if (VAR_1->codec->codec_type = AVMEDIA_TYPE_AUDIO && VAR_5)
avio_printf(VAR_0->pb, " audioSamplingRate=\"%d\"", VAR_1->codec->sample_rate);
if (w->is_live) {
avio_printf(VAR_0->pb, " codecs=\"%VAR_0\"", get_codec_name(VAR_1->codec->codec_id));
avio_printf(VAR_0->pb, " mimeType=\"%VAR_0/webm\"",
VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
avio_printf(VAR_0->pb, " startsWithSAP=\"1\"");
avio_printf(VAR_0->pb, ">");
} else {
avio_printf(VAR_0->pb, ">\n");
avio_printf(VAR_0->pb, "<BaseURL>%VAR_0</BaseURL>\n", filename->value);
avio_printf(VAR_0->pb, "<SegmentBase\n");
avio_printf(VAR_0->pb, " indexRange=\"%VAR_0-%VAR_0\">\n", cues_start->value, cues_end->value);
avio_printf(VAR_0->pb, "<Initialization\n");
avio_printf(VAR_0->pb, " range=\"0-%VAR_0\" />\n", irange->value);
avio_printf(VAR_0->pb, "</SegmentBase>\n");
}
avio_printf(VAR_0->pb, "</Representation>\n");
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, char *VAR_2,\nint VAR_3, int VAR_4,\nint VAR_5) {",
"WebMDashMuxContext *w = VAR_0->priv_data;",
"AVDictionaryEntry *irange = av_dict_get(VAR_1->metadata, INITIALIZATION_RANGE, NULL, 0);",
"AVDictionaryEntry *cues_start = av_dict_get(VAR_1->metadata, CUES_START, NULL, 0);",
"AVDictionaryEntry *cues_end = av_dict_get(VAR_1->metadata, CUES_END, NULL, 0);",
"AVDictionaryEntry *filename = av_dict_get(VAR_1->metadata, FILENAME, NULL, 0);",
"AVDictionaryEntry *bandwidth = av_dict_get(VAR_1->metadata, BANDWIDTH, NULL, 0);",
"if ((w->is_live && (!filename)) ||\n(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {",
"return -1;",
"}",
"avio_printf(VAR_0->pb, \"<Representation VAR_2=\\\"%VAR_0\\\"\", VAR_2);",
"avio_printf(VAR_0->pb, \" bandwidth=\\\"%VAR_0\\\"\",\nw->is_live ? (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO ? \"128000\" : \"1000000\") : bandwidth->value);",
"if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_3)\navio_printf(VAR_0->pb, \" width=\\\"%d\\\"\", VAR_1->codec->width);",
"if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_4)\navio_printf(VAR_0->pb, \" height=\\\"%d\\\"\", VAR_1->codec->height);",
"if (VAR_1->codec->codec_type = AVMEDIA_TYPE_AUDIO && VAR_5)\navio_printf(VAR_0->pb, \" audioSamplingRate=\\\"%d\\\"\", VAR_1->codec->sample_rate);",
"if (w->is_live) {",
"avio_printf(VAR_0->pb, \" codecs=\\\"%VAR_0\\\"\", get_codec_name(VAR_1->codec->codec_id));",
"avio_printf(VAR_0->pb, \" mimeType=\\\"%VAR_0/webm\\\"\",\nVAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO ? \"video\" : \"audio\");",
"avio_printf(VAR_0->pb, \" startsWithSAP=\\\"1\\\"\");",
"avio_printf(VAR_0->pb, \">\");",
"} else {",
"avio_printf(VAR_0->pb, \">\\n\");",
"avio_printf(VAR_0->pb, \"<BaseURL>%VAR_0</BaseURL>\\n\", filename->value);",
"avio_printf(VAR_0->pb, \"<SegmentBase\\n\");",
"avio_printf(VAR_0->pb, \" indexRange=\\\"%VAR_0-%VAR_0\\\">\\n\", cues_start->value, cues_end->value);",
"avio_printf(VAR_0->pb, \"<Initialization\\n\");",
"avio_printf(VAR_0->pb, \" range=\\\"0-%VAR_0\\\" />\\n\", irange->value);",
"avio_printf(VAR_0->pb, \"</SegmentBase>\\n\");",
"}",
"avio_printf(VAR_0->pb, \"</Representation>\\n\");",
"return 0;",
"}"
] | [
0,
1,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
51
],
[
53,
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
21,900 | static inline int set_options(AVFilterContext *ctx, const char *args)
{
HueContext *hue = ctx->priv;
int n, ret;
char c1 = 0, c2 = 0;
char *old_hue_expr, *old_hue_deg_expr, *old_saturation_expr;
AVExpr *old_hue_pexpr, *old_hue_deg_pexpr, *old_saturation_pexpr;
if (args) {
/* named options syntax */
if (strchr(args, '=')) {
old_hue_expr = hue->hue_expr;
old_hue_deg_expr = hue->hue_deg_expr;
old_saturation_expr = hue->saturation_expr;
old_hue_pexpr = hue->hue_pexpr;
old_hue_deg_pexpr = hue->hue_deg_pexpr;
old_saturation_pexpr = hue->saturation_pexpr;
hue->hue_expr = NULL;
hue->hue_deg_expr = NULL;
hue->saturation_expr = NULL;
if ((ret = av_set_options_string(hue, args, "=", ":")) < 0)
return ret;
if (hue->hue_expr && hue->hue_deg_expr) {
av_log(ctx, AV_LOG_ERROR,
"H and h options are incompatible and cannot be specified "
"at the same time\n");
hue->hue_expr = old_hue_expr;
hue->hue_deg_expr = old_hue_deg_expr;
return AVERROR(EINVAL);
}
/*
* if both 'H' and 'h' options have not been specified, restore the
* old values
*/
if (!hue->hue_expr && !hue->hue_deg_expr) {
hue->hue_expr = old_hue_expr;
hue->hue_deg_expr = old_hue_deg_expr;
}
if (hue->hue_deg_expr)
PARSE_EXPRESSION(hue_deg, h);
if (hue->hue_expr)
PARSE_EXPRESSION(hue, H);
if (hue->saturation_expr)
PARSE_EXPRESSION(saturation, s);
hue->flat_syntax = 0;
av_log(ctx, AV_LOG_VERBOSE,
"H_expr:%s h_deg_expr:%s s_expr:%s\n",
hue->hue_expr, hue->hue_deg_expr, hue->saturation_expr);
/* compatibility h:s syntax */
} else {
n = sscanf(args, "%f%c%f%c", &hue->hue_deg, &c1, &hue->saturation, &c2);
if (n != 1 && (n != 3 || c1 != ':')) {
av_log(ctx, AV_LOG_ERROR,
"Invalid syntax for argument '%s': "
"must be in the form 'hue[:saturation]'\n", args);
return AVERROR(EINVAL);
}
if (hue->saturation < SAT_MIN_VAL || hue->saturation > SAT_MAX_VAL) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value for saturation %0.1f: "
"must be included between range %d and +%d\n",
hue->saturation, SAT_MIN_VAL, SAT_MAX_VAL);
return AVERROR(EINVAL);
}
hue->hue = hue->hue_deg * M_PI / 180;
hue->flat_syntax = 1;
av_log(ctx, AV_LOG_VERBOSE,
"H:%0.1f h:%0.1f s:%0.1f\n",
hue->hue, hue->hue_deg, hue->saturation);
}
}
compute_sin_and_cos(hue);
return 0;
}
| true | FFmpeg | 7fe1ecefe17b0146d49cd0003f80266a481d1faa | static inline int set_options(AVFilterContext *ctx, const char *args)
{
HueContext *hue = ctx->priv;
int n, ret;
char c1 = 0, c2 = 0;
char *old_hue_expr, *old_hue_deg_expr, *old_saturation_expr;
AVExpr *old_hue_pexpr, *old_hue_deg_pexpr, *old_saturation_pexpr;
if (args) {
if (strchr(args, '=')) {
old_hue_expr = hue->hue_expr;
old_hue_deg_expr = hue->hue_deg_expr;
old_saturation_expr = hue->saturation_expr;
old_hue_pexpr = hue->hue_pexpr;
old_hue_deg_pexpr = hue->hue_deg_pexpr;
old_saturation_pexpr = hue->saturation_pexpr;
hue->hue_expr = NULL;
hue->hue_deg_expr = NULL;
hue->saturation_expr = NULL;
if ((ret = av_set_options_string(hue, args, "=", ":")) < 0)
return ret;
if (hue->hue_expr && hue->hue_deg_expr) {
av_log(ctx, AV_LOG_ERROR,
"H and h options are incompatible and cannot be specified "
"at the same time\n");
hue->hue_expr = old_hue_expr;
hue->hue_deg_expr = old_hue_deg_expr;
return AVERROR(EINVAL);
}
if (!hue->hue_expr && !hue->hue_deg_expr) {
hue->hue_expr = old_hue_expr;
hue->hue_deg_expr = old_hue_deg_expr;
}
if (hue->hue_deg_expr)
PARSE_EXPRESSION(hue_deg, h);
if (hue->hue_expr)
PARSE_EXPRESSION(hue, H);
if (hue->saturation_expr)
PARSE_EXPRESSION(saturation, s);
hue->flat_syntax = 0;
av_log(ctx, AV_LOG_VERBOSE,
"H_expr:%s h_deg_expr:%s s_expr:%s\n",
hue->hue_expr, hue->hue_deg_expr, hue->saturation_expr);
} else {
n = sscanf(args, "%f%c%f%c", &hue->hue_deg, &c1, &hue->saturation, &c2);
if (n != 1 && (n != 3 || c1 != ':')) {
av_log(ctx, AV_LOG_ERROR,
"Invalid syntax for argument '%s': "
"must be in the form 'hue[:saturation]'\n", args);
return AVERROR(EINVAL);
}
if (hue->saturation < SAT_MIN_VAL || hue->saturation > SAT_MAX_VAL) {
av_log(ctx, AV_LOG_ERROR,
"Invalid value for saturation %0.1f: "
"must be included between range %d and +%d\n",
hue->saturation, SAT_MIN_VAL, SAT_MAX_VAL);
return AVERROR(EINVAL);
}
hue->hue = hue->hue_deg * M_PI / 180;
hue->flat_syntax = 1;
av_log(ctx, AV_LOG_VERBOSE,
"H:%0.1f h:%0.1f s:%0.1f\n",
hue->hue, hue->hue_deg, hue->saturation);
}
}
compute_sin_and_cos(hue);
return 0;
}
| {
"code": [
" if (!hue->hue_expr && !hue->hue_deg_expr) {",
" hue->hue_expr = old_hue_expr;",
" hue->hue_deg_expr = old_hue_deg_expr;",
" if (hue->hue_deg_expr)",
" PARSE_EXPRESSION(hue_deg, h);",
" if (hue->hue_expr)",
" PARSE_EXPRESSION(hue, H);",
" if (hue->saturation_expr)",
" PARSE_EXPRESSION(saturation, s);"
],
"line_no": [
79,
59,
61,
89,
91,
93,
95,
97,
99
]
} | static inline int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1)
{
HueContext *hue = VAR_0->priv;
int VAR_2, VAR_3;
char VAR_4 = 0, VAR_5 = 0;
char *VAR_6, *VAR_7, *VAR_8;
AVExpr *old_hue_pexpr, *old_hue_deg_pexpr, *old_saturation_pexpr;
if (VAR_1) {
if (strchr(VAR_1, '=')) {
VAR_6 = hue->hue_expr;
VAR_7 = hue->hue_deg_expr;
VAR_8 = hue->saturation_expr;
old_hue_pexpr = hue->hue_pexpr;
old_hue_deg_pexpr = hue->hue_deg_pexpr;
old_saturation_pexpr = hue->saturation_pexpr;
hue->hue_expr = NULL;
hue->hue_deg_expr = NULL;
hue->saturation_expr = NULL;
if ((VAR_3 = av_set_options_string(hue, VAR_1, "=", ":")) < 0)
return VAR_3;
if (hue->hue_expr && hue->hue_deg_expr) {
av_log(VAR_0, AV_LOG_ERROR,
"H and h options are incompatible and cannot be specified "
"at the same time\VAR_2");
hue->hue_expr = VAR_6;
hue->hue_deg_expr = VAR_7;
return AVERROR(EINVAL);
}
if (!hue->hue_expr && !hue->hue_deg_expr) {
hue->hue_expr = VAR_6;
hue->hue_deg_expr = VAR_7;
}
if (hue->hue_deg_expr)
PARSE_EXPRESSION(hue_deg, h);
if (hue->hue_expr)
PARSE_EXPRESSION(hue, H);
if (hue->saturation_expr)
PARSE_EXPRESSION(saturation, s);
hue->flat_syntax = 0;
av_log(VAR_0, AV_LOG_VERBOSE,
"H_expr:%s h_deg_expr:%s s_expr:%s\VAR_2",
hue->hue_expr, hue->hue_deg_expr, hue->saturation_expr);
} else {
VAR_2 = sscanf(VAR_1, "%f%c%f%c", &hue->hue_deg, &VAR_4, &hue->saturation, &VAR_5);
if (VAR_2 != 1 && (VAR_2 != 3 || VAR_4 != ':')) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid syntax for argument '%s': "
"must be in the form 'hue[:saturation]'\VAR_2", VAR_1);
return AVERROR(EINVAL);
}
if (hue->saturation < SAT_MIN_VAL || hue->saturation > SAT_MAX_VAL) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid value for saturation %0.1f: "
"must be included between range %d and +%d\VAR_2",
hue->saturation, SAT_MIN_VAL, SAT_MAX_VAL);
return AVERROR(EINVAL);
}
hue->hue = hue->hue_deg * M_PI / 180;
hue->flat_syntax = 1;
av_log(VAR_0, AV_LOG_VERBOSE,
"H:%0.1f h:%0.1f s:%0.1f\VAR_2",
hue->hue, hue->hue_deg, hue->saturation);
}
}
compute_sin_and_cos(hue);
return 0;
}
| [
"static inline int FUNC_0(AVFilterContext *VAR_0, const char *VAR_1)\n{",
"HueContext *hue = VAR_0->priv;",
"int VAR_2, VAR_3;",
"char VAR_4 = 0, VAR_5 = 0;",
"char *VAR_6, *VAR_7, *VAR_8;",
"AVExpr *old_hue_pexpr, *old_hue_deg_pexpr, *old_saturation_pexpr;",
"if (VAR_1) {",
"if (strchr(VAR_1, '=')) {",
"VAR_6 = hue->hue_expr;",
"VAR_7 = hue->hue_deg_expr;",
"VAR_8 = hue->saturation_expr;",
"old_hue_pexpr = hue->hue_pexpr;",
"old_hue_deg_pexpr = hue->hue_deg_pexpr;",
"old_saturation_pexpr = hue->saturation_pexpr;",
"hue->hue_expr = NULL;",
"hue->hue_deg_expr = NULL;",
"hue->saturation_expr = NULL;",
"if ((VAR_3 = av_set_options_string(hue, VAR_1, \"=\", \":\")) < 0)\nreturn VAR_3;",
"if (hue->hue_expr && hue->hue_deg_expr) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"H and h options are incompatible and cannot be specified \"\n\"at the same time\\VAR_2\");",
"hue->hue_expr = VAR_6;",
"hue->hue_deg_expr = VAR_7;",
"return AVERROR(EINVAL);",
"}",
"if (!hue->hue_expr && !hue->hue_deg_expr) {",
"hue->hue_expr = VAR_6;",
"hue->hue_deg_expr = VAR_7;",
"}",
"if (hue->hue_deg_expr)\nPARSE_EXPRESSION(hue_deg, h);",
"if (hue->hue_expr)\nPARSE_EXPRESSION(hue, H);",
"if (hue->saturation_expr)\nPARSE_EXPRESSION(saturation, s);",
"hue->flat_syntax = 0;",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"H_expr:%s h_deg_expr:%s s_expr:%s\\VAR_2\",\nhue->hue_expr, hue->hue_deg_expr, hue->saturation_expr);",
"} else {",
"VAR_2 = sscanf(VAR_1, \"%f%c%f%c\", &hue->hue_deg, &VAR_4, &hue->saturation, &VAR_5);",
"if (VAR_2 != 1 && (VAR_2 != 3 || VAR_4 != ':')) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid syntax for argument '%s': \"\n\"must be in the form 'hue[:saturation]'\\VAR_2\", VAR_1);",
"return AVERROR(EINVAL);",
"}",
"if (hue->saturation < SAT_MIN_VAL || hue->saturation > SAT_MAX_VAL) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid value for saturation %0.1f: \"\n\"must be included between range %d and +%d\\VAR_2\",\nhue->saturation, SAT_MIN_VAL, SAT_MAX_VAL);",
"return AVERROR(EINVAL);",
"}",
"hue->hue = hue->hue_deg * M_PI / 180;",
"hue->flat_syntax = 1;",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"H:%0.1f h:%0.1f s:%0.1f\\VAR_2\",\nhue->hue, hue->hue_deg, hue->saturation);",
"}",
"}",
"compute_sin_and_cos(hue);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53,
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93,
95
],
[
97,
99
],
[
103
],
[
107,
109,
111
],
[
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
135
],
[
137,
139,
141,
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
157,
159,
161
],
[
163
],
[
165
],
[
169
],
[
173
],
[
175
]
] |
21,902 | static int iothread_stop(Object *object, void *opaque)
{
IOThread *iothread;
iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
if (!iothread || !iothread->ctx) {
return 0;
}
iothread->stopping = true;
aio_notify(iothread->ctx);
if (atomic_read(&iothread->main_loop)) {
g_main_loop_quit(iothread->main_loop);
}
qemu_thread_join(&iothread->thread);
return 0;
}
| true | qemu | 65072c157e466db2785748a929e775703b20eefe | static int iothread_stop(Object *object, void *opaque)
{
IOThread *iothread;
iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
if (!iothread || !iothread->ctx) {
return 0;
}
iothread->stopping = true;
aio_notify(iothread->ctx);
if (atomic_read(&iothread->main_loop)) {
g_main_loop_quit(iothread->main_loop);
}
qemu_thread_join(&iothread->thread);
return 0;
}
| {
"code": [
" if (!iothread || !iothread->ctx) {"
],
"line_no": [
11
]
} | static int FUNC_0(Object *VAR_0, void *VAR_1)
{
IOThread *iothread;
iothread = (IOThread *)object_dynamic_cast(VAR_0, TYPE_IOTHREAD);
if (!iothread || !iothread->ctx) {
return 0;
}
iothread->stopping = true;
aio_notify(iothread->ctx);
if (atomic_read(&iothread->main_loop)) {
g_main_loop_quit(iothread->main_loop);
}
qemu_thread_join(&iothread->thread);
return 0;
}
| [
"static int FUNC_0(Object *VAR_0, void *VAR_1)\n{",
"IOThread *iothread;",
"iothread = (IOThread *)object_dynamic_cast(VAR_0, TYPE_IOTHREAD);",
"if (!iothread || !iothread->ctx) {",
"return 0;",
"}",
"iothread->stopping = true;",
"aio_notify(iothread->ctx);",
"if (atomic_read(&iothread->main_loop)) {",
"g_main_loop_quit(iothread->main_loop);",
"}",
"qemu_thread_join(&iothread->thread);",
"return 0;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
21,903 | SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq,
scsi_completionfn completion, void *opaque)
{
SCSIDevice *d;
SCSIDeviceState *s;
s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState));
s->bdrv = bdrv;
s->tcq = tcq;
s->completion = completion;
s->opaque = opaque;
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->cluster_size = 4;
} else {
s->cluster_size = 1;
}
bdrv_get_geometry(s->bdrv, &nb_sectors);
nb_sectors /= s->cluster_size;
if (nb_sectors)
nb_sectors--;
s->max_lba = nb_sectors;
strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),
sizeof(s->drive_serial_str));
if (strlen(s->drive_serial_str) == 0)
pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), "0");
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));
d->state = s;
d->destroy = scsi_destroy;
d->send_command = scsi_send_command;
d->read_data = scsi_read_data;
d->write_data = scsi_write_data;
d->cancel_io = scsi_cancel_io;
d->get_buf = scsi_get_buf;
return d;
} | true | qemu | 274fb0e1ed962e9ae43ab05e7939499cebb39d26 | SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, int tcq,
scsi_completionfn completion, void *opaque)
{
SCSIDevice *d;
SCSIDeviceState *s;
s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState));
s->bdrv = bdrv;
s->tcq = tcq;
s->completion = completion;
s->opaque = opaque;
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->cluster_size = 4;
} else {
s->cluster_size = 1;
}
bdrv_get_geometry(s->bdrv, &nb_sectors);
nb_sectors /= s->cluster_size;
if (nb_sectors)
nb_sectors--;
s->max_lba = nb_sectors;
strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),
sizeof(s->drive_serial_str));
if (strlen(s->drive_serial_str) == 0)
pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), "0");
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));
d->state = s;
d->destroy = scsi_destroy;
d->send_command = scsi_send_command;
d->read_data = scsi_read_data;
d->write_data = scsi_write_data;
d->cancel_io = scsi_cancel_io;
d->get_buf = scsi_get_buf;
return d;
} | {
"code": [],
"line_no": []
} | SCSIDevice *FUNC_0(BlockDriverState *bdrv, int tcq,
scsi_completionfn completion, void *opaque)
{
SCSIDevice *d;
SCSIDeviceState *s;
s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState));
s->bdrv = bdrv;
s->tcq = tcq;
s->completion = completion;
s->opaque = opaque;
if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {
s->cluster_size = 4;
} else {
s->cluster_size = 1;
}
bdrv_get_geometry(s->bdrv, &nb_sectors);
nb_sectors /= s->cluster_size;
if (nb_sectors)
nb_sectors--;
s->max_lba = nb_sectors;
strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),
sizeof(s->drive_serial_str));
if (strlen(s->drive_serial_str) == 0)
pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), "0");
qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));
d->state = s;
d->destroy = scsi_destroy;
d->send_command = scsi_send_command;
d->read_data = scsi_read_data;
d->write_data = scsi_write_data;
d->cancel_io = scsi_cancel_io;
d->get_buf = scsi_get_buf;
return d;
} | [
"SCSIDevice *FUNC_0(BlockDriverState *bdrv, int tcq,\nscsi_completionfn completion, void *opaque)\n{",
"SCSIDevice *d;",
"SCSIDeviceState *s;",
"s = (SCSIDeviceState *)qemu_mallocz(sizeof(SCSIDeviceState));",
"s->bdrv = bdrv;",
"s->tcq = tcq;",
"s->completion = completion;",
"s->opaque = opaque;",
"if (bdrv_get_type_hint(s->bdrv) == BDRV_TYPE_CDROM) {",
"s->cluster_size = 4;",
"} else {",
"s->cluster_size = 1;",
"}",
"bdrv_get_geometry(s->bdrv, &nb_sectors);",
"nb_sectors /= s->cluster_size;",
"if (nb_sectors)\nnb_sectors--;",
"s->max_lba = nb_sectors;",
"strncpy(s->drive_serial_str, drive_get_serial(s->bdrv),\nsizeof(s->drive_serial_str));",
"if (strlen(s->drive_serial_str) == 0)\npstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), \"0\");",
"qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);",
"d = (SCSIDevice *)qemu_mallocz(sizeof(SCSIDevice));",
"d->state = s;",
"d->destroy = scsi_destroy;",
"d->send_command = scsi_send_command;",
"d->read_data = scsi_read_data;",
"d->write_data = scsi_write_data;",
"d->cancel_io = scsi_cancel_io;",
"d->get_buf = scsi_get_buf;",
"return d;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
14
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38,
40
],
[
42
],
[
44,
46
],
[
48,
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
72
],
[
74
]
] |
21,904 | static void usbredir_handle_destroy(USBDevice *udev)
{
USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
qemu_chr_delete(dev->cs);
/* Note must be done after qemu_chr_close, as that causes a close event */
qemu_bh_delete(dev->chardev_close_bh);
qemu_del_timer(dev->attach_timer);
qemu_free_timer(dev->attach_timer);
usbredir_cleanup_device_queues(dev);
if (dev->parser) {
usbredirparser_destroy(dev->parser);
}
if (dev->watch) {
g_source_remove(dev->watch);
}
free(dev->filter_rules);
} | true | qemu | a14ff8a650b5943ee6221b952494661f7cb3b5e2 | static void usbredir_handle_destroy(USBDevice *udev)
{
USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
qemu_chr_delete(dev->cs);
qemu_bh_delete(dev->chardev_close_bh);
qemu_del_timer(dev->attach_timer);
qemu_free_timer(dev->attach_timer);
usbredir_cleanup_device_queues(dev);
if (dev->parser) {
usbredirparser_destroy(dev->parser);
}
if (dev->watch) {
g_source_remove(dev->watch);
}
free(dev->filter_rules);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(USBDevice *VAR_0)
{
USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, VAR_0);
qemu_chr_delete(dev->cs);
qemu_bh_delete(dev->chardev_close_bh);
qemu_del_timer(dev->attach_timer);
qemu_free_timer(dev->attach_timer);
usbredir_cleanup_device_queues(dev);
if (dev->parser) {
usbredirparser_destroy(dev->parser);
}
if (dev->watch) {
g_source_remove(dev->watch);
}
free(dev->filter_rules);
} | [
"static void FUNC_0(USBDevice *VAR_0)\n{",
"USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, VAR_0);",
"qemu_chr_delete(dev->cs);",
"qemu_bh_delete(dev->chardev_close_bh);",
"qemu_del_timer(dev->attach_timer);",
"qemu_free_timer(dev->attach_timer);",
"usbredir_cleanup_device_queues(dev);",
"if (dev->parser) {",
"usbredirparser_destroy(dev->parser);",
"}",
"if (dev->watch) {",
"g_source_remove(dev->watch);",
"}",
"free(dev->filter_rules);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
14
],
[
18
],
[
20
],
[
24
],
[
28
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
42
],
[
44
]
] |
21,905 | static int find_optimal_param(uint32_t sum, int n)
{
int k;
uint32_t sum2;
if (sum <= n >> 1)
return 0;
sum2 = sum - (n >> 1);
k = av_log2(n < 256 ? FASTDIV(sum2, n) : sum2 / n);
return FFMIN(k, MAX_RICE_PARAM);
}
| true | FFmpeg | 5ff998a233d759d0de83ea6f95c383d03d25d88e | static int find_optimal_param(uint32_t sum, int n)
{
int k;
uint32_t sum2;
if (sum <= n >> 1)
return 0;
sum2 = sum - (n >> 1);
k = av_log2(n < 256 ? FASTDIV(sum2, n) : sum2 / n);
return FFMIN(k, MAX_RICE_PARAM);
}
| {
"code": [
"static int find_optimal_param(uint32_t sum, int n)",
" uint32_t sum2;",
" k = av_log2(n < 256 ? FASTDIV(sum2, n) : sum2 / n);"
],
"line_no": [
1,
7,
17
]
} | static int FUNC_0(uint32_t VAR_0, int VAR_1)
{
int VAR_2;
uint32_t sum2;
if (VAR_0 <= VAR_1 >> 1)
return 0;
sum2 = VAR_0 - (VAR_1 >> 1);
VAR_2 = av_log2(VAR_1 < 256 ? FASTDIV(sum2, VAR_1) : sum2 / VAR_1);
return FFMIN(VAR_2, MAX_RICE_PARAM);
}
| [
"static int FUNC_0(uint32_t VAR_0, int VAR_1)\n{",
"int VAR_2;",
"uint32_t sum2;",
"if (VAR_0 <= VAR_1 >> 1)\nreturn 0;",
"sum2 = VAR_0 - (VAR_1 >> 1);",
"VAR_2 = av_log2(VAR_1 < 256 ? FASTDIV(sum2, VAR_1) : sum2 / VAR_1);",
"return FFMIN(VAR_2, MAX_RICE_PARAM);",
"}"
] | [
1,
0,
1,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
21,906 | static void set_pixel_format(VncState *vs,
int bits_per_pixel, int depth,
int big_endian_flag, int true_color_flag,
int red_max, int green_max, int blue_max,
int red_shift, int green_shift, int blue_shift)
{
int host_big_endian_flag;
#ifdef WORDS_BIGENDIAN
host_big_endian_flag = 1;
#else
host_big_endian_flag = 0;
#endif
if (!true_color_flag) {
fail:
vnc_client_error(vs);
return;
}
if (bits_per_pixel == 32 &&
bits_per_pixel == vs->depth * 8 &&
host_big_endian_flag == big_endian_flag &&
red_max == 0xff && green_max == 0xff && blue_max == 0xff &&
red_shift == 16 && green_shift == 8 && blue_shift == 0) {
vs->depth = 4;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_32;
} else
if (bits_per_pixel == 16 &&
bits_per_pixel == vs->depth * 8 &&
host_big_endian_flag == big_endian_flag &&
red_max == 31 && green_max == 63 && blue_max == 31 &&
red_shift == 11 && green_shift == 5 && blue_shift == 0) {
vs->depth = 2;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_16;
} else
if (bits_per_pixel == 8 &&
bits_per_pixel == vs->depth * 8 &&
red_max == 7 && green_max == 7 && blue_max == 3 &&
red_shift == 5 && green_shift == 2 && blue_shift == 0) {
vs->depth = 1;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_8;
} else
{
/* generic and slower case */
if (bits_per_pixel != 8 &&
bits_per_pixel != 16 &&
bits_per_pixel != 32)
goto fail;
if (vs->depth == 4) {
vs->send_hextile_tile = send_hextile_tile_generic_32;
} else if (vs->depth == 2) {
vs->send_hextile_tile = send_hextile_tile_generic_16;
} else {
vs->send_hextile_tile = send_hextile_tile_generic_8;
}
vs->pix_big_endian = big_endian_flag;
vs->write_pixels = vnc_write_pixels_generic;
}
vs->client_red_shift = red_shift;
vs->client_red_max = red_max;
vs->client_green_shift = green_shift;
vs->client_green_max = green_max;
vs->client_blue_shift = blue_shift;
vs->client_blue_max = blue_max;
vs->pix_bpp = bits_per_pixel / 8;
vga_hw_invalidate();
vga_hw_update();
}
| true | qemu | 6cec5487990bf3f1f22b3fcb871978255e92ae0d | static void set_pixel_format(VncState *vs,
int bits_per_pixel, int depth,
int big_endian_flag, int true_color_flag,
int red_max, int green_max, int blue_max,
int red_shift, int green_shift, int blue_shift)
{
int host_big_endian_flag;
#ifdef WORDS_BIGENDIAN
host_big_endian_flag = 1;
#else
host_big_endian_flag = 0;
#endif
if (!true_color_flag) {
fail:
vnc_client_error(vs);
return;
}
if (bits_per_pixel == 32 &&
bits_per_pixel == vs->depth * 8 &&
host_big_endian_flag == big_endian_flag &&
red_max == 0xff && green_max == 0xff && blue_max == 0xff &&
red_shift == 16 && green_shift == 8 && blue_shift == 0) {
vs->depth = 4;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_32;
} else
if (bits_per_pixel == 16 &&
bits_per_pixel == vs->depth * 8 &&
host_big_endian_flag == big_endian_flag &&
red_max == 31 && green_max == 63 && blue_max == 31 &&
red_shift == 11 && green_shift == 5 && blue_shift == 0) {
vs->depth = 2;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_16;
} else
if (bits_per_pixel == 8 &&
bits_per_pixel == vs->depth * 8 &&
red_max == 7 && green_max == 7 && blue_max == 3 &&
red_shift == 5 && green_shift == 2 && blue_shift == 0) {
vs->depth = 1;
vs->write_pixels = vnc_write_pixels_copy;
vs->send_hextile_tile = send_hextile_tile_8;
} else
{
if (bits_per_pixel != 8 &&
bits_per_pixel != 16 &&
bits_per_pixel != 32)
goto fail;
if (vs->depth == 4) {
vs->send_hextile_tile = send_hextile_tile_generic_32;
} else if (vs->depth == 2) {
vs->send_hextile_tile = send_hextile_tile_generic_16;
} else {
vs->send_hextile_tile = send_hextile_tile_generic_8;
}
vs->pix_big_endian = big_endian_flag;
vs->write_pixels = vnc_write_pixels_generic;
}
vs->client_red_shift = red_shift;
vs->client_red_max = red_max;
vs->client_green_shift = green_shift;
vs->client_green_max = green_max;
vs->client_blue_shift = blue_shift;
vs->client_blue_max = blue_max;
vs->pix_bpp = bits_per_pixel / 8;
vga_hw_invalidate();
vga_hw_update();
}
| {
"code": [
" int host_big_endian_flag;",
"#ifdef WORDS_BIGENDIAN",
" host_big_endian_flag = 1;",
"#else",
" host_big_endian_flag = 0;",
"#endif",
" fail:",
" if (bits_per_pixel == 32 &&",
" bits_per_pixel == vs->depth * 8 &&",
" host_big_endian_flag == big_endian_flag &&",
" red_max == 0xff && green_max == 0xff && blue_max == 0xff &&",
" red_shift == 16 && green_shift == 8 && blue_shift == 0) {",
" vs->depth = 4;",
" vs->write_pixels = vnc_write_pixels_copy;",
" vs->send_hextile_tile = send_hextile_tile_32;",
" } else",
" if (bits_per_pixel == 16 &&",
" bits_per_pixel == vs->depth * 8 && ",
" host_big_endian_flag == big_endian_flag &&",
" red_max == 31 && green_max == 63 && blue_max == 31 &&",
" red_shift == 11 && green_shift == 5 && blue_shift == 0) {",
" vs->depth = 2;",
" vs->write_pixels = vnc_write_pixels_copy;",
" vs->send_hextile_tile = send_hextile_tile_16;",
" } else",
" if (bits_per_pixel == 8 &&",
" bits_per_pixel == vs->depth * 8 &&",
" red_max == 7 && green_max == 7 && blue_max == 3 &&",
" red_shift == 5 && green_shift == 2 && blue_shift == 0) {",
" vs->depth = 1;",
" vs->write_pixels = vnc_write_pixels_copy;",
" vs->send_hextile_tile = send_hextile_tile_8;",
" } else",
" if (bits_per_pixel != 8 &&",
" bits_per_pixel != 16 &&",
" bits_per_pixel != 32)",
" goto fail;",
" if (vs->depth == 4) {",
" vs->send_hextile_tile = send_hextile_tile_generic_32;",
" } else if (vs->depth == 2) {",
" vs->send_hextile_tile = send_hextile_tile_generic_16;",
" } else {",
" vs->send_hextile_tile = send_hextile_tile_generic_8;",
" vs->pix_big_endian = big_endian_flag;",
" vs->write_pixels = vnc_write_pixels_generic;",
" vs->client_red_shift = red_shift;",
" vs->client_red_max = red_max;",
" vs->client_green_shift = green_shift;",
" vs->client_green_max = green_max;",
" vs->client_blue_shift = blue_shift;",
" vs->client_blue_max = blue_max;",
" vs->pix_bpp = bits_per_pixel / 8;",
" int host_big_endian_flag;",
"#ifdef WORDS_BIGENDIAN",
" host_big_endian_flag = 1;",
"#else",
" host_big_endian_flag = 0;",
" } else {"
],
"line_no": [
13,
17,
19,
21,
23,
25,
29,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
41,
61,
63,
65,
49,
69,
53,
73,
39,
77,
79,
81,
49,
85,
53,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
117,
119,
125,
127,
129,
131,
133,
135,
137,
13,
17,
19,
21,
23,
109
]
} | static void FUNC_0(VncState *VAR_0,
int 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)
{
int VAR_11;
#ifdef WORDS_BIGENDIAN
VAR_11 = 1;
#else
VAR_11 = 0;
#endif
if (!VAR_4) {
fail:
vnc_client_error(VAR_0);
return;
}
if (VAR_1 == 32 &&
VAR_1 == VAR_0->VAR_2 * 8 &&
VAR_11 == VAR_3 &&
VAR_5 == 0xff && VAR_6 == 0xff && VAR_7 == 0xff &&
VAR_8 == 16 && VAR_9 == 8 && VAR_10 == 0) {
VAR_0->VAR_2 = 4;
VAR_0->write_pixels = vnc_write_pixels_copy;
VAR_0->send_hextile_tile = send_hextile_tile_32;
} else
if (VAR_1 == 16 &&
VAR_1 == VAR_0->VAR_2 * 8 &&
VAR_11 == VAR_3 &&
VAR_5 == 31 && VAR_6 == 63 && VAR_7 == 31 &&
VAR_8 == 11 && VAR_9 == 5 && VAR_10 == 0) {
VAR_0->VAR_2 = 2;
VAR_0->write_pixels = vnc_write_pixels_copy;
VAR_0->send_hextile_tile = send_hextile_tile_16;
} else
if (VAR_1 == 8 &&
VAR_1 == VAR_0->VAR_2 * 8 &&
VAR_5 == 7 && VAR_6 == 7 && VAR_7 == 3 &&
VAR_8 == 5 && VAR_9 == 2 && VAR_10 == 0) {
VAR_0->VAR_2 = 1;
VAR_0->write_pixels = vnc_write_pixels_copy;
VAR_0->send_hextile_tile = send_hextile_tile_8;
} else
{
if (VAR_1 != 8 &&
VAR_1 != 16 &&
VAR_1 != 32)
goto fail;
if (VAR_0->VAR_2 == 4) {
VAR_0->send_hextile_tile = send_hextile_tile_generic_32;
} else if (VAR_0->VAR_2 == 2) {
VAR_0->send_hextile_tile = send_hextile_tile_generic_16;
} else {
VAR_0->send_hextile_tile = send_hextile_tile_generic_8;
}
VAR_0->pix_big_endian = VAR_3;
VAR_0->write_pixels = vnc_write_pixels_generic;
}
VAR_0->client_red_shift = VAR_8;
VAR_0->client_red_max = VAR_5;
VAR_0->client_green_shift = VAR_9;
VAR_0->client_green_max = VAR_6;
VAR_0->client_blue_shift = VAR_10;
VAR_0->client_blue_max = VAR_7;
VAR_0->pix_bpp = VAR_1 / 8;
vga_hw_invalidate();
vga_hw_update();
}
| [
"static void FUNC_0(VncState *VAR_0,\nint VAR_1, int VAR_2,\nint VAR_3, int VAR_4,\nint VAR_5, int VAR_6, int VAR_7,\nint VAR_8, int VAR_9, int VAR_10)\n{",
"int VAR_11;",
"#ifdef WORDS_BIGENDIAN\nVAR_11 = 1;",
"#else\nVAR_11 = 0;",
"#endif\nif (!VAR_4) {",
"fail:\nvnc_client_error(VAR_0);",
"return;",
"}",
"if (VAR_1 == 32 &&\nVAR_1 == VAR_0->VAR_2 * 8 &&\nVAR_11 == VAR_3 &&\nVAR_5 == 0xff && VAR_6 == 0xff && VAR_7 == 0xff &&\nVAR_8 == 16 && VAR_9 == 8 && VAR_10 == 0) {",
"VAR_0->VAR_2 = 4;",
"VAR_0->write_pixels = vnc_write_pixels_copy;",
"VAR_0->send_hextile_tile = send_hextile_tile_32;",
"} else",
"if (VAR_1 == 16 &&\nVAR_1 == VAR_0->VAR_2 * 8 &&\nVAR_11 == VAR_3 &&\nVAR_5 == 31 && VAR_6 == 63 && VAR_7 == 31 &&\nVAR_8 == 11 && VAR_9 == 5 && VAR_10 == 0) {",
"VAR_0->VAR_2 = 2;",
"VAR_0->write_pixels = vnc_write_pixels_copy;",
"VAR_0->send_hextile_tile = send_hextile_tile_16;",
"} else",
"if (VAR_1 == 8 &&\nVAR_1 == VAR_0->VAR_2 * 8 &&\nVAR_5 == 7 && VAR_6 == 7 && VAR_7 == 3 &&\nVAR_8 == 5 && VAR_9 == 2 && VAR_10 == 0) {",
"VAR_0->VAR_2 = 1;",
"VAR_0->write_pixels = vnc_write_pixels_copy;",
"VAR_0->send_hextile_tile = send_hextile_tile_8;",
"} else",
"{",
"if (VAR_1 != 8 &&\nVAR_1 != 16 &&\nVAR_1 != 32)\ngoto fail;",
"if (VAR_0->VAR_2 == 4) {",
"VAR_0->send_hextile_tile = send_hextile_tile_generic_32;",
"} else if (VAR_0->VAR_2 == 2) {",
"VAR_0->send_hextile_tile = send_hextile_tile_generic_16;",
"} else {",
"VAR_0->send_hextile_tile = send_hextile_tile_generic_8;",
"}",
"VAR_0->pix_big_endian = VAR_3;",
"VAR_0->write_pixels = vnc_write_pixels_generic;",
"}",
"VAR_0->client_red_shift = VAR_8;",
"VAR_0->client_red_max = VAR_5;",
"VAR_0->client_green_shift = VAR_9;",
"VAR_0->client_green_max = VAR_6;",
"VAR_0->client_blue_shift = VAR_10;",
"VAR_0->client_blue_max = VAR_7;",
"VAR_0->pix_bpp = VAR_1 / 8;",
"vga_hw_invalidate();",
"vga_hw_update();",
"}"
] | [
0,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
0,
1,
0,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57,
59,
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
]
] |
21,907 | static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
size_t size)
{
int64_t len;
if (!bdrv_is_inserted(bs))
return -ENOMEDIUM;
if (bs->growable)
return 0;
len = bdrv_getlength(bs);
if (offset < 0)
if ((offset > len) || (len - offset < size))
return 0; | true | qemu | 1dd3a44753f10970ded50950d28353c00bfcaf91 | static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
size_t size)
{
int64_t len;
if (!bdrv_is_inserted(bs))
return -ENOMEDIUM;
if (bs->growable)
return 0;
len = bdrv_getlength(bs);
if (offset < 0)
if ((offset > len) || (len - offset < size))
return 0; | {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
size_t VAR_2)
{
int64_t len;
if (!bdrv_is_inserted(VAR_0))
return -ENOMEDIUM;
if (VAR_0->growable)
return 0;
len = bdrv_getlength(VAR_0);
if (VAR_1 < 0)
if ((VAR_1 > len) || (len - VAR_1 < VAR_2))
return 0; | [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nsize_t VAR_2)\n{",
"int64_t len;",
"if (!bdrv_is_inserted(VAR_0))\nreturn -ENOMEDIUM;",
"if (VAR_0->growable)\nreturn 0;",
"len = bdrv_getlength(VAR_0);",
"if (VAR_1 < 0)\nif ((VAR_1 > len) || (len - VAR_1 < VAR_2))\nreturn 0;"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5,
6
],
[
7,
8
],
[
9
],
[
10,
11,
12
]
] |
21,908 | static void net_socket_accept(void *opaque)
{
NetSocketListenState *s = opaque;
NetSocketState *s1;
struct sockaddr_in saddr;
socklen_t len;
int fd;
for(;;) {
len = sizeof(saddr);
fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len);
if (fd < 0 && errno != EINTR) {
return;
} else if (fd >= 0) {
break;
}
}
s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1);
if (!s1) {
closesocket(fd);
} else {
snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
"socket: connection from %s:%d",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
}
}
| true | qemu | e5d1fca0f20babbe355957b9ba536fe6187691cc | static void net_socket_accept(void *opaque)
{
NetSocketListenState *s = opaque;
NetSocketState *s1;
struct sockaddr_in saddr;
socklen_t len;
int fd;
for(;;) {
len = sizeof(saddr);
fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len);
if (fd < 0 && errno != EINTR) {
return;
} else if (fd >= 0) {
break;
}
}
s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1);
if (!s1) {
closesocket(fd);
} else {
snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
"socket: connection from %s:%d",
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
}
}
| {
"code": [
" if (!s1) {",
" closesocket(fd);",
" } else {"
],
"line_no": [
37,
39,
41
]
} | static void FUNC_0(void *VAR_0)
{
NetSocketListenState *s = VAR_0;
NetSocketState *s1;
struct sockaddr_in VAR_1;
socklen_t len;
int VAR_2;
for(;;) {
len = sizeof(VAR_1);
VAR_2 = qemu_accept(s->VAR_2, (struct sockaddr *)&VAR_1, &len);
if (VAR_2 < 0 && errno != EINTR) {
return;
} else if (VAR_2 >= 0) {
break;
}
}
s1 = net_socket_fd_init(s->vlan, s->model, s->name, VAR_2, 1);
if (!s1) {
closesocket(VAR_2);
} else {
snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
"socket: connection from %s:%d",
inet_ntoa(VAR_1.sin_addr), ntohs(VAR_1.sin_port));
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"NetSocketListenState *s = VAR_0;",
"NetSocketState *s1;",
"struct sockaddr_in VAR_1;",
"socklen_t len;",
"int VAR_2;",
"for(;;) {",
"len = sizeof(VAR_1);",
"VAR_2 = qemu_accept(s->VAR_2, (struct sockaddr *)&VAR_1, &len);",
"if (VAR_2 < 0 && errno != EINTR) {",
"return;",
"} else if (VAR_2 >= 0) {",
"break;",
"}",
"}",
"s1 = net_socket_fd_init(s->vlan, s->model, s->name, VAR_2, 1);",
"if (!s1) {",
"closesocket(VAR_2);",
"} else {",
"snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),\n\"socket: connection from %s:%d\",\ninet_ntoa(VAR_1.sin_addr), ntohs(VAR_1.sin_port));",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
]
] |
21,909 | static void svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
{
const int qmul = svq3_dequant_coeff[qp];
#define stride 16
int i;
int temp[16];
static const uint8_t x_offset[4] = { 0, 1 * stride, 4 * stride, 5 * stride };
for (i = 0; i < 4; i++) {
const int z0 = 13 * (input[4 * i + 0] + input[4 * i + 2]);
const int z1 = 13 * (input[4 * i + 0] - input[4 * i + 2]);
const int z2 = 7 * input[4 * i + 1] - 17 * input[4 * i + 3];
const int z3 = 17 * input[4 * i + 1] + 7 * input[4 * i + 3];
temp[4 * i + 0] = z0 + z3;
temp[4 * i + 1] = z1 + z2;
temp[4 * i + 2] = z1 - z2;
temp[4 * i + 3] = z0 - z3;
}
for (i = 0; i < 4; i++) {
const int offset = x_offset[i];
const int z0 = 13 * (temp[4 * 0 + i] + temp[4 * 2 + i]);
const int z1 = 13 * (temp[4 * 0 + i] - temp[4 * 2 + i]);
const int z2 = 7 * temp[4 * 1 + i] - 17 * temp[4 * 3 + i];
const int z3 = 17 * temp[4 * 1 + i] + 7 * temp[4 * 3 + i];
output[stride * 0 + offset] = (z0 + z3) * qmul + 0x80000 >> 20;
output[stride * 2 + offset] = (z1 + z2) * qmul + 0x80000 >> 20;
output[stride * 8 + offset] = (z1 - z2) * qmul + 0x80000 >> 20;
output[stride * 10 + offset] = (z0 - z3) * qmul + 0x80000 >> 20;
}
}
| true | FFmpeg | 669419939c1d36be35196859dc73ec9a194157ad | static void svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
{
const int qmul = svq3_dequant_coeff[qp];
#define stride 16
int i;
int temp[16];
static const uint8_t x_offset[4] = { 0, 1 * stride, 4 * stride, 5 * stride };
for (i = 0; i < 4; i++) {
const int z0 = 13 * (input[4 * i + 0] + input[4 * i + 2]);
const int z1 = 13 * (input[4 * i + 0] - input[4 * i + 2]);
const int z2 = 7 * input[4 * i + 1] - 17 * input[4 * i + 3];
const int z3 = 17 * input[4 * i + 1] + 7 * input[4 * i + 3];
temp[4 * i + 0] = z0 + z3;
temp[4 * i + 1] = z1 + z2;
temp[4 * i + 2] = z1 - z2;
temp[4 * i + 3] = z0 - z3;
}
for (i = 0; i < 4; i++) {
const int offset = x_offset[i];
const int z0 = 13 * (temp[4 * 0 + i] + temp[4 * 2 + i]);
const int z1 = 13 * (temp[4 * 0 + i] - temp[4 * 2 + i]);
const int z2 = 7 * temp[4 * 1 + i] - 17 * temp[4 * 3 + i];
const int z3 = 17 * temp[4 * 1 + i] + 7 * temp[4 * 3 + i];
output[stride * 0 + offset] = (z0 + z3) * qmul + 0x80000 >> 20;
output[stride * 2 + offset] = (z1 + z2) * qmul + 0x80000 >> 20;
output[stride * 8 + offset] = (z1 - z2) * qmul + 0x80000 >> 20;
output[stride * 10 + offset] = (z0 - z3) * qmul + 0x80000 >> 20;
}
}
| {
"code": [
" const int qmul = svq3_dequant_coeff[qp];",
" output[stride * 0 + offset] = (z0 + z3) * qmul + 0x80000 >> 20;",
" output[stride * 2 + offset] = (z1 + z2) * qmul + 0x80000 >> 20;",
" output[stride * 8 + offset] = (z1 - z2) * qmul + 0x80000 >> 20;",
" output[stride * 10 + offset] = (z0 - z3) * qmul + 0x80000 >> 20;"
],
"line_no": [
5,
55,
57,
59,
61
]
} | static void FUNC_0(int16_t *VAR_0, int16_t *VAR_1, int VAR_2)
{
const int VAR_3 = svq3_dequant_coeff[VAR_2];
#define stride 16
int VAR_4;
int VAR_5[16];
static const uint8_t VAR_6[4] = { 0, 1 * stride, 4 * stride, 5 * stride };
for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {
const int VAR_12 = 13 * (VAR_1[4 * VAR_4 + 0] + VAR_1[4 * VAR_4 + 2]);
const int VAR_12 = 13 * (VAR_1[4 * VAR_4 + 0] - VAR_1[4 * VAR_4 + 2]);
const int VAR_12 = 7 * VAR_1[4 * VAR_4 + 1] - 17 * VAR_1[4 * VAR_4 + 3];
const int VAR_12 = 17 * VAR_1[4 * VAR_4 + 1] + 7 * VAR_1[4 * VAR_4 + 3];
VAR_5[4 * VAR_4 + 0] = VAR_12 + VAR_12;
VAR_5[4 * VAR_4 + 1] = VAR_12 + VAR_12;
VAR_5[4 * VAR_4 + 2] = VAR_12 - VAR_12;
VAR_5[4 * VAR_4 + 3] = VAR_12 - VAR_12;
}
for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {
const int VAR_11 = VAR_6[VAR_4];
const int VAR_12 = 13 * (VAR_5[4 * 0 + VAR_4] + VAR_5[4 * 2 + VAR_4]);
const int VAR_12 = 13 * (VAR_5[4 * 0 + VAR_4] - VAR_5[4 * 2 + VAR_4]);
const int VAR_12 = 7 * VAR_5[4 * 1 + VAR_4] - 17 * VAR_5[4 * 3 + VAR_4];
const int VAR_12 = 17 * VAR_5[4 * 1 + VAR_4] + 7 * VAR_5[4 * 3 + VAR_4];
VAR_0[stride * 0 + VAR_11] = (VAR_12 + VAR_12) * VAR_3 + 0x80000 >> 20;
VAR_0[stride * 2 + VAR_11] = (VAR_12 + VAR_12) * VAR_3 + 0x80000 >> 20;
VAR_0[stride * 8 + VAR_11] = (VAR_12 - VAR_12) * VAR_3 + 0x80000 >> 20;
VAR_0[stride * 10 + VAR_11] = (VAR_12 - VAR_12) * VAR_3 + 0x80000 >> 20;
}
}
| [
"static void FUNC_0(int16_t *VAR_0, int16_t *VAR_1, int VAR_2)\n{",
"const int VAR_3 = svq3_dequant_coeff[VAR_2];",
"#define stride 16\nint VAR_4;",
"int VAR_5[16];",
"static const uint8_t VAR_6[4] = { 0, 1 * stride, 4 * stride, 5 * stride };",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {",
"const int VAR_12 = 13 * (VAR_1[4 * VAR_4 + 0] + VAR_1[4 * VAR_4 + 2]);",
"const int VAR_12 = 13 * (VAR_1[4 * VAR_4 + 0] - VAR_1[4 * VAR_4 + 2]);",
"const int VAR_12 = 7 * VAR_1[4 * VAR_4 + 1] - 17 * VAR_1[4 * VAR_4 + 3];",
"const int VAR_12 = 17 * VAR_1[4 * VAR_4 + 1] + 7 * VAR_1[4 * VAR_4 + 3];",
"VAR_5[4 * VAR_4 + 0] = VAR_12 + VAR_12;",
"VAR_5[4 * VAR_4 + 1] = VAR_12 + VAR_12;",
"VAR_5[4 * VAR_4 + 2] = VAR_12 - VAR_12;",
"VAR_5[4 * VAR_4 + 3] = VAR_12 - VAR_12;",
"}",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {",
"const int VAR_11 = VAR_6[VAR_4];",
"const int VAR_12 = 13 * (VAR_5[4 * 0 + VAR_4] + VAR_5[4 * 2 + VAR_4]);",
"const int VAR_12 = 13 * (VAR_5[4 * 0 + VAR_4] - VAR_5[4 * 2 + VAR_4]);",
"const int VAR_12 = 7 * VAR_5[4 * 1 + VAR_4] - 17 * VAR_5[4 * 3 + VAR_4];",
"const int VAR_12 = 17 * VAR_5[4 * 1 + VAR_4] + 7 * VAR_5[4 * 3 + VAR_4];",
"VAR_0[stride * 0 + VAR_11] = (VAR_12 + VAR_12) * VAR_3 + 0x80000 >> 20;",
"VAR_0[stride * 2 + VAR_11] = (VAR_12 + VAR_12) * VAR_3 + 0x80000 >> 20;",
"VAR_0[stride * 8 + VAR_11] = (VAR_12 - VAR_12) * VAR_3 + 0x80000 >> 20;",
"VAR_0[stride * 10 + VAR_11] = (VAR_12 - VAR_12) * VAR_3 + 0x80000 >> 20;",
"}",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
21,910 | static av_cold int adpcm_encode_init(AVCodecContext *avctx)
{
ADPCMEncodeContext *s = avctx->priv_data;
uint8_t *extradata;
int i;
if (avctx->channels > 2)
return -1; /* only stereo or mono =) */
if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
return -1;
}
if (avctx->trellis) {
int frontier = 1 << avctx->trellis;
int max_paths = frontier * FREEZE_INTERVAL;
FF_ALLOC_OR_GOTO(avctx, s->paths,
max_paths * sizeof(*s->paths), error);
FF_ALLOC_OR_GOTO(avctx, s->node_buf,
2 * frontier * sizeof(*s->node_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
2 * frontier * sizeof(*s->nodep_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
65536 * sizeof(*s->trellis_hash), error);
}
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
switch (avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_WAV:
/* each 16 bits sample gives one nibble
and we have 4 bytes per channel overhead */
avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
(4 * avctx->channels) + 1;
/* seems frame_size isn't taken into account...
have to buffer the samples :-( */
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_IMA_QT:
avctx->frame_size = 64;
avctx->block_align = 34 * avctx->channels;
break;
case CODEC_ID_ADPCM_MS:
/* each 16 bits sample gives one nibble
and we have 7 bytes per channel overhead */
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /
avctx->channels + 2;
avctx->block_align = BLKSIZE;
avctx->extradata_size = 32;
extradata = avctx->extradata = av_malloc(avctx->extradata_size);
if (!extradata)
return AVERROR(ENOMEM);
bytestream_put_le16(&extradata, avctx->frame_size);
bytestream_put_le16(&extradata, 7); /* wNumCoef */
for (i = 0; i < 7; i++) {
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[i] * 4);
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[i] * 4);
}
break;
case CODEC_ID_ADPCM_YAMAHA:
avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_SWF:
if (avctx->sample_rate != 11025 &&
avctx->sample_rate != 22050 &&
avctx->sample_rate != 44100) {
av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
goto error;
}
avctx->frame_size = 512 * (avctx->sample_rate / 11025);
break;
default:
goto error;
}
avctx->coded_frame = avcodec_alloc_frame();
return 0;
error:
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
av_freep(&s->trellis_hash);
return -1;
}
| true | FFmpeg | cb023d9afe9da0a9d221b5eeddd2981c520b5978 | static av_cold int adpcm_encode_init(AVCodecContext *avctx)
{
ADPCMEncodeContext *s = avctx->priv_data;
uint8_t *extradata;
int i;
if (avctx->channels > 2)
return -1;
if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
return -1;
}
if (avctx->trellis) {
int frontier = 1 << avctx->trellis;
int max_paths = frontier * FREEZE_INTERVAL;
FF_ALLOC_OR_GOTO(avctx, s->paths,
max_paths * sizeof(*s->paths), error);
FF_ALLOC_OR_GOTO(avctx, s->node_buf,
2 * frontier * sizeof(*s->node_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
2 * frontier * sizeof(*s->nodep_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
65536 * sizeof(*s->trellis_hash), error);
}
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
switch (avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_WAV:
avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
(4 * avctx->channels) + 1;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_IMA_QT:
avctx->frame_size = 64;
avctx->block_align = 34 * avctx->channels;
break;
case CODEC_ID_ADPCM_MS:
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /
avctx->channels + 2;
avctx->block_align = BLKSIZE;
avctx->extradata_size = 32;
extradata = avctx->extradata = av_malloc(avctx->extradata_size);
if (!extradata)
return AVERROR(ENOMEM);
bytestream_put_le16(&extradata, avctx->frame_size);
bytestream_put_le16(&extradata, 7);
for (i = 0; i < 7; i++) {
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[i] * 4);
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[i] * 4);
}
break;
case CODEC_ID_ADPCM_YAMAHA:
avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_SWF:
if (avctx->sample_rate != 11025 &&
avctx->sample_rate != 22050 &&
avctx->sample_rate != 44100) {
av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
goto error;
}
avctx->frame_size = 512 * (avctx->sample_rate / 11025);
break;
default:
goto error;
}
avctx->coded_frame = avcodec_alloc_frame();
return 0;
error:
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
av_freep(&s->trellis_hash);
return -1;
}
| {
"code": [
" avctx->coded_frame = avcodec_alloc_frame();"
],
"line_no": [
155
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
ADPCMEncodeContext *s = avctx->priv_data;
uint8_t *extradata;
int VAR_0;
if (avctx->channels > 2)
return -1;
if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
return -1;
}
if (avctx->trellis) {
int VAR_1 = 1 << avctx->trellis;
int VAR_2 = VAR_1 * FREEZE_INTERVAL;
FF_ALLOC_OR_GOTO(avctx, s->paths,
VAR_2 * sizeof(*s->paths), error);
FF_ALLOC_OR_GOTO(avctx, s->node_buf,
2 * VAR_1 * sizeof(*s->node_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
2 * VAR_1 * sizeof(*s->nodep_buf), error);
FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
65536 * sizeof(*s->trellis_hash), error);
}
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
switch (avctx->codec->id) {
case CODEC_ID_ADPCM_IMA_WAV:
avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /
(4 * avctx->channels) + 1;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_IMA_QT:
avctx->frame_size = 64;
avctx->block_align = 34 * avctx->channels;
break;
case CODEC_ID_ADPCM_MS:
avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /
avctx->channels + 2;
avctx->block_align = BLKSIZE;
avctx->extradata_size = 32;
extradata = avctx->extradata = av_malloc(avctx->extradata_size);
if (!extradata)
return AVERROR(ENOMEM);
bytestream_put_le16(&extradata, avctx->frame_size);
bytestream_put_le16(&extradata, 7);
for (VAR_0 = 0; VAR_0 < 7; VAR_0++) {
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[VAR_0] * 4);
bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[VAR_0] * 4);
}
break;
case CODEC_ID_ADPCM_YAMAHA:
avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE;
break;
case CODEC_ID_ADPCM_SWF:
if (avctx->sample_rate != 11025 &&
avctx->sample_rate != 22050 &&
avctx->sample_rate != 44100) {
av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
goto error;
}
avctx->frame_size = 512 * (avctx->sample_rate / 11025);
break;
default:
goto error;
}
avctx->coded_frame = avcodec_alloc_frame();
return 0;
error:
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
av_freep(&s->trellis_hash);
return -1;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"ADPCMEncodeContext *s = avctx->priv_data;",
"uint8_t *extradata;",
"int VAR_0;",
"if (avctx->channels > 2)\nreturn -1;",
"if (avctx->trellis && (unsigned)avctx->trellis > 16U) {",
"av_log(avctx, AV_LOG_ERROR, \"invalid trellis size\\n\");",
"return -1;",
"}",
"if (avctx->trellis) {",
"int VAR_1 = 1 << avctx->trellis;",
"int VAR_2 = VAR_1 * FREEZE_INTERVAL;",
"FF_ALLOC_OR_GOTO(avctx, s->paths,\nVAR_2 * sizeof(*s->paths), error);",
"FF_ALLOC_OR_GOTO(avctx, s->node_buf,\n2 * VAR_1 * sizeof(*s->node_buf), error);",
"FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,\n2 * VAR_1 * sizeof(*s->nodep_buf), error);",
"FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,\n65536 * sizeof(*s->trellis_hash), error);",
"}",
"avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);",
"switch (avctx->codec->id) {",
"case CODEC_ID_ADPCM_IMA_WAV:\navctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 /\n(4 * avctx->channels) + 1;",
"avctx->block_align = BLKSIZE;",
"break;",
"case CODEC_ID_ADPCM_IMA_QT:\navctx->frame_size = 64;",
"avctx->block_align = 34 * avctx->channels;",
"break;",
"case CODEC_ID_ADPCM_MS:\navctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /\navctx->channels + 2;",
"avctx->block_align = BLKSIZE;",
"avctx->extradata_size = 32;",
"extradata = avctx->extradata = av_malloc(avctx->extradata_size);",
"if (!extradata)\nreturn AVERROR(ENOMEM);",
"bytestream_put_le16(&extradata, avctx->frame_size);",
"bytestream_put_le16(&extradata, 7);",
"for (VAR_0 = 0; VAR_0 < 7; VAR_0++) {",
"bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff1[VAR_0] * 4);",
"bytestream_put_le16(&extradata, ff_adpcm_AdaptCoeff2[VAR_0] * 4);",
"}",
"break;",
"case CODEC_ID_ADPCM_YAMAHA:\navctx->frame_size = BLKSIZE * avctx->channels;",
"avctx->block_align = BLKSIZE;",
"break;",
"case CODEC_ID_ADPCM_SWF:\nif (avctx->sample_rate != 11025 &&\navctx->sample_rate != 22050 &&\navctx->sample_rate != 44100) {",
"av_log(avctx, AV_LOG_ERROR, \"Sample rate must be 11025, \"\n\"22050 or 44100\\n\");",
"goto error;",
"}",
"avctx->frame_size = 512 * (avctx->sample_rate / 11025);",
"break;",
"default:\ngoto error;",
"}",
"avctx->coded_frame = avcodec_alloc_frame();",
"return 0;",
"error:\nav_freep(&s->paths);",
"av_freep(&s->node_buf);",
"av_freep(&s->nodep_buf);",
"av_freep(&s->trellis_hash);",
"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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
53
],
[
57
],
[
59,
65,
67
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85,
91,
93
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129,
131,
133
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
]
] |
21,911 | int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
{
ERContext *er = &sl->er;
int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int x, y, i;
sl->ref_cache[0][scan8[5] + 1] =
sl->ref_cache[0][scan8[7] + 1] =
sl->ref_cache[0][scan8[13] + 1] =
sl->ref_cache[1][scan8[5] + 1] =
sl->ref_cache[1][scan8[7] + 1] =
sl->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (sl != h->slice_ctx) {
memset(er, 0, sizeof(*er));
} else
if (CONFIG_ERROR_RESILIENCE) {
/* init ER */
er->avctx = h->avctx;
er->decode_mb = h264_er_decode_mb;
er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width;
er->mb_height = h->mb_height;
er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
// error resilience code looks cleaner with this
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
(h->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
mb_array_size * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
yc_size * sizeof(int16_t), fail);
er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
sl->dc_val_base[i] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
}
| true | FFmpeg | d9d9fd9446eb722fd288f56d905f0dfde661af8f | int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
{
ERContext *er = &sl->er;
int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size;
int x, y, i;
sl->ref_cache[0][scan8[5] + 1] =
sl->ref_cache[0][scan8[7] + 1] =
sl->ref_cache[0][scan8[13] + 1] =
sl->ref_cache[1][scan8[5] + 1] =
sl->ref_cache[1][scan8[7] + 1] =
sl->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (sl != h->slice_ctx) {
memset(er, 0, sizeof(*er));
} else
if (CONFIG_ERROR_RESILIENCE) {
er->avctx = h->avctx;
er->decode_mb = h264_er_decode_mb;
er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width;
er->mb_height = h->mb_height;
er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
(h->mb_num + 1) * sizeof(int), fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
mb_array_size * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
yc_size * sizeof(int16_t), fail);
er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
sl->dc_val_base[i] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM);
}
| {
"code": [
" h->mb_height * h->mb_stride, fail);"
],
"line_no": [
97
]
} | int FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1)
{
ERContext *er = &VAR_1->er;
int VAR_2 = VAR_0->mb_height * VAR_0->mb_stride;
int VAR_3 = (2 * VAR_0->mb_width + 1) * (2 * VAR_0->mb_height + 1);
int VAR_4 = VAR_0->mb_stride * (VAR_0->mb_height + 1);
int VAR_5 = VAR_3 + 2 * VAR_4;
int VAR_6, VAR_7, VAR_8;
VAR_1->ref_cache[0][scan8[5] + 1] =
VAR_1->ref_cache[0][scan8[7] + 1] =
VAR_1->ref_cache[0][scan8[13] + 1] =
VAR_1->ref_cache[1][scan8[5] + 1] =
VAR_1->ref_cache[1][scan8[7] + 1] =
VAR_1->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
if (VAR_1 != VAR_0->slice_ctx) {
memset(er, 0, sizeof(*er));
} else
if (CONFIG_ERROR_RESILIENCE) {
er->avctx = VAR_0->avctx;
er->decode_mb = h264_er_decode_mb;
er->opaque = VAR_0;
er->quarter_sample = 1;
er->mb_num = VAR_0->mb_num;
er->mb_width = VAR_0->mb_width;
er->mb_height = VAR_0->mb_height;
er->mb_stride = VAR_0->mb_stride;
er->b8_stride = VAR_0->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mb_index2xy,
(VAR_0->mb_num + 1) * sizeof(int), fail);
for (VAR_7 = 0; VAR_7 < VAR_0->mb_height; VAR_7++)
for (VAR_6 = 0; VAR_6 < VAR_0->mb_width; VAR_6++)
er->mb_index2xy[VAR_6 + VAR_7 * VAR_0->mb_width] = VAR_6 + VAR_7 * VAR_0->mb_stride;
er->mb_index2xy[VAR_0->mb_height * VAR_0->mb_width] = (VAR_0->mb_height - 1) *
VAR_0->mb_stride + VAR_0->mb_width;
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->error_status_table,
VAR_2 * sizeof(uint8_t), fail);
FF_ALLOC_OR_GOTO(VAR_0->avctx, er->er_temp_buffer,
VAR_0->mb_height * VAR_0->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_1->dc_val_base,
VAR_5 * sizeof(int16_t), fail);
er->dc_val[0] = VAR_1->dc_val_base + VAR_0->mb_width * 2 + 2;
er->dc_val[1] = VAR_1->dc_val_base + VAR_3 + VAR_0->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + VAR_4;
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++)
VAR_1->dc_val_base[VAR_8] = 1024;
}
return 0;
fail:
return AVERROR(ENOMEM);
}
| [
"int FUNC_0(H264Context *VAR_0, H264SliceContext *VAR_1)\n{",
"ERContext *er = &VAR_1->er;",
"int VAR_2 = VAR_0->mb_height * VAR_0->mb_stride;",
"int VAR_3 = (2 * VAR_0->mb_width + 1) * (2 * VAR_0->mb_height + 1);",
"int VAR_4 = VAR_0->mb_stride * (VAR_0->mb_height + 1);",
"int VAR_5 = VAR_3 + 2 * VAR_4;",
"int VAR_6, VAR_7, VAR_8;",
"VAR_1->ref_cache[0][scan8[5] + 1] =\nVAR_1->ref_cache[0][scan8[7] + 1] =\nVAR_1->ref_cache[0][scan8[13] + 1] =\nVAR_1->ref_cache[1][scan8[5] + 1] =\nVAR_1->ref_cache[1][scan8[7] + 1] =\nVAR_1->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;",
"if (VAR_1 != VAR_0->slice_ctx) {",
"memset(er, 0, sizeof(*er));",
"} else",
"if (CONFIG_ERROR_RESILIENCE) {",
"er->avctx = VAR_0->avctx;",
"er->decode_mb = h264_er_decode_mb;",
"er->opaque = VAR_0;",
"er->quarter_sample = 1;",
"er->mb_num = VAR_0->mb_num;",
"er->mb_width = VAR_0->mb_width;",
"er->mb_height = VAR_0->mb_height;",
"er->mb_stride = VAR_0->mb_stride;",
"er->b8_stride = VAR_0->mb_width * 2 + 1;",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->mb_index2xy,\n(VAR_0->mb_num + 1) * sizeof(int), fail);",
"for (VAR_7 = 0; VAR_7 < VAR_0->mb_height; VAR_7++)",
"for (VAR_6 = 0; VAR_6 < VAR_0->mb_width; VAR_6++)",
"er->mb_index2xy[VAR_6 + VAR_7 * VAR_0->mb_width] = VAR_6 + VAR_7 * VAR_0->mb_stride;",
"er->mb_index2xy[VAR_0->mb_height * VAR_0->mb_width] = (VAR_0->mb_height - 1) *\nVAR_0->mb_stride + VAR_0->mb_width;",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, er->error_status_table,\nVAR_2 * sizeof(uint8_t), fail);",
"FF_ALLOC_OR_GOTO(VAR_0->avctx, er->er_temp_buffer,\nVAR_0->mb_height * VAR_0->mb_stride, fail);",
"FF_ALLOCZ_OR_GOTO(VAR_0->avctx, VAR_1->dc_val_base,\nVAR_5 * sizeof(int16_t), fail);",
"er->dc_val[0] = VAR_1->dc_val_base + VAR_0->mb_width * 2 + 2;",
"er->dc_val[1] = VAR_1->dc_val_base + VAR_3 + VAR_0->mb_stride + 1;",
"er->dc_val[2] = er->dc_val[1] + VAR_4;",
"for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++)",
"VAR_1->dc_val_base[VAR_8] = 1024;",
"}",
"return 0;",
"fail:\nreturn AVERROR(ENOMEM);",
"}"
] | [
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23,
25,
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69,
71
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
89,
91
],
[
95,
97
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
123,
125
],
[
127
]
] |
21,912 | static void test_visitor_in_alternate_number(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
AltStrBool *asb;
AltStrNum *asn;
AltNumStr *ans;
AltStrInt *asi;
AltIntNum *ain;
AltNumInt *ani;
/* Parsing an int */
v = visitor_input_test_init(data, "42");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
/* FIXME: Order of alternate should not affect semantics; asn should
* parse the same as ans */
v = visitor_input_test_init(data, "42");
visit_type_AltStrNum(v, &asn, NULL, &err);
/* FIXME g_assert_cmpint(asn->type, == ALT_STR_NUM_KIND_N); */
/* FIXME g_assert_cmpfloat(asn->u.n, ==, 42); */
error_free_or_abort(&err);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(data, "42");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(data, "42");
visit_type_AltStrInt(v, &asi, NULL, &error_abort);
g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I);
g_assert_cmpint(asi->u.i, ==, 42);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(data, "42");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I);
g_assert_cmpint(ain->u.i, ==, 42);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(data, "42");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I);
g_assert_cmpint(ani->u.i, ==, 42);
qapi_free_AltNumInt(ani);
/* Parsing a double */
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrNum(v, &asn, NULL, &error_abort);
g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N);
g_assert_cmpfloat(asn->u.n, ==, 42.5);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(data, "42.5");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42.5);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrInt(v, &asi, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(data, "42.5");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N);
g_assert_cmpfloat(ain->u.n, ==, 42.5);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(data, "42.5");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N);
g_assert_cmpfloat(ani->u.n, ==, 42.5);
qapi_free_AltNumInt(ani);
}
| true | qemu | 0426d53c6530606bf7641b83f2b755fe61c280ee | static void test_visitor_in_alternate_number(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
Error *err = NULL;
AltStrBool *asb;
AltStrNum *asn;
AltNumStr *ans;
AltStrInt *asi;
AltIntNum *ain;
AltNumInt *ani;
v = visitor_input_test_init(data, "42");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
v = visitor_input_test_init(data, "42");
visit_type_AltStrNum(v, &asn, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(data, "42");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(data, "42");
visit_type_AltStrInt(v, &asi, NULL, &error_abort);
g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I);
g_assert_cmpint(asi->u.i, ==, 42);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(data, "42");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I);
g_assert_cmpint(ain->u.i, ==, 42);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(data, "42");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I);
g_assert_cmpint(ani->u.i, ==, 42);
qapi_free_AltNumInt(ani);
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrNum(v, &asn, NULL, &error_abort);
g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N);
g_assert_cmpfloat(asn->u.n, ==, 42.5);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(data, "42.5");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42.5);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(data, "42.5");
visit_type_AltStrInt(v, &asi, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(data, "42.5");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N);
g_assert_cmpfloat(ain->u.n, ==, 42.5);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(data, "42.5");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N);
g_assert_cmpfloat(ani->u.n, ==, 42.5);
qapi_free_AltNumInt(ani);
}
| {
"code": [
" visit_type_AltNumStr(v, &ans, NULL, &error_abort);",
" g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);",
" g_assert_cmpfloat(ans->u.n, ==, 42);",
" g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I);",
" g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I);",
" g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I);",
" g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N);",
" g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);",
" g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N);",
" g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N);"
],
"line_no": [
59,
61,
63,
73,
85,
97,
123,
61,
157,
169
]
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
Visitor *v;
Error *err = NULL;
AltStrBool *asb;
AltStrNum *asn;
AltNumStr *ans;
AltStrInt *asi;
AltIntNum *ain;
AltNumInt *ani;
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltStrNum(v, &asn, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltStrInt(v, &asi, NULL, &error_abort);
g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I);
g_assert_cmpint(asi->u.i, ==, 42);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I);
g_assert_cmpint(ain->u.i, ==, 42);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(VAR_0, "42");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I);
g_assert_cmpint(ani->u.i, ==, 42);
qapi_free_AltNumInt(ani);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltStrBool(v, &asb, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrBool(asb);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltStrNum(v, &asn, NULL, &error_abort);
g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N);
g_assert_cmpfloat(asn->u.n, ==, 42.5);
qapi_free_AltStrNum(asn);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltNumStr(v, &ans, NULL, &error_abort);
g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);
g_assert_cmpfloat(ans->u.n, ==, 42.5);
qapi_free_AltNumStr(ans);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltStrInt(v, &asi, NULL, &err);
error_free_or_abort(&err);
qapi_free_AltStrInt(asi);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltIntNum(v, &ain, NULL, &error_abort);
g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N);
g_assert_cmpfloat(ain->u.n, ==, 42.5);
qapi_free_AltIntNum(ain);
v = visitor_input_test_init(VAR_0, "42.5");
visit_type_AltNumInt(v, &ani, NULL, &error_abort);
g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N);
g_assert_cmpfloat(ani->u.n, ==, 42.5);
qapi_free_AltNumInt(ani);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"Visitor *v;",
"Error *err = NULL;",
"AltStrBool *asb;",
"AltStrNum *asn;",
"AltNumStr *ans;",
"AltStrInt *asi;",
"AltIntNum *ain;",
"AltNumInt *ani;",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltStrBool(v, &asb, NULL, &err);",
"error_free_or_abort(&err);",
"qapi_free_AltStrBool(asb);",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltStrNum(v, &asn, NULL, &err);",
"error_free_or_abort(&err);",
"qapi_free_AltStrNum(asn);",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltNumStr(v, &ans, NULL, &error_abort);",
"g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);",
"g_assert_cmpfloat(ans->u.n, ==, 42);",
"qapi_free_AltNumStr(ans);",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltStrInt(v, &asi, NULL, &error_abort);",
"g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I);",
"g_assert_cmpint(asi->u.i, ==, 42);",
"qapi_free_AltStrInt(asi);",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltIntNum(v, &ain, NULL, &error_abort);",
"g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I);",
"g_assert_cmpint(ain->u.i, ==, 42);",
"qapi_free_AltIntNum(ain);",
"v = visitor_input_test_init(VAR_0, \"42\");",
"visit_type_AltNumInt(v, &ani, NULL, &error_abort);",
"g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I);",
"g_assert_cmpint(ani->u.i, ==, 42);",
"qapi_free_AltNumInt(ani);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltStrBool(v, &asb, NULL, &err);",
"error_free_or_abort(&err);",
"qapi_free_AltStrBool(asb);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltStrNum(v, &asn, NULL, &error_abort);",
"g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N);",
"g_assert_cmpfloat(asn->u.n, ==, 42.5);",
"qapi_free_AltStrNum(asn);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltNumStr(v, &ans, NULL, &error_abort);",
"g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N);",
"g_assert_cmpfloat(ans->u.n, ==, 42.5);",
"qapi_free_AltNumStr(ans);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltStrInt(v, &asi, NULL, &err);",
"error_free_or_abort(&err);",
"qapi_free_AltStrInt(asi);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltIntNum(v, &ain, NULL, &error_abort);",
"g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N);",
"g_assert_cmpfloat(ain->u.n, ==, 42.5);",
"qapi_free_AltIntNum(ain);",
"v = visitor_input_test_init(VAR_0, \"42.5\");",
"visit_type_AltNumInt(v, &ani, NULL, &error_abort);",
"g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N);",
"g_assert_cmpfloat(ani->u.n, ==, 42.5);",
"qapi_free_AltNumInt(ani);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
29
],
[
31
],
[
33
],
[
35
],
[
43
],
[
45
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
]
] |
21,913 | static int coroutine_fn iscsi_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
uint64_t lba;
uint32_t num_sectors;
uint8_t *data = NULL;
uint8_t *buf = NULL;
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
return -EINVAL;
}
lba = sector_qemu2lun(sector_num, iscsilun);
num_sectors = sector_qemu2lun(nb_sectors, iscsilun);
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
/* if the iovec only contains one buffer we can pass it directly */
if (iov->niov == 1) {
data = iov->iov[0].iov_base;
} else {
size_t size = MIN(nb_sectors * BDRV_SECTOR_SIZE, iov->size);
buf = g_malloc(size);
qemu_iovec_to_buf(iov, 0, buf, size);
data = buf;
}
#endif
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsilun->use_16_for_rw) {
iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
} else {
iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
}
if (iTask.task == NULL) {
g_free(buf);
return -ENOMEM;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov,
iov->niov);
#endif
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
g_free(buf);
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors);
return 0;
}
| true | qemu | e49ab19fcaa617ad6cdfe1ac401327326b6a2552 | static int coroutine_fn iscsi_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
uint64_t lba;
uint32_t num_sectors;
uint8_t *data = NULL;
uint8_t *buf = NULL;
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
return -EINVAL;
}
lba = sector_qemu2lun(sector_num, iscsilun);
num_sectors = sector_qemu2lun(nb_sectors, iscsilun);
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
if (iov->niov == 1) {
data = iov->iov[0].iov_base;
} else {
size_t size = MIN(nb_sectors * BDRV_SECTOR_SIZE, iov->size);
buf = g_malloc(size);
qemu_iovec_to_buf(iov, 0, buf, size);
data = buf;
}
#endif
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsilun->use_16_for_rw) {
iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
} else {
iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
}
if (iTask.task == NULL) {
g_free(buf);
return -ENOMEM;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov,
iov->niov);
#endif
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
g_free(buf);
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors);
return 0;
}
| {
"code": [
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)",
" if (iov->niov == 1) {",
" data = iov->iov[0].iov_base;",
" } else {",
" size_t size = MIN(nb_sectors * BDRV_SECTOR_SIZE, iov->size);",
" buf = g_malloc(size);",
" qemu_iovec_to_buf(iov, 0, buf, size);",
" data = buf;",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#endif",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)",
"#endif",
"#endif"
],
"line_no": [
35,
39,
41,
43,
45,
47,
49,
51,
55,
91,
55,
91,
35,
55,
91,
55,
55,
91,
55,
91,
55,
91,
55,
55,
55,
91,
55,
91,
55,
55
]
} | static int VAR_0 iscsi_co_writev(BlockDriverState *bs,
int64_t sector_num, int nb_sectors,
QEMUIOVector *iov)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
uint64_t lba;
uint32_t num_sectors;
uint8_t *data = NULL;
uint8_t *buf = NULL;
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
return -EINVAL;
}
lba = sector_qemu2lun(sector_num, iscsilun);
num_sectors = sector_qemu2lun(nb_sectors, iscsilun);
#if !defined(LIBISCSI_FEATURE_IOVECTOR)
if (iov->niov == 1) {
data = iov->iov[0].iov_base;
} else {
size_t size = MIN(nb_sectors * BDRV_SECTOR_SIZE, iov->size);
buf = g_malloc(size);
qemu_iovec_to_buf(iov, 0, buf, size);
data = buf;
}
#endif
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsilun->use_16_for_rw) {
iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
} else {
iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba,
data, num_sectors * iscsilun->block_size,
iscsilun->block_size, 0, 0, 0, 0, 0,
iscsi_co_generic_cb, &iTask);
}
if (iTask.task == NULL) {
g_free(buf);
return -ENOMEM;
}
#if defined(LIBISCSI_FEATURE_IOVECTOR)
scsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov,
iov->niov);
#endif
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
g_free(buf);
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors);
return 0;
}
| [
"static int VAR_0 iscsi_co_writev(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors,\nQEMUIOVector *iov)\n{",
"IscsiLun *iscsilun = bs->opaque;",
"struct IscsiTask iTask;",
"uint64_t lba;",
"uint32_t num_sectors;",
"uint8_t *data = NULL;",
"uint8_t *buf = NULL;",
"if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {",
"return -EINVAL;",
"}",
"lba = sector_qemu2lun(sector_num, iscsilun);",
"num_sectors = sector_qemu2lun(nb_sectors, iscsilun);",
"#if !defined(LIBISCSI_FEATURE_IOVECTOR)\nif (iov->niov == 1) {",
"data = iov->iov[0].iov_base;",
"} else {",
"size_t size = MIN(nb_sectors * BDRV_SECTOR_SIZE, iov->size);",
"buf = g_malloc(size);",
"qemu_iovec_to_buf(iov, 0, buf, size);",
"data = buf;",
"}",
"#endif\niscsi_co_init_iscsitask(iscsilun, &iTask);",
"retry:\nif (iscsilun->use_16_for_rw) {",
"iTask.task = iscsi_write16_task(iscsilun->iscsi, iscsilun->lun, lba,\ndata, num_sectors * iscsilun->block_size,\niscsilun->block_size, 0, 0, 0, 0, 0,\niscsi_co_generic_cb, &iTask);",
"} else {",
"iTask.task = iscsi_write10_task(iscsilun->iscsi, iscsilun->lun, lba,\ndata, num_sectors * iscsilun->block_size,\niscsilun->block_size, 0, 0, 0, 0, 0,\niscsi_co_generic_cb, &iTask);",
"}",
"if (iTask.task == NULL) {",
"g_free(buf);",
"return -ENOMEM;",
"}",
"#if defined(LIBISCSI_FEATURE_IOVECTOR)\nscsi_task_set_iov_out(iTask.task, (struct scsi_iovec *) iov->iov,\niov->niov);",
"#endif\nwhile (!iTask.complete) {",
"iscsi_set_events(iscsilun);",
"qemu_coroutine_yield();",
"}",
"if (iTask.task != NULL) {",
"scsi_free_scsi_task(iTask.task);",
"iTask.task = NULL;",
"}",
"if (iTask.do_retry) {",
"iTask.complete = 0;",
"goto retry;",
"}",
"g_free(buf);",
"if (iTask.status != SCSI_STATUS_GOOD) {",
"return -EIO;",
"}",
"iscsi_allocationmap_set(iscsilun, sector_num, nb_sectors);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
1,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35,
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
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145
],
[
147
]
] |
21,915 | static void add_sel_entry(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMI_CHECK_CMD_LEN(18);
if (sel_add_event(ibs, cmd + 2)) {
rsp[2] = IPMI_CC_OUT_OF_SPACE;
return;
}
/* sel_add_event fills in the record number. */
IPMI_ADD_RSP_DATA(cmd[2]);
IPMI_ADD_RSP_DATA(cmd[3]);
}
| true | qemu | 4f298a4b2957b7833bc607c951ca27c458d98d88 | static void add_sel_entry(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMI_CHECK_CMD_LEN(18);
if (sel_add_event(ibs, cmd + 2)) {
rsp[2] = IPMI_CC_OUT_OF_SPACE;
return;
}
IPMI_ADD_RSP_DATA(cmd[2]);
IPMI_ADD_RSP_DATA(cmd[3]);
}
| {
"code": [
" IPMI_CHECK_CMD_LEN(18);"
],
"line_no": [
11
]
} | static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{
IPMI_CHECK_CMD_LEN(18);
if (sel_add_event(VAR_0, VAR_1 + 2)) {
VAR_3[2] = IPMI_CC_OUT_OF_SPACE;
return;
}
IPMI_ADD_RSP_DATA(VAR_1[2]);
IPMI_ADD_RSP_DATA(VAR_1[3]);
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{",
"IPMI_CHECK_CMD_LEN(18);",
"if (sel_add_event(VAR_0, VAR_1 + 2)) {",
"VAR_3[2] = IPMI_CC_OUT_OF_SPACE;",
"return;",
"}",
"IPMI_ADD_RSP_DATA(VAR_1[2]);",
"IPMI_ADD_RSP_DATA(VAR_1[3]);",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
]
] |
21,916 | static void vmdk_free_last_extent(BlockDriverState *bs)
{
BDRVVmdkState *s = bs->opaque;
if (s->num_extents == 0) {
return;
}
s->num_extents--;
s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent));
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | static void vmdk_free_last_extent(BlockDriverState *bs)
{
BDRVVmdkState *s = bs->opaque;
if (s->num_extents == 0) {
return;
}
s->num_extents--;
s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent));
}
| {
"code": [
" s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent));"
],
"line_no": [
17
]
} | static void FUNC_0(BlockDriverState *VAR_0)
{
BDRVVmdkState *s = VAR_0->opaque;
if (s->num_extents == 0) {
return;
}
s->num_extents--;
s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent));
}
| [
"static void FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVVmdkState *s = VAR_0->opaque;",
"if (s->num_extents == 0) {",
"return;",
"}",
"s->num_extents--;",
"s->extents = g_realloc(s->extents, s->num_extents * sizeof(VmdkExtent));",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
21,917 | static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
int enc_size = 0;
SchroEncoderParams *p_schro_params = avctx->priv_data;
SchroEncoder *encoder = p_schro_params->encoder;
struct FFSchroEncodedFrame *p_frame_output = NULL;
int go = 1;
SchroBuffer *enc_buf;
int presentation_frame;
int parse_code;
int last_frame_in_sequence = 0;
int pkt_size, ret;
if (!frame) {
/* Push end of sequence if not already signalled. */
if (!p_schro_params->eos_signalled) {
schro_encoder_end_of_stream(encoder);
p_schro_params->eos_signalled = 1;
}
} else {
/* Allocate frame data to schro input buffer. */
SchroFrame *in_frame = libschroedinger_frame_from_data(avctx, frame);
if (!in_frame)
return AVERROR(ENOMEM);
/* Load next frame. */
schro_encoder_push_frame(encoder, in_frame);
}
if (p_schro_params->eos_pulled)
go = 0;
/* Now check to see if we have any output from the encoder. */
while (go) {
int err;
SchroStateEnum state;
state = schro_encoder_wait(encoder);
switch (state) {
case SCHRO_STATE_HAVE_BUFFER:
case SCHRO_STATE_END_OF_STREAM:
enc_buf = schro_encoder_pull(encoder, &presentation_frame);
if (enc_buf->length <= 0)
return AVERROR_BUG;
parse_code = enc_buf->data[4];
/* All non-frame data is prepended to actual frame data to
* be able to set the pts correctly. So we don't write data
* to the frame output queue until we actually have a frame
*/
if ((err = av_reallocp(&p_schro_params->enc_buf,
p_schro_params->enc_buf_size +
enc_buf->length)) < 0) {
p_schro_params->enc_buf_size = 0;
return err;
}
memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
enc_buf->data, enc_buf->length);
p_schro_params->enc_buf_size += enc_buf->length;
if (state == SCHRO_STATE_END_OF_STREAM) {
p_schro_params->eos_pulled = 1;
go = 0;
}
if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
schro_buffer_unref(enc_buf);
break;
}
/* Create output frame. */
p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame));
if (!p_frame_output)
return AVERROR(ENOMEM);
/* Set output data. */
p_frame_output->size = p_schro_params->enc_buf_size;
p_frame_output->p_encbuf = p_schro_params->enc_buf;
if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
p_frame_output->key_frame = 1;
/* Parse the coded frame number from the bitstream. Bytes 14
* through 17 represent the frame number. */
p_frame_output->frame_num = AV_RB32(enc_buf->data + 13);
ff_schro_queue_push_back(&p_schro_params->enc_frame_queue,
p_frame_output);
p_schro_params->enc_buf_size = 0;
p_schro_params->enc_buf = NULL;
schro_buffer_unref(enc_buf);
break;
case SCHRO_STATE_NEED_FRAME:
go = 0;
break;
case SCHRO_STATE_AGAIN:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Schro Encoder state\n");
return -1;
}
}
/* Copy 'next' frame in queue. */
if (p_schro_params->enc_frame_queue.size == 1 &&
p_schro_params->eos_pulled)
last_frame_in_sequence = 1;
p_frame_output = ff_schro_queue_pop(&p_schro_params->enc_frame_queue);
if (!p_frame_output)
return 0;
pkt_size = p_frame_output->size;
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0)
pkt_size += p_schro_params->enc_buf_size;
if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)
goto error;
memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->key_frame = p_frame_output->key_frame;
avctx->coded_frame->pts = p_frame_output->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
/* Use the frame number of the encoded frame as the pts. It is OK to
* do so since Dirac is a constant frame rate codec. It expects input
* to be of constant frame rate. */
pkt->pts = p_frame_output->frame_num;
pkt->dts = p_schro_params->dts++;
enc_size = p_frame_output->size;
/* Append the end of sequence information to the last frame in the
* sequence. */
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) {
memcpy(pkt->data + enc_size, p_schro_params->enc_buf,
p_schro_params->enc_buf_size);
enc_size += p_schro_params->enc_buf_size;
av_freep(&p_schro_params->enc_buf);
p_schro_params->enc_buf_size = 0;
}
if (p_frame_output->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
error:
/* free frame */
libschroedinger_free_frame(p_frame_output);
return ret;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
int enc_size = 0;
SchroEncoderParams *p_schro_params = avctx->priv_data;
SchroEncoder *encoder = p_schro_params->encoder;
struct FFSchroEncodedFrame *p_frame_output = NULL;
int go = 1;
SchroBuffer *enc_buf;
int presentation_frame;
int parse_code;
int last_frame_in_sequence = 0;
int pkt_size, ret;
if (!frame) {
if (!p_schro_params->eos_signalled) {
schro_encoder_end_of_stream(encoder);
p_schro_params->eos_signalled = 1;
}
} else {
SchroFrame *in_frame = libschroedinger_frame_from_data(avctx, frame);
if (!in_frame)
return AVERROR(ENOMEM);
schro_encoder_push_frame(encoder, in_frame);
}
if (p_schro_params->eos_pulled)
go = 0;
while (go) {
int err;
SchroStateEnum state;
state = schro_encoder_wait(encoder);
switch (state) {
case SCHRO_STATE_HAVE_BUFFER:
case SCHRO_STATE_END_OF_STREAM:
enc_buf = schro_encoder_pull(encoder, &presentation_frame);
if (enc_buf->length <= 0)
return AVERROR_BUG;
parse_code = enc_buf->data[4];
if ((err = av_reallocp(&p_schro_params->enc_buf,
p_schro_params->enc_buf_size +
enc_buf->length)) < 0) {
p_schro_params->enc_buf_size = 0;
return err;
}
memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
enc_buf->data, enc_buf->length);
p_schro_params->enc_buf_size += enc_buf->length;
if (state == SCHRO_STATE_END_OF_STREAM) {
p_schro_params->eos_pulled = 1;
go = 0;
}
if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {
schro_buffer_unref(enc_buf);
break;
}
p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame));
if (!p_frame_output)
return AVERROR(ENOMEM);
p_frame_output->size = p_schro_params->enc_buf_size;
p_frame_output->p_encbuf = p_schro_params->enc_buf;
if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&
SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))
p_frame_output->key_frame = 1;
p_frame_output->frame_num = AV_RB32(enc_buf->data + 13);
ff_schro_queue_push_back(&p_schro_params->enc_frame_queue,
p_frame_output);
p_schro_params->enc_buf_size = 0;
p_schro_params->enc_buf = NULL;
schro_buffer_unref(enc_buf);
break;
case SCHRO_STATE_NEED_FRAME:
go = 0;
break;
case SCHRO_STATE_AGAIN:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown Schro Encoder state\n");
return -1;
}
}
if (p_schro_params->enc_frame_queue.size == 1 &&
p_schro_params->eos_pulled)
last_frame_in_sequence = 1;
p_frame_output = ff_schro_queue_pop(&p_schro_params->enc_frame_queue);
if (!p_frame_output)
return 0;
pkt_size = p_frame_output->size;
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0)
pkt_size += p_schro_params->enc_buf_size;
if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)
goto error;
memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->key_frame = p_frame_output->key_frame;
avctx->coded_frame->pts = p_frame_output->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->pts = p_frame_output->frame_num;
pkt->dts = p_schro_params->dts++;
enc_size = p_frame_output->size;
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) {
memcpy(pkt->data + enc_size, p_schro_params->enc_buf,
p_schro_params->enc_buf_size);
enc_size += p_schro_params->enc_buf_size;
av_freep(&p_schro_params->enc_buf);
p_schro_params->enc_buf_size = 0;
}
if (p_frame_output->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
error:
libschroedinger_free_frame(p_frame_output);
return ret;
}
| {
"code": [
" SchroBuffer *enc_buf;",
" int go = 1;",
" if (!p_schro_params->eos_signalled) {",
" p_schro_params->eos_signalled = 1;",
" return AVERROR(ENOMEM);",
" break;",
" go = 0;",
" break;",
" break;",
" break;",
" go = 0;",
" p_schro_params->eos_pulled = 1;",
" break;",
" break;",
"FF_DISABLE_DEPRECATION_WARNINGS",
"FF_ENABLE_DEPRECATION_WARNINGS",
"#endif",
" } else {",
" return ret;",
" SchroEncoderParams *p_schro_params = avctx->priv_data;",
" SchroEncoderParams *p_schro_params = avctx->priv_data;",
"FF_DISABLE_DEPRECATION_WARNINGS",
"FF_ENABLE_DEPRECATION_WARNINGS",
"#endif",
" } else {",
" } else {",
" SchroEncoderParams *p_schro_params = avctx->priv_data;",
"static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,",
" const AVFrame *frame, int *got_packet)",
" int enc_size = 0;",
" SchroEncoderParams *p_schro_params = avctx->priv_data;",
" SchroEncoder *encoder = p_schro_params->encoder;",
" struct FFSchroEncodedFrame *p_frame_output = NULL;",
" int go = 1;",
" SchroBuffer *enc_buf;",
" int presentation_frame;",
" int parse_code;",
" int last_frame_in_sequence = 0;",
" int pkt_size, ret;",
" if (!frame) {",
" if (!p_schro_params->eos_signalled) {",
" schro_encoder_end_of_stream(encoder);",
" p_schro_params->eos_signalled = 1;",
" } else {",
" SchroFrame *in_frame = libschroedinger_frame_from_data(avctx, frame);",
" if (!in_frame)",
" return AVERROR(ENOMEM);",
" schro_encoder_push_frame(encoder, in_frame);",
" if (p_schro_params->eos_pulled)",
" go = 0;",
" while (go) {",
" int err;",
" SchroStateEnum state;",
" state = schro_encoder_wait(encoder);",
" switch (state) {",
" case SCHRO_STATE_HAVE_BUFFER:",
" case SCHRO_STATE_END_OF_STREAM:",
" enc_buf = schro_encoder_pull(encoder, &presentation_frame);",
" if (enc_buf->length <= 0)",
" return AVERROR_BUG;",
" parse_code = enc_buf->data[4];",
" if ((err = av_reallocp(&p_schro_params->enc_buf,",
" p_schro_params->enc_buf_size +",
" enc_buf->length)) < 0) {",
" p_schro_params->enc_buf_size = 0;",
" return err;",
" memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,",
" enc_buf->data, enc_buf->length);",
" p_schro_params->enc_buf_size += enc_buf->length;",
" if (state == SCHRO_STATE_END_OF_STREAM) {",
" p_schro_params->eos_pulled = 1;",
" go = 0;",
" if (!SCHRO_PARSE_CODE_IS_PICTURE(parse_code)) {",
" schro_buffer_unref(enc_buf);",
" break;",
" p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame));",
" if (!p_frame_output)",
" return AVERROR(ENOMEM);",
" p_frame_output->size = p_schro_params->enc_buf_size;",
" p_frame_output->p_encbuf = p_schro_params->enc_buf;",
" if (SCHRO_PARSE_CODE_IS_INTRA(parse_code) &&",
" SCHRO_PARSE_CODE_IS_REFERENCE(parse_code))",
" p_frame_output->key_frame = 1;",
" p_frame_output->frame_num = AV_RB32(enc_buf->data + 13);",
" ff_schro_queue_push_back(&p_schro_params->enc_frame_queue,",
" p_frame_output);",
" p_schro_params->enc_buf_size = 0;",
" p_schro_params->enc_buf = NULL;",
" schro_buffer_unref(enc_buf);",
" break;",
" case SCHRO_STATE_NEED_FRAME:",
" go = 0;",
" break;",
" case SCHRO_STATE_AGAIN:",
" break;",
" default:",
" av_log(avctx, AV_LOG_ERROR, \"Unknown Schro Encoder state\\n\");",
" return -1;",
" if (p_schro_params->enc_frame_queue.size == 1 &&",
" p_schro_params->eos_pulled)",
" last_frame_in_sequence = 1;",
" p_frame_output = ff_schro_queue_pop(&p_schro_params->enc_frame_queue);",
" if (!p_frame_output)",
" return 0;",
" pkt_size = p_frame_output->size;",
" if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0)",
" pkt_size += p_schro_params->enc_buf_size;",
" if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0)",
" goto error;",
" memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);",
"#if FF_API_CODED_FRAME",
"FF_DISABLE_DEPRECATION_WARNINGS",
" avctx->coded_frame->key_frame = p_frame_output->key_frame;",
" avctx->coded_frame->pts = p_frame_output->frame_num;",
"FF_ENABLE_DEPRECATION_WARNINGS",
"#endif",
" pkt->pts = p_frame_output->frame_num;",
" pkt->dts = p_schro_params->dts++;",
" enc_size = p_frame_output->size;",
" if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0) {",
" memcpy(pkt->data + enc_size, p_schro_params->enc_buf,",
" p_schro_params->enc_buf_size);",
" enc_size += p_schro_params->enc_buf_size;",
" av_freep(&p_schro_params->enc_buf);",
" p_schro_params->enc_buf_size = 0;",
" if (p_frame_output->key_frame)",
" pkt->flags |= AV_PKT_FLAG_KEY;",
" *got_packet = 1;",
"error:",
" libschroedinger_free_frame(p_frame_output);",
" return ret;",
" SchroEncoderParams *p_schro_params = avctx->priv_data;",
" av_freep(&p_schro_params->enc_buf);"
],
"line_no": [
17,
15,
33,
37,
149,
137,
127,
137,
137,
137,
127,
125,
137,
137,
255,
261,
263,
41,
313,
9,
9,
255,
261,
263,
41,
41,
9,
1,
3,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
29,
33,
35,
37,
41,
45,
47,
49,
53,
59,
61,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
99,
101,
103,
105,
107,
113,
115,
117,
123,
125,
127,
133,
135,
137,
145,
147,
149,
153,
155,
157,
159,
161,
169,
173,
175,
177,
179,
183,
187,
191,
193,
187,
199,
187,
205,
207,
209,
221,
223,
225,
229,
233,
235,
239,
241,
243,
245,
247,
251,
253,
255,
257,
259,
261,
263,
271,
273,
275,
283,
285,
287,
289,
291,
293,
299,
301,
303,
307,
311,
313,
9,
291
]
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
int VAR_4 = 0;
SchroEncoderParams *p_schro_params = VAR_0->priv_data;
SchroEncoder *encoder = p_schro_params->encoder;
struct FFSchroEncodedFrame *VAR_5 = NULL;
int VAR_6 = 1;
SchroBuffer *enc_buf;
int VAR_7;
int VAR_8;
int VAR_9 = 0;
int VAR_10, VAR_11;
if (!VAR_2) {
if (!p_schro_params->eos_signalled) {
schro_encoder_end_of_stream(encoder);
p_schro_params->eos_signalled = 1;
}
} else {
SchroFrame *in_frame = libschroedinger_frame_from_data(VAR_0, VAR_2);
if (!in_frame)
return AVERROR(ENOMEM);
schro_encoder_push_frame(encoder, in_frame);
}
if (p_schro_params->eos_pulled)
VAR_6 = 0;
while (VAR_6) {
int VAR_12;
SchroStateEnum state;
state = schro_encoder_wait(encoder);
switch (state) {
case SCHRO_STATE_HAVE_BUFFER:
case SCHRO_STATE_END_OF_STREAM:
enc_buf = schro_encoder_pull(encoder, &VAR_7);
if (enc_buf->length <= 0)
return AVERROR_BUG;
VAR_8 = enc_buf->data[4];
if ((VAR_12 = av_reallocp(&p_schro_params->enc_buf,
p_schro_params->enc_buf_size +
enc_buf->length)) < 0) {
p_schro_params->enc_buf_size = 0;
return VAR_12;
}
memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
enc_buf->data, enc_buf->length);
p_schro_params->enc_buf_size += enc_buf->length;
if (state == SCHRO_STATE_END_OF_STREAM) {
p_schro_params->eos_pulled = 1;
VAR_6 = 0;
}
if (!SCHRO_PARSE_CODE_IS_PICTURE(VAR_8)) {
schro_buffer_unref(enc_buf);
break;
}
VAR_5 = av_mallocz(sizeof(FFSchroEncodedFrame));
if (!VAR_5)
return AVERROR(ENOMEM);
VAR_5->size = p_schro_params->enc_buf_size;
VAR_5->p_encbuf = p_schro_params->enc_buf;
if (SCHRO_PARSE_CODE_IS_INTRA(VAR_8) &&
SCHRO_PARSE_CODE_IS_REFERENCE(VAR_8))
VAR_5->key_frame = 1;
VAR_5->frame_num = AV_RB32(enc_buf->data + 13);
ff_schro_queue_push_back(&p_schro_params->enc_frame_queue,
VAR_5);
p_schro_params->enc_buf_size = 0;
p_schro_params->enc_buf = NULL;
schro_buffer_unref(enc_buf);
break;
case SCHRO_STATE_NEED_FRAME:
VAR_6 = 0;
break;
case SCHRO_STATE_AGAIN:
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown Schro Encoder state\n");
return -1;
}
}
if (p_schro_params->enc_frame_queue.size == 1 &&
p_schro_params->eos_pulled)
VAR_9 = 1;
VAR_5 = ff_schro_queue_pop(&p_schro_params->enc_frame_queue);
if (!VAR_5)
return 0;
VAR_10 = VAR_5->size;
if (VAR_9 && p_schro_params->enc_buf_size > 0)
VAR_10 += p_schro_params->enc_buf_size;
if ((VAR_11 = ff_alloc_packet2(VAR_0, VAR_1, VAR_10, 0)) < 0)
goto error;
memcpy(VAR_1->data, VAR_5->p_encbuf, VAR_5->size);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
VAR_0->coded_frame->key_frame = VAR_5->key_frame;
VAR_0->coded_frame->pts = VAR_5->frame_num;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
VAR_1->pts = VAR_5->frame_num;
VAR_1->dts = p_schro_params->dts++;
VAR_4 = VAR_5->size;
if (VAR_9 && p_schro_params->enc_buf_size > 0) {
memcpy(VAR_1->data + VAR_4, p_schro_params->enc_buf,
p_schro_params->enc_buf_size);
VAR_4 += p_schro_params->enc_buf_size;
av_freep(&p_schro_params->enc_buf);
p_schro_params->enc_buf_size = 0;
}
if (VAR_5->key_frame)
VAR_1->flags |= AV_PKT_FLAG_KEY;
*VAR_3 = 1;
error:
libschroedinger_free_frame(VAR_5);
return VAR_11;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"int VAR_4 = 0;",
"SchroEncoderParams *p_schro_params = VAR_0->priv_data;",
"SchroEncoder *encoder = p_schro_params->encoder;",
"struct FFSchroEncodedFrame *VAR_5 = NULL;",
"int VAR_6 = 1;",
"SchroBuffer *enc_buf;",
"int VAR_7;",
"int VAR_8;",
"int VAR_9 = 0;",
"int VAR_10, VAR_11;",
"if (!VAR_2) {",
"if (!p_schro_params->eos_signalled) {",
"schro_encoder_end_of_stream(encoder);",
"p_schro_params->eos_signalled = 1;",
"}",
"} else {",
"SchroFrame *in_frame = libschroedinger_frame_from_data(VAR_0, VAR_2);",
"if (!in_frame)\nreturn AVERROR(ENOMEM);",
"schro_encoder_push_frame(encoder, in_frame);",
"}",
"if (p_schro_params->eos_pulled)\nVAR_6 = 0;",
"while (VAR_6) {",
"int VAR_12;",
"SchroStateEnum state;",
"state = schro_encoder_wait(encoder);",
"switch (state) {",
"case SCHRO_STATE_HAVE_BUFFER:\ncase SCHRO_STATE_END_OF_STREAM:\nenc_buf = schro_encoder_pull(encoder, &VAR_7);",
"if (enc_buf->length <= 0)\nreturn AVERROR_BUG;",
"VAR_8 = enc_buf->data[4];",
"if ((VAR_12 = av_reallocp(&p_schro_params->enc_buf,\np_schro_params->enc_buf_size +\nenc_buf->length)) < 0) {",
"p_schro_params->enc_buf_size = 0;",
"return VAR_12;",
"}",
"memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,\nenc_buf->data, enc_buf->length);",
"p_schro_params->enc_buf_size += enc_buf->length;",
"if (state == SCHRO_STATE_END_OF_STREAM) {",
"p_schro_params->eos_pulled = 1;",
"VAR_6 = 0;",
"}",
"if (!SCHRO_PARSE_CODE_IS_PICTURE(VAR_8)) {",
"schro_buffer_unref(enc_buf);",
"break;",
"}",
"VAR_5 = av_mallocz(sizeof(FFSchroEncodedFrame));",
"if (!VAR_5)\nreturn AVERROR(ENOMEM);",
"VAR_5->size = p_schro_params->enc_buf_size;",
"VAR_5->p_encbuf = p_schro_params->enc_buf;",
"if (SCHRO_PARSE_CODE_IS_INTRA(VAR_8) &&\nSCHRO_PARSE_CODE_IS_REFERENCE(VAR_8))\nVAR_5->key_frame = 1;",
"VAR_5->frame_num = AV_RB32(enc_buf->data + 13);",
"ff_schro_queue_push_back(&p_schro_params->enc_frame_queue,\nVAR_5);",
"p_schro_params->enc_buf_size = 0;",
"p_schro_params->enc_buf = NULL;",
"schro_buffer_unref(enc_buf);",
"break;",
"case SCHRO_STATE_NEED_FRAME:\nVAR_6 = 0;",
"break;",
"case SCHRO_STATE_AGAIN:\nbreak;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown Schro Encoder state\\n\");",
"return -1;",
"}",
"}",
"if (p_schro_params->enc_frame_queue.size == 1 &&\np_schro_params->eos_pulled)\nVAR_9 = 1;",
"VAR_5 = ff_schro_queue_pop(&p_schro_params->enc_frame_queue);",
"if (!VAR_5)\nreturn 0;",
"VAR_10 = VAR_5->size;",
"if (VAR_9 && p_schro_params->enc_buf_size > 0)\nVAR_10 += p_schro_params->enc_buf_size;",
"if ((VAR_11 = ff_alloc_packet2(VAR_0, VAR_1, VAR_10, 0)) < 0)\ngoto error;",
"memcpy(VAR_1->data, VAR_5->p_encbuf, VAR_5->size);",
"#if FF_API_CODED_FRAME\nFF_DISABLE_DEPRECATION_WARNINGS\nVAR_0->coded_frame->key_frame = VAR_5->key_frame;",
"VAR_0->coded_frame->pts = VAR_5->frame_num;",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_1->pts = VAR_5->frame_num;",
"VAR_1->dts = p_schro_params->dts++;",
"VAR_4 = VAR_5->size;",
"if (VAR_9 && p_schro_params->enc_buf_size > 0) {",
"memcpy(VAR_1->data + VAR_4, p_schro_params->enc_buf,\np_schro_params->enc_buf_size);",
"VAR_4 += p_schro_params->enc_buf_size;",
"av_freep(&p_schro_params->enc_buf);",
"p_schro_params->enc_buf_size = 0;",
"}",
"if (VAR_5->key_frame)\nVAR_1->flags |= AV_PKT_FLAG_KEY;",
"*VAR_3 = 1;",
"error:\nlibschroedinger_free_frame(VAR_5);",
"return VAR_11;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
59,
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81
],
[
83,
85
],
[
87
],
[
99,
101,
103
],
[
105
],
[
107
],
[
109
],
[
113,
115
],
[
117
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
145
],
[
147,
149
],
[
153
],
[
155
],
[
157,
159,
161
],
[
169
],
[
173,
175
],
[
177
],
[
179
],
[
183
],
[
187
],
[
191,
193
],
[
195
],
[
199,
201
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
221,
223,
225
],
[
229
],
[
233,
235
],
[
239
],
[
241,
243
],
[
245,
247
],
[
251
],
[
253,
255,
257
],
[
259
],
[
261,
263,
271
],
[
273
],
[
275
],
[
283
],
[
285,
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299,
301
],
[
303
],
[
307,
311
],
[
313
],
[
315
]
] |
21,920 | static int qcow2_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
Coroutine *co;
AioContext *aio_context = bdrv_get_aio_context(bs);
Qcow2WriteCo data = {
.bs = bs,
.sector_num = sector_num,
.buf = buf,
.nb_sectors = nb_sectors,
.ret = -EINPROGRESS,
};
co = qemu_coroutine_create(qcow2_write_co_entry);
qemu_coroutine_enter(co, &data);
while (data.ret == -EINPROGRESS) {
aio_poll(aio_context, true);
}
return data.ret;
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static int qcow2_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
Coroutine *co;
AioContext *aio_context = bdrv_get_aio_context(bs);
Qcow2WriteCo data = {
.bs = bs,
.sector_num = sector_num,
.buf = buf,
.nb_sectors = nb_sectors,
.ret = -EINPROGRESS,
};
co = qemu_coroutine_create(qcow2_write_co_entry);
qemu_coroutine_enter(co, &data);
while (data.ret == -EINPROGRESS) {
aio_poll(aio_context, true);
}
return data.ret;
}
| {
"code": [
" qemu_coroutine_enter(co, &data);",
" co = qemu_coroutine_create(qcow2_write_co_entry);",
" qemu_coroutine_enter(co, &data);",
" qemu_coroutine_enter(co, &data);",
" qemu_coroutine_enter(co, &data);"
],
"line_no": [
27,
25,
27,
27,
27
]
} | static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
Coroutine *co;
AioContext *aio_context = bdrv_get_aio_context(VAR_0);
Qcow2WriteCo data = {
.VAR_0 = VAR_0,
.VAR_1 = VAR_1,
.VAR_2 = VAR_2,
.VAR_3 = VAR_3,
.ret = -EINPROGRESS,
};
co = qemu_coroutine_create(qcow2_write_co_entry);
qemu_coroutine_enter(co, &data);
while (data.ret == -EINPROGRESS) {
aio_poll(aio_context, true);
}
return data.ret;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"Coroutine *co;",
"AioContext *aio_context = bdrv_get_aio_context(VAR_0);",
"Qcow2WriteCo data = {",
".VAR_0 = VAR_0,\n.VAR_1 = VAR_1,\n.VAR_2 = VAR_2,\n.VAR_3 = VAR_3,\n.ret = -EINPROGRESS,\n};",
"co = qemu_coroutine_create(qcow2_write_co_entry);",
"qemu_coroutine_enter(co, &data);",
"while (data.ret == -EINPROGRESS) {",
"aio_poll(aio_context, true);",
"}",
"return data.ret;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13,
15,
17,
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
21,922 | static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
SCSIDevice *sd = SCSI_DEVICE(dev);
if (s->ctx && !s->dataplane_disabled) {
VirtIOSCSIBlkChangeNotifier *insert_notifier, *remove_notifier;
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
return;
}
blk_op_block_all(sd->conf.blk, s->blocker);
aio_context_acquire(s->ctx);
blk_set_aio_context(sd->conf.blk, s->ctx);
aio_context_release(s->ctx);
insert_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
insert_notifier->n.notify = virtio_scsi_blk_insert_notifier;
insert_notifier->s = s;
insert_notifier->sd = sd;
blk_add_insert_bs_notifier(sd->conf.blk, &insert_notifier->n);
QTAILQ_INSERT_TAIL(&s->insert_notifiers, insert_notifier, next);
remove_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
remove_notifier->n.notify = virtio_scsi_blk_remove_notifier;
remove_notifier->s = s;
remove_notifier->sd = sd;
blk_add_remove_bs_notifier(sd->conf.blk, &remove_notifier->n);
QTAILQ_INSERT_TAIL(&s->remove_notifiers, remove_notifier, next);
}
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
virtio_scsi_push_event(s, sd,
VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_RESCAN);
}
}
| true | qemu | 43c696a298f6bef81818b1d8e64d41a160782101 | static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
SCSIDevice *sd = SCSI_DEVICE(dev);
if (s->ctx && !s->dataplane_disabled) {
VirtIOSCSIBlkChangeNotifier *insert_notifier, *remove_notifier;
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
return;
}
blk_op_block_all(sd->conf.blk, s->blocker);
aio_context_acquire(s->ctx);
blk_set_aio_context(sd->conf.blk, s->ctx);
aio_context_release(s->ctx);
insert_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
insert_notifier->n.notify = virtio_scsi_blk_insert_notifier;
insert_notifier->s = s;
insert_notifier->sd = sd;
blk_add_insert_bs_notifier(sd->conf.blk, &insert_notifier->n);
QTAILQ_INSERT_TAIL(&s->insert_notifiers, insert_notifier, next);
remove_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
remove_notifier->n.notify = virtio_scsi_blk_remove_notifier;
remove_notifier->s = s;
remove_notifier->sd = sd;
blk_add_remove_bs_notifier(sd->conf.blk, &remove_notifier->n);
QTAILQ_INSERT_TAIL(&s->remove_notifiers, remove_notifier, next);
}
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
virtio_scsi_push_event(s, sd,
VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_RESCAN);
}
}
| {
"code": [
" if (s->ctx && !s->dataplane_disabled) {"
],
"line_no": [
15
]
} | static void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,
Error **VAR_2)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
SCSIDevice *sd = SCSI_DEVICE(VAR_1);
if (s->ctx && !s->dataplane_disabled) {
VirtIOSCSIBlkChangeNotifier *insert_notifier, *remove_notifier;
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, VAR_2)) {
return;
}
blk_op_block_all(sd->conf.blk, s->blocker);
aio_context_acquire(s->ctx);
blk_set_aio_context(sd->conf.blk, s->ctx);
aio_context_release(s->ctx);
insert_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
insert_notifier->n.notify = virtio_scsi_blk_insert_notifier;
insert_notifier->s = s;
insert_notifier->sd = sd;
blk_add_insert_bs_notifier(sd->conf.blk, &insert_notifier->n);
QTAILQ_INSERT_TAIL(&s->insert_notifiers, insert_notifier, next);
remove_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);
remove_notifier->n.notify = virtio_scsi_blk_remove_notifier;
remove_notifier->s = s;
remove_notifier->sd = sd;
blk_add_remove_bs_notifier(sd->conf.blk, &remove_notifier->n);
QTAILQ_INSERT_TAIL(&s->remove_notifiers, remove_notifier, next);
}
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
virtio_scsi_push_event(s, sd,
VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_RESCAN);
}
}
| [
"static void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,\nError **VAR_2)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"VirtIOSCSI *s = VIRTIO_SCSI(vdev);",
"SCSIDevice *sd = SCSI_DEVICE(VAR_1);",
"if (s->ctx && !s->dataplane_disabled) {",
"VirtIOSCSIBlkChangeNotifier *insert_notifier, *remove_notifier;",
"if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, VAR_2)) {",
"return;",
"}",
"blk_op_block_all(sd->conf.blk, s->blocker);",
"aio_context_acquire(s->ctx);",
"blk_set_aio_context(sd->conf.blk, s->ctx);",
"aio_context_release(s->ctx);",
"insert_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);",
"insert_notifier->n.notify = virtio_scsi_blk_insert_notifier;",
"insert_notifier->s = s;",
"insert_notifier->sd = sd;",
"blk_add_insert_bs_notifier(sd->conf.blk, &insert_notifier->n);",
"QTAILQ_INSERT_TAIL(&s->insert_notifiers, insert_notifier, next);",
"remove_notifier = g_new0(VirtIOSCSIBlkChangeNotifier, 1);",
"remove_notifier->n.notify = virtio_scsi_blk_remove_notifier;",
"remove_notifier->s = s;",
"remove_notifier->sd = sd;",
"blk_add_remove_bs_notifier(sd->conf.blk, &remove_notifier->n);",
"QTAILQ_INSERT_TAIL(&s->remove_notifiers, remove_notifier, next);",
"}",
"if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {",
"virtio_scsi_push_event(s, sd,\nVIRTIO_SCSI_T_TRANSPORT_RESET,\nVIRTIO_SCSI_EVT_RESET_RESCAN);",
"}",
"}"
] | [
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
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77
]
] |
21,923 | static CharDriverState *qemu_chr_open_pty(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int master_fd, slave_fd;
char pty_name[PATH_MAX];
master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) {
return NULL;
}
close(slave_fd);
qemu_set_nonblock(master_fd);
chr = qemu_chr_alloc();
chr->filename = g_strdup_printf("pty:%s", pty_name);
ret->pty = g_strdup(pty_name);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
pty_name, id);
s = g_malloc0(sizeof(PtyCharDriver));
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;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(master_fd);
s->timer_tag = 0;
return chr;
}
| true | qemu | 2d528d45ecf5ee3c1a566a9f3d664464925ef830 | static CharDriverState *qemu_chr_open_pty(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int master_fd, slave_fd;
char pty_name[PATH_MAX];
master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) {
return NULL;
}
close(slave_fd);
qemu_set_nonblock(master_fd);
chr = qemu_chr_alloc();
chr->filename = g_strdup_printf("pty:%s", pty_name);
ret->pty = g_strdup(pty_name);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
pty_name, id);
s = g_malloc0(sizeof(PtyCharDriver));
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;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(master_fd);
s->timer_tag = 0;
return chr;
}
| {
"code": [
" s = g_malloc0(sizeof(PtyCharDriver));"
],
"line_no": [
51
]
} | static CharDriverState *FUNC_0(const char *id,
ChardevReturn *ret)
{
CharDriverState *chr;
PtyCharDriver *s;
int VAR_0, VAR_1;
char VAR_2[PATH_MAX];
VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);
if (VAR_0 < 0) {
return NULL;
}
close(VAR_1);
qemu_set_nonblock(VAR_0);
chr = qemu_chr_alloc();
chr->filename = g_strdup_printf("pty:%s", VAR_2);
ret->pty = g_strdup(VAR_2);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
VAR_2, id);
s = g_malloc0(sizeof(PtyCharDriver));
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;
chr->chr_add_watch = pty_chr_add_watch;
chr->explicit_be_open = true;
s->fd = io_channel_from_fd(VAR_0);
s->timer_tag = 0;
return chr;
}
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevReturn *ret)\n{",
"CharDriverState *chr;",
"PtyCharDriver *s;",
"int VAR_0, VAR_1;",
"char VAR_2[PATH_MAX];",
"VAR_0 = qemu_openpty_raw(&VAR_1, VAR_2);",
"if (VAR_0 < 0) {",
"return NULL;",
"}",
"close(VAR_1);",
"qemu_set_nonblock(VAR_0);",
"chr = qemu_chr_alloc();",
"chr->filename = g_strdup_printf(\"pty:%s\", VAR_2);",
"ret->pty = g_strdup(VAR_2);",
"ret->has_pty = true;",
"fprintf(stderr, \"char device redirected to %s (label %s)\\n\",\nVAR_2, id);",
"s = g_malloc0(sizeof(PtyCharDriver));",
"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;",
"chr->chr_add_watch = pty_chr_add_watch;",
"chr->explicit_be_open = true;",
"s->fd = io_channel_from_fd(VAR_0);",
"s->timer_tag = 0;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
21,924 | static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
int width, int height,
int lumStride, int chromStride, int srcStride)
{
int y;
const int chromWidth = FF_CEIL_RSHIFT(width, 1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
if(y&1) {
RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| true | FFmpeg | 1e3f77b53a803a6c63fa64829f1be557b8226288 | static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
int width, int height,
int lumStride, int chromStride, int srcStride)
{
int y;
const int chromWidth = FF_CEIL_RSHIFT(width, 1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
if(y&1) {
RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| {
"code": [
" RENAME(extract_even)(src+1, ydst, width);",
" RENAME(extract_even)(src+1, ydst, width);"
],
"line_no": [
17,
17
]
} | static void FUNC_0(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
int width, int height,
int lumStride, int chromStride, int srcStride)
{
int VAR_0;
const int VAR_1 = FF_CEIL_RSHIFT(width, 1);
for (VAR_0=0; VAR_0<height; VAR_0++) {
FUNC_0(extract_even)(src+1, ydst, width);
if(VAR_0&1) {
FUNC_0(extract_even2avg)(src-srcStride, src, udst, vdst, VAR_1);
udst+= chromStride;
vdst+= chromStride;
}
src += srcStride;
ydst+= lumStride;
}
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
}
| [
"static void FUNC_0(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,\nint width, int height,\nint lumStride, int chromStride, int srcStride)\n{",
"int VAR_0;",
"const int VAR_1 = FF_CEIL_RSHIFT(width, 1);",
"for (VAR_0=0; VAR_0<height; VAR_0++) {",
"FUNC_0(extract_even)(src+1, ydst, width);",
"if(VAR_0&1) {",
"FUNC_0(extract_even2avg)(src-srcStride, src, udst, vdst, VAR_1);",
"udst+= chromStride;",
"vdst+= chromStride;",
"}",
"src += srcStride;",
"ydst+= lumStride;",
"}",
"__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45
],
[
47
]
] |
21,926 | av_cold int ff_h264_decode_init(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
int i;
int ret;
h->avctx = avctx;
h->bit_depth_luma = 8;
h->chroma_format_idc = 1;
h->cur_chroma_format_idc = 1;
ff_h264dsp_init(&h->h264dsp, 8, 1);
av_assert0(h->sps.bit_depth_chroma == 0);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, 8);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, 8, 1);
h->dequant_coeff_pps = -1;
h->current_sps_id = -1;
/* needed so that IDCT permutation is known early */
ff_videodsp_init(&h->vdsp, 8);
memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
h->workaround_bugs = avctx->workaround_bugs;
h->flags = avctx->flags;
/* set defaults */
// s->decode_mb = ff_h263_decode_mb;
if (!avctx->has_b_frames)
h->low_delay = 1;
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
ff_h264_decode_init_vlc();
ff_init_cabac_states();
h->pixel_shift = 0;
h->cur_bit_depth_luma =
h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].h264 = h;
h->outputed_poc = h->next_outputed_poc = INT_MIN;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
h->prev_poc_msb = 1 << 16;
h->prev_frame_num = -1;
h->x264_build = -1;
h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
ff_h264_reset_sei(h);
if (avctx->codec_id == AV_CODEC_ID_H264) {
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
} else
h->avctx->time_base.num /= 2;
}
avctx->ticks_per_frame = 2;
}
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
if (ret < 0) {
ff_h264_free_context(h);
return ret;
}
}
if (h->sps.bitstream_restriction_flag &&
h->avctx->has_b_frames < h->sps.num_reorder_frames) {
h->avctx->has_b_frames = h->sps.num_reorder_frames;
h->low_delay = 0;
}
avctx->internal->allocate_progress = 1;
ff_h264_flush_change(h);
if (h->enable_er) {
av_log(avctx, AV_LOG_WARNING,
"Error resilience is enabled. It is unsafe and unsupported and may crash. "
"Use it at your own risk\n");
}
return 0;
}
| true | FFmpeg | 4b7356ce8f2c7902a9b97645f86e0ae09bc2676c | av_cold int ff_h264_decode_init(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
int i;
int ret;
h->avctx = avctx;
h->bit_depth_luma = 8;
h->chroma_format_idc = 1;
h->cur_chroma_format_idc = 1;
ff_h264dsp_init(&h->h264dsp, 8, 1);
av_assert0(h->sps.bit_depth_chroma == 0);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, 8);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, 8, 1);
h->dequant_coeff_pps = -1;
h->current_sps_id = -1;
ff_videodsp_init(&h->vdsp, 8);
memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
h->workaround_bugs = avctx->workaround_bugs;
h->flags = avctx->flags;
if (!avctx->has_b_frames)
h->low_delay = 1;
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
ff_h264_decode_init_vlc();
ff_init_cabac_states();
h->pixel_shift = 0;
h->cur_bit_depth_luma =
h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].h264 = h;
h->outputed_poc = h->next_outputed_poc = INT_MIN;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
h->prev_poc_msb = 1 << 16;
h->prev_frame_num = -1;
h->x264_build = -1;
h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
ff_h264_reset_sei(h);
if (avctx->codec_id == AV_CODEC_ID_H264) {
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
} else
h->avctx->time_base.num /= 2;
}
avctx->ticks_per_frame = 2;
}
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
if (ret < 0) {
ff_h264_free_context(h);
return ret;
}
}
if (h->sps.bitstream_restriction_flag &&
h->avctx->has_b_frames < h->sps.num_reorder_frames) {
h->avctx->has_b_frames = h->sps.num_reorder_frames;
h->low_delay = 0;
}
avctx->internal->allocate_progress = 1;
ff_h264_flush_change(h);
if (h->enable_er) {
av_log(avctx, AV_LOG_WARNING,
"Error resilience is enabled. It is unsafe and unsupported and may crash. "
"Use it at your own risk\n");
}
return 0;
}
| {
"code": [
" \"Error resilience is enabled. It is unsafe and unsupported and may crash. \""
],
"line_no": [
193
]
} | av_cold int FUNC_0(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
int VAR_0;
int VAR_1;
h->avctx = avctx;
h->bit_depth_luma = 8;
h->chroma_format_idc = 1;
h->cur_chroma_format_idc = 1;
ff_h264dsp_init(&h->h264dsp, 8, 1);
av_assert0(h->sps.bit_depth_chroma == 0);
ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
ff_h264qpel_init(&h->h264qpel, 8);
ff_h264_pred_init(&h->hpc, h->avctx->codec_id, 8, 1);
h->dequant_coeff_pps = -1;
h->current_sps_id = -1;
ff_videodsp_init(&h->vdsp, 8);
memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));
h->picture_structure = PICT_FRAME;
h->slice_context_count = 1;
h->workaround_bugs = avctx->workaround_bugs;
h->flags = avctx->flags;
if (!avctx->has_b_frames)
h->low_delay = 1;
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
ff_h264_decode_init_vlc();
ff_init_cabac_states();
h->pixel_shift = 0;
h->cur_bit_depth_luma =
h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;
h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
if (!h->slice_ctx) {
h->nb_slice_ctx = 0;
return AVERROR(ENOMEM);
}
for (VAR_0 = 0; VAR_0 < h->nb_slice_ctx; VAR_0++)
h->slice_ctx[VAR_0].h264 = h;
h->outputed_poc = h->next_outputed_poc = INT_MIN;
for (VAR_0 = 0; VAR_0 < MAX_DELAYED_PIC_COUNT; VAR_0++)
h->last_pocs[VAR_0] = INT_MIN;
h->prev_poc_msb = 1 << 16;
h->prev_frame_num = -1;
h->x264_build = -1;
h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
ff_h264_reset_sei(h);
if (avctx->codec_id == AV_CODEC_ID_H264) {
if (avctx->ticks_per_frame == 1) {
if(h->avctx->time_base.den < INT_MAX/2) {
h->avctx->time_base.den *= 2;
} else
h->avctx->time_base.num /= 2;
}
avctx->ticks_per_frame = 2;
}
if (avctx->extradata_size > 0 && avctx->extradata) {
VAR_1 = ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
if (VAR_1 < 0) {
ff_h264_free_context(h);
return VAR_1;
}
}
if (h->sps.bitstream_restriction_flag &&
h->avctx->has_b_frames < h->sps.num_reorder_frames) {
h->avctx->has_b_frames = h->sps.num_reorder_frames;
h->low_delay = 0;
}
avctx->internal->allocate_progress = 1;
ff_h264_flush_change(h);
if (h->enable_er) {
av_log(avctx, AV_LOG_WARNING,
"Error resilience is enabled. It is unsafe and unsupported and may crash. "
"Use it at your own risk\n");
}
return 0;
}
| [
"av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"H264Context *h = avctx->priv_data;",
"int VAR_0;",
"int VAR_1;",
"h->avctx = avctx;",
"h->bit_depth_luma = 8;",
"h->chroma_format_idc = 1;",
"h->cur_chroma_format_idc = 1;",
"ff_h264dsp_init(&h->h264dsp, 8, 1);",
"av_assert0(h->sps.bit_depth_chroma == 0);",
"ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);",
"ff_h264qpel_init(&h->h264qpel, 8);",
"ff_h264_pred_init(&h->hpc, h->avctx->codec_id, 8, 1);",
"h->dequant_coeff_pps = -1;",
"h->current_sps_id = -1;",
"ff_videodsp_init(&h->vdsp, 8);",
"memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));",
"memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));",
"h->picture_structure = PICT_FRAME;",
"h->slice_context_count = 1;",
"h->workaround_bugs = avctx->workaround_bugs;",
"h->flags = avctx->flags;",
"if (!avctx->has_b_frames)\nh->low_delay = 1;",
"avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;",
"ff_h264_decode_init_vlc();",
"ff_init_cabac_states();",
"h->pixel_shift = 0;",
"h->cur_bit_depth_luma =\nh->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;",
"h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? H264_MAX_THREADS : 1;",
"h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));",
"if (!h->slice_ctx) {",
"h->nb_slice_ctx = 0;",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_0 = 0; VAR_0 < h->nb_slice_ctx; VAR_0++)",
"h->slice_ctx[VAR_0].h264 = h;",
"h->outputed_poc = h->next_outputed_poc = INT_MIN;",
"for (VAR_0 = 0; VAR_0 < MAX_DELAYED_PIC_COUNT; VAR_0++)",
"h->last_pocs[VAR_0] = INT_MIN;",
"h->prev_poc_msb = 1 << 16;",
"h->prev_frame_num = -1;",
"h->x264_build = -1;",
"h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;",
"ff_h264_reset_sei(h);",
"if (avctx->codec_id == AV_CODEC_ID_H264) {",
"if (avctx->ticks_per_frame == 1) {",
"if(h->avctx->time_base.den < INT_MAX/2) {",
"h->avctx->time_base.den *= 2;",
"} else",
"h->avctx->time_base.num /= 2;",
"}",
"avctx->ticks_per_frame = 2;",
"}",
"if (avctx->extradata_size > 0 && avctx->extradata) {",
"VAR_1 = ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);",
"if (VAR_1 < 0) {",
"ff_h264_free_context(h);",
"return VAR_1;",
"}",
"}",
"if (h->sps.bitstream_restriction_flag &&\nh->avctx->has_b_frames < h->sps.num_reorder_frames) {",
"h->avctx->has_b_frames = h->sps.num_reorder_frames;",
"h->low_delay = 0;",
"}",
"avctx->internal->allocate_progress = 1;",
"ff_h264_flush_change(h);",
"if (h->enable_er) {",
"av_log(avctx, AV_LOG_WARNING,\n\"Error resilience is enabled. It is unsafe and unsupported and may crash. \"\n\"Use it at your own risk\\n\");",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
47
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
71,
73
],
[
77
],
[
81
],
[
85
],
[
89
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169,
171
],
[
173
],
[
175
],
[
177
],
[
181
],
[
185
],
[
189
],
[
191,
193,
195
],
[
197
],
[
201
],
[
203
]
] |
21,927 | static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
for (j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if (j + 16 > h)
bh = h - j;
for (i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if (bytestream2_get_bytes_left(gb) <= 0) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
if (i + 16 > w)
bw = w - i;
flags = bytestream2_get_byte(gb);
if (flags & HT_RAW) {
if (bytestream2_get_bytes_left(gb) < bw * bh * bpp) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
paint_raw(dst2, bw, bh, gb, bpp, c->bigendian, stride);
} else {
if (flags & HT_BKG)
bg = vmnc_get_pixel(gb, bpp, c->bigendian);
if (flags & HT_FG)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
rects = 0;
if (flags & HT_SUB)
rects = bytestream2_get_byte(gb);
color = !!(flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
if (bytestream2_get_bytes_left(gb) < rects * (color * bpp + 2)) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < rects; k++) {
if (color)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
xy = bytestream2_get_byte(gb);
wh = bytestream2_get_byte(gb);
paint_rect(dst2, xy >> 4, xy & 0xF,
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return 0;
}
| true | FFmpeg | f5d46d332258dcd8ca623019ece1d5e5bb74142b | static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
int w, int h, int stride)
{
int i, j, k;
int bg = 0, fg = 0, rects, color, flags, xy, wh;
const int bpp = c->bpp2;
uint8_t *dst2;
int bw = 16, bh = 16;
for (j = 0; j < h; j += 16) {
dst2 = dst;
bw = 16;
if (j + 16 > h)
bh = h - j;
for (i = 0; i < w; i += 16, dst2 += 16 * bpp) {
if (bytestream2_get_bytes_left(gb) <= 0) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
if (i + 16 > w)
bw = w - i;
flags = bytestream2_get_byte(gb);
if (flags & HT_RAW) {
if (bytestream2_get_bytes_left(gb) < bw * bh * bpp) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
paint_raw(dst2, bw, bh, gb, bpp, c->bigendian, stride);
} else {
if (flags & HT_BKG)
bg = vmnc_get_pixel(gb, bpp, c->bigendian);
if (flags & HT_FG)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
rects = 0;
if (flags & HT_SUB)
rects = bytestream2_get_byte(gb);
color = !!(flags & HT_CLR);
paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
if (bytestream2_get_bytes_left(gb) < rects * (color * bpp + 2)) {
av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
for (k = 0; k < rects; k++) {
if (color)
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
xy = bytestream2_get_byte(gb);
wh = bytestream2_get_byte(gb);
paint_rect(dst2, xy >> 4, xy & 0xF,
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}
}
}
dst += stride * 16;
}
return 0;
}
| {
"code": [
" paint_rect(dst2, xy >> 4, xy & 0xF,",
" (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);"
],
"line_no": [
99,
101
]
} | static int FUNC_0(VmncContext *VAR_0, uint8_t* VAR_1, GetByteContext *VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8;
int VAR_9 = 0, VAR_10 = 0, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
const int VAR_16 = VAR_0->bpp2;
uint8_t *dst2;
int VAR_17 = 16, VAR_18 = 16;
for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7 += 16) {
dst2 = VAR_1;
VAR_17 = 16;
if (VAR_7 + 16 > VAR_4)
VAR_18 = VAR_4 - VAR_7;
for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 16, dst2 += 16 * VAR_16) {
if (bytestream2_get_bytes_left(VAR_2) <= 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
if (VAR_6 + 16 > VAR_3)
VAR_17 = VAR_3 - VAR_6;
VAR_13 = bytestream2_get_byte(VAR_2);
if (VAR_13 & HT_RAW) {
if (bytestream2_get_bytes_left(VAR_2) < VAR_17 * VAR_18 * VAR_16) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
paint_raw(dst2, VAR_17, VAR_18, VAR_2, VAR_16, VAR_0->bigendian, VAR_5);
} else {
if (VAR_13 & HT_BKG)
VAR_9 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);
if (VAR_13 & HT_FG)
VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);
VAR_11 = 0;
if (VAR_13 & HT_SUB)
VAR_11 = bytestream2_get_byte(VAR_2);
VAR_12 = !!(VAR_13 & HT_CLR);
paint_rect(dst2, 0, 0, VAR_17, VAR_18, VAR_9, VAR_16, VAR_5);
if (bytestream2_get_bytes_left(VAR_2) < VAR_11 * (VAR_12 * VAR_16 + 2)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Premature end of data!\n");
return AVERROR_INVALIDDATA;
}
for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {
if (VAR_12)
VAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);
VAR_14 = bytestream2_get_byte(VAR_2);
VAR_15 = bytestream2_get_byte(VAR_2);
paint_rect(dst2, VAR_14 >> 4, VAR_14 & 0xF,
(VAR_15>>4)+1, (VAR_15 & 0xF)+1, VAR_10, VAR_16, VAR_5);
}
}
}
VAR_1 += VAR_5 * 16;
}
return 0;
}
| [
"static int FUNC_0(VmncContext *VAR_0, uint8_t* VAR_1, GetByteContext *VAR_2,\nint VAR_3, int VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8;",
"int VAR_9 = 0, VAR_10 = 0, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"const int VAR_16 = VAR_0->bpp2;",
"uint8_t *dst2;",
"int VAR_17 = 16, VAR_18 = 16;",
"for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7 += 16) {",
"dst2 = VAR_1;",
"VAR_17 = 16;",
"if (VAR_7 + 16 > VAR_4)\nVAR_18 = VAR_4 - VAR_7;",
"for (VAR_6 = 0; VAR_6 < VAR_3; VAR_6 += 16, dst2 += 16 * VAR_16) {",
"if (bytestream2_get_bytes_left(VAR_2) <= 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Premature end of data!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_6 + 16 > VAR_3)\nVAR_17 = VAR_3 - VAR_6;",
"VAR_13 = bytestream2_get_byte(VAR_2);",
"if (VAR_13 & HT_RAW) {",
"if (bytestream2_get_bytes_left(VAR_2) < VAR_17 * VAR_18 * VAR_16) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Premature end of data!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"paint_raw(dst2, VAR_17, VAR_18, VAR_2, VAR_16, VAR_0->bigendian, VAR_5);",
"} else {",
"if (VAR_13 & HT_BKG)\nVAR_9 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);",
"if (VAR_13 & HT_FG)\nVAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);",
"VAR_11 = 0;",
"if (VAR_13 & HT_SUB)\nVAR_11 = bytestream2_get_byte(VAR_2);",
"VAR_12 = !!(VAR_13 & HT_CLR);",
"paint_rect(dst2, 0, 0, VAR_17, VAR_18, VAR_9, VAR_16, VAR_5);",
"if (bytestream2_get_bytes_left(VAR_2) < VAR_11 * (VAR_12 * VAR_16 + 2)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Premature end of data!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_8 = 0; VAR_8 < VAR_11; VAR_8++) {",
"if (VAR_12)\nVAR_10 = vmnc_get_pixel(VAR_2, VAR_16, VAR_0->bigendian);",
"VAR_14 = bytestream2_get_byte(VAR_2);",
"VAR_15 = bytestream2_get_byte(VAR_2);",
"paint_rect(dst2, VAR_14 >> 4, VAR_14 & 0xF,\n(VAR_15>>4)+1, (VAR_15 & 0xF)+1, VAR_10, VAR_16, VAR_5);",
"}",
"}",
"}",
"VAR_1 += VAR_5 * 16;",
"}",
"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,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
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
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
] |
21,928 | int msi_init(struct PCIDevice *dev, uint8_t offset,
unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
{
unsigned int vectors_order;
uint16_t flags;
uint8_t cap_size;
int config_offset;
if (!msi_nonbroken) {
return -ENOTSUP;
}
MSI_DEV_PRINTF(dev,
"init offset: 0x%"PRIx8" vector: %"PRId8
" 64bit %d mask %d\n",
offset, nr_vectors, msi64bit, msi_per_vector_mask);
assert(!(nr_vectors & (nr_vectors - 1))); /* power of 2 */
assert(nr_vectors > 0);
assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
/* the nr of MSI vectors is up to 32 */
vectors_order = ctz32(nr_vectors);
flags = vectors_order << ctz32(PCI_MSI_FLAGS_QMASK);
if (msi64bit) {
flags |= PCI_MSI_FLAGS_64BIT;
}
if (msi_per_vector_mask) {
flags |= PCI_MSI_FLAGS_MASKBIT;
}
cap_size = msi_cap_sizeof(flags);
config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
if (config_offset < 0) {
return config_offset;
}
dev->msi_cap = config_offset;
dev->cap_present |= QEMU_PCI_CAP_MSI;
pci_set_word(dev->config + msi_flags_off(dev), flags);
pci_set_word(dev->wmask + msi_flags_off(dev),
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(dev->wmask + msi_address_lo_off(dev),
PCI_MSI_ADDRESS_LO_MASK);
if (msi64bit) {
pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff);
}
pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff);
if (msi_per_vector_mask) {
/* Make mask bits 0 to nr_vectors - 1 writable. */
pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
}
return 0;
}
| true | qemu | 1108b2f8a939fb5778d384149e2f1b99062a72da | int msi_init(struct PCIDevice *dev, uint8_t offset,
unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
{
unsigned int vectors_order;
uint16_t flags;
uint8_t cap_size;
int config_offset;
if (!msi_nonbroken) {
return -ENOTSUP;
}
MSI_DEV_PRINTF(dev,
"init offset: 0x%"PRIx8" vector: %"PRId8
" 64bit %d mask %d\n",
offset, nr_vectors, msi64bit, msi_per_vector_mask);
assert(!(nr_vectors & (nr_vectors - 1)));
assert(nr_vectors > 0);
assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
vectors_order = ctz32(nr_vectors);
flags = vectors_order << ctz32(PCI_MSI_FLAGS_QMASK);
if (msi64bit) {
flags |= PCI_MSI_FLAGS_64BIT;
}
if (msi_per_vector_mask) {
flags |= PCI_MSI_FLAGS_MASKBIT;
}
cap_size = msi_cap_sizeof(flags);
config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
if (config_offset < 0) {
return config_offset;
}
dev->msi_cap = config_offset;
dev->cap_present |= QEMU_PCI_CAP_MSI;
pci_set_word(dev->config + msi_flags_off(dev), flags);
pci_set_word(dev->wmask + msi_flags_off(dev),
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(dev->wmask + msi_address_lo_off(dev),
PCI_MSI_ADDRESS_LO_MASK);
if (msi64bit) {
pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff);
}
pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff);
if (msi_per_vector_mask) {
pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
}
return 0;
}
| {
"code": [
" unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)",
" config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);"
],
"line_no": [
3,
65
]
} | int FUNC_0(struct PCIDevice *VAR_0, uint8_t VAR_1,
unsigned int VAR_2, bool VAR_3, bool VAR_4)
{
unsigned int VAR_5;
uint16_t flags;
uint8_t cap_size;
int VAR_6;
if (!msi_nonbroken) {
return -ENOTSUP;
}
MSI_DEV_PRINTF(VAR_0,
"init VAR_1: 0x%"PRIx8" vector: %"PRId8
" 64bit %d mask %d\n",
VAR_1, VAR_2, VAR_3, VAR_4);
assert(!(VAR_2 & (VAR_2 - 1)));
assert(VAR_2 > 0);
assert(VAR_2 <= PCI_MSI_VECTORS_MAX);
VAR_5 = ctz32(VAR_2);
flags = VAR_5 << ctz32(PCI_MSI_FLAGS_QMASK);
if (VAR_3) {
flags |= PCI_MSI_FLAGS_64BIT;
}
if (VAR_4) {
flags |= PCI_MSI_FLAGS_MASKBIT;
}
cap_size = msi_cap_sizeof(flags);
VAR_6 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_1, cap_size);
if (VAR_6 < 0) {
return VAR_6;
}
VAR_0->msi_cap = VAR_6;
VAR_0->cap_present |= QEMU_PCI_CAP_MSI;
pci_set_word(VAR_0->config + msi_flags_off(VAR_0), flags);
pci_set_word(VAR_0->wmask + msi_flags_off(VAR_0),
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(VAR_0->wmask + msi_address_lo_off(VAR_0),
PCI_MSI_ADDRESS_LO_MASK);
if (VAR_3) {
pci_set_long(VAR_0->wmask + msi_address_hi_off(VAR_0), 0xffffffff);
}
pci_set_word(VAR_0->wmask + msi_data_off(VAR_0, VAR_3), 0xffff);
if (VAR_4) {
pci_set_long(VAR_0->wmask + msi_mask_off(VAR_0, VAR_3),
0xffffffff >> (PCI_MSI_VECTORS_MAX - VAR_2));
}
return 0;
}
| [
"int FUNC_0(struct PCIDevice *VAR_0, uint8_t VAR_1,\nunsigned int VAR_2, bool VAR_3, bool VAR_4)\n{",
"unsigned int VAR_5;",
"uint16_t flags;",
"uint8_t cap_size;",
"int VAR_6;",
"if (!msi_nonbroken) {",
"return -ENOTSUP;",
"}",
"MSI_DEV_PRINTF(VAR_0,\n\"init VAR_1: 0x%\"PRIx8\" vector: %\"PRId8\n\" 64bit %d mask %d\\n\",\nVAR_1, VAR_2, VAR_3, VAR_4);",
"assert(!(VAR_2 & (VAR_2 - 1)));",
"assert(VAR_2 > 0);",
"assert(VAR_2 <= PCI_MSI_VECTORS_MAX);",
"VAR_5 = ctz32(VAR_2);",
"flags = VAR_5 << ctz32(PCI_MSI_FLAGS_QMASK);",
"if (VAR_3) {",
"flags |= PCI_MSI_FLAGS_64BIT;",
"}",
"if (VAR_4) {",
"flags |= PCI_MSI_FLAGS_MASKBIT;",
"}",
"cap_size = msi_cap_sizeof(flags);",
"VAR_6 = pci_add_capability(VAR_0, PCI_CAP_ID_MSI, VAR_1, cap_size);",
"if (VAR_6 < 0) {",
"return VAR_6;",
"}",
"VAR_0->msi_cap = VAR_6;",
"VAR_0->cap_present |= QEMU_PCI_CAP_MSI;",
"pci_set_word(VAR_0->config + msi_flags_off(VAR_0), flags);",
"pci_set_word(VAR_0->wmask + msi_flags_off(VAR_0),\nPCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);",
"pci_set_long(VAR_0->wmask + msi_address_lo_off(VAR_0),\nPCI_MSI_ADDRESS_LO_MASK);",
"if (VAR_3) {",
"pci_set_long(VAR_0->wmask + msi_address_hi_off(VAR_0), 0xffffffff);",
"}",
"pci_set_word(VAR_0->wmask + msi_data_off(VAR_0, VAR_3), 0xffff);",
"if (VAR_4) {",
"pci_set_long(VAR_0->wmask + msi_mask_off(VAR_0, VAR_3),\n0xffffffff >> (PCI_MSI_VECTORS_MAX - VAR_2));",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
81
],
[
83,
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105,
107
],
[
109
],
[
113
],
[
115
]
] |
21,929 | static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
{
int t, sign, v;
const uint8_t *dec_end;
CHECK_READ_VAL(gb, b, t);
dec_end = b->cur_dec + t;
if (dec_end > b->data_end) {
av_log(avctx, AV_LOG_ERROR, "Too many motion values\n");
return -1;
}
if (get_bits1(gb)) {
v = get_bits(gb, 4);
if (v) {
sign = -get_bits1(gb);
v = (v ^ sign) - sign;
}
memset(b->cur_dec, v, t);
b->cur_dec += t;
} else {
do {
v = GET_HUFF(gb, b->tree);
if (v) {
sign = -get_bits1(gb);
v = (v ^ sign) - sign;
}
*b->cur_dec++ = v;
} while (b->cur_dec < dec_end);
}
return 0;
}
| true | FFmpeg | a00676e48e49a3d794d6d2063ceca539e945a4a4 | static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
{
int t, sign, v;
const uint8_t *dec_end;
CHECK_READ_VAL(gb, b, t);
dec_end = b->cur_dec + t;
if (dec_end > b->data_end) {
av_log(avctx, AV_LOG_ERROR, "Too many motion values\n");
return -1;
}
if (get_bits1(gb)) {
v = get_bits(gb, 4);
if (v) {
sign = -get_bits1(gb);
v = (v ^ sign) - sign;
}
memset(b->cur_dec, v, t);
b->cur_dec += t;
} else {
do {
v = GET_HUFF(gb, b->tree);
if (v) {
sign = -get_bits1(gb);
v = (v ^ sign) - sign;
}
*b->cur_dec++ = v;
} while (b->cur_dec < dec_end);
}
return 0;
}
| {
"code": [
" do {",
" } while (b->cur_dec < dec_end);",
" do {",
" } while (b->cur_dec < dec_end);"
],
"line_no": [
41,
55,
41,
55
]
} | static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1, Bundle *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
const uint8_t *VAR_6;
CHECK_READ_VAL(VAR_1, VAR_2, VAR_3);
VAR_6 = VAR_2->cur_dec + VAR_3;
if (VAR_6 > VAR_2->data_end) {
av_log(VAR_0, AV_LOG_ERROR, "Too many motion values\n");
return -1;
}
if (get_bits1(VAR_1)) {
VAR_5 = get_bits(VAR_1, 4);
if (VAR_5) {
VAR_4 = -get_bits1(VAR_1);
VAR_5 = (VAR_5 ^ VAR_4) - VAR_4;
}
memset(VAR_2->cur_dec, VAR_5, VAR_3);
VAR_2->cur_dec += VAR_3;
} else {
do {
VAR_5 = GET_HUFF(VAR_1, VAR_2->tree);
if (VAR_5) {
VAR_4 = -get_bits1(VAR_1);
VAR_5 = (VAR_5 ^ VAR_4) - VAR_4;
}
*VAR_2->cur_dec++ = VAR_5;
} while (VAR_2->cur_dec < VAR_6);
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1, Bundle *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"const uint8_t *VAR_6;",
"CHECK_READ_VAL(VAR_1, VAR_2, VAR_3);",
"VAR_6 = VAR_2->cur_dec + VAR_3;",
"if (VAR_6 > VAR_2->data_end) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Too many motion values\\n\");",
"return -1;",
"}",
"if (get_bits1(VAR_1)) {",
"VAR_5 = get_bits(VAR_1, 4);",
"if (VAR_5) {",
"VAR_4 = -get_bits1(VAR_1);",
"VAR_5 = (VAR_5 ^ VAR_4) - VAR_4;",
"}",
"memset(VAR_2->cur_dec, VAR_5, VAR_3);",
"VAR_2->cur_dec += VAR_3;",
"} else {",
"do {",
"VAR_5 = GET_HUFF(VAR_1, VAR_2->tree);",
"if (VAR_5) {",
"VAR_4 = -get_bits1(VAR_1);",
"VAR_5 = (VAR_5 ^ VAR_4) - VAR_4;",
"}",
"*VAR_2->cur_dec++ = VAR_5;",
"} while (VAR_2->cur_dec < VAR_6);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
]
] |
21,930 | static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)
{
TCGv tmp;
if (spsr) {
/* ??? This is also undefined in system mode. */
if (IS_USER(s))
return 1;
tmp = load_cpu_field(spsr);
tcg_gen_andi_i32(tmp, tmp, ~mask);
tcg_gen_andi_i32(t0, t0, mask);
tcg_gen_or_i32(tmp, tmp, t0);
store_cpu_field(tmp, spsr);
} else {
gen_set_cpsr(t0, mask);
}
dead_tmp(t0);
gen_lookup_tb(s);
return 0;
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)
{
TCGv tmp;
if (spsr) {
if (IS_USER(s))
return 1;
tmp = load_cpu_field(spsr);
tcg_gen_andi_i32(tmp, tmp, ~mask);
tcg_gen_andi_i32(t0, t0, mask);
tcg_gen_or_i32(tmp, tmp, t0);
store_cpu_field(tmp, spsr);
} else {
gen_set_cpsr(t0, mask);
}
dead_tmp(t0);
gen_lookup_tb(s);
return 0;
}
| {
"code": [
" dead_tmp(t0);"
],
"line_no": [
33
]
} | static int FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, int VAR_2, TCGv VAR_3)
{
TCGv tmp;
if (VAR_2) {
if (IS_USER(VAR_0))
return 1;
tmp = load_cpu_field(VAR_2);
tcg_gen_andi_i32(tmp, tmp, ~VAR_1);
tcg_gen_andi_i32(VAR_3, VAR_3, VAR_1);
tcg_gen_or_i32(tmp, tmp, VAR_3);
store_cpu_field(tmp, VAR_2);
} else {
gen_set_cpsr(VAR_3, VAR_1);
}
dead_tmp(VAR_3);
gen_lookup_tb(VAR_0);
return 0;
}
| [
"static int FUNC_0(DisasContext *VAR_0, uint32_t VAR_1, int VAR_2, TCGv VAR_3)\n{",
"TCGv tmp;",
"if (VAR_2) {",
"if (IS_USER(VAR_0))\nreturn 1;",
"tmp = load_cpu_field(VAR_2);",
"tcg_gen_andi_i32(tmp, tmp, ~VAR_1);",
"tcg_gen_andi_i32(VAR_3, VAR_3, VAR_1);",
"tcg_gen_or_i32(tmp, tmp, VAR_3);",
"store_cpu_field(tmp, VAR_2);",
"} else {",
"gen_set_cpsr(VAR_3, VAR_1);",
"}",
"dead_tmp(VAR_3);",
"gen_lookup_tb(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
21,931 | int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
{
int i;
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
int max_step [4]; /* max pixel step for each plane */
int max_step_comp[4]; /* the component for each plane which has the max pixel step */
memset(linesizes, 0, 4*sizeof(linesizes[0]));
if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (desc->flags & PIX_FMT_BITSTREAM) {
if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1))
return AVERROR(EINVAL);
linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
for (i = 0; i < 4; i++) {
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
int shifted_w = ((width + (1 << s) - 1)) >> s;
if (max_step[i] > INT_MAX / shifted_w)
return AVERROR(EINVAL);
linesizes[i] = max_step[i] * shifted_w;
}
return 0;
}
| true | FFmpeg | 10931720cd55d83e0b933b8a9bb0795fd9e48875 | int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
{
int i;
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
int max_step [4];
int max_step_comp[4];
memset(linesizes, 0, 4*sizeof(linesizes[0]));
if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (desc->flags & PIX_FMT_BITSTREAM) {
if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1))
return AVERROR(EINVAL);
linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
for (i = 0; i < 4; i++) {
int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
int shifted_w = ((width + (1 << s) - 1)) >> s;
if (max_step[i] > INT_MAX / shifted_w)
return AVERROR(EINVAL);
linesizes[i] = max_step[i] * shifted_w;
}
return 0;
}
| {
"code": [
" if (desc->flags & PIX_FMT_BITSTREAM) {",
" if (width > (INT_MAX -7) / (desc->comp[0].step_minus1+1))",
" return AVERROR(EINVAL);",
" linesizes[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;",
" return 0;"
],
"line_no": [
25,
27,
29,
31,
33
]
} | int FUNC_0(int VAR_0[4], enum PixelFormat VAR_1, int VAR_2)
{
int VAR_3;
const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1];
int VAR_5 [4];
int VAR_6[4];
memset(VAR_0, 0, 4*sizeof(VAR_0[0]));
if ((unsigned)VAR_1 >= PIX_FMT_NB || VAR_4->flags & PIX_FMT_HWACCEL)
return AVERROR(EINVAL);
if (VAR_4->flags & PIX_FMT_BITSTREAM) {
if (VAR_2 > (INT_MAX -7) / (VAR_4->comp[0].step_minus1+1))
return AVERROR(EINVAL);
VAR_0[0] = (VAR_2 * (VAR_4->comp[0].step_minus1+1) + 7) >> 3;
return 0;
}
av_image_fill_max_pixsteps(VAR_5, VAR_6, VAR_4);
for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {
int VAR_7 = (VAR_6[VAR_3] == 1 || VAR_6[VAR_3] == 2) ? VAR_4->log2_chroma_w : 0;
int VAR_8 = ((VAR_2 + (1 << VAR_7) - 1)) >> VAR_7;
if (VAR_5[VAR_3] > INT_MAX / VAR_8)
return AVERROR(EINVAL);
VAR_0[VAR_3] = VAR_5[VAR_3] * VAR_8;
}
return 0;
}
| [
"int FUNC_0(int VAR_0[4], enum PixelFormat VAR_1, int VAR_2)\n{",
"int VAR_3;",
"const AVPixFmtDescriptor *VAR_4 = &av_pix_fmt_descriptors[VAR_1];",
"int VAR_5 [4];",
"int VAR_6[4];",
"memset(VAR_0, 0, 4*sizeof(VAR_0[0]));",
"if ((unsigned)VAR_1 >= PIX_FMT_NB || VAR_4->flags & PIX_FMT_HWACCEL)\nreturn AVERROR(EINVAL);",
"if (VAR_4->flags & PIX_FMT_BITSTREAM) {",
"if (VAR_2 > (INT_MAX -7) / (VAR_4->comp[0].step_minus1+1))\nreturn AVERROR(EINVAL);",
"VAR_0[0] = (VAR_2 * (VAR_4->comp[0].step_minus1+1) + 7) >> 3;",
"return 0;",
"}",
"av_image_fill_max_pixsteps(VAR_5, VAR_6, VAR_4);",
"for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {",
"int VAR_7 = (VAR_6[VAR_3] == 1 || VAR_6[VAR_3] == 2) ? VAR_4->log2_chroma_w : 0;",
"int VAR_8 = ((VAR_2 + (1 << VAR_7) - 1)) >> VAR_7;",
"if (VAR_5[VAR_3] > INT_MAX / VAR_8)\nreturn AVERROR(EINVAL);",
"VAR_0[VAR_3] = VAR_5[VAR_3] * VAR_8;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19,
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
]
] |
21,932 | static int nbd_negotiate_options(NBDClient *client, uint16_t myflags,
Error **errp)
{
uint32_t flags;
bool fixedNewstyle = false;
bool no_zeroes = false;
/* Client sends:
[ 0 .. 3] client flags
Then we loop until NBD_OPT_EXPORT_NAME or NBD_OPT_GO:
[ 0 .. 7] NBD_OPTS_MAGIC
[ 8 .. 11] NBD option
[12 .. 15] Data length
... Rest of request
[ 0 .. 7] NBD_OPTS_MAGIC
[ 8 .. 11] Second NBD option
[12 .. 15] Data length
... Rest of request
*/
if (nbd_read(client->ioc, &flags, sizeof(flags), errp) < 0) {
error_prepend(errp, "read failed: ");
return -EIO;
be32_to_cpus(&flags);
trace_nbd_negotiate_options_flags(flags);
if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) {
fixedNewstyle = true;
flags &= ~NBD_FLAG_C_FIXED_NEWSTYLE;
if (flags & NBD_FLAG_C_NO_ZEROES) {
no_zeroes = true;
flags &= ~NBD_FLAG_C_NO_ZEROES;
if (flags != 0) {
error_setg(errp, "Unknown client flags 0x%" PRIx32 " received", flags);
while (1) {
int ret;
uint32_t option, length;
uint64_t magic;
if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) {
error_prepend(errp, "read failed: ");
magic = be64_to_cpu(magic);
trace_nbd_negotiate_options_check_magic(magic);
if (magic != NBD_OPTS_MAGIC) {
error_setg(errp, "Bad magic received");
if (nbd_read(client->ioc, &option,
sizeof(option), errp) < 0) {
error_prepend(errp, "read failed: ");
option = be32_to_cpu(option);
if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) {
error_prepend(errp, "read failed: ");
length = be32_to_cpu(length);
trace_nbd_negotiate_options_check_option(option,
nbd_opt_lookup(option));
if (client->tlscreds &&
client->ioc == (QIOChannel *)client->sioc) {
QIOChannel *tioc;
if (!fixedNewstyle) {
error_setg(errp, "Unsupported option 0x%" PRIx32, option);
switch (option) {
case NBD_OPT_STARTTLS:
if (length) {
/* Unconditionally drop the connection if the client
* can't start a TLS negotiation correctly */
return nbd_reject_length(client, length, option, true,
errp);
tioc = nbd_negotiate_handle_starttls(client, errp);
if (!tioc) {
return -EIO;
ret = 0;
object_unref(OBJECT(client->ioc));
client->ioc = QIO_CHANNEL(tioc);
break;
case NBD_OPT_EXPORT_NAME:
/* No way to return an error to client, so drop connection */
error_setg(errp, "Option 0x%x not permitted before TLS",
option);
default:
if (nbd_drop(client->ioc, length, errp) < 0) {
return -EIO;
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_TLS_REQD,
option, errp,
"Option 0x%" PRIx32
"not permitted before TLS",
option);
/* Let the client keep trying, unless they asked to
* quit. In this mode, we've already sent an error, so
* we can't ack the abort. */
if (option == NBD_OPT_ABORT) {
return 1;
break;
} else if (fixedNewstyle) {
switch (option) {
case NBD_OPT_LIST:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else {
ret = nbd_negotiate_handle_list(client, errp);
break;
case NBD_OPT_ABORT:
/* NBD spec says we must try to reply before
* disconnecting, but that we must also tolerate
* guests that don't wait for our reply. */
nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, option, NULL);
return 1;
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(client, length,
myflags, no_zeroes,
errp);
case NBD_OPT_INFO:
case NBD_OPT_GO:
ret = nbd_negotiate_handle_info(client, length, option,
myflags, errp);
if (ret == 1) {
assert(option == NBD_OPT_GO);
return 0;
break;
case NBD_OPT_STARTTLS:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else if (client->tlscreds) {
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_INVALID,
option, errp,
"TLS already enabled");
} else {
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_POLICY,
option, errp,
"TLS not configured");
break;
case NBD_OPT_STRUCTURED_REPLY:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else if (client->structured_reply) {
ret = nbd_negotiate_send_rep_err(
client->ioc, NBD_REP_ERR_INVALID, option, errp,
"structured reply already negotiated");
} else {
ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,
option, errp);
client->structured_reply = true;
myflags |= NBD_FLAG_SEND_DF;
break;
default:
if (nbd_drop(client->ioc, length, errp) < 0) {
return -EIO;
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_UNSUP,
option, errp,
"Unsupported option 0x%"
PRIx32 " (%s)", option,
nbd_opt_lookup(option));
break;
} else {
/*
* If broken new-style we should drop the connection
* for anything except NBD_OPT_EXPORT_NAME
*/
switch (option) {
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(client, length,
myflags, no_zeroes,
errp);
default:
error_setg(errp, "Unsupported option 0x%" PRIx32 " (%s)",
option, nbd_opt_lookup(option));
if (ret < 0) {
return ret; | true | qemu | fdad35ef6c5839d50dfc14073364ac893afebc30 | static int nbd_negotiate_options(NBDClient *client, uint16_t myflags,
Error **errp)
{
uint32_t flags;
bool fixedNewstyle = false;
bool no_zeroes = false;
if (nbd_read(client->ioc, &flags, sizeof(flags), errp) < 0) {
error_prepend(errp, "read failed: ");
return -EIO;
be32_to_cpus(&flags);
trace_nbd_negotiate_options_flags(flags);
if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) {
fixedNewstyle = true;
flags &= ~NBD_FLAG_C_FIXED_NEWSTYLE;
if (flags & NBD_FLAG_C_NO_ZEROES) {
no_zeroes = true;
flags &= ~NBD_FLAG_C_NO_ZEROES;
if (flags != 0) {
error_setg(errp, "Unknown client flags 0x%" PRIx32 " received", flags);
while (1) {
int ret;
uint32_t option, length;
uint64_t magic;
if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) {
error_prepend(errp, "read failed: ");
magic = be64_to_cpu(magic);
trace_nbd_negotiate_options_check_magic(magic);
if (magic != NBD_OPTS_MAGIC) {
error_setg(errp, "Bad magic received");
if (nbd_read(client->ioc, &option,
sizeof(option), errp) < 0) {
error_prepend(errp, "read failed: ");
option = be32_to_cpu(option);
if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) {
error_prepend(errp, "read failed: ");
length = be32_to_cpu(length);
trace_nbd_negotiate_options_check_option(option,
nbd_opt_lookup(option));
if (client->tlscreds &&
client->ioc == (QIOChannel *)client->sioc) {
QIOChannel *tioc;
if (!fixedNewstyle) {
error_setg(errp, "Unsupported option 0x%" PRIx32, option);
switch (option) {
case NBD_OPT_STARTTLS:
if (length) {
return nbd_reject_length(client, length, option, true,
errp);
tioc = nbd_negotiate_handle_starttls(client, errp);
if (!tioc) {
return -EIO;
ret = 0;
object_unref(OBJECT(client->ioc));
client->ioc = QIO_CHANNEL(tioc);
break;
case NBD_OPT_EXPORT_NAME:
error_setg(errp, "Option 0x%x not permitted before TLS",
option);
default:
if (nbd_drop(client->ioc, length, errp) < 0) {
return -EIO;
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_TLS_REQD,
option, errp,
"Option 0x%" PRIx32
"not permitted before TLS",
option);
if (option == NBD_OPT_ABORT) {
return 1;
break;
} else if (fixedNewstyle) {
switch (option) {
case NBD_OPT_LIST:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else {
ret = nbd_negotiate_handle_list(client, errp);
break;
case NBD_OPT_ABORT:
nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, option, NULL);
return 1;
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(client, length,
myflags, no_zeroes,
errp);
case NBD_OPT_INFO:
case NBD_OPT_GO:
ret = nbd_negotiate_handle_info(client, length, option,
myflags, errp);
if (ret == 1) {
assert(option == NBD_OPT_GO);
return 0;
break;
case NBD_OPT_STARTTLS:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else if (client->tlscreds) {
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_INVALID,
option, errp,
"TLS already enabled");
} else {
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_POLICY,
option, errp,
"TLS not configured");
break;
case NBD_OPT_STRUCTURED_REPLY:
if (length) {
ret = nbd_reject_length(client, length, option, false,
errp);
} else if (client->structured_reply) {
ret = nbd_negotiate_send_rep_err(
client->ioc, NBD_REP_ERR_INVALID, option, errp,
"structured reply already negotiated");
} else {
ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,
option, errp);
client->structured_reply = true;
myflags |= NBD_FLAG_SEND_DF;
break;
default:
if (nbd_drop(client->ioc, length, errp) < 0) {
return -EIO;
ret = nbd_negotiate_send_rep_err(client->ioc,
NBD_REP_ERR_UNSUP,
option, errp,
"Unsupported option 0x%"
PRIx32 " (%s)", option,
nbd_opt_lookup(option));
break;
} else {
switch (option) {
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(client, length,
myflags, no_zeroes,
errp);
default:
error_setg(errp, "Unsupported option 0x%" PRIx32 " (%s)",
option, nbd_opt_lookup(option));
if (ret < 0) {
return ret; | {
"code": [],
"line_no": []
} | static int FUNC_0(NBDClient *VAR_0, uint16_t VAR_1,
Error **VAR_2)
{
uint32_t flags;
bool fixedNewstyle = false;
bool no_zeroes = false;
if (nbd_read(VAR_0->ioc, &flags, sizeof(flags), VAR_2) < 0) {
error_prepend(VAR_2, "read failed: ");
return -EIO;
be32_to_cpus(&flags);
trace_nbd_negotiate_options_flags(flags);
if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) {
fixedNewstyle = true;
flags &= ~NBD_FLAG_C_FIXED_NEWSTYLE;
if (flags & NBD_FLAG_C_NO_ZEROES) {
no_zeroes = true;
flags &= ~NBD_FLAG_C_NO_ZEROES;
if (flags != 0) {
error_setg(VAR_2, "Unknown VAR_0 flags 0x%" PRIx32 " received", flags);
while (1) {
int VAR_3;
uint32_t option, length;
uint64_t magic;
if (nbd_read(VAR_0->ioc, &magic, sizeof(magic), VAR_2) < 0) {
error_prepend(VAR_2, "read failed: ");
magic = be64_to_cpu(magic);
trace_nbd_negotiate_options_check_magic(magic);
if (magic != NBD_OPTS_MAGIC) {
error_setg(VAR_2, "Bad magic received");
if (nbd_read(VAR_0->ioc, &option,
sizeof(option), VAR_2) < 0) {
error_prepend(VAR_2, "read failed: ");
option = be32_to_cpu(option);
if (nbd_read(VAR_0->ioc, &length, sizeof(length), VAR_2) < 0) {
error_prepend(VAR_2, "read failed: ");
length = be32_to_cpu(length);
trace_nbd_negotiate_options_check_option(option,
nbd_opt_lookup(option));
if (VAR_0->tlscreds &&
VAR_0->ioc == (QIOChannel *)VAR_0->sioc) {
QIOChannel *tioc;
if (!fixedNewstyle) {
error_setg(VAR_2, "Unsupported option 0x%" PRIx32, option);
switch (option) {
case NBD_OPT_STARTTLS:
if (length) {
return nbd_reject_length(VAR_0, length, option, true,
VAR_2);
tioc = nbd_negotiate_handle_starttls(VAR_0, VAR_2);
if (!tioc) {
return -EIO;
VAR_3 = 0;
object_unref(OBJECT(VAR_0->ioc));
VAR_0->ioc = QIO_CHANNEL(tioc);
break;
case NBD_OPT_EXPORT_NAME:
error_setg(VAR_2, "Option 0x%x not permitted before TLS",
option);
default:
if (nbd_drop(VAR_0->ioc, length, VAR_2) < 0) {
return -EIO;
VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,
NBD_REP_ERR_TLS_REQD,
option, VAR_2,
"Option 0x%" PRIx32
"not permitted before TLS",
option);
if (option == NBD_OPT_ABORT) {
return 1;
break;
} else if (fixedNewstyle) {
switch (option) {
case NBD_OPT_LIST:
if (length) {
VAR_3 = nbd_reject_length(VAR_0, length, option, false,
VAR_2);
} else {
VAR_3 = nbd_negotiate_handle_list(VAR_0, VAR_2);
break;
case NBD_OPT_ABORT:
nbd_negotiate_send_rep(VAR_0->ioc, NBD_REP_ACK, option, NULL);
return 1;
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(VAR_0, length,
VAR_1, no_zeroes,
VAR_2);
case NBD_OPT_INFO:
case NBD_OPT_GO:
VAR_3 = nbd_negotiate_handle_info(VAR_0, length, option,
VAR_1, VAR_2);
if (VAR_3 == 1) {
assert(option == NBD_OPT_GO);
return 0;
break;
case NBD_OPT_STARTTLS:
if (length) {
VAR_3 = nbd_reject_length(VAR_0, length, option, false,
VAR_2);
} else if (VAR_0->tlscreds) {
VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,
NBD_REP_ERR_INVALID,
option, VAR_2,
"TLS already enabled");
} else {
VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,
NBD_REP_ERR_POLICY,
option, VAR_2,
"TLS not configured");
break;
case NBD_OPT_STRUCTURED_REPLY:
if (length) {
VAR_3 = nbd_reject_length(VAR_0, length, option, false,
VAR_2);
} else if (VAR_0->structured_reply) {
VAR_3 = nbd_negotiate_send_rep_err(
VAR_0->ioc, NBD_REP_ERR_INVALID, option, VAR_2,
"structured reply already negotiated");
} else {
VAR_3 = nbd_negotiate_send_rep(VAR_0->ioc, NBD_REP_ACK,
option, VAR_2);
VAR_0->structured_reply = true;
VAR_1 |= NBD_FLAG_SEND_DF;
break;
default:
if (nbd_drop(VAR_0->ioc, length, VAR_2) < 0) {
return -EIO;
VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,
NBD_REP_ERR_UNSUP,
option, VAR_2,
"Unsupported option 0x%"
PRIx32 " (%s)", option,
nbd_opt_lookup(option));
break;
} else {
switch (option) {
case NBD_OPT_EXPORT_NAME:
return nbd_negotiate_handle_export_name(VAR_0, length,
VAR_1, no_zeroes,
VAR_2);
default:
error_setg(VAR_2, "Unsupported option 0x%" PRIx32 " (%s)",
option, nbd_opt_lookup(option));
if (VAR_3 < 0) {
return VAR_3; | [
"static int FUNC_0(NBDClient *VAR_0, uint16_t VAR_1,\nError **VAR_2)\n{",
"uint32_t flags;",
"bool fixedNewstyle = false;",
"bool no_zeroes = false;",
"if (nbd_read(VAR_0->ioc, &flags, sizeof(flags), VAR_2) < 0) {",
"error_prepend(VAR_2, \"read failed: \");",
"return -EIO;",
"be32_to_cpus(&flags);",
"trace_nbd_negotiate_options_flags(flags);",
"if (flags & NBD_FLAG_C_FIXED_NEWSTYLE) {",
"fixedNewstyle = true;",
"flags &= ~NBD_FLAG_C_FIXED_NEWSTYLE;",
"if (flags & NBD_FLAG_C_NO_ZEROES) {",
"no_zeroes = true;",
"flags &= ~NBD_FLAG_C_NO_ZEROES;",
"if (flags != 0) {",
"error_setg(VAR_2, \"Unknown VAR_0 flags 0x%\" PRIx32 \" received\", flags);",
"while (1) {",
"int VAR_3;",
"uint32_t option, length;",
"uint64_t magic;",
"if (nbd_read(VAR_0->ioc, &magic, sizeof(magic), VAR_2) < 0) {",
"error_prepend(VAR_2, \"read failed: \");",
"magic = be64_to_cpu(magic);",
"trace_nbd_negotiate_options_check_magic(magic);",
"if (magic != NBD_OPTS_MAGIC) {",
"error_setg(VAR_2, \"Bad magic received\");",
"if (nbd_read(VAR_0->ioc, &option,\nsizeof(option), VAR_2) < 0) {",
"error_prepend(VAR_2, \"read failed: \");",
"option = be32_to_cpu(option);",
"if (nbd_read(VAR_0->ioc, &length, sizeof(length), VAR_2) < 0) {",
"error_prepend(VAR_2, \"read failed: \");",
"length = be32_to_cpu(length);",
"trace_nbd_negotiate_options_check_option(option,\nnbd_opt_lookup(option));",
"if (VAR_0->tlscreds &&\nVAR_0->ioc == (QIOChannel *)VAR_0->sioc) {",
"QIOChannel *tioc;",
"if (!fixedNewstyle) {",
"error_setg(VAR_2, \"Unsupported option 0x%\" PRIx32, option);",
"switch (option) {",
"case NBD_OPT_STARTTLS:\nif (length) {",
"return nbd_reject_length(VAR_0, length, option, true,\nVAR_2);",
"tioc = nbd_negotiate_handle_starttls(VAR_0, VAR_2);",
"if (!tioc) {",
"return -EIO;",
"VAR_3 = 0;",
"object_unref(OBJECT(VAR_0->ioc));",
"VAR_0->ioc = QIO_CHANNEL(tioc);",
"break;",
"case NBD_OPT_EXPORT_NAME:\nerror_setg(VAR_2, \"Option 0x%x not permitted before TLS\",\noption);",
"default:\nif (nbd_drop(VAR_0->ioc, length, VAR_2) < 0) {",
"return -EIO;",
"VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,\nNBD_REP_ERR_TLS_REQD,\noption, VAR_2,\n\"Option 0x%\" PRIx32\n\"not permitted before TLS\",\noption);",
"if (option == NBD_OPT_ABORT) {",
"return 1;",
"break;",
"} else if (fixedNewstyle) {",
"switch (option) {",
"case NBD_OPT_LIST:\nif (length) {",
"VAR_3 = nbd_reject_length(VAR_0, length, option, false,\nVAR_2);",
"} else {",
"VAR_3 = nbd_negotiate_handle_list(VAR_0, VAR_2);",
"break;",
"case NBD_OPT_ABORT:\nnbd_negotiate_send_rep(VAR_0->ioc, NBD_REP_ACK, option, NULL);",
"return 1;",
"case NBD_OPT_EXPORT_NAME:\nreturn nbd_negotiate_handle_export_name(VAR_0, length,\nVAR_1, no_zeroes,\nVAR_2);",
"case NBD_OPT_INFO:\ncase NBD_OPT_GO:\nVAR_3 = nbd_negotiate_handle_info(VAR_0, length, option,\nVAR_1, VAR_2);",
"if (VAR_3 == 1) {",
"assert(option == NBD_OPT_GO);",
"return 0;",
"break;",
"case NBD_OPT_STARTTLS:\nif (length) {",
"VAR_3 = nbd_reject_length(VAR_0, length, option, false,\nVAR_2);",
"} else if (VAR_0->tlscreds) {",
"VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,\nNBD_REP_ERR_INVALID,\noption, VAR_2,\n\"TLS already enabled\");",
"} else {",
"VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,\nNBD_REP_ERR_POLICY,\noption, VAR_2,\n\"TLS not configured\");",
"break;",
"case NBD_OPT_STRUCTURED_REPLY:\nif (length) {",
"VAR_3 = nbd_reject_length(VAR_0, length, option, false,\nVAR_2);",
"} else if (VAR_0->structured_reply) {",
"VAR_3 = nbd_negotiate_send_rep_err(\nVAR_0->ioc, NBD_REP_ERR_INVALID, option, VAR_2,\n\"structured reply already negotiated\");",
"} else {",
"VAR_3 = nbd_negotiate_send_rep(VAR_0->ioc, NBD_REP_ACK,\noption, VAR_2);",
"VAR_0->structured_reply = true;",
"VAR_1 |= NBD_FLAG_SEND_DF;",
"break;",
"default:\nif (nbd_drop(VAR_0->ioc, length, VAR_2) < 0) {",
"return -EIO;",
"VAR_3 = nbd_negotiate_send_rep_err(VAR_0->ioc,\nNBD_REP_ERR_UNSUP,\noption, VAR_2,\n\"Unsupported option 0x%\"\nPRIx32 \" (%s)\", option,\nnbd_opt_lookup(option));",
"break;",
"} else {",
"switch (option) {",
"case NBD_OPT_EXPORT_NAME:\nreturn nbd_negotiate_handle_export_name(VAR_0, length,\nVAR_1, no_zeroes,\nVAR_2);",
"default:\nerror_setg(VAR_2, \"Unsupported option 0x%\" PRIx32 \" (%s)\",\noption, nbd_opt_lookup(option));",
"if (VAR_3 < 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41
],
[
42,
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49,
50
],
[
51,
52
],
[
53
],
[
54
],
[
55
],
[
56
],
[
57,
58
],
[
61,
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
68
],
[
69
],
[
70,
72,
73
],
[
74,
75
],
[
76
],
[
77,
78,
79,
80,
81,
82
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91,
92
],
[
93,
94
],
[
95
],
[
96
],
[
97
],
[
98,
102
],
[
103
],
[
104,
105,
106,
107
],
[
108,
109,
110,
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116,
117
],
[
118,
119
],
[
120
],
[
121,
122,
123,
124
],
[
125
],
[
126,
127,
128,
129
],
[
130
],
[
131,
132
],
[
133,
134
],
[
135
],
[
136,
137,
138
],
[
139
],
[
140,
141
],
[
142
],
[
143
],
[
144
],
[
145,
146
],
[
147
],
[
148,
149,
150,
151,
152,
153
],
[
154
],
[
155
],
[
160
],
[
161,
162,
163,
164
],
[
165,
166,
167
],
[
168
],
[
169
]
] |
21,933 | static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
virtio_blk_set_conf(vdev, &(dev->blk));
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
if (qdev_init(vdev) < 0) {
return -1;
}
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
}
| true | qemu | caffdac363801cd2cf2bf01ad013a8c1e1e43800 | static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
virtio_blk_set_conf(vdev, &(dev->blk));
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
if (qdev_init(vdev) < 0) {
return -1;
}
return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev));
}
| {
"code": [
" virtio_blk_set_conf(vdev, &(dev->blk));",
" virtio_blk_set_conf(vdev, &(dev->blk));",
" virtio_blk_set_conf(vdev, &(dev->blk));"
],
"line_no": [
9,
9,
9
]
} | static int FUNC_0(VirtioCcwDevice *VAR_0)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(VAR_0);
DeviceState *vdev = DEVICE(&dev->vdev);
virtio_blk_set_conf(vdev, &(dev->blk));
qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));
if (qdev_init(vdev) < 0) {
return -1;
}
return virtio_ccw_device_init(VAR_0, VIRTIO_DEVICE(vdev));
}
| [
"static int FUNC_0(VirtioCcwDevice *VAR_0)\n{",
"VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(VAR_0);",
"DeviceState *vdev = DEVICE(&dev->vdev);",
"virtio_blk_set_conf(vdev, &(dev->blk));",
"qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));",
"if (qdev_init(vdev) < 0) {",
"return -1;",
"}",
"return virtio_ccw_device_init(VAR_0, VIRTIO_DEVICE(vdev));",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
21,934 | static av_cold int libschroedinger_decode_close(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
/* Free the decoder. */
schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format);
/* Free data in the output frame queue. */
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
return 0;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | static av_cold int libschroedinger_decode_close(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format);
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
return 0;
}
| {
"code": [
" return 0;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" return 0;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
"static av_cold int libschroedinger_decode_close(AVCodecContext *avctx)",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" schro_decoder_free(p_schro_params->decoder);",
" av_freep(&p_schro_params->format);",
" ff_schro_queue_free(&p_schro_params->dec_frame_queue,",
" libschroedinger_decode_frame_free);",
" return 0;",
" SchroDecoderParams *p_schro_params = avctx->priv_data;",
" ff_schro_queue_free(&p_schro_params->dec_frame_queue,",
" libschroedinger_decode_frame_free);",
" return 0;",
" av_freep(&p_schro_params->format);",
" return 0;"
],
"line_no": [
23,
5,
23,
5,
5,
1,
5,
9,
11,
17,
19,
23,
5,
17,
19,
23,
11,
23
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
SchroDecoderParams *p_schro_params = avctx->priv_data;
schro_decoder_free(p_schro_params->decoder);
av_freep(&p_schro_params->format);
ff_schro_queue_free(&p_schro_params->dec_frame_queue,
libschroedinger_decode_frame_free);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"SchroDecoderParams *p_schro_params = avctx->priv_data;",
"schro_decoder_free(p_schro_params->decoder);",
"av_freep(&p_schro_params->format);",
"ff_schro_queue_free(&p_schro_params->dec_frame_queue,\nlibschroedinger_decode_frame_free);",
"return 0;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
17,
19
],
[
23
],
[
25
]
] |
21,935 | static void parse_forced_key_frames(char *kf, OutputStream *ost,
AVCodecContext *avctx)
{
char *p;
int n = 1, i;
int64_t t;
for (p = kf; *p; p++)
if (*p == ',')
n++;
ost->forced_kf_count = n;
ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
if (!ost->forced_kf_pts) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n");
exit(1);
}
p = kf;
for (i = 0; i < n; i++) {
char *next = strchr(p, ',');
if (next)
*next++ = 0;
t = parse_time_or_die("force_key_frames", p, 1);
ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
p = next;
}
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb | static void parse_forced_key_frames(char *kf, OutputStream *ost,
AVCodecContext *avctx)
{
char *p;
int n = 1, i;
int64_t t;
for (p = kf; *p; p++)
if (*p == ',')
n++;
ost->forced_kf_count = n;
ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
if (!ost->forced_kf_pts) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n");
exit(1);
}
p = kf;
for (i = 0; i < n; i++) {
char *next = strchr(p, ',');
if (next)
*next++ = 0;
t = parse_time_or_die("force_key_frames", p, 1);
ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
p = next;
}
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);"
],
"line_no": [
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29
]
} | static void FUNC_0(char *VAR_0, OutputStream *VAR_1,
AVCodecContext *VAR_2)
{
char *VAR_3;
int VAR_4 = 1, VAR_5;
int64_t t;
for (VAR_3 = VAR_0; *VAR_3; VAR_3++)
if (*VAR_3 == ',')
VAR_4++;
VAR_1->forced_kf_count = VAR_4;
VAR_1->forced_kf_pts = av_malloc(sizeof(*VAR_1->forced_kf_pts) * VAR_4);
if (!VAR_1->forced_kf_pts) {
av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\VAR_4");
exit(1);
}
VAR_3 = VAR_0;
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
char *VAR_6 = strchr(VAR_3, ',');
if (VAR_6)
*VAR_6++ = 0;
t = parse_time_or_die("force_key_frames", VAR_3, 1);
VAR_1->forced_kf_pts[VAR_5] = av_rescale_q(t, AV_TIME_BASE_Q, VAR_2->time_base);
VAR_3 = VAR_6;
}
}
| [
"static void FUNC_0(char *VAR_0, OutputStream *VAR_1,\nAVCodecContext *VAR_2)\n{",
"char *VAR_3;",
"int VAR_4 = 1, VAR_5;",
"int64_t t;",
"for (VAR_3 = VAR_0; *VAR_3; VAR_3++)",
"if (*VAR_3 == ',')\nVAR_4++;",
"VAR_1->forced_kf_count = VAR_4;",
"VAR_1->forced_kf_pts = av_malloc(sizeof(*VAR_1->forced_kf_pts) * VAR_4);",
"if (!VAR_1->forced_kf_pts) {",
"av_log(NULL, AV_LOG_FATAL, \"Could not allocate forced key frames array.\\VAR_4\");",
"exit(1);",
"}",
"VAR_3 = VAR_0;",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"char *VAR_6 = strchr(VAR_3, ',');",
"if (VAR_6)\n*VAR_6++ = 0;",
"t = parse_time_or_die(\"force_key_frames\", VAR_3, 1);",
"VAR_1->forced_kf_pts[VAR_5] = av_rescale_q(t, AV_TIME_BASE_Q, VAR_2->time_base);",
"VAR_3 = VAR_6;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
]
] |
21,936 | void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y)
{
VP8Macroblock *mb_edge[3] = { mb + 2 /* top */,
mb - 1 /* left */,
mb + 1 /* top-left */ };
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
int idx = CNT_ZERO;
int cur_sign_bias = s->sign_bias[mb->ref_frame];
int8_t *sign_bias = s->sign_bias;
VP56mv near_mv[4];
uint8_t cnt[4] = { 0 };
VP56RangeCoder *c = &s->c;
AV_ZERO32(&near_mv[0]);
AV_ZERO32(&near_mv[1]);
/* Process MB on top, left and top-left */
#define MV_EDGE_CHECK(n)\
{\
VP8Macroblock *edge = mb_edge[n];\
int edge_ref = edge->ref_frame;\
if (edge_ref != VP56_FRAME_CURRENT) {\
uint32_t mv = AV_RN32A(&edge->mv);\
if (mv) {\
if (cur_sign_bias != sign_bias[edge_ref]) {\
/* SWAR negate of the values in mv. */\
mv = ~mv;\
mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
}\
if (!n || mv != AV_RN32A(&near_mv[idx]))\
AV_WN32A(&near_mv[++idx], mv);\
cnt[idx] += 1 + (n != 2);\
} else\
cnt[CNT_ZERO] += 1 + (n != 2);\
}\
}
MV_EDGE_CHECK(0)
MV_EDGE_CHECK(1)
MV_EDGE_CHECK(2)
mb->partitioning = VP8_SPLITMVMODE_NONE;
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
mb->mode = VP8_MVMODE_MV;
/* If we have three distinct MVs, merge first and last if they're the same */
if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
/* Swap near and nearest if necessary */
if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
}
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
/* Choose the best mv out of 0,0 and the nearest mv */
clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
(mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
(mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
mb->mode = VP8_MVMODE_SPLIT;
mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1];
} else {
mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
mb->bmv[0] = mb->mv;
}
} else {
clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]);
mb->bmv[0] = mb->mv;
}
} else {
clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST]);
mb->bmv[0] = mb->mv;
}
} else {
mb->mode = VP8_MVMODE_ZERO;
AV_ZERO32(&mb->mv);
mb->bmv[0] = mb->mv;
}
} | true | FFmpeg | 0f0b5d643401d4d83322eeee0e57eb5a226ef9ab | void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y)
{
VP8Macroblock *mb_edge[3] = { mb + 2 ,
mb - 1 ,
mb + 1 };
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
int idx = CNT_ZERO;
int cur_sign_bias = s->sign_bias[mb->ref_frame];
int8_t *sign_bias = s->sign_bias;
VP56mv near_mv[4];
uint8_t cnt[4] = { 0 };
VP56RangeCoder *c = &s->c;
AV_ZERO32(&near_mv[0]);
AV_ZERO32(&near_mv[1]);
#define MV_EDGE_CHECK(n)\
{\
VP8Macroblock *edge = mb_edge[n];\
int edge_ref = edge->ref_frame;\
if (edge_ref != VP56_FRAME_CURRENT) {\
uint32_t mv = AV_RN32A(&edge->mv);\
if (mv) {\
if (cur_sign_bias != sign_bias[edge_ref]) {\
\
mv = ~mv;\
mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
}\
if (!n || mv != AV_RN32A(&near_mv[idx]))\
AV_WN32A(&near_mv[++idx], mv);\
cnt[idx] += 1 + (n != 2);\
} else\
cnt[CNT_ZERO] += 1 + (n != 2);\
}\
}
MV_EDGE_CHECK(0)
MV_EDGE_CHECK(1)
MV_EDGE_CHECK(2)
mb->partitioning = VP8_SPLITMVMODE_NONE;
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
mb->mode = VP8_MVMODE_MV;
if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
}
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
(mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
(mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
mb->mode = VP8_MVMODE_SPLIT;
mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1];
} else {
mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
mb->bmv[0] = mb->mv;
}
} else {
clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]);
mb->bmv[0] = mb->mv;
}
} else {
clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST]);
mb->bmv[0] = mb->mv;
}
} else {
mb->mode = VP8_MVMODE_ZERO;
AV_ZERO32(&mb->mv);
mb->bmv[0] = mb->mv;
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(VP8Context *VAR_0, VP8Macroblock *VAR_1, int VAR_2, int VAR_3)
{
VP8Macroblock *mb_edge[3] = { VAR_1 + 2 ,
VAR_1 - 1 ,
VAR_1 + 1 };
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
int VAR_4 = CNT_ZERO;
int VAR_5 = VAR_0->sign_bias[VAR_1->ref_frame];
int8_t *sign_bias = VAR_0->sign_bias;
VP56mv near_mv[4];
uint8_t cnt[4] = { 0 };
VP56RangeCoder *c = &VAR_0->c;
AV_ZERO32(&near_mv[0]);
AV_ZERO32(&near_mv[1]);
#define MV_EDGE_CHECK(n)\
{\
VP8Macroblock *edge = mb_edge[n];\
int VAR_6 = edge->ref_frame;\
if (VAR_6 != VP56_FRAME_CURRENT) {\
uint32_t mv = AV_RN32A(&edge->mv);\
if (mv) {\
if (VAR_5 != sign_bias[VAR_6]) {\
\
mv = ~mv;\
mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
}\
if (!n || mv != AV_RN32A(&near_mv[VAR_4]))\
AV_WN32A(&near_mv[++VAR_4], mv);\
cnt[VAR_4] += 1 + (n != 2);\
} else\
cnt[CNT_ZERO] += 1 + (n != 2);\
}\
}
MV_EDGE_CHECK(0)
MV_EDGE_CHECK(1)
MV_EDGE_CHECK(2)
VAR_1->partitioning = VP8_SPLITMVMODE_NONE;
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
VAR_1->mode = VP8_MVMODE_MV;
if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
}
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
(mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
(mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
VAR_1->mode = VP8_MVMODE_SPLIT;
VAR_1->mv = VAR_1->bmv[decode_splitmvs(VAR_0, c, VAR_1) - 1];
} else {
VAR_1->mv.y += read_mv_component(c, VAR_0->prob->mvc[0]);
VAR_1->mv.x += read_mv_component(c, VAR_0->prob->mvc[1]);
VAR_1->bmv[0] = VAR_1->mv;
}
} else {
clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_NEAR]);
VAR_1->bmv[0] = VAR_1->mv;
}
} else {
clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_NEAREST]);
VAR_1->bmv[0] = VAR_1->mv;
}
} else {
VAR_1->mode = VP8_MVMODE_ZERO;
AV_ZERO32(&VAR_1->mv);
VAR_1->bmv[0] = VAR_1->mv;
}
} | [
"void FUNC_0(VP8Context *VAR_0, VP8Macroblock *VAR_1, int VAR_2, int VAR_3)\n{",
"VP8Macroblock *mb_edge[3] = { VAR_1 + 2 ,",
"VAR_1 - 1 ,\nVAR_1 + 1 };",
"enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };",
"enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };",
"int VAR_4 = CNT_ZERO;",
"int VAR_5 = VAR_0->sign_bias[VAR_1->ref_frame];",
"int8_t *sign_bias = VAR_0->sign_bias;",
"VP56mv near_mv[4];",
"uint8_t cnt[4] = { 0 };",
"VP56RangeCoder *c = &VAR_0->c;",
"AV_ZERO32(&near_mv[0]);",
"AV_ZERO32(&near_mv[1]);",
"#define MV_EDGE_CHECK(n)\\\n{\\",
"VP8Macroblock *edge = mb_edge[n];\\",
"int VAR_6 = edge->ref_frame;\\",
"if (VAR_6 != VP56_FRAME_CURRENT) {\\",
"uint32_t mv = AV_RN32A(&edge->mv);\\",
"if (mv) {\\",
"if (VAR_5 != sign_bias[VAR_6]) {\\",
"\\\nmv = ~mv;\\",
"mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\\",
"}\\",
"if (!n || mv != AV_RN32A(&near_mv[VAR_4]))\\\nAV_WN32A(&near_mv[++VAR_4], mv);\\",
"cnt[VAR_4] += 1 + (n != 2);\\",
"} else\\",
"cnt[CNT_ZERO] += 1 + (n != 2);\\",
"}\\",
"}",
"MV_EDGE_CHECK(0)\nMV_EDGE_CHECK(1)\nMV_EDGE_CHECK(2)\nVAR_1->partitioning = VP8_SPLITMVMODE_NONE;",
"if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {",
"VAR_1->mode = VP8_MVMODE_MV;",
"if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))\ncnt[CNT_NEAREST] += 1;",
"if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {",
"FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);",
"FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);",
"}",
"if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {",
"if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {",
"clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);",
"cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +\n(mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +\n(mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);",
"if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {",
"VAR_1->mode = VP8_MVMODE_SPLIT;",
"VAR_1->mv = VAR_1->bmv[decode_splitmvs(VAR_0, c, VAR_1) - 1];",
"} else {",
"VAR_1->mv.y += read_mv_component(c, VAR_0->prob->mvc[0]);",
"VAR_1->mv.x += read_mv_component(c, VAR_0->prob->mvc[1]);",
"VAR_1->bmv[0] = VAR_1->mv;",
"}",
"} else {",
"clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_NEAR]);",
"VAR_1->bmv[0] = VAR_1->mv;",
"}",
"} else {",
"clamp_mv(VAR_0, &VAR_1->mv, &near_mv[CNT_NEAREST]);",
"VAR_1->bmv[0] = VAR_1->mv;",
"}",
"} else {",
"VAR_1->mode = VP8_MVMODE_ZERO;",
"AV_ZERO32(&VAR_1->mv);",
"VAR_1->bmv[0] = VAR_1->mv;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
38,
40
],
[
42
],
[
44
],
[
46
],
[
48
],
[
50
],
[
52
],
[
54,
56
],
[
58
],
[
60
],
[
62,
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
74
],
[
78,
80,
82,
86
],
[
88
],
[
90
],
[
96,
98
],
[
104
],
[
106
],
[
108
],
[
110
],
[
114
],
[
116
],
[
122
],
[
124,
126,
128
],
[
132
],
[
134
],
[
136
],
[
138
],
[
140
],
[
142
],
[
144
],
[
146
],
[
148
],
[
150
],
[
152
],
[
154
],
[
156
],
[
158
],
[
160
],
[
162
],
[
164
],
[
166
],
[
168
],
[
170
],
[
172
],
[
174
]
] |
21,937 | static int check_output_constraints(InputStream *ist, OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
int ist_index = input_files[ist->file_index]->ist_index + ist->st->index;
if (ost->source_index != ist_index)
return 0;
if (of->start_time && ist->pts < of->start_time)
return 0;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){ 1, 1000000 }) >= 0) {
ost->is_past_recording_time = 1;
return 0;
}
return 1;
}
| false | FFmpeg | 2fc354f90d61f5f1bb75dbdd808a502dec69cf99 | static int check_output_constraints(InputStream *ist, OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
int ist_index = input_files[ist->file_index]->ist_index + ist->st->index;
if (ost->source_index != ist_index)
return 0;
if (of->start_time && ist->pts < of->start_time)
return 0;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){ 1, 1000000 }) >= 0) {
ost->is_past_recording_time = 1;
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(InputStream *VAR_0, OutputStream *VAR_1)
{
OutputFile *of = output_files[VAR_1->file_index];
int VAR_2 = input_files[VAR_0->file_index]->VAR_2 + VAR_0->st->index;
if (VAR_1->source_index != VAR_2)
return 0;
if (of->start_time && VAR_0->pts < of->start_time)
return 0;
if (of->recording_time != INT64_MAX &&
av_compare_ts(VAR_0->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
(AVRational){ 1, 1000000 }) >= 0) {
VAR_1->is_past_recording_time = 1;
return 0;
}
return 1;
}
| [
"static int FUNC_0(InputStream *VAR_0, OutputStream *VAR_1)\n{",
"OutputFile *of = output_files[VAR_1->file_index];",
"int VAR_2 = input_files[VAR_0->file_index]->VAR_2 + VAR_0->st->index;",
"if (VAR_1->source_index != VAR_2)\nreturn 0;",
"if (of->start_time && VAR_0->pts < of->start_time)\nreturn 0;",
"if (of->recording_time != INT64_MAX &&\nav_compare_ts(VAR_0->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,\n(AVRational){ 1, 1000000 }) >= 0) {",
"VAR_1->is_past_recording_time = 1;",
"return 0;",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17,
19
],
[
23,
25,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
]
] |
21,939 | CPUState *mon_get_cpu(void)
{
if (!cur_mon->mon_cpu) {
monitor_set_cpu(0);
}
cpu_synchronize_state(cur_mon->mon_cpu);
return cur_mon->mon_cpu;
}
| true | qemu | 27a83f8e7ed63ced7e36c47a42f46ab44ee02bd8 | CPUState *mon_get_cpu(void)
{
if (!cur_mon->mon_cpu) {
monitor_set_cpu(0);
}
cpu_synchronize_state(cur_mon->mon_cpu);
return cur_mon->mon_cpu;
}
| {
"code": [
" monitor_set_cpu(0);"
],
"line_no": [
7
]
} | CPUState *FUNC_0(void)
{
if (!cur_mon->mon_cpu) {
monitor_set_cpu(0);
}
cpu_synchronize_state(cur_mon->mon_cpu);
return cur_mon->mon_cpu;
}
| [
"CPUState *FUNC_0(void)\n{",
"if (!cur_mon->mon_cpu) {",
"monitor_set_cpu(0);",
"}",
"cpu_synchronize_state(cur_mon->mon_cpu);",
"return cur_mon->mon_cpu;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
21,940 | static int vc1_decode_p_mb_intfr(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp = 0; /* cbp decoding stuff */
int mqdiff, mquant; /* MB quantization */
int ttmb = v->ttfrm; /* MB Transform type */
int mb_has_coeffs = 1; /* last_flag */
int dmv_x, dmv_y; /* Differential MV components */
int val; /* temp value */
int first_block = 1;
int dst_idx, off;
int skipped, fourmv = 0, twomv = 0;
int block_cbp = 0, pat, block_tt = 0;
int idx_mbmode = 0, mvbp;
int stride_y, fieldtx;
mquant = v->pq; /* Loosy initialization */
if (v->skip_is_raw)
skipped = get_bits1(gb);
else
skipped = v->s.mbskip_table[mb_pos];
if (!skipped) {
if (v->fourmvswitch)
idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
else
idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {
/* store the motion vector type in a flag (useful later) */
case MV_PMODE_INTFR_4MV:
fourmv = 1;
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
break;
case MV_PMODE_INTFR_4MV_FIELD:
fourmv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_2MV_FIELD:
twomv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_1MV:
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
break;
}
if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB
s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
s->mb_intra = v->is_intra[s->mb_x] = 1;
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 1;
fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = get_bits1(gb);
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
GET_MQUANT();
s->current_picture.f.qscale_table[mb_pos] = mquant;
/* Set DC scale - y and c use the same (not sure if necessary here) */
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
dst_idx = 0;
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
v->mb_type[0][s->block_index[i]] = s->mb_intra;
v->a_avail = v->c_avail = 0;
if (i == 2 || i == 3 || !s->first_slice_line)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
if (i < 4) {
stride_y = s->linesize << fieldtx;
off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
} else {
stride_y = s->uvlinesize;
off = 0;
}
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
//TODO: loop filter
}
} else { // inter MB
mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
} else {
if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)
|| (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {
v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
s->mb_intra = v->is_intra[s->mb_x] = 0;
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 0;
fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];
/* for all motion vector read MVDATA and motion compensate each block */
dst_idx = 0;
if (fourmv) {
mvbp = v->fourmvbp;
for (i = 0; i < 6; i++) {
if (i < 4) {
val = ((mvbp >> (3 - i)) & 1);
if (val) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, i, 0);
} else if (i == 4) {
vc1_mc_4mv_chroma4(v);
}
}
} else if (twomv) {
mvbp = v->twomvbp;
if (mvbp & 2) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, 0, 0);
vc1_mc_4mv_luma(v, 1, 0);
if (mvbp & 1) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, 2, 0);
vc1_mc_4mv_luma(v, 3, 0);
vc1_mc_4mv_chroma4(v);
} else {
mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
if (mvbp) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v, 0);
}
if (cbp)
GET_MQUANT(); // p. 227
s->current_picture.f.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
if (!fieldtx)
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
else
off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
if (val) {
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
(i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
block_cbp |= pat << (i << 2);
if (!v->ttmbf && ttmb < 8)
ttmb = -1;
first_block = 0;
}
}
}
} else { // skipped
s->mb_intra = v->is_intra[s->mb_x] = 0;
for (i = 0; i < 6; i++) {
v->mb_type[0][s->block_index[i]] = 0;
s->dc_val[0][s->block_index[i]] = 0;
}
s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP;
s->current_picture.f.qscale_table[mb_pos] = 0;
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v, 0);
}
if (s->mb_x == s->mb_width - 1)
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);
return 0;
} | true | FFmpeg | d51d6ae9c41310d62f4582c07c2fad26d41eeca6 | static int vc1_decode_p_mb_intfr(VC1Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
int i;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int cbp = 0;
int mqdiff, mquant;
int ttmb = v->ttfrm;
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int val;
int first_block = 1;
int dst_idx, off;
int skipped, fourmv = 0, twomv = 0;
int block_cbp = 0, pat, block_tt = 0;
int idx_mbmode = 0, mvbp;
int stride_y, fieldtx;
mquant = v->pq;
if (v->skip_is_raw)
skipped = get_bits1(gb);
else
skipped = v->s.mbskip_table[mb_pos];
if (!skipped) {
if (v->fourmvswitch)
idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2);
else
idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {
case MV_PMODE_INTFR_4MV:
fourmv = 1;
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
break;
case MV_PMODE_INTFR_4MV_FIELD:
fourmv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_2MV_FIELD:
twomv = 1;
v->blk_mv_type[s->block_index[0]] = 1;
v->blk_mv_type[s->block_index[1]] = 1;
v->blk_mv_type[s->block_index[2]] = 1;
v->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_1MV:
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
break;
}
if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) {
s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
s->mb_intra = v->is_intra[s->mb_x] = 1;
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 1;
fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
mb_has_coeffs = get_bits1(gb);
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
GET_MQUANT();
s->current_picture.f.qscale_table[mb_pos] = mquant;
s->y_dc_scale = s->y_dc_scale_table[mquant];
s->c_dc_scale = s->c_dc_scale_table[mquant];
dst_idx = 0;
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
v->mb_type[0][s->block_index[i]] = s->mb_intra;
v->a_avail = v->c_avail = 0;
if (i == 2 || i == 3 || !s->first_slice_line)
v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[0][s->block_index[i] - 1];
vc1_decode_intra_block(v, s->block[i], i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
if (i < 4) {
stride_y = s->linesize << fieldtx;
off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
} else {
stride_y = s->uvlinesize;
off = 0;
}
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
}
} else {
mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
if (mb_has_coeffs)
cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
} else {
if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)
|| (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {
v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
s->mb_intra = v->is_intra[s->mb_x] = 0;
for (i = 0; i < 6; i++)
v->mb_type[0][s->block_index[i]] = 0;
fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];
dst_idx = 0;
if (fourmv) {
mvbp = v->fourmvbp;
for (i = 0; i < 6; i++) {
if (i < 4) {
val = ((mvbp >> (3 - i)) & 1);
if (val) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, i, 0);
} else if (i == 4) {
vc1_mc_4mv_chroma4(v);
}
}
} else if (twomv) {
mvbp = v->twomvbp;
if (mvbp & 2) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, 0, 0);
vc1_mc_4mv_luma(v, 1, 0);
if (mvbp & 1) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_4mv_luma(v, 2, 0);
vc1_mc_4mv_luma(v, 3, 0);
vc1_mc_4mv_chroma4(v);
} else {
mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
if (mvbp) {
get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
}
vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v, 0);
}
if (cbp)
GET_MQUANT();
s->current_picture.f.qscale_table[mb_pos] = mquant;
if (!v->ttmbf && cbp)
ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
for (i = 0; i < 6; i++) {
s->dc_val[0][s->block_index[i]] = 0;
dst_idx += i >> 2;
val = ((cbp >> (5 - i)) & 1);
if (!fieldtx)
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
else
off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
if (val) {
pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
(i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
block_cbp |= pat << (i << 2);
if (!v->ttmbf && ttmb < 8)
ttmb = -1;
first_block = 0;
}
}
}
} else {
s->mb_intra = v->is_intra[s->mb_x] = 0;
for (i = 0; i < 6; i++) {
v->mb_type[0][s->block_index[i]] = 0;
s->dc_val[0][s->block_index[i]] = 0;
}
s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP;
s->current_picture.f.qscale_table[mb_pos] = 0;
v->blk_mv_type[s->block_index[0]] = 0;
v->blk_mv_type[s->block_index[1]] = 0;
v->blk_mv_type[s->block_index[2]] = 0;
v->blk_mv_type[s->block_index[3]] = 0;
vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
vc1_mc_1mv(v, 0);
}
if (s->mb_x == s->mb_width - 1)
memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(VC1Context *VAR_0)
{
MpegEncContext *s = &VAR_0->s;
GetBitContext *gb = &s->gb;
int VAR_1;
int VAR_2 = s->mb_x + s->mb_y * s->mb_stride;
int VAR_3 = 0;
int VAR_4, VAR_5;
int VAR_6 = VAR_0->ttfrm;
int VAR_7 = 1;
int VAR_8, VAR_9;
int VAR_10;
int VAR_11 = 1;
int VAR_12, VAR_13;
int VAR_14, VAR_15 = 0, VAR_16 = 0;
int VAR_17 = 0, VAR_18, VAR_19 = 0;
int VAR_20 = 0, VAR_21;
int VAR_22, VAR_23;
VAR_5 = VAR_0->pq;
if (VAR_0->skip_is_raw)
VAR_14 = get_bits1(gb);
else
VAR_14 = VAR_0->s.mbskip_table[VAR_2];
if (!VAR_14) {
if (VAR_0->fourmvswitch)
VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2);
else
VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
switch (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0]) {
case MV_PMODE_INTFR_4MV:
VAR_15 = 1;
VAR_0->blk_mv_type[s->block_index[0]] = 0;
VAR_0->blk_mv_type[s->block_index[1]] = 0;
VAR_0->blk_mv_type[s->block_index[2]] = 0;
VAR_0->blk_mv_type[s->block_index[3]] = 0;
break;
case MV_PMODE_INTFR_4MV_FIELD:
VAR_15 = 1;
VAR_0->blk_mv_type[s->block_index[0]] = 1;
VAR_0->blk_mv_type[s->block_index[1]] = 1;
VAR_0->blk_mv_type[s->block_index[2]] = 1;
VAR_0->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_2MV_FIELD:
VAR_16 = 1;
VAR_0->blk_mv_type[s->block_index[0]] = 1;
VAR_0->blk_mv_type[s->block_index[1]] = 1;
VAR_0->blk_mv_type[s->block_index[2]] = 1;
VAR_0->blk_mv_type[s->block_index[3]] = 1;
break;
case MV_PMODE_INTFR_1MV:
VAR_0->blk_mv_type[s->block_index[0]] = 0;
VAR_0->blk_mv_type[s->block_index[1]] = 0;
VAR_0->blk_mv_type[s->block_index[2]] = 0;
VAR_0->blk_mv_type[s->block_index[3]] = 0;
break;
}
if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_INTRA) {
s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
s->current_picture.f.mb_type[VAR_2] = MB_TYPE_INTRA;
s->mb_intra = VAR_0->is_intra[s->mb_x] = 1;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++)
VAR_0->mb_type[0][s->block_index[VAR_1]] = 1;
VAR_23 = VAR_0->fieldtx_plane[VAR_2] = get_bits1(gb);
VAR_7 = get_bits1(gb);
if (VAR_7)
VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
VAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_2] = get_bits1(gb);
GET_MQUANT();
s->current_picture.f.qscale_table[VAR_2] = VAR_5;
s->y_dc_scale = s->y_dc_scale_table[VAR_5];
s->c_dc_scale = s->c_dc_scale_table[VAR_5];
VAR_12 = 0;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {
s->dc_val[0][s->block_index[VAR_1]] = 0;
VAR_12 += VAR_1 >> 2;
VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);
VAR_0->mb_type[0][s->block_index[VAR_1]] = s->mb_intra;
VAR_0->a_avail = VAR_0->c_avail = 0;
if (VAR_1 == 2 || VAR_1 == 3 || !s->first_slice_line)
VAR_0->a_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - s->block_wrap[VAR_1]];
if (VAR_1 == 1 || VAR_1 == 3 || s->mb_x)
VAR_0->c_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - 1];
vc1_decode_intra_block(VAR_0, s->block[VAR_1], VAR_1, VAR_10, VAR_5,
(VAR_1 & 4) ? VAR_0->codingset2 : VAR_0->codingset);
if ((VAR_1>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
VAR_0->vc1dsp.vc1_inv_trans_8x8(s->block[VAR_1]);
if (VAR_1 < 4) {
VAR_22 = s->linesize << VAR_23;
VAR_13 = (VAR_23) ? ((VAR_1 & 1) * 8) + ((VAR_1 & 2) >> 1) * s->linesize : (VAR_1 & 1) * 8 + 4 * (VAR_1 & 2) * s->linesize;
} else {
VAR_22 = s->uvlinesize;
VAR_13 = 0;
}
s->dsp.put_signed_pixels_clamped(s->block[VAR_1], s->dest[VAR_12] + VAR_13, VAR_22);
}
} else {
VAR_7 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][3];
if (VAR_7)
VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_2MV_FIELD) {
VAR_0->twomvbp = get_vlc2(gb, VAR_0->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
} else {
if ((ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV)
|| (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV_FIELD)) {
VAR_0->fourmvbp = get_vlc2(gb, VAR_0->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
}
}
s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++)
VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;
VAR_23 = VAR_0->fieldtx_plane[VAR_2] = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][1];
VAR_12 = 0;
if (VAR_15) {
VAR_21 = VAR_0->fourmvbp;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {
if (VAR_1 < 4) {
VAR_10 = ((VAR_21 >> (3 - VAR_1)) & 1);
if (VAR_10) {
get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);
}
vc1_pred_mv_intfr(VAR_0, VAR_1, VAR_8, VAR_9, 0, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);
vc1_mc_4mv_luma(VAR_0, VAR_1, 0);
} else if (VAR_1 == 4) {
vc1_mc_4mv_chroma4(VAR_0);
}
}
} else if (VAR_16) {
VAR_21 = VAR_0->twomvbp;
if (VAR_21 & 2) {
get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);
}
vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);
vc1_mc_4mv_luma(VAR_0, 0, 0);
vc1_mc_4mv_luma(VAR_0, 1, 0);
if (VAR_21 & 1) {
get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);
}
vc1_pred_mv_intfr(VAR_0, 2, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);
vc1_mc_4mv_luma(VAR_0, 2, 0);
vc1_mc_4mv_luma(VAR_0, 3, 0);
vc1_mc_4mv_chroma4(VAR_0);
} else {
VAR_21 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][2];
if (VAR_21) {
get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);
}
vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);
vc1_mc_1mv(VAR_0, 0);
}
if (VAR_3)
GET_MQUANT();
s->current_picture.f.qscale_table[VAR_2] = VAR_5;
if (!VAR_0->ttmbf && VAR_3)
VAR_6 = get_vlc2(gb, ff_vc1_ttmb_vlc[VAR_0->tt_index].table, VC1_TTMB_VLC_BITS, 2);
for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {
s->dc_val[0][s->block_index[VAR_1]] = 0;
VAR_12 += VAR_1 >> 2;
VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);
if (!VAR_23)
VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + (VAR_1 & 2) * 4 * s->linesize);
else
VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + ((VAR_1 > 1) * s->linesize));
if (VAR_10) {
VAR_18 = vc1_decode_p_block(VAR_0, s->block[VAR_1], VAR_1, VAR_5, VAR_6,
VAR_11, s->dest[VAR_12] + VAR_13,
(VAR_1 & 4) ? s->uvlinesize : (s->linesize << VAR_23),
(VAR_1 & 4) && (s->flags & CODEC_FLAG_GRAY), &VAR_19);
VAR_17 |= VAR_18 << (VAR_1 << 2);
if (!VAR_0->ttmbf && VAR_6 < 8)
VAR_6 = -1;
VAR_11 = 0;
}
}
}
} else {
s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;
for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {
VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;
s->dc_val[0][s->block_index[VAR_1]] = 0;
}
s->current_picture.f.mb_type[VAR_2] = MB_TYPE_SKIP;
s->current_picture.f.qscale_table[VAR_2] = 0;
VAR_0->blk_mv_type[s->block_index[0]] = 0;
VAR_0->blk_mv_type[s->block_index[1]] = 0;
VAR_0->blk_mv_type[s->block_index[2]] = 0;
VAR_0->blk_mv_type[s->block_index[3]] = 0;
vc1_pred_mv_intfr(VAR_0, 0, 0, 0, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);
vc1_mc_1mv(VAR_0, 0);
}
if (s->mb_x == s->mb_width - 1)
memmove(VAR_0->is_intra_base, VAR_0->is_intra, sizeof(VAR_0->is_intra_base[0])*s->mb_stride);
return 0;
} | [
"static int FUNC_0(VC1Context *VAR_0)\n{",
"MpegEncContext *s = &VAR_0->s;",
"GetBitContext *gb = &s->gb;",
"int VAR_1;",
"int VAR_2 = s->mb_x + s->mb_y * s->mb_stride;",
"int VAR_3 = 0;",
"int VAR_4, VAR_5;",
"int VAR_6 = VAR_0->ttfrm;",
"int VAR_7 = 1;",
"int VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11 = 1;",
"int VAR_12, VAR_13;",
"int VAR_14, VAR_15 = 0, VAR_16 = 0;",
"int VAR_17 = 0, VAR_18, VAR_19 = 0;",
"int VAR_20 = 0, VAR_21;",
"int VAR_22, VAR_23;",
"VAR_5 = VAR_0->pq;",
"if (VAR_0->skip_is_raw)\nVAR_14 = get_bits1(gb);",
"else\nVAR_14 = VAR_0->s.mbskip_table[VAR_2];",
"if (!VAR_14) {",
"if (VAR_0->fourmvswitch)\nVAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2);",
"else\nVAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);",
"switch (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0]) {",
"case MV_PMODE_INTFR_4MV:\nVAR_15 = 1;",
"VAR_0->blk_mv_type[s->block_index[0]] = 0;",
"VAR_0->blk_mv_type[s->block_index[1]] = 0;",
"VAR_0->blk_mv_type[s->block_index[2]] = 0;",
"VAR_0->blk_mv_type[s->block_index[3]] = 0;",
"break;",
"case MV_PMODE_INTFR_4MV_FIELD:\nVAR_15 = 1;",
"VAR_0->blk_mv_type[s->block_index[0]] = 1;",
"VAR_0->blk_mv_type[s->block_index[1]] = 1;",
"VAR_0->blk_mv_type[s->block_index[2]] = 1;",
"VAR_0->blk_mv_type[s->block_index[3]] = 1;",
"break;",
"case MV_PMODE_INTFR_2MV_FIELD:\nVAR_16 = 1;",
"VAR_0->blk_mv_type[s->block_index[0]] = 1;",
"VAR_0->blk_mv_type[s->block_index[1]] = 1;",
"VAR_0->blk_mv_type[s->block_index[2]] = 1;",
"VAR_0->blk_mv_type[s->block_index[3]] = 1;",
"break;",
"case MV_PMODE_INTFR_1MV:\nVAR_0->blk_mv_type[s->block_index[0]] = 0;",
"VAR_0->blk_mv_type[s->block_index[1]] = 0;",
"VAR_0->blk_mv_type[s->block_index[2]] = 0;",
"VAR_0->blk_mv_type[s->block_index[3]] = 0;",
"break;",
"}",
"if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_INTRA) {",
"s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;",
"s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;",
"s->current_picture.f.mb_type[VAR_2] = MB_TYPE_INTRA;",
"s->mb_intra = VAR_0->is_intra[s->mb_x] = 1;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++)",
"VAR_0->mb_type[0][s->block_index[VAR_1]] = 1;",
"VAR_23 = VAR_0->fieldtx_plane[VAR_2] = get_bits1(gb);",
"VAR_7 = get_bits1(gb);",
"if (VAR_7)\nVAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);",
"VAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_2] = get_bits1(gb);",
"GET_MQUANT();",
"s->current_picture.f.qscale_table[VAR_2] = VAR_5;",
"s->y_dc_scale = s->y_dc_scale_table[VAR_5];",
"s->c_dc_scale = s->c_dc_scale_table[VAR_5];",
"VAR_12 = 0;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"s->dc_val[0][s->block_index[VAR_1]] = 0;",
"VAR_12 += VAR_1 >> 2;",
"VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);",
"VAR_0->mb_type[0][s->block_index[VAR_1]] = s->mb_intra;",
"VAR_0->a_avail = VAR_0->c_avail = 0;",
"if (VAR_1 == 2 || VAR_1 == 3 || !s->first_slice_line)\nVAR_0->a_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - s->block_wrap[VAR_1]];",
"if (VAR_1 == 1 || VAR_1 == 3 || s->mb_x)\nVAR_0->c_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - 1];",
"vc1_decode_intra_block(VAR_0, s->block[VAR_1], VAR_1, VAR_10, VAR_5,\n(VAR_1 & 4) ? VAR_0->codingset2 : VAR_0->codingset);",
"if ((VAR_1>3) && (s->flags & CODEC_FLAG_GRAY)) continue;",
"VAR_0->vc1dsp.vc1_inv_trans_8x8(s->block[VAR_1]);",
"if (VAR_1 < 4) {",
"VAR_22 = s->linesize << VAR_23;",
"VAR_13 = (VAR_23) ? ((VAR_1 & 1) * 8) + ((VAR_1 & 2) >> 1) * s->linesize : (VAR_1 & 1) * 8 + 4 * (VAR_1 & 2) * s->linesize;",
"} else {",
"VAR_22 = s->uvlinesize;",
"VAR_13 = 0;",
"}",
"s->dsp.put_signed_pixels_clamped(s->block[VAR_1], s->dest[VAR_12] + VAR_13, VAR_22);",
"}",
"} else {",
"VAR_7 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][3];",
"if (VAR_7)\nVAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);",
"if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_2MV_FIELD) {",
"VAR_0->twomvbp = get_vlc2(gb, VAR_0->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);",
"} else {",
"if ((ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV)\n|| (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV_FIELD)) {",
"VAR_0->fourmvbp = get_vlc2(gb, VAR_0->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);",
"}",
"}",
"s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++)",
"VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;",
"VAR_23 = VAR_0->fieldtx_plane[VAR_2] = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][1];",
"VAR_12 = 0;",
"if (VAR_15) {",
"VAR_21 = VAR_0->fourmvbp;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"if (VAR_1 < 4) {",
"VAR_10 = ((VAR_21 >> (3 - VAR_1)) & 1);",
"if (VAR_10) {",
"get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);",
"}",
"vc1_pred_mv_intfr(VAR_0, VAR_1, VAR_8, VAR_9, 0, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);",
"vc1_mc_4mv_luma(VAR_0, VAR_1, 0);",
"} else if (VAR_1 == 4) {",
"vc1_mc_4mv_chroma4(VAR_0);",
"}",
"}",
"} else if (VAR_16) {",
"VAR_21 = VAR_0->twomvbp;",
"if (VAR_21 & 2) {",
"get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);",
"}",
"vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);",
"vc1_mc_4mv_luma(VAR_0, 0, 0);",
"vc1_mc_4mv_luma(VAR_0, 1, 0);",
"if (VAR_21 & 1) {",
"get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);",
"}",
"vc1_pred_mv_intfr(VAR_0, 2, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);",
"vc1_mc_4mv_luma(VAR_0, 2, 0);",
"vc1_mc_4mv_luma(VAR_0, 3, 0);",
"vc1_mc_4mv_chroma4(VAR_0);",
"} else {",
"VAR_21 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][2];",
"if (VAR_21) {",
"get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);",
"}",
"vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);",
"vc1_mc_1mv(VAR_0, 0);",
"}",
"if (VAR_3)\nGET_MQUANT();",
"s->current_picture.f.qscale_table[VAR_2] = VAR_5;",
"if (!VAR_0->ttmbf && VAR_3)\nVAR_6 = get_vlc2(gb, ff_vc1_ttmb_vlc[VAR_0->tt_index].table, VC1_TTMB_VLC_BITS, 2);",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"s->dc_val[0][s->block_index[VAR_1]] = 0;",
"VAR_12 += VAR_1 >> 2;",
"VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);",
"if (!VAR_23)\nVAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + (VAR_1 & 2) * 4 * s->linesize);",
"else\nVAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + ((VAR_1 > 1) * s->linesize));",
"if (VAR_10) {",
"VAR_18 = vc1_decode_p_block(VAR_0, s->block[VAR_1], VAR_1, VAR_5, VAR_6,\nVAR_11, s->dest[VAR_12] + VAR_13,\n(VAR_1 & 4) ? s->uvlinesize : (s->linesize << VAR_23),\n(VAR_1 & 4) && (s->flags & CODEC_FLAG_GRAY), &VAR_19);",
"VAR_17 |= VAR_18 << (VAR_1 << 2);",
"if (!VAR_0->ttmbf && VAR_6 < 8)\nVAR_6 = -1;",
"VAR_11 = 0;",
"}",
"}",
"}",
"} else {",
"s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;",
"for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {",
"VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;",
"s->dc_val[0][s->block_index[VAR_1]] = 0;",
"}",
"s->current_picture.f.mb_type[VAR_2] = MB_TYPE_SKIP;",
"s->current_picture.f.qscale_table[VAR_2] = 0;",
"VAR_0->blk_mv_type[s->block_index[0]] = 0;",
"VAR_0->blk_mv_type[s->block_index[1]] = 0;",
"VAR_0->blk_mv_type[s->block_index[2]] = 0;",
"VAR_0->blk_mv_type[s->block_index[3]] = 0;",
"vc1_pred_mv_intfr(VAR_0, 0, 0, 0, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);",
"vc1_mc_1mv(VAR_0, 0);",
"}",
"if (s->mb_x == s->mb_width - 1)\nmemmove(VAR_0->is_intra_base, VAR_0->is_intra, sizeof(VAR_0->is_intra_base[0])*s->mb_stride);",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
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
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175,
177
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
256
],
[
258
],
[
260
],
[
262
],
[
264
],
[
266
],
[
268
],
[
270
],
[
272
],
[
274
],
[
276
],
[
278
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
294
],
[
296
],
[
298
],
[
300
],
[
302
],
[
304
],
[
306
],
[
308
],
[
310
],
[
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
]
] |
21,941 | ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
{
NE2000State *s = qemu_get_nic_opaque(nc);
int size = size_;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return -1;
/* XXX: check this */
if (s->rxcr & 0x10) {
/* promiscuous: receive all */
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
/* broadcast address */
if (!(s->rxcr & 0x04))
return size;
} else if (buf[0] & 0x01) {
/* multicast */
if (!(s->rxcr & 0x08))
return size;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return size;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
/* match */
} else {
return size;
}
}
/* if too small buffer, then expand it */
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
if (index >= NE2000_PMEM_END) {
index = s->start;
}
/* 4 bytes for header */
total_len = size + 4;
/* address for next packet (4 bytes for CRC) */
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
/* prepare packet header */
p = s->mem + index;
s->rsr = ENRSR_RXOK; /* receive status */
/* XXX: check this */
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
/* write packet data */
while (size > 0) {
if (index <= s->stop)
avail = s->stop - index;
else
avail = 0;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
/* now we can signal we have received something */
s->isr |= ENISR_RX;
ne2000_update_irq(s);
return size_;
}
| true | qemu | 737d2b3c41d59eb8f94ab7eb419b957938f24943 | ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
{
NE2000State *s = qemu_get_nic_opaque(nc);
int size = size_;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received len=%d\n", size);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return -1;
if (s->rxcr & 0x10) {
} else {
if (!memcmp(buf, broadcast_macaddr, 6)) {
if (!(s->rxcr & 0x04))
return size;
} else if (buf[0] & 0x01) {
if (!(s->rxcr & 0x08))
return size;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
return size;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
} else {
return size;
}
}
if (size < MIN_BUF_SIZE) {
memcpy(buf1, buf, size);
memset(buf1 + size, 0, MIN_BUF_SIZE - size);
buf = buf1;
size = MIN_BUF_SIZE;
}
index = s->curpag << 8;
if (index >= NE2000_PMEM_END) {
index = s->start;
}
total_len = size + 4;
next = index + ((total_len + 4 + 255) & ~0xff);
if (next >= s->stop)
next -= (s->stop - s->start);
p = s->mem + index;
s->rsr = ENRSR_RXOK;
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = next >> 8;
p[2] = total_len;
p[3] = total_len >> 8;
index += 4;
while (size > 0) {
if (index <= s->stop)
avail = s->stop - index;
else
avail = 0;
len = size;
if (len > avail)
len = avail;
memcpy(s->mem + index, buf, len);
buf += len;
index += len;
if (index == s->stop)
index = s->start;
size -= len;
}
s->curpag = next >> 8;
s->isr |= ENISR_RX;
ne2000_update_irq(s);
return size_;
}
| {
"code": [
" avail = 0;"
],
"line_no": [
161
]
} | ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size_)
{
NE2000State *s = qemu_get_nic_opaque(nc);
int VAR_0 = size_;
uint8_t *p;
unsigned int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
uint8_t buf1[60];
static const uint8_t VAR_7[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#if defined(DEBUG_NE2000)
printf("NE2000: received VAR_4=%d\n", VAR_0);
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
return -1;
if (s->rxcr & 0x10) {
} else {
if (!memcmp(buf, VAR_7, 6)) {
if (!(s->rxcr & 0x04))
return VAR_0;
} else if (buf[0] & 0x01) {
if (!(s->rxcr & 0x08))
return VAR_0;
VAR_6 = compute_mcast_idx(buf);
if (!(s->mult[VAR_6 >> 3] & (1 << (VAR_6 & 7))))
return VAR_0;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
s->mem[6] == buf[3] &&
s->mem[8] == buf[4] &&
s->mem[10] == buf[5]) {
} else {
return VAR_0;
}
}
if (VAR_0 < MIN_BUF_SIZE) {
memcpy(buf1, buf, VAR_0);
memset(buf1 + VAR_0, 0, MIN_BUF_SIZE - VAR_0);
buf = buf1;
VAR_0 = MIN_BUF_SIZE;
}
VAR_5 = s->curpag << 8;
if (VAR_5 >= NE2000_PMEM_END) {
VAR_5 = s->start;
}
VAR_1 = VAR_0 + 4;
VAR_2 = VAR_5 + ((VAR_1 + 4 + 255) & ~0xff);
if (VAR_2 >= s->stop)
VAR_2 -= (s->stop - s->start);
p = s->mem + VAR_5;
s->rsr = ENRSR_RXOK;
if (buf[0] & 0x01)
s->rsr |= ENRSR_PHY;
p[0] = s->rsr;
p[1] = VAR_2 >> 8;
p[2] = VAR_1;
p[3] = VAR_1 >> 8;
VAR_5 += 4;
while (VAR_0 > 0) {
if (VAR_5 <= s->stop)
VAR_3 = s->stop - VAR_5;
else
VAR_3 = 0;
VAR_4 = VAR_0;
if (VAR_4 > VAR_3)
VAR_4 = VAR_3;
memcpy(s->mem + VAR_5, buf, VAR_4);
buf += VAR_4;
VAR_5 += VAR_4;
if (VAR_5 == s->stop)
VAR_5 = s->start;
VAR_0 -= VAR_4;
}
s->curpag = VAR_2 >> 8;
s->isr |= ENISR_RX;
ne2000_update_irq(s);
return size_;
}
| [
"ssize_t FUNC_0(NetClientState *nc, const uint8_t *buf, size_t size_)\n{",
"NE2000State *s = qemu_get_nic_opaque(nc);",
"int VAR_0 = size_;",
"uint8_t *p;",
"unsigned int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"uint8_t buf1[60];",
"static const uint8_t VAR_7[6] =\n{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };",
"#if defined(DEBUG_NE2000)\nprintf(\"NE2000: received VAR_4=%d\\n\", VAR_0);",
"#endif\nif (s->cmd & E8390_STOP || ne2000_buffer_full(s))\nreturn -1;",
"if (s->rxcr & 0x10) {",
"} else {",
"if (!memcmp(buf, VAR_7, 6)) {",
"if (!(s->rxcr & 0x04))\nreturn VAR_0;",
"} else if (buf[0] & 0x01) {",
"if (!(s->rxcr & 0x08))\nreturn VAR_0;",
"VAR_6 = compute_mcast_idx(buf);",
"if (!(s->mult[VAR_6 >> 3] & (1 << (VAR_6 & 7))))\nreturn VAR_0;",
"} else if (s->mem[0] == buf[0] &&",
"s->mem[2] == buf[1] &&\ns->mem[4] == buf[2] &&\ns->mem[6] == buf[3] &&\ns->mem[8] == buf[4] &&\ns->mem[10] == buf[5]) {",
"} else {",
"return VAR_0;",
"}",
"}",
"if (VAR_0 < MIN_BUF_SIZE) {",
"memcpy(buf1, buf, VAR_0);",
"memset(buf1 + VAR_0, 0, MIN_BUF_SIZE - VAR_0);",
"buf = buf1;",
"VAR_0 = MIN_BUF_SIZE;",
"}",
"VAR_5 = s->curpag << 8;",
"if (VAR_5 >= NE2000_PMEM_END) {",
"VAR_5 = s->start;",
"}",
"VAR_1 = VAR_0 + 4;",
"VAR_2 = VAR_5 + ((VAR_1 + 4 + 255) & ~0xff);",
"if (VAR_2 >= s->stop)\nVAR_2 -= (s->stop - s->start);",
"p = s->mem + VAR_5;",
"s->rsr = ENRSR_RXOK;",
"if (buf[0] & 0x01)\ns->rsr |= ENRSR_PHY;",
"p[0] = s->rsr;",
"p[1] = VAR_2 >> 8;",
"p[2] = VAR_1;",
"p[3] = VAR_1 >> 8;",
"VAR_5 += 4;",
"while (VAR_0 > 0) {",
"if (VAR_5 <= s->stop)\nVAR_3 = s->stop - VAR_5;",
"else\nVAR_3 = 0;",
"VAR_4 = VAR_0;",
"if (VAR_4 > VAR_3)\nVAR_4 = VAR_3;",
"memcpy(s->mem + VAR_5, buf, VAR_4);",
"buf += VAR_4;",
"VAR_5 += VAR_4;",
"if (VAR_5 == s->stop)\nVAR_5 = s->start;",
"VAR_0 -= VAR_4;",
"}",
"s->curpag = VAR_2 >> 8;",
"s->isr |= ENISR_RX;",
"ne2000_update_irq(s);",
"return size_;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
21,
23
],
[
25,
29,
31
],
[
37
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69,
71,
73,
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123,
125
],
[
129
],
[
131
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
189
],
[
191
],
[
195
],
[
197
]
] |
21,942 | static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
int i, ret;
if ((ret = ff_huffyuv_alloc_temp(s)) < 0) {
ff_huffyuv_common_end(s);
return ret;
}
for (i = 0; i < 8; i++)
s->vlc[i].table = NULL;
if (s->version >= 2) {
if ((ret = read_huffman_tables(s, avctx->extradata + 4,
avctx->extradata_size)) < 0)
return ret;
} else {
if ((ret = read_old_huffman_tables(s)) < 0)
return ret;
}
return 0;
} | true | FFmpeg | 7c7e7c44a6eb68eca861e45cb2ce78f582b12c69 | static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
int i, ret;
if ((ret = ff_huffyuv_alloc_temp(s)) < 0) {
ff_huffyuv_common_end(s);
return ret;
}
for (i = 0; i < 8; i++)
s->vlc[i].table = NULL;
if (s->version >= 2) {
if ((ret = read_huffman_tables(s, avctx->extradata + 4,
avctx->extradata_size)) < 0)
return ret;
} else {
if ((ret = read_old_huffman_tables(s)) < 0)
return ret;
}
return 0;
} | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
int VAR_0, VAR_1;
if ((VAR_1 = ff_huffyuv_alloc_temp(s)) < 0) {
ff_huffyuv_common_end(s);
return VAR_1;
}
for (VAR_0 = 0; VAR_0 < 8; VAR_0++)
s->vlc[VAR_0].table = NULL;
if (s->version >= 2) {
if ((VAR_1 = read_huffman_tables(s, avctx->extradata + 4,
avctx->extradata_size)) < 0)
return VAR_1;
} else {
if ((VAR_1 = read_old_huffman_tables(s)) < 0)
return VAR_1;
}
return 0;
} | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"HYuvContext *s = avctx->priv_data;",
"int VAR_0, VAR_1;",
"if ((VAR_1 = ff_huffyuv_alloc_temp(s)) < 0) {",
"ff_huffyuv_common_end(s);",
"return VAR_1;",
"}",
"for (VAR_0 = 0; VAR_0 < 8; VAR_0++)",
"s->vlc[VAR_0].table = NULL;",
"if (s->version >= 2) {",
"if ((VAR_1 = read_huffman_tables(s, avctx->extradata + 4,\navctx->extradata_size)) < 0)\nreturn VAR_1;",
"} else {",
"if ((VAR_1 = read_old_huffman_tables(s)) < 0)\nreturn VAR_1;",
"}",
"return 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,943 | static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
char buffer[] = "xxxx:xx:xx.x";
char *p = buffer;
int rc = 0;
rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
addr->domain, addr->bus, addr->slot, addr->function);
assert(rc == sizeof(buffer) - 1);
visit_type_str(v, name, &p, errp);
}
| true | qemu | 00b8702581f312aa46f797a8b3153d9b2892d967 | static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
char buffer[] = "xxxx:xx:xx.x";
char *p = buffer;
int rc = 0;
rc = snprintf(buffer, sizeof(buffer), "%04x:%02x:%02x.%d",
addr->domain, addr->bus, addr->slot, addr->function);
assert(rc == sizeof(buffer) - 1);
visit_type_str(v, name, &p, errp);
}
| {
"code": [
" char buffer[] = \"xxxx:xx:xx.x\";",
" rc = snprintf(buffer, sizeof(buffer), \"%04x:%02x:%02x.%d\",",
" addr->domain, addr->bus, addr->slot, addr->function);",
" assert(rc == sizeof(buffer) - 1);"
],
"line_no": [
13,
21,
23,
25
]
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,
void *VAR_3, Error **VAR_4)
{
DeviceState *dev = DEVICE(VAR_0);
Property *prop = VAR_3;
PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);
char VAR_5[] = "xxxx:xx:xx.x";
char *VAR_6 = VAR_5;
int VAR_7 = 0;
VAR_7 = snprintf(VAR_5, sizeof(VAR_5), "%04x:%02x:%02x.%d",
addr->domain, addr->bus, addr->slot, addr->function);
assert(VAR_7 == sizeof(VAR_5) - 1);
visit_type_str(VAR_1, VAR_2, &VAR_6, VAR_4);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, const char *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"DeviceState *dev = DEVICE(VAR_0);",
"Property *prop = VAR_3;",
"PCIHostDeviceAddress *addr = qdev_get_prop_ptr(dev, prop);",
"char VAR_5[] = \"xxxx:xx:xx.x\";",
"char *VAR_6 = VAR_5;",
"int VAR_7 = 0;",
"VAR_7 = snprintf(VAR_5, sizeof(VAR_5), \"%04x:%02x:%02x.%d\",\naddr->domain, addr->bus, addr->slot, addr->function);",
"assert(VAR_7 == sizeof(VAR_5) - 1);",
"visit_type_str(VAR_1, VAR_2, &VAR_6, VAR_4);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
29
],
[
31
]
] |
21,944 | static int cin_probe(AVProbeData *p)
{
if (p->buf_size < 18)
return 0;
/* header starts with this special marker */
if (AV_RL32(&p->buf[0]) != 0x55AA0000)
return 0;
/* for accuracy, check some header field values */
if (AV_RL32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
return 0;
return AVPROBE_SCORE_MAX;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int cin_probe(AVProbeData *p)
{
if (p->buf_size < 18)
return 0;
if (AV_RL32(&p->buf[0]) != 0x55AA0000)
return 0;
if (AV_RL32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
return 0;
return AVPROBE_SCORE_MAX;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
if (VAR_0->buf_size < 18)
return 0;
if (AV_RL32(&VAR_0->buf[0]) != 0x55AA0000)
return 0;
if (AV_RL32(&VAR_0->buf[12]) != 22050 || VAR_0->buf[16] != 16 || VAR_0->buf[17] != 0)
return 0;
return AVPROBE_SCORE_MAX;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"if (VAR_0->buf_size < 18)\nreturn 0;",
"if (AV_RL32(&VAR_0->buf[0]) != 0x55AA0000)\nreturn 0;",
"if (AV_RL32(&VAR_0->buf[12]) != 22050 || VAR_0->buf[16] != 16 || VAR_0->buf[17] != 0)\nreturn 0;",
"return AVPROBE_SCORE_MAX;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
13,
15
],
[
21,
23
],
[
27
],
[
29
]
] |
21,945 | static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options)
{
AVCodec *codec;
int got_picture = 1, ret = 0;
AVFrame picture;
AVPacket pkt = *avpkt;
if(!st->codec->codec){
AVDictionary *thread_opt = NULL;
codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec)
return -1;
/* force thread count to 1 since the h264 decoder will not extract SPS
* and PPS to extradata during multi-threaded decoding */
av_dict_set(options ? options : &thread_opt, "threads", "1", 0);
ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt);
if (!options)
av_dict_free(&thread_opt);
if (ret < 0)
return ret;
}
while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
ret >= 0 &&
(!has_codec_parameters(st->codec) ||
!has_decode_delay_been_guessed(st) ||
(!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) {
got_picture = 0;
avcodec_get_frame_defaults(&picture);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->codec, &picture,
&got_picture, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt);
break;
default:
break;
}
if (ret >= 0) {
if (got_picture)
st->info->nb_decoded_frames++;
pkt.data += ret;
pkt.size -= ret;
ret = got_picture;
}
}
return ret;
}
| false | FFmpeg | af08d9aeea870de017139f7b1c44b7d816cf8e56 | static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options)
{
AVCodec *codec;
int got_picture = 1, ret = 0;
AVFrame picture;
AVPacket pkt = *avpkt;
if(!st->codec->codec){
AVDictionary *thread_opt = NULL;
codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec)
return -1;
av_dict_set(options ? options : &thread_opt, "threads", "1", 0);
ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt);
if (!options)
av_dict_free(&thread_opt);
if (ret < 0)
return ret;
}
while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
ret >= 0 &&
(!has_codec_parameters(st->codec) ||
!has_decode_delay_been_guessed(st) ||
(!st->codec_info_nb_frames && st->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) {
got_picture = 0;
avcodec_get_frame_defaults(&picture);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(st->codec, &picture,
&got_picture, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
ret = avcodec_decode_audio4(st->codec, &picture, &got_picture, &pkt);
break;
default:
break;
}
if (ret >= 0) {
if (got_picture)
st->info->nb_decoded_frames++;
pkt.data += ret;
pkt.size -= ret;
ret = got_picture;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVStream *VAR_0, AVPacket *VAR_1, AVDictionary **VAR_2)
{
AVCodec *codec;
int VAR_3 = 1, VAR_4 = 0;
AVFrame picture;
AVPacket pkt = *VAR_1;
if(!VAR_0->codec->codec){
AVDictionary *thread_opt = NULL;
codec = avcodec_find_decoder(VAR_0->codec->codec_id);
if (!codec)
return -1;
av_dict_set(VAR_2 ? VAR_2 : &thread_opt, "threads", "1", 0);
VAR_4 = avcodec_open2(VAR_0->codec, codec, VAR_2 ? VAR_2 : &thread_opt);
if (!VAR_2)
av_dict_free(&thread_opt);
if (VAR_4 < 0)
return VAR_4;
}
while ((pkt.size > 0 || (!pkt.data && VAR_3)) &&
VAR_4 >= 0 &&
(!has_codec_parameters(VAR_0->codec) ||
!has_decode_delay_been_guessed(VAR_0) ||
(!VAR_0->codec_info_nb_frames && VAR_0->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) {
VAR_3 = 0;
avcodec_get_frame_defaults(&picture);
switch(VAR_0->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
VAR_4 = avcodec_decode_video2(VAR_0->codec, &picture,
&VAR_3, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
VAR_4 = avcodec_decode_audio4(VAR_0->codec, &picture, &VAR_3, &pkt);
break;
default:
break;
}
if (VAR_4 >= 0) {
if (VAR_3)
VAR_0->info->nb_decoded_frames++;
pkt.data += VAR_4;
pkt.size -= VAR_4;
VAR_4 = VAR_3;
}
}
return VAR_4;
}
| [
"static int FUNC_0(AVStream *VAR_0, AVPacket *VAR_1, AVDictionary **VAR_2)\n{",
"AVCodec *codec;",
"int VAR_3 = 1, VAR_4 = 0;",
"AVFrame picture;",
"AVPacket pkt = *VAR_1;",
"if(!VAR_0->codec->codec){",
"AVDictionary *thread_opt = NULL;",
"codec = avcodec_find_decoder(VAR_0->codec->codec_id);",
"if (!codec)\nreturn -1;",
"av_dict_set(VAR_2 ? VAR_2 : &thread_opt, \"threads\", \"1\", 0);",
"VAR_4 = avcodec_open2(VAR_0->codec, codec, VAR_2 ? VAR_2 : &thread_opt);",
"if (!VAR_2)\nav_dict_free(&thread_opt);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"}",
"while ((pkt.size > 0 || (!pkt.data && VAR_3)) &&\nVAR_4 >= 0 &&\n(!has_codec_parameters(VAR_0->codec) ||\n!has_decode_delay_been_guessed(VAR_0) ||\n(!VAR_0->codec_info_nb_frames && VAR_0->codec->codec->capabilities & CODEC_CAP_CHANNEL_CONF))) {",
"VAR_3 = 0;",
"avcodec_get_frame_defaults(&picture);",
"switch(VAR_0->codec->codec_type) {",
"case AVMEDIA_TYPE_VIDEO:\nVAR_4 = avcodec_decode_video2(VAR_0->codec, &picture,\n&VAR_3, &pkt);",
"break;",
"case AVMEDIA_TYPE_AUDIO:\nVAR_4 = avcodec_decode_audio4(VAR_0->codec, &picture, &VAR_3, &pkt);",
"break;",
"default:\nbreak;",
"}",
"if (VAR_4 >= 0) {",
"if (VAR_3)\nVAR_0->info->nb_decoded_frames++;",
"pkt.data += VAR_4;",
"pkt.size -= VAR_4;",
"VAR_4 = VAR_3;",
"}",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23,
25
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
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
]
] |
21,946 | static void validate_thread_parameters(AVCodecContext *avctx)
{
int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)
&& !(avctx->flags & CODEC_FLAG_TRUNCATED)
&& !(avctx->flags & CODEC_FLAG_LOW_DELAY)
&& !(avctx->flags2 & CODEC_FLAG2_CHUNKS);
if (avctx->thread_count == 1) {
avctx->active_thread_type = 0;
} else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) {
avctx->active_thread_type = FF_THREAD_FRAME;
} else {
avctx->active_thread_type = FF_THREAD_SLICE;
}
}
| false | FFmpeg | d0df2934ca63a1d5c31602e6558f341bd738bd07 | static void validate_thread_parameters(AVCodecContext *avctx)
{
int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)
&& !(avctx->flags & CODEC_FLAG_TRUNCATED)
&& !(avctx->flags & CODEC_FLAG_LOW_DELAY)
&& !(avctx->flags2 & CODEC_FLAG2_CHUNKS);
if (avctx->thread_count == 1) {
avctx->active_thread_type = 0;
} else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) {
avctx->active_thread_type = FF_THREAD_FRAME;
} else {
avctx->active_thread_type = FF_THREAD_SLICE;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0)
{
int VAR_1 = (VAR_0->codec->capabilities & CODEC_CAP_FRAME_THREADS)
&& !(VAR_0->flags & CODEC_FLAG_TRUNCATED)
&& !(VAR_0->flags & CODEC_FLAG_LOW_DELAY)
&& !(VAR_0->flags2 & CODEC_FLAG2_CHUNKS);
if (VAR_0->thread_count == 1) {
VAR_0->active_thread_type = 0;
} else if (VAR_1 && (VAR_0->thread_type & FF_THREAD_FRAME)) {
VAR_0->active_thread_type = FF_THREAD_FRAME;
} else {
VAR_0->active_thread_type = FF_THREAD_SLICE;
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0)\n{",
"int VAR_1 = (VAR_0->codec->capabilities & CODEC_CAP_FRAME_THREADS)\n&& !(VAR_0->flags & CODEC_FLAG_TRUNCATED)\n&& !(VAR_0->flags & CODEC_FLAG_LOW_DELAY)\n&& !(VAR_0->flags2 & CODEC_FLAG2_CHUNKS);",
"if (VAR_0->thread_count == 1) {",
"VAR_0->active_thread_type = 0;",
"} else if (VAR_1 && (VAR_0->thread_type & FF_THREAD_FRAME)) {",
"VAR_0->active_thread_type = FF_THREAD_FRAME;",
"} else {",
"VAR_0->active_thread_type = FF_THREAD_SLICE;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
21,947 | static int xan_unpack_luma(const uint8_t *src, const int src_size,
uint8_t *dst, const int dst_size)
{
int tree_size, eof;
const uint8_t *tree;
int bits, mask;
int tree_root, node;
const uint8_t *dst_end = dst + dst_size;
const uint8_t *src_end = src + src_size;
tree_size = *src++;
eof = *src++;
tree = src - eof * 2 - 2;
tree_root = eof + tree_size;
src += tree_size * 2;
node = tree_root;
bits = *src++;
mask = 0x80;
for (;;) {
int bit = !!(bits & mask);
mask >>= 1;
node = tree[node*2 + bit];
if (node == eof)
break;
if (node < eof) {
*dst++ = node;
if (dst > dst_end)
break;
node = tree_root;
}
if (!mask) {
bits = *src++;
if (src > src_end)
break;
mask = 0x80;
}
}
return dst != dst_end;
}
| true | FFmpeg | 55188278169c3a1838334d7aa47a1f7a40741690 | static int xan_unpack_luma(const uint8_t *src, const int src_size,
uint8_t *dst, const int dst_size)
{
int tree_size, eof;
const uint8_t *tree;
int bits, mask;
int tree_root, node;
const uint8_t *dst_end = dst + dst_size;
const uint8_t *src_end = src + src_size;
tree_size = *src++;
eof = *src++;
tree = src - eof * 2 - 2;
tree_root = eof + tree_size;
src += tree_size * 2;
node = tree_root;
bits = *src++;
mask = 0x80;
for (;;) {
int bit = !!(bits & mask);
mask >>= 1;
node = tree[node*2 + bit];
if (node == eof)
break;
if (node < eof) {
*dst++ = node;
if (dst > dst_end)
break;
node = tree_root;
}
if (!mask) {
bits = *src++;
if (src > src_end)
break;
mask = 0x80;
}
}
return dst != dst_end;
}
| {
"code": [
"static int xan_unpack_luma(const uint8_t *src, const int src_size,",
" const uint8_t *tree;",
" const uint8_t *src_end = src + src_size;",
" tree_size = *src++;",
" eof = *src++;",
" tree = src - eof * 2 - 2;",
" src += tree_size * 2;",
" bits = *src++;",
" node = tree[node*2 + bit];",
" bits = *src++;",
" if (src > src_end)",
" return dst != dst_end;"
],
"line_no": [
1,
9,
17,
21,
23,
25,
29,
35,
45,
65,
67,
77
]
} | static int FUNC_0(const uint8_t *VAR_0, const int VAR_1,
uint8_t *VAR_2, const int VAR_3)
{
int VAR_4, VAR_5;
const uint8_t *VAR_6;
int VAR_7, VAR_8;
int VAR_9, VAR_10;
const uint8_t *VAR_11 = VAR_2 + VAR_3;
const uint8_t *VAR_12 = VAR_0 + VAR_1;
VAR_4 = *VAR_0++;
VAR_5 = *VAR_0++;
VAR_6 = VAR_0 - VAR_5 * 2 - 2;
VAR_9 = VAR_5 + VAR_4;
VAR_0 += VAR_4 * 2;
VAR_10 = VAR_9;
VAR_7 = *VAR_0++;
VAR_8 = 0x80;
for (;;) {
int VAR_13 = !!(VAR_7 & VAR_8);
VAR_8 >>= 1;
VAR_10 = VAR_6[VAR_10*2 + VAR_13];
if (VAR_10 == VAR_5)
break;
if (VAR_10 < VAR_5) {
*VAR_2++ = VAR_10;
if (VAR_2 > VAR_11)
break;
VAR_10 = VAR_9;
}
if (!VAR_8) {
VAR_7 = *VAR_0++;
if (VAR_0 > VAR_12)
break;
VAR_8 = 0x80;
}
}
return VAR_2 != VAR_11;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, const int VAR_1,\nuint8_t *VAR_2, const int VAR_3)\n{",
"int VAR_4, VAR_5;",
"const uint8_t *VAR_6;",
"int VAR_7, VAR_8;",
"int VAR_9, VAR_10;",
"const uint8_t *VAR_11 = VAR_2 + VAR_3;",
"const uint8_t *VAR_12 = VAR_0 + VAR_1;",
"VAR_4 = *VAR_0++;",
"VAR_5 = *VAR_0++;",
"VAR_6 = VAR_0 - VAR_5 * 2 - 2;",
"VAR_9 = VAR_5 + VAR_4;",
"VAR_0 += VAR_4 * 2;",
"VAR_10 = VAR_9;",
"VAR_7 = *VAR_0++;",
"VAR_8 = 0x80;",
"for (;;) {",
"int VAR_13 = !!(VAR_7 & VAR_8);",
"VAR_8 >>= 1;",
"VAR_10 = VAR_6[VAR_10*2 + VAR_13];",
"if (VAR_10 == VAR_5)\nbreak;",
"if (VAR_10 < VAR_5) {",
"*VAR_2++ = VAR_10;",
"if (VAR_2 > VAR_11)\nbreak;",
"VAR_10 = VAR_9;",
"}",
"if (!VAR_8) {",
"VAR_7 = *VAR_0++;",
"if (VAR_0 > VAR_12)\nbreak;",
"VAR_8 = 0x80;",
"}",
"}",
"return VAR_2 != VAR_11;",
"}"
] | [
1,
0,
1,
0,
0,
0,
1,
1,
1,
1,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
21,949 | PPC_OP(set_T1)
{
T1 = PARAM(1);
RETURN();
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | PPC_OP(set_T1)
{
T1 = PARAM(1);
RETURN();
}
| {
"code": [
" T1 = PARAM(1);",
" RETURN();",
" RETURN();"
],
"line_no": [
5,
7,
7
]
} | FUNC_0(VAR_0)
{
T1 = PARAM(1);
RETURN();
}
| [
"FUNC_0(VAR_0)\n{",
"T1 = PARAM(1);",
"RETURN();",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
21,950 | static int nbd_co_send_request(BlockDriverState *bs,
NBDRequest *request,
QEMUIOVector *qiov)
{
NBDClientSession *s = nbd_get_client_session(bs);
int rc, ret, i;
qemu_co_mutex_lock(&s->send_mutex);
while (s->in_flight == MAX_NBD_REQUESTS) {
qemu_co_queue_wait(&s->free_sema, &s->send_mutex);
}
s->in_flight++;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
if (s->recv_coroutine[i] == NULL) {
s->recv_coroutine[i] = qemu_coroutine_self();
break;
}
}
g_assert(qemu_in_coroutine());
assert(i < MAX_NBD_REQUESTS);
request->handle = INDEX_TO_HANDLE(s, i);
if (!s->ioc) {
qemu_co_mutex_unlock(&s->send_mutex);
return -EPIPE;
}
if (qiov) {
qio_channel_set_cork(s->ioc, true);
rc = nbd_send_request(s->ioc, request);
if (rc >= 0) {
ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, false,
NULL);
if (ret != request->len) {
rc = -EIO;
}
}
qio_channel_set_cork(s->ioc, false);
} else {
rc = nbd_send_request(s->ioc, request);
}
qemu_co_mutex_unlock(&s->send_mutex);
return rc;
}
| true | qemu | 72b6ffc76653214b69a94a7b1643ff80df134486 | static int nbd_co_send_request(BlockDriverState *bs,
NBDRequest *request,
QEMUIOVector *qiov)
{
NBDClientSession *s = nbd_get_client_session(bs);
int rc, ret, i;
qemu_co_mutex_lock(&s->send_mutex);
while (s->in_flight == MAX_NBD_REQUESTS) {
qemu_co_queue_wait(&s->free_sema, &s->send_mutex);
}
s->in_flight++;
for (i = 0; i < MAX_NBD_REQUESTS; i++) {
if (s->recv_coroutine[i] == NULL) {
s->recv_coroutine[i] = qemu_coroutine_self();
break;
}
}
g_assert(qemu_in_coroutine());
assert(i < MAX_NBD_REQUESTS);
request->handle = INDEX_TO_HANDLE(s, i);
if (!s->ioc) {
qemu_co_mutex_unlock(&s->send_mutex);
return -EPIPE;
}
if (qiov) {
qio_channel_set_cork(s->ioc, true);
rc = nbd_send_request(s->ioc, request);
if (rc >= 0) {
ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, false,
NULL);
if (ret != request->len) {
rc = -EIO;
}
}
qio_channel_set_cork(s->ioc, false);
} else {
rc = nbd_send_request(s->ioc, request);
}
qemu_co_mutex_unlock(&s->send_mutex);
return rc;
}
| {
"code": [
" if (rc >= 0) {"
],
"line_no": [
65
]
} | static int FUNC_0(BlockDriverState *VAR_0,
NBDRequest *VAR_1,
QEMUIOVector *VAR_2)
{
NBDClientSession *s = nbd_get_client_session(VAR_0);
int VAR_3, VAR_4, VAR_5;
qemu_co_mutex_lock(&s->send_mutex);
while (s->in_flight == MAX_NBD_REQUESTS) {
qemu_co_queue_wait(&s->free_sema, &s->send_mutex);
}
s->in_flight++;
for (VAR_5 = 0; VAR_5 < MAX_NBD_REQUESTS; VAR_5++) {
if (s->recv_coroutine[VAR_5] == NULL) {
s->recv_coroutine[VAR_5] = qemu_coroutine_self();
break;
}
}
g_assert(qemu_in_coroutine());
assert(VAR_5 < MAX_NBD_REQUESTS);
VAR_1->handle = INDEX_TO_HANDLE(s, VAR_5);
if (!s->ioc) {
qemu_co_mutex_unlock(&s->send_mutex);
return -EPIPE;
}
if (VAR_2) {
qio_channel_set_cork(s->ioc, true);
VAR_3 = nbd_send_request(s->ioc, VAR_1);
if (VAR_3 >= 0) {
VAR_4 = nbd_rwv(s->ioc, VAR_2->iov, VAR_2->niov, VAR_1->len, false,
NULL);
if (VAR_4 != VAR_1->len) {
VAR_3 = -EIO;
}
}
qio_channel_set_cork(s->ioc, false);
} else {
VAR_3 = nbd_send_request(s->ioc, VAR_1);
}
qemu_co_mutex_unlock(&s->send_mutex);
return VAR_3;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0,\nNBDRequest *VAR_1,\nQEMUIOVector *VAR_2)\n{",
"NBDClientSession *s = nbd_get_client_session(VAR_0);",
"int VAR_3, VAR_4, VAR_5;",
"qemu_co_mutex_lock(&s->send_mutex);",
"while (s->in_flight == MAX_NBD_REQUESTS) {",
"qemu_co_queue_wait(&s->free_sema, &s->send_mutex);",
"}",
"s->in_flight++;",
"for (VAR_5 = 0; VAR_5 < MAX_NBD_REQUESTS; VAR_5++) {",
"if (s->recv_coroutine[VAR_5] == NULL) {",
"s->recv_coroutine[VAR_5] = qemu_coroutine_self();",
"break;",
"}",
"}",
"g_assert(qemu_in_coroutine());",
"assert(VAR_5 < MAX_NBD_REQUESTS);",
"VAR_1->handle = INDEX_TO_HANDLE(s, VAR_5);",
"if (!s->ioc) {",
"qemu_co_mutex_unlock(&s->send_mutex);",
"return -EPIPE;",
"}",
"if (VAR_2) {",
"qio_channel_set_cork(s->ioc, true);",
"VAR_3 = nbd_send_request(s->ioc, VAR_1);",
"if (VAR_3 >= 0) {",
"VAR_4 = nbd_rwv(s->ioc, VAR_2->iov, VAR_2->niov, VAR_1->len, false,\nNULL);",
"if (VAR_4 != VAR_1->len) {",
"VAR_3 = -EIO;",
"}",
"}",
"qio_channel_set_cork(s->ioc, false);",
"} else {",
"VAR_3 = nbd_send_request(s->ioc, VAR_1);",
"}",
"qemu_co_mutex_unlock(&s->send_mutex);",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
21,952 | static void __attribute__((__constructor__)) rcu_init(void)
{
QemuThread thread;
qemu_mutex_init(&rcu_gp_lock);
qemu_event_init(&rcu_gp_event, true);
qemu_event_init(&rcu_call_ready_event, false);
qemu_thread_create(&thread, "call_rcu", call_rcu_thread,
NULL, QEMU_THREAD_DETACHED);
rcu_register_thread();
}
| true | qemu | 21b7cf9e07e5991c57b461181cfb5bbb6fe7a9d6 | static void __attribute__((__constructor__)) rcu_init(void)
{
QemuThread thread;
qemu_mutex_init(&rcu_gp_lock);
qemu_event_init(&rcu_gp_event, true);
qemu_event_init(&rcu_call_ready_event, false);
qemu_thread_create(&thread, "call_rcu", call_rcu_thread,
NULL, QEMU_THREAD_DETACHED);
rcu_register_thread();
}
| {
"code": [
"static void __attribute__((__constructor__)) rcu_init(void)"
],
"line_no": [
1
]
} | static void __attribute__((__constructor__)) FUNC_0(void)
{
QemuThread thread;
qemu_mutex_init(&rcu_gp_lock);
qemu_event_init(&rcu_gp_event, true);
qemu_event_init(&rcu_call_ready_event, false);
qemu_thread_create(&thread, "call_rcu", call_rcu_thread,
NULL, QEMU_THREAD_DETACHED);
rcu_register_thread();
}
| [
"static void __attribute__((__constructor__)) FUNC_0(void)\n{",
"QemuThread thread;",
"qemu_mutex_init(&rcu_gp_lock);",
"qemu_event_init(&rcu_gp_event, true);",
"qemu_event_init(&rcu_call_ready_event, false);",
"qemu_thread_create(&thread, \"call_rcu\", call_rcu_thread,\nNULL, QEMU_THREAD_DETACHED);",
"rcu_register_thread();",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
]
] |
21,953 | static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
GetByteContext gb;
const uint8_t *bs_hdr;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int i, j;
bytestream2_init(&gb, buf, buf_size);
/* parse and check the OS header */
frame_num = bytestream2_get_le32(&gb);
word2 = bytestream2_get_le32(&gb);
check_sum = bytestream2_get_le32(&gb);
data_size = bytestream2_get_le32(&gb);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
/* parse the bitstream header */
bs_hdr = gb.buffer;
if (bytestream2_get_le16(&gb) != 32) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
ctx->frame_num = frame_num;
ctx->frame_flags = bytestream2_get_le16(&gb);
ctx->data_size = (bytestream2_get_le32(&gb) + 7) >> 3;
ctx->cb_offset = bytestream2_get_byte(&gb);
if (ctx->data_size == 16)
return 4;
if (ctx->data_size > buf_size)
ctx->data_size = buf_size;
bytestream2_skip(&gb, 3); // skip reserved byte and checksum
/* check frame dimensions */
height = bytestream2_get_le16(&gb);
width = bytestream2_get_le16(&gb);
if (av_image_check_size(width, height, 0, avctx))
return AVERROR_INVALIDDATA;
if (width != ctx->width || height != ctx->height) {
int res;
av_dlog(avctx, "Frame dimensions changed!\n");
if (width < 16 || width > 640 ||
height < 16 || height > 480 ||
width & 3 || height & 3) {
av_log(avctx, AV_LOG_ERROR,
"Invalid picture dimensions: %d x %d!\n", width, height);
return AVERROR_INVALIDDATA;
}
ctx->width = width;
ctx->height = height;
free_frame_buffers(ctx);
if ((res = allocate_frame_buffers(ctx, avctx)) < 0)
return res;
avcodec_set_dimensions(avctx, width, height);
}
y_offset = bytestream2_get_le32(&gb);
v_offset = bytestream2_get_le32(&gb);
u_offset = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 4);
/* unfortunately there is no common order of planes in the buffer */
/* so we use that sorting algo for determining planes data sizes */
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (j = 0; j < 3; j++) {
ends[j] = ctx->data_size;
for (i = 2; i >= 0; i--)
if (starts[i] < ends[j] && starts[i] > starts[j])
ends[j] = starts[i];
}
ctx->y_data_size = ends[0] - starts[0];
ctx->v_data_size = ends[1] - starts[1];
ctx->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
FFMIN3(y_offset, v_offset, u_offset) < gb.buffer - bs_hdr + 16 ||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
ctx->y_data_ptr = bs_hdr + y_offset;
ctx->v_data_ptr = bs_hdr + v_offset;
ctx->u_data_ptr = bs_hdr + u_offset;
ctx->alt_quant = gb.buffer;
if (ctx->data_size == 16) {
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (ctx->frame_flags & BS_8BIT_PEL) {
avpriv_request_sample(avctx, "8-bit pixel format");
return AVERROR_PATCHWELCOME;
}
if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) {
avpriv_request_sample(avctx, "Halfpel motion vectors");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| true | FFmpeg | 34e6af9e204ca6bb18d8cf8ec68fe19b0e083e95 | static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
GetByteContext gb;
const uint8_t *bs_hdr;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int i, j;
bytestream2_init(&gb, buf, buf_size);
frame_num = bytestream2_get_le32(&gb);
word2 = bytestream2_get_le32(&gb);
check_sum = bytestream2_get_le32(&gb);
data_size = bytestream2_get_le32(&gb);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
bs_hdr = gb.buffer;
if (bytestream2_get_le16(&gb) != 32) {
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
ctx->frame_num = frame_num;
ctx->frame_flags = bytestream2_get_le16(&gb);
ctx->data_size = (bytestream2_get_le32(&gb) + 7) >> 3;
ctx->cb_offset = bytestream2_get_byte(&gb);
if (ctx->data_size == 16)
return 4;
if (ctx->data_size > buf_size)
ctx->data_size = buf_size;
bytestream2_skip(&gb, 3);
height = bytestream2_get_le16(&gb);
width = bytestream2_get_le16(&gb);
if (av_image_check_size(width, height, 0, avctx))
return AVERROR_INVALIDDATA;
if (width != ctx->width || height != ctx->height) {
int res;
av_dlog(avctx, "Frame dimensions changed!\n");
if (width < 16 || width > 640 ||
height < 16 || height > 480 ||
width & 3 || height & 3) {
av_log(avctx, AV_LOG_ERROR,
"Invalid picture dimensions: %d x %d!\n", width, height);
return AVERROR_INVALIDDATA;
}
ctx->width = width;
ctx->height = height;
free_frame_buffers(ctx);
if ((res = allocate_frame_buffers(ctx, avctx)) < 0)
return res;
avcodec_set_dimensions(avctx, width, height);
}
y_offset = bytestream2_get_le32(&gb);
v_offset = bytestream2_get_le32(&gb);
u_offset = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 4);
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (j = 0; j < 3; j++) {
ends[j] = ctx->data_size;
for (i = 2; i >= 0; i--)
if (starts[i] < ends[j] && starts[i] > starts[j])
ends[j] = starts[i];
}
ctx->y_data_size = ends[0] - starts[0];
ctx->v_data_size = ends[1] - starts[1];
ctx->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
FFMIN3(y_offset, v_offset, u_offset) < gb.buffer - bs_hdr + 16 ||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
ctx->y_data_ptr = bs_hdr + y_offset;
ctx->v_data_ptr = bs_hdr + v_offset;
ctx->u_data_ptr = bs_hdr + u_offset;
ctx->alt_quant = gb.buffer;
if (ctx->data_size == 16) {
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (ctx->frame_flags & BS_8BIT_PEL) {
avpriv_request_sample(avctx, "8-bit pixel format");
return AVERROR_PATCHWELCOME;
}
if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) {
avpriv_request_sample(avctx, "Halfpel motion vectors");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| {
"code": [
" if (ctx->data_size > buf_size)",
" ctx->data_size = buf_size;"
],
"line_no": [
77,
79
]
} | static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,
const uint8_t *VAR_2, int VAR_3)
{
GetByteContext gb;
const uint8_t *VAR_4;
uint32_t frame_num, word2, check_sum, data_size;
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
uint16_t height, width;
int VAR_5, VAR_6;
bytestream2_init(&gb, VAR_2, VAR_3);
frame_num = bytestream2_get_le32(&gb);
word2 = bytestream2_get_le32(&gb);
check_sum = bytestream2_get_le32(&gb);
data_size = bytestream2_get_le32(&gb);
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
av_log(VAR_1, AV_LOG_ERROR, "OS header checksum mismatch!\n");
return AVERROR_INVALIDDATA;
}
VAR_4 = gb.buffer;
if (bytestream2_get_le16(&gb) != 32) {
av_log(VAR_1, AV_LOG_ERROR, "Unsupported codec version!\n");
return AVERROR_INVALIDDATA;
}
VAR_0->frame_num = frame_num;
VAR_0->frame_flags = bytestream2_get_le16(&gb);
VAR_0->data_size = (bytestream2_get_le32(&gb) + 7) >> 3;
VAR_0->cb_offset = bytestream2_get_byte(&gb);
if (VAR_0->data_size == 16)
return 4;
if (VAR_0->data_size > VAR_3)
VAR_0->data_size = VAR_3;
bytestream2_skip(&gb, 3);
height = bytestream2_get_le16(&gb);
width = bytestream2_get_le16(&gb);
if (av_image_check_size(width, height, 0, VAR_1))
return AVERROR_INVALIDDATA;
if (width != VAR_0->width || height != VAR_0->height) {
int VAR_7;
av_dlog(VAR_1, "Frame dimensions changed!\n");
if (width < 16 || width > 640 ||
height < 16 || height > 480 ||
width & 3 || height & 3) {
av_log(VAR_1, AV_LOG_ERROR,
"Invalid picture dimensions: %d x %d!\n", width, height);
return AVERROR_INVALIDDATA;
}
VAR_0->width = width;
VAR_0->height = height;
free_frame_buffers(VAR_0);
if ((VAR_7 = allocate_frame_buffers(VAR_0, VAR_1)) < 0)
return VAR_7;
avcodec_set_dimensions(VAR_1, width, height);
}
y_offset = bytestream2_get_le32(&gb);
v_offset = bytestream2_get_le32(&gb);
u_offset = bytestream2_get_le32(&gb);
bytestream2_skip(&gb, 4);
starts[0] = y_offset;
starts[1] = v_offset;
starts[2] = u_offset;
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
ends[VAR_6] = VAR_0->data_size;
for (VAR_5 = 2; VAR_5 >= 0; VAR_5--)
if (starts[VAR_5] < ends[VAR_6] && starts[VAR_5] > starts[VAR_6])
ends[VAR_6] = starts[VAR_5];
}
VAR_0->y_data_size = ends[0] - starts[0];
VAR_0->v_data_size = ends[1] - starts[1];
VAR_0->u_data_size = ends[2] - starts[2];
if (FFMAX3(y_offset, v_offset, u_offset) >= VAR_0->data_size - 16 ||
FFMIN3(y_offset, v_offset, u_offset) < gb.buffer - VAR_4 + 16 ||
FFMIN3(VAR_0->y_data_size, VAR_0->v_data_size, VAR_0->u_data_size) <= 0) {
av_log(VAR_1, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
return AVERROR_INVALIDDATA;
}
VAR_0->y_data_ptr = VAR_4 + y_offset;
VAR_0->v_data_ptr = VAR_4 + v_offset;
VAR_0->u_data_ptr = VAR_4 + u_offset;
VAR_0->alt_quant = gb.buffer;
if (VAR_0->data_size == 16) {
av_log(VAR_1, AV_LOG_DEBUG, "Sync frame encountered!\n");
return 16;
}
if (VAR_0->frame_flags & BS_8BIT_PEL) {
avpriv_request_sample(VAR_1, "8-bit pixel format");
return AVERROR_PATCHWELCOME;
}
if (VAR_0->frame_flags & BS_MV_X_HALF || VAR_0->frame_flags & BS_MV_Y_HALF) {
avpriv_request_sample(VAR_1, "Halfpel motion vectors");
return AVERROR_PATCHWELCOME;
}
return 0;
}
| [
"static int FUNC_0(Indeo3DecodeContext *VAR_0, AVCodecContext *VAR_1,\nconst uint8_t *VAR_2, int VAR_3)\n{",
"GetByteContext gb;",
"const uint8_t *VAR_4;",
"uint32_t frame_num, word2, check_sum, data_size;",
"uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];",
"uint16_t height, width;",
"int VAR_5, VAR_6;",
"bytestream2_init(&gb, VAR_2, VAR_3);",
"frame_num = bytestream2_get_le32(&gb);",
"word2 = bytestream2_get_le32(&gb);",
"check_sum = bytestream2_get_le32(&gb);",
"data_size = bytestream2_get_le32(&gb);",
"if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {",
"av_log(VAR_1, AV_LOG_ERROR, \"OS header checksum mismatch!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_4 = gb.buffer;",
"if (bytestream2_get_le16(&gb) != 32) {",
"av_log(VAR_1, AV_LOG_ERROR, \"Unsupported codec version!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->frame_num = frame_num;",
"VAR_0->frame_flags = bytestream2_get_le16(&gb);",
"VAR_0->data_size = (bytestream2_get_le32(&gb) + 7) >> 3;",
"VAR_0->cb_offset = bytestream2_get_byte(&gb);",
"if (VAR_0->data_size == 16)\nreturn 4;",
"if (VAR_0->data_size > VAR_3)\nVAR_0->data_size = VAR_3;",
"bytestream2_skip(&gb, 3);",
"height = bytestream2_get_le16(&gb);",
"width = bytestream2_get_le16(&gb);",
"if (av_image_check_size(width, height, 0, VAR_1))\nreturn AVERROR_INVALIDDATA;",
"if (width != VAR_0->width || height != VAR_0->height) {",
"int VAR_7;",
"av_dlog(VAR_1, \"Frame dimensions changed!\\n\");",
"if (width < 16 || width > 640 ||\nheight < 16 || height > 480 ||\nwidth & 3 || height & 3) {",
"av_log(VAR_1, AV_LOG_ERROR,\n\"Invalid picture dimensions: %d x %d!\\n\", width, height);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->width = width;",
"VAR_0->height = height;",
"free_frame_buffers(VAR_0);",
"if ((VAR_7 = allocate_frame_buffers(VAR_0, VAR_1)) < 0)\nreturn VAR_7;",
"avcodec_set_dimensions(VAR_1, width, height);",
"}",
"y_offset = bytestream2_get_le32(&gb);",
"v_offset = bytestream2_get_le32(&gb);",
"u_offset = bytestream2_get_le32(&gb);",
"bytestream2_skip(&gb, 4);",
"starts[0] = y_offset;",
"starts[1] = v_offset;",
"starts[2] = u_offset;",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"ends[VAR_6] = VAR_0->data_size;",
"for (VAR_5 = 2; VAR_5 >= 0; VAR_5--)",
"if (starts[VAR_5] < ends[VAR_6] && starts[VAR_5] > starts[VAR_6])\nends[VAR_6] = starts[VAR_5];",
"}",
"VAR_0->y_data_size = ends[0] - starts[0];",
"VAR_0->v_data_size = ends[1] - starts[1];",
"VAR_0->u_data_size = ends[2] - starts[2];",
"if (FFMAX3(y_offset, v_offset, u_offset) >= VAR_0->data_size - 16 ||\nFFMIN3(y_offset, v_offset, u_offset) < gb.buffer - VAR_4 + 16 ||\nFFMIN3(VAR_0->y_data_size, VAR_0->v_data_size, VAR_0->u_data_size) <= 0) {",
"av_log(VAR_1, AV_LOG_ERROR, \"One of the y/u/v offsets is invalid\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->y_data_ptr = VAR_4 + y_offset;",
"VAR_0->v_data_ptr = VAR_4 + v_offset;",
"VAR_0->u_data_ptr = VAR_4 + u_offset;",
"VAR_0->alt_quant = gb.buffer;",
"if (VAR_0->data_size == 16) {",
"av_log(VAR_1, AV_LOG_DEBUG, \"Sync frame encountered!\\n\");",
"return 16;",
"}",
"if (VAR_0->frame_flags & BS_8BIT_PEL) {",
"avpriv_request_sample(VAR_1, \"8-bit pixel format\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_0->frame_flags & BS_MV_X_HALF || VAR_0->frame_flags & BS_MV_Y_HALF) {",
"avpriv_request_sample(VAR_1, \"Halfpel motion vectors\");",
"return AVERROR_PATCHWELCOME;",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77,
79
],
[
83
],
[
89
],
[
91
],
[
93,
95
],
[
99
],
[
101
],
[
105
],
[
109,
111,
113
],
[
115,
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185,
187,
189
],
[
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
]
] |
21,954 | static int libquvi_probe(AVProbeData *p)
{
int score;
quvi_t q;
QUVIcode rc;
rc = quvi_init(&q);
if (rc != QUVI_OK)
return AVERROR(ENOMEM);
score = quvi_supported(q, (char *)p->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;
quvi_close(&q);
return score;
}
| true | FFmpeg | 2d40a09b6e73230b160a505f01ed1acf169e1d9f | static int libquvi_probe(AVProbeData *p)
{
int score;
quvi_t q;
QUVIcode rc;
rc = quvi_init(&q);
if (rc != QUVI_OK)
return AVERROR(ENOMEM);
score = quvi_supported(q, (char *)p->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;
quvi_close(&q);
return score;
}
| {
"code": [
" quvi_t q;",
" QUVIcode rc;",
" rc = quvi_init(&q);",
" quvi_close(&q);",
"static int libquvi_probe(AVProbeData *p)",
" int score;",
" quvi_t q;",
" QUVIcode rc;",
" rc = quvi_init(&q);",
" if (rc != QUVI_OK)",
" return AVERROR(ENOMEM);",
" score = quvi_supported(q, (char *)p->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;",
" quvi_close(&q);",
" return score;"
],
"line_no": [
7,
9,
13,
21,
1,
5,
7,
9,
13,
15,
17,
19,
21,
23
]
} | static int FUNC_0(AVProbeData *VAR_0)
{
int VAR_1;
quvi_t q;
QUVIcode rc;
rc = quvi_init(&q);
if (rc != QUVI_OK)
return AVERROR(ENOMEM);
VAR_1 = quvi_supported(q, (char *)VAR_0->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;
quvi_close(&q);
return VAR_1;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"int VAR_1;",
"quvi_t q;",
"QUVIcode rc;",
"rc = quvi_init(&q);",
"if (rc != QUVI_OK)\nreturn AVERROR(ENOMEM);",
"VAR_1 = quvi_supported(q, (char *)VAR_0->filename) == QUVI_OK ? AVPROBE_SCORE_EXTENSION : 0;",
"quvi_close(&q);",
"return VAR_1;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
21,955 | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
unsigned i;
unsigned num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| true | FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
unsigned i;
unsigned num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| {
"code": [
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"\tunsigned i;",
"void rgb16tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size)",
"\tunsigned i;",
"\tunsigned num_pixels = src_size >> 1;",
"\tunsigned i;",
"\tunsigned num_pixels = src_size >> 1;",
"\tunsigned i;",
"\tunsigned num_pixels = src_size >> 1;",
"\tunsigned i;",
"\tunsigned num_pixels = src_size >> 1;",
"\tunsigned i;"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
1,
5,
7,
5,
7,
5,
7,
5,
7,
5
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)
{
unsigned VAR_3;
unsigned VAR_4 = VAR_2 >> 1;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++)
{
unsigned VAR_5,VAR_6,VAR_7;
register uint16_t VAR_8;
VAR_8 = VAR_0[2*VAR_3];
VAR_7 = VAR_8&0x1F;
VAR_6 = (VAR_8&0x7E0)>>5;
VAR_5 = (VAR_8&0xF800)>>11;
VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x3F)<<5) | ((VAR_7&0x1F)<<11);
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, unsigned int VAR_2)\n{",
"unsigned VAR_3;",
"unsigned VAR_4 = VAR_2 >> 1;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++)",
"{",
"unsigned VAR_5,VAR_6,VAR_7;",
"register uint16_t VAR_8;",
"VAR_8 = VAR_0[2*VAR_3];",
"VAR_7 = VAR_8&0x1F;",
"VAR_6 = (VAR_8&0x7E0)>>5;",
"VAR_5 = (VAR_8&0xF800)>>11;",
"VAR_1[2*VAR_3] = (VAR_5&0x1F) | ((VAR_6&0x3F)<<5) | ((VAR_7&0x1F)<<11);",
"}",
"}"
] | [
1,
1,
1,
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
]
] |
21,956 | static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
int ret;
ff_tlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
av_assert2(s->mb_skipped == 0);
if (s->mb_skip_run-- != 0) {
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->mb_skipped = 1;
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
int mb_type;
if (s->mb_x)
mb_type = s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
else
// FIXME not sure if this is allowed in MPEG at all
mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1];
if (IS_INTRA(mb_type)) {
av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
return AVERROR_INVALIDDATA;
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
mb_type | MB_TYPE_SKIP;
if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
s->mb_skipped = 1;
}
return 0;
}
switch (s->pict_type) {
default:
case AV_PICTURE_TYPE_I:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in I-frame at %d %d\n",
s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case AV_PICTURE_TYPE_P:
mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in P-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = ptype2mb_type[mb_type];
break;
case AV_PICTURE_TYPE_B:
mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in B-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = btype2mb_type[mb_type];
break;
}
ff_tlog(s->avctx, "mb_type=%x\n", mb_type);
// motion_type = 0; /* avoid warning */
if (IS_INTRA(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
if (!s->chroma_y_shift)
s->bdsp.clear_blocks(s->block[6]);
/* compute DCT type */
// FIXME: add an interlaced_dct coded var?
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
/* just parse them */
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb); /* field select */
s->mv[0][0][0] =
s->last_mv[0][0][0] =
s->last_mv[0][1][0] = mpeg_decode_motion(s, s->mpeg_f_code[0][0],
s->last_mv[0][0][0]);
s->mv[0][0][1] =
s->last_mv[0][0][1] =
s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1],
s->last_mv[0][0][1]);
check_marker(s->avctx, &s->gb, "after concealment_motion_vectors");
} else {
/* reset mv prediction */
memset(s->last_mv, 0, sizeof(s->last_mv));
}
s->mb_intra = 1;
// if 1, we memcpy blocks in xvmcvideo
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++)
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
} else {
for (i = 0; i < mb_block_count; i++)
if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0)
return ret;
}
} else {
for (i = 0; i < 6; i++) {
ret = ff_mpeg1_decode_block_intra(&s->gb,
s->intra_matrix,
s->intra_scantable.permutated,
s->last_dc, *s->pblocks[i],
i, s->qscale);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
s->mb_x, s->mb_y);
return ret;
}
s->block_last_index[i] = ret;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV) {
av_assert2(mb_type & MB_TYPE_CBP);
s->mv_dir = MV_DIR_FORWARD;
if (s->picture_structure == PICT_FRAME) {
if (s->picture_structure == PICT_FRAME
&& !s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
s->mv_type = MV_TYPE_16X16;
} else {
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0] = s->picture_structure - 1;
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
} else {
av_assert2(mb_type & MB_TYPE_L0L1);
// FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED
/* get additional motion vector type */
if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {
motion_type = MT_FRAME;
} else {
motion_type = get_bits(&s->gb, 2);
if (s->picture_structure == PICT_FRAME && HAS_CBP(mb_type))
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
/* motion vectors */
s->mv_dir = (mb_type >> 13) & 3;
ff_tlog(s->avctx, "motion_type=%d\n", motion_type);
switch (motion_type) {
case MT_FRAME: /* or MT_16X8 */
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
/* MT_FRAME */
s->mv[i][0][0] =
s->last_mv[i][0][0] =
s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->mv[i][0][1] =
s->last_mv[i][0][1] =
s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1]);
/* full_pel: only for MPEG-1 */
if (s->full_pel[i]) {
s->mv[i][0][0] *= 2;
s->mv[i][0][1] *= 2;
}
}
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
/* MT_16X8 */
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
ff_tlog(s->avctx, "fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = 2 * val;
s->mv[i][j][1] = val;
ff_tlog(s->avctx, "fmy=%d\n", val);
}
}
}
} else {
av_assert0(!s->progressive_sequence);
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
s->field_select[i][0] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
}
}
break;
case MT_DMV:
if (s->progressive_sequence){
av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
return AVERROR_INVALIDDATA;
}
s->mv_type = MV_TYPE_DMV;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
int dmx, dmy, mx, my, m;
const int my_shift = s->picture_structure == PICT_FRAME;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> my_shift);
dmy = get_dmv(s);
s->last_mv[i][0][1] = my * (1 << my_shift);
s->last_mv[i][1][1] = my * (1 << my_shift);
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx; // not used
s->mv[i][1][1] = my; // not used
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
// m = 1 + 2 * s->top_field_first;
m = s->top_field_first ? 1 : 3;
/* top -> top pred */
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if (s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
cbp = get_vlc2(&s->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (mb_block_count > 6) {
cbp <<= mb_block_count - 6;
cbp |= get_bits(&s->gb, mb_block_count - 6);
s->bdsp.clear_blocks(s->block[6]);
}
if (cbp <= 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
// if 1, we memcpy blocks in xvmcvideo
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, cbp);
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
cbp <<= 12 - mb_block_count;
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11)) {
if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
} else {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
}
} else {
for (i = 0; i < 12; i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type;
return 0;
}
| true | FFmpeg | a720b854b0d3f0fae2b1eac644dd39e5821cacb1 | static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
int ret;
ff_tlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
av_assert2(s->mb_skipped == 0);
if (s->mb_skip_run-- != 0) {
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->mb_skipped = 1;
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
int mb_type;
if (s->mb_x)
mb_type = s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
else
mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1];
if (IS_INTRA(mb_type)) {
av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
return AVERROR_INVALIDDATA;
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
mb_type | MB_TYPE_SKIP;
if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
s->mb_skipped = 1;
}
return 0;
}
switch (s->pict_type) {
default:
case AV_PICTURE_TYPE_I:
if (get_bits1(&s->gb) == 0) {
if (get_bits1(&s->gb) == 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in I-frame at %d %d\n",
s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
mb_type = MB_TYPE_INTRA;
}
break;
case AV_PICTURE_TYPE_P:
mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in P-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = ptype2mb_type[mb_type];
break;
case AV_PICTURE_TYPE_B:
mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid mb type in B-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = btype2mb_type[mb_type];
break;
}
ff_tlog(s->avctx, "mb_type=%x\n", mb_type);
if (IS_INTRA(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
if (!s->chroma_y_shift)
s->bdsp.clear_blocks(s->block[6]);
if (s->picture_structure == PICT_FRAME &&
!s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
if (s->concealment_motion_vectors) {
if (s->picture_structure != PICT_FRAME)
skip_bits1(&s->gb);
s->mv[0][0][0] =
s->last_mv[0][0][0] =
s->last_mv[0][1][0] = mpeg_decode_motion(s, s->mpeg_f_code[0][0],
s->last_mv[0][0][0]);
s->mv[0][0][1] =
s->last_mv[0][0][1] =
s->last_mv[0][1][1] = mpeg_decode_motion(s, s->mpeg_f_code[0][1],
s->last_mv[0][0][1]);
check_marker(s->avctx, &s->gb, "after concealment_motion_vectors");
} else {
memset(s->last_mv, 0, sizeof(s->last_mv));
}
s->mb_intra = 1;
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, -1);
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++)
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
} else {
for (i = 0; i < mb_block_count; i++)
if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0)
return ret;
}
} else {
for (i = 0; i < 6; i++) {
ret = ff_mpeg1_decode_block_intra(&s->gb,
s->intra_matrix,
s->intra_scantable.permutated,
s->last_dc, *s->pblocks[i],
i, s->qscale);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
s->mb_x, s->mb_y);
return ret;
}
s->block_last_index[i] = ret;
}
}
} else {
if (mb_type & MB_TYPE_ZERO_MV) {
av_assert2(mb_type & MB_TYPE_CBP);
s->mv_dir = MV_DIR_FORWARD;
if (s->picture_structure == PICT_FRAME) {
if (s->picture_structure == PICT_FRAME
&& !s->frame_pred_frame_dct)
s->interlaced_dct = get_bits1(&s->gb);
s->mv_type = MV_TYPE_16X16;
} else {
s->mv_type = MV_TYPE_FIELD;
mb_type |= MB_TYPE_INTERLACED;
s->field_select[0][0] = s->picture_structure - 1;
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->last_mv[0][0][0] = 0;
s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = 0;
s->last_mv[0][1][1] = 0;
s->mv[0][0][0] = 0;
s->mv[0][0][1] = 0;
} else {
av_assert2(mb_type & MB_TYPE_L0L1);
if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {
motion_type = MT_FRAME;
} else {
motion_type = get_bits(&s->gb, 2);
if (s->picture_structure == PICT_FRAME && HAS_CBP(mb_type))
s->interlaced_dct = get_bits1(&s->gb);
}
if (IS_QUANT(mb_type))
s->qscale = get_qscale(s);
s->mv_dir = (mb_type >> 13) & 3;
ff_tlog(s->avctx, "motion_type=%d\n", motion_type);
switch (motion_type) {
case MT_FRAME:
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16;
s->mv_type = MV_TYPE_16X16;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
s->mv[i][0][0] =
s->last_mv[i][0][0] =
s->last_mv[i][1][0] =
mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->mv[i][0][1] =
s->last_mv[i][0][1] =
s->last_mv[i][1][1] =
mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1]);
if (s->full_pel[i]) {
s->mv[i][0][0] *= 2;
s->mv[i][0][1] *= 2;
}
}
}
} else {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
s->mv_type = MV_TYPE_16X8;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][j][k]);
s->last_mv[i][j][k] = val;
s->mv[i][j][k] = val;
}
}
}
}
}
break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
for (j = 0; j < 2; j++) {
s->field_select[i][j] = get_bits1(&s->gb);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
ff_tlog(s->avctx, "fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = 2 * val;
s->mv[i][j][1] = val;
ff_tlog(s->avctx, "fmy=%d\n", val);
}
}
}
} else {
av_assert0(!s->progressive_sequence);
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
s->field_select[i][0] = get_bits1(&s->gb);
for (k = 0; k < 2; k++) {
val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
s->last_mv[i][0][k]);
s->last_mv[i][0][k] = val;
s->last_mv[i][1][k] = val;
s->mv[i][0][k] = val;
}
}
}
}
break;
case MT_DMV:
if (s->progressive_sequence){
av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
return AVERROR_INVALIDDATA;
}
s->mv_type = MV_TYPE_DMV;
for (i = 0; i < 2; i++) {
if (USES_LIST(mb_type, i)) {
int dmx, dmy, mx, my, m;
const int my_shift = s->picture_structure == PICT_FRAME;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
s->last_mv[i][0][0]);
s->last_mv[i][0][0] = mx;
s->last_mv[i][1][0] = mx;
dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> my_shift);
dmy = get_dmv(s);
s->last_mv[i][0][1] = my * (1 << my_shift);
s->last_mv[i][1][1] = my * (1 << my_shift);
s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
s->mv[i][1][0] = mx;
s->mv[i][1][1] = my;
if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
m = s->top_field_first ? 1 : 3;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m;
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
} else {
mb_type |= MB_TYPE_16x16;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
if (s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
}
s->mb_intra = 0;
if (HAS_CBP(mb_type)) {
s->bdsp.clear_blocks(s->block[0]);
cbp = get_vlc2(&s->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (mb_block_count > 6) {
cbp <<= mb_block_count - 6;
cbp |= get_bits(&s->gb, mb_block_count - 6);
s->bdsp.clear_blocks(s->block[6]);
}
if (cbp <= 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_pack_pblocks(s, cbp);
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
cbp <<= 12 - mb_block_count;
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11)) {
if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
} else {
if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (i = 0; i < 6; i++) {
if (cbp & 32)
mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
else
s->block_last_index[i] = -1;
cbp += cbp;
}
} else {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0)
return ret;
} else {
s->block_last_index[i] = -1;
}
cbp += cbp;
}
}
}
} else {
for (i = 0; i < 12; i++)
s->block_last_index[i] = -1;
}
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type;
return 0;
}
| {
"code": [
" cbp <<= mb_block_count - 6;"
],
"line_no": [
659
]
} | static int FUNC_0(MpegEncContext *VAR_0, int16_t VAR_1[12][64])
{
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_11, VAR_8;
const int VAR_9 = 4 + (1 << VAR_0->chroma_format);
int VAR_10;
ff_tlog(VAR_0->avctx, "decode_mb: x=%d y=%d\n", VAR_0->mb_x, VAR_0->mb_y);
av_assert2(VAR_0->mb_skipped == 0);
if (VAR_0->mb_skip_run-- != 0) {
if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {
VAR_0->mb_skipped = 1;
VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] =
MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
} else {
int VAR_11;
if (VAR_0->mb_x)
VAR_11 = VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride - 1];
else
VAR_11 = VAR_0->current_picture.VAR_11[VAR_0->mb_width + (VAR_0->mb_y - 1) * VAR_0->mb_stride - 1];
if (IS_INTRA(VAR_11)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "skip with previntra\n");
return AVERROR_INVALIDDATA;
}
VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] =
VAR_11 | MB_TYPE_SKIP;
if ((VAR_0->mv[0][0][0] | VAR_0->mv[0][0][1] | VAR_0->mv[1][0][0] | VAR_0->mv[1][0][1]) == 0)
VAR_0->mb_skipped = 1;
}
return 0;
}
switch (VAR_0->pict_type) {
default:
case AV_PICTURE_TYPE_I:
if (get_bits1(&VAR_0->gb) == 0) {
if (get_bits1(&VAR_0->gb) == 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid mb type in I-frame at %d %d\n",
VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
VAR_11 = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
VAR_11 = MB_TYPE_INTRA;
}
break;
case AV_PICTURE_TYPE_P:
VAR_11 = get_vlc2(&VAR_0->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
if (VAR_11 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid mb type in P-frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
VAR_11 = ptype2mb_type[VAR_11];
break;
case AV_PICTURE_TYPE_B:
VAR_11 = get_vlc2(&VAR_0->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
if (VAR_11 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid mb type in B-frame at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
VAR_11 = btype2mb_type[VAR_11];
break;
}
ff_tlog(VAR_0->avctx, "VAR_11=%x\n", VAR_11);
if (IS_INTRA(VAR_11)) {
VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);
if (!VAR_0->chroma_y_shift)
VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[6]);
if (VAR_0->picture_structure == PICT_FRAME &&
!VAR_0->frame_pred_frame_dct)
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
if (IS_QUANT(VAR_11))
VAR_0->qscale = get_qscale(VAR_0);
if (VAR_0->concealment_motion_vectors) {
if (VAR_0->picture_structure != PICT_FRAME)
skip_bits1(&VAR_0->gb);
VAR_0->mv[0][0][0] =
VAR_0->last_mv[0][0][0] =
VAR_0->last_mv[0][1][0] = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][0],
VAR_0->last_mv[0][0][0]);
VAR_0->mv[0][0][1] =
VAR_0->last_mv[0][0][1] =
VAR_0->last_mv[0][1][1] = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][1],
VAR_0->last_mv[0][0][1]);
check_marker(VAR_0->avctx, &VAR_0->gb, "after concealment_motion_vectors");
} else {
memset(VAR_0->last_mv, 0, sizeof(VAR_0->last_mv));
}
VAR_0->mb_intra = 1;
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && VAR_0->pack_pblocks)
ff_xvmc_pack_pblocks(VAR_0, -1);
if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++)
mpeg2_fast_decode_block_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);
} else {
for (VAR_2 = 0; VAR_2 < VAR_9; VAR_2++)
if ((VAR_10 = mpeg2_decode_block_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)
return VAR_10;
}
} else {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
VAR_10 = ff_mpeg1_decode_block_intra(&VAR_0->gb,
VAR_0->intra_matrix,
VAR_0->intra_scantable.permutated,
VAR_0->last_dc, *VAR_0->pblocks[VAR_2],
VAR_2, VAR_0->qscale);
if (VAR_10 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
VAR_0->mb_x, VAR_0->mb_y);
return VAR_10;
}
VAR_0->block_last_index[VAR_2] = VAR_10;
}
}
} else {
if (VAR_11 & MB_TYPE_ZERO_MV) {
av_assert2(VAR_11 & MB_TYPE_CBP);
VAR_0->mv_dir = MV_DIR_FORWARD;
if (VAR_0->picture_structure == PICT_FRAME) {
if (VAR_0->picture_structure == PICT_FRAME
&& !VAR_0->frame_pred_frame_dct)
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
VAR_0->mv_type = MV_TYPE_16X16;
} else {
VAR_0->mv_type = MV_TYPE_FIELD;
VAR_11 |= MB_TYPE_INTERLACED;
VAR_0->field_select[0][0] = VAR_0->picture_structure - 1;
}
if (IS_QUANT(VAR_11))
VAR_0->qscale = get_qscale(VAR_0);
VAR_0->last_mv[0][0][0] = 0;
VAR_0->last_mv[0][0][1] = 0;
VAR_0->last_mv[0][1][0] = 0;
VAR_0->last_mv[0][1][1] = 0;
VAR_0->mv[0][0][0] = 0;
VAR_0->mv[0][0][1] = 0;
} else {
av_assert2(VAR_11 & MB_TYPE_L0L1);
if (VAR_0->picture_structure == PICT_FRAME && VAR_0->frame_pred_frame_dct) {
VAR_8 = MT_FRAME;
} else {
VAR_8 = get_bits(&VAR_0->gb, 2);
if (VAR_0->picture_structure == PICT_FRAME && HAS_CBP(VAR_11))
VAR_0->interlaced_dct = get_bits1(&VAR_0->gb);
}
if (IS_QUANT(VAR_11))
VAR_0->qscale = get_qscale(VAR_0);
VAR_0->mv_dir = (VAR_11 >> 13) & 3;
ff_tlog(VAR_0->avctx, "VAR_8=%d\n", VAR_8);
switch (VAR_8) {
case MT_FRAME:
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_11 |= MB_TYPE_16x16;
VAR_0->mv_type = MV_TYPE_16X16;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
if (USES_LIST(VAR_11, VAR_2)) {
VAR_0->mv[VAR_2][0][0] =
VAR_0->last_mv[VAR_2][0][0] =
VAR_0->last_mv[VAR_2][1][0] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],
VAR_0->last_mv[VAR_2][0][0]);
VAR_0->mv[VAR_2][0][1] =
VAR_0->last_mv[VAR_2][0][1] =
VAR_0->last_mv[VAR_2][1][1] =
mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],
VAR_0->last_mv[VAR_2][0][1]);
if (VAR_0->full_pel[VAR_2]) {
VAR_0->mv[VAR_2][0][0] *= 2;
VAR_0->mv[VAR_2][0][1] *= 2;
}
}
}
} else {
VAR_11 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
VAR_0->mv_type = MV_TYPE_16X8;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
if (USES_LIST(VAR_11, VAR_2)) {
for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {
VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);
for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],
VAR_0->last_mv[VAR_2][VAR_3][VAR_4]);
VAR_0->last_mv[VAR_2][VAR_3][VAR_4] = VAR_6;
VAR_0->mv[VAR_2][VAR_3][VAR_4] = VAR_6;
}
}
}
}
}
break;
case MT_FIELD:
VAR_0->mv_type = MV_TYPE_FIELD;
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_11 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
if (USES_LIST(VAR_11, VAR_2)) {
for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {
VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],
VAR_0->last_mv[VAR_2][VAR_3][0]);
VAR_0->last_mv[VAR_2][VAR_3][0] = VAR_6;
VAR_0->mv[VAR_2][VAR_3][0] = VAR_6;
ff_tlog(VAR_0->avctx, "fmx=%d\n", VAR_6);
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],
VAR_0->last_mv[VAR_2][VAR_3][1] >> 1);
VAR_0->last_mv[VAR_2][VAR_3][1] = 2 * VAR_6;
VAR_0->mv[VAR_2][VAR_3][1] = VAR_6;
ff_tlog(VAR_0->avctx, "fmy=%d\n", VAR_6);
}
}
}
} else {
av_assert0(!VAR_0->progressive_sequence);
VAR_11 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
if (USES_LIST(VAR_11, VAR_2)) {
VAR_0->field_select[VAR_2][0] = get_bits1(&VAR_0->gb);
for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {
VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],
VAR_0->last_mv[VAR_2][0][VAR_4]);
VAR_0->last_mv[VAR_2][0][VAR_4] = VAR_6;
VAR_0->last_mv[VAR_2][1][VAR_4] = VAR_6;
VAR_0->mv[VAR_2][0][VAR_4] = VAR_6;
}
}
}
}
break;
case MT_DMV:
if (VAR_0->progressive_sequence){
av_log(VAR_0->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
return AVERROR_INVALIDDATA;
}
VAR_0->mv_type = MV_TYPE_DMV;
for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {
if (USES_LIST(VAR_11, VAR_2)) {
int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;
const int VAR_16 = VAR_0->picture_structure == PICT_FRAME;
VAR_13 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],
VAR_0->last_mv[VAR_2][0][0]);
VAR_0->last_mv[VAR_2][0][0] = VAR_13;
VAR_0->last_mv[VAR_2][1][0] = VAR_13;
VAR_11 = get_dmv(VAR_0);
VAR_14 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],
VAR_0->last_mv[VAR_2][0][1] >> VAR_16);
VAR_12 = get_dmv(VAR_0);
VAR_0->last_mv[VAR_2][0][1] = VAR_14 * (1 << VAR_16);
VAR_0->last_mv[VAR_2][1][1] = VAR_14 * (1 << VAR_16);
VAR_0->mv[VAR_2][0][0] = VAR_13;
VAR_0->mv[VAR_2][0][1] = VAR_14;
VAR_0->mv[VAR_2][1][0] = VAR_13;
VAR_0->mv[VAR_2][1][1] = VAR_14;
if (VAR_0->picture_structure == PICT_FRAME) {
VAR_11 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
VAR_15 = VAR_0->top_field_first ? 1 : 3;
VAR_0->mv[VAR_2][2][0] = ((VAR_13 * VAR_15 + (VAR_13 > 0)) >> 1) + VAR_11;
VAR_0->mv[VAR_2][2][1] = ((VAR_14 * VAR_15 + (VAR_14 > 0)) >> 1) + VAR_12 - 1;
VAR_15 = 4 - VAR_15;
VAR_0->mv[VAR_2][3][0] = ((VAR_13 * VAR_15 + (VAR_13 > 0)) >> 1) + VAR_11;
VAR_0->mv[VAR_2][3][1] = ((VAR_14 * VAR_15 + (VAR_14 > 0)) >> 1) + VAR_12 + 1;
} else {
VAR_11 |= MB_TYPE_16x16;
VAR_0->mv[VAR_2][2][0] = ((VAR_13 + (VAR_13 > 0)) >> 1) + VAR_11;
VAR_0->mv[VAR_2][2][1] = ((VAR_14 + (VAR_14 > 0)) >> 1) + VAR_12;
if (VAR_0->picture_structure == PICT_TOP_FIELD)
VAR_0->mv[VAR_2][2][1]--;
else
VAR_0->mv[VAR_2][2][1]++;
}
}
}
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR,
"00 VAR_8 at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
}
VAR_0->mb_intra = 0;
if (HAS_CBP(VAR_11)) {
VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);
VAR_5 = get_vlc2(&VAR_0->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
if (VAR_9 > 6) {
VAR_5 <<= VAR_9 - 6;
VAR_5 |= get_bits(&VAR_0->gb, VAR_9 - 6);
VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[6]);
}
if (VAR_5 <= 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"invalid VAR_5 %d at %d %d\n", VAR_5, VAR_0->mb_x, VAR_0->mb_y);
return AVERROR_INVALIDDATA;
}
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && VAR_0->pack_pblocks)
ff_xvmc_pack_pblocks(VAR_0, VAR_5);
if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
if (VAR_5 & 32)
mpeg2_fast_decode_block_non_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);
else
VAR_0->block_last_index[VAR_2] = -1;
VAR_5 += VAR_5;
}
} else {
VAR_5 <<= 12 - VAR_9;
for (VAR_2 = 0; VAR_2 < VAR_9; VAR_2++) {
if (VAR_5 & (1 << 11)) {
if ((VAR_10 = mpeg2_decode_block_non_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)
return VAR_10;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
VAR_5 += VAR_5;
}
}
} else {
if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
if (VAR_5 & 32)
mpeg1_fast_decode_block_inter(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);
else
VAR_0->block_last_index[VAR_2] = -1;
VAR_5 += VAR_5;
}
} else {
for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {
if (VAR_5 & 32) {
if ((VAR_10 = mpeg1_decode_block_inter(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)
return VAR_10;
} else {
VAR_0->block_last_index[VAR_2] = -1;
}
VAR_5 += VAR_5;
}
}
}
} else {
for (VAR_2 = 0; VAR_2 < 12; VAR_2++)
VAR_0->block_last_index[VAR_2] = -1;
}
}
VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] = VAR_11;
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, int16_t VAR_1[12][64])\n{",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_11, VAR_8;",
"const int VAR_9 = 4 + (1 << VAR_0->chroma_format);",
"int VAR_10;",
"ff_tlog(VAR_0->avctx, \"decode_mb: x=%d y=%d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"av_assert2(VAR_0->mb_skipped == 0);",
"if (VAR_0->mb_skip_run-- != 0) {",
"if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {",
"VAR_0->mb_skipped = 1;",
"VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] =\nMB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;",
"} else {",
"int VAR_11;",
"if (VAR_0->mb_x)\nVAR_11 = VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride - 1];",
"else\nVAR_11 = VAR_0->current_picture.VAR_11[VAR_0->mb_width + (VAR_0->mb_y - 1) * VAR_0->mb_stride - 1];",
"if (IS_INTRA(VAR_11)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"skip with previntra\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] =\nVAR_11 | MB_TYPE_SKIP;",
"if ((VAR_0->mv[0][0][0] | VAR_0->mv[0][0][1] | VAR_0->mv[1][0][0] | VAR_0->mv[1][0][1]) == 0)\nVAR_0->mb_skipped = 1;",
"}",
"return 0;",
"}",
"switch (VAR_0->pict_type) {",
"default:\ncase AV_PICTURE_TYPE_I:\nif (get_bits1(&VAR_0->gb) == 0) {",
"if (get_bits1(&VAR_0->gb) == 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid mb type in I-frame at %d %d\\n\",\nVAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = MB_TYPE_QUANT | MB_TYPE_INTRA;",
"} else {",
"VAR_11 = MB_TYPE_INTRA;",
"}",
"break;",
"case AV_PICTURE_TYPE_P:\nVAR_11 = get_vlc2(&VAR_0->gb, ff_mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);",
"if (VAR_11 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid mb type in P-frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = ptype2mb_type[VAR_11];",
"break;",
"case AV_PICTURE_TYPE_B:\nVAR_11 = get_vlc2(&VAR_0->gb, ff_mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);",
"if (VAR_11 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid mb type in B-frame at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = btype2mb_type[VAR_11];",
"break;",
"}",
"ff_tlog(VAR_0->avctx, \"VAR_11=%x\\n\", VAR_11);",
"if (IS_INTRA(VAR_11)) {",
"VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);",
"if (!VAR_0->chroma_y_shift)\nVAR_0->bdsp.clear_blocks(VAR_0->VAR_1[6]);",
"if (VAR_0->picture_structure == PICT_FRAME &&\n!VAR_0->frame_pred_frame_dct)\nVAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"if (IS_QUANT(VAR_11))\nVAR_0->qscale = get_qscale(VAR_0);",
"if (VAR_0->concealment_motion_vectors) {",
"if (VAR_0->picture_structure != PICT_FRAME)\nskip_bits1(&VAR_0->gb);",
"VAR_0->mv[0][0][0] =\nVAR_0->last_mv[0][0][0] =\nVAR_0->last_mv[0][1][0] = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][0],\nVAR_0->last_mv[0][0][0]);",
"VAR_0->mv[0][0][1] =\nVAR_0->last_mv[0][0][1] =\nVAR_0->last_mv[0][1][1] = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[0][1],\nVAR_0->last_mv[0][0][1]);",
"check_marker(VAR_0->avctx, &VAR_0->gb, \"after concealment_motion_vectors\");",
"} else {",
"memset(VAR_0->last_mv, 0, sizeof(VAR_0->last_mv));",
"}",
"VAR_0->mb_intra = 1;",
"if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && VAR_0->pack_pblocks)\nff_xvmc_pack_pblocks(VAR_0, -1);",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {",
"if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++)",
"mpeg2_fast_decode_block_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_9; VAR_2++)",
"if ((VAR_10 = mpeg2_decode_block_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)\nreturn VAR_10;",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"VAR_10 = ff_mpeg1_decode_block_intra(&VAR_0->gb,\nVAR_0->intra_matrix,\nVAR_0->intra_scantable.permutated,\nVAR_0->last_dc, *VAR_0->pblocks[VAR_2],\nVAR_2, VAR_0->qscale);",
"if (VAR_10 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"ac-tex damaged at %d %d\\n\",\nVAR_0->mb_x, VAR_0->mb_y);",
"return VAR_10;",
"}",
"VAR_0->block_last_index[VAR_2] = VAR_10;",
"}",
"}",
"} else {",
"if (VAR_11 & MB_TYPE_ZERO_MV) {",
"av_assert2(VAR_11 & MB_TYPE_CBP);",
"VAR_0->mv_dir = MV_DIR_FORWARD;",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"if (VAR_0->picture_structure == PICT_FRAME\n&& !VAR_0->frame_pred_frame_dct)\nVAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"VAR_0->mv_type = MV_TYPE_16X16;",
"} else {",
"VAR_0->mv_type = MV_TYPE_FIELD;",
"VAR_11 |= MB_TYPE_INTERLACED;",
"VAR_0->field_select[0][0] = VAR_0->picture_structure - 1;",
"}",
"if (IS_QUANT(VAR_11))\nVAR_0->qscale = get_qscale(VAR_0);",
"VAR_0->last_mv[0][0][0] = 0;",
"VAR_0->last_mv[0][0][1] = 0;",
"VAR_0->last_mv[0][1][0] = 0;",
"VAR_0->last_mv[0][1][1] = 0;",
"VAR_0->mv[0][0][0] = 0;",
"VAR_0->mv[0][0][1] = 0;",
"} else {",
"av_assert2(VAR_11 & MB_TYPE_L0L1);",
"if (VAR_0->picture_structure == PICT_FRAME && VAR_0->frame_pred_frame_dct) {",
"VAR_8 = MT_FRAME;",
"} else {",
"VAR_8 = get_bits(&VAR_0->gb, 2);",
"if (VAR_0->picture_structure == PICT_FRAME && HAS_CBP(VAR_11))\nVAR_0->interlaced_dct = get_bits1(&VAR_0->gb);",
"}",
"if (IS_QUANT(VAR_11))\nVAR_0->qscale = get_qscale(VAR_0);",
"VAR_0->mv_dir = (VAR_11 >> 13) & 3;",
"ff_tlog(VAR_0->avctx, \"VAR_8=%d\\n\", VAR_8);",
"switch (VAR_8) {",
"case MT_FRAME:\nif (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_11 |= MB_TYPE_16x16;",
"VAR_0->mv_type = MV_TYPE_16X16;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"if (USES_LIST(VAR_11, VAR_2)) {",
"VAR_0->mv[VAR_2][0][0] =\nVAR_0->last_mv[VAR_2][0][0] =\nVAR_0->last_mv[VAR_2][1][0] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],\nVAR_0->last_mv[VAR_2][0][0]);",
"VAR_0->mv[VAR_2][0][1] =\nVAR_0->last_mv[VAR_2][0][1] =\nVAR_0->last_mv[VAR_2][1][1] =\nmpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],\nVAR_0->last_mv[VAR_2][0][1]);",
"if (VAR_0->full_pel[VAR_2]) {",
"VAR_0->mv[VAR_2][0][0] *= 2;",
"VAR_0->mv[VAR_2][0][1] *= 2;",
"}",
"}",
"}",
"} else {",
"VAR_11 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;",
"VAR_0->mv_type = MV_TYPE_16X8;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"if (USES_LIST(VAR_11, VAR_2)) {",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {",
"VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);",
"for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],\nVAR_0->last_mv[VAR_2][VAR_3][VAR_4]);",
"VAR_0->last_mv[VAR_2][VAR_3][VAR_4] = VAR_6;",
"VAR_0->mv[VAR_2][VAR_3][VAR_4] = VAR_6;",
"}",
"}",
"}",
"}",
"}",
"break;",
"case MT_FIELD:\nVAR_0->mv_type = MV_TYPE_FIELD;",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_11 |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"if (USES_LIST(VAR_11, VAR_2)) {",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {",
"VAR_0->field_select[VAR_2][VAR_3] = get_bits1(&VAR_0->gb);",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],\nVAR_0->last_mv[VAR_2][VAR_3][0]);",
"VAR_0->last_mv[VAR_2][VAR_3][0] = VAR_6;",
"VAR_0->mv[VAR_2][VAR_3][0] = VAR_6;",
"ff_tlog(VAR_0->avctx, \"fmx=%d\\n\", VAR_6);",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],\nVAR_0->last_mv[VAR_2][VAR_3][1] >> 1);",
"VAR_0->last_mv[VAR_2][VAR_3][1] = 2 * VAR_6;",
"VAR_0->mv[VAR_2][VAR_3][1] = VAR_6;",
"ff_tlog(VAR_0->avctx, \"fmy=%d\\n\", VAR_6);",
"}",
"}",
"}",
"} else {",
"av_assert0(!VAR_0->progressive_sequence);",
"VAR_11 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"if (USES_LIST(VAR_11, VAR_2)) {",
"VAR_0->field_select[VAR_2][0] = get_bits1(&VAR_0->gb);",
"for (VAR_4 = 0; VAR_4 < 2; VAR_4++) {",
"VAR_6 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][VAR_4],\nVAR_0->last_mv[VAR_2][0][VAR_4]);",
"VAR_0->last_mv[VAR_2][0][VAR_4] = VAR_6;",
"VAR_0->last_mv[VAR_2][1][VAR_4] = VAR_6;",
"VAR_0->mv[VAR_2][0][VAR_4] = VAR_6;",
"}",
"}",
"}",
"}",
"break;",
"case MT_DMV:\nif (VAR_0->progressive_sequence){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"MT_DMV in progressive_sequence\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->mv_type = MV_TYPE_DMV;",
"for (VAR_2 = 0; VAR_2 < 2; VAR_2++) {",
"if (USES_LIST(VAR_11, VAR_2)) {",
"int VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;",
"const int VAR_16 = VAR_0->picture_structure == PICT_FRAME;",
"VAR_13 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][0],\nVAR_0->last_mv[VAR_2][0][0]);",
"VAR_0->last_mv[VAR_2][0][0] = VAR_13;",
"VAR_0->last_mv[VAR_2][1][0] = VAR_13;",
"VAR_11 = get_dmv(VAR_0);",
"VAR_14 = mpeg_decode_motion(VAR_0, VAR_0->mpeg_f_code[VAR_2][1],\nVAR_0->last_mv[VAR_2][0][1] >> VAR_16);",
"VAR_12 = get_dmv(VAR_0);",
"VAR_0->last_mv[VAR_2][0][1] = VAR_14 * (1 << VAR_16);",
"VAR_0->last_mv[VAR_2][1][1] = VAR_14 * (1 << VAR_16);",
"VAR_0->mv[VAR_2][0][0] = VAR_13;",
"VAR_0->mv[VAR_2][0][1] = VAR_14;",
"VAR_0->mv[VAR_2][1][0] = VAR_13;",
"VAR_0->mv[VAR_2][1][1] = VAR_14;",
"if (VAR_0->picture_structure == PICT_FRAME) {",
"VAR_11 |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;",
"VAR_15 = VAR_0->top_field_first ? 1 : 3;",
"VAR_0->mv[VAR_2][2][0] = ((VAR_13 * VAR_15 + (VAR_13 > 0)) >> 1) + VAR_11;",
"VAR_0->mv[VAR_2][2][1] = ((VAR_14 * VAR_15 + (VAR_14 > 0)) >> 1) + VAR_12 - 1;",
"VAR_15 = 4 - VAR_15;",
"VAR_0->mv[VAR_2][3][0] = ((VAR_13 * VAR_15 + (VAR_13 > 0)) >> 1) + VAR_11;",
"VAR_0->mv[VAR_2][3][1] = ((VAR_14 * VAR_15 + (VAR_14 > 0)) >> 1) + VAR_12 + 1;",
"} else {",
"VAR_11 |= MB_TYPE_16x16;",
"VAR_0->mv[VAR_2][2][0] = ((VAR_13 + (VAR_13 > 0)) >> 1) + VAR_11;",
"VAR_0->mv[VAR_2][2][1] = ((VAR_14 + (VAR_14 > 0)) >> 1) + VAR_12;",
"if (VAR_0->picture_structure == PICT_TOP_FIELD)\nVAR_0->mv[VAR_2][2][1]--;",
"else\nVAR_0->mv[VAR_2][2][1]++;",
"}",
"}",
"}",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR,\n\"00 VAR_8 at %d %d\\n\", VAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"VAR_0->mb_intra = 0;",
"if (HAS_CBP(VAR_11)) {",
"VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);",
"VAR_5 = get_vlc2(&VAR_0->gb, ff_mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);",
"if (VAR_9 > 6) {",
"VAR_5 <<= VAR_9 - 6;",
"VAR_5 |= get_bits(&VAR_0->gb, VAR_9 - 6);",
"VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[6]);",
"}",
"if (VAR_5 <= 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"invalid VAR_5 %d at %d %d\\n\", VAR_5, VAR_0->mb_x, VAR_0->mb_y);",
"return AVERROR_INVALIDDATA;",
"}",
"if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && VAR_0->pack_pblocks)\nff_xvmc_pack_pblocks(VAR_0, VAR_5);",
"if (VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO) {",
"if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"if (VAR_5 & 32)\nmpeg2_fast_decode_block_non_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);",
"else\nVAR_0->block_last_index[VAR_2] = -1;",
"VAR_5 += VAR_5;",
"}",
"} else {",
"VAR_5 <<= 12 - VAR_9;",
"for (VAR_2 = 0; VAR_2 < VAR_9; VAR_2++) {",
"if (VAR_5 & (1 << 11)) {",
"if ((VAR_10 = mpeg2_decode_block_non_intra(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)\nreturn VAR_10;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"VAR_5 += VAR_5;",
"}",
"}",
"} else {",
"if (VAR_0->avctx->flags2 & AV_CODEC_FLAG2_FAST) {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"if (VAR_5 & 32)\nmpeg1_fast_decode_block_inter(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2);",
"else\nVAR_0->block_last_index[VAR_2] = -1;",
"VAR_5 += VAR_5;",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < 6; VAR_2++) {",
"if (VAR_5 & 32) {",
"if ((VAR_10 = mpeg1_decode_block_inter(VAR_0, *VAR_0->pblocks[VAR_2], VAR_2)) < 0)\nreturn VAR_10;",
"} else {",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"VAR_5 += VAR_5;",
"}",
"}",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < 12; VAR_2++)",
"VAR_0->block_last_index[VAR_2] = -1;",
"}",
"}",
"VAR_0->current_picture.VAR_11[VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride] = VAR_11;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37,
39
],
[
41,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
61,
63
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
153,
155
],
[
163,
165,
167
],
[
171,
173
],
[
177
],
[
181,
183
],
[
187,
189,
191,
193
],
[
195,
197,
199,
201
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
219,
221
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
247,
249,
251,
253,
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283
],
[
285
],
[
287,
289,
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307,
309
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345
],
[
349,
351
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377,
379,
381,
383,
385
],
[
387,
389,
391,
393,
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
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
],
[
547,
549
],
[
551
],
[
553
],
[
555
],
[
557,
559
],
[
561
],
[
567
],
[
569
],
[
573
],
[
575
],
[
577
],
[
579
],
[
583
],
[
585
],
[
591
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
613
],
[
615
],
[
617,
619
],
[
621,
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633,
635,
637
],
[
639
],
[
641
],
[
643
],
[
647
],
[
649
],
[
651
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669,
671
],
[
673
],
[
675
],
[
681,
683
],
[
687
],
[
689
],
[
691
],
[
693,
695
],
[
697,
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
711
],
[
713
],
[
715,
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737,
739
],
[
741,
743
],
[
745
],
[
747
],
[
749
],
[
751
],
[
753
],
[
755,
757
],
[
759
],
[
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
781
],
[
785
],
[
789
],
[
791
]
] |
21,959 | static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
int i;
assert(src1 == src2);
for(i=0; i<width; i++)
{
int d0= ((uint32_t*)src1)[i];
int dl= (d0&0x03E07C1F);
int dh= ((d0>>5)&0x03E0F81F);
int dh2= (dh>>11) + (dh<<21);
int d= dh2 + dl;
int g= d&0x7F;
int r= (d>>10)&0x7F;
int b= d>>21;
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
}
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
int i;
assert(src1 == src2);
for(i=0; i<width; i++)
{
int d0= ((uint32_t*)src1)[i];
int dl= (d0&0x03E07C1F);
int dh= ((d0>>5)&0x03E0F81F);
int dh2= (dh>>11) + (dh<<21);
int d= dh2 + dl;
int g= d&0x7F;
int r= (d>>10)&0x7F;
int b= d>>21;
dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
}
}
| {
"code": [
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
" assert(src1 == src2);",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
" assert(src1 == src2);",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
" assert(src1 == src2);",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
" assert(src1 == src2);",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d0= ((uint32_t*)src1)[i];",
"\t\tint dh2= (dh>>11) + (dh<<21);",
"\t\tint d= dh2 + dl;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d0= ((uint32_t*)src1)[i];",
"\t\tint dl= (d0&0x03E07C1F);",
"\t\tint dh= ((d0>>5)&0x03E0F81F);",
"\t\tint dh2= (dh>>11) + (dh<<21);",
"\t\tint d= dh2 + dl;",
"\t\tint r= (d>>10)&0x7F;",
"\t\tdstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"\t\tdstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
" assert(src1 == src2);",
"\tfor(i=0; i<width; i++)",
"\t\tint d0= ((uint32_t*)src1)[i];",
"\t\tint dh2= (dh>>11) + (dh<<21);",
"\t\tint d= dh2 + dl;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
" assert(src1 == src2);",
"\tfor(i=0; i<width; i++)",
"\t\tint d0= ((uint32_t*)src1)[i];",
"\t\tint dl= (d0&0x03E07C1F);",
"\t\tint dh= ((d0>>5)&0x03E0F81F);",
"\t\tint dh2= (dh>>11) + (dh<<21);",
"\t\tint d= dh2 + dl;",
"\t\tint g= d&0x7F;",
"\t\tint r= (d>>10)&0x7F;",
"\t\tint b= d>>21;",
"\t\tdstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"\t\tdstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
" assert(src1 == src2);",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;"
],
"line_no": [
5,
5,
5,
5,
9,
5,
9,
7,
5,
9,
5,
9,
7,
5,
9,
5,
7,
9,
5,
9,
5,
9,
7,
5,
9,
5,
9,
13,
23,
25,
5,
9,
5,
9,
13,
17,
19,
23,
25,
31,
35,
37,
5,
9,
5,
9,
5,
9,
5,
9,
5,
9,
5,
7,
9,
13,
23,
25,
5,
9,
5,
7,
9,
13,
17,
19,
23,
25,
29,
31,
33,
35,
37,
5,
9,
5,
7,
9,
5,
5,
5,
5,
5
]
} | static inline void FUNC_0(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)
{
int VAR_0;
assert(src1 == src2);
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int d0= ((uint32_t*)src1)[VAR_0];
int dl= (d0&0x03E07C1F);
int dh= ((d0>>5)&0x03E0F81F);
int dh2= (dh>>11) + (dh<<21);
int d= dh2 + dl;
int g= d&0x7F;
int r= (d>>10)&0x7F;
int b= d>>21;
dstU[VAR_0]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
dstV[VAR_0]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;
}
}
| [
"static inline void FUNC_0(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width)\n{",
"int VAR_0;",
"assert(src1 == src2);",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"int d0= ((uint32_t*)src1)[VAR_0];",
"int dl= (d0&0x03E07C1F);",
"int dh= ((d0>>5)&0x03E0F81F);",
"int dh2= (dh>>11) + (dh<<21);",
"int d= dh2 + dl;",
"int g= d&0x7F;",
"int r= (d>>10)&0x7F;",
"int b= d>>21;",
"dstU[VAR_0]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"dstV[VAR_0]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1-3)) + 128;",
"}",
"}"
] | [
0,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
21,960 | const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
void *dst;
if(!o || o->offset<=0)
return NULL;
if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
return NULL;
dst= ((uint8_t*)obj) + o->offset;
if(o_out) *o_out= o;
if(o->type == FF_OPT_TYPE_STRING)
return dst;
switch(o->type){
case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
default: return NULL;
}
return buf;
}
| true | FFmpeg | 24cdc39e9dfd2b98e96c96387903bd41313bd0dd | const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
void *dst;
if(!o || o->offset<=0)
return NULL;
if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
return NULL;
dst= ((uint8_t*)obj) + o->offset;
if(o_out) *o_out= o;
if(o->type == FF_OPT_TYPE_STRING)
return dst;
switch(o->type){
case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
default: return NULL;
}
return buf;
}
| {
"code": [
" return dst;"
],
"line_no": [
25
]
} | const char *FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2, char *VAR_3, int VAR_4){
const AVOption *VAR_5= av_find_opt(VAR_0, VAR_1, NULL, 0, 0);
void *VAR_6;
if(!VAR_5 || VAR_5->offset<=0)
return NULL;
if(VAR_5->type != FF_OPT_TYPE_STRING && (!VAR_3 || !VAR_4))
return NULL;
VAR_6= ((uint8_t*)VAR_0) + VAR_5->offset;
if(VAR_2) *VAR_2= VAR_5;
if(VAR_5->type == FF_OPT_TYPE_STRING)
return VAR_6;
switch(VAR_5->type){
case FF_OPT_TYPE_FLAGS: snprintf(VAR_3, VAR_4, "0x%08X",*(int *)VAR_6);break;
case FF_OPT_TYPE_INT: snprintf(VAR_3, VAR_4, "%d" , *(int *)VAR_6);break;
case FF_OPT_TYPE_INT64: snprintf(VAR_3, VAR_4, "%"PRId64, *(int64_t*)VAR_6);break;
case FF_OPT_TYPE_FLOAT: snprintf(VAR_3, VAR_4, "%f" , *(float *)VAR_6);break;
case FF_OPT_TYPE_DOUBLE: snprintf(VAR_3, VAR_4, "%f" , *(double *)VAR_6);break;
case FF_OPT_TYPE_RATIONAL: snprintf(VAR_3, VAR_4, "%d/%d", ((AVRational*)VAR_6)->num, ((AVRational*)VAR_6)->den);break;
default: return NULL;
}
return VAR_3;
}
| [
"const char *FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2, char *VAR_3, int VAR_4){",
"const AVOption *VAR_5= av_find_opt(VAR_0, VAR_1, NULL, 0, 0);",
"void *VAR_6;",
"if(!VAR_5 || VAR_5->offset<=0)\nreturn NULL;",
"if(VAR_5->type != FF_OPT_TYPE_STRING && (!VAR_3 || !VAR_4))\nreturn NULL;",
"VAR_6= ((uint8_t*)VAR_0) + VAR_5->offset;",
"if(VAR_2) *VAR_2= VAR_5;",
"if(VAR_5->type == FF_OPT_TYPE_STRING)\nreturn VAR_6;",
"switch(VAR_5->type){",
"case FF_OPT_TYPE_FLAGS: snprintf(VAR_3, VAR_4, \"0x%08X\",*(int *)VAR_6);break;",
"case FF_OPT_TYPE_INT: snprintf(VAR_3, VAR_4, \"%d\" , *(int *)VAR_6);break;",
"case FF_OPT_TYPE_INT64: snprintf(VAR_3, VAR_4, \"%\"PRId64, *(int64_t*)VAR_6);break;",
"case FF_OPT_TYPE_FLOAT: snprintf(VAR_3, VAR_4, \"%f\" , *(float *)VAR_6);break;",
"case FF_OPT_TYPE_DOUBLE: snprintf(VAR_3, VAR_4, \"%f\" , *(double *)VAR_6);break;",
"case FF_OPT_TYPE_RATIONAL: snprintf(VAR_3, VAR_4, \"%d/%d\", ((AVRational*)VAR_6)->num, ((AVRational*)VAR_6)->den);break;",
"default: return NULL;",
"}",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
21,961 | static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {
int j, old_nb_alloc;
old_nb_alloc = s->nb_peers;
while (new_min_size >= s->nb_peers)
s->nb_peers = s->nb_peers * 2;
IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
/* zero out new pointers */
for (j = old_nb_alloc; j < s->nb_peers; j++) {
s->peers[j].eventfds = NULL;
s->peers[j].nb_eventfds = 0;
}
}
| true | qemu | 34bc07c5282a631c2663ae1ded0a186f46f64612 | static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {
int j, old_nb_alloc;
old_nb_alloc = s->nb_peers;
while (new_min_size >= s->nb_peers)
s->nb_peers = s->nb_peers * 2;
IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
for (j = old_nb_alloc; j < s->nb_peers; j++) {
s->peers[j].eventfds = NULL;
s->peers[j].nb_eventfds = 0;
}
}
| {
"code": [
"static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {",
" while (new_min_size >= s->nb_peers)",
" s->nb_peers = s->nb_peers * 2;"
],
"line_no": [
1,
13,
15
]
} | static void FUNC_0(IVShmemState *VAR_0, int VAR_1) {
int VAR_2, VAR_3;
VAR_3 = VAR_0->nb_peers;
while (VAR_1 >= VAR_0->nb_peers)
VAR_0->nb_peers = VAR_0->nb_peers * 2;
IVSHMEM_DPRINTF("bumping storage to %d guests\n", VAR_0->nb_peers);
VAR_0->peers = g_realloc(VAR_0->peers, VAR_0->nb_peers * sizeof(Peer));
for (VAR_2 = VAR_3; VAR_2 < VAR_0->nb_peers; VAR_2++) {
VAR_0->peers[VAR_2].eventfds = NULL;
VAR_0->peers[VAR_2].nb_eventfds = 0;
}
}
| [
"static void FUNC_0(IVShmemState *VAR_0, int VAR_1) {",
"int VAR_2, VAR_3;",
"VAR_3 = VAR_0->nb_peers;",
"while (VAR_1 >= VAR_0->nb_peers)\nVAR_0->nb_peers = VAR_0->nb_peers * 2;",
"IVSHMEM_DPRINTF(\"bumping storage to %d guests\\n\", VAR_0->nb_peers);",
"VAR_0->peers = g_realloc(VAR_0->peers, VAR_0->nb_peers * sizeof(Peer));",
"for (VAR_2 = VAR_3; VAR_2 < VAR_0->nb_peers; VAR_2++) {",
"VAR_0->peers[VAR_2].eventfds = NULL;",
"VAR_0->peers[VAR_2].nb_eventfds = 0;",
"}",
"}"
] | [
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
5
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
21,963 | static void usb_host_auto_check(void *unused)
{
struct USBHostDevice *s;
struct USBAutoFilter *f;
libusb_device **devs;
struct libusb_device_descriptor ddesc;
int unconnected = 0;
int i, n;
if (usb_host_init() != 0) {
return;
}
if (runstate_is_running()) {
n = libusb_get_device_list(ctx, &devs);
for (i = 0; i < n; i++) {
if (libusb_get_device_descriptor(devs[i], &ddesc) != 0) {
continue;
}
if (ddesc.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
QTAILQ_FOREACH(s, &hostdevs, next) {
f = &s->match;
if (f->bus_num > 0 &&
f->bus_num != libusb_get_bus_number(devs[i])) {
continue;
}
if (f->addr > 0 &&
f->addr != libusb_get_device_address(devs[i])) {
continue;
}
if (f->port != NULL) {
char port[16] = "-";
usb_host_get_port(devs[i], port, sizeof(port));
if (strcmp(f->port, port) != 0) {
continue;
}
}
if (f->vendor_id > 0 &&
f->vendor_id != ddesc.idVendor) {
continue;
}
if (f->product_id > 0 &&
f->product_id != ddesc.idProduct) {
continue;
}
/* We got a match */
s->seen++;
if (s->errcount >= 3) {
continue;
}
if (s->dh != NULL) {
continue;
}
if (usb_host_open(s, devs[i]) < 0) {
s->errcount++;
continue;
}
break;
}
}
libusb_free_device_list(devs, 1);
QTAILQ_FOREACH(s, &hostdevs, next) {
if (s->dh == NULL) {
unconnected++;
}
if (s->seen == 0) {
if (s->dh) {
usb_host_close(s);
}
s->errcount = 0;
}
s->seen = 0;
}
#if 0
if (unconnected == 0) {
/* nothing to watch */
if (usb_auto_timer) {
timer_del(usb_auto_timer);
trace_usb_host_auto_scan_disabled();
}
return;
}
#endif
}
if (!usb_vmstate) {
usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL);
}
if (!usb_auto_timer) {
usb_auto_timer = timer_new_ms(QEMU_CLOCK_REALTIME, usb_host_auto_check, NULL);
if (!usb_auto_timer) {
return;
}
trace_usb_host_auto_scan_enabled();
}
timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000);
}
| true | qemu | 3ce21445387c64032a21ae73c995195307a28a36 | static void usb_host_auto_check(void *unused)
{
struct USBHostDevice *s;
struct USBAutoFilter *f;
libusb_device **devs;
struct libusb_device_descriptor ddesc;
int unconnected = 0;
int i, n;
if (usb_host_init() != 0) {
return;
}
if (runstate_is_running()) {
n = libusb_get_device_list(ctx, &devs);
for (i = 0; i < n; i++) {
if (libusb_get_device_descriptor(devs[i], &ddesc) != 0) {
continue;
}
if (ddesc.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
QTAILQ_FOREACH(s, &hostdevs, next) {
f = &s->match;
if (f->bus_num > 0 &&
f->bus_num != libusb_get_bus_number(devs[i])) {
continue;
}
if (f->addr > 0 &&
f->addr != libusb_get_device_address(devs[i])) {
continue;
}
if (f->port != NULL) {
char port[16] = "-";
usb_host_get_port(devs[i], port, sizeof(port));
if (strcmp(f->port, port) != 0) {
continue;
}
}
if (f->vendor_id > 0 &&
f->vendor_id != ddesc.idVendor) {
continue;
}
if (f->product_id > 0 &&
f->product_id != ddesc.idProduct) {
continue;
}
s->seen++;
if (s->errcount >= 3) {
continue;
}
if (s->dh != NULL) {
continue;
}
if (usb_host_open(s, devs[i]) < 0) {
s->errcount++;
continue;
}
break;
}
}
libusb_free_device_list(devs, 1);
QTAILQ_FOREACH(s, &hostdevs, next) {
if (s->dh == NULL) {
unconnected++;
}
if (s->seen == 0) {
if (s->dh) {
usb_host_close(s);
}
s->errcount = 0;
}
s->seen = 0;
}
#if 0
if (unconnected == 0) {
if (usb_auto_timer) {
timer_del(usb_auto_timer);
trace_usb_host_auto_scan_disabled();
}
return;
}
#endif
}
if (!usb_vmstate) {
usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL);
}
if (!usb_auto_timer) {
usb_auto_timer = timer_new_ms(QEMU_CLOCK_REALTIME, usb_host_auto_check, NULL);
if (!usb_auto_timer) {
return;
}
trace_usb_host_auto_scan_enabled();
}
timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000);
}
| {
"code": [
" libusb_device **devs;",
" libusb_device **devs;"
],
"line_no": [
9,
9
]
} | static void FUNC_0(void *VAR_0)
{
struct USBHostDevice *VAR_1;
struct USBAutoFilter *VAR_2;
libusb_device **devs;
struct libusb_device_descriptor VAR_3;
int VAR_4 = 0;
int VAR_5, VAR_6;
if (usb_host_init() != 0) {
return;
}
if (runstate_is_running()) {
VAR_6 = libusb_get_device_list(ctx, &devs);
for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {
if (libusb_get_device_descriptor(devs[VAR_5], &VAR_3) != 0) {
continue;
}
if (VAR_3.bDeviceClass == LIBUSB_CLASS_HUB) {
continue;
}
QTAILQ_FOREACH(VAR_1, &hostdevs, next) {
VAR_2 = &VAR_1->match;
if (VAR_2->bus_num > 0 &&
VAR_2->bus_num != libusb_get_bus_number(devs[VAR_5])) {
continue;
}
if (VAR_2->addr > 0 &&
VAR_2->addr != libusb_get_device_address(devs[VAR_5])) {
continue;
}
if (VAR_2->port != NULL) {
char port[16] = "-";
usb_host_get_port(devs[VAR_5], port, sizeof(port));
if (strcmp(VAR_2->port, port) != 0) {
continue;
}
}
if (VAR_2->vendor_id > 0 &&
VAR_2->vendor_id != VAR_3.idVendor) {
continue;
}
if (VAR_2->product_id > 0 &&
VAR_2->product_id != VAR_3.idProduct) {
continue;
}
VAR_1->seen++;
if (VAR_1->errcount >= 3) {
continue;
}
if (VAR_1->dh != NULL) {
continue;
}
if (usb_host_open(VAR_1, devs[VAR_5]) < 0) {
VAR_1->errcount++;
continue;
}
break;
}
}
libusb_free_device_list(devs, 1);
QTAILQ_FOREACH(VAR_1, &hostdevs, next) {
if (VAR_1->dh == NULL) {
VAR_4++;
}
if (VAR_1->seen == 0) {
if (VAR_1->dh) {
usb_host_close(VAR_1);
}
VAR_1->errcount = 0;
}
VAR_1->seen = 0;
}
#if 0
if (VAR_4 == 0) {
if (usb_auto_timer) {
timer_del(usb_auto_timer);
trace_usb_host_auto_scan_disabled();
}
return;
}
#endif
}
if (!usb_vmstate) {
usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL);
}
if (!usb_auto_timer) {
usb_auto_timer = timer_new_ms(QEMU_CLOCK_REALTIME, FUNC_0, NULL);
if (!usb_auto_timer) {
return;
}
trace_usb_host_auto_scan_enabled();
}
timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct USBHostDevice *VAR_1;",
"struct USBAutoFilter *VAR_2;",
"libusb_device **devs;",
"struct libusb_device_descriptor VAR_3;",
"int VAR_4 = 0;",
"int VAR_5, VAR_6;",
"if (usb_host_init() != 0) {",
"return;",
"}",
"if (runstate_is_running()) {",
"VAR_6 = libusb_get_device_list(ctx, &devs);",
"for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) {",
"if (libusb_get_device_descriptor(devs[VAR_5], &VAR_3) != 0) {",
"continue;",
"}",
"if (VAR_3.bDeviceClass == LIBUSB_CLASS_HUB) {",
"continue;",
"}",
"QTAILQ_FOREACH(VAR_1, &hostdevs, next) {",
"VAR_2 = &VAR_1->match;",
"if (VAR_2->bus_num > 0 &&\nVAR_2->bus_num != libusb_get_bus_number(devs[VAR_5])) {",
"continue;",
"}",
"if (VAR_2->addr > 0 &&\nVAR_2->addr != libusb_get_device_address(devs[VAR_5])) {",
"continue;",
"}",
"if (VAR_2->port != NULL) {",
"char port[16] = \"-\";",
"usb_host_get_port(devs[VAR_5], port, sizeof(port));",
"if (strcmp(VAR_2->port, port) != 0) {",
"continue;",
"}",
"}",
"if (VAR_2->vendor_id > 0 &&\nVAR_2->vendor_id != VAR_3.idVendor) {",
"continue;",
"}",
"if (VAR_2->product_id > 0 &&\nVAR_2->product_id != VAR_3.idProduct) {",
"continue;",
"}",
"VAR_1->seen++;",
"if (VAR_1->errcount >= 3) {",
"continue;",
"}",
"if (VAR_1->dh != NULL) {",
"continue;",
"}",
"if (usb_host_open(VAR_1, devs[VAR_5]) < 0) {",
"VAR_1->errcount++;",
"continue;",
"}",
"break;",
"}",
"}",
"libusb_free_device_list(devs, 1);",
"QTAILQ_FOREACH(VAR_1, &hostdevs, next) {",
"if (VAR_1->dh == NULL) {",
"VAR_4++;",
"}",
"if (VAR_1->seen == 0) {",
"if (VAR_1->dh) {",
"usb_host_close(VAR_1);",
"}",
"VAR_1->errcount = 0;",
"}",
"VAR_1->seen = 0;",
"}",
"#if 0\nif (VAR_4 == 0) {",
"if (usb_auto_timer) {",
"timer_del(usb_auto_timer);",
"trace_usb_host_auto_scan_disabled();",
"}",
"return;",
"}",
"#endif\n}",
"if (!usb_vmstate) {",
"usb_vmstate = qemu_add_vm_change_state_handler(usb_host_vm_state, NULL);",
"}",
"if (!usb_auto_timer) {",
"usb_auto_timer = timer_new_ms(QEMU_CLOCK_REALTIME, FUNC_0, NULL);",
"if (!usb_auto_timer) {",
"return;",
"}",
"trace_usb_host_auto_scan_enabled();",
"}",
"timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000);",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
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
],
[
157,
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
]
] |
21,964 | int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
{
#ifdef CONFIG_PROFILER
TCGProfile *prof = &s->prof;
#endif
int i, oi, oi_next, num_insns;
#ifdef CONFIG_PROFILER
{
int n;
n = s->gen_op_buf[0].prev + 1;
atomic_set(&prof->op_count, prof->op_count + n);
if (n > prof->op_count_max) {
atomic_set(&prof->op_count_max, n);
}
n = s->nb_temps;
atomic_set(&prof->temp_count, prof->temp_count + n);
if (n > prof->temp_count_max) {
atomic_set(&prof->temp_count_max, n);
}
}
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time - profile_getclock());
#endif
#ifdef USE_TCG_OPTIMIZATIONS
tcg_optimize(s);
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time + profile_getclock());
atomic_set(&prof->la_time, prof->la_time - profile_getclock());
#endif
liveness_pass_1(s);
if (s->nb_indirects > 0) {
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP before indirect lowering:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
/* Replace indirect temps with direct temps. */
if (liveness_pass_2(s)) {
/* If changes were made, re-run liveness. */
liveness_pass_1(s);
}
}
#ifdef CONFIG_PROFILER
atomic_set(&prof->la_time, prof->la_time + profile_getclock());
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP after optimization and liveness analysis:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
tcg_reg_alloc_start(s);
s->code_buf = tb->tc.ptr;
s->code_ptr = tb->tc.ptr;
#ifdef TCG_TARGET_NEED_LDST_LABELS
s->ldst_labels = NULL;
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
s->pool_labels = NULL;
#endif
num_insns = -1;
for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {
TCGOp * const op = &s->gen_op_buf[oi];
TCGOpcode opc = op->opc;
oi_next = op->next;
#ifdef CONFIG_PROFILER
atomic_set(&prof->table_op_count[opc], prof->table_op_count[opc] + 1);
#endif
switch (opc) {
case INDEX_op_mov_i32:
case INDEX_op_mov_i64:
tcg_reg_alloc_mov(s, op);
break;
case INDEX_op_movi_i32:
case INDEX_op_movi_i64:
tcg_reg_alloc_movi(s, op);
break;
case INDEX_op_insn_start:
if (num_insns >= 0) {
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
}
num_insns++;
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a;
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
a = deposit64(op->args[i * 2], 32, 32, op->args[i * 2 + 1]);
#else
a = op->args[i];
#endif
s->gen_insn_data[num_insns][i] = a;
}
break;
case INDEX_op_discard:
temp_dead(s, arg_temp(op->args[0]));
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s, s->reserved_regs);
tcg_out_label(s, arg_label(op->args[0]), s->code_ptr);
break;
case INDEX_op_call:
tcg_reg_alloc_call(s, op);
break;
default:
/* Sanity check that we've not introduced any unhandled opcodes. */
tcg_debug_assert(tcg_op_supported(opc));
/* Note: in order to speed up the code, it would be much
faster to have specialized register allocator functions for
some common argument patterns */
tcg_reg_alloc_op(s, op);
break;
}
#ifdef CONFIG_DEBUG_TCG
check_regs(s);
#endif
/* Test for (pending) buffer overflow. The assumption is that any
one operation beginning below the high water mark cannot overrun
the buffer completely. Thus we can test for overflow after
generating code without having to check during generation. */
if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) {
return -1;
}
}
tcg_debug_assert(num_insns >= 0);
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
/* Generate TB finalization at the end of block */
#ifdef TCG_TARGET_NEED_LDST_LABELS
if (!tcg_out_ldst_finalize(s)) {
return -1;
}
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
if (!tcg_out_pool_finalize(s)) {
return -1;
}
#endif
/* flush instruction cache */
flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr);
return tcg_current_code_size(s);
}
| true | qemu | 15fa08f8451babc88d733bd411d4c94976f9d0f8 | int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
{
#ifdef CONFIG_PROFILER
TCGProfile *prof = &s->prof;
#endif
int i, oi, oi_next, num_insns;
#ifdef CONFIG_PROFILER
{
int n;
n = s->gen_op_buf[0].prev + 1;
atomic_set(&prof->op_count, prof->op_count + n);
if (n > prof->op_count_max) {
atomic_set(&prof->op_count_max, n);
}
n = s->nb_temps;
atomic_set(&prof->temp_count, prof->temp_count + n);
if (n > prof->temp_count_max) {
atomic_set(&prof->temp_count_max, n);
}
}
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time - profile_getclock());
#endif
#ifdef USE_TCG_OPTIMIZATIONS
tcg_optimize(s);
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time + profile_getclock());
atomic_set(&prof->la_time, prof->la_time - profile_getclock());
#endif
liveness_pass_1(s);
if (s->nb_indirects > 0) {
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP before indirect lowering:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
if (liveness_pass_2(s)) {
liveness_pass_1(s);
}
}
#ifdef CONFIG_PROFILER
atomic_set(&prof->la_time, prof->la_time + profile_getclock());
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
&& qemu_log_in_addr_range(tb->pc))) {
qemu_log_lock();
qemu_log("OP after optimization and liveness analysis:\n");
tcg_dump_ops(s);
qemu_log("\n");
qemu_log_unlock();
}
#endif
tcg_reg_alloc_start(s);
s->code_buf = tb->tc.ptr;
s->code_ptr = tb->tc.ptr;
#ifdef TCG_TARGET_NEED_LDST_LABELS
s->ldst_labels = NULL;
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
s->pool_labels = NULL;
#endif
num_insns = -1;
for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {
TCGOp * const op = &s->gen_op_buf[oi];
TCGOpcode opc = op->opc;
oi_next = op->next;
#ifdef CONFIG_PROFILER
atomic_set(&prof->table_op_count[opc], prof->table_op_count[opc] + 1);
#endif
switch (opc) {
case INDEX_op_mov_i32:
case INDEX_op_mov_i64:
tcg_reg_alloc_mov(s, op);
break;
case INDEX_op_movi_i32:
case INDEX_op_movi_i64:
tcg_reg_alloc_movi(s, op);
break;
case INDEX_op_insn_start:
if (num_insns >= 0) {
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
}
num_insns++;
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a;
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
a = deposit64(op->args[i * 2], 32, 32, op->args[i * 2 + 1]);
#else
a = op->args[i];
#endif
s->gen_insn_data[num_insns][i] = a;
}
break;
case INDEX_op_discard:
temp_dead(s, arg_temp(op->args[0]));
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s, s->reserved_regs);
tcg_out_label(s, arg_label(op->args[0]), s->code_ptr);
break;
case INDEX_op_call:
tcg_reg_alloc_call(s, op);
break;
default:
tcg_debug_assert(tcg_op_supported(opc));
tcg_reg_alloc_op(s, op);
break;
}
#ifdef CONFIG_DEBUG_TCG
check_regs(s);
#endif
if (unlikely((void *)s->code_ptr > s->code_gen_highwater)) {
return -1;
}
}
tcg_debug_assert(num_insns >= 0);
s->gen_insn_end_off[num_insns] = tcg_current_code_size(s);
#ifdef TCG_TARGET_NEED_LDST_LABELS
if (!tcg_out_ldst_finalize(s)) {
return -1;
}
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
if (!tcg_out_pool_finalize(s)) {
return -1;
}
#endif
flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr);
return tcg_current_code_size(s);
}
| {
"code": [
"#endif",
" for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {",
" TCGOp * const op = &s->gen_op_buf[oi];",
" oi_next = op->next;",
" TCGOp * const op = &s->gen_op_buf[oi];",
" for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {",
" oi_next = op->next;",
" int i, oi, oi_next, num_insns;",
" n = s->gen_op_buf[0].prev + 1;",
" for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {",
" TCGOp * const op = &s->gen_op_buf[oi];",
" oi_next = op->next;"
],
"line_no": [
9,
195,
197,
203,
197,
195,
203,
11,
23,
195,
197,
203
]
} | int FUNC_0(TCGContext *VAR_0, TranslationBlock *VAR_1)
{
#ifdef CONFIG_PROFILER
TCGProfile *prof = &VAR_0->prof;
#endif
int VAR_2, VAR_3, VAR_4, VAR_5;
#ifdef CONFIG_PROFILER
{
int n;
n = VAR_0->gen_op_buf[0].prev + 1;
atomic_set(&prof->op_count, prof->op_count + n);
if (n > prof->op_count_max) {
atomic_set(&prof->op_count_max, n);
}
n = VAR_0->nb_temps;
atomic_set(&prof->temp_count, prof->temp_count + n);
if (n > prof->temp_count_max) {
atomic_set(&prof->temp_count_max, n);
}
}
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)
&& qemu_log_in_addr_range(VAR_1->pc))) {
qemu_log_lock();
qemu_log("OP:\n");
tcg_dump_ops(VAR_0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time - profile_getclock());
#endif
#ifdef USE_TCG_OPTIMIZATIONS
tcg_optimize(VAR_0);
#endif
#ifdef CONFIG_PROFILER
atomic_set(&prof->opt_time, prof->opt_time + profile_getclock());
atomic_set(&prof->la_time, prof->la_time - profile_getclock());
#endif
liveness_pass_1(VAR_0);
if (VAR_0->nb_indirects > 0) {
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)
&& qemu_log_in_addr_range(VAR_1->pc))) {
qemu_log_lock();
qemu_log("OP before indirect lowering:\n");
tcg_dump_ops(VAR_0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
if (liveness_pass_2(VAR_0)) {
liveness_pass_1(VAR_0);
}
}
#ifdef CONFIG_PROFILER
atomic_set(&prof->la_time, prof->la_time + profile_getclock());
#endif
#ifdef DEBUG_DISAS
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)
&& qemu_log_in_addr_range(VAR_1->pc))) {
qemu_log_lock();
qemu_log("OP after optimization and liveness analysis:\n");
tcg_dump_ops(VAR_0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
tcg_reg_alloc_start(VAR_0);
VAR_0->code_buf = VAR_1->tc.ptr;
VAR_0->code_ptr = VAR_1->tc.ptr;
#ifdef TCG_TARGET_NEED_LDST_LABELS
VAR_0->ldst_labels = NULL;
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
VAR_0->pool_labels = NULL;
#endif
VAR_5 = -1;
for (VAR_3 = VAR_0->gen_op_buf[0].next; VAR_3 != 0; VAR_3 = VAR_4) {
TCGOp * const op = &VAR_0->gen_op_buf[VAR_3];
TCGOpcode opc = op->opc;
VAR_4 = op->next;
#ifdef CONFIG_PROFILER
atomic_set(&prof->table_op_count[opc], prof->table_op_count[opc] + 1);
#endif
switch (opc) {
case INDEX_op_mov_i32:
case INDEX_op_mov_i64:
tcg_reg_alloc_mov(VAR_0, op);
break;
case INDEX_op_movi_i32:
case INDEX_op_movi_i64:
tcg_reg_alloc_movi(VAR_0, op);
break;
case INDEX_op_insn_start:
if (VAR_5 >= 0) {
VAR_0->gen_insn_end_off[VAR_5] = tcg_current_code_size(VAR_0);
}
VAR_5++;
for (VAR_2 = 0; VAR_2 < TARGET_INSN_START_WORDS; ++VAR_2) {
target_ulong a;
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
a = deposit64(op->args[VAR_2 * 2], 32, 32, op->args[VAR_2 * 2 + 1]);
#else
a = op->args[VAR_2];
#endif
VAR_0->gen_insn_data[VAR_5][VAR_2] = a;
}
break;
case INDEX_op_discard:
temp_dead(VAR_0, arg_temp(op->args[0]));
break;
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(VAR_0, VAR_0->reserved_regs);
tcg_out_label(VAR_0, arg_label(op->args[0]), VAR_0->code_ptr);
break;
case INDEX_op_call:
tcg_reg_alloc_call(VAR_0, op);
break;
default:
tcg_debug_assert(tcg_op_supported(opc));
tcg_reg_alloc_op(VAR_0, op);
break;
}
#ifdef CONFIG_DEBUG_TCG
check_regs(VAR_0);
#endif
if (unlikely((void *)VAR_0->code_ptr > VAR_0->code_gen_highwater)) {
return -1;
}
}
tcg_debug_assert(VAR_5 >= 0);
VAR_0->gen_insn_end_off[VAR_5] = tcg_current_code_size(VAR_0);
#ifdef TCG_TARGET_NEED_LDST_LABELS
if (!tcg_out_ldst_finalize(VAR_0)) {
return -1;
}
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
if (!tcg_out_pool_finalize(VAR_0)) {
return -1;
}
#endif
flush_icache_range((uintptr_t)VAR_0->code_buf, (uintptr_t)VAR_0->code_ptr);
return tcg_current_code_size(VAR_0);
}
| [
"int FUNC_0(TCGContext *VAR_0, TranslationBlock *VAR_1)\n{",
"#ifdef CONFIG_PROFILER\nTCGProfile *prof = &VAR_0->prof;",
"#endif\nint VAR_2, VAR_3, VAR_4, VAR_5;",
"#ifdef CONFIG_PROFILER\n{",
"int n;",
"n = VAR_0->gen_op_buf[0].prev + 1;",
"atomic_set(&prof->op_count, prof->op_count + n);",
"if (n > prof->op_count_max) {",
"atomic_set(&prof->op_count_max, n);",
"}",
"n = VAR_0->nb_temps;",
"atomic_set(&prof->temp_count, prof->temp_count + n);",
"if (n > prof->temp_count_max) {",
"atomic_set(&prof->temp_count_max, n);",
"}",
"}",
"#endif\n#ifdef DEBUG_DISAS\nif (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)\n&& qemu_log_in_addr_range(VAR_1->pc))) {",
"qemu_log_lock();",
"qemu_log(\"OP:\\n\");",
"tcg_dump_ops(VAR_0);",
"qemu_log(\"\\n\");",
"qemu_log_unlock();",
"}",
"#endif\n#ifdef CONFIG_PROFILER\natomic_set(&prof->opt_time, prof->opt_time - profile_getclock());",
"#endif\n#ifdef USE_TCG_OPTIMIZATIONS\ntcg_optimize(VAR_0);",
"#endif\n#ifdef CONFIG_PROFILER\natomic_set(&prof->opt_time, prof->opt_time + profile_getclock());",
"atomic_set(&prof->la_time, prof->la_time - profile_getclock());",
"#endif\nliveness_pass_1(VAR_0);",
"if (VAR_0->nb_indirects > 0) {",
"#ifdef DEBUG_DISAS\nif (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND)\n&& qemu_log_in_addr_range(VAR_1->pc))) {",
"qemu_log_lock();",
"qemu_log(\"OP before indirect lowering:\\n\");",
"tcg_dump_ops(VAR_0);",
"qemu_log(\"\\n\");",
"qemu_log_unlock();",
"}",
"#endif\nif (liveness_pass_2(VAR_0)) {",
"liveness_pass_1(VAR_0);",
"}",
"}",
"#ifdef CONFIG_PROFILER\natomic_set(&prof->la_time, prof->la_time + profile_getclock());",
"#endif\n#ifdef DEBUG_DISAS\nif (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT)\n&& qemu_log_in_addr_range(VAR_1->pc))) {",
"qemu_log_lock();",
"qemu_log(\"OP after optimization and liveness analysis:\\n\");",
"tcg_dump_ops(VAR_0);",
"qemu_log(\"\\n\");",
"qemu_log_unlock();",
"}",
"#endif\ntcg_reg_alloc_start(VAR_0);",
"VAR_0->code_buf = VAR_1->tc.ptr;",
"VAR_0->code_ptr = VAR_1->tc.ptr;",
"#ifdef TCG_TARGET_NEED_LDST_LABELS\nVAR_0->ldst_labels = NULL;",
"#endif\n#ifdef TCG_TARGET_NEED_POOL_LABELS\nVAR_0->pool_labels = NULL;",
"#endif\nVAR_5 = -1;",
"for (VAR_3 = VAR_0->gen_op_buf[0].next; VAR_3 != 0; VAR_3 = VAR_4) {",
"TCGOp * const op = &VAR_0->gen_op_buf[VAR_3];",
"TCGOpcode opc = op->opc;",
"VAR_4 = op->next;",
"#ifdef CONFIG_PROFILER\natomic_set(&prof->table_op_count[opc], prof->table_op_count[opc] + 1);",
"#endif\nswitch (opc) {",
"case INDEX_op_mov_i32:\ncase INDEX_op_mov_i64:\ntcg_reg_alloc_mov(VAR_0, op);",
"break;",
"case INDEX_op_movi_i32:\ncase INDEX_op_movi_i64:\ntcg_reg_alloc_movi(VAR_0, op);",
"break;",
"case INDEX_op_insn_start:\nif (VAR_5 >= 0) {",
"VAR_0->gen_insn_end_off[VAR_5] = tcg_current_code_size(VAR_0);",
"}",
"VAR_5++;",
"for (VAR_2 = 0; VAR_2 < TARGET_INSN_START_WORDS; ++VAR_2) {",
"target_ulong a;",
"#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS\na = deposit64(op->args[VAR_2 * 2], 32, 32, op->args[VAR_2 * 2 + 1]);",
"#else\na = op->args[VAR_2];",
"#endif\nVAR_0->gen_insn_data[VAR_5][VAR_2] = a;",
"}",
"break;",
"case INDEX_op_discard:\ntemp_dead(VAR_0, arg_temp(op->args[0]));",
"break;",
"case INDEX_op_set_label:\ntcg_reg_alloc_bb_end(VAR_0, VAR_0->reserved_regs);",
"tcg_out_label(VAR_0, arg_label(op->args[0]), VAR_0->code_ptr);",
"break;",
"case INDEX_op_call:\ntcg_reg_alloc_call(VAR_0, op);",
"break;",
"default:\ntcg_debug_assert(tcg_op_supported(opc));",
"tcg_reg_alloc_op(VAR_0, op);",
"break;",
"}",
"#ifdef CONFIG_DEBUG_TCG\ncheck_regs(VAR_0);",
"#endif\nif (unlikely((void *)VAR_0->code_ptr > VAR_0->code_gen_highwater)) {",
"return -1;",
"}",
"}",
"tcg_debug_assert(VAR_5 >= 0);",
"VAR_0->gen_insn_end_off[VAR_5] = tcg_current_code_size(VAR_0);",
"#ifdef TCG_TARGET_NEED_LDST_LABELS\nif (!tcg_out_ldst_finalize(VAR_0)) {",
"return -1;",
"}",
"#endif\n#ifdef TCG_TARGET_NEED_POOL_LABELS\nif (!tcg_out_pool_finalize(VAR_0)) {",
"return -1;",
"}",
"#endif\nflush_icache_range((uintptr_t)VAR_0->code_buf, (uintptr_t)VAR_0->code_ptr);",
"return tcg_current_code_size(VAR_0);",
"}"
] | [
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
15,
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
73,
75
],
[
77,
81,
83
],
[
85,
89,
91
],
[
93
],
[
95,
99
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
127
],
[
131
],
[
133
],
[
135
],
[
139,
141
],
[
143,
147,
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
169
],
[
173
],
[
175
],
[
179,
181
],
[
183,
185,
187
],
[
189,
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205,
207
],
[
209,
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,
285
],
[
293
],
[
295
],
[
297
],
[
299,
301
],
[
303,
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
329,
331
],
[
333
],
[
335
],
[
337,
339,
341
],
[
343
],
[
345
],
[
347,
353
],
[
357
],
[
359
]
] |
21,965 | void palette_destroy(VncPalette *palette)
{
if (palette == NULL) {
qemu_free(palette);
}
}
| true | qemu | d6e58090fed20e30e6966007bc4df0c04324d9e7 | void palette_destroy(VncPalette *palette)
{
if (palette == NULL) {
qemu_free(palette);
}
}
| {
"code": [
" if (palette == NULL) {",
" qemu_free(palette);"
],
"line_no": [
5,
7
]
} | void FUNC_0(VncPalette *VAR_0)
{
if (VAR_0 == NULL) {
qemu_free(VAR_0);
}
}
| [
"void FUNC_0(VncPalette *VAR_0)\n{",
"if (VAR_0 == NULL) {",
"qemu_free(VAR_0);",
"}",
"}"
] | [
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
21,966 | static int ivshmem_setup_interrupts(IVShmemState *s)
{
/* allocate QEMU callback data for receiving interrupts */
s->msi_vectors = g_malloc0(s->vectors * sizeof(MSIVector));
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1)) {
return -1;
}
IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
ivshmem_msix_vector_use(s);
}
return 0;
}
| true | qemu | ee640c625e190a0c0e6b8966adc0e4720fb75200 | static int ivshmem_setup_interrupts(IVShmemState *s)
{
s->msi_vectors = g_malloc0(s->vectors * sizeof(MSIVector));
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1)) {
return -1;
}
IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
ivshmem_msix_vector_use(s);
}
return 0;
}
| {
"code": [
"static int ivshmem_setup_interrupts(IVShmemState *s)",
" if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1)) {"
],
"line_no": [
1,
13
]
} | static int FUNC_0(IVShmemState *VAR_0)
{
VAR_0->msi_vectors = g_malloc0(VAR_0->vectors * sizeof(MSIVector));
if (ivshmem_has_feature(VAR_0, IVSHMEM_MSI)) {
if (msix_init_exclusive_bar(PCI_DEVICE(VAR_0), VAR_0->vectors, 1)) {
return -1;
}
IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", VAR_0->vectors);
ivshmem_msix_vector_use(VAR_0);
}
return 0;
}
| [
"static int FUNC_0(IVShmemState *VAR_0)\n{",
"VAR_0->msi_vectors = g_malloc0(VAR_0->vectors * sizeof(MSIVector));",
"if (ivshmem_has_feature(VAR_0, IVSHMEM_MSI)) {",
"if (msix_init_exclusive_bar(PCI_DEVICE(VAR_0), VAR_0->vectors, 1)) {",
"return -1;",
"}",
"IVSHMEM_DPRINTF(\"msix initialized (%d vectors)\\n\", VAR_0->vectors);",
"ivshmem_msix_vector_use(VAR_0);",
"}",
"return 0;",
"}"
] | [
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
21,968 | static int wavpack_encode_block(WavPackEncodeContext *s,
int32_t *samples_l, int32_t *samples_r,
uint8_t *out, int out_size)
{
int block_size, start, end, data_size, tcount, temp, m = 0;
int i, j, ret = 0, got_extra = 0, nb_samples = s->block_samples;
uint32_t crc = 0xffffffffu;
struct Decorr *dpp;
PutByteContext pb;
if (!(s->flags & WV_MONO) && s->optimize_mono) {
int32_t lor = 0, diff = 0;
for (i = 0; i < nb_samples; i++) {
lor |= samples_l[i] | samples_r[i];
diff |= samples_l[i] - samples_r[i];
if (lor && diff)
break;
}
if (i == nb_samples && lor && !diff) {
s->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR);
s->flags |= WV_FALSE_STEREO;
if (!s->false_stereo) {
s->false_stereo = 1;
s->num_terms = 0;
CLEAR(s->w);
}
} else if (s->false_stereo) {
s->false_stereo = 0;
s->num_terms = 0;
CLEAR(s->w);
}
}
if (s->flags & SHIFT_MASK) {
int shift = (s->flags & SHIFT_MASK) >> SHIFT_LSB;
int mag = (s->flags & MAG_MASK) >> MAG_LSB;
if (s->flags & WV_MONO_DATA)
shift_mono(samples_l, nb_samples, shift);
else
shift_stereo(samples_l, samples_r, nb_samples, shift);
if ((mag -= shift) < 0)
s->flags &= ~MAG_MASK;
else
s->flags -= (1 << MAG_LSB) * shift;
}
if ((s->flags & WV_FLOAT_DATA) || (s->flags & MAG_MASK) >> MAG_LSB >= 24) {
av_fast_padded_malloc(&s->orig_l, &s->orig_l_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_l, samples_l, sizeof(int32_t) * nb_samples);
if (!(s->flags & WV_MONO_DATA)) {
av_fast_padded_malloc(&s->orig_r, &s->orig_r_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_r, samples_r, sizeof(int32_t) * nb_samples);
}
if (s->flags & WV_FLOAT_DATA)
got_extra = scan_float(s, samples_l, samples_r, nb_samples);
else
got_extra = scan_int32(s, samples_l, samples_r, nb_samples);
s->num_terms = 0;
} else {
scan_int23(s, samples_l, samples_r, nb_samples);
if (s->shift != s->int32_zeros + s->int32_ones + s->int32_dups) {
s->shift = s->int32_zeros + s->int32_ones + s->int32_dups;
s->num_terms = 0;
}
}
if (!s->num_passes && !s->num_terms) {
s->num_passes = 1;
if (s->flags & WV_MONO_DATA)
ret = wv_mono(s, samples_l, 1, 0);
else
ret = wv_stereo(s, samples_l, samples_r, 1, 0);
s->num_passes = 0;
}
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
crc += (crc << 1) + samples_l[i];
if (s->num_passes)
ret = wv_mono(s, samples_l, !s->num_terms, 1);
} else {
for (i = 0; i < nb_samples; i++)
crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
if (s->num_passes)
ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);
}
if (ret < 0)
return ret;
if (!s->ch_offset)
s->flags |= WV_INITIAL_BLOCK;
s->ch_offset += 1 + !(s->flags & WV_MONO);
if (s->ch_offset == s->avctx->channels)
s->flags |= WV_FINAL_BLOCK;
bytestream2_init_writer(&pb, out, out_size);
bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'k'));
bytestream2_put_le32(&pb, 0);
bytestream2_put_le16(&pb, 0x410);
bytestream2_put_le16(&pb, 0);
bytestream2_put_le32(&pb, 0);
bytestream2_put_le32(&pb, s->sample_index);
bytestream2_put_le32(&pb, nb_samples);
bytestream2_put_le32(&pb, s->flags);
bytestream2_put_le32(&pb, crc);
if (s->flags & WV_INITIAL_BLOCK &&
s->avctx->channel_layout != AV_CH_LAYOUT_MONO &&
s->avctx->channel_layout != AV_CH_LAYOUT_STEREO) {
put_metadata_block(&pb, WP_ID_CHANINFO, 5);
bytestream2_put_byte(&pb, s->avctx->channels);
bytestream2_put_le32(&pb, s->avctx->channel_layout);
bytestream2_put_byte(&pb, 0);
}
if ((s->flags & SRATE_MASK) == SRATE_MASK) {
put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3);
bytestream2_put_le24(&pb, s->avctx->sample_rate);
bytestream2_put_byte(&pb, 0);
}
put_metadata_block(&pb, WP_ID_DECTERMS, s->num_terms);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
bytestream2_put_byte(&pb, ((dpp->value + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0));
}
if (s->num_terms & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECWEIGHT(type) do { \
temp = store_weight(type); \
bytestream2_put_byte(&pb, temp); \
type = restore_weight(temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = s->num_terms - 1; i >= 0; --i) {
struct Decorr *dpp = &s->decorr_passes[i];
if (store_weight(dpp->weightA) ||
(!(s->flags & WV_MONO_DATA) && store_weight(dpp->weightB)))
break;
}
tcount = i + 1;
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i < tcount) {
WRITE_DECWEIGHT(dpp->weightA);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECWEIGHT(dpp->weightB);
} else {
dpp->weightA = dpp->weightB = 0;
}
}
end = bytestream2_tell_p(&pb);
out[start - 2] = WP_ID_DECWEIGHTS | (((end - start) & 1) ? WP_IDF_ODD: 0);
out[start - 1] = (end - start + 1) >> 1;
if ((end - start) & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECSAMPLE(type) do { \
temp = log2s(type); \
type = wp_exp2(temp); \
bytestream2_put_le16(&pb, temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECSAMPLES);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i == 0) {
if (dpp->value > MAX_TERM) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesA[1]);
if (!(s->flags & WV_MONO_DATA)) {
WRITE_DECSAMPLE(dpp->samplesB[0]);
WRITE_DECSAMPLE(dpp->samplesB[1]);
}
} else if (dpp->value < 0) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesB[0]);
} else {
for (j = 0; j < dpp->value; j++) {
WRITE_DECSAMPLE(dpp->samplesA[j]);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECSAMPLE(dpp->samplesB[j]);
}
}
} else {
CLEAR(dpp->samplesA);
CLEAR(dpp->samplesB);
}
}
end = bytestream2_tell_p(&pb);
out[start - 1] = (end - start) >> 1;
#define WRITE_CHAN_ENTROPY(chan) do { \
for (i = 0; i < 3; i++) { \
temp = wp_log2(s->w.c[chan].median[i]); \
bytestream2_put_le16(&pb, temp); \
s->w.c[chan].median[i] = wp_exp2(temp); \
} \
} while (0)
put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(s->flags & WV_MONO_DATA))));
WRITE_CHAN_ENTROPY(0);
if (!(s->flags & WV_MONO_DATA))
WRITE_CHAN_ENTROPY(1);
if (s->flags & WV_FLOAT_DATA) {
put_metadata_block(&pb, WP_ID_FLOATINFO, 4);
bytestream2_put_byte(&pb, s->float_flags);
bytestream2_put_byte(&pb, s->float_shift);
bytestream2_put_byte(&pb, s->float_max_exp);
bytestream2_put_byte(&pb, 127);
}
if (s->flags & WV_INT32_DATA) {
put_metadata_block(&pb, WP_ID_INT32INFO, 4);
bytestream2_put_byte(&pb, s->int32_sent_bits);
bytestream2_put_byte(&pb, s->int32_zeros);
bytestream2_put_byte(&pb, s->int32_ones);
bytestream2_put_byte(&pb, s->int32_dups);
}
if (s->flags & WV_MONO_DATA && !s->num_passes) {
for (i = 0; i < nb_samples; i++) {
int32_t code = samples_l[i];
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++) {
int32_t sam;
if (dpp->value > MAX_TERM) {
if (dpp->value & 1)
sam = 2 * dpp->samplesA[0] - dpp->samplesA[1];
else
sam = (3 * dpp->samplesA[0] - dpp->samplesA[1]) >> 1;
dpp->samplesA[1] = dpp->samplesA[0];
dpp->samplesA[0] = code;
} else {
sam = dpp->samplesA[m];
dpp->samplesA[(m + dpp->value) & (MAX_TERM - 1)] = code;
}
code -= APPLY_WEIGHT(dpp->weightA, sam);
UPDATE_WEIGHT(dpp->weightA, dpp->delta, sam, code);
}
m = (m + 1) & (MAX_TERM - 1);
samples_l[i] = code;
}
if (m) {
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++)
if (dpp->value > 0 && dpp->value <= MAX_TERM) {
int32_t temp_A[MAX_TERM], temp_B[MAX_TERM];
int k;
memcpy(temp_A, dpp->samplesA, sizeof(dpp->samplesA));
memcpy(temp_B, dpp->samplesB, sizeof(dpp->samplesB));
for (k = 0; k < MAX_TERM; k++) {
dpp->samplesA[k] = temp_A[m];
dpp->samplesB[k] = temp_B[m];
m = (m + 1) & (MAX_TERM - 1);
}
}
}
} else if (!s->num_passes) {
if (s->flags & WV_JOINT_STEREO) {
for (i = 0; i < nb_samples; i++)
samples_r[i] += ((samples_l[i] -= samples_r[i]) >> 1);
}
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (((s->flags & MAG_MASK) >> MAG_LSB) >= 16 || dpp->delta != 2)
decorr_stereo_pass2(dpp, samples_l, samples_r, nb_samples);
else
decorr_stereo_pass_id2(dpp, samples_l, samples_r, nb_samples);
}
}
bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
} else {
for (i = 0; i < nb_samples; i++) {
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
wavpack_encode_sample(s, &s->w.c[1], s->samples[1][i]);
}
}
encode_flush(s);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 1) >> 1);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
if (got_extra) {
bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_FLOAT_DATA)
pack_float(s, s->orig_l, s->orig_r, nb_samples);
else
pack_int32(s, s->orig_l, s->orig_r, nb_samples);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 5) >> 1);
bytestream2_put_le32(&pb, s->crc_x);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
}
block_size = bytestream2_tell_p(&pb);
AV_WL32(out + 4, block_size - 8);
return block_size;
} | true | FFmpeg | 4a5cc34b46a8bf8d47ec907383be83b6153b9f69 | static int wavpack_encode_block(WavPackEncodeContext *s,
int32_t *samples_l, int32_t *samples_r,
uint8_t *out, int out_size)
{
int block_size, start, end, data_size, tcount, temp, m = 0;
int i, j, ret = 0, got_extra = 0, nb_samples = s->block_samples;
uint32_t crc = 0xffffffffu;
struct Decorr *dpp;
PutByteContext pb;
if (!(s->flags & WV_MONO) && s->optimize_mono) {
int32_t lor = 0, diff = 0;
for (i = 0; i < nb_samples; i++) {
lor |= samples_l[i] | samples_r[i];
diff |= samples_l[i] - samples_r[i];
if (lor && diff)
break;
}
if (i == nb_samples && lor && !diff) {
s->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR);
s->flags |= WV_FALSE_STEREO;
if (!s->false_stereo) {
s->false_stereo = 1;
s->num_terms = 0;
CLEAR(s->w);
}
} else if (s->false_stereo) {
s->false_stereo = 0;
s->num_terms = 0;
CLEAR(s->w);
}
}
if (s->flags & SHIFT_MASK) {
int shift = (s->flags & SHIFT_MASK) >> SHIFT_LSB;
int mag = (s->flags & MAG_MASK) >> MAG_LSB;
if (s->flags & WV_MONO_DATA)
shift_mono(samples_l, nb_samples, shift);
else
shift_stereo(samples_l, samples_r, nb_samples, shift);
if ((mag -= shift) < 0)
s->flags &= ~MAG_MASK;
else
s->flags -= (1 << MAG_LSB) * shift;
}
if ((s->flags & WV_FLOAT_DATA) || (s->flags & MAG_MASK) >> MAG_LSB >= 24) {
av_fast_padded_malloc(&s->orig_l, &s->orig_l_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_l, samples_l, sizeof(int32_t) * nb_samples);
if (!(s->flags & WV_MONO_DATA)) {
av_fast_padded_malloc(&s->orig_r, &s->orig_r_size, sizeof(int32_t) * nb_samples);
memcpy(s->orig_r, samples_r, sizeof(int32_t) * nb_samples);
}
if (s->flags & WV_FLOAT_DATA)
got_extra = scan_float(s, samples_l, samples_r, nb_samples);
else
got_extra = scan_int32(s, samples_l, samples_r, nb_samples);
s->num_terms = 0;
} else {
scan_int23(s, samples_l, samples_r, nb_samples);
if (s->shift != s->int32_zeros + s->int32_ones + s->int32_dups) {
s->shift = s->int32_zeros + s->int32_ones + s->int32_dups;
s->num_terms = 0;
}
}
if (!s->num_passes && !s->num_terms) {
s->num_passes = 1;
if (s->flags & WV_MONO_DATA)
ret = wv_mono(s, samples_l, 1, 0);
else
ret = wv_stereo(s, samples_l, samples_r, 1, 0);
s->num_passes = 0;
}
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
crc += (crc << 1) + samples_l[i];
if (s->num_passes)
ret = wv_mono(s, samples_l, !s->num_terms, 1);
} else {
for (i = 0; i < nb_samples; i++)
crc += (crc << 3) + (samples_l[i] << 1) + samples_l[i] + samples_r[i];
if (s->num_passes)
ret = wv_stereo(s, samples_l, samples_r, !s->num_terms, 1);
}
if (ret < 0)
return ret;
if (!s->ch_offset)
s->flags |= WV_INITIAL_BLOCK;
s->ch_offset += 1 + !(s->flags & WV_MONO);
if (s->ch_offset == s->avctx->channels)
s->flags |= WV_FINAL_BLOCK;
bytestream2_init_writer(&pb, out, out_size);
bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'k'));
bytestream2_put_le32(&pb, 0);
bytestream2_put_le16(&pb, 0x410);
bytestream2_put_le16(&pb, 0);
bytestream2_put_le32(&pb, 0);
bytestream2_put_le32(&pb, s->sample_index);
bytestream2_put_le32(&pb, nb_samples);
bytestream2_put_le32(&pb, s->flags);
bytestream2_put_le32(&pb, crc);
if (s->flags & WV_INITIAL_BLOCK &&
s->avctx->channel_layout != AV_CH_LAYOUT_MONO &&
s->avctx->channel_layout != AV_CH_LAYOUT_STEREO) {
put_metadata_block(&pb, WP_ID_CHANINFO, 5);
bytestream2_put_byte(&pb, s->avctx->channels);
bytestream2_put_le32(&pb, s->avctx->channel_layout);
bytestream2_put_byte(&pb, 0);
}
if ((s->flags & SRATE_MASK) == SRATE_MASK) {
put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3);
bytestream2_put_le24(&pb, s->avctx->sample_rate);
bytestream2_put_byte(&pb, 0);
}
put_metadata_block(&pb, WP_ID_DECTERMS, s->num_terms);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
bytestream2_put_byte(&pb, ((dpp->value + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0));
}
if (s->num_terms & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECWEIGHT(type) do { \
temp = store_weight(type); \
bytestream2_put_byte(&pb, temp); \
type = restore_weight(temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = s->num_terms - 1; i >= 0; --i) {
struct Decorr *dpp = &s->decorr_passes[i];
if (store_weight(dpp->weightA) ||
(!(s->flags & WV_MONO_DATA) && store_weight(dpp->weightB)))
break;
}
tcount = i + 1;
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i < tcount) {
WRITE_DECWEIGHT(dpp->weightA);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECWEIGHT(dpp->weightB);
} else {
dpp->weightA = dpp->weightB = 0;
}
}
end = bytestream2_tell_p(&pb);
out[start - 2] = WP_ID_DECWEIGHTS | (((end - start) & 1) ? WP_IDF_ODD: 0);
out[start - 1] = (end - start + 1) >> 1;
if ((end - start) & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECSAMPLE(type) do { \
temp = log2s(type); \
type = wp_exp2(temp); \
bytestream2_put_le16(&pb, temp); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECSAMPLES);
bytestream2_put_byte(&pb, 0);
start = bytestream2_tell_p(&pb);
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (i == 0) {
if (dpp->value > MAX_TERM) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesA[1]);
if (!(s->flags & WV_MONO_DATA)) {
WRITE_DECSAMPLE(dpp->samplesB[0]);
WRITE_DECSAMPLE(dpp->samplesB[1]);
}
} else if (dpp->value < 0) {
WRITE_DECSAMPLE(dpp->samplesA[0]);
WRITE_DECSAMPLE(dpp->samplesB[0]);
} else {
for (j = 0; j < dpp->value; j++) {
WRITE_DECSAMPLE(dpp->samplesA[j]);
if (!(s->flags & WV_MONO_DATA))
WRITE_DECSAMPLE(dpp->samplesB[j]);
}
}
} else {
CLEAR(dpp->samplesA);
CLEAR(dpp->samplesB);
}
}
end = bytestream2_tell_p(&pb);
out[start - 1] = (end - start) >> 1;
#define WRITE_CHAN_ENTROPY(chan) do { \
for (i = 0; i < 3; i++) { \
temp = wp_log2(s->w.c[chan].median[i]); \
bytestream2_put_le16(&pb, temp); \
s->w.c[chan].median[i] = wp_exp2(temp); \
} \
} while (0)
put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(s->flags & WV_MONO_DATA))));
WRITE_CHAN_ENTROPY(0);
if (!(s->flags & WV_MONO_DATA))
WRITE_CHAN_ENTROPY(1);
if (s->flags & WV_FLOAT_DATA) {
put_metadata_block(&pb, WP_ID_FLOATINFO, 4);
bytestream2_put_byte(&pb, s->float_flags);
bytestream2_put_byte(&pb, s->float_shift);
bytestream2_put_byte(&pb, s->float_max_exp);
bytestream2_put_byte(&pb, 127);
}
if (s->flags & WV_INT32_DATA) {
put_metadata_block(&pb, WP_ID_INT32INFO, 4);
bytestream2_put_byte(&pb, s->int32_sent_bits);
bytestream2_put_byte(&pb, s->int32_zeros);
bytestream2_put_byte(&pb, s->int32_ones);
bytestream2_put_byte(&pb, s->int32_dups);
}
if (s->flags & WV_MONO_DATA && !s->num_passes) {
for (i = 0; i < nb_samples; i++) {
int32_t code = samples_l[i];
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++) {
int32_t sam;
if (dpp->value > MAX_TERM) {
if (dpp->value & 1)
sam = 2 * dpp->samplesA[0] - dpp->samplesA[1];
else
sam = (3 * dpp->samplesA[0] - dpp->samplesA[1]) >> 1;
dpp->samplesA[1] = dpp->samplesA[0];
dpp->samplesA[0] = code;
} else {
sam = dpp->samplesA[m];
dpp->samplesA[(m + dpp->value) & (MAX_TERM - 1)] = code;
}
code -= APPLY_WEIGHT(dpp->weightA, sam);
UPDATE_WEIGHT(dpp->weightA, dpp->delta, sam, code);
}
m = (m + 1) & (MAX_TERM - 1);
samples_l[i] = code;
}
if (m) {
for (tcount = s->num_terms, dpp = s->decorr_passes; tcount--; dpp++)
if (dpp->value > 0 && dpp->value <= MAX_TERM) {
int32_t temp_A[MAX_TERM], temp_B[MAX_TERM];
int k;
memcpy(temp_A, dpp->samplesA, sizeof(dpp->samplesA));
memcpy(temp_B, dpp->samplesB, sizeof(dpp->samplesB));
for (k = 0; k < MAX_TERM; k++) {
dpp->samplesA[k] = temp_A[m];
dpp->samplesB[k] = temp_B[m];
m = (m + 1) & (MAX_TERM - 1);
}
}
}
} else if (!s->num_passes) {
if (s->flags & WV_JOINT_STEREO) {
for (i = 0; i < nb_samples; i++)
samples_r[i] += ((samples_l[i] -= samples_r[i]) >> 1);
}
for (i = 0; i < s->num_terms; i++) {
struct Decorr *dpp = &s->decorr_passes[i];
if (((s->flags & MAG_MASK) >> MAG_LSB) >= 16 || dpp->delta != 2)
decorr_stereo_pass2(dpp, samples_l, samples_r, nb_samples);
else
decorr_stereo_pass_id2(dpp, samples_l, samples_r, nb_samples);
}
}
bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_MONO_DATA) {
for (i = 0; i < nb_samples; i++)
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
} else {
for (i = 0; i < nb_samples; i++) {
wavpack_encode_sample(s, &s->w.c[0], s->samples[0][i]);
wavpack_encode_sample(s, &s->w.c[1], s->samples[1][i]);
}
}
encode_flush(s);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 1) >> 1);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
if (got_extra) {
bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG);
init_put_bits(&s->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb));
if (s->flags & WV_FLOAT_DATA)
pack_float(s, s->orig_l, s->orig_r, nb_samples);
else
pack_int32(s, s->orig_l, s->orig_r, nb_samples);
flush_put_bits(&s->pb);
data_size = put_bits_count(&s->pb) >> 3;
bytestream2_put_le24(&pb, (data_size + 5) >> 1);
bytestream2_put_le32(&pb, s->crc_x);
bytestream2_skip_p(&pb, data_size);
if (data_size & 1)
bytestream2_put_byte(&pb, 0);
}
block_size = bytestream2_tell_p(&pb);
AV_WL32(out + 4, block_size - 8);
return block_size;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(WavPackEncodeContext *VAR_0,
int32_t *VAR_1, int32_t *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0;
int VAR_12, VAR_13, VAR_14 = 0, VAR_15 = 0, VAR_16 = VAR_0->block_samples;
uint32_t crc = 0xffffffffu;
struct Decorr *VAR_20;
PutByteContext pb;
if (!(VAR_0->flags & WV_MONO) && VAR_0->optimize_mono) {
int32_t lor = 0, diff = 0;
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {
lor |= VAR_1[VAR_12] | VAR_2[VAR_12];
diff |= VAR_1[VAR_12] - VAR_2[VAR_12];
if (lor && diff)
break;
}
if (VAR_12 == VAR_16 && lor && !diff) {
VAR_0->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR);
VAR_0->flags |= WV_FALSE_STEREO;
if (!VAR_0->false_stereo) {
VAR_0->false_stereo = 1;
VAR_0->num_terms = 0;
CLEAR(VAR_0->w);
}
} else if (VAR_0->false_stereo) {
VAR_0->false_stereo = 0;
VAR_0->num_terms = 0;
CLEAR(VAR_0->w);
}
}
if (VAR_0->flags & SHIFT_MASK) {
int VAR_18 = (VAR_0->flags & SHIFT_MASK) >> SHIFT_LSB;
int VAR_19 = (VAR_0->flags & MAG_MASK) >> MAG_LSB;
if (VAR_0->flags & WV_MONO_DATA)
shift_mono(VAR_1, VAR_16, VAR_18);
else
shift_stereo(VAR_1, VAR_2, VAR_16, VAR_18);
if ((VAR_19 -= VAR_18) < 0)
VAR_0->flags &= ~MAG_MASK;
else
VAR_0->flags -= (1 << MAG_LSB) * VAR_18;
}
if ((VAR_0->flags & WV_FLOAT_DATA) || (VAR_0->flags & MAG_MASK) >> MAG_LSB >= 24) {
av_fast_padded_malloc(&VAR_0->orig_l, &VAR_0->orig_l_size, sizeof(int32_t) * VAR_16);
memcpy(VAR_0->orig_l, VAR_1, sizeof(int32_t) * VAR_16);
if (!(VAR_0->flags & WV_MONO_DATA)) {
av_fast_padded_malloc(&VAR_0->orig_r, &VAR_0->orig_r_size, sizeof(int32_t) * VAR_16);
memcpy(VAR_0->orig_r, VAR_2, sizeof(int32_t) * VAR_16);
}
if (VAR_0->flags & WV_FLOAT_DATA)
VAR_15 = scan_float(VAR_0, VAR_1, VAR_2, VAR_16);
else
VAR_15 = scan_int32(VAR_0, VAR_1, VAR_2, VAR_16);
VAR_0->num_terms = 0;
} else {
scan_int23(VAR_0, VAR_1, VAR_2, VAR_16);
if (VAR_0->VAR_18 != VAR_0->int32_zeros + VAR_0->int32_ones + VAR_0->int32_dups) {
VAR_0->VAR_18 = VAR_0->int32_zeros + VAR_0->int32_ones + VAR_0->int32_dups;
VAR_0->num_terms = 0;
}
}
if (!VAR_0->num_passes && !VAR_0->num_terms) {
VAR_0->num_passes = 1;
if (VAR_0->flags & WV_MONO_DATA)
VAR_14 = wv_mono(VAR_0, VAR_1, 1, 0);
else
VAR_14 = wv_stereo(VAR_0, VAR_1, VAR_2, 1, 0);
VAR_0->num_passes = 0;
}
if (VAR_0->flags & WV_MONO_DATA) {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)
crc += (crc << 1) + VAR_1[VAR_12];
if (VAR_0->num_passes)
VAR_14 = wv_mono(VAR_0, VAR_1, !VAR_0->num_terms, 1);
} else {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)
crc += (crc << 3) + (VAR_1[VAR_12] << 1) + VAR_1[VAR_12] + VAR_2[VAR_12];
if (VAR_0->num_passes)
VAR_14 = wv_stereo(VAR_0, VAR_1, VAR_2, !VAR_0->num_terms, 1);
}
if (VAR_14 < 0)
return VAR_14;
if (!VAR_0->ch_offset)
VAR_0->flags |= WV_INITIAL_BLOCK;
VAR_0->ch_offset += 1 + !(VAR_0->flags & WV_MONO);
if (VAR_0->ch_offset == VAR_0->avctx->channels)
VAR_0->flags |= WV_FINAL_BLOCK;
bytestream2_init_writer(&pb, VAR_3, VAR_4);
bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'VAR_20'));
bytestream2_put_le32(&pb, 0);
bytestream2_put_le16(&pb, 0x410);
bytestream2_put_le16(&pb, 0);
bytestream2_put_le32(&pb, 0);
bytestream2_put_le32(&pb, VAR_0->sample_index);
bytestream2_put_le32(&pb, VAR_16);
bytestream2_put_le32(&pb, VAR_0->flags);
bytestream2_put_le32(&pb, crc);
if (VAR_0->flags & WV_INITIAL_BLOCK &&
VAR_0->avctx->channel_layout != AV_CH_LAYOUT_MONO &&
VAR_0->avctx->channel_layout != AV_CH_LAYOUT_STEREO) {
put_metadata_block(&pb, WP_ID_CHANINFO, 5);
bytestream2_put_byte(&pb, VAR_0->avctx->channels);
bytestream2_put_le32(&pb, VAR_0->avctx->channel_layout);
bytestream2_put_byte(&pb, 0);
}
if ((VAR_0->flags & SRATE_MASK) == SRATE_MASK) {
put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3);
bytestream2_put_le24(&pb, VAR_0->avctx->sample_rate);
bytestream2_put_byte(&pb, 0);
}
put_metadata_block(&pb, WP_ID_DECTERMS, VAR_0->num_terms);
for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {
struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];
bytestream2_put_byte(&pb, ((VAR_20->value + 5) & 0x1f) | ((VAR_20->delta << 5) & 0xe0));
}
if (VAR_0->num_terms & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECWEIGHT(type) do { \
VAR_10 = store_weight(type); \
bytestream2_put_byte(&pb, VAR_10); \
type = restore_weight(VAR_10); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS);
bytestream2_put_byte(&pb, 0);
VAR_6 = bytestream2_tell_p(&pb);
for (VAR_12 = VAR_0->num_terms - 1; VAR_12 >= 0; --VAR_12) {
struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];
if (store_weight(VAR_20->weightA) ||
(!(VAR_0->flags & WV_MONO_DATA) && store_weight(VAR_20->weightB)))
break;
}
VAR_9 = VAR_12 + 1;
for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {
struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];
if (VAR_12 < VAR_9) {
WRITE_DECWEIGHT(VAR_20->weightA);
if (!(VAR_0->flags & WV_MONO_DATA))
WRITE_DECWEIGHT(VAR_20->weightB);
} else {
VAR_20->weightA = VAR_20->weightB = 0;
}
}
VAR_7 = bytestream2_tell_p(&pb);
VAR_3[VAR_6 - 2] = WP_ID_DECWEIGHTS | (((VAR_7 - VAR_6) & 1) ? WP_IDF_ODD: 0);
VAR_3[VAR_6 - 1] = (VAR_7 - VAR_6 + 1) >> 1;
if ((VAR_7 - VAR_6) & 1)
bytestream2_put_byte(&pb, 0);
#define WRITE_DECSAMPLE(type) do { \
VAR_10 = log2s(type); \
type = wp_exp2(VAR_10); \
bytestream2_put_le16(&pb, VAR_10); \
} while (0)
bytestream2_put_byte(&pb, WP_ID_DECSAMPLES);
bytestream2_put_byte(&pb, 0);
VAR_6 = bytestream2_tell_p(&pb);
for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {
struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];
if (VAR_12 == 0) {
if (VAR_20->value > MAX_TERM) {
WRITE_DECSAMPLE(VAR_20->samplesA[0]);
WRITE_DECSAMPLE(VAR_20->samplesA[1]);
if (!(VAR_0->flags & WV_MONO_DATA)) {
WRITE_DECSAMPLE(VAR_20->samplesB[0]);
WRITE_DECSAMPLE(VAR_20->samplesB[1]);
}
} else if (VAR_20->value < 0) {
WRITE_DECSAMPLE(VAR_20->samplesA[0]);
WRITE_DECSAMPLE(VAR_20->samplesB[0]);
} else {
for (VAR_13 = 0; VAR_13 < VAR_20->value; VAR_13++) {
WRITE_DECSAMPLE(VAR_20->samplesA[VAR_13]);
if (!(VAR_0->flags & WV_MONO_DATA))
WRITE_DECSAMPLE(VAR_20->samplesB[VAR_13]);
}
}
} else {
CLEAR(VAR_20->samplesA);
CLEAR(VAR_20->samplesB);
}
}
VAR_7 = bytestream2_tell_p(&pb);
VAR_3[VAR_6 - 1] = (VAR_7 - VAR_6) >> 1;
#define WRITE_CHAN_ENTROPY(chan) do { \
for (VAR_12 = 0; VAR_12 < 3; VAR_12++) { \
VAR_10 = wp_log2(VAR_0->w.c[chan].median[VAR_12]); \
bytestream2_put_le16(&pb, VAR_10); \
VAR_0->w.c[chan].median[VAR_12] = wp_exp2(VAR_10); \
} \
} while (0)
put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(VAR_0->flags & WV_MONO_DATA))));
WRITE_CHAN_ENTROPY(0);
if (!(VAR_0->flags & WV_MONO_DATA))
WRITE_CHAN_ENTROPY(1);
if (VAR_0->flags & WV_FLOAT_DATA) {
put_metadata_block(&pb, WP_ID_FLOATINFO, 4);
bytestream2_put_byte(&pb, VAR_0->float_flags);
bytestream2_put_byte(&pb, VAR_0->float_shift);
bytestream2_put_byte(&pb, VAR_0->float_max_exp);
bytestream2_put_byte(&pb, 127);
}
if (VAR_0->flags & WV_INT32_DATA) {
put_metadata_block(&pb, WP_ID_INT32INFO, 4);
bytestream2_put_byte(&pb, VAR_0->int32_sent_bits);
bytestream2_put_byte(&pb, VAR_0->int32_zeros);
bytestream2_put_byte(&pb, VAR_0->int32_ones);
bytestream2_put_byte(&pb, VAR_0->int32_dups);
}
if (VAR_0->flags & WV_MONO_DATA && !VAR_0->num_passes) {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {
int32_t code = VAR_1[VAR_12];
for (VAR_9 = VAR_0->num_terms, VAR_20 = VAR_0->decorr_passes; VAR_9--; VAR_20++) {
int32_t sam;
if (VAR_20->value > MAX_TERM) {
if (VAR_20->value & 1)
sam = 2 * VAR_20->samplesA[0] - VAR_20->samplesA[1];
else
sam = (3 * VAR_20->samplesA[0] - VAR_20->samplesA[1]) >> 1;
VAR_20->samplesA[1] = VAR_20->samplesA[0];
VAR_20->samplesA[0] = code;
} else {
sam = VAR_20->samplesA[VAR_11];
VAR_20->samplesA[(VAR_11 + VAR_20->value) & (MAX_TERM - 1)] = code;
}
code -= APPLY_WEIGHT(VAR_20->weightA, sam);
UPDATE_WEIGHT(VAR_20->weightA, VAR_20->delta, sam, code);
}
VAR_11 = (VAR_11 + 1) & (MAX_TERM - 1);
VAR_1[VAR_12] = code;
}
if (VAR_11) {
for (VAR_9 = VAR_0->num_terms, VAR_20 = VAR_0->decorr_passes; VAR_9--; VAR_20++)
if (VAR_20->value > 0 && VAR_20->value <= MAX_TERM) {
int32_t temp_A[MAX_TERM], temp_B[MAX_TERM];
int VAR_20;
memcpy(temp_A, VAR_20->samplesA, sizeof(VAR_20->samplesA));
memcpy(temp_B, VAR_20->samplesB, sizeof(VAR_20->samplesB));
for (VAR_20 = 0; VAR_20 < MAX_TERM; VAR_20++) {
VAR_20->samplesA[VAR_20] = temp_A[VAR_11];
VAR_20->samplesB[VAR_20] = temp_B[VAR_11];
VAR_11 = (VAR_11 + 1) & (MAX_TERM - 1);
}
}
}
} else if (!VAR_0->num_passes) {
if (VAR_0->flags & WV_JOINT_STEREO) {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)
VAR_2[VAR_12] += ((VAR_1[VAR_12] -= VAR_2[VAR_12]) >> 1);
}
for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {
struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];
if (((VAR_0->flags & MAG_MASK) >> MAG_LSB) >= 16 || VAR_20->delta != 2)
decorr_stereo_pass2(VAR_20, VAR_1, VAR_2, VAR_16);
else
decorr_stereo_pass_id2(VAR_20, VAR_1, VAR_2, VAR_16);
}
}
bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG);
init_put_bits(&VAR_0->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb));
if (VAR_0->flags & WV_MONO_DATA) {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)
wavpack_encode_sample(VAR_0, &VAR_0->w.c[0], VAR_0->samples[0][VAR_12]);
} else {
for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {
wavpack_encode_sample(VAR_0, &VAR_0->w.c[0], VAR_0->samples[0][VAR_12]);
wavpack_encode_sample(VAR_0, &VAR_0->w.c[1], VAR_0->samples[1][VAR_12]);
}
}
encode_flush(VAR_0);
flush_put_bits(&VAR_0->pb);
VAR_8 = put_bits_count(&VAR_0->pb) >> 3;
bytestream2_put_le24(&pb, (VAR_8 + 1) >> 1);
bytestream2_skip_p(&pb, VAR_8);
if (VAR_8 & 1)
bytestream2_put_byte(&pb, 0);
if (VAR_15) {
bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG);
init_put_bits(&VAR_0->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb));
if (VAR_0->flags & WV_FLOAT_DATA)
pack_float(VAR_0, VAR_0->orig_l, VAR_0->orig_r, VAR_16);
else
pack_int32(VAR_0, VAR_0->orig_l, VAR_0->orig_r, VAR_16);
flush_put_bits(&VAR_0->pb);
VAR_8 = put_bits_count(&VAR_0->pb) >> 3;
bytestream2_put_le24(&pb, (VAR_8 + 5) >> 1);
bytestream2_put_le32(&pb, VAR_0->crc_x);
bytestream2_skip_p(&pb, VAR_8);
if (VAR_8 & 1)
bytestream2_put_byte(&pb, 0);
}
VAR_5 = bytestream2_tell_p(&pb);
AV_WL32(VAR_3 + 4, VAR_5 - 8);
return VAR_5;
} | [
"static int FUNC_0(WavPackEncodeContext *VAR_0,\nint32_t *VAR_1, int32_t *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0;",
"int VAR_12, VAR_13, VAR_14 = 0, VAR_15 = 0, VAR_16 = VAR_0->block_samples;",
"uint32_t crc = 0xffffffffu;",
"struct Decorr *VAR_20;",
"PutByteContext pb;",
"if (!(VAR_0->flags & WV_MONO) && VAR_0->optimize_mono) {",
"int32_t lor = 0, diff = 0;",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {",
"lor |= VAR_1[VAR_12] | VAR_2[VAR_12];",
"diff |= VAR_1[VAR_12] - VAR_2[VAR_12];",
"if (lor && diff)\nbreak;",
"}",
"if (VAR_12 == VAR_16 && lor && !diff) {",
"VAR_0->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR);",
"VAR_0->flags |= WV_FALSE_STEREO;",
"if (!VAR_0->false_stereo) {",
"VAR_0->false_stereo = 1;",
"VAR_0->num_terms = 0;",
"CLEAR(VAR_0->w);",
"}",
"} else if (VAR_0->false_stereo) {",
"VAR_0->false_stereo = 0;",
"VAR_0->num_terms = 0;",
"CLEAR(VAR_0->w);",
"}",
"}",
"if (VAR_0->flags & SHIFT_MASK) {",
"int VAR_18 = (VAR_0->flags & SHIFT_MASK) >> SHIFT_LSB;",
"int VAR_19 = (VAR_0->flags & MAG_MASK) >> MAG_LSB;",
"if (VAR_0->flags & WV_MONO_DATA)\nshift_mono(VAR_1, VAR_16, VAR_18);",
"else\nshift_stereo(VAR_1, VAR_2, VAR_16, VAR_18);",
"if ((VAR_19 -= VAR_18) < 0)\nVAR_0->flags &= ~MAG_MASK;",
"else\nVAR_0->flags -= (1 << MAG_LSB) * VAR_18;",
"}",
"if ((VAR_0->flags & WV_FLOAT_DATA) || (VAR_0->flags & MAG_MASK) >> MAG_LSB >= 24) {",
"av_fast_padded_malloc(&VAR_0->orig_l, &VAR_0->orig_l_size, sizeof(int32_t) * VAR_16);",
"memcpy(VAR_0->orig_l, VAR_1, sizeof(int32_t) * VAR_16);",
"if (!(VAR_0->flags & WV_MONO_DATA)) {",
"av_fast_padded_malloc(&VAR_0->orig_r, &VAR_0->orig_r_size, sizeof(int32_t) * VAR_16);",
"memcpy(VAR_0->orig_r, VAR_2, sizeof(int32_t) * VAR_16);",
"}",
"if (VAR_0->flags & WV_FLOAT_DATA)\nVAR_15 = scan_float(VAR_0, VAR_1, VAR_2, VAR_16);",
"else\nVAR_15 = scan_int32(VAR_0, VAR_1, VAR_2, VAR_16);",
"VAR_0->num_terms = 0;",
"} else {",
"scan_int23(VAR_0, VAR_1, VAR_2, VAR_16);",
"if (VAR_0->VAR_18 != VAR_0->int32_zeros + VAR_0->int32_ones + VAR_0->int32_dups) {",
"VAR_0->VAR_18 = VAR_0->int32_zeros + VAR_0->int32_ones + VAR_0->int32_dups;",
"VAR_0->num_terms = 0;",
"}",
"}",
"if (!VAR_0->num_passes && !VAR_0->num_terms) {",
"VAR_0->num_passes = 1;",
"if (VAR_0->flags & WV_MONO_DATA)\nVAR_14 = wv_mono(VAR_0, VAR_1, 1, 0);",
"else\nVAR_14 = wv_stereo(VAR_0, VAR_1, VAR_2, 1, 0);",
"VAR_0->num_passes = 0;",
"}",
"if (VAR_0->flags & WV_MONO_DATA) {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)",
"crc += (crc << 1) + VAR_1[VAR_12];",
"if (VAR_0->num_passes)\nVAR_14 = wv_mono(VAR_0, VAR_1, !VAR_0->num_terms, 1);",
"} else {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)",
"crc += (crc << 3) + (VAR_1[VAR_12] << 1) + VAR_1[VAR_12] + VAR_2[VAR_12];",
"if (VAR_0->num_passes)\nVAR_14 = wv_stereo(VAR_0, VAR_1, VAR_2, !VAR_0->num_terms, 1);",
"}",
"if (VAR_14 < 0)\nreturn VAR_14;",
"if (!VAR_0->ch_offset)\nVAR_0->flags |= WV_INITIAL_BLOCK;",
"VAR_0->ch_offset += 1 + !(VAR_0->flags & WV_MONO);",
"if (VAR_0->ch_offset == VAR_0->avctx->channels)\nVAR_0->flags |= WV_FINAL_BLOCK;",
"bytestream2_init_writer(&pb, VAR_3, VAR_4);",
"bytestream2_put_le32(&pb, MKTAG('w', 'v', 'p', 'VAR_20'));",
"bytestream2_put_le32(&pb, 0);",
"bytestream2_put_le16(&pb, 0x410);",
"bytestream2_put_le16(&pb, 0);",
"bytestream2_put_le32(&pb, 0);",
"bytestream2_put_le32(&pb, VAR_0->sample_index);",
"bytestream2_put_le32(&pb, VAR_16);",
"bytestream2_put_le32(&pb, VAR_0->flags);",
"bytestream2_put_le32(&pb, crc);",
"if (VAR_0->flags & WV_INITIAL_BLOCK &&\nVAR_0->avctx->channel_layout != AV_CH_LAYOUT_MONO &&\nVAR_0->avctx->channel_layout != AV_CH_LAYOUT_STEREO) {",
"put_metadata_block(&pb, WP_ID_CHANINFO, 5);",
"bytestream2_put_byte(&pb, VAR_0->avctx->channels);",
"bytestream2_put_le32(&pb, VAR_0->avctx->channel_layout);",
"bytestream2_put_byte(&pb, 0);",
"}",
"if ((VAR_0->flags & SRATE_MASK) == SRATE_MASK) {",
"put_metadata_block(&pb, WP_ID_SAMPLE_RATE, 3);",
"bytestream2_put_le24(&pb, VAR_0->avctx->sample_rate);",
"bytestream2_put_byte(&pb, 0);",
"}",
"put_metadata_block(&pb, WP_ID_DECTERMS, VAR_0->num_terms);",
"for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {",
"struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];",
"bytestream2_put_byte(&pb, ((VAR_20->value + 5) & 0x1f) | ((VAR_20->delta << 5) & 0xe0));",
"}",
"if (VAR_0->num_terms & 1)\nbytestream2_put_byte(&pb, 0);",
"#define WRITE_DECWEIGHT(type) do { \\",
"VAR_10 = store_weight(type); \\",
"bytestream2_put_byte(&pb, VAR_10); \\",
"type = restore_weight(VAR_10); \\",
"} while (0)",
"bytestream2_put_byte(&pb, WP_ID_DECWEIGHTS);",
"bytestream2_put_byte(&pb, 0);",
"VAR_6 = bytestream2_tell_p(&pb);",
"for (VAR_12 = VAR_0->num_terms - 1; VAR_12 >= 0; --VAR_12) {",
"struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];",
"if (store_weight(VAR_20->weightA) ||\n(!(VAR_0->flags & WV_MONO_DATA) && store_weight(VAR_20->weightB)))\nbreak;",
"}",
"VAR_9 = VAR_12 + 1;",
"for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {",
"struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];",
"if (VAR_12 < VAR_9) {",
"WRITE_DECWEIGHT(VAR_20->weightA);",
"if (!(VAR_0->flags & WV_MONO_DATA))\nWRITE_DECWEIGHT(VAR_20->weightB);",
"} else {",
"VAR_20->weightA = VAR_20->weightB = 0;",
"}",
"}",
"VAR_7 = bytestream2_tell_p(&pb);",
"VAR_3[VAR_6 - 2] = WP_ID_DECWEIGHTS | (((VAR_7 - VAR_6) & 1) ? WP_IDF_ODD: 0);",
"VAR_3[VAR_6 - 1] = (VAR_7 - VAR_6 + 1) >> 1;",
"if ((VAR_7 - VAR_6) & 1)\nbytestream2_put_byte(&pb, 0);",
"#define WRITE_DECSAMPLE(type) do { \\",
"VAR_10 = log2s(type); \\",
"type = wp_exp2(VAR_10); \\",
"bytestream2_put_le16(&pb, VAR_10); \\",
"} while (0)",
"bytestream2_put_byte(&pb, WP_ID_DECSAMPLES);",
"bytestream2_put_byte(&pb, 0);",
"VAR_6 = bytestream2_tell_p(&pb);",
"for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {",
"struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];",
"if (VAR_12 == 0) {",
"if (VAR_20->value > MAX_TERM) {",
"WRITE_DECSAMPLE(VAR_20->samplesA[0]);",
"WRITE_DECSAMPLE(VAR_20->samplesA[1]);",
"if (!(VAR_0->flags & WV_MONO_DATA)) {",
"WRITE_DECSAMPLE(VAR_20->samplesB[0]);",
"WRITE_DECSAMPLE(VAR_20->samplesB[1]);",
"}",
"} else if (VAR_20->value < 0) {",
"WRITE_DECSAMPLE(VAR_20->samplesA[0]);",
"WRITE_DECSAMPLE(VAR_20->samplesB[0]);",
"} else {",
"for (VAR_13 = 0; VAR_13 < VAR_20->value; VAR_13++) {",
"WRITE_DECSAMPLE(VAR_20->samplesA[VAR_13]);",
"if (!(VAR_0->flags & WV_MONO_DATA))\nWRITE_DECSAMPLE(VAR_20->samplesB[VAR_13]);",
"}",
"}",
"} else {",
"CLEAR(VAR_20->samplesA);",
"CLEAR(VAR_20->samplesB);",
"}",
"}",
"VAR_7 = bytestream2_tell_p(&pb);",
"VAR_3[VAR_6 - 1] = (VAR_7 - VAR_6) >> 1;",
"#define WRITE_CHAN_ENTROPY(chan) do { \\",
"for (VAR_12 = 0; VAR_12 < 3; VAR_12++) { \\",
"VAR_10 = wp_log2(VAR_0->w.c[chan].median[VAR_12]); \\",
"bytestream2_put_le16(&pb, VAR_10); \\",
"VAR_0->w.c[chan].median[VAR_12] = wp_exp2(VAR_10); \\",
"} \\",
"} while (0)",
"put_metadata_block(&pb, WP_ID_ENTROPY, 6 * (1 + (!(VAR_0->flags & WV_MONO_DATA))));",
"WRITE_CHAN_ENTROPY(0);",
"if (!(VAR_0->flags & WV_MONO_DATA))\nWRITE_CHAN_ENTROPY(1);",
"if (VAR_0->flags & WV_FLOAT_DATA) {",
"put_metadata_block(&pb, WP_ID_FLOATINFO, 4);",
"bytestream2_put_byte(&pb, VAR_0->float_flags);",
"bytestream2_put_byte(&pb, VAR_0->float_shift);",
"bytestream2_put_byte(&pb, VAR_0->float_max_exp);",
"bytestream2_put_byte(&pb, 127);",
"}",
"if (VAR_0->flags & WV_INT32_DATA) {",
"put_metadata_block(&pb, WP_ID_INT32INFO, 4);",
"bytestream2_put_byte(&pb, VAR_0->int32_sent_bits);",
"bytestream2_put_byte(&pb, VAR_0->int32_zeros);",
"bytestream2_put_byte(&pb, VAR_0->int32_ones);",
"bytestream2_put_byte(&pb, VAR_0->int32_dups);",
"}",
"if (VAR_0->flags & WV_MONO_DATA && !VAR_0->num_passes) {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {",
"int32_t code = VAR_1[VAR_12];",
"for (VAR_9 = VAR_0->num_terms, VAR_20 = VAR_0->decorr_passes; VAR_9--; VAR_20++) {",
"int32_t sam;",
"if (VAR_20->value > MAX_TERM) {",
"if (VAR_20->value & 1)\nsam = 2 * VAR_20->samplesA[0] - VAR_20->samplesA[1];",
"else\nsam = (3 * VAR_20->samplesA[0] - VAR_20->samplesA[1]) >> 1;",
"VAR_20->samplesA[1] = VAR_20->samplesA[0];",
"VAR_20->samplesA[0] = code;",
"} else {",
"sam = VAR_20->samplesA[VAR_11];",
"VAR_20->samplesA[(VAR_11 + VAR_20->value) & (MAX_TERM - 1)] = code;",
"}",
"code -= APPLY_WEIGHT(VAR_20->weightA, sam);",
"UPDATE_WEIGHT(VAR_20->weightA, VAR_20->delta, sam, code);",
"}",
"VAR_11 = (VAR_11 + 1) & (MAX_TERM - 1);",
"VAR_1[VAR_12] = code;",
"}",
"if (VAR_11) {",
"for (VAR_9 = VAR_0->num_terms, VAR_20 = VAR_0->decorr_passes; VAR_9--; VAR_20++)",
"if (VAR_20->value > 0 && VAR_20->value <= MAX_TERM) {",
"int32_t temp_A[MAX_TERM], temp_B[MAX_TERM];",
"int VAR_20;",
"memcpy(temp_A, VAR_20->samplesA, sizeof(VAR_20->samplesA));",
"memcpy(temp_B, VAR_20->samplesB, sizeof(VAR_20->samplesB));",
"for (VAR_20 = 0; VAR_20 < MAX_TERM; VAR_20++) {",
"VAR_20->samplesA[VAR_20] = temp_A[VAR_11];",
"VAR_20->samplesB[VAR_20] = temp_B[VAR_11];",
"VAR_11 = (VAR_11 + 1) & (MAX_TERM - 1);",
"}",
"}",
"}",
"} else if (!VAR_0->num_passes) {",
"if (VAR_0->flags & WV_JOINT_STEREO) {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)",
"VAR_2[VAR_12] += ((VAR_1[VAR_12] -= VAR_2[VAR_12]) >> 1);",
"}",
"for (VAR_12 = 0; VAR_12 < VAR_0->num_terms; VAR_12++) {",
"struct Decorr *VAR_20 = &VAR_0->decorr_passes[VAR_12];",
"if (((VAR_0->flags & MAG_MASK) >> MAG_LSB) >= 16 || VAR_20->delta != 2)\ndecorr_stereo_pass2(VAR_20, VAR_1, VAR_2, VAR_16);",
"else\ndecorr_stereo_pass_id2(VAR_20, VAR_1, VAR_2, VAR_16);",
"}",
"}",
"bytestream2_put_byte(&pb, WP_ID_DATA | WP_IDF_LONG);",
"init_put_bits(&VAR_0->pb, pb.buffer + 3, bytestream2_get_bytes_left_p(&pb));",
"if (VAR_0->flags & WV_MONO_DATA) {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++)",
"wavpack_encode_sample(VAR_0, &VAR_0->w.c[0], VAR_0->samples[0][VAR_12]);",
"} else {",
"for (VAR_12 = 0; VAR_12 < VAR_16; VAR_12++) {",
"wavpack_encode_sample(VAR_0, &VAR_0->w.c[0], VAR_0->samples[0][VAR_12]);",
"wavpack_encode_sample(VAR_0, &VAR_0->w.c[1], VAR_0->samples[1][VAR_12]);",
"}",
"}",
"encode_flush(VAR_0);",
"flush_put_bits(&VAR_0->pb);",
"VAR_8 = put_bits_count(&VAR_0->pb) >> 3;",
"bytestream2_put_le24(&pb, (VAR_8 + 1) >> 1);",
"bytestream2_skip_p(&pb, VAR_8);",
"if (VAR_8 & 1)\nbytestream2_put_byte(&pb, 0);",
"if (VAR_15) {",
"bytestream2_put_byte(&pb, WP_ID_EXTRABITS | WP_IDF_LONG);",
"init_put_bits(&VAR_0->pb, pb.buffer + 7, bytestream2_get_bytes_left_p(&pb));",
"if (VAR_0->flags & WV_FLOAT_DATA)\npack_float(VAR_0, VAR_0->orig_l, VAR_0->orig_r, VAR_16);",
"else\npack_int32(VAR_0, VAR_0->orig_l, VAR_0->orig_r, VAR_16);",
"flush_put_bits(&VAR_0->pb);",
"VAR_8 = put_bits_count(&VAR_0->pb) >> 3;",
"bytestream2_put_le24(&pb, (VAR_8 + 5) >> 1);",
"bytestream2_put_le32(&pb, VAR_0->crc_x);",
"bytestream2_skip_p(&pb, VAR_8);",
"if (VAR_8 & 1)\nbytestream2_put_byte(&pb, 0);",
"}",
"VAR_5 = bytestream2_tell_p(&pb);",
"AV_WL32(VAR_3 + 4, VAR_5 - 8);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15,
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35,
36
],
[
37,
38
],
[
39,
40
],
[
41,
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
49
],
[
50
],
[
51,
52
],
[
53,
54
],
[
55
],
[
56
],
[
57
],
[
58
],
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65,
66
],
[
67,
68
],
[
69
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74,
75
],
[
76
],
[
77
],
[
78
],
[
79,
80
],
[
81
],
[
82,
83
],
[
84,
85
],
[
86
],
[
87,
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
],
[
99,
100,
101
],
[
102
],
[
103
],
[
104
],
[
105
],
[
106
],
[
107
],
[
108
],
[
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117,
118
],
[
119
],
[
120
],
[
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
],
[
129,
130,
131
],
[
132
],
[
133
],
[
134
],
[
135
],
[
136
],
[
137
],
[
138,
139
],
[
140
],
[
141
],
[
142
],
[
143
],
[
144
],
[
145
],
[
146
],
[
147,
148
],
[
149
],
[
150
],
[
151
],
[
152
],
[
153
],
[
154
],
[
155
],
[
156
],
[
157
],
[
158
],
[
159
],
[
160
],
[
161
],
[
162
],
[
163
],
[
164
],
[
165
],
[
166
],
[
167
],
[
168
],
[
169
],
[
170
],
[
171
],
[
172
],
[
173,
174
],
[
175
],
[
176
],
[
177
],
[
178
],
[
179
],
[
180
],
[
181
],
[
182
],
[
183
],
[
184
],
[
185
],
[
186
],
[
187
],
[
188
],
[
189
],
[
190
],
[
191
],
[
192
],
[
193,
194
],
[
195
],
[
196
],
[
197
],
[
198
],
[
199
],
[
200
],
[
201
],
[
202
],
[
203
],
[
204
],
[
205
],
[
206
],
[
207
],
[
208
],
[
209
],
[
210
],
[
211
],
[
212
],
[
213
],
[
214
],
[
215,
216
],
[
217,
218
],
[
219
],
[
220
],
[
221
],
[
222
],
[
223
],
[
224
],
[
225
],
[
226
],
[
227
],
[
228
],
[
229
],
[
230
],
[
231
],
[
232
],
[
233
],
[
234
],
[
235
],
[
236
],
[
237
],
[
238
],
[
239
],
[
240
],
[
241
],
[
242
],
[
243
],
[
244
],
[
245
],
[
246
],
[
247
],
[
248
],
[
249
],
[
250
],
[
251
],
[
252,
253
],
[
254,
255
],
[
256
],
[
257
],
[
258
],
[
259
],
[
260
],
[
261
],
[
262
],
[
263
],
[
264
],
[
265
],
[
266
],
[
267
],
[
268
],
[
269
],
[
270
],
[
271
],
[
272
],
[
273
],
[
274,
275
],
[
276
],
[
277
],
[
278
],
[
279,
280
],
[
281,
282
],
[
283
],
[
284
],
[
285
],
[
286
],
[
287
],
[
288,
289
],
[
290
],
[
291
],
[
292
],
[
293
],
[
294
]
] |
21,970 | virtio_crypto_check_cryptodev_is_used(Object *obj, const char *name,
Object *val, Error **errp)
{
if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(errp,
"can't use already used cryptodev backend: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
}
}
| true | qemu | 8f5d58ef2c92d7b82d9a6eeefd7c8854a183ba4a | virtio_crypto_check_cryptodev_is_used(Object *obj, const char *name,
Object *val, Error **errp)
{
if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(val))) {
char *path = object_get_canonical_path_component(val);
error_setg(errp,
"can't use already used cryptodev backend: %s", path);
g_free(path);
} else {
qdev_prop_allow_set_link_before_realize(obj, name, val, errp);
}
}
| {
"code": [
"virtio_crypto_check_cryptodev_is_used(Object *obj, const char *name,"
],
"line_no": [
1
]
} | FUNC_0(Object *VAR_0, const char *VAR_1,
Object *VAR_2, Error **VAR_3)
{
if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(VAR_2))) {
char *VAR_4 = object_get_canonical_path_component(VAR_2);
error_setg(VAR_3,
"can't use already used cryptodev backend: %s", VAR_4);
g_free(VAR_4);
} else {
qdev_prop_allow_set_link_before_realize(VAR_0, VAR_1, VAR_2, VAR_3);
}
}
| [
"FUNC_0(Object *VAR_0, const char *VAR_1,\nObject *VAR_2, Error **VAR_3)\n{",
"if (cryptodev_backend_is_used(CRYPTODEV_BACKEND(VAR_2))) {",
"char *VAR_4 = object_get_canonical_path_component(VAR_2);",
"error_setg(VAR_3,\n\"can't use already used cryptodev backend: %s\", VAR_4);",
"g_free(VAR_4);",
"} else {",
"qdev_prop_allow_set_link_before_realize(VAR_0, VAR_1, VAR_2, VAR_3);",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
21,973 | static void unterminated_dict(void)
{
QObject *obj = qobject_from_json("{'abc':32", NULL);
g_assert(obj == NULL);
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void unterminated_dict(void)
{
QObject *obj = qobject_from_json("{'abc':32", NULL);
g_assert(obj == NULL);
}
| {
"code": [
" QObject *obj = qobject_from_json(\"{'abc':32\", NULL);"
],
"line_no": [
5
]
} | static void FUNC_0(void)
{
QObject *obj = qobject_from_json("{'abc':32", NULL);
g_assert(obj == NULL);
}
| [
"static void FUNC_0(void)\n{",
"QObject *obj = qobject_from_json(\"{'abc':32\", NULL);",
"g_assert(obj == NULL);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
21,975 | static void* attribute_align_arg worker(void *v)
{
AVCodecContext *avctx = v;
SliceThreadContext *c = avctx->internal->thread_ctx;
unsigned last_execute = 0;
int our_job = c->job_count;
int thread_count = avctx->thread_count;
int self_id;
pthread_mutex_lock(&c->current_job_lock);
self_id = c->current_job++;
for (;;){
while (our_job >= c->job_count) {
if (c->current_job == thread_count + c->job_count)
pthread_cond_signal(&c->last_job_cond);
while (last_execute == c->current_execute && !c->done)
pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
last_execute = c->current_execute;
our_job = self_id;
if (c->done) {
pthread_mutex_unlock(&c->current_job_lock);
return NULL;
}
}
pthread_mutex_unlock(&c->current_job_lock);
c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size):
c->func2(avctx, c->args, our_job, self_id);
pthread_mutex_lock(&c->current_job_lock);
our_job = c->current_job++;
}
}
| false | FFmpeg | 50ce510ac4e3ed093c051738242a9a75aeeb36ce | static void* attribute_align_arg worker(void *v)
{
AVCodecContext *avctx = v;
SliceThreadContext *c = avctx->internal->thread_ctx;
unsigned last_execute = 0;
int our_job = c->job_count;
int thread_count = avctx->thread_count;
int self_id;
pthread_mutex_lock(&c->current_job_lock);
self_id = c->current_job++;
for (;;){
while (our_job >= c->job_count) {
if (c->current_job == thread_count + c->job_count)
pthread_cond_signal(&c->last_job_cond);
while (last_execute == c->current_execute && !c->done)
pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
last_execute = c->current_execute;
our_job = self_id;
if (c->done) {
pthread_mutex_unlock(&c->current_job_lock);
return NULL;
}
}
pthread_mutex_unlock(&c->current_job_lock);
c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size):
c->func2(avctx, c->args, our_job, self_id);
pthread_mutex_lock(&c->current_job_lock);
our_job = c->current_job++;
}
}
| {
"code": [],
"line_no": []
} | static void* VAR_0 worker(void *v)
{
AVCodecContext *avctx = v;
SliceThreadContext *c = avctx->internal->thread_ctx;
unsigned last_execute = 0;
int our_job = c->job_count;
int thread_count = avctx->thread_count;
int self_id;
pthread_mutex_lock(&c->current_job_lock);
self_id = c->current_job++;
for (;;){
while (our_job >= c->job_count) {
if (c->current_job == thread_count + c->job_count)
pthread_cond_signal(&c->last_job_cond);
while (last_execute == c->current_execute && !c->done)
pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
last_execute = c->current_execute;
our_job = self_id;
if (c->done) {
pthread_mutex_unlock(&c->current_job_lock);
return NULL;
}
}
pthread_mutex_unlock(&c->current_job_lock);
c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size):
c->func2(avctx, c->args, our_job, self_id);
pthread_mutex_lock(&c->current_job_lock);
our_job = c->current_job++;
}
}
| [
"static void* VAR_0 worker(void *v)\n{",
"AVCodecContext *avctx = v;",
"SliceThreadContext *c = avctx->internal->thread_ctx;",
"unsigned last_execute = 0;",
"int our_job = c->job_count;",
"int thread_count = avctx->thread_count;",
"int self_id;",
"pthread_mutex_lock(&c->current_job_lock);",
"self_id = c->current_job++;",
"for (;;){",
"while (our_job >= c->job_count) {",
"if (c->current_job == thread_count + c->job_count)\npthread_cond_signal(&c->last_job_cond);",
"while (last_execute == c->current_execute && !c->done)\npthread_cond_wait(&c->current_job_cond, &c->current_job_lock);",
"last_execute = c->current_execute;",
"our_job = self_id;",
"if (c->done) {",
"pthread_mutex_unlock(&c->current_job_lock);",
"return NULL;",
"}",
"}",
"pthread_mutex_unlock(&c->current_job_lock);",
"c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size):\nc->func2(avctx, c->args, our_job, self_id);",
"pthread_mutex_lock(&c->current_job_lock);",
"our_job = c->current_job++;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57,
59
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
21,976 | static void avc_h_loop_filter_luma_mbaff_intra_msa(uint8_t *src,
int32_t stride,
int32_t alpha_in,
int32_t beta_in)
{
uint64_t load0, load1;
uint32_t out0, out2;
uint16_t out1, out3;
v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r;
v8u16 dst0_r, dst1_r, dst4_r, dst5_r;
v8u16 dst2_x_r, dst2_y_r, dst3_x_r, dst3_y_r;
v16u8 dst0, dst1, dst4, dst5, dst2_x, dst2_y, dst3_x, dst3_y;
v8i16 tmp0, tmp1, tmp2, tmp3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;
v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;
v16u8 is_less_than_beta1, is_less_than_beta2;
v16i8 src0 = { 0 };
v16i8 src1 = { 0 };
v16i8 src2 = { 0 };
v16i8 src3 = { 0 };
v16i8 src4 = { 0 };
v16i8 src5 = { 0 };
v16i8 src6 = { 0 };
v16i8 src7 = { 0 };
v16i8 zeros = { 0 };
load0 = LOAD_DWORD(src - 4);
load1 = LOAD_DWORD(src + stride - 4);
src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, load0);
src1 = (v16i8) __msa_insert_d((v2i64) src1, 0, load1);
load0 = LOAD_DWORD(src + (2 * stride) - 4);
load1 = LOAD_DWORD(src + (3 * stride) - 4);
src2 = (v16i8) __msa_insert_d((v2i64) src2, 0, load0);
src3 = (v16i8) __msa_insert_d((v2i64) src3, 0, load1);
load0 = LOAD_DWORD(src + (4 * stride) - 4);
load1 = LOAD_DWORD(src + (5 * stride) - 4);
src4 = (v16i8) __msa_insert_d((v2i64) src4, 0, load0);
src5 = (v16i8) __msa_insert_d((v2i64) src5, 0, load1);
load0 = LOAD_DWORD(src + (6 * stride) - 4);
load1 = LOAD_DWORD(src + (7 * stride) - 4);
src6 = (v16i8) __msa_insert_d((v2i64) src6, 0, load0);
src7 = (v16i8) __msa_insert_d((v2i64) src7, 0, load1);
src0 = __msa_ilvr_b(src1, src0);
src1 = __msa_ilvr_b(src3, src2);
src2 = __msa_ilvr_b(src5, src4);
src3 = __msa_ilvr_b(src7, src6);
tmp0 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);
tmp1 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);
tmp2 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);
tmp3 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);
src6 = (v16i8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
src0 = __msa_sldi_b(zeros, src6, 8);
src1 = (v16i8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
src2 = __msa_sldi_b(zeros, src1, 8);
src3 = (v16i8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
src4 = __msa_sldi_b(zeros, src3, 8);
src5 = (v16i8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
src7 = __msa_sldi_b(zeros, src5, 8);
p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);
p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);
q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_alpha & is_less_than_beta;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than & is_less_than_beta;
alpha >>= 2;
alpha += 2;
is_less_than_alpha = (p0_asub_q0 < alpha);
p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);
is_less_than_beta1 = (p2_asub_p0 < beta);
q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);
is_less_than_beta2 = (q2_asub_q0 < beta);
src0_r = (v8u16) __msa_ilvr_b(zeros, src0);
src1_r = (v8u16) __msa_ilvr_b(zeros, src1);
src2_r = (v8u16) __msa_ilvr_b(zeros, src2);
src3_r = (v8u16) __msa_ilvr_b(zeros, src3);
src4_r = (v8u16) __msa_ilvr_b(zeros, src4);
src5_r = (v8u16) __msa_ilvr_b(zeros, src5);
src6_r = (v8u16) __msa_ilvr_b(zeros, src6);
src7_r = (v8u16) __msa_ilvr_b(zeros, src7);
dst2_x_r = src1_r + src2_r + src3_r;
dst2_x_r = src0_r + (2 * (dst2_x_r)) + src4_r;
dst2_x_r = (v8u16) __msa_srari_h((v8i16) dst2_x_r, 3);
dst1_r = src0_r + src1_r + src2_r + src3_r;
dst1_r = (v8u16) __msa_srari_h((v8i16) dst1_r, 2);
dst0_r = (2 * src6_r) + (3 * src0_r);
dst0_r += src1_r + src2_r + src3_r;
dst0_r = (v8u16) __msa_srari_h((v8i16) dst0_r, 3);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst2_x = (v16u8) __msa_pckev_b((v16i8) dst2_x_r, (v16i8) dst2_x_r);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_beta1);
dst3_x_r = src2_r + src3_r + src4_r;
dst3_x_r = src1_r + (2 * dst3_x_r) + src5_r;
dst3_x_r = (v8u16) __msa_srari_h((v8i16) dst3_x_r, 3);
dst4_r = src2_r + src3_r + src4_r + src5_r;
dst4_r = (v8u16) __msa_srari_h((v8i16) dst4_r, 2);
dst5_r = (2 * src7_r) + (3 * src5_r);
dst5_r += src4_r + src3_r + src2_r;
dst5_r = (v8u16) __msa_srari_h((v8i16) dst5_r, 3);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst3_x = (v16u8) __msa_pckev_b((v16i8) dst3_x_r, (v16i8) dst3_x_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_beta2);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_alpha);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_alpha);
dst2_x = __msa_bmnz_v((v16u8) src2, dst2_x, is_less_than);
dst3_x = __msa_bmnz_v((v16u8) src3, dst3_x, is_less_than);
is_less_than = is_less_than_alpha & is_less_than;
dst1 = (v16u8) __msa_pckev_b((v16i8) dst1_r, (v16i8) dst1_r);
is_less_than_beta1 = is_less_than_beta1 & is_less_than;
dst1 = __msa_bmnz_v((v16u8) src1, dst1, is_less_than_beta1);
dst0 = (v16u8) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r);
dst0 = __msa_bmnz_v((v16u8) src0, dst0, is_less_than_beta1);
dst4 = (v16u8) __msa_pckev_b((v16i8) dst4_r, (v16i8) dst4_r);
is_less_than_beta2 = is_less_than_beta2 & is_less_than;
dst4 = __msa_bmnz_v((v16u8) src4, dst4, is_less_than_beta2);
dst5 = (v16u8) __msa_pckev_b((v16i8) dst5_r, (v16i8) dst5_r);
dst5 = __msa_bmnz_v((v16u8) src5, dst5, is_less_than_beta2);
dst0 = (v16u8) __msa_ilvr_b((v16i8) dst1, (v16i8) dst0);
dst1 = (v16u8) __msa_ilvr_b((v16i8) dst3_x, (v16i8) dst2_x);
dst2_x = (v16u8) __msa_ilvr_b((v16i8) dst5, (v16i8) dst4);
tmp0 = __msa_ilvr_h((v8i16) dst1, (v8i16) dst0);
tmp1 = __msa_ilvl_h((v8i16) dst1, (v8i16) dst0);
tmp2 = __msa_ilvr_h((v8i16) zeros, (v8i16) dst2_x);
tmp3 = __msa_ilvl_h((v8i16) zeros, (v8i16) dst2_x);
dst0 = (v16u8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
dst1 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst0, 8);
dst2_x = (v16u8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
dst3_x = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_x, 8);
dst4 = (v16u8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
dst5 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst4, 8);
dst2_y = (v16u8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
dst3_y = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_y, 8);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_h((v8i16) dst0, 2);
out2 = __msa_copy_u_w((v4i32) dst1, 0);
out3 = __msa_copy_u_h((v8i16) dst1, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_x, 0);
out1 = __msa_copy_u_h((v8i16) dst2_x, 2);
out2 = __msa_copy_u_w((v4i32) dst3_x, 0);
out3 = __msa_copy_u_h((v8i16) dst3_x, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst4, 0);
out1 = __msa_copy_u_h((v8i16) dst4, 2);
out2 = __msa_copy_u_w((v4i32) dst5, 0);
out3 = __msa_copy_u_h((v8i16) dst5, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_y, 0);
out1 = __msa_copy_u_h((v8i16) dst2_y, 2);
out2 = __msa_copy_u_w((v4i32) dst3_y, 0);
out3 = __msa_copy_u_h((v8i16) dst3_y, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | static void avc_h_loop_filter_luma_mbaff_intra_msa(uint8_t *src,
int32_t stride,
int32_t alpha_in,
int32_t beta_in)
{
uint64_t load0, load1;
uint32_t out0, out2;
uint16_t out1, out3;
v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r;
v8u16 dst0_r, dst1_r, dst4_r, dst5_r;
v8u16 dst2_x_r, dst2_y_r, dst3_x_r, dst3_y_r;
v16u8 dst0, dst1, dst4, dst5, dst2_x, dst2_y, dst3_x, dst3_y;
v8i16 tmp0, tmp1, tmp2, tmp3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;
v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;
v16u8 is_less_than_beta1, is_less_than_beta2;
v16i8 src0 = { 0 };
v16i8 src1 = { 0 };
v16i8 src2 = { 0 };
v16i8 src3 = { 0 };
v16i8 src4 = { 0 };
v16i8 src5 = { 0 };
v16i8 src6 = { 0 };
v16i8 src7 = { 0 };
v16i8 zeros = { 0 };
load0 = LOAD_DWORD(src - 4);
load1 = LOAD_DWORD(src + stride - 4);
src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, load0);
src1 = (v16i8) __msa_insert_d((v2i64) src1, 0, load1);
load0 = LOAD_DWORD(src + (2 * stride) - 4);
load1 = LOAD_DWORD(src + (3 * stride) - 4);
src2 = (v16i8) __msa_insert_d((v2i64) src2, 0, load0);
src3 = (v16i8) __msa_insert_d((v2i64) src3, 0, load1);
load0 = LOAD_DWORD(src + (4 * stride) - 4);
load1 = LOAD_DWORD(src + (5 * stride) - 4);
src4 = (v16i8) __msa_insert_d((v2i64) src4, 0, load0);
src5 = (v16i8) __msa_insert_d((v2i64) src5, 0, load1);
load0 = LOAD_DWORD(src + (6 * stride) - 4);
load1 = LOAD_DWORD(src + (7 * stride) - 4);
src6 = (v16i8) __msa_insert_d((v2i64) src6, 0, load0);
src7 = (v16i8) __msa_insert_d((v2i64) src7, 0, load1);
src0 = __msa_ilvr_b(src1, src0);
src1 = __msa_ilvr_b(src3, src2);
src2 = __msa_ilvr_b(src5, src4);
src3 = __msa_ilvr_b(src7, src6);
tmp0 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);
tmp1 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);
tmp2 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);
tmp3 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);
src6 = (v16i8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
src0 = __msa_sldi_b(zeros, src6, 8);
src1 = (v16i8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
src2 = __msa_sldi_b(zeros, src1, 8);
src3 = (v16i8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
src4 = __msa_sldi_b(zeros, src3, 8);
src5 = (v16i8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
src7 = __msa_sldi_b(zeros, src5, 8);
p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);
p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);
q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_alpha & is_less_than_beta;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than & is_less_than_beta;
alpha >>= 2;
alpha += 2;
is_less_than_alpha = (p0_asub_q0 < alpha);
p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);
is_less_than_beta1 = (p2_asub_p0 < beta);
q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);
is_less_than_beta2 = (q2_asub_q0 < beta);
src0_r = (v8u16) __msa_ilvr_b(zeros, src0);
src1_r = (v8u16) __msa_ilvr_b(zeros, src1);
src2_r = (v8u16) __msa_ilvr_b(zeros, src2);
src3_r = (v8u16) __msa_ilvr_b(zeros, src3);
src4_r = (v8u16) __msa_ilvr_b(zeros, src4);
src5_r = (v8u16) __msa_ilvr_b(zeros, src5);
src6_r = (v8u16) __msa_ilvr_b(zeros, src6);
src7_r = (v8u16) __msa_ilvr_b(zeros, src7);
dst2_x_r = src1_r + src2_r + src3_r;
dst2_x_r = src0_r + (2 * (dst2_x_r)) + src4_r;
dst2_x_r = (v8u16) __msa_srari_h((v8i16) dst2_x_r, 3);
dst1_r = src0_r + src1_r + src2_r + src3_r;
dst1_r = (v8u16) __msa_srari_h((v8i16) dst1_r, 2);
dst0_r = (2 * src6_r) + (3 * src0_r);
dst0_r += src1_r + src2_r + src3_r;
dst0_r = (v8u16) __msa_srari_h((v8i16) dst0_r, 3);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst2_x = (v16u8) __msa_pckev_b((v16i8) dst2_x_r, (v16i8) dst2_x_r);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_beta1);
dst3_x_r = src2_r + src3_r + src4_r;
dst3_x_r = src1_r + (2 * dst3_x_r) + src5_r;
dst3_x_r = (v8u16) __msa_srari_h((v8i16) dst3_x_r, 3);
dst4_r = src2_r + src3_r + src4_r + src5_r;
dst4_r = (v8u16) __msa_srari_h((v8i16) dst4_r, 2);
dst5_r = (2 * src7_r) + (3 * src5_r);
dst5_r += src4_r + src3_r + src2_r;
dst5_r = (v8u16) __msa_srari_h((v8i16) dst5_r, 3);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst3_x = (v16u8) __msa_pckev_b((v16i8) dst3_x_r, (v16i8) dst3_x_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_beta2);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_alpha);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_alpha);
dst2_x = __msa_bmnz_v((v16u8) src2, dst2_x, is_less_than);
dst3_x = __msa_bmnz_v((v16u8) src3, dst3_x, is_less_than);
is_less_than = is_less_than_alpha & is_less_than;
dst1 = (v16u8) __msa_pckev_b((v16i8) dst1_r, (v16i8) dst1_r);
is_less_than_beta1 = is_less_than_beta1 & is_less_than;
dst1 = __msa_bmnz_v((v16u8) src1, dst1, is_less_than_beta1);
dst0 = (v16u8) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r);
dst0 = __msa_bmnz_v((v16u8) src0, dst0, is_less_than_beta1);
dst4 = (v16u8) __msa_pckev_b((v16i8) dst4_r, (v16i8) dst4_r);
is_less_than_beta2 = is_less_than_beta2 & is_less_than;
dst4 = __msa_bmnz_v((v16u8) src4, dst4, is_less_than_beta2);
dst5 = (v16u8) __msa_pckev_b((v16i8) dst5_r, (v16i8) dst5_r);
dst5 = __msa_bmnz_v((v16u8) src5, dst5, is_less_than_beta2);
dst0 = (v16u8) __msa_ilvr_b((v16i8) dst1, (v16i8) dst0);
dst1 = (v16u8) __msa_ilvr_b((v16i8) dst3_x, (v16i8) dst2_x);
dst2_x = (v16u8) __msa_ilvr_b((v16i8) dst5, (v16i8) dst4);
tmp0 = __msa_ilvr_h((v8i16) dst1, (v8i16) dst0);
tmp1 = __msa_ilvl_h((v8i16) dst1, (v8i16) dst0);
tmp2 = __msa_ilvr_h((v8i16) zeros, (v8i16) dst2_x);
tmp3 = __msa_ilvl_h((v8i16) zeros, (v8i16) dst2_x);
dst0 = (v16u8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
dst1 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst0, 8);
dst2_x = (v16u8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
dst3_x = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_x, 8);
dst4 = (v16u8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
dst5 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst4, 8);
dst2_y = (v16u8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
dst3_y = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_y, 8);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_h((v8i16) dst0, 2);
out2 = __msa_copy_u_w((v4i32) dst1, 0);
out3 = __msa_copy_u_h((v8i16) dst1, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_x, 0);
out1 = __msa_copy_u_h((v8i16) dst2_x, 2);
out2 = __msa_copy_u_w((v4i32) dst3_x, 0);
out3 = __msa_copy_u_h((v8i16) dst3_x, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst4, 0);
out1 = __msa_copy_u_h((v8i16) dst4, 2);
out2 = __msa_copy_u_w((v4i32) dst5, 0);
out3 = __msa_copy_u_h((v8i16) dst5, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
src += stride;
out0 = __msa_copy_u_w((v4i32) dst2_y, 0);
out1 = __msa_copy_u_h((v8i16) dst2_y, 2);
out2 = __msa_copy_u_w((v4i32) dst3_y, 0);
out3 = __msa_copy_u_h((v8i16) dst3_y, 2);
STORE_WORD((src - 3), out0);
STORE_HWORD((src + 1), out1);
src += stride;
STORE_WORD((src - 3), out2);
STORE_HWORD((src + 1), out3);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0,
int32_t VAR_1,
int32_t VAR_2,
int32_t VAR_3)
{
uint64_t load0, load1;
uint32_t out0, out2;
uint16_t out1, out3;
v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r;
v8u16 dst0_r, dst1_r, dst4_r, dst5_r;
v8u16 dst2_x_r, dst2_y_r, dst3_x_r, dst3_y_r;
v16u8 dst0, dst1, dst4, dst5, dst2_x, dst2_y, dst3_x, dst3_y;
v8i16 tmp0, tmp1, tmp2, tmp3;
v16u8 alpha, beta;
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;
v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;
v16u8 is_less_than_beta1, is_less_than_beta2;
v16i8 src0 = { 0 };
v16i8 src1 = { 0 };
v16i8 src2 = { 0 };
v16i8 src3 = { 0 };
v16i8 src4 = { 0 };
v16i8 src5 = { 0 };
v16i8 src6 = { 0 };
v16i8 src7 = { 0 };
v16i8 zeros = { 0 };
load0 = LOAD_DWORD(VAR_0 - 4);
load1 = LOAD_DWORD(VAR_0 + VAR_1 - 4);
src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, load0);
src1 = (v16i8) __msa_insert_d((v2i64) src1, 0, load1);
load0 = LOAD_DWORD(VAR_0 + (2 * VAR_1) - 4);
load1 = LOAD_DWORD(VAR_0 + (3 * VAR_1) - 4);
src2 = (v16i8) __msa_insert_d((v2i64) src2, 0, load0);
src3 = (v16i8) __msa_insert_d((v2i64) src3, 0, load1);
load0 = LOAD_DWORD(VAR_0 + (4 * VAR_1) - 4);
load1 = LOAD_DWORD(VAR_0 + (5 * VAR_1) - 4);
src4 = (v16i8) __msa_insert_d((v2i64) src4, 0, load0);
src5 = (v16i8) __msa_insert_d((v2i64) src5, 0, load1);
load0 = LOAD_DWORD(VAR_0 + (6 * VAR_1) - 4);
load1 = LOAD_DWORD(VAR_0 + (7 * VAR_1) - 4);
src6 = (v16i8) __msa_insert_d((v2i64) src6, 0, load0);
src7 = (v16i8) __msa_insert_d((v2i64) src7, 0, load1);
src0 = __msa_ilvr_b(src1, src0);
src1 = __msa_ilvr_b(src3, src2);
src2 = __msa_ilvr_b(src5, src4);
src3 = __msa_ilvr_b(src7, src6);
tmp0 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);
tmp1 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);
tmp2 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);
tmp3 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);
src6 = (v16i8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
src0 = __msa_sldi_b(zeros, src6, 8);
src1 = (v16i8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
src2 = __msa_sldi_b(zeros, src1, 8);
src3 = (v16i8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
src4 = __msa_sldi_b(zeros, src3, 8);
src5 = (v16i8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
src7 = __msa_sldi_b(zeros, src5, 8);
p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);
p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);
q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);
alpha = (v16u8) __msa_fill_b(VAR_2);
beta = (v16u8) __msa_fill_b(VAR_3);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_alpha & is_less_than_beta;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than & is_less_than_beta;
alpha >>= 2;
alpha += 2;
is_less_than_alpha = (p0_asub_q0 < alpha);
p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);
is_less_than_beta1 = (p2_asub_p0 < beta);
q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);
is_less_than_beta2 = (q2_asub_q0 < beta);
src0_r = (v8u16) __msa_ilvr_b(zeros, src0);
src1_r = (v8u16) __msa_ilvr_b(zeros, src1);
src2_r = (v8u16) __msa_ilvr_b(zeros, src2);
src3_r = (v8u16) __msa_ilvr_b(zeros, src3);
src4_r = (v8u16) __msa_ilvr_b(zeros, src4);
src5_r = (v8u16) __msa_ilvr_b(zeros, src5);
src6_r = (v8u16) __msa_ilvr_b(zeros, src6);
src7_r = (v8u16) __msa_ilvr_b(zeros, src7);
dst2_x_r = src1_r + src2_r + src3_r;
dst2_x_r = src0_r + (2 * (dst2_x_r)) + src4_r;
dst2_x_r = (v8u16) __msa_srari_h((v8i16) dst2_x_r, 3);
dst1_r = src0_r + src1_r + src2_r + src3_r;
dst1_r = (v8u16) __msa_srari_h((v8i16) dst1_r, 2);
dst0_r = (2 * src6_r) + (3 * src0_r);
dst0_r += src1_r + src2_r + src3_r;
dst0_r = (v8u16) __msa_srari_h((v8i16) dst0_r, 3);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst2_x = (v16u8) __msa_pckev_b((v16i8) dst2_x_r, (v16i8) dst2_x_r);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_beta1);
dst3_x_r = src2_r + src3_r + src4_r;
dst3_x_r = src1_r + (2 * dst3_x_r) + src5_r;
dst3_x_r = (v8u16) __msa_srari_h((v8i16) dst3_x_r, 3);
dst4_r = src2_r + src3_r + src4_r + src5_r;
dst4_r = (v8u16) __msa_srari_h((v8i16) dst4_r, 2);
dst5_r = (2 * src7_r) + (3 * src5_r);
dst5_r += src4_r + src3_r + src2_r;
dst5_r = (v8u16) __msa_srari_h((v8i16) dst5_r, 3);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst3_x = (v16u8) __msa_pckev_b((v16i8) dst3_x_r, (v16i8) dst3_x_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_beta2);
dst2_y_r = (2 * src1_r) + src2_r + src4_r;
dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);
dst3_y_r = (2 * src4_r) + src3_r + src1_r;
dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);
dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);
dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);
dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_alpha);
dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_alpha);
dst2_x = __msa_bmnz_v((v16u8) src2, dst2_x, is_less_than);
dst3_x = __msa_bmnz_v((v16u8) src3, dst3_x, is_less_than);
is_less_than = is_less_than_alpha & is_less_than;
dst1 = (v16u8) __msa_pckev_b((v16i8) dst1_r, (v16i8) dst1_r);
is_less_than_beta1 = is_less_than_beta1 & is_less_than;
dst1 = __msa_bmnz_v((v16u8) src1, dst1, is_less_than_beta1);
dst0 = (v16u8) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r);
dst0 = __msa_bmnz_v((v16u8) src0, dst0, is_less_than_beta1);
dst4 = (v16u8) __msa_pckev_b((v16i8) dst4_r, (v16i8) dst4_r);
is_less_than_beta2 = is_less_than_beta2 & is_less_than;
dst4 = __msa_bmnz_v((v16u8) src4, dst4, is_less_than_beta2);
dst5 = (v16u8) __msa_pckev_b((v16i8) dst5_r, (v16i8) dst5_r);
dst5 = __msa_bmnz_v((v16u8) src5, dst5, is_less_than_beta2);
dst0 = (v16u8) __msa_ilvr_b((v16i8) dst1, (v16i8) dst0);
dst1 = (v16u8) __msa_ilvr_b((v16i8) dst3_x, (v16i8) dst2_x);
dst2_x = (v16u8) __msa_ilvr_b((v16i8) dst5, (v16i8) dst4);
tmp0 = __msa_ilvr_h((v8i16) dst1, (v8i16) dst0);
tmp1 = __msa_ilvl_h((v8i16) dst1, (v8i16) dst0);
tmp2 = __msa_ilvr_h((v8i16) zeros, (v8i16) dst2_x);
tmp3 = __msa_ilvl_h((v8i16) zeros, (v8i16) dst2_x);
dst0 = (v16u8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);
dst1 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst0, 8);
dst2_x = (v16u8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);
dst3_x = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_x, 8);
dst4 = (v16u8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);
dst5 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst4, 8);
dst2_y = (v16u8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);
dst3_y = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_y, 8);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_h((v8i16) dst0, 2);
out2 = __msa_copy_u_w((v4i32) dst1, 0);
out3 = __msa_copy_u_h((v8i16) dst1, 2);
STORE_WORD((VAR_0 - 3), out0);
STORE_HWORD((VAR_0 + 1), out1);
VAR_0 += VAR_1;
STORE_WORD((VAR_0 - 3), out2);
STORE_HWORD((VAR_0 + 1), out3);
VAR_0 += VAR_1;
out0 = __msa_copy_u_w((v4i32) dst2_x, 0);
out1 = __msa_copy_u_h((v8i16) dst2_x, 2);
out2 = __msa_copy_u_w((v4i32) dst3_x, 0);
out3 = __msa_copy_u_h((v8i16) dst3_x, 2);
STORE_WORD((VAR_0 - 3), out0);
STORE_HWORD((VAR_0 + 1), out1);
VAR_0 += VAR_1;
STORE_WORD((VAR_0 - 3), out2);
STORE_HWORD((VAR_0 + 1), out3);
VAR_0 += VAR_1;
out0 = __msa_copy_u_w((v4i32) dst4, 0);
out1 = __msa_copy_u_h((v8i16) dst4, 2);
out2 = __msa_copy_u_w((v4i32) dst5, 0);
out3 = __msa_copy_u_h((v8i16) dst5, 2);
STORE_WORD((VAR_0 - 3), out0);
STORE_HWORD((VAR_0 + 1), out1);
VAR_0 += VAR_1;
STORE_WORD((VAR_0 - 3), out2);
STORE_HWORD((VAR_0 + 1), out3);
VAR_0 += VAR_1;
out0 = __msa_copy_u_w((v4i32) dst2_y, 0);
out1 = __msa_copy_u_h((v8i16) dst2_y, 2);
out2 = __msa_copy_u_w((v4i32) dst3_y, 0);
out3 = __msa_copy_u_h((v8i16) dst3_y, 2);
STORE_WORD((VAR_0 - 3), out0);
STORE_HWORD((VAR_0 + 1), out1);
VAR_0 += VAR_1;
STORE_WORD((VAR_0 - 3), out2);
STORE_HWORD((VAR_0 + 1), out3);
}
| [
"static void FUNC_0(uint8_t *VAR_0,\nint32_t VAR_1,\nint32_t VAR_2,\nint32_t VAR_3)\n{",
"uint64_t load0, load1;",
"uint32_t out0, out2;",
"uint16_t out1, out3;",
"v8u16 src0_r, src1_r, src2_r, src3_r, src4_r, src5_r, src6_r, src7_r;",
"v8u16 dst0_r, dst1_r, dst4_r, dst5_r;",
"v8u16 dst2_x_r, dst2_y_r, dst3_x_r, dst3_y_r;",
"v16u8 dst0, dst1, dst4, dst5, dst2_x, dst2_y, dst3_x, dst3_y;",
"v8i16 tmp0, tmp1, tmp2, tmp3;",
"v16u8 alpha, beta;",
"v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, p2_asub_p0, q2_asub_q0;",
"v16u8 is_less_than, is_less_than_alpha, is_less_than_beta;",
"v16u8 is_less_than_beta1, is_less_than_beta2;",
"v16i8 src0 = { 0 };",
"v16i8 src1 = { 0 };",
"v16i8 src2 = { 0 };",
"v16i8 src3 = { 0 };",
"v16i8 src4 = { 0 };",
"v16i8 src5 = { 0 };",
"v16i8 src6 = { 0 };",
"v16i8 src7 = { 0 };",
"v16i8 zeros = { 0 };",
"load0 = LOAD_DWORD(VAR_0 - 4);",
"load1 = LOAD_DWORD(VAR_0 + VAR_1 - 4);",
"src0 = (v16i8) __msa_insert_d((v2i64) src0, 0, load0);",
"src1 = (v16i8) __msa_insert_d((v2i64) src1, 0, load1);",
"load0 = LOAD_DWORD(VAR_0 + (2 * VAR_1) - 4);",
"load1 = LOAD_DWORD(VAR_0 + (3 * VAR_1) - 4);",
"src2 = (v16i8) __msa_insert_d((v2i64) src2, 0, load0);",
"src3 = (v16i8) __msa_insert_d((v2i64) src3, 0, load1);",
"load0 = LOAD_DWORD(VAR_0 + (4 * VAR_1) - 4);",
"load1 = LOAD_DWORD(VAR_0 + (5 * VAR_1) - 4);",
"src4 = (v16i8) __msa_insert_d((v2i64) src4, 0, load0);",
"src5 = (v16i8) __msa_insert_d((v2i64) src5, 0, load1);",
"load0 = LOAD_DWORD(VAR_0 + (6 * VAR_1) - 4);",
"load1 = LOAD_DWORD(VAR_0 + (7 * VAR_1) - 4);",
"src6 = (v16i8) __msa_insert_d((v2i64) src6, 0, load0);",
"src7 = (v16i8) __msa_insert_d((v2i64) src7, 0, load1);",
"src0 = __msa_ilvr_b(src1, src0);",
"src1 = __msa_ilvr_b(src3, src2);",
"src2 = __msa_ilvr_b(src5, src4);",
"src3 = __msa_ilvr_b(src7, src6);",
"tmp0 = __msa_ilvr_h((v8i16) src1, (v8i16) src0);",
"tmp1 = __msa_ilvl_h((v8i16) src1, (v8i16) src0);",
"tmp2 = __msa_ilvr_h((v8i16) src3, (v8i16) src2);",
"tmp3 = __msa_ilvl_h((v8i16) src3, (v8i16) src2);",
"src6 = (v16i8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);",
"src0 = __msa_sldi_b(zeros, src6, 8);",
"src1 = (v16i8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);",
"src2 = __msa_sldi_b(zeros, src1, 8);",
"src3 = (v16i8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);",
"src4 = __msa_sldi_b(zeros, src3, 8);",
"src5 = (v16i8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);",
"src7 = __msa_sldi_b(zeros, src5, 8);",
"p0_asub_q0 = __msa_asub_u_b((v16u8) src2, (v16u8) src3);",
"p1_asub_p0 = __msa_asub_u_b((v16u8) src1, (v16u8) src2);",
"q1_asub_q0 = __msa_asub_u_b((v16u8) src4, (v16u8) src3);",
"alpha = (v16u8) __msa_fill_b(VAR_2);",
"beta = (v16u8) __msa_fill_b(VAR_3);",
"is_less_than_alpha = (p0_asub_q0 < alpha);",
"is_less_than_beta = (p1_asub_p0 < beta);",
"is_less_than = is_less_than_alpha & is_less_than_beta;",
"is_less_than_beta = (q1_asub_q0 < beta);",
"is_less_than = is_less_than & is_less_than_beta;",
"alpha >>= 2;",
"alpha += 2;",
"is_less_than_alpha = (p0_asub_q0 < alpha);",
"p2_asub_p0 = __msa_asub_u_b((v16u8) src0, (v16u8) src2);",
"is_less_than_beta1 = (p2_asub_p0 < beta);",
"q2_asub_q0 = __msa_asub_u_b((v16u8) src5, (v16u8) src3);",
"is_less_than_beta2 = (q2_asub_q0 < beta);",
"src0_r = (v8u16) __msa_ilvr_b(zeros, src0);",
"src1_r = (v8u16) __msa_ilvr_b(zeros, src1);",
"src2_r = (v8u16) __msa_ilvr_b(zeros, src2);",
"src3_r = (v8u16) __msa_ilvr_b(zeros, src3);",
"src4_r = (v8u16) __msa_ilvr_b(zeros, src4);",
"src5_r = (v8u16) __msa_ilvr_b(zeros, src5);",
"src6_r = (v8u16) __msa_ilvr_b(zeros, src6);",
"src7_r = (v8u16) __msa_ilvr_b(zeros, src7);",
"dst2_x_r = src1_r + src2_r + src3_r;",
"dst2_x_r = src0_r + (2 * (dst2_x_r)) + src4_r;",
"dst2_x_r = (v8u16) __msa_srari_h((v8i16) dst2_x_r, 3);",
"dst1_r = src0_r + src1_r + src2_r + src3_r;",
"dst1_r = (v8u16) __msa_srari_h((v8i16) dst1_r, 2);",
"dst0_r = (2 * src6_r) + (3 * src0_r);",
"dst0_r += src1_r + src2_r + src3_r;",
"dst0_r = (v8u16) __msa_srari_h((v8i16) dst0_r, 3);",
"dst2_y_r = (2 * src1_r) + src2_r + src4_r;",
"dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);",
"dst2_x = (v16u8) __msa_pckev_b((v16i8) dst2_x_r, (v16i8) dst2_x_r);",
"dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);",
"dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_beta1);",
"dst3_x_r = src2_r + src3_r + src4_r;",
"dst3_x_r = src1_r + (2 * dst3_x_r) + src5_r;",
"dst3_x_r = (v8u16) __msa_srari_h((v8i16) dst3_x_r, 3);",
"dst4_r = src2_r + src3_r + src4_r + src5_r;",
"dst4_r = (v8u16) __msa_srari_h((v8i16) dst4_r, 2);",
"dst5_r = (2 * src7_r) + (3 * src5_r);",
"dst5_r += src4_r + src3_r + src2_r;",
"dst5_r = (v8u16) __msa_srari_h((v8i16) dst5_r, 3);",
"dst3_y_r = (2 * src4_r) + src3_r + src1_r;",
"dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);",
"dst3_x = (v16u8) __msa_pckev_b((v16i8) dst3_x_r, (v16i8) dst3_x_r);",
"dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);",
"dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_beta2);",
"dst2_y_r = (2 * src1_r) + src2_r + src4_r;",
"dst2_y_r = (v8u16) __msa_srari_h((v8i16) dst2_y_r, 2);",
"dst3_y_r = (2 * src4_r) + src3_r + src1_r;",
"dst3_y_r = (v8u16) __msa_srari_h((v8i16) dst3_y_r, 2);",
"dst2_y = (v16u8) __msa_pckev_b((v16i8) dst2_y_r, (v16i8) dst2_y_r);",
"dst3_y = (v16u8) __msa_pckev_b((v16i8) dst3_y_r, (v16i8) dst3_y_r);",
"dst2_x = __msa_bmnz_v(dst2_y, dst2_x, is_less_than_alpha);",
"dst3_x = __msa_bmnz_v(dst3_y, dst3_x, is_less_than_alpha);",
"dst2_x = __msa_bmnz_v((v16u8) src2, dst2_x, is_less_than);",
"dst3_x = __msa_bmnz_v((v16u8) src3, dst3_x, is_less_than);",
"is_less_than = is_less_than_alpha & is_less_than;",
"dst1 = (v16u8) __msa_pckev_b((v16i8) dst1_r, (v16i8) dst1_r);",
"is_less_than_beta1 = is_less_than_beta1 & is_less_than;",
"dst1 = __msa_bmnz_v((v16u8) src1, dst1, is_less_than_beta1);",
"dst0 = (v16u8) __msa_pckev_b((v16i8) dst0_r, (v16i8) dst0_r);",
"dst0 = __msa_bmnz_v((v16u8) src0, dst0, is_less_than_beta1);",
"dst4 = (v16u8) __msa_pckev_b((v16i8) dst4_r, (v16i8) dst4_r);",
"is_less_than_beta2 = is_less_than_beta2 & is_less_than;",
"dst4 = __msa_bmnz_v((v16u8) src4, dst4, is_less_than_beta2);",
"dst5 = (v16u8) __msa_pckev_b((v16i8) dst5_r, (v16i8) dst5_r);",
"dst5 = __msa_bmnz_v((v16u8) src5, dst5, is_less_than_beta2);",
"dst0 = (v16u8) __msa_ilvr_b((v16i8) dst1, (v16i8) dst0);",
"dst1 = (v16u8) __msa_ilvr_b((v16i8) dst3_x, (v16i8) dst2_x);",
"dst2_x = (v16u8) __msa_ilvr_b((v16i8) dst5, (v16i8) dst4);",
"tmp0 = __msa_ilvr_h((v8i16) dst1, (v8i16) dst0);",
"tmp1 = __msa_ilvl_h((v8i16) dst1, (v8i16) dst0);",
"tmp2 = __msa_ilvr_h((v8i16) zeros, (v8i16) dst2_x);",
"tmp3 = __msa_ilvl_h((v8i16) zeros, (v8i16) dst2_x);",
"dst0 = (v16u8) __msa_ilvr_w((v4i32) tmp2, (v4i32) tmp0);",
"dst1 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst0, 8);",
"dst2_x = (v16u8) __msa_ilvl_w((v4i32) tmp2, (v4i32) tmp0);",
"dst3_x = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_x, 8);",
"dst4 = (v16u8) __msa_ilvr_w((v4i32) tmp3, (v4i32) tmp1);",
"dst5 = (v16u8) __msa_sldi_b(zeros, (v16i8) dst4, 8);",
"dst2_y = (v16u8) __msa_ilvl_w((v4i32) tmp3, (v4i32) tmp1);",
"dst3_y = (v16u8) __msa_sldi_b(zeros, (v16i8) dst2_y, 8);",
"out0 = __msa_copy_u_w((v4i32) dst0, 0);",
"out1 = __msa_copy_u_h((v8i16) dst0, 2);",
"out2 = __msa_copy_u_w((v4i32) dst1, 0);",
"out3 = __msa_copy_u_h((v8i16) dst1, 2);",
"STORE_WORD((VAR_0 - 3), out0);",
"STORE_HWORD((VAR_0 + 1), out1);",
"VAR_0 += VAR_1;",
"STORE_WORD((VAR_0 - 3), out2);",
"STORE_HWORD((VAR_0 + 1), out3);",
"VAR_0 += VAR_1;",
"out0 = __msa_copy_u_w((v4i32) dst2_x, 0);",
"out1 = __msa_copy_u_h((v8i16) dst2_x, 2);",
"out2 = __msa_copy_u_w((v4i32) dst3_x, 0);",
"out3 = __msa_copy_u_h((v8i16) dst3_x, 2);",
"STORE_WORD((VAR_0 - 3), out0);",
"STORE_HWORD((VAR_0 + 1), out1);",
"VAR_0 += VAR_1;",
"STORE_WORD((VAR_0 - 3), out2);",
"STORE_HWORD((VAR_0 + 1), out3);",
"VAR_0 += VAR_1;",
"out0 = __msa_copy_u_w((v4i32) dst4, 0);",
"out1 = __msa_copy_u_h((v8i16) dst4, 2);",
"out2 = __msa_copy_u_w((v4i32) dst5, 0);",
"out3 = __msa_copy_u_h((v8i16) dst5, 2);",
"STORE_WORD((VAR_0 - 3), out0);",
"STORE_HWORD((VAR_0 + 1), out1);",
"VAR_0 += VAR_1;",
"STORE_WORD((VAR_0 - 3), out2);",
"STORE_HWORD((VAR_0 + 1), out3);",
"VAR_0 += VAR_1;",
"out0 = __msa_copy_u_w((v4i32) dst2_y, 0);",
"out1 = __msa_copy_u_h((v8i16) dst2_y, 2);",
"out2 = __msa_copy_u_w((v4i32) dst3_y, 0);",
"out3 = __msa_copy_u_h((v8i16) dst3_y, 2);",
"STORE_WORD((VAR_0 - 3), out0);",
"STORE_HWORD((VAR_0 + 1), out1);",
"VAR_0 += VAR_1;",
"STORE_WORD((VAR_0 - 3), out2);",
"STORE_HWORD((VAR_0 + 1), out3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
299
],
[
301
],
[
305
],
[
307
],
[
309
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
351
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
399
],
[
401
],
[
403
],
[
405
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
423
],
[
425
],
[
427
],
[
429
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
]
] |
21,977 | static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
int i;
int width;
int height;
int64_t disp_transform[2];
int display_matrix[3][2];
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
get_be24(pb); /* flags */
/*
MOV_TRACK_ENABLED 0x0001
MOV_TRACK_IN_MOVIE 0x0002
MOV_TRACK_IN_PREVIEW 0x0004
MOV_TRACK_IN_POSTER 0x0008
*/
if (version == 1) {
get_be64(pb);
get_be64(pb);
} else {
get_be32(pb); /* creation time */
get_be32(pb); /* modification time */
}
st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
get_be32(pb); /* reserved */
/* highlevel (considering edits) duration in movie timebase */
(version == 1) ? get_be64(pb) : get_be32(pb);
get_be32(pb); /* reserved */
get_be32(pb); /* reserved */
get_be16(pb); /* layer */
get_be16(pb); /* alternate group */
get_be16(pb); /* volume */
get_be16(pb); /* reserved */
//read in the display matrix (outlined in ISO 14496-12, Section 6.2.2)
// they're kept in fixed point format through all calculations
// ignore u,v,z b/c we don't need the scale factor to calc aspect ratio
for (i = 0; i < 3; i++) {
display_matrix[i][0] = get_be32(pb); // 16.16 fixed point
display_matrix[i][1] = get_be32(pb); // 16.16 fixed point
get_be32(pb); // 2.30 fixed point (not used)
}
width = get_be32(pb); // 16.16 fixed point track width
height = get_be32(pb); // 16.16 fixed point track height
sc->width = width >> 16;
sc->height = height >> 16;
//transform the display width/height according to the matrix
// skip this if the display matrix is the default identity matrix
// to keep the same scale, use [width height 1<<16]
if (width && height &&
(display_matrix[0][0] != 65536 || display_matrix[0][1] ||
display_matrix[1][0] || display_matrix[1][1] != 65536 ||
display_matrix[2][0] || display_matrix[2][1])) {
for (i = 0; i < 2; i++)
disp_transform[i] =
(int64_t) width * display_matrix[0][i] +
(int64_t) height * display_matrix[1][i] +
((int64_t) display_matrix[2][i] << 16);
//sample aspect ratio is new width/height divided by old width/height
st->sample_aspect_ratio = av_d2q(
((double) disp_transform[0] * height) /
((double) disp_transform[1] * width), INT_MAX);
}
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
int i;
int width;
int height;
int64_t disp_transform[2];
int display_matrix[3][2];
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
get_be24(pb);
if (version == 1) {
get_be64(pb);
get_be64(pb);
} else {
get_be32(pb);
get_be32(pb);
}
st->id = (int)get_be32(pb);
get_be32(pb);
(version == 1) ? get_be64(pb) : get_be32(pb);
get_be32(pb);
get_be32(pb);
get_be16(pb);
get_be16(pb);
get_be16(pb);
get_be16(pb);
for (i = 0; i < 3; i++) {
display_matrix[i][0] = get_be32(pb);
display_matrix[i][1] = get_be32(pb);
get_be32(pb);
}
width = get_be32(pb); track width
height = get_be32(pb); track height
sc->width = width >> 16;
sc->height = height >> 16;
if (width && height &&
(display_matrix[0][0] != 65536 || display_matrix[0][1] ||
display_matrix[1][0] || display_matrix[1][1] != 65536 ||
display_matrix[2][0] || display_matrix[2][1])) {
for (i = 0; i < 2; i++)
disp_transform[i] =
(int64_t) width * display_matrix[0][i] +
(int64_t) height * display_matrix[1][i] +
((int64_t) display_matrix[2][i] << 16);
st->sample_aspect_ratio = av_d2q(
((double) disp_transform[0] * height) /
((double) disp_transform[1] * width), INT_MAX);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
int VAR_3;
int VAR_4;
int VAR_5;
int64_t disp_transform[2];
int VAR_6[3][2];
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int VAR_7 = get_byte(VAR_1);
get_be24(VAR_1);
if (VAR_7 == 1) {
get_be64(VAR_1);
get_be64(VAR_1);
} else {
get_be32(VAR_1);
get_be32(VAR_1);
}
st->id = (int)get_be32(VAR_1);
get_be32(VAR_1);
(VAR_7 == 1) ? get_be64(VAR_1) : get_be32(VAR_1);
get_be32(VAR_1);
get_be32(VAR_1);
get_be16(VAR_1);
get_be16(VAR_1);
get_be16(VAR_1);
get_be16(VAR_1);
for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {
VAR_6[VAR_3][0] = get_be32(VAR_1);
VAR_6[VAR_3][1] = get_be32(VAR_1);
get_be32(VAR_1);
}
VAR_4 = get_be32(VAR_1); track VAR_4
VAR_5 = get_be32(VAR_1); track VAR_5
sc->VAR_4 = VAR_4 >> 16;
sc->VAR_5 = VAR_5 >> 16;
if (VAR_4 && VAR_5 &&
(VAR_6[0][0] != 65536 || VAR_6[0][1] ||
VAR_6[1][0] || VAR_6[1][1] != 65536 ||
VAR_6[2][0] || VAR_6[2][1])) {
for (VAR_3 = 0; VAR_3 < 2; VAR_3++)
disp_transform[VAR_3] =
(int64_t) VAR_4 * VAR_6[0][VAR_3] +
(int64_t) VAR_5 * VAR_6[1][VAR_3] +
((int64_t) VAR_6[2][VAR_3] << 16);
st->sample_aspect_ratio = av_d2q(
((double) disp_transform[0] * VAR_5) /
((double) disp_transform[1] * VAR_4), INT_MAX);
}
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"int VAR_3;",
"int VAR_4;",
"int VAR_5;",
"int64_t disp_transform[2];",
"int VAR_6[3][2];",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"MOVStreamContext *sc = st->priv_data;",
"int VAR_7 = get_byte(VAR_1);",
"get_be24(VAR_1);",
"if (VAR_7 == 1) {",
"get_be64(VAR_1);",
"get_be64(VAR_1);",
"} else {",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"}",
"st->id = (int)get_be32(VAR_1);",
"get_be32(VAR_1);",
"(VAR_7 == 1) ? get_be64(VAR_1) : get_be32(VAR_1);",
"get_be32(VAR_1);",
"get_be32(VAR_1);",
"get_be16(VAR_1);",
"get_be16(VAR_1);",
"get_be16(VAR_1);",
"get_be16(VAR_1);",
"for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {",
"VAR_6[VAR_3][0] = get_be32(VAR_1);",
"VAR_6[VAR_3][1] = get_be32(VAR_1);",
"get_be32(VAR_1);",
"}",
"VAR_4 = get_be32(VAR_1); track VAR_4",
"VAR_5 = get_be32(VAR_1); track VAR_5",
"sc->VAR_4 = VAR_4 >> 16;",
"sc->VAR_5 = VAR_5 >> 16;",
"if (VAR_4 && VAR_5 &&\n(VAR_6[0][0] != 65536 || VAR_6[0][1] ||\nVAR_6[1][0] || VAR_6[1][1] != 65536 ||\nVAR_6[2][0] || VAR_6[2][1])) {",
"for (VAR_3 = 0; VAR_3 < 2; VAR_3++)",
"disp_transform[VAR_3] =\n(int64_t) VAR_4 * VAR_6[0][VAR_3] +\n(int64_t) VAR_5 * VAR_6[1][VAR_3] +\n((int64_t) VAR_6[2][VAR_3] << 16);",
"st->sample_aspect_ratio = av_d2q(\n((double) disp_transform[0] * VAR_5) /\n((double) disp_transform[1] * VAR_4), INT_MAX);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
113,
115,
117,
119
],
[
121
],
[
123,
125,
127,
129
],
[
135,
137,
139
],
[
141
],
[
143
],
[
145
]
] |
21,978 | static void v9fs_read(void *opaque)
{
int32_t fid;
int64_t off;
ssize_t err = 0;
int32_t count = 0;
size_t offset = 7;
int32_t max_count;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &max_count);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_DIR) {
if (off == 0) {
v9fs_co_rewinddir(pdu, fidp);
}
count = v9fs_do_readdir_with_stat(pdu, fidp, max_count);
if (count < 0) {
err = count;
goto out;
}
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_FILE) {
int32_t cnt;
int32_t len;
struct iovec *sg;
struct iovec iov[128]; /* FIXME: bad, bad, bad */
sg = iov;
pdu_marshal(pdu, offset + 4, "v", sg, &cnt);
sg = cap_sg(sg, max_count, &cnt);
do {
if (0) {
print_sg(sg, cnt);
}
/* Loop in case of EINTR */
do {
len = v9fs_co_preadv(pdu, fidp, sg, cnt, off);
if (len >= 0) {
off += len;
count += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
/* IO error return the error */
err = len;
goto out;
}
sg = adjust_sg(sg, len, &cnt);
} while (count < max_count && len > 0);
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_read(s, pdu, fidp, off, max_count);
} else {
err = -EINVAL;
}
out:
put_fid(pdu, fidp);
out_nofid:
trace_v9fs_read_return(pdu->tag, pdu->id, count, err);
complete_pdu(s, pdu, err);
} | true | qemu | c572f23a3e7180dbeab5e86583e43ea2afed6271 | static void v9fs_read(void *opaque)
{
int32_t fid;
int64_t off;
ssize_t err = 0;
int32_t count = 0;
size_t offset = 7;
int32_t max_count;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &max_count);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_DIR) {
if (off == 0) {
v9fs_co_rewinddir(pdu, fidp);
}
count = v9fs_do_readdir_with_stat(pdu, fidp, max_count);
if (count < 0) {
err = count;
goto out;
}
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_FILE) {
int32_t cnt;
int32_t len;
struct iovec *sg;
struct iovec iov[128];
sg = iov;
pdu_marshal(pdu, offset + 4, "v", sg, &cnt);
sg = cap_sg(sg, max_count, &cnt);
do {
if (0) {
print_sg(sg, cnt);
}
do {
len = v9fs_co_preadv(pdu, fidp, sg, cnt, off);
if (len >= 0) {
off += len;
count += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
err = len;
goto out;
}
sg = adjust_sg(sg, len, &cnt);
} while (count < max_count && len > 0);
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_read(s, pdu, fidp, off, max_count);
} else {
err = -EINVAL;
}
out:
put_fid(pdu, fidp);
out_nofid:
trace_v9fs_read_return(pdu->tag, pdu->id, count, err);
complete_pdu(s, pdu, err);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
int32_t fid;
int64_t off;
ssize_t err = 0;
int32_t count = 0;
size_t offset = 7;
int32_t max_count;
V9fsFidState *fidp;
V9fsPDU *pdu = VAR_0;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &max_count);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_DIR) {
if (off == 0) {
v9fs_co_rewinddir(pdu, fidp);
}
count = v9fs_do_readdir_with_stat(pdu, fidp, max_count);
if (count < 0) {
err = count;
goto out;
}
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_FILE) {
int32_t cnt;
int32_t len;
struct iovec *VAR_1;
struct iovec VAR_2[128];
VAR_1 = VAR_2;
pdu_marshal(pdu, offset + 4, "v", VAR_1, &cnt);
VAR_1 = cap_sg(VAR_1, max_count, &cnt);
do {
if (0) {
print_sg(VAR_1, cnt);
}
do {
len = v9fs_co_preadv(pdu, fidp, VAR_1, cnt, off);
if (len >= 0) {
off += len;
count += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
err = len;
goto out;
}
VAR_1 = adjust_sg(VAR_1, len, &cnt);
} while (count < max_count && len > 0);
err = offset;
err += pdu_marshal(pdu, offset, "d", count);
err += count;
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_read(s, pdu, fidp, off, max_count);
} else {
err = -EINVAL;
}
out:
put_fid(pdu, fidp);
out_nofid:
trace_v9fs_read_return(pdu->tag, pdu->id, count, err);
complete_pdu(s, pdu, err);
} | [
"static void FUNC_0(void *VAR_0)\n{",
"int32_t fid;",
"int64_t off;",
"ssize_t err = 0;",
"int32_t count = 0;",
"size_t offset = 7;",
"int32_t max_count;",
"V9fsFidState *fidp;",
"V9fsPDU *pdu = VAR_0;",
"V9fsState *s = pdu->s;",
"pdu_unmarshal(pdu, offset, \"dqd\", &fid, &off, &max_count);",
"fidp = get_fid(pdu, fid);",
"if (fidp == NULL) {",
"err = -EINVAL;",
"goto out_nofid;",
"}",
"if (fidp->fid_type == P9_FID_DIR) {",
"if (off == 0) {",
"v9fs_co_rewinddir(pdu, fidp);",
"}",
"count = v9fs_do_readdir_with_stat(pdu, fidp, max_count);",
"if (count < 0) {",
"err = count;",
"goto out;",
"}",
"err = offset;",
"err += pdu_marshal(pdu, offset, \"d\", count);",
"err += count;",
"} else if (fidp->fid_type == P9_FID_FILE) {",
"int32_t cnt;",
"int32_t len;",
"struct iovec *VAR_1;",
"struct iovec VAR_2[128];",
"VAR_1 = VAR_2;",
"pdu_marshal(pdu, offset + 4, \"v\", VAR_1, &cnt);",
"VAR_1 = cap_sg(VAR_1, max_count, &cnt);",
"do {",
"if (0) {",
"print_sg(VAR_1, cnt);",
"}",
"do {",
"len = v9fs_co_preadv(pdu, fidp, VAR_1, cnt, off);",
"if (len >= 0) {",
"off += len;",
"count += len;",
"}",
"} while (len == -EINTR && !pdu->cancelled);",
"if (len < 0) {",
"err = len;",
"goto out;",
"}",
"VAR_1 = adjust_sg(VAR_1, len, &cnt);",
"} while (count < max_count && len > 0);",
"err = offset;",
"err += pdu_marshal(pdu, offset, \"d\", count);",
"err += count;",
"} else if (fidp->fid_type == P9_FID_XATTR) {",
"err = v9fs_xattr_read(s, pdu, fidp, off, max_count);",
"} else {",
"err = -EINVAL;",
"}",
"out:\nput_fid(pdu, fidp);",
"out_nofid:\ntrace_v9fs_read_return(pdu->tag, pdu->id, count, err);",
"complete_pdu(s, pdu, 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
44
],
[
46
],
[
48
],
[
50
],
[
52
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
64
],
[
66
],
[
68
],
[
70
],
[
72
],
[
74
],
[
78
],
[
80
],
[
82
],
[
84
],
[
86
],
[
88
],
[
90
],
[
94
],
[
96
],
[
98
],
[
100
],
[
102
],
[
104
],
[
106
],
[
108
],
[
112
],
[
114
],
[
116
],
[
118
],
[
120
],
[
122
],
[
124
],
[
126
],
[
128
],
[
130
],
[
132
],
[
134
],
[
136
],
[
138,
140
],
[
142,
144
],
[
146
],
[
148
]
] |
21,979 | int qio_channel_readv_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp)
{
int ret = -1;
struct iovec *local_iov = g_new(struct iovec, niov);
struct iovec *local_iov_head = local_iov;
unsigned int nlocal_iov = niov;
nlocal_iov = iov_copy(local_iov, nlocal_iov,
iov, niov,
0, iov_size(iov, niov));
while (nlocal_iov > 0) {
ssize_t len;
len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
if (len == QIO_CHANNEL_ERR_BLOCK) {
if (qemu_in_coroutine()) {
qio_channel_yield(ioc, G_IO_IN);
} else {
qio_channel_wait(ioc, G_IO_IN);
}
continue;
} else if (len < 0) {
goto cleanup;
} else if (len == 0) {
error_setg(errp,
"Unexpected end-of-file before all bytes were read");
goto cleanup;
}
iov_discard_front(&local_iov, &nlocal_iov, len);
}
ret = 0;
cleanup:
g_free(local_iov_head);
return ret;
}
| true | qemu | e8ffaa311080a570a7c86d03c139c160cd11a831 | int qio_channel_readv_all(QIOChannel *ioc,
const struct iovec *iov,
size_t niov,
Error **errp)
{
int ret = -1;
struct iovec *local_iov = g_new(struct iovec, niov);
struct iovec *local_iov_head = local_iov;
unsigned int nlocal_iov = niov;
nlocal_iov = iov_copy(local_iov, nlocal_iov,
iov, niov,
0, iov_size(iov, niov));
while (nlocal_iov > 0) {
ssize_t len;
len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
if (len == QIO_CHANNEL_ERR_BLOCK) {
if (qemu_in_coroutine()) {
qio_channel_yield(ioc, G_IO_IN);
} else {
qio_channel_wait(ioc, G_IO_IN);
}
continue;
} else if (len < 0) {
goto cleanup;
} else if (len == 0) {
error_setg(errp,
"Unexpected end-of-file before all bytes were read");
goto cleanup;
}
iov_discard_front(&local_iov, &nlocal_iov, len);
}
ret = 0;
cleanup:
g_free(local_iov_head);
return ret;
}
| {
"code": [
"int qio_channel_readv_all(QIOChannel *ioc,",
" const struct iovec *iov,",
" size_t niov,",
" Error **errp)",
" error_setg(errp,",
" \"Unexpected end-of-file before all bytes were read\");",
" ret = 0;"
],
"line_no": [
1,
3,
5,
7,
55,
57,
71
]
} | int FUNC_0(QIOChannel *VAR_0,
const struct iovec *VAR_1,
size_t VAR_2,
Error **VAR_3)
{
int VAR_4 = -1;
struct iovec *VAR_5 = g_new(struct iovec, VAR_2);
struct iovec *VAR_6 = VAR_5;
unsigned int VAR_7 = VAR_2;
VAR_7 = iov_copy(VAR_5, VAR_7,
VAR_1, VAR_2,
0, iov_size(VAR_1, VAR_2));
while (VAR_7 > 0) {
ssize_t len;
len = qio_channel_readv(VAR_0, VAR_5, VAR_7, VAR_3);
if (len == QIO_CHANNEL_ERR_BLOCK) {
if (qemu_in_coroutine()) {
qio_channel_yield(VAR_0, G_IO_IN);
} else {
qio_channel_wait(VAR_0, G_IO_IN);
}
continue;
} else if (len < 0) {
goto cleanup;
} else if (len == 0) {
error_setg(VAR_3,
"Unexpected end-of-file before all bytes were read");
goto cleanup;
}
iov_discard_front(&VAR_5, &VAR_7, len);
}
VAR_4 = 0;
cleanup:
g_free(VAR_6);
return VAR_4;
}
| [
"int FUNC_0(QIOChannel *VAR_0,\nconst struct iovec *VAR_1,\nsize_t VAR_2,\nError **VAR_3)\n{",
"int VAR_4 = -1;",
"struct iovec *VAR_5 = g_new(struct iovec, VAR_2);",
"struct iovec *VAR_6 = VAR_5;",
"unsigned int VAR_7 = VAR_2;",
"VAR_7 = iov_copy(VAR_5, VAR_7,\nVAR_1, VAR_2,\n0, iov_size(VAR_1, VAR_2));",
"while (VAR_7 > 0) {",
"ssize_t len;",
"len = qio_channel_readv(VAR_0, VAR_5, VAR_7, VAR_3);",
"if (len == QIO_CHANNEL_ERR_BLOCK) {",
"if (qemu_in_coroutine()) {",
"qio_channel_yield(VAR_0, G_IO_IN);",
"} else {",
"qio_channel_wait(VAR_0, G_IO_IN);",
"}",
"continue;",
"} else if (len < 0) {",
"goto cleanup;",
"} else if (len == 0) {",
"error_setg(VAR_3,\n\"Unexpected end-of-file before all bytes were read\");",
"goto cleanup;",
"}",
"iov_discard_front(&VAR_5, &VAR_7, len);",
"}",
"VAR_4 = 0;",
"cleanup:\ng_free(VAR_6);",
"return VAR_4;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
71
],
[
75,
77
],
[
79
],
[
81
]
] |
21,981 | void qvirtio_pci_device_disable(QVirtioPCIDevice *d)
{
qpci_iounmap(d->pdev, d->addr);
d->addr = NULL;
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | void qvirtio_pci_device_disable(QVirtioPCIDevice *d)
{
qpci_iounmap(d->pdev, d->addr);
d->addr = NULL;
}
| {
"code": [
" qpci_iounmap(d->pdev, d->addr);",
" d->addr = NULL;"
],
"line_no": [
5,
7
]
} | void FUNC_0(QVirtioPCIDevice *VAR_0)
{
qpci_iounmap(VAR_0->pdev, VAR_0->addr);
VAR_0->addr = NULL;
}
| [
"void FUNC_0(QVirtioPCIDevice *VAR_0)\n{",
"qpci_iounmap(VAR_0->pdev, VAR_0->addr);",
"VAR_0->addr = NULL;",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
21,982 | static void vfio_vga_quirk_teardown(VFIODevice *vdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(vdev->vga.region); i++) {
while (!QLIST_EMPTY(&vdev->vga.region[i].quirks)) {
VFIOQuirk *quirk = QLIST_FIRST(&vdev->vga.region[i].quirks);
memory_region_del_subregion(&vdev->vga.region[i].mem, &quirk->mem);
QLIST_REMOVE(quirk, next);
g_free(quirk);
}
}
} | true | qemu | 7c4228b4771acddcb8815079bc116007cec8a1ff | static void vfio_vga_quirk_teardown(VFIODevice *vdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(vdev->vga.region); i++) {
while (!QLIST_EMPTY(&vdev->vga.region[i].quirks)) {
VFIOQuirk *quirk = QLIST_FIRST(&vdev->vga.region[i].quirks);
memory_region_del_subregion(&vdev->vga.region[i].mem, &quirk->mem);
QLIST_REMOVE(quirk, next);
g_free(quirk);
}
}
} | {
"code": [],
"line_no": []
} | static void FUNC_0(VFIODevice *VAR_0)
{
int VAR_1;
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_0->vga.region); VAR_1++) {
while (!QLIST_EMPTY(&VAR_0->vga.region[VAR_1].quirks)) {
VFIOQuirk *quirk = QLIST_FIRST(&VAR_0->vga.region[VAR_1].quirks);
memory_region_del_subregion(&VAR_0->vga.region[VAR_1].mem, &quirk->mem);
QLIST_REMOVE(quirk, next);
g_free(quirk);
}
}
} | [
"static void FUNC_0(VFIODevice *VAR_0)\n{",
"int VAR_1;",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(VAR_0->vga.region); VAR_1++) {",
"while (!QLIST_EMPTY(&VAR_0->vga.region[VAR_1].quirks)) {",
"VFIOQuirk *quirk = QLIST_FIRST(&VAR_0->vga.region[VAR_1].quirks);",
"memory_region_del_subregion(&VAR_0->vga.region[VAR_1].mem, &quirk->mem);",
"QLIST_REMOVE(quirk, next);",
"g_free(quirk);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
]
] |
21,983 | int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
{
void *log_ctx = s->avctx;
int ret;
av_log(log_ctx, AV_LOG_DEBUG, "%s full reinit\n", s->devname);
/* wait for pending buffer references */
if (atomic_load(&s->refcount))
while(sem_wait(&s->refsync) == -1 && errno == EINTR);
/* close the driver */
ff_v4l2_m2m_codec_end(s->avctx);
/* start again now that we know the stream dimensions */
s->draining = 0;
s->reinit = 0;
s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);
if (s->fd < 0)
return AVERROR(errno);
ret = v4l2_prepare_contexts(s);
if (ret < 0)
goto error;
/* if a full re-init was requested - probe didn't run - we need to populate
* the format for each context
*/
ret = ff_v4l2_context_get_format(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
goto error;
}
ret = ff_v4l2_context_get_format(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
goto error;
}
ret = ff_v4l2_context_set_format(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n");
goto error;
}
ret = ff_v4l2_context_set_format(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "can't to set v4l2 capture format\n");
goto error;
}
ret = ff_v4l2_context_init(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 output context's buffers\n");
goto error;
}
/* decoder's buffers need to be updated at a later stage */
if (!av_codec_is_decoder(s->avctx->codec)) {
ret = ff_v4l2_context_init(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
goto error;
}
}
return 0;
error:
if (close(s->fd) < 0) {
ret = AVERROR(errno);
av_log(log_ctx, AV_LOG_ERROR, "error closing %s (%s)\n",
s->devname, av_err2str(AVERROR(errno)));
}
s->fd = -1;
return ret;
}
| true | FFmpeg | a0c624e299730c8c5800375c2f5f3c6c200053ff | int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
{
void *log_ctx = s->avctx;
int ret;
av_log(log_ctx, AV_LOG_DEBUG, "%s full reinit\n", s->devname);
if (atomic_load(&s->refcount))
while(sem_wait(&s->refsync) == -1 && errno == EINTR);
ff_v4l2_m2m_codec_end(s->avctx);
s->draining = 0;
s->reinit = 0;
s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);
if (s->fd < 0)
return AVERROR(errno);
ret = v4l2_prepare_contexts(s);
if (ret < 0)
goto error;
ret = ff_v4l2_context_get_format(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 output format not supported\n");
goto error;
}
ret = ff_v4l2_context_get_format(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
goto error;
}
ret = ff_v4l2_context_set_format(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n");
goto error;
}
ret = ff_v4l2_context_set_format(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "can't to set v4l2 capture format\n");
goto error;
}
ret = ff_v4l2_context_init(&s->output);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 output context's buffers\n");
goto error;
}
if (!av_codec_is_decoder(s->avctx->codec)) {
ret = ff_v4l2_context_init(&s->capture);
if (ret) {
av_log(log_ctx, AV_LOG_ERROR, "no v4l2 capture context's buffers\n");
goto error;
}
}
return 0;
error:
if (close(s->fd) < 0) {
ret = AVERROR(errno);
av_log(log_ctx, AV_LOG_ERROR, "error closing %s (%s)\n",
s->devname, av_err2str(AVERROR(errno)));
}
s->fd = -1;
return ret;
}
| {
"code": [
" ff_v4l2_m2m_codec_end(s->avctx);",
" s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);",
" if (s->fd < 0)",
" return AVERROR(errno);",
" ret = v4l2_prepare_contexts(s);",
" if (ret < 0)",
" goto error;",
" if (close(s->fd) < 0) {",
" ret = AVERROR(errno);",
" av_log(log_ctx, AV_LOG_ERROR, \"error closing %s (%s)\\n\",",
" s->devname, av_err2str(AVERROR(errno)));",
" s->fd = -1;",
" if (atomic_load(&s->refcount))",
" s->fd = -1;"
],
"line_no": [
25,
37,
39,
41,
45,
47,
49,
143,
145,
147,
149,
153,
17,
153
]
} | int FUNC_0(V4L2m2mContext *VAR_0)
{
void *VAR_1 = VAR_0->avctx;
int VAR_2;
av_log(VAR_1, AV_LOG_DEBUG, "%VAR_0 full reinit\n", VAR_0->devname);
if (atomic_load(&VAR_0->refcount))
while(sem_wait(&VAR_0->refsync) == -1 && errno == EINTR);
ff_v4l2_m2m_codec_end(VAR_0->avctx);
VAR_0->draining = 0;
VAR_0->reinit = 0;
VAR_0->fd = open(VAR_0->devname, O_RDWR | O_NONBLOCK, 0);
if (VAR_0->fd < 0)
return AVERROR(errno);
VAR_2 = v4l2_prepare_contexts(VAR_0);
if (VAR_2 < 0)
goto error;
VAR_2 = ff_v4l2_context_get_format(&VAR_0->output);
if (VAR_2) {
av_log(VAR_1, AV_LOG_DEBUG, "v4l2 output format not supported\n");
goto error;
}
VAR_2 = ff_v4l2_context_get_format(&VAR_0->capture);
if (VAR_2) {
av_log(VAR_1, AV_LOG_DEBUG, "v4l2 capture format not supported\n");
goto error;
}
VAR_2 = ff_v4l2_context_set_format(&VAR_0->output);
if (VAR_2) {
av_log(VAR_1, AV_LOG_ERROR, "can't set v4l2 output format\n");
goto error;
}
VAR_2 = ff_v4l2_context_set_format(&VAR_0->capture);
if (VAR_2) {
av_log(VAR_1, AV_LOG_ERROR, "can't to set v4l2 capture format\n");
goto error;
}
VAR_2 = ff_v4l2_context_init(&VAR_0->output);
if (VAR_2) {
av_log(VAR_1, AV_LOG_ERROR, "no v4l2 output context'VAR_0 buffers\n");
goto error;
}
if (!av_codec_is_decoder(VAR_0->avctx->codec)) {
VAR_2 = ff_v4l2_context_init(&VAR_0->capture);
if (VAR_2) {
av_log(VAR_1, AV_LOG_ERROR, "no v4l2 capture context'VAR_0 buffers\n");
goto error;
}
}
return 0;
error:
if (close(VAR_0->fd) < 0) {
VAR_2 = AVERROR(errno);
av_log(VAR_1, AV_LOG_ERROR, "error closing %VAR_0 (%VAR_0)\n",
VAR_0->devname, av_err2str(AVERROR(errno)));
}
VAR_0->fd = -1;
return VAR_2;
}
| [
"int FUNC_0(V4L2m2mContext *VAR_0)\n{",
"void *VAR_1 = VAR_0->avctx;",
"int VAR_2;",
"av_log(VAR_1, AV_LOG_DEBUG, \"%VAR_0 full reinit\\n\", VAR_0->devname);",
"if (atomic_load(&VAR_0->refcount))\nwhile(sem_wait(&VAR_0->refsync) == -1 && errno == EINTR);",
"ff_v4l2_m2m_codec_end(VAR_0->avctx);",
"VAR_0->draining = 0;",
"VAR_0->reinit = 0;",
"VAR_0->fd = open(VAR_0->devname, O_RDWR | O_NONBLOCK, 0);",
"if (VAR_0->fd < 0)\nreturn AVERROR(errno);",
"VAR_2 = v4l2_prepare_contexts(VAR_0);",
"if (VAR_2 < 0)\ngoto error;",
"VAR_2 = ff_v4l2_context_get_format(&VAR_0->output);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_DEBUG, \"v4l2 output format not supported\\n\");",
"goto error;",
"}",
"VAR_2 = ff_v4l2_context_get_format(&VAR_0->capture);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_DEBUG, \"v4l2 capture format not supported\\n\");",
"goto error;",
"}",
"VAR_2 = ff_v4l2_context_set_format(&VAR_0->output);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_ERROR, \"can't set v4l2 output format\\n\");",
"goto error;",
"}",
"VAR_2 = ff_v4l2_context_set_format(&VAR_0->capture);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_ERROR, \"can't to set v4l2 capture format\\n\");",
"goto error;",
"}",
"VAR_2 = ff_v4l2_context_init(&VAR_0->output);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_ERROR, \"no v4l2 output context'VAR_0 buffers\\n\");",
"goto error;",
"}",
"if (!av_codec_is_decoder(VAR_0->avctx->codec)) {",
"VAR_2 = ff_v4l2_context_init(&VAR_0->capture);",
"if (VAR_2) {",
"av_log(VAR_1, AV_LOG_ERROR, \"no v4l2 capture context'VAR_0 buffers\\n\");",
"goto error;",
"}",
"}",
"return 0;",
"error:\nif (close(VAR_0->fd) < 0) {",
"VAR_2 = AVERROR(errno);",
"av_log(VAR_1, AV_LOG_ERROR, \"error closing %VAR_0 (%VAR_0)\\n\",\nVAR_0->devname, av_err2str(AVERROR(errno)));",
"}",
"VAR_0->fd = -1;",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
1,
1,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
17,
19
],
[
25
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
45
],
[
47,
49
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
141,
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
157
],
[
159
]
] |
21,984 | static av_cold int wmv2_decode_init(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
if(ff_msmpeg4_decode_init(avctx) < 0)
return -1;
ff_wmv2_common_init(w);
ff_intrax8_common_init(&w->x8,&w->s);
return 0;
}
| true | FFmpeg | e6bc38fd49c94726b45d5d5cc2b756ad8ec49ee0 | static av_cold int wmv2_decode_init(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
if(ff_msmpeg4_decode_init(avctx) < 0)
return -1;
ff_wmv2_common_init(w);
ff_intrax8_common_init(&w->x8,&w->s);
return 0;
}
| {
"code": [
" if(avctx->idct_algo==FF_IDCT_AUTO){",
" avctx->idct_algo=FF_IDCT_WMV2;"
],
"line_no": [
7,
9
]
} | static av_cold int FUNC_0(AVCodecContext *avctx){
Wmv2Context * const w= avctx->priv_data;
if(avctx->idct_algo==FF_IDCT_AUTO){
avctx->idct_algo=FF_IDCT_WMV2;
}
if(ff_msmpeg4_decode_init(avctx) < 0)
return -1;
ff_wmv2_common_init(w);
ff_intrax8_common_init(&w->x8,&w->s);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx){",
"Wmv2Context * const w= avctx->priv_data;",
"if(avctx->idct_algo==FF_IDCT_AUTO){",
"avctx->idct_algo=FF_IDCT_WMV2;",
"}",
"if(ff_msmpeg4_decode_init(avctx) < 0)\nreturn -1;",
"ff_wmv2_common_init(w);",
"ff_intrax8_common_init(&w->x8,&w->s);",
"return 0;",
"}"
] | [
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
29
],
[
31
]
] |
21,985 | static inline int divide3(int x)
{
return ((x+1)*21845 + 10922) >> 16;
}
| true | FFmpeg | c0220c768c7fc933a76c863ebbb0abdf68a88533 | static inline int divide3(int x)
{
return ((x+1)*21845 + 10922) >> 16;
}
| {
"code": [
" return ((x+1)*21845 + 10922) >> 16;"
],
"line_no": [
5
]
} | static inline int FUNC_0(int VAR_0)
{
return ((VAR_0+1)*21845 + 10922) >> 16;
}
| [
"static inline int FUNC_0(int VAR_0)\n{",
"return ((VAR_0+1)*21845 + 10922) >> 16;",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.