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
listlengths 1
2.8k
| label
listlengths 1
2.8k
| line_no
listlengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
14,559 | static int64_t qemu_next_deadline(void)
{
int64_t delta;
if (active_timers[QEMU_CLOCK_VIRTUAL]) {
delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
qemu_get_clock(vm_clock);
} else {
/* To avoid problems with overflow limit this to 2^32. */
delta = INT32_MAX;
}
if (delta < 0)
delta = 0;
return delta;
}
| false | qemu | 21d5d12bb0ad4de7cc92a7a2d018e7ec0f9fd148 | static int64_t qemu_next_deadline(void)
{
int64_t delta;
if (active_timers[QEMU_CLOCK_VIRTUAL]) {
delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
qemu_get_clock(vm_clock);
} else {
delta = INT32_MAX;
}
if (delta < 0)
delta = 0;
return delta;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(void)
{
int64_t delta;
if (active_timers[QEMU_CLOCK_VIRTUAL]) {
delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
qemu_get_clock(vm_clock);
} else {
delta = INT32_MAX;
}
if (delta < 0)
delta = 0;
return delta;
}
| [
"static int64_t FUNC_0(void)\n{",
"int64_t delta;",
"if (active_timers[QEMU_CLOCK_VIRTUAL]) {",
"delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -\nqemu_get_clock(vm_clock);",
"} else {",
"delta = INT32_MAX;",
"}",
"if (delta < 0)\ndelta = 0;",
"return delta;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
25,
27
],
[
31
],
[
33
]
]
|
14,560 | int slirp_remove_hostfwd(int is_udp, struct in_addr host_addr, int host_port)
{
struct socket *so;
struct socket *head = (is_udp ? &udb : &tcb);
struct sockaddr_in addr;
int port = htons(host_port);
socklen_t addr_len;
int n = 0;
loop_again:
for (so = head->so_next; so != head; so = so->so_next) {
addr_len = sizeof(addr);
if (getsockname(so->s, (struct sockaddr *)&addr, &addr_len) == 0 &&
addr.sin_addr.s_addr == host_addr.s_addr &&
addr.sin_port == port) {
close(so->s);
sofree(so);
n++;
goto loop_again;
}
}
return n;
}
| false | qemu | 9c12a6f24d8bfd0e0d81a4a77f515e32d15547c1 | int slirp_remove_hostfwd(int is_udp, struct in_addr host_addr, int host_port)
{
struct socket *so;
struct socket *head = (is_udp ? &udb : &tcb);
struct sockaddr_in addr;
int port = htons(host_port);
socklen_t addr_len;
int n = 0;
loop_again:
for (so = head->so_next; so != head; so = so->so_next) {
addr_len = sizeof(addr);
if (getsockname(so->s, (struct sockaddr *)&addr, &addr_len) == 0 &&
addr.sin_addr.s_addr == host_addr.s_addr &&
addr.sin_port == port) {
close(so->s);
sofree(so);
n++;
goto loop_again;
}
}
return n;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, struct in_addr VAR_1, int VAR_2)
{
struct socket *VAR_3;
struct socket *VAR_4 = (VAR_0 ? &udb : &tcb);
struct sockaddr_in VAR_5;
int VAR_6 = htons(VAR_2);
socklen_t addr_len;
int VAR_7 = 0;
loop_again:
for (VAR_3 = VAR_4->so_next; VAR_3 != VAR_4; VAR_3 = VAR_3->so_next) {
addr_len = sizeof(VAR_5);
if (getsockname(VAR_3->s, (struct sockaddr *)&VAR_5, &addr_len) == 0 &&
VAR_5.sin_addr.s_addr == VAR_1.s_addr &&
VAR_5.sin_port == VAR_6) {
close(VAR_3->s);
sofree(VAR_3);
VAR_7++;
goto loop_again;
}
}
return VAR_7;
}
| [
"int FUNC_0(int VAR_0, struct in_addr VAR_1, int VAR_2)\n{",
"struct socket *VAR_3;",
"struct socket *VAR_4 = (VAR_0 ? &udb : &tcb);",
"struct sockaddr_in VAR_5;",
"int VAR_6 = htons(VAR_2);",
"socklen_t addr_len;",
"int VAR_7 = 0;",
"loop_again:\nfor (VAR_3 = VAR_4->so_next; VAR_3 != VAR_4; VAR_3 = VAR_3->so_next) {",
"addr_len = sizeof(VAR_5);",
"if (getsockname(VAR_3->s, (struct sockaddr *)&VAR_5, &addr_len) == 0 &&\nVAR_5.sin_addr.s_addr == VAR_1.s_addr &&\nVAR_5.sin_port == VAR_6) {",
"close(VAR_3->s);",
"sofree(VAR_3);",
"VAR_7++;",
"goto loop_again;",
"}",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23
],
[
25,
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
]
]
|
14,561 | static int mmu_translate_asc(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, target_ulong *raddr, int *flags,
int rw)
{
uint64_t asce = 0;
int level, new_level;
int r;
switch (asc) {
case PSW_ASC_PRIMARY:
PTE_DPRINTF("%s: asc=primary\n", __func__);
asce = env->cregs[1];
break;
case PSW_ASC_SECONDARY:
PTE_DPRINTF("%s: asc=secondary\n", __func__);
asce = env->cregs[7];
break;
case PSW_ASC_HOME:
PTE_DPRINTF("%s: asc=home\n", __func__);
asce = env->cregs[13];
break;
}
if (asce & _ASCE_REAL_SPACE) {
/* direct mapping */
*raddr = vaddr;
return 0;
}
switch (asce & _ASCE_TYPE_MASK) {
case _ASCE_TYPE_REGION1:
break;
case _ASCE_TYPE_REGION2:
if (vaddr & 0xffe0000000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffe0000000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_REGION3:
if (vaddr & 0xfffffc0000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xfffffc0000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_SEGMENT:
if (vaddr & 0xffffffff80000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffffffff80000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
}
/* fake level above current */
level = asce & _ASCE_TYPE_MASK;
new_level = level + 4;
asce = (asce & ~_ASCE_TYPE_MASK) | (new_level & _ASCE_TYPE_MASK);
r = mmu_translate_asce(env, vaddr, asc, asce, new_level, raddr, flags, rw);
if ((rw == 1) && !(*flags & PAGE_WRITE)) {
trigger_prot_fault(env, vaddr, asc);
return -1;
}
return r;
}
| false | qemu | f8f84e93ab6111848cfc83b3d6122573eb03bccf | static int mmu_translate_asc(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, target_ulong *raddr, int *flags,
int rw)
{
uint64_t asce = 0;
int level, new_level;
int r;
switch (asc) {
case PSW_ASC_PRIMARY:
PTE_DPRINTF("%s: asc=primary\n", __func__);
asce = env->cregs[1];
break;
case PSW_ASC_SECONDARY:
PTE_DPRINTF("%s: asc=secondary\n", __func__);
asce = env->cregs[7];
break;
case PSW_ASC_HOME:
PTE_DPRINTF("%s: asc=home\n", __func__);
asce = env->cregs[13];
break;
}
if (asce & _ASCE_REAL_SPACE) {
*raddr = vaddr;
return 0;
}
switch (asce & _ASCE_TYPE_MASK) {
case _ASCE_TYPE_REGION1:
break;
case _ASCE_TYPE_REGION2:
if (vaddr & 0xffe0000000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffe0000000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_REGION3:
if (vaddr & 0xfffffc0000000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xfffffc0000000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
case _ASCE_TYPE_SEGMENT:
if (vaddr & 0xffffffff80000000ULL) {
DPRINTF("%s: vaddr doesn't fit 0x%16" PRIx64
" 0xffffffff80000000ULL\n", __func__, vaddr);
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw);
return -1;
}
break;
}
level = asce & _ASCE_TYPE_MASK;
new_level = level + 4;
asce = (asce & ~_ASCE_TYPE_MASK) | (new_level & _ASCE_TYPE_MASK);
r = mmu_translate_asce(env, vaddr, asc, asce, new_level, raddr, flags, rw);
if ((rw == 1) && !(*flags & PAGE_WRITE)) {
trigger_prot_fault(env, vaddr, asc);
return -1;
}
return r;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1,
uint64_t VAR_2, target_ulong *VAR_3, int *VAR_4,
int VAR_5)
{
uint64_t asce = 0;
int VAR_6, VAR_7;
int VAR_8;
switch (VAR_2) {
case PSW_ASC_PRIMARY:
PTE_DPRINTF("%s: VAR_2=primary\n", __func__);
asce = VAR_0->cregs[1];
break;
case PSW_ASC_SECONDARY:
PTE_DPRINTF("%s: VAR_2=secondary\n", __func__);
asce = VAR_0->cregs[7];
break;
case PSW_ASC_HOME:
PTE_DPRINTF("%s: VAR_2=home\n", __func__);
asce = VAR_0->cregs[13];
break;
}
if (asce & _ASCE_REAL_SPACE) {
*VAR_3 = VAR_1;
return 0;
}
switch (asce & _ASCE_TYPE_MASK) {
case _ASCE_TYPE_REGION1:
break;
case _ASCE_TYPE_REGION2:
if (VAR_1 & 0xffe0000000000000ULL) {
DPRINTF("%s: VAR_1 doesn't fit 0x%16" PRIx64
" 0xffe0000000000000ULL\n", __func__, VAR_1);
trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);
return -1;
}
break;
case _ASCE_TYPE_REGION3:
if (VAR_1 & 0xfffffc0000000000ULL) {
DPRINTF("%s: VAR_1 doesn't fit 0x%16" PRIx64
" 0xfffffc0000000000ULL\n", __func__, VAR_1);
trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);
return -1;
}
break;
case _ASCE_TYPE_SEGMENT:
if (VAR_1 & 0xffffffff80000000ULL) {
DPRINTF("%s: VAR_1 doesn't fit 0x%16" PRIx64
" 0xffffffff80000000ULL\n", __func__, VAR_1);
trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);
return -1;
}
break;
}
VAR_6 = asce & _ASCE_TYPE_MASK;
VAR_7 = VAR_6 + 4;
asce = (asce & ~_ASCE_TYPE_MASK) | (VAR_7 & _ASCE_TYPE_MASK);
VAR_8 = mmu_translate_asce(VAR_0, VAR_1, VAR_2, asce, VAR_7, VAR_3, VAR_4, VAR_5);
if ((VAR_5 == 1) && !(*VAR_4 & PAGE_WRITE)) {
trigger_prot_fault(VAR_0, VAR_1, VAR_2);
return -1;
}
return VAR_8;
}
| [
"static int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1,\nuint64_t VAR_2, target_ulong *VAR_3, int *VAR_4,\nint VAR_5)\n{",
"uint64_t asce = 0;",
"int VAR_6, VAR_7;",
"int VAR_8;",
"switch (VAR_2) {",
"case PSW_ASC_PRIMARY:\nPTE_DPRINTF(\"%s: VAR_2=primary\\n\", __func__);",
"asce = VAR_0->cregs[1];",
"break;",
"case PSW_ASC_SECONDARY:\nPTE_DPRINTF(\"%s: VAR_2=secondary\\n\", __func__);",
"asce = VAR_0->cregs[7];",
"break;",
"case PSW_ASC_HOME:\nPTE_DPRINTF(\"%s: VAR_2=home\\n\", __func__);",
"asce = VAR_0->cregs[13];",
"break;",
"}",
"if (asce & _ASCE_REAL_SPACE) {",
"*VAR_3 = VAR_1;",
"return 0;",
"}",
"switch (asce & _ASCE_TYPE_MASK) {",
"case _ASCE_TYPE_REGION1:\nbreak;",
"case _ASCE_TYPE_REGION2:\nif (VAR_1 & 0xffe0000000000000ULL) {",
"DPRINTF(\"%s: VAR_1 doesn't fit 0x%16\" PRIx64\n\" 0xffe0000000000000ULL\\n\", __func__, VAR_1);",
"trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);",
"return -1;",
"}",
"break;",
"case _ASCE_TYPE_REGION3:\nif (VAR_1 & 0xfffffc0000000000ULL) {",
"DPRINTF(\"%s: VAR_1 doesn't fit 0x%16\" PRIx64\n\" 0xfffffc0000000000ULL\\n\", __func__, VAR_1);",
"trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);",
"return -1;",
"}",
"break;",
"case _ASCE_TYPE_SEGMENT:\nif (VAR_1 & 0xffffffff80000000ULL) {",
"DPRINTF(\"%s: VAR_1 doesn't fit 0x%16\" PRIx64\n\" 0xffffffff80000000ULL\\n\", __func__, VAR_1);",
"trigger_page_fault(VAR_0, VAR_1, PGM_TRANS_SPEC, VAR_2, VAR_5);",
"return -1;",
"}",
"break;",
"}",
"VAR_6 = asce & _ASCE_TYPE_MASK;",
"VAR_7 = VAR_6 + 4;",
"asce = (asce & ~_ASCE_TYPE_MASK) | (VAR_7 & _ASCE_TYPE_MASK);",
"VAR_8 = mmu_translate_asce(VAR_0, VAR_1, VAR_2, asce, VAR_7, VAR_3, VAR_4, VAR_5);",
"if ((VAR_5 == 1) && !(*VAR_4 & PAGE_WRITE)) {",
"trigger_prot_fault(VAR_0, VAR_1, VAR_2);",
"return -1;",
"}",
"return VAR_8;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
119
],
[
121
],
[
123
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
]
]
|
14,562 | static void kvm_arm_machine_init_done(Notifier *notifier, void *data)
{
KVMDevice *kd, *tkd;
memory_listener_unregister(&devlistener);
QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) {
if (kd->kda.addr != -1) {
if (kvm_vm_ioctl(kvm_state, KVM_ARM_SET_DEVICE_ADDR,
&kd->kda) < 0) {
fprintf(stderr, "KVM_ARM_SET_DEVICE_ADDRESS failed: %s\n",
strerror(errno));
abort();
}
}
memory_region_unref(kd->mr);
g_free(kd);
}
}
| false | qemu | 1da41cc1c6c3efbe2ed47228068bd80dbdc49d0e | static void kvm_arm_machine_init_done(Notifier *notifier, void *data)
{
KVMDevice *kd, *tkd;
memory_listener_unregister(&devlistener);
QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) {
if (kd->kda.addr != -1) {
if (kvm_vm_ioctl(kvm_state, KVM_ARM_SET_DEVICE_ADDR,
&kd->kda) < 0) {
fprintf(stderr, "KVM_ARM_SET_DEVICE_ADDRESS failed: %s\n",
strerror(errno));
abort();
}
}
memory_region_unref(kd->mr);
g_free(kd);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Notifier *VAR_0, void *VAR_1)
{
KVMDevice *kd, *tkd;
memory_listener_unregister(&devlistener);
QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) {
if (kd->kda.addr != -1) {
if (kvm_vm_ioctl(kvm_state, KVM_ARM_SET_DEVICE_ADDR,
&kd->kda) < 0) {
fprintf(stderr, "KVM_ARM_SET_DEVICE_ADDRESS failed: %s\n",
strerror(errno));
abort();
}
}
memory_region_unref(kd->mr);
g_free(kd);
}
}
| [
"static void FUNC_0(Notifier *VAR_0, void *VAR_1)\n{",
"KVMDevice *kd, *tkd;",
"memory_listener_unregister(&devlistener);",
"QSLIST_FOREACH_SAFE(kd, &kvm_devices_head, entries, tkd) {",
"if (kd->kda.addr != -1) {",
"if (kvm_vm_ioctl(kvm_state, KVM_ARM_SET_DEVICE_ADDR,\n&kd->kda) < 0) {",
"fprintf(stderr, \"KVM_ARM_SET_DEVICE_ADDRESS failed: %s\\n\",\nstrerror(errno));",
"abort();",
"}",
"}",
"memory_region_unref(kd->mr);",
"g_free(kd);",
"}",
"}"
]
| [
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
]
]
|
14,564 | static void dec_sru(DisasContext *dc)
{
if (dc->format == OP_FMT_RI) {
LOG_DIS("srui r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5);
} else {
LOG_DIS("sru r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
}
if (dc->format == OP_FMT_RI) {
if (!(dc->features & LM32_FEATURE_SHIFT) && (dc->imm5 != 1)) {
qemu_log_mask(LOG_GUEST_ERROR,
"hardware shifter is not available\n");
t_gen_illegal_insn(dc);
return;
}
tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5);
} else {
int l1 = gen_new_label();
int l2 = gen_new_label();
TCGv t0 = tcg_temp_local_new();
tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f);
if (!(dc->features & LM32_FEATURE_SHIFT)) {
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 1, l1);
t_gen_illegal_insn(dc);
tcg_gen_br(l2);
}
gen_set_label(l1);
tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0);
gen_set_label(l2);
tcg_temp_free(t0);
}
}
| false | qemu | 42a268c241183877192c376d03bd9b6d527407c7 | static void dec_sru(DisasContext *dc)
{
if (dc->format == OP_FMT_RI) {
LOG_DIS("srui r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5);
} else {
LOG_DIS("sru r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1);
}
if (dc->format == OP_FMT_RI) {
if (!(dc->features & LM32_FEATURE_SHIFT) && (dc->imm5 != 1)) {
qemu_log_mask(LOG_GUEST_ERROR,
"hardware shifter is not available\n");
t_gen_illegal_insn(dc);
return;
}
tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5);
} else {
int l1 = gen_new_label();
int l2 = gen_new_label();
TCGv t0 = tcg_temp_local_new();
tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f);
if (!(dc->features & LM32_FEATURE_SHIFT)) {
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 1, l1);
t_gen_illegal_insn(dc);
tcg_gen_br(l2);
}
gen_set_label(l1);
tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0);
gen_set_label(l2);
tcg_temp_free(t0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0)
{
if (VAR_0->format == OP_FMT_RI) {
LOG_DIS("srui r%d, r%d, %d\n", VAR_0->r1, VAR_0->r0, VAR_0->imm5);
} else {
LOG_DIS("sru r%d, r%d, r%d\n", VAR_0->r2, VAR_0->r0, VAR_0->r1);
}
if (VAR_0->format == OP_FMT_RI) {
if (!(VAR_0->features & LM32_FEATURE_SHIFT) && (VAR_0->imm5 != 1)) {
qemu_log_mask(LOG_GUEST_ERROR,
"hardware shifter is not available\n");
t_gen_illegal_insn(VAR_0);
return;
}
tcg_gen_shri_tl(cpu_R[VAR_0->r1], cpu_R[VAR_0->r0], VAR_0->imm5);
} else {
int VAR_1 = gen_new_label();
int VAR_2 = gen_new_label();
TCGv t0 = tcg_temp_local_new();
tcg_gen_andi_tl(t0, cpu_R[VAR_0->r1], 0x1f);
if (!(VAR_0->features & LM32_FEATURE_SHIFT)) {
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 1, VAR_1);
t_gen_illegal_insn(VAR_0);
tcg_gen_br(VAR_2);
}
gen_set_label(VAR_1);
tcg_gen_shr_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], t0);
gen_set_label(VAR_2);
tcg_temp_free(t0);
}
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"if (VAR_0->format == OP_FMT_RI) {",
"LOG_DIS(\"srui r%d, r%d, %d\\n\", VAR_0->r1, VAR_0->r0, VAR_0->imm5);",
"} else {",
"LOG_DIS(\"sru r%d, r%d, r%d\\n\", VAR_0->r2, VAR_0->r0, VAR_0->r1);",
"}",
"if (VAR_0->format == OP_FMT_RI) {",
"if (!(VAR_0->features & LM32_FEATURE_SHIFT) && (VAR_0->imm5 != 1)) {",
"qemu_log_mask(LOG_GUEST_ERROR,\n\"hardware shifter is not available\\n\");",
"t_gen_illegal_insn(VAR_0);",
"return;",
"}",
"tcg_gen_shri_tl(cpu_R[VAR_0->r1], cpu_R[VAR_0->r0], VAR_0->imm5);",
"} else {",
"int VAR_1 = gen_new_label();",
"int VAR_2 = gen_new_label();",
"TCGv t0 = tcg_temp_local_new();",
"tcg_gen_andi_tl(t0, cpu_R[VAR_0->r1], 0x1f);",
"if (!(VAR_0->features & LM32_FEATURE_SHIFT)) {",
"tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 1, VAR_1);",
"t_gen_illegal_insn(VAR_0);",
"tcg_gen_br(VAR_2);",
"}",
"gen_set_label(VAR_1);",
"tcg_gen_shr_tl(cpu_R[VAR_0->r2], cpu_R[VAR_0->r0], t0);",
"gen_set_label(VAR_2);",
"tcg_temp_free(t0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
]
]
|
14,565 | static void test_visitor_in_native_list_string(TestInputVisitorData *data,
const void *unused)
{
UserDefNativeListUnion *cvalue = NULL;
strList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
int i;
for (i = 0; i < 32; i++) {
g_string_append_printf(gstr_list, "'%d'", i);
if (i != 31) {
g_string_append(gstr_list, ", ");
}
}
g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s ] }",
gstr_list->str);
v = visitor_input_test_init_raw(data, gstr_union->str);
visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
g_assert(cvalue != NULL);
g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {
gchar str[8];
sprintf(str, "%d", i);
g_assert_cmpstr(elem->value, ==, str);
}
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
qapi_free_UserDefNativeListUnion(cvalue);
}
| false | qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | static void test_visitor_in_native_list_string(TestInputVisitorData *data,
const void *unused)
{
UserDefNativeListUnion *cvalue = NULL;
strList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
int i;
for (i = 0; i < 32; i++) {
g_string_append_printf(gstr_list, "'%d'", i);
if (i != 31) {
g_string_append(gstr_list, ", ");
}
}
g_string_append_printf(gstr_union, "{ 'type': 'string', 'data': [ %s ] }",
gstr_list->str);
v = visitor_input_test_init_raw(data, gstr_union->str);
visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
g_assert(cvalue != NULL);
g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
for (i = 0, elem = cvalue->u.string.data; elem; elem = elem->next, i++) {
gchar str[8];
sprintf(str, "%d", i);
g_assert_cmpstr(elem->value, ==, str);
}
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
qapi_free_UserDefNativeListUnion(cvalue);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
UserDefNativeListUnion *cvalue = NULL;
strList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
int VAR_2;
for (VAR_2 = 0; VAR_2 < 32; VAR_2++) {
g_string_append_printf(gstr_list, "'%d'", VAR_2);
if (VAR_2 != 31) {
g_string_append(gstr_list, ", ");
}
}
g_string_append_printf(gstr_union, "{ 'type': 'string', 'VAR_0': [ %s ] }",
gstr_list->str);
v = visitor_input_test_init_raw(VAR_0, gstr_union->str);
visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);
g_assert(cvalue != NULL);
g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);
for (VAR_2 = 0, elem = cvalue->u.string.VAR_0; elem; elem = elem->next, VAR_2++) {
gchar str[8];
sprintf(str, "%d", VAR_2);
g_assert_cmpstr(elem->value, ==, str);
}
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
qapi_free_UserDefNativeListUnion(cvalue);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"UserDefNativeListUnion *cvalue = NULL;",
"strList *elem = NULL;",
"Visitor *v;",
"GString *gstr_list = g_string_new(\"\");",
"GString *gstr_union = g_string_new(\"\");",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < 32; VAR_2++) {",
"g_string_append_printf(gstr_list, \"'%d'\", VAR_2);",
"if (VAR_2 != 31) {",
"g_string_append(gstr_list, \", \");",
"}",
"}",
"g_string_append_printf(gstr_union, \"{ 'type': 'string', 'VAR_0': [ %s ] }\",",
"gstr_list->str);",
"v = visitor_input_test_init_raw(VAR_0, gstr_union->str);",
"visit_type_UserDefNativeListUnion(v, NULL, &cvalue, &error_abort);",
"g_assert(cvalue != NULL);",
"g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING);",
"for (VAR_2 = 0, elem = cvalue->u.string.VAR_0; elem; elem = elem->next, VAR_2++) {",
"gchar str[8];",
"sprintf(str, \"%d\", VAR_2);",
"g_assert_cmpstr(elem->value, ==, str);",
"}",
"g_string_free(gstr_union, true);",
"g_string_free(gstr_list, true);",
"qapi_free_UserDefNativeListUnion(cvalue);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
]
]
|
14,567 | static int kvm_get_xsave(CPUState *env)
{
#ifdef KVM_CAP_XSAVE
struct kvm_xsave* xsave;
int ret, i;
uint16_t cwd, swd, twd, fop;
if (!kvm_has_xsave())
return kvm_get_fpu(env);
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
if (ret < 0) {
qemu_free(xsave);
return ret;
}
cwd = (uint16_t)xsave->region[0];
swd = (uint16_t)(xsave->region[0] >> 16);
twd = (uint16_t)xsave->region[1];
fop = (uint16_t)(xsave->region[1] >> 16);
env->fpstt = (swd >> 11) & 7;
env->fpus = swd;
env->fpuc = cwd;
for (i = 0; i < 8; ++i)
env->fptags[i] = !((twd >> i) & 1);
env->mxcsr = xsave->region[XSAVE_MXCSR];
memcpy(env->fpregs, &xsave->region[XSAVE_ST_SPACE],
sizeof env->fpregs);
memcpy(env->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],
sizeof env->xmm_regs);
env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof env->ymmh_regs);
qemu_free(xsave);
return 0;
#else
return kvm_get_fpu(env);
#endif
}
| false | qemu | b9bec74bcb16519a876ec21cd5277c526a9b512d | static int kvm_get_xsave(CPUState *env)
{
#ifdef KVM_CAP_XSAVE
struct kvm_xsave* xsave;
int ret, i;
uint16_t cwd, swd, twd, fop;
if (!kvm_has_xsave())
return kvm_get_fpu(env);
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
if (ret < 0) {
qemu_free(xsave);
return ret;
}
cwd = (uint16_t)xsave->region[0];
swd = (uint16_t)(xsave->region[0] >> 16);
twd = (uint16_t)xsave->region[1];
fop = (uint16_t)(xsave->region[1] >> 16);
env->fpstt = (swd >> 11) & 7;
env->fpus = swd;
env->fpuc = cwd;
for (i = 0; i < 8; ++i)
env->fptags[i] = !((twd >> i) & 1);
env->mxcsr = xsave->region[XSAVE_MXCSR];
memcpy(env->fpregs, &xsave->region[XSAVE_ST_SPACE],
sizeof env->fpregs);
memcpy(env->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],
sizeof env->xmm_regs);
env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof env->ymmh_regs);
qemu_free(xsave);
return 0;
#else
return kvm_get_fpu(env);
#endif
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUState *VAR_0)
{
#ifdef KVM_CAP_XSAVE
struct kvm_xsave* xsave;
int ret, i;
uint16_t cwd, swd, twd, fop;
if (!kvm_has_xsave())
return kvm_get_fpu(VAR_0);
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(VAR_0, KVM_GET_XSAVE, xsave);
if (ret < 0) {
qemu_free(xsave);
return ret;
}
cwd = (uint16_t)xsave->region[0];
swd = (uint16_t)(xsave->region[0] >> 16);
twd = (uint16_t)xsave->region[1];
fop = (uint16_t)(xsave->region[1] >> 16);
VAR_0->fpstt = (swd >> 11) & 7;
VAR_0->fpus = swd;
VAR_0->fpuc = cwd;
for (i = 0; i < 8; ++i)
VAR_0->fptags[i] = !((twd >> i) & 1);
VAR_0->mxcsr = xsave->region[XSAVE_MXCSR];
memcpy(VAR_0->fpregs, &xsave->region[XSAVE_ST_SPACE],
sizeof VAR_0->fpregs);
memcpy(VAR_0->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],
sizeof VAR_0->xmm_regs);
VAR_0->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(VAR_0->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof VAR_0->ymmh_regs);
qemu_free(xsave);
return 0;
#else
return kvm_get_fpu(VAR_0);
#endif
}
| [
"static int FUNC_0(CPUState *VAR_0)\n{",
"#ifdef KVM_CAP_XSAVE\nstruct kvm_xsave* xsave;",
"int ret, i;",
"uint16_t cwd, swd, twd, fop;",
"if (!kvm_has_xsave())\nreturn kvm_get_fpu(VAR_0);",
"xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));",
"ret = kvm_vcpu_ioctl(VAR_0, KVM_GET_XSAVE, xsave);",
"if (ret < 0) {",
"qemu_free(xsave);",
"return ret;",
"}",
"cwd = (uint16_t)xsave->region[0];",
"swd = (uint16_t)(xsave->region[0] >> 16);",
"twd = (uint16_t)xsave->region[1];",
"fop = (uint16_t)(xsave->region[1] >> 16);",
"VAR_0->fpstt = (swd >> 11) & 7;",
"VAR_0->fpus = swd;",
"VAR_0->fpuc = cwd;",
"for (i = 0; i < 8; ++i)",
"VAR_0->fptags[i] = !((twd >> i) & 1);",
"VAR_0->mxcsr = xsave->region[XSAVE_MXCSR];",
"memcpy(VAR_0->fpregs, &xsave->region[XSAVE_ST_SPACE],\nsizeof VAR_0->fpregs);",
"memcpy(VAR_0->xmm_regs, &xsave->region[XSAVE_XMM_SPACE],\nsizeof VAR_0->xmm_regs);",
"VAR_0->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];",
"memcpy(VAR_0->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],\nsizeof VAR_0->ymmh_regs);",
"qemu_free(xsave);",
"return 0;",
"#else\nreturn kvm_get_fpu(VAR_0);",
"#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
]
| [
[
1,
3
],
[
5,
7
],
[
9
],
[
11
],
[
15,
17
],
[
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,
75
],
[
77,
79
]
]
|
14,568 | void do_migrate_set_speed(Monitor *mon, const QDict *qdict)
{
double d;
char *ptr;
FdMigrationState *s;
const char *value = qdict_get_str(qdict, "value");
d = strtod(value, &ptr);
switch (*ptr) {
case 'G': case 'g':
d *= 1024;
case 'M': case 'm':
d *= 1024;
case 'K': case 'k':
d *= 1024;
default:
break;
}
max_throttle = (uint32_t)d;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
}
| false | qemu | 5667c493c430256c99002b719383f0e911cb53a8 | void do_migrate_set_speed(Monitor *mon, const QDict *qdict)
{
double d;
char *ptr;
FdMigrationState *s;
const char *value = qdict_get_str(qdict, "value");
d = strtod(value, &ptr);
switch (*ptr) {
case 'G': case 'g':
d *= 1024;
case 'M': case 'm':
d *= 1024;
case 'K': case 'k':
d *= 1024;
default:
break;
}
max_throttle = (uint32_t)d;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)
{
double VAR_2;
char *VAR_3;
FdMigrationState *s;
const char *VAR_4 = qdict_get_str(VAR_1, "VAR_4");
VAR_2 = strtod(VAR_4, &VAR_3);
switch (*VAR_3) {
case 'G': case 'g':
VAR_2 *= 1024;
case 'M': case 'm':
VAR_2 *= 1024;
case 'K': case 'k':
VAR_2 *= 1024;
default:
break;
}
max_throttle = (uint32_t)VAR_2;
s = migrate_to_fms(current_migration);
if (s && s->file) {
qemu_file_set_rate_limit(s->file, max_throttle);
}
}
| [
"void FUNC_0(Monitor *VAR_0, const QDict *VAR_1)\n{",
"double VAR_2;",
"char *VAR_3;",
"FdMigrationState *s;",
"const char *VAR_4 = qdict_get_str(VAR_1, \"VAR_4\");",
"VAR_2 = strtod(VAR_4, &VAR_3);",
"switch (*VAR_3) {",
"case 'G': case 'g':\nVAR_2 *= 1024;",
"case 'M': case 'm':\nVAR_2 *= 1024;",
"case 'K': case 'k':\nVAR_2 *= 1024;",
"default:\nbreak;",
"}",
"max_throttle = (uint32_t)VAR_2;",
"s = migrate_to_fms(current_migration);",
"if (s && s->file) {",
"qemu_file_set_rate_limit(s->file, max_throttle);",
"}",
"}"
]
| [
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
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
]
]
|
14,569 | static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
NBDExportInfo *info, Error **errp)
{
nbd_opt_reply reply;
uint32_t len = strlen(wantname);
uint16_t type;
int error;
char *buf;
/* The protocol requires that the server send NBD_INFO_EXPORT with
* a non-zero flags (at least NBD_FLAG_HAS_FLAGS must be set); so
* flags still 0 is a witness of a broken server. */
info->flags = 0;
trace_nbd_opt_go_start(wantname);
buf = g_malloc(4 + len + 2 + 1);
stl_be_p(buf, len);
memcpy(buf + 4, wantname, len);
/* No requests, live with whatever server sends */
stw_be_p(buf + 4 + len, 0);
if (nbd_send_option_request(ioc, NBD_OPT_GO, len + 6, buf, errp) < 0) {
return -1;
}
while (1) {
if (nbd_receive_option_reply(ioc, NBD_OPT_GO, &reply, errp) < 0) {
return -1;
}
error = nbd_handle_reply_err(ioc, &reply, errp);
if (error <= 0) {
return error;
}
len = reply.length;
if (reply.type == NBD_REP_ACK) {
/* Server is done sending info and moved into transmission
phase, but make sure it sent flags */
if (len) {
error_setg(errp, "server sent invalid NBD_REP_ACK");
nbd_send_opt_abort(ioc);
return -1;
}
if (!info->flags) {
error_setg(errp, "broken server omitted NBD_INFO_EXPORT");
nbd_send_opt_abort(ioc);
return -1;
}
trace_nbd_opt_go_success();
return 1;
}
if (reply.type != NBD_REP_INFO) {
error_setg(errp, "unexpected reply type %" PRIx32 ", expected %x",
reply.type, NBD_REP_INFO);
nbd_send_opt_abort(ioc);
return -1;
}
if (len < sizeof(type)) {
error_setg(errp, "NBD_REP_INFO length %" PRIu32 " is too short",
len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &type, sizeof(type), errp) < 0) {
error_prepend(errp, "failed to read info type");
nbd_send_opt_abort(ioc);
return -1;
}
len -= sizeof(type);
be16_to_cpus(&type);
switch (type) {
case NBD_INFO_EXPORT:
if (len != sizeof(info->size) + sizeof(info->flags)) {
error_setg(errp, "remaining export info len %" PRIu32
" is unexpected size", len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "failed to read info size");
nbd_send_opt_abort(ioc);
return -1;
}
be64_to_cpus(&info->size);
if (nbd_read(ioc, &info->flags, sizeof(info->flags), errp) < 0) {
error_prepend(errp, "failed to read info flags");
nbd_send_opt_abort(ioc);
return -1;
}
be16_to_cpus(&info->flags);
trace_nbd_receive_negotiate_size_flags(info->size, info->flags);
break;
default:
trace_nbd_opt_go_info_unknown(type, nbd_info_lookup(type));
if (nbd_drop(ioc, len, errp) < 0) {
error_prepend(errp, "Failed to read info payload");
nbd_send_opt_abort(ioc);
return -1;
}
break;
}
}
}
| false | qemu | 081dd1fe36f0ccc04130d1edd136c787c5f8cc50 | static int nbd_opt_go(QIOChannel *ioc, const char *wantname,
NBDExportInfo *info, Error **errp)
{
nbd_opt_reply reply;
uint32_t len = strlen(wantname);
uint16_t type;
int error;
char *buf;
info->flags = 0;
trace_nbd_opt_go_start(wantname);
buf = g_malloc(4 + len + 2 + 1);
stl_be_p(buf, len);
memcpy(buf + 4, wantname, len);
stw_be_p(buf + 4 + len, 0);
if (nbd_send_option_request(ioc, NBD_OPT_GO, len + 6, buf, errp) < 0) {
return -1;
}
while (1) {
if (nbd_receive_option_reply(ioc, NBD_OPT_GO, &reply, errp) < 0) {
return -1;
}
error = nbd_handle_reply_err(ioc, &reply, errp);
if (error <= 0) {
return error;
}
len = reply.length;
if (reply.type == NBD_REP_ACK) {
if (len) {
error_setg(errp, "server sent invalid NBD_REP_ACK");
nbd_send_opt_abort(ioc);
return -1;
}
if (!info->flags) {
error_setg(errp, "broken server omitted NBD_INFO_EXPORT");
nbd_send_opt_abort(ioc);
return -1;
}
trace_nbd_opt_go_success();
return 1;
}
if (reply.type != NBD_REP_INFO) {
error_setg(errp, "unexpected reply type %" PRIx32 ", expected %x",
reply.type, NBD_REP_INFO);
nbd_send_opt_abort(ioc);
return -1;
}
if (len < sizeof(type)) {
error_setg(errp, "NBD_REP_INFO length %" PRIu32 " is too short",
len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &type, sizeof(type), errp) < 0) {
error_prepend(errp, "failed to read info type");
nbd_send_opt_abort(ioc);
return -1;
}
len -= sizeof(type);
be16_to_cpus(&type);
switch (type) {
case NBD_INFO_EXPORT:
if (len != sizeof(info->size) + sizeof(info->flags)) {
error_setg(errp, "remaining export info len %" PRIu32
" is unexpected size", len);
nbd_send_opt_abort(ioc);
return -1;
}
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "failed to read info size");
nbd_send_opt_abort(ioc);
return -1;
}
be64_to_cpus(&info->size);
if (nbd_read(ioc, &info->flags, sizeof(info->flags), errp) < 0) {
error_prepend(errp, "failed to read info flags");
nbd_send_opt_abort(ioc);
return -1;
}
be16_to_cpus(&info->flags);
trace_nbd_receive_negotiate_size_flags(info->size, info->flags);
break;
default:
trace_nbd_opt_go_info_unknown(type, nbd_info_lookup(type));
if (nbd_drop(ioc, len, errp) < 0) {
error_prepend(errp, "Failed to read info payload");
nbd_send_opt_abort(ioc);
return -1;
}
break;
}
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QIOChannel *VAR_0, const char *VAR_1,
NBDExportInfo *VAR_2, Error **VAR_3)
{
nbd_opt_reply reply;
uint32_t len = strlen(VAR_1);
uint16_t type;
int VAR_4;
char *VAR_5;
VAR_2->flags = 0;
trace_nbd_opt_go_start(VAR_1);
VAR_5 = g_malloc(4 + len + 2 + 1);
stl_be_p(VAR_5, len);
memcpy(VAR_5 + 4, VAR_1, len);
stw_be_p(VAR_5 + 4 + len, 0);
if (nbd_send_option_request(VAR_0, NBD_OPT_GO, len + 6, VAR_5, VAR_3) < 0) {
return -1;
}
while (1) {
if (nbd_receive_option_reply(VAR_0, NBD_OPT_GO, &reply, VAR_3) < 0) {
return -1;
}
VAR_4 = nbd_handle_reply_err(VAR_0, &reply, VAR_3);
if (VAR_4 <= 0) {
return VAR_4;
}
len = reply.length;
if (reply.type == NBD_REP_ACK) {
if (len) {
error_setg(VAR_3, "server sent invalid NBD_REP_ACK");
nbd_send_opt_abort(VAR_0);
return -1;
}
if (!VAR_2->flags) {
error_setg(VAR_3, "broken server omitted NBD_INFO_EXPORT");
nbd_send_opt_abort(VAR_0);
return -1;
}
trace_nbd_opt_go_success();
return 1;
}
if (reply.type != NBD_REP_INFO) {
error_setg(VAR_3, "unexpected reply type %" PRIx32 ", expected %x",
reply.type, NBD_REP_INFO);
nbd_send_opt_abort(VAR_0);
return -1;
}
if (len < sizeof(type)) {
error_setg(VAR_3, "NBD_REP_INFO length %" PRIu32 " is too short",
len);
nbd_send_opt_abort(VAR_0);
return -1;
}
if (nbd_read(VAR_0, &type, sizeof(type), VAR_3) < 0) {
error_prepend(VAR_3, "failed to read VAR_2 type");
nbd_send_opt_abort(VAR_0);
return -1;
}
len -= sizeof(type);
be16_to_cpus(&type);
switch (type) {
case NBD_INFO_EXPORT:
if (len != sizeof(VAR_2->size) + sizeof(VAR_2->flags)) {
error_setg(VAR_3, "remaining export VAR_2 len %" PRIu32
" is unexpected size", len);
nbd_send_opt_abort(VAR_0);
return -1;
}
if (nbd_read(VAR_0, &VAR_2->size, sizeof(VAR_2->size), VAR_3) < 0) {
error_prepend(VAR_3, "failed to read VAR_2 size");
nbd_send_opt_abort(VAR_0);
return -1;
}
be64_to_cpus(&VAR_2->size);
if (nbd_read(VAR_0, &VAR_2->flags, sizeof(VAR_2->flags), VAR_3) < 0) {
error_prepend(VAR_3, "failed to read VAR_2 flags");
nbd_send_opt_abort(VAR_0);
return -1;
}
be16_to_cpus(&VAR_2->flags);
trace_nbd_receive_negotiate_size_flags(VAR_2->size, VAR_2->flags);
break;
default:
trace_nbd_opt_go_info_unknown(type, nbd_info_lookup(type));
if (nbd_drop(VAR_0, len, VAR_3) < 0) {
error_prepend(VAR_3, "Failed to read VAR_2 payload");
nbd_send_opt_abort(VAR_0);
return -1;
}
break;
}
}
}
| [
"static int FUNC_0(QIOChannel *VAR_0, const char *VAR_1,\nNBDExportInfo *VAR_2, Error **VAR_3)\n{",
"nbd_opt_reply reply;",
"uint32_t len = strlen(VAR_1);",
"uint16_t type;",
"int VAR_4;",
"char *VAR_5;",
"VAR_2->flags = 0;",
"trace_nbd_opt_go_start(VAR_1);",
"VAR_5 = g_malloc(4 + len + 2 + 1);",
"stl_be_p(VAR_5, len);",
"memcpy(VAR_5 + 4, VAR_1, len);",
"stw_be_p(VAR_5 + 4 + len, 0);",
"if (nbd_send_option_request(VAR_0, NBD_OPT_GO, len + 6, VAR_5, VAR_3) < 0) {",
"return -1;",
"}",
"while (1) {",
"if (nbd_receive_option_reply(VAR_0, NBD_OPT_GO, &reply, VAR_3) < 0) {",
"return -1;",
"}",
"VAR_4 = nbd_handle_reply_err(VAR_0, &reply, VAR_3);",
"if (VAR_4 <= 0) {",
"return VAR_4;",
"}",
"len = reply.length;",
"if (reply.type == NBD_REP_ACK) {",
"if (len) {",
"error_setg(VAR_3, \"server sent invalid NBD_REP_ACK\");",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"if (!VAR_2->flags) {",
"error_setg(VAR_3, \"broken server omitted NBD_INFO_EXPORT\");",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"trace_nbd_opt_go_success();",
"return 1;",
"}",
"if (reply.type != NBD_REP_INFO) {",
"error_setg(VAR_3, \"unexpected reply type %\" PRIx32 \", expected %x\",\nreply.type, NBD_REP_INFO);",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"if (len < sizeof(type)) {",
"error_setg(VAR_3, \"NBD_REP_INFO length %\" PRIu32 \" is too short\",\nlen);",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"if (nbd_read(VAR_0, &type, sizeof(type), VAR_3) < 0) {",
"error_prepend(VAR_3, \"failed to read VAR_2 type\");",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"len -= sizeof(type);",
"be16_to_cpus(&type);",
"switch (type) {",
"case NBD_INFO_EXPORT:\nif (len != sizeof(VAR_2->size) + sizeof(VAR_2->flags)) {",
"error_setg(VAR_3, \"remaining export VAR_2 len %\" PRIu32\n\" is unexpected size\", len);",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"if (nbd_read(VAR_0, &VAR_2->size, sizeof(VAR_2->size), VAR_3) < 0) {",
"error_prepend(VAR_3, \"failed to read VAR_2 size\");",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"be64_to_cpus(&VAR_2->size);",
"if (nbd_read(VAR_0, &VAR_2->flags, sizeof(VAR_2->flags), VAR_3) < 0) {",
"error_prepend(VAR_3, \"failed to read VAR_2 flags\");",
"nbd_send_opt_abort(VAR_0);",
"return -1;",
"}",
"be16_to_cpus(&VAR_2->flags);",
"trace_nbd_receive_negotiate_size_flags(VAR_2->size, VAR_2->flags);",
"break;",
"default:\ntrace_nbd_opt_go_info_unknown(type, nbd_info_lookup(type));",
"if (nbd_drop(VAR_0, len, VAR_3) < 0) {",
"error_prepend(VAR_3, \"Failed to read VAR_2 payload\");",
"nbd_send_opt_abort(VAR_0);",
"return -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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
]
]
|
14,571 | void s390_crw_mchk(S390CPU *cpu)
{
if (kvm_enabled()) {
kvm_s390_crw_mchk(cpu);
} else {
cpu_inject_crw_mchk(cpu);
}
}
| false | qemu | de13d2161473d02ae97ec0f8e4503147554892dd | void s390_crw_mchk(S390CPU *cpu)
{
if (kvm_enabled()) {
kvm_s390_crw_mchk(cpu);
} else {
cpu_inject_crw_mchk(cpu);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(S390CPU *VAR_0)
{
if (kvm_enabled()) {
kvm_s390_crw_mchk(VAR_0);
} else {
cpu_inject_crw_mchk(VAR_0);
}
}
| [
"void FUNC_0(S390CPU *VAR_0)\n{",
"if (kvm_enabled()) {",
"kvm_s390_crw_mchk(VAR_0);",
"} else {",
"cpu_inject_crw_mchk(VAR_0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
]
|
14,572 | static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUARMState *env = cpu->env_ptr;
if (dc->ss_active && !dc->pstate_ss) {
/* Singlestep state is Active-pending.
* If we're in this state at the start of a TB then either
* a) we just took an exception to an EL which is being debugged
* and this is the first insn in the exception handler
* b) debug exceptions were masked and we just unmasked them
* without changing EL (eg by clearing PSTATE.D)
* In either case we're going to take a swstep exception in the
* "did not step an insn" case, and so the syndrome ISV and EX
* bits should be zero.
*/
assert(dc->base.num_insns == 1);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->base.is_jmp = DISAS_NORETURN;
} else {
disas_a64_insn(env, dc);
}
if (dc->base.is_jmp == DISAS_NEXT) {
if (dc->ss_active || dc->pc >= dc->next_page_start) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
}
dc->base.pc_next = dc->pc;
translator_loop_temp_check(&dc->base);
}
| false | qemu | dcc3a21209a8eeae0fe43966012f8e08d3566f98 | static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUARMState *env = cpu->env_ptr;
if (dc->ss_active && !dc->pstate_ss) {
assert(dc->base.num_insns == 1);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->base.is_jmp = DISAS_NORETURN;
} else {
disas_a64_insn(env, dc);
}
if (dc->base.is_jmp == DISAS_NEXT) {
if (dc->ss_active || dc->pc >= dc->next_page_start) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
}
dc->base.pc_next = dc->pc;
translator_loop_temp_check(&dc->base);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContextBase *VAR_0, CPUState *VAR_1)
{
DisasContext *dc = container_of(VAR_0, DisasContext, base);
CPUARMState *env = VAR_1->env_ptr;
if (dc->ss_active && !dc->pstate_ss) {
assert(dc->base.num_insns == 1);
gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),
default_exception_el(dc));
dc->base.is_jmp = DISAS_NORETURN;
} else {
disas_a64_insn(env, dc);
}
if (dc->base.is_jmp == DISAS_NEXT) {
if (dc->ss_active || dc->pc >= dc->next_page_start) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
}
dc->base.pc_next = dc->pc;
translator_loop_temp_check(&dc->base);
}
| [
"static void FUNC_0(DisasContextBase *VAR_0, CPUState *VAR_1)\n{",
"DisasContext *dc = container_of(VAR_0, DisasContext, base);",
"CPUARMState *env = VAR_1->env_ptr;",
"if (dc->ss_active && !dc->pstate_ss) {",
"assert(dc->base.num_insns == 1);",
"gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0),\ndefault_exception_el(dc));",
"dc->base.is_jmp = DISAS_NORETURN;",
"} else {",
"disas_a64_insn(env, dc);",
"}",
"if (dc->base.is_jmp == DISAS_NEXT) {",
"if (dc->ss_active || dc->pc >= dc->next_page_start) {",
"dc->base.is_jmp = DISAS_TOO_MANY;",
"}",
"}",
"dc->base.pc_next = dc->pc;",
"translator_loop_temp_check(&dc->base);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
]
]
|
14,573 | int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
CPUBreakpoint **breakpoint)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
bp = g_malloc(sizeof(*bp));
bp->pc = pc;
bp->flags = flags;
/* keep all GDB-injected breakpoints in front */
if (flags & BP_GDB) {
QTAILQ_INSERT_HEAD(&cpu->breakpoints, bp, entry);
} else {
QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);
}
breakpoint_invalidate(cpu, pc);
if (breakpoint) {
*breakpoint = bp;
}
return 0;
#else
return -ENOSYS;
#endif
}
| false | qemu | ec53b45bcd1f74f7a4c31331fa6d50b402cd6d26 | int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
CPUBreakpoint **breakpoint)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
bp = g_malloc(sizeof(*bp));
bp->pc = pc;
bp->flags = flags;
if (flags & BP_GDB) {
QTAILQ_INSERT_HEAD(&cpu->breakpoints, bp, entry);
} else {
QTAILQ_INSERT_TAIL(&cpu->breakpoints, bp, entry);
}
breakpoint_invalidate(cpu, pc);
if (breakpoint) {
*breakpoint = bp;
}
return 0;
#else
return -ENOSYS;
#endif
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0, vaddr VAR_1, int VAR_2,
CPUBreakpoint **VAR_3)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
bp = g_malloc(sizeof(*bp));
bp->VAR_1 = VAR_1;
bp->VAR_2 = VAR_2;
if (VAR_2 & BP_GDB) {
QTAILQ_INSERT_HEAD(&VAR_0->breakpoints, bp, entry);
} else {
QTAILQ_INSERT_TAIL(&VAR_0->breakpoints, bp, entry);
}
breakpoint_invalidate(VAR_0, VAR_1);
if (VAR_3) {
*VAR_3 = bp;
}
return 0;
#else
return -ENOSYS;
#endif
}
| [
"int FUNC_0(CPUState *VAR_0, vaddr VAR_1, int VAR_2,\nCPUBreakpoint **VAR_3)\n{",
"#if defined(TARGET_HAS_ICE)\nCPUBreakpoint *bp;",
"bp = g_malloc(sizeof(*bp));",
"bp->VAR_1 = VAR_1;",
"bp->VAR_2 = VAR_2;",
"if (VAR_2 & BP_GDB) {",
"QTAILQ_INSERT_HEAD(&VAR_0->breakpoints, bp, entry);",
"} else {",
"QTAILQ_INSERT_TAIL(&VAR_0->breakpoints, bp, entry);",
"}",
"breakpoint_invalidate(VAR_0, VAR_1);",
"if (VAR_3) {",
"*VAR_3 = bp;",
"}",
"return 0;",
"#else\nreturn -ENOSYS;",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
13
],
[
17
],
[
19
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53,
55
]
]
|
14,574 | static uint64_t msix_pba_mmio_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIDevice *dev = opaque;
return pci_get_long(dev->msix_pba + addr);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t msix_pba_mmio_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIDevice *dev = opaque;
return pci_get_long(dev->msix_pba + addr);
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIDevice *dev = opaque;
return pci_get_long(dev->msix_pba + addr);
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"PCIDevice *dev = opaque;",
"return pci_get_long(dev->msix_pba + addr);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
]
]
|
14,575 | static void mcf_fec_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
case 0x004:
s->eir &= ~value;
break;
case 0x008:
s->eimr = value;
break;
case 0x010: /* RDAR */
if ((s->ecr & FEC_EN) && !s->rx_enabled) {
DPRINTF("RX enable\n");
mcf_fec_enable_rx(s);
}
break;
case 0x014: /* TDAR */
if (s->ecr & FEC_EN) {
mcf_fec_do_tx(s);
}
break;
case 0x024:
s->ecr = value;
if (value & FEC_RESET) {
DPRINTF("Reset\n");
mcf_fec_reset(s);
}
if ((s->ecr & FEC_EN) == 0) {
s->rx_enabled = 0;
}
break;
case 0x040:
/* TODO: Implement MII. */
s->mmfr = value;
break;
case 0x044:
s->mscr = value & 0xfe;
break;
case 0x064:
/* TODO: Implement MIB. */
break;
case 0x084:
s->rcr = value & 0x07ff003f;
/* TODO: Implement LOOP mode. */
break;
case 0x0c4: /* TCR */
/* We transmit immediately, so raise GRA immediately. */
s->tcr = value;
if (value & 1)
s->eir |= FEC_INT_GRA;
break;
case 0x0e4: /* PALR */
s->conf.macaddr.a[0] = value >> 24;
s->conf.macaddr.a[1] = value >> 16;
s->conf.macaddr.a[2] = value >> 8;
s->conf.macaddr.a[3] = value;
break;
case 0x0e8: /* PAUR */
s->conf.macaddr.a[4] = value >> 24;
s->conf.macaddr.a[5] = value >> 16;
break;
case 0x0ec:
/* OPD */
break;
case 0x118:
case 0x11c:
case 0x120:
case 0x124:
/* TODO: implement MAC hash filtering. */
break;
case 0x144:
s->tfwr = value & 3;
break;
case 0x14c:
/* FRBR writes ignored. */
break;
case 0x150:
s->rfsr = (value & 0x3fc) | 0x400;
break;
case 0x180:
s->erdsr = value & ~3;
s->rx_descriptor = s->erdsr;
break;
case 0x184:
s->etdsr = value & ~3;
s->tx_descriptor = s->etdsr;
break;
case 0x188:
s->emrbr = value & 0x7f0;
break;
default:
hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);
}
mcf_fec_update(s);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void mcf_fec_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
switch (addr & 0x3ff) {
case 0x004:
s->eir &= ~value;
break;
case 0x008:
s->eimr = value;
break;
case 0x010:
if ((s->ecr & FEC_EN) && !s->rx_enabled) {
DPRINTF("RX enable\n");
mcf_fec_enable_rx(s);
}
break;
case 0x014:
if (s->ecr & FEC_EN) {
mcf_fec_do_tx(s);
}
break;
case 0x024:
s->ecr = value;
if (value & FEC_RESET) {
DPRINTF("Reset\n");
mcf_fec_reset(s);
}
if ((s->ecr & FEC_EN) == 0) {
s->rx_enabled = 0;
}
break;
case 0x040:
s->mmfr = value;
break;
case 0x044:
s->mscr = value & 0xfe;
break;
case 0x064:
break;
case 0x084:
s->rcr = value & 0x07ff003f;
break;
case 0x0c4:
s->tcr = value;
if (value & 1)
s->eir |= FEC_INT_GRA;
break;
case 0x0e4:
s->conf.macaddr.a[0] = value >> 24;
s->conf.macaddr.a[1] = value >> 16;
s->conf.macaddr.a[2] = value >> 8;
s->conf.macaddr.a[3] = value;
break;
case 0x0e8:
s->conf.macaddr.a[4] = value >> 24;
s->conf.macaddr.a[5] = value >> 16;
break;
case 0x0ec:
break;
case 0x118:
case 0x11c:
case 0x120:
case 0x124:
break;
case 0x144:
s->tfwr = value & 3;
break;
case 0x14c:
break;
case 0x150:
s->rfsr = (value & 0x3fc) | 0x400;
break;
case 0x180:
s->erdsr = value & ~3;
s->rx_descriptor = s->erdsr;
break;
case 0x184:
s->etdsr = value & ~3;
s->tx_descriptor = s->etdsr;
break;
case 0x188:
s->emrbr = value & 0x7f0;
break;
default:
hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);
}
mcf_fec_update(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
mcf_fec_state *s = (mcf_fec_state *)VAR_0;
switch (VAR_1 & 0x3ff) {
case 0x004:
s->eir &= ~VAR_2;
break;
case 0x008:
s->eimr = VAR_2;
break;
case 0x010:
if ((s->ecr & FEC_EN) && !s->rx_enabled) {
DPRINTF("RX enable\n");
mcf_fec_enable_rx(s);
}
break;
case 0x014:
if (s->ecr & FEC_EN) {
mcf_fec_do_tx(s);
}
break;
case 0x024:
s->ecr = VAR_2;
if (VAR_2 & FEC_RESET) {
DPRINTF("Reset\n");
mcf_fec_reset(s);
}
if ((s->ecr & FEC_EN) == 0) {
s->rx_enabled = 0;
}
break;
case 0x040:
s->mmfr = VAR_2;
break;
case 0x044:
s->mscr = VAR_2 & 0xfe;
break;
case 0x064:
break;
case 0x084:
s->rcr = VAR_2 & 0x07ff003f;
break;
case 0x0c4:
s->tcr = VAR_2;
if (VAR_2 & 1)
s->eir |= FEC_INT_GRA;
break;
case 0x0e4:
s->conf.macaddr.a[0] = VAR_2 >> 24;
s->conf.macaddr.a[1] = VAR_2 >> 16;
s->conf.macaddr.a[2] = VAR_2 >> 8;
s->conf.macaddr.a[3] = VAR_2;
break;
case 0x0e8:
s->conf.macaddr.a[4] = VAR_2 >> 24;
s->conf.macaddr.a[5] = VAR_2 >> 16;
break;
case 0x0ec:
break;
case 0x118:
case 0x11c:
case 0x120:
case 0x124:
break;
case 0x144:
s->tfwr = VAR_2 & 3;
break;
case 0x14c:
break;
case 0x150:
s->rfsr = (VAR_2 & 0x3fc) | 0x400;
break;
case 0x180:
s->erdsr = VAR_2 & ~3;
s->rx_descriptor = s->erdsr;
break;
case 0x184:
s->etdsr = VAR_2 & ~3;
s->tx_descriptor = s->etdsr;
break;
case 0x188:
s->emrbr = VAR_2 & 0x7f0;
break;
default:
hw_error("FUNC_0 Bad address 0x%x\n", (int)VAR_1);
}
mcf_fec_update(s);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"mcf_fec_state *s = (mcf_fec_state *)VAR_0;",
"switch (VAR_1 & 0x3ff) {",
"case 0x004:\ns->eir &= ~VAR_2;",
"break;",
"case 0x008:\ns->eimr = VAR_2;",
"break;",
"case 0x010:\nif ((s->ecr & FEC_EN) && !s->rx_enabled) {",
"DPRINTF(\"RX enable\\n\");",
"mcf_fec_enable_rx(s);",
"}",
"break;",
"case 0x014:\nif (s->ecr & FEC_EN) {",
"mcf_fec_do_tx(s);",
"}",
"break;",
"case 0x024:\ns->ecr = VAR_2;",
"if (VAR_2 & FEC_RESET) {",
"DPRINTF(\"Reset\\n\");",
"mcf_fec_reset(s);",
"}",
"if ((s->ecr & FEC_EN) == 0) {",
"s->rx_enabled = 0;",
"}",
"break;",
"case 0x040:\ns->mmfr = VAR_2;",
"break;",
"case 0x044:\ns->mscr = VAR_2 & 0xfe;",
"break;",
"case 0x064:\nbreak;",
"case 0x084:\ns->rcr = VAR_2 & 0x07ff003f;",
"break;",
"case 0x0c4:\ns->tcr = VAR_2;",
"if (VAR_2 & 1)\ns->eir |= FEC_INT_GRA;",
"break;",
"case 0x0e4:\ns->conf.macaddr.a[0] = VAR_2 >> 24;",
"s->conf.macaddr.a[1] = VAR_2 >> 16;",
"s->conf.macaddr.a[2] = VAR_2 >> 8;",
"s->conf.macaddr.a[3] = VAR_2;",
"break;",
"case 0x0e8:\ns->conf.macaddr.a[4] = VAR_2 >> 24;",
"s->conf.macaddr.a[5] = VAR_2 >> 16;",
"break;",
"case 0x0ec:\nbreak;",
"case 0x118:\ncase 0x11c:\ncase 0x120:\ncase 0x124:\nbreak;",
"case 0x144:\ns->tfwr = VAR_2 & 3;",
"break;",
"case 0x14c:\nbreak;",
"case 0x150:\ns->rfsr = (VAR_2 & 0x3fc) | 0x400;",
"break;",
"case 0x180:\ns->erdsr = VAR_2 & ~3;",
"s->rx_descriptor = s->erdsr;",
"break;",
"case 0x184:\ns->etdsr = VAR_2 & ~3;",
"s->tx_descriptor = s->etdsr;",
"break;",
"case 0x188:\ns->emrbr = VAR_2 & 0x7f0;",
"break;",
"default:\nhw_error(\"FUNC_0 Bad address 0x%x\\n\", (int)VAR_1);",
"}",
"mcf_fec_update(s);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79,
83
],
[
85,
87
],
[
91
],
[
93,
97
],
[
99,
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125,
129
],
[
131,
133,
135,
137,
141
],
[
143,
145
],
[
147
],
[
149,
153
],
[
155,
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175
],
[
177,
179
],
[
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
]
]
|
14,576 | static void process_incoming_migration_co(void *opaque)
{
QEMUFile *f = opaque;
Error *local_err = NULL;
int ret;
migration_incoming_state_new(f);
migrate_generate_event(MIGRATION_STATUS_ACTIVE);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
free_xbzrle_decoded_buf();
migration_incoming_state_destroy();
if (ret < 0) {
migrate_generate_event(MIGRATION_STATUS_FAILED);
error_report("load of migration failed: %s", strerror(-ret));
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
migrate_generate_event(MIGRATION_STATUS_COMPLETED);
qemu_announce_self();
/* Make sure all file formats flush their mutable metadata */
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
/* If global state section was not received or we are in running
state, we need to obey autostart. Any other state is set with
runstate_set. */
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
}
| false | qemu | ed1f3e0090069dcb9458aa9e450df12bf8eba0b0 | static void process_incoming_migration_co(void *opaque)
{
QEMUFile *f = opaque;
Error *local_err = NULL;
int ret;
migration_incoming_state_new(f);
migrate_generate_event(MIGRATION_STATUS_ACTIVE);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
free_xbzrle_decoded_buf();
migration_incoming_state_destroy();
if (ret < 0) {
migrate_generate_event(MIGRATION_STATUS_FAILED);
error_report("load of migration failed: %s", strerror(-ret));
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
migrate_generate_event(MIGRATION_STATUS_COMPLETED);
qemu_announce_self();
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
QEMUFile *f = VAR_0;
Error *local_err = NULL;
int VAR_1;
migration_incoming_state_new(f);
migrate_generate_event(MIGRATION_STATUS_ACTIVE);
VAR_1 = qemu_loadvm_state(f);
qemu_fclose(f);
free_xbzrle_decoded_buf();
migration_incoming_state_destroy();
if (VAR_1 < 0) {
migrate_generate_event(MIGRATION_STATUS_FAILED);
error_report("load of migration failed: %s", strerror(-VAR_1));
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
migrate_generate_event(MIGRATION_STATUS_COMPLETED);
qemu_announce_self();
bdrv_invalidate_cache_all(&local_err);
if (local_err) {
error_report_err(local_err);
migrate_decompress_threads_join();
exit(EXIT_FAILURE);
}
if (!global_state_received() ||
global_state_get_runstate() == RUN_STATE_RUNNING) {
if (autostart) {
vm_start();
} else {
runstate_set(RUN_STATE_PAUSED);
}
} else {
runstate_set(global_state_get_runstate());
}
migrate_decompress_threads_join();
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"QEMUFile *f = VAR_0;",
"Error *local_err = NULL;",
"int VAR_1;",
"migration_incoming_state_new(f);",
"migrate_generate_event(MIGRATION_STATUS_ACTIVE);",
"VAR_1 = qemu_loadvm_state(f);",
"qemu_fclose(f);",
"free_xbzrle_decoded_buf();",
"migration_incoming_state_destroy();",
"if (VAR_1 < 0) {",
"migrate_generate_event(MIGRATION_STATUS_FAILED);",
"error_report(\"load of migration failed: %s\", strerror(-VAR_1));",
"migrate_decompress_threads_join();",
"exit(EXIT_FAILURE);",
"}",
"migrate_generate_event(MIGRATION_STATUS_COMPLETED);",
"qemu_announce_self();",
"bdrv_invalidate_cache_all(&local_err);",
"if (local_err) {",
"error_report_err(local_err);",
"migrate_decompress_threads_join();",
"exit(EXIT_FAILURE);",
"}",
"if (!global_state_received() ||\nglobal_state_get_runstate() == RUN_STATE_RUNNING) {",
"if (autostart) {",
"vm_start();",
"} else {",
"runstate_set(RUN_STATE_PAUSED);",
"}",
"} else {",
"runstate_set(global_state_get_runstate());",
"}",
"migrate_decompress_threads_join();",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
]
]
|
14,577 | int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
{
char buf1[32], tuple_type[32];
int h, w, depth, maxval;
pnm_get(s, buf1, sizeof(buf1));
s->type= buf1[1]-'0';
if(buf1[0] != 'P')
return AVERROR_INVALIDDATA;
if (s->type==1 || s->type==4) {
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
} else if (s->type==2 || s->type==5) {
if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else if (s->type==3 || s->type==6) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else if (s->type==7) {
w = -1;
h = -1;
maxval = -1;
depth = -1;
tuple_type[0] = '\0';
for (;;) {
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1));
w = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "HEIGHT")) {
pnm_get(s, buf1, sizeof(buf1));
h = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "DEPTH")) {
pnm_get(s, buf1, sizeof(buf1));
depth = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "MAXVAL")) {
pnm_get(s, buf1, sizeof(buf1));
maxval = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "TUPLTYPE") ||
/* libavcodec used to write invalid files */
!strcmp(buf1, "TUPLETYPE")) {
pnm_get(s, tuple_type, sizeof(tuple_type));
} else if (!strcmp(buf1, "ENDHDR")) {
break;
} else {
return AVERROR_INVALIDDATA;
}
}
/* check that all tags are present */
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
s->maxval = maxval;
if (depth == 1) {
if (maxval == 1) {
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
} else if (depth == 2) {
if (maxval == 255)
avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
} else if (depth == 3) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
}
} else if (depth == 4) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGBA;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
}
} else {
return AVERROR_INVALIDDATA;
}
return 0;
} else {
return AVERROR_INVALIDDATA;
}
pnm_get(s, buf1, sizeof(buf1));
w = atoi(buf1);
pnm_get(s, buf1, sizeof(buf1));
h = atoi(buf1);
if(w <= 0 || h <= 0 || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != AV_PIX_FMT_MONOBLACK) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
if (s->maxval <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
s->maxval = 255;
}
if (s->maxval >= 256) {
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
} else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P && s->maxval < 65536) {
if (s->maxval < 512)
avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
else if (s->maxval < 1024)
avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
else
avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
avctx->pix_fmt = AV_PIX_FMT_NONE;
return AVERROR_INVALIDDATA;
}
}
}else
s->maxval=1;
/* more check if YUV420 */
if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
if ((avctx->width & 1) != 0)
return AVERROR_INVALIDDATA;
h = (avctx->height * 2);
if ((h % 3) != 0)
return AVERROR_INVALIDDATA;
h /= 3;
avctx->height = h;
}
return 0;
}
| false | FFmpeg | b4d525eb634666e39745585b17c35faed54352b6 | int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
{
char buf1[32], tuple_type[32];
int h, w, depth, maxval;
pnm_get(s, buf1, sizeof(buf1));
s->type= buf1[1]-'0';
if(buf1[0] != 'P')
return AVERROR_INVALIDDATA;
if (s->type==1 || s->type==4) {
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
} else if (s->type==2 || s->type==5) {
if (avctx->codec_id == AV_CODEC_ID_PGMYUV)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
else
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else if (s->type==3 || s->type==6) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else if (s->type==7) {
w = -1;
h = -1;
maxval = -1;
depth = -1;
tuple_type[0] = '\0';
for (;;) {
pnm_get(s, buf1, sizeof(buf1));
if (!strcmp(buf1, "WIDTH")) {
pnm_get(s, buf1, sizeof(buf1));
w = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "HEIGHT")) {
pnm_get(s, buf1, sizeof(buf1));
h = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "DEPTH")) {
pnm_get(s, buf1, sizeof(buf1));
depth = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "MAXVAL")) {
pnm_get(s, buf1, sizeof(buf1));
maxval = strtol(buf1, NULL, 10);
} else if (!strcmp(buf1, "TUPLTYPE") ||
!strcmp(buf1, "TUPLETYPE")) {
pnm_get(s, tuple_type, sizeof(tuple_type));
} else if (!strcmp(buf1, "ENDHDR")) {
break;
} else {
return AVERROR_INVALIDDATA;
}
}
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
s->maxval = maxval;
if (depth == 1) {
if (maxval == 1) {
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_GRAY8;
} else {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
} else if (depth == 2) {
if (maxval == 255)
avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
} else if (depth == 3) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGB24;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
}
} else if (depth == 4) {
if (maxval < 256) {
avctx->pix_fmt = AV_PIX_FMT_RGBA;
} else {
avctx->pix_fmt = AV_PIX_FMT_RGBA64;
}
} else {
return AVERROR_INVALIDDATA;
}
return 0;
} else {
return AVERROR_INVALIDDATA;
}
pnm_get(s, buf1, sizeof(buf1));
w = atoi(buf1);
pnm_get(s, buf1, sizeof(buf1));
h = atoi(buf1);
if(w <= 0 || h <= 0 || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != AV_PIX_FMT_MONOBLACK) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
if (s->maxval <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
s->maxval = 255;
}
if (s->maxval >= 256) {
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
avctx->pix_fmt = AV_PIX_FMT_GRAY16;
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
avctx->pix_fmt = AV_PIX_FMT_RGB48;
} else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P && s->maxval < 65536) {
if (s->maxval < 512)
avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
else if (s->maxval < 1024)
avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
else
avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
avctx->pix_fmt = AV_PIX_FMT_NONE;
return AVERROR_INVALIDDATA;
}
}
}else
s->maxval=1;
if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
if ((avctx->width & 1) != 0)
return AVERROR_INVALIDDATA;
h = (avctx->height * 2);
if ((h % 3) != 0)
return AVERROR_INVALIDDATA;
h /= 3;
avctx->height = h;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, PNMContext * const VAR_1)
{
char VAR_2[32], VAR_3[32];
int VAR_4, VAR_5, VAR_6, VAR_7;
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_1->type= VAR_2[1]-'0';
if(VAR_2[0] != 'P')
return AVERROR_INVALIDDATA;
if (VAR_1->type==1 || VAR_1->type==4) {
VAR_0->pix_fmt = AV_PIX_FMT_MONOWHITE;
} else if (VAR_1->type==2 || VAR_1->type==5) {
if (VAR_0->codec_id == AV_CODEC_ID_PGMYUV)
VAR_0->pix_fmt = AV_PIX_FMT_YUV420P;
else
VAR_0->pix_fmt = AV_PIX_FMT_GRAY8;
} else if (VAR_1->type==3 || VAR_1->type==6) {
VAR_0->pix_fmt = AV_PIX_FMT_RGB24;
} else if (VAR_1->type==7) {
VAR_5 = -1;
VAR_4 = -1;
VAR_7 = -1;
VAR_6 = -1;
VAR_3[0] = '\0';
for (;;) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
if (!strcmp(VAR_2, "WIDTH")) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_5 = strtol(VAR_2, NULL, 10);
} else if (!strcmp(VAR_2, "HEIGHT")) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_4 = strtol(VAR_2, NULL, 10);
} else if (!strcmp(VAR_2, "DEPTH")) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_6 = strtol(VAR_2, NULL, 10);
} else if (!strcmp(VAR_2, "MAXVAL")) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_7 = strtol(VAR_2, NULL, 10);
} else if (!strcmp(VAR_2, "TUPLTYPE") ||
!strcmp(VAR_2, "TUPLETYPE")) {
pnm_get(VAR_1, VAR_3, sizeof(VAR_3));
} else if (!strcmp(VAR_2, "ENDHDR")) {
break;
} else {
return AVERROR_INVALIDDATA;
}
}
if (VAR_5 <= 0 || VAR_4 <= 0 || VAR_7 <= 0 || VAR_6 <= 0 || VAR_3[0] == '\0' || av_image_check_size(VAR_5, VAR_4, 0, VAR_0) || VAR_1->bytestream >= VAR_1->bytestream_end)
return AVERROR_INVALIDDATA;
VAR_0->width = VAR_5;
VAR_0->height = VAR_4;
VAR_1->VAR_7 = VAR_7;
if (VAR_6 == 1) {
if (VAR_7 == 1) {
VAR_0->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (VAR_7 < 256) {
VAR_0->pix_fmt = AV_PIX_FMT_GRAY8;
} else {
VAR_0->pix_fmt = AV_PIX_FMT_GRAY16;
}
} else if (VAR_6 == 2) {
if (VAR_7 == 255)
VAR_0->pix_fmt = AV_PIX_FMT_GRAY8A;
} else if (VAR_6 == 3) {
if (VAR_7 < 256) {
VAR_0->pix_fmt = AV_PIX_FMT_RGB24;
} else {
VAR_0->pix_fmt = AV_PIX_FMT_RGB48;
}
} else if (VAR_6 == 4) {
if (VAR_7 < 256) {
VAR_0->pix_fmt = AV_PIX_FMT_RGBA;
} else {
VAR_0->pix_fmt = AV_PIX_FMT_RGBA64;
}
} else {
return AVERROR_INVALIDDATA;
}
return 0;
} else {
return AVERROR_INVALIDDATA;
}
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_5 = atoi(VAR_2);
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_4 = atoi(VAR_2);
if(VAR_5 <= 0 || VAR_4 <= 0 || av_image_check_size(VAR_5, VAR_4, 0, VAR_0) || VAR_1->bytestream >= VAR_1->bytestream_end)
return AVERROR_INVALIDDATA;
VAR_0->width = VAR_5;
VAR_0->height = VAR_4;
if (VAR_0->pix_fmt != AV_PIX_FMT_MONOWHITE && VAR_0->pix_fmt != AV_PIX_FMT_MONOBLACK) {
pnm_get(VAR_1, VAR_2, sizeof(VAR_2));
VAR_1->VAR_7 = atoi(VAR_2);
if (VAR_1->VAR_7 <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_7: %d\n", VAR_1->VAR_7);
VAR_1->VAR_7 = 255;
}
if (VAR_1->VAR_7 >= 256) {
if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8) {
VAR_0->pix_fmt = AV_PIX_FMT_GRAY16;
} else if (VAR_0->pix_fmt == AV_PIX_FMT_RGB24) {
VAR_0->pix_fmt = AV_PIX_FMT_RGB48;
} else if (VAR_0->pix_fmt == AV_PIX_FMT_YUV420P && VAR_1->VAR_7 < 65536) {
if (VAR_1->VAR_7 < 512)
VAR_0->pix_fmt = AV_PIX_FMT_YUV420P9;
else if (VAR_1->VAR_7 < 1024)
VAR_0->pix_fmt = AV_PIX_FMT_YUV420P10;
else
VAR_0->pix_fmt = AV_PIX_FMT_YUV420P16;
} else {
av_log(VAR_0, AV_LOG_ERROR, "Unsupported pixel format\n");
VAR_0->pix_fmt = AV_PIX_FMT_NONE;
return AVERROR_INVALIDDATA;
}
}
}else
VAR_1->VAR_7=1;
if (av_pix_fmt_desc_get(VAR_0->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
if ((VAR_0->width & 1) != 0)
return AVERROR_INVALIDDATA;
VAR_4 = (VAR_0->height * 2);
if ((VAR_4 % 3) != 0)
return AVERROR_INVALIDDATA;
VAR_4 /= 3;
VAR_0->height = VAR_4;
}
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, PNMContext * const VAR_1)\n{",
"char VAR_2[32], VAR_3[32];",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_1->type= VAR_2[1]-'0';",
"if(VAR_2[0] != 'P')\nreturn AVERROR_INVALIDDATA;",
"if (VAR_1->type==1 || VAR_1->type==4) {",
"VAR_0->pix_fmt = AV_PIX_FMT_MONOWHITE;",
"} else if (VAR_1->type==2 || VAR_1->type==5) {",
"if (VAR_0->codec_id == AV_CODEC_ID_PGMYUV)\nVAR_0->pix_fmt = AV_PIX_FMT_YUV420P;",
"else\nVAR_0->pix_fmt = AV_PIX_FMT_GRAY8;",
"} else if (VAR_1->type==3 || VAR_1->type==6) {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGB24;",
"} else if (VAR_1->type==7) {",
"VAR_5 = -1;",
"VAR_4 = -1;",
"VAR_7 = -1;",
"VAR_6 = -1;",
"VAR_3[0] = '\\0';",
"for (;;) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"if (!strcmp(VAR_2, \"WIDTH\")) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_5 = strtol(VAR_2, NULL, 10);",
"} else if (!strcmp(VAR_2, \"HEIGHT\")) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_4 = strtol(VAR_2, NULL, 10);",
"} else if (!strcmp(VAR_2, \"DEPTH\")) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_6 = strtol(VAR_2, NULL, 10);",
"} else if (!strcmp(VAR_2, \"MAXVAL\")) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_7 = strtol(VAR_2, NULL, 10);",
"} else if (!strcmp(VAR_2, \"TUPLTYPE\") ||",
"!strcmp(VAR_2, \"TUPLETYPE\")) {",
"pnm_get(VAR_1, VAR_3, sizeof(VAR_3));",
"} else if (!strcmp(VAR_2, \"ENDHDR\")) {",
"break;",
"} else {",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"if (VAR_5 <= 0 || VAR_4 <= 0 || VAR_7 <= 0 || VAR_6 <= 0 || VAR_3[0] == '\\0' || av_image_check_size(VAR_5, VAR_4, 0, VAR_0) || VAR_1->bytestream >= VAR_1->bytestream_end)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->width = VAR_5;",
"VAR_0->height = VAR_4;",
"VAR_1->VAR_7 = VAR_7;",
"if (VAR_6 == 1) {",
"if (VAR_7 == 1) {",
"VAR_0->pix_fmt = AV_PIX_FMT_MONOBLACK;",
"} else if (VAR_7 < 256) {",
"VAR_0->pix_fmt = AV_PIX_FMT_GRAY8;",
"} else {",
"VAR_0->pix_fmt = AV_PIX_FMT_GRAY16;",
"}",
"} else if (VAR_6 == 2) {",
"if (VAR_7 == 255)\nVAR_0->pix_fmt = AV_PIX_FMT_GRAY8A;",
"} else if (VAR_6 == 3) {",
"if (VAR_7 < 256) {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGB24;",
"} else {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGB48;",
"}",
"} else if (VAR_6 == 4) {",
"if (VAR_7 < 256) {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGBA;",
"} else {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGBA64;",
"}",
"} else {",
"return AVERROR_INVALIDDATA;",
"}",
"return 0;",
"} else {",
"return AVERROR_INVALIDDATA;",
"}",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_5 = atoi(VAR_2);",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_4 = atoi(VAR_2);",
"if(VAR_5 <= 0 || VAR_4 <= 0 || av_image_check_size(VAR_5, VAR_4, 0, VAR_0) || VAR_1->bytestream >= VAR_1->bytestream_end)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->width = VAR_5;",
"VAR_0->height = VAR_4;",
"if (VAR_0->pix_fmt != AV_PIX_FMT_MONOWHITE && VAR_0->pix_fmt != AV_PIX_FMT_MONOBLACK) {",
"pnm_get(VAR_1, VAR_2, sizeof(VAR_2));",
"VAR_1->VAR_7 = atoi(VAR_2);",
"if (VAR_1->VAR_7 <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_7: %d\\n\", VAR_1->VAR_7);",
"VAR_1->VAR_7 = 255;",
"}",
"if (VAR_1->VAR_7 >= 256) {",
"if (VAR_0->pix_fmt == AV_PIX_FMT_GRAY8) {",
"VAR_0->pix_fmt = AV_PIX_FMT_GRAY16;",
"} else if (VAR_0->pix_fmt == AV_PIX_FMT_RGB24) {",
"VAR_0->pix_fmt = AV_PIX_FMT_RGB48;",
"} else if (VAR_0->pix_fmt == AV_PIX_FMT_YUV420P && VAR_1->VAR_7 < 65536) {",
"if (VAR_1->VAR_7 < 512)\nVAR_0->pix_fmt = AV_PIX_FMT_YUV420P9;",
"else if (VAR_1->VAR_7 < 1024)\nVAR_0->pix_fmt = AV_PIX_FMT_YUV420P10;",
"else\nVAR_0->pix_fmt = AV_PIX_FMT_YUV420P16;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"Unsupported pixel format\\n\");",
"VAR_0->pix_fmt = AV_PIX_FMT_NONE;",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}else",
"VAR_1->VAR_7=1;",
"if (av_pix_fmt_desc_get(VAR_0->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {",
"if ((VAR_0->width & 1) != 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_4 = (VAR_0->height * 2);",
"if ((VAR_4 % 3) != 0)\nreturn AVERROR_INVALIDDATA;",
"VAR_4 /= 3;",
"VAR_0->height = VAR_4;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
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
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101,
103
],
[
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
],
[
187
],
[
189
],
[
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
],
[
249
],
[
251,
253
],
[
255
],
[
257,
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
]
]
|
14,578 | static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
struct usbdevfs_urb *urb;
AsyncURB *aurb;
int ret, rem, prem, v;
uint8_t *pbuf;
uint8_t ep;
trace_usb_host_req_data(s->bus_num, s->addr,
p->pid == USB_TOKEN_IN,
p->devep, p->iov.size);
if (!is_valid(s, p->pid, p->devep)) {
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
if (p->pid == USB_TOKEN_IN) {
ep = p->devep | 0x80;
} else {
ep = p->devep;
}
if (is_halted(s, p->pid, p->devep)) {
unsigned int arg = ep;
ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &arg);
if (ret < 0) {
perror("USBDEVFS_CLEAR_HALT");
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
clear_halt(s, p->pid, p->devep);
}
if (is_isoc(s, p->pid, p->devep)) {
return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
}
v = 0;
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
rem = p->iov.size;
while (rem) {
if (prem == 0) {
v++;
assert(v < p->iov.niov);
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
assert(prem <= rem);
}
aurb = async_alloc(s);
aurb->packet = p;
urb = &aurb->urb;
urb->endpoint = ep;
urb->type = usb_host_usbfs_type(s, p);
urb->usercontext = s;
urb->buffer = pbuf;
urb->buffer_length = prem;
if (urb->buffer_length > MAX_USBFS_BUFFER_SIZE) {
urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
}
pbuf += urb->buffer_length;
prem -= urb->buffer_length;
rem -= urb->buffer_length;
if (rem) {
aurb->more = 1;
}
trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,
urb->buffer_length, aurb->more);
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, aurb %p\n",
urb->endpoint, urb->buffer_length, aurb->more, p, aurb);
if (ret < 0) {
perror("USBDEVFS_SUBMITURB");
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
case EPIPE:
default:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);
return USB_RET_STALL;
}
}
}
return USB_RET_ASYNC;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
struct usbdevfs_urb *urb;
AsyncURB *aurb;
int ret, rem, prem, v;
uint8_t *pbuf;
uint8_t ep;
trace_usb_host_req_data(s->bus_num, s->addr,
p->pid == USB_TOKEN_IN,
p->devep, p->iov.size);
if (!is_valid(s, p->pid, p->devep)) {
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
if (p->pid == USB_TOKEN_IN) {
ep = p->devep | 0x80;
} else {
ep = p->devep;
}
if (is_halted(s, p->pid, p->devep)) {
unsigned int arg = ep;
ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &arg);
if (ret < 0) {
perror("USBDEVFS_CLEAR_HALT");
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
clear_halt(s, p->pid, p->devep);
}
if (is_isoc(s, p->pid, p->devep)) {
return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
}
v = 0;
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
rem = p->iov.size;
while (rem) {
if (prem == 0) {
v++;
assert(v < p->iov.niov);
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
assert(prem <= rem);
}
aurb = async_alloc(s);
aurb->packet = p;
urb = &aurb->urb;
urb->endpoint = ep;
urb->type = usb_host_usbfs_type(s, p);
urb->usercontext = s;
urb->buffer = pbuf;
urb->buffer_length = prem;
if (urb->buffer_length > MAX_USBFS_BUFFER_SIZE) {
urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
}
pbuf += urb->buffer_length;
prem -= urb->buffer_length;
rem -= urb->buffer_length;
if (rem) {
aurb->more = 1;
}
trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,
urb->buffer_length, aurb->more);
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, aurb %p\n",
urb->endpoint, urb->buffer_length, aurb->more, p, aurb);
if (ret < 0) {
perror("USBDEVFS_SUBMITURB");
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
case EPIPE:
default:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);
return USB_RET_STALL;
}
}
}
return USB_RET_ASYNC;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, VAR_0, VAR_0);
struct usbdevfs_urb *VAR_2;
AsyncURB *aurb;
int VAR_3, VAR_4, VAR_5, VAR_6;
uint8_t *pbuf;
uint8_t ep;
trace_usb_host_req_data(s->bus_num, s->addr,
VAR_1->pid == USB_TOKEN_IN,
VAR_1->devep, VAR_1->iov.size);
if (!is_valid(s, VAR_1->pid, VAR_1->devep)) {
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
if (VAR_1->pid == USB_TOKEN_IN) {
ep = VAR_1->devep | 0x80;
} else {
ep = VAR_1->devep;
}
if (is_halted(s, VAR_1->pid, VAR_1->devep)) {
unsigned int VAR_7 = ep;
VAR_3 = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &VAR_7);
if (VAR_3 < 0) {
perror("USBDEVFS_CLEAR_HALT");
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
clear_halt(s, VAR_1->pid, VAR_1->devep);
}
if (is_isoc(s, VAR_1->pid, VAR_1->devep)) {
return usb_host_handle_iso_data(s, VAR_1, VAR_1->pid == USB_TOKEN_IN);
}
VAR_6 = 0;
VAR_5 = VAR_1->iov.iov[VAR_6].iov_len;
pbuf = VAR_1->iov.iov[VAR_6].iov_base;
VAR_4 = VAR_1->iov.size;
while (VAR_4) {
if (VAR_5 == 0) {
VAR_6++;
assert(VAR_6 < VAR_1->iov.niov);
VAR_5 = VAR_1->iov.iov[VAR_6].iov_len;
pbuf = VAR_1->iov.iov[VAR_6].iov_base;
assert(VAR_5 <= VAR_4);
}
aurb = async_alloc(s);
aurb->packet = VAR_1;
VAR_2 = &aurb->VAR_2;
VAR_2->endpoint = ep;
VAR_2->type = usb_host_usbfs_type(s, VAR_1);
VAR_2->usercontext = s;
VAR_2->buffer = pbuf;
VAR_2->buffer_length = VAR_5;
if (VAR_2->buffer_length > MAX_USBFS_BUFFER_SIZE) {
VAR_2->buffer_length = MAX_USBFS_BUFFER_SIZE;
}
pbuf += VAR_2->buffer_length;
VAR_5 -= VAR_2->buffer_length;
VAR_4 -= VAR_2->buffer_length;
if (VAR_4) {
aurb->more = 1;
}
trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,
VAR_2->buffer_length, aurb->more);
VAR_3 = ioctl(s->fd, USBDEVFS_SUBMITURB, VAR_2);
DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %VAR_1, aurb %VAR_1\n",
VAR_2->endpoint, VAR_2->buffer_length, aurb->more, VAR_1, aurb);
if (VAR_3 < 0) {
perror("USBDEVFS_SUBMITURB");
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
case EPIPE:
default:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);
return USB_RET_STALL;
}
}
}
return USB_RET_ASYNC;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBHostDevice *s = DO_UPCAST(USBHostDevice, VAR_0, VAR_0);",
"struct usbdevfs_urb *VAR_2;",
"AsyncURB *aurb;",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"uint8_t *pbuf;",
"uint8_t ep;",
"trace_usb_host_req_data(s->bus_num, s->addr,\nVAR_1->pid == USB_TOKEN_IN,\nVAR_1->devep, VAR_1->iov.size);",
"if (!is_valid(s, VAR_1->pid, VAR_1->devep)) {",
"trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);",
"return USB_RET_NAK;",
"}",
"if (VAR_1->pid == USB_TOKEN_IN) {",
"ep = VAR_1->devep | 0x80;",
"} else {",
"ep = VAR_1->devep;",
"}",
"if (is_halted(s, VAR_1->pid, VAR_1->devep)) {",
"unsigned int VAR_7 = ep;",
"VAR_3 = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &VAR_7);",
"if (VAR_3 < 0) {",
"perror(\"USBDEVFS_CLEAR_HALT\");",
"trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);",
"return USB_RET_NAK;",
"}",
"clear_halt(s, VAR_1->pid, VAR_1->devep);",
"}",
"if (is_isoc(s, VAR_1->pid, VAR_1->devep)) {",
"return usb_host_handle_iso_data(s, VAR_1, VAR_1->pid == USB_TOKEN_IN);",
"}",
"VAR_6 = 0;",
"VAR_5 = VAR_1->iov.iov[VAR_6].iov_len;",
"pbuf = VAR_1->iov.iov[VAR_6].iov_base;",
"VAR_4 = VAR_1->iov.size;",
"while (VAR_4) {",
"if (VAR_5 == 0) {",
"VAR_6++;",
"assert(VAR_6 < VAR_1->iov.niov);",
"VAR_5 = VAR_1->iov.iov[VAR_6].iov_len;",
"pbuf = VAR_1->iov.iov[VAR_6].iov_base;",
"assert(VAR_5 <= VAR_4);",
"}",
"aurb = async_alloc(s);",
"aurb->packet = VAR_1;",
"VAR_2 = &aurb->VAR_2;",
"VAR_2->endpoint = ep;",
"VAR_2->type = usb_host_usbfs_type(s, VAR_1);",
"VAR_2->usercontext = s;",
"VAR_2->buffer = pbuf;",
"VAR_2->buffer_length = VAR_5;",
"if (VAR_2->buffer_length > MAX_USBFS_BUFFER_SIZE) {",
"VAR_2->buffer_length = MAX_USBFS_BUFFER_SIZE;",
"}",
"pbuf += VAR_2->buffer_length;",
"VAR_5 -= VAR_2->buffer_length;",
"VAR_4 -= VAR_2->buffer_length;",
"if (VAR_4) {",
"aurb->more = 1;",
"}",
"trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,\nVAR_2->buffer_length, aurb->more);",
"VAR_3 = ioctl(s->fd, USBDEVFS_SUBMITURB, VAR_2);",
"DPRINTF(\"husb: data submit: ep 0x%x, len %u, more %d, packet %VAR_1, aurb %VAR_1\\n\",\nVAR_2->endpoint, VAR_2->buffer_length, aurb->more, VAR_1, aurb);",
"if (VAR_3 < 0) {",
"perror(\"USBDEVFS_SUBMITURB\");",
"async_free(aurb);",
"switch(errno) {",
"case ETIMEDOUT:\ntrace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);",
"return USB_RET_NAK;",
"case EPIPE:\ndefault:\ntrace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);",
"return USB_RET_STALL;",
"}",
"}",
"}",
"return USB_RET_ASYNC;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143,
145
],
[
147
],
[
151,
153
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167,
169
],
[
171
],
[
173,
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
]
]
|
14,579 | static void checkpoint(void) {
assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);
check1(vvv);
check2(vvv);
assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));
#if 0
if (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)
fprintf(stderr, "Nonono!\n");
mapping_t* mapping;
direntry_t* direntry;
assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);
assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);
if (vvv->mapping.next<47)
return;
assert((mapping = array_get(&(vvv->mapping), 47)));
assert(mapping->dir_index < vvv->directory.next);
direntry = array_get(&(vvv->directory), mapping->dir_index);
assert(!memcmp(direntry->name, "USB H ", 11) || direntry->name[0]==0);
#endif
}
| false | qemu | 7a6ab45e19b615b9285b9cfa2bbc1fee012bc8d7 | static void checkpoint(void) {
assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);
check1(vvv);
check2(vvv);
assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));
#if 0
if (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)
fprintf(stderr, "Nonono!\n");
mapping_t* mapping;
direntry_t* direntry;
assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);
assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);
if (vvv->mapping.next<47)
return;
assert((mapping = array_get(&(vvv->mapping), 47)));
assert(mapping->dir_index < vvv->directory.next);
direntry = array_get(&(vvv->directory), mapping->dir_index);
assert(!memcmp(direntry->name, "USB H ", 11) || direntry->name[0]==0);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void) {
assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);
check1(vvv);
check2(vvv);
assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));
#if 0
if (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)
fprintf(stderr, "Nonono!\n");
mapping_t* mapping;
direntry_t* direntry;
assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);
assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);
if (vvv->mapping.next<47)
return;
assert((mapping = array_get(&(vvv->mapping), 47)));
assert(mapping->dir_index < vvv->directory.next);
direntry = array_get(&(vvv->directory), mapping->dir_index);
assert(!memcmp(direntry->name, "USB H ", 11) || direntry->name[0]==0);
#endif
}
| [
"static void FUNC_0(void) {",
"assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);",
"check1(vvv);",
"check2(vvv);",
"assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));",
"#if 0\nif (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)\nfprintf(stderr, \"Nonono!\\n\");",
"mapping_t* mapping;",
"direntry_t* direntry;",
"assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);",
"assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);",
"if (vvv->mapping.next<47)\nreturn;",
"assert((mapping = array_get(&(vvv->mapping), 47)));",
"assert(mapping->dir_index < vvv->directory.next);",
"direntry = array_get(&(vvv->directory), mapping->dir_index);",
"assert(!memcmp(direntry->name, \"USB H \", 11) || direntry->name[0]==0);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
]
]
|
14,580 | static void spapr_hotplug_set_signalled(uint32_t drc_index)
{
sPAPRDRConnector *drc = spapr_drc_by_index(drc_index);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->set_signalled(drc);
}
| false | qemu | 307b7715d0256c95444cada36a02882e46bada2f | static void spapr_hotplug_set_signalled(uint32_t drc_index)
{
sPAPRDRConnector *drc = spapr_drc_by_index(drc_index);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->set_signalled(drc);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint32_t VAR_0)
{
sPAPRDRConnector *drc = spapr_drc_by_index(VAR_0);
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->set_signalled(drc);
}
| [
"static void FUNC_0(uint32_t VAR_0)\n{",
"sPAPRDRConnector *drc = spapr_drc_by_index(VAR_0);",
"sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"drck->set_signalled(drc);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,581 | static uint32_t apic_mem_readb(void *opaque, target_phys_addr_t addr)
{
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t apic_mem_readb(void *opaque, target_phys_addr_t addr)
{
return 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"return 0;",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,582 | int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (!drv) {
return -ENOMEDIUM;
}
if (drv->bdrv_get_allocated_file_size) {
return drv->bdrv_get_allocated_file_size(bs);
}
if (bs->file) {
return bdrv_get_allocated_file_size(bs->file);
}
return -ENOTSUP;
}
| false | qemu | 61007b316cd71ee7333ff7a0a749a8949527575f | int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (!drv) {
return -ENOMEDIUM;
}
if (drv->bdrv_get_allocated_file_size) {
return drv->bdrv_get_allocated_file_size(bs);
}
if (bs->file) {
return bdrv_get_allocated_file_size(bs->file);
}
return -ENOTSUP;
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
if (!drv) {
return -ENOMEDIUM;
}
if (drv->FUNC_0) {
return drv->FUNC_0(bs);
}
if (bs->file) {
return FUNC_0(bs->file);
}
return -ENOTSUP;
}
| [
"int64_t FUNC_0(BlockDriverState *bs)\n{",
"BlockDriver *drv = bs->drv;",
"if (!drv) {",
"return -ENOMEDIUM;",
"}",
"if (drv->FUNC_0) {",
"return drv->FUNC_0(bs);",
"}",
"if (bs->file) {",
"return FUNC_0(bs->file);",
"}",
"return -ENOTSUP;",
"}"
]
| [
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
]
]
|
14,583 | static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint8_t ret;
switch (addr) {
case ICCR0:
return s->control[0];
case ICCR1:
return s->control[1];
case ICCR2:
return s->control[2];
case ICDR:
s->status[0] &= ~0x01;
s->status[1] &= ~0x72;
if (s->rx_len) {
s->rx_len --;
ret = s->rx_fifo[s->rx_start ++];
s->rx_start &= 63;
pxa2xx_fir_update(s);
return ret;
}
printf("%s: Rx FIFO underrun.\n", __FUNCTION__);
break;
case ICSR0:
return s->status[0];
case ICSR1:
return s->status[1] | (1 << 3); /* TNF */
case ICFOR:
return s->rx_len;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| false | qemu | a89f364ae8740dfc31b321eed9ee454e996dc3c1 | static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint8_t ret;
switch (addr) {
case ICCR0:
return s->control[0];
case ICCR1:
return s->control[1];
case ICCR2:
return s->control[2];
case ICDR:
s->status[0] &= ~0x01;
s->status[1] &= ~0x72;
if (s->rx_len) {
s->rx_len --;
ret = s->rx_fifo[s->rx_start ++];
s->rx_start &= 63;
pxa2xx_fir_update(s);
return ret;
}
printf("%s: Rx FIFO underrun.\n", __FUNCTION__);
break;
case ICSR0:
return s->status[0];
case ICSR1:
return s->status[1] | (1 << 3);
case ICFOR:
return s->rx_len;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{
PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;
uint8_t ret;
switch (addr) {
case ICCR0:
return s->control[0];
case ICCR1:
return s->control[1];
case ICCR2:
return s->control[2];
case ICDR:
s->status[0] &= ~0x01;
s->status[1] &= ~0x72;
if (s->rx_len) {
s->rx_len --;
ret = s->rx_fifo[s->rx_start ++];
s->rx_start &= 63;
pxa2xx_fir_update(s);
return ret;
}
printf("%s: Rx FIFO underrun.\n", __FUNCTION__);
break;
case ICSR0:
return s->status[0];
case ICSR1:
return s->status[1] | (1 << 3);
case ICFOR:
return s->rx_len;
default:
printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr);
break;
}
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr,\nunsigned size)\n{",
"PXA2xxFIrState *s = (PXA2xxFIrState *) opaque;",
"uint8_t ret;",
"switch (addr) {",
"case ICCR0:\nreturn s->control[0];",
"case ICCR1:\nreturn s->control[1];",
"case ICCR2:\nreturn s->control[2];",
"case ICDR:\ns->status[0] &= ~0x01;",
"s->status[1] &= ~0x72;",
"if (s->rx_len) {",
"s->rx_len --;",
"ret = s->rx_fifo[s->rx_start ++];",
"s->rx_start &= 63;",
"pxa2xx_fir_update(s);",
"return ret;",
"}",
"printf(\"%s: Rx FIFO underrun.\\n\", __FUNCTION__);",
"break;",
"case ICSR0:\nreturn s->status[0];",
"case ICSR1:\nreturn s->status[1] | (1 << 3);",
"case ICFOR:\nreturn s->rx_len;",
"default:\nprintf(\"%s: Bad register \" REG_FMT \"\\n\", __FUNCTION__, addr);",
"break;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
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
]
]
|
14,584 | static char *addr_to_string(const char *format,
struct sockaddr_storage *sa,
socklen_t salen) {
char *addr;
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
int err;
if ((err = getnameinfo((struct sockaddr *)sa, salen,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
VNC_DEBUG("Cannot resolve address %d: %s\n",
err, gai_strerror(err));
return NULL;
}
if (asprintf(&addr, format, host, serv) < 0)
return NULL;
return addr;
}
| false | qemu | 457772e68f83ea02a33b58a70bd25ec5c028c077 | static char *addr_to_string(const char *format,
struct sockaddr_storage *sa,
socklen_t salen) {
char *addr;
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
int err;
if ((err = getnameinfo((struct sockaddr *)sa, salen,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
VNC_DEBUG("Cannot resolve address %d: %s\n",
err, gai_strerror(err));
return NULL;
}
if (asprintf(&addr, format, host, serv) < 0)
return NULL;
return addr;
}
| {
"code": [],
"line_no": []
} | static char *FUNC_0(const char *VAR_0,
struct sockaddr_storage *VAR_1,
socklen_t VAR_2) {
char *VAR_3;
char VAR_4[NI_MAXHOST];
char VAR_5[NI_MAXSERV];
int VAR_6;
if ((VAR_6 = getnameinfo((struct sockaddr *)VAR_1, VAR_2,
VAR_4, sizeof(VAR_4),
VAR_5, sizeof(VAR_5),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
VNC_DEBUG("Cannot resolve address %d: %s\n",
VAR_6, gai_strerror(VAR_6));
return NULL;
}
if (asprintf(&VAR_3, VAR_0, VAR_4, VAR_5) < 0)
return NULL;
return VAR_3;
}
| [
"static char *FUNC_0(const char *VAR_0,\nstruct sockaddr_storage *VAR_1,\nsocklen_t VAR_2) {",
"char *VAR_3;",
"char VAR_4[NI_MAXHOST];",
"char VAR_5[NI_MAXSERV];",
"int VAR_6;",
"if ((VAR_6 = getnameinfo((struct sockaddr *)VAR_1, VAR_2,\nVAR_4, sizeof(VAR_4),\nVAR_5, sizeof(VAR_5),\nNI_NUMERICHOST | NI_NUMERICSERV)) != 0) {",
"VNC_DEBUG(\"Cannot resolve address %d: %s\\n\",\nVAR_6, gai_strerror(VAR_6));",
"return NULL;",
"}",
"if (asprintf(&VAR_3, VAR_0, VAR_4, VAR_5) < 0)\nreturn NULL;",
"return VAR_3;",
"}"
]
| [
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
],
[
41
],
[
43
]
]
|
14,585 | static void sys_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
LM32SysState *s = opaque;
char *testname;
trace_lm32_sys_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_CTRL:
qemu_system_shutdown_request();
break;
case R_PASSFAIL:
s->regs[addr] = value;
testname = (char *)s->testname;
qemu_log("TC %-16s %s\n", testname, (value) ? "FAILED" : "OK");
break;
case R_TESTNAME:
s->regs[addr] = value;
copy_testname(s);
break;
default:
error_report("lm32_sys: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void sys_write(void *opaque, target_phys_addr_t addr,
uint64_t value, unsigned size)
{
LM32SysState *s = opaque;
char *testname;
trace_lm32_sys_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_CTRL:
qemu_system_shutdown_request();
break;
case R_PASSFAIL:
s->regs[addr] = value;
testname = (char *)s->testname;
qemu_log("TC %-16s %s\n", testname, (value) ? "FAILED" : "OK");
break;
case R_TESTNAME:
s->regs[addr] = value;
copy_testname(s);
break;
default:
error_report("lm32_sys: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
LM32SysState *s = VAR_0;
char *VAR_4;
trace_lm32_sys_memory_write(VAR_1, VAR_2);
VAR_1 >>= 2;
switch (VAR_1) {
case R_CTRL:
qemu_system_shutdown_request();
break;
case R_PASSFAIL:
s->regs[VAR_1] = VAR_2;
VAR_4 = (char *)s->VAR_4;
qemu_log("TC %-16s %s\n", VAR_4, (VAR_2) ? "FAILED" : "OK");
break;
case R_TESTNAME:
s->regs[VAR_1] = VAR_2;
copy_testname(s);
break;
default:
error_report("lm32_sys: write access to unknown register 0x"
TARGET_FMT_plx, VAR_1 << 2);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"LM32SysState *s = VAR_0;",
"char *VAR_4;",
"trace_lm32_sys_memory_write(VAR_1, VAR_2);",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_CTRL:\nqemu_system_shutdown_request();",
"break;",
"case R_PASSFAIL:\ns->regs[VAR_1] = VAR_2;",
"VAR_4 = (char *)s->VAR_4;",
"qemu_log(\"TC %-16s %s\\n\", VAR_4, (VAR_2) ? \"FAILED\" : \"OK\");",
"break;",
"case R_TESTNAME:\ns->regs[VAR_1] = VAR_2;",
"copy_testname(s);",
"break;",
"default:\nerror_report(\"lm32_sys: write access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
47,
49,
51
],
[
53
],
[
55
],
[
57
]
]
|
14,586 | int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap, int64_t sector,
int nb_sectors)
{
uint64_t i;
int sectors_per_bit = 1 << hbitmap_granularity(bitmap->meta);
/* To optimize: we can make hbitmap to internally check the range in a
* coarse level, or at least do it word by word. */
for (i = sector; i < sector + nb_sectors; i += sectors_per_bit) {
if (hbitmap_get(bitmap->meta, i)) {
return true;
}
}
return false;
}
| false | qemu | b64bd51efa9bbf30df1b2f91477d2805678d0b93 | int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap, int64_t sector,
int nb_sectors)
{
uint64_t i;
int sectors_per_bit = 1 << hbitmap_granularity(bitmap->meta);
for (i = sector; i < sector + nb_sectors; i += sectors_per_bit) {
if (hbitmap_get(bitmap->meta, i)) {
return true;
}
}
return false;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0,
BdrvDirtyBitmap *VAR_1, int64_t VAR_2,
int VAR_3)
{
uint64_t i;
int VAR_4 = 1 << hbitmap_granularity(VAR_1->meta);
for (i = VAR_2; i < VAR_2 + VAR_3; i += VAR_4) {
if (hbitmap_get(VAR_1->meta, i)) {
return true;
}
}
return false;
}
| [
"int FUNC_0(BlockDriverState *VAR_0,\nBdrvDirtyBitmap *VAR_1, int64_t VAR_2,\nint VAR_3)\n{",
"uint64_t i;",
"int VAR_4 = 1 << hbitmap_granularity(VAR_1->meta);",
"for (i = VAR_2; i < VAR_2 + VAR_3; i += VAR_4) {",
"if (hbitmap_get(VAR_1->meta, i)) {",
"return true;",
"}",
"}",
"return false;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
14,590 | void vring_disable_notification(VirtIODevice *vdev, Vring *vring)
{
if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
}
}
| false | qemu | ef546f1275f6563e8934dd5e338d29d9f9909ca6 | void vring_disable_notification(VirtIODevice *vdev, Vring *vring)
{
if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(VirtIODevice *VAR_0, Vring *VAR_1)
{
if (!(VAR_0->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
vring_set_used_flags(VAR_0, VAR_1, VRING_USED_F_NO_NOTIFY);
}
}
| [
"void FUNC_0(VirtIODevice *VAR_0, Vring *VAR_1)\n{",
"if (!(VAR_0->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {",
"vring_set_used_flags(VAR_0, VAR_1, VRING_USED_F_NO_NOTIFY);",
"}",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,592 | static abi_long do_accept(int fd, abi_ulong target_addr,
abi_ulong target_addrlen_addr)
{
socklen_t addrlen;
void *addr;
abi_long ret;
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
ret = get_errno(accept(fd, addr, &addrlen));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, addr, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
ret = -TARGET_EFAULT;
}
return ret;
}
| false | qemu | 917507b01efea8017bfcb4188ac696612e363e72 | static abi_long do_accept(int fd, abi_ulong target_addr,
abi_ulong target_addrlen_addr)
{
socklen_t addrlen;
void *addr;
abi_long ret;
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
ret = get_errno(accept(fd, addr, &addrlen));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, addr, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
ret = -TARGET_EFAULT;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static abi_long FUNC_0(int fd, abi_ulong target_addr,
abi_ulong target_addrlen_addr)
{
socklen_t addrlen;
void *VAR_0;
abi_long ret;
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
if (addrlen < 0)
return -TARGET_EINVAL;
VAR_0 = alloca(addrlen);
ret = get_errno(accept(fd, VAR_0, &addrlen));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, VAR_0, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
ret = -TARGET_EFAULT;
}
return ret;
}
| [
"static abi_long FUNC_0(int fd, abi_ulong target_addr,\nabi_ulong target_addrlen_addr)\n{",
"socklen_t addrlen;",
"void *VAR_0;",
"abi_long ret;",
"if (get_user_u32(addrlen, target_addrlen_addr))\nreturn -TARGET_EFAULT;",
"if (addrlen < 0)\nreturn -TARGET_EINVAL;",
"VAR_0 = alloca(addrlen);",
"ret = get_errno(accept(fd, VAR_0, &addrlen));",
"if (!is_error(ret)) {",
"host_to_target_sockaddr(target_addr, VAR_0, addrlen);",
"if (put_user_u32(addrlen, target_addrlen_addr))\nret = -TARGET_EFAULT;",
"}",
"return ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21,
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
]
]
|
14,593 | static void mirror_write_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
if (ret < 0) {
BlockDriverState *source = s->common.bs;
BlockErrorAction action;
bdrv_set_dirty(source, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, false, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
}
mirror_iteration_done(op, ret);
}
| true | qemu | c4237dfa635900e4d1cdc6038d5efe3507f45f0c | static void mirror_write_complete(void *opaque, int ret)
{
MirrorOp *op = opaque;
MirrorBlockJob *s = op->s;
if (ret < 0) {
BlockDriverState *source = s->common.bs;
BlockErrorAction action;
bdrv_set_dirty(source, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, false, -ret);
if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) {
s->ret = ret;
}
}
mirror_iteration_done(op, ret);
}
| {
"code": [
" bdrv_set_dirty(source, op->sector_num, op->nb_sectors);",
" bdrv_set_dirty(source, op->sector_num, op->nb_sectors);"
],
"line_no": [
17,
17
]
} | static void FUNC_0(void *VAR_0, int VAR_1)
{
MirrorOp *op = VAR_0;
MirrorBlockJob *s = op->s;
if (VAR_1 < 0) {
BlockDriverState *source = s->common.bs;
BlockErrorAction action;
bdrv_set_dirty(source, op->sector_num, op->nb_sectors);
action = mirror_error_action(s, false, -VAR_1);
if (action == BLOCK_ERROR_ACTION_REPORT && s->VAR_1 >= 0) {
s->VAR_1 = VAR_1;
}
}
mirror_iteration_done(op, VAR_1);
}
| [
"static void FUNC_0(void *VAR_0, int VAR_1)\n{",
"MirrorOp *op = VAR_0;",
"MirrorBlockJob *s = op->s;",
"if (VAR_1 < 0) {",
"BlockDriverState *source = s->common.bs;",
"BlockErrorAction action;",
"bdrv_set_dirty(source, op->sector_num, op->nb_sectors);",
"action = mirror_error_action(s, false, -VAR_1);",
"if (action == BLOCK_ERROR_ACTION_REPORT && s->VAR_1 >= 0) {",
"s->VAR_1 = VAR_1;",
"}",
"}",
"mirror_iteration_done(op, VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
14,594 | void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
{
SHPCDevice *shpc = d->shpc;
d->cap_present &= ~QEMU_PCI_CAP_SHPC;
memory_region_del_subregion(bar, &shpc->mmio);
/* TODO: cleanup config space changes? */
g_free(shpc->config);
g_free(shpc->cmask);
g_free(shpc->wmask);
g_free(shpc->w1cmask);
g_free(shpc);
} | true | qemu | 109e90e47029f415783cd6e9a0eb9d0f10954c18 | void shpc_cleanup(PCIDevice *d, MemoryRegion *bar)
{
SHPCDevice *shpc = d->shpc;
d->cap_present &= ~QEMU_PCI_CAP_SHPC;
memory_region_del_subregion(bar, &shpc->mmio);
g_free(shpc->config);
g_free(shpc->cmask);
g_free(shpc->wmask);
g_free(shpc->w1cmask);
g_free(shpc);
} | {
"code": [],
"line_no": []
} | void FUNC_0(PCIDevice *VAR_0, MemoryRegion *VAR_1)
{
SHPCDevice *shpc = VAR_0->shpc;
VAR_0->cap_present &= ~QEMU_PCI_CAP_SHPC;
memory_region_del_subregion(VAR_1, &shpc->mmio);
g_free(shpc->config);
g_free(shpc->cmask);
g_free(shpc->wmask);
g_free(shpc->w1cmask);
g_free(shpc);
} | [
"void FUNC_0(PCIDevice *VAR_0, MemoryRegion *VAR_1)\n{",
"SHPCDevice *shpc = VAR_0->shpc;",
"VAR_0->cap_present &= ~QEMU_PCI_CAP_SHPC;",
"memory_region_del_subregion(VAR_1, &shpc->mmio);",
"g_free(shpc->config);",
"g_free(shpc->cmask);",
"g_free(shpc->wmask);",
"g_free(shpc->w1cmask);",
"g_free(shpc);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
14
],
[
16
],
[
18
],
[
20
],
[
22
],
[
24
]
]
|
14,595 | void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
QGuestAllocator *alloc, uint16_t entry)
{
uint16_t vector;
uint32_t control;
void *addr;
g_assert(d->pdev->msix_enabled);
addr = d->pdev->msix_table + (entry * 16);
g_assert_cmpint(entry, >=, 0);
g_assert_cmpint(entry, <, qpci_msix_table_size(d->pdev));
vqpci->msix_entry = entry;
vqpci->msix_addr = guest_alloc(alloc, 4);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_LOWER_ADDR,
vqpci->msix_addr & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_UPPER_ADDR,
(vqpci->msix_addr >> 32) & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_DATA, vqpci->msix_data);
control = qpci_io_readl(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
qvirtio_pci_queue_select(&d->vdev, vqpci->vq.index);
qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR, entry);
vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR);
g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
| true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
QGuestAllocator *alloc, uint16_t entry)
{
uint16_t vector;
uint32_t control;
void *addr;
g_assert(d->pdev->msix_enabled);
addr = d->pdev->msix_table + (entry * 16);
g_assert_cmpint(entry, >=, 0);
g_assert_cmpint(entry, <, qpci_msix_table_size(d->pdev));
vqpci->msix_entry = entry;
vqpci->msix_addr = guest_alloc(alloc, 4);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_LOWER_ADDR,
vqpci->msix_addr & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_UPPER_ADDR,
(vqpci->msix_addr >> 32) & ~0UL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_DATA, vqpci->msix_data);
control = qpci_io_readl(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
qvirtio_pci_queue_select(&d->vdev, vqpci->vq.index);
qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR, entry);
vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR);
g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
| {
"code": [
" void *addr;",
" addr = d->pdev->msix_table + (entry * 16);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_LOWER_ADDR,",
" vqpci->msix_addr & ~0UL);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_UPPER_ADDR,",
" (vqpci->msix_addr >> 32) & ~0UL);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_DATA, vqpci->msix_data);",
" control = qpci_io_readl(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,",
" control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);",
" qpci_io_writew(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR, entry);",
" vector = qpci_io_readw(d->pdev, d->addr + VIRTIO_MSI_QUEUE_VECTOR);",
" void *addr;",
" addr = d->pdev->msix_table + (entry * 16);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_LOWER_ADDR,",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_UPPER_ADDR,",
" control = qpci_io_readl(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL);",
" qpci_io_writel(d->pdev, addr + PCI_MSIX_ENTRY_VECTOR_CTRL,",
" control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);",
" void *addr;"
],
"line_no": [
11,
17,
31,
33,
35,
37,
39,
43,
45,
47,
53,
55,
11,
17,
31,
35,
43,
45,
47,
11
]
} | void FUNC_0(QVirtioPCIDevice *VAR_0, QVirtQueuePCI *VAR_1,
QGuestAllocator *VAR_2, uint16_t VAR_3)
{
uint16_t vector;
uint32_t control;
void *VAR_4;
g_assert(VAR_0->pdev->msix_enabled);
VAR_4 = VAR_0->pdev->msix_table + (VAR_3 * 16);
g_assert_cmpint(VAR_3, >=, 0);
g_assert_cmpint(VAR_3, <, qpci_msix_table_size(VAR_0->pdev));
VAR_1->msix_entry = VAR_3;
VAR_1->msix_addr = guest_alloc(VAR_2, 4);
qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_LOWER_ADDR,
VAR_1->msix_addr & ~0UL);
qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_UPPER_ADDR,
(VAR_1->msix_addr >> 32) & ~0UL);
qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_DATA, VAR_1->msix_data);
control = qpci_io_readl(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_VECTOR_CTRL);
qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_VECTOR_CTRL,
control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);
qvirtio_pci_queue_select(&VAR_0->vdev, VAR_1->vq.index);
qpci_io_writew(VAR_0->pdev, VAR_0->VAR_4 + VIRTIO_MSI_QUEUE_VECTOR, VAR_3);
vector = qpci_io_readw(VAR_0->pdev, VAR_0->VAR_4 + VIRTIO_MSI_QUEUE_VECTOR);
g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);
}
| [
"void FUNC_0(QVirtioPCIDevice *VAR_0, QVirtQueuePCI *VAR_1,\nQGuestAllocator *VAR_2, uint16_t VAR_3)\n{",
"uint16_t vector;",
"uint32_t control;",
"void *VAR_4;",
"g_assert(VAR_0->pdev->msix_enabled);",
"VAR_4 = VAR_0->pdev->msix_table + (VAR_3 * 16);",
"g_assert_cmpint(VAR_3, >=, 0);",
"g_assert_cmpint(VAR_3, <, qpci_msix_table_size(VAR_0->pdev));",
"VAR_1->msix_entry = VAR_3;",
"VAR_1->msix_addr = guest_alloc(VAR_2, 4);",
"qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_LOWER_ADDR,\nVAR_1->msix_addr & ~0UL);",
"qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_UPPER_ADDR,\n(VAR_1->msix_addr >> 32) & ~0UL);",
"qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_DATA, VAR_1->msix_data);",
"control = qpci_io_readl(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_VECTOR_CTRL);",
"qpci_io_writel(VAR_0->pdev, VAR_4 + PCI_MSIX_ENTRY_VECTOR_CTRL,\ncontrol & ~PCI_MSIX_ENTRY_CTRL_MASKBIT);",
"qvirtio_pci_queue_select(&VAR_0->vdev, VAR_1->vq.index);",
"qpci_io_writew(VAR_0->pdev, VAR_0->VAR_4 + VIRTIO_MSI_QUEUE_VECTOR, VAR_3);",
"vector = qpci_io_readw(VAR_0->pdev, VAR_0->VAR_4 + VIRTIO_MSI_QUEUE_VECTOR);",
"g_assert_cmphex(vector, !=, VIRTIO_MSI_NO_VECTOR);",
"}"
]
| [
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
1,
1,
1,
1,
0,
1,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
43
],
[
45,
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
]
]
|
14,596 | int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)
{
return kvm_dirty_pages_log_change(phys_addr, end_addr,
KVM_MEM_LOG_DIRTY_PAGES,
KVM_MEM_LOG_DIRTY_PAGES);
}
| true | qemu | d3f8d37fe2d0c24ec8bac9c94d5b0e2dc09c0d2a | int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)
{
return kvm_dirty_pages_log_change(phys_addr, end_addr,
KVM_MEM_LOG_DIRTY_PAGES,
KVM_MEM_LOG_DIRTY_PAGES);
}
| {
"code": [
"int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t end_addr)",
" return kvm_dirty_pages_log_change(phys_addr, end_addr,",
" return kvm_dirty_pages_log_change(phys_addr, end_addr,"
],
"line_no": [
1,
5,
5
]
} | int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1)
{
return kvm_dirty_pages_log_change(VAR_0, VAR_1,
KVM_MEM_LOG_DIRTY_PAGES,
KVM_MEM_LOG_DIRTY_PAGES);
}
| [
"int FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t VAR_1)\n{",
"return kvm_dirty_pages_log_change(VAR_0, VAR_1,\nKVM_MEM_LOG_DIRTY_PAGES,\nKVM_MEM_LOG_DIRTY_PAGES);",
"}"
]
| [
1,
1,
0
]
| [
[
1,
3
],
[
5,
7,
9
],
[
11
]
]
|
14,597 | static uint64_t master_abort_mem_read(void *opaque, hwaddr addr, unsigned size)
{
return -1ULL;
}
| true | qemu | 0fbf50b6ec126600dca115adb1563c657cc27695 | static uint64_t master_abort_mem_read(void *opaque, hwaddr addr, unsigned size)
{
return -1ULL;
}
| {
"code": [
"static uint64_t master_abort_mem_read(void *opaque, hwaddr addr, unsigned size)",
" return -1ULL;"
],
"line_no": [
1,
5
]
} | static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)
{
return -1ULL;
}
| [
"static uint64_t FUNC_0(void *opaque, hwaddr addr, unsigned size)\n{",
"return -1ULL;",
"}"
]
| [
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,598 | static av_cold int a64multi_encode_init(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
int a;
av_lfg_init(&c->randctx, 1);
if (avctx->global_quality < 1) {
c->mc_lifetime = 4;
} else {
c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA;
}
av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime);
c->mc_frame_counter = 0;
c->mc_use_5col = avctx->codec->id == AV_CODEC_ID_A64_MULTI5;
c->mc_pal_size = 4 + c->mc_use_5col;
/* precalc luma values for later use */
for (a = 0; a < c->mc_pal_size; a++) {
c->mc_luma_vals[a]=a64_palette[mc_colors[a]][0] * 0.30 +
a64_palette[mc_colors[a]][1] * 0.59 +
a64_palette[mc_colors[a]][2] * 0.11;
}
if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
!(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
!(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
return AVERROR(ENOMEM);
}
/* set up extradata */
if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
return AVERROR(ENOMEM);
}
avctx->extradata_size = 8 * 4;
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) {
a64multi_close_encoder(avctx);
return AVERROR(ENOMEM);
}
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("a64m");
c->next_pts = AV_NOPTS_VALUE;
return 0;
}
| true | FFmpeg | ab759f8f4a3f7178361e32ab719e6bc49d8afecb | static av_cold int a64multi_encode_init(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
int a;
av_lfg_init(&c->randctx, 1);
if (avctx->global_quality < 1) {
c->mc_lifetime = 4;
} else {
c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA;
}
av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime);
c->mc_frame_counter = 0;
c->mc_use_5col = avctx->codec->id == AV_CODEC_ID_A64_MULTI5;
c->mc_pal_size = 4 + c->mc_use_5col;
for (a = 0; a < c->mc_pal_size; a++) {
c->mc_luma_vals[a]=a64_palette[mc_colors[a]][0] * 0.30 +
a64_palette[mc_colors[a]][1] * 0.59 +
a64_palette[mc_colors[a]][2] * 0.11;
}
if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
!(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
!(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
return AVERROR(ENOMEM);
}
if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
return AVERROR(ENOMEM);
}
avctx->extradata_size = 8 * 4;
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) {
a64multi_close_encoder(avctx);
return AVERROR(ENOMEM);
}
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("a64m");
c->next_pts = AV_NOPTS_VALUE;
return 0;
}
| {
"code": [
" if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||"
],
"line_no": [
51
]
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
int VAR_0;
av_lfg_init(&c->randctx, 1);
if (avctx->global_quality < 1) {
c->mc_lifetime = 4;
} else {
c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA;
}
av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime);
c->mc_frame_counter = 0;
c->mc_use_5col = avctx->codec->id == AV_CODEC_ID_A64_MULTI5;
c->mc_pal_size = 4 + c->mc_use_5col;
for (VAR_0 = 0; VAR_0 < c->mc_pal_size; VAR_0++) {
c->mc_luma_vals[VAR_0]=a64_palette[mc_colors[VAR_0]][0] * 0.30 +
a64_palette[mc_colors[VAR_0]][1] * 0.59 +
a64_palette[mc_colors[VAR_0]][2] * 0.11;
}
if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||
!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
!(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||
!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
!(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
return AVERROR(ENOMEM);
}
if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
return AVERROR(ENOMEM);
}
avctx->extradata_size = 8 * 4;
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame) {
a64multi_close_encoder(avctx);
return AVERROR(ENOMEM);
}
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
avctx->codec_tag = AV_RL32("a64m");
c->next_pts = AV_NOPTS_VALUE;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"A64Context *c = avctx->priv_data;",
"int VAR_0;",
"av_lfg_init(&c->randctx, 1);",
"if (avctx->global_quality < 1) {",
"c->mc_lifetime = 4;",
"} else {",
"c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA;",
"}",
"av_log(avctx, AV_LOG_INFO, \"charset lifetime set to %d frame(s)\\n\", c->mc_lifetime);",
"c->mc_frame_counter = 0;",
"c->mc_use_5col = avctx->codec->id == AV_CODEC_ID_A64_MULTI5;",
"c->mc_pal_size = 4 + c->mc_use_5col;",
"for (VAR_0 = 0; VAR_0 < c->mc_pal_size; VAR_0++) {",
"c->mc_luma_vals[VAR_0]=a64_palette[mc_colors[VAR_0]][0] * 0.30 +\na64_palette[mc_colors[VAR_0]][1] * 0.59 +\na64_palette[mc_colors[VAR_0]][2] * 0.11;",
"}",
"if (!(c->mc_meta_charset = av_malloc_array(c->mc_lifetime, 32000 * sizeof(int))) ||\n!(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||\n!(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) ||\n!(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||\n!(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to allocate buffer memory.\\n\");",
"return AVERROR(ENOMEM);",
"}",
"if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {",
"av_log(avctx, AV_LOG_ERROR, \"Failed to allocate memory for extradata.\\n\");",
"return AVERROR(ENOMEM);",
"}",
"avctx->extradata_size = 8 * 4;",
"AV_WB32(avctx->extradata, c->mc_lifetime);",
"AV_WB32(avctx->extradata + 16, INTERLACED);",
"avctx->coded_frame = av_frame_alloc();",
"if (!avctx->coded_frame) {",
"a64multi_close_encoder(avctx);",
"return AVERROR(ENOMEM);",
"}",
"avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;",
"avctx->coded_frame->key_frame = 1;",
"if (!avctx->codec_tag)\navctx->codec_tag = AV_RL32(\"a64m\");",
"c->next_pts = AV_NOPTS_VALUE;",
"return 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41,
43,
45
],
[
47
],
[
51,
53,
55,
57,
59
],
[
61
],
[
63
],
[
65
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103,
105
],
[
109
],
[
113
],
[
115
]
]
|
14,600 | static int raw_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
AVFrame * frame = (AVFrame *) data;
AVPicture * picture = (AVPicture *) data;
frame->pict_type = avctx->coded_frame->pict_type;
frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
frame->top_field_first = avctx->coded_frame->top_field_first;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts;
frame->pkt_pos = avctx->pkt->pos;
if(context->tff>=0){
frame->interlaced_frame = 1;
frame->top_field_first = context->tff;
}
//2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
if (context->buffer) {
int i;
uint8_t *dst = context->buffer;
buf_size = context->length - 256*4;
if (avctx->bits_per_coded_sample == 4){
for(i=0; 2*i+1 < buf_size; i++){
dst[2*i+0]= buf[i]>>4;
dst[2*i+1]= buf[i]&15;
}
linesize_align = 8;
} else {
for(i=0; 4*i+3 < buf_size; i++){
dst[4*i+0]= buf[i]>>6;
dst[4*i+1]= buf[i]>>4&3;
dst[4*i+2]= buf[i]>>2&3;
dst[4*i+3]= buf[i] &3;
}
linesize_align = 16;
}
buf= dst;
}
if(avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->length;
if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
return -1;
avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
(av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
frame->data[1]= context->palette;
}
if (avctx->pix_fmt == PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
memcpy(frame->data[1], pal, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if((avctx->pix_fmt==PIX_FMT_BGR24 ||
avctx->pix_fmt==PIX_FMT_GRAY8 ||
avctx->pix_fmt==PIX_FMT_RGB555LE ||
avctx->pix_fmt==PIX_FMT_RGB555BE ||
avctx->pix_fmt==PIX_FMT_RGB565LE ||
avctx->pix_fmt==PIX_FMT_MONOWHITE ||
avctx->pix_fmt==PIX_FMT_PAL8) &&
FFALIGN(frame->linesize[0], linesize_align)*avctx->height <= buf_size)
frame->linesize[0] = FFALIGN(frame->linesize[0], linesize_align);
if(context->flip)
flip(avctx, picture);
if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2')
|| avctx->codec_tag == MKTAG('Y', 'V', '1', '6')
|| avctx->codec_tag == MKTAG('Y', 'V', '2', '4')
|| avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
if(avctx->codec_tag == AV_RL32("yuv2") &&
avctx->pix_fmt == PIX_FMT_YUYV422) {
int x, y;
uint8_t *line = picture->data[0];
for(y = 0; y < avctx->height; y++) {
for(x = 0; x < avctx->width; x++)
line[2*x + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*data_size = sizeof(AVPicture);
return buf_size;
}
| true | FFmpeg | 422e3a74b9d783571bec775af64f75e4915c40cc | static int raw_decode(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
AVFrame * frame = (AVFrame *) data;
AVPicture * picture = (AVPicture *) data;
frame->pict_type = avctx->coded_frame->pict_type;
frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
frame->top_field_first = avctx->coded_frame->top_field_first;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts;
frame->pkt_pos = avctx->pkt->pos;
if(context->tff>=0){
frame->interlaced_frame = 1;
frame->top_field_first = context->tff;
}
if (context->buffer) {
int i;
uint8_t *dst = context->buffer;
buf_size = context->length - 256*4;
if (avctx->bits_per_coded_sample == 4){
for(i=0; 2*i+1 < buf_size; i++){
dst[2*i+0]= buf[i]>>4;
dst[2*i+1]= buf[i]&15;
}
linesize_align = 8;
} else {
for(i=0; 4*i+3 < buf_size; i++){
dst[4*i+0]= buf[i]>>6;
dst[4*i+1]= buf[i]>>4&3;
dst[4*i+2]= buf[i]>>2&3;
dst[4*i+3]= buf[i] &3;
}
linesize_align = 16;
}
buf= dst;
}
if(avctx->codec_tag == MKTAG('A', 'V', '1', 'x') ||
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->length;
if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
return -1;
avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
(av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
frame->data[1]= context->palette;
}
if (avctx->pix_fmt == PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
memcpy(frame->data[1], pal, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if((avctx->pix_fmt==PIX_FMT_BGR24 ||
avctx->pix_fmt==PIX_FMT_GRAY8 ||
avctx->pix_fmt==PIX_FMT_RGB555LE ||
avctx->pix_fmt==PIX_FMT_RGB555BE ||
avctx->pix_fmt==PIX_FMT_RGB565LE ||
avctx->pix_fmt==PIX_FMT_MONOWHITE ||
avctx->pix_fmt==PIX_FMT_PAL8) &&
FFALIGN(frame->linesize[0], linesize_align)*avctx->height <= buf_size)
frame->linesize[0] = FFALIGN(frame->linesize[0], linesize_align);
if(context->flip)
flip(avctx, picture);
if ( avctx->codec_tag == MKTAG('Y', 'V', '1', '2')
|| avctx->codec_tag == MKTAG('Y', 'V', '1', '6')
|| avctx->codec_tag == MKTAG('Y', 'V', '2', '4')
|| avctx->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->data[1], picture->data[2]);
if(avctx->codec_tag == AV_RL32("yuv2") &&
avctx->pix_fmt == PIX_FMT_YUYV422) {
int x, y;
uint8_t *line = picture->data[0];
for(y = 0; y < avctx->height; y++) {
for(x = 0; x < avctx->width; x++)
line[2*x + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*data_size = sizeof(AVPicture);
return buf_size;
}
| {
"code": [
" for(i=0; 2*i+1 < buf_size; i++){",
" for(i=0; 4*i+3 < buf_size; i++){"
],
"line_no": [
61,
73
]
} | 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;
int VAR_6 = 4;
RawVideoContext *context = VAR_0->priv_data;
AVFrame * frame = (AVFrame *) VAR_1;
AVPicture * picture = (AVPicture *) VAR_1;
frame->pict_type = VAR_0->coded_frame->pict_type;
frame->interlaced_frame = VAR_0->coded_frame->interlaced_frame;
frame->top_field_first = VAR_0->coded_frame->top_field_first;
frame->reordered_opaque = VAR_0->reordered_opaque;
frame->pkt_pts = VAR_0->pkt->pts;
frame->pkt_pos = VAR_0->pkt->pos;
if(context->tff>=0){
frame->interlaced_frame = 1;
frame->top_field_first = context->tff;
}
if (context->buffer) {
int VAR_7;
uint8_t *dst = context->buffer;
VAR_5 = context->length - 256*4;
if (VAR_0->bits_per_coded_sample == 4){
for(VAR_7=0; 2*VAR_7+1 < VAR_5; VAR_7++){
dst[2*VAR_7+0]= VAR_4[VAR_7]>>4;
dst[2*VAR_7+1]= VAR_4[VAR_7]&15;
}
VAR_6 = 8;
} else {
for(VAR_7=0; 4*VAR_7+3 < VAR_5; VAR_7++){
dst[4*VAR_7+0]= VAR_4[VAR_7]>>6;
dst[4*VAR_7+1]= VAR_4[VAR_7]>>4&3;
dst[4*VAR_7+2]= VAR_4[VAR_7]>>2&3;
dst[4*VAR_7+3]= VAR_4[VAR_7] &3;
}
VAR_6 = 16;
}
VAR_4= dst;
}
if(VAR_0->codec_tag == MKTAG('A', 'V', '1', 'VAR_9') ||
VAR_0->codec_tag == MKTAG('A', 'V', 'u', 'p'))
VAR_4 += VAR_5 - context->length;
if(VAR_5 < context->length - (VAR_0->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
return -1;
avpicture_fill(picture, VAR_4, VAR_0->pix_fmt, VAR_0->width, VAR_0->height);
if((VAR_0->pix_fmt==PIX_FMT_PAL8 && VAR_5 < context->length) ||
(av_pix_fmt_descriptors[VAR_0->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {
frame->VAR_1[1]= context->palette;
}
if (VAR_0->pix_fmt == PIX_FMT_PAL8) {
const uint8_t *VAR_8 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);
if (VAR_8) {
memcpy(frame->VAR_1[1], VAR_8, AVPALETTE_SIZE);
frame->palette_has_changed = 1;
}
}
if((VAR_0->pix_fmt==PIX_FMT_BGR24 ||
VAR_0->pix_fmt==PIX_FMT_GRAY8 ||
VAR_0->pix_fmt==PIX_FMT_RGB555LE ||
VAR_0->pix_fmt==PIX_FMT_RGB555BE ||
VAR_0->pix_fmt==PIX_FMT_RGB565LE ||
VAR_0->pix_fmt==PIX_FMT_MONOWHITE ||
VAR_0->pix_fmt==PIX_FMT_PAL8) &&
FFALIGN(frame->linesize[0], VAR_6)*VAR_0->height <= VAR_5)
frame->linesize[0] = FFALIGN(frame->linesize[0], VAR_6);
if(context->flip)
flip(VAR_0, picture);
if ( VAR_0->codec_tag == MKTAG('Y', 'V', '1', '2')
|| VAR_0->codec_tag == MKTAG('Y', 'V', '1', '6')
|| VAR_0->codec_tag == MKTAG('Y', 'V', '2', '4')
|| VAR_0->codec_tag == MKTAG('Y', 'V', 'U', '9'))
FFSWAP(uint8_t *, picture->VAR_1[1], picture->VAR_1[2]);
if(VAR_0->codec_tag == AV_RL32("yuv2") &&
VAR_0->pix_fmt == PIX_FMT_YUYV422) {
int VAR_9, VAR_10;
uint8_t *line = picture->VAR_1[0];
for(VAR_10 = 0; VAR_10 < VAR_0->height; VAR_10++) {
for(VAR_9 = 0; VAR_9 < VAR_0->width; VAR_9++)
line[2*VAR_9 + 1] ^= 0x80;
line += picture->linesize[0];
}
}
*VAR_2 = sizeof(AVPicture);
return VAR_5;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int VAR_6 = 4;",
"RawVideoContext *context = VAR_0->priv_data;",
"AVFrame * frame = (AVFrame *) VAR_1;",
"AVPicture * picture = (AVPicture *) VAR_1;",
"frame->pict_type = VAR_0->coded_frame->pict_type;",
"frame->interlaced_frame = VAR_0->coded_frame->interlaced_frame;",
"frame->top_field_first = VAR_0->coded_frame->top_field_first;",
"frame->reordered_opaque = VAR_0->reordered_opaque;",
"frame->pkt_pts = VAR_0->pkt->pts;",
"frame->pkt_pos = VAR_0->pkt->pos;",
"if(context->tff>=0){",
"frame->interlaced_frame = 1;",
"frame->top_field_first = context->tff;",
"}",
"if (context->buffer) {",
"int VAR_7;",
"uint8_t *dst = context->buffer;",
"VAR_5 = context->length - 256*4;",
"if (VAR_0->bits_per_coded_sample == 4){",
"for(VAR_7=0; 2*VAR_7+1 < VAR_5; VAR_7++){",
"dst[2*VAR_7+0]= VAR_4[VAR_7]>>4;",
"dst[2*VAR_7+1]= VAR_4[VAR_7]&15;",
"}",
"VAR_6 = 8;",
"} else {",
"for(VAR_7=0; 4*VAR_7+3 < VAR_5; VAR_7++){",
"dst[4*VAR_7+0]= VAR_4[VAR_7]>>6;",
"dst[4*VAR_7+1]= VAR_4[VAR_7]>>4&3;",
"dst[4*VAR_7+2]= VAR_4[VAR_7]>>2&3;",
"dst[4*VAR_7+3]= VAR_4[VAR_7] &3;",
"}",
"VAR_6 = 16;",
"}",
"VAR_4= dst;",
"}",
"if(VAR_0->codec_tag == MKTAG('A', 'V', '1', 'VAR_9') ||\nVAR_0->codec_tag == MKTAG('A', 'V', 'u', 'p'))\nVAR_4 += VAR_5 - context->length;",
"if(VAR_5 < context->length - (VAR_0->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))\nreturn -1;",
"avpicture_fill(picture, VAR_4, VAR_0->pix_fmt, VAR_0->width, VAR_0->height);",
"if((VAR_0->pix_fmt==PIX_FMT_PAL8 && VAR_5 < context->length) ||\n(av_pix_fmt_descriptors[VAR_0->pix_fmt].flags & PIX_FMT_PSEUDOPAL)) {",
"frame->VAR_1[1]= context->palette;",
"}",
"if (VAR_0->pix_fmt == PIX_FMT_PAL8) {",
"const uint8_t *VAR_8 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, NULL);",
"if (VAR_8) {",
"memcpy(frame->VAR_1[1], VAR_8, AVPALETTE_SIZE);",
"frame->palette_has_changed = 1;",
"}",
"}",
"if((VAR_0->pix_fmt==PIX_FMT_BGR24 ||\nVAR_0->pix_fmt==PIX_FMT_GRAY8 ||\nVAR_0->pix_fmt==PIX_FMT_RGB555LE ||\nVAR_0->pix_fmt==PIX_FMT_RGB555BE ||\nVAR_0->pix_fmt==PIX_FMT_RGB565LE ||\nVAR_0->pix_fmt==PIX_FMT_MONOWHITE ||\nVAR_0->pix_fmt==PIX_FMT_PAL8) &&\nFFALIGN(frame->linesize[0], VAR_6)*VAR_0->height <= VAR_5)\nframe->linesize[0] = FFALIGN(frame->linesize[0], VAR_6);",
"if(context->flip)\nflip(VAR_0, picture);",
"if ( VAR_0->codec_tag == MKTAG('Y', 'V', '1', '2')\n|| VAR_0->codec_tag == MKTAG('Y', 'V', '1', '6')\n|| VAR_0->codec_tag == MKTAG('Y', 'V', '2', '4')\n|| VAR_0->codec_tag == MKTAG('Y', 'V', 'U', '9'))\nFFSWAP(uint8_t *, picture->VAR_1[1], picture->VAR_1[2]);",
"if(VAR_0->codec_tag == AV_RL32(\"yuv2\") &&\nVAR_0->pix_fmt == PIX_FMT_YUYV422) {",
"int VAR_9, VAR_10;",
"uint8_t *line = picture->VAR_1[0];",
"for(VAR_10 = 0; VAR_10 < VAR_0->height; VAR_10++) {",
"for(VAR_9 = 0; VAR_9 < VAR_0->width; VAR_9++)",
"line[2*VAR_9 + 1] ^= 0x80;",
"line += picture->linesize[0];",
"}",
"}",
"*VAR_2 = sizeof(AVPicture);",
"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,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95,
97,
99
],
[
103,
105
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139,
141,
143,
145,
147,
149,
151
],
[
155,
157
],
[
161,
163,
165,
167,
169
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
]
]
|
14,601 | static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
int is_chroma)
{
int blk;
int i, j, bx, by;
uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
int xoff, yoff;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = c->pic.linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(gb, c, i);
ref_start = c->last.data[plane_idx];
ref_end = c->last.data[plane_idx]
+ (bw - 1 + c->last.linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES]) < 0)
return -1;
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)
return -1;
if (read_colors(gb, &c->bundle[BINK_SRC_COLORS], c) < 0)
return -1;
if (read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF]) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)
return -1;
if (read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN]) < 0)
return -1;
if (by == bh)
break;
dst = c->pic.data[plane_idx] + 8*by*stride;
prev = c->last.data[plane_idx] + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
// 16x16 block type on odd line means part of the already decoded block, so skip it
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->dsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return -1;
}
if (blk != FILL_BLOCK)
c->bdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
break;
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
c->dsp.clear_block(block);
v = get_bits(gb, 7);
read_residue(gb, block, v);
c->dsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1);
c->bdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return -1;
}
}
}
if (get_bits_count(gb) & 0x1F) //next plane data starts at 32-bit boundary
skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
return 0;
}
| true | FFmpeg | 66aae97a60fcd8658f18c484b5af898a48d0e3f9 | static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx,
int is_chroma)
{
int blk;
int i, j, bx, by;
uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
int xoff, yoff;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = c->pic.linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(gb, c, i);
ref_start = c->last.data[plane_idx];
ref_end = c->last.data[plane_idx]
+ (bw - 1 + c->last.linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES]) < 0)
return -1;
if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)
return -1;
if (read_colors(gb, &c->bundle[BINK_SRC_COLORS], c) < 0)
return -1;
if (read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF]) < 0)
return -1;
if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF]) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)
return -1;
if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)
return -1;
if (read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN]) < 0)
return -1;
if (by == bh)
break;
dst = c->pic.data[plane_idx] + 8*by*stride;
prev = c->last.data[plane_idx] + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->dsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return -1;
}
if (blk != FILL_BLOCK)
c->bdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
break;
case RUN_BLOCK:
scan = bink_patterns[get_bits(gb, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(gb)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
if (ref < ref_start || ref > ref_end) {
av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
bx*8 + xoff, by*8 + yoff);
return -1;
}
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
c->dsp.clear_block(block);
v = get_bits(gb, 7);
read_residue(gb, block, v);
c->dsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1);
c->bdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->dsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
xoff = get_value(c, BINK_SRC_X_OFF);
yoff = get_value(c, BINK_SRC_Y_OFF);
ref = prev + xoff + yoff * stride;
c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8);
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1);
c->bdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return -1;
}
}
}
if (get_bits_count(gb) & 0x1F)
skip_bits_long(gb, 32 - (get_bits_count(gb) & 0x1F));
return 0;
}
| {
"code": [
" ref_start = c->last.data[plane_idx];",
" ref_end = c->last.data[plane_idx]",
" prev = c->last.data[plane_idx] + 8*by*stride;"
],
"line_no": [
47,
49,
107
]
} | static int FUNC_0(BinkContext *VAR_0, GetBitContext *VAR_1, int VAR_2,
int VAR_3)
{
int VAR_4;
int VAR_5, VAR_6, VAR_7, VAR_8;
uint8_t *dst, *prev, *ref, *ref_start, *ref_end;
int VAR_9, VAR_10[2];
const uint8_t *VAR_11;
int VAR_12, VAR_13;
LOCAL_ALIGNED_16(DCTELEM, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int VAR_14[64];
const int VAR_15 = VAR_0->pic.linesize[VAR_2];
int VAR_16 = VAR_3 ? (VAR_0->avctx->VAR_18 + 15) >> 4 : (VAR_0->avctx->VAR_18 + 7) >> 3;
int VAR_17 = VAR_3 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3;
int VAR_18 = VAR_0->avctx->VAR_18 >> VAR_3;
init_lengths(VAR_0, FFMAX(VAR_18, 8), VAR_16);
for (VAR_5 = 0; VAR_5 < BINK_NB_SRC; VAR_5++)
read_bundle(VAR_1, VAR_0, VAR_5);
ref_start = VAR_0->last.data[VAR_2];
ref_end = VAR_0->last.data[VAR_2]
+ (VAR_16 - 1 + VAR_0->last.linesize[VAR_2] * (VAR_17 - 1)) * 8;
for (VAR_5 = 0; VAR_5 < 64; VAR_5++)
VAR_14[VAR_5] = (VAR_5 & 7) + (VAR_5 >> 3) * VAR_15;
for (VAR_8 = 0; VAR_8 < VAR_17; VAR_8++) {
if (read_block_types(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_BLOCK_TYPES]) < 0)
return -1;
if (read_block_types(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)
return -1;
if (read_colors(VAR_1, &VAR_0->bundle[BINK_SRC_COLORS], VAR_0) < 0)
return -1;
if (read_patterns(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_PATTERN]) < 0)
return -1;
if (read_motion_values(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_X_OFF]) < 0)
return -1;
if (read_motion_values(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_Y_OFF]) < 0)
return -1;
if (read_dcs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)
return -1;
if (read_dcs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)
return -1;
if (read_runs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_RUN]) < 0)
return -1;
if (VAR_8 == VAR_17)
break;
dst = VAR_0->pic.data[VAR_2] + 8*VAR_8*VAR_15;
prev = VAR_0->last.data[VAR_2] + 8*VAR_8*VAR_15;
for (VAR_7 = 0; VAR_7 < VAR_16; VAR_7++, dst += 8, prev += 8) {
VAR_4 = get_value(VAR_0, BINK_SRC_BLOCK_TYPES);
if ((VAR_8 & 1) && VAR_4 == SCALED_BLOCK) {
VAR_7++;
dst += 8;
prev += 8;
continue;
}
switch (VAR_4) {
case SKIP_BLOCK:
VAR_0->dsp.put_pixels_tab[1][0](dst, prev, VAR_15, 8);
break;
case SCALED_BLOCK:
VAR_4 = get_value(VAR_0, BINK_SRC_SUB_BLOCK_TYPES);
switch (VAR_4) {
case RUN_BLOCK:
VAR_11 = bink_patterns[get_bits(VAR_1, 4)];
VAR_5 = 0;
do {
int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;
VAR_5 += VAR_20;
if (VAR_5 > 64) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(VAR_1)) {
VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)
ublock[*VAR_11++] = VAR_9;
} else {
for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)
ublock[*VAR_11++] = get_value(VAR_0, BINK_SRC_COLORS);
}
} while (VAR_5 < 63);
if (VAR_5 == 63)
ublock[*VAR_11++] = get_value(VAR_0, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);
read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_intra_quant, -1);
VAR_0->bdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);
VAR_0->dsp.fill_block_tab[0](dst, VAR_9, VAR_15, 16);
break;
case PATTERN_BLOCK:
for (VAR_5 = 0; VAR_5 < 2; VAR_5++)
VAR_10[VAR_5] = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_6 = 0; VAR_6 < 8; VAR_6++) {
VAR_9 = get_value(VAR_0, BINK_SRC_PATTERN);
for (VAR_5 = 0; VAR_5 < 8; VAR_5++, VAR_9 >>= 1)
ublock[VAR_5 + VAR_6*8] = VAR_10[VAR_9 & 1];
}
break;
case RAW_BLOCK:
for (VAR_6 = 0; VAR_6 < 8; VAR_6++)
for (VAR_5 = 0; VAR_5 < 8; VAR_5++)
ublock[VAR_5 + VAR_6*8] = get_value(VAR_0, BINK_SRC_COLORS);
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", VAR_4);
return -1;
}
if (VAR_4 != FILL_BLOCK)
VAR_0->bdsp.scale_block(ublock, dst, VAR_15);
VAR_7++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
VAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);
VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);
ref = prev + VAR_12 + VAR_13 * VAR_15;
if (ref < ref_start || ref > ref_end) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
VAR_7*8 + VAR_12, VAR_8*8 + VAR_13);
return -1;
}
VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);
break;
case RUN_BLOCK:
VAR_11 = bink_patterns[get_bits(VAR_1, 4)];
VAR_5 = 0;
do {
int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;
VAR_5 += VAR_20;
if (VAR_5 > 64) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return -1;
}
if (get_bits1(VAR_1)) {
VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)
dst[VAR_14[*VAR_11++]] = VAR_9;
} else {
for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)
dst[VAR_14[*VAR_11++]] = get_value(VAR_0, BINK_SRC_COLORS);
}
} while (VAR_5 < 63);
if (VAR_5 == 63)
dst[VAR_14[*VAR_11++]] = get_value(VAR_0, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
VAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);
VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);
ref = prev + VAR_12 + VAR_13 * VAR_15;
if (ref < ref_start || ref > ref_end) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n",
VAR_7*8 + VAR_12, VAR_8*8 + VAR_13);
return -1;
}
VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);
VAR_0->dsp.clear_block(block);
VAR_9 = get_bits(VAR_1, 7);
read_residue(VAR_1, block, VAR_9);
VAR_0->dsp.add_pixels8(dst, block, VAR_15);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);
read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_intra_quant, -1);
VAR_0->bdsp.idct_put(dst, VAR_15, dctblock);
break;
case FILL_BLOCK:
VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);
VAR_0->dsp.fill_block_tab[1](dst, VAR_9, VAR_15, 8);
break;
case INTER_BLOCK:
VAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);
VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);
ref = prev + VAR_12 + VAR_13 * VAR_15;
VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(VAR_0, BINK_SRC_INTER_DC);
read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_inter_quant, -1);
VAR_0->bdsp.idct_add(dst, VAR_15, dctblock);
break;
case PATTERN_BLOCK:
for (VAR_5 = 0; VAR_5 < 2; VAR_5++)
VAR_10[VAR_5] = get_value(VAR_0, BINK_SRC_COLORS);
for (VAR_5 = 0; VAR_5 < 8; VAR_5++) {
VAR_9 = get_value(VAR_0, BINK_SRC_PATTERN);
for (VAR_6 = 0; VAR_6 < 8; VAR_6++, VAR_9 >>= 1)
dst[VAR_5*VAR_15 + VAR_6] = VAR_10[VAR_9 & 1];
}
break;
case RAW_BLOCK:
for (VAR_5 = 0; VAR_5 < 8; VAR_5++)
memcpy(dst + VAR_5*VAR_15, VAR_0->bundle[BINK_SRC_COLORS].cur_ptr + VAR_5*8, 8);
VAR_0->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown block type %d\n", VAR_4);
return -1;
}
}
}
if (get_bits_count(VAR_1) & 0x1F)
skip_bits_long(VAR_1, 32 - (get_bits_count(VAR_1) & 0x1F));
return 0;
}
| [
"static int FUNC_0(BinkContext *VAR_0, GetBitContext *VAR_1, int VAR_2,\nint VAR_3)\n{",
"int VAR_4;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"uint8_t *dst, *prev, *ref, *ref_start, *ref_end;",
"int VAR_9, VAR_10[2];",
"const uint8_t *VAR_11;",
"int VAR_12, VAR_13;",
"LOCAL_ALIGNED_16(DCTELEM, block, [64]);",
"LOCAL_ALIGNED_16(uint8_t, ublock, [64]);",
"LOCAL_ALIGNED_16(int32_t, dctblock, [64]);",
"int VAR_14[64];",
"const int VAR_15 = VAR_0->pic.linesize[VAR_2];",
"int VAR_16 = VAR_3 ? (VAR_0->avctx->VAR_18 + 15) >> 4 : (VAR_0->avctx->VAR_18 + 7) >> 3;",
"int VAR_17 = VAR_3 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3;",
"int VAR_18 = VAR_0->avctx->VAR_18 >> VAR_3;",
"init_lengths(VAR_0, FFMAX(VAR_18, 8), VAR_16);",
"for (VAR_5 = 0; VAR_5 < BINK_NB_SRC; VAR_5++)",
"read_bundle(VAR_1, VAR_0, VAR_5);",
"ref_start = VAR_0->last.data[VAR_2];",
"ref_end = VAR_0->last.data[VAR_2]\n+ (VAR_16 - 1 + VAR_0->last.linesize[VAR_2] * (VAR_17 - 1)) * 8;",
"for (VAR_5 = 0; VAR_5 < 64; VAR_5++)",
"VAR_14[VAR_5] = (VAR_5 & 7) + (VAR_5 >> 3) * VAR_15;",
"for (VAR_8 = 0; VAR_8 < VAR_17; VAR_8++) {",
"if (read_block_types(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_BLOCK_TYPES]) < 0)\nreturn -1;",
"if (read_block_types(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0)\nreturn -1;",
"if (read_colors(VAR_1, &VAR_0->bundle[BINK_SRC_COLORS], VAR_0) < 0)\nreturn -1;",
"if (read_patterns(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_PATTERN]) < 0)\nreturn -1;",
"if (read_motion_values(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_X_OFF]) < 0)\nreturn -1;",
"if (read_motion_values(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_Y_OFF]) < 0)\nreturn -1;",
"if (read_dcs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0)\nreturn -1;",
"if (read_dcs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0)\nreturn -1;",
"if (read_runs(VAR_0->avctx, VAR_1, &VAR_0->bundle[BINK_SRC_RUN]) < 0)\nreturn -1;",
"if (VAR_8 == VAR_17)\nbreak;",
"dst = VAR_0->pic.data[VAR_2] + 8*VAR_8*VAR_15;",
"prev = VAR_0->last.data[VAR_2] + 8*VAR_8*VAR_15;",
"for (VAR_7 = 0; VAR_7 < VAR_16; VAR_7++, dst += 8, prev += 8) {",
"VAR_4 = get_value(VAR_0, BINK_SRC_BLOCK_TYPES);",
"if ((VAR_8 & 1) && VAR_4 == SCALED_BLOCK) {",
"VAR_7++;",
"dst += 8;",
"prev += 8;",
"continue;",
"}",
"switch (VAR_4) {",
"case SKIP_BLOCK:\nVAR_0->dsp.put_pixels_tab[1][0](dst, prev, VAR_15, 8);",
"break;",
"case SCALED_BLOCK:\nVAR_4 = get_value(VAR_0, BINK_SRC_SUB_BLOCK_TYPES);",
"switch (VAR_4) {",
"case RUN_BLOCK:\nVAR_11 = bink_patterns[get_bits(VAR_1, 4)];",
"VAR_5 = 0;",
"do {",
"int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;",
"VAR_5 += VAR_20;",
"if (VAR_5 > 64) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return -1;",
"}",
"if (get_bits1(VAR_1)) {",
"VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)",
"ublock[*VAR_11++] = VAR_9;",
"} else {",
"for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)",
"ublock[*VAR_11++] = get_value(VAR_0, BINK_SRC_COLORS);",
"}",
"} while (VAR_5 < 63);",
"if (VAR_5 == 63)\nublock[*VAR_11++] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"case INTRA_BLOCK:\nmemset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);",
"read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_intra_quant, -1);",
"VAR_0->bdsp.idct_put(ublock, 8, dctblock);",
"break;",
"case FILL_BLOCK:\nVAR_9 = get_value(VAR_0, BINK_SRC_COLORS);",
"VAR_0->dsp.fill_block_tab[0](dst, VAR_9, VAR_15, 16);",
"break;",
"case PATTERN_BLOCK:\nfor (VAR_5 = 0; VAR_5 < 2; VAR_5++)",
"VAR_10[VAR_5] = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_6 = 0; VAR_6 < 8; VAR_6++) {",
"VAR_9 = get_value(VAR_0, BINK_SRC_PATTERN);",
"for (VAR_5 = 0; VAR_5 < 8; VAR_5++, VAR_9 >>= 1)",
"ublock[VAR_5 + VAR_6*8] = VAR_10[VAR_9 & 1];",
"}",
"break;",
"case RAW_BLOCK:\nfor (VAR_6 = 0; VAR_6 < 8; VAR_6++)",
"for (VAR_5 = 0; VAR_5 < 8; VAR_5++)",
"ublock[VAR_5 + VAR_6*8] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect 16x16 block type %d\\n\", VAR_4);",
"return -1;",
"}",
"if (VAR_4 != FILL_BLOCK)\nVAR_0->bdsp.scale_block(ublock, dst, VAR_15);",
"VAR_7++;",
"dst += 8;",
"prev += 8;",
"break;",
"case MOTION_BLOCK:\nVAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);",
"VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);",
"ref = prev + VAR_12 + VAR_13 * VAR_15;",
"if (ref < ref_start || ref > ref_end) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Copy out of bounds @%d, %d\\n\",\nVAR_7*8 + VAR_12, VAR_8*8 + VAR_13);",
"return -1;",
"}",
"VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);",
"break;",
"case RUN_BLOCK:\nVAR_11 = bink_patterns[get_bits(VAR_1, 4)];",
"VAR_5 = 0;",
"do {",
"int VAR_20 = get_value(VAR_0, BINK_SRC_RUN) + 1;",
"VAR_5 += VAR_20;",
"if (VAR_5 > 64) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Run went out of bounds\\n\");",
"return -1;",
"}",
"if (get_bits1(VAR_1)) {",
"VAR_9 = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)",
"dst[VAR_14[*VAR_11++]] = VAR_9;",
"} else {",
"for (VAR_6 = 0; VAR_6 < VAR_20; VAR_6++)",
"dst[VAR_14[*VAR_11++]] = get_value(VAR_0, BINK_SRC_COLORS);",
"}",
"} while (VAR_5 < 63);",
"if (VAR_5 == 63)\ndst[VAR_14[*VAR_11++]] = get_value(VAR_0, BINK_SRC_COLORS);",
"break;",
"case RESIDUE_BLOCK:\nVAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);",
"VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);",
"ref = prev + VAR_12 + VAR_13 * VAR_15;",
"if (ref < ref_start || ref > ref_end) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Copy out of bounds @%d, %d\\n\",\nVAR_7*8 + VAR_12, VAR_8*8 + VAR_13);",
"return -1;",
"}",
"VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);",
"VAR_0->dsp.clear_block(block);",
"VAR_9 = get_bits(VAR_1, 7);",
"read_residue(VAR_1, block, VAR_9);",
"VAR_0->dsp.add_pixels8(dst, block, VAR_15);",
"break;",
"case INTRA_BLOCK:\nmemset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTRA_DC);",
"read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_intra_quant, -1);",
"VAR_0->bdsp.idct_put(dst, VAR_15, dctblock);",
"break;",
"case FILL_BLOCK:\nVAR_9 = get_value(VAR_0, BINK_SRC_COLORS);",
"VAR_0->dsp.fill_block_tab[1](dst, VAR_9, VAR_15, 8);",
"break;",
"case INTER_BLOCK:\nVAR_12 = get_value(VAR_0, BINK_SRC_X_OFF);",
"VAR_13 = get_value(VAR_0, BINK_SRC_Y_OFF);",
"ref = prev + VAR_12 + VAR_13 * VAR_15;",
"VAR_0->dsp.put_pixels_tab[1][0](dst, ref, VAR_15, 8);",
"memset(dctblock, 0, sizeof(*dctblock) * 64);",
"dctblock[0] = get_value(VAR_0, BINK_SRC_INTER_DC);",
"read_dct_coeffs(VAR_1, dctblock, bink_scan, bink_inter_quant, -1);",
"VAR_0->bdsp.idct_add(dst, VAR_15, dctblock);",
"break;",
"case PATTERN_BLOCK:\nfor (VAR_5 = 0; VAR_5 < 2; VAR_5++)",
"VAR_10[VAR_5] = get_value(VAR_0, BINK_SRC_COLORS);",
"for (VAR_5 = 0; VAR_5 < 8; VAR_5++) {",
"VAR_9 = get_value(VAR_0, BINK_SRC_PATTERN);",
"for (VAR_6 = 0; VAR_6 < 8; VAR_6++, VAR_9 >>= 1)",
"dst[VAR_5*VAR_15 + VAR_6] = VAR_10[VAR_9 & 1];",
"}",
"break;",
"case RAW_BLOCK:\nfor (VAR_5 = 0; VAR_5 < 8; VAR_5++)",
"memcpy(dst + VAR_5*VAR_15, VAR_0->bundle[BINK_SRC_COLORS].cur_ptr + VAR_5*8, 8);",
"VAR_0->bundle[BINK_SRC_COLORS].cur_ptr += 64;",
"break;",
"default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown block type %d\\n\", VAR_4);",
"return -1;",
"}",
"}",
"}",
"if (get_bits_count(VAR_1) & 0x1F)\nskip_bits_long(VAR_1, 32 - (get_bits_count(VAR_1) & 0x1F));",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71,
73
],
[
75,
77
],
[
79,
81
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95,
97
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135,
137
],
[
139
],
[
141,
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
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
],
[
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
],
[
439
],
[
441
]
]
|
14,602 | static void uart_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
CadenceUARTState *s = opaque;
DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value);
offset >>= 2;
switch (offset) {
case R_IER: /* ier (wts imr) */
s->r[R_IMR] |= value;
break;
case R_IDR: /* idr (wtc imr) */
s->r[R_IMR] &= ~value;
break;
case R_IMR: /* imr (read only) */
break;
case R_CISR: /* cisr (wtc) */
s->r[R_CISR] &= ~value;
break;
case R_TX_RX: /* UARTDR */
switch (s->r[R_MR] & UART_MR_CHMODE) {
case NORMAL_MODE:
uart_write_tx_fifo(s, (uint8_t *) &value, 1);
break;
case LOCAL_LOOPBACK:
uart_write_rx_fifo(opaque, (uint8_t *) &value, 1);
break;
break;
default:
s->r[offset] = value;
switch (offset) {
case R_CR:
uart_ctrl_update(s);
break;
case R_MR:
uart_parameters_setup(s);
break;
uart_update_status(s);
| true | qemu | 5eb0b194e9b01ba0f3613e6ddc2cb9f63ce96ae5 | static void uart_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
CadenceUARTState *s = opaque;
DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value);
offset >>= 2;
switch (offset) {
case R_IER:
s->r[R_IMR] |= value;
break;
case R_IDR:
s->r[R_IMR] &= ~value;
break;
case R_IMR:
break;
case R_CISR:
s->r[R_CISR] &= ~value;
break;
case R_TX_RX:
switch (s->r[R_MR] & UART_MR_CHMODE) {
case NORMAL_MODE:
uart_write_tx_fifo(s, (uint8_t *) &value, 1);
break;
case LOCAL_LOOPBACK:
uart_write_rx_fifo(opaque, (uint8_t *) &value, 1);
break;
break;
default:
s->r[offset] = value;
switch (offset) {
case R_CR:
uart_ctrl_update(s);
break;
case R_MR:
uart_parameters_setup(s);
break;
uart_update_status(s);
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
CadenceUARTState *s = VAR_0;
DB_PRINT(" VAR_1:%x data:%08x\n", (unsigned)VAR_1, (unsigned)VAR_2);
VAR_1 >>= 2;
switch (VAR_1) {
case R_IER:
s->r[R_IMR] |= VAR_2;
break;
case R_IDR:
s->r[R_IMR] &= ~VAR_2;
break;
case R_IMR:
break;
case R_CISR:
s->r[R_CISR] &= ~VAR_2;
break;
case R_TX_RX:
switch (s->r[R_MR] & UART_MR_CHMODE) {
case NORMAL_MODE:
uart_write_tx_fifo(s, (uint8_t *) &VAR_2, 1);
break;
case LOCAL_LOOPBACK:
uart_write_rx_fifo(VAR_0, (uint8_t *) &VAR_2, 1);
break;
break;
default:
s->r[VAR_1] = VAR_2;
switch (VAR_1) {
case R_CR:
uart_ctrl_update(s);
break;
case R_MR:
uart_parameters_setup(s);
break;
uart_update_status(s);
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"CadenceUARTState *s = VAR_0;",
"DB_PRINT(\" VAR_1:%x data:%08x\\n\", (unsigned)VAR_1, (unsigned)VAR_2);",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_IER:\ns->r[R_IMR] |= VAR_2;",
"break;",
"case R_IDR:\ns->r[R_IMR] &= ~VAR_2;",
"break;",
"case R_IMR:\nbreak;",
"case R_CISR:\ns->r[R_CISR] &= ~VAR_2;",
"break;",
"case R_TX_RX:\nswitch (s->r[R_MR] & UART_MR_CHMODE) {",
"case NORMAL_MODE:\nuart_write_tx_fifo(s, (uint8_t *) &VAR_2, 1);",
"break;",
"case LOCAL_LOOPBACK:\nuart_write_rx_fifo(VAR_0, (uint8_t *) &VAR_2, 1);",
"break;",
"break;",
"default:\ns->r[VAR_1] = VAR_2;",
"switch (VAR_1) {",
"case R_CR:\nuart_ctrl_update(s);",
"break;",
"case R_MR:\nuart_parameters_setup(s);",
"break;",
"uart_update_status(s);"
]
| [
0,
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
],
[
18
],
[
20,
22
],
[
24
],
[
26,
28
],
[
30
],
[
32,
34
],
[
36,
38
],
[
40
],
[
42,
44
],
[
46,
48
],
[
50
],
[
52,
54
],
[
56
],
[
59
],
[
61,
63
],
[
68
],
[
70,
72
],
[
74
],
[
76,
78
],
[
80
],
[
83
]
]
|
14,603 | static av_cold int flac_decode_init(AVCodecContext *avctx)
{
FLACContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->sample_fmt = SAMPLE_FMT_S16;
if (avctx->extradata_size > 4) {
/* initialize based on the demuxer-supplied streamdata header */
if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s,
avctx->extradata);
allocate_buffers(s);
} else {
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
metadata_parse(s);
}
}
return 0;
}
| false | FFmpeg | 59c6178a54c414fd19e064f0077d00b82a1eb812 | static av_cold int flac_decode_init(AVCodecContext *avctx)
{
FLACContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->sample_fmt = SAMPLE_FMT_S16;
if (avctx->extradata_size > 4) {
if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s,
avctx->extradata);
allocate_buffers(s);
} else {
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
metadata_parse(s);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
FLACContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->sample_fmt = SAMPLE_FMT_S16;
if (avctx->extradata_size > 4) {
if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s,
avctx->extradata);
allocate_buffers(s);
} else {
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
metadata_parse(s);
}
}
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"FLACContext *s = avctx->priv_data;",
"s->avctx = avctx;",
"avctx->sample_fmt = SAMPLE_FMT_S16;",
"if (avctx->extradata_size > 4) {",
"if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {",
"ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s,\navctx->extradata);",
"allocate_buffers(s);",
"} else {",
"init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);",
"metadata_parse(s);",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
]
]
|
14,604 | static void m68020_cpu_initfn(Object *obj)
{
M68kCPU *cpu = M68K_CPU(obj);
CPUM68KState *env = &cpu->env;
m68k_set_feature(env, M68K_FEATURE_M68000);
m68k_set_feature(env, M68K_FEATURE_USP);
m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
m68k_set_feature(env, M68K_FEATURE_BRAL);
m68k_set_feature(env, M68K_FEATURE_BCCL);
m68k_set_feature(env, M68K_FEATURE_BITFIELD);
m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
m68k_set_feature(env, M68K_FEATURE_FPU);
m68k_set_feature(env, M68K_FEATURE_CAS);
m68k_set_feature(env, M68K_FEATURE_BKPT);
m68k_set_feature(env, M68K_FEATURE_RTD);
} | true | qemu | 8bf6cbaf396a8b54b138bb8a7c3377f2868ed16e | static void m68020_cpu_initfn(Object *obj)
{
M68kCPU *cpu = M68K_CPU(obj);
CPUM68KState *env = &cpu->env;
m68k_set_feature(env, M68K_FEATURE_M68000);
m68k_set_feature(env, M68K_FEATURE_USP);
m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
m68k_set_feature(env, M68K_FEATURE_BRAL);
m68k_set_feature(env, M68K_FEATURE_BCCL);
m68k_set_feature(env, M68K_FEATURE_BITFIELD);
m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
m68k_set_feature(env, M68K_FEATURE_FPU);
m68k_set_feature(env, M68K_FEATURE_CAS);
m68k_set_feature(env, M68K_FEATURE_BKPT);
m68k_set_feature(env, M68K_FEATURE_RTD);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
M68kCPU *cpu = M68K_CPU(VAR_0);
CPUM68KState *env = &cpu->env;
m68k_set_feature(env, M68K_FEATURE_M68000);
m68k_set_feature(env, M68K_FEATURE_USP);
m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
m68k_set_feature(env, M68K_FEATURE_BRAL);
m68k_set_feature(env, M68K_FEATURE_BCCL);
m68k_set_feature(env, M68K_FEATURE_BITFIELD);
m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
m68k_set_feature(env, M68K_FEATURE_FPU);
m68k_set_feature(env, M68K_FEATURE_CAS);
m68k_set_feature(env, M68K_FEATURE_BKPT);
m68k_set_feature(env, M68K_FEATURE_RTD);
} | [
"static void FUNC_0(Object *VAR_0)\n{",
"M68kCPU *cpu = M68K_CPU(VAR_0);",
"CPUM68KState *env = &cpu->env;",
"m68k_set_feature(env, M68K_FEATURE_M68000);",
"m68k_set_feature(env, M68K_FEATURE_USP);",
"m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);",
"m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);",
"m68k_set_feature(env, M68K_FEATURE_BRAL);",
"m68k_set_feature(env, M68K_FEATURE_BCCL);",
"m68k_set_feature(env, M68K_FEATURE_BITFIELD);",
"m68k_set_feature(env, M68K_FEATURE_EXT_FULL);",
"m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);",
"m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);",
"m68k_set_feature(env, M68K_FEATURE_FPU);",
"m68k_set_feature(env, M68K_FEATURE_CAS);",
"m68k_set_feature(env, M68K_FEATURE_BKPT);",
"m68k_set_feature(env, M68K_FEATURE_RTD);",
"}"
]
| [
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
],
[
40
]
]
|
14,605 | static int add_shorts_metadata(int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int16_t *sp;
if (count >= INT_MAX / sizeof(int16_t) || count <= 0)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))
return AVERROR_INVALIDDATA;
sp = av_malloc(count * sizeof(int16_t));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(&s->gb, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| true | FFmpeg | edcc51fb8e15b704955d742559215697598927bb | static int add_shorts_metadata(int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int16_t *sp;
if (count >= INT_MAX / sizeof(int16_t) || count <= 0)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))
return AVERROR_INVALIDDATA;
sp = av_malloc(count * sizeof(int16_t));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(&s->gb, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| {
"code": [
" av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);",
" const char *sep, TiffContext *s)",
" av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);"
],
"line_no": [
45,
3,
45
]
} | static int FUNC_0(int VAR_0, const char *VAR_1,
const char *VAR_2, TiffContext *VAR_3)
{
char *VAR_4;
int VAR_5;
int16_t *sp;
if (VAR_0 >= INT_MAX / sizeof(int16_t) || VAR_0 <= 0)
return AVERROR_INVALIDDATA;
if (bytestream2_get_bytes_left(&VAR_3->gb) < VAR_0 * sizeof(int16_t))
return AVERROR_INVALIDDATA;
sp = av_malloc(VAR_0 * sizeof(int16_t));
if (!sp)
return AVERROR(ENOMEM);
for (VAR_5 = 0; VAR_5 < VAR_0; VAR_5++)
sp[VAR_5] = tget_short(&VAR_3->gb, VAR_3->le);
VAR_4 = shorts2str(sp, VAR_0, VAR_2);
av_freep(&sp);
if (!VAR_4)
return AVERROR(ENOMEM);
av_dict_set(avpriv_frame_get_metadatap(&VAR_3->picture), VAR_1, VAR_4, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| [
"static int FUNC_0(int VAR_0, const char *VAR_1,\nconst char *VAR_2, TiffContext *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5;",
"int16_t *sp;",
"if (VAR_0 >= INT_MAX / sizeof(int16_t) || VAR_0 <= 0)\nreturn AVERROR_INVALIDDATA;",
"if (bytestream2_get_bytes_left(&VAR_3->gb) < VAR_0 * sizeof(int16_t))\nreturn AVERROR_INVALIDDATA;",
"sp = av_malloc(VAR_0 * sizeof(int16_t));",
"if (!sp)\nreturn AVERROR(ENOMEM);",
"for (VAR_5 = 0; VAR_5 < VAR_0; VAR_5++)",
"sp[VAR_5] = tget_short(&VAR_3->gb, VAR_3->le);",
"VAR_4 = shorts2str(sp, VAR_0, VAR_2);",
"av_freep(&sp);",
"if (!VAR_4)\nreturn AVERROR(ENOMEM);",
"av_dict_set(avpriv_frame_get_metadatap(&VAR_3->picture), VAR_1, VAR_4, AV_DICT_DONT_STRDUP_VAL);",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
19,
21
],
[
25
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
]
]
|
14,606 | static inline void RENAME(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int dstbpp, int16_t * lumMmxFilter, int16_t * chrMmxFilter)
{
if(fullUVIpol)
{
//FIXME
}//FULL_UV_IPOL
else
{
#ifdef HAVE_MMX
if(dstbpp == 32) //FIXME untested
{
asm volatile(
YSCALEYUV2RGBX
WRITEBGR32
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==24) //FIXME untested
{
asm volatile(
YSCALEYUV2RGBX
"leal (%%eax, %%eax, 2), %%ebx \n\t" //FIXME optimize
"addl %4, %%ebx \n\t"
WRITEBGR24
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==15)
{
asm volatile(
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g5Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR15
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==16)
{
asm volatile(
YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g6Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR16
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
#else
if(dstbpp==32)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[8*i+0]=clip_table[((Y1 + Cb) >>13)];
dest[8*i+1]=clip_table[((Y1 + Cg) >>13)];
dest[8*i+2]=clip_table[((Y1 + Cr) >>13)];
dest[8*i+4]=clip_table[((Y2 + Cb) >>13)];
dest[8*i+5]=clip_table[((Y2 + Cg) >>13)];
dest[8*i+6]=clip_table[((Y2 + Cr) >>13)];
}
}
else if(dstbpp==24)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[0]=clip_table[((Y1 + Cb) >>13)];
dest[1]=clip_table[((Y1 + Cg) >>13)];
dest[2]=clip_table[((Y1 + Cr) >>13)];
dest[3]=clip_table[((Y2 + Cb) >>13)];
dest[4]=clip_table[((Y2 + Cg) >>13)];
dest[5]=clip_table[((Y2 + Cr) >>13)];
dest+=6;
}
}
else if(dstbpp==16)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table16b[(Y1 + Cb) >>13] |
clip_table16g[(Y1 + Cg) >>13] |
clip_table16r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table16b[(Y2 + Cb) >>13] |
clip_table16g[(Y2 + Cg) >>13] |
clip_table16r[(Y2 + Cr) >>13];
}
}
else if(dstbpp==15)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table15b[(Y1 + Cb) >>13] |
clip_table15g[(Y1 + Cg) >>13] |
clip_table15r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table15b[(Y2 + Cb) >>13] |
clip_table15g[(Y2 + Cg) >>13] |
clip_table15r[(Y2 + Cr) >>13];
}
}
#endif
} //!FULL_UV_IPOL
}
| true | FFmpeg | e3d2500fe498289a878b956f6efb4995438c9515 | static inline void RENAME(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int dstbpp, int16_t * lumMmxFilter, int16_t * chrMmxFilter)
{
if(fullUVIpol)
{
}
else
{
#ifdef HAVE_MMX
if(dstbpp == 32) untested
{
asm volatile(
YSCALEYUV2RGBX
WRITEBGR32
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==24) untested
{
asm volatile(
YSCALEYUV2RGBX
"leal (%%eax, %%eax, 2), %%ebx \n\t" optimize
"addl %4, %%ebx \n\t"
WRITEBGR24
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==15)
{
asm volatile(
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g5Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR15
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==16)
{
asm volatile(
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g6Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR16
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
#else
if(dstbpp==32)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[8*i+0]=clip_table[((Y1 + Cb) >>13)];
dest[8*i+1]=clip_table[((Y1 + Cg) >>13)];
dest[8*i+2]=clip_table[((Y1 + Cr) >>13)];
dest[8*i+4]=clip_table[((Y2 + Cb) >>13)];
dest[8*i+5]=clip_table[((Y2 + Cg) >>13)];
dest[8*i+6]=clip_table[((Y2 + Cr) >>13)];
}
}
else if(dstbpp==24)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[0]=clip_table[((Y1 + Cb) >>13)];
dest[1]=clip_table[((Y1 + Cg) >>13)];
dest[2]=clip_table[((Y1 + Cr) >>13)];
dest[3]=clip_table[((Y2 + Cb) >>13)];
dest[4]=clip_table[((Y2 + Cg) >>13)];
dest[5]=clip_table[((Y2 + Cr) >>13)];
dest+=6;
}
}
else if(dstbpp==16)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table16b[(Y1 + Cb) >>13] |
clip_table16g[(Y1 + Cg) >>13] |
clip_table16r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table16b[(Y2 + Cb) >>13] |
clip_table16g[(Y2 + Cg) >>13] |
clip_table16r[(Y2 + Cr) >>13];
}
}
else if(dstbpp==15)
{
int i;
for(i=0; i<(dstW>>1); i++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*i] * lumFilter[j];
Y2 += lumSrc[j][2*i+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][i] * chrFilter[j];
V += chrSrc[j][i+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*i] =
clip_table15b[(Y1 + Cb) >>13] |
clip_table15g[(Y1 + Cg) >>13] |
clip_table15r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*i+1] =
clip_table15b[(Y2 + Cb) >>13] |
clip_table15g[(Y2 + Cg) >>13] |
clip_table15r[(Y2 + Cr) >>13];
}
}
#endif
}
}
| {
"code": [
"\t\tif(dstbpp==32)",
"\t\t\tint i;",
"\t\t\tfor(i=0; i<(dstW>>1); i++){",
"\t\t\t\tint j;",
"\t\t\t\tint Y1=0;",
"\t\t\t\tint Y2=0;",
"\t\t\t\tint U=0;",
"\t\t\t\tint V=0;",
"\t\t\t\tint Cb, Cr, Cg;",
"\t\t\t\tfor(j=0; j<lumFilterSize; j++)",
"\t\t\t\t\tY1 += lumSrc[j][2*i] * lumFilter[j];",
"\t\t\t\t\tY2 += lumSrc[j][2*i+1] * lumFilter[j];",
"\t\t\t\tfor(j=0; j<chrFilterSize; j++)",
"\t\t\t\t\tU += chrSrc[j][i] * chrFilter[j];",
"\t\t\t\t\tV += chrSrc[j][i+2048] * chrFilter[j];",
"\t\t\t\tY1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"\t\t\t\tY2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"\t\t\t\tU >>= 19;",
"\t\t\t\tV >>= 19;",
"\t\t\t\tCb= clip_yuvtab_40cf[U+ 256];",
"\t\t\t\tCg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"\t\t\t\tCr= clip_yuvtab_3343[V+ 256];",
"\t\t\t\tdest[8*i+0]=clip_table[((Y1 + Cb) >>13)];",
"\t\t\t\tdest[8*i+1]=clip_table[((Y1 + Cg) >>13)];",
"\t\t\t\tdest[8*i+2]=clip_table[((Y1 + Cr) >>13)];",
"\t\t\t\tdest[8*i+4]=clip_table[((Y2 + Cb) >>13)];",
"\t\t\t\tdest[8*i+5]=clip_table[((Y2 + Cg) >>13)];",
"\t\t\t\tdest[8*i+6]=clip_table[((Y2 + Cr) >>13)];",
"\t\telse if(dstbpp==24)",
"\t\t\tint i;",
"\t\t\tfor(i=0; i<(dstW>>1); i++){",
"\t\t\t\tint j;",
"\t\t\t\tint Y1=0;",
"\t\t\t\tint Y2=0;",
"\t\t\t\tint U=0;",
"\t\t\t\tint V=0;",
"\t\t\t\tint Cb, Cr, Cg;",
"\t\t\t\tfor(j=0; j<lumFilterSize; j++)",
"\t\t\t\t\tY1 += lumSrc[j][2*i] * lumFilter[j];",
"\t\t\t\t\tY2 += lumSrc[j][2*i+1] * lumFilter[j];",
"\t\t\t\tfor(j=0; j<chrFilterSize; j++)",
"\t\t\t\t\tU += chrSrc[j][i] * chrFilter[j];",
"\t\t\t\t\tV += chrSrc[j][i+2048] * chrFilter[j];",
"\t\t\t\tY1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"\t\t\t\tY2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"\t\t\t\tU >>= 19;",
"\t\t\t\tV >>= 19;",
"\t\t\t\tCb= clip_yuvtab_40cf[U+ 256];",
"\t\t\t\tCg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"\t\t\t\tCr= clip_yuvtab_3343[V+ 256];",
"\t\t\t\tdest[0]=clip_table[((Y1 + Cb) >>13)];",
"\t\t\t\tdest[1]=clip_table[((Y1 + Cg) >>13)];",
"\t\t\t\tdest[2]=clip_table[((Y1 + Cr) >>13)];",
"\t\t\t\tdest[3]=clip_table[((Y2 + Cb) >>13)];",
"\t\t\t\tdest[4]=clip_table[((Y2 + Cg) >>13)];",
"\t\t\t\tdest[5]=clip_table[((Y2 + Cr) >>13)];",
"\t\t\t\tdest+=6;",
"\t\telse if(dstbpp==16)",
"\t\t\tint i;",
"\t\t\tfor(i=0; i<(dstW>>1); i++){",
"\t\t\t\tint j;",
"\t\t\t\tint Y1=0;",
"\t\t\t\tint Y2=0;",
"\t\t\t\tint U=0;",
"\t\t\t\tint V=0;",
"\t\t\t\tint Cb, Cr, Cg;",
"\t\t\t\tfor(j=0; j<lumFilterSize; j++)",
"\t\t\t\t\tY1 += lumSrc[j][2*i] * lumFilter[j];",
"\t\t\t\t\tY2 += lumSrc[j][2*i+1] * lumFilter[j];",
"\t\t\t\tfor(j=0; j<chrFilterSize; j++)",
"\t\t\t\t\tU += chrSrc[j][i] * chrFilter[j];",
"\t\t\t\t\tV += chrSrc[j][i+2048] * chrFilter[j];",
"\t\t\t\tY1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"\t\t\t\tY2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"\t\t\t\tU >>= 19;",
"\t\t\t\tV >>= 19;",
"\t\t\t\tCb= clip_yuvtab_40cf[U+ 256];",
"\t\t\t\tCg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"\t\t\t\tCr= clip_yuvtab_3343[V+ 256];",
"\t\t\t\t((uint16_t*)dest)[2*i] =",
"\t\t\t\t\tclip_table16b[(Y1 + Cb) >>13] |",
"\t\t\t\t\tclip_table16g[(Y1 + Cg) >>13] |",
"\t\t\t\t\tclip_table16r[(Y1 + Cr) >>13];",
"\t\t\t\t((uint16_t*)dest)[2*i+1] =",
"\t\t\t\t\tclip_table16b[(Y2 + Cb) >>13] |",
"\t\t\t\t\tclip_table16g[(Y2 + Cg) >>13] |",
"\t\t\t\t\tclip_table16r[(Y2 + Cr) >>13];",
"\t\telse if(dstbpp==15)",
"\t\t\tint i;",
"\t\t\tfor(i=0; i<(dstW>>1); i++){",
"\t\t\t\tint j;",
"\t\t\t\tint Y1=0;",
"\t\t\t\tint Y2=0;",
"\t\t\t\tint U=0;",
"\t\t\t\tint V=0;",
"\t\t\t\tint Cb, Cr, Cg;",
"\t\t\t\tfor(j=0; j<lumFilterSize; j++)",
"\t\t\t\t\tY1 += lumSrc[j][2*i] * lumFilter[j];",
"\t\t\t\t\tY2 += lumSrc[j][2*i+1] * lumFilter[j];",
"\t\t\t\tfor(j=0; j<chrFilterSize; j++)",
"\t\t\t\t\tU += chrSrc[j][i] * chrFilter[j];",
"\t\t\t\t\tV += chrSrc[j][i+2048] * chrFilter[j];",
"\t\t\t\tY1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"\t\t\t\tY2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"\t\t\t\tU >>= 19;",
"\t\t\t\tV >>= 19;",
"\t\t\t\tCb= clip_yuvtab_40cf[U+ 256];",
"\t\t\t\tCg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"\t\t\t\tCr= clip_yuvtab_3343[V+ 256];",
"\t\t\t\t((uint16_t*)dest)[2*i] =",
"\t\t\t\t\tclip_table15b[(Y1 + Cb) >>13] |",
"\t\t\t\t\tclip_table15g[(Y1 + Cg) >>13] |",
"\t\t\t\t\tclip_table15r[(Y1 + Cr) >>13];",
"\t\t\t\t((uint16_t*)dest)[2*i+1] =",
"\t\t\t\t\tclip_table15b[(Y2 + Cb) >>13] |",
"\t\t\t\t\tclip_table15g[(Y2 + Cg) >>13] |",
"\t\t\t\t\tclip_table15r[(Y2 + Cr) >>13];"
],
"line_no": [
161,
165,
167,
169,
171,
173,
175,
177,
179,
181,
185,
187,
191,
195,
197,
201,
203,
205,
207,
211,
213,
215,
219,
221,
223,
227,
229,
231,
237,
165,
167,
169,
171,
173,
175,
177,
179,
181,
185,
187,
191,
195,
197,
201,
203,
205,
207,
211,
213,
215,
295,
297,
299,
303,
305,
307,
309,
119,
165,
167,
169,
171,
173,
175,
177,
179,
181,
185,
187,
191,
195,
197,
201,
203,
205,
207,
211,
213,
215,
373,
375,
377,
379,
383,
385,
387,
389,
79,
165,
167,
169,
171,
173,
175,
177,
179,
181,
185,
187,
191,
195,
197,
201,
203,
205,
207,
211,
213,
215,
373,
455,
457,
459,
383,
465,
467,
469
]
} | static inline void FUNC_0(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, int dstW, int dstbpp, int16_t * lumMmxFilter, int16_t * chrMmxFilter)
{
if(fullUVIpol)
{
}
else
{
#ifdef HAVE_MMX
if(dstbpp == 32) untested
{
asm volatile(
YSCALEYUV2RGBX
WRITEBGR32
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==24) untested
{
asm volatile(
YSCALEYUV2RGBX
"leal (%%eax, %%eax, 2), %%ebx \n\t" optimize
"addl %4, %%ebx \n\t"
WRITEBGR24
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==15)
{
asm volatile(
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g5Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR15
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
else if(dstbpp==16)
{
asm volatile(
YSCALEYUV2RGBX
#ifdef DITHER1XBPP
"paddusb b5Dither, %%mm2 \n\t"
"paddusb g6Dither, %%mm4 \n\t"
"paddusb r5Dither, %%mm5 \n\t"
#endif
WRITEBGR16
:: "m" (-lumFilterSize), "m" (-chrFilterSize),
"m" (lumMmxFilter+lumFilterSize*4), "m" (chrMmxFilter+chrFilterSize*4),
"r" (dest), "m" (dstW),
"m" (lumSrc+lumFilterSize), "m" (chrSrc+chrFilterSize)
: "%eax", "%ebx", "%ecx", "%edx", "%esi"
);
}
#else
if(dstbpp==32)
{
int VAR_1;
for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];
Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][VAR_1] * chrFilter[j];
V += chrSrc[j][VAR_1+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[8*VAR_1+0]=clip_table[((Y1 + Cb) >>13)];
dest[8*VAR_1+1]=clip_table[((Y1 + Cg) >>13)];
dest[8*VAR_1+2]=clip_table[((Y1 + Cr) >>13)];
dest[8*VAR_1+4]=clip_table[((Y2 + Cb) >>13)];
dest[8*VAR_1+5]=clip_table[((Y2 + Cg) >>13)];
dest[8*VAR_1+6]=clip_table[((Y2 + Cr) >>13)];
}
}
else if(dstbpp==24)
{
int VAR_1;
for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];
Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][VAR_1] * chrFilter[j];
V += chrSrc[j][VAR_1+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
dest[0]=clip_table[((Y1 + Cb) >>13)];
dest[1]=clip_table[((Y1 + Cg) >>13)];
dest[2]=clip_table[((Y1 + Cr) >>13)];
dest[3]=clip_table[((Y2 + Cb) >>13)];
dest[4]=clip_table[((Y2 + Cg) >>13)];
dest[5]=clip_table[((Y2 + Cr) >>13)];
dest+=6;
}
}
else if(dstbpp==16)
{
int VAR_1;
for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];
Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][VAR_1] * chrFilter[j];
V += chrSrc[j][VAR_1+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*VAR_1] =
clip_table16b[(Y1 + Cb) >>13] |
clip_table16g[(Y1 + Cg) >>13] |
clip_table16r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*VAR_1+1] =
clip_table16b[(Y2 + Cb) >>13] |
clip_table16g[(Y2 + Cg) >>13] |
clip_table16r[(Y2 + Cr) >>13];
}
}
else if(dstbpp==15)
{
int VAR_1;
for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){
int j;
int Y1=0;
int Y2=0;
int U=0;
int V=0;
int Cb, Cr, Cg;
for(j=0; j<lumFilterSize; j++)
{
Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];
Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];
}
for(j=0; j<chrFilterSize; j++)
{
U += chrSrc[j][VAR_1] * chrFilter[j];
V += chrSrc[j][VAR_1+2048] * chrFilter[j];
}
Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];
Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];
U >>= 19;
V >>= 19;
Cb= clip_yuvtab_40cf[U+ 256];
Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];
Cr= clip_yuvtab_3343[V+ 256];
((uint16_t*)dest)[2*VAR_1] =
clip_table15b[(Y1 + Cb) >>13] |
clip_table15g[(Y1 + Cg) >>13] |
clip_table15r[(Y1 + Cr) >>13];
((uint16_t*)dest)[2*VAR_1+1] =
clip_table15b[(Y2 + Cb) >>13] |
clip_table15g[(Y2 + Cg) >>13] |
clip_table15r[(Y2 + Cr) >>13];
}
}
#endif
}
}
| [
"static inline void FUNC_0(yuv2rgbX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,\nint16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,\nuint8_t *dest, int dstW, int dstbpp, int16_t * lumMmxFilter, int16_t * chrMmxFilter)\n{",
"if(fullUVIpol)\n{",
"}",
"else\n{",
"#ifdef HAVE_MMX\nif(dstbpp == 32) untested\n{",
"asm volatile(\nYSCALEYUV2RGBX\nWRITEBGR32\n:: \"m\" (-lumFilterSize), \"m\" (-chrFilterSize),\n\"m\" (lumMmxFilter+lumFilterSize*4), \"m\" (chrMmxFilter+chrFilterSize*4),\n\"r\" (dest), \"m\" (dstW),\n\"m\" (lumSrc+lumFilterSize), \"m\" (chrSrc+chrFilterSize)\n: \"%eax\", \"%ebx\", \"%ecx\", \"%edx\", \"%esi\"\n);",
"}",
"else if(dstbpp==24) untested\n{",
"asm volatile(\nYSCALEYUV2RGBX\n\"leal (%%eax, %%eax, 2), %%ebx\t\\n\\t\" optimize\n\"addl %4, %%ebx\t\t\t\\n\\t\"\nWRITEBGR24\n:: \"m\" (-lumFilterSize), \"m\" (-chrFilterSize),\n\"m\" (lumMmxFilter+lumFilterSize*4), \"m\" (chrMmxFilter+chrFilterSize*4),\n\"r\" (dest), \"m\" (dstW),\n\"m\" (lumSrc+lumFilterSize), \"m\" (chrSrc+chrFilterSize)\n: \"%eax\", \"%ebx\", \"%ecx\", \"%edx\", \"%esi\"\n);",
"}",
"else if(dstbpp==15)\n{",
"asm volatile(\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb b5Dither, %%mm2\t\\n\\t\"\n\"paddusb g5Dither, %%mm4\t\\n\\t\"\n\"paddusb r5Dither, %%mm5\t\\n\\t\"\n#endif\nWRITEBGR15\n:: \"m\" (-lumFilterSize), \"m\" (-chrFilterSize),\n\"m\" (lumMmxFilter+lumFilterSize*4), \"m\" (chrMmxFilter+chrFilterSize*4),\n\"r\" (dest), \"m\" (dstW),\n\"m\" (lumSrc+lumFilterSize), \"m\" (chrSrc+chrFilterSize)\n: \"%eax\", \"%ebx\", \"%ecx\", \"%edx\", \"%esi\"\n);",
"}",
"else if(dstbpp==16)\n{",
"asm volatile(\nYSCALEYUV2RGBX\n#ifdef DITHER1XBPP\n\"paddusb b5Dither, %%mm2\t\\n\\t\"\n\"paddusb g6Dither, %%mm4\t\\n\\t\"\n\"paddusb r5Dither, %%mm5\t\\n\\t\"\n#endif\nWRITEBGR16\n:: \"m\" (-lumFilterSize), \"m\" (-chrFilterSize),\n\"m\" (lumMmxFilter+lumFilterSize*4), \"m\" (chrMmxFilter+chrFilterSize*4),\n\"r\" (dest), \"m\" (dstW),\n\"m\" (lumSrc+lumFilterSize), \"m\" (chrSrc+chrFilterSize)\n: \"%eax\", \"%ebx\", \"%ecx\", \"%edx\", \"%esi\"\n);",
"}",
"#else\nif(dstbpp==32)\n{",
"int VAR_1;",
"for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){",
"int j;",
"int Y1=0;",
"int Y2=0;",
"int U=0;",
"int V=0;",
"int Cb, Cr, Cg;",
"for(j=0; j<lumFilterSize; j++)",
"{",
"Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];",
"Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];",
"}",
"for(j=0; j<chrFilterSize; j++)",
"{",
"U += chrSrc[j][VAR_1] * chrFilter[j];",
"V += chrSrc[j][VAR_1+2048] * chrFilter[j];",
"}",
"Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"U >>= 19;",
"V >>= 19;",
"Cb= clip_yuvtab_40cf[U+ 256];",
"Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"Cr= clip_yuvtab_3343[V+ 256];",
"dest[8*VAR_1+0]=clip_table[((Y1 + Cb) >>13)];",
"dest[8*VAR_1+1]=clip_table[((Y1 + Cg) >>13)];",
"dest[8*VAR_1+2]=clip_table[((Y1 + Cr) >>13)];",
"dest[8*VAR_1+4]=clip_table[((Y2 + Cb) >>13)];",
"dest[8*VAR_1+5]=clip_table[((Y2 + Cg) >>13)];",
"dest[8*VAR_1+6]=clip_table[((Y2 + Cr) >>13)];",
"}",
"}",
"else if(dstbpp==24)\n{",
"int VAR_1;",
"for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){",
"int j;",
"int Y1=0;",
"int Y2=0;",
"int U=0;",
"int V=0;",
"int Cb, Cr, Cg;",
"for(j=0; j<lumFilterSize; j++)",
"{",
"Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];",
"Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];",
"}",
"for(j=0; j<chrFilterSize; j++)",
"{",
"U += chrSrc[j][VAR_1] * chrFilter[j];",
"V += chrSrc[j][VAR_1+2048] * chrFilter[j];",
"}",
"Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"U >>= 19;",
"V >>= 19;",
"Cb= clip_yuvtab_40cf[U+ 256];",
"Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"Cr= clip_yuvtab_3343[V+ 256];",
"dest[0]=clip_table[((Y1 + Cb) >>13)];",
"dest[1]=clip_table[((Y1 + Cg) >>13)];",
"dest[2]=clip_table[((Y1 + Cr) >>13)];",
"dest[3]=clip_table[((Y2 + Cb) >>13)];",
"dest[4]=clip_table[((Y2 + Cg) >>13)];",
"dest[5]=clip_table[((Y2 + Cr) >>13)];",
"dest+=6;",
"}",
"}",
"else if(dstbpp==16)\n{",
"int VAR_1;",
"for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){",
"int j;",
"int Y1=0;",
"int Y2=0;",
"int U=0;",
"int V=0;",
"int Cb, Cr, Cg;",
"for(j=0; j<lumFilterSize; j++)",
"{",
"Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];",
"Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];",
"}",
"for(j=0; j<chrFilterSize; j++)",
"{",
"U += chrSrc[j][VAR_1] * chrFilter[j];",
"V += chrSrc[j][VAR_1+2048] * chrFilter[j];",
"}",
"Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"U >>= 19;",
"V >>= 19;",
"Cb= clip_yuvtab_40cf[U+ 256];",
"Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"Cr= clip_yuvtab_3343[V+ 256];",
"((uint16_t*)dest)[2*VAR_1] =\nclip_table16b[(Y1 + Cb) >>13] |\nclip_table16g[(Y1 + Cg) >>13] |\nclip_table16r[(Y1 + Cr) >>13];",
"((uint16_t*)dest)[2*VAR_1+1] =\nclip_table16b[(Y2 + Cb) >>13] |\nclip_table16g[(Y2 + Cg) >>13] |\nclip_table16r[(Y2 + Cr) >>13];",
"}",
"}",
"else if(dstbpp==15)\n{",
"int VAR_1;",
"for(VAR_1=0; VAR_1<(dstW>>1); VAR_1++){",
"int j;",
"int Y1=0;",
"int Y2=0;",
"int U=0;",
"int V=0;",
"int Cb, Cr, Cg;",
"for(j=0; j<lumFilterSize; j++)",
"{",
"Y1 += lumSrc[j][2*VAR_1] * lumFilter[j];",
"Y2 += lumSrc[j][2*VAR_1+1] * lumFilter[j];",
"}",
"for(j=0; j<chrFilterSize; j++)",
"{",
"U += chrSrc[j][VAR_1] * chrFilter[j];",
"V += chrSrc[j][VAR_1+2048] * chrFilter[j];",
"}",
"Y1= clip_yuvtab_2568[ (Y1>>19) + 256 ];",
"Y2= clip_yuvtab_2568[ (Y2>>19) + 256 ];",
"U >>= 19;",
"V >>= 19;",
"Cb= clip_yuvtab_40cf[U+ 256];",
"Cg= clip_yuvtab_1a1e[V+ 256] + yuvtab_0c92[U+ 256];",
"Cr= clip_yuvtab_3343[V+ 256];",
"((uint16_t*)dest)[2*VAR_1] =\nclip_table15b[(Y1 + Cb) >>13] |\nclip_table15g[(Y1 + Cg) >>13] |\nclip_table15r[(Y1 + Cr) >>13];",
"((uint16_t*)dest)[2*VAR_1+1] =\nclip_table15b[(Y2 + Cb) >>13] |\nclip_table15g[(Y2 + Cg) >>13] |\nclip_table15r[(Y2 + Cr) >>13];",
"}",
"}",
"#endif\n}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
1,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9,
11
],
[
15
],
[
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,
81
],
[
83,
85,
89,
91,
93,
95,
97,
101,
105,
107,
109,
111,
113,
115
],
[
117
],
[
119,
121
],
[
123,
125,
129,
131,
133,
135,
137,
141,
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
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
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
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
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
],
[
365
],
[
367
],
[
369
],
[
373,
375,
377,
379
],
[
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
],
[
445
],
[
447
],
[
449
],
[
453,
455,
457,
459
],
[
463,
465,
467,
469
],
[
471
],
[
473
],
[
475,
477
],
[
479
]
]
|
14,607 | static int opt_map(OptionsContext *o, const char *opt, const char *arg)
{
StreamMap *m = NULL;
int i, negative = 0, file_idx;
int sync_file_idx = -1, sync_stream_idx;
char *p, *sync;
char *map;
if (*arg == '-') {
negative = 1;
arg++;
}
map = av_strdup(arg);
/* parse sync stream first, just pick first matching stream */
if (sync = strchr(map, ',')) {
*sync = 0;
sync_file_idx = strtol(sync + 1, &sync, 0);
if (sync_file_idx >= nb_input_files || sync_file_idx < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid sync file index: %d.\n", sync_file_idx);
exit_program(1);
}
if (*sync)
sync++;
for (i = 0; i < input_files[sync_file_idx].nb_streams; i++)
if (check_stream_specifier(input_files[sync_file_idx].ctx,
input_files[sync_file_idx].ctx->streams[i], sync) == 1) {
sync_stream_idx = i;
break;
}
if (i == input_files[sync_file_idx].nb_streams) {
av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "
"match any streams.\n", arg);
exit_program(1);
}
}
file_idx = strtol(map, &p, 0);
if (file_idx >= nb_input_files || file_idx < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
exit_program(1);
}
if (negative)
/* disable some already defined maps */
for (i = 0; i < o->nb_stream_maps; i++) {
m = &o->stream_maps[i];
if (file_idx == m->file_index &&
check_stream_specifier(input_files[m->file_index].ctx,
input_files[m->file_index].ctx->streams[m->stream_index],
*p == ':' ? p + 1 : p) > 0)
m->disabled = 1;
}
else
for (i = 0; i < input_files[file_idx].nb_streams; i++) {
if (check_stream_specifier(input_files[file_idx].ctx, input_files[file_idx].ctx->streams[i],
*p == ':' ? p + 1 : p) <= 0)
continue;
o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps),
&o->nb_stream_maps, o->nb_stream_maps + 1);
m = &o->stream_maps[o->nb_stream_maps - 1];
m->file_index = file_idx;
m->stream_index = i;
if (sync_file_idx >= 0) {
m->sync_file_index = sync_file_idx;
m->sync_stream_index = sync_stream_idx;
} else {
m->sync_file_index = file_idx;
m->sync_stream_index = i;
}
}
if (!m) {
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg);
exit_program(1);
}
av_freep(&map);
return 0;
}
| true | FFmpeg | 12bdc7b15e4f5a24842b34ba79f59ca869f8f33a | static int opt_map(OptionsContext *o, const char *opt, const char *arg)
{
StreamMap *m = NULL;
int i, negative = 0, file_idx;
int sync_file_idx = -1, sync_stream_idx;
char *p, *sync;
char *map;
if (*arg == '-') {
negative = 1;
arg++;
}
map = av_strdup(arg);
if (sync = strchr(map, ',')) {
*sync = 0;
sync_file_idx = strtol(sync + 1, &sync, 0);
if (sync_file_idx >= nb_input_files || sync_file_idx < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid sync file index: %d.\n", sync_file_idx);
exit_program(1);
}
if (*sync)
sync++;
for (i = 0; i < input_files[sync_file_idx].nb_streams; i++)
if (check_stream_specifier(input_files[sync_file_idx].ctx,
input_files[sync_file_idx].ctx->streams[i], sync) == 1) {
sync_stream_idx = i;
break;
}
if (i == input_files[sync_file_idx].nb_streams) {
av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s does not "
"match any streams.\n", arg);
exit_program(1);
}
}
file_idx = strtol(map, &p, 0);
if (file_idx >= nb_input_files || file_idx < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
exit_program(1);
}
if (negative)
for (i = 0; i < o->nb_stream_maps; i++) {
m = &o->stream_maps[i];
if (file_idx == m->file_index &&
check_stream_specifier(input_files[m->file_index].ctx,
input_files[m->file_index].ctx->streams[m->stream_index],
*p == ':' ? p + 1 : p) > 0)
m->disabled = 1;
}
else
for (i = 0; i < input_files[file_idx].nb_streams; i++) {
if (check_stream_specifier(input_files[file_idx].ctx, input_files[file_idx].ctx->streams[i],
*p == ':' ? p + 1 : p) <= 0)
continue;
o->stream_maps = grow_array(o->stream_maps, sizeof(*o->stream_maps),
&o->nb_stream_maps, o->nb_stream_maps + 1);
m = &o->stream_maps[o->nb_stream_maps - 1];
m->file_index = file_idx;
m->stream_index = i;
if (sync_file_idx >= 0) {
m->sync_file_index = sync_file_idx;
m->sync_stream_index = sync_stream_idx;
} else {
m->sync_file_index = file_idx;
m->sync_stream_index = i;
}
}
if (!m) {
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg);
exit_program(1);
}
av_freep(&map);
return 0;
}
| {
"code": [
" int sync_file_idx = -1, sync_stream_idx;"
],
"line_no": [
9
]
} | static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1, const char *VAR_2)
{
StreamMap *m = NULL;
int VAR_3, VAR_4 = 0, VAR_5;
int VAR_6 = -1, VAR_7;
char *VAR_8, *VAR_9;
char *VAR_10;
if (*VAR_2 == '-') {
VAR_4 = 1;
VAR_2++;
}
VAR_10 = av_strdup(VAR_2);
if (VAR_9 = strchr(VAR_10, ',')) {
*VAR_9 = 0;
VAR_6 = strtol(VAR_9 + 1, &VAR_9, 0);
if (VAR_6 >= nb_input_files || VAR_6 < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid VAR_9 file index: %d.\n", VAR_6);
exit_program(1);
}
if (*VAR_9)
VAR_9++;
for (VAR_3 = 0; VAR_3 < input_files[VAR_6].nb_streams; VAR_3++)
if (check_stream_specifier(input_files[VAR_6].ctx,
input_files[VAR_6].ctx->streams[VAR_3], VAR_9) == 1) {
VAR_7 = VAR_3;
break;
}
if (VAR_3 == input_files[VAR_6].nb_streams) {
av_log(NULL, AV_LOG_FATAL, "Sync stream specification in VAR_10 %s does not "
"match any streams.\n", VAR_2);
exit_program(1);
}
}
VAR_5 = strtol(VAR_10, &VAR_8, 0);
if (VAR_5 >= nb_input_files || VAR_5 < 0) {
av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", VAR_5);
exit_program(1);
}
if (VAR_4)
for (VAR_3 = 0; VAR_3 < VAR_0->nb_stream_maps; VAR_3++) {
m = &VAR_0->stream_maps[VAR_3];
if (VAR_5 == m->file_index &&
check_stream_specifier(input_files[m->file_index].ctx,
input_files[m->file_index].ctx->streams[m->stream_index],
*VAR_8 == ':' ? VAR_8 + 1 : VAR_8) > 0)
m->disabled = 1;
}
else
for (VAR_3 = 0; VAR_3 < input_files[VAR_5].nb_streams; VAR_3++) {
if (check_stream_specifier(input_files[VAR_5].ctx, input_files[VAR_5].ctx->streams[VAR_3],
*VAR_8 == ':' ? VAR_8 + 1 : VAR_8) <= 0)
continue;
VAR_0->stream_maps = grow_array(VAR_0->stream_maps, sizeof(*VAR_0->stream_maps),
&VAR_0->nb_stream_maps, VAR_0->nb_stream_maps + 1);
m = &VAR_0->stream_maps[VAR_0->nb_stream_maps - 1];
m->file_index = VAR_5;
m->stream_index = VAR_3;
if (VAR_6 >= 0) {
m->sync_file_index = VAR_6;
m->sync_stream_index = VAR_7;
} else {
m->sync_file_index = VAR_5;
m->sync_stream_index = VAR_3;
}
}
if (!m) {
av_log(NULL, AV_LOG_FATAL, "Stream VAR_10 '%s' matches no streams.\n", VAR_2);
exit_program(1);
}
av_freep(&VAR_10);
return 0;
}
| [
"static int FUNC_0(OptionsContext *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"StreamMap *m = NULL;",
"int VAR_3, VAR_4 = 0, VAR_5;",
"int VAR_6 = -1, VAR_7;",
"char *VAR_8, *VAR_9;",
"char *VAR_10;",
"if (*VAR_2 == '-') {",
"VAR_4 = 1;",
"VAR_2++;",
"}",
"VAR_10 = av_strdup(VAR_2);",
"if (VAR_9 = strchr(VAR_10, ',')) {",
"*VAR_9 = 0;",
"VAR_6 = strtol(VAR_9 + 1, &VAR_9, 0);",
"if (VAR_6 >= nb_input_files || VAR_6 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid VAR_9 file index: %d.\\n\", VAR_6);",
"exit_program(1);",
"}",
"if (*VAR_9)\nVAR_9++;",
"for (VAR_3 = 0; VAR_3 < input_files[VAR_6].nb_streams; VAR_3++)",
"if (check_stream_specifier(input_files[VAR_6].ctx,\ninput_files[VAR_6].ctx->streams[VAR_3], VAR_9) == 1) {",
"VAR_7 = VAR_3;",
"break;",
"}",
"if (VAR_3 == input_files[VAR_6].nb_streams) {",
"av_log(NULL, AV_LOG_FATAL, \"Sync stream specification in VAR_10 %s does not \"\n\"match any streams.\\n\", VAR_2);",
"exit_program(1);",
"}",
"}",
"VAR_5 = strtol(VAR_10, &VAR_8, 0);",
"if (VAR_5 >= nb_input_files || VAR_5 < 0) {",
"av_log(NULL, AV_LOG_FATAL, \"Invalid input file index: %d.\\n\", VAR_5);",
"exit_program(1);",
"}",
"if (VAR_4)\nfor (VAR_3 = 0; VAR_3 < VAR_0->nb_stream_maps; VAR_3++) {",
"m = &VAR_0->stream_maps[VAR_3];",
"if (VAR_5 == m->file_index &&\ncheck_stream_specifier(input_files[m->file_index].ctx,\ninput_files[m->file_index].ctx->streams[m->stream_index],\n*VAR_8 == ':' ? VAR_8 + 1 : VAR_8) > 0)\nm->disabled = 1;",
"}",
"else\nfor (VAR_3 = 0; VAR_3 < input_files[VAR_5].nb_streams; VAR_3++) {",
"if (check_stream_specifier(input_files[VAR_5].ctx, input_files[VAR_5].ctx->streams[VAR_3],\n*VAR_8 == ':' ? VAR_8 + 1 : VAR_8) <= 0)\ncontinue;",
"VAR_0->stream_maps = grow_array(VAR_0->stream_maps, sizeof(*VAR_0->stream_maps),\n&VAR_0->nb_stream_maps, VAR_0->nb_stream_maps + 1);",
"m = &VAR_0->stream_maps[VAR_0->nb_stream_maps - 1];",
"m->file_index = VAR_5;",
"m->stream_index = VAR_3;",
"if (VAR_6 >= 0) {",
"m->sync_file_index = VAR_6;",
"m->sync_stream_index = VAR_7;",
"} else {",
"m->sync_file_index = VAR_5;",
"m->sync_stream_index = VAR_3;",
"}",
"}",
"if (!m) {",
"av_log(NULL, AV_LOG_FATAL, \"Stream VAR_10 '%s' matches no streams.\\n\", VAR_2);",
"exit_program(1);",
"}",
"av_freep(&VAR_10);",
"return 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
91
],
[
93
],
[
95,
97,
99,
101,
103
],
[
105
],
[
107,
109
],
[
111,
113,
115
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
]
]
|
14,608 | static void network_to_remote_block(RDMARemoteBlock *rb)
{
rb->remote_host_addr = ntohll(rb->remote_host_addr);
rb->offset = ntohll(rb->offset);
rb->length = ntohll(rb->length);
rb->remote_rkey = ntohl(rb->remote_rkey);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static void network_to_remote_block(RDMARemoteBlock *rb)
{
rb->remote_host_addr = ntohll(rb->remote_host_addr);
rb->offset = ntohll(rb->offset);
rb->length = ntohll(rb->length);
rb->remote_rkey = ntohl(rb->remote_rkey);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(RDMARemoteBlock *VAR_0)
{
VAR_0->remote_host_addr = ntohll(VAR_0->remote_host_addr);
VAR_0->offset = ntohll(VAR_0->offset);
VAR_0->length = ntohll(VAR_0->length);
VAR_0->remote_rkey = ntohl(VAR_0->remote_rkey);
}
| [
"static void FUNC_0(RDMARemoteBlock *VAR_0)\n{",
"VAR_0->remote_host_addr = ntohll(VAR_0->remote_host_addr);",
"VAR_0->offset = ntohll(VAR_0->offset);",
"VAR_0->length = ntohll(VAR_0->length);",
"VAR_0->remote_rkey = ntohl(VAR_0->remote_rkey);",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
]
|
14,609 | static uint8_t *advance_line(uint8_t *start, uint8_t *line,
int stride, int *y, int h, int interleave)
{
*y += interleave;
if (*y < h) {
return line + interleave * stride;
} else {
*y = (*y + 1) & (interleave - 1);
if (*y) {
return start + *y * stride;
} else {
return NULL;
}
}
}
| false | FFmpeg | 796012af6c780b5b13ebca39a491f215515a18fe | static uint8_t *advance_line(uint8_t *start, uint8_t *line,
int stride, int *y, int h, int interleave)
{
*y += interleave;
if (*y < h) {
return line + interleave * stride;
} else {
*y = (*y + 1) & (interleave - 1);
if (*y) {
return start + *y * stride;
} else {
return NULL;
}
}
}
| {
"code": [],
"line_no": []
} | static uint8_t *FUNC_0(uint8_t *start, uint8_t *line,
int stride, int *y, int h, int interleave)
{
*y += interleave;
if (*y < h) {
return line + interleave * stride;
} else {
*y = (*y + 1) & (interleave - 1);
if (*y) {
return start + *y * stride;
} else {
return NULL;
}
}
}
| [
"static uint8_t *FUNC_0(uint8_t *start, uint8_t *line,\nint stride, int *y, int h, int interleave)\n{",
"*y += interleave;",
"if (*y < h) {",
"return line + interleave * stride;",
"} else {",
"*y = (*y + 1) & (interleave - 1);",
"if (*y) {",
"return start + *y * stride;",
"} else {",
"return NULL;",
"}",
"}",
"}"
]
| [
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
]
]
|
14,610 | void ff_put_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_16w_msa(src - (2 * stride) - 2,
stride, dst, stride, 16, 1);
}
| false | FFmpeg | e549933a270dd2cfc36f2cf9bb6b29acf3dc6d08 | void ff_put_h264_qpel16_mc32_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_16w_msa(src - (2 * stride) - 2,
stride, dst, stride, 16, 1);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_midh_qrt_16w_msa(VAR_1 - (2 * VAR_2) - 2,
VAR_2, VAR_0, VAR_2, 16, 1);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_midh_qrt_16w_msa(VAR_1 - (2 * VAR_2) - 2,\nVAR_2, VAR_0, VAR_2, 16, 1);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
11
]
]
|
14,613 | void ff_cavs_init_top_lines(AVSContext *h) {
/* alloc top line of predictors */
h->top_qp = av_malloc( h->mb_width);
h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));
h->top_border_y = av_malloc((h->mb_width+1)*16);
h->top_border_u = av_malloc( h->mb_width * 10);
h->top_border_v = av_malloc( h->mb_width * 10);
/* alloc space for co-located MVs and types */
h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector));
h->col_type_base = av_malloc(h->mb_width*h->mb_height);
h->block = av_mallocz(64*sizeof(int16_t));
}
| true | FFmpeg | 4f3b058c84f570e261d743c7c22f865617fd28ac | void ff_cavs_init_top_lines(AVSContext *h) {
h->top_qp = av_malloc( h->mb_width);
h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));
h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));
h->top_border_y = av_malloc((h->mb_width+1)*16);
h->top_border_u = av_malloc( h->mb_width * 10);
h->top_border_v = av_malloc( h->mb_width * 10);
h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector));
h->col_type_base = av_malloc(h->mb_width*h->mb_height);
h->block = av_mallocz(64*sizeof(int16_t));
}
| {
"code": [
" h->top_qp = av_malloc( h->mb_width);",
" h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));",
" h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector));",
" h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y));",
" h->top_border_y = av_malloc((h->mb_width+1)*16);",
" h->top_border_u = av_malloc( h->mb_width * 10);",
" h->top_border_v = av_malloc( h->mb_width * 10);",
" h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector));",
" h->col_type_base = av_malloc(h->mb_width*h->mb_height);"
],
"line_no": [
5,
7,
9,
11,
13,
15,
17,
23,
25
]
} | void FUNC_0(AVSContext *VAR_0) {
VAR_0->top_qp = av_malloc( VAR_0->mb_width);
VAR_0->top_mv[0] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));
VAR_0->top_mv[1] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));
VAR_0->top_pred_Y = av_malloc( VAR_0->mb_width*2*sizeof(*VAR_0->top_pred_Y));
VAR_0->top_border_y = av_malloc((VAR_0->mb_width+1)*16);
VAR_0->top_border_u = av_malloc( VAR_0->mb_width * 10);
VAR_0->top_border_v = av_malloc( VAR_0->mb_width * 10);
VAR_0->col_mv = av_malloc( VAR_0->mb_width*VAR_0->mb_height*4*sizeof(cavs_vector));
VAR_0->col_type_base = av_malloc(VAR_0->mb_width*VAR_0->mb_height);
VAR_0->block = av_mallocz(64*sizeof(int16_t));
}
| [
"void FUNC_0(AVSContext *VAR_0) {",
"VAR_0->top_qp = av_malloc( VAR_0->mb_width);",
"VAR_0->top_mv[0] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));",
"VAR_0->top_mv[1] = av_malloc((VAR_0->mb_width*2+1)*sizeof(cavs_vector));",
"VAR_0->top_pred_Y = av_malloc( VAR_0->mb_width*2*sizeof(*VAR_0->top_pred_Y));",
"VAR_0->top_border_y = av_malloc((VAR_0->mb_width+1)*16);",
"VAR_0->top_border_u = av_malloc( VAR_0->mb_width * 10);",
"VAR_0->top_border_v = av_malloc( VAR_0->mb_width * 10);",
"VAR_0->col_mv = av_malloc( VAR_0->mb_width*VAR_0->mb_height*4*sizeof(cavs_vector));",
"VAR_0->col_type_base = av_malloc(VAR_0->mb_width*VAR_0->mb_height);",
"VAR_0->block = av_mallocz(64*sizeof(int16_t));",
"}"
]
| [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
]
| [
[
1
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
14,614 | int avresample_open(AVAudioResampleContext *avr)
{
int ret;
/* set channel mixing parameters */
avr->in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
if (avr->in_channels <= 0 || avr->in_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid input channel layout: %"PRIu64"\n",
avr->in_channel_layout);
return AVERROR(EINVAL);
}
avr->out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
if (avr->out_channels <= 0 || avr->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid output channel layout: %"PRIu64"\n",
avr->out_channel_layout);
return AVERROR(EINVAL);
}
avr->resample_channels = FFMIN(avr->in_channels, avr->out_channels);
avr->downmix_needed = avr->in_channels > avr->out_channels;
avr->upmix_needed = avr->out_channels > avr->in_channels ||
avr->am->matrix ||
(avr->out_channels == avr->in_channels &&
avr->in_channel_layout != avr->out_channel_layout);
avr->mixing_needed = avr->downmix_needed || avr->upmix_needed;
/* set resampling parameters */
avr->resample_needed = avr->in_sample_rate != avr->out_sample_rate ||
avr->force_resampling;
/* select internal sample format if not specified by the user */
if (avr->internal_sample_fmt == AV_SAMPLE_FMT_NONE &&
(avr->mixing_needed || avr->resample_needed)) {
enum AVSampleFormat in_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
enum AVSampleFormat out_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
int max_bps = FFMAX(av_get_bytes_per_sample(in_fmt),
av_get_bytes_per_sample(out_fmt));
if (max_bps <= 2) {
avr->internal_sample_fmt = AV_SAMPLE_FMT_S16P;
} else if (avr->mixing_needed) {
avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
} else {
if (max_bps <= 4) {
if (in_fmt == AV_SAMPLE_FMT_S32P ||
out_fmt == AV_SAMPLE_FMT_S32P) {
if (in_fmt == AV_SAMPLE_FMT_FLTP ||
out_fmt == AV_SAMPLE_FMT_FLTP) {
/* if one is s32 and the other is flt, use dbl */
avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
} else {
/* if one is s32 and the other is s32, s16, or u8, use s32 */
avr->internal_sample_fmt = AV_SAMPLE_FMT_S32P;
}
} else {
/* if one is flt and the other is flt, s16 or u8, use flt */
avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
}
} else {
/* if either is dbl, use dbl */
avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
}
}
av_log(avr, AV_LOG_DEBUG, "Using %s as internal sample format\n",
av_get_sample_fmt_name(avr->internal_sample_fmt));
}
/* set sample format conversion parameters */
if (avr->in_channels == 1)
avr->in_sample_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
if (avr->out_channels == 1)
avr->out_sample_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
avr->in_convert_needed = (avr->resample_needed || avr->mixing_needed) &&
avr->in_sample_fmt != avr->internal_sample_fmt;
if (avr->resample_needed || avr->mixing_needed)
avr->out_convert_needed = avr->internal_sample_fmt != avr->out_sample_fmt;
else
avr->out_convert_needed = avr->in_sample_fmt != avr->out_sample_fmt;
/* allocate buffers */
if (avr->mixing_needed || avr->in_convert_needed) {
avr->in_buffer = ff_audio_data_alloc(FFMAX(avr->in_channels, avr->out_channels),
0, avr->internal_sample_fmt,
"in_buffer");
if (!avr->in_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
if (avr->resample_needed) {
avr->resample_out_buffer = ff_audio_data_alloc(avr->out_channels,
0, avr->internal_sample_fmt,
"resample_out_buffer");
if (!avr->resample_out_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
if (avr->out_convert_needed) {
avr->out_buffer = ff_audio_data_alloc(avr->out_channels, 0,
avr->out_sample_fmt, "out_buffer");
if (!avr->out_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
avr->out_fifo = av_audio_fifo_alloc(avr->out_sample_fmt, avr->out_channels,
1024);
if (!avr->out_fifo) {
ret = AVERROR(ENOMEM);
goto error;
}
/* setup contexts */
if (avr->in_convert_needed) {
avr->ac_in = ff_audio_convert_alloc(avr, avr->internal_sample_fmt,
avr->in_sample_fmt, avr->in_channels);
if (!avr->ac_in) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->out_convert_needed) {
enum AVSampleFormat src_fmt;
if (avr->in_convert_needed)
src_fmt = avr->internal_sample_fmt;
else
src_fmt = avr->in_sample_fmt;
avr->ac_out = ff_audio_convert_alloc(avr, avr->out_sample_fmt, src_fmt,
avr->out_channels);
if (!avr->ac_out) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->resample_needed) {
avr->resample = ff_audio_resample_init(avr);
if (!avr->resample) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->mixing_needed) {
ret = ff_audio_mix_init(avr);
if (ret < 0)
goto error;
}
return 0;
error:
avresample_close(avr);
return ret;
}
| true | FFmpeg | 8821ae649e61097ec57ca58472c3e4239c82913c | int avresample_open(AVAudioResampleContext *avr)
{
int ret;
avr->in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
if (avr->in_channels <= 0 || avr->in_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid input channel layout: %"PRIu64"\n",
avr->in_channel_layout);
return AVERROR(EINVAL);
}
avr->out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
if (avr->out_channels <= 0 || avr->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(avr, AV_LOG_ERROR, "Invalid output channel layout: %"PRIu64"\n",
avr->out_channel_layout);
return AVERROR(EINVAL);
}
avr->resample_channels = FFMIN(avr->in_channels, avr->out_channels);
avr->downmix_needed = avr->in_channels > avr->out_channels;
avr->upmix_needed = avr->out_channels > avr->in_channels ||
avr->am->matrix ||
(avr->out_channels == avr->in_channels &&
avr->in_channel_layout != avr->out_channel_layout);
avr->mixing_needed = avr->downmix_needed || avr->upmix_needed;
avr->resample_needed = avr->in_sample_rate != avr->out_sample_rate ||
avr->force_resampling;
if (avr->internal_sample_fmt == AV_SAMPLE_FMT_NONE &&
(avr->mixing_needed || avr->resample_needed)) {
enum AVSampleFormat in_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
enum AVSampleFormat out_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
int max_bps = FFMAX(av_get_bytes_per_sample(in_fmt),
av_get_bytes_per_sample(out_fmt));
if (max_bps <= 2) {
avr->internal_sample_fmt = AV_SAMPLE_FMT_S16P;
} else if (avr->mixing_needed) {
avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
} else {
if (max_bps <= 4) {
if (in_fmt == AV_SAMPLE_FMT_S32P ||
out_fmt == AV_SAMPLE_FMT_S32P) {
if (in_fmt == AV_SAMPLE_FMT_FLTP ||
out_fmt == AV_SAMPLE_FMT_FLTP) {
avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
} else {
avr->internal_sample_fmt = AV_SAMPLE_FMT_S32P;
}
} else {
avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
}
} else {
avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
}
}
av_log(avr, AV_LOG_DEBUG, "Using %s as internal sample format\n",
av_get_sample_fmt_name(avr->internal_sample_fmt));
}
if (avr->in_channels == 1)
avr->in_sample_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
if (avr->out_channels == 1)
avr->out_sample_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
avr->in_convert_needed = (avr->resample_needed || avr->mixing_needed) &&
avr->in_sample_fmt != avr->internal_sample_fmt;
if (avr->resample_needed || avr->mixing_needed)
avr->out_convert_needed = avr->internal_sample_fmt != avr->out_sample_fmt;
else
avr->out_convert_needed = avr->in_sample_fmt != avr->out_sample_fmt;
if (avr->mixing_needed || avr->in_convert_needed) {
avr->in_buffer = ff_audio_data_alloc(FFMAX(avr->in_channels, avr->out_channels),
0, avr->internal_sample_fmt,
"in_buffer");
if (!avr->in_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
if (avr->resample_needed) {
avr->resample_out_buffer = ff_audio_data_alloc(avr->out_channels,
0, avr->internal_sample_fmt,
"resample_out_buffer");
if (!avr->resample_out_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
if (avr->out_convert_needed) {
avr->out_buffer = ff_audio_data_alloc(avr->out_channels, 0,
avr->out_sample_fmt, "out_buffer");
if (!avr->out_buffer) {
ret = AVERROR(EINVAL);
goto error;
}
}
avr->out_fifo = av_audio_fifo_alloc(avr->out_sample_fmt, avr->out_channels,
1024);
if (!avr->out_fifo) {
ret = AVERROR(ENOMEM);
goto error;
}
if (avr->in_convert_needed) {
avr->ac_in = ff_audio_convert_alloc(avr, avr->internal_sample_fmt,
avr->in_sample_fmt, avr->in_channels);
if (!avr->ac_in) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->out_convert_needed) {
enum AVSampleFormat src_fmt;
if (avr->in_convert_needed)
src_fmt = avr->internal_sample_fmt;
else
src_fmt = avr->in_sample_fmt;
avr->ac_out = ff_audio_convert_alloc(avr, avr->out_sample_fmt, src_fmt,
avr->out_channels);
if (!avr->ac_out) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->resample_needed) {
avr->resample = ff_audio_resample_init(avr);
if (!avr->resample) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (avr->mixing_needed) {
ret = ff_audio_mix_init(avr);
if (ret < 0)
goto error;
}
return 0;
error:
avresample_close(avr);
return ret;
}
| {
"code": [
" avr->am->matrix ||",
" (avr->out_channels == avr->in_channels &&",
" avr->in_channel_layout != avr->out_channel_layout);"
],
"line_no": [
41,
43,
45
]
} | int FUNC_0(AVAudioResampleContext *VAR_0)
{
int VAR_1;
VAR_0->in_channels = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout);
if (VAR_0->in_channels <= 0 || VAR_0->in_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid input channel layout: %"PRIu64"\n",
VAR_0->in_channel_layout);
return AVERROR(EINVAL);
}
VAR_0->out_channels = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout);
if (VAR_0->out_channels <= 0 || VAR_0->out_channels > AVRESAMPLE_MAX_CHANNELS) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid output channel layout: %"PRIu64"\n",
VAR_0->out_channel_layout);
return AVERROR(EINVAL);
}
VAR_0->resample_channels = FFMIN(VAR_0->in_channels, VAR_0->out_channels);
VAR_0->downmix_needed = VAR_0->in_channels > VAR_0->out_channels;
VAR_0->upmix_needed = VAR_0->out_channels > VAR_0->in_channels ||
VAR_0->am->matrix ||
(VAR_0->out_channels == VAR_0->in_channels &&
VAR_0->in_channel_layout != VAR_0->out_channel_layout);
VAR_0->mixing_needed = VAR_0->downmix_needed || VAR_0->upmix_needed;
VAR_0->resample_needed = VAR_0->in_sample_rate != VAR_0->out_sample_rate ||
VAR_0->force_resampling;
if (VAR_0->internal_sample_fmt == AV_SAMPLE_FMT_NONE &&
(VAR_0->mixing_needed || VAR_0->resample_needed)) {
enum AVSampleFormat VAR_2 = av_get_planar_sample_fmt(VAR_0->in_sample_fmt);
enum AVSampleFormat VAR_3 = av_get_planar_sample_fmt(VAR_0->out_sample_fmt);
int VAR_4 = FFMAX(av_get_bytes_per_sample(VAR_2),
av_get_bytes_per_sample(VAR_3));
if (VAR_4 <= 2) {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_S16P;
} else if (VAR_0->mixing_needed) {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
} else {
if (VAR_4 <= 4) {
if (VAR_2 == AV_SAMPLE_FMT_S32P ||
VAR_3 == AV_SAMPLE_FMT_S32P) {
if (VAR_2 == AV_SAMPLE_FMT_FLTP ||
VAR_3 == AV_SAMPLE_FMT_FLTP) {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
} else {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_S32P;
}
} else {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
}
} else {
VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
}
}
av_log(VAR_0, AV_LOG_DEBUG, "Using %s as internal sample format\n",
av_get_sample_fmt_name(VAR_0->internal_sample_fmt));
}
if (VAR_0->in_channels == 1)
VAR_0->in_sample_fmt = av_get_planar_sample_fmt(VAR_0->in_sample_fmt);
if (VAR_0->out_channels == 1)
VAR_0->out_sample_fmt = av_get_planar_sample_fmt(VAR_0->out_sample_fmt);
VAR_0->in_convert_needed = (VAR_0->resample_needed || VAR_0->mixing_needed) &&
VAR_0->in_sample_fmt != VAR_0->internal_sample_fmt;
if (VAR_0->resample_needed || VAR_0->mixing_needed)
VAR_0->out_convert_needed = VAR_0->internal_sample_fmt != VAR_0->out_sample_fmt;
else
VAR_0->out_convert_needed = VAR_0->in_sample_fmt != VAR_0->out_sample_fmt;
if (VAR_0->mixing_needed || VAR_0->in_convert_needed) {
VAR_0->in_buffer = ff_audio_data_alloc(FFMAX(VAR_0->in_channels, VAR_0->out_channels),
0, VAR_0->internal_sample_fmt,
"in_buffer");
if (!VAR_0->in_buffer) {
VAR_1 = AVERROR(EINVAL);
goto error;
}
}
if (VAR_0->resample_needed) {
VAR_0->resample_out_buffer = ff_audio_data_alloc(VAR_0->out_channels,
0, VAR_0->internal_sample_fmt,
"resample_out_buffer");
if (!VAR_0->resample_out_buffer) {
VAR_1 = AVERROR(EINVAL);
goto error;
}
}
if (VAR_0->out_convert_needed) {
VAR_0->out_buffer = ff_audio_data_alloc(VAR_0->out_channels, 0,
VAR_0->out_sample_fmt, "out_buffer");
if (!VAR_0->out_buffer) {
VAR_1 = AVERROR(EINVAL);
goto error;
}
}
VAR_0->out_fifo = av_audio_fifo_alloc(VAR_0->out_sample_fmt, VAR_0->out_channels,
1024);
if (!VAR_0->out_fifo) {
VAR_1 = AVERROR(ENOMEM);
goto error;
}
if (VAR_0->in_convert_needed) {
VAR_0->ac_in = ff_audio_convert_alloc(VAR_0, VAR_0->internal_sample_fmt,
VAR_0->in_sample_fmt, VAR_0->in_channels);
if (!VAR_0->ac_in) {
VAR_1 = AVERROR(ENOMEM);
goto error;
}
}
if (VAR_0->out_convert_needed) {
enum AVSampleFormat VAR_5;
if (VAR_0->in_convert_needed)
VAR_5 = VAR_0->internal_sample_fmt;
else
VAR_5 = VAR_0->in_sample_fmt;
VAR_0->ac_out = ff_audio_convert_alloc(VAR_0, VAR_0->out_sample_fmt, VAR_5,
VAR_0->out_channels);
if (!VAR_0->ac_out) {
VAR_1 = AVERROR(ENOMEM);
goto error;
}
}
if (VAR_0->resample_needed) {
VAR_0->resample = ff_audio_resample_init(VAR_0);
if (!VAR_0->resample) {
VAR_1 = AVERROR(ENOMEM);
goto error;
}
}
if (VAR_0->mixing_needed) {
VAR_1 = ff_audio_mix_init(VAR_0);
if (VAR_1 < 0)
goto error;
}
return 0;
error:
avresample_close(VAR_0);
return VAR_1;
}
| [
"int FUNC_0(AVAudioResampleContext *VAR_0)\n{",
"int VAR_1;",
"VAR_0->in_channels = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout);",
"if (VAR_0->in_channels <= 0 || VAR_0->in_channels > AVRESAMPLE_MAX_CHANNELS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid input channel layout: %\"PRIu64\"\\n\",\nVAR_0->in_channel_layout);",
"return AVERROR(EINVAL);",
"}",
"VAR_0->out_channels = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout);",
"if (VAR_0->out_channels <= 0 || VAR_0->out_channels > AVRESAMPLE_MAX_CHANNELS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid output channel layout: %\"PRIu64\"\\n\",\nVAR_0->out_channel_layout);",
"return AVERROR(EINVAL);",
"}",
"VAR_0->resample_channels = FFMIN(VAR_0->in_channels, VAR_0->out_channels);",
"VAR_0->downmix_needed = VAR_0->in_channels > VAR_0->out_channels;",
"VAR_0->upmix_needed = VAR_0->out_channels > VAR_0->in_channels ||\nVAR_0->am->matrix ||\n(VAR_0->out_channels == VAR_0->in_channels &&\nVAR_0->in_channel_layout != VAR_0->out_channel_layout);",
"VAR_0->mixing_needed = VAR_0->downmix_needed || VAR_0->upmix_needed;",
"VAR_0->resample_needed = VAR_0->in_sample_rate != VAR_0->out_sample_rate ||\nVAR_0->force_resampling;",
"if (VAR_0->internal_sample_fmt == AV_SAMPLE_FMT_NONE &&\n(VAR_0->mixing_needed || VAR_0->resample_needed)) {",
"enum AVSampleFormat VAR_2 = av_get_planar_sample_fmt(VAR_0->in_sample_fmt);",
"enum AVSampleFormat VAR_3 = av_get_planar_sample_fmt(VAR_0->out_sample_fmt);",
"int VAR_4 = FFMAX(av_get_bytes_per_sample(VAR_2),\nav_get_bytes_per_sample(VAR_3));",
"if (VAR_4 <= 2) {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_S16P;",
"} else if (VAR_0->mixing_needed) {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;",
"} else {",
"if (VAR_4 <= 4) {",
"if (VAR_2 == AV_SAMPLE_FMT_S32P ||\nVAR_3 == AV_SAMPLE_FMT_S32P) {",
"if (VAR_2 == AV_SAMPLE_FMT_FLTP ||\nVAR_3 == AV_SAMPLE_FMT_FLTP) {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;",
"} else {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_S32P;",
"}",
"} else {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;",
"}",
"} else {",
"VAR_0->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;",
"}",
"}",
"av_log(VAR_0, AV_LOG_DEBUG, \"Using %s as internal sample format\\n\",\nav_get_sample_fmt_name(VAR_0->internal_sample_fmt));",
"}",
"if (VAR_0->in_channels == 1)\nVAR_0->in_sample_fmt = av_get_planar_sample_fmt(VAR_0->in_sample_fmt);",
"if (VAR_0->out_channels == 1)\nVAR_0->out_sample_fmt = av_get_planar_sample_fmt(VAR_0->out_sample_fmt);",
"VAR_0->in_convert_needed = (VAR_0->resample_needed || VAR_0->mixing_needed) &&\nVAR_0->in_sample_fmt != VAR_0->internal_sample_fmt;",
"if (VAR_0->resample_needed || VAR_0->mixing_needed)\nVAR_0->out_convert_needed = VAR_0->internal_sample_fmt != VAR_0->out_sample_fmt;",
"else\nVAR_0->out_convert_needed = VAR_0->in_sample_fmt != VAR_0->out_sample_fmt;",
"if (VAR_0->mixing_needed || VAR_0->in_convert_needed) {",
"VAR_0->in_buffer = ff_audio_data_alloc(FFMAX(VAR_0->in_channels, VAR_0->out_channels),\n0, VAR_0->internal_sample_fmt,\n\"in_buffer\");",
"if (!VAR_0->in_buffer) {",
"VAR_1 = AVERROR(EINVAL);",
"goto error;",
"}",
"}",
"if (VAR_0->resample_needed) {",
"VAR_0->resample_out_buffer = ff_audio_data_alloc(VAR_0->out_channels,\n0, VAR_0->internal_sample_fmt,\n\"resample_out_buffer\");",
"if (!VAR_0->resample_out_buffer) {",
"VAR_1 = AVERROR(EINVAL);",
"goto error;",
"}",
"}",
"if (VAR_0->out_convert_needed) {",
"VAR_0->out_buffer = ff_audio_data_alloc(VAR_0->out_channels, 0,\nVAR_0->out_sample_fmt, \"out_buffer\");",
"if (!VAR_0->out_buffer) {",
"VAR_1 = AVERROR(EINVAL);",
"goto error;",
"}",
"}",
"VAR_0->out_fifo = av_audio_fifo_alloc(VAR_0->out_sample_fmt, VAR_0->out_channels,\n1024);",
"if (!VAR_0->out_fifo) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto error;",
"}",
"if (VAR_0->in_convert_needed) {",
"VAR_0->ac_in = ff_audio_convert_alloc(VAR_0, VAR_0->internal_sample_fmt,\nVAR_0->in_sample_fmt, VAR_0->in_channels);",
"if (!VAR_0->ac_in) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto error;",
"}",
"}",
"if (VAR_0->out_convert_needed) {",
"enum AVSampleFormat VAR_5;",
"if (VAR_0->in_convert_needed)\nVAR_5 = VAR_0->internal_sample_fmt;",
"else\nVAR_5 = VAR_0->in_sample_fmt;",
"VAR_0->ac_out = ff_audio_convert_alloc(VAR_0, VAR_0->out_sample_fmt, VAR_5,\nVAR_0->out_channels);",
"if (!VAR_0->ac_out) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto error;",
"}",
"}",
"if (VAR_0->resample_needed) {",
"VAR_0->resample = ff_audio_resample_init(VAR_0);",
"if (!VAR_0->resample) {",
"VAR_1 = AVERROR(ENOMEM);",
"goto error;",
"}",
"}",
"if (VAR_0->mixing_needed) {",
"VAR_1 = ff_audio_mix_init(VAR_0);",
"if (VAR_1 < 0)\ngoto error;",
"}",
"return 0;",
"error:\navresample_close(VAR_0);",
"return VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39,
41,
43,
45
],
[
47
],
[
53,
55
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85,
87
],
[
89,
91
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123,
125
],
[
127
],
[
133,
135
],
[
137,
139
],
[
141,
143
],
[
145,
147
],
[
149,
151
],
[
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
],
[
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
],
[
293
],
[
297,
299
],
[
301
],
[
303
]
]
|
14,615 | void resume_all_vcpus(void)
{
}
| true | qemu | 12d4536f7d911b6d87a766ad7300482ea663cea2 | void resume_all_vcpus(void)
{
}
| {
"code": [
"void resume_all_vcpus(void)"
],
"line_no": [
1
]
} | void FUNC_0(void)
{
}
| [
"void FUNC_0(void)\n{",
"}"
]
| [
1,
0
]
| [
[
1,
3
],
[
5
]
]
|
14,616 | bool cpu_exec_all(void)
{
int r;
/* Account partial waits to the vm_clock. */
qemu_clock_warp(vm_clock);
if (next_cpu == NULL) {
next_cpu = first_cpu;
}
for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
CPUState *env = next_cpu;
qemu_clock_enable(vm_clock,
(env->singlestep_enabled & SSTEP_NOTIMER) == 0);
#ifndef CONFIG_IOTHREAD
if (qemu_alarm_pending()) {
break;
}
#endif
if (cpu_can_run(env)) {
if (kvm_enabled()) {
r = kvm_cpu_exec(env);
qemu_kvm_eat_signals(env);
} else {
r = tcg_cpu_exec(env);
}
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(env);
break;
}
} else if (env->stop || env->stopped) {
break;
}
}
exit_request = 0;
return !all_cpu_threads_idle();
}
| true | qemu | 12d4536f7d911b6d87a766ad7300482ea663cea2 | bool cpu_exec_all(void)
{
int r;
qemu_clock_warp(vm_clock);
if (next_cpu == NULL) {
next_cpu = first_cpu;
}
for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
CPUState *env = next_cpu;
qemu_clock_enable(vm_clock,
(env->singlestep_enabled & SSTEP_NOTIMER) == 0);
#ifndef CONFIG_IOTHREAD
if (qemu_alarm_pending()) {
break;
}
#endif
if (cpu_can_run(env)) {
if (kvm_enabled()) {
r = kvm_cpu_exec(env);
qemu_kvm_eat_signals(env);
} else {
r = tcg_cpu_exec(env);
}
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(env);
break;
}
} else if (env->stop || env->stopped) {
break;
}
}
exit_request = 0;
return !all_cpu_threads_idle();
}
| {
"code": [
"#endif",
"#endif",
"#ifndef CONFIG_IOTHREAD",
"#endif",
"#endif",
"#endif",
"#endif",
"#ifndef CONFIG_IOTHREAD",
" int r;",
"#endif",
"#endif",
"#ifndef CONFIG_IOTHREAD",
" if (qemu_alarm_pending()) {",
" break;",
"#endif",
"#endif",
"#ifndef CONFIG_IOTHREAD",
"#endif",
"#endif",
"#ifndef CONFIG_IOTHREAD",
"#endif",
"#ifndef CONFIG_IOTHREAD",
"#endif",
"#endif"
],
"line_no": [
41,
41,
33,
41,
41,
41,
41,
33,
5,
41,
41,
33,
35,
37,
41,
41,
33,
41,
41,
33,
41,
33,
41,
41
]
} | bool FUNC_0(void)
{
int VAR_0;
qemu_clock_warp(vm_clock);
if (next_cpu == NULL) {
next_cpu = first_cpu;
}
for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
CPUState *env = next_cpu;
qemu_clock_enable(vm_clock,
(env->singlestep_enabled & SSTEP_NOTIMER) == 0);
#ifndef CONFIG_IOTHREAD
if (qemu_alarm_pending()) {
break;
}
#endif
if (cpu_can_run(env)) {
if (kvm_enabled()) {
VAR_0 = kvm_cpu_exec(env);
qemu_kvm_eat_signals(env);
} else {
VAR_0 = tcg_cpu_exec(env);
}
if (VAR_0 == EXCP_DEBUG) {
cpu_handle_guest_debug(env);
break;
}
} else if (env->stop || env->stopped) {
break;
}
}
exit_request = 0;
return !all_cpu_threads_idle();
}
| [
"bool FUNC_0(void)\n{",
"int VAR_0;",
"qemu_clock_warp(vm_clock);",
"if (next_cpu == NULL) {",
"next_cpu = first_cpu;",
"}",
"for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {",
"CPUState *env = next_cpu;",
"qemu_clock_enable(vm_clock,\n(env->singlestep_enabled & SSTEP_NOTIMER) == 0);",
"#ifndef CONFIG_IOTHREAD\nif (qemu_alarm_pending()) {",
"break;",
"}",
"#endif\nif (cpu_can_run(env)) {",
"if (kvm_enabled()) {",
"VAR_0 = kvm_cpu_exec(env);",
"qemu_kvm_eat_signals(env);",
"} else {",
"VAR_0 = tcg_cpu_exec(env);",
"}",
"if (VAR_0 == EXCP_DEBUG) {",
"cpu_handle_guest_debug(env);",
"break;",
"}",
"} else if (env->stop || env->stopped) {",
"break;",
"}",
"}",
"exit_request = 0;",
"return !all_cpu_threads_idle();",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
14,617 | static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
uint32_t node, bool dedicated_hp_event_source,
Error **errp)
{
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
int i, fdt_offset, fdt_size;
void *fdt;
uint64_t addr = addr_start;
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr/SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
fdt = create_device_tree(&fdt_size);
fdt_offset = spapr_populate_memory_node(fdt, node, addr,
SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
addr += SPAPR_MEMORY_BLOCK_SIZE;
/* send hotplug notification to the
* guest only in case of hotplugged memory
*/
if (dev->hotplugged) {
if (dedicated_hp_event_source) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs,
drck->get_index(drc));
} else {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs);
| true | qemu | 5c0139a8c2f01e068c96d456ecf12b0eeb707660 | static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
uint32_t node, bool dedicated_hp_event_source,
Error **errp)
{
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
uint32_t nr_lmbs = size/SPAPR_MEMORY_BLOCK_SIZE;
int i, fdt_offset, fdt_size;
void *fdt;
uint64_t addr = addr_start;
for (i = 0; i < nr_lmbs; i++) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr/SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
fdt = create_device_tree(&fdt_size);
fdt_offset = spapr_populate_memory_node(fdt, node, addr,
SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp);
addr += SPAPR_MEMORY_BLOCK_SIZE;
if (dev->hotplugged) {
if (dedicated_hp_event_source) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs,
drck->get_index(drc));
} else {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs);
| {
"code": [],
"line_no": []
} | static void FUNC_0(DeviceState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,
uint32_t VAR_3, bool VAR_4,
Error **VAR_5)
{
sPAPRDRConnector *drc;
sPAPRDRConnectorClass *drck;
uint32_t nr_lmbs = VAR_2/SPAPR_MEMORY_BLOCK_SIZE;
int VAR_6, VAR_7, VAR_8;
void *VAR_9;
uint64_t addr = VAR_1;
for (VAR_6 = 0; VAR_6 < nr_lmbs; VAR_6++) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
addr/SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
VAR_9 = create_device_tree(&VAR_8);
VAR_7 = spapr_populate_memory_node(VAR_9, VAR_3, addr,
SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->attach(drc, VAR_0, VAR_9, VAR_7, !VAR_0->hotplugged, VAR_5);
addr += SPAPR_MEMORY_BLOCK_SIZE;
if (VAR_0->hotplugged) {
if (VAR_4) {
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,
VAR_1 / SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs,
drck->get_index(drc));
} else {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs);
| [
"static void FUNC_0(DeviceState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,\nuint32_t VAR_3, bool VAR_4,\nError **VAR_5)\n{",
"sPAPRDRConnector *drc;",
"sPAPRDRConnectorClass *drck;",
"uint32_t nr_lmbs = VAR_2/SPAPR_MEMORY_BLOCK_SIZE;",
"int VAR_6, VAR_7, VAR_8;",
"void *VAR_9;",
"uint64_t addr = VAR_1;",
"for (VAR_6 = 0; VAR_6 < nr_lmbs; VAR_6++) {",
"drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\naddr/SPAPR_MEMORY_BLOCK_SIZE);",
"g_assert(drc);",
"VAR_9 = create_device_tree(&VAR_8);",
"VAR_7 = spapr_populate_memory_node(VAR_9, VAR_3, addr,\nSPAPR_MEMORY_BLOCK_SIZE);",
"drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"drck->attach(drc, VAR_0, VAR_9, VAR_7, !VAR_0->hotplugged, VAR_5);",
"addr += SPAPR_MEMORY_BLOCK_SIZE;",
"if (VAR_0->hotplugged) {",
"if (VAR_4) {",
"drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB,\nVAR_1 / SPAPR_MEMORY_BLOCK_SIZE);",
"drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,\nnr_lmbs,\ndrck->get_index(drc));",
"} else {",
"spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,\nnr_lmbs);"
]
| [
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
],
[
41
],
[
43
],
[
45
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77,
79
]
]
|
14,618 | CPUState *ppc440ep_init(ram_addr_t *ram_size, PCIBus **pcip,
const unsigned int pci_irq_nrs[4], int do_init,
const char *cpu_model)
{
target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
CPUState *env;
qemu_irq *pic;
qemu_irq *irqs;
qemu_irq *pci_irqs;
if (cpu_model == NULL)
cpu_model = "405"; // XXX: should be 440EP
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
ppc_dcr_init(env, NULL, NULL);
/* interrupt controller */
irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
/* SDRAM controller */
memset(ram_bases, 0, sizeof(ram_bases));
memset(ram_sizes, 0, sizeof(ram_sizes));
*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
ram_bases, ram_sizes,
ppc440ep_sdram_bank_sizes);
/* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */
ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_bases,
ram_sizes, do_init);
/* PCI */
pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = pic[pci_irq_nrs[0]];
pci_irqs[1] = pic[pci_irq_nrs[1]];
pci_irqs[2] = pic[pci_irq_nrs[2]];
pci_irqs[3] = pic[pci_irq_nrs[3]];
*pcip = ppc4xx_pci_init(env, pci_irqs,
PPC440EP_PCI_CONFIG,
PPC440EP_PCI_INTACK,
PPC440EP_PCI_SPECIAL,
PPC440EP_PCI_REGS);
if (!*pcip)
printf("couldn't create PCI controller!\n");
isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
return env;
}
| true | qemu | 0dd4bc7dd45de7afa88662d24bd50a3aafdbab64 | CPUState *ppc440ep_init(ram_addr_t *ram_size, PCIBus **pcip,
const unsigned int pci_irq_nrs[4], int do_init,
const char *cpu_model)
{
target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
CPUState *env;
qemu_irq *pic;
qemu_irq *irqs;
qemu_irq *pci_irqs;
if (cpu_model == NULL)
cpu_model = "405";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
ppc_dcr_init(env, NULL, NULL);
irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
memset(ram_bases, 0, sizeof(ram_bases));
memset(ram_sizes, 0, sizeof(ram_sizes));
*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
ram_bases, ram_sizes,
ppc440ep_sdram_bank_sizes);
ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_bases,
ram_sizes, do_init);
pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = pic[pci_irq_nrs[0]];
pci_irqs[1] = pic[pci_irq_nrs[1]];
pci_irqs[2] = pic[pci_irq_nrs[2]];
pci_irqs[3] = pic[pci_irq_nrs[3]];
*pcip = ppc4xx_pci_init(env, pci_irqs,
PPC440EP_PCI_CONFIG,
PPC440EP_PCI_INTACK,
PPC440EP_PCI_SPECIAL,
PPC440EP_PCI_REGS);
if (!*pcip)
printf("couldn't create PCI controller!\n");
isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
return env;
}
| {
"code": [
" if (cpu_model == NULL)"
],
"line_no": [
23
]
} | CPUState *FUNC_0(ram_addr_t *ram_size, PCIBus **pcip,
const unsigned int pci_irq_nrs[4], int do_init,
const char *cpu_model)
{
target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
CPUState *env;
qemu_irq *pic;
qemu_irq *irqs;
qemu_irq *pci_irqs;
if (cpu_model == NULL)
cpu_model = "405";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
ppc_dcr_init(env, NULL, NULL);
irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
memset(ram_bases, 0, sizeof(ram_bases));
memset(ram_sizes, 0, sizeof(ram_sizes));
*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
ram_bases, ram_sizes,
ppc440ep_sdram_bank_sizes);
ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_bases,
ram_sizes, do_init);
pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = pic[pci_irq_nrs[0]];
pci_irqs[1] = pic[pci_irq_nrs[1]];
pci_irqs[2] = pic[pci_irq_nrs[2]];
pci_irqs[3] = pic[pci_irq_nrs[3]];
*pcip = ppc4xx_pci_init(env, pci_irqs,
PPC440EP_PCI_CONFIG,
PPC440EP_PCI_INTACK,
PPC440EP_PCI_SPECIAL,
PPC440EP_PCI_REGS);
if (!*pcip)
printf("couldn't create PCI controller!\n");
isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
return env;
}
| [
"CPUState *FUNC_0(ram_addr_t *ram_size, PCIBus **pcip,\nconst unsigned int pci_irq_nrs[4], int do_init,\nconst char *cpu_model)\n{",
"target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];",
"target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];",
"CPUState *env;",
"qemu_irq *pic;",
"qemu_irq *irqs;",
"qemu_irq *pci_irqs;",
"if (cpu_model == NULL)\ncpu_model = \"405\";",
"env = cpu_init(cpu_model);",
"if (!env) {",
"fprintf(stderr, \"Unable to initialize CPU!\\n\");",
"exit(1);",
"}",
"ppc_dcr_init(env, NULL, NULL);",
"irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);",
"irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];",
"irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];",
"pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);",
"memset(ram_bases, 0, sizeof(ram_bases));",
"memset(ram_sizes, 0, sizeof(ram_sizes));",
"*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,\nram_bases, ram_sizes,\nppc440ep_sdram_bank_sizes);",
"ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_bases,\nram_sizes, do_init);",
"pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);",
"pci_irqs[0] = pic[pci_irq_nrs[0]];",
"pci_irqs[1] = pic[pci_irq_nrs[1]];",
"pci_irqs[2] = pic[pci_irq_nrs[2]];",
"pci_irqs[3] = pic[pci_irq_nrs[3]];",
"*pcip = ppc4xx_pci_init(env, pci_irqs,\nPPC440EP_PCI_CONFIG,\nPPC440EP_PCI_INTACK,\nPPC440EP_PCI_SPECIAL,\nPPC440EP_PCI_REGS);",
"if (!*pcip)\nprintf(\"couldn't create PCI controller!\\n\");",
"isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);",
"if (serial_hds[0] != NULL) {",
"serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,\nserial_hds[0], 1, 1);",
"}",
"if (serial_hds[1] != NULL) {",
"serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,\nserial_hds[1], 1, 1);",
"}",
"return env;",
"}"
]
| [
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61,
63,
65
],
[
69,
71
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89,
91,
93,
95
],
[
97,
99
],
[
103
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
125
],
[
127
]
]
|
14,619 | int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
int bufsize, int *header_size, int *coeff)
{
int offset, cutoff;
if (bufsize < 24)
return AVERROR_INVALIDDATA;
if (AV_RB16(buf) != 0x8000)
return AVERROR_INVALIDDATA;
offset = AV_RB16(buf + 2) + 4;
/* if copyright string is within the provided data, validate it */
if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
return AVERROR_INVALIDDATA;
/* check for encoding=3 block_size=18, sample_size=4 */
if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) {
av_log_ask_for_sample(avctx, "unsupported ADX format\n");
return AVERROR_PATCHWELCOME;
}
/* channels */
avctx->channels = buf[7];
if (avctx->channels > 2)
return AVERROR_INVALIDDATA;
/* sample rate */
avctx->sample_rate = AV_RB32(buf + 8);
if (avctx->sample_rate < 1 ||
avctx->sample_rate > INT_MAX / (avctx->channels * BLOCK_SIZE * 8))
return AVERROR_INVALIDDATA;
/* bit rate */
avctx->bit_rate = avctx->sample_rate * avctx->channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES;
/* LPC coefficients */
if (coeff) {
cutoff = AV_RB16(buf + 16);
ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, coeff);
}
*header_size = offset;
return 0;
}
| true | FFmpeg | 6fd075f1806e375f66ce436cca15e085f0088118 | int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
int bufsize, int *header_size, int *coeff)
{
int offset, cutoff;
if (bufsize < 24)
return AVERROR_INVALIDDATA;
if (AV_RB16(buf) != 0x8000)
return AVERROR_INVALIDDATA;
offset = AV_RB16(buf + 2) + 4;
if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
return AVERROR_INVALIDDATA;
if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) {
av_log_ask_for_sample(avctx, "unsupported ADX format\n");
return AVERROR_PATCHWELCOME;
}
avctx->channels = buf[7];
if (avctx->channels > 2)
return AVERROR_INVALIDDATA;
avctx->sample_rate = AV_RB32(buf + 8);
if (avctx->sample_rate < 1 ||
avctx->sample_rate > INT_MAX / (avctx->channels * BLOCK_SIZE * 8))
return AVERROR_INVALIDDATA;
avctx->bit_rate = avctx->sample_rate * avctx->channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES;
if (coeff) {
cutoff = AV_RB16(buf + 16);
ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, coeff);
}
*header_size = offset;
return 0;
}
| {
"code": [
" if (avctx->channels > 2)"
],
"line_no": [
49
]
} | int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1,
int VAR_2, int *VAR_3, int *VAR_4)
{
int VAR_5, VAR_6;
if (VAR_2 < 24)
return AVERROR_INVALIDDATA;
if (AV_RB16(VAR_1) != 0x8000)
return AVERROR_INVALIDDATA;
VAR_5 = AV_RB16(VAR_1 + 2) + 4;
if (VAR_2 >= VAR_5 && memcmp(VAR_1 + VAR_5 - 6, "(c)CRI", 6))
return AVERROR_INVALIDDATA;
if (VAR_1[4] != 3 || VAR_1[5] != 18 || VAR_1[6] != 4) {
av_log_ask_for_sample(VAR_0, "unsupported ADX format\n");
return AVERROR_PATCHWELCOME;
}
VAR_0->channels = VAR_1[7];
if (VAR_0->channels > 2)
return AVERROR_INVALIDDATA;
VAR_0->sample_rate = AV_RB32(VAR_1 + 8);
if (VAR_0->sample_rate < 1 ||
VAR_0->sample_rate > INT_MAX / (VAR_0->channels * BLOCK_SIZE * 8))
return AVERROR_INVALIDDATA;
VAR_0->bit_rate = VAR_0->sample_rate * VAR_0->channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES;
if (VAR_4) {
VAR_6 = AV_RB16(VAR_1 + 16);
ff_adx_calculate_coeffs(VAR_6, VAR_0->sample_rate, COEFF_BITS, VAR_4);
}
*VAR_3 = VAR_5;
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, const uint8_t *VAR_1,\nint VAR_2, int *VAR_3, int *VAR_4)\n{",
"int VAR_5, VAR_6;",
"if (VAR_2 < 24)\nreturn AVERROR_INVALIDDATA;",
"if (AV_RB16(VAR_1) != 0x8000)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = AV_RB16(VAR_1 + 2) + 4;",
"if (VAR_2 >= VAR_5 && memcmp(VAR_1 + VAR_5 - 6, \"(c)CRI\", 6))\nreturn AVERROR_INVALIDDATA;",
"if (VAR_1[4] != 3 || VAR_1[5] != 18 || VAR_1[6] != 4) {",
"av_log_ask_for_sample(VAR_0, \"unsupported ADX format\\n\");",
"return AVERROR_PATCHWELCOME;",
"}",
"VAR_0->channels = VAR_1[7];",
"if (VAR_0->channels > 2)\nreturn AVERROR_INVALIDDATA;",
"VAR_0->sample_rate = AV_RB32(VAR_1 + 8);",
"if (VAR_0->sample_rate < 1 ||\nVAR_0->sample_rate > INT_MAX / (VAR_0->channels * BLOCK_SIZE * 8))\nreturn AVERROR_INVALIDDATA;",
"VAR_0->bit_rate = VAR_0->sample_rate * VAR_0->channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES;",
"if (VAR_4) {",
"VAR_6 = AV_RB16(VAR_1 + 16);",
"ff_adx_calculate_coeffs(VAR_6, VAR_0->sample_rate, COEFF_BITS, VAR_4);",
"}",
"*VAR_3 = VAR_5;",
"return 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
],
[
11,
13
],
[
17,
19
],
[
21
],
[
27,
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47
],
[
49,
51
],
[
57
],
[
59,
61,
63
],
[
69
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
]
]
|
14,620 | static int g2m_decode_frame(AVCodecContext *avctx, void *data,
int *got_picture_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
G2MContext *c = avctx->priv_data;
AVFrame *pic = data;
GetByteContext bc, tbc;
int magic;
int got_header = 0;
uint32_t chunk_size, r_mask, g_mask, b_mask;
int chunk_type, chunk_start;
int i;
int ret;
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR,
"Frame should have at least 12 bytes, got %d instead\n",
buf_size);
return AVERROR_INVALIDDATA;
}
bytestream2_init(&bc, buf, buf_size);
magic = bytestream2_get_be32(&bc);
if ((magic & ~0xF) != MKBETAG('G', '2', 'M', '0') ||
(magic & 0xF) < 2 || (magic & 0xF) > 5) {
av_log(avctx, AV_LOG_ERROR, "Wrong magic %08X\n", magic);
return AVERROR_INVALIDDATA;
}
c->swapuv = magic == MKBETAG('G', '2', 'M', '2');
while (bytestream2_get_bytes_left(&bc) > 5) {
chunk_size = bytestream2_get_le32(&bc) - 1;
chunk_type = bytestream2_get_byte(&bc);
chunk_start = bytestream2_tell(&bc);
if (chunk_size > bytestream2_get_bytes_left(&bc)) {
av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %"PRIu32" type %02X\n",
chunk_size, chunk_type);
break;
}
switch (chunk_type) {
case DISPLAY_INFO:
got_header =
c->got_header = 0;
if (chunk_size < 21) {
av_log(avctx, AV_LOG_ERROR, "Invalid display info size %"PRIu32"\n",
chunk_size);
break;
}
c->width = bytestream2_get_be32(&bc);
c->height = bytestream2_get_be32(&bc);
if (c->width < 16 || c->width > c->orig_width ||
c->height < 16 || c->height > c->orig_height) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame dimensions %dx%d\n",
c->width, c->height);
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
if (c->width != avctx->width || c->height != avctx->height) {
ret = ff_set_dimensions(avctx, c->width, c->height);
if (ret < 0)
goto header_fail;
}
c->compression = bytestream2_get_be32(&bc);
if (c->compression != 2 && c->compression != 3) {
av_log(avctx, AV_LOG_ERROR,
"Unknown compression method %d\n",
c->compression);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
c->tile_width = bytestream2_get_be32(&bc);
c->tile_height = bytestream2_get_be32(&bc);
if (c->tile_width <= 0 || c->tile_height <= 0 ||
((c->tile_width | c->tile_height) & 0xF) ||
c->tile_width * 4LL * c->tile_height >= INT_MAX
) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile dimensions %dx%d\n",
c->tile_width, c->tile_height);
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
c->bpp = bytestream2_get_byte(&bc);
if (c->bpp == 32) {
if (bytestream2_get_bytes_left(&bc) < 16 ||
(chunk_size - 21) < 16) {
av_log(avctx, AV_LOG_ERROR,
"Display info: missing bitmasks!\n");
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
r_mask = bytestream2_get_be32(&bc);
g_mask = bytestream2_get_be32(&bc);
b_mask = bytestream2_get_be32(&bc);
if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
av_log(avctx, AV_LOG_ERROR,
"Invalid or unsupported bitmasks: R=%"PRIX32", G=%"PRIX32", B=%"PRIX32"\n",
r_mask, g_mask, b_mask);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
} else {
avpriv_request_sample(avctx, "bpp=%d", c->bpp);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
if (g2m_init_buffers(c)) {
ret = AVERROR(ENOMEM);
goto header_fail;
}
got_header = 1;
break;
case TILE_DATA:
if (!c->tiles_x || !c->tiles_y) {
av_log(avctx, AV_LOG_WARNING,
"No display info - skipping tile\n");
break;
}
if (chunk_size < 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %"PRIu32"\n",
chunk_size);
break;
}
c->tile_x = bytestream2_get_byte(&bc);
c->tile_y = bytestream2_get_byte(&bc);
if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile pos %d,%d (in %dx%d grid)\n",
c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
break;
}
ret = 0;
switch (c->compression) {
case COMPR_EPIC_J_B:
ret = epic_jb_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
chunk_size - 2, avctx);
break;
case COMPR_KEMPF_J_B:
ret = kempf_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
chunk_size - 2);
break;
}
if (ret && c->framebuf)
av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
c->tile_x, c->tile_y);
break;
case CURSOR_POS:
if (chunk_size < 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %"PRIu32"\n",
chunk_size);
break;
}
c->cursor_x = bytestream2_get_be16(&bc);
c->cursor_y = bytestream2_get_be16(&bc);
break;
case CURSOR_SHAPE:
if (chunk_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %"PRIu32"\n",
chunk_size);
break;
}
bytestream2_init(&tbc, buf + bytestream2_tell(&bc),
chunk_size - 4);
g2m_load_cursor(avctx, c, &tbc);
break;
case CHUNK_CC:
case CHUNK_CD:
break;
default:
av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02d\n",
chunk_type);
}
/* navigate to next chunk */
bytestream2_skip(&bc, chunk_start + chunk_size - bytestream2_tell(&bc));
}
if (got_header)
c->got_header = 1;
if (c->width && c->height && c->framebuf) {
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
pic->key_frame = got_header;
pic->pict_type = got_header ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
for (i = 0; i < avctx->height; i++)
memcpy(pic->data[0] + i * pic->linesize[0],
c->framebuf + i * c->framebuf_stride,
c->width * 3);
g2m_paint_cursor(c, pic->data[0], pic->linesize[0]);
*got_picture_ptr = 1;
}
return buf_size;
header_fail:
c->width =
c->height = 0;
c->tiles_x =
c->tiles_y = 0;
return ret;
}
| true | FFmpeg | 71ec8e1ed6cf4947e204e3e4b5929a44c054f5fb | static int g2m_decode_frame(AVCodecContext *avctx, void *data,
int *got_picture_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
G2MContext *c = avctx->priv_data;
AVFrame *pic = data;
GetByteContext bc, tbc;
int magic;
int got_header = 0;
uint32_t chunk_size, r_mask, g_mask, b_mask;
int chunk_type, chunk_start;
int i;
int ret;
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR,
"Frame should have at least 12 bytes, got %d instead\n",
buf_size);
return AVERROR_INVALIDDATA;
}
bytestream2_init(&bc, buf, buf_size);
magic = bytestream2_get_be32(&bc);
if ((magic & ~0xF) != MKBETAG('G', '2', 'M', '0') ||
(magic & 0xF) < 2 || (magic & 0xF) > 5) {
av_log(avctx, AV_LOG_ERROR, "Wrong magic %08X\n", magic);
return AVERROR_INVALIDDATA;
}
c->swapuv = magic == MKBETAG('G', '2', 'M', '2');
while (bytestream2_get_bytes_left(&bc) > 5) {
chunk_size = bytestream2_get_le32(&bc) - 1;
chunk_type = bytestream2_get_byte(&bc);
chunk_start = bytestream2_tell(&bc);
if (chunk_size > bytestream2_get_bytes_left(&bc)) {
av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %"PRIu32" type %02X\n",
chunk_size, chunk_type);
break;
}
switch (chunk_type) {
case DISPLAY_INFO:
got_header =
c->got_header = 0;
if (chunk_size < 21) {
av_log(avctx, AV_LOG_ERROR, "Invalid display info size %"PRIu32"\n",
chunk_size);
break;
}
c->width = bytestream2_get_be32(&bc);
c->height = bytestream2_get_be32(&bc);
if (c->width < 16 || c->width > c->orig_width ||
c->height < 16 || c->height > c->orig_height) {
av_log(avctx, AV_LOG_ERROR,
"Invalid frame dimensions %dx%d\n",
c->width, c->height);
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
if (c->width != avctx->width || c->height != avctx->height) {
ret = ff_set_dimensions(avctx, c->width, c->height);
if (ret < 0)
goto header_fail;
}
c->compression = bytestream2_get_be32(&bc);
if (c->compression != 2 && c->compression != 3) {
av_log(avctx, AV_LOG_ERROR,
"Unknown compression method %d\n",
c->compression);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
c->tile_width = bytestream2_get_be32(&bc);
c->tile_height = bytestream2_get_be32(&bc);
if (c->tile_width <= 0 || c->tile_height <= 0 ||
((c->tile_width | c->tile_height) & 0xF) ||
c->tile_width * 4LL * c->tile_height >= INT_MAX
) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile dimensions %dx%d\n",
c->tile_width, c->tile_height);
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
c->bpp = bytestream2_get_byte(&bc);
if (c->bpp == 32) {
if (bytestream2_get_bytes_left(&bc) < 16 ||
(chunk_size - 21) < 16) {
av_log(avctx, AV_LOG_ERROR,
"Display info: missing bitmasks!\n");
ret = AVERROR_INVALIDDATA;
goto header_fail;
}
r_mask = bytestream2_get_be32(&bc);
g_mask = bytestream2_get_be32(&bc);
b_mask = bytestream2_get_be32(&bc);
if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
av_log(avctx, AV_LOG_ERROR,
"Invalid or unsupported bitmasks: R=%"PRIX32", G=%"PRIX32", B=%"PRIX32"\n",
r_mask, g_mask, b_mask);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
} else {
avpriv_request_sample(avctx, "bpp=%d", c->bpp);
ret = AVERROR_PATCHWELCOME;
goto header_fail;
}
if (g2m_init_buffers(c)) {
ret = AVERROR(ENOMEM);
goto header_fail;
}
got_header = 1;
break;
case TILE_DATA:
if (!c->tiles_x || !c->tiles_y) {
av_log(avctx, AV_LOG_WARNING,
"No display info - skipping tile\n");
break;
}
if (chunk_size < 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %"PRIu32"\n",
chunk_size);
break;
}
c->tile_x = bytestream2_get_byte(&bc);
c->tile_y = bytestream2_get_byte(&bc);
if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile pos %d,%d (in %dx%d grid)\n",
c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
break;
}
ret = 0;
switch (c->compression) {
case COMPR_EPIC_J_B:
ret = epic_jb_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
chunk_size - 2, avctx);
break;
case COMPR_KEMPF_J_B:
ret = kempf_decode_tile(c, c->tile_x, c->tile_y,
buf + bytestream2_tell(&bc),
chunk_size - 2);
break;
}
if (ret && c->framebuf)
av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
c->tile_x, c->tile_y);
break;
case CURSOR_POS:
if (chunk_size < 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %"PRIu32"\n",
chunk_size);
break;
}
c->cursor_x = bytestream2_get_be16(&bc);
c->cursor_y = bytestream2_get_be16(&bc);
break;
case CURSOR_SHAPE:
if (chunk_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %"PRIu32"\n",
chunk_size);
break;
}
bytestream2_init(&tbc, buf + bytestream2_tell(&bc),
chunk_size - 4);
g2m_load_cursor(avctx, c, &tbc);
break;
case CHUNK_CC:
case CHUNK_CD:
break;
default:
av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02d\n",
chunk_type);
}
bytestream2_skip(&bc, chunk_start + chunk_size - bytestream2_tell(&bc));
}
if (got_header)
c->got_header = 1;
if (c->width && c->height && c->framebuf) {
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
pic->key_frame = got_header;
pic->pict_type = got_header ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
for (i = 0; i < avctx->height; i++)
memcpy(pic->data[0] + i * pic->linesize[0],
c->framebuf + i * c->framebuf_stride,
c->width * 3);
g2m_paint_cursor(c, pic->data[0], pic->linesize[0]);
*got_picture_ptr = 1;
}
return buf_size;
header_fail:
c->width =
c->height = 0;
c->tiles_x =
c->tiles_y = 0;
return ret;
}
| {
"code": [
" c->tile_width * 4LL * c->tile_height >= INT_MAX"
],
"line_no": [
157
]
} | 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;
G2MContext *c = VAR_0->priv_data;
AVFrame *pic = VAR_1;
GetByteContext bc, tbc;
int VAR_6;
int VAR_7 = 0;
uint32_t chunk_size, r_mask, g_mask, b_mask;
int VAR_8, VAR_9;
int VAR_10;
int VAR_11;
if (VAR_5 < 12) {
av_log(VAR_0, AV_LOG_ERROR,
"Frame should have at least 12 bytes, got %d instead\n",
VAR_5);
return AVERROR_INVALIDDATA;
}
bytestream2_init(&bc, VAR_4, VAR_5);
VAR_6 = bytestream2_get_be32(&bc);
if ((VAR_6 & ~0xF) != MKBETAG('G', '2', 'M', '0') ||
(VAR_6 & 0xF) < 2 || (VAR_6 & 0xF) > 5) {
av_log(VAR_0, AV_LOG_ERROR, "Wrong VAR_6 %08X\n", VAR_6);
return AVERROR_INVALIDDATA;
}
c->swapuv = VAR_6 == MKBETAG('G', '2', 'M', '2');
while (bytestream2_get_bytes_left(&bc) > 5) {
chunk_size = bytestream2_get_le32(&bc) - 1;
VAR_8 = bytestream2_get_byte(&bc);
VAR_9 = bytestream2_tell(&bc);
if (chunk_size > bytestream2_get_bytes_left(&bc)) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid chunk size %"PRIu32" type %02X\n",
chunk_size, VAR_8);
break;
}
switch (VAR_8) {
case DISPLAY_INFO:
VAR_7 =
c->VAR_7 = 0;
if (chunk_size < 21) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid display info size %"PRIu32"\n",
chunk_size);
break;
}
c->width = bytestream2_get_be32(&bc);
c->height = bytestream2_get_be32(&bc);
if (c->width < 16 || c->width > c->orig_width ||
c->height < 16 || c->height > c->orig_height) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid frame dimensions %dx%d\n",
c->width, c->height);
VAR_11 = AVERROR_INVALIDDATA;
goto header_fail;
}
if (c->width != VAR_0->width || c->height != VAR_0->height) {
VAR_11 = ff_set_dimensions(VAR_0, c->width, c->height);
if (VAR_11 < 0)
goto header_fail;
}
c->compression = bytestream2_get_be32(&bc);
if (c->compression != 2 && c->compression != 3) {
av_log(VAR_0, AV_LOG_ERROR,
"Unknown compression method %d\n",
c->compression);
VAR_11 = AVERROR_PATCHWELCOME;
goto header_fail;
}
c->tile_width = bytestream2_get_be32(&bc);
c->tile_height = bytestream2_get_be32(&bc);
if (c->tile_width <= 0 || c->tile_height <= 0 ||
((c->tile_width | c->tile_height) & 0xF) ||
c->tile_width * 4LL * c->tile_height >= INT_MAX
) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid tile dimensions %dx%d\n",
c->tile_width, c->tile_height);
VAR_11 = AVERROR_INVALIDDATA;
goto header_fail;
}
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
c->bpp = bytestream2_get_byte(&bc);
if (c->bpp == 32) {
if (bytestream2_get_bytes_left(&bc) < 16 ||
(chunk_size - 21) < 16) {
av_log(VAR_0, AV_LOG_ERROR,
"Display info: missing bitmasks!\n");
VAR_11 = AVERROR_INVALIDDATA;
goto header_fail;
}
r_mask = bytestream2_get_be32(&bc);
g_mask = bytestream2_get_be32(&bc);
b_mask = bytestream2_get_be32(&bc);
if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid or unsupported bitmasks: R=%"PRIX32", G=%"PRIX32", B=%"PRIX32"\n",
r_mask, g_mask, b_mask);
VAR_11 = AVERROR_PATCHWELCOME;
goto header_fail;
}
} else {
avpriv_request_sample(VAR_0, "bpp=%d", c->bpp);
VAR_11 = AVERROR_PATCHWELCOME;
goto header_fail;
}
if (g2m_init_buffers(c)) {
VAR_11 = AVERROR(ENOMEM);
goto header_fail;
}
VAR_7 = 1;
break;
case TILE_DATA:
if (!c->tiles_x || !c->tiles_y) {
av_log(VAR_0, AV_LOG_WARNING,
"No display info - skipping tile\n");
break;
}
if (chunk_size < 2) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid tile VAR_1 size %"PRIu32"\n",
chunk_size);
break;
}
c->tile_x = bytestream2_get_byte(&bc);
c->tile_y = bytestream2_get_byte(&bc);
if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid tile pos %d,%d (in %dx%d grid)\n",
c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
break;
}
VAR_11 = 0;
switch (c->compression) {
case COMPR_EPIC_J_B:
VAR_11 = epic_jb_decode_tile(c, c->tile_x, c->tile_y,
VAR_4 + bytestream2_tell(&bc),
chunk_size - 2, VAR_0);
break;
case COMPR_KEMPF_J_B:
VAR_11 = kempf_decode_tile(c, c->tile_x, c->tile_y,
VAR_4 + bytestream2_tell(&bc),
chunk_size - 2);
break;
}
if (VAR_11 && c->framebuf)
av_log(VAR_0, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
c->tile_x, c->tile_y);
break;
case CURSOR_POS:
if (chunk_size < 5) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid cursor pos size %"PRIu32"\n",
chunk_size);
break;
}
c->cursor_x = bytestream2_get_be16(&bc);
c->cursor_y = bytestream2_get_be16(&bc);
break;
case CURSOR_SHAPE:
if (chunk_size < 8) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid cursor VAR_1 size %"PRIu32"\n",
chunk_size);
break;
}
bytestream2_init(&tbc, VAR_4 + bytestream2_tell(&bc),
chunk_size - 4);
g2m_load_cursor(VAR_0, c, &tbc);
break;
case CHUNK_CC:
case CHUNK_CD:
break;
default:
av_log(VAR_0, AV_LOG_WARNING, "Skipping chunk type %02d\n",
VAR_8);
}
bytestream2_skip(&bc, VAR_9 + chunk_size - bytestream2_tell(&bc));
}
if (VAR_7)
c->VAR_7 = 1;
if (c->width && c->height && c->framebuf) {
if ((VAR_11 = ff_get_buffer(VAR_0, pic, 0)) < 0)
return VAR_11;
pic->key_frame = VAR_7;
pic->pict_type = VAR_7 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
for (VAR_10 = 0; VAR_10 < VAR_0->height; VAR_10++)
memcpy(pic->VAR_1[0] + VAR_10 * pic->linesize[0],
c->framebuf + VAR_10 * c->framebuf_stride,
c->width * 3);
g2m_paint_cursor(c, pic->VAR_1[0], pic->linesize[0]);
*VAR_2 = 1;
}
return VAR_5;
header_fail:
c->width =
c->height = 0;
c->tiles_x =
c->tiles_y = 0;
return VAR_11;
}
| [
"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;",
"int VAR_5 = VAR_3->size;",
"G2MContext *c = VAR_0->priv_data;",
"AVFrame *pic = VAR_1;",
"GetByteContext bc, tbc;",
"int VAR_6;",
"int VAR_7 = 0;",
"uint32_t chunk_size, r_mask, g_mask, b_mask;",
"int VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11;",
"if (VAR_5 < 12) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Frame should have at least 12 bytes, got %d instead\\n\",\nVAR_5);",
"return AVERROR_INVALIDDATA;",
"}",
"bytestream2_init(&bc, VAR_4, VAR_5);",
"VAR_6 = bytestream2_get_be32(&bc);",
"if ((VAR_6 & ~0xF) != MKBETAG('G', '2', 'M', '0') ||\n(VAR_6 & 0xF) < 2 || (VAR_6 & 0xF) > 5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Wrong VAR_6 %08X\\n\", VAR_6);",
"return AVERROR_INVALIDDATA;",
"}",
"c->swapuv = VAR_6 == MKBETAG('G', '2', 'M', '2');",
"while (bytestream2_get_bytes_left(&bc) > 5) {",
"chunk_size = bytestream2_get_le32(&bc) - 1;",
"VAR_8 = bytestream2_get_byte(&bc);",
"VAR_9 = bytestream2_tell(&bc);",
"if (chunk_size > bytestream2_get_bytes_left(&bc)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid chunk size %\"PRIu32\" type %02X\\n\",\nchunk_size, VAR_8);",
"break;",
"}",
"switch (VAR_8) {",
"case DISPLAY_INFO:\nVAR_7 =\nc->VAR_7 = 0;",
"if (chunk_size < 21) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid display info size %\"PRIu32\"\\n\",\nchunk_size);",
"break;",
"}",
"c->width = bytestream2_get_be32(&bc);",
"c->height = bytestream2_get_be32(&bc);",
"if (c->width < 16 || c->width > c->orig_width ||\nc->height < 16 || c->height > c->orig_height) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid frame dimensions %dx%d\\n\",\nc->width, c->height);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto header_fail;",
"}",
"if (c->width != VAR_0->width || c->height != VAR_0->height) {",
"VAR_11 = ff_set_dimensions(VAR_0, c->width, c->height);",
"if (VAR_11 < 0)\ngoto header_fail;",
"}",
"c->compression = bytestream2_get_be32(&bc);",
"if (c->compression != 2 && c->compression != 3) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Unknown compression method %d\\n\",\nc->compression);",
"VAR_11 = AVERROR_PATCHWELCOME;",
"goto header_fail;",
"}",
"c->tile_width = bytestream2_get_be32(&bc);",
"c->tile_height = bytestream2_get_be32(&bc);",
"if (c->tile_width <= 0 || c->tile_height <= 0 ||\n((c->tile_width | c->tile_height) & 0xF) ||\nc->tile_width * 4LL * c->tile_height >= INT_MAX\n) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid tile dimensions %dx%d\\n\",\nc->tile_width, c->tile_height);",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto header_fail;",
"}",
"c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;",
"c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;",
"c->bpp = bytestream2_get_byte(&bc);",
"if (c->bpp == 32) {",
"if (bytestream2_get_bytes_left(&bc) < 16 ||\n(chunk_size - 21) < 16) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Display info: missing bitmasks!\\n\");",
"VAR_11 = AVERROR_INVALIDDATA;",
"goto header_fail;",
"}",
"r_mask = bytestream2_get_be32(&bc);",
"g_mask = bytestream2_get_be32(&bc);",
"b_mask = bytestream2_get_be32(&bc);",
"if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid or unsupported bitmasks: R=%\"PRIX32\", G=%\"PRIX32\", B=%\"PRIX32\"\\n\",\nr_mask, g_mask, b_mask);",
"VAR_11 = AVERROR_PATCHWELCOME;",
"goto header_fail;",
"}",
"} else {",
"avpriv_request_sample(VAR_0, \"bpp=%d\", c->bpp);",
"VAR_11 = AVERROR_PATCHWELCOME;",
"goto header_fail;",
"}",
"if (g2m_init_buffers(c)) {",
"VAR_11 = AVERROR(ENOMEM);",
"goto header_fail;",
"}",
"VAR_7 = 1;",
"break;",
"case TILE_DATA:\nif (!c->tiles_x || !c->tiles_y) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"No display info - skipping tile\\n\");",
"break;",
"}",
"if (chunk_size < 2) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid tile VAR_1 size %\"PRIu32\"\\n\",\nchunk_size);",
"break;",
"}",
"c->tile_x = bytestream2_get_byte(&bc);",
"c->tile_y = bytestream2_get_byte(&bc);",
"if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid tile pos %d,%d (in %dx%d grid)\\n\",\nc->tile_x, c->tile_y, c->tiles_x, c->tiles_y);",
"break;",
"}",
"VAR_11 = 0;",
"switch (c->compression) {",
"case COMPR_EPIC_J_B:\nVAR_11 = epic_jb_decode_tile(c, c->tile_x, c->tile_y,\nVAR_4 + bytestream2_tell(&bc),\nchunk_size - 2, VAR_0);",
"break;",
"case COMPR_KEMPF_J_B:\nVAR_11 = kempf_decode_tile(c, c->tile_x, c->tile_y,\nVAR_4 + bytestream2_tell(&bc),\nchunk_size - 2);",
"break;",
"}",
"if (VAR_11 && c->framebuf)\nav_log(VAR_0, AV_LOG_ERROR, \"Error decoding tile %d,%d\\n\",\nc->tile_x, c->tile_y);",
"break;",
"case CURSOR_POS:\nif (chunk_size < 5) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid cursor pos size %\"PRIu32\"\\n\",\nchunk_size);",
"break;",
"}",
"c->cursor_x = bytestream2_get_be16(&bc);",
"c->cursor_y = bytestream2_get_be16(&bc);",
"break;",
"case CURSOR_SHAPE:\nif (chunk_size < 8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid cursor VAR_1 size %\"PRIu32\"\\n\",\nchunk_size);",
"break;",
"}",
"bytestream2_init(&tbc, VAR_4 + bytestream2_tell(&bc),\nchunk_size - 4);",
"g2m_load_cursor(VAR_0, c, &tbc);",
"break;",
"case CHUNK_CC:\ncase CHUNK_CD:\nbreak;",
"default:\nav_log(VAR_0, AV_LOG_WARNING, \"Skipping chunk type %02d\\n\",\nVAR_8);",
"}",
"bytestream2_skip(&bc, VAR_9 + chunk_size - bytestream2_tell(&bc));",
"}",
"if (VAR_7)\nc->VAR_7 = 1;",
"if (c->width && c->height && c->framebuf) {",
"if ((VAR_11 = ff_get_buffer(VAR_0, pic, 0)) < 0)\nreturn VAR_11;",
"pic->key_frame = VAR_7;",
"pic->pict_type = VAR_7 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;",
"for (VAR_10 = 0; VAR_10 < VAR_0->height; VAR_10++)",
"memcpy(pic->VAR_1[0] + VAR_10 * pic->linesize[0],\nc->framebuf + VAR_10 * c->framebuf_stride,\nc->width * 3);",
"g2m_paint_cursor(c, pic->VAR_1[0], pic->linesize[0]);",
"*VAR_2 = 1;",
"}",
"return VAR_5;",
"header_fail:\nc->width =\nc->height = 0;",
"c->tiles_x =\nc->tiles_y = 0;",
"return VAR_11;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87,
89,
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111,
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
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
],
[
365
],
[
367
],
[
369,
371
],
[
375
],
[
377,
379
],
[
383
],
[
385
],
[
389
],
[
391,
393,
395
],
[
397
],
[
401
],
[
403
],
[
407
],
[
411,
413,
415
],
[
417,
419
],
[
421
],
[
423
]
]
|
14,621 | static int decode_slice(AVCodecContext *avctx,
const uint8_t *buffer,
uint32_t size)
{
H264Context * const h = avctx->priv_data;
MpegEncContext * const s = &h->s;
VASliceParameterBufferH264 *slice_param;
dprintf(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size);
/* Fill in VASliceParameterBufferH264. */
slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
if (!slice_param)
return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8; /* bit buffer started beyond nal_unit_type */
slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(h);
slice_param->direct_spatial_mv_pred_flag = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = s->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0);
fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0);
fill_vaapi_plain_pred_weight_table(h, 0,
&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
&slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);
fill_vaapi_plain_pred_weight_table(h, 1,
&slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,
&slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);
return 0;
}
| false | FFmpeg | 0c32e19d584ba6ddbc27f0a796260404daaf4b6a | static int decode_slice(AVCodecContext *avctx,
const uint8_t *buffer,
uint32_t size)
{
H264Context * const h = avctx->priv_data;
MpegEncContext * const s = &h->s;
VASliceParameterBufferH264 *slice_param;
dprintf(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size);
slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
if (!slice_param)
return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8;
slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(h);
slice_param->direct_spatial_mv_pred_flag = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = s->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0);
fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0);
fill_vaapi_plain_pred_weight_table(h, 0,
&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
&slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);
fill_vaapi_plain_pred_weight_table(h, 1,
&slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,
&slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1,
uint32_t VAR_2)
{
H264Context * const h = VAR_0->priv_data;
MpegEncContext * const s = &h->s;
VASliceParameterBufferH264 *slice_param;
dprintf(VAR_0, "FUNC_0(): VAR_1 %p, VAR_2 %d\n", VAR_1, VAR_2);
slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(VAR_0->hwaccel_context, VAR_1, VAR_2);
if (!slice_param)
return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8;
slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(h);
slice_param->direct_spatial_mv_pred_flag = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = s->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0);
fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0);
fill_vaapi_plain_pred_weight_table(h, 0,
&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
&slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);
fill_vaapi_plain_pred_weight_table(h, 1,
&slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,
&slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nconst uint8_t *VAR_1,\nuint32_t VAR_2)\n{",
"H264Context * const h = VAR_0->priv_data;",
"MpegEncContext * const s = &h->s;",
"VASliceParameterBufferH264 *slice_param;",
"dprintf(VAR_0, \"FUNC_0(): VAR_1 %p, VAR_2 %d\\n\", VAR_1, VAR_2);",
"slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(VAR_0->hwaccel_context, VAR_1, VAR_2);",
"if (!slice_param)\nreturn -1;",
"slice_param->slice_data_bit_offset = get_bits_count(&h->s.gb) + 8;",
"slice_param->first_mb_in_slice = (s->mb_y >> FIELD_OR_MBAFF_PICTURE) * s->mb_width + s->mb_x;",
"slice_param->slice_type = ff_h264_get_slice_type(h);",
"slice_param->direct_spatial_mv_pred_flag = h->slice_type == FF_B_TYPE ? h->direct_spatial_mv_pred : 0;",
"slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;",
"slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0;",
"slice_param->cabac_init_idc = h->cabac_init_idc;",
"slice_param->slice_qp_delta = s->qscale - h->pps.init_qp;",
"slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;",
"slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;",
"slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;",
"slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom;",
"slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;",
"fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0);",
"fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0);",
"fill_vaapi_plain_pred_weight_table(h, 0,\n&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,\n&slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);",
"fill_vaapi_plain_pred_weight_table(h, 1,\n&slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,\n&slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63,
65,
67
],
[
69,
71,
73
],
[
75
],
[
77
]
]
|
14,623 | static void apply_mdct(AC3EncodeContext *s)
{
int blk, ch;
for (ch = 0; ch < s->channels; ch++) {
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
AC3Block *block = &s->blocks[blk];
const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
block->coeff_shift[ch] = normalize_samples(s);
mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples);
}
}
}
| false | FFmpeg | 79997def65fd2313b48a5f3c3a884c6149ae9b5d | static void apply_mdct(AC3EncodeContext *s)
{
int blk, ch;
for (ch = 0; ch < s->channels; ch++) {
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
AC3Block *block = &s->blocks[blk];
const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
block->coeff_shift[ch] = normalize_samples(s);
mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3EncodeContext *VAR_0)
{
int VAR_1, VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) {
for (VAR_1 = 0; VAR_1 < AC3_MAX_BLOCKS; VAR_1++) {
AC3Block *block = &VAR_0->blocks[VAR_1];
const SampleType *input_samples = &VAR_0->planar_samples[VAR_2][VAR_1 * AC3_BLOCK_SIZE];
apply_window(&VAR_0->dsp, VAR_0->windowed_samples, input_samples, VAR_0->mdct.window, AC3_WINDOW_SIZE);
block->coeff_shift[VAR_2] = normalize_samples(VAR_0);
mdct512(&VAR_0->mdct, block->mdct_coef[VAR_2], VAR_0->windowed_samples);
}
}
}
| [
"static void FUNC_0(AC3EncodeContext *VAR_0)\n{",
"int VAR_1, VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_0->channels; VAR_2++) {",
"for (VAR_1 = 0; VAR_1 < AC3_MAX_BLOCKS; VAR_1++) {",
"AC3Block *block = &VAR_0->blocks[VAR_1];",
"const SampleType *input_samples = &VAR_0->planar_samples[VAR_2][VAR_1 * AC3_BLOCK_SIZE];",
"apply_window(&VAR_0->dsp, VAR_0->windowed_samples, input_samples, VAR_0->mdct.window, AC3_WINDOW_SIZE);",
"block->coeff_shift[VAR_2] = normalize_samples(VAR_0);",
"mdct512(&VAR_0->mdct, block->mdct_coef[VAR_2], VAR_0->windowed_samples);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
]
]
|
14,625 | static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
SliceHeader *sh = &s->sh;
int i, ret;
// Coded parameters
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) {
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data;
if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
const HEVCSPS *last_sps = s->ps.sps;
enum AVPixelFormat pix_fmt;
if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) {
if (sps->width != last_sps->width || sps->height != last_sps->height ||
sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering !=
last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(s);
pix_fmt = get_format(s, sps);
if (pix_fmt < 0)
return pix_fmt;
ret = set_sps(s, sps, pix_fmt);
if (ret < 0)
return ret;
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height);
sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
s->slice_idx = 0;
s->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
s->slice_initialized = 0;
for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == HEVC_SLICE_I ||
sh->slice_type == HEVC_SLICE_P ||
sh->slice_type == HEVC_SLICE_B)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
// when flag is not present, picture is inferred to be output
sh->pic_output_flag = 1;
if (s->ps.pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (s->ps.sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(s)) {
int poc, pos;
sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
poc = s->poc;
}
s->poc = poc;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
pos = get_bits_left(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1);
if (ret < 0)
return ret;
sh->short_term_rps = &sh->slice_rps;
} else {
int numbits, rps_idx;
if (!s->ps.sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
numbits = av_ceil_log2(s->ps.sps->nb_st_rps);
rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
sh->short_term_rps = &s->ps.sps->st_rps[rps_idx];
}
sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
pos = get_bits_left(gb);
ret = decode_lt_rps(s, &sh->long_term_rps, gb);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
sh->long_term_ref_pic_set_size = pos - get_bits_left(gb);
if (s->ps.sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
s->sh.short_term_rps = NULL;
s->poc = 0;
}
/* 8.3.1 */
if (sh->first_slice_in_pic_flag && s->temporal_id == 0 &&
s->nal_unit_type != HEVC_NAL_TRAIL_N &&
s->nal_unit_type != HEVC_NAL_TSA_N &&
s->nal_unit_type != HEVC_NAL_STSA_N &&
s->nal_unit_type != HEVC_NAL_RADL_N &&
s->nal_unit_type != HEVC_NAL_RADL_R &&
s->nal_unit_type != HEVC_NAL_RASL_N &&
s->nal_unit_type != HEVC_NAL_RASL_R)
s->pocTid0 = s->poc;
if (s->ps.sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (s->ps.sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
int nb_refs;
sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) { // num_ref_idx_active_override_flag
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > HEVC_MAX_REFS || sh->nb_refs[L1] > HEVC_MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
nb_refs = ff_hevc_frame_nb_refs(s);
if (!nb_refs) {
av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (i = 0; i < sh->nb_refs[L0]; i++)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
if (sh->slice_type == HEVC_SLICE_B) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
}
if (sh->slice_type == HEVC_SLICE_B)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->ps.pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == HEVC_SLICE_B)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
(s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
pred_weight_table(s, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (s->ps.pps->deblocking_filter_control_present_flag) {
int deblocking_filter_override_flag = 0;
if (s->ps.pps->deblocking_filter_override_enabled_flag)
deblocking_filter_override_flag = get_bits1(gb);
if (deblocking_filter_override_flag) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
int beta_offset_div2 = get_se_golomb(gb);
int tc_offset_div2 = get_se_golomb(gb) ;
if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
tc_offset_div2 < -6 || tc_offset_div2 > 6) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid deblock filter offsets: %d, %d\n",
beta_offset_div2, tc_offset_div2);
return AVERROR_INVALIDDATA;
}
sh->beta_offset = beta_offset_div2 * 2;
sh->tc_offset = tc_offset_div2 * 2;
}
} else {
sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf;
sh->beta_offset = s->ps.pps->beta_offset;
sh->tc_offset = s->ps.pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) {
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
// It would be possible to bound this tighter but this here is simpler
if (num_entry_point_offsets > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = num_entry_point_offsets;
if (sh->num_entry_point_offsets > 0) {
int offset_len = get_ue_golomb_long(gb) + 1;
if (offset_len < 1 || offset_len > 32) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < sh->num_entry_point_offsets; i++) {
unsigned val = get_bits_long(gb, offset_len);
sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size
}
if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) {
s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here
s->threads_number = 1;
} else
s->enable_parallel_tiles = 0;
} else
s->enable_parallel_tiles = 0;
}
if (s->ps.pps->slice_header_extension_present_flag) {
unsigned int length = get_ue_golomb_long(gb);
if (length*8LL > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < length; i++)
skip_bits(gb, 8); // slice_header_extension_data_byte
}
// Inferred parameters
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -s->ps.sps->qp_bd_offset) {
av_log(s->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-s->ps.sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->ps.pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
s->HEVClc->tu.cu_qp_offset_cb = 0;
s->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| true | FFmpeg | 2c874548d663225a61b9c25a8b2ce490d26b65fa | static int hls_slice_header(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
SliceHeader *sh = &s->sh;
int i, ret;
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
if (IS_IDR(s))
ff_hevc_clear_refs(s);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) {
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data;
if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
const HEVCSPS *last_sps = s->ps.sps;
enum AVPixelFormat pix_fmt;
if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) {
if (sps->width != last_sps->width || sps->height != last_sps->height ||
sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering !=
last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(s);
pix_fmt = get_format(s, sps);
if (pix_fmt < 0)
return pix_fmt;
ret = set_sps(s, sps, pix_fmt);
if (ret < 0)
return ret;
s->seq_decode = (s->seq_decode + 1) & 0xff;
s->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (s->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
s->ps.sps->ctb_height);
sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
s->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
s->slice_idx = 0;
s->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
s->slice_initialized = 0;
for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == HEVC_SLICE_I ||
sh->slice_type == HEVC_SLICE_P ||
sh->slice_type == HEVC_SLICE_B)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
sh->pic_output_flag = 1;
if (s->ps.pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (s->ps.sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(s)) {
int poc, pos;
sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
poc = s->poc;
}
s->poc = poc;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
pos = get_bits_left(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1);
if (ret < 0)
return ret;
sh->short_term_rps = &sh->slice_rps;
} else {
int numbits, rps_idx;
if (!s->ps.sps->nb_st_rps) {
av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
numbits = av_ceil_log2(s->ps.sps->nb_st_rps);
rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
sh->short_term_rps = &s->ps.sps->st_rps[rps_idx];
}
sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
pos = get_bits_left(gb);
ret = decode_lt_rps(s, &sh->long_term_rps, gb);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
sh->long_term_ref_pic_set_size = pos - get_bits_left(gb);
if (s->ps.sps->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
s->sh.short_term_rps = NULL;
s->poc = 0;
}
if (sh->first_slice_in_pic_flag && s->temporal_id == 0 &&
s->nal_unit_type != HEVC_NAL_TRAIL_N &&
s->nal_unit_type != HEVC_NAL_TSA_N &&
s->nal_unit_type != HEVC_NAL_STSA_N &&
s->nal_unit_type != HEVC_NAL_RADL_N &&
s->nal_unit_type != HEVC_NAL_RADL_R &&
s->nal_unit_type != HEVC_NAL_RASL_N &&
s->nal_unit_type != HEVC_NAL_RASL_R)
s->pocTid0 = s->poc;
if (s->ps.sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (s->ps.sps->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
int nb_refs;
sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) {
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > HEVC_MAX_REFS || sh->nb_refs[L1] > HEVC_MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
nb_refs = ff_hevc_frame_nb_refs(s);
if (!nb_refs) {
av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (i = 0; i < sh->nb_refs[L0]; i++)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
if (sh->slice_type == HEVC_SLICE_B) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
sh->list_entry_lx[1][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
}
if (sh->slice_type == HEVC_SLICE_B)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->ps.pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == HEVC_SLICE_B)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->nb_refs[sh->collocated_list]) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
(s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
pred_weight_table(s, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (s->ps.pps->deblocking_filter_control_present_flag) {
int deblocking_filter_override_flag = 0;
if (s->ps.pps->deblocking_filter_override_enabled_flag)
deblocking_filter_override_flag = get_bits1(gb);
if (deblocking_filter_override_flag) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
int beta_offset_div2 = get_se_golomb(gb);
int tc_offset_div2 = get_se_golomb(gb) ;
if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
tc_offset_div2 < -6 || tc_offset_div2 > 6) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid deblock filter offsets: %d, %d\n",
beta_offset_div2, tc_offset_div2);
return AVERROR_INVALIDDATA;
}
sh->beta_offset = beta_offset_div2 * 2;
sh->tc_offset = tc_offset_div2 * 2;
}
} else {
sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf;
sh->beta_offset = s->ps.pps->beta_offset;
sh->tc_offset = s->ps.pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!s->slice_initialized) {
av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = 0;
if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) {
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
if (num_entry_point_offsets > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
return AVERROR_INVALIDDATA;
}
sh->num_entry_point_offsets = num_entry_point_offsets;
if (sh->num_entry_point_offsets > 0) {
int offset_len = get_ue_golomb_long(gb) + 1;
if (offset_len < 1 || offset_len > 32) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->num_entry_point_offsets = 0;
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < sh->num_entry_point_offsets; i++) {
unsigned val = get_bits_long(gb, offset_len);
sh->entry_point_offset[i] = val + 1;
}
if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) {
s->enable_parallel_tiles = 0;
s->threads_number = 1;
} else
s->enable_parallel_tiles = 0;
} else
s->enable_parallel_tiles = 0;
}
if (s->ps.pps->slice_header_extension_present_flag) {
unsigned int length = get_ue_golomb_long(gb);
if (length*8LL > get_bits_left(gb)) {
av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < length; i++)
skip_bits(gb, 8);
}
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -s->ps.sps->qp_bd_offset) {
av_log(s->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-s->ps.sps->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->ps.pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = s->sh.slice_qp;
s->slice_initialized = 1;
s->HEVClc->tu.cu_qp_offset_cb = 0;
s->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| {
"code": [
" pred_weight_table(s, gb);"
],
"line_no": [
515
]
} | static int FUNC_0(HEVCContext *VAR_0)
{
GetBitContext *gb = &VAR_0->HEVClc->gb;
SliceHeader *sh = &VAR_0->sh;
int VAR_1, VAR_2;
sh->first_slice_in_pic_flag = get_bits1(gb);
if ((IS_IDR(VAR_0) || IS_BLA(VAR_0)) && sh->first_slice_in_pic_flag) {
VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;
VAR_0->max_ra = INT_MAX;
if (IS_IDR(VAR_0))
ff_hevc_clear_refs(VAR_0);
}
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(VAR_0))
sh->no_output_of_prior_pics_flag = get_bits1(gb);
sh->pps_id = get_ue_golomb_long(gb);
if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !VAR_0->ps.pps_list[sh->pps_id]) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
if (!sh->first_slice_in_pic_flag &&
VAR_0->ps.pps != (HEVCPPS*)VAR_0->ps.pps_list[sh->pps_id]->data) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
return AVERROR_INVALIDDATA;
}
VAR_0->ps.pps = (HEVCPPS*)VAR_0->ps.pps_list[sh->pps_id]->data;
if (VAR_0->nal_unit_type == HEVC_NAL_CRA_NUT && VAR_0->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (VAR_0->ps.VAR_3 != (HEVCSPS*)VAR_0->ps.sps_list[VAR_0->ps.pps->sps_id]->data) {
const HEVCSPS *VAR_3 = (HEVCSPS*)VAR_0->ps.sps_list[VAR_0->ps.pps->sps_id]->data;
const HEVCSPS *VAR_4 = VAR_0->ps.VAR_3;
enum AVPixelFormat VAR_5;
if (VAR_4 && IS_IRAP(VAR_0) && VAR_0->nal_unit_type != HEVC_NAL_CRA_NUT) {
if (VAR_3->width != VAR_4->width || VAR_3->height != VAR_4->height ||
VAR_3->temporal_layer[VAR_3->max_sub_layers - 1].max_dec_pic_buffering !=
VAR_4->temporal_layer[VAR_4->max_sub_layers - 1].max_dec_pic_buffering)
sh->no_output_of_prior_pics_flag = 0;
}
ff_hevc_clear_refs(VAR_0);
VAR_5 = get_format(VAR_0, VAR_3);
if (VAR_5 < 0)
return VAR_5;
VAR_2 = set_sps(VAR_0, VAR_3, VAR_5);
if (VAR_2 < 0)
return VAR_2;
VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;
VAR_0->max_ra = INT_MAX;
}
sh->dependent_slice_segment_flag = 0;
if (!sh->first_slice_in_pic_flag) {
int VAR_6;
if (VAR_0->ps.pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
VAR_6 = av_ceil_log2(VAR_0->ps.VAR_3->ctb_width *
VAR_0->ps.VAR_3->ctb_height);
sh->slice_segment_addr = get_bitsz(gb, VAR_6);
if (sh->slice_segment_addr >= VAR_0->ps.VAR_3->ctb_width * VAR_0->ps.VAR_3->ctb_height) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
}
if (!sh->dependent_slice_segment_flag) {
sh->slice_addr = sh->slice_segment_addr;
VAR_0->slice_idx++;
}
} else {
sh->slice_segment_addr = sh->slice_addr = 0;
VAR_0->slice_idx = 0;
VAR_0->slice_initialized = 0;
}
if (!sh->dependent_slice_segment_flag) {
VAR_0->slice_initialized = 0;
for (VAR_1 = 0; VAR_1 < VAR_0->ps.pps->num_extra_slice_header_bits; VAR_1++)
skip_bits(gb, 1);
sh->slice_type = get_ue_golomb_long(gb);
if (!(sh->slice_type == HEVC_SLICE_I ||
sh->slice_type == HEVC_SLICE_P ||
sh->slice_type == HEVC_SLICE_B)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
if (IS_IRAP(VAR_0) && sh->slice_type != HEVC_SLICE_I) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
sh->pic_output_flag = 1;
if (VAR_0->ps.pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (VAR_0->ps.VAR_3->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(VAR_0)) {
int VAR_7, VAR_8;
sh->pic_order_cnt_lsb = get_bits(gb, VAR_0->ps.VAR_3->log2_max_poc_lsb);
VAR_7 = ff_hevc_compute_poc(VAR_0->ps.VAR_3, VAR_0->pocTid0, sh->pic_order_cnt_lsb, VAR_0->nal_unit_type);
if (!sh->first_slice_in_pic_flag && VAR_7 != VAR_0->VAR_7) {
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", VAR_0->VAR_7, VAR_7);
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
VAR_7 = VAR_0->VAR_7;
}
VAR_0->VAR_7 = VAR_7;
sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
VAR_8 = get_bits_left(gb);
if (!sh->short_term_ref_pic_set_sps_flag) {
VAR_2 = ff_hevc_decode_short_term_rps(gb, VAR_0->avctx, &sh->slice_rps, VAR_0->ps.VAR_3, 1);
if (VAR_2 < 0)
return VAR_2;
sh->short_term_rps = &sh->slice_rps;
} else {
int VAR_9, VAR_10;
if (!VAR_0->ps.VAR_3->nb_st_rps) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
return AVERROR_INVALIDDATA;
}
VAR_9 = av_ceil_log2(VAR_0->ps.VAR_3->nb_st_rps);
VAR_10 = VAR_9 > 0 ? get_bits(gb, VAR_9) : 0;
sh->short_term_rps = &VAR_0->ps.VAR_3->st_rps[VAR_10];
}
sh->short_term_ref_pic_set_size = VAR_8 - get_bits_left(gb);
VAR_8 = get_bits_left(gb);
VAR_2 = decode_lt_rps(VAR_0, &sh->long_term_rps, gb);
if (VAR_2 < 0) {
av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
sh->long_term_ref_pic_set_size = VAR_8 - get_bits_left(gb);
if (VAR_0->ps.VAR_3->sps_temporal_mvp_enabled_flag)
sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
else
sh->slice_temporal_mvp_enabled_flag = 0;
} else {
VAR_0->sh.short_term_rps = NULL;
VAR_0->VAR_7 = 0;
}
if (sh->first_slice_in_pic_flag && VAR_0->temporal_id == 0 &&
VAR_0->nal_unit_type != HEVC_NAL_TRAIL_N &&
VAR_0->nal_unit_type != HEVC_NAL_TSA_N &&
VAR_0->nal_unit_type != HEVC_NAL_STSA_N &&
VAR_0->nal_unit_type != HEVC_NAL_RADL_N &&
VAR_0->nal_unit_type != HEVC_NAL_RADL_R &&
VAR_0->nal_unit_type != HEVC_NAL_RASL_N &&
VAR_0->nal_unit_type != HEVC_NAL_RASL_R)
VAR_0->pocTid0 = VAR_0->VAR_7;
if (VAR_0->ps.VAR_3->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
if (VAR_0->ps.VAR_3->chroma_format_idc) {
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
}
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
sh->slice_sample_adaptive_offset_flag[2] = 0;
}
sh->VAR_11[L0] = sh->VAR_11[L1] = 0;
if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
int VAR_11;
sh->VAR_11[L0] = VAR_0->ps.pps->num_ref_idx_l0_default_active;
if (sh->slice_type == HEVC_SLICE_B)
sh->VAR_11[L1] = VAR_0->ps.pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) {
sh->VAR_11[L0] = get_ue_golomb_long(gb) + 1;
if (sh->slice_type == HEVC_SLICE_B)
sh->VAR_11[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->VAR_11[L0] > HEVC_MAX_REFS || sh->VAR_11[L1] > HEVC_MAX_REFS) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->VAR_11[L0], sh->VAR_11[L1]);
return AVERROR_INVALIDDATA;
}
sh->rpl_modification_flag[0] = 0;
sh->rpl_modification_flag[1] = 0;
VAR_11 = ff_hevc_frame_nb_refs(VAR_0);
if (!VAR_11) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Zero refs for a frame with P or B slices.\n");
return AVERROR_INVALIDDATA;
}
if (VAR_0->ps.pps->lists_modification_present_flag && VAR_11 > 1) {
sh->rpl_modification_flag[0] = get_bits1(gb);
if (sh->rpl_modification_flag[0]) {
for (VAR_1 = 0; VAR_1 < sh->VAR_11[L0]; VAR_1++)
sh->list_entry_lx[0][VAR_1] = get_bits(gb, av_ceil_log2(VAR_11));
}
if (sh->slice_type == HEVC_SLICE_B) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (VAR_1 = 0; VAR_1 < sh->VAR_11[L1]; VAR_1++)
sh->list_entry_lx[1][VAR_1] = get_bits(gb, av_ceil_log2(VAR_11));
}
}
if (sh->slice_type == HEVC_SLICE_B)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (VAR_0->ps.pps->cabac_init_present_flag)
sh->cabac_init_flag = get_bits1(gb);
else
sh->cabac_init_flag = 0;
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
if (sh->slice_type == HEVC_SLICE_B)
sh->collocated_list = !get_bits1(gb);
if (sh->VAR_11[sh->collocated_list] > 1) {
sh->collocated_ref_idx = get_ue_golomb_long(gb);
if (sh->collocated_ref_idx >= sh->VAR_11[sh->collocated_list]) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid collocated_ref_idx: %d.\n",
sh->collocated_ref_idx);
return AVERROR_INVALIDDATA;
}
}
}
if ((VAR_0->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
(VAR_0->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
pred_weight_table(VAR_0, gb);
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
if (VAR_0->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
sh->slice_cb_qp_offset = get_se_golomb(gb);
sh->slice_cr_qp_offset = get_se_golomb(gb);
} else {
sh->slice_cb_qp_offset = 0;
sh->slice_cr_qp_offset = 0;
}
if (VAR_0->ps.pps->chroma_qp_offset_list_enabled_flag)
sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
else
sh->cu_chroma_qp_offset_enabled_flag = 0;
if (VAR_0->ps.pps->deblocking_filter_control_present_flag) {
int VAR_12 = 0;
if (VAR_0->ps.pps->deblocking_filter_override_enabled_flag)
VAR_12 = get_bits1(gb);
if (VAR_12) {
sh->disable_deblocking_filter_flag = get_bits1(gb);
if (!sh->disable_deblocking_filter_flag) {
int VAR_13 = get_se_golomb(gb);
int VAR_14 = get_se_golomb(gb) ;
if (VAR_13 < -6 || VAR_13 > 6 ||
VAR_14 < -6 || VAR_14 > 6) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid deblock filter offsets: %d, %d\n",
VAR_13, VAR_14);
return AVERROR_INVALIDDATA;
}
sh->beta_offset = VAR_13 * 2;
sh->tc_offset = VAR_14 * 2;
}
} else {
sh->disable_deblocking_filter_flag = VAR_0->ps.pps->disable_dbf;
sh->beta_offset = VAR_0->ps.pps->beta_offset;
sh->tc_offset = VAR_0->ps.pps->tc_offset;
}
} else {
sh->disable_deblocking_filter_flag = 0;
sh->beta_offset = 0;
sh->tc_offset = 0;
}
if (VAR_0->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
(sh->slice_sample_adaptive_offset_flag[0] ||
sh->slice_sample_adaptive_offset_flag[1] ||
!sh->disable_deblocking_filter_flag)) {
sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
} else {
sh->slice_loop_filter_across_slices_enabled_flag = VAR_0->ps.pps->seq_loop_filter_across_slices_enabled_flag;
}
} else if (!VAR_0->slice_initialized) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
return AVERROR_INVALIDDATA;
}
sh->VAR_15 = 0;
if (VAR_0->ps.pps->tiles_enabled_flag || VAR_0->ps.pps->entropy_coding_sync_enabled_flag) {
unsigned VAR_15 = get_ue_golomb_long(gb);
if (VAR_15 > get_bits_left(gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_15 %d is invalid\n", VAR_15);
return AVERROR_INVALIDDATA;
}
sh->VAR_15 = VAR_15;
if (sh->VAR_15 > 0) {
int VAR_16 = get_ue_golomb_long(gb) + 1;
if (VAR_16 < 1 || VAR_16 > 32) {
sh->VAR_15 = 0;
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_16 %d is invalid\n", VAR_16);
return AVERROR_INVALIDDATA;
}
av_freep(&sh->entry_point_offset);
av_freep(&sh->offset);
av_freep(&sh->size);
sh->entry_point_offset = av_malloc_array(sh->VAR_15, sizeof(unsigned));
sh->offset = av_malloc_array(sh->VAR_15, sizeof(int));
sh->size = av_malloc_array(sh->VAR_15, sizeof(int));
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
sh->VAR_15 = 0;
av_log(VAR_0->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
return AVERROR(ENOMEM);
}
for (VAR_1 = 0; VAR_1 < sh->VAR_15; VAR_1++) {
unsigned val = get_bits_long(gb, VAR_16);
sh->entry_point_offset[VAR_1] = val + 1;
}
if (VAR_0->threads_number > 1 && (VAR_0->ps.pps->num_tile_rows > 1 || VAR_0->ps.pps->num_tile_columns > 1)) {
VAR_0->enable_parallel_tiles = 0;
VAR_0->threads_number = 1;
} else
VAR_0->enable_parallel_tiles = 0;
} else
VAR_0->enable_parallel_tiles = 0;
}
if (VAR_0->ps.pps->slice_header_extension_present_flag) {
unsigned int VAR_17 = get_ue_golomb_long(gb);
if (VAR_17*8LL > get_bits_left(gb)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
return AVERROR_INVALIDDATA;
}
for (VAR_1 = 0; VAR_1 < VAR_17; VAR_1++)
skip_bits(gb, 8);
}
sh->slice_qp = 26U + VAR_0->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
sh->slice_qp < -VAR_0->ps.VAR_3->qp_bd_offset) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"The slice_qp %d is outside the valid range "
"[%d, 51].\n",
sh->slice_qp,
-VAR_0->ps.VAR_3->qp_bd_offset);
return AVERROR_INVALIDDATA;
}
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
if (!VAR_0->sh.slice_ctb_addr_rs && VAR_0->sh.dependent_slice_segment_flag) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
return AVERROR_INVALIDDATA;
}
if (get_bits_left(gb) < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Overread slice header by %d bits\n", -get_bits_left(gb));
return AVERROR_INVALIDDATA;
}
VAR_0->HEVClc->first_qp_group = !VAR_0->sh.dependent_slice_segment_flag;
if (!VAR_0->ps.pps->cu_qp_delta_enabled_flag)
VAR_0->HEVClc->qp_y = VAR_0->sh.slice_qp;
VAR_0->slice_initialized = 1;
VAR_0->HEVClc->tu.cu_qp_offset_cb = 0;
VAR_0->HEVClc->tu.cu_qp_offset_cr = 0;
return 0;
}
| [
"static int FUNC_0(HEVCContext *VAR_0)\n{",
"GetBitContext *gb = &VAR_0->HEVClc->gb;",
"SliceHeader *sh = &VAR_0->sh;",
"int VAR_1, VAR_2;",
"sh->first_slice_in_pic_flag = get_bits1(gb);",
"if ((IS_IDR(VAR_0) || IS_BLA(VAR_0)) && sh->first_slice_in_pic_flag) {",
"VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;",
"VAR_0->max_ra = INT_MAX;",
"if (IS_IDR(VAR_0))\nff_hevc_clear_refs(VAR_0);",
"}",
"sh->no_output_of_prior_pics_flag = 0;",
"if (IS_IRAP(VAR_0))\nsh->no_output_of_prior_pics_flag = get_bits1(gb);",
"sh->pps_id = get_ue_golomb_long(gb);",
"if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !VAR_0->ps.pps_list[sh->pps_id]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS id out of range: %d\\n\", sh->pps_id);",
"return AVERROR_INVALIDDATA;",
"}",
"if (!sh->first_slice_in_pic_flag &&\nVAR_0->ps.pps != (HEVCPPS*)VAR_0->ps.pps_list[sh->pps_id]->data) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"PPS changed between slices.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->ps.pps = (HEVCPPS*)VAR_0->ps.pps_list[sh->pps_id]->data;",
"if (VAR_0->nal_unit_type == HEVC_NAL_CRA_NUT && VAR_0->last_eos == 1)\nsh->no_output_of_prior_pics_flag = 1;",
"if (VAR_0->ps.VAR_3 != (HEVCSPS*)VAR_0->ps.sps_list[VAR_0->ps.pps->sps_id]->data) {",
"const HEVCSPS *VAR_3 = (HEVCSPS*)VAR_0->ps.sps_list[VAR_0->ps.pps->sps_id]->data;",
"const HEVCSPS *VAR_4 = VAR_0->ps.VAR_3;",
"enum AVPixelFormat VAR_5;",
"if (VAR_4 && IS_IRAP(VAR_0) && VAR_0->nal_unit_type != HEVC_NAL_CRA_NUT) {",
"if (VAR_3->width != VAR_4->width || VAR_3->height != VAR_4->height ||\nVAR_3->temporal_layer[VAR_3->max_sub_layers - 1].max_dec_pic_buffering !=\nVAR_4->temporal_layer[VAR_4->max_sub_layers - 1].max_dec_pic_buffering)\nsh->no_output_of_prior_pics_flag = 0;",
"}",
"ff_hevc_clear_refs(VAR_0);",
"VAR_5 = get_format(VAR_0, VAR_3);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_2 = set_sps(VAR_0, VAR_3, VAR_5);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"VAR_0->seq_decode = (VAR_0->seq_decode + 1) & 0xff;",
"VAR_0->max_ra = INT_MAX;",
"}",
"sh->dependent_slice_segment_flag = 0;",
"if (!sh->first_slice_in_pic_flag) {",
"int VAR_6;",
"if (VAR_0->ps.pps->dependent_slice_segments_enabled_flag)\nsh->dependent_slice_segment_flag = get_bits1(gb);",
"VAR_6 = av_ceil_log2(VAR_0->ps.VAR_3->ctb_width *\nVAR_0->ps.VAR_3->ctb_height);",
"sh->slice_segment_addr = get_bitsz(gb, VAR_6);",
"if (sh->slice_segment_addr >= VAR_0->ps.VAR_3->ctb_width * VAR_0->ps.VAR_3->ctb_height) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid slice segment address: %u.\\n\",\nsh->slice_segment_addr);",
"return AVERROR_INVALIDDATA;",
"}",
"if (!sh->dependent_slice_segment_flag) {",
"sh->slice_addr = sh->slice_segment_addr;",
"VAR_0->slice_idx++;",
"}",
"} else {",
"sh->slice_segment_addr = sh->slice_addr = 0;",
"VAR_0->slice_idx = 0;",
"VAR_0->slice_initialized = 0;",
"}",
"if (!sh->dependent_slice_segment_flag) {",
"VAR_0->slice_initialized = 0;",
"for (VAR_1 = 0; VAR_1 < VAR_0->ps.pps->num_extra_slice_header_bits; VAR_1++)",
"skip_bits(gb, 1);",
"sh->slice_type = get_ue_golomb_long(gb);",
"if (!(sh->slice_type == HEVC_SLICE_I ||\nsh->slice_type == HEVC_SLICE_P ||\nsh->slice_type == HEVC_SLICE_B)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown slice type: %d.\\n\",\nsh->slice_type);",
"return AVERROR_INVALIDDATA;",
"}",
"if (IS_IRAP(VAR_0) && sh->slice_type != HEVC_SLICE_I) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Inter slices in an IRAP frame.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"sh->pic_output_flag = 1;",
"if (VAR_0->ps.pps->output_flag_present_flag)\nsh->pic_output_flag = get_bits1(gb);",
"if (VAR_0->ps.VAR_3->separate_colour_plane_flag)\nsh->colour_plane_id = get_bits(gb, 2);",
"if (!IS_IDR(VAR_0)) {",
"int VAR_7, VAR_8;",
"sh->pic_order_cnt_lsb = get_bits(gb, VAR_0->ps.VAR_3->log2_max_poc_lsb);",
"VAR_7 = ff_hevc_compute_poc(VAR_0->ps.VAR_3, VAR_0->pocTid0, sh->pic_order_cnt_lsb, VAR_0->nal_unit_type);",
"if (!sh->first_slice_in_pic_flag && VAR_7 != VAR_0->VAR_7) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING,\n\"Ignoring POC change between slices: %d -> %d\\n\", VAR_0->VAR_7, VAR_7);",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"VAR_7 = VAR_0->VAR_7;",
"}",
"VAR_0->VAR_7 = VAR_7;",
"sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);",
"VAR_8 = get_bits_left(gb);",
"if (!sh->short_term_ref_pic_set_sps_flag) {",
"VAR_2 = ff_hevc_decode_short_term_rps(gb, VAR_0->avctx, &sh->slice_rps, VAR_0->ps.VAR_3, 1);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"sh->short_term_rps = &sh->slice_rps;",
"} else {",
"int VAR_9, VAR_10;",
"if (!VAR_0->ps.VAR_3->nb_st_rps) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"No ref lists in the SPS.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = av_ceil_log2(VAR_0->ps.VAR_3->nb_st_rps);",
"VAR_10 = VAR_9 > 0 ? get_bits(gb, VAR_9) : 0;",
"sh->short_term_rps = &VAR_0->ps.VAR_3->st_rps[VAR_10];",
"}",
"sh->short_term_ref_pic_set_size = VAR_8 - get_bits_left(gb);",
"VAR_8 = get_bits_left(gb);",
"VAR_2 = decode_lt_rps(VAR_0, &sh->long_term_rps, gb);",
"if (VAR_2 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_WARNING, \"Invalid long term RPS.\\n\");",
"if (VAR_0->avctx->err_recognition & AV_EF_EXPLODE)\nreturn AVERROR_INVALIDDATA;",
"}",
"sh->long_term_ref_pic_set_size = VAR_8 - get_bits_left(gb);",
"if (VAR_0->ps.VAR_3->sps_temporal_mvp_enabled_flag)\nsh->slice_temporal_mvp_enabled_flag = get_bits1(gb);",
"else\nsh->slice_temporal_mvp_enabled_flag = 0;",
"} else {",
"VAR_0->sh.short_term_rps = NULL;",
"VAR_0->VAR_7 = 0;",
"}",
"if (sh->first_slice_in_pic_flag && VAR_0->temporal_id == 0 &&\nVAR_0->nal_unit_type != HEVC_NAL_TRAIL_N &&\nVAR_0->nal_unit_type != HEVC_NAL_TSA_N &&\nVAR_0->nal_unit_type != HEVC_NAL_STSA_N &&\nVAR_0->nal_unit_type != HEVC_NAL_RADL_N &&\nVAR_0->nal_unit_type != HEVC_NAL_RADL_R &&\nVAR_0->nal_unit_type != HEVC_NAL_RASL_N &&\nVAR_0->nal_unit_type != HEVC_NAL_RASL_R)\nVAR_0->pocTid0 = VAR_0->VAR_7;",
"if (VAR_0->ps.VAR_3->sao_enabled) {",
"sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);",
"if (VAR_0->ps.VAR_3->chroma_format_idc) {",
"sh->slice_sample_adaptive_offset_flag[1] =\nsh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);",
"}",
"} else {",
"sh->slice_sample_adaptive_offset_flag[0] = 0;",
"sh->slice_sample_adaptive_offset_flag[1] = 0;",
"sh->slice_sample_adaptive_offset_flag[2] = 0;",
"}",
"sh->VAR_11[L0] = sh->VAR_11[L1] = 0;",
"if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {",
"int VAR_11;",
"sh->VAR_11[L0] = VAR_0->ps.pps->num_ref_idx_l0_default_active;",
"if (sh->slice_type == HEVC_SLICE_B)\nsh->VAR_11[L1] = VAR_0->ps.pps->num_ref_idx_l1_default_active;",
"if (get_bits1(gb)) {",
"sh->VAR_11[L0] = get_ue_golomb_long(gb) + 1;",
"if (sh->slice_type == HEVC_SLICE_B)\nsh->VAR_11[L1] = get_ue_golomb_long(gb) + 1;",
"}",
"if (sh->VAR_11[L0] > HEVC_MAX_REFS || sh->VAR_11[L1] > HEVC_MAX_REFS) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Too many refs: %d/%d.\\n\",\nsh->VAR_11[L0], sh->VAR_11[L1]);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->rpl_modification_flag[0] = 0;",
"sh->rpl_modification_flag[1] = 0;",
"VAR_11 = ff_hevc_frame_nb_refs(VAR_0);",
"if (!VAR_11) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Zero refs for a frame with P or B slices.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_0->ps.pps->lists_modification_present_flag && VAR_11 > 1) {",
"sh->rpl_modification_flag[0] = get_bits1(gb);",
"if (sh->rpl_modification_flag[0]) {",
"for (VAR_1 = 0; VAR_1 < sh->VAR_11[L0]; VAR_1++)",
"sh->list_entry_lx[0][VAR_1] = get_bits(gb, av_ceil_log2(VAR_11));",
"}",
"if (sh->slice_type == HEVC_SLICE_B) {",
"sh->rpl_modification_flag[1] = get_bits1(gb);",
"if (sh->rpl_modification_flag[1] == 1)\nfor (VAR_1 = 0; VAR_1 < sh->VAR_11[L1]; VAR_1++)",
"sh->list_entry_lx[1][VAR_1] = get_bits(gb, av_ceil_log2(VAR_11));",
"}",
"}",
"if (sh->slice_type == HEVC_SLICE_B)\nsh->mvd_l1_zero_flag = get_bits1(gb);",
"if (VAR_0->ps.pps->cabac_init_present_flag)\nsh->cabac_init_flag = get_bits1(gb);",
"else\nsh->cabac_init_flag = 0;",
"sh->collocated_ref_idx = 0;",
"if (sh->slice_temporal_mvp_enabled_flag) {",
"sh->collocated_list = L0;",
"if (sh->slice_type == HEVC_SLICE_B)\nsh->collocated_list = !get_bits1(gb);",
"if (sh->VAR_11[sh->collocated_list] > 1) {",
"sh->collocated_ref_idx = get_ue_golomb_long(gb);",
"if (sh->collocated_ref_idx >= sh->VAR_11[sh->collocated_list]) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid collocated_ref_idx: %d.\\n\",\nsh->collocated_ref_idx);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"if ((VAR_0->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||\n(VAR_0->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {",
"pred_weight_table(VAR_0, gb);",
"}",
"sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);",
"if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid number of merging MVP candidates: %d.\\n\",\nsh->max_num_merge_cand);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"sh->slice_qp_delta = get_se_golomb(gb);",
"if (VAR_0->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {",
"sh->slice_cb_qp_offset = get_se_golomb(gb);",
"sh->slice_cr_qp_offset = get_se_golomb(gb);",
"} else {",
"sh->slice_cb_qp_offset = 0;",
"sh->slice_cr_qp_offset = 0;",
"}",
"if (VAR_0->ps.pps->chroma_qp_offset_list_enabled_flag)\nsh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);",
"else\nsh->cu_chroma_qp_offset_enabled_flag = 0;",
"if (VAR_0->ps.pps->deblocking_filter_control_present_flag) {",
"int VAR_12 = 0;",
"if (VAR_0->ps.pps->deblocking_filter_override_enabled_flag)\nVAR_12 = get_bits1(gb);",
"if (VAR_12) {",
"sh->disable_deblocking_filter_flag = get_bits1(gb);",
"if (!sh->disable_deblocking_filter_flag) {",
"int VAR_13 = get_se_golomb(gb);",
"int VAR_14 = get_se_golomb(gb) ;",
"if (VAR_13 < -6 || VAR_13 > 6 ||\nVAR_14 < -6 || VAR_14 > 6) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid deblock filter offsets: %d, %d\\n\",\nVAR_13, VAR_14);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->beta_offset = VAR_13 * 2;",
"sh->tc_offset = VAR_14 * 2;",
"}",
"} else {",
"sh->disable_deblocking_filter_flag = VAR_0->ps.pps->disable_dbf;",
"sh->beta_offset = VAR_0->ps.pps->beta_offset;",
"sh->tc_offset = VAR_0->ps.pps->tc_offset;",
"}",
"} else {",
"sh->disable_deblocking_filter_flag = 0;",
"sh->beta_offset = 0;",
"sh->tc_offset = 0;",
"}",
"if (VAR_0->ps.pps->seq_loop_filter_across_slices_enabled_flag &&\n(sh->slice_sample_adaptive_offset_flag[0] ||\nsh->slice_sample_adaptive_offset_flag[1] ||\n!sh->disable_deblocking_filter_flag)) {",
"sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);",
"} else {",
"sh->slice_loop_filter_across_slices_enabled_flag = VAR_0->ps.pps->seq_loop_filter_across_slices_enabled_flag;",
"}",
"} else if (!VAR_0->slice_initialized) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Independent slice segment missing.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"sh->VAR_15 = 0;",
"if (VAR_0->ps.pps->tiles_enabled_flag || VAR_0->ps.pps->entropy_coding_sync_enabled_flag) {",
"unsigned VAR_15 = get_ue_golomb_long(gb);",
"if (VAR_15 > get_bits_left(gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_15 %d is invalid\\n\", VAR_15);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->VAR_15 = VAR_15;",
"if (sh->VAR_15 > 0) {",
"int VAR_16 = get_ue_golomb_long(gb) + 1;",
"if (VAR_16 < 1 || VAR_16 > 32) {",
"sh->VAR_15 = 0;",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"VAR_16 %d is invalid\\n\", VAR_16);",
"return AVERROR_INVALIDDATA;",
"}",
"av_freep(&sh->entry_point_offset);",
"av_freep(&sh->offset);",
"av_freep(&sh->size);",
"sh->entry_point_offset = av_malloc_array(sh->VAR_15, sizeof(unsigned));",
"sh->offset = av_malloc_array(sh->VAR_15, sizeof(int));",
"sh->size = av_malloc_array(sh->VAR_15, sizeof(int));",
"if (!sh->entry_point_offset || !sh->offset || !sh->size) {",
"sh->VAR_15 = 0;",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Failed to allocate memory\\n\");",
"return AVERROR(ENOMEM);",
"}",
"for (VAR_1 = 0; VAR_1 < sh->VAR_15; VAR_1++) {",
"unsigned val = get_bits_long(gb, VAR_16);",
"sh->entry_point_offset[VAR_1] = val + 1;",
"}",
"if (VAR_0->threads_number > 1 && (VAR_0->ps.pps->num_tile_rows > 1 || VAR_0->ps.pps->num_tile_columns > 1)) {",
"VAR_0->enable_parallel_tiles = 0;",
"VAR_0->threads_number = 1;",
"} else",
"VAR_0->enable_parallel_tiles = 0;",
"} else",
"VAR_0->enable_parallel_tiles = 0;",
"}",
"if (VAR_0->ps.pps->slice_header_extension_present_flag) {",
"unsigned int VAR_17 = get_ue_golomb_long(gb);",
"if (VAR_17*8LL > get_bits_left(gb)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"too many slice_header_extension_data_bytes\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"for (VAR_1 = 0; VAR_1 < VAR_17; VAR_1++)",
"skip_bits(gb, 8);",
"}",
"sh->slice_qp = 26U + VAR_0->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;",
"if (sh->slice_qp > 51 ||\nsh->slice_qp < -VAR_0->ps.VAR_3->qp_bd_offset) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"The slice_qp %d is outside the valid range \"\n\"[%d, 51].\\n\",\nsh->slice_qp,\n-VAR_0->ps.VAR_3->qp_bd_offset);",
"return AVERROR_INVALIDDATA;",
"}",
"sh->slice_ctb_addr_rs = sh->slice_segment_addr;",
"if (!VAR_0->sh.slice_ctb_addr_rs && VAR_0->sh.dependent_slice_segment_flag) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Impossible slice segment.\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (get_bits_left(gb) < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Overread slice header by %d bits\\n\", -get_bits_left(gb));",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->HEVClc->first_qp_group = !VAR_0->sh.dependent_slice_segment_flag;",
"if (!VAR_0->ps.pps->cu_qp_delta_enabled_flag)\nVAR_0->HEVClc->qp_y = VAR_0->sh.slice_qp;",
"VAR_0->slice_initialized = 1;",
"VAR_0->HEVClc->tu.cu_qp_offset_cb = 0;",
"VAR_0->HEVClc->tu.cu_qp_offset_cr = 0;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
31,
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77,
79,
81,
83
],
[
85
],
[
87
],
[
91
],
[
93,
95
],
[
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
129,
131
],
[
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
175
],
[
177
],
[
181
],
[
183,
185,
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
209
],
[
211,
213
],
[
217,
219
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259,
261
],
[
265
],
[
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
313,
315
],
[
317,
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
333,
335,
337,
339,
341,
343,
345,
347,
349
],
[
353
],
[
355
],
[
357
],
[
359,
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
377
],
[
379
],
[
381
],
[
385
],
[
387,
389
],
[
393
],
[
395
],
[
397,
399
],
[
401
],
[
403
],
[
405,
407
],
[
409
],
[
411
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
445
],
[
447
],
[
449,
451
],
[
453
],
[
455
],
[
457
],
[
461,
463
],
[
467,
469
],
[
471,
473
],
[
477
],
[
479
],
[
481
],
[
483,
485
],
[
489
],
[
491
],
[
493
],
[
495,
497,
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
511,
513
],
[
515
],
[
517
],
[
521
],
[
523
],
[
525,
527,
529
],
[
531
],
[
533
],
[
535
],
[
539
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553
],
[
555
],
[
559,
561
],
[
563,
565
],
[
569
],
[
571
],
[
575,
577
],
[
581
],
[
583
],
[
585
],
[
587
],
[
589
],
[
591,
593
],
[
595,
597,
599
],
[
601
],
[
603
],
[
605
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617
],
[
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
633,
635,
637,
639
],
[
641
],
[
643
],
[
645
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
659
],
[
661
],
[
663
],
[
667
],
[
669
],
[
671
],
[
673
],
[
677
],
[
679
],
[
681
],
[
685
],
[
687
],
[
689
],
[
691
],
[
693
],
[
697
],
[
699
],
[
701
],
[
703
],
[
705
],
[
707
],
[
709
],
[
711
],
[
713
],
[
715
],
[
717
],
[
719
],
[
721
],
[
723
],
[
725
],
[
727
],
[
729
],
[
731
],
[
733
],
[
735
],
[
737
],
[
739
],
[
741
],
[
745
],
[
747
],
[
749
],
[
751
],
[
753
],
[
755
],
[
757
],
[
759
],
[
761
],
[
767
],
[
769,
771
],
[
773,
775,
777,
779,
781
],
[
783
],
[
785
],
[
789
],
[
793
],
[
795
],
[
797
],
[
799
],
[
803
],
[
805,
807
],
[
809
],
[
811
],
[
815
],
[
819,
821
],
[
825
],
[
827
],
[
829
],
[
833
],
[
835
]
]
|
14,626 | static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
{
BusState *bus = opaque;
DeviceState *qdev, *next;
PCIDevice *dev;
int slot = ffs(val) - 1;
QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
dev = DO_UPCAST(PCIDevice, qdev, qdev);
if (PCI_SLOT(dev->devfn) == slot) {
qdev_free(qdev);
}
}
PIIX4_DPRINTF("pciej write %x <== %d\n", addr, val);
}
| true | qemu | 505597e4476a6bc219d0ec1362b760d71cb4fdca | static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
{
BusState *bus = opaque;
DeviceState *qdev, *next;
PCIDevice *dev;
int slot = ffs(val) - 1;
QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
dev = DO_UPCAST(PCIDevice, qdev, qdev);
if (PCI_SLOT(dev->devfn) == slot) {
qdev_free(qdev);
}
}
PIIX4_DPRINTF("pciej write %x <== %d\n", addr, val);
}
| {
"code": [
" if (PCI_SLOT(dev->devfn) == slot) {"
],
"line_no": [
19
]
} | static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)
{
BusState *bus = VAR_0;
DeviceState *qdev, *next;
PCIDevice *dev;
int VAR_3 = ffs(VAR_2) - 1;
QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
dev = DO_UPCAST(PCIDevice, qdev, qdev);
if (PCI_SLOT(dev->devfn) == VAR_3) {
qdev_free(qdev);
}
}
PIIX4_DPRINTF("pciej write %x <== %d\n", VAR_1, VAR_2);
}
| [
"static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{",
"BusState *bus = VAR_0;",
"DeviceState *qdev, *next;",
"PCIDevice *dev;",
"int VAR_3 = ffs(VAR_2) - 1;",
"QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {",
"dev = DO_UPCAST(PCIDevice, qdev, qdev);",
"if (PCI_SLOT(dev->devfn) == VAR_3) {",
"qdev_free(qdev);",
"}",
"}",
"PIIX4_DPRINTF(\"pciej write %x <== %d\\n\", VAR_1, VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
31
],
[
33
]
]
|
14,627 | void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
{
DeviceState *qdev = DEVICE(vdev);
BusState *qbus = BUS(qdev_get_parent_bus(qdev));
VirtioBusState *bus = VIRTIO_BUS(qbus);
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
DPRINTF("%s: plug device.\n", qbus->name);
if (klass->pre_plugged != NULL) {
klass->pre_plugged(qbus->parent, errp);
}
/* Get the features of the plugged device. */
assert(vdc->get_features != NULL);
vdev->host_features = vdc->get_features(vdev, vdev->host_features,
errp);
if (klass->device_plugged != NULL) {
klass->device_plugged(qbus->parent, errp);
}
if (klass->get_dma_as != NULL && has_iommu) {
virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
vdev->dma_as = klass->get_dma_as(qbus->parent);
} else {
vdev->dma_as = &address_space_memory;
}
}
| true | qemu | a77690c41da67d85bab1e784a9f24f18bc63dbd9 | void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
{
DeviceState *qdev = DEVICE(vdev);
BusState *qbus = BUS(qdev_get_parent_bus(qdev));
VirtioBusState *bus = VIRTIO_BUS(qbus);
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
DPRINTF("%s: plug device.\n", qbus->name);
if (klass->pre_plugged != NULL) {
klass->pre_plugged(qbus->parent, errp);
}
assert(vdc->get_features != NULL);
vdev->host_features = vdc->get_features(vdev, vdev->host_features,
errp);
if (klass->device_plugged != NULL) {
klass->device_plugged(qbus->parent, errp);
}
if (klass->get_dma_as != NULL && has_iommu) {
virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
vdev->dma_as = klass->get_dma_as(qbus->parent);
} else {
vdev->dma_as = &address_space_memory;
}
}
| {
"code": [
" klass->pre_plugged(qbus->parent, errp);",
" errp);",
" klass->device_plugged(qbus->parent, errp);"
],
"line_no": [
25,
37,
43
]
} | void FUNC_0(VirtIODevice *VAR_0, Error **VAR_1)
{
DeviceState *qdev = DEVICE(VAR_0);
BusState *qbus = BUS(qdev_get_parent_bus(qdev));
VirtioBusState *bus = VIRTIO_BUS(qbus);
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0);
bool has_iommu = virtio_host_has_feature(VAR_0, VIRTIO_F_IOMMU_PLATFORM);
DPRINTF("%s: plug device.\n", qbus->name);
if (klass->pre_plugged != NULL) {
klass->pre_plugged(qbus->parent, VAR_1);
}
assert(vdc->get_features != NULL);
VAR_0->host_features = vdc->get_features(VAR_0, VAR_0->host_features,
VAR_1);
if (klass->device_plugged != NULL) {
klass->device_plugged(qbus->parent, VAR_1);
}
if (klass->get_dma_as != NULL && has_iommu) {
virtio_add_feature(&VAR_0->host_features, VIRTIO_F_IOMMU_PLATFORM);
VAR_0->dma_as = klass->get_dma_as(qbus->parent);
} else {
VAR_0->dma_as = &address_space_memory;
}
}
| [
"void FUNC_0(VirtIODevice *VAR_0, Error **VAR_1)\n{",
"DeviceState *qdev = DEVICE(VAR_0);",
"BusState *qbus = BUS(qdev_get_parent_bus(qdev));",
"VirtioBusState *bus = VIRTIO_BUS(qbus);",
"VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);",
"VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(VAR_0);",
"bool has_iommu = virtio_host_has_feature(VAR_0, VIRTIO_F_IOMMU_PLATFORM);",
"DPRINTF(\"%s: plug device.\\n\", qbus->name);",
"if (klass->pre_plugged != NULL) {",
"klass->pre_plugged(qbus->parent, VAR_1);",
"}",
"assert(vdc->get_features != NULL);",
"VAR_0->host_features = vdc->get_features(VAR_0, VAR_0->host_features,\nVAR_1);",
"if (klass->device_plugged != NULL) {",
"klass->device_plugged(qbus->parent, VAR_1);",
"}",
"if (klass->get_dma_as != NULL && has_iommu) {",
"virtio_add_feature(&VAR_0->host_features, VIRTIO_F_IOMMU_PLATFORM);",
"VAR_0->dma_as = klass->get_dma_as(qbus->parent);",
"} else {",
"VAR_0->dma_as = &address_space_memory;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35,
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
]
|
14,628 | static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int i;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le16_to_cpu(val);
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le32_to_cpu(val);
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le64_to_cpu(val);
break;
}
case 'v': {
struct iovec *iov = va_arg(ap, struct iovec *);
int *iovcnt = va_arg(ap, int *);
*iovcnt = pdu_copy_sg(pdu, offset, 0, iov);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_unmarshal(pdu, offset, "w", &str->size);
/* FIXME: sanity check str->size */
str->data = g_malloc(str->size + 1);
offset += pdu_unpack(str->data, pdu, offset, str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += pdu_unmarshal(pdu, offset, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += pdu_unmarshal(pdu, offset, "wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += pdu_unmarshal(pdu, offset, "ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| true | qemu | 302a0d3ed721e4c30c6a2a37f64c60b50ffd33b9 | static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int i;
va_start(ap, fmt);
for (i = 0; fmt[i]; i++) {
switch (fmt[i]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le16_to_cpu(val);
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le32_to_cpu(val);
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le64_to_cpu(val);
break;
}
case 'v': {
struct iovec *iov = va_arg(ap, struct iovec *);
int *iovcnt = va_arg(ap, int *);
*iovcnt = pdu_copy_sg(pdu, offset, 0, iov);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += pdu_unmarshal(pdu, offset, "w", &str->size);
str->data = g_malloc(str->size + 1);
offset += pdu_unpack(str->data, pdu, offset, str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += pdu_unmarshal(pdu, offset, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += pdu_unmarshal(pdu, offset, "wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += pdu_unmarshal(pdu, offset, "ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| {
"code": [
" case 'v': {",
" struct iovec *iov = va_arg(ap, struct iovec *);",
" int *iovcnt = va_arg(ap, int *);",
" *iovcnt = pdu_copy_sg(pdu, offset, 0, iov);",
" break;",
" case 'v': {",
" struct iovec *iov = va_arg(ap, struct iovec *);",
" int *iovcnt = va_arg(ap, int *);",
" break;",
" int i;",
" break;"
],
"line_no": [
71,
73,
75,
77,
25,
71,
73,
75,
25,
9,
25
]
} | static size_t FUNC_0(V9fsPDU *pdu, size_t offset, const char *fmt, ...)
{
size_t old_offset = offset;
va_list ap;
int VAR_0;
va_start(ap, fmt);
for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {
switch (fmt[VAR_0]) {
case 'b': {
uint8_t *valp = va_arg(ap, uint8_t *);
offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
break;
}
case 'w': {
uint16_t val, *valp;
valp = va_arg(ap, uint16_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le16_to_cpu(val);
break;
}
case 'd': {
uint32_t val, *valp;
valp = va_arg(ap, uint32_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le32_to_cpu(val);
break;
}
case 'q': {
uint64_t val, *valp;
valp = va_arg(ap, uint64_t *);
offset += pdu_unpack(&val, pdu, offset, sizeof(val));
*valp = le64_to_cpu(val);
break;
}
case 'v': {
struct iovec *VAR_1 = va_arg(ap, struct iovec *);
int *VAR_2 = va_arg(ap, int *);
*VAR_2 = pdu_copy_sg(pdu, offset, 0, VAR_1);
break;
}
case 's': {
V9fsString *str = va_arg(ap, V9fsString *);
offset += FUNC_0(pdu, offset, "w", &str->size);
str->data = g_malloc(str->size + 1);
offset += pdu_unpack(str->data, pdu, offset, str->size);
str->data[str->size] = 0;
break;
}
case 'Q': {
V9fsQID *qidp = va_arg(ap, V9fsQID *);
offset += FUNC_0(pdu, offset, "bdq",
&qidp->type, &qidp->version, &qidp->path);
break;
}
case 'S': {
V9fsStat *statp = va_arg(ap, V9fsStat *);
offset += FUNC_0(pdu, offset, "wwdQdddqsssssddd",
&statp->size, &statp->type, &statp->dev,
&statp->qid, &statp->mode, &statp->atime,
&statp->mtime, &statp->length,
&statp->name, &statp->uid, &statp->gid,
&statp->muid, &statp->extension,
&statp->n_uid, &statp->n_gid,
&statp->n_muid);
break;
}
case 'I': {
V9fsIattr *iattr = va_arg(ap, V9fsIattr *);
offset += FUNC_0(pdu, offset, "ddddqqqqq",
&iattr->valid, &iattr->mode,
&iattr->uid, &iattr->gid, &iattr->size,
&iattr->atime_sec, &iattr->atime_nsec,
&iattr->mtime_sec, &iattr->mtime_nsec);
break;
}
default:
break;
}
}
va_end(ap);
return offset - old_offset;
}
| [
"static size_t FUNC_0(V9fsPDU *pdu, size_t offset, const char *fmt, ...)\n{",
"size_t old_offset = offset;",
"va_list ap;",
"int VAR_0;",
"va_start(ap, fmt);",
"for (VAR_0 = 0; fmt[VAR_0]; VAR_0++) {",
"switch (fmt[VAR_0]) {",
"case 'b': {",
"uint8_t *valp = va_arg(ap, uint8_t *);",
"offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));",
"break;",
"}",
"case 'w': {",
"uint16_t val, *valp;",
"valp = va_arg(ap, uint16_t *);",
"offset += pdu_unpack(&val, pdu, offset, sizeof(val));",
"*valp = le16_to_cpu(val);",
"break;",
"}",
"case 'd': {",
"uint32_t val, *valp;",
"valp = va_arg(ap, uint32_t *);",
"offset += pdu_unpack(&val, pdu, offset, sizeof(val));",
"*valp = le32_to_cpu(val);",
"break;",
"}",
"case 'q': {",
"uint64_t val, *valp;",
"valp = va_arg(ap, uint64_t *);",
"offset += pdu_unpack(&val, pdu, offset, sizeof(val));",
"*valp = le64_to_cpu(val);",
"break;",
"}",
"case 'v': {",
"struct iovec *VAR_1 = va_arg(ap, struct iovec *);",
"int *VAR_2 = va_arg(ap, int *);",
"*VAR_2 = pdu_copy_sg(pdu, offset, 0, VAR_1);",
"break;",
"}",
"case 's': {",
"V9fsString *str = va_arg(ap, V9fsString *);",
"offset += FUNC_0(pdu, offset, \"w\", &str->size);",
"str->data = g_malloc(str->size + 1);",
"offset += pdu_unpack(str->data, pdu, offset, str->size);",
"str->data[str->size] = 0;",
"break;",
"}",
"case 'Q': {",
"V9fsQID *qidp = va_arg(ap, V9fsQID *);",
"offset += FUNC_0(pdu, offset, \"bdq\",\n&qidp->type, &qidp->version, &qidp->path);",
"break;",
"}",
"case 'S': {",
"V9fsStat *statp = va_arg(ap, V9fsStat *);",
"offset += FUNC_0(pdu, offset, \"wwdQdddqsssssddd\",\n&statp->size, &statp->type, &statp->dev,\n&statp->qid, &statp->mode, &statp->atime,\n&statp->mtime, &statp->length,\n&statp->name, &statp->uid, &statp->gid,\n&statp->muid, &statp->extension,\n&statp->n_uid, &statp->n_gid,\n&statp->n_muid);",
"break;",
"}",
"case 'I': {",
"V9fsIattr *iattr = va_arg(ap, V9fsIattr *);",
"offset += FUNC_0(pdu, offset, \"ddddqqqqq\",\n&iattr->valid, &iattr->mode,\n&iattr->uid, &iattr->gid, &iattr->size,\n&iattr->atime_sec, &iattr->atime_nsec,\n&iattr->mtime_sec, &iattr->mtime_nsec);",
"break;",
"}",
"default:\nbreak;",
"}",
"}",
"va_end(ap);",
"return offset - old_offset;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
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
],
[
165
],
[
169
],
[
171
]
]
|
14,629 | void unix_start_incoming_migration(const char *path, Error **errp)
{
int s;
s = unix_listen(path, NULL, 0, errp);
if (s < 0) {
return;
}
qemu_set_fd_handler2(s, NULL, unix_accept_incoming_migration, NULL,
(void *)(intptr_t)s);
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | void unix_start_incoming_migration(const char *path, Error **errp)
{
int s;
s = unix_listen(path, NULL, 0, errp);
if (s < 0) {
return;
}
qemu_set_fd_handler2(s, NULL, unix_accept_incoming_migration, NULL,
(void *)(intptr_t)s);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, Error **VAR_1)
{
int VAR_2;
VAR_2 = unix_listen(VAR_0, NULL, 0, VAR_1);
if (VAR_2 < 0) {
return;
}
qemu_set_fd_handler2(VAR_2, NULL, unix_accept_incoming_migration, NULL,
(void *)(intptr_t)VAR_2);
}
| [
"void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"int VAR_2;",
"VAR_2 = unix_listen(VAR_0, NULL, 0, VAR_1);",
"if (VAR_2 < 0) {",
"return;",
"}",
"qemu_set_fd_handler2(VAR_2, NULL, unix_accept_incoming_migration, NULL,\n(void *)(intptr_t)VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
23
]
]
|
14,631 | static inline int draw_glyph_rgb(AVFilterBufferRef *picref, FT_Bitmap *bitmap,
unsigned int x, unsigned int y,
unsigned int width, unsigned int height, int pixel_step,
const uint8_t rgba_color[4], const uint8_t rgba_map[4])
{
int r, c, alpha;
uint8_t *p;
uint8_t src_val;
for (r = 0; r < bitmap->rows && r+y < height; r++) {
for (c = 0; c < bitmap->width && c+x < width; c++) {
/* get intensity value in the glyph bitmap (source) */
src_val = GET_BITMAP_VAL(r, c);
if (!src_val)
continue;
SET_PIXEL_RGB(picref, rgba_color, src_val, c+x, y+r, pixel_step,
rgba_map[0], rgba_map[1], rgba_map[2], rgba_map[3]);
}
}
return 0;
}
| true | FFmpeg | db56a7507ee7c1e095d2eef451d5a487f614edff | static inline int draw_glyph_rgb(AVFilterBufferRef *picref, FT_Bitmap *bitmap,
unsigned int x, unsigned int y,
unsigned int width, unsigned int height, int pixel_step,
const uint8_t rgba_color[4], const uint8_t rgba_map[4])
{
int r, c, alpha;
uint8_t *p;
uint8_t src_val;
for (r = 0; r < bitmap->rows && r+y < height; r++) {
for (c = 0; c < bitmap->width && c+x < width; c++) {
src_val = GET_BITMAP_VAL(r, c);
if (!src_val)
continue;
SET_PIXEL_RGB(picref, rgba_color, src_val, c+x, y+r, pixel_step,
rgba_map[0], rgba_map[1], rgba_map[2], rgba_map[3]);
}
}
return 0;
}
| {
"code": [
" unsigned int x, unsigned int y,",
" unsigned int width, unsigned int height, int pixel_step,"
],
"line_no": [
3,
5
]
} | static inline int FUNC_0(AVFilterBufferRef *VAR_0, FT_Bitmap *VAR_1,
unsigned int VAR_2, unsigned int VAR_3,
unsigned int VAR_4, unsigned int VAR_5, int VAR_6,
const uint8_t VAR_7[4], const uint8_t VAR_8[4])
{
int VAR_9, VAR_10, VAR_11;
uint8_t *p;
uint8_t src_val;
for (VAR_9 = 0; VAR_9 < VAR_1->rows && VAR_9+VAR_3 < VAR_5; VAR_9++) {
for (VAR_10 = 0; VAR_10 < VAR_1->VAR_4 && VAR_10+VAR_2 < VAR_4; VAR_10++) {
src_val = GET_BITMAP_VAL(VAR_9, VAR_10);
if (!src_val)
continue;
SET_PIXEL_RGB(VAR_0, VAR_7, src_val, VAR_10+VAR_2, VAR_3+VAR_9, VAR_6,
VAR_8[0], VAR_8[1], VAR_8[2], VAR_8[3]);
}
}
return 0;
}
| [
"static inline int FUNC_0(AVFilterBufferRef *VAR_0, FT_Bitmap *VAR_1,\nunsigned int VAR_2, unsigned int VAR_3,\nunsigned int VAR_4, unsigned int VAR_5, int VAR_6,\nconst uint8_t VAR_7[4], const uint8_t VAR_8[4])\n{",
"int VAR_9, VAR_10, VAR_11;",
"uint8_t *p;",
"uint8_t src_val;",
"for (VAR_9 = 0; VAR_9 < VAR_1->rows && VAR_9+VAR_3 < VAR_5; VAR_9++) {",
"for (VAR_10 = 0; VAR_10 < VAR_1->VAR_4 && VAR_10+VAR_2 < VAR_4; VAR_10++) {",
"src_val = GET_BITMAP_VAL(VAR_9, VAR_10);",
"if (!src_val)\ncontinue;",
"SET_PIXEL_RGB(VAR_0, VAR_7, src_val, VAR_10+VAR_2, VAR_3+VAR_9, VAR_6,\nVAR_8[0], VAR_8[1], VAR_8[2], VAR_8[3]);",
"}",
"}",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
33,
35
],
[
37
],
[
39
],
[
43
],
[
45
]
]
|
14,632 | static void apply_unsharp( uint8_t *dst, int dst_stride,
const uint8_t *src, int src_stride,
int width, int height, FilterParam *fp)
{
uint32_t **sc = fp->sc;
uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;
int32_t res;
int x, y, z;
const uint8_t *src2;
if (!fp->amount) {
if (dst_stride == src_stride)
memcpy(dst, src, src_stride * height);
else
for (y = 0; y < height; y++, dst += dst_stride, src += src_stride)
memcpy(dst, src, width);
return;
}
for (y = 0; y < 2 * fp->steps_y; y++)
memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x));
for (y = -fp->steps_y; y < height + fp->steps_y; y++) {
if (y < height)
src2 = src;
memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1));
for (x = -fp->steps_x; x < width + fp->steps_x; x++) {
tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
for (z = 0; z < fp->steps_x * 2; z += 2) {
tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
}
for (z = 0; z < fp->steps_y * 2; z += 2) {
tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1;
tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;
}
if (x >= fp->steps_x && y >= fp->steps_y) {
const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x;
uint8_t *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;
res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);
*dsx = av_clip_uint8(res);
}
}
if (y >= 0) {
dst += dst_stride;
src += src_stride;
}
}
}
| true | FFmpeg | cb3034e0d16e753b93dd1d879044399e45e82bf7 | static void apply_unsharp( uint8_t *dst, int dst_stride,
const uint8_t *src, int src_stride,
int width, int height, FilterParam *fp)
{
uint32_t **sc = fp->sc;
uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;
int32_t res;
int x, y, z;
const uint8_t *src2;
if (!fp->amount) {
if (dst_stride == src_stride)
memcpy(dst, src, src_stride * height);
else
for (y = 0; y < height; y++, dst += dst_stride, src += src_stride)
memcpy(dst, src, width);
return;
}
for (y = 0; y < 2 * fp->steps_y; y++)
memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x));
for (y = -fp->steps_y; y < height + fp->steps_y; y++) {
if (y < height)
src2 = src;
memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1));
for (x = -fp->steps_x; x < width + fp->steps_x; x++) {
tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
for (z = 0; z < fp->steps_x * 2; z += 2) {
tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;
}
for (z = 0; z < fp->steps_y * 2; z += 2) {
tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1;
tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;
}
if (x >= fp->steps_x && y >= fp->steps_y) {
const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x;
uint8_t *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;
res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);
*dsx = av_clip_uint8(res);
}
}
if (y >= 0) {
dst += dst_stride;
src += src_stride;
}
}
}
| {
"code": [
" const uint8_t *src2;"
],
"line_no": [
19
]
} | static void FUNC_0( uint8_t *VAR_0, int VAR_1,
const uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5, FilterParam *VAR_6)
{
uint32_t **sc = VAR_6->sc;
uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;
int32_t res;
int VAR_7, VAR_8, VAR_9;
const uint8_t *VAR_10;
if (!VAR_6->amount) {
if (VAR_1 == VAR_3)
memcpy(VAR_0, VAR_2, VAR_3 * VAR_5);
else
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++, VAR_0 += VAR_1, VAR_2 += VAR_3)
memcpy(VAR_0, VAR_2, VAR_4);
return;
}
for (VAR_8 = 0; VAR_8 < 2 * VAR_6->steps_y; VAR_8++)
memset(sc[VAR_8], 0, sizeof(sc[VAR_8][0]) * (VAR_4 + 2 * VAR_6->steps_x));
for (VAR_8 = -VAR_6->steps_y; VAR_8 < VAR_5 + VAR_6->steps_y; VAR_8++) {
if (VAR_8 < VAR_5)
VAR_10 = VAR_2;
memset(sr, 0, sizeof(sr[0]) * (2 * VAR_6->steps_x - 1));
for (VAR_7 = -VAR_6->steps_x; VAR_7 < VAR_4 + VAR_6->steps_x; VAR_7++) {
tmp1 = VAR_7 <= 0 ? VAR_10[0] : VAR_7 >= VAR_4 ? VAR_10[VAR_4-1] : VAR_10[VAR_7];
for (VAR_9 = 0; VAR_9 < VAR_6->steps_x * 2; VAR_9 += 2) {
tmp2 = sr[VAR_9 + 0] + tmp1; sr[VAR_9 + 0] = tmp1;
tmp1 = sr[VAR_9 + 1] + tmp2; sr[VAR_9 + 1] = tmp2;
}
for (VAR_9 = 0; VAR_9 < VAR_6->steps_y * 2; VAR_9 += 2) {
tmp2 = sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] + tmp1; sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] = tmp1;
tmp1 = sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] + tmp2; sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] = tmp2;
}
if (VAR_7 >= VAR_6->steps_x && VAR_8 >= VAR_6->steps_y) {
const uint8_t *srx = VAR_2 - VAR_6->steps_y * VAR_3 + VAR_7 - VAR_6->steps_x;
uint8_t *dsx = VAR_0 - VAR_6->steps_y * VAR_1 + VAR_7 - VAR_6->steps_x;
res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + VAR_6->halfscale) >> VAR_6->scalebits)) * VAR_6->amount) >> 16);
*dsx = av_clip_uint8(res);
}
}
if (VAR_8 >= 0) {
VAR_0 += VAR_1;
VAR_2 += VAR_3;
}
}
}
| [
"static void FUNC_0( uint8_t *VAR_0, int VAR_1,\nconst uint8_t *VAR_2, int VAR_3,\nint VAR_4, int VAR_5, FilterParam *VAR_6)\n{",
"uint32_t **sc = VAR_6->sc;",
"uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;",
"int32_t res;",
"int VAR_7, VAR_8, VAR_9;",
"const uint8_t *VAR_10;",
"if (!VAR_6->amount) {",
"if (VAR_1 == VAR_3)\nmemcpy(VAR_0, VAR_2, VAR_3 * VAR_5);",
"else\nfor (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++, VAR_0 += VAR_1, VAR_2 += VAR_3)",
"memcpy(VAR_0, VAR_2, VAR_4);",
"return;",
"}",
"for (VAR_8 = 0; VAR_8 < 2 * VAR_6->steps_y; VAR_8++)",
"memset(sc[VAR_8], 0, sizeof(sc[VAR_8][0]) * (VAR_4 + 2 * VAR_6->steps_x));",
"for (VAR_8 = -VAR_6->steps_y; VAR_8 < VAR_5 + VAR_6->steps_y; VAR_8++) {",
"if (VAR_8 < VAR_5)\nVAR_10 = VAR_2;",
"memset(sr, 0, sizeof(sr[0]) * (2 * VAR_6->steps_x - 1));",
"for (VAR_7 = -VAR_6->steps_x; VAR_7 < VAR_4 + VAR_6->steps_x; VAR_7++) {",
"tmp1 = VAR_7 <= 0 ? VAR_10[0] : VAR_7 >= VAR_4 ? VAR_10[VAR_4-1] : VAR_10[VAR_7];",
"for (VAR_9 = 0; VAR_9 < VAR_6->steps_x * 2; VAR_9 += 2) {",
"tmp2 = sr[VAR_9 + 0] + tmp1; sr[VAR_9 + 0] = tmp1;",
"tmp1 = sr[VAR_9 + 1] + tmp2; sr[VAR_9 + 1] = tmp2;",
"}",
"for (VAR_9 = 0; VAR_9 < VAR_6->steps_y * 2; VAR_9 += 2) {",
"tmp2 = sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] + tmp1; sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] = tmp1;",
"tmp1 = sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] + tmp2; sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] = tmp2;",
"}",
"if (VAR_7 >= VAR_6->steps_x && VAR_8 >= VAR_6->steps_y) {",
"const uint8_t *srx = VAR_2 - VAR_6->steps_y * VAR_3 + VAR_7 - VAR_6->steps_x;",
"uint8_t *dsx = VAR_0 - VAR_6->steps_y * VAR_1 + VAR_7 - VAR_6->steps_x;",
"res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + VAR_6->halfscale) >> VAR_6->scalebits)) * VAR_6->amount) >> 16);",
"*dsx = av_clip_uint8(res);",
"}",
"}",
"if (VAR_8 >= 0) {",
"VAR_0 += VAR_1;",
"VAR_2 += VAR_3;",
"}",
"}",
"}"
]
| [
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
]
]
|
14,633 | static void acquire_privilege(const char *name, Error **errp)
{
HANDLE token;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
CloseHandle(token);
} else {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| true | qemu | 374044f08fe18a18469b981812cd8695f5b3569c | static void acquire_privilege(const char *name, Error **errp)
{
HANDLE token;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
CloseHandle(token);
} else {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| {
"code": [
" HANDLE token;",
" CloseHandle(token);"
],
"line_no": [
5,
49
]
} | static void FUNC_0(const char *VAR_0, Error **VAR_1)
{
HANDLE token;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
if (OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, VAR_0, &priv.Privileges[0].Luid)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"no luid for requested privilege");
goto out;
}
priv.PrivilegeCount = 1;
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"unable to acquire requested privilege");
goto out;
}
CloseHandle(token);
} else {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (local_err) {
error_propagate(VAR_1, local_err);
}
}
| [
"static void FUNC_0(const char *VAR_0, Error **VAR_1)\n{",
"HANDLE token;",
"TOKEN_PRIVILEGES priv;",
"Error *local_err = NULL;",
"if (OpenProcessToken(GetCurrentProcess(),\nTOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))\n{",
"if (!LookupPrivilegeValue(NULL, VAR_0, &priv.Privileges[0].Luid)) {",
"error_set(&local_err, QERR_QGA_COMMAND_FAILED,\n\"no luid for requested privilege\");",
"goto out;",
"}",
"priv.PrivilegeCount = 1;",
"priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;",
"if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {",
"error_set(&local_err, QERR_QGA_COMMAND_FAILED,\n\"unable to acquire requested privilege\");",
"goto out;",
"}",
"CloseHandle(token);",
"} else {",
"error_set(&local_err, QERR_QGA_COMMAND_FAILED,\n\"failed to open privilege token\");",
"}",
"out:\nif (local_err) {",
"error_propagate(VAR_1, local_err);",
"}",
"}"
]
| [
0,
1,
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
],
[
13,
15,
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69
]
]
|
14,635 | static int mjpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MJpegDecodeContext *s = avctx->priv_data;
UINT8 *buf_end, *buf_ptr, *buf_start;
int len, code, input_size, i;
AVPicture *picture = data;
unsigned int start_code;
*data_size = 0;
/* no supplementary picture */
if (buf_size == 0)
return 0;
buf_ptr = buf;
buf_end = buf + buf_size;
while (buf_ptr < buf_end) {
buf_start = buf_ptr;
/* find start next marker */
code = find_marker(&buf_ptr, buf_end, &s->header_state);
/* copy to buffer */
len = buf_ptr - buf_start;
if (len + (s->buf_ptr - s->buffer) > s->buffer_size) {
/* data too big : flush */
s->buf_ptr = s->buffer;
if (code > 0)
s->start_code = code;
} else {
memcpy(s->buf_ptr, buf_start, len);
s->buf_ptr += len;
/* if we got FF 00, we copy FF to the stream to unescape FF 00 */
/* valid marker code is between 00 and ff - alex */
if (code == 0 || code == 0xff) {
s->buf_ptr--;
} else if (code > 0) {
/* prepare data for next start code */
input_size = s->buf_ptr - s->buffer;
start_code = s->start_code;
s->buf_ptr = s->buffer;
s->start_code = code;
dprintf("marker=%x\n", start_code);
switch(start_code) {
case SOI:
/* nothing to do on SOI */
break;
case DQT:
mjpeg_decode_dqt(s, s->buffer, input_size);
break;
case DHT:
mjpeg_decode_dht(s, s->buffer, input_size);
break;
case SOF0:
mjpeg_decode_sof0(s, s->buffer, input_size);
break;
case SOS:
mjpeg_decode_sos(s, s->buffer, input_size);
if (s->start_code == EOI) {
int l;
if (s->interlaced) {
s->bottom_field ^= 1;
/* if not bottom field, do not output image yet */
if (s->bottom_field)
goto the_end;
}
for(i=0;i<3;i++) {
picture->data[i] = s->current_picture[i];
l = s->linesize[i];
if (s->interlaced)
l >>= 1;
picture->linesize[i] = l;
}
*data_size = sizeof(AVPicture);
avctx->height = s->height;
if (s->interlaced)
avctx->height *= 2;
avctx->width = s->width;
/* XXX: not complete test ! */
switch((s->h_count[0] << 4) | s->v_count[0]) {
case 0x11:
avctx->pix_fmt = PIX_FMT_YUV444P;
break;
case 0x21:
avctx->pix_fmt = PIX_FMT_YUV422P;
break;
default:
case 0x22:
avctx->pix_fmt = PIX_FMT_YUV420P;
break;
}
/* dummy quality */
/* XXX: infer it with matrix */
avctx->quality = 3;
goto the_end;
}
break;
}
}
}
}
the_end:
return buf_ptr - buf;
}
| true | FFmpeg | af289048d8f720743ed82a4e674cff01ab02a836 | static int mjpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
UINT8 *buf, int buf_size)
{
MJpegDecodeContext *s = avctx->priv_data;
UINT8 *buf_end, *buf_ptr, *buf_start;
int len, code, input_size, i;
AVPicture *picture = data;
unsigned int start_code;
*data_size = 0;
if (buf_size == 0)
return 0;
buf_ptr = buf;
buf_end = buf + buf_size;
while (buf_ptr < buf_end) {
buf_start = buf_ptr;
code = find_marker(&buf_ptr, buf_end, &s->header_state);
len = buf_ptr - buf_start;
if (len + (s->buf_ptr - s->buffer) > s->buffer_size) {
s->buf_ptr = s->buffer;
if (code > 0)
s->start_code = code;
} else {
memcpy(s->buf_ptr, buf_start, len);
s->buf_ptr += len;
if (code == 0 || code == 0xff) {
s->buf_ptr--;
} else if (code > 0) {
input_size = s->buf_ptr - s->buffer;
start_code = s->start_code;
s->buf_ptr = s->buffer;
s->start_code = code;
dprintf("marker=%x\n", start_code);
switch(start_code) {
case SOI:
break;
case DQT:
mjpeg_decode_dqt(s, s->buffer, input_size);
break;
case DHT:
mjpeg_decode_dht(s, s->buffer, input_size);
break;
case SOF0:
mjpeg_decode_sof0(s, s->buffer, input_size);
break;
case SOS:
mjpeg_decode_sos(s, s->buffer, input_size);
if (s->start_code == EOI) {
int l;
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field)
goto the_end;
}
for(i=0;i<3;i++) {
picture->data[i] = s->current_picture[i];
l = s->linesize[i];
if (s->interlaced)
l >>= 1;
picture->linesize[i] = l;
}
*data_size = sizeof(AVPicture);
avctx->height = s->height;
if (s->interlaced)
avctx->height *= 2;
avctx->width = s->width;
switch((s->h_count[0] << 4) | s->v_count[0]) {
case 0x11:
avctx->pix_fmt = PIX_FMT_YUV444P;
break;
case 0x21:
avctx->pix_fmt = PIX_FMT_YUV422P;
break;
default:
case 0x22:
avctx->pix_fmt = PIX_FMT_YUV420P;
break;
}
avctx->quality = 3;
goto the_end;
}
break;
}
}
}
}
the_end:
return buf_ptr - buf;
}
| {
"code": [
" if (code == 0 || code == 0xff) {",
" } else if (code > 0) {",
" if (s->start_code == EOI) {"
],
"line_no": [
69,
73,
117
]
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
UINT8 *VAR_3, int VAR_4)
{
MJpegDecodeContext *s = VAR_0->priv_data;
UINT8 *buf_end, *buf_ptr, *buf_start;
int VAR_5, VAR_6, VAR_7, VAR_8;
AVPicture *picture = VAR_1;
unsigned int VAR_9;
*VAR_2 = 0;
if (VAR_4 == 0)
return 0;
buf_ptr = VAR_3;
buf_end = VAR_3 + VAR_4;
while (buf_ptr < buf_end) {
buf_start = buf_ptr;
VAR_6 = find_marker(&buf_ptr, buf_end, &s->header_state);
VAR_5 = buf_ptr - buf_start;
if (VAR_5 + (s->buf_ptr - s->buffer) > s->buffer_size) {
s->buf_ptr = s->buffer;
if (VAR_6 > 0)
s->VAR_9 = VAR_6;
} else {
memcpy(s->buf_ptr, buf_start, VAR_5);
s->buf_ptr += VAR_5;
if (VAR_6 == 0 || VAR_6 == 0xff) {
s->buf_ptr--;
} else if (VAR_6 > 0) {
VAR_7 = s->buf_ptr - s->buffer;
VAR_9 = s->VAR_9;
s->buf_ptr = s->buffer;
s->VAR_9 = VAR_6;
dprintf("marker=%x\n", VAR_9);
switch(VAR_9) {
case SOI:
break;
case DQT:
mjpeg_decode_dqt(s, s->buffer, VAR_7);
break;
case DHT:
mjpeg_decode_dht(s, s->buffer, VAR_7);
break;
case SOF0:
mjpeg_decode_sof0(s, s->buffer, VAR_7);
break;
case SOS:
mjpeg_decode_sos(s, s->buffer, VAR_7);
if (s->VAR_9 == EOI) {
int VAR_10;
if (s->interlaced) {
s->bottom_field ^= 1;
if (s->bottom_field)
goto the_end;
}
for(VAR_8=0;VAR_8<3;VAR_8++) {
picture->VAR_1[VAR_8] = s->current_picture[VAR_8];
VAR_10 = s->linesize[VAR_8];
if (s->interlaced)
VAR_10 >>= 1;
picture->linesize[VAR_8] = VAR_10;
}
*VAR_2 = sizeof(AVPicture);
VAR_0->height = s->height;
if (s->interlaced)
VAR_0->height *= 2;
VAR_0->width = s->width;
switch((s->h_count[0] << 4) | s->v_count[0]) {
case 0x11:
VAR_0->pix_fmt = PIX_FMT_YUV444P;
break;
case 0x21:
VAR_0->pix_fmt = PIX_FMT_YUV422P;
break;
default:
case 0x22:
VAR_0->pix_fmt = PIX_FMT_YUV420P;
break;
}
VAR_0->quality = 3;
goto the_end;
}
break;
}
}
}
}
the_end:
return buf_ptr - VAR_3;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nUINT8 *VAR_3, int VAR_4)\n{",
"MJpegDecodeContext *s = VAR_0->priv_data;",
"UINT8 *buf_end, *buf_ptr, *buf_start;",
"int VAR_5, VAR_6, VAR_7, VAR_8;",
"AVPicture *picture = VAR_1;",
"unsigned int VAR_9;",
"*VAR_2 = 0;",
"if (VAR_4 == 0)\nreturn 0;",
"buf_ptr = VAR_3;",
"buf_end = VAR_3 + VAR_4;",
"while (buf_ptr < buf_end) {",
"buf_start = buf_ptr;",
"VAR_6 = find_marker(&buf_ptr, buf_end, &s->header_state);",
"VAR_5 = buf_ptr - buf_start;",
"if (VAR_5 + (s->buf_ptr - s->buffer) > s->buffer_size) {",
"s->buf_ptr = s->buffer;",
"if (VAR_6 > 0)\ns->VAR_9 = VAR_6;",
"} else {",
"memcpy(s->buf_ptr, buf_start, VAR_5);",
"s->buf_ptr += VAR_5;",
"if (VAR_6 == 0 || VAR_6 == 0xff) {",
"s->buf_ptr--;",
"} else if (VAR_6 > 0) {",
"VAR_7 = s->buf_ptr - s->buffer;",
"VAR_9 = s->VAR_9;",
"s->buf_ptr = s->buffer;",
"s->VAR_9 = VAR_6;",
"dprintf(\"marker=%x\\n\", VAR_9);",
"switch(VAR_9) {",
"case SOI:\nbreak;",
"case DQT:\nmjpeg_decode_dqt(s, s->buffer, VAR_7);",
"break;",
"case DHT:\nmjpeg_decode_dht(s, s->buffer, VAR_7);",
"break;",
"case SOF0:\nmjpeg_decode_sof0(s, s->buffer, VAR_7);",
"break;",
"case SOS:\nmjpeg_decode_sos(s, s->buffer, VAR_7);",
"if (s->VAR_9 == EOI) {",
"int VAR_10;",
"if (s->interlaced) {",
"s->bottom_field ^= 1;",
"if (s->bottom_field)\ngoto the_end;",
"}",
"for(VAR_8=0;VAR_8<3;VAR_8++) {",
"picture->VAR_1[VAR_8] = s->current_picture[VAR_8];",
"VAR_10 = s->linesize[VAR_8];",
"if (s->interlaced)\nVAR_10 >>= 1;",
"picture->linesize[VAR_8] = VAR_10;",
"}",
"*VAR_2 = sizeof(AVPicture);",
"VAR_0->height = s->height;",
"if (s->interlaced)\nVAR_0->height *= 2;",
"VAR_0->width = s->width;",
"switch((s->h_count[0] << 4) | s->v_count[0]) {",
"case 0x11:\nVAR_0->pix_fmt = PIX_FMT_YUV444P;",
"break;",
"case 0x21:\nVAR_0->pix_fmt = PIX_FMT_YUV422P;",
"break;",
"default:\ncase 0x22:\nVAR_0->pix_fmt = PIX_FMT_YUV420P;",
"break;",
"}",
"VAR_0->quality = 3;",
"goto the_end;",
"}",
"break;",
"}",
"}",
"}",
"}",
"the_end:\nreturn buf_ptr - VAR_3;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
27,
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
93
],
[
95,
97
],
[
99
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
113,
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167,
169
],
[
171
],
[
173,
175,
177
],
[
179
],
[
181
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203,
205
],
[
207
]
]
|
14,636 | static struct pxa2xx_dma_state_s *pxa2xx_dma_init(target_phys_addr_t base,
qemu_irq irq, int channels)
{
int i, iomemtype;
struct pxa2xx_dma_state_s *s;
s = (struct pxa2xx_dma_state_s *)
qemu_mallocz(sizeof(struct pxa2xx_dma_state_s));
s->channels = channels;
s->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * s->channels);
s->base = base;
s->irq = irq;
s->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request;
s->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
memset(s->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * s->channels);
for (i = 0; i < s->channels; i ++)
s->chan[i].state = DCSR_STOPINTR;
memset(s->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
iomemtype = cpu_register_io_memory(0, pxa2xx_dma_readfn,
pxa2xx_dma_writefn, s);
cpu_register_physical_memory(base, 0x0000ffff, iomemtype);
register_savevm("pxa2xx_dma", 0, 0, pxa2xx_dma_save, pxa2xx_dma_load, s);
return s;
}
| true | qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | static struct pxa2xx_dma_state_s *pxa2xx_dma_init(target_phys_addr_t base,
qemu_irq irq, int channels)
{
int i, iomemtype;
struct pxa2xx_dma_state_s *s;
s = (struct pxa2xx_dma_state_s *)
qemu_mallocz(sizeof(struct pxa2xx_dma_state_s));
s->channels = channels;
s->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * s->channels);
s->base = base;
s->irq = irq;
s->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request;
s->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
memset(s->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * s->channels);
for (i = 0; i < s->channels; i ++)
s->chan[i].state = DCSR_STOPINTR;
memset(s->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
iomemtype = cpu_register_io_memory(0, pxa2xx_dma_readfn,
pxa2xx_dma_writefn, s);
cpu_register_physical_memory(base, 0x0000ffff, iomemtype);
register_savevm("pxa2xx_dma", 0, 0, pxa2xx_dma_save, pxa2xx_dma_load, s);
return s;
}
| {
"code": [
" cpu_register_physical_memory(base, 0x0000ffff, iomemtype);"
],
"line_no": [
47
]
} | static struct pxa2xx_dma_state_s *FUNC_0(target_phys_addr_t VAR_0,
qemu_irq VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
struct pxa2xx_dma_state_s *VAR_5;
VAR_5 = (struct pxa2xx_dma_state_s *)
qemu_mallocz(sizeof(struct pxa2xx_dma_state_s));
VAR_5->VAR_2 = VAR_2;
VAR_5->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * VAR_5->VAR_2);
VAR_5->VAR_0 = VAR_0;
VAR_5->VAR_1 = VAR_1;
VAR_5->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request;
VAR_5->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
memset(VAR_5->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * VAR_5->VAR_2);
for (VAR_3 = 0; VAR_3 < VAR_5->VAR_2; VAR_3 ++)
VAR_5->chan[VAR_3].state = DCSR_STOPINTR;
memset(VAR_5->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);
VAR_4 = cpu_register_io_memory(0, pxa2xx_dma_readfn,
pxa2xx_dma_writefn, VAR_5);
cpu_register_physical_memory(VAR_0, 0x0000ffff, VAR_4);
register_savevm("pxa2xx_dma", 0, 0, pxa2xx_dma_save, pxa2xx_dma_load, VAR_5);
return VAR_5;
}
| [
"static struct pxa2xx_dma_state_s *FUNC_0(target_phys_addr_t VAR_0,\nqemu_irq VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"struct pxa2xx_dma_state_s *VAR_5;",
"VAR_5 = (struct pxa2xx_dma_state_s *)\nqemu_mallocz(sizeof(struct pxa2xx_dma_state_s));",
"VAR_5->VAR_2 = VAR_2;",
"VAR_5->chan = qemu_mallocz(sizeof(struct pxa2xx_dma_channel_s) * VAR_5->VAR_2);",
"VAR_5->VAR_0 = VAR_0;",
"VAR_5->VAR_1 = VAR_1;",
"VAR_5->handler = (pxa2xx_dma_handler_t) pxa2xx_dma_request;",
"VAR_5->req = qemu_mallocz(sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);",
"memset(VAR_5->chan, 0, sizeof(struct pxa2xx_dma_channel_s) * VAR_5->VAR_2);",
"for (VAR_3 = 0; VAR_3 < VAR_5->VAR_2; VAR_3 ++)",
"VAR_5->chan[VAR_3].state = DCSR_STOPINTR;",
"memset(VAR_5->req, 0, sizeof(uint8_t) * PXA2XX_DMA_NUM_REQUESTS);",
"VAR_4 = cpu_register_io_memory(0, pxa2xx_dma_readfn,\npxa2xx_dma_writefn, VAR_5);",
"cpu_register_physical_memory(VAR_0, 0x0000ffff, VAR_4);",
"register_savevm(\"pxa2xx_dma\", 0, 0, pxa2xx_dma_save, pxa2xx_dma_load, VAR_5);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43,
45
],
[
47
],
[
51
],
[
55
],
[
57
]
]
|
14,637 | static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){
int p,x,y;
for(p=0; p<3; p++){
int is_chroma= !!p;
int w= is_chroma ? s->avctx->width >>s->chroma_h_shift : s->avctx->width;
int h= is_chroma ? s->avctx->height>>s->chroma_v_shift : s->avctx->height;
int ls= frame->linesize[p];
uint8_t *src= frame->data[p];
halfpel[1][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[2][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[3][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[0][p]= src;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[1][p][i]= (20*(src[i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5;
}
}
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[2][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
src= halfpel[1][p];
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[3][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
//FIXME border!
}
}
| true | FFmpeg | f13e733145132e39056027229ff954a798f58410 | static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){
int p,x,y;
for(p=0; p<3; p++){
int is_chroma= !!p;
int w= is_chroma ? s->avctx->width >>s->chroma_h_shift : s->avctx->width;
int h= is_chroma ? s->avctx->height>>s->chroma_v_shift : s->avctx->height;
int ls= frame->linesize[p];
uint8_t *src= frame->data[p];
halfpel[1][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[2][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[3][p] = (uint8_t*) av_malloc(ls * (h + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + ls);
halfpel[0][p]= src;
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[1][p][i]= (20*(src[i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5;
}
}
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[2][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
src= halfpel[1][p];
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int i= y*ls + x;
halfpel[3][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
}
}
}
}
| {
"code": [
"static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){"
],
"line_no": [
1
]
} | static void FUNC_0(SnowContext *VAR_0, uint8_t *VAR_1[4][4], AVFrame *VAR_2){
int VAR_3,VAR_4,VAR_5;
for(VAR_3=0; VAR_3<3; VAR_3++){
int VAR_6= !!VAR_3;
int VAR_7= VAR_6 ? VAR_0->avctx->width >>VAR_0->chroma_h_shift : VAR_0->avctx->width;
int VAR_8= VAR_6 ? VAR_0->avctx->height>>VAR_0->chroma_v_shift : VAR_0->avctx->height;
int VAR_9= VAR_2->linesize[VAR_3];
uint8_t *src= VAR_2->data[VAR_3];
VAR_1[1][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);
VAR_1[2][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);
VAR_1[3][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);
VAR_1[0][VAR_3]= src;
for(VAR_5=0; VAR_5<VAR_8; VAR_5++){
for(VAR_4=0; VAR_4<VAR_7; VAR_4++){
int VAR_11= VAR_5*VAR_9 + VAR_4;
VAR_1[1][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+1]) - 5*(src[VAR_11-1] + src[VAR_11+2]) + (src[VAR_11-2] + src[VAR_11+3]) + 16 )>>5;
}
}
for(VAR_5=0; VAR_5<VAR_8; VAR_5++){
for(VAR_4=0; VAR_4<VAR_7; VAR_4++){
int VAR_11= VAR_5*VAR_9 + VAR_4;
VAR_1[2][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+VAR_9]) - 5*(src[VAR_11-VAR_9] + src[VAR_11+2*VAR_9]) + (src[VAR_11-2*VAR_9] + src[VAR_11+3*VAR_9]) + 16 )>>5;
}
}
src= VAR_1[1][VAR_3];
for(VAR_5=0; VAR_5<VAR_8; VAR_5++){
for(VAR_4=0; VAR_4<VAR_7; VAR_4++){
int VAR_11= VAR_5*VAR_9 + VAR_4;
VAR_1[3][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+VAR_9]) - 5*(src[VAR_11-VAR_9] + src[VAR_11+2*VAR_9]) + (src[VAR_11-2*VAR_9] + src[VAR_11+3*VAR_9]) + 16 )>>5;
}
}
}
}
| [
"static void FUNC_0(SnowContext *VAR_0, uint8_t *VAR_1[4][4], AVFrame *VAR_2){",
"int VAR_3,VAR_4,VAR_5;",
"for(VAR_3=0; VAR_3<3; VAR_3++){",
"int VAR_6= !!VAR_3;",
"int VAR_7= VAR_6 ? VAR_0->avctx->width >>VAR_0->chroma_h_shift : VAR_0->avctx->width;",
"int VAR_8= VAR_6 ? VAR_0->avctx->height>>VAR_0->chroma_v_shift : VAR_0->avctx->height;",
"int VAR_9= VAR_2->linesize[VAR_3];",
"uint8_t *src= VAR_2->data[VAR_3];",
"VAR_1[1][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);",
"VAR_1[2][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);",
"VAR_1[3][VAR_3] = (uint8_t*) av_malloc(VAR_9 * (VAR_8 + 2 * EDGE_WIDTH)) + EDGE_WIDTH * (1 + VAR_9);",
"VAR_1[0][VAR_3]= src;",
"for(VAR_5=0; VAR_5<VAR_8; VAR_5++){",
"for(VAR_4=0; VAR_4<VAR_7; VAR_4++){",
"int VAR_11= VAR_5*VAR_9 + VAR_4;",
"VAR_1[1][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+1]) - 5*(src[VAR_11-1] + src[VAR_11+2]) + (src[VAR_11-2] + src[VAR_11+3]) + 16 )>>5;",
"}",
"}",
"for(VAR_5=0; VAR_5<VAR_8; VAR_5++){",
"for(VAR_4=0; VAR_4<VAR_7; VAR_4++){",
"int VAR_11= VAR_5*VAR_9 + VAR_4;",
"VAR_1[2][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+VAR_9]) - 5*(src[VAR_11-VAR_9] + src[VAR_11+2*VAR_9]) + (src[VAR_11-2*VAR_9] + src[VAR_11+3*VAR_9]) + 16 )>>5;",
"}",
"}",
"src= VAR_1[1][VAR_3];",
"for(VAR_5=0; VAR_5<VAR_8; VAR_5++){",
"for(VAR_4=0; VAR_4<VAR_7; VAR_4++){",
"int VAR_11= VAR_5*VAR_9 + VAR_4;",
"VAR_1[3][VAR_3][VAR_11]= (20*(src[VAR_11] + src[VAR_11+VAR_9]) - 5*(src[VAR_11-VAR_9] + src[VAR_11+2*VAR_9]) + (src[VAR_11-2*VAR_9] + src[VAR_11+3*VAR_9]) + 16 )>>5;",
"}",
"}",
"}",
"}"
]
| [
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
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
]
]
|
14,638 | static int decompress_p(AVCodecContext *avctx,
uint32_t *dst, int linesize,
uint32_t *prev, int plinesize)
{
SCPRContext *s = avctx->priv_data;
GetByteContext *gb = &s->gb;
int ret, temp, min, max, x, y, cx = 0, cx1 = 0;
int backstep = linesize - avctx->width;
const int cxshift = s->cxshift;
if (bytestream2_get_byte(gb) == 0)
return 0;
bytestream2_skip(gb, 1);
init_rangecoder(&s->rc, gb);
ret = decode_value(s, s->range_model, 256, 1, &min);
ret |= decode_value(s, s->range_model, 256, 1, &temp);
min += temp << 8;
ret |= decode_value(s, s->range_model, 256, 1, &max);
ret |= decode_value(s, s->range_model, 256, 1, &temp);
if (ret < 0)
return ret;
max += temp << 8;
memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
while (min <= max) {
int fill, count;
ret = decode_value(s, s->fill_model, 5, 10, &fill);
ret |= decode_value(s, s->count_model, 256, 20, &count);
if (ret < 0)
return ret;
while (min < s->nbcount && count-- > 0) {
s->blocks[min++] = fill;
}
}
for (y = 0; y < s->nby; y++) {
for (x = 0; x < s->nbx; x++) {
int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;
if (s->blocks[y * s->nbx + x] == 0)
continue;
if (((s->blocks[y * s->nbx + x] - 1) & 1) > 0) {
ret = decode_value(s, s->sxy_model[0], 16, 100, &sx1);
ret |= decode_value(s, s->sxy_model[1], 16, 100, &sy1);
ret |= decode_value(s, s->sxy_model[2], 16, 100, &sx2);
ret |= decode_value(s, s->sxy_model[3], 16, 100, &sy2);
if (ret < 0)
return ret;
sx2++;
sy2++;
}
if (((s->blocks[y * s->nbx + x] - 1) & 2) > 0) {
int i, j, by = y * 16, bx = x * 16;
int mvx, mvy;
ret = decode_value(s, s->mv_model[0], 512, 100, &mvx);
ret |= decode_value(s, s->mv_model[1], 512, 100, &mvy);
if (ret < 0)
return ret;
mvx -= 256;
mvy -= 256;
if (by + mvy + sy1 < 0 || bx + mvx + sx1 < 0 ||
by + mvy + sy1 >= avctx->height || bx + mvx + sx1 >= avctx->width)
return AVERROR_INVALIDDATA;
for (i = 0; i < sy2 - sy1 && (by + sy1 + i) < avctx->height && (by + mvy + sy1 + i) < avctx->height; i++) {
for (j = 0; j < sx2 - sx1 && (bx + sx1 + j) < avctx->width && (bx + mvx + sx1 + j) < avctx->width; j++) {
dst[(by + i + sy1) * linesize + bx + sx1 + j] = prev[(by + mvy + sy1 + i) * plinesize + bx + sx1 + mvx + j];
}
}
} else {
int run, r, g, b, z, bx = x * 16 + sx1, by = y * 16 + sy1;
unsigned clr, ptype = 0;
for (; by < y * 16 + sy2 && by < avctx->height;) {
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ptype == 0) {
ret = decode_unit(s, &s->pixel_model[0][cx + cx1], 400, &r);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = r >> cxshift;
ret = decode_unit(s, &s->pixel_model[1][cx + cx1], 400, &g);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = g >> cxshift;
ret = decode_unit(s, &s->pixel_model[2][cx + cx1], 400, &b);
if (ret < 0)
return ret;
clr = (b << 16) + (g << 8) + r;
}
if (ptype > 5)
return AVERROR_INVALIDDATA;
ret = decode_value(s, s->run_model[ptype], 256, 400, &run);
if (ret < 0)
return ret;
switch (ptype) {
case 0:
while (run-- > 0) {
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 1:
while (run-- > 0) {
if (bx == 0) {
if (by < 1)
return AVERROR_INVALIDDATA;
z = backstep;
} else {
z = 0;
}
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = dst[by * linesize + bx - 1 - z];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 2:
while (run-- > 0) {
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = dst[(by - 1) * linesize + bx];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 3:
while (run-- > 0) {
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = prev[by * plinesize + bx];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 4:
while (run-- > 0) {
uint8_t *odst = (uint8_t *)dst;
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = backstep;
} else {
z = 0;
}
r = odst[((by - 1) * linesize + bx) * 4] +
odst[(by * linesize + bx - 1 - z) * 4] -
odst[((by - 1) * linesize + bx - 1 - z) * 4];
g = odst[((by - 1) * linesize + bx) * 4 + 1] +
odst[(by * linesize + bx - 1 - z) * 4 + 1] -
odst[((by - 1) * linesize + bx - 1 - z) * 4 + 1];
b = odst[((by - 1) * linesize + bx) * 4 + 2] +
odst[(by * linesize + bx - 1 - z) * 4 + 2] -
odst[((by - 1) * linesize + bx - 1 - z) * 4 + 2];
clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 5:
while (run-- > 0) {
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = backstep;
} else {
z = 0;
}
clr = dst[(by - 1) * linesize + bx - 1 - z];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
}
if (avctx->bits_per_coded_sample == 16) {
cx1 = (clr & 0x3F00) >> 2;
cx = (clr & 0xFFFFFF) >> 16;
} else {
cx1 = (clr & 0xFC00) >> 4;
cx = (clr & 0xFFFFFF) >> 18;
}
}
}
}
}
return 0;
}
| true | FFmpeg | 5666b95c9f27efa6f9b1e1bb6c592b9a8d78bca5 | static int decompress_p(AVCodecContext *avctx,
uint32_t *dst, int linesize,
uint32_t *prev, int plinesize)
{
SCPRContext *s = avctx->priv_data;
GetByteContext *gb = &s->gb;
int ret, temp, min, max, x, y, cx = 0, cx1 = 0;
int backstep = linesize - avctx->width;
const int cxshift = s->cxshift;
if (bytestream2_get_byte(gb) == 0)
return 0;
bytestream2_skip(gb, 1);
init_rangecoder(&s->rc, gb);
ret = decode_value(s, s->range_model, 256, 1, &min);
ret |= decode_value(s, s->range_model, 256, 1, &temp);
min += temp << 8;
ret |= decode_value(s, s->range_model, 256, 1, &max);
ret |= decode_value(s, s->range_model, 256, 1, &temp);
if (ret < 0)
return ret;
max += temp << 8;
memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
while (min <= max) {
int fill, count;
ret = decode_value(s, s->fill_model, 5, 10, &fill);
ret |= decode_value(s, s->count_model, 256, 20, &count);
if (ret < 0)
return ret;
while (min < s->nbcount && count-- > 0) {
s->blocks[min++] = fill;
}
}
for (y = 0; y < s->nby; y++) {
for (x = 0; x < s->nbx; x++) {
int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;
if (s->blocks[y * s->nbx + x] == 0)
continue;
if (((s->blocks[y * s->nbx + x] - 1) & 1) > 0) {
ret = decode_value(s, s->sxy_model[0], 16, 100, &sx1);
ret |= decode_value(s, s->sxy_model[1], 16, 100, &sy1);
ret |= decode_value(s, s->sxy_model[2], 16, 100, &sx2);
ret |= decode_value(s, s->sxy_model[3], 16, 100, &sy2);
if (ret < 0)
return ret;
sx2++;
sy2++;
}
if (((s->blocks[y * s->nbx + x] - 1) & 2) > 0) {
int i, j, by = y * 16, bx = x * 16;
int mvx, mvy;
ret = decode_value(s, s->mv_model[0], 512, 100, &mvx);
ret |= decode_value(s, s->mv_model[1], 512, 100, &mvy);
if (ret < 0)
return ret;
mvx -= 256;
mvy -= 256;
if (by + mvy + sy1 < 0 || bx + mvx + sx1 < 0 ||
by + mvy + sy1 >= avctx->height || bx + mvx + sx1 >= avctx->width)
return AVERROR_INVALIDDATA;
for (i = 0; i < sy2 - sy1 && (by + sy1 + i) < avctx->height && (by + mvy + sy1 + i) < avctx->height; i++) {
for (j = 0; j < sx2 - sx1 && (bx + sx1 + j) < avctx->width && (bx + mvx + sx1 + j) < avctx->width; j++) {
dst[(by + i + sy1) * linesize + bx + sx1 + j] = prev[(by + mvy + sy1 + i) * plinesize + bx + sx1 + mvx + j];
}
}
} else {
int run, r, g, b, z, bx = x * 16 + sx1, by = y * 16 + sy1;
unsigned clr, ptype = 0;
for (; by < y * 16 + sy2 && by < avctx->height;) {
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ptype == 0) {
ret = decode_unit(s, &s->pixel_model[0][cx + cx1], 400, &r);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = r >> cxshift;
ret = decode_unit(s, &s->pixel_model[1][cx + cx1], 400, &g);
if (ret < 0)
return ret;
cx1 = (cx << 6) & 0xFC0;
cx = g >> cxshift;
ret = decode_unit(s, &s->pixel_model[2][cx + cx1], 400, &b);
if (ret < 0)
return ret;
clr = (b << 16) + (g << 8) + r;
}
if (ptype > 5)
return AVERROR_INVALIDDATA;
ret = decode_value(s, s->run_model[ptype], 256, 400, &run);
if (ret < 0)
return ret;
switch (ptype) {
case 0:
while (run-- > 0) {
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 1:
while (run-- > 0) {
if (bx == 0) {
if (by < 1)
return AVERROR_INVALIDDATA;
z = backstep;
} else {
z = 0;
}
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = dst[by * linesize + bx - 1 - z];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 2:
while (run-- > 0) {
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = dst[(by - 1) * linesize + bx];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 3:
while (run-- > 0) {
if (by >= avctx->height)
return AVERROR_INVALIDDATA;
clr = prev[by * plinesize + bx];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 4:
while (run-- > 0) {
uint8_t *odst = (uint8_t *)dst;
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = backstep;
} else {
z = 0;
}
r = odst[((by - 1) * linesize + bx) * 4] +
odst[(by * linesize + bx - 1 - z) * 4] -
odst[((by - 1) * linesize + bx - 1 - z) * 4];
g = odst[((by - 1) * linesize + bx) * 4 + 1] +
odst[(by * linesize + bx - 1 - z) * 4 + 1] -
odst[((by - 1) * linesize + bx - 1 - z) * 4 + 1];
b = odst[((by - 1) * linesize + bx) * 4 + 2] +
odst[(by * linesize + bx - 1 - z) * 4 + 2] -
odst[((by - 1) * linesize + bx - 1 - z) * 4 + 2];
clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
case 5:
while (run-- > 0) {
if (by < 1 || by >= avctx->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = backstep;
} else {
z = 0;
}
clr = dst[(by - 1) * linesize + bx - 1 - z];
dst[by * linesize + bx] = clr;
bx++;
if (bx >= x * 16 + sx2 || bx >= avctx->width) {
bx = x * 16 + sx1;
by++;
}
}
break;
}
if (avctx->bits_per_coded_sample == 16) {
cx1 = (clr & 0x3F00) >> 2;
cx = (clr & 0xFFFFFF) >> 16;
} else {
cx1 = (clr & 0xFC00) >> 4;
cx = (clr & 0xFFFFFF) >> 18;
}
}
}
}
}
return 0;
}
| {
"code": [
" cx = (clr & 0xFFFFFF) >> 16;"
],
"line_no": [
457
]
} | static int FUNC_0(AVCodecContext *VAR_0,
uint32_t *VAR_1, int VAR_2,
uint32_t *VAR_3, int VAR_4)
{
SCPRContext *s = VAR_0->priv_data;
GetByteContext *gb = &s->gb;
int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;
int VAR_13 = VAR_2 - VAR_0->width;
const int VAR_14 = s->VAR_14;
if (bytestream2_get_byte(gb) == 0)
return 0;
bytestream2_skip(gb, 1);
init_rangecoder(&s->rc, gb);
VAR_5 = decode_value(s, s->range_model, 256, 1, &VAR_7);
VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_6);
VAR_7 += VAR_6 << 8;
VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_8);
VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_6);
if (VAR_5 < 0)
return VAR_5;
VAR_8 += VAR_6 << 8;
memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
while (VAR_7 <= VAR_8) {
int VAR_15, VAR_16;
VAR_5 = decode_value(s, s->fill_model, 5, 10, &VAR_15);
VAR_5 |= decode_value(s, s->count_model, 256, 20, &VAR_16);
if (VAR_5 < 0)
return VAR_5;
while (VAR_7 < s->nbcount && VAR_16-- > 0) {
s->blocks[VAR_7++] = VAR_15;
}
}
for (VAR_10 = 0; VAR_10 < s->nby; VAR_10++) {
for (VAR_9 = 0; VAR_9 < s->nbx; VAR_9++) {
int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;
if (s->blocks[VAR_10 * s->nbx + VAR_9] == 0)
continue;
if (((s->blocks[VAR_10 * s->nbx + VAR_9] - 1) & 1) > 0) {
VAR_5 = decode_value(s, s->sxy_model[0], 16, 100, &sx1);
VAR_5 |= decode_value(s, s->sxy_model[1], 16, 100, &sy1);
VAR_5 |= decode_value(s, s->sxy_model[2], 16, 100, &sx2);
VAR_5 |= decode_value(s, s->sxy_model[3], 16, 100, &sy2);
if (VAR_5 < 0)
return VAR_5;
sx2++;
sy2++;
}
if (((s->blocks[VAR_10 * s->nbx + VAR_9] - 1) & 2) > 0) {
int i, j, by = VAR_10 * 16, bx = VAR_9 * 16;
int mvx, mvy;
VAR_5 = decode_value(s, s->mv_model[0], 512, 100, &mvx);
VAR_5 |= decode_value(s, s->mv_model[1], 512, 100, &mvy);
if (VAR_5 < 0)
return VAR_5;
mvx -= 256;
mvy -= 256;
if (by + mvy + sy1 < 0 || bx + mvx + sx1 < 0 ||
by + mvy + sy1 >= VAR_0->height || bx + mvx + sx1 >= VAR_0->width)
return AVERROR_INVALIDDATA;
for (i = 0; i < sy2 - sy1 && (by + sy1 + i) < VAR_0->height && (by + mvy + sy1 + i) < VAR_0->height; i++) {
for (j = 0; j < sx2 - sx1 && (bx + sx1 + j) < VAR_0->width && (bx + mvx + sx1 + j) < VAR_0->width; j++) {
VAR_1[(by + i + sy1) * VAR_2 + bx + sx1 + j] = VAR_3[(by + mvy + sy1 + i) * VAR_4 + bx + sx1 + mvx + j];
}
}
} else {
int run, r, g, b, z, bx = VAR_9 * 16 + sx1, by = VAR_10 * 16 + sy1;
unsigned clr, ptype = 0;
for (; by < VAR_10 * 16 + sy2 && by < VAR_0->height;) {
VAR_5 = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ptype == 0) {
VAR_5 = decode_unit(s, &s->pixel_model[0][VAR_11 + VAR_12], 400, &r);
if (VAR_5 < 0)
return VAR_5;
VAR_12 = (VAR_11 << 6) & 0xFC0;
VAR_11 = r >> VAR_14;
VAR_5 = decode_unit(s, &s->pixel_model[1][VAR_11 + VAR_12], 400, &g);
if (VAR_5 < 0)
return VAR_5;
VAR_12 = (VAR_11 << 6) & 0xFC0;
VAR_11 = g >> VAR_14;
VAR_5 = decode_unit(s, &s->pixel_model[2][VAR_11 + VAR_12], 400, &b);
if (VAR_5 < 0)
return VAR_5;
clr = (b << 16) + (g << 8) + r;
}
if (ptype > 5)
return AVERROR_INVALIDDATA;
VAR_5 = decode_value(s, s->run_model[ptype], 256, 400, &run);
if (VAR_5 < 0)
return VAR_5;
switch (ptype) {
case 0:
while (run-- > 0) {
if (by >= VAR_0->height)
return AVERROR_INVALIDDATA;
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
case 1:
while (run-- > 0) {
if (bx == 0) {
if (by < 1)
return AVERROR_INVALIDDATA;
z = VAR_13;
} else {
z = 0;
}
if (by >= VAR_0->height)
return AVERROR_INVALIDDATA;
clr = VAR_1[by * VAR_2 + bx - 1 - z];
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
case 2:
while (run-- > 0) {
if (by < 1 || by >= VAR_0->height)
return AVERROR_INVALIDDATA;
clr = VAR_1[(by - 1) * VAR_2 + bx];
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
case 3:
while (run-- > 0) {
if (by >= VAR_0->height)
return AVERROR_INVALIDDATA;
clr = VAR_3[by * VAR_4 + bx];
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
case 4:
while (run-- > 0) {
uint8_t *odst = (uint8_t *)VAR_1;
if (by < 1 || by >= VAR_0->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = VAR_13;
} else {
z = 0;
}
r = odst[((by - 1) * VAR_2 + bx) * 4] +
odst[(by * VAR_2 + bx - 1 - z) * 4] -
odst[((by - 1) * VAR_2 + bx - 1 - z) * 4];
g = odst[((by - 1) * VAR_2 + bx) * 4 + 1] +
odst[(by * VAR_2 + bx - 1 - z) * 4 + 1] -
odst[((by - 1) * VAR_2 + bx - 1 - z) * 4 + 1];
b = odst[((by - 1) * VAR_2 + bx) * 4 + 2] +
odst[(by * VAR_2 + bx - 1 - z) * 4 + 2] -
odst[((by - 1) * VAR_2 + bx - 1 - z) * 4 + 2];
clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
case 5:
while (run-- > 0) {
if (by < 1 || by >= VAR_0->height)
return AVERROR_INVALIDDATA;
if (bx == 0) {
z = VAR_13;
} else {
z = 0;
}
clr = VAR_1[(by - 1) * VAR_2 + bx - 1 - z];
VAR_1[by * VAR_2 + bx] = clr;
bx++;
if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {
bx = VAR_9 * 16 + sx1;
by++;
}
}
break;
}
if (VAR_0->bits_per_coded_sample == 16) {
VAR_12 = (clr & 0x3F00) >> 2;
VAR_11 = (clr & 0xFFFFFF) >> 16;
} else {
VAR_12 = (clr & 0xFC00) >> 4;
VAR_11 = (clr & 0xFFFFFF) >> 18;
}
}
}
}
}
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nuint32_t *VAR_1, int VAR_2,\nuint32_t *VAR_3, int VAR_4)\n{",
"SCPRContext *s = VAR_0->priv_data;",
"GetByteContext *gb = &s->gb;",
"int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12 = 0;",
"int VAR_13 = VAR_2 - VAR_0->width;",
"const int VAR_14 = s->VAR_14;",
"if (bytestream2_get_byte(gb) == 0)\nreturn 0;",
"bytestream2_skip(gb, 1);",
"init_rangecoder(&s->rc, gb);",
"VAR_5 = decode_value(s, s->range_model, 256, 1, &VAR_7);",
"VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_6);",
"VAR_7 += VAR_6 << 8;",
"VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_8);",
"VAR_5 |= decode_value(s, s->range_model, 256, 1, &VAR_6);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_8 += VAR_6 << 8;",
"memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);",
"while (VAR_7 <= VAR_8) {",
"int VAR_15, VAR_16;",
"VAR_5 = decode_value(s, s->fill_model, 5, 10, &VAR_15);",
"VAR_5 |= decode_value(s, s->count_model, 256, 20, &VAR_16);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"while (VAR_7 < s->nbcount && VAR_16-- > 0) {",
"s->blocks[VAR_7++] = VAR_15;",
"}",
"}",
"for (VAR_10 = 0; VAR_10 < s->nby; VAR_10++) {",
"for (VAR_9 = 0; VAR_9 < s->nbx; VAR_9++) {",
"int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;",
"if (s->blocks[VAR_10 * s->nbx + VAR_9] == 0)\ncontinue;",
"if (((s->blocks[VAR_10 * s->nbx + VAR_9] - 1) & 1) > 0) {",
"VAR_5 = decode_value(s, s->sxy_model[0], 16, 100, &sx1);",
"VAR_5 |= decode_value(s, s->sxy_model[1], 16, 100, &sy1);",
"VAR_5 |= decode_value(s, s->sxy_model[2], 16, 100, &sx2);",
"VAR_5 |= decode_value(s, s->sxy_model[3], 16, 100, &sy2);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"sx2++;",
"sy2++;",
"}",
"if (((s->blocks[VAR_10 * s->nbx + VAR_9] - 1) & 2) > 0) {",
"int i, j, by = VAR_10 * 16, bx = VAR_9 * 16;",
"int mvx, mvy;",
"VAR_5 = decode_value(s, s->mv_model[0], 512, 100, &mvx);",
"VAR_5 |= decode_value(s, s->mv_model[1], 512, 100, &mvy);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"mvx -= 256;",
"mvy -= 256;",
"if (by + mvy + sy1 < 0 || bx + mvx + sx1 < 0 ||\nby + mvy + sy1 >= VAR_0->height || bx + mvx + sx1 >= VAR_0->width)\nreturn AVERROR_INVALIDDATA;",
"for (i = 0; i < sy2 - sy1 && (by + sy1 + i) < VAR_0->height && (by + mvy + sy1 + i) < VAR_0->height; i++) {",
"for (j = 0; j < sx2 - sx1 && (bx + sx1 + j) < VAR_0->width && (bx + mvx + sx1 + j) < VAR_0->width; j++) {",
"VAR_1[(by + i + sy1) * VAR_2 + bx + sx1 + j] = VAR_3[(by + mvy + sy1 + i) * VAR_4 + bx + sx1 + mvx + j];",
"}",
"}",
"} else {",
"int run, r, g, b, z, bx = VAR_9 * 16 + sx1, by = VAR_10 * 16 + sy1;",
"unsigned clr, ptype = 0;",
"for (; by < VAR_10 * 16 + sy2 && by < VAR_0->height;) {",
"VAR_5 = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);",
"if (ptype == 0) {",
"VAR_5 = decode_unit(s, &s->pixel_model[0][VAR_11 + VAR_12], 400, &r);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_12 = (VAR_11 << 6) & 0xFC0;",
"VAR_11 = r >> VAR_14;",
"VAR_5 = decode_unit(s, &s->pixel_model[1][VAR_11 + VAR_12], 400, &g);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"VAR_12 = (VAR_11 << 6) & 0xFC0;",
"VAR_11 = g >> VAR_14;",
"VAR_5 = decode_unit(s, &s->pixel_model[2][VAR_11 + VAR_12], 400, &b);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"clr = (b << 16) + (g << 8) + r;",
"}",
"if (ptype > 5)\nreturn AVERROR_INVALIDDATA;",
"VAR_5 = decode_value(s, s->run_model[ptype], 256, 400, &run);",
"if (VAR_5 < 0)\nreturn VAR_5;",
"switch (ptype) {",
"case 0:\nwhile (run-- > 0) {",
"if (by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"case 1:\nwhile (run-- > 0) {",
"if (bx == 0) {",
"if (by < 1)\nreturn AVERROR_INVALIDDATA;",
"z = VAR_13;",
"} else {",
"z = 0;",
"}",
"if (by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"clr = VAR_1[by * VAR_2 + bx - 1 - z];",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"case 2:\nwhile (run-- > 0) {",
"if (by < 1 || by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"clr = VAR_1[(by - 1) * VAR_2 + bx];",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"case 3:\nwhile (run-- > 0) {",
"if (by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"clr = VAR_3[by * VAR_4 + bx];",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"case 4:\nwhile (run-- > 0) {",
"uint8_t *odst = (uint8_t *)VAR_1;",
"if (by < 1 || by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"if (bx == 0) {",
"z = VAR_13;",
"} else {",
"z = 0;",
"}",
"r = odst[((by - 1) * VAR_2 + bx) * 4] +\nodst[(by * VAR_2 + bx - 1 - z) * 4] -\nodst[((by - 1) * VAR_2 + bx - 1 - z) * 4];",
"g = odst[((by - 1) * VAR_2 + bx) * 4 + 1] +\nodst[(by * VAR_2 + bx - 1 - z) * 4 + 1] -\nodst[((by - 1) * VAR_2 + bx - 1 - z) * 4 + 1];",
"b = odst[((by - 1) * VAR_2 + bx) * 4 + 2] +\nodst[(by * VAR_2 + bx - 1 - z) * 4 + 2] -\nodst[((by - 1) * VAR_2 + bx - 1 - z) * 4 + 2];",
"clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"case 5:\nwhile (run-- > 0) {",
"if (by < 1 || by >= VAR_0->height)\nreturn AVERROR_INVALIDDATA;",
"if (bx == 0) {",
"z = VAR_13;",
"} else {",
"z = 0;",
"}",
"clr = VAR_1[(by - 1) * VAR_2 + bx - 1 - z];",
"VAR_1[by * VAR_2 + bx] = clr;",
"bx++;",
"if (bx >= VAR_9 * 16 + sx2 || bx >= VAR_0->width) {",
"bx = VAR_9 * 16 + sx1;",
"by++;",
"}",
"}",
"break;",
"}",
"if (VAR_0->bits_per_coded_sample == 16) {",
"VAR_12 = (clr & 0x3F00) >> 2;",
"VAR_11 = (clr & 0xFFFFFF) >> 16;",
"} else {",
"VAR_12 = (clr & 0xFC00) >> 4;",
"VAR_11 = (clr & 0xFFFFFF) >> 18;",
"}",
"}",
"}",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
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
],
[
47
],
[
49
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63,
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
87,
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127,
129
],
[
133
],
[
135
],
[
139,
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
179
],
[
181
],
[
183
],
[
185,
187
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213,
215
],
[
219
],
[
221,
223
],
[
225,
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247,
249
],
[
251
],
[
253,
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
267,
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295,
297
],
[
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323,
325
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347,
349
],
[
351
],
[
355,
357
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373,
375,
377
],
[
379,
381,
383
],
[
385,
387,
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409,
411
],
[
413,
415
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
477
],
[
479
]
]
|
14,640 | static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double cutoff = cutoff0? cutoff0 : 0.97;
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor
|| c->filter_length != FFMAX((int)ceil(filter_size/factor), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
}
c->phase_shift = phase_shift;
c->phase_mask = phase_count - 1;
c->linear = linear;
c->factor = factor;
c->filter_length = FFMAX((int)ceil(filter_size/factor), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_mallocz(c->filter_alloc*(phase_count+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
goto error;
if (build_filter(c, (void*)c->filter_bank, factor, c->filter_length, c->filter_alloc, phase_count, 1<<c->filter_shift, filter_type, kaiser_beta))
goto error;
memcpy(c->filter_bank + (c->filter_alloc*phase_count+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*phase_count )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
}
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2))
goto error;
c->ideal_dst_incr= c->dst_incr;
c->index= -phase_count*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| true | FFmpeg | f9abeecd94cfa335bf43e2a19b60fb990a46644f | static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double cutoff = cutoff0? cutoff0 : 0.97;
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor
|| c->filter_length != FFMAX((int)ceil(filter_size/factor), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
}
c->phase_shift = phase_shift;
c->phase_mask = phase_count - 1;
c->linear = linear;
c->factor = factor;
c->filter_length = FFMAX((int)ceil(filter_size/factor), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_mallocz(c->filter_alloc*(phase_count+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
goto error;
if (build_filter(c, (void*)c->filter_bank, factor, c->filter_length, c->filter_alloc, phase_count, 1<<c->filter_shift, filter_type, kaiser_beta))
goto error;
memcpy(c->filter_bank + (c->filter_alloc*phase_count+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*phase_count )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
}
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2))
goto error;
c->ideal_dst_incr= c->dst_incr;
c->index= -phase_count*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| {
"code": [
" c->filter_bank = av_mallocz(c->filter_alloc*(phase_count+1)*c->felem_size);"
],
"line_no": [
81
]
} | static ResampleContext *FUNC_0(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,
double precision, int cheby){
double VAR_0 = cutoff0? cutoff0 : 0.97;
double VAR_1= FFMIN(out_rate * VAR_0 / in_rate, 1.0);
int VAR_2= 1<<phase_shift;
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->VAR_1 != VAR_1
|| c->filter_length != FFMAX((int)ceil(filter_size/VAR_1), 1) || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
c->format= format;
c->felem_size= av_get_bytes_per_sample(c->format);
switch(c->format){
case AV_SAMPLE_FMT_S16P:
c->filter_shift = 15;
break;
case AV_SAMPLE_FMT_S32P:
c->filter_shift = 30;
break;
case AV_SAMPLE_FMT_FLTP:
case AV_SAMPLE_FMT_DBLP:
c->filter_shift = 0;
break;
default:
av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
av_assert0(0);
}
c->phase_shift = phase_shift;
c->phase_mask = VAR_2 - 1;
c->linear = linear;
c->VAR_1 = VAR_1;
c->filter_length = FFMAX((int)ceil(filter_size/VAR_1), 1);
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_mallocz(c->filter_alloc*(VAR_2+1)*c->felem_size);
c->filter_type = filter_type;
c->kaiser_beta = kaiser_beta;
if (!c->filter_bank)
goto error;
if (build_filter(c, (void*)c->filter_bank, VAR_1, c->filter_length, c->filter_alloc, VAR_2, 1<<c->filter_shift, filter_type, kaiser_beta))
goto error;
memcpy(c->filter_bank + (c->filter_alloc*VAR_2+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);
memcpy(c->filter_bank + (c->filter_alloc*VAR_2 )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);
}
c->compensation_distance= 0;
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)VAR_2, INT32_MAX/2))
goto error;
c->ideal_dst_incr= c->dst_incr;
c->index= -VAR_2*((c->filter_length-1)/2);
c->frac= 0;
return c;
error:
av_free(c->filter_bank);
av_free(c);
return NULL;
}
| [
"static ResampleContext *FUNC_0(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,\ndouble cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, int kaiser_beta,\ndouble precision, int cheby){",
"double VAR_0 = cutoff0? cutoff0 : 0.97;",
"double VAR_1= FFMIN(out_rate * VAR_0 / in_rate, 1.0);",
"int VAR_2= 1<<phase_shift;",
"if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->VAR_1 != VAR_1\n|| c->filter_length != FFMAX((int)ceil(filter_size/VAR_1), 1) || c->format != format\n|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {",
"c = av_mallocz(sizeof(*c));",
"if (!c)\nreturn NULL;",
"c->format= format;",
"c->felem_size= av_get_bytes_per_sample(c->format);",
"switch(c->format){",
"case AV_SAMPLE_FMT_S16P:\nc->filter_shift = 15;",
"break;",
"case AV_SAMPLE_FMT_S32P:\nc->filter_shift = 30;",
"break;",
"case AV_SAMPLE_FMT_FLTP:\ncase AV_SAMPLE_FMT_DBLP:\nc->filter_shift = 0;",
"break;",
"default:\nav_log(NULL, AV_LOG_ERROR, \"Unsupported sample format\\n\");",
"av_assert0(0);",
"}",
"c->phase_shift = phase_shift;",
"c->phase_mask = VAR_2 - 1;",
"c->linear = linear;",
"c->VAR_1 = VAR_1;",
"c->filter_length = FFMAX((int)ceil(filter_size/VAR_1), 1);",
"c->filter_alloc = FFALIGN(c->filter_length, 8);",
"c->filter_bank = av_mallocz(c->filter_alloc*(VAR_2+1)*c->felem_size);",
"c->filter_type = filter_type;",
"c->kaiser_beta = kaiser_beta;",
"if (!c->filter_bank)\ngoto error;",
"if (build_filter(c, (void*)c->filter_bank, VAR_1, c->filter_length, c->filter_alloc, VAR_2, 1<<c->filter_shift, filter_type, kaiser_beta))\ngoto error;",
"memcpy(c->filter_bank + (c->filter_alloc*VAR_2+1)*c->felem_size, c->filter_bank, (c->filter_alloc-1)*c->felem_size);",
"memcpy(c->filter_bank + (c->filter_alloc*VAR_2 )*c->felem_size, c->filter_bank + (c->filter_alloc - 1)*c->felem_size, c->felem_size);",
"}",
"c->compensation_distance= 0;",
"if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)VAR_2, INT32_MAX/2))\ngoto error;",
"c->ideal_dst_incr= c->dst_incr;",
"c->index= -VAR_2*((c->filter_length-1)/2);",
"c->frac= 0;",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17,
19
],
[
21
],
[
23,
25
],
[
29
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
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
],
[
109
],
[
113
],
[
115
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129
]
]
|
14,641 | int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){
MpegEncContext * const s = &h->s;
int i;
h->mmco_index= 0;
if(h->nal_unit_type == NAL_IDR_SLICE){ //FIXME fields
s->broken_link= get_bits1(gb) -1;
if(get_bits1(gb)){
h->mmco[0].opcode= MMCO_LONG;
h->mmco[0].long_arg= 0;
h->mmco_index= 1;
}
}else{
if(get_bits1(gb)){ // adaptive_ref_pic_marking_mode_flag
for(i= 0; i<MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode= get_ue_golomb_31(gb);
h->mmco[i].opcode= opcode;
if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){
h->mmco[i].short_pic_num= (h->curr_pic_num - get_ue_golomb(gb) - 1) & (h->max_pic_num - 1);
/* if(h->mmco[i].short_pic_num >= h->short_ref_count || h->short_ref[ h->mmco[i].short_pic_num ] == NULL){
av_log(s->avctx, AV_LOG_ERROR, "illegal short ref in memory management control operation %d\n", mmco);
return -1;
}*/
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
unsigned int long_arg= get_ue_golomb_31(gb);
if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
h->mmco[i].long_arg= long_arg;
}
if(opcode > (unsigned)MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
if(opcode == MMCO_END)
break;
}
h->mmco_index= i;
}else{
ff_generate_sliding_window_mmcos(h);
}
}
return 0;
}
| true | FFmpeg | 29a09eae9a827f4dbc9c4517180d8fe2ecef321a | int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){
MpegEncContext * const s = &h->s;
int i;
h->mmco_index= 0;
if(h->nal_unit_type == NAL_IDR_SLICE){
s->broken_link= get_bits1(gb) -1;
if(get_bits1(gb)){
h->mmco[0].opcode= MMCO_LONG;
h->mmco[0].long_arg= 0;
h->mmco_index= 1;
}
}else{
if(get_bits1(gb)){
for(i= 0; i<MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode= get_ue_golomb_31(gb);
h->mmco[i].opcode= opcode;
if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){
h->mmco[i].short_pic_num= (h->curr_pic_num - get_ue_golomb(gb) - 1) & (h->max_pic_num - 1);
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
unsigned int long_arg= get_ue_golomb_31(gb);
if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
h->mmco[i].long_arg= long_arg;
}
if(opcode > (unsigned)MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
if(opcode == MMCO_END)
break;
}
h->mmco_index= i;
}else{
ff_generate_sliding_window_mmcos(h);
}
}
return 0;
}
| {
"code": [
" if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){"
],
"line_no": [
55
]
} | int FUNC_0(H264Context *VAR_0, GetBitContext *VAR_1){
MpegEncContext * const s = &VAR_0->s;
int VAR_2;
VAR_0->mmco_index= 0;
if(VAR_0->nal_unit_type == NAL_IDR_SLICE){
s->broken_link= get_bits1(VAR_1) -1;
if(get_bits1(VAR_1)){
VAR_0->mmco[0].opcode= MMCO_LONG;
VAR_0->mmco[0].long_arg= 0;
VAR_0->mmco_index= 1;
}
}else{
if(get_bits1(VAR_1)){
for(VAR_2= 0; VAR_2<MAX_MMCO_COUNT; VAR_2++) {
MMCOOpcode opcode= get_ue_golomb_31(VAR_1);
VAR_0->mmco[VAR_2].opcode= opcode;
if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){
VAR_0->mmco[VAR_2].short_pic_num= (VAR_0->curr_pic_num - get_ue_golomb(VAR_1) - 1) & (VAR_0->max_pic_num - 1);
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
unsigned int long_arg= get_ue_golomb_31(VAR_1);
if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
VAR_0->mmco[VAR_2].long_arg= long_arg;
}
if(opcode > (unsigned)MMCO_LONG){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
if(opcode == MMCO_END)
break;
}
VAR_0->mmco_index= VAR_2;
}else{
ff_generate_sliding_window_mmcos(VAR_0);
}
}
return 0;
}
| [
"int FUNC_0(H264Context *VAR_0, GetBitContext *VAR_1){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_2;",
"VAR_0->mmco_index= 0;",
"if(VAR_0->nal_unit_type == NAL_IDR_SLICE){",
"s->broken_link= get_bits1(VAR_1) -1;",
"if(get_bits1(VAR_1)){",
"VAR_0->mmco[0].opcode= MMCO_LONG;",
"VAR_0->mmco[0].long_arg= 0;",
"VAR_0->mmco_index= 1;",
"}",
"}else{",
"if(get_bits1(VAR_1)){",
"for(VAR_2= 0; VAR_2<MAX_MMCO_COUNT; VAR_2++) {",
"MMCOOpcode opcode= get_ue_golomb_31(VAR_1);",
"VAR_0->mmco[VAR_2].opcode= opcode;",
"if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){",
"VAR_0->mmco[VAR_2].short_pic_num= (VAR_0->curr_pic_num - get_ue_golomb(VAR_1) - 1) & (VAR_0->max_pic_num - 1);",
"}",
"if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){",
"unsigned int long_arg= get_ue_golomb_31(VAR_1);",
"if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"illegal long ref in memory management control operation %d\\n\", opcode);",
"return -1;",
"}",
"VAR_0->mmco[VAR_2].long_arg= long_arg;",
"}",
"if(opcode > (unsigned)MMCO_LONG){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"illegal memory management control operation %d\\n\", opcode);",
"return -1;",
"}",
"if(opcode == MMCO_END)\nbreak;",
"}",
"VAR_0->mmco_index= VAR_2;",
"}else{",
"ff_generate_sliding_window_mmcos(VAR_0);",
"}",
"}",
"return 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
]
| [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
]
]
|
14,642 | static void listener_add_address_space(MemoryListener *listener,
AddressSpace *as)
{
FlatRange *fr;
if (listener->address_space_filter
&& listener->address_space_filter != as->root) {
return;
}
if (global_dirty_log) {
listener->log_global_start(listener);
}
FOR_EACH_FLAT_RANGE(fr, &as->current_map) {
MemoryRegionSection section = {
.mr = fr->mr,
.address_space = as->root,
.offset_within_region = fr->offset_in_region,
.size = int128_get64(fr->addr.size),
.offset_within_address_space = int128_get64(fr->addr.start),
.readonly = fr->readonly,
};
listener->region_add(listener, §ion);
}
}
| true | qemu | 8786db7cb96f8ce5c75c6e1e074319c9dca8d356 | static void listener_add_address_space(MemoryListener *listener,
AddressSpace *as)
{
FlatRange *fr;
if (listener->address_space_filter
&& listener->address_space_filter != as->root) {
return;
}
if (global_dirty_log) {
listener->log_global_start(listener);
}
FOR_EACH_FLAT_RANGE(fr, &as->current_map) {
MemoryRegionSection section = {
.mr = fr->mr,
.address_space = as->root,
.offset_within_region = fr->offset_in_region,
.size = int128_get64(fr->addr.size),
.offset_within_address_space = int128_get64(fr->addr.start),
.readonly = fr->readonly,
};
listener->region_add(listener, §ion);
}
}
| {
"code": [
" FOR_EACH_FLAT_RANGE(fr, &as->current_map) {",
" FOR_EACH_FLAT_RANGE(fr, &as->current_map) {",
" FOR_EACH_FLAT_RANGE(fr, &as->current_map) {"
],
"line_no": [
27,
27,
27
]
} | static void FUNC_0(MemoryListener *VAR_0,
AddressSpace *VAR_1)
{
FlatRange *fr;
if (VAR_0->address_space_filter
&& VAR_0->address_space_filter != VAR_1->root) {
return;
}
if (global_dirty_log) {
VAR_0->log_global_start(VAR_0);
}
FOR_EACH_FLAT_RANGE(fr, &VAR_1->current_map) {
MemoryRegionSection section = {
.mr = fr->mr,
.address_space = VAR_1->root,
.offset_within_region = fr->offset_in_region,
.size = int128_get64(fr->addr.size),
.offset_within_address_space = int128_get64(fr->addr.start),
.readonly = fr->readonly,
};
VAR_0->region_add(VAR_0, §ion);
}
}
| [
"static void FUNC_0(MemoryListener *VAR_0,\nAddressSpace *VAR_1)\n{",
"FlatRange *fr;",
"if (VAR_0->address_space_filter\n&& VAR_0->address_space_filter != VAR_1->root) {",
"return;",
"}",
"if (global_dirty_log) {",
"VAR_0->log_global_start(VAR_0);",
"}",
"FOR_EACH_FLAT_RANGE(fr, &VAR_1->current_map) {",
"MemoryRegionSection section = {",
".mr = fr->mr,\n.address_space = VAR_1->root,\n.offset_within_region = fr->offset_in_region,\n.size = int128_get64(fr->addr.size),\n.offset_within_address_space = int128_get64(fr->addr.start),\n.readonly = fr->readonly,\n};",
"VAR_0->region_add(VAR_0, §ion);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33,
35,
37,
39,
41,
43
],
[
45
],
[
47
],
[
49
]
]
|
14,644 | BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct qemu_laio_state *s = aio_ctx;
struct qemu_laiocb *laiocb;
struct iocb *iocbs;
off_t offset = sector_num * 512;
laiocb = qemu_aio_get(&laio_pool, bs, cb, opaque);
if (!laiocb)
return NULL;
laiocb->nbytes = nb_sectors * 512;
laiocb->ctx = s;
laiocb->ret = -EINPROGRESS;
iocbs = &laiocb->iocb;
switch (type) {
case QEMU_AIO_WRITE:
io_prep_pwritev(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
case QEMU_AIO_READ:
io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
/* Currently Linux kernel does not support other operations */
default:
fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",
__func__, type);
goto out_free_aiocb;
}
io_set_eventfd(&laiocb->iocb, s->efd);
s->count++;
if (io_submit(s->ctx, 1, &iocbs) < 0)
goto out_dec_count;
return &laiocb->common;
out_free_aiocb:
qemu_aio_release(laiocb);
out_dec_count:
s->count--;
return NULL;
}
| true | qemu | 449c184ed23c6238da7fcc8b965c8fcc865d72a9 | BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct qemu_laio_state *s = aio_ctx;
struct qemu_laiocb *laiocb;
struct iocb *iocbs;
off_t offset = sector_num * 512;
laiocb = qemu_aio_get(&laio_pool, bs, cb, opaque);
if (!laiocb)
return NULL;
laiocb->nbytes = nb_sectors * 512;
laiocb->ctx = s;
laiocb->ret = -EINPROGRESS;
iocbs = &laiocb->iocb;
switch (type) {
case QEMU_AIO_WRITE:
io_prep_pwritev(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
case QEMU_AIO_READ:
io_prep_preadv(iocbs, fd, qiov->iov, qiov->niov, offset);
break;
default:
fprintf(stderr, "%s: invalid AIO request type 0x%x.\n",
__func__, type);
goto out_free_aiocb;
}
io_set_eventfd(&laiocb->iocb, s->efd);
s->count++;
if (io_submit(s->ctx, 1, &iocbs) < 0)
goto out_dec_count;
return &laiocb->common;
out_free_aiocb:
qemu_aio_release(laiocb);
out_dec_count:
s->count--;
return NULL;
}
| {
"code": [
"out_free_aiocb:",
" qemu_aio_release(laiocb);"
],
"line_no": [
77,
79
]
} | BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, void *aio_ctx, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct qemu_laio_state *VAR_0 = aio_ctx;
struct qemu_laiocb *VAR_1;
struct iocb *VAR_2;
off_t offset = sector_num * 512;
VAR_1 = qemu_aio_get(&laio_pool, bs, cb, opaque);
if (!VAR_1)
return NULL;
VAR_1->nbytes = nb_sectors * 512;
VAR_1->ctx = VAR_0;
VAR_1->ret = -EINPROGRESS;
VAR_2 = &VAR_1->iocb;
switch (type) {
case QEMU_AIO_WRITE:
io_prep_pwritev(VAR_2, fd, qiov->iov, qiov->niov, offset);
break;
case QEMU_AIO_READ:
io_prep_preadv(VAR_2, fd, qiov->iov, qiov->niov, offset);
break;
default:
fprintf(stderr, "%VAR_0: invalid AIO request type 0x%x.\n",
__func__, type);
goto out_free_aiocb;
}
io_set_eventfd(&VAR_1->iocb, VAR_0->efd);
VAR_0->count++;
if (io_submit(VAR_0->ctx, 1, &VAR_2) < 0)
goto out_dec_count;
return &VAR_1->common;
out_free_aiocb:
qemu_aio_release(VAR_1);
out_dec_count:
VAR_0->count--;
return NULL;
}
| [
"BlockDriverAIOCB *FUNC_0(BlockDriverState *bs, void *aio_ctx, int fd,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockDriverCompletionFunc *cb, void *opaque, int type)\n{",
"struct qemu_laio_state *VAR_0 = aio_ctx;",
"struct qemu_laiocb *VAR_1;",
"struct iocb *VAR_2;",
"off_t offset = sector_num * 512;",
"VAR_1 = qemu_aio_get(&laio_pool, bs, cb, opaque);",
"if (!VAR_1)\nreturn NULL;",
"VAR_1->nbytes = nb_sectors * 512;",
"VAR_1->ctx = VAR_0;",
"VAR_1->ret = -EINPROGRESS;",
"VAR_2 = &VAR_1->iocb;",
"switch (type) {",
"case QEMU_AIO_WRITE:\nio_prep_pwritev(VAR_2, fd, qiov->iov, qiov->niov, offset);",
"break;",
"case QEMU_AIO_READ:\nio_prep_preadv(VAR_2, fd, qiov->iov, qiov->niov, offset);",
"break;",
"default:\nfprintf(stderr, \"%VAR_0: invalid AIO request type 0x%x.\\n\",\n__func__, type);",
"goto out_free_aiocb;",
"}",
"io_set_eventfd(&VAR_1->iocb, VAR_0->efd);",
"VAR_0->count++;",
"if (io_submit(VAR_0->ctx, 1, &VAR_2) < 0)\ngoto out_dec_count;",
"return &VAR_1->common;",
"out_free_aiocb:\nqemu_aio_release(VAR_1);",
"out_dec_count:\nVAR_0->count--;",
"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,
1,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
49
],
[
53,
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
77,
79
],
[
81,
83
],
[
85
],
[
87
]
]
|
14,645 | static int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame *frame,
int line, int left, uint8_t lru[3][8],
int is_565)
{
int x, y;
int r, g, b;
int width = frame->width;
int stride = frame->linesize[0];
uint8_t *dst = frame->data[0] + stride * line;
for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
for (x = 0; x < width; x++) {
b = decode_sym_565(gb, lru[0], 5);
g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5);
r = decode_sym_565(gb, lru[2], 5);
dst[x * 3 + 0] = (r << 3) | (r >> 2);
dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
dst[x * 3 + 2] = (b << 3) | (b >> 2);
}
dst += stride;
}
return y;
}
| true | FFmpeg | 6e1a167c5564085385488b4f579e9efb987d4bfa | static int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame *frame,
int line, int left, uint8_t lru[3][8],
int is_565)
{
int x, y;
int r, g, b;
int width = frame->width;
int stride = frame->linesize[0];
uint8_t *dst = frame->data[0] + stride * line;
for (y = 0; y < left && get_bits_left(gb) > 16; y++) {
for (x = 0; x < width; x++) {
b = decode_sym_565(gb, lru[0], 5);
g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5);
r = decode_sym_565(gb, lru[2], 5);
dst[x * 3 + 0] = (r << 3) | (r >> 2);
dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
dst[x * 3 + 2] = (b << 3) | (b >> 2);
}
dst += stride;
}
return y;
}
| {
"code": [
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {",
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {",
" for (y = 0; y < left && get_bits_left(gb) > 16; y++) {"
],
"line_no": [
21,
21,
21
]
} | static int FUNC_0(GetBitContext *VAR_0, AVFrame *VAR_1,
int VAR_2, int VAR_3, uint8_t VAR_4[3][8],
int VAR_5)
{
int VAR_6, VAR_7;
int VAR_8, VAR_9, VAR_10;
int VAR_11 = VAR_1->VAR_11;
int VAR_12 = VAR_1->linesize[0];
uint8_t *dst = VAR_1->data[0] + VAR_12 * VAR_2;
for (VAR_7 = 0; VAR_7 < VAR_3 && get_bits_left(VAR_0) > 16; VAR_7++) {
for (VAR_6 = 0; VAR_6 < VAR_11; VAR_6++) {
VAR_10 = decode_sym_565(VAR_0, VAR_4[0], 5);
VAR_9 = decode_sym_565(VAR_0, VAR_4[1], VAR_5 ? 6 : 5);
VAR_8 = decode_sym_565(VAR_0, VAR_4[2], 5);
dst[VAR_6 * 3 + 0] = (VAR_8 << 3) | (VAR_8 >> 2);
dst[VAR_6 * 3 + 1] = VAR_5 ? (VAR_9 << 2) | (VAR_9 >> 4) : (VAR_9 << 3) | (VAR_9 >> 2);
dst[VAR_6 * 3 + 2] = (VAR_10 << 3) | (VAR_10 >> 2);
}
dst += VAR_12;
}
return VAR_7;
}
| [
"static int FUNC_0(GetBitContext *VAR_0, AVFrame *VAR_1,\nint VAR_2, int VAR_3, uint8_t VAR_4[3][8],\nint VAR_5)\n{",
"int VAR_6, VAR_7;",
"int VAR_8, VAR_9, VAR_10;",
"int VAR_11 = VAR_1->VAR_11;",
"int VAR_12 = VAR_1->linesize[0];",
"uint8_t *dst = VAR_1->data[0] + VAR_12 * VAR_2;",
"for (VAR_7 = 0; VAR_7 < VAR_3 && get_bits_left(VAR_0) > 16; VAR_7++) {",
"for (VAR_6 = 0; VAR_6 < VAR_11; VAR_6++) {",
"VAR_10 = decode_sym_565(VAR_0, VAR_4[0], 5);",
"VAR_9 = decode_sym_565(VAR_0, VAR_4[1], VAR_5 ? 6 : 5);",
"VAR_8 = decode_sym_565(VAR_0, VAR_4[2], 5);",
"dst[VAR_6 * 3 + 0] = (VAR_8 << 3) | (VAR_8 >> 2);",
"dst[VAR_6 * 3 + 1] = VAR_5 ? (VAR_9 << 2) | (VAR_9 >> 4) : (VAR_9 << 3) | (VAR_9 >> 2);",
"dst[VAR_6 * 3 + 2] = (VAR_10 << 3) | (VAR_10 >> 2);",
"}",
"dst += VAR_12;",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
]
]
|
14,646 | static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
{
int i, re, im, n, n2, n4;
int16_t *rot = mdct->rot_tmp;
IComplex *x = mdct->cplx_tmp;
n = 1 << mdct->nbits;
n2 = n >> 1;
n4 = n >> 2;
/* shift to simplify computations */
for (i = 0; i <n4; i++)
rot[i] = -in[i + 3*n4];
memcpy(&rot[n4], &in[0], 3*n4*sizeof(*in));
/* pre rotation */
for (i = 0; i < n4; i++) {
re = ((int)rot[ 2*i] - (int)rot[ n-1-2*i]) >> 1;
im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1;
CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15);
}
fft(mdct, x, mdct->nbits - 2);
/* post rotation */
for (i = 0; i < n4; i++) {
re = x[i].re;
im = x[i].im;
CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0);
}
}
| false | FFmpeg | 79997def65fd2313b48a5f3c3a884c6149ae9b5d | static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
{
int i, re, im, n, n2, n4;
int16_t *rot = mdct->rot_tmp;
IComplex *x = mdct->cplx_tmp;
n = 1 << mdct->nbits;
n2 = n >> 1;
n4 = n >> 2;
for (i = 0; i <n4; i++)
rot[i] = -in[i + 3*n4];
memcpy(&rot[n4], &in[0], 3*n4*sizeof(*in));
for (i = 0; i < n4; i++) {
re = ((int)rot[ 2*i] - (int)rot[ n-1-2*i]) >> 1;
im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1;
CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15);
}
fft(mdct, x, mdct->nbits - 2);
for (i = 0; i < n4; i++) {
re = x[i].re;
im = x[i].im;
CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AC3MDCTContext *VAR_0, int32_t *VAR_1, int16_t *VAR_2)
{
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
int16_t *rot = VAR_0->rot_tmp;
IComplex *x = VAR_0->cplx_tmp;
VAR_6 = 1 << VAR_0->nbits;
VAR_7 = VAR_6 >> 1;
VAR_8 = VAR_6 >> 2;
for (VAR_3 = 0; VAR_3 <VAR_8; VAR_3++)
rot[VAR_3] = -VAR_2[VAR_3 + 3*VAR_8];
memcpy(&rot[VAR_8], &VAR_2[0], 3*VAR_8*sizeof(*VAR_2));
for (VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) {
VAR_4 = ((int)rot[ 2*VAR_3] - (int)rot[ VAR_6-1-2*VAR_3]) >> 1;
VAR_5 = -((int)rot[VAR_7+2*VAR_3] - (int)rot[VAR_7-1-2*VAR_3]) >> 1;
CMUL(x[VAR_3].VAR_4, x[VAR_3].VAR_5, VAR_4, VAR_5, -VAR_0->xcos1[VAR_3], VAR_0->xsin1[VAR_3], 15);
}
fft(VAR_0, x, VAR_0->nbits - 2);
for (VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) {
VAR_4 = x[VAR_3].VAR_4;
VAR_5 = x[VAR_3].VAR_5;
CMUL(VAR_1[VAR_7-1-2*VAR_3], VAR_1[2*VAR_3], VAR_4, VAR_5, VAR_0->xsin1[VAR_3], VAR_0->xcos1[VAR_3], 0);
}
}
| [
"static void FUNC_0(AC3MDCTContext *VAR_0, int32_t *VAR_1, int16_t *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"int16_t *rot = VAR_0->rot_tmp;",
"IComplex *x = VAR_0->cplx_tmp;",
"VAR_6 = 1 << VAR_0->nbits;",
"VAR_7 = VAR_6 >> 1;",
"VAR_8 = VAR_6 >> 2;",
"for (VAR_3 = 0; VAR_3 <VAR_8; VAR_3++)",
"rot[VAR_3] = -VAR_2[VAR_3 + 3*VAR_8];",
"memcpy(&rot[VAR_8], &VAR_2[0], 3*VAR_8*sizeof(*VAR_2));",
"for (VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) {",
"VAR_4 = ((int)rot[ 2*VAR_3] - (int)rot[ VAR_6-1-2*VAR_3]) >> 1;",
"VAR_5 = -((int)rot[VAR_7+2*VAR_3] - (int)rot[VAR_7-1-2*VAR_3]) >> 1;",
"CMUL(x[VAR_3].VAR_4, x[VAR_3].VAR_5, VAR_4, VAR_5, -VAR_0->xcos1[VAR_3], VAR_0->xsin1[VAR_3], 15);",
"}",
"fft(VAR_0, x, VAR_0->nbits - 2);",
"for (VAR_3 = 0; VAR_3 < VAR_8; VAR_3++) {",
"VAR_4 = x[VAR_3].VAR_4;",
"VAR_5 = x[VAR_3].VAR_5;",
"CMUL(VAR_1[VAR_7-1-2*VAR_3], VAR_1[2*VAR_3], VAR_4, VAR_5, VAR_0->xsin1[VAR_3], VAR_0->xcos1[VAR_3], 0);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
]
|
14,647 | static int spapr_post_load(void *opaque, int version_id)
{
sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
int err = 0;
if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {
CPUState *cs;
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
icp_resend(ICP(cpu->intc));
/* In earlier versions, there was no separate qdev for the PAPR
* RTC, so the RTC offset was stored directly in sPAPREnvironment.
* So when migrating from those versions, poke the incoming offset
* value into the RTC device */
if (version_id < 3) {
err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
if (kvm_enabled() && spapr->patb_entry) {
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
bool radix = !!(spapr->patb_entry & PATBE1_GR);
bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE);
err = kvmppc_configure_v3_mmu(cpu, radix, gtse, spapr->patb_entry);
error_report("Process table config unsupported by the host");
return -EINVAL; | true | qemu | be85537d654565e35e359a74b46fc08b7956525c | static int spapr_post_load(void *opaque, int version_id)
{
sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
int err = 0;
if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {
CPUState *cs;
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
icp_resend(ICP(cpu->intc));
if (version_id < 3) {
err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
if (kvm_enabled() && spapr->patb_entry) {
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
bool radix = !!(spapr->patb_entry & PATBE1_GR);
bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE);
err = kvmppc_configure_v3_mmu(cpu, radix, gtse, spapr->patb_entry);
error_report("Process table config unsupported by the host");
return -EINVAL; | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
sPAPRMachineState *spapr = (sPAPRMachineState *)VAR_0;
int VAR_2 = 0;
if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {
CPUState *cs;
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
icp_resend(ICP(cpu->intc));
if (VAR_1 < 3) {
VAR_2 = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
if (kvm_enabled() && spapr->patb_entry) {
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
bool radix = !!(spapr->patb_entry & PATBE1_GR);
bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE);
VAR_2 = kvmppc_configure_v3_mmu(cpu, radix, gtse, spapr->patb_entry);
error_report("Process table config unsupported by the host");
return -EINVAL; | [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"sPAPRMachineState *spapr = (sPAPRMachineState *)VAR_0;",
"int VAR_2 = 0;",
"if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {",
"CPUState *cs;",
"CPU_FOREACH(cs) {",
"PowerPCCPU *cpu = POWERPC_CPU(cs);",
"icp_resend(ICP(cpu->intc));",
"if (VAR_1 < 3) {",
"VAR_2 = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);",
"if (kvm_enabled() && spapr->patb_entry) {",
"PowerPCCPU *cpu = POWERPC_CPU(first_cpu);",
"bool radix = !!(spapr->patb_entry & PATBE1_GR);",
"bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE);",
"VAR_2 = kvmppc_configure_v3_mmu(cpu, radix, gtse, spapr->patb_entry);",
"error_report(\"Process table config unsupported by the host\");",
"return -EINVAL;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
]
]
|
14,648 | static int encode_dvd_subtitles(AVCodecContext *avctx,
uint8_t *outbuf, int outbuf_size,
const AVSubtitle *h)
{
DVDSubtitleContext *dvdc = avctx->priv_data;
uint8_t *q, *qq;
int offset1, offset2;
int i, rects = h->num_rects, ret;
unsigned global_palette_hits[33] = { 0 };
int cmap[256];
int out_palette[4];
int out_alpha[4];
AVSubtitleRect vrect;
uint8_t *vrect_data = NULL;
int x2, y2;
if (rects == 0 || h->rects == NULL)
vrect = *h->rects[0];
if (rects > 1) {
/* DVD subtitles can have only one rectangle: build a virtual
rectangle containing all actual rectangles.
The data of the rectangles will be copied later, when the palette
is decided, because the rectangles may have different palettes. */
int xmin = h->rects[0]->x, xmax = xmin + h->rects[0]->w;
int ymin = h->rects[0]->y, ymax = ymin + h->rects[0]->h;
for (i = 1; i < rects; i++) {
xmin = FFMIN(xmin, h->rects[i]->x);
ymin = FFMIN(ymin, h->rects[i]->y);
xmax = FFMAX(xmax, h->rects[i]->x + h->rects[i]->w);
ymax = FFMAX(ymax, h->rects[i]->y + h->rects[i]->h);
vrect.x = xmin;
vrect.y = ymin;
vrect.w = xmax - xmin;
vrect.h = ymax - ymin;
if ((ret = av_image_check_size(vrect.w, vrect.h, 0, avctx)) < 0)
return ret;
/* Count pixels outside the virtual rectangle as transparent */
global_palette_hits[0] = vrect.w * vrect.h;
global_palette_hits[0] -= h->rects[i]->w * h->rects[i]->h;
count_colors(avctx, global_palette_hits, h->rects[i]);
select_palette(avctx, out_palette, out_alpha, global_palette_hits);
if (rects > 1) {
if (!(vrect_data = av_calloc(vrect.w, vrect.h)))
return AVERROR(ENOMEM);
vrect.pict.data [0] = vrect_data;
vrect.pict.linesize[0] = vrect.w;
for (i = 0; i < rects; i++) {
build_color_map(avctx, cmap, (uint32_t *)h->rects[i]->pict.data[1],
out_palette, out_alpha);
copy_rectangle(&vrect, h->rects[i], cmap);
for (i = 0; i < 4; i++)
cmap[i] = i;
} else {
build_color_map(avctx, cmap, (uint32_t *)h->rects[0]->pict.data[1],
out_palette, out_alpha);
av_log(avctx, AV_LOG_DEBUG, "Selected palette:");
for (i = 0; i < 4; i++)
av_log(avctx, AV_LOG_DEBUG, " 0x%06x@@%02x (0x%x,0x%x)",
dvdc->global_palette[out_palette[i]], out_alpha[i],
out_palette[i], out_alpha[i] >> 4);
av_log(avctx, AV_LOG_DEBUG, "\n");
// encode data block
q = outbuf + 4;
offset1 = q - outbuf;
// worst case memory requirement: 1 nibble per pixel..
if ((q - outbuf) + vrect.w * vrect.h / 2 + 17 + 21 > outbuf_size) {
av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
ret = AVERROR_BUFFER_TOO_SMALL;
goto fail;
dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,
vrect.w, (vrect.h + 1) >> 1, cmap);
offset2 = q - outbuf;
dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,
vrect.w, vrect.h >> 1, cmap);
// set data packet size
qq = outbuf + 2;
bytestream_put_be16(&qq, q - outbuf);
// send start display command
bytestream_put_be16(&q, (h->start_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) /*- 2 */ + 8 + 12 + 2);
*q++ = 0x03; // palette - 4 nibbles
*q++ = (out_palette[3] << 4) | out_palette[2];
*q++ = (out_palette[1] << 4) | out_palette[0];
*q++ = 0x04; // alpha - 4 nibbles
*q++ = (out_alpha[3] & 0xF0) | (out_alpha[2] >> 4);
*q++ = (out_alpha[1] & 0xF0) | (out_alpha[0] >> 4);
// 12 bytes per rect
x2 = vrect.x + vrect.w - 1;
y2 = vrect.y + vrect.h - 1;
*q++ = 0x05;
// x1 x2 -> 6 nibbles
*q++ = vrect.x >> 4;
*q++ = (vrect.x << 4) | ((x2 >> 8) & 0xf);
*q++ = x2;
// y1 y2 -> 6 nibbles
*q++ = vrect.y >> 4;
*q++ = (vrect.y << 4) | ((y2 >> 8) & 0xf);
*q++ = y2;
*q++ = 0x06;
// offset1, offset2
bytestream_put_be16(&q, offset1);
bytestream_put_be16(&q, offset2);
*q++ = 0x01; // start command
*q++ = 0xff; // terminating command
// send stop display command last
bytestream_put_be16(&q, (h->end_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) - 2 /*+ 4*/);
*q++ = 0x02; // set end
*q++ = 0xff; // terminating command
qq = outbuf;
bytestream_put_be16(&qq, q - outbuf);
av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
ret = q - outbuf;
fail:
av_free(vrect_data);
return ret;
| true | FFmpeg | de60880543761003c3674d5d29e0af348f5eb301 | static int encode_dvd_subtitles(AVCodecContext *avctx,
uint8_t *outbuf, int outbuf_size,
const AVSubtitle *h)
{
DVDSubtitleContext *dvdc = avctx->priv_data;
uint8_t *q, *qq;
int offset1, offset2;
int i, rects = h->num_rects, ret;
unsigned global_palette_hits[33] = { 0 };
int cmap[256];
int out_palette[4];
int out_alpha[4];
AVSubtitleRect vrect;
uint8_t *vrect_data = NULL;
int x2, y2;
if (rects == 0 || h->rects == NULL)
vrect = *h->rects[0];
if (rects > 1) {
int xmin = h->rects[0]->x, xmax = xmin + h->rects[0]->w;
int ymin = h->rects[0]->y, ymax = ymin + h->rects[0]->h;
for (i = 1; i < rects; i++) {
xmin = FFMIN(xmin, h->rects[i]->x);
ymin = FFMIN(ymin, h->rects[i]->y);
xmax = FFMAX(xmax, h->rects[i]->x + h->rects[i]->w);
ymax = FFMAX(ymax, h->rects[i]->y + h->rects[i]->h);
vrect.x = xmin;
vrect.y = ymin;
vrect.w = xmax - xmin;
vrect.h = ymax - ymin;
if ((ret = av_image_check_size(vrect.w, vrect.h, 0, avctx)) < 0)
return ret;
global_palette_hits[0] = vrect.w * vrect.h;
global_palette_hits[0] -= h->rects[i]->w * h->rects[i]->h;
count_colors(avctx, global_palette_hits, h->rects[i]);
select_palette(avctx, out_palette, out_alpha, global_palette_hits);
if (rects > 1) {
if (!(vrect_data = av_calloc(vrect.w, vrect.h)))
return AVERROR(ENOMEM);
vrect.pict.data [0] = vrect_data;
vrect.pict.linesize[0] = vrect.w;
for (i = 0; i < rects; i++) {
build_color_map(avctx, cmap, (uint32_t *)h->rects[i]->pict.data[1],
out_palette, out_alpha);
copy_rectangle(&vrect, h->rects[i], cmap);
for (i = 0; i < 4; i++)
cmap[i] = i;
} else {
build_color_map(avctx, cmap, (uint32_t *)h->rects[0]->pict.data[1],
out_palette, out_alpha);
av_log(avctx, AV_LOG_DEBUG, "Selected palette:");
for (i = 0; i < 4; i++)
av_log(avctx, AV_LOG_DEBUG, " 0x%06x@@%02x (0x%x,0x%x)",
dvdc->global_palette[out_palette[i]], out_alpha[i],
out_palette[i], out_alpha[i] >> 4);
av_log(avctx, AV_LOG_DEBUG, "\n");
q = outbuf + 4;
offset1 = q - outbuf;
if ((q - outbuf) + vrect.w * vrect.h / 2 + 17 + 21 > outbuf_size) {
av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
ret = AVERROR_BUFFER_TOO_SMALL;
goto fail;
dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,
vrect.w, (vrect.h + 1) >> 1, cmap);
offset2 = q - outbuf;
dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,
vrect.w, vrect.h >> 1, cmap);
qq = outbuf + 2;
bytestream_put_be16(&qq, q - outbuf);
bytestream_put_be16(&q, (h->start_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) + 8 + 12 + 2);
*q++ = 0x03;
*q++ = (out_palette[3] << 4) | out_palette[2];
*q++ = (out_palette[1] << 4) | out_palette[0];
*q++ = 0x04;
*q++ = (out_alpha[3] & 0xF0) | (out_alpha[2] >> 4);
*q++ = (out_alpha[1] & 0xF0) | (out_alpha[0] >> 4);
x2 = vrect.x + vrect.w - 1;
y2 = vrect.y + vrect.h - 1;
*q++ = 0x05;
*q++ = vrect.x >> 4;
*q++ = (vrect.x << 4) | ((x2 >> 8) & 0xf);
*q++ = x2;
*q++ = vrect.y >> 4;
*q++ = (vrect.y << 4) | ((y2 >> 8) & 0xf);
*q++ = y2;
*q++ = 0x06;
bytestream_put_be16(&q, offset1);
bytestream_put_be16(&q, offset2);
*q++ = 0x01;
*q++ = 0xff;
bytestream_put_be16(&q, (h->end_display_time*90) >> 10);
bytestream_put_be16(&q, (q - outbuf) - 2 );
*q++ = 0x02;
*q++ = 0xff;
qq = outbuf;
bytestream_put_be16(&qq, q - outbuf);
av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
ret = q - outbuf;
fail:
av_free(vrect_data);
return ret;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
uint8_t *VAR_1, int VAR_2,
const AVSubtitle *VAR_3)
{
DVDSubtitleContext *dvdc = VAR_0->priv_data;
uint8_t *q, *qq;
int VAR_4, VAR_5;
int VAR_6, VAR_7 = VAR_3->num_rects, VAR_8;
unsigned VAR_9[33] = { 0 };
int VAR_10[256];
int VAR_11[4];
int VAR_12[4];
AVSubtitleRect vrect;
uint8_t *vrect_data = NULL;
int VAR_13, VAR_14;
if (VAR_7 == 0 || VAR_3->VAR_7 == NULL)
vrect = *VAR_3->VAR_7[0];
if (VAR_7 > 1) {
int VAR_15 = VAR_3->VAR_7[0]->x, VAR_16 = VAR_15 + VAR_3->VAR_7[0]->w;
int VAR_17 = VAR_3->VAR_7[0]->y, VAR_18 = VAR_17 + VAR_3->VAR_7[0]->VAR_3;
for (VAR_6 = 1; VAR_6 < VAR_7; VAR_6++) {
VAR_15 = FFMIN(VAR_15, VAR_3->VAR_7[VAR_6]->x);
VAR_17 = FFMIN(VAR_17, VAR_3->VAR_7[VAR_6]->y);
VAR_16 = FFMAX(VAR_16, VAR_3->VAR_7[VAR_6]->x + VAR_3->VAR_7[VAR_6]->w);
VAR_18 = FFMAX(VAR_18, VAR_3->VAR_7[VAR_6]->y + VAR_3->VAR_7[VAR_6]->VAR_3);
vrect.x = VAR_15;
vrect.y = VAR_17;
vrect.w = VAR_16 - VAR_15;
vrect.VAR_3 = VAR_18 - VAR_17;
if ((VAR_8 = av_image_check_size(vrect.w, vrect.VAR_3, 0, VAR_0)) < 0)
return VAR_8;
VAR_9[0] = vrect.w * vrect.VAR_3;
VAR_9[0] -= VAR_3->VAR_7[VAR_6]->w * VAR_3->VAR_7[VAR_6]->VAR_3;
count_colors(VAR_0, VAR_9, VAR_3->VAR_7[VAR_6]);
select_palette(VAR_0, VAR_11, VAR_12, VAR_9);
if (VAR_7 > 1) {
if (!(vrect_data = av_calloc(vrect.w, vrect.VAR_3)))
return AVERROR(ENOMEM);
vrect.pict.data [0] = vrect_data;
vrect.pict.linesize[0] = vrect.w;
for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {
build_color_map(VAR_0, VAR_10, (uint32_t *)VAR_3->VAR_7[VAR_6]->pict.data[1],
VAR_11, VAR_12);
copy_rectangle(&vrect, VAR_3->VAR_7[VAR_6], VAR_10);
for (VAR_6 = 0; VAR_6 < 4; VAR_6++)
VAR_10[VAR_6] = VAR_6;
} else {
build_color_map(VAR_0, VAR_10, (uint32_t *)VAR_3->VAR_7[0]->pict.data[1],
VAR_11, VAR_12);
av_log(VAR_0, AV_LOG_DEBUG, "Selected palette:");
for (VAR_6 = 0; VAR_6 < 4; VAR_6++)
av_log(VAR_0, AV_LOG_DEBUG, " 0x%06x@@%02x (0x%x,0x%x)",
dvdc->global_palette[VAR_11[VAR_6]], VAR_12[VAR_6],
VAR_11[VAR_6], VAR_12[VAR_6] >> 4);
av_log(VAR_0, AV_LOG_DEBUG, "\n");
q = VAR_1 + 4;
VAR_4 = q - VAR_1;
if ((q - VAR_1) + vrect.w * vrect.VAR_3 / 2 + 17 + 21 > VAR_2) {
av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
VAR_8 = AVERROR_BUFFER_TOO_SMALL;
goto fail;
dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,
vrect.w, (vrect.VAR_3 + 1) >> 1, VAR_10);
VAR_5 = q - VAR_1;
dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,
vrect.w, vrect.VAR_3 >> 1, VAR_10);
qq = VAR_1 + 2;
bytestream_put_be16(&qq, q - VAR_1);
bytestream_put_be16(&q, (VAR_3->start_display_time*90) >> 10);
bytestream_put_be16(&q, (q - VAR_1) + 8 + 12 + 2);
*q++ = 0x03;
*q++ = (VAR_11[3] << 4) | VAR_11[2];
*q++ = (VAR_11[1] << 4) | VAR_11[0];
*q++ = 0x04;
*q++ = (VAR_12[3] & 0xF0) | (VAR_12[2] >> 4);
*q++ = (VAR_12[1] & 0xF0) | (VAR_12[0] >> 4);
VAR_13 = vrect.x + vrect.w - 1;
VAR_14 = vrect.y + vrect.VAR_3 - 1;
*q++ = 0x05;
*q++ = vrect.x >> 4;
*q++ = (vrect.x << 4) | ((VAR_13 >> 8) & 0xf);
*q++ = VAR_13;
*q++ = vrect.y >> 4;
*q++ = (vrect.y << 4) | ((VAR_14 >> 8) & 0xf);
*q++ = VAR_14;
*q++ = 0x06;
bytestream_put_be16(&q, VAR_4);
bytestream_put_be16(&q, VAR_5);
*q++ = 0x01;
*q++ = 0xff;
bytestream_put_be16(&q, (VAR_3->end_display_time*90) >> 10);
bytestream_put_be16(&q, (q - VAR_1) - 2 );
*q++ = 0x02;
*q++ = 0xff;
qq = VAR_1;
bytestream_put_be16(&qq, q - VAR_1);
av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - VAR_1);
VAR_8 = q - VAR_1;
fail:
av_free(vrect_data);
return VAR_8;
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nuint8_t *VAR_1, int VAR_2,\nconst AVSubtitle *VAR_3)\n{",
"DVDSubtitleContext *dvdc = VAR_0->priv_data;",
"uint8_t *q, *qq;",
"int VAR_4, VAR_5;",
"int VAR_6, VAR_7 = VAR_3->num_rects, VAR_8;",
"unsigned VAR_9[33] = { 0 };",
"int VAR_10[256];",
"int VAR_11[4];",
"int VAR_12[4];",
"AVSubtitleRect vrect;",
"uint8_t *vrect_data = NULL;",
"int VAR_13, VAR_14;",
"if (VAR_7 == 0 || VAR_3->VAR_7 == NULL)\nvrect = *VAR_3->VAR_7[0];",
"if (VAR_7 > 1) {",
"int VAR_15 = VAR_3->VAR_7[0]->x, VAR_16 = VAR_15 + VAR_3->VAR_7[0]->w;",
"int VAR_17 = VAR_3->VAR_7[0]->y, VAR_18 = VAR_17 + VAR_3->VAR_7[0]->VAR_3;",
"for (VAR_6 = 1; VAR_6 < VAR_7; VAR_6++) {",
"VAR_15 = FFMIN(VAR_15, VAR_3->VAR_7[VAR_6]->x);",
"VAR_17 = FFMIN(VAR_17, VAR_3->VAR_7[VAR_6]->y);",
"VAR_16 = FFMAX(VAR_16, VAR_3->VAR_7[VAR_6]->x + VAR_3->VAR_7[VAR_6]->w);",
"VAR_18 = FFMAX(VAR_18, VAR_3->VAR_7[VAR_6]->y + VAR_3->VAR_7[VAR_6]->VAR_3);",
"vrect.x = VAR_15;",
"vrect.y = VAR_17;",
"vrect.w = VAR_16 - VAR_15;",
"vrect.VAR_3 = VAR_18 - VAR_17;",
"if ((VAR_8 = av_image_check_size(vrect.w, vrect.VAR_3, 0, VAR_0)) < 0)\nreturn VAR_8;",
"VAR_9[0] = vrect.w * vrect.VAR_3;",
"VAR_9[0] -= VAR_3->VAR_7[VAR_6]->w * VAR_3->VAR_7[VAR_6]->VAR_3;",
"count_colors(VAR_0, VAR_9, VAR_3->VAR_7[VAR_6]);",
"select_palette(VAR_0, VAR_11, VAR_12, VAR_9);",
"if (VAR_7 > 1) {",
"if (!(vrect_data = av_calloc(vrect.w, vrect.VAR_3)))\nreturn AVERROR(ENOMEM);",
"vrect.pict.data [0] = vrect_data;",
"vrect.pict.linesize[0] = vrect.w;",
"for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {",
"build_color_map(VAR_0, VAR_10, (uint32_t *)VAR_3->VAR_7[VAR_6]->pict.data[1],\nVAR_11, VAR_12);",
"copy_rectangle(&vrect, VAR_3->VAR_7[VAR_6], VAR_10);",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++)",
"VAR_10[VAR_6] = VAR_6;",
"} else {",
"build_color_map(VAR_0, VAR_10, (uint32_t *)VAR_3->VAR_7[0]->pict.data[1],\nVAR_11, VAR_12);",
"av_log(VAR_0, AV_LOG_DEBUG, \"Selected palette:\");",
"for (VAR_6 = 0; VAR_6 < 4; VAR_6++)",
"av_log(VAR_0, AV_LOG_DEBUG, \" 0x%06x@@%02x (0x%x,0x%x)\",\ndvdc->global_palette[VAR_11[VAR_6]], VAR_12[VAR_6],\nVAR_11[VAR_6], VAR_12[VAR_6] >> 4);",
"av_log(VAR_0, AV_LOG_DEBUG, \"\\n\");",
"q = VAR_1 + 4;",
"VAR_4 = q - VAR_1;",
"if ((q - VAR_1) + vrect.w * vrect.VAR_3 / 2 + 17 + 21 > VAR_2) {",
"av_log(NULL, AV_LOG_ERROR, \"dvd_subtitle too big\\n\");",
"VAR_8 = AVERROR_BUFFER_TOO_SMALL;",
"goto fail;",
"dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,\nvrect.w, (vrect.VAR_3 + 1) >> 1, VAR_10);",
"VAR_5 = q - VAR_1;",
"dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,\nvrect.w, vrect.VAR_3 >> 1, VAR_10);",
"qq = VAR_1 + 2;",
"bytestream_put_be16(&qq, q - VAR_1);",
"bytestream_put_be16(&q, (VAR_3->start_display_time*90) >> 10);",
"bytestream_put_be16(&q, (q - VAR_1) + 8 + 12 + 2);",
"*q++ = 0x03;",
"*q++ = (VAR_11[3] << 4) | VAR_11[2];",
"*q++ = (VAR_11[1] << 4) | VAR_11[0];",
"*q++ = 0x04;",
"*q++ = (VAR_12[3] & 0xF0) | (VAR_12[2] >> 4);",
"*q++ = (VAR_12[1] & 0xF0) | (VAR_12[0] >> 4);",
"VAR_13 = vrect.x + vrect.w - 1;",
"VAR_14 = vrect.y + vrect.VAR_3 - 1;",
"*q++ = 0x05;",
"*q++ = vrect.x >> 4;",
"*q++ = (vrect.x << 4) | ((VAR_13 >> 8) & 0xf);",
"*q++ = VAR_13;",
"*q++ = vrect.y >> 4;",
"*q++ = (vrect.y << 4) | ((VAR_14 >> 8) & 0xf);",
"*q++ = VAR_14;",
"*q++ = 0x06;",
"bytestream_put_be16(&q, VAR_4);",
"bytestream_put_be16(&q, VAR_5);",
"*q++ = 0x01;",
"*q++ = 0xff;",
"bytestream_put_be16(&q, (VAR_3->end_display_time*90) >> 10);",
"bytestream_put_be16(&q, (q - VAR_1) - 2 );",
"*q++ = 0x02;",
"*q++ = 0xff;",
"qq = VAR_1;",
"bytestream_put_be16(&qq, q - VAR_1);",
"av_log(NULL, AV_LOG_DEBUG, \"subtitle_packet size=%td\\n\", q - VAR_1);",
"VAR_8 = q - VAR_1;",
"fail:\nav_free(vrect_data);",
"return VAR_8;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
41
],
[
45
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
70
],
[
72
],
[
74
],
[
76
],
[
78,
80
],
[
86
],
[
89
],
[
95
],
[
97
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117
],
[
120
],
[
122
],
[
124
],
[
126,
128
],
[
133
],
[
135
],
[
137,
139,
141
],
[
143
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
164,
166
],
[
168
],
[
170,
172
],
[
178
],
[
180
],
[
186
],
[
188
],
[
190
],
[
192
],
[
194
],
[
196
],
[
198
],
[
200
],
[
206
],
[
208
],
[
212
],
[
216
],
[
218
],
[
220
],
[
224
],
[
226
],
[
228
],
[
232
],
[
236
],
[
238
],
[
242
],
[
244
],
[
250
],
[
252
],
[
254
],
[
256
],
[
260
],
[
262
],
[
266
],
[
268
],
[
272,
274
],
[
276
]
]
|
14,649 | static int coroutine_enter_func(void *arg)
{
Coroutine *co = arg;
qemu_coroutine_enter(co, NULL);
return 0;
}
| true | qemu | 0b8b8753e4d94901627b3e86431230f2319215c4 | static int coroutine_enter_func(void *arg)
{
Coroutine *co = arg;
qemu_coroutine_enter(co, NULL);
return 0;
}
| {
"code": [
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);",
" qemu_coroutine_enter(co, NULL);"
],
"line_no": [
7,
7,
7,
7,
7,
7,
7
]
} | static int FUNC_0(void *VAR_0)
{
Coroutine *co = VAR_0;
qemu_coroutine_enter(co, NULL);
return 0;
}
| [
"static int FUNC_0(void *VAR_0)\n{",
"Coroutine *co = VAR_0;",
"qemu_coroutine_enter(co, NULL);",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,650 | int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
const uint8_t *name, uint8_t *dst, int dst_size)
{
int namelen = strlen(name);
int len;
while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {
len = ff_amf_tag_size(data, data_end);
if (len < 0)
len = data_end - data;
data += len;
}
if (data_end - data < 3)
return -1;
data++;
for (;;) {
int size = bytestream_get_be16(&data);
if (!size)
break;
if (data + size >= data_end || data + size < data)
return -1;
data += size;
if (size == namelen && !memcmp(data-size, name, namelen)) {
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(dst, dst_size, "%s", *data ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
len = bytestream_get_be16(&data);
av_strlcpy(dst, data, FFMIN(len+1, dst_size));
break;
default:
return -1;
}
return 0;
}
len = ff_amf_tag_size(data, data_end);
if (len < 0 || data + len >= data_end || data + len < data)
return -1;
data += len;
}
return -1;
}
| true | FFmpeg | 3cff53369acdb3bc0695dd6d5df51457fdaa16ce | int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
const uint8_t *name, uint8_t *dst, int dst_size)
{
int namelen = strlen(name);
int len;
while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {
len = ff_amf_tag_size(data, data_end);
if (len < 0)
len = data_end - data;
data += len;
}
if (data_end - data < 3)
return -1;
data++;
for (;;) {
int size = bytestream_get_be16(&data);
if (!size)
break;
if (data + size >= data_end || data + size < data)
return -1;
data += size;
if (size == namelen && !memcmp(data-size, name, namelen)) {
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(dst, dst_size, "%s", *data ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
len = bytestream_get_be16(&data);
av_strlcpy(dst, data, FFMIN(len+1, dst_size));
break;
default:
return -1;
}
return 0;
}
len = ff_amf_tag_size(data, data_end);
if (len < 0 || data + len >= data_end || data + len < data)
return -1;
data += len;
}
return -1;
}
| {
"code": [
" if (data + size >= data_end || data + size < data)",
" if (len < 0 || data + len >= data_end || data + len < data)"
],
"line_no": [
39,
81
]
} | int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,
const uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)
{
int VAR_5 = strlen(VAR_2);
int VAR_6;
while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) {
VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);
if (VAR_6 < 0)
VAR_6 = VAR_1 - VAR_0;
VAR_0 += VAR_6;
}
if (VAR_1 - VAR_0 < 3)
return -1;
VAR_0++;
for (;;) {
int VAR_7 = bytestream_get_be16(&VAR_0);
if (!VAR_7)
break;
if (VAR_0 + VAR_7 >= VAR_1 || VAR_0 + VAR_7 < VAR_0)
return -1;
VAR_0 += VAR_7;
if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) {
switch (*VAR_0++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(VAR_3, VAR_4, "%g", av_int2double(AV_RB64(VAR_0)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(VAR_3, VAR_4, "%s", *VAR_0 ? "true" : "false");
break;
case AMF_DATA_TYPE_STRING:
VAR_6 = bytestream_get_be16(&VAR_0);
av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4));
break;
default:
return -1;
}
return 0;
}
VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);
if (VAR_6 < 0 || VAR_0 + VAR_6 >= VAR_1 || VAR_0 + VAR_6 < VAR_0)
return -1;
VAR_0 += VAR_6;
}
return -1;
}
| [
"int FUNC_0(const uint8_t *VAR_0, const uint8_t *VAR_1,\nconst uint8_t *VAR_2, uint8_t *VAR_3, int VAR_4)\n{",
"int VAR_5 = strlen(VAR_2);",
"int VAR_6;",
"while (*VAR_0 != AMF_DATA_TYPE_OBJECT && VAR_0 < VAR_1) {",
"VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);",
"if (VAR_6 < 0)\nVAR_6 = VAR_1 - VAR_0;",
"VAR_0 += VAR_6;",
"}",
"if (VAR_1 - VAR_0 < 3)\nreturn -1;",
"VAR_0++;",
"for (;;) {",
"int VAR_7 = bytestream_get_be16(&VAR_0);",
"if (!VAR_7)\nbreak;",
"if (VAR_0 + VAR_7 >= VAR_1 || VAR_0 + VAR_7 < VAR_0)\nreturn -1;",
"VAR_0 += VAR_7;",
"if (VAR_7 == VAR_5 && !memcmp(VAR_0-VAR_7, VAR_2, VAR_5)) {",
"switch (*VAR_0++) {",
"case AMF_DATA_TYPE_NUMBER:\nsnprintf(VAR_3, VAR_4, \"%g\", av_int2double(AV_RB64(VAR_0)));",
"break;",
"case AMF_DATA_TYPE_BOOL:\nsnprintf(VAR_3, VAR_4, \"%s\", *VAR_0 ? \"true\" : \"false\");",
"break;",
"case AMF_DATA_TYPE_STRING:\nVAR_6 = bytestream_get_be16(&VAR_0);",
"av_strlcpy(VAR_3, VAR_0, FFMIN(VAR_6+1, VAR_4));",
"break;",
"default:\nreturn -1;",
"}",
"return 0;",
"}",
"VAR_6 = ff_amf_tag_size(VAR_0, VAR_1);",
"if (VAR_6 < 0 || VAR_0 + VAR_6 >= VAR_1 || VAR_0 + VAR_6 < VAR_0)\nreturn -1;",
"VAR_0 += VAR_6;",
"}",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
]
]
|
14,651 | static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
uint32_t length)
{
uint32_t sequence_number;
int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
if (length != 26)
return AVERROR_INVALIDDATA;
if (!(s->state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n");
return AVERROR_INVALIDDATA;
}
s->last_w = s->cur_w;
s->last_h = s->cur_h;
s->last_x_offset = s->x_offset;
s->last_y_offset = s->y_offset;
s->last_dispose_op = s->dispose_op;
sequence_number = bytestream2_get_be32(&s->gb);
cur_w = bytestream2_get_be32(&s->gb);
cur_h = bytestream2_get_be32(&s->gb);
x_offset = bytestream2_get_be32(&s->gb);
y_offset = bytestream2_get_be32(&s->gb);
bytestream2_skip(&s->gb, 4); /* delay_num (2), delay_den (2) */
dispose_op = bytestream2_get_byte(&s->gb);
blend_op = bytestream2_get_byte(&s->gb);
bytestream2_skip(&s->gb, 4); /* crc */
if (sequence_number == 0 &&
(cur_w != s->width ||
cur_h != s->height ||
x_offset != 0 ||
y_offset != 0) ||
cur_w <= 0 || cur_h <= 0 ||
x_offset < 0 || y_offset < 0 ||
cur_w > s->width - x_offset|| cur_h > s->height - y_offset)
return AVERROR_INVALIDDATA;
if (blend_op != APNG_BLEND_OP_OVER && blend_op != APNG_BLEND_OP_SOURCE) {
av_log(avctx, AV_LOG_ERROR, "Invalid blend_op %d\n", blend_op);
return AVERROR_INVALIDDATA;
}
if ((sequence_number == 0 || !s->previous_picture.f->data[0]) &&
dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
// No previous frame to revert to for the first frame
// Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND
dispose_op = APNG_DISPOSE_OP_BACKGROUND;
}
if (blend_op == APNG_BLEND_OP_OVER && !s->has_trns && (
avctx->pix_fmt == AV_PIX_FMT_RGB24 ||
avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
avctx->pix_fmt == AV_PIX_FMT_PAL8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16BE ||
avctx->pix_fmt == AV_PIX_FMT_MONOBLACK
)) {
// APNG_BLEND_OP_OVER is the same as APNG_BLEND_OP_SOURCE when there is no alpha channel
blend_op = APNG_BLEND_OP_SOURCE;
}
s->cur_w = cur_w;
s->cur_h = cur_h;
s->x_offset = x_offset;
s->y_offset = y_offset;
s->dispose_op = dispose_op;
s->blend_op = blend_op;
return 0;
}
| true | FFmpeg | 478f1c3d5e5463a284ea7efecfc62d47ba3be11a | static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
uint32_t length)
{
uint32_t sequence_number;
int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
if (length != 26)
return AVERROR_INVALIDDATA;
if (!(s->state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n");
return AVERROR_INVALIDDATA;
}
s->last_w = s->cur_w;
s->last_h = s->cur_h;
s->last_x_offset = s->x_offset;
s->last_y_offset = s->y_offset;
s->last_dispose_op = s->dispose_op;
sequence_number = bytestream2_get_be32(&s->gb);
cur_w = bytestream2_get_be32(&s->gb);
cur_h = bytestream2_get_be32(&s->gb);
x_offset = bytestream2_get_be32(&s->gb);
y_offset = bytestream2_get_be32(&s->gb);
bytestream2_skip(&s->gb, 4);
dispose_op = bytestream2_get_byte(&s->gb);
blend_op = bytestream2_get_byte(&s->gb);
bytestream2_skip(&s->gb, 4);
if (sequence_number == 0 &&
(cur_w != s->width ||
cur_h != s->height ||
x_offset != 0 ||
y_offset != 0) ||
cur_w <= 0 || cur_h <= 0 ||
x_offset < 0 || y_offset < 0 ||
cur_w > s->width - x_offset|| cur_h > s->height - y_offset)
return AVERROR_INVALIDDATA;
if (blend_op != APNG_BLEND_OP_OVER && blend_op != APNG_BLEND_OP_SOURCE) {
av_log(avctx, AV_LOG_ERROR, "Invalid blend_op %d\n", blend_op);
return AVERROR_INVALIDDATA;
}
if ((sequence_number == 0 || !s->previous_picture.f->data[0]) &&
dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
dispose_op = APNG_DISPOSE_OP_BACKGROUND;
}
if (blend_op == APNG_BLEND_OP_OVER && !s->has_trns && (
avctx->pix_fmt == AV_PIX_FMT_RGB24 ||
avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
avctx->pix_fmt == AV_PIX_FMT_PAL8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16BE ||
avctx->pix_fmt == AV_PIX_FMT_MONOBLACK
)) {
blend_op = APNG_BLEND_OP_SOURCE;
}
s->cur_w = cur_w;
s->cur_h = cur_h;
s->x_offset = x_offset;
s->y_offset = y_offset;
s->dispose_op = dispose_op;
s->blend_op = blend_op;
return 0;
}
| {
"code": [
" if (!(s->state & PNG_IHDR)) {",
" if (!(s->state & PNG_IHDR)) {",
" if (!(s->state & PNG_IHDR)) {",
" if (!(s->state & PNG_IHDR)) {"
],
"line_no": [
19,
19,
19,
19
]
} | static int FUNC_0(AVCodecContext *VAR_0, PNGDecContext *VAR_1,
uint32_t VAR_2)
{
uint32_t sequence_number;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
if (VAR_2 != 26)
return AVERROR_INVALIDDATA;
if (!(VAR_1->state & PNG_IHDR)) {
av_log(VAR_0, AV_LOG_ERROR, "fctl before IHDR\n");
return AVERROR_INVALIDDATA;
}
VAR_1->last_w = VAR_1->VAR_3;
VAR_1->last_h = VAR_1->VAR_4;
VAR_1->last_x_offset = VAR_1->VAR_5;
VAR_1->last_y_offset = VAR_1->VAR_6;
VAR_1->last_dispose_op = VAR_1->VAR_7;
sequence_number = bytestream2_get_be32(&VAR_1->gb);
VAR_3 = bytestream2_get_be32(&VAR_1->gb);
VAR_4 = bytestream2_get_be32(&VAR_1->gb);
VAR_5 = bytestream2_get_be32(&VAR_1->gb);
VAR_6 = bytestream2_get_be32(&VAR_1->gb);
bytestream2_skip(&VAR_1->gb, 4);
VAR_7 = bytestream2_get_byte(&VAR_1->gb);
VAR_8 = bytestream2_get_byte(&VAR_1->gb);
bytestream2_skip(&VAR_1->gb, 4);
if (sequence_number == 0 &&
(VAR_3 != VAR_1->width ||
VAR_4 != VAR_1->height ||
VAR_5 != 0 ||
VAR_6 != 0) ||
VAR_3 <= 0 || VAR_4 <= 0 ||
VAR_5 < 0 || VAR_6 < 0 ||
VAR_3 > VAR_1->width - VAR_5|| VAR_4 > VAR_1->height - VAR_6)
return AVERROR_INVALIDDATA;
if (VAR_8 != APNG_BLEND_OP_OVER && VAR_8 != APNG_BLEND_OP_SOURCE) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_8 %d\n", VAR_8);
return AVERROR_INVALIDDATA;
}
if ((sequence_number == 0 || !VAR_1->previous_picture.f->data[0]) &&
VAR_7 == APNG_DISPOSE_OP_PREVIOUS) {
VAR_7 = APNG_DISPOSE_OP_BACKGROUND;
}
if (VAR_8 == APNG_BLEND_OP_OVER && !VAR_1->has_trns && (
VAR_0->pix_fmt == AV_PIX_FMT_RGB24 ||
VAR_0->pix_fmt == AV_PIX_FMT_RGB48BE ||
VAR_0->pix_fmt == AV_PIX_FMT_PAL8 ||
VAR_0->pix_fmt == AV_PIX_FMT_GRAY8 ||
VAR_0->pix_fmt == AV_PIX_FMT_GRAY16BE ||
VAR_0->pix_fmt == AV_PIX_FMT_MONOBLACK
)) {
VAR_8 = APNG_BLEND_OP_SOURCE;
}
VAR_1->VAR_3 = VAR_3;
VAR_1->VAR_4 = VAR_4;
VAR_1->VAR_5 = VAR_5;
VAR_1->VAR_6 = VAR_6;
VAR_1->VAR_7 = VAR_7;
VAR_1->VAR_8 = VAR_8;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, PNGDecContext *VAR_1,\nuint32_t VAR_2)\n{",
"uint32_t sequence_number;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"if (VAR_2 != 26)\nreturn AVERROR_INVALIDDATA;",
"if (!(VAR_1->state & PNG_IHDR)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"fctl before IHDR\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_1->last_w = VAR_1->VAR_3;",
"VAR_1->last_h = VAR_1->VAR_4;",
"VAR_1->last_x_offset = VAR_1->VAR_5;",
"VAR_1->last_y_offset = VAR_1->VAR_6;",
"VAR_1->last_dispose_op = VAR_1->VAR_7;",
"sequence_number = bytestream2_get_be32(&VAR_1->gb);",
"VAR_3 = bytestream2_get_be32(&VAR_1->gb);",
"VAR_4 = bytestream2_get_be32(&VAR_1->gb);",
"VAR_5 = bytestream2_get_be32(&VAR_1->gb);",
"VAR_6 = bytestream2_get_be32(&VAR_1->gb);",
"bytestream2_skip(&VAR_1->gb, 4);",
"VAR_7 = bytestream2_get_byte(&VAR_1->gb);",
"VAR_8 = bytestream2_get_byte(&VAR_1->gb);",
"bytestream2_skip(&VAR_1->gb, 4);",
"if (sequence_number == 0 &&\n(VAR_3 != VAR_1->width ||\nVAR_4 != VAR_1->height ||\nVAR_5 != 0 ||\nVAR_6 != 0) ||\nVAR_3 <= 0 || VAR_4 <= 0 ||\nVAR_5 < 0 || VAR_6 < 0 ||\nVAR_3 > VAR_1->width - VAR_5|| VAR_4 > VAR_1->height - VAR_6)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_8 != APNG_BLEND_OP_OVER && VAR_8 != APNG_BLEND_OP_SOURCE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_8 %d\\n\", VAR_8);",
"return AVERROR_INVALIDDATA;",
"}",
"if ((sequence_number == 0 || !VAR_1->previous_picture.f->data[0]) &&\nVAR_7 == APNG_DISPOSE_OP_PREVIOUS) {",
"VAR_7 = APNG_DISPOSE_OP_BACKGROUND;",
"}",
"if (VAR_8 == APNG_BLEND_OP_OVER && !VAR_1->has_trns && (\nVAR_0->pix_fmt == AV_PIX_FMT_RGB24 ||\nVAR_0->pix_fmt == AV_PIX_FMT_RGB48BE ||\nVAR_0->pix_fmt == AV_PIX_FMT_PAL8 ||\nVAR_0->pix_fmt == AV_PIX_FMT_GRAY8 ||\nVAR_0->pix_fmt == AV_PIX_FMT_GRAY16BE ||\nVAR_0->pix_fmt == AV_PIX_FMT_MONOBLACK\n)) {",
"VAR_8 = APNG_BLEND_OP_SOURCE;",
"}",
"VAR_1->VAR_3 = VAR_3;",
"VAR_1->VAR_4 = VAR_4;",
"VAR_1->VAR_5 = VAR_5;",
"VAR_1->VAR_6 = VAR_6;",
"VAR_1->VAR_7 = VAR_7;",
"VAR_1->VAR_8 = VAR_8;",
"return 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
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63,
65,
67,
69,
71,
73,
75,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
99
],
[
101
],
[
105,
107,
109,
111,
113,
115,
117,
119
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
]
]
|
14,655 | static void detach(sPAPRDRConnector *drc, DeviceState *d,
spapr_drc_detach_cb *detach_cb,
void *detach_cb_opaque, Error **errp)
{
trace_spapr_drc_detach(get_index(drc));
drc->detach_cb = detach_cb;
drc->detach_cb_opaque = detach_cb_opaque;
/* if we've signalled device presence to the guest, or if the guest
* has gone ahead and configured the device (via manually-executed
* device add via drmgr in guest, namely), we need to wait
* for the guest to quiesce the device before completing detach.
* Otherwise, we can assume the guest hasn't seen it and complete the
* detach immediately. Note that there is a small race window
* just before, or during, configuration, which is this context
* refers mainly to fetching the device tree via RTAS.
* During this window the device access will be arbitrated by
* associated DRC, which will simply fail the RTAS calls as invalid.
* This is recoverable within guest and current implementations of
* drmgr should be able to cope.
*/
if (!drc->signalled && !drc->configured) {
/* if the guest hasn't seen the device we can't rely on it to
* set it back to an isolated state via RTAS, so do it here manually
*/
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
}
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
trace_spapr_drc_awaiting_isolated(get_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
trace_spapr_drc_awaiting_unusable(get_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->awaiting_allocation) {
drc->awaiting_release = true;
trace_spapr_drc_awaiting_allocation(get_index(drc));
return;
}
drc->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;
if (drc->detach_cb) {
drc->detach_cb(drc->dev, drc->detach_cb_opaque);
}
drc->awaiting_release = false;
g_free(drc->fdt);
drc->fdt = NULL;
drc->fdt_start_offset = 0;
object_property_del(OBJECT(drc), "device", NULL);
drc->dev = NULL;
drc->detach_cb = NULL;
drc->detach_cb_opaque = NULL;
}
| true | qemu | fe6824d12642b005c69123ecf8631f9b13553f8b | static void detach(sPAPRDRConnector *drc, DeviceState *d,
spapr_drc_detach_cb *detach_cb,
void *detach_cb_opaque, Error **errp)
{
trace_spapr_drc_detach(get_index(drc));
drc->detach_cb = detach_cb;
drc->detach_cb_opaque = detach_cb_opaque;
if (!drc->signalled && !drc->configured) {
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
}
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
trace_spapr_drc_awaiting_isolated(get_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
trace_spapr_drc_awaiting_unusable(get_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->awaiting_allocation) {
drc->awaiting_release = true;
trace_spapr_drc_awaiting_allocation(get_index(drc));
return;
}
drc->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;
if (drc->detach_cb) {
drc->detach_cb(drc->dev, drc->detach_cb_opaque);
}
drc->awaiting_release = false;
g_free(drc->fdt);
drc->fdt = NULL;
drc->fdt_start_offset = 0;
object_property_del(OBJECT(drc), "device", NULL);
drc->dev = NULL;
drc->detach_cb = NULL;
drc->detach_cb_opaque = NULL;
}
| {
"code": [
" drc->awaiting_release = true;",
" trace_spapr_drc_awaiting_allocation(get_index(drc));"
],
"line_no": [
63,
89
]
} | static void FUNC_0(sPAPRDRConnector *VAR_0, DeviceState *VAR_1,
spapr_drc_detach_cb *VAR_2,
void *VAR_3, Error **VAR_4)
{
trace_spapr_drc_detach(get_index(VAR_0));
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
if (!VAR_0->signalled && !VAR_0->configured) {
VAR_0->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
}
if (VAR_0->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
trace_spapr_drc_awaiting_isolated(get_index(VAR_0));
VAR_0->awaiting_release = true;
return;
}
if (VAR_0->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&
VAR_0->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
trace_spapr_drc_awaiting_unusable(get_index(VAR_0));
VAR_0->awaiting_release = true;
return;
}
if (VAR_0->awaiting_allocation) {
VAR_0->awaiting_release = true;
trace_spapr_drc_awaiting_allocation(get_index(VAR_0));
return;
}
VAR_0->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;
if (VAR_0->VAR_2) {
VAR_0->VAR_2(VAR_0->dev, VAR_0->VAR_3);
}
VAR_0->awaiting_release = false;
g_free(VAR_0->fdt);
VAR_0->fdt = NULL;
VAR_0->fdt_start_offset = 0;
object_property_del(OBJECT(VAR_0), "device", NULL);
VAR_0->dev = NULL;
VAR_0->VAR_2 = NULL;
VAR_0->VAR_3 = NULL;
}
| [
"static void FUNC_0(sPAPRDRConnector *VAR_0, DeviceState *VAR_1,\nspapr_drc_detach_cb *VAR_2,\nvoid *VAR_3, Error **VAR_4)\n{",
"trace_spapr_drc_detach(get_index(VAR_0));",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"if (!VAR_0->signalled && !VAR_0->configured) {",
"VAR_0->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;",
"}",
"if (VAR_0->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {",
"trace_spapr_drc_awaiting_isolated(get_index(VAR_0));",
"VAR_0->awaiting_release = true;",
"return;",
"}",
"if (VAR_0->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&\nVAR_0->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {",
"trace_spapr_drc_awaiting_unusable(get_index(VAR_0));",
"VAR_0->awaiting_release = true;",
"return;",
"}",
"if (VAR_0->awaiting_allocation) {",
"VAR_0->awaiting_release = true;",
"trace_spapr_drc_awaiting_allocation(get_index(VAR_0));",
"return;",
"}",
"VAR_0->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;",
"if (VAR_0->VAR_2) {",
"VAR_0->VAR_2(VAR_0->dev, VAR_0->VAR_3);",
"}",
"VAR_0->awaiting_release = false;",
"g_free(VAR_0->fdt);",
"VAR_0->fdt = NULL;",
"VAR_0->fdt_start_offset = 0;",
"object_property_del(OBJECT(VAR_0), \"device\", NULL);",
"VAR_0->dev = NULL;",
"VAR_0->VAR_2 = NULL;",
"VAR_0->VAR_3 = NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
45
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
]
]
|
14,656 | static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
int h, const uint8_t *src, int size, int Uoff,
const int step)
{
int i, j;
GetBitContext gb;
VLC vlc;
Node nodes[512];
for(i = 0; i < 256; i++)
nodes[i].count = bytestream_get_le32(&src);
size -= 1024;
if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,
FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)
return -1;
/* we have built Huffman table and are ready to decode plane */
/* convert bits so they may be used by standard bitreader */
s->dsp.bswap_buf((uint32_t *)s->tmpbuf, (const uint32_t *)src, size >> 2);
init_get_bits(&gb, s->tmpbuf, size * 8);
for(j = 0; j < h; j++){
for(i = 0; i < w*step; i += step){
dst[i] = get_vlc2(&gb, vlc.table, 9, 3);
/* lines are stored as deltas between previous lines
* and we need to add 0x80 to the first lines of chroma planes
*/
if(j) dst[i] += dst[i - stride];
else if(Uoff) dst[i] += 0x80;
}
dst += stride;
if(get_bits_left(&gb) < 0){
free_vlc(&vlc);
return -1;
}
}
free_vlc(&vlc);
return 0;
}
| true | FFmpeg | 82a1d575757d5bc9b0b218fe89c77f8de06a7d39 | static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
int h, const uint8_t *src, int size, int Uoff,
const int step)
{
int i, j;
GetBitContext gb;
VLC vlc;
Node nodes[512];
for(i = 0; i < 256; i++)
nodes[i].count = bytestream_get_le32(&src);
size -= 1024;
if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,
FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)
return -1;
s->dsp.bswap_buf((uint32_t *)s->tmpbuf, (const uint32_t *)src, size >> 2);
init_get_bits(&gb, s->tmpbuf, size * 8);
for(j = 0; j < h; j++){
for(i = 0; i < w*step; i += step){
dst[i] = get_vlc2(&gb, vlc.table, 9, 3);
if(j) dst[i] += dst[i - stride];
else if(Uoff) dst[i] += 0x80;
}
dst += stride;
if(get_bits_left(&gb) < 0){
free_vlc(&vlc);
return -1;
}
}
free_vlc(&vlc);
return 0;
}
| {
"code": [
" if(get_bits_left(&gb) < 0){",
" free_vlc(&vlc);",
" return -1;"
],
"line_no": [
63,
65,
67
]
} | static int FUNC_0(FrapsContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7,
const int VAR_8)
{
int VAR_9, VAR_10;
GetBitContext gb;
VLC vlc;
Node nodes[512];
for(VAR_9 = 0; VAR_9 < 256; VAR_9++)
nodes[VAR_9].count = bytestream_get_le32(&VAR_5);
VAR_6 -= 1024;
if (ff_huff_build_tree(VAR_0->avctx, &vlc, 256, nodes, huff_cmp,
FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)
return -1;
VAR_0->dsp.bswap_buf((uint32_t *)VAR_0->tmpbuf, (const uint32_t *)VAR_5, VAR_6 >> 2);
init_get_bits(&gb, VAR_0->tmpbuf, VAR_6 * 8);
for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){
for(VAR_9 = 0; VAR_9 < VAR_3*VAR_8; VAR_9 += VAR_8){
VAR_1[VAR_9] = get_vlc2(&gb, vlc.table, 9, 3);
if(VAR_10) VAR_1[VAR_9] += VAR_1[VAR_9 - VAR_2];
else if(VAR_7) VAR_1[VAR_9] += 0x80;
}
VAR_1 += VAR_2;
if(get_bits_left(&gb) < 0){
free_vlc(&vlc);
return -1;
}
}
free_vlc(&vlc);
return 0;
}
| [
"static int FUNC_0(FrapsContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,\nint VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7,\nconst int VAR_8)\n{",
"int VAR_9, VAR_10;",
"GetBitContext gb;",
"VLC vlc;",
"Node nodes[512];",
"for(VAR_9 = 0; VAR_9 < 256; VAR_9++)",
"nodes[VAR_9].count = bytestream_get_le32(&VAR_5);",
"VAR_6 -= 1024;",
"if (ff_huff_build_tree(VAR_0->avctx, &vlc, 256, nodes, huff_cmp,\nFF_HUFFMAN_FLAG_ZERO_COUNT) < 0)\nreturn -1;",
"VAR_0->dsp.bswap_buf((uint32_t *)VAR_0->tmpbuf, (const uint32_t *)VAR_5, VAR_6 >> 2);",
"init_get_bits(&gb, VAR_0->tmpbuf, VAR_6 * 8);",
"for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){",
"for(VAR_9 = 0; VAR_9 < VAR_3*VAR_8; VAR_9 += VAR_8){",
"VAR_1[VAR_9] = get_vlc2(&gb, vlc.table, 9, 3);",
"if(VAR_10) VAR_1[VAR_9] += VAR_1[VAR_9 - VAR_2];",
"else if(VAR_7) VAR_1[VAR_9] += 0x80;",
"}",
"VAR_1 += VAR_2;",
"if(get_bits_left(&gb) < 0){",
"free_vlc(&vlc);",
"return -1;",
"}",
"}",
"free_vlc(&vlc);",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27,
29
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
14,659 | yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int32_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int32_t **chrUSrc,
const int32_t **chrVSrc, int chrFilterSize,
const int32_t **alpSrc, uint16_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = 1 << 14;
int Y2 = 1 << 14;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
Y1 >>= 15;
Y2 >>= 15;
if ((Y1 | Y2) & 0x10000) {
Y1 = av_clip_uint16(Y1);
Y2 = av_clip_uint16(Y2);
}
output_pixel(&dest[i * 2 + 0], Y1);
output_pixel(&dest[i * 2 + 1], Y2);
}
}
| true | FFmpeg | 72dafea0fc0eb7230d7ebb0a7bc803e13b72aaad | yuv2gray16_X_c_template(SwsContext *c, const int16_t *lumFilter,
const int32_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int32_t **chrUSrc,
const int32_t **chrVSrc, int chrFilterSize,
const int32_t **alpSrc, uint16_t *dest, int dstW,
int y, enum PixelFormat target)
{
int i;
for (i = 0; i < (dstW >> 1); i++) {
int j;
int Y1 = 1 << 14;
int Y2 = 1 << 14;
for (j = 0; j < lumFilterSize; j++) {
Y1 += lumSrc[j][i * 2] * lumFilter[j];
Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
}
Y1 >>= 15;
Y2 >>= 15;
if ((Y1 | Y2) & 0x10000) {
Y1 = av_clip_uint16(Y1);
Y2 = av_clip_uint16(Y2);
}
output_pixel(&dest[i * 2 + 0], Y1);
output_pixel(&dest[i * 2 + 1], Y2);
}
}
| {
"code": [
" int Y1 = 1 << 14;",
" int Y2 = 1 << 14;",
" if ((Y1 | Y2) & 0x10000) {",
" Y1 = av_clip_uint16(Y1);",
" Y2 = av_clip_uint16(Y2);",
" output_pixel(&dest[i * 2 + 0], Y1);",
" output_pixel(&dest[i * 2 + 1], Y2);"
],
"line_no": [
23,
25,
41,
43,
45,
49,
51
]
} | FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,
const int32_t **VAR_2, int VAR_3,
const int16_t *VAR_4, const int32_t **VAR_5,
const int32_t **VAR_6, int VAR_7,
const int32_t **VAR_8, uint16_t *VAR_9, int VAR_10,
int VAR_11, enum PixelFormat VAR_12)
{
int VAR_13;
for (VAR_13 = 0; VAR_13 < (VAR_10 >> 1); VAR_13++) {
int VAR_14;
int VAR_15 = 1 << 14;
int VAR_16 = 1 << 14;
for (VAR_14 = 0; VAR_14 < VAR_3; VAR_14++) {
VAR_15 += VAR_2[VAR_14][VAR_13 * 2] * VAR_1[VAR_14];
VAR_16 += VAR_2[VAR_14][VAR_13 * 2 + 1] * VAR_1[VAR_14];
}
VAR_15 >>= 15;
VAR_16 >>= 15;
if ((VAR_15 | VAR_16) & 0x10000) {
VAR_15 = av_clip_uint16(VAR_15);
VAR_16 = av_clip_uint16(VAR_16);
}
output_pixel(&VAR_9[VAR_13 * 2 + 0], VAR_15);
output_pixel(&VAR_9[VAR_13 * 2 + 1], VAR_16);
}
}
| [
"FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,\nconst int32_t **VAR_2, int VAR_3,\nconst int16_t *VAR_4, const int32_t **VAR_5,\nconst int32_t **VAR_6, int VAR_7,\nconst int32_t **VAR_8, uint16_t *VAR_9, int VAR_10,\nint VAR_11, enum PixelFormat VAR_12)\n{",
"int VAR_13;",
"for (VAR_13 = 0; VAR_13 < (VAR_10 >> 1); VAR_13++) {",
"int VAR_14;",
"int VAR_15 = 1 << 14;",
"int VAR_16 = 1 << 14;",
"for (VAR_14 = 0; VAR_14 < VAR_3; VAR_14++) {",
"VAR_15 += VAR_2[VAR_14][VAR_13 * 2] * VAR_1[VAR_14];",
"VAR_16 += VAR_2[VAR_14][VAR_13 * 2 + 1] * VAR_1[VAR_14];",
"}",
"VAR_15 >>= 15;",
"VAR_16 >>= 15;",
"if ((VAR_15 | VAR_16) & 0x10000) {",
"VAR_15 = av_clip_uint16(VAR_15);",
"VAR_16 = av_clip_uint16(VAR_16);",
"}",
"output_pixel(&VAR_9[VAR_13 * 2 + 0], VAR_15);",
"output_pixel(&VAR_9[VAR_13 * 2 + 1], VAR_16);",
"}",
"}"
]
| [
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
]
|
14,660 | static void ehci_mem_writeb(void *ptr, target_phys_addr_t addr, uint32_t val)
{
fprintf(stderr, "EHCI doesn't handle byte writes to MMIO\n");
exit(1);
}
| true | qemu | 3e4f910c8d490a1490409a7e381dbbb229f9d272 | static void ehci_mem_writeb(void *ptr, target_phys_addr_t addr, uint32_t val)
{
fprintf(stderr, "EHCI doesn't handle byte writes to MMIO\n");
exit(1);
}
| {
"code": [
"static void ehci_mem_writeb(void *ptr, target_phys_addr_t addr, uint32_t val)",
" fprintf(stderr, \"EHCI doesn't handle byte writes to MMIO\\n\");",
" exit(1);",
" exit(1);"
],
"line_no": [
1,
5,
7,
7
]
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
fprintf(stderr, "EHCI doesn't handle byte writes to MMIO\n");
exit(1);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"fprintf(stderr, \"EHCI doesn't handle byte writes to MMIO\\n\");",
"exit(1);",
"}"
]
| [
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
]
]
|
14,662 | static int cmp(const void *key, const void *node)
{
return (*(const int64_t *) key) - ((const CacheEntry *) node)->logical_pos;
}
| true | FFmpeg | 72f9a6349cae0eba7caf9e338bee46c1d9baed27 | static int cmp(const void *key, const void *node)
{
return (*(const int64_t *) key) - ((const CacheEntry *) node)->logical_pos;
}
| {
"code": [
" return (*(const int64_t *) key) - ((const CacheEntry *) node)->logical_pos;"
],
"line_no": [
5
]
} | static int FUNC_0(const void *VAR_0, const void *VAR_1)
{
return (*(const int64_t *) VAR_0) - ((const CacheEntry *) VAR_1)->logical_pos;
}
| [
"static int FUNC_0(const void *VAR_0, const void *VAR_1)\n{",
"return (*(const int64_t *) VAR_0) - ((const CacheEntry *) VAR_1)->logical_pos;",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
14,663 | static void spapr_machine_reset(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
PowerPCCPU *first_ppc_cpu;
uint32_t rtas_limit;
hwaddr rtas_addr, fdt_addr;
void *fdt;
int rc;
/* Check for unknown sysbus devices */
foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
first_ppc_cpu = POWERPC_CPU(first_cpu);
if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
spapr->max_compat_pvr)) {
/* If using KVM with radix mode available, VCPUs can be started
* without a HPT because KVM will start them in radix mode.
* Set the GR bit in PATB so that we know there is no HPT. */
spapr->patb_entry = PATBE1_GR;
} else {
spapr_setup_hpt_and_vrma(spapr);
}
qemu_devices_reset();
/* DRC reset may cause a device to be unplugged. This will cause troubles
* if this device is used by another device (eg, a running vhost backend
* will crash QEMU if the DIMM holding the vring goes away). To avoid such
* situations, we reset DRCs after all devices have been reset.
*/
object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL);
spapr_clear_pending_events(spapr);
/*
* We place the device tree and RTAS just below either the top of the RMA,
* or just below 2GB, whichever is lowere, so that it can be
* processed with 32-bit real mode code if necessary
*/
rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR);
rtas_addr = rtas_limit - RTAS_MAX_SIZE;
fdt_addr = rtas_addr - FDT_MAX_SIZE;
/* if this reset wasn't generated by CAS, we should reset our
* negotiated options and start from scratch */
if (!spapr->cas_reboot) {
spapr_ovec_cleanup(spapr->ov5_cas);
spapr->ov5_cas = spapr_ovec_new();
ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
}
fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
spapr_load_rtas(spapr, fdt, rtas_addr);
rc = fdt_pack(fdt);
/* Should only fail if we've built a corrupted tree */
assert(rc == 0);
if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
fdt_totalsize(fdt), FDT_MAX_SIZE);
exit(1);
}
/* Load the fdt */
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
g_free(fdt);
/* Set up the entry state */
first_ppc_cpu->env.gpr[3] = fdt_addr;
first_ppc_cpu->env.gpr[5] = 0;
first_cpu->halted = 0;
first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
spapr->cas_reboot = false;
} | true | qemu | 33face6b8981add8eba1f7cdaf4cf6cede415d2e | static void spapr_machine_reset(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
PowerPCCPU *first_ppc_cpu;
uint32_t rtas_limit;
hwaddr rtas_addr, fdt_addr;
void *fdt;
int rc;
foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
first_ppc_cpu = POWERPC_CPU(first_cpu);
if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
spapr->max_compat_pvr)) {
spapr->patb_entry = PATBE1_GR;
} else {
spapr_setup_hpt_and_vrma(spapr);
}
qemu_devices_reset();
object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL);
spapr_clear_pending_events(spapr);
rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR);
rtas_addr = rtas_limit - RTAS_MAX_SIZE;
fdt_addr = rtas_addr - FDT_MAX_SIZE;
if (!spapr->cas_reboot) {
spapr_ovec_cleanup(spapr->ov5_cas);
spapr->ov5_cas = spapr_ovec_new();
ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
}
fdt = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
spapr_load_rtas(spapr, fdt, rtas_addr);
rc = fdt_pack(fdt);
assert(rc == 0);
if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
fdt_totalsize(fdt), FDT_MAX_SIZE);
exit(1);
}
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
g_free(fdt);
first_ppc_cpu->env.gpr[3] = fdt_addr;
first_ppc_cpu->env.gpr[5] = 0;
first_cpu->halted = 0;
first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
spapr->cas_reboot = false;
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
MachineState *machine = MACHINE(qdev_get_machine());
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
PowerPCCPU *first_ppc_cpu;
uint32_t rtas_limit;
hwaddr rtas_addr, fdt_addr;
void *VAR_0;
int VAR_1;
foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
first_ppc_cpu = POWERPC_CPU(first_cpu);
if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
spapr->max_compat_pvr)) {
spapr->patb_entry = PATBE1_GR;
} else {
spapr_setup_hpt_and_vrma(spapr);
}
qemu_devices_reset();
object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL);
spapr_clear_pending_events(spapr);
rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR);
rtas_addr = rtas_limit - RTAS_MAX_SIZE;
fdt_addr = rtas_addr - FDT_MAX_SIZE;
if (!spapr->cas_reboot) {
spapr_ovec_cleanup(spapr->ov5_cas);
spapr->ov5_cas = spapr_ovec_new();
ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);
}
VAR_0 = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);
spapr_load_rtas(spapr, VAR_0, rtas_addr);
VAR_1 = fdt_pack(VAR_0);
assert(VAR_1 == 0);
if (fdt_totalsize(VAR_0) > FDT_MAX_SIZE) {
error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
fdt_totalsize(VAR_0), FDT_MAX_SIZE);
exit(1);
}
qemu_fdt_dumpdtb(VAR_0, fdt_totalsize(VAR_0));
cpu_physical_memory_write(fdt_addr, VAR_0, fdt_totalsize(VAR_0));
g_free(VAR_0);
first_ppc_cpu->env.gpr[3] = fdt_addr;
first_ppc_cpu->env.gpr[5] = 0;
first_cpu->halted = 0;
first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;
spapr->cas_reboot = false;
} | [
"static void FUNC_0(void)\n{",
"MachineState *machine = MACHINE(qdev_get_machine());",
"sPAPRMachineState *spapr = SPAPR_MACHINE(machine);",
"PowerPCCPU *first_ppc_cpu;",
"uint32_t rtas_limit;",
"hwaddr rtas_addr, fdt_addr;",
"void *VAR_0;",
"int VAR_1;",
"foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);",
"first_ppc_cpu = POWERPC_CPU(first_cpu);",
"if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&\nppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,\nspapr->max_compat_pvr)) {",
"spapr->patb_entry = PATBE1_GR;",
"} else {",
"spapr_setup_hpt_and_vrma(spapr);",
"}",
"qemu_devices_reset();",
"object_child_foreach_recursive(object_get_root(), spapr_reset_drcs, NULL);",
"spapr_clear_pending_events(spapr);",
"rtas_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR);",
"rtas_addr = rtas_limit - RTAS_MAX_SIZE;",
"fdt_addr = rtas_addr - FDT_MAX_SIZE;",
"if (!spapr->cas_reboot) {",
"spapr_ovec_cleanup(spapr->ov5_cas);",
"spapr->ov5_cas = spapr_ovec_new();",
"ppc_set_compat(first_ppc_cpu, spapr->max_compat_pvr, &error_fatal);",
"}",
"VAR_0 = spapr_build_fdt(spapr, rtas_addr, spapr->rtas_size);",
"spapr_load_rtas(spapr, VAR_0, rtas_addr);",
"VAR_1 = fdt_pack(VAR_0);",
"assert(VAR_1 == 0);",
"if (fdt_totalsize(VAR_0) > FDT_MAX_SIZE) {",
"error_report(\"FDT too big ! 0x%x bytes (max is 0x%x)\",\nfdt_totalsize(VAR_0), FDT_MAX_SIZE);",
"exit(1);",
"}",
"qemu_fdt_dumpdtb(VAR_0, fdt_totalsize(VAR_0));",
"cpu_physical_memory_write(fdt_addr, VAR_0, fdt_totalsize(VAR_0));",
"g_free(VAR_0);",
"first_ppc_cpu->env.gpr[3] = fdt_addr;",
"first_ppc_cpu->env.gpr[5] = 0;",
"first_cpu->halted = 0;",
"first_ppc_cpu->env.nip = SPAPR_ENTRY_POINT;",
"spapr->cas_reboot = false;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
11
],
[
12
],
[
13,
14,
15
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
29
],
[
30
],
[
36
],
[
37
],
[
38
],
[
41
],
[
42
],
[
43
],
[
44
],
[
45
],
[
46
],
[
47
],
[
48
],
[
50
],
[
51
],
[
52,
53
],
[
54
],
[
55
],
[
57
],
[
58
],
[
59
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
]
]
|
14,664 | static void compute_chapters_end(AVFormatContext *s)
{
unsigned int i, j;
int64_t max_time = s->duration +
((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time);
for (i = 0; i < s->nb_chapters; i++)
if (s->chapters[i]->end == AV_NOPTS_VALUE) {
AVChapter *ch = s->chapters[i];
int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q,
ch->time_base)
: INT64_MAX;
for (j = 0; j < s->nb_chapters; j++) {
AVChapter *ch1 = s->chapters[j];
int64_t next_start = av_rescale_q(ch1->start, ch1->time_base,
ch->time_base);
if (j != i && next_start > ch->start && next_start < end)
end = next_start;
}
ch->end = (end == INT64_MAX) ? ch->start : end;
}
}
| true | FFmpeg | d872643cfe07e39fee42c846d5a3f57d5cad6ab6 | static void compute_chapters_end(AVFormatContext *s)
{
unsigned int i, j;
int64_t max_time = s->duration +
((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time);
for (i = 0; i < s->nb_chapters; i++)
if (s->chapters[i]->end == AV_NOPTS_VALUE) {
AVChapter *ch = s->chapters[i];
int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q,
ch->time_base)
: INT64_MAX;
for (j = 0; j < s->nb_chapters; j++) {
AVChapter *ch1 = s->chapters[j];
int64_t next_start = av_rescale_q(ch1->start, ch1->time_base,
ch->time_base);
if (j != i && next_start > ch->start && next_start < end)
end = next_start;
}
ch->end = (end == INT64_MAX) ? ch->start : end;
}
}
| {
"code": [
" int64_t max_time = s->duration +"
],
"line_no": [
7
]
} | static void FUNC_0(AVFormatContext *VAR_0)
{
unsigned int VAR_1, VAR_2;
int64_t max_time = VAR_0->duration +
((VAR_0->start_time == AV_NOPTS_VALUE) ? 0 : VAR_0->start_time);
for (VAR_1 = 0; VAR_1 < VAR_0->nb_chapters; VAR_1++)
if (VAR_0->chapters[VAR_1]->end == AV_NOPTS_VALUE) {
AVChapter *ch = VAR_0->chapters[VAR_1];
int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q,
ch->time_base)
: INT64_MAX;
for (VAR_2 = 0; VAR_2 < VAR_0->nb_chapters; VAR_2++) {
AVChapter *ch1 = VAR_0->chapters[VAR_2];
int64_t next_start = av_rescale_q(ch1->start, ch1->time_base,
ch->time_base);
if (VAR_2 != VAR_1 && next_start > ch->start && next_start < end)
end = next_start;
}
ch->end = (end == INT64_MAX) ? ch->start : end;
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"unsigned int VAR_1, VAR_2;",
"int64_t max_time = VAR_0->duration +\n((VAR_0->start_time == AV_NOPTS_VALUE) ? 0 : VAR_0->start_time);",
"for (VAR_1 = 0; VAR_1 < VAR_0->nb_chapters; VAR_1++)",
"if (VAR_0->chapters[VAR_1]->end == AV_NOPTS_VALUE) {",
"AVChapter *ch = VAR_0->chapters[VAR_1];",
"int64_t end = max_time ? av_rescale_q(max_time, AV_TIME_BASE_Q,\nch->time_base)\n: INT64_MAX;",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_chapters; VAR_2++) {",
"AVChapter *ch1 = VAR_0->chapters[VAR_2];",
"int64_t next_start = av_rescale_q(ch1->start, ch1->time_base,\nch->time_base);",
"if (VAR_2 != VAR_1 && next_start > ch->start && next_start < end)\nend = next_start;",
"}",
"ch->end = (end == INT64_MAX) ? ch->start : end;",
"}",
"}"
]
| [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
13
],
[
15
],
[
17
],
[
19,
21,
23
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
]
]
|
14,666 | static coroutine_fn void nbd_read_reply_entry(void *opaque)
{
NBDClientSession *s = opaque;
uint64_t i;
int ret = 0;
Error *local_err = NULL;
while (!s->quit) {
assert(s->reply.handle == 0);
ret = nbd_receive_reply(s->ioc, &s->reply, &local_err);
if (ret < 0) {
error_report_err(local_err);
}
if (ret <= 0) {
break;
}
/* There's no need for a mutex on the receive side, because the
* handler acts as a synchronization point and ensures that only
* one coroutine is called until the reply finishes.
*/
i = HANDLE_TO_INDEX(s, s->reply.handle);
if (i >= MAX_NBD_REQUESTS ||
!s->requests[i].coroutine ||
!s->requests[i].receiving ||
(nbd_reply_is_structured(&s->reply) && !s->info.structured_reply))
{
break;
}
/* We're woken up again by the request itself. Note that there
* is no race between yielding and reentering read_reply_co. This
* is because:
*
* - if the request runs on the same AioContext, it is only
* entered after we yield
*
* - if the request runs on a different AioContext, reentering
* read_reply_co happens through a bottom half, which can only
* run after we yield.
*/
aio_co_wake(s->requests[i].coroutine);
qemu_coroutine_yield();
}
s->quit = true;
nbd_recv_coroutines_wake_all(s);
s->read_reply_co = NULL;
}
| true | qemu | 08ace1d75372b57c5ab56aea02c71cdda4b58fdf | static coroutine_fn void nbd_read_reply_entry(void *opaque)
{
NBDClientSession *s = opaque;
uint64_t i;
int ret = 0;
Error *local_err = NULL;
while (!s->quit) {
assert(s->reply.handle == 0);
ret = nbd_receive_reply(s->ioc, &s->reply, &local_err);
if (ret < 0) {
error_report_err(local_err);
}
if (ret <= 0) {
break;
}
i = HANDLE_TO_INDEX(s, s->reply.handle);
if (i >= MAX_NBD_REQUESTS ||
!s->requests[i].coroutine ||
!s->requests[i].receiving ||
(nbd_reply_is_structured(&s->reply) && !s->info.structured_reply))
{
break;
}
aio_co_wake(s->requests[i].coroutine);
qemu_coroutine_yield();
}
s->quit = true;
nbd_recv_coroutines_wake_all(s);
s->read_reply_co = NULL;
}
| {
"code": [
" if (ret < 0) {"
],
"line_no": [
21
]
} | static coroutine_fn void FUNC_0(void *opaque)
{
NBDClientSession *s = opaque;
uint64_t i;
int VAR_0 = 0;
Error *local_err = NULL;
while (!s->quit) {
assert(s->reply.handle == 0);
VAR_0 = nbd_receive_reply(s->ioc, &s->reply, &local_err);
if (VAR_0 < 0) {
error_report_err(local_err);
}
if (VAR_0 <= 0) {
break;
}
i = HANDLE_TO_INDEX(s, s->reply.handle);
if (i >= MAX_NBD_REQUESTS ||
!s->requests[i].coroutine ||
!s->requests[i].receiving ||
(nbd_reply_is_structured(&s->reply) && !s->info.structured_reply))
{
break;
}
aio_co_wake(s->requests[i].coroutine);
qemu_coroutine_yield();
}
s->quit = true;
nbd_recv_coroutines_wake_all(s);
s->read_reply_co = NULL;
}
| [
"static coroutine_fn void FUNC_0(void *opaque)\n{",
"NBDClientSession *s = opaque;",
"uint64_t i;",
"int VAR_0 = 0;",
"Error *local_err = NULL;",
"while (!s->quit) {",
"assert(s->reply.handle == 0);",
"VAR_0 = nbd_receive_reply(s->ioc, &s->reply, &local_err);",
"if (VAR_0 < 0) {",
"error_report_err(local_err);",
"}",
"if (VAR_0 <= 0) {",
"break;",
"}",
"i = HANDLE_TO_INDEX(s, s->reply.handle);",
"if (i >= MAX_NBD_REQUESTS ||\n!s->requests[i].coroutine ||\n!s->requests[i].receiving ||\n(nbd_reply_is_structured(&s->reply) && !s->info.structured_reply))\n{",
"break;",
"}",
"aio_co_wake(s->requests[i].coroutine);",
"qemu_coroutine_yield();",
"}",
"s->quit = true;",
"nbd_recv_coroutines_wake_all(s);",
"s->read_reply_co = NULL;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
43
],
[
45,
47,
49,
51,
53
],
[
55
],
[
57
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
]
]
|
14,667 | void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
{
trace_esp_mem_writeb(saddr, s->wregs[saddr], val);
switch (saddr) {
case ESP_TCHI:
s->tchi_written = true;
/* fall through */
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = val & 0xff;
} else if (s->ti_size == TI_BUFSZ - 1) {
trace_esp_error_fifo_overrun();
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = val & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = val;
if (val & CMD_DMA) {
s->dma = 1;
/* Reload DMA counter. */
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
s->rregs[ESP_TCHI] = s->wregs[ESP_TCHI];
} else {
s->dma = 0;
}
switch(val & CMD_CMD) {
case CMD_NOP:
trace_esp_mem_writeb_cmd_nop(val);
break;
case CMD_FLUSH:
trace_esp_mem_writeb_cmd_flush(val);
//s->ti_size = 0;
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
trace_esp_mem_writeb_cmd_reset(val);
esp_soft_reset(s);
break;
case CMD_BUSRESET:
trace_esp_mem_writeb_cmd_bus_reset(val);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
trace_esp_mem_writeb_cmd_iccs(val);
write_response(s);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSTAT] |= STAT_MI;
break;
case CMD_MSGACC:
trace_esp_mem_writeb_cmd_msgacc(val);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
esp_raise_irq(s);
break;
case CMD_PAD:
trace_esp_mem_writeb_cmd_pad(val);
s->rregs[ESP_RSTAT] = STAT_TC;
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
trace_esp_mem_writeb_cmd_satn(val);
break;
case CMD_RSTATN:
trace_esp_mem_writeb_cmd_rstatn(val);
break;
case CMD_SEL:
trace_esp_mem_writeb_cmd_sel(val);
handle_s_without_atn(s);
break;
case CMD_SELATN:
trace_esp_mem_writeb_cmd_selatn(val);
handle_satn(s);
break;
case CMD_SELATNS:
trace_esp_mem_writeb_cmd_selatns(val);
handle_satn_stop(s);
break;
case CMD_ENSEL:
trace_esp_mem_writeb_cmd_ensel(val);
s->rregs[ESP_RINTR] = 0;
break;
case CMD_DISSEL:
trace_esp_mem_writeb_cmd_dissel(val);
s->rregs[ESP_RINTR] = 0;
esp_raise_irq(s);
break;
default:
trace_esp_error_unhandled_command(val);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
case ESP_CFG2: case ESP_CFG3:
case ESP_RES3: case ESP_RES4:
s->rregs[saddr] = val;
break;
case ESP_WCCF ... ESP_WTEST:
break;
default:
trace_esp_error_invalid_write(val, saddr);
return;
}
s->wregs[saddr] = val;
}
| true | qemu | c98c6c105f66f05aa0b7c1d2a4a3f716450907ef | void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
{
trace_esp_mem_writeb(saddr, s->wregs[saddr], val);
switch (saddr) {
case ESP_TCHI:
s->tchi_written = true;
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = val & 0xff;
} else if (s->ti_size == TI_BUFSZ - 1) {
trace_esp_error_fifo_overrun();
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = val & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = val;
if (val & CMD_DMA) {
s->dma = 1;
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
s->rregs[ESP_TCHI] = s->wregs[ESP_TCHI];
} else {
s->dma = 0;
}
switch(val & CMD_CMD) {
case CMD_NOP:
trace_esp_mem_writeb_cmd_nop(val);
break;
case CMD_FLUSH:
trace_esp_mem_writeb_cmd_flush(val);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
trace_esp_mem_writeb_cmd_reset(val);
esp_soft_reset(s);
break;
case CMD_BUSRESET:
trace_esp_mem_writeb_cmd_bus_reset(val);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
trace_esp_mem_writeb_cmd_iccs(val);
write_response(s);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSTAT] |= STAT_MI;
break;
case CMD_MSGACC:
trace_esp_mem_writeb_cmd_msgacc(val);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
esp_raise_irq(s);
break;
case CMD_PAD:
trace_esp_mem_writeb_cmd_pad(val);
s->rregs[ESP_RSTAT] = STAT_TC;
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
trace_esp_mem_writeb_cmd_satn(val);
break;
case CMD_RSTATN:
trace_esp_mem_writeb_cmd_rstatn(val);
break;
case CMD_SEL:
trace_esp_mem_writeb_cmd_sel(val);
handle_s_without_atn(s);
break;
case CMD_SELATN:
trace_esp_mem_writeb_cmd_selatn(val);
handle_satn(s);
break;
case CMD_SELATNS:
trace_esp_mem_writeb_cmd_selatns(val);
handle_satn_stop(s);
break;
case CMD_ENSEL:
trace_esp_mem_writeb_cmd_ensel(val);
s->rregs[ESP_RINTR] = 0;
break;
case CMD_DISSEL:
trace_esp_mem_writeb_cmd_dissel(val);
s->rregs[ESP_RINTR] = 0;
esp_raise_irq(s);
break;
default:
trace_esp_error_unhandled_command(val);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
case ESP_CFG2: case ESP_CFG3:
case ESP_RES3: case ESP_RES4:
s->rregs[saddr] = val;
break;
case ESP_WCCF ... ESP_WTEST:
break;
default:
trace_esp_error_invalid_write(val, saddr);
return;
}
s->wregs[saddr] = val;
}
| {
"code": [
" s->cmdbuf[s->cmdlen++] = val & 0xff;"
],
"line_no": [
27
]
} | void FUNC_0(ESPState *VAR_0, uint32_t VAR_1, uint64_t VAR_2)
{
trace_esp_mem_writeb(VAR_1, VAR_0->wregs[VAR_1], VAR_2);
switch (VAR_1) {
case ESP_TCHI:
VAR_0->tchi_written = true;
case ESP_TCLO:
case ESP_TCMID:
VAR_0->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (VAR_0->do_cmd) {
VAR_0->cmdbuf[VAR_0->cmdlen++] = VAR_2 & 0xff;
} else if (VAR_0->ti_size == TI_BUFSZ - 1) {
trace_esp_error_fifo_overrun();
} else {
VAR_0->ti_size++;
VAR_0->ti_buf[VAR_0->ti_wptr++] = VAR_2 & 0xff;
}
break;
case ESP_CMD:
VAR_0->rregs[VAR_1] = VAR_2;
if (VAR_2 & CMD_DMA) {
VAR_0->dma = 1;
VAR_0->rregs[ESP_TCLO] = VAR_0->wregs[ESP_TCLO];
VAR_0->rregs[ESP_TCMID] = VAR_0->wregs[ESP_TCMID];
VAR_0->rregs[ESP_TCHI] = VAR_0->wregs[ESP_TCHI];
} else {
VAR_0->dma = 0;
}
switch(VAR_2 & CMD_CMD) {
case CMD_NOP:
trace_esp_mem_writeb_cmd_nop(VAR_2);
break;
case CMD_FLUSH:
trace_esp_mem_writeb_cmd_flush(VAR_2);
VAR_0->rregs[ESP_RINTR] = INTR_FC;
VAR_0->rregs[ESP_RSEQ] = 0;
VAR_0->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
trace_esp_mem_writeb_cmd_reset(VAR_2);
esp_soft_reset(VAR_0);
break;
case CMD_BUSRESET:
trace_esp_mem_writeb_cmd_bus_reset(VAR_2);
VAR_0->rregs[ESP_RINTR] = INTR_RST;
if (!(VAR_0->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(VAR_0);
}
break;
case CMD_TI:
handle_ti(VAR_0);
break;
case CMD_ICCS:
trace_esp_mem_writeb_cmd_iccs(VAR_2);
write_response(VAR_0);
VAR_0->rregs[ESP_RINTR] = INTR_FC;
VAR_0->rregs[ESP_RSTAT] |= STAT_MI;
break;
case CMD_MSGACC:
trace_esp_mem_writeb_cmd_msgacc(VAR_2);
VAR_0->rregs[ESP_RINTR] = INTR_DC;
VAR_0->rregs[ESP_RSEQ] = 0;
VAR_0->rregs[ESP_RFLAGS] = 0;
esp_raise_irq(VAR_0);
break;
case CMD_PAD:
trace_esp_mem_writeb_cmd_pad(VAR_2);
VAR_0->rregs[ESP_RSTAT] = STAT_TC;
VAR_0->rregs[ESP_RINTR] = INTR_FC;
VAR_0->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
trace_esp_mem_writeb_cmd_satn(VAR_2);
break;
case CMD_RSTATN:
trace_esp_mem_writeb_cmd_rstatn(VAR_2);
break;
case CMD_SEL:
trace_esp_mem_writeb_cmd_sel(VAR_2);
handle_s_without_atn(VAR_0);
break;
case CMD_SELATN:
trace_esp_mem_writeb_cmd_selatn(VAR_2);
handle_satn(VAR_0);
break;
case CMD_SELATNS:
trace_esp_mem_writeb_cmd_selatns(VAR_2);
handle_satn_stop(VAR_0);
break;
case CMD_ENSEL:
trace_esp_mem_writeb_cmd_ensel(VAR_2);
VAR_0->rregs[ESP_RINTR] = 0;
break;
case CMD_DISSEL:
trace_esp_mem_writeb_cmd_dissel(VAR_2);
VAR_0->rregs[ESP_RINTR] = 0;
esp_raise_irq(VAR_0);
break;
default:
trace_esp_error_unhandled_command(VAR_2);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
case ESP_CFG2: case ESP_CFG3:
case ESP_RES3: case ESP_RES4:
VAR_0->rregs[VAR_1] = VAR_2;
break;
case ESP_WCCF ... ESP_WTEST:
break;
default:
trace_esp_error_invalid_write(VAR_2, VAR_1);
return;
}
VAR_0->wregs[VAR_1] = VAR_2;
}
| [
"void FUNC_0(ESPState *VAR_0, uint32_t VAR_1, uint64_t VAR_2)\n{",
"trace_esp_mem_writeb(VAR_1, VAR_0->wregs[VAR_1], VAR_2);",
"switch (VAR_1) {",
"case ESP_TCHI:\nVAR_0->tchi_written = true;",
"case ESP_TCLO:\ncase ESP_TCMID:\nVAR_0->rregs[ESP_RSTAT] &= ~STAT_TC;",
"break;",
"case ESP_FIFO:\nif (VAR_0->do_cmd) {",
"VAR_0->cmdbuf[VAR_0->cmdlen++] = VAR_2 & 0xff;",
"} else if (VAR_0->ti_size == TI_BUFSZ - 1) {",
"trace_esp_error_fifo_overrun();",
"} else {",
"VAR_0->ti_size++;",
"VAR_0->ti_buf[VAR_0->ti_wptr++] = VAR_2 & 0xff;",
"}",
"break;",
"case ESP_CMD:\nVAR_0->rregs[VAR_1] = VAR_2;",
"if (VAR_2 & CMD_DMA) {",
"VAR_0->dma = 1;",
"VAR_0->rregs[ESP_TCLO] = VAR_0->wregs[ESP_TCLO];",
"VAR_0->rregs[ESP_TCMID] = VAR_0->wregs[ESP_TCMID];",
"VAR_0->rregs[ESP_TCHI] = VAR_0->wregs[ESP_TCHI];",
"} else {",
"VAR_0->dma = 0;",
"}",
"switch(VAR_2 & CMD_CMD) {",
"case CMD_NOP:\ntrace_esp_mem_writeb_cmd_nop(VAR_2);",
"break;",
"case CMD_FLUSH:\ntrace_esp_mem_writeb_cmd_flush(VAR_2);",
"VAR_0->rregs[ESP_RINTR] = INTR_FC;",
"VAR_0->rregs[ESP_RSEQ] = 0;",
"VAR_0->rregs[ESP_RFLAGS] = 0;",
"break;",
"case CMD_RESET:\ntrace_esp_mem_writeb_cmd_reset(VAR_2);",
"esp_soft_reset(VAR_0);",
"break;",
"case CMD_BUSRESET:\ntrace_esp_mem_writeb_cmd_bus_reset(VAR_2);",
"VAR_0->rregs[ESP_RINTR] = INTR_RST;",
"if (!(VAR_0->wregs[ESP_CFG1] & CFG1_RESREPT)) {",
"esp_raise_irq(VAR_0);",
"}",
"break;",
"case CMD_TI:\nhandle_ti(VAR_0);",
"break;",
"case CMD_ICCS:\ntrace_esp_mem_writeb_cmd_iccs(VAR_2);",
"write_response(VAR_0);",
"VAR_0->rregs[ESP_RINTR] = INTR_FC;",
"VAR_0->rregs[ESP_RSTAT] |= STAT_MI;",
"break;",
"case CMD_MSGACC:\ntrace_esp_mem_writeb_cmd_msgacc(VAR_2);",
"VAR_0->rregs[ESP_RINTR] = INTR_DC;",
"VAR_0->rregs[ESP_RSEQ] = 0;",
"VAR_0->rregs[ESP_RFLAGS] = 0;",
"esp_raise_irq(VAR_0);",
"break;",
"case CMD_PAD:\ntrace_esp_mem_writeb_cmd_pad(VAR_2);",
"VAR_0->rregs[ESP_RSTAT] = STAT_TC;",
"VAR_0->rregs[ESP_RINTR] = INTR_FC;",
"VAR_0->rregs[ESP_RSEQ] = 0;",
"break;",
"case CMD_SATN:\ntrace_esp_mem_writeb_cmd_satn(VAR_2);",
"break;",
"case CMD_RSTATN:\ntrace_esp_mem_writeb_cmd_rstatn(VAR_2);",
"break;",
"case CMD_SEL:\ntrace_esp_mem_writeb_cmd_sel(VAR_2);",
"handle_s_without_atn(VAR_0);",
"break;",
"case CMD_SELATN:\ntrace_esp_mem_writeb_cmd_selatn(VAR_2);",
"handle_satn(VAR_0);",
"break;",
"case CMD_SELATNS:\ntrace_esp_mem_writeb_cmd_selatns(VAR_2);",
"handle_satn_stop(VAR_0);",
"break;",
"case CMD_ENSEL:\ntrace_esp_mem_writeb_cmd_ensel(VAR_2);",
"VAR_0->rregs[ESP_RINTR] = 0;",
"break;",
"case CMD_DISSEL:\ntrace_esp_mem_writeb_cmd_dissel(VAR_2);",
"VAR_0->rregs[ESP_RINTR] = 0;",
"esp_raise_irq(VAR_0);",
"break;",
"default:\ntrace_esp_error_unhandled_command(VAR_2);",
"break;",
"}",
"break;",
"case ESP_WBUSID ... ESP_WSYNO:\nbreak;",
"case ESP_CFG1:\ncase ESP_CFG2: case ESP_CFG3:\ncase ESP_RES3: case ESP_RES4:\nVAR_0->rregs[VAR_1] = VAR_2;",
"break;",
"case ESP_WCCF ... ESP_WTEST:\nbreak;",
"default:\ntrace_esp_error_invalid_write(VAR_2, VAR_1);",
"return;",
"}",
"VAR_0->wregs[VAR_1] = VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
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
],
[
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
],
[
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
]
]
|
14,668 | static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs,
int64_t offset, int count)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pdiscard(bs->file->bs, offset, count);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| true | qemu | 6d0ceb80ffe18ad4b28aab7356f440636c0be7be | static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs,
int64_t offset, int count)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pdiscard(bs->file->bs, offset, count);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| {
"code": [
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;",
" uint64_t reqid = request_id++;"
],
"line_no": [
7,
7,
7,
7,
7
]
} | static int VAR_0 blkreplay_co_pdiscard(BlockDriverState *bs,
int64_t offset, int count)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pdiscard(bs->file->bs, offset, count);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| [
"static int VAR_0 blkreplay_co_pdiscard(BlockDriverState *bs,\nint64_t offset, int count)\n{",
"uint64_t reqid = request_id++;",
"int ret = bdrv_co_pdiscard(bs->file->bs, offset, count);",
"block_request_create(reqid, bs, qemu_coroutine_self());",
"qemu_coroutine_yield();",
"return ret;",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
]
|
14,669 | static void init_proc_750 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
/* XXX : not implemented */
spr_register(env, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
/* Time base */
gen_tbl(env);
/* Thermal management */
gen_spr_thrm(env);
/* Hardware implementation registers */
/* XXX : not implemented */
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* XXX : not implemented */
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
/* Memory management */
gen_low_BATs(env);
/* XXX: high BATs are also present but are known to be bugged on
* die version 1.x
*/
init_excp_7x0(env);
env->dcache_line_size = 32;
env->icache_line_size = 32;
/* Allocate hardware IRQ controller */
ppc6xx_irq_init(env);
}
| true | qemu | 9633fcc6a02f23e3ef00aa5fe3fe9c41f57c3456 | static void init_proc_750 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_7xx(env);
spr_register(env, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
gen_tbl(env);
gen_spr_thrm(env);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
gen_low_BATs(env);
init_excp_7x0(env);
env->dcache_line_size = 32;
env->icache_line_size = 32;
ppc6xx_irq_init(env);
}
| {
"code": [
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,",
" &spr_read_generic, NULL,"
],
"line_no": [
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15
]
} | static void FUNC_0 (CPUPPCState *VAR_0)
{
gen_spr_ne_601(VAR_0);
gen_spr_7xx(VAR_0);
spr_register(VAR_0, SPR_L2CR, "L2CR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, NULL,
0x00000000);
gen_tbl(VAR_0);
gen_spr_thrm(VAR_0);
spr_register(VAR_0, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(VAR_0, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
gen_low_BATs(VAR_0);
init_excp_7x0(VAR_0);
VAR_0->dcache_line_size = 32;
VAR_0->icache_line_size = 32;
ppc6xx_irq_init(VAR_0);
}
| [
"static void FUNC_0 (CPUPPCState *VAR_0)\n{",
"gen_spr_ne_601(VAR_0);",
"gen_spr_7xx(VAR_0);",
"spr_register(VAR_0, SPR_L2CR, \"L2CR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, NULL,\n0x00000000);",
"gen_tbl(VAR_0);",
"gen_spr_thrm(VAR_0);",
"spr_register(VAR_0, SPR_HID0, \"HID0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"spr_register(VAR_0, SPR_HID1, \"HID1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);",
"gen_low_BATs(VAR_0);",
"init_excp_7x0(VAR_0);",
"VAR_0->dcache_line_size = 32;",
"VAR_0->icache_line_size = 32;",
"ppc6xx_irq_init(VAR_0);",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15,
17
],
[
21
],
[
25
],
[
31,
33,
35,
37
],
[
41,
43,
45,
47
],
[
51
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
]
]
|
14,670 | static USBDevice *usb_serial_init(const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char label[32];
static int index;
while (*filename && *filename != ':') {
const char *p;
char *e;
if (strstart(filename, "vendorid=", &p)) {
vendorid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
qemu_error("bogus vendor ID %s\n", p);
filename = e;
} else if (strstart(filename, "productid=", &p)) {
productid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
qemu_error("bogus product ID %s\n", p);
filename = e;
} else {
qemu_error("unrecognized serial USB option %s\n", filename);
while(*filename == ',')
filename++;
if (!*filename) {
qemu_error("character device specification needed\n");
filename++;
snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_open(label, filename, NULL);
if (!cdrv)
dev = usb_create(NULL /* FIXME */, "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
| true | qemu | d44168fffa07fc57e61a37da65e9348661dec887 | static USBDevice *usb_serial_init(const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char label[32];
static int index;
while (*filename && *filename != ':') {
const char *p;
char *e;
if (strstart(filename, "vendorid=", &p)) {
vendorid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
qemu_error("bogus vendor ID %s\n", p);
filename = e;
} else if (strstart(filename, "productid=", &p)) {
productid = strtol(p, &e, 16);
if (e == p || (*e && *e != ',' && *e != ':')) {
qemu_error("bogus product ID %s\n", p);
filename = e;
} else {
qemu_error("unrecognized serial USB option %s\n", filename);
while(*filename == ',')
filename++;
if (!*filename) {
qemu_error("character device specification needed\n");
filename++;
snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_open(label, filename, NULL);
if (!cdrv)
dev = usb_create(NULL , "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
| {
"code": [],
"line_no": []
} | static USBDevice *FUNC_0(const char *filename)
{
USBDevice *dev;
CharDriverState *cdrv;
uint32_t vendorid = 0, productid = 0;
char VAR_0[32];
static int VAR_1;
while (*filename && *filename != ':') {
const char *VAR_2;
char *VAR_3;
if (strstart(filename, "vendorid=", &VAR_2)) {
vendorid = strtol(VAR_2, &VAR_3, 16);
if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {
qemu_error("bogus vendor ID %s\n", VAR_2);
filename = VAR_3;
} else if (strstart(filename, "productid=", &VAR_2)) {
productid = strtol(VAR_2, &VAR_3, 16);
if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {
qemu_error("bogus product ID %s\n", VAR_2);
filename = VAR_3;
} else {
qemu_error("unrecognized serial USB option %s\n", filename);
while(*filename == ',')
filename++;
if (!*filename) {
qemu_error("character device specification needed\n");
filename++;
snprintf(VAR_0, sizeof(VAR_0), "usbserial%d", VAR_1++);
cdrv = qemu_chr_open(VAR_0, filename, NULL);
if (!cdrv)
dev = usb_create(NULL , "usb-serial");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
if (vendorid)
qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
if (productid)
qdev_prop_set_uint16(&dev->qdev, "productid", productid);
qdev_init_nofail(&dev->qdev);
return dev;
| [
"static USBDevice *FUNC_0(const char *filename)\n{",
"USBDevice *dev;",
"CharDriverState *cdrv;",
"uint32_t vendorid = 0, productid = 0;",
"char VAR_0[32];",
"static int VAR_1;",
"while (*filename && *filename != ':') {",
"const char *VAR_2;",
"char *VAR_3;",
"if (strstart(filename, \"vendorid=\", &VAR_2)) {",
"vendorid = strtol(VAR_2, &VAR_3, 16);",
"if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {",
"qemu_error(\"bogus vendor ID %s\\n\", VAR_2);",
"filename = VAR_3;",
"} else if (strstart(filename, \"productid=\", &VAR_2)) {",
"productid = strtol(VAR_2, &VAR_3, 16);",
"if (VAR_3 == VAR_2 || (*VAR_3 && *VAR_3 != ',' && *VAR_3 != ':')) {",
"qemu_error(\"bogus product ID %s\\n\", VAR_2);",
"filename = VAR_3;",
"} else {",
"qemu_error(\"unrecognized serial USB option %s\\n\", filename);",
"while(*filename == ',')\nfilename++;",
"if (!*filename) {",
"qemu_error(\"character device specification needed\\n\");",
"filename++;",
"snprintf(VAR_0, sizeof(VAR_0), \"usbserial%d\", VAR_1++);",
"cdrv = qemu_chr_open(VAR_0, filename, NULL);",
"if (!cdrv)\ndev = usb_create(NULL , \"usb-serial\");",
"qdev_prop_set_chr(&dev->qdev, \"chardev\", cdrv);",
"if (vendorid)\nqdev_prop_set_uint16(&dev->qdev, \"vendorid\", vendorid);",
"if (productid)\nqdev_prop_set_uint16(&dev->qdev, \"productid\", productid);",
"qdev_init_nofail(&dev->qdev);",
"return 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
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
58
],
[
60
],
[
64
],
[
68
],
[
70
],
[
72,
77
],
[
82
],
[
84,
86
],
[
88,
90
],
[
92
],
[
96
]
]
|
14,672 | static int gen_neon_zip(int rd, int rm, int size, int q)
{
TCGv tmp, tmp2;
if (size == 3 || (!q && size == 2)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
if (q) {
switch (size) {
case 0:
gen_helper_neon_qzip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_qzip16(tmp, tmp2);
break;
case 2:
gen_helper_neon_qzip32(tmp, tmp2);
break;
default:
abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_zip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_zip16(tmp, tmp2);
break;
default:
abort();
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
return 0;
}
| true | qemu | 600b828c448f108b89e1f864f0420a49ccb70d43 | static int gen_neon_zip(int rd, int rm, int size, int q)
{
TCGv tmp, tmp2;
if (size == 3 || (!q && size == 2)) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
if (q) {
switch (size) {
case 0:
gen_helper_neon_qzip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_qzip16(tmp, tmp2);
break;
case 2:
gen_helper_neon_qzip32(tmp, tmp2);
break;
default:
abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_zip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_zip16(tmp, tmp2);
break;
default:
abort();
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
return 0;
}
| {
"code": [
" if (size == 3 || (!q && size == 2)) {",
" if (size == 3 || (!q && size == 2)) {"
],
"line_no": [
7,
7
]
} | static int FUNC_0(int VAR_0, int VAR_1, int VAR_2, int VAR_3)
{
TCGv tmp, tmp2;
if (VAR_2 == 3 || (!VAR_3 && VAR_2 == 2)) {
return 1;
}
tmp = tcg_const_i32(VAR_0);
tmp2 = tcg_const_i32(VAR_1);
if (VAR_3) {
switch (VAR_2) {
case 0:
gen_helper_neon_qzip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_qzip16(tmp, tmp2);
break;
case 2:
gen_helper_neon_qzip32(tmp, tmp2);
break;
default:
abort();
}
} else {
switch (VAR_2) {
case 0:
gen_helper_neon_zip8(tmp, tmp2);
break;
case 1:
gen_helper_neon_zip16(tmp, tmp2);
break;
default:
abort();
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
return 0;
}
| [
"static int FUNC_0(int VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{",
"TCGv tmp, tmp2;",
"if (VAR_2 == 3 || (!VAR_3 && VAR_2 == 2)) {",
"return 1;",
"}",
"tmp = tcg_const_i32(VAR_0);",
"tmp2 = tcg_const_i32(VAR_1);",
"if (VAR_3) {",
"switch (VAR_2) {",
"case 0:\ngen_helper_neon_qzip8(tmp, tmp2);",
"break;",
"case 1:\ngen_helper_neon_qzip16(tmp, tmp2);",
"break;",
"case 2:\ngen_helper_neon_qzip32(tmp, tmp2);",
"break;",
"default:\nabort();",
"}",
"} else {",
"switch (VAR_2) {",
"case 0:\ngen_helper_neon_zip8(tmp, tmp2);",
"break;",
"case 1:\ngen_helper_neon_zip16(tmp, tmp2);",
"break;",
"default:\nabort();",
"}",
"}",
"tcg_temp_free_i32(tmp);",
"tcg_temp_free_i32(tmp2);",
"return 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
]
| [
[
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
]
]
|
14,674 | target_ulong helper_dmt(target_ulong arg1)
{
// TODO
arg1 = 0;
// rt = arg1
return arg1;
}
| true | qemu | 9ed5726c043958359b0f1fa44ab3e4f25f9d9a47 | target_ulong helper_dmt(target_ulong arg1)
{
arg1 = 0;
return arg1;
}
| {
"code": [
"target_ulong helper_dmt(target_ulong arg1)",
" arg1 = 0;",
" return arg1;",
" arg1 = 0;",
" return arg1;",
" arg1 = 0;",
" return arg1;",
" arg1 = 0;",
" return arg1;"
],
"line_no": [
1,
7,
13,
7,
13,
7,
13,
7,
13
]
} | target_ulong FUNC_0(target_ulong arg1)
{
arg1 = 0;
return arg1;
}
| [
"target_ulong FUNC_0(target_ulong arg1)\n{",
"arg1 = 0;",
"return arg1;",
"}"
]
| [
1,
1,
1,
0
]
| [
[
1,
3
],
[
7
],
[
13
],
[
15
]
]
|
14,676 | static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
PrdtEntry *prdt, int prdt_entries)
{
QPCIDevice *dev;
uint16_t bmdma_base;
uintptr_t guest_prdt;
size_t len;
bool from_dev;
uint8_t status;
int flags;
dev = get_pci_device(&bmdma_base);
flags = cmd & ~0xff;
cmd &= 0xff;
switch (cmd) {
case CMD_READ_DMA:
from_dev = true;
break;
case CMD_WRITE_DMA:
from_dev = false;
break;
default:
g_assert_not_reached();
/* Select device 0 */
outb(IDE_BASE + reg_device, 0 | LBA);
/* Stop any running transfer, clear any pending interrupt */
outb(bmdma_base + bmreg_cmd, 0);
outb(bmdma_base + bmreg_status, BM_STS_INTR);
/* Setup PRDT */
len = sizeof(*prdt) * prdt_entries;
guest_prdt = guest_alloc(guest_malloc, len);
memwrite(guest_prdt, prdt, len);
outl(bmdma_base + bmreg_prdt, guest_prdt);
/* ATA DMA command */
outb(IDE_BASE + reg_nsectors, nb_sectors);
outb(IDE_BASE + reg_lba_low, sector & 0xff);
outb(IDE_BASE + reg_lba_middle, (sector >> 8) & 0xff);
outb(IDE_BASE + reg_lba_high, (sector >> 16) & 0xff);
outb(IDE_BASE + reg_command, cmd);
/* Start DMA transfer */
outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
if (flags & CMDF_ABORT) {
outb(bmdma_base + bmreg_cmd, 0);
/* Wait for the DMA transfer to complete */
do {
status = inb(bmdma_base + bmreg_status);
} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);
g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));
/* Check IDE status code */
assert_bit_set(inb(IDE_BASE + reg_status), DRDY);
assert_bit_clear(inb(IDE_BASE + reg_status), BSY | DRQ);
/* Reading the status register clears the IRQ */
g_assert(!get_irq(IDE_PRIMARY_IRQ));
/* Stop DMA transfer if still active */
if (status & BM_STS_ACTIVE) {
outb(bmdma_base + bmreg_cmd, 0);
free_pci_device(dev);
return status; | true | qemu | d7b7e580096255c766f7b1e7502a9151b95091e8 | static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
PrdtEntry *prdt, int prdt_entries)
{
QPCIDevice *dev;
uint16_t bmdma_base;
uintptr_t guest_prdt;
size_t len;
bool from_dev;
uint8_t status;
int flags;
dev = get_pci_device(&bmdma_base);
flags = cmd & ~0xff;
cmd &= 0xff;
switch (cmd) {
case CMD_READ_DMA:
from_dev = true;
break;
case CMD_WRITE_DMA:
from_dev = false;
break;
default:
g_assert_not_reached();
outb(IDE_BASE + reg_device, 0 | LBA);
outb(bmdma_base + bmreg_cmd, 0);
outb(bmdma_base + bmreg_status, BM_STS_INTR);
len = sizeof(*prdt) * prdt_entries;
guest_prdt = guest_alloc(guest_malloc, len);
memwrite(guest_prdt, prdt, len);
outl(bmdma_base + bmreg_prdt, guest_prdt);
outb(IDE_BASE + reg_nsectors, nb_sectors);
outb(IDE_BASE + reg_lba_low, sector & 0xff);
outb(IDE_BASE + reg_lba_middle, (sector >> 8) & 0xff);
outb(IDE_BASE + reg_lba_high, (sector >> 16) & 0xff);
outb(IDE_BASE + reg_command, cmd);
outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
if (flags & CMDF_ABORT) {
outb(bmdma_base + bmreg_cmd, 0);
do {
status = inb(bmdma_base + bmreg_status);
} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);
g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));
assert_bit_set(inb(IDE_BASE + reg_status), DRDY);
assert_bit_clear(inb(IDE_BASE + reg_status), BSY | DRQ);
g_assert(!get_irq(IDE_PRIMARY_IRQ));
if (status & BM_STS_ACTIVE) {
outb(bmdma_base + bmreg_cmd, 0);
free_pci_device(dev);
return status; | {
"code": [],
"line_no": []
} | static int FUNC_0(int VAR_0, uint64_t VAR_1, int VAR_2,
PrdtEntry *VAR_3, int VAR_4)
{
QPCIDevice *dev;
uint16_t bmdma_base;
uintptr_t guest_prdt;
size_t len;
bool from_dev;
uint8_t status;
int VAR_5;
dev = get_pci_device(&bmdma_base);
VAR_5 = VAR_0 & ~0xff;
VAR_0 &= 0xff;
switch (VAR_0) {
case CMD_READ_DMA:
from_dev = true;
break;
case CMD_WRITE_DMA:
from_dev = false;
break;
default:
g_assert_not_reached();
outb(IDE_BASE + reg_device, 0 | LBA);
outb(bmdma_base + bmreg_cmd, 0);
outb(bmdma_base + bmreg_status, BM_STS_INTR);
len = sizeof(*VAR_3) * VAR_4;
guest_prdt = guest_alloc(guest_malloc, len);
memwrite(guest_prdt, VAR_3, len);
outl(bmdma_base + bmreg_prdt, guest_prdt);
outb(IDE_BASE + reg_nsectors, VAR_2);
outb(IDE_BASE + reg_lba_low, VAR_1 & 0xff);
outb(IDE_BASE + reg_lba_middle, (VAR_1 >> 8) & 0xff);
outb(IDE_BASE + reg_lba_high, (VAR_1 >> 16) & 0xff);
outb(IDE_BASE + reg_command, VAR_0);
outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
if (VAR_5 & CMDF_ABORT) {
outb(bmdma_base + bmreg_cmd, 0);
do {
status = inb(bmdma_base + bmreg_status);
} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);
g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));
assert_bit_set(inb(IDE_BASE + reg_status), DRDY);
assert_bit_clear(inb(IDE_BASE + reg_status), BSY | DRQ);
g_assert(!get_irq(IDE_PRIMARY_IRQ));
if (status & BM_STS_ACTIVE) {
outb(bmdma_base + bmreg_cmd, 0);
free_pci_device(dev);
return status; | [
"static int FUNC_0(int VAR_0, uint64_t VAR_1, int VAR_2,\nPrdtEntry *VAR_3, int VAR_4)\n{",
"QPCIDevice *dev;",
"uint16_t bmdma_base;",
"uintptr_t guest_prdt;",
"size_t len;",
"bool from_dev;",
"uint8_t status;",
"int VAR_5;",
"dev = get_pci_device(&bmdma_base);",
"VAR_5 = VAR_0 & ~0xff;",
"VAR_0 &= 0xff;",
"switch (VAR_0) {",
"case CMD_READ_DMA:\nfrom_dev = true;",
"break;",
"case CMD_WRITE_DMA:\nfrom_dev = false;",
"break;",
"default:\ng_assert_not_reached();",
"outb(IDE_BASE + reg_device, 0 | LBA);",
"outb(bmdma_base + bmreg_cmd, 0);",
"outb(bmdma_base + bmreg_status, BM_STS_INTR);",
"len = sizeof(*VAR_3) * VAR_4;",
"guest_prdt = guest_alloc(guest_malloc, len);",
"memwrite(guest_prdt, VAR_3, len);",
"outl(bmdma_base + bmreg_prdt, guest_prdt);",
"outb(IDE_BASE + reg_nsectors, VAR_2);",
"outb(IDE_BASE + reg_lba_low, VAR_1 & 0xff);",
"outb(IDE_BASE + reg_lba_middle, (VAR_1 >> 8) & 0xff);",
"outb(IDE_BASE + reg_lba_high, (VAR_1 >> 16) & 0xff);",
"outb(IDE_BASE + reg_command, VAR_0);",
"outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));",
"if (VAR_5 & CMDF_ABORT) {",
"outb(bmdma_base + bmreg_cmd, 0);",
"do {",
"status = inb(bmdma_base + bmreg_status);",
"} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);",
"g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));",
"assert_bit_set(inb(IDE_BASE + reg_status), DRDY);",
"assert_bit_clear(inb(IDE_BASE + reg_status), BSY | DRQ);",
"g_assert(!get_irq(IDE_PRIMARY_IRQ));",
"if (status & BM_STS_ACTIVE) {",
"outb(bmdma_base + bmreg_cmd, 0);",
"free_pci_device(dev);",
"return status;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15,
16
],
[
17
],
[
18,
19
],
[
20
],
[
21,
22
],
[
24
],
[
26
],
[
27
],
[
29
],
[
30
],
[
31
],
[
32
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
],
[
40
],
[
41
],
[
42
],
[
44
],
[
45
],
[
46
],
[
47
],
[
49
],
[
50
],
[
52
],
[
54
],
[
55
],
[
56
],
[
57
]
]
|
14,677 | static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested,
uint32_t *byte_len)
{
int num_cq_events = 0, ret = 0;
struct ibv_cq *cq;
void *cq_ctx;
uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
if (ibv_req_notify_cq(rdma->cq, 0)) {
return -1;
}
/* poll cq first */
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
return ret;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("A Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested),
wrid_requested, print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
return 0;
}
while (1) {
/*
* Coroutine doesn't start until process_incoming_migration()
* so don't yield unless we know we're running inside of a coroutine.
*/
if (rdma->migration_started_on_destination) {
yield_until_fd_readable(rdma->comp_channel->fd);
}
if (ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx)) {
perror("ibv_get_cq_event");
goto err_block_for_wrid;
}
num_cq_events++;
if (ibv_req_notify_cq(cq, 0)) {
goto err_block_for_wrid;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
goto err_block_for_wrid;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("B Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested), wrid_requested,
print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
goto success_block_for_wrid;
}
}
success_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return 0;
err_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return ret;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested,
uint32_t *byte_len)
{
int num_cq_events = 0, ret = 0;
struct ibv_cq *cq;
void *cq_ctx;
uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
if (ibv_req_notify_cq(rdma->cq, 0)) {
return -1;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
return ret;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("A Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested),
wrid_requested, print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
return 0;
}
while (1) {
if (rdma->migration_started_on_destination) {
yield_until_fd_readable(rdma->comp_channel->fd);
}
if (ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx)) {
perror("ibv_get_cq_event");
goto err_block_for_wrid;
}
num_cq_events++;
if (ibv_req_notify_cq(cq, 0)) {
goto err_block_for_wrid;
}
while (wr_id != wrid_requested) {
ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len);
if (ret < 0) {
goto err_block_for_wrid;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != wrid_requested) {
DDDPRINTF("B Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(wrid_requested), wrid_requested,
print_wrid(wr_id), wr_id);
}
}
if (wr_id == wrid_requested) {
goto success_block_for_wrid;
}
}
success_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return 0;
err_block_for_wrid:
if (num_cq_events) {
ibv_ack_cq_events(cq, num_cq_events);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(RDMAContext *VAR_0, int VAR_1,
uint32_t *VAR_2)
{
int VAR_3 = 0, VAR_4 = 0;
struct ibv_cq *VAR_5;
void *VAR_6;
uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;
if (ibv_req_notify_cq(VAR_0->VAR_5, 0)) {
return -1;
}
while (wr_id != VAR_1) {
VAR_4 = qemu_rdma_poll(VAR_0, &wr_id_in, VAR_2);
if (VAR_4 < 0) {
return VAR_4;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != VAR_1) {
DDDPRINTF("A Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(VAR_1),
VAR_1, print_wrid(wr_id), wr_id);
}
}
if (wr_id == VAR_1) {
return 0;
}
while (1) {
if (VAR_0->migration_started_on_destination) {
yield_until_fd_readable(VAR_0->comp_channel->fd);
}
if (ibv_get_cq_event(VAR_0->comp_channel, &VAR_5, &VAR_6)) {
perror("ibv_get_cq_event");
goto err_block_for_wrid;
}
VAR_3++;
if (ibv_req_notify_cq(VAR_5, 0)) {
goto err_block_for_wrid;
}
while (wr_id != VAR_1) {
VAR_4 = qemu_rdma_poll(VAR_0, &wr_id_in, VAR_2);
if (VAR_4 < 0) {
goto err_block_for_wrid;
}
wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;
if (wr_id == RDMA_WRID_NONE) {
break;
}
if (wr_id != VAR_1) {
DDDPRINTF("B Wanted wrid %s (%d) but got %s (%" PRIu64 ")\n",
print_wrid(VAR_1), VAR_1,
print_wrid(wr_id), wr_id);
}
}
if (wr_id == VAR_1) {
goto success_block_for_wrid;
}
}
success_block_for_wrid:
if (VAR_3) {
ibv_ack_cq_events(VAR_5, VAR_3);
}
return 0;
err_block_for_wrid:
if (VAR_3) {
ibv_ack_cq_events(VAR_5, VAR_3);
}
return VAR_4;
}
| [
"static int FUNC_0(RDMAContext *VAR_0, int VAR_1,\nuint32_t *VAR_2)\n{",
"int VAR_3 = 0, VAR_4 = 0;",
"struct ibv_cq *VAR_5;",
"void *VAR_6;",
"uint64_t wr_id = RDMA_WRID_NONE, wr_id_in;",
"if (ibv_req_notify_cq(VAR_0->VAR_5, 0)) {",
"return -1;",
"}",
"while (wr_id != VAR_1) {",
"VAR_4 = qemu_rdma_poll(VAR_0, &wr_id_in, VAR_2);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;",
"if (wr_id == RDMA_WRID_NONE) {",
"break;",
"}",
"if (wr_id != VAR_1) {",
"DDDPRINTF(\"A Wanted wrid %s (%d) but got %s (%\" PRIu64 \")\\n\",\nprint_wrid(VAR_1),\nVAR_1, print_wrid(wr_id), wr_id);",
"}",
"}",
"if (wr_id == VAR_1) {",
"return 0;",
"}",
"while (1) {",
"if (VAR_0->migration_started_on_destination) {",
"yield_until_fd_readable(VAR_0->comp_channel->fd);",
"}",
"if (ibv_get_cq_event(VAR_0->comp_channel, &VAR_5, &VAR_6)) {",
"perror(\"ibv_get_cq_event\");",
"goto err_block_for_wrid;",
"}",
"VAR_3++;",
"if (ibv_req_notify_cq(VAR_5, 0)) {",
"goto err_block_for_wrid;",
"}",
"while (wr_id != VAR_1) {",
"VAR_4 = qemu_rdma_poll(VAR_0, &wr_id_in, VAR_2);",
"if (VAR_4 < 0) {",
"goto err_block_for_wrid;",
"}",
"wr_id = wr_id_in & RDMA_WRID_TYPE_MASK;",
"if (wr_id == RDMA_WRID_NONE) {",
"break;",
"}",
"if (wr_id != VAR_1) {",
"DDDPRINTF(\"B Wanted wrid %s (%d) but got %s (%\" PRIu64 \")\\n\",\nprint_wrid(VAR_1), VAR_1,\nprint_wrid(wr_id), wr_id);",
"}",
"}",
"if (wr_id == VAR_1) {",
"goto success_block_for_wrid;",
"}",
"}",
"success_block_for_wrid:\nif (VAR_3) {",
"ibv_ack_cq_events(VAR_5, VAR_3);",
"}",
"return 0;",
"err_block_for_wrid:\nif (VAR_3) {",
"ibv_ack_cq_events(VAR_5, VAR_3);",
"}",
"return VAR_4;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
69
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135,
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
167,
169
],
[
171
],
[
173
],
[
175
],
[
177
]
]
|
14,678 | static int svq1_decode_delta_block(AVCodecContext *avctx, DSPContext *dsp,
GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint32_t block_type;
int result = 0;
/* get block type */
block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
/* reset motion vectors */
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
motion[0].x =
motion[0].y =
motion[x / 8 + 2].x =
motion[x / 8 + 2].y =
motion[x / 8 + 3].x =
motion[x / 8 + 3].y = 0;
}
switch (block_type) {
case SVQ1_BLOCK_SKIP:
svq1_skip_block(current, previous, pitch, x, y);
break;
case SVQ1_BLOCK_INTER:
result = svq1_motion_inter_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTER_4V:
result = svq1_motion_inter_4v_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTRA:
result = svq1_decode_block_intra(bitbuf, current, pitch);
break;
}
return result;
}
| true | FFmpeg | ecff5acb5a738fcb4f9e206a12070dac4bf259b3 | static int svq1_decode_delta_block(AVCodecContext *avctx, DSPContext *dsp,
GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint32_t block_type;
int result = 0;
block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
motion[0].x =
motion[0].y =
motion[x / 8 + 2].x =
motion[x / 8 + 2].y =
motion[x / 8 + 3].x =
motion[x / 8 + 3].y = 0;
}
switch (block_type) {
case SVQ1_BLOCK_SKIP:
svq1_skip_block(current, previous, pitch, x, y);
break;
case SVQ1_BLOCK_INTER:
result = svq1_motion_inter_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTER_4V:
result = svq1_motion_inter_4v_block(dsp, bitbuf, current, previous,
pitch, motion, x, y);
if (result != 0) {
av_dlog(avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra(bitbuf, current, pitch);
break;
case SVQ1_BLOCK_INTRA:
result = svq1_decode_block_intra(bitbuf, current, pitch);
break;
}
return result;
}
| {
"code": [
" int pitch, svq1_pmv *motion, int x, int y)",
" int pitch, svq1_pmv *motion, int x, int y)",
" pitch, motion, x, y);",
" pitch, motion, x, y);"
],
"line_no": [
7,
7,
57,
79
]
} | static int FUNC_0(AVCodecContext *VAR_0, DSPContext *VAR_1,
GetBitContext *VAR_2,
uint8_t *VAR_3, uint8_t *VAR_4,
int VAR_5, svq1_pmv *VAR_6, int VAR_7, int VAR_8)
{
uint32_t block_type;
int VAR_9 = 0;
block_type = get_vlc2(VAR_2, svq1_block_type.table, 2, 2);
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
VAR_6[0].VAR_7 =
VAR_6[0].VAR_8 =
VAR_6[VAR_7 / 8 + 2].VAR_7 =
VAR_6[VAR_7 / 8 + 2].VAR_8 =
VAR_6[VAR_7 / 8 + 3].VAR_7 =
VAR_6[VAR_7 / 8 + 3].VAR_8 = 0;
}
switch (block_type) {
case SVQ1_BLOCK_SKIP:
svq1_skip_block(VAR_3, VAR_4, VAR_5, VAR_7, VAR_8);
break;
case SVQ1_BLOCK_INTER:
VAR_9 = svq1_motion_inter_block(VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6, VAR_7, VAR_8);
if (VAR_9 != 0) {
av_dlog(VAR_0, "Error in svq1_motion_inter_block %i\n", VAR_9);
break;
}
VAR_9 = svq1_decode_block_non_intra(VAR_2, VAR_3, VAR_5);
break;
case SVQ1_BLOCK_INTER_4V:
VAR_9 = svq1_motion_inter_4v_block(VAR_1, VAR_2, VAR_3, VAR_4,
VAR_5, VAR_6, VAR_7, VAR_8);
if (VAR_9 != 0) {
av_dlog(VAR_0, "Error in svq1_motion_inter_4v_block %i\n", VAR_9);
break;
}
VAR_9 = svq1_decode_block_non_intra(VAR_2, VAR_3, VAR_5);
break;
case SVQ1_BLOCK_INTRA:
VAR_9 = svq1_decode_block_intra(VAR_2, VAR_3, VAR_5);
break;
}
return VAR_9;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, DSPContext *VAR_1,\nGetBitContext *VAR_2,\nuint8_t *VAR_3, uint8_t *VAR_4,\nint VAR_5, svq1_pmv *VAR_6, int VAR_7, int VAR_8)\n{",
"uint32_t block_type;",
"int VAR_9 = 0;",
"block_type = get_vlc2(VAR_2, svq1_block_type.table, 2, 2);",
"if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {",
"VAR_6[0].VAR_7 =\nVAR_6[0].VAR_8 =\nVAR_6[VAR_7 / 8 + 2].VAR_7 =\nVAR_6[VAR_7 / 8 + 2].VAR_8 =\nVAR_6[VAR_7 / 8 + 3].VAR_7 =\nVAR_6[VAR_7 / 8 + 3].VAR_8 = 0;",
"}",
"switch (block_type) {",
"case SVQ1_BLOCK_SKIP:\nsvq1_skip_block(VAR_3, VAR_4, VAR_5, VAR_7, VAR_8);",
"break;",
"case SVQ1_BLOCK_INTER:\nVAR_9 = svq1_motion_inter_block(VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6, VAR_7, VAR_8);",
"if (VAR_9 != 0) {",
"av_dlog(VAR_0, \"Error in svq1_motion_inter_block %i\\n\", VAR_9);",
"break;",
"}",
"VAR_9 = svq1_decode_block_non_intra(VAR_2, VAR_3, VAR_5);",
"break;",
"case SVQ1_BLOCK_INTER_4V:\nVAR_9 = svq1_motion_inter_4v_block(VAR_1, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6, VAR_7, VAR_8);",
"if (VAR_9 != 0) {",
"av_dlog(VAR_0, \"Error in svq1_motion_inter_4v_block %i\\n\", VAR_9);",
"break;",
"}",
"VAR_9 = svq1_decode_block_non_intra(VAR_2, VAR_3, VAR_5);",
"break;",
"case SVQ1_BLOCK_INTRA:\nVAR_9 = svq1_decode_block_intra(VAR_2, VAR_3, VAR_5);",
"break;",
"}",
"return VAR_9;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
19
],
[
25
],
[
27,
29,
31,
33,
35,
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
53,
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
],
[
103
],
[
107
],
[
109
]
]
|
14,681 | static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
{
int i;
m->style_entries = AV_RB16(tsmb);
tsmb += 2;
// A single style record is of length 12 bytes.
if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)
return -1;
m->box_flags |= STYL_BOX;
for(i = 0; i < m->style_entries; i++) {
m->s_temp = av_malloc(sizeof(*m->s_temp));
if (!m->s_temp) {
mov_text_cleanup(m);
return AVERROR(ENOMEM);
}
m->s_temp->style_start = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_end = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_fontID = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_flag = AV_RB8(tsmb);
tsmb++;
m->s_temp->fontsize = AV_RB8(tsmb);
av_dynarray_add(&m->s, &m->count_s, m->s_temp);
if(!m->s) {
mov_text_cleanup(m);
return AVERROR(ENOMEM);
}
tsmb++;
// text-color-rgba
tsmb += 4;
}
return 0;
}
| true | FFmpeg | e248522d1b0d6dd8641f382cd5c4338d0ecd98e5 | static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
{
int i;
m->style_entries = AV_RB16(tsmb);
tsmb += 2;
if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)
return -1;
m->box_flags |= STYL_BOX;
for(i = 0; i < m->style_entries; i++) {
m->s_temp = av_malloc(sizeof(*m->s_temp));
if (!m->s_temp) {
mov_text_cleanup(m);
return AVERROR(ENOMEM);
}
m->s_temp->style_start = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_end = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_fontID = AV_RB16(tsmb);
tsmb += 2;
m->s_temp->style_flag = AV_RB8(tsmb);
tsmb++;
m->s_temp->fontsize = AV_RB8(tsmb);
av_dynarray_add(&m->s, &m->count_s, m->s_temp);
if(!m->s) {
mov_text_cleanup(m);
return AVERROR(ENOMEM);
}
tsmb++;
tsmb += 4;
}
return 0;
}
| {
"code": [
" m->style_entries = AV_RB16(tsmb);",
" if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size)"
],
"line_no": [
7,
13
]
} | static int FUNC_0(const uint8_t *VAR_0, MovTextContext *VAR_1, AVPacket *VAR_2)
{
int VAR_3;
VAR_1->style_entries = AV_RB16(VAR_0);
VAR_0 += 2;
if (VAR_1->tracksize + VAR_1->size_var + 2 + VAR_1->style_entries * 12 > VAR_2->size)
return -1;
VAR_1->box_flags |= STYL_BOX;
for(VAR_3 = 0; VAR_3 < VAR_1->style_entries; VAR_3++) {
VAR_1->s_temp = av_malloc(sizeof(*VAR_1->s_temp));
if (!VAR_1->s_temp) {
mov_text_cleanup(VAR_1);
return AVERROR(ENOMEM);
}
VAR_1->s_temp->style_start = AV_RB16(VAR_0);
VAR_0 += 2;
VAR_1->s_temp->style_end = AV_RB16(VAR_0);
VAR_0 += 2;
VAR_1->s_temp->style_fontID = AV_RB16(VAR_0);
VAR_0 += 2;
VAR_1->s_temp->style_flag = AV_RB8(VAR_0);
VAR_0++;
VAR_1->s_temp->fontsize = AV_RB8(VAR_0);
av_dynarray_add(&VAR_1->s, &VAR_1->count_s, VAR_1->s_temp);
if(!VAR_1->s) {
mov_text_cleanup(VAR_1);
return AVERROR(ENOMEM);
}
VAR_0++;
VAR_0 += 4;
}
return 0;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, MovTextContext *VAR_1, AVPacket *VAR_2)\n{",
"int VAR_3;",
"VAR_1->style_entries = AV_RB16(VAR_0);",
"VAR_0 += 2;",
"if (VAR_1->tracksize + VAR_1->size_var + 2 + VAR_1->style_entries * 12 > VAR_2->size)\nreturn -1;",
"VAR_1->box_flags |= STYL_BOX;",
"for(VAR_3 = 0; VAR_3 < VAR_1->style_entries; VAR_3++) {",
"VAR_1->s_temp = av_malloc(sizeof(*VAR_1->s_temp));",
"if (!VAR_1->s_temp) {",
"mov_text_cleanup(VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"VAR_1->s_temp->style_start = AV_RB16(VAR_0);",
"VAR_0 += 2;",
"VAR_1->s_temp->style_end = AV_RB16(VAR_0);",
"VAR_0 += 2;",
"VAR_1->s_temp->style_fontID = AV_RB16(VAR_0);",
"VAR_0 += 2;",
"VAR_1->s_temp->style_flag = AV_RB8(VAR_0);",
"VAR_0++;",
"VAR_1->s_temp->fontsize = AV_RB8(VAR_0);",
"av_dynarray_add(&VAR_1->s, &VAR_1->count_s, VAR_1->s_temp);",
"if(!VAR_1->s) {",
"mov_text_cleanup(VAR_1);",
"return AVERROR(ENOMEM);",
"}",
"VAR_0++;",
"VAR_0 += 4;",
"}",
"return 0;",
"}"
]
| [
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
]
]
|
14,682 | static void opt_pass(const char *pass_str)
{
int pass;
pass = atoi(pass_str);
if (pass != 1 && pass != 2) {
fprintf(stderr, "pass number can be only 1 or 2\n");
ffmpeg_exit(1);
}
do_pass = pass;
}
| false | FFmpeg | dbe94539469b6d5113b37ea45eaf69ddbe34154e | static void opt_pass(const char *pass_str)
{
int pass;
pass = atoi(pass_str);
if (pass != 1 && pass != 2) {
fprintf(stderr, "pass number can be only 1 or 2\n");
ffmpeg_exit(1);
}
do_pass = pass;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0)
{
int VAR_1;
VAR_1 = atoi(VAR_0);
if (VAR_1 != 1 && VAR_1 != 2) {
fprintf(stderr, "VAR_1 number can be only 1 or 2\n");
ffmpeg_exit(1);
}
do_pass = VAR_1;
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"int VAR_1;",
"VAR_1 = atoi(VAR_0);",
"if (VAR_1 != 1 && VAR_1 != 2) {",
"fprintf(stderr, \"VAR_1 number can be only 1 or 2\\n\");",
"ffmpeg_exit(1);",
"}",
"do_pass = VAR_1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
]
]
|
14,683 | float av_int2flt(int32_t v){
if(v+v > 0xFF000000U)
return NAN;
return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
}
| true | FFmpeg | 88d1e2b2b0a129365a62efd666db0394e8ffbe08 | float av_int2flt(int32_t v){
if(v+v > 0xFF000000U)
return NAN;
return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
}
| {
"code": [
" if(v+v > 0xFF000000U)"
],
"line_no": [
3
]
} | float FUNC_0(int32_t VAR_0){
if(VAR_0+VAR_0 > 0xFF000000U)
return NAN;
return ldexp(((VAR_0&0x7FFFFF) + (1<<23)) * (VAR_0>>31|1), (VAR_0>>23&0xFF)-150);
}
| [
"float FUNC_0(int32_t VAR_0){",
"if(VAR_0+VAR_0 > 0xFF000000U)\nreturn NAN;",
"return ldexp(((VAR_0&0x7FFFFF) + (1<<23)) * (VAR_0>>31|1), (VAR_0>>23&0xFF)-150);",
"}"
]
| [
0,
1,
0,
0
]
| [
[
1
],
[
3,
5
],
[
7
],
[
9
]
]
|
14,684 | static int opt_deinterlace(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt);
do_deinterlace = 1;
return 0;
}
| false | FFmpeg | 4257b804e2354db07e66ebfd966d7d13f49c7895 | static int opt_deinterlace(void *optctx, const char *opt, const char *arg)
{
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", opt);
do_deinterlace = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2)
{
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -filter:v yadif instead\n", VAR_1);
do_deinterlace = 1;
return 0;
}
| [
"static int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"av_log(NULL, AV_LOG_WARNING, \"-%s is deprecated, use -filter:v yadif instead\\n\", VAR_1);",
"do_deinterlace = 1;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
14,685 | int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
SchroFrameFormat *schro_frame_fmt)
{
unsigned int num_formats = sizeof(schro_pixel_format_map) /
sizeof(schro_pixel_format_map[0]);
int idx;
for (idx = 0; idx < num_formats; ++idx) {
if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
*schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt;
return 0;
}
}
return -1;
}
| true | FFmpeg | 220b24c7c97dc033ceab1510549f66d0e7b52ef1 | int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,
SchroFrameFormat *schro_frame_fmt)
{
unsigned int num_formats = sizeof(schro_pixel_format_map) /
sizeof(schro_pixel_format_map[0]);
int idx;
for (idx = 0; idx < num_formats; ++idx) {
if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {
*schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt;
return 0;
}
}
return -1;
}
| {
"code": [
"int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt,",
" SchroFrameFormat *schro_frame_fmt)",
" unsigned int num_formats = sizeof(schro_pixel_format_map) /",
" sizeof(schro_pixel_format_map[0]);",
" int idx;",
" for (idx = 0; idx < num_formats; ++idx) {",
" if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) {",
" *schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt;",
" return 0;",
" return -1;",
" int idx;",
" int idx;",
" for (idx = 0; idx < num_formats; ++idx) {",
" return 0;",
" return -1;"
],
"line_no": [
1,
3,
7,
9,
13,
17,
19,
21,
23,
29,
13,
13,
17,
23,
29
]
} | int FUNC_0 (SchroChromaFormat VAR_0,
SchroFrameFormat *VAR_1)
{
unsigned int VAR_2 = sizeof(schro_pixel_format_map) /
sizeof(schro_pixel_format_map[0]);
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_2; ++VAR_3) {
if (schro_pixel_format_map[VAR_3].VAR_0 == VAR_0) {
*VAR_1 = schro_pixel_format_map[VAR_3].VAR_1;
return 0;
}
}
return -1;
}
| [
"int FUNC_0 (SchroChromaFormat VAR_0,\nSchroFrameFormat *VAR_1)\n{",
"unsigned int VAR_2 = sizeof(schro_pixel_format_map) /\nsizeof(schro_pixel_format_map[0]);",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_2; ++VAR_3) {",
"if (schro_pixel_format_map[VAR_3].VAR_0 == VAR_0) {",
"*VAR_1 = schro_pixel_format_map[VAR_3].VAR_1;",
"return 0;",
"}",
"}",
"return -1;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0
]
| [
[
1,
3,
5
],
[
7,
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
]
|
14,686 | static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
{
int bit, x = 0;
if (vp56_rac_get_prob_branchy(c, p[0])) {
int i;
for (i = 0; i < 3; i++)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
for (i = 9; i > 3; i--)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))
x += 8;
} else {
// small_mvtree
const uint8_t *ps = p + 2;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + 3 * bit;
x += 4 * bit;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + bit;
x += 2 * bit;
x += vp56_rac_get_prob(c, *ps);
}
return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
{
int bit, x = 0;
if (vp56_rac_get_prob_branchy(c, p[0])) {
int i;
for (i = 0; i < 3; i++)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
for (i = 9; i > 3; i--)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))
x += 8;
} else {
const uint8_t *ps = p + 2;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + 3 * bit;
x += 4 * bit;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + bit;
x += 2 * bit;
x += vp56_rac_get_prob(c, *ps);
}
return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
}
| {
"code": [
"static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)",
" for (i = 9; i > 3; i--)",
" if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))"
],
"line_no": [
1,
19,
23
]
} | static int FUNC_0(VP56RangeCoder *VAR_0, const uint8_t *VAR_1)
{
int VAR_2, VAR_3 = 0;
if (vp56_rac_get_prob_branchy(VAR_0, VAR_1[0])) {
int VAR_4;
for (VAR_4 = 0; VAR_4 < 3; VAR_4++)
VAR_3 += vp56_rac_get_prob(VAR_0, VAR_1[9 + VAR_4]) << VAR_4;
for (VAR_4 = 9; VAR_4 > 3; VAR_4--)
VAR_3 += vp56_rac_get_prob(VAR_0, VAR_1[9 + VAR_4]) << VAR_4;
if (!(VAR_3 & 0xFFF0) || vp56_rac_get_prob(VAR_0, VAR_1[12]))
VAR_3 += 8;
} else {
const uint8_t *VAR_5 = VAR_1 + 2;
VAR_2 = vp56_rac_get_prob(VAR_0, *VAR_5);
VAR_5 += 1 + 3 * VAR_2;
VAR_3 += 4 * VAR_2;
VAR_2 = vp56_rac_get_prob(VAR_0, *VAR_5);
VAR_5 += 1 + VAR_2;
VAR_3 += 2 * VAR_2;
VAR_3 += vp56_rac_get_prob(VAR_0, *VAR_5);
}
return (VAR_3 && vp56_rac_get_prob(VAR_0, VAR_1[1])) ? -VAR_3 : VAR_3;
}
| [
"static int FUNC_0(VP56RangeCoder *VAR_0, const uint8_t *VAR_1)\n{",
"int VAR_2, VAR_3 = 0;",
"if (vp56_rac_get_prob_branchy(VAR_0, VAR_1[0])) {",
"int VAR_4;",
"for (VAR_4 = 0; VAR_4 < 3; VAR_4++)",
"VAR_3 += vp56_rac_get_prob(VAR_0, VAR_1[9 + VAR_4]) << VAR_4;",
"for (VAR_4 = 9; VAR_4 > 3; VAR_4--)",
"VAR_3 += vp56_rac_get_prob(VAR_0, VAR_1[9 + VAR_4]) << VAR_4;",
"if (!(VAR_3 & 0xFFF0) || vp56_rac_get_prob(VAR_0, VAR_1[12]))\nVAR_3 += 8;",
"} else {",
"const uint8_t *VAR_5 = VAR_1 + 2;",
"VAR_2 = vp56_rac_get_prob(VAR_0, *VAR_5);",
"VAR_5 += 1 + 3 * VAR_2;",
"VAR_3 += 4 * VAR_2;",
"VAR_2 = vp56_rac_get_prob(VAR_0, *VAR_5);",
"VAR_5 += 1 + VAR_2;",
"VAR_3 += 2 * VAR_2;",
"VAR_3 += vp56_rac_get_prob(VAR_0, *VAR_5);",
"}",
"return (VAR_3 && vp56_rac_get_prob(VAR_0, VAR_1[1])) ? -VAR_3 : VAR_3;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.