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
|
---|---|---|---|---|---|---|---|---|---|---|
27,249 | static int ehci_state_waitlisthead(EHCIState *ehci, int async)
{
EHCIqh qh;
int i = 0;
int again = 0;
uint32_t entry = ehci->asynclistaddr;
/* set reclamation flag at start event (4.8.6) */
if (async) {
ehci_set_usbsts(ehci, USBSTS_REC);
}
ehci_queues_rip_unused(ehci, async, 0);
/* Find the head of the list (4.9.1.1) */
for(i = 0; i < MAX_QH; i++) {
get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (async) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(ehci, async, entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
again = 1;
goto out;
}
entry = qh.next;
if (entry == ehci->asynclistaddr) {
break;
}
}
/* no head found for list. */
ehci_set_state(ehci, async, EST_ACTIVE);
out:
return again;
}
| false | qemu | 9bc3a3a216e2689bfcdd36c3e079333bbdbf3ba0 | static int ehci_state_waitlisthead(EHCIState *ehci, int async)
{
EHCIqh qh;
int i = 0;
int again = 0;
uint32_t entry = ehci->asynclistaddr;
if (async) {
ehci_set_usbsts(ehci, USBSTS_REC);
}
ehci_queues_rip_unused(ehci, async, 0);
for(i = 0; i < MAX_QH; i++) {
get_dwords(ehci, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (async) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(ehci, async, entry);
ehci_set_state(ehci, async, EST_FETCHENTRY);
again = 1;
goto out;
}
entry = qh.next;
if (entry == ehci->asynclistaddr) {
break;
}
}
ehci_set_state(ehci, async, EST_ACTIVE);
out:
return again;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(EHCIState *VAR_0, int VAR_1)
{
EHCIqh qh;
int VAR_2 = 0;
int VAR_3 = 0;
uint32_t entry = VAR_0->asynclistaddr;
if (VAR_1) {
ehci_set_usbsts(VAR_0, USBSTS_REC);
}
ehci_queues_rip_unused(VAR_0, VAR_1, 0);
for(VAR_2 = 0; VAR_2 < MAX_QH; VAR_2++) {
get_dwords(VAR_0, NLPTR_GET(entry), (uint32_t *) &qh,
sizeof(EHCIqh) >> 2);
ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);
if (qh.epchar & QH_EPCHAR_H) {
if (VAR_1) {
entry |= (NLPTR_TYPE_QH << 1);
}
ehci_set_fetch_addr(VAR_0, VAR_1, entry);
ehci_set_state(VAR_0, VAR_1, EST_FETCHENTRY);
VAR_3 = 1;
goto out;
}
entry = qh.next;
if (entry == VAR_0->asynclistaddr) {
break;
}
}
ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);
out:
return VAR_3;
}
| [
"static int FUNC_0(EHCIState *VAR_0, int VAR_1)\n{",
"EHCIqh qh;",
"int VAR_2 = 0;",
"int VAR_3 = 0;",
"uint32_t entry = VAR_0->asynclistaddr;",
"if (VAR_1) {",
"ehci_set_usbsts(VAR_0, USBSTS_REC);",
"}",
"ehci_queues_rip_unused(VAR_0, VAR_1, 0);",
"for(VAR_2 = 0; VAR_2 < MAX_QH; VAR_2++) {",
"get_dwords(VAR_0, NLPTR_GET(entry), (uint32_t *) &qh,\nsizeof(EHCIqh) >> 2);",
"ehci_trace_qh(NULL, NLPTR_GET(entry), &qh);",
"if (qh.epchar & QH_EPCHAR_H) {",
"if (VAR_1) {",
"entry |= (NLPTR_TYPE_QH << 1);",
"}",
"ehci_set_fetch_addr(VAR_0, VAR_1, entry);",
"ehci_set_state(VAR_0, VAR_1, EST_FETCHENTRY);",
"VAR_3 = 1;",
"goto out;",
"}",
"entry = qh.next;",
"if (entry == VAR_0->asynclistaddr) {",
"break;",
"}",
"}",
"ehci_set_state(VAR_0, VAR_1, EST_ACTIVE);",
"out:\nreturn 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19
],
[
21
],
[
25
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
79
],
[
83,
85
],
[
87
]
] |
27,250 | static void gen_rdhwr(DisasContext *ctx, int rt, int rd)
{
TCGv t0;
#if !defined(CONFIG_USER_ONLY)
/* The Linux kernel will emulate rdhwr if it's not supported natively.
Therefore only check the ISA in system mode. */
check_insn(ctx, ISA_MIPS32R2);
#endif
t0 = tcg_temp_new();
switch (rd) {
case 0:
gen_helper_rdhwr_cpunum(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 1:
gen_helper_rdhwr_synci_step(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 2:
gen_helper_rdhwr_cc(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 3:
gen_helper_rdhwr_ccres(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 29:
#if defined(CONFIG_USER_ONLY)
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, rt);
break;
#else
if ((ctx->hflags & MIPS_HFLAG_CP0) ||
(ctx->hflags & MIPS_HFLAG_HWRENA_ULR)) {
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, rt);
} else {
generate_exception_end(ctx, EXCP_RI);
}
break;
#endif
default: /* Invalid */
MIPS_INVAL("rdhwr");
generate_exception_end(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
| false | qemu | b00c72180c36510bf9b124e190bd520e3b7e1358 | static void gen_rdhwr(DisasContext *ctx, int rt, int rd)
{
TCGv t0;
#if !defined(CONFIG_USER_ONLY)
check_insn(ctx, ISA_MIPS32R2);
#endif
t0 = tcg_temp_new();
switch (rd) {
case 0:
gen_helper_rdhwr_cpunum(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 1:
gen_helper_rdhwr_synci_step(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 2:
gen_helper_rdhwr_cc(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 3:
gen_helper_rdhwr_ccres(t0, cpu_env);
gen_store_gpr(t0, rt);
break;
case 29:
#if defined(CONFIG_USER_ONLY)
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, rt);
break;
#else
if ((ctx->hflags & MIPS_HFLAG_CP0) ||
(ctx->hflags & MIPS_HFLAG_HWRENA_ULR)) {
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, rt);
} else {
generate_exception_end(ctx, EXCP_RI);
}
break;
#endif
default:
MIPS_INVAL("rdhwr");
generate_exception_end(ctx, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)
{
TCGv t0;
#if !defined(CONFIG_USER_ONLY)
check_insn(VAR_0, ISA_MIPS32R2);
#endif
t0 = tcg_temp_new();
switch (VAR_2) {
case 0:
gen_helper_rdhwr_cpunum(t0, cpu_env);
gen_store_gpr(t0, VAR_1);
break;
case 1:
gen_helper_rdhwr_synci_step(t0, cpu_env);
gen_store_gpr(t0, VAR_1);
break;
case 2:
gen_helper_rdhwr_cc(t0, cpu_env);
gen_store_gpr(t0, VAR_1);
break;
case 3:
gen_helper_rdhwr_ccres(t0, cpu_env);
gen_store_gpr(t0, VAR_1);
break;
case 29:
#if defined(CONFIG_USER_ONLY)
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, VAR_1);
break;
#else
if ((VAR_0->hflags & MIPS_HFLAG_CP0) ||
(VAR_0->hflags & MIPS_HFLAG_HWRENA_ULR)) {
tcg_gen_ld_tl(t0, cpu_env,
offsetof(CPUMIPSState, active_tc.CP0_UserLocal));
gen_store_gpr(t0, VAR_1);
} else {
generate_exception_end(VAR_0, EXCP_RI);
}
break;
#endif
default:
MIPS_INVAL("rdhwr");
generate_exception_end(VAR_0, EXCP_RI);
break;
}
tcg_temp_free(t0);
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, int VAR_2)\n{",
"TCGv t0;",
"#if !defined(CONFIG_USER_ONLY)\ncheck_insn(VAR_0, ISA_MIPS32R2);",
"#endif\nt0 = tcg_temp_new();",
"switch (VAR_2) {",
"case 0:\ngen_helper_rdhwr_cpunum(t0, cpu_env);",
"gen_store_gpr(t0, VAR_1);",
"break;",
"case 1:\ngen_helper_rdhwr_synci_step(t0, cpu_env);",
"gen_store_gpr(t0, VAR_1);",
"break;",
"case 2:\ngen_helper_rdhwr_cc(t0, cpu_env);",
"gen_store_gpr(t0, VAR_1);",
"break;",
"case 3:\ngen_helper_rdhwr_ccres(t0, cpu_env);",
"gen_store_gpr(t0, VAR_1);",
"break;",
"case 29:\n#if defined(CONFIG_USER_ONLY)\ntcg_gen_ld_tl(t0, cpu_env,\noffsetof(CPUMIPSState, active_tc.CP0_UserLocal));",
"gen_store_gpr(t0, VAR_1);",
"break;",
"#else\nif ((VAR_0->hflags & MIPS_HFLAG_CP0) ||\n(VAR_0->hflags & MIPS_HFLAG_HWRENA_ULR)) {",
"tcg_gen_ld_tl(t0, cpu_env,\noffsetof(CPUMIPSState, active_tc.CP0_UserLocal));",
"gen_store_gpr(t0, VAR_1);",
"} else {",
"generate_exception_end(VAR_0, EXCP_RI);",
"}",
"break;",
"#endif\ndefault:\nMIPS_INVAL(\"rdhwr\");",
"generate_exception_end(VAR_0, EXCP_RI);",
"break;",
"}",
"tcg_temp_free(t0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
15
],
[
17,
19
],
[
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
]
] |
27,251 | Aml *aml_shiftright(Aml *arg1, Aml *count)
{
Aml *var = aml_opcode(0x7A /* ShiftRightOp */);
aml_append(var, arg1);
aml_append(var, count);
build_append_byte(var->buf, 0x00); /* NullNameOp */
return var;
}
| false | qemu | 439e2a6e10ed7f5da819bf7dcaa54b8cfdbeab0d | Aml *aml_shiftright(Aml *arg1, Aml *count)
{
Aml *var = aml_opcode(0x7A );
aml_append(var, arg1);
aml_append(var, count);
build_append_byte(var->buf, 0x00);
return var;
}
| {
"code": [],
"line_no": []
} | Aml *FUNC_0(Aml *arg1, Aml *count)
{
Aml *var = aml_opcode(0x7A );
aml_append(var, arg1);
aml_append(var, count);
build_append_byte(var->buf, 0x00);
return var;
}
| [
"Aml *FUNC_0(Aml *arg1, Aml *count)\n{",
"Aml *var = aml_opcode(0x7A );",
"aml_append(var, arg1);",
"aml_append(var, count);",
"build_append_byte(var->buf, 0x00);",
"return var;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
27,252 | static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb)
{
int ret = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque;
if (s->has_write_zeroes == 0) {
return -ENOTSUP;
}
if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
#ifdef BLKZEROOUT
do {
uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
return 0;
}
} while (errno == EINTR);
ret = -errno;
#endif
} else {
#ifdef CONFIG_XFS
if (s->is_xfs) {
return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);
}
#endif
}
ret = translate_err(ret);
if (ret == -ENOTSUP) {
s->has_write_zeroes = false;
}
return ret;
}
| false | qemu | 37cc9f7f684ed035da63274daca1594c7ee16213 | static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb)
{
int ret = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque;
if (s->has_write_zeroes == 0) {
return -ENOTSUP;
}
if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
#ifdef BLKZEROOUT
do {
uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
return 0;
}
} while (errno == EINTR);
ret = -errno;
#endif
} else {
#ifdef CONFIG_XFS
if (s->is_xfs) {
return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);
}
#endif
}
ret = translate_err(ret);
if (ret == -ENOTSUP) {
s->has_write_zeroes = false;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(RawPosixAIOData *aiocb)
{
int VAR_0 = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque;
if (s->has_write_zeroes == 0) {
return -ENOTSUP;
}
if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
#ifdef BLKZEROOUT
do {
uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
return 0;
}
} while (errno == EINTR);
VAR_0 = -errno;
#endif
} else {
#ifdef CONFIG_XFS
if (s->is_xfs) {
return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);
}
#endif
}
VAR_0 = translate_err(VAR_0);
if (VAR_0 == -ENOTSUP) {
s->has_write_zeroes = false;
}
return VAR_0;
}
| [
"static ssize_t FUNC_0(RawPosixAIOData *aiocb)\n{",
"int VAR_0 = -EOPNOTSUPP;",
"BDRVRawState *s = aiocb->bs->opaque;",
"if (s->has_write_zeroes == 0) {",
"return -ENOTSUP;",
"}",
"if (aiocb->aio_type & QEMU_AIO_BLKDEV) {",
"#ifdef BLKZEROOUT\ndo {",
"uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };",
"if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {",
"return 0;",
"}",
"} while (errno == EINTR);",
"VAR_0 = -errno;",
"#endif\n} else {",
"#ifdef CONFIG_XFS\nif (s->is_xfs) {",
"return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);",
"}",
"#endif\n}",
"VAR_0 = translate_err(VAR_0);",
"if (VAR_0 == -ENOTSUP) {",
"s->has_write_zeroes = false;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
27,253 | int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int flags, BlockDriver *drv, Error **errp)
{
int ret;
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
char tmp_filename[PATH_MAX + 1];
BlockDriverState *file = NULL;
QDict *file_options = NULL;
const char *drvname;
Error *local_err = NULL;
/* NULL means an empty set of options */
if (options == NULL) {
options = qdict_new();
}
bs->options = options;
options = qdict_clone_shallow(options);
/* For snapshot=on, create a temporary qcow2 overlay */
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *create_options;
char backing_filename[PATH_MAX];
if (qdict_size(options) != 0) {
error_setg(errp, "Can't use snapshot=on with driver-specific options");
ret = -EINVAL;
goto fail;
}
assert(filename != NULL);
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
/* if there is a backing file, use it */
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err);
if (ret < 0) {
bdrv_unref(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
bdrv_unref(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not get temporary filename");
goto fail;
}
/* Real path is meaningless for protocols */
if (path_has_protocol(filename)) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
} else if (!realpath(filename, backing_filename)) {
ret = -errno;
error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
create_options = parse_option_parameters("", bdrv_qcow2->create_options,
NULL);
set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE,
backing_filename);
if (drv) {
set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options, &local_err);
free_option_parameters(create_options);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not create temporary overlay "
"'%s': %s", tmp_filename,
error_get_pretty(local_err));
error_free(local_err);
local_err = NULL;
goto fail;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
/* Open image file without format layer */
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
qdict_extract_subqdict(options, &file_options, "file.");
ret = bdrv_file_open(&file, filename, file_options,
bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &local_err);
if (ret < 0) {
goto fail;
}
/* Find the right image format driver */
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
qdict_del(options, "driver");
if (!drv) {
error_setg(errp, "Invalid driver: '%s'", drvname);
ret = -EINVAL;
goto unlink_and_fail;
}
}
if (!drv) {
ret = find_image_format(file, filename, &drv, &local_err);
}
if (!drv) {
goto unlink_and_fail;
}
/* Open the image */
ret = bdrv_open_common(bs, file, options, flags, drv, &local_err);
if (ret < 0) {
goto unlink_and_fail;
}
if (bs->file != file) {
bdrv_unref(file);
file = NULL;
}
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(options, &backing_options, "backing.");
ret = bdrv_open_backing_file(bs, backing_options, &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
/* Check if any unknown options were used */
if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
error_setg(errp, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", drv->format_name, bs->device_name,
entry->key);
ret = -EINVAL;
goto close_and_fail;
}
QDECREF(options);
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_unref(file);
}
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
}
return ret;
close_and_fail:
bdrv_close(bs);
QDECREF(options);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
}
return ret;
}
| false | qemu | 9fd3171af9d7de2777bf38ce79c2fe3dd6f9a49e | int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int flags, BlockDriver *drv, Error **errp)
{
int ret;
char tmp_filename[PATH_MAX + 1];
BlockDriverState *file = NULL;
QDict *file_options = NULL;
const char *drvname;
Error *local_err = NULL;
if (options == NULL) {
options = qdict_new();
}
bs->options = options;
options = qdict_clone_shallow(options);
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *create_options;
char backing_filename[PATH_MAX];
if (qdict_size(options) != 0) {
error_setg(errp, "Can't use snapshot=on with driver-specific options");
ret = -EINVAL;
goto fail;
}
assert(filename != NULL);
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err);
if (ret < 0) {
bdrv_unref(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
bdrv_unref(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not get temporary filename");
goto fail;
}
if (path_has_protocol(filename)) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
} else if (!realpath(filename, backing_filename)) {
ret = -errno;
error_setg_errno(errp, errno, "Could not resolve path '%s'", filename);
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
create_options = parse_option_parameters("", bdrv_qcow2->create_options,
NULL);
set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE,
backing_filename);
if (drv) {
set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, create_options, &local_err);
free_option_parameters(create_options);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not create temporary overlay "
"'%s': %s", tmp_filename,
error_get_pretty(local_err));
error_free(local_err);
local_err = NULL;
goto fail;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
qdict_extract_subqdict(options, &file_options, "file.");
ret = bdrv_file_open(&file, filename, file_options,
bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &local_err);
if (ret < 0) {
goto fail;
}
drvname = qdict_get_try_str(options, "driver");
if (drvname) {
drv = bdrv_find_format(drvname);
qdict_del(options, "driver");
if (!drv) {
error_setg(errp, "Invalid driver: '%s'", drvname);
ret = -EINVAL;
goto unlink_and_fail;
}
}
if (!drv) {
ret = find_image_format(file, filename, &drv, &local_err);
}
if (!drv) {
goto unlink_and_fail;
}
ret = bdrv_open_common(bs, file, options, flags, drv, &local_err);
if (ret < 0) {
goto unlink_and_fail;
}
if (bs->file != file) {
bdrv_unref(file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(options, &backing_options, "backing.");
ret = bdrv_open_backing_file(bs, backing_options, &local_err);
if (ret < 0) {
goto close_and_fail;
}
}
if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
error_setg(errp, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", drv->format_name, bs->device_name,
entry->key);
ret = -EINVAL;
goto close_and_fail;
}
QDECREF(options);
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_unref(file);
}
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
}
return ret;
close_and_fail:
bdrv_close(bs);
QDECREF(options);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
}
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, QDict *VAR_2,
int VAR_3, BlockDriver *VAR_4, Error **VAR_5)
{
int VAR_6;
char VAR_7[PATH_MAX + 1];
BlockDriverState *file = NULL;
QDict *file_options = NULL;
const char *VAR_8;
Error *local_err = NULL;
if (VAR_2 == NULL) {
VAR_2 = qdict_new();
}
VAR_0->VAR_2 = VAR_2;
VAR_2 = qdict_clone_shallow(VAR_2);
if (VAR_3 & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *create_options;
char VAR_9[PATH_MAX];
if (qdict_size(VAR_2) != 0) {
error_setg(VAR_5, "Can't use snapshot=on with driver-specific VAR_2");
VAR_6 = -EINVAL;
goto fail;
}
assert(VAR_1 != NULL);
bs1 = bdrv_new("");
VAR_6 = FUNC_0(bs1, VAR_1, NULL, 0, VAR_4, &local_err);
if (VAR_6 < 0) {
bdrv_unref(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
bdrv_unref(bs1);
VAR_6 = get_tmp_filename(VAR_7, sizeof(VAR_7));
if (VAR_6 < 0) {
error_setg_errno(VAR_5, -VAR_6, "Could not get temporary VAR_1");
goto fail;
}
if (path_has_protocol(VAR_1)) {
snprintf(VAR_9, sizeof(VAR_9),
"%s", VAR_1);
} else if (!realpath(VAR_1, VAR_9)) {
VAR_6 = -errno;
error_setg_errno(VAR_5, errno, "Could not resolve path '%s'", VAR_1);
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
create_options = parse_option_parameters("", bdrv_qcow2->create_options,
NULL);
set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE,
VAR_9);
if (VAR_4) {
set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT,
VAR_4->format_name);
}
VAR_6 = bdrv_create(bdrv_qcow2, VAR_7, create_options, &local_err);
free_option_parameters(create_options);
if (VAR_6 < 0) {
error_setg_errno(VAR_5, -VAR_6, "Could not create temporary overlay "
"'%s': %s", VAR_7,
error_get_pretty(local_err));
error_free(local_err);
local_err = NULL;
goto fail;
}
VAR_1 = VAR_7;
VAR_4 = bdrv_qcow2;
VAR_0->is_temporary = 1;
}
if (VAR_3 & BDRV_O_RDWR) {
VAR_3 |= BDRV_O_ALLOW_RDWR;
}
qdict_extract_subqdict(VAR_2, &file_options, "file.");
VAR_6 = bdrv_file_open(&file, VAR_1, file_options,
bdrv_open_flags(VAR_0, VAR_3 | BDRV_O_UNMAP), &local_err);
if (VAR_6 < 0) {
goto fail;
}
VAR_8 = qdict_get_try_str(VAR_2, "driver");
if (VAR_8) {
VAR_4 = bdrv_find_format(VAR_8);
qdict_del(VAR_2, "driver");
if (!VAR_4) {
error_setg(VAR_5, "Invalid driver: '%s'", VAR_8);
VAR_6 = -EINVAL;
goto unlink_and_fail;
}
}
if (!VAR_4) {
VAR_6 = find_image_format(file, VAR_1, &VAR_4, &local_err);
}
if (!VAR_4) {
goto unlink_and_fail;
}
VAR_6 = bdrv_open_common(VAR_0, file, VAR_2, VAR_3, VAR_4, &local_err);
if (VAR_6 < 0) {
goto unlink_and_fail;
}
if (VAR_0->file != file) {
bdrv_unref(file);
file = NULL;
}
if ((VAR_3 & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
qdict_extract_subqdict(VAR_2, &backing_options, "backing.");
VAR_6 = bdrv_open_backing_file(VAR_0, backing_options, &local_err);
if (VAR_6 < 0) {
goto close_and_fail;
}
}
if (qdict_size(VAR_2) != 0) {
const QDictEntry *VAR_10 = qdict_first(VAR_2);
error_setg(VAR_5, "Block format '%s' used by device '%s' doesn't "
"support the option '%s'", VAR_4->format_name, VAR_0->device_name,
VAR_10->key);
VAR_6 = -EINVAL;
goto close_and_fail;
}
QDECREF(VAR_2);
if (!bdrv_key_required(VAR_0)) {
bdrv_dev_change_media_cb(VAR_0, true);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_unref(file);
}
if (VAR_0->is_temporary) {
unlink(VAR_1);
}
fail:
QDECREF(VAR_0->VAR_2);
QDECREF(VAR_2);
VAR_0->VAR_2 = NULL;
if (error_is_set(&local_err)) {
error_propagate(VAR_5, local_err);
}
return VAR_6;
close_and_fail:
bdrv_close(VAR_0);
QDECREF(VAR_2);
if (error_is_set(&local_err)) {
error_propagate(VAR_5, local_err);
}
return VAR_6;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, QDict *VAR_2,\nint VAR_3, BlockDriver *VAR_4, Error **VAR_5)\n{",
"int VAR_6;",
"char VAR_7[PATH_MAX + 1];",
"BlockDriverState *file = NULL;",
"QDict *file_options = NULL;",
"const char *VAR_8;",
"Error *local_err = NULL;",
"if (VAR_2 == NULL) {",
"VAR_2 = qdict_new();",
"}",
"VAR_0->VAR_2 = VAR_2;",
"VAR_2 = qdict_clone_shallow(VAR_2);",
"if (VAR_3 & BDRV_O_SNAPSHOT) {",
"BlockDriverState *bs1;",
"int64_t total_size;",
"BlockDriver *bdrv_qcow2;",
"QEMUOptionParameter *create_options;",
"char VAR_9[PATH_MAX];",
"if (qdict_size(VAR_2) != 0) {",
"error_setg(VAR_5, \"Can't use snapshot=on with driver-specific VAR_2\");",
"VAR_6 = -EINVAL;",
"goto fail;",
"}",
"assert(VAR_1 != NULL);",
"bs1 = bdrv_new(\"\");",
"VAR_6 = FUNC_0(bs1, VAR_1, NULL, 0, VAR_4, &local_err);",
"if (VAR_6 < 0) {",
"bdrv_unref(bs1);",
"goto fail;",
"}",
"total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;",
"bdrv_unref(bs1);",
"VAR_6 = get_tmp_filename(VAR_7, sizeof(VAR_7));",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not get temporary VAR_1\");",
"goto fail;",
"}",
"if (path_has_protocol(VAR_1)) {",
"snprintf(VAR_9, sizeof(VAR_9),\n\"%s\", VAR_1);",
"} else if (!realpath(VAR_1, VAR_9)) {",
"VAR_6 = -errno;",
"error_setg_errno(VAR_5, errno, \"Could not resolve path '%s'\", VAR_1);",
"goto fail;",
"}",
"bdrv_qcow2 = bdrv_find_format(\"qcow2\");",
"create_options = parse_option_parameters(\"\", bdrv_qcow2->create_options,\nNULL);",
"set_option_parameter_int(create_options, BLOCK_OPT_SIZE, total_size);",
"set_option_parameter(create_options, BLOCK_OPT_BACKING_FILE,\nVAR_9);",
"if (VAR_4) {",
"set_option_parameter(create_options, BLOCK_OPT_BACKING_FMT,\nVAR_4->format_name);",
"}",
"VAR_6 = bdrv_create(bdrv_qcow2, VAR_7, create_options, &local_err);",
"free_option_parameters(create_options);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not create temporary overlay \"\n\"'%s': %s\", VAR_7,\nerror_get_pretty(local_err));",
"error_free(local_err);",
"local_err = NULL;",
"goto fail;",
"}",
"VAR_1 = VAR_7;",
"VAR_4 = bdrv_qcow2;",
"VAR_0->is_temporary = 1;",
"}",
"if (VAR_3 & BDRV_O_RDWR) {",
"VAR_3 |= BDRV_O_ALLOW_RDWR;",
"}",
"qdict_extract_subqdict(VAR_2, &file_options, \"file.\");",
"VAR_6 = bdrv_file_open(&file, VAR_1, file_options,\nbdrv_open_flags(VAR_0, VAR_3 | BDRV_O_UNMAP), &local_err);",
"if (VAR_6 < 0) {",
"goto fail;",
"}",
"VAR_8 = qdict_get_try_str(VAR_2, \"driver\");",
"if (VAR_8) {",
"VAR_4 = bdrv_find_format(VAR_8);",
"qdict_del(VAR_2, \"driver\");",
"if (!VAR_4) {",
"error_setg(VAR_5, \"Invalid driver: '%s'\", VAR_8);",
"VAR_6 = -EINVAL;",
"goto unlink_and_fail;",
"}",
"}",
"if (!VAR_4) {",
"VAR_6 = find_image_format(file, VAR_1, &VAR_4, &local_err);",
"}",
"if (!VAR_4) {",
"goto unlink_and_fail;",
"}",
"VAR_6 = bdrv_open_common(VAR_0, file, VAR_2, VAR_3, VAR_4, &local_err);",
"if (VAR_6 < 0) {",
"goto unlink_and_fail;",
"}",
"if (VAR_0->file != file) {",
"bdrv_unref(file);",
"file = NULL;",
"}",
"if ((VAR_3 & BDRV_O_NO_BACKING) == 0) {",
"QDict *backing_options;",
"qdict_extract_subqdict(VAR_2, &backing_options, \"backing.\");",
"VAR_6 = bdrv_open_backing_file(VAR_0, backing_options, &local_err);",
"if (VAR_6 < 0) {",
"goto close_and_fail;",
"}",
"}",
"if (qdict_size(VAR_2) != 0) {",
"const QDictEntry *VAR_10 = qdict_first(VAR_2);",
"error_setg(VAR_5, \"Block format '%s' used by device '%s' doesn't \"\n\"support the option '%s'\", VAR_4->format_name, VAR_0->device_name,\nVAR_10->key);",
"VAR_6 = -EINVAL;",
"goto close_and_fail;",
"}",
"QDECREF(VAR_2);",
"if (!bdrv_key_required(VAR_0)) {",
"bdrv_dev_change_media_cb(VAR_0, true);",
"}",
"return 0;",
"unlink_and_fail:\nif (file != NULL) {",
"bdrv_unref(file);",
"}",
"if (VAR_0->is_temporary) {",
"unlink(VAR_1);",
"}",
"fail:\nQDECREF(VAR_0->VAR_2);",
"QDECREF(VAR_2);",
"VAR_0->VAR_2 = NULL;",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_5, local_err);",
"}",
"return VAR_6;",
"close_and_fail:\nbdrv_close(VAR_0);",
"QDECREF(VAR_2);",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_5, local_err);",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131,
133
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159,
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
191
],
[
195
],
[
199,
201
],
[
203
],
[
205
],
[
207
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
],
[
239
],
[
243
],
[
245
],
[
247
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
269
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
297
],
[
299
],
[
301,
303,
305
],
[
309
],
[
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
327
],
[
331,
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
]
] |
27,255 | static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int dst_stride[3], int src_stride[3], int width, int height){
int x, y, i;
for(i=0; i<3; i++){
p->frame->data[i]= src[i];
p->frame->linesize[i]= src_stride[i];
}
p->avctx_enc->me_cmp=
p->avctx_enc->me_sub_cmp= FF_CMP_SAD /*| (p->parity ? FF_CMP_ODD : FF_CMP_EVEN)*/;
p->frame->quality= p->qp*FF_QP2LAMBDA;
avcodec_encode_video(p->avctx_enc, p->outbuf, p->outbuf_size, p->frame);
p->frame_dec = p->avctx_enc->coded_frame;
for(i=0; i<3; i++){
int is_chroma= !!i;
int w= width >>is_chroma;
int h= height>>is_chroma;
int fils= p->frame_dec->linesize[i];
int srcs= src_stride[i];
for(y=0; y<h; y++){
if((y ^ p->parity) & 1){
for(x=0; x<w; x++){
if((x-2)+(y-1)*w>=0 && (x+2)+(y+1)*w<w*h){ //FIXME either alloc larger images or optimize this
uint8_t *filp= &p->frame_dec->data[i][x + y*fils];
uint8_t *srcp= &src[i][x + y*srcs];
int diff0= filp[-fils] - srcp[-srcs];
int diff1= filp[+fils] - srcp[+srcs];
int spatial_score= ABS(srcp[-srcs-1] - srcp[+srcs-1])
+ABS(srcp[-srcs ] - srcp[+srcs ])
+ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 1;
int temp= filp[0];
#define CHECK(j)\
{ int score= ABS(srcp[-srcs-1+(j)] - srcp[+srcs-1-(j)])\
+ ABS(srcp[-srcs +(j)] - srcp[+srcs -(j)])\
+ ABS(srcp[-srcs+1+(j)] - srcp[+srcs+1-(j)]);\
if(score < spatial_score){\
spatial_score= score;\
diff0= filp[-fils+(j)] - srcp[-srcs+(j)];\
diff1= filp[+fils-(j)] - srcp[+srcs-(j)];
CHECK(-1) CHECK(-2) }} }}
CHECK( 1) CHECK( 2) }} }}
| false | FFmpeg | 3a2b9911bffeffc3fc0541df3b4f6d492e122714 | static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int dst_stride[3], int src_stride[3], int width, int height){
int x, y, i;
for(i=0; i<3; i++){
p->frame->data[i]= src[i];
p->frame->linesize[i]= src_stride[i];
}
p->avctx_enc->me_cmp=
p->avctx_enc->me_sub_cmp= FF_CMP_SAD ;
p->frame->quality= p->qp*FF_QP2LAMBDA;
avcodec_encode_video(p->avctx_enc, p->outbuf, p->outbuf_size, p->frame);
p->frame_dec = p->avctx_enc->coded_frame;
for(i=0; i<3; i++){
int is_chroma= !!i;
int w= width >>is_chroma;
int h= height>>is_chroma;
int fils= p->frame_dec->linesize[i];
int srcs= src_stride[i];
for(y=0; y<h; y++){
if((y ^ p->parity) & 1){
for(x=0; x<w; x++){
if((x-2)+(y-1)*w>=0 && (x+2)+(y+1)*w<w*h){
uint8_t *filp= &p->frame_dec->data[i][x + y*fils];
uint8_t *srcp= &src[i][x + y*srcs];
int diff0= filp[-fils] - srcp[-srcs];
int diff1= filp[+fils] - srcp[+srcs];
int spatial_score= ABS(srcp[-srcs-1] - srcp[+srcs-1])
+ABS(srcp[-srcs ] - srcp[+srcs ])
+ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 1;
int temp= filp[0];
#define CHECK(j)\
{ int score= ABS(srcp[-srcs-1+(j)] - srcp[+srcs-1-(j)])\
+ ABS(srcp[-srcs +(j)] - srcp[+srcs -(j)])\
+ ABS(srcp[-srcs+1+(j)] - srcp[+srcs+1-(j)]);\
if(score < spatial_score){\
spatial_score= score;\
diff0= filp[-fils+(j)] - srcp[-srcs+(j)];\
diff1= filp[+fils-(j)] - srcp[+srcs-(j)];
CHECK(-1) CHECK(-2) }} }}
CHECK( 1) CHECK( 2) }} }}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct vf_priv_s *VAR_0, uint8_t *VAR_1[3], uint8_t *VAR_2[3], int VAR_3[3], int VAR_4[3], int VAR_5, int VAR_6){
int VAR_7, VAR_8, VAR_9;
for(VAR_9=0; VAR_9<3; VAR_9++){
VAR_0->frame->data[VAR_9]= VAR_2[VAR_9];
VAR_0->frame->linesize[VAR_9]= VAR_4[VAR_9];
}
VAR_0->avctx_enc->me_cmp=
VAR_0->avctx_enc->me_sub_cmp= FF_CMP_SAD ;
VAR_0->frame->quality= VAR_0->qp*FF_QP2LAMBDA;
avcodec_encode_video(VAR_0->avctx_enc, VAR_0->outbuf, VAR_0->outbuf_size, VAR_0->frame);
VAR_0->frame_dec = VAR_0->avctx_enc->coded_frame;
for(VAR_9=0; VAR_9<3; VAR_9++){
int VAR_10= !!VAR_9;
int VAR_11= VAR_5 >>VAR_10;
int VAR_12= VAR_6>>VAR_10;
int VAR_13= VAR_0->frame_dec->linesize[VAR_9];
int VAR_14= VAR_4[VAR_9];
for(VAR_8=0; VAR_8<VAR_12; VAR_8++){
if((VAR_8 ^ VAR_0->parity) & 1){
for(VAR_7=0; VAR_7<VAR_11; VAR_7++){
if((VAR_7-2)+(VAR_8-1)*VAR_11>=0 && (VAR_7+2)+(VAR_8+1)*VAR_11<VAR_11*VAR_12){
uint8_t *filp= &VAR_0->frame_dec->data[VAR_9][VAR_7 + VAR_8*VAR_13];
uint8_t *srcp= &VAR_2[VAR_9][VAR_7 + VAR_8*VAR_14];
int VAR_15= filp[-VAR_13] - srcp[-VAR_14];
int VAR_16= filp[+VAR_13] - srcp[+VAR_14];
int VAR_17= ABS(srcp[-VAR_14-1] - srcp[+VAR_14-1])
+ABS(srcp[-VAR_14 ] - srcp[+VAR_14 ])
+ABS(srcp[-VAR_14+1] - srcp[+VAR_14+1]) - 1;
int VAR_18= filp[0];
#define CHECK(j)\
{ int VAR_19= ABS(srcp[-VAR_14-1+(j)] - srcp[+VAR_14-1-(j)])\
+ ABS(srcp[-VAR_14 +(j)] - srcp[+VAR_14 -(j)])\
+ ABS(srcp[-VAR_14+1+(j)] - srcp[+VAR_14+1-(j)]);\
if(VAR_19 < VAR_17){\
VAR_17= VAR_19;\
VAR_15= filp[-VAR_13+(j)] - srcp[-VAR_14+(j)];\
VAR_16= filp[+VAR_13-(j)] - srcp[+VAR_14-(j)];
CHECK(-1) CHECK(-2) }} }}
CHECK( 1) CHECK( 2) }} }}
| [
"static void FUNC_0(struct vf_priv_s *VAR_0, uint8_t *VAR_1[3], uint8_t *VAR_2[3], int VAR_3[3], int VAR_4[3], int VAR_5, int VAR_6){",
"int VAR_7, VAR_8, VAR_9;",
"for(VAR_9=0; VAR_9<3; VAR_9++){",
"VAR_0->frame->data[VAR_9]= VAR_2[VAR_9];",
"VAR_0->frame->linesize[VAR_9]= VAR_4[VAR_9];",
"}",
"VAR_0->avctx_enc->me_cmp=\nVAR_0->avctx_enc->me_sub_cmp= FF_CMP_SAD ;",
"VAR_0->frame->quality= VAR_0->qp*FF_QP2LAMBDA;",
"avcodec_encode_video(VAR_0->avctx_enc, VAR_0->outbuf, VAR_0->outbuf_size, VAR_0->frame);",
"VAR_0->frame_dec = VAR_0->avctx_enc->coded_frame;",
"for(VAR_9=0; VAR_9<3; VAR_9++){",
"int VAR_10= !!VAR_9;",
"int VAR_11= VAR_5 >>VAR_10;",
"int VAR_12= VAR_6>>VAR_10;",
"int VAR_13= VAR_0->frame_dec->linesize[VAR_9];",
"int VAR_14= VAR_4[VAR_9];",
"for(VAR_8=0; VAR_8<VAR_12; VAR_8++){",
"if((VAR_8 ^ VAR_0->parity) & 1){",
"for(VAR_7=0; VAR_7<VAR_11; VAR_7++){",
"if((VAR_7-2)+(VAR_8-1)*VAR_11>=0 && (VAR_7+2)+(VAR_8+1)*VAR_11<VAR_11*VAR_12){",
"uint8_t *filp= &VAR_0->frame_dec->data[VAR_9][VAR_7 + VAR_8*VAR_13];",
"uint8_t *srcp= &VAR_2[VAR_9][VAR_7 + VAR_8*VAR_14];",
"int VAR_15= filp[-VAR_13] - srcp[-VAR_14];",
"int VAR_16= filp[+VAR_13] - srcp[+VAR_14];",
"int VAR_17= ABS(srcp[-VAR_14-1] - srcp[+VAR_14-1])\n+ABS(srcp[-VAR_14 ] - srcp[+VAR_14 ])\n+ABS(srcp[-VAR_14+1] - srcp[+VAR_14+1]) - 1;",
"int VAR_18= filp[0];",
"#define CHECK(j)\\\n{ int VAR_19= ABS(srcp[-VAR_14-1+(j)] - srcp[+VAR_14-1-(j)])\\",
"+ ABS(srcp[-VAR_14 +(j)] - srcp[+VAR_14 -(j)])\\\n+ ABS(srcp[-VAR_14+1+(j)] - srcp[+VAR_14+1-(j)]);\\",
"if(VAR_19 < VAR_17){\\",
"VAR_17= VAR_19;\\",
"VAR_15= filp[-VAR_13+(j)] - srcp[-VAR_14+(j)];\\",
"VAR_16= filp[+VAR_13-(j)] - srcp[+VAR_14-(j)];",
"CHECK(-1) CHECK(-2) }} }}",
"CHECK( 1) CHECK( 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
] | [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61,
63
],
[
65
],
[
69,
71
],
[
73,
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
27,258 | static void test_qga_config(gconstpointer data)
{
GError *error = NULL;
char *cwd, *cmd, *out, *err, *str, **strv, **argv = NULL;
char *env[2];
int status;
gsize n;
GKeyFile *kf;
cwd = g_get_current_dir();
cmd = g_strdup_printf("%s%cqemu-ga -D",
cwd, G_DIR_SEPARATOR);
g_shell_parse_argv(cmd, NULL, &argv, &error);
g_assert_no_error(error);
env[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config",
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
env[1] = NULL;
g_spawn_sync(NULL, argv, env, 0,
NULL, NULL, &out, &err, &status, &error);
g_strfreev(argv);
g_assert_no_error(error);
g_assert_cmpstr(err, ==, "");
g_assert_cmpint(status, ==, 0);
kf = g_key_file_new();
g_key_file_load_from_data(kf, out, -1, G_KEY_FILE_NONE, &error);
g_assert_no_error(error);
str = g_key_file_get_start_group(kf);
g_assert_cmpstr(str, ==, "general");
g_free(str);
g_assert_false(g_key_file_get_boolean(kf, "general", "daemon", &error));
g_assert_no_error(error);
str = g_key_file_get_string(kf, "general", "method", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "virtio-serial");
g_free(str);
str = g_key_file_get_string(kf, "general", "path", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/path/to/org.qemu.guest_agent.0");
g_free(str);
str = g_key_file_get_string(kf, "general", "pidfile", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/var/foo/qemu-ga.pid");
g_free(str);
str = g_key_file_get_string(kf, "general", "statedir", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/var/state");
g_free(str);
g_assert_true(g_key_file_get_boolean(kf, "general", "verbose", &error));
g_assert_no_error(error);
strv = g_key_file_get_string_list(kf, "general", "blacklist", &n, &error);
g_assert_cmpint(n, ==, 2);
#if GLIB_CHECK_VERSION(2, 44, 0)
g_assert_true(g_strv_contains((const char * const *)strv,
"guest-ping"));
g_assert_true(g_strv_contains((const char * const *)strv,
"guest-get-time"));
#endif
g_assert_no_error(error);
g_strfreev(strv);
g_free(out);
g_free(err);
g_free(env[0]);
g_key_file_free(kf);
} | true | qemu | 1e2713384c58037ad44f716c31c08daca18862c5 | static void test_qga_config(gconstpointer data)
{
GError *error = NULL;
char *cwd, *cmd, *out, *err, *str, **strv, **argv = NULL;
char *env[2];
int status;
gsize n;
GKeyFile *kf;
cwd = g_get_current_dir();
cmd = g_strdup_printf("%s%cqemu-ga -D",
cwd, G_DIR_SEPARATOR);
g_shell_parse_argv(cmd, NULL, &argv, &error);
g_assert_no_error(error);
env[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config",
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
env[1] = NULL;
g_spawn_sync(NULL, argv, env, 0,
NULL, NULL, &out, &err, &status, &error);
g_strfreev(argv);
g_assert_no_error(error);
g_assert_cmpstr(err, ==, "");
g_assert_cmpint(status, ==, 0);
kf = g_key_file_new();
g_key_file_load_from_data(kf, out, -1, G_KEY_FILE_NONE, &error);
g_assert_no_error(error);
str = g_key_file_get_start_group(kf);
g_assert_cmpstr(str, ==, "general");
g_free(str);
g_assert_false(g_key_file_get_boolean(kf, "general", "daemon", &error));
g_assert_no_error(error);
str = g_key_file_get_string(kf, "general", "method", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "virtio-serial");
g_free(str);
str = g_key_file_get_string(kf, "general", "path", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/path/to/org.qemu.guest_agent.0");
g_free(str);
str = g_key_file_get_string(kf, "general", "pidfile", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/var/foo/qemu-ga.pid");
g_free(str);
str = g_key_file_get_string(kf, "general", "statedir", &error);
g_assert_no_error(error);
g_assert_cmpstr(str, ==, "/var/state");
g_free(str);
g_assert_true(g_key_file_get_boolean(kf, "general", "verbose", &error));
g_assert_no_error(error);
strv = g_key_file_get_string_list(kf, "general", "blacklist", &n, &error);
g_assert_cmpint(n, ==, 2);
#if GLIB_CHECK_VERSION(2, 44, 0)
g_assert_true(g_strv_contains((const char * const *)strv,
"guest-ping"));
g_assert_true(g_strv_contains((const char * const *)strv,
"guest-get-time"));
#endif
g_assert_no_error(error);
g_strfreev(strv);
g_free(out);
g_free(err);
g_free(env[0]);
g_key_file_free(kf);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(gconstpointer VAR_0)
{
GError *error = NULL;
char *VAR_1, *VAR_2, *VAR_3, *VAR_4, *VAR_5, **VAR_6, **VAR_7 = NULL;
char *VAR_8[2];
int VAR_9;
gsize n;
GKeyFile *kf;
VAR_1 = g_get_current_dir();
VAR_2 = g_strdup_printf("%s%cqemu-ga -D",
VAR_1, G_DIR_SEPARATOR);
g_shell_parse_argv(VAR_2, NULL, &VAR_7, &error);
g_assert_no_error(error);
VAR_8[0] = g_strdup_printf("QGA_CONF=tests%cdata%ctest-qga-config",
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
VAR_8[1] = NULL;
g_spawn_sync(NULL, VAR_7, VAR_8, 0,
NULL, NULL, &VAR_3, &VAR_4, &VAR_9, &error);
g_strfreev(VAR_7);
g_assert_no_error(error);
g_assert_cmpstr(VAR_4, ==, "");
g_assert_cmpint(VAR_9, ==, 0);
kf = g_key_file_new();
g_key_file_load_from_data(kf, VAR_3, -1, G_KEY_FILE_NONE, &error);
g_assert_no_error(error);
VAR_5 = g_key_file_get_start_group(kf);
g_assert_cmpstr(VAR_5, ==, "general");
g_free(VAR_5);
g_assert_false(g_key_file_get_boolean(kf, "general", "daemon", &error));
g_assert_no_error(error);
VAR_5 = g_key_file_get_string(kf, "general", "method", &error);
g_assert_no_error(error);
g_assert_cmpstr(VAR_5, ==, "virtio-serial");
g_free(VAR_5);
VAR_5 = g_key_file_get_string(kf, "general", "path", &error);
g_assert_no_error(error);
g_assert_cmpstr(VAR_5, ==, "/path/to/org.qemu.guest_agent.0");
g_free(VAR_5);
VAR_5 = g_key_file_get_string(kf, "general", "pidfile", &error);
g_assert_no_error(error);
g_assert_cmpstr(VAR_5, ==, "/var/foo/qemu-ga.pid");
g_free(VAR_5);
VAR_5 = g_key_file_get_string(kf, "general", "statedir", &error);
g_assert_no_error(error);
g_assert_cmpstr(VAR_5, ==, "/var/state");
g_free(VAR_5);
g_assert_true(g_key_file_get_boolean(kf, "general", "verbose", &error));
g_assert_no_error(error);
VAR_6 = g_key_file_get_string_list(kf, "general", "blacklist", &n, &error);
g_assert_cmpint(n, ==, 2);
#if GLIB_CHECK_VERSION(2, 44, 0)
g_assert_true(g_strv_contains((const char * const *)VAR_6,
"guest-ping"));
g_assert_true(g_strv_contains((const char * const *)VAR_6,
"guest-get-time"));
#endif
g_assert_no_error(error);
g_strfreev(VAR_6);
g_free(VAR_3);
g_free(VAR_4);
g_free(VAR_8[0]);
g_key_file_free(kf);
} | [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"GError *error = NULL;",
"char *VAR_1, *VAR_2, *VAR_3, *VAR_4, *VAR_5, **VAR_6, **VAR_7 = NULL;",
"char *VAR_8[2];",
"int VAR_9;",
"gsize n;",
"GKeyFile *kf;",
"VAR_1 = g_get_current_dir();",
"VAR_2 = g_strdup_printf(\"%s%cqemu-ga -D\",\nVAR_1, G_DIR_SEPARATOR);",
"g_shell_parse_argv(VAR_2, NULL, &VAR_7, &error);",
"g_assert_no_error(error);",
"VAR_8[0] = g_strdup_printf(\"QGA_CONF=tests%cdata%ctest-qga-config\",\nG_DIR_SEPARATOR, G_DIR_SEPARATOR);",
"VAR_8[1] = NULL;",
"g_spawn_sync(NULL, VAR_7, VAR_8, 0,\nNULL, NULL, &VAR_3, &VAR_4, &VAR_9, &error);",
"g_strfreev(VAR_7);",
"g_assert_no_error(error);",
"g_assert_cmpstr(VAR_4, ==, \"\");",
"g_assert_cmpint(VAR_9, ==, 0);",
"kf = g_key_file_new();",
"g_key_file_load_from_data(kf, VAR_3, -1, G_KEY_FILE_NONE, &error);",
"g_assert_no_error(error);",
"VAR_5 = g_key_file_get_start_group(kf);",
"g_assert_cmpstr(VAR_5, ==, \"general\");",
"g_free(VAR_5);",
"g_assert_false(g_key_file_get_boolean(kf, \"general\", \"daemon\", &error));",
"g_assert_no_error(error);",
"VAR_5 = g_key_file_get_string(kf, \"general\", \"method\", &error);",
"g_assert_no_error(error);",
"g_assert_cmpstr(VAR_5, ==, \"virtio-serial\");",
"g_free(VAR_5);",
"VAR_5 = g_key_file_get_string(kf, \"general\", \"path\", &error);",
"g_assert_no_error(error);",
"g_assert_cmpstr(VAR_5, ==, \"/path/to/org.qemu.guest_agent.0\");",
"g_free(VAR_5);",
"VAR_5 = g_key_file_get_string(kf, \"general\", \"pidfile\", &error);",
"g_assert_no_error(error);",
"g_assert_cmpstr(VAR_5, ==, \"/var/foo/qemu-ga.pid\");",
"g_free(VAR_5);",
"VAR_5 = g_key_file_get_string(kf, \"general\", \"statedir\", &error);",
"g_assert_no_error(error);",
"g_assert_cmpstr(VAR_5, ==, \"/var/state\");",
"g_free(VAR_5);",
"g_assert_true(g_key_file_get_boolean(kf, \"general\", \"verbose\", &error));",
"g_assert_no_error(error);",
"VAR_6 = g_key_file_get_string_list(kf, \"general\", \"blacklist\", &n, &error);",
"g_assert_cmpint(n, ==, 2);",
"#if GLIB_CHECK_VERSION(2, 44, 0)\ng_assert_true(g_strv_contains((const char * const *)VAR_6,\n\"guest-ping\"));",
"g_assert_true(g_strv_contains((const char * const *)VAR_6,\n\"guest-get-time\"));",
"#endif\ng_assert_no_error(error);",
"g_strfreev(VAR_6);",
"g_free(VAR_3);",
"g_free(VAR_4);",
"g_free(VAR_8[0]);",
"g_key_file_free(kf);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
26
],
[
29
],
[
33,
35
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133,
135
],
[
137,
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
]
] |
27,260 | static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
pkt->stream_index = 0;
return 0;
} | true | FFmpeg | 7effbee66cf457c62f795d9b9ed3a1110b364b89 | static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
pkt->stream_index = 0;
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
if (av_get_packet(VAR_0->pb, VAR_1, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
VAR_1->stream_index = 0;
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"if (av_get_packet(VAR_0->pb, VAR_1, MAX_READ_SIZE) <= 0)\nreturn AVERROR(EIO);",
"VAR_1->stream_index = 0;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
10
],
[
12
],
[
14
]
] |
27,262 | void helper_fitoq(CPUSPARCState *env, int32_t src)
{
/* No possible exceptions converting int to long double. */
QT0 = int32_to_float128(src, &env->fp_status);
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | void helper_fitoq(CPUSPARCState *env, int32_t src)
{
QT0 = int32_to_float128(src, &env->fp_status);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUSPARCState *VAR_0, int32_t VAR_1)
{
QT0 = int32_to_float128(VAR_1, &VAR_0->fp_status);
}
| [
"void FUNC_0(CPUSPARCState *VAR_0, int32_t VAR_1)\n{",
"QT0 = int32_to_float128(VAR_1, &VAR_0->fp_status);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
]
] |
27,263 | int gdbserver_start(const char *device)
{
GDBState *s;
char gdbstub_device_name[128];
CharDriverState *chr = NULL;
CharDriverState *mon_chr;
if (!device)
return -1;
if (strcmp(device, "none") != 0) {
if (strstart(device, "tcp:", NULL)) {
/* enforce required TCP attributes */
snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
"%s,nowait,nodelay,server", device);
device = gdbstub_device_name;
}
#ifndef _WIN32
else if (strcmp(device, "stdio") == 0) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = gdb_sigterm_handler;
sigaction(SIGINT, &act, NULL);
}
#endif
chr = qemu_chr_new("gdb", device, NULL);
if (!chr)
return -1;
qemu_chr_fe_claim_no_fail(chr);
qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
gdb_chr_event, NULL);
}
s = gdbserver_state;
if (!s) {
s = g_malloc0(sizeof(GDBState));
gdbserver_state = s;
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
/* Initialize a monitor terminal for gdb */
mon_chr = qemu_chr_alloc();
mon_chr->chr_write = gdb_monitor_write;
monitor_init(mon_chr, 0);
} else {
if (s->chr)
qemu_chr_delete(s->chr);
mon_chr = s->mon_chr;
memset(s, 0, sizeof(GDBState));
}
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
s->state = chr ? RS_IDLE : RS_INACTIVE;
s->mon_chr = mon_chr;
s->current_syscall_cb = NULL;
return 0;
}
| false | qemu | d0d7708ba29cbcc343364a46bff981e0ff88366f | int gdbserver_start(const char *device)
{
GDBState *s;
char gdbstub_device_name[128];
CharDriverState *chr = NULL;
CharDriverState *mon_chr;
if (!device)
return -1;
if (strcmp(device, "none") != 0) {
if (strstart(device, "tcp:", NULL)) {
snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
"%s,nowait,nodelay,server", device);
device = gdbstub_device_name;
}
#ifndef _WIN32
else if (strcmp(device, "stdio") == 0) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = gdb_sigterm_handler;
sigaction(SIGINT, &act, NULL);
}
#endif
chr = qemu_chr_new("gdb", device, NULL);
if (!chr)
return -1;
qemu_chr_fe_claim_no_fail(chr);
qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
gdb_chr_event, NULL);
}
s = gdbserver_state;
if (!s) {
s = g_malloc0(sizeof(GDBState));
gdbserver_state = s;
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
mon_chr = qemu_chr_alloc();
mon_chr->chr_write = gdb_monitor_write;
monitor_init(mon_chr, 0);
} else {
if (s->chr)
qemu_chr_delete(s->chr);
mon_chr = s->mon_chr;
memset(s, 0, sizeof(GDBState));
}
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
s->state = chr ? RS_IDLE : RS_INACTIVE;
s->mon_chr = mon_chr;
s->current_syscall_cb = NULL;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(const char *VAR_0)
{
GDBState *s;
char VAR_1[128];
CharDriverState *chr = NULL;
CharDriverState *mon_chr;
if (!VAR_0)
return -1;
if (strcmp(VAR_0, "none") != 0) {
if (strstart(VAR_0, "tcp:", NULL)) {
snprintf(VAR_1, sizeof(VAR_1),
"%s,nowait,nodelay,server", VAR_0);
VAR_0 = VAR_1;
}
#ifndef _WIN32
else if (strcmp(VAR_0, "stdio") == 0) {
struct sigaction VAR_2;
memset(&VAR_2, 0, sizeof(VAR_2));
VAR_2.sa_handler = gdb_sigterm_handler;
sigaction(SIGINT, &VAR_2, NULL);
}
#endif
chr = qemu_chr_new("gdb", VAR_0, NULL);
if (!chr)
return -1;
qemu_chr_fe_claim_no_fail(chr);
qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,
gdb_chr_event, NULL);
}
s = gdbserver_state;
if (!s) {
s = g_malloc0(sizeof(GDBState));
gdbserver_state = s;
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
mon_chr = qemu_chr_alloc();
mon_chr->chr_write = gdb_monitor_write;
monitor_init(mon_chr, 0);
} else {
if (s->chr)
qemu_chr_delete(s->chr);
mon_chr = s->mon_chr;
memset(s, 0, sizeof(GDBState));
}
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
s->state = chr ? RS_IDLE : RS_INACTIVE;
s->mon_chr = mon_chr;
s->current_syscall_cb = NULL;
return 0;
}
| [
"int FUNC_0(const char *VAR_0)\n{",
"GDBState *s;",
"char VAR_1[128];",
"CharDriverState *chr = NULL;",
"CharDriverState *mon_chr;",
"if (!VAR_0)\nreturn -1;",
"if (strcmp(VAR_0, \"none\") != 0) {",
"if (strstart(VAR_0, \"tcp:\", NULL)) {",
"snprintf(VAR_1, sizeof(VAR_1),\n\"%s,nowait,nodelay,server\", VAR_0);",
"VAR_0 = VAR_1;",
"}",
"#ifndef _WIN32\nelse if (strcmp(VAR_0, \"stdio\") == 0) {",
"struct sigaction VAR_2;",
"memset(&VAR_2, 0, sizeof(VAR_2));",
"VAR_2.sa_handler = gdb_sigterm_handler;",
"sigaction(SIGINT, &VAR_2, NULL);",
"}",
"#endif\nchr = qemu_chr_new(\"gdb\", VAR_0, NULL);",
"if (!chr)\nreturn -1;",
"qemu_chr_fe_claim_no_fail(chr);",
"qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive,\ngdb_chr_event, NULL);",
"}",
"s = gdbserver_state;",
"if (!s) {",
"s = g_malloc0(sizeof(GDBState));",
"gdbserver_state = s;",
"qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);",
"mon_chr = qemu_chr_alloc();",
"mon_chr->chr_write = gdb_monitor_write;",
"monitor_init(mon_chr, 0);",
"} else {",
"if (s->chr)\nqemu_chr_delete(s->chr);",
"mon_chr = s->mon_chr;",
"memset(s, 0, sizeof(GDBState));",
"}",
"s->c_cpu = first_cpu;",
"s->g_cpu = first_cpu;",
"s->chr = chr;",
"s->state = chr ? RS_IDLE : RS_INACTIVE;",
"s->mon_chr = mon_chr;",
"s->current_syscall_cb = NULL;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19
],
[
21
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55
],
[
59
],
[
61,
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
]
] |
27,265 | net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
uint32_t iov_off, uint32_t size)
{
size_t iovec_off, buf_off;
unsigned int i;
uint32_t res = 0;
uint32_t seq = 0;
iovec_off = 0;
buf_off = 0;
for (i = 0; i < iov_cnt && size; i++) {
if (iov_off < (iovec_off + iov[i].iov_len)) {
size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);
void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off);
res += net_checksum_add_cont(len, chunk_buf, seq);
seq += len;
buf_off += len;
iov_off += len;
size -= len;
}
iovec_off += iov[i].iov_len;
}
return res;
}
| false | qemu | eb700029c7836798046191d62d595363d92c84d4 | net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
uint32_t iov_off, uint32_t size)
{
size_t iovec_off, buf_off;
unsigned int i;
uint32_t res = 0;
uint32_t seq = 0;
iovec_off = 0;
buf_off = 0;
for (i = 0; i < iov_cnt && size; i++) {
if (iov_off < (iovec_off + iov[i].iov_len)) {
size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);
void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off);
res += net_checksum_add_cont(len, chunk_buf, seq);
seq += len;
buf_off += len;
iov_off += len;
size -= len;
}
iovec_off += iov[i].iov_len;
}
return res;
}
| {
"code": [],
"line_no": []
} | FUNC_0(const struct iovec *VAR_0, const unsigned int VAR_1,
uint32_t VAR_2, uint32_t VAR_3)
{
size_t iovec_off, buf_off;
unsigned int VAR_4;
uint32_t res = 0;
uint32_t seq = 0;
iovec_off = 0;
buf_off = 0;
for (VAR_4 = 0; VAR_4 < VAR_1 && VAR_3; VAR_4++) {
if (VAR_2 < (iovec_off + VAR_0[VAR_4].iov_len)) {
size_t len = MIN((iovec_off + VAR_0[VAR_4].iov_len) - VAR_2 , VAR_3);
void *chunk_buf = VAR_0[VAR_4].iov_base + (VAR_2 - iovec_off);
res += net_checksum_add_cont(len, chunk_buf, seq);
seq += len;
buf_off += len;
VAR_2 += len;
VAR_3 -= len;
}
iovec_off += VAR_0[VAR_4].iov_len;
}
return res;
}
| [
"FUNC_0(const struct iovec *VAR_0, const unsigned int VAR_1,\nuint32_t VAR_2, uint32_t VAR_3)\n{",
"size_t iovec_off, buf_off;",
"unsigned int VAR_4;",
"uint32_t res = 0;",
"uint32_t seq = 0;",
"iovec_off = 0;",
"buf_off = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_1 && VAR_3; VAR_4++) {",
"if (VAR_2 < (iovec_off + VAR_0[VAR_4].iov_len)) {",
"size_t len = MIN((iovec_off + VAR_0[VAR_4].iov_len) - VAR_2 , VAR_3);",
"void *chunk_buf = VAR_0[VAR_4].iov_base + (VAR_2 - iovec_off);",
"res += net_checksum_add_cont(len, chunk_buf, seq);",
"seq += len;",
"buf_off += len;",
"VAR_2 += len;",
"VAR_3 -= len;",
"}",
"iovec_off += VAR_0[VAR_4].iov_len;",
"}",
"return res;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
27,267 | static inline int get_phys_addr(CPUARMState *env, target_ulong address,
int access_type, int is_user,
hwaddr *phys_ptr, int *prot,
target_ulong *page_size)
{
/* This is not entirely correct as get_phys_addr() can also be called
* from ats_write() for an address translation of a specific regime.
*/
uint32_t sctlr = A32_BANKED_CURRENT_REG_GET(env, sctlr);
/* Fast Context Switch Extension. */
if (address < 0x02000000)
address += env->cp15.c13_fcse;
if ((sctlr & SCTLR_M) == 0) {
/* MMU/MPU disabled. */
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
*page_size = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(env, ARM_FEATURE_MPU)) {
*page_size = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,
prot);
} else if (extended_addresses_enabled(env)) {
return get_phys_addr_lpae(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else if (sctlr & SCTLR_XP) {
return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else {
return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,
prot, page_size);
}
}
| false | qemu | 54bf36ed351c526cde0c853079f9ff1ab7e2ff89 | static inline int get_phys_addr(CPUARMState *env, target_ulong address,
int access_type, int is_user,
hwaddr *phys_ptr, int *prot,
target_ulong *page_size)
{
uint32_t sctlr = A32_BANKED_CURRENT_REG_GET(env, sctlr);
if (address < 0x02000000)
address += env->cp15.c13_fcse;
if ((sctlr & SCTLR_M) == 0) {
*phys_ptr = address;
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
*page_size = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(env, ARM_FEATURE_MPU)) {
*page_size = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(env, address, access_type, is_user, phys_ptr,
prot);
} else if (extended_addresses_enabled(env)) {
return get_phys_addr_lpae(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else if (sctlr & SCTLR_XP) {
return get_phys_addr_v6(env, address, access_type, is_user, phys_ptr,
prot, page_size);
} else {
return get_phys_addr_v5(env, address, access_type, is_user, phys_ptr,
prot, page_size);
}
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(CPUARMState *VAR_0, target_ulong VAR_1,
int VAR_2, int VAR_3,
hwaddr *VAR_4, int *VAR_5,
target_ulong *VAR_6)
{
uint32_t sctlr = A32_BANKED_CURRENT_REG_GET(VAR_0, sctlr);
if (VAR_1 < 0x02000000)
VAR_1 += VAR_0->cp15.c13_fcse;
if ((sctlr & SCTLR_M) == 0) {
*VAR_4 = VAR_1;
*VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
*VAR_6 = TARGET_PAGE_SIZE;
return 0;
} else if (arm_feature(VAR_0, ARM_FEATURE_MPU)) {
*VAR_6 = TARGET_PAGE_SIZE;
return get_phys_addr_mpu(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5);
} else if (extended_addresses_enabled(VAR_0)) {
return get_phys_addr_lpae(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6);
} else if (sctlr & SCTLR_XP) {
return get_phys_addr_v6(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6);
} else {
return get_phys_addr_v5(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6);
}
}
| [
"static inline int FUNC_0(CPUARMState *VAR_0, target_ulong VAR_1,\nint VAR_2, int VAR_3,\nhwaddr *VAR_4, int *VAR_5,\ntarget_ulong *VAR_6)\n{",
"uint32_t sctlr = A32_BANKED_CURRENT_REG_GET(VAR_0, sctlr);",
"if (VAR_1 < 0x02000000)\nVAR_1 += VAR_0->cp15.c13_fcse;",
"if ((sctlr & SCTLR_M) == 0) {",
"*VAR_4 = VAR_1;",
"*VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;",
"*VAR_6 = TARGET_PAGE_SIZE;",
"return 0;",
"} else if (arm_feature(VAR_0, ARM_FEATURE_MPU)) {",
"*VAR_6 = TARGET_PAGE_SIZE;",
"return get_phys_addr_mpu(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5);",
"} else if (extended_addresses_enabled(VAR_0)) {",
"return get_phys_addr_lpae(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6);",
"} else if (sctlr & SCTLR_XP) {",
"return get_phys_addr_v6(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6);",
"} else {",
"return get_phys_addr_v5(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
17
],
[
23,
25
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
]
] |
27,268 | DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
{
const char *buf;
const char *file = NULL;
char devname[128];
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
int snapshot = 0;
int ret;
*fatal_error = 1;
translation = BIOS_ATA_TRANSLATION_AUTO;
if (default_to_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
/* extract parameters */
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else if (!strcmp(buf, "none")) {
type = IF_NONE;
max_devs = 0;
} else {
error_report("unsupported bus type '%s'", buf);
return NULL;
}
}
if (cyls || heads || secs) {
if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
error_report("invalid physical cyls number");
return NULL;
}
if (heads < 1 || (type == IF_IDE && heads > 16)) {
error_report("invalid physical heads number");
return NULL;
}
if (secs < 1 || (type == IF_IDE && secs > 63)) {
error_report("invalid physical secs number");
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls,heads and secs",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
error_report("'%s' invalid translation type", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
error_report("'%s' invalid physical CHS format", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
error_report("'%s' invalid media", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
bdrv_flags |= BDRV_O_NOCACHE;
} else if (!strcmp(buf, "writeback")) {
bdrv_flags |= BDRV_O_CACHE_WB;
} else if (!strcmp(buf, "unsafe")) {
bdrv_flags |= BDRV_O_CACHE_WB;
bdrv_flags |= BDRV_O_NO_FLUSH;
} else if (!strcmp(buf, "writethrough")) {
/* this is the default */
} else {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
/* this is the default */
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(buf, "?") == 0) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}
on_write_error = BLOCK_ERR_STOP_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCK_ERR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
/* compute bus and unit according index */
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
return NULL;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
/* if user doesn't specify a unit_id,
* try to find the first free
*/
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
/* check unit id */
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)",
unit_id, max_devs - 1);
return NULL;
}
/*
* ignore multiple definitions
*/
if (drive_get(type, bus_id, unit_id) != NULL) {
*fatal_error = 0;
return NULL;
}
/* init */
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(buf);
} else {
/* no id supplied -> create one */
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
devname, mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->opts = opts;
if (serial)
strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1);
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs);
bdrv_set_translation_hint(dinfo->bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
/* FIXME: This isn't really a floppy, but it's a reasonable
approximation. */
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
/* add virtio block device */
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
case IF_COUNT:
abort();
}
if (!file || !*file) {
*fatal_error = 0;
return NULL;
}
if (snapshot) {
/* always use cache=unsafe with snapshot */
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (media == MEDIA_CDROM) {
/* CDROM is fine for any interface, don't check. */
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
error_report("readonly not supported by this bus type");
return NULL;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
if (ret < 0) {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
}
| false | qemu | 1960966d1b57628f730b66fe33cd2005846092e0 | DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error)
{
const char *buf;
const char *file = NULL;
char devname[128];
const char *serial;
const char *mediastr = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } media;
int bus_id, unit_id;
int cyls, heads, secs, translation;
BlockDriver *drv = NULL;
int max_devs;
int index;
int ro = 0;
int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
int snapshot = 0;
int ret;
*fatal_error = 1;
translation = BIOS_ATA_TRANSLATION_AUTO;
if (default_to_scsi) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
pstrcpy(devname, sizeof(devname), "scsi");
} else {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
pstrcpy(devname, sizeof(devname), "ide");
}
media = MEDIA_DISK;
bus_id = qemu_opt_get_number(opts, "bus", 0);
unit_id = qemu_opt_get_number(opts, "unit", -1);
index = qemu_opt_get_number(opts, "index", -1);
cyls = qemu_opt_get_number(opts, "cyls", 0);
heads = qemu_opt_get_number(opts, "heads", 0);
secs = qemu_opt_get_number(opts, "secs", 0);
snapshot = qemu_opt_get_bool(opts, "snapshot", 0);
ro = qemu_opt_get_bool(opts, "readonly", 0);
file = qemu_opt_get(opts, "file");
serial = qemu_opt_get(opts, "serial");
if ((buf = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(devname, sizeof(devname), buf);
if (!strcmp(buf, "ide")) {
type = IF_IDE;
max_devs = MAX_IDE_DEVS;
} else if (!strcmp(buf, "scsi")) {
type = IF_SCSI;
max_devs = MAX_SCSI_DEVS;
} else if (!strcmp(buf, "floppy")) {
type = IF_FLOPPY;
max_devs = 0;
} else if (!strcmp(buf, "pflash")) {
type = IF_PFLASH;
max_devs = 0;
} else if (!strcmp(buf, "mtd")) {
type = IF_MTD;
max_devs = 0;
} else if (!strcmp(buf, "sd")) {
type = IF_SD;
max_devs = 0;
} else if (!strcmp(buf, "virtio")) {
type = IF_VIRTIO;
max_devs = 0;
} else if (!strcmp(buf, "xen")) {
type = IF_XEN;
max_devs = 0;
} else if (!strcmp(buf, "none")) {
type = IF_NONE;
max_devs = 0;
} else {
error_report("unsupported bus type '%s'", buf);
return NULL;
}
}
if (cyls || heads || secs) {
if (cyls < 1 || (type == IF_IDE && cyls > 16383)) {
error_report("invalid physical cyls number");
return NULL;
}
if (heads < 1 || (type == IF_IDE && heads > 16)) {
error_report("invalid physical heads number");
return NULL;
}
if (secs < 1 || (type == IF_IDE && secs > 63)) {
error_report("invalid physical secs number");
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "trans")) != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls,heads and secs",
buf);
return NULL;
}
if (!strcmp(buf, "none"))
translation = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(buf, "lba"))
translation = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(buf, "auto"))
translation = BIOS_ATA_TRANSLATION_AUTO;
else {
error_report("'%s' invalid translation type", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "media")) != NULL) {
if (!strcmp(buf, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(buf, "cdrom")) {
if (cyls || secs || heads) {
error_report("'%s' invalid physical CHS format", buf);
return NULL;
}
media = MEDIA_CDROM;
} else {
error_report("'%s' invalid media", buf);
return NULL;
}
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
bdrv_flags |= BDRV_O_NOCACHE;
} else if (!strcmp(buf, "writeback")) {
bdrv_flags |= BDRV_O_CACHE_WB;
} else if (!strcmp(buf, "unsafe")) {
bdrv_flags |= BDRV_O_CACHE_WB;
bdrv_flags |= BDRV_O_NO_FLUSH;
} else if (!strcmp(buf, "writethrough")) {
} else {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(buf, "native")) {
bdrv_flags |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(buf, "threads")) {
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((buf = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(buf, "?") == 0) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(buf);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}
on_write_error = BLOCK_ERR_STOP_ENOSPC;
if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
on_write_error = parse_block_error_action(buf, 0);
if (on_write_error < 0) {
return NULL;
}
}
on_read_error = BLOCK_ERR_REPORT;
if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
on_read_error = parse_block_error_action(buf, 1);
if (on_read_error < 0) {
return NULL;
}
}
if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
return NULL;
}
if (max_devs == 0)
{
unit_id = index;
bus_id = 0;
} else {
unit_id = index % max_devs;
bus_id = index / max_devs;
}
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)",
unit_id, max_devs - 1);
return NULL;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
*fatal_error = 0;
return NULL;
}
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((buf = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(buf);
} else {
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
if (max_devs)
snprintf(dinfo->id, 32, "%s%i%s%i",
devname, bus_id, mediastr, unit_id);
else
snprintf(dinfo->id, 32, "%s%s%i",
devname, mediastr, unit_id);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->devaddr = devaddr;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->opts = opts;
if (serial)
strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1);
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(media) {
case MEDIA_DISK:
if (cyls != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs);
bdrv_set_translation_hint(dinfo->bdrv, translation);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (devaddr)
qemu_opt_set(opts, "addr", devaddr);
break;
case IF_COUNT:
abort();
}
if (!file || !*file) {
*fatal_error = 0;
return NULL;
}
if (snapshot) {
bdrv_flags &= ~BDRV_O_CACHE_MASK;
bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (media == MEDIA_CDROM) {
ro = 1;
} else if (ro == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
error_report("readonly not supported by this bus type");
return NULL;
}
}
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv);
if (ret < 0) {
error_report("could not open disk image %s: %s",
file, strerror(-ret));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
}
| {
"code": [],
"line_no": []
} | DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi, int *fatal_error)
{
const char *VAR_0;
const char *VAR_1 = NULL;
char VAR_2[128];
const char *VAR_3;
const char *VAR_4 = "";
BlockInterfaceType type;
enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;
int VAR_6, VAR_7;
int VAR_8, VAR_9, VAR_10, VAR_11;
BlockDriver *drv = NULL;
int VAR_12;
int VAR_13;
int VAR_14 = 0;
int VAR_15 = 0;
int VAR_16, VAR_17;
const char *VAR_18;
DriveInfo *dinfo;
int VAR_19 = 0;
int VAR_20;
*fatal_error = 1;
VAR_11 = BIOS_ATA_TRANSLATION_AUTO;
if (default_to_scsi) {
type = IF_SCSI;
VAR_12 = MAX_SCSI_DEVS;
pstrcpy(VAR_2, sizeof(VAR_2), "scsi");
} else {
type = IF_IDE;
VAR_12 = MAX_IDE_DEVS;
pstrcpy(VAR_2, sizeof(VAR_2), "ide");
}
VAR_5 = MEDIA_DISK;
VAR_6 = qemu_opt_get_number(opts, "bus", 0);
VAR_7 = qemu_opt_get_number(opts, "unit", -1);
VAR_13 = qemu_opt_get_number(opts, "VAR_13", -1);
VAR_8 = qemu_opt_get_number(opts, "VAR_8", 0);
VAR_9 = qemu_opt_get_number(opts, "VAR_9", 0);
VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0);
VAR_19 = qemu_opt_get_bool(opts, "VAR_19", 0);
VAR_14 = qemu_opt_get_bool(opts, "readonly", 0);
VAR_1 = qemu_opt_get(opts, "VAR_1");
VAR_3 = qemu_opt_get(opts, "VAR_3");
if ((VAR_0 = qemu_opt_get(opts, "if")) != NULL) {
pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);
if (!strcmp(VAR_0, "ide")) {
type = IF_IDE;
VAR_12 = MAX_IDE_DEVS;
} else if (!strcmp(VAR_0, "scsi")) {
type = IF_SCSI;
VAR_12 = MAX_SCSI_DEVS;
} else if (!strcmp(VAR_0, "floppy")) {
type = IF_FLOPPY;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "pflash")) {
type = IF_PFLASH;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "mtd")) {
type = IF_MTD;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "sd")) {
type = IF_SD;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "virtio")) {
type = IF_VIRTIO;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "xen")) {
type = IF_XEN;
VAR_12 = 0;
} else if (!strcmp(VAR_0, "none")) {
type = IF_NONE;
VAR_12 = 0;
} else {
error_report("unsupported bus type '%s'", VAR_0);
return NULL;
}
}
if (VAR_8 || VAR_9 || VAR_10) {
if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {
error_report("invalid physical VAR_8 number");
return NULL;
}
if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {
error_report("invalid physical VAR_9 number");
return NULL;
}
if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {
error_report("invalid physical VAR_10 number");
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "trans")) != NULL) {
if (!VAR_8) {
error_report("'%s' trans must be used with VAR_8,VAR_9 and VAR_10",
VAR_0);
return NULL;
}
if (!strcmp(VAR_0, "none"))
VAR_11 = BIOS_ATA_TRANSLATION_NONE;
else if (!strcmp(VAR_0, "lba"))
VAR_11 = BIOS_ATA_TRANSLATION_LBA;
else if (!strcmp(VAR_0, "auto"))
VAR_11 = BIOS_ATA_TRANSLATION_AUTO;
else {
error_report("'%s' invalid VAR_11 type", VAR_0);
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "VAR_5")) != NULL) {
if (!strcmp(VAR_0, "disk")) {
VAR_5 = MEDIA_DISK;
} else if (!strcmp(VAR_0, "cdrom")) {
if (VAR_8 || VAR_10 || VAR_9) {
error_report("'%s' invalid physical CHS format", VAR_0);
return NULL;
}
VAR_5 = MEDIA_CDROM;
} else {
error_report("'%s' invalid VAR_5", VAR_0);
return NULL;
}
}
if ((VAR_0 = qemu_opt_get(opts, "cache")) != NULL) {
if (!strcmp(VAR_0, "off") || !strcmp(VAR_0, "none")) {
VAR_15 |= BDRV_O_NOCACHE;
} else if (!strcmp(VAR_0, "writeback")) {
VAR_15 |= BDRV_O_CACHE_WB;
} else if (!strcmp(VAR_0, "unsafe")) {
VAR_15 |= BDRV_O_CACHE_WB;
VAR_15 |= BDRV_O_NO_FLUSH;
} else if (!strcmp(VAR_0, "writethrough")) {
} else {
error_report("invalid cache option");
return NULL;
}
}
#ifdef CONFIG_LINUX_AIO
if ((VAR_0 = qemu_opt_get(opts, "aio")) != NULL) {
if (!strcmp(VAR_0, "native")) {
VAR_15 |= BDRV_O_NATIVE_AIO;
} else if (!strcmp(VAR_0, "threads")) {
} else {
error_report("invalid aio option");
return NULL;
}
}
#endif
if ((VAR_0 = qemu_opt_get(opts, "format")) != NULL) {
if (strcmp(VAR_0, "?") == 0) {
error_printf("Supported formats:");
bdrv_iterate_format(bdrv_format_print, NULL);
error_printf("\n");
return NULL;
}
drv = bdrv_find_whitelisted_format(VAR_0);
if (!drv) {
error_report("'%s' invalid format", VAR_0);
return NULL;
}
}
VAR_17 = BLOCK_ERR_STOP_ENOSPC;
if ((VAR_0 = qemu_opt_get(opts, "werror")) != NULL) {
if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
error_report("werror is not supported by this bus type");
return NULL;
}
VAR_17 = parse_block_error_action(VAR_0, 0);
if (VAR_17 < 0) {
return NULL;
}
}
VAR_16 = BLOCK_ERR_REPORT;
if ((VAR_0 = qemu_opt_get(opts, "rerror")) != NULL) {
if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
error_report("rerror is not supported by this bus type");
return NULL;
}
VAR_16 = parse_block_error_action(VAR_0, 1);
if (VAR_16 < 0) {
return NULL;
}
}
if ((VAR_18 = qemu_opt_get(opts, "addr")) != NULL) {
if (type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
return NULL;
}
}
if (VAR_13 != -1) {
if (VAR_6 != 0 || VAR_7 != -1) {
error_report("VAR_13 cannot be used with bus and unit");
return NULL;
}
if (VAR_12 == 0)
{
VAR_7 = VAR_13;
VAR_6 = 0;
} else {
VAR_7 = VAR_13 % VAR_12;
VAR_6 = VAR_13 / VAR_12;
}
}
if (VAR_7 == -1) {
VAR_7 = 0;
while (drive_get(type, VAR_6, VAR_7) != NULL) {
VAR_7++;
if (VAR_12 && VAR_7 >= VAR_12) {
VAR_7 -= VAR_12;
VAR_6++;
}
}
}
if (VAR_12 && VAR_7 >= VAR_12) {
error_report("unit %d too big (max is %d)",
VAR_7, VAR_12 - 1);
return NULL;
}
if (drive_get(type, VAR_6, VAR_7) != NULL) {
*fatal_error = 0;
return NULL;
}
dinfo = qemu_mallocz(sizeof(*dinfo));
if ((VAR_0 = qemu_opts_id(opts)) != NULL) {
dinfo->id = qemu_strdup(VAR_0);
} else {
dinfo->id = qemu_mallocz(32);
if (type == IF_IDE || type == IF_SCSI)
VAR_4 = (VAR_5 == MEDIA_CDROM) ? "-cd" : "-hd";
if (VAR_12)
snprintf(dinfo->id, 32, "%s%i%s%i",
VAR_2, VAR_6, VAR_4, VAR_7);
else
snprintf(dinfo->id, 32, "%s%s%i",
VAR_2, VAR_4, VAR_7);
}
dinfo->bdrv = bdrv_new(dinfo->id);
dinfo->VAR_18 = VAR_18;
dinfo->type = type;
dinfo->bus = VAR_6;
dinfo->unit = VAR_7;
dinfo->opts = opts;
if (VAR_3)
strncpy(dinfo->VAR_3, VAR_3, sizeof(dinfo->VAR_3) - 1);
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17);
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
switch(VAR_5) {
case MEDIA_DISK:
if (VAR_8 != 0) {
bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);
bdrv_set_translation_hint(dinfo->bdrv, VAR_11);
}
break;
case MEDIA_CDROM:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);
break;
}
break;
case IF_SD:
case IF_FLOPPY:
bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);
break;
case IF_PFLASH:
case IF_MTD:
break;
case IF_VIRTIO:
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(opts, "driver", "virtio-blk-pci");
qemu_opt_set(opts, "drive", dinfo->id);
if (VAR_18)
qemu_opt_set(opts, "addr", VAR_18);
break;
case IF_COUNT:
abort();
}
if (!VAR_1 || !*VAR_1) {
*fatal_error = 0;
return NULL;
}
if (VAR_19) {
VAR_15 &= ~BDRV_O_CACHE_MASK;
VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
}
if (VAR_5 == MEDIA_CDROM) {
VAR_14 = 1;
} else if (VAR_14 == 1) {
if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
error_report("readonly not supported by this bus type");
return NULL;
}
}
VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;
VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv);
if (VAR_20 < 0) {
error_report("could not open disk image %s: %s",
VAR_1, strerror(-VAR_20));
return NULL;
}
if (bdrv_key_required(dinfo->bdrv))
autostart = 0;
*fatal_error = 0;
return dinfo;
}
| [
"DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi, int *fatal_error)\n{",
"const char *VAR_0;",
"const char *VAR_1 = NULL;",
"char VAR_2[128];",
"const char *VAR_3;",
"const char *VAR_4 = \"\";",
"BlockInterfaceType type;",
"enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8, VAR_9, VAR_10, VAR_11;",
"BlockDriver *drv = NULL;",
"int VAR_12;",
"int VAR_13;",
"int VAR_14 = 0;",
"int VAR_15 = 0;",
"int VAR_16, VAR_17;",
"const char *VAR_18;",
"DriveInfo *dinfo;",
"int VAR_19 = 0;",
"int VAR_20;",
"*fatal_error = 1;",
"VAR_11 = BIOS_ATA_TRANSLATION_AUTO;",
"if (default_to_scsi) {",
"type = IF_SCSI;",
"VAR_12 = MAX_SCSI_DEVS;",
"pstrcpy(VAR_2, sizeof(VAR_2), \"scsi\");",
"} else {",
"type = IF_IDE;",
"VAR_12 = MAX_IDE_DEVS;",
"pstrcpy(VAR_2, sizeof(VAR_2), \"ide\");",
"}",
"VAR_5 = MEDIA_DISK;",
"VAR_6 = qemu_opt_get_number(opts, \"bus\", 0);",
"VAR_7 = qemu_opt_get_number(opts, \"unit\", -1);",
"VAR_13 = qemu_opt_get_number(opts, \"VAR_13\", -1);",
"VAR_8 = qemu_opt_get_number(opts, \"VAR_8\", 0);",
"VAR_9 = qemu_opt_get_number(opts, \"VAR_9\", 0);",
"VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);",
"VAR_19 = qemu_opt_get_bool(opts, \"VAR_19\", 0);",
"VAR_14 = qemu_opt_get_bool(opts, \"readonly\", 0);",
"VAR_1 = qemu_opt_get(opts, \"VAR_1\");",
"VAR_3 = qemu_opt_get(opts, \"VAR_3\");",
"if ((VAR_0 = qemu_opt_get(opts, \"if\")) != NULL) {",
"pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);",
"if (!strcmp(VAR_0, \"ide\")) {",
"type = IF_IDE;",
"VAR_12 = MAX_IDE_DEVS;",
"} else if (!strcmp(VAR_0, \"scsi\")) {",
"type = IF_SCSI;",
"VAR_12 = MAX_SCSI_DEVS;",
"} else if (!strcmp(VAR_0, \"floppy\")) {",
"type = IF_FLOPPY;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"pflash\")) {",
"type = IF_PFLASH;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"mtd\")) {",
"type = IF_MTD;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"sd\")) {",
"type = IF_SD;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"virtio\")) {",
"type = IF_VIRTIO;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"xen\")) {",
"type = IF_XEN;",
"VAR_12 = 0;",
"} else if (!strcmp(VAR_0, \"none\")) {",
"type = IF_NONE;",
"VAR_12 = 0;",
"} else {",
"error_report(\"unsupported bus type '%s'\", VAR_0);",
"return NULL;",
"}",
"}",
"if (VAR_8 || VAR_9 || VAR_10) {",
"if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {",
"error_report(\"invalid physical VAR_8 number\");",
"return NULL;",
"}",
"if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {",
"error_report(\"invalid physical VAR_9 number\");",
"return NULL;",
"}",
"if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {",
"error_report(\"invalid physical VAR_10 number\");",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"trans\")) != NULL) {",
"if (!VAR_8) {",
"error_report(\"'%s' trans must be used with VAR_8,VAR_9 and VAR_10\",\nVAR_0);",
"return NULL;",
"}",
"if (!strcmp(VAR_0, \"none\"))\nVAR_11 = BIOS_ATA_TRANSLATION_NONE;",
"else if (!strcmp(VAR_0, \"lba\"))\nVAR_11 = BIOS_ATA_TRANSLATION_LBA;",
"else if (!strcmp(VAR_0, \"auto\"))\nVAR_11 = BIOS_ATA_TRANSLATION_AUTO;",
"else {",
"error_report(\"'%s' invalid VAR_11 type\", VAR_0);",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"VAR_5\")) != NULL) {",
"if (!strcmp(VAR_0, \"disk\")) {",
"VAR_5 = MEDIA_DISK;",
"} else if (!strcmp(VAR_0, \"cdrom\")) {",
"if (VAR_8 || VAR_10 || VAR_9) {",
"error_report(\"'%s' invalid physical CHS format\", VAR_0);",
"return NULL;",
"}",
"VAR_5 = MEDIA_CDROM;",
"} else {",
"error_report(\"'%s' invalid VAR_5\", VAR_0);",
"return NULL;",
"}",
"}",
"if ((VAR_0 = qemu_opt_get(opts, \"cache\")) != NULL) {",
"if (!strcmp(VAR_0, \"off\") || !strcmp(VAR_0, \"none\")) {",
"VAR_15 |= BDRV_O_NOCACHE;",
"} else if (!strcmp(VAR_0, \"writeback\")) {",
"VAR_15 |= BDRV_O_CACHE_WB;",
"} else if (!strcmp(VAR_0, \"unsafe\")) {",
"VAR_15 |= BDRV_O_CACHE_WB;",
"VAR_15 |= BDRV_O_NO_FLUSH;",
"} else if (!strcmp(VAR_0, \"writethrough\")) {",
"} else {",
"error_report(\"invalid cache option\");",
"return NULL;",
"}",
"}",
"#ifdef CONFIG_LINUX_AIO\nif ((VAR_0 = qemu_opt_get(opts, \"aio\")) != NULL) {",
"if (!strcmp(VAR_0, \"native\")) {",
"VAR_15 |= BDRV_O_NATIVE_AIO;",
"} else if (!strcmp(VAR_0, \"threads\")) {",
"} else {",
"error_report(\"invalid aio option\");",
"return NULL;",
"}",
"}",
"#endif\nif ((VAR_0 = qemu_opt_get(opts, \"format\")) != NULL) {",
"if (strcmp(VAR_0, \"?\") == 0) {",
"error_printf(\"Supported formats:\");",
"bdrv_iterate_format(bdrv_format_print, NULL);",
"error_printf(\"\\n\");",
"return NULL;",
"}",
"drv = bdrv_find_whitelisted_format(VAR_0);",
"if (!drv) {",
"error_report(\"'%s' invalid format\", VAR_0);",
"return NULL;",
"}",
"}",
"VAR_17 = BLOCK_ERR_STOP_ENOSPC;",
"if ((VAR_0 = qemu_opt_get(opts, \"werror\")) != NULL) {",
"if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {",
"error_report(\"werror is not supported by this bus type\");",
"return NULL;",
"}",
"VAR_17 = parse_block_error_action(VAR_0, 0);",
"if (VAR_17 < 0) {",
"return NULL;",
"}",
"}",
"VAR_16 = BLOCK_ERR_REPORT;",
"if ((VAR_0 = qemu_opt_get(opts, \"rerror\")) != NULL) {",
"if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {",
"error_report(\"rerror is not supported by this bus type\");",
"return NULL;",
"}",
"VAR_16 = parse_block_error_action(VAR_0, 1);",
"if (VAR_16 < 0) {",
"return NULL;",
"}",
"}",
"if ((VAR_18 = qemu_opt_get(opts, \"addr\")) != NULL) {",
"if (type != IF_VIRTIO) {",
"error_report(\"addr is not supported by this bus type\");",
"return NULL;",
"}",
"}",
"if (VAR_13 != -1) {",
"if (VAR_6 != 0 || VAR_7 != -1) {",
"error_report(\"VAR_13 cannot be used with bus and unit\");",
"return NULL;",
"}",
"if (VAR_12 == 0)\n{",
"VAR_7 = VAR_13;",
"VAR_6 = 0;",
"} else {",
"VAR_7 = VAR_13 % VAR_12;",
"VAR_6 = VAR_13 / VAR_12;",
"}",
"}",
"if (VAR_7 == -1) {",
"VAR_7 = 0;",
"while (drive_get(type, VAR_6, VAR_7) != NULL) {",
"VAR_7++;",
"if (VAR_12 && VAR_7 >= VAR_12) {",
"VAR_7 -= VAR_12;",
"VAR_6++;",
"}",
"}",
"}",
"if (VAR_12 && VAR_7 >= VAR_12) {",
"error_report(\"unit %d too big (max is %d)\",\nVAR_7, VAR_12 - 1);",
"return NULL;",
"}",
"if (drive_get(type, VAR_6, VAR_7) != NULL) {",
"*fatal_error = 0;",
"return NULL;",
"}",
"dinfo = qemu_mallocz(sizeof(*dinfo));",
"if ((VAR_0 = qemu_opts_id(opts)) != NULL) {",
"dinfo->id = qemu_strdup(VAR_0);",
"} else {",
"dinfo->id = qemu_mallocz(32);",
"if (type == IF_IDE || type == IF_SCSI)\nVAR_4 = (VAR_5 == MEDIA_CDROM) ? \"-cd\" : \"-hd\";",
"if (VAR_12)\nsnprintf(dinfo->id, 32, \"%s%i%s%i\",\nVAR_2, VAR_6, VAR_4, VAR_7);",
"else\nsnprintf(dinfo->id, 32, \"%s%s%i\",\nVAR_2, VAR_4, VAR_7);",
"}",
"dinfo->bdrv = bdrv_new(dinfo->id);",
"dinfo->VAR_18 = VAR_18;",
"dinfo->type = type;",
"dinfo->bus = VAR_6;",
"dinfo->unit = VAR_7;",
"dinfo->opts = opts;",
"if (VAR_3)\nstrncpy(dinfo->VAR_3, VAR_3, sizeof(dinfo->VAR_3) - 1);",
"QTAILQ_INSERT_TAIL(&drives, dinfo, next);",
"bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17);",
"switch(type) {",
"case IF_IDE:\ncase IF_SCSI:\ncase IF_XEN:\ncase IF_NONE:\nswitch(VAR_5) {",
"case MEDIA_DISK:\nif (VAR_8 != 0) {",
"bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);",
"bdrv_set_translation_hint(dinfo->bdrv, VAR_11);",
"}",
"break;",
"case MEDIA_CDROM:\nbdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM);",
"break;",
"}",
"break;",
"case IF_SD:\ncase IF_FLOPPY:\nbdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY);",
"break;",
"case IF_PFLASH:\ncase IF_MTD:\nbreak;",
"case IF_VIRTIO:\nopts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);",
"qemu_opt_set(opts, \"driver\", \"virtio-blk-pci\");",
"qemu_opt_set(opts, \"drive\", dinfo->id);",
"if (VAR_18)\nqemu_opt_set(opts, \"addr\", VAR_18);",
"break;",
"case IF_COUNT:\nabort();",
"}",
"if (!VAR_1 || !*VAR_1) {",
"*fatal_error = 0;",
"return NULL;",
"}",
"if (VAR_19) {",
"VAR_15 &= ~BDRV_O_CACHE_MASK;",
"VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);",
"}",
"if (VAR_5 == MEDIA_CDROM) {",
"VAR_14 = 1;",
"} else if (VAR_14 == 1) {",
"if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {",
"error_report(\"readonly not supported by this bus type\");",
"return NULL;",
"}",
"}",
"VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;",
"VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv);",
"if (VAR_20 < 0) {",
"error_report(\"could not open disk image %s: %s\",\nVAR_1, strerror(-VAR_20));",
"return NULL;",
"}",
"if (bdrv_key_required(dinfo->bdrv))\nautostart = 0;",
"*fatal_error = 0;",
"return dinfo;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
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
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
303,
305
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
491
],
[
493,
495
],
[
497
],
[
499
],
[
511
],
[
513
],
[
515
],
[
517
],
[
525
],
[
527
],
[
529
],
[
531
],
[
535
],
[
537,
539
],
[
541,
543,
545
],
[
547,
549,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567,
569
],
[
571
],
[
575
],
[
579
],
[
581,
583,
585,
587,
589
],
[
591,
593
],
[
595
],
[
597
],
[
599
],
[
601
],
[
603,
605
],
[
607
],
[
609
],
[
611
],
[
613,
619,
621
],
[
623
],
[
625,
627,
629
],
[
631,
635
],
[
637
],
[
639
],
[
641,
643
],
[
645
],
[
647,
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
665
],
[
667
],
[
669
],
[
673
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
693
],
[
697
],
[
699
],
[
701,
703
],
[
705
],
[
707
],
[
711,
713
],
[
715
],
[
717
],
[
719
]
] |
27,270 | static void test_visitor_in_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_assert_cmpint(p->integer, ==, -42);
g_assert(p->boolean == true);
g_assert_cmpstr(p->string, ==, "foo");
g_free(p->string);
g_free(p);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_in_struct(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_assert_cmpint(p->integer, ==, -42);
g_assert(p->boolean == true);
g_assert_cmpstr(p->string, ==, "foo");
g_free(p->string);
g_free(p);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
TestStruct *p = NULL;
Visitor *v;
v = visitor_input_test_init(VAR_0, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, NULL, &p, &error_abort);
g_assert_cmpint(p->integer, ==, -42);
g_assert(p->boolean == true);
g_assert_cmpstr(p->string, ==, "foo");
g_free(p->string);
g_free(p);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"TestStruct *p = NULL;",
"Visitor *v;",
"v = visitor_input_test_init(VAR_0, \"{ 'integer': -42, 'boolean': true, 'string': 'foo' }\");",
"visit_type_TestStruct(v, NULL, &p, &error_abort);",
"g_assert_cmpint(p->integer, ==, -42);",
"g_assert(p->boolean == true);",
"g_assert_cmpstr(p->string, ==, \"foo\");",
"g_free(p->string);",
"g_free(p);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
]
] |
27,271 | static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
unsigned bar_nr, unsigned bar_size)
{
int config_offset;
uint8_t *config;
uint32_t new_size;
if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1)
return -EINVAL;
if (bar_size > 0x80000000)
return -ENOSPC;
/* Add space for MSI-X structures */
if (!bar_size) {
new_size = MSIX_PAGE_SIZE;
} else if (bar_size < MSIX_PAGE_SIZE) {
bar_size = MSIX_PAGE_SIZE;
new_size = MSIX_PAGE_SIZE * 2;
} else {
new_size = bar_size * 2;
}
pdev->msix_bar_size = new_size;
config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX,
0, MSIX_CAP_LENGTH);
if (config_offset < 0)
return config_offset;
config = pdev->config + config_offset;
pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
/* Table on top of BAR */
pci_set_long(config + PCI_MSIX_TABLE, bar_size | bar_nr);
/* Pending bits on top of that */
pci_set_long(config + PCI_MSIX_PBA, (bar_size + MSIX_PAGE_PENDING) |
bar_nr);
pdev->msix_cap = config_offset;
/* Make flags bit writable. */
pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
MSIX_MASKALL_MASK;
pdev->msix_function_masked = true;
return 0;
}
| false | qemu | 393a98924eb00df76231384b86652e1d5f964d67 | static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
unsigned bar_nr, unsigned bar_size)
{
int config_offset;
uint8_t *config;
uint32_t new_size;
if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1)
return -EINVAL;
if (bar_size > 0x80000000)
return -ENOSPC;
if (!bar_size) {
new_size = MSIX_PAGE_SIZE;
} else if (bar_size < MSIX_PAGE_SIZE) {
bar_size = MSIX_PAGE_SIZE;
new_size = MSIX_PAGE_SIZE * 2;
} else {
new_size = bar_size * 2;
}
pdev->msix_bar_size = new_size;
config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX,
0, MSIX_CAP_LENGTH);
if (config_offset < 0)
return config_offset;
config = pdev->config + config_offset;
pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
pci_set_long(config + PCI_MSIX_TABLE, bar_size | bar_nr);
pci_set_long(config + PCI_MSIX_PBA, (bar_size + MSIX_PAGE_PENDING) |
bar_nr);
pdev->msix_cap = config_offset;
pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
MSIX_MASKALL_MASK;
pdev->msix_function_masked = true;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct PCIDevice *VAR_0, unsigned short VAR_1,
unsigned VAR_2, unsigned VAR_3)
{
int VAR_4;
uint8_t *config;
uint32_t new_size;
if (VAR_1 < 1 || VAR_1 > PCI_MSIX_FLAGS_QSIZE + 1)
return -EINVAL;
if (VAR_3 > 0x80000000)
return -ENOSPC;
if (!VAR_3) {
new_size = MSIX_PAGE_SIZE;
} else if (VAR_3 < MSIX_PAGE_SIZE) {
VAR_3 = MSIX_PAGE_SIZE;
new_size = MSIX_PAGE_SIZE * 2;
} else {
new_size = VAR_3 * 2;
}
VAR_0->msix_bar_size = new_size;
VAR_4 = pci_add_capability(VAR_0, PCI_CAP_ID_MSIX,
0, MSIX_CAP_LENGTH);
if (VAR_4 < 0)
return VAR_4;
config = VAR_0->config + VAR_4;
pci_set_word(config + PCI_MSIX_FLAGS, VAR_1 - 1);
pci_set_long(config + PCI_MSIX_TABLE, VAR_3 | VAR_2);
pci_set_long(config + PCI_MSIX_PBA, (VAR_3 + MSIX_PAGE_PENDING) |
VAR_2);
VAR_0->msix_cap = VAR_4;
VAR_0->wmask[VAR_4 + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
MSIX_MASKALL_MASK;
VAR_0->msix_function_masked = true;
return 0;
}
| [
"static int FUNC_0(struct PCIDevice *VAR_0, unsigned short VAR_1,\nunsigned VAR_2, unsigned VAR_3)\n{",
"int VAR_4;",
"uint8_t *config;",
"uint32_t new_size;",
"if (VAR_1 < 1 || VAR_1 > PCI_MSIX_FLAGS_QSIZE + 1)\nreturn -EINVAL;",
"if (VAR_3 > 0x80000000)\nreturn -ENOSPC;",
"if (!VAR_3) {",
"new_size = MSIX_PAGE_SIZE;",
"} else if (VAR_3 < MSIX_PAGE_SIZE) {",
"VAR_3 = MSIX_PAGE_SIZE;",
"new_size = MSIX_PAGE_SIZE * 2;",
"} else {",
"new_size = VAR_3 * 2;",
"}",
"VAR_0->msix_bar_size = new_size;",
"VAR_4 = pci_add_capability(VAR_0, PCI_CAP_ID_MSIX,\n0, MSIX_CAP_LENGTH);",
"if (VAR_4 < 0)\nreturn VAR_4;",
"config = VAR_0->config + VAR_4;",
"pci_set_word(config + PCI_MSIX_FLAGS, VAR_1 - 1);",
"pci_set_long(config + PCI_MSIX_TABLE, VAR_3 | VAR_2);",
"pci_set_long(config + PCI_MSIX_PBA, (VAR_3 + MSIX_PAGE_PENDING) |\nVAR_2);",
"VAR_0->msix_cap = VAR_4;",
"VAR_0->wmask[VAR_4 + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |\nMSIX_MASKALL_MASK;",
"VAR_0->msix_function_masked = true;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
59
],
[
63
],
[
67,
69
],
[
71
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
] |
27,273 | void qmp_memsave(int64_t addr, int64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{
FILE *f;
uint32_t l;
CPUState *cpu;
uint8_t buf[1024];
if (!has_cpu) {
cpu_index = 0;
}
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(cpu, addr, buf, l, 0);
if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
| false | qemu | 2f4d0f5990ede025720e41fa473029e9ca85e8b8 | void qmp_memsave(int64_t addr, int64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{
FILE *f;
uint32_t l;
CPUState *cpu;
uint8_t buf[1024];
if (!has_cpu) {
cpu_index = 0;
}
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
cpu_memory_rw_debug(cpu, addr, buf, l, 0);
if (fwrite(buf, 1, l, f) != l) {
error_set(errp, QERR_IO_ERROR);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int64_t VAR_0, int64_t VAR_1, const char *VAR_2,
bool VAR_3, int64_t VAR_4, Error **VAR_5)
{
FILE *f;
uint32_t l;
CPUState *cpu;
uint8_t buf[1024];
if (!VAR_3) {
VAR_4 = 0;
}
cpu = qemu_get_cpu(VAR_4);
if (cpu == NULL) {
error_set(VAR_5, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(VAR_2, "wb");
if (!f) {
error_setg_file_open(VAR_5, errno, VAR_2);
return;
}
while (VAR_1 != 0) {
l = sizeof(buf);
if (l > VAR_1)
l = VAR_1;
cpu_memory_rw_debug(cpu, VAR_0, buf, l, 0);
if (fwrite(buf, 1, l, f) != l) {
error_set(VAR_5, QERR_IO_ERROR);
goto exit;
}
VAR_0 += l;
VAR_1 -= l;
}
exit:
fclose(f);
}
| [
"void FUNC_0(int64_t VAR_0, int64_t VAR_1, const char *VAR_2,\nbool VAR_3, int64_t VAR_4, Error **VAR_5)\n{",
"FILE *f;",
"uint32_t l;",
"CPUState *cpu;",
"uint8_t buf[1024];",
"if (!VAR_3) {",
"VAR_4 = 0;",
"}",
"cpu = qemu_get_cpu(VAR_4);",
"if (cpu == NULL) {",
"error_set(VAR_5, QERR_INVALID_PARAMETER_VALUE, \"cpu-index\",\n\"a CPU number\");",
"return;",
"}",
"f = fopen(VAR_2, \"wb\");",
"if (!f) {",
"error_setg_file_open(VAR_5, errno, VAR_2);",
"return;",
"}",
"while (VAR_1 != 0) {",
"l = sizeof(buf);",
"if (l > VAR_1)\nl = VAR_1;",
"cpu_memory_rw_debug(cpu, VAR_0, buf, l, 0);",
"if (fwrite(buf, 1, l, f) != l) {",
"error_set(VAR_5, QERR_IO_ERROR);",
"goto exit;",
"}",
"VAR_0 += l;",
"VAR_1 -= l;",
"}",
"exit:\nfclose(f);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
81
]
] |
27,274 | static void xen_platform_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = xen_platform_initfn;
k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;
k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->revision = 1;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
dc->desc = "XEN platform pci device";
dc->reset = platform_reset;
dc->vmsd = &vmstate_xen_platform;
}
| false | qemu | 4098d49db549e20a2d87ca3cced28ace6e5864bf | static void xen_platform_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = xen_platform_initfn;
k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;
k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->revision = 1;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
dc->desc = "XEN platform pci device";
dc->reset = platform_reset;
dc->vmsd = &vmstate_xen_platform;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);
k->init = xen_platform_initfn;
k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;
k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->revision = 1;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
dc->desc = "XEN platform pci device";
dc->reset = platform_reset;
dc->vmsd = &vmstate_xen_platform;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);",
"k->init = xen_platform_initfn;",
"k->vendor_id = PCI_VENDOR_ID_XEN;",
"k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;",
"k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;",
"k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;",
"k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;",
"k->revision = 1;",
"set_bit(DEVICE_CATEGORY_MISC, dc->categories);",
"dc->desc = \"XEN platform pci device\";",
"dc->reset = platform_reset;",
"dc->vmsd = &vmstate_xen_platform;",
"}"
] | [
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
]
] |
27,277 | int net_init_slirp(QemuOpts *opts,
Monitor *mon,
const char *name,
VLANState *vlan)
{
struct slirp_config_str *config;
const char *vhost;
const char *vhostname;
const char *vdhcp_start;
const char *vnamesrv;
const char *tftp_export;
const char *bootfile;
const char *smb_export;
const char *vsmbsrv;
char *vnet = NULL;
int restricted = 0;
int ret;
vhost = qemu_opt_get(opts, "host");
vhostname = qemu_opt_get(opts, "hostname");
vdhcp_start = qemu_opt_get(opts, "dhcpstart");
vnamesrv = qemu_opt_get(opts, "dns");
tftp_export = qemu_opt_get(opts, "tftp");
bootfile = qemu_opt_get(opts, "bootfile");
smb_export = qemu_opt_get(opts, "smb");
vsmbsrv = qemu_opt_get(opts, "smbserver");
if (qemu_opt_get(opts, "ip")) {
const char *ip = qemu_opt_get(opts, "ip");
int l = strlen(ip) + strlen("/24") + 1;
vnet = qemu_malloc(l);
/* emulate legacy ip= parameter */
pstrcpy(vnet, l, ip);
pstrcat(vnet, l, "/24");
}
if (qemu_opt_get(opts, "net")) {
if (vnet) {
qemu_free(vnet);
}
vnet = qemu_strdup(qemu_opt_get(opts, "net"));
}
if (qemu_opt_get(opts, "restrict") &&
qemu_opt_get(opts, "restrict")[0] == 'y') {
restricted = 1;
}
qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
ret = net_slirp_init(vlan, "user", name, restricted, vnet, vhost,
vhostname, tftp_export, bootfile, vdhcp_start,
vnamesrv, smb_export, vsmbsrv);
while (slirp_configs) {
config = slirp_configs;
slirp_configs = config->next;
qemu_free(config);
}
if (ret != -1 && vlan) {
vlan->nb_host_devs++;
}
qemu_free(vnet);
return ret;
}
| false | qemu | 62112d181ca33fea976100c4335dfc3e2f727e6c | int net_init_slirp(QemuOpts *opts,
Monitor *mon,
const char *name,
VLANState *vlan)
{
struct slirp_config_str *config;
const char *vhost;
const char *vhostname;
const char *vdhcp_start;
const char *vnamesrv;
const char *tftp_export;
const char *bootfile;
const char *smb_export;
const char *vsmbsrv;
char *vnet = NULL;
int restricted = 0;
int ret;
vhost = qemu_opt_get(opts, "host");
vhostname = qemu_opt_get(opts, "hostname");
vdhcp_start = qemu_opt_get(opts, "dhcpstart");
vnamesrv = qemu_opt_get(opts, "dns");
tftp_export = qemu_opt_get(opts, "tftp");
bootfile = qemu_opt_get(opts, "bootfile");
smb_export = qemu_opt_get(opts, "smb");
vsmbsrv = qemu_opt_get(opts, "smbserver");
if (qemu_opt_get(opts, "ip")) {
const char *ip = qemu_opt_get(opts, "ip");
int l = strlen(ip) + strlen("/24") + 1;
vnet = qemu_malloc(l);
pstrcpy(vnet, l, ip);
pstrcat(vnet, l, "/24");
}
if (qemu_opt_get(opts, "net")) {
if (vnet) {
qemu_free(vnet);
}
vnet = qemu_strdup(qemu_opt_get(opts, "net"));
}
if (qemu_opt_get(opts, "restrict") &&
qemu_opt_get(opts, "restrict")[0] == 'y') {
restricted = 1;
}
qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
ret = net_slirp_init(vlan, "user", name, restricted, vnet, vhost,
vhostname, tftp_export, bootfile, vdhcp_start,
vnamesrv, smb_export, vsmbsrv);
while (slirp_configs) {
config = slirp_configs;
slirp_configs = config->next;
qemu_free(config);
}
if (ret != -1 && vlan) {
vlan->nb_host_devs++;
}
qemu_free(vnet);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(QemuOpts *VAR_0,
Monitor *VAR_1,
const char *VAR_2,
VLANState *VAR_3)
{
struct slirp_config_str *VAR_4;
const char *VAR_5;
const char *VAR_6;
const char *VAR_7;
const char *VAR_8;
const char *VAR_9;
const char *VAR_10;
const char *VAR_11;
const char *VAR_12;
char *VAR_13 = NULL;
int VAR_14 = 0;
int VAR_15;
VAR_5 = qemu_opt_get(VAR_0, "host");
VAR_6 = qemu_opt_get(VAR_0, "hostname");
VAR_7 = qemu_opt_get(VAR_0, "dhcpstart");
VAR_8 = qemu_opt_get(VAR_0, "dns");
VAR_9 = qemu_opt_get(VAR_0, "tftp");
VAR_10 = qemu_opt_get(VAR_0, "VAR_10");
VAR_11 = qemu_opt_get(VAR_0, "smb");
VAR_12 = qemu_opt_get(VAR_0, "smbserver");
if (qemu_opt_get(VAR_0, "VAR_16")) {
const char *VAR_16 = qemu_opt_get(VAR_0, "VAR_16");
int VAR_17 = strlen(VAR_16) + strlen("/24") + 1;
VAR_13 = qemu_malloc(VAR_17);
pstrcpy(VAR_13, VAR_17, VAR_16);
pstrcat(VAR_13, VAR_17, "/24");
}
if (qemu_opt_get(VAR_0, "net")) {
if (VAR_13) {
qemu_free(VAR_13);
}
VAR_13 = qemu_strdup(qemu_opt_get(VAR_0, "net"));
}
if (qemu_opt_get(VAR_0, "restrict") &&
qemu_opt_get(VAR_0, "restrict")[0] == 'y') {
VAR_14 = 1;
}
qemu_opt_foreach(VAR_0, net_init_slirp_configs, NULL, 0);
VAR_15 = net_slirp_init(VAR_3, "user", VAR_2, VAR_14, VAR_13, VAR_5,
VAR_6, VAR_9, VAR_10, VAR_7,
VAR_8, VAR_11, VAR_12);
while (slirp_configs) {
VAR_4 = slirp_configs;
slirp_configs = VAR_4->next;
qemu_free(VAR_4);
}
if (VAR_15 != -1 && VAR_3) {
VAR_3->nb_host_devs++;
}
qemu_free(VAR_13);
return VAR_15;
}
| [
"int FUNC_0(QemuOpts *VAR_0,\nMonitor *VAR_1,\nconst char *VAR_2,\nVLANState *VAR_3)\n{",
"struct slirp_config_str *VAR_4;",
"const char *VAR_5;",
"const char *VAR_6;",
"const char *VAR_7;",
"const char *VAR_8;",
"const char *VAR_9;",
"const char *VAR_10;",
"const char *VAR_11;",
"const char *VAR_12;",
"char *VAR_13 = NULL;",
"int VAR_14 = 0;",
"int VAR_15;",
"VAR_5 = qemu_opt_get(VAR_0, \"host\");",
"VAR_6 = qemu_opt_get(VAR_0, \"hostname\");",
"VAR_7 = qemu_opt_get(VAR_0, \"dhcpstart\");",
"VAR_8 = qemu_opt_get(VAR_0, \"dns\");",
"VAR_9 = qemu_opt_get(VAR_0, \"tftp\");",
"VAR_10 = qemu_opt_get(VAR_0, \"VAR_10\");",
"VAR_11 = qemu_opt_get(VAR_0, \"smb\");",
"VAR_12 = qemu_opt_get(VAR_0, \"smbserver\");",
"if (qemu_opt_get(VAR_0, \"VAR_16\")) {",
"const char *VAR_16 = qemu_opt_get(VAR_0, \"VAR_16\");",
"int VAR_17 = strlen(VAR_16) + strlen(\"/24\") + 1;",
"VAR_13 = qemu_malloc(VAR_17);",
"pstrcpy(VAR_13, VAR_17, VAR_16);",
"pstrcat(VAR_13, VAR_17, \"/24\");",
"}",
"if (qemu_opt_get(VAR_0, \"net\")) {",
"if (VAR_13) {",
"qemu_free(VAR_13);",
"}",
"VAR_13 = qemu_strdup(qemu_opt_get(VAR_0, \"net\"));",
"}",
"if (qemu_opt_get(VAR_0, \"restrict\") &&\nqemu_opt_get(VAR_0, \"restrict\")[0] == 'y') {",
"VAR_14 = 1;",
"}",
"qemu_opt_foreach(VAR_0, net_init_slirp_configs, NULL, 0);",
"VAR_15 = net_slirp_init(VAR_3, \"user\", VAR_2, VAR_14, VAR_13, VAR_5,\nVAR_6, VAR_9, VAR_10, VAR_7,\nVAR_8, VAR_11, VAR_12);",
"while (slirp_configs) {",
"VAR_4 = slirp_configs;",
"slirp_configs = VAR_4->next;",
"qemu_free(VAR_4);",
"}",
"if (VAR_15 != -1 && VAR_3) {",
"VAR_3->nb_host_devs++;",
"}",
"qemu_free(VAR_13);",
"return VAR_15;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
95
],
[
97
],
[
101
],
[
105,
107,
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
139
]
] |
27,278 | static QOSState *qvirtio_9p_start(void)
{
const char *cmd = "-fsdev local,id=fsdev0,security_model=none,path=%s "
"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s";
test_share = g_strdup("/tmp/qtest.XXXXXX");
g_assert_nonnull(mkdtemp(test_share));
return qtest_pc_boot(cmd, test_share, mount_tag);
}
| false | qemu | 30ca440eec9fe1d7eec5a48addac656438778278 | static QOSState *qvirtio_9p_start(void)
{
const char *cmd = "-fsdev local,id=fsdev0,security_model=none,path=%s "
"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s";
test_share = g_strdup("/tmp/qtest.XXXXXX");
g_assert_nonnull(mkdtemp(test_share));
return qtest_pc_boot(cmd, test_share, mount_tag);
}
| {
"code": [],
"line_no": []
} | static QOSState *FUNC_0(void)
{
const char *VAR_0 = "-fsdev local,id=fsdev0,security_model=none,path=%s "
"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s";
test_share = g_strdup("/tmp/qtest.XXXXXX");
g_assert_nonnull(mkdtemp(test_share));
return qtest_pc_boot(VAR_0, test_share, mount_tag);
}
| [
"static QOSState *FUNC_0(void)\n{",
"const char *VAR_0 = \"-fsdev local,id=fsdev0,security_model=none,path=%s \"\n\"-device virtio-9p-pci,fsdev=fsdev0,mount_tag=%s\";",
"test_share = g_strdup(\"/tmp/qtest.XXXXXX\");",
"g_assert_nonnull(mkdtemp(test_share));",
"return qtest_pc_boot(VAR_0, test_share, mount_tag);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
27,279 | static void test_read_without_media(void)
{
uint8_t ret;
ret = send_read_command();
g_assert(ret == 0);
}
| true | qemu | 6f442fe83821a06c5408056c7879e83a74f2ff32 | static void test_read_without_media(void)
{
uint8_t ret;
ret = send_read_command();
g_assert(ret == 0);
}
| {
"code": [
" ret = send_read_command();"
],
"line_no": [
9
]
} | static void FUNC_0(void)
{
uint8_t ret;
ret = send_read_command();
g_assert(ret == 0);
}
| [
"static void FUNC_0(void)\n{",
"uint8_t ret;",
"ret = send_read_command();",
"g_assert(ret == 0);",
"}"
] | [
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
27,280 | static void set_acpi_power_state(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMI_CHECK_CMD_LEN(4);
ibs->acpi_power_state[0] = cmd[2];
ibs->acpi_power_state[1] = cmd[3];
}
| true | qemu | 4f298a4b2957b7833bc607c951ca27c458d98d88 | static void set_acpi_power_state(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMI_CHECK_CMD_LEN(4);
ibs->acpi_power_state[0] = cmd[2];
ibs->acpi_power_state[1] = cmd[3];
}
| {
"code": [
" IPMI_CHECK_CMD_LEN(4);",
" IPMI_CHECK_CMD_LEN(4);",
" IPMI_CHECK_CMD_LEN(4);"
],
"line_no": [
11,
11,
11
]
} | static void FUNC_0(IPMIBmcSim *VAR_0,
uint8_t *VAR_1, unsigned int VAR_2,
uint8_t *VAR_3, unsigned int *VAR_4,
unsigned int VAR_5)
{
IPMI_CHECK_CMD_LEN(4);
VAR_0->acpi_power_state[0] = VAR_1[2];
VAR_0->acpi_power_state[1] = VAR_1[3];
}
| [
"static void FUNC_0(IPMIBmcSim *VAR_0,\nuint8_t *VAR_1, unsigned int VAR_2,\nuint8_t *VAR_3, unsigned int *VAR_4,\nunsigned int VAR_5)\n{",
"IPMI_CHECK_CMD_LEN(4);",
"VAR_0->acpi_power_state[0] = VAR_1[2];",
"VAR_0->acpi_power_state[1] = VAR_1[3];",
"}"
] | [
0,
1,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
27,281 | static void usb_uas_unrealize(USBDevice *dev, Error **errp)
{
UASDevice *uas = USB_UAS(dev);
qemu_bh_delete(uas->status_bh);
} | true | qemu | cd7bc87868d534f95e928cad98e2a52df7695771 | static void usb_uas_unrealize(USBDevice *dev, Error **errp)
{
UASDevice *uas = USB_UAS(dev);
qemu_bh_delete(uas->status_bh);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(USBDevice *VAR_0, Error **VAR_1)
{
UASDevice *uas = USB_UAS(VAR_0);
qemu_bh_delete(uas->status_bh);
} | [
"static void FUNC_0(USBDevice *VAR_0, Error **VAR_1)\n{",
"UASDevice *uas = USB_UAS(VAR_0);",
"qemu_bh_delete(uas->status_bh);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
3
],
[
4
],
[
5
]
] |
27,282 | static int sdp_parse(AVFormatContext *s, const char *content)
{
const char *p;
int letter;
/* Some SDP lines, particularly for Realmedia or ASF RTSP streams,
* contain long SDP lines containing complete ASF Headers (several
* kB) or arrays of MDPR (RM stream descriptor) headers plus
* "rulebooks" describing their properties. Therefore, the SDP line
* buffer is large.
*
* The Vorbis FMTP line can be up to 16KB - see sdp_parse_fmtp. */
char buf[16384], *q;
SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;
memset(s1, 0, sizeof(SDPParseState));
p = content;
for(;;) {
skip_spaces(&p);
letter = *p;
if (letter == '\0')
break;
p++;
if (*p != '=')
goto next_line;
p++;
/* get the content */
q = buf;
while (*p != '\n' && *p != '\r' && *p != '\0') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = *p;
p++;
}
*q = '\0';
sdp_parse_line(s, s1, letter, buf);
next_line:
while (*p != '\n' && *p != '\0')
p++;
if (*p == '\n')
p++;
}
return 0;
}
| false | FFmpeg | c89658008705d949c319df3fa6f400c481ad73e1 | static int sdp_parse(AVFormatContext *s, const char *content)
{
const char *p;
int letter;
char buf[16384], *q;
SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;
memset(s1, 0, sizeof(SDPParseState));
p = content;
for(;;) {
skip_spaces(&p);
letter = *p;
if (letter == '\0')
break;
p++;
if (*p != '=')
goto next_line;
p++;
q = buf;
while (*p != '\n' && *p != '\r' && *p != '\0') {
if ((q - buf) < sizeof(buf) - 1)
*q++ = *p;
p++;
}
*q = '\0';
sdp_parse_line(s, s1, letter, buf);
next_line:
while (*p != '\n' && *p != '\0')
p++;
if (*p == '\n')
p++;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1)
{
const char *VAR_2;
int VAR_3;
char VAR_4[16384], *VAR_5;
SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;
memset(s1, 0, sizeof(SDPParseState));
VAR_2 = VAR_1;
for(;;) {
skip_spaces(&VAR_2);
VAR_3 = *VAR_2;
if (VAR_3 == '\0')
break;
VAR_2++;
if (*VAR_2 != '=')
goto next_line;
VAR_2++;
VAR_5 = VAR_4;
while (*VAR_2 != '\n' && *VAR_2 != '\r' && *VAR_2 != '\0') {
if ((VAR_5 - VAR_4) < sizeof(VAR_4) - 1)
*VAR_5++ = *VAR_2;
VAR_2++;
}
*VAR_5 = '\0';
sdp_parse_line(VAR_0, s1, VAR_3, VAR_4);
next_line:
while (*VAR_2 != '\n' && *VAR_2 != '\0')
VAR_2++;
if (*VAR_2 == '\n')
VAR_2++;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1)\n{",
"const char *VAR_2;",
"int VAR_3;",
"char VAR_4[16384], *VAR_5;",
"SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;",
"memset(s1, 0, sizeof(SDPParseState));",
"VAR_2 = VAR_1;",
"for(;;) {",
"skip_spaces(&VAR_2);",
"VAR_3 = *VAR_2;",
"if (VAR_3 == '\\0')\nbreak;",
"VAR_2++;",
"if (*VAR_2 != '=')\ngoto next_line;",
"VAR_2++;",
"VAR_5 = VAR_4;",
"while (*VAR_2 != '\\n' && *VAR_2 != '\\r' && *VAR_2 != '\\0') {",
"if ((VAR_5 - VAR_4) < sizeof(VAR_4) - 1)\n*VAR_5++ = *VAR_2;",
"VAR_2++;",
"}",
"*VAR_5 = '\\0';",
"sdp_parse_line(VAR_0, s1, VAR_3, VAR_4);",
"next_line:\nwhile (*VAR_2 != '\\n' && *VAR_2 != '\\0')\nVAR_2++;",
"if (*VAR_2 == '\\n')\nVAR_2++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
]
] |
27,283 | static void flush_change(H264Context *h)
{
h->outputed_poc = h->next_outputed_poc = INT_MIN;
h->prev_interlaced_frame = 1;
idr(h);
h->prev_frame_num = -1;
if (h->s.current_picture_ptr)
h->s.current_picture_ptr->f.reference = 0;
h->s.first_field = 0;
memset(h->ref_list[0], 0, sizeof(h->ref_list[0]));
memset(h->ref_list[1], 0, sizeof(h->ref_list[1]));
memset(h->default_ref_list[0], 0, sizeof(h->default_ref_list[0]));
memset(h->default_ref_list[1], 0, sizeof(h->default_ref_list[1]));
ff_h264_reset_sei(h);
h->recovery_frame= -1;
h->sync= 0;
h->list_count = 0;
h->current_slice = 0;
}
| true | FFmpeg | aaa7d2fafcc375d8cdef25a289008821c9c2fbaa | static void flush_change(H264Context *h)
{
h->outputed_poc = h->next_outputed_poc = INT_MIN;
h->prev_interlaced_frame = 1;
idr(h);
h->prev_frame_num = -1;
if (h->s.current_picture_ptr)
h->s.current_picture_ptr->f.reference = 0;
h->s.first_field = 0;
memset(h->ref_list[0], 0, sizeof(h->ref_list[0]));
memset(h->ref_list[1], 0, sizeof(h->ref_list[1]));
memset(h->default_ref_list[0], 0, sizeof(h->default_ref_list[0]));
memset(h->default_ref_list[1], 0, sizeof(h->default_ref_list[1]));
ff_h264_reset_sei(h);
h->recovery_frame= -1;
h->sync= 0;
h->list_count = 0;
h->current_slice = 0;
}
| {
"code": [
" if (h->s.current_picture_ptr)"
],
"line_no": [
13
]
} | static void FUNC_0(H264Context *VAR_0)
{
VAR_0->outputed_poc = VAR_0->next_outputed_poc = INT_MIN;
VAR_0->prev_interlaced_frame = 1;
idr(VAR_0);
VAR_0->prev_frame_num = -1;
if (VAR_0->s.current_picture_ptr)
VAR_0->s.current_picture_ptr->f.reference = 0;
VAR_0->s.first_field = 0;
memset(VAR_0->ref_list[0], 0, sizeof(VAR_0->ref_list[0]));
memset(VAR_0->ref_list[1], 0, sizeof(VAR_0->ref_list[1]));
memset(VAR_0->default_ref_list[0], 0, sizeof(VAR_0->default_ref_list[0]));
memset(VAR_0->default_ref_list[1], 0, sizeof(VAR_0->default_ref_list[1]));
ff_h264_reset_sei(VAR_0);
VAR_0->recovery_frame= -1;
VAR_0->sync= 0;
VAR_0->list_count = 0;
VAR_0->current_slice = 0;
}
| [
"static void FUNC_0(H264Context *VAR_0)\n{",
"VAR_0->outputed_poc = VAR_0->next_outputed_poc = INT_MIN;",
"VAR_0->prev_interlaced_frame = 1;",
"idr(VAR_0);",
"VAR_0->prev_frame_num = -1;",
"if (VAR_0->s.current_picture_ptr)\nVAR_0->s.current_picture_ptr->f.reference = 0;",
"VAR_0->s.first_field = 0;",
"memset(VAR_0->ref_list[0], 0, sizeof(VAR_0->ref_list[0]));",
"memset(VAR_0->ref_list[1], 0, sizeof(VAR_0->ref_list[1]));",
"memset(VAR_0->default_ref_list[0], 0, sizeof(VAR_0->default_ref_list[0]));",
"memset(VAR_0->default_ref_list[1], 0, sizeof(VAR_0->default_ref_list[1]));",
"ff_h264_reset_sei(VAR_0);",
"VAR_0->recovery_frame= -1;",
"VAR_0->sync= 0;",
"VAR_0->list_count = 0;",
"VAR_0->current_slice = 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
27,284 | int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
const void *in,
void *out,
size_t len,
Error **errp)
{
QCryptoCipherNettle *ctx = cipher->opaque;
switch (cipher->mode) {
case QCRYPTO_CIPHER_MODE_ECB:
ctx->alg_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
len, out, in);
break;
case QCRYPTO_CIPHER_MODE_CBC:
cbc_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
ctx->alg_decrypt, ctx->niv, ctx->iv,
len, out, in);
break;
default:
error_setg(errp, "Unsupported cipher algorithm %d",
cipher->alg);
return -1;
}
return 0;
}
| true | qemu | 3a661f1eabf7e8db66e28489884d9b54aacb94ea | int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
const void *in,
void *out,
size_t len,
Error **errp)
{
QCryptoCipherNettle *ctx = cipher->opaque;
switch (cipher->mode) {
case QCRYPTO_CIPHER_MODE_ECB:
ctx->alg_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
len, out, in);
break;
case QCRYPTO_CIPHER_MODE_CBC:
cbc_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
ctx->alg_decrypt, ctx->niv, ctx->iv,
len, out, in);
break;
default:
error_setg(errp, "Unsupported cipher algorithm %d",
cipher->alg);
return -1;
}
return 0;
}
| {
"code": [
" ctx->alg_decrypt, ctx->niv, ctx->iv,"
],
"line_no": [
33
]
} | int FUNC_0(QCryptoCipher *VAR_0,
const void *VAR_1,
void *VAR_2,
size_t VAR_3,
Error **VAR_4)
{
QCryptoCipherNettle *ctx = VAR_0->opaque;
switch (VAR_0->mode) {
case QCRYPTO_CIPHER_MODE_ECB:
ctx->alg_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
VAR_3, VAR_2, VAR_1);
break;
case QCRYPTO_CIPHER_MODE_CBC:
cbc_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,
ctx->alg_decrypt, ctx->niv, ctx->iv,
VAR_3, VAR_2, VAR_1);
break;
default:
error_setg(VAR_4, "Unsupported VAR_0 algorithm %d",
VAR_0->alg);
return -1;
}
return 0;
}
| [
"int FUNC_0(QCryptoCipher *VAR_0,\nconst void *VAR_1,\nvoid *VAR_2,\nsize_t VAR_3,\nError **VAR_4)\n{",
"QCryptoCipherNettle *ctx = VAR_0->opaque;",
"switch (VAR_0->mode) {",
"case QCRYPTO_CIPHER_MODE_ECB:\nctx->alg_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,\nVAR_3, VAR_2, VAR_1);",
"break;",
"case QCRYPTO_CIPHER_MODE_CBC:\ncbc_decrypt(ctx->ctx_decrypt ? ctx->ctx_decrypt : ctx->ctx_encrypt,\nctx->alg_decrypt, ctx->niv, ctx->iv,\nVAR_3, VAR_2, VAR_1);",
"break;",
"default:\nerror_setg(VAR_4, \"Unsupported VAR_0 algorithm %d\",\nVAR_0->alg);",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
17
],
[
19,
21,
23
],
[
25
],
[
29,
31,
33,
35
],
[
37
],
[
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
]
] |
27,285 | static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
{
QOSState *tmp = to->parent;
QPCIDevice *dev = to->dev;
char *uri_local = NULL;
if (uri == NULL) {
uri_local = g_strdup_printf("%s%s", "unix:", mig_socket);
uri = uri_local;
}
/* context will be 'to' after completion. */
migrate(from->parent, to->parent, uri);
/* We'd like for the AHCIState objects to still point
* to information specific to its specific parent
* instance, but otherwise just inherit the new data. */
memcpy(to, from, sizeof(AHCIQState));
to->parent = tmp;
to->dev = dev;
tmp = from->parent;
dev = from->dev;
memset(from, 0x00, sizeof(AHCIQState));
from->parent = tmp;
from->dev = dev;
verify_state(to);
g_free(uri_local);
}
| true | qemu | e7c8526b2a1482a9b14319fda9f8ad4bfda5b958 | static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
{
QOSState *tmp = to->parent;
QPCIDevice *dev = to->dev;
char *uri_local = NULL;
if (uri == NULL) {
uri_local = g_strdup_printf("%s%s", "unix:", mig_socket);
uri = uri_local;
}
migrate(from->parent, to->parent, uri);
memcpy(to, from, sizeof(AHCIQState));
to->parent = tmp;
to->dev = dev;
tmp = from->parent;
dev = from->dev;
memset(from, 0x00, sizeof(AHCIQState));
from->parent = tmp;
from->dev = dev;
verify_state(to);
g_free(uri_local);
}
| {
"code": [
" verify_state(to);"
],
"line_no": [
55
]
} | static void FUNC_0(AHCIQState *VAR_0, AHCIQState *VAR_1, const char *VAR_2)
{
QOSState *tmp = VAR_1->parent;
QPCIDevice *dev = VAR_1->dev;
char *VAR_3 = NULL;
if (VAR_2 == NULL) {
VAR_3 = g_strdup_printf("%s%s", "unix:", mig_socket);
VAR_2 = VAR_3;
}
migrate(VAR_0->parent, VAR_1->parent, VAR_2);
memcpy(VAR_1, VAR_0, sizeof(AHCIQState));
VAR_1->parent = tmp;
VAR_1->dev = dev;
tmp = VAR_0->parent;
dev = VAR_0->dev;
memset(VAR_0, 0x00, sizeof(AHCIQState));
VAR_0->parent = tmp;
VAR_0->dev = dev;
verify_state(VAR_1);
g_free(VAR_3);
}
| [
"static void FUNC_0(AHCIQState *VAR_0, AHCIQState *VAR_1, const char *VAR_2)\n{",
"QOSState *tmp = VAR_1->parent;",
"QPCIDevice *dev = VAR_1->dev;",
"char *VAR_3 = NULL;",
"if (VAR_2 == NULL) {",
"VAR_3 = g_strdup_printf(\"%s%s\", \"unix:\", mig_socket);",
"VAR_2 = VAR_3;",
"}",
"migrate(VAR_0->parent, VAR_1->parent, VAR_2);",
"memcpy(VAR_1, VAR_0, sizeof(AHCIQState));",
"VAR_1->parent = tmp;",
"VAR_1->dev = dev;",
"tmp = VAR_0->parent;",
"dev = VAR_0->dev;",
"memset(VAR_0, 0x00, sizeof(AHCIQState));",
"VAR_0->parent = tmp;",
"VAR_0->dev = dev;",
"verify_state(VAR_1);",
"g_free(VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
]
] |
27,286 | static int kvm_virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
unsigned int queue_no,
unsigned int vector,
MSIMessage msg)
{
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
int ret;
if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address) {
ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg);
if (ret < 0) {
return ret;
}
}
/* If guest supports masking, irqfd is already setup, unmask it.
* Otherwise, set it up now.
*/
if (proxy->vdev->guest_notifier_mask) {
proxy->vdev->guest_notifier_mask(proxy->vdev, queue_no, false);
/* Test after unmasking to avoid losing events. */
if (proxy->vdev->guest_notifier_pending &&
proxy->vdev->guest_notifier_pending(proxy->vdev, queue_no)) {
event_notifier_set(n);
}
} else {
ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
}
return ret;
}
| true | qemu | 53510bfc1256711365cd2a841649f3ad5a79790f | static int kvm_virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy,
unsigned int queue_no,
unsigned int vector,
MSIMessage msg)
{
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector];
int ret;
if (irqfd->msg.data != msg.data || irqfd->msg.address != msg.address) {
ret = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, msg);
if (ret < 0) {
return ret;
}
}
if (proxy->vdev->guest_notifier_mask) {
proxy->vdev->guest_notifier_mask(proxy->vdev, queue_no, false);
if (proxy->vdev->guest_notifier_pending &&
proxy->vdev->guest_notifier_pending(proxy->vdev, queue_no)) {
event_notifier_set(n);
}
} else {
ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector);
}
return ret;
}
| {
"code": [
" int ret;"
],
"line_no": [
17
]
} | static int FUNC_0(VirtIOPCIProxy *VAR_0,
unsigned int VAR_1,
unsigned int VAR_2,
MSIMessage VAR_3)
{
VirtQueue *vq = virtio_get_queue(VAR_0->vdev, VAR_1);
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
VirtIOIRQFD *irqfd = &VAR_0->vector_irqfd[VAR_2];
int VAR_4;
if (irqfd->VAR_3.data != VAR_3.data || irqfd->VAR_3.address != VAR_3.address) {
VAR_4 = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, VAR_3);
if (VAR_4 < 0) {
return VAR_4;
}
}
if (VAR_0->vdev->guest_notifier_mask) {
VAR_0->vdev->guest_notifier_mask(VAR_0->vdev, VAR_1, false);
if (VAR_0->vdev->guest_notifier_pending &&
VAR_0->vdev->guest_notifier_pending(VAR_0->vdev, VAR_1)) {
event_notifier_set(n);
}
} else {
VAR_4 = kvm_virtio_pci_irqfd_use(VAR_0, VAR_1, VAR_2);
}
return VAR_4;
}
| [
"static int FUNC_0(VirtIOPCIProxy *VAR_0,\nunsigned int VAR_1,\nunsigned int VAR_2,\nMSIMessage VAR_3)\n{",
"VirtQueue *vq = virtio_get_queue(VAR_0->vdev, VAR_1);",
"EventNotifier *n = virtio_queue_get_guest_notifier(vq);",
"VirtIOIRQFD *irqfd = &VAR_0->vector_irqfd[VAR_2];",
"int VAR_4;",
"if (irqfd->VAR_3.data != VAR_3.data || irqfd->VAR_3.address != VAR_3.address) {",
"VAR_4 = kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, VAR_3);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"}",
"if (VAR_0->vdev->guest_notifier_mask) {",
"VAR_0->vdev->guest_notifier_mask(VAR_0->vdev, VAR_1, false);",
"if (VAR_0->vdev->guest_notifier_pending &&\nVAR_0->vdev->guest_notifier_pending(VAR_0->vdev, VAR_1)) {",
"event_notifier_set(n);",
"}",
"} else {",
"VAR_4 = kvm_virtio_pci_irqfd_use(VAR_0, VAR_1, VAR_2);",
"}",
"return VAR_4;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
27,287 | static int vvfat_open(BlockDriverState *bs, const char* dirname, int flags)
{
BDRVVVFATState *s = bs->opaque;
int floppy = 0;
int i;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
s->bs = bs;
s->fat_type=16;
/* LATER TODO: if FAT32, adjust */
s->sectors_per_cluster=0x10;
/* 504MB disk*/
bs->cyls=1024; bs->heads=16; bs->secs=63;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
/* read only is the default for safety */
bs->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
if (!strstart(dirname, "fat:", NULL))
return -1;
if (strstr(dirname, ":floppy:")) {
floppy = 1;
s->fat_type = 12;
s->first_sectors_number = 1;
s->sectors_per_cluster=2;
bs->cyls = 80; bs->heads = 2; bs->secs = 36;
}
if (strstr(dirname, ":32:")) {
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. You are welcome to do so!\n");
s->fat_type = 32;
} else if (strstr(dirname, ":16:")) {
s->fat_type = 16;
} else if (strstr(dirname, ":12:")) {
s->fat_type = 12;
bs->secs = 18;
}
s->sector_count=bs->cyls*bs->heads*bs->secs-(s->first_sectors_number-1);
if (strstr(dirname, ":rw:")) {
if (enable_write_target(s))
return -1;
bs->read_only = 0;
}
i = strrchr(dirname, ':') - dirname;
assert(i >= 3);
if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1]))
/* workaround for DOS drive names */
dirname += i-1;
else
dirname += i+1;
bs->total_sectors=bs->cyls*bs->heads*bs->secs;
if(init_directories(s, dirname))
return -1;
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if(s->first_sectors_number==0x40)
init_mbr(s);
/* for some reason or other, MS-DOS does not like to know about CHS... */
if (floppy)
bs->heads = bs->cyls = bs->secs = 0;
// assert(is_consistent(s));
qemu_co_mutex_init(&s->lock);
return 0;
}
| true | qemu | 273e4e03b3413fd489601cd9d8ba407ccb3b4130 | static int vvfat_open(BlockDriverState *bs, const char* dirname, int flags)
{
BDRVVVFATState *s = bs->opaque;
int floppy = 0;
int i;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
s->bs = bs;
s->fat_type=16;
s->sectors_per_cluster=0x10;
bs->cyls=1024; bs->heads=16; bs->secs=63;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
bs->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
if (!strstart(dirname, "fat:", NULL))
return -1;
if (strstr(dirname, ":floppy:")) {
floppy = 1;
s->fat_type = 12;
s->first_sectors_number = 1;
s->sectors_per_cluster=2;
bs->cyls = 80; bs->heads = 2; bs->secs = 36;
}
if (strstr(dirname, ":32:")) {
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. You are welcome to do so!\n");
s->fat_type = 32;
} else if (strstr(dirname, ":16:")) {
s->fat_type = 16;
} else if (strstr(dirname, ":12:")) {
s->fat_type = 12;
bs->secs = 18;
}
s->sector_count=bs->cyls*bs->heads*bs->secs-(s->first_sectors_number-1);
if (strstr(dirname, ":rw:")) {
if (enable_write_target(s))
return -1;
bs->read_only = 0;
}
i = strrchr(dirname, ':') - dirname;
assert(i >= 3);
if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1]))
dirname += i-1;
else
dirname += i+1;
bs->total_sectors=bs->cyls*bs->heads*bs->secs;
if(init_directories(s, dirname))
return -1;
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if(s->first_sectors_number==0x40)
init_mbr(s);
if (floppy)
bs->heads = bs->cyls = bs->secs = 0;
qemu_co_mutex_init(&s->lock);
return 0;
}
| {
"code": [
" int floppy = 0;",
" s->fat_type=16;",
" bs->cyls=1024; bs->heads=16; bs->secs=63;",
" if (strstr(dirname, \":floppy:\")) {",
"\tfloppy = 1;",
"\ts->fat_type = 12;",
"\ts->first_sectors_number = 1;",
"\ts->sectors_per_cluster=2;",
"\tbs->cyls = 80; bs->heads = 2; bs->secs = 36;",
"\tbs->secs = 18;",
" if (floppy)"
],
"line_no": [
7,
35,
43,
73,
75,
77,
79,
81,
83,
103,
163
]
} | static int FUNC_0(BlockDriverState *VAR_0, const char* VAR_1, int VAR_2)
{
BDRVVVFATState *s = VAR_0->opaque;
int VAR_3 = 0;
int VAR_4;
#ifdef DEBUG
vvv = s;
#endif
DLOG(if (stderr == NULL) {
stderr = fopen("vvfat.log", "a");
setbuf(stderr, NULL);
})
s->VAR_0 = VAR_0;
s->fat_type=16;
s->sectors_per_cluster=0x10;
VAR_0->cyls=1024; VAR_0->heads=16; VAR_0->secs=63;
s->current_cluster=0xffffffff;
s->first_sectors_number=0x40;
VAR_0->read_only = 1;
s->qcow = s->write_target = NULL;
s->qcow_filename = NULL;
s->fat2 = NULL;
s->downcase_short_names = 1;
if (!strstart(VAR_1, "fat:", NULL))
return -1;
if (strstr(VAR_1, ":VAR_3:")) {
VAR_3 = 1;
s->fat_type = 12;
s->first_sectors_number = 1;
s->sectors_per_cluster=2;
VAR_0->cyls = 80; VAR_0->heads = 2; VAR_0->secs = 36;
}
if (strstr(VAR_1, ":32:")) {
fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. You are welcome to do so!\n");
s->fat_type = 32;
} else if (strstr(VAR_1, ":16:")) {
s->fat_type = 16;
} else if (strstr(VAR_1, ":12:")) {
s->fat_type = 12;
VAR_0->secs = 18;
}
s->sector_count=VAR_0->cyls*VAR_0->heads*VAR_0->secs-(s->first_sectors_number-1);
if (strstr(VAR_1, ":rw:")) {
if (enable_write_target(s))
return -1;
VAR_0->read_only = 0;
}
VAR_4 = strrchr(VAR_1, ':') - VAR_1;
assert(VAR_4 >= 3);
if (VAR_1[VAR_4-2] == ':' && qemu_isalpha(VAR_1[VAR_4-1]))
VAR_1 += VAR_4-1;
else
VAR_1 += VAR_4+1;
VAR_0->total_sectors=VAR_0->cyls*VAR_0->heads*VAR_0->secs;
if(init_directories(s, VAR_1))
return -1;
s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
if(s->first_sectors_number==0x40)
init_mbr(s);
if (VAR_3)
VAR_0->heads = VAR_0->cyls = VAR_0->secs = 0;
qemu_co_mutex_init(&s->lock);
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, const char* VAR_1, int VAR_2)\n{",
"BDRVVVFATState *s = VAR_0->opaque;",
"int VAR_3 = 0;",
"int VAR_4;",
"#ifdef DEBUG\nvvv = s;",
"#endif\nDLOG(if (stderr == NULL) {",
"stderr = fopen(\"vvfat.log\", \"a\");",
"setbuf(stderr, NULL);",
"})",
"s->VAR_0 = VAR_0;",
"s->fat_type=16;",
"s->sectors_per_cluster=0x10;",
"VAR_0->cyls=1024; VAR_0->heads=16; VAR_0->secs=63;",
"s->current_cluster=0xffffffff;",
"s->first_sectors_number=0x40;",
"VAR_0->read_only = 1;",
"s->qcow = s->write_target = NULL;",
"s->qcow_filename = NULL;",
"s->fat2 = NULL;",
"s->downcase_short_names = 1;",
"if (!strstart(VAR_1, \"fat:\", NULL))\nreturn -1;",
"if (strstr(VAR_1, \":VAR_3:\")) {",
"VAR_3 = 1;",
"s->fat_type = 12;",
"s->first_sectors_number = 1;",
"s->sectors_per_cluster=2;",
"VAR_0->cyls = 80; VAR_0->heads = 2; VAR_0->secs = 36;",
"}",
"if (strstr(VAR_1, \":32:\")) {",
"fprintf(stderr, \"Big fat greek warning: FAT32 has not been tested. You are welcome to do so!\\n\");",
"s->fat_type = 32;",
"} else if (strstr(VAR_1, \":16:\")) {",
"s->fat_type = 16;",
"} else if (strstr(VAR_1, \":12:\")) {",
"s->fat_type = 12;",
"VAR_0->secs = 18;",
"}",
"s->sector_count=VAR_0->cyls*VAR_0->heads*VAR_0->secs-(s->first_sectors_number-1);",
"if (strstr(VAR_1, \":rw:\")) {",
"if (enable_write_target(s))\nreturn -1;",
"VAR_0->read_only = 0;",
"}",
"VAR_4 = strrchr(VAR_1, ':') - VAR_1;",
"assert(VAR_4 >= 3);",
"if (VAR_1[VAR_4-2] == ':' && qemu_isalpha(VAR_1[VAR_4-1]))\nVAR_1 += VAR_4-1;",
"else\nVAR_1 += VAR_4+1;",
"VAR_0->total_sectors=VAR_0->cyls*VAR_0->heads*VAR_0->secs;",
"if(init_directories(s, VAR_1))\nreturn -1;",
"s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;",
"if(s->first_sectors_number==0x40)\ninit_mbr(s);",
"if (VAR_3)\nVAR_0->heads = VAR_0->cyls = VAR_0->secs = 0;",
"qemu_co_mutex_init(&s->lock);",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
17,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
35
],
[
39
],
[
43
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129,
133
],
[
135,
137
],
[
141
],
[
145,
147
],
[
151
],
[
155,
157
],
[
163,
165
],
[
171
],
[
173
],
[
175
]
] |
27,288 | VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
{
VirtIOSCSI *s;
static int virtio_scsi_id;
size_t sz;
int i;
sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *);
s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig), sz);
s->qdev = dev;
s->conf = proxyconf;
/* TODO set up vdev function pointers */
s->vdev.get_config = virtio_scsi_get_config;
s->vdev.set_config = virtio_scsi_set_config;
s->vdev.get_features = virtio_scsi_get_features;
s->vdev.reset = virtio_scsi_reset;
s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
NULL);
for (i = 0; i < s->conf->num_queues; i++) {
s->cmd_vqs[i] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
scsi_bus_new(&s->bus, dev, &virtio_scsi_scsi_info);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus);
}
register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
virtio_scsi_save, virtio_scsi_load, s);
return &s->vdev;
}
| true | qemu | 619d7ae952bb61ec27ec21fe4a383a8d4dd4cd70 | VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
{
VirtIOSCSI *s;
static int virtio_scsi_id;
size_t sz;
int i;
sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *);
s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig), sz);
s->qdev = dev;
s->conf = proxyconf;
s->vdev.get_config = virtio_scsi_get_config;
s->vdev.set_config = virtio_scsi_set_config;
s->vdev.get_features = virtio_scsi_get_features;
s->vdev.reset = virtio_scsi_reset;
s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
NULL);
for (i = 0; i < s->conf->num_queues; i++) {
s->cmd_vqs[i] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
scsi_bus_new(&s->bus, dev, &virtio_scsi_scsi_info);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus);
}
register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
virtio_scsi_save, virtio_scsi_load, s);
return &s->vdev;
}
| {
"code": [
" NULL);"
],
"line_no": [
47
]
} | VirtIODevice *FUNC_0(DeviceState *dev, VirtIOSCSIConf *proxyconf)
{
VirtIOSCSI *s;
static int VAR_0;
size_t sz;
int VAR_1;
sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *);
s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
sizeof(VirtIOSCSIConfig), sz);
s->qdev = dev;
s->conf = proxyconf;
s->vdev.get_config = virtio_scsi_get_config;
s->vdev.set_config = virtio_scsi_set_config;
s->vdev.get_features = virtio_scsi_get_features;
s->vdev.reset = virtio_scsi_reset;
s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_ctrl);
s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
NULL);
for (VAR_1 = 0; VAR_1 < s->conf->num_queues; VAR_1++) {
s->cmd_vqs[VAR_1] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,
virtio_scsi_handle_cmd);
}
scsi_bus_new(&s->bus, dev, &virtio_scsi_scsi_info);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus);
}
register_savevm(dev, "virtio-scsi", VAR_0++, 1,
virtio_scsi_save, virtio_scsi_load, s);
return &s->vdev;
}
| [
"VirtIODevice *FUNC_0(DeviceState *dev, VirtIOSCSIConf *proxyconf)\n{",
"VirtIOSCSI *s;",
"static int VAR_0;",
"size_t sz;",
"int VAR_1;",
"sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *);",
"s = (VirtIOSCSI *)virtio_common_init(\"virtio-scsi\", VIRTIO_ID_SCSI,\nsizeof(VirtIOSCSIConfig), sz);",
"s->qdev = dev;",
"s->conf = proxyconf;",
"s->vdev.get_config = virtio_scsi_get_config;",
"s->vdev.set_config = virtio_scsi_set_config;",
"s->vdev.get_features = virtio_scsi_get_features;",
"s->vdev.reset = virtio_scsi_reset;",
"s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,\nvirtio_scsi_handle_ctrl);",
"s->event_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,\nNULL);",
"for (VAR_1 = 0; VAR_1 < s->conf->num_queues; VAR_1++) {",
"s->cmd_vqs[VAR_1] = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE,\nvirtio_scsi_handle_cmd);",
"}",
"scsi_bus_new(&s->bus, dev, &virtio_scsi_scsi_info);",
"if (!dev->hotplugged) {",
"scsi_bus_legacy_handle_cmdline(&s->bus);",
"}",
"register_savevm(dev, \"virtio-scsi\", VAR_0++, 1,\nvirtio_scsi_save, virtio_scsi_load, s);",
"return &s->vdev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
75
],
[
77
]
] |
27,289 | static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double cutoff = cutoff0? cutoff0 : 0.97;
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor
|| c->filter_length != FFMAX((int)ceil(filter_size/factor), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
c->phase_shift = phase_shift;
c->phase_mask = phase_count - 1;
c->linear = linear;
c->factor = factor;
c->filter_length = FFMAX((int)ceil(filter_size/factor), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_calloc(c->filter_alloc, (phase_count+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
if (build_filter(c, (void*)c->filter_bank, factor, c->filter_length, c->filter_alloc, phase_count, 1<<c->filter_shift, filter_type, kaiser_beta))
memcpy(c->filter_bank + (c->filter_alloc*phase_count+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*phase_count )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2))
c->ideal_dst_incr= c->dst_incr;
c->index= -phase_count*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_freep(&c->filter_bank);
av_free(c);
return NULL; | true | FFmpeg | f9158b01d0f3effb58e87fb07db0382bc1e47de5 | static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double cutoff = cutoff0? cutoff0 : 0.97;
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor
|| c->filter_length != FFMAX((int)ceil(filter_size/factor), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
c->phase_shift = phase_shift;
c->phase_mask = phase_count - 1;
c->linear = linear;
c->factor = factor;
c->filter_length = FFMAX((int)ceil(filter_size/factor), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_calloc(c->filter_alloc, (phase_count+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
if (build_filter(c, (void*)c->filter_bank, factor, c->filter_length, c->filter_alloc, phase_count, 1<<c->filter_shift, filter_type, kaiser_beta))
memcpy(c->filter_bank + (c->filter_alloc*phase_count+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*phase_count )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2))
c->ideal_dst_incr= c->dst_incr;
c->index= -phase_count*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_freep(&c->filter_bank);
av_free(c);
return NULL; | {
"code": [],
"line_no": []
} | static ResampleContext *FUNC_0(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double VAR_0 = cutoff0? cutoff0 : 0.97;
double VAR_1= FFMIN(out_rate * VAR_0 / in_rate, 1.0);
int VAR_2= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->VAR_1 != VAR_1
|| c->filter_length != FFMAX((int)ceil(filter_size/VAR_1), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
c->phase_shift = phase_shift;
c->phase_mask = VAR_2 - 1;
c->linear = linear;
c->VAR_1 = VAR_1;
c->filter_length = FFMAX((int)ceil(filter_size/VAR_1), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_calloc(c->filter_alloc, (VAR_2+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
if (build_filter(c, (void*)c->filter_bank, VAR_1, c->filter_length, c->filter_alloc, VAR_2, 1<<c->filter_shift, filter_type, kaiser_beta))
memcpy(c->filter_bank + (c->filter_alloc*VAR_2+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*VAR_2 )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)VAR_2, INT32_MAX/2))
c->ideal_dst_incr= c->dst_incr;
c->index= -VAR_2*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_freep(&c->filter_bank);
av_free(c);
return NULL; | [
"static ResampleContext *FUNC_0(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,\ndouble cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,\ndouble precision, int cheby){",
"double VAR_0 = cutoff0? cutoff0 : 0.97;",
"double VAR_1= FFMIN(out_rate * VAR_0 / in_rate, 1.0);",
"int VAR_2= 1<<phase_shift;",
"if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->VAR_1 != VAR_1\n|| c->filter_length != FFMAX((int)ceil(filter_size/VAR_1), 1) || c->format != format\n|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {",
"c = av_mallocz(sizeof(*c));",
"if (!c)\nreturn NULL;",
"c->format= format;",
"c->felem_size= av_get_bytes_per_sample(c->format);",
"switch(c->format){",
"case AV_SAMPLE_FMT_S16P:\nc->filter_shift = 15;",
"break;",
"case AV_SAMPLE_FMT_S32P:\nc->filter_shift = 30;",
"break;",
"case AV_SAMPLE_FMT_FLTP:\ncase AV_SAMPLE_FMT_DBLP:\nc->filter_shift = 0;",
"break;",
"default:\nav_log(NULL, AV_LOG_ERROR, \"Unsupported sample format\\n\");",
"av_assert0(0);",
"c->phase_shift = phase_shift;",
"c->phase_mask = VAR_2 - 1;",
"c->linear = linear;",
"c->VAR_1 = VAR_1;",
"c->filter_length = FFMAX((int)ceil(filter_size/VAR_1), 1);",
"c->filter_alloc = FFALIGN(c->filter_length, 8);",
"c->filter_bank = av_calloc(c->filter_alloc, (VAR_2+1)*c->felem_size);",
"c->filter_type = filter_type;",
"c->kaiser_beta = kaiser_beta;",
"if (!c->filter_bank)\nif (build_filter(c, (void*)c->filter_bank, VAR_1, c->filter_length, c->filter_alloc, VAR_2, 1<<c->filter_shift, filter_type, kaiser_beta))\nmemcpy(c->filter_bank + (c->filter_alloc*VAR_2+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);",
"memcpy(c->filter_bank + (c->filter_alloc*VAR_2 )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);",
"c->compensation_distance= 0;",
"if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)VAR_2, INT32_MAX/2))\nc->ideal_dst_incr= c->dst_incr;",
"c->index= -VAR_2*((c->filter_length-1)/2);",
"c->frac= 0;",
"return c;",
"error:\nav_freep(&c->filter_bank);",
"av_free(c);",
"return NULL;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7,
8,
9
],
[
10
],
[
11,
12
],
[
13
],
[
14
],
[
15
],
[
16,
17
],
[
18
],
[
19,
20
],
[
21
],
[
22,
23,
24
],
[
25
],
[
26,
27
],
[
28
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38,
39,
40
],
[
41
],
[
42
],
[
43,
44
],
[
45
],
[
46
],
[
47
],
[
48,
49
],
[
50
],
[
51
]
] |
27,291 | static void test_properties(const char *path)
{
char *child_path;
QDict *response, *tuple;
QList *list;
QListEntry *entry;
g_test_message("Obtaining properties of %s", path);
response = qmp("{ 'execute': 'qom-list',"
" 'arguments': { 'path': '%s' } }", path);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
list = qobject_to_qlist(qdict_get(response, "return"));
QLIST_FOREACH_ENTRY(list, entry) {
tuple = qobject_to_qdict(qlist_entry_obj(entry));
if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) {
child_path = g_strdup_printf("%s/%s",
path, qdict_get_str(tuple, "name"));
test_properties(child_path);
g_free(child_path);
} else {
const char *prop = qdict_get_str(tuple, "name");
g_test_message("Testing property %s.%s", path, prop);
response = qmp("{ 'execute': 'qom-get',"
" 'arguments': { 'path': '%s',"
" 'property': '%s' } }",
path, prop);
/* qom-get may fail but should not, e.g., segfault. */
g_assert(response);
}
}
}
| true | qemu | 0380aef323154205a7d838fb9953423621290d41 | static void test_properties(const char *path)
{
char *child_path;
QDict *response, *tuple;
QList *list;
QListEntry *entry;
g_test_message("Obtaining properties of %s", path);
response = qmp("{ 'execute': 'qom-list',"
" 'arguments': { 'path': '%s' } }", path);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
list = qobject_to_qlist(qdict_get(response, "return"));
QLIST_FOREACH_ENTRY(list, entry) {
tuple = qobject_to_qdict(qlist_entry_obj(entry));
if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) {
child_path = g_strdup_printf("%s/%s",
path, qdict_get_str(tuple, "name"));
test_properties(child_path);
g_free(child_path);
} else {
const char *prop = qdict_get_str(tuple, "name");
g_test_message("Testing property %s.%s", path, prop);
response = qmp("{ 'execute': 'qom-get',"
" 'arguments': { 'path': '%s',"
" 'property': '%s' } }",
path, prop);
g_assert(response);
}
}
}
| {
"code": [
"static void test_properties(const char *path)",
" if (strstart(qdict_get_str(tuple, \"type\"), \"child<\", NULL)) {",
" test_properties(child_path);"
],
"line_no": [
1,
33,
39
]
} | static void FUNC_0(const char *VAR_0)
{
char *VAR_1;
QDict *response, *tuple;
QList *list;
QListEntry *entry;
g_test_message("Obtaining properties of %s", VAR_0);
response = qmp("{ 'execute': 'qom-list',"
" 'arguments': { 'VAR_0': '%s' } }", VAR_0);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
list = qobject_to_qlist(qdict_get(response, "return"));
QLIST_FOREACH_ENTRY(list, entry) {
tuple = qobject_to_qdict(qlist_entry_obj(entry));
if (strstart(qdict_get_str(tuple, "type"), "child<", NULL)) {
VAR_1 = g_strdup_printf("%s/%s",
VAR_0, qdict_get_str(tuple, "name"));
FUNC_0(VAR_1);
g_free(VAR_1);
} else {
const char *prop = qdict_get_str(tuple, "name");
g_test_message("Testing property %s.%s", VAR_0, prop);
response = qmp("{ 'execute': 'qom-get',"
" 'arguments': { 'VAR_0': '%s',"
" 'property': '%s' } }",
VAR_0, prop);
g_assert(response);
}
}
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"char *VAR_1;",
"QDict *response, *tuple;",
"QList *list;",
"QListEntry *entry;",
"g_test_message(\"Obtaining properties of %s\", VAR_0);",
"response = qmp(\"{ 'execute': 'qom-list',\"",
"\" 'arguments': { 'VAR_0': '%s' } }\", VAR_0);",
"g_assert(response);",
"g_assert(qdict_haskey(response, \"return\"));",
"list = qobject_to_qlist(qdict_get(response, \"return\"));",
"QLIST_FOREACH_ENTRY(list, entry) {",
"tuple = qobject_to_qdict(qlist_entry_obj(entry));",
"if (strstart(qdict_get_str(tuple, \"type\"), \"child<\", NULL)) {",
"VAR_1 = g_strdup_printf(\"%s/%s\",\nVAR_0, qdict_get_str(tuple, \"name\"));",
"FUNC_0(VAR_1);",
"g_free(VAR_1);",
"} else {",
"const char *prop = qdict_get_str(tuple, \"name\");",
"g_test_message(\"Testing property %s.%s\", VAR_0, prop);",
"response = qmp(\"{ 'execute': 'qom-get',\"",
"\" 'arguments': { 'VAR_0': '%s',\"",
"\" 'property': '%s' } }\",",
"VAR_0, prop);",
"g_assert(response);",
"}",
"}",
"}"
] | [
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
27,292 | static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
AVPacket* avpkt)
{
WmallDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame, packet_sequence_number, spliced_packet;
s->frame.nb_samples = 0;
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
/* sanity check for the buffer length */
if (buf_size < avctx->block_align)
return 0;
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
s->buf_bit_size = buf_size << 3;
/* parse packet header */
init_get_bits(gb, buf, s->buf_bit_size);
packet_sequence_number = get_bits(gb, 4);
skip_bits(gb, 1); // Skip seekable_frame_in_packet, currently ununused
spliced_packet = get_bits1(gb);
if (spliced_packet)
avpriv_request_sample(avctx, "Bitstream splicing");
/* get number of bits that need to be added to the previous frame */
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
/* check for packet loss */
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
}
/* Append the previous frame data to the remaining data from the
* previous packet to create a full frame. */
save_bits(s, gb, num_bits_prev_frame, 1);
/* decode the cross packet frame if it is valid */
if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
av_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
if (s->packet_loss) {
/* Reset number of saved bits so that the decoder does not start
* to decode incomplete frames in the s->len_prefix == 0 case. */
s->num_saved_bits = 0;
s->packet_loss = 0;
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
s->packet_done = !decode_frame(s);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
/* when the frames do not have a length prefix, we don't know the
* compressed length of the individual frames however, we know what
* part of a new packet belongs to the previous frame therefore we
* save the incoming packet first, then we append the "previous
* frame" data from the next packet so that we get a buffer that
* only contains full frames */
s->packet_done = !decode_frame(s);
} else {
s->packet_done = 1;
}
}
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
/* save the rest of the data so that it can be decoded
* with the next packet */
save_bits(s, gb, remaining_bits(s, gb), 0);
}
*(AVFrame *)data = s->frame;
*got_frame_ptr = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
| true | FFmpeg | 3ca5df36a50e3ffd3b24734725bf545617a627a8 | static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
AVPacket* avpkt)
{
WmallDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame, packet_sequence_number, spliced_packet;
s->frame.nb_samples = 0;
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (buf_size < avctx->block_align)
return 0;
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
s->buf_bit_size = buf_size << 3;
init_get_bits(gb, buf, s->buf_bit_size);
packet_sequence_number = get_bits(gb, 4);
skip_bits(gb, 1);
spliced_packet = get_bits1(gb);
if (spliced_packet)
avpriv_request_sample(avctx, "Bitstream splicing");
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
}
save_bits(s, gb, num_bits_prev_frame, 1);
if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
av_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
s->packet_done = !decode_frame(s);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s);
} else {
s->packet_done = 1;
}
}
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
}
*(AVFrame *)data = s->frame;
*got_frame_ptr = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
| {
"code": [
" s->frame.nb_samples = 0;",
" *(AVFrame *)data = s->frame;",
" *got_frame_ptr = s->frame.nb_samples > 0;"
],
"line_no": [
19,
205,
207
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket* VAR_3)
{
WmallDecodeCtx *s = VAR_0->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
int VAR_6, VAR_7, VAR_8;
s->frame.nb_samples = 0;
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (VAR_5 < VAR_0->block_align)
return 0;
s->next_packet_start = VAR_5 - VAR_0->block_align;
VAR_5 = VAR_0->block_align;
s->buf_bit_size = VAR_5 << 3;
init_get_bits(gb, VAR_4, s->buf_bit_size);
VAR_7 = get_bits(gb, 4);
skip_bits(gb, 1);
VAR_8 = get_bits1(gb);
if (VAR_8)
avpriv_request_sample(VAR_0, "Bitstream splicing");
VAR_6 = get_bits(gb, s->log2_frame_size);
if (!s->packet_loss &&
((s->VAR_7 + 1) & 0xF) != VAR_7) {
s->packet_loss = 1;
av_log(VAR_0, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
s->VAR_7, VAR_7);
}
s->VAR_7 = VAR_7;
if (VAR_6 > 0) {
int VAR_9 = s->buf_bit_size - get_bits_count(gb);
if (VAR_6 >= VAR_9) {
VAR_6 = VAR_9;
s->packet_done = 1;
}
save_bits(s, gb, VAR_6, 1);
if (VAR_6 < VAR_9 && !s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
av_dlog(VAR_0, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
} else {
int VAR_10;
s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3;
init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(VAR_10 = show_bits(gb, s->log2_frame_size)) &&
VAR_10 <= remaining_bits(s, gb)) {
save_bits(s, gb, VAR_10, 0);
s->packet_done = !decode_frame(s);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s);
} else {
s->packet_done = 1;
}
}
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
}
*(AVFrame *)VAR_1 = s->frame;
*VAR_2 = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket* VAR_3)\n{",
"WmallDecodeCtx *s = VAR_0->priv_data;",
"GetBitContext* gb = &s->pgb;",
"const uint8_t* VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int VAR_6, VAR_7, VAR_8;",
"s->frame.nb_samples = 0;",
"if (s->packet_done || s->packet_loss) {",
"s->packet_done = 0;",
"if (VAR_5 < VAR_0->block_align)\nreturn 0;",
"s->next_packet_start = VAR_5 - VAR_0->block_align;",
"VAR_5 = VAR_0->block_align;",
"s->buf_bit_size = VAR_5 << 3;",
"init_get_bits(gb, VAR_4, s->buf_bit_size);",
"VAR_7 = get_bits(gb, 4);",
"skip_bits(gb, 1);",
"VAR_8 = get_bits1(gb);",
"if (VAR_8)\navpriv_request_sample(VAR_0, \"Bitstream splicing\");",
"VAR_6 = get_bits(gb, s->log2_frame_size);",
"if (!s->packet_loss &&\n((s->VAR_7 + 1) & 0xF) != VAR_7) {",
"s->packet_loss = 1;",
"av_log(VAR_0, AV_LOG_ERROR, \"Packet loss detected! seq %x vs %x\\n\",\ns->VAR_7, VAR_7);",
"}",
"s->VAR_7 = VAR_7;",
"if (VAR_6 > 0) {",
"int VAR_9 = s->buf_bit_size - get_bits_count(gb);",
"if (VAR_6 >= VAR_9) {",
"VAR_6 = VAR_9;",
"s->packet_done = 1;",
"}",
"save_bits(s, gb, VAR_6, 1);",
"if (VAR_6 < VAR_9 && !s->packet_loss)\ndecode_frame(s);",
"} else if (s->num_saved_bits - s->frame_offset) {",
"av_dlog(VAR_0, \"ignoring %x previously saved bits\\n\",\ns->num_saved_bits - s->frame_offset);",
"}",
"if (s->packet_loss) {",
"s->num_saved_bits = 0;",
"s->packet_loss = 0;",
"init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);",
"}",
"} else {",
"int VAR_10;",
"s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3;",
"init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size);",
"skip_bits(gb, s->packet_offset);",
"if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&\n(VAR_10 = show_bits(gb, s->log2_frame_size)) &&\nVAR_10 <= remaining_bits(s, gb)) {",
"save_bits(s, gb, VAR_10, 0);",
"s->packet_done = !decode_frame(s);",
"} else if (!s->len_prefix",
"&& s->num_saved_bits > get_bits_count(&s->gb)) {",
"s->packet_done = !decode_frame(s);",
"} else {",
"s->packet_done = 1;",
"}",
"}",
"if (s->packet_done && !s->packet_loss &&\nremaining_bits(s, gb) > 0) {",
"save_bits(s, gb, remaining_bits(s, gb), 0);",
"}",
"*(AVFrame *)VAR_1 = s->frame;",
"*VAR_2 = s->frame.nb_samples > 0;",
"s->packet_offset = get_bits_count(gb) & 7;",
"return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;",
"}"
] | [
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,
1,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
63
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
109,
111
],
[
113
],
[
115,
117
],
[
119
],
[
123
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
153,
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191,
193
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
]
] |
27,293 | static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
const uint8_t *payload, int payload_size,
int64_t pts, int64_t dts, int key)
{
MpegTSWriteStream *ts_st = st->priv_data;
MpegTSWrite *ts = s->priv_data;
uint8_t buf[TS_PACKET_SIZE];
uint8_t *q;
int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
int afc_len, stuffing_len;
int64_t pcr = -1; /* avoid warning */
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
is_start = 1;
while (payload_size > 0) {
retransmit_si_info(s, force_pat);
force_pat = 0;
write_pcr = 0;
if (ts_st->pid == ts_st->service->pcr_pid) {
if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on frames
ts_st->service->pcr_packet_count++;
if (ts_st->service->pcr_packet_count >=
ts_st->service->pcr_packet_period) {
ts_st->service->pcr_packet_count = 0;
write_pcr = 1;
if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
(dts - get_pcr(ts, s->pb)/300) > delay) {
/* pcr insert gets priority over null packet insert */
if (write_pcr)
mpegts_insert_pcr_only(s, st);
else
mpegts_insert_null_packet(s);
continue; /* recalculate write_pcr and possibly retransmit si_info */
/* prepare packet header */
q = buf;
*q++ = 0x47;
val = (ts_st->pid >> 8);
if (is_start)
val |= 0x40;
*q++ = val;
*q++ = ts_st->pid;
ts_st->cc = (ts_st->cc + 1) & 0xf;
*q++ = 0x10 | ts_st->cc; // payload indicator + CC
if (key && is_start && pts != AV_NOPTS_VALUE) {
// set Random Access for key frames
if (ts_st->pid == ts_st->service->pcr_pid)
write_pcr = 1;
set_af_flag(buf, 0x40);
q = get_ts_payload_start(buf);
if (write_pcr) {
set_af_flag(buf, 0x10);
q = get_ts_payload_start(buf);
// add 11, pcr references the last byte of program clock reference base
if (ts->mux_rate > 1)
pcr = get_pcr(ts, s->pb);
else
pcr = (dts - delay)*300;
if (dts != AV_NOPTS_VALUE && dts < pcr / 300)
av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n");
extend_af(buf, write_pcr_bits(q, pcr));
q = get_ts_payload_start(buf);
if (is_start) {
int pes_extension = 0;
int pes_header_stuffing_bytes = 0;
/* write PES header */
*q++ = 0x00;
*q++ = 0x00;
*q++ = 0x01;
is_dvb_subtitle = 0;
is_dvb_teletext = 0;
if (st->codec->codec_id == AV_CODEC_ID_DIRAC) {
*q++ = 0xfd;
} else
*q++ = 0xe0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
(st->codec->codec_id == AV_CODEC_ID_MP2 ||
st->codec->codec_id == AV_CODEC_ID_MP3 ||
st->codec->codec_id == AV_CODEC_ID_AAC)) {
*q++ = 0xc0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codec->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
*q++ = 0xfd;
} else {
*q++ = 0xbd;
if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
is_dvb_subtitle = 1;
} else if (st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
is_dvb_teletext = 1;
header_len = 0;
flags = 0;
if (pts != AV_NOPTS_VALUE) {
header_len += 5;
flags |= 0x80;
if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
header_len += 5;
flags |= 0x40;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
st->codec->codec_id == AV_CODEC_ID_DIRAC) {
/* set PES_extension_flag */
pes_extension = 1;
flags |= 0x01;
/*
* One byte for PES2 extension flag +
* one byte for extension length +
* one byte for extension id
*/
header_len += 3;
/* for Blu-ray AC3 Audio the PES Extension flag should be as follow
* otherwise it will not play sound on blu-ray
*/
if (ts->m2ts_mode &&
st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codec->codec_id == AV_CODEC_ID_AC3) {
/* set PES_extension_flag */
pes_extension = 1;
flags |= 0x01;
header_len += 3;
if (is_dvb_teletext) {
pes_header_stuffing_bytes = 0x24 - header_len;
header_len = 0x24;
len = payload_size + header_len + 3;
/* 3 extra bytes should be added to DVB subtitle payload: 0x20 0x00 at the beginning and trailing 0xff */
if (is_dvb_subtitle) {
len += 3;
payload_size++;
if (len > 0xffff)
*q++ = len >> 8;
*q++ = len;
val = 0x80;
/* data alignment indicator is required for subtitle and data streams */
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codec->codec_type == AVMEDIA_TYPE_DATA)
val |= 0x04;
*q++ = val;
*q++ = flags;
*q++ = header_len;
if (pts != AV_NOPTS_VALUE) {
write_pts(q, flags >> 6, pts);
q += 5;
if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
write_pts(q, 1, dts);
q += 5;
if (pes_extension && st->codec->codec_id == AV_CODEC_ID_DIRAC) {
flags = 0x01; /* set PES_extension_flag_2 */
*q++ = flags;
*q++ = 0x80 | 0x01; /* marker bit + extension length */
/*
* Set the stream id extension flag bit to 0 and
* write the extended stream id
*/
*q++ = 0x00 | 0x60;
/* For Blu-ray AC3 Audio Setting extended flags */
if (ts->m2ts_mode &&
pes_extension &&
st->codec->codec_id == AV_CODEC_ID_AC3) {
flags = 0x01; /* set PES_extension_flag_2 */
*q++ = flags;
*q++ = 0x80 | 0x01; /* marker bit + extension length */
*q++ = 0x00 | 0x71; /* for AC3 Audio (specifically on blue-rays) */
if (is_dvb_subtitle) {
/* First two fields of DVB subtitles PES data:
* data_identifier: for DVB subtitle streams shall be coded with the value 0x20
* subtitle_stream_id: for DVB subtitle stream shall be identified by the value 0x00 */
*q++ = 0x20;
*q++ = 0x00;
if (is_dvb_teletext) {
memset(q, 0xff, pes_header_stuffing_bytes);
q += pes_header_stuffing_bytes;
is_start = 0;
/* header size */
header_len = q - buf;
/* data len */
len = TS_PACKET_SIZE - header_len;
if (len > payload_size)
len = payload_size;
stuffing_len = TS_PACKET_SIZE - header_len - len;
if (stuffing_len > 0) {
/* add stuffing with AFC */
if (buf[3] & 0x20) {
/* stuffing already present: increase its size */
afc_len = buf[4] + 1;
memmove(buf + 4 + afc_len + stuffing_len,
buf + 4 + afc_len,
header_len - (4 + afc_len));
buf[4] += stuffing_len;
memset(buf + 4 + afc_len, 0xff, stuffing_len);
} else {
/* add stuffing */
memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
buf[3] |= 0x20;
buf[4] = stuffing_len - 1;
if (stuffing_len >= 2) {
buf[5] = 0x00;
memset(buf + 6, 0xff, stuffing_len - 2);
if (is_dvb_subtitle && payload_size == len) {
memcpy(buf + TS_PACKET_SIZE - len, payload, len - 1);
buf[TS_PACKET_SIZE - 1] = 0xff; /* end_of_PES_data_field_marker: an 8-bit field with fixed contents 0xff for DVB subtitle */
} else {
memcpy(buf + TS_PACKET_SIZE - len, payload, len);
payload += len;
payload_size -= len;
mpegts_prefix_m2ts_header(s);
avio_write(s->pb, buf, TS_PACKET_SIZE);
avio_flush(s->pb);
ts_st->prev_payload_key = key;
| true | FFmpeg | 60fcc19b9068614f25cf64dff5e4aa0e8dbff6a5 | static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
const uint8_t *payload, int payload_size,
int64_t pts, int64_t dts, int key)
{
MpegTSWriteStream *ts_st = st->priv_data;
MpegTSWrite *ts = s->priv_data;
uint8_t buf[TS_PACKET_SIZE];
uint8_t *q;
int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
int afc_len, stuffing_len;
int64_t pcr = -1;
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
is_start = 1;
while (payload_size > 0) {
retransmit_si_info(s, force_pat);
force_pat = 0;
write_pcr = 0;
if (ts_st->pid == ts_st->service->pcr_pid) {
if (ts->mux_rate > 1 || is_start)
ts_st->service->pcr_packet_count++;
if (ts_st->service->pcr_packet_count >=
ts_st->service->pcr_packet_period) {
ts_st->service->pcr_packet_count = 0;
write_pcr = 1;
if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
(dts - get_pcr(ts, s->pb)/300) > delay) {
if (write_pcr)
mpegts_insert_pcr_only(s, st);
else
mpegts_insert_null_packet(s);
continue;
q = buf;
*q++ = 0x47;
val = (ts_st->pid >> 8);
if (is_start)
val |= 0x40;
*q++ = val;
*q++ = ts_st->pid;
ts_st->cc = (ts_st->cc + 1) & 0xf;
*q++ = 0x10 | ts_st->cc;
if (key && is_start && pts != AV_NOPTS_VALUE) {
if (ts_st->pid == ts_st->service->pcr_pid)
write_pcr = 1;
set_af_flag(buf, 0x40);
q = get_ts_payload_start(buf);
if (write_pcr) {
set_af_flag(buf, 0x10);
q = get_ts_payload_start(buf);
if (ts->mux_rate > 1)
pcr = get_pcr(ts, s->pb);
else
pcr = (dts - delay)*300;
if (dts != AV_NOPTS_VALUE && dts < pcr / 300)
av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n");
extend_af(buf, write_pcr_bits(q, pcr));
q = get_ts_payload_start(buf);
if (is_start) {
int pes_extension = 0;
int pes_header_stuffing_bytes = 0;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 0x01;
is_dvb_subtitle = 0;
is_dvb_teletext = 0;
if (st->codec->codec_id == AV_CODEC_ID_DIRAC) {
*q++ = 0xfd;
} else
*q++ = 0xe0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
(st->codec->codec_id == AV_CODEC_ID_MP2 ||
st->codec->codec_id == AV_CODEC_ID_MP3 ||
st->codec->codec_id == AV_CODEC_ID_AAC)) {
*q++ = 0xc0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codec->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
*q++ = 0xfd;
} else {
*q++ = 0xbd;
if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
is_dvb_subtitle = 1;
} else if (st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
is_dvb_teletext = 1;
header_len = 0;
flags = 0;
if (pts != AV_NOPTS_VALUE) {
header_len += 5;
flags |= 0x80;
if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
header_len += 5;
flags |= 0x40;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
st->codec->codec_id == AV_CODEC_ID_DIRAC) {
pes_extension = 1;
flags |= 0x01;
header_len += 3;
if (ts->m2ts_mode &&
st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codec->codec_id == AV_CODEC_ID_AC3) {
pes_extension = 1;
flags |= 0x01;
header_len += 3;
if (is_dvb_teletext) {
pes_header_stuffing_bytes = 0x24 - header_len;
header_len = 0x24;
len = payload_size + header_len + 3;
if (is_dvb_subtitle) {
len += 3;
payload_size++;
if (len > 0xffff)
*q++ = len >> 8;
*q++ = len;
val = 0x80;
if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codec->codec_type == AVMEDIA_TYPE_DATA)
val |= 0x04;
*q++ = val;
*q++ = flags;
*q++ = header_len;
if (pts != AV_NOPTS_VALUE) {
write_pts(q, flags >> 6, pts);
q += 5;
if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
write_pts(q, 1, dts);
q += 5;
if (pes_extension && st->codec->codec_id == AV_CODEC_ID_DIRAC) {
flags = 0x01;
*q++ = flags;
*q++ = 0x80 | 0x01;
*q++ = 0x00 | 0x60;
if (ts->m2ts_mode &&
pes_extension &&
st->codec->codec_id == AV_CODEC_ID_AC3) {
flags = 0x01;
*q++ = flags;
*q++ = 0x80 | 0x01;
*q++ = 0x00 | 0x71;
if (is_dvb_subtitle) {
*q++ = 0x20;
*q++ = 0x00;
if (is_dvb_teletext) {
memset(q, 0xff, pes_header_stuffing_bytes);
q += pes_header_stuffing_bytes;
is_start = 0;
header_len = q - buf;
len = TS_PACKET_SIZE - header_len;
if (len > payload_size)
len = payload_size;
stuffing_len = TS_PACKET_SIZE - header_len - len;
if (stuffing_len > 0) {
if (buf[3] & 0x20) {
afc_len = buf[4] + 1;
memmove(buf + 4 + afc_len + stuffing_len,
buf + 4 + afc_len,
header_len - (4 + afc_len));
buf[4] += stuffing_len;
memset(buf + 4 + afc_len, 0xff, stuffing_len);
} else {
memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
buf[3] |= 0x20;
buf[4] = stuffing_len - 1;
if (stuffing_len >= 2) {
buf[5] = 0x00;
memset(buf + 6, 0xff, stuffing_len - 2);
if (is_dvb_subtitle && payload_size == len) {
memcpy(buf + TS_PACKET_SIZE - len, payload, len - 1);
buf[TS_PACKET_SIZE - 1] = 0xff;
} else {
memcpy(buf + TS_PACKET_SIZE - len, payload, len);
payload += len;
payload_size -= len;
mpegts_prefix_m2ts_header(s);
avio_write(s->pb, buf, TS_PACKET_SIZE);
avio_flush(s->pb);
ts_st->prev_payload_key = key;
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,
const uint8_t *VAR_2, int VAR_3,
int64_t VAR_4, int64_t VAR_5, int VAR_6)
{
MpegTSWriteStream *ts_st = VAR_1->priv_data;
MpegTSWrite *ts = VAR_0->priv_data;
uint8_t buf[TS_PACKET_SIZE];
uint8_t *q;
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;
int VAR_15, VAR_16;
int64_t pcr = -1;
int64_t delay = av_rescale(VAR_0->max_delay, 90000, AV_TIME_BASE);
int VAR_17 = VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_6 && !ts_st->prev_payload_key;
VAR_8 = 1;
while (VAR_3 > 0) {
retransmit_si_info(VAR_0, VAR_17);
VAR_17 = 0;
VAR_11 = 0;
if (ts_st->pid == ts_st->service->pcr_pid) {
if (ts->mux_rate > 1 || VAR_8)
ts_st->service->pcr_packet_count++;
if (ts_st->service->pcr_packet_count >=
ts_st->service->pcr_packet_period) {
ts_st->service->pcr_packet_count = 0;
VAR_11 = 1;
if (ts->mux_rate > 1 && VAR_5 != AV_NOPTS_VALUE &&
(VAR_5 - get_pcr(ts, VAR_0->pb)/300) > delay) {
if (VAR_11)
mpegts_insert_pcr_only(VAR_0, VAR_1);
else
mpegts_insert_null_packet(VAR_0);
continue;
q = buf;
*q++ = 0x47;
VAR_7 = (ts_st->pid >> 8);
if (VAR_8)
VAR_7 |= 0x40;
*q++ = VAR_7;
*q++ = ts_st->pid;
ts_st->cc = (ts_st->cc + 1) & 0xf;
*q++ = 0x10 | ts_st->cc;
if (VAR_6 && VAR_8 && VAR_4 != AV_NOPTS_VALUE) {
if (ts_st->pid == ts_st->service->pcr_pid)
VAR_11 = 1;
set_af_flag(buf, 0x40);
q = get_ts_payload_start(buf);
if (VAR_11) {
set_af_flag(buf, 0x10);
q = get_ts_payload_start(buf);
if (ts->mux_rate > 1)
pcr = get_pcr(ts, VAR_0->pb);
else
pcr = (VAR_5 - delay)*300;
if (VAR_5 != AV_NOPTS_VALUE && VAR_5 < pcr / 300)
av_log(VAR_0, AV_LOG_WARNING, "VAR_5 < pcr, TS is invalid\n");
extend_af(buf, write_pcr_bits(q, pcr));
q = get_ts_payload_start(buf);
if (VAR_8) {
int VAR_18 = 0;
int VAR_19 = 0;
*q++ = 0x00;
*q++ = 0x00;
*q++ = 0x01;
VAR_12 = 0;
VAR_13 = 0;
if (VAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {
*q++ = 0xfd;
} else
*q++ = 0xe0;
} else if (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
(VAR_1->codec->codec_id == AV_CODEC_ID_MP2 ||
VAR_1->codec->codec_id == AV_CODEC_ID_MP3 ||
VAR_1->codec->codec_id == AV_CODEC_ID_AAC)) {
*q++ = 0xc0;
} else if (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
VAR_1->codec->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
*q++ = 0xfd;
} else {
*q++ = 0xbd;
if(VAR_1->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (VAR_1->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
VAR_12 = 1;
} else if (VAR_1->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
VAR_13 = 1;
VAR_10 = 0;
VAR_14 = 0;
if (VAR_4 != AV_NOPTS_VALUE) {
VAR_10 += 5;
VAR_14 |= 0x80;
if (VAR_5 != AV_NOPTS_VALUE && VAR_4 != AV_NOPTS_VALUE && VAR_5 != VAR_4) {
VAR_10 += 5;
VAR_14 |= 0x40;
if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
VAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {
VAR_18 = 1;
VAR_14 |= 0x01;
VAR_10 += 3;
if (ts->m2ts_mode &&
VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
VAR_1->codec->codec_id == AV_CODEC_ID_AC3) {
VAR_18 = 1;
VAR_14 |= 0x01;
VAR_10 += 3;
if (VAR_13) {
VAR_19 = 0x24 - VAR_10;
VAR_10 = 0x24;
VAR_9 = VAR_3 + VAR_10 + 3;
if (VAR_12) {
VAR_9 += 3;
VAR_3++;
if (VAR_9 > 0xffff)
*q++ = VAR_9 >> 8;
*q++ = VAR_9;
VAR_7 = 0x80;
if (VAR_1->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || VAR_1->codec->codec_type == AVMEDIA_TYPE_DATA)
VAR_7 |= 0x04;
*q++ = VAR_7;
*q++ = VAR_14;
*q++ = VAR_10;
if (VAR_4 != AV_NOPTS_VALUE) {
write_pts(q, VAR_14 >> 6, VAR_4);
q += 5;
if (VAR_5 != AV_NOPTS_VALUE && VAR_4 != AV_NOPTS_VALUE && VAR_5 != VAR_4) {
write_pts(q, 1, VAR_5);
q += 5;
if (VAR_18 && VAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {
VAR_14 = 0x01;
*q++ = VAR_14;
*q++ = 0x80 | 0x01;
*q++ = 0x00 | 0x60;
if (ts->m2ts_mode &&
VAR_18 &&
VAR_1->codec->codec_id == AV_CODEC_ID_AC3) {
VAR_14 = 0x01;
*q++ = VAR_14;
*q++ = 0x80 | 0x01;
*q++ = 0x00 | 0x71;
if (VAR_12) {
*q++ = 0x20;
*q++ = 0x00;
if (VAR_13) {
memset(q, 0xff, VAR_19);
q += VAR_19;
VAR_8 = 0;
VAR_10 = q - buf;
VAR_9 = TS_PACKET_SIZE - VAR_10;
if (VAR_9 > VAR_3)
VAR_9 = VAR_3;
VAR_16 = TS_PACKET_SIZE - VAR_10 - VAR_9;
if (VAR_16 > 0) {
if (buf[3] & 0x20) {
VAR_15 = buf[4] + 1;
memmove(buf + 4 + VAR_15 + VAR_16,
buf + 4 + VAR_15,
VAR_10 - (4 + VAR_15));
buf[4] += VAR_16;
memset(buf + 4 + VAR_15, 0xff, VAR_16);
} else {
memmove(buf + 4 + VAR_16, buf + 4, VAR_10 - 4);
buf[3] |= 0x20;
buf[4] = VAR_16 - 1;
if (VAR_16 >= 2) {
buf[5] = 0x00;
memset(buf + 6, 0xff, VAR_16 - 2);
if (VAR_12 && VAR_3 == VAR_9) {
memcpy(buf + TS_PACKET_SIZE - VAR_9, VAR_2, VAR_9 - 1);
buf[TS_PACKET_SIZE - 1] = 0xff;
} else {
memcpy(buf + TS_PACKET_SIZE - VAR_9, VAR_2, VAR_9);
VAR_2 += VAR_9;
VAR_3 -= VAR_9;
mpegts_prefix_m2ts_header(VAR_0);
avio_write(VAR_0->pb, buf, TS_PACKET_SIZE);
avio_flush(VAR_0->pb);
ts_st->prev_payload_key = VAR_6;
| [
"static void FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1,\nconst uint8_t *VAR_2, int VAR_3,\nint64_t VAR_4, int64_t VAR_5, int VAR_6)\n{",
"MpegTSWriteStream *ts_st = VAR_1->priv_data;",
"MpegTSWrite *ts = VAR_0->priv_data;",
"uint8_t buf[TS_PACKET_SIZE];",
"uint8_t *q;",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;",
"int VAR_15, VAR_16;",
"int64_t pcr = -1;",
"int64_t delay = av_rescale(VAR_0->max_delay, 90000, AV_TIME_BASE);",
"int VAR_17 = VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_6 && !ts_st->prev_payload_key;",
"VAR_8 = 1;",
"while (VAR_3 > 0) {",
"retransmit_si_info(VAR_0, VAR_17);",
"VAR_17 = 0;",
"VAR_11 = 0;",
"if (ts_st->pid == ts_st->service->pcr_pid) {",
"if (ts->mux_rate > 1 || VAR_8)\nts_st->service->pcr_packet_count++;",
"if (ts_st->service->pcr_packet_count >=\nts_st->service->pcr_packet_period) {",
"ts_st->service->pcr_packet_count = 0;",
"VAR_11 = 1;",
"if (ts->mux_rate > 1 && VAR_5 != AV_NOPTS_VALUE &&\n(VAR_5 - get_pcr(ts, VAR_0->pb)/300) > delay) {",
"if (VAR_11)\nmpegts_insert_pcr_only(VAR_0, VAR_1);",
"else\nmpegts_insert_null_packet(VAR_0);",
"continue;",
"q = buf;",
"*q++ = 0x47;",
"VAR_7 = (ts_st->pid >> 8);",
"if (VAR_8)\nVAR_7 |= 0x40;",
"*q++ = VAR_7;",
"*q++ = ts_st->pid;",
"ts_st->cc = (ts_st->cc + 1) & 0xf;",
"*q++ = 0x10 | ts_st->cc;",
"if (VAR_6 && VAR_8 && VAR_4 != AV_NOPTS_VALUE) {",
"if (ts_st->pid == ts_st->service->pcr_pid)\nVAR_11 = 1;",
"set_af_flag(buf, 0x40);",
"q = get_ts_payload_start(buf);",
"if (VAR_11) {",
"set_af_flag(buf, 0x10);",
"q = get_ts_payload_start(buf);",
"if (ts->mux_rate > 1)\npcr = get_pcr(ts, VAR_0->pb);",
"else\npcr = (VAR_5 - delay)*300;",
"if (VAR_5 != AV_NOPTS_VALUE && VAR_5 < pcr / 300)\nav_log(VAR_0, AV_LOG_WARNING, \"VAR_5 < pcr, TS is invalid\\n\");",
"extend_af(buf, write_pcr_bits(q, pcr));",
"q = get_ts_payload_start(buf);",
"if (VAR_8) {",
"int VAR_18 = 0;",
"int VAR_19 = 0;",
"*q++ = 0x00;",
"*q++ = 0x00;",
"*q++ = 0x01;",
"VAR_12 = 0;",
"VAR_13 = 0;",
"if (VAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {",
"*q++ = 0xfd;",
"} else",
"*q++ = 0xe0;",
"} else if (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&",
"(VAR_1->codec->codec_id == AV_CODEC_ID_MP2 ||\nVAR_1->codec->codec_id == AV_CODEC_ID_MP3 ||\nVAR_1->codec->codec_id == AV_CODEC_ID_AAC)) {",
"*q++ = 0xc0;",
"} else if (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&",
"VAR_1->codec->codec_id == AV_CODEC_ID_AC3 &&\nts->m2ts_mode) {",
"*q++ = 0xfd;",
"} else {",
"*q++ = 0xbd;",
"if(VAR_1->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {",
"if (VAR_1->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {",
"VAR_12 = 1;",
"} else if (VAR_1->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {",
"VAR_13 = 1;",
"VAR_10 = 0;",
"VAR_14 = 0;",
"if (VAR_4 != AV_NOPTS_VALUE) {",
"VAR_10 += 5;",
"VAR_14 |= 0x80;",
"if (VAR_5 != AV_NOPTS_VALUE && VAR_4 != AV_NOPTS_VALUE && VAR_5 != VAR_4) {",
"VAR_10 += 5;",
"VAR_14 |= 0x40;",
"if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\nVAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {",
"VAR_18 = 1;",
"VAR_14 |= 0x01;",
"VAR_10 += 3;",
"if (ts->m2ts_mode &&\nVAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&\nVAR_1->codec->codec_id == AV_CODEC_ID_AC3) {",
"VAR_18 = 1;",
"VAR_14 |= 0x01;",
"VAR_10 += 3;",
"if (VAR_13) {",
"VAR_19 = 0x24 - VAR_10;",
"VAR_10 = 0x24;",
"VAR_9 = VAR_3 + VAR_10 + 3;",
"if (VAR_12) {",
"VAR_9 += 3;",
"VAR_3++;",
"if (VAR_9 > 0xffff)\n*q++ = VAR_9 >> 8;",
"*q++ = VAR_9;",
"VAR_7 = 0x80;",
"if (VAR_1->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || VAR_1->codec->codec_type == AVMEDIA_TYPE_DATA)\nVAR_7 |= 0x04;",
"*q++ = VAR_7;",
"*q++ = VAR_14;",
"*q++ = VAR_10;",
"if (VAR_4 != AV_NOPTS_VALUE) {",
"write_pts(q, VAR_14 >> 6, VAR_4);",
"q += 5;",
"if (VAR_5 != AV_NOPTS_VALUE && VAR_4 != AV_NOPTS_VALUE && VAR_5 != VAR_4) {",
"write_pts(q, 1, VAR_5);",
"q += 5;",
"if (VAR_18 && VAR_1->codec->codec_id == AV_CODEC_ID_DIRAC) {",
"VAR_14 = 0x01;",
"*q++ = VAR_14;",
"*q++ = 0x80 | 0x01;",
"*q++ = 0x00 | 0x60;",
"if (ts->m2ts_mode &&\nVAR_18 &&\nVAR_1->codec->codec_id == AV_CODEC_ID_AC3) {",
"VAR_14 = 0x01;",
"*q++ = VAR_14;",
"*q++ = 0x80 | 0x01;",
"*q++ = 0x00 | 0x71;",
"if (VAR_12) {",
"*q++ = 0x20;",
"*q++ = 0x00;",
"if (VAR_13) {",
"memset(q, 0xff, VAR_19);",
"q += VAR_19;",
"VAR_8 = 0;",
"VAR_10 = q - buf;",
"VAR_9 = TS_PACKET_SIZE - VAR_10;",
"if (VAR_9 > VAR_3)\nVAR_9 = VAR_3;",
"VAR_16 = TS_PACKET_SIZE - VAR_10 - VAR_9;",
"if (VAR_16 > 0) {",
"if (buf[3] & 0x20) {",
"VAR_15 = buf[4] + 1;",
"memmove(buf + 4 + VAR_15 + VAR_16,\nbuf + 4 + VAR_15,\nVAR_10 - (4 + VAR_15));",
"buf[4] += VAR_16;",
"memset(buf + 4 + VAR_15, 0xff, VAR_16);",
"} else {",
"memmove(buf + 4 + VAR_16, buf + 4, VAR_10 - 4);",
"buf[3] |= 0x20;",
"buf[4] = VAR_16 - 1;",
"if (VAR_16 >= 2) {",
"buf[5] = 0x00;",
"memset(buf + 6, 0xff, VAR_16 - 2);",
"if (VAR_12 && VAR_3 == VAR_9) {",
"memcpy(buf + TS_PACKET_SIZE - VAR_9, VAR_2, VAR_9 - 1);",
"buf[TS_PACKET_SIZE - 1] = 0xff;",
"} else {",
"memcpy(buf + TS_PACKET_SIZE - VAR_9, VAR_2, VAR_9);",
"VAR_2 += VAR_9;",
"VAR_3 -= VAR_9;",
"mpegts_prefix_m2ts_header(VAR_0);",
"avio_write(VAR_0->pb, buf, TS_PACKET_SIZE);",
"avio_flush(VAR_0->pb);",
"ts_st->prev_payload_key = VAR_6;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
59,
61
],
[
65,
67
],
[
69,
71
],
[
73
],
[
80
],
[
82
],
[
84
],
[
86,
88
],
[
90
],
[
92
],
[
94
],
[
96
],
[
98
],
[
102,
104
],
[
106
],
[
108
],
[
111
],
[
113
],
[
115
],
[
119,
121
],
[
123,
125
],
[
127,
129
],
[
131
],
[
133
],
[
136
],
[
138
],
[
140
],
[
144
],
[
146
],
[
148
],
[
150
],
[
152
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
198
],
[
200
],
[
202
],
[
204
],
[
206
],
[
209
],
[
211
],
[
213
],
[
216,
218
],
[
222
],
[
224
],
[
238
],
[
247,
249,
251
],
[
255
],
[
257
],
[
259
],
[
262
],
[
264
],
[
266
],
[
269
],
[
273
],
[
275
],
[
277
],
[
280,
286
],
[
288
],
[
290
],
[
294,
296
],
[
298
],
[
300
],
[
302
],
[
304
],
[
306
],
[
308
],
[
311
],
[
313
],
[
315
],
[
318
],
[
320
],
[
322
],
[
324
],
[
334
],
[
339,
341,
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
358
],
[
366
],
[
368
],
[
371
],
[
373
],
[
375
],
[
378
],
[
383
],
[
387
],
[
389,
391
],
[
393
],
[
395
],
[
399
],
[
403
],
[
405,
407,
409
],
[
411
],
[
413
],
[
415
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
436
],
[
438
],
[
440
],
[
442
],
[
444
],
[
449
],
[
451
],
[
453
],
[
455
],
[
458
],
[
460
]
] |
27,294 | static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)
{
DECLARE_ALIGNED(8, PPContext, c)= *c2; //copy to stack for faster access
int x,y;
#ifdef TEMPLATE_PP_TIME_MODE
const int mode= TEMPLATE_PP_TIME_MODE;
#else
const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;
#endif
int black=0, white=255; // blackest black and whitest white in the picture
int QPCorrecture= 256*256;
int copyAhead;
#if TEMPLATE_PP_MMX
int i;
#endif
const int qpHShift= isColor ? 4-c.hChromaSubSample : 4;
const int qpVShift= isColor ? 4-c.vChromaSubSample : 4;
//FIXME remove
uint64_t * const yHistogram= c.yHistogram;
uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;
uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;
//const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4;
if (mode & VISUALIZE){
if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {
av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");
}
}
#if TEMPLATE_PP_MMX
for(i=0; i<57; i++){
int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1;
int threshold= offset*2 + 1;
c.mmxDcOffset[i]= 0x7F - offset;
c.mmxDcThreshold[i]= 0x7F - threshold;
c.mmxDcOffset[i]*= 0x0101010101010101LL;
c.mmxDcThreshold[i]*= 0x0101010101010101LL;
}
#endif
if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;
else if( (mode & LINEAR_BLEND_DEINT_FILTER)
|| (mode & FFMPEG_DEINT_FILTER)
|| (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14;
else if( (mode & V_DEBLOCK)
|| (mode & LINEAR_IPOL_DEINT_FILTER)
|| (mode & MEDIAN_DEINT_FILTER)
|| (mode & V_A_DEBLOCK)) copyAhead=13;
else if(mode & V_X1_FILTER) copyAhead=11;
// else if(mode & V_RK1_FILTER) copyAhead=10;
else if(mode & DERING) copyAhead=9;
else copyAhead=8;
copyAhead-= 8;
if(!isColor){
uint64_t sum= 0;
int i;
uint64_t maxClipped;
uint64_t clipped;
double scale;
c.frameNum++;
// first frame is fscked so we ignore it
if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;
for(i=0; i<256; i++){
sum+= yHistogram[i];
}
/* We always get a completely black picture first. */
maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);
clipped= sum;
for(black=255; black>0; black--){
if(clipped < maxClipped) break;
clipped-= yHistogram[black];
}
clipped= sum;
for(white=0; white<256; white++){
if(clipped < maxClipped) break;
clipped-= yHistogram[white];
}
scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black);
#if TEMPLATE_PP_MMXEXT
c.packedYScale= (uint16_t)(scale*256.0 + 0.5);
c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;
#else
c.packedYScale= (uint16_t)(scale*1024.0 + 0.5);
c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF;
#endif
c.packedYOffset|= c.packedYOffset<<32;
c.packedYOffset|= c.packedYOffset<<16;
c.packedYScale|= c.packedYScale<<32;
c.packedYScale|= c.packedYScale<<16;
if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5);
else QPCorrecture= 256*256;
}else{
c.packedYScale= 0x0100010001000100LL;
c.packedYOffset= 0;
QPCorrecture= 256*256;
}
/* copy & deinterlace first row of blocks */
y=-BLOCK_SIZE;
{
const uint8_t *srcBlock= &(src[y*srcStride]);
uint8_t *dstBlock= tempDst + dstStride;
// From this point on it is guaranteed that we can read and write 16 lines downward
// finish 1 block before the next otherwise we might have a problem
// with the L1 Cache of the P4 ... or only a few blocks at a time or something
for(x=0; x<width; x+=BLOCK_SIZE){
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
/*
prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32);
prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32);
prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32);
prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32);
*/
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)x), "g" ((x86_reg)copyAhead)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
//FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...
/* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);
prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);
prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);
prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);
*/
#endif
RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,
srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset);
RENAME(duplicate)(dstBlock + dstStride*8, dstStride);
if(mode & LINEAR_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(mode & LINEAR_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & MEDIAN_DEINT_FILTER)
RENAME(deInterlaceMedian)(dstBlock, dstStride);
else if(mode & CUBIC_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(mode & FFMPEG_DEINT_FILTER)
RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & LOWPASS5_DEINT_FILTER)
RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);
/* else if(mode & CUBIC_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);
*/
dstBlock+=8;
srcBlock+=8;
}
if(width==FFABS(dstStride))
linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);
else{
int i;
for(i=0; i<copyAhead; i++){
memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width);
}
}
}
for(y=0; y<height; y+=BLOCK_SIZE){
//1% speedup if these are here instead of the inner loop
const uint8_t *srcBlock= &(src[y*srcStride]);
uint8_t *dstBlock= &(dst[y*dstStride]);
#if TEMPLATE_PP_MMX
uint8_t *tempBlock1= c.tempBlocks;
uint8_t *tempBlock2= c.tempBlocks + 8;
#endif
const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];
int QP=0;
/* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards
if not than use a temporary buffer */
if(y+15 >= height){
int i;
/* copy from line (copyAhead) to (copyAhead+7) of src, these will be copied with
blockcopy to dst later */
linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
FFMAX(height-y-copyAhead, 0), srcStride);
/* duplicate last line of src to fill the void up to line (copyAhead+7) */
for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
/* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
/* duplicate last line of dst to fill the void up to line (copyAhead) */
for(i=height-y+1; i<=copyAhead; i++)
memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
dstBlock= tempDst + dstStride;
srcBlock= tempSrc;
}
// From this point on it is guaranteed that we can read and write 16 lines downward
// finish 1 block before the next otherwise we might have a problem
// with the L1 Cache of the P4 ... or only a few blocks at a time or something
for(x=0; x<width; x+=BLOCK_SIZE){
const int stride= dstStride;
#if TEMPLATE_PP_MMX
uint8_t *tmpXchg;
#endif
if(isColor){
QP= QPptr[x>>qpHShift];
c.nonBQP= nonBQPptr[x>>qpHShift];
}else{
QP= QPptr[x>>4];
QP= (QP* QPCorrecture + 256*128)>>16;
c.nonBQP= nonBQPptr[x>>4];
c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16;
yHistogram[ srcBlock[srcStride*12 + 4] ]++;
}
c.QP= QP;
#if TEMPLATE_PP_MMX
__asm__ volatile(
"movd %1, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t" // 0, 0, 0, QP, 0, 0, 0, QP
"packuswb %%mm7, %%mm7 \n\t" // 0,QP, 0, QP, 0,QP, 0, QP
"packuswb %%mm7, %%mm7 \n\t" // QP,..., QP
"movq %%mm7, %0 \n\t"
: "=m" (c.pQPb)
: "r" (QP)
);
#endif
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
/*
prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32);
prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32);
prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32);
prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32);
*/
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)x), "g" ((x86_reg)copyAhead)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
//FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...
/* prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);
prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);
prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);
prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);
*/
#endif
RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,
srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset);
if(mode & LINEAR_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(mode & LINEAR_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & MEDIAN_DEINT_FILTER)
RENAME(deInterlaceMedian)(dstBlock, dstStride);
else if(mode & CUBIC_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(mode & FFMPEG_DEINT_FILTER)
RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & LOWPASS5_DEINT_FILTER)
RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);
/* else if(mode & CUBIC_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);
*/
/* only deblock if we have 2 blocks */
if(y + 8 < height){
if(mode & V_X1_FILTER)
RENAME(vertX1Filter)(dstBlock, stride, &c);
else if(mode & V_DEBLOCK){
const int t= RENAME(vertClassify)(dstBlock, stride, &c);
if(t==1)
RENAME(doVertLowPass)(dstBlock, stride, &c);
else if(t==2)
RENAME(doVertDefFilter)(dstBlock, stride, &c);
}else if(mode & V_A_DEBLOCK){
RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);
}
}
#if TEMPLATE_PP_MMX
RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);
#endif
/* check if we have a previous block to deblock it with dstBlock */
if(x - 8 >= 0){
#if TEMPLATE_PP_MMX
if(mode & H_X1_FILTER)
RENAME(vertX1Filter)(tempBlock1, 16, &c);
else if(mode & H_DEBLOCK){
//START_TIMER
const int t= RENAME(vertClassify)(tempBlock1, 16, &c);
//STOP_TIMER("dc & minmax")
if(t==1)
RENAME(doVertLowPass)(tempBlock1, 16, &c);
else if(t==2)
RENAME(doVertDefFilter)(tempBlock1, 16, &c);
}else if(mode & H_A_DEBLOCK){
RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);
}
RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
#else
if(mode & H_X1_FILTER)
horizX1Filter(dstBlock-4, stride, QP);
else if(mode & H_DEBLOCK){
#if TEMPLATE_PP_ALTIVEC
DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];
int t;
transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);
t = vertClassify_altivec(tempBlock-48, 16, &c);
if(t==1) {
doVertLowPass_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
else if(t==2) {
doVertDefFilter_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
#else
const int t= RENAME(horizClassify)(dstBlock-4, stride, &c);
if(t==1)
RENAME(doHorizLowPass)(dstBlock-4, stride, &c);
else if(t==2)
RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);
#endif
}else if(mode & H_A_DEBLOCK){
RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);
}
#endif //TEMPLATE_PP_MMX
if(mode & DERING){
//FIXME filter first line
if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c);
}
if(mode & TEMP_NOISE_FILTER)
{
RENAME(tempNoiseReducer)(dstBlock-8, stride,
c.tempBlurred[isColor] + y*dstStride + x,
c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
c.ppMode.maxTmpNoise);
}
}
dstBlock+=8;
srcBlock+=8;
#if TEMPLATE_PP_MMX
tmpXchg= tempBlock1;
tempBlock1= tempBlock2;
tempBlock2 = tmpXchg;
#endif
}
if(mode & DERING){
if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c);
}
if((mode & TEMP_NOISE_FILTER)){
RENAME(tempNoiseReducer)(dstBlock-8, dstStride,
c.tempBlurred[isColor] + y*dstStride + x,
c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
c.ppMode.maxTmpNoise);
}
/* did we use a tmp buffer for the last lines*/
if(y+15 >= height){
uint8_t *dstBlock= &(dst[y*dstStride]);
if(width==FFABS(dstStride))
linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);
else{
int i;
for(i=0; i<height-y; i++){
memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width);
}
}
}
/*
for(x=0; x<width; x+=32){
volatile int i;
i+= dstBlock[x + 7*dstStride] + dstBlock[x + 8*dstStride]
+ dstBlock[x + 9*dstStride] + dstBlock[x +10*dstStride]
+ dstBlock[x +11*dstStride] + dstBlock[x +12*dstStride];
+ dstBlock[x +13*dstStride]
+ dstBlock[x +14*dstStride] + dstBlock[x +15*dstStride];
}*/
}
#if TEMPLATE_PP_3DNOW
__asm__ volatile("femms");
#elif TEMPLATE_PP_MMX
__asm__ volatile("emms");
#endif
#ifdef DEBUG_BRIGHTNESS
if(!isColor){
int max=1;
int i;
for(i=0; i<256; i++)
if(yHistogram[i] > max) max=yHistogram[i];
for(i=1; i<256; i++){
int x;
int start=yHistogram[i-1]/(max/256+1);
int end=yHistogram[i]/(max/256+1);
int inc= end > start ? 1 : -1;
for(x=start; x!=end+inc; x+=inc)
dst[ i*dstStride + x]+=128;
}
for(i=0; i<100; i+=2){
dst[ (white)*dstStride + i]+=128;
dst[ (black)*dstStride + i]+=128;
}
}
#endif
*c2= c; //copy local context back
}
| false | FFmpeg | 93f4538363069b721c24417f3d38575274394845 | static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)
{
DECLARE_ALIGNED(8, PPContext, c)= *c2;
int x,y;
#ifdef TEMPLATE_PP_TIME_MODE
const int mode= TEMPLATE_PP_TIME_MODE;
#else
const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;
#endif
int black=0, white=255;
int QPCorrecture= 256*256;
int copyAhead;
#if TEMPLATE_PP_MMX
int i;
#endif
const int qpHShift= isColor ? 4-c.hChromaSubSample : 4;
const int qpVShift= isColor ? 4-c.vChromaSubSample : 4;
uint64_t * const yHistogram= c.yHistogram;
uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;
uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;
if (mode & VISUALIZE){
if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {
av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");
}
}
#if TEMPLATE_PP_MMX
for(i=0; i<57; i++){
int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1;
int threshold= offset*2 + 1;
c.mmxDcOffset[i]= 0x7F - offset;
c.mmxDcThreshold[i]= 0x7F - threshold;
c.mmxDcOffset[i]*= 0x0101010101010101LL;
c.mmxDcThreshold[i]*= 0x0101010101010101LL;
}
#endif
if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;
else if( (mode & LINEAR_BLEND_DEINT_FILTER)
|| (mode & FFMPEG_DEINT_FILTER)
|| (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14;
else if( (mode & V_DEBLOCK)
|| (mode & LINEAR_IPOL_DEINT_FILTER)
|| (mode & MEDIAN_DEINT_FILTER)
|| (mode & V_A_DEBLOCK)) copyAhead=13;
else if(mode & V_X1_FILTER) copyAhead=11;
else if(mode & DERING) copyAhead=9;
else copyAhead=8;
copyAhead-= 8;
if(!isColor){
uint64_t sum= 0;
int i;
uint64_t maxClipped;
uint64_t clipped;
double scale;
c.frameNum++;
if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;
for(i=0; i<256; i++){
sum+= yHistogram[i];
}
maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);
clipped= sum;
for(black=255; black>0; black--){
if(clipped < maxClipped) break;
clipped-= yHistogram[black];
}
clipped= sum;
for(white=0; white<256; white++){
if(clipped < maxClipped) break;
clipped-= yHistogram[white];
}
scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black);
#if TEMPLATE_PP_MMXEXT
c.packedYScale= (uint16_t)(scale*256.0 + 0.5);
c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;
#else
c.packedYScale= (uint16_t)(scale*1024.0 + 0.5);
c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF;
#endif
c.packedYOffset|= c.packedYOffset<<32;
c.packedYOffset|= c.packedYOffset<<16;
c.packedYScale|= c.packedYScale<<32;
c.packedYScale|= c.packedYScale<<16;
if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5);
else QPCorrecture= 256*256;
}else{
c.packedYScale= 0x0100010001000100LL;
c.packedYOffset= 0;
QPCorrecture= 256*256;
}
y=-BLOCK_SIZE;
{
const uint8_t *srcBlock= &(src[y*srcStride]);
uint8_t *dstBlock= tempDst + dstStride;
for(x=0; x<width; x+=BLOCK_SIZE){
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)x), "g" ((x86_reg)copyAhead)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
#endif
RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,
srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset);
RENAME(duplicate)(dstBlock + dstStride*8, dstStride);
if(mode & LINEAR_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(mode & LINEAR_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & MEDIAN_DEINT_FILTER)
RENAME(deInterlaceMedian)(dstBlock, dstStride);
else if(mode & CUBIC_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(mode & FFMPEG_DEINT_FILTER)
RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & LOWPASS5_DEINT_FILTER)
RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);
dstBlock+=8;
srcBlock+=8;
}
if(width==FFABS(dstStride))
linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);
else{
int i;
for(i=0; i<copyAhead; i++){
memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width);
}
}
}
for(y=0; y<height; y+=BLOCK_SIZE){
const uint8_t *srcBlock= &(src[y*srcStride]);
uint8_t *dstBlock= &(dst[y*dstStride]);
#if TEMPLATE_PP_MMX
uint8_t *tempBlock1= c.tempBlocks;
uint8_t *tempBlock2= c.tempBlocks + 8;
#endif
const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];
int QP=0;
if(y+15 >= height){
int i;
linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
FFMAX(height-y-copyAhead, 0), srcStride);
for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
for(i=height-y+1; i<=copyAhead; i++)
memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
dstBlock= tempDst + dstStride;
srcBlock= tempSrc;
}
for(x=0; x<width; x+=BLOCK_SIZE){
const int stride= dstStride;
#if TEMPLATE_PP_MMX
uint8_t *tmpXchg;
#endif
if(isColor){
QP= QPptr[x>>qpHShift];
c.nonBQP= nonBQPptr[x>>qpHShift];
}else{
QP= QPptr[x>>4];
QP= (QP* QPCorrecture + 256*128)>>16;
c.nonBQP= nonBQPptr[x>>4];
c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16;
yHistogram[ srcBlock[srcStride*12 + 4] ]++;
}
c.QP= QP;
#if TEMPLATE_PP_MMX
__asm__ volatile(
"movd %1, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"movq %%mm7, %0 \n\t"
: "=m" (c.pQPb)
: "r" (QP)
);
#endif
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)x), "g" ((x86_reg)copyAhead)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
#endif
RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,
srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset);
if(mode & LINEAR_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(mode & LINEAR_BLEND_DEINT_FILTER)
RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & MEDIAN_DEINT_FILTER)
RENAME(deInterlaceMedian)(dstBlock, dstStride);
else if(mode & CUBIC_IPOL_DEINT_FILTER)
RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(mode & FFMPEG_DEINT_FILTER)
RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
else if(mode & LOWPASS5_DEINT_FILTER)
RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);
if(y + 8 < height){
if(mode & V_X1_FILTER)
RENAME(vertX1Filter)(dstBlock, stride, &c);
else if(mode & V_DEBLOCK){
const int t= RENAME(vertClassify)(dstBlock, stride, &c);
if(t==1)
RENAME(doVertLowPass)(dstBlock, stride, &c);
else if(t==2)
RENAME(doVertDefFilter)(dstBlock, stride, &c);
}else if(mode & V_A_DEBLOCK){
RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);
}
}
#if TEMPLATE_PP_MMX
RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);
#endif
if(x - 8 >= 0){
#if TEMPLATE_PP_MMX
if(mode & H_X1_FILTER)
RENAME(vertX1Filter)(tempBlock1, 16, &c);
else if(mode & H_DEBLOCK){
const int t= RENAME(vertClassify)(tempBlock1, 16, &c);
if(t==1)
RENAME(doVertLowPass)(tempBlock1, 16, &c);
else if(t==2)
RENAME(doVertDefFilter)(tempBlock1, 16, &c);
}else if(mode & H_A_DEBLOCK){
RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);
}
RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
#else
if(mode & H_X1_FILTER)
horizX1Filter(dstBlock-4, stride, QP);
else if(mode & H_DEBLOCK){
#if TEMPLATE_PP_ALTIVEC
DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];
int t;
transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);
t = vertClassify_altivec(tempBlock-48, 16, &c);
if(t==1) {
doVertLowPass_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
else if(t==2) {
doVertDefFilter_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
#else
const int t= RENAME(horizClassify)(dstBlock-4, stride, &c);
if(t==1)
RENAME(doHorizLowPass)(dstBlock-4, stride, &c);
else if(t==2)
RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);
#endif
}else if(mode & H_A_DEBLOCK){
RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);
}
#endif
if(mode & DERING){
if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c);
}
if(mode & TEMP_NOISE_FILTER)
{
RENAME(tempNoiseReducer)(dstBlock-8, stride,
c.tempBlurred[isColor] + y*dstStride + x,
c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
c.ppMode.maxTmpNoise);
}
}
dstBlock+=8;
srcBlock+=8;
#if TEMPLATE_PP_MMX
tmpXchg= tempBlock1;
tempBlock1= tempBlock2;
tempBlock2 = tmpXchg;
#endif
}
if(mode & DERING){
if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c);
}
if((mode & TEMP_NOISE_FILTER)){
RENAME(tempNoiseReducer)(dstBlock-8, dstStride,
c.tempBlurred[isColor] + y*dstStride + x,
c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,
c.ppMode.maxTmpNoise);
}
if(y+15 >= height){
uint8_t *dstBlock= &(dst[y*dstStride]);
if(width==FFABS(dstStride))
linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);
else{
int i;
for(i=0; i<height-y; i++){
memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width);
}
}
}
}
#if TEMPLATE_PP_3DNOW
__asm__ volatile("femms");
#elif TEMPLATE_PP_MMX
__asm__ volatile("emms");
#endif
#ifdef DEBUG_BRIGHTNESS
if(!isColor){
int max=1;
int i;
for(i=0; i<256; i++)
if(yHistogram[i] > max) max=yHistogram[i];
for(i=1; i<256; i++){
int x;
int start=yHistogram[i-1]/(max/256+1);
int end=yHistogram[i]/(max/256+1);
int inc= end > start ? 1 : -1;
for(x=start; x!=end+inc; x+=inc)
dst[ i*dstStride + x]+=128;
}
for(i=0; i<100; i+=2){
dst[ (white)*dstStride + i]+=128;
dst[ (black)*dstStride + i]+=128;
}
}
#endif
*c2= c;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)
{
DECLARE_ALIGNED(8, PPContext, c)= *c2;
int VAR_0,VAR_1;
#ifdef TEMPLATE_PP_TIME_MODE
const int VAR_2= TEMPLATE_PP_TIME_MODE;
#else
const int VAR_2= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;
#endif
int VAR_3=0, VAR_4=255;
int VAR_5= 256*256;
int VAR_6;
#if TEMPLATE_PP_MMX
int VAR_12;
#endif
const int VAR_7= isColor ? 4-c.hChromaSubSample : 4;
const int VAR_8= isColor ? 4-c.vChromaSubSample : 4;
uint64_t * const yHistogram= c.yHistogram;
uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;
uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;
if (VAR_2 & VISUALIZE){
if(!(VAR_2 & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {
av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");
}
}
#if TEMPLATE_PP_MMX
for(VAR_12=0; VAR_12<57; VAR_12++){
int offset= ((VAR_12*c.ppMode.baseDcDiff)>>8) + 1;
int threshold= offset*2 + 1;
c.mmxDcOffset[VAR_12]= 0x7F - offset;
c.mmxDcThreshold[VAR_12]= 0x7F - threshold;
c.mmxDcOffset[VAR_12]*= 0x0101010101010101LL;
c.mmxDcThreshold[VAR_12]*= 0x0101010101010101LL;
}
#endif
if(VAR_2 & CUBIC_IPOL_DEINT_FILTER) VAR_6=16;
else if( (VAR_2 & LINEAR_BLEND_DEINT_FILTER)
|| (VAR_2 & FFMPEG_DEINT_FILTER)
|| (VAR_2 & LOWPASS5_DEINT_FILTER)) VAR_6=14;
else if( (VAR_2 & V_DEBLOCK)
|| (VAR_2 & LINEAR_IPOL_DEINT_FILTER)
|| (VAR_2 & MEDIAN_DEINT_FILTER)
|| (VAR_2 & V_A_DEBLOCK)) VAR_6=13;
else if(VAR_2 & V_X1_FILTER) VAR_6=11;
else if(VAR_2 & DERING) VAR_6=9;
else VAR_6=8;
VAR_6-= 8;
if(!isColor){
uint64_t sum= 0;
int VAR_12;
uint64_t maxClipped;
uint64_t clipped;
double VAR_10;
c.frameNum++;
if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;
for(VAR_12=0; VAR_12<256; VAR_12++){
sum+= yHistogram[VAR_12];
}
maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);
clipped= sum;
for(VAR_3=255; VAR_3>0; VAR_3--){
if(clipped < maxClipped) break;
clipped-= yHistogram[VAR_3];
}
clipped= sum;
for(VAR_4=0; VAR_4<256; VAR_4++){
if(clipped < maxClipped) break;
clipped-= yHistogram[VAR_4];
}
VAR_10= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(VAR_4-VAR_3);
#if TEMPLATE_PP_MMXEXT
c.packedYScale= (uint16_t)(VAR_10*256.0 + 0.5);
c.packedYOffset= (((VAR_3*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;
#else
c.packedYScale= (uint16_t)(VAR_10*1024.0 + 0.5);
c.packedYOffset= (VAR_3 - c.ppMode.minAllowedY) & 0xFFFF;
#endif
c.packedYOffset|= c.packedYOffset<<32;
c.packedYOffset|= c.packedYOffset<<16;
c.packedYScale|= c.packedYScale<<32;
c.packedYScale|= c.packedYScale<<16;
if(VAR_2 & LEVEL_FIX) VAR_5= (int)(VAR_10*256*256 + 0.5);
else VAR_5= 256*256;
}else{
c.packedYScale= 0x0100010001000100LL;
c.packedYOffset= 0;
VAR_5= 256*256;
}
VAR_1=-BLOCK_SIZE;
{
const uint8_t *VAR_11= &(src[VAR_1*srcStride]);
uint8_t *dstBlock= tempDst + dstStride;
for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
#endif
FUNC_0(blockCopy)(dstBlock + dstStride*8, dstStride,
VAR_11 + srcStride*8, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);
FUNC_0(duplicate)(dstBlock + dstStride*8, dstStride);
if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)
FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);
else if(VAR_2 & MEDIAN_DEINT_FILTER)
FUNC_0(deInterlaceMedian)(dstBlock, dstStride);
else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(VAR_2 & FFMPEG_DEINT_FILTER)
FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);
else if(VAR_2 & LOWPASS5_DEINT_FILTER)
FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);
dstBlock+=8;
VAR_11+=8;
}
if(width==FFABS(dstStride))
linecpy(dst, tempDst + 9*dstStride, VAR_6, dstStride);
else{
int VAR_12;
for(VAR_12=0; VAR_12<VAR_6; VAR_12++){
memcpy(dst + VAR_12*dstStride, tempDst + (9+VAR_12)*dstStride, width);
}
}
}
for(VAR_1=0; VAR_1<height; VAR_1+=BLOCK_SIZE){
const uint8_t *VAR_11= &(src[VAR_1*srcStride]);
uint8_t *dstBlock= &(dst[VAR_1*dstStride]);
#if TEMPLATE_PP_MMX
uint8_t *tempBlock1= c.tempBlocks;
uint8_t *tempBlock2= c.tempBlocks + 8;
#endif
const int8_t *QPptr= &QPs[(VAR_1>>VAR_8)*QPStride];
int8_t *nonBQPptr= &c.nonBQPTable[(VAR_1>>VAR_8)*FFABS(QPStride)];
int QP=0;
if(VAR_1+15 >= height){
int VAR_12;
linecpy(tempSrc + srcStride*VAR_6, VAR_11 + srcStride*VAR_6,
FFMAX(height-VAR_1-VAR_6, 0), srcStride);
for(VAR_12=FFMAX(height-VAR_1, 8); VAR_12<VAR_6+8; VAR_12++)
memcpy(tempSrc + srcStride*VAR_12, src + srcStride*(height-1), FFABS(srcStride));
linecpy(tempDst, dstBlock - dstStride, FFMIN(height-VAR_1+1, VAR_6+1), dstStride);
for(VAR_12=height-VAR_1+1; VAR_12<=VAR_6; VAR_12++)
memcpy(tempDst + dstStride*VAR_12, dst + dstStride*(height-1), FFABS(dstStride));
dstBlock= tempDst + dstStride;
VAR_11= tempSrc;
}
for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){
const int stride= dstStride;
#if TEMPLATE_PP_MMX
uint8_t *tmpXchg;
#endif
if(isColor){
QP= QPptr[VAR_0>>VAR_7];
c.nonBQP= nonBQPptr[VAR_0>>VAR_7];
}else{
QP= QPptr[VAR_0>>4];
QP= (QP* VAR_5 + 256*128)>>16;
c.nonBQP= nonBQPptr[VAR_0>>4];
c.nonBQP= (c.nonBQP* VAR_5 + 256*128)>>16;
yHistogram[ VAR_11[srcStride*12 + 4] ]++;
}
c.QP= QP;
#if TEMPLATE_PP_MMX
__asm__ volatile(
"movd %1, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"packuswb %%mm7, %%mm7 \n\t"
"movq %%mm7, %0 \n\t"
: "=m" (c.pQPb)
: "r" (QP)
);
#endif
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a" \n\t"
"shr $2, %%"REG_a" \n\t"
"and $6, %%"REG_a" \n\t"
"add %5, %%"REG_a" \n\t"
"mov %%"REG_a", %%"REG_d" \n\t"
"imul %1, %%"REG_a" \n\t"
"imul %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
"add %1, %%"REG_a" \n\t"
"add %3, %%"REG_d" \n\t"
"prefetchnta 32(%%"REG_a", %0) \n\t"
"prefetcht0 32(%%"REG_d", %2) \n\t"
:: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)
: "%"REG_a, "%"REG_d
);
#elif TEMPLATE_PP_3DNOW
#endif
FUNC_0(blockCopy)(dstBlock + dstStride*VAR_6, dstStride,
VAR_11 + srcStride*VAR_6, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);
if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);
else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)
FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);
else if(VAR_2 & MEDIAN_DEINT_FILTER)
FUNC_0(deInterlaceMedian)(dstBlock, dstStride);
else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);
else if(VAR_2 & FFMPEG_DEINT_FILTER)
FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);
else if(VAR_2 & LOWPASS5_DEINT_FILTER)
FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);
if(VAR_1 + 8 < height){
if(VAR_2 & V_X1_FILTER)
FUNC_0(vertX1Filter)(dstBlock, stride, &c);
else if(VAR_2 & V_DEBLOCK){
const int t= FUNC_0(vertClassify)(dstBlock, stride, &c);
if(t==1)
FUNC_0(doVertLowPass)(dstBlock, stride, &c);
else if(t==2)
FUNC_0(doVertDefFilter)(dstBlock, stride, &c);
}else if(VAR_2 & V_A_DEBLOCK){
FUNC_0(do_a_deblock)(dstBlock, stride, 1, &c, VAR_2);
}
}
#if TEMPLATE_PP_MMX
FUNC_0(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);
#endif
if(VAR_0 - 8 >= 0){
#if TEMPLATE_PP_MMX
if(VAR_2 & H_X1_FILTER)
FUNC_0(vertX1Filter)(tempBlock1, 16, &c);
else if(VAR_2 & H_DEBLOCK){
const int t= FUNC_0(vertClassify)(tempBlock1, 16, &c);
if(t==1)
FUNC_0(doVertLowPass)(tempBlock1, 16, &c);
else if(t==2)
FUNC_0(doVertDefFilter)(tempBlock1, 16, &c);
}else if(VAR_2 & H_A_DEBLOCK){
FUNC_0(do_a_deblock)(tempBlock1, 16, 1, &c, VAR_2);
}
FUNC_0(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
#else
if(VAR_2 & H_X1_FILTER)
horizX1Filter(dstBlock-4, stride, QP);
else if(VAR_2 & H_DEBLOCK){
#if TEMPLATE_PP_ALTIVEC
DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];
int t;
transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);
t = vertClassify_altivec(tempBlock-48, 16, &c);
if(t==1) {
doVertLowPass_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
else if(t==2) {
doVertDefFilter_altivec(tempBlock-48, 16, &c);
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);
}
#else
const int t= FUNC_0(horizClassify)(dstBlock-4, stride, &c);
if(t==1)
FUNC_0(doHorizLowPass)(dstBlock-4, stride, &c);
else if(t==2)
FUNC_0(doHorizDefFilter)(dstBlock-4, stride, &c);
#endif
}else if(VAR_2 & H_A_DEBLOCK){
FUNC_0(do_a_deblock)(dstBlock-8, 1, stride, &c, VAR_2);
}
#endif
if(VAR_2 & DERING){
if(VAR_1>0) FUNC_0(dering)(dstBlock - stride - 8, stride, &c);
}
if(VAR_2 & TEMP_NOISE_FILTER)
{
FUNC_0(tempNoiseReducer)(dstBlock-8, stride,
c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,
c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,
c.ppMode.maxTmpNoise);
}
}
dstBlock+=8;
VAR_11+=8;
#if TEMPLATE_PP_MMX
tmpXchg= tempBlock1;
tempBlock1= tempBlock2;
tempBlock2 = tmpXchg;
#endif
}
if(VAR_2 & DERING){
if(VAR_1 > 0) FUNC_0(dering)(dstBlock - dstStride - 8, dstStride, &c);
}
if((VAR_2 & TEMP_NOISE_FILTER)){
FUNC_0(tempNoiseReducer)(dstBlock-8, dstStride,
c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,
c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,
c.ppMode.maxTmpNoise);
}
if(VAR_1+15 >= height){
uint8_t *dstBlock= &(dst[VAR_1*dstStride]);
if(width==FFABS(dstStride))
linecpy(dstBlock, tempDst + dstStride, height-VAR_1, dstStride);
else{
int VAR_12;
for(VAR_12=0; VAR_12<height-VAR_1; VAR_12++){
memcpy(dstBlock + VAR_12*dstStride, tempDst + (VAR_12+1)*dstStride, width);
}
}
}
}
#if TEMPLATE_PP_3DNOW
__asm__ volatile("femms");
#elif TEMPLATE_PP_MMX
__asm__ volatile("emms");
#endif
#ifdef DEBUG_BRIGHTNESS
if(!isColor){
int max=1;
int VAR_12;
for(VAR_12=0; VAR_12<256; VAR_12++)
if(yHistogram[VAR_12] > max) max=yHistogram[VAR_12];
for(VAR_12=1; VAR_12<256; VAR_12++){
int VAR_0;
int start=yHistogram[VAR_12-1]/(max/256+1);
int end=yHistogram[VAR_12]/(max/256+1);
int inc= end > start ? 1 : -1;
for(VAR_0=start; VAR_0!=end+inc; VAR_0+=inc)
dst[ VAR_12*dstStride + VAR_0]+=128;
}
for(VAR_12=0; VAR_12<100; VAR_12+=2){
dst[ (VAR_4)*dstStride + VAR_12]+=128;
dst[ (VAR_3)*dstStride + VAR_12]+=128;
}
}
#endif
*c2= c;
}
| [
"static void FUNC_0(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,\nconst QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)\n{",
"DECLARE_ALIGNED(8, PPContext, c)= *c2;",
"int VAR_0,VAR_1;",
"#ifdef TEMPLATE_PP_TIME_MODE\nconst int VAR_2= TEMPLATE_PP_TIME_MODE;",
"#else\nconst int VAR_2= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;",
"#endif\nint VAR_3=0, VAR_4=255;",
"int VAR_5= 256*256;",
"int VAR_6;",
"#if TEMPLATE_PP_MMX\nint VAR_12;",
"#endif\nconst int VAR_7= isColor ? 4-c.hChromaSubSample : 4;",
"const int VAR_8= isColor ? 4-c.vChromaSubSample : 4;",
"uint64_t * const yHistogram= c.yHistogram;",
"uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;",
"uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;",
"if (VAR_2 & VISUALIZE){",
"if(!(VAR_2 & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {",
"av_log(c2, AV_LOG_WARNING, \"Visualization is currently only supported with the accurate deblock filter without SIMD\\n\");",
"}",
"}",
"#if TEMPLATE_PP_MMX\nfor(VAR_12=0; VAR_12<57; VAR_12++){",
"int offset= ((VAR_12*c.ppMode.baseDcDiff)>>8) + 1;",
"int threshold= offset*2 + 1;",
"c.mmxDcOffset[VAR_12]= 0x7F - offset;",
"c.mmxDcThreshold[VAR_12]= 0x7F - threshold;",
"c.mmxDcOffset[VAR_12]*= 0x0101010101010101LL;",
"c.mmxDcThreshold[VAR_12]*= 0x0101010101010101LL;",
"}",
"#endif\nif(VAR_2 & CUBIC_IPOL_DEINT_FILTER) VAR_6=16;",
"else if( (VAR_2 & LINEAR_BLEND_DEINT_FILTER)\n|| (VAR_2 & FFMPEG_DEINT_FILTER)\n|| (VAR_2 & LOWPASS5_DEINT_FILTER)) VAR_6=14;",
"else if( (VAR_2 & V_DEBLOCK)\n|| (VAR_2 & LINEAR_IPOL_DEINT_FILTER)\n|| (VAR_2 & MEDIAN_DEINT_FILTER)\n|| (VAR_2 & V_A_DEBLOCK)) VAR_6=13;",
"else if(VAR_2 & V_X1_FILTER) VAR_6=11;",
"else if(VAR_2 & DERING) VAR_6=9;",
"else VAR_6=8;",
"VAR_6-= 8;",
"if(!isColor){",
"uint64_t sum= 0;",
"int VAR_12;",
"uint64_t maxClipped;",
"uint64_t clipped;",
"double VAR_10;",
"c.frameNum++;",
"if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;",
"for(VAR_12=0; VAR_12<256; VAR_12++){",
"sum+= yHistogram[VAR_12];",
"}",
"maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);",
"clipped= sum;",
"for(VAR_3=255; VAR_3>0; VAR_3--){",
"if(clipped < maxClipped) break;",
"clipped-= yHistogram[VAR_3];",
"}",
"clipped= sum;",
"for(VAR_4=0; VAR_4<256; VAR_4++){",
"if(clipped < maxClipped) break;",
"clipped-= yHistogram[VAR_4];",
"}",
"VAR_10= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(VAR_4-VAR_3);",
"#if TEMPLATE_PP_MMXEXT\nc.packedYScale= (uint16_t)(VAR_10*256.0 + 0.5);",
"c.packedYOffset= (((VAR_3*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;",
"#else\nc.packedYScale= (uint16_t)(VAR_10*1024.0 + 0.5);",
"c.packedYOffset= (VAR_3 - c.ppMode.minAllowedY) & 0xFFFF;",
"#endif\nc.packedYOffset|= c.packedYOffset<<32;",
"c.packedYOffset|= c.packedYOffset<<16;",
"c.packedYScale|= c.packedYScale<<32;",
"c.packedYScale|= c.packedYScale<<16;",
"if(VAR_2 & LEVEL_FIX) VAR_5= (int)(VAR_10*256*256 + 0.5);",
"else VAR_5= 256*256;",
"}else{",
"c.packedYScale= 0x0100010001000100LL;",
"c.packedYOffset= 0;",
"VAR_5= 256*256;",
"}",
"VAR_1=-BLOCK_SIZE;",
"{",
"const uint8_t *VAR_11= &(src[VAR_1*srcStride]);",
"uint8_t *dstBlock= tempDst + dstStride;",
"for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){",
"#if TEMPLATE_PP_MMXEXT && HAVE_6REGS\n__asm__(\n\"mov %4, %%\"REG_a\" \\n\\t\"\n\"shr $2, %%\"REG_a\" \\n\\t\"\n\"and $6, %%\"REG_a\" \\n\\t\"\n\"add %5, %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", %%\"REG_d\" \\n\\t\"\n\"imul %1, %%\"REG_a\" \\n\\t\"\n\"imul %3, %%\"REG_d\" \\n\\t\"\n\"prefetchnta 32(%%\"REG_a\", %0) \\n\\t\"\n\"prefetcht0 32(%%\"REG_d\", %2) \\n\\t\"\n\"add %1, %%\"REG_a\" \\n\\t\"\n\"add %3, %%\"REG_d\" \\n\\t\"\n\"prefetchnta 32(%%\"REG_a\", %0) \\n\\t\"\n\"prefetcht0 32(%%\"REG_d\", %2) \\n\\t\"\n:: \"r\" (VAR_11), \"r\" ((x86_reg)srcStride), \"r\" (dstBlock), \"r\" ((x86_reg)dstStride),\n\"g\" ((x86_reg)VAR_0), \"g\" ((x86_reg)VAR_6)\n: \"%\"REG_a, \"%\"REG_d\n);",
"#elif TEMPLATE_PP_3DNOW\n#endif\nFUNC_0(blockCopy)(dstBlock + dstStride*8, dstStride,\nVAR_11 + srcStride*8, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);",
"FUNC_0(duplicate)(dstBlock + dstStride*8, dstStride);",
"if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)\nFUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);",
"else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)\nFUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);",
"else if(VAR_2 & MEDIAN_DEINT_FILTER)\nFUNC_0(deInterlaceMedian)(dstBlock, dstStride);",
"else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)\nFUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);",
"else if(VAR_2 & FFMPEG_DEINT_FILTER)\nFUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);",
"else if(VAR_2 & LOWPASS5_DEINT_FILTER)\nFUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);",
"dstBlock+=8;",
"VAR_11+=8;",
"}",
"if(width==FFABS(dstStride))\nlinecpy(dst, tempDst + 9*dstStride, VAR_6, dstStride);",
"else{",
"int VAR_12;",
"for(VAR_12=0; VAR_12<VAR_6; VAR_12++){",
"memcpy(dst + VAR_12*dstStride, tempDst + (9+VAR_12)*dstStride, width);",
"}",
"}",
"}",
"for(VAR_1=0; VAR_1<height; VAR_1+=BLOCK_SIZE){",
"const uint8_t *VAR_11= &(src[VAR_1*srcStride]);",
"uint8_t *dstBlock= &(dst[VAR_1*dstStride]);",
"#if TEMPLATE_PP_MMX\nuint8_t *tempBlock1= c.tempBlocks;",
"uint8_t *tempBlock2= c.tempBlocks + 8;",
"#endif\nconst int8_t *QPptr= &QPs[(VAR_1>>VAR_8)*QPStride];",
"int8_t *nonBQPptr= &c.nonBQPTable[(VAR_1>>VAR_8)*FFABS(QPStride)];",
"int QP=0;",
"if(VAR_1+15 >= height){",
"int VAR_12;",
"linecpy(tempSrc + srcStride*VAR_6, VAR_11 + srcStride*VAR_6,\nFFMAX(height-VAR_1-VAR_6, 0), srcStride);",
"for(VAR_12=FFMAX(height-VAR_1, 8); VAR_12<VAR_6+8; VAR_12++)",
"memcpy(tempSrc + srcStride*VAR_12, src + srcStride*(height-1), FFABS(srcStride));",
"linecpy(tempDst, dstBlock - dstStride, FFMIN(height-VAR_1+1, VAR_6+1), dstStride);",
"for(VAR_12=height-VAR_1+1; VAR_12<=VAR_6; VAR_12++)",
"memcpy(tempDst + dstStride*VAR_12, dst + dstStride*(height-1), FFABS(dstStride));",
"dstBlock= tempDst + dstStride;",
"VAR_11= tempSrc;",
"}",
"for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){",
"const int stride= dstStride;",
"#if TEMPLATE_PP_MMX\nuint8_t *tmpXchg;",
"#endif\nif(isColor){",
"QP= QPptr[VAR_0>>VAR_7];",
"c.nonBQP= nonBQPptr[VAR_0>>VAR_7];",
"}else{",
"QP= QPptr[VAR_0>>4];",
"QP= (QP* VAR_5 + 256*128)>>16;",
"c.nonBQP= nonBQPptr[VAR_0>>4];",
"c.nonBQP= (c.nonBQP* VAR_5 + 256*128)>>16;",
"yHistogram[ VAR_11[srcStride*12 + 4] ]++;",
"}",
"c.QP= QP;",
"#if TEMPLATE_PP_MMX\n__asm__ volatile(\n\"movd %1, %%mm7 \\n\\t\"\n\"packuswb %%mm7, %%mm7 \\n\\t\"\n\"packuswb %%mm7, %%mm7 \\n\\t\"\n\"packuswb %%mm7, %%mm7 \\n\\t\"\n\"movq %%mm7, %0 \\n\\t\"\n: \"=m\" (c.pQPb)\n: \"r\" (QP)\n);",
"#endif\n#if TEMPLATE_PP_MMXEXT && HAVE_6REGS\n__asm__(\n\"mov %4, %%\"REG_a\" \\n\\t\"\n\"shr $2, %%\"REG_a\" \\n\\t\"\n\"and $6, %%\"REG_a\" \\n\\t\"\n\"add %5, %%\"REG_a\" \\n\\t\"\n\"mov %%\"REG_a\", %%\"REG_d\" \\n\\t\"\n\"imul %1, %%\"REG_a\" \\n\\t\"\n\"imul %3, %%\"REG_d\" \\n\\t\"\n\"prefetchnta 32(%%\"REG_a\", %0) \\n\\t\"\n\"prefetcht0 32(%%\"REG_d\", %2) \\n\\t\"\n\"add %1, %%\"REG_a\" \\n\\t\"\n\"add %3, %%\"REG_d\" \\n\\t\"\n\"prefetchnta 32(%%\"REG_a\", %0) \\n\\t\"\n\"prefetcht0 32(%%\"REG_d\", %2) \\n\\t\"\n:: \"r\" (VAR_11), \"r\" ((x86_reg)srcStride), \"r\" (dstBlock), \"r\" ((x86_reg)dstStride),\n\"g\" ((x86_reg)VAR_0), \"g\" ((x86_reg)VAR_6)\n: \"%\"REG_a, \"%\"REG_d\n);",
"#elif TEMPLATE_PP_3DNOW\n#endif\nFUNC_0(blockCopy)(dstBlock + dstStride*VAR_6, dstStride,\nVAR_11 + srcStride*VAR_6, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);",
"if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)\nFUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);",
"else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)\nFUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);",
"else if(VAR_2 & MEDIAN_DEINT_FILTER)\nFUNC_0(deInterlaceMedian)(dstBlock, dstStride);",
"else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)\nFUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);",
"else if(VAR_2 & FFMPEG_DEINT_FILTER)\nFUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);",
"else if(VAR_2 & LOWPASS5_DEINT_FILTER)\nFUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);",
"if(VAR_1 + 8 < height){",
"if(VAR_2 & V_X1_FILTER)\nFUNC_0(vertX1Filter)(dstBlock, stride, &c);",
"else if(VAR_2 & V_DEBLOCK){",
"const int t= FUNC_0(vertClassify)(dstBlock, stride, &c);",
"if(t==1)\nFUNC_0(doVertLowPass)(dstBlock, stride, &c);",
"else if(t==2)\nFUNC_0(doVertDefFilter)(dstBlock, stride, &c);",
"}else if(VAR_2 & V_A_DEBLOCK){",
"FUNC_0(do_a_deblock)(dstBlock, stride, 1, &c, VAR_2);",
"}",
"}",
"#if TEMPLATE_PP_MMX\nFUNC_0(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);",
"#endif\nif(VAR_0 - 8 >= 0){",
"#if TEMPLATE_PP_MMX\nif(VAR_2 & H_X1_FILTER)\nFUNC_0(vertX1Filter)(tempBlock1, 16, &c);",
"else if(VAR_2 & H_DEBLOCK){",
"const int t= FUNC_0(vertClassify)(tempBlock1, 16, &c);",
"if(t==1)\nFUNC_0(doVertLowPass)(tempBlock1, 16, &c);",
"else if(t==2)\nFUNC_0(doVertDefFilter)(tempBlock1, 16, &c);",
"}else if(VAR_2 & H_A_DEBLOCK){",
"FUNC_0(do_a_deblock)(tempBlock1, 16, 1, &c, VAR_2);",
"}",
"FUNC_0(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);",
"#else\nif(VAR_2 & H_X1_FILTER)\nhorizX1Filter(dstBlock-4, stride, QP);",
"else if(VAR_2 & H_DEBLOCK){",
"#if TEMPLATE_PP_ALTIVEC\nDECLARE_ALIGNED(16, unsigned char, tempBlock)[272];",
"int t;",
"transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);",
"t = vertClassify_altivec(tempBlock-48, 16, &c);",
"if(t==1) {",
"doVertLowPass_altivec(tempBlock-48, 16, &c);",
"transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);",
"}",
"else if(t==2) {",
"doVertDefFilter_altivec(tempBlock-48, 16, &c);",
"transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);",
"}",
"#else\nconst int t= FUNC_0(horizClassify)(dstBlock-4, stride, &c);",
"if(t==1)\nFUNC_0(doHorizLowPass)(dstBlock-4, stride, &c);",
"else if(t==2)\nFUNC_0(doHorizDefFilter)(dstBlock-4, stride, &c);",
"#endif\n}else if(VAR_2 & H_A_DEBLOCK){",
"FUNC_0(do_a_deblock)(dstBlock-8, 1, stride, &c, VAR_2);",
"}",
"#endif\nif(VAR_2 & DERING){",
"if(VAR_1>0) FUNC_0(dering)(dstBlock - stride - 8, stride, &c);",
"}",
"if(VAR_2 & TEMP_NOISE_FILTER)\n{",
"FUNC_0(tempNoiseReducer)(dstBlock-8, stride,\nc.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,\nc.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,\nc.ppMode.maxTmpNoise);",
"}",
"}",
"dstBlock+=8;",
"VAR_11+=8;",
"#if TEMPLATE_PP_MMX\ntmpXchg= tempBlock1;",
"tempBlock1= tempBlock2;",
"tempBlock2 = tmpXchg;",
"#endif\n}",
"if(VAR_2 & DERING){",
"if(VAR_1 > 0) FUNC_0(dering)(dstBlock - dstStride - 8, dstStride, &c);",
"}",
"if((VAR_2 & TEMP_NOISE_FILTER)){",
"FUNC_0(tempNoiseReducer)(dstBlock-8, dstStride,\nc.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,\nc.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,\nc.ppMode.maxTmpNoise);",
"}",
"if(VAR_1+15 >= height){",
"uint8_t *dstBlock= &(dst[VAR_1*dstStride]);",
"if(width==FFABS(dstStride))\nlinecpy(dstBlock, tempDst + dstStride, height-VAR_1, dstStride);",
"else{",
"int VAR_12;",
"for(VAR_12=0; VAR_12<height-VAR_1; VAR_12++){",
"memcpy(dstBlock + VAR_12*dstStride, tempDst + (VAR_12+1)*dstStride, width);",
"}",
"}",
"}",
"}",
"#if TEMPLATE_PP_3DNOW\n__asm__ volatile(\"femms\");",
"#elif TEMPLATE_PP_MMX\n__asm__ volatile(\"emms\");",
"#endif\n#ifdef DEBUG_BRIGHTNESS\nif(!isColor){",
"int max=1;",
"int VAR_12;",
"for(VAR_12=0; VAR_12<256; VAR_12++)",
"if(yHistogram[VAR_12] > max) max=yHistogram[VAR_12];",
"for(VAR_12=1; VAR_12<256; VAR_12++){",
"int VAR_0;",
"int start=yHistogram[VAR_12-1]/(max/256+1);",
"int end=yHistogram[VAR_12]/(max/256+1);",
"int inc= end > start ? 1 : -1;",
"for(VAR_0=start; VAR_0!=end+inc; VAR_0+=inc)",
"dst[ VAR_12*dstStride + VAR_0]+=128;",
"}",
"for(VAR_12=0; VAR_12<100; VAR_12+=2){",
"dst[ (VAR_4)*dstStride + VAR_12]+=128;",
"dst[ (VAR_3)*dstStride + VAR_12]+=128;",
"}",
"}",
"#endif\n*c2= c;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19,
21
],
[
23
],
[
27
],
[
29,
31
],
[
33,
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
89
],
[
91,
93,
95
],
[
97,
99,
101,
103
],
[
105
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
141
],
[
143
],
[
145
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
183,
185
],
[
187
],
[
189,
191
],
[
193
],
[
195,
199
],
[
201
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
229
],
[
231
],
[
233
],
[
235
],
[
245
],
[
249,
265,
267,
269,
271,
273,
275,
277,
279,
281,
283,
285,
287,
289,
291,
293,
295,
297,
299
],
[
303,
317,
321,
323
],
[
327
],
[
331,
333
],
[
335,
337
],
[
339,
341
],
[
343,
345
],
[
347,
349
],
[
351,
353
],
[
361
],
[
363
],
[
365
],
[
367,
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
387
],
[
391
],
[
393
],
[
395,
397
],
[
399
],
[
401,
403
],
[
405
],
[
407
],
[
413
],
[
415
],
[
421,
423
],
[
429
],
[
431
],
[
437
],
[
443
],
[
445
],
[
449
],
[
451
],
[
453
],
[
463
],
[
465
],
[
467,
469
],
[
471,
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495,
497,
499,
501,
503,
505,
507,
509,
511,
513
],
[
515,
521,
537,
539,
541,
543,
545,
547,
549,
551,
553,
555,
557,
559,
561,
563,
565,
567,
569,
571
],
[
575,
589,
593,
595
],
[
599,
601
],
[
603,
605
],
[
607,
609
],
[
611,
613
],
[
615,
617
],
[
619,
621
],
[
633
],
[
635,
637
],
[
639
],
[
641
],
[
645,
647
],
[
649,
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
663,
665
],
[
667,
671
],
[
673,
675,
677
],
[
679
],
[
683
],
[
687,
689
],
[
691,
693
],
[
695
],
[
697
],
[
699
],
[
703
],
[
707,
709,
711
],
[
713
],
[
715,
717
],
[
719
],
[
721
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
743,
745
],
[
749,
751
],
[
753,
755
],
[
757,
759
],
[
761
],
[
763
],
[
765,
767
],
[
771
],
[
773
],
[
777,
779
],
[
781,
783,
785,
787
],
[
789
],
[
791
],
[
795
],
[
797
],
[
801,
803
],
[
805
],
[
807
],
[
809,
811
],
[
815
],
[
817
],
[
819
],
[
823
],
[
825,
827,
829,
831
],
[
833
],
[
839
],
[
841
],
[
843,
845
],
[
847
],
[
849
],
[
851
],
[
853
],
[
855
],
[
857
],
[
859
],
[
879
],
[
881,
883
],
[
885,
887
],
[
889,
893,
895
],
[
897
],
[
899
],
[
901
],
[
903
],
[
907
],
[
909
],
[
911
],
[
913
],
[
915
],
[
917
],
[
919
],
[
921
],
[
925
],
[
927
],
[
929
],
[
931
],
[
933
],
[
935,
939
],
[
943
]
] |
27,295 | static char *choose_pix_fmts(OutputStream *ost)
{
if (ost->keep_pix_fmt) {
if (ost->filter)
avfilter_graph_set_auto_convert(ost->filter->graph->graph,
AVFILTER_AUTO_CONVERT_NONE);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE)
return NULL;
return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));
}
if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
} else if (ost->enc->pix_fmts) {
const enum PixelFormat *p;
AVIOContext *s = NULL;
uint8_t *ret;
int len;
if (avio_open_dyn_buf(&s) < 0)
exit_program(1);
p = ost->enc->pix_fmts;
if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
if (ost->st->codec->codec_id == CODEC_ID_MJPEG) {
p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
} else if (ost->st->codec->codec_id == CODEC_ID_LJPEG) {
p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
}
}
for (; *p != PIX_FMT_NONE; p++) {
const char *name = av_get_pix_fmt_name(*p);
avio_printf(s, "%s:", name);
}
len = avio_close_dyn_buf(s, &ret);
ret[len - 1] = 0;
return ret;
} else
return NULL;
}
| true | FFmpeg | 432fe9a38afca9104c1c11942d21739e2a48ba96 | static char *choose_pix_fmts(OutputStream *ost)
{
if (ost->keep_pix_fmt) {
if (ost->filter)
avfilter_graph_set_auto_convert(ost->filter->graph->graph,
AVFILTER_AUTO_CONVERT_NONE);
if (ost->st->codec->pix_fmt == PIX_FMT_NONE)
return NULL;
return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));
}
if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
} else if (ost->enc->pix_fmts) {
const enum PixelFormat *p;
AVIOContext *s = NULL;
uint8_t *ret;
int len;
if (avio_open_dyn_buf(&s) < 0)
exit_program(1);
p = ost->enc->pix_fmts;
if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
if (ost->st->codec->codec_id == CODEC_ID_MJPEG) {
p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
} else if (ost->st->codec->codec_id == CODEC_ID_LJPEG) {
p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
}
}
for (; *p != PIX_FMT_NONE; p++) {
const char *name = av_get_pix_fmt_name(*p);
avio_printf(s, "%s:", name);
}
len = avio_close_dyn_buf(s, &ret);
ret[len - 1] = 0;
return ret;
} else
return NULL;
}
| {
"code": [
" } else if (ost->enc->pix_fmts) {"
],
"line_no": [
25
]
} | static char *FUNC_0(OutputStream *VAR_0)
{
if (VAR_0->keep_pix_fmt) {
if (VAR_0->filter)
avfilter_graph_set_auto_convert(VAR_0->filter->graph->graph,
AVFILTER_AUTO_CONVERT_NONE);
if (VAR_0->st->codec->pix_fmt == PIX_FMT_NONE)
return NULL;
return av_strdup(av_get_pix_fmt_name(VAR_0->st->codec->pix_fmt));
}
if (VAR_0->st->codec->pix_fmt != PIX_FMT_NONE) {
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(VAR_0->st, VAR_0->enc, VAR_0->st->codec->pix_fmt)));
} else if (VAR_0->enc->pix_fmts) {
const enum PixelFormat *VAR_1;
AVIOContext *s = NULL;
uint8_t *ret;
int VAR_2;
if (avio_open_dyn_buf(&s) < 0)
exit_program(1);
VAR_1 = VAR_0->enc->pix_fmts;
if (VAR_0->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
if (VAR_0->st->codec->codec_id == CODEC_ID_MJPEG) {
VAR_1 = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
} else if (VAR_0->st->codec->codec_id == CODEC_ID_LJPEG) {
VAR_1 = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
}
}
for (; *VAR_1 != PIX_FMT_NONE; VAR_1++) {
const char *name = av_get_pix_fmt_name(*VAR_1);
avio_printf(s, "%s:", name);
}
VAR_2 = avio_close_dyn_buf(s, &ret);
ret[VAR_2 - 1] = 0;
return ret;
} else
return NULL;
}
| [
"static char *FUNC_0(OutputStream *VAR_0)\n{",
"if (VAR_0->keep_pix_fmt) {",
"if (VAR_0->filter)\navfilter_graph_set_auto_convert(VAR_0->filter->graph->graph,\nAVFILTER_AUTO_CONVERT_NONE);",
"if (VAR_0->st->codec->pix_fmt == PIX_FMT_NONE)\nreturn NULL;",
"return av_strdup(av_get_pix_fmt_name(VAR_0->st->codec->pix_fmt));",
"}",
"if (VAR_0->st->codec->pix_fmt != PIX_FMT_NONE) {",
"return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(VAR_0->st, VAR_0->enc, VAR_0->st->codec->pix_fmt)));",
"} else if (VAR_0->enc->pix_fmts) {",
"const enum PixelFormat *VAR_1;",
"AVIOContext *s = NULL;",
"uint8_t *ret;",
"int VAR_2;",
"if (avio_open_dyn_buf(&s) < 0)\nexit_program(1);",
"VAR_1 = VAR_0->enc->pix_fmts;",
"if (VAR_0->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {",
"if (VAR_0->st->codec->codec_id == CODEC_ID_MJPEG) {",
"VAR_1 = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };",
"} else if (VAR_0->st->codec->codec_id == CODEC_ID_LJPEG) {",
"VAR_1 = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,",
"PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };",
"}",
"}",
"for (; *VAR_1 != PIX_FMT_NONE; VAR_1++) {",
"const char *name = av_get_pix_fmt_name(*VAR_1);",
"avio_printf(s, \"%s:\", name);",
"}",
"VAR_2 = avio_close_dyn_buf(s, &ret);",
"ret[VAR_2 - 1] = 0;",
"return ret;",
"} else",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
]
] |
27,297 | static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int ident, fragmented, tdt, num_pkts, pkt_len;
if (!buf) {
if (!data->split_buf || data->split_pos + 2 > data->split_buf_len ||
data->split_pkts <= 0) {
av_log(ctx, AV_LOG_ERROR, "No more data to return\n");
return AVERROR_INVALIDDATA;
}
pkt_len = AV_RB16(data->split_buf + data->split_pos);
data->split_pos += 2;
if (data->split_pos + pkt_len > data->split_buf_len) {
av_log(ctx, AV_LOG_ERROR, "Not enough data to return\n");
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, pkt_len)) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
pkt->stream_index = st->index;
memcpy(pkt->data, data->split_buf + data->split_pos, pkt_len);
data->split_pos += pkt_len;
data->split_pkts--;
return data->split_pkts > 0;
}
if (len < 6 || len > INT_MAX/2) {
av_log(ctx, AV_LOG_ERROR, "Invalid %d byte packet\n", len);
return AVERROR_INVALIDDATA;
}
// read xiph rtp headers
ident = AV_RB24(buf);
fragmented = buf[3] >> 6;
tdt = (buf[3] >> 4) & 3;
num_pkts = buf[3] & 0xf;
pkt_len = AV_RB16(buf + 4);
if (pkt_len > len - 6) {
av_log(ctx, AV_LOG_ERROR,
"Invalid packet length %d in %d byte packet\n", pkt_len,
len);
return AVERROR_INVALIDDATA;
}
if (ident != data->ident) {
av_log(ctx, AV_LOG_ERROR,
"Unimplemented Xiph SDP configuration change detected\n");
return AVERROR_PATCHWELCOME;
}
if (tdt) {
av_log(ctx, AV_LOG_ERROR,
"Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
fragmented, tdt, num_pkts);
return AVERROR_PATCHWELCOME;
}
buf += 6; // move past header bits
len -= 6;
if (fragmented == 0) {
if (av_new_packet(pkt, pkt_len)) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
pkt->stream_index = st->index;
memcpy(pkt->data, buf, pkt_len);
buf += pkt_len;
len -= pkt_len;
num_pkts--;
if (num_pkts > 0) {
if (len > data->split_buf_size || !data->split_buf) {
av_freep(&data->split_buf);
data->split_buf_size = 2 * len;
data->split_buf = av_malloc(data->split_buf_size);
if (!data->split_buf) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
av_free_packet(pkt);
return AVERROR(ENOMEM);
}
}
memcpy(data->split_buf, buf, len);
data->split_buf_len = len;
data->split_pos = 0;
data->split_pkts = num_pkts;
return 1;
}
return 0;
} else if (fragmented == 1) {
// start of xiph data fragment
int res;
// end packet has been lost somewhere, so drop buffered data
ffio_free_dyn_buf(&data->fragment);
if((res = avio_open_dyn_buf(&data->fragment)) < 0)
return res;
avio_write(data->fragment, buf, pkt_len);
data->timestamp = *timestamp;
} else {
av_assert1(fragmented < 4);
if (data->timestamp != *timestamp) {
// skip if fragmented timestamp is incorrect;
// a start packet has been lost somewhere
ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match!\n");
return AVERROR_INVALIDDATA;
}
if (!data->fragment) {
av_log(ctx, AV_LOG_WARNING,
"Received packet without a start fragment; dropping.\n");
return AVERROR(EAGAIN);
}
// copy data to fragment buffer
avio_write(data->fragment, buf, pkt_len);
if (fragmented == 3) {
// end of xiph data packet
int ret = ff_rtp_finalize_packet(pkt, &data->fragment, st->index);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR,
"Error occurred when getting fragment buffer.");
return ret;
}
return 0;
}
}
return AVERROR(EAGAIN);
}
| false | FFmpeg | a23379a0a68a6dd9a0e0d583e11b0c6f9b33f9ae | static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int ident, fragmented, tdt, num_pkts, pkt_len;
if (!buf) {
if (!data->split_buf || data->split_pos + 2 > data->split_buf_len ||
data->split_pkts <= 0) {
av_log(ctx, AV_LOG_ERROR, "No more data to return\n");
return AVERROR_INVALIDDATA;
}
pkt_len = AV_RB16(data->split_buf + data->split_pos);
data->split_pos += 2;
if (data->split_pos + pkt_len > data->split_buf_len) {
av_log(ctx, AV_LOG_ERROR, "Not enough data to return\n");
return AVERROR_INVALIDDATA;
}
if (av_new_packet(pkt, pkt_len)) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
pkt->stream_index = st->index;
memcpy(pkt->data, data->split_buf + data->split_pos, pkt_len);
data->split_pos += pkt_len;
data->split_pkts--;
return data->split_pkts > 0;
}
if (len < 6 || len > INT_MAX/2) {
av_log(ctx, AV_LOG_ERROR, "Invalid %d byte packet\n", len);
return AVERROR_INVALIDDATA;
}
ident = AV_RB24(buf);
fragmented = buf[3] >> 6;
tdt = (buf[3] >> 4) & 3;
num_pkts = buf[3] & 0xf;
pkt_len = AV_RB16(buf + 4);
if (pkt_len > len - 6) {
av_log(ctx, AV_LOG_ERROR,
"Invalid packet length %d in %d byte packet\n", pkt_len,
len);
return AVERROR_INVALIDDATA;
}
if (ident != data->ident) {
av_log(ctx, AV_LOG_ERROR,
"Unimplemented Xiph SDP configuration change detected\n");
return AVERROR_PATCHWELCOME;
}
if (tdt) {
av_log(ctx, AV_LOG_ERROR,
"Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
fragmented, tdt, num_pkts);
return AVERROR_PATCHWELCOME;
}
buf += 6;
len -= 6;
if (fragmented == 0) {
if (av_new_packet(pkt, pkt_len)) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
pkt->stream_index = st->index;
memcpy(pkt->data, buf, pkt_len);
buf += pkt_len;
len -= pkt_len;
num_pkts--;
if (num_pkts > 0) {
if (len > data->split_buf_size || !data->split_buf) {
av_freep(&data->split_buf);
data->split_buf_size = 2 * len;
data->split_buf = av_malloc(data->split_buf_size);
if (!data->split_buf) {
av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
av_free_packet(pkt);
return AVERROR(ENOMEM);
}
}
memcpy(data->split_buf, buf, len);
data->split_buf_len = len;
data->split_pos = 0;
data->split_pkts = num_pkts;
return 1;
}
return 0;
} else if (fragmented == 1) {
int res;
ffio_free_dyn_buf(&data->fragment);
if((res = avio_open_dyn_buf(&data->fragment)) < 0)
return res;
avio_write(data->fragment, buf, pkt_len);
data->timestamp = *timestamp;
} else {
av_assert1(fragmented < 4);
if (data->timestamp != *timestamp) {
ffio_free_dyn_buf(&data->fragment);
av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match!\n");
return AVERROR_INVALIDDATA;
}
if (!data->fragment) {
av_log(ctx, AV_LOG_WARNING,
"Received packet without a start fragment; dropping.\n");
return AVERROR(EAGAIN);
}
avio_write(data->fragment, buf, pkt_len);
if (fragmented == 3) {
int ret = ff_rtp_finalize_packet(pkt, &data->fragment, st->index);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR,
"Error occurred when getting fragment buffer.");
return ret;
}
return 0;
}
}
return AVERROR(EAGAIN);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,
AVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4,
const uint8_t *VAR_5, int VAR_6, uint16_t VAR_7,
int VAR_8)
{
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
if (!VAR_5) {
if (!VAR_1->split_buf || VAR_1->split_pos + 2 > VAR_1->split_buf_len ||
VAR_1->split_pkts <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "No more VAR_1 to return\n");
return AVERROR_INVALIDDATA;
}
VAR_13 = AV_RB16(VAR_1->split_buf + VAR_1->split_pos);
VAR_1->split_pos += 2;
if (VAR_1->split_pos + VAR_13 > VAR_1->split_buf_len) {
av_log(VAR_0, AV_LOG_ERROR, "Not enough VAR_1 to return\n");
return AVERROR_INVALIDDATA;
}
if (av_new_packet(VAR_3, VAR_13)) {
av_log(VAR_0, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
VAR_3->stream_index = VAR_2->index;
memcpy(VAR_3->VAR_1, VAR_1->split_buf + VAR_1->split_pos, VAR_13);
VAR_1->split_pos += VAR_13;
VAR_1->split_pkts--;
return VAR_1->split_pkts > 0;
}
if (VAR_6 < 6 || VAR_6 > INT_MAX/2) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid %d byte packet\n", VAR_6);
return AVERROR_INVALIDDATA;
}
VAR_9 = AV_RB24(VAR_5);
VAR_10 = VAR_5[3] >> 6;
VAR_11 = (VAR_5[3] >> 4) & 3;
VAR_12 = VAR_5[3] & 0xf;
VAR_13 = AV_RB16(VAR_5 + 4);
if (VAR_13 > VAR_6 - 6) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid packet length %d in %d byte packet\n", VAR_13,
VAR_6);
return AVERROR_INVALIDDATA;
}
if (VAR_9 != VAR_1->VAR_9) {
av_log(VAR_0, AV_LOG_ERROR,
"Unimplemented Xiph SDP configuration change detected\n");
return AVERROR_PATCHWELCOME;
}
if (VAR_11) {
av_log(VAR_0, AV_LOG_ERROR,
"Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
VAR_10, VAR_11, VAR_12);
return AVERROR_PATCHWELCOME;
}
VAR_5 += 6;
VAR_6 -= 6;
if (VAR_10 == 0) {
if (av_new_packet(VAR_3, VAR_13)) {
av_log(VAR_0, AV_LOG_ERROR, "Out of memory.\n");
return AVERROR(ENOMEM);
}
VAR_3->stream_index = VAR_2->index;
memcpy(VAR_3->VAR_1, VAR_5, VAR_13);
VAR_5 += VAR_13;
VAR_6 -= VAR_13;
VAR_12--;
if (VAR_12 > 0) {
if (VAR_6 > VAR_1->split_buf_size || !VAR_1->split_buf) {
av_freep(&VAR_1->split_buf);
VAR_1->split_buf_size = 2 * VAR_6;
VAR_1->split_buf = av_malloc(VAR_1->split_buf_size);
if (!VAR_1->split_buf) {
av_log(VAR_0, AV_LOG_ERROR, "Out of memory.\n");
av_free_packet(VAR_3);
return AVERROR(ENOMEM);
}
}
memcpy(VAR_1->split_buf, VAR_5, VAR_6);
VAR_1->split_buf_len = VAR_6;
VAR_1->split_pos = 0;
VAR_1->split_pkts = VAR_12;
return 1;
}
return 0;
} else if (VAR_10 == 1) {
int VAR_14;
ffio_free_dyn_buf(&VAR_1->fragment);
if((VAR_14 = avio_open_dyn_buf(&VAR_1->fragment)) < 0)
return VAR_14;
avio_write(VAR_1->fragment, VAR_5, VAR_13);
VAR_1->VAR_4 = *VAR_4;
} else {
av_assert1(VAR_10 < 4);
if (VAR_1->VAR_4 != *VAR_4) {
ffio_free_dyn_buf(&VAR_1->fragment);
av_log(VAR_0, AV_LOG_ERROR, "RTP timestamps don't match!\n");
return AVERROR_INVALIDDATA;
}
if (!VAR_1->fragment) {
av_log(VAR_0, AV_LOG_WARNING,
"Received packet without a start fragment; dropping.\n");
return AVERROR(EAGAIN);
}
avio_write(VAR_1->fragment, VAR_5, VAR_13);
if (VAR_10 == 3) {
int VAR_15 = ff_rtp_finalize_packet(VAR_3, &VAR_1->fragment, VAR_2->index);
if (VAR_15 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Error occurred when getting fragment buffer.");
return VAR_15;
}
return 0;
}
}
return AVERROR(EAGAIN);
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, PayloadContext *VAR_1,\nAVStream *VAR_2, AVPacket *VAR_3, uint32_t *VAR_4,\nconst uint8_t *VAR_5, int VAR_6, uint16_t VAR_7,\nint VAR_8)\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"if (!VAR_5) {",
"if (!VAR_1->split_buf || VAR_1->split_pos + 2 > VAR_1->split_buf_len ||\nVAR_1->split_pkts <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"No more VAR_1 to return\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_13 = AV_RB16(VAR_1->split_buf + VAR_1->split_pos);",
"VAR_1->split_pos += 2;",
"if (VAR_1->split_pos + VAR_13 > VAR_1->split_buf_len) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Not enough VAR_1 to return\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (av_new_packet(VAR_3, VAR_13)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Out of memory.\\n\");",
"return AVERROR(ENOMEM);",
"}",
"VAR_3->stream_index = VAR_2->index;",
"memcpy(VAR_3->VAR_1, VAR_1->split_buf + VAR_1->split_pos, VAR_13);",
"VAR_1->split_pos += VAR_13;",
"VAR_1->split_pkts--;",
"return VAR_1->split_pkts > 0;",
"}",
"if (VAR_6 < 6 || VAR_6 > INT_MAX/2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid %d byte packet\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = AV_RB24(VAR_5);",
"VAR_10 = VAR_5[3] >> 6;",
"VAR_11 = (VAR_5[3] >> 4) & 3;",
"VAR_12 = VAR_5[3] & 0xf;",
"VAR_13 = AV_RB16(VAR_5 + 4);",
"if (VAR_13 > VAR_6 - 6) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid packet length %d in %d byte packet\\n\", VAR_13,\nVAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_9 != VAR_1->VAR_9) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unimplemented Xiph SDP configuration change detected\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"if (VAR_11) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unimplemented RTP Xiph packet settings (%d,%d,%d)\\n\",\nVAR_10, VAR_11, VAR_12);",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_5 += 6;",
"VAR_6 -= 6;",
"if (VAR_10 == 0) {",
"if (av_new_packet(VAR_3, VAR_13)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Out of memory.\\n\");",
"return AVERROR(ENOMEM);",
"}",
"VAR_3->stream_index = VAR_2->index;",
"memcpy(VAR_3->VAR_1, VAR_5, VAR_13);",
"VAR_5 += VAR_13;",
"VAR_6 -= VAR_13;",
"VAR_12--;",
"if (VAR_12 > 0) {",
"if (VAR_6 > VAR_1->split_buf_size || !VAR_1->split_buf) {",
"av_freep(&VAR_1->split_buf);",
"VAR_1->split_buf_size = 2 * VAR_6;",
"VAR_1->split_buf = av_malloc(VAR_1->split_buf_size);",
"if (!VAR_1->split_buf) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Out of memory.\\n\");",
"av_free_packet(VAR_3);",
"return AVERROR(ENOMEM);",
"}",
"}",
"memcpy(VAR_1->split_buf, VAR_5, VAR_6);",
"VAR_1->split_buf_len = VAR_6;",
"VAR_1->split_pos = 0;",
"VAR_1->split_pkts = VAR_12;",
"return 1;",
"}",
"return 0;",
"} else if (VAR_10 == 1) {",
"int VAR_14;",
"ffio_free_dyn_buf(&VAR_1->fragment);",
"if((VAR_14 = avio_open_dyn_buf(&VAR_1->fragment)) < 0)\nreturn VAR_14;",
"avio_write(VAR_1->fragment, VAR_5, VAR_13);",
"VAR_1->VAR_4 = *VAR_4;",
"} else {",
"av_assert1(VAR_10 < 4);",
"if (VAR_1->VAR_4 != *VAR_4) {",
"ffio_free_dyn_buf(&VAR_1->fragment);",
"av_log(VAR_0, AV_LOG_ERROR, \"RTP timestamps don't match!\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (!VAR_1->fragment) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"Received packet without a start fragment; dropping.\\n\");",
"return AVERROR(EAGAIN);",
"}",
"avio_write(VAR_1->fragment, VAR_5, VAR_13);",
"if (VAR_10 == 3) {",
"int VAR_15 = ff_rtp_finalize_packet(VAR_3, &VAR_1->fragment, VAR_2->index);",
"if (VAR_15 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Error occurred when getting fragment buffer.\");",
"return VAR_15;",
"}",
"return 0;",
"}",
"}",
"return AVERROR(EAGAIN);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89,
91,
93
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115,
117,
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
195
],
[
199
],
[
205
],
[
209,
211
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
],
[
245
],
[
247
],
[
253
],
[
257
],
[
261
],
[
263
],
[
265,
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
283
],
[
285
]
] |
27,298 | static int check_image_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt,
const int linesizes[4])
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
for (i = 0; i < 4; i++) {
int plane = desc->comp[i].plane;
if (!data[plane] || !linesizes[plane])
return 0;
}
return 1;
}
| false | FFmpeg | 37f573543c4fd7f44339e04d8d15b95118493ddd | static int check_image_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt,
const int linesizes[4])
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
for (i = 0; i < 4; i++) {
int plane = desc->comp[i].plane;
if (!data[plane] || !linesizes[plane])
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(uint8_t *VAR_0[4], enum AVPixelFormat VAR_1,
const int VAR_2[4])
{
const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1);
int VAR_4;
for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {
int VAR_5 = VAR_3->comp[VAR_4].VAR_5;
if (!VAR_0[VAR_5] || !VAR_2[VAR_5])
return 0;
}
return 1;
}
| [
"static int FUNC_0(uint8_t *VAR_0[4], enum AVPixelFormat VAR_1,\nconst int VAR_2[4])\n{",
"const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1);",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {",
"int VAR_5 = VAR_3->comp[VAR_4].VAR_5;",
"if (!VAR_0[VAR_5] || !VAR_2[VAR_5])\nreturn 0;",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
25
],
[
27
]
] |
27,299 | static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
{
MpegEncContext *s = &v->s;
DSPContext *dsp = &v->s.dsp;
uint8_t *srcY;
int dxy, mx, my, src_x, src_y;
int off;
int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
if (!v->field_mode && !v->s.last_picture.f.data[0])
return;
mx = s->mv[dir][n][0];
my = s->mv[dir][n][1];
if (!dir) {
if (v->field_mode) {
if ((v->cur_field_type != v->ref_field_type[dir]) && v->cur_field_type)
srcY = s->current_picture.f.data[0];
else
srcY = s->last_picture.f.data[0];
} else
srcY = s->last_picture.f.data[0];
} else
srcY = s->next_picture.f.data[0];
if (v->field_mode) {
if (v->cur_field_type != v->ref_field_type[dir])
my = my - 2 + 4 * v->cur_field_type;
}
if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
int same_count = 0, opp_count = 0, k;
int chosen_mv[2][4][2], f;
int tx, ty;
for (k = 0; k < 4; k++) {
f = v->mv_f[0][s->block_index[k] + v->blocks_off];
chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0];
chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1];
opp_count += f;
same_count += 1 - f;
}
f = opp_count > same_count;
switch (f ? opp_count : same_count) {
case 4:
tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
chosen_mv[f][2][0], chosen_mv[f][3][0]);
ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
chosen_mv[f][2][1], chosen_mv[f][3][1]);
break;
case 3:
tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
break;
case 2:
tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
break;
}
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
for (k = 0; k < 4; k++)
v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
}
if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture
int qx, qy;
int width = s->avctx->coded_width;
int height = s->avctx->coded_height >> 1;
qx = (s->mb_x * 16) + (mx >> 2);
qy = (s->mb_y * 8) + (my >> 3);
if (qx < -17)
mx -= 4 * (qx + 17);
else if (qx > width)
mx -= 4 * (qx - width);
if (qy < -18)
my -= 8 * (qy + 18);
else if (qy > height + 1)
my -= 8 * (qy - height - 1);
}
if ((v->fcm == ILACE_FRAME) && fieldmv)
off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
else
off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
if (v->field_mode && v->cur_field_type)
off += s->current_picture_ptr->f.linesize[0];
src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
if (!fieldmv)
src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
else
src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
if (v->profile != PROFILE_ADVANCED) {
src_x = av_clip(src_x, -16, s->mb_width * 16);
src_y = av_clip(src_y, -16, s->mb_height * 16);
} else {
src_x = av_clip(src_x, -17, s->avctx->coded_width);
if (v->fcm == ILACE_FRAME) {
if (src_y & 1)
src_y = av_clip(src_y, -17, s->avctx->coded_height + 1);
else
src_y = av_clip(src_y, -18, s->avctx->coded_height);
} else {
src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
}
}
srcY += src_y * s->linesize + src_x;
if (v->field_mode && v->ref_field_type[dir])
srcY += s->current_picture_ptr->f.linesize[0];
if (fieldmv && !(src_y & 1))
v_edge_pos--;
if (fieldmv && (src_y & 1) && src_y < 4)
src_y--;
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 13 || v_edge_pos < 23
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
|| (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
srcY -= s->mspel * (1 + (s->linesize << fieldmv));
/* check emulate edge stride and offset */
s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv,
src_x - s->mspel, src_y - (s->mspel << fieldmv),
s->h_edge_pos, v_edge_pos);
srcY = s->edge_emu_buffer;
/* if we deal with range reduction we need to scale source blocks */
if (v->rangeredfrm) {
int i, j;
uint8_t *src;
src = srcY;
for (j = 0; j < 9 + s->mspel * 2; j++) {
for (i = 0; i < 9 + s->mspel * 2; i++)
src[i] = ((src[i] - 128) >> 1) + 128;
src += s->linesize << fieldmv;
}
}
/* if we deal with intensity compensation we need to scale source blocks */
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
int i, j;
uint8_t *src;
src = srcY;
for (j = 0; j < 9 + s->mspel * 2; j++) {
for (i = 0; i < 9 + s->mspel * 2; i++)
src[i] = v->luty[src[i]];
src += s->linesize << fieldmv;
}
}
srcY += s->mspel * (1 + (s->linesize << fieldmv));
}
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
} else { // hpel mc - always used for luma
dxy = (my & 2) | ((mx & 2) >> 1);
if (!v->rnd)
dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
else
dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
}
}
| false | FFmpeg | ae591aeea58d64399b8281be31dacec0de85ae04 | static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
{
MpegEncContext *s = &v->s;
DSPContext *dsp = &v->s.dsp;
uint8_t *srcY;
int dxy, mx, my, src_x, src_y;
int off;
int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
if (!v->field_mode && !v->s.last_picture.f.data[0])
return;
mx = s->mv[dir][n][0];
my = s->mv[dir][n][1];
if (!dir) {
if (v->field_mode) {
if ((v->cur_field_type != v->ref_field_type[dir]) && v->cur_field_type)
srcY = s->current_picture.f.data[0];
else
srcY = s->last_picture.f.data[0];
} else
srcY = s->last_picture.f.data[0];
} else
srcY = s->next_picture.f.data[0];
if (v->field_mode) {
if (v->cur_field_type != v->ref_field_type[dir])
my = my - 2 + 4 * v->cur_field_type;
}
if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
int same_count = 0, opp_count = 0, k;
int chosen_mv[2][4][2], f;
int tx, ty;
for (k = 0; k < 4; k++) {
f = v->mv_f[0][s->block_index[k] + v->blocks_off];
chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0];
chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1];
opp_count += f;
same_count += 1 - f;
}
f = opp_count > same_count;
switch (f ? opp_count : same_count) {
case 4:
tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
chosen_mv[f][2][0], chosen_mv[f][3][0]);
ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
chosen_mv[f][2][1], chosen_mv[f][3][1]);
break;
case 3:
tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
break;
case 2:
tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
break;
}
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
for (k = 0; k < 4; k++)
v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
}
if (v->fcm == ILACE_FRAME) {
int qx, qy;
int width = s->avctx->coded_width;
int height = s->avctx->coded_height >> 1;
qx = (s->mb_x * 16) + (mx >> 2);
qy = (s->mb_y * 8) + (my >> 3);
if (qx < -17)
mx -= 4 * (qx + 17);
else if (qx > width)
mx -= 4 * (qx - width);
if (qy < -18)
my -= 8 * (qy + 18);
else if (qy > height + 1)
my -= 8 * (qy - height - 1);
}
if ((v->fcm == ILACE_FRAME) && fieldmv)
off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
else
off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
if (v->field_mode && v->cur_field_type)
off += s->current_picture_ptr->f.linesize[0];
src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
if (!fieldmv)
src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
else
src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
if (v->profile != PROFILE_ADVANCED) {
src_x = av_clip(src_x, -16, s->mb_width * 16);
src_y = av_clip(src_y, -16, s->mb_height * 16);
} else {
src_x = av_clip(src_x, -17, s->avctx->coded_width);
if (v->fcm == ILACE_FRAME) {
if (src_y & 1)
src_y = av_clip(src_y, -17, s->avctx->coded_height + 1);
else
src_y = av_clip(src_y, -18, s->avctx->coded_height);
} else {
src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
}
}
srcY += src_y * s->linesize + src_x;
if (v->field_mode && v->ref_field_type[dir])
srcY += s->current_picture_ptr->f.linesize[0];
if (fieldmv && !(src_y & 1))
v_edge_pos--;
if (fieldmv && (src_y & 1) && src_y < 4)
src_y--;
if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 13 || v_edge_pos < 23
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
|| (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
srcY -= s->mspel * (1 + (s->linesize << fieldmv));
s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv,
src_x - s->mspel, src_y - (s->mspel << fieldmv),
s->h_edge_pos, v_edge_pos);
srcY = s->edge_emu_buffer;
if (v->rangeredfrm) {
int i, j;
uint8_t *src;
src = srcY;
for (j = 0; j < 9 + s->mspel * 2; j++) {
for (i = 0; i < 9 + s->mspel * 2; i++)
src[i] = ((src[i] - 128) >> 1) + 128;
src += s->linesize << fieldmv;
}
}
if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
int i, j;
uint8_t *src;
src = srcY;
for (j = 0; j < 9 + s->mspel * 2; j++) {
for (i = 0; i < 9 + s->mspel * 2; i++)
src[i] = v->luty[src[i]];
src += s->linesize << fieldmv;
}
}
srcY += s->mspel * (1 + (s->linesize << fieldmv));
}
if (s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
} else {
dxy = (my & 2) | ((mx & 2) >> 1);
if (!v->rnd)
dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
else
dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VC1Context *VAR_0, int VAR_1, int VAR_2)
{
MpegEncContext *s = &VAR_0->s;
DSPContext *dsp = &VAR_0->s.dsp;
uint8_t *srcY;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;
int VAR_8;
int VAR_9 = (VAR_0->fcm == ILACE_FRAME) ? VAR_0->blk_mv_type[s->block_index[VAR_1]] : 0;
int VAR_10 = s->VAR_10 >> VAR_0->field_mode;
if (!VAR_0->field_mode && !VAR_0->s.last_picture.VAR_15.data[0])
return;
VAR_4 = s->mv[VAR_2][VAR_1][0];
VAR_5 = s->mv[VAR_2][VAR_1][1];
if (!VAR_2) {
if (VAR_0->field_mode) {
if ((VAR_0->cur_field_type != VAR_0->ref_field_type[VAR_2]) && VAR_0->cur_field_type)
srcY = s->current_picture.VAR_15.data[0];
else
srcY = s->last_picture.VAR_15.data[0];
} else
srcY = s->last_picture.VAR_15.data[0];
} else
srcY = s->next_picture.VAR_15.data[0];
if (VAR_0->field_mode) {
if (VAR_0->cur_field_type != VAR_0->ref_field_type[VAR_2])
VAR_5 = VAR_5 - 2 + 4 * VAR_0->cur_field_type;
}
if (s->pict_type == AV_PICTURE_TYPE_P && VAR_1 == 3 && VAR_0->field_mode) {
int VAR_11 = 0, VAR_12 = 0, VAR_13;
int VAR_14[2][4][2], VAR_15;
int VAR_16, VAR_17;
for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {
VAR_15 = VAR_0->mv_f[0][s->block_index[VAR_13] + VAR_0->blocks_off];
VAR_14[VAR_15][VAR_15 ? VAR_12 : VAR_11][0] = s->mv[0][VAR_13][0];
VAR_14[VAR_15][VAR_15 ? VAR_12 : VAR_11][1] = s->mv[0][VAR_13][1];
VAR_12 += VAR_15;
VAR_11 += 1 - VAR_15;
}
VAR_15 = VAR_12 > VAR_11;
switch (VAR_15 ? VAR_12 : VAR_11) {
case 4:
VAR_16 = median4(VAR_14[VAR_15][0][0], VAR_14[VAR_15][1][0],
VAR_14[VAR_15][2][0], VAR_14[VAR_15][3][0]);
VAR_17 = median4(VAR_14[VAR_15][0][1], VAR_14[VAR_15][1][1],
VAR_14[VAR_15][2][1], VAR_14[VAR_15][3][1]);
break;
case 3:
VAR_16 = mid_pred(VAR_14[VAR_15][0][0], VAR_14[VAR_15][1][0], VAR_14[VAR_15][2][0]);
VAR_17 = mid_pred(VAR_14[VAR_15][0][1], VAR_14[VAR_15][1][1], VAR_14[VAR_15][2][1]);
break;
case 2:
VAR_16 = (VAR_14[VAR_15][0][0] + VAR_14[VAR_15][1][0]) / 2;
VAR_17 = (VAR_14[VAR_15][0][1] + VAR_14[VAR_15][1][1]) / 2;
break;
}
s->current_picture.VAR_15.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_16;
s->current_picture.VAR_15.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_17;
for (VAR_13 = 0; VAR_13 < 4; VAR_13++)
VAR_0->mv_f[1][s->block_index[VAR_13] + VAR_0->blocks_off] = VAR_15;
}
if (VAR_0->fcm == ILACE_FRAME) {
int VAR_18, VAR_19;
int VAR_20 = s->avctx->coded_width;
int VAR_21 = s->avctx->coded_height >> 1;
VAR_18 = (s->mb_x * 16) + (VAR_4 >> 2);
VAR_19 = (s->mb_y * 8) + (VAR_5 >> 3);
if (VAR_18 < -17)
VAR_4 -= 4 * (VAR_18 + 17);
else if (VAR_18 > VAR_20)
VAR_4 -= 4 * (VAR_18 - VAR_20);
if (VAR_19 < -18)
VAR_5 -= 8 * (VAR_19 + 18);
else if (VAR_19 > VAR_21 + 1)
VAR_5 -= 8 * (VAR_19 - VAR_21 - 1);
}
if ((VAR_0->fcm == ILACE_FRAME) && VAR_9)
VAR_8 = ((VAR_1 > 1) ? s->linesize : 0) + (VAR_1 & 1) * 8;
else
VAR_8 = s->linesize * 4 * (VAR_1 & 2) + (VAR_1 & 1) * 8;
if (VAR_0->field_mode && VAR_0->cur_field_type)
VAR_8 += s->current_picture_ptr->VAR_15.linesize[0];
VAR_6 = s->mb_x * 16 + (VAR_1 & 1) * 8 + (VAR_4 >> 2);
if (!VAR_9)
VAR_7 = s->mb_y * 16 + (VAR_1 & 2) * 4 + (VAR_5 >> 2);
else
VAR_7 = s->mb_y * 16 + ((VAR_1 > 1) ? 1 : 0) + (VAR_5 >> 2);
if (VAR_0->profile != PROFILE_ADVANCED) {
VAR_6 = av_clip(VAR_6, -16, s->mb_width * 16);
VAR_7 = av_clip(VAR_7, -16, s->mb_height * 16);
} else {
VAR_6 = av_clip(VAR_6, -17, s->avctx->coded_width);
if (VAR_0->fcm == ILACE_FRAME) {
if (VAR_7 & 1)
VAR_7 = av_clip(VAR_7, -17, s->avctx->coded_height + 1);
else
VAR_7 = av_clip(VAR_7, -18, s->avctx->coded_height);
} else {
VAR_7 = av_clip(VAR_7, -18, s->avctx->coded_height + 1);
}
}
srcY += VAR_7 * s->linesize + VAR_6;
if (VAR_0->field_mode && VAR_0->ref_field_type[VAR_2])
srcY += s->current_picture_ptr->VAR_15.linesize[0];
if (VAR_9 && !(VAR_7 & 1))
VAR_10--;
if (VAR_9 && (VAR_7 & 1) && VAR_7 < 4)
VAR_7--;
if (VAR_0->rangeredfrm || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 13 || VAR_10 < 23
|| (unsigned)(VAR_6 - s->mspel) > s->h_edge_pos - (VAR_4 & 3) - 8 - s->mspel * 2
|| (unsigned)(VAR_7 - (s->mspel << VAR_9)) > VAR_10 - (VAR_5 & 3) - ((8 + s->mspel * 2) << VAR_9)) {
srcY -= s->mspel * (1 + (s->linesize << VAR_9));
s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
9 + s->mspel * 2, (9 + s->mspel * 2) << VAR_9,
VAR_6 - s->mspel, VAR_7 - (s->mspel << VAR_9),
s->h_edge_pos, VAR_10);
srcY = s->edge_emu_buffer;
if (VAR_0->rangeredfrm) {
int VAR_24, VAR_24;
uint8_t *src;
src = srcY;
for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++) {
for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++)
src[VAR_24] = ((src[VAR_24] - 128) >> 1) + 128;
src += s->linesize << VAR_9;
}
}
if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {
int VAR_24, VAR_24;
uint8_t *src;
src = srcY;
for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++) {
for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++)
src[VAR_24] = VAR_0->luty[src[VAR_24]];
src += s->linesize << VAR_9;
}
}
srcY += s->mspel * (1 + (s->linesize << VAR_9));
}
if (s->mspel) {
VAR_3 = ((VAR_5 & 3) << 2) | (VAR_4 & 3);
VAR_0->vc1dsp.put_vc1_mspel_pixels_tab[VAR_3](s->dest[0] + VAR_8, srcY, s->linesize << VAR_9, VAR_0->rnd);
} else {
VAR_3 = (VAR_5 & 2) | ((VAR_4 & 2) >> 1);
if (!VAR_0->rnd)
dsp->put_pixels_tab[1][VAR_3](s->dest[0] + VAR_8, srcY, s->linesize, 8);
else
dsp->put_no_rnd_pixels_tab[1][VAR_3](s->dest[0] + VAR_8, srcY, s->linesize, 8);
}
}
| [
"static void FUNC_0(VC1Context *VAR_0, int VAR_1, int VAR_2)\n{",
"MpegEncContext *s = &VAR_0->s;",
"DSPContext *dsp = &VAR_0->s.dsp;",
"uint8_t *srcY;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;",
"int VAR_8;",
"int VAR_9 = (VAR_0->fcm == ILACE_FRAME) ? VAR_0->blk_mv_type[s->block_index[VAR_1]] : 0;",
"int VAR_10 = s->VAR_10 >> VAR_0->field_mode;",
"if (!VAR_0->field_mode && !VAR_0->s.last_picture.VAR_15.data[0])\nreturn;",
"VAR_4 = s->mv[VAR_2][VAR_1][0];",
"VAR_5 = s->mv[VAR_2][VAR_1][1];",
"if (!VAR_2) {",
"if (VAR_0->field_mode) {",
"if ((VAR_0->cur_field_type != VAR_0->ref_field_type[VAR_2]) && VAR_0->cur_field_type)\nsrcY = s->current_picture.VAR_15.data[0];",
"else\nsrcY = s->last_picture.VAR_15.data[0];",
"} else",
"srcY = s->last_picture.VAR_15.data[0];",
"} else",
"srcY = s->next_picture.VAR_15.data[0];",
"if (VAR_0->field_mode) {",
"if (VAR_0->cur_field_type != VAR_0->ref_field_type[VAR_2])\nVAR_5 = VAR_5 - 2 + 4 * VAR_0->cur_field_type;",
"}",
"if (s->pict_type == AV_PICTURE_TYPE_P && VAR_1 == 3 && VAR_0->field_mode) {",
"int VAR_11 = 0, VAR_12 = 0, VAR_13;",
"int VAR_14[2][4][2], VAR_15;",
"int VAR_16, VAR_17;",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {",
"VAR_15 = VAR_0->mv_f[0][s->block_index[VAR_13] + VAR_0->blocks_off];",
"VAR_14[VAR_15][VAR_15 ? VAR_12 : VAR_11][0] = s->mv[0][VAR_13][0];",
"VAR_14[VAR_15][VAR_15 ? VAR_12 : VAR_11][1] = s->mv[0][VAR_13][1];",
"VAR_12 += VAR_15;",
"VAR_11 += 1 - VAR_15;",
"}",
"VAR_15 = VAR_12 > VAR_11;",
"switch (VAR_15 ? VAR_12 : VAR_11) {",
"case 4:\nVAR_16 = median4(VAR_14[VAR_15][0][0], VAR_14[VAR_15][1][0],\nVAR_14[VAR_15][2][0], VAR_14[VAR_15][3][0]);",
"VAR_17 = median4(VAR_14[VAR_15][0][1], VAR_14[VAR_15][1][1],\nVAR_14[VAR_15][2][1], VAR_14[VAR_15][3][1]);",
"break;",
"case 3:\nVAR_16 = mid_pred(VAR_14[VAR_15][0][0], VAR_14[VAR_15][1][0], VAR_14[VAR_15][2][0]);",
"VAR_17 = mid_pred(VAR_14[VAR_15][0][1], VAR_14[VAR_15][1][1], VAR_14[VAR_15][2][1]);",
"break;",
"case 2:\nVAR_16 = (VAR_14[VAR_15][0][0] + VAR_14[VAR_15][1][0]) / 2;",
"VAR_17 = (VAR_14[VAR_15][0][1] + VAR_14[VAR_15][1][1]) / 2;",
"break;",
"}",
"s->current_picture.VAR_15.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_16;",
"s->current_picture.VAR_15.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_17;",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++)",
"VAR_0->mv_f[1][s->block_index[VAR_13] + VAR_0->blocks_off] = VAR_15;",
"}",
"if (VAR_0->fcm == ILACE_FRAME) {",
"int VAR_18, VAR_19;",
"int VAR_20 = s->avctx->coded_width;",
"int VAR_21 = s->avctx->coded_height >> 1;",
"VAR_18 = (s->mb_x * 16) + (VAR_4 >> 2);",
"VAR_19 = (s->mb_y * 8) + (VAR_5 >> 3);",
"if (VAR_18 < -17)\nVAR_4 -= 4 * (VAR_18 + 17);",
"else if (VAR_18 > VAR_20)\nVAR_4 -= 4 * (VAR_18 - VAR_20);",
"if (VAR_19 < -18)\nVAR_5 -= 8 * (VAR_19 + 18);",
"else if (VAR_19 > VAR_21 + 1)\nVAR_5 -= 8 * (VAR_19 - VAR_21 - 1);",
"}",
"if ((VAR_0->fcm == ILACE_FRAME) && VAR_9)\nVAR_8 = ((VAR_1 > 1) ? s->linesize : 0) + (VAR_1 & 1) * 8;",
"else\nVAR_8 = s->linesize * 4 * (VAR_1 & 2) + (VAR_1 & 1) * 8;",
"if (VAR_0->field_mode && VAR_0->cur_field_type)\nVAR_8 += s->current_picture_ptr->VAR_15.linesize[0];",
"VAR_6 = s->mb_x * 16 + (VAR_1 & 1) * 8 + (VAR_4 >> 2);",
"if (!VAR_9)\nVAR_7 = s->mb_y * 16 + (VAR_1 & 2) * 4 + (VAR_5 >> 2);",
"else\nVAR_7 = s->mb_y * 16 + ((VAR_1 > 1) ? 1 : 0) + (VAR_5 >> 2);",
"if (VAR_0->profile != PROFILE_ADVANCED) {",
"VAR_6 = av_clip(VAR_6, -16, s->mb_width * 16);",
"VAR_7 = av_clip(VAR_7, -16, s->mb_height * 16);",
"} else {",
"VAR_6 = av_clip(VAR_6, -17, s->avctx->coded_width);",
"if (VAR_0->fcm == ILACE_FRAME) {",
"if (VAR_7 & 1)\nVAR_7 = av_clip(VAR_7, -17, s->avctx->coded_height + 1);",
"else\nVAR_7 = av_clip(VAR_7, -18, s->avctx->coded_height);",
"} else {",
"VAR_7 = av_clip(VAR_7, -18, s->avctx->coded_height + 1);",
"}",
"}",
"srcY += VAR_7 * s->linesize + VAR_6;",
"if (VAR_0->field_mode && VAR_0->ref_field_type[VAR_2])\nsrcY += s->current_picture_ptr->VAR_15.linesize[0];",
"if (VAR_9 && !(VAR_7 & 1))\nVAR_10--;",
"if (VAR_9 && (VAR_7 & 1) && VAR_7 < 4)\nVAR_7--;",
"if (VAR_0->rangeredfrm || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)\n|| s->h_edge_pos < 13 || VAR_10 < 23\n|| (unsigned)(VAR_6 - s->mspel) > s->h_edge_pos - (VAR_4 & 3) - 8 - s->mspel * 2\n|| (unsigned)(VAR_7 - (s->mspel << VAR_9)) > VAR_10 - (VAR_5 & 3) - ((8 + s->mspel * 2) << VAR_9)) {",
"srcY -= s->mspel * (1 + (s->linesize << VAR_9));",
"s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,\n9 + s->mspel * 2, (9 + s->mspel * 2) << VAR_9,\nVAR_6 - s->mspel, VAR_7 - (s->mspel << VAR_9),\ns->h_edge_pos, VAR_10);",
"srcY = s->edge_emu_buffer;",
"if (VAR_0->rangeredfrm) {",
"int VAR_24, VAR_24;",
"uint8_t *src;",
"src = srcY;",
"for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++) {",
"for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++)",
"src[VAR_24] = ((src[VAR_24] - 128) >> 1) + 128;",
"src += s->linesize << VAR_9;",
"}",
"}",
"if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {",
"int VAR_24, VAR_24;",
"uint8_t *src;",
"src = srcY;",
"for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++) {",
"for (VAR_24 = 0; VAR_24 < 9 + s->mspel * 2; VAR_24++)",
"src[VAR_24] = VAR_0->luty[src[VAR_24]];",
"src += s->linesize << VAR_9;",
"}",
"}",
"srcY += s->mspel * (1 + (s->linesize << VAR_9));",
"}",
"if (s->mspel) {",
"VAR_3 = ((VAR_5 & 3) << 2) | (VAR_4 & 3);",
"VAR_0->vc1dsp.put_vc1_mspel_pixels_tab[VAR_3](s->dest[0] + VAR_8, srcY, s->linesize << VAR_9, VAR_0->rnd);",
"} else {",
"VAR_3 = (VAR_5 & 2) | ((VAR_4 & 2) >> 1);",
"if (!VAR_0->rnd)\ndsp->put_pixels_tab[1][VAR_3](s->dest[0] + VAR_8, srcY, s->linesize, 8);",
"else\ndsp->put_no_rnd_pixels_tab[1][VAR_3](s->dest[0] + VAR_8, srcY, s->linesize, 8);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
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
],
[
141
],
[
143
],
[
147,
149
],
[
151,
153
],
[
155,
157
],
[
159,
161
],
[
163
],
[
167,
169
],
[
171,
173
],
[
175,
177
],
[
181
],
[
183,
185
],
[
187,
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225,
227
],
[
231,
233
],
[
235,
237
],
[
239,
241,
243,
245
],
[
247
],
[
251,
253,
255,
257
],
[
259
],
[
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325,
327
],
[
329,
331
],
[
333
],
[
335
]
] |
27,300 | int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_pwritev(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
/* throttling disk I/O */
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, true);
}
if (!blk->enable_write_cache) {
flags |= BDRV_REQ_FUA;
}
return bdrv_co_pwritev(blk_bs(blk), offset, bytes, qiov, flags);
}
| false | qemu | a03ef88f77af045a2eb9629b5ce774a3fb973c5e | int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_pwritev(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, true);
}
if (!blk->enable_write_cache) {
flags |= BDRV_REQ_FUA;
}
return bdrv_co_pwritev(blk_bs(blk), offset, bytes, qiov, flags);
}
| {
"code": [],
"line_no": []
} | int VAR_0 blk_co_pwritev(BlockBackend *blk, int64_t offset,
unsigned int bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
int ret;
trace_blk_co_pwritev(blk, blk_bs(blk), offset, bytes, flags);
ret = blk_check_byte_request(blk, offset, bytes);
if (ret < 0) {
return ret;
}
if (blk->public.throttle_state) {
throttle_group_co_io_limits_intercept(blk, bytes, true);
}
if (!blk->enable_write_cache) {
flags |= BDRV_REQ_FUA;
}
return bdrv_co_pwritev(blk_bs(blk), offset, bytes, qiov, flags);
}
| [
"int VAR_0 blk_co_pwritev(BlockBackend *blk, int64_t offset,\nunsigned int bytes, QEMUIOVector *qiov,\nBdrvRequestFlags flags)\n{",
"int ret;",
"trace_blk_co_pwritev(blk, blk_bs(blk), offset, bytes, flags);",
"ret = blk_check_byte_request(blk, offset, bytes);",
"if (ret < 0) {",
"return ret;",
"}",
"if (blk->public.throttle_state) {",
"throttle_group_co_io_limits_intercept(blk, bytes, true);",
"}",
"if (!blk->enable_write_cache) {",
"flags |= BDRV_REQ_FUA;",
"}",
"return bdrv_co_pwritev(blk_bs(blk), offset, bytes, qiov, flags);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
27,301 | void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
switch (event) {
case QEVENT_DEBUG:
event_name = "DEBUG";
break;
case QEVENT_SHUTDOWN:
event_name = "SHUTDOWN";
break;
case QEVENT_RESET:
event_name = "RESET";
break;
case QEVENT_POWERDOWN:
event_name = "POWERDOWN";
break;
case QEVENT_STOP:
event_name = "STOP";
break;
case QEVENT_VNC_CONNECTED:
event_name = "VNC_CONNECTED";
break;
case QEVENT_VNC_INITIALIZED:
event_name = "VNC_INITIALIZED";
break;
case QEVENT_VNC_DISCONNECTED:
event_name = "VNC_DISCONNECTED";
break;
default:
abort();
break;
}
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (!monitor_ctrl_mode(mon))
return;
monitor_json_emitter(mon, QOBJECT(qmp));
}
QDECREF(qmp);
}
| false | qemu | 23fabed13645fdf66473e458f318baa63be56b22 | void monitor_protocol_event(MonitorEvent event, QObject *data)
{
QDict *qmp;
const char *event_name;
Monitor *mon;
assert(event < QEVENT_MAX);
switch (event) {
case QEVENT_DEBUG:
event_name = "DEBUG";
break;
case QEVENT_SHUTDOWN:
event_name = "SHUTDOWN";
break;
case QEVENT_RESET:
event_name = "RESET";
break;
case QEVENT_POWERDOWN:
event_name = "POWERDOWN";
break;
case QEVENT_STOP:
event_name = "STOP";
break;
case QEVENT_VNC_CONNECTED:
event_name = "VNC_CONNECTED";
break;
case QEVENT_VNC_INITIALIZED:
event_name = "VNC_INITIALIZED";
break;
case QEVENT_VNC_DISCONNECTED:
event_name = "VNC_DISCONNECTED";
break;
default:
abort();
break;
}
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "event", qstring_from_str(event_name));
if (data) {
qobject_incref(data);
qdict_put_obj(qmp, "data", data);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (!monitor_ctrl_mode(mon))
return;
monitor_json_emitter(mon, QOBJECT(qmp));
}
QDECREF(qmp);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MonitorEvent VAR_0, QObject *VAR_1)
{
QDict *qmp;
const char *VAR_2;
Monitor *mon;
assert(VAR_0 < QEVENT_MAX);
switch (VAR_0) {
case QEVENT_DEBUG:
VAR_2 = "DEBUG";
break;
case QEVENT_SHUTDOWN:
VAR_2 = "SHUTDOWN";
break;
case QEVENT_RESET:
VAR_2 = "RESET";
break;
case QEVENT_POWERDOWN:
VAR_2 = "POWERDOWN";
break;
case QEVENT_STOP:
VAR_2 = "STOP";
break;
case QEVENT_VNC_CONNECTED:
VAR_2 = "VNC_CONNECTED";
break;
case QEVENT_VNC_INITIALIZED:
VAR_2 = "VNC_INITIALIZED";
break;
case QEVENT_VNC_DISCONNECTED:
VAR_2 = "VNC_DISCONNECTED";
break;
default:
abort();
break;
}
qmp = qdict_new();
timestamp_put(qmp);
qdict_put(qmp, "VAR_0", qstring_from_str(VAR_2));
if (VAR_1) {
qobject_incref(VAR_1);
qdict_put_obj(qmp, "VAR_1", VAR_1);
}
QLIST_FOREACH(mon, &mon_list, entry) {
if (!monitor_ctrl_mode(mon))
return;
monitor_json_emitter(mon, QOBJECT(qmp));
}
QDECREF(qmp);
}
| [
"void FUNC_0(MonitorEvent VAR_0, QObject *VAR_1)\n{",
"QDict *qmp;",
"const char *VAR_2;",
"Monitor *mon;",
"assert(VAR_0 < QEVENT_MAX);",
"switch (VAR_0) {",
"case QEVENT_DEBUG:\nVAR_2 = \"DEBUG\";",
"break;",
"case QEVENT_SHUTDOWN:\nVAR_2 = \"SHUTDOWN\";",
"break;",
"case QEVENT_RESET:\nVAR_2 = \"RESET\";",
"break;",
"case QEVENT_POWERDOWN:\nVAR_2 = \"POWERDOWN\";",
"break;",
"case QEVENT_STOP:\nVAR_2 = \"STOP\";",
"break;",
"case QEVENT_VNC_CONNECTED:\nVAR_2 = \"VNC_CONNECTED\";",
"break;",
"case QEVENT_VNC_INITIALIZED:\nVAR_2 = \"VNC_INITIALIZED\";",
"break;",
"case QEVENT_VNC_DISCONNECTED:\nVAR_2 = \"VNC_DISCONNECTED\";",
"break;",
"default:\nabort();",
"break;",
"}",
"qmp = qdict_new();",
"timestamp_put(qmp);",
"qdict_put(qmp, \"VAR_0\", qstring_from_str(VAR_2));",
"if (VAR_1) {",
"qobject_incref(VAR_1);",
"qdict_put_obj(qmp, \"VAR_1\", VAR_1);",
"}",
"QLIST_FOREACH(mon, &mon_list, entry) {",
"if (!monitor_ctrl_mode(mon))\nreturn;",
"monitor_json_emitter(mon, QOBJECT(qmp));",
"}",
"QDECREF(qmp);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
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
],
[
93
],
[
95,
97
],
[
101
],
[
103
],
[
105
],
[
107
]
] |
27,302 | static int ppce500_prep_device_tree(MachineState *machine,
PPCE500Params *params,
hwaddr addr,
hwaddr initrd_base,
hwaddr initrd_size)
{
DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
p->machine = machine;
p->params = *params;
p->addr = addr;
p->initrd_base = initrd_base;
p->initrd_size = initrd_size;
qemu_register_reset(ppce500_reset_device_tree, p);
/* Issue the device tree loader once, so that we get the size of the blob */
return ppce500_load_device_tree(machine, params, addr, initrd_base,
initrd_size, true);
}
| false | qemu | 903585dec63ee83bd8149006e31f92ea789b38e3 | static int ppce500_prep_device_tree(MachineState *machine,
PPCE500Params *params,
hwaddr addr,
hwaddr initrd_base,
hwaddr initrd_size)
{
DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
p->machine = machine;
p->params = *params;
p->addr = addr;
p->initrd_base = initrd_base;
p->initrd_size = initrd_size;
qemu_register_reset(ppce500_reset_device_tree, p);
return ppce500_load_device_tree(machine, params, addr, initrd_base,
initrd_size, true);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MachineState *VAR_0,
PPCE500Params *VAR_1,
hwaddr VAR_2,
hwaddr VAR_3,
hwaddr VAR_4)
{
DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
p->VAR_0 = VAR_0;
p->VAR_1 = *VAR_1;
p->VAR_2 = VAR_2;
p->VAR_3 = VAR_3;
p->VAR_4 = VAR_4;
qemu_register_reset(ppce500_reset_device_tree, p);
return ppce500_load_device_tree(VAR_0, VAR_1, VAR_2, VAR_3,
VAR_4, true);
}
| [
"static int FUNC_0(MachineState *VAR_0,\nPPCE500Params *VAR_1,\nhwaddr VAR_2,\nhwaddr VAR_3,\nhwaddr VAR_4)\n{",
"DeviceTreeParams *p = g_new(DeviceTreeParams, 1);",
"p->VAR_0 = VAR_0;",
"p->VAR_1 = *VAR_1;",
"p->VAR_2 = VAR_2;",
"p->VAR_3 = VAR_3;",
"p->VAR_4 = VAR_4;",
"qemu_register_reset(ppce500_reset_device_tree, p);",
"return ppce500_load_device_tree(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, true);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
33,
35
],
[
37
]
] |
27,303 | int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_ioctl)
return drv->bdrv_ioctl(bs, req, buf);
return -ENOTSUP;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_ioctl)
return drv->bdrv_ioctl(bs, req, buf);
return -ENOTSUP;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, unsigned long int VAR_1, void *VAR_2)
{
BlockDriver *drv = VAR_0->drv;
if (drv && drv->FUNC_0)
return drv->FUNC_0(VAR_0, VAR_1, VAR_2);
return -ENOTSUP;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, unsigned long int VAR_1, void *VAR_2)\n{",
"BlockDriver *drv = VAR_0->drv;",
"if (drv && drv->FUNC_0)\nreturn drv->FUNC_0(VAR_0, VAR_1, VAR_2);",
"return -ENOTSUP;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
]
] |
27,304 | void tb_invalidate_phys_addr(target_phys_addr_t addr)
{
ram_addr_t ram_addr;
MemoryRegionSection *section;
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr)
|| (section->mr->rom_device && section->mr->readable))) {
return;
}
ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
}
| false | qemu | ac1970fbe8ad5a70174f462109ac0f6c7bf1bc43 | void tb_invalidate_phys_addr(target_phys_addr_t addr)
{
ram_addr_t ram_addr;
MemoryRegionSection *section;
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr)
|| (section->mr->rom_device && section->mr->readable))) {
return;
}
ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(target_phys_addr_t VAR_0)
{
ram_addr_t ram_addr;
MemoryRegionSection *section;
section = phys_page_find(VAR_0 >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr)
|| (section->mr->rom_device && section->mr->readable))) {
return;
}
ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ memory_region_section_addr(section, VAR_0);
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
}
| [
"void FUNC_0(target_phys_addr_t VAR_0)\n{",
"ram_addr_t ram_addr;",
"MemoryRegionSection *section;",
"section = phys_page_find(VAR_0 >> TARGET_PAGE_BITS);",
"if (!(memory_region_is_ram(section->mr)\n|| (section->mr->rom_device && section->mr->readable))) {",
"return;",
"}",
"ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)\n+ memory_region_section_addr(section, VAR_0);",
"tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
]
] |
27,305 | static void scsi_generic_realize(SCSIDevice *s, Error **errp)
{
int rc;
int sg_version;
struct sg_scsi_id scsiid;
if (!s->conf.bs) {
error_setg(errp, "drive property not set");
return;
}
if (bdrv_get_on_error(s->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
error_setg(errp, "Device doesn't support drive option werror");
return;
}
if (bdrv_get_on_error(s->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
error_setg(errp, "Device doesn't support drive option rerror");
return;
}
/* check we are using a driver managing SG_IO (version 3 and after */
rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version);
if (rc < 0) {
error_setg(errp, "cannot get SG_IO version number: %s. "
"Is this a SCSI device?",
strerror(-rc));
return;
}
if (sg_version < 30000) {
error_setg(errp, "scsi generic interface too old");
return;
}
/* get LUN of the /dev/sg? */
if (bdrv_ioctl(s->conf.bs, SG_GET_SCSI_ID, &scsiid)) {
error_setg(errp, "SG_GET_SCSI_ID ioctl failed");
return;
}
/* define device state */
s->type = scsiid.scsi_type;
DPRINTF("device type %d\n", s->type);
switch (s->type) {
case TYPE_TAPE:
s->blocksize = get_stream_blocksize(s->conf.bs);
if (s->blocksize == -1) {
s->blocksize = 0;
}
break;
/* Make a guess for block devices, we'll fix it when the guest sends.
* READ CAPACITY. If they don't, they likely would assume these sizes
* anyway. (TODO: they could also send MODE SENSE).
*/
case TYPE_ROM:
case TYPE_WORM:
s->blocksize = 2048;
break;
default:
s->blocksize = 512;
break;
}
DPRINTF("block size %d\n", s->blocksize);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void scsi_generic_realize(SCSIDevice *s, Error **errp)
{
int rc;
int sg_version;
struct sg_scsi_id scsiid;
if (!s->conf.bs) {
error_setg(errp, "drive property not set");
return;
}
if (bdrv_get_on_error(s->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
error_setg(errp, "Device doesn't support drive option werror");
return;
}
if (bdrv_get_on_error(s->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
error_setg(errp, "Device doesn't support drive option rerror");
return;
}
rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version);
if (rc < 0) {
error_setg(errp, "cannot get SG_IO version number: %s. "
"Is this a SCSI device?",
strerror(-rc));
return;
}
if (sg_version < 30000) {
error_setg(errp, "scsi generic interface too old");
return;
}
if (bdrv_ioctl(s->conf.bs, SG_GET_SCSI_ID, &scsiid)) {
error_setg(errp, "SG_GET_SCSI_ID ioctl failed");
return;
}
s->type = scsiid.scsi_type;
DPRINTF("device type %d\n", s->type);
switch (s->type) {
case TYPE_TAPE:
s->blocksize = get_stream_blocksize(s->conf.bs);
if (s->blocksize == -1) {
s->blocksize = 0;
}
break;
case TYPE_ROM:
case TYPE_WORM:
s->blocksize = 2048;
break;
default:
s->blocksize = 512;
break;
}
DPRINTF("block size %d\n", s->blocksize);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1)
{
int VAR_2;
int VAR_3;
struct sg_scsi_id VAR_4;
if (!VAR_0->conf.bs) {
error_setg(VAR_1, "drive property not set");
return;
}
if (bdrv_get_on_error(VAR_0->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
error_setg(VAR_1, "Device doesn't support drive option werror");
return;
}
if (bdrv_get_on_error(VAR_0->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
error_setg(VAR_1, "Device doesn't support drive option rerror");
return;
}
VAR_2 = bdrv_ioctl(VAR_0->conf.bs, SG_GET_VERSION_NUM, &VAR_3);
if (VAR_2 < 0) {
error_setg(VAR_1, "cannot get SG_IO version number: %VAR_0. "
"Is this a SCSI device?",
strerror(-VAR_2));
return;
}
if (VAR_3 < 30000) {
error_setg(VAR_1, "scsi generic interface too old");
return;
}
if (bdrv_ioctl(VAR_0->conf.bs, SG_GET_SCSI_ID, &VAR_4)) {
error_setg(VAR_1, "SG_GET_SCSI_ID ioctl failed");
return;
}
VAR_0->type = VAR_4.scsi_type;
DPRINTF("device type %d\n", VAR_0->type);
switch (VAR_0->type) {
case TYPE_TAPE:
VAR_0->blocksize = get_stream_blocksize(VAR_0->conf.bs);
if (VAR_0->blocksize == -1) {
VAR_0->blocksize = 0;
}
break;
case TYPE_ROM:
case TYPE_WORM:
VAR_0->blocksize = 2048;
break;
default:
VAR_0->blocksize = 512;
break;
}
DPRINTF("block size %d\n", VAR_0->blocksize);
}
| [
"static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1)\n{",
"int VAR_2;",
"int VAR_3;",
"struct sg_scsi_id VAR_4;",
"if (!VAR_0->conf.bs) {",
"error_setg(VAR_1, \"drive property not set\");",
"return;",
"}",
"if (bdrv_get_on_error(VAR_0->conf.bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {",
"error_setg(VAR_1, \"Device doesn't support drive option werror\");",
"return;",
"}",
"if (bdrv_get_on_error(VAR_0->conf.bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {",
"error_setg(VAR_1, \"Device doesn't support drive option rerror\");",
"return;",
"}",
"VAR_2 = bdrv_ioctl(VAR_0->conf.bs, SG_GET_VERSION_NUM, &VAR_3);",
"if (VAR_2 < 0) {",
"error_setg(VAR_1, \"cannot get SG_IO version number: %VAR_0. \"\n\"Is this a SCSI device?\",\nstrerror(-VAR_2));",
"return;",
"}",
"if (VAR_3 < 30000) {",
"error_setg(VAR_1, \"scsi generic interface too old\");",
"return;",
"}",
"if (bdrv_ioctl(VAR_0->conf.bs, SG_GET_SCSI_ID, &VAR_4)) {",
"error_setg(VAR_1, \"SG_GET_SCSI_ID ioctl failed\");",
"return;",
"}",
"VAR_0->type = VAR_4.scsi_type;",
"DPRINTF(\"device type %d\\n\", VAR_0->type);",
"switch (VAR_0->type) {",
"case TYPE_TAPE:\nVAR_0->blocksize = get_stream_blocksize(VAR_0->conf.bs);",
"if (VAR_0->blocksize == -1) {",
"VAR_0->blocksize = 0;",
"}",
"break;",
"case TYPE_ROM:\ncase TYPE_WORM:\nVAR_0->blocksize = 2048;",
"break;",
"default:\nVAR_0->blocksize = 512;",
"break;",
"}",
"DPRINTF(\"block size %d\\n\", VAR_0->blocksize);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
43
],
[
45
],
[
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
111,
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
129
],
[
131
]
] |
27,306 | static void pool_release_buffer(void *opaque, uint8_t *data)
{
BufferPoolEntry *buf = opaque;
AVBufferPool *pool = buf->pool;
if(CONFIG_MEMORY_POISONING)
memset(buf->data, 0x2a, pool->size);
add_to_pool(buf);
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
buffer_pool_free(pool);
}
| false | FFmpeg | 84be80698227366d970e045001e4b59e4f99f0a1 | static void pool_release_buffer(void *opaque, uint8_t *data)
{
BufferPoolEntry *buf = opaque;
AVBufferPool *pool = buf->pool;
if(CONFIG_MEMORY_POISONING)
memset(buf->data, 0x2a, pool->size);
add_to_pool(buf);
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
buffer_pool_free(pool);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, uint8_t *VAR_1)
{
BufferPoolEntry *buf = VAR_0;
AVBufferPool *pool = buf->pool;
if(CONFIG_MEMORY_POISONING)
memset(buf->VAR_1, 0x2a, pool->size);
add_to_pool(buf);
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
buffer_pool_free(pool);
}
| [
"static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{",
"BufferPoolEntry *buf = VAR_0;",
"AVBufferPool *pool = buf->pool;",
"if(CONFIG_MEMORY_POISONING)\nmemset(buf->VAR_1, 0x2a, pool->size);",
"add_to_pool(buf);",
"if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))\nbuffer_pool_free(pool);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19,
21
],
[
23
]
] |
27,307 | static void dec_load(DisasContext *dc)
{
TCGv t, *addr;
unsigned int size;
size = 1 << (dc->opcode & 3);
LOG_DIS("l %x %d\n", dc->opcode, size);
t_sync_flags(dc);
addr = compute_ldst_addr(dc, &t);
/* If we get a fault on a dslot, the jmpstate better be in sync. */
sync_jmpstate(dc);
/* Verify alignment if needed. */
if ((dc->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1) {
gen_helper_memalign(*addr, tcg_const_tl(dc->rd),
tcg_const_tl(0), tcg_const_tl(size));
}
if (dc->rd) {
gen_load(dc, cpu_R[dc->rd], *addr, size);
} else {
gen_load(dc, env_imm, *addr, size);
}
if (addr == &t)
tcg_temp_free(t);
}
| false | qemu | 3aa80988430f41847e1b78d165440ac03503b6d0 | static void dec_load(DisasContext *dc)
{
TCGv t, *addr;
unsigned int size;
size = 1 << (dc->opcode & 3);
LOG_DIS("l %x %d\n", dc->opcode, size);
t_sync_flags(dc);
addr = compute_ldst_addr(dc, &t);
sync_jmpstate(dc);
if ((dc->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && size > 1) {
gen_helper_memalign(*addr, tcg_const_tl(dc->rd),
tcg_const_tl(0), tcg_const_tl(size));
}
if (dc->rd) {
gen_load(dc, cpu_R[dc->rd], *addr, size);
} else {
gen_load(dc, env_imm, *addr, size);
}
if (addr == &t)
tcg_temp_free(t);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
TCGv t, *addr;
unsigned int VAR_1;
VAR_1 = 1 << (VAR_0->opcode & 3);
LOG_DIS("l %x %d\n", VAR_0->opcode, VAR_1);
t_sync_flags(VAR_0);
addr = compute_ldst_addr(VAR_0, &t);
sync_jmpstate(VAR_0);
if ((VAR_0->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && VAR_1 > 1) {
gen_helper_memalign(*addr, tcg_const_tl(VAR_0->rd),
tcg_const_tl(0), tcg_const_tl(VAR_1));
}
if (VAR_0->rd) {
gen_load(VAR_0, cpu_R[VAR_0->rd], *addr, VAR_1);
} else {
gen_load(VAR_0, env_imm, *addr, VAR_1);
}
if (addr == &t)
tcg_temp_free(t);
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"TCGv t, *addr;",
"unsigned int VAR_1;",
"VAR_1 = 1 << (VAR_0->opcode & 3);",
"LOG_DIS(\"l %x %d\\n\", VAR_0->opcode, VAR_1);",
"t_sync_flags(VAR_0);",
"addr = compute_ldst_addr(VAR_0, &t);",
"sync_jmpstate(VAR_0);",
"if ((VAR_0->env->pvr.regs[2] & PVR2_UNALIGNED_EXC_MASK) && VAR_1 > 1) {",
"gen_helper_memalign(*addr, tcg_const_tl(VAR_0->rd),\ntcg_const_tl(0), tcg_const_tl(VAR_1));",
"}",
"if (VAR_0->rd) {",
"gen_load(VAR_0, cpu_R[VAR_0->rd], *addr, VAR_1);",
"} else {",
"gen_load(VAR_0, env_imm, *addr, VAR_1);",
"}",
"if (addr == &t)\ntcg_temp_free(t);",
"}"
] | [
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
],
[
25
],
[
31
],
[
33,
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
]
] |
27,308 | void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci);
qemu_irq sci_irq;
sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);
ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, sci_irq);
ich9_lpc_reset(&lpc->d.qdev);
}
| false | qemu | 920557971b60e53c2f3f22e5d6c620ab1ed411fd | void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci);
qemu_irq sci_irq;
sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);
ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, sci_irq);
ich9_lpc_reset(&lpc->d.qdev);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(PCIDevice *VAR_0, bool VAR_1)
{
ICH9LPCState *lpc = ICH9_LPC_DEVICE(VAR_0);
qemu_irq sci_irq;
sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);
ich9_pm_init(VAR_0, &lpc->pm, VAR_1, sci_irq);
ich9_lpc_reset(&lpc->d.qdev);
}
| [
"void FUNC_0(PCIDevice *VAR_0, bool VAR_1)\n{",
"ICH9LPCState *lpc = ICH9_LPC_DEVICE(VAR_0);",
"qemu_irq sci_irq;",
"sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);",
"ich9_pm_init(VAR_0, &lpc->pm, VAR_1, sci_irq);",
"ich9_lpc_reset(&lpc->d.qdev);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
27,309 | uint64_t helper_fctiw (uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
/* sNaN conversion */
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI);
} else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) {
/* qNan / infinity conversion */
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
} else {
farg.ll = float64_to_int32(farg.d, &env->fp_status);
#if USE_PRECISE_EMULATION
/* XXX: higher bits are not supposed to be significant.
* to make tests easier, return the same as a real PowerPC 750
*/
farg.ll |= 0xFFF80000ULL << 32;
#endif
}
return farg.ll;
}
| false | qemu | 185698715dfb18c82ad2a5dbc169908602d43e81 | uint64_t helper_fctiw (uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI);
} else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
} else {
farg.ll = float64_to_int32(farg.d, &env->fp_status);
#if USE_PRECISE_EMULATION
farg.ll |= 0xFFF80000ULL << 32;
#endif
}
return farg.ll;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0 (uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_signaling_nan(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI);
} else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) {
farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);
} else {
farg.ll = float64_to_int32(farg.d, &env->fp_status);
#if USE_PRECISE_EMULATION
farg.ll |= 0xFFF80000ULL << 32;
#endif
}
return farg.ll;
}
| [
"uint64_t FUNC_0 (uint64_t arg)\n{",
"CPU_DoubleU farg;",
"farg.ll = arg;",
"if (unlikely(float64_is_signaling_nan(farg.d))) {",
"farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN | POWERPC_EXCP_FP_VXCVI);",
"} else if (unlikely(float64_is_nan(farg.d) || float64_is_infinity(farg.d))) {",
"farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXCVI);",
"} else {",
"farg.ll = float64_to_int32(farg.d, &env->fp_status);",
"#if USE_PRECISE_EMULATION\nfarg.ll |= 0xFFF80000ULL << 32;",
"#endif\n}",
"return farg.ll;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27,
35
],
[
37,
39
],
[
41
],
[
43
]
] |
27,310 | static int ppc_hash64_pte_prot(PowerPCCPU *cpu,
ppc_slb_t *slb, ppc_hash_pte64_t pte)
{
CPUPPCState *env = &cpu->env;
unsigned pp, key;
/* Some pp bit combinations have undefined behaviour, so default
* to no access in those cases */
int prot = 0;
key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61);
if (key == 0) {
switch (pp) {
case 0x0:
case 0x1:
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
case 0x3:
case 0x6:
prot = PAGE_READ;
break;
}
} else {
switch (pp) {
case 0x0:
case 0x6:
prot = 0;
break;
case 0x1:
case 0x3:
prot = PAGE_READ;
break;
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
}
}
/* No execute if either noexec or guarded bits set */
if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)
|| (slb->vsid & SLB_VSID_N)) {
prot |= PAGE_EXEC;
}
return prot;
}
| false | qemu | 347a5c73bafd1b5872c9d3192a4d08f8aa1d5f5a | static int ppc_hash64_pte_prot(PowerPCCPU *cpu,
ppc_slb_t *slb, ppc_hash_pte64_t pte)
{
CPUPPCState *env = &cpu->env;
unsigned pp, key;
int prot = 0;
key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP)
: (slb->vsid & SLB_VSID_KS));
pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61);
if (key == 0) {
switch (pp) {
case 0x0:
case 0x1:
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
case 0x3:
case 0x6:
prot = PAGE_READ;
break;
}
} else {
switch (pp) {
case 0x0:
case 0x6:
prot = 0;
break;
case 0x1:
case 0x3:
prot = PAGE_READ;
break;
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
}
}
if (!(pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G)
|| (slb->vsid & SLB_VSID_N)) {
prot |= PAGE_EXEC;
}
return prot;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PowerPCCPU *VAR_0,
ppc_slb_t *VAR_1, ppc_hash_pte64_t VAR_2)
{
CPUPPCState *env = &VAR_0->env;
unsigned VAR_3, VAR_4;
int VAR_5 = 0;
VAR_4 = !!(msr_pr ? (VAR_1->vsid & SLB_VSID_KP)
: (VAR_1->vsid & SLB_VSID_KS));
VAR_3 = (VAR_2.pte1 & HPTE64_R_PP) | ((VAR_2.pte1 & HPTE64_R_PP0) >> 61);
if (VAR_4 == 0) {
switch (VAR_3) {
case 0x0:
case 0x1:
case 0x2:
VAR_5 = PAGE_READ | PAGE_WRITE;
break;
case 0x3:
case 0x6:
VAR_5 = PAGE_READ;
break;
}
} else {
switch (VAR_3) {
case 0x0:
case 0x6:
VAR_5 = 0;
break;
case 0x1:
case 0x3:
VAR_5 = PAGE_READ;
break;
case 0x2:
VAR_5 = PAGE_READ | PAGE_WRITE;
break;
}
}
if (!(VAR_2.pte1 & HPTE64_R_N) || (VAR_2.pte1 & HPTE64_R_G)
|| (VAR_1->vsid & SLB_VSID_N)) {
VAR_5 |= PAGE_EXEC;
}
return VAR_5;
}
| [
"static int FUNC_0(PowerPCCPU *VAR_0,\nppc_slb_t *VAR_1, ppc_hash_pte64_t VAR_2)\n{",
"CPUPPCState *env = &VAR_0->env;",
"unsigned VAR_3, VAR_4;",
"int VAR_5 = 0;",
"VAR_4 = !!(msr_pr ? (VAR_1->vsid & SLB_VSID_KP)\n: (VAR_1->vsid & SLB_VSID_KS));",
"VAR_3 = (VAR_2.pte1 & HPTE64_R_PP) | ((VAR_2.pte1 & HPTE64_R_PP0) >> 61);",
"if (VAR_4 == 0) {",
"switch (VAR_3) {",
"case 0x0:\ncase 0x1:\ncase 0x2:\nVAR_5 = PAGE_READ | PAGE_WRITE;",
"break;",
"case 0x3:\ncase 0x6:\nVAR_5 = PAGE_READ;",
"break;",
"}",
"} else {",
"switch (VAR_3) {",
"case 0x0:\ncase 0x6:\nVAR_5 = 0;",
"break;",
"case 0x1:\ncase 0x3:\nVAR_5 = PAGE_READ;",
"break;",
"case 0x2:\nVAR_5 = PAGE_READ | PAGE_WRITE;",
"break;",
"}",
"}",
"if (!(VAR_2.pte1 & HPTE64_R_N) || (VAR_2.pte1 & HPTE64_R_G)\n|| (VAR_1->vsid & SLB_VSID_N)) {",
"VAR_5 |= PAGE_EXEC;",
"}",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
15
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31,
33,
35,
37
],
[
39
],
[
43,
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59,
61
],
[
63
],
[
67,
69,
71
],
[
73
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
91,
93
],
[
95
],
[
97
],
[
101
],
[
103
]
] |
27,312 | static void exynos4210_mct_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)opaque;
int index; /* index in buffer which represents register set */
int shift;
int lt_i;
uint64_t new_frc;
uint32_t i;
uint32_t old_val;
#ifdef DEBUG_MCT
static uint32_t icntb_max[2] = {0};
static uint32_t icntb_min[2] = {UINT32_MAX, UINT32_MAX};
static uint32_t tcntb_max[2] = {0};
static uint32_t tcntb_min[2] = {UINT32_MAX, UINT32_MAX};
#endif
new_frc = s->g_timer.reg.cnt;
switch (offset) {
case MCT_CFG:
s->reg_mct_cfg = value;
exynos4210_mct_update_freq(s);
break;
case G_CNT_L:
case G_CNT_U:
if (offset == G_CNT_L) {
DPRINTF("global timer write to reg.cntl %llx\n", value);
new_frc = (s->g_timer.reg.cnt & (uint64_t)UINT32_MAX << 32) + value;
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_L;
}
if (offset == G_CNT_U) {
DPRINTF("global timer write to reg.cntu %llx\n", value);
new_frc = (s->g_timer.reg.cnt & UINT32_MAX) +
((uint64_t)value << 32);
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_U;
}
s->g_timer.reg.cnt = new_frc;
exynos4210_gfrc_restart(s);
break;
case G_CNT_WSTAT:
s->g_timer.reg.cnt_wstat &= ~(value);
break;
case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3):
case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3):
index = GET_G_COMP_IDX(offset);
shift = 8 * (offset & 0x4);
s->g_timer.reg.comp[index] =
(s->g_timer.reg.comp[index] &
(((uint64_t)UINT32_MAX << 32) >> shift)) +
(value << shift);
DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift);
if (offset&0x4) {
s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index);
} else {
s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index);
}
exynos4210_gfrc_restart(s);
break;
case G_TCON:
old_val = s->g_timer.reg.tcon;
s->g_timer.reg.tcon = value;
s->g_timer.reg.wstat |= G_WSTAT_TCON_WRITE;
DPRINTF("global timer write to reg.g_tcon %llx\n", value);
/* Start FRC if transition from disabled to enabled */
if ((value & G_TCON_TIMER_ENABLE) > (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_start(&s->g_timer);
}
if ((value & G_TCON_TIMER_ENABLE) < (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_stop(&s->g_timer);
}
/* Start CMP if transition from disabled to enabled */
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((value & G_TCON_COMP_ENABLE(i)) != (old_val &
G_TCON_COMP_ENABLE(i))) {
exynos4210_gfrc_restart(s);
}
}
break;
case G_INT_CSTAT:
s->g_timer.reg.int_cstat &= ~(value);
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if (value & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
break;
case G_INT_ENB:
/* Raise IRQ if transition from disabled to enabled and CSTAT pending */
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((value & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
if (s->g_timer.reg.int_cstat & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_raise_irq(&s->g_timer, i);
}
}
if ((value & G_INT_ENABLE(i)) < (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
DPRINTF("global timer INT enable %llx\n", value);
s->g_timer.reg.int_enb = value;
break;
case G_WSTAT:
s->g_timer.reg.wstat &= ~(value);
break;
case G_COMP0_ADD_INCR: case G_COMP1_ADD_INCR:
case G_COMP2_ADD_INCR: case G_COMP3_ADD_INCR:
index = GET_G_COMP_ADD_INCR_IDX(offset);
s->g_timer.reg.comp_add_incr[index] = value;
s->g_timer.reg.wstat |= G_WSTAT_COMP_ADDINCR(index);
break;
/* Local timers */
case L0_TCON: case L1_TCON:
lt_i = GET_L_TIMER_IDX(offset);
old_val = s->l_timer[lt_i].reg.tcon;
s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCON_WRITE;
s->l_timer[lt_i].reg.tcon = value;
/* Stop local CNT */
if ((value & L_TCON_TICK_START) <
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] stop cnt\n", lt_i);
exynos4210_ltick_cnt_stop(&s->l_timer[lt_i].tick_timer);
}
/* Stop local INT */
if ((value & L_TCON_INT_START) <
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] stop int\n", lt_i);
exynos4210_ltick_int_stop(&s->l_timer[lt_i].tick_timer);
}
/* Start local CNT */
if ((value & L_TCON_TICK_START) >
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] start cnt\n", lt_i);
exynos4210_ltick_cnt_start(&s->l_timer[lt_i].tick_timer);
}
/* Start local INT */
if ((value & L_TCON_INT_START) >
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] start int\n", lt_i);
exynos4210_ltick_int_start(&s->l_timer[lt_i].tick_timer);
}
/* Start or Stop local FRC if TCON changed */
if ((value & L_TCON_FRC_START) >
(s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] start frc\n", lt_i);
exynos4210_lfrc_start(&s->l_timer[lt_i]);
}
if ((value & L_TCON_FRC_START) <
(s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] stop frc\n", lt_i);
exynos4210_lfrc_stop(&s->l_timer[lt_i]);
}
break;
case L0_TCNTB: case L1_TCNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
/*
* TCNTB is updated to internal register only after CNT expired.
* Due to this we should reload timer to nearest moment when CNT is
* expired and then in event handler update tcntb to new TCNTB value.
*/
exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer, value,
s->l_timer[lt_i].tick_timer.icntb);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] = value;
#ifdef DEBUG_MCT
if (tcntb_min[lt_i] > value) {
tcntb_min[lt_i] = value;
}
if (tcntb_max[lt_i] < value) {
tcntb_max[lt_i] = value;
}
DPRINTF("local timer[%d] TCNTB write %llx; max=%x, min=%x\n",
lt_i, value, tcntb_max[lt_i], tcntb_min[lt_i]);
#endif
break;
case L0_ICNTB: case L1_ICNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
~L_ICNTB_MANUAL_UPDATE;
/*
* We need to avoid too small values for TCNTB*ICNTB. If not, IRQ event
* could raise too fast disallowing QEMU to execute target code.
*/
if (s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] *
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] < MCT_LT_CNT_LOW_LIMIT) {
if (!s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB]) {
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT;
} else {
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT /
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB];
}
}
if (value & L_ICNTB_MANUAL_UPDATE) {
exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer,
s->l_timer[lt_i].tick_timer.tcntb,
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB]);
}
#ifdef DEBUG_MCT
if (icntb_min[lt_i] > value) {
icntb_min[lt_i] = value;
}
if (icntb_max[lt_i] < value) {
icntb_max[lt_i] = value;
}
DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n",
lt_i, value, icntb_max[lt_i], icntb_min[lt_i]);
#endif
break;
case L0_FRCNTB: case L1_FRCNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_FRCCNTB] = value;
break;
case L0_TCNTO: case L1_TCNTO:
case L0_ICNTO: case L1_ICNTO:
case L0_FRCNTO: case L1_FRCNTO:
fprintf(stderr, "\n[exynos4210.mct: write to RO register "
TARGET_FMT_plx "]\n\n", offset);
break;
case L0_INT_CSTAT: case L1_INT_CSTAT:
lt_i = GET_L_TIMER_IDX(offset);
DPRINTF("local timer[%d] CSTAT write %llx\n", lt_i, value);
s->l_timer[lt_i].reg.int_cstat &= ~value;
if (!s->l_timer[lt_i].reg.int_cstat) {
qemu_irq_lower(s->l_timer[lt_i].irq);
}
break;
case L0_INT_ENB: case L1_INT_ENB:
lt_i = GET_L_TIMER_IDX(offset);
old_val = s->l_timer[lt_i].reg.int_enb;
/* Raise Local timer IRQ if cstat is pending */
if ((value & L_INT_INTENB_ICNTEIE) > (old_val & L_INT_INTENB_ICNTEIE)) {
if (s->l_timer[lt_i].reg.int_cstat & L_INT_CSTAT_INTCNT) {
qemu_irq_raise(s->l_timer[lt_i].irq);
}
}
s->l_timer[lt_i].reg.int_enb = value;
break;
case L0_WSTAT: case L1_WSTAT:
lt_i = GET_L_TIMER_IDX(offset);
s->l_timer[lt_i].reg.wstat &= ~value;
break;
default:
hw_error("exynos4210.mct: bad write offset "
TARGET_FMT_plx "\n", offset);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void exynos4210_mct_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)opaque;
int index;
int shift;
int lt_i;
uint64_t new_frc;
uint32_t i;
uint32_t old_val;
#ifdef DEBUG_MCT
static uint32_t icntb_max[2] = {0};
static uint32_t icntb_min[2] = {UINT32_MAX, UINT32_MAX};
static uint32_t tcntb_max[2] = {0};
static uint32_t tcntb_min[2] = {UINT32_MAX, UINT32_MAX};
#endif
new_frc = s->g_timer.reg.cnt;
switch (offset) {
case MCT_CFG:
s->reg_mct_cfg = value;
exynos4210_mct_update_freq(s);
break;
case G_CNT_L:
case G_CNT_U:
if (offset == G_CNT_L) {
DPRINTF("global timer write to reg.cntl %llx\n", value);
new_frc = (s->g_timer.reg.cnt & (uint64_t)UINT32_MAX << 32) + value;
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_L;
}
if (offset == G_CNT_U) {
DPRINTF("global timer write to reg.cntu %llx\n", value);
new_frc = (s->g_timer.reg.cnt & UINT32_MAX) +
((uint64_t)value << 32);
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_U;
}
s->g_timer.reg.cnt = new_frc;
exynos4210_gfrc_restart(s);
break;
case G_CNT_WSTAT:
s->g_timer.reg.cnt_wstat &= ~(value);
break;
case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3):
case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3):
index = GET_G_COMP_IDX(offset);
shift = 8 * (offset & 0x4);
s->g_timer.reg.comp[index] =
(s->g_timer.reg.comp[index] &
(((uint64_t)UINT32_MAX << 32) >> shift)) +
(value << shift);
DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift);
if (offset&0x4) {
s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index);
} else {
s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index);
}
exynos4210_gfrc_restart(s);
break;
case G_TCON:
old_val = s->g_timer.reg.tcon;
s->g_timer.reg.tcon = value;
s->g_timer.reg.wstat |= G_WSTAT_TCON_WRITE;
DPRINTF("global timer write to reg.g_tcon %llx\n", value);
if ((value & G_TCON_TIMER_ENABLE) > (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_start(&s->g_timer);
}
if ((value & G_TCON_TIMER_ENABLE) < (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_stop(&s->g_timer);
}
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((value & G_TCON_COMP_ENABLE(i)) != (old_val &
G_TCON_COMP_ENABLE(i))) {
exynos4210_gfrc_restart(s);
}
}
break;
case G_INT_CSTAT:
s->g_timer.reg.int_cstat &= ~(value);
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if (value & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
break;
case G_INT_ENB:
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((value & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
if (s->g_timer.reg.int_cstat & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_raise_irq(&s->g_timer, i);
}
}
if ((value & G_INT_ENABLE(i)) < (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
DPRINTF("global timer INT enable %llx\n", value);
s->g_timer.reg.int_enb = value;
break;
case G_WSTAT:
s->g_timer.reg.wstat &= ~(value);
break;
case G_COMP0_ADD_INCR: case G_COMP1_ADD_INCR:
case G_COMP2_ADD_INCR: case G_COMP3_ADD_INCR:
index = GET_G_COMP_ADD_INCR_IDX(offset);
s->g_timer.reg.comp_add_incr[index] = value;
s->g_timer.reg.wstat |= G_WSTAT_COMP_ADDINCR(index);
break;
case L0_TCON: case L1_TCON:
lt_i = GET_L_TIMER_IDX(offset);
old_val = s->l_timer[lt_i].reg.tcon;
s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCON_WRITE;
s->l_timer[lt_i].reg.tcon = value;
if ((value & L_TCON_TICK_START) <
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] stop cnt\n", lt_i);
exynos4210_ltick_cnt_stop(&s->l_timer[lt_i].tick_timer);
}
if ((value & L_TCON_INT_START) <
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] stop int\n", lt_i);
exynos4210_ltick_int_stop(&s->l_timer[lt_i].tick_timer);
}
if ((value & L_TCON_TICK_START) >
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] start cnt\n", lt_i);
exynos4210_ltick_cnt_start(&s->l_timer[lt_i].tick_timer);
}
if ((value & L_TCON_INT_START) >
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] start int\n", lt_i);
exynos4210_ltick_int_start(&s->l_timer[lt_i].tick_timer);
}
if ((value & L_TCON_FRC_START) >
(s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] start frc\n", lt_i);
exynos4210_lfrc_start(&s->l_timer[lt_i]);
}
if ((value & L_TCON_FRC_START) <
(s->l_timer[lt_i].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] stop frc\n", lt_i);
exynos4210_lfrc_stop(&s->l_timer[lt_i]);
}
break;
case L0_TCNTB: case L1_TCNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer, value,
s->l_timer[lt_i].tick_timer.icntb);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_TCNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] = value;
#ifdef DEBUG_MCT
if (tcntb_min[lt_i] > value) {
tcntb_min[lt_i] = value;
}
if (tcntb_max[lt_i] < value) {
tcntb_max[lt_i] = value;
}
DPRINTF("local timer[%d] TCNTB write %llx; max=%x, min=%x\n",
lt_i, value, tcntb_max[lt_i], tcntb_min[lt_i]);
#endif
break;
case L0_ICNTB: case L1_ICNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
~L_ICNTB_MANUAL_UPDATE;
if (s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] *
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB] < MCT_LT_CNT_LOW_LIMIT) {
if (!s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB]) {
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT;
} else {
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT /
s->l_timer[lt_i].reg.cnt[L_REG_CNT_TCNTB];
}
}
if (value & L_ICNTB_MANUAL_UPDATE) {
exynos4210_ltick_set_cntb(&s->l_timer[lt_i].tick_timer,
s->l_timer[lt_i].tick_timer.tcntb,
s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB]);
}
#ifdef DEBUG_MCT
if (icntb_min[lt_i] > value) {
icntb_min[lt_i] = value;
}
if (icntb_max[lt_i] < value) {
icntb_max[lt_i] = value;
}
DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n",
lt_i, value, icntb_max[lt_i], icntb_min[lt_i]);
#endif
break;
case L0_FRCNTB: case L1_FRCNTB:
lt_i = GET_L_TIMER_IDX(offset);
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
s->l_timer[lt_i].reg.cnt[L_REG_CNT_FRCCNTB] = value;
break;
case L0_TCNTO: case L1_TCNTO:
case L0_ICNTO: case L1_ICNTO:
case L0_FRCNTO: case L1_FRCNTO:
fprintf(stderr, "\n[exynos4210.mct: write to RO register "
TARGET_FMT_plx "]\n\n", offset);
break;
case L0_INT_CSTAT: case L1_INT_CSTAT:
lt_i = GET_L_TIMER_IDX(offset);
DPRINTF("local timer[%d] CSTAT write %llx\n", lt_i, value);
s->l_timer[lt_i].reg.int_cstat &= ~value;
if (!s->l_timer[lt_i].reg.int_cstat) {
qemu_irq_lower(s->l_timer[lt_i].irq);
}
break;
case L0_INT_ENB: case L1_INT_ENB:
lt_i = GET_L_TIMER_IDX(offset);
old_val = s->l_timer[lt_i].reg.int_enb;
if ((value & L_INT_INTENB_ICNTEIE) > (old_val & L_INT_INTENB_ICNTEIE)) {
if (s->l_timer[lt_i].reg.int_cstat & L_INT_CSTAT_INTCNT) {
qemu_irq_raise(s->l_timer[lt_i].irq);
}
}
s->l_timer[lt_i].reg.int_enb = value;
break;
case L0_WSTAT: case L1_WSTAT:
lt_i = GET_L_TIMER_IDX(offset);
s->l_timer[lt_i].reg.wstat &= ~value;
break;
default:
hw_error("exynos4210.mct: bad write offset "
TARGET_FMT_plx "\n", offset);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
Exynos4210MCTState *s = (Exynos4210MCTState *)VAR_0;
int VAR_4;
int VAR_5;
int VAR_6;
uint64_t new_frc;
uint32_t i;
uint32_t old_val;
#ifdef DEBUG_MCT
static uint32_t icntb_max[2] = {0};
static uint32_t icntb_min[2] = {UINT32_MAX, UINT32_MAX};
static uint32_t tcntb_max[2] = {0};
static uint32_t tcntb_min[2] = {UINT32_MAX, UINT32_MAX};
#endif
new_frc = s->g_timer.reg.cnt;
switch (VAR_1) {
case MCT_CFG:
s->reg_mct_cfg = VAR_2;
exynos4210_mct_update_freq(s);
break;
case G_CNT_L:
case G_CNT_U:
if (VAR_1 == G_CNT_L) {
DPRINTF("global timer write to reg.cntl %llx\n", VAR_2);
new_frc = (s->g_timer.reg.cnt & (uint64_t)UINT32_MAX << 32) + VAR_2;
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_L;
}
if (VAR_1 == G_CNT_U) {
DPRINTF("global timer write to reg.cntu %llx\n", VAR_2);
new_frc = (s->g_timer.reg.cnt & UINT32_MAX) +
((uint64_t)VAR_2 << 32);
s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_U;
}
s->g_timer.reg.cnt = new_frc;
exynos4210_gfrc_restart(s);
break;
case G_CNT_WSTAT:
s->g_timer.reg.cnt_wstat &= ~(VAR_2);
break;
case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3):
case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3):
VAR_4 = GET_G_COMP_IDX(VAR_1);
VAR_5 = 8 * (VAR_1 & 0x4);
s->g_timer.reg.comp[VAR_4] =
(s->g_timer.reg.comp[VAR_4] &
(((uint64_t)UINT32_MAX << 32) >> VAR_5)) +
(VAR_2 << VAR_5);
DPRINTF("comparator %d write 0x%llx val << %d\n", VAR_4, VAR_2, VAR_5);
if (VAR_1&0x4) {
s->g_timer.reg.wstat |= G_WSTAT_COMP_U(VAR_4);
} else {
s->g_timer.reg.wstat |= G_WSTAT_COMP_L(VAR_4);
}
exynos4210_gfrc_restart(s);
break;
case G_TCON:
old_val = s->g_timer.reg.tcon;
s->g_timer.reg.tcon = VAR_2;
s->g_timer.reg.wstat |= G_WSTAT_TCON_WRITE;
DPRINTF("global timer write to reg.g_tcon %llx\n", VAR_2);
if ((VAR_2 & G_TCON_TIMER_ENABLE) > (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_start(&s->g_timer);
}
if ((VAR_2 & G_TCON_TIMER_ENABLE) < (old_val &
G_TCON_TIMER_ENABLE)) {
exynos4210_gfrc_stop(&s->g_timer);
}
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((VAR_2 & G_TCON_COMP_ENABLE(i)) != (old_val &
G_TCON_COMP_ENABLE(i))) {
exynos4210_gfrc_restart(s);
}
}
break;
case G_INT_CSTAT:
s->g_timer.reg.int_cstat &= ~(VAR_2);
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if (VAR_2 & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
break;
case G_INT_ENB:
for (i = 0; i < MCT_GT_CMP_NUM; i++) {
if ((VAR_2 & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
if (s->g_timer.reg.int_cstat & G_INT_CSTAT_COMP(i)) {
exynos4210_gcomp_raise_irq(&s->g_timer, i);
}
}
if ((VAR_2 & G_INT_ENABLE(i)) < (s->g_timer.reg.tcon &
G_INT_ENABLE(i))) {
exynos4210_gcomp_lower_irq(&s->g_timer, i);
}
}
DPRINTF("global timer INT enable %llx\n", VAR_2);
s->g_timer.reg.int_enb = VAR_2;
break;
case G_WSTAT:
s->g_timer.reg.wstat &= ~(VAR_2);
break;
case G_COMP0_ADD_INCR: case G_COMP1_ADD_INCR:
case G_COMP2_ADD_INCR: case G_COMP3_ADD_INCR:
VAR_4 = GET_G_COMP_ADD_INCR_IDX(VAR_1);
s->g_timer.reg.comp_add_incr[VAR_4] = VAR_2;
s->g_timer.reg.wstat |= G_WSTAT_COMP_ADDINCR(VAR_4);
break;
case L0_TCON: case L1_TCON:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
old_val = s->l_timer[VAR_6].reg.tcon;
s->l_timer[VAR_6].reg.wstat |= L_WSTAT_TCON_WRITE;
s->l_timer[VAR_6].reg.tcon = VAR_2;
if ((VAR_2 & L_TCON_TICK_START) <
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] stop cnt\n", VAR_6);
exynos4210_ltick_cnt_stop(&s->l_timer[VAR_6].tick_timer);
}
if ((VAR_2 & L_TCON_INT_START) <
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] stop int\n", VAR_6);
exynos4210_ltick_int_stop(&s->l_timer[VAR_6].tick_timer);
}
if ((VAR_2 & L_TCON_TICK_START) >
(old_val & L_TCON_TICK_START)) {
DPRINTF("local timer[%d] start cnt\n", VAR_6);
exynos4210_ltick_cnt_start(&s->l_timer[VAR_6].tick_timer);
}
if ((VAR_2 & L_TCON_INT_START) >
(old_val & L_TCON_INT_START)) {
DPRINTF("local timer[%d] start int\n", VAR_6);
exynos4210_ltick_int_start(&s->l_timer[VAR_6].tick_timer);
}
if ((VAR_2 & L_TCON_FRC_START) >
(s->l_timer[VAR_6].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] start frc\n", VAR_6);
exynos4210_lfrc_start(&s->l_timer[VAR_6]);
}
if ((VAR_2 & L_TCON_FRC_START) <
(s->l_timer[VAR_6].reg.tcon & L_TCON_FRC_START)) {
DPRINTF("local timer[%d] stop frc\n", VAR_6);
exynos4210_lfrc_stop(&s->l_timer[VAR_6]);
}
break;
case L0_TCNTB: case L1_TCNTB:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);
exynos4210_ltick_set_cntb(&s->l_timer[VAR_6].tick_timer, VAR_2,
s->l_timer[VAR_6].tick_timer.icntb);
s->l_timer[VAR_6].reg.wstat |= L_WSTAT_TCNTB_WRITE;
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB] = VAR_2;
#ifdef DEBUG_MCT
if (tcntb_min[VAR_6] > VAR_2) {
tcntb_min[VAR_6] = VAR_2;
}
if (tcntb_max[VAR_6] < VAR_2) {
tcntb_max[VAR_6] = VAR_2;
}
DPRINTF("local timer[%d] TCNTB write %llx; max=%x, min=%x\n",
VAR_6, VAR_2, tcntb_max[VAR_6], tcntb_min[VAR_6]);
#endif
break;
case L0_ICNTB: case L1_ICNTB:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);
s->l_timer[VAR_6].reg.wstat |= L_WSTAT_ICNTB_WRITE;
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] = VAR_2 &
~L_ICNTB_MANUAL_UPDATE;
if (s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] *
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB] < MCT_LT_CNT_LOW_LIMIT) {
if (!s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB]) {
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT;
} else {
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] =
MCT_LT_CNT_LOW_LIMIT /
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB];
}
}
if (VAR_2 & L_ICNTB_MANUAL_UPDATE) {
exynos4210_ltick_set_cntb(&s->l_timer[VAR_6].tick_timer,
s->l_timer[VAR_6].tick_timer.tcntb,
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB]);
}
#ifdef DEBUG_MCT
if (icntb_min[VAR_6] > VAR_2) {
icntb_min[VAR_6] = VAR_2;
}
if (icntb_max[VAR_6] < VAR_2) {
icntb_max[VAR_6] = VAR_2;
}
DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n",
VAR_6, VAR_2, icntb_max[VAR_6], icntb_min[VAR_6]);
#endif
break;
case L0_FRCNTB: case L1_FRCNTB:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);
DPRINTF("local timer[%d] FRCNTB write %llx\n", VAR_6, VAR_2);
s->l_timer[VAR_6].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
s->l_timer[VAR_6].reg.cnt[L_REG_CNT_FRCCNTB] = VAR_2;
break;
case L0_TCNTO: case L1_TCNTO:
case L0_ICNTO: case L1_ICNTO:
case L0_FRCNTO: case L1_FRCNTO:
fprintf(stderr, "\n[exynos4210.mct: write to RO register "
TARGET_FMT_plx "]\n\n", VAR_1);
break;
case L0_INT_CSTAT: case L1_INT_CSTAT:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
DPRINTF("local timer[%d] CSTAT write %llx\n", VAR_6, VAR_2);
s->l_timer[VAR_6].reg.int_cstat &= ~VAR_2;
if (!s->l_timer[VAR_6].reg.int_cstat) {
qemu_irq_lower(s->l_timer[VAR_6].irq);
}
break;
case L0_INT_ENB: case L1_INT_ENB:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
old_val = s->l_timer[VAR_6].reg.int_enb;
if ((VAR_2 & L_INT_INTENB_ICNTEIE) > (old_val & L_INT_INTENB_ICNTEIE)) {
if (s->l_timer[VAR_6].reg.int_cstat & L_INT_CSTAT_INTCNT) {
qemu_irq_raise(s->l_timer[VAR_6].irq);
}
}
s->l_timer[VAR_6].reg.int_enb = VAR_2;
break;
case L0_WSTAT: case L1_WSTAT:
VAR_6 = GET_L_TIMER_IDX(VAR_1);
s->l_timer[VAR_6].reg.wstat &= ~VAR_2;
break;
default:
hw_error("exynos4210.mct: bad write VAR_1 "
TARGET_FMT_plx "\n", VAR_1);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"Exynos4210MCTState *s = (Exynos4210MCTState *)VAR_0;",
"int VAR_4;",
"int VAR_5;",
"int VAR_6;",
"uint64_t new_frc;",
"uint32_t i;",
"uint32_t old_val;",
"#ifdef DEBUG_MCT\nstatic uint32_t icntb_max[2] = {0};",
"static uint32_t icntb_min[2] = {UINT32_MAX, UINT32_MAX};",
"static uint32_t tcntb_max[2] = {0};",
"static uint32_t tcntb_min[2] = {UINT32_MAX, UINT32_MAX};",
"#endif\nnew_frc = s->g_timer.reg.cnt;",
"switch (VAR_1) {",
"case MCT_CFG:\ns->reg_mct_cfg = VAR_2;",
"exynos4210_mct_update_freq(s);",
"break;",
"case G_CNT_L:\ncase G_CNT_U:\nif (VAR_1 == G_CNT_L) {",
"DPRINTF(\"global timer write to reg.cntl %llx\\n\", VAR_2);",
"new_frc = (s->g_timer.reg.cnt & (uint64_t)UINT32_MAX << 32) + VAR_2;",
"s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_L;",
"}",
"if (VAR_1 == G_CNT_U) {",
"DPRINTF(\"global timer write to reg.cntu %llx\\n\", VAR_2);",
"new_frc = (s->g_timer.reg.cnt & UINT32_MAX) +\n((uint64_t)VAR_2 << 32);",
"s->g_timer.reg.cnt_wstat |= G_CNT_WSTAT_U;",
"}",
"s->g_timer.reg.cnt = new_frc;",
"exynos4210_gfrc_restart(s);",
"break;",
"case G_CNT_WSTAT:\ns->g_timer.reg.cnt_wstat &= ~(VAR_2);",
"break;",
"case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3):\ncase G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3):\nVAR_4 = GET_G_COMP_IDX(VAR_1);",
"VAR_5 = 8 * (VAR_1 & 0x4);",
"s->g_timer.reg.comp[VAR_4] =\n(s->g_timer.reg.comp[VAR_4] &\n(((uint64_t)UINT32_MAX << 32) >> VAR_5)) +\n(VAR_2 << VAR_5);",
"DPRINTF(\"comparator %d write 0x%llx val << %d\\n\", VAR_4, VAR_2, VAR_5);",
"if (VAR_1&0x4) {",
"s->g_timer.reg.wstat |= G_WSTAT_COMP_U(VAR_4);",
"} else {",
"s->g_timer.reg.wstat |= G_WSTAT_COMP_L(VAR_4);",
"}",
"exynos4210_gfrc_restart(s);",
"break;",
"case G_TCON:\nold_val = s->g_timer.reg.tcon;",
"s->g_timer.reg.tcon = VAR_2;",
"s->g_timer.reg.wstat |= G_WSTAT_TCON_WRITE;",
"DPRINTF(\"global timer write to reg.g_tcon %llx\\n\", VAR_2);",
"if ((VAR_2 & G_TCON_TIMER_ENABLE) > (old_val &\nG_TCON_TIMER_ENABLE)) {",
"exynos4210_gfrc_start(&s->g_timer);",
"}",
"if ((VAR_2 & G_TCON_TIMER_ENABLE) < (old_val &\nG_TCON_TIMER_ENABLE)) {",
"exynos4210_gfrc_stop(&s->g_timer);",
"}",
"for (i = 0; i < MCT_GT_CMP_NUM; i++) {",
"if ((VAR_2 & G_TCON_COMP_ENABLE(i)) != (old_val &\nG_TCON_COMP_ENABLE(i))) {",
"exynos4210_gfrc_restart(s);",
"}",
"}",
"break;",
"case G_INT_CSTAT:\ns->g_timer.reg.int_cstat &= ~(VAR_2);",
"for (i = 0; i < MCT_GT_CMP_NUM; i++) {",
"if (VAR_2 & G_INT_CSTAT_COMP(i)) {",
"exynos4210_gcomp_lower_irq(&s->g_timer, i);",
"}",
"}",
"break;",
"case G_INT_ENB:\nfor (i = 0; i < MCT_GT_CMP_NUM; i++) {",
"if ((VAR_2 & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon &\nG_INT_ENABLE(i))) {",
"if (s->g_timer.reg.int_cstat & G_INT_CSTAT_COMP(i)) {",
"exynos4210_gcomp_raise_irq(&s->g_timer, i);",
"}",
"}",
"if ((VAR_2 & G_INT_ENABLE(i)) < (s->g_timer.reg.tcon &\nG_INT_ENABLE(i))) {",
"exynos4210_gcomp_lower_irq(&s->g_timer, i);",
"}",
"}",
"DPRINTF(\"global timer INT enable %llx\\n\", VAR_2);",
"s->g_timer.reg.int_enb = VAR_2;",
"break;",
"case G_WSTAT:\ns->g_timer.reg.wstat &= ~(VAR_2);",
"break;",
"case G_COMP0_ADD_INCR: case G_COMP1_ADD_INCR:\ncase G_COMP2_ADD_INCR: case G_COMP3_ADD_INCR:\nVAR_4 = GET_G_COMP_ADD_INCR_IDX(VAR_1);",
"s->g_timer.reg.comp_add_incr[VAR_4] = VAR_2;",
"s->g_timer.reg.wstat |= G_WSTAT_COMP_ADDINCR(VAR_4);",
"break;",
"case L0_TCON: case L1_TCON:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"old_val = s->l_timer[VAR_6].reg.tcon;",
"s->l_timer[VAR_6].reg.wstat |= L_WSTAT_TCON_WRITE;",
"s->l_timer[VAR_6].reg.tcon = VAR_2;",
"if ((VAR_2 & L_TCON_TICK_START) <\n(old_val & L_TCON_TICK_START)) {",
"DPRINTF(\"local timer[%d] stop cnt\\n\", VAR_6);",
"exynos4210_ltick_cnt_stop(&s->l_timer[VAR_6].tick_timer);",
"}",
"if ((VAR_2 & L_TCON_INT_START) <\n(old_val & L_TCON_INT_START)) {",
"DPRINTF(\"local timer[%d] stop int\\n\", VAR_6);",
"exynos4210_ltick_int_stop(&s->l_timer[VAR_6].tick_timer);",
"}",
"if ((VAR_2 & L_TCON_TICK_START) >\n(old_val & L_TCON_TICK_START)) {",
"DPRINTF(\"local timer[%d] start cnt\\n\", VAR_6);",
"exynos4210_ltick_cnt_start(&s->l_timer[VAR_6].tick_timer);",
"}",
"if ((VAR_2 & L_TCON_INT_START) >\n(old_val & L_TCON_INT_START)) {",
"DPRINTF(\"local timer[%d] start int\\n\", VAR_6);",
"exynos4210_ltick_int_start(&s->l_timer[VAR_6].tick_timer);",
"}",
"if ((VAR_2 & L_TCON_FRC_START) >\n(s->l_timer[VAR_6].reg.tcon & L_TCON_FRC_START)) {",
"DPRINTF(\"local timer[%d] start frc\\n\", VAR_6);",
"exynos4210_lfrc_start(&s->l_timer[VAR_6]);",
"}",
"if ((VAR_2 & L_TCON_FRC_START) <\n(s->l_timer[VAR_6].reg.tcon & L_TCON_FRC_START)) {",
"DPRINTF(\"local timer[%d] stop frc\\n\", VAR_6);",
"exynos4210_lfrc_stop(&s->l_timer[VAR_6]);",
"}",
"break;",
"case L0_TCNTB: case L1_TCNTB:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);",
"exynos4210_ltick_set_cntb(&s->l_timer[VAR_6].tick_timer, VAR_2,\ns->l_timer[VAR_6].tick_timer.icntb);",
"s->l_timer[VAR_6].reg.wstat |= L_WSTAT_TCNTB_WRITE;",
"s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB] = VAR_2;",
"#ifdef DEBUG_MCT\nif (tcntb_min[VAR_6] > VAR_2) {",
"tcntb_min[VAR_6] = VAR_2;",
"}",
"if (tcntb_max[VAR_6] < VAR_2) {",
"tcntb_max[VAR_6] = VAR_2;",
"}",
"DPRINTF(\"local timer[%d] TCNTB write %llx; max=%x, min=%x\\n\",",
"VAR_6, VAR_2, tcntb_max[VAR_6], tcntb_min[VAR_6]);",
"#endif\nbreak;",
"case L0_ICNTB: case L1_ICNTB:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);",
"s->l_timer[VAR_6].reg.wstat |= L_WSTAT_ICNTB_WRITE;",
"s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] = VAR_2 &\n~L_ICNTB_MANUAL_UPDATE;",
"if (s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] *\ns->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB] < MCT_LT_CNT_LOW_LIMIT) {",
"if (!s->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB]) {",
"s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] =\nMCT_LT_CNT_LOW_LIMIT;",
"} else {",
"s->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB] =\nMCT_LT_CNT_LOW_LIMIT /\ns->l_timer[VAR_6].reg.cnt[L_REG_CNT_TCNTB];",
"}",
"}",
"if (VAR_2 & L_ICNTB_MANUAL_UPDATE) {",
"exynos4210_ltick_set_cntb(&s->l_timer[VAR_6].tick_timer,\ns->l_timer[VAR_6].tick_timer.tcntb,\ns->l_timer[VAR_6].reg.cnt[L_REG_CNT_ICNTB]);",
"}",
"#ifdef DEBUG_MCT\nif (icntb_min[VAR_6] > VAR_2) {",
"icntb_min[VAR_6] = VAR_2;",
"}",
"if (icntb_max[VAR_6] < VAR_2) {",
"icntb_max[VAR_6] = VAR_2;",
"}",
"DPRINTF(\"local timer[%d] ICNTB write %llx; max=%x, min=%x\\n\\n\",",
"VAR_6, VAR_2, icntb_max[VAR_6], icntb_min[VAR_6]);",
"#endif\nbreak;",
"case L0_FRCNTB: case L1_FRCNTB:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"VAR_4 = GET_L_TIMER_CNT_REG_IDX(VAR_1, VAR_6);",
"DPRINTF(\"local timer[%d] FRCNTB write %llx\\n\", VAR_6, VAR_2);",
"s->l_timer[VAR_6].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;",
"s->l_timer[VAR_6].reg.cnt[L_REG_CNT_FRCCNTB] = VAR_2;",
"break;",
"case L0_TCNTO: case L1_TCNTO:\ncase L0_ICNTO: case L1_ICNTO:\ncase L0_FRCNTO: case L1_FRCNTO:\nfprintf(stderr, \"\\n[exynos4210.mct: write to RO register \"\nTARGET_FMT_plx \"]\\n\\n\", VAR_1);",
"break;",
"case L0_INT_CSTAT: case L1_INT_CSTAT:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"DPRINTF(\"local timer[%d] CSTAT write %llx\\n\", VAR_6, VAR_2);",
"s->l_timer[VAR_6].reg.int_cstat &= ~VAR_2;",
"if (!s->l_timer[VAR_6].reg.int_cstat) {",
"qemu_irq_lower(s->l_timer[VAR_6].irq);",
"}",
"break;",
"case L0_INT_ENB: case L1_INT_ENB:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"old_val = s->l_timer[VAR_6].reg.int_enb;",
"if ((VAR_2 & L_INT_INTENB_ICNTEIE) > (old_val & L_INT_INTENB_ICNTEIE)) {",
"if (s->l_timer[VAR_6].reg.int_cstat & L_INT_CSTAT_INTCNT) {",
"qemu_irq_raise(s->l_timer[VAR_6].irq);",
"}",
"}",
"s->l_timer[VAR_6].reg.int_enb = VAR_2;",
"break;",
"case L0_WSTAT: case L1_WSTAT:\nVAR_6 = GET_L_TIMER_IDX(VAR_1);",
"s->l_timer[VAR_6].reg.wstat &= ~VAR_2;",
"break;",
"default:\nhw_error(\"exynos4210.mct: bad write VAR_1 \"\nTARGET_FMT_plx \"\\n\", VAR_1);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
39
],
[
43,
45
],
[
47
],
[
49
],
[
53,
55,
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
],
[
105,
107,
109
],
[
111
],
[
113,
115,
117,
119
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
145,
147
],
[
149
],
[
151
],
[
155
],
[
161,
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
215,
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253
],
[
257,
259
],
[
261
],
[
265,
267,
269
],
[
271
],
[
273
],
[
275
],
[
281,
283
],
[
285
],
[
289
],
[
291
],
[
297,
299
],
[
301
],
[
303
],
[
305
],
[
311,
313
],
[
315
],
[
317
],
[
319
],
[
325,
327
],
[
329
],
[
331
],
[
333
],
[
339,
341
],
[
343
],
[
345
],
[
347
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
363,
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377,
381
],
[
383
],
[
397,
399
],
[
403
],
[
405
],
[
409,
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427,
429
],
[
433,
437
],
[
439
],
[
443
],
[
445,
447
],
[
459,
461
],
[
463
],
[
465,
467
],
[
469
],
[
471,
473,
475
],
[
477
],
[
479
],
[
483
],
[
485,
487,
489
],
[
491
],
[
495,
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513,
515
],
[
519,
523
],
[
525
],
[
529
],
[
533
],
[
535
],
[
539
],
[
543,
545,
547,
549,
551
],
[
553
],
[
557,
559
],
[
563
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
579,
581
],
[
583
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
601
],
[
605
],
[
609,
611
],
[
615
],
[
617
],
[
621,
623,
625
],
[
627
],
[
629
],
[
631
]
] |
27,313 | static int no_init_in (HWVoiceIn *hw, audsettings_t *as)
{
audio_pcm_init_info (&hw->info, as);
hw->samples = 1024;
return 0;
}
| false | qemu | 1ea879e5580f63414693655fcf0328559cdce138 | static int no_init_in (HWVoiceIn *hw, audsettings_t *as)
{
audio_pcm_init_info (&hw->info, as);
hw->samples = 1024;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)
{
audio_pcm_init_info (&VAR_0->info, VAR_1);
VAR_0->samples = 1024;
return 0;
}
| [
"static int FUNC_0 (HWVoiceIn *VAR_0, audsettings_t *VAR_1)\n{",
"audio_pcm_init_info (&VAR_0->info, VAR_1);",
"VAR_0->samples = 1024;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
27,314 | uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)
{
uint64_t words[MAX_STFL_WORDS];
unsigned count_m1 = env->regs[0] & 0xff;
unsigned max_m1 = do_stfle(env, words);
unsigned i;
for (i = 0; i <= count_m1; ++i) {
cpu_stq_data(env, addr + 8 * i, words[i]);
}
env->regs[0] = deposit64(env->regs[0], 0, 8, max_m1);
return (count_m1 >= max_m1 ? 0 : 3);
}
| false | qemu | f74990a5d019751c545e9800a3376b6336e77d38 | uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)
{
uint64_t words[MAX_STFL_WORDS];
unsigned count_m1 = env->regs[0] & 0xff;
unsigned max_m1 = do_stfle(env, words);
unsigned i;
for (i = 0; i <= count_m1; ++i) {
cpu_stq_data(env, addr + 8 * i, words[i]);
}
env->regs[0] = deposit64(env->regs[0], 0, 8, max_m1);
return (count_m1 >= max_m1 ? 0 : 3);
}
| {
"code": [],
"line_no": []
} | uint32_t FUNC_0(stfle)(CPUS390XState *env, uint64_t addr)
{
uint64_t words[MAX_STFL_WORDS];
unsigned VAR_0 = env->regs[0] & 0xff;
unsigned VAR_1 = do_stfle(env, words);
unsigned VAR_2;
for (VAR_2 = 0; VAR_2 <= VAR_0; ++VAR_2) {
cpu_stq_data(env, addr + 8 * VAR_2, words[VAR_2]);
}
env->regs[0] = deposit64(env->regs[0], 0, 8, VAR_1);
return (VAR_0 >= VAR_1 ? 0 : 3);
}
| [
"uint32_t FUNC_0(stfle)(CPUS390XState *env, uint64_t addr)\n{",
"uint64_t words[MAX_STFL_WORDS];",
"unsigned VAR_0 = env->regs[0] & 0xff;",
"unsigned VAR_1 = do_stfle(env, words);",
"unsigned VAR_2;",
"for (VAR_2 = 0; VAR_2 <= VAR_0; ++VAR_2) {",
"cpu_stq_data(env, addr + 8 * VAR_2, words[VAR_2]);",
"}",
"env->regs[0] = deposit64(env->regs[0], 0, 8, VAR_1);",
"return (VAR_0 >= VAR_1 ? 0 : 3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
]
] |
27,315 | static void pxa2xx_fir_write(void *opaque, hwaddr addr,
uint64_t value64, unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint32_t value = value64;
uint8_t ch;
switch (addr) {
case ICCR0:
s->control[0] = value;
if (!(value & (1 << 4))) /* RXE */
s->rx_len = s->rx_start = 0;
if (!(value & (1 << 3))) { /* TXE */
/* Nop */
}
s->enable = value & 1; /* ITR */
if (!s->enable)
s->status[0] = 0;
pxa2xx_fir_update(s);
break;
case ICCR1:
s->control[1] = value;
break;
case ICCR2:
s->control[2] = value & 0x3f;
pxa2xx_fir_update(s);
break;
case ICDR:
if (s->control[2] & (1 << 2)) { /* TXP */
ch = value;
} else {
ch = ~value;
}
if (s->enable && (s->control[0] & (1 << 3))) { /* TXE */
/* XXX this blocks entire thread. Rewrite to use
* qemu_chr_fe_write and background I/O callbacks */
qemu_chr_fe_write_all(&s->chr, &ch, 1);
}
break;
case ICSR0:
s->status[0] &= ~(value & 0x66);
pxa2xx_fir_update(s);
break;
case ICFOR:
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
}
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void pxa2xx_fir_write(void *opaque, hwaddr addr,
uint64_t value64, unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint32_t value = value64;
uint8_t ch;
switch (addr) {
case ICCR0:
s->control[0] = value;
if (!(value & (1 << 4)))
s->rx_len = s->rx_start = 0;
if (!(value & (1 << 3))) {
}
s->enable = value & 1;
if (!s->enable)
s->status[0] = 0;
pxa2xx_fir_update(s);
break;
case ICCR1:
s->control[1] = value;
break;
case ICCR2:
s->control[2] = value & 0x3f;
pxa2xx_fir_update(s);
break;
case ICDR:
if (s->control[2] & (1 << 2)) {
ch = value;
} else {
ch = ~value;
}
if (s->enable && (s->control[0] & (1 << 3))) {
qemu_chr_fe_write_all(&s->chr, &ch, 1);
}
break;
case ICSR0:
s->status[0] &= ~(value & 0x66);
pxa2xx_fir_update(s);
break;
case ICFOR:
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) VAR_0;
uint32_t value = VAR_2;
uint8_t ch;
switch (VAR_1) {
case ICCR0:
s->control[0] = value;
if (!(value & (1 << 4)))
s->rx_len = s->rx_start = 0;
if (!(value & (1 << 3))) {
}
s->enable = value & 1;
if (!s->enable)
s->status[0] = 0;
pxa2xx_fir_update(s);
break;
case ICCR1:
s->control[1] = value;
break;
case ICCR2:
s->control[2] = value & 0x3f;
pxa2xx_fir_update(s);
break;
case ICDR:
if (s->control[2] & (1 << 2)) {
ch = value;
} else {
ch = ~value;
}
if (s->enable && (s->control[0] & (1 << 3))) {
qemu_chr_fe_write_all(&s->chr, &ch, 1);
}
break;
case ICSR0:
s->status[0] &= ~(value & 0x66);
pxa2xx_fir_update(s);
break;
case ICFOR:
break;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, VAR_1);
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"PXA2xxFIrState *s = (PXA2xxFIrState *) VAR_0;",
"uint32_t value = VAR_2;",
"uint8_t ch;",
"switch (VAR_1) {",
"case ICCR0:\ns->control[0] = value;",
"if (!(value & (1 << 4)))\ns->rx_len = s->rx_start = 0;",
"if (!(value & (1 << 3))) {",
"}",
"s->enable = value & 1;",
"if (!s->enable)\ns->status[0] = 0;",
"pxa2xx_fir_update(s);",
"break;",
"case ICCR1:\ns->control[1] = value;",
"break;",
"case ICCR2:\ns->control[2] = value & 0x3f;",
"pxa2xx_fir_update(s);",
"break;",
"case ICDR:\nif (s->control[2] & (1 << 2)) {",
"ch = value;",
"} else {",
"ch = ~value;",
"}",
"if (s->enable && (s->control[0] & (1 << 3))) {",
"qemu_chr_fe_write_all(&s->chr, &ch, 1);",
"}",
"break;",
"case ICSR0:\ns->status[0] &= ~(value & 0x66);",
"pxa2xx_fir_update(s);",
"break;",
"case ICFOR:\nbreak;",
"default:\nprintf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21,
23
],
[
25
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
97
]
] |
27,316 | static void disas_thumb_insn(CPUARMState *env, DisasContext *s)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int i;
TCGv_i32 tmp;
TCGv_i32 tmp2;
TCGv_i32 addr;
if (s->condexec_mask) {
cond = s->condexec_cond;
if (cond != 0x0e) { /* Skip conditional when condition is AL. */
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
}
insn = arm_lduw_code(env, s->pc, s->bswap_code);
s->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
/* add/subtract */
rn = (insn >> 3) & 7;
tmp = load_reg(s, rn);
if (insn & (1 << 10)) {
/* immediate */
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
/* reg */
rm = (insn >> 6) & 7;
tmp2 = load_reg(s, rm);
}
if (insn & (1 << 9)) {
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
} else {
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
/* shift immediate */
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(s, rm);
gen_arm_shift_im(tmp, op, shift, s->condexec_mask == 0);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
}
break;
case 2: case 3:
/* arithmetic large immediate */
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) { /* mov */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1: /* cmp */
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2: /* add */
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3: /* sub */
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
/* load pc-relative. Bit 1 of PC is ignored. */
val = s->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp);
break;
}
if (insn & (1 << 10)) {
/* data processing extended or blx */
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0: /* add */
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1: /* cmp */
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2: /* mov/cpy */
tmp = load_reg(s, rm);
store_reg(s, rd, tmp);
break;
case 3:/* branch [and link] exchange thumb register */
tmp = load_reg(s, rm);
if (insn & (1 << 7)) {
ARCH(5);
val = (uint32_t)s->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(s, 14, tmp2);
}
/* already thumb, no need to check */
gen_bx(s, tmp);
break;
}
break;
}
/* data processing register */
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
/* the shift/rotate ops want the operands backwards */
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) { /* neg */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) { /* mvn doesn't read its first operand */
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED_I32(tmp);
}
tmp2 = load_reg(s, rm);
switch (op) {
case 0x0: /* and */
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1: /* eor */
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2: /* lsl */
if (s->condexec_mask) {
gen_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3: /* lsr */
if (s->condexec_mask) {
gen_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4: /* asr */
if (s->condexec_mask) {
gen_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5: /* adc */
if (s->condexec_mask) {
gen_adc(tmp, tmp2);
} else {
gen_adc_CC(tmp, tmp, tmp2);
}
break;
case 0x6: /* sbc */
if (s->condexec_mask) {
gen_sub_carry(tmp, tmp, tmp2);
} else {
gen_sbc_CC(tmp, tmp, tmp2);
}
break;
case 0x7: /* ror */
if (s->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8: /* tst */
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9: /* neg */
if (s->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
break;
case 0xa: /* cmp */
gen_sub_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb: /* cmn */
gen_add_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc: /* orr */
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd: /* mul */
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe: /* bic */
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf: /* mvn */
tcg_gen_not_i32(tmp2, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(s, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
/* load/store register offset. */
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3) { /* store */
tmp = load_reg(s, rd);
} else {
tmp = tcg_temp_new_i32();
}
switch (op) {
case 0: /* str */
gen_aa32_st32(tmp, addr, IS_USER(s));
break;
case 1: /* strh */
gen_aa32_st16(tmp, addr, IS_USER(s));
break;
case 2: /* strb */
gen_aa32_st8(tmp, addr, IS_USER(s));
break;
case 3: /* ldrsb */
gen_aa32_ld8s(tmp, addr, IS_USER(s));
break;
case 4: /* ldr */
gen_aa32_ld32u(tmp, addr, IS_USER(s));
break;
case 5: /* ldrh */
gen_aa32_ld16u(tmp, addr, IS_USER(s));
break;
case 6: /* ldrb */
gen_aa32_ld8u(tmp, addr, IS_USER(s));
break;
case 7: /* ldrsh */
gen_aa32_ld16s(tmp, addr, IS_USER(s));
break;
}
if (op >= 3) { /* load */
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 6:
/* load/store word immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 7:
/* load/store byte immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_aa32_st8(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 8:
/* load/store halfword immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = tcg_temp_new_i32();
gen_aa32_ld16u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_aa32_st16(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 9:
/* load/store from stack */
rd = (insn >> 8) & 7;
addr = load_reg(s, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 10:
/* add to high reg */
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
/* SP */
tmp = load_reg(s, 13);
} else {
/* PC. bit 1 is ignored. */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, rd, tmp);
break;
case 11:
/* misc */
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
/* adjust stack pointer */
tmp = load_reg(s, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, 13, tmp);
break;
case 2: /* sign/zero extend. */
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(s, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(s, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
/* push/pop */
addr = load_reg(s, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (i = 0; i < 8; i++) {
if (insn & (1 << i))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
/* pop */
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
/* push */
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
/* advance to the next address. */
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED_I32(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
/* pop pc */
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
/* don't set the pc until the rest of the instruction
has completed */
} else {
/* push lr */
tmp = load_reg(s, 14);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
/* write back the new stack pointer */
store_reg(s, 13, addr);
/* set the new PC value */
if ((insn & 0x0900) == 0x0900) {
store_reg_from_load(env, s, 15, tmp);
}
break;
case 1: case 3: case 9: case 11: /* czb */
rm = insn & 7;
tmp = load_reg(s, rm);
s->condlabel = gen_new_label();
s->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, s->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)s->pc + 2;
val += offset;
gen_jmp(s, val);
break;
case 15: /* IT, nop-hint. */
if ((insn & 0xf) == 0) {
gen_nop_hint(s, (insn >> 4) & 0xf);
break;
}
/* If Then. */
s->condexec_cond = (insn >> 4) & 0xe;
s->condexec_mask = insn & 0x1f;
/* No actual code generated for this insn, just setup state. */
break;
case 0xe: /* bkpt */
ARCH(5);
gen_exception_insn(s, 2, EXCP_BKPT);
break;
case 0xa: /* rev */
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(s, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(s, rd, tmp);
break;
case 6:
switch ((insn >> 5) & 7) {
case 2:
/* setend */
ARCH(6);
if (((insn >> 3) & 1) != s->bswap_code) {
/* Dynamic endianness switching not implemented. */
qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n");
goto illegal_op;
}
break;
case 3:
/* cps */
ARCH(6);
if (IS_USER(s)) {
break;
}
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* FAULTMASK */
if (insn & 1) {
addr = tcg_const_i32(19);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
/* PRIMASK */
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
} else {
if (insn & (1 << 4)) {
shift = CPSR_A | CPSR_I | CPSR_F;
} else {
shift = 0;
}
gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
default:
goto undef;
}
break;
case 12:
{
/* load/store multiple */
TCGv_i32 loaded_var;
TCGV_UNUSED_I32(loaded_var);
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
/* load */
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
if (i == rn) {
loaded_var = tmp;
} else {
store_reg(s, i, tmp);
}
} else {
/* store */
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
/* advance to the next address */
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
/* base reg not in list: base register writeback */
store_reg(s, rn, addr);
} else {
/* base reg in list: if load, complete it now */
if (insn & (1 << 11)) {
store_reg(s, rn, loaded_var);
}
tcg_temp_free_i32(addr);
}
break;
}
case 13:
/* conditional branch or swi */
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
/* swi */
gen_set_pc_im(s, s->pc);
s->is_jmp = DISAS_SWI;
break;
}
/* generate a conditional jump to next instruction */
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
/* jump to the offset */
val = (uint32_t)s->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(s, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
/* unconditional branch */
val = (uint32_t)s->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(s, val);
break;
case 15:
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(s, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(s, 2, EXCP_UDEF);
}
| false | qemu | 39fb730aed8c5f7b0058845cb9feac0d4b177985 | static void disas_thumb_insn(CPUARMState *env, DisasContext *s)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int i;
TCGv_i32 tmp;
TCGv_i32 tmp2;
TCGv_i32 addr;
if (s->condexec_mask) {
cond = s->condexec_cond;
if (cond != 0x0e) {
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
}
insn = arm_lduw_code(env, s->pc, s->bswap_code);
s->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
rn = (insn >> 3) & 7;
tmp = load_reg(s, rn);
if (insn & (1 << 10)) {
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
rm = (insn >> 6) & 7;
tmp2 = load_reg(s, rm);
}
if (insn & (1 << 9)) {
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
} else {
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(s, rm);
gen_arm_shift_im(tmp, op, shift, s->condexec_mask == 0);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
}
break;
case 2: case 3:
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1:
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2:
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3:
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
val = s->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp);
break;
}
if (insn & (1 << 10)) {
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1:
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2:
tmp = load_reg(s, rm);
store_reg(s, rd, tmp);
break;
case 3:
tmp = load_reg(s, rm);
if (insn & (1 << 7)) {
ARCH(5);
val = (uint32_t)s->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(s, 14, tmp2);
}
gen_bx(s, tmp);
break;
}
break;
}
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) {
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED_I32(tmp);
}
tmp2 = load_reg(s, rm);
switch (op) {
case 0x0:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2:
if (s->condexec_mask) {
gen_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3:
if (s->condexec_mask) {
gen_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4:
if (s->condexec_mask) {
gen_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5:
if (s->condexec_mask) {
gen_adc(tmp, tmp2);
} else {
gen_adc_CC(tmp, tmp, tmp2);
}
break;
case 0x6:
if (s->condexec_mask) {
gen_sub_carry(tmp, tmp, tmp2);
} else {
gen_sbc_CC(tmp, tmp, tmp2);
}
break;
case 0x7:
if (s->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8:
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9:
if (s->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
break;
case 0xa:
gen_sub_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb:
gen_add_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd:
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf:
tcg_gen_not_i32(tmp2, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(s, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3) {
tmp = load_reg(s, rd);
} else {
tmp = tcg_temp_new_i32();
}
switch (op) {
case 0:
gen_aa32_st32(tmp, addr, IS_USER(s));
break;
case 1:
gen_aa32_st16(tmp, addr, IS_USER(s));
break;
case 2:
gen_aa32_st8(tmp, addr, IS_USER(s));
break;
case 3:
gen_aa32_ld8s(tmp, addr, IS_USER(s));
break;
case 4:
gen_aa32_ld32u(tmp, addr, IS_USER(s));
break;
case 5:
gen_aa32_ld16u(tmp, addr, IS_USER(s));
break;
case 6:
gen_aa32_ld8u(tmp, addr, IS_USER(s));
break;
case 7:
gen_aa32_ld16s(tmp, addr, IS_USER(s));
break;
}
if (op >= 3) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 6:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 7:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st8(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 8:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld16u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st16(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 9:
rd = (insn >> 8) & 7;
addr = load_reg(s, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 10:
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
tmp = load_reg(s, 13);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, rd, tmp);
break;
case 11:
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
tmp = load_reg(s, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, 13, tmp);
break;
case 2:
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(s, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(s, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
addr = load_reg(s, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (i = 0; i < 8; i++) {
if (insn & (1 << i))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED_I32(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
} else {
tmp = load_reg(s, 14);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
store_reg(s, 13, addr);
if ((insn & 0x0900) == 0x0900) {
store_reg_from_load(env, s, 15, tmp);
}
break;
case 1: case 3: case 9: case 11:
rm = insn & 7;
tmp = load_reg(s, rm);
s->condlabel = gen_new_label();
s->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, s->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)s->pc + 2;
val += offset;
gen_jmp(s, val);
break;
case 15:
if ((insn & 0xf) == 0) {
gen_nop_hint(s, (insn >> 4) & 0xf);
break;
}
s->condexec_cond = (insn >> 4) & 0xe;
s->condexec_mask = insn & 0x1f;
break;
case 0xe:
ARCH(5);
gen_exception_insn(s, 2, EXCP_BKPT);
break;
case 0xa:
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(s, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(s, rd, tmp);
break;
case 6:
switch ((insn >> 5) & 7) {
case 2:
ARCH(6);
if (((insn >> 3) & 1) != s->bswap_code) {
qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n");
goto illegal_op;
}
break;
case 3:
ARCH(6);
if (IS_USER(s)) {
break;
}
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
if (insn & 1) {
addr = tcg_const_i32(19);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
} else {
if (insn & (1 << 4)) {
shift = CPSR_A | CPSR_I | CPSR_F;
} else {
shift = 0;
}
gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
default:
goto undef;
}
break;
case 12:
{
TCGv_i32 loaded_var;
TCGV_UNUSED_I32(loaded_var);
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(s));
if (i == rn) {
loaded_var = tmp;
} else {
store_reg(s, i, tmp);
}
} else {
tmp = load_reg(s, i);
gen_aa32_st32(tmp, addr, IS_USER(s));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
store_reg(s, rn, addr);
} else {
if (insn & (1 << 11)) {
store_reg(s, rn, loaded_var);
}
tcg_temp_free_i32(addr);
}
break;
}
case 13:
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
gen_set_pc_im(s, s->pc);
s->is_jmp = DISAS_SWI;
break;
}
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
val = (uint32_t)s->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(s, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
val = (uint32_t)s->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(s, val);
break;
case 15:
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(s, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(s, 2, EXCP_UDEF);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUARMState *VAR_0, DisasContext *VAR_1)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int VAR_2;
TCGv_i32 tmp;
TCGv_i32 tmp2;
TCGv_i32 addr;
if (VAR_1->condexec_mask) {
cond = VAR_1->condexec_cond;
if (cond != 0x0e) {
VAR_1->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, VAR_1->condlabel);
VAR_1->condjmp = 1;
}
}
insn = arm_lduw_code(VAR_0, VAR_1->pc, VAR_1->bswap_code);
VAR_1->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
rn = (insn >> 3) & 7;
tmp = load_reg(VAR_1, rn);
if (insn & (1 << 10)) {
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
rm = (insn >> 6) & 7;
tmp2 = load_reg(VAR_1, rm);
}
if (insn & (1 << 9)) {
if (VAR_1->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
} else {
if (VAR_1->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(VAR_1, rd, tmp);
} else {
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(VAR_1, rm);
gen_arm_shift_im(tmp, op, shift, VAR_1->condexec_mask == 0);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
store_reg(VAR_1, rd, tmp);
}
break;
case 2: case 3:
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1:
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2:
if (VAR_1->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_add_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(VAR_1, rd, tmp);
break;
case 3:
if (VAR_1->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(VAR_1, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
val = VAR_1->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(addr);
store_reg(VAR_1, rd, tmp);
break;
}
if (insn & (1 << 10)) {
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0:
tmp = load_reg(VAR_1, rd);
tmp2 = load_reg(VAR_1, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(VAR_1, rd, tmp);
break;
case 1:
tmp = load_reg(VAR_1, rd);
tmp2 = load_reg(VAR_1, rm);
gen_sub_CC(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2:
tmp = load_reg(VAR_1, rm);
store_reg(VAR_1, rd, tmp);
break;
case 3:
tmp = load_reg(VAR_1, rm);
if (insn & (1 << 7)) {
ARCH(5);
val = (uint32_t)VAR_1->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(VAR_1, 14, tmp2);
}
gen_bx(VAR_1, tmp);
break;
}
break;
}
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) {
tmp = load_reg(VAR_1, rd);
} else {
TCGV_UNUSED_I32(tmp);
}
tmp2 = load_reg(VAR_1, rm);
switch (op) {
case 0x0:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2:
if (VAR_1->condexec_mask) {
gen_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3:
if (VAR_1->condexec_mask) {
gen_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4:
if (VAR_1->condexec_mask) {
gen_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5:
if (VAR_1->condexec_mask) {
gen_adc(tmp, tmp2);
} else {
gen_adc_CC(tmp, tmp, tmp2);
}
break;
case 0x6:
if (VAR_1->condexec_mask) {
gen_sub_carry(tmp, tmp, tmp2);
} else {
gen_sbc_CC(tmp, tmp, tmp2);
}
break;
case 0x7:
if (VAR_1->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, cpu_env, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8:
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9:
if (VAR_1->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_sub_CC(tmp, tmp, tmp2);
break;
case 0xa:
gen_sub_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb:
gen_add_CC(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd:
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf:
tcg_gen_not_i32(tmp2, tmp2);
if (!VAR_1->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(VAR_1, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(VAR_1, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(VAR_1, rn);
tmp = load_reg(VAR_1, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3) {
tmp = load_reg(VAR_1, rd);
} else {
tmp = tcg_temp_new_i32();
}
switch (op) {
case 0:
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
break;
case 1:
gen_aa32_st16(tmp, addr, IS_USER(VAR_1));
break;
case 2:
gen_aa32_st8(tmp, addr, IS_USER(VAR_1));
break;
case 3:
gen_aa32_ld8s(tmp, addr, IS_USER(VAR_1));
break;
case 4:
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
break;
case 5:
gen_aa32_ld16u(tmp, addr, IS_USER(VAR_1));
break;
case 6:
gen_aa32_ld8u(tmp, addr, IS_USER(VAR_1));
break;
case 7:
gen_aa32_ld16s(tmp, addr, IS_USER(VAR_1));
break;
}
if (op >= 3) {
store_reg(VAR_1, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 6:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(VAR_1, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 7:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(VAR_1, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld8u(tmp, addr, IS_USER(VAR_1));
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
gen_aa32_st8(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 8:
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(VAR_1, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld16u(tmp, addr, IS_USER(VAR_1));
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
gen_aa32_st16(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 9:
rd = (insn >> 8) & 7;
addr = load_reg(VAR_1, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
store_reg(VAR_1, rd, tmp);
} else {
tmp = load_reg(VAR_1, rd);
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_temp_free_i32(addr);
break;
case 10:
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
tmp = load_reg(VAR_1, 13);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (VAR_1->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(VAR_1, rd, tmp);
break;
case 11:
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
tmp = load_reg(VAR_1, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(VAR_1, 13, tmp);
break;
case 2:
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(VAR_1, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(VAR_1, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
addr = load_reg(VAR_1, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {
if (insn & (1 << VAR_2))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {
if (insn & (1 << VAR_2)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
store_reg(VAR_1, VAR_2, tmp);
} else {
tmp = load_reg(VAR_1, VAR_2);
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED_I32(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
} else {
tmp = load_reg(VAR_1, 14);
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
store_reg(VAR_1, 13, addr);
if ((insn & 0x0900) == 0x0900) {
store_reg_from_load(VAR_0, VAR_1, 15, tmp);
}
break;
case 1: case 3: case 9: case 11:
rm = insn & 7;
tmp = load_reg(VAR_1, rm);
VAR_1->condlabel = gen_new_label();
VAR_1->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, VAR_1->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, VAR_1->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)VAR_1->pc + 2;
val += offset;
gen_jmp(VAR_1, val);
break;
case 15:
if ((insn & 0xf) == 0) {
gen_nop_hint(VAR_1, (insn >> 4) & 0xf);
break;
}
VAR_1->condexec_cond = (insn >> 4) & 0xe;
VAR_1->condexec_mask = insn & 0x1f;
break;
case 0xe:
ARCH(5);
gen_exception_insn(VAR_1, 2, EXCP_BKPT);
break;
case 0xa:
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(VAR_1, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(VAR_1, rd, tmp);
break;
case 6:
switch ((insn >> 5) & 7) {
case 2:
ARCH(6);
if (((insn >> 3) & 1) != VAR_1->bswap_code) {
qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n");
goto illegal_op;
}
break;
case 3:
ARCH(6);
if (IS_USER(VAR_1)) {
break;
}
if (IS_M(VAR_0)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
if (insn & 1) {
addr = tcg_const_i32(19);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(VAR_1);
} else {
if (insn & (1 << 4)) {
shift = CPSR_A | CPSR_I | CPSR_F;
} else {
shift = 0;
}
gen_set_psr_im(VAR_1, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
default:
goto undef;
}
break;
case 12:
{
TCGv_i32 loaded_var;
TCGV_UNUSED_I32(loaded_var);
rn = (insn >> 8) & 0x7;
addr = load_reg(VAR_1, rn);
for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {
if (insn & (1 << VAR_2)) {
if (insn & (1 << 11)) {
tmp = tcg_temp_new_i32();
gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));
if (VAR_2 == rn) {
loaded_var = tmp;
} else {
store_reg(VAR_1, VAR_2, tmp);
}
} else {
tmp = load_reg(VAR_1, VAR_2);
gen_aa32_st32(tmp, addr, IS_USER(VAR_1));
tcg_temp_free_i32(tmp);
}
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
store_reg(VAR_1, rn, addr);
} else {
if (insn & (1 << 11)) {
store_reg(VAR_1, rn, loaded_var);
}
tcg_temp_free_i32(addr);
}
break;
}
case 13:
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
gen_set_pc_im(VAR_1, VAR_1->pc);
VAR_1->is_jmp = DISAS_SWI;
break;
}
VAR_1->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, VAR_1->condlabel);
VAR_1->condjmp = 1;
val = (uint32_t)VAR_1->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(VAR_1, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(VAR_0, VAR_1, insn))
goto undef32;
break;
}
val = (uint32_t)VAR_1->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(VAR_1, val);
break;
case 15:
if (disas_thumb2_insn(VAR_0, VAR_1, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(VAR_1, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(VAR_1, 2, EXCP_UDEF);
}
| [
"static void FUNC_0(CPUARMState *VAR_0, DisasContext *VAR_1)\n{",
"uint32_t val, insn, op, rm, rn, rd, shift, cond;",
"int32_t offset;",
"int VAR_2;",
"TCGv_i32 tmp;",
"TCGv_i32 tmp2;",
"TCGv_i32 addr;",
"if (VAR_1->condexec_mask) {",
"cond = VAR_1->condexec_cond;",
"if (cond != 0x0e) {",
"VAR_1->condlabel = gen_new_label();",
"gen_test_cc(cond ^ 1, VAR_1->condlabel);",
"VAR_1->condjmp = 1;",
"}",
"}",
"insn = arm_lduw_code(VAR_0, VAR_1->pc, VAR_1->bswap_code);",
"VAR_1->pc += 2;",
"switch (insn >> 12) {",
"case 0: case 1:\nrd = insn & 7;",
"op = (insn >> 11) & 3;",
"if (op == 3) {",
"rn = (insn >> 3) & 7;",
"tmp = load_reg(VAR_1, rn);",
"if (insn & (1 << 10)) {",
"tmp2 = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);",
"} else {",
"rm = (insn >> 6) & 7;",
"tmp2 = load_reg(VAR_1, rm);",
"}",
"if (insn & (1 << 9)) {",
"if (VAR_1->condexec_mask)\ntcg_gen_sub_i32(tmp, tmp, tmp2);",
"else\ngen_sub_CC(tmp, tmp, tmp2);",
"} else {",
"if (VAR_1->condexec_mask)\ntcg_gen_add_i32(tmp, tmp, tmp2);",
"else\ngen_add_CC(tmp, tmp, tmp2);",
"}",
"tcg_temp_free_i32(tmp2);",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"rm = (insn >> 3) & 7;",
"shift = (insn >> 6) & 0x1f;",
"tmp = load_reg(VAR_1, rm);",
"gen_arm_shift_im(tmp, op, shift, VAR_1->condexec_mask == 0);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"store_reg(VAR_1, rd, tmp);",
"}",
"break;",
"case 2: case 3:\nop = (insn >> 11) & 3;",
"rd = (insn >> 8) & 0x7;",
"if (op == 0) {",
"tmp = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp, insn & 0xff);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"tmp2 = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp2, insn & 0xff);",
"switch (op) {",
"case 1:\ngen_sub_CC(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp);",
"tcg_temp_free_i32(tmp2);",
"break;",
"case 2:\nif (VAR_1->condexec_mask)\ntcg_gen_add_i32(tmp, tmp, tmp2);",
"else\ngen_add_CC(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 3:\nif (VAR_1->condexec_mask)\ntcg_gen_sub_i32(tmp, tmp, tmp2);",
"else\ngen_sub_CC(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"}",
"}",
"break;",
"case 4:\nif (insn & (1 << 11)) {",
"rd = (insn >> 8) & 7;",
"val = VAR_1->pc + 2 + ((insn & 0xff) * 4);",
"val &= ~(uint32_t)2;",
"addr = tcg_temp_new_i32();",
"tcg_gen_movi_i32(addr, val);",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(addr);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"}",
"if (insn & (1 << 10)) {",
"rd = (insn & 7) | ((insn >> 4) & 8);",
"rm = (insn >> 3) & 0xf;",
"op = (insn >> 8) & 3;",
"switch (op) {",
"case 0:\ntmp = load_reg(VAR_1, rd);",
"tmp2 = load_reg(VAR_1, rm);",
"tcg_gen_add_i32(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 1:\ntmp = load_reg(VAR_1, rd);",
"tmp2 = load_reg(VAR_1, rm);",
"gen_sub_CC(tmp, tmp, tmp2);",
"tcg_temp_free_i32(tmp2);",
"tcg_temp_free_i32(tmp);",
"break;",
"case 2:\ntmp = load_reg(VAR_1, rm);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 3:\ntmp = load_reg(VAR_1, rm);",
"if (insn & (1 << 7)) {",
"ARCH(5);",
"val = (uint32_t)VAR_1->pc | 1;",
"tmp2 = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp2, val);",
"store_reg(VAR_1, 14, tmp2);",
"}",
"gen_bx(VAR_1, tmp);",
"break;",
"}",
"break;",
"}",
"rd = insn & 7;",
"rm = (insn >> 3) & 7;",
"op = (insn >> 6) & 0xf;",
"if (op == 2 || op == 3 || op == 4 || op == 7) {",
"val = rm;",
"rm = rd;",
"rd = val;",
"val = 1;",
"} else {",
"val = 0;",
"}",
"if (op == 9) {",
"tmp = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp, 0);",
"} else if (op != 0xf) {",
"tmp = load_reg(VAR_1, rd);",
"} else {",
"TCGV_UNUSED_I32(tmp);",
"}",
"tmp2 = load_reg(VAR_1, rm);",
"switch (op) {",
"case 0x0:\ntcg_gen_and_i32(tmp, tmp, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"break;",
"case 0x1:\ntcg_gen_xor_i32(tmp, tmp, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"break;",
"case 0x2:\nif (VAR_1->condexec_mask) {",
"gen_shl(tmp2, tmp2, tmp);",
"} else {",
"gen_helper_shl_cc(tmp2, cpu_env, tmp2, tmp);",
"gen_logic_CC(tmp2);",
"}",
"break;",
"case 0x3:\nif (VAR_1->condexec_mask) {",
"gen_shr(tmp2, tmp2, tmp);",
"} else {",
"gen_helper_shr_cc(tmp2, cpu_env, tmp2, tmp);",
"gen_logic_CC(tmp2);",
"}",
"break;",
"case 0x4:\nif (VAR_1->condexec_mask) {",
"gen_sar(tmp2, tmp2, tmp);",
"} else {",
"gen_helper_sar_cc(tmp2, cpu_env, tmp2, tmp);",
"gen_logic_CC(tmp2);",
"}",
"break;",
"case 0x5:\nif (VAR_1->condexec_mask) {",
"gen_adc(tmp, tmp2);",
"} else {",
"gen_adc_CC(tmp, tmp, tmp2);",
"}",
"break;",
"case 0x6:\nif (VAR_1->condexec_mask) {",
"gen_sub_carry(tmp, tmp, tmp2);",
"} else {",
"gen_sbc_CC(tmp, tmp, tmp2);",
"}",
"break;",
"case 0x7:\nif (VAR_1->condexec_mask) {",
"tcg_gen_andi_i32(tmp, tmp, 0x1f);",
"tcg_gen_rotr_i32(tmp2, tmp2, tmp);",
"} else {",
"gen_helper_ror_cc(tmp2, cpu_env, tmp2, tmp);",
"gen_logic_CC(tmp2);",
"}",
"break;",
"case 0x8:\ntcg_gen_and_i32(tmp, tmp, tmp2);",
"gen_logic_CC(tmp);",
"rd = 16;",
"break;",
"case 0x9:\nif (VAR_1->condexec_mask)\ntcg_gen_neg_i32(tmp, tmp2);",
"else\ngen_sub_CC(tmp, tmp, tmp2);",
"break;",
"case 0xa:\ngen_sub_CC(tmp, tmp, tmp2);",
"rd = 16;",
"break;",
"case 0xb:\ngen_add_CC(tmp, tmp, tmp2);",
"rd = 16;",
"break;",
"case 0xc:\ntcg_gen_or_i32(tmp, tmp, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"break;",
"case 0xd:\ntcg_gen_mul_i32(tmp, tmp, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"break;",
"case 0xe:\ntcg_gen_andc_i32(tmp, tmp, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp);",
"break;",
"case 0xf:\ntcg_gen_not_i32(tmp2, tmp2);",
"if (!VAR_1->condexec_mask)\ngen_logic_CC(tmp2);",
"val = 1;",
"rm = rd;",
"break;",
"}",
"if (rd != 16) {",
"if (val) {",
"store_reg(VAR_1, rm, tmp2);",
"if (op != 0xf)\ntcg_temp_free_i32(tmp);",
"} else {",
"store_reg(VAR_1, rd, tmp);",
"tcg_temp_free_i32(tmp2);",
"}",
"} else {",
"tcg_temp_free_i32(tmp);",
"tcg_temp_free_i32(tmp2);",
"}",
"break;",
"case 5:\nrd = insn & 7;",
"rn = (insn >> 3) & 7;",
"rm = (insn >> 6) & 7;",
"op = (insn >> 9) & 7;",
"addr = load_reg(VAR_1, rn);",
"tmp = load_reg(VAR_1, rm);",
"tcg_gen_add_i32(addr, addr, tmp);",
"tcg_temp_free_i32(tmp);",
"if (op < 3) {",
"tmp = load_reg(VAR_1, rd);",
"} else {",
"tmp = tcg_temp_new_i32();",
"}",
"switch (op) {",
"case 0:\ngen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 1:\ngen_aa32_st16(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 2:\ngen_aa32_st8(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 3:\ngen_aa32_ld8s(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 4:\ngen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 5:\ngen_aa32_ld16u(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 6:\ngen_aa32_ld8u(tmp, addr, IS_USER(VAR_1));",
"break;",
"case 7:\ngen_aa32_ld16s(tmp, addr, IS_USER(VAR_1));",
"break;",
"}",
"if (op >= 3) {",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_temp_free_i32(addr);",
"break;",
"case 6:\nrd = insn & 7;",
"rn = (insn >> 3) & 7;",
"addr = load_reg(VAR_1, rn);",
"val = (insn >> 4) & 0x7c;",
"tcg_gen_addi_i32(addr, addr, val);",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"gen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_temp_free_i32(addr);",
"break;",
"case 7:\nrd = insn & 7;",
"rn = (insn >> 3) & 7;",
"addr = load_reg(VAR_1, rn);",
"val = (insn >> 6) & 0x1f;",
"tcg_gen_addi_i32(addr, addr, val);",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld8u(tmp, addr, IS_USER(VAR_1));",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"gen_aa32_st8(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_temp_free_i32(addr);",
"break;",
"case 8:\nrd = insn & 7;",
"rn = (insn >> 3) & 7;",
"addr = load_reg(VAR_1, rn);",
"val = (insn >> 5) & 0x3e;",
"tcg_gen_addi_i32(addr, addr, val);",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld16u(tmp, addr, IS_USER(VAR_1));",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"gen_aa32_st16(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_temp_free_i32(addr);",
"break;",
"case 9:\nrd = (insn >> 8) & 7;",
"addr = load_reg(VAR_1, 13);",
"val = (insn & 0xff) * 4;",
"tcg_gen_addi_i32(addr, addr, val);",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"store_reg(VAR_1, rd, tmp);",
"} else {",
"tmp = load_reg(VAR_1, rd);",
"gen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_temp_free_i32(addr);",
"break;",
"case 10:\nrd = (insn >> 8) & 7;",
"if (insn & (1 << 11)) {",
"tmp = load_reg(VAR_1, 13);",
"} else {",
"tmp = tcg_temp_new_i32();",
"tcg_gen_movi_i32(tmp, (VAR_1->pc + 2) & ~(uint32_t)2);",
"}",
"val = (insn & 0xff) * 4;",
"tcg_gen_addi_i32(tmp, tmp, val);",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 11:\nop = (insn >> 8) & 0xf;",
"switch (op) {",
"case 0:\ntmp = load_reg(VAR_1, 13);",
"val = (insn & 0x7f) * 4;",
"if (insn & (1 << 7))\nval = -(int32_t)val;",
"tcg_gen_addi_i32(tmp, tmp, val);",
"store_reg(VAR_1, 13, tmp);",
"break;",
"case 2:\nARCH(6);",
"rd = insn & 7;",
"rm = (insn >> 3) & 7;",
"tmp = load_reg(VAR_1, rm);",
"switch ((insn >> 6) & 3) {",
"case 0: gen_sxth(tmp); break;",
"case 1: gen_sxtb(tmp); break;",
"case 2: gen_uxth(tmp); break;",
"case 3: gen_uxtb(tmp); break;",
"}",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 4: case 5: case 0xc: case 0xd:\naddr = load_reg(VAR_1, 13);",
"if (insn & (1 << 8))\noffset = 4;",
"else\noffset = 0;",
"for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {",
"if (insn & (1 << VAR_2))\noffset += 4;",
"}",
"if ((insn & (1 << 11)) == 0) {",
"tcg_gen_addi_i32(addr, addr, -offset);",
"}",
"for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {",
"if (insn & (1 << VAR_2)) {",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"store_reg(VAR_1, VAR_2, tmp);",
"} else {",
"tmp = load_reg(VAR_1, VAR_2);",
"gen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_gen_addi_i32(addr, addr, 4);",
"}",
"}",
"TCGV_UNUSED_I32(tmp);",
"if (insn & (1 << 8)) {",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"} else {",
"tmp = load_reg(VAR_1, 14);",
"gen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_gen_addi_i32(addr, addr, 4);",
"}",
"if ((insn & (1 << 11)) == 0) {",
"tcg_gen_addi_i32(addr, addr, -offset);",
"}",
"store_reg(VAR_1, 13, addr);",
"if ((insn & 0x0900) == 0x0900) {",
"store_reg_from_load(VAR_0, VAR_1, 15, tmp);",
"}",
"break;",
"case 1: case 3: case 9: case 11:\nrm = insn & 7;",
"tmp = load_reg(VAR_1, rm);",
"VAR_1->condlabel = gen_new_label();",
"VAR_1->condjmp = 1;",
"if (insn & (1 << 11))\ntcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, VAR_1->condlabel);",
"else\ntcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, VAR_1->condlabel);",
"tcg_temp_free_i32(tmp);",
"offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;",
"val = (uint32_t)VAR_1->pc + 2;",
"val += offset;",
"gen_jmp(VAR_1, val);",
"break;",
"case 15:\nif ((insn & 0xf) == 0) {",
"gen_nop_hint(VAR_1, (insn >> 4) & 0xf);",
"break;",
"}",
"VAR_1->condexec_cond = (insn >> 4) & 0xe;",
"VAR_1->condexec_mask = insn & 0x1f;",
"break;",
"case 0xe:\nARCH(5);",
"gen_exception_insn(VAR_1, 2, EXCP_BKPT);",
"break;",
"case 0xa:\nARCH(6);",
"rn = (insn >> 3) & 0x7;",
"rd = insn & 0x7;",
"tmp = load_reg(VAR_1, rn);",
"switch ((insn >> 6) & 3) {",
"case 0: tcg_gen_bswap32_i32(tmp, tmp); break;",
"case 1: gen_rev16(tmp); break;",
"case 3: gen_revsh(tmp); break;",
"default: goto illegal_op;",
"}",
"store_reg(VAR_1, rd, tmp);",
"break;",
"case 6:\nswitch ((insn >> 5) & 7) {",
"case 2:\nARCH(6);",
"if (((insn >> 3) & 1) != VAR_1->bswap_code) {",
"qemu_log_mask(LOG_UNIMP, \"arm: unimplemented setend\\n\");",
"goto illegal_op;",
"}",
"break;",
"case 3:\nARCH(6);",
"if (IS_USER(VAR_1)) {",
"break;",
"}",
"if (IS_M(VAR_0)) {",
"tmp = tcg_const_i32((insn & (1 << 4)) != 0);",
"if (insn & 1) {",
"addr = tcg_const_i32(19);",
"gen_helper_v7m_msr(cpu_env, addr, tmp);",
"tcg_temp_free_i32(addr);",
"}",
"if (insn & 2) {",
"addr = tcg_const_i32(16);",
"gen_helper_v7m_msr(cpu_env, addr, tmp);",
"tcg_temp_free_i32(addr);",
"}",
"tcg_temp_free_i32(tmp);",
"gen_lookup_tb(VAR_1);",
"} else {",
"if (insn & (1 << 4)) {",
"shift = CPSR_A | CPSR_I | CPSR_F;",
"} else {",
"shift = 0;",
"}",
"gen_set_psr_im(VAR_1, ((insn & 7) << 6), 0, shift);",
"}",
"break;",
"default:\ngoto undef;",
"}",
"break;",
"default:\ngoto undef;",
"}",
"break;",
"case 12:\n{",
"TCGv_i32 loaded_var;",
"TCGV_UNUSED_I32(loaded_var);",
"rn = (insn >> 8) & 0x7;",
"addr = load_reg(VAR_1, rn);",
"for (VAR_2 = 0; VAR_2 < 8; VAR_2++) {",
"if (insn & (1 << VAR_2)) {",
"if (insn & (1 << 11)) {",
"tmp = tcg_temp_new_i32();",
"gen_aa32_ld32u(tmp, addr, IS_USER(VAR_1));",
"if (VAR_2 == rn) {",
"loaded_var = tmp;",
"} else {",
"store_reg(VAR_1, VAR_2, tmp);",
"}",
"} else {",
"tmp = load_reg(VAR_1, VAR_2);",
"gen_aa32_st32(tmp, addr, IS_USER(VAR_1));",
"tcg_temp_free_i32(tmp);",
"}",
"tcg_gen_addi_i32(addr, addr, 4);",
"}",
"}",
"if ((insn & (1 << rn)) == 0) {",
"store_reg(VAR_1, rn, addr);",
"} else {",
"if (insn & (1 << 11)) {",
"store_reg(VAR_1, rn, loaded_var);",
"}",
"tcg_temp_free_i32(addr);",
"}",
"break;",
"}",
"case 13:\ncond = (insn >> 8) & 0xf;",
"if (cond == 0xe)\ngoto undef;",
"if (cond == 0xf) {",
"gen_set_pc_im(VAR_1, VAR_1->pc);",
"VAR_1->is_jmp = DISAS_SWI;",
"break;",
"}",
"VAR_1->condlabel = gen_new_label();",
"gen_test_cc(cond ^ 1, VAR_1->condlabel);",
"VAR_1->condjmp = 1;",
"val = (uint32_t)VAR_1->pc + 2;",
"offset = ((int32_t)insn << 24) >> 24;",
"val += offset << 1;",
"gen_jmp(VAR_1, val);",
"break;",
"case 14:\nif (insn & (1 << 11)) {",
"if (disas_thumb2_insn(VAR_0, VAR_1, insn))\ngoto undef32;",
"break;",
"}",
"val = (uint32_t)VAR_1->pc;",
"offset = ((int32_t)insn << 21) >> 21;",
"val += (offset << 1) + 2;",
"gen_jmp(VAR_1, val);",
"break;",
"case 15:\nif (disas_thumb2_insn(VAR_0, VAR_1, insn))\ngoto undef32;",
"break;",
"}",
"return;",
"undef32:\ngen_exception_insn(VAR_1, 4, EXCP_UDEF);",
"return;",
"illegal_op:\nundef:\ngen_exception_insn(VAR_1, 2, EXCP_UDEF);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
45,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
165
],
[
167,
169,
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183,
185,
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
315
],
[
317
],
[
319
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
359
],
[
361
],
[
363,
365
],
[
367,
369
],
[
371
],
[
373,
375
],
[
377,
379
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399,
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431,
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445,
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459,
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485
],
[
487,
489,
491
],
[
493,
495
],
[
497
],
[
499,
501
],
[
503
],
[
505
],
[
507,
509
],
[
511
],
[
513
],
[
515,
517
],
[
519,
521
],
[
523
],
[
525,
527
],
[
529,
531
],
[
533
],
[
535,
537
],
[
539,
541
],
[
543
],
[
545,
547
],
[
549,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563
],
[
565
],
[
567,
569
],
[
571
],
[
573
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
587
],
[
591,
595
],
[
597
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
625
],
[
627,
629
],
[
631
],
[
633,
635
],
[
637
],
[
639,
641
],
[
643
],
[
645,
647
],
[
649
],
[
651,
653
],
[
655
],
[
657,
659
],
[
661
],
[
663,
665
],
[
667
],
[
669,
671
],
[
673
],
[
675
],
[
677
],
[
679
],
[
681
],
[
683
],
[
685
],
[
687
],
[
689
],
[
693,
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
709
],
[
713
],
[
715
],
[
717
],
[
719
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
737,
741
],
[
743
],
[
745
],
[
747
],
[
749
],
[
753
],
[
757
],
[
759
],
[
761
],
[
763
],
[
767
],
[
769
],
[
771
],
[
773
],
[
775
],
[
777
],
[
781,
785
],
[
787
],
[
789
],
[
791
],
[
793
],
[
797
],
[
801
],
[
803
],
[
805
],
[
807
],
[
811
],
[
813
],
[
815
],
[
817
],
[
819
],
[
821
],
[
825,
829
],
[
831
],
[
833
],
[
835
],
[
839
],
[
843
],
[
845
],
[
847
],
[
849
],
[
853
],
[
855
],
[
857
],
[
859
],
[
861
],
[
863
],
[
867,
871
],
[
873
],
[
877
],
[
879
],
[
883
],
[
885
],
[
887
],
[
889
],
[
891
],
[
893
],
[
895
],
[
899,
903
],
[
905
],
[
907,
911
],
[
913
],
[
915,
917
],
[
919
],
[
921
],
[
923
],
[
927,
929
],
[
931
],
[
933
],
[
935
],
[
937
],
[
939
],
[
941
],
[
943
],
[
945
],
[
947
],
[
949
],
[
951
],
[
953,
957
],
[
959,
961
],
[
963,
965
],
[
967
],
[
969,
971
],
[
973
],
[
975
],
[
977
],
[
979
],
[
981
],
[
983
],
[
985
],
[
989
],
[
991
],
[
993
],
[
995
],
[
999
],
[
1001
],
[
1003
],
[
1005
],
[
1009
],
[
1011
],
[
1013
],
[
1015
],
[
1017
],
[
1019
],
[
1023
],
[
1025
],
[
1031
],
[
1035
],
[
1037
],
[
1039
],
[
1041
],
[
1043
],
[
1045
],
[
1047
],
[
1049
],
[
1051
],
[
1055
],
[
1059
],
[
1061
],
[
1063
],
[
1065
],
[
1069,
1071
],
[
1073
],
[
1075
],
[
1077
],
[
1079,
1081
],
[
1083,
1085
],
[
1087
],
[
1089
],
[
1091
],
[
1093
],
[
1095
],
[
1097
],
[
1101,
1103
],
[
1105
],
[
1107
],
[
1109
],
[
1113
],
[
1115
],
[
1119
],
[
1123,
1125
],
[
1127
],
[
1129
],
[
1133,
1135
],
[
1137
],
[
1139
],
[
1141
],
[
1143
],
[
1145
],
[
1147
],
[
1149
],
[
1151
],
[
1153
],
[
1155
],
[
1157
],
[
1161,
1163
],
[
1165,
1169
],
[
1171
],
[
1175
],
[
1177
],
[
1179
],
[
1181
],
[
1183,
1187
],
[
1189
],
[
1191
],
[
1193
],
[
1195
],
[
1197
],
[
1201
],
[
1203
],
[
1205
],
[
1207
],
[
1209
],
[
1213
],
[
1215
],
[
1217
],
[
1219
],
[
1221
],
[
1223
],
[
1225
],
[
1227
],
[
1229
],
[
1231
],
[
1233
],
[
1235
],
[
1237
],
[
1239
],
[
1241
],
[
1243
],
[
1245,
1247
],
[
1249
],
[
1251
],
[
1255,
1257
],
[
1259
],
[
1261
],
[
1265,
1267
],
[
1271
],
[
1273
],
[
1275
],
[
1277
],
[
1279
],
[
1281
],
[
1283
],
[
1287
],
[
1289
],
[
1291
],
[
1293
],
[
1295
],
[
1297
],
[
1299
],
[
1301
],
[
1305
],
[
1307
],
[
1309
],
[
1311
],
[
1315
],
[
1317
],
[
1319
],
[
1321
],
[
1325
],
[
1327
],
[
1331
],
[
1333
],
[
1335
],
[
1337
],
[
1339
],
[
1341
],
[
1343
],
[
1345,
1349
],
[
1351,
1353
],
[
1357
],
[
1361
],
[
1363
],
[
1365
],
[
1367
],
[
1371
],
[
1373
],
[
1375
],
[
1381
],
[
1383
],
[
1385
],
[
1387
],
[
1389
],
[
1393,
1395
],
[
1397,
1399
],
[
1401
],
[
1403
],
[
1407
],
[
1409
],
[
1411
],
[
1413
],
[
1415
],
[
1419,
1421,
1423
],
[
1425
],
[
1427
],
[
1429
],
[
1431,
1433
],
[
1435
],
[
1437,
1439,
1441
],
[
1443
]
] |