id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
25,633 | void cpu_loop(CPUS390XState *env)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
int trapnr, n, sig;
target_siginfo_t info;
target_ulong addr;
while (1) {
cpu_exec_start(cs);
trapnr = cpu_s390x_exec(cs);
cpu_exec_end(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
/* Just indicate that signals should be handled asap. */
break;
case EXCP_SVC:
n = env->int_svc_code;
if (!n) {
/* syscalls > 255 */
n = env->regs[1];
}
env->psw.addr += env->int_svc_ilen;
env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3],
env->regs[4], env->regs[5],
env->regs[6], env->regs[7], 0, 0);
break;
case EXCP_DEBUG:
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
n = TARGET_TRAP_BRKPT;
goto do_signal_pc;
}
break;
case EXCP_PGM:
n = env->int_pgm_code;
switch (n) {
case PGM_OPERATION:
case PGM_PRIVILEGED:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPC;
goto do_signal_pc;
case PGM_PROTECTION:
case PGM_ADDRESSING:
sig = TARGET_SIGSEGV;
/* XXX: check env->error_code */
n = TARGET_SEGV_MAPERR;
addr = env->__excp_addr;
goto do_signal;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
case PGM_SPECIAL_OP:
case PGM_OPERAND:
do_sigill_opn:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPN;
goto do_signal_pc;
case PGM_FIXPT_OVERFLOW:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTOVF;
goto do_signal_pc;
case PGM_FIXPT_DIVIDE:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTDIV;
goto do_signal_pc;
case PGM_DATA:
n = (env->fpc >> 8) & 0xff;
if (n == 0xff) {
/* compare-and-trap */
goto do_sigill_opn;
} else {
/* An IEEE exception, simulated or otherwise. */
if (n & 0x80) {
n = TARGET_FPE_FLTINV;
} else if (n & 0x40) {
n = TARGET_FPE_FLTDIV;
} else if (n & 0x20) {
n = TARGET_FPE_FLTOVF;
} else if (n & 0x10) {
n = TARGET_FPE_FLTUND;
} else if (n & 0x08) {
n = TARGET_FPE_FLTRES;
} else {
/* ??? Quantum exception; BFP, DFP error. */
goto do_sigill_opn;
}
sig = TARGET_SIGFPE;
goto do_signal_pc;
}
default:
fprintf(stderr, "Unhandled program exception: %#x\n", n);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
break;
do_signal_pc:
addr = env->psw.addr;
do_signal:
info.si_signo = sig;
info.si_errno = 0;
info.si_code = n;
info._sifields._sigfault._addr = addr;
queue_signal(env, info.si_signo, &info);
break;
default:
fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
process_pending_signals (env);
}
}
| false | qemu | 47405ab642101c8ea0472ae434ab4bd2bc1fa41f | void cpu_loop(CPUS390XState *env)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
int trapnr, n, sig;
target_siginfo_t info;
target_ulong addr;
while (1) {
cpu_exec_start(cs);
trapnr = cpu_s390x_exec(cs);
cpu_exec_end(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
break;
case EXCP_SVC:
n = env->int_svc_code;
if (!n) {
n = env->regs[1];
}
env->psw.addr += env->int_svc_ilen;
env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3],
env->regs[4], env->regs[5],
env->regs[6], env->regs[7], 0, 0);
break;
case EXCP_DEBUG:
sig = gdb_handlesig(cs, TARGET_SIGTRAP);
if (sig) {
n = TARGET_TRAP_BRKPT;
goto do_signal_pc;
}
break;
case EXCP_PGM:
n = env->int_pgm_code;
switch (n) {
case PGM_OPERATION:
case PGM_PRIVILEGED:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPC;
goto do_signal_pc;
case PGM_PROTECTION:
case PGM_ADDRESSING:
sig = TARGET_SIGSEGV;
n = TARGET_SEGV_MAPERR;
addr = env->__excp_addr;
goto do_signal;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
case PGM_SPECIAL_OP:
case PGM_OPERAND:
do_sigill_opn:
sig = TARGET_SIGILL;
n = TARGET_ILL_ILLOPN;
goto do_signal_pc;
case PGM_FIXPT_OVERFLOW:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTOVF;
goto do_signal_pc;
case PGM_FIXPT_DIVIDE:
sig = TARGET_SIGFPE;
n = TARGET_FPE_INTDIV;
goto do_signal_pc;
case PGM_DATA:
n = (env->fpc >> 8) & 0xff;
if (n == 0xff) {
goto do_sigill_opn;
} else {
if (n & 0x80) {
n = TARGET_FPE_FLTINV;
} else if (n & 0x40) {
n = TARGET_FPE_FLTDIV;
} else if (n & 0x20) {
n = TARGET_FPE_FLTOVF;
} else if (n & 0x10) {
n = TARGET_FPE_FLTUND;
} else if (n & 0x08) {
n = TARGET_FPE_FLTRES;
} else {
goto do_sigill_opn;
}
sig = TARGET_SIGFPE;
goto do_signal_pc;
}
default:
fprintf(stderr, "Unhandled program exception: %#x\n", n);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
break;
do_signal_pc:
addr = env->psw.addr;
do_signal:
info.si_signo = sig;
info.si_errno = 0;
info.si_code = n;
info._sifields._sigfault._addr = addr;
queue_signal(env, info.si_signo, &info);
break;
default:
fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
process_pending_signals (env);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUS390XState *VAR_0)
{
CPUState *cs = CPU(s390_env_get_cpu(VAR_0));
int VAR_1, VAR_2, VAR_3;
target_siginfo_t info;
target_ulong addr;
while (1) {
cpu_exec_start(cs);
VAR_1 = cpu_s390x_exec(cs);
cpu_exec_end(cs);
switch (VAR_1) {
case EXCP_INTERRUPT:
break;
case EXCP_SVC:
VAR_2 = VAR_0->int_svc_code;
if (!VAR_2) {
VAR_2 = VAR_0->regs[1];
}
VAR_0->psw.addr += VAR_0->int_svc_ilen;
VAR_0->regs[2] = do_syscall(VAR_0, VAR_2, VAR_0->regs[2], VAR_0->regs[3],
VAR_0->regs[4], VAR_0->regs[5],
VAR_0->regs[6], VAR_0->regs[7], 0, 0);
break;
case EXCP_DEBUG:
VAR_3 = gdb_handlesig(cs, TARGET_SIGTRAP);
if (VAR_3) {
VAR_2 = TARGET_TRAP_BRKPT;
goto do_signal_pc;
}
break;
case EXCP_PGM:
VAR_2 = VAR_0->int_pgm_code;
switch (VAR_2) {
case PGM_OPERATION:
case PGM_PRIVILEGED:
VAR_3 = TARGET_SIGILL;
VAR_2 = TARGET_ILL_ILLOPC;
goto do_signal_pc;
case PGM_PROTECTION:
case PGM_ADDRESSING:
VAR_3 = TARGET_SIGSEGV;
VAR_2 = TARGET_SEGV_MAPERR;
addr = VAR_0->__excp_addr;
goto do_signal;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
case PGM_SPECIAL_OP:
case PGM_OPERAND:
do_sigill_opn:
VAR_3 = TARGET_SIGILL;
VAR_2 = TARGET_ILL_ILLOPN;
goto do_signal_pc;
case PGM_FIXPT_OVERFLOW:
VAR_3 = TARGET_SIGFPE;
VAR_2 = TARGET_FPE_INTOVF;
goto do_signal_pc;
case PGM_FIXPT_DIVIDE:
VAR_3 = TARGET_SIGFPE;
VAR_2 = TARGET_FPE_INTDIV;
goto do_signal_pc;
case PGM_DATA:
VAR_2 = (VAR_0->fpc >> 8) & 0xff;
if (VAR_2 == 0xff) {
goto do_sigill_opn;
} else {
if (VAR_2 & 0x80) {
VAR_2 = TARGET_FPE_FLTINV;
} else if (VAR_2 & 0x40) {
VAR_2 = TARGET_FPE_FLTDIV;
} else if (VAR_2 & 0x20) {
VAR_2 = TARGET_FPE_FLTOVF;
} else if (VAR_2 & 0x10) {
VAR_2 = TARGET_FPE_FLTUND;
} else if (VAR_2 & 0x08) {
VAR_2 = TARGET_FPE_FLTRES;
} else {
goto do_sigill_opn;
}
VAR_3 = TARGET_SIGFPE;
goto do_signal_pc;
}
default:
fprintf(stderr, "Unhandled program exception: %#x\VAR_2", VAR_2);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
break;
do_signal_pc:
addr = VAR_0->psw.addr;
do_signal:
info.si_signo = VAR_3;
info.si_errno = 0;
info.si_code = VAR_2;
info._sifields._sigfault._addr = addr;
queue_signal(VAR_0, info.si_signo, &info);
break;
default:
fprintf(stderr, "Unhandled trap: 0x%x\VAR_2", VAR_1);
cpu_dump_state(cs, stderr, fprintf, 0);
exit(EXIT_FAILURE);
}
process_pending_signals (VAR_0);
}
}
| [
"void FUNC_0(CPUS390XState *VAR_0)\n{",
"CPUState *cs = CPU(s390_env_get_cpu(VAR_0));",
"int VAR_1, VAR_2, VAR_3;",
"target_siginfo_t info;",
"target_ulong addr;",
"while (1) {",
"cpu_exec_start(cs);",
"VAR_1 = cpu_s390x_exec(cs);",
"cpu_exec_end(cs);",
"switch (VAR_1) {",
"case EXCP_INTERRUPT:\nbreak;",
"case EXCP_SVC:\nVAR_2 = VAR_0->int_svc_code;",
"if (!VAR_2) {",
"VAR_2 = VAR_0->regs[1];",
"}",
"VAR_0->psw.addr += VAR_0->int_svc_ilen;",
"VAR_0->regs[2] = do_syscall(VAR_0, VAR_2, VAR_0->regs[2], VAR_0->regs[3],\nVAR_0->regs[4], VAR_0->regs[5],\nVAR_0->regs[6], VAR_0->regs[7], 0, 0);",
"break;",
"case EXCP_DEBUG:\nVAR_3 = gdb_handlesig(cs, TARGET_SIGTRAP);",
"if (VAR_3) {",
"VAR_2 = TARGET_TRAP_BRKPT;",
"goto do_signal_pc;",
"}",
"break;",
"case EXCP_PGM:\nVAR_2 = VAR_0->int_pgm_code;",
"switch (VAR_2) {",
"case PGM_OPERATION:\ncase PGM_PRIVILEGED:\nVAR_3 = TARGET_SIGILL;",
"VAR_2 = TARGET_ILL_ILLOPC;",
"goto do_signal_pc;",
"case PGM_PROTECTION:\ncase PGM_ADDRESSING:\nVAR_3 = TARGET_SIGSEGV;",
"VAR_2 = TARGET_SEGV_MAPERR;",
"addr = VAR_0->__excp_addr;",
"goto do_signal;",
"case PGM_EXECUTE:\ncase PGM_SPECIFICATION:\ncase PGM_SPECIAL_OP:\ncase PGM_OPERAND:\ndo_sigill_opn:\nVAR_3 = TARGET_SIGILL;",
"VAR_2 = TARGET_ILL_ILLOPN;",
"goto do_signal_pc;",
"case PGM_FIXPT_OVERFLOW:\nVAR_3 = TARGET_SIGFPE;",
"VAR_2 = TARGET_FPE_INTOVF;",
"goto do_signal_pc;",
"case PGM_FIXPT_DIVIDE:\nVAR_3 = TARGET_SIGFPE;",
"VAR_2 = TARGET_FPE_INTDIV;",
"goto do_signal_pc;",
"case PGM_DATA:\nVAR_2 = (VAR_0->fpc >> 8) & 0xff;",
"if (VAR_2 == 0xff) {",
"goto do_sigill_opn;",
"} else {",
"if (VAR_2 & 0x80) {",
"VAR_2 = TARGET_FPE_FLTINV;",
"} else if (VAR_2 & 0x40) {",
"VAR_2 = TARGET_FPE_FLTDIV;",
"} else if (VAR_2 & 0x20) {",
"VAR_2 = TARGET_FPE_FLTOVF;",
"} else if (VAR_2 & 0x10) {",
"VAR_2 = TARGET_FPE_FLTUND;",
"} else if (VAR_2 & 0x08) {",
"VAR_2 = TARGET_FPE_FLTRES;",
"} else {",
"goto do_sigill_opn;",
"}",
"VAR_3 = TARGET_SIGFPE;",
"goto do_signal_pc;",
"}",
"default:\nfprintf(stderr, \"Unhandled program exception: %#x\\VAR_2\", VAR_2);",
"cpu_dump_state(cs, stderr, fprintf, 0);",
"exit(EXIT_FAILURE);",
"}",
"break;",
"do_signal_pc:\naddr = VAR_0->psw.addr;",
"do_signal:\ninfo.si_signo = VAR_3;",
"info.si_errno = 0;",
"info.si_code = VAR_2;",
"info._sifields._sigfault._addr = addr;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"default:\nfprintf(stderr, \"Unhandled trap: 0x%x\\VAR_2\", VAR_1);",
"cpu_dump_state(cs, stderr, fprintf, 0);",
"exit(EXIT_FAILURE);",
"}",
"process_pending_signals (VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
29
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87,
89,
91
],
[
95
],
[
97
],
[
99
],
[
101,
103,
105,
107,
109,
111
],
[
113
],
[
115
],
[
119,
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
]
] |
25,634 | Object *object_resolve_path_component(Object *parent, const gchar *part)
{
ObjectProperty *prop = object_property_find(parent, part, NULL);
if (prop == NULL) {
return NULL;
}
if (object_property_is_link(prop)) {
LinkProperty *lprop = prop->opaque;
return *lprop->child;
} else if (object_property_is_child(prop)) {
return prop->opaque;
} else {
return NULL;
}
}
| false | qemu | 64607d088132abdb25bf30d93e97d0c8df7b364c | Object *object_resolve_path_component(Object *parent, const gchar *part)
{
ObjectProperty *prop = object_property_find(parent, part, NULL);
if (prop == NULL) {
return NULL;
}
if (object_property_is_link(prop)) {
LinkProperty *lprop = prop->opaque;
return *lprop->child;
} else if (object_property_is_child(prop)) {
return prop->opaque;
} else {
return NULL;
}
}
| {
"code": [],
"line_no": []
} | Object *FUNC_0(Object *parent, const gchar *part)
{
ObjectProperty *prop = object_property_find(parent, part, NULL);
if (prop == NULL) {
return NULL;
}
if (object_property_is_link(prop)) {
LinkProperty *lprop = prop->opaque;
return *lprop->child;
} else if (object_property_is_child(prop)) {
return prop->opaque;
} else {
return NULL;
}
}
| [
"Object *FUNC_0(Object *parent, const gchar *part)\n{",
"ObjectProperty *prop = object_property_find(parent, part, NULL);",
"if (prop == NULL) {",
"return NULL;",
"}",
"if (object_property_is_link(prop)) {",
"LinkProperty *lprop = prop->opaque;",
"return *lprop->child;",
"} else if (object_property_is_child(prop)) {",
"return prop->opaque;",
"} else {",
"return NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
25,635 | static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(f, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
/* TODO: add a way for SCSIBusInfo's load_request to fail,
* and fail migration instead of asserting here.
* When we do, we might be able to re-enable NDEBUG below.
*/
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));
assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(sreq);
req->sreq = sreq;
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->sreq->cmd.mode == req_mode);
}
return req;
}
| false | qemu | 36b15c79aa1bef5fe7543f9f2629b6413720bbfb | static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(f, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));
assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(sreq);
req->sreq = sreq;
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->sreq->cmd.mode == req_mode);
}
return req;
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)
{
SCSIBus *bus = VAR_1->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(VAR_0, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(VAR_0, (unsigned char *)&req->elem, sizeof(req->elem));
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));
assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(VAR_1);
req->VAR_1 = VAR_1;
if (req->VAR_1->cmd.mode != SCSI_XFER_NONE) {
int VAR_2 =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->VAR_1->cmd.mode == VAR_2);
}
return req;
}
| [
"static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)\n{",
"SCSIBus *bus = VAR_1->bus;",
"VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);",
"VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);",
"VirtIOSCSIReq *req;",
"uint32_t n;",
"req = g_malloc(sizeof(*req));",
"qemu_get_be32s(VAR_0, &n);",
"assert(n < vs->conf.num_queues);",
"qemu_get_buffer(VAR_0, (unsigned char *)&req->elem, sizeof(req->elem));",
"#ifdef NDEBUG\n#error building with NDEBUG is not supported\n#endif\nassert(req->elem.in_num <= ARRAY_SIZE(req->elem.in_sg));",
"assert(req->elem.out_num <= ARRAY_SIZE(req->elem.out_sg));",
"virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);",
"scsi_req_ref(VAR_1);",
"req->VAR_1 = VAR_1;",
"if (req->VAR_1->cmd.mode != SCSI_XFER_NONE) {",
"int VAR_2 =\n(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);",
"assert(req->VAR_1->cmd.mode == VAR_2);",
"}",
"return req;",
"}"
] | [
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
],
[
33,
35,
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
25,637 | static void phys_sections_free(PhysPageMap *map)
{
while (map->sections_nb > 0) {
MemoryRegionSection *section = &map->sections[--map->sections_nb];
phys_section_destroy(section->mr);
}
g_free(map->sections);
g_free(map->nodes);
g_free(map);
}
| false | qemu | 53cb28cbfea038f8ad50132dc8a684e638c7d48b | static void phys_sections_free(PhysPageMap *map)
{
while (map->sections_nb > 0) {
MemoryRegionSection *section = &map->sections[--map->sections_nb];
phys_section_destroy(section->mr);
}
g_free(map->sections);
g_free(map->nodes);
g_free(map);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PhysPageMap *VAR_0)
{
while (VAR_0->sections_nb > 0) {
MemoryRegionSection *section = &VAR_0->sections[--VAR_0->sections_nb];
phys_section_destroy(section->mr);
}
g_free(VAR_0->sections);
g_free(VAR_0->nodes);
g_free(VAR_0);
}
| [
"static void FUNC_0(PhysPageMap *VAR_0)\n{",
"while (VAR_0->sections_nb > 0) {",
"MemoryRegionSection *section = &VAR_0->sections[--VAR_0->sections_nb];",
"phys_section_destroy(section->mr);",
"}",
"g_free(VAR_0->sections);",
"g_free(VAR_0->nodes);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
] |
25,638 | static void fill_buffer(ByteIOContext *s)
{
int len;
/* no need to do anything if EOF already reached */
if (s->eof_reached)
return;
if(s->update_checksum){
if(s->buf_end > s->checksum_ptr)
s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr);
s->checksum_ptr= s->buffer;
}
len = s->read_packet(s->opaque, s->buffer, s->buffer_size);
if (len <= 0) {
/* do not modify buffer if EOF reached so that a seek back can
be done without rereading data */
s->eof_reached = 1;
if(len<0)
s->error= len;
} else {
s->pos += len;
s->buf_ptr = s->buffer;
s->buf_end = s->buffer + len;
}
}
| false | FFmpeg | 602dd8f6c4d4f7e1b5f48cc580fd9b694d41d602 | static void fill_buffer(ByteIOContext *s)
{
int len;
if (s->eof_reached)
return;
if(s->update_checksum){
if(s->buf_end > s->checksum_ptr)
s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr);
s->checksum_ptr= s->buffer;
}
len = s->read_packet(s->opaque, s->buffer, s->buffer_size);
if (len <= 0) {
s->eof_reached = 1;
if(len<0)
s->error= len;
} else {
s->pos += len;
s->buf_ptr = s->buffer;
s->buf_end = s->buffer + len;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ByteIOContext *VAR_0)
{
int VAR_1;
if (VAR_0->eof_reached)
return;
if(VAR_0->update_checksum){
if(VAR_0->buf_end > VAR_0->checksum_ptr)
VAR_0->checksum= VAR_0->update_checksum(VAR_0->checksum, VAR_0->checksum_ptr, VAR_0->buf_end - VAR_0->checksum_ptr);
VAR_0->checksum_ptr= VAR_0->buffer;
}
VAR_1 = VAR_0->read_packet(VAR_0->opaque, VAR_0->buffer, VAR_0->buffer_size);
if (VAR_1 <= 0) {
VAR_0->eof_reached = 1;
if(VAR_1<0)
VAR_0->error= VAR_1;
} else {
VAR_0->pos += VAR_1;
VAR_0->buf_ptr = VAR_0->buffer;
VAR_0->buf_end = VAR_0->buffer + VAR_1;
}
}
| [
"static void FUNC_0(ByteIOContext *VAR_0)\n{",
"int VAR_1;",
"if (VAR_0->eof_reached)\nreturn;",
"if(VAR_0->update_checksum){",
"if(VAR_0->buf_end > VAR_0->checksum_ptr)\nVAR_0->checksum= VAR_0->update_checksum(VAR_0->checksum, VAR_0->checksum_ptr, VAR_0->buf_end - VAR_0->checksum_ptr);",
"VAR_0->checksum_ptr= VAR_0->buffer;",
"}",
"VAR_1 = VAR_0->read_packet(VAR_0->opaque, VAR_0->buffer, VAR_0->buffer_size);",
"if (VAR_1 <= 0) {",
"VAR_0->eof_reached = 1;",
"if(VAR_1<0)\nVAR_0->error= VAR_1;",
"} else {",
"VAR_0->pos += VAR_1;",
"VAR_0->buf_ptr = VAR_0->buffer;",
"VAR_0->buf_end = VAR_0->buffer + VAR_1;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
25,639 | static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
ADXContext *c = avctx->priv_data;
const int16_t *samples = data;
uint8_t *dst = frame;
int ch;
if (!c->header_parsed) {
int hdrsize = adx_encode_header(avctx, dst, buf_size);
dst += hdrsize;
c->header_parsed = 1;
}
for (ch = 0; ch < avctx->channels; ch++) {
adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels);
dst += BLOCK_SIZE;
}
return dst - frame;
}
| false | FFmpeg | 754ebd1a5b68dd63ccceb50a8a852fe8d0c94354 | static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
ADXContext *c = avctx->priv_data;
const int16_t *samples = data;
uint8_t *dst = frame;
int ch;
if (!c->header_parsed) {
int hdrsize = adx_encode_header(avctx, dst, buf_size);
dst += hdrsize;
c->header_parsed = 1;
}
for (ch = 0; ch < avctx->channels; ch++) {
adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels);
dst += BLOCK_SIZE;
}
return dst - frame;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,
int VAR_2, void *VAR_3)
{
ADXContext *c = VAR_0->priv_data;
const int16_t *VAR_4 = VAR_3;
uint8_t *dst = VAR_1;
int VAR_5;
if (!c->header_parsed) {
int VAR_6 = adx_encode_header(VAR_0, dst, VAR_2);
dst += VAR_6;
c->header_parsed = 1;
}
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
adx_encode(c, dst, VAR_4 + VAR_5, &c->prev[VAR_5], VAR_0->channels);
dst += BLOCK_SIZE;
}
return dst - VAR_1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, uint8_t *VAR_1,\nint VAR_2, void *VAR_3)\n{",
"ADXContext *c = VAR_0->priv_data;",
"const int16_t *VAR_4 = VAR_3;",
"uint8_t *dst = VAR_1;",
"int VAR_5;",
"if (!c->header_parsed) {",
"int VAR_6 = adx_encode_header(VAR_0, dst, VAR_2);",
"dst += VAR_6;",
"c->header_parsed = 1;",
"}",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"adx_encode(c, dst, VAR_4 + VAR_5, &c->prev[VAR_5], VAR_0->channels);",
"dst += BLOCK_SIZE;",
"}",
"return dst - VAR_1;",
"}"
] | [
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
]
] |
25,640 | static int bmp_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
BMPParseContext *bpc = s->priv_data;
uint64_t state = bpc->pc.state64;
int next = END_NOT_FOUND;
int i = 0;
*poutbuf_size = 0;
restart:
if (bpc->pc.frame_start_found <= 2+4+4) {
for (; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (bpc->pc.frame_start_found == 0) {
if ((state >> 48) == (('B' << 8) | 'M')) {
bpc->fsize = av_bswap32(state >> 16);
bpc->pc.frame_start_found = 1;
}
} else if (bpc->pc.frame_start_found == 2+4+4) {
// unsigned hsize = av_bswap32(state>>32);
unsigned ihsize = av_bswap32(state);
if (ihsize < 12 || ihsize > 200) {
bpc->pc.frame_start_found = 0;
continue;
}
bpc->pc.frame_start_found++;
bpc->remaining_size = bpc->fsize + i - 17;
if (bpc->pc.index + i > 17) {
next = i - 17;
state = 0;
break;
} else {
bpc->pc.state64 = 0;
goto restart;
}
} else if (bpc->pc.frame_start_found)
bpc->pc.frame_start_found++;
}
bpc->pc.state64 = state;
} else {
if (bpc->remaining_size) {
i = FFMIN(bpc->remaining_size, buf_size);
bpc->remaining_size -= i;
if (bpc->remaining_size)
goto flush;
bpc->pc.frame_start_found = 0;
goto restart;
}
}
flush:
if (ff_combine_frame(&bpc->pc, next, &buf, &buf_size) < 0)
return buf_size;
if (next != END_NOT_FOUND && next < 0)
bpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - i - 1, 0);
else
bpc->pc.frame_start_found = 0;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
| false | FFmpeg | 43a4276c6964a2ec57e08c3c622bb94d35c0441f | static int bmp_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
BMPParseContext *bpc = s->priv_data;
uint64_t state = bpc->pc.state64;
int next = END_NOT_FOUND;
int i = 0;
*poutbuf_size = 0;
restart:
if (bpc->pc.frame_start_found <= 2+4+4) {
for (; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (bpc->pc.frame_start_found == 0) {
if ((state >> 48) == (('B' << 8) | 'M')) {
bpc->fsize = av_bswap32(state >> 16);
bpc->pc.frame_start_found = 1;
}
} else if (bpc->pc.frame_start_found == 2+4+4) {
unsigned ihsize = av_bswap32(state);
if (ihsize < 12 || ihsize > 200) {
bpc->pc.frame_start_found = 0;
continue;
}
bpc->pc.frame_start_found++;
bpc->remaining_size = bpc->fsize + i - 17;
if (bpc->pc.index + i > 17) {
next = i - 17;
state = 0;
break;
} else {
bpc->pc.state64 = 0;
goto restart;
}
} else if (bpc->pc.frame_start_found)
bpc->pc.frame_start_found++;
}
bpc->pc.state64 = state;
} else {
if (bpc->remaining_size) {
i = FFMIN(bpc->remaining_size, buf_size);
bpc->remaining_size -= i;
if (bpc->remaining_size)
goto flush;
bpc->pc.frame_start_found = 0;
goto restart;
}
}
flush:
if (ff_combine_frame(&bpc->pc, next, &buf, &buf_size) < 0)
return buf_size;
if (next != END_NOT_FOUND && next < 0)
bpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - i - 1, 0);
else
bpc->pc.frame_start_found = 0;
*poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,
const uint8_t **VAR_2, int *VAR_3,
const uint8_t *VAR_4, int VAR_5)
{
BMPParseContext *bpc = VAR_0->priv_data;
uint64_t state = bpc->pc.state64;
int VAR_6 = END_NOT_FOUND;
int VAR_7 = 0;
*VAR_3 = 0;
restart:
if (bpc->pc.frame_start_found <= 2+4+4) {
for (; VAR_7 < VAR_5; VAR_7++) {
state = (state << 8) | VAR_4[VAR_7];
if (bpc->pc.frame_start_found == 0) {
if ((state >> 48) == (('B' << 8) | 'M')) {
bpc->fsize = av_bswap32(state >> 16);
bpc->pc.frame_start_found = 1;
}
} else if (bpc->pc.frame_start_found == 2+4+4) {
unsigned VAR_8 = av_bswap32(state);
if (VAR_8 < 12 || VAR_8 > 200) {
bpc->pc.frame_start_found = 0;
continue;
}
bpc->pc.frame_start_found++;
bpc->remaining_size = bpc->fsize + VAR_7 - 17;
if (bpc->pc.index + VAR_7 > 17) {
VAR_6 = VAR_7 - 17;
state = 0;
break;
} else {
bpc->pc.state64 = 0;
goto restart;
}
} else if (bpc->pc.frame_start_found)
bpc->pc.frame_start_found++;
}
bpc->pc.state64 = state;
} else {
if (bpc->remaining_size) {
VAR_7 = FFMIN(bpc->remaining_size, VAR_5);
bpc->remaining_size -= VAR_7;
if (bpc->remaining_size)
goto flush;
bpc->pc.frame_start_found = 0;
goto restart;
}
}
flush:
if (ff_combine_frame(&bpc->pc, VAR_6, &VAR_4, &VAR_5) < 0)
return VAR_5;
if (VAR_6 != END_NOT_FOUND && VAR_6 < 0)
bpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - VAR_7 - 1, 0);
else
bpc->pc.frame_start_found = 0;
*VAR_2 = VAR_4;
*VAR_3 = VAR_5;
return VAR_6;
}
| [
"static int FUNC_0(AVCodecParserContext *VAR_0, AVCodecContext *VAR_1,\nconst uint8_t **VAR_2, int *VAR_3,\nconst uint8_t *VAR_4, int VAR_5)\n{",
"BMPParseContext *bpc = VAR_0->priv_data;",
"uint64_t state = bpc->pc.state64;",
"int VAR_6 = END_NOT_FOUND;",
"int VAR_7 = 0;",
"*VAR_3 = 0;",
"restart:\nif (bpc->pc.frame_start_found <= 2+4+4) {",
"for (; VAR_7 < VAR_5; VAR_7++) {",
"state = (state << 8) | VAR_4[VAR_7];",
"if (bpc->pc.frame_start_found == 0) {",
"if ((state >> 48) == (('B' << 8) | 'M')) {",
"bpc->fsize = av_bswap32(state >> 16);",
"bpc->pc.frame_start_found = 1;",
"}",
"} else if (bpc->pc.frame_start_found == 2+4+4) {",
"unsigned VAR_8 = av_bswap32(state);",
"if (VAR_8 < 12 || VAR_8 > 200) {",
"bpc->pc.frame_start_found = 0;",
"continue;",
"}",
"bpc->pc.frame_start_found++;",
"bpc->remaining_size = bpc->fsize + VAR_7 - 17;",
"if (bpc->pc.index + VAR_7 > 17) {",
"VAR_6 = VAR_7 - 17;",
"state = 0;",
"break;",
"} else {",
"bpc->pc.state64 = 0;",
"goto restart;",
"}",
"} else if (bpc->pc.frame_start_found)",
"bpc->pc.frame_start_found++;",
"}",
"bpc->pc.state64 = state;",
"} else {",
"if (bpc->remaining_size) {",
"VAR_7 = FFMIN(bpc->remaining_size, VAR_5);",
"bpc->remaining_size -= VAR_7;",
"if (bpc->remaining_size)\ngoto flush;",
"bpc->pc.frame_start_found = 0;",
"goto restart;",
"}",
"}",
"flush:\nif (ff_combine_frame(&bpc->pc, VAR_6, &VAR_4, &VAR_5) < 0)\nreturn VAR_5;",
"if (VAR_6 != END_NOT_FOUND && VAR_6 < 0)\nbpc->pc.frame_start_found = FFMAX(bpc->pc.frame_start_found - VAR_7 - 1, 0);",
"else\nbpc->pc.frame_start_found = 0;",
"*VAR_2 = VAR_4;",
"*VAR_3 = VAR_5;",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111,
113
],
[
117,
119
],
[
121,
123
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
25,641 | static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVIContext *avi = s->priv_data;
AVStream *st;
int i, index;
int64_t pos;
AVIStream *ast;
if (!avi->index_loaded) {
/* we only load the index on demand */
avi_load_index(s);
avi->index_loaded = 1;
}
assert(stream_index>= 0);
st = s->streams[stream_index];
ast= st->priv_data;
index= av_index_search_timestamp(st, timestamp * FFMAX(ast->sample_size, 1), flags);
if(index<0)
return -1;
/* find the position */
pos = st->index_entries[index].pos;
timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
av_dlog(s, "XX %"PRId64" %d %"PRId64"\n",
timestamp, index, st->index_entries[index].timestamp);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
/* One and only one real stream for DV in AVI, and it has video */
/* offsets. Calling with other stream indexes should have failed */
/* the av_index_search_timestamp call above. */
assert(stream_index == 0);
/* Feed the DV video stream version of the timestamp to the */
/* DV demux so it can synthesize correct timestamps. */
ff_dv_offset_reset(avi->dv_demux, timestamp);
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, timestamp);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
// assert(st2->codec->block_align);
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD);
if(index<0)
index=0;
if(!avi->non_interleaved){
while(index>0 && st2->index_entries[index].pos > pos)
index--;
while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
index++;
}
av_dlog(s, "%"PRId64" %d %"PRId64"\n",
timestamp, index, st2->index_entries[index].timestamp);
/* extract the current frame number */
ast2->frame_offset = st2->index_entries[index].timestamp;
}
/* do the seek */
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
| false | FFmpeg | 570a4a0189946c2c983da41d37fdd67fa13266e7 | static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
AVIContext *avi = s->priv_data;
AVStream *st;
int i, index;
int64_t pos;
AVIStream *ast;
if (!avi->index_loaded) {
avi_load_index(s);
avi->index_loaded = 1;
}
assert(stream_index>= 0);
st = s->streams[stream_index];
ast= st->priv_data;
index= av_index_search_timestamp(st, timestamp * FFMAX(ast->sample_size, 1), flags);
if(index<0)
return -1;
pos = st->index_entries[index].pos;
timestamp = st->index_entries[index].timestamp / FFMAX(ast->sample_size, 1);
av_dlog(s, "XX %"PRId64" %d %"PRId64"\n",
timestamp, index, st->index_entries[index].timestamp);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
assert(stream_index == 0);
ff_dv_offset_reset(avi->dv_demux, timestamp);
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, timestamp);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD);
if(index<0)
index=0;
if(!avi->non_interleaved){
while(index>0 && st2->index_entries[index].pos > pos)
index--;
while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
index++;
}
av_dlog(s, "%"PRId64" %d %"PRId64"\n",
timestamp, index, st2->index_entries[index].timestamp);
ast2->frame_offset = st2->index_entries[index].timestamp;
}
avio_seek(s->pb, pos, SEEK_SET);
avi->stream_index= -1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)
{
AVIContext *avi = VAR_0->priv_data;
AVStream *st;
int VAR_4, VAR_5;
int64_t pos;
AVIStream *ast;
if (!avi->index_loaded) {
avi_load_index(VAR_0);
avi->index_loaded = 1;
}
assert(VAR_1>= 0);
st = VAR_0->streams[VAR_1];
ast= st->priv_data;
VAR_5= av_index_search_timestamp(st, VAR_2 * FFMAX(ast->sample_size, 1), VAR_3);
if(VAR_5<0)
return -1;
pos = st->index_entries[VAR_5].pos;
VAR_2 = st->index_entries[VAR_5].VAR_2 / FFMAX(ast->sample_size, 1);
av_dlog(VAR_0, "XX %"PRId64" %d %"PRId64"\n",
VAR_2, VAR_5, st->index_entries[VAR_5].VAR_2);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
assert(VAR_1 == 0);
ff_dv_offset_reset(avi->dv_demux, VAR_2);
avio_seek(VAR_0->pb, pos, SEEK_SET);
avi->VAR_1= -1;
return 0;
}
for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
AVStream *st2 = VAR_0->streams[VAR_4];
AVIStream *ast2 = st2->priv_data;
ast2->packet_size=
ast2->remaining= 0;
if (ast2->sub_ctx) {
seek_subtitle(st, st2, VAR_2);
continue;
}
if (st2->nb_index_entries <= 0)
continue;
assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);
VAR_5 = av_index_search_timestamp(
st2,
av_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
VAR_3 | AVSEEK_FLAG_BACKWARD);
if(VAR_5<0)
VAR_5=0;
if(!avi->non_interleaved){
while(VAR_5>0 && st2->index_entries[VAR_5].pos > pos)
VAR_5--;
while(VAR_5+1 < st2->nb_index_entries && st2->index_entries[VAR_5].pos < pos)
VAR_5++;
}
av_dlog(VAR_0, "%"PRId64" %d %"PRId64"\n",
VAR_2, VAR_5, st2->index_entries[VAR_5].VAR_2);
ast2->frame_offset = st2->index_entries[VAR_5].VAR_2;
}
avio_seek(VAR_0->pb, pos, SEEK_SET);
avi->VAR_1= -1;
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int VAR_3)\n{",
"AVIContext *avi = VAR_0->priv_data;",
"AVStream *st;",
"int VAR_4, VAR_5;",
"int64_t pos;",
"AVIStream *ast;",
"if (!avi->index_loaded) {",
"avi_load_index(VAR_0);",
"avi->index_loaded = 1;",
"}",
"assert(VAR_1>= 0);",
"st = VAR_0->streams[VAR_1];",
"ast= st->priv_data;",
"VAR_5= av_index_search_timestamp(st, VAR_2 * FFMAX(ast->sample_size, 1), VAR_3);",
"if(VAR_5<0)\nreturn -1;",
"pos = st->index_entries[VAR_5].pos;",
"VAR_2 = st->index_entries[VAR_5].VAR_2 / FFMAX(ast->sample_size, 1);",
"av_dlog(VAR_0, \"XX %\"PRId64\" %d %\"PRId64\"\\n\",\nVAR_2, VAR_5, st->index_entries[VAR_5].VAR_2);",
"if (CONFIG_DV_DEMUXER && avi->dv_demux) {",
"assert(VAR_1 == 0);",
"ff_dv_offset_reset(avi->dv_demux, VAR_2);",
"avio_seek(VAR_0->pb, pos, SEEK_SET);",
"avi->VAR_1= -1;",
"return 0;",
"}",
"for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"AVStream *st2 = VAR_0->streams[VAR_4];",
"AVIStream *ast2 = st2->priv_data;",
"ast2->packet_size=\nast2->remaining= 0;",
"if (ast2->sub_ctx) {",
"seek_subtitle(st, st2, VAR_2);",
"continue;",
"}",
"if (st2->nb_index_entries <= 0)\ncontinue;",
"assert((int64_t)st2->time_base.num*ast2->rate == (int64_t)st2->time_base.den*ast2->scale);",
"VAR_5 = av_index_search_timestamp(\nst2,\nav_rescale_q(VAR_2, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),\nVAR_3 | AVSEEK_FLAG_BACKWARD);",
"if(VAR_5<0)\nVAR_5=0;",
"if(!avi->non_interleaved){",
"while(VAR_5>0 && st2->index_entries[VAR_5].pos > pos)\nVAR_5--;",
"while(VAR_5+1 < st2->nb_index_entries && st2->index_entries[VAR_5].pos < pos)\nVAR_5++;",
"}",
"av_dlog(VAR_0, \"%\"PRId64\" %d %\"PRId64\"\\n\",\nVAR_2, VAR_5, st2->index_entries[VAR_5].VAR_2);",
"ast2->frame_offset = st2->index_entries[VAR_5].VAR_2;",
"}",
"avio_seek(VAR_0->pb, pos, SEEK_SET);",
"avi->VAR_1= -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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
45
],
[
47
],
[
51,
53
],
[
57
],
[
65
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111,
113
],
[
119
],
[
121,
123,
125,
127
],
[
129,
131
],
[
135
],
[
137,
139
],
[
141,
143
],
[
145
],
[
149,
151
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
]
] |
25,642 | static int opt_streamid(const char *opt, const char *arg)
{
int idx;
char *p;
char idx_str[16];
av_strlcpy(idx_str, arg, sizeof(idx_str));
p = strchr(idx_str, ':');
if (!p) {
fprintf(stderr,
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
arg, opt);
ffmpeg_exit(1);
}
*p++ = '\0';
idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX);
streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
return 0;
}
| false | FFmpeg | c31a5b23b4cd566724743685e5ea158b0c818647 | static int opt_streamid(const char *opt, const char *arg)
{
int idx;
char *p;
char idx_str[16];
av_strlcpy(idx_str, arg, sizeof(idx_str));
p = strchr(idx_str, ':');
if (!p) {
fprintf(stderr,
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
arg, opt);
ffmpeg_exit(1);
}
*p++ = '\0';
idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX);
streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0, const char *VAR_1)
{
int VAR_2;
char *VAR_3;
char VAR_4[16];
av_strlcpy(VAR_4, VAR_1, sizeof(VAR_4));
VAR_3 = strchr(VAR_4, ':');
if (!VAR_3) {
fprintf(stderr,
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
VAR_1, VAR_0);
ffmpeg_exit(1);
}
*VAR_3++ = '\0';
VAR_2 = parse_number_or_die(VAR_0, VAR_4, OPT_INT, 0, INT_MAX);
streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, VAR_2+1);
streamid_map[VAR_2] = parse_number_or_die(VAR_0, VAR_3, OPT_INT, 0, INT_MAX);
return 0;
}
| [
"static int FUNC_0(const char *VAR_0, const char *VAR_1)\n{",
"int VAR_2;",
"char *VAR_3;",
"char VAR_4[16];",
"av_strlcpy(VAR_4, VAR_1, sizeof(VAR_4));",
"VAR_3 = strchr(VAR_4, ':');",
"if (!VAR_3) {",
"fprintf(stderr,\n\"Invalid value '%s' for option '%s', required syntax is 'index:value'\\n\",\nVAR_1, VAR_0);",
"ffmpeg_exit(1);",
"}",
"*VAR_3++ = '\\0';",
"VAR_2 = parse_number_or_die(VAR_0, VAR_4, OPT_INT, 0, INT_MAX);",
"streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, VAR_2+1);",
"streamid_map[VAR_2] = parse_number_or_die(VAR_0, VAR_3, OPT_INT, 0, INT_MAX);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
25,643 | static void avc_luma_midv_qrt_16w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height, uint8_t vert_offset)
{
uint32_t multiple8_cnt;
for (multiple8_cnt = 2; multiple8_cnt--;) {
avc_luma_midv_qrt_8w_msa(src, src_stride, dst, dst_stride, height,
vert_offset);
src += 8;
dst += 8;
}
}
| false | FFmpeg | 662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a | static void avc_luma_midv_qrt_16w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height, uint8_t vert_offset)
{
uint32_t multiple8_cnt;
for (multiple8_cnt = 2; multiple8_cnt--;) {
avc_luma_midv_qrt_8w_msa(src, src_stride, dst, dst_stride, height,
vert_offset);
src += 8;
dst += 8;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,
uint8_t *VAR_2, int32_t VAR_3,
int32_t VAR_4, uint8_t VAR_5)
{
uint32_t multiple8_cnt;
for (multiple8_cnt = 2; multiple8_cnt--;) {
avc_luma_midv_qrt_8w_msa(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5);
VAR_0 += 8;
VAR_2 += 8;
}
}
| [
"static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,\nuint8_t *VAR_2, int32_t VAR_3,\nint32_t VAR_4, uint8_t VAR_5)\n{",
"uint32_t multiple8_cnt;",
"for (multiple8_cnt = 2; multiple8_cnt--;) {",
"avc_luma_midv_qrt_8w_msa(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5);",
"VAR_0 += 8;",
"VAR_2 += 8;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15,
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,645 | static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
} else {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
}
}
| false | FFmpeg | 13a099799e89a76eb921ca452e1b04a7a28a9855 | static void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
const uint16_t *buf1= buf0;
if (uvalpha < 2048) {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
} else {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,
const uint16_t *ubuf0, const uint16_t *ubuf1,
const uint16_t *vbuf0, const uint16_t *vbuf1,
const uint16_t *abuf0, uint8_t *dest,
int dstW, int uvalpha, enum PixelFormat dstFormat,
int flags, int y)
{
const uint16_t *VAR_0= buf0;
if (uvalpha < 2048) {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
} else {
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
YSCALEYUV2RGB1_ALPHA(%%REGBP)
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
} else {
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB1b(%%REGBP, %5)
"pcmpeqd %%mm7, %%mm7 \n\t"
WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
}
}
| [
"static void FUNC_0(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *ubuf0, const uint16_t *ubuf1,\nconst uint16_t *vbuf0, const uint16_t *vbuf1,\nconst uint16_t *abuf0, uint8_t *dest,\nint dstW, int uvalpha, enum PixelFormat dstFormat,\nint flags, int y)\n{",
"const uint16_t *VAR_0= buf0;",
"if (uvalpha < 2048) {",
"if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1(%%REGBP, %5)\nYSCALEYUV2RGB1_ALPHA(%%REGBP)\nWRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (abuf0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"} else {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1(%%REGBP, %5)\n\"pcmpeqd %%mm7, %%mm7 \\n\\t\"\nWRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"}",
"} else {",
"if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1b(%%REGBP, %5)\nYSCALEYUV2RGB1_ALPHA(%%REGBP)\nWRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (abuf0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"} else {",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1b(%%REGBP, %5)\n\"pcmpeqd %%mm7, %%mm7 \\n\\t\"\nWRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"}",
"}",
"}"
] | [
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,
31,
33,
35,
37,
39,
41,
43,
45
],
[
47
],
[
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71
],
[
73
],
[
75
],
[
77
],
[
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101
],
[
103
],
[
105,
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127
],
[
129
],
[
131
],
[
133
]
] |
25,646 | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){
HYuvContext *s = avctx->priv_data;
const int width= s->width;
const int width2= s->width>>1;
const int height= s->height;
int fake_ystride, fake_ustride, fake_vstride;
AVFrame * const p= &s->picture;
AVFrame *picture = data;
*data_size = 0;
/* no supplementary picture */
if (buf_size == 0)
return 0;
bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);
init_get_bits(&s->gb, s->bitstream_buffer, buf_size);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0];
fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1];
fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2];
s->last_slice_end= 0;
if(s->bitstream_bpp<24){
int y, cy;
int lefty, leftu, leftv;
int lefttopy, lefttopu, lefttopv;
if(s->yuy2){
p->data[0][3]= get_bits(&s->gb, 8);
p->data[0][2]= get_bits(&s->gb, 8);
p->data[0][1]= get_bits(&s->gb, 8);
p->data[0][0]= get_bits(&s->gb, 8);
fprintf(stderr, "YUY2 output isnt implemenetd yet\n");
return -1;
}else{
leftv= p->data[2][0]= get_bits(&s->gb, 8);
lefty= p->data[0][1]= get_bits(&s->gb, 8);
leftu= p->data[1][0]= get_bits(&s->gb, 8);
p->data[0][0]= get_bits(&s->gb, 8);
switch(s->predictor){
case LEFT:
case PLANE:
decode_422_bitstream(s, width-2);
lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu);
leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv);
}
for(cy=y=1; y<s->height; y++,cy++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
decode_gray_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
lefty= add_left_prediction(ydst, s->temp[0], width, lefty);
if(s->predictor == PLANE){
if(y>s->interlaced)
s->dsp.add_bytes(ydst, ydst - fake_ystride, width);
}
y++;
if(y>=s->height) break;
}
draw_slice(s, y);
ydst= p->data[0] + p->linesize[0]*y;
udst= p->data[1] + p->linesize[1]*cy;
vdst= p->data[2] + p->linesize[2]*cy;
decode_422_bitstream(s, width);
lefty= add_left_prediction(ydst, s->temp[0], width, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(udst, s->temp[1], width2, leftu);
leftv= add_left_prediction(vdst, s->temp[2], width2, leftv);
}
if(s->predictor == PLANE){
if(cy>s->interlaced){
s->dsp.add_bytes(ydst, ydst - fake_ystride, width);
if(!(s->flags&CODEC_FLAG_GRAY)){
s->dsp.add_bytes(udst, udst - fake_ustride, width2);
s->dsp.add_bytes(vdst, vdst - fake_vstride, width2);
}
}
}
}
draw_slice(s, height);
break;
case MEDIAN:
/* first line except first 2 pixels is left predicted */
decode_422_bitstream(s, width-2);
lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu);
leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv);
}
cy=y=1;
/* second line is left predicted for interlaced case */
if(s->interlaced){
decode_422_bitstream(s, width);
lefty= add_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu);
leftv= add_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv);
}
y++; cy++;
}
/* next 4 pixels are left predicted too */
decode_422_bitstream(s, 4);
lefty= add_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu);
leftv= add_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv);
}
/* next line except the first 4 pixels is median predicted */
lefttopy= p->data[0][3];
decode_422_bitstream(s, width-4);
add_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy);
if(!(s->flags&CODEC_FLAG_GRAY)){
lefttopu= p->data[1][1];
lefttopv= p->data[2][1];
add_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu);
add_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv);
}
y++; cy++;
for(; y<height; y++,cy++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
while(2*cy > y){
decode_gray_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
y++;
}
if(y>=height) break;
}
draw_slice(s, y);
decode_422_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
udst= p->data[1] + p->linesize[1]*cy;
vdst= p->data[2] + p->linesize[2]*cy;
add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
if(!(s->flags&CODEC_FLAG_GRAY)){
add_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu);
add_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv);
}
}
draw_slice(s, height);
break;
}
}
}else{
int y;
int leftr, leftg, leftb;
const int last_line= (height-1)*p->linesize[0];
if(s->bitstream_bpp==32){
p->data[0][last_line+3]= get_bits(&s->gb, 8);
leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8);
leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8);
leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8);
}else{
leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8);
leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8);
leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8);
skip_bits(&s->gb, 8);
}
if(s->bgr32){
switch(s->predictor){
case LEFT:
case PLANE:
decode_bgr_bitstream(s, width-1);
add_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb);
for(y=s->height-2; y>=0; y--){ //yes its stored upside down
decode_bgr_bitstream(s, width);
add_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb);
if(s->predictor == PLANE){
if((y&s->interlaced)==0){
s->dsp.add_bytes(p->data[0] + p->linesize[0]*y,
p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride);
}
}
}
draw_slice(s, height); // just 1 large slice as this isnt possible in reverse order
break;
default:
fprintf(stderr, "prediction type not supported!\n");
}
}else{
fprintf(stderr, "BGR24 output isnt implemenetd yet\n");
return -1;
}
}
emms_c();
*picture= *p;
avctx->release_buffer(avctx, p);
*data_size = sizeof(AVFrame);
return (get_bits_count(&s->gb)+7)>>3;
}
| false | FFmpeg | 68f593b48433842f3407586679fe07f3e5199ab9 | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){
HYuvContext *s = avctx->priv_data;
const int width= s->width;
const int width2= s->width>>1;
const int height= s->height;
int fake_ystride, fake_ustride, fake_vstride;
AVFrame * const p= &s->picture;
AVFrame *picture = data;
*data_size = 0;
if (buf_size == 0)
return 0;
bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);
init_get_bits(&s->gb, s->bitstream_buffer, buf_size);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0];
fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1];
fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2];
s->last_slice_end= 0;
if(s->bitstream_bpp<24){
int y, cy;
int lefty, leftu, leftv;
int lefttopy, lefttopu, lefttopv;
if(s->yuy2){
p->data[0][3]= get_bits(&s->gb, 8);
p->data[0][2]= get_bits(&s->gb, 8);
p->data[0][1]= get_bits(&s->gb, 8);
p->data[0][0]= get_bits(&s->gb, 8);
fprintf(stderr, "YUY2 output isnt implemenetd yet\n");
return -1;
}else{
leftv= p->data[2][0]= get_bits(&s->gb, 8);
lefty= p->data[0][1]= get_bits(&s->gb, 8);
leftu= p->data[1][0]= get_bits(&s->gb, 8);
p->data[0][0]= get_bits(&s->gb, 8);
switch(s->predictor){
case LEFT:
case PLANE:
decode_422_bitstream(s, width-2);
lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu);
leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv);
}
for(cy=y=1; y<s->height; y++,cy++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
decode_gray_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
lefty= add_left_prediction(ydst, s->temp[0], width, lefty);
if(s->predictor == PLANE){
if(y>s->interlaced)
s->dsp.add_bytes(ydst, ydst - fake_ystride, width);
}
y++;
if(y>=s->height) break;
}
draw_slice(s, y);
ydst= p->data[0] + p->linesize[0]*y;
udst= p->data[1] + p->linesize[1]*cy;
vdst= p->data[2] + p->linesize[2]*cy;
decode_422_bitstream(s, width);
lefty= add_left_prediction(ydst, s->temp[0], width, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(udst, s->temp[1], width2, leftu);
leftv= add_left_prediction(vdst, s->temp[2], width2, leftv);
}
if(s->predictor == PLANE){
if(cy>s->interlaced){
s->dsp.add_bytes(ydst, ydst - fake_ystride, width);
if(!(s->flags&CODEC_FLAG_GRAY)){
s->dsp.add_bytes(udst, udst - fake_ustride, width2);
s->dsp.add_bytes(vdst, vdst - fake_vstride, width2);
}
}
}
}
draw_slice(s, height);
break;
case MEDIAN:
decode_422_bitstream(s, width-2);
lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu);
leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv);
}
cy=y=1;
if(s->interlaced){
decode_422_bitstream(s, width);
lefty= add_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu);
leftv= add_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv);
}
y++; cy++;
}
decode_422_bitstream(s, 4);
lefty= add_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty);
if(!(s->flags&CODEC_FLAG_GRAY)){
leftu= add_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu);
leftv= add_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv);
}
lefttopy= p->data[0][3];
decode_422_bitstream(s, width-4);
add_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy);
if(!(s->flags&CODEC_FLAG_GRAY)){
lefttopu= p->data[1][1];
lefttopv= p->data[2][1];
add_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu);
add_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv);
}
y++; cy++;
for(; y<height; y++,cy++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
while(2*cy > y){
decode_gray_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
y++;
}
if(y>=height) break;
}
draw_slice(s, y);
decode_422_bitstream(s, width);
ydst= p->data[0] + p->linesize[0]*y;
udst= p->data[1] + p->linesize[1]*cy;
vdst= p->data[2] + p->linesize[2]*cy;
add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy);
if(!(s->flags&CODEC_FLAG_GRAY)){
add_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu);
add_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv);
}
}
draw_slice(s, height);
break;
}
}
}else{
int y;
int leftr, leftg, leftb;
const int last_line= (height-1)*p->linesize[0];
if(s->bitstream_bpp==32){
p->data[0][last_line+3]= get_bits(&s->gb, 8);
leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8);
leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8);
leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8);
}else{
leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8);
leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8);
leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8);
skip_bits(&s->gb, 8);
}
if(s->bgr32){
switch(s->predictor){
case LEFT:
case PLANE:
decode_bgr_bitstream(s, width-1);
add_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb);
for(y=s->height-2; y>=0; y--){
decode_bgr_bitstream(s, width);
add_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb);
if(s->predictor == PLANE){
if((y&s->interlaced)==0){
s->dsp.add_bytes(p->data[0] + p->linesize[0]*y,
p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride);
}
}
}
draw_slice(s, height);
break;
default:
fprintf(stderr, "prediction type not supported!\n");
}
}else{
fprintf(stderr, "BGR24 output isnt implemenetd yet\n");
return -1;
}
}
emms_c();
*picture= *p;
avctx->release_buffer(avctx, p);
*data_size = sizeof(AVFrame);
return (get_bits_count(&s->gb)+7)>>3;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, uint8_t *VAR_3, int VAR_4){
HYuvContext *s = VAR_0->priv_data;
const int VAR_5= s->VAR_5;
const int VAR_6= s->VAR_5>>1;
const int VAR_7= s->VAR_7;
int VAR_8, VAR_9, VAR_10;
AVFrame * const p= &s->picture;
AVFrame *picture = VAR_1;
*VAR_2 = 0;
if (VAR_4 == 0)
return 0;
bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)VAR_3, VAR_4/4);
init_get_bits(&s->gb, s->bitstream_buffer, VAR_4);
p->reference= 0;
if(VAR_0->get_buffer(VAR_0, p) < 0){
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
VAR_8= s->interlaced ? p->linesize[0]*2 : p->linesize[0];
VAR_9= s->interlaced ? p->linesize[1]*2 : p->linesize[1];
VAR_10= s->interlaced ? p->linesize[2]*2 : p->linesize[2];
s->last_slice_end= 0;
if(s->bitstream_bpp<24){
int VAR_19, VAR_12;
int VAR_13, VAR_14, VAR_15;
int VAR_16, VAR_17, VAR_18;
if(s->yuy2){
p->VAR_1[0][3]= get_bits(&s->gb, 8);
p->VAR_1[0][2]= get_bits(&s->gb, 8);
p->VAR_1[0][1]= get_bits(&s->gb, 8);
p->VAR_1[0][0]= get_bits(&s->gb, 8);
fprintf(stderr, "YUY2 output isnt implemenetd yet\n");
return -1;
}else{
VAR_15= p->VAR_1[2][0]= get_bits(&s->gb, 8);
VAR_13= p->VAR_1[0][1]= get_bits(&s->gb, 8);
VAR_14= p->VAR_1[1][0]= get_bits(&s->gb, 8);
p->VAR_1[0][0]= get_bits(&s->gb, 8);
switch(s->predictor){
case LEFT:
case PLANE:
decode_422_bitstream(s, VAR_5-2);
VAR_13= add_left_prediction(p->VAR_1[0] + 2, s->temp[0], VAR_5-2, VAR_13);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_14= add_left_prediction(p->VAR_1[1] + 1, s->temp[1], VAR_6-1, VAR_14);
VAR_15= add_left_prediction(p->VAR_1[2] + 1, s->temp[2], VAR_6-1, VAR_15);
}
for(VAR_12=VAR_19=1; VAR_19<s->VAR_7; VAR_19++,VAR_12++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
decode_gray_bitstream(s, VAR_5);
ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;
VAR_13= add_left_prediction(ydst, s->temp[0], VAR_5, VAR_13);
if(s->predictor == PLANE){
if(VAR_19>s->interlaced)
s->dsp.add_bytes(ydst, ydst - VAR_8, VAR_5);
}
VAR_19++;
if(VAR_19>=s->VAR_7) break;
}
draw_slice(s, VAR_19);
ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;
udst= p->VAR_1[1] + p->linesize[1]*VAR_12;
vdst= p->VAR_1[2] + p->linesize[2]*VAR_12;
decode_422_bitstream(s, VAR_5);
VAR_13= add_left_prediction(ydst, s->temp[0], VAR_5, VAR_13);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_14= add_left_prediction(udst, s->temp[1], VAR_6, VAR_14);
VAR_15= add_left_prediction(vdst, s->temp[2], VAR_6, VAR_15);
}
if(s->predictor == PLANE){
if(VAR_12>s->interlaced){
s->dsp.add_bytes(ydst, ydst - VAR_8, VAR_5);
if(!(s->flags&CODEC_FLAG_GRAY)){
s->dsp.add_bytes(udst, udst - VAR_9, VAR_6);
s->dsp.add_bytes(vdst, vdst - VAR_10, VAR_6);
}
}
}
}
draw_slice(s, VAR_7);
break;
case MEDIAN:
decode_422_bitstream(s, VAR_5-2);
VAR_13= add_left_prediction(p->VAR_1[0] + 2, s->temp[0], VAR_5-2, VAR_13);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_14= add_left_prediction(p->VAR_1[1] + 1, s->temp[1], VAR_6-1, VAR_14);
VAR_15= add_left_prediction(p->VAR_1[2] + 1, s->temp[2], VAR_6-1, VAR_15);
}
VAR_12=VAR_19=1;
if(s->interlaced){
decode_422_bitstream(s, VAR_5);
VAR_13= add_left_prediction(p->VAR_1[0] + p->linesize[0], s->temp[0], VAR_5, VAR_13);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_14= add_left_prediction(p->VAR_1[1] + p->linesize[2], s->temp[1], VAR_6, VAR_14);
VAR_15= add_left_prediction(p->VAR_1[2] + p->linesize[1], s->temp[2], VAR_6, VAR_15);
}
VAR_19++; VAR_12++;
}
decode_422_bitstream(s, 4);
VAR_13= add_left_prediction(p->VAR_1[0] + VAR_8, s->temp[0], 4, VAR_13);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_14= add_left_prediction(p->VAR_1[1] + VAR_9, s->temp[1], 2, VAR_14);
VAR_15= add_left_prediction(p->VAR_1[2] + VAR_10, s->temp[2], 2, VAR_15);
}
VAR_16= p->VAR_1[0][3];
decode_422_bitstream(s, VAR_5-4);
add_median_prediction(p->VAR_1[0] + VAR_8+4, p->VAR_1[0]+4, s->temp[0], VAR_5-4, &VAR_13, &VAR_16);
if(!(s->flags&CODEC_FLAG_GRAY)){
VAR_17= p->VAR_1[1][1];
VAR_18= p->VAR_1[2][1];
add_median_prediction(p->VAR_1[1] + VAR_9+2, p->VAR_1[1]+2, s->temp[1], VAR_6-2, &VAR_14, &VAR_17);
add_median_prediction(p->VAR_1[2] + VAR_10+2, p->VAR_1[2]+2, s->temp[2], VAR_6-2, &VAR_15, &VAR_18);
}
VAR_19++; VAR_12++;
for(; VAR_19<VAR_7; VAR_19++,VAR_12++){
uint8_t *ydst, *udst, *vdst;
if(s->bitstream_bpp==12){
while(2*VAR_12 > VAR_19){
decode_gray_bitstream(s, VAR_5);
ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;
add_median_prediction(ydst, ydst - VAR_8, s->temp[0], VAR_5, &VAR_13, &VAR_16);
VAR_19++;
}
if(VAR_19>=VAR_7) break;
}
draw_slice(s, VAR_19);
decode_422_bitstream(s, VAR_5);
ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;
udst= p->VAR_1[1] + p->linesize[1]*VAR_12;
vdst= p->VAR_1[2] + p->linesize[2]*VAR_12;
add_median_prediction(ydst, ydst - VAR_8, s->temp[0], VAR_5, &VAR_13, &VAR_16);
if(!(s->flags&CODEC_FLAG_GRAY)){
add_median_prediction(udst, udst - VAR_9, s->temp[1], VAR_6, &VAR_14, &VAR_17);
add_median_prediction(vdst, vdst - VAR_10, s->temp[2], VAR_6, &VAR_15, &VAR_18);
}
}
draw_slice(s, VAR_7);
break;
}
}
}else{
int VAR_19;
int VAR_19, VAR_20, VAR_21;
const int VAR_22= (VAR_7-1)*p->linesize[0];
if(s->bitstream_bpp==32){
p->VAR_1[0][VAR_22+3]= get_bits(&s->gb, 8);
VAR_19= p->VAR_1[0][VAR_22+2]= get_bits(&s->gb, 8);
VAR_20= p->VAR_1[0][VAR_22+1]= get_bits(&s->gb, 8);
VAR_21= p->VAR_1[0][VAR_22+0]= get_bits(&s->gb, 8);
}else{
VAR_19= p->VAR_1[0][VAR_22+2]= get_bits(&s->gb, 8);
VAR_20= p->VAR_1[0][VAR_22+1]= get_bits(&s->gb, 8);
VAR_21= p->VAR_1[0][VAR_22+0]= get_bits(&s->gb, 8);
skip_bits(&s->gb, 8);
}
if(s->bgr32){
switch(s->predictor){
case LEFT:
case PLANE:
decode_bgr_bitstream(s, VAR_5-1);
add_left_prediction_bgr32(p->VAR_1[0] + VAR_22+4, s->temp[0], VAR_5-1, &VAR_19, &VAR_20, &VAR_21);
for(VAR_19=s->VAR_7-2; VAR_19>=0; VAR_19--){
decode_bgr_bitstream(s, VAR_5);
add_left_prediction_bgr32(p->VAR_1[0] + p->linesize[0]*VAR_19, s->temp[0], VAR_5, &VAR_19, &VAR_20, &VAR_21);
if(s->predictor == PLANE){
if((VAR_19&s->interlaced)==0){
s->dsp.add_bytes(p->VAR_1[0] + p->linesize[0]*VAR_19,
p->VAR_1[0] + p->linesize[0]*VAR_19 + VAR_8, VAR_8);
}
}
}
draw_slice(s, VAR_7);
break;
default:
fprintf(stderr, "prediction type not supported!\n");
}
}else{
fprintf(stderr, "BGR24 output isnt implemenetd yet\n");
return -1;
}
}
emms_c();
*picture= *p;
VAR_0->release_buffer(VAR_0, p);
*VAR_2 = sizeof(AVFrame);
return (get_bits_count(&s->gb)+7)>>3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, uint8_t *VAR_3, int VAR_4){",
"HYuvContext *s = VAR_0->priv_data;",
"const int VAR_5= s->VAR_5;",
"const int VAR_6= s->VAR_5>>1;",
"const int VAR_7= s->VAR_7;",
"int VAR_8, VAR_9, VAR_10;",
"AVFrame * const p= &s->picture;",
"AVFrame *picture = VAR_1;",
"*VAR_2 = 0;",
"if (VAR_4 == 0)\nreturn 0;",
"bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)VAR_3, VAR_4/4);",
"init_get_bits(&s->gb, s->bitstream_buffer, VAR_4);",
"p->reference= 0;",
"if(VAR_0->get_buffer(VAR_0, p) < 0){",
"fprintf(stderr, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"VAR_8= s->interlaced ? p->linesize[0]*2 : p->linesize[0];",
"VAR_9= s->interlaced ? p->linesize[1]*2 : p->linesize[1];",
"VAR_10= s->interlaced ? p->linesize[2]*2 : p->linesize[2];",
"s->last_slice_end= 0;",
"if(s->bitstream_bpp<24){",
"int VAR_19, VAR_12;",
"int VAR_13, VAR_14, VAR_15;",
"int VAR_16, VAR_17, VAR_18;",
"if(s->yuy2){",
"p->VAR_1[0][3]= get_bits(&s->gb, 8);",
"p->VAR_1[0][2]= get_bits(&s->gb, 8);",
"p->VAR_1[0][1]= get_bits(&s->gb, 8);",
"p->VAR_1[0][0]= get_bits(&s->gb, 8);",
"fprintf(stderr, \"YUY2 output isnt implemenetd yet\\n\");",
"return -1;",
"}else{",
"VAR_15= p->VAR_1[2][0]= get_bits(&s->gb, 8);",
"VAR_13= p->VAR_1[0][1]= get_bits(&s->gb, 8);",
"VAR_14= p->VAR_1[1][0]= get_bits(&s->gb, 8);",
"p->VAR_1[0][0]= get_bits(&s->gb, 8);",
"switch(s->predictor){",
"case LEFT:\ncase PLANE:\ndecode_422_bitstream(s, VAR_5-2);",
"VAR_13= add_left_prediction(p->VAR_1[0] + 2, s->temp[0], VAR_5-2, VAR_13);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_14= add_left_prediction(p->VAR_1[1] + 1, s->temp[1], VAR_6-1, VAR_14);",
"VAR_15= add_left_prediction(p->VAR_1[2] + 1, s->temp[2], VAR_6-1, VAR_15);",
"}",
"for(VAR_12=VAR_19=1; VAR_19<s->VAR_7; VAR_19++,VAR_12++){",
"uint8_t *ydst, *udst, *vdst;",
"if(s->bitstream_bpp==12){",
"decode_gray_bitstream(s, VAR_5);",
"ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;",
"VAR_13= add_left_prediction(ydst, s->temp[0], VAR_5, VAR_13);",
"if(s->predictor == PLANE){",
"if(VAR_19>s->interlaced)\ns->dsp.add_bytes(ydst, ydst - VAR_8, VAR_5);",
"}",
"VAR_19++;",
"if(VAR_19>=s->VAR_7) break;",
"}",
"draw_slice(s, VAR_19);",
"ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;",
"udst= p->VAR_1[1] + p->linesize[1]*VAR_12;",
"vdst= p->VAR_1[2] + p->linesize[2]*VAR_12;",
"decode_422_bitstream(s, VAR_5);",
"VAR_13= add_left_prediction(ydst, s->temp[0], VAR_5, VAR_13);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_14= add_left_prediction(udst, s->temp[1], VAR_6, VAR_14);",
"VAR_15= add_left_prediction(vdst, s->temp[2], VAR_6, VAR_15);",
"}",
"if(s->predictor == PLANE){",
"if(VAR_12>s->interlaced){",
"s->dsp.add_bytes(ydst, ydst - VAR_8, VAR_5);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"s->dsp.add_bytes(udst, udst - VAR_9, VAR_6);",
"s->dsp.add_bytes(vdst, vdst - VAR_10, VAR_6);",
"}",
"}",
"}",
"}",
"draw_slice(s, VAR_7);",
"break;",
"case MEDIAN:\ndecode_422_bitstream(s, VAR_5-2);",
"VAR_13= add_left_prediction(p->VAR_1[0] + 2, s->temp[0], VAR_5-2, VAR_13);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_14= add_left_prediction(p->VAR_1[1] + 1, s->temp[1], VAR_6-1, VAR_14);",
"VAR_15= add_left_prediction(p->VAR_1[2] + 1, s->temp[2], VAR_6-1, VAR_15);",
"}",
"VAR_12=VAR_19=1;",
"if(s->interlaced){",
"decode_422_bitstream(s, VAR_5);",
"VAR_13= add_left_prediction(p->VAR_1[0] + p->linesize[0], s->temp[0], VAR_5, VAR_13);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_14= add_left_prediction(p->VAR_1[1] + p->linesize[2], s->temp[1], VAR_6, VAR_14);",
"VAR_15= add_left_prediction(p->VAR_1[2] + p->linesize[1], s->temp[2], VAR_6, VAR_15);",
"}",
"VAR_19++; VAR_12++;",
"}",
"decode_422_bitstream(s, 4);",
"VAR_13= add_left_prediction(p->VAR_1[0] + VAR_8, s->temp[0], 4, VAR_13);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_14= add_left_prediction(p->VAR_1[1] + VAR_9, s->temp[1], 2, VAR_14);",
"VAR_15= add_left_prediction(p->VAR_1[2] + VAR_10, s->temp[2], 2, VAR_15);",
"}",
"VAR_16= p->VAR_1[0][3];",
"decode_422_bitstream(s, VAR_5-4);",
"add_median_prediction(p->VAR_1[0] + VAR_8+4, p->VAR_1[0]+4, s->temp[0], VAR_5-4, &VAR_13, &VAR_16);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"VAR_17= p->VAR_1[1][1];",
"VAR_18= p->VAR_1[2][1];",
"add_median_prediction(p->VAR_1[1] + VAR_9+2, p->VAR_1[1]+2, s->temp[1], VAR_6-2, &VAR_14, &VAR_17);",
"add_median_prediction(p->VAR_1[2] + VAR_10+2, p->VAR_1[2]+2, s->temp[2], VAR_6-2, &VAR_15, &VAR_18);",
"}",
"VAR_19++; VAR_12++;",
"for(; VAR_19<VAR_7; VAR_19++,VAR_12++){",
"uint8_t *ydst, *udst, *vdst;",
"if(s->bitstream_bpp==12){",
"while(2*VAR_12 > VAR_19){",
"decode_gray_bitstream(s, VAR_5);",
"ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;",
"add_median_prediction(ydst, ydst - VAR_8, s->temp[0], VAR_5, &VAR_13, &VAR_16);",
"VAR_19++;",
"}",
"if(VAR_19>=VAR_7) break;",
"}",
"draw_slice(s, VAR_19);",
"decode_422_bitstream(s, VAR_5);",
"ydst= p->VAR_1[0] + p->linesize[0]*VAR_19;",
"udst= p->VAR_1[1] + p->linesize[1]*VAR_12;",
"vdst= p->VAR_1[2] + p->linesize[2]*VAR_12;",
"add_median_prediction(ydst, ydst - VAR_8, s->temp[0], VAR_5, &VAR_13, &VAR_16);",
"if(!(s->flags&CODEC_FLAG_GRAY)){",
"add_median_prediction(udst, udst - VAR_9, s->temp[1], VAR_6, &VAR_14, &VAR_17);",
"add_median_prediction(vdst, vdst - VAR_10, s->temp[2], VAR_6, &VAR_15, &VAR_18);",
"}",
"}",
"draw_slice(s, VAR_7);",
"break;",
"}",
"}",
"}else{",
"int VAR_19;",
"int VAR_19, VAR_20, VAR_21;",
"const int VAR_22= (VAR_7-1)*p->linesize[0];",
"if(s->bitstream_bpp==32){",
"p->VAR_1[0][VAR_22+3]= get_bits(&s->gb, 8);",
"VAR_19= p->VAR_1[0][VAR_22+2]= get_bits(&s->gb, 8);",
"VAR_20= p->VAR_1[0][VAR_22+1]= get_bits(&s->gb, 8);",
"VAR_21= p->VAR_1[0][VAR_22+0]= get_bits(&s->gb, 8);",
"}else{",
"VAR_19= p->VAR_1[0][VAR_22+2]= get_bits(&s->gb, 8);",
"VAR_20= p->VAR_1[0][VAR_22+1]= get_bits(&s->gb, 8);",
"VAR_21= p->VAR_1[0][VAR_22+0]= get_bits(&s->gb, 8);",
"skip_bits(&s->gb, 8);",
"}",
"if(s->bgr32){",
"switch(s->predictor){",
"case LEFT:\ncase PLANE:\ndecode_bgr_bitstream(s, VAR_5-1);",
"add_left_prediction_bgr32(p->VAR_1[0] + VAR_22+4, s->temp[0], VAR_5-1, &VAR_19, &VAR_20, &VAR_21);",
"for(VAR_19=s->VAR_7-2; VAR_19>=0; VAR_19--){",
"decode_bgr_bitstream(s, VAR_5);",
"add_left_prediction_bgr32(p->VAR_1[0] + p->linesize[0]*VAR_19, s->temp[0], VAR_5, &VAR_19, &VAR_20, &VAR_21);",
"if(s->predictor == PLANE){",
"if((VAR_19&s->interlaced)==0){",
"s->dsp.add_bytes(p->VAR_1[0] + p->linesize[0]*VAR_19,\np->VAR_1[0] + p->linesize[0]*VAR_19 + VAR_8, VAR_8);",
"}",
"}",
"}",
"draw_slice(s, VAR_7);",
"break;",
"default:\nfprintf(stderr, \"prediction type not supported!\\n\");",
"}",
"}else{",
"fprintf(stderr, \"BGR24 output isnt implemenetd yet\\n\");",
"return -1;",
"}",
"}",
"emms_c();",
"*picture= *p;",
"VAR_0->release_buffer(VAR_0, p);",
"*VAR_2 = sizeof(AVFrame);",
"return (get_bits_count(&s->gb)+7)>>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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
27,
29
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
133
],
[
137
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209,
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
321
],
[
325
],
[
327
],
[
329
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393,
395,
397
],
[
399
],
[
403
],
[
405
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451
],
[
455
],
[
459
],
[
463
],
[
465
]
] |
25,647 | static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
int permit_abbrev, bool defaults)
{
const char *firstname;
char value[1024], *id = NULL;
const char *p;
QemuOpts *opts;
Error *local_err = NULL;
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
if (strncmp(params, "id=", 3) == 0) {
get_opt_value(value, sizeof(value), params+3);
id = value;
} else if ((p = strstr(params, ",id=")) != NULL) {
get_opt_value(value, sizeof(value), p+4);
id = value;
}
opts = qemu_opts_create(list, id, !defaults, &local_err);
if (opts == NULL) {
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
}
return NULL;
}
if (opts_do_parse(opts, params, firstname, defaults) != 0) {
qemu_opts_del(opts);
return NULL;
}
return opts;
} | true | qemu | cb77d1925ac4d673e19be58aa39fc53c5d2fed10 | static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
int permit_abbrev, bool defaults)
{
const char *firstname;
char value[1024], *id = NULL;
const char *p;
QemuOpts *opts;
Error *local_err = NULL;
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
if (strncmp(params, "id=", 3) == 0) {
get_opt_value(value, sizeof(value), params+3);
id = value;
} else if ((p = strstr(params, ",id=")) != NULL) {
get_opt_value(value, sizeof(value), p+4);
id = value;
}
opts = qemu_opts_create(list, id, !defaults, &local_err);
if (opts == NULL) {
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
}
return NULL;
}
if (opts_do_parse(opts, params, firstname, defaults) != 0) {
qemu_opts_del(opts);
return NULL;
}
return opts;
} | {
"code": [],
"line_no": []
} | static QemuOpts *FUNC_0(QemuOptsList *list, const char *params,
int permit_abbrev, bool defaults)
{
const char *VAR_0;
char VAR_1[1024], *VAR_2 = NULL;
const char *VAR_3;
QemuOpts *opts;
Error *local_err = NULL;
assert(!permit_abbrev || list->implied_opt_name);
VAR_0 = permit_abbrev ? list->implied_opt_name : NULL;
if (strncmp(params, "VAR_2=", 3) == 0) {
get_opt_value(VAR_1, sizeof(VAR_1), params+3);
VAR_2 = VAR_1;
} else if ((VAR_3 = strstr(params, ",VAR_2=")) != NULL) {
get_opt_value(VAR_1, sizeof(VAR_1), VAR_3+4);
VAR_2 = VAR_1;
}
opts = qemu_opts_create(list, VAR_2, !defaults, &local_err);
if (opts == NULL) {
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
}
return NULL;
}
if (opts_do_parse(opts, params, VAR_0, defaults) != 0) {
qemu_opts_del(opts);
return NULL;
}
return opts;
} | [
"static QemuOpts *FUNC_0(QemuOptsList *list, const char *params,\nint permit_abbrev, bool defaults)\n{",
"const char *VAR_0;",
"char VAR_1[1024], *VAR_2 = NULL;",
"const char *VAR_3;",
"QemuOpts *opts;",
"Error *local_err = NULL;",
"assert(!permit_abbrev || list->implied_opt_name);",
"VAR_0 = permit_abbrev ? list->implied_opt_name : NULL;",
"if (strncmp(params, \"VAR_2=\", 3) == 0) {",
"get_opt_value(VAR_1, sizeof(VAR_1), params+3);",
"VAR_2 = VAR_1;",
"} else if ((VAR_3 = strstr(params, \",VAR_2=\")) != NULL) {",
"get_opt_value(VAR_1, sizeof(VAR_1), VAR_3+4);",
"VAR_2 = VAR_1;",
"}",
"opts = qemu_opts_create(list, VAR_2, !defaults, &local_err);",
"if (opts == NULL) {",
"if (error_is_set(&local_err)) {",
"qerror_report_err(local_err);",
"error_free(local_err);",
"}",
"return NULL;",
"}",
"if (opts_do_parse(opts, params, VAR_0, defaults) != 0) {",
"qemu_opts_del(opts);",
"return NULL;",
"}",
"return opts;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30
],
[
31
]
] |
25,648 | static int get_bool(QEMUFile *f, void *pv, size_t size)
{
bool *v = pv;
*v = qemu_get_byte(f);
return 0;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int get_bool(QEMUFile *f, void *pv, size_t size)
{
bool *v = pv;
*v = qemu_get_byte(f);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)
{
bool *v = VAR_1;
*v = qemu_get_byte(VAR_0);
return 0;
}
| [
"static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, size_t VAR_2)\n{",
"bool *v = VAR_1;",
"*v = qemu_get_byte(VAR_0);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
25,649 | int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
}
}
/* many decoders assign whole AVFrames, thus overwriting extended_data;
* make sure it's set correctly; assume decoders that actually use
* extended_data are doing it correctly */
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
} | true | FFmpeg | 1bc64c2814d409d3cc129c27c493ee915bebdc4a | int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
}
}
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
} | {
"code": [],
"line_no": []
} | int VAR_0 avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
}
}
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
} | [
"int VAR_0 avcodec_decode_audio4(AVCodecContext *avctx,\nAVFrame *frame,\nint *got_frame_ptr,\nAVPacket *avpkt)\n{",
"int planar, channels;",
"int ret = 0;",
"*got_frame_ptr = 0;",
"avctx->pkt = avpkt;",
"if (!avpkt->data && avpkt->size) {",
"av_log(avctx, AV_LOG_ERROR, \"invalid packet: NULL data, size != 0\\n\");",
"return AVERROR(EINVAL);",
"}",
"apply_param_change(avctx, avpkt);",
"if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {",
"ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);",
"if (ret >= 0 && *got_frame_ptr) {",
"avctx->frame_number++;",
"frame->pkt_dts = avpkt->dts;",
"if (frame->format == AV_SAMPLE_FMT_NONE)\nframe->format = avctx->sample_fmt;",
"}",
"}",
"planar = av_sample_fmt_is_planar(frame->format);",
"channels = av_get_channel_layout_nb_channels(frame->channel_layout);",
"if (!(planar && channels > AV_NUM_DATA_POINTERS))\nframe->extended_data = frame->data;",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3,
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20,
21
],
[
22
],
[
23
],
[
27
],
[
28
],
[
29,
30
],
[
31
],
[
32
]
] |
25,650 | int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy)
{
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform))
return ret;
for (i = 0; i < 2; i++)
csize *= comp->coord[i][1] - comp->coord[i][0];
comp->data = av_malloc(csize * sizeof(int));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl - 1);
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width)
- (reslevel->coord[0][0] >> codsty->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height)
- (reslevel->coord[1][0] >> codsty->log2_prec_height);
reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precx, precy, precno;
int x0, y0, x1, y1;
int xi0, yi0, xi1, yi1;
int cblkperprecw, cblkperprech;
if (qntsty->quantsty != JPEG2000_QSTY_NONE) {
static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}};
int numbps;
numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0];
band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]);
} else
band->stepsize = 1 << 13;
if (reslevelno == 0) { // the same everywhere
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl-1);
} else{
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl);
}
band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;
band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, dx);
band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, dy);
band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);
if (!band->cblk)
return AVERROR(ENOMEM);
band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);
if (!band->prec)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) {
Jpeg2000Cblk *cblk = band->cblk + cblkno;
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
y0 = band->coord[1][0];
y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0;
yi0 = 0;
yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height;
yi1 = FFMIN(yi1, band->cblkny);
cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height);
for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) {
for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) {
band->prec[precno].yi0 = yi0;
band->prec[precno].yi1 = yi1;
}
yi1 += cblkperprech;
yi0 = yi1 - cblkperprech;
yi1 = FFMIN(yi1, band->cblkny);
}
x0 = band->coord[0][0];
x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0;
xi0 = 0;
xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width;
xi1 = FFMIN(xi1, band->cblknx);
cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width);
for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) {
for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) {
Jpeg2000Prec *prec = band->prec + precno;
prec->xi0 = xi0;
prec->xi1 = xi1;
prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
if (!prec->cblkincl || !prec->zerobits)
return AVERROR(ENOMEM);
}
xi1 += cblkperprecw;
xi0 = xi1 - cblkperprecw;
xi1 = FFMIN(xi1, band->cblknx);
}
}
}
return 0;
}
| true | FFmpeg | 9ea242962c4093a5523deef124a98193bbb36730 | int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy)
{
int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1;
if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform))
return ret;
for (i = 0; i < 2; i++)
csize *= comp->coord[i][1] - comp->coord[i][0];
comp->data = av_malloc(csize * sizeof(int));
if (!comp->data)
return AVERROR(ENOMEM);
comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel));
if (!comp->reslevel)
return AVERROR(ENOMEM);
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
int declvl = codsty->nreslevels - reslevelno;
Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
reslevel->coord[i][j] =
ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl - 1);
if (reslevelno == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width)
- (reslevel->coord[0][0] >> codsty->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height)
- (reslevel->coord[1][0] >> codsty->log2_prec_height);
reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precx, precy, precno;
int x0, y0, x1, y1;
int xi0, yi0, xi1, yi1;
int cblkperprecw, cblkperprech;
if (qntsty->quantsty != JPEG2000_QSTY_NONE) {
static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}};
int numbps;
numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0];
band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]);
} else
band->stepsize = 1 << 13;
if (reslevelno == 0) {
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl-1);
} else{
band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width);
band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height);
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl);
}
band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;
band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;
for (j = 0; j < 2; j++)
band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx);
for (j = 0; j < 2; j++)
band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy);
band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, dx);
band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, dy);
band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);
if (!band->cblk)
return AVERROR(ENOMEM);
band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);
if (!band->prec)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) {
Jpeg2000Cblk *cblk = band->cblk + cblkno;
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
y0 = band->coord[1][0];
y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0;
yi0 = 0;
yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height;
yi1 = FFMIN(yi1, band->cblkny);
cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height);
for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) {
for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) {
band->prec[precno].yi0 = yi0;
band->prec[precno].yi1 = yi1;
}
yi1 += cblkperprech;
yi0 = yi1 - cblkperprech;
yi1 = FFMIN(yi1, band->cblkny);
}
x0 = band->coord[0][0];
x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0;
xi0 = 0;
xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width;
xi1 = FFMIN(xi1, band->cblknx);
cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width);
for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) {
for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) {
Jpeg2000Prec *prec = band->prec + precno;
prec->xi0 = xi0;
prec->xi1 = xi1;
prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
if (!prec->cblkincl || !prec->zerobits)
return AVERROR(ENOMEM);
}
xi1 += cblkperprecw;
xi0 = xi1 - cblkperprecw;
xi1 = FFMIN(xi1, band->cblknx);
}
}
}
return 0;
}
| {
"code": [
" comp->data = av_malloc(csize * sizeof(int));",
" comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel));",
" reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));",
" band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);",
" band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);"
],
"line_no": [
19,
25,
85,
173,
179
]
} | int FUNC_0(Jpeg2000Component *VAR_0, Jpeg2000CodingStyle *VAR_1, Jpeg2000QuantStyle *VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
int VAR_6, VAR_7, VAR_8 = 0, VAR_9, VAR_10, VAR_11, VAR_12 = 1;
if (VAR_9=ff_j2k_dwt_init(&VAR_0->dwt, VAR_0->coord, VAR_1->nreslevels-1, VAR_1->transform))
return VAR_9;
for (VAR_10 = 0; VAR_10 < 2; VAR_10++)
VAR_12 *= VAR_0->coord[VAR_10][1] - VAR_0->coord[VAR_10][0];
VAR_0->data = av_malloc(VAR_12 * sizeof(int));
if (!VAR_0->data)
return AVERROR(ENOMEM);
VAR_0->reslevel = av_malloc(VAR_1->nreslevels * sizeof(Jpeg2000ResLevel));
if (!VAR_0->reslevel)
return AVERROR(ENOMEM);
for (VAR_6 = 0; VAR_6 < VAR_1->nreslevels; VAR_6++) {
int declvl = VAR_1->nreslevels - VAR_6;
Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_6;
for (VAR_10 = 0; VAR_10 < 2; VAR_10++)
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
reslevel->coord[VAR_10][VAR_11] =
ff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11], declvl - 1);
if (VAR_6 == 0)
reslevel->nbands = 1;
else
reslevel->nbands = 3;
if (reslevel->coord[0][1] == reslevel->coord[0][0])
reslevel->num_precincts_x = 0;
else
reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], VAR_1->log2_prec_width)
- (reslevel->coord[0][0] >> VAR_1->log2_prec_width);
if (reslevel->coord[1][1] == reslevel->coord[1][0])
reslevel->num_precincts_y = 0;
else
reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], VAR_1->log2_prec_height)
- (reslevel->coord[1][0] >> VAR_1->log2_prec_height);
reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));
if (!reslevel->band)
return AVERROR(ENOMEM);
for (VAR_7 = 0; VAR_7 < reslevel->nbands; VAR_7++, VAR_8++) {
Jpeg2000Band *band = reslevel->band + VAR_7;
int cblkno, precx, precy, precno;
int x0, y0, x1, y1;
int xi0, yi0, xi1, yi1;
int cblkperprecw, cblkperprech;
if (VAR_2->quantsty != JPEG2000_QSTY_NONE) {
static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}};
int numbps;
numbps = VAR_3 + lut_gain[VAR_1->transform][VAR_7 + VAR_6>0];
band->stepsize = SHL(2048 + VAR_2->mant[VAR_8], 2 + numbps - VAR_2->expn[VAR_8]);
} else
band->stepsize = 1 << 13;
if (VAR_6 == 0) {
band->codeblock_width = 1 << FFMIN(VAR_1->log2_cblk_width, VAR_1->log2_prec_width-1);
band->codeblock_height = 1 << FFMIN(VAR_1->log2_cblk_height, VAR_1->log2_prec_height-1);
for (VAR_10 = 0; VAR_10 < 2; VAR_10++)
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
band->coord[VAR_10][VAR_11] = ff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11], declvl-1);
} else{
band->codeblock_width = 1 << FFMIN(VAR_1->log2_cblk_width, VAR_1->log2_prec_width);
band->codeblock_height = 1 << FFMIN(VAR_1->log2_cblk_height, VAR_1->log2_prec_height);
for (VAR_10 = 0; VAR_10 < 2; VAR_10++)
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
band->coord[VAR_10][VAR_11] = ff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11] - (((VAR_7+1>>VAR_10)&1) << declvl-1), declvl);
}
band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;
band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
band->coord[0][VAR_11] = ff_jpeg2000_ceildiv(band->coord[0][VAR_11], VAR_4);
for (VAR_11 = 0; VAR_11 < 2; VAR_11++)
band->coord[1][VAR_11] = ff_jpeg2000_ceildiv(band->coord[1][VAR_11], VAR_5);
band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, VAR_4);
band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, VAR_5);
band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);
if (!band->cblk)
return AVERROR(ENOMEM);
band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);
if (!band->prec)
return AVERROR(ENOMEM);
for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) {
Jpeg2000Cblk *cblk = band->cblk + cblkno;
cblk->zero = 0;
cblk->lblock = 3;
cblk->length = 0;
cblk->lengthinc = 0;
cblk->npasses = 0;
}
y0 = band->coord[1][0];
y1 = ((band->coord[1][0] + (1<<VAR_1->log2_prec_height)) & ~((1<<VAR_1->log2_prec_height)-1)) - y0;
yi0 = 0;
yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, VAR_1->log2_cblk_height) << VAR_1->log2_cblk_height;
yi1 = FFMIN(yi1, band->cblkny);
cblkperprech = 1<<(VAR_1->log2_prec_height - VAR_1->log2_cblk_height);
for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) {
for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) {
band->prec[precno].yi0 = yi0;
band->prec[precno].yi1 = yi1;
}
yi1 += cblkperprech;
yi0 = yi1 - cblkperprech;
yi1 = FFMIN(yi1, band->cblkny);
}
x0 = band->coord[0][0];
x1 = ((band->coord[0][0] + (1<<VAR_1->log2_prec_width)) & ~((1<<VAR_1->log2_prec_width)-1)) - x0;
xi0 = 0;
xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, VAR_1->log2_cblk_width) << VAR_1->log2_cblk_width;
xi1 = FFMIN(xi1, band->cblknx);
cblkperprecw = 1<<(VAR_1->log2_prec_width - VAR_1->log2_cblk_width);
for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) {
for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) {
Jpeg2000Prec *prec = band->prec + precno;
prec->xi0 = xi0;
prec->xi1 = xi1;
prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,
prec->yi1 - prec->yi0);
if (!prec->cblkincl || !prec->zerobits)
return AVERROR(ENOMEM);
}
xi1 += cblkperprecw;
xi0 = xi1 - cblkperprecw;
xi1 = FFMIN(xi1, band->cblknx);
}
}
}
return 0;
}
| [
"int FUNC_0(Jpeg2000Component *VAR_0, Jpeg2000CodingStyle *VAR_1, Jpeg2000QuantStyle *VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8 = 0, VAR_9, VAR_10, VAR_11, VAR_12 = 1;",
"if (VAR_9=ff_j2k_dwt_init(&VAR_0->dwt, VAR_0->coord, VAR_1->nreslevels-1, VAR_1->transform))\nreturn VAR_9;",
"for (VAR_10 = 0; VAR_10 < 2; VAR_10++)",
"VAR_12 *= VAR_0->coord[VAR_10][1] - VAR_0->coord[VAR_10][0];",
"VAR_0->data = av_malloc(VAR_12 * sizeof(int));",
"if (!VAR_0->data)\nreturn AVERROR(ENOMEM);",
"VAR_0->reslevel = av_malloc(VAR_1->nreslevels * sizeof(Jpeg2000ResLevel));",
"if (!VAR_0->reslevel)\nreturn AVERROR(ENOMEM);",
"for (VAR_6 = 0; VAR_6 < VAR_1->nreslevels; VAR_6++) {",
"int declvl = VAR_1->nreslevels - VAR_6;",
"Jpeg2000ResLevel *reslevel = VAR_0->reslevel + VAR_6;",
"for (VAR_10 = 0; VAR_10 < 2; VAR_10++)",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"reslevel->coord[VAR_10][VAR_11] =\nff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11], declvl - 1);",
"if (VAR_6 == 0)\nreslevel->nbands = 1;",
"else\nreslevel->nbands = 3;",
"if (reslevel->coord[0][1] == reslevel->coord[0][0])\nreslevel->num_precincts_x = 0;",
"else\nreslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], VAR_1->log2_prec_width)\n- (reslevel->coord[0][0] >> VAR_1->log2_prec_width);",
"if (reslevel->coord[1][1] == reslevel->coord[1][0])\nreslevel->num_precincts_y = 0;",
"else\nreslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], VAR_1->log2_prec_height)\n- (reslevel->coord[1][0] >> VAR_1->log2_prec_height);",
"reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band));",
"if (!reslevel->band)\nreturn AVERROR(ENOMEM);",
"for (VAR_7 = 0; VAR_7 < reslevel->nbands; VAR_7++, VAR_8++) {",
"Jpeg2000Band *band = reslevel->band + VAR_7;",
"int cblkno, precx, precy, precno;",
"int x0, y0, x1, y1;",
"int xi0, yi0, xi1, yi1;",
"int cblkperprecw, cblkperprech;",
"if (VAR_2->quantsty != JPEG2000_QSTY_NONE) {",
"static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}};",
"int numbps;",
"numbps = VAR_3 + lut_gain[VAR_1->transform][VAR_7 + VAR_6>0];",
"band->stepsize = SHL(2048 + VAR_2->mant[VAR_8], 2 + numbps - VAR_2->expn[VAR_8]);",
"} else",
"band->stepsize = 1 << 13;",
"if (VAR_6 == 0) {",
"band->codeblock_width = 1 << FFMIN(VAR_1->log2_cblk_width, VAR_1->log2_prec_width-1);",
"band->codeblock_height = 1 << FFMIN(VAR_1->log2_cblk_height, VAR_1->log2_prec_height-1);",
"for (VAR_10 = 0; VAR_10 < 2; VAR_10++)",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"band->coord[VAR_10][VAR_11] = ff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11], declvl-1);",
"} else{",
"band->codeblock_width = 1 << FFMIN(VAR_1->log2_cblk_width, VAR_1->log2_prec_width);",
"band->codeblock_height = 1 << FFMIN(VAR_1->log2_cblk_height, VAR_1->log2_prec_height);",
"for (VAR_10 = 0; VAR_10 < 2; VAR_10++)",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"band->coord[VAR_10][VAR_11] = ff_jpeg2000_ceildivpow2(VAR_0->coord[VAR_10][VAR_11] - (((VAR_7+1>>VAR_10)&1) << declvl-1), declvl);",
"}",
"band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width;",
"band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height;",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"band->coord[0][VAR_11] = ff_jpeg2000_ceildiv(band->coord[0][VAR_11], VAR_4);",
"for (VAR_11 = 0; VAR_11 < 2; VAR_11++)",
"band->coord[1][VAR_11] = ff_jpeg2000_ceildiv(band->coord[1][VAR_11], VAR_5);",
"band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, VAR_4);",
"band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, VAR_5);",
"band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny);",
"if (!band->cblk)\nreturn AVERROR(ENOMEM);",
"band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y);",
"if (!band->prec)\nreturn AVERROR(ENOMEM);",
"for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) {",
"Jpeg2000Cblk *cblk = band->cblk + cblkno;",
"cblk->zero = 0;",
"cblk->lblock = 3;",
"cblk->length = 0;",
"cblk->lengthinc = 0;",
"cblk->npasses = 0;",
"}",
"y0 = band->coord[1][0];",
"y1 = ((band->coord[1][0] + (1<<VAR_1->log2_prec_height)) & ~((1<<VAR_1->log2_prec_height)-1)) - y0;",
"yi0 = 0;",
"yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, VAR_1->log2_cblk_height) << VAR_1->log2_cblk_height;",
"yi1 = FFMIN(yi1, band->cblkny);",
"cblkperprech = 1<<(VAR_1->log2_prec_height - VAR_1->log2_cblk_height);",
"for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) {",
"for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) {",
"band->prec[precno].yi0 = yi0;",
"band->prec[precno].yi1 = yi1;",
"}",
"yi1 += cblkperprech;",
"yi0 = yi1 - cblkperprech;",
"yi1 = FFMIN(yi1, band->cblkny);",
"}",
"x0 = band->coord[0][0];",
"x1 = ((band->coord[0][0] + (1<<VAR_1->log2_prec_width)) & ~((1<<VAR_1->log2_prec_width)-1)) - x0;",
"xi0 = 0;",
"xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, VAR_1->log2_cblk_width) << VAR_1->log2_cblk_width;",
"xi1 = FFMIN(xi1, band->cblknx);",
"cblkperprecw = 1<<(VAR_1->log2_prec_width - VAR_1->log2_cblk_width);",
"for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) {",
"for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) {",
"Jpeg2000Prec *prec = band->prec + precno;",
"prec->xi0 = xi0;",
"prec->xi1 = xi1;",
"prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,\nprec->yi1 - prec->yi0);",
"prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0,\nprec->yi1 - prec->yi0);",
"if (!prec->cblkincl || !prec->zerobits)\nreturn AVERROR(ENOMEM);",
"}",
"xi1 += cblkperprecw;",
"xi0 = xi1 - cblkperprecw;",
"xi1 = FFMIN(xi1, band->cblknx);",
"}",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
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,
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
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45,
47
],
[
51,
53
],
[
55,
57
],
[
61,
63
],
[
65,
67,
69
],
[
73,
75
],
[
77,
79,
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
173
],
[
175,
177
],
[
179
],
[
181,
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263,
265
],
[
267,
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
]
] |
25,651 | static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
TCGv tmp, tmp2;
uint32_t rd = (insn >> 12) & 0xf;
uint32_t cp = (insn >> 8) & 0xf;
if (IS_USER(s)) {
return 1;
}
if (insn & ARM_CP_RW_BIT) {
if (!env->cp[cp].cp_read)
return 1;
gen_set_pc_im(s->pc);
tmp = new_tmp();
tmp2 = tcg_const_i32(insn);
gen_helper_get_cp(tmp, cpu_env, tmp2);
tcg_temp_free(tmp2);
store_reg(s, rd, tmp);
} else {
if (!env->cp[cp].cp_write)
return 1;
gen_set_pc_im(s->pc);
tmp = load_reg(s, rd);
tmp2 = tcg_const_i32(insn);
gen_helper_set_cp(cpu_env, tmp2, tmp);
tcg_temp_free(tmp2);
dead_tmp(tmp);
}
return 0;
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
TCGv tmp, tmp2;
uint32_t rd = (insn >> 12) & 0xf;
uint32_t cp = (insn >> 8) & 0xf;
if (IS_USER(s)) {
return 1;
}
if (insn & ARM_CP_RW_BIT) {
if (!env->cp[cp].cp_read)
return 1;
gen_set_pc_im(s->pc);
tmp = new_tmp();
tmp2 = tcg_const_i32(insn);
gen_helper_get_cp(tmp, cpu_env, tmp2);
tcg_temp_free(tmp2);
store_reg(s, rd, tmp);
} else {
if (!env->cp[cp].cp_write)
return 1;
gen_set_pc_im(s->pc);
tmp = load_reg(s, rd);
tmp2 = tcg_const_i32(insn);
gen_helper_set_cp(cpu_env, tmp2, tmp);
tcg_temp_free(tmp2);
dead_tmp(tmp);
}
return 0;
}
| {
"code": [
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" tmp = new_tmp();",
" dead_tmp(tmp);",
" dead_tmp(tmp);",
" dead_tmp(tmp);"
],
"line_no": [
53,
53,
53,
53,
27,
53,
27,
53,
53,
27,
53,
53,
53,
53,
27,
27,
53,
27,
53,
27,
53,
27,
53,
53,
53,
27,
53,
27,
53,
53,
53
]
} | static int FUNC_0(CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2)
{
TCGv tmp, tmp2;
uint32_t rd = (VAR_2 >> 12) & 0xf;
uint32_t cp = (VAR_2 >> 8) & 0xf;
if (IS_USER(VAR_1)) {
return 1;
}
if (VAR_2 & ARM_CP_RW_BIT) {
if (!VAR_0->cp[cp].cp_read)
return 1;
gen_set_pc_im(VAR_1->pc);
tmp = new_tmp();
tmp2 = tcg_const_i32(VAR_2);
gen_helper_get_cp(tmp, cpu_env, tmp2);
tcg_temp_free(tmp2);
store_reg(VAR_1, rd, tmp);
} else {
if (!VAR_0->cp[cp].cp_write)
return 1;
gen_set_pc_im(VAR_1->pc);
tmp = load_reg(VAR_1, rd);
tmp2 = tcg_const_i32(VAR_2);
gen_helper_set_cp(cpu_env, tmp2, tmp);
tcg_temp_free(tmp2);
dead_tmp(tmp);
}
return 0;
}
| [
"static int FUNC_0(CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2)\n{",
"TCGv tmp, tmp2;",
"uint32_t rd = (VAR_2 >> 12) & 0xf;",
"uint32_t cp = (VAR_2 >> 8) & 0xf;",
"if (IS_USER(VAR_1)) {",
"return 1;",
"}",
"if (VAR_2 & ARM_CP_RW_BIT) {",
"if (!VAR_0->cp[cp].cp_read)\nreturn 1;",
"gen_set_pc_im(VAR_1->pc);",
"tmp = new_tmp();",
"tmp2 = tcg_const_i32(VAR_2);",
"gen_helper_get_cp(tmp, cpu_env, tmp2);",
"tcg_temp_free(tmp2);",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"if (!VAR_0->cp[cp].cp_write)\nreturn 1;",
"gen_set_pc_im(VAR_1->pc);",
"tmp = load_reg(VAR_1, rd);",
"tmp2 = tcg_const_i32(VAR_2);",
"gen_helper_set_cp(cpu_env, tmp2, tmp);",
"tcg_temp_free(tmp2);",
"dead_tmp(tmp);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
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
]
] |
25,652 | static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st;
int len, ret, i;
av_init_packet(pkt);
for(;;) {
/* select current input stream component */
st = s->cur_st;
if (st) {
if (!st->need_parsing || !st->parser) {
/* no parsing needed: we just output the packet as is */
/* raw data support */
*pkt = st->cur_pkt; st->cur_pkt.data= NULL;
compute_pkt_fields(s, st, NULL, pkt);
s->cur_st = NULL;
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
(pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);
}
break;
} else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
len = av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size,
st->cur_ptr, st->cur_len,
st->cur_pkt.pts, st->cur_pkt.dts,
st->cur_pkt.pos);
st->cur_pkt.pts = AV_NOPTS_VALUE;
st->cur_pkt.dts = AV_NOPTS_VALUE;
/* increment read pointer */
st->cur_ptr += len;
st->cur_len -= len;
/* return packet if any */
if (pkt->size) {
got_packet:
pkt->duration = 0;
pkt->stream_index = st->index;
pkt->pts = st->parser->pts;
pkt->dts = st->parser->dts;
pkt->pos = st->parser->pos;
if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){
s->cur_st = NULL;
pkt->destruct= st->cur_pkt.destruct;
st->cur_pkt.destruct= NULL;
st->cur_pkt.data = NULL;
assert(st->cur_len == 0);
}else{
pkt->destruct = NULL;
}
compute_pkt_fields(s, st, st->parser, pkt);
if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY){
int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->pos : st->parser->frame_offset;
ff_reduce_index(s, st->index);
av_add_index_entry(st, pos, pkt->dts,
0, 0, AVINDEX_KEYFRAME);
}
break;
}
} else {
/* free packet */
av_free_packet(&st->cur_pkt);
s->cur_st = NULL;
}
} else {
AVPacket cur_pkt;
/* read next packet */
ret = av_read_packet(s, &cur_pkt);
if (ret < 0) {
if (ret == AVERROR(EAGAIN))
return ret;
/* return the last frames, if any */
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->parser && st->need_parsing) {
av_parser_parse2(st->parser, st->codec,
&pkt->data, &pkt->size,
NULL, 0,
AV_NOPTS_VALUE, AV_NOPTS_VALUE,
AV_NOPTS_VALUE);
if (pkt->size)
goto got_packet;
}
}
/* no more packets: really terminate parsing */
return ret;
}
st = s->streams[cur_pkt.stream_index];
st->cur_pkt= cur_pkt;
if(st->cur_pkt.pts != AV_NOPTS_VALUE &&
st->cur_pkt.dts != AV_NOPTS_VALUE &&
st->cur_pkt.pts < st->cur_pkt.dts){
av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size);
// av_free_packet(&st->cur_pkt);
// return -1;
}
if(s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size,
st->cur_pkt.duration,
st->cur_pkt.flags);
s->cur_st = st;
st->cur_ptr = st->cur_pkt.data;
st->cur_len = st->cur_pkt.size;
if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) {
av_log(s, AV_LOG_WARNING, "parser not found for codec "
"%s, packets or times may be invalid.\n",
avcodec_get_name(st->codec->codec_id));
/* no parser available: just output the raw packets */
st->need_parsing = AVSTREAM_PARSE_NONE;
}else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){
st->parser->flags |= PARSER_FLAG_ONCE;
}
}
}
}
if(s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
pkt->stream_index,
pkt->pts,
pkt->dts,
pkt->size,
pkt->duration,
pkt->flags);
return 0;
}
| true | FFmpeg | d64066f6e88c827e33002b2c7740efd62cd5ba7f | static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st;
int len, ret, i;
av_init_packet(pkt);
for(;;) {
st = s->cur_st;
if (st) {
if (!st->need_parsing || !st->parser) {
*pkt = st->cur_pkt; st->cur_pkt.data= NULL;
compute_pkt_fields(s, st, NULL, pkt);
s->cur_st = NULL;
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
(pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);
}
break;
} else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
len = av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size,
st->cur_ptr, st->cur_len,
st->cur_pkt.pts, st->cur_pkt.dts,
st->cur_pkt.pos);
st->cur_pkt.pts = AV_NOPTS_VALUE;
st->cur_pkt.dts = AV_NOPTS_VALUE;
st->cur_ptr += len;
st->cur_len -= len;
if (pkt->size) {
got_packet:
pkt->duration = 0;
pkt->stream_index = st->index;
pkt->pts = st->parser->pts;
pkt->dts = st->parser->dts;
pkt->pos = st->parser->pos;
if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){
s->cur_st = NULL;
pkt->destruct= st->cur_pkt.destruct;
st->cur_pkt.destruct= NULL;
st->cur_pkt.data = NULL;
assert(st->cur_len == 0);
}else{
pkt->destruct = NULL;
}
compute_pkt_fields(s, st, st->parser, pkt);
if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY){
int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->pos : st->parser->frame_offset;
ff_reduce_index(s, st->index);
av_add_index_entry(st, pos, pkt->dts,
0, 0, AVINDEX_KEYFRAME);
}
break;
}
} else {
av_free_packet(&st->cur_pkt);
s->cur_st = NULL;
}
} else {
AVPacket cur_pkt;
ret = av_read_packet(s, &cur_pkt);
if (ret < 0) {
if (ret == AVERROR(EAGAIN))
return ret;
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->parser && st->need_parsing) {
av_parser_parse2(st->parser, st->codec,
&pkt->data, &pkt->size,
NULL, 0,
AV_NOPTS_VALUE, AV_NOPTS_VALUE,
AV_NOPTS_VALUE);
if (pkt->size)
goto got_packet;
}
}
return ret;
}
st = s->streams[cur_pkt.stream_index];
st->cur_pkt= cur_pkt;
if(st->cur_pkt.pts != AV_NOPTS_VALUE &&
st->cur_pkt.dts != AV_NOPTS_VALUE &&
st->cur_pkt.pts < st->cur_pkt.dts){
av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size);
}
if(s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size,
st->cur_pkt.duration,
st->cur_pkt.flags);
s->cur_st = st;
st->cur_ptr = st->cur_pkt.data;
st->cur_len = st->cur_pkt.size;
if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) {
av_log(s, AV_LOG_WARNING, "parser not found for codec "
"%s, packets or times may be invalid.\n",
avcodec_get_name(st->codec->codec_id));
st->need_parsing = AVSTREAM_PARSE_NONE;
}else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){
st->parser->flags |= PARSER_FLAG_ONCE;
}
}
}
}
if(s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
pkt->stream_index,
pkt->pts,
pkt->dts,
pkt->size,
pkt->duration,
pkt->flags);
return 0;
}
| {
"code": [
" *pkt = st->cur_pkt; st->cur_pkt.data= NULL;"
],
"line_no": [
29
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
AVStream *st;
int VAR_2, VAR_3, VAR_4;
av_init_packet(VAR_1);
for(;;) {
st = VAR_0->cur_st;
if (st) {
if (!st->need_parsing || !st->parser) {
*VAR_1 = st->cur_pkt; st->cur_pkt.data= NULL;
compute_pkt_fields(VAR_0, st, NULL, VAR_1);
VAR_0->cur_st = NULL;
if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) &&
(VAR_1->flags & AV_PKT_FLAG_KEY) && VAR_1->dts != AV_NOPTS_VALUE) {
ff_reduce_index(VAR_0, st->index);
av_add_index_entry(st, VAR_1->pos, VAR_1->dts, 0, 0, AVINDEX_KEYFRAME);
}
break;
} else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
VAR_2 = av_parser_parse2(st->parser, st->codec, &VAR_1->data, &VAR_1->size,
st->cur_ptr, st->cur_len,
st->cur_pkt.pts, st->cur_pkt.dts,
st->cur_pkt.pos);
st->cur_pkt.pts = AV_NOPTS_VALUE;
st->cur_pkt.dts = AV_NOPTS_VALUE;
st->cur_ptr += VAR_2;
st->cur_len -= VAR_2;
if (VAR_1->size) {
got_packet:
VAR_1->duration = 0;
VAR_1->stream_index = st->index;
VAR_1->pts = st->parser->pts;
VAR_1->dts = st->parser->dts;
VAR_1->pos = st->parser->pos;
if(VAR_1->data == st->cur_pkt.data && VAR_1->size == st->cur_pkt.size){
VAR_0->cur_st = NULL;
VAR_1->destruct= st->cur_pkt.destruct;
st->cur_pkt.destruct= NULL;
st->cur_pkt.data = NULL;
assert(st->cur_len == 0);
}else{
VAR_1->destruct = NULL;
}
compute_pkt_fields(VAR_0, st, st->parser, VAR_1);
if((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) && VAR_1->flags & AV_PKT_FLAG_KEY){
int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? VAR_1->pos : st->parser->frame_offset;
ff_reduce_index(VAR_0, st->index);
av_add_index_entry(st, pos, VAR_1->dts,
0, 0, AVINDEX_KEYFRAME);
}
break;
}
} else {
av_free_packet(&st->cur_pkt);
VAR_0->cur_st = NULL;
}
} else {
AVPacket cur_pkt;
VAR_3 = av_read_packet(VAR_0, &cur_pkt);
if (VAR_3 < 0) {
if (VAR_3 == AVERROR(EAGAIN))
return VAR_3;
for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {
st = VAR_0->streams[VAR_4];
if (st->parser && st->need_parsing) {
av_parser_parse2(st->parser, st->codec,
&VAR_1->data, &VAR_1->size,
NULL, 0,
AV_NOPTS_VALUE, AV_NOPTS_VALUE,
AV_NOPTS_VALUE);
if (VAR_1->size)
goto got_packet;
}
}
return VAR_3;
}
st = VAR_0->streams[cur_pkt.stream_index];
st->cur_pkt= cur_pkt;
if(st->cur_pkt.pts != AV_NOPTS_VALUE &&
st->cur_pkt.dts != AV_NOPTS_VALUE &&
st->cur_pkt.pts < st->cur_pkt.dts){
av_log(VAR_0, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size);
}
if(VAR_0->debug & FF_FDEBUG_TS)
av_log(VAR_0, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
st->cur_pkt.stream_index,
st->cur_pkt.pts,
st->cur_pkt.dts,
st->cur_pkt.size,
st->cur_pkt.duration,
st->cur_pkt.flags);
VAR_0->cur_st = st;
st->cur_ptr = st->cur_pkt.data;
st->cur_len = st->cur_pkt.size;
if (st->need_parsing && !st->parser && !(VAR_0->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) {
av_log(VAR_0, AV_LOG_WARNING, "parser not found for codec "
"%VAR_0, packets or times may be invalid.\n",
avcodec_get_name(st->codec->codec_id));
st->need_parsing = AVSTREAM_PARSE_NONE;
}else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){
st->parser->flags |= PARSER_FLAG_ONCE;
}
}
}
}
if(VAR_0->debug & FF_FDEBUG_TS)
av_log(VAR_0, AV_LOG_DEBUG, "FUNC_0 stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
VAR_1->stream_index,
VAR_1->pts,
VAR_1->dts,
VAR_1->size,
VAR_1->duration,
VAR_1->flags);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"AVStream *st;",
"int VAR_2, VAR_3, VAR_4;",
"av_init_packet(VAR_1);",
"for(;;) {",
"st = VAR_0->cur_st;",
"if (st) {",
"if (!st->need_parsing || !st->parser) {",
"*VAR_1 = st->cur_pkt; st->cur_pkt.data= NULL;",
"compute_pkt_fields(VAR_0, st, NULL, VAR_1);",
"VAR_0->cur_st = NULL;",
"if ((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) &&\n(VAR_1->flags & AV_PKT_FLAG_KEY) && VAR_1->dts != AV_NOPTS_VALUE) {",
"ff_reduce_index(VAR_0, st->index);",
"av_add_index_entry(st, VAR_1->pos, VAR_1->dts, 0, 0, AVINDEX_KEYFRAME);",
"}",
"break;",
"} else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {",
"VAR_2 = av_parser_parse2(st->parser, st->codec, &VAR_1->data, &VAR_1->size,\nst->cur_ptr, st->cur_len,\nst->cur_pkt.pts, st->cur_pkt.dts,\nst->cur_pkt.pos);",
"st->cur_pkt.pts = AV_NOPTS_VALUE;",
"st->cur_pkt.dts = AV_NOPTS_VALUE;",
"st->cur_ptr += VAR_2;",
"st->cur_len -= VAR_2;",
"if (VAR_1->size) {",
"got_packet:\nVAR_1->duration = 0;",
"VAR_1->stream_index = st->index;",
"VAR_1->pts = st->parser->pts;",
"VAR_1->dts = st->parser->dts;",
"VAR_1->pos = st->parser->pos;",
"if(VAR_1->data == st->cur_pkt.data && VAR_1->size == st->cur_pkt.size){",
"VAR_0->cur_st = NULL;",
"VAR_1->destruct= st->cur_pkt.destruct;",
"st->cur_pkt.destruct= NULL;",
"st->cur_pkt.data = NULL;",
"assert(st->cur_len == 0);",
"}else{",
"VAR_1->destruct = NULL;",
"}",
"compute_pkt_fields(VAR_0, st, st->parser, VAR_1);",
"if((VAR_0->iformat->flags & AVFMT_GENERIC_INDEX) && VAR_1->flags & AV_PKT_FLAG_KEY){",
"int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? VAR_1->pos : st->parser->frame_offset;",
"ff_reduce_index(VAR_0, st->index);",
"av_add_index_entry(st, pos, VAR_1->dts,\n0, 0, AVINDEX_KEYFRAME);",
"}",
"break;",
"}",
"} else {",
"av_free_packet(&st->cur_pkt);",
"VAR_0->cur_st = NULL;",
"}",
"} else {",
"AVPacket cur_pkt;",
"VAR_3 = av_read_packet(VAR_0, &cur_pkt);",
"if (VAR_3 < 0) {",
"if (VAR_3 == AVERROR(EAGAIN))\nreturn VAR_3;",
"for(VAR_4 = 0; VAR_4 < VAR_0->nb_streams; VAR_4++) {",
"st = VAR_0->streams[VAR_4];",
"if (st->parser && st->need_parsing) {",
"av_parser_parse2(st->parser, st->codec,\n&VAR_1->data, &VAR_1->size,\nNULL, 0,\nAV_NOPTS_VALUE, AV_NOPTS_VALUE,\nAV_NOPTS_VALUE);",
"if (VAR_1->size)\ngoto got_packet;",
"}",
"}",
"return VAR_3;",
"}",
"st = VAR_0->streams[cur_pkt.stream_index];",
"st->cur_pkt= cur_pkt;",
"if(st->cur_pkt.pts != AV_NOPTS_VALUE &&\nst->cur_pkt.dts != AV_NOPTS_VALUE &&\nst->cur_pkt.pts < st->cur_pkt.dts){",
"av_log(VAR_0, AV_LOG_WARNING, \"Invalid timestamps stream=%d, pts=%\"PRId64\", dts=%\"PRId64\", size=%d\\n\",\nst->cur_pkt.stream_index,\nst->cur_pkt.pts,\nst->cur_pkt.dts,\nst->cur_pkt.size);",
"}",
"if(VAR_0->debug & FF_FDEBUG_TS)\nav_log(VAR_0, AV_LOG_DEBUG, \"av_read_packet stream=%d, pts=%\"PRId64\", dts=%\"PRId64\", size=%d, duration=%d, flags=%d\\n\",\nst->cur_pkt.stream_index,\nst->cur_pkt.pts,\nst->cur_pkt.dts,\nst->cur_pkt.size,\nst->cur_pkt.duration,\nst->cur_pkt.flags);",
"VAR_0->cur_st = st;",
"st->cur_ptr = st->cur_pkt.data;",
"st->cur_len = st->cur_pkt.size;",
"if (st->need_parsing && !st->parser && !(VAR_0->flags & AVFMT_FLAG_NOPARSE)) {",
"st->parser = av_parser_init(st->codec->codec_id);",
"if (!st->parser) {",
"av_log(VAR_0, AV_LOG_WARNING, \"parser not found for codec \"\n\"%VAR_0, packets or times may be invalid.\\n\",\navcodec_get_name(st->codec->codec_id));",
"st->need_parsing = AVSTREAM_PARSE_NONE;",
"}else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){",
"st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;",
"}else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){",
"st->parser->flags |= PARSER_FLAG_ONCE;",
"}",
"}",
"}",
"}",
"if(VAR_0->debug & FF_FDEBUG_TS)\nav_log(VAR_0, AV_LOG_DEBUG, \"FUNC_0 stream=%d, pts=%\"PRId64\", dts=%\"PRId64\", size=%d, duration=%d, flags=%d\\n\",\nVAR_1->stream_index,\nVAR_1->pts,\nVAR_1->dts,\nVAR_1->size,\nVAR_1->duration,\nVAR_1->flags);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145,
147
],
[
151
],
[
153
],
[
155
],
[
157,
159,
161,
163,
165
],
[
167,
169
],
[
171
],
[
173
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187,
189,
191
],
[
193,
195,
197,
199,
201
],
[
207
],
[
211,
213,
215,
217,
219,
221,
223,
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243,
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267,
269,
271,
273,
275,
277,
279,
281
],
[
285
],
[
287
]
] |
25,653 | void qemu_co_rwlock_unlock(CoRwlock *lock)
{
assert(qemu_in_coroutine());
if (lock->writer) {
lock->writer = false;
qemu_co_queue_restart_all(&lock->queue);
} else {
lock->reader--;
assert(lock->reader >= 0);
/* Wakeup only one waiting writer */
if (!lock->reader) {
qemu_co_queue_next(&lock->queue);
}
}
} | true | qemu | 1b7f01d966f97b7820f3cdd471461cf0799a93cc | void qemu_co_rwlock_unlock(CoRwlock *lock)
{
assert(qemu_in_coroutine());
if (lock->writer) {
lock->writer = false;
qemu_co_queue_restart_all(&lock->queue);
} else {
lock->reader--;
assert(lock->reader >= 0);
if (!lock->reader) {
qemu_co_queue_next(&lock->queue);
}
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(CoRwlock *VAR_0)
{
assert(qemu_in_coroutine());
if (VAR_0->writer) {
VAR_0->writer = false;
qemu_co_queue_restart_all(&VAR_0->queue);
} else {
VAR_0->reader--;
assert(VAR_0->reader >= 0);
if (!VAR_0->reader) {
qemu_co_queue_next(&VAR_0->queue);
}
}
} | [
"void FUNC_0(CoRwlock *VAR_0)\n{",
"assert(qemu_in_coroutine());",
"if (VAR_0->writer) {",
"VAR_0->writer = false;",
"qemu_co_queue_restart_all(&VAR_0->queue);",
"} else {",
"VAR_0->reader--;",
"assert(VAR_0->reader >= 0);",
"if (!VAR_0->reader) {",
"qemu_co_queue_next(&VAR_0->queue);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
]
] |
25,654 | void do_addzeo (void)
{
T1 = T0;
T0 += xer_ca;
if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {
xer_ov = 0;
} else {
xer_so = 1;
xer_ov = 1;
}
if (likely(T0 >= T1)) {
xer_ca = 0;
} else {
xer_ca = 1;
}
}
| true | qemu | d9bce9d99f4656ae0b0127f7472db9067b8f84ab | void do_addzeo (void)
{
T1 = T0;
T0 += xer_ca;
if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {
xer_ov = 0;
} else {
xer_so = 1;
xer_ov = 1;
}
if (likely(T0 >= T1)) {
xer_ca = 0;
} else {
xer_ca = 1;
}
}
| {
"code": [
" xer_ca = 1;",
" T1 = T0;",
" } else {",
" xer_ca = 0;",
" T1 = T0;",
" T1 = T0;",
" xer_ca = 1;",
" } else {",
" xer_ca = 0;",
" xer_ca = 1;",
" } else {",
" T1 = T0;",
" xer_ov = 0;",
" } else {",
" xer_so = 1;",
" xer_ov = 1;",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" xer_ov = 0;",
" } else {",
" xer_so = 1;",
" xer_ov = 1;",
" xer_ov = 0;",
" } else {",
" xer_so = 1;",
" xer_ov = 1;",
"void do_addzeo (void)",
" T0 += xer_ca;",
" if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {",
" if (likely(T0 >= T1)) {",
" xer_ca = 0;",
" } else {",
" xer_so = 1;",
" xer_ca = 0;",
" } else {",
" xer_ca = 1;",
" xer_so = 1;",
" xer_ca = 0;",
" } else {"
],
"line_no": [
27,
5,
13,
23,
5,
5,
27,
13,
23,
27,
13,
5,
11,
13,
15,
17,
23,
13,
27,
11,
13,
15,
17,
11,
13,
15,
17,
1,
7,
9,
21,
23,
13,
15,
23,
13,
27,
15,
23,
13
]
} | void FUNC_0 (void)
{
T1 = T0;
T0 += xer_ca;
if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {
xer_ov = 0;
} else {
xer_so = 1;
xer_ov = 1;
}
if (likely(T0 >= T1)) {
xer_ca = 0;
} else {
xer_ca = 1;
}
}
| [
"void FUNC_0 (void)\n{",
"T1 = T0;",
"T0 += xer_ca;",
"if (likely(!((T1 ^ (-1)) & (T1 ^ T0) & (1 << 31)))) {",
"xer_ov = 0;",
"} else {",
"xer_so = 1;",
"xer_ov = 1;",
"}",
"if (likely(T0 >= T1)) {",
"xer_ca = 0;",
"} else {",
"xer_ca = 1;",
"}",
"}"
] | [
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
25,655 | void ide_atapi_cmd_reply_end(IDEState *s)
{
int byte_count_limit, size, ret;
#ifdef DEBUG_IDE_ATAPI
printf("reply: tx_size=%d elem_tx_size=%d index=%d\n",
s->packet_transfer_size,
s->elementary_transfer_size,
s->io_buffer_index);
#endif
if (s->packet_transfer_size <= 0) {
/* end of transfer */
ide_atapi_cmd_ok(s);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
} else {
/* see if a new sector must be read */
if (s->lba != -1 && s->io_buffer_index >= s->cd_sector_size) {
ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size);
if (ret < 0) {
ide_atapi_io_error(s, ret);
return;
}
s->lba++;
s->io_buffer_index = 0;
}
if (s->elementary_transfer_size > 0) {
/* there are some data left to transmit in this elementary
transfer */
size = s->cd_sector_size - s->io_buffer_index;
if (size > s->elementary_transfer_size)
size = s->elementary_transfer_size;
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
} else {
/* a new transfer is needed */
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO;
byte_count_limit = atapi_byte_count_limit(s);
#ifdef DEBUG_IDE_ATAPI
printf("byte_count_limit=%d\n", byte_count_limit);
#endif
size = s->packet_transfer_size;
if (size > byte_count_limit) {
/* byte count limit must be even if this case */
if (byte_count_limit & 1)
byte_count_limit--;
size = byte_count_limit;
}
s->lcyl = size;
s->hcyl = size >> 8;
s->elementary_transfer_size = size;
/* we cannot transmit more than one sector at a time */
if (s->lba != -1) {
if (size > (s->cd_sector_size - s->io_buffer_index))
size = (s->cd_sector_size - s->io_buffer_index);
}
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
}
}
}
| true | qemu | 5f81724d80a1492c73d329242663962139db739b | void ide_atapi_cmd_reply_end(IDEState *s)
{
int byte_count_limit, size, ret;
#ifdef DEBUG_IDE_ATAPI
printf("reply: tx_size=%d elem_tx_size=%d index=%d\n",
s->packet_transfer_size,
s->elementary_transfer_size,
s->io_buffer_index);
#endif
if (s->packet_transfer_size <= 0) {
ide_atapi_cmd_ok(s);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
} else {
if (s->lba != -1 && s->io_buffer_index >= s->cd_sector_size) {
ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size);
if (ret < 0) {
ide_atapi_io_error(s, ret);
return;
}
s->lba++;
s->io_buffer_index = 0;
}
if (s->elementary_transfer_size > 0) {
size = s->cd_sector_size - s->io_buffer_index;
if (size > s->elementary_transfer_size)
size = s->elementary_transfer_size;
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
} else {
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO;
byte_count_limit = atapi_byte_count_limit(s);
#ifdef DEBUG_IDE_ATAPI
printf("byte_count_limit=%d\n", byte_count_limit);
#endif
size = s->packet_transfer_size;
if (size > byte_count_limit) {
if (byte_count_limit & 1)
byte_count_limit--;
size = byte_count_limit;
}
s->lcyl = size;
s->hcyl = size >> 8;
s->elementary_transfer_size = size;
if (s->lba != -1) {
if (size > (s->cd_sector_size - s->io_buffer_index))
size = (s->cd_sector_size - s->io_buffer_index);
}
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
}
}
}
| {
"code": [
" printf(\"status=0x%x\\n\", s->status);",
" ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size);",
" if (ret < 0) {",
" ide_atapi_io_error(s, ret);",
" s->lba++;",
" s->io_buffer_index = 0;"
],
"line_no": [
29,
39,
41,
43,
49,
51
]
} | void FUNC_0(IDEState *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
#ifdef DEBUG_IDE_ATAPI
printf("reply: tx_size=%d elem_tx_size=%d index=%d\n",
VAR_0->packet_transfer_size,
VAR_0->elementary_transfer_size,
VAR_0->io_buffer_index);
#endif
if (VAR_0->packet_transfer_size <= 0) {
ide_atapi_cmd_ok(VAR_0);
ide_set_irq(VAR_0->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", VAR_0->status);
#endif
} else {
if (VAR_0->lba != -1 && VAR_0->io_buffer_index >= VAR_0->cd_sector_size) {
VAR_3 = cd_read_sector(VAR_0, VAR_0->lba, VAR_0->io_buffer, VAR_0->cd_sector_size);
if (VAR_3 < 0) {
ide_atapi_io_error(VAR_0, VAR_3);
return;
}
VAR_0->lba++;
VAR_0->io_buffer_index = 0;
}
if (VAR_0->elementary_transfer_size > 0) {
VAR_2 = VAR_0->cd_sector_size - VAR_0->io_buffer_index;
if (VAR_2 > VAR_0->elementary_transfer_size)
VAR_2 = VAR_0->elementary_transfer_size;
VAR_0->packet_transfer_size -= VAR_2;
VAR_0->elementary_transfer_size -= VAR_2;
VAR_0->io_buffer_index += VAR_2;
ide_transfer_start(VAR_0, VAR_0->io_buffer + VAR_0->io_buffer_index - VAR_2,
VAR_2, FUNC_0);
} else {
VAR_0->nsector = (VAR_0->nsector & ~7) | ATAPI_INT_REASON_IO;
VAR_1 = atapi_byte_count_limit(VAR_0);
#ifdef DEBUG_IDE_ATAPI
printf("VAR_1=%d\n", VAR_1);
#endif
VAR_2 = VAR_0->packet_transfer_size;
if (VAR_2 > VAR_1) {
if (VAR_1 & 1)
VAR_1--;
VAR_2 = VAR_1;
}
VAR_0->lcyl = VAR_2;
VAR_0->hcyl = VAR_2 >> 8;
VAR_0->elementary_transfer_size = VAR_2;
if (VAR_0->lba != -1) {
if (VAR_2 > (VAR_0->cd_sector_size - VAR_0->io_buffer_index))
VAR_2 = (VAR_0->cd_sector_size - VAR_0->io_buffer_index);
}
VAR_0->packet_transfer_size -= VAR_2;
VAR_0->elementary_transfer_size -= VAR_2;
VAR_0->io_buffer_index += VAR_2;
ide_transfer_start(VAR_0, VAR_0->io_buffer + VAR_0->io_buffer_index - VAR_2,
VAR_2, FUNC_0);
ide_set_irq(VAR_0->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", VAR_0->status);
#endif
}
}
}
| [
"void FUNC_0(IDEState *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"#ifdef DEBUG_IDE_ATAPI\nprintf(\"reply: tx_size=%d elem_tx_size=%d index=%d\\n\",\nVAR_0->packet_transfer_size,\nVAR_0->elementary_transfer_size,\nVAR_0->io_buffer_index);",
"#endif\nif (VAR_0->packet_transfer_size <= 0) {",
"ide_atapi_cmd_ok(VAR_0);",
"ide_set_irq(VAR_0->bus);",
"#ifdef DEBUG_IDE_ATAPI\nprintf(\"status=0x%x\\n\", VAR_0->status);",
"#endif\n} else {",
"if (VAR_0->lba != -1 && VAR_0->io_buffer_index >= VAR_0->cd_sector_size) {",
"VAR_3 = cd_read_sector(VAR_0, VAR_0->lba, VAR_0->io_buffer, VAR_0->cd_sector_size);",
"if (VAR_3 < 0) {",
"ide_atapi_io_error(VAR_0, VAR_3);",
"return;",
"}",
"VAR_0->lba++;",
"VAR_0->io_buffer_index = 0;",
"}",
"if (VAR_0->elementary_transfer_size > 0) {",
"VAR_2 = VAR_0->cd_sector_size - VAR_0->io_buffer_index;",
"if (VAR_2 > VAR_0->elementary_transfer_size)\nVAR_2 = VAR_0->elementary_transfer_size;",
"VAR_0->packet_transfer_size -= VAR_2;",
"VAR_0->elementary_transfer_size -= VAR_2;",
"VAR_0->io_buffer_index += VAR_2;",
"ide_transfer_start(VAR_0, VAR_0->io_buffer + VAR_0->io_buffer_index - VAR_2,\nVAR_2, FUNC_0);",
"} else {",
"VAR_0->nsector = (VAR_0->nsector & ~7) | ATAPI_INT_REASON_IO;",
"VAR_1 = atapi_byte_count_limit(VAR_0);",
"#ifdef DEBUG_IDE_ATAPI\nprintf(\"VAR_1=%d\\n\", VAR_1);",
"#endif\nVAR_2 = VAR_0->packet_transfer_size;",
"if (VAR_2 > VAR_1) {",
"if (VAR_1 & 1)\nVAR_1--;",
"VAR_2 = VAR_1;",
"}",
"VAR_0->lcyl = VAR_2;",
"VAR_0->hcyl = VAR_2 >> 8;",
"VAR_0->elementary_transfer_size = VAR_2;",
"if (VAR_0->lba != -1) {",
"if (VAR_2 > (VAR_0->cd_sector_size - VAR_0->io_buffer_index))\nVAR_2 = (VAR_0->cd_sector_size - VAR_0->io_buffer_index);",
"}",
"VAR_0->packet_transfer_size -= VAR_2;",
"VAR_0->elementary_transfer_size -= VAR_2;",
"VAR_0->io_buffer_index += VAR_2;",
"ide_transfer_start(VAR_0, VAR_0->io_buffer + VAR_0->io_buffer_index - VAR_2,\nVAR_2, FUNC_0);",
"ide_set_irq(VAR_0->bus);",
"#ifdef DEBUG_IDE_ATAPI\nprintf(\"status=0x%x\\n\", VAR_0->status);",
"#endif\n}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11,
13,
15
],
[
17,
19
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85,
87
],
[
89,
91
],
[
93
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
143
]
] |
25,656 | static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
unsigned int substr, unsigned int channel,
unsigned int filter)
{
SubStream *s = &m->substream[substr];
FilterParams *fp = &s->channel_params[channel].filter_params[filter];
const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char fchar = filter ? 'I' : 'F';
int i, order;
// Filter is 0 for FIR, 1 for IIR.
av_assert0(filter < 2);
if (m->filter_changed[channel][filter]++ > 1) {
av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
return AVERROR_INVALIDDATA;
}
order = get_bits(gbp, 4);
if (order > max_order) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter order %d is greater than maximum %d.\n",
fchar, order, max_order);
return AVERROR_INVALIDDATA;
}
fp->order = order;
if (order > 0) {
int32_t *fcoeff = s->channel_params[channel].coeff[filter];
int coeff_bits, coeff_shift;
fp->shift = get_bits(gbp, 4);
coeff_bits = get_bits(gbp, 5);
coeff_shift = get_bits(gbp, 3);
if (coeff_bits < 1 || coeff_bits > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter coeff_bits must be between 1 and 16.\n",
fchar);
return AVERROR_INVALIDDATA;
}
if (coeff_bits + coeff_shift > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
fchar);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < order; i++)
fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift);
if (get_bits1(gbp)) {
int state_bits, state_shift;
if (filter == FIR) {
av_log(m->avctx, AV_LOG_ERROR,
"FIR filter has state data specified.\n");
return AVERROR_INVALIDDATA;
}
state_bits = get_bits(gbp, 4);
state_shift = get_bits(gbp, 4);
/* TODO: Check validity of state data. */
for (i = 0; i < order; i++)
fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;
}
}
return 0;
}
| true | FFmpeg | 552adf1dd3a38fb7a1a6109dd2b517d63290f20e | static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
unsigned int substr, unsigned int channel,
unsigned int filter)
{
SubStream *s = &m->substream[substr];
FilterParams *fp = &s->channel_params[channel].filter_params[filter];
const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char fchar = filter ? 'I' : 'F';
int i, order;
av_assert0(filter < 2);
if (m->filter_changed[channel][filter]++ > 1) {
av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
return AVERROR_INVALIDDATA;
}
order = get_bits(gbp, 4);
if (order > max_order) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter order %d is greater than maximum %d.\n",
fchar, order, max_order);
return AVERROR_INVALIDDATA;
}
fp->order = order;
if (order > 0) {
int32_t *fcoeff = s->channel_params[channel].coeff[filter];
int coeff_bits, coeff_shift;
fp->shift = get_bits(gbp, 4);
coeff_bits = get_bits(gbp, 5);
coeff_shift = get_bits(gbp, 3);
if (coeff_bits < 1 || coeff_bits > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"%cIR filter coeff_bits must be between 1 and 16.\n",
fchar);
return AVERROR_INVALIDDATA;
}
if (coeff_bits + coeff_shift > 16) {
av_log(m->avctx, AV_LOG_ERROR,
"Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
fchar);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < order; i++)
fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift);
if (get_bits1(gbp)) {
int state_bits, state_shift;
if (filter == FIR) {
av_log(m->avctx, AV_LOG_ERROR,
"FIR filter has state data specified.\n");
return AVERROR_INVALIDDATA;
}
state_bits = get_bits(gbp, 4);
state_shift = get_bits(gbp, 4);
for (i = 0; i < order; i++)
fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;
}
}
return 0;
}
| {
"code": [
" fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;"
],
"line_no": [
133
]
} | static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,
unsigned int VAR_2, unsigned int VAR_3,
unsigned int VAR_4)
{
SubStream *s = &VAR_0->substream[VAR_2];
FilterParams *fp = &s->channel_params[VAR_3].filter_params[VAR_4];
const int VAR_5 = VAR_4 ? MAX_IIR_ORDER : MAX_FIR_ORDER;
const char VAR_6 = VAR_4 ? 'I' : 'F';
int VAR_7, VAR_8;
av_assert0(VAR_4 < 2);
if (VAR_0->filter_changed[VAR_3][VAR_4]++ > 1) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
return AVERROR_INVALIDDATA;
}
VAR_8 = get_bits(VAR_1, 4);
if (VAR_8 > VAR_5) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"%cIR VAR_4 VAR_8 %d is greater than maximum %d.\n",
VAR_6, VAR_8, VAR_5);
return AVERROR_INVALIDDATA;
}
fp->VAR_8 = VAR_8;
if (VAR_8 > 0) {
int32_t *fcoeff = s->channel_params[VAR_3].coeff[VAR_4];
int VAR_9, VAR_10;
fp->shift = get_bits(VAR_1, 4);
VAR_9 = get_bits(VAR_1, 5);
VAR_10 = get_bits(VAR_1, 3);
if (VAR_9 < 1 || VAR_9 > 16) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"%cIR VAR_4 VAR_9 must be between 1 and 16.\n",
VAR_6);
return AVERROR_INVALIDDATA;
}
if (VAR_9 + VAR_10 > 16) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Sum of VAR_9 and VAR_10 for %cIR VAR_4 must be 16 or less.\n",
VAR_6);
return AVERROR_INVALIDDATA;
}
for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)
fcoeff[VAR_7] = get_sbits(VAR_1, VAR_9) * (1 << VAR_10);
if (get_bits1(VAR_1)) {
int VAR_11, VAR_12;
if (VAR_4 == FIR) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"FIR VAR_4 has state data specified.\n");
return AVERROR_INVALIDDATA;
}
VAR_11 = get_bits(VAR_1, 4);
VAR_12 = get_bits(VAR_1, 4);
for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)
fp->state[VAR_7] = VAR_11 ? get_sbits(VAR_1, VAR_11) << VAR_12 : 0;
}
}
return 0;
}
| [
"static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,\nunsigned int VAR_2, unsigned int VAR_3,\nunsigned int VAR_4)\n{",
"SubStream *s = &VAR_0->substream[VAR_2];",
"FilterParams *fp = &s->channel_params[VAR_3].filter_params[VAR_4];",
"const int VAR_5 = VAR_4 ? MAX_IIR_ORDER : MAX_FIR_ORDER;",
"const char VAR_6 = VAR_4 ? 'I' : 'F';",
"int VAR_7, VAR_8;",
"av_assert0(VAR_4 < 2);",
"if (VAR_0->filter_changed[VAR_3][VAR_4]++ > 1) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Filters may change only once per access unit.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_8 = get_bits(VAR_1, 4);",
"if (VAR_8 > VAR_5) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"%cIR VAR_4 VAR_8 %d is greater than maximum %d.\\n\",\nVAR_6, VAR_8, VAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"fp->VAR_8 = VAR_8;",
"if (VAR_8 > 0) {",
"int32_t *fcoeff = s->channel_params[VAR_3].coeff[VAR_4];",
"int VAR_9, VAR_10;",
"fp->shift = get_bits(VAR_1, 4);",
"VAR_9 = get_bits(VAR_1, 5);",
"VAR_10 = get_bits(VAR_1, 3);",
"if (VAR_9 < 1 || VAR_9 > 16) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"%cIR VAR_4 VAR_9 must be between 1 and 16.\\n\",\nVAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_9 + VAR_10 > 16) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Sum of VAR_9 and VAR_10 for %cIR VAR_4 must be 16 or less.\\n\",\nVAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)",
"fcoeff[VAR_7] = get_sbits(VAR_1, VAR_9) * (1 << VAR_10);",
"if (get_bits1(VAR_1)) {",
"int VAR_11, VAR_12;",
"if (VAR_4 == FIR) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"FIR VAR_4 has state data specified.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_11 = get_bits(VAR_1, 4);",
"VAR_12 = get_bits(VAR_1, 4);",
"for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)",
"fp->state[VAR_7] = VAR_11 ? get_sbits(VAR_1, VAR_11) << VAR_12 : 0;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81
],
[
83
],
[
85,
87,
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
103
],
[
105
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
]
] |
25,657 | static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
IlContext *il = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *out;
int ret;
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out) {
avfilter_unref_bufferp(&inpicref);
return AVERROR(ENOMEM);
}
avfilter_copy_buffer_ref_props(out, inpicref);
interleave(out->data[0], inpicref->data[0],
il->width, inlink->h,
out->linesize[0], inpicref->linesize[0],
il->luma_mode, il->luma_swap);
if (il->nb_planes > 2) {
interleave(out->data[1], inpicref->data[1],
il->chroma_width, il->chroma_height,
out->linesize[1], inpicref->linesize[1],
il->chroma_mode, il->chroma_swap);
interleave(out->data[2], inpicref->data[2],
il->chroma_width, il->chroma_height,
out->linesize[2], inpicref->linesize[2],
il->chroma_mode, il->chroma_swap);
}
if (il->nb_planes == 2 && il->nb_planes == 4) {
int comp = il->nb_planes - 1;
interleave(out->data[comp], inpicref->data[comp],
il->width, inlink->h,
out->linesize[comp], inpicref->linesize[comp],
il->alpha_mode, il->alpha_swap);
}
ret = ff_filter_frame(outlink, out);
avfilter_unref_bufferp(&inpicref);
return ret;
}
| true | FFmpeg | 63a99622876ff79a07862167f243a7d3823b7315 | static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
IlContext *il = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *out;
int ret;
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out) {
avfilter_unref_bufferp(&inpicref);
return AVERROR(ENOMEM);
}
avfilter_copy_buffer_ref_props(out, inpicref);
interleave(out->data[0], inpicref->data[0],
il->width, inlink->h,
out->linesize[0], inpicref->linesize[0],
il->luma_mode, il->luma_swap);
if (il->nb_planes > 2) {
interleave(out->data[1], inpicref->data[1],
il->chroma_width, il->chroma_height,
out->linesize[1], inpicref->linesize[1],
il->chroma_mode, il->chroma_swap);
interleave(out->data[2], inpicref->data[2],
il->chroma_width, il->chroma_height,
out->linesize[2], inpicref->linesize[2],
il->chroma_mode, il->chroma_swap);
}
if (il->nb_planes == 2 && il->nb_planes == 4) {
int comp = il->nb_planes - 1;
interleave(out->data[comp], inpicref->data[comp],
il->width, inlink->h,
out->linesize[comp], inpicref->linesize[comp],
il->alpha_mode, il->alpha_swap);
}
ret = ff_filter_frame(outlink, out);
avfilter_unref_bufferp(&inpicref);
return ret;
}
| {
"code": [
" int ret;",
" il->width, inlink->h,",
" if (il->nb_planes > 2) {",
" interleave(out->data[1], inpicref->data[1],",
" il->chroma_width, il->chroma_height,",
" out->linesize[1], inpicref->linesize[1],",
" il->chroma_mode, il->chroma_swap);",
" interleave(out->data[2], inpicref->data[2],",
" il->chroma_width, il->chroma_height,",
" out->linesize[2], inpicref->linesize[2],",
" if (il->nb_planes == 2 && il->nb_planes == 4) {",
" il->width, inlink->h,"
],
"line_no": [
11,
31,
39,
41,
43,
45,
47,
49,
43,
53,
59,
65
]
} | static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)
{
IlContext *il = VAR_0->dst->priv;
AVFilterLink *outlink = VAR_0->dst->outputs[0];
AVFilterBufferRef *out;
int VAR_2;
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!out) {
avfilter_unref_bufferp(&VAR_1);
return AVERROR(ENOMEM);
}
avfilter_copy_buffer_ref_props(out, VAR_1);
interleave(out->data[0], VAR_1->data[0],
il->width, VAR_0->h,
out->linesize[0], VAR_1->linesize[0],
il->luma_mode, il->luma_swap);
if (il->nb_planes > 2) {
interleave(out->data[1], VAR_1->data[1],
il->chroma_width, il->chroma_height,
out->linesize[1], VAR_1->linesize[1],
il->chroma_mode, il->chroma_swap);
interleave(out->data[2], VAR_1->data[2],
il->chroma_width, il->chroma_height,
out->linesize[2], VAR_1->linesize[2],
il->chroma_mode, il->chroma_swap);
}
if (il->nb_planes == 2 && il->nb_planes == 4) {
int VAR_3 = il->nb_planes - 1;
interleave(out->data[VAR_3], VAR_1->data[VAR_3],
il->width, VAR_0->h,
out->linesize[VAR_3], VAR_1->linesize[VAR_3],
il->alpha_mode, il->alpha_swap);
}
VAR_2 = ff_filter_frame(outlink, out);
avfilter_unref_bufferp(&VAR_1);
return VAR_2;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{",
"IlContext *il = VAR_0->dst->priv;",
"AVFilterLink *outlink = VAR_0->dst->outputs[0];",
"AVFilterBufferRef *out;",
"int VAR_2;",
"out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);",
"if (!out) {",
"avfilter_unref_bufferp(&VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"avfilter_copy_buffer_ref_props(out, VAR_1);",
"interleave(out->data[0], VAR_1->data[0],\nil->width, VAR_0->h,\nout->linesize[0], VAR_1->linesize[0],\nil->luma_mode, il->luma_swap);",
"if (il->nb_planes > 2) {",
"interleave(out->data[1], VAR_1->data[1],\nil->chroma_width, il->chroma_height,\nout->linesize[1], VAR_1->linesize[1],\nil->chroma_mode, il->chroma_swap);",
"interleave(out->data[2], VAR_1->data[2],\nil->chroma_width, il->chroma_height,\nout->linesize[2], VAR_1->linesize[2],\nil->chroma_mode, il->chroma_swap);",
"}",
"if (il->nb_planes == 2 && il->nb_planes == 4) {",
"int VAR_3 = il->nb_planes - 1;",
"interleave(out->data[VAR_3], VAR_1->data[VAR_3],\nil->width, VAR_0->h,\nout->linesize[VAR_3], VAR_1->linesize[VAR_3],\nil->alpha_mode, il->alpha_swap);",
"}",
"VAR_2 = ff_filter_frame(outlink, out);",
"avfilter_unref_bufferp(&VAR_1);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
1,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31,
33,
35
],
[
39
],
[
41,
43,
45,
47
],
[
49,
51,
53,
55
],
[
57
],
[
59
],
[
61
],
[
63,
65,
67,
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
]
] |
25,658 | decode_lpc(WmallDecodeCtx *s)
{
int ch, i, cbits;
s->lpc_order = get_bits(&s->gb, 5) + 1;
s->lpc_scaling = get_bits(&s->gb, 4);
s->lpc_intbits = get_bits(&s->gb, 3) + 1;
cbits = s->lpc_scaling + s->lpc_intbits;
for(ch = 0; ch < s->num_channels; ch++) {
for(i = 0; i < s->lpc_order; i++) {
s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
}
}
}
| true | FFmpeg | dae7ff04160901a30a35af05f2f149b289c4f0b1 | decode_lpc(WmallDecodeCtx *s)
{
int ch, i, cbits;
s->lpc_order = get_bits(&s->gb, 5) + 1;
s->lpc_scaling = get_bits(&s->gb, 4);
s->lpc_intbits = get_bits(&s->gb, 3) + 1;
cbits = s->lpc_scaling + s->lpc_intbits;
for(ch = 0; ch < s->num_channels; ch++) {
for(i = 0; i < s->lpc_order; i++) {
s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);
}
}
}
| {
"code": [
"\tfor(i = 0; i < s->lpc_order; i++) {",
"\t s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits);"
],
"line_no": [
17,
19
]
} | FUNC_0(WmallDecodeCtx *VAR_0)
{
int VAR_1, VAR_2, VAR_3;
VAR_0->lpc_order = get_bits(&VAR_0->gb, 5) + 1;
VAR_0->lpc_scaling = get_bits(&VAR_0->gb, 4);
VAR_0->lpc_intbits = get_bits(&VAR_0->gb, 3) + 1;
VAR_3 = VAR_0->lpc_scaling + VAR_0->lpc_intbits;
for(VAR_1 = 0; VAR_1 < VAR_0->num_channels; VAR_1++) {
for(VAR_2 = 0; VAR_2 < VAR_0->lpc_order; VAR_2++) {
VAR_0->lpc_coefs[VAR_1][VAR_2] = get_sbits(&VAR_0->gb, VAR_3);
}
}
}
| [
"FUNC_0(WmallDecodeCtx *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3;",
"VAR_0->lpc_order = get_bits(&VAR_0->gb, 5) + 1;",
"VAR_0->lpc_scaling = get_bits(&VAR_0->gb, 4);",
"VAR_0->lpc_intbits = get_bits(&VAR_0->gb, 3) + 1;",
"VAR_3 = VAR_0->lpc_scaling + VAR_0->lpc_intbits;",
"for(VAR_1 = 0; VAR_1 < VAR_0->num_channels; VAR_1++) {",
"for(VAR_2 = 0; VAR_2 < VAR_0->lpc_order; VAR_2++) {",
"VAR_0->lpc_coefs[VAR_1][VAR_2] = get_sbits(&VAR_0->gb, VAR_3);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
25,659 | static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
{
FrameRateContext *s = ctx->priv;
double ret = 0;
ff_dlog(ctx, "get_scene_score()\n");
if (crnt->height == next->height &&
crnt->width == next->width) {
int64_t sad;
double mafd, diff;
ff_dlog(ctx, "get_scene_score() process\n");
if (s->bitdepth == 8)
sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->height);
else
sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] >> 1, (const uint16_t*)next->data[0], next->linesize[0] >> 1, crnt->height);
mafd = (double)sad * 100.0 / (crnt->height * crnt->width) / (1 << s->bitdepth);
diff = fabs(mafd - s->prev_mafd);
ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
s->prev_mafd = mafd;
}
ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
return ret;
}
| true | FFmpeg | e403e4bdbea08af0c4a068eb560b577d1b64cf7a | static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next)
{
FrameRateContext *s = ctx->priv;
double ret = 0;
ff_dlog(ctx, "get_scene_score()\n");
if (crnt->height == next->height &&
crnt->width == next->width) {
int64_t sad;
double mafd, diff;
ff_dlog(ctx, "get_scene_score() process\n");
if (s->bitdepth == 8)
sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->height);
else
sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] >> 1, (const uint16_t*)next->data[0], next->linesize[0] >> 1, crnt->height);
mafd = (double)sad * 100.0 / (crnt->height * crnt->width) / (1 << s->bitdepth);
diff = fabs(mafd - s->prev_mafd);
ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
s->prev_mafd = mafd;
}
ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
return ret;
}
| {
"code": [
" sad = scene_sad8(s, crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->height);",
" sad = scene_sad16(s, (const uint16_t*)crnt->data[0], crnt->linesize[0] >> 1, (const uint16_t*)next->data[0], next->linesize[0] >> 1, crnt->height);",
" mafd = (double)sad * 100.0 / (crnt->height * crnt->width) / (1 << s->bitdepth);"
],
"line_no": [
29,
33,
37
]
} | static double FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2)
{
FrameRateContext *s = VAR_0->priv;
double VAR_3 = 0;
ff_dlog(VAR_0, "FUNC_0()\n");
if (VAR_1->height == VAR_2->height &&
VAR_1->width == VAR_2->width) {
int64_t sad;
double VAR_4, VAR_5;
ff_dlog(VAR_0, "FUNC_0() process\n");
if (s->bitdepth == 8)
sad = scene_sad8(s, VAR_1->data[0], VAR_1->linesize[0], VAR_2->data[0], VAR_2->linesize[0], VAR_1->height);
else
sad = scene_sad16(s, (const uint16_t*)VAR_1->data[0], VAR_1->linesize[0] >> 1, (const uint16_t*)VAR_2->data[0], VAR_2->linesize[0] >> 1, VAR_1->height);
VAR_4 = (double)sad * 100.0 / (VAR_1->height * VAR_1->width) / (1 << s->bitdepth);
VAR_5 = fabs(VAR_4 - s->prev_mafd);
VAR_3 = av_clipf(FFMIN(VAR_4, VAR_5), 0, 100.0);
s->prev_mafd = VAR_4;
}
ff_dlog(VAR_0, "FUNC_0() result is:%f\n", VAR_3);
return VAR_3;
}
| [
"static double FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2)\n{",
"FrameRateContext *s = VAR_0->priv;",
"double VAR_3 = 0;",
"ff_dlog(VAR_0, \"FUNC_0()\\n\");",
"if (VAR_1->height == VAR_2->height &&\nVAR_1->width == VAR_2->width) {",
"int64_t sad;",
"double VAR_4, VAR_5;",
"ff_dlog(VAR_0, \"FUNC_0() process\\n\");",
"if (s->bitdepth == 8)\nsad = scene_sad8(s, VAR_1->data[0], VAR_1->linesize[0], VAR_2->data[0], VAR_2->linesize[0], VAR_1->height);",
"else\nsad = scene_sad16(s, (const uint16_t*)VAR_1->data[0], VAR_1->linesize[0] >> 1, (const uint16_t*)VAR_2->data[0], VAR_2->linesize[0] >> 1, VAR_1->height);",
"VAR_4 = (double)sad * 100.0 / (VAR_1->height * VAR_1->width) / (1 << s->bitdepth);",
"VAR_5 = fabs(VAR_4 - s->prev_mafd);",
"VAR_3 = av_clipf(FFMIN(VAR_4, VAR_5), 0, 100.0);",
"s->prev_mafd = VAR_4;",
"}",
"ff_dlog(VAR_0, \"FUNC_0() result is:%f\\n\", VAR_3);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
25,660 | int main(int argc,char* argv[]){
int i, j;
uint64_t sse=0;
uint64_t dev;
FILE *f[2];
uint8_t buf[2][SIZE];
uint64_t psnr;
int len= argc<4 ? 1 : atoi(argv[3]);
int64_t max= (1<<(8*len))-1;
int shift= argc<5 ? 0 : atoi(argv[4]);
int skip_bytes = argc<6 ? 0 : atoi(argv[5]);
if(argc<3){
printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n");
printf("For WAV files use the following:\n");
printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n");
return -1;
}
f[0]= fopen(argv[1], "rb");
f[1]= fopen(argv[2], "rb");
if(!f[0] || !f[1]){
fprintf(stderr, "Could not open input files.\n");
return -1;
}
fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET);
fseek(f[0],skip_bytes,SEEK_CUR);
fseek(f[1],skip_bytes,SEEK_CUR);
for(i=0;;){
if( fread(buf[0], SIZE, 1, f[0]) != 1) break;
if( fread(buf[1], SIZE, 1, f[1]) != 1) break;
for(j=0; j<SIZE; i++,j++){
int64_t a= buf[0][j];
int64_t b= buf[1][j];
if(len==2){
a= (int16_t)(a | (buf[0][++j]<<8));
b= (int16_t)(b | (buf[1][ j]<<8));
}
sse += (a-b) * (a-b);
}
}
if(!i) i=1;
dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i );
if(sse)
psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32);
else
psnr= 100*F-1; //floating point free infinity :)
printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n",
(int)(dev/F), (int)(dev%F),
(int)(psnr/F), (int)(psnr%F),
i*len);
return 0;
}
| false | FFmpeg | 1e90317b655699a2877478e335e998fb5e4b79d8 | int main(int argc,char* argv[]){
int i, j;
uint64_t sse=0;
uint64_t dev;
FILE *f[2];
uint8_t buf[2][SIZE];
uint64_t psnr;
int len= argc<4 ? 1 : atoi(argv[3]);
int64_t max= (1<<(8*len))-1;
int shift= argc<5 ? 0 : atoi(argv[4]);
int skip_bytes = argc<6 ? 0 : atoi(argv[5]);
if(argc<3){
printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n");
printf("For WAV files use the following:\n");
printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n");
return -1;
}
f[0]= fopen(argv[1], "rb");
f[1]= fopen(argv[2], "rb");
if(!f[0] || !f[1]){
fprintf(stderr, "Could not open input files.\n");
return -1;
}
fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET);
fseek(f[0],skip_bytes,SEEK_CUR);
fseek(f[1],skip_bytes,SEEK_CUR);
for(i=0;;){
if( fread(buf[0], SIZE, 1, f[0]) != 1) break;
if( fread(buf[1], SIZE, 1, f[1]) != 1) break;
for(j=0; j<SIZE; i++,j++){
int64_t a= buf[0][j];
int64_t b= buf[1][j];
if(len==2){
a= (int16_t)(a | (buf[0][++j]<<8));
b= (int16_t)(b | (buf[1][ j]<<8));
}
sse += (a-b) * (a-b);
}
}
if(!i) i=1;
dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i );
if(sse)
psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32);
else
psnr= 100*F-1;
printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n",
(int)(dev/F), (int)(dev%F),
(int)(psnr/F), (int)(psnr%F),
i*len);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0,char* VAR_1[]){
int VAR_2, VAR_3;
uint64_t sse=0;
uint64_t dev;
FILE *f[2];
uint8_t buf[2][SIZE];
uint64_t psnr;
int VAR_4= VAR_0<4 ? 1 : atoi(VAR_1[3]);
int64_t max= (1<<(8*VAR_4))-1;
int VAR_5= VAR_0<5 ? 0 : atoi(VAR_1[4]);
int VAR_6 = VAR_0<6 ? 0 : atoi(VAR_1[5]);
if(VAR_0<3){
printf("tiny_psnr <file1> <file2> [<elem size> [<VAR_5> [<skip bytes>]]]\n");
printf("For WAV files use the following:\n");
printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n");
return -1;
}
f[0]= fopen(VAR_1[1], "rb");
f[1]= fopen(VAR_1[2], "rb");
if(!f[0] || !f[1]){
fprintf(stderr, "Could not open input files.\n");
return -1;
}
fseek(f[VAR_5<0], VAR_5 < 0 ? -VAR_5 : VAR_5, SEEK_SET);
fseek(f[0],VAR_6,SEEK_CUR);
fseek(f[1],VAR_6,SEEK_CUR);
for(VAR_2=0;;){
if( fread(buf[0], SIZE, 1, f[0]) != 1) break;
if( fread(buf[1], SIZE, 1, f[1]) != 1) break;
for(VAR_3=0; VAR_3<SIZE; VAR_2++,VAR_3++){
int64_t a= buf[0][VAR_3];
int64_t b= buf[1][VAR_3];
if(VAR_4==2){
a= (int16_t)(a | (buf[0][++VAR_3]<<8));
b= (int16_t)(b | (buf[1][ VAR_3]<<8));
}
sse += (a-b) * (a-b);
}
}
if(!VAR_2) VAR_2=1;
dev= int_sqrt( ((sse/VAR_2)*F*F) + (((sse%VAR_2)*F*F) + VAR_2/2)/VAR_2 );
if(sse)
psnr= ((2*log16(max<<16) + log16(VAR_2) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32);
else
psnr= 100*F-1;
printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n",
(int)(dev/F), (int)(dev%F),
(int)(psnr/F), (int)(psnr%F),
VAR_2*VAR_4);
return 0;
}
| [
"int FUNC_0(int VAR_0,char* VAR_1[]){",
"int VAR_2, VAR_3;",
"uint64_t sse=0;",
"uint64_t dev;",
"FILE *f[2];",
"uint8_t buf[2][SIZE];",
"uint64_t psnr;",
"int VAR_4= VAR_0<4 ? 1 : atoi(VAR_1[3]);",
"int64_t max= (1<<(8*VAR_4))-1;",
"int VAR_5= VAR_0<5 ? 0 : atoi(VAR_1[4]);",
"int VAR_6 = VAR_0<6 ? 0 : atoi(VAR_1[5]);",
"if(VAR_0<3){",
"printf(\"tiny_psnr <file1> <file2> [<elem size> [<VAR_5> [<skip bytes>]]]\\n\");",
"printf(\"For WAV files use the following:\\n\");",
"printf(\"./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\\n\");",
"return -1;",
"}",
"f[0]= fopen(VAR_1[1], \"rb\");",
"f[1]= fopen(VAR_1[2], \"rb\");",
"if(!f[0] || !f[1]){",
"fprintf(stderr, \"Could not open input files.\\n\");",
"return -1;",
"}",
"fseek(f[VAR_5<0], VAR_5 < 0 ? -VAR_5 : VAR_5, SEEK_SET);",
"fseek(f[0],VAR_6,SEEK_CUR);",
"fseek(f[1],VAR_6,SEEK_CUR);",
"for(VAR_2=0;;){",
"if( fread(buf[0], SIZE, 1, f[0]) != 1) break;",
"if( fread(buf[1], SIZE, 1, f[1]) != 1) break;",
"for(VAR_3=0; VAR_3<SIZE; VAR_2++,VAR_3++){",
"int64_t a= buf[0][VAR_3];",
"int64_t b= buf[1][VAR_3];",
"if(VAR_4==2){",
"a= (int16_t)(a | (buf[0][++VAR_3]<<8));",
"b= (int16_t)(b | (buf[1][ VAR_3]<<8));",
"}",
"sse += (a-b) * (a-b);",
"}",
"}",
"if(!VAR_2) VAR_2=1;",
"dev= int_sqrt( ((sse/VAR_2)*F*F) + (((sse%VAR_2)*F*F) + VAR_2/2)/VAR_2 );",
"if(sse)\npsnr= ((2*log16(max<<16) + log16(VAR_2) - log16(sse))*284619LL*F + (1<<31)) / (1LL<<32);",
"else\npsnr= 100*F-1;",
"printf(\"stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\\n\",\n(int)(dev/F), (int)(dev%F),\n(int)(psnr/F), (int)(psnr%F),\nVAR_2*VAR_4);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95,
97
],
[
99,
101
],
[
105,
107,
109,
111
],
[
113
],
[
115
]
] |
25,661 | StrongARMState *sa1110_init(MemoryRegion *sysmem,
unsigned int sdram_size, const char *rev)
{
StrongARMState *s;
int i;
s = g_new0(StrongARMState, 1);
if (!rev) {
rev = "sa1110-b5";
}
if (strncmp(rev, "sa1110", 6)) {
error_report("Machine requires a SA1110 processor.");
exit(1);
}
s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev));
if (!s->cpu) {
error_report("Unable to find CPU definition");
exit(1);
}
memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
sdram_size);
memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
NULL);
sysbus_create_varargs("pxa25x-timer", 0x90000000,
qdev_get_gpio_in(s->pic, SA_PIC_OSTC0),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC1),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC2),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC3),
NULL);
sysbus_create_simple(TYPE_STRONGARM_RTC, 0x90010000,
qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM));
s->gpio = strongarm_gpio_init(0x90040000, s->pic);
s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL);
for (i = 0; sa_serial[i].io_base; i++) {
DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART);
qdev_prop_set_chr(dev, "chardev", serial_hds[i]);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
sa_serial[i].io_base);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(s->pic, sa_serial[i].irq));
}
s->ssp = sysbus_create_varargs(TYPE_STRONGARM_SSP, 0x80070000,
qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
return s;
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | StrongARMState *sa1110_init(MemoryRegion *sysmem,
unsigned int sdram_size, const char *rev)
{
StrongARMState *s;
int i;
s = g_new0(StrongARMState, 1);
if (!rev) {
rev = "sa1110-b5";
}
if (strncmp(rev, "sa1110", 6)) {
error_report("Machine requires a SA1110 processor.");
exit(1);
}
s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev));
if (!s->cpu) {
error_report("Unable to find CPU definition");
exit(1);
}
memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
sdram_size);
memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
NULL);
sysbus_create_varargs("pxa25x-timer", 0x90000000,
qdev_get_gpio_in(s->pic, SA_PIC_OSTC0),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC1),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC2),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC3),
NULL);
sysbus_create_simple(TYPE_STRONGARM_RTC, 0x90010000,
qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM));
s->gpio = strongarm_gpio_init(0x90040000, s->pic);
s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL);
for (i = 0; sa_serial[i].io_base; i++) {
DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART);
qdev_prop_set_chr(dev, "chardev", serial_hds[i]);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
sa_serial[i].io_base);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(s->pic, sa_serial[i].irq));
}
s->ssp = sysbus_create_varargs(TYPE_STRONGARM_SSP, 0x80070000,
qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
return s;
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!s->cpu) {",
" error_report(\"Unable to find CPU definition\");",
" 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);",
" exit(1);",
" exit(1);",
" exit(1);",
" error_report(\"Unable to find CPU definition\");",
" exit(1);",
" error_report(\"Unable to find CPU definition\");",
" exit(1);"
],
"line_no": [
29,
29,
29,
29,
29,
29,
39,
41,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
29,
41,
29,
41,
29
]
} | StrongARMState *FUNC_0(MemoryRegion *sysmem,
unsigned int sdram_size, const char *rev)
{
StrongARMState *s;
int VAR_0;
s = g_new0(StrongARMState, 1);
if (!rev) {
rev = "sa1110-b5";
}
if (strncmp(rev, "sa1110", 6)) {
error_report("Machine requires a SA1110 processor.");
exit(1);
}
s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev));
if (!s->cpu) {
error_report("Unable to find CPU definition");
exit(1);
}
memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
sdram_size);
memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
NULL);
sysbus_create_varargs("pxa25x-timer", 0x90000000,
qdev_get_gpio_in(s->pic, SA_PIC_OSTC0),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC1),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC2),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC3),
NULL);
sysbus_create_simple(TYPE_STRONGARM_RTC, 0x90010000,
qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM));
s->gpio = strongarm_gpio_init(0x90040000, s->pic);
s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL);
for (VAR_0 = 0; sa_serial[VAR_0].io_base; VAR_0++) {
DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART);
qdev_prop_set_chr(dev, "chardev", serial_hds[VAR_0]);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
sa_serial[VAR_0].io_base);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
qdev_get_gpio_in(s->pic, sa_serial[VAR_0].irq));
}
s->ssp = sysbus_create_varargs(TYPE_STRONGARM_SSP, 0x80070000,
qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
return s;
}
| [
"StrongARMState *FUNC_0(MemoryRegion *sysmem,\nunsigned int sdram_size, const char *rev)\n{",
"StrongARMState *s;",
"int VAR_0;",
"s = g_new0(StrongARMState, 1);",
"if (!rev) {",
"rev = \"sa1110-b5\";",
"}",
"if (strncmp(rev, \"sa1110\", 6)) {",
"error_report(\"Machine requires a SA1110 processor.\");",
"exit(1);",
"}",
"s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, rev));",
"if (!s->cpu) {",
"error_report(\"Unable to find CPU definition\");",
"exit(1);",
"}",
"memory_region_allocate_system_memory(&s->sdram, NULL, \"strongarm.sdram\",\nsdram_size);",
"memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);",
"s->pic = sysbus_create_varargs(\"strongarm_pic\", 0x90050000,\nqdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),\nqdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),\nNULL);",
"sysbus_create_varargs(\"pxa25x-timer\", 0x90000000,\nqdev_get_gpio_in(s->pic, SA_PIC_OSTC0),\nqdev_get_gpio_in(s->pic, SA_PIC_OSTC1),\nqdev_get_gpio_in(s->pic, SA_PIC_OSTC2),\nqdev_get_gpio_in(s->pic, SA_PIC_OSTC3),\nNULL);",
"sysbus_create_simple(TYPE_STRONGARM_RTC, 0x90010000,\nqdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM));",
"s->gpio = strongarm_gpio_init(0x90040000, s->pic);",
"s->ppc = sysbus_create_varargs(TYPE_STRONGARM_PPC, 0x90060000, NULL);",
"for (VAR_0 = 0; sa_serial[VAR_0].io_base; VAR_0++) {",
"DeviceState *dev = qdev_create(NULL, TYPE_STRONGARM_UART);",
"qdev_prop_set_chr(dev, \"chardev\", serial_hds[VAR_0]);",
"qdev_init_nofail(dev);",
"sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,\nsa_serial[VAR_0].io_base);",
"sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,\nqdev_get_gpio_in(s->pic, sa_serial[VAR_0].irq));",
"}",
"s->ssp = sysbus_create_varargs(TYPE_STRONGARM_SSP, 0x80070000,\nqdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);",
"s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, \"ssi\");",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
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
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
53
],
[
57,
59,
61,
63
],
[
67,
69,
71,
73,
75,
77
],
[
81,
83
],
[
87
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107,
109
],
[
111
],
[
115,
117
],
[
119
],
[
123
],
[
125
]
] |
25,662 | static int celt_header(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
struct oggcelt_private *priv = os->private;
uint8_t *p = os->buf + os->pstart;
if (os->psize == 60 &&
!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {
/* Main header */
uint32_t version, sample_rate, nb_channels;
uint32_t overlap, extra_headers;
priv = av_malloc(sizeof(struct oggcelt_private));
if (!priv)
return AVERROR(ENOMEM);
if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {
av_free(priv);
return AVERROR(ENOMEM);
}
version = AV_RL32(p + 28);
/* unused header size field skipped */
sample_rate = AV_RL32(p + 36);
nb_channels = AV_RL32(p + 40);
overlap = AV_RL32(p + 48);
/* unused bytes per packet field skipped */
extra_headers = AV_RL32(p + 56);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_CELT;
st->codecpar->sample_rate = sample_rate;
st->codecpar->channels = nb_channels;
if (sample_rate)
avpriv_set_pts_info(st, 64, 1, sample_rate);
priv->extra_headers_left = 1 + extra_headers;
av_free(os->private);
os->private = priv;
AV_WL32(st->codecpar->extradata + 0, overlap);
AV_WL32(st->codecpar->extradata + 4, version);
return 1;
} else if (priv && priv->extra_headers_left) {
/* Extra headers (vorbiscomment) */
ff_vorbis_stream_comment(s, st, p, os->psize);
priv->extra_headers_left--;
return 1;
} else {
return 0;
}
}
| true | FFmpeg | 7140761481e4296723a592019a0244ebe6c1a8cf | static int celt_header(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
struct oggcelt_private *priv = os->private;
uint8_t *p = os->buf + os->pstart;
if (os->psize == 60 &&
!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {
uint32_t version, sample_rate, nb_channels;
uint32_t overlap, extra_headers;
priv = av_malloc(sizeof(struct oggcelt_private));
if (!priv)
return AVERROR(ENOMEM);
if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {
av_free(priv);
return AVERROR(ENOMEM);
}
version = AV_RL32(p + 28);
sample_rate = AV_RL32(p + 36);
nb_channels = AV_RL32(p + 40);
overlap = AV_RL32(p + 48);
extra_headers = AV_RL32(p + 56);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_CELT;
st->codecpar->sample_rate = sample_rate;
st->codecpar->channels = nb_channels;
if (sample_rate)
avpriv_set_pts_info(st, 64, 1, sample_rate);
priv->extra_headers_left = 1 + extra_headers;
av_free(os->private);
os->private = priv;
AV_WL32(st->codecpar->extradata + 0, overlap);
AV_WL32(st->codecpar->extradata + 4, version);
return 1;
} else if (priv && priv->extra_headers_left) {
ff_vorbis_stream_comment(s, st, p, os->psize);
priv->extra_headers_left--;
return 1;
} else {
return 0;
}
}
| {
"code": [
" priv->extra_headers_left = 1 + extra_headers;",
" av_free(os->private);"
],
"line_no": [
71,
73
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
struct VAR_2 *VAR_2 = VAR_0->priv_data;
struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;
AVStream *st = VAR_0->streams[VAR_1];
struct oggcelt_private *VAR_4 = VAR_3->private;
uint8_t *p = VAR_3->buf + VAR_3->pstart;
if (VAR_3->psize == 60 &&
!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {
uint32_t version, sample_rate, nb_channels;
uint32_t overlap, extra_headers;
VAR_4 = av_malloc(sizeof(struct oggcelt_private));
if (!VAR_4)
return AVERROR(ENOMEM);
if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {
av_free(VAR_4);
return AVERROR(ENOMEM);
}
version = AV_RL32(p + 28);
sample_rate = AV_RL32(p + 36);
nb_channels = AV_RL32(p + 40);
overlap = AV_RL32(p + 48);
extra_headers = AV_RL32(p + 56);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_CELT;
st->codecpar->sample_rate = sample_rate;
st->codecpar->channels = nb_channels;
if (sample_rate)
avpriv_set_pts_info(st, 64, 1, sample_rate);
VAR_4->extra_headers_left = 1 + extra_headers;
av_free(VAR_3->private);
VAR_3->private = VAR_4;
AV_WL32(st->codecpar->extradata + 0, overlap);
AV_WL32(st->codecpar->extradata + 4, version);
return 1;
} else if (VAR_4 && VAR_4->extra_headers_left) {
ff_vorbis_stream_comment(VAR_0, st, p, VAR_3->psize);
VAR_4->extra_headers_left--;
return 1;
} else {
return 0;
}
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"struct VAR_2 *VAR_2 = VAR_0->priv_data;",
"struct ogg_stream *VAR_3 = VAR_2->streams + VAR_1;",
"AVStream *st = VAR_0->streams[VAR_1];",
"struct oggcelt_private *VAR_4 = VAR_3->private;",
"uint8_t *p = VAR_3->buf + VAR_3->pstart;",
"if (VAR_3->psize == 60 &&\n!memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) {",
"uint32_t version, sample_rate, nb_channels;",
"uint32_t overlap, extra_headers;",
"VAR_4 = av_malloc(sizeof(struct oggcelt_private));",
"if (!VAR_4)\nreturn AVERROR(ENOMEM);",
"if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {",
"av_free(VAR_4);",
"return AVERROR(ENOMEM);",
"}",
"version = AV_RL32(p + 28);",
"sample_rate = AV_RL32(p + 36);",
"nb_channels = AV_RL32(p + 40);",
"overlap = AV_RL32(p + 48);",
"extra_headers = AV_RL32(p + 56);",
"st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;",
"st->codecpar->codec_id = AV_CODEC_ID_CELT;",
"st->codecpar->sample_rate = sample_rate;",
"st->codecpar->channels = nb_channels;",
"if (sample_rate)\navpriv_set_pts_info(st, 64, 1, sample_rate);",
"VAR_4->extra_headers_left = 1 + extra_headers;",
"av_free(VAR_3->private);",
"VAR_3->private = VAR_4;",
"AV_WL32(st->codecpar->extradata + 0, overlap);",
"AV_WL32(st->codecpar->extradata + 4, version);",
"return 1;",
"} else if (VAR_4 && VAR_4->extra_headers_left) {",
"ff_vorbis_stream_comment(VAR_0, st, p, VAR_3->psize);",
"VAR_4->extra_headers_left--;",
"return 1;",
"} else {",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
25
],
[
27
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
25,663 | static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
int flags, int send)
{
abi_long ret, len;
struct msghdr msg;
int count;
struct iovec *vec;
abi_ulong target_vec;
if (msgp->msg_name) {
msg.msg_namelen = tswap32(msgp->msg_namelen);
msg.msg_name = alloca(msg.msg_namelen+1);
ret = target_to_host_sockaddr(fd, msg.msg_name,
tswapal(msgp->msg_name),
msg.msg_namelen);
if (ret) {
goto out2;
}
} else {
msg.msg_name = NULL;
msg.msg_namelen = 0;
}
msg.msg_controllen = 2 * tswapal(msgp->msg_controllen);
msg.msg_control = alloca(msg.msg_controllen);
msg.msg_flags = tswap32(msgp->msg_flags);
count = tswapal(msgp->msg_iovlen);
target_vec = tswapal(msgp->msg_iov);
vec = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE,
target_vec, count, send);
if (vec == NULL) {
ret = -host_to_target_errno(errno);
goto out2;
}
msg.msg_iovlen = count;
msg.msg_iov = vec;
if (send) {
if (fd_trans_target_to_host_data(fd)) {
ret = fd_trans_target_to_host_data(fd)(msg.msg_iov->iov_base,
msg.msg_iov->iov_len);
} else {
ret = target_to_host_cmsg(&msg, msgp);
}
if (ret == 0) {
ret = get_errno(safe_sendmsg(fd, &msg, flags));
}
} else {
ret = get_errno(safe_recvmsg(fd, &msg, flags));
if (!is_error(ret)) {
len = ret;
if (fd_trans_host_to_target_data(fd)) {
ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
len);
} else {
ret = host_to_target_cmsg(msgp, &msg);
}
if (!is_error(ret)) {
msgp->msg_namelen = tswap32(msg.msg_namelen);
if (msg.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
msg.msg_name, msg.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(vec, target_vec, count, !send);
out2:
return ret;
}
| true | qemu | 7d61d892327d803ae43d14500601e48031b4632c | static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
int flags, int send)
{
abi_long ret, len;
struct msghdr msg;
int count;
struct iovec *vec;
abi_ulong target_vec;
if (msgp->msg_name) {
msg.msg_namelen = tswap32(msgp->msg_namelen);
msg.msg_name = alloca(msg.msg_namelen+1);
ret = target_to_host_sockaddr(fd, msg.msg_name,
tswapal(msgp->msg_name),
msg.msg_namelen);
if (ret) {
goto out2;
}
} else {
msg.msg_name = NULL;
msg.msg_namelen = 0;
}
msg.msg_controllen = 2 * tswapal(msgp->msg_controllen);
msg.msg_control = alloca(msg.msg_controllen);
msg.msg_flags = tswap32(msgp->msg_flags);
count = tswapal(msgp->msg_iovlen);
target_vec = tswapal(msgp->msg_iov);
vec = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE,
target_vec, count, send);
if (vec == NULL) {
ret = -host_to_target_errno(errno);
goto out2;
}
msg.msg_iovlen = count;
msg.msg_iov = vec;
if (send) {
if (fd_trans_target_to_host_data(fd)) {
ret = fd_trans_target_to_host_data(fd)(msg.msg_iov->iov_base,
msg.msg_iov->iov_len);
} else {
ret = target_to_host_cmsg(&msg, msgp);
}
if (ret == 0) {
ret = get_errno(safe_sendmsg(fd, &msg, flags));
}
} else {
ret = get_errno(safe_recvmsg(fd, &msg, flags));
if (!is_error(ret)) {
len = ret;
if (fd_trans_host_to_target_data(fd)) {
ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
len);
} else {
ret = host_to_target_cmsg(msgp, &msg);
}
if (!is_error(ret)) {
msgp->msg_namelen = tswap32(msg.msg_namelen);
if (msg.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
msg.msg_name, msg.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(vec, target_vec, count, !send);
out2:
return ret;
}
| {
"code": [
" ret = fd_trans_target_to_host_data(fd)(msg.msg_iov->iov_base,",
" if (ret == 0) {",
" ret = get_errno(safe_sendmsg(fd, &msg, flags));"
],
"line_no": [
79,
89,
91
]
} | static abi_long FUNC_0(int fd, struct target_msghdr *msgp,
int flags, int send)
{
abi_long ret, len;
struct msghdr VAR_0;
int VAR_1;
struct iovec *VAR_2;
abi_ulong target_vec;
if (msgp->msg_name) {
VAR_0.msg_namelen = tswap32(msgp->msg_namelen);
VAR_0.msg_name = alloca(VAR_0.msg_namelen+1);
ret = target_to_host_sockaddr(fd, VAR_0.msg_name,
tswapal(msgp->msg_name),
VAR_0.msg_namelen);
if (ret) {
goto out2;
}
} else {
VAR_0.msg_name = NULL;
VAR_0.msg_namelen = 0;
}
VAR_0.msg_controllen = 2 * tswapal(msgp->msg_controllen);
VAR_0.msg_control = alloca(VAR_0.msg_controllen);
VAR_0.msg_flags = tswap32(msgp->msg_flags);
VAR_1 = tswapal(msgp->msg_iovlen);
target_vec = tswapal(msgp->msg_iov);
VAR_2 = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE,
target_vec, VAR_1, send);
if (VAR_2 == NULL) {
ret = -host_to_target_errno(errno);
goto out2;
}
VAR_0.msg_iovlen = VAR_1;
VAR_0.msg_iov = VAR_2;
if (send) {
if (fd_trans_target_to_host_data(fd)) {
ret = fd_trans_target_to_host_data(fd)(VAR_0.msg_iov->iov_base,
VAR_0.msg_iov->iov_len);
} else {
ret = target_to_host_cmsg(&VAR_0, msgp);
}
if (ret == 0) {
ret = get_errno(safe_sendmsg(fd, &VAR_0, flags));
}
} else {
ret = get_errno(safe_recvmsg(fd, &VAR_0, flags));
if (!is_error(ret)) {
len = ret;
if (fd_trans_host_to_target_data(fd)) {
ret = fd_trans_host_to_target_data(fd)(VAR_0.msg_iov->iov_base,
len);
} else {
ret = host_to_target_cmsg(msgp, &VAR_0);
}
if (!is_error(ret)) {
msgp->msg_namelen = tswap32(VAR_0.msg_namelen);
if (VAR_0.msg_name != NULL) {
ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
VAR_0.msg_name, VAR_0.msg_namelen);
if (ret) {
goto out;
}
}
ret = len;
}
}
}
out:
unlock_iovec(VAR_2, target_vec, VAR_1, !send);
out2:
return ret;
}
| [
"static abi_long FUNC_0(int fd, struct target_msghdr *msgp,\nint flags, int send)\n{",
"abi_long ret, len;",
"struct msghdr VAR_0;",
"int VAR_1;",
"struct iovec *VAR_2;",
"abi_ulong target_vec;",
"if (msgp->msg_name) {",
"VAR_0.msg_namelen = tswap32(msgp->msg_namelen);",
"VAR_0.msg_name = alloca(VAR_0.msg_namelen+1);",
"ret = target_to_host_sockaddr(fd, VAR_0.msg_name,\ntswapal(msgp->msg_name),\nVAR_0.msg_namelen);",
"if (ret) {",
"goto out2;",
"}",
"} else {",
"VAR_0.msg_name = NULL;",
"VAR_0.msg_namelen = 0;",
"}",
"VAR_0.msg_controllen = 2 * tswapal(msgp->msg_controllen);",
"VAR_0.msg_control = alloca(VAR_0.msg_controllen);",
"VAR_0.msg_flags = tswap32(msgp->msg_flags);",
"VAR_1 = tswapal(msgp->msg_iovlen);",
"target_vec = tswapal(msgp->msg_iov);",
"VAR_2 = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE,\ntarget_vec, VAR_1, send);",
"if (VAR_2 == NULL) {",
"ret = -host_to_target_errno(errno);",
"goto out2;",
"}",
"VAR_0.msg_iovlen = VAR_1;",
"VAR_0.msg_iov = VAR_2;",
"if (send) {",
"if (fd_trans_target_to_host_data(fd)) {",
"ret = fd_trans_target_to_host_data(fd)(VAR_0.msg_iov->iov_base,\nVAR_0.msg_iov->iov_len);",
"} else {",
"ret = target_to_host_cmsg(&VAR_0, msgp);",
"}",
"if (ret == 0) {",
"ret = get_errno(safe_sendmsg(fd, &VAR_0, flags));",
"}",
"} else {",
"ret = get_errno(safe_recvmsg(fd, &VAR_0, flags));",
"if (!is_error(ret)) {",
"len = ret;",
"if (fd_trans_host_to_target_data(fd)) {",
"ret = fd_trans_host_to_target_data(fd)(VAR_0.msg_iov->iov_base,\nlen);",
"} else {",
"ret = host_to_target_cmsg(msgp, &VAR_0);",
"}",
"if (!is_error(ret)) {",
"msgp->msg_namelen = tswap32(VAR_0.msg_namelen);",
"if (VAR_0.msg_name != NULL) {",
"ret = host_to_target_sockaddr(tswapal(msgp->msg_name),\nVAR_0.msg_name, VAR_0.msg_namelen);",
"if (ret) {",
"goto out;",
"}",
"}",
"ret = len;",
"}",
"}",
"}",
"out:\nunlock_iovec(VAR_2, target_vec, VAR_1, !send);",
"out2:\nreturn ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145,
147
],
[
149,
151
],
[
153
]
] |
25,664 | static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb,
int pix_left, int *runs)
{
int mode = 0, run = 0;
unsigned int t;
for(;;){
t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2);
run += t;
if(t < 64){
pix_left -= run;
*runs++ = run;
if(pix_left <= 0){
if(!pix_left)
break;
runs[-1] = 0;
av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
run = 0;
mode = !mode;
}else if((int)t == -1){
av_log(avctx, AV_LOG_ERROR, "Incorrect code\n");
return -1;
}
}
*runs++ = 0;
return 0;
}
| false | FFmpeg | d68542f019c89e7938297a18da282e3a892718aa | static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb,
int pix_left, int *runs)
{
int mode = 0, run = 0;
unsigned int t;
for(;;){
t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2);
run += t;
if(t < 64){
pix_left -= run;
*runs++ = run;
if(pix_left <= 0){
if(!pix_left)
break;
runs[-1] = 0;
av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
run = 0;
mode = !mode;
}else if((int)t == -1){
av_log(avctx, AV_LOG_ERROR, "Incorrect code\n");
return -1;
}
}
*runs++ = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,
int VAR_2, int *VAR_3)
{
int VAR_4 = 0, VAR_5 = 0;
unsigned int VAR_6;
for(;;){
VAR_6 = get_vlc2(VAR_1, ccitt_vlc[VAR_4].table, 9, 2);
VAR_5 += VAR_6;
if(VAR_6 < 64){
VAR_2 -= VAR_5;
*VAR_3++ = VAR_5;
if(VAR_2 <= 0){
if(!VAR_2)
break;
VAR_3[-1] = 0;
av_log(VAR_0, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
VAR_5 = 0;
VAR_4 = !VAR_4;
}else if((int)VAR_6 == -1){
av_log(VAR_0, AV_LOG_ERROR, "Incorrect code\n");
return -1;
}
}
*VAR_3++ = 0;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,\nint VAR_2, int *VAR_3)\n{",
"int VAR_4 = 0, VAR_5 = 0;",
"unsigned int VAR_6;",
"for(;;){",
"VAR_6 = get_vlc2(VAR_1, ccitt_vlc[VAR_4].table, 9, 2);",
"VAR_5 += VAR_6;",
"if(VAR_6 < 64){",
"VAR_2 -= VAR_5;",
"*VAR_3++ = VAR_5;",
"if(VAR_2 <= 0){",
"if(!VAR_2)\nbreak;",
"VAR_3[-1] = 0;",
"av_log(VAR_0, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return -1;",
"}",
"VAR_5 = 0;",
"VAR_4 = !VAR_4;",
"}else if((int)VAR_6 == -1){",
"av_log(VAR_0, AV_LOG_ERROR, \"Incorrect code\\n\");",
"return -1;",
"}",
"}",
"*VAR_3++ = 0;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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
]
] |
25,665 | static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
{
int i, x;
if (s->buf_end - s->buf < 1)
return AVERROR(EINVAL);
x = bytestream_get_byte(&s->buf); // Sqcd
q->nguardbits = x >> 5;
q->quantsty = x & 0x1f;
if (q->quantsty == JPEG2000_QSTY_NONE) {
n -= 3;
if (s->buf_end - s->buf < n || 32*3 < n)
return AVERROR(EINVAL);
for (i = 0; i < n; i++)
q->expn[i] = bytestream_get_byte(&s->buf) >> 3;
} else if (q->quantsty == JPEG2000_QSTY_SI) {
if (s->buf_end - s->buf < 2)
return AVERROR(EINVAL);
x = bytestream_get_be16(&s->buf);
q->expn[0] = x >> 11;
q->mant[0] = x & 0x7ff;
for (i = 1; i < 32 * 3; i++) {
int curexpn = FFMAX(0, q->expn[0] - (i - 1) / 3);
q->expn[i] = curexpn;
q->mant[i] = q->mant[0];
}
} else {
n = (n - 3) >> 1;
if (s->buf_end - s->buf < 2 * n || 32*3 < n)
return AVERROR(EINVAL);
for (i = 0; i < n; i++) {
x = bytestream_get_be16(&s->buf);
q->expn[i] = x >> 11;
q->mant[i] = x & 0x7ff;
}
}
return 0;
}
| false | FFmpeg | 0b42631641d998e509cde6fa344edc6ab5cb4ac8 | static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q)
{
int i, x;
if (s->buf_end - s->buf < 1)
return AVERROR(EINVAL);
x = bytestream_get_byte(&s->buf);
q->nguardbits = x >> 5;
q->quantsty = x & 0x1f;
if (q->quantsty == JPEG2000_QSTY_NONE) {
n -= 3;
if (s->buf_end - s->buf < n || 32*3 < n)
return AVERROR(EINVAL);
for (i = 0; i < n; i++)
q->expn[i] = bytestream_get_byte(&s->buf) >> 3;
} else if (q->quantsty == JPEG2000_QSTY_SI) {
if (s->buf_end - s->buf < 2)
return AVERROR(EINVAL);
x = bytestream_get_be16(&s->buf);
q->expn[0] = x >> 11;
q->mant[0] = x & 0x7ff;
for (i = 1; i < 32 * 3; i++) {
int curexpn = FFMAX(0, q->expn[0] - (i - 1) / 3);
q->expn[i] = curexpn;
q->mant[i] = q->mant[0];
}
} else {
n = (n - 3) >> 1;
if (s->buf_end - s->buf < 2 * n || 32*3 < n)
return AVERROR(EINVAL);
for (i = 0; i < n; i++) {
x = bytestream_get_be16(&s->buf);
q->expn[i] = x >> 11;
q->mant[i] = x & 0x7ff;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1, Jpeg2000QuantStyle *VAR_2)
{
int VAR_3, VAR_4;
if (VAR_0->buf_end - VAR_0->buf < 1)
return AVERROR(EINVAL);
VAR_4 = bytestream_get_byte(&VAR_0->buf);
VAR_2->nguardbits = VAR_4 >> 5;
VAR_2->quantsty = VAR_4 & 0x1f;
if (VAR_2->quantsty == JPEG2000_QSTY_NONE) {
VAR_1 -= 3;
if (VAR_0->buf_end - VAR_0->buf < VAR_1 || 32*3 < VAR_1)
return AVERROR(EINVAL);
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++)
VAR_2->expn[VAR_3] = bytestream_get_byte(&VAR_0->buf) >> 3;
} else if (VAR_2->quantsty == JPEG2000_QSTY_SI) {
if (VAR_0->buf_end - VAR_0->buf < 2)
return AVERROR(EINVAL);
VAR_4 = bytestream_get_be16(&VAR_0->buf);
VAR_2->expn[0] = VAR_4 >> 11;
VAR_2->mant[0] = VAR_4 & 0x7ff;
for (VAR_3 = 1; VAR_3 < 32 * 3; VAR_3++) {
int VAR_5 = FFMAX(0, VAR_2->expn[0] - (VAR_3 - 1) / 3);
VAR_2->expn[VAR_3] = VAR_5;
VAR_2->mant[VAR_3] = VAR_2->mant[0];
}
} else {
VAR_1 = (VAR_1 - 3) >> 1;
if (VAR_0->buf_end - VAR_0->buf < 2 * VAR_1 || 32*3 < VAR_1)
return AVERROR(EINVAL);
for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {
VAR_4 = bytestream_get_be16(&VAR_0->buf);
VAR_2->expn[VAR_3] = VAR_4 >> 11;
VAR_2->mant[VAR_3] = VAR_4 & 0x7ff;
}
}
return 0;
}
| [
"static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1, Jpeg2000QuantStyle *VAR_2)\n{",
"int VAR_3, VAR_4;",
"if (VAR_0->buf_end - VAR_0->buf < 1)\nreturn AVERROR(EINVAL);",
"VAR_4 = bytestream_get_byte(&VAR_0->buf);",
"VAR_2->nguardbits = VAR_4 >> 5;",
"VAR_2->quantsty = VAR_4 & 0x1f;",
"if (VAR_2->quantsty == JPEG2000_QSTY_NONE) {",
"VAR_1 -= 3;",
"if (VAR_0->buf_end - VAR_0->buf < VAR_1 || 32*3 < VAR_1)\nreturn AVERROR(EINVAL);",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++)",
"VAR_2->expn[VAR_3] = bytestream_get_byte(&VAR_0->buf) >> 3;",
"} else if (VAR_2->quantsty == JPEG2000_QSTY_SI) {",
"if (VAR_0->buf_end - VAR_0->buf < 2)\nreturn AVERROR(EINVAL);",
"VAR_4 = bytestream_get_be16(&VAR_0->buf);",
"VAR_2->expn[0] = VAR_4 >> 11;",
"VAR_2->mant[0] = VAR_4 & 0x7ff;",
"for (VAR_3 = 1; VAR_3 < 32 * 3; VAR_3++) {",
"int VAR_5 = FFMAX(0, VAR_2->expn[0] - (VAR_3 - 1) / 3);",
"VAR_2->expn[VAR_3] = VAR_5;",
"VAR_2->mant[VAR_3] = VAR_2->mant[0];",
"}",
"} else {",
"VAR_1 = (VAR_1 - 3) >> 1;",
"if (VAR_0->buf_end - VAR_0->buf < 2 * VAR_1 || 32*3 < VAR_1)\nreturn AVERROR(EINVAL);",
"for (VAR_3 = 0; VAR_3 < VAR_1; VAR_3++) {",
"VAR_4 = bytestream_get_be16(&VAR_0->buf);",
"VAR_2->expn[VAR_3] = VAR_4 >> 11;",
"VAR_2->mant[VAR_3] = VAR_4 & 0x7ff;",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
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
]
] |
25,666 | void do_compare_and_swap32(void *cpu_env, int num)
{
#ifdef TARGET_I386
uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX];
uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX];
DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value);
if(value && old == tswap32(*value))
{
uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX];
*value = tswap32(new);
/* set zf flag */
((CPUX86State*)cpu_env)->eflags |= 0x40;
}
else
{
((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value);
/* unset zf flag */
((CPUX86State*)cpu_env)->eflags &= ~0x40;
}
#else
qerror("do_compare_and_swap32 unimplemented");
#endif
}
| true | qemu | 70afb8ff90e9d922ed729e6dbabaff6d67c461aa | void do_compare_and_swap32(void *cpu_env, int num)
{
#ifdef TARGET_I386
uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX];
uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX];
DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value);
if(value && old == tswap32(*value))
{
uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX];
*value = tswap32(new);
((CPUX86State*)cpu_env)->eflags |= 0x40;
}
else
{
((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value);
((CPUX86State*)cpu_env)->eflags &= ~0x40;
}
#else
qerror("do_compare_and_swap32 unimplemented");
#endif
}
| {
"code": [
" if(value && old == tswap32(*value))"
],
"line_no": [
15
]
} | void FUNC_0(void *VAR_0, int VAR_1)
{
#ifdef TARGET_I386
uint32_t old = ((CPUX86State*)VAR_0)->regs[R_EAX];
uint32_t *value = (uint32_t*)((CPUX86State*)VAR_0)->regs[R_ECX];
DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value);
if(value && old == tswap32(*value))
{
uint32_t new = ((CPUX86State*)VAR_0)->regs[R_EDX];
*value = tswap32(new);
((CPUX86State*)VAR_0)->eflags |= 0x40;
}
else
{
((CPUX86State*)VAR_0)->regs[R_EAX] = tswap32(*value);
((CPUX86State*)VAR_0)->eflags &= ~0x40;
}
#else
qerror("FUNC_0 unimplemented");
#endif
}
| [
"void FUNC_0(void *VAR_0, int VAR_1)\n{",
"#ifdef TARGET_I386\nuint32_t old = ((CPUX86State*)VAR_0)->regs[R_EAX];",
"uint32_t *value = (uint32_t*)((CPUX86State*)VAR_0)->regs[R_ECX];",
"DPRINTF(\"commpage: compare_and_swap32(%x,new,%p)\\n\", old, value);",
"if(value && old == tswap32(*value))\n{",
"uint32_t new = ((CPUX86State*)VAR_0)->regs[R_EDX];",
"*value = tswap32(new);",
"((CPUX86State*)VAR_0)->eflags |= 0x40;",
"}",
"else\n{",
"((CPUX86State*)VAR_0)->regs[R_EAX] = tswap32(*value);",
"((CPUX86State*)VAR_0)->eflags &= ~0x40;",
"}",
"#else\nqerror(\"FUNC_0 unimplemented\");",
"#endif\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
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47
]
] |
25,667 | static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
{
int i;
assert(rc->type == 2);
rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications);
for (i = 0; i < rc->classifications; i++) {
int j;
vorbis_enc_codebook * cb;
for (j = 0; j < 8; j++)
if (rc->books[i][j] != -1)
break;
if (j == 8) // zero
continue;
cb = &venc->codebooks[rc->books[i][j]];
assert(cb->ndimentions >= 2);
assert(cb->lookup);
for (j = 0; j < cb->nentries; j++) {
float a;
if (!cb->lens[j])
continue;
a = fabs(cb->dimentions[j * cb->ndimentions]);
if (a > rc->maxes[i][0])
rc->maxes[i][0] = a;
a = fabs(cb->dimentions[j * cb->ndimentions + 1]);
if (a > rc->maxes[i][1])
rc->maxes[i][1] = a;
}
}
// small bias
for (i = 0; i < rc->classifications; i++) {
rc->maxes[i][0] += 0.8;
rc->maxes[i][1] += 0.8;
}
}
| true | FFmpeg | be8d812c9635f31f69c30dff9ebf565a07a7dab7 | static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)
{
int i;
assert(rc->type == 2);
rc->maxes = av_mallocz(sizeof(float[2]) * rc->classifications);
for (i = 0; i < rc->classifications; i++) {
int j;
vorbis_enc_codebook * cb;
for (j = 0; j < 8; j++)
if (rc->books[i][j] != -1)
break;
if (j == 8)
continue;
cb = &venc->codebooks[rc->books[i][j]];
assert(cb->ndimentions >= 2);
assert(cb->lookup);
for (j = 0; j < cb->nentries; j++) {
float a;
if (!cb->lens[j])
continue;
a = fabs(cb->dimentions[j * cb->ndimentions]);
if (a > rc->maxes[i][0])
rc->maxes[i][0] = a;
a = fabs(cb->dimentions[j * cb->ndimentions + 1]);
if (a > rc->maxes[i][1])
rc->maxes[i][1] = a;
}
}
for (i = 0; i < rc->classifications; i++) {
rc->maxes[i][0] += 0.8;
rc->maxes[i][1] += 0.8;
}
}
| {
"code": [
"static void ready_residue(vorbis_enc_residue *rc, vorbis_enc_context *venc)"
],
"line_no": [
1
]
} | static void FUNC_0(vorbis_enc_residue *VAR_0, vorbis_enc_context *VAR_1)
{
int VAR_2;
assert(VAR_0->type == 2);
VAR_0->maxes = av_mallocz(sizeof(float[2]) * VAR_0->classifications);
for (VAR_2 = 0; VAR_2 < VAR_0->classifications; VAR_2++) {
int j;
vorbis_enc_codebook * cb;
for (j = 0; j < 8; j++)
if (VAR_0->books[VAR_2][j] != -1)
break;
if (j == 8)
continue;
cb = &VAR_1->codebooks[VAR_0->books[VAR_2][j]];
assert(cb->ndimentions >= 2);
assert(cb->lookup);
for (j = 0; j < cb->nentries; j++) {
float a;
if (!cb->lens[j])
continue;
a = fabs(cb->dimentions[j * cb->ndimentions]);
if (a > VAR_0->maxes[VAR_2][0])
VAR_0->maxes[VAR_2][0] = a;
a = fabs(cb->dimentions[j * cb->ndimentions + 1]);
if (a > VAR_0->maxes[VAR_2][1])
VAR_0->maxes[VAR_2][1] = a;
}
}
for (VAR_2 = 0; VAR_2 < VAR_0->classifications; VAR_2++) {
VAR_0->maxes[VAR_2][0] += 0.8;
VAR_0->maxes[VAR_2][1] += 0.8;
}
}
| [
"static void FUNC_0(vorbis_enc_residue *VAR_0, vorbis_enc_context *VAR_1)\n{",
"int VAR_2;",
"assert(VAR_0->type == 2);",
"VAR_0->maxes = av_mallocz(sizeof(float[2]) * VAR_0->classifications);",
"for (VAR_2 = 0; VAR_2 < VAR_0->classifications; VAR_2++) {",
"int j;",
"vorbis_enc_codebook * cb;",
"for (j = 0; j < 8; j++)",
"if (VAR_0->books[VAR_2][j] != -1)\nbreak;",
"if (j == 8)\ncontinue;",
"cb = &VAR_1->codebooks[VAR_0->books[VAR_2][j]];",
"assert(cb->ndimentions >= 2);",
"assert(cb->lookup);",
"for (j = 0; j < cb->nentries; j++) {",
"float a;",
"if (!cb->lens[j])\ncontinue;",
"a = fabs(cb->dimentions[j * cb->ndimentions]);",
"if (a > VAR_0->maxes[VAR_2][0])\nVAR_0->maxes[VAR_2][0] = a;",
"a = fabs(cb->dimentions[j * cb->ndimentions + 1]);",
"if (a > VAR_0->maxes[VAR_2][1])\nVAR_0->maxes[VAR_2][1] = a;",
"}",
"}",
"for (VAR_2 = 0; VAR_2 < VAR_0->classifications; VAR_2++) {",
"VAR_0->maxes[VAR_2][0] += 0.8;",
"VAR_0->maxes[VAR_2][1] += 0.8;",
"}",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
25,668 | BlockDriverState *bdrv_all_find_vmstate_bs(void)
{
bool not_found = true;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
while (not_found && (it = bdrv_next(it, &bs))) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
not_found = !bdrv_can_snapshot(bs);
aio_context_release(ctx);
}
return bs;
}
| true | qemu | 88be7b4be4aa17c88247e162bdd7577ea79db94f | BlockDriverState *bdrv_all_find_vmstate_bs(void)
{
bool not_found = true;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
while (not_found && (it = bdrv_next(it, &bs))) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
not_found = !bdrv_can_snapshot(bs);
aio_context_release(ctx);
}
return bs;
}
| {
"code": [
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BlockDriverState *bs;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" bool not_found = true;",
" BdrvNextIterator *it = NULL;",
" while (not_found && (it = bdrv_next(it, &bs))) {",
" not_found = !bdrv_can_snapshot(bs);",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;",
" BdrvNextIterator *it = NULL;"
],
"line_no": [
9,
9,
9,
7,
9,
9,
9,
9,
9,
9,
5,
9,
13,
21,
9,
9,
9
]
} | BlockDriverState *FUNC_0(void)
{
bool not_found = true;
BlockDriverState *bs;
BdrvNextIterator *it = NULL;
while (not_found && (it = bdrv_next(it, &bs))) {
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
not_found = !bdrv_can_snapshot(bs);
aio_context_release(ctx);
}
return bs;
}
| [
"BlockDriverState *FUNC_0(void)\n{",
"bool not_found = true;",
"BlockDriverState *bs;",
"BdrvNextIterator *it = NULL;",
"while (not_found && (it = bdrv_next(it, &bs))) {",
"AioContext *ctx = bdrv_get_aio_context(bs);",
"aio_context_acquire(ctx);",
"not_found = !bdrv_can_snapshot(bs);",
"aio_context_release(ctx);",
"}",
"return bs;",
"}"
] | [
0,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
25,671 | static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int *outFilterSize, int xInc, int srcW,
int dstW, int filterAlign, int one,
int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter,
double param[2], int is_horizontal)
{
int i;
int filterSize;
int filter2Size;
int minFilterSize;
int64_t *filter = NULL;
int64_t *filter2 = NULL;
const int64_t fone = 1LL << 54;
int ret = -1;
emms_c(); // FIXME should not be required but IS (even for non-MMX versions)
// NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10) { // unscaled
int i;
filterSize = 1;
FF_ALLOCZ_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
for (i = 0; i < dstW; i++) {
filter[i * filterSize] = fone;
(*filterPos)[i] = i;
}
} else if (flags & SWS_POINT) { // lame looking point sampling mode
int i;
int xDstInSrc;
filterSize = 1;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
(*filterPos)[i] = xx;
filter[i] = fone;
xDstInSrc += xInc;
}
} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||
(flags & SWS_FAST_BILINEAR)) { // bilinear upscale
int i;
int xDstInSrc;
filterSize = 2;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
int j;
(*filterPos)[i] = xx;
// bilinear upscale / linear interpolate / area averaging
for (j = 0; j < filterSize; j++) {
int64_t coeff = fone - FFABS((xx << 16) - xDstInSrc) *
(fone >> 16);
if (coeff < 0)
coeff = 0;
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += xInc;
}
} else {
int64_t xDstInSrc;
int sizeFactor;
if (flags & SWS_BICUBIC)
sizeFactor = 4;
else if (flags & SWS_X)
sizeFactor = 8;
else if (flags & SWS_AREA)
sizeFactor = 1; // downscale only, for upscale it is bilinear
else if (flags & SWS_GAUSS)
sizeFactor = 8; // infinite ;)
else if (flags & SWS_LANCZOS)
sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;
else if (flags & SWS_SINC)
sizeFactor = 20; // infinite ;)
else if (flags & SWS_SPLINE)
sizeFactor = 20; // infinite ;)
else if (flags & SWS_BILINEAR)
sizeFactor = 2;
else {
sizeFactor = 0; // GCC warning killer
assert(0);
}
if (xInc <= 1 << 16)
filterSize = 1 + sizeFactor; // upscale
else
filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
filterSize = FFMIN(filterSize, srcW - 2);
filterSize = FFMAX(filterSize, 1);
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc - 0x10000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
int j;
(*filterPos)[i] = xx;
for (j = 0; j < filterSize; j++) {
int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
double floatd;
int64_t coeff;
if (xInc > 1 << 16)
d = d * dstW / srcW;
floatd = d * (1.0 / (1 << 30));
if (flags & SWS_BICUBIC) {
int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);
int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);
if (d >= 1LL << 31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL << 30)
coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
(-18 * (1 << 24) + 12 * B + 6 * C) * dd +
(6 * (1 << 24) - 2 * B) * (1 << 30);
else
coeff = (-B - 6 * C) * ddd +
(6 * B + 30 * C) * dd +
(-12 * B - 48 * C) * d +
(8 * B + 24 * C) * (1 << 30);
}
coeff *= fone >> (30 + 24);
}
#if 0
else if (flags & SWS_X) {
double p = param ? param * 0.01 : 0.3;
coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
coeff *= pow(2.0, -p * d * d);
}
#endif
else if (flags & SWS_X) {
double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double c;
if (floatd < 1.0)
c = cos(floatd * M_PI);
else
c = -1.0;
if (c < 0.0)
c = -pow(-c, A);
else
c = pow(c, A);
coeff = (c * 0.5 + 0.5) * fone;
} else if (flags & SWS_AREA) {
int64_t d2 = d - (1 << 29);
if (d2 * xInc < -(1LL << (29 + 16)))
coeff = 1.0 * (1LL << (30 + 16));
else if (d2 * xInc < (1LL << (29 + 16)))
coeff = -d2 * xInc + (1LL << (29 + 16));
else
coeff = 0.0;
coeff *= fone >> (30 + 16);
} else if (flags & SWS_GAUSS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, -p * floatd * floatd)) * fone;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
} else if (flags & SWS_LANCZOS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
(floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
if (floatd > p)
coeff = 0;
} else if (flags & SWS_BILINEAR) {
coeff = (1 << 30) - d;
if (coeff < 0)
coeff = 0;
coeff *= fone >> 30;
} else if (flags & SWS_SPLINE) {
double p = -2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone;
} else {
coeff = 0.0; // GCC warning killer
assert(0);
}
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += 2 * xInc;
}
}
/* apply src & dst Filter to filter -> filter2
* av_free(filter);
*/
assert(filterSize > 0);
filter2Size = filterSize;
if (srcFilter)
filter2Size += srcFilter->length - 1;
if (dstFilter)
filter2Size += dstFilter->length - 1;
assert(filter2Size > 0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail);
for (i = 0; i < dstW; i++) {
int j, k;
if (srcFilter) {
for (k = 0; k < srcFilter->length; k++) {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + k + j] +=
srcFilter->coeff[k] * filter[i * filterSize + j];
}
} else {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + j] = filter[i * filterSize + j];
}
// FIXME dstFilter
(*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
}
av_freep(&filter);
/* try to reduce the filter-size (step1 find size and shift left) */
// Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not).
minFilterSize = 0;
for (i = dstW - 1; i >= 0; i--) {
int min = filter2Size;
int j;
int64_t cutOff = 0.0;
/* get rid of near zero elements on the left by shifting left */
for (j = 0; j < filter2Size; j++) {
int k;
cutOff += FFABS(filter2[i * filter2Size]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
/* preserve monotonicity because the core can't handle the
* filter otherwise */
if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
break;
// move filter coefficients left
for (k = 1; k < filter2Size; k++)
filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
filter2[i * filter2Size + k - 1] = 0;
(*filterPos)[i]++;
}
cutOff = 0;
/* count near zeros on the right */
for (j = filter2Size - 1; j > 0; j--) {
cutOff += FFABS(filter2[i * filter2Size + j]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
min--;
}
if (min > minFilterSize)
minFilterSize = min;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
// we can handle the special case 4, so we don't want to go the full 8
if (minFilterSize < 5)
filterAlign = 4;
/* We really don't want to waste our time doing useless computation, so
* fall back on the scalar C code for very small filters.
* Vectorizing is worth it only if you have a decent-sized vector. */
if (minFilterSize < 3)
filterAlign = 1;
}
if (INLINE_MMX(cpu_flags)) {
// special case for unscaled vertical filtering
if (minFilterSize == 1 && filterAlign == 2)
filterAlign = 1;
}
assert(minFilterSize > 0);
filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
assert(filterSize > 0);
filter = av_malloc(filterSize * dstW * sizeof(*filter));
if (filterSize >= MAX_FILTER_SIZE * 16 /
((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize = filterSize;
if (flags & SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE,
"SwScaler: reducing / aligning filtersize %d -> %d\n",
filter2Size, filterSize);
/* try to reduce the filter-size (step2 reduce it) */
for (i = 0; i < dstW; i++) {
int j;
for (j = 0; j < filterSize; j++) {
if (j >= filter2Size)
filter[i * filterSize + j] = 0;
else
filter[i * filterSize + j] = filter2[i * filter2Size + j];
if ((flags & SWS_BITEXACT) && j >= minFilterSize)
filter[i * filterSize + j] = 0;
}
}
// FIXME try to align filterPos if possible
// fix borders
if (is_horizontal) {
for (i = 0; i < dstW; i++) {
int j;
if ((*filterPos)[i] < 0) {
// move filter coefficients left to compensate for filterPos
for (j = 1; j < filterSize; j++) {
int left = FFMAX(j + (*filterPos)[i], 0);
filter[i * filterSize + left] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = 0;
}
if ((*filterPos)[i] + filterSize > srcW) {
int shift = (*filterPos)[i] + filterSize - srcW;
// move filter coefficients right to compensate for filterPos
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = srcW - filterSize;
}
}
}
// Note the +1 is for the MMX scaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */
FF_ALLOCZ_OR_GOTO(NULL, *outFilter,
*outFilterSize * (dstW + 3) * sizeof(int16_t), fail);
/* normalize & store in outFilter */
for (i = 0; i < dstW; i++) {
int j;
int64_t error = 0;
int64_t sum = 0;
for (j = 0; j < filterSize; j++) {
sum += filter[i * filterSize + j];
}
sum = (sum + one / 2) / one;
for (j = 0; j < *outFilterSize; j++) {
int64_t v = filter[i * filterSize + j] + error;
int intV = ROUNDED_DIV(v, sum);
(*outFilter)[i * (*outFilterSize) + j] = intV;
error = v - intV * sum;
}
}
(*filterPos)[dstW + 0] =
(*filterPos)[dstW + 1] =
(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; /* the MMX/SSE scaler will
* read over the end */
for (i = 0; i < *outFilterSize; i++) {
int k = (dstW - 1) * (*outFilterSize) + i;
(*outFilter)[k + 1 * (*outFilterSize)] =
(*outFilter)[k + 2 * (*outFilterSize)] =
(*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
}
ret = 0;
fail:
av_free(filter);
av_free(filter2);
return ret;
}
| false | FFmpeg | f61bece684d9685b07895508e6c1c733b5564ccf | static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int *outFilterSize, int xInc, int srcW,
int dstW, int filterAlign, int one,
int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter,
double param[2], int is_horizontal)
{
int i;
int filterSize;
int filter2Size;
int minFilterSize;
int64_t *filter = NULL;
int64_t *filter2 = NULL;
const int64_t fone = 1LL << 54;
int ret = -1;
emms_c();
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10) {
int i;
filterSize = 1;
FF_ALLOCZ_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
for (i = 0; i < dstW; i++) {
filter[i * filterSize] = fone;
(*filterPos)[i] = i;
}
} else if (flags & SWS_POINT) {
int i;
int xDstInSrc;
filterSize = 1;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
(*filterPos)[i] = xx;
filter[i] = fone;
xDstInSrc += xInc;
}
} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||
(flags & SWS_FAST_BILINEAR)) {
int i;
int xDstInSrc;
filterSize = 2;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc / 2 - 0x8000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
int j;
(*filterPos)[i] = xx;
/ linear interpolate / area averaging
for (j = 0; j < filterSize; j++) {
int64_t coeff = fone - FFABS((xx << 16) - xDstInSrc) *
(fone >> 16);
if (coeff < 0)
coeff = 0;
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += xInc;
}
} else {
int64_t xDstInSrc;
int sizeFactor;
if (flags & SWS_BICUBIC)
sizeFactor = 4;
else if (flags & SWS_X)
sizeFactor = 8;
else if (flags & SWS_AREA)
sizeFactor = 1;
else if (flags & SWS_GAUSS)
sizeFactor = 8;
else if (flags & SWS_LANCZOS)
sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;
else if (flags & SWS_SINC)
sizeFactor = 20;
else if (flags & SWS_SPLINE)
sizeFactor = 20;
else if (flags & SWS_BILINEAR)
sizeFactor = 2;
else {
sizeFactor = 0;
assert(0);
}
if (xInc <= 1 << 16)
filterSize = 1 + sizeFactor;
else
filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
filterSize = FFMIN(filterSize, srcW - 2);
filterSize = FFMAX(filterSize, 1);
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail);
xDstInSrc = xInc - 0x10000;
for (i = 0; i < dstW; i++) {
int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
int j;
(*filterPos)[i] = xx;
for (j = 0; j < filterSize; j++) {
int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
double floatd;
int64_t coeff;
if (xInc > 1 << 16)
d = d * dstW / srcW;
floatd = d * (1.0 / (1 << 30));
if (flags & SWS_BICUBIC) {
int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);
int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);
if (d >= 1LL << 31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL << 30)
coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
(-18 * (1 << 24) + 12 * B + 6 * C) * dd +
(6 * (1 << 24) - 2 * B) * (1 << 30);
else
coeff = (-B - 6 * C) * ddd +
(6 * B + 30 * C) * dd +
(-12 * B - 48 * C) * d +
(8 * B + 24 * C) * (1 << 30);
}
coeff *= fone >> (30 + 24);
}
#if 0
else if (flags & SWS_X) {
double p = param ? param * 0.01 : 0.3;
coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
coeff *= pow(2.0, -p * d * d);
}
#endif
else if (flags & SWS_X) {
double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double c;
if (floatd < 1.0)
c = cos(floatd * M_PI);
else
c = -1.0;
if (c < 0.0)
c = -pow(-c, A);
else
c = pow(c, A);
coeff = (c * 0.5 + 0.5) * fone;
} else if (flags & SWS_AREA) {
int64_t d2 = d - (1 << 29);
if (d2 * xInc < -(1LL << (29 + 16)))
coeff = 1.0 * (1LL << (30 + 16));
else if (d2 * xInc < (1LL << (29 + 16)))
coeff = -d2 * xInc + (1LL << (29 + 16));
else
coeff = 0.0;
coeff *= fone >> (30 + 16);
} else if (flags & SWS_GAUSS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, -p * floatd * floatd)) * fone;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
} else if (flags & SWS_LANCZOS) {
double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
(floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
if (floatd > p)
coeff = 0;
} else if (flags & SWS_BILINEAR) {
coeff = (1 << 30) - d;
if (coeff < 0)
coeff = 0;
coeff *= fone >> 30;
} else if (flags & SWS_SPLINE) {
double p = -2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone;
} else {
coeff = 0.0;
assert(0);
}
filter[i * filterSize + j] = coeff;
xx++;
}
xDstInSrc += 2 * xInc;
}
}
assert(filterSize > 0);
filter2Size = filterSize;
if (srcFilter)
filter2Size += srcFilter->length - 1;
if (dstFilter)
filter2Size += dstFilter->length - 1;
assert(filter2Size > 0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail);
for (i = 0; i < dstW; i++) {
int j, k;
if (srcFilter) {
for (k = 0; k < srcFilter->length; k++) {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + k + j] +=
srcFilter->coeff[k] * filter[i * filterSize + j];
}
} else {
for (j = 0; j < filterSize; j++)
filter2[i * filter2Size + j] = filter[i * filterSize + j];
}
(*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
}
av_freep(&filter);
minFilterSize = 0;
for (i = dstW - 1; i >= 0; i--) {
int min = filter2Size;
int j;
int64_t cutOff = 0.0;
for (j = 0; j < filter2Size; j++) {
int k;
cutOff += FFABS(filter2[i * filter2Size]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
break;
for (k = 1; k < filter2Size; k++)
filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
filter2[i * filter2Size + k - 1] = 0;
(*filterPos)[i]++;
}
cutOff = 0;
for (j = filter2Size - 1; j > 0; j--) {
cutOff += FFABS(filter2[i * filter2Size + j]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
break;
min--;
}
if (min > minFilterSize)
minFilterSize = min;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
if (minFilterSize < 5)
filterAlign = 4;
if (minFilterSize < 3)
filterAlign = 1;
}
if (INLINE_MMX(cpu_flags)) {
if (minFilterSize == 1 && filterAlign == 2)
filterAlign = 1;
}
assert(minFilterSize > 0);
filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
assert(filterSize > 0);
filter = av_malloc(filterSize * dstW * sizeof(*filter));
if (filterSize >= MAX_FILTER_SIZE * 16 /
((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize = filterSize;
if (flags & SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE,
"SwScaler: reducing / aligning filtersize %d -> %d\n",
filter2Size, filterSize);
for (i = 0; i < dstW; i++) {
int j;
for (j = 0; j < filterSize; j++) {
if (j >= filter2Size)
filter[i * filterSize + j] = 0;
else
filter[i * filterSize + j] = filter2[i * filter2Size + j];
if ((flags & SWS_BITEXACT) && j >= minFilterSize)
filter[i * filterSize + j] = 0;
}
}
if (is_horizontal) {
for (i = 0; i < dstW; i++) {
int j;
if ((*filterPos)[i] < 0) {
to compensate for filterPos
for (j = 1; j < filterSize; j++) {
int left = FFMAX(j + (*filterPos)[i], 0);
filter[i * filterSize + left] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = 0;
}
if ((*filterPos)[i] + filterSize > srcW) {
int shift = (*filterPos)[i] + filterSize - srcW;
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
(*filterPos)[i] = srcW - filterSize;
}
}
}
FF_ALLOCZ_OR_GOTO(NULL, *outFilter,
*outFilterSize * (dstW + 3) * sizeof(int16_t), fail);
for (i = 0; i < dstW; i++) {
int j;
int64_t error = 0;
int64_t sum = 0;
for (j = 0; j < filterSize; j++) {
sum += filter[i * filterSize + j];
}
sum = (sum + one / 2) / one;
for (j = 0; j < *outFilterSize; j++) {
int64_t v = filter[i * filterSize + j] + error;
int intV = ROUNDED_DIV(v, sum);
(*outFilter)[i * (*outFilterSize) + j] = intV;
error = v - intV * sum;
}
}
(*filterPos)[dstW + 0] =
(*filterPos)[dstW + 1] =
(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
for (i = 0; i < *outFilterSize; i++) {
int k = (dstW - 1) * (*outFilterSize) + i;
(*outFilter)[k + 1 * (*outFilterSize)] =
(*outFilter)[k + 2 * (*outFilterSize)] =
(*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
}
ret = 0;
fail:
av_free(filter);
av_free(filter2);
return ret;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(int16_t **outFilter, int32_t **filterPos,
int *outFilterSize, int xInc, int srcW,
int dstW, int filterAlign, int one,
int flags, int cpu_flags,
SwsVector *srcFilter, SwsVector *dstFilter,
double param[2], int is_horizontal)
{
int VAR_8;
int VAR_1;
int VAR_2;
int VAR_3;
int64_t *filter = NULL;
int64_t *filter2 = NULL;
const int64_t VAR_4 = 1LL << 54;
int VAR_5 = -1;
emms_c();
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10) {
int VAR_8;
VAR_1 = 1;
FF_ALLOCZ_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * VAR_1, fail);
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
filter[VAR_8 * VAR_1] = VAR_4;
(*filterPos)[VAR_8] = VAR_8;
}
} else if (flags & SWS_POINT) {
int VAR_8;
int VAR_8;
VAR_1 = 1;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * VAR_1, fail);
VAR_8 = xInc / 2 - 0x8000;
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_10 = (VAR_8 - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;
(*filterPos)[VAR_8] = VAR_10;
filter[VAR_8] = VAR_4;
VAR_8 += xInc;
}
} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||
(flags & SWS_FAST_BILINEAR)) {
int VAR_8;
int VAR_8;
VAR_1 = 2;
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * VAR_1, fail);
VAR_8 = xInc / 2 - 0x8000;
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_10 = (VAR_8 - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;
int VAR_18;
(*filterPos)[VAR_8] = VAR_10;
/ linear interpolate / area averaging
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {
int64_t coeff = VAR_4 - FFABS((VAR_10 << 16) - VAR_8) *
(VAR_4 >> 16);
if (coeff < 0)
coeff = 0;
filter[VAR_8 * VAR_1 + VAR_18] = coeff;
VAR_10++;
}
VAR_8 += xInc;
}
} else {
int64_t VAR_8;
int VAR_9;
if (flags & SWS_BICUBIC)
VAR_9 = 4;
else if (flags & SWS_X)
VAR_9 = 8;
else if (flags & SWS_AREA)
VAR_9 = 1;
else if (flags & SWS_GAUSS)
VAR_9 = 8;
else if (flags & SWS_LANCZOS)
VAR_9 = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;
else if (flags & SWS_SINC)
VAR_9 = 20;
else if (flags & SWS_SPLINE)
VAR_9 = 20;
else if (flags & SWS_BILINEAR)
VAR_9 = 2;
else {
VAR_9 = 0;
assert(0);
}
if (xInc <= 1 << 16)
VAR_1 = 1 + VAR_9;
else
VAR_1 = 1 + (VAR_9 * srcW + dstW - 1) / dstW;
VAR_1 = FFMIN(VAR_1, srcW - 2);
VAR_1 = FFMAX(VAR_1, 1);
FF_ALLOC_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * VAR_1, fail);
VAR_8 = xInc - 0x10000;
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_10 = (VAR_8 - ((VAR_1 - 2) << 16)) / (1 << 17);
int VAR_18;
(*filterPos)[VAR_8] = VAR_10;
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {
int64_t d = (FFABS(((int64_t)VAR_10 << 17) - VAR_8)) << 13;
double VAR_10;
int64_t coeff;
if (xInc > 1 << 16)
d = d * dstW / srcW;
VAR_10 = d * (1.0 / (1 << 30));
if (flags & SWS_BICUBIC) {
int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);
int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);
if (d >= 1LL << 31) {
coeff = 0.0;
} else {
int64_t dd = (d * d) >> 30;
int64_t ddd = (dd * d) >> 30;
if (d < 1LL << 30)
coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
(-18 * (1 << 24) + 12 * B + 6 * C) * dd +
(6 * (1 << 24) - 2 * B) * (1 << 30);
else
coeff = (-B - 6 * C) * ddd +
(6 * B + 30 * C) * dd +
(-12 * B - 48 * C) * d +
(8 * B + 24 * C) * (1 << 30);
}
coeff *= VAR_4 >> (30 + 24);
}
#if 0
else if (flags & SWS_X) {
double VAR_14 = param ? param * 0.01 : 0.3;
coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
coeff *= pow(2.0, -VAR_14 * d * d);
}
#endif
else if (flags & SWS_X) {
double VAR_11 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
double VAR_12;
if (VAR_10 < 1.0)
VAR_12 = cos(VAR_10 * M_PI);
else
VAR_12 = -1.0;
if (VAR_12 < 0.0)
VAR_12 = -pow(-VAR_12, VAR_11);
else
VAR_12 = pow(VAR_12, VAR_11);
coeff = (VAR_12 * 0.5 + 0.5) * VAR_4;
} else if (flags & SWS_AREA) {
int64_t d2 = d - (1 << 29);
if (d2 * xInc < -(1LL << (29 + 16)))
coeff = 1.0 * (1LL << (30 + 16));
else if (d2 * xInc < (1LL << (29 + 16)))
coeff = -d2 * xInc + (1LL << (29 + 16));
else
coeff = 0.0;
coeff *= VAR_4 >> (30 + 16);
} else if (flags & SWS_GAUSS) {
double VAR_14 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (pow(2.0, -VAR_14 * VAR_10 * VAR_10)) * VAR_4;
} else if (flags & SWS_SINC) {
coeff = (d ? sin(VAR_10 * M_PI) / (VAR_10 * M_PI) : 1.0) * VAR_4;
} else if (flags & SWS_LANCZOS) {
double VAR_14 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
coeff = (d ? sin(VAR_10 * M_PI) * sin(VAR_10 * M_PI / VAR_14) /
(VAR_10 * VAR_10 * M_PI * M_PI / VAR_14) : 1.0) * VAR_4;
if (VAR_10 > VAR_14)
coeff = 0;
} else if (flags & SWS_BILINEAR) {
coeff = (1 << 30) - d;
if (coeff < 0)
coeff = 0;
coeff *= VAR_4 >> 30;
} else if (flags & SWS_SPLINE) {
double VAR_14 = -2.196152422706632;
coeff = getSplineCoeff(1.0, 0.0, VAR_14, -VAR_14 - 1.0, VAR_10) * VAR_4;
} else {
coeff = 0.0;
assert(0);
}
filter[VAR_8 * VAR_1 + VAR_18] = coeff;
VAR_10++;
}
VAR_8 += 2 * xInc;
}
}
assert(VAR_1 > 0);
VAR_2 = VAR_1;
if (srcFilter)
VAR_2 += srcFilter->length - 1;
if (dstFilter)
VAR_2 += dstFilter->length - 1;
assert(VAR_2 > 0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, VAR_2 * dstW * sizeof(*filter2), fail);
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_18, VAR_19;
if (srcFilter) {
for (VAR_19 = 0; VAR_19 < srcFilter->length; VAR_19++) {
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++)
filter2[VAR_8 * VAR_2 + VAR_19 + VAR_18] +=
srcFilter->coeff[VAR_19] * filter[VAR_8 * VAR_1 + VAR_18];
}
} else {
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++)
filter2[VAR_8 * VAR_2 + VAR_18] = filter[VAR_8 * VAR_1 + VAR_18];
}
(*filterPos)[VAR_8] += (VAR_1 - 1) / 2 - (VAR_2 - 1) / 2;
}
av_freep(&filter);
VAR_3 = 0;
for (VAR_8 = dstW - 1; VAR_8 >= 0; VAR_8--) {
int VAR_15 = VAR_2;
int VAR_18;
int64_t cutOff = 0.0;
for (VAR_18 = 0; VAR_18 < VAR_2; VAR_18++) {
int VAR_19;
cutOff += FFABS(filter2[VAR_8 * VAR_2]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)
break;
if (VAR_8 < dstW - 1 && (*filterPos)[VAR_8] >= (*filterPos)[VAR_8 + 1])
break;
for (VAR_19 = 1; VAR_19 < VAR_2; VAR_19++)
filter2[VAR_8 * VAR_2 + VAR_19 - 1] = filter2[VAR_8 * VAR_2 + VAR_19];
filter2[VAR_8 * VAR_2 + VAR_19 - 1] = 0;
(*filterPos)[VAR_8]++;
}
cutOff = 0;
for (VAR_18 = VAR_2 - 1; VAR_18 > 0; VAR_18--) {
cutOff += FFABS(filter2[VAR_8 * VAR_2 + VAR_18]);
if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)
break;
VAR_15--;
}
if (VAR_15 > VAR_3)
VAR_3 = VAR_15;
}
if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
if (VAR_3 < 5)
filterAlign = 4;
if (VAR_3 < 3)
filterAlign = 1;
}
if (INLINE_MMX(cpu_flags)) {
if (VAR_3 == 1 && filterAlign == 2)
filterAlign = 1;
}
assert(VAR_3 > 0);
VAR_1 = (VAR_3 + (filterAlign - 1)) & (~(filterAlign - 1));
assert(VAR_1 > 0);
filter = av_malloc(VAR_1 * dstW * sizeof(*filter));
if (VAR_1 >= MAX_FILTER_SIZE * 16 /
((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)
goto fail;
*outFilterSize = VAR_1;
if (flags & SWS_PRINT_INFO)
av_log(NULL, AV_LOG_VERBOSE,
"SwScaler: reducing / aligning filtersize %d -> %d\n",
VAR_2, VAR_1);
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_18;
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {
if (VAR_18 >= VAR_2)
filter[VAR_8 * VAR_1 + VAR_18] = 0;
else
filter[VAR_8 * VAR_1 + VAR_18] = filter2[VAR_8 * VAR_2 + VAR_18];
if ((flags & SWS_BITEXACT) && VAR_18 >= VAR_3)
filter[VAR_8 * VAR_1 + VAR_18] = 0;
}
}
if (is_horizontal) {
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_18;
if ((*filterPos)[VAR_8] < 0) {
to compensate for filterPos
for (VAR_18 = 1; VAR_18 < VAR_1; VAR_18++) {
int left = FFMAX(VAR_18 + (*filterPos)[VAR_8], 0);
filter[VAR_8 * VAR_1 + left] += filter[VAR_8 * VAR_1 + VAR_18];
filter[VAR_8 * VAR_1 + VAR_18] = 0;
}
(*filterPos)[VAR_8] = 0;
}
if ((*filterPos)[VAR_8] + VAR_1 > srcW) {
int VAR_16 = (*filterPos)[VAR_8] + VAR_1 - srcW;
for (VAR_18 = VAR_1 - 2; VAR_18 >= 0; VAR_18--) {
int VAR_17 = FFMIN(VAR_18 + VAR_16, VAR_1 - 1);
filter[VAR_8 * VAR_1 + VAR_17] += filter[VAR_8 * VAR_1 + VAR_18];
filter[VAR_8 * VAR_1 + VAR_18] = 0;
}
(*filterPos)[VAR_8] = srcW - VAR_1;
}
}
}
FF_ALLOCZ_OR_GOTO(NULL, *outFilter,
*outFilterSize * (dstW + 3) * sizeof(int16_t), fail);
for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {
int VAR_18;
int64_t error = 0;
int64_t sum = 0;
for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {
sum += filter[VAR_8 * VAR_1 + VAR_18];
}
sum = (sum + one / 2) / one;
for (VAR_18 = 0; VAR_18 < *outFilterSize; VAR_18++) {
int64_t v = filter[VAR_8 * VAR_1 + VAR_18] + error;
int VAR_18 = ROUNDED_DIV(v, sum);
(*outFilter)[VAR_8 * (*outFilterSize) + VAR_18] = VAR_18;
error = v - VAR_18 * sum;
}
}
(*filterPos)[dstW + 0] =
(*filterPos)[dstW + 1] =
(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
for (VAR_8 = 0; VAR_8 < *outFilterSize; VAR_8++) {
int VAR_19 = (dstW - 1) * (*outFilterSize) + VAR_8;
(*outFilter)[VAR_19 + 1 * (*outFilterSize)] =
(*outFilter)[VAR_19 + 2 * (*outFilterSize)] =
(*outFilter)[VAR_19 + 3 * (*outFilterSize)] = (*outFilter)[VAR_19];
}
VAR_5 = 0;
fail:
av_free(filter);
av_free(filter2);
return VAR_5;
}
| [
"static av_cold int FUNC_0(int16_t **outFilter, int32_t **filterPos,\nint *outFilterSize, int xInc, int srcW,\nint dstW, int filterAlign, int one,\nint flags, int cpu_flags,\nSwsVector *srcFilter, SwsVector *dstFilter,\ndouble param[2], int is_horizontal)\n{",
"int VAR_8;",
"int VAR_1;",
"int VAR_2;",
"int VAR_3;",
"int64_t *filter = NULL;",
"int64_t *filter2 = NULL;",
"const int64_t VAR_4 = 1LL << 54;",
"int VAR_5 = -1;",
"emms_c();",
"FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);",
"if (FFABS(xInc - 0x10000) < 10) {",
"int VAR_8;",
"VAR_1 = 1;",
"FF_ALLOCZ_OR_GOTO(NULL, filter,\ndstW * sizeof(*filter) * VAR_1, fail);",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"filter[VAR_8 * VAR_1] = VAR_4;",
"(*filterPos)[VAR_8] = VAR_8;",
"}",
"} else if (flags & SWS_POINT) {",
"int VAR_8;",
"int VAR_8;",
"VAR_1 = 1;",
"FF_ALLOC_OR_GOTO(NULL, filter,\ndstW * sizeof(*filter) * VAR_1, fail);",
"VAR_8 = xInc / 2 - 0x8000;",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_10 = (VAR_8 - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;",
"(*filterPos)[VAR_8] = VAR_10;",
"filter[VAR_8] = VAR_4;",
"VAR_8 += xInc;",
"}",
"} else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||",
"(flags & SWS_FAST_BILINEAR)) {",
"int VAR_8;",
"int VAR_8;",
"VAR_1 = 2;",
"FF_ALLOC_OR_GOTO(NULL, filter,\ndstW * sizeof(*filter) * VAR_1, fail);",
"VAR_8 = xInc / 2 - 0x8000;",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_10 = (VAR_8 - ((VAR_1 - 1) << 15) + (1 << 15)) >> 16;",
"int VAR_18;",
"(*filterPos)[VAR_8] = VAR_10;",
"/ linear interpolate / area averaging\nfor (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {",
"int64_t coeff = VAR_4 - FFABS((VAR_10 << 16) - VAR_8) *\n(VAR_4 >> 16);",
"if (coeff < 0)\ncoeff = 0;",
"filter[VAR_8 * VAR_1 + VAR_18] = coeff;",
"VAR_10++;",
"}",
"VAR_8 += xInc;",
"}",
"} else {",
"int64_t VAR_8;",
"int VAR_9;",
"if (flags & SWS_BICUBIC)\nVAR_9 = 4;",
"else if (flags & SWS_X)\nVAR_9 = 8;",
"else if (flags & SWS_AREA)\nVAR_9 = 1;",
"else if (flags & SWS_GAUSS)\nVAR_9 = 8;",
"else if (flags & SWS_LANCZOS)\nVAR_9 = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;",
"else if (flags & SWS_SINC)\nVAR_9 = 20;",
"else if (flags & SWS_SPLINE)\nVAR_9 = 20;",
"else if (flags & SWS_BILINEAR)\nVAR_9 = 2;",
"else {",
"VAR_9 = 0;",
"assert(0);",
"}",
"if (xInc <= 1 << 16)\nVAR_1 = 1 + VAR_9;",
"else\nVAR_1 = 1 + (VAR_9 * srcW + dstW - 1) / dstW;",
"VAR_1 = FFMIN(VAR_1, srcW - 2);",
"VAR_1 = FFMAX(VAR_1, 1);",
"FF_ALLOC_OR_GOTO(NULL, filter,\ndstW * sizeof(*filter) * VAR_1, fail);",
"VAR_8 = xInc - 0x10000;",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_10 = (VAR_8 - ((VAR_1 - 2) << 16)) / (1 << 17);",
"int VAR_18;",
"(*filterPos)[VAR_8] = VAR_10;",
"for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {",
"int64_t d = (FFABS(((int64_t)VAR_10 << 17) - VAR_8)) << 13;",
"double VAR_10;",
"int64_t coeff;",
"if (xInc > 1 << 16)\nd = d * dstW / srcW;",
"VAR_10 = d * (1.0 / (1 << 30));",
"if (flags & SWS_BICUBIC) {",
"int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);",
"int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);",
"if (d >= 1LL << 31) {",
"coeff = 0.0;",
"} else {",
"int64_t dd = (d * d) >> 30;",
"int64_t ddd = (dd * d) >> 30;",
"if (d < 1LL << 30)\ncoeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +\n(-18 * (1 << 24) + 12 * B + 6 * C) * dd +\n(6 * (1 << 24) - 2 * B) * (1 << 30);",
"else\ncoeff = (-B - 6 * C) * ddd +\n(6 * B + 30 * C) * dd +\n(-12 * B - 48 * C) * d +\n(8 * B + 24 * C) * (1 << 30);",
"}",
"coeff *= VAR_4 >> (30 + 24);",
"}",
"#if 0\nelse if (flags & SWS_X) {",
"double VAR_14 = param ? param * 0.01 : 0.3;",
"coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;",
"coeff *= pow(2.0, -VAR_14 * d * d);",
"}",
"#endif\nelse if (flags & SWS_X) {",
"double VAR_11 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;",
"double VAR_12;",
"if (VAR_10 < 1.0)\nVAR_12 = cos(VAR_10 * M_PI);",
"else\nVAR_12 = -1.0;",
"if (VAR_12 < 0.0)\nVAR_12 = -pow(-VAR_12, VAR_11);",
"else\nVAR_12 = pow(VAR_12, VAR_11);",
"coeff = (VAR_12 * 0.5 + 0.5) * VAR_4;",
"} else if (flags & SWS_AREA) {",
"int64_t d2 = d - (1 << 29);",
"if (d2 * xInc < -(1LL << (29 + 16)))\ncoeff = 1.0 * (1LL << (30 + 16));",
"else if (d2 * xInc < (1LL << (29 + 16)))\ncoeff = -d2 * xInc + (1LL << (29 + 16));",
"else\ncoeff = 0.0;",
"coeff *= VAR_4 >> (30 + 16);",
"} else if (flags & SWS_GAUSS) {",
"double VAR_14 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;",
"coeff = (pow(2.0, -VAR_14 * VAR_10 * VAR_10)) * VAR_4;",
"} else if (flags & SWS_SINC) {",
"coeff = (d ? sin(VAR_10 * M_PI) / (VAR_10 * M_PI) : 1.0) * VAR_4;",
"} else if (flags & SWS_LANCZOS) {",
"double VAR_14 = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;",
"coeff = (d ? sin(VAR_10 * M_PI) * sin(VAR_10 * M_PI / VAR_14) /\n(VAR_10 * VAR_10 * M_PI * M_PI / VAR_14) : 1.0) * VAR_4;",
"if (VAR_10 > VAR_14)\ncoeff = 0;",
"} else if (flags & SWS_BILINEAR) {",
"coeff = (1 << 30) - d;",
"if (coeff < 0)\ncoeff = 0;",
"coeff *= VAR_4 >> 30;",
"} else if (flags & SWS_SPLINE) {",
"double VAR_14 = -2.196152422706632;",
"coeff = getSplineCoeff(1.0, 0.0, VAR_14, -VAR_14 - 1.0, VAR_10) * VAR_4;",
"} else {",
"coeff = 0.0;",
"assert(0);",
"}",
"filter[VAR_8 * VAR_1 + VAR_18] = coeff;",
"VAR_10++;",
"}",
"VAR_8 += 2 * xInc;",
"}",
"}",
"assert(VAR_1 > 0);",
"VAR_2 = VAR_1;",
"if (srcFilter)\nVAR_2 += srcFilter->length - 1;",
"if (dstFilter)\nVAR_2 += dstFilter->length - 1;",
"assert(VAR_2 > 0);",
"FF_ALLOCZ_OR_GOTO(NULL, filter2, VAR_2 * dstW * sizeof(*filter2), fail);",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_18, VAR_19;",
"if (srcFilter) {",
"for (VAR_19 = 0; VAR_19 < srcFilter->length; VAR_19++) {",
"for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++)",
"filter2[VAR_8 * VAR_2 + VAR_19 + VAR_18] +=\nsrcFilter->coeff[VAR_19] * filter[VAR_8 * VAR_1 + VAR_18];",
"}",
"} else {",
"for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++)",
"filter2[VAR_8 * VAR_2 + VAR_18] = filter[VAR_8 * VAR_1 + VAR_18];",
"}",
"(*filterPos)[VAR_8] += (VAR_1 - 1) / 2 - (VAR_2 - 1) / 2;",
"}",
"av_freep(&filter);",
"VAR_3 = 0;",
"for (VAR_8 = dstW - 1; VAR_8 >= 0; VAR_8--) {",
"int VAR_15 = VAR_2;",
"int VAR_18;",
"int64_t cutOff = 0.0;",
"for (VAR_18 = 0; VAR_18 < VAR_2; VAR_18++) {",
"int VAR_19;",
"cutOff += FFABS(filter2[VAR_8 * VAR_2]);",
"if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)\nbreak;",
"if (VAR_8 < dstW - 1 && (*filterPos)[VAR_8] >= (*filterPos)[VAR_8 + 1])\nbreak;",
"for (VAR_19 = 1; VAR_19 < VAR_2; VAR_19++)",
"filter2[VAR_8 * VAR_2 + VAR_19 - 1] = filter2[VAR_8 * VAR_2 + VAR_19];",
"filter2[VAR_8 * VAR_2 + VAR_19 - 1] = 0;",
"(*filterPos)[VAR_8]++;",
"}",
"cutOff = 0;",
"for (VAR_18 = VAR_2 - 1; VAR_18 > 0; VAR_18--) {",
"cutOff += FFABS(filter2[VAR_8 * VAR_2 + VAR_18]);",
"if (cutOff > SWS_MAX_REDUCE_CUTOFF * VAR_4)\nbreak;",
"VAR_15--;",
"}",
"if (VAR_15 > VAR_3)\nVAR_3 = VAR_15;",
"}",
"if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {",
"if (VAR_3 < 5)\nfilterAlign = 4;",
"if (VAR_3 < 3)\nfilterAlign = 1;",
"}",
"if (INLINE_MMX(cpu_flags)) {",
"if (VAR_3 == 1 && filterAlign == 2)\nfilterAlign = 1;",
"}",
"assert(VAR_3 > 0);",
"VAR_1 = (VAR_3 + (filterAlign - 1)) & (~(filterAlign - 1));",
"assert(VAR_1 > 0);",
"filter = av_malloc(VAR_1 * dstW * sizeof(*filter));",
"if (VAR_1 >= MAX_FILTER_SIZE * 16 /\n((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter)\ngoto fail;",
"*outFilterSize = VAR_1;",
"if (flags & SWS_PRINT_INFO)\nav_log(NULL, AV_LOG_VERBOSE,\n\"SwScaler: reducing / aligning filtersize %d -> %d\\n\",\nVAR_2, VAR_1);",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_18;",
"for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {",
"if (VAR_18 >= VAR_2)\nfilter[VAR_8 * VAR_1 + VAR_18] = 0;",
"else\nfilter[VAR_8 * VAR_1 + VAR_18] = filter2[VAR_8 * VAR_2 + VAR_18];",
"if ((flags & SWS_BITEXACT) && VAR_18 >= VAR_3)\nfilter[VAR_8 * VAR_1 + VAR_18] = 0;",
"}",
"}",
"if (is_horizontal) {",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_18;",
"if ((*filterPos)[VAR_8] < 0) {",
"to compensate for filterPos\nfor (VAR_18 = 1; VAR_18 < VAR_1; VAR_18++) {",
"int left = FFMAX(VAR_18 + (*filterPos)[VAR_8], 0);",
"filter[VAR_8 * VAR_1 + left] += filter[VAR_8 * VAR_1 + VAR_18];",
"filter[VAR_8 * VAR_1 + VAR_18] = 0;",
"}",
"(*filterPos)[VAR_8] = 0;",
"}",
"if ((*filterPos)[VAR_8] + VAR_1 > srcW) {",
"int VAR_16 = (*filterPos)[VAR_8] + VAR_1 - srcW;",
"for (VAR_18 = VAR_1 - 2; VAR_18 >= 0; VAR_18--) {",
"int VAR_17 = FFMIN(VAR_18 + VAR_16, VAR_1 - 1);",
"filter[VAR_8 * VAR_1 + VAR_17] += filter[VAR_8 * VAR_1 + VAR_18];",
"filter[VAR_8 * VAR_1 + VAR_18] = 0;",
"}",
"(*filterPos)[VAR_8] = srcW - VAR_1;",
"}",
"}",
"}",
"FF_ALLOCZ_OR_GOTO(NULL, *outFilter,\n*outFilterSize * (dstW + 3) * sizeof(int16_t), fail);",
"for (VAR_8 = 0; VAR_8 < dstW; VAR_8++) {",
"int VAR_18;",
"int64_t error = 0;",
"int64_t sum = 0;",
"for (VAR_18 = 0; VAR_18 < VAR_1; VAR_18++) {",
"sum += filter[VAR_8 * VAR_1 + VAR_18];",
"}",
"sum = (sum + one / 2) / one;",
"for (VAR_18 = 0; VAR_18 < *outFilterSize; VAR_18++) {",
"int64_t v = filter[VAR_8 * VAR_1 + VAR_18] + error;",
"int VAR_18 = ROUNDED_DIV(v, sum);",
"(*outFilter)[VAR_8 * (*outFilterSize) + VAR_18] = VAR_18;",
"error = v - VAR_18 * sum;",
"}",
"}",
"(*filterPos)[dstW + 0] =\n(*filterPos)[dstW + 1] =\n(*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];",
"for (VAR_8 = 0; VAR_8 < *outFilterSize; VAR_8++) {",
"int VAR_19 = (dstW - 1) * (*outFilterSize) + VAR_8;",
"(*outFilter)[VAR_19 + 1 * (*outFilterSize)] =\n(*outFilter)[VAR_19 + 2 * (*outFilterSize)] =\n(*outFilter)[VAR_19 + 3 * (*outFilterSize)] = (*outFilter)[VAR_19];",
"}",
"VAR_5 = 0;",
"fail:\nav_free(filter);",
"av_free(filter2);",
"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
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121,
123
],
[
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151,
153
],
[
155,
157
],
[
159,
161
],
[
163,
165
],
[
167,
169
],
[
171,
173
],
[
175,
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193,
195
],
[
197,
199
],
[
203
],
[
205
],
[
209,
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235,
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263,
265,
267,
269
],
[
271,
273,
275,
277,
279
],
[
281
],
[
283
],
[
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
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
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
413
],
[
415
],
[
417,
419
],
[
421,
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
437
],
[
439
],
[
441
],
[
443,
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
461
],
[
463
],
[
465
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
487
],
[
489
],
[
491
],
[
495,
497
],
[
505,
507
],
[
513
],
[
515
],
[
517
],
[
519
],
[
521
],
[
525
],
[
529
],
[
531
],
[
535,
537
],
[
539
],
[
541
],
[
545,
547
],
[
549
],
[
553
],
[
557,
559
],
[
569,
571
],
[
573
],
[
577
],
[
581,
583
],
[
585
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597,
599,
601
],
[
603
],
[
607,
609,
611,
613
],
[
617
],
[
619
],
[
623
],
[
625,
627
],
[
629,
631
],
[
633,
635
],
[
637
],
[
639
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657,
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
669
],
[
671
],
[
675
],
[
677
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
695
],
[
697
],
[
705,
707
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
747,
749,
751
],
[
755
],
[
757
],
[
759,
761,
763
],
[
765
],
[
769
],
[
773,
775
],
[
777
],
[
779
],
[
781
]
] |
25,673 | int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
const void *symbols, int symbols_wrap, int symbols_size,
int flags)
{
VLCcode *buf;
int i, j, ret;
vlc->bits = nb_bits;
if (flags & INIT_VLC_USE_NEW_STATIC) {
VLC dyn_vlc = *vlc;
if (vlc->table_size)
return 0;
ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
symbols, symbols_wrap, symbols_size,
flags & ~INIT_VLC_USE_NEW_STATIC);
av_assert0(ret >= 0);
av_assert0(dyn_vlc.table_size <= vlc->table_allocated);
if (dyn_vlc.table_size < vlc->table_allocated)
av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated);
memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table));
vlc->table_size = dyn_vlc.table_size;
ff_free_vlc(&dyn_vlc);
return 0;
} else {
vlc->table = NULL;
vlc->table_allocated = 0;
vlc->table_size = 0;
}
av_dlog(NULL, "build table nb_codes=%d\n", nb_codes);
buf = av_malloc((nb_codes + 1) * sizeof(VLCcode));
av_assert0(symbols_size <= 2 || !symbols);
j = 0;
#define COPY(condition)\
for (i = 0; i < nb_codes; i++) { \
GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size); \
if (!(condition)) \
continue; \
if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \
av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
av_free(buf); \
return -1; \
} \
GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
if (buf[j].code >= (1LL<<buf[j].bits)) { \
av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n"); \
av_free(buf); \
return -1; \
} \
if (flags & INIT_VLC_LE) \
buf[j].code = bitswap_32(buf[j].code); \
else \
buf[j].code <<= 32 - buf[j].bits; \
if (symbols) \
GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
else \
buf[j].symbol = i; \
j++; \
}
COPY(buf[j].bits > nb_bits);
// qsort is the slowest part of init_vlc, and could probably be improved or avoided
qsort(buf, j, sizeof(VLCcode), compare_vlcspec);
COPY(buf[j].bits && buf[j].bits <= nb_bits);
nb_codes = j;
ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
av_free(buf);
if (ret < 0) {
av_freep(&vlc->table);
return ret;
}
return 0;
} | true | FFmpeg | aa74810fc6b9afe21c9be3725e3d078d10633670 | int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
const void *symbols, int symbols_wrap, int symbols_size,
int flags)
{
VLCcode *buf;
int i, j, ret;
vlc->bits = nb_bits;
if (flags & INIT_VLC_USE_NEW_STATIC) {
VLC dyn_vlc = *vlc;
if (vlc->table_size)
return 0;
ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
symbols, symbols_wrap, symbols_size,
flags & ~INIT_VLC_USE_NEW_STATIC);
av_assert0(ret >= 0);
av_assert0(dyn_vlc.table_size <= vlc->table_allocated);
if (dyn_vlc.table_size < vlc->table_allocated)
av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated);
memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table));
vlc->table_size = dyn_vlc.table_size;
ff_free_vlc(&dyn_vlc);
return 0;
} else {
vlc->table = NULL;
vlc->table_allocated = 0;
vlc->table_size = 0;
}
av_dlog(NULL, "build table nb_codes=%d\n", nb_codes);
buf = av_malloc((nb_codes + 1) * sizeof(VLCcode));
av_assert0(symbols_size <= 2 || !symbols);
j = 0;
#define COPY(condition)\
for (i = 0; i < nb_codes; i++) { \
GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size); \
if (!(condition)) \
continue; \
if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \
av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
av_free(buf); \
return -1; \
} \
GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
if (buf[j].code >= (1LL<<buf[j].bits)) { \
av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n"); \
av_free(buf); \
return -1; \
} \
if (flags & INIT_VLC_LE) \
buf[j].code = bitswap_32(buf[j].code); \
else \
buf[j].code <<= 32 - buf[j].bits; \
if (symbols) \
GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size) \
else \
buf[j].symbol = i; \
j++; \
}
COPY(buf[j].bits > nb_bits);
qsort(buf, j, sizeof(VLCcode), compare_vlcspec);
COPY(buf[j].bits && buf[j].bits <= nb_bits);
nb_codes = j;
ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
av_free(buf);
if (ret < 0) {
av_freep(&vlc->table);
return ret;
}
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(VLC *VAR_0, int VAR_1, int VAR_2,
const void *VAR_3, int VAR_4, int VAR_5,
const void *VAR_6, int VAR_7, int VAR_8,
const void *VAR_9, int VAR_10, int VAR_11,
int VAR_12)
{
VLCcode *buf;
int VAR_13, VAR_14, VAR_15;
VAR_0->VAR_3 = VAR_1;
if (VAR_12 & INIT_VLC_USE_NEW_STATIC) {
VLC dyn_vlc = *VAR_0;
if (VAR_0->table_size)
return 0;
VAR_15 = FUNC_0(&dyn_vlc, VAR_1, VAR_2,
VAR_3, VAR_4, VAR_5,
VAR_6, VAR_7, VAR_8,
VAR_9, VAR_10, VAR_11,
VAR_12 & ~INIT_VLC_USE_NEW_STATIC);
av_assert0(VAR_15 >= 0);
av_assert0(dyn_vlc.table_size <= VAR_0->table_allocated);
if (dyn_vlc.table_size < VAR_0->table_allocated)
av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, VAR_0->table_allocated);
memcpy(VAR_0->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*VAR_0->table));
VAR_0->table_size = dyn_vlc.table_size;
ff_free_vlc(&dyn_vlc);
return 0;
} else {
VAR_0->table = NULL;
VAR_0->table_allocated = 0;
VAR_0->table_size = 0;
}
av_dlog(NULL, "build table VAR_2=%d\n", VAR_2);
buf = av_malloc((VAR_2 + 1) * sizeof(VLCcode));
av_assert0(VAR_11 <= 2 || !VAR_9);
VAR_14 = 0;
#define COPY(condition)\
for (VAR_13 = 0; VAR_13 < VAR_2; VAR_13++) { \
GET_DATA(buf[VAR_14].VAR_3, VAR_3, VAR_13, VAR_4, VAR_5); \
if (!(condition)) \
continue; \
if (buf[VAR_14].VAR_3 > 3*VAR_1 || buf[VAR_14].VAR_3>32) { \
av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[VAR_14].VAR_3);\
av_free(buf); \
return -1; \
} \
GET_DATA(buf[VAR_14].code, VAR_6, VAR_13, VAR_7, VAR_8); \
if (buf[VAR_14].code >= (1LL<<buf[VAR_14].VAR_3)) { \
av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n"); \
av_free(buf); \
return -1; \
} \
if (VAR_12 & INIT_VLC_LE) \
buf[VAR_14].code = bitswap_32(buf[VAR_14].code); \
else \
buf[VAR_14].code <<= 32 - buf[VAR_14].VAR_3; \
if (VAR_9) \
GET_DATA(buf[VAR_14].symbol, VAR_9, VAR_13, VAR_10, VAR_11) \
else \
buf[VAR_14].symbol = VAR_13; \
VAR_14++; \
}
COPY(buf[VAR_14].VAR_3 > VAR_1);
qsort(buf, VAR_14, sizeof(VLCcode), compare_vlcspec);
COPY(buf[VAR_14].VAR_3 && buf[VAR_14].VAR_3 <= VAR_1);
VAR_2 = VAR_14;
VAR_15 = build_table(VAR_0, VAR_1, VAR_2, buf, VAR_12);
av_free(buf);
if (VAR_15 < 0) {
av_freep(&VAR_0->table);
return VAR_15;
}
return 0;
} | [
"int FUNC_0(VLC *VAR_0, int VAR_1, int VAR_2,\nconst void *VAR_3, int VAR_4, int VAR_5,\nconst void *VAR_6, int VAR_7, int VAR_8,\nconst void *VAR_9, int VAR_10, int VAR_11,\nint VAR_12)\n{",
"VLCcode *buf;",
"int VAR_13, VAR_14, VAR_15;",
"VAR_0->VAR_3 = VAR_1;",
"if (VAR_12 & INIT_VLC_USE_NEW_STATIC) {",
"VLC dyn_vlc = *VAR_0;",
"if (VAR_0->table_size)\nreturn 0;",
"VAR_15 = FUNC_0(&dyn_vlc, VAR_1, VAR_2,\nVAR_3, VAR_4, VAR_5,\nVAR_6, VAR_7, VAR_8,\nVAR_9, VAR_10, VAR_11,\nVAR_12 & ~INIT_VLC_USE_NEW_STATIC);",
"av_assert0(VAR_15 >= 0);",
"av_assert0(dyn_vlc.table_size <= VAR_0->table_allocated);",
"if (dyn_vlc.table_size < VAR_0->table_allocated)\nav_log(NULL, AV_LOG_ERROR, \"needed %d had %d\\n\", dyn_vlc.table_size, VAR_0->table_allocated);",
"memcpy(VAR_0->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*VAR_0->table));",
"VAR_0->table_size = dyn_vlc.table_size;",
"ff_free_vlc(&dyn_vlc);",
"return 0;",
"} else {",
"VAR_0->table = NULL;",
"VAR_0->table_allocated = 0;",
"VAR_0->table_size = 0;",
"}",
"av_dlog(NULL, \"build table VAR_2=%d\\n\", VAR_2);",
"buf = av_malloc((VAR_2 + 1) * sizeof(VLCcode));",
"av_assert0(VAR_11 <= 2 || !VAR_9);",
"VAR_14 = 0;",
"#define COPY(condition)\\\nfor (VAR_13 = 0; VAR_13 < VAR_2; VAR_13++) { \\",
"GET_DATA(buf[VAR_14].VAR_3, VAR_3, VAR_13, VAR_4, VAR_5); \\",
"if (!(condition)) \\\ncontinue; \\",
"if (buf[VAR_14].VAR_3 > 3*VAR_1 || buf[VAR_14].VAR_3>32) { \\",
"av_log(NULL, AV_LOG_ERROR, \"Too long VLC (%d) in init_vlc\\n\", buf[VAR_14].VAR_3);\\",
"av_free(buf); \\",
"return -1; \\",
"} \\",
"GET_DATA(buf[VAR_14].code, VAR_6, VAR_13, VAR_7, VAR_8); \\",
"if (buf[VAR_14].code >= (1LL<<buf[VAR_14].VAR_3)) { \\",
"av_log(NULL, AV_LOG_ERROR, \"Invalid code in init_vlc\\n\"); \\",
"av_free(buf); \\",
"return -1; \\",
"} \\",
"if (VAR_12 & INIT_VLC_LE) \\\nbuf[VAR_14].code = bitswap_32(buf[VAR_14].code); \\",
"else \\\nbuf[VAR_14].code <<= 32 - buf[VAR_14].VAR_3; \\",
"if (VAR_9) \\\nGET_DATA(buf[VAR_14].symbol, VAR_9, VAR_13, VAR_10, VAR_11) \\\nelse \\\nbuf[VAR_14].symbol = VAR_13; \\",
"VAR_14++; \\",
"}",
"COPY(buf[VAR_14].VAR_3 > VAR_1);",
"qsort(buf, VAR_14, sizeof(VLCcode), compare_vlcspec);",
"COPY(buf[VAR_14].VAR_3 && buf[VAR_14].VAR_3 <= VAR_1);",
"VAR_2 = VAR_14;",
"VAR_15 = build_table(VAR_0, VAR_1, VAR_2, buf, VAR_12);",
"av_free(buf);",
"if (VAR_15 < 0) {",
"av_freep(&VAR_0->table);",
"return VAR_15;",
"}",
"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
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
75
],
[
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
],
[
141
],
[
143
],
[
145
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
]
] |
25,674 | static uint64_t macio_nvram_readb(void *opaque, hwaddr addr,
unsigned size)
{
MacIONVRAMState *s = opaque;
uint32_t value;
addr = (addr >> s->it_shift) & (s->size - 1);
value = s->data[addr];
NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
return value;
}
| true | qemu | 2f448e415f364d0ec4c5556993e44ca183e31c5c | static uint64_t macio_nvram_readb(void *opaque, hwaddr addr,
unsigned size)
{
MacIONVRAMState *s = opaque;
uint32_t value;
addr = (addr >> s->it_shift) & (s->size - 1);
value = s->data[addr];
NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
return value;
}
| {
"code": [
" NVR_DPRINTF(\"readb addr %04x val %x\\n\", (int)addr, value);"
],
"line_no": [
17
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
MacIONVRAMState *s = opaque;
uint32_t value;
addr = (addr >> s->it_shift) & (s->size - 1);
value = s->data[addr];
NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
return value;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"MacIONVRAMState *s = opaque;",
"uint32_t value;",
"addr = (addr >> s->it_shift) & (s->size - 1);",
"value = s->data[addr];",
"NVR_DPRINTF(\"readb addr %04x val %x\\n\", (int)addr, value);",
"return value;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
25,675 | void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)
{
ARMCPU *cpu = arm_env_get_cpu(env);
switch (reg) {
case 0: /* APSR */
xpsr_write(env, val, 0xf8000000);
break;
case 1: /* IAPSR */
xpsr_write(env, val, 0xf8000000);
break;
case 2: /* EAPSR */
xpsr_write(env, val, 0xfe00fc00);
break;
case 3: /* xPSR */
xpsr_write(env, val, 0xfe00fc00);
break;
case 5: /* IPSR */
/* IPSR bits are readonly. */
break;
case 6: /* EPSR */
xpsr_write(env, val, 0x0600fc00);
break;
case 7: /* IEPSR */
xpsr_write(env, val, 0x0600fc00);
break;
case 8: /* MSP */
if (env->v7m.current_sp)
env->v7m.other_sp = val;
else
env->regs[13] = val;
break;
case 9: /* PSP */
if (env->v7m.current_sp)
env->regs[13] = val;
else
env->v7m.other_sp = val;
break;
case 16: /* PRIMASK */
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17: /* BASEPRI */
env->v7m.basepri = val & 0xff;
break;
case 18: /* BASEPRI_MAX */
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19: /* FAULTMASK */
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20: /* CONTROL */
env->v7m.control = val & 3;
switch_v7m_sp(env, (val & 2) != 0);
break;
default:
/* ??? For debugging only. */
cpu_abort(CPU(cpu), "Unimplemented system register write (%d)\n", reg);
return;
}
}
| true | qemu | 58117c9bb429cd9552d998687aa99088eb1d8528 | void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)
{
ARMCPU *cpu = arm_env_get_cpu(env);
switch (reg) {
case 0:
xpsr_write(env, val, 0xf8000000);
break;
case 1:
xpsr_write(env, val, 0xf8000000);
break;
case 2:
xpsr_write(env, val, 0xfe00fc00);
break;
case 3:
xpsr_write(env, val, 0xfe00fc00);
break;
case 5:
break;
case 6:
xpsr_write(env, val, 0x0600fc00);
break;
case 7:
xpsr_write(env, val, 0x0600fc00);
break;
case 8:
if (env->v7m.current_sp)
env->v7m.other_sp = val;
else
env->regs[13] = val;
break;
case 9:
if (env->v7m.current_sp)
env->regs[13] = val;
else
env->v7m.other_sp = val;
break;
case 16:
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17:
env->v7m.basepri = val & 0xff;
break;
case 18:
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19:
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20:
env->v7m.control = val & 3;
switch_v7m_sp(env, (val & 2) != 0);
break;
default:
cpu_abort(CPU(cpu), "Unimplemented system register write (%d)\n", reg);
return;
}
}
| {
"code": [
" ARMCPU *cpu = arm_env_get_cpu(env);",
" ARMCPU *cpu = arm_env_get_cpu(env);",
" xpsr_write(env, val, 0xf8000000);",
" break;",
" xpsr_write(env, val, 0xf8000000);",
" break;",
" xpsr_write(env, val, 0xfe00fc00);",
" break;",
" xpsr_write(env, val, 0xfe00fc00);",
" break;",
" break;",
" xpsr_write(env, val, 0x0600fc00);",
" break;",
" xpsr_write(env, val, 0x0600fc00);",
" cpu_abort(CPU(cpu), \"Unimplemented system register write (%d)\\n\", reg);"
],
"line_no": [
5,
5,
13,
15,
13,
15,
25,
15,
25,
15,
15,
43,
15,
43,
133
]
} | void FUNC_0(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)
{
ARMCPU *cpu = arm_env_get_cpu(env);
switch (reg) {
case 0:
xpsr_write(env, val, 0xf8000000);
break;
case 1:
xpsr_write(env, val, 0xf8000000);
break;
case 2:
xpsr_write(env, val, 0xfe00fc00);
break;
case 3:
xpsr_write(env, val, 0xfe00fc00);
break;
case 5:
break;
case 6:
xpsr_write(env, val, 0x0600fc00);
break;
case 7:
xpsr_write(env, val, 0x0600fc00);
break;
case 8:
if (env->v7m.current_sp)
env->v7m.other_sp = val;
else
env->regs[13] = val;
break;
case 9:
if (env->v7m.current_sp)
env->regs[13] = val;
else
env->v7m.other_sp = val;
break;
case 16:
if (val & 1) {
env->daif |= PSTATE_I;
} else {
env->daif &= ~PSTATE_I;
}
break;
case 17:
env->v7m.basepri = val & 0xff;
break;
case 18:
val &= 0xff;
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
case 19:
if (val & 1) {
env->daif |= PSTATE_F;
} else {
env->daif &= ~PSTATE_F;
}
break;
case 20:
env->v7m.control = val & 3;
switch_v7m_sp(env, (val & 2) != 0);
break;
default:
cpu_abort(CPU(cpu), "Unimplemented system register write (%d)\n", reg);
return;
}
}
| [
"void FUNC_0(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)\n{",
"ARMCPU *cpu = arm_env_get_cpu(env);",
"switch (reg) {",
"case 0:\nxpsr_write(env, val, 0xf8000000);",
"break;",
"case 1:\nxpsr_write(env, val, 0xf8000000);",
"break;",
"case 2:\nxpsr_write(env, val, 0xfe00fc00);",
"break;",
"case 3:\nxpsr_write(env, val, 0xfe00fc00);",
"break;",
"case 5:\nbreak;",
"case 6:\nxpsr_write(env, val, 0x0600fc00);",
"break;",
"case 7:\nxpsr_write(env, val, 0x0600fc00);",
"break;",
"case 8:\nif (env->v7m.current_sp)\nenv->v7m.other_sp = val;",
"else\nenv->regs[13] = val;",
"break;",
"case 9:\nif (env->v7m.current_sp)\nenv->regs[13] = val;",
"else\nenv->v7m.other_sp = val;",
"break;",
"case 16:\nif (val & 1) {",
"env->daif |= PSTATE_I;",
"} else {",
"env->daif &= ~PSTATE_I;",
"}",
"break;",
"case 17:\nenv->v7m.basepri = val & 0xff;",
"break;",
"case 18:\nval &= 0xff;",
"if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))\nenv->v7m.basepri = val;",
"break;",
"case 19:\nif (val & 1) {",
"env->daif |= PSTATE_F;",
"} else {",
"env->daif &= ~PSTATE_F;",
"}",
"break;",
"case 20:\nenv->v7m.control = val & 3;",
"switch_v7m_sp(env, (val & 2) != 0);",
"break;",
"default:\ncpu_abort(CPU(cpu), \"Unimplemented system register write (%d)\\n\", reg);",
"return;",
"}",
"}"
] | [
0,
1,
0,
1,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
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
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129,
133
],
[
135
],
[
137
],
[
139
]
] |
25,677 | AVRational av_d2q(double d, int max)
{
AVRational a;
int exponent;
int64_t den;
if (isnan(d))
return (AVRational) { 0,0 };
if (fabs(d) > INT_MAX + 3LL)
return (AVRational) { d < 0 ? -1 : 1, 0 };
frexp(d, &exponent);
exponent = FFMAX(exponent-1, 0);
den = 1LL << (61 - exponent);
// (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
return a;
}
| false | FFmpeg | 7dabc78ce13e3baa37292f42df2364b4ccd2aa78 | AVRational av_d2q(double d, int max)
{
AVRational a;
int exponent;
int64_t den;
if (isnan(d))
return (AVRational) { 0,0 };
if (fabs(d) > INT_MAX + 3LL)
return (AVRational) { d < 0 ? -1 : 1, 0 };
frexp(d, &exponent);
exponent = FFMAX(exponent-1, 0);
den = 1LL << (61 - exponent);
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
return a;
}
| {
"code": [],
"line_no": []
} | AVRational FUNC_0(double d, int max)
{
AVRational a;
int VAR_0;
int64_t den;
if (isnan(d))
return (AVRational) { 0,0 };
if (fabs(d) > INT_MAX + 3LL)
return (AVRational) { d < 0 ? -1 : 1, 0 };
frexp(d, &VAR_0);
VAR_0 = FFMAX(VAR_0-1, 0);
den = 1LL << (61 - VAR_0);
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
return a;
}
| [
"AVRational FUNC_0(double d, int max)\n{",
"AVRational a;",
"int VAR_0;",
"int64_t den;",
"if (isnan(d))\nreturn (AVRational) { 0,0 };",
"if (fabs(d) > INT_MAX + 3LL)\nreturn (AVRational) { d < 0 ? -1 : 1, 0 };",
"frexp(d, &VAR_0);",
"VAR_0 = FFMAX(VAR_0-1, 0);",
"den = 1LL << (61 - VAR_0);",
"av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);",
"if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)\nav_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);",
"return a;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
]
] |
25,678 | static unsigned tget(GetByteContext *gb, int type, int le)
{
switch (type) {
case TIFF_BYTE : return bytestream2_get_byteu(gb);
case TIFF_SHORT: return tget_short(gb, le);
case TIFF_LONG : return tget_long(gb, le);
default : return UINT_MAX;
}
}
| false | FFmpeg | ce1ebb31a9a0e556a89cd7681082af19fbc1cced | static unsigned tget(GetByteContext *gb, int type, int le)
{
switch (type) {
case TIFF_BYTE : return bytestream2_get_byteu(gb);
case TIFF_SHORT: return tget_short(gb, le);
case TIFF_LONG : return tget_long(gb, le);
default : return UINT_MAX;
}
}
| {
"code": [],
"line_no": []
} | static unsigned FUNC_0(GetByteContext *VAR_0, int VAR_1, int VAR_2)
{
switch (VAR_1) {
case TIFF_BYTE : return bytestream2_get_byteu(VAR_0);
case TIFF_SHORT: return tget_short(VAR_0, VAR_2);
case TIFF_LONG : return tget_long(VAR_0, VAR_2);
default : return UINT_MAX;
}
}
| [
"static unsigned FUNC_0(GetByteContext *VAR_0, int VAR_1, int VAR_2)\n{",
"switch (VAR_1) {",
"case TIFF_BYTE : return bytestream2_get_byteu(VAR_0);",
"case TIFF_SHORT: return tget_short(VAR_0, VAR_2);",
"case TIFF_LONG : return tget_long(VAR_0, VAR_2);",
"default : return UINT_MAX;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,679 | PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCNetState *d;
uint8_t *pci_conf;
#if 0
printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n",
sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));
#endif
d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
devfn, NULL, NULL);
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);
*(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007);
*(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280);
pci_conf[0x08] = 0x10;
pci_conf[0x09] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
pci_conf[0x0e] = 0x00; // header_type
*(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001);
*(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000);
pci_conf[0x3d] = 1; // interrupt pin 0
pci_conf[0x3e] = 0x06;
pci_conf[0x3f] = 0xff;
/* Handler for memory-mapped I/O */
d->mmio_index =
cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d);
pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,
PCI_ADDRESS_SPACE_IO, pcnet_ioport_map);
pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE,
PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
d->irq = d->dev.irq[0];
d->phys_mem_read = pci_physical_memory_read;
d->phys_mem_write = pci_physical_memory_write;
d->pci_dev = &d->dev;
pcnet_common_init(d, nd);
return (PCIDevice *)d;
}
| true | qemu | b946a1533209f61a93e34898aebb5b43154b99c3 | PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
{
PCNetState *d;
uint8_t *pci_conf;
#if 0
printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n",
sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));
#endif
d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
devfn, NULL, NULL);
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);
*(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007);
*(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280);
pci_conf[0x08] = 0x10;
pci_conf[0x09] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
pci_conf[0x0e] = 0x00;
*(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001);
*(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000);
pci_conf[0x3d] = 1;
pci_conf[0x3e] = 0x06;
pci_conf[0x3f] = 0xff;
d->mmio_index =
cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d);
pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,
PCI_ADDRESS_SPACE_IO, pcnet_ioport_map);
pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE,
PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
d->irq = d->dev.irq[0];
d->phys_mem_read = pci_physical_memory_read;
d->phys_mem_write = pci_physical_memory_write;
d->pci_dev = &d->dev;
pcnet_common_init(d, nd);
return (PCIDevice *)d;
}
| {
"code": [
" pcnet_common_init(d, nd);",
" pcnet_common_init(d, nd);",
"#endif",
"#endif"
],
"line_no": [
93,
93,
17,
17
]
} | PCIDevice *FUNC_0(PCIBus *bus, NICInfo *nd, int devfn)
{
PCNetState *d;
uint8_t *pci_conf;
#if 0
printf("sizeof(RMD)=%d, sizeof(TMD)=%d\n",
sizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));
#endif
d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
devfn, NULL, NULL);
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);
*(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007);
*(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280);
pci_conf[0x08] = 0x10;
pci_conf[0x09] = 0x00;
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
pci_conf[0x0e] = 0x00;
*(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001);
*(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000);
pci_conf[0x3d] = 1;
pci_conf[0x3e] = 0x06;
pci_conf[0x3f] = 0xff;
d->mmio_index =
cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d);
pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,
PCI_ADDRESS_SPACE_IO, pcnet_ioport_map);
pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE,
PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
d->irq = d->dev.irq[0];
d->phys_mem_read = pci_physical_memory_read;
d->phys_mem_write = pci_physical_memory_write;
d->pci_dev = &d->dev;
pcnet_common_init(d, nd);
return (PCIDevice *)d;
}
| [
"PCIDevice *FUNC_0(PCIBus *bus, NICInfo *nd, int devfn)\n{",
"PCNetState *d;",
"uint8_t *pci_conf;",
"#if 0\nprintf(\"sizeof(RMD)=%d, sizeof(TMD)=%d\\n\",\nsizeof(struct pcnet_RMD), sizeof(struct pcnet_TMD));",
"#endif\nd = (PCNetState *)pci_register_device(bus, \"PCNet\", sizeof(PCNetState),\ndevfn, NULL, NULL);",
"pci_conf = d->dev.config;",
"pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);",
"pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);",
"*(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007);",
"*(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280);",
"pci_conf[0x08] = 0x10;",
"pci_conf[0x09] = 0x00;",
"pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);",
"pci_conf[0x0e] = 0x00;",
"*(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001);",
"*(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000);",
"pci_conf[0x3d] = 1;",
"pci_conf[0x3e] = 0x06;",
"pci_conf[0x3f] = 0xff;",
"d->mmio_index =\ncpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d);",
"pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,\nPCI_ADDRESS_SPACE_IO, pcnet_ioport_map);",
"pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE,\nPCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);",
"d->irq = d->dev.irq[0];",
"d->phys_mem_read = pci_physical_memory_read;",
"d->phys_mem_write = pci_physical_memory_write;",
"d->pci_dev = &d->dev;",
"pcnet_common_init(d, nd);",
"return (PCIDevice *)d;",
"}"
] | [
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,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17,
21,
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
65,
67
],
[
71,
73
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
]
] |
25,680 | void aio_notify(AioContext *ctx)
{
/* Write e.g. bh->scheduled before reading ctx->dispatching. */
smp_mb();
if (!ctx->dispatching) {
event_notifier_set(&ctx->notifier);
}
}
| true | qemu | eabc977973103527bbb8fed69c91cfaa6691f8ab | void aio_notify(AioContext *ctx)
{
smp_mb();
if (!ctx->dispatching) {
event_notifier_set(&ctx->notifier);
}
}
| {
"code": [
" if (!ctx->dispatching) {"
],
"line_no": [
9
]
} | void FUNC_0(AioContext *VAR_0)
{
smp_mb();
if (!VAR_0->dispatching) {
event_notifier_set(&VAR_0->notifier);
}
}
| [
"void FUNC_0(AioContext *VAR_0)\n{",
"smp_mb();",
"if (!VAR_0->dispatching) {",
"event_notifier_set(&VAR_0->notifier);",
"}",
"}"
] | [
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,681 | static void tb_invalidate_phys_page(tb_page_addr_t addr,
uintptr_t pc, void *puc)
{
TranslationBlock *tb;
PageDesc *p;
int n;
#ifdef TARGET_HAS_PRECISE_SMC
TranslationBlock *current_tb = NULL;
CPUState *cpu = current_cpu;
CPUArchState *env = NULL;
int current_tb_modified = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
int current_flags = 0;
#endif
addr &= TARGET_PAGE_MASK;
p = page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
return;
}
tb = p->first_tb;
#ifdef TARGET_HAS_PRECISE_SMC
if (tb && pc != 0) {
current_tb = tb_find_pc(pc);
}
if (cpu != NULL) {
env = cpu->env_ptr;
}
#endif
while (tb != NULL) {
n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((uintptr_t)tb & ~3);
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb == tb &&
(current_tb->cflags & CF_COUNT_MASK) != 1) {
/* If we are modifying the current TB, we must stop
its execution. We could be more precise by checking
that the modification is after the current PC, but it
would require a specialized function to partially
restore the CPU state */
current_tb_modified = 1;
cpu_restore_state_from_tb(current_tb, env, pc);
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
#endif /* TARGET_HAS_PRECISE_SMC */
tb_phys_invalidate(tb, addr);
tb = tb->page_next[n];
}
p->first_tb = NULL;
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_modified) {
/* we generate a block containing just the instruction
modifying the memory. It will ensure that it cannot modify
itself */
cpu->current_tb = NULL;
tb_gen_code(env, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(env, puc);
}
#endif
}
| true | qemu | d02532f08e207419e412ea7cd4eb8b36f04f426d | static void tb_invalidate_phys_page(tb_page_addr_t addr,
uintptr_t pc, void *puc)
{
TranslationBlock *tb;
PageDesc *p;
int n;
#ifdef TARGET_HAS_PRECISE_SMC
TranslationBlock *current_tb = NULL;
CPUState *cpu = current_cpu;
CPUArchState *env = NULL;
int current_tb_modified = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
int current_flags = 0;
#endif
addr &= TARGET_PAGE_MASK;
p = page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
return;
}
tb = p->first_tb;
#ifdef TARGET_HAS_PRECISE_SMC
if (tb && pc != 0) {
current_tb = tb_find_pc(pc);
}
if (cpu != NULL) {
env = cpu->env_ptr;
}
#endif
while (tb != NULL) {
n = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((uintptr_t)tb & ~3);
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb == tb &&
(current_tb->cflags & CF_COUNT_MASK) != 1) {
current_tb_modified = 1;
cpu_restore_state_from_tb(current_tb, env, pc);
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
#endif
tb_phys_invalidate(tb, addr);
tb = tb->page_next[n];
}
p->first_tb = NULL;
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_modified) {
cpu->current_tb = NULL;
tb_gen_code(env, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(env, puc);
}
#endif
}
| {
"code": [
" uintptr_t pc, void *puc)"
],
"line_no": [
3
]
} | static void FUNC_0(tb_page_addr_t VAR_0,
uintptr_t VAR_1, void *VAR_2)
{
TranslationBlock *tb;
PageDesc *p;
int VAR_3;
#ifdef TARGET_HAS_PRECISE_SMC
TranslationBlock *current_tb = NULL;
CPUState *cpu = current_cpu;
CPUArchState *env = NULL;
int current_tb_modified = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
int current_flags = 0;
#endif
VAR_0 &= TARGET_PAGE_MASK;
p = page_find(VAR_0 >> TARGET_PAGE_BITS);
if (!p) {
return;
}
tb = p->first_tb;
#ifdef TARGET_HAS_PRECISE_SMC
if (tb && VAR_1 != 0) {
current_tb = tb_find_pc(VAR_1);
}
if (cpu != NULL) {
env = cpu->env_ptr;
}
#endif
while (tb != NULL) {
VAR_3 = (uintptr_t)tb & 3;
tb = (TranslationBlock *)((uintptr_t)tb & ~3);
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb == tb &&
(current_tb->cflags & CF_COUNT_MASK) != 1) {
current_tb_modified = 1;
cpu_restore_state_from_tb(current_tb, env, VAR_1);
cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,
¤t_flags);
}
#endif
tb_phys_invalidate(tb, VAR_0);
tb = tb->page_next[VAR_3];
}
p->first_tb = NULL;
#ifdef TARGET_HAS_PRECISE_SMC
if (current_tb_modified) {
cpu->current_tb = NULL;
tb_gen_code(env, current_pc, current_cs_base, current_flags, 1);
cpu_resume_from_signal(env, VAR_2);
}
#endif
}
| [
"static void FUNC_0(tb_page_addr_t VAR_0,\nuintptr_t VAR_1, void *VAR_2)\n{",
"TranslationBlock *tb;",
"PageDesc *p;",
"int VAR_3;",
"#ifdef TARGET_HAS_PRECISE_SMC\nTranslationBlock *current_tb = NULL;",
"CPUState *cpu = current_cpu;",
"CPUArchState *env = NULL;",
"int current_tb_modified = 0;",
"target_ulong current_pc = 0;",
"target_ulong current_cs_base = 0;",
"int current_flags = 0;",
"#endif\nVAR_0 &= TARGET_PAGE_MASK;",
"p = page_find(VAR_0 >> TARGET_PAGE_BITS);",
"if (!p) {",
"return;",
"}",
"tb = p->first_tb;",
"#ifdef TARGET_HAS_PRECISE_SMC\nif (tb && VAR_1 != 0) {",
"current_tb = tb_find_pc(VAR_1);",
"}",
"if (cpu != NULL) {",
"env = cpu->env_ptr;",
"}",
"#endif\nwhile (tb != NULL) {",
"VAR_3 = (uintptr_t)tb & 3;",
"tb = (TranslationBlock *)((uintptr_t)tb & ~3);",
"#ifdef TARGET_HAS_PRECISE_SMC\nif (current_tb == tb &&\n(current_tb->cflags & CF_COUNT_MASK) != 1) {",
"current_tb_modified = 1;",
"cpu_restore_state_from_tb(current_tb, env, VAR_1);",
"cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base,\n¤t_flags);",
"}",
"#endif\ntb_phys_invalidate(tb, VAR_0);",
"tb = tb->page_next[VAR_3];",
"}",
"p->first_tb = NULL;",
"#ifdef TARGET_HAS_PRECISE_SMC\nif (current_tb_modified) {",
"cpu->current_tb = NULL;",
"tb_gen_code(env, current_pc, current_cs_base, current_flags, 1);",
"cpu_resume_from_signal(env, VAR_2);",
"}",
"#endif\n}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69,
71
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
]
] |
25,683 | static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf)
{
int au_headers_length, au_header_size, i;
GetBitContext getbitcontext;
/* decode the first 2 bytes where the AUHeader sections are stored
length in bits */
au_headers_length = AV_RB16(buf);
if (au_headers_length > RTP_MAX_PACKET_LENGTH)
return -1;
data->au_headers_length_bytes = (au_headers_length + 7) / 8;
/* skip AU headers length section (2 bytes) */
buf += 2;
init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8);
/* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */
au_header_size = data->sizelength + data->indexlength;
if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
return -1;
data->nb_au_headers = au_headers_length / au_header_size;
if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) {
av_free(data->au_headers);
data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers);
if (!data->au_headers)
return AVERROR(ENOMEM);
data->au_headers_allocated = data->nb_au_headers;
}
/* XXX: We handle multiple AU Section as only one (need to fix this for interleaving)
In my test, the FAAD decoder does not behave correctly when sending each AU one by one
but does when sending the whole as one big packet... */
data->au_headers[0].size = 0;
data->au_headers[0].index = 0;
for (i = 0; i < data->nb_au_headers; ++i) {
data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength);
data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength);
}
data->nb_au_headers = 1;
return 0;
}
| true | FFmpeg | a7ba3244131d96d9ab7a99ef30dc7276efd05cc7 | static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf)
{
int au_headers_length, au_header_size, i;
GetBitContext getbitcontext;
au_headers_length = AV_RB16(buf);
if (au_headers_length > RTP_MAX_PACKET_LENGTH)
return -1;
data->au_headers_length_bytes = (au_headers_length + 7) / 8;
buf += 2;
init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8);
au_header_size = data->sizelength + data->indexlength;
if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
return -1;
data->nb_au_headers = au_headers_length / au_header_size;
if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) {
av_free(data->au_headers);
data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers);
if (!data->au_headers)
return AVERROR(ENOMEM);
data->au_headers_allocated = data->nb_au_headers;
}
data->au_headers[0].size = 0;
data->au_headers[0].index = 0;
for (i = 0; i < data->nb_au_headers; ++i) {
data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength);
data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength);
}
data->nb_au_headers = 1;
return 0;
}
| {
"code": [
"static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf)"
],
"line_no": [
1
]
} | static int FUNC_0(PayloadContext *VAR_0, const uint8_t *VAR_1)
{
int VAR_2, VAR_3, VAR_4;
GetBitContext getbitcontext;
VAR_2 = AV_RB16(VAR_1);
if (VAR_2 > RTP_MAX_PACKET_LENGTH)
return -1;
VAR_0->au_headers_length_bytes = (VAR_2 + 7) / 8;
VAR_1 += 2;
init_get_bits(&getbitcontext, VAR_1, VAR_0->au_headers_length_bytes * 8);
VAR_3 = VAR_0->sizelength + VAR_0->indexlength;
if (VAR_3 <= 0 || (VAR_2 % VAR_3 != 0))
return -1;
VAR_0->nb_au_headers = VAR_2 / VAR_3;
if (!VAR_0->au_headers || VAR_0->au_headers_allocated < VAR_0->nb_au_headers) {
av_free(VAR_0->au_headers);
VAR_0->au_headers = av_malloc(sizeof(struct AUHeaders) * VAR_0->nb_au_headers);
if (!VAR_0->au_headers)
return AVERROR(ENOMEM);
VAR_0->au_headers_allocated = VAR_0->nb_au_headers;
}
VAR_0->au_headers[0].size = 0;
VAR_0->au_headers[0].index = 0;
for (VAR_4 = 0; VAR_4 < VAR_0->nb_au_headers; ++VAR_4) {
VAR_0->au_headers[0].size += get_bits_long(&getbitcontext, VAR_0->sizelength);
VAR_0->au_headers[0].index = get_bits_long(&getbitcontext, VAR_0->indexlength);
}
VAR_0->nb_au_headers = 1;
return 0;
}
| [
"static int FUNC_0(PayloadContext *VAR_0, const uint8_t *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"GetBitContext getbitcontext;",
"VAR_2 = AV_RB16(VAR_1);",
"if (VAR_2 > RTP_MAX_PACKET_LENGTH)\nreturn -1;",
"VAR_0->au_headers_length_bytes = (VAR_2 + 7) / 8;",
"VAR_1 += 2;",
"init_get_bits(&getbitcontext, VAR_1, VAR_0->au_headers_length_bytes * 8);",
"VAR_3 = VAR_0->sizelength + VAR_0->indexlength;",
"if (VAR_3 <= 0 || (VAR_2 % VAR_3 != 0))\nreturn -1;",
"VAR_0->nb_au_headers = VAR_2 / VAR_3;",
"if (!VAR_0->au_headers || VAR_0->au_headers_allocated < VAR_0->nb_au_headers) {",
"av_free(VAR_0->au_headers);",
"VAR_0->au_headers = av_malloc(sizeof(struct AUHeaders) * VAR_0->nb_au_headers);",
"if (!VAR_0->au_headers)\nreturn AVERROR(ENOMEM);",
"VAR_0->au_headers_allocated = VAR_0->nb_au_headers;",
"}",
"VAR_0->au_headers[0].size = 0;",
"VAR_0->au_headers[0].index = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_au_headers; ++VAR_4) {",
"VAR_0->au_headers[0].size += get_bits_long(&getbitcontext, VAR_0->sizelength);",
"VAR_0->au_headers[0].index = get_bits_long(&getbitcontext, VAR_0->indexlength);",
"}",
"VAR_0->nb_au_headers = 1;",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
15
],
[
19,
21
],
[
25
],
[
31
],
[
35
],
[
41
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
91
],
[
93
]
] |
25,684 | static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)
{
int i;
assert(src1 == src2);
for(i=0; i<width; i++)
{
int p= pal[src1[i]];
dstU[i]= p>>8;
dstV[i]= p>>16;
}
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)
{
int i;
assert(src1 == src2);
for(i=0; i<width; i++)
{
int p= pal[src1[i]];
dstU[i]= p>>8;
dstV[i]= p>>16;
}
}
| {
"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++)",
"\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;",
"\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++)",
"\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;",
" assert(src1 == src2);",
"\tfor(i=0; i<width; i++)",
"\t\tint p= pal[src1[i]];",
"\t\tdstU[i]= p>>8;",
"\t\tdstV[i]= p>>16;",
"\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,
5,
9,
5,
9,
5,
9,
5,
9,
5,
9,
5,
9,
5,
9,
5,
7,
9,
5,
9,
5,
7,
9,
5,
9,
5,
7,
9,
13,
17,
19,
5,
5,
5,
5,
5
]
} | static inline void FUNC_0(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)
{
int VAR_0;
assert(src1 == src2);
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int p= pal[src1[VAR_0]];
dstU[VAR_0]= p>>8;
dstV[VAR_0]= p>>16;
}
}
| [
"static inline void FUNC_0(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)\n{",
"int VAR_0;",
"assert(src1 == src2);",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"int p= pal[src1[VAR_0]];",
"dstU[VAR_0]= p>>8;",
"dstV[VAR_0]= p>>16;",
"}",
"}"
] | [
0,
1,
1,
1,
0,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
25,685 | static uint64_t pl011_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
pl011_state *s = (pl011_state *)opaque;
uint32_t c;
if (offset >= 0xfe0 && offset < 0x1000) {
return s->id[(offset - 0xfe0) >> 2];
}
switch (offset >> 2) {
case 0: /* UARTDR */
s->flags &= ~PL011_FLAG_RXFF;
c = s->read_fifo[s->read_pos];
if (s->read_count > 0) {
s->read_count--;
if (++s->read_pos == 16)
s->read_pos = 0;
}
if (s->read_count == 0) {
s->flags |= PL011_FLAG_RXFE;
}
if (s->read_count == s->read_trigger - 1)
s->int_level &= ~ PL011_INT_RX;
pl011_update(s);
qemu_chr_accept_input(s->chr);
return c;
case 1: /* UARTCR */
return 0;
case 6: /* UARTFR */
return s->flags;
case 8: /* UARTILPR */
return s->ilpr;
case 9: /* UARTIBRD */
return s->ibrd;
case 10: /* UARTFBRD */
return s->fbrd;
case 11: /* UARTLCR_H */
return s->lcr;
case 12: /* UARTCR */
return s->cr;
case 13: /* UARTIFLS */
return s->ifl;
case 14: /* UARTIMSC */
return s->int_enabled;
case 15: /* UARTRIS */
return s->int_level;
case 16: /* UARTMIS */
return s->int_level & s->int_enabled;
case 18: /* UARTDMACR */
return s->dmacr;
default:
hw_error("pl011_read: Bad offset %x\n", (int)offset);
return 0;
}
}
| true | qemu | 0d4abda8f7328c8911c1d020bb6961650eaf7801 | static uint64_t pl011_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
pl011_state *s = (pl011_state *)opaque;
uint32_t c;
if (offset >= 0xfe0 && offset < 0x1000) {
return s->id[(offset - 0xfe0) >> 2];
}
switch (offset >> 2) {
case 0:
s->flags &= ~PL011_FLAG_RXFF;
c = s->read_fifo[s->read_pos];
if (s->read_count > 0) {
s->read_count--;
if (++s->read_pos == 16)
s->read_pos = 0;
}
if (s->read_count == 0) {
s->flags |= PL011_FLAG_RXFE;
}
if (s->read_count == s->read_trigger - 1)
s->int_level &= ~ PL011_INT_RX;
pl011_update(s);
qemu_chr_accept_input(s->chr);
return c;
case 1:
return 0;
case 6:
return s->flags;
case 8:
return s->ilpr;
case 9:
return s->ibrd;
case 10:
return s->fbrd;
case 11:
return s->lcr;
case 12:
return s->cr;
case 13:
return s->ifl;
case 14:
return s->int_enabled;
case 15:
return s->int_level;
case 16:
return s->int_level & s->int_enabled;
case 18:
return s->dmacr;
default:
hw_error("pl011_read: Bad offset %x\n", (int)offset);
return 0;
}
}
| {
"code": [
" qemu_chr_accept_input(s->chr);"
],
"line_no": [
49
]
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,
unsigned size)
{
pl011_state *s = (pl011_state *)opaque;
uint32_t c;
if (offset >= 0xfe0 && offset < 0x1000) {
return s->id[(offset - 0xfe0) >> 2];
}
switch (offset >> 2) {
case 0:
s->flags &= ~PL011_FLAG_RXFF;
c = s->read_fifo[s->read_pos];
if (s->read_count > 0) {
s->read_count--;
if (++s->read_pos == 16)
s->read_pos = 0;
}
if (s->read_count == 0) {
s->flags |= PL011_FLAG_RXFE;
}
if (s->read_count == s->read_trigger - 1)
s->int_level &= ~ PL011_INT_RX;
pl011_update(s);
qemu_chr_accept_input(s->chr);
return c;
case 1:
return 0;
case 6:
return s->flags;
case 8:
return s->ilpr;
case 9:
return s->ibrd;
case 10:
return s->fbrd;
case 11:
return s->lcr;
case 12:
return s->cr;
case 13:
return s->ifl;
case 14:
return s->int_enabled;
case 15:
return s->int_level;
case 16:
return s->int_level & s->int_enabled;
case 18:
return s->dmacr;
default:
hw_error("FUNC_0: Bad offset %x\n", (int)offset);
return 0;
}
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset,\nunsigned size)\n{",
"pl011_state *s = (pl011_state *)opaque;",
"uint32_t c;",
"if (offset >= 0xfe0 && offset < 0x1000) {",
"return s->id[(offset - 0xfe0) >> 2];",
"}",
"switch (offset >> 2) {",
"case 0:\ns->flags &= ~PL011_FLAG_RXFF;",
"c = s->read_fifo[s->read_pos];",
"if (s->read_count > 0) {",
"s->read_count--;",
"if (++s->read_pos == 16)\ns->read_pos = 0;",
"}",
"if (s->read_count == 0) {",
"s->flags |= PL011_FLAG_RXFE;",
"}",
"if (s->read_count == s->read_trigger - 1)\ns->int_level &= ~ PL011_INT_RX;",
"pl011_update(s);",
"qemu_chr_accept_input(s->chr);",
"return c;",
"case 1:\nreturn 0;",
"case 6:\nreturn s->flags;",
"case 8:\nreturn s->ilpr;",
"case 9:\nreturn s->ibrd;",
"case 10:\nreturn s->fbrd;",
"case 11:\nreturn s->lcr;",
"case 12:\nreturn s->cr;",
"case 13:\nreturn s->ifl;",
"case 14:\nreturn s->int_enabled;",
"case 15:\nreturn s->int_level;",
"case 16:\nreturn s->int_level & s->int_enabled;",
"case 18:\nreturn s->dmacr;",
"default:\nhw_error(\"FUNC_0: Bad offset %x\\n\", (int)offset);",
"return 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81,
83
],
[
85,
87
],
[
89,
91
],
[
93,
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
]
] |
25,688 | static void icp_pit_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
icp_pit_state *s = (icp_pit_state *)opaque;
int n;
n = offset >> 8;
if (n > 2) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad timer %d\n", __func__, n);
}
arm_timer_write(s->timer[n], offset & 0xff, value);
} | true | qemu | cba933b2257ef0ad241756a0ff86bc0acda685ca | static void icp_pit_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
icp_pit_state *s = (icp_pit_state *)opaque;
int n;
n = offset >> 8;
if (n > 2) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad timer %d\n", __func__, n);
}
arm_timer_write(s->timer[n], offset & 0xff, value);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
icp_pit_state *s = (icp_pit_state *)VAR_0;
int VAR_4;
VAR_4 = VAR_1 >> 8;
if (VAR_4 > 2) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad timer %d\VAR_4", __func__, VAR_4);
}
arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2);
} | [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"icp_pit_state *s = (icp_pit_state *)VAR_0;",
"int VAR_4;",
"VAR_4 = VAR_1 >> 8;",
"if (VAR_4 > 2) {",
"qemu_log_mask(LOG_GUEST_ERROR, \"%s: Bad timer %d\\VAR_4\", __func__, VAR_4);",
"}",
"arm_timer_write(s->timer[VAR_4], VAR_1 & 0xff, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
20
],
[
24
],
[
26
]
] |
25,689 | static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)
{
int i, x, y;
int depth = (bpp + 1) >> 3;
int type, count;
int diff;
diff = stride - w * depth;
x = y = 0;
while(y < h){
type = *src++;
count = (type & 0x7F) + 1;
type &= 0x80;
if((x + count > w) && (x + count + 1 > (h - y) * w)){
av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);
return;
}
for(i = 0; i < count; i++){
switch(depth){
case 1:
*dst = *src;
break;
case 2:
*((uint16_t*)dst) = AV_RL16(src);
break;
case 3:
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
break;
case 4:
*((uint32_t*)dst) = AV_RL32(src);
break;
}
dst += depth;
if(!type)
src += depth;
x++;
if(x == w){
x = 0;
y++;
dst += diff;
}
}
if(type)
src += depth;
}
}
| true | FFmpeg | 7782cb207a09f4acf0b2a935ca81076b117660a2 | static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)
{
int i, x, y;
int depth = (bpp + 1) >> 3;
int type, count;
int diff;
diff = stride - w * depth;
x = y = 0;
while(y < h){
type = *src++;
count = (type & 0x7F) + 1;
type &= 0x80;
if((x + count > w) && (x + count + 1 > (h - y) * w)){
av_log(avctx, AV_LOG_ERROR, "Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);
return;
}
for(i = 0; i < count; i++){
switch(depth){
case 1:
*dst = *src;
break;
case 2:
*((uint16_t*)dst) = AV_RL16(src);
break;
case 3:
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
break;
case 4:
*((uint32_t*)dst) = AV_RL32(src);
break;
}
dst += depth;
if(!type)
src += depth;
x++;
if(x == w){
x = 0;
y++;
dst += diff;
}
}
if(type)
src += depth;
}
}
| {
"code": [
"static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp)"
],
"line_no": [
1
]
} | static void FUNC_0(AVCodecContext *VAR_0, TargaContext *VAR_1, const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{
int VAR_8, VAR_9, VAR_10;
int VAR_11 = (VAR_7 + 1) >> 3;
int VAR_12, VAR_13;
int VAR_14;
VAR_14 = VAR_6 - VAR_4 * VAR_11;
VAR_9 = VAR_10 = 0;
while(VAR_10 < VAR_5){
VAR_12 = *VAR_2++;
VAR_13 = (VAR_12 & 0x7F) + 1;
VAR_12 &= 0x80;
if((VAR_9 + VAR_13 > VAR_4) && (VAR_9 + VAR_13 + 1 > (VAR_5 - VAR_10) * VAR_4)){
av_log(VAR_0, AV_LOG_ERROR, "Packet went out of bounds: position (%VAR_8,%VAR_8) size %VAR_8\n", VAR_9, VAR_10, VAR_13);
return;
}
for(VAR_8 = 0; VAR_8 < VAR_13; VAR_8++){
switch(VAR_11){
case 1:
*VAR_3 = *VAR_2;
break;
case 2:
*((uint16_t*)VAR_3) = AV_RL16(VAR_2);
break;
case 3:
VAR_3[0] = VAR_2[0];
VAR_3[1] = VAR_2[1];
VAR_3[2] = VAR_2[2];
break;
case 4:
*((uint32_t*)VAR_3) = AV_RL32(VAR_2);
break;
}
VAR_3 += VAR_11;
if(!VAR_12)
VAR_2 += VAR_11;
VAR_9++;
if(VAR_9 == VAR_4){
VAR_9 = 0;
VAR_10++;
VAR_3 += VAR_14;
}
}
if(VAR_12)
VAR_2 += VAR_11;
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0, TargaContext *VAR_1, const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)\n{",
"int VAR_8, VAR_9, VAR_10;",
"int VAR_11 = (VAR_7 + 1) >> 3;",
"int VAR_12, VAR_13;",
"int VAR_14;",
"VAR_14 = VAR_6 - VAR_4 * VAR_11;",
"VAR_9 = VAR_10 = 0;",
"while(VAR_10 < VAR_5){",
"VAR_12 = *VAR_2++;",
"VAR_13 = (VAR_12 & 0x7F) + 1;",
"VAR_12 &= 0x80;",
"if((VAR_9 + VAR_13 > VAR_4) && (VAR_9 + VAR_13 + 1 > (VAR_5 - VAR_10) * VAR_4)){",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet went out of bounds: position (%VAR_8,%VAR_8) size %VAR_8\\n\", VAR_9, VAR_10, VAR_13);",
"return;",
"}",
"for(VAR_8 = 0; VAR_8 < VAR_13; VAR_8++){",
"switch(VAR_11){",
"case 1:\n*VAR_3 = *VAR_2;",
"break;",
"case 2:\n*((uint16_t*)VAR_3) = AV_RL16(VAR_2);",
"break;",
"case 3:\nVAR_3[0] = VAR_2[0];",
"VAR_3[1] = VAR_2[1];",
"VAR_3[2] = VAR_2[2];",
"break;",
"case 4:\n*((uint32_t*)VAR_3) = AV_RL32(VAR_2);",
"break;",
"}",
"VAR_3 += VAR_11;",
"if(!VAR_12)\nVAR_2 += VAR_11;",
"VAR_9++;",
"if(VAR_9 == VAR_4){",
"VAR_9 = 0;",
"VAR_10++;",
"VAR_3 += VAR_14;",
"}",
"}",
"if(VAR_12)\nVAR_2 += VAR_11;",
"}",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
]
] |
25,690 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, psize;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
psize = avctx->bits_per_coded_sample / 8;
switch (avctx->codec_tag) {
case MKTAG('A', 'A', 'S', '4'):
bytestream2_init(&s->gb, buf - 4, buf_size + 4);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
case MKTAG('A', 'A', 'S', 'C'):
switch(compr){
case 0:
stride = (avctx->width * psize + psize) & ~psize;
for(i = avctx->height - 1; i >= 0; i--){
if(avctx->width * psize > buf_size){
av_log(avctx, AV_LOG_ERROR, "Next line is beyond buffer bounds\n");
break;
memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return -1;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag);
return -1;
if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
memcpy(s->frame.data[1], s->palette, s->palette_size);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
/* report that the buffer was completely consumed */
return buf_size; | true | FFmpeg | e1631f8ebe9a8f2a9cca85d60160b9be94eb63f3 | static int aasc_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AascContext *s = avctx->priv_data;
int compr, i, stride, psize;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (avctx->reget_buffer(avctx, &s->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
compr = AV_RL32(buf);
buf += 4;
buf_size -= 4;
psize = avctx->bits_per_coded_sample / 8;
switch (avctx->codec_tag) {
case MKTAG('A', 'A', 'S', '4'):
bytestream2_init(&s->gb, buf - 4, buf_size + 4);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
case MKTAG('A', 'A', 'S', 'C'):
switch(compr){
case 0:
stride = (avctx->width * psize + psize) & ~psize;
for(i = avctx->height - 1; i >= 0; i--){
if(avctx->width * psize > buf_size){
av_log(avctx, AV_LOG_ERROR, "Next line is beyond buffer bounds\n");
break;
memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width * psize);
buf += stride;
buf_size -= stride;
break;
case 1:
bytestream2_init(&s->gb, buf, buf_size);
ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr);
return -1;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown FourCC: %X\n", avctx->codec_tag);
return -1;
if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
memcpy(s->frame.data[1], s->palette, s->palette_size);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AascContext *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
if (VAR_0->reget_buffer(VAR_0, &s->frame)) {
av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
VAR_6 = AV_RL32(VAR_4);
VAR_4 += 4;
VAR_5 -= 4;
VAR_9 = VAR_0->bits_per_coded_sample / 8;
switch (VAR_0->codec_tag) {
case MKTAG('A', 'A', 'S', '4'):
bytestream2_init(&s->gb, VAR_4 - 4, VAR_5 + 4);
ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);
break;
case MKTAG('A', 'A', 'S', 'C'):
switch(VAR_6){
case 0:
VAR_8 = (VAR_0->width * VAR_9 + VAR_9) & ~VAR_9;
for(VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--){
if(VAR_0->width * VAR_9 > VAR_5){
av_log(VAR_0, AV_LOG_ERROR, "Next line is beyond buffer bounds\n");
break;
memcpy(s->frame.VAR_1[0] + VAR_7*s->frame.linesize[0], VAR_4, VAR_0->width * VAR_9);
VAR_4 += VAR_8;
VAR_5 -= VAR_8;
break;
case 1:
bytestream2_init(&s->gb, VAR_4, VAR_5);
ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown compression type %d\n", VAR_6);
return -1;
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "Unknown FourCC: %X\n", VAR_0->codec_tag);
return -1;
if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8)
memcpy(s->frame.VAR_1[1], s->palette, s->palette_size);
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1 = s->frame;
return VAR_5; | [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AascContext *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"s->frame.reference = 3;",
"s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;",
"if (VAR_0->reget_buffer(VAR_0, &s->frame)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reget_buffer() failed\\n\");",
"return -1;",
"VAR_6 = AV_RL32(VAR_4);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"VAR_9 = VAR_0->bits_per_coded_sample / 8;",
"switch (VAR_0->codec_tag) {",
"case MKTAG('A', 'A', 'S', '4'):\nbytestream2_init(&s->gb, VAR_4 - 4, VAR_5 + 4);",
"ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);",
"break;",
"case MKTAG('A', 'A', 'S', 'C'):\nswitch(VAR_6){",
"case 0:\nVAR_8 = (VAR_0->width * VAR_9 + VAR_9) & ~VAR_9;",
"for(VAR_7 = VAR_0->height - 1; VAR_7 >= 0; VAR_7--){",
"if(VAR_0->width * VAR_9 > VAR_5){",
"av_log(VAR_0, AV_LOG_ERROR, \"Next line is beyond buffer bounds\\n\");",
"break;",
"memcpy(s->frame.VAR_1[0] + VAR_7*s->frame.linesize[0], VAR_4, VAR_0->width * VAR_9);",
"VAR_4 += VAR_8;",
"VAR_5 -= VAR_8;",
"break;",
"case 1:\nbytestream2_init(&s->gb, VAR_4, VAR_5);",
"ff_msrle_decode(VAR_0, (AVPicture*)&s->frame, 8, &s->gb);",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown compression type %d\\n\", VAR_6);",
"return -1;",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unknown FourCC: %X\\n\", VAR_0->codec_tag);",
"return -1;",
"if (VAR_0->pix_fmt == AV_PIX_FMT_PAL8)\nmemcpy(s->frame.VAR_1[1], s->palette, s->palette_size);",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1 = s->frame;",
"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
] | [
[
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
],
[
51
]
] |
25,691 | int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
int64_t size)
{
int ret = qcow2_check_metadata_overlap(bs, ign, offset, size);
if (ret < 0) {
return ret;
} else if (ret > 0) {
int metadata_ol_bitnr = ffs(ret) - 1;
char *message;
assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR);
fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps "
"with %s); image marked as corrupt.\n",
metadata_ol_names[metadata_ol_bitnr]);
message = g_strdup_printf("Prevented %s overwrite",
metadata_ol_names[metadata_ol_bitnr]);
qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),
message,
true,
offset,
true,
size,
true,
&error_abort);
g_free(message);
qcow2_mark_corrupt(bs);
bs->drv = NULL; /* make BDS unusable */
return -EIO;
}
return 0;
}
| true | qemu | adb435522b86b3fca2324cb8c94e17b55ae071f1 | int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
int64_t size)
{
int ret = qcow2_check_metadata_overlap(bs, ign, offset, size);
if (ret < 0) {
return ret;
} else if (ret > 0) {
int metadata_ol_bitnr = ffs(ret) - 1;
char *message;
assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR);
fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps "
"with %s); image marked as corrupt.\n",
metadata_ol_names[metadata_ol_bitnr]);
message = g_strdup_printf("Prevented %s overwrite",
metadata_ol_names[metadata_ol_bitnr]);
qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),
message,
true,
offset,
true,
size,
true,
&error_abort);
g_free(message);
qcow2_mark_corrupt(bs);
bs->drv = NULL;
return -EIO;
}
return 0;
}
| {
"code": [
" char *message;",
" fprintf(stderr, \"qcow2: Preventing invalid write on metadata (overlaps \"",
" \"with %s); image marked as corrupt.\\n\",",
" metadata_ol_names[metadata_ol_bitnr]);",
" message = g_strdup_printf(\"Prevented %s overwrite\",",
" metadata_ol_names[metadata_ol_bitnr]);",
" qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),",
" message,",
" true,",
" offset,",
" true,",
" size,",
" true,",
" &error_abort);",
" g_free(message);",
" qcow2_mark_corrupt(bs);"
],
"line_no": [
19,
27,
29,
31,
33,
31,
37,
39,
41,
43,
41,
47,
41,
51,
53,
57
]
} | int FUNC_0(BlockDriverState *VAR_0, int VAR_1, int64_t VAR_2,
int64_t VAR_3)
{
int VAR_4 = qcow2_check_metadata_overlap(VAR_0, VAR_1, VAR_2, VAR_3);
if (VAR_4 < 0) {
return VAR_4;
} else if (VAR_4 > 0) {
int VAR_5 = ffs(VAR_4) - 1;
char *VAR_6;
assert(VAR_5 < QCOW2_OL_MAX_BITNR);
fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps "
"with %s); image marked as corrupt.\n",
metadata_ol_names[VAR_5]);
VAR_6 = g_strdup_printf("Prevented %s overwrite",
metadata_ol_names[VAR_5]);
qapi_event_send_block_image_corrupted(bdrv_get_device_name(VAR_0),
VAR_6,
true,
VAR_2,
true,
VAR_3,
true,
&error_abort);
g_free(VAR_6);
qcow2_mark_corrupt(VAR_0);
VAR_0->drv = NULL;
return -EIO;
}
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int VAR_1, int64_t VAR_2,\nint64_t VAR_3)\n{",
"int VAR_4 = qcow2_check_metadata_overlap(VAR_0, VAR_1, VAR_2, VAR_3);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"} else if (VAR_4 > 0) {",
"int VAR_5 = ffs(VAR_4) - 1;",
"char *VAR_6;",
"assert(VAR_5 < QCOW2_OL_MAX_BITNR);",
"fprintf(stderr, \"qcow2: Preventing invalid write on metadata (overlaps \"\n\"with %s); image marked as corrupt.\\n\",",
"metadata_ol_names[VAR_5]);",
"VAR_6 = g_strdup_printf(\"Prevented %s overwrite\",\nmetadata_ol_names[VAR_5]);",
"qapi_event_send_block_image_corrupted(bdrv_get_device_name(VAR_0),\nVAR_6,\ntrue,\nVAR_2,\ntrue,\nVAR_3,\ntrue,\n&error_abort);",
"g_free(VAR_6);",
"qcow2_mark_corrupt(VAR_0);",
"VAR_0->drv = NULL;",
"return -EIO;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27,
29
],
[
31
],
[
33,
35
],
[
37,
39,
41,
43,
45,
47,
49,
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
] |
25,692 | static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVDMGState *s = bs->opaque;
uint64_t info_begin, info_end, last_in_offset, last_out_offset;
uint32_t count, tmp;
uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i;
int64_t offset;
int ret;
bs->read_only = 1;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
/* read offset of info blocks */
offset = bdrv_getlength(bs->file);
if (offset < 0) {
ret = offset;
offset -= 0x1d8;
ret = read_uint64(bs, offset, &info_begin);
if (ret < 0) {
} else if (info_begin == 0) {
ret = read_uint32(bs, info_begin, &tmp);
if (ret < 0) {
} else if (tmp != 0x100) {
ret = read_uint32(bs, info_begin + 4, &count);
if (ret < 0) {
} else if (count == 0) {
info_end = info_begin + count;
offset = info_begin + 0x100;
/* read offsets */
last_in_offset = last_out_offset = 0;
while (offset < info_end) {
uint32_t type;
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
} else if (count == 0) {
offset += 4;
ret = read_uint32(bs, offset, &type);
if (ret < 0) {
if (type == 0x6d697368 && count >= 244) {
size_t new_size;
uint32_t chunk_count;
offset += 4;
offset += 200;
chunk_count = (count - 204) / 40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
s->types = g_realloc(s->types, new_size / 2);
s->offsets = g_realloc(s->offsets, new_size);
s->lengths = g_realloc(s->lengths, new_size);
s->sectors = g_realloc(s->sectors, new_size);
s->sectorcounts = g_realloc(s->sectorcounts, new_size);
for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) {
ret = read_uint32(bs, offset, &s->types[i]);
if (ret < 0) {
offset += 4;
if (s->types[i] != 0x80000005 && s->types[i] != 1 &&
s->types[i] != 2) {
if (s->types[i] == 0xffffffff && i > 0) {
last_in_offset = s->offsets[i - 1] + s->lengths[i - 1];
last_out_offset = s->sectors[i - 1] +
s->sectorcounts[i - 1];
chunk_count--;
i--;
offset += 36;
continue;
offset += 4;
ret = read_uint64(bs, offset, &s->sectors[i]);
if (ret < 0) {
s->sectors[i] += last_out_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->sectorcounts[i]);
if (ret < 0) {
offset += 8;
if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
error_report("sector count %" PRIu64 " for chunk %u is "
"larger than max (%u)",
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
ret = read_uint64(bs, offset, &s->offsets[i]);
if (ret < 0) {
s->offsets[i] += last_in_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->lengths[i]);
if (ret < 0) {
offset += 8;
if (s->lengths[i] > max_compressed_size) {
max_compressed_size = s->lengths[i];
if (s->sectorcounts[i] > max_sectors_per_chunk) {
max_sectors_per_chunk = s->sectorcounts[i];
s->n_chunks += chunk_count;
/* initialize zlib engine */
s->compressed_chunk = g_malloc(max_compressed_size + 1);
s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk);
if (inflateInit(&s->zstream) != Z_OK) {
s->current_chunk = s->n_chunks;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->types);
g_free(s->offsets);
g_free(s->lengths);
g_free(s->sectors);
g_free(s->sectorcounts);
g_free(s->compressed_chunk);
g_free(s->uncompressed_chunk);
return ret; | true | qemu | c165f7758009a4f793c1fc19ebb69cf55313450b | static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVDMGState *s = bs->opaque;
uint64_t info_begin, info_end, last_in_offset, last_out_offset;
uint32_t count, tmp;
uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i;
int64_t offset;
int ret;
bs->read_only = 1;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
offset = bdrv_getlength(bs->file);
if (offset < 0) {
ret = offset;
offset -= 0x1d8;
ret = read_uint64(bs, offset, &info_begin);
if (ret < 0) {
} else if (info_begin == 0) {
ret = read_uint32(bs, info_begin, &tmp);
if (ret < 0) {
} else if (tmp != 0x100) {
ret = read_uint32(bs, info_begin + 4, &count);
if (ret < 0) {
} else if (count == 0) {
info_end = info_begin + count;
offset = info_begin + 0x100;
last_in_offset = last_out_offset = 0;
while (offset < info_end) {
uint32_t type;
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
} else if (count == 0) {
offset += 4;
ret = read_uint32(bs, offset, &type);
if (ret < 0) {
if (type == 0x6d697368 && count >= 244) {
size_t new_size;
uint32_t chunk_count;
offset += 4;
offset += 200;
chunk_count = (count - 204) / 40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
s->types = g_realloc(s->types, new_size / 2);
s->offsets = g_realloc(s->offsets, new_size);
s->lengths = g_realloc(s->lengths, new_size);
s->sectors = g_realloc(s->sectors, new_size);
s->sectorcounts = g_realloc(s->sectorcounts, new_size);
for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) {
ret = read_uint32(bs, offset, &s->types[i]);
if (ret < 0) {
offset += 4;
if (s->types[i] != 0x80000005 && s->types[i] != 1 &&
s->types[i] != 2) {
if (s->types[i] == 0xffffffff && i > 0) {
last_in_offset = s->offsets[i - 1] + s->lengths[i - 1];
last_out_offset = s->sectors[i - 1] +
s->sectorcounts[i - 1];
chunk_count--;
i--;
offset += 36;
continue;
offset += 4;
ret = read_uint64(bs, offset, &s->sectors[i]);
if (ret < 0) {
s->sectors[i] += last_out_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->sectorcounts[i]);
if (ret < 0) {
offset += 8;
if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
error_report("sector count %" PRIu64 " for chunk %u is "
"larger than max (%u)",
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
ret = read_uint64(bs, offset, &s->offsets[i]);
if (ret < 0) {
s->offsets[i] += last_in_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->lengths[i]);
if (ret < 0) {
offset += 8;
if (s->lengths[i] > max_compressed_size) {
max_compressed_size = s->lengths[i];
if (s->sectorcounts[i] > max_sectors_per_chunk) {
max_sectors_per_chunk = s->sectorcounts[i];
s->n_chunks += chunk_count;
s->compressed_chunk = g_malloc(max_compressed_size + 1);
s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk);
if (inflateInit(&s->zstream) != Z_OK) {
s->current_chunk = s->n_chunks;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->types);
g_free(s->offsets);
g_free(s->lengths);
g_free(s->sectors);
g_free(s->sectorcounts);
g_free(s->compressed_chunk);
g_free(s->uncompressed_chunk);
return ret; | {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{
BDRVDMGState *s = VAR_0->opaque;
uint64_t info_begin, info_end, last_in_offset, last_out_offset;
uint32_t count, tmp;
uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i;
int64_t offset;
int VAR_4;
VAR_0->read_only = 1;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
offset = bdrv_getlength(VAR_0->file);
if (offset < 0) {
VAR_4 = offset;
offset -= 0x1d8;
VAR_4 = read_uint64(VAR_0, offset, &info_begin);
if (VAR_4 < 0) {
} else if (info_begin == 0) {
VAR_4 = read_uint32(VAR_0, info_begin, &tmp);
if (VAR_4 < 0) {
} else if (tmp != 0x100) {
VAR_4 = read_uint32(VAR_0, info_begin + 4, &count);
if (VAR_4 < 0) {
} else if (count == 0) {
info_end = info_begin + count;
offset = info_begin + 0x100;
last_in_offset = last_out_offset = 0;
while (offset < info_end) {
uint32_t type;
VAR_4 = read_uint32(VAR_0, offset, &count);
if (VAR_4 < 0) {
} else if (count == 0) {
offset += 4;
VAR_4 = read_uint32(VAR_0, offset, &type);
if (VAR_4 < 0) {
if (type == 0x6d697368 && count >= 244) {
size_t new_size;
uint32_t chunk_count;
offset += 4;
offset += 200;
chunk_count = (count - 204) / 40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
s->types = g_realloc(s->types, new_size / 2);
s->offsets = g_realloc(s->offsets, new_size);
s->lengths = g_realloc(s->lengths, new_size);
s->sectors = g_realloc(s->sectors, new_size);
s->sectorcounts = g_realloc(s->sectorcounts, new_size);
for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) {
VAR_4 = read_uint32(VAR_0, offset, &s->types[i]);
if (VAR_4 < 0) {
offset += 4;
if (s->types[i] != 0x80000005 && s->types[i] != 1 &&
s->types[i] != 2) {
if (s->types[i] == 0xffffffff && i > 0) {
last_in_offset = s->offsets[i - 1] + s->lengths[i - 1];
last_out_offset = s->sectors[i - 1] +
s->sectorcounts[i - 1];
chunk_count--;
i--;
offset += 36;
continue;
offset += 4;
VAR_4 = read_uint64(VAR_0, offset, &s->sectors[i]);
if (VAR_4 < 0) {
s->sectors[i] += last_out_offset;
offset += 8;
VAR_4 = read_uint64(VAR_0, offset, &s->sectorcounts[i]);
if (VAR_4 < 0) {
offset += 8;
if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
error_report("sector count %" PRIu64 " for chunk %u is "
"larger than max (%u)",
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
VAR_4 = read_uint64(VAR_0, offset, &s->offsets[i]);
if (VAR_4 < 0) {
s->offsets[i] += last_in_offset;
offset += 8;
VAR_4 = read_uint64(VAR_0, offset, &s->lengths[i]);
if (VAR_4 < 0) {
offset += 8;
if (s->lengths[i] > max_compressed_size) {
max_compressed_size = s->lengths[i];
if (s->sectorcounts[i] > max_sectors_per_chunk) {
max_sectors_per_chunk = s->sectorcounts[i];
s->n_chunks += chunk_count;
s->compressed_chunk = g_malloc(max_compressed_size + 1);
s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk);
if (inflateInit(&s->zstream) != Z_OK) {
s->current_chunk = s->n_chunks;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->types);
g_free(s->offsets);
g_free(s->lengths);
g_free(s->sectors);
g_free(s->sectorcounts);
g_free(s->compressed_chunk);
g_free(s->uncompressed_chunk);
return VAR_4; | [
"static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{",
"BDRVDMGState *s = VAR_0->opaque;",
"uint64_t info_begin, info_end, last_in_offset, last_out_offset;",
"uint32_t count, tmp;",
"uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i;",
"int64_t offset;",
"int VAR_4;",
"VAR_0->read_only = 1;",
"s->n_chunks = 0;",
"s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;",
"offset = bdrv_getlength(VAR_0->file);",
"if (offset < 0) {",
"VAR_4 = offset;",
"offset -= 0x1d8;",
"VAR_4 = read_uint64(VAR_0, offset, &info_begin);",
"if (VAR_4 < 0) {",
"} else if (info_begin == 0) {",
"VAR_4 = read_uint32(VAR_0, info_begin, &tmp);",
"if (VAR_4 < 0) {",
"} else if (tmp != 0x100) {",
"VAR_4 = read_uint32(VAR_0, info_begin + 4, &count);",
"if (VAR_4 < 0) {",
"} else if (count == 0) {",
"info_end = info_begin + count;",
"offset = info_begin + 0x100;",
"last_in_offset = last_out_offset = 0;",
"while (offset < info_end) {",
"uint32_t type;",
"VAR_4 = read_uint32(VAR_0, offset, &count);",
"if (VAR_4 < 0) {",
"} else if (count == 0) {",
"offset += 4;",
"VAR_4 = read_uint32(VAR_0, offset, &type);",
"if (VAR_4 < 0) {",
"if (type == 0x6d697368 && count >= 244) {",
"size_t new_size;",
"uint32_t chunk_count;",
"offset += 4;",
"offset += 200;",
"chunk_count = (count - 204) / 40;",
"new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);",
"s->types = g_realloc(s->types, new_size / 2);",
"s->offsets = g_realloc(s->offsets, new_size);",
"s->lengths = g_realloc(s->lengths, new_size);",
"s->sectors = g_realloc(s->sectors, new_size);",
"s->sectorcounts = g_realloc(s->sectorcounts, new_size);",
"for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) {",
"VAR_4 = read_uint32(VAR_0, offset, &s->types[i]);",
"if (VAR_4 < 0) {",
"offset += 4;",
"if (s->types[i] != 0x80000005 && s->types[i] != 1 &&\ns->types[i] != 2) {",
"if (s->types[i] == 0xffffffff && i > 0) {",
"last_in_offset = s->offsets[i - 1] + s->lengths[i - 1];",
"last_out_offset = s->sectors[i - 1] +\ns->sectorcounts[i - 1];",
"chunk_count--;",
"i--;",
"offset += 36;",
"continue;",
"offset += 4;",
"VAR_4 = read_uint64(VAR_0, offset, &s->sectors[i]);",
"if (VAR_4 < 0) {",
"s->sectors[i] += last_out_offset;",
"offset += 8;",
"VAR_4 = read_uint64(VAR_0, offset, &s->sectorcounts[i]);",
"if (VAR_4 < 0) {",
"offset += 8;",
"if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {",
"error_report(\"sector count %\" PRIu64 \" for chunk %u is \"\n\"larger than max (%u)\",\ns->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);",
"VAR_4 = read_uint64(VAR_0, offset, &s->offsets[i]);",
"if (VAR_4 < 0) {",
"s->offsets[i] += last_in_offset;",
"offset += 8;",
"VAR_4 = read_uint64(VAR_0, offset, &s->lengths[i]);",
"if (VAR_4 < 0) {",
"offset += 8;",
"if (s->lengths[i] > max_compressed_size) {",
"max_compressed_size = s->lengths[i];",
"if (s->sectorcounts[i] > max_sectors_per_chunk) {",
"max_sectors_per_chunk = s->sectorcounts[i];",
"s->n_chunks += chunk_count;",
"s->compressed_chunk = g_malloc(max_compressed_size + 1);",
"s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk);",
"if (inflateInit(&s->zstream) != Z_OK) {",
"s->current_chunk = s->n_chunks;",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"fail:\ng_free(s->types);",
"g_free(s->offsets);",
"g_free(s->lengths);",
"g_free(s->sectors);",
"g_free(s->sectorcounts);",
"g_free(s->compressed_chunk);",
"g_free(s->uncompressed_chunk);",
"return VAR_4;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
28
],
[
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
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96,
97
],
[
98
],
[
99
],
[
100
],
[
101
],
[
102
],
[
103
],
[
104
]
] |
25,695 | int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
{
int len, nb_components, i, width, height, pix_fmt_id;
s->cur_scan = 0;
s->upscale_h = s->upscale_v = 0;
/* XXX: verify len field validity */
len = get_bits(&s->gb, 16);
s->bits = get_bits(&s->gb, 8);
if (s->pegasus_rct)
s->bits = 9;
if (s->bits == 9 && !s->pegasus_rct)
s->rct = 1; // FIXME ugly
if (s->bits != 8 && !s->lossless) {
av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
return -1;
}
if(s->lossless && s->avctx->lowres){
av_log(s->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n");
return -1;
}
height = get_bits(&s->gb, 16);
width = get_bits(&s->gb, 16);
// HACK for odd_height.mov
if (s->interlaced && s->width == width && s->height == height + 1)
height= s->height;
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR_INVALIDDATA;
nb_components = get_bits(&s->gb, 8);
if (nb_components <= 0 ||
nb_components > MAX_COMPONENTS)
return -1;
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (nb_components != s->nb_components) {
av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
return AVERROR_INVALIDDATA;
}
}
if (s->ls && !(s->bits <= 8 || nb_components == 1)) {
av_log_missing_feature(s->avctx,
"For JPEG-LS anything except <= 8 bits/component"
" or 16-bit gray", 0);
return AVERROR_PATCHWELCOME;
}
s->nb_components = nb_components;
s->h_max = 1;
s->v_max = 1;
memset(s->h_count, 0, sizeof(s->h_count));
memset(s->v_count, 0, sizeof(s->v_count));
for (i = 0; i < nb_components; i++) {
/* component id */
s->component_id[i] = get_bits(&s->gb, 8) - 1;
s->h_count[i] = get_bits(&s->gb, 4);
s->v_count[i] = get_bits(&s->gb, 4);
/* compute hmax and vmax (only used in interleaved case) */
if (s->h_count[i] > s->h_max)
s->h_max = s->h_count[i];
if (s->v_count[i] > s->v_max)
s->v_max = s->v_count[i];
if (!s->h_count[i] || !s->v_count[i]) {
av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
return -1;
}
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return AVERROR_INVALIDDATA;
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
i, s->h_count[i], s->v_count[i],
s->component_id[i], s->quant_index[i]);
}
if (s->ls && (s->h_max > 1 || s->v_max > 1)) {
av_log_missing_feature(s->avctx, "Subsampling in JPEG-LS", 0);
return AVERROR_PATCHWELCOME;
}
if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3)
s->rgb = 1;
/* if different size, realloc/alloc picture */
/* XXX: also check h_count and v_count */
if (width != s->width || height != s->height) {
av_freep(&s->qscale_table);
s->width = width;
s->height = height;
s->interlaced = 0;
/* test interlaced mode */
if (s->first_picture &&
s->org_height != 0 &&
s->height < ((s->org_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = s->interlace_polarity;
s->picture_ptr->interlaced_frame = 1;
s->picture_ptr->top_field_first = !s->interlace_polarity;
height *= 2;
}
avcodec_set_dimensions(s->avctx, width, height);
s->qscale_table = av_mallocz((s->width + 15) / 16);
s->first_picture = 0;
}
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (s->progressive) {
av_log_ask_for_sample(s->avctx, "progressively coded interlaced pictures not supported\n");
return AVERROR_INVALIDDATA;
}
} else{
/* XXX: not complete test ! */
pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
(s->h_count[1] << 20) | (s->v_count[1] << 16) |
(s->h_count[2] << 12) | (s->v_count[2] << 8) |
(s->h_count[3] << 4) | s->v_count[3];
av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
/* NOTE we do not allocate pictures large enough for the possible
* padding of h/v_count being 4 */
if (!(pix_fmt_id & 0xD0D0D0D0))
pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
if (!(pix_fmt_id & 0x0D0D0D0D))
pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
switch (pix_fmt_id) {
case 0x11111100:
if (s->rgb)
s->avctx->pix_fmt = AV_PIX_FMT_BGR24;
else {
if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
s->avctx->pix_fmt = AV_PIX_FMT_GBR24P;
} else {
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
}
av_assert0(s->nb_components == 3);
break;
case 0x12121100:
case 0x22122100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = (pix_fmt_id == 0x22122100);
s->chroma_height = s->height;
break;
case 0x21211100:
case 0x22211200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22211200);
s->upscale_h = 2;
s->chroma_height = s->height;
break;
case 0x22221100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = 2;
s->chroma_height = s->height / 2;
break;
case 0x11000000:
if(s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
break;
case 0x12111100:
case 0x22211100:
case 0x22112100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_h = (pix_fmt_id == 0x22211100) * 2 + (pix_fmt_id == 0x22112100);
s->chroma_height = s->height / 2;
break;
case 0x21111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
case 0x22121100:
case 0x22111200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22121100) + 1;
break;
case 0x22111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id);
return AVERROR_PATCHWELCOME;
}
if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) {
av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n");
return AVERROR_PATCHWELCOME;
}
if (s->ls) {
s->upscale_h = s->upscale_v = 0;
if (s->nb_components > 1)
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
else if (s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
if (s->picture_ptr->data[0])
s->avctx->release_buffer(s->avctx, s->picture_ptr);
if (s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
s->picture_ptr->key_frame = 1;
s->got_picture = 1;
for (i = 0; i < 3; i++)
s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced;
av_dlog(s->avctx, "%d %d %d %d %d %d\n",
s->width, s->height, s->linesize[0], s->linesize[1],
s->interlaced, s->avctx->height);
if (len != (8 + (3 * nb_components)))
av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len);
}
/* totally blank picture as progressive JPEG will only add details to it */
if (s->progressive) {
int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8);
int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8);
for (i = 0; i < s->nb_components; i++) {
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz));
s->block_stride[i] = bw * s->h_count[i];
}
memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
}
return 0;
}
| false | FFmpeg | a2f680c7bc7642c687aeb4e14d00ac74833c7a09 | int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
{
int len, nb_components, i, width, height, pix_fmt_id;
s->cur_scan = 0;
s->upscale_h = s->upscale_v = 0;
len = get_bits(&s->gb, 16);
s->bits = get_bits(&s->gb, 8);
if (s->pegasus_rct)
s->bits = 9;
if (s->bits == 9 && !s->pegasus_rct)
s->rct = 1;
if (s->bits != 8 && !s->lossless) {
av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
return -1;
}
if(s->lossless && s->avctx->lowres){
av_log(s->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n");
return -1;
}
height = get_bits(&s->gb, 16);
width = get_bits(&s->gb, 16);
if (s->interlaced && s->width == width && s->height == height + 1)
height= s->height;
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR_INVALIDDATA;
nb_components = get_bits(&s->gb, 8);
if (nb_components <= 0 ||
nb_components > MAX_COMPONENTS)
return -1;
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (nb_components != s->nb_components) {
av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
return AVERROR_INVALIDDATA;
}
}
if (s->ls && !(s->bits <= 8 || nb_components == 1)) {
av_log_missing_feature(s->avctx,
"For JPEG-LS anything except <= 8 bits/component"
" or 16-bit gray", 0);
return AVERROR_PATCHWELCOME;
}
s->nb_components = nb_components;
s->h_max = 1;
s->v_max = 1;
memset(s->h_count, 0, sizeof(s->h_count));
memset(s->v_count, 0, sizeof(s->v_count));
for (i = 0; i < nb_components; i++) {
s->component_id[i] = get_bits(&s->gb, 8) - 1;
s->h_count[i] = get_bits(&s->gb, 4);
s->v_count[i] = get_bits(&s->gb, 4);
if (s->h_count[i] > s->h_max)
s->h_max = s->h_count[i];
if (s->v_count[i] > s->v_max)
s->v_max = s->v_count[i];
if (!s->h_count[i] || !s->v_count[i]) {
av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
return -1;
}
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return AVERROR_INVALIDDATA;
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
i, s->h_count[i], s->v_count[i],
s->component_id[i], s->quant_index[i]);
}
if (s->ls && (s->h_max > 1 || s->v_max > 1)) {
av_log_missing_feature(s->avctx, "Subsampling in JPEG-LS", 0);
return AVERROR_PATCHWELCOME;
}
if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3)
s->rgb = 1;
if (width != s->width || height != s->height) {
av_freep(&s->qscale_table);
s->width = width;
s->height = height;
s->interlaced = 0;
if (s->first_picture &&
s->org_height != 0 &&
s->height < ((s->org_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = s->interlace_polarity;
s->picture_ptr->interlaced_frame = 1;
s->picture_ptr->top_field_first = !s->interlace_polarity;
height *= 2;
}
avcodec_set_dimensions(s->avctx, width, height);
s->qscale_table = av_mallocz((s->width + 15) / 16);
s->first_picture = 0;
}
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (s->progressive) {
av_log_ask_for_sample(s->avctx, "progressively coded interlaced pictures not supported\n");
return AVERROR_INVALIDDATA;
}
} else{
pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
(s->h_count[1] << 20) | (s->v_count[1] << 16) |
(s->h_count[2] << 12) | (s->v_count[2] << 8) |
(s->h_count[3] << 4) | s->v_count[3];
av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
if (!(pix_fmt_id & 0xD0D0D0D0))
pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
if (!(pix_fmt_id & 0x0D0D0D0D))
pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
switch (pix_fmt_id) {
case 0x11111100:
if (s->rgb)
s->avctx->pix_fmt = AV_PIX_FMT_BGR24;
else {
if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
s->avctx->pix_fmt = AV_PIX_FMT_GBR24P;
} else {
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
}
av_assert0(s->nb_components == 3);
break;
case 0x12121100:
case 0x22122100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = (pix_fmt_id == 0x22122100);
s->chroma_height = s->height;
break;
case 0x21211100:
case 0x22211200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22211200);
s->upscale_h = 2;
s->chroma_height = s->height;
break;
case 0x22221100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = 2;
s->chroma_height = s->height / 2;
break;
case 0x11000000:
if(s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
break;
case 0x12111100:
case 0x22211100:
case 0x22112100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_h = (pix_fmt_id == 0x22211100) * 2 + (pix_fmt_id == 0x22112100);
s->chroma_height = s->height / 2;
break;
case 0x21111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
case 0x22121100:
case 0x22111200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22121100) + 1;
break;
case 0x22111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id);
return AVERROR_PATCHWELCOME;
}
if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) {
av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n");
return AVERROR_PATCHWELCOME;
}
if (s->ls) {
s->upscale_h = s->upscale_v = 0;
if (s->nb_components > 1)
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
else if (s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
if (s->picture_ptr->data[0])
s->avctx->release_buffer(s->avctx, s->picture_ptr);
if (s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
s->picture_ptr->key_frame = 1;
s->got_picture = 1;
for (i = 0; i < 3; i++)
s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced;
av_dlog(s->avctx, "%d %d %d %d %d %d\n",
s->width, s->height, s->linesize[0], s->linesize[1],
s->interlaced, s->avctx->height);
if (len != (8 + (3 * nb_components)))
av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len);
}
if (s->progressive) {
int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8);
int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8);
for (i = 0; i < s->nb_components; i++) {
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz));
s->block_stride[i] = bw * s->h_count[i];
}
memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(MJpegDecodeContext *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
VAR_0->cur_scan = 0;
VAR_0->upscale_h = VAR_0->upscale_v = 0;
VAR_1 = get_bits(&VAR_0->gb, 16);
VAR_0->bits = get_bits(&VAR_0->gb, 8);
if (VAR_0->pegasus_rct)
VAR_0->bits = 9;
if (VAR_0->bits == 9 && !VAR_0->pegasus_rct)
VAR_0->rct = 1;
if (VAR_0->bits != 8 && !VAR_0->lossless) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
return -1;
}
if(VAR_0->lossless && VAR_0->avctx->lowres){
av_log(VAR_0->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n");
return -1;
}
VAR_5 = get_bits(&VAR_0->gb, 16);
VAR_4 = get_bits(&VAR_0->gb, 16);
if (VAR_0->interlaced && VAR_0->VAR_4 == VAR_4 && VAR_0->VAR_5 == VAR_5 + 1)
VAR_5= VAR_0->VAR_5;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", VAR_4, VAR_5);
if (av_image_check_size(VAR_4, VAR_5, 0, VAR_0->avctx))
return AVERROR_INVALIDDATA;
VAR_2 = get_bits(&VAR_0->gb, 8);
if (VAR_2 <= 0 ||
VAR_2 > MAX_COMPONENTS)
return -1;
if (VAR_0->interlaced && (VAR_0->bottom_field == !VAR_0->interlace_polarity)) {
if (VAR_2 != VAR_0->VAR_2) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_2 changing in interlaced picture\n");
return AVERROR_INVALIDDATA;
}
}
if (VAR_0->ls && !(VAR_0->bits <= 8 || VAR_2 == 1)) {
av_log_missing_feature(VAR_0->avctx,
"For JPEG-LS anything except <= 8 bits/component"
" or 16-bit gray", 0);
return AVERROR_PATCHWELCOME;
}
VAR_0->VAR_2 = VAR_2;
VAR_0->h_max = 1;
VAR_0->v_max = 1;
memset(VAR_0->h_count, 0, sizeof(VAR_0->h_count));
memset(VAR_0->v_count, 0, sizeof(VAR_0->v_count));
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
VAR_0->component_id[VAR_3] = get_bits(&VAR_0->gb, 8) - 1;
VAR_0->h_count[VAR_3] = get_bits(&VAR_0->gb, 4);
VAR_0->v_count[VAR_3] = get_bits(&VAR_0->gb, 4);
if (VAR_0->h_count[VAR_3] > VAR_0->h_max)
VAR_0->h_max = VAR_0->h_count[VAR_3];
if (VAR_0->v_count[VAR_3] > VAR_0->v_max)
VAR_0->v_max = VAR_0->v_count[VAR_3];
if (!VAR_0->h_count[VAR_3] || !VAR_0->v_count[VAR_3]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
return -1;
}
VAR_0->quant_index[VAR_3] = get_bits(&VAR_0->gb, 8);
if (VAR_0->quant_index[VAR_3] >= 4)
return AVERROR_INVALIDDATA;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
VAR_3, VAR_0->h_count[VAR_3], VAR_0->v_count[VAR_3],
VAR_0->component_id[VAR_3], VAR_0->quant_index[VAR_3]);
}
if (VAR_0->ls && (VAR_0->h_max > 1 || VAR_0->v_max > 1)) {
av_log_missing_feature(VAR_0->avctx, "Subsampling in JPEG-LS", 0);
return AVERROR_PATCHWELCOME;
}
if (VAR_0->v_max == 1 && VAR_0->h_max == 1 && VAR_0->lossless==1 && VAR_2==3)
VAR_0->rgb = 1;
if (VAR_4 != VAR_0->VAR_4 || VAR_5 != VAR_0->VAR_5) {
av_freep(&VAR_0->qscale_table);
VAR_0->VAR_4 = VAR_4;
VAR_0->VAR_5 = VAR_5;
VAR_0->interlaced = 0;
if (VAR_0->first_picture &&
VAR_0->org_height != 0 &&
VAR_0->VAR_5 < ((VAR_0->org_height * 3) / 4)) {
VAR_0->interlaced = 1;
VAR_0->bottom_field = VAR_0->interlace_polarity;
VAR_0->picture_ptr->interlaced_frame = 1;
VAR_0->picture_ptr->top_field_first = !VAR_0->interlace_polarity;
VAR_5 *= 2;
}
avcodec_set_dimensions(VAR_0->avctx, VAR_4, VAR_5);
VAR_0->qscale_table = av_mallocz((VAR_0->VAR_4 + 15) / 16);
VAR_0->first_picture = 0;
}
if (VAR_0->interlaced && (VAR_0->bottom_field == !VAR_0->interlace_polarity)) {
if (VAR_0->progressive) {
av_log_ask_for_sample(VAR_0->avctx, "progressively coded interlaced pictures not supported\n");
return AVERROR_INVALIDDATA;
}
} else{
VAR_6 = (VAR_0->h_count[0] << 28) | (VAR_0->v_count[0] << 24) |
(VAR_0->h_count[1] << 20) | (VAR_0->v_count[1] << 16) |
(VAR_0->h_count[2] << 12) | (VAR_0->v_count[2] << 8) |
(VAR_0->h_count[3] << 4) | VAR_0->v_count[3];
av_log(VAR_0->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", VAR_6);
if (!(VAR_6 & 0xD0D0D0D0))
VAR_6 -= (VAR_6 & 0xF0F0F0F0) >> 1;
if (!(VAR_6 & 0x0D0D0D0D))
VAR_6 -= (VAR_6 & 0x0F0F0F0F) >> 1;
switch (VAR_6) {
case 0x11111100:
if (VAR_0->rgb)
VAR_0->avctx->pix_fmt = AV_PIX_FMT_BGR24;
else {
if (VAR_0->component_id[0] == 'Q' && VAR_0->component_id[1] == 'F' && VAR_0->component_id[2] == 'A') {
VAR_0->avctx->pix_fmt = AV_PIX_FMT_GBR24P;
} else {
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
}
av_assert0(VAR_0->VAR_2 == 3);
break;
case 0x12121100:
case 0x22122100:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
VAR_0->upscale_v = 2;
VAR_0->upscale_h = (VAR_6 == 0x22122100);
VAR_0->chroma_height = VAR_0->VAR_5;
break;
case 0x21211100:
case 0x22211200:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
VAR_0->upscale_v = (VAR_6 == 0x22211200);
VAR_0->upscale_h = 2;
VAR_0->chroma_height = VAR_0->VAR_5;
break;
case 0x22221100:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
VAR_0->upscale_v = 2;
VAR_0->upscale_h = 2;
VAR_0->chroma_height = VAR_0->VAR_5 / 2;
break;
case 0x11000000:
if(VAR_0->bits <= 8)
VAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
VAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
break;
case 0x12111100:
case 0x22211100:
case 0x22112100:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
VAR_0->upscale_h = (VAR_6 == 0x22211100) * 2 + (VAR_6 == 0x22112100);
VAR_0->chroma_height = VAR_0->VAR_5 / 2;
break;
case 0x21111100:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
case 0x22121100:
case 0x22111200:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
VAR_0->upscale_v = (VAR_6 == 0x22121100) + 1;
break;
case 0x22111100:
VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", VAR_6);
return AVERROR_PATCHWELCOME;
}
if ((VAR_0->upscale_h || VAR_0->upscale_v) && VAR_0->avctx->lowres) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n");
return AVERROR_PATCHWELCOME;
}
if (VAR_0->ls) {
VAR_0->upscale_h = VAR_0->upscale_v = 0;
if (VAR_0->VAR_2 > 1)
VAR_0->avctx->pix_fmt = AV_PIX_FMT_RGB24;
else if (VAR_0->bits <= 8)
VAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
VAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
if (VAR_0->picture_ptr->data[0])
VAR_0->avctx->release_buffer(VAR_0->avctx, VAR_0->picture_ptr);
if (VAR_0->avctx->get_buffer(VAR_0->avctx, VAR_0->picture_ptr) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
VAR_0->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
VAR_0->picture_ptr->key_frame = 1;
VAR_0->got_picture = 1;
for (VAR_3 = 0; VAR_3 < 3; VAR_3++)
VAR_0->linesize[VAR_3] = VAR_0->picture_ptr->linesize[VAR_3] << VAR_0->interlaced;
av_dlog(VAR_0->avctx, "%d %d %d %d %d %d\n",
VAR_0->VAR_4, VAR_0->VAR_5, VAR_0->linesize[0], VAR_0->linesize[1],
VAR_0->interlaced, VAR_0->avctx->VAR_5);
if (VAR_1 != (8 + (3 * VAR_2)))
av_log(VAR_0->avctx, AV_LOG_DEBUG, "decode_sof0: error, VAR_1(%d) mismatch\n", VAR_1);
}
if (VAR_0->progressive) {
int VAR_7 = (VAR_4 + VAR_0->h_max * 8 - 1) / (VAR_0->h_max * 8);
int VAR_8 = (VAR_5 + VAR_0->v_max * 8 - 1) / (VAR_0->v_max * 8);
for (VAR_3 = 0; VAR_3 < VAR_0->VAR_2; VAR_3++) {
int size = VAR_7 * VAR_8 * VAR_0->h_count[VAR_3] * VAR_0->v_count[VAR_3];
av_freep(&VAR_0->blocks[VAR_3]);
av_freep(&VAR_0->last_nnz[VAR_3]);
VAR_0->blocks[VAR_3] = av_malloc(size * sizeof(**VAR_0->blocks));
VAR_0->last_nnz[VAR_3] = av_mallocz(size * sizeof(**VAR_0->last_nnz));
VAR_0->block_stride[VAR_3] = VAR_7 * VAR_0->h_count[VAR_3];
}
memset(VAR_0->coefs_finished, 0, sizeof(VAR_0->coefs_finished));
}
return 0;
}
| [
"int FUNC_0(MJpegDecodeContext *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"VAR_0->cur_scan = 0;",
"VAR_0->upscale_h = VAR_0->upscale_v = 0;",
"VAR_1 = get_bits(&VAR_0->gb, 16);",
"VAR_0->bits = get_bits(&VAR_0->gb, 8);",
"if (VAR_0->pegasus_rct)\nVAR_0->bits = 9;",
"if (VAR_0->bits == 9 && !VAR_0->pegasus_rct)\nVAR_0->rct = 1;",
"if (VAR_0->bits != 8 && !VAR_0->lossless) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"only 8 bits/component accepted\\n\");",
"return -1;",
"}",
"if(VAR_0->lossless && VAR_0->avctx->lowres){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"lowres is not possible with lossless jpeg\\n\");",
"return -1;",
"}",
"VAR_5 = get_bits(&VAR_0->gb, 16);",
"VAR_4 = get_bits(&VAR_0->gb, 16);",
"if (VAR_0->interlaced && VAR_0->VAR_4 == VAR_4 && VAR_0->VAR_5 == VAR_5 + 1)\nVAR_5= VAR_0->VAR_5;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"sof0: picture: %dx%d\\n\", VAR_4, VAR_5);",
"if (av_image_check_size(VAR_4, VAR_5, 0, VAR_0->avctx))\nreturn AVERROR_INVALIDDATA;",
"VAR_2 = get_bits(&VAR_0->gb, 8);",
"if (VAR_2 <= 0 ||\nVAR_2 > MAX_COMPONENTS)\nreturn -1;",
"if (VAR_0->interlaced && (VAR_0->bottom_field == !VAR_0->interlace_polarity)) {",
"if (VAR_2 != VAR_0->VAR_2) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_2 changing in interlaced picture\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"if (VAR_0->ls && !(VAR_0->bits <= 8 || VAR_2 == 1)) {",
"av_log_missing_feature(VAR_0->avctx,\n\"For JPEG-LS anything except <= 8 bits/component\"\n\" or 16-bit gray\", 0);",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->h_max = 1;",
"VAR_0->v_max = 1;",
"memset(VAR_0->h_count, 0, sizeof(VAR_0->h_count));",
"memset(VAR_0->v_count, 0, sizeof(VAR_0->v_count));",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"VAR_0->component_id[VAR_3] = get_bits(&VAR_0->gb, 8) - 1;",
"VAR_0->h_count[VAR_3] = get_bits(&VAR_0->gb, 4);",
"VAR_0->v_count[VAR_3] = get_bits(&VAR_0->gb, 4);",
"if (VAR_0->h_count[VAR_3] > VAR_0->h_max)\nVAR_0->h_max = VAR_0->h_count[VAR_3];",
"if (VAR_0->v_count[VAR_3] > VAR_0->v_max)\nVAR_0->v_max = VAR_0->v_count[VAR_3];",
"if (!VAR_0->h_count[VAR_3] || !VAR_0->v_count[VAR_3]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"h/v_count is 0\\n\");",
"return -1;",
"}",
"VAR_0->quant_index[VAR_3] = get_bits(&VAR_0->gb, 8);",
"if (VAR_0->quant_index[VAR_3] >= 4)\nreturn AVERROR_INVALIDDATA;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"component %d %d:%d id: %d quant:%d\\n\",\nVAR_3, VAR_0->h_count[VAR_3], VAR_0->v_count[VAR_3],\nVAR_0->component_id[VAR_3], VAR_0->quant_index[VAR_3]);",
"}",
"if (VAR_0->ls && (VAR_0->h_max > 1 || VAR_0->v_max > 1)) {",
"av_log_missing_feature(VAR_0->avctx, \"Subsampling in JPEG-LS\", 0);",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_0->v_max == 1 && VAR_0->h_max == 1 && VAR_0->lossless==1 && VAR_2==3)\nVAR_0->rgb = 1;",
"if (VAR_4 != VAR_0->VAR_4 || VAR_5 != VAR_0->VAR_5) {",
"av_freep(&VAR_0->qscale_table);",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->VAR_5 = VAR_5;",
"VAR_0->interlaced = 0;",
"if (VAR_0->first_picture &&\nVAR_0->org_height != 0 &&\nVAR_0->VAR_5 < ((VAR_0->org_height * 3) / 4)) {",
"VAR_0->interlaced = 1;",
"VAR_0->bottom_field = VAR_0->interlace_polarity;",
"VAR_0->picture_ptr->interlaced_frame = 1;",
"VAR_0->picture_ptr->top_field_first = !VAR_0->interlace_polarity;",
"VAR_5 *= 2;",
"}",
"avcodec_set_dimensions(VAR_0->avctx, VAR_4, VAR_5);",
"VAR_0->qscale_table = av_mallocz((VAR_0->VAR_4 + 15) / 16);",
"VAR_0->first_picture = 0;",
"}",
"if (VAR_0->interlaced && (VAR_0->bottom_field == !VAR_0->interlace_polarity)) {",
"if (VAR_0->progressive) {",
"av_log_ask_for_sample(VAR_0->avctx, \"progressively coded interlaced pictures not supported\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"} else{",
"VAR_6 = (VAR_0->h_count[0] << 28) | (VAR_0->v_count[0] << 24) |\n(VAR_0->h_count[1] << 20) | (VAR_0->v_count[1] << 16) |\n(VAR_0->h_count[2] << 12) | (VAR_0->v_count[2] << 8) |\n(VAR_0->h_count[3] << 4) | VAR_0->v_count[3];",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"pix fmt id %x\\n\", VAR_6);",
"if (!(VAR_6 & 0xD0D0D0D0))\nVAR_6 -= (VAR_6 & 0xF0F0F0F0) >> 1;",
"if (!(VAR_6 & 0x0D0D0D0D))\nVAR_6 -= (VAR_6 & 0x0F0F0F0F) >> 1;",
"switch (VAR_6) {",
"case 0x11111100:\nif (VAR_0->rgb)\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_BGR24;",
"else {",
"if (VAR_0->component_id[0] == 'Q' && VAR_0->component_id[1] == 'F' && VAR_0->component_id[2] == 'A') {",
"VAR_0->avctx->pix_fmt = AV_PIX_FMT_GBR24P;",
"} else {",
"VAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"}",
"}",
"av_assert0(VAR_0->VAR_2 == 3);",
"break;",
"case 0x12121100:\ncase 0x22122100:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"VAR_0->upscale_v = 2;",
"VAR_0->upscale_h = (VAR_6 == 0x22122100);",
"VAR_0->chroma_height = VAR_0->VAR_5;",
"break;",
"case 0x21211100:\ncase 0x22211200:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"VAR_0->upscale_v = (VAR_6 == 0x22211200);",
"VAR_0->upscale_h = 2;",
"VAR_0->chroma_height = VAR_0->VAR_5;",
"break;",
"case 0x22221100:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"VAR_0->upscale_v = 2;",
"VAR_0->upscale_h = 2;",
"VAR_0->chroma_height = VAR_0->VAR_5 / 2;",
"break;",
"case 0x11000000:\nif(VAR_0->bits <= 8)\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY8;",
"else\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY16;",
"break;",
"case 0x12111100:\ncase 0x22211100:\ncase 0x22112100:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"VAR_0->upscale_h = (VAR_6 == 0x22211100) * 2 + (VAR_6 == 0x22112100);",
"VAR_0->chroma_height = VAR_0->VAR_5 / 2;",
"break;",
"case 0x21111100:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"break;",
"case 0x22121100:\ncase 0x22111200:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"VAR_0->upscale_v = (VAR_6 == 0x22121100) + 1;",
"break;",
"case 0x22111100:\nVAR_0->avctx->pix_fmt = VAR_0->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;",
"VAR_0->avctx->color_range = VAR_0->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unhandled pixel format 0x%x\\n\", VAR_6);",
"return AVERROR_PATCHWELCOME;",
"}",
"if ((VAR_0->upscale_h || VAR_0->upscale_v) && VAR_0->avctx->lowres) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"lowres not supported for weird subsampling\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_0->ls) {",
"VAR_0->upscale_h = VAR_0->upscale_v = 0;",
"if (VAR_0->VAR_2 > 1)\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_RGB24;",
"else if (VAR_0->bits <= 8)\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY8;",
"else\nVAR_0->avctx->pix_fmt = AV_PIX_FMT_GRAY16;",
"}",
"if (VAR_0->picture_ptr->data[0])\nVAR_0->avctx->release_buffer(VAR_0->avctx, VAR_0->picture_ptr);",
"if (VAR_0->avctx->get_buffer(VAR_0->avctx, VAR_0->picture_ptr) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"VAR_0->picture_ptr->pict_type = AV_PICTURE_TYPE_I;",
"VAR_0->picture_ptr->key_frame = 1;",
"VAR_0->got_picture = 1;",
"for (VAR_3 = 0; VAR_3 < 3; VAR_3++)",
"VAR_0->linesize[VAR_3] = VAR_0->picture_ptr->linesize[VAR_3] << VAR_0->interlaced;",
"av_dlog(VAR_0->avctx, \"%d %d %d %d %d %d\\n\",\nVAR_0->VAR_4, VAR_0->VAR_5, VAR_0->linesize[0], VAR_0->linesize[1],\nVAR_0->interlaced, VAR_0->avctx->VAR_5);",
"if (VAR_1 != (8 + (3 * VAR_2)))\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"decode_sof0: error, VAR_1(%d) mismatch\\n\", VAR_1);",
"}",
"if (VAR_0->progressive) {",
"int VAR_7 = (VAR_4 + VAR_0->h_max * 8 - 1) / (VAR_0->h_max * 8);",
"int VAR_8 = (VAR_5 + VAR_0->v_max * 8 - 1) / (VAR_0->v_max * 8);",
"for (VAR_3 = 0; VAR_3 < VAR_0->VAR_2; VAR_3++) {",
"int size = VAR_7 * VAR_8 * VAR_0->h_count[VAR_3] * VAR_0->v_count[VAR_3];",
"av_freep(&VAR_0->blocks[VAR_3]);",
"av_freep(&VAR_0->last_nnz[VAR_3]);",
"VAR_0->blocks[VAR_3] = av_malloc(size * sizeof(**VAR_0->blocks));",
"VAR_0->last_nnz[VAR_3] = av_mallocz(size * sizeof(**VAR_0->last_nnz));",
"VAR_0->block_stride[VAR_3] = VAR_7 * VAR_0->h_count[VAR_3];",
"}",
"memset(VAR_0->coefs_finished, 0, sizeof(VAR_0->coefs_finished));",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
17
],
[
19
],
[
23,
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
61,
63
],
[
67
],
[
69,
71
],
[
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147,
149
],
[
151,
153,
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171,
173
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
197,
199,
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243,
245,
247,
249
],
[
251
],
[
257,
259
],
[
261,
263
],
[
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
],
[
433,
435
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
455
],
[
457
],
[
461,
463,
465
],
[
469,
471
],
[
473
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
]
] |
25,696 | void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error,
BlockdevOnError on_write_error)
{
bs->on_read_error = on_read_error;
bs->on_write_error = on_write_error;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error,
BlockdevOnError on_write_error)
{
bs->on_read_error = on_read_error;
bs->on_write_error = on_write_error;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0, BlockdevOnError VAR_1,
BlockdevOnError VAR_2)
{
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_2 = VAR_2;
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockdevOnError VAR_1,\nBlockdevOnError VAR_2)\n{",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_2 = VAR_2;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
] |
25,697 | static void test_acpi_one(const char *params, test_data *data)
{
char *args;
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
const char *device = "";
if (!g_strcmp0(data->machine, MACHINE_Q35)) {
device = ",id=hd -device ide-hd,drive=hd";
}
args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
params ? params : "", disk, device);
qtest_start(args);
/* Wait at most 1 minute */
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
/* Poll until code has run and modified memory. Once it has we know BIOS
* initialization is done. TODO: check that IP reached the halt
* instruction.
*/
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
test_acpi_ssdt_tables(data);
if (iasl) {
test_acpi_asl(data);
}
qtest_quit(global_qtest);
g_free(args);
}
| false | qemu | 4500bc98a6aab1734d865afaeade3509eb65b560 | static void test_acpi_one(const char *params, test_data *data)
{
char *args;
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
const char *device = "";
if (!g_strcmp0(data->machine, MACHINE_Q35)) {
device = ",id=hd -device ide-hd,drive=hd";
}
args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
params ? params : "", disk, device);
qtest_start(args);
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
test_acpi_ssdt_tables(data);
if (iasl) {
test_acpi_asl(data);
}
qtest_quit(global_qtest);
g_free(args);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0, test_data *VAR_1)
{
char *VAR_2;
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int VAR_3;
const char *VAR_4 = "";
if (!g_strcmp0(VAR_1->machine, MACHINE_Q35)) {
VAR_4 = ",id=hd -VAR_4 ide-hd,drive=hd";
}
VAR_2 = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
VAR_0 ? VAR_0 : "", disk, VAR_4);
qtest_start(VAR_2);
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (VAR_3 = 0; VAR_3 < TEST_CYCLES; ++VAR_3) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
test_acpi_rsdp_address(VAR_1);
test_acpi_rsdp_table(VAR_1);
test_acpi_rsdt_table(VAR_1);
test_acpi_fadt_table(VAR_1);
test_acpi_facs_table(VAR_1);
test_acpi_dsdt_table(VAR_1);
test_acpi_ssdt_tables(VAR_1);
if (iasl) {
test_acpi_asl(VAR_1);
}
qtest_quit(global_qtest);
g_free(VAR_2);
}
| [
"static void FUNC_0(const char *VAR_0, test_data *VAR_1)\n{",
"char *VAR_2;",
"uint8_t signature_low;",
"uint8_t signature_high;",
"uint16_t signature;",
"int VAR_3;",
"const char *VAR_4 = \"\";",
"if (!g_strcmp0(VAR_1->machine, MACHINE_Q35)) {",
"VAR_4 = \",id=hd -VAR_4 ide-hd,drive=hd\";",
"}",
"VAR_2 = g_strdup_printf(\"-net none -display none %s -drive file=%s%s,\",\nVAR_0 ? VAR_0 : \"\", disk, VAR_4);",
"qtest_start(VAR_2);",
"#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)\n#define TEST_CYCLES MAX((60 * G_USEC_PER_SEC / TEST_DELAY), 1)\nfor (VAR_3 = 0; VAR_3 < TEST_CYCLES; ++VAR_3) {",
"signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);",
"signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);",
"signature = (signature_high << 8) | signature_low;",
"if (signature == SIGNATURE) {",
"break;",
"}",
"g_usleep(TEST_DELAY);",
"}",
"g_assert_cmphex(signature, ==, SIGNATURE);",
"test_acpi_rsdp_address(VAR_1);",
"test_acpi_rsdp_table(VAR_1);",
"test_acpi_rsdt_table(VAR_1);",
"test_acpi_fadt_table(VAR_1);",
"test_acpi_facs_table(VAR_1);",
"test_acpi_dsdt_table(VAR_1);",
"test_acpi_ssdt_tables(VAR_1);",
"if (iasl) {",
"test_acpi_asl(VAR_1);",
"}",
"qtest_quit(global_qtest);",
"g_free(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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
37,
39,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
]
] |
25,698 | static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val)
{
Rocker *r = opaque;
if (rocker_addr_is_desc_reg(r, addr)) {
unsigned index = ROCKER_RING_INDEX(addr);
unsigned offset = addr & ROCKER_DMA_DESC_MASK;
switch (offset) {
case ROCKER_DMA_DESC_ADDR_OFFSET:
r->lower32 = (uint64_t)val;
break;
case ROCKER_DMA_DESC_ADDR_OFFSET + 4:
desc_ring_set_base_addr(r->rings[index],
((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
case ROCKER_DMA_DESC_SIZE_OFFSET:
desc_ring_set_size(r->rings[index], val);
break;
case ROCKER_DMA_DESC_HEAD_OFFSET:
if (desc_ring_set_head(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
case ROCKER_DMA_DESC_CTRL_OFFSET:
desc_ring_set_ctrl(r->rings[index], val);
break;
case ROCKER_DMA_DESC_CREDITS_OFFSET:
if (desc_ring_ret_credits(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
default:
DPRINTF("not implemented dma reg write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x (ring %d, addr=0x%02x)\n",
addr, val, index, offset);
break;
}
return;
}
switch (addr) {
case ROCKER_TEST_REG:
r->test_reg = val;
break;
case ROCKER_TEST_REG64:
case ROCKER_TEST_DMA_ADDR:
case ROCKER_PORT_PHYS_ENABLE:
r->lower32 = (uint64_t)val;
break;
case ROCKER_TEST_REG64 + 4:
r->test_reg64 = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_IRQ:
rocker_msix_irq(r, val);
break;
case ROCKER_TEST_DMA_SIZE:
r->test_dma_size = val;
break;
case ROCKER_TEST_DMA_ADDR + 4:
r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_DMA_CTRL:
rocker_test_dma_ctrl(r, val);
break;
case ROCKER_CONTROL:
rocker_control(r, val);
break;
case ROCKER_PORT_PHYS_ENABLE + 4:
rocker_port_phys_enable_write(r, ((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
default:
DPRINTF("not implemented write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x\n", addr, val);
break;
}
}
| false | qemu | 8caed3d564672e8bc6d2e4c6a35228afd01f4723 | static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val)
{
Rocker *r = opaque;
if (rocker_addr_is_desc_reg(r, addr)) {
unsigned index = ROCKER_RING_INDEX(addr);
unsigned offset = addr & ROCKER_DMA_DESC_MASK;
switch (offset) {
case ROCKER_DMA_DESC_ADDR_OFFSET:
r->lower32 = (uint64_t)val;
break;
case ROCKER_DMA_DESC_ADDR_OFFSET + 4:
desc_ring_set_base_addr(r->rings[index],
((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
case ROCKER_DMA_DESC_SIZE_OFFSET:
desc_ring_set_size(r->rings[index], val);
break;
case ROCKER_DMA_DESC_HEAD_OFFSET:
if (desc_ring_set_head(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
case ROCKER_DMA_DESC_CTRL_OFFSET:
desc_ring_set_ctrl(r->rings[index], val);
break;
case ROCKER_DMA_DESC_CREDITS_OFFSET:
if (desc_ring_ret_credits(r->rings[index], val)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[index]));
}
break;
default:
DPRINTF("not implemented dma reg write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x (ring %d, addr=0x%02x)\n",
addr, val, index, offset);
break;
}
return;
}
switch (addr) {
case ROCKER_TEST_REG:
r->test_reg = val;
break;
case ROCKER_TEST_REG64:
case ROCKER_TEST_DMA_ADDR:
case ROCKER_PORT_PHYS_ENABLE:
r->lower32 = (uint64_t)val;
break;
case ROCKER_TEST_REG64 + 4:
r->test_reg64 = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_IRQ:
rocker_msix_irq(r, val);
break;
case ROCKER_TEST_DMA_SIZE:
r->test_dma_size = val;
break;
case ROCKER_TEST_DMA_ADDR + 4:
r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_DMA_CTRL:
rocker_test_dma_ctrl(r, val);
break;
case ROCKER_CONTROL:
rocker_control(r, val);
break;
case ROCKER_PORT_PHYS_ENABLE + 4:
rocker_port_phys_enable_write(r, ((uint64_t)val) << 32 | r->lower32);
r->lower32 = 0;
break;
default:
DPRINTF("not implemented write(l) addr=0x" TARGET_FMT_plx
" val=0x%08x\n", addr, val);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint32_t VAR_2)
{
Rocker *r = VAR_0;
if (rocker_addr_is_desc_reg(r, VAR_1)) {
unsigned VAR_3 = ROCKER_RING_INDEX(VAR_1);
unsigned VAR_4 = VAR_1 & ROCKER_DMA_DESC_MASK;
switch (VAR_4) {
case ROCKER_DMA_DESC_ADDR_OFFSET:
r->lower32 = (uint64_t)VAR_2;
break;
case ROCKER_DMA_DESC_ADDR_OFFSET + 4:
desc_ring_set_base_addr(r->rings[VAR_3],
((uint64_t)VAR_2) << 32 | r->lower32);
r->lower32 = 0;
break;
case ROCKER_DMA_DESC_SIZE_OFFSET:
desc_ring_set_size(r->rings[VAR_3], VAR_2);
break;
case ROCKER_DMA_DESC_HEAD_OFFSET:
if (desc_ring_set_head(r->rings[VAR_3], VAR_2)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[VAR_3]));
}
break;
case ROCKER_DMA_DESC_CTRL_OFFSET:
desc_ring_set_ctrl(r->rings[VAR_3], VAR_2);
break;
case ROCKER_DMA_DESC_CREDITS_OFFSET:
if (desc_ring_ret_credits(r->rings[VAR_3], VAR_2)) {
rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[VAR_3]));
}
break;
default:
DPRINTF("not implemented dma reg write(l) VAR_1=0x" TARGET_FMT_plx
" VAR_2=0x%08x (ring %d, VAR_1=0x%02x)\n",
VAR_1, VAR_2, VAR_3, VAR_4);
break;
}
return;
}
switch (VAR_1) {
case ROCKER_TEST_REG:
r->test_reg = VAR_2;
break;
case ROCKER_TEST_REG64:
case ROCKER_TEST_DMA_ADDR:
case ROCKER_PORT_PHYS_ENABLE:
r->lower32 = (uint64_t)VAR_2;
break;
case ROCKER_TEST_REG64 + 4:
r->test_reg64 = ((uint64_t)VAR_2) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_IRQ:
rocker_msix_irq(r, VAR_2);
break;
case ROCKER_TEST_DMA_SIZE:
r->test_dma_size = VAR_2;
break;
case ROCKER_TEST_DMA_ADDR + 4:
r->test_dma_addr = ((uint64_t)VAR_2) << 32 | r->lower32;
r->lower32 = 0;
break;
case ROCKER_TEST_DMA_CTRL:
rocker_test_dma_ctrl(r, VAR_2);
break;
case ROCKER_CONTROL:
rocker_control(r, VAR_2);
break;
case ROCKER_PORT_PHYS_ENABLE + 4:
rocker_port_phys_enable_write(r, ((uint64_t)VAR_2) << 32 | r->lower32);
r->lower32 = 0;
break;
default:
DPRINTF("not implemented write(l) VAR_1=0x" TARGET_FMT_plx
" VAR_2=0x%08x\n", VAR_1, VAR_2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint32_t VAR_2)\n{",
"Rocker *r = VAR_0;",
"if (rocker_addr_is_desc_reg(r, VAR_1)) {",
"unsigned VAR_3 = ROCKER_RING_INDEX(VAR_1);",
"unsigned VAR_4 = VAR_1 & ROCKER_DMA_DESC_MASK;",
"switch (VAR_4) {",
"case ROCKER_DMA_DESC_ADDR_OFFSET:\nr->lower32 = (uint64_t)VAR_2;",
"break;",
"case ROCKER_DMA_DESC_ADDR_OFFSET + 4:\ndesc_ring_set_base_addr(r->rings[VAR_3],\n((uint64_t)VAR_2) << 32 | r->lower32);",
"r->lower32 = 0;",
"break;",
"case ROCKER_DMA_DESC_SIZE_OFFSET:\ndesc_ring_set_size(r->rings[VAR_3], VAR_2);",
"break;",
"case ROCKER_DMA_DESC_HEAD_OFFSET:\nif (desc_ring_set_head(r->rings[VAR_3], VAR_2)) {",
"rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[VAR_3]));",
"}",
"break;",
"case ROCKER_DMA_DESC_CTRL_OFFSET:\ndesc_ring_set_ctrl(r->rings[VAR_3], VAR_2);",
"break;",
"case ROCKER_DMA_DESC_CREDITS_OFFSET:\nif (desc_ring_ret_credits(r->rings[VAR_3], VAR_2)) {",
"rocker_msix_irq(r, desc_ring_get_msix_vector(r->rings[VAR_3]));",
"}",
"break;",
"default:\nDPRINTF(\"not implemented dma reg write(l) VAR_1=0x\" TARGET_FMT_plx\n\" VAR_2=0x%08x (ring %d, VAR_1=0x%02x)\\n\",\nVAR_1, VAR_2, VAR_3, VAR_4);",
"break;",
"}",
"return;",
"}",
"switch (VAR_1) {",
"case ROCKER_TEST_REG:\nr->test_reg = VAR_2;",
"break;",
"case ROCKER_TEST_REG64:\ncase ROCKER_TEST_DMA_ADDR:\ncase ROCKER_PORT_PHYS_ENABLE:\nr->lower32 = (uint64_t)VAR_2;",
"break;",
"case ROCKER_TEST_REG64 + 4:\nr->test_reg64 = ((uint64_t)VAR_2) << 32 | r->lower32;",
"r->lower32 = 0;",
"break;",
"case ROCKER_TEST_IRQ:\nrocker_msix_irq(r, VAR_2);",
"break;",
"case ROCKER_TEST_DMA_SIZE:\nr->test_dma_size = VAR_2;",
"break;",
"case ROCKER_TEST_DMA_ADDR + 4:\nr->test_dma_addr = ((uint64_t)VAR_2) << 32 | r->lower32;",
"r->lower32 = 0;",
"break;",
"case ROCKER_TEST_DMA_CTRL:\nrocker_test_dma_ctrl(r, VAR_2);",
"break;",
"case ROCKER_CONTROL:\nrocker_control(r, VAR_2);",
"break;",
"case ROCKER_PORT_PHYS_ENABLE + 4:\nrocker_port_phys_enable_write(r, ((uint64_t)VAR_2) << 32 | r->lower32);",
"r->lower32 = 0;",
"break;",
"default:\nDPRINTF(\"not implemented write(l) VAR_1=0x\" TARGET_FMT_plx\n\" VAR_2=0x%08x\\n\", VAR_1, VAR_2);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
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
],
[
85
],
[
87,
89
],
[
91
],
[
93,
95,
97,
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117,
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
151,
153,
155
],
[
157
],
[
159
],
[
161
]
] |
25,699 | build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
{
AcpiRsdtDescriptorRev1 *rsdt;
size_t rsdt_len;
int i;
const int table_data_len = (sizeof(uint32_t) * table_offsets->len);
rsdt_len = sizeof(*rsdt) + table_data_len;
rsdt = acpi_data_push(table_data, rsdt_len);
memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len);
for (i = 0; i < table_offsets->len; ++i) {
/* rsdt->table_offset_entry to be filled by Guest linker */
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &rsdt->table_offset_entry[i],
sizeof(uint32_t));
}
build_header(linker, table_data,
(void *)rsdt, "RSDT", rsdt_len, 1, NULL, NULL);
}
| false | qemu | 5151355898699eb66fad0a710b8b6011690a0dfc | build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets)
{
AcpiRsdtDescriptorRev1 *rsdt;
size_t rsdt_len;
int i;
const int table_data_len = (sizeof(uint32_t) * table_offsets->len);
rsdt_len = sizeof(*rsdt) + table_data_len;
rsdt = acpi_data_push(table_data, rsdt_len);
memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len);
for (i = 0; i < table_offsets->len; ++i) {
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
table_data, &rsdt->table_offset_entry[i],
sizeof(uint32_t));
}
build_header(linker, table_data,
(void *)rsdt, "RSDT", rsdt_len, 1, NULL, NULL);
}
| {
"code": [],
"line_no": []
} | FUNC_0(GArray *VAR_0, GArray *VAR_1, GArray *VAR_2)
{
AcpiRsdtDescriptorRev1 *rsdt;
size_t rsdt_len;
int VAR_3;
const int VAR_4 = (sizeof(uint32_t) * VAR_2->len);
rsdt_len = sizeof(*rsdt) + VAR_4;
rsdt = acpi_data_push(VAR_0, rsdt_len);
memcpy(rsdt->table_offset_entry, VAR_2->data, VAR_4);
for (VAR_3 = 0; VAR_3 < VAR_2->len; ++VAR_3) {
bios_linker_loader_add_pointer(VAR_1,
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_FILE,
VAR_0, &rsdt->table_offset_entry[VAR_3],
sizeof(uint32_t));
}
build_header(VAR_1, VAR_0,
(void *)rsdt, "RSDT", rsdt_len, 1, NULL, NULL);
}
| [
"FUNC_0(GArray *VAR_0, GArray *VAR_1, GArray *VAR_2)\n{",
"AcpiRsdtDescriptorRev1 *rsdt;",
"size_t rsdt_len;",
"int VAR_3;",
"const int VAR_4 = (sizeof(uint32_t) * VAR_2->len);",
"rsdt_len = sizeof(*rsdt) + VAR_4;",
"rsdt = acpi_data_push(VAR_0, rsdt_len);",
"memcpy(rsdt->table_offset_entry, VAR_2->data, VAR_4);",
"for (VAR_3 = 0; VAR_3 < VAR_2->len; ++VAR_3) {",
"bios_linker_loader_add_pointer(VAR_1,\nACPI_BUILD_TABLE_FILE,\nACPI_BUILD_TABLE_FILE,\nVAR_0, &rsdt->table_offset_entry[VAR_3],\nsizeof(uint32_t));",
"}",
"build_header(VAR_1, VAR_0,\n(void *)rsdt, \"RSDT\", rsdt_len, 1, NULL, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27,
29,
31,
33
],
[
35
],
[
37,
39
],
[
41
]
] |
25,700 | int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
int offset = 0;
int ret;
while (nb_sectors > NBD_MAX_SECTORS) {
ret = nbd_co_writev_1(client, sector_num,
NBD_MAX_SECTORS, qiov, offset);
if (ret < 0) {
return ret;
}
offset += NBD_MAX_SECTORS * 512;
sector_num += NBD_MAX_SECTORS;
nb_sectors -= NBD_MAX_SECTORS;
}
return nbd_co_writev_1(client, sector_num, nb_sectors, qiov, offset);
}
| false | qemu | f53a829bb9ef14be800556cbc02d8b20fc1050a7 | int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
int offset = 0;
int ret;
while (nb_sectors > NBD_MAX_SECTORS) {
ret = nbd_co_writev_1(client, sector_num,
NBD_MAX_SECTORS, qiov, offset);
if (ret < 0) {
return ret;
}
offset += NBD_MAX_SECTORS * 512;
sector_num += NBD_MAX_SECTORS;
nb_sectors -= NBD_MAX_SECTORS;
}
return nbd_co_writev_1(client, sector_num, nb_sectors, qiov, offset);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(NbdClientSession *VAR_0, int64_t VAR_1,
int VAR_2, QEMUIOVector *VAR_3)
{
int VAR_4 = 0;
int VAR_5;
while (VAR_2 > NBD_MAX_SECTORS) {
VAR_5 = nbd_co_writev_1(VAR_0, VAR_1,
NBD_MAX_SECTORS, VAR_3, VAR_4);
if (VAR_5 < 0) {
return VAR_5;
}
VAR_4 += NBD_MAX_SECTORS * 512;
VAR_1 += NBD_MAX_SECTORS;
VAR_2 -= NBD_MAX_SECTORS;
}
return nbd_co_writev_1(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
}
| [
"int FUNC_0(NbdClientSession *VAR_0, int64_t VAR_1,\nint VAR_2, QEMUIOVector *VAR_3)\n{",
"int VAR_4 = 0;",
"int VAR_5;",
"while (VAR_2 > NBD_MAX_SECTORS) {",
"VAR_5 = nbd_co_writev_1(VAR_0, VAR_1,\nNBD_MAX_SECTORS, VAR_3, VAR_4);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"VAR_4 += NBD_MAX_SECTORS * 512;",
"VAR_1 += NBD_MAX_SECTORS;",
"VAR_2 -= NBD_MAX_SECTORS;",
"}",
"return nbd_co_writev_1(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"}"
] | [
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
]
] |
25,701 | static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint64_t nb_sectors;
bool dbd;
int page, buflen, ret, page_control;
uint8_t *p;
uint8_t dev_specific_param;
dbd = (r->req.cmd.buf[1] & 0x8) != 0;
page = r->req.cmd.buf[2] & 0x3f;
page_control = (r->req.cmd.buf[2] & 0xc0) >> 6;
DPRINTF("Mode Sense(%d) (page %d, xfer %zd, page_control %d)\n",
(r->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, r->req.cmd.xfer, page_control);
memset(outbuf, 0, r->req.cmd.xfer);
p = outbuf;
if (s->qdev.type == TYPE_DISK) {
dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0;
if (bdrv_is_read_only(s->qdev.conf.bs)) {
dev_specific_param |= 0x80; /* Readonly. */
}
} else {
/* MMC prescribes that CD/DVD drives have no block descriptors,
* and defines no device-specific parameter. */
dev_specific_param = 0x00;
dbd = true;
}
if (r->req.cmd.buf[0] == MODE_SENSE) {
p[1] = 0; /* Default media type. */
p[2] = dev_specific_param;
p[3] = 0; /* Block descriptor length. */
p += 4;
} else { /* MODE_SENSE_10 */
p[2] = 0; /* Default media type. */
p[3] = dev_specific_param;
p[6] = p[7] = 0; /* Block descriptor length. */
p += 8;
}
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!dbd && nb_sectors) {
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[3] = 8; /* Block descriptor length */
} else { /* MODE_SENSE_10 */
outbuf[7] = 8; /* Block descriptor length */
}
nb_sectors /= (s->qdev.blocksize / 512);
if (nb_sectors > 0xffffff) {
nb_sectors = 0;
}
p[0] = 0; /* media density code */
p[1] = (nb_sectors >> 16) & 0xff;
p[2] = (nb_sectors >> 8) & 0xff;
p[3] = nb_sectors & 0xff;
p[4] = 0; /* reserved */
p[5] = 0; /* bytes 5-7 are the sector size in bytes */
p[6] = s->qdev.blocksize >> 8;
p[7] = 0;
p += 8;
}
if (page_control == 3) {
/* Saved Values */
scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED));
return -1;
}
if (page == 0x3f) {
for (page = 0; page <= 0x3e; page++) {
mode_sense_page(s, page, &p, page_control);
}
} else {
ret = mode_sense_page(s, page, &p, page_control);
if (ret == -1) {
return -1;
}
}
buflen = p - outbuf;
/*
* The mode data length field specifies the length in bytes of the
* following data that is available to be transferred. The mode data
* length does not include itself.
*/
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[0] = buflen - 1;
} else { /* MODE_SENSE_10 */
outbuf[0] = ((buflen - 2) >> 8) & 0xff;
outbuf[1] = (buflen - 2) & 0xff;
}
return buflen;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint64_t nb_sectors;
bool dbd;
int page, buflen, ret, page_control;
uint8_t *p;
uint8_t dev_specific_param;
dbd = (r->req.cmd.buf[1] & 0x8) != 0;
page = r->req.cmd.buf[2] & 0x3f;
page_control = (r->req.cmd.buf[2] & 0xc0) >> 6;
DPRINTF("Mode Sense(%d) (page %d, xfer %zd, page_control %d)\n",
(r->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, r->req.cmd.xfer, page_control);
memset(outbuf, 0, r->req.cmd.xfer);
p = outbuf;
if (s->qdev.type == TYPE_DISK) {
dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0;
if (bdrv_is_read_only(s->qdev.conf.bs)) {
dev_specific_param |= 0x80;
}
} else {
dev_specific_param = 0x00;
dbd = true;
}
if (r->req.cmd.buf[0] == MODE_SENSE) {
p[1] = 0;
p[2] = dev_specific_param;
p[3] = 0;
p += 4;
} else {
p[2] = 0;
p[3] = dev_specific_param;
p[6] = p[7] = 0;
p += 8;
}
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!dbd && nb_sectors) {
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[3] = 8;
} else {
outbuf[7] = 8;
}
nb_sectors /= (s->qdev.blocksize / 512);
if (nb_sectors > 0xffffff) {
nb_sectors = 0;
}
p[0] = 0;
p[1] = (nb_sectors >> 16) & 0xff;
p[2] = (nb_sectors >> 8) & 0xff;
p[3] = nb_sectors & 0xff;
p[4] = 0;
p[5] = 0;
p[6] = s->qdev.blocksize >> 8;
p[7] = 0;
p += 8;
}
if (page_control == 3) {
scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED));
return -1;
}
if (page == 0x3f) {
for (page = 0; page <= 0x3e; page++) {
mode_sense_page(s, page, &p, page_control);
}
} else {
ret = mode_sense_page(s, page, &p, page_control);
if (ret == -1) {
return -1;
}
}
buflen = p - outbuf;
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[0] = buflen - 1;
} else {
outbuf[0] = ((buflen - 2) >> 8) & 0xff;
outbuf[1] = (buflen - 2) & 0xff;
}
return buflen;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SCSIDiskReq *VAR_0, uint8_t *VAR_1)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);
uint64_t nb_sectors;
bool dbd;
int VAR_2, VAR_3, VAR_4, VAR_5;
uint8_t *p;
uint8_t dev_specific_param;
dbd = (VAR_0->req.cmd.buf[1] & 0x8) != 0;
VAR_2 = VAR_0->req.cmd.buf[2] & 0x3f;
VAR_5 = (VAR_0->req.cmd.buf[2] & 0xc0) >> 6;
DPRINTF("Mode Sense(%d) (VAR_2 %d, xfer %zd, VAR_5 %d)\n",
(VAR_0->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, VAR_2, VAR_0->req.cmd.xfer, VAR_5);
memset(VAR_1, 0, VAR_0->req.cmd.xfer);
p = VAR_1;
if (s->qdev.type == TYPE_DISK) {
dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0;
if (bdrv_is_read_only(s->qdev.conf.bs)) {
dev_specific_param |= 0x80;
}
} else {
dev_specific_param = 0x00;
dbd = true;
}
if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {
p[1] = 0;
p[2] = dev_specific_param;
p[3] = 0;
p += 4;
} else {
p[2] = 0;
p[3] = dev_specific_param;
p[6] = p[7] = 0;
p += 8;
}
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!dbd && nb_sectors) {
if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {
VAR_1[3] = 8;
} else {
VAR_1[7] = 8;
}
nb_sectors /= (s->qdev.blocksize / 512);
if (nb_sectors > 0xffffff) {
nb_sectors = 0;
}
p[0] = 0;
p[1] = (nb_sectors >> 16) & 0xff;
p[2] = (nb_sectors >> 8) & 0xff;
p[3] = nb_sectors & 0xff;
p[4] = 0;
p[5] = 0;
p[6] = s->qdev.blocksize >> 8;
p[7] = 0;
p += 8;
}
if (VAR_5 == 3) {
scsi_check_condition(VAR_0, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED));
return -1;
}
if (VAR_2 == 0x3f) {
for (VAR_2 = 0; VAR_2 <= 0x3e; VAR_2++) {
mode_sense_page(s, VAR_2, &p, VAR_5);
}
} else {
VAR_4 = mode_sense_page(s, VAR_2, &p, VAR_5);
if (VAR_4 == -1) {
return -1;
}
}
VAR_3 = p - VAR_1;
if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {
VAR_1[0] = VAR_3 - 1;
} else {
VAR_1[0] = ((VAR_3 - 2) >> 8) & 0xff;
VAR_1[1] = (VAR_3 - 2) & 0xff;
}
return VAR_3;
}
| [
"static int FUNC_0(SCSIDiskReq *VAR_0, uint8_t *VAR_1)\n{",
"SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);",
"uint64_t nb_sectors;",
"bool dbd;",
"int VAR_2, VAR_3, VAR_4, VAR_5;",
"uint8_t *p;",
"uint8_t dev_specific_param;",
"dbd = (VAR_0->req.cmd.buf[1] & 0x8) != 0;",
"VAR_2 = VAR_0->req.cmd.buf[2] & 0x3f;",
"VAR_5 = (VAR_0->req.cmd.buf[2] & 0xc0) >> 6;",
"DPRINTF(\"Mode Sense(%d) (VAR_2 %d, xfer %zd, VAR_5 %d)\\n\",\n(VAR_0->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, VAR_2, VAR_0->req.cmd.xfer, VAR_5);",
"memset(VAR_1, 0, VAR_0->req.cmd.xfer);",
"p = VAR_1;",
"if (s->qdev.type == TYPE_DISK) {",
"dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0;",
"if (bdrv_is_read_only(s->qdev.conf.bs)) {",
"dev_specific_param |= 0x80;",
"}",
"} else {",
"dev_specific_param = 0x00;",
"dbd = true;",
"}",
"if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {",
"p[1] = 0;",
"p[2] = dev_specific_param;",
"p[3] = 0;",
"p += 4;",
"} else {",
"p[2] = 0;",
"p[3] = dev_specific_param;",
"p[6] = p[7] = 0;",
"p += 8;",
"}",
"bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);",
"if (!dbd && nb_sectors) {",
"if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {",
"VAR_1[3] = 8;",
"} else {",
"VAR_1[7] = 8;",
"}",
"nb_sectors /= (s->qdev.blocksize / 512);",
"if (nb_sectors > 0xffffff) {",
"nb_sectors = 0;",
"}",
"p[0] = 0;",
"p[1] = (nb_sectors >> 16) & 0xff;",
"p[2] = (nb_sectors >> 8) & 0xff;",
"p[3] = nb_sectors & 0xff;",
"p[4] = 0;",
"p[5] = 0;",
"p[6] = s->qdev.blocksize >> 8;",
"p[7] = 0;",
"p += 8;",
"}",
"if (VAR_5 == 3) {",
"scsi_check_condition(VAR_0, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED));",
"return -1;",
"}",
"if (VAR_2 == 0x3f) {",
"for (VAR_2 = 0; VAR_2 <= 0x3e; VAR_2++) {",
"mode_sense_page(s, VAR_2, &p, VAR_5);",
"}",
"} else {",
"VAR_4 = mode_sense_page(s, VAR_2, &p, VAR_5);",
"if (VAR_4 == -1) {",
"return -1;",
"}",
"}",
"VAR_3 = p - VAR_1;",
"if (VAR_0->req.cmd.buf[0] == MODE_SENSE) {",
"VAR_1[0] = VAR_3 - 1;",
"} else {",
"VAR_1[0] = ((VAR_3 - 2) >> 8) & 0xff;",
"VAR_1[1] = (VAR_3 - 2) & 0xff;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
]
] |
25,702 | static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *device = qemu_opt_get(opts, "path");
ChardevHostdev *dev;
if (device == NULL) {
error_setg(errp, "chardev: pipe: no device path given");
return;
}
dev = backend->u.pipe = g_new0(ChardevHostdev, 1);
qemu_chr_parse_common(opts, qapi_ChardevHostdev_base(dev));
dev->device = g_strdup(device);
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static void qemu_chr_parse_pipe(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *device = qemu_opt_get(opts, "path");
ChardevHostdev *dev;
if (device == NULL) {
error_setg(errp, "chardev: pipe: no device path given");
return;
}
dev = backend->u.pipe = g_new0(ChardevHostdev, 1);
qemu_chr_parse_common(opts, qapi_ChardevHostdev_base(dev));
dev->device = g_strdup(device);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1,
Error **VAR_2)
{
const char *VAR_3 = qemu_opt_get(VAR_0, "path");
ChardevHostdev *dev;
if (VAR_3 == NULL) {
error_setg(VAR_2, "chardev: pipe: no VAR_3 path given");
return;
}
dev = VAR_1->u.pipe = g_new0(ChardevHostdev, 1);
qemu_chr_parse_common(VAR_0, qapi_ChardevHostdev_base(dev));
dev->VAR_3 = g_strdup(VAR_3);
}
| [
"static void FUNC_0(QemuOpts *VAR_0, ChardevBackend *VAR_1,\nError **VAR_2)\n{",
"const char *VAR_3 = qemu_opt_get(VAR_0, \"path\");",
"ChardevHostdev *dev;",
"if (VAR_3 == NULL) {",
"error_setg(VAR_2, \"chardev: pipe: no VAR_3 path given\");",
"return;",
"}",
"dev = VAR_1->u.pipe = g_new0(ChardevHostdev, 1);",
"qemu_chr_parse_common(VAR_0, qapi_ChardevHostdev_base(dev));",
"dev->VAR_3 = g_strdup(VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,703 | static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int i, entries;
int64_t duration=0;
int64_t total_sample_count=0;
get_byte(pb); /* version */
get_be24(pb); /* flags */
entries = get_be32(pb);
dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
if(entries >= UINT_MAX / sizeof(*sc->stts_data))
return -1;
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
if (!sc->stts_data)
return AVERROR(ENOMEM);
sc->stts_count = entries;
for(i=0; i<entries; i++) {
int sample_duration;
int sample_count;
sample_count=get_be32(pb);
sample_duration = get_be32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
duration+=(int64_t)sample_duration*sample_count;
total_sample_count+=sample_count;
}
st->nb_frames= total_sample_count;
if(duration)
st->duration= duration;
return 0;
}
| false | FFmpeg | 6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432 | static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int i, entries;
int64_t duration=0;
int64_t total_sample_count=0;
get_byte(pb);
get_be24(pb);
entries = get_be32(pb);
dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries);
if(entries >= UINT_MAX / sizeof(*sc->stts_data))
return -1;
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
if (!sc->stts_data)
return AVERROR(ENOMEM);
sc->stts_count = entries;
for(i=0; i<entries; i++) {
int sample_duration;
int sample_count;
sample_count=get_be32(pb);
sample_duration = get_be32(pb);
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
duration+=(int64_t)sample_duration*sample_count;
total_sample_count+=sample_count;
}
st->nb_frames= total_sample_count;
if(duration)
st->duration= duration;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)
{
AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
unsigned int VAR_3, VAR_4;
int64_t duration=0;
int64_t total_sample_count=0;
get_byte(VAR_1);
get_be24(VAR_1);
VAR_4 = get_be32(VAR_1);
dprintf(VAR_0->fc, "track[%VAR_3].stts.VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams-1, VAR_4);
if(VAR_4 >= UINT_MAX / sizeof(*sc->stts_data))
return -1;
sc->stts_data = av_malloc(VAR_4 * sizeof(*sc->stts_data));
if (!sc->stts_data)
return AVERROR(ENOMEM);
sc->stts_count = VAR_4;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++) {
int VAR_5;
int VAR_6;
VAR_6=get_be32(VAR_1);
VAR_5 = get_be32(VAR_1);
sc->stts_data[VAR_3].count= VAR_6;
sc->stts_data[VAR_3].duration= VAR_5;
dprintf(VAR_0->fc, "VAR_6=%d, VAR_5=%d\n",VAR_6,VAR_5);
duration+=(int64_t)VAR_5*VAR_6;
total_sample_count+=VAR_6;
}
st->nb_frames= total_sample_count;
if(duration)
st->duration= duration;
return 0;
}
| [
"static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{",
"AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];",
"MOVStreamContext *sc = st->priv_data;",
"unsigned int VAR_3, VAR_4;",
"int64_t duration=0;",
"int64_t total_sample_count=0;",
"get_byte(VAR_1);",
"get_be24(VAR_1);",
"VAR_4 = get_be32(VAR_1);",
"dprintf(VAR_0->fc, \"track[%VAR_3].stts.VAR_4 = %VAR_3\\n\", VAR_0->fc->nb_streams-1, VAR_4);",
"if(VAR_4 >= UINT_MAX / sizeof(*sc->stts_data))\nreturn -1;",
"sc->stts_data = av_malloc(VAR_4 * sizeof(*sc->stts_data));",
"if (!sc->stts_data)\nreturn AVERROR(ENOMEM);",
"sc->stts_count = VAR_4;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++) {",
"int VAR_5;",
"int VAR_6;",
"VAR_6=get_be32(VAR_1);",
"VAR_5 = get_be32(VAR_1);",
"sc->stts_data[VAR_3].count= VAR_6;",
"sc->stts_data[VAR_3].duration= VAR_5;",
"dprintf(VAR_0->fc, \"VAR_6=%d, VAR_5=%d\\n\",VAR_6,VAR_5);",
"duration+=(int64_t)VAR_5*VAR_6;",
"total_sample_count+=VAR_6;",
"}",
"st->nb_frames= total_sample_count;",
"if(duration)\nst->duration= duration;",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77
],
[
79
],
[
81
]
] |
25,705 | static void bt_submit_sco(struct HCIInfo *info,
const uint8_t *data, int length)
{
struct bt_hci_s *hci = hci_from_info(info);
uint16_t handle;
int datalen;
if (length < 3)
return;
handle = acl_handle((data[1] << 8) | data[0]);
datalen = data[2];
length -= 3;
if (bt_hci_handle_bad(hci, handle)) {
fprintf(stderr, "%s: invalid SCO handle %03x\n",
__FUNCTION__, handle);
return;
}
if (datalen > length) {
fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n",
__FUNCTION__, length, datalen);
return;
}
/* TODO */
/* TODO: increase counter and send EVT_NUM_COMP_PKTS if synchronous
* Flow Control is enabled.
* (See Read/Write_Synchronous_Flow_Control_Enable on page 513 and
* page 514.) */
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void bt_submit_sco(struct HCIInfo *info,
const uint8_t *data, int length)
{
struct bt_hci_s *hci = hci_from_info(info);
uint16_t handle;
int datalen;
if (length < 3)
return;
handle = acl_handle((data[1] << 8) | data[0]);
datalen = data[2];
length -= 3;
if (bt_hci_handle_bad(hci, handle)) {
fprintf(stderr, "%s: invalid SCO handle %03x\n",
__FUNCTION__, handle);
return;
}
if (datalen > length) {
fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n",
__FUNCTION__, length, datalen);
return;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct HCIInfo *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
struct bt_hci_s *VAR_3 = hci_from_info(VAR_0);
uint16_t handle;
int VAR_4;
if (VAR_2 < 3)
return;
handle = acl_handle((VAR_1[1] << 8) | VAR_1[0]);
VAR_4 = VAR_1[2];
VAR_2 -= 3;
if (bt_hci_handle_bad(VAR_3, handle)) {
fprintf(stderr, "%s: invalid SCO handle %03x\n",
__FUNCTION__, handle);
return;
}
if (VAR_4 > VAR_2) {
fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n",
__FUNCTION__, VAR_2, VAR_4);
return;
}
}
| [
"static void FUNC_0(struct HCIInfo *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"struct bt_hci_s *VAR_3 = hci_from_info(VAR_0);",
"uint16_t handle;",
"int VAR_4;",
"if (VAR_2 < 3)\nreturn;",
"handle = acl_handle((VAR_1[1] << 8) | VAR_1[0]);",
"VAR_4 = VAR_1[2];",
"VAR_2 -= 3;",
"if (bt_hci_handle_bad(VAR_3, handle)) {",
"fprintf(stderr, \"%s: invalid SCO handle %03x\\n\",\n__FUNCTION__, handle);",
"return;",
"}",
"if (VAR_4 > VAR_2) {",
"fprintf(stderr, \"%s: SCO packet too short (%iB < %iB)\\n\",\n__FUNCTION__, VAR_2, VAR_4);",
"return;",
"}",
"}"
] | [
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
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
65
]
] |
25,707 | static void do_v7m_exception_exit(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
uint32_t type;
uint32_t xpsr;
bool ufault = false;
bool return_to_sp_process = false;
bool return_to_handler = false;
bool rettobase = false;
/* We can only get here from an EXCP_EXCEPTION_EXIT, and
* gen_bx_excret() enforces the architectural rule
* that jumps to magic addresses don't have magic behaviour unless
* we're in Handler mode (compare pseudocode BXWritePC()).
*/
assert(arm_v7m_is_handler_mode(env));
/* In the spec pseudocode ExceptionReturn() is called directly
* from BXWritePC() and gets the full target PC value including
* bit zero. In QEMU's implementation we treat it as a normal
* jump-to-register (which is then caught later on), and so split
* the target value up between env->regs[15] and env->thumb in
* gen_bx(). Reconstitute it.
*/
type = env->regs[15];
if (env->thumb) {
type |= 1;
}
qemu_log_mask(CPU_LOG_INT, "Exception return: magic PC %" PRIx32
" previous exception %d\n",
type, env->v7m.exception);
if (extract32(type, 5, 23) != extract32(-1, 5, 23)) {
qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero high bits in exception "
"exit PC value 0x%" PRIx32 " are UNPREDICTABLE\n", type);
}
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
/* Auto-clear FAULTMASK on return from other than NMI.
* If the security extension is implemented then this only
* happens if the raw execution priority is >= 0; the
* value of the ES bit in the exception return value indicates
* which security state's faultmask to clear. (v8M ARM ARM R_KBNF.)
*/
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
int es = type & 1;
if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) {
env->v7m.faultmask[es] = 0;
}
} else {
env->v7m.faultmask[M_REG_NS] = 0;
}
}
switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) {
case -1:
/* attempt to exit an exception that isn't active */
ufault = true;
break;
case 0:
/* still an irq active now */
break;
case 1:
/* we returned to base exception level, no nesting.
* (In the pseudocode this is written using "NestedActivation != 1"
* where we have 'rettobase == false'.)
*/
rettobase = true;
break;
default:
g_assert_not_reached();
}
switch (type & 0xf) {
case 1: /* Return to Handler */
return_to_handler = true;
break;
case 13: /* Return to Thread using Process stack */
return_to_sp_process = true;
/* fall through */
case 9: /* Return to Thread using Main stack */
if (!rettobase &&
!(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) {
ufault = true;
}
break;
default:
ufault = true;
}
if (ufault) {
/* Bad exception return: instead of popping the exception
* stack, directly take a usage fault on the current stack.
*/
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
v7m_exception_taken(cpu, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
"stackframe: failed exception return integrity check\n");
return;
}
/* Switch to the target stack. */
switch_v7m_sp(env, return_to_sp_process);
/* Pop registers. */
env->regs[0] = v7m_pop(env);
env->regs[1] = v7m_pop(env);
env->regs[2] = v7m_pop(env);
env->regs[3] = v7m_pop(env);
env->regs[12] = v7m_pop(env);
env->regs[14] = v7m_pop(env);
env->regs[15] = v7m_pop(env);
if (env->regs[15] & 1) {
qemu_log_mask(LOG_GUEST_ERROR,
"M profile return from interrupt with misaligned "
"PC is UNPREDICTABLE\n");
/* Actual hardware seems to ignore the lsbit, and there are several
* RTOSes out there which incorrectly assume the r15 in the stack
* frame should be a Thumb-style "lsbit indicates ARM/Thumb" value.
*/
env->regs[15] &= ~1U;
}
xpsr = v7m_pop(env);
xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
/* Undo stack alignment. */
if (xpsr & XPSR_SPREALIGN) {
env->regs[13] |= 4;
}
/* The restored xPSR exception field will be zero if we're
* resuming in Thread mode. If that doesn't match what the
* exception return type specified then this is a UsageFault.
*/
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
/* Take an INVPC UsageFault by pushing the stack again. */
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
v7m_push_stack(cpu);
v7m_exception_taken(cpu, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: "
"failed exception return integrity check\n");
return;
}
/* Otherwise, we have a successful exception exit. */
qemu_log_mask(CPU_LOG_INT, "...successful exception return\n");
}
| false | qemu | 334e8dad7a109d15cb20b090131374ae98682a50 | static void do_v7m_exception_exit(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
uint32_t type;
uint32_t xpsr;
bool ufault = false;
bool return_to_sp_process = false;
bool return_to_handler = false;
bool rettobase = false;
assert(arm_v7m_is_handler_mode(env));
type = env->regs[15];
if (env->thumb) {
type |= 1;
}
qemu_log_mask(CPU_LOG_INT, "Exception return: magic PC %" PRIx32
" previous exception %d\n",
type, env->v7m.exception);
if (extract32(type, 5, 23) != extract32(-1, 5, 23)) {
qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero high bits in exception "
"exit PC value 0x%" PRIx32 " are UNPREDICTABLE\n", type);
}
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
int es = type & 1;
if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) {
env->v7m.faultmask[es] = 0;
}
} else {
env->v7m.faultmask[M_REG_NS] = 0;
}
}
switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) {
case -1:
ufault = true;
break;
case 0:
break;
case 1:
rettobase = true;
break;
default:
g_assert_not_reached();
}
switch (type & 0xf) {
case 1:
return_to_handler = true;
break;
case 13:
return_to_sp_process = true;
case 9:
if (!rettobase &&
!(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) {
ufault = true;
}
break;
default:
ufault = true;
}
if (ufault) {
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
v7m_exception_taken(cpu, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
"stackframe: failed exception return integrity check\n");
return;
}
switch_v7m_sp(env, return_to_sp_process);
env->regs[0] = v7m_pop(env);
env->regs[1] = v7m_pop(env);
env->regs[2] = v7m_pop(env);
env->regs[3] = v7m_pop(env);
env->regs[12] = v7m_pop(env);
env->regs[14] = v7m_pop(env);
env->regs[15] = v7m_pop(env);
if (env->regs[15] & 1) {
qemu_log_mask(LOG_GUEST_ERROR,
"M profile return from interrupt with misaligned "
"PC is UNPREDICTABLE\n");
env->regs[15] &= ~1U;
}
xpsr = v7m_pop(env);
xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
if (xpsr & XPSR_SPREALIGN) {
env->regs[13] |= 4;
}
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
v7m_push_stack(cpu);
v7m_exception_taken(cpu, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: "
"failed exception return integrity check\n");
return;
}
qemu_log_mask(CPU_LOG_INT, "...successful exception return\n");
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ARMCPU *VAR_0)
{
CPUARMState *env = &VAR_0->env;
uint32_t type;
uint32_t xpsr;
bool ufault = false;
bool return_to_sp_process = false;
bool return_to_handler = false;
bool rettobase = false;
assert(arm_v7m_is_handler_mode(env));
type = env->regs[15];
if (env->thumb) {
type |= 1;
}
qemu_log_mask(CPU_LOG_INT, "Exception return: magic PC %" PRIx32
" previous exception %d\n",
type, env->v7m.exception);
if (extract32(type, 5, 23) != extract32(-1, 5, 23)) {
qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero high bits in exception "
"exit PC value 0x%" PRIx32 " are UNPREDICTABLE\n", type);
}
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
int VAR_1 = type & 1;
if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) {
env->v7m.faultmask[VAR_1] = 0;
}
} else {
env->v7m.faultmask[M_REG_NS] = 0;
}
}
switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) {
case -1:
ufault = true;
break;
case 0:
break;
case 1:
rettobase = true;
break;
default:
g_assert_not_reached();
}
switch (type & 0xf) {
case 1:
return_to_handler = true;
break;
case 13:
return_to_sp_process = true;
case 9:
if (!rettobase &&
!(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) {
ufault = true;
}
break;
default:
ufault = true;
}
if (ufault) {
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
v7m_exception_taken(VAR_0, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
"stackframe: failed exception return integrity check\n");
return;
}
switch_v7m_sp(env, return_to_sp_process);
env->regs[0] = v7m_pop(env);
env->regs[1] = v7m_pop(env);
env->regs[2] = v7m_pop(env);
env->regs[3] = v7m_pop(env);
env->regs[12] = v7m_pop(env);
env->regs[14] = v7m_pop(env);
env->regs[15] = v7m_pop(env);
if (env->regs[15] & 1) {
qemu_log_mask(LOG_GUEST_ERROR,
"M profile return from interrupt with misaligned "
"PC is UNPREDICTABLE\n");
env->regs[15] &= ~1U;
}
xpsr = v7m_pop(env);
xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
if (xpsr & XPSR_SPREALIGN) {
env->regs[13] |= 4;
}
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;
v7m_push_stack(VAR_0);
v7m_exception_taken(VAR_0, type | 0xf0000000);
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: "
"failed exception return integrity check\n");
return;
}
qemu_log_mask(CPU_LOG_INT, "...successful exception return\n");
}
| [
"static void FUNC_0(ARMCPU *VAR_0)\n{",
"CPUARMState *env = &VAR_0->env;",
"uint32_t type;",
"uint32_t xpsr;",
"bool ufault = false;",
"bool return_to_sp_process = false;",
"bool return_to_handler = false;",
"bool rettobase = false;",
"assert(arm_v7m_is_handler_mode(env));",
"type = env->regs[15];",
"if (env->thumb) {",
"type |= 1;",
"}",
"qemu_log_mask(CPU_LOG_INT, \"Exception return: magic PC %\" PRIx32\n\" previous exception %d\\n\",\ntype, env->v7m.exception);",
"if (extract32(type, 5, 23) != extract32(-1, 5, 23)) {",
"qemu_log_mask(LOG_GUEST_ERROR, \"M profile: zero high bits in exception \"\n\"exit PC value 0x%\" PRIx32 \" are UNPREDICTABLE\\n\", type);",
"}",
"if (env->v7m.exception != ARMV7M_EXCP_NMI) {",
"if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {",
"int VAR_1 = type & 1;",
"if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) {",
"env->v7m.faultmask[VAR_1] = 0;",
"}",
"} else {",
"env->v7m.faultmask[M_REG_NS] = 0;",
"}",
"}",
"switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) {",
"case -1:\nufault = true;",
"break;",
"case 0:\nbreak;",
"case 1:\nrettobase = true;",
"break;",
"default:\ng_assert_not_reached();",
"}",
"switch (type & 0xf) {",
"case 1:\nreturn_to_handler = true;",
"break;",
"case 13:\nreturn_to_sp_process = true;",
"case 9:\nif (!rettobase &&\n!(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) {",
"ufault = true;",
"}",
"break;",
"default:\nufault = true;",
"}",
"if (ufault) {",
"env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;",
"armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);",
"v7m_exception_taken(VAR_0, type | 0xf0000000);",
"qemu_log_mask(CPU_LOG_INT, \"...taking UsageFault on existing \"\n\"stackframe: failed exception return integrity check\\n\");",
"return;",
"}",
"switch_v7m_sp(env, return_to_sp_process);",
"env->regs[0] = v7m_pop(env);",
"env->regs[1] = v7m_pop(env);",
"env->regs[2] = v7m_pop(env);",
"env->regs[3] = v7m_pop(env);",
"env->regs[12] = v7m_pop(env);",
"env->regs[14] = v7m_pop(env);",
"env->regs[15] = v7m_pop(env);",
"if (env->regs[15] & 1) {",
"qemu_log_mask(LOG_GUEST_ERROR,\n\"M profile return from interrupt with misaligned \"\n\"PC is UNPREDICTABLE\\n\");",
"env->regs[15] &= ~1U;",
"}",
"xpsr = v7m_pop(env);",
"xpsr_write(env, xpsr, ~XPSR_SPREALIGN);",
"if (xpsr & XPSR_SPREALIGN) {",
"env->regs[13] |= 4;",
"}",
"if (return_to_handler != arm_v7m_is_handler_mode(env)) {",
"armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);",
"env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK;",
"v7m_push_stack(VAR_0);",
"v7m_exception_taken(VAR_0, type | 0xf0000000);",
"qemu_log_mask(CPU_LOG_INT, \"...taking UsageFault on new stackframe: \"\n\"failed exception return integrity check\\n\");",
"return;",
"}",
"qemu_log_mask(CPU_LOG_INT, \"...successful exception return\\n\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
31
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
61,
63
],
[
67
],
[
69,
71
],
[
73
],
[
77
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113,
117
],
[
119
],
[
121,
125
],
[
127,
137
],
[
139
],
[
141,
143
],
[
145
],
[
149
],
[
151,
153
],
[
155
],
[
157,
159
],
[
163,
165,
167
],
[
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
183
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229,
231,
233
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
293
],
[
295
]
] |
25,708 | static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int i, l2_size, nb_csectors;
/* Read L2 table from disk */
l2_size = s->l2_size * sizeof(uint64_t);
l2_table = g_malloc(l2_size);
if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
goto fail;
/* Do the actual checks */
for(i = 0; i < s->l2_size; i++) {
l2_entry = be64_to_cpu(l2_table[i]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
/* Compressed clusters don't have QCOW_OFLAG_COPIED */
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
res->corruptions++;
}
/* Mark cluster as used */
nb_csectors = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_entry & ~511, nb_csectors * 512);
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
res->bfi.compressed_clusters++;
/* Compressed clusters are fragmented by nature. Since they
* take up sub-sector space but we only have sector granularity
* I/O we need to re-read the same sectors even for adjacent
* compressed clusters.
*/
res->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
/* fall through */
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
res->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
/* Mark cluster as used */
inc_refcounts(bs, res, refcount_table,refcount_table_size,
offset, s->cluster_size);
/* Correct offsets are cluster aligned */
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
res->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
g_free(l2_table);
return -EIO;
}
| false | qemu | 713d9675e0e31c627d08b6a33d3a92e4b8505b40 | static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res,
uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset,
int flags)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int i, l2_size, nb_csectors;
l2_size = s->l2_size * sizeof(uint64_t);
l2_table = g_malloc(l2_size);
if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
goto fail;
for(i = 0; i < s->l2_size; i++) {
l2_entry = be64_to_cpu(l2_table[i]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
res->corruptions++;
}
nb_csectors = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(bs, res, refcount_table, refcount_table_size,
l2_entry & ~511, nb_csectors * 512);
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
res->bfi.compressed_clusters++;
res->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (flags & CHECK_FRAG_INFO) {
res->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
res->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
inc_refcounts(bs, res, refcount_table,refcount_table_size,
offset, s->cluster_size);
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
res->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
g_free(l2_table);
return -EIO;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,
uint16_t *VAR_2, int VAR_3, int64_t VAR_4,
int VAR_5)
{
BDRVQcowState *s = VAR_0->opaque;
uint64_t *l2_table, l2_entry;
uint64_t next_contiguous_offset = 0;
int VAR_6, VAR_7, VAR_8;
VAR_7 = s->VAR_7 * sizeof(uint64_t);
l2_table = g_malloc(VAR_7);
if (bdrv_pread(VAR_0->file, VAR_4, l2_table, VAR_7) != VAR_7)
goto fail;
for(VAR_6 = 0; VAR_6 < s->VAR_7; VAR_6++) {
l2_entry = be64_to_cpu(l2_table[VAR_6]);
switch (qcow2_get_cluster_type(l2_entry)) {
case QCOW2_CLUSTER_COMPRESSED:
if (l2_entry & QCOW_OFLAG_COPIED) {
fprintf(stderr, "ERROR: cluster %" PRId64 ": "
"copied flag must never be set for compressed "
"clusters\n", l2_entry >> s->cluster_bits);
l2_entry &= ~QCOW_OFLAG_COPIED;
VAR_1->corruptions++;
}
VAR_8 = ((l2_entry >> s->csize_shift) &
s->csize_mask) + 1;
l2_entry &= s->cluster_offset_mask;
inc_refcounts(VAR_0, VAR_1, VAR_2, VAR_3,
l2_entry & ~511, VAR_8 * 512);
if (VAR_5 & CHECK_FRAG_INFO) {
VAR_1->bfi.allocated_clusters++;
VAR_1->bfi.compressed_clusters++;
VAR_1->bfi.fragmented_clusters++;
}
break;
case QCOW2_CLUSTER_ZERO:
if ((l2_entry & L2E_OFFSET_MASK) == 0) {
break;
}
case QCOW2_CLUSTER_NORMAL:
{
uint64_t offset = l2_entry & L2E_OFFSET_MASK;
if (VAR_5 & CHECK_FRAG_INFO) {
VAR_1->bfi.allocated_clusters++;
if (next_contiguous_offset &&
offset != next_contiguous_offset) {
VAR_1->bfi.fragmented_clusters++;
}
next_contiguous_offset = offset + s->cluster_size;
}
inc_refcounts(VAR_0, VAR_1, VAR_2,VAR_3,
offset, s->cluster_size);
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
"properly aligned; L2 entry corrupted.\n", offset);
VAR_1->corruptions++;
}
break;
}
case QCOW2_CLUSTER_UNALLOCATED:
break;
default:
abort();
}
}
g_free(l2_table);
return 0;
fail:
fprintf(stderr, "ERROR: I/O error in FUNC_0\n");
g_free(l2_table);
return -EIO;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nuint16_t *VAR_2, int VAR_3, int64_t VAR_4,\nint VAR_5)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"uint64_t *l2_table, l2_entry;",
"uint64_t next_contiguous_offset = 0;",
"int VAR_6, VAR_7, VAR_8;",
"VAR_7 = s->VAR_7 * sizeof(uint64_t);",
"l2_table = g_malloc(VAR_7);",
"if (bdrv_pread(VAR_0->file, VAR_4, l2_table, VAR_7) != VAR_7)\ngoto fail;",
"for(VAR_6 = 0; VAR_6 < s->VAR_7; VAR_6++) {",
"l2_entry = be64_to_cpu(l2_table[VAR_6]);",
"switch (qcow2_get_cluster_type(l2_entry)) {",
"case QCOW2_CLUSTER_COMPRESSED:\nif (l2_entry & QCOW_OFLAG_COPIED) {",
"fprintf(stderr, \"ERROR: cluster %\" PRId64 \": \"\n\"copied flag must never be set for compressed \"\n\"clusters\\n\", l2_entry >> s->cluster_bits);",
"l2_entry &= ~QCOW_OFLAG_COPIED;",
"VAR_1->corruptions++;",
"}",
"VAR_8 = ((l2_entry >> s->csize_shift) &\ns->csize_mask) + 1;",
"l2_entry &= s->cluster_offset_mask;",
"inc_refcounts(VAR_0, VAR_1, VAR_2, VAR_3,\nl2_entry & ~511, VAR_8 * 512);",
"if (VAR_5 & CHECK_FRAG_INFO) {",
"VAR_1->bfi.allocated_clusters++;",
"VAR_1->bfi.compressed_clusters++;",
"VAR_1->bfi.fragmented_clusters++;",
"}",
"break;",
"case QCOW2_CLUSTER_ZERO:\nif ((l2_entry & L2E_OFFSET_MASK) == 0) {",
"break;",
"}",
"case QCOW2_CLUSTER_NORMAL:\n{",
"uint64_t offset = l2_entry & L2E_OFFSET_MASK;",
"if (VAR_5 & CHECK_FRAG_INFO) {",
"VAR_1->bfi.allocated_clusters++;",
"if (next_contiguous_offset &&\noffset != next_contiguous_offset) {",
"VAR_1->bfi.fragmented_clusters++;",
"}",
"next_contiguous_offset = offset + s->cluster_size;",
"}",
"inc_refcounts(VAR_0, VAR_1, VAR_2,VAR_3,\noffset, s->cluster_size);",
"if (offset_into_cluster(s, offset)) {",
"fprintf(stderr, \"ERROR offset=%\" PRIx64 \": Cluster is not \"\n\"properly aligned; L2 entry corrupted.\\n\", offset);",
"VAR_1->corruptions++;",
"}",
"break;",
"}",
"case QCOW2_CLUSTER_UNALLOCATED:\nbreak;",
"default:\nabort();",
"}",
"}",
"g_free(l2_table);",
"return 0;",
"fail:\nfprintf(stderr, \"ERROR: I/O error in FUNC_0\\n\");",
"g_free(l2_table);",
"return -EIO;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23
],
[
27,
29
],
[
35
],
[
37
],
[
41
],
[
43,
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
65,
67
],
[
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107
],
[
109
],
[
115,
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
143,
145
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167,
169
],
[
173,
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189,
191
],
[
193
],
[
195
],
[
197
]
] |
25,709 | static inline void gen_op_fcmpq(int fccno)
{
switch (fccno) {
case 0:
gen_helper_fcmpq(cpu_env);
break;
case 1:
gen_helper_fcmpq_fcc1(cpu_env);
break;
case 2:
gen_helper_fcmpq_fcc2(cpu_env);
break;
case 3:
gen_helper_fcmpq_fcc3(cpu_env);
break;
}
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | static inline void gen_op_fcmpq(int fccno)
{
switch (fccno) {
case 0:
gen_helper_fcmpq(cpu_env);
break;
case 1:
gen_helper_fcmpq_fcc1(cpu_env);
break;
case 2:
gen_helper_fcmpq_fcc2(cpu_env);
break;
case 3:
gen_helper_fcmpq_fcc3(cpu_env);
break;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(int VAR_0)
{
switch (VAR_0) {
case 0:
gen_helper_fcmpq(cpu_env);
break;
case 1:
gen_helper_fcmpq_fcc1(cpu_env);
break;
case 2:
gen_helper_fcmpq_fcc2(cpu_env);
break;
case 3:
gen_helper_fcmpq_fcc3(cpu_env);
break;
}
}
| [
"static inline void FUNC_0(int VAR_0)\n{",
"switch (VAR_0) {",
"case 0:\ngen_helper_fcmpq(cpu_env);",
"break;",
"case 1:\ngen_helper_fcmpq_fcc1(cpu_env);",
"break;",
"case 2:\ngen_helper_fcmpq_fcc2(cpu_env);",
"break;",
"case 3:\ngen_helper_fcmpq_fcc3(cpu_env);",
"break;",
"}",
"}"
] | [
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
]
] |
25,712 | static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs)
{
return closedir(fs->dir);
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs)
{
return closedir(fs->dir);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1)
{
return closedir(VAR_1->dir);
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1)\n{",
"return closedir(VAR_1->dir);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,715 | static int ne2000_can_receive(void *opaque)
{
NE2000State *s = opaque;
int avail, index, boundary;
if (s->cmd & E8390_STOP)
return 0;
index = s->curpag << 8;
boundary = s->boundary << 8;
if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
if (avail < (MAX_ETH_FRAME_SIZE + 4))
return 0;
return MAX_ETH_FRAME_SIZE;
}
| true | qemu | d861b05ea30e6ac177de9b679da96194ebe21afc | static int ne2000_can_receive(void *opaque)
{
NE2000State *s = opaque;
int avail, index, boundary;
if (s->cmd & E8390_STOP)
return 0;
index = s->curpag << 8;
boundary = s->boundary << 8;
if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
if (avail < (MAX_ETH_FRAME_SIZE + 4))
return 0;
return MAX_ETH_FRAME_SIZE;
}
| {
"code": [
"static int ne2000_can_receive(void *opaque)",
" NE2000State *s = opaque;",
" if (s->cmd & E8390_STOP)",
" return 0;",
" return 0;",
" return MAX_ETH_FRAME_SIZE;"
],
"line_no": [
1,
5,
11,
13,
13,
31
]
} | static int FUNC_0(void *VAR_0)
{
NE2000State *s = VAR_0;
int VAR_1, VAR_2, VAR_3;
if (s->cmd & E8390_STOP)
return 0;
VAR_2 = s->curpag << 8;
VAR_3 = s->VAR_3 << 8;
if (VAR_2 < VAR_3)
VAR_1 = VAR_3 - VAR_2;
else
VAR_1 = (s->stop - s->start) - (VAR_2 - VAR_3);
if (VAR_1 < (MAX_ETH_FRAME_SIZE + 4))
return 0;
return MAX_ETH_FRAME_SIZE;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"NE2000State *s = VAR_0;",
"int VAR_1, VAR_2, VAR_3;",
"if (s->cmd & E8390_STOP)\nreturn 0;",
"VAR_2 = s->curpag << 8;",
"VAR_3 = s->VAR_3 << 8;",
"if (VAR_2 < VAR_3)\nVAR_1 = VAR_3 - VAR_2;",
"else\nVAR_1 = (s->stop - s->start) - (VAR_2 - VAR_3);",
"if (VAR_1 < (MAX_ETH_FRAME_SIZE + 4))\nreturn 0;",
"return MAX_ETH_FRAME_SIZE;",
"}"
] | [
1,
1,
0,
1,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19,
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
]
] |
25,716 | static void test_qemu_strtoll_invalid(void)
{
const char *str = " xxxx \t abc";
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
int err;
err = qemu_strtoll(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert(endptr == str);
}
| true | qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | static void test_qemu_strtoll_invalid(void)
{
const char *str = " xxxx \t abc";
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
int err;
err = qemu_strtoll(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert(endptr == str);
}
| {
"code": [
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);",
" g_assert(endptr == str);",
" g_assert_cmpint(err, ==, 0);"
],
"line_no": [
21,
23,
21,
23,
21,
23,
21,
21,
23,
21,
23,
21,
23,
21,
21,
23,
21,
23,
21,
23,
21,
21,
23,
21,
23,
21,
23,
21
]
} | static void FUNC_0(void)
{
const char *VAR_0 = " xxxx \t abc";
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
int64_t res = 999;
int VAR_3;
VAR_3 = qemu_strtoll(VAR_0, &VAR_2, 0, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert(VAR_2 == VAR_0);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \" xxxx \\t abc\";",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"int64_t res = 999;",
"int VAR_3;",
"VAR_3 = qemu_strtoll(VAR_0, &VAR_2, 0, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert(VAR_2 == VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
]
] |
25,718 | static int decode_i_picture_secondary_header(VC9Context *v)
{
int status;
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
v->s.ac_pred = get_bits(&v->s.gb, 1);
if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1);
/* 7.1.1.34 + 8.5.2 */
if (v->overlap && v->pq<9)
{
v->condover = get_bits(&v->s.gb, 1);
if (v->condover)
{
v->condover = 2+get_bits(&v->s.gb, 1);
if (v->condover == 3)
{
status = bitplane_decoding(&v->over_flags_plane, v);
if (status < 0) return -1;
# if TRACE
av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
# endif
}
}
}
}
#endif
/* Epilog (AC/DC syntax) should be done in caller */
return 0;
}
| true | FFmpeg | 7cc84d241ba6ef8e27e4d057176a4ad385ad3d59 | static int decode_i_picture_secondary_header(VC9Context *v)
{
int status;
#if HAS_ADVANCED_PROFILE
if (v->profile > PROFILE_MAIN)
{
v->s.ac_pred = get_bits(&v->s.gb, 1);
if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1);
if (v->overlap && v->pq<9)
{
v->condover = get_bits(&v->s.gb, 1);
if (v->condover)
{
v->condover = 2+get_bits(&v->s.gb, 1);
if (v->condover == 3)
{
status = bitplane_decoding(&v->over_flags_plane, v);
if (status < 0) return -1;
# if TRACE
av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
# endif
}
}
}
}
#endif
return 0;
}
| {
"code": [
"#endif",
"#endif",
"# endif",
"#endif",
"#endif",
" if (v->profile > PROFILE_MAIN)",
"#endif",
"# if TRACE",
"# endif",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
" if (v->profile > PROFILE_MAIN)",
"#endif",
"#endif"
],
"line_no": [
55,
55,
45,
55,
55,
9,
55,
39,
45,
9,
9,
9,
9,
9,
9,
9,
55,
55
]
} | static int FUNC_0(VC9Context *VAR_0)
{
int VAR_1;
#if HAS_ADVANCED_PROFILE
if (VAR_0->profile > PROFILE_MAIN)
{
VAR_0->s.ac_pred = get_bits(&VAR_0->s.gb, 1);
if (VAR_0->postprocflag) VAR_0->postproc = get_bits(&VAR_0->s.gb, 1);
if (VAR_0->overlap && VAR_0->pq<9)
{
VAR_0->condover = get_bits(&VAR_0->s.gb, 1);
if (VAR_0->condover)
{
VAR_0->condover = 2+get_bits(&VAR_0->s.gb, 1);
if (VAR_0->condover == 3)
{
VAR_1 = bitplane_decoding(&VAR_0->over_flags_plane, VAR_0);
if (VAR_1 < 0) return -1;
# if TRACE
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: "
"Imode: %i, Invert: %i\n", VAR_1>>1, VAR_1&1);
# endif
}
}
}
}
#endif
return 0;
}
| [
"static int FUNC_0(VC9Context *VAR_0)\n{",
"int VAR_1;",
"#if HAS_ADVANCED_PROFILE\nif (VAR_0->profile > PROFILE_MAIN)\n{",
"VAR_0->s.ac_pred = get_bits(&VAR_0->s.gb, 1);",
"if (VAR_0->postprocflag) VAR_0->postproc = get_bits(&VAR_0->s.gb, 1);",
"if (VAR_0->overlap && VAR_0->pq<9)\n{",
"VAR_0->condover = get_bits(&VAR_0->s.gb, 1);",
"if (VAR_0->condover)\n{",
"VAR_0->condover = 2+get_bits(&VAR_0->s.gb, 1);",
"if (VAR_0->condover == 3)\n{",
"VAR_1 = bitplane_decoding(&VAR_0->over_flags_plane, VAR_0);",
"if (VAR_1 < 0) return -1;",
"# if TRACE\nav_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"Overflags plane encoding: \"\n\"Imode: %i, Invert: %i\\n\", VAR_1>>1, VAR_1&1);",
"# endif\n}",
"}",
"}",
"}",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
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,
61
],
[
63
]
] |
25,719 | void visit_type_enum(Visitor *v, int *obj, const char *strings[],
const char *kind, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->type_enum(v, obj, strings, kind, name, errp);
}
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | void visit_type_enum(Visitor *v, int *obj, const char *strings[],
const char *kind, const char *name, Error **errp)
{
if (!error_is_set(errp)) {
v->type_enum(v, obj, strings, kind, name, errp);
}
}
| {
"code": [
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" v->type_enum(v, obj, strings, kind, name, errp);",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {",
" if (!error_is_set(errp)) {"
],
"line_no": [
7,
7,
7,
7,
9,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7
]
} | void FUNC_0(Visitor *VAR_0, int *VAR_1, const char *VAR_2[],
const char *VAR_3, const char *VAR_4, Error **VAR_5)
{
if (!error_is_set(VAR_5)) {
VAR_0->type_enum(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);
}
}
| [
"void FUNC_0(Visitor *VAR_0, int *VAR_1, const char *VAR_2[],\nconst char *VAR_3, const char *VAR_4, Error **VAR_5)\n{",
"if (!error_is_set(VAR_5)) {",
"VAR_0->type_enum(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);",
"}",
"}"
] | [
0,
1,
1,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,720 | static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st,
AVPacket *pkt)
{
AVIStream *ast, *next_ast = next_st->priv_data;
int64_t ts, next_ts, ts_min = INT64_MAX;
AVStream *st, *sub_st = NULL;
int i;
next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base,
AV_TIME_BASE_Q);
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
ast = st->priv_data;
if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {
ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);
if (ts <= next_ts && ts < ts_min) {
ts_min = ts;
sub_st = st;
}
}
}
if (sub_st) {
ast = sub_st->priv_data;
*pkt = ast->sub_pkt;
pkt->stream_index = sub_st->index;
if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
ast->sub_pkt.data = NULL;
}
return sub_st;
}
| true | FFmpeg | 4ed899f2c5848b75b61d13ad42942ecc2a4386f9 | static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st,
AVPacket *pkt)
{
AVIStream *ast, *next_ast = next_st->priv_data;
int64_t ts, next_ts, ts_min = INT64_MAX;
AVStream *st, *sub_st = NULL;
int i;
next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base,
AV_TIME_BASE_Q);
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
ast = st->priv_data;
if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {
ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);
if (ts <= next_ts && ts < ts_min) {
ts_min = ts;
sub_st = st;
}
}
}
if (sub_st) {
ast = sub_st->priv_data;
*pkt = ast->sub_pkt;
pkt->stream_index = sub_st->index;
if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
ast->sub_pkt.data = NULL;
}
return sub_st;
}
| {
"code": [
" if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {"
],
"line_no": [
29
]
} | static AVStream *FUNC_0(AVFormatContext *s, AVStream *next_st,
AVPacket *pkt)
{
AVIStream *ast, *next_ast = next_st->priv_data;
int64_t ts, next_ts, ts_min = INT64_MAX;
AVStream *st, *sub_st = NULL;
int VAR_0;
next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base,
AV_TIME_BASE_Q);
for (VAR_0=0; VAR_0<s->nb_streams; VAR_0++) {
st = s->streams[VAR_0];
ast = st->priv_data;
if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {
ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);
if (ts <= next_ts && ts < ts_min) {
ts_min = ts;
sub_st = st;
}
}
}
if (sub_st) {
ast = sub_st->priv_data;
*pkt = ast->sub_pkt;
pkt->stream_index = sub_st->index;
if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
ast->sub_pkt.data = NULL;
}
return sub_st;
}
| [
"static AVStream *FUNC_0(AVFormatContext *s, AVStream *next_st,\nAVPacket *pkt)\n{",
"AVIStream *ast, *next_ast = next_st->priv_data;",
"int64_t ts, next_ts, ts_min = INT64_MAX;",
"AVStream *st, *sub_st = NULL;",
"int VAR_0;",
"next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base,\nAV_TIME_BASE_Q);",
"for (VAR_0=0; VAR_0<s->nb_streams; VAR_0++) {",
"st = s->streams[VAR_0];",
"ast = st->priv_data;",
"if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) {",
"ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);",
"if (ts <= next_ts && ts < ts_min) {",
"ts_min = ts;",
"sub_st = st;",
"}",
"}",
"}",
"if (sub_st) {",
"ast = sub_st->priv_data;",
"*pkt = ast->sub_pkt;",
"pkt->stream_index = sub_st->index;",
"if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)\nast->sub_pkt.data = NULL;",
"}",
"return sub_st;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
]
] |
25,721 | static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
KBDState *s = (KBDState *)dev;
int qcode, keycode;
qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);
if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) {
return;
}
/* FIXME: take handler into account when translating qcode */
keycode = qcode_to_adb_keycode[qcode];
if (keycode == NO_KEY) { /* We don't want to send this to the guest */
ADB_DPRINTF("Ignoring NO_KEY\n");
return;
}
if (evt->u.key.data->down == false) { /* if key release event */
keycode = keycode | 0x80; /* create keyboard break code */
}
adb_kbd_put_keycode(s, keycode);
}
| true | qemu | 77cb0f5aafc8e6d0c6d3c339f381c9b7921648e0 | static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
{
KBDState *s = (KBDState *)dev;
int qcode, keycode;
qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);
if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) {
return;
}
keycode = qcode_to_adb_keycode[qcode];
if (keycode == NO_KEY) {
ADB_DPRINTF("Ignoring NO_KEY\n");
return;
}
if (evt->u.key.data->down == false) {
keycode = keycode | 0x80;
}
adb_kbd_put_keycode(s, keycode);
}
| {
"code": [
"static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,",
" InputEvent *evt)",
" KBDState *s = (KBDState *)dev;",
" int qcode, keycode;",
" qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key);",
" if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) {",
" keycode = qcode_to_adb_keycode[qcode];",
" ADB_DPRINTF(\"Ignoring NO_KEY\\n\");",
" adb_kbd_put_keycode(s, keycode);"
],
"line_no": [
1,
3,
7,
9,
13,
15,
23,
27,
41
]
} | static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,
InputEvent *VAR_2)
{
KBDState *s = (KBDState *)VAR_0;
int VAR_3, VAR_4;
VAR_3 = qemu_input_key_value_to_qcode(VAR_2->u.key.data->key);
if (VAR_3 >= ARRAY_SIZE(qcode_to_adb_keycode)) {
return;
}
VAR_4 = qcode_to_adb_keycode[VAR_3];
if (VAR_4 == NO_KEY) {
ADB_DPRINTF("Ignoring NO_KEY\n");
return;
}
if (VAR_2->u.key.data->down == false) {
VAR_4 = VAR_4 | 0x80;
}
adb_kbd_put_keycode(s, VAR_4);
}
| [
"static void FUNC_0(DeviceState *VAR_0, QemuConsole *VAR_1,\nInputEvent *VAR_2)\n{",
"KBDState *s = (KBDState *)VAR_0;",
"int VAR_3, VAR_4;",
"VAR_3 = qemu_input_key_value_to_qcode(VAR_2->u.key.data->key);",
"if (VAR_3 >= ARRAY_SIZE(qcode_to_adb_keycode)) {",
"return;",
"}",
"VAR_4 = qcode_to_adb_keycode[VAR_3];",
"if (VAR_4 == NO_KEY) {",
"ADB_DPRINTF(\"Ignoring NO_KEY\\n\");",
"return;",
"}",
"if (VAR_2->u.key.data->down == false) {",
"VAR_4 = VAR_4 | 0x80;",
"}",
"adb_kbd_put_keycode(s, VAR_4);",
"}"
] | [
1,
1,
1,
1,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
]
] |
25,722 | void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
mm_flags = mm_support();
if (avctx->dsp_mask) {
if (avctx->dsp_mask & FF_MM_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
else
mm_flags &= ~(avctx->dsp_mask & 0xffff);
}
#if 0
av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
if (mm_flags & MM_MMX)
av_log(avctx, AV_LOG_INFO, " mmx");
if (mm_flags & MM_MMXEXT)
av_log(avctx, AV_LOG_INFO, " mmxext");
if (mm_flags & MM_3DNOW)
av_log(avctx, AV_LOG_INFO, " 3dnow");
if (mm_flags & MM_SSE)
av_log(avctx, AV_LOG_INFO, " sse");
if (mm_flags & MM_SSE2)
av_log(avctx, AV_LOG_INFO, " sse2");
av_log(avctx, AV_LOG_INFO, "\n");
#endif
if (mm_flags & MM_MMX) {
const int idct_algo= avctx->idct_algo;
if(avctx->lowres==0){
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
#ifdef CONFIG_GPL
}else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
if(mm_flags & MM_MMXEXT){
c->idct_put= ff_libmpeg2mmx2_idct_put;
c->idct_add= ff_libmpeg2mmx2_idct_add;
c->idct = ff_mmxext_idct;
}else{
c->idct_put= ff_libmpeg2mmx_idct_put;
c->idct_add= ff_libmpeg2mmx_idct_add;
c->idct = ff_mmx_idct;
}
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
}else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER) &&
idct_algo==FF_IDCT_VP3){
if(mm_flags & MM_SSE2){
c->idct_put= ff_vp3_idct_put_sse2;
c->idct_add= ff_vp3_idct_add_sse2;
c->idct = ff_vp3_idct_sse2;
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else{
c->idct_put= ff_vp3_idct_put_mmx;
c->idct_add= ff_vp3_idct_add_mmx;
c->idct = ff_vp3_idct_mmx;
c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;
}
}else if(idct_algo==FF_IDCT_CAVS){
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else if(idct_algo==FF_IDCT_XVIDMMX){
if(mm_flags & MM_SSE2){
c->idct_put= ff_idct_xvid_sse2_put;
c->idct_add= ff_idct_xvid_sse2_add;
c->idct = ff_idct_xvid_sse2;
c->idct_permutation_type= FF_SSE2_IDCT_PERM;
}else if(mm_flags & MM_MMXEXT){
c->idct_put= ff_idct_xvid_mmx2_put;
c->idct_add= ff_idct_xvid_mmx2_add;
c->idct = ff_idct_xvid_mmx2;
}else{
c->idct_put= ff_idct_xvid_mmx_put;
c->idct_add= ff_idct_xvid_mmx_add;
c->idct = ff_idct_xvid_mmx;
}
}
}
c->put_pixels_clamped = put_pixels_clamped_mmx;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
c->add_pixels_clamped = add_pixels_clamped_mmx;
c->clear_blocks = clear_blocks_mmx;
#define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \
c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \
c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \
c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU
SET_HPEL_FUNCS(put, 0, 16, mmx);
SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(avg, 0, 16, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(put, 1, 8, mmx);
SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx);
SET_HPEL_FUNCS(avg, 1, 8, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx);
c->gmc= gmc_mmx;
c->add_bytes= add_bytes_mmx;
c->add_bytes_l2= add_bytes_l2_mmx;
c->draw_edges = draw_edges_mmx;
if (ENABLE_ANY_H263) {
c->h263_v_loop_filter= h263_v_loop_filter_mmx;
c->h263_h_loop_filter= h263_h_loop_filter_mmx;
}
if ((ENABLE_VP3_DECODER || ENABLE_THEORA_DECODER) &&
!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx;
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx;
}
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd;
c->h264_idct_dc_add=
c->h264_idct_add= ff_h264_idct_add_mmx;
c->h264_idct8_dc_add=
c->h264_idct8_add= ff_h264_idct8_add_mmx;
if (mm_flags & MM_SSE2)
c->h264_idct8_add= ff_h264_idct8_add_sse2;
if (mm_flags & MM_MMXEXT) {
c->prefetch = prefetch_mmx2;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
}
#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU
SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2);
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_mmx2(c, avctx);
if (ENABLE_VC1_DECODER || ENABLE_WMV3_DECODER)
ff_vc1dsp_init_mmx(c, avctx);
c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;
} else if (mm_flags & MM_3DNOW) {
c->prefetch = prefetch_3dnow;
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
}
SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_3dnow(c, avctx);
}
#define H264_QPEL_FUNCS(x, y, CPU)\
c->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\
c->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
if((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)){
// these functions are slower than mmx on AMD, but faster on Intel
/* FIXME works in most codecs, but crashes svq1 due to unaligned chroma
c->put_pixels_tab[0][0] = put_pixels16_sse2;
c->avg_pixels_tab[0][0] = avg_pixels16_sse2;
*/
H264_QPEL_FUNCS(0, 0, sse2);
}
if(mm_flags & MM_SSE2){
H264_QPEL_FUNCS(0, 1, sse2);
H264_QPEL_FUNCS(0, 2, sse2);
H264_QPEL_FUNCS(0, 3, sse2);
H264_QPEL_FUNCS(1, 1, sse2);
H264_QPEL_FUNCS(1, 2, sse2);
H264_QPEL_FUNCS(1, 3, sse2);
H264_QPEL_FUNCS(2, 1, sse2);
H264_QPEL_FUNCS(2, 2, sse2);
H264_QPEL_FUNCS(2, 3, sse2);
H264_QPEL_FUNCS(3, 1, sse2);
H264_QPEL_FUNCS(3, 2, sse2);
H264_QPEL_FUNCS(3, 3, sse2);
}
#ifdef HAVE_SSSE3
if(mm_flags & MM_SSSE3){
H264_QPEL_FUNCS(1, 0, ssse3);
H264_QPEL_FUNCS(1, 1, ssse3);
H264_QPEL_FUNCS(1, 2, ssse3);
H264_QPEL_FUNCS(1, 3, ssse3);
H264_QPEL_FUNCS(2, 0, ssse3);
H264_QPEL_FUNCS(2, 1, ssse3);
H264_QPEL_FUNCS(2, 2, ssse3);
H264_QPEL_FUNCS(2, 3, ssse3);
H264_QPEL_FUNCS(3, 0, ssse3);
H264_QPEL_FUNCS(3, 1, ssse3);
H264_QPEL_FUNCS(3, 2, ssse3);
H264_QPEL_FUNCS(3, 3, ssse3);
c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_nornd;
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd;
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3;
c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;
}
#endif
#ifdef CONFIG_SNOW_DECODER
if(mm_flags & MM_SSE2 & 0){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
#ifdef HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
#endif
c->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
}
else{
if(mm_flags & MM_MMXEXT){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;
#ifdef HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
#endif
}
c->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
}
#endif
if(mm_flags & MM_3DNOW){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
c->vector_fmul = vector_fmul_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->float_to_int16 = float_to_int16_3dnow;
c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
}
}
if(mm_flags & MM_3DNOWEXT){
c->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
c->vector_fmul_window = vector_fmul_window_3dnow2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
}
}
if(mm_flags & MM_SSE){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;
c->ac3_downmix = ac3_downmix_sse;
c->vector_fmul = vector_fmul_sse;
c->vector_fmul_reverse = vector_fmul_reverse_sse;
c->vector_fmul_add_add = vector_fmul_add_add_sse;
c->vector_fmul_window = vector_fmul_window_sse;
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
c->float_to_int16 = float_to_int16_sse;
c->float_to_int16_interleave = float_to_int16_interleave_sse;
}
if(mm_flags & MM_3DNOW)
c->vector_fmul_add_add = vector_fmul_add_add_3dnow; // faster than sse
if(mm_flags & MM_SSE2){
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
c->float_to_int16 = float_to_int16_sse2;
c->float_to_int16_interleave = float_to_int16_interleave_sse2;
c->add_int16 = add_int16_sse2;
c->sub_int16 = sub_int16_sse2;
c->scalarproduct_int16 = scalarproduct_int16_sse2;
}
}
if (ENABLE_ENCODERS)
dsputilenc_init_mmx(c, avctx);
#if 0
// for speed testing
get_pixels = just_return;
put_pixels_clamped = just_return;
add_pixels_clamped = just_return;
pix_abs16x16 = just_return;
pix_abs16x16_x2 = just_return;
pix_abs16x16_y2 = just_return;
pix_abs16x16_xy2 = just_return;
put_pixels_tab[0] = just_return;
put_pixels_tab[1] = just_return;
put_pixels_tab[2] = just_return;
put_pixels_tab[3] = just_return;
put_no_rnd_pixels_tab[0] = just_return;
put_no_rnd_pixels_tab[1] = just_return;
put_no_rnd_pixels_tab[2] = just_return;
put_no_rnd_pixels_tab[3] = just_return;
avg_pixels_tab[0] = just_return;
avg_pixels_tab[1] = just_return;
avg_pixels_tab[2] = just_return;
avg_pixels_tab[3] = just_return;
avg_no_rnd_pixels_tab[0] = just_return;
avg_no_rnd_pixels_tab[1] = just_return;
avg_no_rnd_pixels_tab[2] = just_return;
avg_no_rnd_pixels_tab[3] = just_return;
//av_fdct = just_return;
//ff_idct = just_return;
#endif
}
| false | FFmpeg | daa1ea049a9445b7bed03963cb789497065dd1eb | void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
mm_flags = mm_support();
if (avctx->dsp_mask) {
if (avctx->dsp_mask & FF_MM_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
else
mm_flags &= ~(avctx->dsp_mask & 0xffff);
}
#if 0
av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
if (mm_flags & MM_MMX)
av_log(avctx, AV_LOG_INFO, " mmx");
if (mm_flags & MM_MMXEXT)
av_log(avctx, AV_LOG_INFO, " mmxext");
if (mm_flags & MM_3DNOW)
av_log(avctx, AV_LOG_INFO, " 3dnow");
if (mm_flags & MM_SSE)
av_log(avctx, AV_LOG_INFO, " sse");
if (mm_flags & MM_SSE2)
av_log(avctx, AV_LOG_INFO, " sse2");
av_log(avctx, AV_LOG_INFO, "\n");
#endif
if (mm_flags & MM_MMX) {
const int idct_algo= avctx->idct_algo;
if(avctx->lowres==0){
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
#ifdef CONFIG_GPL
}else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
if(mm_flags & MM_MMXEXT){
c->idct_put= ff_libmpeg2mmx2_idct_put;
c->idct_add= ff_libmpeg2mmx2_idct_add;
c->idct = ff_mmxext_idct;
}else{
c->idct_put= ff_libmpeg2mmx_idct_put;
c->idct_add= ff_libmpeg2mmx_idct_add;
c->idct = ff_mmx_idct;
}
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
}else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER) &&
idct_algo==FF_IDCT_VP3){
if(mm_flags & MM_SSE2){
c->idct_put= ff_vp3_idct_put_sse2;
c->idct_add= ff_vp3_idct_add_sse2;
c->idct = ff_vp3_idct_sse2;
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else{
c->idct_put= ff_vp3_idct_put_mmx;
c->idct_add= ff_vp3_idct_add_mmx;
c->idct = ff_vp3_idct_mmx;
c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;
}
}else if(idct_algo==FF_IDCT_CAVS){
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else if(idct_algo==FF_IDCT_XVIDMMX){
if(mm_flags & MM_SSE2){
c->idct_put= ff_idct_xvid_sse2_put;
c->idct_add= ff_idct_xvid_sse2_add;
c->idct = ff_idct_xvid_sse2;
c->idct_permutation_type= FF_SSE2_IDCT_PERM;
}else if(mm_flags & MM_MMXEXT){
c->idct_put= ff_idct_xvid_mmx2_put;
c->idct_add= ff_idct_xvid_mmx2_add;
c->idct = ff_idct_xvid_mmx2;
}else{
c->idct_put= ff_idct_xvid_mmx_put;
c->idct_add= ff_idct_xvid_mmx_add;
c->idct = ff_idct_xvid_mmx;
}
}
}
c->put_pixels_clamped = put_pixels_clamped_mmx;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
c->add_pixels_clamped = add_pixels_clamped_mmx;
c->clear_blocks = clear_blocks_mmx;
#define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \
c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \
c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \
c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU
SET_HPEL_FUNCS(put, 0, 16, mmx);
SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(avg, 0, 16, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(put, 1, 8, mmx);
SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx);
SET_HPEL_FUNCS(avg, 1, 8, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx);
c->gmc= gmc_mmx;
c->add_bytes= add_bytes_mmx;
c->add_bytes_l2= add_bytes_l2_mmx;
c->draw_edges = draw_edges_mmx;
if (ENABLE_ANY_H263) {
c->h263_v_loop_filter= h263_v_loop_filter_mmx;
c->h263_h_loop_filter= h263_h_loop_filter_mmx;
}
if ((ENABLE_VP3_DECODER || ENABLE_THEORA_DECODER) &&
!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx;
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx;
}
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd;
c->h264_idct_dc_add=
c->h264_idct_add= ff_h264_idct_add_mmx;
c->h264_idct8_dc_add=
c->h264_idct8_add= ff_h264_idct8_add_mmx;
if (mm_flags & MM_SSE2)
c->h264_idct8_add= ff_h264_idct8_add_sse2;
if (mm_flags & MM_MMXEXT) {
c->prefetch = prefetch_mmx2;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
}
#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU
SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2);
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_mmx2(c, avctx);
if (ENABLE_VC1_DECODER || ENABLE_WMV3_DECODER)
ff_vc1dsp_init_mmx(c, avctx);
c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;
} else if (mm_flags & MM_3DNOW) {
c->prefetch = prefetch_3dnow;
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
}
SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_3dnow(c, avctx);
}
#define H264_QPEL_FUNCS(x, y, CPU)\
c->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\
c->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
if((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)){
H264_QPEL_FUNCS(0, 0, sse2);
}
if(mm_flags & MM_SSE2){
H264_QPEL_FUNCS(0, 1, sse2);
H264_QPEL_FUNCS(0, 2, sse2);
H264_QPEL_FUNCS(0, 3, sse2);
H264_QPEL_FUNCS(1, 1, sse2);
H264_QPEL_FUNCS(1, 2, sse2);
H264_QPEL_FUNCS(1, 3, sse2);
H264_QPEL_FUNCS(2, 1, sse2);
H264_QPEL_FUNCS(2, 2, sse2);
H264_QPEL_FUNCS(2, 3, sse2);
H264_QPEL_FUNCS(3, 1, sse2);
H264_QPEL_FUNCS(3, 2, sse2);
H264_QPEL_FUNCS(3, 3, sse2);
}
#ifdef HAVE_SSSE3
if(mm_flags & MM_SSSE3){
H264_QPEL_FUNCS(1, 0, ssse3);
H264_QPEL_FUNCS(1, 1, ssse3);
H264_QPEL_FUNCS(1, 2, ssse3);
H264_QPEL_FUNCS(1, 3, ssse3);
H264_QPEL_FUNCS(2, 0, ssse3);
H264_QPEL_FUNCS(2, 1, ssse3);
H264_QPEL_FUNCS(2, 2, ssse3);
H264_QPEL_FUNCS(2, 3, ssse3);
H264_QPEL_FUNCS(3, 0, ssse3);
H264_QPEL_FUNCS(3, 1, ssse3);
H264_QPEL_FUNCS(3, 2, ssse3);
H264_QPEL_FUNCS(3, 3, ssse3);
c->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_nornd;
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd;
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3;
c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;
}
#endif
#ifdef CONFIG_SNOW_DECODER
if(mm_flags & MM_SSE2 & 0){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
#ifdef HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
#endif
c->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
}
else{
if(mm_flags & MM_MMXEXT){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;
#ifdef HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
#endif
}
c->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
}
#endif
if(mm_flags & MM_3DNOW){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
c->vector_fmul = vector_fmul_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->float_to_int16 = float_to_int16_3dnow;
c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
}
}
if(mm_flags & MM_3DNOWEXT){
c->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
c->vector_fmul_window = vector_fmul_window_3dnow2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
}
}
if(mm_flags & MM_SSE){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;
c->ac3_downmix = ac3_downmix_sse;
c->vector_fmul = vector_fmul_sse;
c->vector_fmul_reverse = vector_fmul_reverse_sse;
c->vector_fmul_add_add = vector_fmul_add_add_sse;
c->vector_fmul_window = vector_fmul_window_sse;
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
c->float_to_int16 = float_to_int16_sse;
c->float_to_int16_interleave = float_to_int16_interleave_sse;
}
if(mm_flags & MM_3DNOW)
c->vector_fmul_add_add = vector_fmul_add_add_3dnow;
if(mm_flags & MM_SSE2){
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
c->float_to_int16 = float_to_int16_sse2;
c->float_to_int16_interleave = float_to_int16_interleave_sse2;
c->add_int16 = add_int16_sse2;
c->sub_int16 = sub_int16_sse2;
c->scalarproduct_int16 = scalarproduct_int16_sse2;
}
}
if (ENABLE_ENCODERS)
dsputilenc_init_mmx(c, avctx);
#if 0
get_pixels = just_return;
put_pixels_clamped = just_return;
add_pixels_clamped = just_return;
pix_abs16x16 = just_return;
pix_abs16x16_x2 = just_return;
pix_abs16x16_y2 = just_return;
pix_abs16x16_xy2 = just_return;
put_pixels_tab[0] = just_return;
put_pixels_tab[1] = just_return;
put_pixels_tab[2] = just_return;
put_pixels_tab[3] = just_return;
put_no_rnd_pixels_tab[0] = just_return;
put_no_rnd_pixels_tab[1] = just_return;
put_no_rnd_pixels_tab[2] = just_return;
put_no_rnd_pixels_tab[3] = just_return;
avg_pixels_tab[0] = just_return;
avg_pixels_tab[1] = just_return;
avg_pixels_tab[2] = just_return;
avg_pixels_tab[3] = just_return;
avg_no_rnd_pixels_tab[0] = just_return;
avg_no_rnd_pixels_tab[1] = just_return;
avg_no_rnd_pixels_tab[2] = just_return;
avg_no_rnd_pixels_tab[3] = just_return;
#endif
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DSPContext* VAR_0, AVCodecContext *VAR_1)
{
mm_flags = mm_support();
if (VAR_1->dsp_mask) {
if (VAR_1->dsp_mask & FF_MM_FORCE)
mm_flags |= (VAR_1->dsp_mask & 0xffff);
else
mm_flags &= ~(VAR_1->dsp_mask & 0xffff);
}
#if 0
av_log(VAR_1, AV_LOG_INFO, "libavcodec: CPU flags:");
if (mm_flags & MM_MMX)
av_log(VAR_1, AV_LOG_INFO, " mmx");
if (mm_flags & MM_MMXEXT)
av_log(VAR_1, AV_LOG_INFO, " mmxext");
if (mm_flags & MM_3DNOW)
av_log(VAR_1, AV_LOG_INFO, " 3dnow");
if (mm_flags & MM_SSE)
av_log(VAR_1, AV_LOG_INFO, " sse");
if (mm_flags & MM_SSE2)
av_log(VAR_1, AV_LOG_INFO, " sse2");
av_log(VAR_1, AV_LOG_INFO, "\n");
#endif
if (mm_flags & MM_MMX) {
const int VAR_2= VAR_1->VAR_2;
if(VAR_1->lowres==0){
if(VAR_2==FF_IDCT_AUTO || VAR_2==FF_IDCT_SIMPLEMMX){
VAR_0->idct_put= ff_simple_idct_put_mmx;
VAR_0->idct_add= ff_simple_idct_add_mmx;
VAR_0->idct = ff_simple_idct_mmx;
VAR_0->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
#ifdef CONFIG_GPL
}else if(VAR_2==FF_IDCT_LIBMPEG2MMX){
if(mm_flags & MM_MMXEXT){
VAR_0->idct_put= ff_libmpeg2mmx2_idct_put;
VAR_0->idct_add= ff_libmpeg2mmx2_idct_add;
VAR_0->idct = ff_mmxext_idct;
}else{
VAR_0->idct_put= ff_libmpeg2mmx_idct_put;
VAR_0->idct_add= ff_libmpeg2mmx_idct_add;
VAR_0->idct = ff_mmx_idct;
}
VAR_0->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
}else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER) &&
VAR_2==FF_IDCT_VP3){
if(mm_flags & MM_SSE2){
VAR_0->idct_put= ff_vp3_idct_put_sse2;
VAR_0->idct_add= ff_vp3_idct_add_sse2;
VAR_0->idct = ff_vp3_idct_sse2;
VAR_0->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else{
VAR_0->idct_put= ff_vp3_idct_put_mmx;
VAR_0->idct_add= ff_vp3_idct_add_mmx;
VAR_0->idct = ff_vp3_idct_mmx;
VAR_0->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;
}
}else if(VAR_2==FF_IDCT_CAVS){
VAR_0->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else if(VAR_2==FF_IDCT_XVIDMMX){
if(mm_flags & MM_SSE2){
VAR_0->idct_put= ff_idct_xvid_sse2_put;
VAR_0->idct_add= ff_idct_xvid_sse2_add;
VAR_0->idct = ff_idct_xvid_sse2;
VAR_0->idct_permutation_type= FF_SSE2_IDCT_PERM;
}else if(mm_flags & MM_MMXEXT){
VAR_0->idct_put= ff_idct_xvid_mmx2_put;
VAR_0->idct_add= ff_idct_xvid_mmx2_add;
VAR_0->idct = ff_idct_xvid_mmx2;
}else{
VAR_0->idct_put= ff_idct_xvid_mmx_put;
VAR_0->idct_add= ff_idct_xvid_mmx_add;
VAR_0->idct = ff_idct_xvid_mmx;
}
}
}
VAR_0->put_pixels_clamped = put_pixels_clamped_mmx;
VAR_0->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
VAR_0->add_pixels_clamped = add_pixels_clamped_mmx;
VAR_0->clear_blocks = clear_blocks_mmx;
#define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \
VAR_0->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU
SET_HPEL_FUNCS(put, 0, 16, mmx);
SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(avg, 0, 16, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx);
SET_HPEL_FUNCS(put, 1, 8, mmx);
SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx);
SET_HPEL_FUNCS(avg, 1, 8, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx);
VAR_0->gmc= gmc_mmx;
VAR_0->add_bytes= add_bytes_mmx;
VAR_0->add_bytes_l2= add_bytes_l2_mmx;
VAR_0->draw_edges = draw_edges_mmx;
if (ENABLE_ANY_H263) {
VAR_0->h263_v_loop_filter= h263_v_loop_filter_mmx;
VAR_0->h263_h_loop_filter= h263_h_loop_filter_mmx;
}
if ((ENABLE_VP3_DECODER || ENABLE_THEORA_DECODER) &&
!(VAR_1->flags & CODEC_FLAG_BITEXACT)) {
VAR_0->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx;
VAR_0->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx;
}
VAR_0->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;
VAR_0->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
VAR_0->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd;
VAR_0->h264_idct_dc_add=
VAR_0->h264_idct_add= ff_h264_idct_add_mmx;
VAR_0->h264_idct8_dc_add=
VAR_0->h264_idct8_add= ff_h264_idct8_add_mmx;
if (mm_flags & MM_SSE2)
VAR_0->h264_idct8_add= ff_h264_idct8_add_sse2;
if (mm_flags & MM_MMXEXT) {
VAR_0->prefetch = prefetch_mmx2;
VAR_0->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
VAR_0->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
VAR_0->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
VAR_0->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
VAR_0->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
VAR_0->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
VAR_0->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
VAR_0->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
VAR_0->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
VAR_0->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
VAR_0->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
VAR_0->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){
VAR_0->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
VAR_0->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
VAR_0->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
VAR_0->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
VAR_0->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
VAR_0->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
}
#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \
VAR_0->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \
VAR_0->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU
SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2);
VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;
VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
VAR_0->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
VAR_0->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
VAR_0->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
VAR_0->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
VAR_0->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
VAR_0->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
VAR_0->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
VAR_0->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
VAR_0->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
VAR_0->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
VAR_0->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
VAR_0->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
VAR_0->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
VAR_0->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
VAR_0->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
VAR_0->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
VAR_0->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
VAR_0->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
VAR_0->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
VAR_0->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
VAR_0->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
VAR_0->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
VAR_0->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
VAR_0->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
VAR_0->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_mmx2(VAR_0, VAR_1);
if (ENABLE_VC1_DECODER || ENABLE_WMV3_DECODER)
ff_vc1dsp_init_mmx(VAR_0, VAR_1);
VAR_0->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;
} else if (mm_flags & MM_3DNOW) {
VAR_0->prefetch = prefetch_3dnow;
VAR_0->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
VAR_0->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
VAR_0->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
VAR_0->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
VAR_0->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
VAR_0->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
VAR_0->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
VAR_0->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
VAR_0->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
VAR_0->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){
VAR_0->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
VAR_0->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
VAR_0->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
VAR_0->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
VAR_0->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
VAR_0->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
}
SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;
VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
if (ENABLE_CAVS_DECODER)
ff_cavsdsp_init_3dnow(VAR_0, VAR_1);
}
#define H264_QPEL_FUNCS(x, y, CPU)\
VAR_0->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\
VAR_0->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\
VAR_0->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\
VAR_0->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
if((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)){
H264_QPEL_FUNCS(0, 0, sse2);
}
if(mm_flags & MM_SSE2){
H264_QPEL_FUNCS(0, 1, sse2);
H264_QPEL_FUNCS(0, 2, sse2);
H264_QPEL_FUNCS(0, 3, sse2);
H264_QPEL_FUNCS(1, 1, sse2);
H264_QPEL_FUNCS(1, 2, sse2);
H264_QPEL_FUNCS(1, 3, sse2);
H264_QPEL_FUNCS(2, 1, sse2);
H264_QPEL_FUNCS(2, 2, sse2);
H264_QPEL_FUNCS(2, 3, sse2);
H264_QPEL_FUNCS(3, 1, sse2);
H264_QPEL_FUNCS(3, 2, sse2);
H264_QPEL_FUNCS(3, 3, sse2);
}
#ifdef HAVE_SSSE3
if(mm_flags & MM_SSSE3){
H264_QPEL_FUNCS(1, 0, ssse3);
H264_QPEL_FUNCS(1, 1, ssse3);
H264_QPEL_FUNCS(1, 2, ssse3);
H264_QPEL_FUNCS(1, 3, ssse3);
H264_QPEL_FUNCS(2, 0, ssse3);
H264_QPEL_FUNCS(2, 1, ssse3);
H264_QPEL_FUNCS(2, 2, ssse3);
H264_QPEL_FUNCS(2, 3, ssse3);
H264_QPEL_FUNCS(3, 0, ssse3);
H264_QPEL_FUNCS(3, 1, ssse3);
H264_QPEL_FUNCS(3, 2, ssse3);
H264_QPEL_FUNCS(3, 3, ssse3);
VAR_0->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_nornd;
VAR_0->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd;
VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd;
VAR_0->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3;
VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3;
VAR_0->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;
}
#endif
#ifdef CONFIG_SNOW_DECODER
if(mm_flags & MM_SSE2 & 0){
VAR_0->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
#ifdef HAVE_7REGS
VAR_0->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
#endif
VAR_0->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
}
else{
if(mm_flags & MM_MMXEXT){
VAR_0->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;
#ifdef HAVE_7REGS
VAR_0->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
#endif
}
VAR_0->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
}
#endif
if(mm_flags & MM_3DNOW){
VAR_0->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
VAR_0->vector_fmul = vector_fmul_3dnow;
if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){
VAR_0->float_to_int16 = float_to_int16_3dnow;
VAR_0->float_to_int16_interleave = float_to_int16_interleave_3dnow;
}
}
if(mm_flags & MM_3DNOWEXT){
VAR_0->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
VAR_0->vector_fmul_window = vector_fmul_window_3dnow2;
if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){
VAR_0->float_to_int16_interleave = float_to_int16_interleave_3dn2;
}
}
if(mm_flags & MM_SSE){
VAR_0->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;
VAR_0->ac3_downmix = ac3_downmix_sse;
VAR_0->vector_fmul = vector_fmul_sse;
VAR_0->vector_fmul_reverse = vector_fmul_reverse_sse;
VAR_0->vector_fmul_add_add = vector_fmul_add_add_sse;
VAR_0->vector_fmul_window = vector_fmul_window_sse;
VAR_0->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
VAR_0->float_to_int16 = float_to_int16_sse;
VAR_0->float_to_int16_interleave = float_to_int16_interleave_sse;
}
if(mm_flags & MM_3DNOW)
VAR_0->vector_fmul_add_add = vector_fmul_add_add_3dnow;
if(mm_flags & MM_SSE2){
VAR_0->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
VAR_0->float_to_int16 = float_to_int16_sse2;
VAR_0->float_to_int16_interleave = float_to_int16_interleave_sse2;
VAR_0->add_int16 = add_int16_sse2;
VAR_0->sub_int16 = sub_int16_sse2;
VAR_0->scalarproduct_int16 = scalarproduct_int16_sse2;
}
}
if (ENABLE_ENCODERS)
dsputilenc_init_mmx(VAR_0, VAR_1);
#if 0
get_pixels = just_return;
put_pixels_clamped = just_return;
add_pixels_clamped = just_return;
pix_abs16x16 = just_return;
pix_abs16x16_x2 = just_return;
pix_abs16x16_y2 = just_return;
pix_abs16x16_xy2 = just_return;
put_pixels_tab[0] = just_return;
put_pixels_tab[1] = just_return;
put_pixels_tab[2] = just_return;
put_pixels_tab[3] = just_return;
put_no_rnd_pixels_tab[0] = just_return;
put_no_rnd_pixels_tab[1] = just_return;
put_no_rnd_pixels_tab[2] = just_return;
put_no_rnd_pixels_tab[3] = just_return;
avg_pixels_tab[0] = just_return;
avg_pixels_tab[1] = just_return;
avg_pixels_tab[2] = just_return;
avg_pixels_tab[3] = just_return;
avg_no_rnd_pixels_tab[0] = just_return;
avg_no_rnd_pixels_tab[1] = just_return;
avg_no_rnd_pixels_tab[2] = just_return;
avg_no_rnd_pixels_tab[3] = just_return;
#endif
}
| [
"void FUNC_0(DSPContext* VAR_0, AVCodecContext *VAR_1)\n{",
"mm_flags = mm_support();",
"if (VAR_1->dsp_mask) {",
"if (VAR_1->dsp_mask & FF_MM_FORCE)\nmm_flags |= (VAR_1->dsp_mask & 0xffff);",
"else\nmm_flags &= ~(VAR_1->dsp_mask & 0xffff);",
"}",
"#if 0\nav_log(VAR_1, AV_LOG_INFO, \"libavcodec: CPU flags:\");",
"if (mm_flags & MM_MMX)\nav_log(VAR_1, AV_LOG_INFO, \" mmx\");",
"if (mm_flags & MM_MMXEXT)\nav_log(VAR_1, AV_LOG_INFO, \" mmxext\");",
"if (mm_flags & MM_3DNOW)\nav_log(VAR_1, AV_LOG_INFO, \" 3dnow\");",
"if (mm_flags & MM_SSE)\nav_log(VAR_1, AV_LOG_INFO, \" sse\");",
"if (mm_flags & MM_SSE2)\nav_log(VAR_1, AV_LOG_INFO, \" sse2\");",
"av_log(VAR_1, AV_LOG_INFO, \"\\n\");",
"#endif\nif (mm_flags & MM_MMX) {",
"const int VAR_2= VAR_1->VAR_2;",
"if(VAR_1->lowres==0){",
"if(VAR_2==FF_IDCT_AUTO || VAR_2==FF_IDCT_SIMPLEMMX){",
"VAR_0->idct_put= ff_simple_idct_put_mmx;",
"VAR_0->idct_add= ff_simple_idct_add_mmx;",
"VAR_0->idct = ff_simple_idct_mmx;",
"VAR_0->idct_permutation_type= FF_SIMPLE_IDCT_PERM;",
"#ifdef CONFIG_GPL\n}else if(VAR_2==FF_IDCT_LIBMPEG2MMX){",
"if(mm_flags & MM_MMXEXT){",
"VAR_0->idct_put= ff_libmpeg2mmx2_idct_put;",
"VAR_0->idct_add= ff_libmpeg2mmx2_idct_add;",
"VAR_0->idct = ff_mmxext_idct;",
"}else{",
"VAR_0->idct_put= ff_libmpeg2mmx_idct_put;",
"VAR_0->idct_add= ff_libmpeg2mmx_idct_add;",
"VAR_0->idct = ff_mmx_idct;",
"}",
"VAR_0->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;",
"#endif\n}else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER) &&",
"VAR_2==FF_IDCT_VP3){",
"if(mm_flags & MM_SSE2){",
"VAR_0->idct_put= ff_vp3_idct_put_sse2;",
"VAR_0->idct_add= ff_vp3_idct_add_sse2;",
"VAR_0->idct = ff_vp3_idct_sse2;",
"VAR_0->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;",
"}else{",
"VAR_0->idct_put= ff_vp3_idct_put_mmx;",
"VAR_0->idct_add= ff_vp3_idct_add_mmx;",
"VAR_0->idct = ff_vp3_idct_mmx;",
"VAR_0->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;",
"}",
"}else if(VAR_2==FF_IDCT_CAVS){",
"VAR_0->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;",
"}else if(VAR_2==FF_IDCT_XVIDMMX){",
"if(mm_flags & MM_SSE2){",
"VAR_0->idct_put= ff_idct_xvid_sse2_put;",
"VAR_0->idct_add= ff_idct_xvid_sse2_add;",
"VAR_0->idct = ff_idct_xvid_sse2;",
"VAR_0->idct_permutation_type= FF_SSE2_IDCT_PERM;",
"}else if(mm_flags & MM_MMXEXT){",
"VAR_0->idct_put= ff_idct_xvid_mmx2_put;",
"VAR_0->idct_add= ff_idct_xvid_mmx2_add;",
"VAR_0->idct = ff_idct_xvid_mmx2;",
"}else{",
"VAR_0->idct_put= ff_idct_xvid_mmx_put;",
"VAR_0->idct_add= ff_idct_xvid_mmx_add;",
"VAR_0->idct = ff_idct_xvid_mmx;",
"}",
"}",
"}",
"VAR_0->put_pixels_clamped = put_pixels_clamped_mmx;",
"VAR_0->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;",
"VAR_0->add_pixels_clamped = add_pixels_clamped_mmx;",
"VAR_0->clear_blocks = clear_blocks_mmx;",
"#define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \\\nVAR_0->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU\nSET_HPEL_FUNCS(put, 0, 16, mmx);",
"SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);",
"SET_HPEL_FUNCS(avg, 0, 16, mmx);",
"SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx);",
"SET_HPEL_FUNCS(put, 1, 8, mmx);",
"SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx);",
"SET_HPEL_FUNCS(avg, 1, 8, mmx);",
"SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx);",
"VAR_0->gmc= gmc_mmx;",
"VAR_0->add_bytes= add_bytes_mmx;",
"VAR_0->add_bytes_l2= add_bytes_l2_mmx;",
"VAR_0->draw_edges = draw_edges_mmx;",
"if (ENABLE_ANY_H263) {",
"VAR_0->h263_v_loop_filter= h263_v_loop_filter_mmx;",
"VAR_0->h263_h_loop_filter= h263_h_loop_filter_mmx;",
"}",
"if ((ENABLE_VP3_DECODER || ENABLE_THEORA_DECODER) &&\n!(VAR_1->flags & CODEC_FLAG_BITEXACT)) {",
"VAR_0->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx;",
"VAR_0->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx;",
"}",
"VAR_0->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;",
"VAR_0->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;",
"VAR_0->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_nornd;",
"VAR_0->h264_idct_dc_add=\nVAR_0->h264_idct_add= ff_h264_idct_add_mmx;",
"VAR_0->h264_idct8_dc_add=\nVAR_0->h264_idct8_add= ff_h264_idct8_add_mmx;",
"if (mm_flags & MM_SSE2)\nVAR_0->h264_idct8_add= ff_h264_idct8_add_sse2;",
"if (mm_flags & MM_MMXEXT) {",
"VAR_0->prefetch = prefetch_mmx2;",
"VAR_0->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;",
"VAR_0->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;",
"VAR_0->avg_pixels_tab[0][0] = avg_pixels16_mmx2;",
"VAR_0->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;",
"VAR_0->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;",
"VAR_0->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;",
"VAR_0->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;",
"VAR_0->avg_pixels_tab[1][0] = avg_pixels8_mmx2;",
"VAR_0->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;",
"VAR_0->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;",
"VAR_0->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;",
"VAR_0->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;",
"if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){",
"VAR_0->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;",
"VAR_0->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;",
"VAR_0->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;",
"VAR_0->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;",
"VAR_0->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;",
"VAR_0->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;",
"}",
"#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \\\nVAR_0->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \\",
"VAR_0->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU\nSET_QPEL_FUNCS(put_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);",
"SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2);",
"SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2);",
"SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2);",
"SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2);",
"VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;",
"VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;",
"VAR_0->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;",
"VAR_0->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;",
"VAR_0->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;",
"VAR_0->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;",
"VAR_0->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;",
"VAR_0->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;",
"VAR_0->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;",
"VAR_0->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;",
"VAR_0->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;",
"VAR_0->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;",
"VAR_0->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;",
"VAR_0->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;",
"VAR_0->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;",
"VAR_0->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;",
"VAR_0->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;",
"VAR_0->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;",
"VAR_0->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;",
"VAR_0->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;",
"VAR_0->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;",
"VAR_0->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;",
"VAR_0->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;",
"VAR_0->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;",
"VAR_0->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;",
"VAR_0->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;",
"VAR_0->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;",
"if (ENABLE_CAVS_DECODER)\nff_cavsdsp_init_mmx2(VAR_0, VAR_1);",
"if (ENABLE_VC1_DECODER || ENABLE_WMV3_DECODER)\nff_vc1dsp_init_mmx(VAR_0, VAR_1);",
"VAR_0->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;",
"} else if (mm_flags & MM_3DNOW) {",
"VAR_0->prefetch = prefetch_3dnow;",
"VAR_0->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;",
"VAR_0->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;",
"VAR_0->avg_pixels_tab[0][0] = avg_pixels16_3dnow;",
"VAR_0->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;",
"VAR_0->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;",
"VAR_0->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;",
"VAR_0->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;",
"VAR_0->avg_pixels_tab[1][0] = avg_pixels8_3dnow;",
"VAR_0->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;",
"VAR_0->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;",
"if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){",
"VAR_0->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;",
"VAR_0->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;",
"VAR_0->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;",
"VAR_0->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;",
"VAR_0->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;",
"VAR_0->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;",
"}",
"SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);",
"SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow);",
"SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow);",
"SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow);",
"SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);",
"VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;",
"VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;",
"if (ENABLE_CAVS_DECODER)\nff_cavsdsp_init_3dnow(VAR_0, VAR_1);",
"}",
"#define H264_QPEL_FUNCS(x, y, CPU)\\\nVAR_0->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\\",
"VAR_0->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\\",
"VAR_0->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\\",
"VAR_0->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;",
"if((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)){",
"H264_QPEL_FUNCS(0, 0, sse2);",
"}",
"if(mm_flags & MM_SSE2){",
"H264_QPEL_FUNCS(0, 1, sse2);",
"H264_QPEL_FUNCS(0, 2, sse2);",
"H264_QPEL_FUNCS(0, 3, sse2);",
"H264_QPEL_FUNCS(1, 1, sse2);",
"H264_QPEL_FUNCS(1, 2, sse2);",
"H264_QPEL_FUNCS(1, 3, sse2);",
"H264_QPEL_FUNCS(2, 1, sse2);",
"H264_QPEL_FUNCS(2, 2, sse2);",
"H264_QPEL_FUNCS(2, 3, sse2);",
"H264_QPEL_FUNCS(3, 1, sse2);",
"H264_QPEL_FUNCS(3, 2, sse2);",
"H264_QPEL_FUNCS(3, 3, sse2);",
"}",
"#ifdef HAVE_SSSE3\nif(mm_flags & MM_SSSE3){",
"H264_QPEL_FUNCS(1, 0, ssse3);",
"H264_QPEL_FUNCS(1, 1, ssse3);",
"H264_QPEL_FUNCS(1, 2, ssse3);",
"H264_QPEL_FUNCS(1, 3, ssse3);",
"H264_QPEL_FUNCS(2, 0, ssse3);",
"H264_QPEL_FUNCS(2, 1, ssse3);",
"H264_QPEL_FUNCS(2, 2, ssse3);",
"H264_QPEL_FUNCS(2, 3, ssse3);",
"H264_QPEL_FUNCS(3, 0, ssse3);",
"H264_QPEL_FUNCS(3, 1, ssse3);",
"H264_QPEL_FUNCS(3, 2, ssse3);",
"H264_QPEL_FUNCS(3, 3, ssse3);",
"VAR_0->put_no_rnd_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_nornd;",
"VAR_0->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd;",
"VAR_0->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd;",
"VAR_0->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3;",
"VAR_0->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3;",
"VAR_0->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;",
"}",
"#endif\n#ifdef CONFIG_SNOW_DECODER\nif(mm_flags & MM_SSE2 & 0){",
"VAR_0->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;",
"#ifdef HAVE_7REGS\nVAR_0->vertical_compose97i = ff_snow_vertical_compose97i_sse2;",
"#endif\nVAR_0->inner_add_yblock = ff_snow_inner_add_yblock_sse2;",
"}",
"else{",
"if(mm_flags & MM_MMXEXT){",
"VAR_0->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;",
"#ifdef HAVE_7REGS\nVAR_0->vertical_compose97i = ff_snow_vertical_compose97i_mmx;",
"#endif\n}",
"VAR_0->inner_add_yblock = ff_snow_inner_add_yblock_mmx;",
"}",
"#endif\nif(mm_flags & MM_3DNOW){",
"VAR_0->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;",
"VAR_0->vector_fmul = vector_fmul_3dnow;",
"if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){",
"VAR_0->float_to_int16 = float_to_int16_3dnow;",
"VAR_0->float_to_int16_interleave = float_to_int16_interleave_3dnow;",
"}",
"}",
"if(mm_flags & MM_3DNOWEXT){",
"VAR_0->vector_fmul_reverse = vector_fmul_reverse_3dnow2;",
"VAR_0->vector_fmul_window = vector_fmul_window_3dnow2;",
"if(!(VAR_1->flags & CODEC_FLAG_BITEXACT)){",
"VAR_0->float_to_int16_interleave = float_to_int16_interleave_3dn2;",
"}",
"}",
"if(mm_flags & MM_SSE){",
"VAR_0->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;",
"VAR_0->ac3_downmix = ac3_downmix_sse;",
"VAR_0->vector_fmul = vector_fmul_sse;",
"VAR_0->vector_fmul_reverse = vector_fmul_reverse_sse;",
"VAR_0->vector_fmul_add_add = vector_fmul_add_add_sse;",
"VAR_0->vector_fmul_window = vector_fmul_window_sse;",
"VAR_0->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;",
"VAR_0->float_to_int16 = float_to_int16_sse;",
"VAR_0->float_to_int16_interleave = float_to_int16_interleave_sse;",
"}",
"if(mm_flags & MM_3DNOW)\nVAR_0->vector_fmul_add_add = vector_fmul_add_add_3dnow;",
"if(mm_flags & MM_SSE2){",
"VAR_0->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;",
"VAR_0->float_to_int16 = float_to_int16_sse2;",
"VAR_0->float_to_int16_interleave = float_to_int16_interleave_sse2;",
"VAR_0->add_int16 = add_int16_sse2;",
"VAR_0->sub_int16 = sub_int16_sse2;",
"VAR_0->scalarproduct_int16 = scalarproduct_int16_sse2;",
"}",
"}",
"if (ENABLE_ENCODERS)\ndsputilenc_init_mmx(VAR_0, VAR_1);",
"#if 0\nget_pixels = just_return;",
"put_pixels_clamped = just_return;",
"add_pixels_clamped = just_return;",
"pix_abs16x16 = just_return;",
"pix_abs16x16_x2 = just_return;",
"pix_abs16x16_y2 = just_return;",
"pix_abs16x16_xy2 = just_return;",
"put_pixels_tab[0] = just_return;",
"put_pixels_tab[1] = just_return;",
"put_pixels_tab[2] = just_return;",
"put_pixels_tab[3] = just_return;",
"put_no_rnd_pixels_tab[0] = just_return;",
"put_no_rnd_pixels_tab[1] = just_return;",
"put_no_rnd_pixels_tab[2] = just_return;",
"put_no_rnd_pixels_tab[3] = just_return;",
"avg_pixels_tab[0] = just_return;",
"avg_pixels_tab[1] = just_return;",
"avg_pixels_tab[2] = just_return;",
"avg_pixels_tab[3] = just_return;",
"avg_no_rnd_pixels_tab[0] = just_return;",
"avg_no_rnd_pixels_tab[1] = just_return;",
"avg_no_rnd_pixels_tab[2] = just_return;",
"avg_no_rnd_pixels_tab[3] = just_return;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173,
175
],
[
177
],
[
179
],
[
181,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
207
],
[
209
],
[
213
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
243,
245
],
[
247,
249
],
[
251,
253
],
[
257
],
[
259
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
277
],
[
279
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315,
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
449,
451
],
[
455,
457
],
[
461
],
[
463
],
[
465
],
[
469
],
[
471
],
[
475
],
[
477
],
[
479
],
[
483
],
[
485
],
[
489
],
[
491
],
[
493
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
515
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
543
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555
],
[
559,
561
],
[
563
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623,
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
637
],
[
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665,
669,
671
],
[
673
],
[
675,
677
],
[
679,
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
691,
693
],
[
695,
697
],
[
699
],
[
701
],
[
703,
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743
],
[
745
],
[
747
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757
],
[
759,
761
],
[
763
],
[
765
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
779
],
[
783,
785
],
[
789,
793
],
[
795
],
[
797
],
[
801
],
[
803
],
[
805
],
[
807
],
[
811
],
[
813
],
[
815
],
[
817
],
[
821
],
[
823
],
[
825
],
[
827
],
[
831
],
[
833
],
[
835
],
[
837
],
[
841
],
[
843
],
[
845
],
[
847
],
[
855,
857
]
] |
25,723 | static void iscsi_retry_timer_expired(void *opaque)
{
struct IscsiTask *iTask = opaque;
iTask->complete = 1;
if (iTask->co) {
qemu_coroutine_enter(iTask->co, NULL);
}
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static void iscsi_retry_timer_expired(void *opaque)
{
struct IscsiTask *iTask = opaque;
iTask->complete = 1;
if (iTask->co) {
qemu_coroutine_enter(iTask->co, NULL);
}
}
| {
"code": [
" qemu_coroutine_enter(iTask->co, NULL);"
],
"line_no": [
11
]
} | static void FUNC_0(void *VAR_0)
{
struct IscsiTask *VAR_1 = VAR_0;
VAR_1->complete = 1;
if (VAR_1->co) {
qemu_coroutine_enter(VAR_1->co, NULL);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct IscsiTask *VAR_1 = VAR_0;",
"VAR_1->complete = 1;",
"if (VAR_1->co) {",
"qemu_coroutine_enter(VAR_1->co, NULL);",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,725 | int qemu_shutdown_requested_get(void)
{
return shutdown_requested;
}
| true | qemu | aedbe19297907143f17b733a7ff0e0534377bed1 | int qemu_shutdown_requested_get(void)
{
return shutdown_requested;
}
| {
"code": [
"int qemu_shutdown_requested_get(void)"
],
"line_no": [
1
]
} | int FUNC_0(void)
{
return shutdown_requested;
}
| [
"int FUNC_0(void)\n{",
"return shutdown_requested;",
"}"
] | [
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,727 | static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int i;
for(i=0; i<width; i++)
{
int d= ((uint16_t*)src)[i];
int r= d&0x1F;
int g= (d>>5)&0x1F;
int b= (d>>10)&0x1F;
dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| true | FFmpeg | 2da0d70d5eebe42f9fcd27ee554419ebe2a5da06 | static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int i;
for(i=0; i<width; i++)
{
int d= ((uint16_t*)src)[i];
int r= d&0x1F;
int g= (d>>5)&0x1F;
int b= (d>>10)&0x1F;
dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| {
"code": [
"\tint i;",
"\tint i;",
"\tint 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;",
"\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++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint g= (d>>5)&0x1F;",
"\t\tdst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"\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;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint r= d&0x1F;",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\tint i;",
"\tfor(i=0; i<width; i++)",
"\t\tint d= ((uint16_t*)src)[i];",
"\t\tint r= d&0x1F;",
"\t\tint g= (d>>5)&0x1F;",
"\t\tint b= (d>>10)&0x1F;",
"\t\tdst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"\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;",
"\tint i;",
"\tint i;",
"\tint i;",
"\tint i;"
],
"line_no": [
5,
5,
5,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
11,
5,
7,
5,
7,
11,
15,
21,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
5,
7,
11,
13,
5,
7,
5,
7,
11,
13,
15,
17,
21,
5,
7,
5,
7,
5,
7,
5,
5,
5,
5,
5
]
} | static inline void FUNC_0(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)
{
int VAR_0;
for(VAR_0=0; VAR_0<width; VAR_0++)
{
int d= ((uint16_t*)src)[VAR_0];
int r= d&0x1F;
int g= (d>>5)&0x1F;
int b= (d>>10)&0x1F;
dst[VAR_0]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;
}
}
| [
"static inline void FUNC_0(rgb15ToY)(uint8_t *dst, uint8_t *src, int width)\n{",
"int VAR_0;",
"for(VAR_0=0; VAR_0<width; VAR_0++)",
"{",
"int d= ((uint16_t*)src)[VAR_0];",
"int r= d&0x1F;",
"int g= (d>>5)&0x1F;",
"int b= (d>>10)&0x1F;",
"dst[VAR_0]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16;",
"}",
"}"
] | [
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
]
] |
25,728 | static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, target_phys_addr_t end_addr,
unsigned flags,
unsigned mask)
{
KVMState *s = kvm_state;
KVMSlot *mem = kvm_lookup_slot(s, phys_addr);
if (mem == NULL) {
dprintf("invalid parameters %llx-%llx\n", phys_addr, end_addr);
return -EINVAL;
}
flags = (mem->flags & ~mask) | flags;
/* Nothing changed, no need to issue ioctl */
if (flags == mem->flags)
return 0;
mem->flags = flags;
return kvm_set_user_memory_region(s, mem);
}
| true | qemu | d3f8d37fe2d0c24ec8bac9c94d5b0e2dc09c0d2a | static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, target_phys_addr_t end_addr,
unsigned flags,
unsigned mask)
{
KVMState *s = kvm_state;
KVMSlot *mem = kvm_lookup_slot(s, phys_addr);
if (mem == NULL) {
dprintf("invalid parameters %llx-%llx\n", phys_addr, end_addr);
return -EINVAL;
}
flags = (mem->flags & ~mask) | flags;
if (flags == mem->flags)
return 0;
mem->flags = flags;
return kvm_set_user_memory_region(s, mem);
}
| {
"code": [
"static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, target_phys_addr_t end_addr,",
" unsigned flags,",
" KVMSlot *mem = kvm_lookup_slot(s, phys_addr);",
" dprintf(\"invalid parameters %llx-%llx\\n\", phys_addr, end_addr);"
],
"line_no": [
1,
3,
11,
15
]
} | static int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1,
unsigned VAR_2,
unsigned VAR_3)
{
KVMState *s = kvm_state;
KVMSlot *mem = kvm_lookup_slot(s, VAR_0);
if (mem == NULL) {
dprintf("invalid parameters %llx-%llx\n", VAR_0, VAR_1);
return -EINVAL;
}
VAR_2 = (mem->VAR_2 & ~VAR_3) | VAR_2;
if (VAR_2 == mem->VAR_2)
return 0;
mem->VAR_2 = VAR_2;
return kvm_set_user_memory_region(s, mem);
}
| [
"static int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1,\nunsigned VAR_2,\nunsigned VAR_3)\n{",
"KVMState *s = kvm_state;",
"KVMSlot *mem = kvm_lookup_slot(s, VAR_0);",
"if (mem == NULL) {",
"dprintf(\"invalid parameters %llx-%llx\\n\", VAR_0, VAR_1);",
"return -EINVAL;",
"}",
"VAR_2 = (mem->VAR_2 & ~VAR_3) | VAR_2;",
"if (VAR_2 == mem->VAR_2)\nreturn 0;",
"mem->VAR_2 = VAR_2;",
"return kvm_set_user_memory_region(s, mem);",
"}"
] | [
1,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27,
29
],
[
33
],
[
37
],
[
39
]
] |
25,730 | static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-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;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long y;
const long chromWidth= -((-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;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
long width, long height,
long lumStride, long chromStride, long srcStride)
{
long VAR_0;
const long VAR_1= -((-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;
}
#if COMPILE_TEMPLATE_MMX
__asm__(
EMMS" \n\t"
SFENCE" \n\t"
::: "memory"
);
#endif
}
| [
"static void FUNC_0(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,\nlong width, long height,\nlong lumStride, long chromStride, long srcStride)\n{",
"long VAR_0;",
"const long VAR_1= -((-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;",
"}",
"#if COMPILE_TEMPLATE_MMX\n__asm__(\nEMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n::: \"memory\"\n);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39,
41,
43,
45,
47
],
[
49,
51
]
] |
25,731 | static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const uint8_t *srcPtr= src[0];
uint8_t *dstY= dst[0];
uint8_t *dstU= dst[1];
uint8_t *dstV= dst[2];
int i;
void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
switch(c->srcFormat) {
#define CASE(pixfmt, prefix) \
case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
interpolate = bayer_##prefix##_to_yv12_interpolate; \
break;
CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
#undef CASE
default: return 0;
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
for (i = 2; i < srcSliceH - 2; i += 2) {
interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
return srcSliceH;
}
| false | FFmpeg | 757248ea3cd917a7755cb15f817a9b1f15578718 | static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
const uint8_t *srcPtr= src[0];
uint8_t *dstY= dst[0];
uint8_t *dstU= dst[1];
uint8_t *dstV= dst[2];
int i;
void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
switch(c->srcFormat) {
#define CASE(pixfmt, prefix) \
case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
interpolate = bayer_##prefix##_to_yv12_interpolate; \
break;
CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
#undef CASE
default: return 0;
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
for (i = 2; i < srcSliceH - 2; i += 2) {
interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
srcPtr += 2 * srcStride[0];
dstY += 2 * dstStride[0];
dstU += dstStride[1];
dstV += dstStride[1];
}
copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
return srcSliceH;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_18[], int VAR_2[], int VAR_3,
int VAR_4, uint8_t* VAR_5[], int VAR_6[])
{
const uint8_t *VAR_7= VAR_18[0];
uint8_t *VAR_18= VAR_5[0];
uint8_t *VAR_18= VAR_5[1];
uint8_t *VAR_18= VAR_5[2];
int VAR_8;
void (*VAR_9) (const uint8_t *VAR_18, int VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, int VAR_18, int VAR_18, int32_t *VAR_18);
void (*VAR_17)(const uint8_t *VAR_18, int VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, int VAR_18, int VAR_18, int32_t *VAR_18);
switch(VAR_0->srcFormat) {
#define CASE(pixfmt, prefix) \
case pixfmt: VAR_9 = bayer_##prefix##_to_yv12_copy; \
VAR_17 = bayer_##prefix##_to_yv12_interpolate; \
break;
CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)
CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)
CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)
CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)
CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
#undef CASE
default: return 0;
}
VAR_9(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);
VAR_7 += 2 * VAR_2[0];
VAR_18 += 2 * VAR_6[0];
VAR_18 += VAR_6[1];
VAR_18 += VAR_6[1];
for (VAR_8 = 2; VAR_8 < VAR_4 - 2; VAR_8 += 2) {
VAR_17(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);
VAR_7 += 2 * VAR_2[0];
VAR_18 += 2 * VAR_6[0];
VAR_18 += VAR_6[1];
VAR_18 += VAR_6[1];
}
VAR_9(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);
return VAR_4;
}
| [
"static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_18[], int VAR_2[], int VAR_3,\nint VAR_4, uint8_t* VAR_5[], int VAR_6[])\n{",
"const uint8_t *VAR_7= VAR_18[0];",
"uint8_t *VAR_18= VAR_5[0];",
"uint8_t *VAR_18= VAR_5[1];",
"uint8_t *VAR_18= VAR_5[2];",
"int VAR_8;",
"void (*VAR_9) (const uint8_t *VAR_18, int VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, int VAR_18, int VAR_18, int32_t *VAR_18);",
"void (*VAR_17)(const uint8_t *VAR_18, int VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, uint8_t *VAR_18, int VAR_18, int VAR_18, int32_t *VAR_18);",
"switch(VAR_0->srcFormat) {",
"#define CASE(pixfmt, prefix) \\\ncase pixfmt: VAR_9 = bayer_##prefix##_to_yv12_copy; \\",
"VAR_17 = bayer_##prefix##_to_yv12_interpolate; \\",
"break;",
"CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8)\nCASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)\nCASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)\nCASE(AV_PIX_FMT_BAYER_RGGB8, rggb8)\nCASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)\nCASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)\nCASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8)\nCASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)\nCASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)\nCASE(AV_PIX_FMT_BAYER_GRBG8, grbg8)\nCASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)\nCASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)\n#undef CASE\ndefault: return 0;",
"}",
"VAR_9(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);",
"VAR_7 += 2 * VAR_2[0];",
"VAR_18 += 2 * VAR_6[0];",
"VAR_18 += VAR_6[1];",
"VAR_18 += VAR_6[1];",
"for (VAR_8 = 2; VAR_8 < VAR_4 - 2; VAR_8 += 2) {",
"VAR_17(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);",
"VAR_7 += 2 * VAR_2[0];",
"VAR_18 += 2 * VAR_6[0];",
"VAR_18 += VAR_6[1];",
"VAR_18 += VAR_6[1];",
"}",
"VAR_9(VAR_7, VAR_2[0], VAR_18, VAR_18, VAR_18, VAR_6[0], VAR_0->srcW, VAR_0->input_rgb2yuv_table);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
]
] |
25,733 | static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
int i;
if (pic->type == PICTURE_TYPE_IDR) {
av_assert0(pic->display_order == pic->encode_order);
vpic->frame_num = 0;
priv->next_frame_num = 1;
priv->cpb_delay = 0;
} else {
vpic->frame_num = priv->next_frame_num;
if (pic->type != PICTURE_TYPE_B) {
// nal_ref_idc != 0
++priv->next_frame_num;
}
++priv->cpb_delay;
}
priv->dpb_delay = pic->display_order - pic->encode_order + 1;
vpic->frame_num = vpic->frame_num &
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);
vpic->CurrPic.picture_id = pic->recon_surface;
vpic->CurrPic.frame_idx = vpic->frame_num;
vpic->CurrPic.flags = 0;
vpic->CurrPic.TopFieldOrderCnt = pic->display_order;
vpic->CurrPic.BottomFieldOrderCnt = pic->display_order;
for (i = 0; i < pic->nb_refs; i++) {
VAAPIEncodePicture *ref = pic->refs[i];
av_assert0(ref && ref->encode_order < pic->encode_order);
vpic->ReferenceFrames[i].picture_id = ref->recon_surface;
vpic->ReferenceFrames[i].frame_idx = ref->encode_order;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order;
vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order;
}
for (; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) {
vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
}
vpic->coded_buf = pic->output_buffer;
vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR);
vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B);
pic->nb_slices = 1;
return 0;
}
| false | FFmpeg | e72662e131e5099e34d5a7519c5690d2fff7b83f | static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
VAAPIEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
int i;
if (pic->type == PICTURE_TYPE_IDR) {
av_assert0(pic->display_order == pic->encode_order);
vpic->frame_num = 0;
priv->next_frame_num = 1;
priv->cpb_delay = 0;
} else {
vpic->frame_num = priv->next_frame_num;
if (pic->type != PICTURE_TYPE_B) {
++priv->next_frame_num;
}
++priv->cpb_delay;
}
priv->dpb_delay = pic->display_order - pic->encode_order + 1;
vpic->frame_num = vpic->frame_num &
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);
vpic->CurrPic.picture_id = pic->recon_surface;
vpic->CurrPic.frame_idx = vpic->frame_num;
vpic->CurrPic.flags = 0;
vpic->CurrPic.TopFieldOrderCnt = pic->display_order;
vpic->CurrPic.BottomFieldOrderCnt = pic->display_order;
for (i = 0; i < pic->nb_refs; i++) {
VAAPIEncodePicture *ref = pic->refs[i];
av_assert0(ref && ref->encode_order < pic->encode_order);
vpic->ReferenceFrames[i].picture_id = ref->recon_surface;
vpic->ReferenceFrames[i].frame_idx = ref->encode_order;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order;
vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order;
}
for (; i < FF_ARRAY_ELEMS(vpic->ReferenceFrames); i++) {
vpic->ReferenceFrames[i].picture_id = VA_INVALID_ID;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
}
vpic->coded_buf = pic->output_buffer;
vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR);
vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B);
pic->nb_slices = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
VAAPIEncodePicture *VAR_1)
{
VAAPIEncodeContext *ctx = VAR_0->priv_data;
VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params;
VAAPIEncodeH264Context *priv = ctx->priv_data;
int VAR_2;
if (VAR_1->type == PICTURE_TYPE_IDR) {
av_assert0(VAR_1->display_order == VAR_1->encode_order);
vpic->frame_num = 0;
priv->next_frame_num = 1;
priv->cpb_delay = 0;
} else {
vpic->frame_num = priv->next_frame_num;
if (VAR_1->type != PICTURE_TYPE_B) {
++priv->next_frame_num;
}
++priv->cpb_delay;
}
priv->dpb_delay = VAR_1->display_order - VAR_1->encode_order + 1;
vpic->frame_num = vpic->frame_num &
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);
vpic->CurrPic.picture_id = VAR_1->recon_surface;
vpic->CurrPic.frame_idx = vpic->frame_num;
vpic->CurrPic.flags = 0;
vpic->CurrPic.TopFieldOrderCnt = VAR_1->display_order;
vpic->CurrPic.BottomFieldOrderCnt = VAR_1->display_order;
for (VAR_2 = 0; VAR_2 < VAR_1->nb_refs; VAR_2++) {
VAAPIEncodePicture *ref = VAR_1->refs[VAR_2];
av_assert0(ref && ref->encode_order < VAR_1->encode_order);
vpic->ReferenceFrames[VAR_2].picture_id = ref->recon_surface;
vpic->ReferenceFrames[VAR_2].frame_idx = ref->encode_order;
vpic->ReferenceFrames[VAR_2].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
vpic->ReferenceFrames[VAR_2].TopFieldOrderCnt = ref->display_order;
vpic->ReferenceFrames[VAR_2].BottomFieldOrderCnt = ref->display_order;
}
for (; VAR_2 < FF_ARRAY_ELEMS(vpic->ReferenceFrames); VAR_2++) {
vpic->ReferenceFrames[VAR_2].picture_id = VA_INVALID_ID;
vpic->ReferenceFrames[VAR_2].flags = VA_PICTURE_H264_INVALID;
}
vpic->coded_buf = VAR_1->output_buffer;
vpic->pic_fields.bits.idr_pic_flag = (VAR_1->type == PICTURE_TYPE_IDR);
vpic->pic_fields.bits.reference_pic_flag = (VAR_1->type != PICTURE_TYPE_B);
VAR_1->nb_slices = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nVAAPIEncodePicture *VAR_1)\n{",
"VAAPIEncodeContext *ctx = VAR_0->priv_data;",
"VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;",
"VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params;",
"VAAPIEncodeH264Context *priv = ctx->priv_data;",
"int VAR_2;",
"if (VAR_1->type == PICTURE_TYPE_IDR) {",
"av_assert0(VAR_1->display_order == VAR_1->encode_order);",
"vpic->frame_num = 0;",
"priv->next_frame_num = 1;",
"priv->cpb_delay = 0;",
"} else {",
"vpic->frame_num = priv->next_frame_num;",
"if (VAR_1->type != PICTURE_TYPE_B) {",
"++priv->next_frame_num;",
"}",
"++priv->cpb_delay;",
"}",
"priv->dpb_delay = VAR_1->display_order - VAR_1->encode_order + 1;",
"vpic->frame_num = vpic->frame_num &\n((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);",
"vpic->CurrPic.picture_id = VAR_1->recon_surface;",
"vpic->CurrPic.frame_idx = vpic->frame_num;",
"vpic->CurrPic.flags = 0;",
"vpic->CurrPic.TopFieldOrderCnt = VAR_1->display_order;",
"vpic->CurrPic.BottomFieldOrderCnt = VAR_1->display_order;",
"for (VAR_2 = 0; VAR_2 < VAR_1->nb_refs; VAR_2++) {",
"VAAPIEncodePicture *ref = VAR_1->refs[VAR_2];",
"av_assert0(ref && ref->encode_order < VAR_1->encode_order);",
"vpic->ReferenceFrames[VAR_2].picture_id = ref->recon_surface;",
"vpic->ReferenceFrames[VAR_2].frame_idx = ref->encode_order;",
"vpic->ReferenceFrames[VAR_2].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;",
"vpic->ReferenceFrames[VAR_2].TopFieldOrderCnt = ref->display_order;",
"vpic->ReferenceFrames[VAR_2].BottomFieldOrderCnt = ref->display_order;",
"}",
"for (; VAR_2 < FF_ARRAY_ELEMS(vpic->ReferenceFrames); VAR_2++) {",
"vpic->ReferenceFrames[VAR_2].picture_id = VA_INVALID_ID;",
"vpic->ReferenceFrames[VAR_2].flags = VA_PICTURE_H264_INVALID;",
"}",
"vpic->coded_buf = VAR_1->output_buffer;",
"vpic->pic_fields.bits.idr_pic_flag = (VAR_1->type == PICTURE_TYPE_IDR);",
"vpic->pic_fields.bits.reference_pic_flag = (VAR_1->type != PICTURE_TYPE_B);",
"VAR_1->nb_slices = 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
99
],
[
101
],
[
105
],
[
109
],
[
111
]
] |
25,735 | static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum)
{
uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
uint8_t bitmap;
if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
}
return !!(bitmap & (1 << (bitnum % 8)));
}
| true | qemu | b0ad5a455d7e5352d4c86ba945112011dbeadfb8 | static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum)
{
uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8;
uint8_t bitmap;
if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
}
return !!(bitmap & (1 << (bitnum % 8)));
}
| {
"code": [
" if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) !=",
"\t sizeof(bitmap)) {",
" return -errno;",
"\t sizeof(bitmap)) {",
" return -errno;",
" if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) !=",
"\t sizeof(bitmap)) {",
" return -errno;"
],
"line_no": [
11,
13,
15,
13,
15,
11,
13,
15
]
} | static inline int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)
{
uint64_t offset = sizeof(struct cow_header_v2) + VAR_1 / 8;
uint8_t bitmap;
if (bdrv_pread(VAR_0->file, offset, &bitmap, sizeof(bitmap)) !=
sizeof(bitmap)) {
return -errno;
}
return !!(bitmap & (1 << (VAR_1 % 8)));
}
| [
"static inline int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)\n{",
"uint64_t offset = sizeof(struct cow_header_v2) + VAR_1 / 8;",
"uint8_t bitmap;",
"if (bdrv_pread(VAR_0->file, offset, &bitmap, sizeof(bitmap)) !=\nsizeof(bitmap)) {",
"return -errno;",
"}",
"return !!(bitmap & (1 << (VAR_1 % 8)));",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
25,736 | bool st_init(const char *file)
{
pthread_t thread;
pthread_attr_t attr;
sigset_t set, oldset;
int ret;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &oldset);
ret = pthread_create(&thread, &attr, writeout_thread, NULL);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (ret != 0) {
return false;
}
atexit(st_flush_trace_buffer);
st_set_trace_file(file);
return true;
}
| true | qemu | e4858974ec36afd8a6b3a9e2b0ad8f357f28efc7 | bool st_init(const char *file)
{
pthread_t thread;
pthread_attr_t attr;
sigset_t set, oldset;
int ret;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &oldset);
ret = pthread_create(&thread, &attr, writeout_thread, NULL);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (ret != 0) {
return false;
}
atexit(st_flush_trace_buffer);
st_set_trace_file(file);
return true;
}
| {
"code": [
"bool st_init(const char *file)",
" return false;",
" atexit(st_flush_trace_buffer);",
" st_set_trace_file(file);",
" return true;"
],
"line_no": [
1,
33,
39,
41,
43
]
} | bool FUNC_0(const char *file)
{
pthread_t thread;
pthread_attr_t attr;
sigset_t set, oldset;
int VAR_0;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &oldset);
VAR_0 = pthread_create(&thread, &attr, writeout_thread, NULL);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (VAR_0 != 0) {
return false;
}
atexit(st_flush_trace_buffer);
st_set_trace_file(file);
return true;
}
| [
"bool FUNC_0(const char *file)\n{",
"pthread_t thread;",
"pthread_attr_t attr;",
"sigset_t set, oldset;",
"int VAR_0;",
"pthread_attr_init(&attr);",
"pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);",
"sigfillset(&set);",
"pthread_sigmask(SIG_SETMASK, &set, &oldset);",
"VAR_0 = pthread_create(&thread, &attr, writeout_thread, NULL);",
"pthread_sigmask(SIG_SETMASK, &oldset, NULL);",
"if (VAR_0 != 0) {",
"return false;",
"}",
"atexit(st_flush_trace_buffer);",
"st_set_trace_file(file);",
"return true;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
25,739 | static int libquvi_close(AVFormatContext *s)
{
LibQuviContext *qc = s->priv_data;
if (qc->fmtctx)
avformat_close_input(&qc->fmtctx);
return 0;
}
| true | FFmpeg | 2d40a09b6e73230b160a505f01ed1acf169e1d9f | static int libquvi_close(AVFormatContext *s)
{
LibQuviContext *qc = s->priv_data;
if (qc->fmtctx)
avformat_close_input(&qc->fmtctx);
return 0;
}
| {
"code": [
"static int libquvi_close(AVFormatContext *s)",
" LibQuviContext *qc = s->priv_data;",
" if (qc->fmtctx)",
" avformat_close_input(&qc->fmtctx);",
" return 0;",
" LibQuviContext *qc = s->priv_data;",
" return 0;",
" LibQuviContext *qc = s->priv_data;",
" LibQuviContext *qc = s->priv_data;"
],
"line_no": [
1,
5,
7,
9,
11,
5,
11,
5,
5
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
LibQuviContext *qc = VAR_0->priv_data;
if (qc->fmtctx)
avformat_close_input(&qc->fmtctx);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"LibQuviContext *qc = VAR_0->priv_data;",
"if (qc->fmtctx)\navformat_close_input(&qc->fmtctx);",
"return 0;",
"}"
] | [
1,
1,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
]
] |
25,740 | static void aspeed_soc_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
sc->info = (AspeedSoCInfo *) data;
dc->realize = aspeed_soc_realize;
} | true | qemu | 469f3da42ef4af347fa7831e1cc0bd35d17f5b83 | static void aspeed_soc_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
sc->info = (AspeedSoCInfo *) data;
dc->realize = aspeed_soc_realize;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
AspeedSoCClass *sc = ASPEED_SOC_CLASS(VAR_0);
sc->info = (AspeedSoCInfo *) VAR_1;
dc->realize = aspeed_soc_realize;
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"AspeedSoCClass *sc = ASPEED_SOC_CLASS(VAR_0);",
"sc->info = (AspeedSoCInfo *) VAR_1;",
"dc->realize = aspeed_soc_realize;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
]
] |
25,742 | static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
AVStream avs[MAX_STREAMS];
int i;
avc = avformat_alloc_context();
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
inet_ntoa(stream->multicast_ip),
stream->multicast_port, stream->multicast_ttl);
} else {
snprintf(avc->filename, 1024, "rtp://0.0.0.0");
}
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
avf_sdp_create(&avc, 1, *pbuffer, 2048);
av_free(avc);
return strlen(*pbuffer);
} | true | FFmpeg | ea4f8aabab2a5a7ebd232b45557c11c4c59c332b | static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
AVStream avs[MAX_STREAMS];
int i;
avc = avformat_alloc_context();
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp:
inet_ntoa(stream->multicast_ip),
stream->multicast_port, stream->multicast_ttl);
} else {
snprintf(avc->filename, 1024, "rtp:
}
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
avf_sdp_create(&avc, 1, *pbuffer, 2048);
av_free(avc);
return strlen(*pbuffer);
} | {
"code": [],
"line_no": []
} | static int FUNC_0(FFStream *VAR_0, uint8_t **VAR_1,
struct in_addr VAR_2)
{
AVFormatContext *avc;
AVStream avs[MAX_STREAMS];
int VAR_3;
avc = avformat_alloc_context();
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
VAR_0->title[0] ? VAR_0->title : "No Title", 0);
avc->nb_streams = VAR_0->nb_streams;
if (VAR_0->is_multicast) {
snprintf(avc->filename, 1024, "rtp:
inet_ntoa(VAR_0->multicast_ip),
VAR_0->multicast_port, VAR_0->multicast_ttl);
} else {
snprintf(avc->filename, 1024, "rtp:
}
for(VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++) {
avc->streams[VAR_3] = &avs[VAR_3];
avc->streams[VAR_3]->codec = VAR_0->streams[VAR_3]->codec;
}
*VAR_1 = av_mallocz(2048);
avf_sdp_create(&avc, 1, *VAR_1, 2048);
av_free(avc);
return strlen(*VAR_1);
} | [
"static int FUNC_0(FFStream *VAR_0, uint8_t **VAR_1,\nstruct in_addr VAR_2)\n{",
"AVFormatContext *avc;",
"AVStream avs[MAX_STREAMS];",
"int VAR_3;",
"avc = avformat_alloc_context();",
"if (avc == NULL) {",
"return -1;",
"}",
"av_metadata_set2(&avc->metadata, \"title\",\nVAR_0->title[0] ? VAR_0->title : \"No Title\", 0);",
"avc->nb_streams = VAR_0->nb_streams;",
"if (VAR_0->is_multicast) {",
"snprintf(avc->filename, 1024, \"rtp:\ninet_ntoa(VAR_0->multicast_ip),\nVAR_0->multicast_port, VAR_0->multicast_ttl);",
"} else {",
"snprintf(avc->filename, 1024, \"rtp:\n}",
"for(VAR_3 = 0; VAR_3 < VAR_0->nb_streams; VAR_3++) {",
"avc->streams[VAR_3] = &avs[VAR_3];",
"avc->streams[VAR_3]->codec = VAR_0->streams[VAR_3]->codec;",
"}",
"*VAR_1 = av_mallocz(2048);",
"avf_sdp_create(&avc, 1, *VAR_1, 2048);",
"av_free(avc);",
"return strlen(*VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33,
35
],
[
37
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
58
],
[
62
],
[
64
]
] |
25,745 | static int dvdsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
DVDSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
int is_menu;
if (ctx->buf) {
int ret = append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
*data_size = 0;
return ret;
}
buf = ctx->buf;
buf_size = ctx->buf_size;
}
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
return append_to_cached_buf(avctx, buf, buf_size);
}
if (is_menu < 0) {
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
av_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif
av_freep(&ctx->buf);
ctx->buf_size = 0;
*data_size = 1;
return buf_size;
}
| true | FFmpeg | 816577716bc6170bccfea3b9e865618b69a4b426 | static int dvdsub_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
DVDSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
int is_menu;
if (ctx->buf) {
int ret = append_to_cached_buf(avctx, buf, buf_size);
if (ret < 0) {
*data_size = 0;
return ret;
}
buf = ctx->buf;
buf_size = ctx->buf_size;
}
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
if (is_menu == AVERROR(EAGAIN)) {
*data_size = 0;
return append_to_cached_buf(avctx, buf, buf_size);
}
if (is_menu < 0) {
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
av_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif
av_freep(&ctx->buf);
ctx->buf_size = 0;
*data_size = 1;
return buf_size;
}
| {
"code": [
" if (ctx->buf) {",
" av_freep(&ctx->buf);",
" av_freep(&ctx->buf);"
],
"line_no": [
21,
105,
105
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
DVDSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
AVSubtitle *sub = VAR_1;
int VAR_6;
if (ctx->VAR_4) {
int VAR_7 = append_to_cached_buf(VAR_0, VAR_4, VAR_5);
if (VAR_7 < 0) {
*VAR_2 = 0;
return VAR_7;
}
VAR_4 = ctx->VAR_4;
VAR_5 = ctx->VAR_5;
}
VAR_6 = decode_dvd_subtitles(ctx, sub, VAR_4, VAR_5);
if (VAR_6 == AVERROR(EAGAIN)) {
*VAR_2 = 0;
return append_to_cached_buf(VAR_0, VAR_4, VAR_5);
}
if (VAR_6 < 0) {
no_subtitle:
reset_rects(sub);
*VAR_2 = 0;
return VAR_5;
}
if (!VAR_6 && find_smallest_bounding_rectangle(sub) == 0)
goto no_subtitle;
if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))
goto no_subtitle;
#if defined(DEBUG)
{
char ppm_name[32];
snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++);
av_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.VAR_1[0],
sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.VAR_1[1]);
}
#endif
av_freep(&ctx->VAR_4);
ctx->VAR_5 = 0;
*VAR_2 = 1;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"DVDSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"AVSubtitle *sub = VAR_1;",
"int VAR_6;",
"if (ctx->VAR_4) {",
"int VAR_7 = append_to_cached_buf(VAR_0, VAR_4, VAR_5);",
"if (VAR_7 < 0) {",
"*VAR_2 = 0;",
"return VAR_7;",
"}",
"VAR_4 = ctx->VAR_4;",
"VAR_5 = ctx->VAR_5;",
"}",
"VAR_6 = decode_dvd_subtitles(ctx, sub, VAR_4, VAR_5);",
"if (VAR_6 == AVERROR(EAGAIN)) {",
"*VAR_2 = 0;",
"return append_to_cached_buf(VAR_0, VAR_4, VAR_5);",
"}",
"if (VAR_6 < 0) {",
"no_subtitle:\nreset_rects(sub);",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"if (!VAR_6 && find_smallest_bounding_rectangle(sub) == 0)\ngoto no_subtitle;",
"if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED))\ngoto no_subtitle;",
"#if defined(DEBUG)\n{",
"char ppm_name[32];",
"snprintf(ppm_name, sizeof(ppm_name), \"/tmp/%05d.ppm\", ctx->sub_id++);",
"av_dlog(NULL, \"start=%d ms end =%d ms\\n\",\nsub->start_display_time,\nsub->end_display_time);",
"ppm_save(ppm_name, sub->rects[0]->pict.VAR_1[0],\nsub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.VAR_1[1]);",
"}",
"#endif\nav_freep(&ctx->VAR_4);",
"ctx->VAR_5 = 0;",
"*VAR_2 = 1;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
73,
75
],
[
79,
81
],
[
83
],
[
87
],
[
89,
91,
93
],
[
95,
97
],
[
99
],
[
101,
105
],
[
107
],
[
109
],
[
111
],
[
113
]
] |
25,746 | static void ibm_40p_init(MachineState *machine)
{
CPUPPCState *env = NULL;
uint16_t cmos_checksum;
PowerPCCPU *cpu;
DeviceState *dev;
SysBusDevice *pcihost;
Nvram *m48t59 = NULL;
PCIBus *pci_bus;
ISABus *isa_bus;
void *fw_cfg;
int i;
uint32_t kernel_base = 0, initrd_base = 0;
long kernel_size = 0, initrd_size = 0;
char boot_device;
/* init CPU */
if (!machine->cpu_model) {
machine->cpu_model = "604";
}
cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));
if (!cpu) {
error_report("could not initialize CPU '%s'",
machine->cpu_model);
exit(1);
}
env = &cpu->env;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
error_report("only 6xx bus is supported on this machine");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
/* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
cpu_ppc_tb_init(env, 7812500UL);
} else {
/* Set time-base frequency to 100 Mhz */
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(ppc_prep_reset, cpu);
/* PCI host */
dev = qdev_create(NULL, "raven-pcihost");
if (!bios_name) {
bios_name = BIOS_FILENAME;
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
pcihost = SYS_BUS_DEVICE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0"));
if (!pci_bus) {
error_report("could not create PCI host controller");
exit(1);
}
/* PCI -> ISA bridge */
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(dev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));
sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
/* Memory controller */
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
qdev_prop_set_uint32(dev, "ram-size", machine->ram_size);
qdev_init_nofail(dev);
/* initialize CMOS checksums */
cmos_checksum = 0x6aa9;
qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,
&cmos_checksum);
/* add some more devices */
if (defaults_enabled()) {
isa_create_simple(isa_bus, "i8042");
m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59"));
dev = DEVICE(isa_create(isa_bus, "cs4231a"));
qdev_prop_set_uint32(dev, "iobase", 0x830);
qdev_prop_set_uint32(dev, "irq", 10);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "pc87312"));
qdev_prop_set_uint32(dev, "config", 12);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "prep-systemio"));
qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc);
qdev_prop_set_uint32(dev, "equipment", 0xc0);
qdev_init_nofail(dev);
pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "lsi53c810");
/* XXX: s3-trio at PCI_DEVFN(2, 0) */
pci_vga_init(pci_bus);
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "pcnet",
i == 0 ? "3" : NULL);
}
}
/* Prepare firmware configuration for OpenBIOS */
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
if (machine->kernel_filename) {
/* load kernel */
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(machine->kernel_filename,
kernel_base,
machine->ram_size - kernel_base);
if (kernel_size < 0) {
error_report("could not load kernel '%s'",
machine->kernel_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
/* load initrd */
if (machine->initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(machine->initrd_filename,
initrd_base,
machine->ram_size - initrd_base);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
machine->initrd_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
}
if (machine->kernel_cmdline && *machine->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA,
machine->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(machine->kernel_cmdline) + 1);
}
boot_device = 'm';
} else {
boot_device = machine->boot_order[0];
}
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
}
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
/* Prepare firmware configuration for Open Hack'Ware */
if (m48t59) {
PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size,
boot_device,
kernel_base, kernel_size,
machine->kernel_cmdline,
initrd_base, initrd_size,
/* XXX: need an option to load a NVRAM image */
0,
graphic_width, graphic_height, graphic_depth);
}
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | static void ibm_40p_init(MachineState *machine)
{
CPUPPCState *env = NULL;
uint16_t cmos_checksum;
PowerPCCPU *cpu;
DeviceState *dev;
SysBusDevice *pcihost;
Nvram *m48t59 = NULL;
PCIBus *pci_bus;
ISABus *isa_bus;
void *fw_cfg;
int i;
uint32_t kernel_base = 0, initrd_base = 0;
long kernel_size = 0, initrd_size = 0;
char boot_device;
if (!machine->cpu_model) {
machine->cpu_model = "604";
}
cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model));
if (!cpu) {
error_report("could not initialize CPU '%s'",
machine->cpu_model);
exit(1);
}
env = &cpu->env;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
error_report("only 6xx bus is supported on this machine");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(ppc_prep_reset, cpu);
dev = qdev_create(NULL, "raven-pcihost");
if (!bios_name) {
bios_name = BIOS_FILENAME;
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
pcihost = SYS_BUS_DEVICE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0"));
if (!pci_bus) {
error_report("could not create PCI host controller");
exit(1);
}
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(dev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));
sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
qdev_prop_set_uint32(dev, "ram-size", machine->ram_size);
qdev_init_nofail(dev);
cmos_checksum = 0x6aa9;
qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,
&cmos_checksum);
if (defaults_enabled()) {
isa_create_simple(isa_bus, "i8042");
m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59"));
dev = DEVICE(isa_create(isa_bus, "cs4231a"));
qdev_prop_set_uint32(dev, "iobase", 0x830);
qdev_prop_set_uint32(dev, "irq", 10);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "pc87312"));
qdev_prop_set_uint32(dev, "config", 12);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "prep-systemio"));
qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc);
qdev_prop_set_uint32(dev, "equipment", 0xc0);
qdev_init_nofail(dev);
pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "lsi53c810");
pci_vga_init(pci_bus);
for (i = 0; i < nb_nics; i++) {
pci_nic_init_nofail(&nd_table[i], pci_bus, "pcnet",
i == 0 ? "3" : NULL);
}
}
fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
if (machine->kernel_filename) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image_targphys(machine->kernel_filename,
kernel_base,
machine->ram_size - kernel_base);
if (kernel_size < 0) {
error_report("could not load kernel '%s'",
machine->kernel_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (machine->initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image_targphys(machine->initrd_filename,
initrd_base,
machine->ram_size - initrd_base);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
machine->initrd_filename);
exit(1);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
}
if (machine->kernel_cmdline && *machine->kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA,
machine->kernel_cmdline);
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
strlen(machine->kernel_cmdline) + 1);
}
boot_device = 'm';
} else {
boot_device = machine->boot_order[0];
}
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
}
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
if (m48t59) {
PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size,
boot_device,
kernel_base, kernel_size,
machine->kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
}
}
| {
"code": [
" if (!cpu) {",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" error_report(\"could not initialize CPU '%s'\",",
" machine->cpu_model);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {",
" exit(1);",
" if (!cpu) {"
],
"line_no": [
43,
49,
239,
43,
49,
49,
49,
49,
49,
49,
49,
49,
49,
43,
49,
43,
49,
49,
49,
239,
49,
49,
43,
49,
239,
239,
239,
239,
49,
49,
239,
43,
45,
47,
49,
49,
49,
49,
49,
49,
49,
43,
49,
43,
49,
43
]
} | static void FUNC_0(MachineState *VAR_0)
{
CPUPPCState *env = NULL;
uint16_t cmos_checksum;
PowerPCCPU *cpu;
DeviceState *dev;
SysBusDevice *pcihost;
Nvram *m48t59 = NULL;
PCIBus *pci_bus;
ISABus *isa_bus;
void *VAR_1;
int VAR_2;
uint32_t kernel_base = 0, initrd_base = 0;
long VAR_3 = 0, VAR_4 = 0;
char VAR_5;
if (!VAR_0->cpu_model) {
VAR_0->cpu_model = "604";
}
cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, VAR_0->cpu_model));
if (!cpu) {
error_report("could not initialize CPU '%s'",
VAR_0->cpu_model);
exit(1);
}
env = &cpu->env;
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
error_report("only 6xx bus is supported on this VAR_0");
exit(1);
}
if (env->flags & POWERPC_FLAG_RTC_CLK) {
cpu_ppc_tb_init(env, 7812500UL);
} else {
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
qemu_register_reset(ppc_prep_reset, cpu);
dev = qdev_create(NULL, "raven-pcihost");
if (!bios_name) {
bios_name = BIOS_FILENAME;
}
qdev_prop_set_string(dev, "bios-name", bios_name);
qdev_prop_set_uint32(dev, "elf-VAR_0", PPC_ELF_MACHINE);
pcihost = SYS_BUS_DEVICE(dev);
object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
qdev_init_nofail(dev);
pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci.0"));
if (!pci_bus) {
error_report("could not create PCI host controller");
exit(1);
}
dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
qdev_connect_gpio_out(dev, 0,
cpu->env.irq_inputs[PPC6xx_INPUT_INT]);
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));
sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));
sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
dev = DEVICE(isa_create(isa_bus, "rs6000-mc"));
qdev_prop_set_uint32(dev, "ram-size", VAR_0->ram_size);
qdev_init_nofail(dev);
cmos_checksum = 0x6aa9;
qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,
&cmos_checksum);
if (defaults_enabled()) {
isa_create_simple(isa_bus, "i8042");
m48t59 = NVRAM(isa_create_simple(isa_bus, "isa-m48t59"));
dev = DEVICE(isa_create(isa_bus, "cs4231a"));
qdev_prop_set_uint32(dev, "iobase", 0x830);
qdev_prop_set_uint32(dev, "irq", 10);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "pc87312"));
qdev_prop_set_uint32(dev, "config", 12);
qdev_init_nofail(dev);
dev = DEVICE(isa_create(isa_bus, "prep-systemio"));
qdev_prop_set_uint32(dev, "ibm-planar-id", 0xfc);
qdev_prop_set_uint32(dev, "equipment", 0xc0);
qdev_init_nofail(dev);
pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "lsi53c810");
pci_vga_init(pci_bus);
for (VAR_2 = 0; VAR_2 < nb_nics; VAR_2++) {
pci_nic_init_nofail(&nd_table[VAR_2], pci_bus, "pcnet",
VAR_2 == 0 ? "3" : NULL);
}
}
VAR_1 = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);
if (VAR_0->kernel_filename) {
kernel_base = KERNEL_LOAD_ADDR;
VAR_3 = load_image_targphys(VAR_0->kernel_filename,
kernel_base,
VAR_0->ram_size - kernel_base);
if (VAR_3 < 0) {
error_report("could not load kernel '%s'",
VAR_0->kernel_filename);
exit(1);
}
fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_SIZE, VAR_3);
if (VAR_0->initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
VAR_4 = load_image_targphys(VAR_0->initrd_filename,
initrd_base,
VAR_0->ram_size - initrd_base);
if (VAR_4 < 0) {
error_report("could not load initial ram disk '%s'",
VAR_0->initrd_filename);
exit(1);
}
fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_SIZE, VAR_4);
}
if (VAR_0->kernel_cmdline && *VAR_0->kernel_cmdline) {
fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
VAR_0->kernel_cmdline);
fw_cfg_add_string(VAR_1, FW_CFG_CMDLINE_DATA,
VAR_0->kernel_cmdline);
fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_SIZE,
strlen(VAR_0->kernel_cmdline) + 1);
}
VAR_5 = 'm';
} else {
VAR_5 = VAR_0->boot_order[0];
}
fw_cfg_add_i16(VAR_1, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i64(VAR_1, FW_CFG_RAM_SIZE, (uint64_t)VAR_0->ram_size);
fw_cfg_add_i16(VAR_1, FW_CFG_MACHINE_ID, ARCH_PREP);
fw_cfg_add_i16(VAR_1, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(VAR_1, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(VAR_1, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(VAR_1, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(VAR_1, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(VAR_1, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(VAR_1, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(VAR_1, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);
}
fw_cfg_add_i16(VAR_1, FW_CFG_BOOT_DEVICE, VAR_5);
qemu_register_boot_set(fw_cfg_boot_set, VAR_1);
if (m48t59) {
PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size,
VAR_5,
kernel_base, VAR_3,
VAR_0->kernel_cmdline,
initrd_base, VAR_4,
0,
graphic_width, graphic_height, graphic_depth);
}
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"CPUPPCState *env = NULL;",
"uint16_t cmos_checksum;",
"PowerPCCPU *cpu;",
"DeviceState *dev;",
"SysBusDevice *pcihost;",
"Nvram *m48t59 = NULL;",
"PCIBus *pci_bus;",
"ISABus *isa_bus;",
"void *VAR_1;",
"int VAR_2;",
"uint32_t kernel_base = 0, initrd_base = 0;",
"long VAR_3 = 0, VAR_4 = 0;",
"char VAR_5;",
"if (!VAR_0->cpu_model) {",
"VAR_0->cpu_model = \"604\";",
"}",
"cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, VAR_0->cpu_model));",
"if (!cpu) {",
"error_report(\"could not initialize CPU '%s'\",\nVAR_0->cpu_model);",
"exit(1);",
"}",
"env = &cpu->env;",
"if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {",
"error_report(\"only 6xx bus is supported on this VAR_0\");",
"exit(1);",
"}",
"if (env->flags & POWERPC_FLAG_RTC_CLK) {",
"cpu_ppc_tb_init(env, 7812500UL);",
"} else {",
"cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);",
"}",
"qemu_register_reset(ppc_prep_reset, cpu);",
"dev = qdev_create(NULL, \"raven-pcihost\");",
"if (!bios_name) {",
"bios_name = BIOS_FILENAME;",
"}",
"qdev_prop_set_string(dev, \"bios-name\", bios_name);",
"qdev_prop_set_uint32(dev, \"elf-VAR_0\", PPC_ELF_MACHINE);",
"pcihost = SYS_BUS_DEVICE(dev);",
"object_property_add_child(qdev_get_machine(), \"raven\", OBJECT(dev), NULL);",
"qdev_init_nofail(dev);",
"pci_bus = PCI_BUS(qdev_get_child_bus(dev, \"pci.0\"));",
"if (!pci_bus) {",
"error_report(\"could not create PCI host controller\");",
"exit(1);",
"}",
"dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), \"i82378\"));",
"qdev_connect_gpio_out(dev, 0,\ncpu->env.irq_inputs[PPC6xx_INPUT_INT]);",
"sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(dev, 15));",
"sysbus_connect_irq(pcihost, 1, qdev_get_gpio_in(dev, 13));",
"sysbus_connect_irq(pcihost, 2, qdev_get_gpio_in(dev, 15));",
"sysbus_connect_irq(pcihost, 3, qdev_get_gpio_in(dev, 13));",
"isa_bus = ISA_BUS(qdev_get_child_bus(dev, \"isa.0\"));",
"dev = DEVICE(isa_create(isa_bus, \"rs6000-mc\"));",
"qdev_prop_set_uint32(dev, \"ram-size\", VAR_0->ram_size);",
"qdev_init_nofail(dev);",
"cmos_checksum = 0x6aa9;",
"qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,\n&cmos_checksum);",
"if (defaults_enabled()) {",
"isa_create_simple(isa_bus, \"i8042\");",
"m48t59 = NVRAM(isa_create_simple(isa_bus, \"isa-m48t59\"));",
"dev = DEVICE(isa_create(isa_bus, \"cs4231a\"));",
"qdev_prop_set_uint32(dev, \"iobase\", 0x830);",
"qdev_prop_set_uint32(dev, \"irq\", 10);",
"qdev_init_nofail(dev);",
"dev = DEVICE(isa_create(isa_bus, \"pc87312\"));",
"qdev_prop_set_uint32(dev, \"config\", 12);",
"qdev_init_nofail(dev);",
"dev = DEVICE(isa_create(isa_bus, \"prep-systemio\"));",
"qdev_prop_set_uint32(dev, \"ibm-planar-id\", 0xfc);",
"qdev_prop_set_uint32(dev, \"equipment\", 0xc0);",
"qdev_init_nofail(dev);",
"pci_create_simple(pci_bus, PCI_DEVFN(1, 0), \"lsi53c810\");",
"pci_vga_init(pci_bus);",
"for (VAR_2 = 0; VAR_2 < nb_nics; VAR_2++) {",
"pci_nic_init_nofail(&nd_table[VAR_2], pci_bus, \"pcnet\",\nVAR_2 == 0 ? \"3\" : NULL);",
"}",
"}",
"VAR_1 = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2);",
"if (VAR_0->kernel_filename) {",
"kernel_base = KERNEL_LOAD_ADDR;",
"VAR_3 = load_image_targphys(VAR_0->kernel_filename,\nkernel_base,\nVAR_0->ram_size - kernel_base);",
"if (VAR_3 < 0) {",
"error_report(\"could not load kernel '%s'\",\nVAR_0->kernel_filename);",
"exit(1);",
"}",
"fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_ADDR, kernel_base);",
"fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_SIZE, VAR_3);",
"if (VAR_0->initrd_filename) {",
"initrd_base = INITRD_LOAD_ADDR;",
"VAR_4 = load_image_targphys(VAR_0->initrd_filename,\ninitrd_base,\nVAR_0->ram_size - initrd_base);",
"if (VAR_4 < 0) {",
"error_report(\"could not load initial ram disk '%s'\",\nVAR_0->initrd_filename);",
"exit(1);",
"}",
"fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_ADDR, initrd_base);",
"fw_cfg_add_i32(VAR_1, FW_CFG_INITRD_SIZE, VAR_4);",
"}",
"if (VAR_0->kernel_cmdline && *VAR_0->kernel_cmdline) {",
"fw_cfg_add_i32(VAR_1, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);",
"pstrcpy_targphys(\"cmdline\", CMDLINE_ADDR, TARGET_PAGE_SIZE,\nVAR_0->kernel_cmdline);",
"fw_cfg_add_string(VAR_1, FW_CFG_CMDLINE_DATA,\nVAR_0->kernel_cmdline);",
"fw_cfg_add_i32(VAR_1, FW_CFG_CMDLINE_SIZE,\nstrlen(VAR_0->kernel_cmdline) + 1);",
"}",
"VAR_5 = 'm';",
"} else {",
"VAR_5 = VAR_0->boot_order[0];",
"}",
"fw_cfg_add_i16(VAR_1, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);",
"fw_cfg_add_i64(VAR_1, FW_CFG_RAM_SIZE, (uint64_t)VAR_0->ram_size);",
"fw_cfg_add_i16(VAR_1, FW_CFG_MACHINE_ID, ARCH_PREP);",
"fw_cfg_add_i16(VAR_1, FW_CFG_PPC_WIDTH, graphic_width);",
"fw_cfg_add_i16(VAR_1, FW_CFG_PPC_HEIGHT, graphic_height);",
"fw_cfg_add_i16(VAR_1, FW_CFG_PPC_DEPTH, graphic_depth);",
"fw_cfg_add_i32(VAR_1, FW_CFG_PPC_IS_KVM, kvm_enabled());",
"if (kvm_enabled()) {",
"#ifdef CONFIG_KVM\nuint8_t *hypercall;",
"fw_cfg_add_i32(VAR_1, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());",
"hypercall = g_malloc(16);",
"kvmppc_get_hypercall(env, hypercall, 16);",
"fw_cfg_add_bytes(VAR_1, FW_CFG_PPC_KVM_HC, hypercall, 16);",
"fw_cfg_add_i32(VAR_1, FW_CFG_PPC_KVM_PID, getpid());",
"#endif\n} else {",
"fw_cfg_add_i32(VAR_1, FW_CFG_PPC_TBFREQ, NANOSECONDS_PER_SECOND);",
"}",
"fw_cfg_add_i16(VAR_1, FW_CFG_BOOT_DEVICE, VAR_5);",
"qemu_register_boot_set(fw_cfg_boot_set, VAR_1);",
"if (m48t59) {",
"PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, \"PREP\", ram_size,\nVAR_5,\nkernel_base, VAR_3,\nVAR_0->kernel_cmdline,\ninitrd_base, VAR_4,\n0,\ngraphic_width, graphic_height, graphic_depth);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
137
],
[
139
],
[
141
],
[
147
],
[
149,
151
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
199
],
[
203
],
[
205,
207
],
[
209
],
[
211
],
[
217
],
[
221
],
[
225
],
[
227,
229,
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
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
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323,
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
355
],
[
357,
359,
361,
363,
365,
369,
371
],
[
373
],
[
375
]
] |
25,747 | static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "iommu");
qdev_prop_set_uint32(dev, "version", version);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
sysbus_mmio_map(s, 0, addr);
return s;
}
| true | qemu | e23a1b33b53d25510320b26d9f154e19c6c99725 | static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "iommu");
qdev_prop_set_uint32(dev, "version", version);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, irq);
sysbus_mmio_map(s, 0, addr);
return s;
}
| {
"code": [
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);",
" qdev_init(dev);"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15
]
} | static void *FUNC_0(target_phys_addr_t VAR_0, uint32_t VAR_1, qemu_irq VAR_2)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "iommu");
qdev_prop_set_uint32(dev, "VAR_1", VAR_1);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, VAR_2);
sysbus_mmio_map(s, 0, VAR_0);
return s;
}
| [
"static void *FUNC_0(target_phys_addr_t VAR_0, uint32_t VAR_1, qemu_irq VAR_2)\n{",
"DeviceState *dev;",
"SysBusDevice *s;",
"dev = qdev_create(NULL, \"iommu\");",
"qdev_prop_set_uint32(dev, \"VAR_1\", VAR_1);",
"qdev_init(dev);",
"s = sysbus_from_qdev(dev);",
"sysbus_connect_irq(s, 0, VAR_2);",
"sysbus_mmio_map(s, 0, VAR_0);",
"return s;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
25,749 | static void test_qemu_strtoull_full_empty(void)
{
const char *str = "";
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
}
| true | qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | static void test_qemu_strtoull_full_empty(void)
{
const char *str = "";
uint64_t res = 999;
int err;
err = qemu_strtoull(str, NULL, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, 0);
}
| {
"code": [
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(err, ==, 0);",
" g_assert_cmpint(res, ==, 0);"
],
"line_no": [
17,
19,
17,
19,
17,
19,
17,
19,
17,
19,
17,
19,
17,
17,
19,
17,
19,
17,
19,
17,
17,
19,
17,
19,
17,
19,
17,
17,
19
]
} | static void FUNC_0(void)
{
const char *VAR_0 = "";
uint64_t res = 999;
int VAR_1;
VAR_1 = qemu_strtoull(VAR_0, NULL, 0, &res);
g_assert_cmpint(VAR_1, ==, 0);
g_assert_cmpint(res, ==, 0);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = \"\";",
"uint64_t res = 999;",
"int VAR_1;",
"VAR_1 = qemu_strtoull(VAR_0, NULL, 0, &res);",
"g_assert_cmpint(VAR_1, ==, 0);",
"g_assert_cmpint(res, ==, 0);",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
25,750 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %7 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %6, %%"REG_D" \n\t" // buf2
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %7, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2), "m"(dst2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst1[i] = src1[srcW-1]*128;
dst2[i] = src2[srcW-1]*128;
}
}
| false | FFmpeg | 9bcbb250e23959075765edd3cb4c1fcb46736d7d | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %7 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %6, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %7, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2), "m"(dst2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst1[i] = src1[srcW-1]*128;
dst2[i] = src2[srcW-1]*128;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
void *VAR_0= c->chrMmx2FilterCode;
int VAR_1;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %7 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t"
"mov %5, %%"REG_c" \n\t"
"mov %6, %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %7, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
"m" (VAR_0), "m" (src2), "m"(dst2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (VAR_1=dstWidth-1; (VAR_1*xInc)>>16 >=srcW-1; VAR_1--) {
dst1[VAR_1] = src1[srcW-1]*128;
dst2[VAR_1] = src2[srcW-1]*128;
}
}
| [
"static inline void FUNC_0(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,\nint dstWidth, const uint8_t *src1,\nconst uint8_t *src2, int srcW, int xInc)\n{",
"int32_t *filterPos = c->hChrFilterPos;",
"int16_t *filter = c->hChrFilter;",
"void *VAR_0= c->chrMmx2FilterCode;",
"int VAR_1;",
"#if defined(PIC)\nDECLARE_ALIGNED(8, uint64_t, ebxsave);",
"#endif\n__asm__ volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %7 \\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"mov %5, %%\"REG_c\" \\n\\t\"\n\"mov %6, %%\"REG_D\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n#if defined(PIC)\n\"mov %7, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src1), \"m\" (dst1), \"m\" (filter), \"m\" (filterPos),\n\"m\" (VAR_0), \"m\" (src2), \"m\"(dst2)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);",
"for (VAR_1=dstWidth-1; (VAR_1*xInc)>>16 >=srcW-1; VAR_1--) {",
"dst1[VAR_1] = src1[srcW-1]*128;",
"dst2[VAR_1] = src2[srcW-1]*128;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
75,
77,
79,
81,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
]
] |
25,751 | static void get_pointer(Object *obj, Visitor *v, Property *prop,
const char *(*print)(void *ptr),
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
void **ptr = qdev_get_prop_ptr(dev, prop);
char *p;
p = (char *) (*ptr ? print(*ptr) : "");
visit_type_str(v, &p, name, errp);
}
| false | qemu | d4d34b0d3f5af5c8e09980da0de2eebe9a27dc71 | static void get_pointer(Object *obj, Visitor *v, Property *prop,
const char *(*print)(void *ptr),
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
void **ptr = qdev_get_prop_ptr(dev, prop);
char *p;
p = (char *) (*ptr ? print(*ptr) : "");
visit_type_str(v, &p, name, errp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0, Visitor *VAR_1, Property *VAR_2,
const char *(*VAR_3)(void *VAR_7),
const char *VAR_5, Error **VAR_6)
{
DeviceState *dev = DEVICE(VAR_0);
void **VAR_7 = qdev_get_prop_ptr(dev, VAR_2);
char *VAR_7;
VAR_7 = (char *) (*VAR_7 ? VAR_3(*VAR_7) : "");
visit_type_str(VAR_1, &VAR_7, VAR_5, VAR_6);
}
| [
"static void FUNC_0(Object *VAR_0, Visitor *VAR_1, Property *VAR_2,\nconst char *(*VAR_3)(void *VAR_7),\nconst char *VAR_5, Error **VAR_6)\n{",
"DeviceState *dev = DEVICE(VAR_0);",
"void **VAR_7 = qdev_get_prop_ptr(dev, VAR_2);",
"char *VAR_7;",
"VAR_7 = (char *) (*VAR_7 ? VAR_3(*VAR_7) : \"\");",
"visit_type_str(VAR_1, &VAR_7, VAR_5, VAR_6);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
]
] |
25,752 | static uint64_t jazz_led_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
LedState *s = opaque;
uint8_t val;
val = s->segments;
trace_jazz_led_read(addr, val);
return val;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t jazz_led_read(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
LedState *s = opaque;
uint8_t val;
val = s->segments;
trace_jazz_led_read(addr, val);
return val;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned int size)
{
LedState *s = opaque;
uint8_t val;
val = s->segments;
trace_jazz_led_read(addr, val);
return val;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned int size)\n{",
"LedState *s = opaque;",
"uint8_t val;",
"val = s->segments;",
"trace_jazz_led_read(addr, val);",
"return val;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
]
] |
25,754 | float32 HELPER(ucf64_divs)(float32 a, float32 b, CPUUniCore32State *env)
{
return float32_div(a, b, &env->ucf64.fp_status);
}
| false | qemu | e8ede0a8bb5298a6979bcf7ed84ef64a64a4e3fe | float32 HELPER(ucf64_divs)(float32 a, float32 b, CPUUniCore32State *env)
{
return float32_div(a, b, &env->ucf64.fp_status);
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0(ucf64_divs)(float32 a, float32 b, CPUUniCore32State *env)
{
return float32_div(a, b, &env->ucf64.fp_status);
}
| [
"float32 FUNC_0(ucf64_divs)(float32 a, float32 b, CPUUniCore32State *env)\n{",
"return float32_div(a, b, &env->ucf64.fp_status);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,755 | static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->realize = scsi_generic_realize;
sc->unrealize = scsi_unrealize;
sc->alloc_req = scsi_new_request;
sc->parse_cdb = scsi_generic_parse_cdb;
dc->fw_name = "disk";
dc->desc = "pass through generic scsi device (/dev/sg*)";
dc->reset = scsi_generic_reset;
dc->props = scsi_generic_properties;
dc->vmsd = &vmstate_scsi_device;
}
| false | qemu | fb7b5c0df6e3c501973ce4d57eb2b1d4344a519d | static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
sc->realize = scsi_generic_realize;
sc->unrealize = scsi_unrealize;
sc->alloc_req = scsi_new_request;
sc->parse_cdb = scsi_generic_parse_cdb;
dc->fw_name = "disk";
dc->desc = "pass through generic scsi device (/dev/sg*)";
dc->reset = scsi_generic_reset;
dc->props = scsi_generic_properties;
dc->vmsd = &vmstate_scsi_device;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(VAR_0);
sc->realize = scsi_generic_realize;
sc->unrealize = scsi_unrealize;
sc->alloc_req = scsi_new_request;
sc->parse_cdb = scsi_generic_parse_cdb;
dc->fw_name = "disk";
dc->desc = "pass through generic scsi device (/dev/sg*)";
dc->reset = scsi_generic_reset;
dc->props = scsi_generic_properties;
dc->vmsd = &vmstate_scsi_device;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(VAR_0);",
"sc->realize = scsi_generic_realize;",
"sc->unrealize = scsi_unrealize;",
"sc->alloc_req = scsi_new_request;",
"sc->parse_cdb = scsi_generic_parse_cdb;",
"dc->fw_name = \"disk\";",
"dc->desc = \"pass through generic scsi device (/dev/sg*)\";",
"dc->reset = scsi_generic_reset;",
"dc->props = scsi_generic_properties;",
"dc->vmsd = &vmstate_scsi_device;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
] |
25,756 | START_TEST(qlist_destroy_test)
{
int i;
QList *qlist;
qlist = qlist_new();
for (i = 0; i < 42; i++)
qlist_append(qlist, qint_from_int(i));
QDECREF(qlist);
}
| false | qemu | 91479dd0b5bd3b087b92ddd7bc3f2c54982cfe17 | START_TEST(qlist_destroy_test)
{
int i;
QList *qlist;
qlist = qlist_new();
for (i = 0; i < 42; i++)
qlist_append(qlist, qint_from_int(i));
QDECREF(qlist);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
int VAR_1;
QList *qlist;
qlist = qlist_new();
for (VAR_1 = 0; VAR_1 < 42; VAR_1++)
qlist_append(qlist, qint_from_int(VAR_1));
QDECREF(qlist);
}
| [
"FUNC_0(VAR_0)\n{",
"int VAR_1;",
"QList *qlist;",
"qlist = qlist_new();",
"for (VAR_1 = 0; VAR_1 < 42; VAR_1++)",
"qlist_append(qlist, qint_from_int(VAR_1));",
"QDECREF(qlist);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
25,757 | static void vnc_client_read(void *opaque)
{
VncState *vs = opaque;
long ret;
buffer_reserve(&vs->input, 4096);
#ifdef CONFIG_VNC_TLS
if (vs->tls_session) {
ret = gnutls_read(vs->tls_session, buffer_end(&vs->input), 4096);
if (ret < 0) {
if (ret == GNUTLS_E_AGAIN)
errno = EAGAIN;
else
errno = EIO;
ret = -1;
}
} else
#endif /* CONFIG_VNC_TLS */
ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);
ret = vnc_client_io_error(vs, ret, socket_error());
if (!ret)
return;
vs->input.offset += ret;
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1)
return;
if (!ret) {
memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));
vs->input.offset -= len;
} else {
vs->read_handler_expect = ret;
}
}
}
| false | qemu | 5fb6c7a8b26eab1a22207d24b4784bd2b39ab54b | static void vnc_client_read(void *opaque)
{
VncState *vs = opaque;
long ret;
buffer_reserve(&vs->input, 4096);
#ifdef CONFIG_VNC_TLS
if (vs->tls_session) {
ret = gnutls_read(vs->tls_session, buffer_end(&vs->input), 4096);
if (ret < 0) {
if (ret == GNUTLS_E_AGAIN)
errno = EAGAIN;
else
errno = EIO;
ret = -1;
}
} else
#endif
ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);
ret = vnc_client_io_error(vs, ret, socket_error());
if (!ret)
return;
vs->input.offset += ret;
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1)
return;
if (!ret) {
memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));
vs->input.offset -= len;
} else {
vs->read_handler_expect = ret;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
VncState *vs = VAR_0;
long VAR_2;
buffer_reserve(&vs->input, 4096);
#ifdef CONFIG_VNC_TLS
if (vs->tls_session) {
VAR_2 = gnutls_read(vs->tls_session, buffer_end(&vs->input), 4096);
if (VAR_2 < 0) {
if (VAR_2 == GNUTLS_E_AGAIN)
errno = EAGAIN;
else
errno = EIO;
VAR_2 = -1;
}
} else
#endif
VAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0);
VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error());
if (!VAR_2)
return;
vs->input.offset += VAR_2;
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int VAR_2;
VAR_2 = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1)
return;
if (!VAR_2) {
memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));
vs->input.offset -= len;
} else {
vs->read_handler_expect = VAR_2;
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"VncState *vs = VAR_0;",
"long VAR_2;",
"buffer_reserve(&vs->input, 4096);",
"#ifdef CONFIG_VNC_TLS\nif (vs->tls_session) {",
"VAR_2 = gnutls_read(vs->tls_session, buffer_end(&vs->input), 4096);",
"if (VAR_2 < 0) {",
"if (VAR_2 == GNUTLS_E_AGAIN)\nerrno = EAGAIN;",
"else\nerrno = EIO;",
"VAR_2 = -1;",
"}",
"} else",
"#endif\nVAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0);",
"VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error());",
"if (!VAR_2)\nreturn;",
"vs->input.offset += VAR_2;",
"while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {",
"size_t len = vs->read_handler_expect;",
"int VAR_2;",
"VAR_2 = vs->read_handler(vs, vs->input.buffer, len);",
"if (vs->csock == -1)\nreturn;",
"if (!VAR_2) {",
"memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));",
"vs->input.offset -= len;",
"} else {",
"vs->read_handler_expect = 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
25,758 | POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->desc = "e5500 core";
pcc->init_proc = init_proc_e5500;
pcc->check_pow = check_pow_none;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL |
PPC_WRTEE | PPC_RFDI | PPC_RFMCI |
PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI |
PPC_CACHE_DCBZ | PPC_CACHE_DCBA |
PPC_FLOAT | PPC_FLOAT_FRES |
PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |
PPC_FLOAT_STFIWX | PPC_WAIT |
PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC |
PPC_64B | PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206;
pcc->msr_mask = (1ull << MSR_CM) |
(1ull << MSR_GS) |
(1ull << MSR_UCLE) |
(1ull << MSR_CE) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PX) |
(1ull << MSR_RI);
pcc->mmu_model = POWERPC_MMU_BOOKE206;
pcc->excp_model = POWERPC_EXCP_BOOKE;
pcc->bus_model = PPC_FLAGS_INPUT_BookE;
/* FIXME: figure out the correct flag for e5500 */
pcc->bfd_mach = bfd_mach_ppc_e500;
pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE |
POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK;
}
| false | qemu | 4171853cf4dfb88da93bf77a4c9d319d6ba2bdc6 | POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->desc = "e5500 core";
pcc->init_proc = init_proc_e5500;
pcc->check_pow = check_pow_none;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL |
PPC_WRTEE | PPC_RFDI | PPC_RFMCI |
PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI |
PPC_CACHE_DCBZ | PPC_CACHE_DCBA |
PPC_FLOAT | PPC_FLOAT_FRES |
PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |
PPC_FLOAT_STFIWX | PPC_WAIT |
PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC |
PPC_64B | PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206;
pcc->msr_mask = (1ull << MSR_CM) |
(1ull << MSR_GS) |
(1ull << MSR_UCLE) |
(1ull << MSR_CE) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PX) |
(1ull << MSR_RI);
pcc->mmu_model = POWERPC_MMU_BOOKE206;
pcc->excp_model = POWERPC_EXCP_BOOKE;
pcc->bus_model = PPC_FLAGS_INPUT_BookE;
pcc->bfd_mach = bfd_mach_ppc_e500;
pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE |
POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK;
}
| {
"code": [],
"line_no": []
} | FUNC_0(e5500)(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
dc->desc = "e5500 core";
pcc->init_proc = init_proc_e5500;
pcc->check_pow = check_pow_none;
pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL |
PPC_WRTEE | PPC_RFDI | PPC_RFMCI |
PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI |
PPC_CACHE_DCBZ | PPC_CACHE_DCBA |
PPC_FLOAT | PPC_FLOAT_FRES |
PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |
PPC_FLOAT_STFIWX | PPC_WAIT |
PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC |
PPC_64B | PPC_POPCNTB | PPC_POPCNTWD;
pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206;
pcc->msr_mask = (1ull << MSR_CM) |
(1ull << MSR_GS) |
(1ull << MSR_UCLE) |
(1ull << MSR_CE) |
(1ull << MSR_EE) |
(1ull << MSR_PR) |
(1ull << MSR_FP) |
(1ull << MSR_ME) |
(1ull << MSR_FE0) |
(1ull << MSR_DE) |
(1ull << MSR_FE1) |
(1ull << MSR_IR) |
(1ull << MSR_DR) |
(1ull << MSR_PX) |
(1ull << MSR_RI);
pcc->mmu_model = POWERPC_MMU_BOOKE206;
pcc->excp_model = POWERPC_EXCP_BOOKE;
pcc->bus_model = PPC_FLAGS_INPUT_BookE;
pcc->bfd_mach = bfd_mach_ppc_e500;
pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE |
POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK;
}
| [
"FUNC_0(e5500)(ObjectClass *oc, void *data)\n{",
"DeviceClass *dc = DEVICE_CLASS(oc);",
"PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);",
"dc->desc = \"e5500 core\";",
"pcc->init_proc = init_proc_e5500;",
"pcc->check_pow = check_pow_none;",
"pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL |\nPPC_WRTEE | PPC_RFDI | PPC_RFMCI |\nPPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI |\nPPC_CACHE_DCBZ | PPC_CACHE_DCBA |\nPPC_FLOAT | PPC_FLOAT_FRES |\nPPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |\nPPC_FLOAT_STFIWX | PPC_WAIT |\nPPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC |\nPPC_64B | PPC_POPCNTB | PPC_POPCNTWD;",
"pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206;",
"pcc->msr_mask = (1ull << MSR_CM) |\n(1ull << MSR_GS) |\n(1ull << MSR_UCLE) |\n(1ull << MSR_CE) |\n(1ull << MSR_EE) |\n(1ull << MSR_PR) |\n(1ull << MSR_FP) |\n(1ull << MSR_ME) |\n(1ull << MSR_FE0) |\n(1ull << MSR_DE) |\n(1ull << MSR_FE1) |\n(1ull << MSR_IR) |\n(1ull << MSR_DR) |\n(1ull << MSR_PX) |\n(1ull << MSR_RI);",
"pcc->mmu_model = POWERPC_MMU_BOOKE206;",
"pcc->excp_model = POWERPC_EXCP_BOOKE;",
"pcc->bus_model = PPC_FLAGS_INPUT_BookE;",
"pcc->bfd_mach = bfd_mach_ppc_e500;",
"pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE |\nPOWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17,
19,
21,
23,
25,
27,
29,
31,
33
],
[
35
],
[
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77,
79
],
[
81
]
] |
25,759 | void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
{
const uint8_t *end;
int j;
j = ctx->len & 63;
ctx->len += len;
if (j) {
int cnt = FFMIN(len, 64 - j);
memcpy(ctx->block + j, src, cnt);
src += cnt;
len -= cnt;
if (j + cnt < 64)
return;
body(ctx->ABCD, (uint32_t *)ctx->block);
}
end = src + (len & ~63);
if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) {
while (src < end) {
memcpy(ctx->block, src, 64);
body(ctx->ABCD, (uint32_t *) ctx->block);
src += 64;
}
} else {
while (src < end) {
body(ctx->ABCD, (uint32_t *)src);
src += 64;
}
}
len &= 63;
if (len > 0)
memcpy(ctx->block, src, len);
}
| false | FFmpeg | a67304d05f11b2377bf157a356d7ebb00f3e06dd | void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
{
const uint8_t *end;
int j;
j = ctx->len & 63;
ctx->len += len;
if (j) {
int cnt = FFMIN(len, 64 - j);
memcpy(ctx->block + j, src, cnt);
src += cnt;
len -= cnt;
if (j + cnt < 64)
return;
body(ctx->ABCD, (uint32_t *)ctx->block);
}
end = src + (len & ~63);
if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) {
while (src < end) {
memcpy(ctx->block, src, 64);
body(ctx->ABCD, (uint32_t *) ctx->block);
src += 64;
}
} else {
while (src < end) {
body(ctx->ABCD, (uint32_t *)src);
src += 64;
}
}
len &= 63;
if (len > 0)
memcpy(ctx->block, src, len);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AVMD5 *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
const uint8_t *VAR_3;
int VAR_4;
VAR_4 = VAR_0->VAR_2 & 63;
VAR_0->VAR_2 += VAR_2;
if (VAR_4) {
int VAR_5 = FFMIN(VAR_2, 64 - VAR_4);
memcpy(VAR_0->block + VAR_4, VAR_1, VAR_5);
VAR_1 += VAR_5;
VAR_2 -= VAR_5;
if (VAR_4 + VAR_5 < 64)
return;
body(VAR_0->ABCD, (uint32_t *)VAR_0->block);
}
VAR_3 = VAR_1 + (VAR_2 & ~63);
if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)VAR_1 & 3))) {
while (VAR_1 < VAR_3) {
memcpy(VAR_0->block, VAR_1, 64);
body(VAR_0->ABCD, (uint32_t *) VAR_0->block);
VAR_1 += 64;
}
} else {
while (VAR_1 < VAR_3) {
body(VAR_0->ABCD, (uint32_t *)VAR_1);
VAR_1 += 64;
}
}
VAR_2 &= 63;
if (VAR_2 > 0)
memcpy(VAR_0->block, VAR_1, VAR_2);
}
| [
"void FUNC_0(AVMD5 *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"const uint8_t *VAR_3;",
"int VAR_4;",
"VAR_4 = VAR_0->VAR_2 & 63;",
"VAR_0->VAR_2 += VAR_2;",
"if (VAR_4) {",
"int VAR_5 = FFMIN(VAR_2, 64 - VAR_4);",
"memcpy(VAR_0->block + VAR_4, VAR_1, VAR_5);",
"VAR_1 += VAR_5;",
"VAR_2 -= VAR_5;",
"if (VAR_4 + VAR_5 < 64)\nreturn;",
"body(VAR_0->ABCD, (uint32_t *)VAR_0->block);",
"}",
"VAR_3 = VAR_1 + (VAR_2 & ~63);",
"if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)VAR_1 & 3))) {",
"while (VAR_1 < VAR_3) {",
"memcpy(VAR_0->block, VAR_1, 64);",
"body(VAR_0->ABCD, (uint32_t *) VAR_0->block);",
"VAR_1 += 64;",
"}",
"} else {",
"while (VAR_1 < VAR_3) {",
"body(VAR_0->ABCD, (uint32_t *)VAR_1);",
"VAR_1 += 64;",
"}",
"}",
"VAR_2 &= 63;",
"if (VAR_2 > 0)\nmemcpy(VAR_0->block, 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
]
] |
25,760 | int main()
{
int rt, rs;
int achi, acli;
int dsp;
int acho, aclo;
int resulth, resultl;
int resdsp;
achi = 0x05;
acli = 0xB4CB;
rs = 0xFF06;
rt = 0xCB00;
resulth = 0x04;
resultl = 0x947438CB;
__asm
("mthi %2, $ac1\n\t"
"mtlo %3, $ac1\n\t"
"maq_s.w.phr $ac1, %4, %5\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
: "=r"(acho), "=r"(aclo)
: "r"(achi), "r"(acli), "r"(rs), "r"(rt)
);
assert(resulth == acho);
assert(resultl == aclo);
achi = 0x06;
acli = 0xB4CB;
rs = 0x8000;
rt = 0x8000;
resulth = 0x6;
resultl = 0x8000b4ca;
resdsp = 1;
__asm
("mthi %3, $ac1\n\t"
"mtlo %4, $ac1\n\t"
"maq_s.w.phr $ac1, %5, %6\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
"rddsp %2\n\t"
: "=r"(acho), "=r"(aclo), "=r"(dsp)
: "r"(achi), "r"(acli), "r"(rs), "r"(rt)
);
assert(resulth == acho);
assert(resultl == aclo);
assert(((dsp >> 17) & 0x01) == resdsp);
return 0;
}
| false | qemu | beb3faaa0027c114e37317fdba38a8a7facf3f9b | int main()
{
int rt, rs;
int achi, acli;
int dsp;
int acho, aclo;
int resulth, resultl;
int resdsp;
achi = 0x05;
acli = 0xB4CB;
rs = 0xFF06;
rt = 0xCB00;
resulth = 0x04;
resultl = 0x947438CB;
__asm
("mthi %2, $ac1\n\t"
"mtlo %3, $ac1\n\t"
"maq_s.w.phr $ac1, %4, %5\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
: "=r"(acho), "=r"(aclo)
: "r"(achi), "r"(acli), "r"(rs), "r"(rt)
);
assert(resulth == acho);
assert(resultl == aclo);
achi = 0x06;
acli = 0xB4CB;
rs = 0x8000;
rt = 0x8000;
resulth = 0x6;
resultl = 0x8000b4ca;
resdsp = 1;
__asm
("mthi %3, $ac1\n\t"
"mtlo %4, $ac1\n\t"
"maq_s.w.phr $ac1, %5, %6\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
"rddsp %2\n\t"
: "=r"(acho), "=r"(aclo), "=r"(dsp)
: "r"(achi), "r"(acli), "r"(rs), "r"(rt)
);
assert(resulth == acho);
assert(resultl == aclo);
assert(((dsp >> 17) & 0x01) == resdsp);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0()
{
int VAR_0, VAR_1;
int VAR_2, VAR_3;
int VAR_4;
int VAR_5, VAR_6;
int VAR_7, VAR_8;
int VAR_9;
VAR_2 = 0x05;
VAR_3 = 0xB4CB;
VAR_1 = 0xFF06;
VAR_0 = 0xCB00;
VAR_7 = 0x04;
VAR_8 = 0x947438CB;
__asm
("mthi %2, $ac1\n\t"
"mtlo %3, $ac1\n\t"
"maq_s.w.phr $ac1, %4, %5\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
: "=r"(VAR_5), "=r"(VAR_6)
: "r"(VAR_2), "r"(VAR_3), "r"(VAR_1), "r"(VAR_0)
);
assert(VAR_7 == VAR_5);
assert(VAR_8 == VAR_6);
VAR_2 = 0x06;
VAR_3 = 0xB4CB;
VAR_1 = 0x8000;
VAR_0 = 0x8000;
VAR_7 = 0x6;
VAR_8 = 0x8000b4ca;
VAR_9 = 1;
__asm
("mthi %3, $ac1\n\t"
"mtlo %4, $ac1\n\t"
"maq_s.w.phr $ac1, %5, %6\n\t"
"mfhi %0, $ac1\n\t"
"mflo %1, $ac1\n\t"
"rddsp %2\n\t"
: "=r"(VAR_5), "=r"(VAR_6), "=r"(VAR_4)
: "r"(VAR_2), "r"(VAR_3), "r"(VAR_1), "r"(VAR_0)
);
assert(VAR_7 == VAR_5);
assert(VAR_8 == VAR_6);
assert(((VAR_4 >> 17) & 0x01) == VAR_9);
return 0;
}
| [
"int FUNC_0()\n{",
"int VAR_0, VAR_1;",
"int VAR_2, VAR_3;",
"int VAR_4;",
"int VAR_5, VAR_6;",
"int VAR_7, VAR_8;",
"int VAR_9;",
"VAR_2 = 0x05;",
"VAR_3 = 0xB4CB;",
"VAR_1 = 0xFF06;",
"VAR_0 = 0xCB00;",
"VAR_7 = 0x04;",
"VAR_8 = 0x947438CB;",
"__asm\n(\"mthi %2, $ac1\\n\\t\"\n\"mtlo %3, $ac1\\n\\t\"\n\"maq_s.w.phr $ac1, %4, %5\\n\\t\"\n\"mfhi %0, $ac1\\n\\t\"\n\"mflo %1, $ac1\\n\\t\"\n: \"=r\"(VAR_5), \"=r\"(VAR_6)\n: \"r\"(VAR_2), \"r\"(VAR_3), \"r\"(VAR_1), \"r\"(VAR_0)\n);",
"assert(VAR_7 == VAR_5);",
"assert(VAR_8 == VAR_6);",
"VAR_2 = 0x06;",
"VAR_3 = 0xB4CB;",
"VAR_1 = 0x8000;",
"VAR_0 = 0x8000;",
"VAR_7 = 0x6;",
"VAR_8 = 0x8000b4ca;",
"VAR_9 = 1;",
"__asm\n(\"mthi %3, $ac1\\n\\t\"\n\"mtlo %4, $ac1\\n\\t\"\n\"maq_s.w.phr $ac1, %5, %6\\n\\t\"\n\"mfhi %0, $ac1\\n\\t\"\n\"mflo %1, $ac1\\n\\t\"\n\"rddsp %2\\n\\t\"\n: \"=r\"(VAR_5), \"=r\"(VAR_6), \"=r\"(VAR_4)\n: \"r\"(VAR_2), \"r\"(VAR_3), \"r\"(VAR_1), \"r\"(VAR_0)\n);",
"assert(VAR_7 == VAR_5);",
"assert(VAR_8 == VAR_6);",
"assert(((VAR_4 >> 17) & 0x01) == VAR_9);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37,
39,
41,
43,
45,
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75,
77,
79,
81,
83,
85,
87,
89,
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
]
] |
25,761 | int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
const char *version, const char *serial)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
s->bs = bs;
s->drive_kind = kind;
bdrv_get_geometry(bs, &nb_sectors);
bdrv_guess_geometry(bs, &cylinders, &heads, &secs);
if (cylinders < 1 || cylinders > 16383) {
error_report("cyls must be between 1 and 16383");
return -1;
}
if (heads < 1 || heads > 16) {
error_report("heads must be between 1 and 16");
return -1;
}
if (secs < 1 || secs > 63) {
error_report("secs must be between 1 and 63");
return -1;
}
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
s->nb_sectors = nb_sectors;
/* The SMART values should be preserved across power cycles
but they aren't. */
s->smart_enabled = 1;
s->smart_autosave = 1;
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (kind == IDE_CD) {
bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
bdrv_set_buffer_alignment(bs, 2048);
} else {
if (!bdrv_is_inserted(s->bs)) {
error_report("Device needs media, but drive is empty");
return -1;
}
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
return -1;
}
}
if (serial) {
strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
} else {
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial);
}
if (version) {
pstrcpy(s->version, sizeof(s->version), version);
} else {
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
}
ide_reset(s);
bdrv_iostatus_enable(bs);
return 0;
}
| false | qemu | 27e0c9a1bbd166a67c16291016fba298a8e47140 | int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
const char *version, const char *serial)
{
int cylinders, heads, secs;
uint64_t nb_sectors;
s->bs = bs;
s->drive_kind = kind;
bdrv_get_geometry(bs, &nb_sectors);
bdrv_guess_geometry(bs, &cylinders, &heads, &secs);
if (cylinders < 1 || cylinders > 16383) {
error_report("cyls must be between 1 and 16383");
return -1;
}
if (heads < 1 || heads > 16) {
error_report("heads must be between 1 and 16");
return -1;
}
if (secs < 1 || secs > 63) {
error_report("secs must be between 1 and 63");
return -1;
}
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
s->nb_sectors = nb_sectors;
s->smart_enabled = 1;
s->smart_autosave = 1;
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (kind == IDE_CD) {
bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
bdrv_set_buffer_alignment(bs, 2048);
} else {
if (!bdrv_is_inserted(s->bs)) {
error_report("Device needs media, but drive is empty");
return -1;
}
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
return -1;
}
}
if (serial) {
strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
} else {
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial);
}
if (version) {
pstrcpy(s->version, sizeof(s->version), version);
} else {
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
}
ide_reset(s);
bdrv_iostatus_enable(bs);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(IDEState *VAR_0, BlockDriverState *VAR_1, IDEDriveKind VAR_2,
const char *VAR_3, const char *VAR_4)
{
int VAR_5, VAR_6, VAR_7;
uint64_t nb_sectors;
VAR_0->VAR_1 = VAR_1;
VAR_0->drive_kind = VAR_2;
bdrv_get_geometry(VAR_1, &nb_sectors);
bdrv_guess_geometry(VAR_1, &VAR_5, &VAR_6, &VAR_7);
if (VAR_5 < 1 || VAR_5 > 16383) {
error_report("cyls must be between 1 and 16383");
return -1;
}
if (VAR_6 < 1 || VAR_6 > 16) {
error_report("VAR_6 must be between 1 and 16");
return -1;
}
if (VAR_7 < 1 || VAR_7 > 63) {
error_report("VAR_7 must be between 1 and 63");
return -1;
}
VAR_0->VAR_5 = VAR_5;
VAR_0->VAR_6 = VAR_6;
VAR_0->sectors = VAR_7;
VAR_0->nb_sectors = nb_sectors;
VAR_0->smart_enabled = 1;
VAR_0->smart_autosave = 1;
VAR_0->smart_errors = 0;
VAR_0->smart_selftest_count = 0;
if (VAR_2 == IDE_CD) {
bdrv_set_dev_ops(VAR_1, &ide_cd_block_ops, VAR_0);
bdrv_set_buffer_alignment(VAR_1, 2048);
} else {
if (!bdrv_is_inserted(VAR_0->VAR_1)) {
error_report("Device needs media, but drive is empty");
return -1;
}
if (bdrv_is_read_only(VAR_1)) {
error_report("Can't use a read-only drive");
return -1;
}
}
if (VAR_4) {
strncpy(VAR_0->drive_serial_str, VAR_4, sizeof(VAR_0->drive_serial_str));
} else {
snprintf(VAR_0->drive_serial_str, sizeof(VAR_0->drive_serial_str),
"QM%05d", VAR_0->drive_serial);
}
if (VAR_3) {
pstrcpy(VAR_0->VAR_3, sizeof(VAR_0->VAR_3), VAR_3);
} else {
pstrcpy(VAR_0->VAR_3, sizeof(VAR_0->VAR_3), QEMU_VERSION);
}
ide_reset(VAR_0);
bdrv_iostatus_enable(VAR_1);
return 0;
}
| [
"int FUNC_0(IDEState *VAR_0, BlockDriverState *VAR_1, IDEDriveKind VAR_2,\nconst char *VAR_3, const char *VAR_4)\n{",
"int VAR_5, VAR_6, VAR_7;",
"uint64_t nb_sectors;",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->drive_kind = VAR_2;",
"bdrv_get_geometry(VAR_1, &nb_sectors);",
"bdrv_guess_geometry(VAR_1, &VAR_5, &VAR_6, &VAR_7);",
"if (VAR_5 < 1 || VAR_5 > 16383) {",
"error_report(\"cyls must be between 1 and 16383\");",
"return -1;",
"}",
"if (VAR_6 < 1 || VAR_6 > 16) {",
"error_report(\"VAR_6 must be between 1 and 16\");",
"return -1;",
"}",
"if (VAR_7 < 1 || VAR_7 > 63) {",
"error_report(\"VAR_7 must be between 1 and 63\");",
"return -1;",
"}",
"VAR_0->VAR_5 = VAR_5;",
"VAR_0->VAR_6 = VAR_6;",
"VAR_0->sectors = VAR_7;",
"VAR_0->nb_sectors = nb_sectors;",
"VAR_0->smart_enabled = 1;",
"VAR_0->smart_autosave = 1;",
"VAR_0->smart_errors = 0;",
"VAR_0->smart_selftest_count = 0;",
"if (VAR_2 == IDE_CD) {",
"bdrv_set_dev_ops(VAR_1, &ide_cd_block_ops, VAR_0);",
"bdrv_set_buffer_alignment(VAR_1, 2048);",
"} else {",
"if (!bdrv_is_inserted(VAR_0->VAR_1)) {",
"error_report(\"Device needs media, but drive is empty\");",
"return -1;",
"}",
"if (bdrv_is_read_only(VAR_1)) {",
"error_report(\"Can't use a read-only drive\");",
"return -1;",
"}",
"}",
"if (VAR_4) {",
"strncpy(VAR_0->drive_serial_str, VAR_4, sizeof(VAR_0->drive_serial_str));",
"} else {",
"snprintf(VAR_0->drive_serial_str, sizeof(VAR_0->drive_serial_str),\n\"QM%05d\", VAR_0->drive_serial);",
"}",
"if (VAR_3) {",
"pstrcpy(VAR_0->VAR_3, sizeof(VAR_0->VAR_3), VAR_3);",
"} else {",
"pstrcpy(VAR_0->VAR_3, sizeof(VAR_0->VAR_3), QEMU_VERSION);",
"}",
"ide_reset(VAR_0);",
"bdrv_iostatus_enable(VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
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
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
25,762 | int subch_device_load(SubchDev *s, QEMUFile *f)
{
SubchDev *old_s;
Error *err = NULL;
uint16_t old_schid = s->schid;
uint16_t old_devno = s->devno;
int i;
s->cssid = qemu_get_byte(f);
s->ssid = qemu_get_byte(f);
s->schid = qemu_get_be16(f);
s->devno = qemu_get_be16(f);
if (s->devno != old_devno) {
/* Only possible if machine < 2.7 (no css_dev_path) */
error_setg(&err, "%x != %x", old_devno, s->devno);
error_append_hint(&err, "Devno mismatch, tried to load wrong section!"
" Likely reason: some sequences of plug and unplug"
" can break migration for machine versions prior to"
" 2.7 (known design flaw).\n");
error_report_err(err);
return -EINVAL;
}
/* Re-assign subch. */
if (old_schid != s->schid) {
old_s = channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_schid];
/*
* (old_s != s) means that some other device has its correct
* subchannel already assigned (in load).
*/
if (old_s == s) {
css_subch_assign(s->cssid, s->ssid, old_schid, s->devno, NULL);
}
/* It's OK to re-assign without a prior de-assign. */
css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s);
}
s->thinint_active = qemu_get_byte(f);
/* SCHIB */
/* PMCW */
s->curr_status.pmcw.intparm = qemu_get_be32(f);
s->curr_status.pmcw.flags = qemu_get_be16(f);
s->curr_status.pmcw.devno = qemu_get_be16(f);
s->curr_status.pmcw.lpm = qemu_get_byte(f);
s->curr_status.pmcw.pnom = qemu_get_byte(f);
s->curr_status.pmcw.lpum = qemu_get_byte(f);
s->curr_status.pmcw.pim = qemu_get_byte(f);
s->curr_status.pmcw.mbi = qemu_get_be16(f);
s->curr_status.pmcw.pom = qemu_get_byte(f);
s->curr_status.pmcw.pam = qemu_get_byte(f);
qemu_get_buffer(f, s->curr_status.pmcw.chpid, 8);
s->curr_status.pmcw.chars = qemu_get_be32(f);
/* SCSW */
s->curr_status.scsw.flags = qemu_get_be16(f);
s->curr_status.scsw.ctrl = qemu_get_be16(f);
s->curr_status.scsw.cpa = qemu_get_be32(f);
s->curr_status.scsw.dstat = qemu_get_byte(f);
s->curr_status.scsw.cstat = qemu_get_byte(f);
s->curr_status.scsw.count = qemu_get_be16(f);
s->curr_status.mba = qemu_get_be64(f);
qemu_get_buffer(f, s->curr_status.mda, 4);
/* end SCHIB */
qemu_get_buffer(f, s->sense_data, 32);
s->channel_prog = qemu_get_be64(f);
/* last cmd */
s->last_cmd.cmd_code = qemu_get_byte(f);
s->last_cmd.flags = qemu_get_byte(f);
s->last_cmd.count = qemu_get_be16(f);
s->last_cmd.cda = qemu_get_be32(f);
s->last_cmd_valid = qemu_get_byte(f);
s->id.reserved = qemu_get_byte(f);
s->id.cu_type = qemu_get_be16(f);
s->id.cu_model = qemu_get_byte(f);
s->id.dev_type = qemu_get_be16(f);
s->id.dev_model = qemu_get_byte(f);
s->id.unused = qemu_get_byte(f);
for (i = 0; i < ARRAY_SIZE(s->id.ciw); i++) {
s->id.ciw[i].type = qemu_get_byte(f);
s->id.ciw[i].command = qemu_get_byte(f);
s->id.ciw[i].count = qemu_get_be16(f);
}
s->ccw_fmt_1 = qemu_get_byte(f);
s->ccw_no_data_cnt = qemu_get_byte(f);
/*
* Hack alert. We don't migrate the channel subsystem status (no
* device!), but we need to find out if the guest enabled mss/mcss-e.
* If the subchannel is enabled, it certainly was able to access it,
* so adjust the max_ssid/max_cssid values for relevant ssid/cssid
* values. This is not watertight, but better than nothing.
*/
if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {
if (s->ssid) {
channel_subsys.max_ssid = MAX_SSID;
}
if (s->cssid != channel_subsys.default_cssid) {
channel_subsys.max_cssid = MAX_CSSID;
}
}
return 0;
}
| false | qemu | 517ff12c7d000fa1f5b1e989b22fb86a286f9cc2 | int subch_device_load(SubchDev *s, QEMUFile *f)
{
SubchDev *old_s;
Error *err = NULL;
uint16_t old_schid = s->schid;
uint16_t old_devno = s->devno;
int i;
s->cssid = qemu_get_byte(f);
s->ssid = qemu_get_byte(f);
s->schid = qemu_get_be16(f);
s->devno = qemu_get_be16(f);
if (s->devno != old_devno) {
error_setg(&err, "%x != %x", old_devno, s->devno);
error_append_hint(&err, "Devno mismatch, tried to load wrong section!"
" Likely reason: some sequences of plug and unplug"
" can break migration for machine versions prior to"
" 2.7 (known design flaw).\n");
error_report_err(err);
return -EINVAL;
}
if (old_schid != s->schid) {
old_s = channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_schid];
if (old_s == s) {
css_subch_assign(s->cssid, s->ssid, old_schid, s->devno, NULL);
}
css_subch_assign(s->cssid, s->ssid, s->schid, s->devno, s);
}
s->thinint_active = qemu_get_byte(f);
s->curr_status.pmcw.intparm = qemu_get_be32(f);
s->curr_status.pmcw.flags = qemu_get_be16(f);
s->curr_status.pmcw.devno = qemu_get_be16(f);
s->curr_status.pmcw.lpm = qemu_get_byte(f);
s->curr_status.pmcw.pnom = qemu_get_byte(f);
s->curr_status.pmcw.lpum = qemu_get_byte(f);
s->curr_status.pmcw.pim = qemu_get_byte(f);
s->curr_status.pmcw.mbi = qemu_get_be16(f);
s->curr_status.pmcw.pom = qemu_get_byte(f);
s->curr_status.pmcw.pam = qemu_get_byte(f);
qemu_get_buffer(f, s->curr_status.pmcw.chpid, 8);
s->curr_status.pmcw.chars = qemu_get_be32(f);
s->curr_status.scsw.flags = qemu_get_be16(f);
s->curr_status.scsw.ctrl = qemu_get_be16(f);
s->curr_status.scsw.cpa = qemu_get_be32(f);
s->curr_status.scsw.dstat = qemu_get_byte(f);
s->curr_status.scsw.cstat = qemu_get_byte(f);
s->curr_status.scsw.count = qemu_get_be16(f);
s->curr_status.mba = qemu_get_be64(f);
qemu_get_buffer(f, s->curr_status.mda, 4);
qemu_get_buffer(f, s->sense_data, 32);
s->channel_prog = qemu_get_be64(f);
s->last_cmd.cmd_code = qemu_get_byte(f);
s->last_cmd.flags = qemu_get_byte(f);
s->last_cmd.count = qemu_get_be16(f);
s->last_cmd.cda = qemu_get_be32(f);
s->last_cmd_valid = qemu_get_byte(f);
s->id.reserved = qemu_get_byte(f);
s->id.cu_type = qemu_get_be16(f);
s->id.cu_model = qemu_get_byte(f);
s->id.dev_type = qemu_get_be16(f);
s->id.dev_model = qemu_get_byte(f);
s->id.unused = qemu_get_byte(f);
for (i = 0; i < ARRAY_SIZE(s->id.ciw); i++) {
s->id.ciw[i].type = qemu_get_byte(f);
s->id.ciw[i].command = qemu_get_byte(f);
s->id.ciw[i].count = qemu_get_be16(f);
}
s->ccw_fmt_1 = qemu_get_byte(f);
s->ccw_no_data_cnt = qemu_get_byte(f);
if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {
if (s->ssid) {
channel_subsys.max_ssid = MAX_SSID;
}
if (s->cssid != channel_subsys.default_cssid) {
channel_subsys.max_cssid = MAX_CSSID;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(SubchDev *VAR_0, QEMUFile *VAR_1)
{
SubchDev *old_s;
Error *err = NULL;
uint16_t old_schid = VAR_0->schid;
uint16_t old_devno = VAR_0->devno;
int VAR_2;
VAR_0->cssid = qemu_get_byte(VAR_1);
VAR_0->ssid = qemu_get_byte(VAR_1);
VAR_0->schid = qemu_get_be16(VAR_1);
VAR_0->devno = qemu_get_be16(VAR_1);
if (VAR_0->devno != old_devno) {
error_setg(&err, "%x != %x", old_devno, VAR_0->devno);
error_append_hint(&err, "Devno mismatch, tried to load wrong section!"
" Likely reason: some sequences of plug and unplug"
" can break migration for machine versions prior to"
" 2.7 (known design flaw).\n");
error_report_err(err);
return -EINVAL;
}
if (old_schid != VAR_0->schid) {
old_s = channel_subsys.css[VAR_0->cssid]->sch_set[VAR_0->ssid]->sch[old_schid];
if (old_s == VAR_0) {
css_subch_assign(VAR_0->cssid, VAR_0->ssid, old_schid, VAR_0->devno, NULL);
}
css_subch_assign(VAR_0->cssid, VAR_0->ssid, VAR_0->schid, VAR_0->devno, VAR_0);
}
VAR_0->thinint_active = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.intparm = qemu_get_be32(VAR_1);
VAR_0->curr_status.pmcw.flags = qemu_get_be16(VAR_1);
VAR_0->curr_status.pmcw.devno = qemu_get_be16(VAR_1);
VAR_0->curr_status.pmcw.lpm = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.pnom = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.lpum = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.pim = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.mbi = qemu_get_be16(VAR_1);
VAR_0->curr_status.pmcw.pom = qemu_get_byte(VAR_1);
VAR_0->curr_status.pmcw.pam = qemu_get_byte(VAR_1);
qemu_get_buffer(VAR_1, VAR_0->curr_status.pmcw.chpid, 8);
VAR_0->curr_status.pmcw.chars = qemu_get_be32(VAR_1);
VAR_0->curr_status.scsw.flags = qemu_get_be16(VAR_1);
VAR_0->curr_status.scsw.ctrl = qemu_get_be16(VAR_1);
VAR_0->curr_status.scsw.cpa = qemu_get_be32(VAR_1);
VAR_0->curr_status.scsw.dstat = qemu_get_byte(VAR_1);
VAR_0->curr_status.scsw.cstat = qemu_get_byte(VAR_1);
VAR_0->curr_status.scsw.count = qemu_get_be16(VAR_1);
VAR_0->curr_status.mba = qemu_get_be64(VAR_1);
qemu_get_buffer(VAR_1, VAR_0->curr_status.mda, 4);
qemu_get_buffer(VAR_1, VAR_0->sense_data, 32);
VAR_0->channel_prog = qemu_get_be64(VAR_1);
VAR_0->last_cmd.cmd_code = qemu_get_byte(VAR_1);
VAR_0->last_cmd.flags = qemu_get_byte(VAR_1);
VAR_0->last_cmd.count = qemu_get_be16(VAR_1);
VAR_0->last_cmd.cda = qemu_get_be32(VAR_1);
VAR_0->last_cmd_valid = qemu_get_byte(VAR_1);
VAR_0->id.reserved = qemu_get_byte(VAR_1);
VAR_0->id.cu_type = qemu_get_be16(VAR_1);
VAR_0->id.cu_model = qemu_get_byte(VAR_1);
VAR_0->id.dev_type = qemu_get_be16(VAR_1);
VAR_0->id.dev_model = qemu_get_byte(VAR_1);
VAR_0->id.unused = qemu_get_byte(VAR_1);
for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_0->id.ciw); VAR_2++) {
VAR_0->id.ciw[VAR_2].type = qemu_get_byte(VAR_1);
VAR_0->id.ciw[VAR_2].command = qemu_get_byte(VAR_1);
VAR_0->id.ciw[VAR_2].count = qemu_get_be16(VAR_1);
}
VAR_0->ccw_fmt_1 = qemu_get_byte(VAR_1);
VAR_0->ccw_no_data_cnt = qemu_get_byte(VAR_1);
if (VAR_0->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {
if (VAR_0->ssid) {
channel_subsys.max_ssid = MAX_SSID;
}
if (VAR_0->cssid != channel_subsys.default_cssid) {
channel_subsys.max_cssid = MAX_CSSID;
}
}
return 0;
}
| [
"int FUNC_0(SubchDev *VAR_0, QEMUFile *VAR_1)\n{",
"SubchDev *old_s;",
"Error *err = NULL;",
"uint16_t old_schid = VAR_0->schid;",
"uint16_t old_devno = VAR_0->devno;",
"int VAR_2;",
"VAR_0->cssid = qemu_get_byte(VAR_1);",
"VAR_0->ssid = qemu_get_byte(VAR_1);",
"VAR_0->schid = qemu_get_be16(VAR_1);",
"VAR_0->devno = qemu_get_be16(VAR_1);",
"if (VAR_0->devno != old_devno) {",
"error_setg(&err, \"%x != %x\", old_devno, VAR_0->devno);",
"error_append_hint(&err, \"Devno mismatch, tried to load wrong section!\"\n\" Likely reason: some sequences of plug and unplug\"\n\" can break migration for machine versions prior to\"\n\" 2.7 (known design flaw).\\n\");",
"error_report_err(err);",
"return -EINVAL;",
"}",
"if (old_schid != VAR_0->schid) {",
"old_s = channel_subsys.css[VAR_0->cssid]->sch_set[VAR_0->ssid]->sch[old_schid];",
"if (old_s == VAR_0) {",
"css_subch_assign(VAR_0->cssid, VAR_0->ssid, old_schid, VAR_0->devno, NULL);",
"}",
"css_subch_assign(VAR_0->cssid, VAR_0->ssid, VAR_0->schid, VAR_0->devno, VAR_0);",
"}",
"VAR_0->thinint_active = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.intparm = qemu_get_be32(VAR_1);",
"VAR_0->curr_status.pmcw.flags = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.pmcw.devno = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.pmcw.lpm = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.pnom = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.lpum = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.pim = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.mbi = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.pmcw.pom = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.pmcw.pam = qemu_get_byte(VAR_1);",
"qemu_get_buffer(VAR_1, VAR_0->curr_status.pmcw.chpid, 8);",
"VAR_0->curr_status.pmcw.chars = qemu_get_be32(VAR_1);",
"VAR_0->curr_status.scsw.flags = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.scsw.ctrl = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.scsw.cpa = qemu_get_be32(VAR_1);",
"VAR_0->curr_status.scsw.dstat = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.scsw.cstat = qemu_get_byte(VAR_1);",
"VAR_0->curr_status.scsw.count = qemu_get_be16(VAR_1);",
"VAR_0->curr_status.mba = qemu_get_be64(VAR_1);",
"qemu_get_buffer(VAR_1, VAR_0->curr_status.mda, 4);",
"qemu_get_buffer(VAR_1, VAR_0->sense_data, 32);",
"VAR_0->channel_prog = qemu_get_be64(VAR_1);",
"VAR_0->last_cmd.cmd_code = qemu_get_byte(VAR_1);",
"VAR_0->last_cmd.flags = qemu_get_byte(VAR_1);",
"VAR_0->last_cmd.count = qemu_get_be16(VAR_1);",
"VAR_0->last_cmd.cda = qemu_get_be32(VAR_1);",
"VAR_0->last_cmd_valid = qemu_get_byte(VAR_1);",
"VAR_0->id.reserved = qemu_get_byte(VAR_1);",
"VAR_0->id.cu_type = qemu_get_be16(VAR_1);",
"VAR_0->id.cu_model = qemu_get_byte(VAR_1);",
"VAR_0->id.dev_type = qemu_get_be16(VAR_1);",
"VAR_0->id.dev_model = qemu_get_byte(VAR_1);",
"VAR_0->id.unused = qemu_get_byte(VAR_1);",
"for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_0->id.ciw); VAR_2++) {",
"VAR_0->id.ciw[VAR_2].type = qemu_get_byte(VAR_1);",
"VAR_0->id.ciw[VAR_2].command = qemu_get_byte(VAR_1);",
"VAR_0->id.ciw[VAR_2].count = qemu_get_be16(VAR_1);",
"}",
"VAR_0->ccw_fmt_1 = qemu_get_byte(VAR_1);",
"VAR_0->ccw_no_data_cnt = qemu_get_byte(VAR_1);",
"if (VAR_0->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {",
"if (VAR_0->ssid) {",
"channel_subsys.max_ssid = MAX_SSID;",
"}",
"if (VAR_0->cssid != channel_subsys.default_cssid) {",
"channel_subsys.max_cssid = MAX_CSSID;",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33,
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.