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
|
---|---|---|---|---|---|---|---|---|---|---|
1,835 | static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
AVDictionary *opts, AVDictionary *opts2)
{
HLSContext *c = s->priv_data;
AVDictionary *tmp = NULL;
const char *proto_name = avio_find_protocol_name(url);
int ret;
av_dict_copy(&tmp, opts, 0);
av_dict_copy(&tmp, opts2, 0);
if (!proto_name)
return AVERROR_INVALIDDATA;
// only http(s) & file are allowed
if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))
return AVERROR_INVALIDDATA;
if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')
;
else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
return AVERROR_INVALIDDATA;
ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
if (ret >= 0) {
// update cookies on http response with setcookies.
void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
update_options(&c->cookies, "cookies", u);
av_dict_set(&opts, "cookies", c->cookies, 0);
}
av_dict_free(&tmp);
return ret;
}
| false | FFmpeg | eae2d89bf715bc3edff478174b43e1f388e768bf | static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
AVDictionary *opts, AVDictionary *opts2)
{
HLSContext *c = s->priv_data;
AVDictionary *tmp = NULL;
const char *proto_name = avio_find_protocol_name(url);
int ret;
av_dict_copy(&tmp, opts, 0);
av_dict_copy(&tmp, opts2, 0);
if (!proto_name)
return AVERROR_INVALIDDATA;
if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))
return AVERROR_INVALIDDATA;
if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')
;
else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
return AVERROR_INVALIDDATA;
ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
if (ret >= 0) {
void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
update_options(&c->cookies, "cookies", u);
av_dict_set(&opts, "cookies", c->cookies, 0);
}
av_dict_free(&tmp);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2,
AVDictionary *VAR_3, AVDictionary *VAR_4)
{
HLSContext *c = VAR_0->priv_data;
AVDictionary *tmp = NULL;
const char *VAR_5 = avio_find_protocol_name(VAR_2);
int VAR_6;
av_dict_copy(&tmp, VAR_3, 0);
av_dict_copy(&tmp, VAR_4, 0);
if (!VAR_5)
return AVERROR_INVALIDDATA;
if (!av_strstart(VAR_5, "http", NULL) && !av_strstart(VAR_5, "file", NULL))
return AVERROR_INVALIDDATA;
if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')
;
else if (strcmp(VAR_5, "file") || !strncmp(VAR_2, "file,", 5))
return AVERROR_INVALIDDATA;
VAR_6 = VAR_0->io_open(VAR_0, VAR_1, VAR_2, AVIO_FLAG_READ, &tmp);
if (VAR_6 >= 0) {
void *VAR_7 = (VAR_0->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : VAR_0->VAR_1;
update_options(&c->cookies, "cookies", VAR_7);
av_dict_set(&VAR_3, "cookies", c->cookies, 0);
}
av_dict_free(&tmp);
return VAR_6;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2,\nAVDictionary *VAR_3, AVDictionary *VAR_4)\n{",
"HLSContext *c = VAR_0->priv_data;",
"AVDictionary *tmp = NULL;",
"const char *VAR_5 = avio_find_protocol_name(VAR_2);",
"int VAR_6;",
"av_dict_copy(&tmp, VAR_3, 0);",
"av_dict_copy(&tmp, VAR_4, 0);",
"if (!VAR_5)\nreturn AVERROR_INVALIDDATA;",
"if (!av_strstart(VAR_5, \"http\", NULL) && !av_strstart(VAR_5, \"file\", NULL))\nreturn AVERROR_INVALIDDATA;",
"if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')\n;",
"else if (strcmp(VAR_5, \"file\") || !strncmp(VAR_2, \"file,\", 5))\nreturn AVERROR_INVALIDDATA;",
"VAR_6 = VAR_0->io_open(VAR_0, VAR_1, VAR_2, AVIO_FLAG_READ, &tmp);",
"if (VAR_6 >= 0) {",
"void *VAR_7 = (VAR_0->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : VAR_0->VAR_1;",
"update_options(&c->cookies, \"cookies\", VAR_7);",
"av_dict_set(&VAR_3, \"cookies\", c->cookies, 0);",
"}",
"av_dict_free(&tmp);",
"return VAR_6;",
"}"
] | [
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
],
[
23,
25
],
[
31,
33
],
[
35,
37
],
[
39,
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
]
] |
1,837 | static int nvdec_mpeg12_end_frame(AVCodecContext *avctx)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
int ret = ff_nvdec_end_frame(avctx);
ctx->bitstream = NULL;
return ret;
}
| false | FFmpeg | 4c7b023d56e09a78a587d036db1b64bf7c493b3d | static int nvdec_mpeg12_end_frame(AVCodecContext *avctx)
{
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
int ret = ff_nvdec_end_frame(avctx);
ctx->bitstream = NULL;
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0)
{
NVDECContext *ctx = VAR_0->internal->hwaccel_priv_data;
int VAR_1 = ff_nvdec_end_frame(VAR_0);
ctx->bitstream = NULL;
return VAR_1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"NVDECContext *ctx = VAR_0->internal->hwaccel_priv_data;",
"int VAR_1 = ff_nvdec_end_frame(VAR_0);",
"ctx->bitstream = NULL;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,838 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUX86State *env)
{
abi_ulong frame_addr, addr;
struct rt_sigframe *frame;
int i, err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(current_exec_domain_sig(sig), &frame->sig);
addr = frame_addr + offsetof(struct rt_sigframe, info);
__put_user(addr, &frame->pinfo);
addr = frame_addr + offsetof(struct rt_sigframe, uc);
__put_user(addr, &frame->puc);
err |= copy_siginfo_to_user(&frame->info, info);
if (err)
goto give_sigsegv;
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
err |= setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate,
env, set->sig[0],
frame_addr + offsetof(struct rt_sigframe, fpstate));
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]))
goto give_sigsegv;
}
/* Set up to return from userspace. If provided, use a stub
already in userspace. */
if (ka->sa_flags & TARGET_SA_RESTORER) {
__put_user(ka->sa_restorer, &frame->pretcode);
} else {
uint16_t val16;
addr = frame_addr + offsetof(struct rt_sigframe, retcode);
__put_user(addr, &frame->pretcode);
/* This is movl $,%eax ; int $0x80 */
__put_user(0xb8, (char *)(frame->retcode+0));
__put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1));
val16 = 0x80cd;
__put_user(val16, (uint16_t *)(frame->retcode+5));
}
if (err)
goto give_sigsegv;
/* Set up registers for signal handler */
env->regs[R_ESP] = frame_addr;
env->eip = ka->_sa_handler;
cpu_x86_load_seg(env, R_DS, __USER_DS);
cpu_x86_load_seg(env, R_ES, __USER_DS);
cpu_x86_load_seg(env, R_SS, __USER_DS);
cpu_x86_load_seg(env, R_CS, __USER_CS);
env->eflags &= ~TF_MASK;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
if (sig == TARGET_SIGSEGV)
ka->_sa_handler = TARGET_SIG_DFL;
force_sig(TARGET_SIGSEGV /* , current */);
}
| false | qemu | b0fd8d18683f0d77a8e6b482771ebea82234d727 | static void setup_rt_frame(int sig, struct target_sigaction *ka,
target_siginfo_t *info,
target_sigset_t *set, CPUX86State *env)
{
abi_ulong frame_addr, addr;
struct rt_sigframe *frame;
int i, err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(current_exec_domain_sig(sig), &frame->sig);
addr = frame_addr + offsetof(struct rt_sigframe, info);
__put_user(addr, &frame->pinfo);
addr = frame_addr + offsetof(struct rt_sigframe, uc);
__put_user(addr, &frame->puc);
err |= copy_siginfo_to_user(&frame->info, info);
if (err)
goto give_sigsegv;
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
err |= setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate,
env, set->sig[0],
frame_addr + offsetof(struct rt_sigframe, fpstate));
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]))
goto give_sigsegv;
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
__put_user(ka->sa_restorer, &frame->pretcode);
} else {
uint16_t val16;
addr = frame_addr + offsetof(struct rt_sigframe, retcode);
__put_user(addr, &frame->pretcode);
__put_user(0xb8, (char *)(frame->retcode+0));
__put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1));
val16 = 0x80cd;
__put_user(val16, (uint16_t *)(frame->retcode+5));
}
if (err)
goto give_sigsegv;
env->regs[R_ESP] = frame_addr;
env->eip = ka->_sa_handler;
cpu_x86_load_seg(env, R_DS, __USER_DS);
cpu_x86_load_seg(env, R_ES, __USER_DS);
cpu_x86_load_seg(env, R_SS, __USER_DS);
cpu_x86_load_seg(env, R_CS, __USER_CS);
env->eflags &= ~TF_MASK;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
if (sig == TARGET_SIGSEGV)
ka->_sa_handler = TARGET_SIG_DFL;
force_sig(TARGET_SIGSEGV );
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_siginfo_t *VAR_2,
target_sigset_t *VAR_3, CPUX86State *VAR_4)
{
abi_ulong frame_addr, addr;
struct rt_sigframe *VAR_5;
int VAR_6, VAR_7 = 0;
frame_addr = get_sigframe(VAR_1, VAR_4, sizeof(*VAR_5));
if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0))
goto give_sigsegv;
__put_user(current_exec_domain_sig(VAR_0), &VAR_5->VAR_0);
addr = frame_addr + offsetof(struct rt_sigframe, VAR_2);
__put_user(addr, &VAR_5->pinfo);
addr = frame_addr + offsetof(struct rt_sigframe, uc);
__put_user(addr, &VAR_5->puc);
VAR_7 |= copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2);
if (VAR_7)
goto give_sigsegv;
__put_user(0, &VAR_5->uc.tuc_flags);
__put_user(0, &VAR_5->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp, &VAR_5->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(VAR_4)),
&VAR_5->uc.tuc_stack.ss_flags);
__put_user(target_sigaltstack_used.ss_size,
&VAR_5->uc.tuc_stack.ss_size);
VAR_7 |= setup_sigcontext(&VAR_5->uc.tuc_mcontext, &VAR_5->fpstate,
VAR_4, VAR_3->VAR_0[0],
frame_addr + offsetof(struct rt_sigframe, fpstate));
for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {
if (__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6]))
goto give_sigsegv;
}
if (VAR_1->sa_flags & TARGET_SA_RESTORER) {
__put_user(VAR_1->sa_restorer, &VAR_5->pretcode);
} else {
uint16_t val16;
addr = frame_addr + offsetof(struct rt_sigframe, retcode);
__put_user(addr, &VAR_5->pretcode);
__put_user(0xb8, (char *)(VAR_5->retcode+0));
__put_user(TARGET_NR_rt_sigreturn, (int *)(VAR_5->retcode+1));
val16 = 0x80cd;
__put_user(val16, (uint16_t *)(VAR_5->retcode+5));
}
if (VAR_7)
goto give_sigsegv;
VAR_4->regs[R_ESP] = frame_addr;
VAR_4->eip = VAR_1->_sa_handler;
cpu_x86_load_seg(VAR_4, R_DS, __USER_DS);
cpu_x86_load_seg(VAR_4, R_ES, __USER_DS);
cpu_x86_load_seg(VAR_4, R_SS, __USER_DS);
cpu_x86_load_seg(VAR_4, R_CS, __USER_CS);
VAR_4->eflags &= ~TF_MASK;
unlock_user_struct(VAR_5, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(VAR_5, frame_addr, 1);
if (VAR_0 == TARGET_SIGSEGV)
VAR_1->_sa_handler = TARGET_SIG_DFL;
force_sig(TARGET_SIGSEGV );
}
| [
"static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_siginfo_t *VAR_2,\ntarget_sigset_t *VAR_3, CPUX86State *VAR_4)\n{",
"abi_ulong frame_addr, addr;",
"struct rt_sigframe *VAR_5;",
"int VAR_6, VAR_7 = 0;",
"frame_addr = get_sigframe(VAR_1, VAR_4, sizeof(*VAR_5));",
"if (!lock_user_struct(VERIFY_WRITE, VAR_5, frame_addr, 0))\ngoto give_sigsegv;",
"__put_user(current_exec_domain_sig(VAR_0), &VAR_5->VAR_0);",
"addr = frame_addr + offsetof(struct rt_sigframe, VAR_2);",
"__put_user(addr, &VAR_5->pinfo);",
"addr = frame_addr + offsetof(struct rt_sigframe, uc);",
"__put_user(addr, &VAR_5->puc);",
"VAR_7 |= copy_siginfo_to_user(&VAR_5->VAR_2, VAR_2);",
"if (VAR_7)\ngoto give_sigsegv;",
"__put_user(0, &VAR_5->uc.tuc_flags);",
"__put_user(0, &VAR_5->uc.tuc_link);",
"__put_user(target_sigaltstack_used.ss_sp, &VAR_5->uc.tuc_stack.ss_sp);",
"__put_user(sas_ss_flags(get_sp_from_cpustate(VAR_4)),\n&VAR_5->uc.tuc_stack.ss_flags);",
"__put_user(target_sigaltstack_used.ss_size,\n&VAR_5->uc.tuc_stack.ss_size);",
"VAR_7 |= setup_sigcontext(&VAR_5->uc.tuc_mcontext, &VAR_5->fpstate,\nVAR_4, VAR_3->VAR_0[0],\nframe_addr + offsetof(struct rt_sigframe, fpstate));",
"for(VAR_6 = 0; VAR_6 < TARGET_NSIG_WORDS; VAR_6++) {",
"if (__put_user(VAR_3->VAR_0[VAR_6], &VAR_5->uc.tuc_sigmask.VAR_0[VAR_6]))\ngoto give_sigsegv;",
"}",
"if (VAR_1->sa_flags & TARGET_SA_RESTORER) {",
"__put_user(VAR_1->sa_restorer, &VAR_5->pretcode);",
"} else {",
"uint16_t val16;",
"addr = frame_addr + offsetof(struct rt_sigframe, retcode);",
"__put_user(addr, &VAR_5->pretcode);",
"__put_user(0xb8, (char *)(VAR_5->retcode+0));",
"__put_user(TARGET_NR_rt_sigreturn, (int *)(VAR_5->retcode+1));",
"val16 = 0x80cd;",
"__put_user(val16, (uint16_t *)(VAR_5->retcode+5));",
"}",
"if (VAR_7)\ngoto give_sigsegv;",
"VAR_4->regs[R_ESP] = frame_addr;",
"VAR_4->eip = VAR_1->_sa_handler;",
"cpu_x86_load_seg(VAR_4, R_DS, __USER_DS);",
"cpu_x86_load_seg(VAR_4, R_ES, __USER_DS);",
"cpu_x86_load_seg(VAR_4, R_SS, __USER_DS);",
"cpu_x86_load_seg(VAR_4, R_CS, __USER_CS);",
"VAR_4->eflags &= ~TF_MASK;",
"unlock_user_struct(VAR_5, frame_addr, 1);",
"return;",
"give_sigsegv:\nunlock_user_struct(VAR_5, frame_addr, 1);",
"if (VAR_0 == TARGET_SIGSEGV)\nVAR_1->_sa_handler = TARGET_SIG_DFL;",
"force_sig(TARGET_SIGSEGV );",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61,
63,
65
],
[
67
],
[
69,
71
],
[
73
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
137
],
[
141,
143
],
[
145,
147
],
[
149
],
[
151
]
] |
1,839 | static void pci_qdev_realize(DeviceState *qdev, Error **errp)
{
PCIDevice *pci_dev = (PCIDevice *)qdev;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
Error *local_err = NULL;
PCIBus *bus;
bool is_default_rom;
/* initialize cap_present for pci_is_express() and pci_config_size() */
if (pc->is_express) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
bus = PCI_BUS(qdev_get_parent_bus(qdev));
pci_dev = do_pci_register_device(pci_dev, bus,
object_get_typename(OBJECT(qdev)),
pci_dev->devfn, errp);
if (pci_dev == NULL)
return;
if (pc->realize) {
pc->realize(pci_dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
do_pci_unregister_device(pci_dev);
return;
}
}
/* rom loading */
is_default_rom = false;
if (pci_dev->romfile == NULL && pc->romfile != NULL) {
pci_dev->romfile = g_strdup(pc->romfile);
is_default_rom = true;
}
pci_add_option_rom(pci_dev, is_default_rom, &local_err);
if (local_err) {
error_propagate(errp, local_err);
pci_qdev_unrealize(DEVICE(pci_dev), NULL);
return;
}
}
| false | qemu | fd56e0612b6454a282fa6a953fdb09281a98c589 | static void pci_qdev_realize(DeviceState *qdev, Error **errp)
{
PCIDevice *pci_dev = (PCIDevice *)qdev;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
Error *local_err = NULL;
PCIBus *bus;
bool is_default_rom;
if (pc->is_express) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
bus = PCI_BUS(qdev_get_parent_bus(qdev));
pci_dev = do_pci_register_device(pci_dev, bus,
object_get_typename(OBJECT(qdev)),
pci_dev->devfn, errp);
if (pci_dev == NULL)
return;
if (pc->realize) {
pc->realize(pci_dev, &local_err);
if (local_err) {
error_propagate(errp, local_err);
do_pci_unregister_device(pci_dev);
return;
}
}
is_default_rom = false;
if (pci_dev->romfile == NULL && pc->romfile != NULL) {
pci_dev->romfile = g_strdup(pc->romfile);
is_default_rom = true;
}
pci_add_option_rom(pci_dev, is_default_rom, &local_err);
if (local_err) {
error_propagate(errp, local_err);
pci_qdev_unrealize(DEVICE(pci_dev), NULL);
return;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
PCIDevice *pci_dev = (PCIDevice *)VAR_0;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
Error *local_err = NULL;
PCIBus *bus;
bool is_default_rom;
if (pc->is_express) {
pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
}
bus = PCI_BUS(qdev_get_parent_bus(VAR_0));
pci_dev = do_pci_register_device(pci_dev, bus,
object_get_typename(OBJECT(VAR_0)),
pci_dev->devfn, VAR_1);
if (pci_dev == NULL)
return;
if (pc->realize) {
pc->realize(pci_dev, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
do_pci_unregister_device(pci_dev);
return;
}
}
is_default_rom = false;
if (pci_dev->romfile == NULL && pc->romfile != NULL) {
pci_dev->romfile = g_strdup(pc->romfile);
is_default_rom = true;
}
pci_add_option_rom(pci_dev, is_default_rom, &local_err);
if (local_err) {
error_propagate(VAR_1, local_err);
pci_qdev_unrealize(DEVICE(pci_dev), NULL);
return;
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"PCIDevice *pci_dev = (PCIDevice *)VAR_0;",
"PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);",
"Error *local_err = NULL;",
"PCIBus *bus;",
"bool is_default_rom;",
"if (pc->is_express) {",
"pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;",
"}",
"bus = PCI_BUS(qdev_get_parent_bus(VAR_0));",
"pci_dev = do_pci_register_device(pci_dev, bus,\nobject_get_typename(OBJECT(VAR_0)),\npci_dev->devfn, VAR_1);",
"if (pci_dev == NULL)\nreturn;",
"if (pc->realize) {",
"pc->realize(pci_dev, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"do_pci_unregister_device(pci_dev);",
"return;",
"}",
"}",
"is_default_rom = false;",
"if (pci_dev->romfile == NULL && pc->romfile != NULL) {",
"pci_dev->romfile = g_strdup(pc->romfile);",
"is_default_rom = true;",
"}",
"pci_add_option_rom(pci_dev, is_default_rom, &local_err);",
"if (local_err) {",
"error_propagate(VAR_1, local_err);",
"pci_qdev_unrealize(DEVICE(pci_dev), 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31,
33
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
1,840 | int check_migratable(Object *obj, Error **err)
{
return 0;
}
| false | qemu | 1bfe5f0586083747f1602931713111673849cd9d | int check_migratable(Object *obj, Error **err)
{
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(Object *VAR_0, Error **VAR_1)
{
return 0;
}
| [
"int FUNC_0(Object *VAR_0, Error **VAR_1)\n{",
"return 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,841 | static av_cold int vp8_free(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
vpx_codec_destroy(&ctx->encoder);
av_freep(&ctx->twopass_stats.buf);
av_freep(&avctx->coded_frame);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
return 0;
}
| false | FFmpeg | d6604b29ef544793479d7fb4e05ef6622bb3e534 | static av_cold int vp8_free(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
vpx_codec_destroy(&ctx->encoder);
av_freep(&ctx->twopass_stats.buf);
av_freep(&avctx->coded_frame);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
vpx_codec_destroy(&ctx->encoder);
av_freep(&ctx->twopass_stats.buf);
av_freep(&avctx->coded_frame);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"VP8Context *ctx = avctx->priv_data;",
"vpx_codec_destroy(&ctx->encoder);",
"av_freep(&ctx->twopass_stats.buf);",
"av_freep(&avctx->coded_frame);",
"av_freep(&avctx->stats_out);",
"free_frame_list(ctx->coded_frame_list);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,842 | static void exynos4210_fimd_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
Exynos4210fimdState *s = (Exynos4210fimdState *)opaque;
unsigned w, i;
uint32_t old_value;
DPRINT_L2("write offset 0x%08x, value=%llu(0x%08llx)\n", offset,
(long long unsigned int)val, (long long unsigned int)val);
switch (offset) {
case FIMD_VIDCON0:
if ((val & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) {
exynos4210_fimd_enable(s, true);
} else {
if ((val & FIMD_VIDCON0_ENVID) == 0) {
exynos4210_fimd_enable(s, false);
}
}
s->vidcon[0] = val;
break;
case FIMD_VIDCON1:
/* Leave read-only bits as is */
val = (val & (~FIMD_VIDCON1_ROMASK)) |
(s->vidcon[1] & FIMD_VIDCON1_ROMASK);
s->vidcon[1] = val;
break;
case FIMD_VIDCON2 ... FIMD_VIDCON3:
s->vidcon[(offset) >> 2] = val;
break;
case FIMD_VIDTCON_START ... FIMD_VIDTCON_END:
s->vidtcon[(offset - FIMD_VIDTCON_START) >> 2] = val;
break;
case FIMD_WINCON_START ... FIMD_WINCON_END:
w = (offset - FIMD_WINCON_START) >> 2;
/* Window's current buffer ID */
i = fimd_get_buffer_id(&s->window[w]);
old_value = s->window[w].wincon;
val = (val & ~FIMD_WINCON_ROMASK) |
(s->window[w].wincon & FIMD_WINCON_ROMASK);
if (w == 0) {
/* Window 0 wincon ALPHA_MUL bit must always be 0 */
val &= ~FIMD_WINCON_ALPHA_MUL;
}
exynos4210_fimd_trace_bppmode(s, w, val);
switch (val & FIMD_WINCON_BUFSELECT) {
case FIMD_WINCON_BUF0_SEL:
val &= ~FIMD_WINCON_BUFSTATUS;
break;
case FIMD_WINCON_BUF1_SEL:
val = (val & ~FIMD_WINCON_BUFSTAT_H) | FIMD_WINCON_BUFSTAT_L;
break;
case FIMD_WINCON_BUF2_SEL:
if (val & FIMD_WINCON_BUFMODE) {
val = (val & ~FIMD_WINCON_BUFSTAT_L) | FIMD_WINCON_BUFSTAT_H;
}
break;
default:
break;
}
s->window[w].wincon = val;
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
if ((i != fimd_get_buffer_id(&s->window[w])) ||
(!(old_value & FIMD_WINCON_ENWIN) && (s->window[w].wincon &
FIMD_WINCON_ENWIN))) {
fimd_update_memory_section(s, w);
}
break;
case FIMD_SHADOWCON:
old_value = s->shadowcon;
s->shadowcon = val;
for (w = 0; w < NUM_OF_WINDOWS; w++) {
if (FIMD_WINDOW_PROTECTED(old_value, w) &&
!FIMD_WINDOW_PROTECTED(s->shadowcon, w)) {
fimd_update_memory_section(s, w);
}
}
break;
case FIMD_WINCHMAP:
s->winchmap = val;
break;
case FIMD_VIDOSD_START ... FIMD_VIDOSD_END:
w = (offset - FIMD_VIDOSD_START) >> 4;
i = ((offset - FIMD_VIDOSD_START) & 0xF) >> 2;
switch (i) {
case 0:
old_value = s->window[w].lefttop_y;
s->window[w].lefttop_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].lefttop_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].lefttop_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 1:
old_value = s->window[w].rightbot_y;
s->window[w].rightbot_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].rightbot_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].rightbot_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 2:
if (w == 0) {
s->window[w].osdsize = val;
} else {
s->window[w].alpha_val[0] =
unpack_upper_4((val & FIMD_VIDOSD_ALPHA_AEN0) >>
FIMD_VIDOSD_AEN0_SHIFT) |
(s->window[w].alpha_val[0] & FIMD_VIDALPHA_ALPHA_LOWER);
s->window[w].alpha_val[1] =
unpack_upper_4(val & FIMD_VIDOSD_ALPHA_AEN1) |
(s->window[w].alpha_val[1] & FIMD_VIDALPHA_ALPHA_LOWER);
}
break;
case 3:
if (w != 1 && w != 2) {
DPRINT_ERROR("Bad write offset 0x%08x\n", offset);
return;
}
s->window[w].osdsize = val;
break;
}
break;
case FIMD_VIDWADD0_START ... FIMD_VIDWADD0_END:
w = (offset - FIMD_VIDWADD0_START) >> 3;
i = ((offset - FIMD_VIDWADD0_START) >> 2) & 1;
if (i == fimd_get_buffer_id(&s->window[w]) &&
s->window[w].buf_start[i] != val) {
s->window[w].buf_start[i] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[i] = val;
break;
case FIMD_VIDWADD1_START ... FIMD_VIDWADD1_END:
w = (offset - FIMD_VIDWADD1_START) >> 3;
i = ((offset - FIMD_VIDWADD1_START) >> 2) & 1;
s->window[w].buf_end[i] = val;
break;
case FIMD_VIDWADD2_START ... FIMD_VIDWADD2_END:
w = (offset - FIMD_VIDWADD2_START) >> 2;
if (((val & FIMD_VIDWADD2_PAGEWIDTH) != s->window[w].virtpage_width) ||
(((val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE) !=
s->window[w].virtpage_offsize)) {
s->window[w].virtpage_width = val & FIMD_VIDWADD2_PAGEWIDTH;
s->window[w].virtpage_offsize =
(val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE;
fimd_update_memory_section(s, w);
}
break;
case FIMD_VIDINTCON0:
s->vidintcon[0] = val;
break;
case FIMD_VIDINTCON1:
s->vidintcon[1] &= ~(val & 7);
exynos4210_fimd_update_irq(s);
break;
case FIMD_WKEYCON_START ... FIMD_WKEYCON_END:
w = ((offset - FIMD_WKEYCON_START) >> 3) + 1;
i = ((offset - FIMD_WKEYCON_START) >> 2) & 1;
s->window[w].keycon[i] = val;
break;
case FIMD_WKEYALPHA_START ... FIMD_WKEYALPHA_END:
w = ((offset - FIMD_WKEYALPHA_START) >> 2) + 1;
s->window[w].keyalpha = val;
break;
case FIMD_DITHMODE:
s->dithmode = val;
break;
case FIMD_WINMAP_START ... FIMD_WINMAP_END:
w = (offset - FIMD_WINMAP_START) >> 2;
old_value = s->window[w].winmap;
s->window[w].winmap = val;
if ((val & FIMD_WINMAP_EN) ^ (old_value & FIMD_WINMAP_EN)) {
exynos4210_fimd_invalidate(s);
exynos4210_fimd_update_win_bppmode(s, w);
exynos4210_fimd_trace_bppmode(s, w, 0xFFFFFFFF);
exynos4210_fimd_update(s);
}
break;
case FIMD_WPALCON_HIGH ... FIMD_WPALCON_LOW:
i = (offset - FIMD_WPALCON_HIGH) >> 2;
s->wpalcon[i] = val;
if (s->wpalcon[1] & FIMD_WPALCON_UPDATEEN) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_TRIGCON:
val = (val & ~FIMD_TRIGCON_ROMASK) | (s->trigcon & FIMD_TRIGCON_ROMASK);
s->trigcon = val;
break;
case FIMD_I80IFCON_START ... FIMD_I80IFCON_END:
s->i80ifcon[(offset - FIMD_I80IFCON_START) >> 2] = val;
break;
case FIMD_COLORGAINCON:
s->colorgaincon = val;
break;
case FIMD_LDI_CMDCON0 ... FIMD_LDI_CMDCON1:
s->ldi_cmdcon[(offset - FIMD_LDI_CMDCON0) >> 2] = val;
break;
case FIMD_SIFCCON0 ... FIMD_SIFCCON2:
i = (offset - FIMD_SIFCCON0) >> 2;
if (i != 2) {
s->sifccon[i] = val;
}
break;
case FIMD_HUECOEFCR_START ... FIMD_HUECOEFCR_END:
i = (offset - FIMD_HUECOEFCR_START) >> 2;
s->huecoef_cr[i] = val;
break;
case FIMD_HUECOEFCB_START ... FIMD_HUECOEFCB_END:
i = (offset - FIMD_HUECOEFCB_START) >> 2;
s->huecoef_cb[i] = val;
break;
case FIMD_HUEOFFSET:
s->hueoffset = val;
break;
case FIMD_VIDWALPHA_START ... FIMD_VIDWALPHA_END:
w = ((offset - FIMD_VIDWALPHA_START) >> 3);
i = ((offset - FIMD_VIDWALPHA_START) >> 2) & 1;
if (w == 0) {
s->window[w].alpha_val[i] = val;
} else {
s->window[w].alpha_val[i] = (val & FIMD_VIDALPHA_ALPHA_LOWER) |
(s->window[w].alpha_val[i] & FIMD_VIDALPHA_ALPHA_UPPER);
}
break;
case FIMD_BLENDEQ_START ... FIMD_BLENDEQ_END:
s->window[(offset - FIMD_BLENDEQ_START) >> 2].blendeq = val;
break;
case FIMD_BLENDCON:
old_value = s->blendcon;
s->blendcon = val;
if ((s->blendcon & FIMD_ALPHA_8BIT) != (old_value & FIMD_ALPHA_8BIT)) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_WRTQOSCON_START ... FIMD_WRTQOSCON_END:
s->window[(offset - FIMD_WRTQOSCON_START) >> 2].rtqoscon = val;
break;
case FIMD_I80IFCMD_START ... FIMD_I80IFCMD_END:
s->i80ifcmd[(offset - FIMD_I80IFCMD_START) >> 2] = val;
break;
case FIMD_VIDW0ADD0_B2 ... FIMD_VIDW4ADD0_B2:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
w = (offset - FIMD_VIDW0ADD0_B2) >> 3;
if (fimd_get_buffer_id(&s->window[w]) == 2 &&
s->window[w].buf_start[2] != val) {
s->window[w].buf_start[2] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[2] = val;
break;
case FIMD_SHD_ADD0_START ... FIMD_SHD_ADD0_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD0_START) >> 3].shadow_buf_start = val;
break;
case FIMD_SHD_ADD1_START ... FIMD_SHD_ADD1_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD1_START) >> 3].shadow_buf_end = val;
break;
case FIMD_SHD_ADD2_START ... FIMD_SHD_ADD2_END:
s->window[(offset - FIMD_SHD_ADD2_START) >> 2].shadow_buf_size = val;
break;
case FIMD_PAL_MEM_START ... FIMD_PAL_MEM_END:
w = (offset - FIMD_PAL_MEM_START) >> 10;
i = ((offset - FIMD_PAL_MEM_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
case FIMD_PALMEM_AL_START ... FIMD_PALMEM_AL_END:
/* Palette memory aliases for windows 0 and 1 */
w = (offset - FIMD_PALMEM_AL_START) >> 10;
i = ((offset - FIMD_PALMEM_AL_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
default:
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void exynos4210_fimd_write(void *opaque, target_phys_addr_t offset,
uint64_t val, unsigned size)
{
Exynos4210fimdState *s = (Exynos4210fimdState *)opaque;
unsigned w, i;
uint32_t old_value;
DPRINT_L2("write offset 0x%08x, value=%llu(0x%08llx)\n", offset,
(long long unsigned int)val, (long long unsigned int)val);
switch (offset) {
case FIMD_VIDCON0:
if ((val & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) {
exynos4210_fimd_enable(s, true);
} else {
if ((val & FIMD_VIDCON0_ENVID) == 0) {
exynos4210_fimd_enable(s, false);
}
}
s->vidcon[0] = val;
break;
case FIMD_VIDCON1:
val = (val & (~FIMD_VIDCON1_ROMASK)) |
(s->vidcon[1] & FIMD_VIDCON1_ROMASK);
s->vidcon[1] = val;
break;
case FIMD_VIDCON2 ... FIMD_VIDCON3:
s->vidcon[(offset) >> 2] = val;
break;
case FIMD_VIDTCON_START ... FIMD_VIDTCON_END:
s->vidtcon[(offset - FIMD_VIDTCON_START) >> 2] = val;
break;
case FIMD_WINCON_START ... FIMD_WINCON_END:
w = (offset - FIMD_WINCON_START) >> 2;
i = fimd_get_buffer_id(&s->window[w]);
old_value = s->window[w].wincon;
val = (val & ~FIMD_WINCON_ROMASK) |
(s->window[w].wincon & FIMD_WINCON_ROMASK);
if (w == 0) {
val &= ~FIMD_WINCON_ALPHA_MUL;
}
exynos4210_fimd_trace_bppmode(s, w, val);
switch (val & FIMD_WINCON_BUFSELECT) {
case FIMD_WINCON_BUF0_SEL:
val &= ~FIMD_WINCON_BUFSTATUS;
break;
case FIMD_WINCON_BUF1_SEL:
val = (val & ~FIMD_WINCON_BUFSTAT_H) | FIMD_WINCON_BUFSTAT_L;
break;
case FIMD_WINCON_BUF2_SEL:
if (val & FIMD_WINCON_BUFMODE) {
val = (val & ~FIMD_WINCON_BUFSTAT_L) | FIMD_WINCON_BUFSTAT_H;
}
break;
default:
break;
}
s->window[w].wincon = val;
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
if ((i != fimd_get_buffer_id(&s->window[w])) ||
(!(old_value & FIMD_WINCON_ENWIN) && (s->window[w].wincon &
FIMD_WINCON_ENWIN))) {
fimd_update_memory_section(s, w);
}
break;
case FIMD_SHADOWCON:
old_value = s->shadowcon;
s->shadowcon = val;
for (w = 0; w < NUM_OF_WINDOWS; w++) {
if (FIMD_WINDOW_PROTECTED(old_value, w) &&
!FIMD_WINDOW_PROTECTED(s->shadowcon, w)) {
fimd_update_memory_section(s, w);
}
}
break;
case FIMD_WINCHMAP:
s->winchmap = val;
break;
case FIMD_VIDOSD_START ... FIMD_VIDOSD_END:
w = (offset - FIMD_VIDOSD_START) >> 4;
i = ((offset - FIMD_VIDOSD_START) & 0xF) >> 2;
switch (i) {
case 0:
old_value = s->window[w].lefttop_y;
s->window[w].lefttop_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].lefttop_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].lefttop_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 1:
old_value = s->window[w].rightbot_y;
s->window[w].rightbot_x = (val >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[w].rightbot_y = (val >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[w].rightbot_y != old_value) {
fimd_update_memory_section(s, w);
}
break;
case 2:
if (w == 0) {
s->window[w].osdsize = val;
} else {
s->window[w].alpha_val[0] =
unpack_upper_4((val & FIMD_VIDOSD_ALPHA_AEN0) >>
FIMD_VIDOSD_AEN0_SHIFT) |
(s->window[w].alpha_val[0] & FIMD_VIDALPHA_ALPHA_LOWER);
s->window[w].alpha_val[1] =
unpack_upper_4(val & FIMD_VIDOSD_ALPHA_AEN1) |
(s->window[w].alpha_val[1] & FIMD_VIDALPHA_ALPHA_LOWER);
}
break;
case 3:
if (w != 1 && w != 2) {
DPRINT_ERROR("Bad write offset 0x%08x\n", offset);
return;
}
s->window[w].osdsize = val;
break;
}
break;
case FIMD_VIDWADD0_START ... FIMD_VIDWADD0_END:
w = (offset - FIMD_VIDWADD0_START) >> 3;
i = ((offset - FIMD_VIDWADD0_START) >> 2) & 1;
if (i == fimd_get_buffer_id(&s->window[w]) &&
s->window[w].buf_start[i] != val) {
s->window[w].buf_start[i] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[i] = val;
break;
case FIMD_VIDWADD1_START ... FIMD_VIDWADD1_END:
w = (offset - FIMD_VIDWADD1_START) >> 3;
i = ((offset - FIMD_VIDWADD1_START) >> 2) & 1;
s->window[w].buf_end[i] = val;
break;
case FIMD_VIDWADD2_START ... FIMD_VIDWADD2_END:
w = (offset - FIMD_VIDWADD2_START) >> 2;
if (((val & FIMD_VIDWADD2_PAGEWIDTH) != s->window[w].virtpage_width) ||
(((val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE) !=
s->window[w].virtpage_offsize)) {
s->window[w].virtpage_width = val & FIMD_VIDWADD2_PAGEWIDTH;
s->window[w].virtpage_offsize =
(val >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE;
fimd_update_memory_section(s, w);
}
break;
case FIMD_VIDINTCON0:
s->vidintcon[0] = val;
break;
case FIMD_VIDINTCON1:
s->vidintcon[1] &= ~(val & 7);
exynos4210_fimd_update_irq(s);
break;
case FIMD_WKEYCON_START ... FIMD_WKEYCON_END:
w = ((offset - FIMD_WKEYCON_START) >> 3) + 1;
i = ((offset - FIMD_WKEYCON_START) >> 2) & 1;
s->window[w].keycon[i] = val;
break;
case FIMD_WKEYALPHA_START ... FIMD_WKEYALPHA_END:
w = ((offset - FIMD_WKEYALPHA_START) >> 2) + 1;
s->window[w].keyalpha = val;
break;
case FIMD_DITHMODE:
s->dithmode = val;
break;
case FIMD_WINMAP_START ... FIMD_WINMAP_END:
w = (offset - FIMD_WINMAP_START) >> 2;
old_value = s->window[w].winmap;
s->window[w].winmap = val;
if ((val & FIMD_WINMAP_EN) ^ (old_value & FIMD_WINMAP_EN)) {
exynos4210_fimd_invalidate(s);
exynos4210_fimd_update_win_bppmode(s, w);
exynos4210_fimd_trace_bppmode(s, w, 0xFFFFFFFF);
exynos4210_fimd_update(s);
}
break;
case FIMD_WPALCON_HIGH ... FIMD_WPALCON_LOW:
i = (offset - FIMD_WPALCON_HIGH) >> 2;
s->wpalcon[i] = val;
if (s->wpalcon[1] & FIMD_WPALCON_UPDATEEN) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
exynos4210_fimd_update_win_bppmode(s, w);
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_TRIGCON:
val = (val & ~FIMD_TRIGCON_ROMASK) | (s->trigcon & FIMD_TRIGCON_ROMASK);
s->trigcon = val;
break;
case FIMD_I80IFCON_START ... FIMD_I80IFCON_END:
s->i80ifcon[(offset - FIMD_I80IFCON_START) >> 2] = val;
break;
case FIMD_COLORGAINCON:
s->colorgaincon = val;
break;
case FIMD_LDI_CMDCON0 ... FIMD_LDI_CMDCON1:
s->ldi_cmdcon[(offset - FIMD_LDI_CMDCON0) >> 2] = val;
break;
case FIMD_SIFCCON0 ... FIMD_SIFCCON2:
i = (offset - FIMD_SIFCCON0) >> 2;
if (i != 2) {
s->sifccon[i] = val;
}
break;
case FIMD_HUECOEFCR_START ... FIMD_HUECOEFCR_END:
i = (offset - FIMD_HUECOEFCR_START) >> 2;
s->huecoef_cr[i] = val;
break;
case FIMD_HUECOEFCB_START ... FIMD_HUECOEFCB_END:
i = (offset - FIMD_HUECOEFCB_START) >> 2;
s->huecoef_cb[i] = val;
break;
case FIMD_HUEOFFSET:
s->hueoffset = val;
break;
case FIMD_VIDWALPHA_START ... FIMD_VIDWALPHA_END:
w = ((offset - FIMD_VIDWALPHA_START) >> 3);
i = ((offset - FIMD_VIDWALPHA_START) >> 2) & 1;
if (w == 0) {
s->window[w].alpha_val[i] = val;
} else {
s->window[w].alpha_val[i] = (val & FIMD_VIDALPHA_ALPHA_LOWER) |
(s->window[w].alpha_val[i] & FIMD_VIDALPHA_ALPHA_UPPER);
}
break;
case FIMD_BLENDEQ_START ... FIMD_BLENDEQ_END:
s->window[(offset - FIMD_BLENDEQ_START) >> 2].blendeq = val;
break;
case FIMD_BLENDCON:
old_value = s->blendcon;
s->blendcon = val;
if ((s->blendcon & FIMD_ALPHA_8BIT) != (old_value & FIMD_ALPHA_8BIT)) {
for (w = 0; w < NUM_OF_WINDOWS; w++) {
fimd_update_get_alpha(s, w);
}
}
break;
case FIMD_WRTQOSCON_START ... FIMD_WRTQOSCON_END:
s->window[(offset - FIMD_WRTQOSCON_START) >> 2].rtqoscon = val;
break;
case FIMD_I80IFCMD_START ... FIMD_I80IFCMD_END:
s->i80ifcmd[(offset - FIMD_I80IFCMD_START) >> 2] = val;
break;
case FIMD_VIDW0ADD0_B2 ... FIMD_VIDW4ADD0_B2:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
w = (offset - FIMD_VIDW0ADD0_B2) >> 3;
if (fimd_get_buffer_id(&s->window[w]) == 2 &&
s->window[w].buf_start[2] != val) {
s->window[w].buf_start[2] = val;
fimd_update_memory_section(s, w);
break;
}
s->window[w].buf_start[2] = val;
break;
case FIMD_SHD_ADD0_START ... FIMD_SHD_ADD0_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD0_START) >> 3].shadow_buf_start = val;
break;
case FIMD_SHD_ADD1_START ... FIMD_SHD_ADD1_END:
if (offset & 0x0004) {
DPRINT_ERROR("bad write offset 0x%08x\n", offset);
break;
}
s->window[(offset - FIMD_SHD_ADD1_START) >> 3].shadow_buf_end = val;
break;
case FIMD_SHD_ADD2_START ... FIMD_SHD_ADD2_END:
s->window[(offset - FIMD_SHD_ADD2_START) >> 2].shadow_buf_size = val;
break;
case FIMD_PAL_MEM_START ... FIMD_PAL_MEM_END:
w = (offset - FIMD_PAL_MEM_START) >> 10;
i = ((offset - FIMD_PAL_MEM_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
case FIMD_PALMEM_AL_START ... FIMD_PALMEM_AL_END:
w = (offset - FIMD_PALMEM_AL_START) >> 10;
i = ((offset - FIMD_PALMEM_AL_START) >> 2) & 0xFF;
s->window[w].palette[i] = val;
break;
default:
DPRINT_ERROR("bad write offset 0x%08x\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)
{
Exynos4210fimdState *s = (Exynos4210fimdState *)VAR_0;
unsigned VAR_4, VAR_5;
uint32_t old_value;
DPRINT_L2("write VAR_1 0x%08x, value=%llu(0x%08llx)\n", VAR_1,
(long long unsigned int)VAR_2, (long long unsigned int)VAR_2);
switch (VAR_1) {
case FIMD_VIDCON0:
if ((VAR_2 & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) {
exynos4210_fimd_enable(s, true);
} else {
if ((VAR_2 & FIMD_VIDCON0_ENVID) == 0) {
exynos4210_fimd_enable(s, false);
}
}
s->vidcon[0] = VAR_2;
break;
case FIMD_VIDCON1:
VAR_2 = (VAR_2 & (~FIMD_VIDCON1_ROMASK)) |
(s->vidcon[1] & FIMD_VIDCON1_ROMASK);
s->vidcon[1] = VAR_2;
break;
case FIMD_VIDCON2 ... FIMD_VIDCON3:
s->vidcon[(VAR_1) >> 2] = VAR_2;
break;
case FIMD_VIDTCON_START ... FIMD_VIDTCON_END:
s->vidtcon[(VAR_1 - FIMD_VIDTCON_START) >> 2] = VAR_2;
break;
case FIMD_WINCON_START ... FIMD_WINCON_END:
VAR_4 = (VAR_1 - FIMD_WINCON_START) >> 2;
VAR_5 = fimd_get_buffer_id(&s->window[VAR_4]);
old_value = s->window[VAR_4].wincon;
VAR_2 = (VAR_2 & ~FIMD_WINCON_ROMASK) |
(s->window[VAR_4].wincon & FIMD_WINCON_ROMASK);
if (VAR_4 == 0) {
VAR_2 &= ~FIMD_WINCON_ALPHA_MUL;
}
exynos4210_fimd_trace_bppmode(s, VAR_4, VAR_2);
switch (VAR_2 & FIMD_WINCON_BUFSELECT) {
case FIMD_WINCON_BUF0_SEL:
VAR_2 &= ~FIMD_WINCON_BUFSTATUS;
break;
case FIMD_WINCON_BUF1_SEL:
VAR_2 = (VAR_2 & ~FIMD_WINCON_BUFSTAT_H) | FIMD_WINCON_BUFSTAT_L;
break;
case FIMD_WINCON_BUF2_SEL:
if (VAR_2 & FIMD_WINCON_BUFMODE) {
VAR_2 = (VAR_2 & ~FIMD_WINCON_BUFSTAT_L) | FIMD_WINCON_BUFSTAT_H;
}
break;
default:
break;
}
s->window[VAR_4].wincon = VAR_2;
exynos4210_fimd_update_win_bppmode(s, VAR_4);
fimd_update_get_alpha(s, VAR_4);
if ((VAR_5 != fimd_get_buffer_id(&s->window[VAR_4])) ||
(!(old_value & FIMD_WINCON_ENWIN) && (s->window[VAR_4].wincon &
FIMD_WINCON_ENWIN))) {
fimd_update_memory_section(s, VAR_4);
}
break;
case FIMD_SHADOWCON:
old_value = s->shadowcon;
s->shadowcon = VAR_2;
for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {
if (FIMD_WINDOW_PROTECTED(old_value, VAR_4) &&
!FIMD_WINDOW_PROTECTED(s->shadowcon, VAR_4)) {
fimd_update_memory_section(s, VAR_4);
}
}
break;
case FIMD_WINCHMAP:
s->winchmap = VAR_2;
break;
case FIMD_VIDOSD_START ... FIMD_VIDOSD_END:
VAR_4 = (VAR_1 - FIMD_VIDOSD_START) >> 4;
VAR_5 = ((VAR_1 - FIMD_VIDOSD_START) & 0xF) >> 2;
switch (VAR_5) {
case 0:
old_value = s->window[VAR_4].lefttop_y;
s->window[VAR_4].lefttop_x = (VAR_2 >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[VAR_4].lefttop_y = (VAR_2 >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[VAR_4].lefttop_y != old_value) {
fimd_update_memory_section(s, VAR_4);
}
break;
case 1:
old_value = s->window[VAR_4].rightbot_y;
s->window[VAR_4].rightbot_x = (VAR_2 >> FIMD_VIDOSD_HOR_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
s->window[VAR_4].rightbot_y = (VAR_2 >> FIMD_VIDOSD_VER_SHIFT) &
FIMD_VIDOSD_COORD_MASK;
if (s->window[VAR_4].rightbot_y != old_value) {
fimd_update_memory_section(s, VAR_4);
}
break;
case 2:
if (VAR_4 == 0) {
s->window[VAR_4].osdsize = VAR_2;
} else {
s->window[VAR_4].alpha_val[0] =
unpack_upper_4((VAR_2 & FIMD_VIDOSD_ALPHA_AEN0) >>
FIMD_VIDOSD_AEN0_SHIFT) |
(s->window[VAR_4].alpha_val[0] & FIMD_VIDALPHA_ALPHA_LOWER);
s->window[VAR_4].alpha_val[1] =
unpack_upper_4(VAR_2 & FIMD_VIDOSD_ALPHA_AEN1) |
(s->window[VAR_4].alpha_val[1] & FIMD_VIDALPHA_ALPHA_LOWER);
}
break;
case 3:
if (VAR_4 != 1 && VAR_4 != 2) {
DPRINT_ERROR("Bad write VAR_1 0x%08x\n", VAR_1);
return;
}
s->window[VAR_4].osdsize = VAR_2;
break;
}
break;
case FIMD_VIDWADD0_START ... FIMD_VIDWADD0_END:
VAR_4 = (VAR_1 - FIMD_VIDWADD0_START) >> 3;
VAR_5 = ((VAR_1 - FIMD_VIDWADD0_START) >> 2) & 1;
if (VAR_5 == fimd_get_buffer_id(&s->window[VAR_4]) &&
s->window[VAR_4].buf_start[VAR_5] != VAR_2) {
s->window[VAR_4].buf_start[VAR_5] = VAR_2;
fimd_update_memory_section(s, VAR_4);
break;
}
s->window[VAR_4].buf_start[VAR_5] = VAR_2;
break;
case FIMD_VIDWADD1_START ... FIMD_VIDWADD1_END:
VAR_4 = (VAR_1 - FIMD_VIDWADD1_START) >> 3;
VAR_5 = ((VAR_1 - FIMD_VIDWADD1_START) >> 2) & 1;
s->window[VAR_4].buf_end[VAR_5] = VAR_2;
break;
case FIMD_VIDWADD2_START ... FIMD_VIDWADD2_END:
VAR_4 = (VAR_1 - FIMD_VIDWADD2_START) >> 2;
if (((VAR_2 & FIMD_VIDWADD2_PAGEWIDTH) != s->window[VAR_4].virtpage_width) ||
(((VAR_2 >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE) !=
s->window[VAR_4].virtpage_offsize)) {
s->window[VAR_4].virtpage_width = VAR_2 & FIMD_VIDWADD2_PAGEWIDTH;
s->window[VAR_4].virtpage_offsize =
(VAR_2 >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE;
fimd_update_memory_section(s, VAR_4);
}
break;
case FIMD_VIDINTCON0:
s->vidintcon[0] = VAR_2;
break;
case FIMD_VIDINTCON1:
s->vidintcon[1] &= ~(VAR_2 & 7);
exynos4210_fimd_update_irq(s);
break;
case FIMD_WKEYCON_START ... FIMD_WKEYCON_END:
VAR_4 = ((VAR_1 - FIMD_WKEYCON_START) >> 3) + 1;
VAR_5 = ((VAR_1 - FIMD_WKEYCON_START) >> 2) & 1;
s->window[VAR_4].keycon[VAR_5] = VAR_2;
break;
case FIMD_WKEYALPHA_START ... FIMD_WKEYALPHA_END:
VAR_4 = ((VAR_1 - FIMD_WKEYALPHA_START) >> 2) + 1;
s->window[VAR_4].keyalpha = VAR_2;
break;
case FIMD_DITHMODE:
s->dithmode = VAR_2;
break;
case FIMD_WINMAP_START ... FIMD_WINMAP_END:
VAR_4 = (VAR_1 - FIMD_WINMAP_START) >> 2;
old_value = s->window[VAR_4].winmap;
s->window[VAR_4].winmap = VAR_2;
if ((VAR_2 & FIMD_WINMAP_EN) ^ (old_value & FIMD_WINMAP_EN)) {
exynos4210_fimd_invalidate(s);
exynos4210_fimd_update_win_bppmode(s, VAR_4);
exynos4210_fimd_trace_bppmode(s, VAR_4, 0xFFFFFFFF);
exynos4210_fimd_update(s);
}
break;
case FIMD_WPALCON_HIGH ... FIMD_WPALCON_LOW:
VAR_5 = (VAR_1 - FIMD_WPALCON_HIGH) >> 2;
s->wpalcon[VAR_5] = VAR_2;
if (s->wpalcon[1] & FIMD_WPALCON_UPDATEEN) {
for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {
exynos4210_fimd_update_win_bppmode(s, VAR_4);
fimd_update_get_alpha(s, VAR_4);
}
}
break;
case FIMD_TRIGCON:
VAR_2 = (VAR_2 & ~FIMD_TRIGCON_ROMASK) | (s->trigcon & FIMD_TRIGCON_ROMASK);
s->trigcon = VAR_2;
break;
case FIMD_I80IFCON_START ... FIMD_I80IFCON_END:
s->i80ifcon[(VAR_1 - FIMD_I80IFCON_START) >> 2] = VAR_2;
break;
case FIMD_COLORGAINCON:
s->colorgaincon = VAR_2;
break;
case FIMD_LDI_CMDCON0 ... FIMD_LDI_CMDCON1:
s->ldi_cmdcon[(VAR_1 - FIMD_LDI_CMDCON0) >> 2] = VAR_2;
break;
case FIMD_SIFCCON0 ... FIMD_SIFCCON2:
VAR_5 = (VAR_1 - FIMD_SIFCCON0) >> 2;
if (VAR_5 != 2) {
s->sifccon[VAR_5] = VAR_2;
}
break;
case FIMD_HUECOEFCR_START ... FIMD_HUECOEFCR_END:
VAR_5 = (VAR_1 - FIMD_HUECOEFCR_START) >> 2;
s->huecoef_cr[VAR_5] = VAR_2;
break;
case FIMD_HUECOEFCB_START ... FIMD_HUECOEFCB_END:
VAR_5 = (VAR_1 - FIMD_HUECOEFCB_START) >> 2;
s->huecoef_cb[VAR_5] = VAR_2;
break;
case FIMD_HUEOFFSET:
s->hueoffset = VAR_2;
break;
case FIMD_VIDWALPHA_START ... FIMD_VIDWALPHA_END:
VAR_4 = ((VAR_1 - FIMD_VIDWALPHA_START) >> 3);
VAR_5 = ((VAR_1 - FIMD_VIDWALPHA_START) >> 2) & 1;
if (VAR_4 == 0) {
s->window[VAR_4].alpha_val[VAR_5] = VAR_2;
} else {
s->window[VAR_4].alpha_val[VAR_5] = (VAR_2 & FIMD_VIDALPHA_ALPHA_LOWER) |
(s->window[VAR_4].alpha_val[VAR_5] & FIMD_VIDALPHA_ALPHA_UPPER);
}
break;
case FIMD_BLENDEQ_START ... FIMD_BLENDEQ_END:
s->window[(VAR_1 - FIMD_BLENDEQ_START) >> 2].blendeq = VAR_2;
break;
case FIMD_BLENDCON:
old_value = s->blendcon;
s->blendcon = VAR_2;
if ((s->blendcon & FIMD_ALPHA_8BIT) != (old_value & FIMD_ALPHA_8BIT)) {
for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {
fimd_update_get_alpha(s, VAR_4);
}
}
break;
case FIMD_WRTQOSCON_START ... FIMD_WRTQOSCON_END:
s->window[(VAR_1 - FIMD_WRTQOSCON_START) >> 2].rtqoscon = VAR_2;
break;
case FIMD_I80IFCMD_START ... FIMD_I80IFCMD_END:
s->i80ifcmd[(VAR_1 - FIMD_I80IFCMD_START) >> 2] = VAR_2;
break;
case FIMD_VIDW0ADD0_B2 ... FIMD_VIDW4ADD0_B2:
if (VAR_1 & 0x0004) {
DPRINT_ERROR("bad write VAR_1 0x%08x\n", VAR_1);
break;
}
VAR_4 = (VAR_1 - FIMD_VIDW0ADD0_B2) >> 3;
if (fimd_get_buffer_id(&s->window[VAR_4]) == 2 &&
s->window[VAR_4].buf_start[2] != VAR_2) {
s->window[VAR_4].buf_start[2] = VAR_2;
fimd_update_memory_section(s, VAR_4);
break;
}
s->window[VAR_4].buf_start[2] = VAR_2;
break;
case FIMD_SHD_ADD0_START ... FIMD_SHD_ADD0_END:
if (VAR_1 & 0x0004) {
DPRINT_ERROR("bad write VAR_1 0x%08x\n", VAR_1);
break;
}
s->window[(VAR_1 - FIMD_SHD_ADD0_START) >> 3].shadow_buf_start = VAR_2;
break;
case FIMD_SHD_ADD1_START ... FIMD_SHD_ADD1_END:
if (VAR_1 & 0x0004) {
DPRINT_ERROR("bad write VAR_1 0x%08x\n", VAR_1);
break;
}
s->window[(VAR_1 - FIMD_SHD_ADD1_START) >> 3].shadow_buf_end = VAR_2;
break;
case FIMD_SHD_ADD2_START ... FIMD_SHD_ADD2_END:
s->window[(VAR_1 - FIMD_SHD_ADD2_START) >> 2].shadow_buf_size = VAR_2;
break;
case FIMD_PAL_MEM_START ... FIMD_PAL_MEM_END:
VAR_4 = (VAR_1 - FIMD_PAL_MEM_START) >> 10;
VAR_5 = ((VAR_1 - FIMD_PAL_MEM_START) >> 2) & 0xFF;
s->window[VAR_4].palette[VAR_5] = VAR_2;
break;
case FIMD_PALMEM_AL_START ... FIMD_PALMEM_AL_END:
VAR_4 = (VAR_1 - FIMD_PALMEM_AL_START) >> 10;
VAR_5 = ((VAR_1 - FIMD_PALMEM_AL_START) >> 2) & 0xFF;
s->window[VAR_4].palette[VAR_5] = VAR_2;
break;
default:
DPRINT_ERROR("bad write VAR_1 0x%08x\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{",
"Exynos4210fimdState *s = (Exynos4210fimdState *)VAR_0;",
"unsigned VAR_4, VAR_5;",
"uint32_t old_value;",
"DPRINT_L2(\"write VAR_1 0x%08x, value=%llu(0x%08llx)\\n\", VAR_1,\n(long long unsigned int)VAR_2, (long long unsigned int)VAR_2);",
"switch (VAR_1) {",
"case FIMD_VIDCON0:\nif ((VAR_2 & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) {",
"exynos4210_fimd_enable(s, true);",
"} else {",
"if ((VAR_2 & FIMD_VIDCON0_ENVID) == 0) {",
"exynos4210_fimd_enable(s, false);",
"}",
"}",
"s->vidcon[0] = VAR_2;",
"break;",
"case FIMD_VIDCON1:\nVAR_2 = (VAR_2 & (~FIMD_VIDCON1_ROMASK)) |\n(s->vidcon[1] & FIMD_VIDCON1_ROMASK);",
"s->vidcon[1] = VAR_2;",
"break;",
"case FIMD_VIDCON2 ... FIMD_VIDCON3:\ns->vidcon[(VAR_1) >> 2] = VAR_2;",
"break;",
"case FIMD_VIDTCON_START ... FIMD_VIDTCON_END:\ns->vidtcon[(VAR_1 - FIMD_VIDTCON_START) >> 2] = VAR_2;",
"break;",
"case FIMD_WINCON_START ... FIMD_WINCON_END:\nVAR_4 = (VAR_1 - FIMD_WINCON_START) >> 2;",
"VAR_5 = fimd_get_buffer_id(&s->window[VAR_4]);",
"old_value = s->window[VAR_4].wincon;",
"VAR_2 = (VAR_2 & ~FIMD_WINCON_ROMASK) |\n(s->window[VAR_4].wincon & FIMD_WINCON_ROMASK);",
"if (VAR_4 == 0) {",
"VAR_2 &= ~FIMD_WINCON_ALPHA_MUL;",
"}",
"exynos4210_fimd_trace_bppmode(s, VAR_4, VAR_2);",
"switch (VAR_2 & FIMD_WINCON_BUFSELECT) {",
"case FIMD_WINCON_BUF0_SEL:\nVAR_2 &= ~FIMD_WINCON_BUFSTATUS;",
"break;",
"case FIMD_WINCON_BUF1_SEL:\nVAR_2 = (VAR_2 & ~FIMD_WINCON_BUFSTAT_H) | FIMD_WINCON_BUFSTAT_L;",
"break;",
"case FIMD_WINCON_BUF2_SEL:\nif (VAR_2 & FIMD_WINCON_BUFMODE) {",
"VAR_2 = (VAR_2 & ~FIMD_WINCON_BUFSTAT_L) | FIMD_WINCON_BUFSTAT_H;",
"}",
"break;",
"default:\nbreak;",
"}",
"s->window[VAR_4].wincon = VAR_2;",
"exynos4210_fimd_update_win_bppmode(s, VAR_4);",
"fimd_update_get_alpha(s, VAR_4);",
"if ((VAR_5 != fimd_get_buffer_id(&s->window[VAR_4])) ||\n(!(old_value & FIMD_WINCON_ENWIN) && (s->window[VAR_4].wincon &\nFIMD_WINCON_ENWIN))) {",
"fimd_update_memory_section(s, VAR_4);",
"}",
"break;",
"case FIMD_SHADOWCON:\nold_value = s->shadowcon;",
"s->shadowcon = VAR_2;",
"for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {",
"if (FIMD_WINDOW_PROTECTED(old_value, VAR_4) &&\n!FIMD_WINDOW_PROTECTED(s->shadowcon, VAR_4)) {",
"fimd_update_memory_section(s, VAR_4);",
"}",
"}",
"break;",
"case FIMD_WINCHMAP:\ns->winchmap = VAR_2;",
"break;",
"case FIMD_VIDOSD_START ... FIMD_VIDOSD_END:\nVAR_4 = (VAR_1 - FIMD_VIDOSD_START) >> 4;",
"VAR_5 = ((VAR_1 - FIMD_VIDOSD_START) & 0xF) >> 2;",
"switch (VAR_5) {",
"case 0:\nold_value = s->window[VAR_4].lefttop_y;",
"s->window[VAR_4].lefttop_x = (VAR_2 >> FIMD_VIDOSD_HOR_SHIFT) &\nFIMD_VIDOSD_COORD_MASK;",
"s->window[VAR_4].lefttop_y = (VAR_2 >> FIMD_VIDOSD_VER_SHIFT) &\nFIMD_VIDOSD_COORD_MASK;",
"if (s->window[VAR_4].lefttop_y != old_value) {",
"fimd_update_memory_section(s, VAR_4);",
"}",
"break;",
"case 1:\nold_value = s->window[VAR_4].rightbot_y;",
"s->window[VAR_4].rightbot_x = (VAR_2 >> FIMD_VIDOSD_HOR_SHIFT) &\nFIMD_VIDOSD_COORD_MASK;",
"s->window[VAR_4].rightbot_y = (VAR_2 >> FIMD_VIDOSD_VER_SHIFT) &\nFIMD_VIDOSD_COORD_MASK;",
"if (s->window[VAR_4].rightbot_y != old_value) {",
"fimd_update_memory_section(s, VAR_4);",
"}",
"break;",
"case 2:\nif (VAR_4 == 0) {",
"s->window[VAR_4].osdsize = VAR_2;",
"} else {",
"s->window[VAR_4].alpha_val[0] =\nunpack_upper_4((VAR_2 & FIMD_VIDOSD_ALPHA_AEN0) >>\nFIMD_VIDOSD_AEN0_SHIFT) |\n(s->window[VAR_4].alpha_val[0] & FIMD_VIDALPHA_ALPHA_LOWER);",
"s->window[VAR_4].alpha_val[1] =\nunpack_upper_4(VAR_2 & FIMD_VIDOSD_ALPHA_AEN1) |\n(s->window[VAR_4].alpha_val[1] & FIMD_VIDALPHA_ALPHA_LOWER);",
"}",
"break;",
"case 3:\nif (VAR_4 != 1 && VAR_4 != 2) {",
"DPRINT_ERROR(\"Bad write VAR_1 0x%08x\\n\", VAR_1);",
"return;",
"}",
"s->window[VAR_4].osdsize = VAR_2;",
"break;",
"}",
"break;",
"case FIMD_VIDWADD0_START ... FIMD_VIDWADD0_END:\nVAR_4 = (VAR_1 - FIMD_VIDWADD0_START) >> 3;",
"VAR_5 = ((VAR_1 - FIMD_VIDWADD0_START) >> 2) & 1;",
"if (VAR_5 == fimd_get_buffer_id(&s->window[VAR_4]) &&\ns->window[VAR_4].buf_start[VAR_5] != VAR_2) {",
"s->window[VAR_4].buf_start[VAR_5] = VAR_2;",
"fimd_update_memory_section(s, VAR_4);",
"break;",
"}",
"s->window[VAR_4].buf_start[VAR_5] = VAR_2;",
"break;",
"case FIMD_VIDWADD1_START ... FIMD_VIDWADD1_END:\nVAR_4 = (VAR_1 - FIMD_VIDWADD1_START) >> 3;",
"VAR_5 = ((VAR_1 - FIMD_VIDWADD1_START) >> 2) & 1;",
"s->window[VAR_4].buf_end[VAR_5] = VAR_2;",
"break;",
"case FIMD_VIDWADD2_START ... FIMD_VIDWADD2_END:\nVAR_4 = (VAR_1 - FIMD_VIDWADD2_START) >> 2;",
"if (((VAR_2 & FIMD_VIDWADD2_PAGEWIDTH) != s->window[VAR_4].virtpage_width) ||\n(((VAR_2 >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE) !=\ns->window[VAR_4].virtpage_offsize)) {",
"s->window[VAR_4].virtpage_width = VAR_2 & FIMD_VIDWADD2_PAGEWIDTH;",
"s->window[VAR_4].virtpage_offsize =\n(VAR_2 >> FIMD_VIDWADD2_OFFSIZE_SHIFT) & FIMD_VIDWADD2_OFFSIZE;",
"fimd_update_memory_section(s, VAR_4);",
"}",
"break;",
"case FIMD_VIDINTCON0:\ns->vidintcon[0] = VAR_2;",
"break;",
"case FIMD_VIDINTCON1:\ns->vidintcon[1] &= ~(VAR_2 & 7);",
"exynos4210_fimd_update_irq(s);",
"break;",
"case FIMD_WKEYCON_START ... FIMD_WKEYCON_END:\nVAR_4 = ((VAR_1 - FIMD_WKEYCON_START) >> 3) + 1;",
"VAR_5 = ((VAR_1 - FIMD_WKEYCON_START) >> 2) & 1;",
"s->window[VAR_4].keycon[VAR_5] = VAR_2;",
"break;",
"case FIMD_WKEYALPHA_START ... FIMD_WKEYALPHA_END:\nVAR_4 = ((VAR_1 - FIMD_WKEYALPHA_START) >> 2) + 1;",
"s->window[VAR_4].keyalpha = VAR_2;",
"break;",
"case FIMD_DITHMODE:\ns->dithmode = VAR_2;",
"break;",
"case FIMD_WINMAP_START ... FIMD_WINMAP_END:\nVAR_4 = (VAR_1 - FIMD_WINMAP_START) >> 2;",
"old_value = s->window[VAR_4].winmap;",
"s->window[VAR_4].winmap = VAR_2;",
"if ((VAR_2 & FIMD_WINMAP_EN) ^ (old_value & FIMD_WINMAP_EN)) {",
"exynos4210_fimd_invalidate(s);",
"exynos4210_fimd_update_win_bppmode(s, VAR_4);",
"exynos4210_fimd_trace_bppmode(s, VAR_4, 0xFFFFFFFF);",
"exynos4210_fimd_update(s);",
"}",
"break;",
"case FIMD_WPALCON_HIGH ... FIMD_WPALCON_LOW:\nVAR_5 = (VAR_1 - FIMD_WPALCON_HIGH) >> 2;",
"s->wpalcon[VAR_5] = VAR_2;",
"if (s->wpalcon[1] & FIMD_WPALCON_UPDATEEN) {",
"for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {",
"exynos4210_fimd_update_win_bppmode(s, VAR_4);",
"fimd_update_get_alpha(s, VAR_4);",
"}",
"}",
"break;",
"case FIMD_TRIGCON:\nVAR_2 = (VAR_2 & ~FIMD_TRIGCON_ROMASK) | (s->trigcon & FIMD_TRIGCON_ROMASK);",
"s->trigcon = VAR_2;",
"break;",
"case FIMD_I80IFCON_START ... FIMD_I80IFCON_END:\ns->i80ifcon[(VAR_1 - FIMD_I80IFCON_START) >> 2] = VAR_2;",
"break;",
"case FIMD_COLORGAINCON:\ns->colorgaincon = VAR_2;",
"break;",
"case FIMD_LDI_CMDCON0 ... FIMD_LDI_CMDCON1:\ns->ldi_cmdcon[(VAR_1 - FIMD_LDI_CMDCON0) >> 2] = VAR_2;",
"break;",
"case FIMD_SIFCCON0 ... FIMD_SIFCCON2:\nVAR_5 = (VAR_1 - FIMD_SIFCCON0) >> 2;",
"if (VAR_5 != 2) {",
"s->sifccon[VAR_5] = VAR_2;",
"}",
"break;",
"case FIMD_HUECOEFCR_START ... FIMD_HUECOEFCR_END:\nVAR_5 = (VAR_1 - FIMD_HUECOEFCR_START) >> 2;",
"s->huecoef_cr[VAR_5] = VAR_2;",
"break;",
"case FIMD_HUECOEFCB_START ... FIMD_HUECOEFCB_END:\nVAR_5 = (VAR_1 - FIMD_HUECOEFCB_START) >> 2;",
"s->huecoef_cb[VAR_5] = VAR_2;",
"break;",
"case FIMD_HUEOFFSET:\ns->hueoffset = VAR_2;",
"break;",
"case FIMD_VIDWALPHA_START ... FIMD_VIDWALPHA_END:\nVAR_4 = ((VAR_1 - FIMD_VIDWALPHA_START) >> 3);",
"VAR_5 = ((VAR_1 - FIMD_VIDWALPHA_START) >> 2) & 1;",
"if (VAR_4 == 0) {",
"s->window[VAR_4].alpha_val[VAR_5] = VAR_2;",
"} else {",
"s->window[VAR_4].alpha_val[VAR_5] = (VAR_2 & FIMD_VIDALPHA_ALPHA_LOWER) |\n(s->window[VAR_4].alpha_val[VAR_5] & FIMD_VIDALPHA_ALPHA_UPPER);",
"}",
"break;",
"case FIMD_BLENDEQ_START ... FIMD_BLENDEQ_END:\ns->window[(VAR_1 - FIMD_BLENDEQ_START) >> 2].blendeq = VAR_2;",
"break;",
"case FIMD_BLENDCON:\nold_value = s->blendcon;",
"s->blendcon = VAR_2;",
"if ((s->blendcon & FIMD_ALPHA_8BIT) != (old_value & FIMD_ALPHA_8BIT)) {",
"for (VAR_4 = 0; VAR_4 < NUM_OF_WINDOWS; VAR_4++) {",
"fimd_update_get_alpha(s, VAR_4);",
"}",
"}",
"break;",
"case FIMD_WRTQOSCON_START ... FIMD_WRTQOSCON_END:\ns->window[(VAR_1 - FIMD_WRTQOSCON_START) >> 2].rtqoscon = VAR_2;",
"break;",
"case FIMD_I80IFCMD_START ... FIMD_I80IFCMD_END:\ns->i80ifcmd[(VAR_1 - FIMD_I80IFCMD_START) >> 2] = VAR_2;",
"break;",
"case FIMD_VIDW0ADD0_B2 ... FIMD_VIDW4ADD0_B2:\nif (VAR_1 & 0x0004) {",
"DPRINT_ERROR(\"bad write VAR_1 0x%08x\\n\", VAR_1);",
"break;",
"}",
"VAR_4 = (VAR_1 - FIMD_VIDW0ADD0_B2) >> 3;",
"if (fimd_get_buffer_id(&s->window[VAR_4]) == 2 &&\ns->window[VAR_4].buf_start[2] != VAR_2) {",
"s->window[VAR_4].buf_start[2] = VAR_2;",
"fimd_update_memory_section(s, VAR_4);",
"break;",
"}",
"s->window[VAR_4].buf_start[2] = VAR_2;",
"break;",
"case FIMD_SHD_ADD0_START ... FIMD_SHD_ADD0_END:\nif (VAR_1 & 0x0004) {",
"DPRINT_ERROR(\"bad write VAR_1 0x%08x\\n\", VAR_1);",
"break;",
"}",
"s->window[(VAR_1 - FIMD_SHD_ADD0_START) >> 3].shadow_buf_start = VAR_2;",
"break;",
"case FIMD_SHD_ADD1_START ... FIMD_SHD_ADD1_END:\nif (VAR_1 & 0x0004) {",
"DPRINT_ERROR(\"bad write VAR_1 0x%08x\\n\", VAR_1);",
"break;",
"}",
"s->window[(VAR_1 - FIMD_SHD_ADD1_START) >> 3].shadow_buf_end = VAR_2;",
"break;",
"case FIMD_SHD_ADD2_START ... FIMD_SHD_ADD2_END:\ns->window[(VAR_1 - FIMD_SHD_ADD2_START) >> 2].shadow_buf_size = VAR_2;",
"break;",
"case FIMD_PAL_MEM_START ... FIMD_PAL_MEM_END:\nVAR_4 = (VAR_1 - FIMD_PAL_MEM_START) >> 10;",
"VAR_5 = ((VAR_1 - FIMD_PAL_MEM_START) >> 2) & 0xFF;",
"s->window[VAR_4].palette[VAR_5] = VAR_2;",
"break;",
"case FIMD_PALMEM_AL_START ... FIMD_PALMEM_AL_END:\nVAR_4 = (VAR_1 - FIMD_PALMEM_AL_START) >> 10;",
"VAR_5 = ((VAR_1 - FIMD_PALMEM_AL_START) >> 2) & 0xFF;",
"s->window[VAR_4].palette[VAR_5] = VAR_2;",
"break;",
"default:\nDPRINT_ERROR(\"bad write VAR_1 0x%08x\\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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129,
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181,
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197,
199
],
[
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221,
223,
225,
227
],
[
229,
231,
233
],
[
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
289,
291
],
[
293,
295,
297
],
[
299
],
[
301,
303
],
[
305
],
[
307
],
[
309
],
[
311,
313
],
[
315
],
[
317,
319
],
[
321
],
[
323
],
[
325,
327
],
[
329
],
[
331
],
[
333
],
[
335,
337
],
[
339
],
[
341
],
[
343,
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395
],
[
397
],
[
399,
401
],
[
403
],
[
405,
407
],
[
409
],
[
411,
413
],
[
415
],
[
417,
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429,
431
],
[
433
],
[
435
],
[
437,
439
],
[
441
],
[
443
],
[
445,
447
],
[
449
],
[
451,
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
471,
473
],
[
475
],
[
477,
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495,
497
],
[
499
],
[
501,
503
],
[
505
],
[
507,
509
],
[
511
],
[
513
],
[
515
],
[
517
],
[
519,
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535,
537
],
[
539
],
[
541
],
[
543
],
[
545
],
[
547
],
[
549,
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
563,
565
],
[
567
],
[
569,
571
],
[
573
],
[
575
],
[
577
],
[
579,
583
],
[
585
],
[
587
],
[
589
],
[
591,
593
],
[
595
],
[
597
],
[
599
]
] |
1,843 | static int usb_wacom_initfn(USBDevice *dev)
{
USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
s->changed = 1;
return 0;
}
| false | qemu | a980a065fb5e86d6dec337e6cb6ff432f1a143c9 | static int usb_wacom_initfn(USBDevice *dev)
{
USBWacomState *s = DO_UPCAST(USBWacomState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
s->changed = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0)
{
USBWacomState *s = DO_UPCAST(USBWacomState, VAR_0, VAR_0);
s->VAR_0.speed = USB_SPEED_FULL;
s->changed = 1;
return 0;
}
| [
"static int FUNC_0(USBDevice *VAR_0)\n{",
"USBWacomState *s = DO_UPCAST(USBWacomState, VAR_0, VAR_0);",
"s->VAR_0.speed = USB_SPEED_FULL;",
"s->changed = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,844 | void bdrv_register(BlockDriver *bdrv)
{
/* Block drivers without coroutine functions need emulation */
if (!bdrv->bdrv_co_readv) {
bdrv->bdrv_co_readv = bdrv_co_readv_em;
bdrv->bdrv_co_writev = bdrv_co_writev_em;
if (!bdrv->bdrv_aio_readv) {
/* add AIO emulation layer */
bdrv->bdrv_aio_readv = bdrv_aio_readv_em;
bdrv->bdrv_aio_writev = bdrv_aio_writev_em;
} else if (!bdrv->bdrv_read) {
/* add synchronous IO emulation layer */
bdrv->bdrv_read = bdrv_read_em;
bdrv->bdrv_write = bdrv_write_em;
}
}
if (!bdrv->bdrv_aio_flush)
bdrv->bdrv_aio_flush = bdrv_aio_flush_em;
QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
}
| false | qemu | f8c35c1d59c9fecf79f6d5a02cd09f472a6f411d | void bdrv_register(BlockDriver *bdrv)
{
if (!bdrv->bdrv_co_readv) {
bdrv->bdrv_co_readv = bdrv_co_readv_em;
bdrv->bdrv_co_writev = bdrv_co_writev_em;
if (!bdrv->bdrv_aio_readv) {
bdrv->bdrv_aio_readv = bdrv_aio_readv_em;
bdrv->bdrv_aio_writev = bdrv_aio_writev_em;
} else if (!bdrv->bdrv_read) {
bdrv->bdrv_read = bdrv_read_em;
bdrv->bdrv_write = bdrv_write_em;
}
}
if (!bdrv->bdrv_aio_flush)
bdrv->bdrv_aio_flush = bdrv_aio_flush_em;
QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriver *VAR_0)
{
if (!VAR_0->bdrv_co_readv) {
VAR_0->bdrv_co_readv = bdrv_co_readv_em;
VAR_0->bdrv_co_writev = bdrv_co_writev_em;
if (!VAR_0->bdrv_aio_readv) {
VAR_0->bdrv_aio_readv = bdrv_aio_readv_em;
VAR_0->bdrv_aio_writev = bdrv_aio_writev_em;
} else if (!VAR_0->bdrv_read) {
VAR_0->bdrv_read = bdrv_read_em;
VAR_0->bdrv_write = bdrv_write_em;
}
}
if (!VAR_0->bdrv_aio_flush)
VAR_0->bdrv_aio_flush = bdrv_aio_flush_em;
QLIST_INSERT_HEAD(&bdrv_drivers, VAR_0, list);
}
| [
"void FUNC_0(BlockDriver *VAR_0)\n{",
"if (!VAR_0->bdrv_co_readv) {",
"VAR_0->bdrv_co_readv = bdrv_co_readv_em;",
"VAR_0->bdrv_co_writev = bdrv_co_writev_em;",
"if (!VAR_0->bdrv_aio_readv) {",
"VAR_0->bdrv_aio_readv = bdrv_aio_readv_em;",
"VAR_0->bdrv_aio_writev = bdrv_aio_writev_em;",
"} else if (!VAR_0->bdrv_read) {",
"VAR_0->bdrv_read = bdrv_read_em;",
"VAR_0->bdrv_write = bdrv_write_em;",
"}",
"}",
"if (!VAR_0->bdrv_aio_flush)\nVAR_0->bdrv_aio_flush = bdrv_aio_flush_em;",
"QLIST_INSERT_HEAD(&bdrv_drivers, VAR_0, list);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
43
],
[
45
]
] |
1,845 | void socket_listen_cleanup(int fd, Error **errp)
{
SocketAddress *addr;
addr = socket_local_address(fd, errp);
if (addr->type == SOCKET_ADDRESS_KIND_UNIX
&& addr->u.q_unix.data->path) {
if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
error_setg_errno(errp, errno,
"Failed to unlink socket %s",
addr->u.q_unix.data->path);
}
}
qapi_free_SocketAddress(addr);
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | void socket_listen_cleanup(int fd, Error **errp)
{
SocketAddress *addr;
addr = socket_local_address(fd, errp);
if (addr->type == SOCKET_ADDRESS_KIND_UNIX
&& addr->u.q_unix.data->path) {
if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
error_setg_errno(errp, errno,
"Failed to unlink socket %s",
addr->u.q_unix.data->path);
}
}
qapi_free_SocketAddress(addr);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0, Error **VAR_1)
{
SocketAddress *addr;
addr = socket_local_address(VAR_0, VAR_1);
if (addr->type == SOCKET_ADDRESS_KIND_UNIX
&& addr->u.q_unix.data->path) {
if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
error_setg_errno(VAR_1, errno,
"Failed to unlink socket %s",
addr->u.q_unix.data->path);
}
}
qapi_free_SocketAddress(addr);
}
| [
"void FUNC_0(int VAR_0, Error **VAR_1)\n{",
"SocketAddress *addr;",
"addr = socket_local_address(VAR_0, VAR_1);",
"if (addr->type == SOCKET_ADDRESS_KIND_UNIX\n&& addr->u.q_unix.data->path) {",
"if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {",
"error_setg_errno(VAR_1, errno,\n\"Failed to unlink socket %s\",\naddr->u.q_unix.data->path);",
"}",
"}",
"qapi_free_SocketAddress(addr);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13,
15
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
]
] |
1,846 | static void test_nested_struct(gconstpointer opaque)
{
TestArgs *args = (TestArgs *) opaque;
const SerializeOps *ops = args->ops;
UserDefNested *udnp = nested_struct_create();
UserDefNested *udnp_copy = NULL;
Error *err = NULL;
void *serialize_data;
ops->serialize(udnp, &serialize_data, visit_nested_struct, &err);
ops->deserialize((void **)&udnp_copy, serialize_data, visit_nested_struct, &err);
g_assert(err == NULL);
nested_struct_compare(udnp, udnp_copy);
nested_struct_cleanup(udnp);
nested_struct_cleanup(udnp_copy);
ops->cleanup(serialize_data);
g_free(args);
}
| false | qemu | b6fcf32d9b851a83dedcb609091236b97cc4a985 | static void test_nested_struct(gconstpointer opaque)
{
TestArgs *args = (TestArgs *) opaque;
const SerializeOps *ops = args->ops;
UserDefNested *udnp = nested_struct_create();
UserDefNested *udnp_copy = NULL;
Error *err = NULL;
void *serialize_data;
ops->serialize(udnp, &serialize_data, visit_nested_struct, &err);
ops->deserialize((void **)&udnp_copy, serialize_data, visit_nested_struct, &err);
g_assert(err == NULL);
nested_struct_compare(udnp, udnp_copy);
nested_struct_cleanup(udnp);
nested_struct_cleanup(udnp_copy);
ops->cleanup(serialize_data);
g_free(args);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(gconstpointer VAR_0)
{
TestArgs *args = (TestArgs *) VAR_0;
const SerializeOps *VAR_1 = args->VAR_1;
UserDefNested *udnp = nested_struct_create();
UserDefNested *udnp_copy = NULL;
Error *err = NULL;
void *VAR_2;
VAR_1->serialize(udnp, &VAR_2, visit_nested_struct, &err);
VAR_1->deserialize((void **)&udnp_copy, VAR_2, visit_nested_struct, &err);
g_assert(err == NULL);
nested_struct_compare(udnp, udnp_copy);
nested_struct_cleanup(udnp);
nested_struct_cleanup(udnp_copy);
VAR_1->cleanup(VAR_2);
g_free(args);
}
| [
"static void FUNC_0(gconstpointer VAR_0)\n{",
"TestArgs *args = (TestArgs *) VAR_0;",
"const SerializeOps *VAR_1 = args->VAR_1;",
"UserDefNested *udnp = nested_struct_create();",
"UserDefNested *udnp_copy = NULL;",
"Error *err = NULL;",
"void *VAR_2;",
"VAR_1->serialize(udnp, &VAR_2, visit_nested_struct, &err);",
"VAR_1->deserialize((void **)&udnp_copy, VAR_2, visit_nested_struct, &err);",
"g_assert(err == NULL);",
"nested_struct_compare(udnp, udnp_copy);",
"nested_struct_cleanup(udnp);",
"nested_struct_cleanup(udnp_copy);",
"VAR_1->cleanup(VAR_2);",
"g_free(args);",
"}"
] | [
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
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
]
] |
1,847 | static int usb_net_initfn(USBDevice *dev)
{
USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
s->rndis = 1;
s->rndis_state = RNDIS_UNINITIALIZED;
QTAILQ_INIT(&s->rndis_resp);
s->medium = 0; /* NDIS_MEDIUM_802_3 */
s->speed = 1000000; /* 100MBps, in 100Bps units */
s->media_state = 0; /* NDIS_MEDIA_STATE_CONNECTED */;
s->filter = 0;
s->vendorid = 0x1234;
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
s->dev.qdev.info->name, s->dev.qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
0x40,
s->conf.macaddr.a[1],
s->conf.macaddr.a[2],
s->conf.macaddr.a[3],
s->conf.macaddr.a[4],
s->conf.macaddr.a[5]);
usb_desc_set_string(dev, STRING_ETHADDR, s->usbstring_mac);
add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@0");
return 0;
}
| false | qemu | a980a065fb5e86d6dec337e6cb6ff432f1a143c9 | static int usb_net_initfn(USBDevice *dev)
{
USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
s->dev.speed = USB_SPEED_FULL;
s->rndis = 1;
s->rndis_state = RNDIS_UNINITIALIZED;
QTAILQ_INIT(&s->rndis_resp);
s->medium = 0;
s->speed = 1000000;
s->media_state = 0; ;
s->filter = 0;
s->vendorid = 0x1234;
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
s->dev.qdev.info->name, s->dev.qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
0x40,
s->conf.macaddr.a[1],
s->conf.macaddr.a[2],
s->conf.macaddr.a[3],
s->conf.macaddr.a[4],
s->conf.macaddr.a[5]);
usb_desc_set_string(dev, STRING_ETHADDR, s->usbstring_mac);
add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@0");
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0)
{
USBNetState *s = DO_UPCAST(USBNetState, VAR_0, VAR_0);
s->VAR_0.speed = USB_SPEED_FULL;
s->rndis = 1;
s->rndis_state = RNDIS_UNINITIALIZED;
QTAILQ_INIT(&s->rndis_resp);
s->medium = 0;
s->speed = 1000000;
s->media_state = 0; ;
s->filter = 0;
s->vendorid = 0x1234;
qemu_macaddr_default_if_unset(&s->conf.macaddr);
s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
s->VAR_0.qdev.info->name, s->VAR_0.qdev.id, s);
qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
"%02x%02x%02x%02x%02x%02x",
0x40,
s->conf.macaddr.a[1],
s->conf.macaddr.a[2],
s->conf.macaddr.a[3],
s->conf.macaddr.a[4],
s->conf.macaddr.a[5]);
usb_desc_set_string(VAR_0, STRING_ETHADDR, s->usbstring_mac);
add_boot_device_path(s->conf.bootindex, &VAR_0->qdev, "/ethernet@0");
return 0;
}
| [
"static int FUNC_0(USBDevice *VAR_0)\n{",
"USBNetState *s = DO_UPCAST(USBNetState, VAR_0, VAR_0);",
"s->VAR_0.speed = USB_SPEED_FULL;",
"s->rndis = 1;",
"s->rndis_state = RNDIS_UNINITIALIZED;",
"QTAILQ_INIT(&s->rndis_resp);",
"s->medium = 0;",
"s->speed = 1000000;",
"s->media_state = 0;\t;",
"s->filter = 0;",
"s->vendorid = 0x1234;",
"qemu_macaddr_default_if_unset(&s->conf.macaddr);",
"s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,\ns->VAR_0.qdev.info->name, s->VAR_0.qdev.id, s);",
"qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);",
"snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),\n\"%02x%02x%02x%02x%02x%02x\",\n0x40,\ns->conf.macaddr.a[1],\ns->conf.macaddr.a[2],\ns->conf.macaddr.a[3],\ns->conf.macaddr.a[4],\ns->conf.macaddr.a[5]);",
"usb_desc_set_string(VAR_0, STRING_ETHADDR, s->usbstring_mac);",
"add_boot_device_path(s->conf.bootindex, &VAR_0->qdev, \"/ethernet@0\");",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43,
45,
47,
49,
51,
53,
55
],
[
57
],
[
61
],
[
63
],
[
65
]
] |
1,848 | static void curses_setup(void)
{
int i, colour_default[8] = {
COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
};
/* input as raw as possible, let everything be interpreted
* by the guest system */
initscr(); noecho(); intrflush(stdscr, FALSE);
nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
start_color(); raw(); scrollok(stdscr, FALSE);
for (i = 0; i < 64; i++) {
init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
}
/* Set default color for more than 64. (monitor uses 0x74xx for example) */
for (i = 64; i < COLOR_PAIRS; i++) {
init_pair(i, COLOR_WHITE, COLOR_BLACK);
}
/*
* Setup mapping for vga to curses line graphics.
* FIXME: for better font, have to use ncursesw and setlocale()
*/
#if 0
/* FIXME: map from where? */
ACS_S1;
ACS_S3;
ACS_S7;
ACS_S9;
#endif
/* ACS_* is not constant. So, we can't initialize statically. */
vga_to_curses['\0'] = ' ';
vga_to_curses[0x04] = ACS_DIAMOND;
vga_to_curses[0x0a] = ACS_RARROW;
vga_to_curses[0x0b] = ACS_LARROW;
vga_to_curses[0x18] = ACS_UARROW;
vga_to_curses[0x19] = ACS_DARROW;
vga_to_curses[0x9c] = ACS_STERLING;
vga_to_curses[0xb0] = ACS_BOARD;
vga_to_curses[0xb1] = ACS_CKBOARD;
vga_to_curses[0xb3] = ACS_VLINE;
vga_to_curses[0xb4] = ACS_RTEE;
vga_to_curses[0xbf] = ACS_URCORNER;
vga_to_curses[0xc0] = ACS_LLCORNER;
vga_to_curses[0xc1] = ACS_BTEE;
vga_to_curses[0xc2] = ACS_TTEE;
vga_to_curses[0xc3] = ACS_LTEE;
vga_to_curses[0xc4] = ACS_HLINE;
vga_to_curses[0xc5] = ACS_PLUS;
vga_to_curses[0xce] = ACS_LANTERN;
vga_to_curses[0xd8] = ACS_NEQUAL;
vga_to_curses[0xd9] = ACS_LRCORNER;
vga_to_curses[0xda] = ACS_ULCORNER;
vga_to_curses[0xdb] = ACS_BLOCK;
vga_to_curses[0xe3] = ACS_PI;
vga_to_curses[0xf1] = ACS_PLMINUS;
vga_to_curses[0xf2] = ACS_GEQUAL;
vga_to_curses[0xf3] = ACS_LEQUAL;
vga_to_curses[0xf8] = ACS_DEGREE;
vga_to_curses[0xfe] = ACS_BULLET;
}
| false | qemu | 4083733db5e4120939acee57019ff52db1f45b9d | static void curses_setup(void)
{
int i, colour_default[8] = {
COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
};
initscr(); noecho(); intrflush(stdscr, FALSE);
nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
start_color(); raw(); scrollok(stdscr, FALSE);
for (i = 0; i < 64; i++) {
init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
}
for (i = 64; i < COLOR_PAIRS; i++) {
init_pair(i, COLOR_WHITE, COLOR_BLACK);
}
#if 0
ACS_S1;
ACS_S3;
ACS_S7;
ACS_S9;
#endif
vga_to_curses['\0'] = ' ';
vga_to_curses[0x04] = ACS_DIAMOND;
vga_to_curses[0x0a] = ACS_RARROW;
vga_to_curses[0x0b] = ACS_LARROW;
vga_to_curses[0x18] = ACS_UARROW;
vga_to_curses[0x19] = ACS_DARROW;
vga_to_curses[0x9c] = ACS_STERLING;
vga_to_curses[0xb0] = ACS_BOARD;
vga_to_curses[0xb1] = ACS_CKBOARD;
vga_to_curses[0xb3] = ACS_VLINE;
vga_to_curses[0xb4] = ACS_RTEE;
vga_to_curses[0xbf] = ACS_URCORNER;
vga_to_curses[0xc0] = ACS_LLCORNER;
vga_to_curses[0xc1] = ACS_BTEE;
vga_to_curses[0xc2] = ACS_TTEE;
vga_to_curses[0xc3] = ACS_LTEE;
vga_to_curses[0xc4] = ACS_HLINE;
vga_to_curses[0xc5] = ACS_PLUS;
vga_to_curses[0xce] = ACS_LANTERN;
vga_to_curses[0xd8] = ACS_NEQUAL;
vga_to_curses[0xd9] = ACS_LRCORNER;
vga_to_curses[0xda] = ACS_ULCORNER;
vga_to_curses[0xdb] = ACS_BLOCK;
vga_to_curses[0xe3] = ACS_PI;
vga_to_curses[0xf1] = ACS_PLMINUS;
vga_to_curses[0xf2] = ACS_GEQUAL;
vga_to_curses[0xf3] = ACS_LEQUAL;
vga_to_curses[0xf8] = ACS_DEGREE;
vga_to_curses[0xfe] = ACS_BULLET;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
int VAR_0, VAR_1[8] = {
COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
};
initscr(); noecho(); intrflush(stdscr, FALSE);
nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
start_color(); raw(); scrollok(stdscr, FALSE);
for (VAR_0 = 0; VAR_0 < 64; VAR_0++) {
init_pair(VAR_0, VAR_1[VAR_0 & 7], VAR_1[VAR_0 >> 3]);
}
for (VAR_0 = 64; VAR_0 < COLOR_PAIRS; VAR_0++) {
init_pair(VAR_0, COLOR_WHITE, COLOR_BLACK);
}
#if 0
ACS_S1;
ACS_S3;
ACS_S7;
ACS_S9;
#endif
vga_to_curses['\0'] = ' ';
vga_to_curses[0x04] = ACS_DIAMOND;
vga_to_curses[0x0a] = ACS_RARROW;
vga_to_curses[0x0b] = ACS_LARROW;
vga_to_curses[0x18] = ACS_UARROW;
vga_to_curses[0x19] = ACS_DARROW;
vga_to_curses[0x9c] = ACS_STERLING;
vga_to_curses[0xb0] = ACS_BOARD;
vga_to_curses[0xb1] = ACS_CKBOARD;
vga_to_curses[0xb3] = ACS_VLINE;
vga_to_curses[0xb4] = ACS_RTEE;
vga_to_curses[0xbf] = ACS_URCORNER;
vga_to_curses[0xc0] = ACS_LLCORNER;
vga_to_curses[0xc1] = ACS_BTEE;
vga_to_curses[0xc2] = ACS_TTEE;
vga_to_curses[0xc3] = ACS_LTEE;
vga_to_curses[0xc4] = ACS_HLINE;
vga_to_curses[0xc5] = ACS_PLUS;
vga_to_curses[0xce] = ACS_LANTERN;
vga_to_curses[0xd8] = ACS_NEQUAL;
vga_to_curses[0xd9] = ACS_LRCORNER;
vga_to_curses[0xda] = ACS_ULCORNER;
vga_to_curses[0xdb] = ACS_BLOCK;
vga_to_curses[0xe3] = ACS_PI;
vga_to_curses[0xf1] = ACS_PLMINUS;
vga_to_curses[0xf2] = ACS_GEQUAL;
vga_to_curses[0xf3] = ACS_LEQUAL;
vga_to_curses[0xf8] = ACS_DEGREE;
vga_to_curses[0xfe] = ACS_BULLET;
}
| [
"static void FUNC_0(void)\n{",
"int VAR_0, VAR_1[8] = {",
"COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,\nCOLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,\n};",
"initscr(); noecho(); intrflush(stdscr, FALSE);",
"nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);",
"start_color(); raw(); scrollok(stdscr, FALSE);",
"for (VAR_0 = 0; VAR_0 < 64; VAR_0++) {",
"init_pair(VAR_0, VAR_1[VAR_0 & 7], VAR_1[VAR_0 >> 3]);",
"}",
"for (VAR_0 = 64; VAR_0 < COLOR_PAIRS; VAR_0++) {",
"init_pair(VAR_0, COLOR_WHITE, COLOR_BLACK);",
"}",
"#if 0\nACS_S1;",
"ACS_S3;",
"ACS_S7;",
"ACS_S9;",
"#endif\nvga_to_curses['\\0'] = ' ';",
"vga_to_curses[0x04] = ACS_DIAMOND;",
"vga_to_curses[0x0a] = ACS_RARROW;",
"vga_to_curses[0x0b] = ACS_LARROW;",
"vga_to_curses[0x18] = ACS_UARROW;",
"vga_to_curses[0x19] = ACS_DARROW;",
"vga_to_curses[0x9c] = ACS_STERLING;",
"vga_to_curses[0xb0] = ACS_BOARD;",
"vga_to_curses[0xb1] = ACS_CKBOARD;",
"vga_to_curses[0xb3] = ACS_VLINE;",
"vga_to_curses[0xb4] = ACS_RTEE;",
"vga_to_curses[0xbf] = ACS_URCORNER;",
"vga_to_curses[0xc0] = ACS_LLCORNER;",
"vga_to_curses[0xc1] = ACS_BTEE;",
"vga_to_curses[0xc2] = ACS_TTEE;",
"vga_to_curses[0xc3] = ACS_LTEE;",
"vga_to_curses[0xc4] = ACS_HLINE;",
"vga_to_curses[0xc5] = ACS_PLUS;",
"vga_to_curses[0xce] = ACS_LANTERN;",
"vga_to_curses[0xd8] = ACS_NEQUAL;",
"vga_to_curses[0xd9] = ACS_LRCORNER;",
"vga_to_curses[0xda] = ACS_ULCORNER;",
"vga_to_curses[0xdb] = ACS_BLOCK;",
"vga_to_curses[0xe3] = ACS_PI;",
"vga_to_curses[0xf1] = ACS_PLMINUS;",
"vga_to_curses[0xf2] = ACS_GEQUAL;",
"vga_to_curses[0xf3] = ACS_LEQUAL;",
"vga_to_curses[0xf8] = ACS_DEGREE;",
"vga_to_curses[0xfe] = ACS_BULLET;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
51,
55
],
[
57
],
[
59
],
[
61
],
[
63,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
] |
1,849 | static bool send_gradient_rect(VncState *vs, int w, int h)
{
int stream = 3;
int level = tight_conf[vs->tight_compression].gradient_zlib_level;
size_t bytes;
if (vs->clientds.pf.bytes_per_pixel == 1)
return send_full_color_rect(vs, w, h);
vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);
buffer_reserve(&vs->tight_gradient, w * 3 * sizeof (int));
if (vs->tight_pixel24) {
tight_filter_gradient24(vs, vs->tight.buffer, w, h);
bytes = 3;
} else if (vs->clientds.pf.bytes_per_pixel == 4) {
tight_filter_gradient32(vs, (uint32_t *)vs->tight.buffer, w, h);
bytes = 4;
} else {
tight_filter_gradient16(vs, (uint16_t *)vs->tight.buffer, w, h);
bytes = 2;
}
buffer_reset(&vs->tight_gradient);
bytes = w * h * bytes;
vs->tight.offset = bytes;
bytes = tight_compress_data(vs, stream, bytes,
level, Z_FILTERED);
return (bytes >= 0);
}
| false | qemu | 245f7b51c0ea04fb2224b1127430a096c91aee70 | static bool send_gradient_rect(VncState *vs, int w, int h)
{
int stream = 3;
int level = tight_conf[vs->tight_compression].gradient_zlib_level;
size_t bytes;
if (vs->clientds.pf.bytes_per_pixel == 1)
return send_full_color_rect(vs, w, h);
vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);
buffer_reserve(&vs->tight_gradient, w * 3 * sizeof (int));
if (vs->tight_pixel24) {
tight_filter_gradient24(vs, vs->tight.buffer, w, h);
bytes = 3;
} else if (vs->clientds.pf.bytes_per_pixel == 4) {
tight_filter_gradient32(vs, (uint32_t *)vs->tight.buffer, w, h);
bytes = 4;
} else {
tight_filter_gradient16(vs, (uint16_t *)vs->tight.buffer, w, h);
bytes = 2;
}
buffer_reset(&vs->tight_gradient);
bytes = w * h * bytes;
vs->tight.offset = bytes;
bytes = tight_compress_data(vs, stream, bytes,
level, Z_FILTERED);
return (bytes >= 0);
}
| {
"code": [],
"line_no": []
} | static bool FUNC_0(VncState *vs, int w, int h)
{
int VAR_0 = 3;
int VAR_1 = tight_conf[vs->tight_compression].gradient_zlib_level;
size_t bytes;
if (vs->clientds.pf.bytes_per_pixel == 1)
return send_full_color_rect(vs, w, h);
vnc_write_u8(vs, (VAR_0 | VNC_TIGHT_EXPLICIT_FILTER) << 4);
vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);
buffer_reserve(&vs->tight_gradient, w * 3 * sizeof (int));
if (vs->tight_pixel24) {
tight_filter_gradient24(vs, vs->tight.buffer, w, h);
bytes = 3;
} else if (vs->clientds.pf.bytes_per_pixel == 4) {
tight_filter_gradient32(vs, (uint32_t *)vs->tight.buffer, w, h);
bytes = 4;
} else {
tight_filter_gradient16(vs, (uint16_t *)vs->tight.buffer, w, h);
bytes = 2;
}
buffer_reset(&vs->tight_gradient);
bytes = w * h * bytes;
vs->tight.offset = bytes;
bytes = tight_compress_data(vs, VAR_0, bytes,
VAR_1, Z_FILTERED);
return (bytes >= 0);
}
| [
"static bool FUNC_0(VncState *vs, int w, int h)\n{",
"int VAR_0 = 3;",
"int VAR_1 = tight_conf[vs->tight_compression].gradient_zlib_level;",
"size_t bytes;",
"if (vs->clientds.pf.bytes_per_pixel == 1)\nreturn send_full_color_rect(vs, w, h);",
"vnc_write_u8(vs, (VAR_0 | VNC_TIGHT_EXPLICIT_FILTER) << 4);",
"vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);",
"buffer_reserve(&vs->tight_gradient, w * 3 * sizeof (int));",
"if (vs->tight_pixel24) {",
"tight_filter_gradient24(vs, vs->tight.buffer, w, h);",
"bytes = 3;",
"} else if (vs->clientds.pf.bytes_per_pixel == 4) {",
"tight_filter_gradient32(vs, (uint32_t *)vs->tight.buffer, w, h);",
"bytes = 4;",
"} else {",
"tight_filter_gradient16(vs, (uint16_t *)vs->tight.buffer, w, h);",
"bytes = 2;",
"}",
"buffer_reset(&vs->tight_gradient);",
"bytes = w * h * bytes;",
"vs->tight.offset = bytes;",
"bytes = tight_compress_data(vs, VAR_0, bytes,\nVAR_1, Z_FILTERED);",
"return (bytes >= 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
]
] |
1,850 | int bdrv_get_flags(BlockDriverState *bs)
{
return bs->open_flags;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | int bdrv_get_flags(BlockDriverState *bs)
{
return bs->open_flags;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0)
{
return VAR_0->open_flags;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"return VAR_0->open_flags;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,852 | static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
{
AVFilterContext *ctx = inlink->dst;
ASNSContext *asns = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int ret;
int nb_samples = insamples->nb_samples;
if (av_audio_fifo_space(asns->fifo) < nb_samples) {
av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", nb_samples);
ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + nb_samples);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR,
"Stretching audio fifo failed, discarded %d samples\n", nb_samples);
return -1;
}
}
av_audio_fifo_write(asns->fifo, (void **)insamples->extended_data, nb_samples);
if (asns->next_out_pts == AV_NOPTS_VALUE)
asns->next_out_pts = insamples->pts;
av_frame_free(&insamples);
while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples)
push_samples(outlink);
return 0;
}
| false | FFmpeg | 000836c2a98e1c6a2867dd9db0371c137609acf0 | static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
{
AVFilterContext *ctx = inlink->dst;
ASNSContext *asns = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int ret;
int nb_samples = insamples->nb_samples;
if (av_audio_fifo_space(asns->fifo) < nb_samples) {
av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", nb_samples);
ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + nb_samples);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR,
"Stretching audio fifo failed, discarded %d samples\n", nb_samples);
return -1;
}
}
av_audio_fifo_write(asns->fifo, (void **)insamples->extended_data, nb_samples);
if (asns->next_out_pts == AV_NOPTS_VALUE)
asns->next_out_pts = insamples->pts;
av_frame_free(&insamples);
while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples)
push_samples(outlink);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{
AVFilterContext *ctx = VAR_0->dst;
ASNSContext *asns = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
int VAR_2;
int VAR_3 = VAR_1->VAR_3;
if (av_audio_fifo_space(asns->fifo) < VAR_3) {
av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", VAR_3);
VAR_2 = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + VAR_3);
if (VAR_2 < 0) {
av_log(ctx, AV_LOG_ERROR,
"Stretching audio fifo failed, discarded %d samples\n", VAR_3);
return -1;
}
}
av_audio_fifo_write(asns->fifo, (void **)VAR_1->extended_data, VAR_3);
if (asns->next_out_pts == AV_NOPTS_VALUE)
asns->next_out_pts = VAR_1->pts;
av_frame_free(&VAR_1);
while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples)
push_samples(outlink);
return 0;
}
| [
"static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)\n{",
"AVFilterContext *ctx = VAR_0->dst;",
"ASNSContext *asns = ctx->priv;",
"AVFilterLink *outlink = ctx->outputs[0];",
"int VAR_2;",
"int VAR_3 = VAR_1->VAR_3;",
"if (av_audio_fifo_space(asns->fifo) < VAR_3) {",
"av_log(ctx, AV_LOG_DEBUG, \"No space for %d samples, stretching audio fifo\\n\", VAR_3);",
"VAR_2 = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + VAR_3);",
"if (VAR_2 < 0) {",
"av_log(ctx, AV_LOG_ERROR,\n\"Stretching audio fifo failed, discarded %d samples\\n\", VAR_3);",
"return -1;",
"}",
"}",
"av_audio_fifo_write(asns->fifo, (void **)VAR_1->extended_data, VAR_3);",
"if (asns->next_out_pts == AV_NOPTS_VALUE)\nasns->next_out_pts = VAR_1->pts;",
"av_frame_free(&VAR_1);",
"while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples)\npush_samples(outlink);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
]
] |
1,853 | long do_rt_sigreturn(CPUState *env)
{
struct rt_sigframe *frame;
sigset_t host_set;
/*
* Since we stacked the signal on a 64-bit boundary,
* then 'sp' should be word aligned here. If it's
* not, then the user is trying to mess with us.
*/
if (env->regs[13] & 7)
goto badframe;
frame = (struct rt_sigframe *)env->regs[13];
#if 0
if (verify_area(VERIFY_READ, frame, sizeof (*frame)))
goto badframe;
#endif
target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext))
goto badframe;
if (do_sigaltstack(h2g(&frame->uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
#if 0
/* Send SIGTRAP if we're single-stepping */
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
return env->regs[0];
badframe:
force_sig(SIGSEGV /* , current */);
return 0;
}
| false | qemu | f8b0aa25599782eef91edc00ebf620bd14db720c | long do_rt_sigreturn(CPUState *env)
{
struct rt_sigframe *frame;
sigset_t host_set;
if (env->regs[13] & 7)
goto badframe;
frame = (struct rt_sigframe *)env->regs[13];
#if 0
if (verify_area(VERIFY_READ, frame, sizeof (*frame)))
goto badframe;
#endif
target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext))
goto badframe;
if (do_sigaltstack(h2g(&frame->uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
#if 0
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
return env->regs[0];
badframe:
force_sig(SIGSEGV );
return 0;
}
| {
"code": [],
"line_no": []
} | long FUNC_0(CPUState *VAR_0)
{
struct rt_sigframe *VAR_1;
sigset_t host_set;
if (VAR_0->regs[13] & 7)
goto badframe;
VAR_1 = (struct rt_sigframe *)VAR_0->regs[13];
#if 0
if (verify_area(VERIFY_READ, VAR_1, sizeof (*VAR_1)))
goto badframe;
#endif
target_to_host_sigset(&host_set, &VAR_1->uc.tuc_sigmask);
sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext))
goto badframe;
if (do_sigaltstack(h2g(&VAR_1->uc.tuc_stack), 0, get_sp_from_cpustate(VAR_0)) == -EFAULT)
goto badframe;
#if 0
if (ptrace_cancel_bpt(current))
send_sig(SIGTRAP, current, 1);
#endif
return VAR_0->regs[0];
badframe:
force_sig(SIGSEGV );
return 0;
}
| [
"long FUNC_0(CPUState *VAR_0)\n{",
"struct rt_sigframe *VAR_1;",
"sigset_t host_set;",
"if (VAR_0->regs[13] & 7)\ngoto badframe;",
"VAR_1 = (struct rt_sigframe *)VAR_0->regs[13];",
"#if 0\nif (verify_area(VERIFY_READ, VAR_1, sizeof (*VAR_1)))\ngoto badframe;",
"#endif\ntarget_to_host_sigset(&host_set, &VAR_1->uc.tuc_sigmask);",
"sigprocmask(SIG_SETMASK, &host_set, NULL);",
"if (restore_sigcontext(VAR_0, &VAR_1->uc.tuc_mcontext))\ngoto badframe;",
"if (do_sigaltstack(h2g(&VAR_1->uc.tuc_stack), 0, get_sp_from_cpustate(VAR_0)) == -EFAULT)\ngoto badframe;",
"#if 0\nif (ptrace_cancel_bpt(current))\nsend_sig(SIGTRAP, current, 1);",
"#endif\nreturn VAR_0->regs[0];",
"badframe:\nforce_sig(SIGSEGV );",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
21,
23
],
[
27
],
[
31,
33,
35
],
[
37,
39
],
[
41
],
[
45,
47
],
[
51,
53
],
[
57,
61,
63
],
[
65,
67
],
[
71,
73
],
[
75
],
[
77
]
] |
1,854 | static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
uint32_t config_addr)
{
sPAPRPHBState *sphb = find_phb(spapr, buid);
PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
int bus_num = (config_addr >> 16) & 0xFF;
int devfn = (config_addr >> 8) & 0xFF;
if (!phb) {
return NULL;
}
return pci_find_device(phb->bus, bus_num, devfn);
}
| false | qemu | 46c5874e9cd752ed8ded31af03472edd8fc3efc1 | static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
uint32_t config_addr)
{
sPAPRPHBState *sphb = find_phb(spapr, buid);
PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
int bus_num = (config_addr >> 16) & 0xFF;
int devfn = (config_addr >> 8) & 0xFF;
if (!phb) {
return NULL;
}
return pci_find_device(phb->bus, bus_num, devfn);
}
| {
"code": [],
"line_no": []
} | static PCIDevice *FUNC_0(sPAPREnvironment *spapr, uint64_t buid,
uint32_t config_addr)
{
sPAPRPHBState *sphb = find_phb(spapr, buid);
PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
int VAR_0 = (config_addr >> 16) & 0xFF;
int VAR_1 = (config_addr >> 8) & 0xFF;
if (!phb) {
return NULL;
}
return pci_find_device(phb->bus, VAR_0, VAR_1);
}
| [
"static PCIDevice *FUNC_0(sPAPREnvironment *spapr, uint64_t buid,\nuint32_t config_addr)\n{",
"sPAPRPHBState *sphb = find_phb(spapr, buid);",
"PCIHostState *phb = PCI_HOST_BRIDGE(sphb);",
"int VAR_0 = (config_addr >> 16) & 0xFF;",
"int VAR_1 = (config_addr >> 8) & 0xFF;",
"if (!phb) {",
"return NULL;",
"}",
"return pci_find_device(phb->bus, VAR_0, VAR_1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
1,855 | void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
int *size, unsigned int domain,
unsigned int bus, unsigned int slot,
unsigned int function)
{
char name[32], rom_file[64];
FILE *fp;
uint8_t val;
struct stat st;
void *ptr = NULL;
/* If loading ROM from file, pci handles it */
if (dev->romfile || !dev->rom_bar) {
return NULL;
}
snprintf(rom_file, sizeof(rom_file),
"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/rom",
domain, bus, slot, function);
if (stat(rom_file, &st)) {
if (errno != ENOENT) {
error_report("pci-assign: Invalid ROM.");
}
return NULL;
}
/* Write "1" to the ROM file to enable it */
fp = fopen(rom_file, "r+");
if (fp == NULL) {
error_report("pci-assign: Cannot open %s: %s", rom_file, strerror(errno));
return NULL;
}
val = 1;
if (fwrite(&val, 1, 1, fp) != 1) {
goto close_rom;
}
fseek(fp, 0, SEEK_SET);
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
memory_region_init_ram(&dev->rom, owner, name, st.st_size, &error_abort);
vmstate_register_ram(&dev->rom, &dev->qdev);
ptr = memory_region_get_ram_ptr(&dev->rom);
memset(ptr, 0xff, st.st_size);
if (!fread(ptr, 1, st.st_size, fp)) {
error_report("pci-assign: Cannot read from host %s", rom_file);
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
goto close_rom;
}
pci_register_bar(dev, PCI_ROM_SLOT, 0, &dev->rom);
dev->has_rom = true;
*size = st.st_size;
close_rom:
/* Write "0" to disable ROM */
fseek(fp, 0, SEEK_SET);
val = 0;
if (!fwrite(&val, 1, 1, fp)) {
DEBUG("%s\n", "Failed to disable pci-sysfs rom file");
}
fclose(fp);
return ptr;
}
| false | qemu | 9ed2690354e65a87b830f197cac0138e842f989e | void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
int *size, unsigned int domain,
unsigned int bus, unsigned int slot,
unsigned int function)
{
char name[32], rom_file[64];
FILE *fp;
uint8_t val;
struct stat st;
void *ptr = NULL;
if (dev->romfile || !dev->rom_bar) {
return NULL;
}
snprintf(rom_file, sizeof(rom_file),
"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/rom",
domain, bus, slot, function);
if (stat(rom_file, &st)) {
if (errno != ENOENT) {
error_report("pci-assign: Invalid ROM.");
}
return NULL;
}
fp = fopen(rom_file, "r+");
if (fp == NULL) {
error_report("pci-assign: Cannot open %s: %s", rom_file, strerror(errno));
return NULL;
}
val = 1;
if (fwrite(&val, 1, 1, fp) != 1) {
goto close_rom;
}
fseek(fp, 0, SEEK_SET);
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
memory_region_init_ram(&dev->rom, owner, name, st.st_size, &error_abort);
vmstate_register_ram(&dev->rom, &dev->qdev);
ptr = memory_region_get_ram_ptr(&dev->rom);
memset(ptr, 0xff, st.st_size);
if (!fread(ptr, 1, st.st_size, fp)) {
error_report("pci-assign: Cannot read from host %s", rom_file);
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
goto close_rom;
}
pci_register_bar(dev, PCI_ROM_SLOT, 0, &dev->rom);
dev->has_rom = true;
*size = st.st_size;
close_rom:
fseek(fp, 0, SEEK_SET);
val = 0;
if (!fwrite(&val, 1, 1, fp)) {
DEBUG("%s\n", "Failed to disable pci-sysfs rom file");
}
fclose(fp);
return ptr;
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(PCIDevice *VAR_0, struct Object *VAR_1,
int *VAR_2, unsigned int VAR_3,
unsigned int VAR_4, unsigned int VAR_5,
unsigned int VAR_6)
{
char VAR_7[32], VAR_8[64];
FILE *fp;
uint8_t val;
struct stat VAR_9;
void *VAR_10 = NULL;
if (VAR_0->romfile || !VAR_0->rom_bar) {
return NULL;
}
snprintf(VAR_8, sizeof(VAR_8),
"/sys/VAR_4/pci/devices/%04x:%02x:%02x.%01x/rom",
VAR_3, VAR_4, VAR_5, VAR_6);
if (stat(VAR_8, &VAR_9)) {
if (errno != ENOENT) {
error_report("pci-assign: Invalid ROM.");
}
return NULL;
}
fp = fopen(VAR_8, "r+");
if (fp == NULL) {
error_report("pci-assign: Cannot open %s: %s", VAR_8, strerror(errno));
return NULL;
}
val = 1;
if (fwrite(&val, 1, 1, fp) != 1) {
goto close_rom;
}
fseek(fp, 0, SEEK_SET);
snprintf(VAR_7, sizeof(VAR_7), "%s.rom", object_get_typename(VAR_1));
memory_region_init_ram(&VAR_0->rom, VAR_1, VAR_7, VAR_9.st_size, &error_abort);
vmstate_register_ram(&VAR_0->rom, &VAR_0->qdev);
VAR_10 = memory_region_get_ram_ptr(&VAR_0->rom);
memset(VAR_10, 0xff, VAR_9.st_size);
if (!fread(VAR_10, 1, VAR_9.st_size, fp)) {
error_report("pci-assign: Cannot read from host %s", VAR_8);
error_printf("Device option ROM contents are probably invalid "
"(check dmesg).\nSkip option ROM probe with rombar=0, "
"or load from file with romfile=\n");
goto close_rom;
}
pci_register_bar(VAR_0, PCI_ROM_SLOT, 0, &VAR_0->rom);
VAR_0->has_rom = true;
*VAR_2 = VAR_9.st_size;
close_rom:
fseek(fp, 0, SEEK_SET);
val = 0;
if (!fwrite(&val, 1, 1, fp)) {
DEBUG("%s\n", "Failed to disable pci-sysfs rom file");
}
fclose(fp);
return VAR_10;
}
| [
"void *FUNC_0(PCIDevice *VAR_0, struct Object *VAR_1,\nint *VAR_2, unsigned int VAR_3,\nunsigned int VAR_4, unsigned int VAR_5,\nunsigned int VAR_6)\n{",
"char VAR_7[32], VAR_8[64];",
"FILE *fp;",
"uint8_t val;",
"struct stat VAR_9;",
"void *VAR_10 = NULL;",
"if (VAR_0->romfile || !VAR_0->rom_bar) {",
"return NULL;",
"}",
"snprintf(VAR_8, sizeof(VAR_8),\n\"/sys/VAR_4/pci/devices/%04x:%02x:%02x.%01x/rom\",\nVAR_3, VAR_4, VAR_5, VAR_6);",
"if (stat(VAR_8, &VAR_9)) {",
"if (errno != ENOENT) {",
"error_report(\"pci-assign: Invalid ROM.\");",
"}",
"return NULL;",
"}",
"fp = fopen(VAR_8, \"r+\");",
"if (fp == NULL) {",
"error_report(\"pci-assign: Cannot open %s: %s\", VAR_8, strerror(errno));",
"return NULL;",
"}",
"val = 1;",
"if (fwrite(&val, 1, 1, fp) != 1) {",
"goto close_rom;",
"}",
"fseek(fp, 0, SEEK_SET);",
"snprintf(VAR_7, sizeof(VAR_7), \"%s.rom\", object_get_typename(VAR_1));",
"memory_region_init_ram(&VAR_0->rom, VAR_1, VAR_7, VAR_9.st_size, &error_abort);",
"vmstate_register_ram(&VAR_0->rom, &VAR_0->qdev);",
"VAR_10 = memory_region_get_ram_ptr(&VAR_0->rom);",
"memset(VAR_10, 0xff, VAR_9.st_size);",
"if (!fread(VAR_10, 1, VAR_9.st_size, fp)) {",
"error_report(\"pci-assign: Cannot read from host %s\", VAR_8);",
"error_printf(\"Device option ROM contents are probably invalid \"\n\"(check dmesg).\\nSkip option ROM probe with rombar=0, \"\n\"or load from file with romfile=\\n\");",
"goto close_rom;",
"}",
"pci_register_bar(VAR_0, PCI_ROM_SLOT, 0, &VAR_0->rom);",
"VAR_0->has_rom = true;",
"*VAR_2 = VAR_9.st_size;",
"close_rom:\nfseek(fp, 0, SEEK_SET);",
"val = 0;",
"if (!fwrite(&val, 1, 1, fp)) {",
"DEBUG(\"%s\\n\", \"Failed to disable pci-sysfs rom file\");",
"}",
"fclose(fp);",
"return VAR_10;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
33,
35,
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
]
] |
1,857 | void cpu_unregister_map_client(void *_client)
{
MapClient *client = (MapClient *)_client;
LIST_REMOVE(client, link);
qemu_free(client);
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void cpu_unregister_map_client(void *_client)
{
MapClient *client = (MapClient *)_client;
LIST_REMOVE(client, link);
qemu_free(client);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0)
{
MapClient *client = (MapClient *)VAR_0;
LIST_REMOVE(client, link);
qemu_free(client);
}
| [
"void FUNC_0(void *VAR_0)\n{",
"MapClient *client = (MapClient *)VAR_0;",
"LIST_REMOVE(client, link);",
"qemu_free(client);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
]
] |
1,858 | static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.pr = msr_pr;
ctx.hv = !msr_pr && msr_hv;
ctx.mem_idx = env->mmu_idx;
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = msr_vsx;
} else {
ctx.vsx_enabled = 0;
}
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
#if defined (DO_SINGLE_STEP) && 0
/* Single step trace mode */
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
tcg_clear_temp_count();
/* Set env in case of segfault during code fetch */
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = ctx.nip;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(need_byteswap(&ctx))) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx.nip);
}
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
/* Is opcode *REALLY* valid ? */
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
}
if (unlikely((ctx.opcode & inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
/* Check trace mode exceptions */
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
/* if we reach a page boundary or are single stepping, stop
* generation
*/
break;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode);
exit(1);
}
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
/* Generate the return instruction */
tcg_gen_exit_tb(0);
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| false | qemu | cd42d5b23691ad73edfd6dbcfc935a960a9c5a65 | static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.pr = msr_pr;
ctx.hv = !msr_pr && msr_hv;
ctx.mem_idx = env->mmu_idx;
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = msr_vsx;
} else {
ctx.vsx_enabled = 0;
}
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_tb_start();
tcg_clear_temp_count();
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = ctx.nip;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(need_byteswap(&ctx))) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx.nip);
}
ctx.nip += 4;
table = env->opcodes;
num_insns++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
}
if (unlikely((ctx.opcode & inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
num_insns >= max_insns)) {
break;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode);
exit(1);
}
}
if (tb->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.nip - pc_start;
tb->icount = num_insns;
}
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(PowerPCCPU *VAR_0,
TranslationBlock *VAR_1,
bool VAR_2)
{
CPUState *cs = CPU(VAR_0);
CPUPPCState *env = &VAR_0->env;
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int VAR_3, VAR_4 = -1;
int VAR_5;
int VAR_6;
pc_start = VAR_1->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.nip = pc_start;
ctx.VAR_1 = VAR_1;
ctx.exception = POWERPC_EXCP_NONE;
ctx.spr_cb = env->spr_cb;
ctx.pr = msr_pr;
ctx.hv = !msr_pr && msr_hv;
ctx.mem_idx = env->mmu_idx;
ctx.insns_flags = env->insns_flags;
ctx.insns_flags2 = env->insns_flags2;
ctx.access_type = -1;
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
#if defined(TARGET_PPC64)
ctx.sf_mode = msr_is_64bit(env, env->msr);
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
#endif
ctx.fpu_enabled = msr_fp;
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
ctx.spe_enabled = msr_spe;
else
ctx.spe_enabled = 0;
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
ctx.altivec_enabled = msr_vr;
else
ctx.altivec_enabled = 0;
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
ctx.vsx_enabled = msr_vsx;
} else {
ctx.vsx_enabled = 0;
}
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
ctx.singlestep_enabled = CPU_SINGLE_STEP;
else
ctx.singlestep_enabled = 0;
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
if (unlikely(cs->singlestep_enabled)) {
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
#if defined (DO_SINGLE_STEP) && 0
msr_se = 1;
#endif
VAR_5 = 0;
VAR_6 = VAR_1->cflags & CF_COUNT_MASK;
if (VAR_6 == 0)
VAR_6 = CF_COUNT_MASK;
gen_tb_start();
tcg_clear_temp_count();
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.nip) {
gen_debug_exception(ctxp);
break;
}
}
}
if (unlikely(VAR_2)) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (VAR_4 < VAR_3) {
VAR_4++;
while (VAR_4 < VAR_3)
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
tcg_ctx.gen_opc_pc[VAR_4] = ctx.nip;
tcg_ctx.gen_opc_instr_start[VAR_4] = 1;
tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;
}
LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(need_byteswap(&ctx))) {
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
} else {
ctx.opcode = cpu_ldl_code(env, ctx.nip);
}
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(ctx.nip);
}
ctx.nip += 4;
table = env->opcodes;
VAR_5++;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (unlikely(handler->handler == &gen_invalid)) {
if (qemu_log_enabled()) {
qemu_log("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
}
} else {
uint32_t inval;
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
inval = handler->inval2;
} else {
inval = handler->inval1;
}
if (unlikely((ctx.opcode & inval) != 0)) {
if (qemu_log_enabled()) {
qemu_log("invalid bits: %08x for opcode: "
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
ctx.opcode & inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
break;
}
}
(*(handler->handler))(&ctx);
#if defined(DO_PPC_STATISTICS)
handler->count++;
#endif
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
ctx.exception != POWERPC_SYSCALL &&
ctx.exception != POWERPC_EXCP_TRAP &&
ctx.exception != POWERPC_EXCP_BRANCH)) {
gen_exception(ctxp, POWERPC_EXCP_TRACE);
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
(cs->singlestep_enabled) ||
singlestep ||
VAR_5 >= VAR_6)) {
break;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode);
exit(1);
}
}
if (VAR_1->cflags & CF_LAST_IO)
gen_io_end();
if (ctx.exception == POWERPC_EXCP_NONE) {
gen_goto_tb(&ctx, 0, ctx.nip);
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
if (unlikely(cs->singlestep_enabled)) {
gen_debug_exception(ctxp);
}
tcg_gen_exit_tb(0);
}
gen_tb_end(VAR_1, VAR_5);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(VAR_2)) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
VAR_4++;
while (VAR_4 <= VAR_3)
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
} else {
VAR_1->size = ctx.nip - pc_start;
VAR_1->icount = VAR_5;
}
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
int flags;
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
}
| [
"static inline void FUNC_0(PowerPCCPU *VAR_0,\nTranslationBlock *VAR_1,\nbool VAR_2)\n{",
"CPUState *cs = CPU(VAR_0);",
"CPUPPCState *env = &VAR_0->env;",
"DisasContext ctx, *ctxp = &ctx;",
"opc_handler_t **table, *handler;",
"target_ulong pc_start;",
"uint16_t *gen_opc_end;",
"CPUBreakpoint *bp;",
"int VAR_3, VAR_4 = -1;",
"int VAR_5;",
"int VAR_6;",
"pc_start = VAR_1->pc;",
"gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;",
"ctx.nip = pc_start;",
"ctx.VAR_1 = VAR_1;",
"ctx.exception = POWERPC_EXCP_NONE;",
"ctx.spr_cb = env->spr_cb;",
"ctx.pr = msr_pr;",
"ctx.hv = !msr_pr && msr_hv;",
"ctx.mem_idx = env->mmu_idx;",
"ctx.insns_flags = env->insns_flags;",
"ctx.insns_flags2 = env->insns_flags2;",
"ctx.access_type = -1;",
"ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;",
"ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;",
"#if defined(TARGET_PPC64)\nctx.sf_mode = msr_is_64bit(env, env->msr);",
"ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);",
"#endif\nctx.fpu_enabled = msr_fp;",
"if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)\nctx.spe_enabled = msr_spe;",
"else\nctx.spe_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)\nctx.altivec_enabled = msr_vr;",
"else\nctx.altivec_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {",
"ctx.vsx_enabled = msr_vsx;",
"} else {",
"ctx.vsx_enabled = 0;",
"}",
"if ((env->flags & POWERPC_FLAG_SE) && msr_se)\nctx.singlestep_enabled = CPU_SINGLE_STEP;",
"else\nctx.singlestep_enabled = 0;",
"if ((env->flags & POWERPC_FLAG_BE) && msr_be)\nctx.singlestep_enabled |= CPU_BRANCH_STEP;",
"if (unlikely(cs->singlestep_enabled)) {",
"ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;",
"}",
"#if defined (DO_SINGLE_STEP) && 0\nmsr_se = 1;",
"#endif\nVAR_5 = 0;",
"VAR_6 = VAR_1->cflags & CF_COUNT_MASK;",
"if (VAR_6 == 0)\nVAR_6 = CF_COUNT_MASK;",
"gen_tb_start();",
"tcg_clear_temp_count();",
"while (ctx.exception == POWERPC_EXCP_NONE\n&& tcg_ctx.gen_opc_ptr < gen_opc_end) {",
"if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {",
"QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {",
"if (bp->pc == ctx.nip) {",
"gen_debug_exception(ctxp);",
"break;",
"}",
"}",
"}",
"if (unlikely(VAR_2)) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"if (VAR_4 < VAR_3) {",
"VAR_4++;",
"while (VAR_4 < VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"tcg_ctx.gen_opc_pc[VAR_4] = ctx.nip;",
"tcg_ctx.gen_opc_instr_start[VAR_4] = 1;",
"tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;",
"}",
"LOG_DISAS(\"----------------\\n\");",
"LOG_DISAS(\"nip=\" TARGET_FMT_lx \" super=%d ir=%d\\n\",\nctx.nip, ctx.mem_idx, (int)msr_ir);",
"if (VAR_5 + 1 == VAR_6 && (VAR_1->cflags & CF_LAST_IO))\ngen_io_start();",
"if (unlikely(need_byteswap(&ctx))) {",
"ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));",
"} else {",
"ctx.opcode = cpu_ldl_code(env, ctx.nip);",
"}",
"LOG_DISAS(\"translate opcode %08x (%02x %02x %02x) (%s)\\n\",\nctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.le_mode ? \"little\" : \"big\");",
"if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {",
"tcg_gen_debug_insn_start(ctx.nip);",
"}",
"ctx.nip += 4;",
"table = env->opcodes;",
"VAR_5++;",
"handler = table[opc1(ctx.opcode)];",
"if (is_indirect_opcode(handler)) {",
"table = ind_table(handler);",
"handler = table[opc2(ctx.opcode)];",
"if (is_indirect_opcode(handler)) {",
"table = ind_table(handler);",
"handler = table[opc3(ctx.opcode)];",
"}",
"}",
"if (unlikely(handler->handler == &gen_invalid)) {",
"if (qemu_log_enabled()) {",
"qemu_log(\"invalid/unsupported opcode: \"\n\"%02x - %02x - %02x (%08x) \" TARGET_FMT_lx \" %d\\n\",\nopc1(ctx.opcode), opc2(ctx.opcode),\nopc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);",
"}",
"} else {",
"uint32_t inval;",
"if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {",
"inval = handler->inval2;",
"} else {",
"inval = handler->inval1;",
"}",
"if (unlikely((ctx.opcode & inval) != 0)) {",
"if (qemu_log_enabled()) {",
"qemu_log(\"invalid bits: %08x for opcode: \"\n\"%02x - %02x - %02x (%08x) \" TARGET_FMT_lx \"\\n\",\nctx.opcode & inval, opc1(ctx.opcode),\nopc2(ctx.opcode), opc3(ctx.opcode),\nctx.opcode, ctx.nip - 4);",
"}",
"gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);",
"break;",
"}",
"}",
"(*(handler->handler))(&ctx);",
"#if defined(DO_PPC_STATISTICS)\nhandler->count++;",
"#endif\nif (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&\n(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&\nctx.exception != POWERPC_SYSCALL &&\nctx.exception != POWERPC_EXCP_TRAP &&\nctx.exception != POWERPC_EXCP_BRANCH)) {",
"gen_exception(ctxp, POWERPC_EXCP_TRACE);",
"} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||",
"(cs->singlestep_enabled) ||\nsinglestep ||\nVAR_5 >= VAR_6)) {",
"break;",
"}",
"if (tcg_check_temp_count()) {",
"fprintf(stderr, \"Opcode %02x %02x %02x (%08x) leaked temporaries\\n\",\nopc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),\nctx.opcode);",
"exit(1);",
"}",
"}",
"if (VAR_1->cflags & CF_LAST_IO)\ngen_io_end();",
"if (ctx.exception == POWERPC_EXCP_NONE) {",
"gen_goto_tb(&ctx, 0, ctx.nip);",
"} else if (ctx.exception != POWERPC_EXCP_BRANCH) {",
"if (unlikely(cs->singlestep_enabled)) {",
"gen_debug_exception(ctxp);",
"}",
"tcg_gen_exit_tb(0);",
"}",
"gen_tb_end(VAR_1, VAR_5);",
"*tcg_ctx.gen_opc_ptr = INDEX_op_end;",
"if (unlikely(VAR_2)) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"VAR_4++;",
"while (VAR_4 <= VAR_3)\ntcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"} else {",
"VAR_1->size = ctx.nip - pc_start;",
"VAR_1->icount = VAR_5;",
"}",
"#if defined(DEBUG_DISAS)\nif (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {",
"int flags;",
"flags = env->bfd_mach;",
"flags |= ctx.le_mode << 16;",
"qemu_log(\"IN: %s\\n\", lookup_symbol(pc_start));",
"log_target_disas(env, pc_start, ctx.nip - pc_start, flags);",
"qemu_log(\"\\n\");",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
73,
75
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99,
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113,
117
],
[
119,
121
],
[
123
],
[
125,
127
],
[
131
],
[
133
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181,
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199,
201,
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
241,
243,
245,
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273,
275,
277,
279,
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299,
303,
305,
307,
309,
311
],
[
313
],
[
315
],
[
317,
319,
321
],
[
329
],
[
331
],
[
333
],
[
335,
337,
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
377
],
[
379,
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
]
] |
1,859 | static void dma_aio_cancel(BlockDriverAIOCB *acb)
{
DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
if (dbs->acb) {
bdrv_aio_cancel(dbs->acb);
}
}
| true | qemu | c3adb5b9168a57790b5074489b6f0275ac3cc8b5 | static void dma_aio_cancel(BlockDriverAIOCB *acb)
{
DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
if (dbs->acb) {
bdrv_aio_cancel(dbs->acb);
}
}
| {
"code": [
" bdrv_aio_cancel(dbs->acb);"
],
"line_no": [
11
]
} | static void FUNC_0(BlockDriverAIOCB *VAR_0)
{
DMAAIOCB *dbs = container_of(VAR_0, DMAAIOCB, common);
if (dbs->VAR_0) {
bdrv_aio_cancel(dbs->VAR_0);
}
}
| [
"static void FUNC_0(BlockDriverAIOCB *VAR_0)\n{",
"DMAAIOCB *dbs = container_of(VAR_0, DMAAIOCB, common);",
"if (dbs->VAR_0) {",
"bdrv_aio_cancel(dbs->VAR_0);",
"}",
"}"
] | [
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
1,860 | int32_t idiv32(int32_t *q_ptr, int64_t num, int32_t den)
{
*q_ptr = num / den;
return num % den;
}
| true | qemu | 45bbbb466cf4a6280076ea5a51f67ef5bedee345 | int32_t idiv32(int32_t *q_ptr, int64_t num, int32_t den)
{
*q_ptr = num / den;
return num % den;
}
| {
"code": [
"int32_t idiv32(int32_t *q_ptr, int64_t num, int32_t den)"
],
"line_no": [
1
]
} | int32_t FUNC_0(int32_t *q_ptr, int64_t num, int32_t den)
{
*q_ptr = num / den;
return num % den;
}
| [
"int32_t FUNC_0(int32_t *q_ptr, int64_t num, int32_t den)\n{",
"*q_ptr = num / den;",
"return num % den;",
"}"
] | [
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,861 | void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
Error **errp)
{
BlockDriverState *bs;
NBDExport *exp;
NBDCloseNotifier *n;
if (server_fd == -1) {
error_setg(errp, "NBD server not running");
return;
}
if (nbd_export_find(device)) {
error_setg(errp, "NBD server already exporting device '%s'", device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_writable) {
writable = false;
}
if (bdrv_is_read_only(bs)) {
writable = false;
}
exp = nbd_export_new(bs, 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY, NULL);
nbd_export_set_name(exp, device);
n = g_malloc0(sizeof(NBDCloseNotifier));
n->n.notify = nbd_close_notifier;
n->exp = exp;
bdrv_add_close_notifier(bs, &n->n);
QTAILQ_INSERT_TAIL(&close_notifiers, n, next);
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
Error **errp)
{
BlockDriverState *bs;
NBDExport *exp;
NBDCloseNotifier *n;
if (server_fd == -1) {
error_setg(errp, "NBD server not running");
return;
}
if (nbd_export_find(device)) {
error_setg(errp, "NBD server already exporting device '%s'", device);
return;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_writable) {
writable = false;
}
if (bdrv_is_read_only(bs)) {
writable = false;
}
exp = nbd_export_new(bs, 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY, NULL);
nbd_export_set_name(exp, device);
n = g_malloc0(sizeof(NBDCloseNotifier));
n->n.notify = nbd_close_notifier;
n->exp = exp;
bdrv_add_close_notifier(bs, &n->n);
QTAILQ_INSERT_TAIL(&close_notifiers, n, next);
}
| {
"code": [
" n = g_malloc0(sizeof(NBDCloseNotifier));"
],
"line_no": [
77
]
} | void FUNC_0(const char *VAR_0, bool VAR_1, bool VAR_2,
Error **VAR_3)
{
BlockDriverState *bs;
NBDExport *exp;
NBDCloseNotifier *n;
if (server_fd == -1) {
error_setg(VAR_3, "NBD server not running");
return;
}
if (nbd_export_find(VAR_0)) {
error_setg(VAR_3, "NBD server already exporting VAR_0 '%s'", VAR_0);
return;
}
bs = bdrv_find(VAR_0);
if (!bs) {
error_set(VAR_3, QERR_DEVICE_NOT_FOUND, VAR_0);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(VAR_3, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);
return;
}
if (!VAR_1) {
VAR_2 = false;
}
if (bdrv_is_read_only(bs)) {
VAR_2 = false;
}
exp = nbd_export_new(bs, 0, -1, VAR_2 ? 0 : NBD_FLAG_READ_ONLY, NULL);
nbd_export_set_name(exp, VAR_0);
n = g_malloc0(sizeof(NBDCloseNotifier));
n->n.notify = nbd_close_notifier;
n->exp = exp;
bdrv_add_close_notifier(bs, &n->n);
QTAILQ_INSERT_TAIL(&close_notifiers, n, next);
}
| [
"void FUNC_0(const char *VAR_0, bool VAR_1, bool VAR_2,\nError **VAR_3)\n{",
"BlockDriverState *bs;",
"NBDExport *exp;",
"NBDCloseNotifier *n;",
"if (server_fd == -1) {",
"error_setg(VAR_3, \"NBD server not running\");",
"return;",
"}",
"if (nbd_export_find(VAR_0)) {",
"error_setg(VAR_3, \"NBD server already exporting VAR_0 '%s'\", VAR_0);",
"return;",
"}",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"error_set(VAR_3, QERR_DEVICE_NOT_FOUND, VAR_0);",
"return;",
"}",
"if (!bdrv_is_inserted(bs)) {",
"error_set(VAR_3, QERR_DEVICE_HAS_NO_MEDIUM, VAR_0);",
"return;",
"}",
"if (!VAR_1) {",
"VAR_2 = false;",
"}",
"if (bdrv_is_read_only(bs)) {",
"VAR_2 = false;",
"}",
"exp = nbd_export_new(bs, 0, -1, VAR_2 ? 0 : NBD_FLAG_READ_ONLY, NULL);",
"nbd_export_set_name(exp, VAR_0);",
"n = g_malloc0(sizeof(NBDCloseNotifier));",
"n->n.notify = nbd_close_notifier;",
"n->exp = exp;",
"bdrv_add_close_notifier(bs, &n->n);",
"QTAILQ_INSERT_TAIL(&close_notifiers, n, next);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
1,862 | static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
{
const int nl = output->linesize[0]>>2;
const int nl1 = nl + nl;
uint32_t pprev;
uint32_t pprev2;
int x,y;
for (y = 0; y < input->height; y++) {
uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 3);
/* middle. Offset of -8 is given */
uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
/* up one */
uint32_t * sa1 = sa2 - (input->linesize[0]>>2);
/* up two */
uint32_t * sa0 = sa1 - (input->linesize[0]>>2);
/* down one */
uint32_t * sa3 = sa2 + (input->linesize[0]>>2);
/* down two */
uint32_t * sa4 = sa3 + (input->linesize[0]>>2);
if (y <= 1){
sa0 = sa1;
if (y == 0){
sa0 = sa1 = sa2;
}
}
if (y >= input->height - 2){
sa4 = sa3;
if (y == input->height - 1){
sa4 = sa3 = sa2;
}
}
pprev = pprev2 = 2;
for (x = 0; x < input->width; x++){
uint32_t B1 = sa0[2];
uint32_t PB = sa1[2];
uint32_t PE = sa2[2];
uint32_t PH = sa3[2];
uint32_t H5 = sa4[2];
uint32_t A1 = sa0[pprev];
uint32_t PA = sa1[pprev];
uint32_t PD = sa2[pprev];
uint32_t PG = sa3[pprev];
uint32_t G5 = sa4[pprev];
uint32_t A0 = sa1[pprev2];
uint32_t D0 = sa2[pprev2];
uint32_t G0 = sa3[pprev2];
uint32_t C1 = 0;
uint32_t PC = 0;
uint32_t PF = 0;
uint32_t PI = 0;
uint32_t I5 = 0;
uint32_t C4 = 0;
uint32_t F4 = 0;
uint32_t I4 = 0;
if (x >= input->width - 2){
if (x == input->width - 1){
C1 = sa0[2];
PC = sa1[2];
PF = sa2[2];
PI = sa3[2];
I5 = sa4[2];
C4 = sa1[2];
F4 = sa2[2];
I4 = sa3[2];
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[3];
F4 = sa2[3];
I4 = sa3[3];
}
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[4];
F4 = sa2[4];
I4 = sa3[4];
}
E[0] = E[1] = E[2] = PE;
E[nl] = E[nl+1] = E[nl+2] = PE; // 3, 4, 5
E[nl1] = E[nl1+1] = E[nl1+2] = PE; // 6, 7, 8
FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, nl, nl+1, nl+2, nl1, nl1+1, nl1+2);
FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, nl1, nl, 0, nl1+1, nl+1, 1, nl1+2, nl+2, 2);
FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, nl1+2, nl1+1, nl1, nl+2, nl+1, nl, 2, 1, 0);
FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, nl+2, nl1+2, 1, nl+1, nl1+1, 0, nl, nl1);
sa0 += 1;
sa1 += 1;
sa2 += 1;
sa3 += 1;
sa4 += 1;
E += 3;
if (pprev2){
pprev2--;
pprev = 1;
}
}
}
}
| true | FFmpeg | e0704840404381c7b976a35db4004deca4495a22 | static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
{
const int nl = output->linesize[0]>>2;
const int nl1 = nl + nl;
uint32_t pprev;
uint32_t pprev2;
int x,y;
for (y = 0; y < input->height; y++) {
uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 3);
uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
uint32_t * sa1 = sa2 - (input->linesize[0]>>2);
uint32_t * sa0 = sa1 - (input->linesize[0]>>2);
uint32_t * sa3 = sa2 + (input->linesize[0]>>2);
uint32_t * sa4 = sa3 + (input->linesize[0]>>2);
if (y <= 1){
sa0 = sa1;
if (y == 0){
sa0 = sa1 = sa2;
}
}
if (y >= input->height - 2){
sa4 = sa3;
if (y == input->height - 1){
sa4 = sa3 = sa2;
}
}
pprev = pprev2 = 2;
for (x = 0; x < input->width; x++){
uint32_t B1 = sa0[2];
uint32_t PB = sa1[2];
uint32_t PE = sa2[2];
uint32_t PH = sa3[2];
uint32_t H5 = sa4[2];
uint32_t A1 = sa0[pprev];
uint32_t PA = sa1[pprev];
uint32_t PD = sa2[pprev];
uint32_t PG = sa3[pprev];
uint32_t G5 = sa4[pprev];
uint32_t A0 = sa1[pprev2];
uint32_t D0 = sa2[pprev2];
uint32_t G0 = sa3[pprev2];
uint32_t C1 = 0;
uint32_t PC = 0;
uint32_t PF = 0;
uint32_t PI = 0;
uint32_t I5 = 0;
uint32_t C4 = 0;
uint32_t F4 = 0;
uint32_t I4 = 0;
if (x >= input->width - 2){
if (x == input->width - 1){
C1 = sa0[2];
PC = sa1[2];
PF = sa2[2];
PI = sa3[2];
I5 = sa4[2];
C4 = sa1[2];
F4 = sa2[2];
I4 = sa3[2];
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[3];
F4 = sa2[3];
I4 = sa3[3];
}
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[4];
F4 = sa2[4];
I4 = sa3[4];
}
E[0] = E[1] = E[2] = PE;
E[nl] = E[nl+1] = E[nl+2] = PE;
E[nl1] = E[nl1+1] = E[nl1+2] = PE;
FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, nl, nl+1, nl+2, nl1, nl1+1, nl1+2);
FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, nl1, nl, 0, nl1+1, nl+1, 1, nl1+2, nl+2, 2);
FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, nl1+2, nl1+1, nl1, nl+2, nl+1, nl, 2, 1, 0);
FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, nl+2, nl1+2, 1, nl+1, nl1+1, 0, nl, nl1);
sa0 += 1;
sa1 += 1;
sa2 += 1;
sa3 += 1;
sa4 += 1;
E += 3;
if (pprev2){
pprev2--;
pprev = 1;
}
}
}
}
| {
"code": [
" pprev = pprev2 = 2;",
" uint32_t C1 = 0;",
" uint32_t PC = 0;",
" uint32_t PF = 0;",
" uint32_t PI = 0;",
" uint32_t I5 = 0;",
" uint32_t C4 = 0;",
" uint32_t F4 = 0;",
" uint32_t I4 = 0;",
" C1 = sa0[2];",
" PC = sa1[2];",
" PF = sa2[2];",
" PI = sa3[2];",
" I5 = sa4[2];",
" C4 = sa1[2];",
" F4 = sa2[2];",
" I4 = sa3[2];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[3];",
" F4 = sa2[3];",
" I4 = sa3[3];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[4];",
" F4 = sa2[4];",
" I4 = sa3[4];",
" if (pprev2){",
" pprev2--;",
" pprev = 1;",
" uint32_t pprev;",
" uint32_t pprev2;",
" pprev = pprev2 = 2;",
" uint32_t C1 = 0;",
" uint32_t PC = 0;",
" uint32_t PF = 0;",
" uint32_t PI = 0;",
" uint32_t I5 = 0;",
" uint32_t C4 = 0;",
" uint32_t F4 = 0;",
" uint32_t I4 = 0;",
" if (x >= input->width - 2){",
" if (x == input->width - 1){",
" C1 = sa0[2];",
" PC = sa1[2];",
" PF = sa2[2];",
" PI = sa3[2];",
" I5 = sa4[2];",
" C4 = sa1[2];",
" F4 = sa2[2];",
" I4 = sa3[2];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[3];",
" F4 = sa2[3];",
" I4 = sa3[3];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[4];",
" F4 = sa2[4];",
" I4 = sa3[4];",
" if (pprev2){",
" pprev2--;",
" pprev = 1;",
" uint32_t pprev;",
" uint32_t pprev2;",
" pprev = pprev2 = 2;",
" uint32_t C1 = 0;",
" uint32_t PC = 0;",
" uint32_t PF = 0;",
" uint32_t PI = 0;",
" uint32_t I5 = 0;",
" uint32_t C4 = 0;",
" uint32_t F4 = 0;",
" uint32_t I4 = 0;",
" C1 = sa0[2];",
" PC = sa1[2];",
" PF = sa2[2];",
" PI = sa3[2];",
" I5 = sa4[2];",
" C4 = sa1[2];",
" F4 = sa2[2];",
" I4 = sa3[2];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[3];",
" F4 = sa2[3];",
" I4 = sa3[3];",
" } else {",
" C1 = sa0[3];",
" PC = sa1[3];",
" PF = sa2[3];",
" PI = sa3[3];",
" I5 = sa4[3];",
" C4 = sa1[4];",
" F4 = sa2[4];",
" I4 = sa3[4];",
" if (pprev2){",
" pprev2--;",
" pprev = 1;"
],
"line_no": [
77,
115,
117,
119,
121,
123,
127,
129,
131,
139,
141,
143,
145,
147,
151,
153,
155,
157,
159,
161,
163,
165,
167,
171,
173,
175,
179,
181,
183,
185,
187,
189,
193,
195,
197,
237,
239,
241,
9,
11,
77,
115,
117,
119,
121,
123,
127,
129,
131,
135,
137,
139,
141,
143,
145,
147,
151,
153,
155,
157,
159,
161,
163,
165,
167,
171,
173,
175,
179,
181,
183,
185,
187,
189,
193,
195,
197,
237,
239,
241,
9,
11,
77,
115,
117,
119,
121,
123,
127,
129,
131,
139,
141,
143,
145,
147,
151,
153,
155,
157,
159,
161,
163,
165,
167,
171,
173,
175,
179,
181,
183,
185,
187,
189,
193,
195,
197,
237,
239,
241
]
} | static void FUNC_0(AVFrame *VAR_0, AVFrame *VAR_1, const uint32_t *VAR_2)
{
const int VAR_3 = VAR_1->linesize[0]>>2;
const int VAR_4 = VAR_3 + VAR_3;
uint32_t pprev;
uint32_t pprev2;
int VAR_5,VAR_6;
for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {
uint32_t * E = (uint32_t *)(VAR_1->data[0] + VAR_6 * VAR_1->linesize[0] * 3);
uint32_t * sa2 = (uint32_t *)(VAR_0->data[0] + VAR_6 * VAR_0->linesize[0] - 8);
uint32_t * sa1 = sa2 - (VAR_0->linesize[0]>>2);
uint32_t * sa0 = sa1 - (VAR_0->linesize[0]>>2);
uint32_t * sa3 = sa2 + (VAR_0->linesize[0]>>2);
uint32_t * sa4 = sa3 + (VAR_0->linesize[0]>>2);
if (VAR_6 <= 1){
sa0 = sa1;
if (VAR_6 == 0){
sa0 = sa1 = sa2;
}
}
if (VAR_6 >= VAR_0->height - 2){
sa4 = sa3;
if (VAR_6 == VAR_0->height - 1){
sa4 = sa3 = sa2;
}
}
pprev = pprev2 = 2;
for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++){
uint32_t B1 = sa0[2];
uint32_t PB = sa1[2];
uint32_t PE = sa2[2];
uint32_t PH = sa3[2];
uint32_t H5 = sa4[2];
uint32_t A1 = sa0[pprev];
uint32_t PA = sa1[pprev];
uint32_t PD = sa2[pprev];
uint32_t PG = sa3[pprev];
uint32_t G5 = sa4[pprev];
uint32_t A0 = sa1[pprev2];
uint32_t D0 = sa2[pprev2];
uint32_t G0 = sa3[pprev2];
uint32_t C1 = 0;
uint32_t PC = 0;
uint32_t PF = 0;
uint32_t PI = 0;
uint32_t I5 = 0;
uint32_t C4 = 0;
uint32_t F4 = 0;
uint32_t I4 = 0;
if (VAR_5 >= VAR_0->width - 2){
if (VAR_5 == VAR_0->width - 1){
C1 = sa0[2];
PC = sa1[2];
PF = sa2[2];
PI = sa3[2];
I5 = sa4[2];
C4 = sa1[2];
F4 = sa2[2];
I4 = sa3[2];
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[3];
F4 = sa2[3];
I4 = sa3[3];
}
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[4];
F4 = sa2[4];
I4 = sa3[4];
}
E[0] = E[1] = E[2] = PE;
E[VAR_3] = E[VAR_3+1] = E[VAR_3+2] = PE;
E[VAR_4] = E[VAR_4+1] = E[VAR_4+2] = PE;
FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, VAR_3, VAR_3+1, VAR_3+2, VAR_4, VAR_4+1, VAR_4+2);
FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, VAR_4, VAR_3, 0, VAR_4+1, VAR_3+1, 1, VAR_4+2, VAR_3+2, 2);
FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, VAR_4+2, VAR_4+1, VAR_4, VAR_3+2, VAR_3+1, VAR_3, 2, 1, 0);
FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, VAR_3+2, VAR_4+2, 1, VAR_3+1, VAR_4+1, 0, VAR_3, VAR_4);
sa0 += 1;
sa1 += 1;
sa2 += 1;
sa3 += 1;
sa4 += 1;
E += 3;
if (pprev2){
pprev2--;
pprev = 1;
}
}
}
}
| [
"static void FUNC_0(AVFrame *VAR_0, AVFrame *VAR_1, const uint32_t *VAR_2)\n{",
"const int VAR_3 = VAR_1->linesize[0]>>2;",
"const int VAR_4 = VAR_3 + VAR_3;",
"uint32_t pprev;",
"uint32_t pprev2;",
"int VAR_5,VAR_6;",
"for (VAR_6 = 0; VAR_6 < VAR_0->height; VAR_6++) {",
"uint32_t * E = (uint32_t *)(VAR_1->data[0] + VAR_6 * VAR_1->linesize[0] * 3);",
"uint32_t * sa2 = (uint32_t *)(VAR_0->data[0] + VAR_6 * VAR_0->linesize[0] - 8);",
"uint32_t * sa1 = sa2 - (VAR_0->linesize[0]>>2);",
"uint32_t * sa0 = sa1 - (VAR_0->linesize[0]>>2);",
"uint32_t * sa3 = sa2 + (VAR_0->linesize[0]>>2);",
"uint32_t * sa4 = sa3 + (VAR_0->linesize[0]>>2);",
"if (VAR_6 <= 1){",
"sa0 = sa1;",
"if (VAR_6 == 0){",
"sa0 = sa1 = sa2;",
"}",
"}",
"if (VAR_6 >= VAR_0->height - 2){",
"sa4 = sa3;",
"if (VAR_6 == VAR_0->height - 1){",
"sa4 = sa3 = sa2;",
"}",
"}",
"pprev = pprev2 = 2;",
"for (VAR_5 = 0; VAR_5 < VAR_0->width; VAR_5++){",
"uint32_t B1 = sa0[2];",
"uint32_t PB = sa1[2];",
"uint32_t PE = sa2[2];",
"uint32_t PH = sa3[2];",
"uint32_t H5 = sa4[2];",
"uint32_t A1 = sa0[pprev];",
"uint32_t PA = sa1[pprev];",
"uint32_t PD = sa2[pprev];",
"uint32_t PG = sa3[pprev];",
"uint32_t G5 = sa4[pprev];",
"uint32_t A0 = sa1[pprev2];",
"uint32_t D0 = sa2[pprev2];",
"uint32_t G0 = sa3[pprev2];",
"uint32_t C1 = 0;",
"uint32_t PC = 0;",
"uint32_t PF = 0;",
"uint32_t PI = 0;",
"uint32_t I5 = 0;",
"uint32_t C4 = 0;",
"uint32_t F4 = 0;",
"uint32_t I4 = 0;",
"if (VAR_5 >= VAR_0->width - 2){",
"if (VAR_5 == VAR_0->width - 1){",
"C1 = sa0[2];",
"PC = sa1[2];",
"PF = sa2[2];",
"PI = sa3[2];",
"I5 = sa4[2];",
"C4 = sa1[2];",
"F4 = sa2[2];",
"I4 = sa3[2];",
"} else {",
"C1 = sa0[3];",
"PC = sa1[3];",
"PF = sa2[3];",
"PI = sa3[3];",
"I5 = sa4[3];",
"C4 = sa1[3];",
"F4 = sa2[3];",
"I4 = sa3[3];",
"}",
"} else {",
"C1 = sa0[3];",
"PC = sa1[3];",
"PF = sa2[3];",
"PI = sa3[3];",
"I5 = sa4[3];",
"C4 = sa1[4];",
"F4 = sa2[4];",
"I4 = sa3[4];",
"}",
"E[0] = E[1] = E[2] = PE;",
"E[VAR_3] = E[VAR_3+1] = E[VAR_3+2] = PE;",
"E[VAR_4] = E[VAR_4+1] = E[VAR_4+2] = PE;",
"FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, VAR_3, VAR_3+1, VAR_3+2, VAR_4, VAR_4+1, VAR_4+2);",
"FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, VAR_4, VAR_3, 0, VAR_4+1, VAR_3+1, 1, VAR_4+2, VAR_3+2, 2);",
"FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, VAR_4+2, VAR_4+1, VAR_4, VAR_3+2, VAR_3+1, VAR_3, 2, 1, 0);",
"FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, VAR_3+2, VAR_4+2, 1, VAR_3+1, VAR_4+1, 0, VAR_3, VAR_4);",
"sa0 += 1;",
"sa1 += 1;",
"sa2 += 1;",
"sa3 += 1;",
"sa4 += 1;",
"E += 3;",
"if (pprev2){",
"pprev2--;",
"pprev = 1;",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
23
],
[
29
],
[
33
],
[
37
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
233
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
]
] |
1,863 | qio_channel_websock_source_prepare(GSource *source,
gint *timeout)
{
QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source;
GIOCondition cond = 0;
*timeout = -1;
if (wsource->wioc->rawinput.offset) {
cond |= G_IO_IN;
}
if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
cond |= G_IO_OUT;
}
return cond & wsource->condition;
}
| true | qemu | eefa3d8ef649f9055611361e2201cca49f8c3433 | qio_channel_websock_source_prepare(GSource *source,
gint *timeout)
{
QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source;
GIOCondition cond = 0;
*timeout = -1;
if (wsource->wioc->rawinput.offset) {
cond |= G_IO_IN;
}
if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
cond |= G_IO_OUT;
}
return cond & wsource->condition;
}
| {
"code": [
"qio_channel_websock_source_prepare(GSource *source,",
" gint *timeout)",
" *timeout = -1;",
" if (wsource->wioc->rawinput.offset) {",
" QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source;",
" GIOCondition cond = 0;",
" if (wsource->wioc->rawinput.offset) {",
" cond |= G_IO_IN;",
" if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {",
" cond |= G_IO_OUT;",
" return cond & wsource->condition;",
" GIOCondition cond = 0;",
" if (wsource->wioc->rawinput.offset) {",
" cond |= G_IO_IN;",
" if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {",
" cond |= G_IO_OUT;"
],
"line_no": [
1,
3,
11,
15,
7,
9,
15,
17,
21,
23,
29,
9,
15,
17,
21,
23
]
} | FUNC_0(GSource *VAR_0,
gint *VAR_1)
{
QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)VAR_0;
GIOCondition cond = 0;
*VAR_1 = -1;
if (wsource->wioc->rawinput.offset) {
cond |= G_IO_IN;
}
if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
cond |= G_IO_OUT;
}
return cond & wsource->condition;
}
| [
"FUNC_0(GSource *VAR_0,\ngint *VAR_1)\n{",
"QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)VAR_0;",
"GIOCondition cond = 0;",
"*VAR_1 = -1;",
"if (wsource->wioc->rawinput.offset) {",
"cond |= G_IO_IN;",
"}",
"if (wsource->wioc->rawoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {",
"cond |= G_IO_OUT;",
"}",
"return cond & wsource->condition;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
]
] |
1,864 | static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
vorbis_floor_data *vfu, float *vec)
{
vorbis_floor1 *vf = &vfu->t1;
GetBitContext *gb = &vc->gb;
uint_fast16_t range_v[4] = { 256, 128, 86, 64 };
uint_fast16_t range = range_v[vf->multiplier-1];
uint_fast16_t floor1_Y[258];
uint_fast16_t floor1_Y_final[258];
int floor1_flag[258];
uint_fast8_t class_;
uint_fast8_t cdim;
uint_fast8_t cbits;
uint_fast8_t csub;
uint_fast8_t cval;
int_fast16_t book;
uint_fast16_t offset;
uint_fast16_t i,j;
/*u*/int_fast16_t adx, ady, off, predicted; // WTF ? dy/adx = (unsigned)dy/adx ?
int_fast16_t dy, err;
if (!get_bits1(gb)) // silence
return 1;
// Read values (or differences) for the floor's points
floor1_Y[0] = get_bits(gb, ilog(range - 1));
floor1_Y[1] = get_bits(gb, ilog(range - 1));
AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
offset = 2;
for (i = 0; i < vf->partitions; ++i) {
class_ = vf->partition_class[i];
cdim = vf->class_dimensions[class_];
cbits = vf->class_subclasses[class_];
csub = (1 << cbits) - 1;
cval = 0;
AV_DEBUG("Cbits %d \n", cbits);
if (cbits) // this reads all subclasses for this partition's class
cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table,
vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3);
for (j = 0; j < cdim; ++j) {
book = vf->subclass_books[class_][cval & csub];
AV_DEBUG("book %d Cbits %d cval %d bits:%d \n", book, cbits, cval, get_bits_count(gb));
cval = cval >> cbits;
if (book > -1) {
floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,
vc->codebooks[book].nb_bits, 3);
} else {
floor1_Y[offset+j] = 0;
}
AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]);
}
offset+=cdim;
}
// Amplitude calculation from the differences
floor1_flag[0] = 1;
floor1_flag[1] = 1;
floor1_Y_final[0] = floor1_Y[0];
floor1_Y_final[1] = floor1_Y[1];
for (i = 2; i < vf->x_list_dim; ++i) {
uint_fast16_t val, highroom, lowroom, room;
uint_fast16_t high_neigh_offs;
uint_fast16_t low_neigh_offs;
low_neigh_offs = vf->list[i].low;
high_neigh_offs = vf->list[i].high;
dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs]; // render_point begin
adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;
ady = FFABS(dy);
err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);
off = (int16_t)err / (int16_t)adx;
if (dy < 0) {
predicted = floor1_Y_final[low_neigh_offs] - off;
} else {
predicted = floor1_Y_final[low_neigh_offs] + off;
} // render_point end
val = floor1_Y[i];
highroom = range-predicted;
lowroom = predicted;
if (highroom < lowroom) {
room = highroom * 2;
} else {
room = lowroom * 2; // SPEC mispelling
}
if (val) {
floor1_flag[low_neigh_offs] = 1;
floor1_flag[high_neigh_offs] = 1;
floor1_flag[i] = 1;
if (val >= room) {
if (highroom > lowroom) {
floor1_Y_final[i] = val - lowroom + predicted;
} else {
floor1_Y_final[i] = predicted - val + highroom - 1;
}
} else {
if (val & 1) {
floor1_Y_final[i] = predicted - (val + 1) / 2;
} else {
floor1_Y_final[i] = predicted + val / 2;
}
}
} else {
floor1_flag[i] = 0;
floor1_Y_final[i] = predicted;
}
AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val);
}
// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?
ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);
AV_DEBUG(" Floor decoded\n");
return 0;
}
| true | FFmpeg | 3dde66752d59dfdd0f3727efd66e7202b3c75078 | static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
vorbis_floor_data *vfu, float *vec)
{
vorbis_floor1 *vf = &vfu->t1;
GetBitContext *gb = &vc->gb;
uint_fast16_t range_v[4] = { 256, 128, 86, 64 };
uint_fast16_t range = range_v[vf->multiplier-1];
uint_fast16_t floor1_Y[258];
uint_fast16_t floor1_Y_final[258];
int floor1_flag[258];
uint_fast8_t class_;
uint_fast8_t cdim;
uint_fast8_t cbits;
uint_fast8_t csub;
uint_fast8_t cval;
int_fast16_t book;
uint_fast16_t offset;
uint_fast16_t i,j;
int_fast16_t adx, ady, off, predicted;
int_fast16_t dy, err;
if (!get_bits1(gb))
return 1;
floor1_Y[0] = get_bits(gb, ilog(range - 1));
floor1_Y[1] = get_bits(gb, ilog(range - 1));
AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
offset = 2;
for (i = 0; i < vf->partitions; ++i) {
class_ = vf->partition_class[i];
cdim = vf->class_dimensions[class_];
cbits = vf->class_subclasses[class_];
csub = (1 << cbits) - 1;
cval = 0;
AV_DEBUG("Cbits %d \n", cbits);
if (cbits)
cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table,
vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3);
for (j = 0; j < cdim; ++j) {
book = vf->subclass_books[class_][cval & csub];
AV_DEBUG("book %d Cbits %d cval %d bits:%d \n", book, cbits, cval, get_bits_count(gb));
cval = cval >> cbits;
if (book > -1) {
floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,
vc->codebooks[book].nb_bits, 3);
} else {
floor1_Y[offset+j] = 0;
}
AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]);
}
offset+=cdim;
}
floor1_flag[0] = 1;
floor1_flag[1] = 1;
floor1_Y_final[0] = floor1_Y[0];
floor1_Y_final[1] = floor1_Y[1];
for (i = 2; i < vf->x_list_dim; ++i) {
uint_fast16_t val, highroom, lowroom, room;
uint_fast16_t high_neigh_offs;
uint_fast16_t low_neigh_offs;
low_neigh_offs = vf->list[i].low;
high_neigh_offs = vf->list[i].high;
dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];
adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;
ady = FFABS(dy);
err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);
off = (int16_t)err / (int16_t)adx;
if (dy < 0) {
predicted = floor1_Y_final[low_neigh_offs] - off;
} else {
predicted = floor1_Y_final[low_neigh_offs] + off;
}
val = floor1_Y[i];
highroom = range-predicted;
lowroom = predicted;
if (highroom < lowroom) {
room = highroom * 2;
} else {
room = lowroom * 2;
}
if (val) {
floor1_flag[low_neigh_offs] = 1;
floor1_flag[high_neigh_offs] = 1;
floor1_flag[i] = 1;
if (val >= room) {
if (highroom > lowroom) {
floor1_Y_final[i] = val - lowroom + predicted;
} else {
floor1_Y_final[i] = predicted - val + highroom - 1;
}
} else {
if (val & 1) {
floor1_Y_final[i] = predicted - (val + 1) / 2;
} else {
floor1_Y_final[i] = predicted + val / 2;
}
}
} else {
floor1_flag[i] = 0;
floor1_Y_final[i] = predicted;
}
AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val);
}
ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);
AV_DEBUG(" Floor decoded\n");
return 0;
}
| {
"code": [
"static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,",
" vorbis_floor_data *vfu, float *vec)",
"static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,",
" vorbis_floor_data *vfu, float *vec)"
],
"line_no": [
1,
3,
1,
3
]
} | static uint_fast8_t FUNC_0(vorbis_context *vc,
vorbis_floor_data *vfu, float *vec)
{
vorbis_floor1 *vf = &vfu->t1;
GetBitContext *gb = &vc->gb;
uint_fast16_t range_v[4] = { 256, 128, 86, 64 };
uint_fast16_t range = range_v[vf->multiplier-1];
uint_fast16_t floor1_Y[258];
uint_fast16_t floor1_Y_final[258];
int VAR_0[258];
uint_fast8_t class_;
uint_fast8_t cdim;
uint_fast8_t cbits;
uint_fast8_t csub;
uint_fast8_t cval;
int_fast16_t book;
uint_fast16_t offset;
uint_fast16_t i,j;
int_fast16_t adx, ady, off, predicted;
int_fast16_t dy, err;
if (!get_bits1(gb))
return 1;
floor1_Y[0] = get_bits(gb, ilog(range - 1));
floor1_Y[1] = get_bits(gb, ilog(range - 1));
AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
offset = 2;
for (i = 0; i < vf->partitions; ++i) {
class_ = vf->partition_class[i];
cdim = vf->class_dimensions[class_];
cbits = vf->class_subclasses[class_];
csub = (1 << cbits) - 1;
cval = 0;
AV_DEBUG("Cbits %d \n", cbits);
if (cbits)
cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table,
vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3);
for (j = 0; j < cdim; ++j) {
book = vf->subclass_books[class_][cval & csub];
AV_DEBUG("book %d Cbits %d cval %d bits:%d \n", book, cbits, cval, get_bits_count(gb));
cval = cval >> cbits;
if (book > -1) {
floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,
vc->codebooks[book].nb_bits, 3);
} else {
floor1_Y[offset+j] = 0;
}
AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]);
}
offset+=cdim;
}
VAR_0[0] = 1;
VAR_0[1] = 1;
floor1_Y_final[0] = floor1_Y[0];
floor1_Y_final[1] = floor1_Y[1];
for (i = 2; i < vf->x_list_dim; ++i) {
uint_fast16_t val, highroom, lowroom, room;
uint_fast16_t high_neigh_offs;
uint_fast16_t low_neigh_offs;
low_neigh_offs = vf->list[i].low;
high_neigh_offs = vf->list[i].high;
dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];
adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;
ady = FFABS(dy);
err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);
off = (int16_t)err / (int16_t)adx;
if (dy < 0) {
predicted = floor1_Y_final[low_neigh_offs] - off;
} else {
predicted = floor1_Y_final[low_neigh_offs] + off;
}
val = floor1_Y[i];
highroom = range-predicted;
lowroom = predicted;
if (highroom < lowroom) {
room = highroom * 2;
} else {
room = lowroom * 2;
}
if (val) {
VAR_0[low_neigh_offs] = 1;
VAR_0[high_neigh_offs] = 1;
VAR_0[i] = 1;
if (val >= room) {
if (highroom > lowroom) {
floor1_Y_final[i] = val - lowroom + predicted;
} else {
floor1_Y_final[i] = predicted - val + highroom - 1;
}
} else {
if (val & 1) {
floor1_Y_final[i] = predicted - (val + 1) / 2;
} else {
floor1_Y_final[i] = predicted + val / 2;
}
}
} else {
VAR_0[i] = 0;
floor1_Y_final[i] = predicted;
}
AV_DEBUG(" Decoded floor(%d) = %d / val %d \n", vf->list[i].x, floor1_Y_final[i], val);
}
ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, VAR_0, vf->multiplier, vec, vf->list[1].x);
AV_DEBUG(" Floor decoded\n");
return 0;
}
| [
"static uint_fast8_t FUNC_0(vorbis_context *vc,\nvorbis_floor_data *vfu, float *vec)\n{",
"vorbis_floor1 *vf = &vfu->t1;",
"GetBitContext *gb = &vc->gb;",
"uint_fast16_t range_v[4] = { 256, 128, 86, 64 };",
"uint_fast16_t range = range_v[vf->multiplier-1];",
"uint_fast16_t floor1_Y[258];",
"uint_fast16_t floor1_Y_final[258];",
"int VAR_0[258];",
"uint_fast8_t class_;",
"uint_fast8_t cdim;",
"uint_fast8_t cbits;",
"uint_fast8_t csub;",
"uint_fast8_t cval;",
"int_fast16_t book;",
"uint_fast16_t offset;",
"uint_fast16_t i,j;",
"int_fast16_t adx, ady, off, predicted;",
"int_fast16_t dy, err;",
"if (!get_bits1(gb))\nreturn 1;",
"floor1_Y[0] = get_bits(gb, ilog(range - 1));",
"floor1_Y[1] = get_bits(gb, ilog(range - 1));",
"AV_DEBUG(\"floor 0 Y %d floor 1 Y %d \\n\", floor1_Y[0], floor1_Y[1]);",
"offset = 2;",
"for (i = 0; i < vf->partitions; ++i) {",
"class_ = vf->partition_class[i];",
"cdim = vf->class_dimensions[class_];",
"cbits = vf->class_subclasses[class_];",
"csub = (1 << cbits) - 1;",
"cval = 0;",
"AV_DEBUG(\"Cbits %d \\n\", cbits);",
"if (cbits)\ncval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table,\nvc->codebooks[vf->class_masterbook[class_]].nb_bits, 3);",
"for (j = 0; j < cdim; ++j) {",
"book = vf->subclass_books[class_][cval & csub];",
"AV_DEBUG(\"book %d Cbits %d cval %d bits:%d \\n\", book, cbits, cval, get_bits_count(gb));",
"cval = cval >> cbits;",
"if (book > -1) {",
"floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,\nvc->codebooks[book].nb_bits, 3);",
"} else {",
"floor1_Y[offset+j] = 0;",
"}",
"AV_DEBUG(\" floor(%d) = %d \\n\", vf->list[offset+j].x, floor1_Y[offset+j]);",
"}",
"offset+=cdim;",
"}",
"VAR_0[0] = 1;",
"VAR_0[1] = 1;",
"floor1_Y_final[0] = floor1_Y[0];",
"floor1_Y_final[1] = floor1_Y[1];",
"for (i = 2; i < vf->x_list_dim; ++i) {",
"uint_fast16_t val, highroom, lowroom, room;",
"uint_fast16_t high_neigh_offs;",
"uint_fast16_t low_neigh_offs;",
"low_neigh_offs = vf->list[i].low;",
"high_neigh_offs = vf->list[i].high;",
"dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];",
"adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;",
"ady = FFABS(dy);",
"err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);",
"off = (int16_t)err / (int16_t)adx;",
"if (dy < 0) {",
"predicted = floor1_Y_final[low_neigh_offs] - off;",
"} else {",
"predicted = floor1_Y_final[low_neigh_offs] + off;",
"}",
"val = floor1_Y[i];",
"highroom = range-predicted;",
"lowroom = predicted;",
"if (highroom < lowroom) {",
"room = highroom * 2;",
"} else {",
"room = lowroom * 2;",
"}",
"if (val) {",
"VAR_0[low_neigh_offs] = 1;",
"VAR_0[high_neigh_offs] = 1;",
"VAR_0[i] = 1;",
"if (val >= room) {",
"if (highroom > lowroom) {",
"floor1_Y_final[i] = val - lowroom + predicted;",
"} else {",
"floor1_Y_final[i] = predicted - val + highroom - 1;",
"}",
"} else {",
"if (val & 1) {",
"floor1_Y_final[i] = predicted - (val + 1) / 2;",
"} else {",
"floor1_Y_final[i] = predicted + val / 2;",
"}",
"}",
"} else {",
"VAR_0[i] = 0;",
"floor1_Y_final[i] = predicted;",
"}",
"AV_DEBUG(\" Decoded floor(%d) = %d / val %d \\n\", vf->list[i].x, floor1_Y_final[i], val);",
"}",
"ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, VAR_0, vf->multiplier, vec, vf->list[1].x);",
"AV_DEBUG(\" Floor decoded\\n\");",
"return 0;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
45,
47
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
85,
87,
89
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
239
],
[
241
],
[
249
],
[
253
],
[
257
],
[
259
]
] |
1,865 | static void qemu_add_data_dir(const char *path)
{
int i;
if (path == NULL) {
return;
}
if (data_dir_idx == ARRAY_SIZE(data_dir)) {
return;
}
for (i = 0; i < data_dir_idx; i++) {
if (strcmp(data_dir[i], path) == 0) {
return; /* duplicate */
}
}
data_dir[data_dir_idx++] = path;
}
| true | qemu | 354711279fcc532cee310ed8098f51403dfef5d9 | static void qemu_add_data_dir(const char *path)
{
int i;
if (path == NULL) {
return;
}
if (data_dir_idx == ARRAY_SIZE(data_dir)) {
return;
}
for (i = 0; i < data_dir_idx; i++) {
if (strcmp(data_dir[i], path) == 0) {
return;
}
}
data_dir[data_dir_idx++] = path;
}
| {
"code": [
" data_dir[data_dir_idx++] = path;"
],
"line_no": [
31
]
} | static void FUNC_0(const char *VAR_0)
{
int VAR_1;
if (VAR_0 == NULL) {
return;
}
if (data_dir_idx == ARRAY_SIZE(data_dir)) {
return;
}
for (VAR_1 = 0; VAR_1 < data_dir_idx; VAR_1++) {
if (strcmp(data_dir[VAR_1], VAR_0) == 0) {
return;
}
}
data_dir[data_dir_idx++] = VAR_0;
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"int VAR_1;",
"if (VAR_0 == NULL) {",
"return;",
"}",
"if (data_dir_idx == ARRAY_SIZE(data_dir)) {",
"return;",
"}",
"for (VAR_1 = 0; VAR_1 < data_dir_idx; VAR_1++) {",
"if (strcmp(data_dir[VAR_1], VAR_0) == 0) {",
"return;",
"}",
"}",
"data_dir[data_dir_idx++] = VAR_0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
1,866 | void *ff_schro_queue_pop(FFSchroQueue *queue)
{
FFSchroQueueElement *top = queue->p_head;
if (top) {
void *data = top->data;
queue->p_head = queue->p_head->next;
--queue->size;
av_freep(&top);
return data;
}
return NULL;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | void *ff_schro_queue_pop(FFSchroQueue *queue)
{
FFSchroQueueElement *top = queue->p_head;
if (top) {
void *data = top->data;
queue->p_head = queue->p_head->next;
--queue->size;
av_freep(&top);
return data;
}
return NULL;
}
| {
"code": [
"void *ff_schro_queue_pop(FFSchroQueue *queue)",
" FFSchroQueueElement *top = queue->p_head;",
" if (top) {",
" void *data = top->data;",
" queue->p_head = queue->p_head->next;",
" --queue->size;",
" av_freep(&top);",
" return data;",
" return NULL;"
],
"line_no": [
1,
5,
9,
11,
13,
15,
17,
19,
25
]
} | void *FUNC_0(FFSchroQueue *VAR_0)
{
FFSchroQueueElement *top = VAR_0->p_head;
if (top) {
void *VAR_1 = top->VAR_1;
VAR_0->p_head = VAR_0->p_head->next;
--VAR_0->size;
av_freep(&top);
return VAR_1;
}
return NULL;
}
| [
"void *FUNC_0(FFSchroQueue *VAR_0)\n{",
"FFSchroQueueElement *top = VAR_0->p_head;",
"if (top) {",
"void *VAR_1 = top->VAR_1;",
"VAR_0->p_head = VAR_0->p_head->next;",
"--VAR_0->size;",
"av_freep(&top);",
"return VAR_1;",
"}",
"return NULL;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
1,867 | static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
NetClientState *nc = qemu_get_queue(n->nic);
int queues = n->multiqueue ? n->max_queues : 1;
if (!get_vhost_net(nc->peer)) {
return;
}
if ((virtio_net_started(n, status) && !nc->peer->link_down) ==
!!n->vhost_started) {
return;
}
if (!n->vhost_started) {
int r, i;
if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {
return;
}
/* Any packets outstanding? Purge them to avoid touching rings
* when vhost is running.
*/
for (i = 0; i < queues; i++) {
NetClientState *qnc = qemu_get_subqueue(n->nic, i);
/* Purge both directions: TX and RX. */
qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);
qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
}
n->vhost_started = 1;
r = vhost_net_start(vdev, n->nic->ncs, queues);
if (r < 0) {
error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -r);
n->vhost_started = 0;
}
} else {
vhost_net_stop(vdev, n->nic->ncs, queues);
n->vhost_started = 0;
}
}
| true | qemu | 1e7398a140f7a6bd9f5a438e7ad0f1ef50990e25 | static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
{
VirtIODevice *vdev = VIRTIO_DEVICE(n);
NetClientState *nc = qemu_get_queue(n->nic);
int queues = n->multiqueue ? n->max_queues : 1;
if (!get_vhost_net(nc->peer)) {
return;
}
if ((virtio_net_started(n, status) && !nc->peer->link_down) ==
!!n->vhost_started) {
return;
}
if (!n->vhost_started) {
int r, i;
if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {
return;
}
for (i = 0; i < queues; i++) {
NetClientState *qnc = qemu_get_subqueue(n->nic, i);
qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);
qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
}
n->vhost_started = 1;
r = vhost_net_start(vdev, n->nic->ncs, queues);
if (r < 0) {
error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -r);
n->vhost_started = 0;
}
} else {
vhost_net_stop(vdev, n->nic->ncs, queues);
n->vhost_started = 0;
}
}
| {
"code": [
" if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {"
],
"line_no": [
35
]
} | static void FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1)
{
VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);
NetClientState *nc = qemu_get_queue(VAR_0->nic);
int VAR_2 = VAR_0->multiqueue ? VAR_0->max_queues : 1;
if (!get_vhost_net(nc->peer)) {
return;
}
if ((virtio_net_started(VAR_0, VAR_1) && !nc->peer->link_down) ==
!!VAR_0->vhost_started) {
return;
}
if (!VAR_0->vhost_started) {
int VAR_3, VAR_4;
if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {
return;
}
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
NetClientState *qnc = qemu_get_subqueue(VAR_0->nic, VAR_4);
qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);
qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
}
VAR_0->vhost_started = 1;
VAR_3 = vhost_net_start(vdev, VAR_0->nic->ncs, VAR_2);
if (VAR_3 < 0) {
error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -VAR_3);
VAR_0->vhost_started = 0;
}
} else {
vhost_net_stop(vdev, VAR_0->nic->ncs, VAR_2);
VAR_0->vhost_started = 0;
}
}
| [
"static void FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1)\n{",
"VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);",
"NetClientState *nc = qemu_get_queue(VAR_0->nic);",
"int VAR_2 = VAR_0->multiqueue ? VAR_0->max_queues : 1;",
"if (!get_vhost_net(nc->peer)) {",
"return;",
"}",
"if ((virtio_net_started(VAR_0, VAR_1) && !nc->peer->link_down) ==\n!!VAR_0->vhost_started) {",
"return;",
"}",
"if (!VAR_0->vhost_started) {",
"int VAR_3, VAR_4;",
"if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {",
"return;",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"NetClientState *qnc = qemu_get_subqueue(VAR_0->nic, VAR_4);",
"qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);",
"qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);",
"}",
"VAR_0->vhost_started = 1;",
"VAR_3 = vhost_net_start(vdev, VAR_0->nic->ncs, VAR_2);",
"if (VAR_3 < 0) {",
"error_report(\"unable to start vhost net: %d: \"\n\"falling back on userspace virtio\", -VAR_3);",
"VAR_0->vhost_started = 0;",
"}",
"} else {",
"vhost_net_stop(vdev, VAR_0->nic->ncs, VAR_2);",
"VAR_0->vhost_started = 0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
1,868 | static int evrc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
AVFrame *frame = data;
EVRCContext *e = avctx->priv_data;
int buf_size = avpkt->size;
float ilspf[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];
float *samples;
int i, j, ret, error_flag = 0;
frame->nb_samples = 160;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (float *)frame->data[0];
if ((e->bitrate = determine_bitrate(avctx, &buf_size, &buf)) == RATE_ERRS) {
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
goto erasure;
}
if (e->bitrate <= SILENCE || e->bitrate == RATE_QUARTER)
goto erasure;
if (e->bitrate == RATE_QUANT && e->last_valid_bitrate == RATE_FULL
&& !e->prev_error_flag)
goto erasure;
init_get_bits(&e->gb, buf, 8 * buf_size);
memset(&e->frame, 0, sizeof(EVRCAFrame));
unpack_frame(e);
if (e->bitrate != RATE_QUANT) {
uint8_t *p = (uint8_t *) &e->frame;
for (i = 0; i < sizeof(EVRCAFrame); i++) {
if (p[i])
break;
}
if (i == sizeof(EVRCAFrame))
goto erasure;
} else if (e->frame.lsp[0] == 0xf &&
e->frame.lsp[1] == 0xf &&
e->frame.energy_gain == 0xff) {
goto erasure;
}
if (decode_lspf(e) < 0)
goto erasure;
if (e->bitrate == RATE_FULL || e->bitrate == RATE_HALF) {
/* Pitch delay parameter checking as per TIA/IS-127 5.1.5.1 */
if (e->frame.pitch_delay > MAX_DELAY - MIN_DELAY)
goto erasure;
e->pitch_delay = e->frame.pitch_delay + MIN_DELAY;
/* Delay diff parameter checking as per TIA/IS-127 5.1.5.2 */
if (e->frame.delay_diff) {
int p = e->pitch_delay - e->frame.delay_diff + 16;
if (p < MIN_DELAY || p > MAX_DELAY)
goto erasure;
}
/* Delay contour reconstruction as per TIA/IS-127 5.2.2.2 */
if (e->frame.delay_diff &&
e->bitrate == RATE_FULL && e->prev_error_flag) {
float delay;
memcpy(e->pitch, e->pitch_back, ACB_SIZE * sizeof(float));
delay = e->prev_pitch_delay;
e->prev_pitch_delay = delay - e->frame.delay_diff + 16.0;
if (fabs(e->pitch_delay - delay) > 15)
delay = e->pitch_delay;
for (i = 0; i < NB_SUBFRAMES; i++) {
int subframe_size = subframe_sizes[i];
interpolate_delay(idelay, delay, e->prev_pitch_delay, i);
acb_excitation(e, e->pitch + ACB_SIZE, e->avg_acb_gain, idelay, subframe_size);
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
}
}
/* Smoothing of the decoded delay as per TIA/IS-127 5.2.2.5 */
if (fabs(e->pitch_delay - e->prev_pitch_delay) > 15)
e->prev_pitch_delay = e->pitch_delay;
e->avg_acb_gain = e->avg_fcb_gain = 0.0;
} else {
idelay[0] = idelay[1] = idelay[2] = MIN_DELAY;
/* Decode frame energy vectors as per TIA/IS-127 5.7.2 */
for (i = 0; i < NB_SUBFRAMES; i++)
e->energy_vector[i] = pow(10, evrc_energy_quant[e->frame.energy_gain][i]);
e->prev_energy_gain = e->frame.energy_gain;
}
for (i = 0; i < NB_SUBFRAMES; i++) {
float tmp[SUBFRAME_SIZE + 6] = { 0 };
int subframe_size = subframe_sizes[i];
int pitch_lag;
interpolate_lsp(ilspf, e->lspf, e->prev_lspf, i);
if (e->bitrate != RATE_QUANT)
interpolate_delay(idelay, e->pitch_delay, e->prev_pitch_delay, i);
pitch_lag = lrintf((idelay[1] + idelay[0]) / 2.0);
decode_predictor_coeffs(ilspf, ilpc);
/* Bandwidth expansion as per TIA/IS-127 5.2.3.3 */
if (e->frame.lpc_flag && e->prev_error_flag)
bandwidth_expansion(ilpc, ilpc, 0.75);
if (e->bitrate != RATE_QUANT) {
float acb_sum, f;
f = exp((e->bitrate == RATE_HALF ? 0.5 : 0.25)
* (e->frame.fcb_gain[i] + 1));
acb_sum = pitch_gain_vq[e->frame.acb_gain[i]];
e->avg_acb_gain += acb_sum / NB_SUBFRAMES;
e->avg_fcb_gain += f / NB_SUBFRAMES;
acb_excitation(e, e->pitch + ACB_SIZE,
acb_sum, idelay, subframe_size);
fcb_excitation(e, e->frame.fcb_shape[i], tmp,
acb_sum, pitch_lag, subframe_size);
/* Total excitation generation as per TIA/IS-127 5.2.3.9 */
for (j = 0; j < subframe_size; j++)
e->pitch[ACB_SIZE + j] += f * tmp[j];
e->fade_scale = FFMIN(e->fade_scale + 0.2, 1.0);
} else {
for (j = 0; j < subframe_size; j++)
e->pitch[ACB_SIZE + j] = e->energy_vector[i];
}
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
synthesis_filter(e->pitch + ACB_SIZE, ilpc,
e->synthesis, subframe_size, tmp);
postfilter(e, tmp, ilpc, samples, pitch_lag,
&postfilter_coeffs[e->bitrate], subframe_size);
samples += subframe_size;
}
if (error_flag) {
erasure:
error_flag = 1;
av_log(avctx, AV_LOG_WARNING, "frame erasure\n");
frame_erasure(e, samples);
}
memcpy(e->prev_lspf, e->lspf, sizeof(e->prev_lspf));
e->prev_error_flag = error_flag;
e->last_valid_bitrate = e->bitrate;
if (e->bitrate != RATE_QUANT)
e->prev_pitch_delay = e->pitch_delay;
samples = (float *)frame->data[0];
for (i = 0; i < 160; i++)
samples[i] /= 32768;
*got_frame_ptr = 1;
return avpkt->size;
}
| false | FFmpeg | 5ae484e350e4f1b20b31802dac59ca3519627c0a | static int evrc_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
AVFrame *frame = data;
EVRCContext *e = avctx->priv_data;
int buf_size = avpkt->size;
float ilspf[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];
float *samples;
int i, j, ret, error_flag = 0;
frame->nb_samples = 160;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (float *)frame->data[0];
if ((e->bitrate = determine_bitrate(avctx, &buf_size, &buf)) == RATE_ERRS) {
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
goto erasure;
}
if (e->bitrate <= SILENCE || e->bitrate == RATE_QUARTER)
goto erasure;
if (e->bitrate == RATE_QUANT && e->last_valid_bitrate == RATE_FULL
&& !e->prev_error_flag)
goto erasure;
init_get_bits(&e->gb, buf, 8 * buf_size);
memset(&e->frame, 0, sizeof(EVRCAFrame));
unpack_frame(e);
if (e->bitrate != RATE_QUANT) {
uint8_t *p = (uint8_t *) &e->frame;
for (i = 0; i < sizeof(EVRCAFrame); i++) {
if (p[i])
break;
}
if (i == sizeof(EVRCAFrame))
goto erasure;
} else if (e->frame.lsp[0] == 0xf &&
e->frame.lsp[1] == 0xf &&
e->frame.energy_gain == 0xff) {
goto erasure;
}
if (decode_lspf(e) < 0)
goto erasure;
if (e->bitrate == RATE_FULL || e->bitrate == RATE_HALF) {
if (e->frame.pitch_delay > MAX_DELAY - MIN_DELAY)
goto erasure;
e->pitch_delay = e->frame.pitch_delay + MIN_DELAY;
if (e->frame.delay_diff) {
int p = e->pitch_delay - e->frame.delay_diff + 16;
if (p < MIN_DELAY || p > MAX_DELAY)
goto erasure;
}
if (e->frame.delay_diff &&
e->bitrate == RATE_FULL && e->prev_error_flag) {
float delay;
memcpy(e->pitch, e->pitch_back, ACB_SIZE * sizeof(float));
delay = e->prev_pitch_delay;
e->prev_pitch_delay = delay - e->frame.delay_diff + 16.0;
if (fabs(e->pitch_delay - delay) > 15)
delay = e->pitch_delay;
for (i = 0; i < NB_SUBFRAMES; i++) {
int subframe_size = subframe_sizes[i];
interpolate_delay(idelay, delay, e->prev_pitch_delay, i);
acb_excitation(e, e->pitch + ACB_SIZE, e->avg_acb_gain, idelay, subframe_size);
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
}
}
if (fabs(e->pitch_delay - e->prev_pitch_delay) > 15)
e->prev_pitch_delay = e->pitch_delay;
e->avg_acb_gain = e->avg_fcb_gain = 0.0;
} else {
idelay[0] = idelay[1] = idelay[2] = MIN_DELAY;
for (i = 0; i < NB_SUBFRAMES; i++)
e->energy_vector[i] = pow(10, evrc_energy_quant[e->frame.energy_gain][i]);
e->prev_energy_gain = e->frame.energy_gain;
}
for (i = 0; i < NB_SUBFRAMES; i++) {
float tmp[SUBFRAME_SIZE + 6] = { 0 };
int subframe_size = subframe_sizes[i];
int pitch_lag;
interpolate_lsp(ilspf, e->lspf, e->prev_lspf, i);
if (e->bitrate != RATE_QUANT)
interpolate_delay(idelay, e->pitch_delay, e->prev_pitch_delay, i);
pitch_lag = lrintf((idelay[1] + idelay[0]) / 2.0);
decode_predictor_coeffs(ilspf, ilpc);
if (e->frame.lpc_flag && e->prev_error_flag)
bandwidth_expansion(ilpc, ilpc, 0.75);
if (e->bitrate != RATE_QUANT) {
float acb_sum, f;
f = exp((e->bitrate == RATE_HALF ? 0.5 : 0.25)
* (e->frame.fcb_gain[i] + 1));
acb_sum = pitch_gain_vq[e->frame.acb_gain[i]];
e->avg_acb_gain += acb_sum / NB_SUBFRAMES;
e->avg_fcb_gain += f / NB_SUBFRAMES;
acb_excitation(e, e->pitch + ACB_SIZE,
acb_sum, idelay, subframe_size);
fcb_excitation(e, e->frame.fcb_shape[i], tmp,
acb_sum, pitch_lag, subframe_size);
for (j = 0; j < subframe_size; j++)
e->pitch[ACB_SIZE + j] += f * tmp[j];
e->fade_scale = FFMIN(e->fade_scale + 0.2, 1.0);
} else {
for (j = 0; j < subframe_size; j++)
e->pitch[ACB_SIZE + j] = e->energy_vector[i];
}
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
synthesis_filter(e->pitch + ACB_SIZE, ilpc,
e->synthesis, subframe_size, tmp);
postfilter(e, tmp, ilpc, samples, pitch_lag,
&postfilter_coeffs[e->bitrate], subframe_size);
samples += subframe_size;
}
if (error_flag) {
erasure:
error_flag = 1;
av_log(avctx, AV_LOG_WARNING, "frame erasure\n");
frame_erasure(e, samples);
}
memcpy(e->prev_lspf, e->lspf, sizeof(e->prev_lspf));
e->prev_error_flag = error_flag;
e->last_valid_bitrate = e->bitrate;
if (e->bitrate != RATE_QUANT)
e->prev_pitch_delay = e->pitch_delay;
samples = (float *)frame->data[0];
for (i = 0; i < 160; i++)
samples[i] /= 32768;
*got_frame_ptr = 1;
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
AVFrame *frame = VAR_1;
EVRCContext *e = VAR_0->priv_data;
int VAR_5 = VAR_3->size;
float VAR_6[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];
float *VAR_7;
int VAR_8, VAR_9, VAR_10, VAR_11 = 0;
frame->nb_samples = 160;
if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_10;
VAR_7 = (float *)frame->VAR_1[0];
if ((e->bitrate = determine_bitrate(VAR_0, &VAR_5, &VAR_4)) == RATE_ERRS) {
warn_insufficient_frame_quality(VAR_0, "bitrate cannot be determined.");
goto erasure;
}
if (e->bitrate <= SILENCE || e->bitrate == RATE_QUARTER)
goto erasure;
if (e->bitrate == RATE_QUANT && e->last_valid_bitrate == RATE_FULL
&& !e->prev_error_flag)
goto erasure;
init_get_bits(&e->gb, VAR_4, 8 * VAR_5);
memset(&e->frame, 0, sizeof(EVRCAFrame));
unpack_frame(e);
if (e->bitrate != RATE_QUANT) {
uint8_t *VAR_12 = (uint8_t *) &e->frame;
for (VAR_8 = 0; VAR_8 < sizeof(EVRCAFrame); VAR_8++) {
if (VAR_12[VAR_8])
break;
}
if (VAR_8 == sizeof(EVRCAFrame))
goto erasure;
} else if (e->frame.lsp[0] == 0xf &&
e->frame.lsp[1] == 0xf &&
e->frame.energy_gain == 0xff) {
goto erasure;
}
if (decode_lspf(e) < 0)
goto erasure;
if (e->bitrate == RATE_FULL || e->bitrate == RATE_HALF) {
if (e->frame.pitch_delay > MAX_DELAY - MIN_DELAY)
goto erasure;
e->pitch_delay = e->frame.pitch_delay + MIN_DELAY;
if (e->frame.delay_diff) {
int VAR_12 = e->pitch_delay - e->frame.delay_diff + 16;
if (VAR_12 < MIN_DELAY || VAR_12 > MAX_DELAY)
goto erasure;
}
if (e->frame.delay_diff &&
e->bitrate == RATE_FULL && e->prev_error_flag) {
float VAR_13;
memcpy(e->pitch, e->pitch_back, ACB_SIZE * sizeof(float));
VAR_13 = e->prev_pitch_delay;
e->prev_pitch_delay = VAR_13 - e->frame.delay_diff + 16.0;
if (fabs(e->pitch_delay - VAR_13) > 15)
VAR_13 = e->pitch_delay;
for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++) {
int subframe_size = subframe_sizes[VAR_8];
interpolate_delay(idelay, VAR_13, e->prev_pitch_delay, VAR_8);
acb_excitation(e, e->pitch + ACB_SIZE, e->avg_acb_gain, idelay, subframe_size);
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
}
}
if (fabs(e->pitch_delay - e->prev_pitch_delay) > 15)
e->prev_pitch_delay = e->pitch_delay;
e->avg_acb_gain = e->avg_fcb_gain = 0.0;
} else {
idelay[0] = idelay[1] = idelay[2] = MIN_DELAY;
for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++)
e->energy_vector[VAR_8] = pow(10, evrc_energy_quant[e->frame.energy_gain][VAR_8]);
e->prev_energy_gain = e->frame.energy_gain;
}
for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++) {
float tmp[SUBFRAME_SIZE + 6] = { 0 };
int subframe_size = subframe_sizes[VAR_8];
int pitch_lag;
interpolate_lsp(VAR_6, e->lspf, e->prev_lspf, VAR_8);
if (e->bitrate != RATE_QUANT)
interpolate_delay(idelay, e->pitch_delay, e->prev_pitch_delay, VAR_8);
pitch_lag = lrintf((idelay[1] + idelay[0]) / 2.0);
decode_predictor_coeffs(VAR_6, ilpc);
if (e->frame.lpc_flag && e->prev_error_flag)
bandwidth_expansion(ilpc, ilpc, 0.75);
if (e->bitrate != RATE_QUANT) {
float acb_sum, f;
f = exp((e->bitrate == RATE_HALF ? 0.5 : 0.25)
* (e->frame.fcb_gain[VAR_8] + 1));
acb_sum = pitch_gain_vq[e->frame.acb_gain[VAR_8]];
e->avg_acb_gain += acb_sum / NB_SUBFRAMES;
e->avg_fcb_gain += f / NB_SUBFRAMES;
acb_excitation(e, e->pitch + ACB_SIZE,
acb_sum, idelay, subframe_size);
fcb_excitation(e, e->frame.fcb_shape[VAR_8], tmp,
acb_sum, pitch_lag, subframe_size);
for (VAR_9 = 0; VAR_9 < subframe_size; VAR_9++)
e->pitch[ACB_SIZE + VAR_9] += f * tmp[VAR_9];
e->fade_scale = FFMIN(e->fade_scale + 0.2, 1.0);
} else {
for (VAR_9 = 0; VAR_9 < subframe_size; VAR_9++)
e->pitch[ACB_SIZE + VAR_9] = e->energy_vector[VAR_8];
}
memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));
synthesis_filter(e->pitch + ACB_SIZE, ilpc,
e->synthesis, subframe_size, tmp);
postfilter(e, tmp, ilpc, VAR_7, pitch_lag,
&postfilter_coeffs[e->bitrate], subframe_size);
VAR_7 += subframe_size;
}
if (VAR_11) {
erasure:
VAR_11 = 1;
av_log(VAR_0, AV_LOG_WARNING, "frame erasure\n");
frame_erasure(e, VAR_7);
}
memcpy(e->prev_lspf, e->lspf, sizeof(e->prev_lspf));
e->prev_error_flag = VAR_11;
e->last_valid_bitrate = e->bitrate;
if (e->bitrate != RATE_QUANT)
e->prev_pitch_delay = e->pitch_delay;
VAR_7 = (float *)frame->VAR_1[0];
for (VAR_8 = 0; VAR_8 < 160; VAR_8++)
VAR_7[VAR_8] /= 32768;
*VAR_2 = 1;
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"AVFrame *frame = VAR_1;",
"EVRCContext *e = VAR_0->priv_data;",
"int VAR_5 = VAR_3->size;",
"float VAR_6[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];",
"float *VAR_7;",
"int VAR_8, VAR_9, VAR_10, VAR_11 = 0;",
"frame->nb_samples = 160;",
"if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_10;",
"VAR_7 = (float *)frame->VAR_1[0];",
"if ((e->bitrate = determine_bitrate(VAR_0, &VAR_5, &VAR_4)) == RATE_ERRS) {",
"warn_insufficient_frame_quality(VAR_0, \"bitrate cannot be determined.\");",
"goto erasure;",
"}",
"if (e->bitrate <= SILENCE || e->bitrate == RATE_QUARTER)\ngoto erasure;",
"if (e->bitrate == RATE_QUANT && e->last_valid_bitrate == RATE_FULL\n&& !e->prev_error_flag)\ngoto erasure;",
"init_get_bits(&e->gb, VAR_4, 8 * VAR_5);",
"memset(&e->frame, 0, sizeof(EVRCAFrame));",
"unpack_frame(e);",
"if (e->bitrate != RATE_QUANT) {",
"uint8_t *VAR_12 = (uint8_t *) &e->frame;",
"for (VAR_8 = 0; VAR_8 < sizeof(EVRCAFrame); VAR_8++) {",
"if (VAR_12[VAR_8])\nbreak;",
"}",
"if (VAR_8 == sizeof(EVRCAFrame))\ngoto erasure;",
"} else if (e->frame.lsp[0] == 0xf &&",
"e->frame.lsp[1] == 0xf &&\ne->frame.energy_gain == 0xff) {",
"goto erasure;",
"}",
"if (decode_lspf(e) < 0)\ngoto erasure;",
"if (e->bitrate == RATE_FULL || e->bitrate == RATE_HALF) {",
"if (e->frame.pitch_delay > MAX_DELAY - MIN_DELAY)\ngoto erasure;",
"e->pitch_delay = e->frame.pitch_delay + MIN_DELAY;",
"if (e->frame.delay_diff) {",
"int VAR_12 = e->pitch_delay - e->frame.delay_diff + 16;",
"if (VAR_12 < MIN_DELAY || VAR_12 > MAX_DELAY)\ngoto erasure;",
"}",
"if (e->frame.delay_diff &&\ne->bitrate == RATE_FULL && e->prev_error_flag) {",
"float VAR_13;",
"memcpy(e->pitch, e->pitch_back, ACB_SIZE * sizeof(float));",
"VAR_13 = e->prev_pitch_delay;",
"e->prev_pitch_delay = VAR_13 - e->frame.delay_diff + 16.0;",
"if (fabs(e->pitch_delay - VAR_13) > 15)\nVAR_13 = e->pitch_delay;",
"for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++) {",
"int subframe_size = subframe_sizes[VAR_8];",
"interpolate_delay(idelay, VAR_13, e->prev_pitch_delay, VAR_8);",
"acb_excitation(e, e->pitch + ACB_SIZE, e->avg_acb_gain, idelay, subframe_size);",
"memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));",
"}",
"}",
"if (fabs(e->pitch_delay - e->prev_pitch_delay) > 15)\ne->prev_pitch_delay = e->pitch_delay;",
"e->avg_acb_gain = e->avg_fcb_gain = 0.0;",
"} else {",
"idelay[0] = idelay[1] = idelay[2] = MIN_DELAY;",
"for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++)",
"e->energy_vector[VAR_8] = pow(10, evrc_energy_quant[e->frame.energy_gain][VAR_8]);",
"e->prev_energy_gain = e->frame.energy_gain;",
"}",
"for (VAR_8 = 0; VAR_8 < NB_SUBFRAMES; VAR_8++) {",
"float tmp[SUBFRAME_SIZE + 6] = { 0 };",
"int subframe_size = subframe_sizes[VAR_8];",
"int pitch_lag;",
"interpolate_lsp(VAR_6, e->lspf, e->prev_lspf, VAR_8);",
"if (e->bitrate != RATE_QUANT)\ninterpolate_delay(idelay, e->pitch_delay, e->prev_pitch_delay, VAR_8);",
"pitch_lag = lrintf((idelay[1] + idelay[0]) / 2.0);",
"decode_predictor_coeffs(VAR_6, ilpc);",
"if (e->frame.lpc_flag && e->prev_error_flag)\nbandwidth_expansion(ilpc, ilpc, 0.75);",
"if (e->bitrate != RATE_QUANT) {",
"float acb_sum, f;",
"f = exp((e->bitrate == RATE_HALF ? 0.5 : 0.25)\n* (e->frame.fcb_gain[VAR_8] + 1));",
"acb_sum = pitch_gain_vq[e->frame.acb_gain[VAR_8]];",
"e->avg_acb_gain += acb_sum / NB_SUBFRAMES;",
"e->avg_fcb_gain += f / NB_SUBFRAMES;",
"acb_excitation(e, e->pitch + ACB_SIZE,\nacb_sum, idelay, subframe_size);",
"fcb_excitation(e, e->frame.fcb_shape[VAR_8], tmp,\nacb_sum, pitch_lag, subframe_size);",
"for (VAR_9 = 0; VAR_9 < subframe_size; VAR_9++)",
"e->pitch[ACB_SIZE + VAR_9] += f * tmp[VAR_9];",
"e->fade_scale = FFMIN(e->fade_scale + 0.2, 1.0);",
"} else {",
"for (VAR_9 = 0; VAR_9 < subframe_size; VAR_9++)",
"e->pitch[ACB_SIZE + VAR_9] = e->energy_vector[VAR_8];",
"}",
"memcpy(e->pitch, e->pitch + subframe_size, ACB_SIZE * sizeof(float));",
"synthesis_filter(e->pitch + ACB_SIZE, ilpc,\ne->synthesis, subframe_size, tmp);",
"postfilter(e, tmp, ilpc, VAR_7, pitch_lag,\n&postfilter_coeffs[e->bitrate], subframe_size);",
"VAR_7 += subframe_size;",
"}",
"if (VAR_11) {",
"erasure:\nVAR_11 = 1;",
"av_log(VAR_0, AV_LOG_WARNING, \"frame erasure\\n\");",
"frame_erasure(e, VAR_7);",
"}",
"memcpy(e->prev_lspf, e->lspf, sizeof(e->prev_lspf));",
"e->prev_error_flag = VAR_11;",
"e->last_valid_bitrate = e->bitrate;",
"if (e->bitrate != RATE_QUANT)\ne->prev_pitch_delay = e->pitch_delay;",
"VAR_7 = (float *)frame->VAR_1[0];",
"for (VAR_8 = 0; VAR_8 < 160; VAR_8++)",
"VAR_7[VAR_8] /= 32768;",
"*VAR_2 = 1;",
"return VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45,
47,
49
],
[
53
],
[
55
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
91,
93
],
[
97
],
[
101,
103
],
[
107
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
127,
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
145,
147
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
171,
173
],
[
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
211,
213
],
[
217
],
[
219
],
[
225,
227
],
[
231
],
[
233
],
[
237,
239
],
[
241
],
[
243
],
[
245
],
[
249,
251
],
[
253,
255
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
277
],
[
281,
283
],
[
285,
287
],
[
291
],
[
293
],
[
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
315
],
[
319,
321
],
[
325
],
[
327
],
[
329
],
[
333
],
[
337
],
[
339
]
] |
1,869 | static int _do_rematrixing(AC3DecodeContext *ctx, int start, int end)
{
float tmp0, tmp1;
while (start < end) {
tmp0 = ctx->samples[start];
tmp1 = (ctx->samples + 256)[start];
ctx->samples[start] = tmp0 + tmp1;
(ctx->samples + 256)[start] = tmp0 - tmp1;
start++;
}
return 0;
}
| false | FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | static int _do_rematrixing(AC3DecodeContext *ctx, int start, int end)
{
float tmp0, tmp1;
while (start < end) {
tmp0 = ctx->samples[start];
tmp1 = (ctx->samples + 256)[start];
ctx->samples[start] = tmp0 + tmp1;
(ctx->samples + 256)[start] = tmp0 - tmp1;
start++;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AC3DecodeContext *VAR_0, int VAR_1, int VAR_2)
{
float VAR_3, VAR_4;
while (VAR_1 < VAR_2) {
VAR_3 = VAR_0->samples[VAR_1];
VAR_4 = (VAR_0->samples + 256)[VAR_1];
VAR_0->samples[VAR_1] = VAR_3 + VAR_4;
(VAR_0->samples + 256)[VAR_1] = VAR_3 - VAR_4;
VAR_1++;
}
return 0;
}
| [
"static int FUNC_0(AC3DecodeContext *VAR_0, int VAR_1, int VAR_2)\n{",
"float VAR_3, VAR_4;",
"while (VAR_1 < VAR_2) {",
"VAR_3 = VAR_0->samples[VAR_1];",
"VAR_4 = (VAR_0->samples + 256)[VAR_1];",
"VAR_0->samples[VAR_1] = VAR_3 + VAR_4;",
"(VAR_0->samples + 256)[VAR_1] = VAR_3 - VAR_4;",
"VAR_1++;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
1,870 | const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
const uint8_t* frame, unsigned buf_size)
{
int i;
int dsf = (frame[3] & 0x80) >> 7;
int stype = frame[80*5 + 48 + 3] & 0x1f;
/* 576i50 25Mbps 4:1:1 is a special case */
if (dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) {
return &dv_profiles[2];
}
for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
return &dv_profiles[i];
/* check if old sys matches and assumes corrupted input */
if (sys && buf_size == sys->frame_size)
return sys;
return NULL;
}
| false | FFmpeg | e97efecec82ca8458a9bbd75a91ebf556abde362 | const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
const uint8_t* frame, unsigned buf_size)
{
int i;
int dsf = (frame[3] & 0x80) >> 7;
int stype = frame[80*5 + 48 + 3] & 0x1f;
if (dsf == 1 && stype == 0 && frame[4] & 0x07 ) {
return &dv_profiles[2];
}
for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)
return &dv_profiles[i];
if (sys && buf_size == sys->frame_size)
return sys;
return NULL;
}
| {
"code": [],
"line_no": []
} | const DVprofile* FUNC_0(const DVprofile *sys,
const uint8_t* frame, unsigned buf_size)
{
int VAR_0;
int VAR_1 = (frame[3] & 0x80) >> 7;
int VAR_2 = frame[80*5 + 48 + 3] & 0x1f;
if (VAR_1 == 1 && VAR_2 == 0 && frame[4] & 0x07 ) {
return &dv_profiles[2];
}
for (VAR_0=0; VAR_0<FF_ARRAY_ELEMS(dv_profiles); VAR_0++)
if (VAR_1 == dv_profiles[VAR_0].VAR_1 && VAR_2 == dv_profiles[VAR_0].video_stype)
return &dv_profiles[VAR_0];
if (sys && buf_size == sys->frame_size)
return sys;
return NULL;
}
| [
"const DVprofile* FUNC_0(const DVprofile *sys,\nconst uint8_t* frame, unsigned buf_size)\n{",
"int VAR_0;",
"int VAR_1 = (frame[3] & 0x80) >> 7;",
"int VAR_2 = frame[80*5 + 48 + 3] & 0x1f;",
"if (VAR_1 == 1 && VAR_2 == 0 && frame[4] & 0x07 ) {",
"return &dv_profiles[2];",
"}",
"for (VAR_0=0; VAR_0<FF_ARRAY_ELEMS(dv_profiles); VAR_0++)",
"if (VAR_1 == dv_profiles[VAR_0].VAR_1 && VAR_2 == dv_profiles[VAR_0].video_stype)\nreturn &dv_profiles[VAR_0];",
"if (sys && buf_size == sys->frame_size)\nreturn sys;",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
15
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
39,
41
],
[
45
],
[
47
]
] |
1,873 | static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
abi_ulong parent_tidptr, target_ulong newtls,
abi_ulong child_tidptr)
{
int ret;
TaskState *ts;
uint8_t *new_stack;
CPUState *new_env;
#if defined(CONFIG_USE_NPTL)
unsigned int nptl_flags;
sigset_t sigmask;
#endif
/* Emulate vfork() with fork() */
if (flags & CLONE_VFORK)
flags &= ~(CLONE_VFORK | CLONE_VM);
if (flags & CLONE_VM) {
TaskState *parent_ts = (TaskState *)env->opaque;
#if defined(CONFIG_USE_NPTL)
new_thread_info info;
pthread_attr_t attr;
#endif
ts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE);
init_task_state(ts);
new_stack = ts->stack;
/* we create a new CPU instance. */
new_env = cpu_copy(env);
#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
cpu_reset(new_env);
#endif
/* Init regs that differ from the parent. */
cpu_clone_regs(new_env, newsp);
new_env->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
#if defined(CONFIG_USE_NPTL)
nptl_flags = flags;
flags &= ~CLONE_NPTL_FLAGS2;
if (nptl_flags & CLONE_CHILD_CLEARTID) {
ts->child_tidptr = child_tidptr;
}
if (nptl_flags & CLONE_SETTLS)
cpu_set_tls (new_env, newtls);
/* Grab a mutex so that thread setup appears atomic. */
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.env = new_env;
if (nptl_flags & CLONE_CHILD_SETTID)
info.child_tidptr = child_tidptr;
if (nptl_flags & CLONE_PARENT_SETTID)
info.parent_tidptr = parent_tidptr;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE);
/* It is not safe to deliver signals until the child has finished
initializing, so temporarily block all signals. */
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
ret = pthread_create(&info.thread, &attr, clone_func, &info);
/* TODO: Free new CPU state if thread creation failed. */
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (ret == 0) {
/* Wait for the child to initialize. */
pthread_cond_wait(&info.cond, &info.mutex);
ret = info.tid;
if (flags & CLONE_PARENT_SETTID)
put_user_u32(ret, parent_tidptr);
} else {
ret = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
#else
if (flags & CLONE_NPTL_FLAGS2)
return -EINVAL;
/* This is probably going to die very quickly, but do it anyway. */
#ifdef __ia64__
ret = __clone2(clone_func, new_stack, NEW_STACK_SIZE, flags, new_env);
#else
ret = clone(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env);
#endif
#endif
} else {
/* if no CLONE_VM, we consider it is a fork */
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)
return -EINVAL;
fork_start();
ret = fork();
if (ret == 0) {
/* Child Process. */
cpu_clone_regs(env, newsp);
fork_end(1);
#if defined(CONFIG_USE_NPTL)
/* There is a race condition here. The parent process could
theoretically read the TID in the child process before the child
tid is set. This would require using either ptrace
(not implemented) or having *_tidptr to point at a shared memory
mapping. We can't repeat the spinlock hack used above because
the child process gets its own copy of the lock. */
if (flags & CLONE_CHILD_SETTID)
put_user_u32(gettid(), child_tidptr);
if (flags & CLONE_PARENT_SETTID)
put_user_u32(gettid(), parent_tidptr);
ts = (TaskState *)env->opaque;
if (flags & CLONE_SETTLS)
cpu_set_tls (env, newtls);
if (flags & CLONE_CHILD_CLEARTID)
ts->child_tidptr = child_tidptr;
#endif
} else {
fork_end(0);
}
}
return ret;
}
| true | qemu | 48e15fc2de29276f0c93482f5175b95e50557fbf | static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
abi_ulong parent_tidptr, target_ulong newtls,
abi_ulong child_tidptr)
{
int ret;
TaskState *ts;
uint8_t *new_stack;
CPUState *new_env;
#if defined(CONFIG_USE_NPTL)
unsigned int nptl_flags;
sigset_t sigmask;
#endif
if (flags & CLONE_VFORK)
flags &= ~(CLONE_VFORK | CLONE_VM);
if (flags & CLONE_VM) {
TaskState *parent_ts = (TaskState *)env->opaque;
#if defined(CONFIG_USE_NPTL)
new_thread_info info;
pthread_attr_t attr;
#endif
ts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE);
init_task_state(ts);
new_stack = ts->stack;
new_env = cpu_copy(env);
#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
cpu_reset(new_env);
#endif
cpu_clone_regs(new_env, newsp);
new_env->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
#if defined(CONFIG_USE_NPTL)
nptl_flags = flags;
flags &= ~CLONE_NPTL_FLAGS2;
if (nptl_flags & CLONE_CHILD_CLEARTID) {
ts->child_tidptr = child_tidptr;
}
if (nptl_flags & CLONE_SETTLS)
cpu_set_tls (new_env, newtls);
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.env = new_env;
if (nptl_flags & CLONE_CHILD_SETTID)
info.child_tidptr = child_tidptr;
if (nptl_flags & CLONE_PARENT_SETTID)
info.parent_tidptr = parent_tidptr;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE);
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
ret = pthread_create(&info.thread, &attr, clone_func, &info);
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (ret == 0) {
pthread_cond_wait(&info.cond, &info.mutex);
ret = info.tid;
if (flags & CLONE_PARENT_SETTID)
put_user_u32(ret, parent_tidptr);
} else {
ret = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
#else
if (flags & CLONE_NPTL_FLAGS2)
return -EINVAL;
#ifdef __ia64__
ret = __clone2(clone_func, new_stack, NEW_STACK_SIZE, flags, new_env);
#else
ret = clone(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env);
#endif
#endif
} else {
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)
return -EINVAL;
fork_start();
ret = fork();
if (ret == 0) {
cpu_clone_regs(env, newsp);
fork_end(1);
#if defined(CONFIG_USE_NPTL)
if (flags & CLONE_CHILD_SETTID)
put_user_u32(gettid(), child_tidptr);
if (flags & CLONE_PARENT_SETTID)
put_user_u32(gettid(), parent_tidptr);
ts = (TaskState *)env->opaque;
if (flags & CLONE_SETTLS)
cpu_set_tls (env, newtls);
if (flags & CLONE_CHILD_CLEARTID)
ts->child_tidptr = child_tidptr;
#endif
} else {
fork_end(0);
}
}
return ret;
}
| {
"code": [
" ts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE);",
" new_stack = ts->stack;",
" ret = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE);"
],
"line_no": [
47,
51,
123
]
} | static int FUNC_0(CPUState *VAR_0, unsigned int VAR_1, abi_ulong VAR_2,
abi_ulong VAR_3, target_ulong VAR_4,
abi_ulong VAR_5)
{
int VAR_6;
TaskState *ts;
uint8_t *new_stack;
CPUState *new_env;
#if defined(CONFIG_USE_NPTL)
unsigned int nptl_flags;
sigset_t sigmask;
#endif
if (VAR_1 & CLONE_VFORK)
VAR_1 &= ~(CLONE_VFORK | CLONE_VM);
if (VAR_1 & CLONE_VM) {
TaskState *parent_ts = (TaskState *)VAR_0->opaque;
#if defined(CONFIG_USE_NPTL)
new_thread_info info;
pthread_attr_t attr;
#endif
ts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE);
init_task_state(ts);
new_stack = ts->stack;
new_env = cpu_copy(VAR_0);
#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
cpu_reset(new_env);
#endif
cpu_clone_regs(new_env, VAR_2);
new_env->opaque = ts;
ts->bprm = parent_ts->bprm;
ts->info = parent_ts->info;
#if defined(CONFIG_USE_NPTL)
nptl_flags = VAR_1;
VAR_1 &= ~CLONE_NPTL_FLAGS2;
if (nptl_flags & CLONE_CHILD_CLEARTID) {
ts->VAR_5 = VAR_5;
}
if (nptl_flags & CLONE_SETTLS)
cpu_set_tls (new_env, VAR_4);
pthread_mutex_lock(&clone_lock);
memset(&info, 0, sizeof(info));
pthread_mutex_init(&info.mutex, NULL);
pthread_mutex_lock(&info.mutex);
pthread_cond_init(&info.cond, NULL);
info.VAR_0 = new_env;
if (nptl_flags & CLONE_CHILD_SETTID)
info.VAR_5 = VAR_5;
if (nptl_flags & CLONE_PARENT_SETTID)
info.VAR_3 = VAR_3;
VAR_6 = pthread_attr_init(&attr);
VAR_6 = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE);
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
VAR_6 = pthread_create(&info.thread, &attr, clone_func, &info);
sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
pthread_attr_destroy(&attr);
if (VAR_6 == 0) {
pthread_cond_wait(&info.cond, &info.mutex);
VAR_6 = info.tid;
if (VAR_1 & CLONE_PARENT_SETTID)
put_user_u32(VAR_6, VAR_3);
} else {
VAR_6 = -1;
}
pthread_mutex_unlock(&info.mutex);
pthread_cond_destroy(&info.cond);
pthread_mutex_destroy(&info.mutex);
pthread_mutex_unlock(&clone_lock);
#else
if (VAR_1 & CLONE_NPTL_FLAGS2)
return -EINVAL;
#ifdef __ia64__
VAR_6 = __clone2(clone_func, new_stack, NEW_STACK_SIZE, VAR_1, new_env);
#else
VAR_6 = clone(clone_func, new_stack + NEW_STACK_SIZE, VAR_1, new_env);
#endif
#endif
} else {
if ((VAR_1 & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)
return -EINVAL;
fork_start();
VAR_6 = fork();
if (VAR_6 == 0) {
cpu_clone_regs(VAR_0, VAR_2);
fork_end(1);
#if defined(CONFIG_USE_NPTL)
if (VAR_1 & CLONE_CHILD_SETTID)
put_user_u32(gettid(), VAR_5);
if (VAR_1 & CLONE_PARENT_SETTID)
put_user_u32(gettid(), VAR_3);
ts = (TaskState *)VAR_0->opaque;
if (VAR_1 & CLONE_SETTLS)
cpu_set_tls (VAR_0, VAR_4);
if (VAR_1 & CLONE_CHILD_CLEARTID)
ts->VAR_5 = VAR_5;
#endif
} else {
fork_end(0);
}
}
return VAR_6;
}
| [
"static int FUNC_0(CPUState *VAR_0, unsigned int VAR_1, abi_ulong VAR_2,\nabi_ulong VAR_3, target_ulong VAR_4,\nabi_ulong VAR_5)\n{",
"int VAR_6;",
"TaskState *ts;",
"uint8_t *new_stack;",
"CPUState *new_env;",
"#if defined(CONFIG_USE_NPTL)\nunsigned int nptl_flags;",
"sigset_t sigmask;",
"#endif\nif (VAR_1 & CLONE_VFORK)\nVAR_1 &= ~(CLONE_VFORK | CLONE_VM);",
"if (VAR_1 & CLONE_VM) {",
"TaskState *parent_ts = (TaskState *)VAR_0->opaque;",
"#if defined(CONFIG_USE_NPTL)\nnew_thread_info info;",
"pthread_attr_t attr;",
"#endif\nts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE);",
"init_task_state(ts);",
"new_stack = ts->stack;",
"new_env = cpu_copy(VAR_0);",
"#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)\ncpu_reset(new_env);",
"#endif\ncpu_clone_regs(new_env, VAR_2);",
"new_env->opaque = ts;",
"ts->bprm = parent_ts->bprm;",
"ts->info = parent_ts->info;",
"#if defined(CONFIG_USE_NPTL)\nnptl_flags = VAR_1;",
"VAR_1 &= ~CLONE_NPTL_FLAGS2;",
"if (nptl_flags & CLONE_CHILD_CLEARTID) {",
"ts->VAR_5 = VAR_5;",
"}",
"if (nptl_flags & CLONE_SETTLS)\ncpu_set_tls (new_env, VAR_4);",
"pthread_mutex_lock(&clone_lock);",
"memset(&info, 0, sizeof(info));",
"pthread_mutex_init(&info.mutex, NULL);",
"pthread_mutex_lock(&info.mutex);",
"pthread_cond_init(&info.cond, NULL);",
"info.VAR_0 = new_env;",
"if (nptl_flags & CLONE_CHILD_SETTID)\ninfo.VAR_5 = VAR_5;",
"if (nptl_flags & CLONE_PARENT_SETTID)\ninfo.VAR_3 = VAR_3;",
"VAR_6 = pthread_attr_init(&attr);",
"VAR_6 = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE);",
"sigfillset(&sigmask);",
"sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);",
"VAR_6 = pthread_create(&info.thread, &attr, clone_func, &info);",
"sigprocmask(SIG_SETMASK, &info.sigmask, NULL);",
"pthread_attr_destroy(&attr);",
"if (VAR_6 == 0) {",
"pthread_cond_wait(&info.cond, &info.mutex);",
"VAR_6 = info.tid;",
"if (VAR_1 & CLONE_PARENT_SETTID)\nput_user_u32(VAR_6, VAR_3);",
"} else {",
"VAR_6 = -1;",
"}",
"pthread_mutex_unlock(&info.mutex);",
"pthread_cond_destroy(&info.cond);",
"pthread_mutex_destroy(&info.mutex);",
"pthread_mutex_unlock(&clone_lock);",
"#else\nif (VAR_1 & CLONE_NPTL_FLAGS2)\nreturn -EINVAL;",
"#ifdef __ia64__\nVAR_6 = __clone2(clone_func, new_stack, NEW_STACK_SIZE, VAR_1, new_env);",
"#else\nVAR_6 = clone(clone_func, new_stack + NEW_STACK_SIZE, VAR_1, new_env);",
"#endif\n#endif\n} else {",
"if ((VAR_1 & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)\nreturn -EINVAL;",
"fork_start();",
"VAR_6 = fork();",
"if (VAR_6 == 0) {",
"cpu_clone_regs(VAR_0, VAR_2);",
"fork_end(1);",
"#if defined(CONFIG_USE_NPTL)\nif (VAR_1 & CLONE_CHILD_SETTID)\nput_user_u32(gettid(), VAR_5);",
"if (VAR_1 & CLONE_PARENT_SETTID)\nput_user_u32(gettid(), VAR_3);",
"ts = (TaskState *)VAR_0->opaque;",
"if (VAR_1 & CLONE_SETTLS)\ncpu_set_tls (VAR_0, VAR_4);",
"if (VAR_1 & CLONE_CHILD_CLEARTID)\nts->VAR_5 = VAR_5;",
"#endif\n} else {",
"fork_end(0);",
"}",
"}",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
29,
31
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61,
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115,
117
],
[
121
],
[
123
],
[
129
],
[
131
],
[
135
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153,
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173,
175
],
[
179,
181
],
[
183,
185
],
[
187,
189,
191
],
[
195,
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211,
225,
227
],
[
229,
231
],
[
233
],
[
235,
237
],
[
239,
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
]
] |
1,874 | static inline void decode(DisasContext *dc, uint32_t ir)
{
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
dc->ir = ir;
LOG_DIS("%8.8x\t", dc->ir);
/* try guessing 'empty' instruction memory, although it may be a valid
* instruction sequence (eg. srui r0, r0, 0) */
if (dc->ir) {
dc->nr_nops = 0;
} else {
LOG_DIS("nr_nops=%d\t", dc->nr_nops);
dc->nr_nops++;
if (dc->nr_nops > 4) {
cpu_abort(dc->env, "fetching nop sequence\n");
}
}
dc->opcode = EXTRACT_FIELD(ir, 26, 31);
dc->imm5 = EXTRACT_FIELD(ir, 0, 4);
dc->imm16 = EXTRACT_FIELD(ir, 0, 15);
dc->imm26 = EXTRACT_FIELD(ir, 0, 25);
dc->csr = EXTRACT_FIELD(ir, 21, 25);
dc->r0 = EXTRACT_FIELD(ir, 21, 25);
dc->r1 = EXTRACT_FIELD(ir, 16, 20);
dc->r2 = EXTRACT_FIELD(ir, 11, 15);
/* bit 31 seems to indicate insn type. */
if (ir & (1 << 31)) {
dc->format = OP_FMT_RR;
} else {
dc->format = OP_FMT_RI;
}
assert(ARRAY_SIZE(decinfo) == 64);
assert(dc->opcode < 64);
decinfo[dc->opcode](dc);
}
| true | qemu | 3604a76fea6ff37738d4a8f596be38407be74a83 | static inline void decode(DisasContext *dc, uint32_t ir)
{
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(dc->pc);
}
dc->ir = ir;
LOG_DIS("%8.8x\t", dc->ir);
if (dc->ir) {
dc->nr_nops = 0;
} else {
LOG_DIS("nr_nops=%d\t", dc->nr_nops);
dc->nr_nops++;
if (dc->nr_nops > 4) {
cpu_abort(dc->env, "fetching nop sequence\n");
}
}
dc->opcode = EXTRACT_FIELD(ir, 26, 31);
dc->imm5 = EXTRACT_FIELD(ir, 0, 4);
dc->imm16 = EXTRACT_FIELD(ir, 0, 15);
dc->imm26 = EXTRACT_FIELD(ir, 0, 25);
dc->csr = EXTRACT_FIELD(ir, 21, 25);
dc->r0 = EXTRACT_FIELD(ir, 21, 25);
dc->r1 = EXTRACT_FIELD(ir, 16, 20);
dc->r2 = EXTRACT_FIELD(ir, 11, 15);
if (ir & (1 << 31)) {
dc->format = OP_FMT_RR;
} else {
dc->format = OP_FMT_RI;
}
assert(ARRAY_SIZE(decinfo) == 64);
assert(dc->opcode < 64);
decinfo[dc->opcode](dc);
}
| {
"code": [
" if (dc->ir) {",
" dc->nr_nops = 0;",
" } else {",
" LOG_DIS(\"nr_nops=%d\\t\", dc->nr_nops);",
" dc->nr_nops++;",
" if (dc->nr_nops > 4) {",
" cpu_abort(dc->env, \"fetching nop sequence\\n\");"
],
"line_no": [
23,
25,
27,
29,
31,
33,
35
]
} | static inline void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)
{
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_debug_insn_start(VAR_0->pc);
}
VAR_0->VAR_1 = VAR_1;
LOG_DIS("%8.8x\t", VAR_0->VAR_1);
if (VAR_0->VAR_1) {
VAR_0->nr_nops = 0;
} else {
LOG_DIS("nr_nops=%d\t", VAR_0->nr_nops);
VAR_0->nr_nops++;
if (VAR_0->nr_nops > 4) {
cpu_abort(VAR_0->env, "fetching nop sequence\n");
}
}
VAR_0->opcode = EXTRACT_FIELD(VAR_1, 26, 31);
VAR_0->imm5 = EXTRACT_FIELD(VAR_1, 0, 4);
VAR_0->imm16 = EXTRACT_FIELD(VAR_1, 0, 15);
VAR_0->imm26 = EXTRACT_FIELD(VAR_1, 0, 25);
VAR_0->csr = EXTRACT_FIELD(VAR_1, 21, 25);
VAR_0->r0 = EXTRACT_FIELD(VAR_1, 21, 25);
VAR_0->r1 = EXTRACT_FIELD(VAR_1, 16, 20);
VAR_0->r2 = EXTRACT_FIELD(VAR_1, 11, 15);
if (VAR_1 & (1 << 31)) {
VAR_0->format = OP_FMT_RR;
} else {
VAR_0->format = OP_FMT_RI;
}
assert(ARRAY_SIZE(decinfo) == 64);
assert(VAR_0->opcode < 64);
decinfo[VAR_0->opcode](VAR_0);
}
| [
"static inline void FUNC_0(DisasContext *VAR_0, uint32_t VAR_1)\n{",
"if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {",
"tcg_gen_debug_insn_start(VAR_0->pc);",
"}",
"VAR_0->VAR_1 = VAR_1;",
"LOG_DIS(\"%8.8x\\t\", VAR_0->VAR_1);",
"if (VAR_0->VAR_1) {",
"VAR_0->nr_nops = 0;",
"} else {",
"LOG_DIS(\"nr_nops=%d\\t\", VAR_0->nr_nops);",
"VAR_0->nr_nops++;",
"if (VAR_0->nr_nops > 4) {",
"cpu_abort(VAR_0->env, \"fetching nop sequence\\n\");",
"}",
"}",
"VAR_0->opcode = EXTRACT_FIELD(VAR_1, 26, 31);",
"VAR_0->imm5 = EXTRACT_FIELD(VAR_1, 0, 4);",
"VAR_0->imm16 = EXTRACT_FIELD(VAR_1, 0, 15);",
"VAR_0->imm26 = EXTRACT_FIELD(VAR_1, 0, 25);",
"VAR_0->csr = EXTRACT_FIELD(VAR_1, 21, 25);",
"VAR_0->r0 = EXTRACT_FIELD(VAR_1, 21, 25);",
"VAR_0->r1 = EXTRACT_FIELD(VAR_1, 16, 20);",
"VAR_0->r2 = EXTRACT_FIELD(VAR_1, 11, 15);",
"if (VAR_1 & (1 << 31)) {",
"VAR_0->format = OP_FMT_RR;",
"} else {",
"VAR_0->format = OP_FMT_RI;",
"}",
"assert(ARRAY_SIZE(decinfo) == 64);",
"assert(VAR_0->opcode < 64);",
"decinfo[VAR_0->opcode](VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
85
],
[
87
]
] |
1,875 | static int decode_zbuf(AVBPrint *bp, const uint8_t *data,
const uint8_t *data_end)
{
z_stream zstream;
unsigned char *buf;
unsigned buf_size;
int ret;
zstream.zalloc = ff_png_zalloc;
zstream.zfree = ff_png_zfree;
zstream.opaque = NULL;
if (inflateInit(&zstream) != Z_OK)
return AVERROR_EXTERNAL;
zstream.next_in = (unsigned char *)data;
zstream.avail_in = data_end - data;
av_bprint_init(bp, 0, -1);
while (zstream.avail_in > 0) {
av_bprint_get_buffer(bp, 1, &buf, &buf_size);
if (!buf_size) {
ret = AVERROR(ENOMEM);
goto fail;
}
zstream.next_out = buf;
zstream.avail_out = buf_size;
ret = inflate(&zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
ret = AVERROR_EXTERNAL;
goto fail;
}
bp->len += zstream.next_out - buf;
if (ret == Z_STREAM_END)
break;
}
inflateEnd(&zstream);
bp->str[bp->len] = 0;
return 0;
fail:
inflateEnd(&zstream);
av_bprint_finalize(bp, NULL);
return ret;
}
| true | FFmpeg | e371f031b942d73e02c090170975561fabd5c264 | static int decode_zbuf(AVBPrint *bp, const uint8_t *data,
const uint8_t *data_end)
{
z_stream zstream;
unsigned char *buf;
unsigned buf_size;
int ret;
zstream.zalloc = ff_png_zalloc;
zstream.zfree = ff_png_zfree;
zstream.opaque = NULL;
if (inflateInit(&zstream) != Z_OK)
return AVERROR_EXTERNAL;
zstream.next_in = (unsigned char *)data;
zstream.avail_in = data_end - data;
av_bprint_init(bp, 0, -1);
while (zstream.avail_in > 0) {
av_bprint_get_buffer(bp, 1, &buf, &buf_size);
if (!buf_size) {
ret = AVERROR(ENOMEM);
goto fail;
}
zstream.next_out = buf;
zstream.avail_out = buf_size;
ret = inflate(&zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
ret = AVERROR_EXTERNAL;
goto fail;
}
bp->len += zstream.next_out - buf;
if (ret == Z_STREAM_END)
break;
}
inflateEnd(&zstream);
bp->str[bp->len] = 0;
return 0;
fail:
inflateEnd(&zstream);
av_bprint_finalize(bp, NULL);
return ret;
}
| {
"code": [
" av_bprint_get_buffer(bp, 1, &buf, &buf_size);",
" if (!buf_size) {",
" zstream.avail_out = buf_size;"
],
"line_no": [
37,
39,
49
]
} | static int FUNC_0(AVBPrint *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2)
{
z_stream zstream;
unsigned char *VAR_3;
unsigned VAR_4;
int VAR_5;
zstream.zalloc = ff_png_zalloc;
zstream.zfree = ff_png_zfree;
zstream.opaque = NULL;
if (inflateInit(&zstream) != Z_OK)
return AVERROR_EXTERNAL;
zstream.next_in = (unsigned char *)VAR_1;
zstream.avail_in = VAR_2 - VAR_1;
av_bprint_init(VAR_0, 0, -1);
while (zstream.avail_in > 0) {
av_bprint_get_buffer(VAR_0, 1, &VAR_3, &VAR_4);
if (!VAR_4) {
VAR_5 = AVERROR(ENOMEM);
goto fail;
}
zstream.next_out = VAR_3;
zstream.avail_out = VAR_4;
VAR_5 = inflate(&zstream, Z_PARTIAL_FLUSH);
if (VAR_5 != Z_OK && VAR_5 != Z_STREAM_END) {
VAR_5 = AVERROR_EXTERNAL;
goto fail;
}
VAR_0->len += zstream.next_out - VAR_3;
if (VAR_5 == Z_STREAM_END)
break;
}
inflateEnd(&zstream);
VAR_0->str[VAR_0->len] = 0;
return 0;
fail:
inflateEnd(&zstream);
av_bprint_finalize(VAR_0, NULL);
return VAR_5;
}
| [
"static int FUNC_0(AVBPrint *VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2)\n{",
"z_stream zstream;",
"unsigned char *VAR_3;",
"unsigned VAR_4;",
"int VAR_5;",
"zstream.zalloc = ff_png_zalloc;",
"zstream.zfree = ff_png_zfree;",
"zstream.opaque = NULL;",
"if (inflateInit(&zstream) != Z_OK)\nreturn AVERROR_EXTERNAL;",
"zstream.next_in = (unsigned char *)VAR_1;",
"zstream.avail_in = VAR_2 - VAR_1;",
"av_bprint_init(VAR_0, 0, -1);",
"while (zstream.avail_in > 0) {",
"av_bprint_get_buffer(VAR_0, 1, &VAR_3, &VAR_4);",
"if (!VAR_4) {",
"VAR_5 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"zstream.next_out = VAR_3;",
"zstream.avail_out = VAR_4;",
"VAR_5 = inflate(&zstream, Z_PARTIAL_FLUSH);",
"if (VAR_5 != Z_OK && VAR_5 != Z_STREAM_END) {",
"VAR_5 = AVERROR_EXTERNAL;",
"goto fail;",
"}",
"VAR_0->len += zstream.next_out - VAR_3;",
"if (VAR_5 == Z_STREAM_END)\nbreak;",
"}",
"inflateEnd(&zstream);",
"VAR_0->str[VAR_0->len] = 0;",
"return 0;",
"fail:\ninflateEnd(&zstream);",
"av_bprint_finalize(VAR_0, NULL);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
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
]
] |
1,876 | static int write_extradata(FFV1Context *f)
{
RangeCoder *const c = &f->c;
uint8_t state[CONTEXT_SIZE];
int i, j, k;
uint8_t state2[32][CONTEXT_SIZE];
unsigned v;
memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
f->avctx->extradata_size = 10000 + 4 +
(11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;
f->avctx->extradata = av_malloc(f->avctx->extradata_size);
ff_init_range_encoder(c, f->avctx->extradata, f->avctx->extradata_size);
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
put_symbol(c, state, f->version, 0);
if (f->version > 2) {
if (f->version == 3)
f->minor_version = 4;
put_symbol(c, state, f->minor_version, 0);
}
put_symbol(c, state, f->ac, 0);
if (f->ac > 1)
for (i = 1; i < 256; i++)
put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
put_symbol(c, state, f->colorspace, 0); // YUV cs type
put_symbol(c, state, f->bits_per_raw_sample, 0);
put_rac(c, state, f->chroma_planes);
put_symbol(c, state, f->chroma_h_shift, 0);
put_symbol(c, state, f->chroma_v_shift, 0);
put_rac(c, state, f->transparency);
put_symbol(c, state, f->num_h_slices - 1, 0);
put_symbol(c, state, f->num_v_slices - 1, 0);
put_symbol(c, state, f->quant_table_count, 0);
for (i = 0; i < f->quant_table_count; i++)
write_quant_tables(c, f->quant_tables[i]);
for (i = 0; i < f->quant_table_count; i++) {
for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++)
if (f->initial_states[i] && f->initial_states[i][0][j] != 128)
break;
if (j < f->context_count[i] * CONTEXT_SIZE) {
put_rac(c, state, 1);
for (j = 0; j < f->context_count[i]; j++)
for (k = 0; k < CONTEXT_SIZE; k++) {
int pred = j ? f->initial_states[i][j - 1][k] : 128;
put_symbol(c, state2[k],
(int8_t)(f->initial_states[i][j][k] - pred), 1);
}
} else {
put_rac(c, state, 0);
}
}
if (f->version > 2) {
put_symbol(c, state, f->ec, 0);
put_symbol(c, state, f->intra = (f->avctx->gop_size < 2), 0);
}
f->avctx->extradata_size = ff_rac_terminate(c);
v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size);
AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v);
f->avctx->extradata_size += 4;
return 0;
} | true | FFmpeg | eeb3fb9e62d4647e1fee5d262be63e793117430d | static int write_extradata(FFV1Context *f)
{
RangeCoder *const c = &f->c;
uint8_t state[CONTEXT_SIZE];
int i, j, k;
uint8_t state2[32][CONTEXT_SIZE];
unsigned v;
memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
f->avctx->extradata_size = 10000 + 4 +
(11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;
f->avctx->extradata = av_malloc(f->avctx->extradata_size);
ff_init_range_encoder(c, f->avctx->extradata, f->avctx->extradata_size);
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
put_symbol(c, state, f->version, 0);
if (f->version > 2) {
if (f->version == 3)
f->minor_version = 4;
put_symbol(c, state, f->minor_version, 0);
}
put_symbol(c, state, f->ac, 0);
if (f->ac > 1)
for (i = 1; i < 256; i++)
put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
put_symbol(c, state, f->colorspace, 0);
put_symbol(c, state, f->bits_per_raw_sample, 0);
put_rac(c, state, f->chroma_planes);
put_symbol(c, state, f->chroma_h_shift, 0);
put_symbol(c, state, f->chroma_v_shift, 0);
put_rac(c, state, f->transparency);
put_symbol(c, state, f->num_h_slices - 1, 0);
put_symbol(c, state, f->num_v_slices - 1, 0);
put_symbol(c, state, f->quant_table_count, 0);
for (i = 0; i < f->quant_table_count; i++)
write_quant_tables(c, f->quant_tables[i]);
for (i = 0; i < f->quant_table_count; i++) {
for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++)
if (f->initial_states[i] && f->initial_states[i][0][j] != 128)
break;
if (j < f->context_count[i] * CONTEXT_SIZE) {
put_rac(c, state, 1);
for (j = 0; j < f->context_count[i]; j++)
for (k = 0; k < CONTEXT_SIZE; k++) {
int pred = j ? f->initial_states[i][j - 1][k] : 128;
put_symbol(c, state2[k],
(int8_t)(f->initial_states[i][j][k] - pred), 1);
}
} else {
put_rac(c, state, 0);
}
}
if (f->version > 2) {
put_symbol(c, state, f->ec, 0);
put_symbol(c, state, f->intra = (f->avctx->gop_size < 2), 0);
}
f->avctx->extradata_size = ff_rac_terminate(c);
v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size);
AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v);
f->avctx->extradata_size += 4;
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(FFV1Context *VAR_0)
{
RangeCoder *const c = &VAR_0->c;
uint8_t state[CONTEXT_SIZE];
int VAR_1, VAR_2, VAR_3;
uint8_t state2[32][CONTEXT_SIZE];
unsigned VAR_4;
memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
VAR_0->avctx->extradata_size = 10000 + 4 +
(11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;
VAR_0->avctx->extradata = av_malloc(VAR_0->avctx->extradata_size);
ff_init_range_encoder(c, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size);
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
put_symbol(c, state, VAR_0->version, 0);
if (VAR_0->version > 2) {
if (VAR_0->version == 3)
VAR_0->minor_version = 4;
put_symbol(c, state, VAR_0->minor_version, 0);
}
put_symbol(c, state, VAR_0->ac, 0);
if (VAR_0->ac > 1)
for (VAR_1 = 1; VAR_1 < 256; VAR_1++)
put_symbol(c, state, VAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1);
put_symbol(c, state, VAR_0->colorspace, 0);
put_symbol(c, state, VAR_0->bits_per_raw_sample, 0);
put_rac(c, state, VAR_0->chroma_planes);
put_symbol(c, state, VAR_0->chroma_h_shift, 0);
put_symbol(c, state, VAR_0->chroma_v_shift, 0);
put_rac(c, state, VAR_0->transparency);
put_symbol(c, state, VAR_0->num_h_slices - 1, 0);
put_symbol(c, state, VAR_0->num_v_slices - 1, 0);
put_symbol(c, state, VAR_0->quant_table_count, 0);
for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++)
write_quant_tables(c, VAR_0->quant_tables[VAR_1]);
for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++) {
for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1] * CONTEXT_SIZE; VAR_2++)
if (VAR_0->initial_states[VAR_1] && VAR_0->initial_states[VAR_1][0][VAR_2] != 128)
break;
if (VAR_2 < VAR_0->context_count[VAR_1] * CONTEXT_SIZE) {
put_rac(c, state, 1);
for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1]; VAR_2++)
for (VAR_3 = 0; VAR_3 < CONTEXT_SIZE; VAR_3++) {
int pred = VAR_2 ? VAR_0->initial_states[VAR_1][VAR_2 - 1][VAR_3] : 128;
put_symbol(c, state2[VAR_3],
(int8_t)(VAR_0->initial_states[VAR_1][VAR_2][VAR_3] - pred), 1);
}
} else {
put_rac(c, state, 0);
}
}
if (VAR_0->version > 2) {
put_symbol(c, state, VAR_0->ec, 0);
put_symbol(c, state, VAR_0->intra = (VAR_0->avctx->gop_size < 2), 0);
}
VAR_0->avctx->extradata_size = ff_rac_terminate(c);
VAR_4 = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size);
AV_WL32(VAR_0->avctx->extradata + VAR_0->avctx->extradata_size, VAR_4);
VAR_0->avctx->extradata_size += 4;
return 0;
} | [
"static int FUNC_0(FFV1Context *VAR_0)\n{",
"RangeCoder *const c = &VAR_0->c;",
"uint8_t state[CONTEXT_SIZE];",
"int VAR_1, VAR_2, VAR_3;",
"uint8_t state2[32][CONTEXT_SIZE];",
"unsigned VAR_4;",
"memset(state2, 128, sizeof(state2));",
"memset(state, 128, sizeof(state));",
"VAR_0->avctx->extradata_size = 10000 + 4 +\n(11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;",
"VAR_0->avctx->extradata = av_malloc(VAR_0->avctx->extradata_size);",
"ff_init_range_encoder(c, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size);",
"ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);",
"put_symbol(c, state, VAR_0->version, 0);",
"if (VAR_0->version > 2) {",
"if (VAR_0->version == 3)\nVAR_0->minor_version = 4;",
"put_symbol(c, state, VAR_0->minor_version, 0);",
"}",
"put_symbol(c, state, VAR_0->ac, 0);",
"if (VAR_0->ac > 1)\nfor (VAR_1 = 1; VAR_1 < 256; VAR_1++)",
"put_symbol(c, state, VAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1);",
"put_symbol(c, state, VAR_0->colorspace, 0);",
"put_symbol(c, state, VAR_0->bits_per_raw_sample, 0);",
"put_rac(c, state, VAR_0->chroma_planes);",
"put_symbol(c, state, VAR_0->chroma_h_shift, 0);",
"put_symbol(c, state, VAR_0->chroma_v_shift, 0);",
"put_rac(c, state, VAR_0->transparency);",
"put_symbol(c, state, VAR_0->num_h_slices - 1, 0);",
"put_symbol(c, state, VAR_0->num_v_slices - 1, 0);",
"put_symbol(c, state, VAR_0->quant_table_count, 0);",
"for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++)",
"write_quant_tables(c, VAR_0->quant_tables[VAR_1]);",
"for (VAR_1 = 0; VAR_1 < VAR_0->quant_table_count; VAR_1++) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1] * CONTEXT_SIZE; VAR_2++)",
"if (VAR_0->initial_states[VAR_1] && VAR_0->initial_states[VAR_1][0][VAR_2] != 128)\nbreak;",
"if (VAR_2 < VAR_0->context_count[VAR_1] * CONTEXT_SIZE) {",
"put_rac(c, state, 1);",
"for (VAR_2 = 0; VAR_2 < VAR_0->context_count[VAR_1]; VAR_2++)",
"for (VAR_3 = 0; VAR_3 < CONTEXT_SIZE; VAR_3++) {",
"int pred = VAR_2 ? VAR_0->initial_states[VAR_1][VAR_2 - 1][VAR_3] : 128;",
"put_symbol(c, state2[VAR_3],\n(int8_t)(VAR_0->initial_states[VAR_1][VAR_2][VAR_3] - pred), 1);",
"}",
"} else {",
"put_rac(c, state, 0);",
"}",
"}",
"if (VAR_0->version > 2) {",
"put_symbol(c, state, VAR_0->ec, 0);",
"put_symbol(c, state, VAR_0->intra = (VAR_0->avctx->gop_size < 2), 0);",
"}",
"VAR_0->avctx->extradata_size = ff_rac_terminate(c);",
"VAR_4 = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, VAR_0->avctx->extradata, VAR_0->avctx->extradata_size);",
"AV_WL32(VAR_0->avctx->extradata + VAR_0->avctx->extradata_size, VAR_4);",
"VAR_0->avctx->extradata_size += 4;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91,
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
]
] |
1,877 | int qemu_strtol(const char *nptr, const char **endptr, int base,
long *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtol(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| true | qemu | 47d4be12c3997343e436c6cca89aefbbbeb70863 | int qemu_strtol(const char *nptr, const char **endptr, int base,
long *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtol(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| {
"code": [
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);",
" err = check_strtox_error(endptr, p, errno);"
],
"line_no": [
27,
27,
27,
27
]
} | int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,
long *VAR_3)
{
char *VAR_4;
int VAR_5 = 0;
if (!VAR_0) {
if (VAR_1) {
*VAR_1 = VAR_0;
}
VAR_5 = -EINVAL;
} else {
errno = 0;
*VAR_3 = strtol(VAR_0, &VAR_4, VAR_2);
VAR_5 = check_strtox_error(VAR_1, VAR_4, errno);
}
return VAR_5;
}
| [
"int FUNC_0(const char *VAR_0, const char **VAR_1, int VAR_2,\nlong *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5 = 0;",
"if (!VAR_0) {",
"if (VAR_1) {",
"*VAR_1 = VAR_0;",
"}",
"VAR_5 = -EINVAL;",
"} else {",
"errno = 0;",
"*VAR_3 = strtol(VAR_0, &VAR_4, VAR_2);",
"VAR_5 = check_strtox_error(VAR_1, VAR_4, errno);",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
1,879 | static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
{
Error *local_err = NULL;
bool vsmt_user = !!spapr->vsmt;
int kvm_smt = kvmppc_smt_threads();
int ret;
if (!kvm_enabled() && (smp_threads > 1)) {
error_setg(&local_err, "TCG cannot support more than 1 thread/core "
"on a pseries machine");
goto out;
}
if (!is_power_of_2(smp_threads)) {
error_setg(&local_err, "Cannot support %d threads/core on a pseries "
"machine because it must be a power of 2", smp_threads);
goto out;
}
/* Detemine the VSMT mode to use: */
if (vsmt_user) {
if (spapr->vsmt < smp_threads) {
error_setg(&local_err, "Cannot support VSMT mode %d"
" because it must be >= threads/core (%d)",
spapr->vsmt, smp_threads);
goto out;
}
/* In this case, spapr->vsmt has been set by the command line */
} else {
/* Choose a VSMT mode that may be higher than necessary but is
* likely to be compatible with hosts that don't have VSMT. */
spapr->vsmt = MAX(kvm_smt, smp_threads);
}
/* KVM: If necessary, set the SMT mode: */
if (kvm_enabled() && (spapr->vsmt != kvm_smt)) {
ret = kvmppc_set_smt_threads(spapr->vsmt);
if (ret) {
/* Looks like KVM isn't able to change VSMT mode */
error_setg(&local_err,
"Failed to set KVM's VSMT mode to %d (errno %d)",
spapr->vsmt, ret);
/* We can live with that if the default one is big enough
* for the number of threads, and a submultiple of the one
* we want. In this case we'll waste some vcpu ids, but
* behaviour will be correct */
if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
warn_report_err(local_err);
local_err = NULL;
goto out;
} else {
if (!vsmt_user) {
error_append_hint(&local_err,
"On PPC, a VM with %d threads/core"
" on a host with %d threads/core"
" requires the use of VSMT mode %d.\n",
smp_threads, kvm_smt, spapr->vsmt);
}
kvmppc_hint_smt_possible(&local_err);
goto out;
}
}
}
/* else TCG: nothing to do currently */
out:
error_propagate(errp, local_err);
}
| true | qemu | 8904e5a75005fe579c28806003892d8ae4a27dfa | static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
{
Error *local_err = NULL;
bool vsmt_user = !!spapr->vsmt;
int kvm_smt = kvmppc_smt_threads();
int ret;
if (!kvm_enabled() && (smp_threads > 1)) {
error_setg(&local_err, "TCG cannot support more than 1 thread/core "
"on a pseries machine");
goto out;
}
if (!is_power_of_2(smp_threads)) {
error_setg(&local_err, "Cannot support %d threads/core on a pseries "
"machine because it must be a power of 2", smp_threads);
goto out;
}
if (vsmt_user) {
if (spapr->vsmt < smp_threads) {
error_setg(&local_err, "Cannot support VSMT mode %d"
" because it must be >= threads/core (%d)",
spapr->vsmt, smp_threads);
goto out;
}
} else {
spapr->vsmt = MAX(kvm_smt, smp_threads);
}
if (kvm_enabled() && (spapr->vsmt != kvm_smt)) {
ret = kvmppc_set_smt_threads(spapr->vsmt);
if (ret) {
error_setg(&local_err,
"Failed to set KVM's VSMT mode to %d (errno %d)",
spapr->vsmt, ret);
if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
warn_report_err(local_err);
local_err = NULL;
goto out;
} else {
if (!vsmt_user) {
error_append_hint(&local_err,
"On PPC, a VM with %d threads/core"
" on a host with %d threads/core"
" requires the use of VSMT mode %d.\n",
smp_threads, kvm_smt, spapr->vsmt);
}
kvmppc_hint_smt_possible(&local_err);
goto out;
}
}
}
out:
error_propagate(errp, local_err);
}
| {
"code": [
" spapr->vsmt = MAX(kvm_smt, smp_threads);"
],
"line_no": [
61
]
} | static void FUNC_0(sPAPRMachineState *VAR_0, Error **VAR_1)
{
Error *local_err = NULL;
bool vsmt_user = !!VAR_0->vsmt;
int VAR_2 = kvmppc_smt_threads();
int VAR_3;
if (!kvm_enabled() && (smp_threads > 1)) {
error_setg(&local_err, "TCG cannot support more than 1 thread/core "
"on a pseries machine");
goto out;
}
if (!is_power_of_2(smp_threads)) {
error_setg(&local_err, "Cannot support %d threads/core on a pseries "
"machine because it must be a power of 2", smp_threads);
goto out;
}
if (vsmt_user) {
if (VAR_0->vsmt < smp_threads) {
error_setg(&local_err, "Cannot support VSMT mode %d"
" because it must be >= threads/core (%d)",
VAR_0->vsmt, smp_threads);
goto out;
}
} else {
VAR_0->vsmt = MAX(VAR_2, smp_threads);
}
if (kvm_enabled() && (VAR_0->vsmt != VAR_2)) {
VAR_3 = kvmppc_set_smt_threads(VAR_0->vsmt);
if (VAR_3) {
error_setg(&local_err,
"Failed to set KVM's VSMT mode to %d (errno %d)",
VAR_0->vsmt, VAR_3);
if ((VAR_2 >= smp_threads) && ((VAR_0->vsmt % VAR_2) == 0)) {
warn_report_err(local_err);
local_err = NULL;
goto out;
} else {
if (!vsmt_user) {
error_append_hint(&local_err,
"On PPC, a VM with %d threads/core"
" on a host with %d threads/core"
" requires the use of VSMT mode %d.\n",
smp_threads, VAR_2, VAR_0->vsmt);
}
kvmppc_hint_smt_possible(&local_err);
goto out;
}
}
}
out:
error_propagate(VAR_1, local_err);
}
| [
"static void FUNC_0(sPAPRMachineState *VAR_0, Error **VAR_1)\n{",
"Error *local_err = NULL;",
"bool vsmt_user = !!VAR_0->vsmt;",
"int VAR_2 = kvmppc_smt_threads();",
"int VAR_3;",
"if (!kvm_enabled() && (smp_threads > 1)) {",
"error_setg(&local_err, \"TCG cannot support more than 1 thread/core \"\n\"on a pseries machine\");",
"goto out;",
"}",
"if (!is_power_of_2(smp_threads)) {",
"error_setg(&local_err, \"Cannot support %d threads/core on a pseries \"\n\"machine because it must be a power of 2\", smp_threads);",
"goto out;",
"}",
"if (vsmt_user) {",
"if (VAR_0->vsmt < smp_threads) {",
"error_setg(&local_err, \"Cannot support VSMT mode %d\"\n\" because it must be >= threads/core (%d)\",\nVAR_0->vsmt, smp_threads);",
"goto out;",
"}",
"} else {",
"VAR_0->vsmt = MAX(VAR_2, smp_threads);",
"}",
"if (kvm_enabled() && (VAR_0->vsmt != VAR_2)) {",
"VAR_3 = kvmppc_set_smt_threads(VAR_0->vsmt);",
"if (VAR_3) {",
"error_setg(&local_err,\n\"Failed to set KVM's VSMT mode to %d (errno %d)\",\nVAR_0->vsmt, VAR_3);",
"if ((VAR_2 >= smp_threads) && ((VAR_0->vsmt % VAR_2) == 0)) {",
"warn_report_err(local_err);",
"local_err = NULL;",
"goto out;",
"} else {",
"if (!vsmt_user) {",
"error_append_hint(&local_err,\n\"On PPC, a VM with %d threads/core\"\n\" on a host with %d threads/core\"\n\" requires the use of VSMT mode %d.\\n\",\nsmp_threads, VAR_2, VAR_0->vsmt);",
"}",
"kvmppc_hint_smt_possible(&local_err);",
"goto out;",
"}",
"}",
"}",
"out:\nerror_propagate(VAR_1, local_err);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43,
45,
47
],
[
49
],
[
51
],
[
55
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
77,
79,
81
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105,
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
131
]
] |
1,880 | static void pci_bridge_update_mappings(PCIBridge *br)
{
/* Make updates atomic to: handle the case of one VCPU updating the bridge
* while another accesses an unaffected region. */
memory_region_transaction_begin();
pci_bridge_region_cleanup(br);
pci_bridge_region_init(br);
memory_region_transaction_commit();
}
| true | qemu | b308c82cbda44e138ef990af64d44a5613c16092 | static void pci_bridge_update_mappings(PCIBridge *br)
{
memory_region_transaction_begin();
pci_bridge_region_cleanup(br);
pci_bridge_region_init(br);
memory_region_transaction_commit();
}
| {
"code": [
" pci_bridge_region_cleanup(br);",
" pci_bridge_region_init(br);",
" pci_bridge_region_init(br);"
],
"line_no": [
11,
13,
13
]
} | static void FUNC_0(PCIBridge *VAR_0)
{
memory_region_transaction_begin();
pci_bridge_region_cleanup(VAR_0);
pci_bridge_region_init(VAR_0);
memory_region_transaction_commit();
}
| [
"static void FUNC_0(PCIBridge *VAR_0)\n{",
"memory_region_transaction_begin();",
"pci_bridge_region_cleanup(VAR_0);",
"pci_bridge_region_init(VAR_0);",
"memory_region_transaction_commit();",
"}"
] | [
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
1,881 | static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
omap_clk iclk, struct omap_mpu_state_s *mpu)
{
struct omap_sysctl_s *s = (struct omap_sysctl_s *)
g_malloc0(sizeof(struct omap_sysctl_s));
s->mpu = mpu;
omap_sysctl_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_sysctl_ops, s, "omap.sysctl",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| true | qemu | b45c03f585ea9bb1af76c73e82195418c294919d | static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
omap_clk iclk, struct omap_mpu_state_s *mpu)
{
struct omap_sysctl_s *s = (struct omap_sysctl_s *)
g_malloc0(sizeof(struct omap_sysctl_s));
s->mpu = mpu;
omap_sysctl_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_sysctl_ops, s, "omap.sysctl",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| {
"code": [
" struct omap_sysctl_s *s = (struct omap_sysctl_s *)",
" g_malloc0(sizeof(struct omap_sysctl_s));"
],
"line_no": [
7,
9
]
} | static struct omap_sysctl_s *FUNC_0(struct omap_target_agent_s *VAR_0,
omap_clk VAR_1, struct omap_mpu_state_s *VAR_2)
{
struct omap_sysctl_s *VAR_3 = (struct omap_sysctl_s *)
g_malloc0(sizeof(struct omap_sysctl_s));
VAR_3->VAR_2 = VAR_2;
omap_sysctl_reset(VAR_3);
memory_region_init_io(&VAR_3->iomem, NULL, &omap_sysctl_ops, VAR_3, "omap.sysctl",
omap_l4_region_size(VAR_0, 0));
omap_l4_attach(VAR_0, 0, &VAR_3->iomem);
return VAR_3;
}
| [
"static struct omap_sysctl_s *FUNC_0(struct omap_target_agent_s *VAR_0,\nomap_clk VAR_1, struct omap_mpu_state_s *VAR_2)\n{",
"struct omap_sysctl_s *VAR_3 = (struct omap_sysctl_s *)\ng_malloc0(sizeof(struct omap_sysctl_s));",
"VAR_3->VAR_2 = VAR_2;",
"omap_sysctl_reset(VAR_3);",
"memory_region_init_io(&VAR_3->iomem, NULL, &omap_sysctl_ops, VAR_3, \"omap.sysctl\",\nomap_l4_region_size(VAR_0, 0));",
"omap_l4_attach(VAR_0, 0, &VAR_3->iomem);",
"return VAR_3;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
27
],
[
29
]
] |
1,884 | static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
int size = pkt->size;
uint8_t *buf = pkt->data;
uint8_t *data = NULL;
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
int64_t dts = pkt->dts, pts = pkt->pts;
if (ts->reemit_pat_pmt) {
av_log(s, AV_LOG_WARNING,
"resend_headers option is deprecated, use -mpegts_flags resend_headers\n");
ts->reemit_pat_pmt = 0;
ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
ts->flags &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->copyts < 1) {
if (pts != AV_NOPTS_VALUE)
pts += delay;
if (dts != AV_NOPTS_VALUE)
dts += delay;
}
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
return AVERROR_INVALIDDATA;
}
ts_st->first_pts_check = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p + size;
uint32_t state = -1;
int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;
int ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
if (extradd && AV_RB24(st->codec->extradata) > 1)
extradd = 0;
do {
p = avpriv_find_start_code(p, buf_end, &state);
av_log(s, AV_LOG_TRACE, "nal %d\n", state & 0x1f);
if ((state & 0x1f) == 7)
extradd = 0;
} while (p < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 5)
extradd = 0;
if ((state & 0x1f) != 9) { // AUD NAL
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
memcpy(data + 6, st->codec->extradata, extradd);
memcpy(data + 6 + extradd, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[5] = 0xf0; // any slice type (0xe) + rbsp stop one bit
buf = data;
size = pkt->size + 6 + extradd;
}
} else if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size < 2) {
av_log(s, AV_LOG_ERROR, "AAC packet too short\n");
return AVERROR_INVALIDDATA;
}
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) {
int ret;
AVPacket pkt2;
if (!ts_st->amux) {
av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format "
"and extradata missing\n");
return AVERROR_INVALIDDATA;
}
av_init_packet(&pkt2);
pkt2.data = pkt->data;
pkt2.size = pkt->size;
av_assert0(pkt->dts != AV_NOPTS_VALUE);
pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base);
ret = avio_open_dyn_buf(&ts_st->amux->pb);
if (ret < 0)
return AVERROR(ENOMEM);
ret = av_write_frame(ts_st->amux, &pkt2);
if (ret < 0) {
ffio_free_dyn_buf(&ts_st->amux->pb);
return ret;
}
size = avio_close_dyn_buf(ts_st->amux->pb, &data);
ts_st->amux->pb = NULL;
buf = data;
}
} else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
int ret = check_hevc_startcode(s, st, pkt);
if (ret < 0)
return ret;
}
if (pkt->dts != AV_NOPTS_VALUE) {
int i;
for(i=0; i<s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY);
ts_st2->payload_size = 0;
}
}
}
if (ts_st->payload_size && (ts_st->payload_size + size > ts->pes_payload_size ||
(dts != AV_NOPTS_VALUE && ts_st->payload_dts != AV_NOPTS_VALUE &&
av_compare_ts(dts - ts_st->payload_dts, st->time_base,
s->max_delay, AV_TIME_BASE_Q) >= 0))) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
// for video and subtitle, write a single pes packet
mpegts_write_pes(s, st, buf, size, pts, dts,
pkt->flags & AV_PKT_FLAG_KEY);
av_free(data);
return 0;
}
if (!ts_st->payload_size) {
ts_st->payload_pts = pts;
ts_st->payload_dts = dts;
ts_st->payload_flags = pkt->flags;
}
memcpy(ts_st->payload + ts_st->payload_size, buf, size);
ts_st->payload_size += size;
av_free(data);
return 0;
}
| true | FFmpeg | 1d5edad8ccfd1843bc8c60260a20ac37b738cb77 | static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
int size = pkt->size;
uint8_t *buf = pkt->data;
uint8_t *data = NULL;
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
int64_t dts = pkt->dts, pts = pkt->pts;
if (ts->reemit_pat_pmt) {
av_log(s, AV_LOG_WARNING,
"resend_headers option is deprecated, use -mpegts_flags resend_headers\n");
ts->reemit_pat_pmt = 0;
ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
ts->flags &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->copyts < 1) {
if (pts != AV_NOPTS_VALUE)
pts += delay;
if (dts != AV_NOPTS_VALUE)
dts += delay;
}
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
return AVERROR_INVALIDDATA;
}
ts_st->first_pts_check = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p + size;
uint32_t state = -1;
int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;
int ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
if (extradd && AV_RB24(st->codec->extradata) > 1)
extradd = 0;
do {
p = avpriv_find_start_code(p, buf_end, &state);
av_log(s, AV_LOG_TRACE, "nal %d\n", state & 0x1f);
if ((state & 0x1f) == 7)
extradd = 0;
} while (p < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 5)
extradd = 0;
if ((state & 0x1f) != 9) {
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
memcpy(data + 6, st->codec->extradata, extradd);
memcpy(data + 6 + extradd, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[5] = 0xf0;
buf = data;
size = pkt->size + 6 + extradd;
}
} else if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size < 2) {
av_log(s, AV_LOG_ERROR, "AAC packet too short\n");
return AVERROR_INVALIDDATA;
}
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) {
int ret;
AVPacket pkt2;
if (!ts_st->amux) {
av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format "
"and extradata missing\n");
return AVERROR_INVALIDDATA;
}
av_init_packet(&pkt2);
pkt2.data = pkt->data;
pkt2.size = pkt->size;
av_assert0(pkt->dts != AV_NOPTS_VALUE);
pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base);
ret = avio_open_dyn_buf(&ts_st->amux->pb);
if (ret < 0)
return AVERROR(ENOMEM);
ret = av_write_frame(ts_st->amux, &pkt2);
if (ret < 0) {
ffio_free_dyn_buf(&ts_st->amux->pb);
return ret;
}
size = avio_close_dyn_buf(ts_st->amux->pb, &data);
ts_st->amux->pb = NULL;
buf = data;
}
} else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
int ret = check_hevc_startcode(s, st, pkt);
if (ret < 0)
return ret;
}
if (pkt->dts != AV_NOPTS_VALUE) {
int i;
for(i=0; i<s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY);
ts_st2->payload_size = 0;
}
}
}
if (ts_st->payload_size && (ts_st->payload_size + size > ts->pes_payload_size ||
(dts != AV_NOPTS_VALUE && ts_st->payload_dts != AV_NOPTS_VALUE &&
av_compare_ts(dts - ts_st->payload_dts, st->time_base,
s->max_delay, AV_TIME_BASE_Q) >= 0))) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
mpegts_write_pes(s, st, buf, size, pts, dts,
pkt->flags & AV_PKT_FLAG_KEY);
av_free(data);
return 0;
}
if (!ts_st->payload_size) {
ts_st->payload_pts = pts;
ts_st->payload_dts = dts;
ts_st->payload_flags = pkt->flags;
}
memcpy(ts_st->payload + ts_st->payload_size, buf, size);
ts_st->payload_size += size;
av_free(data);
return 0;
}
| {
"code": [
" return AVERROR_INVALIDDATA;"
],
"line_no": [
165
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
AVStream *st = VAR_0->streams[VAR_1->stream_index];
int VAR_2 = VAR_1->VAR_2;
uint8_t *buf = VAR_1->data;
uint8_t *data = NULL;
MpegTSWrite *ts = VAR_0->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
const int64_t VAR_3 = av_rescale(VAR_0->max_delay, 90000, AV_TIME_BASE) * 2;
int64_t dts = VAR_1->dts, pts = VAR_1->pts;
if (ts->reemit_pat_pmt) {
av_log(VAR_0, AV_LOG_WARNING,
"resend_headers option is deprecated, use -mpegts_flags resend_headers\n");
ts->reemit_pat_pmt = 0;
ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
ts->flags &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->copyts < 1) {
if (pts != AV_NOPTS_VALUE)
pts += VAR_3;
if (dts != AV_NOPTS_VALUE)
dts += VAR_3;
}
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
av_log(VAR_0, AV_LOG_ERROR, "first pts value must be set\n");
return AVERROR_INVALIDDATA;
}
ts_st->first_pts_check = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264) {
const uint8_t *VAR_4 = buf, *buf_end = VAR_4 + VAR_2;
uint32_t state = -1;
int VAR_5 = (VAR_1->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;
int VAR_7 = ff_check_h264_startcode(VAR_0, st, VAR_1);
if (VAR_7 < 0)
return VAR_7;
if (VAR_5 && AV_RB24(st->codec->extradata) > 1)
VAR_5 = 0;
do {
VAR_4 = avpriv_find_start_code(VAR_4, buf_end, &state);
av_log(VAR_0, AV_LOG_TRACE, "nal %d\n", state & 0x1f);
if ((state & 0x1f) == 7)
VAR_5 = 0;
} while (VAR_4 < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 5)
VAR_5 = 0;
if ((state & 0x1f) != 9) {
data = av_malloc(VAR_1->VAR_2 + 6 + VAR_5);
if (!data)
return AVERROR(ENOMEM);
memcpy(data + 6, st->codec->extradata, VAR_5);
memcpy(data + 6 + VAR_5, VAR_1->data, VAR_1->VAR_2);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[5] = 0xf0;
buf = data;
VAR_2 = VAR_1->VAR_2 + 6 + VAR_5;
}
} else if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (VAR_1->VAR_2 < 2) {
av_log(VAR_0, AV_LOG_ERROR, "AAC packet too short\n");
return AVERROR_INVALIDDATA;
}
if ((AV_RB16(VAR_1->data) & 0xfff0) != 0xfff0) {
int VAR_7;
AVPacket pkt2;
if (!ts_st->amux) {
av_log(VAR_0, AV_LOG_ERROR, "AAC bitstream not in ADTS format "
"and extradata missing\n");
return AVERROR_INVALIDDATA;
}
av_init_packet(&pkt2);
pkt2.data = VAR_1->data;
pkt2.VAR_2 = VAR_1->VAR_2;
av_assert0(VAR_1->dts != AV_NOPTS_VALUE);
pkt2.dts = av_rescale_q(VAR_1->dts, st->time_base, ts_st->amux->streams[0]->time_base);
VAR_7 = avio_open_dyn_buf(&ts_st->amux->pb);
if (VAR_7 < 0)
return AVERROR(ENOMEM);
VAR_7 = av_write_frame(ts_st->amux, &pkt2);
if (VAR_7 < 0) {
ffio_free_dyn_buf(&ts_st->amux->pb);
return VAR_7;
}
VAR_2 = avio_close_dyn_buf(ts_st->amux->pb, &data);
ts_st->amux->pb = NULL;
buf = data;
}
} else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
int VAR_7 = check_hevc_startcode(VAR_0, st, VAR_1);
if (VAR_7 < 0)
return VAR_7;
}
if (VAR_1->dts != AV_NOPTS_VALUE) {
int VAR_7;
for(VAR_7=0; VAR_7<VAR_0->nb_streams; VAR_7++) {
AVStream *st2 = VAR_0->streams[VAR_7];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > VAR_3/2)) {
mpegts_write_pes(VAR_0, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY);
ts_st2->payload_size = 0;
}
}
}
if (ts_st->payload_size && (ts_st->payload_size + VAR_2 > ts->pes_payload_size ||
(dts != AV_NOPTS_VALUE && ts_st->payload_dts != AV_NOPTS_VALUE &&
av_compare_ts(dts - ts_st->payload_dts, st->time_base,
VAR_0->max_delay, AV_TIME_BASE_Q) >= 0))) {
mpegts_write_pes(VAR_0, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || VAR_2 > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
mpegts_write_pes(VAR_0, st, buf, VAR_2, pts, dts,
VAR_1->flags & AV_PKT_FLAG_KEY);
av_free(data);
return 0;
}
if (!ts_st->payload_size) {
ts_st->payload_pts = pts;
ts_st->payload_dts = dts;
ts_st->payload_flags = VAR_1->flags;
}
memcpy(ts_st->payload + ts_st->payload_size, buf, VAR_2);
ts_st->payload_size += VAR_2;
av_free(data);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"AVStream *st = VAR_0->streams[VAR_1->stream_index];",
"int VAR_2 = VAR_1->VAR_2;",
"uint8_t *buf = VAR_1->data;",
"uint8_t *data = NULL;",
"MpegTSWrite *ts = VAR_0->priv_data;",
"MpegTSWriteStream *ts_st = st->priv_data;",
"const int64_t VAR_3 = av_rescale(VAR_0->max_delay, 90000, AV_TIME_BASE) * 2;",
"int64_t dts = VAR_1->dts, pts = VAR_1->pts;",
"if (ts->reemit_pat_pmt) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"resend_headers option is deprecated, use -mpegts_flags resend_headers\\n\");",
"ts->reemit_pat_pmt = 0;",
"ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;",
"}",
"if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {",
"ts->pat_packet_count = ts->pat_packet_period - 1;",
"ts->sdt_packet_count = ts->sdt_packet_period - 1;",
"ts->flags &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;",
"}",
"if (ts->copyts < 1) {",
"if (pts != AV_NOPTS_VALUE)\npts += VAR_3;",
"if (dts != AV_NOPTS_VALUE)\ndts += VAR_3;",
"}",
"if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"first pts value must be set\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"ts_st->first_pts_check = 0;",
"if (st->codec->codec_id == AV_CODEC_ID_H264) {",
"const uint8_t *VAR_4 = buf, *buf_end = VAR_4 + VAR_2;",
"uint32_t state = -1;",
"int VAR_5 = (VAR_1->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;",
"int VAR_7 = ff_check_h264_startcode(VAR_0, st, VAR_1);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"if (VAR_5 && AV_RB24(st->codec->extradata) > 1)\nVAR_5 = 0;",
"do {",
"VAR_4 = avpriv_find_start_code(VAR_4, buf_end, &state);",
"av_log(VAR_0, AV_LOG_TRACE, \"nal %d\\n\", state & 0x1f);",
"if ((state & 0x1f) == 7)\nVAR_5 = 0;",
"} while (VAR_4 < buf_end && (state & 0x1f) != 9 &&",
"(state & 0x1f) != 5 && (state & 0x1f) != 1);",
"if ((state & 0x1f) != 5)\nVAR_5 = 0;",
"if ((state & 0x1f) != 9) {",
"data = av_malloc(VAR_1->VAR_2 + 6 + VAR_5);",
"if (!data)\nreturn AVERROR(ENOMEM);",
"memcpy(data + 6, st->codec->extradata, VAR_5);",
"memcpy(data + 6 + VAR_5, VAR_1->data, VAR_1->VAR_2);",
"AV_WB32(data, 0x00000001);",
"data[4] = 0x09;",
"data[5] = 0xf0;",
"buf = data;",
"VAR_2 = VAR_1->VAR_2 + 6 + VAR_5;",
"}",
"} else if (st->codec->codec_id == AV_CODEC_ID_AAC) {",
"if (VAR_1->VAR_2 < 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"AAC packet too short\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if ((AV_RB16(VAR_1->data) & 0xfff0) != 0xfff0) {",
"int VAR_7;",
"AVPacket pkt2;",
"if (!ts_st->amux) {",
"av_log(VAR_0, AV_LOG_ERROR, \"AAC bitstream not in ADTS format \"\n\"and extradata missing\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"av_init_packet(&pkt2);",
"pkt2.data = VAR_1->data;",
"pkt2.VAR_2 = VAR_1->VAR_2;",
"av_assert0(VAR_1->dts != AV_NOPTS_VALUE);",
"pkt2.dts = av_rescale_q(VAR_1->dts, st->time_base, ts_st->amux->streams[0]->time_base);",
"VAR_7 = avio_open_dyn_buf(&ts_st->amux->pb);",
"if (VAR_7 < 0)\nreturn AVERROR(ENOMEM);",
"VAR_7 = av_write_frame(ts_st->amux, &pkt2);",
"if (VAR_7 < 0) {",
"ffio_free_dyn_buf(&ts_st->amux->pb);",
"return VAR_7;",
"}",
"VAR_2 = avio_close_dyn_buf(ts_st->amux->pb, &data);",
"ts_st->amux->pb = NULL;",
"buf = data;",
"}",
"} else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {",
"int VAR_7 = check_hevc_startcode(VAR_0, st, VAR_1);",
"if (VAR_7 < 0)\nreturn VAR_7;",
"}",
"if (VAR_1->dts != AV_NOPTS_VALUE) {",
"int VAR_7;",
"for(VAR_7=0; VAR_7<VAR_0->nb_streams; VAR_7++) {",
"AVStream *st2 = VAR_0->streams[VAR_7];",
"MpegTSWriteStream *ts_st2 = st2->priv_data;",
"if ( ts_st2->payload_size\n&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > VAR_3/2)) {",
"mpegts_write_pes(VAR_0, st2, ts_st2->payload, ts_st2->payload_size,\nts_st2->payload_pts, ts_st2->payload_dts,\nts_st2->payload_flags & AV_PKT_FLAG_KEY);",
"ts_st2->payload_size = 0;",
"}",
"}",
"}",
"if (ts_st->payload_size && (ts_st->payload_size + VAR_2 > ts->pes_payload_size ||\n(dts != AV_NOPTS_VALUE && ts_st->payload_dts != AV_NOPTS_VALUE &&\nav_compare_ts(dts - ts_st->payload_dts, st->time_base,\nVAR_0->max_delay, AV_TIME_BASE_Q) >= 0))) {",
"mpegts_write_pes(VAR_0, st, ts_st->payload, ts_st->payload_size,\nts_st->payload_pts, ts_st->payload_dts,\nts_st->payload_flags & AV_PKT_FLAG_KEY);",
"ts_st->payload_size = 0;",
"}",
"if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || VAR_2 > ts->pes_payload_size) {",
"av_assert0(!ts_st->payload_size);",
"mpegts_write_pes(VAR_0, st, buf, VAR_2, pts, dts,\nVAR_1->flags & AV_PKT_FLAG_KEY);",
"av_free(data);",
"return 0;",
"}",
"if (!ts_st->payload_size) {",
"ts_st->payload_pts = pts;",
"ts_st->payload_dts = dts;",
"ts_st->payload_flags = VAR_1->flags;",
"}",
"memcpy(ts_st->payload + ts_st->payload_size, buf, VAR_2);",
"ts_st->payload_size += VAR_2;",
"av_free(data);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113,
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185,
187
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235,
237,
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
251,
253,
255,
257
],
[
259,
261,
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303
],
[
307
],
[
311
],
[
313
]
] |
1,885 | static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MP3Context *mp3 = s->priv_data;
if (pkt->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) {
/* buffer audio packets until we get all the pictures */
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
if (!pktl)
return AVERROR(ENOMEM);
pktl->pkt = *pkt;
pktl->pkt.buf = av_buffer_ref(pkt->buf);
if (!pktl->pkt.buf) {
av_freep(&pktl);
return AVERROR(ENOMEM);
}
if (mp3->queue_end)
mp3->queue_end->next = pktl;
else
mp3->queue = pktl;
mp3->queue_end = pktl;
} else
return mp3_write_audio_packet(s, pkt);
} else {
int ret;
/* warn only once for each stream */
if (s->streams[pkt->stream_index]->nb_frames == 1) {
av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
" ignoring.\n", pkt->stream_index);
}
if (!mp3->pics_to_write || s->streams[pkt->stream_index]->nb_frames >= 1)
return 0;
if ((ret = ff_id3v2_write_apic(s, &mp3->id3, pkt)) < 0)
return ret;
mp3->pics_to_write--;
/* flush the buffered audio packets */
if (!mp3->pics_to_write &&
(ret = mp3_queue_flush(s)) < 0)
return ret;
}
return 0;
}
| true | FFmpeg | d003a0cd2e587a47627fd328f9fc5a484adc29f2 | static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MP3Context *mp3 = s->priv_data;
if (pkt->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) {
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
if (!pktl)
return AVERROR(ENOMEM);
pktl->pkt = *pkt;
pktl->pkt.buf = av_buffer_ref(pkt->buf);
if (!pktl->pkt.buf) {
av_freep(&pktl);
return AVERROR(ENOMEM);
}
if (mp3->queue_end)
mp3->queue_end->next = pktl;
else
mp3->queue = pktl;
mp3->queue_end = pktl;
} else
return mp3_write_audio_packet(s, pkt);
} else {
int ret;
if (s->streams[pkt->stream_index]->nb_frames == 1) {
av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
" ignoring.\n", pkt->stream_index);
}
if (!mp3->pics_to_write || s->streams[pkt->stream_index]->nb_frames >= 1)
return 0;
if ((ret = ff_id3v2_write_apic(s, &mp3->id3, pkt)) < 0)
return ret;
mp3->pics_to_write--;
if (!mp3->pics_to_write &&
(ret = mp3_queue_flush(s)) < 0)
return ret;
}
return 0;
}
| {
"code": [
" pktl->pkt = *pkt;",
" pktl->pkt.buf = av_buffer_ref(pkt->buf);",
" if (!pktl->pkt.buf) {",
" return AVERROR(ENOMEM);"
],
"line_no": [
23,
25,
27,
19
]
} | static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
MP3Context *mp3 = VAR_0->priv_data;
if (VAR_1->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) {
AVPacketList *pktl = av_mallocz(sizeof(*pktl));
if (!pktl)
return AVERROR(ENOMEM);
pktl->VAR_1 = *VAR_1;
pktl->VAR_1.buf = av_buffer_ref(VAR_1->buf);
if (!pktl->VAR_1.buf) {
av_freep(&pktl);
return AVERROR(ENOMEM);
}
if (mp3->queue_end)
mp3->queue_end->next = pktl;
else
mp3->queue = pktl;
mp3->queue_end = pktl;
} else
return mp3_write_audio_packet(VAR_0, VAR_1);
} else {
int VAR_2;
if (VAR_0->streams[VAR_1->stream_index]->nb_frames == 1) {
av_log(VAR_0, AV_LOG_WARNING, "Got more than one picture in stream %d,"
" ignoring.\n", VAR_1->stream_index);
}
if (!mp3->pics_to_write || VAR_0->streams[VAR_1->stream_index]->nb_frames >= 1)
return 0;
if ((VAR_2 = ff_id3v2_write_apic(VAR_0, &mp3->id3, VAR_1)) < 0)
return VAR_2;
mp3->pics_to_write--;
if (!mp3->pics_to_write &&
(VAR_2 = mp3_queue_flush(VAR_0)) < 0)
return VAR_2;
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{",
"MP3Context *mp3 = VAR_0->priv_data;",
"if (VAR_1->stream_index == mp3->audio_stream_idx) {",
"if (mp3->pics_to_write) {",
"AVPacketList *pktl = av_mallocz(sizeof(*pktl));",
"if (!pktl)\nreturn AVERROR(ENOMEM);",
"pktl->VAR_1 = *VAR_1;",
"pktl->VAR_1.buf = av_buffer_ref(VAR_1->buf);",
"if (!pktl->VAR_1.buf) {",
"av_freep(&pktl);",
"return AVERROR(ENOMEM);",
"}",
"if (mp3->queue_end)\nmp3->queue_end->next = pktl;",
"else\nmp3->queue = pktl;",
"mp3->queue_end = pktl;",
"} else",
"return mp3_write_audio_packet(VAR_0, VAR_1);",
"} else {",
"int VAR_2;",
"if (VAR_0->streams[VAR_1->stream_index]->nb_frames == 1) {",
"av_log(VAR_0, AV_LOG_WARNING, \"Got more than one picture in stream %d,\"\n\" ignoring.\\n\", VAR_1->stream_index);",
"}",
"if (!mp3->pics_to_write || VAR_0->streams[VAR_1->stream_index]->nb_frames >= 1)\nreturn 0;",
"if ((VAR_2 = ff_id3v2_write_apic(VAR_0, &mp3->id3, VAR_1)) < 0)\nreturn VAR_2;",
"mp3->pics_to_write--;",
"if (!mp3->pics_to_write &&\n(VAR_2 = mp3_queue_flush(VAR_0)) < 0)\nreturn VAR_2;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
73,
75
],
[
77
],
[
83,
85,
87
],
[
89
],
[
93
],
[
95
]
] |
1,886 | static void ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIQXLDevice *d = opaque;
uint32_t io_port = addr;
qxl_async_io async = QXL_SYNC;
uint32_t orig_io_port = io_port;
if (d->guest_bug && !io_port == QXL_IO_RESET) {
return;
if (d->revision <= QXL_REVISION_STABLE_V10 &&
io_port >= QXL_IO_FLUSH_SURFACES_ASYNC) {
qxl_set_guest_bug(d, "unsupported io %d for revision %d\n",
io_port, d->revision);
return;
switch (io_port) {
case QXL_IO_RESET:
case QXL_IO_SET_MODE:
case QXL_IO_MEMSLOT_ADD:
case QXL_IO_MEMSLOT_DEL:
case QXL_IO_CREATE_PRIMARY:
case QXL_IO_UPDATE_IRQ:
case QXL_IO_LOG:
case QXL_IO_MEMSLOT_ADD_ASYNC:
case QXL_IO_CREATE_PRIMARY_ASYNC:
default:
if (d->mode != QXL_MODE_VGA) {
trace_qxl_io_unexpected_vga_mode(d->id,
io_port, io_port_to_string(io_port));
/* be nice to buggy guest drivers */
if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&
io_port < QXL_IO_RANGE_SIZE) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
return;
/* we change the io_port to avoid ifdeffery in the main switch */
orig_io_port = io_port;
switch (io_port) {
case QXL_IO_UPDATE_AREA_ASYNC:
io_port = QXL_IO_UPDATE_AREA;
goto async_common;
case QXL_IO_MEMSLOT_ADD_ASYNC:
io_port = QXL_IO_MEMSLOT_ADD;
goto async_common;
case QXL_IO_CREATE_PRIMARY_ASYNC:
io_port = QXL_IO_CREATE_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_PRIMARY_ASYNC:
io_port = QXL_IO_DESTROY_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_SURFACE_ASYNC:
io_port = QXL_IO_DESTROY_SURFACE_WAIT;
goto async_common;
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
io_port = QXL_IO_DESTROY_ALL_SURFACES;
goto async_common;
case QXL_IO_FLUSH_SURFACES_ASYNC:
case QXL_IO_MONITORS_CONFIG_ASYNC:
async_common:
async = QXL_ASYNC;
qemu_mutex_lock(&d->async_lock);
if (d->current_async != QXL_UNDEFINED_IO) {
qxl_set_guest_bug(d, "%d async started before last (%d) complete",
io_port, d->current_async);
qemu_mutex_unlock(&d->async_lock);
return;
d->current_async = orig_io_port;
qemu_mutex_unlock(&d->async_lock);
default:
trace_qxl_io_write(d->id, qxl_mode_to_string(d->mode), addr, val, size,
async);
switch (io_port) {
case QXL_IO_UPDATE_AREA:
{
QXLCookie *cookie = NULL;
QXLRect update = d->ram->update_area;
if (d->ram->update_surface > d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
d->ram->update_surface);
return;
if (update.left >= update.right || update.top >= update.bottom) {
qxl_set_guest_bug(d,
"QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
update.left, update.top, update.right, update.bottom);
return;
if (async == QXL_ASYNC) {
cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
QXL_IO_UPDATE_AREA_ASYNC);
cookie->u.area = update;
qxl_spice_update_area(d, d->ram->update_surface,
cookie ? &cookie->u.area : &update,
NULL, 0, 0, async, cookie);
case QXL_IO_NOTIFY_CMD:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_NOTIFY_CURSOR:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_UPDATE_IRQ:
qxl_update_irq(d);
case QXL_IO_NOTIFY_OOM:
if (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {
d->oom_running = 1;
qxl_spice_oom(d);
d->oom_running = 0;
case QXL_IO_SET_MODE:
qxl_set_mode(d, val, 0);
case QXL_IO_LOG:
if (d->guestdebug) {
fprintf(stderr, "qxl/guest-%d: %" PRId64 ": %s", d->id,
qemu_get_clock_ns(vm_clock), d->ram->log_buf);
case QXL_IO_RESET:
qxl_hard_reset(d, 0);
case QXL_IO_MEMSLOT_ADD:
if (val >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_ADD: val out of range");
if (d->guest_slots[val].active) {
qxl_set_guest_bug(d,
"QXL_IO_MEMSLOT_ADD: memory slot already active");
d->guest_slots[val].slot = d->ram->mem_slot;
qxl_add_memslot(d, val, 0, async);
case QXL_IO_MEMSLOT_DEL:
if (val >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_DEL: val out of range");
qxl_del_memslot(d, val);
case QXL_IO_CREATE_PRIMARY:
if (val != 0) {
qxl_set_guest_bug(d, "QXL_IO_CREATE_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
d->guest_primary.surface = d->ram->create_surface;
qxl_create_guest_primary(d, 0, async);
case QXL_IO_DESTROY_PRIMARY:
if (val != 0) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
if (!qxl_destroy_primary(d, async)) {
trace_qxl_io_destroy_primary_ignored(d->id,
qxl_mode_to_string(d->mode));
goto cancel_async;
case QXL_IO_DESTROY_SURFACE_WAIT:
if (val >= d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
"%" PRIu64 " >= NUM_SURFACES", async, val);
goto cancel_async;
qxl_spice_destroy_surface_wait(d, val, async);
case QXL_IO_FLUSH_RELEASE: {
QXLReleaseRing *ring = &d->ram->release_ring;
if (ring->prod - ring->cons + 1 == ring->num_items) {
fprintf(stderr,
"ERROR: no flush, full release ring [p%d,%dc]\n",
ring->prod, ring->cons);
qxl_push_free_res(d, 1 /* flush */);
case QXL_IO_FLUSH_SURFACES_ASYNC:
qxl_spice_flush_surfaces_async(d);
case QXL_IO_DESTROY_ALL_SURFACES:
d->mode = QXL_MODE_UNDEFINED;
qxl_spice_destroy_surfaces(d, async);
case QXL_IO_MONITORS_CONFIG_ASYNC:
qxl_spice_monitors_config_async(d, 0);
default:
qxl_set_guest_bug(d, "%s: unexpected ioport=0x%x\n", __func__, io_port);
return;
cancel_async:
if (async) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
qemu_mutex_lock(&d->async_lock);
d->current_async = QXL_UNDEFINED_IO;
qemu_mutex_unlock(&d->async_lock);
| true | qemu | ccc2960d654a233a6ed415b37d8ff41728d817c5 | static void ioport_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
PCIQXLDevice *d = opaque;
uint32_t io_port = addr;
qxl_async_io async = QXL_SYNC;
uint32_t orig_io_port = io_port;
if (d->guest_bug && !io_port == QXL_IO_RESET) {
return;
if (d->revision <= QXL_REVISION_STABLE_V10 &&
io_port >= QXL_IO_FLUSH_SURFACES_ASYNC) {
qxl_set_guest_bug(d, "unsupported io %d for revision %d\n",
io_port, d->revision);
return;
switch (io_port) {
case QXL_IO_RESET:
case QXL_IO_SET_MODE:
case QXL_IO_MEMSLOT_ADD:
case QXL_IO_MEMSLOT_DEL:
case QXL_IO_CREATE_PRIMARY:
case QXL_IO_UPDATE_IRQ:
case QXL_IO_LOG:
case QXL_IO_MEMSLOT_ADD_ASYNC:
case QXL_IO_CREATE_PRIMARY_ASYNC:
default:
if (d->mode != QXL_MODE_VGA) {
trace_qxl_io_unexpected_vga_mode(d->id,
io_port, io_port_to_string(io_port));
if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&
io_port < QXL_IO_RANGE_SIZE) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
return;
orig_io_port = io_port;
switch (io_port) {
case QXL_IO_UPDATE_AREA_ASYNC:
io_port = QXL_IO_UPDATE_AREA;
goto async_common;
case QXL_IO_MEMSLOT_ADD_ASYNC:
io_port = QXL_IO_MEMSLOT_ADD;
goto async_common;
case QXL_IO_CREATE_PRIMARY_ASYNC:
io_port = QXL_IO_CREATE_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_PRIMARY_ASYNC:
io_port = QXL_IO_DESTROY_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_SURFACE_ASYNC:
io_port = QXL_IO_DESTROY_SURFACE_WAIT;
goto async_common;
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
io_port = QXL_IO_DESTROY_ALL_SURFACES;
goto async_common;
case QXL_IO_FLUSH_SURFACES_ASYNC:
case QXL_IO_MONITORS_CONFIG_ASYNC:
async_common:
async = QXL_ASYNC;
qemu_mutex_lock(&d->async_lock);
if (d->current_async != QXL_UNDEFINED_IO) {
qxl_set_guest_bug(d, "%d async started before last (%d) complete",
io_port, d->current_async);
qemu_mutex_unlock(&d->async_lock);
return;
d->current_async = orig_io_port;
qemu_mutex_unlock(&d->async_lock);
default:
trace_qxl_io_write(d->id, qxl_mode_to_string(d->mode), addr, val, size,
async);
switch (io_port) {
case QXL_IO_UPDATE_AREA:
{
QXLCookie *cookie = NULL;
QXLRect update = d->ram->update_area;
if (d->ram->update_surface > d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
d->ram->update_surface);
return;
if (update.left >= update.right || update.top >= update.bottom) {
qxl_set_guest_bug(d,
"QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
update.left, update.top, update.right, update.bottom);
return;
if (async == QXL_ASYNC) {
cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
QXL_IO_UPDATE_AREA_ASYNC);
cookie->u.area = update;
qxl_spice_update_area(d, d->ram->update_surface,
cookie ? &cookie->u.area : &update,
NULL, 0, 0, async, cookie);
case QXL_IO_NOTIFY_CMD:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_NOTIFY_CURSOR:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_UPDATE_IRQ:
qxl_update_irq(d);
case QXL_IO_NOTIFY_OOM:
if (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {
d->oom_running = 1;
qxl_spice_oom(d);
d->oom_running = 0;
case QXL_IO_SET_MODE:
qxl_set_mode(d, val, 0);
case QXL_IO_LOG:
if (d->guestdebug) {
fprintf(stderr, "qxl/guest-%d: %" PRId64 ": %s", d->id,
qemu_get_clock_ns(vm_clock), d->ram->log_buf);
case QXL_IO_RESET:
qxl_hard_reset(d, 0);
case QXL_IO_MEMSLOT_ADD:
if (val >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_ADD: val out of range");
if (d->guest_slots[val].active) {
qxl_set_guest_bug(d,
"QXL_IO_MEMSLOT_ADD: memory slot already active");
d->guest_slots[val].slot = d->ram->mem_slot;
qxl_add_memslot(d, val, 0, async);
case QXL_IO_MEMSLOT_DEL:
if (val >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_DEL: val out of range");
qxl_del_memslot(d, val);
case QXL_IO_CREATE_PRIMARY:
if (val != 0) {
qxl_set_guest_bug(d, "QXL_IO_CREATE_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
d->guest_primary.surface = d->ram->create_surface;
qxl_create_guest_primary(d, 0, async);
case QXL_IO_DESTROY_PRIMARY:
if (val != 0) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_PRIMARY (async=%d): val != 0",
async);
goto cancel_async;
if (!qxl_destroy_primary(d, async)) {
trace_qxl_io_destroy_primary_ignored(d->id,
qxl_mode_to_string(d->mode));
goto cancel_async;
case QXL_IO_DESTROY_SURFACE_WAIT:
if (val >= d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
"%" PRIu64 " >= NUM_SURFACES", async, val);
goto cancel_async;
qxl_spice_destroy_surface_wait(d, val, async);
case QXL_IO_FLUSH_RELEASE: {
QXLReleaseRing *ring = &d->ram->release_ring;
if (ring->prod - ring->cons + 1 == ring->num_items) {
fprintf(stderr,
"ERROR: no flush, full release ring [p%d,%dc]\n",
ring->prod, ring->cons);
qxl_push_free_res(d, 1 );
case QXL_IO_FLUSH_SURFACES_ASYNC:
qxl_spice_flush_surfaces_async(d);
case QXL_IO_DESTROY_ALL_SURFACES:
d->mode = QXL_MODE_UNDEFINED;
qxl_spice_destroy_surfaces(d, async);
case QXL_IO_MONITORS_CONFIG_ASYNC:
qxl_spice_monitors_config_async(d, 0);
default:
qxl_set_guest_bug(d, "%s: unexpected ioport=0x%x\n", __func__, io_port);
return;
cancel_async:
if (async) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
qemu_mutex_lock(&d->async_lock);
d->current_async = QXL_UNDEFINED_IO;
qemu_mutex_unlock(&d->async_lock);
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
PCIQXLDevice *d = VAR_0;
uint32_t io_port = VAR_1;
qxl_async_io async = QXL_SYNC;
uint32_t orig_io_port = io_port;
if (d->guest_bug && !io_port == QXL_IO_RESET) {
return;
if (d->revision <= QXL_REVISION_STABLE_V10 &&
io_port >= QXL_IO_FLUSH_SURFACES_ASYNC) {
qxl_set_guest_bug(d, "unsupported io %d for revision %d\n",
io_port, d->revision);
return;
switch (io_port) {
case QXL_IO_RESET:
case QXL_IO_SET_MODE:
case QXL_IO_MEMSLOT_ADD:
case QXL_IO_MEMSLOT_DEL:
case QXL_IO_CREATE_PRIMARY:
case QXL_IO_UPDATE_IRQ:
case QXL_IO_LOG:
case QXL_IO_MEMSLOT_ADD_ASYNC:
case QXL_IO_CREATE_PRIMARY_ASYNC:
default:
if (d->mode != QXL_MODE_VGA) {
trace_qxl_io_unexpected_vga_mode(d->id,
io_port, io_port_to_string(io_port));
if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&
io_port < QXL_IO_RANGE_SIZE) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
return;
orig_io_port = io_port;
switch (io_port) {
case QXL_IO_UPDATE_AREA_ASYNC:
io_port = QXL_IO_UPDATE_AREA;
goto async_common;
case QXL_IO_MEMSLOT_ADD_ASYNC:
io_port = QXL_IO_MEMSLOT_ADD;
goto async_common;
case QXL_IO_CREATE_PRIMARY_ASYNC:
io_port = QXL_IO_CREATE_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_PRIMARY_ASYNC:
io_port = QXL_IO_DESTROY_PRIMARY;
goto async_common;
case QXL_IO_DESTROY_SURFACE_ASYNC:
io_port = QXL_IO_DESTROY_SURFACE_WAIT;
goto async_common;
case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:
io_port = QXL_IO_DESTROY_ALL_SURFACES;
goto async_common;
case QXL_IO_FLUSH_SURFACES_ASYNC:
case QXL_IO_MONITORS_CONFIG_ASYNC:
async_common:
async = QXL_ASYNC;
qemu_mutex_lock(&d->async_lock);
if (d->current_async != QXL_UNDEFINED_IO) {
qxl_set_guest_bug(d, "%d async started before last (%d) complete",
io_port, d->current_async);
qemu_mutex_unlock(&d->async_lock);
return;
d->current_async = orig_io_port;
qemu_mutex_unlock(&d->async_lock);
default:
trace_qxl_io_write(d->id, qxl_mode_to_string(d->mode), VAR_1, VAR_2, VAR_3,
async);
switch (io_port) {
case QXL_IO_UPDATE_AREA:
{
QXLCookie *cookie = NULL;
QXLRect update = d->ram->update_area;
if (d->ram->update_surface > d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
d->ram->update_surface);
return;
if (update.left >= update.right || update.top >= update.bottom) {
qxl_set_guest_bug(d,
"QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
update.left, update.top, update.right, update.bottom);
return;
if (async == QXL_ASYNC) {
cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
QXL_IO_UPDATE_AREA_ASYNC);
cookie->u.area = update;
qxl_spice_update_area(d, d->ram->update_surface,
cookie ? &cookie->u.area : &update,
NULL, 0, 0, async, cookie);
case QXL_IO_NOTIFY_CMD:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_NOTIFY_CURSOR:
qemu_spice_wakeup(&d->ssd);
case QXL_IO_UPDATE_IRQ:
qxl_update_irq(d);
case QXL_IO_NOTIFY_OOM:
if (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {
d->oom_running = 1;
qxl_spice_oom(d);
d->oom_running = 0;
case QXL_IO_SET_MODE:
qxl_set_mode(d, VAR_2, 0);
case QXL_IO_LOG:
if (d->guestdebug) {
fprintf(stderr, "qxl/guest-%d: %" PRId64 ": %s", d->id,
qemu_get_clock_ns(vm_clock), d->ram->log_buf);
case QXL_IO_RESET:
qxl_hard_reset(d, 0);
case QXL_IO_MEMSLOT_ADD:
if (VAR_2 >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_ADD: VAR_2 out of range");
if (d->guest_slots[VAR_2].active) {
qxl_set_guest_bug(d,
"QXL_IO_MEMSLOT_ADD: memory slot already active");
d->guest_slots[VAR_2].slot = d->ram->mem_slot;
qxl_add_memslot(d, VAR_2, 0, async);
case QXL_IO_MEMSLOT_DEL:
if (VAR_2 >= NUM_MEMSLOTS) {
qxl_set_guest_bug(d, "QXL_IO_MEMSLOT_DEL: VAR_2 out of range");
qxl_del_memslot(d, VAR_2);
case QXL_IO_CREATE_PRIMARY:
if (VAR_2 != 0) {
qxl_set_guest_bug(d, "QXL_IO_CREATE_PRIMARY (async=%d): VAR_2 != 0",
async);
goto cancel_async;
d->guest_primary.surface = d->ram->create_surface;
qxl_create_guest_primary(d, 0, async);
case QXL_IO_DESTROY_PRIMARY:
if (VAR_2 != 0) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_PRIMARY (async=%d): VAR_2 != 0",
async);
goto cancel_async;
if (!qxl_destroy_primary(d, async)) {
trace_qxl_io_destroy_primary_ignored(d->id,
qxl_mode_to_string(d->mode));
goto cancel_async;
case QXL_IO_DESTROY_SURFACE_WAIT:
if (VAR_2 >= d->ssd.num_surfaces) {
qxl_set_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
"%" PRIu64 " >= NUM_SURFACES", async, VAR_2);
goto cancel_async;
qxl_spice_destroy_surface_wait(d, VAR_2, async);
case QXL_IO_FLUSH_RELEASE: {
QXLReleaseRing *ring = &d->ram->release_ring;
if (ring->prod - ring->cons + 1 == ring->num_items) {
fprintf(stderr,
"ERROR: no flush, full release ring [p%d,%dc]\n",
ring->prod, ring->cons);
qxl_push_free_res(d, 1 );
case QXL_IO_FLUSH_SURFACES_ASYNC:
qxl_spice_flush_surfaces_async(d);
case QXL_IO_DESTROY_ALL_SURFACES:
d->mode = QXL_MODE_UNDEFINED;
qxl_spice_destroy_surfaces(d, async);
case QXL_IO_MONITORS_CONFIG_ASYNC:
qxl_spice_monitors_config_async(d, 0);
default:
qxl_set_guest_bug(d, "%s: unexpected ioport=0x%x\n", __func__, io_port);
return;
cancel_async:
if (async) {
qxl_send_events(d, QXL_INTERRUPT_IO_CMD);
qemu_mutex_lock(&d->async_lock);
d->current_async = QXL_UNDEFINED_IO;
qemu_mutex_unlock(&d->async_lock);
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"PCIQXLDevice *d = VAR_0;",
"uint32_t io_port = VAR_1;",
"qxl_async_io async = QXL_SYNC;",
"uint32_t orig_io_port = io_port;",
"if (d->guest_bug && !io_port == QXL_IO_RESET) {",
"return;",
"if (d->revision <= QXL_REVISION_STABLE_V10 &&\nio_port >= QXL_IO_FLUSH_SURFACES_ASYNC) {",
"qxl_set_guest_bug(d, \"unsupported io %d for revision %d\\n\",\nio_port, d->revision);",
"return;",
"switch (io_port) {",
"case QXL_IO_RESET:\ncase QXL_IO_SET_MODE:\ncase QXL_IO_MEMSLOT_ADD:\ncase QXL_IO_MEMSLOT_DEL:\ncase QXL_IO_CREATE_PRIMARY:\ncase QXL_IO_UPDATE_IRQ:\ncase QXL_IO_LOG:\ncase QXL_IO_MEMSLOT_ADD_ASYNC:\ncase QXL_IO_CREATE_PRIMARY_ASYNC:\ndefault:\nif (d->mode != QXL_MODE_VGA) {",
"trace_qxl_io_unexpected_vga_mode(d->id,\nio_port, io_port_to_string(io_port));",
"if (io_port >= QXL_IO_UPDATE_AREA_ASYNC &&\nio_port < QXL_IO_RANGE_SIZE) {",
"qxl_send_events(d, QXL_INTERRUPT_IO_CMD);",
"return;",
"orig_io_port = io_port;",
"switch (io_port) {",
"case QXL_IO_UPDATE_AREA_ASYNC:\nio_port = QXL_IO_UPDATE_AREA;",
"goto async_common;",
"case QXL_IO_MEMSLOT_ADD_ASYNC:\nio_port = QXL_IO_MEMSLOT_ADD;",
"goto async_common;",
"case QXL_IO_CREATE_PRIMARY_ASYNC:\nio_port = QXL_IO_CREATE_PRIMARY;",
"goto async_common;",
"case QXL_IO_DESTROY_PRIMARY_ASYNC:\nio_port = QXL_IO_DESTROY_PRIMARY;",
"goto async_common;",
"case QXL_IO_DESTROY_SURFACE_ASYNC:\nio_port = QXL_IO_DESTROY_SURFACE_WAIT;",
"goto async_common;",
"case QXL_IO_DESTROY_ALL_SURFACES_ASYNC:\nio_port = QXL_IO_DESTROY_ALL_SURFACES;",
"goto async_common;",
"case QXL_IO_FLUSH_SURFACES_ASYNC:\ncase QXL_IO_MONITORS_CONFIG_ASYNC:\nasync_common:\nasync = QXL_ASYNC;",
"qemu_mutex_lock(&d->async_lock);",
"if (d->current_async != QXL_UNDEFINED_IO) {",
"qxl_set_guest_bug(d, \"%d async started before last (%d) complete\",\nio_port, d->current_async);",
"qemu_mutex_unlock(&d->async_lock);",
"return;",
"d->current_async = orig_io_port;",
"qemu_mutex_unlock(&d->async_lock);",
"default:\ntrace_qxl_io_write(d->id, qxl_mode_to_string(d->mode), VAR_1, VAR_2, VAR_3,\nasync);",
"switch (io_port) {",
"case QXL_IO_UPDATE_AREA:\n{",
"QXLCookie *cookie = NULL;",
"QXLRect update = d->ram->update_area;",
"if (d->ram->update_surface > d->ssd.num_surfaces) {",
"qxl_set_guest_bug(d, \"QXL_IO_UPDATE_AREA: invalid surface id %d\\n\",\nd->ram->update_surface);",
"return;",
"if (update.left >= update.right || update.top >= update.bottom) {",
"qxl_set_guest_bug(d,\n\"QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\\n\",\nupdate.left, update.top, update.right, update.bottom);",
"return;",
"if (async == QXL_ASYNC) {",
"cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,\nQXL_IO_UPDATE_AREA_ASYNC);",
"cookie->u.area = update;",
"qxl_spice_update_area(d, d->ram->update_surface,\ncookie ? &cookie->u.area : &update,\nNULL, 0, 0, async, cookie);",
"case QXL_IO_NOTIFY_CMD:\nqemu_spice_wakeup(&d->ssd);",
"case QXL_IO_NOTIFY_CURSOR:\nqemu_spice_wakeup(&d->ssd);",
"case QXL_IO_UPDATE_IRQ:\nqxl_update_irq(d);",
"case QXL_IO_NOTIFY_OOM:\nif (!SPICE_RING_IS_EMPTY(&d->ram->release_ring)) {",
"d->oom_running = 1;",
"qxl_spice_oom(d);",
"d->oom_running = 0;",
"case QXL_IO_SET_MODE:\nqxl_set_mode(d, VAR_2, 0);",
"case QXL_IO_LOG:\nif (d->guestdebug) {",
"fprintf(stderr, \"qxl/guest-%d: %\" PRId64 \": %s\", d->id,\nqemu_get_clock_ns(vm_clock), d->ram->log_buf);",
"case QXL_IO_RESET:\nqxl_hard_reset(d, 0);",
"case QXL_IO_MEMSLOT_ADD:\nif (VAR_2 >= NUM_MEMSLOTS) {",
"qxl_set_guest_bug(d, \"QXL_IO_MEMSLOT_ADD: VAR_2 out of range\");",
"if (d->guest_slots[VAR_2].active) {",
"qxl_set_guest_bug(d,\n\"QXL_IO_MEMSLOT_ADD: memory slot already active\");",
"d->guest_slots[VAR_2].slot = d->ram->mem_slot;",
"qxl_add_memslot(d, VAR_2, 0, async);",
"case QXL_IO_MEMSLOT_DEL:\nif (VAR_2 >= NUM_MEMSLOTS) {",
"qxl_set_guest_bug(d, \"QXL_IO_MEMSLOT_DEL: VAR_2 out of range\");",
"qxl_del_memslot(d, VAR_2);",
"case QXL_IO_CREATE_PRIMARY:\nif (VAR_2 != 0) {",
"qxl_set_guest_bug(d, \"QXL_IO_CREATE_PRIMARY (async=%d): VAR_2 != 0\",\nasync);",
"goto cancel_async;",
"d->guest_primary.surface = d->ram->create_surface;",
"qxl_create_guest_primary(d, 0, async);",
"case QXL_IO_DESTROY_PRIMARY:\nif (VAR_2 != 0) {",
"qxl_set_guest_bug(d, \"QXL_IO_DESTROY_PRIMARY (async=%d): VAR_2 != 0\",\nasync);",
"goto cancel_async;",
"if (!qxl_destroy_primary(d, async)) {",
"trace_qxl_io_destroy_primary_ignored(d->id,\nqxl_mode_to_string(d->mode));",
"goto cancel_async;",
"case QXL_IO_DESTROY_SURFACE_WAIT:\nif (VAR_2 >= d->ssd.num_surfaces) {",
"qxl_set_guest_bug(d, \"QXL_IO_DESTROY_SURFACE (async=%d):\"\n\"%\" PRIu64 \" >= NUM_SURFACES\", async, VAR_2);",
"goto cancel_async;",
"qxl_spice_destroy_surface_wait(d, VAR_2, async);",
"case QXL_IO_FLUSH_RELEASE: {",
"QXLReleaseRing *ring = &d->ram->release_ring;",
"if (ring->prod - ring->cons + 1 == ring->num_items) {",
"fprintf(stderr,\n\"ERROR: no flush, full release ring [p%d,%dc]\\n\",\nring->prod, ring->cons);",
"qxl_push_free_res(d, 1 );",
"case QXL_IO_FLUSH_SURFACES_ASYNC:\nqxl_spice_flush_surfaces_async(d);",
"case QXL_IO_DESTROY_ALL_SURFACES:\nd->mode = QXL_MODE_UNDEFINED;",
"qxl_spice_destroy_surfaces(d, async);",
"case QXL_IO_MONITORS_CONFIG_ASYNC:\nqxl_spice_monitors_config_async(d, 0);",
"default:\nqxl_set_guest_bug(d, \"%s: unexpected ioport=0x%x\\n\", __func__, io_port);",
"return;",
"cancel_async:\nif (async) {",
"qxl_send_events(d, QXL_INTERRUPT_IO_CMD);",
"qemu_mutex_lock(&d->async_lock);",
"d->current_async = QXL_UNDEFINED_IO;",
"qemu_mutex_unlock(&d->async_lock);"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
24,
26
],
[
28,
30
],
[
32
],
[
37
],
[
39,
41,
43,
45,
47,
49,
51,
53,
55,
58,
60
],
[
64,
66
],
[
70,
72
],
[
74
],
[
77
],
[
84
],
[
86
],
[
88,
90
],
[
92
],
[
94,
96
],
[
98
],
[
100,
102
],
[
104
],
[
106,
108
],
[
110
],
[
112,
114
],
[
116
],
[
118,
120
],
[
122
],
[
124,
126,
128,
130
],
[
132
],
[
134
],
[
136,
138
],
[
140
],
[
142
],
[
145
],
[
147
],
[
150,
154,
156
],
[
160
],
[
162,
164
],
[
166
],
[
168
],
[
172
],
[
174,
176
],
[
178
],
[
181
],
[
183,
185,
187
],
[
189
],
[
201
],
[
203,
205
],
[
207
],
[
210,
212,
214
],
[
218,
220
],
[
223,
225
],
[
228,
230
],
[
233,
235
],
[
239
],
[
241
],
[
243
],
[
246,
248
],
[
251,
253
],
[
255,
257
],
[
261,
263
],
[
266,
268
],
[
270
],
[
274
],
[
276,
278
],
[
282
],
[
284
],
[
287,
289
],
[
291
],
[
295
],
[
298,
300
],
[
302,
304
],
[
306
],
[
309
],
[
311
],
[
314,
316
],
[
318,
320
],
[
322
],
[
325
],
[
327,
329
],
[
331
],
[
335,
337
],
[
339,
341
],
[
343
],
[
346
],
[
349
],
[
351
],
[
353
],
[
355,
357,
359
],
[
362
],
[
366,
368
],
[
371,
373
],
[
375
],
[
378,
380
],
[
383,
385
],
[
388
],
[
390,
392
],
[
394
],
[
396
],
[
398
],
[
400
]
] |
1,887 | static int decode_frame_byterun1(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
IffContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
unsigned buf_size = avpkt->size;
const uint8_t *buf_end = buf+buf_size;
unsigned y, plane, x;
if (avctx->reget_buffer(avctx, &s->frame) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));
for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {
for(x = 0; x < s->planesize && buf < buf_end; ) {
int8_t value = *buf++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(s->planebuf + x, buf, FFMIN3(length, s->planesize - x, buf_end - buf));
buf += length;
} else if (value > -128) {
length = -value + 1;
memset(s->planebuf + x, *buf++, FFMIN(length, s->planesize - x));
} else { //noop
continue;
}
x += length;
}
if (avctx->pix_fmt == PIX_FMT_PAL8) {
decodeplane8(row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);
} else { //PIX_FMT_BGR32
decodeplane32((uint32_t *) row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);
}
}
} else {
for(x = 0; x < avctx->width && buf < buf_end; ) {
int8_t value = *buf++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(row + x, buf, FFMIN3(length, buf_end - buf, avctx->width - x));
buf += length;
} else if (value > -128) {
length = -value + 1;
memset(row + x, *buf++, FFMIN(length, avctx->width - x));
} else { //noop
continue;
}
x += length;
}
}
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
}
| false | FFmpeg | fe51b5ce504d118757407c0855e957e97ca90f78 | static int decode_frame_byterun1(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
IffContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
unsigned buf_size = avpkt->size;
const uint8_t *buf_end = buf+buf_size;
unsigned y, plane, x;
if (avctx->reget_buffer(avctx, &s->frame) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
for(y = 0; y < avctx->height ; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
if (avctx->codec_tag == MKTAG('I','L','B','M')) {
memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));
for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {
for(x = 0; x < s->planesize && buf < buf_end; ) {
int8_t value = *buf++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(s->planebuf + x, buf, FFMIN3(length, s->planesize - x, buf_end - buf));
buf += length;
} else if (value > -128) {
length = -value + 1;
memset(s->planebuf + x, *buf++, FFMIN(length, s->planesize - x));
} else {
continue;
}
x += length;
}
if (avctx->pix_fmt == PIX_FMT_PAL8) {
decodeplane8(row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);
} else {
decodeplane32((uint32_t *) row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);
}
}
} else {
for(x = 0; x < avctx->width && buf < buf_end; ) {
int8_t value = *buf++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(row + x, buf, FFMIN3(length, buf_end - buf, avctx->width - x));
buf += length;
} else if (value > -128) {
length = -value + 1;
memset(row + x, *buf++, FFMIN(length, avctx->width - x));
} else {
continue;
}
x += length;
}
}
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
IffContext *s = VAR_0->priv_data;
const uint8_t *VAR_4 = VAR_3->VAR_1;
unsigned VAR_5 = VAR_3->size;
const uint8_t *VAR_6 = VAR_4+VAR_5;
unsigned VAR_7, VAR_8, VAR_9;
if (VAR_0->reget_buffer(VAR_0, &s->frame) < 0){
av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
for(VAR_7 = 0; VAR_7 < VAR_0->height ; VAR_7++ ) {
uint8_t *row = &s->frame.VAR_1[0][ VAR_7*s->frame.linesize[0] ];
if (VAR_0->codec_tag == MKTAG('I','L','B','M')) {
memset(row, 0, VAR_0->pix_fmt == PIX_FMT_PAL8 ? VAR_0->width : (VAR_0->width * 4));
for (VAR_8 = 0; VAR_8 < VAR_0->bits_per_coded_sample; VAR_8++) {
for(VAR_9 = 0; VAR_9 < s->planesize && VAR_4 < VAR_6; ) {
int8_t value = *VAR_4++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(s->planebuf + VAR_9, VAR_4, FFMIN3(length, s->planesize - VAR_9, VAR_6 - VAR_4));
VAR_4 += length;
} else if (value > -128) {
length = -value + 1;
memset(s->planebuf + VAR_9, *VAR_4++, FFMIN(length, s->planesize - VAR_9));
} else {
continue;
}
VAR_9 += length;
}
if (VAR_0->pix_fmt == PIX_FMT_PAL8) {
decodeplane8(row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);
} else {
decodeplane32((uint32_t *) row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);
}
}
} else {
for(VAR_9 = 0; VAR_9 < VAR_0->width && VAR_4 < VAR_6; ) {
int8_t value = *VAR_4++;
unsigned length;
if (value >= 0) {
length = value + 1;
memcpy(row + VAR_9, VAR_4, FFMIN3(length, VAR_6 - VAR_4, VAR_0->width - VAR_9));
VAR_4 += length;
} else if (value > -128) {
length = -value + 1;
memset(row + VAR_9, *VAR_4++, FFMIN(length, VAR_0->width - VAR_9));
} else {
continue;
}
VAR_9 += length;
}
}
}
*VAR_2 = sizeof(AVFrame);
*(AVFrame*)VAR_1 = s->frame;
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"IffContext *s = VAR_0->priv_data;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"unsigned VAR_5 = VAR_3->size;",
"const uint8_t *VAR_6 = VAR_4+VAR_5;",
"unsigned VAR_7, VAR_8, VAR_9;",
"if (VAR_0->reget_buffer(VAR_0, &s->frame) < 0){",
"av_log(VAR_0, AV_LOG_ERROR, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"for(VAR_7 = 0; VAR_7 < VAR_0->height ; VAR_7++ ) {",
"uint8_t *row = &s->frame.VAR_1[0][ VAR_7*s->frame.linesize[0] ];",
"if (VAR_0->codec_tag == MKTAG('I','L','B','M')) {",
"memset(row, 0, VAR_0->pix_fmt == PIX_FMT_PAL8 ? VAR_0->width : (VAR_0->width * 4));",
"for (VAR_8 = 0; VAR_8 < VAR_0->bits_per_coded_sample; VAR_8++) {",
"for(VAR_9 = 0; VAR_9 < s->planesize && VAR_4 < VAR_6; ) {",
"int8_t value = *VAR_4++;",
"unsigned length;",
"if (value >= 0) {",
"length = value + 1;",
"memcpy(s->planebuf + VAR_9, VAR_4, FFMIN3(length, s->planesize - VAR_9, VAR_6 - VAR_4));",
"VAR_4 += length;",
"} else if (value > -128) {",
"length = -value + 1;",
"memset(s->planebuf + VAR_9, *VAR_4++, FFMIN(length, s->planesize - VAR_9));",
"} else {",
"continue;",
"}",
"VAR_9 += length;",
"}",
"if (VAR_0->pix_fmt == PIX_FMT_PAL8) {",
"decodeplane8(row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);",
"} else {",
"decodeplane32((uint32_t *) row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);",
"}",
"}",
"} else {",
"for(VAR_9 = 0; VAR_9 < VAR_0->width && VAR_4 < VAR_6; ) {",
"int8_t value = *VAR_4++;",
"unsigned length;",
"if (value >= 0) {",
"length = value + 1;",
"memcpy(row + VAR_9, VAR_4, FFMIN3(length, VAR_6 - VAR_4, VAR_0->width - VAR_9));",
"VAR_4 += length;",
"} else if (value > -128) {",
"length = -value + 1;",
"memset(row + VAR_9, *VAR_4++, FFMIN(length, VAR_0->width - VAR_9));",
"} else {",
"continue;",
"}",
"VAR_9 += length;",
"}",
"}",
"}",
"*VAR_2 = sizeof(AVFrame);",
"*(AVFrame*)VAR_1 = s->frame;",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
]
] |
1,888 | static void avc_loopfilter_luma_inter_edge_ver_msa(uint8_t *data,
uint8_t bs0, uint8_t bs1,
uint8_t bs2, uint8_t bs3,
uint8_t tc0, uint8_t tc1,
uint8_t tc2, uint8_t tc3,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
uint8_t *src;
v16u8 beta, tmp_vec, bs = { 0 };
v16u8 tc = { 0 };
v16u8 is_less_than, is_less_than_beta;
v16u8 p1, p0, q0, q1;
v8i16 p0_r, q0_r, p1_r = { 0 };
v8i16 q1_r = { 0 };
v8i16 p0_l, q0_l, p1_l = { 0 };
v8i16 q1_l = { 0 };
v16u8 p3_org, p2_org, p1_org, p0_org, q0_org, q1_org, q2_org, q3_org;
v8i16 p2_org_r, p1_org_r, p0_org_r, q0_org_r, q1_org_r, q2_org_r;
v8i16 p2_org_l, p1_org_l, p0_org_l, q0_org_l, q1_org_l, q2_org_l;
v8i16 tc_r, tc_l;
v16i8 zero = { 0 };
v16u8 is_bs_greater_than0;
tmp_vec = (v16u8) __msa_fill_b(bs0);
bs = (v16u8) __msa_insve_w((v4i32) bs, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs1);
bs = (v16u8) __msa_insve_w((v4i32) bs, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs2);
bs = (v16u8) __msa_insve_w((v4i32) bs, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs3);
bs = (v16u8) __msa_insve_w((v4i32) bs, 3, (v4i32) tmp_vec);
if (!__msa_test_bz_v(bs)) {
tmp_vec = (v16u8) __msa_fill_b(tc0);
tc = (v16u8) __msa_insve_w((v4i32) tc, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc1);
tc = (v16u8) __msa_insve_w((v4i32) tc, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc2);
tc = (v16u8) __msa_insve_w((v4i32) tc, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc3);
tc = (v16u8) __msa_insve_w((v4i32) tc, 3, (v4i32) tmp_vec);
is_bs_greater_than0 = (zero < bs);
{
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
src = data;
src -= 4;
LOAD_8VECS_UB(src, img_width,
row0, row1, row2, row3, row4, row5, row6, row7);
src += (8 * img_width);
LOAD_8VECS_UB(src, img_width,
row8, row9, row10, row11, row12, row13, row14, row15);
TRANSPOSE16x8_B_UB(row0, row1, row2, row3, row4, row5, row6, row7,
row8, row9, row10, row11,
row12, row13, row14, row15,
p3_org, p2_org, p1_org, p0_org,
q0_org, q1_org, q2_org, q3_org);
}
{
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, alpha;
v16u8 is_less_than_alpha;
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_less_than & is_bs_greater_than0;
}
if (!__msa_test_bz_v(is_less_than)) {
v16i8 negate_tc, sign_negate_tc;
v8i16 negate_tc_r, i16_negatetc_l;
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
i16_negatetc_l = (v8i16) __msa_ilvl_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
tc_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
p1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p1_org);
p0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p0_org);
q0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q0_org);
{
v16u8 p2_asub_p0;
v16u8 is_less_than_beta_r, is_less_than_beta_l;
p2_asub_p0 = __msa_asub_u_b(p2_org, p0_org);
is_less_than_beta = (p2_asub_p0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
p2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
p1_org_r, p2_org_r,
negate_tc_r, tc_r, p1_r);
}
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
p2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
p1_org_l, p2_org_l,
i16_negatetc_l, tc_l, p1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
p1 = (v16u8) __msa_pckev_b((v16i8) p1_l, (v16i8) p1_r);
p1_org = __msa_bmnz_v(p1_org, p1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v16u8 u8_q2asub_q0;
v16u8 is_less_than_beta_l, is_less_than_beta_r;
u8_q2asub_q0 = __msa_asub_u_b(q2_org, q0_org);
is_less_than_beta = (u8_q2asub_q0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
q2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
q1_org_r, q2_org_r,
negate_tc_r, tc_r, q1_r);
}
q1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q1_org);
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
q2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
q1_org_l, q2_org_l,
i16_negatetc_l, tc_l, q1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
q1 = (v16u8) __msa_pckev_b((v16i8) q1_l, (v16i8) q1_r);
q1_org = __msa_bmnz_v(q1_org, q1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v8i16 threshold_r, negate_thresh_r;
v8i16 threshold_l, negate_thresh_l;
v16i8 negate_thresh, sign_negate_thresh;
negate_thresh = zero - (v16i8) tc;
sign_negate_thresh = __msa_clti_s_b(negate_thresh, 0);
threshold_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
negate_thresh_r = (v8i16) __msa_ilvr_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_thresh_r, threshold_r, p0_r, q0_r);
threshold_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
negate_thresh_l = (v8i16) __msa_ilvl_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_l, p0_org_l, p1_org_l, q1_org_l,
negate_thresh_l, threshold_l, p0_l, q0_l);
}
p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
}
{
v16i8 tmp0, tmp1;
v8i16 tmp2, tmp5;
v4i32 tmp3, tmp4, tmp6, tmp7;
uint32_t out0, out2;
uint16_t out1, out3;
src = data - 3;
tmp0 = __msa_ilvr_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
tmp2 = (v8i16) __msa_ilvr_b((v16i8) q2_org, (v16i8) q1_org);
tmp3 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp4 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
tmp0 = __msa_ilvl_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvl_b((v16i8) q0_org, (v16i8) p0_org);
tmp5 = (v8i16) __msa_ilvl_b((v16i8) q2_org, (v16i8) q1_org);
tmp6 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp7 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
out0 = __msa_copy_u_w(tmp3, 0);
out1 = __msa_copy_u_h(tmp2, 0);
out2 = __msa_copy_u_w(tmp3, 1);
out3 = __msa_copy_u_h(tmp2, 1);
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp3, 2);
out1 = __msa_copy_u_h(tmp2, 2);
out2 = __msa_copy_u_w(tmp3, 3);
out3 = __msa_copy_u_h(tmp2, 3);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 0);
out1 = __msa_copy_u_h(tmp2, 4);
out2 = __msa_copy_u_w(tmp4, 1);
out3 = __msa_copy_u_h(tmp2, 5);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 2);
out1 = __msa_copy_u_h(tmp2, 6);
out2 = __msa_copy_u_w(tmp4, 3);
out3 = __msa_copy_u_h(tmp2, 7);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 0);
out1 = __msa_copy_u_h(tmp5, 0);
out2 = __msa_copy_u_w(tmp6, 1);
out3 = __msa_copy_u_h(tmp5, 1);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 2);
out1 = __msa_copy_u_h(tmp5, 2);
out2 = __msa_copy_u_w(tmp6, 3);
out3 = __msa_copy_u_h(tmp5, 3);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 0);
out1 = __msa_copy_u_h(tmp5, 4);
out2 = __msa_copy_u_w(tmp7, 1);
out3 = __msa_copy_u_h(tmp5, 5);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 2);
out1 = __msa_copy_u_h(tmp5, 6);
out2 = __msa_copy_u_w(tmp7, 3);
out3 = __msa_copy_u_h(tmp5, 7);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
}
}
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | static void avc_loopfilter_luma_inter_edge_ver_msa(uint8_t *data,
uint8_t bs0, uint8_t bs1,
uint8_t bs2, uint8_t bs3,
uint8_t tc0, uint8_t tc1,
uint8_t tc2, uint8_t tc3,
uint8_t alpha_in,
uint8_t beta_in,
uint32_t img_width)
{
uint8_t *src;
v16u8 beta, tmp_vec, bs = { 0 };
v16u8 tc = { 0 };
v16u8 is_less_than, is_less_than_beta;
v16u8 p1, p0, q0, q1;
v8i16 p0_r, q0_r, p1_r = { 0 };
v8i16 q1_r = { 0 };
v8i16 p0_l, q0_l, p1_l = { 0 };
v8i16 q1_l = { 0 };
v16u8 p3_org, p2_org, p1_org, p0_org, q0_org, q1_org, q2_org, q3_org;
v8i16 p2_org_r, p1_org_r, p0_org_r, q0_org_r, q1_org_r, q2_org_r;
v8i16 p2_org_l, p1_org_l, p0_org_l, q0_org_l, q1_org_l, q2_org_l;
v8i16 tc_r, tc_l;
v16i8 zero = { 0 };
v16u8 is_bs_greater_than0;
tmp_vec = (v16u8) __msa_fill_b(bs0);
bs = (v16u8) __msa_insve_w((v4i32) bs, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs1);
bs = (v16u8) __msa_insve_w((v4i32) bs, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs2);
bs = (v16u8) __msa_insve_w((v4i32) bs, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(bs3);
bs = (v16u8) __msa_insve_w((v4i32) bs, 3, (v4i32) tmp_vec);
if (!__msa_test_bz_v(bs)) {
tmp_vec = (v16u8) __msa_fill_b(tc0);
tc = (v16u8) __msa_insve_w((v4i32) tc, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc1);
tc = (v16u8) __msa_insve_w((v4i32) tc, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc2);
tc = (v16u8) __msa_insve_w((v4i32) tc, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(tc3);
tc = (v16u8) __msa_insve_w((v4i32) tc, 3, (v4i32) tmp_vec);
is_bs_greater_than0 = (zero < bs);
{
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
src = data;
src -= 4;
LOAD_8VECS_UB(src, img_width,
row0, row1, row2, row3, row4, row5, row6, row7);
src += (8 * img_width);
LOAD_8VECS_UB(src, img_width,
row8, row9, row10, row11, row12, row13, row14, row15);
TRANSPOSE16x8_B_UB(row0, row1, row2, row3, row4, row5, row6, row7,
row8, row9, row10, row11,
row12, row13, row14, row15,
p3_org, p2_org, p1_org, p0_org,
q0_org, q1_org, q2_org, q3_org);
}
{
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, alpha;
v16u8 is_less_than_alpha;
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(alpha_in);
beta = (v16u8) __msa_fill_b(beta_in);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_less_than & is_bs_greater_than0;
}
if (!__msa_test_bz_v(is_less_than)) {
v16i8 negate_tc, sign_negate_tc;
v8i16 negate_tc_r, i16_negatetc_l;
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
i16_negatetc_l = (v8i16) __msa_ilvl_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
tc_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
p1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p1_org);
p0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p0_org);
q0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q0_org);
{
v16u8 p2_asub_p0;
v16u8 is_less_than_beta_r, is_less_than_beta_l;
p2_asub_p0 = __msa_asub_u_b(p2_org, p0_org);
is_less_than_beta = (p2_asub_p0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
p2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
p1_org_r, p2_org_r,
negate_tc_r, tc_r, p1_r);
}
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
p2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
p1_org_l, p2_org_l,
i16_negatetc_l, tc_l, p1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
p1 = (v16u8) __msa_pckev_b((v16i8) p1_l, (v16i8) p1_r);
p1_org = __msa_bmnz_v(p1_org, p1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v16u8 u8_q2asub_q0;
v16u8 is_less_than_beta_l, is_less_than_beta_r;
u8_q2asub_q0 = __msa_asub_u_b(q2_org, q0_org);
is_less_than_beta = (u8_q2asub_q0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
q2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
q1_org_r, q2_org_r,
negate_tc_r, tc_r, q1_r);
}
q1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q1_org);
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
q2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
q1_org_l, q2_org_l,
i16_negatetc_l, tc_l, q1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
q1 = (v16u8) __msa_pckev_b((v16i8) q1_l, (v16i8) q1_r);
q1_org = __msa_bmnz_v(q1_org, q1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v8i16 threshold_r, negate_thresh_r;
v8i16 threshold_l, negate_thresh_l;
v16i8 negate_thresh, sign_negate_thresh;
negate_thresh = zero - (v16i8) tc;
sign_negate_thresh = __msa_clti_s_b(negate_thresh, 0);
threshold_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
negate_thresh_r = (v8i16) __msa_ilvr_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_thresh_r, threshold_r, p0_r, q0_r);
threshold_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
negate_thresh_l = (v8i16) __msa_ilvl_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_l, p0_org_l, p1_org_l, q1_org_l,
negate_thresh_l, threshold_l, p0_l, q0_l);
}
p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
}
{
v16i8 tmp0, tmp1;
v8i16 tmp2, tmp5;
v4i32 tmp3, tmp4, tmp6, tmp7;
uint32_t out0, out2;
uint16_t out1, out3;
src = data - 3;
tmp0 = __msa_ilvr_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
tmp2 = (v8i16) __msa_ilvr_b((v16i8) q2_org, (v16i8) q1_org);
tmp3 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp4 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
tmp0 = __msa_ilvl_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvl_b((v16i8) q0_org, (v16i8) p0_org);
tmp5 = (v8i16) __msa_ilvl_b((v16i8) q2_org, (v16i8) q1_org);
tmp6 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp7 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
out0 = __msa_copy_u_w(tmp3, 0);
out1 = __msa_copy_u_h(tmp2, 0);
out2 = __msa_copy_u_w(tmp3, 1);
out3 = __msa_copy_u_h(tmp2, 1);
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp3, 2);
out1 = __msa_copy_u_h(tmp2, 2);
out2 = __msa_copy_u_w(tmp3, 3);
out3 = __msa_copy_u_h(tmp2, 3);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 0);
out1 = __msa_copy_u_h(tmp2, 4);
out2 = __msa_copy_u_w(tmp4, 1);
out3 = __msa_copy_u_h(tmp2, 5);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 2);
out1 = __msa_copy_u_h(tmp2, 6);
out2 = __msa_copy_u_w(tmp4, 3);
out3 = __msa_copy_u_h(tmp2, 7);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 0);
out1 = __msa_copy_u_h(tmp5, 0);
out2 = __msa_copy_u_w(tmp6, 1);
out3 = __msa_copy_u_h(tmp5, 1);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 2);
out1 = __msa_copy_u_h(tmp5, 2);
out2 = __msa_copy_u_w(tmp6, 3);
out3 = __msa_copy_u_h(tmp5, 3);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 0);
out1 = __msa_copy_u_h(tmp5, 4);
out2 = __msa_copy_u_w(tmp7, 1);
out3 = __msa_copy_u_h(tmp5, 5);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 2);
out1 = __msa_copy_u_h(tmp5, 6);
out2 = __msa_copy_u_w(tmp7, 3);
out3 = __msa_copy_u_h(tmp5, 7);
src += img_width;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += img_width;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0,
uint8_t VAR_1, uint8_t VAR_2,
uint8_t VAR_3, uint8_t VAR_4,
uint8_t VAR_5, uint8_t VAR_6,
uint8_t VAR_7, uint8_t VAR_8,
uint8_t VAR_9,
uint8_t VAR_10,
uint32_t VAR_11)
{
uint8_t *src;
v16u8 beta, tmp_vec, bs = { 0 };
v16u8 tc = { 0 };
v16u8 is_less_than, is_less_than_beta;
v16u8 p1, p0, q0, q1;
v8i16 p0_r, q0_r, p1_r = { 0 };
v8i16 q1_r = { 0 };
v8i16 p0_l, q0_l, p1_l = { 0 };
v8i16 q1_l = { 0 };
v16u8 p3_org, p2_org, p1_org, p0_org, q0_org, q1_org, q2_org, q3_org;
v8i16 p2_org_r, p1_org_r, p0_org_r, q0_org_r, q1_org_r, q2_org_r;
v8i16 p2_org_l, p1_org_l, p0_org_l, q0_org_l, q1_org_l, q2_org_l;
v8i16 tc_r, tc_l;
v16i8 zero = { 0 };
v16u8 is_bs_greater_than0;
tmp_vec = (v16u8) __msa_fill_b(VAR_1);
bs = (v16u8) __msa_insve_w((v4i32) bs, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_2);
bs = (v16u8) __msa_insve_w((v4i32) bs, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_3);
bs = (v16u8) __msa_insve_w((v4i32) bs, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_4);
bs = (v16u8) __msa_insve_w((v4i32) bs, 3, (v4i32) tmp_vec);
if (!__msa_test_bz_v(bs)) {
tmp_vec = (v16u8) __msa_fill_b(VAR_5);
tc = (v16u8) __msa_insve_w((v4i32) tc, 0, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_6);
tc = (v16u8) __msa_insve_w((v4i32) tc, 1, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_7);
tc = (v16u8) __msa_insve_w((v4i32) tc, 2, (v4i32) tmp_vec);
tmp_vec = (v16u8) __msa_fill_b(VAR_8);
tc = (v16u8) __msa_insve_w((v4i32) tc, 3, (v4i32) tmp_vec);
is_bs_greater_than0 = (zero < bs);
{
v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
src = VAR_0;
src -= 4;
LOAD_8VECS_UB(src, VAR_11,
row0, row1, row2, row3, row4, row5, row6, row7);
src += (8 * VAR_11);
LOAD_8VECS_UB(src, VAR_11,
row8, row9, row10, row11, row12, row13, row14, row15);
TRANSPOSE16x8_B_UB(row0, row1, row2, row3, row4, row5, row6, row7,
row8, row9, row10, row11,
row12, row13, row14, row15,
p3_org, p2_org, p1_org, p0_org,
q0_org, q1_org, q2_org, q3_org);
}
{
v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, alpha;
v16u8 is_less_than_alpha;
p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);
p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);
q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);
alpha = (v16u8) __msa_fill_b(VAR_9);
beta = (v16u8) __msa_fill_b(VAR_10);
is_less_than_alpha = (p0_asub_q0 < alpha);
is_less_than_beta = (p1_asub_p0 < beta);
is_less_than = is_less_than_beta & is_less_than_alpha;
is_less_than_beta = (q1_asub_q0 < beta);
is_less_than = is_less_than_beta & is_less_than;
is_less_than = is_less_than & is_bs_greater_than0;
}
if (!__msa_test_bz_v(is_less_than)) {
v16i8 negate_tc, sign_negate_tc;
v8i16 negate_tc_r, i16_negatetc_l;
negate_tc = zero - (v16i8) tc;
sign_negate_tc = __msa_clti_s_b(negate_tc, 0);
negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);
i16_negatetc_l = (v8i16) __msa_ilvl_b(sign_negate_tc, negate_tc);
tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
tc_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);
p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);
q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);
p1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p1_org);
p0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p0_org);
q0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q0_org);
{
v16u8 p2_asub_p0;
v16u8 is_less_than_beta_r, is_less_than_beta_l;
p2_asub_p0 = __msa_asub_u_b(p2_org, p0_org);
is_less_than_beta = (p2_asub_p0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
p2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
p1_org_r, p2_org_r,
negate_tc_r, tc_r, p1_r);
}
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
p2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
p1_org_l, p2_org_l,
i16_negatetc_l, tc_l, p1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
p1 = (v16u8) __msa_pckev_b((v16i8) p1_l, (v16i8) p1_r);
p1_org = __msa_bmnz_v(p1_org, p1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v16u8 u8_q2asub_q0;
v16u8 is_less_than_beta_l, is_less_than_beta_r;
u8_q2asub_q0 = __msa_asub_u_b(q2_org, q0_org);
is_less_than_beta = (u8_q2asub_q0 < beta);
is_less_than_beta = is_less_than_beta & is_less_than;
q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);
is_less_than_beta_r =
(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);
if (!__msa_test_bz_v(is_less_than_beta_r)) {
q2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,
q1_org_r, q2_org_r,
negate_tc_r, tc_r, q1_r);
}
q1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q1_org);
is_less_than_beta_l =
(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);
if (!__msa_test_bz_v(is_less_than_beta_l)) {
q2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q2_org);
AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,
q1_org_l, q2_org_l,
i16_negatetc_l, tc_l, q1_l);
}
}
if (!__msa_test_bz_v(is_less_than_beta)) {
q1 = (v16u8) __msa_pckev_b((v16i8) q1_l, (v16i8) q1_r);
q1_org = __msa_bmnz_v(q1_org, q1, is_less_than_beta);
is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);
tc = tc + is_less_than_beta;
}
{
v8i16 threshold_r, negate_thresh_r;
v8i16 threshold_l, negate_thresh_l;
v16i8 negate_thresh, sign_negate_thresh;
negate_thresh = zero - (v16i8) tc;
sign_negate_thresh = __msa_clti_s_b(negate_thresh, 0);
threshold_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);
negate_thresh_r = (v8i16) __msa_ilvr_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,
negate_thresh_r, threshold_r, p0_r, q0_r);
threshold_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);
negate_thresh_l = (v8i16) __msa_ilvl_b(sign_negate_thresh,
negate_thresh);
AVC_LOOP_FILTER_P0Q0(q0_org_l, p0_org_l, p1_org_l, q1_org_l,
negate_thresh_l, threshold_l, p0_l, q0_l);
}
p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);
q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);
p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);
q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);
}
{
v16i8 tmp0, tmp1;
v8i16 tmp2, tmp5;
v4i32 tmp3, tmp4, tmp6, tmp7;
uint32_t out0, out2;
uint16_t out1, out3;
src = VAR_0 - 3;
tmp0 = __msa_ilvr_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);
tmp2 = (v8i16) __msa_ilvr_b((v16i8) q2_org, (v16i8) q1_org);
tmp3 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp4 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
tmp0 = __msa_ilvl_b((v16i8) p1_org, (v16i8) p2_org);
tmp1 = __msa_ilvl_b((v16i8) q0_org, (v16i8) p0_org);
tmp5 = (v8i16) __msa_ilvl_b((v16i8) q2_org, (v16i8) q1_org);
tmp6 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);
tmp7 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);
out0 = __msa_copy_u_w(tmp3, 0);
out1 = __msa_copy_u_h(tmp2, 0);
out2 = __msa_copy_u_w(tmp3, 1);
out3 = __msa_copy_u_h(tmp2, 1);
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp3, 2);
out1 = __msa_copy_u_h(tmp2, 2);
out2 = __msa_copy_u_w(tmp3, 3);
out3 = __msa_copy_u_h(tmp2, 3);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 0);
out1 = __msa_copy_u_h(tmp2, 4);
out2 = __msa_copy_u_w(tmp4, 1);
out3 = __msa_copy_u_h(tmp2, 5);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp4, 2);
out1 = __msa_copy_u_h(tmp2, 6);
out2 = __msa_copy_u_w(tmp4, 3);
out3 = __msa_copy_u_h(tmp2, 7);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 0);
out1 = __msa_copy_u_h(tmp5, 0);
out2 = __msa_copy_u_w(tmp6, 1);
out3 = __msa_copy_u_h(tmp5, 1);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp6, 2);
out1 = __msa_copy_u_h(tmp5, 2);
out2 = __msa_copy_u_w(tmp6, 3);
out3 = __msa_copy_u_h(tmp5, 3);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 0);
out1 = __msa_copy_u_h(tmp5, 4);
out2 = __msa_copy_u_w(tmp7, 1);
out3 = __msa_copy_u_h(tmp5, 5);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
out0 = __msa_copy_u_w(tmp7, 2);
out1 = __msa_copy_u_h(tmp5, 6);
out2 = __msa_copy_u_w(tmp7, 3);
out3 = __msa_copy_u_h(tmp5, 7);
src += VAR_11;
STORE_WORD(src, out0);
STORE_HWORD((src + 4), out1);
src += VAR_11;
STORE_WORD(src, out2);
STORE_HWORD((src + 4), out3);
}
}
}
| [
"static void FUNC_0(uint8_t *VAR_0,\nuint8_t VAR_1, uint8_t VAR_2,\nuint8_t VAR_3, uint8_t VAR_4,\nuint8_t VAR_5, uint8_t VAR_6,\nuint8_t VAR_7, uint8_t VAR_8,\nuint8_t VAR_9,\nuint8_t VAR_10,\nuint32_t VAR_11)\n{",
"uint8_t *src;",
"v16u8 beta, tmp_vec, bs = { 0 };",
"v16u8 tc = { 0 };",
"v16u8 is_less_than, is_less_than_beta;",
"v16u8 p1, p0, q0, q1;",
"v8i16 p0_r, q0_r, p1_r = { 0 };",
"v8i16 q1_r = { 0 };",
"v8i16 p0_l, q0_l, p1_l = { 0 };",
"v8i16 q1_l = { 0 };",
"v16u8 p3_org, p2_org, p1_org, p0_org, q0_org, q1_org, q2_org, q3_org;",
"v8i16 p2_org_r, p1_org_r, p0_org_r, q0_org_r, q1_org_r, q2_org_r;",
"v8i16 p2_org_l, p1_org_l, p0_org_l, q0_org_l, q1_org_l, q2_org_l;",
"v8i16 tc_r, tc_l;",
"v16i8 zero = { 0 };",
"v16u8 is_bs_greater_than0;",
"tmp_vec = (v16u8) __msa_fill_b(VAR_1);",
"bs = (v16u8) __msa_insve_w((v4i32) bs, 0, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_2);",
"bs = (v16u8) __msa_insve_w((v4i32) bs, 1, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_3);",
"bs = (v16u8) __msa_insve_w((v4i32) bs, 2, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_4);",
"bs = (v16u8) __msa_insve_w((v4i32) bs, 3, (v4i32) tmp_vec);",
"if (!__msa_test_bz_v(bs)) {",
"tmp_vec = (v16u8) __msa_fill_b(VAR_5);",
"tc = (v16u8) __msa_insve_w((v4i32) tc, 0, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_6);",
"tc = (v16u8) __msa_insve_w((v4i32) tc, 1, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_7);",
"tc = (v16u8) __msa_insve_w((v4i32) tc, 2, (v4i32) tmp_vec);",
"tmp_vec = (v16u8) __msa_fill_b(VAR_8);",
"tc = (v16u8) __msa_insve_w((v4i32) tc, 3, (v4i32) tmp_vec);",
"is_bs_greater_than0 = (zero < bs);",
"{",
"v16u8 row0, row1, row2, row3, row4, row5, row6, row7;",
"v16u8 row8, row9, row10, row11, row12, row13, row14, row15;",
"src = VAR_0;",
"src -= 4;",
"LOAD_8VECS_UB(src, VAR_11,\nrow0, row1, row2, row3, row4, row5, row6, row7);",
"src += (8 * VAR_11);",
"LOAD_8VECS_UB(src, VAR_11,\nrow8, row9, row10, row11, row12, row13, row14, row15);",
"TRANSPOSE16x8_B_UB(row0, row1, row2, row3, row4, row5, row6, row7,\nrow8, row9, row10, row11,\nrow12, row13, row14, row15,\np3_org, p2_org, p1_org, p0_org,\nq0_org, q1_org, q2_org, q3_org);",
"}",
"{",
"v16u8 p0_asub_q0, p1_asub_p0, q1_asub_q0, alpha;",
"v16u8 is_less_than_alpha;",
"p0_asub_q0 = __msa_asub_u_b(p0_org, q0_org);",
"p1_asub_p0 = __msa_asub_u_b(p1_org, p0_org);",
"q1_asub_q0 = __msa_asub_u_b(q1_org, q0_org);",
"alpha = (v16u8) __msa_fill_b(VAR_9);",
"beta = (v16u8) __msa_fill_b(VAR_10);",
"is_less_than_alpha = (p0_asub_q0 < alpha);",
"is_less_than_beta = (p1_asub_p0 < beta);",
"is_less_than = is_less_than_beta & is_less_than_alpha;",
"is_less_than_beta = (q1_asub_q0 < beta);",
"is_less_than = is_less_than_beta & is_less_than;",
"is_less_than = is_less_than & is_bs_greater_than0;",
"}",
"if (!__msa_test_bz_v(is_less_than)) {",
"v16i8 negate_tc, sign_negate_tc;",
"v8i16 negate_tc_r, i16_negatetc_l;",
"negate_tc = zero - (v16i8) tc;",
"sign_negate_tc = __msa_clti_s_b(negate_tc, 0);",
"negate_tc_r = (v8i16) __msa_ilvr_b(sign_negate_tc, negate_tc);",
"i16_negatetc_l = (v8i16) __msa_ilvl_b(sign_negate_tc, negate_tc);",
"tc_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);",
"tc_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);",
"p1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p1_org);",
"p0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p0_org);",
"q0_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q0_org);",
"p1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p1_org);",
"p0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p0_org);",
"q0_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q0_org);",
"{",
"v16u8 p2_asub_p0;",
"v16u8 is_less_than_beta_r, is_less_than_beta_l;",
"p2_asub_p0 = __msa_asub_u_b(p2_org, p0_org);",
"is_less_than_beta = (p2_asub_p0 < beta);",
"is_less_than_beta = is_less_than_beta & is_less_than;",
"is_less_than_beta_r =\n(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);",
"if (!__msa_test_bz_v(is_less_than_beta_r)) {",
"p2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) p2_org);",
"AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,\np1_org_r, p2_org_r,\nnegate_tc_r, tc_r, p1_r);",
"}",
"is_less_than_beta_l =\n(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);",
"if (!__msa_test_bz_v(is_less_than_beta_l)) {",
"p2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) p2_org);",
"AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,\np1_org_l, p2_org_l,\ni16_negatetc_l, tc_l, p1_l);",
"}",
"}",
"if (!__msa_test_bz_v(is_less_than_beta)) {",
"p1 = (v16u8) __msa_pckev_b((v16i8) p1_l, (v16i8) p1_r);",
"p1_org = __msa_bmnz_v(p1_org, p1, is_less_than_beta);",
"is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);",
"tc = tc + is_less_than_beta;",
"}",
"{",
"v16u8 u8_q2asub_q0;",
"v16u8 is_less_than_beta_l, is_less_than_beta_r;",
"u8_q2asub_q0 = __msa_asub_u_b(q2_org, q0_org);",
"is_less_than_beta = (u8_q2asub_q0 < beta);",
"is_less_than_beta = is_less_than_beta & is_less_than;",
"q1_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q1_org);",
"is_less_than_beta_r =\n(v16u8) __msa_sldi_b((v16i8) is_less_than_beta, zero, 8);",
"if (!__msa_test_bz_v(is_less_than_beta_r)) {",
"q2_org_r = (v8i16) __msa_ilvr_b(zero, (v16i8) q2_org);",
"AVC_LOOP_FILTER_P1_OR_Q1(p0_org_r, q0_org_r,\nq1_org_r, q2_org_r,\nnegate_tc_r, tc_r, q1_r);",
"}",
"q1_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q1_org);",
"is_less_than_beta_l =\n(v16u8) __msa_sldi_b(zero, (v16i8) is_less_than_beta, 8);",
"if (!__msa_test_bz_v(is_less_than_beta_l)) {",
"q2_org_l = (v8i16) __msa_ilvl_b(zero, (v16i8) q2_org);",
"AVC_LOOP_FILTER_P1_OR_Q1(p0_org_l, q0_org_l,\nq1_org_l, q2_org_l,\ni16_negatetc_l, tc_l, q1_l);",
"}",
"}",
"if (!__msa_test_bz_v(is_less_than_beta)) {",
"q1 = (v16u8) __msa_pckev_b((v16i8) q1_l, (v16i8) q1_r);",
"q1_org = __msa_bmnz_v(q1_org, q1, is_less_than_beta);",
"is_less_than_beta = __msa_andi_b(is_less_than_beta, 1);",
"tc = tc + is_less_than_beta;",
"}",
"{",
"v8i16 threshold_r, negate_thresh_r;",
"v8i16 threshold_l, negate_thresh_l;",
"v16i8 negate_thresh, sign_negate_thresh;",
"negate_thresh = zero - (v16i8) tc;",
"sign_negate_thresh = __msa_clti_s_b(negate_thresh, 0);",
"threshold_r = (v8i16) __msa_ilvr_b(zero, (v16i8) tc);",
"negate_thresh_r = (v8i16) __msa_ilvr_b(sign_negate_thresh,\nnegate_thresh);",
"AVC_LOOP_FILTER_P0Q0(q0_org_r, p0_org_r, p1_org_r, q1_org_r,\nnegate_thresh_r, threshold_r, p0_r, q0_r);",
"threshold_l = (v8i16) __msa_ilvl_b(zero, (v16i8) tc);",
"negate_thresh_l = (v8i16) __msa_ilvl_b(sign_negate_thresh,\nnegate_thresh);",
"AVC_LOOP_FILTER_P0Q0(q0_org_l, p0_org_l, p1_org_l, q1_org_l,\nnegate_thresh_l, threshold_l, p0_l, q0_l);",
"}",
"p0 = (v16u8) __msa_pckev_b((v16i8) p0_l, (v16i8) p0_r);",
"q0 = (v16u8) __msa_pckev_b((v16i8) q0_l, (v16i8) q0_r);",
"p0_org = __msa_bmnz_v(p0_org, p0, is_less_than);",
"q0_org = __msa_bmnz_v(q0_org, q0, is_less_than);",
"}",
"{",
"v16i8 tmp0, tmp1;",
"v8i16 tmp2, tmp5;",
"v4i32 tmp3, tmp4, tmp6, tmp7;",
"uint32_t out0, out2;",
"uint16_t out1, out3;",
"src = VAR_0 - 3;",
"tmp0 = __msa_ilvr_b((v16i8) p1_org, (v16i8) p2_org);",
"tmp1 = __msa_ilvr_b((v16i8) q0_org, (v16i8) p0_org);",
"tmp2 = (v8i16) __msa_ilvr_b((v16i8) q2_org, (v16i8) q1_org);",
"tmp3 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);",
"tmp4 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);",
"tmp0 = __msa_ilvl_b((v16i8) p1_org, (v16i8) p2_org);",
"tmp1 = __msa_ilvl_b((v16i8) q0_org, (v16i8) p0_org);",
"tmp5 = (v8i16) __msa_ilvl_b((v16i8) q2_org, (v16i8) q1_org);",
"tmp6 = (v4i32) __msa_ilvr_h((v8i16) tmp1, (v8i16) tmp0);",
"tmp7 = (v4i32) __msa_ilvl_h((v8i16) tmp1, (v8i16) tmp0);",
"out0 = __msa_copy_u_w(tmp3, 0);",
"out1 = __msa_copy_u_h(tmp2, 0);",
"out2 = __msa_copy_u_w(tmp3, 1);",
"out3 = __msa_copy_u_h(tmp2, 1);",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp3, 2);",
"out1 = __msa_copy_u_h(tmp2, 2);",
"out2 = __msa_copy_u_w(tmp3, 3);",
"out3 = __msa_copy_u_h(tmp2, 3);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp4, 0);",
"out1 = __msa_copy_u_h(tmp2, 4);",
"out2 = __msa_copy_u_w(tmp4, 1);",
"out3 = __msa_copy_u_h(tmp2, 5);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp4, 2);",
"out1 = __msa_copy_u_h(tmp2, 6);",
"out2 = __msa_copy_u_w(tmp4, 3);",
"out3 = __msa_copy_u_h(tmp2, 7);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp6, 0);",
"out1 = __msa_copy_u_h(tmp5, 0);",
"out2 = __msa_copy_u_w(tmp6, 1);",
"out3 = __msa_copy_u_h(tmp5, 1);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp6, 2);",
"out1 = __msa_copy_u_h(tmp5, 2);",
"out2 = __msa_copy_u_w(tmp6, 3);",
"out3 = __msa_copy_u_h(tmp5, 3);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp7, 0);",
"out1 = __msa_copy_u_h(tmp5, 4);",
"out2 = __msa_copy_u_w(tmp7, 1);",
"out3 = __msa_copy_u_h(tmp5, 5);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"out0 = __msa_copy_u_w(tmp7, 2);",
"out1 = __msa_copy_u_h(tmp5, 6);",
"out2 = __msa_copy_u_w(tmp7, 3);",
"out3 = __msa_copy_u_h(tmp5, 7);",
"src += VAR_11;",
"STORE_WORD(src, out0);",
"STORE_HWORD((src + 4), out1);",
"src += VAR_11;",
"STORE_WORD(src, out2);",
"STORE_HWORD((src + 4), out3);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
107,
109
],
[
111
],
[
113,
115
],
[
119,
121,
123,
125,
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
185
],
[
187
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
229,
231
],
[
233
],
[
235
],
[
239,
241,
243
],
[
245
],
[
249,
251
],
[
253
],
[
255
],
[
259,
261,
263
],
[
265
],
[
267
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
303
],
[
307,
309
],
[
311
],
[
313
],
[
317,
319,
321
],
[
323
],
[
327
],
[
331,
333
],
[
335
],
[
337
],
[
341,
343,
345
],
[
347
],
[
349
],
[
353
],
[
355
],
[
357
],
[
361
],
[
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
],
[
385
],
[
387,
389
],
[
393,
395
],
[
399
],
[
401,
403
],
[
407,
409
],
[
411
],
[
415
],
[
417
],
[
421
],
[
423
],
[
425
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
443
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
471
],
[
473
],
[
475
],
[
477
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
493
],
[
495
],
[
497
],
[
499
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
519
],
[
521
],
[
523
],
[
527
],
[
529
],
[
531
],
[
533
],
[
535
],
[
537
],
[
541
],
[
543
],
[
545
],
[
547
],
[
551
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
565
],
[
567
],
[
569
],
[
571
],
[
575
],
[
577
],
[
579
],
[
581
],
[
583
],
[
585
],
[
589
],
[
591
],
[
593
],
[
595
],
[
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
613
],
[
615
],
[
617
],
[
619
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
637
],
[
639
],
[
641
],
[
643
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
]
] |
1,889 | static void dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
return;
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->next = ctx->region_list;
ctx->region_list = region;
}
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
}
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
}
region->clut = *buf++;
if (region->depth == 8)
region->bgcolor = *buf++;
else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
}
av_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
av_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
}
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
}
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
}
}
| false | FFmpeg | 607ad990d31e6be52980970e5ce8cd25ab3de812 | static void dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
return;
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->next = ctx->region_list;
ctx->region_list = region;
}
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
}
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
}
region->clut = *buf++;
if (region->depth == 8)
region->bgcolor = *buf++;
else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
}
av_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
av_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
}
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
}
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
DVBSubContext *ctx = VAR_0->priv_data;
const uint8_t *VAR_3 = VAR_1 + VAR_2;
int VAR_4, VAR_5;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int VAR_6;
if (VAR_2 < 10)
return;
VAR_4 = *VAR_1++;
region = get_region(ctx, VAR_4);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
region->id = VAR_4;
region->next = ctx->region_list;
ctx->region_list = region;
}
VAR_6 = ((*VAR_1++) >> 3) & 1;
region->width = AV_RB16(VAR_1);
VAR_1 += 2;
region->height = AV_RB16(VAR_1);
VAR_1 += 2;
if (region->width * region->height != region->VAR_2) {
av_free(region->pbuf);
region->VAR_2 = region->width * region->height;
region->pbuf = av_malloc(region->VAR_2);
VAR_6 = 1;
}
region->depth = 1 << (((*VAR_1++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(VAR_0, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
}
region->clut = *VAR_1++;
if (region->depth == 8)
region->bgcolor = *VAR_1++;
else {
VAR_1 += 1;
if (region->depth == 4)
region->bgcolor = (((*VAR_1++) >> 4) & 15);
else
region->bgcolor = (((*VAR_1++) >> 2) & 3);
}
av_dlog(VAR_0, "Region %d, (%dx%d)\n", VAR_4, region->width, region->height);
if (VAR_6) {
memset(region->pbuf, region->bgcolor, region->VAR_2);
av_dlog(VAR_0, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
while (VAR_1 + 5 < VAR_3) {
VAR_5 = AV_RB16(VAR_1);
VAR_1 += 2;
object = get_object(ctx, VAR_5);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = VAR_5;
object->next = ctx->object_list;
ctx->object_list = object;
}
object->type = (*VAR_1) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->VAR_5 = VAR_5;
display->VAR_4 = VAR_4;
display->x_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
display->y_pos = AV_RB16(VAR_1) & 0xfff;
VAR_1 += 2;
if ((object->type == 1 || object->type == 2) && VAR_1+1 < VAR_3) {
display->fgcolor = *VAR_1++;
display->bgcolor = *VAR_1++;
}
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
}
}
| [
"static void FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"DVBSubContext *ctx = VAR_0->priv_data;",
"const uint8_t *VAR_3 = VAR_1 + VAR_2;",
"int VAR_4, VAR_5;",
"DVBSubRegion *region;",
"DVBSubObject *object;",
"DVBSubObjectDisplay *display;",
"int VAR_6;",
"if (VAR_2 < 10)\nreturn;",
"VAR_4 = *VAR_1++;",
"region = get_region(ctx, VAR_4);",
"if (!region) {",
"region = av_mallocz(sizeof(DVBSubRegion));",
"region->id = VAR_4;",
"region->next = ctx->region_list;",
"ctx->region_list = region;",
"}",
"VAR_6 = ((*VAR_1++) >> 3) & 1;",
"region->width = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"region->height = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"if (region->width * region->height != region->VAR_2) {",
"av_free(region->pbuf);",
"region->VAR_2 = region->width * region->height;",
"region->pbuf = av_malloc(region->VAR_2);",
"VAR_6 = 1;",
"}",
"region->depth = 1 << (((*VAR_1++) >> 2) & 7);",
"if(region->depth<2 || region->depth>8){",
"av_log(VAR_0, AV_LOG_ERROR, \"region depth %d is invalid\\n\", region->depth);",
"region->depth= 4;",
"}",
"region->clut = *VAR_1++;",
"if (region->depth == 8)\nregion->bgcolor = *VAR_1++;",
"else {",
"VAR_1 += 1;",
"if (region->depth == 4)\nregion->bgcolor = (((*VAR_1++) >> 4) & 15);",
"else\nregion->bgcolor = (((*VAR_1++) >> 2) & 3);",
"}",
"av_dlog(VAR_0, \"Region %d, (%dx%d)\\n\", VAR_4, region->width, region->height);",
"if (VAR_6) {",
"memset(region->pbuf, region->bgcolor, region->VAR_2);",
"av_dlog(VAR_0, \"Fill region (%d)\\n\", region->bgcolor);",
"}",
"delete_region_display_list(ctx, region);",
"while (VAR_1 + 5 < VAR_3) {",
"VAR_5 = AV_RB16(VAR_1);",
"VAR_1 += 2;",
"object = get_object(ctx, VAR_5);",
"if (!object) {",
"object = av_mallocz(sizeof(DVBSubObject));",
"object->id = VAR_5;",
"object->next = ctx->object_list;",
"ctx->object_list = object;",
"}",
"object->type = (*VAR_1) >> 6;",
"display = av_mallocz(sizeof(DVBSubObjectDisplay));",
"display->VAR_5 = VAR_5;",
"display->VAR_4 = VAR_4;",
"display->x_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"display->y_pos = AV_RB16(VAR_1) & 0xfff;",
"VAR_1 += 2;",
"if ((object->type == 1 || object->type == 2) && VAR_1+1 < VAR_3) {",
"display->fgcolor = *VAR_1++;",
"display->bgcolor = *VAR_1++;",
"}",
"display->region_list_next = region->display_list;",
"region->display_list = display;",
"display->object_list_next = object->display_list;",
"object->display_list = display;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
35
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105,
107
],
[
109
],
[
111
],
[
115,
117
],
[
119,
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
145
],
[
147
],
[
149
],
[
153
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
177
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
219
]
] |
1,890 | static void sdhci_initfn(Object *obj)
{
SDHCIState *s = SDHCI(obj);
DriveInfo *di;
di = drive_get_next(IF_SD);
s->card = sd_init(di ? blk_bs(blk_by_legacy_dinfo(di)) : NULL, false);
if (s->card == NULL) {
exit(1);
}
s->eject_cb = qemu_allocate_irq(sdhci_insert_eject_cb, s, 0);
s->ro_cb = qemu_allocate_irq(sdhci_card_readonly_cb, s, 0);
sd_set_cb(s->card, s->ro_cb, s->eject_cb);
s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s);
s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_do_data_transfer, s);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void sdhci_initfn(Object *obj)
{
SDHCIState *s = SDHCI(obj);
DriveInfo *di;
di = drive_get_next(IF_SD);
s->card = sd_init(di ? blk_bs(blk_by_legacy_dinfo(di)) : NULL, false);
if (s->card == NULL) {
exit(1);
}
s->eject_cb = qemu_allocate_irq(sdhci_insert_eject_cb, s, 0);
s->ro_cb = qemu_allocate_irq(sdhci_card_readonly_cb, s, 0);
sd_set_cb(s->card, s->ro_cb, s->eject_cb);
s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s);
s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_do_data_transfer, s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
SDHCIState *s = SDHCI(VAR_0);
DriveInfo *di;
di = drive_get_next(IF_SD);
s->card = sd_init(di ? blk_bs(blk_by_legacy_dinfo(di)) : NULL, false);
if (s->card == NULL) {
exit(1);
}
s->eject_cb = qemu_allocate_irq(sdhci_insert_eject_cb, s, 0);
s->ro_cb = qemu_allocate_irq(sdhci_card_readonly_cb, s, 0);
sd_set_cb(s->card, s->ro_cb, s->eject_cb);
s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s);
s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_do_data_transfer, s);
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"SDHCIState *s = SDHCI(VAR_0);",
"DriveInfo *di;",
"di = drive_get_next(IF_SD);",
"s->card = sd_init(di ? blk_bs(blk_by_legacy_dinfo(di)) : NULL, false);",
"if (s->card == NULL) {",
"exit(1);",
"}",
"s->eject_cb = qemu_allocate_irq(sdhci_insert_eject_cb, s, 0);",
"s->ro_cb = qemu_allocate_irq(sdhci_card_readonly_cb, s, 0);",
"sd_set_cb(s->card, s->ro_cb, s->eject_cb);",
"s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s);",
"s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_do_data_transfer, s);",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
]
] |
1,891 | static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
{
void **ptr = qdev_get_prop_ptr(dev, prop);
return snprintf(dest, len, "<%p>", *ptr);
}
| false | qemu | 036f7166c73a9e0cc1b2f10c03763e61894a1033 | static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
{
void **ptr = qdev_get_prop_ptr(dev, prop);
return snprintf(dest, len, "<%p>", *ptr);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DeviceState *VAR_0, Property *VAR_1, char *VAR_2, size_t VAR_3)
{
void **VAR_4 = qdev_get_prop_ptr(VAR_0, VAR_1);
return snprintf(VAR_2, VAR_3, "<%p>", *VAR_4);
}
| [
"static int FUNC_0(DeviceState *VAR_0, Property *VAR_1, char *VAR_2, size_t VAR_3)\n{",
"void **VAR_4 = qdev_get_prop_ptr(VAR_0, VAR_1);",
"return snprintf(VAR_2, VAR_3, \"<%p>\", *VAR_4);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,892 | static ssize_t drop_sync(int fd, size_t size)
{
ssize_t ret, dropped = size;
uint8_t *buffer = g_malloc(MIN(65536, size));
while (size > 0) {
ret = read_sync(fd, buffer, MIN(65536, size));
if (ret < 0) {
g_free(buffer);
return ret;
}
assert(ret <= size);
size -= ret;
}
g_free(buffer);
return dropped;
}
| false | qemu | 1a6245a5b0b4e8d822c739b403fc67c8a7bc8d12 | static ssize_t drop_sync(int fd, size_t size)
{
ssize_t ret, dropped = size;
uint8_t *buffer = g_malloc(MIN(65536, size));
while (size > 0) {
ret = read_sync(fd, buffer, MIN(65536, size));
if (ret < 0) {
g_free(buffer);
return ret;
}
assert(ret <= size);
size -= ret;
}
g_free(buffer);
return dropped;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(int fd, size_t size)
{
ssize_t ret, dropped = size;
uint8_t *buffer = g_malloc(MIN(65536, size));
while (size > 0) {
ret = read_sync(fd, buffer, MIN(65536, size));
if (ret < 0) {
g_free(buffer);
return ret;
}
assert(ret <= size);
size -= ret;
}
g_free(buffer);
return dropped;
}
| [
"static ssize_t FUNC_0(int fd, size_t size)\n{",
"ssize_t ret, dropped = size;",
"uint8_t *buffer = g_malloc(MIN(65536, size));",
"while (size > 0) {",
"ret = read_sync(fd, buffer, MIN(65536, size));",
"if (ret < 0) {",
"g_free(buffer);",
"return ret;",
"}",
"assert(ret <= size);",
"size -= ret;",
"}",
"g_free(buffer);",
"return dropped;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
]
] |
1,893 | static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
if (bs->sg) {
return 0;
}
if (!iscsilun->force_next_flush) {
return 0;
}
iscsilun->force_next_flush = false;
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,
0, iscsi_co_generic_cb, &iTask) == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
return 0;
}
| false | qemu | b192af8acc597a6e8068873434e56e0c7de1b7d3 | static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
if (bs->sg) {
return 0;
}
if (!iscsilun->force_next_flush) {
return 0;
}
iscsilun->force_next_flush = false;
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,
0, iscsi_co_generic_cb, &iTask) == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 iscsi_co_flush(BlockDriverState *bs)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
if (bs->sg) {
return 0;
}
if (!iscsilun->force_next_flush) {
return 0;
}
iscsilun->force_next_flush = false;
iscsi_co_init_iscsitask(iscsilun, &iTask);
retry:
if (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,
0, iscsi_co_generic_cb, &iTask) == NULL) {
return -ENOMEM;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
iTask.complete = 0;
goto retry;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
return 0;
}
| [
"static int VAR_0 iscsi_co_flush(BlockDriverState *bs)\n{",
"IscsiLun *iscsilun = bs->opaque;",
"struct IscsiTask iTask;",
"if (bs->sg) {",
"return 0;",
"}",
"if (!iscsilun->force_next_flush) {",
"return 0;",
"}",
"iscsilun->force_next_flush = false;",
"iscsi_co_init_iscsitask(iscsilun, &iTask);",
"retry:\nif (iscsi_synchronizecache10_task(iscsilun->iscsi, iscsilun->lun, 0, 0, 0,\n0, iscsi_co_generic_cb, &iTask) == NULL) {",
"return -ENOMEM;",
"}",
"while (!iTask.complete) {",
"iscsi_set_events(iscsilun);",
"qemu_coroutine_yield();",
"}",
"if (iTask.task != NULL) {",
"scsi_free_scsi_task(iTask.task);",
"iTask.task = NULL;",
"}",
"if (iTask.do_retry) {",
"iTask.complete = 0;",
"goto retry;",
"}",
"if (iTask.status != SCSI_STATUS_GOOD) {",
"return -EIO;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
]
] |
1,895 | static void mmio_ide_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
MMIOState *s = opaque;
addr >>= s->shift;
if (addr & 7)
ide_ioport_write(&s->bus, addr, val);
else
ide_data_writew(&s->bus, 0, val);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void mmio_ide_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
MMIOState *s = opaque;
addr >>= s->shift;
if (addr & 7)
ide_ioport_write(&s->bus, addr, val);
else
ide_data_writew(&s->bus, 0, val);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
MMIOState *s = VAR_0;
VAR_1 >>= s->shift;
if (VAR_1 & 7)
ide_ioport_write(&s->bus, VAR_1, VAR_2);
else
ide_data_writew(&s->bus, 0, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"MMIOState *s = VAR_0;",
"VAR_1 >>= s->shift;",
"if (VAR_1 & 7)\nide_ioport_write(&s->bus, VAR_1, VAR_2);",
"else\nide_data_writew(&s->bus, 0, VAR_2);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
]
] |
1,897 | static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
if (block_type == BLOCK_TYPE_AUDIO) {
/* the chunk contains audio */
*data_size = vmdaudio_loadsound(s, output_samples, buf, 0, buf_size);
} else if (block_type == BLOCK_TYPE_INITIAL) {
/* initial chunk, may contain audio and silence */
uint32_t flags = AV_RB32(buf);
int silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
if(*data_size < (s->block_align*silent_chunks + buf_size) * 2)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
} else if (block_type == BLOCK_TYPE_SILENCE) {
/* silent chunk */
*data_size = vmdaudio_loadsound(s, output_samples, buf, 1, 0);
}
return avpkt->size;
}
| false | FFmpeg | 504dff8e4ec7e282bed5bf1f31d5ede765643d3e | static int vmdaudio_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VmdAudioContext *s = avctx->priv_data;
int block_type;
unsigned char *output_samples = (unsigned char *)data;
if (buf_size < 16) {
av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");
*data_size = 0;
return buf_size;
}
block_type = buf[6];
if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {
av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);
return AVERROR(EINVAL);
}
buf += 16;
buf_size -= 16;
if (block_type == BLOCK_TYPE_AUDIO) {
*data_size = vmdaudio_loadsound(s, output_samples, buf, 0, buf_size);
} else if (block_type == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(buf);
int silent_chunks = av_popcount(flags);
buf += 4;
buf_size -= 4;
if(*data_size < (s->block_align*silent_chunks + buf_size) * 2)
return -1;
*data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);
} else if (block_type == BLOCK_TYPE_SILENCE) {
*data_size = vmdaudio_loadsound(s, output_samples, buf, 1, 0);
}
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
VmdAudioContext *s = VAR_0->priv_data;
int VAR_6;
unsigned char *VAR_7 = (unsigned char *)VAR_1;
if (VAR_5 < 16) {
av_log(VAR_0, AV_LOG_WARNING, "skipping small junk packet\n");
*VAR_2 = 0;
return VAR_5;
}
VAR_6 = VAR_4[6];
if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) {
av_log(VAR_0, AV_LOG_ERROR, "unknown block type: %d\n", VAR_6);
return AVERROR(EINVAL);
}
VAR_4 += 16;
VAR_5 -= 16;
if (VAR_6 == BLOCK_TYPE_AUDIO) {
*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, 0, VAR_5);
} else if (VAR_6 == BLOCK_TYPE_INITIAL) {
uint32_t flags = AV_RB32(VAR_4);
int VAR_8 = av_popcount(flags);
VAR_4 += 4;
VAR_5 -= 4;
if(*VAR_2 < (s->block_align*VAR_8 + VAR_5) * 2)
return -1;
*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, VAR_8, VAR_5);
} else if (VAR_6 == BLOCK_TYPE_SILENCE) {
*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, 1, 0);
}
return VAR_3->size;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"VmdAudioContext *s = VAR_0->priv_data;",
"int VAR_6;",
"unsigned char *VAR_7 = (unsigned char *)VAR_1;",
"if (VAR_5 < 16) {",
"av_log(VAR_0, AV_LOG_WARNING, \"skipping small junk packet\\n\");",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"VAR_6 = VAR_4[6];",
"if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"unknown block type: %d\\n\", VAR_6);",
"return AVERROR(EINVAL);",
"}",
"VAR_4 += 16;",
"VAR_5 -= 16;",
"if (VAR_6 == BLOCK_TYPE_AUDIO) {",
"*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, 0, VAR_5);",
"} else if (VAR_6 == BLOCK_TYPE_INITIAL) {",
"uint32_t flags = AV_RB32(VAR_4);",
"int VAR_8 = av_popcount(flags);",
"VAR_4 += 4;",
"VAR_5 -= 4;",
"if(*VAR_2 < (s->block_align*VAR_8 + VAR_5) * 2)\nreturn -1;",
"*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, VAR_8, VAR_5);",
"} else if (VAR_6 == BLOCK_TYPE_SILENCE) {",
"*VAR_2 = vmdaudio_loadsound(s, VAR_7, VAR_4, 1, 0);",
"}",
"return VAR_3->size;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
1,898 | static int usb_parse(const char *cmdline)
{
int r;
r = usb_device_add(cmdline);
if (r < 0) {
fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline);
}
return r;
}
| false | qemu | f61eddcb2bb5cbbdd1d911b7e937db9affc29028 | static int usb_parse(const char *cmdline)
{
int r;
r = usb_device_add(cmdline);
if (r < 0) {
fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline);
}
return r;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const char *VAR_0)
{
int VAR_1;
VAR_1 = usb_device_add(VAR_0);
if (VAR_1 < 0) {
fprintf(stderr, "qemu: could not add USB device '%s'\n", VAR_0);
}
return VAR_1;
}
| [
"static int FUNC_0(const char *VAR_0)\n{",
"int VAR_1;",
"VAR_1 = usb_device_add(VAR_0);",
"if (VAR_1 < 0) {",
"fprintf(stderr, \"qemu: could not add USB device '%s'\\n\", VAR_0);",
"}",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
1,899 | static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table)
{
int i;
for (i = 0; i < nb_clusters; i++) {
int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i]));
if (type != QCOW2_CLUSTER_UNALLOCATED) {
break;
}
}
return i;
}
| false | qemu | b6d36def6d9e9fd187327182d0abafc9b7085d8f | static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table)
{
int i;
for (i = 0; i < nb_clusters; i++) {
int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i]));
if (type != QCOW2_CLUSTER_UNALLOCATED) {
break;
}
}
return i;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(uint64_t VAR_0, uint64_t *VAR_1)
{
int VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {
int type = qcow2_get_cluster_type(be64_to_cpu(VAR_1[VAR_2]));
if (type != QCOW2_CLUSTER_UNALLOCATED) {
break;
}
}
return VAR_2;
}
| [
"static int FUNC_0(uint64_t VAR_0, uint64_t *VAR_1)\n{",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_0; VAR_2++) {",
"int type = qcow2_get_cluster_type(be64_to_cpu(VAR_1[VAR_2]));",
"if (type != QCOW2_CLUSTER_UNALLOCATED) {",
"break;",
"}",
"}",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
]
] |
1,901 | void bdrv_set_geometry_hint(BlockDriverState *bs,
int cyls, int heads, int secs)
{
bs->cyls = cyls;
bs->heads = heads;
bs->secs = secs;
}
| false | qemu | 2b584959ed300ddff4acba0d7554becad5f274fd | void bdrv_set_geometry_hint(BlockDriverState *bs,
int cyls, int heads, int secs)
{
bs->cyls = cyls;
bs->heads = heads;
bs->secs = secs;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0,
int VAR_1, int VAR_2, int VAR_3)
{
VAR_0->VAR_1 = VAR_1;
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
}
| [
"void FUNC_0(BlockDriverState *VAR_0,\nint VAR_1, int VAR_2, int VAR_3)\n{",
"VAR_0->VAR_1 = VAR_1;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,903 | static BlockDriverState *bdrv_new_open(const char *filename,
const char *fmt,
int flags)
{
BlockDriverState *bs;
BlockDriver *drv;
char password[256];
bs = bdrv_new("");
if (!bs) {
error_report("Not enough memory");
goto fail;
}
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
error_report("Unknown file format '%s'", fmt);
goto fail;
}
} else {
drv = NULL;
}
if (bdrv_open(bs, filename, flags, drv) < 0) {
error_report("Could not open '%s'", filename);
goto fail;
}
if (bdrv_is_encrypted(bs)) {
printf("Disk image '%s' is encrypted.\n", filename);
if (read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto fail;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto fail;
}
}
return bs;
fail:
if (bs) {
bdrv_delete(bs);
}
return NULL;
}
| false | qemu | ad7171394f2fe3f9b5fe02f0c62496291a859a92 | static BlockDriverState *bdrv_new_open(const char *filename,
const char *fmt,
int flags)
{
BlockDriverState *bs;
BlockDriver *drv;
char password[256];
bs = bdrv_new("");
if (!bs) {
error_report("Not enough memory");
goto fail;
}
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
error_report("Unknown file format '%s'", fmt);
goto fail;
}
} else {
drv = NULL;
}
if (bdrv_open(bs, filename, flags, drv) < 0) {
error_report("Could not open '%s'", filename);
goto fail;
}
if (bdrv_is_encrypted(bs)) {
printf("Disk image '%s' is encrypted.\n", filename);
if (read_password(password, sizeof(password)) < 0) {
error_report("No password given");
goto fail;
}
if (bdrv_set_key(bs, password) < 0) {
error_report("invalid password");
goto fail;
}
}
return bs;
fail:
if (bs) {
bdrv_delete(bs);
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static BlockDriverState *FUNC_0(const char *filename,
const char *fmt,
int flags)
{
BlockDriverState *bs;
BlockDriver *drv;
char VAR_0[256];
bs = bdrv_new("");
if (!bs) {
error_report("Not enough memory");
goto fail;
}
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
error_report("Unknown file format '%s'", fmt);
goto fail;
}
} else {
drv = NULL;
}
if (bdrv_open(bs, filename, flags, drv) < 0) {
error_report("Could not open '%s'", filename);
goto fail;
}
if (bdrv_is_encrypted(bs)) {
printf("Disk image '%s' is encrypted.\n", filename);
if (read_password(VAR_0, sizeof(VAR_0)) < 0) {
error_report("No VAR_0 given");
goto fail;
}
if (bdrv_set_key(bs, VAR_0) < 0) {
error_report("invalid VAR_0");
goto fail;
}
}
return bs;
fail:
if (bs) {
bdrv_delete(bs);
}
return NULL;
}
| [
"static BlockDriverState *FUNC_0(const char *filename,\nconst char *fmt,\nint flags)\n{",
"BlockDriverState *bs;",
"BlockDriver *drv;",
"char VAR_0[256];",
"bs = bdrv_new(\"\");",
"if (!bs) {",
"error_report(\"Not enough memory\");",
"goto fail;",
"}",
"if (fmt) {",
"drv = bdrv_find_format(fmt);",
"if (!drv) {",
"error_report(\"Unknown file format '%s'\", fmt);",
"goto fail;",
"}",
"} else {",
"drv = NULL;",
"}",
"if (bdrv_open(bs, filename, flags, drv) < 0) {",
"error_report(\"Could not open '%s'\", filename);",
"goto fail;",
"}",
"if (bdrv_is_encrypted(bs)) {",
"printf(\"Disk image '%s' is encrypted.\\n\", filename);",
"if (read_password(VAR_0, sizeof(VAR_0)) < 0) {",
"error_report(\"No VAR_0 given\");",
"goto fail;",
"}",
"if (bdrv_set_key(bs, VAR_0) < 0) {",
"error_report(\"invalid VAR_0\");",
"goto fail;",
"}",
"}",
"return bs;",
"fail:\nif (bs) {",
"bdrv_delete(bs);",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
]
] |
1,904 | static uint32_t bitband_readl(void *opaque, target_phys_addr_t offset)
{
uint32_t addr;
uint32_t mask;
uint32_t v;
addr = bitband_addr(opaque, offset) & ~3;
mask = (1 << ((offset >> 2) & 31));
mask = tswap32(mask);
cpu_physical_memory_read(addr, (uint8_t *)&v, 4);
return (v & mask) != 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t bitband_readl(void *opaque, target_phys_addr_t offset)
{
uint32_t addr;
uint32_t mask;
uint32_t v;
addr = bitband_addr(opaque, offset) & ~3;
mask = (1 << ((offset >> 2) & 31));
mask = tswap32(mask);
cpu_physical_memory_read(addr, (uint8_t *)&v, 4);
return (v & mask) != 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset)
{
uint32_t addr;
uint32_t mask;
uint32_t v;
addr = bitband_addr(opaque, offset) & ~3;
mask = (1 << ((offset >> 2) & 31));
mask = tswap32(mask);
cpu_physical_memory_read(addr, (uint8_t *)&v, 4);
return (v & mask) != 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset)\n{",
"uint32_t addr;",
"uint32_t mask;",
"uint32_t v;",
"addr = bitband_addr(opaque, offset) & ~3;",
"mask = (1 << ((offset >> 2) & 31));",
"mask = tswap32(mask);",
"cpu_physical_memory_read(addr, (uint8_t *)&v, 4);",
"return (v & mask) != 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,906 | int64_t qemu_strtosz_MiB(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'M', 1024);
}
| false | qemu | f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7 | int64_t qemu_strtosz_MiB(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'M', 1024);
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'M', 1024);
}
| [
"int64_t FUNC_0(const char *nptr, char **end)\n{",
"return do_strtosz(nptr, end, 'M', 1024);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,907 | static void to_json(const QObject *obj, QString *str, int pretty, int indent)
{
switch (qobject_type(obj)) {
case QTYPE_QINT: {
QInt *val = qobject_to_qint(obj);
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val));
qstring_append(str, buffer);
break;
}
case QTYPE_QSTRING: {
QString *val = qobject_to_qstring(obj);
const char *ptr;
ptr = qstring_get_str(val);
qstring_append(str, "\"");
while (*ptr) {
if ((ptr[0] & 0xE0) == 0xE0 &&
(ptr[1] & 0x80) && (ptr[2] & 0x80)) {
uint16_t wchar;
char escape[7];
wchar = (ptr[0] & 0x0F) << 12;
wchar |= (ptr[1] & 0x3F) << 6;
wchar |= (ptr[2] & 0x3F);
ptr += 2;
snprintf(escape, sizeof(escape), "\\u%04X", wchar);
qstring_append(str, escape);
} else if ((ptr[0] & 0xE0) == 0xC0 && (ptr[1] & 0x80)) {
uint16_t wchar;
char escape[7];
wchar = (ptr[0] & 0x1F) << 6;
wchar |= (ptr[1] & 0x3F);
ptr++;
snprintf(escape, sizeof(escape), "\\u%04X", wchar);
qstring_append(str, escape);
} else switch (ptr[0]) {
case '\"':
qstring_append(str, "\\\"");
break;
case '\\':
qstring_append(str, "\\\\");
break;
case '\b':
qstring_append(str, "\\b");
break;
case '\f':
qstring_append(str, "\\f");
break;
case '\n':
qstring_append(str, "\\n");
break;
case '\r':
qstring_append(str, "\\r");
break;
case '\t':
qstring_append(str, "\\t");
break;
default: {
if (ptr[0] <= 0x1F) {
char escape[7];
snprintf(escape, sizeof(escape), "\\u%04X", ptr[0]);
qstring_append(str, escape);
} else {
char buf[2] = { ptr[0], 0 };
qstring_append(str, buf);
}
break;
}
}
ptr++;
}
qstring_append(str, "\"");
break;
}
case QTYPE_QDICT: {
ToJsonIterState s;
QDict *val = qobject_to_qdict(obj);
s.count = 0;
s.str = str;
s.indent = indent + 1;
s.pretty = pretty;
qstring_append(str, "{");
qdict_iter(val, to_json_dict_iter, &s);
if (pretty) {
int j;
qstring_append(str, "\n");
for (j = 0 ; j < indent ; j++)
qstring_append(str, " ");
}
qstring_append(str, "}");
break;
}
case QTYPE_QLIST: {
ToJsonIterState s;
QList *val = qobject_to_qlist(obj);
s.count = 0;
s.str = str;
s.indent = indent + 1;
s.pretty = pretty;
qstring_append(str, "[");
qlist_iter(val, (void *)to_json_list_iter, &s);
if (pretty) {
int j;
qstring_append(str, "\n");
for (j = 0 ; j < indent ; j++)
qstring_append(str, " ");
}
qstring_append(str, "]");
break;
}
case QTYPE_QFLOAT: {
QFloat *val = qobject_to_qfloat(obj);
char buffer[1024];
int len;
len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val));
while (len > 0 && buffer[len - 1] == '0') {
len--;
}
if (len && buffer[len - 1] == '.') {
buffer[len - 1] = 0;
} else {
buffer[len] = 0;
}
qstring_append(str, buffer);
break;
}
case QTYPE_QBOOL: {
QBool *val = qobject_to_qbool(obj);
if (qbool_get_int(val)) {
qstring_append(str, "true");
} else {
qstring_append(str, "false");
}
break;
}
case QTYPE_QERROR:
/* XXX: should QError be emitted? */
case QTYPE_NONE:
break;
}
}
| false | qemu | e2ec3f976803b360c70d9ae2ba13852fa5d11665 | static void to_json(const QObject *obj, QString *str, int pretty, int indent)
{
switch (qobject_type(obj)) {
case QTYPE_QINT: {
QInt *val = qobject_to_qint(obj);
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val));
qstring_append(str, buffer);
break;
}
case QTYPE_QSTRING: {
QString *val = qobject_to_qstring(obj);
const char *ptr;
ptr = qstring_get_str(val);
qstring_append(str, "\"");
while (*ptr) {
if ((ptr[0] & 0xE0) == 0xE0 &&
(ptr[1] & 0x80) && (ptr[2] & 0x80)) {
uint16_t wchar;
char escape[7];
wchar = (ptr[0] & 0x0F) << 12;
wchar |= (ptr[1] & 0x3F) << 6;
wchar |= (ptr[2] & 0x3F);
ptr += 2;
snprintf(escape, sizeof(escape), "\\u%04X", wchar);
qstring_append(str, escape);
} else if ((ptr[0] & 0xE0) == 0xC0 && (ptr[1] & 0x80)) {
uint16_t wchar;
char escape[7];
wchar = (ptr[0] & 0x1F) << 6;
wchar |= (ptr[1] & 0x3F);
ptr++;
snprintf(escape, sizeof(escape), "\\u%04X", wchar);
qstring_append(str, escape);
} else switch (ptr[0]) {
case '\"':
qstring_append(str, "\\\"");
break;
case '\\':
qstring_append(str, "\\\\");
break;
case '\b':
qstring_append(str, "\\b");
break;
case '\f':
qstring_append(str, "\\f");
break;
case '\n':
qstring_append(str, "\\n");
break;
case '\r':
qstring_append(str, "\\r");
break;
case '\t':
qstring_append(str, "\\t");
break;
default: {
if (ptr[0] <= 0x1F) {
char escape[7];
snprintf(escape, sizeof(escape), "\\u%04X", ptr[0]);
qstring_append(str, escape);
} else {
char buf[2] = { ptr[0], 0 };
qstring_append(str, buf);
}
break;
}
}
ptr++;
}
qstring_append(str, "\"");
break;
}
case QTYPE_QDICT: {
ToJsonIterState s;
QDict *val = qobject_to_qdict(obj);
s.count = 0;
s.str = str;
s.indent = indent + 1;
s.pretty = pretty;
qstring_append(str, "{");
qdict_iter(val, to_json_dict_iter, &s);
if (pretty) {
int j;
qstring_append(str, "\n");
for (j = 0 ; j < indent ; j++)
qstring_append(str, " ");
}
qstring_append(str, "}");
break;
}
case QTYPE_QLIST: {
ToJsonIterState s;
QList *val = qobject_to_qlist(obj);
s.count = 0;
s.str = str;
s.indent = indent + 1;
s.pretty = pretty;
qstring_append(str, "[");
qlist_iter(val, (void *)to_json_list_iter, &s);
if (pretty) {
int j;
qstring_append(str, "\n");
for (j = 0 ; j < indent ; j++)
qstring_append(str, " ");
}
qstring_append(str, "]");
break;
}
case QTYPE_QFLOAT: {
QFloat *val = qobject_to_qfloat(obj);
char buffer[1024];
int len;
len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val));
while (len > 0 && buffer[len - 1] == '0') {
len--;
}
if (len && buffer[len - 1] == '.') {
buffer[len - 1] = 0;
} else {
buffer[len] = 0;
}
qstring_append(str, buffer);
break;
}
case QTYPE_QBOOL: {
QBool *val = qobject_to_qbool(obj);
if (qbool_get_int(val)) {
qstring_append(str, "true");
} else {
qstring_append(str, "false");
}
break;
}
case QTYPE_QERROR:
case QTYPE_NONE:
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const QObject *VAR_0, QString *VAR_1, int VAR_2, int VAR_3)
{
switch (qobject_type(VAR_0)) {
case QTYPE_QINT: {
QInt *val = qobject_to_qint(VAR_0);
char VAR_9[1024];
snprintf(VAR_9, sizeof(VAR_9), "%" PRId64, qint_get_int(val));
qstring_append(VAR_1, VAR_9);
break;
}
case QTYPE_QSTRING: {
QString *val = qobject_to_qstring(VAR_0);
const char *VAR_5;
VAR_5 = qstring_get_str(val);
qstring_append(VAR_1, "\"");
while (*VAR_5) {
if ((VAR_5[0] & 0xE0) == 0xE0 &&
(VAR_5[1] & 0x80) && (VAR_5[2] & 0x80)) {
uint16_t wchar;
char VAR_7[7];
wchar = (VAR_5[0] & 0x0F) << 12;
wchar |= (VAR_5[1] & 0x3F) << 6;
wchar |= (VAR_5[2] & 0x3F);
VAR_5 += 2;
snprintf(VAR_7, sizeof(VAR_7), "\\u%04X", wchar);
qstring_append(VAR_1, VAR_7);
} else if ((VAR_5[0] & 0xE0) == 0xC0 && (VAR_5[1] & 0x80)) {
uint16_t wchar;
char VAR_7[7];
wchar = (VAR_5[0] & 0x1F) << 6;
wchar |= (VAR_5[1] & 0x3F);
VAR_5++;
snprintf(VAR_7, sizeof(VAR_7), "\\u%04X", wchar);
qstring_append(VAR_1, VAR_7);
} else switch (VAR_5[0]) {
case '\"':
qstring_append(VAR_1, "\\\"");
break;
case '\\':
qstring_append(VAR_1, "\\\\");
break;
case '\b':
qstring_append(VAR_1, "\\b");
break;
case '\f':
qstring_append(VAR_1, "\\f");
break;
case '\n':
qstring_append(VAR_1, "\\n");
break;
case '\r':
qstring_append(VAR_1, "\\r");
break;
case '\t':
qstring_append(VAR_1, "\\t");
break;
default: {
if (VAR_5[0] <= 0x1F) {
char VAR_7[7];
snprintf(VAR_7, sizeof(VAR_7), "\\u%04X", VAR_5[0]);
qstring_append(VAR_1, VAR_7);
} else {
char VAR_7[2] = { VAR_5[0], 0 };
qstring_append(VAR_1, VAR_7);
}
break;
}
}
VAR_5++;
}
qstring_append(VAR_1, "\"");
break;
}
case QTYPE_QDICT: {
ToJsonIterState s;
QDict *val = qobject_to_qdict(VAR_0);
s.count = 0;
s.VAR_1 = VAR_1;
s.VAR_3 = VAR_3 + 1;
s.VAR_2 = VAR_2;
qstring_append(VAR_1, "{");
qdict_iter(val, to_json_dict_iter, &s);
if (VAR_2) {
int VAR_9;
qstring_append(VAR_1, "\n");
for (VAR_9 = 0 ; VAR_9 < VAR_3 ; VAR_9++)
qstring_append(VAR_1, " ");
}
qstring_append(VAR_1, "}");
break;
}
case QTYPE_QLIST: {
ToJsonIterState s;
QList *val = qobject_to_qlist(VAR_0);
s.count = 0;
s.VAR_1 = VAR_1;
s.VAR_3 = VAR_3 + 1;
s.VAR_2 = VAR_2;
qstring_append(VAR_1, "[");
qlist_iter(val, (void *)to_json_list_iter, &s);
if (VAR_2) {
int VAR_9;
qstring_append(VAR_1, "\n");
for (VAR_9 = 0 ; VAR_9 < VAR_3 ; VAR_9++)
qstring_append(VAR_1, " ");
}
qstring_append(VAR_1, "]");
break;
}
case QTYPE_QFLOAT: {
QFloat *val = qobject_to_qfloat(VAR_0);
char VAR_9[1024];
int VAR_9;
VAR_9 = snprintf(VAR_9, sizeof(VAR_9), "%f", qfloat_get_double(val));
while (VAR_9 > 0 && VAR_9[VAR_9 - 1] == '0') {
VAR_9--;
}
if (VAR_9 && VAR_9[VAR_9 - 1] == '.') {
VAR_9[VAR_9 - 1] = 0;
} else {
VAR_9[VAR_9] = 0;
}
qstring_append(VAR_1, VAR_9);
break;
}
case QTYPE_QBOOL: {
QBool *val = qobject_to_qbool(VAR_0);
if (qbool_get_int(val)) {
qstring_append(VAR_1, "true");
} else {
qstring_append(VAR_1, "false");
}
break;
}
case QTYPE_QERROR:
case QTYPE_NONE:
break;
}
}
| [
"static void FUNC_0(const QObject *VAR_0, QString *VAR_1, int VAR_2, int VAR_3)\n{",
"switch (qobject_type(VAR_0)) {",
"case QTYPE_QINT: {",
"QInt *val = qobject_to_qint(VAR_0);",
"char VAR_9[1024];",
"snprintf(VAR_9, sizeof(VAR_9), \"%\" PRId64, qint_get_int(val));",
"qstring_append(VAR_1, VAR_9);",
"break;",
"}",
"case QTYPE_QSTRING: {",
"QString *val = qobject_to_qstring(VAR_0);",
"const char *VAR_5;",
"VAR_5 = qstring_get_str(val);",
"qstring_append(VAR_1, \"\\\"\");",
"while (*VAR_5) {",
"if ((VAR_5[0] & 0xE0) == 0xE0 &&\n(VAR_5[1] & 0x80) && (VAR_5[2] & 0x80)) {",
"uint16_t wchar;",
"char VAR_7[7];",
"wchar = (VAR_5[0] & 0x0F) << 12;",
"wchar |= (VAR_5[1] & 0x3F) << 6;",
"wchar |= (VAR_5[2] & 0x3F);",
"VAR_5 += 2;",
"snprintf(VAR_7, sizeof(VAR_7), \"\\\\u%04X\", wchar);",
"qstring_append(VAR_1, VAR_7);",
"} else if ((VAR_5[0] & 0xE0) == 0xC0 && (VAR_5[1] & 0x80)) {",
"uint16_t wchar;",
"char VAR_7[7];",
"wchar = (VAR_5[0] & 0x1F) << 6;",
"wchar |= (VAR_5[1] & 0x3F);",
"VAR_5++;",
"snprintf(VAR_7, sizeof(VAR_7), \"\\\\u%04X\", wchar);",
"qstring_append(VAR_1, VAR_7);",
"} else switch (VAR_5[0]) {",
"case '\\\"':\nqstring_append(VAR_1, \"\\\\\\\"\");",
"break;",
"case '\\\\':\nqstring_append(VAR_1, \"\\\\\\\\\");",
"break;",
"case '\\b':\nqstring_append(VAR_1, \"\\\\b\");",
"break;",
"case '\\f':\nqstring_append(VAR_1, \"\\\\f\");",
"break;",
"case '\\n':\nqstring_append(VAR_1, \"\\\\n\");",
"break;",
"case '\\r':\nqstring_append(VAR_1, \"\\\\r\");",
"break;",
"case '\\t':\nqstring_append(VAR_1, \"\\\\t\");",
"break;",
"default: {",
"if (VAR_5[0] <= 0x1F) {",
"char VAR_7[7];",
"snprintf(VAR_7, sizeof(VAR_7), \"\\\\u%04X\", VAR_5[0]);",
"qstring_append(VAR_1, VAR_7);",
"} else {",
"char VAR_7[2] = { VAR_5[0], 0 };",
"qstring_append(VAR_1, VAR_7);",
"}",
"break;",
"}",
"}",
"VAR_5++;",
"}",
"qstring_append(VAR_1, \"\\\"\");",
"break;",
"}",
"case QTYPE_QDICT: {",
"ToJsonIterState s;",
"QDict *val = qobject_to_qdict(VAR_0);",
"s.count = 0;",
"s.VAR_1 = VAR_1;",
"s.VAR_3 = VAR_3 + 1;",
"s.VAR_2 = VAR_2;",
"qstring_append(VAR_1, \"{\");",
"qdict_iter(val, to_json_dict_iter, &s);",
"if (VAR_2) {",
"int VAR_9;",
"qstring_append(VAR_1, \"\\n\");",
"for (VAR_9 = 0 ; VAR_9 < VAR_3 ; VAR_9++)",
"qstring_append(VAR_1, \" \");",
"}",
"qstring_append(VAR_1, \"}\");",
"break;",
"}",
"case QTYPE_QLIST: {",
"ToJsonIterState s;",
"QList *val = qobject_to_qlist(VAR_0);",
"s.count = 0;",
"s.VAR_1 = VAR_1;",
"s.VAR_3 = VAR_3 + 1;",
"s.VAR_2 = VAR_2;",
"qstring_append(VAR_1, \"[\");",
"qlist_iter(val, (void *)to_json_list_iter, &s);",
"if (VAR_2) {",
"int VAR_9;",
"qstring_append(VAR_1, \"\\n\");",
"for (VAR_9 = 0 ; VAR_9 < VAR_3 ; VAR_9++)",
"qstring_append(VAR_1, \" \");",
"}",
"qstring_append(VAR_1, \"]\");",
"break;",
"}",
"case QTYPE_QFLOAT: {",
"QFloat *val = qobject_to_qfloat(VAR_0);",
"char VAR_9[1024];",
"int VAR_9;",
"VAR_9 = snprintf(VAR_9, sizeof(VAR_9), \"%f\", qfloat_get_double(val));",
"while (VAR_9 > 0 && VAR_9[VAR_9 - 1] == '0') {",
"VAR_9--;",
"}",
"if (VAR_9 && VAR_9[VAR_9 - 1] == '.') {",
"VAR_9[VAR_9 - 1] = 0;",
"} else {",
"VAR_9[VAR_9] = 0;",
"}",
"qstring_append(VAR_1, VAR_9);",
"break;",
"}",
"case QTYPE_QBOOL: {",
"QBool *val = qobject_to_qbool(VAR_0);",
"if (qbool_get_int(val)) {",
"qstring_append(VAR_1, \"true\");",
"} else {",
"qstring_append(VAR_1, \"false\");",
"}",
"break;",
"}",
"case QTYPE_QERROR:\ncase QTYPE_NONE:\nbreak;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
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
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293,
297,
299
],
[
301
],
[
303
]
] |
1,908 | static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len)
{
ByteIOContext *pb = &s->pb;
int hdr, seq, pic_num, len2, pos;
int type;
int ssize;
hdr = get_byte(pb); len--;
type = hdr >> 6;
switch(type){
case 0: // slice
case 2: // last slice
seq = get_byte(pb); len--;
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
rm->remaining_len = len;
break;
case 1: //whole frame
seq = get_byte(pb); len--;
if(av_new_packet(pkt, len + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len);
rm->remaining_len = 0;
return 0;
case 3: //frame as a part of packet
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
rm->remaining_len = len - len2;
if(av_new_packet(pkt, len2 + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len2);
return 0;
}
//now we have to deal with single slice
if((seq & 0x7F) == 1 || rm->curpic_num != pic_num){
rm->slices = ((hdr & 0x3F) << 1) + 1;
ssize = len2 + 8*rm->slices + 1;
rm->videobuf = av_realloc(rm->videobuf, ssize);
rm->videobufsize = ssize;
rm->videobufpos = 8*rm->slices + 1;
rm->cur_slice = 0;
rm->curpic_num = pic_num;
rm->pktpos = url_ftell(pb);
}
if(type == 2){
len = FFMIN(len, pos);
pos = len2 - pos;
}
if(++rm->cur_slice > rm->cur_slice)
return 1;
AV_WL32(rm->videobuf - 7 + 8*rm->cur_slice, 1);
AV_WL32(rm->videobuf - 3 + 8*rm->cur_slice, rm->videobufpos - 8*rm->slices - 1);
if(rm->videobufpos + len > rm->videobufsize)
return 1;
if (get_buffer(pb, rm->videobuf + rm->videobufpos, len) != len)
return AVERROR(EIO);
rm->videobufpos += len,
rm->remaining_len-= len;
if(type == 2 || (rm->videobufpos) == rm->videobufsize){
//adjust slice headers
memmove(rm->videobuf + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufsize - 1 - 8*rm->slices);
ssize = rm->videobufsize - 8*(rm->slices - rm->cur_slice);
rm->videobuf[0] = rm->cur_slice-1;
if(av_new_packet(pkt, ssize) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data, rm->videobuf, ssize);
pkt->pts = AV_NOPTS_VALUE;
pkt->pos = rm->pktpos;
return 0;
}
return 1;
}
| false | FFmpeg | 27a2f87da8012efd31f0df063072c16345fbe115 | static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len)
{
ByteIOContext *pb = &s->pb;
int hdr, seq, pic_num, len2, pos;
int type;
int ssize;
hdr = get_byte(pb); len--;
type = hdr >> 6;
switch(type){
case 0:
case 2:
seq = get_byte(pb); len--;
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
rm->remaining_len = len;
break;
case 1:
seq = get_byte(pb); len--;
if(av_new_packet(pkt, len + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len);
rm->remaining_len = 0;
return 0;
case 3:
len2 = get_num(pb, &len);
pos = get_num(pb, &len);
pic_num = get_byte(pb); len--;
rm->remaining_len = len - len2;
if(av_new_packet(pkt, len2 + 9) < 0)
return AVERROR(EIO);
pkt->data[0] = 0;
AV_WL32(pkt->data + 1, 1);
AV_WL32(pkt->data + 5, 0);
get_buffer(pb, pkt->data + 9, len2);
return 0;
}
if((seq & 0x7F) == 1 || rm->curpic_num != pic_num){
rm->slices = ((hdr & 0x3F) << 1) + 1;
ssize = len2 + 8*rm->slices + 1;
rm->videobuf = av_realloc(rm->videobuf, ssize);
rm->videobufsize = ssize;
rm->videobufpos = 8*rm->slices + 1;
rm->cur_slice = 0;
rm->curpic_num = pic_num;
rm->pktpos = url_ftell(pb);
}
if(type == 2){
len = FFMIN(len, pos);
pos = len2 - pos;
}
if(++rm->cur_slice > rm->cur_slice)
return 1;
AV_WL32(rm->videobuf - 7 + 8*rm->cur_slice, 1);
AV_WL32(rm->videobuf - 3 + 8*rm->cur_slice, rm->videobufpos - 8*rm->slices - 1);
if(rm->videobufpos + len > rm->videobufsize)
return 1;
if (get_buffer(pb, rm->videobuf + rm->videobufpos, len) != len)
return AVERROR(EIO);
rm->videobufpos += len,
rm->remaining_len-= len;
if(type == 2 || (rm->videobufpos) == rm->videobufsize){
memmove(rm->videobuf + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufsize - 1 - 8*rm->slices);
ssize = rm->videobufsize - 8*(rm->slices - rm->cur_slice);
rm->videobuf[0] = rm->cur_slice-1;
if(av_new_packet(pkt, ssize) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data, rm->videobuf, ssize);
pkt->pts = AV_NOPTS_VALUE;
pkt->pos = rm->pktpos;
return 0;
}
return 1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, RMContext *VAR_1, AVPacket *VAR_2, int VAR_3)
{
ByteIOContext *pb = &VAR_0->pb;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int VAR_9;
int VAR_10;
VAR_4 = get_byte(pb); VAR_3--;
VAR_9 = VAR_4 >> 6;
switch(VAR_9){
case 0:
case 2:
VAR_5 = get_byte(pb); VAR_3--;
VAR_7 = get_num(pb, &VAR_3);
VAR_8 = get_num(pb, &VAR_3);
VAR_6 = get_byte(pb); VAR_3--;
VAR_1->remaining_len = VAR_3;
break;
case 1:
VAR_5 = get_byte(pb); VAR_3--;
if(av_new_packet(VAR_2, VAR_3 + 9) < 0)
return AVERROR(EIO);
VAR_2->data[0] = 0;
AV_WL32(VAR_2->data + 1, 1);
AV_WL32(VAR_2->data + 5, 0);
get_buffer(pb, VAR_2->data + 9, VAR_3);
VAR_1->remaining_len = 0;
return 0;
case 3:
VAR_7 = get_num(pb, &VAR_3);
VAR_8 = get_num(pb, &VAR_3);
VAR_6 = get_byte(pb); VAR_3--;
VAR_1->remaining_len = VAR_3 - VAR_7;
if(av_new_packet(VAR_2, VAR_7 + 9) < 0)
return AVERROR(EIO);
VAR_2->data[0] = 0;
AV_WL32(VAR_2->data + 1, 1);
AV_WL32(VAR_2->data + 5, 0);
get_buffer(pb, VAR_2->data + 9, VAR_7);
return 0;
}
if((VAR_5 & 0x7F) == 1 || VAR_1->curpic_num != VAR_6){
VAR_1->slices = ((VAR_4 & 0x3F) << 1) + 1;
VAR_10 = VAR_7 + 8*VAR_1->slices + 1;
VAR_1->videobuf = av_realloc(VAR_1->videobuf, VAR_10);
VAR_1->videobufsize = VAR_10;
VAR_1->videobufpos = 8*VAR_1->slices + 1;
VAR_1->cur_slice = 0;
VAR_1->curpic_num = VAR_6;
VAR_1->pktpos = url_ftell(pb);
}
if(VAR_9 == 2){
VAR_3 = FFMIN(VAR_3, VAR_8);
VAR_8 = VAR_7 - VAR_8;
}
if(++VAR_1->cur_slice > VAR_1->cur_slice)
return 1;
AV_WL32(VAR_1->videobuf - 7 + 8*VAR_1->cur_slice, 1);
AV_WL32(VAR_1->videobuf - 3 + 8*VAR_1->cur_slice, VAR_1->videobufpos - 8*VAR_1->slices - 1);
if(VAR_1->videobufpos + VAR_3 > VAR_1->videobufsize)
return 1;
if (get_buffer(pb, VAR_1->videobuf + VAR_1->videobufpos, VAR_3) != VAR_3)
return AVERROR(EIO);
VAR_1->videobufpos += VAR_3,
VAR_1->remaining_len-= VAR_3;
if(VAR_9 == 2 || (VAR_1->videobufpos) == VAR_1->videobufsize){
memmove(VAR_1->videobuf + 1 + 8*VAR_1->cur_slice, VAR_1->videobuf + 1 + 8*VAR_1->slices, VAR_1->videobufsize - 1 - 8*VAR_1->slices);
VAR_10 = VAR_1->videobufsize - 8*(VAR_1->slices - VAR_1->cur_slice);
VAR_1->videobuf[0] = VAR_1->cur_slice-1;
if(av_new_packet(VAR_2, VAR_10) < 0)
return AVERROR(ENOMEM);
memcpy(VAR_2->data, VAR_1->videobuf, VAR_10);
VAR_2->pts = AV_NOPTS_VALUE;
VAR_2->VAR_8 = VAR_1->pktpos;
return 0;
}
return 1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, RMContext *VAR_1, AVPacket *VAR_2, int VAR_3)\n{",
"ByteIOContext *pb = &VAR_0->pb;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int VAR_9;",
"int VAR_10;",
"VAR_4 = get_byte(pb); VAR_3--;",
"VAR_9 = VAR_4 >> 6;",
"switch(VAR_9){",
"case 0:\ncase 2:\nVAR_5 = get_byte(pb); VAR_3--;",
"VAR_7 = get_num(pb, &VAR_3);",
"VAR_8 = get_num(pb, &VAR_3);",
"VAR_6 = get_byte(pb); VAR_3--;",
"VAR_1->remaining_len = VAR_3;",
"break;",
"case 1:\nVAR_5 = get_byte(pb); VAR_3--;",
"if(av_new_packet(VAR_2, VAR_3 + 9) < 0)\nreturn AVERROR(EIO);",
"VAR_2->data[0] = 0;",
"AV_WL32(VAR_2->data + 1, 1);",
"AV_WL32(VAR_2->data + 5, 0);",
"get_buffer(pb, VAR_2->data + 9, VAR_3);",
"VAR_1->remaining_len = 0;",
"return 0;",
"case 3:\nVAR_7 = get_num(pb, &VAR_3);",
"VAR_8 = get_num(pb, &VAR_3);",
"VAR_6 = get_byte(pb); VAR_3--;",
"VAR_1->remaining_len = VAR_3 - VAR_7;",
"if(av_new_packet(VAR_2, VAR_7 + 9) < 0)\nreturn AVERROR(EIO);",
"VAR_2->data[0] = 0;",
"AV_WL32(VAR_2->data + 1, 1);",
"AV_WL32(VAR_2->data + 5, 0);",
"get_buffer(pb, VAR_2->data + 9, VAR_7);",
"return 0;",
"}",
"if((VAR_5 & 0x7F) == 1 || VAR_1->curpic_num != VAR_6){",
"VAR_1->slices = ((VAR_4 & 0x3F) << 1) + 1;",
"VAR_10 = VAR_7 + 8*VAR_1->slices + 1;",
"VAR_1->videobuf = av_realloc(VAR_1->videobuf, VAR_10);",
"VAR_1->videobufsize = VAR_10;",
"VAR_1->videobufpos = 8*VAR_1->slices + 1;",
"VAR_1->cur_slice = 0;",
"VAR_1->curpic_num = VAR_6;",
"VAR_1->pktpos = url_ftell(pb);",
"}",
"if(VAR_9 == 2){",
"VAR_3 = FFMIN(VAR_3, VAR_8);",
"VAR_8 = VAR_7 - VAR_8;",
"}",
"if(++VAR_1->cur_slice > VAR_1->cur_slice)\nreturn 1;",
"AV_WL32(VAR_1->videobuf - 7 + 8*VAR_1->cur_slice, 1);",
"AV_WL32(VAR_1->videobuf - 3 + 8*VAR_1->cur_slice, VAR_1->videobufpos - 8*VAR_1->slices - 1);",
"if(VAR_1->videobufpos + VAR_3 > VAR_1->videobufsize)\nreturn 1;",
"if (get_buffer(pb, VAR_1->videobuf + VAR_1->videobufpos, VAR_3) != VAR_3)\nreturn AVERROR(EIO);",
"VAR_1->videobufpos += VAR_3,\nVAR_1->remaining_len-= VAR_3;",
"if(VAR_9 == 2 || (VAR_1->videobufpos) == VAR_1->videobufsize){",
"memmove(VAR_1->videobuf + 1 + 8*VAR_1->cur_slice, VAR_1->videobuf + 1 + 8*VAR_1->slices, VAR_1->videobufsize - 1 - 8*VAR_1->slices);",
"VAR_10 = VAR_1->videobufsize - 8*(VAR_1->slices - VAR_1->cur_slice);",
"VAR_1->videobuf[0] = VAR_1->cur_slice-1;",
"if(av_new_packet(VAR_2, VAR_10) < 0)\nreturn AVERROR(ENOMEM);",
"memcpy(VAR_2->data, VAR_1->videobuf, VAR_10);",
"VAR_2->pts = AV_NOPTS_VALUE;",
"VAR_2->VAR_8 = VAR_1->pktpos;",
"return 0;",
"}",
"return 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
125,
127
],
[
129,
131
],
[
133,
135
],
[
139
],
[
143
],
[
145
],
[
149
],
[
151,
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
167
],
[
169
]
] |
1,910 | static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
{
if (d->term_got_escape) {
d->term_got_escape = 0;
if (ch == term_escape_char)
goto send_char;
switch(ch) {
case '?':
case 'h':
mux_print_help(chr);
break;
case 'x':
{
const char *term = "QEMU: Terminated\n\r";
qemu_chr_fe_write(chr, (uint8_t *)term, strlen(term));
exit(0);
break;
}
case 's':
blk_commit_all();
break;
case 'b':
qemu_chr_be_event(chr, CHR_EVENT_BREAK);
break;
case 'c':
/* Switch to the next registered device */
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
d->focus++;
if (d->focus >= d->mux_cnt)
d->focus = 0;
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
break;
case 't':
d->timestamps = !d->timestamps;
d->timestamps_start = -1;
d->linestart = 0;
break;
}
} else if (ch == term_escape_char) {
d->term_got_escape = 1;
} else {
send_char:
return 1;
}
return 0;
}
| false | qemu | 90f998f5f4267a0c22e983f533d19b9de1849283 | static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
{
if (d->term_got_escape) {
d->term_got_escape = 0;
if (ch == term_escape_char)
goto send_char;
switch(ch) {
case '?':
case 'h':
mux_print_help(chr);
break;
case 'x':
{
const char *term = "QEMU: Terminated\n\r";
qemu_chr_fe_write(chr, (uint8_t *)term, strlen(term));
exit(0);
break;
}
case 's':
blk_commit_all();
break;
case 'b':
qemu_chr_be_event(chr, CHR_EVENT_BREAK);
break;
case 'c':
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_OUT);
d->focus++;
if (d->focus >= d->mux_cnt)
d->focus = 0;
mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN);
break;
case 't':
d->timestamps = !d->timestamps;
d->timestamps_start = -1;
d->linestart = 0;
break;
}
} else if (ch == term_escape_char) {
d->term_got_escape = 1;
} else {
send_char:
return 1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CharDriverState *VAR_0, MuxDriver *VAR_1, int VAR_2)
{
if (VAR_1->term_got_escape) {
VAR_1->term_got_escape = 0;
if (VAR_2 == term_escape_char)
goto send_char;
switch(VAR_2) {
case '?':
case 'h':
mux_print_help(VAR_0);
break;
case 'x':
{
const char *VAR_3 = "QEMU: Terminated\n\r";
qemu_chr_fe_write(VAR_0, (uint8_t *)VAR_3, strlen(VAR_3));
exit(0);
break;
}
case 's':
blk_commit_all();
break;
case 'b':
qemu_chr_be_event(VAR_0, CHR_EVENT_BREAK);
break;
case 'c':
mux_chr_send_event(VAR_1, VAR_1->focus, CHR_EVENT_MUX_OUT);
VAR_1->focus++;
if (VAR_1->focus >= VAR_1->mux_cnt)
VAR_1->focus = 0;
mux_chr_send_event(VAR_1, VAR_1->focus, CHR_EVENT_MUX_IN);
break;
case 't':
VAR_1->timestamps = !VAR_1->timestamps;
VAR_1->timestamps_start = -1;
VAR_1->linestart = 0;
break;
}
} else if (VAR_2 == term_escape_char) {
VAR_1->term_got_escape = 1;
} else {
send_char:
return 1;
}
return 0;
}
| [
"static int FUNC_0(CharDriverState *VAR_0, MuxDriver *VAR_1, int VAR_2)\n{",
"if (VAR_1->term_got_escape) {",
"VAR_1->term_got_escape = 0;",
"if (VAR_2 == term_escape_char)\ngoto send_char;",
"switch(VAR_2) {",
"case '?':\ncase 'h':\nmux_print_help(VAR_0);",
"break;",
"case 'x':\n{",
"const char *VAR_3 = \"QEMU: Terminated\\n\\r\";",
"qemu_chr_fe_write(VAR_0, (uint8_t *)VAR_3, strlen(VAR_3));",
"exit(0);",
"break;",
"}",
"case 's':\nblk_commit_all();",
"break;",
"case 'b':\nqemu_chr_be_event(VAR_0, CHR_EVENT_BREAK);",
"break;",
"case 'c':\nmux_chr_send_event(VAR_1, VAR_1->focus, CHR_EVENT_MUX_OUT);",
"VAR_1->focus++;",
"if (VAR_1->focus >= VAR_1->mux_cnt)\nVAR_1->focus = 0;",
"mux_chr_send_event(VAR_1, VAR_1->focus, CHR_EVENT_MUX_IN);",
"break;",
"case 't':\nVAR_1->timestamps = !VAR_1->timestamps;",
"VAR_1->timestamps_start = -1;",
"VAR_1->linestart = 0;",
"break;",
"}",
"} else if (VAR_2 == term_escape_char) {",
"VAR_1->term_got_escape = 1;",
"} else {",
"send_char:\nreturn 1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49,
53
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
]
] |
1,911 | static void win_chr_readfile(CharDriverState *chr)
{
WinCharState *s = chr->opaque;
int ret, err;
uint8_t buf[1024];
DWORD size;
ZeroMemory(&s->orecv, sizeof(s->orecv));
s->orecv.hEvent = s->hrecv;
ret = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);
if (!ret) {
err = GetLastError();
if (err == ERROR_IO_PENDING) {
ret = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);
}
}
if (size > 0) {
qemu_chr_read(chr, buf, size);
}
}
| false | qemu | 9bd7854e1e5d6f4cfe4558090bbd9493c12bf846 | static void win_chr_readfile(CharDriverState *chr)
{
WinCharState *s = chr->opaque;
int ret, err;
uint8_t buf[1024];
DWORD size;
ZeroMemory(&s->orecv, sizeof(s->orecv));
s->orecv.hEvent = s->hrecv;
ret = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);
if (!ret) {
err = GetLastError();
if (err == ERROR_IO_PENDING) {
ret = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);
}
}
if (size > 0) {
qemu_chr_read(chr, buf, size);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CharDriverState *VAR_0)
{
WinCharState *s = VAR_0->opaque;
int VAR_1, VAR_2;
uint8_t buf[1024];
DWORD size;
ZeroMemory(&s->orecv, sizeof(s->orecv));
s->orecv.hEvent = s->hrecv;
VAR_1 = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);
if (!VAR_1) {
VAR_2 = GetLastError();
if (VAR_2 == ERROR_IO_PENDING) {
VAR_1 = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);
}
}
if (size > 0) {
qemu_chr_read(VAR_0, buf, size);
}
}
| [
"static void FUNC_0(CharDriverState *VAR_0)\n{",
"WinCharState *s = VAR_0->opaque;",
"int VAR_1, VAR_2;",
"uint8_t buf[1024];",
"DWORD size;",
"ZeroMemory(&s->orecv, sizeof(s->orecv));",
"s->orecv.hEvent = s->hrecv;",
"VAR_1 = ReadFile(s->hcom, buf, s->len, &size, &s->orecv);",
"if (!VAR_1) {",
"VAR_2 = GetLastError();",
"if (VAR_2 == ERROR_IO_PENDING) {",
"VAR_1 = GetOverlappedResult(s->hcom, &s->orecv, &size, TRUE);",
"}",
"}",
"if (size > 0) {",
"qemu_chr_read(VAR_0, buf, size);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
1,912 | void mips_r4k_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios;
MemoryRegion *iomem = g_new(MemoryRegion, 1);
MemoryRegion *isa_io = g_new(MemoryRegion, 1);
MemoryRegion *isa_mem = g_new(MemoryRegion, 1);
int bios_size;
MIPSCPU *cpu;
CPUMIPSState *env;
ResetData *reset_info;
int i;
qemu_irq *i8259;
ISABus *isa_bus;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *dinfo;
int be;
/* init CPUs */
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "R4000";
#else
cpu_model = "24Kf";
#endif
}
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
/* allocate RAM */
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_io(iomem, NULL, &mips_qemu_ops, NULL, "mips-qemu", 0x10000);
memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem);
/* Try to load a BIOS image. If this fails, we continue regardless,
but initialize the hardware ourselves. When a kernel gets
preloaded we also initialize the hardware, since the BIOS wasn't
run. */
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "mips_r4k.bios", BIOS_SIZE,
&error_fatal);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), 0x1fc00000, bios);
load_image_targphys(filename, 0x1fc00000, BIOS_SIZE);
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
uint32_t mips_rom = 0x00400000;
if (!pflash_cfi01_register(0x1fc00000, NULL, "mips_r4k.bios", mips_rom,
blk_by_legacy_dinfo(dinfo),
sector_len, mips_rom / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
}
} else if (!qtest_enabled()) {
/* not fatal */
fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
bios_name);
}
g_free(filename);
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
reset_info->vector = load_kernel();
}
/* Init CPU internal devices */
cpu_mips_irq_init_cpu(cpu);
cpu_mips_clock_init(cpu);
/* ISA bus: IO space at 0x14000000, mem space at 0x10000000 */
memory_region_init_alias(isa_io, NULL, "isa-io",
get_system_io(), 0, 0x00010000);
memory_region_init(isa_mem, NULL, "isa-mem", 0x01000000);
memory_region_add_subregion(get_system_memory(), 0x14000000, isa_io);
memory_region_add_subregion(get_system_memory(), 0x10000000, isa_mem);
isa_bus = isa_bus_new(NULL, isa_mem, get_system_io(), &error_abort);
/* The PIC is attached to the MIPS CPU INT0 pin */
i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, i8259);
rtc_init(isa_bus, 2000, NULL);
pit = pit_init(isa_bus, 0x40, 0, NULL);
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
isa_vga_init(isa_bus);
if (nd_table[0].used)
isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);
ide_drive_get(hd, ARRAY_SIZE(hd));
for(i = 0; i < MAX_IDE_BUS; i++)
isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
isa_create_simple(isa_bus, "i8042");
}
| false | qemu | 8297be80f7cf71e09617669a8bd8b2836dcfd4c3 | void mips_r4k_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
char *filename;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios;
MemoryRegion *iomem = g_new(MemoryRegion, 1);
MemoryRegion *isa_io = g_new(MemoryRegion, 1);
MemoryRegion *isa_mem = g_new(MemoryRegion, 1);
int bios_size;
MIPSCPU *cpu;
CPUMIPSState *env;
ResetData *reset_info;
int i;
qemu_irq *i8259;
ISABus *isa_bus;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *dinfo;
int be;
if (cpu_model == NULL) {
#ifdef TARGET_MIPS64
cpu_model = "R4000";
#else
cpu_model = "24Kf";
#endif
}
cpu = cpu_mips_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_io(iomem, NULL, &mips_qemu_ops, NULL, "mips-qemu", 0x10000);
memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = get_image_size(filename);
} else {
bios_size = -1;
}
#ifdef TARGET_WORDS_BIGENDIAN
be = 1;
#else
be = 0;
#endif
if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "mips_r4k.bios", BIOS_SIZE,
&error_fatal);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), 0x1fc00000, bios);
load_image_targphys(filename, 0x1fc00000, BIOS_SIZE);
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
uint32_t mips_rom = 0x00400000;
if (!pflash_cfi01_register(0x1fc00000, NULL, "mips_r4k.bios", mips_rom,
blk_by_legacy_dinfo(dinfo),
sector_len, mips_rom / sector_len,
4, 0, 0, 0, 0, be)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
}
} else if (!qtest_enabled()) {
fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
bios_name);
}
g_free(filename);
if (kernel_filename) {
loaderparams.ram_size = ram_size;
loaderparams.kernel_filename = kernel_filename;
loaderparams.kernel_cmdline = kernel_cmdline;
loaderparams.initrd_filename = initrd_filename;
reset_info->vector = load_kernel();
}
cpu_mips_irq_init_cpu(cpu);
cpu_mips_clock_init(cpu);
memory_region_init_alias(isa_io, NULL, "isa-io",
get_system_io(), 0, 0x00010000);
memory_region_init(isa_mem, NULL, "isa-mem", 0x01000000);
memory_region_add_subregion(get_system_memory(), 0x14000000, isa_io);
memory_region_add_subregion(get_system_memory(), 0x10000000, isa_mem);
isa_bus = isa_bus_new(NULL, isa_mem, get_system_io(), &error_abort);
i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, i8259);
rtc_init(isa_bus, 2000, NULL);
pit = pit_init(isa_bus, 0x40, 0, NULL);
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
isa_vga_init(isa_bus);
if (nd_table[0].used)
isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);
ide_drive_get(hd, ARRAY_SIZE(hd));
for(i = 0; i < MAX_IDE_BUS; i++)
isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
isa_create_simple(isa_bus, "i8042");
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MachineState *VAR_0)
{
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
const char *VAR_3 = VAR_0->VAR_3;
const char *VAR_4 = VAR_0->VAR_4;
char *VAR_5;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios;
MemoryRegion *iomem = g_new(MemoryRegion, 1);
MemoryRegion *isa_io = g_new(MemoryRegion, 1);
MemoryRegion *isa_mem = g_new(MemoryRegion, 1);
int VAR_6;
MIPSCPU *cpu;
CPUMIPSState *env;
ResetData *reset_info;
int VAR_7;
qemu_irq *i8259;
ISABus *isa_bus;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
DriveInfo *dinfo;
int VAR_8;
if (VAR_1 == NULL) {
#ifdef TARGET_MIPS64
VAR_1 = "R4000";
#else
VAR_1 = "24Kf";
#endif
}
cpu = cpu_mips_init(VAR_1);
if (cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
env = &cpu->env;
reset_info = g_malloc0(sizeof(ResetData));
reset_info->cpu = cpu;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
if (ram_size > (256 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this VAR_0: %d MB, maximum 256 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
memory_region_add_subregion(address_space_mem, 0, ram);
memory_region_init_io(iomem, NULL, &mips_qemu_ops, NULL, "mips-qemu", 0x10000);
memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (VAR_5) {
VAR_6 = get_image_size(VAR_5);
} else {
VAR_6 = -1;
}
#ifdef TARGET_WORDS_BIGENDIAN
VAR_8 = 1;
#else
VAR_8 = 0;
#endif
if ((VAR_6 > 0) && (VAR_6 <= BIOS_SIZE)) {
bios = g_new(MemoryRegion, 1);
memory_region_init_ram(bios, NULL, "mips_r4k.bios", BIOS_SIZE,
&error_fatal);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), 0x1fc00000, bios);
load_image_targphys(VAR_5, 0x1fc00000, BIOS_SIZE);
} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {
uint32_t mips_rom = 0x00400000;
if (!pflash_cfi01_register(0x1fc00000, NULL, "mips_r4k.bios", mips_rom,
blk_by_legacy_dinfo(dinfo),
sector_len, mips_rom / sector_len,
4, 0, 0, 0, 0, VAR_8)) {
fprintf(stderr, "qemu: Error registering flash memory.\n");
}
} else if (!qtest_enabled()) {
fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
bios_name);
}
g_free(VAR_5);
if (VAR_2) {
loaderparams.ram_size = ram_size;
loaderparams.VAR_2 = VAR_2;
loaderparams.VAR_3 = VAR_3;
loaderparams.VAR_4 = VAR_4;
reset_info->vector = load_kernel();
}
cpu_mips_irq_init_cpu(cpu);
cpu_mips_clock_init(cpu);
memory_region_init_alias(isa_io, NULL, "isa-io",
get_system_io(), 0, 0x00010000);
memory_region_init(isa_mem, NULL, "isa-mem", 0x01000000);
memory_region_add_subregion(get_system_memory(), 0x14000000, isa_io);
memory_region_add_subregion(get_system_memory(), 0x10000000, isa_mem);
isa_bus = isa_bus_new(NULL, isa_mem, get_system_io(), &error_abort);
i8259 = i8259_init(isa_bus, env->irq[2]);
isa_bus_irqs(isa_bus, i8259);
rtc_init(isa_bus, 2000, NULL);
pit = pit_init(isa_bus, 0x40, 0, NULL);
serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
isa_vga_init(isa_bus);
if (nd_table[0].used)
isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);
ide_drive_get(hd, ARRAY_SIZE(hd));
for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS; VAR_7++)
isa_ide_init(isa_bus, ide_iobase[VAR_7], ide_iobase2[VAR_7], ide_irq[VAR_7],
hd[MAX_IDE_DEVS * VAR_7],
hd[MAX_IDE_DEVS * VAR_7 + 1]);
isa_create_simple(isa_bus, "i8042");
}
| [
"void FUNC_0(MachineState *VAR_0)\n{",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"const char *VAR_3 = VAR_0->VAR_3;",
"const char *VAR_4 = VAR_0->VAR_4;",
"char *VAR_5;",
"MemoryRegion *address_space_mem = get_system_memory();",
"MemoryRegion *ram = g_new(MemoryRegion, 1);",
"MemoryRegion *bios;",
"MemoryRegion *iomem = g_new(MemoryRegion, 1);",
"MemoryRegion *isa_io = g_new(MemoryRegion, 1);",
"MemoryRegion *isa_mem = g_new(MemoryRegion, 1);",
"int VAR_6;",
"MIPSCPU *cpu;",
"CPUMIPSState *env;",
"ResetData *reset_info;",
"int VAR_7;",
"qemu_irq *i8259;",
"ISABus *isa_bus;",
"DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];",
"DriveInfo *dinfo;",
"int VAR_8;",
"if (VAR_1 == NULL) {",
"#ifdef TARGET_MIPS64\nVAR_1 = \"R4000\";",
"#else\nVAR_1 = \"24Kf\";",
"#endif\n}",
"cpu = cpu_mips_init(VAR_1);",
"if (cpu == NULL) {",
"fprintf(stderr, \"Unable to find CPU definition\\n\");",
"exit(1);",
"}",
"env = &cpu->env;",
"reset_info = g_malloc0(sizeof(ResetData));",
"reset_info->cpu = cpu;",
"reset_info->vector = env->active_tc.PC;",
"qemu_register_reset(main_cpu_reset, reset_info);",
"if (ram_size > (256 << 20)) {",
"fprintf(stderr,\n\"qemu: Too much memory for this VAR_0: %d MB, maximum 256 MB\\n\",\n((unsigned int)ram_size / (1 << 20)));",
"exit(1);",
"}",
"memory_region_allocate_system_memory(ram, NULL, \"mips_r4k.ram\", ram_size);",
"memory_region_add_subregion(address_space_mem, 0, ram);",
"memory_region_init_io(iomem, NULL, &mips_qemu_ops, NULL, \"mips-qemu\", 0x10000);",
"memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem);",
"if (bios_name == NULL)\nbios_name = BIOS_FILENAME;",
"VAR_5 = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);",
"if (VAR_5) {",
"VAR_6 = get_image_size(VAR_5);",
"} else {",
"VAR_6 = -1;",
"}",
"#ifdef TARGET_WORDS_BIGENDIAN\nVAR_8 = 1;",
"#else\nVAR_8 = 0;",
"#endif\nif ((VAR_6 > 0) && (VAR_6 <= BIOS_SIZE)) {",
"bios = g_new(MemoryRegion, 1);",
"memory_region_init_ram(bios, NULL, \"mips_r4k.bios\", BIOS_SIZE,\n&error_fatal);",
"memory_region_set_readonly(bios, true);",
"memory_region_add_subregion(get_system_memory(), 0x1fc00000, bios);",
"load_image_targphys(VAR_5, 0x1fc00000, BIOS_SIZE);",
"} else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) {",
"uint32_t mips_rom = 0x00400000;",
"if (!pflash_cfi01_register(0x1fc00000, NULL, \"mips_r4k.bios\", mips_rom,\nblk_by_legacy_dinfo(dinfo),\nsector_len, mips_rom / sector_len,\n4, 0, 0, 0, 0, VAR_8)) {",
"fprintf(stderr, \"qemu: Error registering flash memory.\\n\");",
"}",
"} else if (!qtest_enabled()) {",
"fprintf(stderr, \"qemu: Warning, could not load MIPS bios '%s'\\n\",\nbios_name);",
"}",
"g_free(VAR_5);",
"if (VAR_2) {",
"loaderparams.ram_size = ram_size;",
"loaderparams.VAR_2 = VAR_2;",
"loaderparams.VAR_3 = VAR_3;",
"loaderparams.VAR_4 = VAR_4;",
"reset_info->vector = load_kernel();",
"}",
"cpu_mips_irq_init_cpu(cpu);",
"cpu_mips_clock_init(cpu);",
"memory_region_init_alias(isa_io, NULL, \"isa-io\",\nget_system_io(), 0, 0x00010000);",
"memory_region_init(isa_mem, NULL, \"isa-mem\", 0x01000000);",
"memory_region_add_subregion(get_system_memory(), 0x14000000, isa_io);",
"memory_region_add_subregion(get_system_memory(), 0x10000000, isa_mem);",
"isa_bus = isa_bus_new(NULL, isa_mem, get_system_io(), &error_abort);",
"i8259 = i8259_init(isa_bus, env->irq[2]);",
"isa_bus_irqs(isa_bus, i8259);",
"rtc_init(isa_bus, 2000, NULL);",
"pit = pit_init(isa_bus, 0x40, 0, NULL);",
"serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);",
"isa_vga_init(isa_bus);",
"if (nd_table[0].used)\nisa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);",
"ide_drive_get(hd, ARRAY_SIZE(hd));",
"for(VAR_7 = 0; VAR_7 < MAX_IDE_BUS; VAR_7++)",
"isa_ide_init(isa_bus, ide_iobase[VAR_7], ide_iobase2[VAR_7], ide_irq[VAR_7],\nhd[MAX_IDE_DEVS * VAR_7],\nhd[MAX_IDE_DEVS * VAR_7 + 1]);",
"isa_create_simple(isa_bus, \"i8042\");",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95,
97,
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143,
145
],
[
147,
149
],
[
151,
153
],
[
155
],
[
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173,
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
189,
191
],
[
193
],
[
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
217
],
[
219
],
[
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
241
],
[
243
],
[
247
],
[
251
],
[
255
],
[
259
],
[
263,
265
],
[
269
],
[
271
],
[
273,
275,
277
],
[
281
],
[
283
]
] |
1,913 | static int write_note(struct memelfnote *men, int fd)
{
struct elf_note en;
en.n_namesz = men->namesz;
en.n_type = men->type;
en.n_descsz = men->datasz;
bswap_note(&en);
if (dump_write(fd, &en, sizeof(en)) != 0)
return (-1);
if (dump_write(fd, men->name, men->namesz_rounded) != 0)
return (-1);
if (dump_write(fd, men->data, men->datasz) != 0)
return (-1);
return (0);
}
| false | qemu | 80f5ce758ac277e76c016dd7c0b246e40d4fca2d | static int write_note(struct memelfnote *men, int fd)
{
struct elf_note en;
en.n_namesz = men->namesz;
en.n_type = men->type;
en.n_descsz = men->datasz;
bswap_note(&en);
if (dump_write(fd, &en, sizeof(en)) != 0)
return (-1);
if (dump_write(fd, men->name, men->namesz_rounded) != 0)
return (-1);
if (dump_write(fd, men->data, men->datasz) != 0)
return (-1);
return (0);
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct memelfnote *VAR_0, int VAR_1)
{
struct elf_note VAR_2;
VAR_2.n_namesz = VAR_0->namesz;
VAR_2.n_type = VAR_0->type;
VAR_2.n_descsz = VAR_0->datasz;
bswap_note(&VAR_2);
if (dump_write(VAR_1, &VAR_2, sizeof(VAR_2)) != 0)
return (-1);
if (dump_write(VAR_1, VAR_0->name, VAR_0->namesz_rounded) != 0)
return (-1);
if (dump_write(VAR_1, VAR_0->data, VAR_0->datasz) != 0)
return (-1);
return (0);
}
| [
"static int FUNC_0(struct memelfnote *VAR_0, int VAR_1)\n{",
"struct elf_note VAR_2;",
"VAR_2.n_namesz = VAR_0->namesz;",
"VAR_2.n_type = VAR_0->type;",
"VAR_2.n_descsz = VAR_0->datasz;",
"bswap_note(&VAR_2);",
"if (dump_write(VAR_1, &VAR_2, sizeof(VAR_2)) != 0)\nreturn (-1);",
"if (dump_write(VAR_1, VAR_0->name, VAR_0->namesz_rounded) != 0)\nreturn (-1);",
"if (dump_write(VAR_1, VAR_0->data, VAR_0->datasz) != 0)\nreturn (-1);",
"return (0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21,
23
],
[
25,
27
],
[
29,
31
],
[
35
],
[
37
]
] |
1,916 | static int vhost_virtqueue_start(struct vhost_dev *dev,
struct VirtIODevice *vdev,
struct vhost_virtqueue *vq,
unsigned idx)
{
hwaddr s, l, a;
int r;
int vhost_vq_index = idx - dev->vq_index;
struct vhost_vring_file file = {
.index = vhost_vq_index
};
struct vhost_vring_state state = {
.index = vhost_vq_index
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_NUM, &state);
if (r) {
return -errno;
}
state.num = virtio_queue_get_last_avail_idx(vdev, idx);
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_BASE, &state);
if (r) {
return -errno;
}
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
virtio_legacy_is_cross_endian(vdev)) {
r = vhost_virtqueue_set_vring_endian_legacy(dev,
virtio_is_big_endian(vdev),
vhost_vq_index);
if (r) {
return -errno;
}
}
s = l = virtio_queue_get_desc_size(vdev, idx);
a = virtio_queue_get_desc_addr(vdev, idx);
vq->desc = cpu_physical_memory_map(a, &l, 0);
if (!vq->desc || l != s) {
r = -ENOMEM;
goto fail_alloc_desc;
}
s = l = virtio_queue_get_avail_size(vdev, idx);
a = virtio_queue_get_avail_addr(vdev, idx);
vq->avail = cpu_physical_memory_map(a, &l, 0);
if (!vq->avail || l != s) {
r = -ENOMEM;
goto fail_alloc_avail;
}
vq->used_size = s = l = virtio_queue_get_used_size(vdev, idx);
vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx);
vq->used = cpu_physical_memory_map(a, &l, 1);
if (!vq->used || l != s) {
r = -ENOMEM;
goto fail_alloc_used;
}
vq->ring_size = s = l = virtio_queue_get_ring_size(vdev, idx);
vq->ring_phys = a = virtio_queue_get_ring_addr(vdev, idx);
vq->ring = cpu_physical_memory_map(a, &l, 1);
if (!vq->ring || l != s) {
r = -ENOMEM;
goto fail_alloc_ring;
}
r = vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabled);
if (r < 0) {
r = -errno;
goto fail_alloc;
}
file.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(vvq));
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_KICK, &file);
if (r) {
r = -errno;
goto fail_kick;
}
/* Clear and discard previous events if any. */
event_notifier_test_and_clear(&vq->masked_notifier);
return 0;
fail_kick:
fail_alloc:
cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
0, 0);
fail_alloc_ring:
cpu_physical_memory_unmap(vq->used, virtio_queue_get_used_size(vdev, idx),
0, 0);
fail_alloc_used:
cpu_physical_memory_unmap(vq->avail, virtio_queue_get_avail_size(vdev, idx),
0, 0);
fail_alloc_avail:
cpu_physical_memory_unmap(vq->desc, virtio_queue_get_desc_size(vdev, idx),
0, 0);
fail_alloc_desc:
return r;
}
| false | qemu | 95129d6fc9ead97155627a4ca0cfd37282883658 | static int vhost_virtqueue_start(struct vhost_dev *dev,
struct VirtIODevice *vdev,
struct vhost_virtqueue *vq,
unsigned idx)
{
hwaddr s, l, a;
int r;
int vhost_vq_index = idx - dev->vq_index;
struct vhost_vring_file file = {
.index = vhost_vq_index
};
struct vhost_vring_state state = {
.index = vhost_vq_index
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_NUM, &state);
if (r) {
return -errno;
}
state.num = virtio_queue_get_last_avail_idx(vdev, idx);
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_BASE, &state);
if (r) {
return -errno;
}
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) &&
virtio_legacy_is_cross_endian(vdev)) {
r = vhost_virtqueue_set_vring_endian_legacy(dev,
virtio_is_big_endian(vdev),
vhost_vq_index);
if (r) {
return -errno;
}
}
s = l = virtio_queue_get_desc_size(vdev, idx);
a = virtio_queue_get_desc_addr(vdev, idx);
vq->desc = cpu_physical_memory_map(a, &l, 0);
if (!vq->desc || l != s) {
r = -ENOMEM;
goto fail_alloc_desc;
}
s = l = virtio_queue_get_avail_size(vdev, idx);
a = virtio_queue_get_avail_addr(vdev, idx);
vq->avail = cpu_physical_memory_map(a, &l, 0);
if (!vq->avail || l != s) {
r = -ENOMEM;
goto fail_alloc_avail;
}
vq->used_size = s = l = virtio_queue_get_used_size(vdev, idx);
vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx);
vq->used = cpu_physical_memory_map(a, &l, 1);
if (!vq->used || l != s) {
r = -ENOMEM;
goto fail_alloc_used;
}
vq->ring_size = s = l = virtio_queue_get_ring_size(vdev, idx);
vq->ring_phys = a = virtio_queue_get_ring_addr(vdev, idx);
vq->ring = cpu_physical_memory_map(a, &l, 1);
if (!vq->ring || l != s) {
r = -ENOMEM;
goto fail_alloc_ring;
}
r = vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabled);
if (r < 0) {
r = -errno;
goto fail_alloc;
}
file.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(vvq));
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_KICK, &file);
if (r) {
r = -errno;
goto fail_kick;
}
event_notifier_test_and_clear(&vq->masked_notifier);
return 0;
fail_kick:
fail_alloc:
cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
0, 0);
fail_alloc_ring:
cpu_physical_memory_unmap(vq->used, virtio_queue_get_used_size(vdev, idx),
0, 0);
fail_alloc_used:
cpu_physical_memory_unmap(vq->avail, virtio_queue_get_avail_size(vdev, idx),
0, 0);
fail_alloc_avail:
cpu_physical_memory_unmap(vq->desc, virtio_queue_get_desc_size(vdev, idx),
0, 0);
fail_alloc_desc:
return r;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(struct vhost_dev *VAR_0,
struct VirtIODevice *VAR_1,
struct vhost_virtqueue *VAR_2,
unsigned VAR_3)
{
hwaddr s, l, a;
int VAR_4;
int VAR_5 = VAR_3 - VAR_0->vq_index;
struct vhost_vring_file VAR_6 = {
.index = VAR_5
};
struct vhost_vring_state VAR_7 = {
.index = VAR_5
};
struct VirtQueue *VAR_8 = virtio_get_queue(VAR_1, VAR_3);
assert(VAR_3 >= VAR_0->vq_index && VAR_3 < VAR_0->vq_index + VAR_0->nvqs);
VAR_2->num = VAR_7.num = virtio_queue_get_num(VAR_1, VAR_3);
VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_NUM, &VAR_7);
if (VAR_4) {
return -errno;
}
VAR_7.num = virtio_queue_get_last_avail_idx(VAR_1, VAR_3);
VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_BASE, &VAR_7);
if (VAR_4) {
return -errno;
}
if (!virtio_has_feature(VAR_1, VIRTIO_F_VERSION_1) &&
virtio_legacy_is_cross_endian(VAR_1)) {
VAR_4 = vhost_virtqueue_set_vring_endian_legacy(VAR_0,
virtio_is_big_endian(VAR_1),
VAR_5);
if (VAR_4) {
return -errno;
}
}
s = l = virtio_queue_get_desc_size(VAR_1, VAR_3);
a = virtio_queue_get_desc_addr(VAR_1, VAR_3);
VAR_2->desc = cpu_physical_memory_map(a, &l, 0);
if (!VAR_2->desc || l != s) {
VAR_4 = -ENOMEM;
goto fail_alloc_desc;
}
s = l = virtio_queue_get_avail_size(VAR_1, VAR_3);
a = virtio_queue_get_avail_addr(VAR_1, VAR_3);
VAR_2->avail = cpu_physical_memory_map(a, &l, 0);
if (!VAR_2->avail || l != s) {
VAR_4 = -ENOMEM;
goto fail_alloc_avail;
}
VAR_2->used_size = s = l = virtio_queue_get_used_size(VAR_1, VAR_3);
VAR_2->used_phys = a = virtio_queue_get_used_addr(VAR_1, VAR_3);
VAR_2->used = cpu_physical_memory_map(a, &l, 1);
if (!VAR_2->used || l != s) {
VAR_4 = -ENOMEM;
goto fail_alloc_used;
}
VAR_2->ring_size = s = l = virtio_queue_get_ring_size(VAR_1, VAR_3);
VAR_2->ring_phys = a = virtio_queue_get_ring_addr(VAR_1, VAR_3);
VAR_2->ring = cpu_physical_memory_map(a, &l, 1);
if (!VAR_2->ring || l != s) {
VAR_4 = -ENOMEM;
goto fail_alloc_ring;
}
VAR_4 = vhost_virtqueue_set_addr(VAR_0, VAR_2, VAR_5, VAR_0->log_enabled);
if (VAR_4 < 0) {
VAR_4 = -errno;
goto fail_alloc;
}
VAR_6.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(VAR_8));
VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_KICK, &VAR_6);
if (VAR_4) {
VAR_4 = -errno;
goto fail_kick;
}
event_notifier_test_and_clear(&VAR_2->masked_notifier);
return 0;
fail_kick:
fail_alloc:
cpu_physical_memory_unmap(VAR_2->ring, virtio_queue_get_ring_size(VAR_1, VAR_3),
0, 0);
fail_alloc_ring:
cpu_physical_memory_unmap(VAR_2->used, virtio_queue_get_used_size(VAR_1, VAR_3),
0, 0);
fail_alloc_used:
cpu_physical_memory_unmap(VAR_2->avail, virtio_queue_get_avail_size(VAR_1, VAR_3),
0, 0);
fail_alloc_avail:
cpu_physical_memory_unmap(VAR_2->desc, virtio_queue_get_desc_size(VAR_1, VAR_3),
0, 0);
fail_alloc_desc:
return VAR_4;
}
| [
"static int FUNC_0(struct vhost_dev *VAR_0,\nstruct VirtIODevice *VAR_1,\nstruct vhost_virtqueue *VAR_2,\nunsigned VAR_3)\n{",
"hwaddr s, l, a;",
"int VAR_4;",
"int VAR_5 = VAR_3 - VAR_0->vq_index;",
"struct vhost_vring_file VAR_6 = {",
".index = VAR_5\n};",
"struct vhost_vring_state VAR_7 = {",
".index = VAR_5\n};",
"struct VirtQueue *VAR_8 = virtio_get_queue(VAR_1, VAR_3);",
"assert(VAR_3 >= VAR_0->vq_index && VAR_3 < VAR_0->vq_index + VAR_0->nvqs);",
"VAR_2->num = VAR_7.num = virtio_queue_get_num(VAR_1, VAR_3);",
"VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_NUM, &VAR_7);",
"if (VAR_4) {",
"return -errno;",
"}",
"VAR_7.num = virtio_queue_get_last_avail_idx(VAR_1, VAR_3);",
"VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_BASE, &VAR_7);",
"if (VAR_4) {",
"return -errno;",
"}",
"if (!virtio_has_feature(VAR_1, VIRTIO_F_VERSION_1) &&\nvirtio_legacy_is_cross_endian(VAR_1)) {",
"VAR_4 = vhost_virtqueue_set_vring_endian_legacy(VAR_0,\nvirtio_is_big_endian(VAR_1),\nVAR_5);",
"if (VAR_4) {",
"return -errno;",
"}",
"}",
"s = l = virtio_queue_get_desc_size(VAR_1, VAR_3);",
"a = virtio_queue_get_desc_addr(VAR_1, VAR_3);",
"VAR_2->desc = cpu_physical_memory_map(a, &l, 0);",
"if (!VAR_2->desc || l != s) {",
"VAR_4 = -ENOMEM;",
"goto fail_alloc_desc;",
"}",
"s = l = virtio_queue_get_avail_size(VAR_1, VAR_3);",
"a = virtio_queue_get_avail_addr(VAR_1, VAR_3);",
"VAR_2->avail = cpu_physical_memory_map(a, &l, 0);",
"if (!VAR_2->avail || l != s) {",
"VAR_4 = -ENOMEM;",
"goto fail_alloc_avail;",
"}",
"VAR_2->used_size = s = l = virtio_queue_get_used_size(VAR_1, VAR_3);",
"VAR_2->used_phys = a = virtio_queue_get_used_addr(VAR_1, VAR_3);",
"VAR_2->used = cpu_physical_memory_map(a, &l, 1);",
"if (!VAR_2->used || l != s) {",
"VAR_4 = -ENOMEM;",
"goto fail_alloc_used;",
"}",
"VAR_2->ring_size = s = l = virtio_queue_get_ring_size(VAR_1, VAR_3);",
"VAR_2->ring_phys = a = virtio_queue_get_ring_addr(VAR_1, VAR_3);",
"VAR_2->ring = cpu_physical_memory_map(a, &l, 1);",
"if (!VAR_2->ring || l != s) {",
"VAR_4 = -ENOMEM;",
"goto fail_alloc_ring;",
"}",
"VAR_4 = vhost_virtqueue_set_addr(VAR_0, VAR_2, VAR_5, VAR_0->log_enabled);",
"if (VAR_4 < 0) {",
"VAR_4 = -errno;",
"goto fail_alloc;",
"}",
"VAR_6.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(VAR_8));",
"VAR_4 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_VRING_KICK, &VAR_6);",
"if (VAR_4) {",
"VAR_4 = -errno;",
"goto fail_kick;",
"}",
"event_notifier_test_and_clear(&VAR_2->masked_notifier);",
"return 0;",
"fail_kick:\nfail_alloc:\ncpu_physical_memory_unmap(VAR_2->ring, virtio_queue_get_ring_size(VAR_1, VAR_3),\n0, 0);",
"fail_alloc_ring:\ncpu_physical_memory_unmap(VAR_2->used, virtio_queue_get_used_size(VAR_1, VAR_3),\n0, 0);",
"fail_alloc_used:\ncpu_physical_memory_unmap(VAR_2->avail, virtio_queue_get_avail_size(VAR_1, VAR_3),\n0, 0);",
"fail_alloc_avail:\ncpu_physical_memory_unmap(VAR_2->desc, virtio_queue_get_desc_size(VAR_1, VAR_3),\n0, 0);",
"fail_alloc_desc:\nreturn VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25,
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
169
],
[
173
],
[
177,
179,
181,
183
],
[
185,
187,
189
],
[
191,
193,
195
],
[
197,
199,
201
],
[
203,
205
],
[
207
]
] |
1,918 | void vnc_client_read(void *opaque)
{
VncState *vs = opaque;
long ret;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF)
ret = vnc_client_read_sasl(vs);
else
#endif /* CONFIG_VNC_SASL */
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
ret = vnc_client_read_ws(vs);
if (ret == -1) {
vnc_disconnect_start(vs);
return;
} else if (ret == -2) {
vnc_client_error(vs);
return;
}
} else
#endif /* CONFIG_VNC_WS */
{
ret = vnc_client_read_plain(vs);
}
if (!ret) {
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return;
}
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
return;
}
if (!ret) {
buffer_advance(&vs->input, len);
} else {
vs->read_handler_expect = ret;
}
}
}
| false | qemu | 8e9b0d24fb986d4241ae3b77752eca5dab4cb486 | void vnc_client_read(void *opaque)
{
VncState *vs = opaque;
long ret;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF)
ret = vnc_client_read_sasl(vs);
else
#endif
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
ret = vnc_client_read_ws(vs);
if (ret == -1) {
vnc_disconnect_start(vs);
return;
} else if (ret == -2) {
vnc_client_error(vs);
return;
}
} else
#endif
{
ret = vnc_client_read_plain(vs);
}
if (!ret) {
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return;
}
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int ret;
ret = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
return;
}
if (!ret) {
buffer_advance(&vs->input, len);
} else {
vs->read_handler_expect = ret;
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void *VAR_0)
{
VncState *vs = VAR_0;
long VAR_2;
#ifdef CONFIG_VNC_SASL
if (vs->sasl.conn && vs->sasl.runSSF)
VAR_2 = vnc_client_read_sasl(vs);
else
#endif
#ifdef CONFIG_VNC_WS
if (vs->encode_ws) {
VAR_2 = vnc_client_read_ws(vs);
if (VAR_2 == -1) {
vnc_disconnect_start(vs);
return;
} else if (VAR_2 == -2) {
vnc_client_error(vs);
return;
}
} else
#endif
{
VAR_2 = vnc_client_read_plain(vs);
}
if (!VAR_2) {
if (vs->csock == -1)
vnc_disconnect_finish(vs);
return;
}
while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {
size_t len = vs->read_handler_expect;
int VAR_2;
VAR_2 = vs->read_handler(vs, vs->input.buffer, len);
if (vs->csock == -1) {
vnc_disconnect_finish(vs);
return;
}
if (!VAR_2) {
buffer_advance(&vs->input, len);
} else {
vs->read_handler_expect = VAR_2;
}
}
}
| [
"void FUNC_0(void *VAR_0)\n{",
"VncState *vs = VAR_0;",
"long VAR_2;",
"#ifdef CONFIG_VNC_SASL\nif (vs->sasl.conn && vs->sasl.runSSF)\nVAR_2 = vnc_client_read_sasl(vs);",
"else\n#endif\n#ifdef CONFIG_VNC_WS\nif (vs->encode_ws) {",
"VAR_2 = vnc_client_read_ws(vs);",
"if (VAR_2 == -1) {",
"vnc_disconnect_start(vs);",
"return;",
"} else if (VAR_2 == -2) {",
"vnc_client_error(vs);",
"return;",
"}",
"} else",
"#endif\n{",
"VAR_2 = vnc_client_read_plain(vs);",
"}",
"if (!VAR_2) {",
"if (vs->csock == -1)\nvnc_disconnect_finish(vs);",
"return;",
"}",
"while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {",
"size_t len = vs->read_handler_expect;",
"int VAR_2;",
"VAR_2 = vs->read_handler(vs, vs->input.buffer, len);",
"if (vs->csock == -1) {",
"vnc_disconnect_finish(vs);",
"return;",
"}",
"if (!VAR_2) {",
"buffer_advance(&vs->input, len);",
"} else {",
"vs->read_handler_expect = VAR_2;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17,
19,
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
1,919 | static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
{
int x, fmt = sono->format, w = sono->width;
uint8_t *lpy = sono->data[0] + idx * sono->linesize[0];
uint8_t *lpu = sono->data[1] + idx * sono->linesize[1];
uint8_t *lpv = sono->data[2] + idx * sono->linesize[2];
for (x = 0; x < w; x += 2) {
*lpy++ = c[x].yuv.y + 0.5f;
*lpu++ = c[x].yuv.u + 0.5f;
*lpv++ = c[x].yuv.v + 0.5f;
*lpy++ = c[x+1].yuv.y + 0.5f;
if (fmt == AV_PIX_FMT_YUV444P) {
*lpu++ = c[x+1].yuv.u + 0.5f;
*lpv++ = c[x+1].yuv.v + 0.5f;
}
}
}
| false | FFmpeg | 6df2c94130b026930d1f7148699925dcaa08759c | static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
{
int x, fmt = sono->format, w = sono->width;
uint8_t *lpy = sono->data[0] + idx * sono->linesize[0];
uint8_t *lpu = sono->data[1] + idx * sono->linesize[1];
uint8_t *lpv = sono->data[2] + idx * sono->linesize[2];
for (x = 0; x < w; x += 2) {
*lpy++ = c[x].yuv.y + 0.5f;
*lpu++ = c[x].yuv.u + 0.5f;
*lpv++ = c[x].yuv.v + 0.5f;
*lpy++ = c[x+1].yuv.y + 0.5f;
if (fmt == AV_PIX_FMT_YUV444P) {
*lpu++ = c[x+1].yuv.u + 0.5f;
*lpv++ = c[x+1].yuv.v + 0.5f;
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFrame *VAR_0, const ColorFloat *VAR_1, int VAR_2)
{
int VAR_3, VAR_4 = VAR_0->format, VAR_5 = VAR_0->width;
uint8_t *lpy = VAR_0->data[0] + VAR_2 * VAR_0->linesize[0];
uint8_t *lpu = VAR_0->data[1] + VAR_2 * VAR_0->linesize[1];
uint8_t *lpv = VAR_0->data[2] + VAR_2 * VAR_0->linesize[2];
for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3 += 2) {
*lpy++ = VAR_1[VAR_3].yuv.y + 0.5f;
*lpu++ = VAR_1[VAR_3].yuv.u + 0.5f;
*lpv++ = VAR_1[VAR_3].yuv.v + 0.5f;
*lpy++ = VAR_1[VAR_3+1].yuv.y + 0.5f;
if (VAR_4 == AV_PIX_FMT_YUV444P) {
*lpu++ = VAR_1[VAR_3+1].yuv.u + 0.5f;
*lpv++ = VAR_1[VAR_3+1].yuv.v + 0.5f;
}
}
}
| [
"static void FUNC_0(AVFrame *VAR_0, const ColorFloat *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4 = VAR_0->format, VAR_5 = VAR_0->width;",
"uint8_t *lpy = VAR_0->data[0] + VAR_2 * VAR_0->linesize[0];",
"uint8_t *lpu = VAR_0->data[1] + VAR_2 * VAR_0->linesize[1];",
"uint8_t *lpv = VAR_0->data[2] + VAR_2 * VAR_0->linesize[2];",
"for (VAR_3 = 0; VAR_3 < VAR_5; VAR_3 += 2) {",
"*lpy++ = VAR_1[VAR_3].yuv.y + 0.5f;",
"*lpu++ = VAR_1[VAR_3].yuv.u + 0.5f;",
"*lpv++ = VAR_1[VAR_3].yuv.v + 0.5f;",
"*lpy++ = VAR_1[VAR_3+1].yuv.y + 0.5f;",
"if (VAR_4 == AV_PIX_FMT_YUV444P) {",
"*lpu++ = VAR_1[VAR_3+1].yuv.u + 0.5f;",
"*lpv++ = VAR_1[VAR_3+1].yuv.v + 0.5f;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
]
] |
1,920 | static int find_pte32(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,
target_ulong sr, target_ulong eaddr, int rwx)
{
hwaddr pteg_off, pte_offset;
ppc_hash_pte32_t pte;
hwaddr hash;
uint32_t vsid, pgidx, ptem;
int ret;
ret = -1; /* No entry found */
vsid = sr & SR32_VSID;
ctx->key = (((sr & SR32_KP) && (msr_pr != 0)) ||
((sr & SR32_KS) && (msr_pr == 0))) ? 1 : 0;
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
ptem = (vsid << 7) | (pgidx >> 10);
/* Page address translation */
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
/* Primary PTEG lookup */
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " ptem=%" PRIx32
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ptem, hash);
pteg_off = get_pteg_offset32(env, hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 0, ptem, &pte);
if (pte_offset == -1) {
/* Secondary PTEG lookup */
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " api=%" PRIx32
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ptem, ~hash);
pteg_off = get_pteg_offset32(env, ~hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 1, ptem, &pte);
}
if (pte_offset != -1) {
ret = pte_check_hash32(ctx, pte.pte0, pte.pte1, rwx);
LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n",
ctx->raddr, ctx->prot, ret);
/* Update page flags */
if (ppc_hash32_pte_update_flags(ctx, &pte.pte1, ret, rwx) == 1) {
ppc_hash32_store_hpte1(env, pte_offset, pte.pte1);
}
}
return ret;
}
| false | qemu | 7f3bdc2d8e17999a26ac0f6649caef92fedfc1c0 | static int find_pte32(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,
target_ulong sr, target_ulong eaddr, int rwx)
{
hwaddr pteg_off, pte_offset;
ppc_hash_pte32_t pte;
hwaddr hash;
uint32_t vsid, pgidx, ptem;
int ret;
ret = -1;
vsid = sr & SR32_VSID;
ctx->key = (((sr & SR32_KP) && (msr_pr != 0)) ||
((sr & SR32_KS) && (msr_pr == 0))) ? 1 : 0;
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
ptem = (vsid << 7) | (pgidx >> 10);
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " ptem=%" PRIx32
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ptem, hash);
pteg_off = get_pteg_offset32(env, hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 0, ptem, &pte);
if (pte_offset == -1) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " api=%" PRIx32
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ptem, ~hash);
pteg_off = get_pteg_offset32(env, ~hash);
pte_offset = ppc_hash32_pteg_search(env, pteg_off, 1, ptem, &pte);
}
if (pte_offset != -1) {
ret = pte_check_hash32(ctx, pte.pte0, pte.pte1, rwx);
LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x ret=%d\n",
ctx->raddr, ctx->prot, ret);
if (ppc_hash32_pte_update_flags(ctx, &pte.pte1, ret, rwx) == 1) {
ppc_hash32_store_hpte1(env, pte_offset, pte.pte1);
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUPPCState *VAR_0, struct mmu_ctx_hash32 *VAR_1,
target_ulong VAR_2, target_ulong VAR_3, int VAR_4)
{
hwaddr pteg_off, pte_offset;
ppc_hash_pte32_t pte;
hwaddr hash;
uint32_t vsid, pgidx, ptem;
int VAR_5;
VAR_5 = -1;
vsid = VAR_2 & SR32_VSID;
VAR_1->key = (((VAR_2 & SR32_KP) && (msr_pr != 0)) ||
((VAR_2 & SR32_KS) && (msr_pr == 0))) ? 1 : 0;
pgidx = (VAR_3 & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
ptem = (vsid << 7) | (pgidx >> 10);
LOG_MMU("htab_base " TARGET_FMT_plx " htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, hash);
LOG_MMU("0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " ptem=%" PRIx32
" hash=" TARGET_FMT_plx "\n",
VAR_0->htab_base, VAR_0->htab_mask, vsid, ptem, hash);
pteg_off = get_pteg_offset32(VAR_0, hash);
pte_offset = ppc_hash32_pteg_search(VAR_0, pteg_off, 0, ptem, &pte);
if (pte_offset == -1) {
LOG_MMU("1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " api=%" PRIx32
" hash=" TARGET_FMT_plx "\n", VAR_0->htab_base,
VAR_0->htab_mask, vsid, ptem, ~hash);
pteg_off = get_pteg_offset32(VAR_0, ~hash);
pte_offset = ppc_hash32_pteg_search(VAR_0, pteg_off, 1, ptem, &pte);
}
if (pte_offset != -1) {
VAR_5 = pte_check_hash32(VAR_1, pte.pte0, pte.pte1, VAR_4);
LOG_MMU("found PTE at addr %08" HWADDR_PRIx " prot=%01x VAR_5=%d\n",
VAR_1->raddr, VAR_1->prot, VAR_5);
if (ppc_hash32_pte_update_flags(VAR_1, &pte.pte1, VAR_5, VAR_4) == 1) {
ppc_hash32_store_hpte1(VAR_0, pte_offset, pte.pte1);
}
}
return VAR_5;
}
| [
"static int FUNC_0(CPUPPCState *VAR_0, struct mmu_ctx_hash32 *VAR_1,\ntarget_ulong VAR_2, target_ulong VAR_3, int VAR_4)\n{",
"hwaddr pteg_off, pte_offset;",
"ppc_hash_pte32_t pte;",
"hwaddr hash;",
"uint32_t vsid, pgidx, ptem;",
"int VAR_5;",
"VAR_5 = -1;",
"vsid = VAR_2 & SR32_VSID;",
"VAR_1->key = (((VAR_2 & SR32_KP) && (msr_pr != 0)) ||\n((VAR_2 & SR32_KS) && (msr_pr == 0))) ? 1 : 0;",
"pgidx = (VAR_3 & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;",
"hash = vsid ^ pgidx;",
"ptem = (vsid << 7) | (pgidx >> 10);",
"LOG_MMU(\"htab_base \" TARGET_FMT_plx \" htab_mask \" TARGET_FMT_plx\n\" hash \" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, hash);",
"LOG_MMU(\"0 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=%\" PRIx32 \" ptem=%\" PRIx32\n\" hash=\" TARGET_FMT_plx \"\\n\",\nVAR_0->htab_base, VAR_0->htab_mask, vsid, ptem, hash);",
"pteg_off = get_pteg_offset32(VAR_0, hash);",
"pte_offset = ppc_hash32_pteg_search(VAR_0, pteg_off, 0, ptem, &pte);",
"if (pte_offset == -1) {",
"LOG_MMU(\"1 htab=\" TARGET_FMT_plx \"/\" TARGET_FMT_plx\n\" vsid=%\" PRIx32 \" api=%\" PRIx32\n\" hash=\" TARGET_FMT_plx \"\\n\", VAR_0->htab_base,\nVAR_0->htab_mask, vsid, ptem, ~hash);",
"pteg_off = get_pteg_offset32(VAR_0, ~hash);",
"pte_offset = ppc_hash32_pteg_search(VAR_0, pteg_off, 1, ptem, &pte);",
"}",
"if (pte_offset != -1) {",
"VAR_5 = pte_check_hash32(VAR_1, pte.pte0, pte.pte1, VAR_4);",
"LOG_MMU(\"found PTE at addr %08\" HWADDR_PRIx \" prot=%01x VAR_5=%d\\n\",\nVAR_1->raddr, VAR_1->prot, VAR_5);",
"if (ppc_hash32_pte_update_flags(VAR_1, &pte.pte1, VAR_5, VAR_4) == 1) {",
"ppc_hash32_store_hpte1(VAR_0, pte_offset, pte.pte1);",
"}",
"}",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
37,
39,
41
],
[
47,
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
63,
65,
67,
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
]
] |
1,921 | static void csrhci_in_packet_vendor(struct csrhci_s *s, int ocf,
uint8_t *data, int len)
{
int offset;
uint8_t *rpkt;
switch (ocf) {
case OCF_CSR_SEND_FIRMWARE:
/* Check if this is the bd_address packet */
if (len >= 18 + 8 && data[12] == 0x01 && data[13] == 0x00) {
offset = 18;
s->bd_addr.b[0] = data[offset + 7]; /* Beyond cmd packet end(!?) */
s->bd_addr.b[1] = data[offset + 6];
s->bd_addr.b[2] = data[offset + 4];
s->bd_addr.b[3] = data[offset + 0];
s->bd_addr.b[4] = data[offset + 3];
s->bd_addr.b[5] = data[offset + 2];
s->hci->bdaddr_set(s->hci, s->bd_addr.b);
fprintf(stderr, "%s: bd_address loaded from firmware: "
"%02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
s->bd_addr.b[0], s->bd_addr.b[1], s->bd_addr.b[2],
s->bd_addr.b[3], s->bd_addr.b[4], s->bd_addr.b[5]);
}
rpkt = csrhci_out_packet_event(s, EVT_VENDOR, 11);
/* Status bytes: no error */
rpkt[9] = 0x00;
rpkt[10] = 0x00;
break;
default:
fprintf(stderr, "%s: got a bad CMD packet\n", __FUNCTION__);
return;
}
csrhci_fifo_wake(s);
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static void csrhci_in_packet_vendor(struct csrhci_s *s, int ocf,
uint8_t *data, int len)
{
int offset;
uint8_t *rpkt;
switch (ocf) {
case OCF_CSR_SEND_FIRMWARE:
if (len >= 18 + 8 && data[12] == 0x01 && data[13] == 0x00) {
offset = 18;
s->bd_addr.b[0] = data[offset + 7];
s->bd_addr.b[1] = data[offset + 6];
s->bd_addr.b[2] = data[offset + 4];
s->bd_addr.b[3] = data[offset + 0];
s->bd_addr.b[4] = data[offset + 3];
s->bd_addr.b[5] = data[offset + 2];
s->hci->bdaddr_set(s->hci, s->bd_addr.b);
fprintf(stderr, "%s: bd_address loaded from firmware: "
"%02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
s->bd_addr.b[0], s->bd_addr.b[1], s->bd_addr.b[2],
s->bd_addr.b[3], s->bd_addr.b[4], s->bd_addr.b[5]);
}
rpkt = csrhci_out_packet_event(s, EVT_VENDOR, 11);
rpkt[9] = 0x00;
rpkt[10] = 0x00;
break;
default:
fprintf(stderr, "%s: got a bad CMD packet\n", __FUNCTION__);
return;
}
csrhci_fifo_wake(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct csrhci_s *VAR_0, int VAR_1,
uint8_t *VAR_2, int VAR_3)
{
int VAR_4;
uint8_t *rpkt;
switch (VAR_1) {
case OCF_CSR_SEND_FIRMWARE:
if (VAR_3 >= 18 + 8 && VAR_2[12] == 0x01 && VAR_2[13] == 0x00) {
VAR_4 = 18;
VAR_0->bd_addr.b[0] = VAR_2[VAR_4 + 7];
VAR_0->bd_addr.b[1] = VAR_2[VAR_4 + 6];
VAR_0->bd_addr.b[2] = VAR_2[VAR_4 + 4];
VAR_0->bd_addr.b[3] = VAR_2[VAR_4 + 0];
VAR_0->bd_addr.b[4] = VAR_2[VAR_4 + 3];
VAR_0->bd_addr.b[5] = VAR_2[VAR_4 + 2];
VAR_0->hci->bdaddr_set(VAR_0->hci, VAR_0->bd_addr.b);
fprintf(stderr, "%VAR_0: bd_address loaded from firmware: "
"%02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
VAR_0->bd_addr.b[0], VAR_0->bd_addr.b[1], VAR_0->bd_addr.b[2],
VAR_0->bd_addr.b[3], VAR_0->bd_addr.b[4], VAR_0->bd_addr.b[5]);
}
rpkt = csrhci_out_packet_event(VAR_0, EVT_VENDOR, 11);
rpkt[9] = 0x00;
rpkt[10] = 0x00;
break;
default:
fprintf(stderr, "%VAR_0: got a bad CMD packet\n", __FUNCTION__);
return;
}
csrhci_fifo_wake(VAR_0);
}
| [
"static void FUNC_0(struct csrhci_s *VAR_0, int VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"int VAR_4;",
"uint8_t *rpkt;",
"switch (VAR_1) {",
"case OCF_CSR_SEND_FIRMWARE:\nif (VAR_3 >= 18 + 8 && VAR_2[12] == 0x01 && VAR_2[13] == 0x00) {",
"VAR_4 = 18;",
"VAR_0->bd_addr.b[0] = VAR_2[VAR_4 + 7];",
"VAR_0->bd_addr.b[1] = VAR_2[VAR_4 + 6];",
"VAR_0->bd_addr.b[2] = VAR_2[VAR_4 + 4];",
"VAR_0->bd_addr.b[3] = VAR_2[VAR_4 + 0];",
"VAR_0->bd_addr.b[4] = VAR_2[VAR_4 + 3];",
"VAR_0->bd_addr.b[5] = VAR_2[VAR_4 + 2];",
"VAR_0->hci->bdaddr_set(VAR_0->hci, VAR_0->bd_addr.b);",
"fprintf(stderr, \"%VAR_0: bd_address loaded from firmware: \"\n\"%02x:%02x:%02x:%02x:%02x:%02x\\n\", __FUNCTION__,\nVAR_0->bd_addr.b[0], VAR_0->bd_addr.b[1], VAR_0->bd_addr.b[2],\nVAR_0->bd_addr.b[3], VAR_0->bd_addr.b[4], VAR_0->bd_addr.b[5]);",
"}",
"rpkt = csrhci_out_packet_event(VAR_0, EVT_VENDOR, 11);",
"rpkt[9] = 0x00;",
"rpkt[10] = 0x00;",
"break;",
"default:\nfprintf(stderr, \"%VAR_0: got a bad CMD packet\\n\", __FUNCTION__);",
"return;",
"}",
"csrhci_fifo_wake(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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39,
41,
43,
45
],
[
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63,
65
],
[
67
],
[
69
],
[
73
],
[
75
]
] |
1,922 | static void spapr_cpu_core_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = spapr_cpu_core_realize;
}
| false | qemu | 7ebaf7955603cc50988e0eafd5e6074320fefc70 | static void spapr_cpu_core_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = spapr_cpu_core_realize;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
dc->realize = spapr_cpu_core_realize;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"dc->realize = spapr_cpu_core_realize;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,923 | static int vnc_display_listen(VncDisplay *vd,
SocketAddressLegacy **saddr,
size_t nsaddr,
SocketAddressLegacy **wsaddr,
size_t nwsaddr,
Error **errp)
{
size_t i;
for (i = 0; i < nsaddr; i++) {
if (vnc_display_listen_addr(vd, saddr[i],
"vnc-listen",
&vd->lsock,
&vd->lsock_tag,
&vd->nlsock,
errp) < 0) {
return -1;
}
}
for (i = 0; i < nwsaddr; i++) {
if (vnc_display_listen_addr(vd, wsaddr[i],
"vnc-ws-listen",
&vd->lwebsock,
&vd->lwebsock_tag,
&vd->nlwebsock,
errp) < 0) {
return -1;
}
}
return 0;
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static int vnc_display_listen(VncDisplay *vd,
SocketAddressLegacy **saddr,
size_t nsaddr,
SocketAddressLegacy **wsaddr,
size_t nwsaddr,
Error **errp)
{
size_t i;
for (i = 0; i < nsaddr; i++) {
if (vnc_display_listen_addr(vd, saddr[i],
"vnc-listen",
&vd->lsock,
&vd->lsock_tag,
&vd->nlsock,
errp) < 0) {
return -1;
}
}
for (i = 0; i < nwsaddr; i++) {
if (vnc_display_listen_addr(vd, wsaddr[i],
"vnc-ws-listen",
&vd->lwebsock,
&vd->lwebsock_tag,
&vd->nlwebsock,
errp) < 0) {
return -1;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VncDisplay *VAR_0,
SocketAddressLegacy **VAR_1,
size_t VAR_2,
SocketAddressLegacy **VAR_3,
size_t VAR_4,
Error **VAR_5)
{
size_t i;
for (i = 0; i < VAR_2; i++) {
if (vnc_display_listen_addr(VAR_0, VAR_1[i],
"vnc-listen",
&VAR_0->lsock,
&VAR_0->lsock_tag,
&VAR_0->nlsock,
VAR_5) < 0) {
return -1;
}
}
for (i = 0; i < VAR_4; i++) {
if (vnc_display_listen_addr(VAR_0, VAR_3[i],
"vnc-ws-listen",
&VAR_0->lwebsock,
&VAR_0->lwebsock_tag,
&VAR_0->nlwebsock,
VAR_5) < 0) {
return -1;
}
}
return 0;
}
| [
"static int FUNC_0(VncDisplay *VAR_0,\nSocketAddressLegacy **VAR_1,\nsize_t VAR_2,\nSocketAddressLegacy **VAR_3,\nsize_t VAR_4,\nError **VAR_5)\n{",
"size_t i;",
"for (i = 0; i < VAR_2; i++) {",
"if (vnc_display_listen_addr(VAR_0, VAR_1[i],\n\"vnc-listen\",\n&VAR_0->lsock,\n&VAR_0->lsock_tag,\n&VAR_0->nlsock,\nVAR_5) < 0) {",
"return -1;",
"}",
"}",
"for (i = 0; i < VAR_4; i++) {",
"if (vnc_display_listen_addr(VAR_0, VAR_3[i],\n\"vnc-ws-listen\",\n&VAR_0->lwebsock,\n&VAR_0->lwebsock_tag,\n&VAR_0->nlwebsock,\nVAR_5) < 0) {",
"return -1;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
21,
23,
25,
27,
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43,
45,
47,
49,
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
1,924 | static int do_create_others(int type, struct iovec *iovec)
{
dev_t rdev;
int retval = 0;
int offset = PROXY_HDR_SZ;
V9fsString oldpath, path;
int mode, uid, gid, cur_uid, cur_gid;
v9fs_string_init(&path);
v9fs_string_init(&oldpath);
cur_uid = geteuid();
cur_gid = getegid();
retval = proxy_unmarshal(iovec, offset, "dd", &uid, &gid);
if (retval < 0) {
return retval;
}
offset += retval;
retval = setfsugid(uid, gid);
if (retval < 0) {
retval = -errno;
goto err_out;
}
switch (type) {
case T_MKNOD:
retval = proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rdev);
if (retval < 0) {
goto err_out;
}
retval = mknod(path.data, mode, rdev);
break;
case T_MKDIR:
retval = proxy_unmarshal(iovec, offset, "sd", &path, &mode);
if (retval < 0) {
goto err_out;
}
retval = mkdir(path.data, mode);
break;
case T_SYMLINK:
retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path);
if (retval < 0) {
goto err_out;
}
retval = symlink(oldpath.data, path.data);
break;
}
if (retval < 0) {
retval = -errno;
}
err_out:
v9fs_string_free(&path);
v9fs_string_free(&oldpath);
setfsugid(cur_uid, cur_gid);
return retval;
}
| false | qemu | 9fd2ecdc8cb2dc1a8a7c57b6c9c60bc9947b6a73 | static int do_create_others(int type, struct iovec *iovec)
{
dev_t rdev;
int retval = 0;
int offset = PROXY_HDR_SZ;
V9fsString oldpath, path;
int mode, uid, gid, cur_uid, cur_gid;
v9fs_string_init(&path);
v9fs_string_init(&oldpath);
cur_uid = geteuid();
cur_gid = getegid();
retval = proxy_unmarshal(iovec, offset, "dd", &uid, &gid);
if (retval < 0) {
return retval;
}
offset += retval;
retval = setfsugid(uid, gid);
if (retval < 0) {
retval = -errno;
goto err_out;
}
switch (type) {
case T_MKNOD:
retval = proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rdev);
if (retval < 0) {
goto err_out;
}
retval = mknod(path.data, mode, rdev);
break;
case T_MKDIR:
retval = proxy_unmarshal(iovec, offset, "sd", &path, &mode);
if (retval < 0) {
goto err_out;
}
retval = mkdir(path.data, mode);
break;
case T_SYMLINK:
retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path);
if (retval < 0) {
goto err_out;
}
retval = symlink(oldpath.data, path.data);
break;
}
if (retval < 0) {
retval = -errno;
}
err_out:
v9fs_string_free(&path);
v9fs_string_free(&oldpath);
setfsugid(cur_uid, cur_gid);
return retval;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, struct VAR_1 *VAR_1)
{
dev_t rdev;
int VAR_2 = 0;
int VAR_3 = PROXY_HDR_SZ;
V9fsString oldpath, path;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
v9fs_string_init(&path);
v9fs_string_init(&oldpath);
VAR_7 = geteuid();
VAR_8 = getegid();
VAR_2 = proxy_unmarshal(VAR_1, VAR_3, "dd", &VAR_5, &VAR_6);
if (VAR_2 < 0) {
return VAR_2;
}
VAR_3 += VAR_2;
VAR_2 = setfsugid(VAR_5, VAR_6);
if (VAR_2 < 0) {
VAR_2 = -errno;
goto err_out;
}
switch (VAR_0) {
case T_MKNOD:
VAR_2 = proxy_unmarshal(VAR_1, VAR_3, "sdq", &path, &VAR_4, &rdev);
if (VAR_2 < 0) {
goto err_out;
}
VAR_2 = mknod(path.data, VAR_4, rdev);
break;
case T_MKDIR:
VAR_2 = proxy_unmarshal(VAR_1, VAR_3, "sd", &path, &VAR_4);
if (VAR_2 < 0) {
goto err_out;
}
VAR_2 = mkdir(path.data, VAR_4);
break;
case T_SYMLINK:
VAR_2 = proxy_unmarshal(VAR_1, VAR_3, "ss", &oldpath, &path);
if (VAR_2 < 0) {
goto err_out;
}
VAR_2 = symlink(oldpath.data, path.data);
break;
}
if (VAR_2 < 0) {
VAR_2 = -errno;
}
err_out:
v9fs_string_free(&path);
v9fs_string_free(&oldpath);
setfsugid(VAR_7, VAR_8);
return VAR_2;
}
| [
"static int FUNC_0(int VAR_0, struct VAR_1 *VAR_1)\n{",
"dev_t rdev;",
"int VAR_2 = 0;",
"int VAR_3 = PROXY_HDR_SZ;",
"V9fsString oldpath, path;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"v9fs_string_init(&path);",
"v9fs_string_init(&oldpath);",
"VAR_7 = geteuid();",
"VAR_8 = getegid();",
"VAR_2 = proxy_unmarshal(VAR_1, VAR_3, \"dd\", &VAR_5, &VAR_6);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"VAR_3 += VAR_2;",
"VAR_2 = setfsugid(VAR_5, VAR_6);",
"if (VAR_2 < 0) {",
"VAR_2 = -errno;",
"goto err_out;",
"}",
"switch (VAR_0) {",
"case T_MKNOD:\nVAR_2 = proxy_unmarshal(VAR_1, VAR_3, \"sdq\", &path, &VAR_4, &rdev);",
"if (VAR_2 < 0) {",
"goto err_out;",
"}",
"VAR_2 = mknod(path.data, VAR_4, rdev);",
"break;",
"case T_MKDIR:\nVAR_2 = proxy_unmarshal(VAR_1, VAR_3, \"sd\", &path, &VAR_4);",
"if (VAR_2 < 0) {",
"goto err_out;",
"}",
"VAR_2 = mkdir(path.data, VAR_4);",
"break;",
"case T_SYMLINK:\nVAR_2 = proxy_unmarshal(VAR_1, VAR_3, \"ss\", &oldpath, &path);",
"if (VAR_2 < 0) {",
"goto err_out;",
"}",
"VAR_2 = symlink(oldpath.data, path.data);",
"break;",
"}",
"if (VAR_2 < 0) {",
"VAR_2 = -errno;",
"}",
"err_out:\nv9fs_string_free(&path);",
"v9fs_string_free(&oldpath);",
"setfsugid(VAR_7, VAR_8);",
"return VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
1,925 | void blockdev_auto_del(BlockDriverState *bs)
{
DriveInfo *dinfo = drive_get_by_blockdev(bs);
if (dinfo->auto_del) {
drive_uninit(dinfo);
}
}
| false | qemu | 0fc0f1fa7f86e9f1d480c6508191ca90ac10b32c | void blockdev_auto_del(BlockDriverState *bs)
{
DriveInfo *dinfo = drive_get_by_blockdev(bs);
if (dinfo->auto_del) {
drive_uninit(dinfo);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0)
{
DriveInfo *dinfo = drive_get_by_blockdev(VAR_0);
if (dinfo->auto_del) {
drive_uninit(dinfo);
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0)\n{",
"DriveInfo *dinfo = drive_get_by_blockdev(VAR_0);",
"if (dinfo->auto_del) {",
"drive_uninit(dinfo);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
1,926 | void helper_lcall_protected_T0_T1(int shift, int next_eip)
{
int new_cs, new_eip;
uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
uint32_t ss, ss_e1, ss_e2, push_size, sp, type, ss_dpl;
uint32_t old_ss, old_esp, val, i, limit;
uint8_t *ssp, *old_ssp;
new_cs = T0;
new_eip = T1;
if ((new_cs & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, new_cs) != 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
if (e2 & DESC_S_MASK) {
if (!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_CS_MASK) {
/* conforming code segment */
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
} else {
/* non conforming code segment */
rpl = new_cs & 3;
if (rpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (dpl != cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
sp = ESP;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= (4 << shift);
limit = get_seg_limit(e1, e2);
if (new_eip > limit)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
/* from this point, not restartable */
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl,
get_seg_base(e1, e2), limit, e2);
EIP = new_eip;
} else {
/* check gate type */
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch(type) {
case 1: /* available 286 TSS */
case 9: /* available 386 TSS */
case 5: /* task gate */
cpu_abort(env, "task gate not supported");
break;
case 4: /* 286 call gate */
case 12: /* 386 call gate */
break;
default:
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
break;
}
shift = type >> 3;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
rpl = new_cs & 3;
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
/* check valid bit */
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
selector = e1 >> 16;
offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);
if ((selector & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, selector) != 0)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
if (!(e2 & DESC_C_MASK) && dpl < cpl) {
/* to inner priviledge */
get_ss_esp_from_tss(&ss, &sp, dpl);
if ((ss & 0xfffc) == 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if ((ss & 3) != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, ss) != 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (ss_dpl != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
param_count = e2 & 0x1f;
push_size = ((param_count * 2) + 8) << shift;
old_esp = ESP;
old_ss = env->segs[R_SS].selector;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
old_esp &= 0xffff;
old_ssp = env->segs[R_SS].base + old_esp;
/* XXX: from this point not restartable */
ss = (ss & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss,
get_seg_base(ss_e1, ss_e2),
get_seg_limit(ss_e1, ss_e2),
ss_e2);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, old_ss);
ssp -= 4;
stl_kernel(ssp, old_esp);
ssp -= 4 * param_count;
for(i = 0; i < param_count; i++) {
val = ldl_kernel(old_ssp + i * 4);
stl_kernel(ssp + i * 4, val);
}
} else {
ssp -= 2;
stw_kernel(ssp, old_ss);
ssp -= 2;
stw_kernel(ssp, old_esp);
ssp -= 2 * param_count;
for(i = 0; i < param_count; i++) {
val = lduw_kernel(old_ssp + i * 2);
stw_kernel(ssp + i * 2, val);
}
}
} else {
/* to same priviledge */
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
push_size = (4 << shift);
}
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= push_size;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_set_cpl(env, dpl);
/* from this point, not restartable if same priviledge */
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
EIP = offset;
}
}
| false | qemu | 7e84c2498f0ff3999937d18d1e9abaa030400000 | void helper_lcall_protected_T0_T1(int shift, int next_eip)
{
int new_cs, new_eip;
uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
uint32_t ss, ss_e1, ss_e2, push_size, sp, type, ss_dpl;
uint32_t old_ss, old_esp, val, i, limit;
uint8_t *ssp, *old_ssp;
new_cs = T0;
new_eip = T1;
if ((new_cs & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, new_cs) != 0)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
if (e2 & DESC_S_MASK) {
if (!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_CS_MASK) {
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
} else {
rpl = new_cs & 3;
if (rpl > cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (dpl != cpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
sp = ESP;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= (4 << shift);
limit = get_seg_limit(e1, e2);
if (new_eip > limit)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl,
get_seg_base(e1, e2), limit, e2);
EIP = new_eip;
} else {
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch(type) {
case 1:
case 9:
case 5:
cpu_abort(env, "task gate not supported");
break;
case 4:
case 12:
break;
default:
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
break;
}
shift = type >> 3;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
rpl = new_cs & 3;
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc);
selector = e1 >> 16;
offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);
if ((selector & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, selector) != 0)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
if (!(e2 & DESC_C_MASK) && dpl < cpl) {
get_ss_esp_from_tss(&ss, &sp, dpl);
if ((ss & 0xfffc) == 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if ((ss & 3) != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, ss) != 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (ss_dpl != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
param_count = e2 & 0x1f;
push_size = ((param_count * 2) + 8) << shift;
old_esp = ESP;
old_ss = env->segs[R_SS].selector;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
old_esp &= 0xffff;
old_ssp = env->segs[R_SS].base + old_esp;
ss = (ss & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss,
get_seg_base(ss_e1, ss_e2),
get_seg_limit(ss_e1, ss_e2),
ss_e2);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (shift) {
ssp -= 4;
stl_kernel(ssp, old_ss);
ssp -= 4;
stl_kernel(ssp, old_esp);
ssp -= 4 * param_count;
for(i = 0; i < param_count; i++) {
val = ldl_kernel(old_ssp + i * 4);
stl_kernel(ssp + i * 4, val);
}
} else {
ssp -= 2;
stw_kernel(ssp, old_ss);
ssp -= 2;
stw_kernel(ssp, old_esp);
ssp -= 2 * param_count;
for(i = 0; i < param_count; i++) {
val = lduw_kernel(old_ssp + i * 2);
stw_kernel(ssp + i * 2, val);
}
}
} else {
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
push_size = (4 << shift);
}
if (shift) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, next_eip);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, next_eip);
}
sp -= push_size;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_set_cpl(env, dpl);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
EIP = offset;
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0, int VAR_1)
{
int VAR_2, VAR_3;
uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
uint32_t ss, ss_e1, ss_e2, push_size, sp, type, ss_dpl;
uint32_t old_ss, old_esp, val, i, limit;
uint8_t *ssp, *old_ssp;
VAR_2 = T0;
VAR_3 = T1;
if ((VAR_2 & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, VAR_2) != 0)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
cpl = env->hflags & HF_CPL_MASK;
if (e2 & DESC_S_MASK) {
if (!(e2 & DESC_CS_MASK))
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (e2 & DESC_CS_MASK) {
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
} else {
rpl = VAR_2 & 3;
if (rpl > cpl)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
if (dpl != cpl)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
}
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, VAR_2 & 0xfffc);
sp = ESP;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (VAR_0) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, VAR_1);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, VAR_1);
}
sp -= (4 << VAR_0);
limit = get_seg_limit(e1, e2);
if (VAR_3 > limit)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
cpu_x86_load_seg_cache(env, R_CS, (VAR_2 & 0xfffc) | cpl,
get_seg_base(e1, e2), limit, e2);
EIP = VAR_3;
} else {
type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;
switch(type) {
case 1:
case 9:
case 5:
cpu_abort(env, "task gate not supported");
break;
case 4:
case 12:
break;
default:
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
break;
}
VAR_0 = type >> 3;
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
rpl = VAR_2 & 3;
if (dpl < cpl || dpl < rpl)
raise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, VAR_2 & 0xfffc);
selector = e1 >> 16;
offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);
if ((selector & 0xfffc) == 0)
raise_exception_err(EXCP0D_GPF, 0);
if (load_segment(&e1, &e2, selector) != 0)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
dpl = (e2 >> DESC_DPL_SHIFT) & 3;
if (dpl > cpl)
raise_exception_err(EXCP0D_GPF, selector & 0xfffc);
if (!(e2 & DESC_P_MASK))
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);
if (!(e2 & DESC_C_MASK) && dpl < cpl) {
get_ss_esp_from_tss(&ss, &sp, dpl);
if ((ss & 0xfffc) == 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if ((ss & 3) != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (load_segment(&ss_e1, &ss_e2, ss) != 0)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;
if (ss_dpl != dpl)
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_S_MASK) ||
(ss_e2 & DESC_CS_MASK) ||
!(ss_e2 & DESC_W_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
if (!(ss_e2 & DESC_P_MASK))
raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
param_count = e2 & 0x1f;
push_size = ((param_count * 2) + 8) << VAR_0;
old_esp = ESP;
old_ss = env->segs[R_SS].selector;
if (!(env->segs[R_SS].flags & DESC_B_MASK))
old_esp &= 0xffff;
old_ssp = env->segs[R_SS].base + old_esp;
ss = (ss & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_SS, ss,
get_seg_base(ss_e1, ss_e2),
get_seg_limit(ss_e1, ss_e2),
ss_e2);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
if (VAR_0) {
ssp -= 4;
stl_kernel(ssp, old_ss);
ssp -= 4;
stl_kernel(ssp, old_esp);
ssp -= 4 * param_count;
for(i = 0; i < param_count; i++) {
val = ldl_kernel(old_ssp + i * 4);
stl_kernel(ssp + i * 4, val);
}
} else {
ssp -= 2;
stw_kernel(ssp, old_ss);
ssp -= 2;
stw_kernel(ssp, old_esp);
ssp -= 2 * param_count;
for(i = 0; i < param_count; i++) {
val = lduw_kernel(old_ssp + i * 2);
stw_kernel(ssp + i * 2, val);
}
}
} else {
if (!(env->segs[R_SS].flags & DESC_B_MASK))
sp &= 0xffff;
ssp = env->segs[R_SS].base + sp;
push_size = (4 << VAR_0);
}
if (VAR_0) {
ssp -= 4;
stl_kernel(ssp, env->segs[R_CS].selector);
ssp -= 4;
stl_kernel(ssp, VAR_1);
} else {
ssp -= 2;
stw_kernel(ssp, env->segs[R_CS].selector);
ssp -= 2;
stw_kernel(ssp, VAR_1);
}
sp -= push_size;
selector = (selector & ~3) | dpl;
cpu_x86_load_seg_cache(env, R_CS, selector,
get_seg_base(e1, e2),
get_seg_limit(e1, e2),
e2);
cpu_x86_set_cpl(env, dpl);
if (!(env->segs[R_SS].flags & DESC_B_MASK))
ESP = (ESP & 0xffff0000) | (sp & 0xffff);
else
ESP = sp;
EIP = offset;
}
}
| [
"void FUNC_0(int VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3;",
"uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;",
"uint32_t ss, ss_e1, ss_e2, push_size, sp, type, ss_dpl;",
"uint32_t old_ss, old_esp, val, i, limit;",
"uint8_t *ssp, *old_ssp;",
"VAR_2 = T0;",
"VAR_3 = T1;",
"if ((VAR_2 & 0xfffc) == 0)\nraise_exception_err(EXCP0D_GPF, 0);",
"if (load_segment(&e1, &e2, VAR_2) != 0)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"cpl = env->hflags & HF_CPL_MASK;",
"if (e2 & DESC_S_MASK) {",
"if (!(e2 & DESC_CS_MASK))\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"dpl = (e2 >> DESC_DPL_SHIFT) & 3;",
"if (e2 & DESC_CS_MASK) {",
"if (dpl > cpl)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"} else {",
"rpl = VAR_2 & 3;",
"if (rpl > cpl)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"if (dpl != cpl)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"}",
"if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, VAR_2 & 0xfffc);",
"sp = ESP;",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nsp &= 0xffff;",
"ssp = env->segs[R_SS].base + sp;",
"if (VAR_0) {",
"ssp -= 4;",
"stl_kernel(ssp, env->segs[R_CS].selector);",
"ssp -= 4;",
"stl_kernel(ssp, VAR_1);",
"} else {",
"ssp -= 2;",
"stw_kernel(ssp, env->segs[R_CS].selector);",
"ssp -= 2;",
"stw_kernel(ssp, VAR_1);",
"}",
"sp -= (4 << VAR_0);",
"limit = get_seg_limit(e1, e2);",
"if (VAR_3 > limit)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nESP = (ESP & 0xffff0000) | (sp & 0xffff);",
"else\nESP = sp;",
"cpu_x86_load_seg_cache(env, R_CS, (VAR_2 & 0xfffc) | cpl,\nget_seg_base(e1, e2), limit, e2);",
"EIP = VAR_3;",
"} else {",
"type = (e2 >> DESC_TYPE_SHIFT) & 0x1f;",
"switch(type) {",
"case 1:\ncase 9:\ncase 5:\ncpu_abort(env, \"task gate not supported\");",
"break;",
"case 4:\ncase 12:\nbreak;",
"default:\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"break;",
"}",
"VAR_0 = type >> 3;",
"dpl = (e2 >> DESC_DPL_SHIFT) & 3;",
"rpl = VAR_2 & 3;",
"if (dpl < cpl || dpl < rpl)\nraise_exception_err(EXCP0D_GPF, VAR_2 & 0xfffc);",
"if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, VAR_2 & 0xfffc);",
"selector = e1 >> 16;",
"offset = (e2 & 0xffff0000) | (e1 & 0x0000ffff);",
"if ((selector & 0xfffc) == 0)\nraise_exception_err(EXCP0D_GPF, 0);",
"if (load_segment(&e1, &e2, selector) != 0)\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);",
"if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK)))\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);",
"dpl = (e2 >> DESC_DPL_SHIFT) & 3;",
"if (dpl > cpl)\nraise_exception_err(EXCP0D_GPF, selector & 0xfffc);",
"if (!(e2 & DESC_P_MASK))\nraise_exception_err(EXCP0B_NOSEG, selector & 0xfffc);",
"if (!(e2 & DESC_C_MASK) && dpl < cpl) {",
"get_ss_esp_from_tss(&ss, &sp, dpl);",
"if ((ss & 0xfffc) == 0)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"if ((ss & 3) != dpl)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"if (load_segment(&ss_e1, &ss_e2, ss) != 0)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"ss_dpl = (ss_e2 >> DESC_DPL_SHIFT) & 3;",
"if (ss_dpl != dpl)\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"if (!(ss_e2 & DESC_S_MASK) ||\n(ss_e2 & DESC_CS_MASK) ||\n!(ss_e2 & DESC_W_MASK))\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"if (!(ss_e2 & DESC_P_MASK))\nraise_exception_err(EXCP0A_TSS, ss & 0xfffc);",
"param_count = e2 & 0x1f;",
"push_size = ((param_count * 2) + 8) << VAR_0;",
"old_esp = ESP;",
"old_ss = env->segs[R_SS].selector;",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nold_esp &= 0xffff;",
"old_ssp = env->segs[R_SS].base + old_esp;",
"ss = (ss & ~3) | dpl;",
"cpu_x86_load_seg_cache(env, R_SS, ss,\nget_seg_base(ss_e1, ss_e2),\nget_seg_limit(ss_e1, ss_e2),\nss_e2);",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nsp &= 0xffff;",
"ssp = env->segs[R_SS].base + sp;",
"if (VAR_0) {",
"ssp -= 4;",
"stl_kernel(ssp, old_ss);",
"ssp -= 4;",
"stl_kernel(ssp, old_esp);",
"ssp -= 4 * param_count;",
"for(i = 0; i < param_count; i++) {",
"val = ldl_kernel(old_ssp + i * 4);",
"stl_kernel(ssp + i * 4, val);",
"}",
"} else {",
"ssp -= 2;",
"stw_kernel(ssp, old_ss);",
"ssp -= 2;",
"stw_kernel(ssp, old_esp);",
"ssp -= 2 * param_count;",
"for(i = 0; i < param_count; i++) {",
"val = lduw_kernel(old_ssp + i * 2);",
"stw_kernel(ssp + i * 2, val);",
"}",
"}",
"} else {",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nsp &= 0xffff;",
"ssp = env->segs[R_SS].base + sp;",
"push_size = (4 << VAR_0);",
"}",
"if (VAR_0) {",
"ssp -= 4;",
"stl_kernel(ssp, env->segs[R_CS].selector);",
"ssp -= 4;",
"stl_kernel(ssp, VAR_1);",
"} else {",
"ssp -= 2;",
"stw_kernel(ssp, env->segs[R_CS].selector);",
"ssp -= 2;",
"stw_kernel(ssp, VAR_1);",
"}",
"sp -= push_size;",
"selector = (selector & ~3) | dpl;",
"cpu_x86_load_seg_cache(env, R_CS, selector,\nget_seg_base(e1, e2),\nget_seg_limit(e1, e2),\ne2);",
"cpu_x86_set_cpl(env, dpl);",
"if (!(env->segs[R_SS].flags & DESC_B_MASK))\nESP = (ESP & 0xffff0000) | (sp & 0xffff);",
"else\nESP = sp;",
"EIP = offset;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
43,
45
],
[
47
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105,
107
],
[
111,
113
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133,
135,
137,
139
],
[
141
],
[
143,
145,
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165,
167
],
[
171,
173
],
[
175
],
[
177
],
[
179,
181
],
[
185,
187
],
[
189,
191
],
[
193
],
[
195,
197
],
[
199,
201
],
[
205
],
[
209
],
[
211,
213
],
[
215,
217
],
[
219,
221
],
[
223
],
[
225,
227
],
[
229,
231,
233,
235
],
[
237,
239
],
[
243
],
[
245
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
263
],
[
265,
267,
269,
271
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
363
],
[
365
],
[
367,
369,
371,
373
],
[
375
],
[
381,
383
],
[
385,
387
],
[
389
],
[
391
],
[
393
]
] |
1,927 | static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
{
NVICState *s = NVIC(dev);
SysBusDevice *systick_sbd;
Error *err = NULL;
s->cpu = ARM_CPU(qemu_get_cpu(0));
assert(s->cpu);
if (s->num_irq > NVIC_MAX_IRQ) {
error_setg(errp, "num-irq %d exceeds NVIC maximum", s->num_irq);
return;
}
qdev_init_gpio_in(dev, set_irq_level, s->num_irq);
/* include space for internal exception vectors */
s->num_irq += NVIC_FIRST_IRQ;
object_property_set_bool(OBJECT(&s->systick), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
systick_sbd = SYS_BUS_DEVICE(&s->systick);
sysbus_connect_irq(systick_sbd, 0,
qdev_get_gpio_in_named(dev, "systick-trigger", 0));
/* The NVIC and System Control Space (SCS) starts at 0xe000e000
* and looks like this:
* 0x004 - ICTR
* 0x010 - 0xff - systick
* 0x100..0x7ec - NVIC
* 0x7f0..0xcff - Reserved
* 0xd00..0xd3c - SCS registers
* 0xd40..0xeff - Reserved or Not implemented
* 0xf00 - STIR
*/
memory_region_init(&s->container, OBJECT(s), "nvic", 0x1000);
/* The system register region goes at the bottom of the priority
* stack as it covers the whole page.
*/
memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s,
"nvic_sysregs", 0x1000);
memory_region_add_subregion(&s->container, 0, &s->sysregmem);
memory_region_add_subregion_overlap(&s->container, 0x10,
sysbus_mmio_get_region(systick_sbd, 0),
1);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container);
}
| false | qemu | f104919d15a3f0be57a70b5499bc9fa5e06224fd | static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
{
NVICState *s = NVIC(dev);
SysBusDevice *systick_sbd;
Error *err = NULL;
s->cpu = ARM_CPU(qemu_get_cpu(0));
assert(s->cpu);
if (s->num_irq > NVIC_MAX_IRQ) {
error_setg(errp, "num-irq %d exceeds NVIC maximum", s->num_irq);
return;
}
qdev_init_gpio_in(dev, set_irq_level, s->num_irq);
s->num_irq += NVIC_FIRST_IRQ;
object_property_set_bool(OBJECT(&s->systick), true, "realized", &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
systick_sbd = SYS_BUS_DEVICE(&s->systick);
sysbus_connect_irq(systick_sbd, 0,
qdev_get_gpio_in_named(dev, "systick-trigger", 0));
memory_region_init(&s->container, OBJECT(s), "nvic", 0x1000);
memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s,
"nvic_sysregs", 0x1000);
memory_region_add_subregion(&s->container, 0, &s->sysregmem);
memory_region_add_subregion_overlap(&s->container, 0x10,
sysbus_mmio_get_region(systick_sbd, 0),
1);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
NVICState *s = NVIC(VAR_0);
SysBusDevice *systick_sbd;
Error *err = NULL;
s->cpu = ARM_CPU(qemu_get_cpu(0));
assert(s->cpu);
if (s->num_irq > NVIC_MAX_IRQ) {
error_setg(VAR_1, "num-irq %d exceeds NVIC maximum", s->num_irq);
return;
}
qdev_init_gpio_in(VAR_0, set_irq_level, s->num_irq);
s->num_irq += NVIC_FIRST_IRQ;
object_property_set_bool(OBJECT(&s->systick), true, "realized", &err);
if (err != NULL) {
error_propagate(VAR_1, err);
return;
}
systick_sbd = SYS_BUS_DEVICE(&s->systick);
sysbus_connect_irq(systick_sbd, 0,
qdev_get_gpio_in_named(VAR_0, "systick-trigger", 0));
memory_region_init(&s->container, OBJECT(s), "nvic", 0x1000);
memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s,
"nvic_sysregs", 0x1000);
memory_region_add_subregion(&s->container, 0, &s->sysregmem);
memory_region_add_subregion_overlap(&s->container, 0x10,
sysbus_mmio_get_region(systick_sbd, 0),
1);
sysbus_init_mmio(SYS_BUS_DEVICE(VAR_0), &s->container);
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"NVICState *s = NVIC(VAR_0);",
"SysBusDevice *systick_sbd;",
"Error *err = NULL;",
"s->cpu = ARM_CPU(qemu_get_cpu(0));",
"assert(s->cpu);",
"if (s->num_irq > NVIC_MAX_IRQ) {",
"error_setg(VAR_1, \"num-irq %d exceeds NVIC maximum\", s->num_irq);",
"return;",
"}",
"qdev_init_gpio_in(VAR_0, set_irq_level, s->num_irq);",
"s->num_irq += NVIC_FIRST_IRQ;",
"object_property_set_bool(OBJECT(&s->systick), true, \"realized\", &err);",
"if (err != NULL) {",
"error_propagate(VAR_1, err);",
"return;",
"}",
"systick_sbd = SYS_BUS_DEVICE(&s->systick);",
"sysbus_connect_irq(systick_sbd, 0,\nqdev_get_gpio_in_named(VAR_0, \"systick-trigger\", 0));",
"memory_region_init(&s->container, OBJECT(s), \"nvic\", 0x1000);",
"memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s,\n\"nvic_sysregs\", 0x1000);",
"memory_region_add_subregion(&s->container, 0, &s->sysregmem);",
"memory_region_add_subregion_overlap(&s->container, 0x10,\nsysbus_mmio_get_region(systick_sbd, 0),\n1);",
"sysbus_init_mmio(SYS_BUS_DEVICE(VAR_0), &s->container);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
77
],
[
85,
87
],
[
89
],
[
91,
93,
95
],
[
99
],
[
101
]
] |
1,928 | static int nprobe(AVFormatContext *s, uint8_t *enc_header, const uint8_t *n_val)
{
OMAContext *oc = s->priv_data;
uint32_t pos, taglen, datalen;
struct AVDES av_des;
if (!enc_header || !n_val)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&enc_header[pos], "EKB ", 4))
pos += 32;
if (AV_RB32(&enc_header[pos]) != oc->rid)
av_log(s, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&enc_header[pos+32]);
datalen = AV_RB32(&enc_header[pos+36]) >> 4;
pos += 44 + taglen;
av_des_init(&av_des, n_val, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
kset(s, oc->r_val, NULL, 16);
if (!rprobe(s, enc_header, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| true | FFmpeg | 72ec043af4510723c53c729a67be482a14b7c7f3 | static int nprobe(AVFormatContext *s, uint8_t *enc_header, const uint8_t *n_val)
{
OMAContext *oc = s->priv_data;
uint32_t pos, taglen, datalen;
struct AVDES av_des;
if (!enc_header || !n_val)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&enc_header[pos], "EKB ", 4))
pos += 32;
if (AV_RB32(&enc_header[pos]) != oc->rid)
av_log(s, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&enc_header[pos+32]);
datalen = AV_RB32(&enc_header[pos+36]) >> 4;
pos += 44 + taglen;
av_des_init(&av_des, n_val, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1);
kset(s, oc->r_val, NULL, 16);
if (!rprobe(s, enc_header, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| {
"code": [
"static int nprobe(AVFormatContext *s, uint8_t *enc_header, const uint8_t *n_val)"
],
"line_no": [
1
]
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, const uint8_t *VAR_2)
{
OMAContext *oc = VAR_0->priv_data;
uint32_t pos, taglen, datalen;
struct AVDES VAR_3;
if (!VAR_1 || !VAR_2)
return -1;
pos = OMA_ENC_HEADER_SIZE + oc->k_size;
if (!memcmp(&VAR_1[pos], "EKB ", 4))
pos += 32;
if (AV_RB32(&VAR_1[pos]) != oc->rid)
av_log(VAR_0, AV_LOG_DEBUG, "Mismatching RID\n");
taglen = AV_RB32(&VAR_1[pos+32]);
datalen = AV_RB32(&VAR_1[pos+36]) >> 4;
pos += 44 + taglen;
av_des_init(&VAR_3, VAR_2, 192, 1);
while (datalen-- > 0) {
av_des_crypt(&VAR_3, oc->r_val, &VAR_1[pos], 2, NULL, 1);
kset(VAR_0, oc->r_val, NULL, 16);
if (!rprobe(VAR_0, VAR_1, oc->r_val))
return 0;
pos += 16;
}
return -1;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, const uint8_t *VAR_2)\n{",
"OMAContext *oc = VAR_0->priv_data;",
"uint32_t pos, taglen, datalen;",
"struct AVDES VAR_3;",
"if (!VAR_1 || !VAR_2)\nreturn -1;",
"pos = OMA_ENC_HEADER_SIZE + oc->k_size;",
"if (!memcmp(&VAR_1[pos], \"EKB \", 4))\npos += 32;",
"if (AV_RB32(&VAR_1[pos]) != oc->rid)\nav_log(VAR_0, AV_LOG_DEBUG, \"Mismatching RID\\n\");",
"taglen = AV_RB32(&VAR_1[pos+32]);",
"datalen = AV_RB32(&VAR_1[pos+36]) >> 4;",
"pos += 44 + taglen;",
"av_des_init(&VAR_3, VAR_2, 192, 1);",
"while (datalen-- > 0) {",
"av_des_crypt(&VAR_3, oc->r_val, &VAR_1[pos], 2, NULL, 1);",
"kset(VAR_0, oc->r_val, NULL, 16);",
"if (!rprobe(VAR_0, VAR_1, oc->r_val))\nreturn 0;",
"pos += 16;",
"}",
"return -1;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21,
23
],
[
27,
29
],
[
33
],
[
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
1,929 | static gboolean nbd_negotiate_continue(QIOChannel *ioc,
GIOCondition condition,
void *opaque)
{
qemu_coroutine_enter(opaque, NULL);
return TRUE;
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static gboolean nbd_negotiate_continue(QIOChannel *ioc,
GIOCondition condition,
void *opaque)
{
qemu_coroutine_enter(opaque, NULL);
return TRUE;
}
| {
"code": [
" qemu_coroutine_enter(opaque, NULL);"
],
"line_no": [
9
]
} | static gboolean FUNC_0(QIOChannel *ioc,
GIOCondition condition,
void *opaque)
{
qemu_coroutine_enter(opaque, NULL);
return TRUE;
}
| [
"static gboolean FUNC_0(QIOChannel *ioc,\nGIOCondition condition,\nvoid *opaque)\n{",
"qemu_coroutine_enter(opaque, NULL);",
"return TRUE;",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
]
] |
1,930 | void object_add(const char *type, const char *id, const QDict *qdict,
Visitor *v, Error **errp)
{
Object *obj;
const QDictEntry *e;
Error *local_err = NULL;
if (!object_class_by_name(type)) {
error_setg(errp, "invalid class name");
return;
}
obj = object_new(type);
if (qdict) {
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
object_property_set(obj, v, e->key, &local_err);
if (local_err) {
goto out;
}
}
}
if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
error_setg(&local_err, "object type '%s' isn't supported by object-add",
type);
goto out;
}
user_creatable_complete(obj, &local_err);
if (local_err) {
goto out;
}
object_property_add_child(container_get(object_get_root(), "/objects"),
id, obj, &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
}
object_unref(obj);
}
| true | qemu | c3481247e58ff3f13337ce0a262b058799bd156c | void object_add(const char *type, const char *id, const QDict *qdict,
Visitor *v, Error **errp)
{
Object *obj;
const QDictEntry *e;
Error *local_err = NULL;
if (!object_class_by_name(type)) {
error_setg(errp, "invalid class name");
return;
}
obj = object_new(type);
if (qdict) {
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
object_property_set(obj, v, e->key, &local_err);
if (local_err) {
goto out;
}
}
}
if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
error_setg(&local_err, "object type '%s' isn't supported by object-add",
type);
goto out;
}
user_creatable_complete(obj, &local_err);
if (local_err) {
goto out;
}
object_property_add_child(container_get(object_get_root(), "/objects"),
id, obj, &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
}
object_unref(obj);
}
| {
"code": [
" if (!object_class_by_name(type)) {",
" if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {",
" error_setg(&local_err, \"object type '%s' isn't supported by object-add\",",
" type);",
" goto out;"
],
"line_no": [
15,
45,
47,
49,
51
]
} | void FUNC_0(const char *VAR_0, const char *VAR_1, const QDict *VAR_2,
Visitor *VAR_3, Error **VAR_4)
{
Object *obj;
const QDictEntry *VAR_5;
Error *local_err = NULL;
if (!object_class_by_name(VAR_0)) {
error_setg(VAR_4, "invalid class name");
return;
}
obj = object_new(VAR_0);
if (VAR_2) {
for (VAR_5 = qdict_first(VAR_2); VAR_5; VAR_5 = qdict_next(VAR_2, VAR_5)) {
object_property_set(obj, VAR_3, VAR_5->key, &local_err);
if (local_err) {
goto out;
}
}
}
if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
error_setg(&local_err, "object VAR_0 '%s' isn't supported by object-add",
VAR_0);
goto out;
}
user_creatable_complete(obj, &local_err);
if (local_err) {
goto out;
}
object_property_add_child(container_get(object_get_root(), "/objects"),
VAR_1, obj, &local_err);
out:
if (local_err) {
error_propagate(VAR_4, local_err);
}
object_unref(obj);
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1, const QDict *VAR_2,\nVisitor *VAR_3, Error **VAR_4)\n{",
"Object *obj;",
"const QDictEntry *VAR_5;",
"Error *local_err = NULL;",
"if (!object_class_by_name(VAR_0)) {",
"error_setg(VAR_4, \"invalid class name\");",
"return;",
"}",
"obj = object_new(VAR_0);",
"if (VAR_2) {",
"for (VAR_5 = qdict_first(VAR_2); VAR_5; VAR_5 = qdict_next(VAR_2, VAR_5)) {",
"object_property_set(obj, VAR_3, VAR_5->key, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"}",
"}",
"if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {",
"error_setg(&local_err, \"object VAR_0 '%s' isn't supported by object-add\",\nVAR_0);",
"goto out;",
"}",
"user_creatable_complete(obj, &local_err);",
"if (local_err) {",
"goto out;",
"}",
"object_property_add_child(container_get(object_get_root(), \"/objects\"),\nVAR_1, obj, &local_err);",
"out:\nif (local_err) {",
"error_propagate(VAR_4, local_err);",
"}",
"object_unref(obj);",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
]
] |
1,931 | static int create_filtergraph(AVFilterContext *ctx,
const AVFrame *in, const AVFrame *out)
{
ColorSpaceContext *s = ctx->priv;
const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in->format);
const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(in_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\n",
in->format, av_get_pix_fmt_name(in->format),
in_desc ? in_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(out_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\n",
out->format, av_get_pix_fmt_name(out->format),
out_desc ? out_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (in->color_primaries != s->in_prm) s->in_primaries = NULL;
if (out->color_primaries != s->out_prm) s->out_primaries = NULL;
if (in->color_trc != s->in_trc) s->in_txchr = NULL;
if (out->color_trc != s->out_trc) s->out_txchr = NULL;
if (in->colorspace != s->in_csp ||
in->color_range != s->in_rng) s->in_lumacoef = NULL;
if (out->colorspace != s->out_csp ||
out->color_range != s->out_rng) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = in->color_primaries;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\n",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = out->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR, "Please specify output primaries\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\n",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
fill_rgb2xyz_table(s->out_primaries, rgb2xyz);
invert_matrix3x3(rgb2xyz, xyz2rgb);
fill_rgb2xyz_table(s->in_primaries, rgb2xyz);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double wpconv[3][3], tmp[3][3];
fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(tmp, rgb2xyz, wpconv);
mul3x3(rgb2rgb, tmp, xyz2rgb);
} else {
mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
}
for (m = 0; m < 3; m++)
for (n = 0; n < 3; n++) {
s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]);
for (o = 1; o < 8; o++)
s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0];
}
emms = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = in->color_trc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\n",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = out->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
res = fill_gamma_table(s);
if (res < 0)
return res;
emms = 1;
}
if (!s->in_lumacoef) {
s->in_csp = in->colorspace;
s->in_rng = in->color_range;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\n",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
redo_yuv2rgb = 1;
}
if (!s->out_lumacoef) {
s->out_csp = out->colorspace;
s->out_rng = out->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
redo_rgb2yuv = 1;
}
fmt_identical = in_desc->log2_chroma_h == out_desc->log2_chroma_h &&
in_desc->log2_chroma_w == out_desc->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && fmt_identical;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->in_rng == s->out_rng &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef));
if (!s->yuv2yuv_passthrough) {
if (redo_yuv2rgb) {
double rgb2yuv[3][3], (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
int off, bits, in_rng;
res = get_range_off(&off, &s->in_y_rng, &s->in_uv_rng,
s->in_rng, in_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\n",
s->in_rng, av_color_range_name(s->in_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[0][n] = off;
fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv);
invert_matrix3x3(rgb2yuv, yuv2rgb);
bits = 1 << (in_desc->comp[0].depth - 1);
for (n = 0; n < 3; n++) {
for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
s->yuv2rgb_coeffs[n][m][0] = lrint(28672 * bits * yuv2rgb[n][m] / in_rng);
for (o = 1; o < 8; o++)
s->yuv2rgb_coeffs[n][m][o] = s->yuv2rgb_coeffs[n][m][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
emms = 1;
}
if (redo_rgb2yuv) {
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
int off, out_rng, bits;
res = get_range_off(&off, &s->out_y_rng, &s->out_uv_rng,
s->out_rng, out_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\n",
s->out_rng, av_color_range_name(s->out_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[1][n] = off;
fill_rgb2yuv_table(s->out_lumacoef, rgb2yuv);
bits = 1 << (29 - out_desc->comp[0].depth);
for (out_rng = s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
for (m = 0; m < 3; m++) {
s->rgb2yuv_coeffs[n][m][0] = lrint(bits * out_rng * rgb2yuv[n][m] / 28672);
for (o = 1; o < 8; o++)
s->rgb2yuv_coeffs[n][m][o] = s->rgb2yuv_coeffs[n][m][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->rgb2yuv = s->dsp.rgb2yuv[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
emms = 1;
}
if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
int idepth = in_desc->comp[0].depth, odepth = out_desc->comp[0].depth;
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
double (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
double yuv2yuv[3][3];
int in_rng, out_rng;
mul3x3(yuv2yuv, yuv2rgb, rgb2yuv);
for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
s->yuv2yuv_coeffs[m][n][0] =
lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) /
(in_rng * (1 << odepth)));
for (o = 1; o < 8; o++)
s->yuv2yuv_coeffs[m][n][o] = s->yuv2yuv_coeffs[m][n][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->yuv2yuv = s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
}
}
if (emms)
emms_c();
return 0;
}
| true | FFmpeg | 531ff7161d9d6b0cf8f71125319c1f5df5041637 | static int create_filtergraph(AVFilterContext *ctx,
const AVFrame *in, const AVFrame *out)
{
ColorSpaceContext *s = ctx->priv;
const AVPixFmtDescriptor *in_desc = av_pix_fmt_desc_get(in->format);
const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(in_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\n",
in->format, av_get_pix_fmt_name(in->format),
in_desc ? in_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(out_desc)) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\n",
out->format, av_get_pix_fmt_name(out->format),
out_desc ? out_desc->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (in->color_primaries != s->in_prm) s->in_primaries = NULL;
if (out->color_primaries != s->out_prm) s->out_primaries = NULL;
if (in->color_trc != s->in_trc) s->in_txchr = NULL;
if (out->color_trc != s->out_trc) s->out_txchr = NULL;
if (in->colorspace != s->in_csp ||
in->color_range != s->in_rng) s->in_lumacoef = NULL;
if (out->colorspace != s->out_csp ||
out->color_range != s->out_rng) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = in->color_primaries;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\n",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = out->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR, "Please specify output primaries\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\n",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
fill_rgb2xyz_table(s->out_primaries, rgb2xyz);
invert_matrix3x3(rgb2xyz, xyz2rgb);
fill_rgb2xyz_table(s->in_primaries, rgb2xyz);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double wpconv[3][3], tmp[3][3];
fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(tmp, rgb2xyz, wpconv);
mul3x3(rgb2rgb, tmp, xyz2rgb);
} else {
mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
}
for (m = 0; m < 3; m++)
for (n = 0; n < 3; n++) {
s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]);
for (o = 1; o < 8; o++)
s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0];
}
emms = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = in->color_trc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\n",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = out->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
res = fill_gamma_table(s);
if (res < 0)
return res;
emms = 1;
}
if (!s->in_lumacoef) {
s->in_csp = in->colorspace;
s->in_rng = in->color_range;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\n",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
redo_yuv2rgb = 1;
}
if (!s->out_lumacoef) {
s->out_csp = out->colorspace;
s->out_rng = out->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(ctx, AV_LOG_ERROR,
"Please specify output transfer characteristics\n");
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color property %d\n", s->user_all);
}
} else {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\n",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
redo_rgb2yuv = 1;
}
fmt_identical = in_desc->log2_chroma_h == out_desc->log2_chroma_h &&
in_desc->log2_chroma_w == out_desc->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && fmt_identical;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->in_rng == s->out_rng &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef));
if (!s->yuv2yuv_passthrough) {
if (redo_yuv2rgb) {
double rgb2yuv[3][3], (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
int off, bits, in_rng;
res = get_range_off(&off, &s->in_y_rng, &s->in_uv_rng,
s->in_rng, in_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\n",
s->in_rng, av_color_range_name(s->in_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[0][n] = off;
fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv);
invert_matrix3x3(rgb2yuv, yuv2rgb);
bits = 1 << (in_desc->comp[0].depth - 1);
for (n = 0; n < 3; n++) {
for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
s->yuv2rgb_coeffs[n][m][0] = lrint(28672 * bits * yuv2rgb[n][m] / in_rng);
for (o = 1; o < 8; o++)
s->yuv2rgb_coeffs[n][m][o] = s->yuv2rgb_coeffs[n][m][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
emms = 1;
}
if (redo_rgb2yuv) {
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
int off, out_rng, bits;
res = get_range_off(&off, &s->out_y_rng, &s->out_uv_rng,
s->out_rng, out_desc->comp[0].depth);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\n",
s->out_rng, av_color_range_name(s->out_rng));
return res;
}
for (n = 0; n < 8; n++)
s->yuv_offset[1][n] = off;
fill_rgb2yuv_table(s->out_lumacoef, rgb2yuv);
bits = 1 << (29 - out_desc->comp[0].depth);
for (out_rng = s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
for (m = 0; m < 3; m++) {
s->rgb2yuv_coeffs[n][m][0] = lrint(bits * out_rng * rgb2yuv[n][m] / 28672);
for (o = 1; o < 8; o++)
s->rgb2yuv_coeffs[n][m][o] = s->rgb2yuv_coeffs[n][m][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->rgb2yuv = s->dsp.rgb2yuv[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) >> 1]
[out_desc->log2_chroma_h + out_desc->log2_chroma_w];
emms = 1;
}
if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
int idepth = in_desc->comp[0].depth, odepth = out_desc->comp[0].depth;
double (*rgb2yuv)[3] = s->rgb2yuv_dbl_coeffs;
double (*yuv2rgb)[3] = s->yuv2rgb_dbl_coeffs;
double yuv2yuv[3][3];
int in_rng, out_rng;
mul3x3(yuv2yuv, yuv2rgb, rgb2yuv);
for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
s->yuv2yuv_coeffs[m][n][0] =
lrint(16384 * yuv2yuv[m][n] * out_rng * (1 << idepth) /
(in_rng * (1 << odepth)));
for (o = 1; o < 8; o++)
s->yuv2yuv_coeffs[m][n][o] = s->yuv2yuv_coeffs[m][n][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->yuv2yuv = s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1]
[in_desc->log2_chroma_h + in_desc->log2_chroma_w];
}
}
if (emms)
emms_c();
return 0;
}
| {
"code": [
" sizeof(*s->in_lumacoef));"
],
"line_no": [
363
]
} | static int FUNC_0(AVFilterContext *VAR_0,
const AVFrame *VAR_1, const AVFrame *VAR_2)
{
ColorSpaceContext *s = VAR_0->priv;
const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1->format);
const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_2->format);
int VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;
#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
#define supported_subsampling(lcw, lch) \
(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
#define supported_format(d) \
((d) != NULL && (d)->nb_components == 3 && \
!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
supported_depth((d)->comp[0].depth) && \
supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
if (!supported_format(VAR_3)) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input format %d (%s) or bitdepth (%d)\VAR_7",
VAR_1->format, av_get_pix_fmt_name(VAR_1->format),
VAR_3 ? VAR_3->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (!supported_format(VAR_4)) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output format %d (%s) or bitdepth (%d)\VAR_7",
VAR_2->format, av_get_pix_fmt_name(VAR_2->format),
VAR_4 ? VAR_4->comp[0].depth : -1);
return AVERROR(EINVAL);
}
if (VAR_1->color_primaries != s->in_prm) s->in_primaries = NULL;
if (VAR_2->color_primaries != s->out_prm) s->out_primaries = NULL;
if (VAR_1->color_trc != s->in_trc) s->in_txchr = NULL;
if (VAR_2->color_trc != s->out_trc) s->out_txchr = NULL;
if (VAR_1->colorspace != s->in_csp ||
VAR_1->color_range != s->VAR_27) s->in_lumacoef = NULL;
if (VAR_2->colorspace != s->out_csp ||
VAR_2->color_range != s->VAR_27) s->out_lumacoef = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = VAR_1->color_primaries;
s->in_primaries = get_color_primaries(s->in_prm);
if (!s->in_primaries) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input primaries %d (%s)\VAR_7",
s->in_prm, av_color_primaries_name(s->in_prm));
return AVERROR(EINVAL);
}
s->out_prm = VAR_2->color_primaries;
s->out_primaries = get_color_primaries(s->out_prm);
if (!s->out_primaries) {
if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR, "Please specify output primaries\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output primaries %d (%s)\VAR_7",
s->out_prm, av_color_primaries_name(s->out_prm));
}
return AVERROR(EINVAL);
}
s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,
sizeof(*s->in_primaries));
if (!s->lrgb2lrgb_passthrough) {
double VAR_13[3][3], VAR_14[3][3], VAR_15[3][3];
fill_rgb2xyz_table(s->out_primaries, VAR_13);
invert_matrix3x3(VAR_13, VAR_14);
fill_rgb2xyz_table(s->in_primaries, VAR_13);
if (s->out_primaries->wp != s->in_primaries->wp &&
s->wp_adapt != WP_ADAPT_IDENTITY) {
double VAR_16[3][3], VAR_17[3][3];
fill_whitepoint_conv_table(VAR_16, s->wp_adapt, s->in_primaries->wp,
s->out_primaries->wp);
mul3x3(VAR_17, VAR_13, VAR_16);
mul3x3(VAR_15, VAR_17, VAR_14);
} else {
mul3x3(VAR_15, VAR_13, VAR_14);
}
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0] = lrint(16384.0 * VAR_15[VAR_6][VAR_7]);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->lrgb2lrgb_coeffs[VAR_6][VAR_7][VAR_8] = s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0];
}
VAR_5 = 1;
}
}
if (!s->in_txchr) {
av_freep(&s->lin_lut);
s->in_trc = VAR_1->color_trc;
s->in_txchr = get_transfer_characteristics(s->in_trc);
if (!s->in_txchr) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input transfer characteristics %d (%s)\VAR_7",
s->in_trc, av_color_transfer_name(s->in_trc));
return AVERROR(EINVAL);
}
}
if (!s->out_txchr) {
av_freep(&s->lin_lut);
s->out_trc = VAR_2->color_trc;
s->out_txchr = get_transfer_characteristics(s->out_trc);
if (!s->out_txchr) {
if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR,
"Please specify output transfer characteristics\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\VAR_7",
s->out_trc, av_color_transfer_name(s->out_trc));
}
return AVERROR(EINVAL);
}
}
s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&
!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));
if (!s->rgb2rgb_passthrough && !s->lin_lut) {
VAR_9 = fill_gamma_table(s);
if (VAR_9 < 0)
return VAR_9;
VAR_5 = 1;
}
if (!s->in_lumacoef) {
s->in_csp = VAR_1->colorspace;
s->VAR_27 = VAR_1->color_range;
s->in_lumacoef = get_luma_coefficients(s->in_csp);
if (!s->in_lumacoef) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input colorspace %d (%s)\VAR_7",
s->in_csp, av_color_space_name(s->in_csp));
return AVERROR(EINVAL);
}
VAR_11 = 1;
}
if (!s->out_lumacoef) {
s->out_csp = VAR_2->colorspace;
s->VAR_27 = VAR_2->color_range;
s->out_lumacoef = get_luma_coefficients(s->out_csp);
if (!s->out_lumacoef) {
if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
if (s->user_all == CS_UNSPECIFIED) {
av_log(VAR_0, AV_LOG_ERROR,
"Please specify output transfer characteristics\VAR_7");
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color property %d\VAR_7", s->user_all);
}
} else {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output transfer characteristics %d (%s)\VAR_7",
s->out_csp, av_color_space_name(s->out_csp));
}
return AVERROR(EINVAL);
}
VAR_12 = 1;
}
VAR_10 = VAR_3->log2_chroma_h == VAR_4->log2_chroma_h &&
VAR_3->log2_chroma_w == VAR_4->log2_chroma_w;
s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && VAR_10;
s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->VAR_27 == s->VAR_27 &&
!memcmp(s->in_lumacoef, s->out_lumacoef,
sizeof(*s->in_lumacoef));
if (!s->yuv2yuv_passthrough) {
if (VAR_11) {
double VAR_26[3][3], (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;
int VAR_23, VAR_24, VAR_27;
VAR_9 = get_range_off(&VAR_23, &s->in_y_rng, &s->in_uv_rng,
s->VAR_27, VAR_3->comp[0].depth);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported input color range %d (%s)\VAR_7",
s->VAR_27, av_color_range_name(s->VAR_27));
return VAR_9;
}
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
s->yuv_offset[0][VAR_7] = VAR_23;
fill_rgb2yuv_table(s->in_lumacoef, VAR_26);
invert_matrix3x3(VAR_26, VAR_26);
VAR_24 = 1 << (VAR_3->comp[0].depth - 1);
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
for (VAR_27 = s->in_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->in_uv_rng) {
s->yuv2rgb_coeffs[VAR_7][VAR_6][0] = lrint(28672 * VAR_24 * VAR_26[VAR_7][VAR_6] / VAR_27);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->yuv2rgb_coeffs[VAR_7][VAR_6][VAR_8] = s->yuv2rgb_coeffs[VAR_7][VAR_6][0];
}
}
av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);
av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);
av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);
s->VAR_26 = s->dsp.VAR_26[(VAR_3->comp[0].depth - 8) >> 1]
[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];
VAR_5 = 1;
}
if (VAR_12) {
double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;
int VAR_23, VAR_27, VAR_24;
VAR_9 = get_range_off(&VAR_23, &s->out_y_rng, &s->out_uv_rng,
s->VAR_27, VAR_4->comp[0].depth);
if (VAR_9 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Unsupported output color range %d (%s)\VAR_7",
s->VAR_27, av_color_range_name(s->VAR_27));
return VAR_9;
}
for (VAR_7 = 0; VAR_7 < 8; VAR_7++)
s->yuv_offset[1][VAR_7] = VAR_23;
fill_rgb2yuv_table(s->out_lumacoef, VAR_26);
VAR_24 = 1 << (29 - VAR_4->comp[0].depth);
for (VAR_27 = s->out_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->out_uv_rng) {
for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {
s->rgb2yuv_coeffs[VAR_7][VAR_6][0] = lrint(VAR_24 * VAR_27 * VAR_26[VAR_7][VAR_6] / 28672);
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->rgb2yuv_coeffs[VAR_7][VAR_6][VAR_8] = s->rgb2yuv_coeffs[VAR_7][VAR_6][0];
}
}
av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);
s->VAR_26 = s->dsp.VAR_26[(VAR_4->comp[0].depth - 8) >> 1]
[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];
s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(VAR_4->comp[0].depth - 8) >> 1]
[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];
VAR_5 = 1;
}
if (s->yuv2yuv_fastmode && (VAR_11 || VAR_12)) {
int VAR_24 = VAR_3->comp[0].depth, VAR_25 = VAR_4->comp[0].depth;
double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;
double (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;
double VAR_26[3][3];
int VAR_27, VAR_27;
mul3x3(VAR_26, VAR_26, VAR_26);
for (VAR_27 = s->out_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->out_uv_rng) {
for (VAR_27 = s->in_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->in_uv_rng) {
s->yuv2yuv_coeffs[VAR_6][VAR_7][0] =
lrint(16384 * VAR_26[VAR_6][VAR_7] * VAR_27 * (1 << VAR_24) /
(VAR_27 * (1 << VAR_25)));
for (VAR_8 = 1; VAR_8 < 8; VAR_8++)
s->yuv2yuv_coeffs[VAR_6][VAR_7][VAR_8] = s->yuv2yuv_coeffs[VAR_6][VAR_7][0];
}
}
av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);
av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);
s->VAR_26 = s->dsp.VAR_26[(VAR_24 - 8) >> 1][(VAR_25 - 8) >> 1]
[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];
}
}
if (VAR_5)
emms_c();
return 0;
}
| [
"static int FUNC_0(AVFilterContext *VAR_0,\nconst AVFrame *VAR_1, const AVFrame *VAR_2)\n{",
"ColorSpaceContext *s = VAR_0->priv;",
"const AVPixFmtDescriptor *VAR_3 = av_pix_fmt_desc_get(VAR_1->format);",
"const AVPixFmtDescriptor *VAR_4 = av_pix_fmt_desc_get(VAR_2->format);",
"int VAR_5 = 0, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;",
"#define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)\n#define supported_subsampling(lcw, lch) \\\n(((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))\n#define supported_format(d) \\\n((d) != NULL && (d)->nb_components == 3 && \\\n!((d)->flags & AV_PIX_FMT_FLAG_RGB) && \\\nsupported_depth((d)->comp[0].depth) && \\\nsupported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))\nif (!supported_format(VAR_3)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input format %d (%s) or bitdepth (%d)\\VAR_7\",\nVAR_1->format, av_get_pix_fmt_name(VAR_1->format),\nVAR_3 ? VAR_3->comp[0].depth : -1);",
"return AVERROR(EINVAL);",
"}",
"if (!supported_format(VAR_4)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output format %d (%s) or bitdepth (%d)\\VAR_7\",\nVAR_2->format, av_get_pix_fmt_name(VAR_2->format),\nVAR_4 ? VAR_4->comp[0].depth : -1);",
"return AVERROR(EINVAL);",
"}",
"if (VAR_1->color_primaries != s->in_prm) s->in_primaries = NULL;",
"if (VAR_2->color_primaries != s->out_prm) s->out_primaries = NULL;",
"if (VAR_1->color_trc != s->in_trc) s->in_txchr = NULL;",
"if (VAR_2->color_trc != s->out_trc) s->out_txchr = NULL;",
"if (VAR_1->colorspace != s->in_csp ||\nVAR_1->color_range != s->VAR_27) s->in_lumacoef = NULL;",
"if (VAR_2->colorspace != s->out_csp ||\nVAR_2->color_range != s->VAR_27) s->out_lumacoef = NULL;",
"if (!s->out_primaries || !s->in_primaries) {",
"s->in_prm = VAR_1->color_primaries;",
"s->in_primaries = get_color_primaries(s->in_prm);",
"if (!s->in_primaries) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input primaries %d (%s)\\VAR_7\",\ns->in_prm, av_color_primaries_name(s->in_prm));",
"return AVERROR(EINVAL);",
"}",
"s->out_prm = VAR_2->color_primaries;",
"s->out_primaries = get_color_primaries(s->out_prm);",
"if (!s->out_primaries) {",
"if (s->out_prm == AVCOL_PRI_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Please specify output primaries\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output primaries %d (%s)\\VAR_7\",\ns->out_prm, av_color_primaries_name(s->out_prm));",
"}",
"return AVERROR(EINVAL);",
"}",
"s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries,\nsizeof(*s->in_primaries));",
"if (!s->lrgb2lrgb_passthrough) {",
"double VAR_13[3][3], VAR_14[3][3], VAR_15[3][3];",
"fill_rgb2xyz_table(s->out_primaries, VAR_13);",
"invert_matrix3x3(VAR_13, VAR_14);",
"fill_rgb2xyz_table(s->in_primaries, VAR_13);",
"if (s->out_primaries->wp != s->in_primaries->wp &&\ns->wp_adapt != WP_ADAPT_IDENTITY) {",
"double VAR_16[3][3], VAR_17[3][3];",
"fill_whitepoint_conv_table(VAR_16, s->wp_adapt, s->in_primaries->wp,\ns->out_primaries->wp);",
"mul3x3(VAR_17, VAR_13, VAR_16);",
"mul3x3(VAR_15, VAR_17, VAR_14);",
"} else {",
"mul3x3(VAR_15, VAR_13, VAR_14);",
"}",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0] = lrint(16384.0 * VAR_15[VAR_6][VAR_7]);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->lrgb2lrgb_coeffs[VAR_6][VAR_7][VAR_8] = s->lrgb2lrgb_coeffs[VAR_6][VAR_7][0];",
"}",
"VAR_5 = 1;",
"}",
"}",
"if (!s->in_txchr) {",
"av_freep(&s->lin_lut);",
"s->in_trc = VAR_1->color_trc;",
"s->in_txchr = get_transfer_characteristics(s->in_trc);",
"if (!s->in_txchr) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input transfer characteristics %d (%s)\\VAR_7\",\ns->in_trc, av_color_transfer_name(s->in_trc));",
"return AVERROR(EINVAL);",
"}",
"}",
"if (!s->out_txchr) {",
"av_freep(&s->lin_lut);",
"s->out_trc = VAR_2->color_trc;",
"s->out_txchr = get_transfer_characteristics(s->out_trc);",
"if (!s->out_txchr) {",
"if (s->out_trc == AVCOL_TRC_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Please specify output transfer characteristics\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output transfer characteristics %d (%s)\\VAR_7\",\ns->out_trc, av_color_transfer_name(s->out_trc));",
"}",
"return AVERROR(EINVAL);",
"}",
"}",
"s->rgb2rgb_passthrough = s->fast_mode || (s->lrgb2lrgb_passthrough &&\n!memcmp(s->in_txchr, s->out_txchr, sizeof(*s->in_txchr)));",
"if (!s->rgb2rgb_passthrough && !s->lin_lut) {",
"VAR_9 = fill_gamma_table(s);",
"if (VAR_9 < 0)\nreturn VAR_9;",
"VAR_5 = 1;",
"}",
"if (!s->in_lumacoef) {",
"s->in_csp = VAR_1->colorspace;",
"s->VAR_27 = VAR_1->color_range;",
"s->in_lumacoef = get_luma_coefficients(s->in_csp);",
"if (!s->in_lumacoef) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input colorspace %d (%s)\\VAR_7\",\ns->in_csp, av_color_space_name(s->in_csp));",
"return AVERROR(EINVAL);",
"}",
"VAR_11 = 1;",
"}",
"if (!s->out_lumacoef) {",
"s->out_csp = VAR_2->colorspace;",
"s->VAR_27 = VAR_2->color_range;",
"s->out_lumacoef = get_luma_coefficients(s->out_csp);",
"if (!s->out_lumacoef) {",
"if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {",
"if (s->user_all == CS_UNSPECIFIED) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Please specify output transfer characteristics\\VAR_7\");",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color property %d\\VAR_7\", s->user_all);",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output transfer characteristics %d (%s)\\VAR_7\",\ns->out_csp, av_color_space_name(s->out_csp));",
"}",
"return AVERROR(EINVAL);",
"}",
"VAR_12 = 1;",
"}",
"VAR_10 = VAR_3->log2_chroma_h == VAR_4->log2_chroma_h &&\nVAR_3->log2_chroma_w == VAR_4->log2_chroma_w;",
"s->yuv2yuv_fastmode = s->rgb2rgb_passthrough && VAR_10;",
"s->yuv2yuv_passthrough = s->yuv2yuv_fastmode && s->VAR_27 == s->VAR_27 &&\n!memcmp(s->in_lumacoef, s->out_lumacoef,\nsizeof(*s->in_lumacoef));",
"if (!s->yuv2yuv_passthrough) {",
"if (VAR_11) {",
"double VAR_26[3][3], (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;",
"int VAR_23, VAR_24, VAR_27;",
"VAR_9 = get_range_off(&VAR_23, &s->in_y_rng, &s->in_uv_rng,\ns->VAR_27, VAR_3->comp[0].depth);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported input color range %d (%s)\\VAR_7\",\ns->VAR_27, av_color_range_name(s->VAR_27));",
"return VAR_9;",
"}",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"s->yuv_offset[0][VAR_7] = VAR_23;",
"fill_rgb2yuv_table(s->in_lumacoef, VAR_26);",
"invert_matrix3x3(VAR_26, VAR_26);",
"VAR_24 = 1 << (VAR_3->comp[0].depth - 1);",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"for (VAR_27 = s->in_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->in_uv_rng) {",
"s->yuv2rgb_coeffs[VAR_7][VAR_6][0] = lrint(28672 * VAR_24 * VAR_26[VAR_7][VAR_6] / VAR_27);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->yuv2rgb_coeffs[VAR_7][VAR_6][VAR_8] = s->yuv2rgb_coeffs[VAR_7][VAR_6][0];",
"}",
"}",
"av_assert2(s->yuv2rgb_coeffs[0][1][0] == 0);",
"av_assert2(s->yuv2rgb_coeffs[2][2][0] == 0);",
"av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[1][0][0]);",
"av_assert2(s->yuv2rgb_coeffs[0][0][0] == s->yuv2rgb_coeffs[2][0][0]);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_3->comp[0].depth - 8) >> 1]\n[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];",
"VAR_5 = 1;",
"}",
"if (VAR_12) {",
"double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;",
"int VAR_23, VAR_27, VAR_24;",
"VAR_9 = get_range_off(&VAR_23, &s->out_y_rng, &s->out_uv_rng,\ns->VAR_27, VAR_4->comp[0].depth);",
"if (VAR_9 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unsupported output color range %d (%s)\\VAR_7\",\ns->VAR_27, av_color_range_name(s->VAR_27));",
"return VAR_9;",
"}",
"for (VAR_7 = 0; VAR_7 < 8; VAR_7++)",
"s->yuv_offset[1][VAR_7] = VAR_23;",
"fill_rgb2yuv_table(s->out_lumacoef, VAR_26);",
"VAR_24 = 1 << (29 - VAR_4->comp[0].depth);",
"for (VAR_27 = s->out_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->out_uv_rng) {",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++) {",
"s->rgb2yuv_coeffs[VAR_7][VAR_6][0] = lrint(VAR_24 * VAR_27 * VAR_26[VAR_7][VAR_6] / 28672);",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->rgb2yuv_coeffs[VAR_7][VAR_6][VAR_8] = s->rgb2yuv_coeffs[VAR_7][VAR_6][0];",
"}",
"}",
"av_assert2(s->rgb2yuv_coeffs[1][2][0] == s->rgb2yuv_coeffs[2][0][0]);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_4->comp[0].depth - 8) >> 1]\n[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];",
"s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(VAR_4->comp[0].depth - 8) >> 1]\n[VAR_4->log2_chroma_h + VAR_4->log2_chroma_w];",
"VAR_5 = 1;",
"}",
"if (s->yuv2yuv_fastmode && (VAR_11 || VAR_12)) {",
"int VAR_24 = VAR_3->comp[0].depth, VAR_25 = VAR_4->comp[0].depth;",
"double (*VAR_26)[3] = s->rgb2yuv_dbl_coeffs;",
"double (*VAR_26)[3] = s->yuv2rgb_dbl_coeffs;",
"double VAR_26[3][3];",
"int VAR_27, VAR_27;",
"mul3x3(VAR_26, VAR_26, VAR_26);",
"for (VAR_27 = s->out_y_rng, VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_27 = s->out_uv_rng) {",
"for (VAR_27 = s->in_y_rng, VAR_7 = 0; VAR_7 < 3; VAR_7++, VAR_27 = s->in_uv_rng) {",
"s->yuv2yuv_coeffs[VAR_6][VAR_7][0] =\nlrint(16384 * VAR_26[VAR_6][VAR_7] * VAR_27 * (1 << VAR_24) /\n(VAR_27 * (1 << VAR_25)));",
"for (VAR_8 = 1; VAR_8 < 8; VAR_8++)",
"s->yuv2yuv_coeffs[VAR_6][VAR_7][VAR_8] = s->yuv2yuv_coeffs[VAR_6][VAR_7][0];",
"}",
"}",
"av_assert2(s->yuv2yuv_coeffs[1][0][0] == 0);",
"av_assert2(s->yuv2yuv_coeffs[2][0][0] == 0);",
"s->VAR_26 = s->dsp.VAR_26[(VAR_24 - 8) >> 1][(VAR_25 - 8) >> 1]\n[VAR_3->log2_chroma_h + VAR_3->log2_chroma_w];",
"}",
"}",
"if (VAR_5)\nemms_c();",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19,
21,
23,
25,
27,
29,
31,
35
],
[
37,
39,
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
53,
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73,
75
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123,
125,
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205,
207,
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
247,
249,
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263,
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291,
293,
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335,
337,
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
353,
355
],
[
357
],
[
359,
361,
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
375,
377
],
[
379
],
[
381,
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423,
425
],
[
427
],
[
429
],
[
433
],
[
435
],
[
437
],
[
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
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
509
],
[
511
],
[
513
],
[
515,
517,
519
],
[
521
],
[
523
],
[
525
],
[
527
],
[
529
],
[
531
],
[
533,
535
],
[
537
],
[
539
],
[
543,
545
],
[
549
],
[
551
]
] |
1,932 | AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){
AVResampleContext *c= av_mallocz(sizeof(AVResampleContext));
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c)
return NULL;
c->phase_shift= phase_shift;
c->phase_mask= phase_count-1;
c->linear= linear;
c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
if (!c->filter_bank)
goto error;
if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE))
goto error;
memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
c->src_incr= out_rate;
c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;
c->index= -phase_count*((c->filter_length-1)/2);
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| true | FFmpeg | a67cb012e6947fb238193afc0f18114f6e20818c | AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){
AVResampleContext *c= av_mallocz(sizeof(AVResampleContext));
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c)
return NULL;
c->phase_shift= phase_shift;
c->phase_mask= phase_count-1;
c->linear= linear;
c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
if (!c->filter_bank)
goto error;
if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE))
goto error;
memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
c->src_incr= out_rate;
c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;
c->index= -phase_count*((c->filter_length-1)/2);
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| {
"code": [
" c->src_incr= out_rate;",
" c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;",
" c->src_incr= out_rate;",
" c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;"
],
"line_no": [
43,
45,
43,
45
]
} | AVResampleContext *FUNC_0(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){
AVResampleContext *c= av_mallocz(sizeof(AVResampleContext));
double VAR_0= FFMIN(out_rate * cutoff / in_rate, 1.0);
int VAR_1= 1<<phase_shift;
if (!c)
return NULL;
c->phase_shift= phase_shift;
c->phase_mask= VAR_1-1;
c->linear= linear;
c->filter_length= FFMAX((int)ceil(filter_size/VAR_0), 1);
c->filter_bank= av_mallocz(c->filter_length*(VAR_1+1)*sizeof(FELEM));
if (!c->filter_bank)
goto error;
if (build_filter(c->filter_bank, VAR_0, c->filter_length, VAR_1, 1<<FILTER_SHIFT, WINDOW_TYPE))
goto error;
memcpy(&c->filter_bank[c->filter_length*VAR_1+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
c->filter_bank[c->filter_length*VAR_1]= c->filter_bank[c->filter_length - 1];
c->src_incr= out_rate;
c->ideal_dst_incr= c->dst_incr= in_rate * VAR_1;
c->index= -VAR_1*((c->filter_length-1)/2);
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| [
"AVResampleContext *FUNC_0(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){",
"AVResampleContext *c= av_mallocz(sizeof(AVResampleContext));",
"double VAR_0= FFMIN(out_rate * cutoff / in_rate, 1.0);",
"int VAR_1= 1<<phase_shift;",
"if (!c)\nreturn NULL;",
"c->phase_shift= phase_shift;",
"c->phase_mask= VAR_1-1;",
"c->linear= linear;",
"c->filter_length= FFMAX((int)ceil(filter_size/VAR_0), 1);",
"c->filter_bank= av_mallocz(c->filter_length*(VAR_1+1)*sizeof(FELEM));",
"if (!c->filter_bank)\ngoto error;",
"if (build_filter(c->filter_bank, VAR_0, c->filter_length, VAR_1, 1<<FILTER_SHIFT, WINDOW_TYPE))\ngoto error;",
"memcpy(&c->filter_bank[c->filter_length*VAR_1+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));",
"c->filter_bank[c->filter_length*VAR_1]= c->filter_bank[c->filter_length - 1];",
"c->src_incr= out_rate;",
"c->ideal_dst_incr= c->dst_incr= in_rate * VAR_1;",
"c->index= -VAR_1*((c->filter_length-1)/2);",
"return c;",
"error:\nav_free(c->filter_bank);",
"av_free(c);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
]
] |
1,933 | static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
QDict *options, int flags, BlockDriver *drv, Error **errp)
{
int ret, open_flags;
const char *filename;
Error *local_err = NULL;
assert(drv != NULL);
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
if (file != NULL) {
filename = file->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
/* bdrv_open() with directly using a protocol as drv. This layer is already
* opened, so assign it to bs (while file becomes a closed BlockDriverState)
* and return immediately. */
if (file != NULL && drv->bdrv_file_open) {
bdrv_swap(file, bs);
return 0;
}
bs->open_flags = flags;
bs->buffer_alignment = 512;
bs->zero_beyond_eof = true;
open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name);
return -ENOTSUP;
}
assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
if (!bs->read_only && (flags & BDRV_O_COPY_ON_READ)) {
bdrv_enable_copy_on_read(bs);
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
/* Open the image, either directly or using a protocol */
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
#ifndef _WIN32
if (bs->is_temporary) {
assert(bs->filename[0] != '\0');
unlink(bs->filename);
}
#endif
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| true | qemu | 8f94a6e40e46cbc8e8014da825d25824b1803b34 | static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
QDict *options, int flags, BlockDriver *drv, Error **errp)
{
int ret, open_flags;
const char *filename;
Error *local_err = NULL;
assert(drv != NULL);
assert(bs->file == NULL);
assert(options != NULL && bs->options != options);
if (file != NULL) {
filename = file->filename;
} else {
filename = qdict_get_try_str(options, "filename");
}
trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
if (file != NULL && drv->bdrv_file_open) {
bdrv_swap(file, bs);
return 0;
}
bs->open_flags = flags;
bs->buffer_alignment = 512;
bs->zero_beyond_eof = true;
open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name);
return -ENOTSUP;
}
assert(bs->copy_on_read == 0);
if (!bs->read_only && (flags & BDRV_O_COPY_ON_READ)) {
bdrv_enable_copy_on_read(bs);
}
if (filename != NULL) {
pstrcpy(bs->filename, sizeof(bs->filename), filename);
} else {
bs->filename[0] = '\0';
}
bs->drv = drv;
bs->opaque = g_malloc0(drv->instance_size);
bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
if (drv->bdrv_file_open) {
assert(file == NULL);
assert(!drv->bdrv_needs_filename || filename != NULL);
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else {
if (file == NULL) {
error_setg(errp, "Can't use '%s' as a block driver for the "
"protocol level", drv->format_name);
ret = -EINVAL;
goto free_and_fail;
}
bs->file = file;
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
}
if (ret < 0) {
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
} else if (bs->filename[0]) {
error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
} else {
error_setg_errno(errp, -ret, "Could not open image");
}
goto free_and_fail;
}
ret = refresh_total_sectors(bs, bs->total_sectors);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not refresh total sector count");
goto free_and_fail;
}
#ifndef _WIN32
if (bs->is_temporary) {
assert(bs->filename[0] != '\0');
unlink(bs->filename);
}
#endif
return 0;
free_and_fail:
bs->file = NULL;
g_free(bs->opaque);
bs->opaque = NULL;
bs->drv = NULL;
return ret;
}
| {
"code": [
" error_setg(errp, \"Driver '%s' is not whitelisted\", drv->format_name);"
],
"line_no": [
69
]
} | static int FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
QDict *VAR_2, int VAR_3, BlockDriver *VAR_4, Error **VAR_5)
{
int VAR_6, VAR_7;
const char *VAR_8;
Error *local_err = NULL;
assert(VAR_4 != NULL);
assert(VAR_0->VAR_1 == NULL);
assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);
if (VAR_1 != NULL) {
VAR_8 = VAR_1->VAR_8;
} else {
VAR_8 = qdict_get_try_str(VAR_2, "VAR_8");
}
trace_bdrv_open_common(VAR_0, VAR_8 ?: "", VAR_3, VAR_4->format_name);
if (VAR_1 != NULL && VAR_4->bdrv_file_open) {
bdrv_swap(VAR_1, VAR_0);
return 0;
}
VAR_0->VAR_7 = VAR_3;
VAR_0->buffer_alignment = 512;
VAR_0->zero_beyond_eof = true;
VAR_7 = bdrv_open_flags(VAR_0, VAR_3);
VAR_0->read_only = !(VAR_7 & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_4, VAR_0->read_only)) {
error_setg(VAR_5, "Driver '%s' is not whitelisted", VAR_4->format_name);
return -ENOTSUP;
}
assert(VAR_0->copy_on_read == 0);
if (!VAR_0->read_only && (VAR_3 & BDRV_O_COPY_ON_READ)) {
bdrv_enable_copy_on_read(VAR_0);
}
if (VAR_8 != NULL) {
pstrcpy(VAR_0->VAR_8, sizeof(VAR_0->VAR_8), VAR_8);
} else {
VAR_0->VAR_8[0] = '\0';
}
VAR_0->VAR_4 = VAR_4;
VAR_0->opaque = g_malloc0(VAR_4->instance_size);
VAR_0->enable_write_cache = !!(VAR_3 & BDRV_O_CACHE_WB);
if (VAR_4->bdrv_file_open) {
assert(VAR_1 == NULL);
assert(!VAR_4->bdrv_needs_filename || VAR_8 != NULL);
VAR_6 = VAR_4->bdrv_file_open(VAR_0, VAR_2, VAR_7, &local_err);
} else {
if (VAR_1 == NULL) {
error_setg(VAR_5, "Can't use '%s' as a block driver for the "
"protocol level", VAR_4->format_name);
VAR_6 = -EINVAL;
goto free_and_fail;
}
VAR_0->VAR_1 = VAR_1;
VAR_6 = VAR_4->bdrv_open(VAR_0, VAR_2, VAR_7, &local_err);
}
if (VAR_6 < 0) {
if (error_is_set(&local_err)) {
error_propagate(VAR_5, local_err);
} else if (VAR_0->VAR_8[0]) {
error_setg_errno(VAR_5, -VAR_6, "Could not open '%s'", VAR_0->VAR_8);
} else {
error_setg_errno(VAR_5, -VAR_6, "Could not open image");
}
goto free_and_fail;
}
VAR_6 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);
if (VAR_6 < 0) {
error_setg_errno(VAR_5, -VAR_6, "Could not refresh total sector count");
goto free_and_fail;
}
#ifndef _WIN32
if (VAR_0->is_temporary) {
assert(VAR_0->VAR_8[0] != '\0');
unlink(VAR_0->VAR_8);
}
#endif
return 0;
free_and_fail:
VAR_0->VAR_1 = NULL;
g_free(VAR_0->opaque);
VAR_0->opaque = NULL;
VAR_0->VAR_4 = NULL;
return VAR_6;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nQDict *VAR_2, int VAR_3, BlockDriver *VAR_4, Error **VAR_5)\n{",
"int VAR_6, VAR_7;",
"const char *VAR_8;",
"Error *local_err = NULL;",
"assert(VAR_4 != NULL);",
"assert(VAR_0->VAR_1 == NULL);",
"assert(VAR_2 != NULL && VAR_0->VAR_2 != VAR_2);",
"if (VAR_1 != NULL) {",
"VAR_8 = VAR_1->VAR_8;",
"} else {",
"VAR_8 = qdict_get_try_str(VAR_2, \"VAR_8\");",
"}",
"trace_bdrv_open_common(VAR_0, VAR_8 ?: \"\", VAR_3, VAR_4->format_name);",
"if (VAR_1 != NULL && VAR_4->bdrv_file_open) {",
"bdrv_swap(VAR_1, VAR_0);",
"return 0;",
"}",
"VAR_0->VAR_7 = VAR_3;",
"VAR_0->buffer_alignment = 512;",
"VAR_0->zero_beyond_eof = true;",
"VAR_7 = bdrv_open_flags(VAR_0, VAR_3);",
"VAR_0->read_only = !(VAR_7 & BDRV_O_RDWR);",
"if (use_bdrv_whitelist && !bdrv_is_whitelisted(VAR_4, VAR_0->read_only)) {",
"error_setg(VAR_5, \"Driver '%s' is not whitelisted\", VAR_4->format_name);",
"return -ENOTSUP;",
"}",
"assert(VAR_0->copy_on_read == 0);",
"if (!VAR_0->read_only && (VAR_3 & BDRV_O_COPY_ON_READ)) {",
"bdrv_enable_copy_on_read(VAR_0);",
"}",
"if (VAR_8 != NULL) {",
"pstrcpy(VAR_0->VAR_8, sizeof(VAR_0->VAR_8), VAR_8);",
"} else {",
"VAR_0->VAR_8[0] = '\\0';",
"}",
"VAR_0->VAR_4 = VAR_4;",
"VAR_0->opaque = g_malloc0(VAR_4->instance_size);",
"VAR_0->enable_write_cache = !!(VAR_3 & BDRV_O_CACHE_WB);",
"if (VAR_4->bdrv_file_open) {",
"assert(VAR_1 == NULL);",
"assert(!VAR_4->bdrv_needs_filename || VAR_8 != NULL);",
"VAR_6 = VAR_4->bdrv_file_open(VAR_0, VAR_2, VAR_7, &local_err);",
"} else {",
"if (VAR_1 == NULL) {",
"error_setg(VAR_5, \"Can't use '%s' as a block driver for the \"\n\"protocol level\", VAR_4->format_name);",
"VAR_6 = -EINVAL;",
"goto free_and_fail;",
"}",
"VAR_0->VAR_1 = VAR_1;",
"VAR_6 = VAR_4->bdrv_open(VAR_0, VAR_2, VAR_7, &local_err);",
"}",
"if (VAR_6 < 0) {",
"if (error_is_set(&local_err)) {",
"error_propagate(VAR_5, local_err);",
"} else if (VAR_0->VAR_8[0]) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not open '%s'\", VAR_0->VAR_8);",
"} else {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not open image\");",
"}",
"goto free_and_fail;",
"}",
"VAR_6 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);",
"if (VAR_6 < 0) {",
"error_setg_errno(VAR_5, -VAR_6, \"Could not refresh total sector count\");",
"goto free_and_fail;",
"}",
"#ifndef _WIN32\nif (VAR_0->is_temporary) {",
"assert(VAR_0->VAR_8[0] != '\\0');",
"unlink(VAR_0->VAR_8);",
"}",
"#endif\nreturn 0;",
"free_and_fail:\nVAR_0->VAR_1 = NULL;",
"g_free(VAR_0->opaque);",
"VAR_0->opaque = NULL;",
"VAR_0->VAR_4 = NULL;",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
]
] |
1,934 | static void usage(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
"Linux CPU emulator (compiled for %s emulation)\n"
"\n"
"Standard options:\n"
"-h print this help\n"
"-g port wait gdb connection to port\n"
"-L path set the elf interpreter prefix (default=%s)\n"
"-s size set the stack size in bytes (default=%ld)\n"
"-cpu model select CPU (-cpu ? for list)\n"
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-0 argv0 forces target process argv[0] to be argv0\n"
#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address\n"
#endif
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
"-p pagesize set the host page size to 'pagesize'\n"
"-singlestep always run in singlestep mode\n"
"-strace log system calls\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
" 'strace' program. Enable by setting to any value.\n"
"You can use -E and -U options to set/unset environment variables\n"
"for target process. It is possible to provide several variables\n"
"by repeating the option. For example:\n"
" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n"
"Note that if you provide several changes to single variable\n"
"last change will stay in effect.\n"
,
TARGET_ARCH,
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
exit(1);
}
| true | qemu | 703e0e89c669a70bbd6bf33c5e75f910d8d8cca3 | static void usage(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
"Linux CPU emulator (compiled for %s emulation)\n"
"\n"
"Standard options:\n"
"-h print this help\n"
"-g port wait gdb connection to port\n"
"-L path set the elf interpreter prefix (default=%s)\n"
"-s size set the stack size in bytes (default=%ld)\n"
"-cpu model select CPU (-cpu ? for list)\n"
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-0 argv0 forces target process argv[0] to be argv0\n"
#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address\n"
#endif
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
"-p pagesize set the host page size to 'pagesize'\n"
"-singlestep always run in singlestep mode\n"
"-strace log system calls\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
" 'strace' program. Enable by setting to any value.\n"
"You can use -E and -U options to set/unset environment variables\n"
"for target process. It is possible to provide several variables\n"
"by repeating the option. For example:\n"
" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n"
"Note that if you provide several changes to single variable\n"
"last change will stay in effect.\n"
,
TARGET_ARCH,
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
exit(1);
}
| {
"code": [
" x86_stack_size,"
],
"line_no": [
77
]
} | static void FUNC_0(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
"FUNC_0: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
"Linux CPU emulator (compiled for %s emulation)\n"
"\n"
"Standard options:\n"
"-h print this help\n"
"-g port wait gdb connection to port\n"
"-L path set the elf interpreter prefix (default=%s)\n"
"-s size set the stack size in bytes (default=%ld)\n"
"-cpu model select CPU (-cpu ? for list)\n"
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-0 argv0 forces target process argv[0] to be argv0\n"
#if defined(CONFIG_USE_GUEST_BASE)
"-B address set guest_base address to address\n"
#endif
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
"-p pagesize set the host page size to 'pagesize'\n"
"-singlestep always run in singlestep mode\n"
"-strace log system calls\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
" 'strace' program. Enable by setting to any value.\n"
"You can use -E and -U options to set/unset environment variables\n"
"for target process. It is possible to provide several variables\n"
"by repeating the option. For example:\n"
" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n"
"Note that if you provide several changes to single variable\n"
"last change will stay in effect.\n"
,
TARGET_ARCH,
interp_prefix,
x86_stack_size,
DEBUG_LOGFILE);
exit(1);
}
| [
"static void FUNC_0(void)\n{",
"printf(\"qemu-\" TARGET_ARCH \" version \" QEMU_VERSION QEMU_PKGVERSION \", Copyright (c) 2003-2008 Fabrice Bellard\\n\"\n\"FUNC_0: qemu-\" TARGET_ARCH \" [options] program [arguments...]\\n\"\n\"Linux CPU emulator (compiled for %s emulation)\\n\"\n\"\\n\"\n\"Standard options:\\n\"\n\"-h print this help\\n\"\n\"-g port wait gdb connection to port\\n\"\n\"-L path set the elf interpreter prefix (default=%s)\\n\"\n\"-s size set the stack size in bytes (default=%ld)\\n\"\n\"-cpu model select CPU (-cpu ? for list)\\n\"\n\"-drop-ld-preload drop LD_PRELOAD for target process\\n\"\n\"-E var=value sets/modifies targets environment variable(s)\\n\"\n\"-U var unsets targets environment variable(s)\\n\"\n\"-0 argv0 forces target process argv[0] to be argv0\\n\"\n#if defined(CONFIG_USE_GUEST_BASE)\n\"-B address set guest_base address to address\\n\"\n#endif\n\"\\n\"\n\"Debug options:\\n\"\n\"-d options activate log (logfile=%s)\\n\"\n\"-p pagesize set the host page size to 'pagesize'\\n\"\n\"-singlestep always run in singlestep mode\\n\"\n\"-strace log system calls\\n\"\n\"\\n\"\n\"Environment variables:\\n\"\n\"QEMU_STRACE Print system calls and arguments similar to the\\n\"\n\" 'strace' program. Enable by setting to any value.\\n\"\n\"You can use -E and -U options to set/unset environment variables\\n\"\n\"for target process. It is possible to provide several variables\\n\"\n\"by repeating the option. For example:\\n\"\n\" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\\n\"\n\"Note that if you provide several changes to single variable\\n\"\n\"last change will stay in effect.\\n\"\n,\nTARGET_ARCH,\ninterp_prefix,\nx86_stack_size,\nDEBUG_LOGFILE);",
"exit(1);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79
],
[
81
],
[
83
]
] |
1,935 | void visit_end_struct(Visitor *v, Error **errp)
{
assert(!error_is_set(errp));
v->end_struct(v, errp);
}
| true | qemu | 297a3646c2947ee64a6d42ca264039732c6218e0 | void visit_end_struct(Visitor *v, Error **errp)
{
assert(!error_is_set(errp));
v->end_struct(v, errp);
}
| {
"code": [
" assert(!error_is_set(errp));",
" assert(!error_is_set(errp));",
" assert(!error_is_set(errp));"
],
"line_no": [
5,
5,
5
]
} | void FUNC_0(Visitor *VAR_0, Error **VAR_1)
{
assert(!error_is_set(VAR_1));
VAR_0->end_struct(VAR_0, VAR_1);
}
| [
"void FUNC_0(Visitor *VAR_0, Error **VAR_1)\n{",
"assert(!error_is_set(VAR_1));",
"VAR_0->end_struct(VAR_0, VAR_1);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,936 | static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
uint8_t *buf, int buf_size)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
fd_set rfds;
int fd, fd_max, n, i, ret, tcp_fd;
struct timeval tv;
for(;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
FD_ZERO(&rfds);
tcp_fd = fd_max = url_get_file_handle(rt->rtsp_hd);
FD_SET(tcp_fd, &rfds);
for(i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
/* currently, we cannot probe RTCP handle because of
* blocking restrictions */
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (fd > fd_max)
fd_max = fd;
FD_SET(fd, &rfds);
}
}
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
n = select(fd_max + 1, &rfds, NULL, NULL, &tv);
if (n > 0) {
for(i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (FD_ISSET(fd, &rfds)) {
ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
if (ret > 0) {
*prtsp_st = rtsp_st;
return ret;
}
}
}
}
if (FD_ISSET(tcp_fd, &rfds)) {
RTSPMessageHeader reply;
rtsp_read_reply(s, &reply, NULL, 0);
/* XXX: parse message */
}
}
}
}
| true | FFmpeg | 46ff7a5f4ae05e5e4da33b700604dae2c37bebcb | static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
uint8_t *buf, int buf_size)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
fd_set rfds;
int fd, fd_max, n, i, ret, tcp_fd;
struct timeval tv;
for(;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
FD_ZERO(&rfds);
tcp_fd = fd_max = url_get_file_handle(rt->rtsp_hd);
FD_SET(tcp_fd, &rfds);
for(i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (fd > fd_max)
fd_max = fd;
FD_SET(fd, &rfds);
}
}
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
n = select(fd_max + 1, &rfds, NULL, NULL, &tv);
if (n > 0) {
for(i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st->rtp_handle) {
fd = url_get_file_handle(rtsp_st->rtp_handle);
if (FD_ISSET(fd, &rfds)) {
ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
if (ret > 0) {
*prtsp_st = rtsp_st;
return ret;
}
}
}
}
if (FD_ISSET(tcp_fd, &rfds)) {
RTSPMessageHeader reply;
rtsp_read_reply(s, &reply, NULL, 0);
}
}
}
}
| {
"code": [
" tcp_fd = fd_max = url_get_file_handle(rt->rtsp_hd);",
" FD_SET(tcp_fd, &rfds);"
],
"line_no": [
27,
29
]
} | static int FUNC_0(AVFormatContext *VAR_0, RTSPStream **VAR_1,
uint8_t *VAR_2, int VAR_3)
{
RTSPState *rt = VAR_0->priv_data;
RTSPStream *rtsp_st;
fd_set rfds;
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
struct timeval VAR_10;
for(;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
FD_ZERO(&rfds);
VAR_9 = VAR_5 = url_get_file_handle(rt->rtsp_hd);
FD_SET(VAR_9, &rfds);
for(VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; VAR_7++) {
rtsp_st = rt->rtsp_streams[VAR_7];
if (rtsp_st->rtp_handle) {
VAR_4 = url_get_file_handle(rtsp_st->rtp_handle);
if (VAR_4 > VAR_5)
VAR_5 = VAR_4;
FD_SET(VAR_4, &rfds);
}
}
VAR_10.tv_sec = 0;
VAR_10.tv_usec = 100 * 1000;
VAR_6 = select(VAR_5 + 1, &rfds, NULL, NULL, &VAR_10);
if (VAR_6 > 0) {
for(VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; VAR_7++) {
rtsp_st = rt->rtsp_streams[VAR_7];
if (rtsp_st->rtp_handle) {
VAR_4 = url_get_file_handle(rtsp_st->rtp_handle);
if (FD_ISSET(VAR_4, &rfds)) {
VAR_8 = url_read(rtsp_st->rtp_handle, VAR_2, VAR_3);
if (VAR_8 > 0) {
*VAR_1 = rtsp_st;
return VAR_8;
}
}
}
}
if (FD_ISSET(VAR_9, &rfds)) {
RTSPMessageHeader reply;
rtsp_read_reply(VAR_0, &reply, NULL, 0);
}
}
}
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, RTSPStream **VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"RTSPStream *rtsp_st;",
"fd_set rfds;",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"struct timeval VAR_10;",
"for(;;) {",
"if (url_interrupt_cb())\nreturn AVERROR(EINTR);",
"FD_ZERO(&rfds);",
"VAR_9 = VAR_5 = url_get_file_handle(rt->rtsp_hd);",
"FD_SET(VAR_9, &rfds);",
"for(VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; VAR_7++) {",
"rtsp_st = rt->rtsp_streams[VAR_7];",
"if (rtsp_st->rtp_handle) {",
"VAR_4 = url_get_file_handle(rtsp_st->rtp_handle);",
"if (VAR_4 > VAR_5)\nVAR_5 = VAR_4;",
"FD_SET(VAR_4, &rfds);",
"}",
"}",
"VAR_10.tv_sec = 0;",
"VAR_10.tv_usec = 100 * 1000;",
"VAR_6 = select(VAR_5 + 1, &rfds, NULL, NULL, &VAR_10);",
"if (VAR_6 > 0) {",
"for(VAR_7 = 0; VAR_7 < rt->nb_rtsp_streams; VAR_7++) {",
"rtsp_st = rt->rtsp_streams[VAR_7];",
"if (rtsp_st->rtp_handle) {",
"VAR_4 = url_get_file_handle(rtsp_st->rtp_handle);",
"if (FD_ISSET(VAR_4, &rfds)) {",
"VAR_8 = url_read(rtsp_st->rtp_handle, VAR_2, VAR_3);",
"if (VAR_8 > 0) {",
"*VAR_1 = rtsp_st;",
"return VAR_8;",
"}",
"}",
"}",
"}",
"if (FD_ISSET(VAR_9, &rfds)) {",
"RTSPMessageHeader reply;",
"rtsp_read_reply(VAR_0, &reply, NULL, 0);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
]
] |
1,938 | static float **alloc_audio_arrays(int channels, int frame_size)
{
float **audio = av_mallocz_array(channels, sizeof(float *));
if (!audio)
return NULL;
for (int ch = 0; ch < channels; ch++) {
audio[ch] = av_mallocz_array(frame_size, sizeof(float));
if (!audio[ch]) {
// alloc has failed, free everything allocated thus far
for (ch--; ch >= 0; ch--)
av_free(audio[ch]);
av_free(audio);
return NULL;
}
}
return audio;
}
| true | FFmpeg | 34c52005605d68f7cd1957b169b6732c7d2447d9 | static float **alloc_audio_arrays(int channels, int frame_size)
{
float **audio = av_mallocz_array(channels, sizeof(float *));
if (!audio)
return NULL;
for (int ch = 0; ch < channels; ch++) {
audio[ch] = av_mallocz_array(frame_size, sizeof(float));
if (!audio[ch]) {
for (ch--; ch >= 0; ch--)
av_free(audio[ch]);
av_free(audio);
return NULL;
}
}
return audio;
}
| {
"code": [
"static float **alloc_audio_arrays(int channels, int frame_size)",
" float **audio = av_mallocz_array(channels, sizeof(float *));",
" if (!audio)",
" return NULL;",
" for (int ch = 0; ch < channels; ch++) {",
" audio[ch] = av_mallocz_array(frame_size, sizeof(float));",
" if (!audio[ch]) {",
" for (ch--; ch >= 0; ch--)",
" av_free(audio[ch]);",
" av_free(audio);",
" return NULL;",
" return audio;",
" if (!audio)"
],
"line_no": [
1,
5,
7,
9,
13,
15,
17,
21,
23,
25,
27,
35,
7
]
} | static float **FUNC_0(int VAR_0, int VAR_1)
{
float **VAR_2 = av_mallocz_array(VAR_0, sizeof(float *));
if (!VAR_2)
return NULL;
for (int VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) {
VAR_2[VAR_3] = av_mallocz_array(VAR_1, sizeof(float));
if (!VAR_2[VAR_3]) {
for (VAR_3--; VAR_3 >= 0; VAR_3--)
av_free(VAR_2[VAR_3]);
av_free(VAR_2);
return NULL;
}
}
return VAR_2;
}
| [
"static float **FUNC_0(int VAR_0, int VAR_1)\n{",
"float **VAR_2 = av_mallocz_array(VAR_0, sizeof(float *));",
"if (!VAR_2)\nreturn NULL;",
"for (int VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) {",
"VAR_2[VAR_3] = av_mallocz_array(VAR_1, sizeof(float));",
"if (!VAR_2[VAR_3]) {",
"for (VAR_3--; VAR_3 >= 0; VAR_3--)",
"av_free(VAR_2[VAR_3]);",
"av_free(VAR_2);",
"return NULL;",
"}",
"}",
"return VAR_2;",
"}"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
1,939 | static void unterminated_sq_string(void)
{
QObject *obj = qobject_from_json("'abc", NULL);
g_assert(obj == NULL);
}
| true | qemu | aec4b054ea36c53c8b887da99f20010133b84378 | static void unterminated_sq_string(void)
{
QObject *obj = qobject_from_json("'abc", NULL);
g_assert(obj == NULL);
}
| {
"code": [
" QObject *obj = qobject_from_json(\"'abc\", NULL);"
],
"line_no": [
5
]
} | static void FUNC_0(void)
{
QObject *obj = qobject_from_json("'abc", NULL);
g_assert(obj == NULL);
}
| [
"static void FUNC_0(void)\n{",
"QObject *obj = qobject_from_json(\"'abc\", NULL);",
"g_assert(obj == NULL);",
"}"
] | [
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,940 | static inline bool use_goto_tb(DisasContext *s, int n, uint64_t dest)
{
/* No direct tb linking with singlestep (either QEMU's or the ARM
* debug architecture kind) or deterministic io
*/
if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) {
return false;
}
#ifndef CONFIG_USER_ONLY
/* Only link tbs from inside the same guest page */
if ((s->base.tb->pc & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) {
return false;
}
#endif
return true;
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static inline bool use_goto_tb(DisasContext *s, int n, uint64_t dest)
{
if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) {
return false;
}
#ifndef CONFIG_USER_ONLY
if ((s->base.tb->pc & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) {
return false;
}
#endif
return true;
}
| {
"code": [
" if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) {"
],
"line_no": [
11
]
} | static inline bool FUNC_0(DisasContext *s, int n, uint64_t dest)
{
if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) {
return false;
}
#ifndef CONFIG_USER_ONLY
if ((s->base.tb->pc & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) {
return false;
}
#endif
return true;
}
| [
"static inline bool FUNC_0(DisasContext *s, int n, uint64_t dest)\n{",
"if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) {",
"return false;",
"}",
"#ifndef CONFIG_USER_ONLY\nif ((s->base.tb->pc & TARGET_PAGE_MASK) != (dest & TARGET_PAGE_MASK)) {",
"return false;",
"}",
"#endif\nreturn true;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
11
],
[
13
],
[
15
],
[
19,
23
],
[
25
],
[
27
],
[
29,
33
],
[
35
]
] |
1,941 | static int common_end(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
int i;
for(i=0; i<s->plane_count; i++){
PlaneContext *p= &s->plane[i];
av_freep(&p->state);
}
return 0;
} | true | FFmpeg | 3caffb7d80f20c66d7d582ca3d23f80ad373ba0a | static int common_end(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
int i;
for(i=0; i<s->plane_count; i++){
PlaneContext *p= &s->plane[i];
av_freep(&p->state);
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0){
FFV1Context *s = VAR_0->priv_data;
int VAR_1;
for(VAR_1=0; VAR_1<s->plane_count; VAR_1++){
PlaneContext *p= &s->plane[VAR_1];
av_freep(&p->state);
}
return 0;
} | [
"static int FUNC_0(AVCodecContext *VAR_0){",
"FFV1Context *s = VAR_0->priv_data;",
"int VAR_1;",
"for(VAR_1=0; VAR_1<s->plane_count; VAR_1++){",
"PlaneContext *p= &s->plane[VAR_1];",
"av_freep(&p->state);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
18
],
[
22
],
[
24
]
] |
1,942 | av_cold void ff_sws_init_input_funcs(SwsContext *c)
{
enum PixelFormat srcFormat = c->srcFormat;
c->chrToYV12 = NULL;
switch(srcFormat) {
case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break;
case PIX_FMT_UYVY422 : c->chrToYV12 = uyvyToUV_c; break;
case PIX_FMT_NV12 : c->chrToYV12 = nv12ToUV_c; break;
case PIX_FMT_NV21 : c->chrToYV12 = nv21ToUV_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break;
case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break;
#endif
}
if (c->chrSrcHSubSample) {
switch(srcFormat) {
case PIX_FMT_RGBA64BE: c->chrToYV12 = rgb64BEToUV_half_c; break;
case PIX_FMT_RGBA64LE: c->chrToYV12 = rgb64LEToUV_half_c; break;
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_half_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_half_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_half_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_half_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_half_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_half_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_half_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_half_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_half_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_half_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_half_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_half_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_half_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_half_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_half_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break;
case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_half_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_half_c; break;
}
} else {
switch(srcFormat) {
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_c; break;
}
}
c->lumToYV12 = NULL;
c->alpToYV12 = NULL;
switch (srcFormat) {
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break;
case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE:
case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE:
case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break;
#endif
case PIX_FMT_YUYV422 :
case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break;
case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break;
case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break;
case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break;
case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break;
case PIX_FMT_BGR555LE : c->lumToYV12 = bgr15leToY_c; break;
case PIX_FMT_BGR555BE : c->lumToYV12 = bgr15beToY_c; break;
case PIX_FMT_BGR444LE : c->lumToYV12 = bgr12leToY_c; break;
case PIX_FMT_BGR444BE : c->lumToYV12 = bgr12beToY_c; break;
case PIX_FMT_RGB24 : c->lumToYV12 = rgb24ToY_c; break;
case PIX_FMT_RGB565LE : c->lumToYV12 = rgb16leToY_c; break;
case PIX_FMT_RGB565BE : c->lumToYV12 = rgb16beToY_c; break;
case PIX_FMT_RGB555LE : c->lumToYV12 = rgb15leToY_c; break;
case PIX_FMT_RGB555BE : c->lumToYV12 = rgb15beToY_c; break;
case PIX_FMT_RGB444LE : c->lumToYV12 = rgb12leToY_c; break;
case PIX_FMT_RGB444BE : c->lumToYV12 = rgb12beToY_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->lumToYV12 = palToY_c; break;
case PIX_FMT_MONOBLACK: c->lumToYV12 = monoblack2Y_c; break;
case PIX_FMT_MONOWHITE: c->lumToYV12 = monowhite2Y_c; break;
case PIX_FMT_RGB32 : c->lumToYV12 = bgr32ToY_c; break;
case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break;
case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break;
case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break;
case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break;
case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break;
case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break;
case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break;
case PIX_FMT_RGBA64BE:c->lumToYV12 = rgb64BEToY_c; break;
case PIX_FMT_RGBA64LE:c->lumToYV12 = rgb64LEToY_c; break;
}
if (c->alpPixBuf) {
switch (srcFormat) {
case PIX_FMT_RGBA64LE:
case PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
case PIX_FMT_BGRA:
case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break;
case PIX_FMT_ABGR:
case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break;
case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;
case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
}
}
} | true | FFmpeg | f972193a15026a99eb2b08e7913a03f2123663da | av_cold void ff_sws_init_input_funcs(SwsContext *c)
{
enum PixelFormat srcFormat = c->srcFormat;
c->chrToYV12 = NULL;
switch(srcFormat) {
case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break;
case PIX_FMT_UYVY422 : c->chrToYV12 = uyvyToUV_c; break;
case PIX_FMT_NV12 : c->chrToYV12 = nv12ToUV_c; break;
case PIX_FMT_NV21 : c->chrToYV12 = nv21ToUV_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break;
case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break;
#endif
}
if (c->chrSrcHSubSample) {
switch(srcFormat) {
case PIX_FMT_RGBA64BE: c->chrToYV12 = rgb64BEToUV_half_c; break;
case PIX_FMT_RGBA64LE: c->chrToYV12 = rgb64LEToUV_half_c; break;
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_half_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_half_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_half_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_half_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_half_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_half_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_half_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_half_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_half_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_half_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_half_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_half_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_half_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_half_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_half_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break;
case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_half_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_half_c; break;
}
} else {
switch(srcFormat) {
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_c; break;
}
}
c->lumToYV12 = NULL;
c->alpToYV12 = NULL;
switch (srcFormat) {
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break;
case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE:
case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE:
case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break;
#endif
case PIX_FMT_YUYV422 :
case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break;
case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break;
case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break;
case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break;
case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break;
case PIX_FMT_BGR555LE : c->lumToYV12 = bgr15leToY_c; break;
case PIX_FMT_BGR555BE : c->lumToYV12 = bgr15beToY_c; break;
case PIX_FMT_BGR444LE : c->lumToYV12 = bgr12leToY_c; break;
case PIX_FMT_BGR444BE : c->lumToYV12 = bgr12beToY_c; break;
case PIX_FMT_RGB24 : c->lumToYV12 = rgb24ToY_c; break;
case PIX_FMT_RGB565LE : c->lumToYV12 = rgb16leToY_c; break;
case PIX_FMT_RGB565BE : c->lumToYV12 = rgb16beToY_c; break;
case PIX_FMT_RGB555LE : c->lumToYV12 = rgb15leToY_c; break;
case PIX_FMT_RGB555BE : c->lumToYV12 = rgb15beToY_c; break;
case PIX_FMT_RGB444LE : c->lumToYV12 = rgb12leToY_c; break;
case PIX_FMT_RGB444BE : c->lumToYV12 = rgb12beToY_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->lumToYV12 = palToY_c; break;
case PIX_FMT_MONOBLACK: c->lumToYV12 = monoblack2Y_c; break;
case PIX_FMT_MONOWHITE: c->lumToYV12 = monowhite2Y_c; break;
case PIX_FMT_RGB32 : c->lumToYV12 = bgr32ToY_c; break;
case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break;
case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break;
case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break;
case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break;
case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break;
case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break;
case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break;
case PIX_FMT_RGBA64BE:c->lumToYV12 = rgb64BEToY_c; break;
case PIX_FMT_RGBA64LE:c->lumToYV12 = rgb64LEToY_c; break;
}
if (c->alpPixBuf) {
switch (srcFormat) {
case PIX_FMT_RGBA64LE:
case PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
case PIX_FMT_BGRA:
case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break;
case PIX_FMT_ABGR:
case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break;
case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;
case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
}
}
} | {
"code": [],
"line_no": []
} | av_cold void FUNC_0(SwsContext *c)
{
enum PixelFormat VAR_0 = c->VAR_0;
c->chrToYV12 = NULL;
switch(VAR_0) {
case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break;
case PIX_FMT_UYVY422 : c->chrToYV12 = uyvyToUV_c; break;
case PIX_FMT_NV12 : c->chrToYV12 = nv12ToUV_c; break;
case PIX_FMT_NV21 : c->chrToYV12 = nv21ToUV_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break;
case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break;
#endif
}
if (c->chrSrcHSubSample) {
switch(VAR_0) {
case PIX_FMT_RGBA64BE: c->chrToYV12 = rgb64BEToUV_half_c; break;
case PIX_FMT_RGBA64LE: c->chrToYV12 = rgb64LEToUV_half_c; break;
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_half_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_half_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_half_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_half_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_half_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_half_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_half_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_half_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_half_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_half_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_half_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_half_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_half_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_half_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_half_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break;
case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_half_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_half_c; break;
}
} else {
switch(VAR_0) {
case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_c; break;
case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_c; break;
case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_c; break;
case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_c; break;
case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break;
case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_c; break;
case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break;
case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_c; break;
case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_c; break;
case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_c; break;
case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_c; break;
case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_c; break;
case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_c; break;
case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_c; break;
case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_c; break;
case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_c; break;
case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_c; break;
case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break;
case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break;
case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break;
case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_c; break;
case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_c; break;
}
}
c->lumToYV12 = NULL;
c->alpToYV12 = NULL;
switch (VAR_0) {
case PIX_FMT_GBRP9LE:
case PIX_FMT_GBRP10LE:
case PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break;
case PIX_FMT_GBRP9BE:
case PIX_FMT_GBRP10BE:
case PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break;
case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break;
#if HAVE_BIGENDIAN
case PIX_FMT_YUV444P9LE:
case PIX_FMT_YUV422P9LE:
case PIX_FMT_YUV420P9LE:
case PIX_FMT_YUV444P10LE:
case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV420P10LE:
case PIX_FMT_YUV420P16LE:
case PIX_FMT_YUV422P16LE:
case PIX_FMT_YUV444P16LE:
case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break;
#else
case PIX_FMT_YUV444P9BE:
case PIX_FMT_YUV422P9BE:
case PIX_FMT_YUV420P9BE:
case PIX_FMT_YUV444P10BE:
case PIX_FMT_YUV422P10BE:
case PIX_FMT_YUV420P10BE:
case PIX_FMT_YUV420P16BE:
case PIX_FMT_YUV422P16BE:
case PIX_FMT_YUV444P16BE:
case PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break;
#endif
case PIX_FMT_YUYV422 :
case PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break;
case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break;
case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break;
case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break;
case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break;
case PIX_FMT_BGR555LE : c->lumToYV12 = bgr15leToY_c; break;
case PIX_FMT_BGR555BE : c->lumToYV12 = bgr15beToY_c; break;
case PIX_FMT_BGR444LE : c->lumToYV12 = bgr12leToY_c; break;
case PIX_FMT_BGR444BE : c->lumToYV12 = bgr12beToY_c; break;
case PIX_FMT_RGB24 : c->lumToYV12 = rgb24ToY_c; break;
case PIX_FMT_RGB565LE : c->lumToYV12 = rgb16leToY_c; break;
case PIX_FMT_RGB565BE : c->lumToYV12 = rgb16beToY_c; break;
case PIX_FMT_RGB555LE : c->lumToYV12 = rgb15leToY_c; break;
case PIX_FMT_RGB555BE : c->lumToYV12 = rgb15beToY_c; break;
case PIX_FMT_RGB444LE : c->lumToYV12 = rgb12leToY_c; break;
case PIX_FMT_RGB444BE : c->lumToYV12 = rgb12beToY_c; break;
case PIX_FMT_RGB8 :
case PIX_FMT_BGR8 :
case PIX_FMT_PAL8 :
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE: c->lumToYV12 = palToY_c; break;
case PIX_FMT_MONOBLACK: c->lumToYV12 = monoblack2Y_c; break;
case PIX_FMT_MONOWHITE: c->lumToYV12 = monowhite2Y_c; break;
case PIX_FMT_RGB32 : c->lumToYV12 = bgr32ToY_c; break;
case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break;
case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break;
case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break;
case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break;
case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break;
case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break;
case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break;
case PIX_FMT_RGBA64BE:c->lumToYV12 = rgb64BEToY_c; break;
case PIX_FMT_RGBA64LE:c->lumToYV12 = rgb64LEToY_c; break;
}
if (c->alpPixBuf) {
switch (VAR_0) {
case PIX_FMT_RGBA64LE:
case PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
case PIX_FMT_BGRA:
case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break;
case PIX_FMT_ABGR:
case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break;
case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;
case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; break;
}
}
} | [
"av_cold void FUNC_0(SwsContext *c)\n{",
"enum PixelFormat VAR_0 = c->VAR_0;",
"c->chrToYV12 = NULL;",
"switch(VAR_0) {",
"case PIX_FMT_YUYV422 : c->chrToYV12 = yuy2ToUV_c; break;",
"case PIX_FMT_UYVY422 : c->chrToYV12 = uyvyToUV_c; break;",
"case PIX_FMT_NV12 : c->chrToYV12 = nv12ToUV_c; break;",
"case PIX_FMT_NV21 : c->chrToYV12 = nv21ToUV_c; break;",
"case PIX_FMT_RGB8 :\ncase PIX_FMT_BGR8 :\ncase PIX_FMT_PAL8 :\ncase PIX_FMT_BGR4_BYTE:\ncase PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break;",
"case PIX_FMT_GBRP9LE:\ncase PIX_FMT_GBRP10LE:\ncase PIX_FMT_GBRP16LE: c->readChrPlanar = planar_rgb16le_to_uv; break;",
"case PIX_FMT_GBRP9BE:\ncase PIX_FMT_GBRP10BE:\ncase PIX_FMT_GBRP16BE: c->readChrPlanar = planar_rgb16be_to_uv; break;",
"case PIX_FMT_GBRP: c->readChrPlanar = planar_rgb_to_uv; break;",
"#if HAVE_BIGENDIAN\ncase PIX_FMT_YUV444P9LE:\ncase PIX_FMT_YUV422P9LE:\ncase PIX_FMT_YUV420P9LE:\ncase PIX_FMT_YUV422P10LE:\ncase PIX_FMT_YUV444P10LE:\ncase PIX_FMT_YUV420P10LE:\ncase PIX_FMT_YUV420P16LE:\ncase PIX_FMT_YUV422P16LE:\ncase PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break;",
"#else\ncase PIX_FMT_YUV444P9BE:\ncase PIX_FMT_YUV422P9BE:\ncase PIX_FMT_YUV420P9BE:\ncase PIX_FMT_YUV444P10BE:\ncase PIX_FMT_YUV422P10BE:\ncase PIX_FMT_YUV420P10BE:\ncase PIX_FMT_YUV420P16BE:\ncase PIX_FMT_YUV422P16BE:\ncase PIX_FMT_YUV444P16BE: c->chrToYV12 = bswap16UV_c; break;",
"#endif\n}",
"if (c->chrSrcHSubSample) {",
"switch(VAR_0) {",
"case PIX_FMT_RGBA64BE: c->chrToYV12 = rgb64BEToUV_half_c; break;",
"case PIX_FMT_RGBA64LE: c->chrToYV12 = rgb64LEToUV_half_c; break;",
"case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_half_c; break;",
"case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_half_c; break;",
"case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_half_c; break;",
"case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_half_c; break;",
"case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break;",
"case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_half_c; break;",
"case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break;",
"case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_half_c; break;",
"case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_half_c; break;",
"case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_half_c; break;",
"case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_half_c; break;",
"case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_half_c; break;",
"case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_half_c; break;",
"case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_half_c; break;",
"case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_half_c; break;",
"case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_half_c; break;",
"case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_half_c; break;",
"case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break;",
"case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break;",
"case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break;",
"case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break;",
"case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_half_c; break;",
"case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_half_c; break;",
"}",
"} else {",
"switch(VAR_0) {",
"case PIX_FMT_RGB48BE : c->chrToYV12 = rgb48BEToUV_c; break;",
"case PIX_FMT_RGB48LE : c->chrToYV12 = rgb48LEToUV_c; break;",
"case PIX_FMT_BGR48BE : c->chrToYV12 = bgr48BEToUV_c; break;",
"case PIX_FMT_BGR48LE : c->chrToYV12 = bgr48LEToUV_c; break;",
"case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break;",
"case PIX_FMT_RGB32_1 : c->chrToYV12 = bgr321ToUV_c; break;",
"case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break;",
"case PIX_FMT_BGR565LE: c->chrToYV12 = bgr16leToUV_c; break;",
"case PIX_FMT_BGR565BE: c->chrToYV12 = bgr16beToUV_c; break;",
"case PIX_FMT_BGR555LE: c->chrToYV12 = bgr15leToUV_c; break;",
"case PIX_FMT_BGR555BE: c->chrToYV12 = bgr15beToUV_c; break;",
"case PIX_FMT_BGR444LE: c->chrToYV12 = bgr12leToUV_c; break;",
"case PIX_FMT_BGR444BE: c->chrToYV12 = bgr12beToUV_c; break;",
"case PIX_FMT_BGR32 : c->chrToYV12 = rgb32ToUV_c; break;",
"case PIX_FMT_BGR32_1 : c->chrToYV12 = rgb321ToUV_c; break;",
"case PIX_FMT_RGB24 : c->chrToYV12 = rgb24ToUV_c; break;",
"case PIX_FMT_RGB565LE: c->chrToYV12 = rgb16leToUV_c; break;",
"case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break;",
"case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break;",
"case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break;",
"case PIX_FMT_RGB444LE: c->chrToYV12 = rgb12leToUV_c; break;",
"case PIX_FMT_RGB444BE: c->chrToYV12 = rgb12beToUV_c; break;",
"}",
"}",
"c->lumToYV12 = NULL;",
"c->alpToYV12 = NULL;",
"switch (VAR_0) {",
"case PIX_FMT_GBRP9LE:\ncase PIX_FMT_GBRP10LE:\ncase PIX_FMT_GBRP16LE: c->readLumPlanar = planar_rgb16le_to_y; break;",
"case PIX_FMT_GBRP9BE:\ncase PIX_FMT_GBRP10BE:\ncase PIX_FMT_GBRP16BE: c->readLumPlanar = planar_rgb16be_to_y; break;",
"case PIX_FMT_GBRP: c->readLumPlanar = planar_rgb_to_y; break;",
"#if HAVE_BIGENDIAN\ncase PIX_FMT_YUV444P9LE:\ncase PIX_FMT_YUV422P9LE:\ncase PIX_FMT_YUV420P9LE:\ncase PIX_FMT_YUV444P10LE:\ncase PIX_FMT_YUV422P10LE:\ncase PIX_FMT_YUV420P10LE:\ncase PIX_FMT_YUV420P16LE:\ncase PIX_FMT_YUV422P16LE:\ncase PIX_FMT_YUV444P16LE:\ncase PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break;",
"#else\ncase PIX_FMT_YUV444P9BE:\ncase PIX_FMT_YUV422P9BE:\ncase PIX_FMT_YUV420P9BE:\ncase PIX_FMT_YUV444P10BE:\ncase PIX_FMT_YUV422P10BE:\ncase PIX_FMT_YUV420P10BE:\ncase PIX_FMT_YUV420P16BE:\ncase PIX_FMT_YUV422P16BE:\ncase PIX_FMT_YUV444P16BE:\ncase PIX_FMT_GRAY16BE: c->lumToYV12 = bswap16Y_c; break;",
"#endif\ncase PIX_FMT_YUYV422 :\ncase PIX_FMT_Y400A : c->lumToYV12 = yuy2ToY_c; break;",
"case PIX_FMT_UYVY422 : c->lumToYV12 = uyvyToY_c; break;",
"case PIX_FMT_BGR24 : c->lumToYV12 = bgr24ToY_c; break;",
"case PIX_FMT_BGR565LE : c->lumToYV12 = bgr16leToY_c; break;",
"case PIX_FMT_BGR565BE : c->lumToYV12 = bgr16beToY_c; break;",
"case PIX_FMT_BGR555LE : c->lumToYV12 = bgr15leToY_c; break;",
"case PIX_FMT_BGR555BE : c->lumToYV12 = bgr15beToY_c; break;",
"case PIX_FMT_BGR444LE : c->lumToYV12 = bgr12leToY_c; break;",
"case PIX_FMT_BGR444BE : c->lumToYV12 = bgr12beToY_c; break;",
"case PIX_FMT_RGB24 : c->lumToYV12 = rgb24ToY_c; break;",
"case PIX_FMT_RGB565LE : c->lumToYV12 = rgb16leToY_c; break;",
"case PIX_FMT_RGB565BE : c->lumToYV12 = rgb16beToY_c; break;",
"case PIX_FMT_RGB555LE : c->lumToYV12 = rgb15leToY_c; break;",
"case PIX_FMT_RGB555BE : c->lumToYV12 = rgb15beToY_c; break;",
"case PIX_FMT_RGB444LE : c->lumToYV12 = rgb12leToY_c; break;",
"case PIX_FMT_RGB444BE : c->lumToYV12 = rgb12beToY_c; break;",
"case PIX_FMT_RGB8 :\ncase PIX_FMT_BGR8 :\ncase PIX_FMT_PAL8 :\ncase PIX_FMT_BGR4_BYTE:\ncase PIX_FMT_RGB4_BYTE: c->lumToYV12 = palToY_c; break;",
"case PIX_FMT_MONOBLACK: c->lumToYV12 = monoblack2Y_c; break;",
"case PIX_FMT_MONOWHITE: c->lumToYV12 = monowhite2Y_c; break;",
"case PIX_FMT_RGB32 : c->lumToYV12 = bgr32ToY_c; break;",
"case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break;",
"case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break;",
"case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break;",
"case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break;",
"case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break;",
"case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break;",
"case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break;",
"case PIX_FMT_RGBA64BE:c->lumToYV12 = rgb64BEToY_c; break;",
"case PIX_FMT_RGBA64LE:c->lumToYV12 = rgb64LEToY_c; break;",
"}",
"if (c->alpPixBuf) {",
"switch (VAR_0) {",
"case PIX_FMT_RGBA64LE:\ncase PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;",
"case PIX_FMT_BGRA:\ncase PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break;",
"case PIX_FMT_ABGR:\ncase PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break;",
"case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break;",
"case PIX_FMT_PAL8 : c->alpToYV12 = palToA_c; 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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23,
25,
27,
29
],
[
31,
33,
35
],
[
37,
39,
41
],
[
43
],
[
45,
47,
49,
51,
53,
55,
57,
59,
61,
63
],
[
65,
67,
69,
71,
73,
75,
77,
79,
81,
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
201
],
[
203
],
[
205
],
[
207,
209,
211
],
[
213,
215,
217
],
[
219
],
[
221,
223,
225,
227,
229,
231,
233,
235,
237,
239,
241
],
[
243,
245,
247,
249,
251,
253,
255,
257,
259,
261,
263
],
[
265,
267,
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301,
303,
305,
307,
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341,
343
],
[
345,
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
]
] |
1,943 | static uint32_t pcie_mmcfg_data_read(PCIBus *s, uint32_t addr, int len)
{
PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);
if (!pci_dev) {
return ~0x0;
}
return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),
pci_config_size(pci_dev), len);
}
| true | qemu | 43e86c8f5b6d9f6279e20dede4e1f7829bdc43b7 | static uint32_t pcie_mmcfg_data_read(PCIBus *s, uint32_t addr, int len)
{
PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);
if (!pci_dev) {
return ~0x0;
}
return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),
pci_config_size(pci_dev), len);
}
| {
"code": [
"static uint32_t pcie_mmcfg_data_read(PCIBus *s, uint32_t addr, int len)",
" PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);",
" return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),",
" pci_config_size(pci_dev), len);"
],
"line_no": [
1,
5,
15,
17
]
} | static uint32_t FUNC_0(PCIBus *s, uint32_t addr, int len)
{
PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);
if (!pci_dev) {
return ~0x0;
}
return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),
pci_config_size(pci_dev), len);
}
| [
"static uint32_t FUNC_0(PCIBus *s, uint32_t addr, int len)\n{",
"PCIDevice *pci_dev = pcie_dev_find_by_mmcfg_addr(s, addr);",
"if (!pci_dev) {",
"return ~0x0;",
"}",
"return pci_host_config_read_common(pci_dev, PCIE_MMCFG_CONFOFFSET(addr),\npci_config_size(pci_dev), len);",
"}"
] | [
1,
1,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19
]
] |
1,944 | int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
uint8_t *data, size_t size)
{
AVPacketSideData *sd, *tmp;
int i;
for (i = 0; i < st->nb_side_data; i++) {
sd = &st->side_data[i];
if (sd->type == type) {
av_freep(&sd->data);
sd->data = data;
sd->size = size;
return 0;
}
}
tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
if (!tmp) {
return AVERROR(ENOMEM);
}
st->side_data = tmp;
st->nb_side_data++;
sd = &st->side_data[st->nb_side_data - 1];
sd->type = type;
sd->data = data;
sd->size = size;
return 0;
}
| true | FFmpeg | 0ffea3565700c9b3093ead285f729bb319a2163e | int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
uint8_t *data, size_t size)
{
AVPacketSideData *sd, *tmp;
int i;
for (i = 0; i < st->nb_side_data; i++) {
sd = &st->side_data[i];
if (sd->type == type) {
av_freep(&sd->data);
sd->data = data;
sd->size = size;
return 0;
}
}
tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
if (!tmp) {
return AVERROR(ENOMEM);
}
st->side_data = tmp;
st->nb_side_data++;
sd = &st->side_data[st->nb_side_data - 1];
sd->type = type;
sd->data = data;
sd->size = size;
return 0;
}
| {
"code": [
" tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));"
],
"line_no": [
35
]
} | int FUNC_0(AVStream *VAR_0, enum AVPacketSideDataType VAR_1,
uint8_t *VAR_2, size_t VAR_3)
{
AVPacketSideData *sd, *tmp;
int VAR_4;
for (VAR_4 = 0; VAR_4 < VAR_0->nb_side_data; VAR_4++) {
sd = &VAR_0->side_data[VAR_4];
if (sd->VAR_1 == VAR_1) {
av_freep(&sd->VAR_2);
sd->VAR_2 = VAR_2;
sd->VAR_3 = VAR_3;
return 0;
}
}
tmp = av_realloc_array(VAR_0->side_data, VAR_0->nb_side_data + 1, sizeof(*tmp));
if (!tmp) {
return AVERROR(ENOMEM);
}
VAR_0->side_data = tmp;
VAR_0->nb_side_data++;
sd = &VAR_0->side_data[VAR_0->nb_side_data - 1];
sd->VAR_1 = VAR_1;
sd->VAR_2 = VAR_2;
sd->VAR_3 = VAR_3;
return 0;
}
| [
"int FUNC_0(AVStream *VAR_0, enum AVPacketSideDataType VAR_1,\nuint8_t *VAR_2, size_t VAR_3)\n{",
"AVPacketSideData *sd, *tmp;",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < VAR_0->nb_side_data; VAR_4++) {",
"sd = &VAR_0->side_data[VAR_4];",
"if (sd->VAR_1 == VAR_1) {",
"av_freep(&sd->VAR_2);",
"sd->VAR_2 = VAR_2;",
"sd->VAR_3 = VAR_3;",
"return 0;",
"}",
"}",
"tmp = av_realloc_array(VAR_0->side_data, VAR_0->nb_side_data + 1, sizeof(*tmp));",
"if (!tmp) {",
"return AVERROR(ENOMEM);",
"}",
"VAR_0->side_data = tmp;",
"VAR_0->nb_side_data++;",
"sd = &VAR_0->side_data[VAR_0->nb_side_data - 1];",
"sd->VAR_1 = VAR_1;",
"sd->VAR_2 = VAR_2;",
"sd->VAR_3 = VAR_3;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
] |
1,947 | static void qemu_announce_self_once(void *opaque)
{
int i, len;
VLANState *vlan;
VLANClientState *vc;
uint8_t buf[256];
static int count = SELF_ANNOUNCE_ROUNDS;
QEMUTimer *timer = *(QEMUTimer **)opaque;
for (i = 0; i < MAX_NICS; i++) {
if (!nd_table[i].used)
continue;
len = announce_self_create(buf, nd_table[i].macaddr);
vlan = nd_table[i].vlan;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
vc->receive(vc, buf, len);
}
}
if (count--) {
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);
} else {
qemu_del_timer(timer);
qemu_free_timer(timer);
}
}
| true | qemu | 18995b9808dc48897bda6ed93ce3e978191f7251 | static void qemu_announce_self_once(void *opaque)
{
int i, len;
VLANState *vlan;
VLANClientState *vc;
uint8_t buf[256];
static int count = SELF_ANNOUNCE_ROUNDS;
QEMUTimer *timer = *(QEMUTimer **)opaque;
for (i = 0; i < MAX_NICS; i++) {
if (!nd_table[i].used)
continue;
len = announce_self_create(buf, nd_table[i].macaddr);
vlan = nd_table[i].vlan;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
vc->receive(vc, buf, len);
}
}
if (count--) {
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);
} else {
qemu_del_timer(timer);
qemu_free_timer(timer);
}
}
| {
"code": [
" uint8_t buf[256];",
" if (count--) {",
"\t qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);"
],
"line_no": [
11,
37,
39
]
} | static void FUNC_0(void *VAR_0)
{
int VAR_1, VAR_2;
VLANState *vlan;
VLANClientState *vc;
uint8_t buf[256];
static int VAR_3 = SELF_ANNOUNCE_ROUNDS;
QEMUTimer *timer = *(QEMUTimer **)VAR_0;
for (VAR_1 = 0; VAR_1 < MAX_NICS; VAR_1++) {
if (!nd_table[VAR_1].used)
continue;
VAR_2 = announce_self_create(buf, nd_table[VAR_1].macaddr);
vlan = nd_table[VAR_1].vlan;
QTAILQ_FOREACH(vc, &vlan->clients, next) {
vc->receive(vc, buf, VAR_2);
}
}
if (VAR_3--) {
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);
} else {
qemu_del_timer(timer);
qemu_free_timer(timer);
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"int VAR_1, VAR_2;",
"VLANState *vlan;",
"VLANClientState *vc;",
"uint8_t buf[256];",
"static int VAR_3 = SELF_ANNOUNCE_ROUNDS;",
"QEMUTimer *timer = *(QEMUTimer **)VAR_0;",
"for (VAR_1 = 0; VAR_1 < MAX_NICS; VAR_1++) {",
"if (!nd_table[VAR_1].used)\ncontinue;",
"VAR_2 = announce_self_create(buf, nd_table[VAR_1].macaddr);",
"vlan = nd_table[VAR_1].vlan;",
"QTAILQ_FOREACH(vc, &vlan->clients, next) {",
"vc->receive(vc, buf, VAR_2);",
"}",
"}",
"if (VAR_3--) {",
"qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100);",
"} else {",
"qemu_del_timer(timer);",
"qemu_free_timer(timer);",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
]
] |
1,948 | static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn)
{
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
AddressSpace *dma_as;
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
if (!bus->devices[devfn])
goto found;
}
error_report("PCI: no slot/function available for %s, all in use", name);
return NULL;
found: ;
} else if (bus->devices[devfn]) {
error_report("PCI: slot %d function %d not available for %s, in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
return NULL;
}
pci_dev->bus = bus;
dma_as = pci_device_iommu_address_space(pci_dev);
memory_region_init_alias(&pci_dev->bus_master_enable_region,
OBJECT(pci_dev), "bus master",
dma_as->root, 0, memory_region_size(dma_as->root));
memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
name);
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
pci_config_set_device_id(pci_dev->config, pc->device_id);
pci_config_set_revision(pci_dev->config, pc->revision);
pci_config_set_class(pci_dev->config, pc->class_id);
if (!pc->is_bridge) {
if (pc->subsystem_vendor_id || pc->subsystem_id) {
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
pc->subsystem_vendor_id);
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
pc->subsystem_id);
} else {
pci_set_default_subsystem_id(pci_dev);
}
} else {
/* subsystem_vendor_id/subsystem_id are only for header type 0 */
assert(!pc->subsystem_vendor_id);
assert(!pc->subsystem_id);
}
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
pci_init_w1cmask(pci_dev);
if (pc->is_bridge) {
pci_init_mask_bridge(pci_dev);
}
if (pci_init_multifunction(bus, pci_dev)) {
pci_config_free(pci_dev);
return NULL;
}
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->version_id = 2; /* Current pci device vmstate version */
return pci_dev;
}
| true | qemu | 306077640a652e090779498aadbeb0c605feaacd | static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn)
{
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
AddressSpace *dma_as;
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
if (!bus->devices[devfn])
goto found;
}
error_report("PCI: no slot/function available for %s, all in use", name);
return NULL;
found: ;
} else if (bus->devices[devfn]) {
error_report("PCI: slot %d function %d not available for %s, in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
return NULL;
}
pci_dev->bus = bus;
dma_as = pci_device_iommu_address_space(pci_dev);
memory_region_init_alias(&pci_dev->bus_master_enable_region,
OBJECT(pci_dev), "bus master",
dma_as->root, 0, memory_region_size(dma_as->root));
memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
name);
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
pci_config_set_device_id(pci_dev->config, pc->device_id);
pci_config_set_revision(pci_dev->config, pc->revision);
pci_config_set_class(pci_dev->config, pc->class_id);
if (!pc->is_bridge) {
if (pc->subsystem_vendor_id || pc->subsystem_id) {
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
pc->subsystem_vendor_id);
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
pc->subsystem_id);
} else {
pci_set_default_subsystem_id(pci_dev);
}
} else {
assert(!pc->subsystem_vendor_id);
assert(!pc->subsystem_id);
}
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
pci_init_w1cmask(pci_dev);
if (pc->is_bridge) {
pci_init_mask_bridge(pci_dev);
}
if (pci_init_multifunction(bus, pci_dev)) {
pci_config_free(pci_dev);
return NULL;
}
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->version_id = 2;
return pci_dev;
}
| {
"code": [
" pci_config_free(pci_dev);"
],
"line_no": [
129
]
} | static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn)
{
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
AddressSpace *dma_as;
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
if (!bus->devices[devfn])
goto found;
}
error_report("PCI: no slot/function available for %s, all in use", name);
return NULL;
found: ;
} else if (bus->devices[devfn]) {
error_report("PCI: slot %d function %d not available for %s, in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
return NULL;
}
pci_dev->bus = bus;
dma_as = pci_device_iommu_address_space(pci_dev);
memory_region_init_alias(&pci_dev->bus_master_enable_region,
OBJECT(pci_dev), "bus master",
dma_as->root, 0, memory_region_size(dma_as->root));
memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
name);
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);
pci_config_set_device_id(pci_dev->config, pc->device_id);
pci_config_set_revision(pci_dev->config, pc->revision);
pci_config_set_class(pci_dev->config, pc->class_id);
if (!pc->is_bridge) {
if (pc->subsystem_vendor_id || pc->subsystem_id) {
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
pc->subsystem_vendor_id);
pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
pc->subsystem_id);
} else {
pci_set_default_subsystem_id(pci_dev);
}
} else {
assert(!pc->subsystem_vendor_id);
assert(!pc->subsystem_id);
}
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
pci_init_w1cmask(pci_dev);
if (pc->is_bridge) {
pci_init_mask_bridge(pci_dev);
}
if (pci_init_multifunction(bus, pci_dev)) {
pci_config_free(pci_dev);
return NULL;
}
if (!config_read)
config_read = pci_default_read_config;
if (!config_write)
config_write = pci_default_write_config;
pci_dev->config_read = config_read;
pci_dev->config_write = config_write;
bus->devices[devfn] = pci_dev;
pci_dev->version_id = 2;
return pci_dev;
}
| [
"static PCIDevice *FUNC_0(PCIDevice *pci_dev, PCIBus *bus,\nconst char *name, int devfn)\n{",
"PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);",
"PCIConfigReadFunc *config_read = pc->config_read;",
"PCIConfigWriteFunc *config_write = pc->config_write;",
"AddressSpace *dma_as;",
"if (devfn < 0) {",
"for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);",
"devfn += PCI_FUNC_MAX) {",
"if (!bus->devices[devfn])\ngoto found;",
"}",
"error_report(\"PCI: no slot/function available for %s, all in use\", name);",
"return NULL;",
"found: ;",
"} else if (bus->devices[devfn]) {",
"error_report(\"PCI: slot %d function %d not available for %s, in use by %s\",\nPCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);",
"return NULL;",
"}",
"pci_dev->bus = bus;",
"dma_as = pci_device_iommu_address_space(pci_dev);",
"memory_region_init_alias(&pci_dev->bus_master_enable_region,\nOBJECT(pci_dev), \"bus master\",\ndma_as->root, 0, memory_region_size(dma_as->root));",
"memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);",
"address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,\nname);",
"pci_dev->devfn = devfn;",
"pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);",
"pci_dev->irq_state = 0;",
"pci_config_alloc(pci_dev);",
"pci_config_set_vendor_id(pci_dev->config, pc->vendor_id);",
"pci_config_set_device_id(pci_dev->config, pc->device_id);",
"pci_config_set_revision(pci_dev->config, pc->revision);",
"pci_config_set_class(pci_dev->config, pc->class_id);",
"if (!pc->is_bridge) {",
"if (pc->subsystem_vendor_id || pc->subsystem_id) {",
"pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,\npc->subsystem_vendor_id);",
"pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,\npc->subsystem_id);",
"} else {",
"pci_set_default_subsystem_id(pci_dev);",
"}",
"} else {",
"assert(!pc->subsystem_vendor_id);",
"assert(!pc->subsystem_id);",
"}",
"pci_init_cmask(pci_dev);",
"pci_init_wmask(pci_dev);",
"pci_init_w1cmask(pci_dev);",
"if (pc->is_bridge) {",
"pci_init_mask_bridge(pci_dev);",
"}",
"if (pci_init_multifunction(bus, pci_dev)) {",
"pci_config_free(pci_dev);",
"return NULL;",
"}",
"if (!config_read)\nconfig_read = pci_default_read_config;",
"if (!config_write)\nconfig_write = pci_default_write_config;",
"pci_dev->config_read = config_read;",
"pci_dev->config_write = config_write;",
"bus->devices[devfn] = pci_dev;",
"pci_dev->version_id = 2;",
"return pci_dev;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53,
55,
57
],
[
59
],
[
61,
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137,
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
]
] |
1,949 | static void avc_luma_vt_8w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height)
{
int32_t loop_cnt;
int16_t filt_const0 = 0xfb01;
int16_t filt_const1 = 0x1414;
int16_t filt_const2 = 0x1fb;
v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10;
v16i8 src10_r, src32_r, src76_r, src98_r;
v16i8 src21_r, src43_r, src87_r, src109_r;
v8i16 out0_r, out1_r, out2_r, out3_r;
v16i8 filt0, filt1, filt2;
v16u8 out0, out1;
filt0 = (v16i8) __msa_fill_h(filt_const0);
filt1 = (v16i8) __msa_fill_h(filt_const1);
filt2 = (v16i8) __msa_fill_h(filt_const2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3,
src10_r, src21_r, src32_r, src43_r);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src, src_stride, src7, src8, src9, src10);
src += (4 * src_stride);
XORI_B4_128_SB(src7, src8, src9, src10);
ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9,
src76_r, src87_r, src98_r, src109_r);
out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2);
out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2);
out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2);
out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2);
SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5);
SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
out0 = PCKEV_XORI128_UB(out0_r, out1_r);
out1 = PCKEV_XORI128_UB(out2_r, out3_r);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
src10_r = src76_r;
src32_r = src98_r;
src21_r = src87_r;
src43_r = src109_r;
src4 = src10;
}
}
| false | FFmpeg | 662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a | static void avc_luma_vt_8w_msa(const uint8_t *src, int32_t src_stride,
uint8_t *dst, int32_t dst_stride,
int32_t height)
{
int32_t loop_cnt;
int16_t filt_const0 = 0xfb01;
int16_t filt_const1 = 0x1414;
int16_t filt_const2 = 0x1fb;
v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10;
v16i8 src10_r, src32_r, src76_r, src98_r;
v16i8 src21_r, src43_r, src87_r, src109_r;
v8i16 out0_r, out1_r, out2_r, out3_r;
v16i8 filt0, filt1, filt2;
v16u8 out0, out1;
filt0 = (v16i8) __msa_fill_h(filt_const0);
filt1 = (v16i8) __msa_fill_h(filt_const1);
filt2 = (v16i8) __msa_fill_h(filt_const2);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3,
src10_r, src21_r, src32_r, src43_r);
for (loop_cnt = (height >> 2); loop_cnt--;) {
LD_SB4(src, src_stride, src7, src8, src9, src10);
src += (4 * src_stride);
XORI_B4_128_SB(src7, src8, src9, src10);
ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9,
src76_r, src87_r, src98_r, src109_r);
out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2);
out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2);
out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2);
out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2);
SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5);
SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
out0 = PCKEV_XORI128_UB(out0_r, out1_r);
out1 = PCKEV_XORI128_UB(out2_r, out3_r);
ST8x4_UB(out0, out1, dst, dst_stride);
dst += (4 * dst_stride);
src10_r = src76_r;
src32_r = src98_r;
src21_r = src87_r;
src43_r = src109_r;
src4 = src10;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,
uint8_t *VAR_2, int32_t VAR_3,
int32_t VAR_4)
{
int32_t loop_cnt;
int16_t filt_const0 = 0xfb01;
int16_t filt_const1 = 0x1414;
int16_t filt_const2 = 0x1fb;
v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10;
v16i8 src10_r, src32_r, src76_r, src98_r;
v16i8 src21_r, src43_r, src87_r, src109_r;
v8i16 out0_r, out1_r, out2_r, out3_r;
v16i8 filt0, filt1, filt2;
v16u8 out0, out1;
filt0 = (v16i8) __msa_fill_h(filt_const0);
filt1 = (v16i8) __msa_fill_h(filt_const1);
filt2 = (v16i8) __msa_fill_h(filt_const2);
LD_SB5(VAR_0, VAR_1, src0, src1, src2, src3, src4);
VAR_0 += (5 * VAR_1);
XORI_B5_128_SB(src0, src1, src2, src3, src4);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3,
src10_r, src21_r, src32_r, src43_r);
for (loop_cnt = (VAR_4 >> 2); loop_cnt--;) {
LD_SB4(VAR_0, VAR_1, src7, src8, src9, src10);
VAR_0 += (4 * VAR_1);
XORI_B4_128_SB(src7, src8, src9, src10);
ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9,
src76_r, src87_r, src98_r, src109_r);
out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2);
out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2);
out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2);
out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2);
SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5);
SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
out0 = PCKEV_XORI128_UB(out0_r, out1_r);
out1 = PCKEV_XORI128_UB(out2_r, out3_r);
ST8x4_UB(out0, out1, VAR_2, VAR_3);
VAR_2 += (4 * VAR_3);
src10_r = src76_r;
src32_r = src98_r;
src21_r = src87_r;
src43_r = src109_r;
src4 = src10;
}
}
| [
"static void FUNC_0(const uint8_t *VAR_0, int32_t VAR_1,\nuint8_t *VAR_2, int32_t VAR_3,\nint32_t VAR_4)\n{",
"int32_t loop_cnt;",
"int16_t filt_const0 = 0xfb01;",
"int16_t filt_const1 = 0x1414;",
"int16_t filt_const2 = 0x1fb;",
"v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10;",
"v16i8 src10_r, src32_r, src76_r, src98_r;",
"v16i8 src21_r, src43_r, src87_r, src109_r;",
"v8i16 out0_r, out1_r, out2_r, out3_r;",
"v16i8 filt0, filt1, filt2;",
"v16u8 out0, out1;",
"filt0 = (v16i8) __msa_fill_h(filt_const0);",
"filt1 = (v16i8) __msa_fill_h(filt_const1);",
"filt2 = (v16i8) __msa_fill_h(filt_const2);",
"LD_SB5(VAR_0, VAR_1, src0, src1, src2, src3, src4);",
"VAR_0 += (5 * VAR_1);",
"XORI_B5_128_SB(src0, src1, src2, src3, src4);",
"ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3,\nsrc10_r, src21_r, src32_r, src43_r);",
"for (loop_cnt = (VAR_4 >> 2); loop_cnt--;) {",
"LD_SB4(VAR_0, VAR_1, src7, src8, src9, src10);",
"VAR_0 += (4 * VAR_1);",
"XORI_B4_128_SB(src7, src8, src9, src10);",
"ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9,\nsrc76_r, src87_r, src98_r, src109_r);",
"out0_r = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2);",
"out1_r = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2);",
"out2_r = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2);",
"out3_r = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2);",
"SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, 5);",
"SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);",
"out0 = PCKEV_XORI128_UB(out0_r, out1_r);",
"out1 = PCKEV_XORI128_UB(out2_r, out3_r);",
"ST8x4_UB(out0, out1, VAR_2, VAR_3);",
"VAR_2 += (4 * VAR_3);",
"src10_r = src76_r;",
"src32_r = src98_r;",
"src21_r = src87_r;",
"src43_r = src109_r;",
"src4 = src10;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
]
] |
1,950 | static bool xhci_er_full(void *opaque, int version_id)
{
struct XHCIInterrupter *intr = opaque;
return intr->er_full;
}
| true | qemu | 898248a32915024a4f01ce4f0c3519509fb703cb | static bool xhci_er_full(void *opaque, int version_id)
{
struct XHCIInterrupter *intr = opaque;
return intr->er_full;
}
| {
"code": [
" struct XHCIInterrupter *intr = opaque;",
" return intr->er_full;"
],
"line_no": [
5,
7
]
} | static bool FUNC_0(void *opaque, int version_id)
{
struct XHCIInterrupter *VAR_0 = opaque;
return VAR_0->er_full;
}
| [
"static bool FUNC_0(void *opaque, int version_id)\n{",
"struct XHCIInterrupter *VAR_0 = opaque;",
"return VAR_0->er_full;",
"}"
] | [
0,
1,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
]
] |
1,951 | bool st_change_trace_event_state(const char *tname, bool tstate)
{
TraceEvent *tp;
tp = find_trace_event_by_name(tname);
if (tp) {
tp->state = tstate;
return true;
}
return false;
}
| true | qemu | 0b5538c300a56c3cfb33022840fe0b4968147e7a | bool st_change_trace_event_state(const char *tname, bool tstate)
{
TraceEvent *tp;
tp = find_trace_event_by_name(tname);
if (tp) {
tp->state = tstate;
return true;
}
return false;
}
| {
"code": [
"bool st_change_trace_event_state(const char *tname, bool tstate)",
" TraceEvent *tp;",
" tp = find_trace_event_by_name(tname);",
" if (tp) {",
" tp->state = tstate;",
" return true;",
" return false;"
],
"line_no": [
1,
5,
9,
11,
13,
15,
19
]
} | bool FUNC_0(const char *tname, bool tstate)
{
TraceEvent *tp;
tp = find_trace_event_by_name(tname);
if (tp) {
tp->state = tstate;
return true;
}
return false;
}
| [
"bool FUNC_0(const char *tname, bool tstate)\n{",
"TraceEvent *tp;",
"tp = find_trace_event_by_name(tname);",
"if (tp) {",
"tp->state = tstate;",
"return true;",
"}",
"return false;",
"}"
] | [
1,
1,
1,
1,
1,
1,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,952 | aio_read_f(int argc, char **argv)
{
int nr_iov, c;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
BlockDriverAIOCB *acb;
while ((c = getopt(argc, argv, "CP:qv")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'P':
ctx->Pflag = 1;
ctx->pattern = parse_pattern(optarg);
if (ctx->pattern < 0)
return 0;
break;
case 'q':
ctx->qflag = 1;
break;
case 'v':
ctx->vflag = 1;
break;
default:
free(ctx);
return command_usage(&aio_read_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_read_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab);
gettimeofday(&ctx->t1, NULL);
acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_read_done, ctx);
if (!acb) {
free(ctx->buf);
free(ctx);
return -EIO;
}
return 0;
}
| true | qemu | 1afec9138f848cfba517bd2d80167b27216b9df9 | aio_read_f(int argc, char **argv)
{
int nr_iov, c;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
BlockDriverAIOCB *acb;
while ((c = getopt(argc, argv, "CP:qv")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'P':
ctx->Pflag = 1;
ctx->pattern = parse_pattern(optarg);
if (ctx->pattern < 0)
return 0;
break;
case 'q':
ctx->qflag = 1;
break;
case 'v':
ctx->vflag = 1;
break;
default:
free(ctx);
return command_usage(&aio_read_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_read_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab);
gettimeofday(&ctx->t1, NULL);
acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_read_done, ctx);
if (!acb) {
free(ctx->buf);
free(ctx);
return -EIO;
}
return 0;
}
| {
"code": [
"\t\t\tif (ctx->pattern < 0)"
],
"line_no": [
29
]
} | FUNC_0(int VAR_0, char **VAR_1)
{
int VAR_2, VAR_3;
struct aio_ctx *VAR_4 = calloc(1, sizeof(struct aio_ctx));
BlockDriverAIOCB *acb;
while ((VAR_3 = getopt(VAR_0, VAR_1, "CP:qv")) != EOF) {
switch (VAR_3) {
case 'C':
VAR_4->Cflag = 1;
break;
case 'P':
VAR_4->Pflag = 1;
VAR_4->pattern = parse_pattern(optarg);
if (VAR_4->pattern < 0)
return 0;
break;
case 'q':
VAR_4->qflag = 1;
break;
case 'v':
VAR_4->vflag = 1;
break;
default:
free(VAR_4);
return command_usage(&aio_read_cmd);
}
}
if (optind > VAR_0 - 2) {
free(VAR_4);
return command_usage(&aio_read_cmd);
}
VAR_4->offset = cvtnum(VAR_1[optind]);
if (VAR_4->offset < 0) {
printf("non-numeric length argument -- %s\n", VAR_1[optind]);
free(VAR_4);
return 0;
}
optind++;
if (VAR_4->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
VAR_4->offset);
free(VAR_4);
return 0;
}
VAR_2 = VAR_0 - optind;
VAR_4->buf = create_iovec(&VAR_4->qiov, &VAR_1[optind], VAR_2, 0xab);
gettimeofday(&VAR_4->t1, NULL);
acb = bdrv_aio_readv(bs, VAR_4->offset >> 9, &VAR_4->qiov,
VAR_4->qiov.size >> 9, aio_read_done, VAR_4);
if (!acb) {
free(VAR_4->buf);
free(VAR_4);
return -EIO;
}
return 0;
}
| [
"FUNC_0(int VAR_0, char **VAR_1)\n{",
"int VAR_2, VAR_3;",
"struct aio_ctx *VAR_4 = calloc(1, sizeof(struct aio_ctx));",
"BlockDriverAIOCB *acb;",
"while ((VAR_3 = getopt(VAR_0, VAR_1, \"CP:qv\")) != EOF) {",
"switch (VAR_3) {",
"case 'C':\nVAR_4->Cflag = 1;",
"break;",
"case 'P':\nVAR_4->Pflag = 1;",
"VAR_4->pattern = parse_pattern(optarg);",
"if (VAR_4->pattern < 0)\nreturn 0;",
"break;",
"case 'q':\nVAR_4->qflag = 1;",
"break;",
"case 'v':\nVAR_4->vflag = 1;",
"break;",
"default:\nfree(VAR_4);",
"return command_usage(&aio_read_cmd);",
"}",
"}",
"if (optind > VAR_0 - 2) {",
"free(VAR_4);",
"return command_usage(&aio_read_cmd);",
"}",
"VAR_4->offset = cvtnum(VAR_1[optind]);",
"if (VAR_4->offset < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", VAR_1[optind]);",
"free(VAR_4);",
"return 0;",
"}",
"optind++;",
"if (VAR_4->offset & 0x1ff) {",
"printf(\"offset %\" PRId64 \" is not sector aligned\\n\",\nVAR_4->offset);",
"free(VAR_4);",
"return 0;",
"}",
"VAR_2 = VAR_0 - optind;",
"VAR_4->buf = create_iovec(&VAR_4->qiov, &VAR_1[optind], VAR_2, 0xab);",
"gettimeofday(&VAR_4->t1, NULL);",
"acb = bdrv_aio_readv(bs, VAR_4->offset >> 9, &VAR_4->qiov,\nVAR_4->qiov.size >> 9, aio_read_done, VAR_4);",
"if (!acb) {",
"free(VAR_4->buf);",
"free(VAR_4);",
"return -EIO;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
]
] |
1,953 | int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
{
int b, i, j;
int buffer1[LPC_ORDER];
int buffer2[LPC_ORDER];
int *bp1 = buffer1;
int *bp2 = buffer2;
for (i=0; i < LPC_ORDER; i++)
buffer2[i] = coefs[i];
refl[LPC_ORDER-1] = bp2[LPC_ORDER-1];
if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) {
av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 1;
}
for (i = LPC_ORDER-2; i >= 0; i--) {
b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12);
if (!b)
b = -2;
b = 0x1000000 / b;
for (j=0; j <= i; j++) {
#if CONFIG_FTRAPV
int a = bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12);
if((int)(a*(unsigned)b) != a*(int64_t)b)
return 1;
#endif
bp1[j] = ((bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12)) * b) >> 12;
}
if ((unsigned) bp1[i] + 0x1000 > 0x1fff)
return 1;
refl[i] = bp1[i];
FFSWAP(int *, bp1, bp2);
}
return 0;
}
| true | FFmpeg | 7c845450d2daa0d066045cf94ab51cb496f1b824 | int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
{
int b, i, j;
int buffer1[LPC_ORDER];
int buffer2[LPC_ORDER];
int *bp1 = buffer1;
int *bp2 = buffer2;
for (i=0; i < LPC_ORDER; i++)
buffer2[i] = coefs[i];
refl[LPC_ORDER-1] = bp2[LPC_ORDER-1];
if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) {
av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 1;
}
for (i = LPC_ORDER-2; i >= 0; i--) {
b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12);
if (!b)
b = -2;
b = 0x1000000 / b;
for (j=0; j <= i; j++) {
#if CONFIG_FTRAPV
int a = bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12);
if((int)(a*(unsigned)b) != a*(int64_t)b)
return 1;
#endif
bp1[j] = ((bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12)) * b) >> 12;
}
if ((unsigned) bp1[i] + 0x1000 > 0x1fff)
return 1;
refl[i] = bp1[i];
FFSWAP(int *, bp1, bp2);
}
return 0;
}
| {
"code": [
" bp1[j] = ((bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12)) * b) >> 12;"
],
"line_no": [
63
]
} | int FUNC_0(int *VAR_0, const int16_t *VAR_1, AVCodecContext *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
int VAR_6[LPC_ORDER];
int VAR_7[LPC_ORDER];
int *VAR_8 = VAR_6;
int *VAR_9 = VAR_7;
for (VAR_4=0; VAR_4 < LPC_ORDER; VAR_4++)
VAR_7[VAR_4] = VAR_1[VAR_4];
VAR_0[LPC_ORDER-1] = VAR_9[LPC_ORDER-1];
if ((unsigned) VAR_9[LPC_ORDER-1] + 0x1000 > 0x1fff) {
av_log(VAR_2, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 1;
}
for (VAR_4 = LPC_ORDER-2; VAR_4 >= 0; VAR_4--) {
VAR_3 = 0x1000-((VAR_9[VAR_4+1] * VAR_9[VAR_4+1]) >> 12);
if (!VAR_3)
VAR_3 = -2;
VAR_3 = 0x1000000 / VAR_3;
for (VAR_5=0; VAR_5 <= VAR_4; VAR_5++) {
#if CONFIG_FTRAPV
int a = VAR_9[VAR_5] - ((VAR_0[VAR_4+1] * VAR_9[VAR_4-VAR_5]) >> 12);
if((int)(a*(unsigned)VAR_3) != a*(int64_t)VAR_3)
return 1;
#endif
VAR_8[VAR_5] = ((VAR_9[VAR_5] - ((VAR_0[VAR_4+1] * VAR_9[VAR_4-VAR_5]) >> 12)) * VAR_3) >> 12;
}
if ((unsigned) VAR_8[VAR_4] + 0x1000 > 0x1fff)
return 1;
VAR_0[VAR_4] = VAR_8[VAR_4];
FFSWAP(int *, VAR_8, VAR_9);
}
return 0;
}
| [
"int FUNC_0(int *VAR_0, const int16_t *VAR_1, AVCodecContext *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"int VAR_6[LPC_ORDER];",
"int VAR_7[LPC_ORDER];",
"int *VAR_8 = VAR_6;",
"int *VAR_9 = VAR_7;",
"for (VAR_4=0; VAR_4 < LPC_ORDER; VAR_4++)",
"VAR_7[VAR_4] = VAR_1[VAR_4];",
"VAR_0[LPC_ORDER-1] = VAR_9[LPC_ORDER-1];",
"if ((unsigned) VAR_9[LPC_ORDER-1] + 0x1000 > 0x1fff) {",
"av_log(VAR_2, AV_LOG_ERROR, \"Overflow. Broken sample?\\n\");",
"return 1;",
"}",
"for (VAR_4 = LPC_ORDER-2; VAR_4 >= 0; VAR_4--) {",
"VAR_3 = 0x1000-((VAR_9[VAR_4+1] * VAR_9[VAR_4+1]) >> 12);",
"if (!VAR_3)\nVAR_3 = -2;",
"VAR_3 = 0x1000000 / VAR_3;",
"for (VAR_5=0; VAR_5 <= VAR_4; VAR_5++) {",
"#if CONFIG_FTRAPV\nint a = VAR_9[VAR_5] - ((VAR_0[VAR_4+1] * VAR_9[VAR_4-VAR_5]) >> 12);",
"if((int)(a*(unsigned)VAR_3) != a*(int64_t)VAR_3)\nreturn 1;",
"#endif\nVAR_8[VAR_5] = ((VAR_9[VAR_5] - ((VAR_0[VAR_4+1] * VAR_9[VAR_4-VAR_5]) >> 12)) * VAR_3) >> 12;",
"}",
"if ((unsigned) VAR_8[VAR_4] + 0x1000 > 0x1fff)\nreturn 1;",
"VAR_0[VAR_4] = VAR_8[VAR_4];",
"FFSWAP(int *, VAR_8, VAR_9);",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53,
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
69,
71
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
1,954 | void cpu_loop(CPUAlphaState *env)
{
int trapnr;
target_siginfo_t info;
abi_long sysret;
while (1) {
trapnr = cpu_alpha_exec (env);
/* All of the traps imply a transition through PALcode, which
implies an REI instruction has been executed. Which means
that the intr_flag should be cleared. */
env->intr_flag = 0;
switch (trapnr) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_SMP_INTERRUPT:
case EXCP_CLK_INTERRUPT:
case EXCP_DEV_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_MMFAULT:
env->lock_addr = -1;
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = (page_get_flags(env->trap_arg0) & PAGE_VALID
? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR);
info._sifields._sigfault._addr = env->trap_arg0;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_UNALIGN:
env->lock_addr = -1;
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = env->trap_arg0;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_OPCDEC:
do_sigill:
env->lock_addr = -1;
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLOPC;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_ARITH:
env->lock_addr = -1;
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTINV;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_FEN:
/* No-op. Linux simply re-enables the FPU. */
break;
case EXCP_CALL_PAL:
env->lock_addr = -1;
switch (env->error_code) {
case 0x80:
/* BPT */
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case 0x81:
/* BUGCHK */
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = 0;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case 0x83:
/* CALLSYS */
trapnr = env->ir[IR_V0];
sysret = do_syscall(env, trapnr,
env->ir[IR_A0], env->ir[IR_A1],
env->ir[IR_A2], env->ir[IR_A3],
env->ir[IR_A4], env->ir[IR_A5],
0, 0);
if (trapnr == TARGET_NR_sigreturn
|| trapnr == TARGET_NR_rt_sigreturn) {
break;
}
/* Syscall writes 0 to V0 to bypass error check, similar
to how this is handled internal to Linux kernel. */
if (env->ir[IR_V0] == 0) {
env->ir[IR_V0] = sysret;
} else {
env->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);
env->ir[IR_A3] = (sysret < 0);
}
break;
case 0x86:
/* IMB */
/* ??? We can probably elide the code using page_unprotect
that is checking for self-modifying code. Instead we
could simply call tb_flush here. Until we work out the
changes required to turn off the extra write protection,
this can be a no-op. */
break;
case 0x9E:
/* RDUNIQUE */
/* Handled in the translator for usermode. */
abort();
case 0x9F:
/* WRUNIQUE */
/* Handled in the translator for usermode. */
abort();
case 0xAA:
/* GENTRAP */
info.si_signo = TARGET_SIGFPE;
switch (env->ir[IR_A0]) {
case TARGET_GEN_INTOVF:
info.si_code = TARGET_FPE_INTOVF;
break;
case TARGET_GEN_INTDIV:
info.si_code = TARGET_FPE_INTDIV;
break;
case TARGET_GEN_FLTOVF:
info.si_code = TARGET_FPE_FLTOVF;
break;
case TARGET_GEN_FLTUND:
info.si_code = TARGET_FPE_FLTUND;
break;
case TARGET_GEN_FLTINV:
info.si_code = TARGET_FPE_FLTINV;
break;
case TARGET_GEN_FLTINE:
info.si_code = TARGET_FPE_FLTRES;
break;
case TARGET_GEN_ROPRAND:
info.si_code = 0;
break;
default:
info.si_signo = TARGET_SIGTRAP;
info.si_code = 0;
break;
}
info.si_errno = 0;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
default:
goto do_sigill;
}
break;
case EXCP_DEBUG:
info.si_signo = gdb_handlesig (env, TARGET_SIGTRAP);
if (info.si_signo) {
env->lock_addr = -1;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_STL_C:
case EXCP_STQ_C:
do_store_exclusive(env, env->error_code, trapnr - EXCP_STL_C);
break;
case EXCP_INTERRUPT:
/* Just indicate that signals should be handled asap. */
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| true | qemu | 0e141977e690ee6cd06e5a842eae0be291297efa | void cpu_loop(CPUAlphaState *env)
{
int trapnr;
target_siginfo_t info;
abi_long sysret;
while (1) {
trapnr = cpu_alpha_exec (env);
env->intr_flag = 0;
switch (trapnr) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_SMP_INTERRUPT:
case EXCP_CLK_INTERRUPT:
case EXCP_DEV_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_MMFAULT:
env->lock_addr = -1;
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = (page_get_flags(env->trap_arg0) & PAGE_VALID
? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR);
info._sifields._sigfault._addr = env->trap_arg0;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_UNALIGN:
env->lock_addr = -1;
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = env->trap_arg0;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_OPCDEC:
do_sigill:
env->lock_addr = -1;
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLOPC;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_ARITH:
env->lock_addr = -1;
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTINV;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case EXCP_FEN:
break;
case EXCP_CALL_PAL:
env->lock_addr = -1;
switch (env->error_code) {
case 0x80:
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case 0x81:
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = 0;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
case 0x83:
trapnr = env->ir[IR_V0];
sysret = do_syscall(env, trapnr,
env->ir[IR_A0], env->ir[IR_A1],
env->ir[IR_A2], env->ir[IR_A3],
env->ir[IR_A4], env->ir[IR_A5],
0, 0);
if (trapnr == TARGET_NR_sigreturn
|| trapnr == TARGET_NR_rt_sigreturn) {
break;
}
if (env->ir[IR_V0] == 0) {
env->ir[IR_V0] = sysret;
} else {
env->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);
env->ir[IR_A3] = (sysret < 0);
}
break;
case 0x86:
break;
case 0x9E:
abort();
case 0x9F:
abort();
case 0xAA:
info.si_signo = TARGET_SIGFPE;
switch (env->ir[IR_A0]) {
case TARGET_GEN_INTOVF:
info.si_code = TARGET_FPE_INTOVF;
break;
case TARGET_GEN_INTDIV:
info.si_code = TARGET_FPE_INTDIV;
break;
case TARGET_GEN_FLTOVF:
info.si_code = TARGET_FPE_FLTOVF;
break;
case TARGET_GEN_FLTUND:
info.si_code = TARGET_FPE_FLTUND;
break;
case TARGET_GEN_FLTINV:
info.si_code = TARGET_FPE_FLTINV;
break;
case TARGET_GEN_FLTINE:
info.si_code = TARGET_FPE_FLTRES;
break;
case TARGET_GEN_ROPRAND:
info.si_code = 0;
break;
default:
info.si_signo = TARGET_SIGTRAP;
info.si_code = 0;
break;
}
info.si_errno = 0;
info._sifields._sigfault._addr = env->pc;
queue_signal(env, info.si_signo, &info);
break;
default:
goto do_sigill;
}
break;
case EXCP_DEBUG:
info.si_signo = gdb_handlesig (env, TARGET_SIGTRAP);
if (info.si_signo) {
env->lock_addr = -1;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_STL_C:
case EXCP_STQ_C:
do_store_exclusive(env, env->error_code, trapnr - EXCP_STL_C);
break;
case EXCP_INTERRUPT:
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| {
"code": [
" if (env->ir[IR_V0] == 0) {",
" env->ir[IR_V0] = sysret;",
" } else {",
" env->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);",
" env->ir[IR_A3] = (sysret < 0);"
],
"line_no": [
199,
201,
203,
205,
207
]
} | void FUNC_0(CPUAlphaState *VAR_0)
{
int VAR_1;
target_siginfo_t info;
abi_long sysret;
while (1) {
VAR_1 = cpu_alpha_exec (VAR_0);
VAR_0->intr_flag = 0;
switch (VAR_1) {
case EXCP_RESET:
fprintf(stderr, "Reset requested. Exit\n");
exit(1);
break;
case EXCP_MCHK:
fprintf(stderr, "Machine check exception. Exit\n");
exit(1);
break;
case EXCP_SMP_INTERRUPT:
case EXCP_CLK_INTERRUPT:
case EXCP_DEV_INTERRUPT:
fprintf(stderr, "External interrupt. Exit\n");
exit(1);
break;
case EXCP_MMFAULT:
VAR_0->lock_addr = -1;
info.si_signo = TARGET_SIGSEGV;
info.si_errno = 0;
info.si_code = (page_get_flags(VAR_0->trap_arg0) & PAGE_VALID
? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR);
info._sifields._sigfault._addr = VAR_0->trap_arg0;
queue_signal(VAR_0, info.si_signo, &info);
break;
case EXCP_UNALIGN:
VAR_0->lock_addr = -1;
info.si_signo = TARGET_SIGBUS;
info.si_errno = 0;
info.si_code = TARGET_BUS_ADRALN;
info._sifields._sigfault._addr = VAR_0->trap_arg0;
queue_signal(VAR_0, info.si_signo, &info);
break;
case EXCP_OPCDEC:
do_sigill:
VAR_0->lock_addr = -1;
info.si_signo = TARGET_SIGILL;
info.si_errno = 0;
info.si_code = TARGET_ILL_ILLOPC;
info._sifields._sigfault._addr = VAR_0->pc;
queue_signal(VAR_0, info.si_signo, &info);
break;
case EXCP_ARITH:
VAR_0->lock_addr = -1;
info.si_signo = TARGET_SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTINV;
info._sifields._sigfault._addr = VAR_0->pc;
queue_signal(VAR_0, info.si_signo, &info);
break;
case EXCP_FEN:
break;
case EXCP_CALL_PAL:
VAR_0->lock_addr = -1;
switch (VAR_0->error_code) {
case 0x80:
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
info._sifields._sigfault._addr = VAR_0->pc;
queue_signal(VAR_0, info.si_signo, &info);
break;
case 0x81:
info.si_signo = TARGET_SIGTRAP;
info.si_errno = 0;
info.si_code = 0;
info._sifields._sigfault._addr = VAR_0->pc;
queue_signal(VAR_0, info.si_signo, &info);
break;
case 0x83:
VAR_1 = VAR_0->ir[IR_V0];
sysret = do_syscall(VAR_0, VAR_1,
VAR_0->ir[IR_A0], VAR_0->ir[IR_A1],
VAR_0->ir[IR_A2], VAR_0->ir[IR_A3],
VAR_0->ir[IR_A4], VAR_0->ir[IR_A5],
0, 0);
if (VAR_1 == TARGET_NR_sigreturn
|| VAR_1 == TARGET_NR_rt_sigreturn) {
break;
}
if (VAR_0->ir[IR_V0] == 0) {
VAR_0->ir[IR_V0] = sysret;
} else {
VAR_0->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);
VAR_0->ir[IR_A3] = (sysret < 0);
}
break;
case 0x86:
break;
case 0x9E:
abort();
case 0x9F:
abort();
case 0xAA:
info.si_signo = TARGET_SIGFPE;
switch (VAR_0->ir[IR_A0]) {
case TARGET_GEN_INTOVF:
info.si_code = TARGET_FPE_INTOVF;
break;
case TARGET_GEN_INTDIV:
info.si_code = TARGET_FPE_INTDIV;
break;
case TARGET_GEN_FLTOVF:
info.si_code = TARGET_FPE_FLTOVF;
break;
case TARGET_GEN_FLTUND:
info.si_code = TARGET_FPE_FLTUND;
break;
case TARGET_GEN_FLTINV:
info.si_code = TARGET_FPE_FLTINV;
break;
case TARGET_GEN_FLTINE:
info.si_code = TARGET_FPE_FLTRES;
break;
case TARGET_GEN_ROPRAND:
info.si_code = 0;
break;
default:
info.si_signo = TARGET_SIGTRAP;
info.si_code = 0;
break;
}
info.si_errno = 0;
info._sifields._sigfault._addr = VAR_0->pc;
queue_signal(VAR_0, info.si_signo, &info);
break;
default:
goto do_sigill;
}
break;
case EXCP_DEBUG:
info.si_signo = gdb_handlesig (VAR_0, TARGET_SIGTRAP);
if (info.si_signo) {
VAR_0->lock_addr = -1;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(VAR_0, info.si_signo, &info);
}
break;
case EXCP_STL_C:
case EXCP_STQ_C:
do_store_exclusive(VAR_0, VAR_0->error_code, VAR_1 - EXCP_STL_C);
break;
case EXCP_INTERRUPT:
break;
default:
printf ("Unhandled trap: 0x%x\n", VAR_1);
cpu_dump_state(VAR_0, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (VAR_0);
}
}
| [
"void FUNC_0(CPUAlphaState *VAR_0)\n{",
"int VAR_1;",
"target_siginfo_t info;",
"abi_long sysret;",
"while (1) {",
"VAR_1 = cpu_alpha_exec (VAR_0);",
"VAR_0->intr_flag = 0;",
"switch (VAR_1) {",
"case EXCP_RESET:\nfprintf(stderr, \"Reset requested. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_MCHK:\nfprintf(stderr, \"Machine check exception. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_SMP_INTERRUPT:\ncase EXCP_CLK_INTERRUPT:\ncase EXCP_DEV_INTERRUPT:\nfprintf(stderr, \"External interrupt. Exit\\n\");",
"exit(1);",
"break;",
"case EXCP_MMFAULT:\nVAR_0->lock_addr = -1;",
"info.si_signo = TARGET_SIGSEGV;",
"info.si_errno = 0;",
"info.si_code = (page_get_flags(VAR_0->trap_arg0) & PAGE_VALID\n? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR);",
"info._sifields._sigfault._addr = VAR_0->trap_arg0;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case EXCP_UNALIGN:\nVAR_0->lock_addr = -1;",
"info.si_signo = TARGET_SIGBUS;",
"info.si_errno = 0;",
"info.si_code = TARGET_BUS_ADRALN;",
"info._sifields._sigfault._addr = VAR_0->trap_arg0;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case EXCP_OPCDEC:\ndo_sigill:\nVAR_0->lock_addr = -1;",
"info.si_signo = TARGET_SIGILL;",
"info.si_errno = 0;",
"info.si_code = TARGET_ILL_ILLOPC;",
"info._sifields._sigfault._addr = VAR_0->pc;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case EXCP_ARITH:\nVAR_0->lock_addr = -1;",
"info.si_signo = TARGET_SIGFPE;",
"info.si_errno = 0;",
"info.si_code = TARGET_FPE_FLTINV;",
"info._sifields._sigfault._addr = VAR_0->pc;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case EXCP_FEN:\nbreak;",
"case EXCP_CALL_PAL:\nVAR_0->lock_addr = -1;",
"switch (VAR_0->error_code) {",
"case 0x80:\ninfo.si_signo = TARGET_SIGTRAP;",
"info.si_errno = 0;",
"info.si_code = TARGET_TRAP_BRKPT;",
"info._sifields._sigfault._addr = VAR_0->pc;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case 0x81:\ninfo.si_signo = TARGET_SIGTRAP;",
"info.si_errno = 0;",
"info.si_code = 0;",
"info._sifields._sigfault._addr = VAR_0->pc;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"case 0x83:\nVAR_1 = VAR_0->ir[IR_V0];",
"sysret = do_syscall(VAR_0, VAR_1,\nVAR_0->ir[IR_A0], VAR_0->ir[IR_A1],\nVAR_0->ir[IR_A2], VAR_0->ir[IR_A3],\nVAR_0->ir[IR_A4], VAR_0->ir[IR_A5],\n0, 0);",
"if (VAR_1 == TARGET_NR_sigreturn\n|| VAR_1 == TARGET_NR_rt_sigreturn) {",
"break;",
"}",
"if (VAR_0->ir[IR_V0] == 0) {",
"VAR_0->ir[IR_V0] = sysret;",
"} else {",
"VAR_0->ir[IR_V0] = (sysret < 0 ? -sysret : sysret);",
"VAR_0->ir[IR_A3] = (sysret < 0);",
"}",
"break;",
"case 0x86:\nbreak;",
"case 0x9E:\nabort();",
"case 0x9F:\nabort();",
"case 0xAA:\ninfo.si_signo = TARGET_SIGFPE;",
"switch (VAR_0->ir[IR_A0]) {",
"case TARGET_GEN_INTOVF:\ninfo.si_code = TARGET_FPE_INTOVF;",
"break;",
"case TARGET_GEN_INTDIV:\ninfo.si_code = TARGET_FPE_INTDIV;",
"break;",
"case TARGET_GEN_FLTOVF:\ninfo.si_code = TARGET_FPE_FLTOVF;",
"break;",
"case TARGET_GEN_FLTUND:\ninfo.si_code = TARGET_FPE_FLTUND;",
"break;",
"case TARGET_GEN_FLTINV:\ninfo.si_code = TARGET_FPE_FLTINV;",
"break;",
"case TARGET_GEN_FLTINE:\ninfo.si_code = TARGET_FPE_FLTRES;",
"break;",
"case TARGET_GEN_ROPRAND:\ninfo.si_code = 0;",
"break;",
"default:\ninfo.si_signo = TARGET_SIGTRAP;",
"info.si_code = 0;",
"break;",
"}",
"info.si_errno = 0;",
"info._sifields._sigfault._addr = VAR_0->pc;",
"queue_signal(VAR_0, info.si_signo, &info);",
"break;",
"default:\ngoto do_sigill;",
"}",
"break;",
"case EXCP_DEBUG:\ninfo.si_signo = gdb_handlesig (VAR_0, TARGET_SIGTRAP);",
"if (info.si_signo) {",
"VAR_0->lock_addr = -1;",
"info.si_errno = 0;",
"info.si_code = TARGET_TRAP_BRKPT;",
"queue_signal(VAR_0, info.si_signo, &info);",
"}",
"break;",
"case EXCP_STL_C:\ncase EXCP_STQ_C:\ndo_store_exclusive(VAR_0, VAR_0->error_code, VAR_1 - EXCP_STL_C);",
"break;",
"case EXCP_INTERRUPT:\nbreak;",
"default:\nprintf (\"Unhandled trap: 0x%x\\n\", VAR_1);",
"cpu_dump_state(VAR_0, stderr, fprintf, 0);",
"exit (1);",
"}",
"process_pending_signals (VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
47,
49,
51,
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
131
],
[
133,
135
],
[
137
],
[
139,
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
175
],
[
177,
179,
181,
183,
185
],
[
187,
189
],
[
191
],
[
193
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213,
227
],
[
229,
235
],
[
237,
243
],
[
245,
249
],
[
251
],
[
253,
255
],
[
257
],
[
259,
261
],
[
263
],
[
265,
267
],
[
269
],
[
271,
273
],
[
275
],
[
277,
279
],
[
281
],
[
283,
285
],
[
287
],
[
289,
291
],
[
293
],
[
295,
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313,
315
],
[
317
],
[
319
],
[
321,
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339,
341,
343
],
[
345
],
[
347,
351
],
[
353,
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.