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
|
---|---|---|---|---|---|---|---|---|---|---|
17,081 | static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
{
int retval;
retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, "sq", fs_path, size);
if (retval < 0) {
errno = -retval;
return -1;
}
return 0;
}
| false | qemu | 494a8ebe713055d3946183f4b395f85a18b43e9e | static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
{
int retval;
retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, "sq", fs_path, size);
if (retval < 0) {
errno = -retval;
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, off_t VAR_2)
{
int VAR_3;
VAR_3 = v9fs_request(VAR_0->private, T_TRUNCATE, NULL, "sq", VAR_1, VAR_2);
if (VAR_3 < 0) {
errno = -VAR_3;
return -1;
}
return 0;
}
| [
"static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, off_t VAR_2)\n{",
"int VAR_3;",
"VAR_3 = v9fs_request(VAR_0->private, T_TRUNCATE, NULL, \"sq\", VAR_1, VAR_2);",
"if (VAR_3 < 0) {",
"errno = -VAR_3;",
"return -1;",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
]
|
17,083 | static uint64_t e1000_io_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
E1000State *s = opaque;
(void)s;
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t e1000_io_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
E1000State *s = opaque;
(void)s;
return 0;
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
E1000State *s = opaque;
(void)s;
return 0;
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"E1000State *s = opaque;",
"(void)s;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
]
]
|
17,084 | static void pci_vpb_init(Object *obj)
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
PCIVPBState *s = PCI_VPB(obj);
memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32);
memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32);
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), "pci",
&s->pci_mem_space, &s->pci_io_space,
PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus;
object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST);
qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus));
/* Window sizes for VersatilePB; realview_pci's init will override */
s->mem_win_size[0] = 0x0c000000;
s->mem_win_size[1] = 0x10000000;
s->mem_win_size[2] = 0x10000000;
}
| false | qemu | d28fca153bb27ff965b9eb26d73327fa4d2402c8 | static void pci_vpb_init(Object *obj)
{
PCIHostState *h = PCI_HOST_BRIDGE(obj);
PCIVPBState *s = PCI_VPB(obj);
memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32);
memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32);
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), "pci",
&s->pci_mem_space, &s->pci_io_space,
PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus;
object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST);
qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus));
s->mem_win_size[0] = 0x0c000000;
s->mem_win_size[1] = 0x10000000;
s->mem_win_size[2] = 0x10000000;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
PCIHostState *h = PCI_HOST_BRIDGE(VAR_0);
PCIVPBState *s = PCI_VPB(VAR_0);
memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32);
memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32);
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(VAR_0), "pci",
&s->pci_mem_space, &s->pci_io_space,
PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus;
object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST);
qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus));
s->mem_win_size[0] = 0x0c000000;
s->mem_win_size[1] = 0x10000000;
s->mem_win_size[2] = 0x10000000;
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"PCIHostState *h = PCI_HOST_BRIDGE(VAR_0);",
"PCIVPBState *s = PCI_VPB(VAR_0);",
"memory_region_init(&s->pci_io_space, OBJECT(s), \"pci_io\", 1ULL << 32);",
"memory_region_init(&s->pci_mem_space, OBJECT(s), \"pci_mem\", 1ULL << 32);",
"pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(VAR_0), \"pci\",\n&s->pci_mem_space, &s->pci_io_space,\nPCI_DEVFN(11, 0), TYPE_PCI_BUS);",
"h->bus = &s->pci_bus;",
"object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST);",
"qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus));",
"s->mem_win_size[0] = 0x0c000000;",
"s->mem_win_size[1] = 0x10000000;",
"s->mem_win_size[2] = 0x10000000;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17,
19,
21
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
]
]
|
17,086 | BlockDriverState *bdrv_new(const char *device_name)
{
BlockDriverState *bs;
bs = g_malloc0(sizeof(BlockDriverState));
QLIST_INIT(&bs->dirty_bitmaps);
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
if (device_name[0] != '\0') {
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
}
bdrv_iostatus_disable(bs);
notifier_list_init(&bs->close_notifiers);
notifier_with_return_list_init(&bs->before_write_notifiers);
qemu_co_queue_init(&bs->throttled_reqs[0]);
qemu_co_queue_init(&bs->throttled_reqs[1]);
bs->refcnt = 1;
return bs;
}
| false | qemu | 98522f63f40adaebc412481e1d2e9170160d4539 | BlockDriverState *bdrv_new(const char *device_name)
{
BlockDriverState *bs;
bs = g_malloc0(sizeof(BlockDriverState));
QLIST_INIT(&bs->dirty_bitmaps);
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
if (device_name[0] != '\0') {
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
}
bdrv_iostatus_disable(bs);
notifier_list_init(&bs->close_notifiers);
notifier_with_return_list_init(&bs->before_write_notifiers);
qemu_co_queue_init(&bs->throttled_reqs[0]);
qemu_co_queue_init(&bs->throttled_reqs[1]);
bs->refcnt = 1;
return bs;
}
| {
"code": [],
"line_no": []
} | BlockDriverState *FUNC_0(const char *device_name)
{
BlockDriverState *bs;
bs = g_malloc0(sizeof(BlockDriverState));
QLIST_INIT(&bs->dirty_bitmaps);
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
if (device_name[0] != '\0') {
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
}
bdrv_iostatus_disable(bs);
notifier_list_init(&bs->close_notifiers);
notifier_with_return_list_init(&bs->before_write_notifiers);
qemu_co_queue_init(&bs->throttled_reqs[0]);
qemu_co_queue_init(&bs->throttled_reqs[1]);
bs->refcnt = 1;
return bs;
}
| [
"BlockDriverState *FUNC_0(const char *device_name)\n{",
"BlockDriverState *bs;",
"bs = g_malloc0(sizeof(BlockDriverState));",
"QLIST_INIT(&bs->dirty_bitmaps);",
"pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);",
"if (device_name[0] != '\\0') {",
"QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);",
"}",
"bdrv_iostatus_disable(bs);",
"notifier_list_init(&bs->close_notifiers);",
"notifier_with_return_list_init(&bs->before_write_notifiers);",
"qemu_co_queue_init(&bs->throttled_reqs[0]);",
"qemu_co_queue_init(&bs->throttled_reqs[1]);",
"bs->refcnt = 1;",
"return bs;",
"}"
]
| [
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
]
]
|
17,087 | static inline int get_scale(GetBitContext *gb, int level, int value)
{
if (level < 5) {
/* huffman encoded */
value += get_bitalloc(gb, &dca_scalefactor, level);
} else if (level < 8)
value = get_bits(gb, level + 1);
return value;
}
| false | FFmpeg | e6ffd997cbc06426e75d3fa291b991866c84a79b | static inline int get_scale(GetBitContext *gb, int level, int value)
{
if (level < 5) {
value += get_bitalloc(gb, &dca_scalefactor, level);
} else if (level < 8)
value = get_bits(gb, level + 1);
return value;
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2)
{
if (VAR_1 < 5) {
VAR_2 += get_bitalloc(VAR_0, &dca_scalefactor, VAR_1);
} else if (VAR_1 < 8)
VAR_2 = get_bits(VAR_0, VAR_1 + 1);
return VAR_2;
}
| [
"static inline int FUNC_0(GetBitContext *VAR_0, int VAR_1, int VAR_2)\n{",
"if (VAR_1 < 5) {",
"VAR_2 += get_bitalloc(VAR_0, &dca_scalefactor, VAR_1);",
"} else if (VAR_1 < 8)",
"VAR_2 = get_bits(VAR_0, VAR_1 + 1);",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
]
|
17,089 | int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,
int rw, int mmu_idx)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
target_ulong vaddr, raddr;
uint64_t asc;
int prot;
DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n",
__func__, orig_vaddr, rw, mmu_idx);
orig_vaddr &= TARGET_PAGE_MASK;
vaddr = orig_vaddr;
if (mmu_idx < MMU_REAL_IDX) {
asc = cpu_mmu_idx_to_asc(mmu_idx);
/* 31-Bit mode */
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) {
return 1;
}
} else if (mmu_idx == MMU_REAL_IDX) {
if (mmu_translate_real(env, vaddr, rw, &raddr, &prot)) {
return 1;
}
} else {
abort();
}
/* check out of RAM access */
if (!address_space_access_valid(&address_space_memory, raddr,
TARGET_PAGE_SIZE, rw)) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, prot);
tlb_set_page(cs, orig_vaddr, raddr, prot,
mmu_idx, TARGET_PAGE_SIZE);
return 0;
}
| false | qemu | 2bcf018340cbf233f7145e643fc1bb367f23fd90 | int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,
int rw, int mmu_idx)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
target_ulong vaddr, raddr;
uint64_t asc;
int prot;
DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n",
__func__, orig_vaddr, rw, mmu_idx);
orig_vaddr &= TARGET_PAGE_MASK;
vaddr = orig_vaddr;
if (mmu_idx < MMU_REAL_IDX) {
asc = cpu_mmu_idx_to_asc(mmu_idx);
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) {
return 1;
}
} else if (mmu_idx == MMU_REAL_IDX) {
if (mmu_translate_real(env, vaddr, rw, &raddr, &prot)) {
return 1;
}
} else {
abort();
}
if (!address_space_access_valid(&address_space_memory, raddr,
TARGET_PAGE_SIZE, rw)) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, prot);
tlb_set_page(cs, orig_vaddr, raddr, prot,
mmu_idx, TARGET_PAGE_SIZE);
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(CPUState *VAR_0, vaddr VAR_1,
int VAR_2, int VAR_3)
{
S390CPU *cpu = S390_CPU(VAR_0);
CPUS390XState *env = &cpu->env;
target_ulong vaddr, raddr;
uint64_t asc;
int VAR_4;
DPRINTF("%s: address 0x%" VADDR_PRIx " VAR_2 %d VAR_3 %d\n",
__func__, VAR_1, VAR_2, VAR_3);
VAR_1 &= TARGET_PAGE_MASK;
vaddr = VAR_1;
if (VAR_3 < MMU_REAL_IDX) {
asc = cpu_mmu_idx_to_asc(VAR_3);
if (!(env->psw.mask & PSW_MASK_64)) {
vaddr &= 0x7fffffff;
}
if (mmu_translate(env, vaddr, VAR_2, asc, &raddr, &VAR_4, true)) {
return 1;
}
} else if (VAR_3 == MMU_REAL_IDX) {
if (mmu_translate_real(env, vaddr, VAR_2, &raddr, &VAR_4)) {
return 1;
}
} else {
abort();
}
if (!address_space_access_valid(&address_space_memory, raddr,
TARGET_PAGE_SIZE, VAR_2)) {
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
(uint64_t)raddr, (uint64_t)ram_size);
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
return 1;
}
qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n",
__func__, (uint64_t)vaddr, (uint64_t)raddr, VAR_4);
tlb_set_page(VAR_0, VAR_1, raddr, VAR_4,
VAR_3, TARGET_PAGE_SIZE);
return 0;
}
| [
"int FUNC_0(CPUState *VAR_0, vaddr VAR_1,\nint VAR_2, int VAR_3)\n{",
"S390CPU *cpu = S390_CPU(VAR_0);",
"CPUS390XState *env = &cpu->env;",
"target_ulong vaddr, raddr;",
"uint64_t asc;",
"int VAR_4;",
"DPRINTF(\"%s: address 0x%\" VADDR_PRIx \" VAR_2 %d VAR_3 %d\\n\",\n__func__, VAR_1, VAR_2, VAR_3);",
"VAR_1 &= TARGET_PAGE_MASK;",
"vaddr = VAR_1;",
"if (VAR_3 < MMU_REAL_IDX) {",
"asc = cpu_mmu_idx_to_asc(VAR_3);",
"if (!(env->psw.mask & PSW_MASK_64)) {",
"vaddr &= 0x7fffffff;",
"}",
"if (mmu_translate(env, vaddr, VAR_2, asc, &raddr, &VAR_4, true)) {",
"return 1;",
"}",
"} else if (VAR_3 == MMU_REAL_IDX) {",
"if (mmu_translate_real(env, vaddr, VAR_2, &raddr, &VAR_4)) {",
"return 1;",
"}",
"} else {",
"abort();",
"}",
"if (!address_space_access_valid(&address_space_memory, raddr,\nTARGET_PAGE_SIZE, VAR_2)) {",
"DPRINTF(\"%s: raddr %\" PRIx64 \" > ram_size %\" PRIx64 \"\\n\", __func__,\n(uint64_t)raddr, (uint64_t)ram_size);",
"trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);",
"return 1;",
"}",
"qemu_log_mask(CPU_LOG_MMU, \"%s: set tlb %\" PRIx64 \" -> %\" PRIx64 \" (%x)\\n\",\n__func__, (uint64_t)vaddr, (uint64_t)raddr, VAR_4);",
"tlb_set_page(VAR_0, VAR_1, raddr, VAR_4,\nVAR_3, TARGET_PAGE_SIZE);",
"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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
83,
85
],
[
89,
91
],
[
95
],
[
97
]
]
|
17,090 | uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift)
{
if (cap_ppc_rma >= 2) {
return current_size;
}
return MIN(current_size,
getrampagesize() << (hash_shift - 7));
}
| false | qemu | f36951c19f15f3c053a31234bd2c297d86c1a052 | uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift)
{
if (cap_ppc_rma >= 2) {
return current_size;
}
return MIN(current_size,
getrampagesize() << (hash_shift - 7));
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(uint64_t current_size, unsigned int hash_shift)
{
if (cap_ppc_rma >= 2) {
return current_size;
}
return MIN(current_size,
getrampagesize() << (hash_shift - 7));
}
| [
"uint64_t FUNC_0(uint64_t current_size, unsigned int hash_shift)\n{",
"if (cap_ppc_rma >= 2) {",
"return current_size;",
"}",
"return MIN(current_size,\ngetrampagesize() << (hash_shift - 7));",
"}"
]
| [
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15
]
]
|
17,093 | setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/
CPUState *env, unsigned long mask)
{
int err = 0;
__put_user_error(env->regs[0], &sc->arm_r0, err);
__put_user_error(env->regs[1], &sc->arm_r1, err);
__put_user_error(env->regs[2], &sc->arm_r2, err);
__put_user_error(env->regs[3], &sc->arm_r3, err);
__put_user_error(env->regs[4], &sc->arm_r4, err);
__put_user_error(env->regs[5], &sc->arm_r5, err);
__put_user_error(env->regs[6], &sc->arm_r6, err);
__put_user_error(env->regs[7], &sc->arm_r7, err);
__put_user_error(env->regs[8], &sc->arm_r8, err);
__put_user_error(env->regs[9], &sc->arm_r9, err);
__put_user_error(env->regs[10], &sc->arm_r10, err);
__put_user_error(env->regs[11], &sc->arm_fp, err);
__put_user_error(env->regs[12], &sc->arm_ip, err);
__put_user_error(env->regs[13], &sc->arm_sp, err);
__put_user_error(env->regs[14], &sc->arm_lr, err);
__put_user_error(env->regs[15], &sc->arm_pc, err);
#ifdef TARGET_CONFIG_CPU_32
__put_user_error(cpsr_read(env), &sc->arm_cpsr, err);
#endif
__put_user_error(/* current->thread.trap_no */ 0, &sc->trap_no, err);
__put_user_error(/* current->thread.error_code */ 0, &sc->error_code, err);
__put_user_error(/* current->thread.address */ 0, &sc->fault_address, err);
__put_user_error(mask, &sc->oldmask, err);
return err;
}
| false | qemu | f8b0aa25599782eef91edc00ebf620bd14db720c | setup_sigcontext(struct target_sigcontext *sc,
CPUState *env, unsigned long mask)
{
int err = 0;
__put_user_error(env->regs[0], &sc->arm_r0, err);
__put_user_error(env->regs[1], &sc->arm_r1, err);
__put_user_error(env->regs[2], &sc->arm_r2, err);
__put_user_error(env->regs[3], &sc->arm_r3, err);
__put_user_error(env->regs[4], &sc->arm_r4, err);
__put_user_error(env->regs[5], &sc->arm_r5, err);
__put_user_error(env->regs[6], &sc->arm_r6, err);
__put_user_error(env->regs[7], &sc->arm_r7, err);
__put_user_error(env->regs[8], &sc->arm_r8, err);
__put_user_error(env->regs[9], &sc->arm_r9, err);
__put_user_error(env->regs[10], &sc->arm_r10, err);
__put_user_error(env->regs[11], &sc->arm_fp, err);
__put_user_error(env->regs[12], &sc->arm_ip, err);
__put_user_error(env->regs[13], &sc->arm_sp, err);
__put_user_error(env->regs[14], &sc->arm_lr, err);
__put_user_error(env->regs[15], &sc->arm_pc, err);
#ifdef TARGET_CONFIG_CPU_32
__put_user_error(cpsr_read(env), &sc->arm_cpsr, err);
#endif
__put_user_error( 0, &sc->trap_no, err);
__put_user_error( 0, &sc->error_code, err);
__put_user_error( 0, &sc->fault_address, err);
__put_user_error(mask, &sc->oldmask, err);
return err;
}
| {
"code": [],
"line_no": []
} | FUNC_0(struct target_sigcontext *VAR_0,
CPUState *VAR_1, unsigned long VAR_2)
{
int VAR_3 = 0;
__put_user_error(VAR_1->regs[0], &VAR_0->arm_r0, VAR_3);
__put_user_error(VAR_1->regs[1], &VAR_0->arm_r1, VAR_3);
__put_user_error(VAR_1->regs[2], &VAR_0->arm_r2, VAR_3);
__put_user_error(VAR_1->regs[3], &VAR_0->arm_r3, VAR_3);
__put_user_error(VAR_1->regs[4], &VAR_0->arm_r4, VAR_3);
__put_user_error(VAR_1->regs[5], &VAR_0->arm_r5, VAR_3);
__put_user_error(VAR_1->regs[6], &VAR_0->arm_r6, VAR_3);
__put_user_error(VAR_1->regs[7], &VAR_0->arm_r7, VAR_3);
__put_user_error(VAR_1->regs[8], &VAR_0->arm_r8, VAR_3);
__put_user_error(VAR_1->regs[9], &VAR_0->arm_r9, VAR_3);
__put_user_error(VAR_1->regs[10], &VAR_0->arm_r10, VAR_3);
__put_user_error(VAR_1->regs[11], &VAR_0->arm_fp, VAR_3);
__put_user_error(VAR_1->regs[12], &VAR_0->arm_ip, VAR_3);
__put_user_error(VAR_1->regs[13], &VAR_0->arm_sp, VAR_3);
__put_user_error(VAR_1->regs[14], &VAR_0->arm_lr, VAR_3);
__put_user_error(VAR_1->regs[15], &VAR_0->arm_pc, VAR_3);
#ifdef TARGET_CONFIG_CPU_32
__put_user_error(cpsr_read(VAR_1), &VAR_0->arm_cpsr, VAR_3);
#endif
__put_user_error( 0, &VAR_0->trap_no, VAR_3);
__put_user_error( 0, &VAR_0->error_code, VAR_3);
__put_user_error( 0, &VAR_0->fault_address, VAR_3);
__put_user_error(VAR_2, &VAR_0->oldmask, VAR_3);
return VAR_3;
}
| [
"FUNC_0(struct target_sigcontext *VAR_0,\nCPUState *VAR_1, unsigned long VAR_2)\n{",
"int VAR_3 = 0;",
"__put_user_error(VAR_1->regs[0], &VAR_0->arm_r0, VAR_3);",
"__put_user_error(VAR_1->regs[1], &VAR_0->arm_r1, VAR_3);",
"__put_user_error(VAR_1->regs[2], &VAR_0->arm_r2, VAR_3);",
"__put_user_error(VAR_1->regs[3], &VAR_0->arm_r3, VAR_3);",
"__put_user_error(VAR_1->regs[4], &VAR_0->arm_r4, VAR_3);",
"__put_user_error(VAR_1->regs[5], &VAR_0->arm_r5, VAR_3);",
"__put_user_error(VAR_1->regs[6], &VAR_0->arm_r6, VAR_3);",
"__put_user_error(VAR_1->regs[7], &VAR_0->arm_r7, VAR_3);",
"__put_user_error(VAR_1->regs[8], &VAR_0->arm_r8, VAR_3);",
"__put_user_error(VAR_1->regs[9], &VAR_0->arm_r9, VAR_3);",
"__put_user_error(VAR_1->regs[10], &VAR_0->arm_r10, VAR_3);",
"__put_user_error(VAR_1->regs[11], &VAR_0->arm_fp, VAR_3);",
"__put_user_error(VAR_1->regs[12], &VAR_0->arm_ip, VAR_3);",
"__put_user_error(VAR_1->regs[13], &VAR_0->arm_sp, VAR_3);",
"__put_user_error(VAR_1->regs[14], &VAR_0->arm_lr, VAR_3);",
"__put_user_error(VAR_1->regs[15], &VAR_0->arm_pc, VAR_3);",
"#ifdef TARGET_CONFIG_CPU_32\n__put_user_error(cpsr_read(VAR_1), &VAR_0->arm_cpsr, VAR_3);",
"#endif\n__put_user_error( 0, &VAR_0->trap_no, VAR_3);",
"__put_user_error( 0, &VAR_0->error_code, VAR_3);",
"__put_user_error( 0, &VAR_0->fault_address, VAR_3);",
"__put_user_error(VAR_2, &VAR_0->oldmask, VAR_3);",
"return VAR_3;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47,
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
]
]
|
17,094 | void hd_geometry_guess(BlockDriverState *bs,
int *pcyls, int *pheads, int *psecs)
{
int cylinders, heads, secs, translation;
bdrv_get_geometry_hint(bs, &cylinders, &heads, &secs);
translation = bdrv_get_translation_hint(bs);
if (cylinders != 0) {
/* already got a geometry hint: use it */
*pcyls = cylinders;
*pheads = heads;
*psecs = secs;
return;
}
if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) {
/* no LCHS guess: use a standard physical disk geometry */
guess_chs_for_size(bs, pcyls, pheads, psecs);
} else if (heads > 16) {
/* LCHS guess with heads > 16 means that a BIOS LBA
translation was active, so a standard physical disk
geometry is OK */
guess_chs_for_size(bs, pcyls, pheads, psecs);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(bs,
*pcyls * *pheads <= 131072
? BIOS_ATA_TRANSLATION_LARGE
: BIOS_ATA_TRANSLATION_LBA);
}
} else {
/* LCHS guess with heads <= 16: use as physical geometry */
*pcyls = cylinders;
*pheads = heads;
*psecs = secs;
/* disable any translation to be in sync with
the logical geometry */
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(bs,
BIOS_ATA_TRANSLATION_NONE);
}
}
bdrv_set_geometry_hint(bs, *pcyls, *pheads, *psecs);
trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation);
}
| false | qemu | dc28c0cd30d7b122500b17eedc7e070624fd7c86 | void hd_geometry_guess(BlockDriverState *bs,
int *pcyls, int *pheads, int *psecs)
{
int cylinders, heads, secs, translation;
bdrv_get_geometry_hint(bs, &cylinders, &heads, &secs);
translation = bdrv_get_translation_hint(bs);
if (cylinders != 0) {
*pcyls = cylinders;
*pheads = heads;
*psecs = secs;
return;
}
if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) {
guess_chs_for_size(bs, pcyls, pheads, psecs);
} else if (heads > 16) {
guess_chs_for_size(bs, pcyls, pheads, psecs);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(bs,
*pcyls * *pheads <= 131072
? BIOS_ATA_TRANSLATION_LARGE
: BIOS_ATA_TRANSLATION_LBA);
}
} else {
*pcyls = cylinders;
*pheads = heads;
*psecs = secs;
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(bs,
BIOS_ATA_TRANSLATION_NONE);
}
}
bdrv_set_geometry_hint(bs, *pcyls, *pheads, *psecs);
trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(BlockDriverState *VAR_0,
int *VAR_1, int *VAR_2, int *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7;
bdrv_get_geometry_hint(VAR_0, &VAR_4, &VAR_5, &VAR_6);
VAR_7 = bdrv_get_translation_hint(VAR_0);
if (VAR_4 != 0) {
*VAR_1 = VAR_4;
*VAR_2 = VAR_5;
*VAR_3 = VAR_6;
return;
}
if (guess_disk_lchs(VAR_0, &VAR_4, &VAR_5, &VAR_6) < 0) {
guess_chs_for_size(VAR_0, VAR_1, VAR_2, VAR_3);
} else if (VAR_5 > 16) {
guess_chs_for_size(VAR_0, VAR_1, VAR_2, VAR_3);
if (VAR_7 == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(VAR_0,
*VAR_1 * *VAR_2 <= 131072
? BIOS_ATA_TRANSLATION_LARGE
: BIOS_ATA_TRANSLATION_LBA);
}
} else {
*VAR_1 = VAR_4;
*VAR_2 = VAR_5;
*VAR_3 = VAR_6;
if (VAR_7 == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(VAR_0,
BIOS_ATA_TRANSLATION_NONE);
}
}
bdrv_set_geometry_hint(VAR_0, *VAR_1, *VAR_2, *VAR_3);
trace_hd_geometry_guess(VAR_0, *VAR_1, *VAR_2, *VAR_3, VAR_7);
}
| [
"void FUNC_0(BlockDriverState *VAR_0,\nint *VAR_1, int *VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7;",
"bdrv_get_geometry_hint(VAR_0, &VAR_4, &VAR_5, &VAR_6);",
"VAR_7 = bdrv_get_translation_hint(VAR_0);",
"if (VAR_4 != 0) {",
"*VAR_1 = VAR_4;",
"*VAR_2 = VAR_5;",
"*VAR_3 = VAR_6;",
"return;",
"}",
"if (guess_disk_lchs(VAR_0, &VAR_4, &VAR_5, &VAR_6) < 0) {",
"guess_chs_for_size(VAR_0, VAR_1, VAR_2, VAR_3);",
"} else if (VAR_5 > 16) {",
"guess_chs_for_size(VAR_0, VAR_1, VAR_2, VAR_3);",
"if (VAR_7 == BIOS_ATA_TRANSLATION_AUTO) {",
"bdrv_set_translation_hint(VAR_0,\n*VAR_1 * *VAR_2 <= 131072\n? BIOS_ATA_TRANSLATION_LARGE\n: BIOS_ATA_TRANSLATION_LBA);",
"}",
"} else {",
"*VAR_1 = VAR_4;",
"*VAR_2 = VAR_5;",
"*VAR_3 = VAR_6;",
"if (VAR_7 == BIOS_ATA_TRANSLATION_AUTO) {",
"bdrv_set_translation_hint(VAR_0,\nBIOS_ATA_TRANSLATION_NONE);",
"}",
"}",
"bdrv_set_geometry_hint(VAR_0, *VAR_1, *VAR_2, *VAR_3);",
"trace_hd_geometry_guess(VAR_0, *VAR_1, *VAR_2, *VAR_3, VAR_7);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
37
],
[
39
],
[
47
],
[
49
],
[
51,
53,
55,
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
75
],
[
77,
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
]
]
|
17,095 | static void test_visitor_in_intList(TestInputVisitorData *data,
const void *unused)
{
int64_t value[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20};
int16List *res = NULL, *tmp;
Error *err = NULL;
Visitor *v;
int i = 0;
v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8");
visit_type_int16List(v, NULL, &res, &error_abort);
tmp = res;
while (i < sizeof(value) / sizeof(value[0])) {
g_assert(tmp);
g_assert_cmpint(tmp->value, ==, value[i++]);
tmp = tmp->next;
}
g_assert(!tmp);
qapi_free_int16List(res);
visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "not an int list");
/* FIXME: res should be NULL on failure, regardless of starting value */
res = NULL;
visit_type_int16List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
}
| false | qemu | d9f62dde1303286b24ac8ce88be27e2b9b9c5f46 | static void test_visitor_in_intList(TestInputVisitorData *data,
const void *unused)
{
int64_t value[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20};
int16List *res = NULL, *tmp;
Error *err = NULL;
Visitor *v;
int i = 0;
v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8");
visit_type_int16List(v, NULL, &res, &error_abort);
tmp = res;
while (i < sizeof(value) / sizeof(value[0])) {
g_assert(tmp);
g_assert_cmpint(tmp->value, ==, value[i++]);
tmp = tmp->next;
}
g_assert(!tmp);
qapi_free_int16List(res);
visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "not an int list");
res = NULL;
visit_type_int16List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(TestInputVisitorData *VAR_0,
const void *VAR_1)
{
int64_t value[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20};
int16List *res = NULL, *tmp;
Error *err = NULL;
Visitor *v;
int VAR_2 = 0;
v = visitor_input_test_init(VAR_0, "1,2,0,2-4,20,5-9,1-8");
visit_type_int16List(v, NULL, &res, &error_abort);
tmp = res;
while (VAR_2 < sizeof(value) / sizeof(value[0])) {
g_assert(tmp);
g_assert_cmpint(tmp->value, ==, value[VAR_2++]);
tmp = tmp->next;
}
g_assert(!tmp);
qapi_free_int16List(res);
visitor_input_teardown(VAR_0, VAR_1);
v = visitor_input_test_init(VAR_0, "not an int list");
res = NULL;
visit_type_int16List(v, NULL, &res, &err);
error_free_or_abort(&err);
g_assert(!res);
}
| [
"static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{",
"int64_t value[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20};",
"int16List *res = NULL, *tmp;",
"Error *err = NULL;",
"Visitor *v;",
"int VAR_2 = 0;",
"v = visitor_input_test_init(VAR_0, \"1,2,0,2-4,20,5-9,1-8\");",
"visit_type_int16List(v, NULL, &res, &error_abort);",
"tmp = res;",
"while (VAR_2 < sizeof(value) / sizeof(value[0])) {",
"g_assert(tmp);",
"g_assert_cmpint(tmp->value, ==, value[VAR_2++]);",
"tmp = tmp->next;",
"}",
"g_assert(!tmp);",
"qapi_free_int16List(res);",
"visitor_input_teardown(VAR_0, VAR_1);",
"v = visitor_input_test_init(VAR_0, \"not an int list\");",
"res = NULL;",
"visit_type_int16List(v, NULL, &res, &err);",
"error_free_or_abort(&err);",
"g_assert(!res);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
49
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
]
|
17,096 | int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
int i, err = -1;
for (i = 0; alarm_timers[i].name; i++) {
t = &alarm_timers[i];
err = t->start(t);
if (!err)
break;
}
if (err) {
err = -ENOENT;
goto fail;
}
/* first event is at time 0 */
atexit(quit_timers);
t->pending = true;
alarm_timer = t;
return 0;
fail:
return err;
}
| false | qemu | de188751da8db3c77a681bf903035a0e5218c463 | int init_timer_alarm(void)
{
struct qemu_alarm_timer *t = NULL;
int i, err = -1;
for (i = 0; alarm_timers[i].name; i++) {
t = &alarm_timers[i];
err = t->start(t);
if (!err)
break;
}
if (err) {
err = -ENOENT;
goto fail;
}
atexit(quit_timers);
t->pending = true;
alarm_timer = t;
return 0;
fail:
return err;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(void)
{
struct qemu_alarm_timer *VAR_0 = NULL;
int VAR_1, VAR_2 = -1;
for (VAR_1 = 0; alarm_timers[VAR_1].name; VAR_1++) {
VAR_0 = &alarm_timers[VAR_1];
VAR_2 = VAR_0->start(VAR_0);
if (!VAR_2)
break;
}
if (VAR_2) {
VAR_2 = -ENOENT;
goto fail;
}
atexit(quit_timers);
VAR_0->pending = true;
alarm_timer = VAR_0;
return 0;
fail:
return VAR_2;
}
| [
"int FUNC_0(void)\n{",
"struct qemu_alarm_timer *VAR_0 = NULL;",
"int VAR_1, VAR_2 = -1;",
"for (VAR_1 = 0; alarm_timers[VAR_1].name; VAR_1++) {",
"VAR_0 = &alarm_timers[VAR_1];",
"VAR_2 = VAR_0->start(VAR_0);",
"if (!VAR_2)\nbreak;",
"}",
"if (VAR_2) {",
"VAR_2 = -ENOENT;",
"goto fail;",
"}",
"atexit(quit_timers);",
"VAR_0->pending = true;",
"alarm_timer = VAR_0;",
"return 0;",
"fail:\nreturn VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51,
53
],
[
55
]
]
|
17,097 | static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
target_ulong pc_next = disas_insn(dc, cpu);
if (dc->tf || (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) {
/* if single step mode, we generate only one instruction and
generate an exception */
/* if irq were inhibited with HF_INHIBIT_IRQ_MASK, we clear
the flag and abort the translation to give the irqs a
chance to happen */
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((dc->base.tb->cflags & CF_USE_ICOUNT)
&& ((dc->base.pc_next & TARGET_PAGE_MASK)
!= ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1)
& TARGET_PAGE_MASK)
|| (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) {
/* Do not cross the boundary of the pages in icount mode,
it can cause an exception. Do it only when boundary is
crossed by the first instruction in the block.
If current instruction already crossed the bound - it's ok,
because an exception hasn't stopped this code.
*/
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
dc->base.pc_next = pc_next;
}
| true | qemu | c5a49c63fa26e8825ad101dfe86339ae4c216539 | static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
target_ulong pc_next = disas_insn(dc, cpu);
if (dc->tf || (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) {
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((dc->base.tb->cflags & CF_USE_ICOUNT)
&& ((dc->base.pc_next & TARGET_PAGE_MASK)
!= ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1)
& TARGET_PAGE_MASK)
|| (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) {
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
dc->base.pc_next = pc_next;
}
| {
"code": [
" } else if ((dc->base.tb->cflags & CF_USE_ICOUNT)"
],
"line_no": [
25
]
} | static void FUNC_0(DisasContextBase *VAR_0, CPUState *VAR_1)
{
DisasContext *dc = container_of(VAR_0, DisasContext, base);
target_ulong pc_next = disas_insn(dc, VAR_1);
if (dc->tf || (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) {
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((dc->base.tb->cflags & CF_USE_ICOUNT)
&& ((dc->base.pc_next & TARGET_PAGE_MASK)
!= ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1)
& TARGET_PAGE_MASK)
|| (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) {
dc->base.is_jmp = DISAS_TOO_MANY;
} else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
dc->base.pc_next = pc_next;
}
| [
"static void FUNC_0(DisasContextBase *VAR_0, CPUState *VAR_1)\n{",
"DisasContext *dc = container_of(VAR_0, DisasContext, base);",
"target_ulong pc_next = disas_insn(dc, VAR_1);",
"if (dc->tf || (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) {",
"dc->base.is_jmp = DISAS_TOO_MANY;",
"} else if ((dc->base.tb->cflags & CF_USE_ICOUNT)",
"&& ((dc->base.pc_next & TARGET_PAGE_MASK)\n!= ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1)\n& TARGET_PAGE_MASK)\n|| (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) {",
"dc->base.is_jmp = DISAS_TOO_MANY;",
"} else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) {",
"dc->base.is_jmp = DISAS_TOO_MANY;",
"}",
"dc->base.pc_next = pc_next;",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
23
],
[
25
],
[
27,
29,
31,
33
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
]
]
|
17,098 | static av_cold int alac_decode_init(AVCodecContext * avctx)
{
int ret;
int req_packed;
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
/* initialize from the extradata */
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return -1;
}
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
return -1;
}
req_packed = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);
switch (alac->sample_size) {
case 16: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;
break;
case 24:
case 32: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;
break;
default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
alac->sample_size);
return AVERROR_PATCHWELCOME;
}
avctx->bits_per_raw_sample = alac->sample_size;
if (alac->channels < 1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
alac->channels = avctx->channels;
} else {
if (alac->channels > MAX_CHANNELS)
alac->channels = avctx->channels;
else
avctx->channels = alac->channels;
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
avctx->channels);
return AVERROR_PATCHWELCOME;
}
avctx->channel_layout = alac_channel_layouts[alac->channels - 1];
if ((ret = allocate_buffers(alac)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
return ret;
}
avcodec_get_frame_defaults(&alac->frame);
avctx->coded_frame = &alac->frame;
return 0;
}
| false | FFmpeg | 001af703c6bff7cb8009db3ac882b8d929d67d9e | static av_cold int alac_decode_init(AVCodecContext * avctx)
{
int ret;
int req_packed;
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return -1;
}
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
return -1;
}
req_packed = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);
switch (alac->sample_size) {
case 16: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;
break;
case 24:
case 32: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;
break;
default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
alac->sample_size);
return AVERROR_PATCHWELCOME;
}
avctx->bits_per_raw_sample = alac->sample_size;
if (alac->channels < 1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
alac->channels = avctx->channels;
} else {
if (alac->channels > MAX_CHANNELS)
alac->channels = avctx->channels;
else
avctx->channels = alac->channels;
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
avctx->channels);
return AVERROR_PATCHWELCOME;
}
avctx->channel_layout = alac_channel_layouts[alac->channels - 1];
if ((ret = allocate_buffers(alac)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
return ret;
}
avcodec_get_frame_defaults(&alac->frame);
avctx->coded_frame = &alac->frame;
return 0;
}
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext * avctx)
{
int VAR_0;
int VAR_1;
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return -1;
}
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
return -1;
}
VAR_1 = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);
switch (alac->sample_size) {
case 16: avctx->sample_fmt = VAR_1 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;
break;
case 24:
case 32: avctx->sample_fmt = VAR_1 ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;
break;
default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
alac->sample_size);
return AVERROR_PATCHWELCOME;
}
avctx->bits_per_raw_sample = alac->sample_size;
if (alac->channels < 1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
alac->channels = avctx->channels;
} else {
if (alac->channels > MAX_CHANNELS)
alac->channels = avctx->channels;
else
avctx->channels = alac->channels;
}
if (avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
avctx->channels);
return AVERROR_PATCHWELCOME;
}
avctx->channel_layout = alac_channel_layouts[alac->channels - 1];
if ((VAR_0 = allocate_buffers(alac)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
return VAR_0;
}
avcodec_get_frame_defaults(&alac->frame);
avctx->coded_frame = &alac->frame;
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext * avctx)\n{",
"int VAR_0;",
"int VAR_1;",
"ALACContext *alac = avctx->priv_data;",
"alac->avctx = avctx;",
"if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {",
"av_log(avctx, AV_LOG_ERROR, \"expected %d extradata bytes\\n\",\nALAC_EXTRADATA_SIZE);",
"return -1;",
"}",
"if (alac_set_info(alac)) {",
"av_log(avctx, AV_LOG_ERROR, \"set_info failed\\n\");",
"return -1;",
"}",
"VAR_1 = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);",
"switch (alac->sample_size) {",
"case 16: avctx->sample_fmt = VAR_1 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;",
"break;",
"case 24:\ncase 32: avctx->sample_fmt = VAR_1 ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;",
"break;",
"default: av_log_ask_for_sample(avctx, \"Sample depth %d is not supported.\\n\",\nalac->sample_size);",
"return AVERROR_PATCHWELCOME;",
"}",
"avctx->bits_per_raw_sample = alac->sample_size;",
"if (alac->channels < 1) {",
"av_log(avctx, AV_LOG_WARNING, \"Invalid channel count\\n\");",
"alac->channels = avctx->channels;",
"} else {",
"if (alac->channels > MAX_CHANNELS)\nalac->channels = avctx->channels;",
"else\navctx->channels = alac->channels;",
"}",
"if (avctx->channels > MAX_CHANNELS) {",
"av_log(avctx, AV_LOG_ERROR, \"Unsupported channel count: %d\\n\",\navctx->channels);",
"return AVERROR_PATCHWELCOME;",
"}",
"avctx->channel_layout = alac_channel_layouts[alac->channels - 1];",
"if ((VAR_0 = allocate_buffers(alac)) < 0) {",
"av_log(avctx, AV_LOG_ERROR, \"Error allocating buffers\\n\");",
"return VAR_0;",
"}",
"avcodec_get_frame_defaults(&alac->frame);",
"avctx->coded_frame = &alac->frame;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
]
]
|
17,099 | static void qtrle_decode_8bpp(QtrleContext *s)
{
int stream_ptr;
int header;
int start_line;
int lines_to_change;
signed char rle_code;
int row_ptr, pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char pi1, pi2, pi3, pi4; /* 4 palette indices */
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
/* check if this frame is even supposed to change */
if (s->size < 8)
return;
/* start after the chunk size */
stream_ptr = 4;
/* fetch the header */
CHECK_STREAM_PTR(2);
header = BE_16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
start_line = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
lines_to_change = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
lines_to_change = s->avctx->height;
}
row_ptr = row_inc * start_line;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (4 * (s->buf[stream_ptr++] - 1));
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
/* there's another skip code in the stream */
CHECK_STREAM_PTR(1);
pixel_ptr += (4 * (s->buf[stream_ptr++] - 1));
} else if (rle_code < 0) {
/* decode the run length code */
rle_code = -rle_code;
/* get the next 4 bytes from the stream, treat them as palette
* indices, and output them rle_code times */
CHECK_STREAM_PTR(4);
pi1 = s->buf[stream_ptr++];
pi2 = s->buf[stream_ptr++];
pi3 = s->buf[stream_ptr++];
pi4 = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 4);
while (rle_code--) {
rgb[pixel_ptr++] = pi1;
rgb[pixel_ptr++] = pi2;
rgb[pixel_ptr++] = pi3;
rgb[pixel_ptr++] = pi4;
}
} else {
/* copy the same pixel directly to output 4 times */
rle_code *= 4;
CHECK_STREAM_PTR(rle_code);
CHECK_PIXEL_PTR(rle_code);
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| true | FFmpeg | e102fcf7f0f78bbdd395f05bb5b2fca83297749b | static void qtrle_decode_8bpp(QtrleContext *s)
{
int stream_ptr;
int header;
int start_line;
int lines_to_change;
signed char rle_code;
int row_ptr, pixel_ptr;
int row_inc = s->frame.linesize[0];
unsigned char pi1, pi2, pi3, pi4;
unsigned char *rgb = s->frame.data[0];
int pixel_limit = s->frame.linesize[0] * s->avctx->height;
if (s->size < 8)
return;
stream_ptr = 4;
CHECK_STREAM_PTR(2);
header = BE_16(&s->buf[stream_ptr]);
stream_ptr += 2;
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
start_line = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
lines_to_change = BE_16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
lines_to_change = s->avctx->height;
}
row_ptr = row_inc * start_line;
while (lines_to_change--) {
CHECK_STREAM_PTR(2);
pixel_ptr = row_ptr + (4 * (s->buf[stream_ptr++] - 1));
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
if (rle_code == 0) {
CHECK_STREAM_PTR(1);
pixel_ptr += (4 * (s->buf[stream_ptr++] - 1));
} else if (rle_code < 0) {
rle_code = -rle_code;
CHECK_STREAM_PTR(4);
pi1 = s->buf[stream_ptr++];
pi2 = s->buf[stream_ptr++];
pi3 = s->buf[stream_ptr++];
pi4 = s->buf[stream_ptr++];
CHECK_PIXEL_PTR(rle_code * 4);
while (rle_code--) {
rgb[pixel_ptr++] = pi1;
rgb[pixel_ptr++] = pi2;
rgb[pixel_ptr++] = pi3;
rgb[pixel_ptr++] = pi4;
}
} else {
rle_code *= 4;
CHECK_STREAM_PTR(rle_code);
CHECK_PIXEL_PTR(rle_code);
while (rle_code--) {
rgb[pixel_ptr++] = s->buf[stream_ptr++];
}
}
}
row_ptr += row_inc;
}
}
| {
"code": [
" signed char rle_code;"
],
"line_no": [
13
]
} | static void FUNC_0(QtrleContext *VAR_0)
{
int VAR_1;
int VAR_2;
int VAR_3;
int VAR_4;
signed char VAR_5;
int VAR_6, VAR_7;
int VAR_8 = VAR_0->frame.linesize[0];
unsigned char VAR_9, VAR_10, VAR_11, VAR_12;
unsigned char *VAR_13 = VAR_0->frame.data[0];
int VAR_14 = VAR_0->frame.linesize[0] * VAR_0->avctx->height;
if (VAR_0->size < 8)
return;
VAR_1 = 4;
CHECK_STREAM_PTR(2);
VAR_2 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 2;
if (VAR_2 & 0x0008) {
CHECK_STREAM_PTR(8);
VAR_3 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 4;
VAR_4 = BE_16(&VAR_0->buf[VAR_1]);
VAR_1 += 4;
} else {
VAR_3 = 0;
VAR_4 = VAR_0->avctx->height;
}
VAR_6 = VAR_8 * VAR_3;
while (VAR_4--) {
CHECK_STREAM_PTR(2);
VAR_7 = VAR_6 + (4 * (VAR_0->buf[VAR_1++] - 1));
while ((VAR_5 = (signed char)VAR_0->buf[VAR_1++]) != -1) {
if (VAR_5 == 0) {
CHECK_STREAM_PTR(1);
VAR_7 += (4 * (VAR_0->buf[VAR_1++] - 1));
} else if (VAR_5 < 0) {
VAR_5 = -VAR_5;
CHECK_STREAM_PTR(4);
VAR_9 = VAR_0->buf[VAR_1++];
VAR_10 = VAR_0->buf[VAR_1++];
VAR_11 = VAR_0->buf[VAR_1++];
VAR_12 = VAR_0->buf[VAR_1++];
CHECK_PIXEL_PTR(VAR_5 * 4);
while (VAR_5--) {
VAR_13[VAR_7++] = VAR_9;
VAR_13[VAR_7++] = VAR_10;
VAR_13[VAR_7++] = VAR_11;
VAR_13[VAR_7++] = VAR_12;
}
} else {
VAR_5 *= 4;
CHECK_STREAM_PTR(VAR_5);
CHECK_PIXEL_PTR(VAR_5);
while (VAR_5--) {
VAR_13[VAR_7++] = VAR_0->buf[VAR_1++];
}
}
}
VAR_6 += VAR_8;
}
}
| [
"static void FUNC_0(QtrleContext *VAR_0)\n{",
"int VAR_1;",
"int VAR_2;",
"int VAR_3;",
"int VAR_4;",
"signed char VAR_5;",
"int VAR_6, VAR_7;",
"int VAR_8 = VAR_0->frame.linesize[0];",
"unsigned char VAR_9, VAR_10, VAR_11, VAR_12;",
"unsigned char *VAR_13 = VAR_0->frame.data[0];",
"int VAR_14 = VAR_0->frame.linesize[0] * VAR_0->avctx->height;",
"if (VAR_0->size < 8)\nreturn;",
"VAR_1 = 4;",
"CHECK_STREAM_PTR(2);",
"VAR_2 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 2;",
"if (VAR_2 & 0x0008) {",
"CHECK_STREAM_PTR(8);",
"VAR_3 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 4;",
"VAR_4 = BE_16(&VAR_0->buf[VAR_1]);",
"VAR_1 += 4;",
"} else {",
"VAR_3 = 0;",
"VAR_4 = VAR_0->avctx->height;",
"}",
"VAR_6 = VAR_8 * VAR_3;",
"while (VAR_4--) {",
"CHECK_STREAM_PTR(2);",
"VAR_7 = VAR_6 + (4 * (VAR_0->buf[VAR_1++] - 1));",
"while ((VAR_5 = (signed char)VAR_0->buf[VAR_1++]) != -1) {",
"if (VAR_5 == 0) {",
"CHECK_STREAM_PTR(1);",
"VAR_7 += (4 * (VAR_0->buf[VAR_1++] - 1));",
"} else if (VAR_5 < 0) {",
"VAR_5 = -VAR_5;",
"CHECK_STREAM_PTR(4);",
"VAR_9 = VAR_0->buf[VAR_1++];",
"VAR_10 = VAR_0->buf[VAR_1++];",
"VAR_11 = VAR_0->buf[VAR_1++];",
"VAR_12 = VAR_0->buf[VAR_1++];",
"CHECK_PIXEL_PTR(VAR_5 * 4);",
"while (VAR_5--) {",
"VAR_13[VAR_7++] = VAR_9;",
"VAR_13[VAR_7++] = VAR_10;",
"VAR_13[VAR_7++] = VAR_11;",
"VAR_13[VAR_7++] = VAR_12;",
"}",
"} else {",
"VAR_5 *= 4;",
"CHECK_STREAM_PTR(VAR_5);",
"CHECK_PIXEL_PTR(VAR_5);",
"while (VAR_5--) {",
"VAR_13[VAR_7++] = VAR_0->buf[VAR_1++];",
"}",
"}",
"}",
"VAR_6 += VAR_8;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29,
31
],
[
37
],
[
43
],
[
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
99
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
]
]
|
17,100 | static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
/* UMID, only get last 16 bytes */
url_fskip(pb, 16);
get_buffer(pb, package->package_uid, 16);
break;
case 0x4701:
get_buffer(pb, package->descriptor_ref, 16);
break;
}
return 0;
}
| true | FFmpeg | 39bb30f6640fe1faf4bbc779a79786028febc95d | static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4);
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
url_fskip(pb, 16);
get_buffer(pb, package->package_uid, 16);
break;
case 0x4701:
get_buffer(pb, package->descriptor_ref, 16);
break;
}
return 0;
}
| {
"code": [
"static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag)"
],
"line_no": [
1
]
} | static int FUNC_0(MXFPackage *VAR_0, ByteIOContext *VAR_1, int VAR_2)
{
switch(VAR_2) {
case 0x4403:
VAR_0->tracks_count = get_be32(VAR_1);
if (VAR_0->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
VAR_0->tracks_refs = av_malloc(VAR_0->tracks_count * sizeof(UID));
if (!VAR_0->tracks_refs)
return -1;
url_fskip(VAR_1, 4);
get_buffer(VAR_1, (uint8_t *)VAR_0->tracks_refs, VAR_0->tracks_count * sizeof(UID));
break;
case 0x4401:
url_fskip(VAR_1, 16);
get_buffer(VAR_1, VAR_0->package_uid, 16);
break;
case 0x4701:
get_buffer(VAR_1, VAR_0->descriptor_ref, 16);
break;
}
return 0;
}
| [
"static int FUNC_0(MXFPackage *VAR_0, ByteIOContext *VAR_1, int VAR_2)\n{",
"switch(VAR_2) {",
"case 0x4403:\nVAR_0->tracks_count = get_be32(VAR_1);",
"if (VAR_0->tracks_count >= UINT_MAX / sizeof(UID))\nreturn -1;",
"VAR_0->tracks_refs = av_malloc(VAR_0->tracks_count * sizeof(UID));",
"if (!VAR_0->tracks_refs)\nreturn -1;",
"url_fskip(VAR_1, 4);",
"get_buffer(VAR_1, (uint8_t *)VAR_0->tracks_refs, VAR_0->tracks_count * sizeof(UID));",
"break;",
"case 0x4401:\nurl_fskip(VAR_1, 16);",
"get_buffer(VAR_1, VAR_0->package_uid, 16);",
"break;",
"case 0x4701:\nget_buffer(VAR_1, VAR_0->descriptor_ref, 16);",
"break;",
"}",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
]
]
|
17,102 | static int decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket* avpkt)
{
WMAProDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame;
int packet_sequence_number;
*got_frame_ptr = 0;
if (s->skip_packets > 0) {
s->skip_packets--;
return FFMIN(avpkt->size, avctx->block_align);
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
/** sanity check for the buffer length */
if (avctx->codec_id == AV_CODEC_ID_WMAPRO && buf_size < avctx->block_align) {
av_log(avctx, AV_LOG_ERROR, "Input packet too small (%d < %d)\n",
buf_size, avctx->block_align);
return AVERROR_INVALIDDATA;
if (avctx->codec_id == AV_CODEC_ID_WMAPRO) {
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
} else {
s->next_packet_start = buf_size - FFMIN(buf_size, avctx->block_align);
buf_size = FFMIN(buf_size, avctx->block_align);
s->buf_bit_size = buf_size << 3;
/** parse packet header */
init_get_bits(gb, buf, s->buf_bit_size);
if (avctx->codec_id != AV_CODEC_ID_XMA2) {
packet_sequence_number = get_bits(gb, 4);
skip_bits(gb, 2);
} else {
s->num_frames = get_bits(gb, 6);
packet_sequence_number = 0;
/** get number of bits that need to be added to the previous frame */
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
if (avctx->codec_id != AV_CODEC_ID_WMAPRO) {
skip_bits(gb, 3);
s->skip_packets = get_bits(gb, 8);
ff_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
num_bits_prev_frame);
/** check for packet loss */
if (avctx->codec_id != AV_CODEC_ID_XMA2 && !s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
av_log(avctx, AV_LOG_ERROR,
"Packet loss detected! seq %"PRIx8" vs %x\n",
s->packet_sequence_number, packet_sequence_number);
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
/** append the previous frame data to the remaining data from the
previous packet to create a full frame */
save_bits(s, gb, num_bits_prev_frame, 1);
ff_dlog(avctx, "accumulated %x bits of frame data\n",
s->num_saved_bits - s->frame_offset);
/** decode the cross packet frame if it is valid */
if (!s->packet_loss)
decode_frame(s, data, got_frame_ptr);
} else if (s->num_saved_bits - s->frame_offset) {
ff_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
if (s->packet_loss) {
/** reset number of saved bits so that the decoder
does not start to decode incomplete frames in the
s->len_prefix == 0 case */
s->num_saved_bits = 0;
s->packet_loss = 0;
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
if (!s->packet_loss)
s->packet_done = !decode_frame(s, data, got_frame_ptr);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
/** when the frames do not have a length prefix, we don't know
the compressed length of the individual frames
however, we know what part of a new packet belongs to the
previous frame
therefore we save the incoming packet first, then we append
the "previous frame" data from the next packet so that
we get a buffer that only contains full frames */
s->packet_done = !decode_frame(s, data, got_frame_ptr);
} else
s->packet_done = 1;
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
/** save the rest of the data so that it can be decoded
with the next packet */
save_bits(s, gb, remaining_bits(s, gb), 0);
s->packet_offset = get_bits_count(gb) & 7;
if (s->packet_loss)
return AVERROR_INVALIDDATA;
return get_bits_count(gb) >> 3; | true | FFmpeg | 7ad698e24e6b9dde57c4e01c145bcddfe9d6e4a3 | static int decode_packet(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket* avpkt)
{
WMAProDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame;
int packet_sequence_number;
*got_frame_ptr = 0;
if (s->skip_packets > 0) {
s->skip_packets--;
return FFMIN(avpkt->size, avctx->block_align);
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (avctx->codec_id == AV_CODEC_ID_WMAPRO && buf_size < avctx->block_align) {
av_log(avctx, AV_LOG_ERROR, "Input packet too small (%d < %d)\n",
buf_size, avctx->block_align);
return AVERROR_INVALIDDATA;
if (avctx->codec_id == AV_CODEC_ID_WMAPRO) {
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
} else {
s->next_packet_start = buf_size - FFMIN(buf_size, avctx->block_align);
buf_size = FFMIN(buf_size, avctx->block_align);
s->buf_bit_size = buf_size << 3;
init_get_bits(gb, buf, s->buf_bit_size);
if (avctx->codec_id != AV_CODEC_ID_XMA2) {
packet_sequence_number = get_bits(gb, 4);
skip_bits(gb, 2);
} else {
s->num_frames = get_bits(gb, 6);
packet_sequence_number = 0;
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
if (avctx->codec_id != AV_CODEC_ID_WMAPRO) {
skip_bits(gb, 3);
s->skip_packets = get_bits(gb, 8);
ff_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
num_bits_prev_frame);
if (avctx->codec_id != AV_CODEC_ID_XMA2 && !s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
av_log(avctx, AV_LOG_ERROR,
"Packet loss detected! seq %"PRIx8" vs %x\n",
s->packet_sequence_number, packet_sequence_number);
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
save_bits(s, gb, num_bits_prev_frame, 1);
ff_dlog(avctx, "accumulated %x bits of frame data\n",
s->num_saved_bits - s->frame_offset);
if (!s->packet_loss)
decode_frame(s, data, got_frame_ptr);
} else if (s->num_saved_bits - s->frame_offset) {
ff_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
if (!s->packet_loss)
s->packet_done = !decode_frame(s, data, got_frame_ptr);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s, data, got_frame_ptr);
} else
s->packet_done = 1;
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
s->packet_offset = get_bits_count(gb) & 7;
if (s->packet_loss)
return AVERROR_INVALIDDATA;
return get_bits_count(gb) >> 3; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket* VAR_3)
{
WMAProDecodeCtx *s = VAR_0->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
int VAR_6;
int VAR_7;
*VAR_2 = 0;
if (s->skip_packets > 0) {
s->skip_packets--;
return FFMIN(VAR_3->size, VAR_0->block_align);
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (VAR_0->codec_id == AV_CODEC_ID_WMAPRO && VAR_5 < VAR_0->block_align) {
av_log(VAR_0, AV_LOG_ERROR, "Input packet too small (%d < %d)\n",
VAR_5, VAR_0->block_align);
return AVERROR_INVALIDDATA;
if (VAR_0->codec_id == AV_CODEC_ID_WMAPRO) {
s->next_packet_start = VAR_5 - VAR_0->block_align;
VAR_5 = VAR_0->block_align;
} else {
s->next_packet_start = VAR_5 - FFMIN(VAR_5, VAR_0->block_align);
VAR_5 = FFMIN(VAR_5, VAR_0->block_align);
s->buf_bit_size = VAR_5 << 3;
init_get_bits(gb, VAR_4, s->buf_bit_size);
if (VAR_0->codec_id != AV_CODEC_ID_XMA2) {
VAR_7 = get_bits(gb, 4);
skip_bits(gb, 2);
} else {
s->num_frames = get_bits(gb, 6);
VAR_7 = 0;
VAR_6 = get_bits(gb, s->log2_frame_size);
if (VAR_0->codec_id != AV_CODEC_ID_WMAPRO) {
skip_bits(gb, 3);
s->skip_packets = get_bits(gb, 8);
ff_dlog(VAR_0, "packet[%d]: nbpf %x\n", VAR_0->frame_number,
VAR_6);
if (VAR_0->codec_id != AV_CODEC_ID_XMA2 && !s->packet_loss &&
((s->VAR_7 + 1) & 0xF) != VAR_7) {
av_log(VAR_0, AV_LOG_ERROR,
"Packet loss detected! seq %"PRIx8" vs %x\n",
s->VAR_7, VAR_7);
s->VAR_7 = VAR_7;
if (VAR_6 > 0) {
int VAR_8 = s->buf_bit_size - get_bits_count(gb);
if (VAR_6 >= VAR_8) {
VAR_6 = VAR_8;
s->packet_done = 1;
save_bits(s, gb, VAR_6, 1);
ff_dlog(VAR_0, "accumulated %x bits of frame VAR_1\n",
s->num_saved_bits - s->frame_offset);
if (!s->packet_loss)
decode_frame(s, VAR_1, VAR_2);
} else if (s->num_saved_bits - s->frame_offset) {
ff_dlog(VAR_0, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
} else {
int VAR_9;
s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3;
init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(VAR_9 = show_bits(gb, s->log2_frame_size)) &&
VAR_9 <= remaining_bits(s, gb)) {
save_bits(s, gb, VAR_9, 0);
if (!s->packet_loss)
s->packet_done = !decode_frame(s, VAR_1, VAR_2);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s, VAR_1, VAR_2);
} else
s->packet_done = 1;
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
s->packet_offset = get_bits_count(gb) & 7;
if (s->packet_loss)
return AVERROR_INVALIDDATA;
return get_bits_count(gb) >> 3; | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket* VAR_3)\n{",
"WMAProDecodeCtx *s = VAR_0->priv_data;",
"GetBitContext* gb = &s->pgb;",
"const uint8_t* VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int VAR_6;",
"int VAR_7;",
"*VAR_2 = 0;",
"if (s->skip_packets > 0) {",
"s->skip_packets--;",
"return FFMIN(VAR_3->size, VAR_0->block_align);",
"if (s->packet_done || s->packet_loss) {",
"s->packet_done = 0;",
"if (VAR_0->codec_id == AV_CODEC_ID_WMAPRO && VAR_5 < VAR_0->block_align) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Input packet too small (%d < %d)\\n\",\nVAR_5, VAR_0->block_align);",
"return AVERROR_INVALIDDATA;",
"if (VAR_0->codec_id == AV_CODEC_ID_WMAPRO) {",
"s->next_packet_start = VAR_5 - VAR_0->block_align;",
"VAR_5 = VAR_0->block_align;",
"} else {",
"s->next_packet_start = VAR_5 - FFMIN(VAR_5, VAR_0->block_align);",
"VAR_5 = FFMIN(VAR_5, VAR_0->block_align);",
"s->buf_bit_size = VAR_5 << 3;",
"init_get_bits(gb, VAR_4, s->buf_bit_size);",
"if (VAR_0->codec_id != AV_CODEC_ID_XMA2) {",
"VAR_7 = get_bits(gb, 4);",
"skip_bits(gb, 2);",
"} else {",
"s->num_frames = get_bits(gb, 6);",
"VAR_7 = 0;",
"VAR_6 = get_bits(gb, s->log2_frame_size);",
"if (VAR_0->codec_id != AV_CODEC_ID_WMAPRO) {",
"skip_bits(gb, 3);",
"s->skip_packets = get_bits(gb, 8);",
"ff_dlog(VAR_0, \"packet[%d]: nbpf %x\\n\", VAR_0->frame_number,\nVAR_6);",
"if (VAR_0->codec_id != AV_CODEC_ID_XMA2 && !s->packet_loss &&\n((s->VAR_7 + 1) & 0xF) != VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Packet loss detected! seq %\"PRIx8\" vs %x\\n\",\ns->VAR_7, VAR_7);",
"s->VAR_7 = VAR_7;",
"if (VAR_6 > 0) {",
"int VAR_8 = s->buf_bit_size - get_bits_count(gb);",
"if (VAR_6 >= VAR_8) {",
"VAR_6 = VAR_8;",
"s->packet_done = 1;",
"save_bits(s, gb, VAR_6, 1);",
"ff_dlog(VAR_0, \"accumulated %x bits of frame VAR_1\\n\",\ns->num_saved_bits - s->frame_offset);",
"if (!s->packet_loss)\ndecode_frame(s, VAR_1, VAR_2);",
"} else if (s->num_saved_bits - s->frame_offset) {",
"ff_dlog(VAR_0, \"ignoring %x previously saved bits\\n\",\ns->num_saved_bits - s->frame_offset);",
"if (s->packet_loss) {",
"s->num_saved_bits = 0;",
"s->packet_loss = 0;",
"} else {",
"int VAR_9;",
"s->buf_bit_size = (VAR_3->size - s->next_packet_start) << 3;",
"init_get_bits(gb, VAR_3->VAR_1, s->buf_bit_size);",
"skip_bits(gb, s->packet_offset);",
"if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&\n(VAR_9 = show_bits(gb, s->log2_frame_size)) &&\nVAR_9 <= remaining_bits(s, gb)) {",
"save_bits(s, gb, VAR_9, 0);",
"if (!s->packet_loss)\ns->packet_done = !decode_frame(s, VAR_1, VAR_2);",
"} else if (!s->len_prefix",
"&& s->num_saved_bits > get_bits_count(&s->gb)) {",
"s->packet_done = !decode_frame(s, VAR_1, VAR_2);",
"} else",
"s->packet_done = 1;",
"if (s->packet_done && !s->packet_loss &&\nremaining_bits(s, gb) > 0) {",
"save_bits(s, gb, remaining_bits(s, gb), 0);",
"s->packet_offset = get_bits_count(gb) & 7;",
"if (s->packet_loss)\nreturn AVERROR_INVALIDDATA;",
"return get_bits_count(gb) >> 3;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
17
],
[
18,
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24
],
[
25
],
[
26
],
[
27
],
[
29
],
[
30
],
[
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
37
],
[
38
],
[
39
],
[
40
],
[
41,
42
],
[
44,
45
],
[
46,
47,
48
],
[
49
],
[
50
],
[
51
],
[
52
],
[
53
],
[
54
],
[
57
],
[
58,
59
],
[
61,
62
],
[
63
],
[
64,
65
],
[
66
],
[
70
],
[
71
],
[
72
],
[
73
],
[
74
],
[
75
],
[
76
],
[
77,
78,
79
],
[
80
],
[
81,
82
],
[
83
],
[
84
],
[
92
],
[
93
],
[
94
],
[
95,
96
],
[
99
],
[
100
],
[
101,
102
],
[
103
]
]
|
17,103 | int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){
int i, j, k, pass;
const int n= pca->n;
double z[n];
memset(eigenvector, 0, sizeof(double)*n*n);
for(j=0; j<n; j++){
pca->mean[j] /= pca->count;
eigenvector[j + j*n] = 1.0;
for(i=0; i<=j; i++){
pca->covariance[j + i*n] /= pca->count;
pca->covariance[j + i*n] -= pca->mean[i] * pca->mean[j];
pca->covariance[i + j*n] = pca->covariance[j + i*n];
}
eigenvalue[j]= pca->covariance[j + j*n];
z[j]= 0;
}
for(pass=0; pass < 50; pass++){
double sum=0;
for(i=0; i<n; i++)
for(j=i+1; j<n; j++)
sum += fabs(pca->covariance[j + i*n]);
if(sum == 0){
for(i=0; i<n; i++){
double maxvalue= -1;
for(j=i; j<n; j++){
if(eigenvalue[j] > maxvalue){
maxvalue= eigenvalue[j];
k= j;
}
}
eigenvalue[k]= eigenvalue[i];
eigenvalue[i]= maxvalue;
for(j=0; j<n; j++){
double tmp= eigenvector[k + j*n];
eigenvector[k + j*n]= eigenvector[i + j*n];
eigenvector[i + j*n]= tmp;
}
}
return pass;
}
for(i=0; i<n; i++){
for(j=i+1; j<n; j++){
double covar= pca->covariance[j + i*n];
double t,c,s,tau,theta, h;
if(pass < 3 && fabs(covar) < sum / (5*n*n)) //FIXME why pass < 3
continue;
if(fabs(covar) == 0.0) //FIXME shouldnt be needed
continue;
if(pass >=3 && fabs((eigenvalue[j]+z[j])/covar) > (1LL<<32) && fabs((eigenvalue[i]+z[i])/covar) > (1LL<<32)){
pca->covariance[j + i*n]=0.0;
continue;
}
h= (eigenvalue[j]+z[j]) - (eigenvalue[i]+z[i]);
theta=0.5*h/covar;
t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
if(theta < 0.0) t = -t;
c=1.0/sqrt(1+t*t);
s=t*c;
tau=s/(1.0+c);
z[i] -= t*covar;
z[j] += t*covar;
#define ROTATE(a,i,j,k,l) {\
double g=a[j + i*n];\
double h=a[l + k*n];\
a[j + i*n]=g-s*(h+g*tau);\
a[l + k*n]=h+s*(g-h*tau); }
for(k=0; k<n; k++) {
if(k!=i && k!=j){
ROTATE(pca->covariance,FFMIN(k,i),FFMAX(k,i),FFMIN(k,j),FFMAX(k,j))
}
ROTATE(eigenvector,k,i,k,j)
}
pca->covariance[j + i*n]=0.0;
}
}
for (i=0; i<n; i++) {
eigenvalue[i] += z[i];
z[i]=0.0;
}
}
return -1;
}
| true | FFmpeg | ecad9872fb8c50dc88e8298535603e04fd9cf8b4 | int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){
int i, j, k, pass;
const int n= pca->n;
double z[n];
memset(eigenvector, 0, sizeof(double)*n*n);
for(j=0; j<n; j++){
pca->mean[j] /= pca->count;
eigenvector[j + j*n] = 1.0;
for(i=0; i<=j; i++){
pca->covariance[j + i*n] /= pca->count;
pca->covariance[j + i*n] -= pca->mean[i] * pca->mean[j];
pca->covariance[i + j*n] = pca->covariance[j + i*n];
}
eigenvalue[j]= pca->covariance[j + j*n];
z[j]= 0;
}
for(pass=0; pass < 50; pass++){
double sum=0;
for(i=0; i<n; i++)
for(j=i+1; j<n; j++)
sum += fabs(pca->covariance[j + i*n]);
if(sum == 0){
for(i=0; i<n; i++){
double maxvalue= -1;
for(j=i; j<n; j++){
if(eigenvalue[j] > maxvalue){
maxvalue= eigenvalue[j];
k= j;
}
}
eigenvalue[k]= eigenvalue[i];
eigenvalue[i]= maxvalue;
for(j=0; j<n; j++){
double tmp= eigenvector[k + j*n];
eigenvector[k + j*n]= eigenvector[i + j*n];
eigenvector[i + j*n]= tmp;
}
}
return pass;
}
for(i=0; i<n; i++){
for(j=i+1; j<n; j++){
double covar= pca->covariance[j + i*n];
double t,c,s,tau,theta, h;
if(pass < 3 && fabs(covar) < sum / (5*n*n))
continue;
if(fabs(covar) == 0.0)
continue;
if(pass >=3 && fabs((eigenvalue[j]+z[j])/covar) > (1LL<<32) && fabs((eigenvalue[i]+z[i])/covar) > (1LL<<32)){
pca->covariance[j + i*n]=0.0;
continue;
}
h= (eigenvalue[j]+z[j]) - (eigenvalue[i]+z[i]);
theta=0.5*h/covar;
t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
if(theta < 0.0) t = -t;
c=1.0/sqrt(1+t*t);
s=t*c;
tau=s/(1.0+c);
z[i] -= t*covar;
z[j] += t*covar;
#define ROTATE(a,i,j,k,l) {\
double g=a[j + i*n];\
double h=a[l + k*n];\
a[j + i*n]=g-s*(h+g*tau);\
a[l + k*n]=h+s*(g-h*tau); }
for(k=0; k<n; k++) {
if(k!=i && k!=j){
ROTATE(pca->covariance,FFMIN(k,i),FFMAX(k,i),FFMIN(k,j),FFMAX(k,j))
}
ROTATE(eigenvector,k,i,k,j)
}
pca->covariance[j + i*n]=0.0;
}
}
for (i=0; i<n; i++) {
eigenvalue[i] += z[i];
z[i]=0.0;
}
}
return -1;
}
| {
"code": [
" int i, j, k, pass;"
],
"line_no": [
3
]
} | int FUNC_0(PCA *VAR_0, double *VAR_1, double *VAR_2){
int VAR_3, VAR_4, VAR_5, VAR_6;
const int VAR_7= VAR_0->VAR_7;
double VAR_8[VAR_7];
memset(VAR_1, 0, sizeof(double)*VAR_7*VAR_7);
for(VAR_4=0; VAR_4<VAR_7; VAR_4++){
VAR_0->mean[VAR_4] /= VAR_0->count;
VAR_1[VAR_4 + VAR_4*VAR_7] = 1.0;
for(VAR_3=0; VAR_3<=VAR_4; VAR_3++){
VAR_0->covariance[VAR_4 + VAR_3*VAR_7] /= VAR_0->count;
VAR_0->covariance[VAR_4 + VAR_3*VAR_7] -= VAR_0->mean[VAR_3] * VAR_0->mean[VAR_4];
VAR_0->covariance[VAR_3 + VAR_4*VAR_7] = VAR_0->covariance[VAR_4 + VAR_3*VAR_7];
}
VAR_2[VAR_4]= VAR_0->covariance[VAR_4 + VAR_4*VAR_7];
VAR_8[VAR_4]= 0;
}
for(VAR_6=0; VAR_6 < 50; VAR_6++){
double VAR_9=0;
for(VAR_3=0; VAR_3<VAR_7; VAR_3++)
for(VAR_4=VAR_3+1; VAR_4<VAR_7; VAR_4++)
VAR_9 += fabs(VAR_0->covariance[VAR_4 + VAR_3*VAR_7]);
if(VAR_9 == 0){
for(VAR_3=0; VAR_3<VAR_7; VAR_3++){
double VAR_10= -1;
for(VAR_4=VAR_3; VAR_4<VAR_7; VAR_4++){
if(VAR_2[VAR_4] > VAR_10){
VAR_10= VAR_2[VAR_4];
VAR_5= VAR_4;
}
}
VAR_2[VAR_5]= VAR_2[VAR_3];
VAR_2[VAR_3]= VAR_10;
for(VAR_4=0; VAR_4<VAR_7; VAR_4++){
double VAR_11= VAR_1[VAR_5 + VAR_4*VAR_7];
VAR_1[VAR_5 + VAR_4*VAR_7]= VAR_1[VAR_3 + VAR_4*VAR_7];
VAR_1[VAR_3 + VAR_4*VAR_7]= VAR_11;
}
}
return VAR_6;
}
for(VAR_3=0; VAR_3<VAR_7; VAR_3++){
for(VAR_4=VAR_3+1; VAR_4<VAR_7; VAR_4++){
double VAR_12= VAR_0->covariance[VAR_4 + VAR_3*VAR_7];
double VAR_13,VAR_14,VAR_15,VAR_16,VAR_17, VAR_20;
if(VAR_6 < 3 && fabs(VAR_12) < VAR_9 / (5*VAR_7*VAR_7))
continue;
if(fabs(VAR_12) == 0.0)
continue;
if(VAR_6 >=3 && fabs((VAR_2[VAR_4]+VAR_8[VAR_4])/VAR_12) > (1LL<<32) && fabs((VAR_2[VAR_3]+VAR_8[VAR_3])/VAR_12) > (1LL<<32)){
VAR_0->covariance[VAR_4 + VAR_3*VAR_7]=0.0;
continue;
}
VAR_20= (VAR_2[VAR_4]+VAR_8[VAR_4]) - (VAR_2[VAR_3]+VAR_8[VAR_3]);
VAR_17=0.5*VAR_20/VAR_12;
VAR_13=1.0/(fabs(VAR_17)+sqrt(1.0+VAR_17*VAR_17));
if(VAR_17 < 0.0) VAR_13 = -VAR_13;
VAR_14=1.0/sqrt(1+VAR_13*VAR_13);
VAR_15=VAR_13*VAR_14;
VAR_16=VAR_15/(1.0+VAR_14);
VAR_8[VAR_3] -= VAR_13*VAR_12;
VAR_8[VAR_4] += VAR_13*VAR_12;
#define ROTATE(a,VAR_3,VAR_4,VAR_5,l) {\
double VAR_19=a[VAR_4 + VAR_3*VAR_7];\
double VAR_20=a[l + VAR_5*VAR_7];\
a[VAR_4 + VAR_3*VAR_7]=VAR_19-VAR_15*(VAR_20+VAR_19*VAR_16);\
a[l + VAR_5*VAR_7]=VAR_20+VAR_15*(VAR_19-VAR_20*VAR_16); }
for(VAR_5=0; VAR_5<VAR_7; VAR_5++) {
if(VAR_5!=VAR_3 && VAR_5!=VAR_4){
ROTATE(VAR_0->covariance,FFMIN(VAR_5,VAR_3),FFMAX(VAR_5,VAR_3),FFMIN(VAR_5,VAR_4),FFMAX(VAR_5,VAR_4))
}
ROTATE(VAR_1,VAR_5,VAR_3,VAR_5,VAR_4)
}
VAR_0->covariance[VAR_4 + VAR_3*VAR_7]=0.0;
}
}
for (VAR_3=0; VAR_3<VAR_7; VAR_3++) {
VAR_2[VAR_3] += VAR_8[VAR_3];
VAR_8[VAR_3]=0.0;
}
}
return -1;
}
| [
"int FUNC_0(PCA *VAR_0, double *VAR_1, double *VAR_2){",
"int VAR_3, VAR_4, VAR_5, VAR_6;",
"const int VAR_7= VAR_0->VAR_7;",
"double VAR_8[VAR_7];",
"memset(VAR_1, 0, sizeof(double)*VAR_7*VAR_7);",
"for(VAR_4=0; VAR_4<VAR_7; VAR_4++){",
"VAR_0->mean[VAR_4] /= VAR_0->count;",
"VAR_1[VAR_4 + VAR_4*VAR_7] = 1.0;",
"for(VAR_3=0; VAR_3<=VAR_4; VAR_3++){",
"VAR_0->covariance[VAR_4 + VAR_3*VAR_7] /= VAR_0->count;",
"VAR_0->covariance[VAR_4 + VAR_3*VAR_7] -= VAR_0->mean[VAR_3] * VAR_0->mean[VAR_4];",
"VAR_0->covariance[VAR_3 + VAR_4*VAR_7] = VAR_0->covariance[VAR_4 + VAR_3*VAR_7];",
"}",
"VAR_2[VAR_4]= VAR_0->covariance[VAR_4 + VAR_4*VAR_7];",
"VAR_8[VAR_4]= 0;",
"}",
"for(VAR_6=0; VAR_6 < 50; VAR_6++){",
"double VAR_9=0;",
"for(VAR_3=0; VAR_3<VAR_7; VAR_3++)",
"for(VAR_4=VAR_3+1; VAR_4<VAR_7; VAR_4++)",
"VAR_9 += fabs(VAR_0->covariance[VAR_4 + VAR_3*VAR_7]);",
"if(VAR_9 == 0){",
"for(VAR_3=0; VAR_3<VAR_7; VAR_3++){",
"double VAR_10= -1;",
"for(VAR_4=VAR_3; VAR_4<VAR_7; VAR_4++){",
"if(VAR_2[VAR_4] > VAR_10){",
"VAR_10= VAR_2[VAR_4];",
"VAR_5= VAR_4;",
"}",
"}",
"VAR_2[VAR_5]= VAR_2[VAR_3];",
"VAR_2[VAR_3]= VAR_10;",
"for(VAR_4=0; VAR_4<VAR_7; VAR_4++){",
"double VAR_11= VAR_1[VAR_5 + VAR_4*VAR_7];",
"VAR_1[VAR_5 + VAR_4*VAR_7]= VAR_1[VAR_3 + VAR_4*VAR_7];",
"VAR_1[VAR_3 + VAR_4*VAR_7]= VAR_11;",
"}",
"}",
"return VAR_6;",
"}",
"for(VAR_3=0; VAR_3<VAR_7; VAR_3++){",
"for(VAR_4=VAR_3+1; VAR_4<VAR_7; VAR_4++){",
"double VAR_12= VAR_0->covariance[VAR_4 + VAR_3*VAR_7];",
"double VAR_13,VAR_14,VAR_15,VAR_16,VAR_17, VAR_20;",
"if(VAR_6 < 3 && fabs(VAR_12) < VAR_9 / (5*VAR_7*VAR_7))\ncontinue;",
"if(fabs(VAR_12) == 0.0)\ncontinue;",
"if(VAR_6 >=3 && fabs((VAR_2[VAR_4]+VAR_8[VAR_4])/VAR_12) > (1LL<<32) && fabs((VAR_2[VAR_3]+VAR_8[VAR_3])/VAR_12) > (1LL<<32)){",
"VAR_0->covariance[VAR_4 + VAR_3*VAR_7]=0.0;",
"continue;",
"}",
"VAR_20= (VAR_2[VAR_4]+VAR_8[VAR_4]) - (VAR_2[VAR_3]+VAR_8[VAR_3]);",
"VAR_17=0.5*VAR_20/VAR_12;",
"VAR_13=1.0/(fabs(VAR_17)+sqrt(1.0+VAR_17*VAR_17));",
"if(VAR_17 < 0.0) VAR_13 = -VAR_13;",
"VAR_14=1.0/sqrt(1+VAR_13*VAR_13);",
"VAR_15=VAR_13*VAR_14;",
"VAR_16=VAR_15/(1.0+VAR_14);",
"VAR_8[VAR_3] -= VAR_13*VAR_12;",
"VAR_8[VAR_4] += VAR_13*VAR_12;",
"#define ROTATE(a,VAR_3,VAR_4,VAR_5,l) {\\",
"double VAR_19=a[VAR_4 + VAR_3*VAR_7];\\",
"double VAR_20=a[l + VAR_5*VAR_7];\\",
"a[VAR_4 + VAR_3*VAR_7]=VAR_19-VAR_15*(VAR_20+VAR_19*VAR_16);\\",
"a[l + VAR_5*VAR_7]=VAR_20+VAR_15*(VAR_19-VAR_20*VAR_16); }",
"for(VAR_5=0; VAR_5<VAR_7; VAR_5++) {",
"if(VAR_5!=VAR_3 && VAR_5!=VAR_4){",
"ROTATE(VAR_0->covariance,FFMIN(VAR_5,VAR_3),FFMAX(VAR_5,VAR_3),FFMIN(VAR_5,VAR_4),FFMAX(VAR_5,VAR_4))\n}",
"ROTATE(VAR_1,VAR_5,VAR_3,VAR_5,VAR_4)\n}",
"VAR_0->covariance[VAR_4 + VAR_3*VAR_7]=0.0;",
"}",
"}",
"for (VAR_3=0; VAR_3<VAR_7; VAR_3++) {",
"VAR_2[VAR_3] += VAR_8[VAR_3];",
"VAR_8[VAR_3]=0.0;",
"}",
"}",
"return -1;",
"}"
]
| [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103,
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157,
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
]
]
|
17,104 | qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds,
gnutls_x509_crt_t cert,
const char *certFile,
bool isServer,
Error **errp)
{
int status;
size_t i;
unsigned int purposeCritical;
unsigned int critical;
char *buffer = NULL;
size_t size;
bool allowClient = false, allowServer = false;
critical = 0;
for (i = 0; ; i++) {
size = 0;
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, NULL);
if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
/* If there is no data at all, then we must allow
client/server to pass */
if (i == 0) {
allowServer = allowClient = true;
}
break;
}
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
buffer = g_new0(char, size);
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, &purposeCritical);
if (status < 0) {
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, "<none>", purposeCritical);
g_free(buffer);
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, buffer, purposeCritical);
if (purposeCritical) {
critical = true;
}
if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_SERVER)) {
allowServer = true;
} else if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_CLIENT)) {
allowClient = true;
} else if (g_str_equal(buffer, GNUTLS_KP_ANY)) {
allowServer = allowClient = true;
}
g_free(buffer);
}
if (isServer) {
if (!allowServer) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow "
"use with a TLS server", certFile);
return -1;
}
}
} else {
if (!allowClient) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow use "
"with a TLS client", certFile);
return -1;
}
}
}
return 0;
} | true | qemu | 0e1d02452bf2c3486406dd48524a5b1de3c0eba8 | qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds,
gnutls_x509_crt_t cert,
const char *certFile,
bool isServer,
Error **errp)
{
int status;
size_t i;
unsigned int purposeCritical;
unsigned int critical;
char *buffer = NULL;
size_t size;
bool allowClient = false, allowServer = false;
critical = 0;
for (i = 0; ; i++) {
size = 0;
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, NULL);
if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
if (i == 0) {
allowServer = allowClient = true;
}
break;
}
if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) {
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
buffer = g_new0(char, size);
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer,
&size, &purposeCritical);
if (status < 0) {
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, "<none>", purposeCritical);
g_free(buffer);
error_setg(errp,
"Unable to query certificate %s key purpose: %s",
certFile, gnutls_strerror(status));
return -1;
}
trace_qcrypto_tls_creds_x509_check_key_purpose(
creds, certFile, status, buffer, purposeCritical);
if (purposeCritical) {
critical = true;
}
if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_SERVER)) {
allowServer = true;
} else if (g_str_equal(buffer, GNUTLS_KP_TLS_WWW_CLIENT)) {
allowClient = true;
} else if (g_str_equal(buffer, GNUTLS_KP_ANY)) {
allowServer = allowClient = true;
}
g_free(buffer);
}
if (isServer) {
if (!allowServer) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow "
"use with a TLS server", certFile);
return -1;
}
}
} else {
if (!allowClient) {
if (critical) {
error_setg(errp,
"Certificate %s purpose does not allow use "
"with a TLS client", certFile);
return -1;
}
}
}
return 0;
} | {
"code": [],
"line_no": []
} | FUNC_0(QCryptoTLSCredsX509 *VAR_0,
gnutls_x509_crt_t VAR_1,
const char *VAR_2,
bool VAR_3,
Error **VAR_4)
{
int VAR_5;
size_t i;
unsigned int VAR_6;
unsigned int VAR_7;
char *VAR_8 = NULL;
size_t size;
bool allowClient = false, allowServer = false;
VAR_7 = 0;
for (i = 0; ; i++) {
size = 0;
VAR_5 = gnutls_x509_crt_get_key_purpose_oid(VAR_1, i, VAR_8,
&size, NULL);
if (VAR_5 == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
if (i == 0) {
allowServer = allowClient = true;
}
break;
}
if (VAR_5 != GNUTLS_E_SHORT_MEMORY_BUFFER) {
error_setg(VAR_4,
"Unable to query certificate %s key purpose: %s",
VAR_2, gnutls_strerror(VAR_5));
return -1;
}
VAR_8 = g_new0(char, size);
VAR_5 = gnutls_x509_crt_get_key_purpose_oid(VAR_1, i, VAR_8,
&size, &VAR_6);
if (VAR_5 < 0) {
trace_qcrypto_tls_creds_x509_check_key_purpose(
VAR_0, VAR_2, VAR_5, "<none>", VAR_6);
g_free(VAR_8);
error_setg(VAR_4,
"Unable to query certificate %s key purpose: %s",
VAR_2, gnutls_strerror(VAR_5));
return -1;
}
trace_qcrypto_tls_creds_x509_check_key_purpose(
VAR_0, VAR_2, VAR_5, VAR_8, VAR_6);
if (VAR_6) {
VAR_7 = true;
}
if (g_str_equal(VAR_8, GNUTLS_KP_TLS_WWW_SERVER)) {
allowServer = true;
} else if (g_str_equal(VAR_8, GNUTLS_KP_TLS_WWW_CLIENT)) {
allowClient = true;
} else if (g_str_equal(VAR_8, GNUTLS_KP_ANY)) {
allowServer = allowClient = true;
}
g_free(VAR_8);
}
if (VAR_3) {
if (!allowServer) {
if (VAR_7) {
error_setg(VAR_4,
"Certificate %s purpose does not allow "
"use with a TLS server", VAR_2);
return -1;
}
}
} else {
if (!allowClient) {
if (VAR_7) {
error_setg(VAR_4,
"Certificate %s purpose does not allow use "
"with a TLS client", VAR_2);
return -1;
}
}
}
return 0;
} | [
"FUNC_0(QCryptoTLSCredsX509 *VAR_0,\ngnutls_x509_crt_t VAR_1,\nconst char *VAR_2,\nbool VAR_3,\nError **VAR_4)\n{",
"int VAR_5;",
"size_t i;",
"unsigned int VAR_6;",
"unsigned int VAR_7;",
"char *VAR_8 = NULL;",
"size_t size;",
"bool allowClient = false, allowServer = false;",
"VAR_7 = 0;",
"for (i = 0; ; i++) {",
"size = 0;",
"VAR_5 = gnutls_x509_crt_get_key_purpose_oid(VAR_1, i, VAR_8,\n&size, NULL);",
"if (VAR_5 == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {",
"if (i == 0) {",
"allowServer = allowClient = true;",
"}",
"break;",
"}",
"if (VAR_5 != GNUTLS_E_SHORT_MEMORY_BUFFER) {",
"error_setg(VAR_4,\n\"Unable to query certificate %s key purpose: %s\",\nVAR_2, gnutls_strerror(VAR_5));",
"return -1;",
"}",
"VAR_8 = g_new0(char, size);",
"VAR_5 = gnutls_x509_crt_get_key_purpose_oid(VAR_1, i, VAR_8,\n&size, &VAR_6);",
"if (VAR_5 < 0) {",
"trace_qcrypto_tls_creds_x509_check_key_purpose(\nVAR_0, VAR_2, VAR_5, \"<none>\", VAR_6);",
"g_free(VAR_8);",
"error_setg(VAR_4,\n\"Unable to query certificate %s key purpose: %s\",\nVAR_2, gnutls_strerror(VAR_5));",
"return -1;",
"}",
"trace_qcrypto_tls_creds_x509_check_key_purpose(\nVAR_0, VAR_2, VAR_5, VAR_8, VAR_6);",
"if (VAR_6) {",
"VAR_7 = true;",
"}",
"if (g_str_equal(VAR_8, GNUTLS_KP_TLS_WWW_SERVER)) {",
"allowServer = true;",
"} else if (g_str_equal(VAR_8, GNUTLS_KP_TLS_WWW_CLIENT)) {",
"allowClient = true;",
"} else if (g_str_equal(VAR_8, GNUTLS_KP_ANY)) {",
"allowServer = allowClient = true;",
"}",
"g_free(VAR_8);",
"}",
"if (VAR_3) {",
"if (!allowServer) {",
"if (VAR_7) {",
"error_setg(VAR_4,\n\"Certificate %s purpose does not allow \"\n\"use with a TLS server\", VAR_2);",
"return -1;",
"}",
"}",
"} else {",
"if (!allowClient) {",
"if (VAR_7) {",
"error_setg(VAR_4,\n\"Certificate %s purpose does not allow use \"\n\"with a TLS client\", VAR_2);",
"return -1;",
"}",
"}",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
41
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63,
65
],
[
67
],
[
69
],
[
73
],
[
77,
79
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93,
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
132
],
[
136
],
[
138
],
[
140
],
[
142,
144,
146
],
[
148
],
[
150
],
[
152
],
[
154
],
[
156
],
[
158
],
[
160,
162,
164
],
[
166
],
[
168
],
[
170
],
[
172
],
[
176
],
[
178
]
]
|
17,105 | void HELPER(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w)
{
uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
uint32_t windowstart = env->sregs[WINDOW_START];
uint32_t m, n;
if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {
return;
}
for (n = 1; ; ++n) {
if (n > w) {
return;
}
if (windowstart & windowstart_bit(windowbase + n, env)) {
break;
}
}
m = windowbase_bound(windowbase + n, env);
rotate_window(env, n);
env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
(windowbase << PS_OWB_SHIFT) | PS_EXCM;
env->sregs[EPC1] = env->pc = pc;
if (windowstart & windowstart_bit(m + 1, env)) {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW4);
} else if (windowstart & windowstart_bit(m + 2, env)) {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW8);
} else {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW12);
}
}
| true | qemu | 2db59a76c421cdd1039d10e32a9798952d3ff5ba | void HELPER(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w)
{
uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
uint32_t windowstart = env->sregs[WINDOW_START];
uint32_t m, n;
if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {
return;
}
for (n = 1; ; ++n) {
if (n > w) {
return;
}
if (windowstart & windowstart_bit(windowbase + n, env)) {
break;
}
}
m = windowbase_bound(windowbase + n, env);
rotate_window(env, n);
env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
(windowbase << PS_OWB_SHIFT) | PS_EXCM;
env->sregs[EPC1] = env->pc = pc;
if (windowstart & windowstart_bit(m + 1, env)) {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW4);
} else if (windowstart & windowstart_bit(m + 2, env)) {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW8);
} else {
HELPER(exception)(env, EXC_WINDOW_OVERFLOW12);
}
}
| {
"code": [
" uint32_t windowstart = env->sregs[WINDOW_START];",
" uint32_t m, n;",
" if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {",
" for (n = 1; ; ++n) {",
" if (n > w) {",
" if (windowstart & windowstart_bit(windowbase + n, env)) {",
" break;",
" m = windowbase_bound(windowbase + n, env);",
" if (windowstart & windowstart_bit(m + 1, env)) {",
" } else if (windowstart & windowstart_bit(m + 2, env)) {",
" } else {"
],
"line_no": [
7,
9,
13,
21,
23,
29,
31,
39,
51,
55,
59
]
} | void FUNC_0(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w)
{
uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
uint32_t windowstart = env->sregs[WINDOW_START];
uint32_t m, n;
if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {
return;
}
for (n = 1; ; ++n) {
if (n > w) {
return;
}
if (windowstart & windowstart_bit(windowbase + n, env)) {
break;
}
}
m = windowbase_bound(windowbase + n, env);
rotate_window(env, n);
env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
(windowbase << PS_OWB_SHIFT) | PS_EXCM;
env->sregs[EPC1] = env->pc = pc;
if (windowstart & windowstart_bit(m + 1, env)) {
FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW4);
} else if (windowstart & windowstart_bit(m + 2, env)) {
FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW8);
} else {
FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW12);
}
}
| [
"void FUNC_0(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w)\n{",
"uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);",
"uint32_t windowstart = env->sregs[WINDOW_START];",
"uint32_t m, n;",
"if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {",
"return;",
"}",
"for (n = 1; ; ++n) {",
"if (n > w) {",
"return;",
"}",
"if (windowstart & windowstart_bit(windowbase + n, env)) {",
"break;",
"}",
"}",
"m = windowbase_bound(windowbase + n, env);",
"rotate_window(env, n);",
"env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |\n(windowbase << PS_OWB_SHIFT) | PS_EXCM;",
"env->sregs[EPC1] = env->pc = pc;",
"if (windowstart & windowstart_bit(m + 1, env)) {",
"FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW4);",
"} else if (windowstart & windowstart_bit(m + 2, env)) {",
"FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW8);",
"} else {",
"FUNC_0(exception)(env, EXC_WINDOW_OVERFLOW12);",
"}",
"}"
]
| [
0,
0,
1,
1,
1,
0,
0,
1,
1,
0,
0,
1,
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
]
|
17,106 | QDict *qobject_to_qdict(const QObject *obj)
{
if (qobject_type(obj) != QTYPE_QDICT)
return NULL;
return container_of(obj, QDict, base);
}
| true | qemu | 89cad9f3ec6b30d7550fb5704475fc9c3393a066 | QDict *qobject_to_qdict(const QObject *obj)
{
if (qobject_type(obj) != QTYPE_QDICT)
return NULL;
return container_of(obj, QDict, base);
}
| {
"code": [
" if (qobject_type(obj) != QTYPE_QDICT)"
],
"line_no": [
5
]
} | QDict *FUNC_0(const QObject *obj)
{
if (qobject_type(obj) != QTYPE_QDICT)
return NULL;
return container_of(obj, QDict, base);
}
| [
"QDict *FUNC_0(const QObject *obj)\n{",
"if (qobject_type(obj) != QTYPE_QDICT)\nreturn NULL;",
"return container_of(obj, QDict, base);",
"}"
]
| [
0,
1,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
]
]
|
17,107 | PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
target_phys_addr_t base, qemu_irq irq)
{
PXA2xxLCDState *s;
s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
s->invalidated = 1;
s->irq = irq;
s->sysmem = sysmem;
pxa2xx_lcdc_orientation(s, graphic_rotate);
memory_region_init_io(&s->iomem, &pxa2xx_lcdc_ops, s,
"pxa2xx-lcd-controller", 0x00100000);
memory_region_add_subregion(sysmem, base, &s->iomem);
s->ds = graphic_console_init(pxa2xx_update_display,
pxa2xx_invalidate_display,
pxa2xx_screen_dump, NULL, s);
switch (ds_get_bits_per_pixel(s->ds)) {
case 0:
s->dest_width = 0;
break;
case 8:
s->line_fn[0] = pxa2xx_draw_fn_8;
s->line_fn[1] = pxa2xx_draw_fn_8t;
s->dest_width = 1;
break;
case 15:
s->line_fn[0] = pxa2xx_draw_fn_15;
s->line_fn[1] = pxa2xx_draw_fn_15t;
s->dest_width = 2;
break;
case 16:
s->line_fn[0] = pxa2xx_draw_fn_16;
s->line_fn[1] = pxa2xx_draw_fn_16t;
s->dest_width = 2;
break;
case 24:
s->line_fn[0] = pxa2xx_draw_fn_24;
s->line_fn[1] = pxa2xx_draw_fn_24t;
s->dest_width = 3;
break;
case 32:
s->line_fn[0] = pxa2xx_draw_fn_32;
s->line_fn[1] = pxa2xx_draw_fn_32t;
s->dest_width = 4;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
return s;
}
| true | qemu | 167351020420c285b67cdf0603501b3d3b15e3f7 | PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
target_phys_addr_t base, qemu_irq irq)
{
PXA2xxLCDState *s;
s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
s->invalidated = 1;
s->irq = irq;
s->sysmem = sysmem;
pxa2xx_lcdc_orientation(s, graphic_rotate);
memory_region_init_io(&s->iomem, &pxa2xx_lcdc_ops, s,
"pxa2xx-lcd-controller", 0x00100000);
memory_region_add_subregion(sysmem, base, &s->iomem);
s->ds = graphic_console_init(pxa2xx_update_display,
pxa2xx_invalidate_display,
pxa2xx_screen_dump, NULL, s);
switch (ds_get_bits_per_pixel(s->ds)) {
case 0:
s->dest_width = 0;
break;
case 8:
s->line_fn[0] = pxa2xx_draw_fn_8;
s->line_fn[1] = pxa2xx_draw_fn_8t;
s->dest_width = 1;
break;
case 15:
s->line_fn[0] = pxa2xx_draw_fn_15;
s->line_fn[1] = pxa2xx_draw_fn_15t;
s->dest_width = 2;
break;
case 16:
s->line_fn[0] = pxa2xx_draw_fn_16;
s->line_fn[1] = pxa2xx_draw_fn_16t;
s->dest_width = 2;
break;
case 24:
s->line_fn[0] = pxa2xx_draw_fn_24;
s->line_fn[1] = pxa2xx_draw_fn_24t;
s->dest_width = 3;
break;
case 32:
s->line_fn[0] = pxa2xx_draw_fn_32;
s->line_fn[1] = pxa2xx_draw_fn_32t;
s->dest_width = 4;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
return s;
}
| {
"code": [
" pxa2xx_screen_dump, NULL, s);"
],
"line_no": [
37
]
} | PXA2xxLCDState *FUNC_0(MemoryRegion *sysmem,
target_phys_addr_t base, qemu_irq irq)
{
PXA2xxLCDState *s;
s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
s->invalidated = 1;
s->irq = irq;
s->sysmem = sysmem;
pxa2xx_lcdc_orientation(s, graphic_rotate);
memory_region_init_io(&s->iomem, &pxa2xx_lcdc_ops, s,
"pxa2xx-lcd-controller", 0x00100000);
memory_region_add_subregion(sysmem, base, &s->iomem);
s->ds = graphic_console_init(pxa2xx_update_display,
pxa2xx_invalidate_display,
pxa2xx_screen_dump, NULL, s);
switch (ds_get_bits_per_pixel(s->ds)) {
case 0:
s->dest_width = 0;
break;
case 8:
s->line_fn[0] = pxa2xx_draw_fn_8;
s->line_fn[1] = pxa2xx_draw_fn_8t;
s->dest_width = 1;
break;
case 15:
s->line_fn[0] = pxa2xx_draw_fn_15;
s->line_fn[1] = pxa2xx_draw_fn_15t;
s->dest_width = 2;
break;
case 16:
s->line_fn[0] = pxa2xx_draw_fn_16;
s->line_fn[1] = pxa2xx_draw_fn_16t;
s->dest_width = 2;
break;
case 24:
s->line_fn[0] = pxa2xx_draw_fn_24;
s->line_fn[1] = pxa2xx_draw_fn_24t;
s->dest_width = 3;
break;
case 32:
s->line_fn[0] = pxa2xx_draw_fn_32;
s->line_fn[1] = pxa2xx_draw_fn_32t;
s->dest_width = 4;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
return s;
}
| [
"PXA2xxLCDState *FUNC_0(MemoryRegion *sysmem,\ntarget_phys_addr_t base, qemu_irq irq)\n{",
"PXA2xxLCDState *s;",
"s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));",
"s->invalidated = 1;",
"s->irq = irq;",
"s->sysmem = sysmem;",
"pxa2xx_lcdc_orientation(s, graphic_rotate);",
"memory_region_init_io(&s->iomem, &pxa2xx_lcdc_ops, s,\n\"pxa2xx-lcd-controller\", 0x00100000);",
"memory_region_add_subregion(sysmem, base, &s->iomem);",
"s->ds = graphic_console_init(pxa2xx_update_display,\npxa2xx_invalidate_display,\npxa2xx_screen_dump, NULL, s);",
"switch (ds_get_bits_per_pixel(s->ds)) {",
"case 0:\ns->dest_width = 0;",
"break;",
"case 8:\ns->line_fn[0] = pxa2xx_draw_fn_8;",
"s->line_fn[1] = pxa2xx_draw_fn_8t;",
"s->dest_width = 1;",
"break;",
"case 15:\ns->line_fn[0] = pxa2xx_draw_fn_15;",
"s->line_fn[1] = pxa2xx_draw_fn_15t;",
"s->dest_width = 2;",
"break;",
"case 16:\ns->line_fn[0] = pxa2xx_draw_fn_16;",
"s->line_fn[1] = pxa2xx_draw_fn_16t;",
"s->dest_width = 2;",
"break;",
"case 24:\ns->line_fn[0] = pxa2xx_draw_fn_24;",
"s->line_fn[1] = pxa2xx_draw_fn_24t;",
"s->dest_width = 3;",
"break;",
"case 32:\ns->line_fn[0] = pxa2xx_draw_fn_32;",
"s->line_fn[1] = pxa2xx_draw_fn_32t;",
"s->dest_width = 4;",
"break;",
"default:\nfprintf(stderr, \"%s: Bad color depth\\n\", __FUNCTION__);",
"exit(1);",
"}",
"vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);",
"return s;",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25,
27
],
[
29
],
[
33,
35,
37
],
[
41
],
[
43,
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
113
],
[
115
]
]
|
17,108 | static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx,
int *is_branch)
{
int rx, ry;
int sa;
int op, cnvt_op, op1, offset;
int funct;
int n_bytes;
op = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 2) & 0x7;
sa = sa == 0 ? 8 : sa;
rx = xlat((ctx->opcode >> 8) & 0x7);
cnvt_op = (ctx->opcode >> 5) & 0x7;
ry = xlat((ctx->opcode >> 5) & 0x7);
op1 = offset = ctx->opcode & 0x1f;
n_bytes = 2;
switch (op) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) ctx->opcode) << 2;
gen_arith_imm(ctx, OPC_ADDIU, rx, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(ctx, rx, ((uint8_t) ctx->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
offset = (ctx->opcode & 0x7ff) << 1;
offset = (int16_t)(offset << 4) >> 4;
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0, offset);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_JAL:
offset = cpu_lduw_code(env, ctx->pc + 2);
offset = (((ctx->opcode & 0x1f) << 21)
| ((ctx->opcode >> 5) & 0x1f) << 16
| offset) << 2;
op = ((ctx->opcode >> 10) & 0x1) ? OPC_JALXS : OPC_JALS;
gen_compute_branch(ctx, op, 4, rx, ry, offset);
n_bytes = 4;
*is_branch = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_BNEQZ:
gen_compute_branch(ctx, OPC_BNE, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
/* No delay slot, so just process as a normal instruction */
break;
case M16_OPC_SHIFT:
switch (ctx->opcode & 0x3) {
case 0x0:
gen_shift_imm(ctx, OPC_SLL, rx, ry, sa);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSLL, rx, ry, sa);
#else
generate_exception(ctx, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(ctx, OPC_SRL, rx, ry, sa);
break;
case 0x3:
gen_shift_imm(ctx, OPC_SRA, rx, ry, sa);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(ctx);
gen_ld(ctx, OPC_LD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((ctx->opcode & 0xf) << 4) >> 4;
if ((ctx->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_arith_imm(ctx, OPC_DADDIU, ry, rx, imm);
#else
generate_exception(ctx, EXCP_RI);
#endif
} else {
gen_arith_imm(ctx, OPC_ADDIU, ry, rx, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) ctx->opcode;
gen_arith_imm(ctx, OPC_ADDIU, rx, rx, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(ctx, OPC_SLTI, 24, rx, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(ctx, OPC_SLTIU, 24, rx, imm);
}
break;
case M16_OPC_I8:
{
int reg32;
funct = (ctx->opcode >> 8) & 0x7;
switch (funct) {
case I8_BTEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(ctx, OPC_BNE, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_SWRASP:
gen_st(ctx, OPC_SW, 31, 29, (ctx->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(ctx, OPC_ADDIU, 29, 29,
((int8_t)ctx->opcode) << 3);
break;
case I8_SVRS:
{
int do_ra = ctx->opcode & (1 << 6);
int do_s0 = ctx->opcode & (1 << 5);
int do_s1 = ctx->opcode & (1 << 4);
int framesize = ctx->opcode & 0xf;
if (framesize == 0) {
framesize = 128;
} else {
framesize = framesize << 3;
}
if (ctx->opcode & (1 << 7)) {
gen_mips16_save(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
} else {
gen_mips16_restore(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
}
}
break;
case I8_MOV32R:
{
int rz = xlat(ctx->opcode & 0x7);
reg32 = (((ctx->opcode >> 3) & 0x3) << 3) |
((ctx->opcode >> 5) & 0x7);
gen_arith(ctx, OPC_ADDU, reg32, rz, 0);
}
break;
case I8_MOVR32:
reg32 = ctx->opcode & 0x1f;
gen_arith(ctx, OPC_ADDU, ry, reg32, 0);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_arith_imm(ctx, OPC_ADDIU, rx, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_logic_imm(ctx, OPC_XORI, 24, rx, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(ctx);
gen_st(ctx, OPC_SD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_LB:
gen_ld(ctx, OPC_LB, ry, rx, offset);
break;
case M16_OPC_LH:
gen_ld(ctx, OPC_LH, ry, rx, offset << 1);
break;
case M16_OPC_LWSP:
gen_ld(ctx, OPC_LW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_LW:
gen_ld(ctx, OPC_LW, ry, rx, offset << 2);
break;
case M16_OPC_LBU:
gen_ld(ctx, OPC_LBU, ry, rx, offset);
break;
case M16_OPC_LHU:
gen_ld(ctx, OPC_LHU, ry, rx, offset << 1);
break;
case M16_OPC_LWPC:
gen_ld(ctx, OPC_LWPC, rx, 0, ((uint8_t)ctx->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(ctx);
gen_ld(ctx, OPC_LWU, ry, rx, offset << 2);
break;
#endif
case M16_OPC_SB:
gen_st(ctx, OPC_SB, ry, rx, offset);
break;
case M16_OPC_SH:
gen_st(ctx, OPC_SH, ry, rx, offset << 1);
break;
case M16_OPC_SWSP:
gen_st(ctx, OPC_SW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_SW:
gen_st(ctx, OPC_SW, ry, rx, offset << 2);
break;
case M16_OPC_RRR:
{
int rz = xlat((ctx->opcode >> 2) & 0x7);
int mips32_op;
switch (ctx->opcode & 0x3) {
case RRR_ADDU:
mips32_op = OPC_ADDU;
break;
case RRR_SUBU:
mips32_op = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
mips32_op = OPC_DADDU;
check_mips_64(ctx);
break;
case RRR_DSUBU:
mips32_op = OPC_DSUBU;
check_mips_64(ctx);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
goto done;
}
gen_arith(ctx, mips32_op, rz, rx, ry);
done:
;
}
break;
case M16_OPC_RR:
switch (op1) {
case RR_JR:
{
int nd = (ctx->opcode >> 7) & 0x1;
int link = (ctx->opcode >> 6) & 0x1;
int ra = (ctx->opcode >> 5) & 0x1;
if (link) {
op = nd ? OPC_JALRC : OPC_JALRS;
} else {
op = OPC_JR;
}
gen_compute_branch(ctx, op, 2, ra ? 31 : rx, 31, 0);
if (!nd) {
*is_branch = 1;
}
}
break;
case RR_SDBBP:
/* XXX: not clear which exception should be raised
* when in debug mode...
*/
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(ctx, OPC_SLT, 24, rx, ry);
break;
case RR_SLTU:
gen_slt(ctx, OPC_SLTU, 24, rx, ry);
break;
case RR_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(ctx, OPC_SLLV, ry, rx, ry);
break;
case RR_SRLV:
gen_shift(ctx, OPC_SRLV, ry, rx, ry);
break;
case RR_SRAV:
gen_shift(ctx, OPC_SRAV, ry, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRL, ry, ry, sa);
break;
#endif
case RR_CMP:
gen_logic(ctx, OPC_XOR, 24, rx, ry);
break;
case RR_NEG:
gen_arith(ctx, OPC_SUBU, rx, 0, ry);
break;
case RR_AND:
gen_logic(ctx, OPC_AND, rx, rx, ry);
break;
case RR_OR:
gen_logic(ctx, OPC_OR, rx, rx, ry);
break;
case RR_XOR:
gen_logic(ctx, OPC_XOR, rx, rx, ry);
break;
case RR_NOT:
gen_logic(ctx, OPC_NOR, rx, ry, 0);
break;
case RR_MFHI:
gen_HILO(ctx, OPC_MFHI, 0, rx);
break;
case RR_CNVT:
switch (cnvt_op) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(ctx);
tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(ctx);
tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(ctx, OPC_MFLO, 0, rx);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRA, ry, ry, sa);
break;
case RR_DSLLV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSLLV, ry, rx, ry);
break;
case RR_DSRLV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSRLV, ry, rx, ry);
break;
case RR_DSRAV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSRAV, ry, rx, ry);
break;
#endif
case RR_MULT:
gen_muldiv(ctx, OPC_MULT, 0, rx, ry);
break;
case RR_MULTU:
gen_muldiv(ctx, OPC_MULTU, 0, rx, ry);
break;
case RR_DIV:
gen_muldiv(ctx, OPC_DIV, 0, rx, ry);
break;
case RR_DIVU:
gen_muldiv(ctx, OPC_DIVU, 0, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULT, 0, rx, ry);
break;
case RR_DMULTU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULTU, 0, rx, ry);
break;
case RR_DDIV:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIV, 0, rx, ry);
break;
case RR_DDIVU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIVU, 0, rx, ry);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(env, ctx, is_branch);
n_bytes = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
funct = (ctx->opcode >> 8) & 0x7;
decode_i64_mips16(ctx, ry, funct, offset, 0);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
return n_bytes;
}
| true | qemu | 240ce26a0533a6e5ee472789fbfbd9f7f939197e | static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx,
int *is_branch)
{
int rx, ry;
int sa;
int op, cnvt_op, op1, offset;
int funct;
int n_bytes;
op = (ctx->opcode >> 11) & 0x1f;
sa = (ctx->opcode >> 2) & 0x7;
sa = sa == 0 ? 8 : sa;
rx = xlat((ctx->opcode >> 8) & 0x7);
cnvt_op = (ctx->opcode >> 5) & 0x7;
ry = xlat((ctx->opcode >> 5) & 0x7);
op1 = offset = ctx->opcode & 0x1f;
n_bytes = 2;
switch (op) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) ctx->opcode) << 2;
gen_arith_imm(ctx, OPC_ADDIU, rx, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(ctx, rx, ((uint8_t) ctx->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
offset = (ctx->opcode & 0x7ff) << 1;
offset = (int16_t)(offset << 4) >> 4;
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0, offset);
break;
case M16_OPC_JAL:
offset = cpu_lduw_code(env, ctx->pc + 2);
offset = (((ctx->opcode & 0x1f) << 21)
| ((ctx->opcode >> 5) & 0x1f) << 16
| offset) << 2;
op = ((ctx->opcode >> 10) & 0x1) ? OPC_JALXS : OPC_JALS;
gen_compute_branch(ctx, op, 4, rx, ry, offset);
n_bytes = 4;
*is_branch = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
break;
case M16_OPC_BNEQZ:
gen_compute_branch(ctx, OPC_BNE, 2, rx, 0, ((int8_t)ctx->opcode) << 1);
break;
case M16_OPC_SHIFT:
switch (ctx->opcode & 0x3) {
case 0x0:
gen_shift_imm(ctx, OPC_SLL, rx, ry, sa);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSLL, rx, ry, sa);
#else
generate_exception(ctx, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(ctx, OPC_SRL, rx, ry, sa);
break;
case 0x3:
gen_shift_imm(ctx, OPC_SRA, rx, ry, sa);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(ctx);
gen_ld(ctx, OPC_LD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((ctx->opcode & 0xf) << 4) >> 4;
if ((ctx->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(ctx);
gen_arith_imm(ctx, OPC_DADDIU, ry, rx, imm);
#else
generate_exception(ctx, EXCP_RI);
#endif
} else {
gen_arith_imm(ctx, OPC_ADDIU, ry, rx, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) ctx->opcode;
gen_arith_imm(ctx, OPC_ADDIU, rx, rx, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(ctx, OPC_SLTI, 24, rx, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_slt_imm(ctx, OPC_SLTIU, 24, rx, imm);
}
break;
case M16_OPC_I8:
{
int reg32;
funct = (ctx->opcode >> 8) & 0x7;
switch (funct) {
case I8_BTEQZ:
gen_compute_branch(ctx, OPC_BEQ, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(ctx, OPC_BNE, 2, 24, 0,
((int8_t)ctx->opcode) << 1);
break;
case I8_SWRASP:
gen_st(ctx, OPC_SW, 31, 29, (ctx->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(ctx, OPC_ADDIU, 29, 29,
((int8_t)ctx->opcode) << 3);
break;
case I8_SVRS:
{
int do_ra = ctx->opcode & (1 << 6);
int do_s0 = ctx->opcode & (1 << 5);
int do_s1 = ctx->opcode & (1 << 4);
int framesize = ctx->opcode & 0xf;
if (framesize == 0) {
framesize = 128;
} else {
framesize = framesize << 3;
}
if (ctx->opcode & (1 << 7)) {
gen_mips16_save(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
} else {
gen_mips16_restore(ctx, 0, 0,
do_ra, do_s0, do_s1, framesize);
}
}
break;
case I8_MOV32R:
{
int rz = xlat(ctx->opcode & 0x7);
reg32 = (((ctx->opcode >> 3) & 0x3) << 3) |
((ctx->opcode >> 5) & 0x7);
gen_arith(ctx, OPC_ADDU, reg32, rz, 0);
}
break;
case I8_MOVR32:
reg32 = ctx->opcode & 0x1f;
gen_arith(ctx, OPC_ADDU, ry, reg32, 0);
break;
default:
generate_exception(ctx, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_arith_imm(ctx, OPC_ADDIU, rx, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) ctx->opcode;
gen_logic_imm(ctx, OPC_XORI, 24, rx, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(ctx);
gen_st(ctx, OPC_SD, ry, rx, offset << 3);
break;
#endif
case M16_OPC_LB:
gen_ld(ctx, OPC_LB, ry, rx, offset);
break;
case M16_OPC_LH:
gen_ld(ctx, OPC_LH, ry, rx, offset << 1);
break;
case M16_OPC_LWSP:
gen_ld(ctx, OPC_LW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_LW:
gen_ld(ctx, OPC_LW, ry, rx, offset << 2);
break;
case M16_OPC_LBU:
gen_ld(ctx, OPC_LBU, ry, rx, offset);
break;
case M16_OPC_LHU:
gen_ld(ctx, OPC_LHU, ry, rx, offset << 1);
break;
case M16_OPC_LWPC:
gen_ld(ctx, OPC_LWPC, rx, 0, ((uint8_t)ctx->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(ctx);
gen_ld(ctx, OPC_LWU, ry, rx, offset << 2);
break;
#endif
case M16_OPC_SB:
gen_st(ctx, OPC_SB, ry, rx, offset);
break;
case M16_OPC_SH:
gen_st(ctx, OPC_SH, ry, rx, offset << 1);
break;
case M16_OPC_SWSP:
gen_st(ctx, OPC_SW, rx, 29, ((uint8_t)ctx->opcode) << 2);
break;
case M16_OPC_SW:
gen_st(ctx, OPC_SW, ry, rx, offset << 2);
break;
case M16_OPC_RRR:
{
int rz = xlat((ctx->opcode >> 2) & 0x7);
int mips32_op;
switch (ctx->opcode & 0x3) {
case RRR_ADDU:
mips32_op = OPC_ADDU;
break;
case RRR_SUBU:
mips32_op = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
mips32_op = OPC_DADDU;
check_mips_64(ctx);
break;
case RRR_DSUBU:
mips32_op = OPC_DSUBU;
check_mips_64(ctx);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
goto done;
}
gen_arith(ctx, mips32_op, rz, rx, ry);
done:
;
}
break;
case M16_OPC_RR:
switch (op1) {
case RR_JR:
{
int nd = (ctx->opcode >> 7) & 0x1;
int link = (ctx->opcode >> 6) & 0x1;
int ra = (ctx->opcode >> 5) & 0x1;
if (link) {
op = nd ? OPC_JALRC : OPC_JALRS;
} else {
op = OPC_JR;
}
gen_compute_branch(ctx, op, 2, ra ? 31 : rx, 31, 0);
if (!nd) {
*is_branch = 1;
}
}
break;
case RR_SDBBP:
check_insn(ctx, ISA_MIPS32);
if (!(ctx->hflags & MIPS_HFLAG_DM)) {
generate_exception(ctx, EXCP_DBp);
} else {
generate_exception(ctx, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(ctx, OPC_SLT, 24, rx, ry);
break;
case RR_SLTU:
gen_slt(ctx, OPC_SLTU, 24, rx, ry);
break;
case RR_BREAK:
generate_exception(ctx, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(ctx, OPC_SLLV, ry, rx, ry);
break;
case RR_SRLV:
gen_shift(ctx, OPC_SRLV, ry, rx, ry);
break;
case RR_SRAV:
gen_shift(ctx, OPC_SRAV, ry, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRL, ry, ry, sa);
break;
#endif
case RR_CMP:
gen_logic(ctx, OPC_XOR, 24, rx, ry);
break;
case RR_NEG:
gen_arith(ctx, OPC_SUBU, rx, 0, ry);
break;
case RR_AND:
gen_logic(ctx, OPC_AND, rx, rx, ry);
break;
case RR_OR:
gen_logic(ctx, OPC_OR, rx, rx, ry);
break;
case RR_XOR:
gen_logic(ctx, OPC_XOR, rx, rx, ry);
break;
case RR_NOT:
gen_logic(ctx, OPC_NOR, rx, ry, 0);
break;
case RR_MFHI:
gen_HILO(ctx, OPC_MFHI, 0, rx);
break;
case RR_CNVT:
switch (cnvt_op) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(ctx);
tcg_gen_ext32u_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(ctx);
tcg_gen_ext32s_tl(cpu_gpr[rx], cpu_gpr[rx]);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(ctx, OPC_MFLO, 0, rx);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(ctx);
gen_shift_imm(ctx, OPC_DSRA, ry, ry, sa);
break;
case RR_DSLLV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSLLV, ry, rx, ry);
break;
case RR_DSRLV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSRLV, ry, rx, ry);
break;
case RR_DSRAV:
check_mips_64(ctx);
gen_shift(ctx, OPC_DSRAV, ry, rx, ry);
break;
#endif
case RR_MULT:
gen_muldiv(ctx, OPC_MULT, 0, rx, ry);
break;
case RR_MULTU:
gen_muldiv(ctx, OPC_MULTU, 0, rx, ry);
break;
case RR_DIV:
gen_muldiv(ctx, OPC_DIV, 0, rx, ry);
break;
case RR_DIVU:
gen_muldiv(ctx, OPC_DIVU, 0, rx, ry);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULT, 0, rx, ry);
break;
case RR_DMULTU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DMULTU, 0, rx, ry);
break;
case RR_DDIV:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIV, 0, rx, ry);
break;
case RR_DDIVU:
check_mips_64(ctx);
gen_muldiv(ctx, OPC_DDIVU, 0, rx, ry);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(env, ctx, is_branch);
n_bytes = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
funct = (ctx->opcode >> 8) & 0x7;
decode_i64_mips16(ctx, ry, funct, offset, 0);
break;
#endif
default:
generate_exception(ctx, EXCP_RI);
break;
}
return n_bytes;
}
| {
"code": [
"static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx,",
" int *is_branch)",
" *is_branch = 1;",
" if (!nd) {",
" *is_branch = 1;",
" decode_extended_mips16_opc(env, ctx, is_branch);",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;",
" *is_branch = 1;"
],
"line_no": [
1,
3,
89,
567,
569,
861,
89,
89,
89,
89,
89,
89,
89,
89,
89,
89,
89
]
} | static int FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1,
int *VAR_2)
{
int VAR_3, VAR_4;
int VAR_5;
int VAR_6, VAR_7, VAR_8, VAR_9;
int VAR_10;
int VAR_11;
VAR_6 = (VAR_1->opcode >> 11) & 0x1f;
VAR_5 = (VAR_1->opcode >> 2) & 0x7;
VAR_5 = VAR_5 == 0 ? 8 : VAR_5;
VAR_3 = xlat((VAR_1->opcode >> 8) & 0x7);
VAR_7 = (VAR_1->opcode >> 5) & 0x7;
VAR_4 = xlat((VAR_1->opcode >> 5) & 0x7);
VAR_8 = VAR_9 = VAR_1->opcode & 0x1f;
VAR_11 = 2;
switch (VAR_6) {
case M16_OPC_ADDIUSP:
{
int16_t imm = ((uint8_t) VAR_1->opcode) << 2;
gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, 29, imm);
}
break;
case M16_OPC_ADDIUPC:
gen_addiupc(VAR_1, VAR_3, ((uint8_t) VAR_1->opcode) << 2, 0, 0);
break;
case M16_OPC_B:
VAR_9 = (VAR_1->opcode & 0x7ff) << 1;
VAR_9 = (int16_t)(VAR_9 << 4) >> 4;
gen_compute_branch(VAR_1, OPC_BEQ, 2, 0, 0, VAR_9);
break;
case M16_OPC_JAL:
VAR_9 = cpu_lduw_code(VAR_0, VAR_1->pc + 2);
VAR_9 = (((VAR_1->opcode & 0x1f) << 21)
| ((VAR_1->opcode >> 5) & 0x1f) << 16
| VAR_9) << 2;
VAR_6 = ((VAR_1->opcode >> 10) & 0x1) ? OPC_JALXS : OPC_JALS;
gen_compute_branch(VAR_1, VAR_6, 4, VAR_3, VAR_4, VAR_9);
VAR_11 = 4;
*VAR_2 = 1;
break;
case M16_OPC_BEQZ:
gen_compute_branch(VAR_1, OPC_BEQ, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);
break;
case M16_OPC_BNEQZ:
gen_compute_branch(VAR_1, OPC_BNE, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);
break;
case M16_OPC_SHIFT:
switch (VAR_1->opcode & 0x3) {
case 0x0:
gen_shift_imm(VAR_1, OPC_SLL, VAR_3, VAR_4, VAR_5);
break;
case 0x1:
#if defined(TARGET_MIPS64)
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, OPC_DSLL, VAR_3, VAR_4, VAR_5);
#else
generate_exception(VAR_1, EXCP_RI);
#endif
break;
case 0x2:
gen_shift_imm(VAR_1, OPC_SRL, VAR_3, VAR_4, VAR_5);
break;
case 0x3:
gen_shift_imm(VAR_1, OPC_SRA, VAR_3, VAR_4, VAR_5);
break;
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_LD:
check_mips_64(VAR_1);
gen_ld(VAR_1, OPC_LD, VAR_4, VAR_3, VAR_9 << 3);
break;
#endif
case M16_OPC_RRIA:
{
int16_t imm = (int8_t)((VAR_1->opcode & 0xf) << 4) >> 4;
if ((VAR_1->opcode >> 4) & 1) {
#if defined(TARGET_MIPS64)
check_mips_64(VAR_1);
gen_arith_imm(VAR_1, OPC_DADDIU, VAR_4, VAR_3, imm);
#else
generate_exception(VAR_1, EXCP_RI);
#endif
} else {
gen_arith_imm(VAR_1, OPC_ADDIU, VAR_4, VAR_3, imm);
}
}
break;
case M16_OPC_ADDIU8:
{
int16_t imm = (int8_t) VAR_1->opcode;
gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, VAR_3, imm);
}
break;
case M16_OPC_SLTI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_slt_imm(VAR_1, OPC_SLTI, 24, VAR_3, imm);
}
break;
case M16_OPC_SLTIU:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_slt_imm(VAR_1, OPC_SLTIU, 24, VAR_3, imm);
}
break;
case M16_OPC_I8:
{
int VAR_12;
VAR_10 = (VAR_1->opcode >> 8) & 0x7;
switch (VAR_10) {
case I8_BTEQZ:
gen_compute_branch(VAR_1, OPC_BEQ, 2, 24, 0,
((int8_t)VAR_1->opcode) << 1);
break;
case I8_BTNEZ:
gen_compute_branch(VAR_1, OPC_BNE, 2, 24, 0,
((int8_t)VAR_1->opcode) << 1);
break;
case I8_SWRASP:
gen_st(VAR_1, OPC_SW, 31, 29, (VAR_1->opcode & 0xff) << 2);
break;
case I8_ADJSP:
gen_arith_imm(VAR_1, OPC_ADDIU, 29, 29,
((int8_t)VAR_1->opcode) << 3);
break;
case I8_SVRS:
{
int VAR_13 = VAR_1->opcode & (1 << 6);
int VAR_14 = VAR_1->opcode & (1 << 5);
int VAR_15 = VAR_1->opcode & (1 << 4);
int VAR_16 = VAR_1->opcode & 0xf;
if (VAR_16 == 0) {
VAR_16 = 128;
} else {
VAR_16 = VAR_16 << 3;
}
if (VAR_1->opcode & (1 << 7)) {
gen_mips16_save(VAR_1, 0, 0,
VAR_13, VAR_14, VAR_15, VAR_16);
} else {
gen_mips16_restore(VAR_1, 0, 0,
VAR_13, VAR_14, VAR_15, VAR_16);
}
}
break;
case I8_MOV32R:
{
int VAR_18 = xlat(VAR_1->opcode & 0x7);
VAR_12 = (((VAR_1->opcode >> 3) & 0x3) << 3) |
((VAR_1->opcode >> 5) & 0x7);
gen_arith(VAR_1, OPC_ADDU, VAR_12, VAR_18, 0);
}
break;
case I8_MOVR32:
VAR_12 = VAR_1->opcode & 0x1f;
gen_arith(VAR_1, OPC_ADDU, VAR_4, VAR_12, 0);
break;
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
}
break;
case M16_OPC_LI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, 0, imm);
}
break;
case M16_OPC_CMPI:
{
int16_t imm = (uint8_t) VAR_1->opcode;
gen_logic_imm(VAR_1, OPC_XORI, 24, VAR_3, imm);
}
break;
#if defined(TARGET_MIPS64)
case M16_OPC_SD:
check_mips_64(VAR_1);
gen_st(VAR_1, OPC_SD, VAR_4, VAR_3, VAR_9 << 3);
break;
#endif
case M16_OPC_LB:
gen_ld(VAR_1, OPC_LB, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_LH:
gen_ld(VAR_1, OPC_LH, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_LWSP:
gen_ld(VAR_1, OPC_LW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);
break;
case M16_OPC_LW:
gen_ld(VAR_1, OPC_LW, VAR_4, VAR_3, VAR_9 << 2);
break;
case M16_OPC_LBU:
gen_ld(VAR_1, OPC_LBU, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_LHU:
gen_ld(VAR_1, OPC_LHU, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_LWPC:
gen_ld(VAR_1, OPC_LWPC, VAR_3, 0, ((uint8_t)VAR_1->opcode) << 2);
break;
#if defined (TARGET_MIPS64)
case M16_OPC_LWU:
check_mips_64(VAR_1);
gen_ld(VAR_1, OPC_LWU, VAR_4, VAR_3, VAR_9 << 2);
break;
#endif
case M16_OPC_SB:
gen_st(VAR_1, OPC_SB, VAR_4, VAR_3, VAR_9);
break;
case M16_OPC_SH:
gen_st(VAR_1, OPC_SH, VAR_4, VAR_3, VAR_9 << 1);
break;
case M16_OPC_SWSP:
gen_st(VAR_1, OPC_SW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);
break;
case M16_OPC_SW:
gen_st(VAR_1, OPC_SW, VAR_4, VAR_3, VAR_9 << 2);
break;
case M16_OPC_RRR:
{
int VAR_18 = xlat((VAR_1->opcode >> 2) & 0x7);
int VAR_18;
switch (VAR_1->opcode & 0x3) {
case RRR_ADDU:
VAR_18 = OPC_ADDU;
break;
case RRR_SUBU:
VAR_18 = OPC_SUBU;
break;
#if defined(TARGET_MIPS64)
case RRR_DADDU:
VAR_18 = OPC_DADDU;
check_mips_64(VAR_1);
break;
case RRR_DSUBU:
VAR_18 = OPC_DSUBU;
check_mips_64(VAR_1);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
goto done;
}
gen_arith(VAR_1, VAR_18, VAR_18, VAR_3, VAR_4);
done:
;
}
break;
case M16_OPC_RR:
switch (VAR_8) {
case RR_JR:
{
int VAR_19 = (VAR_1->opcode >> 7) & 0x1;
int VAR_20 = (VAR_1->opcode >> 6) & 0x1;
int VAR_21 = (VAR_1->opcode >> 5) & 0x1;
if (VAR_20) {
VAR_6 = VAR_19 ? OPC_JALRC : OPC_JALRS;
} else {
VAR_6 = OPC_JR;
}
gen_compute_branch(VAR_1, VAR_6, 2, VAR_21 ? 31 : VAR_3, 31, 0);
if (!VAR_19) {
*VAR_2 = 1;
}
}
break;
case RR_SDBBP:
check_insn(VAR_1, ISA_MIPS32);
if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {
generate_exception(VAR_1, EXCP_DBp);
} else {
generate_exception(VAR_1, EXCP_DBp);
}
break;
case RR_SLT:
gen_slt(VAR_1, OPC_SLT, 24, VAR_3, VAR_4);
break;
case RR_SLTU:
gen_slt(VAR_1, OPC_SLTU, 24, VAR_3, VAR_4);
break;
case RR_BREAK:
generate_exception(VAR_1, EXCP_BREAK);
break;
case RR_SLLV:
gen_shift(VAR_1, OPC_SLLV, VAR_4, VAR_3, VAR_4);
break;
case RR_SRLV:
gen_shift(VAR_1, OPC_SRLV, VAR_4, VAR_3, VAR_4);
break;
case RR_SRAV:
gen_shift(VAR_1, OPC_SRAV, VAR_4, VAR_3, VAR_4);
break;
#if defined (TARGET_MIPS64)
case RR_DSRL:
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, OPC_DSRL, VAR_4, VAR_4, VAR_5);
break;
#endif
case RR_CMP:
gen_logic(VAR_1, OPC_XOR, 24, VAR_3, VAR_4);
break;
case RR_NEG:
gen_arith(VAR_1, OPC_SUBU, VAR_3, 0, VAR_4);
break;
case RR_AND:
gen_logic(VAR_1, OPC_AND, VAR_3, VAR_3, VAR_4);
break;
case RR_OR:
gen_logic(VAR_1, OPC_OR, VAR_3, VAR_3, VAR_4);
break;
case RR_XOR:
gen_logic(VAR_1, OPC_XOR, VAR_3, VAR_3, VAR_4);
break;
case RR_NOT:
gen_logic(VAR_1, OPC_NOR, VAR_3, VAR_4, 0);
break;
case RR_MFHI:
gen_HILO(VAR_1, OPC_MFHI, 0, VAR_3);
break;
case RR_CNVT:
switch (VAR_7) {
case RR_RY_CNVT_ZEB:
tcg_gen_ext8u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_ZEH:
tcg_gen_ext16u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEB:
tcg_gen_ext8s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEH:
tcg_gen_ext16s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
#if defined (TARGET_MIPS64)
case RR_RY_CNVT_ZEW:
check_mips_64(VAR_1);
tcg_gen_ext32u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
case RR_RY_CNVT_SEW:
check_mips_64(VAR_1);
tcg_gen_ext32s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case RR_MFLO:
gen_HILO(VAR_1, OPC_MFLO, 0, VAR_3);
break;
#if defined (TARGET_MIPS64)
case RR_DSRA:
check_mips_64(VAR_1);
gen_shift_imm(VAR_1, OPC_DSRA, VAR_4, VAR_4, VAR_5);
break;
case RR_DSLLV:
check_mips_64(VAR_1);
gen_shift(VAR_1, OPC_DSLLV, VAR_4, VAR_3, VAR_4);
break;
case RR_DSRLV:
check_mips_64(VAR_1);
gen_shift(VAR_1, OPC_DSRLV, VAR_4, VAR_3, VAR_4);
break;
case RR_DSRAV:
check_mips_64(VAR_1);
gen_shift(VAR_1, OPC_DSRAV, VAR_4, VAR_3, VAR_4);
break;
#endif
case RR_MULT:
gen_muldiv(VAR_1, OPC_MULT, 0, VAR_3, VAR_4);
break;
case RR_MULTU:
gen_muldiv(VAR_1, OPC_MULTU, 0, VAR_3, VAR_4);
break;
case RR_DIV:
gen_muldiv(VAR_1, OPC_DIV, 0, VAR_3, VAR_4);
break;
case RR_DIVU:
gen_muldiv(VAR_1, OPC_DIVU, 0, VAR_3, VAR_4);
break;
#if defined (TARGET_MIPS64)
case RR_DMULT:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DMULT, 0, VAR_3, VAR_4);
break;
case RR_DMULTU:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DMULTU, 0, VAR_3, VAR_4);
break;
case RR_DDIV:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DDIV, 0, VAR_3, VAR_4);
break;
case RR_DDIVU:
check_mips_64(VAR_1);
gen_muldiv(VAR_1, OPC_DDIVU, 0, VAR_3, VAR_4);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
break;
case M16_OPC_EXTEND:
decode_extended_mips16_opc(VAR_0, VAR_1, VAR_2);
VAR_11 = 4;
break;
#if defined(TARGET_MIPS64)
case M16_OPC_I64:
VAR_10 = (VAR_1->opcode >> 8) & 0x7;
decode_i64_mips16(VAR_1, VAR_4, VAR_10, VAR_9, 0);
break;
#endif
default:
generate_exception(VAR_1, EXCP_RI);
break;
}
return VAR_11;
}
| [
"static int FUNC_0 (CPUMIPSState *VAR_0, DisasContext *VAR_1,\nint *VAR_2)\n{",
"int VAR_3, VAR_4;",
"int VAR_5;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"int VAR_10;",
"int VAR_11;",
"VAR_6 = (VAR_1->opcode >> 11) & 0x1f;",
"VAR_5 = (VAR_1->opcode >> 2) & 0x7;",
"VAR_5 = VAR_5 == 0 ? 8 : VAR_5;",
"VAR_3 = xlat((VAR_1->opcode >> 8) & 0x7);",
"VAR_7 = (VAR_1->opcode >> 5) & 0x7;",
"VAR_4 = xlat((VAR_1->opcode >> 5) & 0x7);",
"VAR_8 = VAR_9 = VAR_1->opcode & 0x1f;",
"VAR_11 = 2;",
"switch (VAR_6) {",
"case M16_OPC_ADDIUSP:\n{",
"int16_t imm = ((uint8_t) VAR_1->opcode) << 2;",
"gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, 29, imm);",
"}",
"break;",
"case M16_OPC_ADDIUPC:\ngen_addiupc(VAR_1, VAR_3, ((uint8_t) VAR_1->opcode) << 2, 0, 0);",
"break;",
"case M16_OPC_B:\nVAR_9 = (VAR_1->opcode & 0x7ff) << 1;",
"VAR_9 = (int16_t)(VAR_9 << 4) >> 4;",
"gen_compute_branch(VAR_1, OPC_BEQ, 2, 0, 0, VAR_9);",
"break;",
"case M16_OPC_JAL:\nVAR_9 = cpu_lduw_code(VAR_0, VAR_1->pc + 2);",
"VAR_9 = (((VAR_1->opcode & 0x1f) << 21)\n| ((VAR_1->opcode >> 5) & 0x1f) << 16\n| VAR_9) << 2;",
"VAR_6 = ((VAR_1->opcode >> 10) & 0x1) ? OPC_JALXS : OPC_JALS;",
"gen_compute_branch(VAR_1, VAR_6, 4, VAR_3, VAR_4, VAR_9);",
"VAR_11 = 4;",
"*VAR_2 = 1;",
"break;",
"case M16_OPC_BEQZ:\ngen_compute_branch(VAR_1, OPC_BEQ, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);",
"break;",
"case M16_OPC_BNEQZ:\ngen_compute_branch(VAR_1, OPC_BNE, 2, VAR_3, 0, ((int8_t)VAR_1->opcode) << 1);",
"break;",
"case M16_OPC_SHIFT:\nswitch (VAR_1->opcode & 0x3) {",
"case 0x0:\ngen_shift_imm(VAR_1, OPC_SLL, VAR_3, VAR_4, VAR_5);",
"break;",
"case 0x1:\n#if defined(TARGET_MIPS64)\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, OPC_DSLL, VAR_3, VAR_4, VAR_5);",
"#else\ngenerate_exception(VAR_1, EXCP_RI);",
"#endif\nbreak;",
"case 0x2:\ngen_shift_imm(VAR_1, OPC_SRL, VAR_3, VAR_4, VAR_5);",
"break;",
"case 0x3:\ngen_shift_imm(VAR_1, OPC_SRA, VAR_3, VAR_4, VAR_5);",
"break;",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_LD:\ncheck_mips_64(VAR_1);",
"gen_ld(VAR_1, OPC_LD, VAR_4, VAR_3, VAR_9 << 3);",
"break;",
"#endif\ncase M16_OPC_RRIA:\n{",
"int16_t imm = (int8_t)((VAR_1->opcode & 0xf) << 4) >> 4;",
"if ((VAR_1->opcode >> 4) & 1) {",
"#if defined(TARGET_MIPS64)\ncheck_mips_64(VAR_1);",
"gen_arith_imm(VAR_1, OPC_DADDIU, VAR_4, VAR_3, imm);",
"#else\ngenerate_exception(VAR_1, EXCP_RI);",
"#endif\n} else {",
"gen_arith_imm(VAR_1, OPC_ADDIU, VAR_4, VAR_3, imm);",
"}",
"}",
"break;",
"case M16_OPC_ADDIU8:\n{",
"int16_t imm = (int8_t) VAR_1->opcode;",
"gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_SLTI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_slt_imm(VAR_1, OPC_SLTI, 24, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_SLTIU:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_slt_imm(VAR_1, OPC_SLTIU, 24, VAR_3, imm);",
"}",
"break;",
"case M16_OPC_I8:\n{",
"int VAR_12;",
"VAR_10 = (VAR_1->opcode >> 8) & 0x7;",
"switch (VAR_10) {",
"case I8_BTEQZ:\ngen_compute_branch(VAR_1, OPC_BEQ, 2, 24, 0,\n((int8_t)VAR_1->opcode) << 1);",
"break;",
"case I8_BTNEZ:\ngen_compute_branch(VAR_1, OPC_BNE, 2, 24, 0,\n((int8_t)VAR_1->opcode) << 1);",
"break;",
"case I8_SWRASP:\ngen_st(VAR_1, OPC_SW, 31, 29, (VAR_1->opcode & 0xff) << 2);",
"break;",
"case I8_ADJSP:\ngen_arith_imm(VAR_1, OPC_ADDIU, 29, 29,\n((int8_t)VAR_1->opcode) << 3);",
"break;",
"case I8_SVRS:\n{",
"int VAR_13 = VAR_1->opcode & (1 << 6);",
"int VAR_14 = VAR_1->opcode & (1 << 5);",
"int VAR_15 = VAR_1->opcode & (1 << 4);",
"int VAR_16 = VAR_1->opcode & 0xf;",
"if (VAR_16 == 0) {",
"VAR_16 = 128;",
"} else {",
"VAR_16 = VAR_16 << 3;",
"}",
"if (VAR_1->opcode & (1 << 7)) {",
"gen_mips16_save(VAR_1, 0, 0,\nVAR_13, VAR_14, VAR_15, VAR_16);",
"} else {",
"gen_mips16_restore(VAR_1, 0, 0,\nVAR_13, VAR_14, VAR_15, VAR_16);",
"}",
"}",
"break;",
"case I8_MOV32R:\n{",
"int VAR_18 = xlat(VAR_1->opcode & 0x7);",
"VAR_12 = (((VAR_1->opcode >> 3) & 0x3) << 3) |\n((VAR_1->opcode >> 5) & 0x7);",
"gen_arith(VAR_1, OPC_ADDU, VAR_12, VAR_18, 0);",
"}",
"break;",
"case I8_MOVR32:\nVAR_12 = VAR_1->opcode & 0x1f;",
"gen_arith(VAR_1, OPC_ADDU, VAR_4, VAR_12, 0);",
"break;",
"default:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"}",
"break;",
"case M16_OPC_LI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_arith_imm(VAR_1, OPC_ADDIU, VAR_3, 0, imm);",
"}",
"break;",
"case M16_OPC_CMPI:\n{",
"int16_t imm = (uint8_t) VAR_1->opcode;",
"gen_logic_imm(VAR_1, OPC_XORI, 24, VAR_3, imm);",
"}",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_SD:\ncheck_mips_64(VAR_1);",
"gen_st(VAR_1, OPC_SD, VAR_4, VAR_3, VAR_9 << 3);",
"break;",
"#endif\ncase M16_OPC_LB:\ngen_ld(VAR_1, OPC_LB, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_LH:\ngen_ld(VAR_1, OPC_LH, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_LWSP:\ngen_ld(VAR_1, OPC_LW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"case M16_OPC_LW:\ngen_ld(VAR_1, OPC_LW, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"case M16_OPC_LBU:\ngen_ld(VAR_1, OPC_LBU, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_LHU:\ngen_ld(VAR_1, OPC_LHU, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_LWPC:\ngen_ld(VAR_1, OPC_LWPC, VAR_3, 0, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"#if defined (TARGET_MIPS64)\ncase M16_OPC_LWU:\ncheck_mips_64(VAR_1);",
"gen_ld(VAR_1, OPC_LWU, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"#endif\ncase M16_OPC_SB:\ngen_st(VAR_1, OPC_SB, VAR_4, VAR_3, VAR_9);",
"break;",
"case M16_OPC_SH:\ngen_st(VAR_1, OPC_SH, VAR_4, VAR_3, VAR_9 << 1);",
"break;",
"case M16_OPC_SWSP:\ngen_st(VAR_1, OPC_SW, VAR_3, 29, ((uint8_t)VAR_1->opcode) << 2);",
"break;",
"case M16_OPC_SW:\ngen_st(VAR_1, OPC_SW, VAR_4, VAR_3, VAR_9 << 2);",
"break;",
"case M16_OPC_RRR:\n{",
"int VAR_18 = xlat((VAR_1->opcode >> 2) & 0x7);",
"int VAR_18;",
"switch (VAR_1->opcode & 0x3) {",
"case RRR_ADDU:\nVAR_18 = OPC_ADDU;",
"break;",
"case RRR_SUBU:\nVAR_18 = OPC_SUBU;",
"break;",
"#if defined(TARGET_MIPS64)\ncase RRR_DADDU:\nVAR_18 = OPC_DADDU;",
"check_mips_64(VAR_1);",
"break;",
"case RRR_DSUBU:\nVAR_18 = OPC_DSUBU;",
"check_mips_64(VAR_1);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"goto done;",
"}",
"gen_arith(VAR_1, VAR_18, VAR_18, VAR_3, VAR_4);",
"done:\n;",
"}",
"break;",
"case M16_OPC_RR:\nswitch (VAR_8) {",
"case RR_JR:\n{",
"int VAR_19 = (VAR_1->opcode >> 7) & 0x1;",
"int VAR_20 = (VAR_1->opcode >> 6) & 0x1;",
"int VAR_21 = (VAR_1->opcode >> 5) & 0x1;",
"if (VAR_20) {",
"VAR_6 = VAR_19 ? OPC_JALRC : OPC_JALRS;",
"} else {",
"VAR_6 = OPC_JR;",
"}",
"gen_compute_branch(VAR_1, VAR_6, 2, VAR_21 ? 31 : VAR_3, 31, 0);",
"if (!VAR_19) {",
"*VAR_2 = 1;",
"}",
"}",
"break;",
"case RR_SDBBP:\ncheck_insn(VAR_1, ISA_MIPS32);",
"if (!(VAR_1->hflags & MIPS_HFLAG_DM)) {",
"generate_exception(VAR_1, EXCP_DBp);",
"} else {",
"generate_exception(VAR_1, EXCP_DBp);",
"}",
"break;",
"case RR_SLT:\ngen_slt(VAR_1, OPC_SLT, 24, VAR_3, VAR_4);",
"break;",
"case RR_SLTU:\ngen_slt(VAR_1, OPC_SLTU, 24, VAR_3, VAR_4);",
"break;",
"case RR_BREAK:\ngenerate_exception(VAR_1, EXCP_BREAK);",
"break;",
"case RR_SLLV:\ngen_shift(VAR_1, OPC_SLLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_SRLV:\ngen_shift(VAR_1, OPC_SRLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_SRAV:\ngen_shift(VAR_1, OPC_SRAV, VAR_4, VAR_3, VAR_4);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DSRL:\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, OPC_DSRL, VAR_4, VAR_4, VAR_5);",
"break;",
"#endif\ncase RR_CMP:\ngen_logic(VAR_1, OPC_XOR, 24, VAR_3, VAR_4);",
"break;",
"case RR_NEG:\ngen_arith(VAR_1, OPC_SUBU, VAR_3, 0, VAR_4);",
"break;",
"case RR_AND:\ngen_logic(VAR_1, OPC_AND, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_OR:\ngen_logic(VAR_1, OPC_OR, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_XOR:\ngen_logic(VAR_1, OPC_XOR, VAR_3, VAR_3, VAR_4);",
"break;",
"case RR_NOT:\ngen_logic(VAR_1, OPC_NOR, VAR_3, VAR_4, 0);",
"break;",
"case RR_MFHI:\ngen_HILO(VAR_1, OPC_MFHI, 0, VAR_3);",
"break;",
"case RR_CNVT:\nswitch (VAR_7) {",
"case RR_RY_CNVT_ZEB:\ntcg_gen_ext8u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_ZEH:\ntcg_gen_ext16u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEB:\ntcg_gen_ext8s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEH:\ntcg_gen_ext16s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_RY_CNVT_ZEW:\ncheck_mips_64(VAR_1);",
"tcg_gen_ext32u_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"case RR_RY_CNVT_SEW:\ncheck_mips_64(VAR_1);",
"tcg_gen_ext32s_tl(cpu_gpr[VAR_3], cpu_gpr[VAR_3]);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case RR_MFLO:\ngen_HILO(VAR_1, OPC_MFLO, 0, VAR_3);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DSRA:\ncheck_mips_64(VAR_1);",
"gen_shift_imm(VAR_1, OPC_DSRA, VAR_4, VAR_4, VAR_5);",
"break;",
"case RR_DSLLV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_1, OPC_DSLLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_DSRLV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_1, OPC_DSRLV, VAR_4, VAR_3, VAR_4);",
"break;",
"case RR_DSRAV:\ncheck_mips_64(VAR_1);",
"gen_shift(VAR_1, OPC_DSRAV, VAR_4, VAR_3, VAR_4);",
"break;",
"#endif\ncase RR_MULT:\ngen_muldiv(VAR_1, OPC_MULT, 0, VAR_3, VAR_4);",
"break;",
"case RR_MULTU:\ngen_muldiv(VAR_1, OPC_MULTU, 0, VAR_3, VAR_4);",
"break;",
"case RR_DIV:\ngen_muldiv(VAR_1, OPC_DIV, 0, VAR_3, VAR_4);",
"break;",
"case RR_DIVU:\ngen_muldiv(VAR_1, OPC_DIVU, 0, VAR_3, VAR_4);",
"break;",
"#if defined (TARGET_MIPS64)\ncase RR_DMULT:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DMULT, 0, VAR_3, VAR_4);",
"break;",
"case RR_DMULTU:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DMULTU, 0, VAR_3, VAR_4);",
"break;",
"case RR_DDIV:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DDIV, 0, VAR_3, VAR_4);",
"break;",
"case RR_DDIVU:\ncheck_mips_64(VAR_1);",
"gen_muldiv(VAR_1, OPC_DDIVU, 0, VAR_3, VAR_4);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"break;",
"case M16_OPC_EXTEND:\ndecode_extended_mips16_opc(VAR_0, VAR_1, VAR_2);",
"VAR_11 = 4;",
"break;",
"#if defined(TARGET_MIPS64)\ncase M16_OPC_I64:\nVAR_10 = (VAR_1->opcode >> 8) & 0x7;",
"decode_i64_mips16(VAR_1, VAR_4, VAR_10, VAR_9, 0);",
"break;",
"#endif\ndefault:\ngenerate_exception(VAR_1, EXCP_RI);",
"break;",
"}",
"return VAR_11;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73,
75
],
[
77,
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95
],
[
99
],
[
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
],
[
171
],
[
173,
175
],
[
177
],
[
179,
181
],
[
183,
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195,
197
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209,
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
241
],
[
243
],
[
245,
247,
249
],
[
251
],
[
253,
255,
257
],
[
259
],
[
261,
263
],
[
265
],
[
267,
269,
271
],
[
273
],
[
275,
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
301
],
[
303,
305
],
[
307
],
[
309,
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337,
339
],
[
341
],
[
343
],
[
345,
347
],
[
349
],
[
351
],
[
353
],
[
355
],
[
357,
359
],
[
361
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385,
387
],
[
389
],
[
391
],
[
393,
395,
397
],
[
399
],
[
401,
403
],
[
405
],
[
407,
409
],
[
411
],
[
413,
415
],
[
417
],
[
419,
421
],
[
423
],
[
425,
427
],
[
429
],
[
431,
433
],
[
435
],
[
437,
439,
441
],
[
443
],
[
445
],
[
447,
449,
451
],
[
453
],
[
455,
457
],
[
459
],
[
461,
463
],
[
465
],
[
467,
469
],
[
471
],
[
473,
475
],
[
477
],
[
479
],
[
483
],
[
485,
487
],
[
489
],
[
491,
493
],
[
495
],
[
497,
499,
501
],
[
503
],
[
505
],
[
507,
509
],
[
511
],
[
513
],
[
515,
517,
519
],
[
521
],
[
523
],
[
527
],
[
529,
531
],
[
533
],
[
535
],
[
537,
539
],
[
541,
543
],
[
545
],
[
547
],
[
549
],
[
553
],
[
555
],
[
557
],
[
559
],
[
561
],
[
565
],
[
567
],
[
569
],
[
571
],
[
573
],
[
575
],
[
577,
585
],
[
587
],
[
589
],
[
591
],
[
593
],
[
595
],
[
597
],
[
599,
601
],
[
603
],
[
605,
607
],
[
609
],
[
611,
613
],
[
615
],
[
617,
619
],
[
621
],
[
623,
625
],
[
627
],
[
629,
631
],
[
633
],
[
635,
637,
639
],
[
641
],
[
643
],
[
645,
647,
649
],
[
651
],
[
653,
655
],
[
657
],
[
659,
661
],
[
663
],
[
665,
667
],
[
669
],
[
671,
673
],
[
675
],
[
677,
679
],
[
681
],
[
683,
685
],
[
687
],
[
689,
691
],
[
693,
695
],
[
697
],
[
699,
701
],
[
703
],
[
705,
707
],
[
709
],
[
711,
713
],
[
715
],
[
717,
719,
721
],
[
723
],
[
725
],
[
727,
729
],
[
731
],
[
733
],
[
735,
737,
739
],
[
741
],
[
743
],
[
745
],
[
747,
749
],
[
751
],
[
753,
755,
757
],
[
759
],
[
761
],
[
763,
765
],
[
767
],
[
769
],
[
771,
773
],
[
775
],
[
777
],
[
779,
781
],
[
783
],
[
785
],
[
787,
789,
791
],
[
793
],
[
795,
797
],
[
799
],
[
801,
803
],
[
805
],
[
807,
809
],
[
811
],
[
813,
815,
817
],
[
819
],
[
821
],
[
823,
825
],
[
827
],
[
829
],
[
831,
833
],
[
835
],
[
837
],
[
839,
841
],
[
843
],
[
845
],
[
847,
849,
851
],
[
853
],
[
855
],
[
857
],
[
859,
861
],
[
863
],
[
865
],
[
867,
869,
871
],
[
873
],
[
875
],
[
877,
879,
881
],
[
883
],
[
885
],
[
889
],
[
891
]
]
|
17,109 | static int arm_gic_common_init(SysBusDevice *dev)
{
GICState *s = FROM_SYSBUS(GICState, dev);
int num_irq = s->num_irq;
if (s->num_cpu > NCPU) {
hw_error("requested %u CPUs exceeds GIC maximum %d\n",
s->num_cpu, NCPU);
}
s->num_irq += GIC_BASE_IRQ;
if (s->num_irq > GIC_MAXIRQ) {
hw_error("requested %u interrupt lines exceeds GIC maximum %d\n",
num_irq, GIC_MAXIRQ);
}
/* ITLinesNumber is represented as (N / 32) - 1 (see
* gic_dist_readb) so this is an implementation imposed
* restriction, not an architectural one:
*/
if (s->num_irq < 32 || (s->num_irq % 32)) {
hw_error("%d interrupt lines unsupported: not divisible by 32\n",
num_irq);
}
register_savevm(NULL, "arm_gic", -1, 3, gic_save, gic_load, s);
return 0;
}
| true | qemu | 53111180946a56d314a9c1d07d09b9ef91e847b9 | static int arm_gic_common_init(SysBusDevice *dev)
{
GICState *s = FROM_SYSBUS(GICState, dev);
int num_irq = s->num_irq;
if (s->num_cpu > NCPU) {
hw_error("requested %u CPUs exceeds GIC maximum %d\n",
s->num_cpu, NCPU);
}
s->num_irq += GIC_BASE_IRQ;
if (s->num_irq > GIC_MAXIRQ) {
hw_error("requested %u interrupt lines exceeds GIC maximum %d\n",
num_irq, GIC_MAXIRQ);
}
if (s->num_irq < 32 || (s->num_irq % 32)) {
hw_error("%d interrupt lines unsupported: not divisible by 32\n",
num_irq);
}
register_savevm(NULL, "arm_gic", -1, 3, gic_save, gic_load, s);
return 0;
}
| {
"code": [
" GICState *s = FROM_SYSBUS(GICState, dev);",
" return 0;",
"static int arm_gic_common_init(SysBusDevice *dev)",
" GICState *s = FROM_SYSBUS(GICState, dev);",
" hw_error(\"requested %u CPUs exceeds GIC maximum %d\\n\",",
" s->num_cpu, NCPU);",
" hw_error(\"requested %u interrupt lines exceeds GIC maximum %d\\n\",",
" num_irq, GIC_MAXIRQ);",
" hw_error(\"%d interrupt lines unsupported: not divisible by 32\\n\",",
" num_irq);",
" return 0;",
" return 0;"
],
"line_no": [
5,
49,
1,
5,
13,
15,
23,
25,
39,
41,
49,
49
]
} | static int FUNC_0(SysBusDevice *VAR_0)
{
GICState *s = FROM_SYSBUS(GICState, VAR_0);
int VAR_1 = s->VAR_1;
if (s->num_cpu > NCPU) {
hw_error("requested %u CPUs exceeds GIC maximum %d\n",
s->num_cpu, NCPU);
}
s->VAR_1 += GIC_BASE_IRQ;
if (s->VAR_1 > GIC_MAXIRQ) {
hw_error("requested %u interrupt lines exceeds GIC maximum %d\n",
VAR_1, GIC_MAXIRQ);
}
if (s->VAR_1 < 32 || (s->VAR_1 % 32)) {
hw_error("%d interrupt lines unsupported: not divisible by 32\n",
VAR_1);
}
register_savevm(NULL, "arm_gic", -1, 3, gic_save, gic_load, s);
return 0;
}
| [
"static int FUNC_0(SysBusDevice *VAR_0)\n{",
"GICState *s = FROM_SYSBUS(GICState, VAR_0);",
"int VAR_1 = s->VAR_1;",
"if (s->num_cpu > NCPU) {",
"hw_error(\"requested %u CPUs exceeds GIC maximum %d\\n\",\ns->num_cpu, NCPU);",
"}",
"s->VAR_1 += GIC_BASE_IRQ;",
"if (s->VAR_1 > GIC_MAXIRQ) {",
"hw_error(\"requested %u interrupt lines exceeds GIC maximum %d\\n\",\nVAR_1, GIC_MAXIRQ);",
"}",
"if (s->VAR_1 < 32 || (s->VAR_1 % 32)) {",
"hw_error(\"%d interrupt lines unsupported: not divisible by 32\\n\",\nVAR_1);",
"}",
"register_savevm(NULL, \"arm_gic\", -1, 3, gic_save, gic_load, s);",
"return 0;",
"}"
]
| [
1,
1,
0,
0,
1,
0,
0,
0,
1,
0,
0,
1,
0,
0,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
37
],
[
39,
41
],
[
43
],
[
47
],
[
49
],
[
51
]
]
|
17,110 | static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *language,
kbd_layout_t * k)
{
FILE *f;
char * filename;
char line[1024];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
g_free(filename);
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
len = strlen(line);
if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
if (line[0] == '#')
continue;
if (!strncmp(line, "map ", 4))
continue;
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ')
end_of_keysym++;
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(table, line);
if (keysym == 0) {
// fprintf(stderr, "Warning: unknown keysym %s\n", line);
} else {
const char *rest = end_of_keysym + 1;
char *rest2;
int keycode = strtol(rest, &rest2, 0);
if (rest && strstr(rest, "numlock")) {
add_to_key_range(&k->keypad_range, keycode);
add_to_key_range(&k->numlock_range, keysym);
//fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
}
if (rest && strstr(rest, "shift"))
keycode |= SCANCODE_SHIFT;
if (rest && strstr(rest, "altgr"))
keycode |= SCANCODE_ALTGR;
if (rest && strstr(rest, "ctrl"))
keycode |= SCANCODE_CTRL;
add_keysym(line, keysym, keycode, k);
if (rest && strstr(rest, "addupper")) {
char *c;
for (c = line; *c; c++)
*c = qemu_toupper(*c);
keysym = get_keysym(table, line);
if (keysym)
add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k);
}
}
}
}
}
fclose(f);
return k;
}
| true | qemu | f2d3476eba17486c42357ba25c36bd26e627d1d7 | static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *language,
kbd_layout_t * k)
{
FILE *f;
char * filename;
char line[1024];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
g_free(filename);
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
len = strlen(line);
if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
if (line[0] == '#')
continue;
if (!strncmp(line, "map ", 4))
continue;
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ')
end_of_keysym++;
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(table, line);
if (keysym == 0) {
} else {
const char *rest = end_of_keysym + 1;
char *rest2;
int keycode = strtol(rest, &rest2, 0);
if (rest && strstr(rest, "numlock")) {
add_to_key_range(&k->keypad_range, keycode);
add_to_key_range(&k->numlock_range, keysym);
}
if (rest && strstr(rest, "shift"))
keycode |= SCANCODE_SHIFT;
if (rest && strstr(rest, "altgr"))
keycode |= SCANCODE_ALTGR;
if (rest && strstr(rest, "ctrl"))
keycode |= SCANCODE_CTRL;
add_keysym(line, keysym, keycode, k);
if (rest && strstr(rest, "addupper")) {
char *c;
for (c = line; *c; c++)
*c = qemu_toupper(*c);
keysym = get_keysym(table, line);
if (keysym)
add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k);
}
}
}
}
}
fclose(f);
return k;
}
| {
"code": [
" if (!k)",
"\tk = g_malloc0(sizeof(kbd_layout_t));",
" if (!(filename && (f = fopen(filename, \"r\")))) {",
" g_free(filename);"
],
"line_no": [
23,
25,
27,
37
]
} | static kbd_layout_t *FUNC_0(const name2keysym_t *table,
const char *language,
kbd_layout_t * k)
{
FILE *f;
char * VAR_0;
char VAR_1[1024];
int VAR_2;
VAR_0 = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
if (!(VAR_0 && (f = fopen(VAR_0, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
g_free(VAR_0);
for(;;) {
if (fgets(VAR_1, 1024, f) == NULL)
break;
VAR_2 = strlen(VAR_1);
if (VAR_2 > 0 && VAR_1[VAR_2 - 1] == '\n')
VAR_1[VAR_2 - 1] = '\0';
if (VAR_1[0] == '#')
continue;
if (!strncmp(VAR_1, "map ", 4))
continue;
if (!strncmp(VAR_1, "include ", 8)) {
FUNC_0(table, VAR_1 + 8, k);
} else {
char *VAR_3 = VAR_1;
while (*VAR_3 != 0 && *VAR_3 != ' ')
VAR_3++;
if (*VAR_3) {
int VAR_4;
*VAR_3 = 0;
VAR_4 = get_keysym(table, VAR_1);
if (VAR_4 == 0) {
} else {
const char *VAR_5 = VAR_3 + 1;
char *VAR_6;
int VAR_7 = strtol(VAR_5, &VAR_6, 0);
if (VAR_5 && strstr(VAR_5, "numlock")) {
add_to_key_range(&k->keypad_range, VAR_7);
add_to_key_range(&k->numlock_range, VAR_4);
}
if (VAR_5 && strstr(VAR_5, "shift"))
VAR_7 |= SCANCODE_SHIFT;
if (VAR_5 && strstr(VAR_5, "altgr"))
VAR_7 |= SCANCODE_ALTGR;
if (VAR_5 && strstr(VAR_5, "ctrl"))
VAR_7 |= SCANCODE_CTRL;
add_keysym(VAR_1, VAR_4, VAR_7, k);
if (VAR_5 && strstr(VAR_5, "addupper")) {
char *VAR_8;
for (VAR_8 = VAR_1; *VAR_8; VAR_8++)
*VAR_8 = qemu_toupper(*VAR_8);
VAR_4 = get_keysym(table, VAR_1);
if (VAR_4)
add_keysym(VAR_1, VAR_4, VAR_7 | SCANCODE_SHIFT, k);
}
}
}
}
}
fclose(f);
return k;
}
| [
"static kbd_layout_t *FUNC_0(const name2keysym_t *table,\nconst char *language,\nkbd_layout_t * k)\n{",
"FILE *f;",
"char * VAR_0;",
"char VAR_1[1024];",
"int VAR_2;",
"VAR_0 = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);",
"if (!k)\nk = g_malloc0(sizeof(kbd_layout_t));",
"if (!(VAR_0 && (f = fopen(VAR_0, \"r\")))) {",
"fprintf(stderr,\n\"Could not read keymap file: '%s'\\n\", language);",
"return NULL;",
"}",
"g_free(VAR_0);",
"for(;;) {",
"if (fgets(VAR_1, 1024, f) == NULL)\nbreak;",
"VAR_2 = strlen(VAR_1);",
"if (VAR_2 > 0 && VAR_1[VAR_2 - 1] == '\\n')\nVAR_1[VAR_2 - 1] = '\\0';",
"if (VAR_1[0] == '#')\ncontinue;",
"if (!strncmp(VAR_1, \"map \", 4))\ncontinue;",
"if (!strncmp(VAR_1, \"include \", 8)) {",
"FUNC_0(table, VAR_1 + 8, k);",
"} else {",
"char *VAR_3 = VAR_1;",
"while (*VAR_3 != 0 && *VAR_3 != ' ')\nVAR_3++;",
"if (*VAR_3) {",
"int VAR_4;",
"*VAR_3 = 0;",
"VAR_4 = get_keysym(table, VAR_1);",
"if (VAR_4 == 0) {",
"} else {",
"const char *VAR_5 = VAR_3 + 1;",
"char *VAR_6;",
"int VAR_7 = strtol(VAR_5, &VAR_6, 0);",
"if (VAR_5 && strstr(VAR_5, \"numlock\")) {",
"add_to_key_range(&k->keypad_range, VAR_7);",
"add_to_key_range(&k->numlock_range, VAR_4);",
"}",
"if (VAR_5 && strstr(VAR_5, \"shift\"))\nVAR_7 |= SCANCODE_SHIFT;",
"if (VAR_5 && strstr(VAR_5, \"altgr\"))\nVAR_7 |= SCANCODE_ALTGR;",
"if (VAR_5 && strstr(VAR_5, \"ctrl\"))\nVAR_7 |= SCANCODE_CTRL;",
"add_keysym(VAR_1, VAR_4, VAR_7, k);",
"if (VAR_5 && strstr(VAR_5, \"addupper\")) {",
"char *VAR_8;",
"for (VAR_8 = VAR_1; *VAR_8; VAR_8++)",
"*VAR_8 = qemu_toupper(*VAR_8);",
"VAR_4 = get_keysym(table, VAR_1);",
"if (VAR_4)\nadd_keysym(VAR_1, VAR_4, VAR_7 | SCANCODE_SHIFT, k);",
"}",
"}",
"}",
"}",
"}",
"fclose(f);",
"return k;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
1,
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
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
101
],
[
105,
107
],
[
109,
111
],
[
113,
115
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
]
]
|
17,111 | static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(f, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(sreq);
req->sreq = sreq;
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->sreq->cmd.mode == req_mode);
}
return req;
} | true | qemu | 3c3ce981423e0d6c18af82ee62f1850c2cda5976 | static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
{
SCSIBus *bus = sreq->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(f, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(sreq);
req->sreq = sreq;
if (req->sreq->cmd.mode != SCSI_XFER_NONE) {
int req_mode =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->sreq->cmd.mode == req_mode);
}
return req;
} | {
"code": [],
"line_no": []
} | static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)
{
SCSIBus *bus = VAR_1->bus;
VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
VirtIOSCSIReq *req;
uint32_t n;
req = g_malloc(sizeof(*req));
qemu_get_be32s(VAR_0, &n);
assert(n < vs->conf.num_queues);
qemu_get_buffer(VAR_0, (unsigned char *)&req->elem, sizeof(req->elem));
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
scsi_req_ref(VAR_1);
req->VAR_1 = VAR_1;
if (req->VAR_1->cmd.mode != SCSI_XFER_NONE) {
int VAR_2 =
(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);
assert(req->VAR_1->cmd.mode == VAR_2);
}
return req;
} | [
"static void *FUNC_0(QEMUFile *VAR_0, SCSIRequest *VAR_1)\n{",
"SCSIBus *bus = VAR_1->bus;",
"VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);",
"VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);",
"VirtIOSCSIReq *req;",
"uint32_t n;",
"req = g_malloc(sizeof(*req));",
"qemu_get_be32s(VAR_0, &n);",
"assert(n < vs->conf.num_queues);",
"qemu_get_buffer(VAR_0, (unsigned char *)&req->elem, sizeof(req->elem));",
"virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);",
"scsi_req_ref(VAR_1);",
"req->VAR_1 = VAR_1;",
"if (req->VAR_1->cmd.mode != SCSI_XFER_NONE) {",
"int VAR_2 =\n(req->elem.in_num > 1 ? SCSI_XFER_FROM_DEV : SCSI_XFER_TO_DEV);",
"assert(req->VAR_1->cmd.mode == VAR_2);",
"}",
"return req;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
34
],
[
38
],
[
40
],
[
42
],
[
44,
46
],
[
50
],
[
52
],
[
54
],
[
56
]
]
|
17,112 | static int svq1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
uint8_t *current, *previous;
int result, i, x, y, width, height;
AVFrame *pict = data;
svq1_pmv *pmv;
/* initialize bit buffer */
init_get_bits(&s->gb, buf, buf_size * 8);
/* decode frame header */
s->f_code = get_bits(&s->gb, 22);
if ((s->f_code & ~0x70) || !(s->f_code & 0x60))
return AVERROR_INVALIDDATA;
/* swap some header bytes (why?) */
if (s->f_code != 0x20) {
uint32_t *src = (uint32_t *)(buf + 4);
if (buf_size < 36)
return AVERROR_INVALIDDATA;
for (i = 0; i < 4; i++)
src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
}
result = svq1_decode_frame_header(&s->gb, s);
if (result) {
av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n", result);
return result;
}
avcodec_set_dimensions(avctx, s->width, s->height);
/* FIXME: This avoids some confusion for "B frames" without 2 references.
* This should be removed after libavcodec can handle more flexible
* picture types & ordering */
if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL)
return buf_size;
if ((avctx->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
return buf_size;
if ((result = ff_MPV_frame_start(s, avctx)) < 0)
return result;
pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
if (!pmv)
return AVERROR(ENOMEM);
/* decode y, u and v components */
for (i = 0; i < 3; i++) {
int linesize;
if (i == 0) {
width = FFALIGN(s->width, 16);
height = FFALIGN(s->height, 16);
linesize = s->linesize;
} else {
if (s->flags & CODEC_FLAG_GRAY)
break;
width = FFALIGN(s->width / 4, 16);
height = FFALIGN(s->height / 4, 16);
linesize = s->uvlinesize;
}
current = s->current_picture.f.data[i];
if (s->pict_type == AV_PICTURE_TYPE_B)
previous = s->next_picture.f.data[i];
else
previous = s->last_picture.f.data[i];
if (s->pict_type == AV_PICTURE_TYPE_I) {
/* keyframe */
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
result = svq1_decode_block_intra(&s->gb, ¤t[x],
linesize);
if (result) {
av_log(s->avctx, AV_LOG_ERROR,
"Error in svq1_decode_block %i (keyframe)\n",
result);
goto err;
}
}
current += 16 * linesize;
}
} else {
/* delta frame */
memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
result = svq1_decode_delta_block(s, &s->gb, ¤t[x],
previous, linesize,
pmv, x, y);
if (result) {
av_dlog(s->avctx,
"Error in svq1_decode_delta_block %i\n",
result);
goto err;
}
}
pmv[0].x =
pmv[0].y = 0;
current += 16 * linesize;
}
}
}
*pict = s->current_picture.f;
ff_MPV_frame_end(s);
*data_size = sizeof(AVFrame);
result = buf_size;
err:
av_free(pmv);
return result;
} | true | FFmpeg | 0a373c31cb7f8dae84857881cd7e3829a6483efe | static int svq1_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
uint8_t *current, *previous;
int result, i, x, y, width, height;
AVFrame *pict = data;
svq1_pmv *pmv;
init_get_bits(&s->gb, buf, buf_size * 8);
s->f_code = get_bits(&s->gb, 22);
if ((s->f_code & ~0x70) || !(s->f_code & 0x60))
return AVERROR_INVALIDDATA;
if (s->f_code != 0x20) {
uint32_t *src = (uint32_t *)(buf + 4);
if (buf_size < 36)
return AVERROR_INVALIDDATA;
for (i = 0; i < 4; i++)
src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
}
result = svq1_decode_frame_header(&s->gb, s);
if (result) {
av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n", result);
return result;
}
avcodec_set_dimensions(avctx, s->width, s->height);
if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL)
return buf_size;
if ((avctx->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
return buf_size;
if ((result = ff_MPV_frame_start(s, avctx)) < 0)
return result;
pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
if (!pmv)
return AVERROR(ENOMEM);
for (i = 0; i < 3; i++) {
int linesize;
if (i == 0) {
width = FFALIGN(s->width, 16);
height = FFALIGN(s->height, 16);
linesize = s->linesize;
} else {
if (s->flags & CODEC_FLAG_GRAY)
break;
width = FFALIGN(s->width / 4, 16);
height = FFALIGN(s->height / 4, 16);
linesize = s->uvlinesize;
}
current = s->current_picture.f.data[i];
if (s->pict_type == AV_PICTURE_TYPE_B)
previous = s->next_picture.f.data[i];
else
previous = s->last_picture.f.data[i];
if (s->pict_type == AV_PICTURE_TYPE_I) {
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
result = svq1_decode_block_intra(&s->gb, ¤t[x],
linesize);
if (result) {
av_log(s->avctx, AV_LOG_ERROR,
"Error in svq1_decode_block %i (keyframe)\n",
result);
goto err;
}
}
current += 16 * linesize;
}
} else {
memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
result = svq1_decode_delta_block(s, &s->gb, ¤t[x],
previous, linesize,
pmv, x, y);
if (result) {
av_dlog(s->avctx,
"Error in svq1_decode_delta_block %i\n",
result);
goto err;
}
}
pmv[0].x =
pmv[0].y = 0;
current += 16 * linesize;
}
}
}
*pict = s->current_picture.f;
ff_MPV_frame_end(s);
*data_size = sizeof(AVFrame);
result = buf_size;
err:
av_free(pmv);
return result;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
MpegEncContext *s = VAR_0->priv_data;
uint8_t *current, *previous;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;
AVFrame *pict = VAR_1;
svq1_pmv *pmv;
init_get_bits(&s->gb, VAR_4, VAR_5 * 8);
s->f_code = get_bits(&s->gb, 22);
if ((s->f_code & ~0x70) || !(s->f_code & 0x60))
return AVERROR_INVALIDDATA;
if (s->f_code != 0x20) {
uint32_t *src = (uint32_t *)(VAR_4 + 4);
if (VAR_5 < 36)
return AVERROR_INVALIDDATA;
for (VAR_7 = 0; VAR_7 < 4; VAR_7++)
src[VAR_7] = ((src[VAR_7] << 16) | (src[VAR_7] >> 16)) ^ src[7 - VAR_7];
}
VAR_6 = svq1_decode_frame_header(&s->gb, s);
if (VAR_6) {
av_dlog(s->VAR_0, "Error in svq1_decode_frame_header %VAR_7\n", VAR_6);
return VAR_6;
}
avcodec_set_dimensions(VAR_0, s->VAR_10, s->VAR_11);
if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL)
return VAR_5;
if ((VAR_0->skip_frame >= AVDISCARD_NONREF &&
s->pict_type == AV_PICTURE_TYPE_B) ||
(VAR_0->skip_frame >= AVDISCARD_NONKEY &&
s->pict_type != AV_PICTURE_TYPE_I) ||
VAR_0->skip_frame >= AVDISCARD_ALL)
return VAR_5;
if ((VAR_6 = ff_MPV_frame_start(s, VAR_0)) < 0)
return VAR_6;
pmv = av_malloc((FFALIGN(s->VAR_10, 16) / 8 + 3) * sizeof(*pmv));
if (!pmv)
return AVERROR(ENOMEM);
for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {
int VAR_12;
if (VAR_7 == 0) {
VAR_10 = FFALIGN(s->VAR_10, 16);
VAR_11 = FFALIGN(s->VAR_11, 16);
VAR_12 = s->VAR_12;
} else {
if (s->flags & CODEC_FLAG_GRAY)
break;
VAR_10 = FFALIGN(s->VAR_10 / 4, 16);
VAR_11 = FFALIGN(s->VAR_11 / 4, 16);
VAR_12 = s->uvlinesize;
}
current = s->current_picture.f.VAR_1[VAR_7];
if (s->pict_type == AV_PICTURE_TYPE_B)
previous = s->next_picture.f.VAR_1[VAR_7];
else
previous = s->last_picture.f.VAR_1[VAR_7];
if (s->pict_type == AV_PICTURE_TYPE_I) {
for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9 += 16) {
for (VAR_8 = 0; VAR_8 < VAR_10; VAR_8 += 16) {
VAR_6 = svq1_decode_block_intra(&s->gb, ¤t[VAR_8],
VAR_12);
if (VAR_6) {
av_log(s->VAR_0, AV_LOG_ERROR,
"Error in svq1_decode_block %VAR_7 (keyframe)\n",
VAR_6);
goto err;
}
}
current += 16 * VAR_12;
}
} else {
memset(pmv, 0, ((VAR_10 / 8) + 3) * sizeof(svq1_pmv));
for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9 += 16) {
for (VAR_8 = 0; VAR_8 < VAR_10; VAR_8 += 16) {
VAR_6 = svq1_decode_delta_block(s, &s->gb, ¤t[VAR_8],
previous, VAR_12,
pmv, VAR_8, VAR_9);
if (VAR_6) {
av_dlog(s->VAR_0,
"Error in svq1_decode_delta_block %VAR_7\n",
VAR_6);
goto err;
}
}
pmv[0].VAR_8 =
pmv[0].VAR_9 = 0;
current += 16 * VAR_12;
}
}
}
*pict = s->current_picture.f;
ff_MPV_frame_end(s);
*VAR_2 = sizeof(AVFrame);
VAR_6 = VAR_5;
err:
av_free(pmv);
return VAR_6;
} | [
"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;",
"MpegEncContext *s = VAR_0->priv_data;",
"uint8_t *current, *previous;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;",
"AVFrame *pict = VAR_1;",
"svq1_pmv *pmv;",
"init_get_bits(&s->gb, VAR_4, VAR_5 * 8);",
"s->f_code = get_bits(&s->gb, 22);",
"if ((s->f_code & ~0x70) || !(s->f_code & 0x60))\nreturn AVERROR_INVALIDDATA;",
"if (s->f_code != 0x20) {",
"uint32_t *src = (uint32_t *)(VAR_4 + 4);",
"if (VAR_5 < 36)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_7 = 0; VAR_7 < 4; VAR_7++)",
"src[VAR_7] = ((src[VAR_7] << 16) | (src[VAR_7] >> 16)) ^ src[7 - VAR_7];",
"}",
"VAR_6 = svq1_decode_frame_header(&s->gb, s);",
"if (VAR_6) {",
"av_dlog(s->VAR_0, \"Error in svq1_decode_frame_header %VAR_7\\n\", VAR_6);",
"return VAR_6;",
"}",
"avcodec_set_dimensions(VAR_0, s->VAR_10, s->VAR_11);",
"if (s->pict_type == AV_PICTURE_TYPE_B && s->last_picture_ptr == NULL)\nreturn VAR_5;",
"if ((VAR_0->skip_frame >= AVDISCARD_NONREF &&\ns->pict_type == AV_PICTURE_TYPE_B) ||\n(VAR_0->skip_frame >= AVDISCARD_NONKEY &&\ns->pict_type != AV_PICTURE_TYPE_I) ||\nVAR_0->skip_frame >= AVDISCARD_ALL)\nreturn VAR_5;",
"if ((VAR_6 = ff_MPV_frame_start(s, VAR_0)) < 0)\nreturn VAR_6;",
"pmv = av_malloc((FFALIGN(s->VAR_10, 16) / 8 + 3) * sizeof(*pmv));",
"if (!pmv)\nreturn AVERROR(ENOMEM);",
"for (VAR_7 = 0; VAR_7 < 3; VAR_7++) {",
"int VAR_12;",
"if (VAR_7 == 0) {",
"VAR_10 = FFALIGN(s->VAR_10, 16);",
"VAR_11 = FFALIGN(s->VAR_11, 16);",
"VAR_12 = s->VAR_12;",
"} else {",
"if (s->flags & CODEC_FLAG_GRAY)\nbreak;",
"VAR_10 = FFALIGN(s->VAR_10 / 4, 16);",
"VAR_11 = FFALIGN(s->VAR_11 / 4, 16);",
"VAR_12 = s->uvlinesize;",
"}",
"current = s->current_picture.f.VAR_1[VAR_7];",
"if (s->pict_type == AV_PICTURE_TYPE_B)\nprevious = s->next_picture.f.VAR_1[VAR_7];",
"else\nprevious = s->last_picture.f.VAR_1[VAR_7];",
"if (s->pict_type == AV_PICTURE_TYPE_I) {",
"for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9 += 16) {",
"for (VAR_8 = 0; VAR_8 < VAR_10; VAR_8 += 16) {",
"VAR_6 = svq1_decode_block_intra(&s->gb, ¤t[VAR_8],\nVAR_12);",
"if (VAR_6) {",
"av_log(s->VAR_0, AV_LOG_ERROR,\n\"Error in svq1_decode_block %VAR_7 (keyframe)\\n\",\nVAR_6);",
"goto err;",
"}",
"}",
"current += 16 * VAR_12;",
"}",
"} else {",
"memset(pmv, 0, ((VAR_10 / 8) + 3) * sizeof(svq1_pmv));",
"for (VAR_9 = 0; VAR_9 < VAR_11; VAR_9 += 16) {",
"for (VAR_8 = 0; VAR_8 < VAR_10; VAR_8 += 16) {",
"VAR_6 = svq1_decode_delta_block(s, &s->gb, ¤t[VAR_8],\nprevious, VAR_12,\npmv, VAR_8, VAR_9);",
"if (VAR_6) {",
"av_dlog(s->VAR_0,\n\"Error in svq1_decode_delta_block %VAR_7\\n\",\nVAR_6);",
"goto err;",
"}",
"}",
"pmv[0].VAR_8 =\npmv[0].VAR_9 = 0;",
"current += 16 * VAR_12;",
"}",
"}",
"}",
"*pict = s->current_picture.f;",
"ff_MPV_frame_end(s);",
"*VAR_2 = sizeof(AVFrame);",
"VAR_6 = VAR_5;",
"err:\nav_free(pmv);",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
31
],
[
35,
37
],
[
43
],
[
45
],
[
49,
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
83,
85
],
[
89,
91,
93,
95,
97,
99
],
[
103,
105
],
[
109
],
[
111,
113
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
151,
153
],
[
155,
157
],
[
161
],
[
165
],
[
167
],
[
169,
171
],
[
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
199
],
[
201
],
[
203,
205,
207
],
[
209
],
[
211,
213,
215
],
[
217
],
[
219
],
[
221
],
[
225,
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
241
],
[
246
],
[
250
],
[
252
],
[
256,
258
],
[
260
],
[
262
]
]
|
17,114 | bool migrate_rdma_pin_all(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | bool migrate_rdma_pin_all(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(void)
{
MigrationState *s;
s = migrate_get_current();
return s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];
}
| [
"bool FUNC_0(void)\n{",
"MigrationState *s;",
"s = migrate_get_current();",
"return s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL];",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
]
]
|
17,115 | static void openpic_reset (void *opaque)
{
openpic_t *opp = (openpic_t *)opaque;
int i;
opp->glbc = 0x80000000;
/* Initialise controller registers */
opp->frep = ((OPENPIC_EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
opp->veni = VENI;
opp->pint = 0x00000000;
opp->spve = 0x000000FF;
opp->tifr = 0x003F7A00;
/* ? */
opp->micr = 0x00000000;
/* Initialise IRQ sources */
for (i = 0; i < opp->max_irq; i++) {
opp->src[i].ipvp = 0xA0000000;
opp->src[i].ide = 0x00000000;
}
/* Initialise IRQ destinations */
for (i = 0; i < MAX_CPU; i++) {
opp->dst[i].pctp = 0x0000000F;
opp->dst[i].pcsr = 0x00000000;
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
memset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));
}
/* Initialise timers */
for (i = 0; i < MAX_TMR; i++) {
opp->timers[i].ticc = 0x00000000;
opp->timers[i].tibc = 0x80000000;
}
/* Initialise doorbells */
#if MAX_DBL > 0
opp->dar = 0x00000000;
for (i = 0; i < MAX_DBL; i++) {
opp->doorbells[i].dmr = 0x00000000;
}
#endif
/* Initialise mailboxes */
#if MAX_MBX > 0
for (i = 0; i < MAX_MBX; i++) { /* ? */
opp->mailboxes[i].mbr = 0x00000000;
}
#endif
/* Go out of RESET state */
opp->glbc = 0x00000000;
} | true | qemu | d14ed2548c3163cdb316eb4da36cd7a6a8975da4 | static void openpic_reset (void *opaque)
{
openpic_t *opp = (openpic_t *)opaque;
int i;
opp->glbc = 0x80000000;
opp->frep = ((OPENPIC_EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
opp->veni = VENI;
opp->pint = 0x00000000;
opp->spve = 0x000000FF;
opp->tifr = 0x003F7A00;
opp->micr = 0x00000000;
for (i = 0; i < opp->max_irq; i++) {
opp->src[i].ipvp = 0xA0000000;
opp->src[i].ide = 0x00000000;
}
for (i = 0; i < MAX_CPU; i++) {
opp->dst[i].pctp = 0x0000000F;
opp->dst[i].pcsr = 0x00000000;
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
memset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));
}
for (i = 0; i < MAX_TMR; i++) {
opp->timers[i].ticc = 0x00000000;
opp->timers[i].tibc = 0x80000000;
}
#if MAX_DBL > 0
opp->dar = 0x00000000;
for (i = 0; i < MAX_DBL; i++) {
opp->doorbells[i].dmr = 0x00000000;
}
#endif
#if MAX_MBX > 0
for (i = 0; i < MAX_MBX; i++) {
opp->mailboxes[i].mbr = 0x00000000;
}
#endif
opp->glbc = 0x00000000;
} | {
"code": [],
"line_no": []
} | static void FUNC_0 (void *VAR_0)
{
openpic_t *opp = (openpic_t *)VAR_0;
int VAR_1;
opp->glbc = 0x80000000;
opp->frep = ((OPENPIC_EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
opp->veni = VENI;
opp->pint = 0x00000000;
opp->spve = 0x000000FF;
opp->tifr = 0x003F7A00;
opp->micr = 0x00000000;
for (VAR_1 = 0; VAR_1 < opp->max_irq; VAR_1++) {
opp->src[VAR_1].ipvp = 0xA0000000;
opp->src[VAR_1].ide = 0x00000000;
}
for (VAR_1 = 0; VAR_1 < MAX_CPU; VAR_1++) {
opp->dst[VAR_1].pctp = 0x0000000F;
opp->dst[VAR_1].pcsr = 0x00000000;
memset(&opp->dst[VAR_1].raised, 0, sizeof(IRQ_queue_t));
memset(&opp->dst[VAR_1].servicing, 0, sizeof(IRQ_queue_t));
}
for (VAR_1 = 0; VAR_1 < MAX_TMR; VAR_1++) {
opp->timers[VAR_1].ticc = 0x00000000;
opp->timers[VAR_1].tibc = 0x80000000;
}
#if MAX_DBL > 0
opp->dar = 0x00000000;
for (VAR_1 = 0; VAR_1 < MAX_DBL; VAR_1++) {
opp->doorbells[VAR_1].dmr = 0x00000000;
}
#endif
#if MAX_MBX > 0
for (VAR_1 = 0; VAR_1 < MAX_MBX; VAR_1++) {
opp->mailboxes[VAR_1].mbr = 0x00000000;
}
#endif
opp->glbc = 0x00000000;
} | [
"static void FUNC_0 (void *VAR_0)\n{",
"openpic_t *opp = (openpic_t *)VAR_0;",
"int VAR_1;",
"opp->glbc = 0x80000000;",
"opp->frep = ((OPENPIC_EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;",
"opp->veni = VENI;",
"opp->pint = 0x00000000;",
"opp->spve = 0x000000FF;",
"opp->tifr = 0x003F7A00;",
"opp->micr = 0x00000000;",
"for (VAR_1 = 0; VAR_1 < opp->max_irq; VAR_1++) {",
"opp->src[VAR_1].ipvp = 0xA0000000;",
"opp->src[VAR_1].ide = 0x00000000;",
"}",
"for (VAR_1 = 0; VAR_1 < MAX_CPU; VAR_1++) {",
"opp->dst[VAR_1].pctp = 0x0000000F;",
"opp->dst[VAR_1].pcsr = 0x00000000;",
"memset(&opp->dst[VAR_1].raised, 0, sizeof(IRQ_queue_t));",
"memset(&opp->dst[VAR_1].servicing, 0, sizeof(IRQ_queue_t));",
"}",
"for (VAR_1 = 0; VAR_1 < MAX_TMR; VAR_1++) {",
"opp->timers[VAR_1].ticc = 0x00000000;",
"opp->timers[VAR_1].tibc = 0x80000000;",
"}",
"#if MAX_DBL > 0\nopp->dar = 0x00000000;",
"for (VAR_1 = 0; VAR_1 < MAX_DBL; VAR_1++) {",
"opp->doorbells[VAR_1].dmr = 0x00000000;",
"}",
"#endif\n#if MAX_MBX > 0\nfor (VAR_1 = 0; VAR_1 < MAX_MBX; VAR_1++) {",
"opp->mailboxes[VAR_1].mbr = 0x00000000;",
"}",
"#endif\nopp->glbc = 0x00000000;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
50
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
77,
81,
83
],
[
85
],
[
87
],
[
89,
93
],
[
95
]
]
|
17,116 | static av_cold void movie_uninit(AVFilterContext *ctx)
{
MovieContext *movie = ctx->priv;
int i;
for (i = 0; i < ctx->nb_outputs; i++) {
av_freep(&ctx->output_pads[i].name);
if (movie->st[i].st)
avcodec_close(movie->st[i].st->codec);
}
av_freep(&movie->st);
av_freep(&movie->out_index);
av_frame_free(&movie->frame);
if (movie->format_ctx)
avformat_close_input(&movie->format_ctx);
}
| true | FFmpeg | 97392553656a7f4fabde9ded4d2b7f538d98ee17 | static av_cold void movie_uninit(AVFilterContext *ctx)
{
MovieContext *movie = ctx->priv;
int i;
for (i = 0; i < ctx->nb_outputs; i++) {
av_freep(&ctx->output_pads[i].name);
if (movie->st[i].st)
avcodec_close(movie->st[i].st->codec);
}
av_freep(&movie->st);
av_freep(&movie->out_index);
av_frame_free(&movie->frame);
if (movie->format_ctx)
avformat_close_input(&movie->format_ctx);
}
| {
"code": [
" av_frame_free(&movie->frame);"
],
"line_no": [
25
]
} | static av_cold void FUNC_0(AVFilterContext *ctx)
{
MovieContext *movie = ctx->priv;
int VAR_0;
for (VAR_0 = 0; VAR_0 < ctx->nb_outputs; VAR_0++) {
av_freep(&ctx->output_pads[VAR_0].name);
if (movie->st[VAR_0].st)
avcodec_close(movie->st[VAR_0].st->codec);
}
av_freep(&movie->st);
av_freep(&movie->out_index);
av_frame_free(&movie->frame);
if (movie->format_ctx)
avformat_close_input(&movie->format_ctx);
}
| [
"static av_cold void FUNC_0(AVFilterContext *ctx)\n{",
"MovieContext *movie = ctx->priv;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < ctx->nb_outputs; VAR_0++) {",
"av_freep(&ctx->output_pads[VAR_0].name);",
"if (movie->st[VAR_0].st)\navcodec_close(movie->st[VAR_0].st->codec);",
"}",
"av_freep(&movie->st);",
"av_freep(&movie->out_index);",
"av_frame_free(&movie->frame);",
"if (movie->format_ctx)\navformat_close_input(&movie->format_ctx);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
29
],
[
31
]
]
|
17,117 | static XICSState *xics_system_init(MachineState *machine,
int nr_servers, int nr_irqs)
{
XICSState *icp = NULL;
if (kvm_enabled()) {
Error *err = NULL;
if (machine_kernel_irqchip_allowed(machine)) {
icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !icp) {
error_report("kernel_irqchip requested but unavailable: %s",
error_get_pretty(err));
}
}
if (!icp) {
icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);
}
return icp;
} | true | qemu | 903a41d3415960240cb3b9f1d66f3707b27010d6 | static XICSState *xics_system_init(MachineState *machine,
int nr_servers, int nr_irqs)
{
XICSState *icp = NULL;
if (kvm_enabled()) {
Error *err = NULL;
if (machine_kernel_irqchip_allowed(machine)) {
icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !icp) {
error_report("kernel_irqchip requested but unavailable: %s",
error_get_pretty(err));
}
}
if (!icp) {
icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);
}
return icp;
} | {
"code": [],
"line_no": []
} | static XICSState *FUNC_0(MachineState *machine,
int nr_servers, int nr_irqs)
{
XICSState *icp = NULL;
if (kvm_enabled()) {
Error *err = NULL;
if (machine_kernel_irqchip_allowed(machine)) {
icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !icp) {
error_report("kernel_irqchip requested but unavailable: %s",
error_get_pretty(err));
}
}
if (!icp) {
icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);
}
return icp;
} | [
"static XICSState *FUNC_0(MachineState *machine,\nint nr_servers, int nr_irqs)\n{",
"XICSState *icp = NULL;",
"if (kvm_enabled()) {",
"Error *err = NULL;",
"if (machine_kernel_irqchip_allowed(machine)) {",
"icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);",
"}",
"if (machine_kernel_irqchip_required(machine) && !icp) {",
"error_report(\"kernel_irqchip requested but unavailable: %s\",\nerror_get_pretty(err));",
"}",
"}",
"if (!icp) {",
"icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);",
"}",
"return icp;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
32
],
[
36
],
[
38
],
[
40
],
[
44
],
[
46
]
]
|
17,119 | static void chroma(WaveformContext *s, AVFrame *in, AVFrame *out,
int component, int intensity, int offset, int column)
{
const int plane = s->desc->comp[component].plane;
const int mirror = s->mirror;
const int c0_linesize = in->linesize[(plane + 1) % s->ncomp];
const int c1_linesize = in->linesize[(plane + 2) % s->ncomp];
const int dst_linesize = out->linesize[plane];
const int max = 255 - intensity;
const int src_h = in->height;
const int src_w = in->width;
int x, y;
if (column) {
const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
for (x = 0; x < src_w; x++) {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset * dst_linesize;
uint8_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
uint8_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
uint8_t *dst = dst_line;
for (y = 0; y < src_h; y++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
target = dst + x + dst_signed_linesize * p;
update(target, max, 1);
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
} else {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset;
if (mirror)
dst_data += s->size - 1;
for (y = 0; y < src_h; y++) {
for (x = 0; x < src_w; x++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
if (mirror)
target = dst_data - p;
else
target = dst_data + p;
update(target, max, 1);
}
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
envelope(s, out, plane, (plane + 0) % s->ncomp);
}
| false | FFmpeg | 5b349c8d7cc5dd26b3fbbce6e3883ce02861eeb7 | static void chroma(WaveformContext *s, AVFrame *in, AVFrame *out,
int component, int intensity, int offset, int column)
{
const int plane = s->desc->comp[component].plane;
const int mirror = s->mirror;
const int c0_linesize = in->linesize[(plane + 1) % s->ncomp];
const int c1_linesize = in->linesize[(plane + 2) % s->ncomp];
const int dst_linesize = out->linesize[plane];
const int max = 255 - intensity;
const int src_h = in->height;
const int src_w = in->width;
int x, y;
if (column) {
const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
for (x = 0; x < src_w; x++) {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset * dst_linesize;
uint8_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
uint8_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
uint8_t *dst = dst_line;
for (y = 0; y < src_h; y++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
target = dst + x + dst_signed_linesize * p;
update(target, max, 1);
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
} else {
const uint8_t *c0_data = in->data[(plane + 1) % s->ncomp];
const uint8_t *c1_data = in->data[(plane + 2) % s->ncomp];
uint8_t *dst_data = out->data[plane] + offset;
if (mirror)
dst_data += s->size - 1;
for (y = 0; y < src_h; y++) {
for (x = 0; x < src_w; x++) {
const int sum = FFABS(c0_data[x] - 128) + FFABS(c1_data[x] - 128);
uint8_t *target;
int p;
for (p = 256 - sum; p < 256 + sum; p++) {
if (mirror)
target = dst_data - p;
else
target = dst_data + p;
update(target, max, 1);
}
}
c0_data += c0_linesize;
c1_data += c1_linesize;
dst_data += dst_linesize;
}
}
envelope(s, out, plane, (plane + 0) % s->ncomp);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2,
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{
const int VAR_7 = VAR_0->desc->comp[VAR_3].VAR_7;
const int VAR_8 = VAR_0->VAR_8;
const int VAR_9 = VAR_1->linesize[(VAR_7 + 1) % VAR_0->ncomp];
const int VAR_10 = VAR_1->linesize[(VAR_7 + 2) % VAR_0->ncomp];
const int VAR_11 = VAR_2->linesize[VAR_7];
const int VAR_12 = 255 - VAR_4;
const int VAR_13 = VAR_1->height;
const int VAR_14 = VAR_1->width;
int VAR_15, VAR_16;
if (VAR_6) {
const int VAR_17 = VAR_11 * (VAR_8 == 1 ? -1 : 1);
for (VAR_15 = 0; VAR_15 < VAR_14; VAR_15++) {
const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp];
const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp];
uint8_t *dst_data = VAR_2->data[VAR_7] + VAR_5 * VAR_11;
uint8_t * const dst_bottom_line = dst_data + VAR_11 * (VAR_0->size - 1);
uint8_t * const dst_line = (VAR_8 ? dst_bottom_line : dst_data);
uint8_t *dst = dst_line;
for (VAR_16 = 0; VAR_16 < VAR_13; VAR_16++) {
const int VAR_22 = FFABS(VAR_22[VAR_15] - 128) + FFABS(VAR_22[VAR_15] - 128);
uint8_t *target;
int VAR_22;
for (VAR_22 = 256 - VAR_22; VAR_22 < 256 + VAR_22; VAR_22++) {
target = dst + VAR_15 + VAR_17 * VAR_22;
update(target, VAR_12, 1);
}
VAR_22 += VAR_9;
VAR_22 += VAR_10;
dst_data += VAR_11;
}
}
} else {
const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp];
const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp];
uint8_t *dst_data = VAR_2->data[VAR_7] + VAR_5;
if (VAR_8)
dst_data += VAR_0->size - 1;
for (VAR_16 = 0; VAR_16 < VAR_13; VAR_16++) {
for (VAR_15 = 0; VAR_15 < VAR_14; VAR_15++) {
const int VAR_22 = FFABS(VAR_22[VAR_15] - 128) + FFABS(VAR_22[VAR_15] - 128);
uint8_t *target;
int VAR_22;
for (VAR_22 = 256 - VAR_22; VAR_22 < 256 + VAR_22; VAR_22++) {
if (VAR_8)
target = dst_data - VAR_22;
else
target = dst_data + VAR_22;
update(target, VAR_12, 1);
}
}
VAR_22 += VAR_9;
VAR_22 += VAR_10;
dst_data += VAR_11;
}
}
envelope(VAR_0, VAR_2, VAR_7, (VAR_7 + 0) % VAR_0->ncomp);
}
| [
"static void FUNC_0(WaveformContext *VAR_0, AVFrame *VAR_1, AVFrame *VAR_2,\nint VAR_3, int VAR_4, int VAR_5, int VAR_6)\n{",
"const int VAR_7 = VAR_0->desc->comp[VAR_3].VAR_7;",
"const int VAR_8 = VAR_0->VAR_8;",
"const int VAR_9 = VAR_1->linesize[(VAR_7 + 1) % VAR_0->ncomp];",
"const int VAR_10 = VAR_1->linesize[(VAR_7 + 2) % VAR_0->ncomp];",
"const int VAR_11 = VAR_2->linesize[VAR_7];",
"const int VAR_12 = 255 - VAR_4;",
"const int VAR_13 = VAR_1->height;",
"const int VAR_14 = VAR_1->width;",
"int VAR_15, VAR_16;",
"if (VAR_6) {",
"const int VAR_17 = VAR_11 * (VAR_8 == 1 ? -1 : 1);",
"for (VAR_15 = 0; VAR_15 < VAR_14; VAR_15++) {",
"const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp];",
"const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp];",
"uint8_t *dst_data = VAR_2->data[VAR_7] + VAR_5 * VAR_11;",
"uint8_t * const dst_bottom_line = dst_data + VAR_11 * (VAR_0->size - 1);",
"uint8_t * const dst_line = (VAR_8 ? dst_bottom_line : dst_data);",
"uint8_t *dst = dst_line;",
"for (VAR_16 = 0; VAR_16 < VAR_13; VAR_16++) {",
"const int VAR_22 = FFABS(VAR_22[VAR_15] - 128) + FFABS(VAR_22[VAR_15] - 128);",
"uint8_t *target;",
"int VAR_22;",
"for (VAR_22 = 256 - VAR_22; VAR_22 < 256 + VAR_22; VAR_22++) {",
"target = dst + VAR_15 + VAR_17 * VAR_22;",
"update(target, VAR_12, 1);",
"}",
"VAR_22 += VAR_9;",
"VAR_22 += VAR_10;",
"dst_data += VAR_11;",
"}",
"}",
"} else {",
"const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 1) % VAR_0->ncomp];",
"const uint8_t *VAR_22 = VAR_1->data[(VAR_7 + 2) % VAR_0->ncomp];",
"uint8_t *dst_data = VAR_2->data[VAR_7] + VAR_5;",
"if (VAR_8)\ndst_data += VAR_0->size - 1;",
"for (VAR_16 = 0; VAR_16 < VAR_13; VAR_16++) {",
"for (VAR_15 = 0; VAR_15 < VAR_14; VAR_15++) {",
"const int VAR_22 = FFABS(VAR_22[VAR_15] - 128) + FFABS(VAR_22[VAR_15] - 128);",
"uint8_t *target;",
"int VAR_22;",
"for (VAR_22 = 256 - VAR_22; VAR_22 < 256 + VAR_22; VAR_22++) {",
"if (VAR_8)\ntarget = dst_data - VAR_22;",
"else\ntarget = dst_data + VAR_22;",
"update(target, VAR_12, 1);",
"}",
"}",
"VAR_22 += VAR_9;",
"VAR_22 += VAR_10;",
"dst_data += VAR_11;",
"}",
"}",
"envelope(VAR_0, VAR_2, VAR_7, (VAR_7 + 0) % VAR_0->ncomp);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107,
109
],
[
111,
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
]
]
|
17,121 | target_ulong helper_lwr(CPUMIPSState *env, target_ulong arg1,
target_ulong arg2, int mem_idx)
{
target_ulong tmp;
tmp = do_lbu(env, arg2, mem_idx);
arg1 = (arg1 & 0xFFFFFF00) | tmp;
if (GET_LMASK(arg2) >= 1) {
tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);
arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);
}
if (GET_LMASK(arg2) >= 2) {
tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);
arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);
}
if (GET_LMASK(arg2) == 3) {
tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);
arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);
}
return (int32_t)arg1;
}
| true | qemu | fc40787abcf8452b8f50d92b7a13243a12972c7a | target_ulong helper_lwr(CPUMIPSState *env, target_ulong arg1,
target_ulong arg2, int mem_idx)
{
target_ulong tmp;
tmp = do_lbu(env, arg2, mem_idx);
arg1 = (arg1 & 0xFFFFFF00) | tmp;
if (GET_LMASK(arg2) >= 1) {
tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);
arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);
}
if (GET_LMASK(arg2) >= 2) {
tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);
arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);
}
if (GET_LMASK(arg2) == 3) {
tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);
arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);
}
return (int32_t)arg1;
}
| {
"code": [
" target_ulong arg2, int mem_idx)",
" target_ulong tmp;",
" tmp = do_lbu(env, arg2, mem_idx);",
" arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);",
" arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);",
" return (int32_t)arg1;",
"target_ulong helper_lwr(CPUMIPSState *env, target_ulong arg1,",
" target_ulong arg2, int mem_idx)",
" target_ulong tmp;",
" tmp = do_lbu(env, arg2, mem_idx);",
" arg1 = (arg1 & 0xFFFFFF00) | tmp;",
" if (GET_LMASK(arg2) >= 1) {",
" tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);",
" arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);",
" if (GET_LMASK(arg2) >= 2) {",
" tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);",
" arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);",
" if (GET_LMASK(arg2) == 3) {",
" tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);",
" arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);",
" return (int32_t)arg1;",
" target_ulong arg2, int mem_idx)",
" tmp = do_lbu(env, arg2, mem_idx);",
" target_ulong arg2, int mem_idx)",
" tmp = do_lbu(env, arg2, mem_idx);",
" tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);",
" tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);",
" tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);"
],
"line_no": [
3,
7,
11,
31,
21,
45,
1,
3,
7,
11,
13,
17,
19,
21,
27,
29,
31,
37,
39,
41,
45,
3,
11,
3,
11,
19,
29,
39
]
} | target_ulong FUNC_0(CPUMIPSState *env, target_ulong arg1,
target_ulong arg2, int mem_idx)
{
target_ulong tmp;
tmp = do_lbu(env, arg2, mem_idx);
arg1 = (arg1 & 0xFFFFFF00) | tmp;
if (GET_LMASK(arg2) >= 1) {
tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);
arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);
}
if (GET_LMASK(arg2) >= 2) {
tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);
arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);
}
if (GET_LMASK(arg2) == 3) {
tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);
arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);
}
return (int32_t)arg1;
}
| [
"target_ulong FUNC_0(CPUMIPSState *env, target_ulong arg1,\ntarget_ulong arg2, int mem_idx)\n{",
"target_ulong tmp;",
"tmp = do_lbu(env, arg2, mem_idx);",
"arg1 = (arg1 & 0xFFFFFF00) | tmp;",
"if (GET_LMASK(arg2) >= 1) {",
"tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx);",
"arg1 = (arg1 & 0xFFFF00FF) | (tmp << 8);",
"}",
"if (GET_LMASK(arg2) >= 2) {",
"tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx);",
"arg1 = (arg1 & 0xFF00FFFF) | (tmp << 16);",
"}",
"if (GET_LMASK(arg2) == 3) {",
"tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx);",
"arg1 = (arg1 & 0x00FFFFFF) | (tmp << 24);",
"}",
"return (int32_t)arg1;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
1,
1,
0,
1,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
]
|
17,122 | read_help(void)
{
printf(
"\n"
" reads a range of bytes from the given offset\n"
"\n"
" Example:\n"
" 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\n"
"\n"
" Reads a segment of the currently open file, optionally dumping it to the\n"
" standard output stream (with -v option) for subsequent inspection.\n"
" -p, -- use bdrv_pread to read the file\n"
" -P, -- use a pattern to verify read data\n"
" -C, -- report statistics in a machine parsable format\n"
" -v, -- dump buffer to standard output\n"
" -q, -- quite mode, do not show I/O statistics\n"
"\n");
}
| true | qemu | d9654a58576dae982458bdb1eb565c9876c24c22 | read_help(void)
{
printf(
"\n"
" reads a range of bytes from the given offset\n"
"\n"
" Example:\n"
" 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\n"
"\n"
" Reads a segment of the currently open file, optionally dumping it to the\n"
" standard output stream (with -v option) for subsequent inspection.\n"
" -p, -- use bdrv_pread to read the file\n"
" -P, -- use a pattern to verify read data\n"
" -C, -- report statistics in a machine parsable format\n"
" -v, -- dump buffer to standard output\n"
" -q, -- quite mode, do not show I/O statistics\n"
"\n");
}
| {
"code": [
"\" -C, -- report statistics in a machine parsable format\\n\"",
"\" -v, -- dump buffer to standard output\\n\""
],
"line_no": [
27,
29
]
} | FUNC_0(void)
{
printf(
"\n"
" reads a range of bytes from the given offset\n"
"\n"
" Example:\n"
" 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\n"
"\n"
" Reads a segment of the currently open file, optionally dumping it to the\n"
" standard output stream (with -v option) for subsequent inspection.\n"
" -p, -- use bdrv_pread to read the file\n"
" -P, -- use a pattern to verify read data\n"
" -C, -- report statistics in a machine parsable format\n"
" -v, -- dump buffer to standard output\n"
" -q, -- quite mode, do not show I/O statistics\n"
"\n");
}
| [
"FUNC_0(void)\n{",
"printf(\n\"\\n\"\n\" reads a range of bytes from the given offset\\n\"\n\"\\n\"\n\" Example:\\n\"\n\" 'read -v 512 1k' - dumps 1 kilobyte read from 512 bytes into the file\\n\"\n\"\\n\"\n\" Reads a segment of the currently open file, optionally dumping it to the\\n\"\n\" standard output stream (with -v option) for subsequent inspection.\\n\"\n\" -p, -- use bdrv_pread to read the file\\n\"\n\" -P, -- use a pattern to verify read data\\n\"\n\" -C, -- report statistics in a machine parsable format\\n\"\n\" -v, -- dump buffer to standard output\\n\"\n\" -q, -- quite mode, do not show I/O statistics\\n\"\n\"\\n\");",
"}"
]
| [
0,
1,
0
]
| [
[
1,
3
],
[
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33
],
[
35
]
]
|
17,123 | QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *qsb)
{
QEMUSizedBuffer *out = qsb_create(NULL, qsb_get_length(qsb));
size_t i;
ssize_t res;
off_t pos = 0;
if (!out) {
return NULL;
}
for (i = 0; i < qsb->n_iov; i++) {
res = qsb_write_at(out, qsb->iov[i].iov_base,
pos, qsb->iov[i].iov_len);
if (res < 0) {
qsb_free(out);
return NULL;
}
pos += res;
}
return out;
}
| true | qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *qsb)
{
QEMUSizedBuffer *out = qsb_create(NULL, qsb_get_length(qsb));
size_t i;
ssize_t res;
off_t pos = 0;
if (!out) {
return NULL;
}
for (i = 0; i < qsb->n_iov; i++) {
res = qsb_write_at(out, qsb->iov[i].iov_base,
pos, qsb->iov[i].iov_len);
if (res < 0) {
qsb_free(out);
return NULL;
}
pos += res;
}
return out;
}
| {
"code": [],
"line_no": []
} | QEMUSizedBuffer *FUNC_0(const QEMUSizedBuffer *qsb)
{
QEMUSizedBuffer *out = qsb_create(NULL, qsb_get_length(qsb));
size_t i;
ssize_t res;
off_t pos = 0;
if (!out) {
return NULL;
}
for (i = 0; i < qsb->n_iov; i++) {
res = qsb_write_at(out, qsb->iov[i].iov_base,
pos, qsb->iov[i].iov_len);
if (res < 0) {
qsb_free(out);
return NULL;
}
pos += res;
}
return out;
}
| [
"QEMUSizedBuffer *FUNC_0(const QEMUSizedBuffer *qsb)\n{",
"QEMUSizedBuffer *out = qsb_create(NULL, qsb_get_length(qsb));",
"size_t i;",
"ssize_t res;",
"off_t pos = 0;",
"if (!out) {",
"return NULL;",
"}",
"for (i = 0; i < qsb->n_iov; i++) {",
"res = qsb_write_at(out, qsb->iov[i].iov_base,\npos, qsb->iov[i].iov_len);",
"if (res < 0) {",
"qsb_free(out);",
"return NULL;",
"}",
"pos += res;",
"}",
"return out;",
"}"
]
| [
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
],
[
39
],
[
43
],
[
45
]
]
|
17,125 | int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
{
int bps, blkalign, bytespersec;
int hdrsize = 18;
if(!enc->codec_tag || enc->codec_tag > 0xffff)
enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id);
if(!enc->codec_tag)
return -1;
put_le16(pb, enc->codec_tag);
put_le16(pb, enc->channels);
put_le32(pb, enc->sample_rate);
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_ALAW ||
enc->codec_id == CODEC_ID_PCM_MULAW) {
bps = 8;
} else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) { //
bps = 4;
} else if (enc->codec_id == CODEC_ID_PCM_S24LE) {
bps = 24;
} else if (enc->codec_id == CODEC_ID_PCM_S32LE) {
bps = 32;
} else {
bps = 16;
}
if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
blkalign = enc->frame_size; //this is wrong, but seems many demuxers dont work if this is set correctly
//blkalign = 144 * enc->bit_rate/enc->sample_rate;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) { //
blkalign = 1;
} else if (enc->block_align != 0) { /* specified by the codec */
blkalign = enc->block_align;
} else
blkalign = enc->channels*bps >> 3;
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_S24LE ||
enc->codec_id == CODEC_ID_PCM_S32LE ||
enc->codec_id == CODEC_ID_PCM_S16LE) {
bytespersec = enc->sample_rate * blkalign;
} else {
bytespersec = enc->bit_rate / 8;
}
put_le32(pb, bytespersec); /* bytes per second */
put_le16(pb, blkalign); /* block align */
put_le16(pb, bps); /* bits per sample */
if (enc->codec_id == CODEC_ID_MP3) {
put_le16(pb, 12); /* wav_extra_size */
hdrsize += 12;
put_le16(pb, 1); /* wID */
put_le32(pb, 2); /* fdwFlags */
put_le16(pb, 1152); /* nBlockSize */
put_le16(pb, 1); /* nFramesPerBlock */
put_le16(pb, 1393); /* nCodecDelay */
} else if (enc->codec_id == CODEC_ID_MP2) {
put_le16(pb, 22); /* wav_extra_size */
hdrsize += 22;
put_le16(pb, 2); /* fwHeadLayer */
put_le32(pb, enc->bit_rate); /* dwHeadBitrate */
put_le16(pb, enc->channels == 2 ? 1 : 8); /* fwHeadMode */
put_le16(pb, 0); /* fwHeadModeExt */
put_le16(pb, 1); /* wHeadEmphasis */
put_le16(pb, 16); /* fwHeadFlags */
put_le32(pb, 0); /* dwPTSLow */
put_le32(pb, 0); /* dwPTSHigh */
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
put_le16(pb, 2); /* wav_extra_size */
hdrsize += 2;
put_le16(pb, ((enc->block_align - 4 * enc->channels) / (4 * enc->channels)) * 8 + 1); /* wSamplesPerBlock */
} else if(enc->extradata_size){
put_le16(pb, enc->extradata_size);
put_buffer(pb, enc->extradata, enc->extradata_size);
hdrsize += enc->extradata_size;
if(hdrsize&1){
hdrsize++;
put_byte(pb, 0);
}
} else {
hdrsize -= 2;
}
return hdrsize;
}
| false | FFmpeg | 92eb82325e8bddc56daa8dbd1308efd4896c6114 | int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
{
int bps, blkalign, bytespersec;
int hdrsize = 18;
if(!enc->codec_tag || enc->codec_tag > 0xffff)
enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id);
if(!enc->codec_tag)
return -1;
put_le16(pb, enc->codec_tag);
put_le16(pb, enc->channels);
put_le32(pb, enc->sample_rate);
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_ALAW ||
enc->codec_id == CODEC_ID_PCM_MULAW) {
bps = 8;
} else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) {
bps = 4;
} else if (enc->codec_id == CODEC_ID_PCM_S24LE) {
bps = 24;
} else if (enc->codec_id == CODEC_ID_PCM_S32LE) {
bps = 32;
} else {
bps = 16;
}
if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
blkalign = enc->frame_size; this is wrong, but seems many demuxers dont work if this is set correctly
blkalign = 144 * enc->bit_rate/enc->sample_rate;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) {
blkalign = 1;
} else if (enc->block_align != 0) {
blkalign = enc->block_align;
} else
blkalign = enc->channels*bps >> 3;
if (enc->codec_id == CODEC_ID_PCM_U8 ||
enc->codec_id == CODEC_ID_PCM_S24LE ||
enc->codec_id == CODEC_ID_PCM_S32LE ||
enc->codec_id == CODEC_ID_PCM_S16LE) {
bytespersec = enc->sample_rate * blkalign;
} else {
bytespersec = enc->bit_rate / 8;
}
put_le32(pb, bytespersec);
put_le16(pb, blkalign);
put_le16(pb, bps);
if (enc->codec_id == CODEC_ID_MP3) {
put_le16(pb, 12);
hdrsize += 12;
put_le16(pb, 1);
put_le32(pb, 2);
put_le16(pb, 1152);
put_le16(pb, 1);
put_le16(pb, 1393);
} else if (enc->codec_id == CODEC_ID_MP2) {
put_le16(pb, 22);
hdrsize += 22;
put_le16(pb, 2);
put_le32(pb, enc->bit_rate);
put_le16(pb, enc->channels == 2 ? 1 : 8);
put_le16(pb, 0);
put_le16(pb, 1);
put_le16(pb, 16);
put_le32(pb, 0);
put_le32(pb, 0);
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
put_le16(pb, 2);
hdrsize += 2;
put_le16(pb, ((enc->block_align - 4 * enc->channels) / (4 * enc->channels)) * 8 + 1);
} else if(enc->extradata_size){
put_le16(pb, enc->extradata_size);
put_buffer(pb, enc->extradata, enc->extradata_size);
hdrsize += enc->extradata_size;
if(hdrsize&1){
hdrsize++;
put_byte(pb, 0);
}
} else {
hdrsize -= 2;
}
return hdrsize;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(ByteIOContext *VAR_0, AVCodecContext *VAR_1)
{
int VAR_2, VAR_3, VAR_4;
int VAR_5 = 18;
if(!VAR_1->codec_tag || VAR_1->codec_tag > 0xffff)
VAR_1->codec_tag = codec_get_tag(codec_wav_tags, VAR_1->codec_id);
if(!VAR_1->codec_tag)
return -1;
put_le16(VAR_0, VAR_1->codec_tag);
put_le16(VAR_0, VAR_1->channels);
put_le32(VAR_0, VAR_1->sample_rate);
if (VAR_1->codec_id == CODEC_ID_PCM_U8 ||
VAR_1->codec_id == CODEC_ID_PCM_ALAW ||
VAR_1->codec_id == CODEC_ID_PCM_MULAW) {
VAR_2 = 8;
} else if (VAR_1->codec_id == CODEC_ID_MP2 || VAR_1->codec_id == CODEC_ID_MP3) {
VAR_2 = 0;
} else if (VAR_1->codec_id == CODEC_ID_ADPCM_IMA_WAV || VAR_1->codec_id == CODEC_ID_ADPCM_MS || VAR_1->codec_id == CODEC_ID_ADPCM_G726 || VAR_1->codec_id == CODEC_ID_ADPCM_YAMAHA) {
VAR_2 = 4;
} else if (VAR_1->codec_id == CODEC_ID_PCM_S24LE) {
VAR_2 = 24;
} else if (VAR_1->codec_id == CODEC_ID_PCM_S32LE) {
VAR_2 = 32;
} else {
VAR_2 = 16;
}
if (VAR_1->codec_id == CODEC_ID_MP2 || VAR_1->codec_id == CODEC_ID_MP3) {
VAR_3 = VAR_1->frame_size; this is wrong, but seems many demuxers dont work if this is set correctly
VAR_3 = 144 * VAR_1->bit_rate/VAR_1->sample_rate;
} else if (VAR_1->codec_id == CODEC_ID_ADPCM_G726) {
VAR_3 = 1;
} else if (VAR_1->block_align != 0) {
VAR_3 = VAR_1->block_align;
} else
VAR_3 = VAR_1->channels*VAR_2 >> 3;
if (VAR_1->codec_id == CODEC_ID_PCM_U8 ||
VAR_1->codec_id == CODEC_ID_PCM_S24LE ||
VAR_1->codec_id == CODEC_ID_PCM_S32LE ||
VAR_1->codec_id == CODEC_ID_PCM_S16LE) {
VAR_4 = VAR_1->sample_rate * VAR_3;
} else {
VAR_4 = VAR_1->bit_rate / 8;
}
put_le32(VAR_0, VAR_4);
put_le16(VAR_0, VAR_3);
put_le16(VAR_0, VAR_2);
if (VAR_1->codec_id == CODEC_ID_MP3) {
put_le16(VAR_0, 12);
VAR_5 += 12;
put_le16(VAR_0, 1);
put_le32(VAR_0, 2);
put_le16(VAR_0, 1152);
put_le16(VAR_0, 1);
put_le16(VAR_0, 1393);
} else if (VAR_1->codec_id == CODEC_ID_MP2) {
put_le16(VAR_0, 22);
VAR_5 += 22;
put_le16(VAR_0, 2);
put_le32(VAR_0, VAR_1->bit_rate);
put_le16(VAR_0, VAR_1->channels == 2 ? 1 : 8);
put_le16(VAR_0, 0);
put_le16(VAR_0, 1);
put_le16(VAR_0, 16);
put_le32(VAR_0, 0);
put_le32(VAR_0, 0);
} else if (VAR_1->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
put_le16(VAR_0, 2);
VAR_5 += 2;
put_le16(VAR_0, ((VAR_1->block_align - 4 * VAR_1->channels) / (4 * VAR_1->channels)) * 8 + 1);
} else if(VAR_1->extradata_size){
put_le16(VAR_0, VAR_1->extradata_size);
put_buffer(VAR_0, VAR_1->extradata, VAR_1->extradata_size);
VAR_5 += VAR_1->extradata_size;
if(VAR_5&1){
VAR_5++;
put_byte(VAR_0, 0);
}
} else {
VAR_5 -= 2;
}
return VAR_5;
}
| [
"int FUNC_0(ByteIOContext *VAR_0, AVCodecContext *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"int VAR_5 = 18;",
"if(!VAR_1->codec_tag || VAR_1->codec_tag > 0xffff)\nVAR_1->codec_tag = codec_get_tag(codec_wav_tags, VAR_1->codec_id);",
"if(!VAR_1->codec_tag)\nreturn -1;",
"put_le16(VAR_0, VAR_1->codec_tag);",
"put_le16(VAR_0, VAR_1->channels);",
"put_le32(VAR_0, VAR_1->sample_rate);",
"if (VAR_1->codec_id == CODEC_ID_PCM_U8 ||\nVAR_1->codec_id == CODEC_ID_PCM_ALAW ||\nVAR_1->codec_id == CODEC_ID_PCM_MULAW) {",
"VAR_2 = 8;",
"} else if (VAR_1->codec_id == CODEC_ID_MP2 || VAR_1->codec_id == CODEC_ID_MP3) {",
"VAR_2 = 0;",
"} else if (VAR_1->codec_id == CODEC_ID_ADPCM_IMA_WAV || VAR_1->codec_id == CODEC_ID_ADPCM_MS || VAR_1->codec_id == CODEC_ID_ADPCM_G726 || VAR_1->codec_id == CODEC_ID_ADPCM_YAMAHA) {",
"VAR_2 = 4;",
"} else if (VAR_1->codec_id == CODEC_ID_PCM_S24LE) {",
"VAR_2 = 24;",
"} else if (VAR_1->codec_id == CODEC_ID_PCM_S32LE) {",
"VAR_2 = 32;",
"} else {",
"VAR_2 = 16;",
"}",
"if (VAR_1->codec_id == CODEC_ID_MP2 || VAR_1->codec_id == CODEC_ID_MP3) {",
"VAR_3 = VAR_1->frame_size; this is wrong, but seems many demuxers dont work if this is set correctly",
"VAR_3 = 144 * VAR_1->bit_rate/VAR_1->sample_rate;",
"} else if (VAR_1->codec_id == CODEC_ID_ADPCM_G726) {",
"VAR_3 = 1;",
"} else if (VAR_1->block_align != 0) {",
"VAR_3 = VAR_1->block_align;",
"} else",
"VAR_3 = VAR_1->channels*VAR_2 >> 3;",
"if (VAR_1->codec_id == CODEC_ID_PCM_U8 ||\nVAR_1->codec_id == CODEC_ID_PCM_S24LE ||\nVAR_1->codec_id == CODEC_ID_PCM_S32LE ||\nVAR_1->codec_id == CODEC_ID_PCM_S16LE) {",
"VAR_4 = VAR_1->sample_rate * VAR_3;",
"} else {",
"VAR_4 = VAR_1->bit_rate / 8;",
"}",
"put_le32(VAR_0, VAR_4);",
"put_le16(VAR_0, VAR_3);",
"put_le16(VAR_0, VAR_2);",
"if (VAR_1->codec_id == CODEC_ID_MP3) {",
"put_le16(VAR_0, 12);",
"VAR_5 += 12;",
"put_le16(VAR_0, 1);",
"put_le32(VAR_0, 2);",
"put_le16(VAR_0, 1152);",
"put_le16(VAR_0, 1);",
"put_le16(VAR_0, 1393);",
"} else if (VAR_1->codec_id == CODEC_ID_MP2) {",
"put_le16(VAR_0, 22);",
"VAR_5 += 22;",
"put_le16(VAR_0, 2);",
"put_le32(VAR_0, VAR_1->bit_rate);",
"put_le16(VAR_0, VAR_1->channels == 2 ? 1 : 8);",
"put_le16(VAR_0, 0);",
"put_le16(VAR_0, 1);",
"put_le16(VAR_0, 16);",
"put_le32(VAR_0, 0);",
"put_le32(VAR_0, 0);",
"} else if (VAR_1->codec_id == CODEC_ID_ADPCM_IMA_WAV) {",
"put_le16(VAR_0, 2);",
"VAR_5 += 2;",
"put_le16(VAR_0, ((VAR_1->block_align - 4 * VAR_1->channels) / (4 * VAR_1->channels)) * 8 + 1);",
"} else if(VAR_1->extradata_size){",
"put_le16(VAR_0, VAR_1->extradata_size);",
"put_buffer(VAR_0, VAR_1->extradata, VAR_1->extradata_size);",
"VAR_5 += VAR_1->extradata_size;",
"if(VAR_5&1){",
"VAR_5++;",
"put_byte(VAR_0, 0);",
"}",
"} else {",
"VAR_5 -= 2;",
"}",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
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
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77,
79,
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
]
]
|
17,126 | static inline int get_egolomb(GetBitContext *gb)
{
int v = 4;
while (get_bits1(gb)) v++;
return (1 << v) + get_bits(gb, v);
}
| false | FFmpeg | 2884cf205a9a29d89db7a444c5b1613cdfe37acf | static inline int get_egolomb(GetBitContext *gb)
{
int v = 4;
while (get_bits1(gb)) v++;
return (1 << v) + get_bits(gb, v);
}
| {
"code": [],
"line_no": []
} | static inline int FUNC_0(GetBitContext *VAR_0)
{
int VAR_1 = 4;
while (get_bits1(VAR_0)) VAR_1++;
return (1 << VAR_1) + get_bits(VAR_0, VAR_1);
}
| [
"static inline int FUNC_0(GetBitContext *VAR_0)\n{",
"int VAR_1 = 4;",
"while (get_bits1(VAR_0)) VAR_1++;",
"return (1 << VAR_1) + get_bits(VAR_0, VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
]
]
|
17,127 | static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,
const uint8_t *buf, int buf_size)
{
MLPDecodeContext *m = avctx->priv_data;
GetBitContext gb;
unsigned int length, substr;
unsigned int substream_start;
unsigned int header_size = 4;
unsigned int substr_header_size = 0;
uint8_t substream_parity_present[MAX_SUBSTREAMS];
uint16_t substream_data_len[MAX_SUBSTREAMS];
uint8_t parity_bits;
if (buf_size < 4)
return 0;
length = (AV_RB16(buf) & 0xfff) * 2;
if (length > buf_size)
return -1;
init_get_bits(&gb, (buf + 4), (length - 4) * 8);
if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {
if (read_major_sync(m, &gb) < 0)
goto error;
header_size += 28;
}
if (!m->params_valid) {
av_log(m->avctx, AV_LOG_WARNING,
"Stream parameters not seen; skipping frame.\n");
*data_size = 0;
return length;
}
substream_start = 0;
for (substr = 0; substr < m->num_substreams; substr++) {
int extraword_present, checkdata_present, end;
extraword_present = get_bits1(&gb);
skip_bits1(&gb);
checkdata_present = get_bits1(&gb);
skip_bits1(&gb);
end = get_bits(&gb, 12) * 2;
substr_header_size += 2;
if (extraword_present) {
skip_bits(&gb, 16);
substr_header_size += 2;
}
if (end + header_size + substr_header_size > length) {
av_log(m->avctx, AV_LOG_ERROR,
"Indicated length of substream %d data goes off end of "
"packet.\n", substr);
end = length - header_size - substr_header_size;
}
if (end < substream_start) {
av_log(avctx, AV_LOG_ERROR,
"Indicated end offset of substream %d data "
"is smaller than calculated start offset.\n",
substr);
goto error;
}
if (substr > m->max_decoded_substream)
continue;
substream_parity_present[substr] = checkdata_present;
substream_data_len[substr] = end - substream_start;
substream_start = end;
}
parity_bits = ff_mlp_calculate_parity(buf, 4);
parity_bits ^= ff_mlp_calculate_parity(buf + header_size, substr_header_size);
if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
av_log(avctx, AV_LOG_ERROR, "Parity check failed.\n");
goto error;
}
buf += header_size + substr_header_size;
for (substr = 0; substr <= m->max_decoded_substream; substr++) {
SubStream *s = &m->substream[substr];
init_get_bits(&gb, buf, substream_data_len[substr] * 8);
s->blockpos = 0;
do {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
/* A restart header should be present. */
if (read_restart_header(m, &gb, buf, substr) < 0)
goto next_substr;
s->restart_seen = 1;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_decoding_params(m, &gb, substr) < 0)
goto next_substr;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_block_data(m, &gb, substr) < 0)
return -1;
if (get_bits_count(&gb) >= substream_data_len[substr] * 8)
goto substream_length_mismatch;
} while (!get_bits1(&gb));
skip_bits(&gb, (-get_bits_count(&gb)) & 15);
if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) {
int shorten_by;
if (get_bits(&gb, 16) != 0xD234)
return -1;
shorten_by = get_bits(&gb, 16);
if (m->avctx->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000)
s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
else if (m->avctx->codec_id == CODEC_ID_MLP && shorten_by != 0xD234)
return -1;
if (substr == m->max_decoded_substream)
av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n");
}
if (substream_parity_present[substr]) {
uint8_t parity, checksum;
if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16)
goto substream_length_mismatch;
parity = ff_mlp_calculate_parity(buf, substream_data_len[substr] - 2);
checksum = ff_mlp_checksum8 (buf, substream_data_len[substr] - 2);
if ((get_bits(&gb, 8) ^ parity) != 0xa9 )
av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr);
if ( get_bits(&gb, 8) != checksum)
av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr);
}
if (substream_data_len[substr] * 8 != get_bits_count(&gb)) {
goto substream_length_mismatch;
}
next_substr:
if (!s->restart_seen) {
av_log(m->avctx, AV_LOG_ERROR,
"No restart header present in substream %d.\n", substr);
}
buf += substream_data_len[substr];
}
rematrix_channels(m, m->max_decoded_substream);
if (output_data(m, m->max_decoded_substream, data, data_size) < 0)
return -1;
return length;
substream_length_mismatch:
av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr);
return -1;
error:
m->params_valid = 0;
return -1;
}
| false | FFmpeg | cc9c5126387a1d8093ca8cc1df6ab2c535c35dba | static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,
const uint8_t *buf, int buf_size)
{
MLPDecodeContext *m = avctx->priv_data;
GetBitContext gb;
unsigned int length, substr;
unsigned int substream_start;
unsigned int header_size = 4;
unsigned int substr_header_size = 0;
uint8_t substream_parity_present[MAX_SUBSTREAMS];
uint16_t substream_data_len[MAX_SUBSTREAMS];
uint8_t parity_bits;
if (buf_size < 4)
return 0;
length = (AV_RB16(buf) & 0xfff) * 2;
if (length > buf_size)
return -1;
init_get_bits(&gb, (buf + 4), (length - 4) * 8);
if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {
if (read_major_sync(m, &gb) < 0)
goto error;
header_size += 28;
}
if (!m->params_valid) {
av_log(m->avctx, AV_LOG_WARNING,
"Stream parameters not seen; skipping frame.\n");
*data_size = 0;
return length;
}
substream_start = 0;
for (substr = 0; substr < m->num_substreams; substr++) {
int extraword_present, checkdata_present, end;
extraword_present = get_bits1(&gb);
skip_bits1(&gb);
checkdata_present = get_bits1(&gb);
skip_bits1(&gb);
end = get_bits(&gb, 12) * 2;
substr_header_size += 2;
if (extraword_present) {
skip_bits(&gb, 16);
substr_header_size += 2;
}
if (end + header_size + substr_header_size > length) {
av_log(m->avctx, AV_LOG_ERROR,
"Indicated length of substream %d data goes off end of "
"packet.\n", substr);
end = length - header_size - substr_header_size;
}
if (end < substream_start) {
av_log(avctx, AV_LOG_ERROR,
"Indicated end offset of substream %d data "
"is smaller than calculated start offset.\n",
substr);
goto error;
}
if (substr > m->max_decoded_substream)
continue;
substream_parity_present[substr] = checkdata_present;
substream_data_len[substr] = end - substream_start;
substream_start = end;
}
parity_bits = ff_mlp_calculate_parity(buf, 4);
parity_bits ^= ff_mlp_calculate_parity(buf + header_size, substr_header_size);
if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
av_log(avctx, AV_LOG_ERROR, "Parity check failed.\n");
goto error;
}
buf += header_size + substr_header_size;
for (substr = 0; substr <= m->max_decoded_substream; substr++) {
SubStream *s = &m->substream[substr];
init_get_bits(&gb, buf, substream_data_len[substr] * 8);
s->blockpos = 0;
do {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (read_restart_header(m, &gb, buf, substr) < 0)
goto next_substr;
s->restart_seen = 1;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_decoding_params(m, &gb, substr) < 0)
goto next_substr;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_block_data(m, &gb, substr) < 0)
return -1;
if (get_bits_count(&gb) >= substream_data_len[substr] * 8)
goto substream_length_mismatch;
} while (!get_bits1(&gb));
skip_bits(&gb, (-get_bits_count(&gb)) & 15);
if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) {
int shorten_by;
if (get_bits(&gb, 16) != 0xD234)
return -1;
shorten_by = get_bits(&gb, 16);
if (m->avctx->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000)
s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
else if (m->avctx->codec_id == CODEC_ID_MLP && shorten_by != 0xD234)
return -1;
if (substr == m->max_decoded_substream)
av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n");
}
if (substream_parity_present[substr]) {
uint8_t parity, checksum;
if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16)
goto substream_length_mismatch;
parity = ff_mlp_calculate_parity(buf, substream_data_len[substr] - 2);
checksum = ff_mlp_checksum8 (buf, substream_data_len[substr] - 2);
if ((get_bits(&gb, 8) ^ parity) != 0xa9 )
av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr);
if ( get_bits(&gb, 8) != checksum)
av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr);
}
if (substream_data_len[substr] * 8 != get_bits_count(&gb)) {
goto substream_length_mismatch;
}
next_substr:
if (!s->restart_seen) {
av_log(m->avctx, AV_LOG_ERROR,
"No restart header present in substream %d.\n", substr);
}
buf += substream_data_len[substr];
}
rematrix_channels(m, m->max_decoded_substream);
if (output_data(m, m->max_decoded_substream, data, data_size) < 0)
return -1;
return length;
substream_length_mismatch:
av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr);
return -1;
error:
m->params_valid = 0;
return -1;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void* VAR_1, int *VAR_2,
const uint8_t *VAR_3, int VAR_4)
{
MLPDecodeContext *m = VAR_0->priv_data;
GetBitContext gb;
unsigned int VAR_5, VAR_6;
unsigned int VAR_7;
unsigned int VAR_8 = 4;
unsigned int VAR_9 = 0;
uint8_t substream_parity_present[MAX_SUBSTREAMS];
uint16_t substream_data_len[MAX_SUBSTREAMS];
uint8_t parity_bits;
if (VAR_4 < 4)
return 0;
VAR_5 = (AV_RB16(VAR_3) & 0xfff) * 2;
if (VAR_5 > VAR_4)
return -1;
init_get_bits(&gb, (VAR_3 + 4), (VAR_5 - 4) * 8);
if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {
if (read_major_sync(m, &gb) < 0)
goto error;
VAR_8 += 28;
}
if (!m->params_valid) {
av_log(m->VAR_0, AV_LOG_WARNING,
"Stream parameters not seen; skipping frame.\n");
*VAR_2 = 0;
return VAR_5;
}
VAR_7 = 0;
for (VAR_6 = 0; VAR_6 < m->num_substreams; VAR_6++) {
int extraword_present, checkdata_present, end;
extraword_present = get_bits1(&gb);
skip_bits1(&gb);
checkdata_present = get_bits1(&gb);
skip_bits1(&gb);
end = get_bits(&gb, 12) * 2;
VAR_9 += 2;
if (extraword_present) {
skip_bits(&gb, 16);
VAR_9 += 2;
}
if (end + VAR_8 + VAR_9 > VAR_5) {
av_log(m->VAR_0, AV_LOG_ERROR,
"Indicated VAR_5 of substream %d VAR_1 goes off end of "
"packet.\n", VAR_6);
end = VAR_5 - VAR_8 - VAR_9;
}
if (end < VAR_7) {
av_log(VAR_0, AV_LOG_ERROR,
"Indicated end offset of substream %d VAR_1 "
"is smaller than calculated start offset.\n",
VAR_6);
goto error;
}
if (VAR_6 > m->max_decoded_substream)
continue;
substream_parity_present[VAR_6] = checkdata_present;
substream_data_len[VAR_6] = end - VAR_7;
VAR_7 = end;
}
parity_bits = ff_mlp_calculate_parity(VAR_3, 4);
parity_bits ^= ff_mlp_calculate_parity(VAR_3 + VAR_8, VAR_9);
if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
av_log(VAR_0, AV_LOG_ERROR, "Parity check failed.\n");
goto error;
}
VAR_3 += VAR_8 + VAR_9;
for (VAR_6 = 0; VAR_6 <= m->max_decoded_substream; VAR_6++) {
SubStream *s = &m->substream[VAR_6];
init_get_bits(&gb, VAR_3, substream_data_len[VAR_6] * 8);
s->blockpos = 0;
do {
if (get_bits1(&gb)) {
if (get_bits1(&gb)) {
if (read_restart_header(m, &gb, VAR_3, VAR_6) < 0)
goto next_substr;
s->restart_seen = 1;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_decoding_params(m, &gb, VAR_6) < 0)
goto next_substr;
}
if (!s->restart_seen) {
goto next_substr;
}
if (read_block_data(m, &gb, VAR_6) < 0)
return -1;
if (get_bits_count(&gb) >= substream_data_len[VAR_6] * 8)
goto substream_length_mismatch;
} while (!get_bits1(&gb));
skip_bits(&gb, (-get_bits_count(&gb)) & 15);
if (substream_data_len[VAR_6] * 8 - get_bits_count(&gb) >= 32) {
int shorten_by;
if (get_bits(&gb, 16) != 0xD234)
return -1;
shorten_by = get_bits(&gb, 16);
if (m->VAR_0->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000)
s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
else if (m->VAR_0->codec_id == CODEC_ID_MLP && shorten_by != 0xD234)
return -1;
if (VAR_6 == m->max_decoded_substream)
av_log(m->VAR_0, AV_LOG_INFO, "End of stream indicated.\n");
}
if (substream_parity_present[VAR_6]) {
uint8_t parity, checksum;
if (substream_data_len[VAR_6] * 8 - get_bits_count(&gb) != 16)
goto substream_length_mismatch;
parity = ff_mlp_calculate_parity(VAR_3, substream_data_len[VAR_6] - 2);
checksum = ff_mlp_checksum8 (VAR_3, substream_data_len[VAR_6] - 2);
if ((get_bits(&gb, 8) ^ parity) != 0xa9 )
av_log(m->VAR_0, AV_LOG_ERROR, "Substream %d parity check failed.\n", VAR_6);
if ( get_bits(&gb, 8) != checksum)
av_log(m->VAR_0, AV_LOG_ERROR, "Substream %d checksum failed.\n" , VAR_6);
}
if (substream_data_len[VAR_6] * 8 != get_bits_count(&gb)) {
goto substream_length_mismatch;
}
next_substr:
if (!s->restart_seen) {
av_log(m->VAR_0, AV_LOG_ERROR,
"No restart header present in substream %d.\n", VAR_6);
}
VAR_3 += substream_data_len[VAR_6];
}
rematrix_channels(m, m->max_decoded_substream);
if (output_data(m, m->max_decoded_substream, VAR_1, VAR_2) < 0)
return -1;
return VAR_5;
substream_length_mismatch:
av_log(m->VAR_0, AV_LOG_ERROR, "substream %d VAR_5 mismatch\n", VAR_6);
return -1;
error:
m->params_valid = 0;
return -1;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void* VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{",
"MLPDecodeContext *m = VAR_0->priv_data;",
"GetBitContext gb;",
"unsigned int VAR_5, VAR_6;",
"unsigned int VAR_7;",
"unsigned int VAR_8 = 4;",
"unsigned int VAR_9 = 0;",
"uint8_t substream_parity_present[MAX_SUBSTREAMS];",
"uint16_t substream_data_len[MAX_SUBSTREAMS];",
"uint8_t parity_bits;",
"if (VAR_4 < 4)\nreturn 0;",
"VAR_5 = (AV_RB16(VAR_3) & 0xfff) * 2;",
"if (VAR_5 > VAR_4)\nreturn -1;",
"init_get_bits(&gb, (VAR_3 + 4), (VAR_5 - 4) * 8);",
"if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {",
"if (read_major_sync(m, &gb) < 0)\ngoto error;",
"VAR_8 += 28;",
"}",
"if (!m->params_valid) {",
"av_log(m->VAR_0, AV_LOG_WARNING,\n\"Stream parameters not seen; skipping frame.\\n\");",
"*VAR_2 = 0;",
"return VAR_5;",
"}",
"VAR_7 = 0;",
"for (VAR_6 = 0; VAR_6 < m->num_substreams; VAR_6++) {",
"int extraword_present, checkdata_present, end;",
"extraword_present = get_bits1(&gb);",
"skip_bits1(&gb);",
"checkdata_present = get_bits1(&gb);",
"skip_bits1(&gb);",
"end = get_bits(&gb, 12) * 2;",
"VAR_9 += 2;",
"if (extraword_present) {",
"skip_bits(&gb, 16);",
"VAR_9 += 2;",
"}",
"if (end + VAR_8 + VAR_9 > VAR_5) {",
"av_log(m->VAR_0, AV_LOG_ERROR,\n\"Indicated VAR_5 of substream %d VAR_1 goes off end of \"\n\"packet.\\n\", VAR_6);",
"end = VAR_5 - VAR_8 - VAR_9;",
"}",
"if (end < VAR_7) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Indicated end offset of substream %d VAR_1 \"\n\"is smaller than calculated start offset.\\n\",\nVAR_6);",
"goto error;",
"}",
"if (VAR_6 > m->max_decoded_substream)\ncontinue;",
"substream_parity_present[VAR_6] = checkdata_present;",
"substream_data_len[VAR_6] = end - VAR_7;",
"VAR_7 = end;",
"}",
"parity_bits = ff_mlp_calculate_parity(VAR_3, 4);",
"parity_bits ^= ff_mlp_calculate_parity(VAR_3 + VAR_8, VAR_9);",
"if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Parity check failed.\\n\");",
"goto error;",
"}",
"VAR_3 += VAR_8 + VAR_9;",
"for (VAR_6 = 0; VAR_6 <= m->max_decoded_substream; VAR_6++) {",
"SubStream *s = &m->substream[VAR_6];",
"init_get_bits(&gb, VAR_3, substream_data_len[VAR_6] * 8);",
"s->blockpos = 0;",
"do {",
"if (get_bits1(&gb)) {",
"if (get_bits1(&gb)) {",
"if (read_restart_header(m, &gb, VAR_3, VAR_6) < 0)\ngoto next_substr;",
"s->restart_seen = 1;",
"}",
"if (!s->restart_seen) {",
"goto next_substr;",
"}",
"if (read_decoding_params(m, &gb, VAR_6) < 0)\ngoto next_substr;",
"}",
"if (!s->restart_seen) {",
"goto next_substr;",
"}",
"if (read_block_data(m, &gb, VAR_6) < 0)\nreturn -1;",
"if (get_bits_count(&gb) >= substream_data_len[VAR_6] * 8)\ngoto substream_length_mismatch;",
"} while (!get_bits1(&gb));",
"skip_bits(&gb, (-get_bits_count(&gb)) & 15);",
"if (substream_data_len[VAR_6] * 8 - get_bits_count(&gb) >= 32) {",
"int shorten_by;",
"if (get_bits(&gb, 16) != 0xD234)\nreturn -1;",
"shorten_by = get_bits(&gb, 16);",
"if (m->VAR_0->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000)\ns->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);",
"else if (m->VAR_0->codec_id == CODEC_ID_MLP && shorten_by != 0xD234)\nreturn -1;",
"if (VAR_6 == m->max_decoded_substream)\nav_log(m->VAR_0, AV_LOG_INFO, \"End of stream indicated.\\n\");",
"}",
"if (substream_parity_present[VAR_6]) {",
"uint8_t parity, checksum;",
"if (substream_data_len[VAR_6] * 8 - get_bits_count(&gb) != 16)\ngoto substream_length_mismatch;",
"parity = ff_mlp_calculate_parity(VAR_3, substream_data_len[VAR_6] - 2);",
"checksum = ff_mlp_checksum8 (VAR_3, substream_data_len[VAR_6] - 2);",
"if ((get_bits(&gb, 8) ^ parity) != 0xa9 )\nav_log(m->VAR_0, AV_LOG_ERROR, \"Substream %d parity check failed.\\n\", VAR_6);",
"if ( get_bits(&gb, 8) != checksum)\nav_log(m->VAR_0, AV_LOG_ERROR, \"Substream %d checksum failed.\\n\" , VAR_6);",
"}",
"if (substream_data_len[VAR_6] * 8 != get_bits_count(&gb)) {",
"goto substream_length_mismatch;",
"}",
"next_substr:\nif (!s->restart_seen) {",
"av_log(m->VAR_0, AV_LOG_ERROR,\n\"No restart header present in substream %d.\\n\", VAR_6);",
"}",
"VAR_3 += substream_data_len[VAR_6];",
"}",
"rematrix_channels(m, m->max_decoded_substream);",
"if (output_data(m, m->max_decoded_substream, VAR_1, VAR_2) < 0)\nreturn -1;",
"return VAR_5;",
"substream_length_mismatch:\nav_log(m->VAR_0, AV_LOG_ERROR, \"substream %d VAR_5 mismatch\\n\", VAR_6);",
"return -1;",
"error:\nm->params_valid = 0;",
"return -1;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27,
29
],
[
33
],
[
37,
39
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113,
115,
117
],
[
119
],
[
121
],
[
125
],
[
127,
129,
131,
133
],
[
135
],
[
137
],
[
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195,
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
213,
215
],
[
217
],
[
221
],
[
223
],
[
225
],
[
229,
231
],
[
235,
237
],
[
241
],
[
245
],
[
247
],
[
249
],
[
253,
255
],
[
259
],
[
261,
263
],
[
265,
267
],
[
271,
273
],
[
275
],
[
277
],
[
279
],
[
283,
285
],
[
289
],
[
291
],
[
295,
297
],
[
299,
301
],
[
303
],
[
305
],
[
307
],
[
309
],
[
313,
315
],
[
317,
319
],
[
321
],
[
325
],
[
327
],
[
331
],
[
335,
337
],
[
341
],
[
345,
347
],
[
349
],
[
353,
355
],
[
357
],
[
359
]
]
|
17,129 | int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
int ret;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (!frame->width)
frame->width = avctx->width;
if (!frame->height)
frame->height = avctx->height;
if (frame->format < 0)
frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
return ret;
break;
case AVMEDIA_TYPE_AUDIO:
if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate;
if (frame->format < 0)
frame->format = avctx->sample_fmt;
if (!frame->channel_layout)
frame->channel_layout = avctx->channel_layout;
break;
default: return AVERROR(EINVAL);
}
frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
#if FF_API_GET_BUFFER
/*
* Wrap an old get_buffer()-allocated buffer in an bunch of AVBuffers.
* We wrap each plane in its own AVBuffer. Each of those has a reference to
* a dummy AVBuffer as its private data, unreffing it on free.
* When all the planes are freed, the dummy buffer's free callback calls
* release_buffer().
*/
if (avctx->get_buffer) {
CompatReleaseBufPriv *priv = NULL;
AVBufferRef *dummy_buf = NULL;
int planes, i, ret;
if (flags & AV_GET_BUFFER_FLAG_REF)
frame->reference = 1;
ret = avctx->get_buffer(avctx, frame);
if (ret < 0)
return ret;
/* return if the buffers are already set up
* this would happen e.g. when a custom get_buffer() calls
* avcodec_default_get_buffer
*/
if (frame->buf[0])
return 0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
ret = AVERROR(ENOMEM);
goto fail;
}
priv->avctx = *avctx;
priv->frame = *frame;
dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);
if (!dummy_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
#define WRAP_PLANE(ref_out, data, data_size) \
do { \
AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
if (!dummy_ref) { \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
dummy_ref, 0); \
if (!ref_out) { \
av_frame_unref(frame); \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
} while (0)
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
if (!desc) {
ret = AVERROR(EINVAL);
goto fail;
}
planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) {
int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
int plane_size = (frame->width >> h_shift) * frame->linesize[i];
WRAP_PLANE(frame->buf[i], frame->data[i], plane_size);
}
} else {
int planar = av_sample_fmt_is_planar(frame->format);
planes = planar ? avctx->channels : 1;
if (planes > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) *
frame->nb_extended_buf);
if (!frame->extended_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++)
WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]);
for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++)
WRAP_PLANE(frame->extended_buf[i],
frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)],
frame->linesize[0]);
}
av_buffer_unref(&dummy_buf);
return 0;
fail:
avctx->release_buffer(avctx, frame);
av_freep(&priv);
av_buffer_unref(&dummy_buf);
return ret;
}
#endif
return avctx->get_buffer2(avctx, frame, flags);
}
| false | FFmpeg | 2eba9087f3031c6050f8dcd996225490be6c2410 | int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
int ret;
switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (!frame->width)
frame->width = avctx->width;
if (!frame->height)
frame->height = avctx->height;
if (frame->format < 0)
frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
return ret;
break;
case AVMEDIA_TYPE_AUDIO:
if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate;
if (frame->format < 0)
frame->format = avctx->sample_fmt;
if (!frame->channel_layout)
frame->channel_layout = avctx->channel_layout;
break;
default: return AVERROR(EINVAL);
}
frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
frame->reordered_opaque = avctx->reordered_opaque;
#if FF_API_GET_BUFFER
if (avctx->get_buffer) {
CompatReleaseBufPriv *priv = NULL;
AVBufferRef *dummy_buf = NULL;
int planes, i, ret;
if (flags & AV_GET_BUFFER_FLAG_REF)
frame->reference = 1;
ret = avctx->get_buffer(avctx, frame);
if (ret < 0)
return ret;
if (frame->buf[0])
return 0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
ret = AVERROR(ENOMEM);
goto fail;
}
priv->avctx = *avctx;
priv->frame = *frame;
dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);
if (!dummy_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
#define WRAP_PLANE(ref_out, data, data_size) \
do { \
AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
if (!dummy_ref) { \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
dummy_ref, 0); \
if (!ref_out) { \
av_frame_unref(frame); \
ret = AVERROR(ENOMEM); \
goto fail; \
} \
} while (0)
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
if (!desc) {
ret = AVERROR(EINVAL);
goto fail;
}
planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) {
int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
int plane_size = (frame->width >> h_shift) * frame->linesize[i];
WRAP_PLANE(frame->buf[i], frame->data[i], plane_size);
}
} else {
int planar = av_sample_fmt_is_planar(frame->format);
planes = planar ? avctx->channels : 1;
if (planes > FF_ARRAY_ELEMS(frame->buf)) {
frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) *
frame->nb_extended_buf);
if (!frame->extended_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++)
WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]);
for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++)
WRAP_PLANE(frame->extended_buf[i],
frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)],
frame->linesize[0]);
}
av_buffer_unref(&dummy_buf);
return 0;
fail:
avctx->release_buffer(avctx, frame);
av_freep(&priv);
av_buffer_unref(&dummy_buf);
return ret;
}
#endif
return avctx->get_buffer2(avctx, frame, flags);
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)
{
int VAR_3;
switch (VAR_0->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (!VAR_1->width)
VAR_1->width = VAR_0->width;
if (!VAR_1->height)
VAR_1->height = VAR_0->height;
if (VAR_1->format < 0)
VAR_1->format = VAR_0->pix_fmt;
if (!VAR_1->sample_aspect_ratio.num)
VAR_1->sample_aspect_ratio = VAR_0->sample_aspect_ratio;
if ((VAR_3 = av_image_check_size(VAR_0->width, VAR_0->height, 0, VAR_0)) < 0)
return VAR_3;
break;
case AVMEDIA_TYPE_AUDIO:
if (!VAR_1->sample_rate)
VAR_1->sample_rate = VAR_0->sample_rate;
if (VAR_1->format < 0)
VAR_1->format = VAR_0->sample_fmt;
if (!VAR_1->channel_layout)
VAR_1->channel_layout = VAR_0->channel_layout;
break;
default: return AVERROR(EINVAL);
}
VAR_1->pkt_pts = VAR_0->pkt ? VAR_0->pkt->pts : AV_NOPTS_VALUE;
VAR_1->reordered_opaque = VAR_0->reordered_opaque;
#if FF_API_GET_BUFFER
if (VAR_0->get_buffer) {
CompatReleaseBufPriv *priv = NULL;
AVBufferRef *dummy_buf = NULL;
int planes, i, VAR_3;
if (VAR_2 & AV_GET_BUFFER_FLAG_REF)
VAR_1->reference = 1;
VAR_3 = VAR_0->get_buffer(VAR_0, VAR_1);
if (VAR_3 < 0)
return VAR_3;
if (VAR_1->buf[0])
return 0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
VAR_3 = AVERROR(ENOMEM);
goto fail;
}
priv->VAR_0 = *VAR_0;
priv->VAR_1 = *VAR_1;
dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);
if (!dummy_buf) {
VAR_3 = AVERROR(ENOMEM);
goto fail;
}
#define WRAP_PLANE(ref_out, data, data_size) \
do { \
AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
if (!dummy_ref) { \
VAR_3 = AVERROR(ENOMEM); \
goto fail; \
} \
ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
dummy_ref, 0); \
if (!ref_out) { \
av_frame_unref(VAR_1); \
VAR_3 = AVERROR(ENOMEM); \
goto fail; \
} \
} while (0)
if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(VAR_1->format);
if (!desc) {
VAR_3 = AVERROR(EINVAL);
goto fail;
}
planes = (desc->VAR_2 & PIX_FMT_PLANAR) ? desc->nb_components : 1;
for (i = 0; i < planes; i++) {
int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
int plane_size = (VAR_1->width >> h_shift) * VAR_1->linesize[i];
WRAP_PLANE(VAR_1->buf[i], VAR_1->data[i], plane_size);
}
} else {
int planar = av_sample_fmt_is_planar(VAR_1->format);
planes = planar ? VAR_0->channels : 1;
if (planes > FF_ARRAY_ELEMS(VAR_1->buf)) {
VAR_1->nb_extended_buf = planes - FF_ARRAY_ELEMS(VAR_1->buf);
VAR_1->extended_buf = av_malloc(sizeof(*VAR_1->extended_buf) *
VAR_1->nb_extended_buf);
if (!VAR_1->extended_buf) {
VAR_3 = AVERROR(ENOMEM);
goto fail;
}
}
for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(VAR_1->buf)); i++)
WRAP_PLANE(VAR_1->buf[i], VAR_1->extended_data[i], VAR_1->linesize[0]);
for (i = 0; i < planes - FF_ARRAY_ELEMS(VAR_1->buf); i++)
WRAP_PLANE(VAR_1->extended_buf[i],
VAR_1->extended_data[i + FF_ARRAY_ELEMS(VAR_1->buf)],
VAR_1->linesize[0]);
}
av_buffer_unref(&dummy_buf);
return 0;
fail:
VAR_0->release_buffer(VAR_0, VAR_1);
av_freep(&priv);
av_buffer_unref(&dummy_buf);
return VAR_3;
}
#endif
return VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2);
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"switch (VAR_0->codec_type) {",
"case AVMEDIA_TYPE_VIDEO:\nif (!VAR_1->width)\nVAR_1->width = VAR_0->width;",
"if (!VAR_1->height)\nVAR_1->height = VAR_0->height;",
"if (VAR_1->format < 0)\nVAR_1->format = VAR_0->pix_fmt;",
"if (!VAR_1->sample_aspect_ratio.num)\nVAR_1->sample_aspect_ratio = VAR_0->sample_aspect_ratio;",
"if ((VAR_3 = av_image_check_size(VAR_0->width, VAR_0->height, 0, VAR_0)) < 0)\nreturn VAR_3;",
"break;",
"case AVMEDIA_TYPE_AUDIO:\nif (!VAR_1->sample_rate)\nVAR_1->sample_rate = VAR_0->sample_rate;",
"if (VAR_1->format < 0)\nVAR_1->format = VAR_0->sample_fmt;",
"if (!VAR_1->channel_layout)\nVAR_1->channel_layout = VAR_0->channel_layout;",
"break;",
"default: return AVERROR(EINVAL);",
"}",
"VAR_1->pkt_pts = VAR_0->pkt ? VAR_0->pkt->pts : AV_NOPTS_VALUE;",
"VAR_1->reordered_opaque = VAR_0->reordered_opaque;",
"#if FF_API_GET_BUFFER\nif (VAR_0->get_buffer) {",
"CompatReleaseBufPriv *priv = NULL;",
"AVBufferRef *dummy_buf = NULL;",
"int planes, i, VAR_3;",
"if (VAR_2 & AV_GET_BUFFER_FLAG_REF)\nVAR_1->reference = 1;",
"VAR_3 = VAR_0->get_buffer(VAR_0, VAR_1);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"if (VAR_1->buf[0])\nreturn 0;",
"priv = av_mallocz(sizeof(*priv));",
"if (!priv) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"priv->VAR_0 = *VAR_0;",
"priv->VAR_1 = *VAR_1;",
"dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);",
"if (!dummy_buf) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"#define WRAP_PLANE(ref_out, data, data_size) \\\ndo { \\",
"AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \\",
"if (!dummy_ref) { \\",
"VAR_3 = AVERROR(ENOMEM); \\",
"goto fail; \\",
"} \\",
"ref_out = av_buffer_create(data, data_size, compat_release_buffer, \\\ndummy_ref, 0); \\",
"if (!ref_out) { \\",
"av_frame_unref(VAR_1); \\",
"VAR_3 = AVERROR(ENOMEM); \\",
"goto fail; \\",
"} \\",
"} while (0)",
"if (VAR_0->codec_type == AVMEDIA_TYPE_VIDEO) {",
"const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(VAR_1->format);",
"if (!desc) {",
"VAR_3 = AVERROR(EINVAL);",
"goto fail;",
"}",
"planes = (desc->VAR_2 & PIX_FMT_PLANAR) ? desc->nb_components : 1;",
"for (i = 0; i < planes; i++) {",
"int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;",
"int plane_size = (VAR_1->width >> h_shift) * VAR_1->linesize[i];",
"WRAP_PLANE(VAR_1->buf[i], VAR_1->data[i], plane_size);",
"}",
"} else {",
"int planar = av_sample_fmt_is_planar(VAR_1->format);",
"planes = planar ? VAR_0->channels : 1;",
"if (planes > FF_ARRAY_ELEMS(VAR_1->buf)) {",
"VAR_1->nb_extended_buf = planes - FF_ARRAY_ELEMS(VAR_1->buf);",
"VAR_1->extended_buf = av_malloc(sizeof(*VAR_1->extended_buf) *\nVAR_1->nb_extended_buf);",
"if (!VAR_1->extended_buf) {",
"VAR_3 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(VAR_1->buf)); i++)",
"WRAP_PLANE(VAR_1->buf[i], VAR_1->extended_data[i], VAR_1->linesize[0]);",
"for (i = 0; i < planes - FF_ARRAY_ELEMS(VAR_1->buf); i++)",
"WRAP_PLANE(VAR_1->extended_buf[i],\nVAR_1->extended_data[i + FF_ARRAY_ELEMS(VAR_1->buf)],\nVAR_1->linesize[0]);",
"}",
"av_buffer_unref(&dummy_buf);",
"return 0;",
"fail:\nVAR_0->release_buffer(VAR_0, VAR_1);",
"av_freep(&priv);",
"av_buffer_unref(&dummy_buf);",
"return VAR_3;",
"}",
"#endif\nreturn VAR_0->get_buffer2(VAR_0, VAR_1, VAR_2);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13,
15
],
[
17,
19
],
[
21,
23
],
[
25,
27
],
[
31,
33
],
[
35
],
[
37,
39,
41
],
[
43,
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65,
81
],
[
83
],
[
85
],
[
87
],
[
91,
93
],
[
97
],
[
99,
101
],
[
113,
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239
],
[
243
],
[
245,
247,
249
],
[
251
],
[
255
],
[
259
],
[
263,
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275,
279
],
[
281
]
]
|
17,130 | static av_cold void common_init(H264Context *h){
MpegEncContext * const s = &h->s;
s->width = s->avctx->width;
s->height = s->avctx->height;
s->codec_id= s->avctx->codec->id;
ff_h264dsp_init(&h->h264dsp, 8, 1);
ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);
h->dequant_coeff_pps= -1;
s->unrestricted_mv=1;
s->decode=1; //FIXME
dsputil_init(&s->dsp, s->avctx); // needed so that idct permutation is known early
memset(h->pps.scaling_matrix4, 16, 6*16*sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
}
| false | FFmpeg | a51fbb56bb9352476affaef1fc6773c8b059db91 | static av_cold void common_init(H264Context *h){
MpegEncContext * const s = &h->s;
s->width = s->avctx->width;
s->height = s->avctx->height;
s->codec_id= s->avctx->codec->id;
ff_h264dsp_init(&h->h264dsp, 8, 1);
ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);
h->dequant_coeff_pps= -1;
s->unrestricted_mv=1;
s->decode=1;
dsputil_init(&s->dsp, s->avctx);
memset(h->pps.scaling_matrix4, 16, 6*16*sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
}
| {
"code": [],
"line_no": []
} | static av_cold void FUNC_0(H264Context *h){
MpegEncContext * const s = &h->s;
s->width = s->avctx->width;
s->height = s->avctx->height;
s->codec_id= s->avctx->codec->id;
ff_h264dsp_init(&h->h264dsp, 8, 1);
ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);
h->dequant_coeff_pps= -1;
s->unrestricted_mv=1;
s->decode=1;
dsputil_init(&s->dsp, s->avctx);
memset(h->pps.scaling_matrix4, 16, 6*16*sizeof(uint8_t));
memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
}
| [
"static av_cold void FUNC_0(H264Context *h){",
"MpegEncContext * const s = &h->s;",
"s->width = s->avctx->width;",
"s->height = s->avctx->height;",
"s->codec_id= s->avctx->codec->id;",
"ff_h264dsp_init(&h->h264dsp, 8, 1);",
"ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);",
"h->dequant_coeff_pps= -1;",
"s->unrestricted_mv=1;",
"s->decode=1;",
"dsputil_init(&s->dsp, s->avctx);",
"memset(h->pps.scaling_matrix4, 16, 6*16*sizeof(uint8_t));",
"memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
33
],
[
35
],
[
37
]
]
|
17,131 | static void RENAME(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
"pxor %%mm7, %%mm7 \n\t"
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
| false | FFmpeg | 13a099799e89a76eb921ca452e1b04a7a28a9855 | static void RENAME(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5)
"pxor %%mm7, %%mm7 \n\t"
#ifdef DITHER1XBPP
"paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
"paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
"paddusb "RED_DITHER"(%5), %%mm5 \n\t"
#endif
WRITERGB15(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither)
);
}
| [
"static void FUNC_0(yuv2rgb555_2)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *buf1, const uint16_t *ubuf0,\nconst uint16_t *ubuf1, const uint16_t *vbuf0,\nconst uint16_t *vbuf1, const uint16_t *abuf0,\nconst uint16_t *abuf1, uint8_t *dest,\nint dstW, int yalpha, int uvalpha, int y)\n{",
"__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB(%%REGBP, %5)\n\"pxor %%mm7, %%mm7 \\n\\t\"\n#ifdef DITHER1XBPP\n\"paddusb \"BLUE_DITHER\"(%5), %%mm2 \\n\\t\"\n\"paddusb \"GREEN_DITHER\"(%5), %%mm4 \\n\\t\"\n\"paddusb \"RED_DITHER\"(%5), %%mm5 \\n\\t\"\n#endif\nWRITERGB15(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (buf1), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither)\n);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
17,
19,
21,
23,
25,
27,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51
],
[
53
]
]
|
17,132 | static void device_finalize(Object *obj)
{
DeviceState *dev = DEVICE(obj);
BusState *bus;
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dev->realized) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (qdev_get_vmsd(dev)) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
if (dc->exit) {
dc->exit(dev);
}
if (dev->opts) {
qemu_opts_del(dev->opts);
}
}
}
| false | qemu | 06f7f2bb562826101468f387b4a34971b16e9aee | static void device_finalize(Object *obj)
{
DeviceState *dev = DEVICE(obj);
BusState *bus;
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dev->realized) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (qdev_get_vmsd(dev)) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
if (dc->exit) {
dc->exit(dev);
}
if (dev->opts) {
qemu_opts_del(dev->opts);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Object *VAR_0)
{
DeviceState *dev = DEVICE(VAR_0);
BusState *bus;
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dev->realized) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (qdev_get_vmsd(dev)) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
if (dc->exit) {
dc->exit(dev);
}
if (dev->opts) {
qemu_opts_del(dev->opts);
}
}
}
| [
"static void FUNC_0(Object *VAR_0)\n{",
"DeviceState *dev = DEVICE(VAR_0);",
"BusState *bus;",
"DeviceClass *dc = DEVICE_GET_CLASS(dev);",
"if (dev->realized) {",
"while (dev->num_child_bus) {",
"bus = QLIST_FIRST(&dev->child_bus);",
"qbus_free(bus);",
"}",
"if (qdev_get_vmsd(dev)) {",
"vmstate_unregister(dev, qdev_get_vmsd(dev), dev);",
"}",
"if (dc->exit) {",
"dc->exit(dev);",
"}",
"if (dev->opts) {",
"qemu_opts_del(dev->opts);",
"}",
"}",
"}"
]
| [
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
]
]
|
17,134 | static int pte_check_hash32(mmu_ctx_t *ctx, target_ulong pte0,
target_ulong pte1, int h, int rw, int type)
{
target_ulong ptem, mmask;
int access, ret, pteh, ptev, pp;
ret = -1;
/* Check validity and table match */
ptev = pte_is_valid_hash32(pte0);
pteh = (pte0 >> 6) & 1;
if (ptev && h == pteh) {
/* Check vsid & api */
ptem = pte0 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
pp = pte1 & 0x00000003;
if (ptem == ctx->ptem) {
if (ctx->raddr != (hwaddr)-1ULL) {
/* all matches should have equal RPN, WIMG & PP */
if ((ctx->raddr & mmask) != (pte1 & mmask)) {
qemu_log("Bad RPN/WIMG/PP\n");
return -3;
}
}
/* Compute access rights */
access = pp_check(ctx->key, pp, ctx->nx);
/* Keep the matching PTE informations */
ctx->raddr = pte1;
ctx->prot = access;
ret = check_prot(ctx->prot, rw, type);
if (ret == 0) {
/* Access granted */
LOG_MMU("PTE access granted !\n");
} else {
/* Access right violation */
LOG_MMU("PTE access rejected\n");
}
}
}
return ret;
}
| false | qemu | 496272a7018ba01aa2b87a1a5ed866ff85133401 | static int pte_check_hash32(mmu_ctx_t *ctx, target_ulong pte0,
target_ulong pte1, int h, int rw, int type)
{
target_ulong ptem, mmask;
int access, ret, pteh, ptev, pp;
ret = -1;
ptev = pte_is_valid_hash32(pte0);
pteh = (pte0 >> 6) & 1;
if (ptev && h == pteh) {
ptem = pte0 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
pp = pte1 & 0x00000003;
if (ptem == ctx->ptem) {
if (ctx->raddr != (hwaddr)-1ULL) {
if ((ctx->raddr & mmask) != (pte1 & mmask)) {
qemu_log("Bad RPN/WIMG/PP\n");
return -3;
}
}
access = pp_check(ctx->key, pp, ctx->nx);
ctx->raddr = pte1;
ctx->prot = access;
ret = check_prot(ctx->prot, rw, type);
if (ret == 0) {
LOG_MMU("PTE access granted !\n");
} else {
LOG_MMU("PTE access rejected\n");
}
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(mmu_ctx_t *VAR_0, target_ulong VAR_1,
target_ulong VAR_2, int VAR_3, int VAR_4, int VAR_5)
{
target_ulong ptem, mmask;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
VAR_7 = -1;
VAR_9 = pte_is_valid_hash32(VAR_1);
VAR_8 = (VAR_1 >> 6) & 1;
if (VAR_9 && VAR_3 == VAR_8) {
ptem = VAR_1 & PTE_PTEM_MASK;
mmask = PTE_CHECK_MASK;
VAR_10 = VAR_2 & 0x00000003;
if (ptem == VAR_0->ptem) {
if (VAR_0->raddr != (hwaddr)-1ULL) {
if ((VAR_0->raddr & mmask) != (VAR_2 & mmask)) {
qemu_log("Bad RPN/WIMG/PP\n");
return -3;
}
}
VAR_6 = pp_check(VAR_0->key, VAR_10, VAR_0->nx);
VAR_0->raddr = VAR_2;
VAR_0->prot = VAR_6;
VAR_7 = check_prot(VAR_0->prot, VAR_4, VAR_5);
if (VAR_7 == 0) {
LOG_MMU("PTE VAR_6 granted !\n");
} else {
LOG_MMU("PTE VAR_6 rejected\n");
}
}
}
return VAR_7;
}
| [
"static int FUNC_0(mmu_ctx_t *VAR_0, target_ulong VAR_1,\ntarget_ulong VAR_2, int VAR_3, int VAR_4, int VAR_5)\n{",
"target_ulong ptem, mmask;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"VAR_7 = -1;",
"VAR_9 = pte_is_valid_hash32(VAR_1);",
"VAR_8 = (VAR_1 >> 6) & 1;",
"if (VAR_9 && VAR_3 == VAR_8) {",
"ptem = VAR_1 & PTE_PTEM_MASK;",
"mmask = PTE_CHECK_MASK;",
"VAR_10 = VAR_2 & 0x00000003;",
"if (ptem == VAR_0->ptem) {",
"if (VAR_0->raddr != (hwaddr)-1ULL) {",
"if ((VAR_0->raddr & mmask) != (VAR_2 & mmask)) {",
"qemu_log(\"Bad RPN/WIMG/PP\\n\");",
"return -3;",
"}",
"}",
"VAR_6 = pp_check(VAR_0->key, VAR_10, VAR_0->nx);",
"VAR_0->raddr = VAR_2;",
"VAR_0->prot = VAR_6;",
"VAR_7 = check_prot(VAR_0->prot, VAR_4, VAR_5);",
"if (VAR_7 == 0) {",
"LOG_MMU(\"PTE VAR_6 granted !\\n\");",
"} else {",
"LOG_MMU(\"PTE VAR_6 rejected\\n\");",
"}",
"}",
"}",
"return VAR_7;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
]
]
|
17,135 | static void gen_lea_modrm(DisasContext *s, int modrm, int *reg_ptr, int *offset_ptr)
{
int havesib;
int base, disp;
int index;
int scale;
int opreg;
int mod, rm, code, override, must_add_seg;
/* XXX: add a generation time variable to tell if base == 0 in DS/ES/SS */
override = -1;
must_add_seg = s->addseg;
if (s->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS)) {
if (s->prefix & PREFIX_ES)
override = R_ES;
else if (s->prefix & PREFIX_CS)
override = R_CS;
else if (s->prefix & PREFIX_SS)
override = R_SS;
else if (s->prefix & PREFIX_DS)
override = R_DS;
else if (s->prefix & PREFIX_FS)
override = R_FS;
else
override = R_GS;
must_add_seg = 1;
}
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (s->aflag) {
havesib = 0;
base = rm;
index = 0;
scale = 0;
if (base == 4) {
havesib = 1;
code = ldub(s->pc++);
scale = (code >> 6) & 3;
index = (code >> 3) & 7;
base = code & 7;
}
switch (mod) {
case 0:
if (base == 5) {
base = -1;
disp = ldl(s->pc);
s->pc += 4;
} else {
disp = 0;
}
break;
case 1:
disp = (int8_t)ldub(s->pc++);
break;
default:
case 2:
disp = ldl(s->pc);
s->pc += 4;
break;
}
if (base >= 0) {
gen_op_movl_A0_reg[base]();
if (disp != 0)
gen_op_addl_A0_im(disp);
} else {
gen_op_movl_A0_im(disp);
}
if (havesib && (index != 4 || scale != 0)) {
gen_op_addl_A0_reg_sN[scale][index]();
}
if (must_add_seg) {
if (override < 0) {
if (base == R_EBP || base == R_ESP)
override = R_SS;
else
override = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
} else {
switch (mod) {
case 0:
if (rm == 6) {
disp = lduw(s->pc);
s->pc += 2;
gen_op_movl_A0_im(disp);
rm = 0; /* avoid SS override */
goto no_rm;
} else {
disp = 0;
}
break;
case 1:
disp = (int8_t)ldub(s->pc++);
break;
default:
case 2:
disp = lduw(s->pc);
s->pc += 2;
break;
}
switch(rm) {
case 0:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 1:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 2:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 3:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 4:
gen_op_movl_A0_reg[R_ESI]();
break;
case 5:
gen_op_movl_A0_reg[R_EDI]();
break;
case 6:
gen_op_movl_A0_reg[R_EBP]();
break;
default:
case 7:
gen_op_movl_A0_reg[R_EBX]();
break;
}
if (disp != 0)
gen_op_addl_A0_im(disp);
gen_op_andl_A0_ffff();
no_rm:
if (must_add_seg) {
if (override < 0) {
if (rm == 2 || rm == 3 || rm == 6)
override = R_SS;
else
override = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
}
opreg = OR_A0;
disp = 0;
*reg_ptr = opreg;
*offset_ptr = disp;
}
| false | qemu | 9c605cb13547a5faa5cb1092e3e44ac8b0d0b841 | static void gen_lea_modrm(DisasContext *s, int modrm, int *reg_ptr, int *offset_ptr)
{
int havesib;
int base, disp;
int index;
int scale;
int opreg;
int mod, rm, code, override, must_add_seg;
override = -1;
must_add_seg = s->addseg;
if (s->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS)) {
if (s->prefix & PREFIX_ES)
override = R_ES;
else if (s->prefix & PREFIX_CS)
override = R_CS;
else if (s->prefix & PREFIX_SS)
override = R_SS;
else if (s->prefix & PREFIX_DS)
override = R_DS;
else if (s->prefix & PREFIX_FS)
override = R_FS;
else
override = R_GS;
must_add_seg = 1;
}
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (s->aflag) {
havesib = 0;
base = rm;
index = 0;
scale = 0;
if (base == 4) {
havesib = 1;
code = ldub(s->pc++);
scale = (code >> 6) & 3;
index = (code >> 3) & 7;
base = code & 7;
}
switch (mod) {
case 0:
if (base == 5) {
base = -1;
disp = ldl(s->pc);
s->pc += 4;
} else {
disp = 0;
}
break;
case 1:
disp = (int8_t)ldub(s->pc++);
break;
default:
case 2:
disp = ldl(s->pc);
s->pc += 4;
break;
}
if (base >= 0) {
gen_op_movl_A0_reg[base]();
if (disp != 0)
gen_op_addl_A0_im(disp);
} else {
gen_op_movl_A0_im(disp);
}
if (havesib && (index != 4 || scale != 0)) {
gen_op_addl_A0_reg_sN[scale][index]();
}
if (must_add_seg) {
if (override < 0) {
if (base == R_EBP || base == R_ESP)
override = R_SS;
else
override = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
} else {
switch (mod) {
case 0:
if (rm == 6) {
disp = lduw(s->pc);
s->pc += 2;
gen_op_movl_A0_im(disp);
rm = 0;
goto no_rm;
} else {
disp = 0;
}
break;
case 1:
disp = (int8_t)ldub(s->pc++);
break;
default:
case 2:
disp = lduw(s->pc);
s->pc += 2;
break;
}
switch(rm) {
case 0:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 1:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 2:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 3:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 4:
gen_op_movl_A0_reg[R_ESI]();
break;
case 5:
gen_op_movl_A0_reg[R_EDI]();
break;
case 6:
gen_op_movl_A0_reg[R_EBP]();
break;
default:
case 7:
gen_op_movl_A0_reg[R_EBX]();
break;
}
if (disp != 0)
gen_op_addl_A0_im(disp);
gen_op_andl_A0_ffff();
no_rm:
if (must_add_seg) {
if (override < 0) {
if (rm == 2 || rm == 3 || rm == 6)
override = R_SS;
else
override = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
}
opreg = OR_A0;
disp = 0;
*reg_ptr = opreg;
*offset_ptr = disp;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, int *VAR_2, int *VAR_3)
{
int VAR_4;
int VAR_5, VAR_6;
int VAR_7;
int VAR_8;
int VAR_9;
int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;
VAR_13 = -1;
VAR_14 = VAR_0->addseg;
if (VAR_0->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS)) {
if (VAR_0->prefix & PREFIX_ES)
VAR_13 = R_ES;
else if (VAR_0->prefix & PREFIX_CS)
VAR_13 = R_CS;
else if (VAR_0->prefix & PREFIX_SS)
VAR_13 = R_SS;
else if (VAR_0->prefix & PREFIX_DS)
VAR_13 = R_DS;
else if (VAR_0->prefix & PREFIX_FS)
VAR_13 = R_FS;
else
VAR_13 = R_GS;
VAR_14 = 1;
}
VAR_10 = (VAR_1 >> 6) & 3;
VAR_11 = VAR_1 & 7;
if (VAR_0->aflag) {
VAR_4 = 0;
VAR_5 = VAR_11;
VAR_7 = 0;
VAR_8 = 0;
if (VAR_5 == 4) {
VAR_4 = 1;
VAR_12 = ldub(VAR_0->pc++);
VAR_8 = (VAR_12 >> 6) & 3;
VAR_7 = (VAR_12 >> 3) & 7;
VAR_5 = VAR_12 & 7;
}
switch (VAR_10) {
case 0:
if (VAR_5 == 5) {
VAR_5 = -1;
VAR_6 = ldl(VAR_0->pc);
VAR_0->pc += 4;
} else {
VAR_6 = 0;
}
break;
case 1:
VAR_6 = (int8_t)ldub(VAR_0->pc++);
break;
default:
case 2:
VAR_6 = ldl(VAR_0->pc);
VAR_0->pc += 4;
break;
}
if (VAR_5 >= 0) {
gen_op_movl_A0_reg[VAR_5]();
if (VAR_6 != 0)
gen_op_addl_A0_im(VAR_6);
} else {
gen_op_movl_A0_im(VAR_6);
}
if (VAR_4 && (VAR_7 != 4 || VAR_8 != 0)) {
gen_op_addl_A0_reg_sN[VAR_8][VAR_7]();
}
if (VAR_14) {
if (VAR_13 < 0) {
if (VAR_5 == R_EBP || VAR_5 == R_ESP)
VAR_13 = R_SS;
else
VAR_13 = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[VAR_13].VAR_5));
}
} else {
switch (VAR_10) {
case 0:
if (VAR_11 == 6) {
VAR_6 = lduw(VAR_0->pc);
VAR_0->pc += 2;
gen_op_movl_A0_im(VAR_6);
VAR_11 = 0;
goto no_rm;
} else {
VAR_6 = 0;
}
break;
case 1:
VAR_6 = (int8_t)ldub(VAR_0->pc++);
break;
default:
case 2:
VAR_6 = lduw(VAR_0->pc);
VAR_0->pc += 2;
break;
}
switch(VAR_11) {
case 0:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 1:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 2:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_ESI]();
break;
case 3:
gen_op_movl_A0_reg[R_EBP]();
gen_op_addl_A0_reg_sN[0][R_EDI]();
break;
case 4:
gen_op_movl_A0_reg[R_ESI]();
break;
case 5:
gen_op_movl_A0_reg[R_EDI]();
break;
case 6:
gen_op_movl_A0_reg[R_EBP]();
break;
default:
case 7:
gen_op_movl_A0_reg[R_EBX]();
break;
}
if (VAR_6 != 0)
gen_op_addl_A0_im(VAR_6);
gen_op_andl_A0_ffff();
no_rm:
if (VAR_14) {
if (VAR_13 < 0) {
if (VAR_11 == 2 || VAR_11 == 3 || VAR_11 == 6)
VAR_13 = R_SS;
else
VAR_13 = R_DS;
}
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[VAR_13].VAR_5));
}
}
VAR_9 = OR_A0;
VAR_6 = 0;
*VAR_2 = VAR_9;
*VAR_3 = VAR_6;
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, int *VAR_2, int *VAR_3)\n{",
"int VAR_4;",
"int VAR_5, VAR_6;",
"int VAR_7;",
"int VAR_8;",
"int VAR_9;",
"int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;",
"VAR_13 = -1;",
"VAR_14 = VAR_0->addseg;",
"if (VAR_0->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |\nPREFIX_ES | PREFIX_FS | PREFIX_GS)) {",
"if (VAR_0->prefix & PREFIX_ES)\nVAR_13 = R_ES;",
"else if (VAR_0->prefix & PREFIX_CS)\nVAR_13 = R_CS;",
"else if (VAR_0->prefix & PREFIX_SS)\nVAR_13 = R_SS;",
"else if (VAR_0->prefix & PREFIX_DS)\nVAR_13 = R_DS;",
"else if (VAR_0->prefix & PREFIX_FS)\nVAR_13 = R_FS;",
"else\nVAR_13 = R_GS;",
"VAR_14 = 1;",
"}",
"VAR_10 = (VAR_1 >> 6) & 3;",
"VAR_11 = VAR_1 & 7;",
"if (VAR_0->aflag) {",
"VAR_4 = 0;",
"VAR_5 = VAR_11;",
"VAR_7 = 0;",
"VAR_8 = 0;",
"if (VAR_5 == 4) {",
"VAR_4 = 1;",
"VAR_12 = ldub(VAR_0->pc++);",
"VAR_8 = (VAR_12 >> 6) & 3;",
"VAR_7 = (VAR_12 >> 3) & 7;",
"VAR_5 = VAR_12 & 7;",
"}",
"switch (VAR_10) {",
"case 0:\nif (VAR_5 == 5) {",
"VAR_5 = -1;",
"VAR_6 = ldl(VAR_0->pc);",
"VAR_0->pc += 4;",
"} else {",
"VAR_6 = 0;",
"}",
"break;",
"case 1:\nVAR_6 = (int8_t)ldub(VAR_0->pc++);",
"break;",
"default:\ncase 2:\nVAR_6 = ldl(VAR_0->pc);",
"VAR_0->pc += 4;",
"break;",
"}",
"if (VAR_5 >= 0) {",
"gen_op_movl_A0_reg[VAR_5]();",
"if (VAR_6 != 0)\ngen_op_addl_A0_im(VAR_6);",
"} else {",
"gen_op_movl_A0_im(VAR_6);",
"}",
"if (VAR_4 && (VAR_7 != 4 || VAR_8 != 0)) {",
"gen_op_addl_A0_reg_sN[VAR_8][VAR_7]();",
"}",
"if (VAR_14) {",
"if (VAR_13 < 0) {",
"if (VAR_5 == R_EBP || VAR_5 == R_ESP)\nVAR_13 = R_SS;",
"else\nVAR_13 = R_DS;",
"}",
"gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[VAR_13].VAR_5));",
"}",
"} else {",
"switch (VAR_10) {",
"case 0:\nif (VAR_11 == 6) {",
"VAR_6 = lduw(VAR_0->pc);",
"VAR_0->pc += 2;",
"gen_op_movl_A0_im(VAR_6);",
"VAR_11 = 0;",
"goto no_rm;",
"} else {",
"VAR_6 = 0;",
"}",
"break;",
"case 1:\nVAR_6 = (int8_t)ldub(VAR_0->pc++);",
"break;",
"default:\ncase 2:\nVAR_6 = lduw(VAR_0->pc);",
"VAR_0->pc += 2;",
"break;",
"}",
"switch(VAR_11) {",
"case 0:\ngen_op_movl_A0_reg[R_EBX]();",
"gen_op_addl_A0_reg_sN[0][R_ESI]();",
"break;",
"case 1:\ngen_op_movl_A0_reg[R_EBX]();",
"gen_op_addl_A0_reg_sN[0][R_EDI]();",
"break;",
"case 2:\ngen_op_movl_A0_reg[R_EBP]();",
"gen_op_addl_A0_reg_sN[0][R_ESI]();",
"break;",
"case 3:\ngen_op_movl_A0_reg[R_EBP]();",
"gen_op_addl_A0_reg_sN[0][R_EDI]();",
"break;",
"case 4:\ngen_op_movl_A0_reg[R_ESI]();",
"break;",
"case 5:\ngen_op_movl_A0_reg[R_EDI]();",
"break;",
"case 6:\ngen_op_movl_A0_reg[R_EBP]();",
"break;",
"default:\ncase 7:\ngen_op_movl_A0_reg[R_EBX]();",
"break;",
"}",
"if (VAR_6 != 0)\ngen_op_addl_A0_im(VAR_6);",
"gen_op_andl_A0_ffff();",
"no_rm:\nif (VAR_14) {",
"if (VAR_13 < 0) {",
"if (VAR_11 == 2 || VAR_11 == 3 || VAR_11 == 6)\nVAR_13 = R_SS;",
"else\nVAR_13 = R_DS;",
"}",
"gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[VAR_13].VAR_5));",
"}",
"}",
"VAR_9 = OR_A0;",
"VAR_6 = 0;",
"*VAR_2 = VAR_9;",
"*VAR_3 = VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
21
],
[
23
],
[
25,
27
],
[
29,
31
],
[
33,
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121,
123,
125
],
[
127
],
[
129
],
[
131
],
[
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
],
[
309
],
[
311
],
[
313
],
[
315
],
[
317
]
]
|
17,136 | static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
{
VideoPicture *vp;
#if CONFIG_AVFILTER
AVPicture pict_src;
#else
int dst_pix_fmt = AV_PIX_FMT_YUV420P;
#endif
/* wait until we have space to put a new picture */
SDL_LockMutex(is->pictq_mutex);
if (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
is->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0 - FRAME_SKIP_FACTOR));
while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
vp = &is->pictq[is->pictq_windex];
vp->sar = src_frame->sample_aspect_ratio;
/* alloc or resize hardware picture buffer */
if (!vp->bmp || vp->reallocate ||
#if CONFIG_AVFILTER
vp->width != is->out_video_filter->inputs[0]->w ||
vp->height != is->out_video_filter->inputs[0]->h) {
#else
vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
vp->reallocate = 0;
/* the allocation must be done in the main thread to avoid
locking problems */
event.type = FF_ALLOC_EVENT;
event.user.data1 = is;
SDL_PushEvent(&event);
/* wait until the picture is allocated */
SDL_LockMutex(is->pictq_mutex);
while (!vp->allocated && !is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
}
/* if the frame is not skipped, then display it */
if (vp->bmp) {
AVPicture pict = { { 0 } };
/* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp);
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
pict_src.data[0] = src_frame->data[0];
pict_src.data[1] = src_frame->data[1];
pict_src.data[2] = src_frame->data[2];
pict_src.linesize[0] = src_frame->linesize[0];
pict_src.linesize[1] = src_frame->linesize[1];
pict_src.linesize[2] = src_frame->linesize[2];
// FIXME use direct rendering
av_picture_copy(&pict, &pict_src,
vp->pix_fmt, vp->width, vp->height);
#else
av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
if (is->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
}
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
/* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp);
vp->pts = pts;
vp->pos = pos;
/* now we can update the picture count */
if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_windex = 0;
SDL_LockMutex(is->pictq_mutex);
vp->target_clock = compute_target_time(vp->pts, is);
is->pictq_size++;
SDL_UnlockMutex(is->pictq_mutex);
}
return 0;
}
| false | FFmpeg | f929ab0569ff31ed5a59b0b0adb7ce09df3fca39 | static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
{
VideoPicture *vp;
#if CONFIG_AVFILTER
AVPicture pict_src;
#else
int dst_pix_fmt = AV_PIX_FMT_YUV420P;
#endif
SDL_LockMutex(is->pictq_mutex);
if (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->refresh)
is->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0 - FRAME_SKIP_FACTOR));
while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
vp = &is->pictq[is->pictq_windex];
vp->sar = src_frame->sample_aspect_ratio;
if (!vp->bmp || vp->reallocate ||
#if CONFIG_AVFILTER
vp->width != is->out_video_filter->inputs[0]->w ||
vp->height != is->out_video_filter->inputs[0]->h) {
#else
vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
vp->reallocate = 0;
event.type = FF_ALLOC_EVENT;
event.user.data1 = is;
SDL_PushEvent(&event);
SDL_LockMutex(is->pictq_mutex);
while (!vp->allocated && !is->videoq.abort_request) {
SDL_CondWait(is->pictq_cond, is->pictq_mutex);
}
SDL_UnlockMutex(is->pictq_mutex);
if (is->videoq.abort_request)
return -1;
}
if (vp->bmp) {
AVPicture pict = { { 0 } };
SDL_LockYUVOverlay (vp->bmp);
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
pict_src.data[0] = src_frame->data[0];
pict_src.data[1] = src_frame->data[1];
pict_src.data[2] = src_frame->data[2];
pict_src.linesize[0] = src_frame->linesize[0];
pict_src.linesize[1] = src_frame->linesize[1];
pict_src.linesize[2] = src_frame->linesize[2];
av_picture_copy(&pict, &pict_src,
vp->pix_fmt, vp->width, vp->height);
#else
av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
if (is->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
}
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
SDL_UnlockYUVOverlay(vp->bmp);
vp->pts = pts;
vp->pos = pos;
if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
is->pictq_windex = 0;
SDL_LockMutex(is->pictq_mutex);
vp->target_clock = compute_target_time(vp->pts, is);
is->pictq_size++;
SDL_UnlockMutex(is->pictq_mutex);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2, int64_t VAR_3)
{
VideoPicture *vp;
#if CONFIG_AVFILTER
AVPicture pict_src;
#else
int VAR_4 = AV_PIX_FMT_YUV420P;
#endif
SDL_LockMutex(VAR_0->pictq_mutex);
if (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !VAR_0->refresh)
VAR_0->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, VAR_0->skip_frames * (1.0 - FRAME_SKIP_FACTOR));
while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&
!VAR_0->videoq.abort_request) {
SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);
}
SDL_UnlockMutex(VAR_0->pictq_mutex);
if (VAR_0->videoq.abort_request)
return -1;
vp = &VAR_0->pictq[VAR_0->pictq_windex];
vp->sar = VAR_1->sample_aspect_ratio;
if (!vp->bmp || vp->reallocate ||
#if CONFIG_AVFILTER
vp->width != VAR_0->out_video_filter->inputs[0]->w ||
vp->height != VAR_0->out_video_filter->inputs[0]->h) {
#else
vp->width != VAR_0->video_st->codec->width ||
vp->height != VAR_0->video_st->codec->height) {
#endif
SDL_Event event;
vp->allocated = 0;
vp->reallocate = 0;
event.type = FF_ALLOC_EVENT;
event.user.data1 = VAR_0;
SDL_PushEvent(&event);
SDL_LockMutex(VAR_0->pictq_mutex);
while (!vp->allocated && !VAR_0->videoq.abort_request) {
SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);
}
SDL_UnlockMutex(VAR_0->pictq_mutex);
if (VAR_0->videoq.abort_request)
return -1;
}
if (vp->bmp) {
AVPicture pict = { { 0 } };
SDL_LockYUVOverlay (vp->bmp);
pict.data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
pict_src.data[0] = VAR_1->data[0];
pict_src.data[1] = VAR_1->data[1];
pict_src.data[2] = VAR_1->data[2];
pict_src.linesize[0] = VAR_1->linesize[0];
pict_src.linesize[1] = VAR_1->linesize[1];
pict_src.linesize[2] = VAR_1->linesize[2];
av_picture_copy(&pict, &pict_src,
vp->pix_fmt, vp->width, vp->height);
#else
av_opt_get_int(sws_opts, "sws_flags", 0, &sws_flags);
VAR_0->img_convert_ctx = sws_getCachedContext(VAR_0->img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
VAR_4, sws_flags, NULL, NULL, NULL);
if (VAR_0->img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context\n");
exit(1);
}
sws_scale(VAR_0->img_convert_ctx, VAR_1->data, VAR_1->linesize,
0, vp->height, pict.data, pict.linesize);
#endif
SDL_UnlockYUVOverlay(vp->bmp);
vp->VAR_2 = VAR_2;
vp->VAR_3 = VAR_3;
if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)
VAR_0->pictq_windex = 0;
SDL_LockMutex(VAR_0->pictq_mutex);
vp->target_clock = compute_target_time(vp->VAR_2, VAR_0);
VAR_0->pictq_size++;
SDL_UnlockMutex(VAR_0->pictq_mutex);
}
return 0;
}
| [
"static int FUNC_0(VideoState *VAR_0, AVFrame *VAR_1, double VAR_2, int64_t VAR_3)\n{",
"VideoPicture *vp;",
"#if CONFIG_AVFILTER\nAVPicture pict_src;",
"#else\nint VAR_4 = AV_PIX_FMT_YUV420P;",
"#endif\nSDL_LockMutex(VAR_0->pictq_mutex);",
"if (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !VAR_0->refresh)\nVAR_0->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, VAR_0->skip_frames * (1.0 - FRAME_SKIP_FACTOR));",
"while (VAR_0->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE &&\n!VAR_0->videoq.abort_request) {",
"SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);",
"}",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"if (VAR_0->videoq.abort_request)\nreturn -1;",
"vp = &VAR_0->pictq[VAR_0->pictq_windex];",
"vp->sar = VAR_1->sample_aspect_ratio;",
"if (!vp->bmp || vp->reallocate ||\n#if CONFIG_AVFILTER\nvp->width != VAR_0->out_video_filter->inputs[0]->w ||\nvp->height != VAR_0->out_video_filter->inputs[0]->h) {",
"#else\nvp->width != VAR_0->video_st->codec->width ||\nvp->height != VAR_0->video_st->codec->height) {",
"#endif\nSDL_Event event;",
"vp->allocated = 0;",
"vp->reallocate = 0;",
"event.type = FF_ALLOC_EVENT;",
"event.user.data1 = VAR_0;",
"SDL_PushEvent(&event);",
"SDL_LockMutex(VAR_0->pictq_mutex);",
"while (!vp->allocated && !VAR_0->videoq.abort_request) {",
"SDL_CondWait(VAR_0->pictq_cond, VAR_0->pictq_mutex);",
"}",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"if (VAR_0->videoq.abort_request)\nreturn -1;",
"}",
"if (vp->bmp) {",
"AVPicture pict = { { 0 } };",
"SDL_LockYUVOverlay (vp->bmp);",
"pict.data[0] = vp->bmp->pixels[0];",
"pict.data[1] = vp->bmp->pixels[2];",
"pict.data[2] = vp->bmp->pixels[1];",
"pict.linesize[0] = vp->bmp->pitches[0];",
"pict.linesize[1] = vp->bmp->pitches[2];",
"pict.linesize[2] = vp->bmp->pitches[1];",
"#if CONFIG_AVFILTER\npict_src.data[0] = VAR_1->data[0];",
"pict_src.data[1] = VAR_1->data[1];",
"pict_src.data[2] = VAR_1->data[2];",
"pict_src.linesize[0] = VAR_1->linesize[0];",
"pict_src.linesize[1] = VAR_1->linesize[1];",
"pict_src.linesize[2] = VAR_1->linesize[2];",
"av_picture_copy(&pict, &pict_src,\nvp->pix_fmt, vp->width, vp->height);",
"#else\nav_opt_get_int(sws_opts, \"sws_flags\", 0, &sws_flags);",
"VAR_0->img_convert_ctx = sws_getCachedContext(VAR_0->img_convert_ctx,\nvp->width, vp->height, vp->pix_fmt, vp->width, vp->height,\nVAR_4, sws_flags, NULL, NULL, NULL);",
"if (VAR_0->img_convert_ctx == NULL) {",
"fprintf(stderr, \"Cannot initialize the conversion context\\n\");",
"exit(1);",
"}",
"sws_scale(VAR_0->img_convert_ctx, VAR_1->data, VAR_1->linesize,\n0, vp->height, pict.data, pict.linesize);",
"#endif\nSDL_UnlockYUVOverlay(vp->bmp);",
"vp->VAR_2 = VAR_2;",
"vp->VAR_3 = VAR_3;",
"if (++VAR_0->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE)\nVAR_0->pictq_windex = 0;",
"SDL_LockMutex(VAR_0->pictq_mutex);",
"vp->target_clock = compute_target_time(vp->VAR_2, VAR_0);",
"VAR_0->pictq_size++;",
"SDL_UnlockMutex(VAR_0->pictq_mutex);",
"}",
"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
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15,
19
],
[
23,
25
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
47
],
[
51
],
[
57,
59,
61,
63
],
[
65,
67,
69
],
[
71,
73
],
[
77
],
[
79
],
[
87
],
[
89
],
[
91
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109,
111
],
[
113
],
[
119
],
[
121
],
[
127
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
147,
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
167,
169
],
[
171,
173
],
[
175,
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193,
197
],
[
201
],
[
203
],
[
209,
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
]
]
|
17,137 | float64 int64_to_float64( int64 a STATUS_PARAM )
{
flag zSign;
if ( a == 0 ) return 0;
if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) {
return packFloat64( 1, 0x43E, 0 );
}
zSign = ( a < 0 );
return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a STATUS_VAR );
}
| false | qemu | f090c9d4ad5812fb92843d6470a1111c15190c4c | float64 int64_to_float64( int64 a STATUS_PARAM )
{
flag zSign;
if ( a == 0 ) return 0;
if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) {
return packFloat64( 1, 0x43E, 0 );
}
zSign = ( a < 0 );
return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a STATUS_VAR );
}
| {
"code": [],
"line_no": []
} | float64 FUNC_0( int64 a STATUS_PARAM )
{
flag zSign;
if ( a == 0 ) return 0;
if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) {
return packFloat64( 1, 0x43E, 0 );
}
zSign = ( a < 0 );
return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a STATUS_VAR );
}
| [
"float64 FUNC_0( int64 a STATUS_PARAM )\n{",
"flag zSign;",
"if ( a == 0 ) return 0;",
"if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) {",
"return packFloat64( 1, 0x43E, 0 );",
"}",
"zSign = ( a < 0 );",
"return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a STATUS_VAR );",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
]
]
|
17,138 | static void rtas_ibm_change_msi(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
uint32_t config_addr = rtas_ld(args, 0);
uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
unsigned int func = rtas_ld(args, 3);
unsigned int req_num = rtas_ld(args, 4); /* 0 == remove all */
unsigned int seq_num = rtas_ld(args, 5);
unsigned int ret_intr_type;
int ndev, irq;
sPAPRPHBState *phb = NULL;
PCIDevice *pdev = NULL;
switch (func) {
case RTAS_CHANGE_MSI_FN:
case RTAS_CHANGE_FN:
ret_intr_type = RTAS_TYPE_MSI;
break;
case RTAS_CHANGE_MSIX_FN:
ret_intr_type = RTAS_TYPE_MSIX;
break;
default:
fprintf(stderr, "rtas_ibm_change_msi(%u) is not implemented\n", func);
rtas_st(rets, 0, -3); /* Parameter error */
return;
}
/* Fins sPAPRPHBState */
phb = find_phb(spapr, buid);
if (phb) {
pdev = find_dev(spapr, buid, config_addr);
}
if (!phb || !pdev) {
rtas_st(rets, 0, -3); /* Parameter error */
return;
}
/* Releasing MSIs */
if (!req_num) {
ndev = spapr_msicfg_find(phb, config_addr, false);
if (ndev < 0) {
trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr);
rtas_st(rets, 0, -1); /* Hardware error */
return;
}
trace_spapr_pci_msi("Released MSIs", ndev, config_addr);
rtas_st(rets, 0, 0);
rtas_st(rets, 1, 0);
return;
}
/* Enabling MSI */
/* Find a device number in the map to add or reuse the existing one */
ndev = spapr_msicfg_find(phb, config_addr, true);
if (ndev >= SPAPR_MSIX_MAX_DEVS || ndev < 0) {
fprintf(stderr, "No free entry for a new MSI device\n");
rtas_st(rets, 0, -1); /* Hardware error */
return;
}
trace_spapr_pci_msi("Configuring MSI", ndev, config_addr);
/* Check if there is an old config and MSI number has not changed */
if (phb->msi_table[ndev].nvec && (req_num != phb->msi_table[ndev].nvec)) {
/* Unexpected behaviour */
fprintf(stderr, "Cannot reuse MSI config for device#%d", ndev);
rtas_st(rets, 0, -1); /* Hardware error */
return;
}
/* There is no cached config, allocate MSIs */
if (!phb->msi_table[ndev].nvec) {
irq = spapr_allocate_irq_block(req_num, false);
if (irq < 0) {
fprintf(stderr, "Cannot allocate MSIs for device#%d", ndev);
rtas_st(rets, 0, -1); /* Hardware error */
return;
}
phb->msi_table[ndev].irq = irq;
phb->msi_table[ndev].nvec = req_num;
phb->msi_table[ndev].config_addr = config_addr;
}
/* Setup MSI/MSIX vectors in the device (via cfgspace or MSIX BAR) */
spapr_msi_setmsg(pdev, phb->msi_win_addr | (ndev << 16),
ret_intr_type == RTAS_TYPE_MSIX, req_num);
rtas_st(rets, 0, 0);
rtas_st(rets, 1, req_num);
rtas_st(rets, 2, ++seq_num);
rtas_st(rets, 3, ret_intr_type);
trace_spapr_pci_rtas_ibm_change_msi(func, req_num);
}
| false | qemu | 210b580b106fa798149e28aa13c66b325a43204e | static void rtas_ibm_change_msi(sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
uint32_t config_addr = rtas_ld(args, 0);
uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
unsigned int func = rtas_ld(args, 3);
unsigned int req_num = rtas_ld(args, 4);
unsigned int seq_num = rtas_ld(args, 5);
unsigned int ret_intr_type;
int ndev, irq;
sPAPRPHBState *phb = NULL;
PCIDevice *pdev = NULL;
switch (func) {
case RTAS_CHANGE_MSI_FN:
case RTAS_CHANGE_FN:
ret_intr_type = RTAS_TYPE_MSI;
break;
case RTAS_CHANGE_MSIX_FN:
ret_intr_type = RTAS_TYPE_MSIX;
break;
default:
fprintf(stderr, "rtas_ibm_change_msi(%u) is not implemented\n", func);
rtas_st(rets, 0, -3);
return;
}
phb = find_phb(spapr, buid);
if (phb) {
pdev = find_dev(spapr, buid, config_addr);
}
if (!phb || !pdev) {
rtas_st(rets, 0, -3);
return;
}
if (!req_num) {
ndev = spapr_msicfg_find(phb, config_addr, false);
if (ndev < 0) {
trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr);
rtas_st(rets, 0, -1);
return;
}
trace_spapr_pci_msi("Released MSIs", ndev, config_addr);
rtas_st(rets, 0, 0);
rtas_st(rets, 1, 0);
return;
}
ndev = spapr_msicfg_find(phb, config_addr, true);
if (ndev >= SPAPR_MSIX_MAX_DEVS || ndev < 0) {
fprintf(stderr, "No free entry for a new MSI device\n");
rtas_st(rets, 0, -1);
return;
}
trace_spapr_pci_msi("Configuring MSI", ndev, config_addr);
if (phb->msi_table[ndev].nvec && (req_num != phb->msi_table[ndev].nvec)) {
fprintf(stderr, "Cannot reuse MSI config for device#%d", ndev);
rtas_st(rets, 0, -1);
return;
}
if (!phb->msi_table[ndev].nvec) {
irq = spapr_allocate_irq_block(req_num, false);
if (irq < 0) {
fprintf(stderr, "Cannot allocate MSIs for device#%d", ndev);
rtas_st(rets, 0, -1);
return;
}
phb->msi_table[ndev].irq = irq;
phb->msi_table[ndev].nvec = req_num;
phb->msi_table[ndev].config_addr = config_addr;
}
spapr_msi_setmsg(pdev, phb->msi_win_addr | (ndev << 16),
ret_intr_type == RTAS_TYPE_MSIX, req_num);
rtas_st(rets, 0, 0);
rtas_st(rets, 1, req_num);
rtas_st(rets, 2, ++seq_num);
rtas_st(rets, 3, ret_intr_type);
trace_spapr_pci_rtas_ibm_change_msi(func, req_num);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPREnvironment *VAR_0,
uint32_t VAR_1, uint32_t VAR_2,
target_ulong VAR_3, uint32_t VAR_4,
target_ulong VAR_5)
{
uint32_t config_addr = rtas_ld(VAR_3, 0);
uint64_t buid = ((uint64_t)rtas_ld(VAR_3, 1) << 32) | rtas_ld(VAR_3, 2);
unsigned int VAR_6 = rtas_ld(VAR_3, 3);
unsigned int VAR_7 = rtas_ld(VAR_3, 4);
unsigned int VAR_8 = rtas_ld(VAR_3, 5);
unsigned int VAR_9;
int VAR_10, VAR_11;
sPAPRPHBState *phb = NULL;
PCIDevice *pdev = NULL;
switch (VAR_6) {
case RTAS_CHANGE_MSI_FN:
case RTAS_CHANGE_FN:
VAR_9 = RTAS_TYPE_MSI;
break;
case RTAS_CHANGE_MSIX_FN:
VAR_9 = RTAS_TYPE_MSIX;
break;
default:
fprintf(stderr, "FUNC_0(%u) is not implemented\n", VAR_6);
rtas_st(VAR_5, 0, -3);
return;
}
phb = find_phb(VAR_0, buid);
if (phb) {
pdev = find_dev(VAR_0, buid, config_addr);
}
if (!phb || !pdev) {
rtas_st(VAR_5, 0, -3);
return;
}
if (!VAR_7) {
VAR_10 = spapr_msicfg_find(phb, config_addr, false);
if (VAR_10 < 0) {
trace_spapr_pci_msi("MSI has not been enabled", -1, config_addr);
rtas_st(VAR_5, 0, -1);
return;
}
trace_spapr_pci_msi("Released MSIs", VAR_10, config_addr);
rtas_st(VAR_5, 0, 0);
rtas_st(VAR_5, 1, 0);
return;
}
VAR_10 = spapr_msicfg_find(phb, config_addr, true);
if (VAR_10 >= SPAPR_MSIX_MAX_DEVS || VAR_10 < 0) {
fprintf(stderr, "No free entry for a new MSI device\n");
rtas_st(VAR_5, 0, -1);
return;
}
trace_spapr_pci_msi("Configuring MSI", VAR_10, config_addr);
if (phb->msi_table[VAR_10].nvec && (VAR_7 != phb->msi_table[VAR_10].nvec)) {
fprintf(stderr, "Cannot reuse MSI config for device#%d", VAR_10);
rtas_st(VAR_5, 0, -1);
return;
}
if (!phb->msi_table[VAR_10].nvec) {
VAR_11 = spapr_allocate_irq_block(VAR_7, false);
if (VAR_11 < 0) {
fprintf(stderr, "Cannot allocate MSIs for device#%d", VAR_10);
rtas_st(VAR_5, 0, -1);
return;
}
phb->msi_table[VAR_10].VAR_11 = VAR_11;
phb->msi_table[VAR_10].nvec = VAR_7;
phb->msi_table[VAR_10].config_addr = config_addr;
}
spapr_msi_setmsg(pdev, phb->msi_win_addr | (VAR_10 << 16),
VAR_9 == RTAS_TYPE_MSIX, VAR_7);
rtas_st(VAR_5, 0, 0);
rtas_st(VAR_5, 1, VAR_7);
rtas_st(VAR_5, 2, ++VAR_8);
rtas_st(VAR_5, 3, VAR_9);
trace_spapr_pci_rtas_ibm_change_msi(VAR_6, VAR_7);
}
| [
"static void FUNC_0(sPAPREnvironment *VAR_0,\nuint32_t VAR_1, uint32_t VAR_2,\ntarget_ulong VAR_3, uint32_t VAR_4,\ntarget_ulong VAR_5)\n{",
"uint32_t config_addr = rtas_ld(VAR_3, 0);",
"uint64_t buid = ((uint64_t)rtas_ld(VAR_3, 1) << 32) | rtas_ld(VAR_3, 2);",
"unsigned int VAR_6 = rtas_ld(VAR_3, 3);",
"unsigned int VAR_7 = rtas_ld(VAR_3, 4);",
"unsigned int VAR_8 = rtas_ld(VAR_3, 5);",
"unsigned int VAR_9;",
"int VAR_10, VAR_11;",
"sPAPRPHBState *phb = NULL;",
"PCIDevice *pdev = NULL;",
"switch (VAR_6) {",
"case RTAS_CHANGE_MSI_FN:\ncase RTAS_CHANGE_FN:\nVAR_9 = RTAS_TYPE_MSI;",
"break;",
"case RTAS_CHANGE_MSIX_FN:\nVAR_9 = RTAS_TYPE_MSIX;",
"break;",
"default:\nfprintf(stderr, \"FUNC_0(%u) is not implemented\\n\", VAR_6);",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"phb = find_phb(VAR_0, buid);",
"if (phb) {",
"pdev = find_dev(VAR_0, buid, config_addr);",
"}",
"if (!phb || !pdev) {",
"rtas_st(VAR_5, 0, -3);",
"return;",
"}",
"if (!VAR_7) {",
"VAR_10 = spapr_msicfg_find(phb, config_addr, false);",
"if (VAR_10 < 0) {",
"trace_spapr_pci_msi(\"MSI has not been enabled\", -1, config_addr);",
"rtas_st(VAR_5, 0, -1);",
"return;",
"}",
"trace_spapr_pci_msi(\"Released MSIs\", VAR_10, config_addr);",
"rtas_st(VAR_5, 0, 0);",
"rtas_st(VAR_5, 1, 0);",
"return;",
"}",
"VAR_10 = spapr_msicfg_find(phb, config_addr, true);",
"if (VAR_10 >= SPAPR_MSIX_MAX_DEVS || VAR_10 < 0) {",
"fprintf(stderr, \"No free entry for a new MSI device\\n\");",
"rtas_st(VAR_5, 0, -1);",
"return;",
"}",
"trace_spapr_pci_msi(\"Configuring MSI\", VAR_10, config_addr);",
"if (phb->msi_table[VAR_10].nvec && (VAR_7 != phb->msi_table[VAR_10].nvec)) {",
"fprintf(stderr, \"Cannot reuse MSI config for device#%d\", VAR_10);",
"rtas_st(VAR_5, 0, -1);",
"return;",
"}",
"if (!phb->msi_table[VAR_10].nvec) {",
"VAR_11 = spapr_allocate_irq_block(VAR_7, false);",
"if (VAR_11 < 0) {",
"fprintf(stderr, \"Cannot allocate MSIs for device#%d\", VAR_10);",
"rtas_st(VAR_5, 0, -1);",
"return;",
"}",
"phb->msi_table[VAR_10].VAR_11 = VAR_11;",
"phb->msi_table[VAR_10].nvec = VAR_7;",
"phb->msi_table[VAR_10].config_addr = config_addr;",
"}",
"spapr_msi_setmsg(pdev, phb->msi_win_addr | (VAR_10 << 16),\nVAR_9 == RTAS_TYPE_MSIX, VAR_7);",
"rtas_st(VAR_5, 0, 0);",
"rtas_st(VAR_5, 1, VAR_7);",
"rtas_st(VAR_5, 2, ++VAR_8);",
"rtas_st(VAR_5, 3, VAR_9);",
"trace_spapr_pci_rtas_ibm_change_msi(VAR_6, VAR_7);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33,
35,
37
],
[
39
],
[
41,
43
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
173,
175
],
[
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
]
]
|
17,139 | static void gic_dist_writel(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
GICState *s = (GICState *)opaque;
if (offset == 0xf00) {
int cpu;
int irq;
int mask;
cpu = gic_get_current_cpu(s);
irq = value & 0x3ff;
switch ((value >> 24) & 3) {
case 0:
mask = (value >> 16) & ALL_CPU_MASK;
break;
case 1:
mask = ALL_CPU_MASK ^ (1 << cpu);
break;
case 2:
mask = 1 << cpu;
break;
default:
DPRINTF("Bad Soft Int target filter\n");
mask = ALL_CPU_MASK;
break;
}
GIC_SET_PENDING(irq, mask);
gic_update(s);
return;
}
gic_dist_writew(opaque, offset, value & 0xffff);
gic_dist_writew(opaque, offset + 2, value >> 16);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void gic_dist_writel(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
GICState *s = (GICState *)opaque;
if (offset == 0xf00) {
int cpu;
int irq;
int mask;
cpu = gic_get_current_cpu(s);
irq = value & 0x3ff;
switch ((value >> 24) & 3) {
case 0:
mask = (value >> 16) & ALL_CPU_MASK;
break;
case 1:
mask = ALL_CPU_MASK ^ (1 << cpu);
break;
case 2:
mask = 1 << cpu;
break;
default:
DPRINTF("Bad Soft Int target filter\n");
mask = ALL_CPU_MASK;
break;
}
GIC_SET_PENDING(irq, mask);
gic_update(s);
return;
}
gic_dist_writew(opaque, offset, value & 0xffff);
gic_dist_writew(opaque, offset + 2, value >> 16);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{
GICState *s = (GICState *)VAR_0;
if (VAR_1 == 0xf00) {
int VAR_3;
int VAR_4;
int VAR_5;
VAR_3 = gic_get_current_cpu(s);
VAR_4 = VAR_2 & 0x3ff;
switch ((VAR_2 >> 24) & 3) {
case 0:
VAR_5 = (VAR_2 >> 16) & ALL_CPU_MASK;
break;
case 1:
VAR_5 = ALL_CPU_MASK ^ (1 << VAR_3);
break;
case 2:
VAR_5 = 1 << VAR_3;
break;
default:
DPRINTF("Bad Soft Int target filter\n");
VAR_5 = ALL_CPU_MASK;
break;
}
GIC_SET_PENDING(VAR_4, VAR_5);
gic_update(s);
return;
}
gic_dist_writew(VAR_0, VAR_1, VAR_2 & 0xffff);
gic_dist_writew(VAR_0, VAR_1 + 2, VAR_2 >> 16);
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint32_t VAR_2)\n{",
"GICState *s = (GICState *)VAR_0;",
"if (VAR_1 == 0xf00) {",
"int VAR_3;",
"int VAR_4;",
"int VAR_5;",
"VAR_3 = gic_get_current_cpu(s);",
"VAR_4 = VAR_2 & 0x3ff;",
"switch ((VAR_2 >> 24) & 3) {",
"case 0:\nVAR_5 = (VAR_2 >> 16) & ALL_CPU_MASK;",
"break;",
"case 1:\nVAR_5 = ALL_CPU_MASK ^ (1 << VAR_3);",
"break;",
"case 2:\nVAR_5 = 1 << VAR_3;",
"break;",
"default:\nDPRINTF(\"Bad Soft Int target filter\\n\");",
"VAR_5 = ALL_CPU_MASK;",
"break;",
"}",
"GIC_SET_PENDING(VAR_4, VAR_5);",
"gic_update(s);",
"return;",
"}",
"gic_dist_writew(VAR_0, VAR_1, VAR_2 & 0xffff);",
"gic_dist_writew(VAR_0, VAR_1 + 2, VAR_2 >> 16);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
]
|
17,142 | void eth_setup_vlan_headers(struct eth_header *ehdr, uint16_t vlan_tag,
bool *is_new)
{
struct vlan_header *vhdr = PKT_GET_VLAN_HDR(ehdr);
switch (be16_to_cpu(ehdr->h_proto)) {
case ETH_P_VLAN:
case ETH_P_DVLAN:
/* vlan hdr exists */
*is_new = false;
break;
default:
/* No VLAN header, put a new one */
vhdr->h_proto = ehdr->h_proto;
ehdr->h_proto = cpu_to_be16(ETH_P_VLAN);
*is_new = true;
break;
}
vhdr->h_tci = cpu_to_be16(vlan_tag);
}
| false | qemu | eb700029c7836798046191d62d595363d92c84d4 | void eth_setup_vlan_headers(struct eth_header *ehdr, uint16_t vlan_tag,
bool *is_new)
{
struct vlan_header *vhdr = PKT_GET_VLAN_HDR(ehdr);
switch (be16_to_cpu(ehdr->h_proto)) {
case ETH_P_VLAN:
case ETH_P_DVLAN:
*is_new = false;
break;
default:
vhdr->h_proto = ehdr->h_proto;
ehdr->h_proto = cpu_to_be16(ETH_P_VLAN);
*is_new = true;
break;
}
vhdr->h_tci = cpu_to_be16(vlan_tag);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(struct eth_header *VAR_0, uint16_t VAR_1,
bool *VAR_2)
{
struct vlan_header *VAR_3 = PKT_GET_VLAN_HDR(VAR_0);
switch (be16_to_cpu(VAR_0->h_proto)) {
case ETH_P_VLAN:
case ETH_P_DVLAN:
*VAR_2 = false;
break;
default:
VAR_3->h_proto = VAR_0->h_proto;
VAR_0->h_proto = cpu_to_be16(ETH_P_VLAN);
*VAR_2 = true;
break;
}
VAR_3->h_tci = cpu_to_be16(VAR_1);
}
| [
"void FUNC_0(struct eth_header *VAR_0, uint16_t VAR_1,\nbool *VAR_2)\n{",
"struct vlan_header *VAR_3 = PKT_GET_VLAN_HDR(VAR_0);",
"switch (be16_to_cpu(VAR_0->h_proto)) {",
"case ETH_P_VLAN:\ncase ETH_P_DVLAN:\n*VAR_2 = false;",
"break;",
"default:\nVAR_3->h_proto = VAR_0->h_proto;",
"VAR_0->h_proto = cpu_to_be16(ETH_P_VLAN);",
"*VAR_2 = true;",
"break;",
"}",
"VAR_3->h_tci = cpu_to_be16(VAR_1);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13,
15,
19
],
[
21
],
[
25,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
]
]
|
17,143 | static void qemu_laio_completion_cb(void *opaque)
{
struct qemu_laio_state *s = opaque;
while (1) {
struct io_event events[MAX_EVENTS];
uint64_t val;
ssize_t ret;
struct timespec ts = { 0 };
int nevents, i;
do {
ret = read(s->efd, &val, sizeof(val));
} while (ret == 1 && errno == EINTR);
if (ret == -1 && errno == EAGAIN)
break;
if (ret != 8)
break;
do {
nevents = io_getevents(s->ctx, val, MAX_EVENTS, events, &ts);
} while (nevents == -EINTR);
for (i = 0; i < nevents; i++) {
struct iocb *iocb = events[i].obj;
struct qemu_laiocb *laiocb =
container_of(iocb, struct qemu_laiocb, iocb);
laiocb->ret = io_event_ret(&events[i]);
qemu_laio_enqueue_completed(s, laiocb);
}
}
}
| false | qemu | 2be5064953540d5451480375519389f104eb7909 | static void qemu_laio_completion_cb(void *opaque)
{
struct qemu_laio_state *s = opaque;
while (1) {
struct io_event events[MAX_EVENTS];
uint64_t val;
ssize_t ret;
struct timespec ts = { 0 };
int nevents, i;
do {
ret = read(s->efd, &val, sizeof(val));
} while (ret == 1 && errno == EINTR);
if (ret == -1 && errno == EAGAIN)
break;
if (ret != 8)
break;
do {
nevents = io_getevents(s->ctx, val, MAX_EVENTS, events, &ts);
} while (nevents == -EINTR);
for (i = 0; i < nevents; i++) {
struct iocb *iocb = events[i].obj;
struct qemu_laiocb *laiocb =
container_of(iocb, struct qemu_laiocb, iocb);
laiocb->ret = io_event_ret(&events[i]);
qemu_laio_enqueue_completed(s, laiocb);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
struct qemu_laio_state *VAR_1 = VAR_0;
while (1) {
struct io_event VAR_2[MAX_EVENTS];
uint64_t val;
ssize_t ret;
struct timespec VAR_3 = { 0 };
int VAR_4, VAR_5;
do {
ret = read(VAR_1->efd, &val, sizeof(val));
} while (ret == 1 && errno == EINTR);
if (ret == -1 && errno == EAGAIN)
break;
if (ret != 8)
break;
do {
VAR_4 = io_getevents(VAR_1->ctx, val, MAX_EVENTS, VAR_2, &VAR_3);
} while (VAR_4 == -EINTR);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
struct VAR_6 *VAR_6 = VAR_2[VAR_5].obj;
struct qemu_laiocb *VAR_7 =
container_of(VAR_6, struct qemu_laiocb, VAR_6);
VAR_7->ret = io_event_ret(&VAR_2[VAR_5]);
qemu_laio_enqueue_completed(VAR_1, VAR_7);
}
}
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"struct qemu_laio_state *VAR_1 = VAR_0;",
"while (1) {",
"struct io_event VAR_2[MAX_EVENTS];",
"uint64_t val;",
"ssize_t ret;",
"struct timespec VAR_3 = { 0 };",
"int VAR_4, VAR_5;",
"do {",
"ret = read(VAR_1->efd, &val, sizeof(val));",
"} while (ret == 1 && errno == EINTR);",
"if (ret == -1 && errno == EAGAIN)\nbreak;",
"if (ret != 8)\nbreak;",
"do {",
"VAR_4 = io_getevents(VAR_1->ctx, val, MAX_EVENTS, VAR_2, &VAR_3);",
"} while (VAR_4 == -EINTR);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"struct VAR_6 *VAR_6 = VAR_2[VAR_5].obj;",
"struct qemu_laiocb *VAR_7 =\ncontainer_of(VAR_6, struct qemu_laiocb, VAR_6);",
"VAR_7->ret = io_event_ret(&VAR_2[VAR_5]);",
"qemu_laio_enqueue_completed(VAR_1, VAR_7);",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
37,
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
]
]
|
17,145 | static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| false | qemu | 621ff94d5074d88253a5818c6b9c4db718fbfc65 | static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(errp, err);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(VirtioCcwDevice *VAR_0, Error **VAR_1)
{
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(VAR_0);
DeviceState *vdev = DEVICE(&dev->vdev);
Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));
object_property_set_bool(OBJECT(vdev), true, "realized", &err);
if (err) {
error_propagate(VAR_1, err);
}
}
| [
"static void FUNC_0(VirtioCcwDevice *VAR_0, Error **VAR_1)\n{",
"VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(VAR_0);",
"DeviceState *vdev = DEVICE(&dev->vdev);",
"Error *err = NULL;",
"qdev_set_parent_bus(vdev, BUS(&VAR_0->bus));",
"object_property_set_bool(OBJECT(vdev), true, \"realized\", &err);",
"if (err) {",
"error_propagate(VAR_1, err);",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
17,146 | S390PCIBusDevice *s390_pci_find_dev_by_idx(uint32_t idx)
{
S390PCIBusDevice *pbdev;
int i;
int j = 0;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return NULL;
}
for (i = 0; i < PCI_SLOT_MAX; i++) {
pbdev = &s->pbdev[i];
if (pbdev->fh == 0) {
continue;
}
if (j == idx) {
return pbdev;
}
j++;
}
return NULL;
}
| false | qemu | e7d336959b7c01699702dcda4b54a822972d74a8 | S390PCIBusDevice *s390_pci_find_dev_by_idx(uint32_t idx)
{
S390PCIBusDevice *pbdev;
int i;
int j = 0;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return NULL;
}
for (i = 0; i < PCI_SLOT_MAX; i++) {
pbdev = &s->pbdev[i];
if (pbdev->fh == 0) {
continue;
}
if (j == idx) {
return pbdev;
}
j++;
}
return NULL;
}
| {
"code": [],
"line_no": []
} | S390PCIBusDevice *FUNC_0(uint32_t idx)
{
S390PCIBusDevice *pbdev;
int VAR_0;
int VAR_1 = 0;
S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) {
return NULL;
}
for (VAR_0 = 0; VAR_0 < PCI_SLOT_MAX; VAR_0++) {
pbdev = &s->pbdev[VAR_0];
if (pbdev->fh == 0) {
continue;
}
if (VAR_1 == idx) {
return pbdev;
}
VAR_1++;
}
return NULL;
}
| [
"S390PCIBusDevice *FUNC_0(uint32_t idx)\n{",
"S390PCIBusDevice *pbdev;",
"int VAR_0;",
"int VAR_1 = 0;",
"S390pciState *s = S390_PCI_HOST_BRIDGE(\nobject_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));",
"if (!s) {",
"return NULL;",
"}",
"for (VAR_0 = 0; VAR_0 < PCI_SLOT_MAX; VAR_0++) {",
"pbdev = &s->pbdev[VAR_0];",
"if (pbdev->fh == 0) {",
"continue;",
"}",
"if (VAR_1 == idx) {",
"return pbdev;",
"}",
"VAR_1++;",
"}",
"return NULL;",
"}"
]
| [
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
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
]
|
17,147 | hadamard_func(mmxext)
hadamard_func(sse2)
hadamard_func(ssse3)
av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
{
int cpu_flags = av_get_cpu_flags();
#if HAVE_YASM
int bit_depth = avctx->bits_per_raw_sample;
if (EXTERNAL_MMX(cpu_flags)) {
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
c->pix_sum = ff_pix_sum16_mmx;
c->pix_norm1 = ff_pix_norm1_mmx;
}
if (EXTERNAL_SSE2(cpu_flags))
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_sse2;
#endif /* HAVE_YASM */
#if HAVE_INLINE_ASM
if (cpu_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo;
if (avctx->bits_per_raw_sample <= 8 &&
(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->fdct = ff_fdct_sse2;
} else if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->fdct = ff_fdct_mmxext;
}else{
c->fdct = ff_fdct_mmx;
}
}
c->diff_bytes= diff_bytes_mmx;
c->sum_abs_dctelem= sum_abs_dctelem_mmx;
c->sse[0] = sse16_mmx;
c->sse[1] = sse8_mmx;
c->vsad[4]= vsad_intra16_mmx;
c->nsse[0] = nsse16_mmx;
c->nsse[1] = nsse8_mmx;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmx;
}
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_mmx;
}
c->add_8x8basis= add_8x8basis_mmx;
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
c->vsad[4] = vsad_intra16_mmxext;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmxext;
}
c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext;
}
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
}
#if HAVE_SSSE3_INLINE
if (cpu_flags & AV_CPU_FLAG_SSSE3) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_ssse3;
}
c->add_8x8basis= add_8x8basis_ssse3;
c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
}
#endif
if (cpu_flags & AV_CPU_FLAG_3DNOW) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_3dnow;
}
c->add_8x8basis= add_8x8basis_3dnow;
}
}
#endif /* HAVE_INLINE_ASM */
if (EXTERNAL_MMX(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->sse[0] = ff_sse16_sse2;
#if HAVE_ALIGNED_STACK
c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
#endif
}
if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;
}
}
ff_dsputil_init_pix_mmx(c, avctx);
}
| false | FFmpeg | 6369ba3c9cc74becfaad2a8882dff3dd3e7ae3c0 | hadamard_func(mmxext)
hadamard_func(sse2)
hadamard_func(ssse3)
av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
{
int cpu_flags = av_get_cpu_flags();
#if HAVE_YASM
int bit_depth = avctx->bits_per_raw_sample;
if (EXTERNAL_MMX(cpu_flags)) {
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
c->pix_sum = ff_pix_sum16_mmx;
c->pix_norm1 = ff_pix_norm1_mmx;
}
if (EXTERNAL_SSE2(cpu_flags))
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_sse2;
#endif
#if HAVE_INLINE_ASM
if (cpu_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo;
if (avctx->bits_per_raw_sample <= 8 &&
(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->fdct = ff_fdct_sse2;
} else if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->fdct = ff_fdct_mmxext;
}else{
c->fdct = ff_fdct_mmx;
}
}
c->diff_bytes= diff_bytes_mmx;
c->sum_abs_dctelem= sum_abs_dctelem_mmx;
c->sse[0] = sse16_mmx;
c->sse[1] = sse8_mmx;
c->vsad[4]= vsad_intra16_mmx;
c->nsse[0] = nsse16_mmx;
c->nsse[1] = nsse8_mmx;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmx;
}
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_mmx;
}
c->add_8x8basis= add_8x8basis_mmx;
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
c->vsad[4] = vsad_intra16_mmxext;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmxext;
}
c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext;
}
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
}
#if HAVE_SSSE3_INLINE
if (cpu_flags & AV_CPU_FLAG_SSSE3) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_ssse3;
}
c->add_8x8basis= add_8x8basis_ssse3;
c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
}
#endif
if (cpu_flags & AV_CPU_FLAG_3DNOW) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_3dnow;
}
c->add_8x8basis= add_8x8basis_3dnow;
}
}
#endif
if (EXTERNAL_MMX(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->sse[0] = ff_sse16_sse2;
#if HAVE_ALIGNED_STACK
c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
#endif
}
if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;
}
}
ff_dsputil_init_pix_mmx(c, avctx);
}
| {
"code": [],
"line_no": []
} | hadamard_func(mmxext)
hadamard_func(sse2)
hadamard_func(ssse3)
av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
{
int cpu_flags = av_get_cpu_flags();
#if HAVE_YASM
int bit_depth = avctx->bits_per_raw_sample;
if (EXTERNAL_MMX(cpu_flags)) {
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
c->pix_sum = ff_pix_sum16_mmx;
c->pix_norm1 = ff_pix_norm1_mmx;
}
if (EXTERNAL_SSE2(cpu_flags))
if (bit_depth <= 8)
c->get_pixels = ff_get_pixels_sse2;
#endif
#if HAVE_INLINE_ASM
if (cpu_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo;
if (avctx->bits_per_raw_sample <= 8 &&
(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->fdct = ff_fdct_sse2;
} else if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->fdct = ff_fdct_mmxext;
}else{
c->fdct = ff_fdct_mmx;
}
}
c->diff_bytes= diff_bytes_mmx;
c->sum_abs_dctelem= sum_abs_dctelem_mmx;
c->sse[0] = sse16_mmx;
c->sse[1] = sse8_mmx;
c->vsad[4]= vsad_intra16_mmx;
c->nsse[0] = nsse16_mmx;
c->nsse[1] = nsse8_mmx;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmx;
}
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_mmx;
}
c->add_8x8basis= add_8x8basis_mmx;
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
c->vsad[4] = vsad_intra16_mmxext;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmxext;
}
c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext;
}
if (cpu_flags & AV_CPU_FLAG_SSE2) {
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
}
#if HAVE_SSSE3_INLINE
if (cpu_flags & AV_CPU_FLAG_SSSE3) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_ssse3;
}
c->add_8x8basis= add_8x8basis_ssse3;
c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
}
#endif
if (cpu_flags & AV_CPU_FLAG_3DNOW) {
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_3dnow;
}
c->add_8x8basis= add_8x8basis_3dnow;
}
}
#endif
if (EXTERNAL_MMX(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
if (EXTERNAL_MMXEXT(cpu_flags)) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;
c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;
}
if (EXTERNAL_SSE2(cpu_flags)) {
c->sse[0] = ff_sse16_sse2;
#if HAVE_ALIGNED_STACK
c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
#endif
}
if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) {
c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;
}
}
ff_dsputil_init_pix_mmx(c, avctx);
}
| [
"hadamard_func(mmxext)\nhadamard_func(sse2)\nhadamard_func(ssse3)\nav_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)\n{",
"int cpu_flags = av_get_cpu_flags();",
"#if HAVE_YASM\nint bit_depth = avctx->bits_per_raw_sample;",
"if (EXTERNAL_MMX(cpu_flags)) {",
"if (bit_depth <= 8)\nc->get_pixels = ff_get_pixels_mmx;",
"c->diff_pixels = ff_diff_pixels_mmx;",
"c->pix_sum = ff_pix_sum16_mmx;",
"c->pix_norm1 = ff_pix_norm1_mmx;",
"}",
"if (EXTERNAL_SSE2(cpu_flags))\nif (bit_depth <= 8)\nc->get_pixels = ff_get_pixels_sse2;",
"#endif\n#if HAVE_INLINE_ASM\nif (cpu_flags & AV_CPU_FLAG_MMX) {",
"const int dct_algo = avctx->dct_algo;",
"if (avctx->bits_per_raw_sample <= 8 &&\n(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {",
"if (cpu_flags & AV_CPU_FLAG_SSE2) {",
"c->fdct = ff_fdct_sse2;",
"} else if (cpu_flags & AV_CPU_FLAG_MMXEXT) {",
"c->fdct = ff_fdct_mmxext;",
"}else{",
"c->fdct = ff_fdct_mmx;",
"}",
"}",
"c->diff_bytes= diff_bytes_mmx;",
"c->sum_abs_dctelem= sum_abs_dctelem_mmx;",
"c->sse[0] = sse16_mmx;",
"c->sse[1] = sse8_mmx;",
"c->vsad[4]= vsad_intra16_mmx;",
"c->nsse[0] = nsse16_mmx;",
"c->nsse[1] = nsse8_mmx;",
"if(!(avctx->flags & CODEC_FLAG_BITEXACT)){",
"c->vsad[0] = vsad16_mmx;",
"}",
"if(!(avctx->flags & CODEC_FLAG_BITEXACT)){",
"c->try_8x8basis= try_8x8basis_mmx;",
"}",
"c->add_8x8basis= add_8x8basis_mmx;",
"c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;",
"if (cpu_flags & AV_CPU_FLAG_MMXEXT) {",
"c->sum_abs_dctelem = sum_abs_dctelem_mmxext;",
"c->vsad[4] = vsad_intra16_mmxext;",
"if(!(avctx->flags & CODEC_FLAG_BITEXACT)){",
"c->vsad[0] = vsad16_mmxext;",
"}",
"c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext;",
"}",
"if (cpu_flags & AV_CPU_FLAG_SSE2) {",
"c->sum_abs_dctelem= sum_abs_dctelem_sse2;",
"}",
"#if HAVE_SSSE3_INLINE\nif (cpu_flags & AV_CPU_FLAG_SSSE3) {",
"if(!(avctx->flags & CODEC_FLAG_BITEXACT)){",
"c->try_8x8basis= try_8x8basis_ssse3;",
"}",
"c->add_8x8basis= add_8x8basis_ssse3;",
"c->sum_abs_dctelem= sum_abs_dctelem_ssse3;",
"}",
"#endif\nif (cpu_flags & AV_CPU_FLAG_3DNOW) {",
"if(!(avctx->flags & CODEC_FLAG_BITEXACT)){",
"c->try_8x8basis= try_8x8basis_3dnow;",
"}",
"c->add_8x8basis= add_8x8basis_3dnow;",
"}",
"}",
"#endif\nif (EXTERNAL_MMX(cpu_flags)) {",
"c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;",
"c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;",
"if (EXTERNAL_MMXEXT(cpu_flags)) {",
"c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;",
"c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;",
"}",
"if (EXTERNAL_SSE2(cpu_flags)) {",
"c->sse[0] = ff_sse16_sse2;",
"#if HAVE_ALIGNED_STACK\nc->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;",
"c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;",
"#endif\n}",
"if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) {",
"c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;",
"c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;",
"}",
"}",
"ff_dsputil_init_pix_mmx(c, avctx);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
9,
11
],
[
13
],
[
17,
19
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39,
41,
43
],
[
45,
49,
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165,
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183,
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
211,
213
],
[
215
],
[
217,
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
235
],
[
237
]
]
|
17,148 | void aio_set_fd_poll(AioContext *ctx, int fd,
IOHandler *io_poll_begin,
IOHandler *io_poll_end)
{
/* Not implemented */
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | void aio_set_fd_poll(AioContext *ctx, int fd,
IOHandler *io_poll_begin,
IOHandler *io_poll_end)
{
}
| {
"code": [],
"line_no": []
} | void FUNC_0(AioContext *VAR_0, int VAR_1,
IOHandler *VAR_2,
IOHandler *VAR_3)
{
}
| [
"void FUNC_0(AioContext *VAR_0, int VAR_1,\nIOHandler *VAR_2,\nIOHandler *VAR_3)\n{",
"}"
]
| [
0,
0
]
| [
[
1,
3,
5,
7
],
[
11
]
]
|
17,149 | static void raw_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
int ret;
assert(!(bdrv_get_flags(bs) & BDRV_O_INACTIVE));
ret = raw_handle_perm_lock(bs, RAW_PL_PREPARE, s->perm, s->shared_perm,
errp);
if (ret) {
return;
}
raw_handle_perm_lock(bs, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL);
}
| false | qemu | 22d5cd82e98b61b1dbd791fab9f4ae0f77c0ed14 | static void raw_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
int ret;
assert(!(bdrv_get_flags(bs) & BDRV_O_INACTIVE));
ret = raw_handle_perm_lock(bs, RAW_PL_PREPARE, s->perm, s->shared_perm,
errp);
if (ret) {
return;
}
raw_handle_perm_lock(bs, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{
BDRVRawState *s = VAR_0->opaque;
int VAR_2;
assert(!(bdrv_get_flags(VAR_0) & BDRV_O_INACTIVE));
VAR_2 = raw_handle_perm_lock(VAR_0, RAW_PL_PREPARE, s->perm, s->shared_perm,
VAR_1);
if (VAR_2) {
return;
}
raw_handle_perm_lock(VAR_0, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL);
}
| [
"static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{",
"BDRVRawState *s = VAR_0->opaque;",
"int VAR_2;",
"assert(!(bdrv_get_flags(VAR_0) & BDRV_O_INACTIVE));",
"VAR_2 = raw_handle_perm_lock(VAR_0, RAW_PL_PREPARE, s->perm, s->shared_perm,\nVAR_1);",
"if (VAR_2) {",
"return;",
"}",
"raw_handle_perm_lock(VAR_0, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
]
|
17,150 | static uint64_t bw_conf1_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBus *b = opaque;
return pci_data_read(b, addr, size);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint64_t bw_conf1_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBus *b = opaque;
return pci_data_read(b, addr, size);
}
| {
"code": [],
"line_no": []
} | static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,
unsigned size)
{
PCIBus *b = opaque;
return pci_data_read(b, addr, size);
}
| [
"static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{",
"PCIBus *b = opaque;",
"return pci_data_read(b, addr, size);",
"}"
]
| [
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
]
]
|
17,151 | int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int flags, BlockDriver *drv)
{
int ret;
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
char tmp_filename[PATH_MAX + 1];
BlockDriverState *file = NULL;
/* NULL means an empty set of options */
if (options == NULL) {
options = qdict_new();
}
bs->options = options;
options = qdict_clone_shallow(options);
/* For snapshot=on, create a temporary qcow2 overlay */
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
/* if snapshot, we create a temporary backing file and open it
instead of opening 'filename' directly */
/* if there is a backing file, use it */
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, NULL, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (ret < 0) {
goto fail;
}
/* Real path is meaningless for protocols */
if (is_protocol) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
} else if (!realpath(filename, backing_filename)) {
ret = -errno;
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
free_option_parameters(options);
if (ret < 0) {
goto fail;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
/* Open image file without format layer */
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
ret = bdrv_file_open(&file, filename, bdrv_open_flags(bs, flags));
if (ret < 0) {
goto fail;
}
/* Find the right image format driver */
if (!drv) {
ret = find_image_format(file, filename, &drv);
}
if (!drv) {
goto unlink_and_fail;
}
/* Open the image */
ret = bdrv_open_common(bs, file, filename, options, flags, drv);
if (ret < 0) {
goto unlink_and_fail;
}
if (bs->file != file) {
bdrv_delete(file);
file = NULL;
}
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0) {
ret = bdrv_open_backing_file(bs);
if (ret < 0) {
goto close_and_fail;
}
}
/* Check if any unknown options were used */
if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by "
"device '%s' doesn't support the option '%s'",
drv->format_name, bs->device_name, entry->key);
ret = -EINVAL;
goto close_and_fail;
}
QDECREF(options);
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
/* throttling disk I/O limits */
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_delete(file);
}
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
return ret;
close_and_fail:
bdrv_close(bs);
QDECREF(options);
return ret;
}
| false | qemu | 4d70655bcb852ea0a006d3923f0b0a9c69ff462e | int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
int flags, BlockDriver *drv)
{
int ret;
char tmp_filename[PATH_MAX + 1];
BlockDriverState *file = NULL;
if (options == NULL) {
options = qdict_new();
}
bs->options = options;
options = qdict_clone_shallow(options);
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
bs1 = bdrv_new("");
ret = bdrv_open(bs1, filename, NULL, 0, drv);
if (ret < 0) {
bdrv_delete(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->drv && bs1->drv->protocol_name)
is_protocol = 1;
bdrv_delete(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
if (ret < 0) {
goto fail;
}
if (is_protocol) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
} else if (!realpath(filename, backing_filename)) {
ret = -errno;
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size);
set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
if (drv) {
set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
drv->format_name);
}
ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
free_option_parameters(options);
if (ret < 0) {
goto fail;
}
filename = tmp_filename;
drv = bdrv_qcow2;
bs->is_temporary = 1;
}
if (flags & BDRV_O_RDWR) {
flags |= BDRV_O_ALLOW_RDWR;
}
ret = bdrv_file_open(&file, filename, bdrv_open_flags(bs, flags));
if (ret < 0) {
goto fail;
}
if (!drv) {
ret = find_image_format(file, filename, &drv);
}
if (!drv) {
goto unlink_and_fail;
}
ret = bdrv_open_common(bs, file, filename, options, flags, drv);
if (ret < 0) {
goto unlink_and_fail;
}
if (bs->file != file) {
bdrv_delete(file);
file = NULL;
}
if ((flags & BDRV_O_NO_BACKING) == 0) {
ret = bdrv_open_backing_file(bs);
if (ret < 0) {
goto close_and_fail;
}
}
if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by "
"device '%s' doesn't support the option '%s'",
drv->format_name, bs->device_name, entry->key);
ret = -EINVAL;
goto close_and_fail;
}
QDECREF(options);
if (!bdrv_key_required(bs)) {
bdrv_dev_change_media_cb(bs, true);
}
if (bs->io_limits_enabled) {
bdrv_io_limits_enable(bs);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_delete(file);
}
if (bs->is_temporary) {
unlink(filename);
}
fail:
QDECREF(bs->options);
QDECREF(options);
bs->options = NULL;
return ret;
close_and_fail:
bdrv_close(bs);
QDECREF(options);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, QDict *VAR_2,
int VAR_3, BlockDriver *VAR_4)
{
int VAR_5;
char VAR_6[PATH_MAX + 1];
BlockDriverState *file = NULL;
if (VAR_2 == NULL) {
VAR_2 = qdict_new();
}
VAR_0->VAR_2 = VAR_2;
VAR_2 = qdict_clone_shallow(VAR_2);
if (VAR_3 & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
int VAR_7 = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *VAR_2;
char VAR_8[PATH_MAX];
bs1 = bdrv_new("");
VAR_5 = FUNC_0(bs1, VAR_1, NULL, 0, VAR_4);
if (VAR_5 < 0) {
bdrv_delete(bs1);
goto fail;
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
if (bs1->VAR_4 && bs1->VAR_4->protocol_name)
VAR_7 = 1;
bdrv_delete(bs1);
VAR_5 = get_tmp_filename(VAR_6, sizeof(VAR_6));
if (VAR_5 < 0) {
goto fail;
}
if (VAR_7) {
snprintf(VAR_8, sizeof(VAR_8),
"%s", VAR_1);
} else if (!realpath(VAR_1, VAR_8)) {
VAR_5 = -errno;
goto fail;
}
bdrv_qcow2 = bdrv_find_format("qcow2");
VAR_2 = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
set_option_parameter_int(VAR_2, BLOCK_OPT_SIZE, total_size);
set_option_parameter(VAR_2, BLOCK_OPT_BACKING_FILE, VAR_8);
if (VAR_4) {
set_option_parameter(VAR_2, BLOCK_OPT_BACKING_FMT,
VAR_4->format_name);
}
VAR_5 = bdrv_create(bdrv_qcow2, VAR_6, VAR_2);
free_option_parameters(VAR_2);
if (VAR_5 < 0) {
goto fail;
}
VAR_1 = VAR_6;
VAR_4 = bdrv_qcow2;
VAR_0->is_temporary = 1;
}
if (VAR_3 & BDRV_O_RDWR) {
VAR_3 |= BDRV_O_ALLOW_RDWR;
}
VAR_5 = bdrv_file_open(&file, VAR_1, bdrv_open_flags(VAR_0, VAR_3));
if (VAR_5 < 0) {
goto fail;
}
if (!VAR_4) {
VAR_5 = find_image_format(file, VAR_1, &VAR_4);
}
if (!VAR_4) {
goto unlink_and_fail;
}
VAR_5 = bdrv_open_common(VAR_0, file, VAR_1, VAR_2, VAR_3, VAR_4);
if (VAR_5 < 0) {
goto unlink_and_fail;
}
if (VAR_0->file != file) {
bdrv_delete(file);
file = NULL;
}
if ((VAR_3 & BDRV_O_NO_BACKING) == 0) {
VAR_5 = bdrv_open_backing_file(VAR_0);
if (VAR_5 < 0) {
goto close_and_fail;
}
}
if (qdict_size(VAR_2) != 0) {
const QDictEntry *VAR_9 = qdict_first(VAR_2);
qerror_report(ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by "
"device '%s' doesn't support the option '%s'",
VAR_4->format_name, VAR_0->device_name, VAR_9->key);
VAR_5 = -EINVAL;
goto close_and_fail;
}
QDECREF(VAR_2);
if (!bdrv_key_required(VAR_0)) {
bdrv_dev_change_media_cb(VAR_0, true);
}
if (VAR_0->io_limits_enabled) {
bdrv_io_limits_enable(VAR_0);
}
return 0;
unlink_and_fail:
if (file != NULL) {
bdrv_delete(file);
}
if (VAR_0->is_temporary) {
unlink(VAR_1);
}
fail:
QDECREF(VAR_0->VAR_2);
QDECREF(VAR_2);
VAR_0->VAR_2 = NULL;
return VAR_5;
close_and_fail:
bdrv_close(VAR_0);
QDECREF(VAR_2);
return VAR_5;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, QDict *VAR_2,\nint VAR_3, BlockDriver *VAR_4)\n{",
"int VAR_5;",
"char VAR_6[PATH_MAX + 1];",
"BlockDriverState *file = NULL;",
"if (VAR_2 == NULL) {",
"VAR_2 = qdict_new();",
"}",
"VAR_0->VAR_2 = VAR_2;",
"VAR_2 = qdict_clone_shallow(VAR_2);",
"if (VAR_3 & BDRV_O_SNAPSHOT) {",
"BlockDriverState *bs1;",
"int64_t total_size;",
"int VAR_7 = 0;",
"BlockDriver *bdrv_qcow2;",
"QEMUOptionParameter *VAR_2;",
"char VAR_8[PATH_MAX];",
"bs1 = bdrv_new(\"\");",
"VAR_5 = FUNC_0(bs1, VAR_1, NULL, 0, VAR_4);",
"if (VAR_5 < 0) {",
"bdrv_delete(bs1);",
"goto fail;",
"}",
"total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;",
"if (bs1->VAR_4 && bs1->VAR_4->protocol_name)\nVAR_7 = 1;",
"bdrv_delete(bs1);",
"VAR_5 = get_tmp_filename(VAR_6, sizeof(VAR_6));",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"if (VAR_7) {",
"snprintf(VAR_8, sizeof(VAR_8),\n\"%s\", VAR_1);",
"} else if (!realpath(VAR_1, VAR_8)) {",
"VAR_5 = -errno;",
"goto fail;",
"}",
"bdrv_qcow2 = bdrv_find_format(\"qcow2\");",
"VAR_2 = parse_option_parameters(\"\", bdrv_qcow2->create_options, NULL);",
"set_option_parameter_int(VAR_2, BLOCK_OPT_SIZE, total_size);",
"set_option_parameter(VAR_2, BLOCK_OPT_BACKING_FILE, VAR_8);",
"if (VAR_4) {",
"set_option_parameter(VAR_2, BLOCK_OPT_BACKING_FMT,\nVAR_4->format_name);",
"}",
"VAR_5 = bdrv_create(bdrv_qcow2, VAR_6, VAR_2);",
"free_option_parameters(VAR_2);",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"VAR_1 = VAR_6;",
"VAR_4 = bdrv_qcow2;",
"VAR_0->is_temporary = 1;",
"}",
"if (VAR_3 & BDRV_O_RDWR) {",
"VAR_3 |= BDRV_O_ALLOW_RDWR;",
"}",
"VAR_5 = bdrv_file_open(&file, VAR_1, bdrv_open_flags(VAR_0, VAR_3));",
"if (VAR_5 < 0) {",
"goto fail;",
"}",
"if (!VAR_4) {",
"VAR_5 = find_image_format(file, VAR_1, &VAR_4);",
"}",
"if (!VAR_4) {",
"goto unlink_and_fail;",
"}",
"VAR_5 = bdrv_open_common(VAR_0, file, VAR_1, VAR_2, VAR_3, VAR_4);",
"if (VAR_5 < 0) {",
"goto unlink_and_fail;",
"}",
"if (VAR_0->file != file) {",
"bdrv_delete(file);",
"file = NULL;",
"}",
"if ((VAR_3 & BDRV_O_NO_BACKING) == 0) {",
"VAR_5 = bdrv_open_backing_file(VAR_0);",
"if (VAR_5 < 0) {",
"goto close_and_fail;",
"}",
"}",
"if (qdict_size(VAR_2) != 0) {",
"const QDictEntry *VAR_9 = qdict_first(VAR_2);",
"qerror_report(ERROR_CLASS_GENERIC_ERROR, \"Block format '%s' used by \"\n\"device '%s' doesn't support the option '%s'\",\nVAR_4->format_name, VAR_0->device_name, VAR_9->key);",
"VAR_5 = -EINVAL;",
"goto close_and_fail;",
"}",
"QDECREF(VAR_2);",
"if (!bdrv_key_required(VAR_0)) {",
"bdrv_dev_change_media_cb(VAR_0, true);",
"}",
"if (VAR_0->io_limits_enabled) {",
"bdrv_io_limits_enable(VAR_0);",
"}",
"return 0;",
"unlink_and_fail:\nif (file != NULL) {",
"bdrv_delete(file);",
"}",
"if (VAR_0->is_temporary) {",
"unlink(VAR_1);",
"}",
"fail:\nQDECREF(VAR_0->VAR_2);",
"QDECREF(VAR_2);",
"VAR_0->VAR_2 = NULL;",
"return VAR_5;",
"close_and_fail:\nbdrv_close(VAR_0);",
"QDECREF(VAR_2);",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149
],
[
151
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
195
],
[
197
],
[
199
],
[
201
],
[
205
],
[
207
],
[
209
],
[
211
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
233
],
[
235
],
[
237,
239,
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
255
],
[
257
],
[
259
],
[
265
],
[
267
],
[
269
],
[
273
],
[
277,
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
303,
305
],
[
307
],
[
309
],
[
311
]
]
|
17,153 | static uint32_t omap_sysctl_read(void *opaque, target_phys_addr_t addr)
{
struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
switch (addr) {
case 0x000: /* CONTROL_REVISION */
return 0x20;
case 0x010: /* CONTROL_SYSCONFIG */
return s->sysconfig;
case 0x030 ... 0x140: /* CONTROL_PADCONF - only used in the POP */
return s->padconf[(addr - 0x30) >> 2];
case 0x270: /* CONTROL_DEBOBS */
return s->obs;
case 0x274: /* CONTROL_DEVCONF */
return s->devconfig;
case 0x28c: /* CONTROL_EMU_SUPPORT */
return 0;
case 0x290: /* CONTROL_MSUSPENDMUX_0 */
return s->msuspendmux[0];
case 0x294: /* CONTROL_MSUSPENDMUX_1 */
return s->msuspendmux[1];
case 0x298: /* CONTROL_MSUSPENDMUX_2 */
return s->msuspendmux[2];
case 0x29c: /* CONTROL_MSUSPENDMUX_3 */
return s->msuspendmux[3];
case 0x2a0: /* CONTROL_MSUSPENDMUX_4 */
return s->msuspendmux[4];
case 0x2a4: /* CONTROL_MSUSPENDMUX_5 */
return 0;
case 0x2b8: /* CONTROL_PSA_CTRL */
return s->psaconfig;
case 0x2bc: /* CONTROL_PSA_CMD */
case 0x2c0: /* CONTROL_PSA_VALUE */
return 0;
case 0x2b0: /* CONTROL_SEC_CTRL */
return 0x800000f1;
case 0x2d0: /* CONTROL_SEC_EMU */
return 0x80000015;
case 0x2d4: /* CONTROL_SEC_TAP */
return 0x8000007f;
case 0x2b4: /* CONTROL_SEC_TEST */
case 0x2f0: /* CONTROL_SEC_STATUS */
case 0x2f4: /* CONTROL_SEC_ERR_STATUS */
/* Secure mode is not present on general-pusrpose device. Outside
* secure mode these values cannot be read or written. */
return 0;
case 0x2d8: /* CONTROL_OCM_RAM_PERM */
return 0xff;
case 0x2dc: /* CONTROL_OCM_PUB_RAM_ADD */
case 0x2e0: /* CONTROL_EXT_SEC_RAM_START_ADD */
case 0x2e4: /* CONTROL_EXT_SEC_RAM_STOP_ADD */
/* No secure mode so no Extended Secure RAM present. */
return 0;
case 0x2f8: /* CONTROL_STATUS */
/* Device Type => General-purpose */
return 0x0300;
case 0x2fc: /* CONTROL_GENERAL_PURPOSE_STATUS */
case 0x300: /* CONTROL_RPUB_KEY_H_0 */
case 0x304: /* CONTROL_RPUB_KEY_H_1 */
case 0x308: /* CONTROL_RPUB_KEY_H_2 */
case 0x30c: /* CONTROL_RPUB_KEY_H_3 */
return 0xdecafbad;
case 0x310: /* CONTROL_RAND_KEY_0 */
case 0x314: /* CONTROL_RAND_KEY_1 */
case 0x318: /* CONTROL_RAND_KEY_2 */
case 0x31c: /* CONTROL_RAND_KEY_3 */
case 0x320: /* CONTROL_CUST_KEY_0 */
case 0x324: /* CONTROL_CUST_KEY_1 */
case 0x330: /* CONTROL_TEST_KEY_0 */
case 0x334: /* CONTROL_TEST_KEY_1 */
case 0x338: /* CONTROL_TEST_KEY_2 */
case 0x33c: /* CONTROL_TEST_KEY_3 */
case 0x340: /* CONTROL_TEST_KEY_4 */
case 0x344: /* CONTROL_TEST_KEY_5 */
case 0x348: /* CONTROL_TEST_KEY_6 */
case 0x34c: /* CONTROL_TEST_KEY_7 */
case 0x350: /* CONTROL_TEST_KEY_8 */
case 0x354: /* CONTROL_TEST_KEY_9 */
/* Can only be accessed in secure mode and when C_FieldAccEnable
* bit is set in CONTROL_SEC_CTRL.
* TODO: otherwise an interconnect access error is generated. */
return 0;
}
OMAP_BAD_REG(addr);
return 0;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static uint32_t omap_sysctl_read(void *opaque, target_phys_addr_t addr)
{
struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
switch (addr) {
case 0x000:
return 0x20;
case 0x010:
return s->sysconfig;
case 0x030 ... 0x140:
return s->padconf[(addr - 0x30) >> 2];
case 0x270:
return s->obs;
case 0x274:
return s->devconfig;
case 0x28c:
return 0;
case 0x290:
return s->msuspendmux[0];
case 0x294:
return s->msuspendmux[1];
case 0x298:
return s->msuspendmux[2];
case 0x29c:
return s->msuspendmux[3];
case 0x2a0:
return s->msuspendmux[4];
case 0x2a4:
return 0;
case 0x2b8:
return s->psaconfig;
case 0x2bc:
case 0x2c0:
return 0;
case 0x2b0:
return 0x800000f1;
case 0x2d0:
return 0x80000015;
case 0x2d4:
return 0x8000007f;
case 0x2b4:
case 0x2f0:
case 0x2f4:
return 0;
case 0x2d8:
return 0xff;
case 0x2dc:
case 0x2e0:
case 0x2e4:
return 0;
case 0x2f8:
return 0x0300;
case 0x2fc:
case 0x300:
case 0x304:
case 0x308:
case 0x30c:
return 0xdecafbad;
case 0x310:
case 0x314:
case 0x318:
case 0x31c:
case 0x320:
case 0x324:
case 0x330:
case 0x334:
case 0x338:
case 0x33c:
case 0x340:
case 0x344:
case 0x348:
case 0x34c:
case 0x350:
case 0x354:
return 0;
}
OMAP_BAD_REG(addr);
return 0;
}
| {
"code": [],
"line_no": []
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
struct omap_sysctl_s *VAR_0 = (struct omap_sysctl_s *) opaque;
switch (addr) {
case 0x000:
return 0x20;
case 0x010:
return VAR_0->sysconfig;
case 0x030 ... 0x140:
return VAR_0->padconf[(addr - 0x30) >> 2];
case 0x270:
return VAR_0->obs;
case 0x274:
return VAR_0->devconfig;
case 0x28c:
return 0;
case 0x290:
return VAR_0->msuspendmux[0];
case 0x294:
return VAR_0->msuspendmux[1];
case 0x298:
return VAR_0->msuspendmux[2];
case 0x29c:
return VAR_0->msuspendmux[3];
case 0x2a0:
return VAR_0->msuspendmux[4];
case 0x2a4:
return 0;
case 0x2b8:
return VAR_0->psaconfig;
case 0x2bc:
case 0x2c0:
return 0;
case 0x2b0:
return 0x800000f1;
case 0x2d0:
return 0x80000015;
case 0x2d4:
return 0x8000007f;
case 0x2b4:
case 0x2f0:
case 0x2f4:
return 0;
case 0x2d8:
return 0xff;
case 0x2dc:
case 0x2e0:
case 0x2e4:
return 0;
case 0x2f8:
return 0x0300;
case 0x2fc:
case 0x300:
case 0x304:
case 0x308:
case 0x30c:
return 0xdecafbad;
case 0x310:
case 0x314:
case 0x318:
case 0x31c:
case 0x320:
case 0x324:
case 0x330:
case 0x334:
case 0x338:
case 0x33c:
case 0x340:
case 0x344:
case 0x348:
case 0x34c:
case 0x350:
case 0x354:
return 0;
}
OMAP_BAD_REG(addr);
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"struct omap_sysctl_s *VAR_0 = (struct omap_sysctl_s *) opaque;",
"switch (addr) {",
"case 0x000:\nreturn 0x20;",
"case 0x010:\nreturn VAR_0->sysconfig;",
"case 0x030 ... 0x140:\nreturn VAR_0->padconf[(addr - 0x30) >> 2];",
"case 0x270:\nreturn VAR_0->obs;",
"case 0x274:\nreturn VAR_0->devconfig;",
"case 0x28c:\nreturn 0;",
"case 0x290:\nreturn VAR_0->msuspendmux[0];",
"case 0x294:\nreturn VAR_0->msuspendmux[1];",
"case 0x298:\nreturn VAR_0->msuspendmux[2];",
"case 0x29c:\nreturn VAR_0->msuspendmux[3];",
"case 0x2a0:\nreturn VAR_0->msuspendmux[4];",
"case 0x2a4:\nreturn 0;",
"case 0x2b8:\nreturn VAR_0->psaconfig;",
"case 0x2bc:\ncase 0x2c0:\nreturn 0;",
"case 0x2b0:\nreturn 0x800000f1;",
"case 0x2d0:\nreturn 0x80000015;",
"case 0x2d4:\nreturn 0x8000007f;",
"case 0x2b4:\ncase 0x2f0:\ncase 0x2f4:\nreturn 0;",
"case 0x2d8:\nreturn 0xff;",
"case 0x2dc:\ncase 0x2e0:\ncase 0x2e4:\nreturn 0;",
"case 0x2f8:\nreturn 0x0300;",
"case 0x2fc:\ncase 0x300:\ncase 0x304:\ncase 0x308:\ncase 0x30c:\nreturn 0xdecafbad;",
"case 0x310:\ncase 0x314:\ncase 0x318:\ncase 0x31c:\ncase 0x320:\ncase 0x324:\ncase 0x330:\ncase 0x334:\ncase 0x338:\ncase 0x33c:\ncase 0x340:\ncase 0x344:\ncase 0x348:\ncase 0x34c:\ncase 0x350:\ncase 0x354:\nreturn 0;",
"}",
"OMAP_BAD_REG(addr);",
"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
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
17,
19
],
[
23,
25
],
[
29,
31
],
[
35,
37
],
[
41,
43
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59,
61
],
[
63,
65
],
[
67,
69
],
[
73,
75
],
[
77,
79,
81
],
[
85,
87
],
[
89,
91
],
[
93,
95
],
[
97,
99,
101,
107
],
[
111,
113
],
[
115,
117,
119,
123
],
[
127,
131
],
[
133,
137,
139,
141,
143,
145
],
[
149,
151,
153,
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
187
],
[
189
],
[
193
],
[
195
],
[
197
]
]
|
17,154 | static void gen_dmtc0 (DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mtc0_index();
rn = "Index";
break;
case 1:
// gen_op_dmtc0_mvpcontrol(); /* MT ASE */
rn = "MVPControl";
// break;
case 2:
// gen_op_dmtc0_mvpconf0(); /* MT ASE */
rn = "MVPConf0";
// break;
case 3:
// gen_op_dmtc0_mvpconf1(); /* MT ASE */
rn = "MVPConf1";
// break;
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
/* ignored */
rn = "Random";
break;
case 1:
// gen_op_dmtc0_vpecontrol(); /* MT ASE */
rn = "VPEControl";
// break;
case 2:
// gen_op_dmtc0_vpeconf0(); /* MT ASE */
rn = "VPEConf0";
// break;
case 3:
// gen_op_dmtc0_vpeconf1(); /* MT ASE */
rn = "VPEConf1";
// break;
case 4:
// gen_op_dmtc0_YQMask(); /* MT ASE */
rn = "YQMask";
// break;
case 5:
// gen_op_dmtc0_vpeschedule(); /* MT ASE */
rn = "VPESchedule";
// break;
case 6:
// gen_op_dmtc0_vpeschefback(); /* MT ASE */
rn = "VPEScheFBack";
// break;
case 7:
// gen_op_dmtc0_vpeopt(); /* MT ASE */
rn = "VPEOpt";
// break;
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmtc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
// gen_op_dmtc0_tcstatus(); /* MT ASE */
rn = "TCStatus";
// break;
case 2:
// gen_op_dmtc0_tcbind(); /* MT ASE */
rn = "TCBind";
// break;
case 3:
// gen_op_dmtc0_tcrestart(); /* MT ASE */
rn = "TCRestart";
// break;
case 4:
// gen_op_dmtc0_tchalt(); /* MT ASE */
rn = "TCHalt";
// break;
case 5:
// gen_op_dmtc0_tccontext(); /* MT ASE */
rn = "TCContext";
// break;
case 6:
// gen_op_dmtc0_tcschedule(); /* MT ASE */
rn = "TCSchedule";
// break;
case 7:
// gen_op_dmtc0_tcschefback(); /* MT ASE */
rn = "TCScheFBack";
// break;
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmtc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmtc0_context();
rn = "Context";
break;
case 1:
// gen_op_dmtc0_contextconfig(); /* SmartMIPS ASE */
rn = "ContextConfig";
// break;
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mtc0_pagemask();
rn = "PageMask";
break;
case 1:
gen_op_mtc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mtc0_wired();
rn = "Wired";
break;
case 1:
// gen_op_dmtc0_srsconf0(); /* shadow registers */
rn = "SRSConf0";
// break;
case 2:
// gen_op_dmtc0_srsconf1(); /* shadow registers */
rn = "SRSConf1";
// break;
case 3:
// gen_op_dmtc0_srsconf2(); /* shadow registers */
rn = "SRSConf2";
// break;
case 4:
// gen_op_dmtc0_srsconf3(); /* shadow registers */
rn = "SRSConf3";
// break;
case 5:
// gen_op_dmtc0_srsconf4(); /* shadow registers */
rn = "SRSConf4";
// break;
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
gen_op_mtc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
/* ignored */
rn = "BadVaddr";
break;
case 9:
switch (sel) {
case 0:
gen_op_mtc0_count();
rn = "Count";
break;
/* 6,7 are implementation dependent */
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 10:
switch (sel) {
case 0:
gen_op_mtc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mtc0_compare();
rn = "Compare";
break;
/* 6,7 are implementation dependent */
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 12:
switch (sel) {
case 0:
gen_op_mtc0_status();
rn = "Status";
break;
case 1:
gen_op_mtc0_intctl();
rn = "IntCtl";
break;
case 2:
gen_op_mtc0_srsctl();
rn = "SRSCtl";
break;
case 3:
gen_op_mtc0_srsmap(); /* shadow registers */
rn = "SRSMap";
break;
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 13:
switch (sel) {
case 0:
gen_op_mtc0_cause();
rn = "Cause";
break;
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 14:
switch (sel) {
case 0:
gen_op_dmtc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
/* ignored */
rn = "PRid";
break;
case 1:
gen_op_dmtc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mtc0_config0();
rn = "Config";
break;
case 1:
/* ignored */
rn = "Config1";
break;
case 2:
gen_op_mtc0_config2();
rn = "Config2";
break;
case 3:
/* ignored */
rn = "Config3";
break;
/* 6,7 are implementation dependent */
default:
rn = "Invalid config selector";
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 17:
switch (sel) {
case 0:
/* ignored */
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0:
gen_op_dmtc0_watchlo0();
rn = "WatchLo";
break;
case 1:
// gen_op_dmtc0_watchlo1();
rn = "WatchLo1";
// break;
case 2:
// gen_op_dmtc0_watchlo2();
rn = "WatchLo2";
// break;
case 3:
// gen_op_dmtc0_watchlo3();
rn = "WatchLo3";
// break;
case 4:
// gen_op_dmtc0_watchlo4();
rn = "WatchLo4";
// break;
case 5:
// gen_op_dmtc0_watchlo5();
rn = "WatchLo5";
// break;
case 6:
// gen_op_dmtc0_watchlo6();
rn = "WatchLo6";
// break;
case 7:
// gen_op_dmtc0_watchlo7();
rn = "WatchLo7";
// break;
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0:
gen_op_mtc0_watchhi0();
rn = "WatchHi";
break;
case 1:
// gen_op_dmtc0_watchhi1();
rn = "WatchHi1";
// break;
case 2:
// gen_op_dmtc0_watchhi2();
rn = "WatchHi2";
// break;
case 3:
// gen_op_dmtc0_watchhi3();
rn = "WatchHi3";
// break;
case 4:
// gen_op_dmtc0_watchhi4();
rn = "WatchHi4";
// break;
case 5:
// gen_op_dmtc0_watchhi5();
rn = "WatchHi5";
// break;
case 6:
// gen_op_dmtc0_watchhi6();
rn = "WatchHi6";
// break;
case 7:
// gen_op_dmtc0_watchhi7();
rn = "WatchHi7";
// break;
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
/* 64 bit MMU only */
gen_op_dmtc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
/* Officially reserved, but sel 0 is used for R1x000 framemask */
switch (sel) {
case 0:
gen_op_mtc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
/* ignored */
rn = "Diagnostic"; /* implementation dependent */
break;
case 23:
switch (sel) {
case 0:
gen_op_mtc0_debug(); /* EJTAG support */
rn = "Debug";
break;
case 1:
// gen_op_dmtc0_tracecontrol(); /* PDtrace support */
rn = "TraceControl";
// break;
case 2:
// gen_op_dmtc0_tracecontrol2(); /* PDtrace support */
rn = "TraceControl2";
// break;
case 3:
// gen_op_dmtc0_usertracedata(); /* PDtrace support */
rn = "UserTraceData";
// break;
case 4:
// gen_op_dmtc0_debug(); /* PDtrace support */
rn = "TraceBPC";
// break;
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
case 24:
switch (sel) {
case 0:
gen_op_dmtc0_depc(); /* EJTAG support */
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mtc0_performance0();
rn = "Performance0";
break;
case 1:
// gen_op_dmtc0_performance1();
rn = "Performance1";
// break;
case 2:
// gen_op_dmtc0_performance2();
rn = "Performance2";
// break;
case 3:
// gen_op_dmtc0_performance3();
rn = "Performance3";
// break;
case 4:
// gen_op_dmtc0_performance4();
rn = "Performance4";
// break;
case 5:
// gen_op_dmtc0_performance5();
rn = "Performance5";
// break;
case 6:
// gen_op_dmtc0_performance6();
rn = "Performance6";
// break;
case 7:
// gen_op_dmtc0_performance7();
rn = "Performance7";
// break;
default:
goto die;
}
break;
case 26:
/* ignored */
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
/* ignored */
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datahi();
rn = "DataHi";
break;
default:
rn = "invalid sel";
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmtc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mtc0_desave(); /* EJTAG support */
rn = "DESAVE";
break;
default:
goto die;
}
/* Stop translation as we may have switched the execution mode */
ctx->bstate = BS_STOP;
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| false | qemu | b29a0341d7ed7e7df4bf77a41db8e614f1ddb645 | static void gen_dmtc0 (DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mtc0_index();
rn = "Index";
break;
case 1:
rn = "MVPControl";
case 2:
rn = "MVPConf0";
case 3:
rn = "MVPConf1";
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
rn = "Random";
break;
case 1:
rn = "VPEControl";
case 2:
rn = "VPEConf0";
case 3:
rn = "VPEConf1";
case 4:
rn = "YQMask";
case 5:
rn = "VPESchedule";
case 6:
rn = "VPEScheFBack";
case 7:
rn = "VPEOpt";
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmtc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
rn = "TCStatus";
case 2:
rn = "TCBind";
case 3:
rn = "TCRestart";
case 4:
rn = "TCHalt";
case 5:
rn = "TCContext";
case 6:
rn = "TCSchedule";
case 7:
rn = "TCScheFBack";
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmtc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmtc0_context();
rn = "Context";
break;
case 1:
rn = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mtc0_pagemask();
rn = "PageMask";
break;
case 1:
gen_op_mtc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mtc0_wired();
rn = "Wired";
break;
case 1:
rn = "SRSConf0";
case 2:
rn = "SRSConf1";
case 3:
rn = "SRSConf2";
case 4:
rn = "SRSConf3";
case 5:
rn = "SRSConf4";
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
gen_op_mtc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
rn = "BadVaddr";
break;
case 9:
switch (sel) {
case 0:
gen_op_mtc0_count();
rn = "Count";
break;
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
case 10:
switch (sel) {
case 0:
gen_op_mtc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mtc0_compare();
rn = "Compare";
break;
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
case 12:
switch (sel) {
case 0:
gen_op_mtc0_status();
rn = "Status";
break;
case 1:
gen_op_mtc0_intctl();
rn = "IntCtl";
break;
case 2:
gen_op_mtc0_srsctl();
rn = "SRSCtl";
break;
case 3:
gen_op_mtc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
case 13:
switch (sel) {
case 0:
gen_op_mtc0_cause();
rn = "Cause";
break;
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
case 14:
switch (sel) {
case 0:
gen_op_dmtc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
rn = "PRid";
break;
case 1:
gen_op_dmtc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mtc0_config0();
rn = "Config";
break;
case 1:
rn = "Config1";
break;
case 2:
gen_op_mtc0_config2();
rn = "Config2";
break;
case 3:
rn = "Config3";
break;
default:
rn = "Invalid config selector";
goto die;
}
ctx->bstate = BS_STOP;
break;
case 17:
switch (sel) {
case 0:
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0:
gen_op_dmtc0_watchlo0();
rn = "WatchLo";
break;
case 1:
rn = "WatchLo1";
case 2:
rn = "WatchLo2";
case 3:
rn = "WatchLo3";
case 4:
rn = "WatchLo4";
case 5:
rn = "WatchLo5";
case 6:
rn = "WatchLo6";
case 7:
rn = "WatchLo7";
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0:
gen_op_mtc0_watchhi0();
rn = "WatchHi";
break;
case 1:
rn = "WatchHi1";
case 2:
rn = "WatchHi2";
case 3:
rn = "WatchHi3";
case 4:
rn = "WatchHi4";
case 5:
rn = "WatchHi5";
case 6:
rn = "WatchHi6";
case 7:
rn = "WatchHi7";
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
gen_op_dmtc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (sel) {
case 0:
gen_op_mtc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
rn = "Diagnostic";
break;
case 23:
switch (sel) {
case 0:
gen_op_mtc0_debug();
rn = "Debug";
break;
case 1:
rn = "TraceControl";
case 2:
rn = "TraceControl2";
case 3:
rn = "UserTraceData";
case 4:
rn = "TraceBPC";
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
case 24:
switch (sel) {
case 0:
gen_op_dmtc0_depc();
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mtc0_performance0();
rn = "Performance0";
break;
case 1:
rn = "Performance1";
case 2:
rn = "Performance2";
case 3:
rn = "Performance3";
case 4:
rn = "Performance4";
case 5:
rn = "Performance5";
case 6:
rn = "Performance6";
case 7:
rn = "Performance7";
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datahi();
rn = "DataHi";
break;
default:
rn = "invalid sel";
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmtc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mtc0_desave();
rn = "DESAVE";
break;
default:
goto die;
}
ctx->bstate = BS_STOP;
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (DisasContext *VAR_0, int VAR_1, int VAR_2)
{
const char *VAR_3 = "invalid";
switch (VAR_1) {
case 0:
switch (VAR_2) {
case 0:
gen_op_mtc0_index();
VAR_3 = "Index";
break;
case 1:
VAR_3 = "MVPControl";
case 2:
VAR_3 = "MVPConf0";
case 3:
VAR_3 = "MVPConf1";
default:
goto die;
}
break;
case 1:
switch (VAR_2) {
case 0:
VAR_3 = "Random";
break;
case 1:
VAR_3 = "VPEControl";
case 2:
VAR_3 = "VPEConf0";
case 3:
VAR_3 = "VPEConf1";
case 4:
VAR_3 = "YQMask";
case 5:
VAR_3 = "VPESchedule";
case 6:
VAR_3 = "VPEScheFBack";
case 7:
VAR_3 = "VPEOpt";
default:
goto die;
}
break;
case 2:
switch (VAR_2) {
case 0:
gen_op_dmtc0_entrylo0();
VAR_3 = "EntryLo0";
break;
case 1:
VAR_3 = "TCStatus";
case 2:
VAR_3 = "TCBind";
case 3:
VAR_3 = "TCRestart";
case 4:
VAR_3 = "TCHalt";
case 5:
VAR_3 = "TCContext";
case 6:
VAR_3 = "TCSchedule";
case 7:
VAR_3 = "TCScheFBack";
default:
goto die;
}
break;
case 3:
switch (VAR_2) {
case 0:
gen_op_dmtc0_entrylo1();
VAR_3 = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (VAR_2) {
case 0:
gen_op_dmtc0_context();
VAR_3 = "Context";
break;
case 1:
VAR_3 = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (VAR_2) {
case 0:
gen_op_mtc0_pagemask();
VAR_3 = "PageMask";
break;
case 1:
gen_op_mtc0_pagegrain();
VAR_3 = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (VAR_2) {
case 0:
gen_op_mtc0_wired();
VAR_3 = "Wired";
break;
case 1:
VAR_3 = "SRSConf0";
case 2:
VAR_3 = "SRSConf1";
case 3:
VAR_3 = "SRSConf2";
case 4:
VAR_3 = "SRSConf3";
case 5:
VAR_3 = "SRSConf4";
default:
goto die;
}
break;
case 7:
switch (VAR_2) {
case 0:
gen_op_mtc0_hwrena();
VAR_3 = "HWREna";
break;
default:
goto die;
}
break;
case 8:
VAR_3 = "BadVaddr";
break;
case 9:
switch (VAR_2) {
case 0:
gen_op_mtc0_count();
VAR_3 = "Count";
break;
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 10:
switch (VAR_2) {
case 0:
gen_op_mtc0_entryhi();
VAR_3 = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (VAR_2) {
case 0:
gen_op_mtc0_compare();
VAR_3 = "Compare";
break;
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 12:
switch (VAR_2) {
case 0:
gen_op_mtc0_status();
VAR_3 = "Status";
break;
case 1:
gen_op_mtc0_intctl();
VAR_3 = "IntCtl";
break;
case 2:
gen_op_mtc0_srsctl();
VAR_3 = "SRSCtl";
break;
case 3:
gen_op_mtc0_srsmap();
VAR_3 = "SRSMap";
break;
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 13:
switch (VAR_2) {
case 0:
gen_op_mtc0_cause();
VAR_3 = "Cause";
break;
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 14:
switch (VAR_2) {
case 0:
gen_op_dmtc0_epc();
VAR_3 = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (VAR_2) {
case 0:
VAR_3 = "PRid";
break;
case 1:
gen_op_dmtc0_ebase();
VAR_3 = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (VAR_2) {
case 0:
gen_op_mtc0_config0();
VAR_3 = "Config";
break;
case 1:
VAR_3 = "Config1";
break;
case 2:
gen_op_mtc0_config2();
VAR_3 = "Config2";
break;
case 3:
VAR_3 = "Config3";
break;
default:
VAR_3 = "Invalid config selector";
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 17:
switch (VAR_2) {
case 0:
VAR_3 = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (VAR_2) {
case 0:
gen_op_dmtc0_watchlo0();
VAR_3 = "WatchLo";
break;
case 1:
VAR_3 = "WatchLo1";
case 2:
VAR_3 = "WatchLo2";
case 3:
VAR_3 = "WatchLo3";
case 4:
VAR_3 = "WatchLo4";
case 5:
VAR_3 = "WatchLo5";
case 6:
VAR_3 = "WatchLo6";
case 7:
VAR_3 = "WatchLo7";
default:
goto die;
}
break;
case 19:
switch (VAR_2) {
case 0:
gen_op_mtc0_watchhi0();
VAR_3 = "WatchHi";
break;
case 1:
VAR_3 = "WatchHi1";
case 2:
VAR_3 = "WatchHi2";
case 3:
VAR_3 = "WatchHi3";
case 4:
VAR_3 = "WatchHi4";
case 5:
VAR_3 = "WatchHi5";
case 6:
VAR_3 = "WatchHi6";
case 7:
VAR_3 = "WatchHi7";
default:
goto die;
}
break;
case 20:
switch (VAR_2) {
case 0:
gen_op_dmtc0_xcontext();
VAR_3 = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (VAR_2) {
case 0:
gen_op_mtc0_framemask();
VAR_3 = "Framemask";
break;
default:
goto die;
}
break;
case 22:
VAR_3 = "Diagnostic";
break;
case 23:
switch (VAR_2) {
case 0:
gen_op_mtc0_debug();
VAR_3 = "Debug";
break;
case 1:
VAR_3 = "TraceControl";
case 2:
VAR_3 = "TraceControl2";
case 3:
VAR_3 = "UserTraceData";
case 4:
VAR_3 = "TraceBPC";
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
case 24:
switch (VAR_2) {
case 0:
gen_op_dmtc0_depc();
VAR_3 = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (VAR_2) {
case 0:
gen_op_mtc0_performance0();
VAR_3 = "Performance0";
break;
case 1:
VAR_3 = "Performance1";
case 2:
VAR_3 = "Performance2";
case 3:
VAR_3 = "Performance3";
case 4:
VAR_3 = "Performance4";
case 5:
VAR_3 = "Performance5";
case 6:
VAR_3 = "Performance6";
case 7:
VAR_3 = "Performance7";
default:
goto die;
}
break;
case 26:
VAR_3 = "ECC";
break;
case 27:
switch (VAR_2) {
case 0 ... 3:
VAR_3 = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (VAR_2) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taglo();
VAR_3 = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datalo();
VAR_3 = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (VAR_2) {
case 0:
case 2:
case 4:
case 6:
gen_op_mtc0_taghi();
VAR_3 = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mtc0_datahi();
VAR_3 = "DataHi";
break;
default:
VAR_3 = "invalid VAR_2";
goto die;
}
break;
case 30:
switch (VAR_2) {
case 0:
gen_op_dmtc0_errorepc();
VAR_3 = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (VAR_2) {
case 0:
gen_op_mtc0_desave();
VAR_3 = "DESAVE";
break;
default:
goto die;
}
VAR_0->bstate = BS_STOP;
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (VAR_1 %d VAR_2 %d)\n",
VAR_3, VAR_1, VAR_2);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmtc0 %s (VAR_1 %d VAR_2 %d)\n",
VAR_3, VAR_1, VAR_2);
}
#endif
generate_exception(VAR_0, EXCP_RI);
}
| [
"static void FUNC_0 (DisasContext *VAR_0, int VAR_1, int VAR_2)\n{",
"const char *VAR_3 = \"invalid\";",
"switch (VAR_1) {",
"case 0:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_index();",
"VAR_3 = \"Index\";",
"break;",
"case 1:\nVAR_3 = \"MVPControl\";",
"case 2:\nVAR_3 = \"MVPConf0\";",
"case 3:\nVAR_3 = \"MVPConf1\";",
"default:\ngoto die;",
"}",
"break;",
"case 1:\nswitch (VAR_2) {",
"case 0:\nVAR_3 = \"Random\";",
"break;",
"case 1:\nVAR_3 = \"VPEControl\";",
"case 2:\nVAR_3 = \"VPEConf0\";",
"case 3:\nVAR_3 = \"VPEConf1\";",
"case 4:\nVAR_3 = \"YQMask\";",
"case 5:\nVAR_3 = \"VPESchedule\";",
"case 6:\nVAR_3 = \"VPEScheFBack\";",
"case 7:\nVAR_3 = \"VPEOpt\";",
"default:\ngoto die;",
"}",
"break;",
"case 2:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_entrylo0();",
"VAR_3 = \"EntryLo0\";",
"break;",
"case 1:\nVAR_3 = \"TCStatus\";",
"case 2:\nVAR_3 = \"TCBind\";",
"case 3:\nVAR_3 = \"TCRestart\";",
"case 4:\nVAR_3 = \"TCHalt\";",
"case 5:\nVAR_3 = \"TCContext\";",
"case 6:\nVAR_3 = \"TCSchedule\";",
"case 7:\nVAR_3 = \"TCScheFBack\";",
"default:\ngoto die;",
"}",
"break;",
"case 3:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_entrylo1();",
"VAR_3 = \"EntryLo1\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 4:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_context();",
"VAR_3 = \"Context\";",
"break;",
"case 1:\nVAR_3 = \"ContextConfig\";",
"default:\ngoto die;",
"}",
"break;",
"case 5:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_pagemask();",
"VAR_3 = \"PageMask\";",
"break;",
"case 1:\ngen_op_mtc0_pagegrain();",
"VAR_3 = \"PageGrain\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 6:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_wired();",
"VAR_3 = \"Wired\";",
"break;",
"case 1:\nVAR_3 = \"SRSConf0\";",
"case 2:\nVAR_3 = \"SRSConf1\";",
"case 3:\nVAR_3 = \"SRSConf2\";",
"case 4:\nVAR_3 = \"SRSConf3\";",
"case 5:\nVAR_3 = \"SRSConf4\";",
"default:\ngoto die;",
"}",
"break;",
"case 7:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_hwrena();",
"VAR_3 = \"HWREna\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 8:\nVAR_3 = \"BadVaddr\";",
"break;",
"case 9:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_count();",
"VAR_3 = \"Count\";",
"break;",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 10:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_entryhi();",
"VAR_3 = \"EntryHi\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 11:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_compare();",
"VAR_3 = \"Compare\";",
"break;",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 12:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_status();",
"VAR_3 = \"Status\";",
"break;",
"case 1:\ngen_op_mtc0_intctl();",
"VAR_3 = \"IntCtl\";",
"break;",
"case 2:\ngen_op_mtc0_srsctl();",
"VAR_3 = \"SRSCtl\";",
"break;",
"case 3:\ngen_op_mtc0_srsmap();",
"VAR_3 = \"SRSMap\";",
"break;",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 13:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_cause();",
"VAR_3 = \"Cause\";",
"break;",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 14:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_epc();",
"VAR_3 = \"EPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 15:\nswitch (VAR_2) {",
"case 0:\nVAR_3 = \"PRid\";",
"break;",
"case 1:\ngen_op_dmtc0_ebase();",
"VAR_3 = \"EBase\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 16:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_config0();",
"VAR_3 = \"Config\";",
"break;",
"case 1:\nVAR_3 = \"Config1\";",
"break;",
"case 2:\ngen_op_mtc0_config2();",
"VAR_3 = \"Config2\";",
"break;",
"case 3:\nVAR_3 = \"Config3\";",
"break;",
"default:\nVAR_3 = \"Invalid config selector\";",
"goto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 17:\nswitch (VAR_2) {",
"case 0:\nVAR_3 = \"LLAddr\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 18:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_watchlo0();",
"VAR_3 = \"WatchLo\";",
"break;",
"case 1:\nVAR_3 = \"WatchLo1\";",
"case 2:\nVAR_3 = \"WatchLo2\";",
"case 3:\nVAR_3 = \"WatchLo3\";",
"case 4:\nVAR_3 = \"WatchLo4\";",
"case 5:\nVAR_3 = \"WatchLo5\";",
"case 6:\nVAR_3 = \"WatchLo6\";",
"case 7:\nVAR_3 = \"WatchLo7\";",
"default:\ngoto die;",
"}",
"break;",
"case 19:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_watchhi0();",
"VAR_3 = \"WatchHi\";",
"break;",
"case 1:\nVAR_3 = \"WatchHi1\";",
"case 2:\nVAR_3 = \"WatchHi2\";",
"case 3:\nVAR_3 = \"WatchHi3\";",
"case 4:\nVAR_3 = \"WatchHi4\";",
"case 5:\nVAR_3 = \"WatchHi5\";",
"case 6:\nVAR_3 = \"WatchHi6\";",
"case 7:\nVAR_3 = \"WatchHi7\";",
"default:\ngoto die;",
"}",
"break;",
"case 20:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_xcontext();",
"VAR_3 = \"XContext\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 21:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_framemask();",
"VAR_3 = \"Framemask\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 22:\nVAR_3 = \"Diagnostic\";",
"break;",
"case 23:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_debug();",
"VAR_3 = \"Debug\";",
"break;",
"case 1:\nVAR_3 = \"TraceControl\";",
"case 2:\nVAR_3 = \"TraceControl2\";",
"case 3:\nVAR_3 = \"UserTraceData\";",
"case 4:\nVAR_3 = \"TraceBPC\";",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"case 24:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_depc();",
"VAR_3 = \"DEPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 25:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_performance0();",
"VAR_3 = \"Performance0\";",
"break;",
"case 1:\nVAR_3 = \"Performance1\";",
"case 2:\nVAR_3 = \"Performance2\";",
"case 3:\nVAR_3 = \"Performance3\";",
"case 4:\nVAR_3 = \"Performance4\";",
"case 5:\nVAR_3 = \"Performance5\";",
"case 6:\nVAR_3 = \"Performance6\";",
"case 7:\nVAR_3 = \"Performance7\";",
"default:\ngoto die;",
"}",
"break;",
"case 26:\nVAR_3 = \"ECC\";",
"break;",
"case 27:\nswitch (VAR_2) {",
"case 0 ... 3:\nVAR_3 = \"CacheErr\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 28:\nswitch (VAR_2) {",
"case 0:\ncase 2:\ncase 4:\ncase 6:\ngen_op_mtc0_taglo();",
"VAR_3 = \"TagLo\";",
"break;",
"case 1:\ncase 3:\ncase 5:\ncase 7:\ngen_op_mtc0_datalo();",
"VAR_3 = \"DataLo\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 29:\nswitch (VAR_2) {",
"case 0:\ncase 2:\ncase 4:\ncase 6:\ngen_op_mtc0_taghi();",
"VAR_3 = \"TagHi\";",
"break;",
"case 1:\ncase 3:\ncase 5:\ncase 7:\ngen_op_mtc0_datahi();",
"VAR_3 = \"DataHi\";",
"break;",
"default:\nVAR_3 = \"invalid VAR_2\";",
"goto die;",
"}",
"break;",
"case 30:\nswitch (VAR_2) {",
"case 0:\ngen_op_dmtc0_errorepc();",
"VAR_3 = \"ErrorEPC\";",
"break;",
"default:\ngoto die;",
"}",
"break;",
"case 31:\nswitch (VAR_2) {",
"case 0:\ngen_op_mtc0_desave();",
"VAR_3 = \"DESAVE\";",
"break;",
"default:\ngoto die;",
"}",
"VAR_0->bstate = BS_STOP;",
"break;",
"default:\ngoto die;",
"}",
"#if defined MIPS_DEBUG_DISAS\nif (loglevel & CPU_LOG_TB_IN_ASM) {",
"fprintf(logfile, \"dmtc0 %s (VAR_1 %d VAR_2 %d)\\n\",\nVAR_3, VAR_1, VAR_2);",
"}",
"#endif\nreturn;",
"die:\n#if defined MIPS_DEBUG_DISAS\nif (loglevel & CPU_LOG_TB_IN_ASM) {",
"fprintf(logfile, \"dmtc0 %s (VAR_1 %d VAR_2 %d)\\n\",\nVAR_3, VAR_1, VAR_2);",
"}",
"#endif\ngenerate_exception(VAR_0, EXCP_RI);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
27
],
[
31,
35
],
[
39,
43
],
[
47,
49
],
[
51
],
[
53
],
[
55,
57
],
[
59,
63
],
[
65
],
[
67,
71
],
[
75,
79
],
[
83,
87
],
[
91,
95
],
[
99,
103
],
[
107,
111
],
[
115,
119
],
[
123,
125
],
[
127
],
[
129
],
[
131,
133
],
[
135,
137
],
[
139
],
[
141
],
[
143,
147
],
[
151,
155
],
[
159,
163
],
[
167,
171
],
[
175,
179
],
[
183,
187
],
[
191,
195
],
[
199,
201
],
[
203
],
[
205
],
[
207,
209
],
[
211,
213
],
[
215
],
[
217
],
[
219,
221
],
[
223
],
[
225
],
[
227,
229
],
[
231,
233
],
[
235
],
[
237
],
[
239,
243
],
[
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,
299
],
[
303,
307
],
[
311,
315
],
[
319,
323
],
[
327,
331
],
[
335,
337
],
[
339
],
[
341
],
[
343,
345
],
[
347,
349
],
[
351
],
[
353
],
[
355,
357
],
[
359
],
[
361
],
[
363,
367
],
[
369
],
[
371,
373
],
[
375,
377
],
[
379
],
[
381
],
[
385,
387
],
[
389
],
[
393
],
[
395
],
[
397,
399
],
[
401,
403
],
[
405
],
[
407
],
[
409,
411
],
[
413
],
[
415
],
[
417,
419
],
[
421,
423
],
[
425
],
[
427
],
[
431,
433
],
[
435
],
[
439
],
[
441
],
[
443,
445
],
[
447,
449
],
[
451
],
[
453
],
[
455,
457
],
[
459
],
[
461
],
[
463,
465
],
[
467
],
[
469
],
[
471,
473
],
[
475
],
[
477
],
[
479,
481
],
[
483
],
[
487
],
[
489
],
[
491,
493
],
[
495,
497
],
[
499
],
[
501
],
[
503,
505
],
[
507
],
[
511
],
[
513
],
[
515,
517
],
[
519,
521
],
[
523
],
[
525
],
[
527,
529
],
[
531
],
[
533
],
[
535,
537
],
[
539,
543
],
[
545
],
[
547,
549
],
[
551
],
[
553
],
[
555,
557
],
[
559
],
[
561
],
[
563,
565
],
[
567,
569
],
[
571
],
[
573
],
[
575,
579
],
[
581
],
[
583,
585
],
[
587
],
[
589
],
[
591,
595
],
[
597
],
[
601,
603
],
[
605
],
[
607
],
[
611
],
[
613
],
[
615,
617
],
[
619,
623
],
[
625
],
[
627,
629
],
[
631
],
[
633
],
[
635,
637
],
[
639,
641
],
[
643
],
[
645
],
[
647,
651
],
[
655,
659
],
[
663,
667
],
[
671,
675
],
[
679,
683
],
[
687,
691
],
[
695,
699
],
[
703,
705
],
[
707
],
[
709
],
[
711,
713
],
[
715,
717
],
[
719
],
[
721
],
[
723,
727
],
[
731,
735
],
[
739,
743
],
[
747,
751
],
[
755,
759
],
[
763,
767
],
[
771,
775
],
[
779,
781
],
[
783
],
[
785
],
[
787,
789
],
[
791,
795
],
[
797
],
[
799
],
[
801,
803
],
[
805
],
[
807
],
[
809,
813
],
[
815,
817
],
[
819
],
[
821
],
[
823,
825
],
[
827
],
[
829
],
[
831,
835
],
[
837
],
[
839,
841
],
[
843,
845
],
[
847
],
[
849
],
[
851,
855
],
[
859,
863
],
[
867,
871
],
[
875,
879
],
[
883,
885
],
[
887
],
[
891
],
[
893
],
[
895,
897
],
[
899,
901
],
[
903
],
[
905
],
[
907,
909
],
[
911
],
[
913
],
[
915,
917
],
[
919,
921
],
[
923
],
[
925
],
[
927,
931
],
[
935,
939
],
[
943,
947
],
[
951,
955
],
[
959,
963
],
[
967,
971
],
[
975,
979
],
[
983,
985
],
[
987
],
[
989
],
[
991,
995
],
[
997
],
[
999,
1001
],
[
1003,
1007
],
[
1009
],
[
1011,
1013
],
[
1015
],
[
1017
],
[
1019,
1021
],
[
1023,
1025,
1027,
1029,
1031
],
[
1033
],
[
1035
],
[
1037,
1039,
1041,
1043,
1045
],
[
1047
],
[
1049
],
[
1051,
1053
],
[
1055
],
[
1057
],
[
1059,
1061
],
[
1063,
1065,
1067,
1069,
1071
],
[
1073
],
[
1075
],
[
1077,
1079,
1081,
1083,
1085
],
[
1087
],
[
1089
],
[
1091,
1093
],
[
1095
],
[
1097
],
[
1099
],
[
1101,
1103
],
[
1105,
1107
],
[
1109
],
[
1111
],
[
1113,
1115
],
[
1117
],
[
1119
],
[
1121,
1123
],
[
1125,
1127
],
[
1129
],
[
1131
],
[
1133,
1135
],
[
1137
],
[
1141
],
[
1143
],
[
1145,
1147
],
[
1149
],
[
1151,
1153
],
[
1155,
1157
],
[
1159
],
[
1161,
1163
],
[
1167,
1169,
1171
],
[
1173,
1175
],
[
1177
],
[
1179,
1181
],
[
1183
]
]
|
17,155 | static void xilinx_spips_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
int mask = ~0;
int man_start_com = 0;
XilinxSPIPS *s = opaque;
DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr, (unsigned)value);
addr >>= 2;
switch (addr) {
case R_CONFIG:
mask = 0x0002FFFF;
if (value & MAN_START_COM) {
man_start_com = 1;
}
break;
case R_INTR_STATUS:
mask = IXR_ALL;
s->regs[R_INTR_STATUS] &= ~(mask & value);
goto no_reg_update;
case R_INTR_DIS:
mask = IXR_ALL;
s->regs[R_INTR_MASK] &= ~(mask & value);
goto no_reg_update;
case R_INTR_EN:
mask = IXR_ALL;
s->regs[R_INTR_MASK] |= mask & value;
goto no_reg_update;
case R_EN:
mask = 0x1;
break;
case R_SLAVE_IDLE_COUNT:
mask = 0xFF;
break;
case R_RX_DATA:
case R_INTR_MASK:
case R_MOD_ID:
mask = 0;
break;
case R_TX_DATA:
tx_data_bytes(s, (uint32_t)value, s->num_txrx_bytes);
goto no_reg_update;
case R_TXD1:
tx_data_bytes(s, (uint32_t)value, 1);
goto no_reg_update;
case R_TXD2:
tx_data_bytes(s, (uint32_t)value, 2);
goto no_reg_update;
case R_TXD3:
tx_data_bytes(s, (uint32_t)value, 3);
goto no_reg_update;
}
s->regs[addr] = (s->regs[addr] & ~mask) | (value & mask);
no_reg_update:
xilinx_spips_update_cs_lines(s);
if ((man_start_com && s->regs[R_CONFIG] & MAN_START_EN) ||
(fifo8_is_empty(&s->tx_fifo) && s->regs[R_CONFIG] & MAN_START_EN)) {
xilinx_spips_flush_txfifo(s);
}
xilinx_spips_update_cs_lines(s);
xilinx_spips_update_ixr(s);
}
| false | qemu | 2133a5f6b8f8941a6a3734c6c1990656553de76c | static void xilinx_spips_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
int mask = ~0;
int man_start_com = 0;
XilinxSPIPS *s = opaque;
DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr, (unsigned)value);
addr >>= 2;
switch (addr) {
case R_CONFIG:
mask = 0x0002FFFF;
if (value & MAN_START_COM) {
man_start_com = 1;
}
break;
case R_INTR_STATUS:
mask = IXR_ALL;
s->regs[R_INTR_STATUS] &= ~(mask & value);
goto no_reg_update;
case R_INTR_DIS:
mask = IXR_ALL;
s->regs[R_INTR_MASK] &= ~(mask & value);
goto no_reg_update;
case R_INTR_EN:
mask = IXR_ALL;
s->regs[R_INTR_MASK] |= mask & value;
goto no_reg_update;
case R_EN:
mask = 0x1;
break;
case R_SLAVE_IDLE_COUNT:
mask = 0xFF;
break;
case R_RX_DATA:
case R_INTR_MASK:
case R_MOD_ID:
mask = 0;
break;
case R_TX_DATA:
tx_data_bytes(s, (uint32_t)value, s->num_txrx_bytes);
goto no_reg_update;
case R_TXD1:
tx_data_bytes(s, (uint32_t)value, 1);
goto no_reg_update;
case R_TXD2:
tx_data_bytes(s, (uint32_t)value, 2);
goto no_reg_update;
case R_TXD3:
tx_data_bytes(s, (uint32_t)value, 3);
goto no_reg_update;
}
s->regs[addr] = (s->regs[addr] & ~mask) | (value & mask);
no_reg_update:
xilinx_spips_update_cs_lines(s);
if ((man_start_com && s->regs[R_CONFIG] & MAN_START_EN) ||
(fifo8_is_empty(&s->tx_fifo) && s->regs[R_CONFIG] & MAN_START_EN)) {
xilinx_spips_flush_txfifo(s);
}
xilinx_spips_update_cs_lines(s);
xilinx_spips_update_ixr(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
int VAR_4 = ~0;
int VAR_5 = 0;
XilinxSPIPS *s = VAR_0;
DB_PRINT("VAR_1=" TARGET_FMT_plx " = %x\n", VAR_1, (unsigned)VAR_2);
VAR_1 >>= 2;
switch (VAR_1) {
case R_CONFIG:
VAR_4 = 0x0002FFFF;
if (VAR_2 & MAN_START_COM) {
VAR_5 = 1;
}
break;
case R_INTR_STATUS:
VAR_4 = IXR_ALL;
s->regs[R_INTR_STATUS] &= ~(VAR_4 & VAR_2);
goto no_reg_update;
case R_INTR_DIS:
VAR_4 = IXR_ALL;
s->regs[R_INTR_MASK] &= ~(VAR_4 & VAR_2);
goto no_reg_update;
case R_INTR_EN:
VAR_4 = IXR_ALL;
s->regs[R_INTR_MASK] |= VAR_4 & VAR_2;
goto no_reg_update;
case R_EN:
VAR_4 = 0x1;
break;
case R_SLAVE_IDLE_COUNT:
VAR_4 = 0xFF;
break;
case R_RX_DATA:
case R_INTR_MASK:
case R_MOD_ID:
VAR_4 = 0;
break;
case R_TX_DATA:
tx_data_bytes(s, (uint32_t)VAR_2, s->num_txrx_bytes);
goto no_reg_update;
case R_TXD1:
tx_data_bytes(s, (uint32_t)VAR_2, 1);
goto no_reg_update;
case R_TXD2:
tx_data_bytes(s, (uint32_t)VAR_2, 2);
goto no_reg_update;
case R_TXD3:
tx_data_bytes(s, (uint32_t)VAR_2, 3);
goto no_reg_update;
}
s->regs[VAR_1] = (s->regs[VAR_1] & ~VAR_4) | (VAR_2 & VAR_4);
no_reg_update:
xilinx_spips_update_cs_lines(s);
if ((VAR_5 && s->regs[R_CONFIG] & MAN_START_EN) ||
(fifo8_is_empty(&s->tx_fifo) && s->regs[R_CONFIG] & MAN_START_EN)) {
xilinx_spips_flush_txfifo(s);
}
xilinx_spips_update_cs_lines(s);
xilinx_spips_update_ixr(s);
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"int VAR_4 = ~0;",
"int VAR_5 = 0;",
"XilinxSPIPS *s = VAR_0;",
"DB_PRINT(\"VAR_1=\" TARGET_FMT_plx \" = %x\\n\", VAR_1, (unsigned)VAR_2);",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_CONFIG:\nVAR_4 = 0x0002FFFF;",
"if (VAR_2 & MAN_START_COM) {",
"VAR_5 = 1;",
"}",
"break;",
"case R_INTR_STATUS:\nVAR_4 = IXR_ALL;",
"s->regs[R_INTR_STATUS] &= ~(VAR_4 & VAR_2);",
"goto no_reg_update;",
"case R_INTR_DIS:\nVAR_4 = IXR_ALL;",
"s->regs[R_INTR_MASK] &= ~(VAR_4 & VAR_2);",
"goto no_reg_update;",
"case R_INTR_EN:\nVAR_4 = IXR_ALL;",
"s->regs[R_INTR_MASK] |= VAR_4 & VAR_2;",
"goto no_reg_update;",
"case R_EN:\nVAR_4 = 0x1;",
"break;",
"case R_SLAVE_IDLE_COUNT:\nVAR_4 = 0xFF;",
"break;",
"case R_RX_DATA:\ncase R_INTR_MASK:\ncase R_MOD_ID:\nVAR_4 = 0;",
"break;",
"case R_TX_DATA:\ntx_data_bytes(s, (uint32_t)VAR_2, s->num_txrx_bytes);",
"goto no_reg_update;",
"case R_TXD1:\ntx_data_bytes(s, (uint32_t)VAR_2, 1);",
"goto no_reg_update;",
"case R_TXD2:\ntx_data_bytes(s, (uint32_t)VAR_2, 2);",
"goto no_reg_update;",
"case R_TXD3:\ntx_data_bytes(s, (uint32_t)VAR_2, 3);",
"goto no_reg_update;",
"}",
"s->regs[VAR_1] = (s->regs[VAR_1] & ~VAR_4) | (VAR_2 & VAR_4);",
"no_reg_update:\nxilinx_spips_update_cs_lines(s);",
"if ((VAR_5 && s->regs[R_CONFIG] & MAN_START_EN) ||\n(fifo8_is_empty(&s->tx_fifo) && s->regs[R_CONFIG] & MAN_START_EN)) {",
"xilinx_spips_flush_txfifo(s);",
"}",
"xilinx_spips_update_cs_lines(s);",
"xilinx_spips_update_ixr(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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69,
71,
73,
75
],
[
77
],
[
79,
81
],
[
83
],
[
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
97,
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
]
|
17,156 | int nbd_init(int fd, QIOChannelSocket *ioc, uint32_t flags, off_t size)
{
return -ENOTSUP;
}
| false | qemu | 7423f417827146f956df820f172d0bf80a489495 | int nbd_init(int fd, QIOChannelSocket *ioc, uint32_t flags, off_t size)
{
return -ENOTSUP;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0, QIOChannelSocket *VAR_1, uint32_t VAR_2, off_t VAR_3)
{
return -ENOTSUP;
}
| [
"int FUNC_0(int VAR_0, QIOChannelSocket *VAR_1, uint32_t VAR_2, off_t VAR_3)\n{",
"return -ENOTSUP;",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
17,158 | static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
int buf_size)
{
int start_found, i;
uint32_t state;
ParseContext *pc = &pc1->pc;
start_found = pc->frame_start_found;
state = pc->state;
i = 0;
if (!start_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
start_found = 1;
pc1->lastmarker = state;
i++;
break;
}
}
}
}
if (start_found) {
for (; i < buf_size; i++) {
pc1->size++;
state = (state << 8) | buf[i];
if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos)
pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
if (pc1->framesize > pc1->size)
continue;
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
return i - 3;
}
}
}
pc->frame_start_found = start_found;
pc->state = state;
return END_NOT_FOUND;
}
| false | FFmpeg | e80b2b9c81716a5d9f559c04cfe69d76b04e4cd3 | static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
int buf_size)
{
int start_found, i;
uint32_t state;
ParseContext *pc = &pc1->pc;
start_found = pc->frame_start_found;
state = pc->state;
i = 0;
if (!start_found) {
for (i = 0; i < buf_size; i++) {
state = (state << 8) | buf[i];
if (IS_MARKER(state, i, buf, buf_size)) {
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
start_found = 1;
pc1->lastmarker = state;
i++;
break;
}
}
}
}
if (start_found) {
for (; i < buf_size; i++) {
pc1->size++;
state = (state << 8) | buf[i];
if (state == DCA_SYNCWORD_SUBSTREAM && !pc1->hd_pos)
pc1->hd_pos = pc1->size;
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
if (pc1->framesize > pc1->size)
continue;
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
return i - 3;
}
}
}
pc->frame_start_found = start_found;
pc->state = state;
return END_NOT_FOUND;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DCAParseContext *VAR_0, const uint8_t *VAR_1,
int VAR_2)
{
int VAR_3, VAR_4;
uint32_t state;
ParseContext *pc = &VAR_0->pc;
VAR_3 = pc->frame_start_found;
state = pc->state;
VAR_4 = 0;
if (!VAR_3) {
for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {
state = (state << 8) | VAR_1[VAR_4];
if (IS_MARKER(state, VAR_4, VAR_1, VAR_2)) {
if (!VAR_0->lastmarker || state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
VAR_3 = 1;
VAR_0->lastmarker = state;
VAR_4++;
break;
}
}
}
}
if (VAR_3) {
for (; VAR_4 < VAR_2; VAR_4++) {
VAR_0->size++;
state = (state << 8) | VAR_1[VAR_4];
if (state == DCA_SYNCWORD_SUBSTREAM && !VAR_0->hd_pos)
VAR_0->hd_pos = VAR_0->size;
if (IS_MARKER(state, VAR_4, VAR_1, VAR_2) && (state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
if (VAR_0->framesize > VAR_0->size)
continue;
pc->frame_start_found = 0;
pc->state = -1;
VAR_0->size = 0;
return VAR_4 - 3;
}
}
}
pc->frame_start_found = VAR_3;
pc->state = state;
return END_NOT_FOUND;
}
| [
"static int FUNC_0(DCAParseContext *VAR_0, const uint8_t *VAR_1,\nint VAR_2)\n{",
"int VAR_3, VAR_4;",
"uint32_t state;",
"ParseContext *pc = &VAR_0->pc;",
"VAR_3 = pc->frame_start_found;",
"state = pc->state;",
"VAR_4 = 0;",
"if (!VAR_3) {",
"for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {",
"state = (state << 8) | VAR_1[VAR_4];",
"if (IS_MARKER(state, VAR_4, VAR_1, VAR_2)) {",
"if (!VAR_0->lastmarker || state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_SYNCWORD_SUBSTREAM) {",
"VAR_3 = 1;",
"VAR_0->lastmarker = state;",
"VAR_4++;",
"break;",
"}",
"}",
"}",
"}",
"if (VAR_3) {",
"for (; VAR_4 < VAR_2; VAR_4++) {",
"VAR_0->size++;",
"state = (state << 8) | VAR_1[VAR_4];",
"if (state == DCA_SYNCWORD_SUBSTREAM && !VAR_0->hd_pos)\nVAR_0->hd_pos = VAR_0->size;",
"if (IS_MARKER(state, VAR_4, VAR_1, VAR_2) && (state == VAR_0->lastmarker || VAR_0->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {",
"if (VAR_0->framesize > VAR_0->size)\ncontinue;",
"pc->frame_start_found = 0;",
"pc->state = -1;",
"VAR_0->size = 0;",
"return VAR_4 - 3;",
"}",
"}",
"}",
"pc->frame_start_found = VAR_3;",
"pc->state = state;",
"return END_NOT_FOUND;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
]
]
|
17,159 | static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
{
int fd;
fd = socket_connect(s->addr, NULL, NULL, errp);
if (s->addr->type == SOCKET_ADDRESS_KIND_INET && fd >= 0) {
int ret = socket_set_nodelay(fd);
if (ret < 0) {
error_report("%s", strerror(errno));
}
}
if (fd >= 0) {
qemu_set_nonblock(fd);
} else {
fd = -EIO;
}
return fd;
}
| false | qemu | dfd100f242370886bb6732f70f1f7cbd8eb9fedc | static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
{
int fd;
fd = socket_connect(s->addr, NULL, NULL, errp);
if (s->addr->type == SOCKET_ADDRESS_KIND_INET && fd >= 0) {
int ret = socket_set_nodelay(fd);
if (ret < 0) {
error_report("%s", strerror(errno));
}
}
if (fd >= 0) {
qemu_set_nonblock(fd);
} else {
fd = -EIO;
}
return fd;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVSheepdogState *VAR_0, Error **VAR_1)
{
int VAR_2;
VAR_2 = socket_connect(VAR_0->addr, NULL, NULL, VAR_1);
if (VAR_0->addr->type == SOCKET_ADDRESS_KIND_INET && VAR_2 >= 0) {
int VAR_3 = socket_set_nodelay(VAR_2);
if (VAR_3 < 0) {
error_report("%VAR_0", strerror(errno));
}
}
if (VAR_2 >= 0) {
qemu_set_nonblock(VAR_2);
} else {
VAR_2 = -EIO;
}
return VAR_2;
}
| [
"static int FUNC_0(BDRVSheepdogState *VAR_0, Error **VAR_1)\n{",
"int VAR_2;",
"VAR_2 = socket_connect(VAR_0->addr, NULL, NULL, VAR_1);",
"if (VAR_0->addr->type == SOCKET_ADDRESS_KIND_INET && VAR_2 >= 0) {",
"int VAR_3 = socket_set_nodelay(VAR_2);",
"if (VAR_3 < 0) {",
"error_report(\"%VAR_0\", strerror(errno));",
"}",
"}",
"if (VAR_2 >= 0) {",
"qemu_set_nonblock(VAR_2);",
"} else {",
"VAR_2 = -EIO;",
"}",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
]
]
|
17,160 | static void do_info_block(int argc, const char **argv)
{
bdrv_info();
}
| false | qemu | 9307c4c1d93939db9b04117b654253af5113dc21 | static void do_info_block(int argc, const char **argv)
{
bdrv_info();
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, const char **VAR_1)
{
bdrv_info();
}
| [
"static void FUNC_0(int VAR_0, const char **VAR_1)\n{",
"bdrv_info();",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
17,161 | static void buffered_flush(QEMUFileBuffered *s)
{
size_t offset = 0;
int error;
error = qemu_file_get_error(s->file);
if (error != 0) {
DPRINTF("flush when error, bailing: %s\n", strerror(-error));
return;
}
DPRINTF("flushing %zu byte(s) of data\n", s->buffer_size);
while (s->bytes_xfer < s->xfer_limit && offset < s->buffer_size) {
ssize_t ret;
ret = migrate_fd_put_buffer(s->migration_state, s->buffer + offset,
s->buffer_size - offset);
if (ret == -EAGAIN) {
DPRINTF("backend not ready, freezing\n");
s->freeze_output = 1;
break;
}
if (ret <= 0) {
DPRINTF("error flushing data, %zd\n", ret);
qemu_file_set_error(s->file, ret);
break;
} else {
DPRINTF("flushed %zd byte(s)\n", ret);
offset += ret;
s->bytes_xfer += ret;
}
}
DPRINTF("flushed %zu of %zu byte(s)\n", offset, s->buffer_size);
memmove(s->buffer, s->buffer + offset, s->buffer_size - offset);
s->buffer_size -= offset;
}
| false | qemu | 3d6dff316f20137a87e099c30136358df029c0f6 | static void buffered_flush(QEMUFileBuffered *s)
{
size_t offset = 0;
int error;
error = qemu_file_get_error(s->file);
if (error != 0) {
DPRINTF("flush when error, bailing: %s\n", strerror(-error));
return;
}
DPRINTF("flushing %zu byte(s) of data\n", s->buffer_size);
while (s->bytes_xfer < s->xfer_limit && offset < s->buffer_size) {
ssize_t ret;
ret = migrate_fd_put_buffer(s->migration_state, s->buffer + offset,
s->buffer_size - offset);
if (ret == -EAGAIN) {
DPRINTF("backend not ready, freezing\n");
s->freeze_output = 1;
break;
}
if (ret <= 0) {
DPRINTF("error flushing data, %zd\n", ret);
qemu_file_set_error(s->file, ret);
break;
} else {
DPRINTF("flushed %zd byte(s)\n", ret);
offset += ret;
s->bytes_xfer += ret;
}
}
DPRINTF("flushed %zu of %zu byte(s)\n", offset, s->buffer_size);
memmove(s->buffer, s->buffer + offset, s->buffer_size - offset);
s->buffer_size -= offset;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(QEMUFileBuffered *VAR_0)
{
size_t offset = 0;
int VAR_1;
VAR_1 = qemu_file_get_error(VAR_0->file);
if (VAR_1 != 0) {
DPRINTF("flush when VAR_1, bailing: %VAR_0\n", strerror(-VAR_1));
return;
}
DPRINTF("flushing %zu byte(VAR_0) of data\n", VAR_0->buffer_size);
while (VAR_0->bytes_xfer < VAR_0->xfer_limit && offset < VAR_0->buffer_size) {
ssize_t ret;
ret = migrate_fd_put_buffer(VAR_0->migration_state, VAR_0->buffer + offset,
VAR_0->buffer_size - offset);
if (ret == -EAGAIN) {
DPRINTF("backend not ready, freezing\n");
VAR_0->freeze_output = 1;
break;
}
if (ret <= 0) {
DPRINTF("VAR_1 flushing data, %zd\n", ret);
qemu_file_set_error(VAR_0->file, ret);
break;
} else {
DPRINTF("flushed %zd byte(VAR_0)\n", ret);
offset += ret;
VAR_0->bytes_xfer += ret;
}
}
DPRINTF("flushed %zu of %zu byte(VAR_0)\n", offset, VAR_0->buffer_size);
memmove(VAR_0->buffer, VAR_0->buffer + offset, VAR_0->buffer_size - offset);
VAR_0->buffer_size -= offset;
}
| [
"static void FUNC_0(QEMUFileBuffered *VAR_0)\n{",
"size_t offset = 0;",
"int VAR_1;",
"VAR_1 = qemu_file_get_error(VAR_0->file);",
"if (VAR_1 != 0) {",
"DPRINTF(\"flush when VAR_1, bailing: %VAR_0\\n\", strerror(-VAR_1));",
"return;",
"}",
"DPRINTF(\"flushing %zu byte(VAR_0) of data\\n\", VAR_0->buffer_size);",
"while (VAR_0->bytes_xfer < VAR_0->xfer_limit && offset < VAR_0->buffer_size) {",
"ssize_t ret;",
"ret = migrate_fd_put_buffer(VAR_0->migration_state, VAR_0->buffer + offset,\nVAR_0->buffer_size - offset);",
"if (ret == -EAGAIN) {",
"DPRINTF(\"backend not ready, freezing\\n\");",
"VAR_0->freeze_output = 1;",
"break;",
"}",
"if (ret <= 0) {",
"DPRINTF(\"VAR_1 flushing data, %zd\\n\", ret);",
"qemu_file_set_error(VAR_0->file, ret);",
"break;",
"} else {",
"DPRINTF(\"flushed %zd byte(VAR_0)\\n\", ret);",
"offset += ret;",
"VAR_0->bytes_xfer += ret;",
"}",
"}",
"DPRINTF(\"flushed %zu of %zu byte(VAR_0)\\n\", offset, VAR_0->buffer_size);",
"memmove(VAR_0->buffer, VAR_0->buffer + offset, VAR_0->buffer_size - offset);",
"VAR_0->buffer_size -= offset;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
]
]
|
17,162 | static int vt82c686b_mc97_initfn(PCIDevice *dev)
{
VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev);
uint8_t *pci_conf = s->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_MC97);
pci_config_set_class(pci_conf, PCI_CLASS_COMMUNICATION_OTHER);
pci_config_set_revision(pci_conf, 0x30);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
PCI_COMMAND_VGA_PALETTE);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
return 0;
}
| false | qemu | 1cf0d2b8352a2df35919030b84dbfc713ee9b9be | static int vt82c686b_mc97_initfn(PCIDevice *dev)
{
VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev);
uint8_t *pci_conf = s->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_MC97);
pci_config_set_class(pci_conf, PCI_CLASS_COMMUNICATION_OTHER);
pci_config_set_revision(pci_conf, 0x30);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
PCI_COMMAND_VGA_PALETTE);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(PCIDevice *VAR_0)
{
VT686MC97State *s = DO_UPCAST(VT686MC97State, VAR_0, VAR_0);
uint8_t *pci_conf = s->VAR_0.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_MC97);
pci_config_set_class(pci_conf, PCI_CLASS_COMMUNICATION_OTHER);
pci_config_set_revision(pci_conf, 0x30);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
PCI_COMMAND_VGA_PALETTE);
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
return 0;
}
| [
"static int FUNC_0(PCIDevice *VAR_0)\n{",
"VT686MC97State *s = DO_UPCAST(VT686MC97State, VAR_0, VAR_0);",
"uint8_t *pci_conf = s->VAR_0.config;",
"pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);",
"pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_MC97);",
"pci_config_set_class(pci_conf, PCI_CLASS_COMMUNICATION_OTHER);",
"pci_config_set_revision(pci_conf, 0x30);",
"pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |\nPCI_COMMAND_VGA_PALETTE);",
"pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);",
"pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);",
"return 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
],
[
31
],
[
33
]
]
|
17,163 | PCIBus *pci_gt64120_init(qemu_irq *pic)
{
GT64120State *s;
PCIDevice *d;
(void)&pci_host_data_writeb; /* avoid warning */
(void)&pci_host_data_writew; /* avoid warning */
(void)&pci_host_data_writel; /* avoid warning */
(void)&pci_host_data_readb; /* avoid warning */
(void)&pci_host_data_readw; /* avoid warning */
(void)&pci_host_data_readl; /* avoid warning */
s = qemu_mallocz(sizeof(GT64120State));
s->pci = qemu_mallocz(sizeof(GT64120PCIState));
s->pci->bus = pci_register_bus(NULL, "pci",
pci_gt64120_set_irq, pci_gt64120_map_irq,
pic, 144, 4);
s->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, s);
d = pci_register_device(s->pci->bus, "GT64120 PCI Bus", sizeof(PCIDevice),
0, gt64120_read_config, gt64120_write_config);
/* FIXME: Malta specific hw assumptions ahead */
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MARVELL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MARVELL_GT6412X);
d->config[0x04] = 0x00;
d->config[0x05] = 0x00;
d->config[0x06] = 0x80;
d->config[0x07] = 0x02;
d->config[0x08] = 0x10;
d->config[0x09] = 0x00;
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
d->config[0x10] = 0x08;
d->config[0x14] = 0x08;
d->config[0x17] = 0x01;
d->config[0x1B] = 0x1c;
d->config[0x1F] = 0x1f;
d->config[0x23] = 0x14;
d->config[0x24] = 0x01;
d->config[0x27] = 0x14;
d->config[0x3D] = 0x01;
gt64120_reset(s);
register_savevm("GT64120 PCI Bus", 0, 1, gt64120_save, gt64120_load, d);
return s->pci->bus;
}
| false | qemu | 4f5e19e6c570459cd524b29b24374f03860f5149 | PCIBus *pci_gt64120_init(qemu_irq *pic)
{
GT64120State *s;
PCIDevice *d;
(void)&pci_host_data_writeb;
(void)&pci_host_data_writew;
(void)&pci_host_data_writel;
(void)&pci_host_data_readb;
(void)&pci_host_data_readw;
(void)&pci_host_data_readl;
s = qemu_mallocz(sizeof(GT64120State));
s->pci = qemu_mallocz(sizeof(GT64120PCIState));
s->pci->bus = pci_register_bus(NULL, "pci",
pci_gt64120_set_irq, pci_gt64120_map_irq,
pic, 144, 4);
s->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, s);
d = pci_register_device(s->pci->bus, "GT64120 PCI Bus", sizeof(PCIDevice),
0, gt64120_read_config, gt64120_write_config);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MARVELL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MARVELL_GT6412X);
d->config[0x04] = 0x00;
d->config[0x05] = 0x00;
d->config[0x06] = 0x80;
d->config[0x07] = 0x02;
d->config[0x08] = 0x10;
d->config[0x09] = 0x00;
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
d->config[0x10] = 0x08;
d->config[0x14] = 0x08;
d->config[0x17] = 0x01;
d->config[0x1B] = 0x1c;
d->config[0x1F] = 0x1f;
d->config[0x23] = 0x14;
d->config[0x24] = 0x01;
d->config[0x27] = 0x14;
d->config[0x3D] = 0x01;
gt64120_reset(s);
register_savevm("GT64120 PCI Bus", 0, 1, gt64120_save, gt64120_load, d);
return s->pci->bus;
}
| {
"code": [],
"line_no": []
} | PCIBus *FUNC_0(qemu_irq *pic)
{
GT64120State *s;
PCIDevice *d;
(void)&pci_host_data_writeb;
(void)&pci_host_data_writew;
(void)&pci_host_data_writel;
(void)&pci_host_data_readb;
(void)&pci_host_data_readw;
(void)&pci_host_data_readl;
s = qemu_mallocz(sizeof(GT64120State));
s->pci = qemu_mallocz(sizeof(GT64120PCIState));
s->pci->bus = pci_register_bus(NULL, "pci",
pci_gt64120_set_irq, pci_gt64120_map_irq,
pic, 144, 4);
s->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, s);
d = pci_register_device(s->pci->bus, "GT64120 PCI Bus", sizeof(PCIDevice),
0, gt64120_read_config, gt64120_write_config);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MARVELL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_MARVELL_GT6412X);
d->config[0x04] = 0x00;
d->config[0x05] = 0x00;
d->config[0x06] = 0x80;
d->config[0x07] = 0x02;
d->config[0x08] = 0x10;
d->config[0x09] = 0x00;
pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
d->config[0x10] = 0x08;
d->config[0x14] = 0x08;
d->config[0x17] = 0x01;
d->config[0x1B] = 0x1c;
d->config[0x1F] = 0x1f;
d->config[0x23] = 0x14;
d->config[0x24] = 0x01;
d->config[0x27] = 0x14;
d->config[0x3D] = 0x01;
gt64120_reset(s);
register_savevm("GT64120 PCI Bus", 0, 1, gt64120_save, gt64120_load, d);
return s->pci->bus;
}
| [
"PCIBus *FUNC_0(qemu_irq *pic)\n{",
"GT64120State *s;",
"PCIDevice *d;",
"(void)&pci_host_data_writeb;",
"(void)&pci_host_data_writew;",
"(void)&pci_host_data_writel;",
"(void)&pci_host_data_readb;",
"(void)&pci_host_data_readw;",
"(void)&pci_host_data_readl;",
"s = qemu_mallocz(sizeof(GT64120State));",
"s->pci = qemu_mallocz(sizeof(GT64120PCIState));",
"s->pci->bus = pci_register_bus(NULL, \"pci\",\npci_gt64120_set_irq, pci_gt64120_map_irq,\npic, 144, 4);",
"s->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, s);",
"d = pci_register_device(s->pci->bus, \"GT64120 PCI Bus\", sizeof(PCIDevice),\n0, gt64120_read_config, gt64120_write_config);",
"pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MARVELL);",
"pci_config_set_device_id(d->config, PCI_DEVICE_ID_MARVELL_GT6412X);",
"d->config[0x04] = 0x00;",
"d->config[0x05] = 0x00;",
"d->config[0x06] = 0x80;",
"d->config[0x07] = 0x02;",
"d->config[0x08] = 0x10;",
"d->config[0x09] = 0x00;",
"pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);",
"d->config[0x10] = 0x08;",
"d->config[0x14] = 0x08;",
"d->config[0x17] = 0x01;",
"d->config[0x1B] = 0x1c;",
"d->config[0x1F] = 0x1f;",
"d->config[0x23] = 0x14;",
"d->config[0x24] = 0x01;",
"d->config[0x27] = 0x14;",
"d->config[0x3D] = 0x01;",
"gt64120_reset(s);",
"register_savevm(\"GT64120 PCI Bus\", 0, 1, gt64120_save, gt64120_load, d);",
"return s->pci->bus;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
31,
33,
35
],
[
37
],
[
39,
41
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
97
],
[
101
],
[
103
]
]
|
17,164 | static void enter_pgmcheck(S390CPU *cpu, uint16_t code)
{
kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
}
| false | qemu | de13d2161473d02ae97ec0f8e4503147554892dd | static void enter_pgmcheck(S390CPU *cpu, uint16_t code)
{
kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(S390CPU *VAR_0, uint16_t VAR_1)
{
kvm_s390_interrupt(VAR_0, KVM_S390_PROGRAM_INT, VAR_1);
}
| [
"static void FUNC_0(S390CPU *VAR_0, uint16_t VAR_1)\n{",
"kvm_s390_interrupt(VAR_0, KVM_S390_PROGRAM_INT, VAR_1);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
]
]
|
17,165 | static void add_xblock(DWTELEM *dst, uint8_t *src, uint8_t *obmc, int s_x, int s_y, int b_w, int b_h, int mv_x, int mv_y, int w, int h, int dst_stride, int src_stride, int obmc_stride, int mb_type, int add){
uint8_t tmp[src_stride*(b_h+5)]; //FIXME move to context to gurantee alignment
int x,y;
if(s_x<0){
obmc -= s_x;
b_w += s_x;
s_x=0;
}else if(s_x + b_w > w){
b_w = w - s_x;
}
if(s_y<0){
obmc -= s_y*obmc_stride;
b_h += s_y;
s_y=0;
}else if(s_y + b_h> h){
b_h = h - s_y;
}
if(b_w<=0 || b_h<=0) return;
dst += s_x + s_y*dst_stride;
if(mb_type==1){
src += s_x + s_y*src_stride;
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
if(add) dst[x + y*dst_stride] += obmc[x + y*obmc_stride] * 128 * (256/OBMC_MAX);
else dst[x + y*dst_stride] -= obmc[x + y*obmc_stride] * 128 * (256/OBMC_MAX);
}
}
}else{
int dx= mv_x&15;
int dy= mv_y&15;
// int dxy= (mv_x&1) + 2*(mv_y&1);
s_x += (mv_x>>4) - 2;
s_y += (mv_y>>4) - 2;
src += s_x + s_y*src_stride;
//use dsputil
if( (unsigned)s_x >= w - b_w - 4
|| (unsigned)s_y >= h - b_h - 4){
ff_emulated_edge_mc(tmp + 32, src, src_stride, b_w+5, b_h+5, s_x, s_y, w, h);
src= tmp + 32;
}
if(mb_type==0){
mc_block(tmp, src, tmp + 64+8, src_stride, b_w, b_h, dx, dy);
}else{
int sum=0;
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
sum += src[x+ y*src_stride];
}
}
sum= (sum + b_h*b_w/2) / (b_h*b_w);
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
tmp[x + y*src_stride]= sum;
}
}
}
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
if(add) dst[x + y*dst_stride] += obmc[x + y*obmc_stride] * tmp[x + y*src_stride] * (256/OBMC_MAX);
else dst[x + y*dst_stride] -= obmc[x + y*obmc_stride] * tmp[x + y*src_stride] * (256/OBMC_MAX);
}
}
}
}
| false | FFmpeg | 155ec6edf82692bcf3a5f87d2bc697404f4e5aaf | static void add_xblock(DWTELEM *dst, uint8_t *src, uint8_t *obmc, int s_x, int s_y, int b_w, int b_h, int mv_x, int mv_y, int w, int h, int dst_stride, int src_stride, int obmc_stride, int mb_type, int add){
uint8_t tmp[src_stride*(b_h+5)];
int x,y;
if(s_x<0){
obmc -= s_x;
b_w += s_x;
s_x=0;
}else if(s_x + b_w > w){
b_w = w - s_x;
}
if(s_y<0){
obmc -= s_y*obmc_stride;
b_h += s_y;
s_y=0;
}else if(s_y + b_h> h){
b_h = h - s_y;
}
if(b_w<=0 || b_h<=0) return;
dst += s_x + s_y*dst_stride;
if(mb_type==1){
src += s_x + s_y*src_stride;
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
if(add) dst[x + y*dst_stride] += obmc[x + y*obmc_stride] * 128 * (256/OBMC_MAX);
else dst[x + y*dst_stride] -= obmc[x + y*obmc_stride] * 128 * (256/OBMC_MAX);
}
}
}else{
int dx= mv_x&15;
int dy= mv_y&15;
s_x += (mv_x>>4) - 2;
s_y += (mv_y>>4) - 2;
src += s_x + s_y*src_stride;
if( (unsigned)s_x >= w - b_w - 4
|| (unsigned)s_y >= h - b_h - 4){
ff_emulated_edge_mc(tmp + 32, src, src_stride, b_w+5, b_h+5, s_x, s_y, w, h);
src= tmp + 32;
}
if(mb_type==0){
mc_block(tmp, src, tmp + 64+8, src_stride, b_w, b_h, dx, dy);
}else{
int sum=0;
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
sum += src[x+ y*src_stride];
}
}
sum= (sum + b_h*b_w/2) / (b_h*b_w);
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
tmp[x + y*src_stride]= sum;
}
}
}
for(y=0; y < b_h; y++){
for(x=0; x < b_w; x++){
if(add) dst[x + y*dst_stride] += obmc[x + y*obmc_stride] * tmp[x + y*src_stride] * (256/OBMC_MAX);
else dst[x + y*dst_stride] -= obmc[x + y*obmc_stride] * tmp[x + y*src_stride] * (256/OBMC_MAX);
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DWTELEM *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10, int VAR_11, int VAR_12, int VAR_13, int VAR_14, int VAR_15){
uint8_t tmp[VAR_12*(VAR_6+5)];
int VAR_16,VAR_17;
if(VAR_3<0){
VAR_2 -= VAR_3;
VAR_5 += VAR_3;
VAR_3=0;
}else if(VAR_3 + VAR_5 > VAR_9){
VAR_5 = VAR_9 - VAR_3;
}
if(VAR_4<0){
VAR_2 -= VAR_4*VAR_13;
VAR_6 += VAR_4;
VAR_4=0;
}else if(VAR_4 + VAR_6> VAR_10){
VAR_6 = VAR_10 - VAR_4;
}
if(VAR_5<=0 || VAR_6<=0) return;
VAR_0 += VAR_3 + VAR_4*VAR_11;
if(VAR_14==1){
VAR_1 += VAR_3 + VAR_4*VAR_12;
for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){
for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){
if(VAR_15) VAR_0[VAR_16 + VAR_17*VAR_11] += VAR_2[VAR_16 + VAR_17*VAR_13] * 128 * (256/OBMC_MAX);
else VAR_0[VAR_16 + VAR_17*VAR_11] -= VAR_2[VAR_16 + VAR_17*VAR_13] * 128 * (256/OBMC_MAX);
}
}
}else{
int VAR_18= VAR_7&15;
int VAR_19= VAR_8&15;
VAR_3 += (VAR_7>>4) - 2;
VAR_4 += (VAR_8>>4) - 2;
VAR_1 += VAR_3 + VAR_4*VAR_12;
if( (unsigned)VAR_3 >= VAR_9 - VAR_5 - 4
|| (unsigned)VAR_4 >= VAR_10 - VAR_6 - 4){
ff_emulated_edge_mc(tmp + 32, VAR_1, VAR_12, VAR_5+5, VAR_6+5, VAR_3, VAR_4, VAR_9, VAR_10);
VAR_1= tmp + 32;
}
if(VAR_14==0){
mc_block(tmp, VAR_1, tmp + 64+8, VAR_12, VAR_5, VAR_6, VAR_18, VAR_19);
}else{
int VAR_20=0;
for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){
for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){
VAR_20 += VAR_1[VAR_16+ VAR_17*VAR_12];
}
}
VAR_20= (VAR_20 + VAR_6*VAR_5/2) / (VAR_6*VAR_5);
for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){
for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){
tmp[VAR_16 + VAR_17*VAR_12]= VAR_20;
}
}
}
for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){
for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){
if(VAR_15) VAR_0[VAR_16 + VAR_17*VAR_11] += VAR_2[VAR_16 + VAR_17*VAR_13] * tmp[VAR_16 + VAR_17*VAR_12] * (256/OBMC_MAX);
else VAR_0[VAR_16 + VAR_17*VAR_11] -= VAR_2[VAR_16 + VAR_17*VAR_13] * tmp[VAR_16 + VAR_17*VAR_12] * (256/OBMC_MAX);
}
}
}
}
| [
"static void FUNC_0(DWTELEM *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10, int VAR_11, int VAR_12, int VAR_13, int VAR_14, int VAR_15){",
"uint8_t tmp[VAR_12*(VAR_6+5)];",
"int VAR_16,VAR_17;",
"if(VAR_3<0){",
"VAR_2 -= VAR_3;",
"VAR_5 += VAR_3;",
"VAR_3=0;",
"}else if(VAR_3 + VAR_5 > VAR_9){",
"VAR_5 = VAR_9 - VAR_3;",
"}",
"if(VAR_4<0){",
"VAR_2 -= VAR_4*VAR_13;",
"VAR_6 += VAR_4;",
"VAR_4=0;",
"}else if(VAR_4 + VAR_6> VAR_10){",
"VAR_6 = VAR_10 - VAR_4;",
"}",
"if(VAR_5<=0 || VAR_6<=0) return;",
"VAR_0 += VAR_3 + VAR_4*VAR_11;",
"if(VAR_14==1){",
"VAR_1 += VAR_3 + VAR_4*VAR_12;",
"for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){",
"for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){",
"if(VAR_15) VAR_0[VAR_16 + VAR_17*VAR_11] += VAR_2[VAR_16 + VAR_17*VAR_13] * 128 * (256/OBMC_MAX);",
"else VAR_0[VAR_16 + VAR_17*VAR_11] -= VAR_2[VAR_16 + VAR_17*VAR_13] * 128 * (256/OBMC_MAX);",
"}",
"}",
"}else{",
"int VAR_18= VAR_7&15;",
"int VAR_19= VAR_8&15;",
"VAR_3 += (VAR_7>>4) - 2;",
"VAR_4 += (VAR_8>>4) - 2;",
"VAR_1 += VAR_3 + VAR_4*VAR_12;",
"if( (unsigned)VAR_3 >= VAR_9 - VAR_5 - 4\n|| (unsigned)VAR_4 >= VAR_10 - VAR_6 - 4){",
"ff_emulated_edge_mc(tmp + 32, VAR_1, VAR_12, VAR_5+5, VAR_6+5, VAR_3, VAR_4, VAR_9, VAR_10);",
"VAR_1= tmp + 32;",
"}",
"if(VAR_14==0){",
"mc_block(tmp, VAR_1, tmp + 64+8, VAR_12, VAR_5, VAR_6, VAR_18, VAR_19);",
"}else{",
"int VAR_20=0;",
"for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){",
"for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){",
"VAR_20 += VAR_1[VAR_16+ VAR_17*VAR_12];",
"}",
"}",
"VAR_20= (VAR_20 + VAR_6*VAR_5/2) / (VAR_6*VAR_5);",
"for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){",
"for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){",
"tmp[VAR_16 + VAR_17*VAR_12]= VAR_20;",
"}",
"}",
"}",
"for(VAR_17=0; VAR_17 < VAR_6; VAR_17++){",
"for(VAR_16=0; VAR_16 < VAR_5; VAR_16++){",
"if(VAR_15) VAR_0[VAR_16 + VAR_17*VAR_11] += VAR_2[VAR_16 + VAR_17*VAR_13] * tmp[VAR_16 + VAR_17*VAR_12] * (256/OBMC_MAX);",
"else VAR_0[VAR_16 + VAR_17*VAR_11] -= VAR_2[VAR_16 + VAR_17*VAR_13] * tmp[VAR_16 + VAR_17*VAR_12] * (256/OBMC_MAX);",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
73
],
[
75
],
[
77
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
]
]
|
17,166 | int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterLink *outlink = buffer_filter->outputs[0];
AVFilterBufferRef *buf;
int ret;
if (!picref) {
c->eof = 1;
return 0;
} else if (c->eof)
return AVERROR(EINVAL);
if (!av_fifo_space(c->fifo) &&
(ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
sizeof(buf))) < 0)
return ret;
if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
/* TODO reindent */
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
char scale_param[1024];
av_log(buffer_filter, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
if (!scale || strcmp(scale->filter->name, "scale")) {
AVFilter *f = avfilter_get_by_name("scale");
av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
return ret;
c->scale = scale;
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
return ret;
}
if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
return ret;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
} else if (!strcmp(scale->filter->name, "scale")) {
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
scale->filter->init(scale, scale_param, NULL);
}
c->pix_fmt = scale->inputs[0]->format = picref->format;
c->w = scale->inputs[0]->w = picref->video->w;
c->h = scale->inputs[0]->h = picref->video->h;
link = scale->outputs[0];
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
}
if (flags & AV_BUFFERSRC_FLAG_NO_COPY) {
buf = picref;
} else {
buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
picref->video->w, picref->video->h);
av_image_copy(buf->data, buf->linesize,
(void*)picref->data, picref->linesize,
picref->format, picref->video->w, picref->video->h);
avfilter_copy_buffer_ref_props(buf, picref);
}
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
if (buf != picref)
avfilter_unref_buffer(buf);
return ret;
}
c->nb_failed_requests = 0;
return 0;
}
| false | FFmpeg | f94b150a0342fc5a7d0b0f0c82d0d9c3aec3c49f | int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterLink *outlink = buffer_filter->outputs[0];
AVFilterBufferRef *buf;
int ret;
if (!picref) {
c->eof = 1;
return 0;
} else if (c->eof)
return AVERROR(EINVAL);
if (!av_fifo_space(c->fifo) &&
(ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
sizeof(buf))) < 0)
return ret;
if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
char scale_param[1024];
av_log(buffer_filter, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
if (!scale || strcmp(scale->filter->name, "scale")) {
AVFilter *f = avfilter_get_by_name("scale");
av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
return ret;
c->scale = scale;
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
return ret;
}
if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
return ret;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
} else if (!strcmp(scale->filter->name, "scale")) {
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
scale->filter->init(scale, scale_param, NULL);
}
c->pix_fmt = scale->inputs[0]->format = picref->format;
c->w = scale->inputs[0]->w = picref->video->w;
c->h = scale->inputs[0]->h = picref->video->h;
link = scale->outputs[0];
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
}
if (flags & AV_BUFFERSRC_FLAG_NO_COPY) {
buf = picref;
} else {
buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
picref->video->w, picref->video->h);
av_image_copy(buf->data, buf->linesize,
(void*)picref->data, picref->linesize,
picref->format, picref->video->w, picref->video->h);
avfilter_copy_buffer_ref_props(buf, picref);
}
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
if (buf != picref)
avfilter_unref_buffer(buf);
return ret;
}
c->nb_failed_requests = 0;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFilterContext *VAR_0,
AVFilterBufferRef *VAR_1, int VAR_2)
{
BufferSourceContext *c = VAR_0->priv;
AVFilterLink *outlink = VAR_0->outputs[0];
AVFilterBufferRef *buf;
int VAR_3;
if (!VAR_1) {
c->eof = 1;
return 0;
} else if (c->eof)
return AVERROR(EINVAL);
if (!av_fifo_space(c->fifo) &&
(VAR_3 = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
sizeof(buf))) < 0)
return VAR_3;
if (!(VAR_2 & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
if (VAR_1->video->w != c->w || VAR_1->video->h != c->h || VAR_1->format != c->pix_fmt) {
AVFilterContext *scale = VAR_0->outputs[0]->dst;
AVFilterLink *link;
char VAR_4[1024];
av_log(VAR_0, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
VAR_1->video->w, VAR_1->video->h, av_pix_fmt_descriptors[VAR_1->format].name);
if (!scale || strcmp(scale->filter->name, "scale")) {
AVFilter *f = avfilter_get_by_name("scale");
av_log(VAR_0, AV_LOG_INFO, "Inserting scaler filter\n");
if ((VAR_3 = avfilter_open(&scale, f, "Input equalizer")) < 0)
return VAR_3;
c->scale = scale;
snprintf(VAR_4, sizeof(VAR_4)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((VAR_3 = avfilter_init_filter(scale, VAR_4, NULL)) < 0) {
return VAR_3;
}
if ((VAR_3 = avfilter_insert_filter(VAR_0->outputs[0], scale, 0, 0)) < 0) {
return VAR_3;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
} else if (!strcmp(scale->filter->name, "scale")) {
snprintf(VAR_4, sizeof(VAR_4)-1, "%d:%d:%s",
scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
scale->filter->init(scale, VAR_4, NULL);
}
c->pix_fmt = scale->inputs[0]->format = VAR_1->format;
c->w = scale->inputs[0]->w = VAR_1->video->w;
c->h = scale->inputs[0]->h = VAR_1->video->h;
link = scale->outputs[0];
if ((VAR_3 = link->srcpad->config_props(link)) < 0)
return VAR_3;
}
}
if (VAR_2 & AV_BUFFERSRC_FLAG_NO_COPY) {
buf = VAR_1;
} else {
buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
VAR_1->video->w, VAR_1->video->h);
av_image_copy(buf->data, buf->linesize,
(void*)VAR_1->data, VAR_1->linesize,
VAR_1->format, VAR_1->video->w, VAR_1->video->h);
avfilter_copy_buffer_ref_props(buf, VAR_1);
}
if ((VAR_3 = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
if (buf != VAR_1)
avfilter_unref_buffer(buf);
return VAR_3;
}
c->nb_failed_requests = 0;
return 0;
}
| [
"int FUNC_0(AVFilterContext *VAR_0,\nAVFilterBufferRef *VAR_1, int VAR_2)\n{",
"BufferSourceContext *c = VAR_0->priv;",
"AVFilterLink *outlink = VAR_0->outputs[0];",
"AVFilterBufferRef *buf;",
"int VAR_3;",
"if (!VAR_1) {",
"c->eof = 1;",
"return 0;",
"} else if (c->eof)",
"return AVERROR(EINVAL);",
"if (!av_fifo_space(c->fifo) &&\n(VAR_3 = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +\nsizeof(buf))) < 0)\nreturn VAR_3;",
"if (!(VAR_2 & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {",
"if (VAR_1->video->w != c->w || VAR_1->video->h != c->h || VAR_1->format != c->pix_fmt) {",
"AVFilterContext *scale = VAR_0->outputs[0]->dst;",
"AVFilterLink *link;",
"char VAR_4[1024];",
"av_log(VAR_0, AV_LOG_INFO,\n\"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\\n\",\nc->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,\nVAR_1->video->w, VAR_1->video->h, av_pix_fmt_descriptors[VAR_1->format].name);",
"if (!scale || strcmp(scale->filter->name, \"scale\")) {",
"AVFilter *f = avfilter_get_by_name(\"scale\");",
"av_log(VAR_0, AV_LOG_INFO, \"Inserting scaler filter\\n\");",
"if ((VAR_3 = avfilter_open(&scale, f, \"Input equalizer\")) < 0)\nreturn VAR_3;",
"c->scale = scale;",
"snprintf(VAR_4, sizeof(VAR_4)-1, \"%d:%d:%s\", c->w, c->h, c->sws_param);",
"if ((VAR_3 = avfilter_init_filter(scale, VAR_4, NULL)) < 0) {",
"return VAR_3;",
"}",
"if ((VAR_3 = avfilter_insert_filter(VAR_0->outputs[0], scale, 0, 0)) < 0) {",
"return VAR_3;",
"}",
"scale->outputs[0]->time_base = scale->inputs[0]->time_base;",
"scale->outputs[0]->format= c->pix_fmt;",
"} else if (!strcmp(scale->filter->name, \"scale\")) {",
"snprintf(VAR_4, sizeof(VAR_4)-1, \"%d:%d:%s\",\nscale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);",
"scale->filter->init(scale, VAR_4, NULL);",
"}",
"c->pix_fmt = scale->inputs[0]->format = VAR_1->format;",
"c->w = scale->inputs[0]->w = VAR_1->video->w;",
"c->h = scale->inputs[0]->h = VAR_1->video->h;",
"link = scale->outputs[0];",
"if ((VAR_3 = link->srcpad->config_props(link)) < 0)\nreturn VAR_3;",
"}",
"}",
"if (VAR_2 & AV_BUFFERSRC_FLAG_NO_COPY) {",
"buf = VAR_1;",
"} else {",
"buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,\nVAR_1->video->w, VAR_1->video->h);",
"av_image_copy(buf->data, buf->linesize,\n(void*)VAR_1->data, VAR_1->linesize,\nVAR_1->format, VAR_1->video->w, VAR_1->video->h);",
"avfilter_copy_buffer_ref_props(buf, VAR_1);",
"}",
"if ((VAR_3 = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {",
"if (buf != VAR_1)\navfilter_unref_buffer(buf);",
"return VAR_3;",
"}",
"c->nb_failed_requests = 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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29,
31,
33,
35
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55,
57,
59
],
[
63
],
[
65
],
[
69
],
[
71,
73
],
[
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
145,
147,
149
],
[
151
],
[
155
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
]
]
|
17,167 | int avformat_write_header(AVFormatContext *s, AVDictionary **options)
{
int ret = 0, i;
AVStream *st;
AVDictionary *tmp = NULL;
if (options)
av_dict_copy(&tmp, *options, 0);
if ((ret = av_opt_set_dict(s, &tmp)) < 0)
goto fail;
if (s->priv_data && s->oformat->priv_class && *(const AVClass**)s->priv_data==s->oformat->priv_class &&
(ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
goto fail;
// some sanity checks
if (s->nb_streams == 0 && !(s->oformat->flags & AVFMT_NOSTREAMS)) {
av_log(s, AV_LOG_ERROR, "no streams\n");
ret = AVERROR(EINVAL);
goto fail;
}
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(st->codec->sample_rate<=0){
av_log(s, AV_LOG_ERROR, "sample rate not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if(!st->codec->block_align)
st->codec->block_align = st->codec->channels *
av_get_bits_per_sample(st->codec->codec_id) >> 3;
break;
case AVMEDIA_TYPE_VIDEO:
if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too?
av_log(s, AV_LOG_ERROR, "time base not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if((st->codec->width<=0 || st->codec->height<=0) && !(s->oformat->flags & AVFMT_NODIMENSIONS)){
av_log(s, AV_LOG_ERROR, "dimensions not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)
&& FFABS(av_q2d(st->sample_aspect_ratio) - av_q2d(st->codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)
){
av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between muxer "
"(%d/%d) and encoder layer (%d/%d)\n",
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
st->codec->sample_aspect_ratio.num,
st->codec->sample_aspect_ratio.den);
ret = AVERROR(EINVAL);
goto fail;
}
break;
}
if(s->oformat->codec_tag){
if(st->codec->codec_tag && st->codec->codec_id == CODEC_ID_RAWVIDEO && av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id) == 0 && !validate_codec_tag(s, st)){
//the current rawvideo encoding system ends up setting the wrong codec_tag for avi, we override it here
st->codec->codec_tag= 0;
}
if(st->codec->codec_tag){
if (!validate_codec_tag(s, st)) {
char tagbuf[32], cortag[32];
av_get_codec_tag_string(tagbuf, sizeof(tagbuf), st->codec->codec_tag);
av_get_codec_tag_string(cortag, sizeof(cortag), av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id));
av_log(s, AV_LOG_ERROR,
"Tag %s/0x%08x incompatible with output codec id '%d' (%s)\n",
tagbuf, st->codec->codec_tag, st->codec->codec_id, cortag);
ret = AVERROR_INVALIDDATA;
goto fail;
}
}else
st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
}
if(s->oformat->flags & AVFMT_GLOBALHEADER &&
!(st->codec->flags & CODEC_FLAG_GLOBAL_HEADER))
av_log(s, AV_LOG_WARNING, "Codec for stream %d does not use global headers but container format requires global headers\n", i);
}
if (!s->priv_data && s->oformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if (!s->priv_data) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (s->oformat->priv_class) {
*(const AVClass**)s->priv_data= s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
goto fail;
}
}
/* set muxer identification string */
if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
}
if(s->oformat->write_header){
ret = s->oformat->write_header(s);
if (ret < 0)
goto fail;
}
/* init PTS generation */
for(i=0;i<s->nb_streams;i++) {
int64_t den = AV_NOPTS_VALUE;
st = s->streams[i];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
den = (int64_t)st->time_base.num * st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
den = (int64_t)st->time_base.num * st->codec->time_base.den;
break;
default:
break;
}
if (den != AV_NOPTS_VALUE) {
if (den <= 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
frac_init(&st->pts, 0, 0, den);
}
}
if (options) {
av_dict_free(options);
*options = tmp;
}
return 0;
fail:
av_dict_free(&tmp);
return ret;
}
| false | FFmpeg | 75a9479b393a02ffa03436f275ad2b91bd2acd26 | int avformat_write_header(AVFormatContext *s, AVDictionary **options)
{
int ret = 0, i;
AVStream *st;
AVDictionary *tmp = NULL;
if (options)
av_dict_copy(&tmp, *options, 0);
if ((ret = av_opt_set_dict(s, &tmp)) < 0)
goto fail;
if (s->priv_data && s->oformat->priv_class && *(const AVClass**)s->priv_data==s->oformat->priv_class &&
(ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
goto fail;
if (s->nb_streams == 0 && !(s->oformat->flags & AVFMT_NOSTREAMS)) {
av_log(s, AV_LOG_ERROR, "no streams\n");
ret = AVERROR(EINVAL);
goto fail;
}
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(st->codec->sample_rate<=0){
av_log(s, AV_LOG_ERROR, "sample rate not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if(!st->codec->block_align)
st->codec->block_align = st->codec->channels *
av_get_bits_per_sample(st->codec->codec_id) >> 3;
break;
case AVMEDIA_TYPE_VIDEO:
if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){
av_log(s, AV_LOG_ERROR, "time base not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if((st->codec->width<=0 || st->codec->height<=0) && !(s->oformat->flags & AVFMT_NODIMENSIONS)){
av_log(s, AV_LOG_ERROR, "dimensions not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)
&& FFABS(av_q2d(st->sample_aspect_ratio) - av_q2d(st->codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)
){
av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between muxer "
"(%d/%d) and encoder layer (%d/%d)\n",
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
st->codec->sample_aspect_ratio.num,
st->codec->sample_aspect_ratio.den);
ret = AVERROR(EINVAL);
goto fail;
}
break;
}
if(s->oformat->codec_tag){
if(st->codec->codec_tag && st->codec->codec_id == CODEC_ID_RAWVIDEO && av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id) == 0 && !validate_codec_tag(s, st)){
st->codec->codec_tag= 0;
}
if(st->codec->codec_tag){
if (!validate_codec_tag(s, st)) {
char tagbuf[32], cortag[32];
av_get_codec_tag_string(tagbuf, sizeof(tagbuf), st->codec->codec_tag);
av_get_codec_tag_string(cortag, sizeof(cortag), av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id));
av_log(s, AV_LOG_ERROR,
"Tag %s/0x%08x incompatible with output codec id '%d' (%s)\n",
tagbuf, st->codec->codec_tag, st->codec->codec_id, cortag);
ret = AVERROR_INVALIDDATA;
goto fail;
}
}else
st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
}
if(s->oformat->flags & AVFMT_GLOBALHEADER &&
!(st->codec->flags & CODEC_FLAG_GLOBAL_HEADER))
av_log(s, AV_LOG_WARNING, "Codec for stream %d does not use global headers but container format requires global headers\n", i);
}
if (!s->priv_data && s->oformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if (!s->priv_data) {
ret = AVERROR(ENOMEM);
goto fail;
}
if (s->oformat->priv_class) {
*(const AVClass**)s->priv_data= s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0)
goto fail;
}
}
if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
}
if(s->oformat->write_header){
ret = s->oformat->write_header(s);
if (ret < 0)
goto fail;
}
for(i=0;i<s->nb_streams;i++) {
int64_t den = AV_NOPTS_VALUE;
st = s->streams[i];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
den = (int64_t)st->time_base.num * st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
den = (int64_t)st->time_base.num * st->codec->time_base.den;
break;
default:
break;
}
if (den != AV_NOPTS_VALUE) {
if (den <= 0) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
frac_init(&st->pts, 0, 0, den);
}
}
if (options) {
av_dict_free(options);
*options = tmp;
}
return 0;
fail:
av_dict_free(&tmp);
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1)
{
int VAR_2 = 0, VAR_3;
AVStream *st;
AVDictionary *tmp = NULL;
if (VAR_1)
av_dict_copy(&tmp, *VAR_1, 0);
if ((VAR_2 = av_opt_set_dict(VAR_0, &tmp)) < 0)
goto fail;
if (VAR_0->priv_data && VAR_0->oformat->priv_class && *(const AVClass**)VAR_0->priv_data==VAR_0->oformat->priv_class &&
(VAR_2 = av_opt_set_dict(VAR_0->priv_data, &tmp)) < 0)
goto fail;
if (VAR_0->nb_streams == 0 && !(VAR_0->oformat->flags & AVFMT_NOSTREAMS)) {
av_log(VAR_0, AV_LOG_ERROR, "no streams\n");
VAR_2 = AVERROR(EINVAL);
goto fail;
}
for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {
st = VAR_0->streams[VAR_3];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if(st->codec->sample_rate<=0){
av_log(VAR_0, AV_LOG_ERROR, "sample rate not set\n");
VAR_2 = AVERROR(EINVAL);
goto fail;
}
if(!st->codec->block_align)
st->codec->block_align = st->codec->channels *
av_get_bits_per_sample(st->codec->codec_id) >> 3;
break;
case AVMEDIA_TYPE_VIDEO:
if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){
av_log(VAR_0, AV_LOG_ERROR, "time base not set\n");
VAR_2 = AVERROR(EINVAL);
goto fail;
}
if((st->codec->width<=0 || st->codec->height<=0) && !(VAR_0->oformat->flags & AVFMT_NODIMENSIONS)){
av_log(VAR_0, AV_LOG_ERROR, "dimensions not set\n");
VAR_2 = AVERROR(EINVAL);
goto fail;
}
if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)
&& FFABS(av_q2d(st->sample_aspect_ratio) - av_q2d(st->codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)
){
av_log(VAR_0, AV_LOG_ERROR, "Aspect ratio mismatch between muxer "
"(%d/%d) and encoder layer (%d/%d)\n",
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
st->codec->sample_aspect_ratio.num,
st->codec->sample_aspect_ratio.den);
VAR_2 = AVERROR(EINVAL);
goto fail;
}
break;
}
if(VAR_0->oformat->codec_tag){
if(st->codec->codec_tag && st->codec->codec_id == CODEC_ID_RAWVIDEO && av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id) == 0 && !validate_codec_tag(VAR_0, st)){
st->codec->codec_tag= 0;
}
if(st->codec->codec_tag){
if (!validate_codec_tag(VAR_0, st)) {
char tagbuf[32], cortag[32];
av_get_codec_tag_string(tagbuf, sizeof(tagbuf), st->codec->codec_tag);
av_get_codec_tag_string(cortag, sizeof(cortag), av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id));
av_log(VAR_0, AV_LOG_ERROR,
"Tag %VAR_0/0x%08x incompatible with output codec id '%d' (%VAR_0)\n",
tagbuf, st->codec->codec_tag, st->codec->codec_id, cortag);
VAR_2 = AVERROR_INVALIDDATA;
goto fail;
}
}else
st->codec->codec_tag= av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id);
}
if(VAR_0->oformat->flags & AVFMT_GLOBALHEADER &&
!(st->codec->flags & CODEC_FLAG_GLOBAL_HEADER))
av_log(VAR_0, AV_LOG_WARNING, "Codec for stream %d does not use global headers but container format requires global headers\n", VAR_3);
}
if (!VAR_0->priv_data && VAR_0->oformat->priv_data_size > 0) {
VAR_0->priv_data = av_mallocz(VAR_0->oformat->priv_data_size);
if (!VAR_0->priv_data) {
VAR_2 = AVERROR(ENOMEM);
goto fail;
}
if (VAR_0->oformat->priv_class) {
*(const AVClass**)VAR_0->priv_data= VAR_0->oformat->priv_class;
av_opt_set_defaults(VAR_0->priv_data);
if ((VAR_2 = av_opt_set_dict(VAR_0->priv_data, &tmp)) < 0)
goto fail;
}
}
if (VAR_0->nb_streams && !(VAR_0->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
av_dict_set(&VAR_0->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
}
if(VAR_0->oformat->write_header){
VAR_2 = VAR_0->oformat->write_header(VAR_0);
if (VAR_2 < 0)
goto fail;
}
for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {
int64_t den = AV_NOPTS_VALUE;
st = VAR_0->streams[VAR_3];
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
den = (int64_t)st->time_base.num * st->codec->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
den = (int64_t)st->time_base.num * st->codec->time_base.den;
break;
default:
break;
}
if (den != AV_NOPTS_VALUE) {
if (den <= 0) {
VAR_2 = AVERROR_INVALIDDATA;
goto fail;
}
frac_init(&st->pts, 0, 0, den);
}
}
if (VAR_1) {
av_dict_free(VAR_1);
*VAR_1 = tmp;
}
return 0;
fail:
av_dict_free(&tmp);
return VAR_2;
}
| [
"int FUNC_0(AVFormatContext *VAR_0, AVDictionary **VAR_1)\n{",
"int VAR_2 = 0, VAR_3;",
"AVStream *st;",
"AVDictionary *tmp = NULL;",
"if (VAR_1)\nav_dict_copy(&tmp, *VAR_1, 0);",
"if ((VAR_2 = av_opt_set_dict(VAR_0, &tmp)) < 0)\ngoto fail;",
"if (VAR_0->priv_data && VAR_0->oformat->priv_class && *(const AVClass**)VAR_0->priv_data==VAR_0->oformat->priv_class &&\n(VAR_2 = av_opt_set_dict(VAR_0->priv_data, &tmp)) < 0)\ngoto fail;",
"if (VAR_0->nb_streams == 0 && !(VAR_0->oformat->flags & AVFMT_NOSTREAMS)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"no streams\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {",
"st = VAR_0->streams[VAR_3];",
"switch (st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nif(st->codec->sample_rate<=0){",
"av_log(VAR_0, AV_LOG_ERROR, \"sample rate not set\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if(!st->codec->block_align)\nst->codec->block_align = st->codec->channels *\nav_get_bits_per_sample(st->codec->codec_id) >> 3;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nif(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){",
"av_log(VAR_0, AV_LOG_ERROR, \"time base not set\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if((st->codec->width<=0 || st->codec->height<=0) && !(VAR_0->oformat->flags & AVFMT_NODIMENSIONS)){",
"av_log(VAR_0, AV_LOG_ERROR, \"dimensions not set\\n\");",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)\n&& FFABS(av_q2d(st->sample_aspect_ratio) - av_q2d(st->codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)\n){",
"av_log(VAR_0, AV_LOG_ERROR, \"Aspect ratio mismatch between muxer \"\n\"(%d/%d) and encoder layer (%d/%d)\\n\",\nst->sample_aspect_ratio.num, st->sample_aspect_ratio.den,\nst->codec->sample_aspect_ratio.num,\nst->codec->sample_aspect_ratio.den);",
"VAR_2 = AVERROR(EINVAL);",
"goto fail;",
"}",
"break;",
"}",
"if(VAR_0->oformat->codec_tag){",
"if(st->codec->codec_tag && st->codec->codec_id == CODEC_ID_RAWVIDEO && av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id) == 0 && !validate_codec_tag(VAR_0, st)){",
"st->codec->codec_tag= 0;",
"}",
"if(st->codec->codec_tag){",
"if (!validate_codec_tag(VAR_0, st)) {",
"char tagbuf[32], cortag[32];",
"av_get_codec_tag_string(tagbuf, sizeof(tagbuf), st->codec->codec_tag);",
"av_get_codec_tag_string(cortag, sizeof(cortag), av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id));",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Tag %VAR_0/0x%08x incompatible with output codec id '%d' (%VAR_0)\\n\",\ntagbuf, st->codec->codec_tag, st->codec->codec_id, cortag);",
"VAR_2 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"}else",
"st->codec->codec_tag= av_codec_get_tag(VAR_0->oformat->codec_tag, st->codec->codec_id);",
"}",
"if(VAR_0->oformat->flags & AVFMT_GLOBALHEADER &&\n!(st->codec->flags & CODEC_FLAG_GLOBAL_HEADER))\nav_log(VAR_0, AV_LOG_WARNING, \"Codec for stream %d does not use global headers but container format requires global headers\\n\", VAR_3);",
"}",
"if (!VAR_0->priv_data && VAR_0->oformat->priv_data_size > 0) {",
"VAR_0->priv_data = av_mallocz(VAR_0->oformat->priv_data_size);",
"if (!VAR_0->priv_data) {",
"VAR_2 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"if (VAR_0->oformat->priv_class) {",
"*(const AVClass**)VAR_0->priv_data= VAR_0->oformat->priv_class;",
"av_opt_set_defaults(VAR_0->priv_data);",
"if ((VAR_2 = av_opt_set_dict(VAR_0->priv_data, &tmp)) < 0)\ngoto fail;",
"}",
"}",
"if (VAR_0->nb_streams && !(VAR_0->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {",
"av_dict_set(&VAR_0->metadata, \"encoder\", LIBAVFORMAT_IDENT, 0);",
"}",
"if(VAR_0->oformat->write_header){",
"VAR_2 = VAR_0->oformat->write_header(VAR_0);",
"if (VAR_2 < 0)\ngoto fail;",
"}",
"for(VAR_3=0;VAR_3<VAR_0->nb_streams;VAR_3++) {",
"int64_t den = AV_NOPTS_VALUE;",
"st = VAR_0->streams[VAR_3];",
"switch (st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nden = (int64_t)st->time_base.num * st->codec->sample_rate;",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nden = (int64_t)st->time_base.num * st->codec->time_base.den;",
"break;",
"default:\nbreak;",
"}",
"if (den != AV_NOPTS_VALUE) {",
"if (den <= 0) {",
"VAR_2 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"frac_init(&st->pts, 0, 0, den);",
"}",
"}",
"if (VAR_1) {",
"av_dict_free(VAR_1);",
"*VAR_1 = tmp;",
"}",
"return 0;",
"fail:\nav_dict_free(&tmp);",
"return VAR_2;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65,
67
],
[
69
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93,
95,
97
],
[
99,
101,
103,
105,
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143,
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161,
163,
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
201
],
[
203
],
[
205
],
[
209
],
[
211
],
[
213,
215
],
[
217
],
[
223
],
[
225
],
[
227
],
[
231
],
[
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
245,
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
]
]
|
17,168 | static int decode_slice_header(H264Context *h){
MpegEncContext * const s = &h->s;
int first_mb_in_slice, pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
int slice_type;
int default_ref_list_done = 0;
s->current_picture.reference= h->nal_ref_idc != 0;
s->dropable= h->nal_ref_idc == 0;
first_mb_in_slice= get_ue_golomb(&s->gb);
slice_type= get_ue_golomb(&s->gb);
if(slice_type > 9){
av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
return -1;
}
if(slice_type > 4){
slice_type -= 5;
h->slice_type_fixed=1;
}else
h->slice_type_fixed=0;
slice_type= slice_type_map[ slice_type ];
if (slice_type == I_TYPE
|| (h->slice_num != 0 && slice_type == h->slice_type) ) {
default_ref_list_done = 1;
}
h->slice_type= slice_type;
s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though
pps_id= get_ue_golomb(&s->gb);
if(pps_id>255){
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
h->pps= h->pps_buffer[pps_id];
if(h->pps.slice_group_count == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
return -1;
}
h->sps= h->sps_buffer[ h->pps.sps_id ];
if(h->sps.log2_max_frame_num == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
return -1;
}
if(h->dequant_coeff_pps != pps_id){
h->dequant_coeff_pps = pps_id;
init_dequant_tables(h);
}
s->mb_width= h->sps.mb_width;
s->mb_height= h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->b_stride= s->mb_width*4 + 1;
h->b8_stride= s->mb_width*2 + 1;
s->width = 16*s->mb_width - 2*(h->sps.crop_left + h->sps.crop_right );
if(h->sps.frame_mbs_only_flag)
s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom);
else
s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(h);
MPV_common_end(s);
}
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
if(s->dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly
memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t));
}else{
int i;
for(i=0; i<16; i++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
h->zigzag_scan[i] = T(zigzag_scan[i]);
h-> field_scan[i] = T( field_scan[i]);
}
}
if(h->sps.transform_bypass){ //FIXME same ugly
h->zigzag_scan_q0 = zigzag_scan;
h->field_scan_q0 = field_scan;
}else{
h->zigzag_scan_q0 = h->zigzag_scan;
h->field_scan_q0 = h->field_scan;
}
alloc_tables(h);
s->avctx->width = s->width;
s->avctx->height = s->height;
s->avctx->sample_aspect_ratio= h->sps.sar;
if(!s->avctx->sample_aspect_ratio.den)
s->avctx->sample_aspect_ratio.den = 1;
if(h->sps.timing_info_present_flag){
s->avctx->time_base= (AVRational){h->sps.num_units_in_tick, h->sps.time_scale};
}
}
if(h->slice_num == 0){
frame_start(h);
}
s->current_picture_ptr->frame_num= //FIXME frame_num cleanup
h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
h->mb_aff_frame = 0;
if(h->sps.frame_mbs_only_flag){
s->picture_structure= PICT_FRAME;
}else{
if(get_bits1(&s->gb)) { //field_pic_flag
s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag
} else {
s->picture_structure= PICT_FRAME;
first_mb_in_slice <<= h->sps.mb_aff;
h->mb_aff_frame = h->sps.mb_aff;
}
}
s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
s->resync_mb_y = s->mb_y = first_mb_in_slice / s->mb_width;
if(s->mb_y >= s->mb_height){
return -1;
}
if(s->picture_structure==PICT_FRAME){
h->curr_pic_num= h->frame_num;
h->max_pic_num= 1<< h->sps.log2_max_frame_num;
}else{
h->curr_pic_num= 2*h->frame_num;
h->max_pic_num= 1<<(h->sps.log2_max_frame_num + 1);
}
if(h->nal_unit_type == NAL_IDR_SLICE){
get_ue_golomb(&s->gb); /* idr_pic_id */
}
if(h->sps.poc_type==0){
h->poc_lsb= get_bits(&s->gb, h->sps.log2_max_poc_lsb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){
h->delta_poc_bottom= get_se_golomb(&s->gb);
}
}
if(h->sps.poc_type==1 && !h->sps.delta_pic_order_always_zero_flag){
h->delta_poc[0]= get_se_golomb(&s->gb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME)
h->delta_poc[1]= get_se_golomb(&s->gb);
}
init_poc(h);
if(h->pps.redundant_pic_cnt_present){
h->redundant_pic_count= get_ue_golomb(&s->gb);
}
//set defaults, might be overriden a few line later
h->ref_count[0]= h->pps.ref_count[0];
h->ref_count[1]= h->pps.ref_count[1];
if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){
if(h->slice_type == B_TYPE){
h->direct_spatial_mv_pred= get_bits1(&s->gb);
}
num_ref_idx_active_override_flag= get_bits1(&s->gb);
if(num_ref_idx_active_override_flag){
h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
if(h->slice_type==B_TYPE)
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
return -1;
}
}
}
if(!default_ref_list_done){
fill_default_ref_list(h);
}
if(decode_ref_pic_list_reordering(h) < 0)
return -1;
if( (h->pps.weighted_pred && (h->slice_type == P_TYPE || h->slice_type == SP_TYPE ))
|| (h->pps.weighted_bipred_idc==1 && h->slice_type==B_TYPE ) )
pred_weight_table(h);
else if(h->pps.weighted_bipred_idc==2 && h->slice_type==B_TYPE)
implicit_weight_table(h);
else
h->use_weight = 0;
if(s->current_picture.reference)
decode_ref_pic_marking(h);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac )
h->cabac_init_idc = get_ue_golomb(&s->gb);
h->last_qscale_diff = 0;
s->qscale = h->pps.init_qp + get_se_golomb(&s->gb);
if(s->qscale<0 || s->qscale>51){
av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
return -1;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
//FIXME qscale / qp ... stuff
if(h->slice_type == SP_TYPE){
get_bits1(&s->gb); /* sp_for_switch_flag */
}
if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){
get_se_golomb(&s->gb); /* slice_qs_delta */
}
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if( h->pps.deblocking_filter_parameters_present ) {
h->deblocking_filter= get_ue_golomb(&s->gb);
if(h->deblocking_filter < 2)
h->deblocking_filter^= 1; // 1<->0
if( h->deblocking_filter ) {
h->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1;
h->slice_beta_offset = get_se_golomb(&s->gb) << 1;
}
}
if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != I_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == B_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
h->deblocking_filter= 0;
#if 0 //FMO
if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
slice_group_change_cycle= get_bits(&s->gb, ?);
#endif
h->slice_num++;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
h->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_pict_type_char(h->slice_type),
pps_id, h->frame_num,
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1],
s->qscale,
h->deblocking_filter, h->slice_alpha_c0_offset/2, h->slice_beta_offset/2,
h->use_weight,
h->use_weight==1 && h->use_weight_chroma ? "c" : ""
);
}
return 0;
}
| false | FFmpeg | af8aa846fa5b9f2c7dcde451c872426528b8b561 | static int decode_slice_header(H264Context *h){
MpegEncContext * const s = &h->s;
int first_mb_in_slice, pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
int slice_type;
int default_ref_list_done = 0;
s->current_picture.reference= h->nal_ref_idc != 0;
s->dropable= h->nal_ref_idc == 0;
first_mb_in_slice= get_ue_golomb(&s->gb);
slice_type= get_ue_golomb(&s->gb);
if(slice_type > 9){
av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
return -1;
}
if(slice_type > 4){
slice_type -= 5;
h->slice_type_fixed=1;
}else
h->slice_type_fixed=0;
slice_type= slice_type_map[ slice_type ];
if (slice_type == I_TYPE
|| (h->slice_num != 0 && slice_type == h->slice_type) ) {
default_ref_list_done = 1;
}
h->slice_type= slice_type;
s->pict_type= h->slice_type;
pps_id= get_ue_golomb(&s->gb);
if(pps_id>255){
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
h->pps= h->pps_buffer[pps_id];
if(h->pps.slice_group_count == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
return -1;
}
h->sps= h->sps_buffer[ h->pps.sps_id ];
if(h->sps.log2_max_frame_num == 0){
av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
return -1;
}
if(h->dequant_coeff_pps != pps_id){
h->dequant_coeff_pps = pps_id;
init_dequant_tables(h);
}
s->mb_width= h->sps.mb_width;
s->mb_height= h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
h->b_stride= s->mb_width*4 + 1;
h->b8_stride= s->mb_width*2 + 1;
s->width = 16*s->mb_width - 2*(h->sps.crop_left + h->sps.crop_right );
if(h->sps.frame_mbs_only_flag)
s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom);
else
s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom);
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(h);
MPV_common_end(s);
}
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
if(s->dsp.h264_idct_add == ff_h264_idct_add_c){
memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t));
}else{
int i;
for(i=0; i<16; i++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
h->zigzag_scan[i] = T(zigzag_scan[i]);
h-> field_scan[i] = T( field_scan[i]);
}
}
if(h->sps.transform_bypass){
h->zigzag_scan_q0 = zigzag_scan;
h->field_scan_q0 = field_scan;
}else{
h->zigzag_scan_q0 = h->zigzag_scan;
h->field_scan_q0 = h->field_scan;
}
alloc_tables(h);
s->avctx->width = s->width;
s->avctx->height = s->height;
s->avctx->sample_aspect_ratio= h->sps.sar;
if(!s->avctx->sample_aspect_ratio.den)
s->avctx->sample_aspect_ratio.den = 1;
if(h->sps.timing_info_present_flag){
s->avctx->time_base= (AVRational){h->sps.num_units_in_tick, h->sps.time_scale};
}
}
if(h->slice_num == 0){
frame_start(h);
}
s->current_picture_ptr->frame_num=
h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
h->mb_aff_frame = 0;
if(h->sps.frame_mbs_only_flag){
s->picture_structure= PICT_FRAME;
}else{
if(get_bits1(&s->gb)) {
s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb);
} else {
s->picture_structure= PICT_FRAME;
first_mb_in_slice <<= h->sps.mb_aff;
h->mb_aff_frame = h->sps.mb_aff;
}
}
s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
s->resync_mb_y = s->mb_y = first_mb_in_slice / s->mb_width;
if(s->mb_y >= s->mb_height){
return -1;
}
if(s->picture_structure==PICT_FRAME){
h->curr_pic_num= h->frame_num;
h->max_pic_num= 1<< h->sps.log2_max_frame_num;
}else{
h->curr_pic_num= 2*h->frame_num;
h->max_pic_num= 1<<(h->sps.log2_max_frame_num + 1);
}
if(h->nal_unit_type == NAL_IDR_SLICE){
get_ue_golomb(&s->gb);
}
if(h->sps.poc_type==0){
h->poc_lsb= get_bits(&s->gb, h->sps.log2_max_poc_lsb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){
h->delta_poc_bottom= get_se_golomb(&s->gb);
}
}
if(h->sps.poc_type==1 && !h->sps.delta_pic_order_always_zero_flag){
h->delta_poc[0]= get_se_golomb(&s->gb);
if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME)
h->delta_poc[1]= get_se_golomb(&s->gb);
}
init_poc(h);
if(h->pps.redundant_pic_cnt_present){
h->redundant_pic_count= get_ue_golomb(&s->gb);
}
h->ref_count[0]= h->pps.ref_count[0];
h->ref_count[1]= h->pps.ref_count[1];
if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){
if(h->slice_type == B_TYPE){
h->direct_spatial_mv_pred= get_bits1(&s->gb);
}
num_ref_idx_active_override_flag= get_bits1(&s->gb);
if(num_ref_idx_active_override_flag){
h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
if(h->slice_type==B_TYPE)
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
return -1;
}
}
}
if(!default_ref_list_done){
fill_default_ref_list(h);
}
if(decode_ref_pic_list_reordering(h) < 0)
return -1;
if( (h->pps.weighted_pred && (h->slice_type == P_TYPE || h->slice_type == SP_TYPE ))
|| (h->pps.weighted_bipred_idc==1 && h->slice_type==B_TYPE ) )
pred_weight_table(h);
else if(h->pps.weighted_bipred_idc==2 && h->slice_type==B_TYPE)
implicit_weight_table(h);
else
h->use_weight = 0;
if(s->current_picture.reference)
decode_ref_pic_marking(h);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac )
h->cabac_init_idc = get_ue_golomb(&s->gb);
h->last_qscale_diff = 0;
s->qscale = h->pps.init_qp + get_se_golomb(&s->gb);
if(s->qscale<0 || s->qscale>51){
av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
return -1;
}
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
if(h->slice_type == SP_TYPE){
get_bits1(&s->gb);
}
if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){
get_se_golomb(&s->gb);
}
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if( h->pps.deblocking_filter_parameters_present ) {
h->deblocking_filter= get_ue_golomb(&s->gb);
if(h->deblocking_filter < 2)
h->deblocking_filter^= 1;
if( h->deblocking_filter ) {
h->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1;
h->slice_beta_offset = get_se_golomb(&s->gb) << 1;
}
}
if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != I_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == B_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
h->deblocking_filter= 0;
#if 0
if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
slice_group_change_cycle= get_bits(&s->gb, ?);
#endif
h->slice_num++;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
h->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_pict_type_char(h->slice_type),
pps_id, h->frame_num,
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1],
s->qscale,
h->deblocking_filter, h->slice_alpha_c0_offset/2, h->slice_beta_offset/2,
h->use_weight,
h->use_weight==1 && h->use_weight_chroma ? "c" : ""
);
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(H264Context *VAR_0){
MpegEncContext * const s = &VAR_0->s;
int VAR_1, VAR_2;
int VAR_3;
static const uint8_t VAR_4[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
int VAR_5;
int VAR_6 = 0;
s->current_picture.reference= VAR_0->nal_ref_idc != 0;
s->dropable= VAR_0->nal_ref_idc == 0;
VAR_1= get_ue_golomb(&s->gb);
VAR_5= get_ue_golomb(&s->gb);
if(VAR_5 > 9){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", VAR_0->VAR_5, s->mb_x, s->mb_y);
return -1;
}
if(VAR_5 > 4){
VAR_5 -= 5;
VAR_0->slice_type_fixed=1;
}else
VAR_0->slice_type_fixed=0;
VAR_5= VAR_4[ VAR_5 ];
if (VAR_5 == I_TYPE
|| (VAR_0->slice_num != 0 && VAR_5 == VAR_0->VAR_5) ) {
VAR_6 = 1;
}
VAR_0->VAR_5= VAR_5;
s->pict_type= VAR_0->VAR_5;
VAR_2= get_ue_golomb(&s->gb);
if(VAR_2>255){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "VAR_2 out of range\n");
return -1;
}
VAR_0->pps= VAR_0->pps_buffer[VAR_2];
if(VAR_0->pps.slice_group_count == 0){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
return -1;
}
VAR_0->sps= VAR_0->sps_buffer[ VAR_0->pps.sps_id ];
if(VAR_0->sps.log2_max_frame_num == 0){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
return -1;
}
if(VAR_0->dequant_coeff_pps != VAR_2){
VAR_0->dequant_coeff_pps = VAR_2;
init_dequant_tables(VAR_0);
}
s->mb_width= VAR_0->sps.mb_width;
s->mb_height= VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag);
VAR_0->b_stride= s->mb_width*4 + 1;
VAR_0->b8_stride= s->mb_width*2 + 1;
s->width = 16*s->mb_width - 2*(VAR_0->sps.crop_left + VAR_0->sps.crop_right );
if(VAR_0->sps.frame_mbs_only_flag)
s->height= 16*s->mb_height - 2*(VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);
else
s->height= 16*s->mb_height - 4*(VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height)) {
free_tables(VAR_0);
MPV_common_end(s);
}
if (!s->context_initialized) {
if (MPV_common_init(s) < 0)
return -1;
if(s->dsp.h264_idct_add == ff_h264_idct_add_c){
memcpy(VAR_0->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
memcpy(VAR_0-> field_scan, field_scan, 16*sizeof(uint8_t));
}else{
int VAR_7;
for(VAR_7=0; VAR_7<16; VAR_7++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
VAR_0->zigzag_scan[VAR_7] = T(zigzag_scan[VAR_7]);
VAR_0-> field_scan[VAR_7] = T( field_scan[VAR_7]);
}
}
if(VAR_0->sps.transform_bypass){
VAR_0->zigzag_scan_q0 = zigzag_scan;
VAR_0->field_scan_q0 = field_scan;
}else{
VAR_0->zigzag_scan_q0 = VAR_0->zigzag_scan;
VAR_0->field_scan_q0 = VAR_0->field_scan;
}
alloc_tables(VAR_0);
s->avctx->width = s->width;
s->avctx->height = s->height;
s->avctx->sample_aspect_ratio= VAR_0->sps.sar;
if(!s->avctx->sample_aspect_ratio.den)
s->avctx->sample_aspect_ratio.den = 1;
if(VAR_0->sps.timing_info_present_flag){
s->avctx->time_base= (AVRational){VAR_0->sps.num_units_in_tick, VAR_0->sps.time_scale};
}
}
if(VAR_0->slice_num == 0){
frame_start(VAR_0);
}
s->current_picture_ptr->frame_num=
VAR_0->frame_num= get_bits(&s->gb, VAR_0->sps.log2_max_frame_num);
VAR_0->mb_aff_frame = 0;
if(VAR_0->sps.frame_mbs_only_flag){
s->picture_structure= PICT_FRAME;
}else{
if(get_bits1(&s->gb)) {
s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb);
} else {
s->picture_structure= PICT_FRAME;
VAR_1 <<= VAR_0->sps.mb_aff;
VAR_0->mb_aff_frame = VAR_0->sps.mb_aff;
}
}
s->resync_mb_x = s->mb_x = VAR_1 % s->mb_width;
s->resync_mb_y = s->mb_y = VAR_1 / s->mb_width;
if(s->mb_y >= s->mb_height){
return -1;
}
if(s->picture_structure==PICT_FRAME){
VAR_0->curr_pic_num= VAR_0->frame_num;
VAR_0->max_pic_num= 1<< VAR_0->sps.log2_max_frame_num;
}else{
VAR_0->curr_pic_num= 2*VAR_0->frame_num;
VAR_0->max_pic_num= 1<<(VAR_0->sps.log2_max_frame_num + 1);
}
if(VAR_0->nal_unit_type == NAL_IDR_SLICE){
get_ue_golomb(&s->gb);
}
if(VAR_0->sps.poc_type==0){
VAR_0->poc_lsb= get_bits(&s->gb, VAR_0->sps.log2_max_poc_lsb);
if(VAR_0->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){
VAR_0->delta_poc_bottom= get_se_golomb(&s->gb);
}
}
if(VAR_0->sps.poc_type==1 && !VAR_0->sps.delta_pic_order_always_zero_flag){
VAR_0->delta_poc[0]= get_se_golomb(&s->gb);
if(VAR_0->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME)
VAR_0->delta_poc[1]= get_se_golomb(&s->gb);
}
init_poc(VAR_0);
if(VAR_0->pps.redundant_pic_cnt_present){
VAR_0->redundant_pic_count= get_ue_golomb(&s->gb);
}
VAR_0->ref_count[0]= VAR_0->pps.ref_count[0];
VAR_0->ref_count[1]= VAR_0->pps.ref_count[1];
if(VAR_0->VAR_5 == P_TYPE || VAR_0->VAR_5 == SP_TYPE || VAR_0->VAR_5 == B_TYPE){
if(VAR_0->VAR_5 == B_TYPE){
VAR_0->direct_spatial_mv_pred= get_bits1(&s->gb);
}
VAR_3= get_bits1(&s->gb);
if(VAR_3){
VAR_0->ref_count[0]= get_ue_golomb(&s->gb) + 1;
if(VAR_0->VAR_5==B_TYPE)
VAR_0->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(VAR_0->ref_count[0] > 32 || VAR_0->ref_count[1] > 32){
av_log(VAR_0->s.avctx, AV_LOG_ERROR, "reference overflow\n");
return -1;
}
}
}
if(!VAR_6){
fill_default_ref_list(VAR_0);
}
if(decode_ref_pic_list_reordering(VAR_0) < 0)
return -1;
if( (VAR_0->pps.weighted_pred && (VAR_0->VAR_5 == P_TYPE || VAR_0->VAR_5 == SP_TYPE ))
|| (VAR_0->pps.weighted_bipred_idc==1 && VAR_0->VAR_5==B_TYPE ) )
pred_weight_table(VAR_0);
else if(VAR_0->pps.weighted_bipred_idc==2 && VAR_0->VAR_5==B_TYPE)
implicit_weight_table(VAR_0);
else
VAR_0->use_weight = 0;
if(s->current_picture.reference)
decode_ref_pic_marking(VAR_0);
if( VAR_0->VAR_5 != I_TYPE && VAR_0->VAR_5 != SI_TYPE && VAR_0->pps.cabac )
VAR_0->cabac_init_idc = get_ue_golomb(&s->gb);
VAR_0->last_qscale_diff = 0;
s->qscale = VAR_0->pps.init_qp + get_se_golomb(&s->gb);
if(s->qscale<0 || s->qscale>51){
av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
return -1;
}
VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, s->qscale);
if(VAR_0->VAR_5 == SP_TYPE){
get_bits1(&s->gb);
}
if(VAR_0->VAR_5==SP_TYPE || VAR_0->VAR_5 == SI_TYPE){
get_se_golomb(&s->gb);
}
VAR_0->deblocking_filter = 1;
VAR_0->slice_alpha_c0_offset = 0;
VAR_0->slice_beta_offset = 0;
if( VAR_0->pps.deblocking_filter_parameters_present ) {
VAR_0->deblocking_filter= get_ue_golomb(&s->gb);
if(VAR_0->deblocking_filter < 2)
VAR_0->deblocking_filter^= 1;
if( VAR_0->deblocking_filter ) {
VAR_0->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1;
VAR_0->slice_beta_offset = get_se_golomb(&s->gb) << 1;
}
}
if( s->avctx->skip_loop_filter >= AVDISCARD_ALL
||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && VAR_0->VAR_5 != I_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && VAR_0->VAR_5 == B_TYPE)
||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && VAR_0->nal_ref_idc == 0))
VAR_0->deblocking_filter= 0;
#if 0
if( VAR_0->pps.num_slice_groups > 1 && VAR_0->pps.mb_slice_group_map_type >= 3 && VAR_0->pps.mb_slice_group_map_type <= 5)
slice_group_change_cycle= get_bits(&s->gb, ?);
#endif
VAR_0->slice_num++;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
VAR_0->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
VAR_1,
av_get_pict_type_char(VAR_0->VAR_5),
VAR_2, VAR_0->frame_num,
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
VAR_0->ref_count[0], VAR_0->ref_count[1],
s->qscale,
VAR_0->deblocking_filter, VAR_0->slice_alpha_c0_offset/2, VAR_0->slice_beta_offset/2,
VAR_0->use_weight,
VAR_0->use_weight==1 && VAR_0->use_weight_chroma ? "c" : ""
);
}
return 0;
}
| [
"static int FUNC_0(H264Context *VAR_0){",
"MpegEncContext * const s = &VAR_0->s;",
"int VAR_1, VAR_2;",
"int VAR_3;",
"static const uint8_t VAR_4[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};",
"int VAR_5;",
"int VAR_6 = 0;",
"s->current_picture.reference= VAR_0->nal_ref_idc != 0;",
"s->dropable= VAR_0->nal_ref_idc == 0;",
"VAR_1= get_ue_golomb(&s->gb);",
"VAR_5= get_ue_golomb(&s->gb);",
"if(VAR_5 > 9){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"slice type too large (%d) at %d %d\\n\", VAR_0->VAR_5, s->mb_x, s->mb_y);",
"return -1;",
"}",
"if(VAR_5 > 4){",
"VAR_5 -= 5;",
"VAR_0->slice_type_fixed=1;",
"}else",
"VAR_0->slice_type_fixed=0;",
"VAR_5= VAR_4[ VAR_5 ];",
"if (VAR_5 == I_TYPE\n|| (VAR_0->slice_num != 0 && VAR_5 == VAR_0->VAR_5) ) {",
"VAR_6 = 1;",
"}",
"VAR_0->VAR_5= VAR_5;",
"s->pict_type= VAR_0->VAR_5;",
"VAR_2= get_ue_golomb(&s->gb);",
"if(VAR_2>255){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"VAR_2 out of range\\n\");",
"return -1;",
"}",
"VAR_0->pps= VAR_0->pps_buffer[VAR_2];",
"if(VAR_0->pps.slice_group_count == 0){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"non existing PPS referenced\\n\");",
"return -1;",
"}",
"VAR_0->sps= VAR_0->sps_buffer[ VAR_0->pps.sps_id ];",
"if(VAR_0->sps.log2_max_frame_num == 0){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"non existing SPS referenced\\n\");",
"return -1;",
"}",
"if(VAR_0->dequant_coeff_pps != VAR_2){",
"VAR_0->dequant_coeff_pps = VAR_2;",
"init_dequant_tables(VAR_0);",
"}",
"s->mb_width= VAR_0->sps.mb_width;",
"s->mb_height= VAR_0->sps.mb_height * (2 - VAR_0->sps.frame_mbs_only_flag);",
"VAR_0->b_stride= s->mb_width*4 + 1;",
"VAR_0->b8_stride= s->mb_width*2 + 1;",
"s->width = 16*s->mb_width - 2*(VAR_0->sps.crop_left + VAR_0->sps.crop_right );",
"if(VAR_0->sps.frame_mbs_only_flag)\ns->height= 16*s->mb_height - 2*(VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);",
"else\ns->height= 16*s->mb_height - 4*(VAR_0->sps.crop_top + VAR_0->sps.crop_bottom);",
"if (s->context_initialized\n&& ( s->width != s->avctx->width || s->height != s->avctx->height)) {",
"free_tables(VAR_0);",
"MPV_common_end(s);",
"}",
"if (!s->context_initialized) {",
"if (MPV_common_init(s) < 0)\nreturn -1;",
"if(s->dsp.h264_idct_add == ff_h264_idct_add_c){",
"memcpy(VAR_0->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));",
"memcpy(VAR_0-> field_scan, field_scan, 16*sizeof(uint8_t));",
"}else{",
"int VAR_7;",
"for(VAR_7=0; VAR_7<16; VAR_7++){",
"#define T(x) (x>>2) | ((x<<2) & 0xF)\nVAR_0->zigzag_scan[VAR_7] = T(zigzag_scan[VAR_7]);",
"VAR_0-> field_scan[VAR_7] = T( field_scan[VAR_7]);",
"}",
"}",
"if(VAR_0->sps.transform_bypass){",
"VAR_0->zigzag_scan_q0 = zigzag_scan;",
"VAR_0->field_scan_q0 = field_scan;",
"}else{",
"VAR_0->zigzag_scan_q0 = VAR_0->zigzag_scan;",
"VAR_0->field_scan_q0 = VAR_0->field_scan;",
"}",
"alloc_tables(VAR_0);",
"s->avctx->width = s->width;",
"s->avctx->height = s->height;",
"s->avctx->sample_aspect_ratio= VAR_0->sps.sar;",
"if(!s->avctx->sample_aspect_ratio.den)\ns->avctx->sample_aspect_ratio.den = 1;",
"if(VAR_0->sps.timing_info_present_flag){",
"s->avctx->time_base= (AVRational){VAR_0->sps.num_units_in_tick, VAR_0->sps.time_scale};",
"}",
"}",
"if(VAR_0->slice_num == 0){",
"frame_start(VAR_0);",
"}",
"s->current_picture_ptr->frame_num=\nVAR_0->frame_num= get_bits(&s->gb, VAR_0->sps.log2_max_frame_num);",
"VAR_0->mb_aff_frame = 0;",
"if(VAR_0->sps.frame_mbs_only_flag){",
"s->picture_structure= PICT_FRAME;",
"}else{",
"if(get_bits1(&s->gb)) {",
"s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb);",
"} else {",
"s->picture_structure= PICT_FRAME;",
"VAR_1 <<= VAR_0->sps.mb_aff;",
"VAR_0->mb_aff_frame = VAR_0->sps.mb_aff;",
"}",
"}",
"s->resync_mb_x = s->mb_x = VAR_1 % s->mb_width;",
"s->resync_mb_y = s->mb_y = VAR_1 / s->mb_width;",
"if(s->mb_y >= s->mb_height){",
"return -1;",
"}",
"if(s->picture_structure==PICT_FRAME){",
"VAR_0->curr_pic_num= VAR_0->frame_num;",
"VAR_0->max_pic_num= 1<< VAR_0->sps.log2_max_frame_num;",
"}else{",
"VAR_0->curr_pic_num= 2*VAR_0->frame_num;",
"VAR_0->max_pic_num= 1<<(VAR_0->sps.log2_max_frame_num + 1);",
"}",
"if(VAR_0->nal_unit_type == NAL_IDR_SLICE){",
"get_ue_golomb(&s->gb);",
"}",
"if(VAR_0->sps.poc_type==0){",
"VAR_0->poc_lsb= get_bits(&s->gb, VAR_0->sps.log2_max_poc_lsb);",
"if(VAR_0->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){",
"VAR_0->delta_poc_bottom= get_se_golomb(&s->gb);",
"}",
"}",
"if(VAR_0->sps.poc_type==1 && !VAR_0->sps.delta_pic_order_always_zero_flag){",
"VAR_0->delta_poc[0]= get_se_golomb(&s->gb);",
"if(VAR_0->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME)\nVAR_0->delta_poc[1]= get_se_golomb(&s->gb);",
"}",
"init_poc(VAR_0);",
"if(VAR_0->pps.redundant_pic_cnt_present){",
"VAR_0->redundant_pic_count= get_ue_golomb(&s->gb);",
"}",
"VAR_0->ref_count[0]= VAR_0->pps.ref_count[0];",
"VAR_0->ref_count[1]= VAR_0->pps.ref_count[1];",
"if(VAR_0->VAR_5 == P_TYPE || VAR_0->VAR_5 == SP_TYPE || VAR_0->VAR_5 == B_TYPE){",
"if(VAR_0->VAR_5 == B_TYPE){",
"VAR_0->direct_spatial_mv_pred= get_bits1(&s->gb);",
"}",
"VAR_3= get_bits1(&s->gb);",
"if(VAR_3){",
"VAR_0->ref_count[0]= get_ue_golomb(&s->gb) + 1;",
"if(VAR_0->VAR_5==B_TYPE)\nVAR_0->ref_count[1]= get_ue_golomb(&s->gb) + 1;",
"if(VAR_0->ref_count[0] > 32 || VAR_0->ref_count[1] > 32){",
"av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"reference overflow\\n\");",
"return -1;",
"}",
"}",
"}",
"if(!VAR_6){",
"fill_default_ref_list(VAR_0);",
"}",
"if(decode_ref_pic_list_reordering(VAR_0) < 0)\nreturn -1;",
"if( (VAR_0->pps.weighted_pred && (VAR_0->VAR_5 == P_TYPE || VAR_0->VAR_5 == SP_TYPE ))\n|| (VAR_0->pps.weighted_bipred_idc==1 && VAR_0->VAR_5==B_TYPE ) )\npred_weight_table(VAR_0);",
"else if(VAR_0->pps.weighted_bipred_idc==2 && VAR_0->VAR_5==B_TYPE)\nimplicit_weight_table(VAR_0);",
"else\nVAR_0->use_weight = 0;",
"if(s->current_picture.reference)\ndecode_ref_pic_marking(VAR_0);",
"if( VAR_0->VAR_5 != I_TYPE && VAR_0->VAR_5 != SI_TYPE && VAR_0->pps.cabac )\nVAR_0->cabac_init_idc = get_ue_golomb(&s->gb);",
"VAR_0->last_qscale_diff = 0;",
"s->qscale = VAR_0->pps.init_qp + get_se_golomb(&s->gb);",
"if(s->qscale<0 || s->qscale>51){",
"av_log(s->avctx, AV_LOG_ERROR, \"QP %d out of range\\n\", s->qscale);",
"return -1;",
"}",
"VAR_0->chroma_qp = get_chroma_qp(VAR_0->pps.chroma_qp_index_offset, s->qscale);",
"if(VAR_0->VAR_5 == SP_TYPE){",
"get_bits1(&s->gb);",
"}",
"if(VAR_0->VAR_5==SP_TYPE || VAR_0->VAR_5 == SI_TYPE){",
"get_se_golomb(&s->gb);",
"}",
"VAR_0->deblocking_filter = 1;",
"VAR_0->slice_alpha_c0_offset = 0;",
"VAR_0->slice_beta_offset = 0;",
"if( VAR_0->pps.deblocking_filter_parameters_present ) {",
"VAR_0->deblocking_filter= get_ue_golomb(&s->gb);",
"if(VAR_0->deblocking_filter < 2)\nVAR_0->deblocking_filter^= 1;",
"if( VAR_0->deblocking_filter ) {",
"VAR_0->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1;",
"VAR_0->slice_beta_offset = get_se_golomb(&s->gb) << 1;",
"}",
"}",
"if( s->avctx->skip_loop_filter >= AVDISCARD_ALL\n||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && VAR_0->VAR_5 != I_TYPE)\n||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && VAR_0->VAR_5 == B_TYPE)\n||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && VAR_0->nal_ref_idc == 0))\nVAR_0->deblocking_filter= 0;",
"#if 0\nif( VAR_0->pps.num_slice_groups > 1 && VAR_0->pps.mb_slice_group_map_type >= 3 && VAR_0->pps.mb_slice_group_map_type <= 5)\nslice_group_change_cycle= get_bits(&s->gb, ?);",
"#endif\nVAR_0->slice_num++;",
"if(s->avctx->debug&FF_DEBUG_PICT_INFO){",
"av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\\n\",\nVAR_0->slice_num,\n(s->picture_structure==PICT_FRAME ? \"F\" : s->picture_structure==PICT_TOP_FIELD ? \"T\" : \"B\"),\nVAR_1,\nav_get_pict_type_char(VAR_0->VAR_5),\nVAR_2, VAR_0->frame_num,\ns->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],\nVAR_0->ref_count[0], VAR_0->ref_count[1],\ns->qscale,\nVAR_0->deblocking_filter, VAR_0->slice_alpha_c0_offset/2, VAR_0->slice_beta_offset/2,\nVAR_0->use_weight,\nVAR_0->use_weight==1 && VAR_0->use_weight_chroma ? \"c\" : \"\"\n);",
"}",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
123
],
[
125,
127
],
[
129,
131
],
[
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
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201,
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
217
],
[
219
],
[
221
],
[
225,
227
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285
],
[
287
],
[
289
],
[
293
],
[
295
],
[
299
],
[
301
],
[
303
],
[
305
],
[
309
],
[
311
],
[
315,
317
],
[
319
],
[
323
],
[
327
],
[
329
],
[
331
],
[
337
],
[
339
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359,
361
],
[
365
],
[
367
],
[
369
],
[
371
],
[
373
],
[
375
],
[
379
],
[
381
],
[
383
],
[
387,
389
],
[
393,
395,
397
],
[
399,
401
],
[
403,
405
],
[
409,
411
],
[
415,
417
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461,
463
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477,
479,
481,
483,
485
],
[
489,
491,
493
],
[
495,
499
],
[
503
],
[
505,
507,
509,
511,
513,
515,
517,
519,
521,
523,
525,
527,
529
],
[
531
],
[
535
],
[
537
]
]
|
17,169 | void ff_put_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 0);
}
| false | FFmpeg | e549933a270dd2cfc36f2cf9bb6b29acf3dc6d08 | void ff_put_h264_qpel8_mc12_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 0);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_midh_qrt_8w_msa(VAR_1 - (2 * VAR_2) - 2, VAR_2, VAR_0, VAR_2, 8, 0);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_midh_qrt_8w_msa(VAR_1 - (2 * VAR_2) - 2, VAR_2, VAR_0, VAR_2, 8, 0);",
"}"
]
| [
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
]
]
|
17,170 | static void become_daemon(const char *pidfile)
{
#ifndef _WIN32
pid_t pid, sid;
pid = fork();
if (pid < 0) {
exit(EXIT_FAILURE);
}
if (pid > 0) {
exit(EXIT_SUCCESS);
}
if (pidfile) {
if (!ga_open_pidfile(pidfile)) {
g_critical("failed to create pidfile");
exit(EXIT_FAILURE);
}
}
umask(0);
sid = setsid();
if (sid < 0) {
goto fail;
}
if ((chdir("/")) < 0) {
goto fail;
}
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
return;
fail:
unlink(pidfile);
g_critical("failed to daemonize");
exit(EXIT_FAILURE);
#endif
}
| true | qemu | 226a48949cf74006a94b5931e50352b2af801ac7 | static void become_daemon(const char *pidfile)
{
#ifndef _WIN32
pid_t pid, sid;
pid = fork();
if (pid < 0) {
exit(EXIT_FAILURE);
}
if (pid > 0) {
exit(EXIT_SUCCESS);
}
if (pidfile) {
if (!ga_open_pidfile(pidfile)) {
g_critical("failed to create pidfile");
exit(EXIT_FAILURE);
}
}
umask(0);
sid = setsid();
if (sid < 0) {
goto fail;
}
if ((chdir("/")) < 0) {
goto fail;
}
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
return;
fail:
unlink(pidfile);
g_critical("failed to daemonize");
exit(EXIT_FAILURE);
#endif
}
| {
"code": [
" close(STDIN_FILENO);",
" close(STDOUT_FILENO);",
" close(STDERR_FILENO);"
],
"line_no": [
59,
61,
63
]
} | static void FUNC_0(const char *VAR_0)
{
#ifndef _WIN32
pid_t pid, sid;
pid = fork();
if (pid < 0) {
exit(EXIT_FAILURE);
}
if (pid > 0) {
exit(EXIT_SUCCESS);
}
if (VAR_0) {
if (!ga_open_pidfile(VAR_0)) {
g_critical("failed to create VAR_0");
exit(EXIT_FAILURE);
}
}
umask(0);
sid = setsid();
if (sid < 0) {
goto fail;
}
if ((chdir("/")) < 0) {
goto fail;
}
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
return;
fail:
unlink(VAR_0);
g_critical("failed to daemonize");
exit(EXIT_FAILURE);
#endif
}
| [
"static void FUNC_0(const char *VAR_0)\n{",
"#ifndef _WIN32\npid_t pid, sid;",
"pid = fork();",
"if (pid < 0) {",
"exit(EXIT_FAILURE);",
"}",
"if (pid > 0) {",
"exit(EXIT_SUCCESS);",
"}",
"if (VAR_0) {",
"if (!ga_open_pidfile(VAR_0)) {",
"g_critical(\"failed to create VAR_0\");",
"exit(EXIT_FAILURE);",
"}",
"}",
"umask(0);",
"sid = setsid();",
"if (sid < 0) {",
"goto fail;",
"}",
"if ((chdir(\"/\")) < 0) {",
"goto fail;",
"}",
"close(STDIN_FILENO);",
"close(STDOUT_FILENO);",
"close(STDERR_FILENO);",
"return;",
"fail:\nunlink(VAR_0);",
"g_critical(\"failed to daemonize\");",
"exit(EXIT_FAILURE);",
"#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,
1,
1,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5,
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
75
],
[
77,
79
]
]
|
17,171 | static int msvideo1_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Msvideo1Context *s = avctx->priv_data;
int ret;
s->buf = buf;
s->size = buf_size;
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (s->mode_8bit) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
memcpy(s->pal, pal, AVPALETTE_SIZE);
s->frame->palette_has_changed = 1;
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
if (s->mode_8bit)
msvideo1_decode_8bit(s);
else
msvideo1_decode_16bit(s);
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
/* report that the buffer was completely consumed */
return buf_size; | true | FFmpeg | cabfed6895fcc679cd6a6244a12d800e0f3f2d20 | static int msvideo1_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
Msvideo1Context *s = avctx->priv_data;
int ret;
s->buf = buf;
s->size = buf_size;
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (s->mode_8bit) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
memcpy(s->pal, pal, AVPALETTE_SIZE);
s->frame->palette_has_changed = 1;
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
if (s->mode_8bit)
msvideo1_decode_8bit(s);
else
msvideo1_decode_16bit(s);
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
return buf_size; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->VAR_7;
Msvideo1Context *s = VAR_0->priv_data;
int VAR_6;
s->VAR_4 = VAR_4;
s->VAR_7 = VAR_5;
if ((VAR_6 = ff_reget_buffer(VAR_0, s->frame)) < 0)
return VAR_6;
if (s->mode_8bit) {
int VAR_7;
const uint8_t *VAR_8 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_7);
if (VAR_8 && VAR_7 == AVPALETTE_SIZE) {
memcpy(s->VAR_8, VAR_8, AVPALETTE_SIZE);
s->frame->palette_has_changed = 1;
} else if (VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Palette VAR_7 %d is wrong\n", VAR_7);
if (s->mode_8bit)
msvideo1_decode_8bit(s);
else
msvideo1_decode_16bit(s);
if ((VAR_6 = av_frame_ref(VAR_1, s->frame)) < 0)
return VAR_6;
*VAR_2 = 1;
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->VAR_7;",
"Msvideo1Context *s = VAR_0->priv_data;",
"int VAR_6;",
"s->VAR_4 = VAR_4;",
"s->VAR_7 = VAR_5;",
"if ((VAR_6 = ff_reget_buffer(VAR_0, s->frame)) < 0)\nreturn VAR_6;",
"if (s->mode_8bit) {",
"int VAR_7;",
"const uint8_t *VAR_8 = av_packet_get_side_data(VAR_3, AV_PKT_DATA_PALETTE, &VAR_7);",
"if (VAR_8 && VAR_7 == AVPALETTE_SIZE) {",
"memcpy(s->VAR_8, VAR_8, AVPALETTE_SIZE);",
"s->frame->palette_has_changed = 1;",
"} else if (VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Palette VAR_7 %d is wrong\\n\", VAR_7);",
"if (s->mode_8bit)\nmsvideo1_decode_8bit(s);",
"else\nmsvideo1_decode_16bit(s);",
"if ((VAR_6 = av_frame_ref(VAR_1, s->frame)) < 0)\nreturn VAR_6;",
"*VAR_2 = 1;",
"return VAR_5;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2,
3,
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11,
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21,
22
],
[
23,
24
],
[
25,
26
],
[
27
],
[
29
]
]
|
17,173 | void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0xF800)>>8;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0x1F)<<3;
}
}
| {
"code": [
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0xF800)>>8;",
"\t\t*d++ = (bgr&0x7E0)>>3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x7E0)>>3;",
"\t\t*d++ = (bgr&0xF800)>>8;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tconst uint16_t *s = (const uint16_t *)src;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\tconst uint16_t *end;",
"\tuint8_t *d = (uint8_t *)dst;",
"\tend = s + src_size/2;",
"\twhile(s < end)",
"\t\tregister uint16_t bgr;",
"\t\tbgr = *s++;",
"\t\t*d++ = (bgr&0xF800)>>8;",
"\t\t*d++ = (bgr&0x7E0)>>3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x1F)<<3;",
"\t\t*d++ = (bgr&0x7E0)>>3;",
"\t\t*d++ = (bgr&0xF800)>>8;"
],
"line_no": [
5,
7,
11,
13,
17,
19,
5,
7,
9,
11,
13,
17,
19,
21,
23,
25,
5,
7,
9,
11,
13,
17,
19,
5,
7,
11,
13,
17,
19,
25,
13,
13,
13,
13,
13,
13,
13,
13,
5,
7,
11,
13,
17,
19,
25,
5,
7,
9,
11,
13,
17,
19,
25,
23,
21,
5,
7,
9,
11,
13,
17,
19,
25,
25,
5,
7,
11,
13,
17,
19,
21,
23,
25,
25,
23,
21
]
} | void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)
{
const uint16_t *VAR_3;
uint8_t *d = (uint8_t *)VAR_1;
const uint16_t *VAR_4 = (const uint16_t *)VAR_0;
VAR_3 = VAR_4 + VAR_2/2;
while(VAR_4 < VAR_3)
{
register uint16_t VAR_5;
VAR_5 = *VAR_4++;
*d++ = (VAR_5&0xF800)>>8;
*d++ = (VAR_5&0x7E0)>>3;
*d++ = (VAR_5&0x1F)<<3;
}
}
| [
"void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, long VAR_2)\n{",
"const uint16_t *VAR_3;",
"uint8_t *d = (uint8_t *)VAR_1;",
"const uint16_t *VAR_4 = (const uint16_t *)VAR_0;",
"VAR_3 = VAR_4 + VAR_2/2;",
"while(VAR_4 < VAR_3)\n{",
"register uint16_t VAR_5;",
"VAR_5 = *VAR_4++;",
"*d++ = (VAR_5&0xF800)>>8;",
"*d++ = (VAR_5&0x7E0)>>3;",
"*d++ = (VAR_5&0x1F)<<3;",
"}",
"}"
]
| [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
]
]
|
17,174 | static void serial_receive_byte(SerialState *s, int ch)
{
s->rbr = ch;
s->lsr |= UART_LSR_DR;
serial_update_irq(s);
}
| true | qemu | 81174dae3f9189519cd60c7b79e91c291b021bbe | static void serial_receive_byte(SerialState *s, int ch)
{
s->rbr = ch;
s->lsr |= UART_LSR_DR;
serial_update_irq(s);
}
| {
"code": [
" serial_update_irq(s);",
"static void serial_receive_byte(SerialState *s, int ch)",
" s->rbr = ch;",
" s->lsr |= UART_LSR_DR;",
" serial_update_irq(s);"
],
"line_no": [
9,
1,
5,
7,
9
]
} | static void FUNC_0(SerialState *VAR_0, int VAR_1)
{
VAR_0->rbr = VAR_1;
VAR_0->lsr |= UART_LSR_DR;
serial_update_irq(VAR_0);
}
| [
"static void FUNC_0(SerialState *VAR_0, int VAR_1)\n{",
"VAR_0->rbr = VAR_1;",
"VAR_0->lsr |= UART_LSR_DR;",
"serial_update_irq(VAR_0);",
"}"
]
| [
1,
1,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
17,175 | ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb,
ram_addr_t start)
{
unsigned long base = rb->offset >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
unsigned long *bitmap;
unsigned long next;
bitmap = atomic_rcu_read(&migration_bitmap);
if (ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(bitmap, size, nr);
}
if (next < size) {
clear_bit(next, bitmap);
migration_dirty_pages--;
}
return (next - base) << TARGET_PAGE_BITS;
}
| true | qemu | 60be6340796e66b5ac8aac2d98dde5c79336a89c | ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb,
ram_addr_t start)
{
unsigned long base = rb->offset >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
unsigned long *bitmap;
unsigned long next;
bitmap = atomic_rcu_read(&migration_bitmap);
if (ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(bitmap, size, nr);
}
if (next < size) {
clear_bit(next, bitmap);
migration_dirty_pages--;
}
return (next - base) << TARGET_PAGE_BITS;
}
| {
"code": [
" bitmap = atomic_rcu_read(&migration_bitmap);",
" bitmap = atomic_rcu_read(&migration_bitmap);"
],
"line_no": [
23,
23
]
} | ram_addr_t FUNC_0(RAMBlock *rb,
ram_addr_t start)
{
unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS;
unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS);
unsigned long *VAR_3;
unsigned long VAR_4;
VAR_3 = atomic_rcu_read(&migration_bitmap);
if (ram_bulk_stage && VAR_1 > VAR_0) {
VAR_4 = VAR_1 + 1;
} else {
VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1);
}
if (VAR_4 < VAR_2) {
clear_bit(VAR_4, VAR_3);
migration_dirty_pages--;
}
return (VAR_4 - VAR_0) << TARGET_PAGE_BITS;
}
| [
"ram_addr_t FUNC_0(RAMBlock *rb,\nram_addr_t start)\n{",
"unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS;",
"unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS);",
"uint64_t rb_size = rb->used_length;",
"unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS);",
"unsigned long *VAR_3;",
"unsigned long VAR_4;",
"VAR_3 = atomic_rcu_read(&migration_bitmap);",
"if (ram_bulk_stage && VAR_1 > VAR_0) {",
"VAR_4 = VAR_1 + 1;",
"} else {",
"VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1);",
"}",
"if (VAR_4 < VAR_2) {",
"clear_bit(VAR_4, VAR_3);",
"migration_dirty_pages--;",
"}",
"return (VAR_4 - VAR_0) << TARGET_PAGE_BITS;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
]
|
17,176 | static int svq1_motion_inter_block(DSPContext *dsp, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[3];
int result;
/* predict and decode motion vector */
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[x / 8 + 2];
pmv[2] = &motion[x / 8 + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
motion[0].x =
motion[x / 8 + 2].x =
motion[x / 8 + 3].x = mv.x;
motion[0].y =
motion[x / 8 + 2].y =
motion[x / 8 + 3].y = mv.y;
if (y + (mv.y >> 1) < 0)
mv.y = 0;
if (x + (mv.x >> 1) < 0)
mv.x = 0;
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];
dst = current;
dsp->put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);
return 0;
}
| true | FFmpeg | ecff5acb5a738fcb4f9e206a12070dac4bf259b3 | static int svq1_motion_inter_block(DSPContext *dsp, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous,
int pitch, svq1_pmv *motion, int x, int y)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[3];
int result;
pmv[0] = &motion[0];
if (y == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[x / 8 + 2];
pmv[2] = &motion[x / 8 + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
if (result != 0)
return result;
motion[0].x =
motion[x / 8 + 2].x =
motion[x / 8 + 3].x = mv.x;
motion[0].y =
motion[x / 8 + 2].y =
motion[x / 8 + 3].y = mv.y;
if (y + (mv.y >> 1) < 0)
mv.y = 0;
if (x + (mv.x >> 1) < 0)
mv.x = 0;
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];
dst = current;
dsp->put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);
return 0;
}
| {
"code": [
" int pitch, svq1_pmv *motion, int x, int y)",
" if (y + (mv.y >> 1) < 0)",
" mv.y = 0;",
" if (x + (mv.x >> 1) < 0)",
" mv.x = 0;",
" int pitch, svq1_pmv *motion, int x, int y)"
],
"line_no": [
5,
65,
67,
69,
71,
5
]
} | static int FUNC_0(DSPContext *VAR_0, GetBitContext *VAR_1,
uint8_t *VAR_2, uint8_t *VAR_3,
int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)
{
uint8_t *src;
uint8_t *dst;
svq1_pmv mv;
svq1_pmv *pmv[3];
int VAR_8;
pmv[0] = &VAR_5[0];
if (VAR_7 == 0) {
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &VAR_5[VAR_6 / 8 + 2];
pmv[2] = &VAR_5[VAR_6 / 8 + 4];
}
VAR_8 = svq1_decode_motion_vector(VAR_1, &mv, pmv);
if (VAR_8 != 0)
return VAR_8;
VAR_5[0].VAR_6 =
VAR_5[VAR_6 / 8 + 2].VAR_6 =
VAR_5[VAR_6 / 8 + 3].VAR_6 = mv.VAR_6;
VAR_5[0].VAR_7 =
VAR_5[VAR_6 / 8 + 2].VAR_7 =
VAR_5[VAR_6 / 8 + 3].VAR_7 = mv.VAR_7;
if (VAR_7 + (mv.VAR_7 >> 1) < 0)
mv.VAR_7 = 0;
if (VAR_6 + (mv.VAR_6 >> 1) < 0)
mv.VAR_6 = 0;
src = &VAR_3[(VAR_6 + (mv.VAR_6 >> 1)) + (VAR_7 + (mv.VAR_7 >> 1)) * VAR_4];
dst = VAR_2;
VAR_0->put_pixels_tab[0][(mv.VAR_7 & 1) << 1 | (mv.VAR_6 & 1)](dst, src, VAR_4, 16);
return 0;
}
| [
"static int FUNC_0(DSPContext *VAR_0, GetBitContext *VAR_1,\nuint8_t *VAR_2, uint8_t *VAR_3,\nint VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)\n{",
"uint8_t *src;",
"uint8_t *dst;",
"svq1_pmv mv;",
"svq1_pmv *pmv[3];",
"int VAR_8;",
"pmv[0] = &VAR_5[0];",
"if (VAR_7 == 0) {",
"pmv[1] =\npmv[2] = pmv[0];",
"} else {",
"pmv[1] = &VAR_5[VAR_6 / 8 + 2];",
"pmv[2] = &VAR_5[VAR_6 / 8 + 4];",
"}",
"VAR_8 = svq1_decode_motion_vector(VAR_1, &mv, pmv);",
"if (VAR_8 != 0)\nreturn VAR_8;",
"VAR_5[0].VAR_6 =\nVAR_5[VAR_6 / 8 + 2].VAR_6 =\nVAR_5[VAR_6 / 8 + 3].VAR_6 = mv.VAR_6;",
"VAR_5[0].VAR_7 =\nVAR_5[VAR_6 / 8 + 2].VAR_7 =\nVAR_5[VAR_6 / 8 + 3].VAR_7 = mv.VAR_7;",
"if (VAR_7 + (mv.VAR_7 >> 1) < 0)\nmv.VAR_7 = 0;",
"if (VAR_6 + (mv.VAR_6 >> 1) < 0)\nmv.VAR_6 = 0;",
"src = &VAR_3[(VAR_6 + (mv.VAR_6 >> 1)) + (VAR_7 + (mv.VAR_7 >> 1)) * VAR_4];",
"dst = VAR_2;",
"VAR_0->put_pixels_tab[0][(mv.VAR_7 & 1) << 1 | (mv.VAR_6 & 1)](dst, src, VAR_4, 16);",
"return 0;",
"}"
]
| [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45,
47
],
[
51,
53,
55
],
[
57,
59,
61
],
[
65,
67
],
[
69,
71
],
[
75
],
[
77
],
[
81
],
[
85
],
[
87
]
]
|
17,177 | static inline TCGv gen_ld8u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld8u(tmp, addr, index);
return tmp;
}
| true | qemu | 7d1b0095bff7157e856d1d0e6c4295641ced2752 | static inline TCGv gen_ld8u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld8u(tmp, addr, index);
return tmp;
}
| {
"code": [
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();",
" TCGv tmp = new_tmp();"
],
"line_no": [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
]
} | static inline TCGv FUNC_0(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld8u(tmp, addr, index);
return tmp;
}
| [
"static inline TCGv FUNC_0(TCGv addr, int index)\n{",
"TCGv tmp = new_tmp();",
"tcg_gen_qemu_ld8u(tmp, addr, index);",
"return tmp;",
"}"
]
| [
0,
1,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
]
|
17,178 | void replay_account_executed_instructions(void)
{
if (replay_mode == REPLAY_MODE_PLAY) {
replay_mutex_lock();
if (replay_state.instructions_count > 0) {
int count = (int)(replay_get_current_step()
- replay_state.current_step);
replay_state.instructions_count -= count;
replay_state.current_step += count;
if (replay_state.instructions_count == 0) {
assert(replay_state.data_kind == EVENT_INSTRUCTION);
replay_finish_event();
/* Wake up iothread. This is required because
timers will not expire until clock counters
will be read from the log. */
qemu_notify_event();
}
}
replay_mutex_unlock();
}
} | true | qemu | 982263ce714ffcc4c7c41a7b255bd29e093912fe | void replay_account_executed_instructions(void)
{
if (replay_mode == REPLAY_MODE_PLAY) {
replay_mutex_lock();
if (replay_state.instructions_count > 0) {
int count = (int)(replay_get_current_step()
- replay_state.current_step);
replay_state.instructions_count -= count;
replay_state.current_step += count;
if (replay_state.instructions_count == 0) {
assert(replay_state.data_kind == EVENT_INSTRUCTION);
replay_finish_event();
qemu_notify_event();
}
}
replay_mutex_unlock();
}
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
if (replay_mode == REPLAY_MODE_PLAY) {
replay_mutex_lock();
if (replay_state.instructions_count > 0) {
int VAR_0 = (int)(replay_get_current_step()
- replay_state.current_step);
replay_state.instructions_count -= VAR_0;
replay_state.current_step += VAR_0;
if (replay_state.instructions_count == 0) {
assert(replay_state.data_kind == EVENT_INSTRUCTION);
replay_finish_event();
qemu_notify_event();
}
}
replay_mutex_unlock();
}
} | [
"void FUNC_0(void)\n{",
"if (replay_mode == REPLAY_MODE_PLAY) {",
"replay_mutex_lock();",
"if (replay_state.instructions_count > 0) {",
"int VAR_0 = (int)(replay_get_current_step()\n- replay_state.current_step);",
"replay_state.instructions_count -= VAR_0;",
"replay_state.current_step += VAR_0;",
"if (replay_state.instructions_count == 0) {",
"assert(replay_state.data_kind == EVENT_INSTRUCTION);",
"replay_finish_event();",
"qemu_notify_event();",
"}",
"}",
"replay_mutex_unlock();",
"}",
"}"
]
| [
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
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
]
]
|
17,179 | static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
{
int compno, reslevelno, bandno;
int x, y, *src[4];
uint8_t *line;
J2kT1Context t1;
for (compno = 0; compno < s->ncomponents; compno++){
J2kComponent *comp = tile->comp + compno;
J2kCodingStyle *codsty = tile->codsty + compno;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
J2kResLevel *rlevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
bandpos = bandno + (reslevelno > 0);
yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
y0 = yy0;
yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height,
band->coord[1][1]) - band->coord[1][0] + yy0;
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
for (cblky = 0; cblky < band->cblkny; cblky++){
if (reslevelno == 0 || bandno == 1)
xx0 = 0;
else
xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
x0 = xx0;
xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width,
band->coord[0][1]) - band->coord[0][0] + xx0;
for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){
int y, x;
decode_cblk(s, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos);
if (codsty->transform == FF_DWT53){
for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x+=s->cdx[compno]){
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = *ptr++ >> 1;
}
}
} else{
for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x+=s->cdx[compno]){
int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2;
tmp2 = FFABS(tmp>>1) + FFABS(tmp&1);
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = tmp < 0 ? -tmp2 : tmp2;
}
}
}
xx0 = xx1;
xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0);
}
yy0 = yy1;
yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0);
}
}
}
ff_j2k_dwt_decode(&comp->dwt, comp->data);
src[compno] = comp->data;
}
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->avctx->pix_fmt == PIX_FMT_BGRA) // RGBA -> BGRA
FFSWAP(int *, src[0], src[2]);
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++){
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture.data[0] + y * s->picture.linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){
uint8_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
*src[compno] += 1 << (s->cbps[compno]-1);
if (*src[compno] < 0)
*src[compno] = 0;
else if (*src[compno] >= (1 << s->cbps[compno]))
*src[compno] = (1 << s->cbps[compno]) - 1;
*dst = *src[compno]++;
dst += s->ncomponents;
}
line += s->picture.linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture.data[0] + y * s->picture.linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + (x * s->ncomponents + compno) * 2;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) {
int32_t val;
val = *src[compno]++ << (16 - s->cbps[compno]);
val += 1 << 15;
val = av_clip(val, 0, (1 << 16) - 1);
*dst = val;
dst += s->ncomponents;
}
line += s->picture.linesize[0];
}
}
}
return 0;
}
| true | FFmpeg | ddfa3751c092feaf1e080f66587024689dfe603c | static int decode_tile(J2kDecoderContext *s, J2kTile *tile)
{
int compno, reslevelno, bandno;
int x, y, *src[4];
uint8_t *line;
J2kT1Context t1;
for (compno = 0; compno < s->ncomponents; compno++){
J2kComponent *comp = tile->comp + compno;
J2kCodingStyle *codsty = tile->codsty + compno;
for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++){
J2kResLevel *rlevel = comp->reslevel + reslevelno;
for (bandno = 0; bandno < rlevel->nbands; bandno++){
J2kBand *band = rlevel->band + bandno;
int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
bandpos = bandno + (reslevelno > 0);
yy0 = bandno == 0 ? 0 : comp->reslevel[reslevelno-1].coord[1][1] - comp->reslevel[reslevelno-1].coord[1][0];
y0 = yy0;
yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height,
band->coord[1][1]) - band->coord[1][0] + yy0;
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
for (cblky = 0; cblky < band->cblkny; cblky++){
if (reslevelno == 0 || bandno == 1)
xx0 = 0;
else
xx0 = comp->reslevel[reslevelno-1].coord[0][1] - comp->reslevel[reslevelno-1].coord[0][0];
x0 = xx0;
xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width,
band->coord[0][1]) - band->coord[0][0] + xx0;
for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){
int y, x;
decode_cblk(s, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos);
if (codsty->transform == FF_DWT53){
for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x+=s->cdx[compno]){
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = *ptr++ >> 1;
}
}
} else{
for (y = yy0; y < yy1; y+=s->cdy[compno]){
int *ptr = t1.data[y-yy0];
for (x = xx0; x < xx1; x+=s->cdx[compno]){
int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2;
tmp2 = FFABS(tmp>>1) + FFABS(tmp&1);
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * y + x] = tmp < 0 ? -tmp2 : tmp2;
}
}
}
xx0 = xx1;
xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0);
}
yy0 = yy1;
yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0);
}
}
}
ff_j2k_dwt_decode(&comp->dwt, comp->data);
src[compno] = comp->data;
}
if (tile->codsty[0].mct)
mct_decode(s, tile);
if (s->avctx->pix_fmt == PIX_FMT_BGRA)
FFSWAP(int *, src[0], src[2]);
if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++){
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture.data[0] + y * s->picture.linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]){
uint8_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
*src[compno] += 1 << (s->cbps[compno]-1);
if (*src[compno] < 0)
*src[compno] = 0;
else if (*src[compno] >= (1 << s->cbps[compno]))
*src[compno] = (1 << s->cbps[compno]) - 1;
*dst = *src[compno]++;
dst += s->ncomponents;
}
line += s->picture.linesize[0];
}
}
} else {
for (compno = 0; compno < s->ncomponents; compno++) {
y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = s->picture.data[0] + y * s->picture.linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
uint16_t *dst;
x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = line + (x * s->ncomponents + compno) * 2;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s-> cdx[compno]) {
int32_t val;
val = *src[compno]++ << (16 - s->cbps[compno]);
val += 1 << 15;
val = av_clip(val, 0, (1 << 16) - 1);
*dst = val;
dst += s->ncomponents;
}
line += s->picture.linesize[0];
}
}
}
return 0;
}
| {
"code": [
" dst = line + (x * s->ncomponents + compno) * 2;"
],
"line_no": [
205
]
} | static int FUNC_0(J2kDecoderContext *VAR_0, J2kTile *VAR_1)
{
int VAR_2, VAR_3, VAR_4;
int VAR_5, VAR_6, *VAR_7[4];
uint8_t *line;
J2kT1Context t1;
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++){
J2kComponent *comp = VAR_1->comp + VAR_2;
J2kCodingStyle *codsty = VAR_1->codsty + VAR_2;
for (VAR_3 = 0; VAR_3 < codsty->nreslevels; VAR_3++){
J2kResLevel *rlevel = comp->reslevel + VAR_3;
for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++){
J2kBand *band = rlevel->band + VAR_4;
int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;
bandpos = VAR_4 + (VAR_3 > 0);
yy0 = VAR_4 == 0 ? 0 : comp->reslevel[VAR_3-1].coord[1][1] - comp->reslevel[VAR_3-1].coord[1][0];
y0 = yy0;
yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height,
band->coord[1][1]) - band->coord[1][0] + yy0;
if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])
continue;
for (cblky = 0; cblky < band->cblkny; cblky++){
if (VAR_3 == 0 || VAR_4 == 1)
xx0 = 0;
else
xx0 = comp->reslevel[VAR_3-1].coord[0][1] - comp->reslevel[VAR_3-1].coord[0][0];
x0 = xx0;
xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width,
band->coord[0][1]) - band->coord[0][0] + xx0;
for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){
int VAR_6, VAR_5;
decode_cblk(VAR_0, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos);
if (codsty->transform == FF_DWT53){
for (VAR_6 = yy0; VAR_6 < yy1; VAR_6+=VAR_0->cdy[VAR_2]){
int *ptr = t1.data[VAR_6-yy0];
for (VAR_5 = xx0; VAR_5 < xx1; VAR_5+=VAR_0->cdx[VAR_2]){
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * VAR_6 + VAR_5] = *ptr++ >> 1;
}
}
} else{
for (VAR_6 = yy0; VAR_6 < yy1; VAR_6+=VAR_0->cdy[VAR_2]){
int *ptr = t1.data[VAR_6-yy0];
for (VAR_5 = xx0; VAR_5 < xx1; VAR_5+=VAR_0->cdx[VAR_2]){
int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2;
tmp2 = FFABS(tmp>>1) + FFABS(tmp&1);
comp->data[(comp->coord[0][1] - comp->coord[0][0]) * VAR_6 + VAR_5] = tmp < 0 ? -tmp2 : tmp2;
}
}
}
xx0 = xx1;
xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0);
}
yy0 = yy1;
yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0);
}
}
}
ff_j2k_dwt_decode(&comp->dwt, comp->data);
VAR_7[VAR_2] = comp->data;
}
if (VAR_1->codsty[0].mct)
mct_decode(VAR_0, VAR_1);
if (VAR_0->avctx->pix_fmt == PIX_FMT_BGRA)
FFSWAP(int *, VAR_7[0], VAR_7[2]);
if (VAR_0->precision <= 8) {
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++){
VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;
line = VAR_0->picture.data[0] + VAR_6 * VAR_0->picture.linesize[0];
for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]){
uint8_t *dst;
VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;
dst = line + VAR_5 * VAR_0->ncomponents + VAR_2;
for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) {
*VAR_7[VAR_2] += 1 << (VAR_0->cbps[VAR_2]-1);
if (*VAR_7[VAR_2] < 0)
*VAR_7[VAR_2] = 0;
else if (*VAR_7[VAR_2] >= (1 << VAR_0->cbps[VAR_2]))
*VAR_7[VAR_2] = (1 << VAR_0->cbps[VAR_2]) - 1;
*dst = *VAR_7[VAR_2]++;
dst += VAR_0->ncomponents;
}
line += VAR_0->picture.linesize[0];
}
}
} else {
for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {
VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;
line = VAR_0->picture.data[0] + VAR_6 * VAR_0->picture.linesize[0];
for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {
uint16_t *dst;
VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;
dst = line + (VAR_5 * VAR_0->ncomponents + VAR_2) * 2;
for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) {
int32_t val;
val = *VAR_7[VAR_2]++ << (16 - VAR_0->cbps[VAR_2]);
val += 1 << 15;
val = av_clip(val, 0, (1 << 16) - 1);
*dst = val;
dst += VAR_0->ncomponents;
}
line += VAR_0->picture.linesize[0];
}
}
}
return 0;
}
| [
"static int FUNC_0(J2kDecoderContext *VAR_0, J2kTile *VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"int VAR_5, VAR_6, *VAR_7[4];",
"uint8_t *line;",
"J2kT1Context t1;",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++){",
"J2kComponent *comp = VAR_1->comp + VAR_2;",
"J2kCodingStyle *codsty = VAR_1->codsty + VAR_2;",
"for (VAR_3 = 0; VAR_3 < codsty->nreslevels; VAR_3++){",
"J2kResLevel *rlevel = comp->reslevel + VAR_3;",
"for (VAR_4 = 0; VAR_4 < rlevel->nbands; VAR_4++){",
"J2kBand *band = rlevel->band + VAR_4;",
"int cblkx, cblky, cblkno=0, xx0, x0, xx1, y0, yy0, yy1, bandpos;",
"bandpos = VAR_4 + (VAR_3 > 0);",
"yy0 = VAR_4 == 0 ? 0 : comp->reslevel[VAR_3-1].coord[1][1] - comp->reslevel[VAR_3-1].coord[1][0];",
"y0 = yy0;",
"yy1 = FFMIN(ff_j2k_ceildiv(band->coord[1][0] + 1, band->codeblock_height) * band->codeblock_height,\nband->coord[1][1]) - band->coord[1][0] + yy0;",
"if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1])\ncontinue;",
"for (cblky = 0; cblky < band->cblkny; cblky++){",
"if (VAR_3 == 0 || VAR_4 == 1)\nxx0 = 0;",
"else\nxx0 = comp->reslevel[VAR_3-1].coord[0][1] - comp->reslevel[VAR_3-1].coord[0][0];",
"x0 = xx0;",
"xx1 = FFMIN(ff_j2k_ceildiv(band->coord[0][0] + 1, band->codeblock_width) * band->codeblock_width,\nband->coord[0][1]) - band->coord[0][0] + xx0;",
"for (cblkx = 0; cblkx < band->cblknx; cblkx++, cblkno++){",
"int VAR_6, VAR_5;",
"decode_cblk(VAR_0, codsty, &t1, band->cblk + cblkno, xx1 - xx0, yy1 - yy0, bandpos);",
"if (codsty->transform == FF_DWT53){",
"for (VAR_6 = yy0; VAR_6 < yy1; VAR_6+=VAR_0->cdy[VAR_2]){",
"int *ptr = t1.data[VAR_6-yy0];",
"for (VAR_5 = xx0; VAR_5 < xx1; VAR_5+=VAR_0->cdx[VAR_2]){",
"comp->data[(comp->coord[0][1] - comp->coord[0][0]) * VAR_6 + VAR_5] = *ptr++ >> 1;",
"}",
"}",
"} else{",
"for (VAR_6 = yy0; VAR_6 < yy1; VAR_6+=VAR_0->cdy[VAR_2]){",
"int *ptr = t1.data[VAR_6-yy0];",
"for (VAR_5 = xx0; VAR_5 < xx1; VAR_5+=VAR_0->cdx[VAR_2]){",
"int tmp = ((int64_t)*ptr++) * ((int64_t)band->stepsize) >> 13, tmp2;",
"tmp2 = FFABS(tmp>>1) + FFABS(tmp&1);",
"comp->data[(comp->coord[0][1] - comp->coord[0][0]) * VAR_6 + VAR_5] = tmp < 0 ? -tmp2 : tmp2;",
"}",
"}",
"}",
"xx0 = xx1;",
"xx1 = FFMIN(xx1 + band->codeblock_width, band->coord[0][1] - band->coord[0][0] + x0);",
"}",
"yy0 = yy1;",
"yy1 = FFMIN(yy1 + band->codeblock_height, band->coord[1][1] - band->coord[1][0] + y0);",
"}",
"}",
"}",
"ff_j2k_dwt_decode(&comp->dwt, comp->data);",
"VAR_7[VAR_2] = comp->data;",
"}",
"if (VAR_1->codsty[0].mct)\nmct_decode(VAR_0, VAR_1);",
"if (VAR_0->avctx->pix_fmt == PIX_FMT_BGRA)\nFFSWAP(int *, VAR_7[0], VAR_7[2]);",
"if (VAR_0->precision <= 8) {",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++){",
"VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;",
"line = VAR_0->picture.data[0] + VAR_6 * VAR_0->picture.linesize[0];",
"for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]){",
"uint8_t *dst;",
"VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;",
"dst = line + VAR_5 * VAR_0->ncomponents + VAR_2;",
"for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0->cdx[VAR_2]) {",
"*VAR_7[VAR_2] += 1 << (VAR_0->cbps[VAR_2]-1);",
"if (*VAR_7[VAR_2] < 0)\n*VAR_7[VAR_2] = 0;",
"else if (*VAR_7[VAR_2] >= (1 << VAR_0->cbps[VAR_2]))\n*VAR_7[VAR_2] = (1 << VAR_0->cbps[VAR_2]) - 1;",
"*dst = *VAR_7[VAR_2]++;",
"dst += VAR_0->ncomponents;",
"}",
"line += VAR_0->picture.linesize[0];",
"}",
"}",
"} else {",
"for (VAR_2 = 0; VAR_2 < VAR_0->ncomponents; VAR_2++) {",
"VAR_6 = VAR_1->comp[VAR_2].coord[1][0] - VAR_0->image_offset_y;",
"line = VAR_0->picture.data[0] + VAR_6 * VAR_0->picture.linesize[0];",
"for (; VAR_6 < VAR_1->comp[VAR_2].coord[1][1] - VAR_0->image_offset_y; VAR_6 += VAR_0->cdy[VAR_2]) {",
"uint16_t *dst;",
"VAR_5 = VAR_1->comp[VAR_2].coord[0][0] - VAR_0->image_offset_x;",
"dst = line + (VAR_5 * VAR_0->ncomponents + VAR_2) * 2;",
"for (; VAR_5 < VAR_1->comp[VAR_2].coord[0][1] - VAR_0->image_offset_x; VAR_5 += VAR_0-> cdx[VAR_2]) {",
"int32_t val;",
"val = *VAR_7[VAR_2]++ << (16 - VAR_0->cbps[VAR_2]);",
"val += 1 << 15;",
"val = av_clip(val, 0, (1 << 16) - 1);",
"*dst = val;",
"dst += VAR_0->ncomponents;",
"}",
"line += VAR_0->picture.linesize[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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43,
45
],
[
49,
51
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67,
69
],
[
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
],
[
141,
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
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
]
]
|
17,180 | void boot_sector_test(void)
{
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
/* Wait at most 90 seconds */
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((90 * G_USEC_PER_SEC / TEST_DELAY), 1)
/* Poll until code has run and modified memory. Once it has we know BIOS
* initialization is done. TODO: check that IP reached the halt
* instruction.
*/
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
}
| true | qemu | 83898cce62ba25a473af6a164388105994481e9c | void boot_sector_test(void)
{
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int i;
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((90 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (i = 0; i < TEST_CYCLES; ++i) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
}
| {
"code": [
" signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);",
" signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);"
],
"line_no": [
33,
35
]
} | void FUNC_0(void)
{
uint8_t signature_low;
uint8_t signature_high;
uint16_t signature;
int VAR_0;
#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
#define TEST_CYCLES MAX((90 * G_USEC_PER_SEC / TEST_DELAY), 1)
for (VAR_0 = 0; VAR_0 < TEST_CYCLES; ++VAR_0) {
signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
}
g_usleep(TEST_DELAY);
}
g_assert_cmphex(signature, ==, SIGNATURE);
}
| [
"void FUNC_0(void)\n{",
"uint8_t signature_low;",
"uint8_t signature_high;",
"uint16_t signature;",
"int VAR_0;",
"#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)\n#define TEST_CYCLES MAX((90 * G_USEC_PER_SEC / TEST_DELAY), 1)\nfor (VAR_0 = 0; VAR_0 < TEST_CYCLES; ++VAR_0) {",
"signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);",
"signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);",
"signature = (signature_high << 8) | signature_low;",
"if (signature == SIGNATURE) {",
"break;",
"}",
"g_usleep(TEST_DELAY);",
"}",
"g_assert_cmphex(signature, ==, SIGNATURE);",
"}"
]
| [
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
17,
19,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
]
]
|
17,181 | int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
{
int rc;
cmd->lba = -1;
cmd->len = scsi_cdb_length(buf);
switch (dev->type) {
case TYPE_TAPE:
rc = scsi_req_stream_xfer(cmd, dev, buf);
break;
case TYPE_MEDIUM_CHANGER:
rc = scsi_req_medium_changer_xfer(cmd, dev, buf);
break;
default:
rc = scsi_req_xfer(cmd, dev, buf);
break;
}
if (rc != 0)
return rc;
memcpy(cmd->buf, buf, cmd->len);
scsi_cmd_xfer_mode(cmd);
cmd->lba = scsi_cmd_lba(cmd);
return 0;
}
| true | qemu | c170aad8b057223b1139d72e5ce7acceafab4fa9 | int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
{
int rc;
cmd->lba = -1;
cmd->len = scsi_cdb_length(buf);
switch (dev->type) {
case TYPE_TAPE:
rc = scsi_req_stream_xfer(cmd, dev, buf);
break;
case TYPE_MEDIUM_CHANGER:
rc = scsi_req_medium_changer_xfer(cmd, dev, buf);
break;
default:
rc = scsi_req_xfer(cmd, dev, buf);
break;
}
if (rc != 0)
return rc;
memcpy(cmd->buf, buf, cmd->len);
scsi_cmd_xfer_mode(cmd);
cmd->lba = scsi_cmd_lba(cmd);
return 0;
}
| {
"code": [
" cmd->len = scsi_cdb_length(buf);"
],
"line_no": [
11
]
} | int FUNC_0(SCSIDevice *VAR_0, SCSICommand *VAR_1, uint8_t *VAR_2)
{
int VAR_3;
VAR_1->lba = -1;
VAR_1->len = scsi_cdb_length(VAR_2);
switch (VAR_0->type) {
case TYPE_TAPE:
VAR_3 = scsi_req_stream_xfer(VAR_1, VAR_0, VAR_2);
break;
case TYPE_MEDIUM_CHANGER:
VAR_3 = scsi_req_medium_changer_xfer(VAR_1, VAR_0, VAR_2);
break;
default:
VAR_3 = scsi_req_xfer(VAR_1, VAR_0, VAR_2);
break;
}
if (VAR_3 != 0)
return VAR_3;
memcpy(VAR_1->VAR_2, VAR_2, VAR_1->len);
scsi_cmd_xfer_mode(VAR_1);
VAR_1->lba = scsi_cmd_lba(VAR_1);
return 0;
}
| [
"int FUNC_0(SCSIDevice *VAR_0, SCSICommand *VAR_1, uint8_t *VAR_2)\n{",
"int VAR_3;",
"VAR_1->lba = -1;",
"VAR_1->len = scsi_cdb_length(VAR_2);",
"switch (VAR_0->type) {",
"case TYPE_TAPE:\nVAR_3 = scsi_req_stream_xfer(VAR_1, VAR_0, VAR_2);",
"break;",
"case TYPE_MEDIUM_CHANGER:\nVAR_3 = scsi_req_medium_changer_xfer(VAR_1, VAR_0, VAR_2);",
"break;",
"default:\nVAR_3 = scsi_req_xfer(VAR_1, VAR_0, VAR_2);",
"break;",
"}",
"if (VAR_3 != 0)\nreturn VAR_3;",
"memcpy(VAR_1->VAR_2, VAR_2, VAR_1->len);",
"scsi_cmd_xfer_mode(VAR_1);",
"VAR_1->lba = scsi_cmd_lba(VAR_1);",
"return 0;",
"}"
]
| [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
15
],
[
17,
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
]
]
|
17,182 | static int graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
int ret;
/* find supported formats from sub-filters, and merge along links */
if ((ret = query_formats(graph, log_ctx)) < 0)
return ret;
/* Once everything is merged, it's possible that we'll still have
* multiple valid media format choices. We try to minimize the amount
* of format conversion inside filters */
reduce_formats(graph);
/* for audio filters, ensure the best format, sample rate and channel layout
* is selected */
swap_sample_fmts(graph);
swap_samplerates(graph);
swap_channel_layouts(graph);
if ((ret = pick_formats(graph)) < 0)
return ret;
return 0;
}
| false | FFmpeg | 125acd215250ead008938266efcacd56743f3a2a | static int graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
int ret;
if ((ret = query_formats(graph, log_ctx)) < 0)
return ret;
reduce_formats(graph);
swap_sample_fmts(graph);
swap_samplerates(graph);
swap_channel_layouts(graph);
if ((ret = pick_formats(graph)) < 0)
return ret;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFilterGraph *VAR_0, AVClass *VAR_1)
{
int VAR_2;
if ((VAR_2 = query_formats(VAR_0, VAR_1)) < 0)
return VAR_2;
reduce_formats(VAR_0);
swap_sample_fmts(VAR_0);
swap_samplerates(VAR_0);
swap_channel_layouts(VAR_0);
if ((VAR_2 = pick_formats(VAR_0)) < 0)
return VAR_2;
return 0;
}
| [
"static int FUNC_0(AVFilterGraph *VAR_0, AVClass *VAR_1)\n{",
"int VAR_2;",
"if ((VAR_2 = query_formats(VAR_0, VAR_1)) < 0)\nreturn VAR_2;",
"reduce_formats(VAR_0);",
"swap_sample_fmts(VAR_0);",
"swap_samplerates(VAR_0);",
"swap_channel_layouts(VAR_0);",
"if ((VAR_2 = pick_formats(VAR_0)) < 0)\nreturn VAR_2;",
"return 0;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
11,
13
],
[
23
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
45
],
[
47
]
]
|
17,184 | static int pred(float *in, float *tgt, int n)
{
int x, y;
float *p1, *p2;
double f0, f1, f2;
float temp;
if (in[n] == 0)
return 0;
if ((f0 = *in) <= 0)
return 0;
for (x=1 ; ; x++) {
if (n < x)
return 1;
p1 = in + x;
p2 = tgt;
f1 = *(p1--);
for (y=x; --y; f1 += (*(p1--))*(*(p2++)));
p1 = tgt + x - 1;
p2 = tgt;
*(p1--) = f2 = -f1/f0;
for (y=x >> 1; y--;) {
temp = *p2 + *p1 * f2;
*(p1--) += *p2 * f2;
*(p2++) = temp;
}
if ((f0 += f1*f2) < 0)
return 0;
}
}
| false | FFmpeg | 69c23e6f33c38ebc03ce7f51fcb963deaff7383b | static int pred(float *in, float *tgt, int n)
{
int x, y;
float *p1, *p2;
double f0, f1, f2;
float temp;
if (in[n] == 0)
return 0;
if ((f0 = *in) <= 0)
return 0;
for (x=1 ; ; x++) {
if (n < x)
return 1;
p1 = in + x;
p2 = tgt;
f1 = *(p1--);
for (y=x; --y; f1 += (*(p1--))*(*(p2++)));
p1 = tgt + x - 1;
p2 = tgt;
*(p1--) = f2 = -f1/f0;
for (y=x >> 1; y--;) {
temp = *p2 + *p1 * f2;
*(p1--) += *p2 * f2;
*(p2++) = temp;
}
if ((f0 += f1*f2) < 0)
return 0;
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(float *VAR_0, float *VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
float *VAR_5, *VAR_6;
double VAR_7, VAR_8, VAR_9;
float VAR_10;
if (VAR_0[VAR_2] == 0)
return 0;
if ((VAR_7 = *VAR_0) <= 0)
return 0;
for (VAR_3=1 ; ; VAR_3++) {
if (VAR_2 < VAR_3)
return 1;
VAR_5 = VAR_0 + VAR_3;
VAR_6 = VAR_1;
VAR_8 = *(VAR_5--);
for (VAR_4=VAR_3; --VAR_4; VAR_8 += (*(VAR_5--))*(*(VAR_6++)));
VAR_5 = VAR_1 + VAR_3 - 1;
VAR_6 = VAR_1;
*(VAR_5--) = VAR_9 = -VAR_8/VAR_7;
for (VAR_4=VAR_3 >> 1; VAR_4--;) {
VAR_10 = *VAR_6 + *VAR_5 * VAR_9;
*(VAR_5--) += *VAR_6 * VAR_9;
*(VAR_6++) = VAR_10;
}
if ((VAR_7 += VAR_8*VAR_9) < 0)
return 0;
}
}
| [
"static int FUNC_0(float *VAR_0, float *VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"float *VAR_5, *VAR_6;",
"double VAR_7, VAR_8, VAR_9;",
"float VAR_10;",
"if (VAR_0[VAR_2] == 0)\nreturn 0;",
"if ((VAR_7 = *VAR_0) <= 0)\nreturn 0;",
"for (VAR_3=1 ; ; VAR_3++) {",
"if (VAR_2 < VAR_3)\nreturn 1;",
"VAR_5 = VAR_0 + VAR_3;",
"VAR_6 = VAR_1;",
"VAR_8 = *(VAR_5--);",
"for (VAR_4=VAR_3; --VAR_4; VAR_8 += (*(VAR_5--))*(*(VAR_6++)));",
"VAR_5 = VAR_1 + VAR_3 - 1;",
"VAR_6 = VAR_1;",
"*(VAR_5--) = VAR_9 = -VAR_8/VAR_7;",
"for (VAR_4=VAR_3 >> 1; VAR_4--;) {",
"VAR_10 = *VAR_6 + *VAR_5 * VAR_9;",
"*(VAR_5--) += *VAR_6 * VAR_9;",
"*(VAR_6++) = VAR_10;",
"}",
"if ((VAR_7 += VAR_8*VAR_9) < 0)\nreturn 0;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21,
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
]
]
|
17,185 | void watchdog_perform_action(void)
{
switch (watchdog_action) {
case WDT_RESET: /* same as 'system_reset' in monitor */
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort);
qemu_system_reset_request();
break;
case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort);
qemu_system_powerdown_request();
break;
case WDT_POWEROFF: /* same as 'quit' command in monitor */
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);
exit(0);
case WDT_PAUSE: /* same as 'stop' command in monitor */
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort);
vm_stop(RUN_STATE_WATCHDOG);
break;
case WDT_DEBUG:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort);
fprintf(stderr, "watchdog: timer fired\n");
break;
case WDT_NONE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
break;
}
}
| true | qemu | 30e5210a706ca6b52cbefa8b71e40ae614ffd6e5 | void watchdog_perform_action(void)
{
switch (watchdog_action) {
case WDT_RESET:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort);
qemu_system_reset_request();
break;
case WDT_SHUTDOWN:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort);
qemu_system_powerdown_request();
break;
case WDT_POWEROFF:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);
exit(0);
case WDT_PAUSE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort);
vm_stop(RUN_STATE_WATCHDOG);
break;
case WDT_DEBUG:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort);
fprintf(stderr, "watchdog: timer fired\n");
break;
case WDT_NONE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
break;
}
}
| {
"code": [
" vm_stop(RUN_STATE_WATCHDOG);"
],
"line_no": [
39
]
} | void FUNC_0(void)
{
switch (watchdog_action) {
case WDT_RESET:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort);
qemu_system_reset_request();
break;
case WDT_SHUTDOWN:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort);
qemu_system_powerdown_request();
break;
case WDT_POWEROFF:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);
exit(0);
case WDT_PAUSE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort);
vm_stop(RUN_STATE_WATCHDOG);
break;
case WDT_DEBUG:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort);
fprintf(stderr, "watchdog: timer fired\n");
break;
case WDT_NONE:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
break;
}
}
| [
"void FUNC_0(void)\n{",
"switch (watchdog_action) {",
"case WDT_RESET:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort);",
"qemu_system_reset_request();",
"break;",
"case WDT_SHUTDOWN:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort);",
"qemu_system_powerdown_request();",
"break;",
"case WDT_POWEROFF:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);",
"exit(0);",
"case WDT_PAUSE:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort);",
"vm_stop(RUN_STATE_WATCHDOG);",
"break;",
"case WDT_DEBUG:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort);",
"fprintf(stderr, \"watchdog: timer fired\\n\");",
"break;",
"case WDT_NONE:\nqapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);",
"break;",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
17,
19
],
[
21
],
[
23
],
[
27,
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
45,
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
],
[
63
]
]
|
17,186 | static void *spapr_create_fdt_skel(hwaddr initrd_base,
hwaddr initrd_size,
hwaddr kernel_size,
bool little_endian,
const char *kernel_cmdline,
uint32_t epow_irq)
{
void *fdt;
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(max_cpus)};
unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
char *buf;
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(qemu_hypertas, "hcall-memop1");
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
if (kernel_size) {
_FDT((fdt_add_reservemap_entry(fdt, KERNEL_LOAD_ADDR, kernel_size)));
}
if (initrd_size) {
_FDT((fdt_add_reservemap_entry(fdt, initrd_base, initrd_size)));
}
_FDT((fdt_finish_reservemap(fdt)));
/* Root node */
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_string(fdt, "compatible", "qemu,pseries")));
/*
* Add info to guest to indentify which host is it being run on
* and what is the uuid of the guest
*/
if (kvmppc_get_host_model(&buf)) {
_FDT((fdt_property_string(fdt, "host-model", buf)));
g_free(buf);
}
if (kvmppc_get_host_serial(&buf)) {
_FDT((fdt_property_string(fdt, "host-serial", buf)));
g_free(buf);
}
buf = g_strdup_printf(UUID_FMT, qemu_uuid[0], qemu_uuid[1],
qemu_uuid[2], qemu_uuid[3], qemu_uuid[4],
qemu_uuid[5], qemu_uuid[6], qemu_uuid[7],
qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
qemu_uuid[14], qemu_uuid[15]);
_FDT((fdt_property_string(fdt, "vm,uuid", buf)));
if (qemu_uuid_set) {
_FDT((fdt_property_string(fdt, "system-id", buf)));
}
g_free(buf);
if (qemu_get_vm_name()) {
_FDT((fdt_property_string(fdt, "ibm,partition-name",
qemu_get_vm_name())));
}
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
/* /chosen */
_FDT((fdt_begin_node(fdt, "chosen")));
/* Set Form1_affinity */
_FDT((fdt_property(fdt, "ibm,architecture-vec-5", vec5, sizeof(vec5))));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (kernel_size) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(kernel_size) };
_FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop))));
if (little_endian) {
_FDT((fdt_property(fdt, "qemu,boot-kernel-le", NULL, 0)));
}
}
if (boot_menu) {
_FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
}
_FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(fdt)));
/* RTAS */
_FDT((fdt_begin_node(fdt, "rtas")));
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas->str,
hypertas->len)));
g_string_free(hypertas, TRUE);
_FDT((fdt_property(fdt, "qemu,hypertas-functions", qemu_hypertas->str,
qemu_hypertas->len)));
g_string_free(qemu_hypertas, TRUE);
_FDT((fdt_property(fdt, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_property_cell(fdt, "rtas-error-log-max", RTAS_ERROR_LOG_MAX)));
_FDT((fdt_property_cell(fdt, "rtas-event-scan-rate",
RTAS_EVENT_SCAN_RATE)));
if (msi_nonbroken) {
_FDT((fdt_property(fdt, "ibm,change-msix-capable", NULL, 0)));
}
/*
* According to PAPR, rtas ibm,os-term does not guarantee a return
* back to the guest cpu.
*
* While an additional ibm,extended-os-term property indicates that
* rtas call return will always occur. Set this property.
*/
_FDT((fdt_property(fdt, "ibm,extended-os-term", NULL, 0)));
_FDT((fdt_end_node(fdt)));
/* interrupt controller */
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
/* vdevice */
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
/* event-sources */
spapr_events_fdt_skel(fdt, epow_irq);
/* /hypervisor node */
if (kvm_enabled()) {
uint8_t hypercall[16];
/* indicate KVM hypercall interface */
_FDT((fdt_begin_node(fdt, "hypervisor")));
_FDT((fdt_property_string(fdt, "compatible", "linux,kvm")));
if (kvmppc_has_cap_fixup_hcalls()) {
/*
* Older KVM versions with older guest kernels were broken with the
* magic page, don't allow the guest to map it.
*/
kvmppc_get_hypercall(first_cpu->env_ptr, hypercall,
sizeof(hypercall));
_FDT((fdt_property(fdt, "hcall-instructions", hypercall,
sizeof(hypercall))));
}
_FDT((fdt_end_node(fdt)));
}
_FDT((fdt_end_node(fdt))); /* close root node */
_FDT((fdt_finish(fdt)));
return fdt;
}
| true | qemu | 0ddbd0536296f5a36c8f225edd4d14441be6b153 | static void *spapr_create_fdt_skel(hwaddr initrd_base,
hwaddr initrd_size,
hwaddr kernel_size,
bool little_endian,
const char *kernel_cmdline,
uint32_t epow_irq)
{
void *fdt;
uint32_t start_prop = cpu_to_be32(initrd_base);
uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(max_cpus)};
unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
char *buf;
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(qemu_hypertas, "hcall-memop1");
fdt = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(fdt, FDT_MAX_SIZE)));
if (kernel_size) {
_FDT((fdt_add_reservemap_entry(fdt, KERNEL_LOAD_ADDR, kernel_size)));
}
if (initrd_size) {
_FDT((fdt_add_reservemap_entry(fdt, initrd_base, initrd_size)));
}
_FDT((fdt_finish_reservemap(fdt)));
_FDT((fdt_begin_node(fdt, "")));
_FDT((fdt_property_string(fdt, "device_type", "chrp")));
_FDT((fdt_property_string(fdt, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_string(fdt, "compatible", "qemu,pseries")));
if (kvmppc_get_host_model(&buf)) {
_FDT((fdt_property_string(fdt, "host-model", buf)));
g_free(buf);
}
if (kvmppc_get_host_serial(&buf)) {
_FDT((fdt_property_string(fdt, "host-serial", buf)));
g_free(buf);
}
buf = g_strdup_printf(UUID_FMT, qemu_uuid[0], qemu_uuid[1],
qemu_uuid[2], qemu_uuid[3], qemu_uuid[4],
qemu_uuid[5], qemu_uuid[6], qemu_uuid[7],
qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
qemu_uuid[14], qemu_uuid[15]);
_FDT((fdt_property_string(fdt, "vm,uuid", buf)));
if (qemu_uuid_set) {
_FDT((fdt_property_string(fdt, "system-id", buf)));
}
g_free(buf);
if (qemu_get_vm_name()) {
_FDT((fdt_property_string(fdt, "ibm,partition-name",
qemu_get_vm_name())));
}
_FDT((fdt_property_cell(fdt, "#address-cells", 0x2)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x2)));
_FDT((fdt_begin_node(fdt, "chosen")));
_FDT((fdt_property(fdt, "ibm,architecture-vec-5", vec5, sizeof(vec5))));
_FDT((fdt_property_string(fdt, "bootargs", kernel_cmdline)));
_FDT((fdt_property(fdt, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(fdt, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (kernel_size) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(kernel_size) };
_FDT((fdt_property(fdt, "qemu,boot-kernel", &kprop, sizeof(kprop))));
if (little_endian) {
_FDT((fdt_property(fdt, "qemu,boot-kernel-le", NULL, 0)));
}
}
if (boot_menu) {
_FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
}
_FDT((fdt_property_cell(fdt, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(fdt, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "rtas")));
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
_FDT((fdt_property(fdt, "ibm,hypertas-functions", hypertas->str,
hypertas->len)));
g_string_free(hypertas, TRUE);
_FDT((fdt_property(fdt, "qemu,hypertas-functions", qemu_hypertas->str,
qemu_hypertas->len)));
g_string_free(qemu_hypertas, TRUE);
_FDT((fdt_property(fdt, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_property_cell(fdt, "rtas-error-log-max", RTAS_ERROR_LOG_MAX)));
_FDT((fdt_property_cell(fdt, "rtas-event-scan-rate",
RTAS_EVENT_SCAN_RATE)));
if (msi_nonbroken) {
_FDT((fdt_property(fdt, "ibm,change-msix-capable", NULL, 0)));
}
_FDT((fdt_property(fdt, "ibm,extended-os-term", NULL, 0)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "interrupt-controller")));
_FDT((fdt_property_string(fdt, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(fdt, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(fdt, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(fdt, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(fdt)));
_FDT((fdt_begin_node(fdt, "vdevice")));
_FDT((fdt_property_string(fdt, "device_type", "vdevice")));
_FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
_FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
_FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2)));
_FDT((fdt_property(fdt, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(fdt)));
spapr_events_fdt_skel(fdt, epow_irq);
if (kvm_enabled()) {
uint8_t hypercall[16];
_FDT((fdt_begin_node(fdt, "hypervisor")));
_FDT((fdt_property_string(fdt, "compatible", "linux,kvm")));
if (kvmppc_has_cap_fixup_hcalls()) {
kvmppc_get_hypercall(first_cpu->env_ptr, hypercall,
sizeof(hypercall));
_FDT((fdt_property(fdt, "hcall-instructions", hypercall,
sizeof(hypercall))));
}
_FDT((fdt_end_node(fdt)));
}
_FDT((fdt_end_node(fdt)));
_FDT((fdt_finish(fdt)));
return fdt;
}
| {
"code": [
" kvmppc_get_hypercall(first_cpu->env_ptr, hypercall,",
" sizeof(hypercall));",
" _FDT((fdt_property(fdt, \"hcall-instructions\", hypercall,",
" sizeof(hypercall))));"
],
"line_no": [
373,
375,
377,
379
]
} | static void *FUNC_0(hwaddr VAR_0,
hwaddr VAR_1,
hwaddr VAR_2,
bool VAR_3,
const char *VAR_4,
uint32_t VAR_5)
{
void *VAR_6;
uint32_t start_prop = cpu_to_be32(VAR_0);
uint32_t end_prop = cpu_to_be32(VAR_0 + VAR_1);
GString *hypertas = g_string_sized_new(256);
GString *qemu_hypertas = g_string_sized_new(256);
uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(max_cpus)};
unsigned char VAR_7[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
char *VAR_8;
add_str(hypertas, "hcall-pft");
add_str(hypertas, "hcall-term");
add_str(hypertas, "hcall-dabr");
add_str(hypertas, "hcall-interrupt");
add_str(hypertas, "hcall-tce");
add_str(hypertas, "hcall-vio");
add_str(hypertas, "hcall-splpar");
add_str(hypertas, "hcall-bulk");
add_str(hypertas, "hcall-set-mode");
add_str(qemu_hypertas, "hcall-memop1");
VAR_6 = g_malloc0(FDT_MAX_SIZE);
_FDT((fdt_create(VAR_6, FDT_MAX_SIZE)));
if (VAR_2) {
_FDT((fdt_add_reservemap_entry(VAR_6, KERNEL_LOAD_ADDR, VAR_2)));
}
if (VAR_1) {
_FDT((fdt_add_reservemap_entry(VAR_6, VAR_0, VAR_1)));
}
_FDT((fdt_finish_reservemap(VAR_6)));
_FDT((fdt_begin_node(VAR_6, "")));
_FDT((fdt_property_string(VAR_6, "device_type", "chrp")));
_FDT((fdt_property_string(VAR_6, "model", "IBM pSeries (emulated by qemu)")));
_FDT((fdt_property_string(VAR_6, "compatible", "qemu,pseries")));
if (kvmppc_get_host_model(&VAR_8)) {
_FDT((fdt_property_string(VAR_6, "host-model", VAR_8)));
g_free(VAR_8);
}
if (kvmppc_get_host_serial(&VAR_8)) {
_FDT((fdt_property_string(VAR_6, "host-serial", VAR_8)));
g_free(VAR_8);
}
VAR_8 = g_strdup_printf(UUID_FMT, qemu_uuid[0], qemu_uuid[1],
qemu_uuid[2], qemu_uuid[3], qemu_uuid[4],
qemu_uuid[5], qemu_uuid[6], qemu_uuid[7],
qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
qemu_uuid[14], qemu_uuid[15]);
_FDT((fdt_property_string(VAR_6, "vm,uuid", VAR_8)));
if (qemu_uuid_set) {
_FDT((fdt_property_string(VAR_6, "system-id", VAR_8)));
}
g_free(VAR_8);
if (qemu_get_vm_name()) {
_FDT((fdt_property_string(VAR_6, "ibm,partition-name",
qemu_get_vm_name())));
}
_FDT((fdt_property_cell(VAR_6, "#address-cells", 0x2)));
_FDT((fdt_property_cell(VAR_6, "#size-cells", 0x2)));
_FDT((fdt_begin_node(VAR_6, "chosen")));
_FDT((fdt_property(VAR_6, "ibm,architecture-vec-5", VAR_7, sizeof(VAR_7))));
_FDT((fdt_property_string(VAR_6, "bootargs", VAR_4)));
_FDT((fdt_property(VAR_6, "linux,initrd-start",
&start_prop, sizeof(start_prop))));
_FDT((fdt_property(VAR_6, "linux,initrd-end",
&end_prop, sizeof(end_prop))));
if (VAR_2) {
uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),
cpu_to_be64(VAR_2) };
_FDT((fdt_property(VAR_6, "qemu,boot-kernel", &kprop, sizeof(kprop))));
if (VAR_3) {
_FDT((fdt_property(VAR_6, "qemu,boot-kernel-le", NULL, 0)));
}
}
if (boot_menu) {
_FDT((fdt_property_cell(VAR_6, "qemu,boot-menu", boot_menu)));
}
_FDT((fdt_property_cell(VAR_6, "qemu,graphic-width", graphic_width)));
_FDT((fdt_property_cell(VAR_6, "qemu,graphic-height", graphic_height)));
_FDT((fdt_property_cell(VAR_6, "qemu,graphic-depth", graphic_depth)));
_FDT((fdt_end_node(VAR_6)));
_FDT((fdt_begin_node(VAR_6, "rtas")));
if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
add_str(hypertas, "hcall-multi-tce");
}
_FDT((fdt_property(VAR_6, "ibm,hypertas-functions", hypertas->str,
hypertas->len)));
g_string_free(hypertas, TRUE);
_FDT((fdt_property(VAR_6, "qemu,hypertas-functions", qemu_hypertas->str,
qemu_hypertas->len)));
g_string_free(qemu_hypertas, TRUE);
_FDT((fdt_property(VAR_6, "ibm,associativity-reference-points",
refpoints, sizeof(refpoints))));
_FDT((fdt_property_cell(VAR_6, "rtas-error-log-max", RTAS_ERROR_LOG_MAX)));
_FDT((fdt_property_cell(VAR_6, "rtas-event-scan-rate",
RTAS_EVENT_SCAN_RATE)));
if (msi_nonbroken) {
_FDT((fdt_property(VAR_6, "ibm,change-msix-capable", NULL, 0)));
}
_FDT((fdt_property(VAR_6, "ibm,extended-os-term", NULL, 0)));
_FDT((fdt_end_node(VAR_6)));
_FDT((fdt_begin_node(VAR_6, "interrupt-controller")));
_FDT((fdt_property_string(VAR_6, "device_type",
"PowerPC-External-Interrupt-Presentation")));
_FDT((fdt_property_string(VAR_6, "compatible", "IBM,ppc-xicp")));
_FDT((fdt_property(VAR_6, "interrupt-controller", NULL, 0)));
_FDT((fdt_property(VAR_6, "ibm,interrupt-server-ranges",
interrupt_server_ranges_prop,
sizeof(interrupt_server_ranges_prop))));
_FDT((fdt_property_cell(VAR_6, "#interrupt-cells", 2)));
_FDT((fdt_property_cell(VAR_6, "linux,phandle", PHANDLE_XICP)));
_FDT((fdt_property_cell(VAR_6, "phandle", PHANDLE_XICP)));
_FDT((fdt_end_node(VAR_6)));
_FDT((fdt_begin_node(VAR_6, "vdevice")));
_FDT((fdt_property_string(VAR_6, "device_type", "vdevice")));
_FDT((fdt_property_string(VAR_6, "compatible", "IBM,vdevice")));
_FDT((fdt_property_cell(VAR_6, "#address-cells", 0x1)));
_FDT((fdt_property_cell(VAR_6, "#size-cells", 0x0)));
_FDT((fdt_property_cell(VAR_6, "#interrupt-cells", 0x2)));
_FDT((fdt_property(VAR_6, "interrupt-controller", NULL, 0)));
_FDT((fdt_end_node(VAR_6)));
spapr_events_fdt_skel(VAR_6, VAR_5);
if (kvm_enabled()) {
uint8_t hypercall[16];
_FDT((fdt_begin_node(VAR_6, "hypervisor")));
_FDT((fdt_property_string(VAR_6, "compatible", "linux,kvm")));
if (kvmppc_has_cap_fixup_hcalls()) {
kvmppc_get_hypercall(first_cpu->env_ptr, hypercall,
sizeof(hypercall));
_FDT((fdt_property(VAR_6, "hcall-instructions", hypercall,
sizeof(hypercall))));
}
_FDT((fdt_end_node(VAR_6)));
}
_FDT((fdt_end_node(VAR_6)));
_FDT((fdt_finish(VAR_6)));
return VAR_6;
}
| [
"static void *FUNC_0(hwaddr VAR_0,\nhwaddr VAR_1,\nhwaddr VAR_2,\nbool VAR_3,\nconst char *VAR_4,\nuint32_t VAR_5)\n{",
"void *VAR_6;",
"uint32_t start_prop = cpu_to_be32(VAR_0);",
"uint32_t end_prop = cpu_to_be32(VAR_0 + VAR_1);",
"GString *hypertas = g_string_sized_new(256);",
"GString *qemu_hypertas = g_string_sized_new(256);",
"uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};",
"uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(max_cpus)};",
"unsigned char VAR_7[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};",
"char *VAR_8;",
"add_str(hypertas, \"hcall-pft\");",
"add_str(hypertas, \"hcall-term\");",
"add_str(hypertas, \"hcall-dabr\");",
"add_str(hypertas, \"hcall-interrupt\");",
"add_str(hypertas, \"hcall-tce\");",
"add_str(hypertas, \"hcall-vio\");",
"add_str(hypertas, \"hcall-splpar\");",
"add_str(hypertas, \"hcall-bulk\");",
"add_str(hypertas, \"hcall-set-mode\");",
"add_str(qemu_hypertas, \"hcall-memop1\");",
"VAR_6 = g_malloc0(FDT_MAX_SIZE);",
"_FDT((fdt_create(VAR_6, FDT_MAX_SIZE)));",
"if (VAR_2) {",
"_FDT((fdt_add_reservemap_entry(VAR_6, KERNEL_LOAD_ADDR, VAR_2)));",
"}",
"if (VAR_1) {",
"_FDT((fdt_add_reservemap_entry(VAR_6, VAR_0, VAR_1)));",
"}",
"_FDT((fdt_finish_reservemap(VAR_6)));",
"_FDT((fdt_begin_node(VAR_6, \"\")));",
"_FDT((fdt_property_string(VAR_6, \"device_type\", \"chrp\")));",
"_FDT((fdt_property_string(VAR_6, \"model\", \"IBM pSeries (emulated by qemu)\")));",
"_FDT((fdt_property_string(VAR_6, \"compatible\", \"qemu,pseries\")));",
"if (kvmppc_get_host_model(&VAR_8)) {",
"_FDT((fdt_property_string(VAR_6, \"host-model\", VAR_8)));",
"g_free(VAR_8);",
"}",
"if (kvmppc_get_host_serial(&VAR_8)) {",
"_FDT((fdt_property_string(VAR_6, \"host-serial\", VAR_8)));",
"g_free(VAR_8);",
"}",
"VAR_8 = g_strdup_printf(UUID_FMT, qemu_uuid[0], qemu_uuid[1],\nqemu_uuid[2], qemu_uuid[3], qemu_uuid[4],\nqemu_uuid[5], qemu_uuid[6], qemu_uuid[7],\nqemu_uuid[8], qemu_uuid[9], qemu_uuid[10],\nqemu_uuid[11], qemu_uuid[12], qemu_uuid[13],\nqemu_uuid[14], qemu_uuid[15]);",
"_FDT((fdt_property_string(VAR_6, \"vm,uuid\", VAR_8)));",
"if (qemu_uuid_set) {",
"_FDT((fdt_property_string(VAR_6, \"system-id\", VAR_8)));",
"}",
"g_free(VAR_8);",
"if (qemu_get_vm_name()) {",
"_FDT((fdt_property_string(VAR_6, \"ibm,partition-name\",\nqemu_get_vm_name())));",
"}",
"_FDT((fdt_property_cell(VAR_6, \"#address-cells\", 0x2)));",
"_FDT((fdt_property_cell(VAR_6, \"#size-cells\", 0x2)));",
"_FDT((fdt_begin_node(VAR_6, \"chosen\")));",
"_FDT((fdt_property(VAR_6, \"ibm,architecture-vec-5\", VAR_7, sizeof(VAR_7))));",
"_FDT((fdt_property_string(VAR_6, \"bootargs\", VAR_4)));",
"_FDT((fdt_property(VAR_6, \"linux,initrd-start\",\n&start_prop, sizeof(start_prop))));",
"_FDT((fdt_property(VAR_6, \"linux,initrd-end\",\n&end_prop, sizeof(end_prop))));",
"if (VAR_2) {",
"uint64_t kprop[2] = { cpu_to_be64(KERNEL_LOAD_ADDR),",
"cpu_to_be64(VAR_2) };",
"_FDT((fdt_property(VAR_6, \"qemu,boot-kernel\", &kprop, sizeof(kprop))));",
"if (VAR_3) {",
"_FDT((fdt_property(VAR_6, \"qemu,boot-kernel-le\", NULL, 0)));",
"}",
"}",
"if (boot_menu) {",
"_FDT((fdt_property_cell(VAR_6, \"qemu,boot-menu\", boot_menu)));",
"}",
"_FDT((fdt_property_cell(VAR_6, \"qemu,graphic-width\", graphic_width)));",
"_FDT((fdt_property_cell(VAR_6, \"qemu,graphic-height\", graphic_height)));",
"_FDT((fdt_property_cell(VAR_6, \"qemu,graphic-depth\", graphic_depth)));",
"_FDT((fdt_end_node(VAR_6)));",
"_FDT((fdt_begin_node(VAR_6, \"rtas\")));",
"if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {",
"add_str(hypertas, \"hcall-multi-tce\");",
"}",
"_FDT((fdt_property(VAR_6, \"ibm,hypertas-functions\", hypertas->str,\nhypertas->len)));",
"g_string_free(hypertas, TRUE);",
"_FDT((fdt_property(VAR_6, \"qemu,hypertas-functions\", qemu_hypertas->str,\nqemu_hypertas->len)));",
"g_string_free(qemu_hypertas, TRUE);",
"_FDT((fdt_property(VAR_6, \"ibm,associativity-reference-points\",\nrefpoints, sizeof(refpoints))));",
"_FDT((fdt_property_cell(VAR_6, \"rtas-error-log-max\", RTAS_ERROR_LOG_MAX)));",
"_FDT((fdt_property_cell(VAR_6, \"rtas-event-scan-rate\",\nRTAS_EVENT_SCAN_RATE)));",
"if (msi_nonbroken) {",
"_FDT((fdt_property(VAR_6, \"ibm,change-msix-capable\", NULL, 0)));",
"}",
"_FDT((fdt_property(VAR_6, \"ibm,extended-os-term\", NULL, 0)));",
"_FDT((fdt_end_node(VAR_6)));",
"_FDT((fdt_begin_node(VAR_6, \"interrupt-controller\")));",
"_FDT((fdt_property_string(VAR_6, \"device_type\",\n\"PowerPC-External-Interrupt-Presentation\")));",
"_FDT((fdt_property_string(VAR_6, \"compatible\", \"IBM,ppc-xicp\")));",
"_FDT((fdt_property(VAR_6, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_property(VAR_6, \"ibm,interrupt-server-ranges\",\ninterrupt_server_ranges_prop,\nsizeof(interrupt_server_ranges_prop))));",
"_FDT((fdt_property_cell(VAR_6, \"#interrupt-cells\", 2)));",
"_FDT((fdt_property_cell(VAR_6, \"linux,phandle\", PHANDLE_XICP)));",
"_FDT((fdt_property_cell(VAR_6, \"phandle\", PHANDLE_XICP)));",
"_FDT((fdt_end_node(VAR_6)));",
"_FDT((fdt_begin_node(VAR_6, \"vdevice\")));",
"_FDT((fdt_property_string(VAR_6, \"device_type\", \"vdevice\")));",
"_FDT((fdt_property_string(VAR_6, \"compatible\", \"IBM,vdevice\")));",
"_FDT((fdt_property_cell(VAR_6, \"#address-cells\", 0x1)));",
"_FDT((fdt_property_cell(VAR_6, \"#size-cells\", 0x0)));",
"_FDT((fdt_property_cell(VAR_6, \"#interrupt-cells\", 0x2)));",
"_FDT((fdt_property(VAR_6, \"interrupt-controller\", NULL, 0)));",
"_FDT((fdt_end_node(VAR_6)));",
"spapr_events_fdt_skel(VAR_6, VAR_5);",
"if (kvm_enabled()) {",
"uint8_t hypercall[16];",
"_FDT((fdt_begin_node(VAR_6, \"hypervisor\")));",
"_FDT((fdt_property_string(VAR_6, \"compatible\", \"linux,kvm\")));",
"if (kvmppc_has_cap_fixup_hcalls()) {",
"kvmppc_get_hypercall(first_cpu->env_ptr, hypercall,\nsizeof(hypercall));",
"_FDT((fdt_property(VAR_6, \"hcall-instructions\", hypercall,\nsizeof(hypercall))));",
"}",
"_FDT((fdt_end_node(VAR_6)));",
"}",
"_FDT((fdt_end_node(VAR_6)));",
"_FDT((fdt_finish(VAR_6)));",
"return VAR_6;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117,
119,
121,
123,
125,
127
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145,
147
],
[
149
],
[
153
],
[
155
],
[
161
],
[
167
],
[
171
],
[
173,
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229,
231
],
[
233
],
[
235,
237
],
[
239
],
[
243,
245
],
[
249
],
[
251,
253
],
[
257
],
[
259
],
[
261
],
[
279
],
[
283
],
[
289
],
[
293,
295
],
[
297
],
[
299
],
[
301,
303,
305
],
[
307
],
[
309
],
[
311
],
[
315
],
[
321
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
339
],
[
345
],
[
351
],
[
353
],
[
359
],
[
361
],
[
363
],
[
373,
375
],
[
377,
379
],
[
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
395
],
[
397
]
]
|
17,187 | static inline struct rgbvec interp_trilinear(const LUT3DContext *lut3d,
const struct rgbvec *s)
{
const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};
const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c00 = lerp(&c000, &c100, d.r);
const struct rgbvec c10 = lerp(&c010, &c110, d.r);
const struct rgbvec c01 = lerp(&c001, &c101, d.r);
const struct rgbvec c11 = lerp(&c011, &c111, d.r);
const struct rgbvec c0 = lerp(&c00, &c10, d.g);
const struct rgbvec c1 = lerp(&c01, &c11, d.g);
const struct rgbvec c = lerp(&c0, &c1, d.b);
return c;
}
| true | FFmpeg | b6ee25e300420a3c98b78a1c2e983250ff065038 | static inline struct rgbvec interp_trilinear(const LUT3DContext *lut3d,
const struct rgbvec *s)
{
const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};
const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];
const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];
const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];
const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];
const struct rgbvec c00 = lerp(&c000, &c100, d.r);
const struct rgbvec c10 = lerp(&c010, &c110, d.r);
const struct rgbvec c01 = lerp(&c001, &c101, d.r);
const struct rgbvec c11 = lerp(&c011, &c111, d.r);
const struct rgbvec c0 = lerp(&c00, &c10, d.g);
const struct rgbvec c1 = lerp(&c01, &c11, d.g);
const struct rgbvec c = lerp(&c0, &c1, d.b);
return c;
}
| {
"code": [
" const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};",
" const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];",
" const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];",
" const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];",
" const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];",
" const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];",
" const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];",
" const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];",
" const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];",
" const struct rgbvec d = {s->r - PREV(s->r), s->g - PREV(s->g), s->b - PREV(s->b)};",
" const struct rgbvec c000 = lut3d->lut[PREV(s->r)][PREV(s->g)][PREV(s->b)];",
" const struct rgbvec c001 = lut3d->lut[PREV(s->r)][PREV(s->g)][NEXT(s->b)];",
" const struct rgbvec c010 = lut3d->lut[PREV(s->r)][NEXT(s->g)][PREV(s->b)];",
" const struct rgbvec c011 = lut3d->lut[PREV(s->r)][NEXT(s->g)][NEXT(s->b)];",
" const struct rgbvec c100 = lut3d->lut[NEXT(s->r)][PREV(s->g)][PREV(s->b)];",
" const struct rgbvec c101 = lut3d->lut[NEXT(s->r)][PREV(s->g)][NEXT(s->b)];",
" const struct rgbvec c110 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][PREV(s->b)];",
" const struct rgbvec c111 = lut3d->lut[NEXT(s->r)][NEXT(s->g)][NEXT(s->b)];"
],
"line_no": [
7,
9,
11,
13,
15,
17,
19,
21,
23,
7,
9,
11,
13,
15,
17,
19,
21,
23
]
} | static inline struct rgbvec FUNC_0(const LUT3DContext *VAR_0,
const struct rgbvec *VAR_1)
{
const struct rgbvec VAR_2 = {VAR_1->r - PREV(VAR_1->r), VAR_1->g - PREV(VAR_1->g), VAR_1->b - PREV(VAR_1->b)};
const struct rgbvec VAR_3 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];
const struct rgbvec VAR_4 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];
const struct rgbvec VAR_5 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];
const struct rgbvec VAR_6 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];
const struct rgbvec VAR_7 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];
const struct rgbvec VAR_8 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];
const struct rgbvec VAR_9 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];
const struct rgbvec VAR_10 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];
const struct rgbvec VAR_11 = lerp(&VAR_3, &VAR_7, VAR_2.r);
const struct rgbvec VAR_12 = lerp(&VAR_5, &VAR_9, VAR_2.r);
const struct rgbvec VAR_13 = lerp(&VAR_4, &VAR_8, VAR_2.r);
const struct rgbvec VAR_14 = lerp(&VAR_6, &VAR_10, VAR_2.r);
const struct rgbvec VAR_15 = lerp(&VAR_11, &VAR_12, VAR_2.g);
const struct rgbvec VAR_16 = lerp(&VAR_13, &VAR_14, VAR_2.g);
const struct rgbvec VAR_17 = lerp(&VAR_15, &VAR_16, VAR_2.b);
return VAR_17;
}
| [
"static inline struct rgbvec FUNC_0(const LUT3DContext *VAR_0,\nconst struct rgbvec *VAR_1)\n{",
"const struct rgbvec VAR_2 = {VAR_1->r - PREV(VAR_1->r), VAR_1->g - PREV(VAR_1->g), VAR_1->b - PREV(VAR_1->b)};",
"const struct rgbvec VAR_3 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];",
"const struct rgbvec VAR_4 = VAR_0->lut[PREV(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];",
"const struct rgbvec VAR_5 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];",
"const struct rgbvec VAR_6 = VAR_0->lut[PREV(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];",
"const struct rgbvec VAR_7 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][PREV(VAR_1->b)];",
"const struct rgbvec VAR_8 = VAR_0->lut[NEXT(VAR_1->r)][PREV(VAR_1->g)][NEXT(VAR_1->b)];",
"const struct rgbvec VAR_9 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][PREV(VAR_1->b)];",
"const struct rgbvec VAR_10 = VAR_0->lut[NEXT(VAR_1->r)][NEXT(VAR_1->g)][NEXT(VAR_1->b)];",
"const struct rgbvec VAR_11 = lerp(&VAR_3, &VAR_7, VAR_2.r);",
"const struct rgbvec VAR_12 = lerp(&VAR_5, &VAR_9, VAR_2.r);",
"const struct rgbvec VAR_13 = lerp(&VAR_4, &VAR_8, VAR_2.r);",
"const struct rgbvec VAR_14 = lerp(&VAR_6, &VAR_10, VAR_2.r);",
"const struct rgbvec VAR_15 = lerp(&VAR_11, &VAR_12, VAR_2.g);",
"const struct rgbvec VAR_16 = lerp(&VAR_13, &VAR_14, VAR_2.g);",
"const struct rgbvec VAR_17 = lerp(&VAR_15, &VAR_16, VAR_2.b);",
"return VAR_17;",
"}"
]
| [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
]
]
|
17,188 | static void mux_chr_accept_input(CharDriverState *chr)
{
int m = chr->focus;
MuxDriver *d = chr->opaque;
while (d->prod != d->cons &&
d->chr_can_read[m] &&
d->chr_can_read[m](d->ext_opaque[m])) {
d->chr_read[m](d->ext_opaque[m],
&d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);
}
}
| true | qemu | a80bf99fa3dd829ecea88b9bfb4f7cf146208f07 | static void mux_chr_accept_input(CharDriverState *chr)
{
int m = chr->focus;
MuxDriver *d = chr->opaque;
while (d->prod != d->cons &&
d->chr_can_read[m] &&
d->chr_can_read[m](d->ext_opaque[m])) {
d->chr_read[m](d->ext_opaque[m],
&d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);
}
}
| {
"code": [
" while (d->prod != d->cons &&",
" &d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);"
],
"line_no": [
11,
19
]
} | static void FUNC_0(CharDriverState *VAR_0)
{
int VAR_1 = VAR_0->focus;
MuxDriver *d = VAR_0->opaque;
while (d->prod != d->cons &&
d->chr_can_read[VAR_1] &&
d->chr_can_read[VAR_1](d->ext_opaque[VAR_1])) {
d->chr_read[VAR_1](d->ext_opaque[VAR_1],
&d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);
}
}
| [
"static void FUNC_0(CharDriverState *VAR_0)\n{",
"int VAR_1 = VAR_0->focus;",
"MuxDriver *d = VAR_0->opaque;",
"while (d->prod != d->cons &&\nd->chr_can_read[VAR_1] &&\nd->chr_can_read[VAR_1](d->ext_opaque[VAR_1])) {",
"d->chr_read[VAR_1](d->ext_opaque[VAR_1],\n&d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);",
"}",
"}"
]
| [
0,
0,
0,
1,
1,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17,
19
],
[
21
],
[
23
]
]
|
17,189 | static int ogg_read_close(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
for (i = 0; i < ogg->nstreams; i++) {
av_free(ogg->streams[i].buf);
av_free(ogg->streams[i].private);
}
av_free(ogg->streams);
return 0;
}
| true | FFmpeg | 89b51b570daa80e6e3790fcd449fe61fc5574e07 | static int ogg_read_close(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
for (i = 0; i < ogg->nstreams; i++) {
av_free(ogg->streams[i].buf);
av_free(ogg->streams[i].private);
}
av_free(ogg->streams);
return 0;
}
| {
"code": [
"static int ogg_read_close(AVFormatContext *s)",
" struct ogg *ogg = s->priv_data;",
" int i;",
" for (i = 0; i < ogg->nstreams; i++) {",
" av_free(ogg->streams[i].buf);",
" av_free(ogg->streams[i].private);",
" av_free(ogg->streams);",
" return 0;"
],
"line_no": [
1,
5,
7,
11,
13,
15,
19,
21
]
} | static int FUNC_0(AVFormatContext *VAR_0)
{
struct VAR_1 *VAR_1 = VAR_0->priv_data;
int VAR_2;
for (VAR_2 = 0; VAR_2 < VAR_1->nstreams; VAR_2++) {
av_free(VAR_1->streams[VAR_2].buf);
av_free(VAR_1->streams[VAR_2].private);
}
av_free(VAR_1->streams);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"struct VAR_1 *VAR_1 = VAR_0->priv_data;",
"int VAR_2;",
"for (VAR_2 = 0; VAR_2 < VAR_1->nstreams; VAR_2++) {",
"av_free(VAR_1->streams[VAR_2].buf);",
"av_free(VAR_1->streams[VAR_2].private);",
"}",
"av_free(VAR_1->streams);",
"return 0;",
"}"
]
| [
1,
1,
1,
1,
1,
1,
0,
1,
1,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
]
|
17,190 | static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
{
Vp3DecodeContext *s = avctx->priv_data;
int i, n, matrices, inter, plane;
if (s->theora >= 0x030200) {
n = get_bits(gb, 3);
/* loop filter limit values table */
if (n) {
for (i = 0; i < 64; i++) {
s->filter_limit_values[i] = get_bits(gb, n);
if (s->filter_limit_values[i] > 127) {
av_log(avctx, AV_LOG_ERROR, "filter limit value too large (%i > 127), clamping\n", s->filter_limit_values[i]);
s->filter_limit_values[i] = 127;
if (s->theora >= 0x030200)
n = get_bits(gb, 4) + 1;
else
n = 16;
/* quality threshold table */
for (i = 0; i < 64; i++)
s->coded_ac_scale_factor[i] = get_bits(gb, n);
if (s->theora >= 0x030200)
n = get_bits(gb, 4) + 1;
else
n = 16;
/* dc scale factor table */
for (i = 0; i < 64; i++)
s->coded_dc_scale_factor[i] = get_bits(gb, n);
if (s->theora >= 0x030200)
matrices = get_bits(gb, 9) + 1;
else
matrices = 3;
if(matrices > 384){
av_log(avctx, AV_LOG_ERROR, "invalid number of base matrixes\n");
return -1;
for(n=0; n<matrices; n++){
for (i = 0; i < 64; i++)
s->base_matrix[n][i]= get_bits(gb, 8);
for (inter = 0; inter <= 1; inter++) {
for (plane = 0; plane <= 2; plane++) {
int newqr= 1;
if (inter || plane > 0)
newqr = get_bits1(gb);
if (!newqr) {
int qtj, plj;
if(inter && get_bits1(gb)){
qtj = 0;
plj = plane;
}else{
qtj= (3*inter + plane - 1) / 3;
plj= (plane + 2) % 3;
s->qr_count[inter][plane]= s->qr_count[qtj][plj];
memcpy(s->qr_size[inter][plane], s->qr_size[qtj][plj], sizeof(s->qr_size[0][0]));
memcpy(s->qr_base[inter][plane], s->qr_base[qtj][plj], sizeof(s->qr_base[0][0]));
} else {
int qri= 0;
int qi = 0;
for(;;){
i= get_bits(gb, av_log2(matrices-1)+1);
if(i>= matrices){
av_log(avctx, AV_LOG_ERROR, "invalid base matrix index\n");
return -1;
s->qr_base[inter][plane][qri]= i;
if(qi >= 63)
break;
i = get_bits(gb, av_log2(63-qi)+1) + 1;
s->qr_size[inter][plane][qri++]= i;
qi += i;
if (qi > 63) {
av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi);
return -1;
s->qr_count[inter][plane]= qri;
/* Huffman tables */
for (s->hti = 0; s->hti < 80; s->hti++) {
s->entries = 0;
s->huff_code_size = 1;
if (!get_bits1(gb)) {
s->hbits = 0;
if(read_huffman_tree(avctx, gb))
return -1;
s->hbits = 1;
if(read_huffman_tree(avctx, gb))
return -1;
s->theora_tables = 1;
return 0;
| true | FFmpeg | 1a48a57071df7756a92dee147acb2123cb92a799 | static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
{
Vp3DecodeContext *s = avctx->priv_data;
int i, n, matrices, inter, plane;
if (s->theora >= 0x030200) {
n = get_bits(gb, 3);
if (n) {
for (i = 0; i < 64; i++) {
s->filter_limit_values[i] = get_bits(gb, n);
if (s->filter_limit_values[i] > 127) {
av_log(avctx, AV_LOG_ERROR, "filter limit value too large (%i > 127), clamping\n", s->filter_limit_values[i]);
s->filter_limit_values[i] = 127;
if (s->theora >= 0x030200)
n = get_bits(gb, 4) + 1;
else
n = 16;
for (i = 0; i < 64; i++)
s->coded_ac_scale_factor[i] = get_bits(gb, n);
if (s->theora >= 0x030200)
n = get_bits(gb, 4) + 1;
else
n = 16;
for (i = 0; i < 64; i++)
s->coded_dc_scale_factor[i] = get_bits(gb, n);
if (s->theora >= 0x030200)
matrices = get_bits(gb, 9) + 1;
else
matrices = 3;
if(matrices > 384){
av_log(avctx, AV_LOG_ERROR, "invalid number of base matrixes\n");
return -1;
for(n=0; n<matrices; n++){
for (i = 0; i < 64; i++)
s->base_matrix[n][i]= get_bits(gb, 8);
for (inter = 0; inter <= 1; inter++) {
for (plane = 0; plane <= 2; plane++) {
int newqr= 1;
if (inter || plane > 0)
newqr = get_bits1(gb);
if (!newqr) {
int qtj, plj;
if(inter && get_bits1(gb)){
qtj = 0;
plj = plane;
}else{
qtj= (3*inter + plane - 1) / 3;
plj= (plane + 2) % 3;
s->qr_count[inter][plane]= s->qr_count[qtj][plj];
memcpy(s->qr_size[inter][plane], s->qr_size[qtj][plj], sizeof(s->qr_size[0][0]));
memcpy(s->qr_base[inter][plane], s->qr_base[qtj][plj], sizeof(s->qr_base[0][0]));
} else {
int qri= 0;
int qi = 0;
for(;;){
i= get_bits(gb, av_log2(matrices-1)+1);
if(i>= matrices){
av_log(avctx, AV_LOG_ERROR, "invalid base matrix index\n");
return -1;
s->qr_base[inter][plane][qri]= i;
if(qi >= 63)
break;
i = get_bits(gb, av_log2(63-qi)+1) + 1;
s->qr_size[inter][plane][qri++]= i;
qi += i;
if (qi > 63) {
av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi);
return -1;
s->qr_count[inter][plane]= qri;
for (s->hti = 0; s->hti < 80; s->hti++) {
s->entries = 0;
s->huff_code_size = 1;
if (!get_bits1(gb)) {
s->hbits = 0;
if(read_huffman_tree(avctx, gb))
return -1;
s->hbits = 1;
if(read_huffman_tree(avctx, gb))
return -1;
s->theora_tables = 1;
return 0;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1)
{
Vp3DecodeContext *s = VAR_0->priv_data;
int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;
if (s->theora >= 0x030200) {
VAR_3 = get_bits(VAR_1, 3);
if (VAR_3) {
for (VAR_2 = 0; VAR_2 < 64; VAR_2++) {
s->filter_limit_values[VAR_2] = get_bits(VAR_1, VAR_3);
if (s->filter_limit_values[VAR_2] > 127) {
av_log(VAR_0, AV_LOG_ERROR, "filter limit value too large (%VAR_2 > 127), clamping\VAR_3", s->filter_limit_values[VAR_2]);
s->filter_limit_values[VAR_2] = 127;
if (s->theora >= 0x030200)
VAR_3 = get_bits(VAR_1, 4) + 1;
else
VAR_3 = 16;
for (VAR_2 = 0; VAR_2 < 64; VAR_2++)
s->coded_ac_scale_factor[VAR_2] = get_bits(VAR_1, VAR_3);
if (s->theora >= 0x030200)
VAR_3 = get_bits(VAR_1, 4) + 1;
else
VAR_3 = 16;
for (VAR_2 = 0; VAR_2 < 64; VAR_2++)
s->coded_dc_scale_factor[VAR_2] = get_bits(VAR_1, VAR_3);
if (s->theora >= 0x030200)
VAR_4 = get_bits(VAR_1, 9) + 1;
else
VAR_4 = 3;
if(VAR_4 > 384){
av_log(VAR_0, AV_LOG_ERROR, "invalid number of base matrixes\VAR_3");
return -1;
for(VAR_3=0; VAR_3<VAR_4; VAR_3++){
for (VAR_2 = 0; VAR_2 < 64; VAR_2++)
s->base_matrix[VAR_3][VAR_2]= get_bits(VAR_1, 8);
for (VAR_5 = 0; VAR_5 <= 1; VAR_5++) {
for (VAR_6 = 0; VAR_6 <= 2; VAR_6++) {
int VAR_7= 1;
if (VAR_5 || VAR_6 > 0)
VAR_7 = get_bits1(VAR_1);
if (!VAR_7) {
int VAR_8, VAR_9;
if(VAR_5 && get_bits1(VAR_1)){
VAR_8 = 0;
VAR_9 = VAR_6;
}else{
VAR_8= (3*VAR_5 + VAR_6 - 1) / 3;
VAR_9= (VAR_6 + 2) % 3;
s->qr_count[VAR_5][VAR_6]= s->qr_count[VAR_8][VAR_9];
memcpy(s->qr_size[VAR_5][VAR_6], s->qr_size[VAR_8][VAR_9], sizeof(s->qr_size[0][0]));
memcpy(s->qr_base[VAR_5][VAR_6], s->qr_base[VAR_8][VAR_9], sizeof(s->qr_base[0][0]));
} else {
int qri= 0;
int qi = 0;
for(;;){
VAR_2= get_bits(VAR_1, av_log2(VAR_4-1)+1);
if(VAR_2>= VAR_4){
av_log(VAR_0, AV_LOG_ERROR, "invalid base matrix index\VAR_3");
return -1;
s->qr_base[VAR_5][VAR_6][qri]= VAR_2;
if(qi >= 63)
break;
VAR_2 = get_bits(VAR_1, av_log2(63-qi)+1) + 1;
s->qr_size[VAR_5][VAR_6][qri++]= VAR_2;
qi += VAR_2;
if (qi > 63) {
av_log(VAR_0, AV_LOG_ERROR, "invalid qi %d > 63\VAR_3", qi);
return -1;
s->qr_count[VAR_5][VAR_6]= qri;
for (s->hti = 0; s->hti < 80; s->hti++) {
s->entries = 0;
s->huff_code_size = 1;
if (!get_bits1(VAR_1)) {
s->hbits = 0;
if(read_huffman_tree(VAR_0, VAR_1))
return -1;
s->hbits = 1;
if(read_huffman_tree(VAR_0, VAR_1))
return -1;
s->theora_tables = 1;
return 0;
| [
"static int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1)\n{",
"Vp3DecodeContext *s = VAR_0->priv_data;",
"int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;",
"if (s->theora >= 0x030200) {",
"VAR_3 = get_bits(VAR_1, 3);",
"if (VAR_3) {",
"for (VAR_2 = 0; VAR_2 < 64; VAR_2++) {",
"s->filter_limit_values[VAR_2] = get_bits(VAR_1, VAR_3);",
"if (s->filter_limit_values[VAR_2] > 127) {",
"av_log(VAR_0, AV_LOG_ERROR, \"filter limit value too large (%VAR_2 > 127), clamping\\VAR_3\", s->filter_limit_values[VAR_2]);",
"s->filter_limit_values[VAR_2] = 127;",
"if (s->theora >= 0x030200)\nVAR_3 = get_bits(VAR_1, 4) + 1;",
"else\nVAR_3 = 16;",
"for (VAR_2 = 0; VAR_2 < 64; VAR_2++)",
"s->coded_ac_scale_factor[VAR_2] = get_bits(VAR_1, VAR_3);",
"if (s->theora >= 0x030200)\nVAR_3 = get_bits(VAR_1, 4) + 1;",
"else\nVAR_3 = 16;",
"for (VAR_2 = 0; VAR_2 < 64; VAR_2++)",
"s->coded_dc_scale_factor[VAR_2] = get_bits(VAR_1, VAR_3);",
"if (s->theora >= 0x030200)\nVAR_4 = get_bits(VAR_1, 9) + 1;",
"else\nVAR_4 = 3;",
"if(VAR_4 > 384){",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid number of base matrixes\\VAR_3\");",
"return -1;",
"for(VAR_3=0; VAR_3<VAR_4; VAR_3++){",
"for (VAR_2 = 0; VAR_2 < 64; VAR_2++)",
"s->base_matrix[VAR_3][VAR_2]= get_bits(VAR_1, 8);",
"for (VAR_5 = 0; VAR_5 <= 1; VAR_5++) {",
"for (VAR_6 = 0; VAR_6 <= 2; VAR_6++) {",
"int VAR_7= 1;",
"if (VAR_5 || VAR_6 > 0)\nVAR_7 = get_bits1(VAR_1);",
"if (!VAR_7) {",
"int VAR_8, VAR_9;",
"if(VAR_5 && get_bits1(VAR_1)){",
"VAR_8 = 0;",
"VAR_9 = VAR_6;",
"}else{",
"VAR_8= (3*VAR_5 + VAR_6 - 1) / 3;",
"VAR_9= (VAR_6 + 2) % 3;",
"s->qr_count[VAR_5][VAR_6]= s->qr_count[VAR_8][VAR_9];",
"memcpy(s->qr_size[VAR_5][VAR_6], s->qr_size[VAR_8][VAR_9], sizeof(s->qr_size[0][0]));",
"memcpy(s->qr_base[VAR_5][VAR_6], s->qr_base[VAR_8][VAR_9], sizeof(s->qr_base[0][0]));",
"} else {",
"int qri= 0;",
"int qi = 0;",
"for(;;){",
"VAR_2= get_bits(VAR_1, av_log2(VAR_4-1)+1);",
"if(VAR_2>= VAR_4){",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid base matrix index\\VAR_3\");",
"return -1;",
"s->qr_base[VAR_5][VAR_6][qri]= VAR_2;",
"if(qi >= 63)\nbreak;",
"VAR_2 = get_bits(VAR_1, av_log2(63-qi)+1) + 1;",
"s->qr_size[VAR_5][VAR_6][qri++]= VAR_2;",
"qi += VAR_2;",
"if (qi > 63) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid qi %d > 63\\VAR_3\", qi);",
"return -1;",
"s->qr_count[VAR_5][VAR_6]= qri;",
"for (s->hti = 0; s->hti < 80; s->hti++) {",
"s->entries = 0;",
"s->huff_code_size = 1;",
"if (!get_bits1(VAR_1)) {",
"s->hbits = 0;",
"if(read_huffman_tree(VAR_0, VAR_1))\nreturn -1;",
"s->hbits = 1;",
"if(read_huffman_tree(VAR_0, VAR_1))\nreturn -1;",
"s->theora_tables = 1;",
"return 0;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
35,
37
],
[
39,
41
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
61
],
[
63
],
[
67,
69
],
[
71,
73
],
[
77
],
[
79
],
[
81
],
[
86
],
[
88
],
[
90
],
[
95
],
[
97
],
[
99
],
[
101,
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
122
],
[
124
],
[
126
],
[
128
],
[
130
],
[
132
],
[
136
],
[
138
],
[
140
],
[
142
],
[
144
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
162
],
[
164
],
[
166
],
[
169
],
[
178
],
[
180
],
[
182
],
[
184
],
[
186
],
[
188,
190
],
[
192
],
[
194,
196
],
[
202
],
[
206
]
]
|
17,192 | int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
{
BDRVQcowState *s = bs->opaque;
int64_t offset;
size_t free_in_cluster;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);
assert(size > 0 && size <= s->cluster_size);
assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));
offset = s->free_byte_offset;
if (offset) {
uint64_t refcount;
ret = qcow2_get_refcount(bs, offset >> s->cluster_bits, &refcount);
if (ret < 0) {
return ret;
}
if (refcount == s->refcount_max) {
offset = 0;
}
}
free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);
if (!offset || free_in_cluster < size) {
int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
if (new_cluster < 0) {
return new_cluster;
}
if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
offset = new_cluster;
}
}
assert(offset);
ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
if (ret < 0) {
return ret;
}
/* The cluster refcount was incremented; refcount blocks must be flushed
* before the caller's L2 table updates. */
qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
s->free_byte_offset = offset + size;
if (!offset_into_cluster(s, s->free_byte_offset)) {
s->free_byte_offset = 0;
}
return offset;
}
| true | qemu | 3e5feb6202149e8a963a33b911216e40d790f1d7 | int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
{
BDRVQcowState *s = bs->opaque;
int64_t offset;
size_t free_in_cluster;
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);
assert(size > 0 && size <= s->cluster_size);
assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));
offset = s->free_byte_offset;
if (offset) {
uint64_t refcount;
ret = qcow2_get_refcount(bs, offset >> s->cluster_bits, &refcount);
if (ret < 0) {
return ret;
}
if (refcount == s->refcount_max) {
offset = 0;
}
}
free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);
if (!offset || free_in_cluster < size) {
int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
if (new_cluster < 0) {
return new_cluster;
}
if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
offset = new_cluster;
}
}
assert(offset);
ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
if (ret < 0) {
return ret;
}
qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
s->free_byte_offset = offset + size;
if (!offset_into_cluster(s, s->free_byte_offset)) {
s->free_byte_offset = 0;
}
return offset;
}
| {
"code": [
" if (!offset || free_in_cluster < size) {",
" int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);",
" if (new_cluster < 0) {",
" return new_cluster;",
" if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {",
" offset = new_cluster;",
" assert(offset);",
" ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);"
],
"line_no": [
53,
55,
57,
59,
65,
67,
75,
77
]
} | int64_t FUNC_0(BlockDriverState *bs, int size)
{
BDRVQcowState *s = bs->opaque;
int64_t offset;
size_t free_in_cluster;
int VAR_0;
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);
assert(size > 0 && size <= s->cluster_size);
assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));
offset = s->free_byte_offset;
if (offset) {
uint64_t refcount;
VAR_0 = qcow2_get_refcount(bs, offset >> s->cluster_bits, &refcount);
if (VAR_0 < 0) {
return VAR_0;
}
if (refcount == s->refcount_max) {
offset = 0;
}
}
free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);
if (!offset || free_in_cluster < size) {
int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);
if (new_cluster < 0) {
return new_cluster;
}
if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {
offset = new_cluster;
}
}
assert(offset);
VAR_0 = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);
if (VAR_0 < 0) {
return VAR_0;
}
qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
s->free_byte_offset = offset + size;
if (!offset_into_cluster(s, s->free_byte_offset)) {
s->free_byte_offset = 0;
}
return offset;
}
| [
"int64_t FUNC_0(BlockDriverState *bs, int size)\n{",
"BDRVQcowState *s = bs->opaque;",
"int64_t offset;",
"size_t free_in_cluster;",
"int VAR_0;",
"BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_BYTES);",
"assert(size > 0 && size <= s->cluster_size);",
"assert(!s->free_byte_offset || offset_into_cluster(s, s->free_byte_offset));",
"offset = s->free_byte_offset;",
"if (offset) {",
"uint64_t refcount;",
"VAR_0 = qcow2_get_refcount(bs, offset >> s->cluster_bits, &refcount);",
"if (VAR_0 < 0) {",
"return VAR_0;",
"}",
"if (refcount == s->refcount_max) {",
"offset = 0;",
"}",
"}",
"free_in_cluster = s->cluster_size - offset_into_cluster(s, offset);",
"if (!offset || free_in_cluster < size) {",
"int64_t new_cluster = alloc_clusters_noref(bs, s->cluster_size);",
"if (new_cluster < 0) {",
"return new_cluster;",
"}",
"if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) {",
"offset = new_cluster;",
"}",
"}",
"assert(offset);",
"VAR_0 = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER);",
"if (VAR_0 < 0) {",
"return VAR_0;",
"}",
"qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);",
"s->free_byte_offset = offset + size;",
"if (!offset_into_cluster(s, s->free_byte_offset)) {",
"s->free_byte_offset = 0;",
"}",
"return offset;",
"}"
]
| [
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,
1,
1,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
]
]
|
17,194 | void aio_co_schedule(AioContext *ctx, Coroutine *co)
{
trace_aio_co_schedule(ctx, co);
QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines,
co, co_scheduled_next);
qemu_bh_schedule(ctx->co_schedule_bh); | true | qemu | 6133b39f3c36623425a6ede9e89d93175fde15cd | void aio_co_schedule(AioContext *ctx, Coroutine *co)
{
trace_aio_co_schedule(ctx, co);
QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines,
co, co_scheduled_next);
qemu_bh_schedule(ctx->co_schedule_bh); | {
"code": [],
"line_no": []
} | void FUNC_0(AioContext *VAR_0, Coroutine *VAR_1)
{
trace_aio_co_schedule(VAR_0, VAR_1);
QSLIST_INSERT_HEAD_ATOMIC(&VAR_0->scheduled_coroutines,
VAR_1, co_scheduled_next);
qemu_bh_schedule(VAR_0->co_schedule_bh); | [
"void FUNC_0(AioContext *VAR_0, Coroutine *VAR_1)\n{",
"trace_aio_co_schedule(VAR_0, VAR_1);",
"QSLIST_INSERT_HEAD_ATOMIC(&VAR_0->scheduled_coroutines,\nVAR_1, co_scheduled_next);",
"qemu_bh_schedule(VAR_0->co_schedule_bh);"
]
| [
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4,
5
],
[
6
]
]
|
17,196 | static void xtensa_sim_init(MachineState *machine)
{
XtensaCPU *cpu = NULL;
CPUXtensaState *env = NULL;
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
int n;
if (!cpu_model) {
cpu_model = XTENSA_DEFAULT_CPU_MODEL;
}
for (n = 0; n < smp_cpus; n++) {
cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, cpu_model));
if (cpu == NULL) {
error_report("unable to find CPU definition '%s'",
cpu_model);
exit(EXIT_FAILURE);
}
env = &cpu->env;
env->sregs[PRID] = n;
qemu_register_reset(sim_reset, cpu);
/* Need MMU initialized prior to ELF loading,
* so that ELF gets loaded into virtual addresses
*/
sim_reset(cpu);
}
if (env) {
XtensaMemory sysram = env->config->sysram;
sysram.location[0].size = ram_size;
xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom");
xtensa_create_memory_regions(&env->config->instram, "xtensa.instram");
xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom");
xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram");
xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom");
xtensa_create_memory_regions(&sysram, "xtensa.sysram");
}
if (serial_hds[0]) {
xtensa_sim_open_console(serial_hds[0]);
}
if (kernel_filename) {
uint64_t elf_entry;
uint64_t elf_lowaddr;
#ifdef TARGET_WORDS_BIGENDIAN
int success = load_elf(kernel_filename, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 1, EM_XTENSA, 0, 0);
#else
int success = load_elf(kernel_filename, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 0, EM_XTENSA, 0, 0);
#endif
if (success > 0) {
env->pc = elf_entry;
}
}
}
| true | qemu | 4482e05cbbb7e50e476f6a9500cf0b38913bd939 | static void xtensa_sim_init(MachineState *machine)
{
XtensaCPU *cpu = NULL;
CPUXtensaState *env = NULL;
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
int n;
if (!cpu_model) {
cpu_model = XTENSA_DEFAULT_CPU_MODEL;
}
for (n = 0; n < smp_cpus; n++) {
cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, cpu_model));
if (cpu == NULL) {
error_report("unable to find CPU definition '%s'",
cpu_model);
exit(EXIT_FAILURE);
}
env = &cpu->env;
env->sregs[PRID] = n;
qemu_register_reset(sim_reset, cpu);
sim_reset(cpu);
}
if (env) {
XtensaMemory sysram = env->config->sysram;
sysram.location[0].size = ram_size;
xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom");
xtensa_create_memory_regions(&env->config->instram, "xtensa.instram");
xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom");
xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram");
xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom");
xtensa_create_memory_regions(&sysram, "xtensa.sysram");
}
if (serial_hds[0]) {
xtensa_sim_open_console(serial_hds[0]);
}
if (kernel_filename) {
uint64_t elf_entry;
uint64_t elf_lowaddr;
#ifdef TARGET_WORDS_BIGENDIAN
int success = load_elf(kernel_filename, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 1, EM_XTENSA, 0, 0);
#else
int success = load_elf(kernel_filename, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 0, EM_XTENSA, 0, 0);
#endif
if (success > 0) {
env->pc = elf_entry;
}
}
}
| {
"code": [
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" if (cpu == NULL) {",
" error_report(\"unable to find CPU definition '%s'\",",
" cpu_model);",
" exit(EXIT_FAILURE);",
" if (cpu == NULL) {",
" error_report(\"unable to find CPU definition '%s'\",",
" cpu_model);",
" exit(EXIT_FAILURE);"
],
"line_no": [
31,
31,
31,
31,
31,
31,
31,
31,
33,
35,
37,
31,
33,
35,
37
]
} | static void FUNC_0(MachineState *VAR_0)
{
XtensaCPU *cpu = NULL;
CPUXtensaState *env = NULL;
ram_addr_t ram_size = VAR_0->ram_size;
const char *VAR_1 = VAR_0->VAR_1;
const char *VAR_2 = VAR_0->VAR_2;
int VAR_3;
if (!VAR_1) {
VAR_1 = XTENSA_DEFAULT_CPU_MODEL;
}
for (VAR_3 = 0; VAR_3 < smp_cpus; VAR_3++) {
cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, VAR_1));
if (cpu == NULL) {
error_report("unable to find CPU definition '%s'",
VAR_1);
exit(EXIT_FAILURE);
}
env = &cpu->env;
env->sregs[PRID] = VAR_3;
qemu_register_reset(sim_reset, cpu);
sim_reset(cpu);
}
if (env) {
XtensaMemory sysram = env->config->sysram;
sysram.location[0].size = ram_size;
xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom");
xtensa_create_memory_regions(&env->config->instram, "xtensa.instram");
xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom");
xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram");
xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom");
xtensa_create_memory_regions(&sysram, "xtensa.sysram");
}
if (serial_hds[0]) {
xtensa_sim_open_console(serial_hds[0]);
}
if (VAR_2) {
uint64_t elf_entry;
uint64_t elf_lowaddr;
#ifdef TARGET_WORDS_BIGENDIAN
int VAR_4 = load_elf(VAR_2, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 1, EM_XTENSA, 0, 0);
#else
int VAR_4 = load_elf(VAR_2, translate_phys_addr, cpu,
&elf_entry, &elf_lowaddr, NULL, 0, EM_XTENSA, 0, 0);
#endif
if (VAR_4 > 0) {
env->pc = elf_entry;
}
}
}
| [
"static void FUNC_0(MachineState *VAR_0)\n{",
"XtensaCPU *cpu = NULL;",
"CPUXtensaState *env = NULL;",
"ram_addr_t ram_size = VAR_0->ram_size;",
"const char *VAR_1 = VAR_0->VAR_1;",
"const char *VAR_2 = VAR_0->VAR_2;",
"int VAR_3;",
"if (!VAR_1) {",
"VAR_1 = XTENSA_DEFAULT_CPU_MODEL;",
"}",
"for (VAR_3 = 0; VAR_3 < smp_cpus; VAR_3++) {",
"cpu = XTENSA_CPU(cpu_generic_init(TYPE_XTENSA_CPU, VAR_1));",
"if (cpu == NULL) {",
"error_report(\"unable to find CPU definition '%s'\",\nVAR_1);",
"exit(EXIT_FAILURE);",
"}",
"env = &cpu->env;",
"env->sregs[PRID] = VAR_3;",
"qemu_register_reset(sim_reset, cpu);",
"sim_reset(cpu);",
"}",
"if (env) {",
"XtensaMemory sysram = env->config->sysram;",
"sysram.location[0].size = ram_size;",
"xtensa_create_memory_regions(&env->config->instrom, \"xtensa.instrom\");",
"xtensa_create_memory_regions(&env->config->instram, \"xtensa.instram\");",
"xtensa_create_memory_regions(&env->config->datarom, \"xtensa.datarom\");",
"xtensa_create_memory_regions(&env->config->dataram, \"xtensa.dataram\");",
"xtensa_create_memory_regions(&env->config->sysrom, \"xtensa.sysrom\");",
"xtensa_create_memory_regions(&sysram, \"xtensa.sysram\");",
"}",
"if (serial_hds[0]) {",
"xtensa_sim_open_console(serial_hds[0]);",
"}",
"if (VAR_2) {",
"uint64_t elf_entry;",
"uint64_t elf_lowaddr;",
"#ifdef TARGET_WORDS_BIGENDIAN\nint VAR_4 = load_elf(VAR_2, translate_phys_addr, cpu,\n&elf_entry, &elf_lowaddr, NULL, 1, EM_XTENSA, 0, 0);",
"#else\nint VAR_4 = load_elf(VAR_2, translate_phys_addr, cpu,\n&elf_entry, &elf_lowaddr, NULL, 0, EM_XTENSA, 0, 0);",
"#endif\nif (VAR_4 > 0) {",
"env->pc = elf_entry;",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99,
101
],
[
103,
105,
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
]
]
|
17,197 | void cpu_physical_memory_write_rom(target_phys_addr_t addr,
const uint8_t *buf, int len)
{
int l;
uint8_t *ptr;
target_phys_addr_t page;
MemoryRegionSection *section;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(page >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
/* do nothing */
} else {
unsigned long addr1;
addr1 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
/* ROM/RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
qemu_put_ram_ptr(ptr);
len -= l;
buf += l;
addr += l;
| true | qemu | 0b57e287138728f72d88b06e69b970c5d745c44a | void cpu_physical_memory_write_rom(target_phys_addr_t addr,
const uint8_t *buf, int len)
{
int l;
uint8_t *ptr;
target_phys_addr_t page;
MemoryRegionSection *section;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(page >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
} else {
unsigned long addr1;
addr1 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
qemu_put_ram_ptr(ptr);
len -= l;
buf += l;
addr += l;
| {
"code": [],
"line_no": []
} | void FUNC_0(target_phys_addr_t VAR_0,
const uint8_t *VAR_1, int VAR_2)
{
int VAR_3;
uint8_t *ptr;
target_phys_addr_t page;
MemoryRegionSection *section;
while (VAR_2 > 0) {
page = VAR_0 & TARGET_PAGE_MASK;
VAR_3 = (page + TARGET_PAGE_SIZE) - VAR_0;
if (VAR_3 > VAR_2)
VAR_3 = VAR_2;
section = phys_page_find(page >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
} else {
unsigned long VAR_4;
VAR_4 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, VAR_0);
ptr = qemu_get_ram_ptr(VAR_4);
memcpy(ptr, VAR_1, VAR_3);
qemu_put_ram_ptr(ptr);
VAR_2 -= VAR_3;
VAR_1 += VAR_3;
VAR_0 += VAR_3;
| [
"void FUNC_0(target_phys_addr_t VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"uint8_t *ptr;",
"target_phys_addr_t page;",
"MemoryRegionSection *section;",
"while (VAR_2 > 0) {",
"page = VAR_0 & TARGET_PAGE_MASK;",
"VAR_3 = (page + TARGET_PAGE_SIZE) - VAR_0;",
"if (VAR_3 > VAR_2)\nVAR_3 = VAR_2;",
"section = phys_page_find(page >> TARGET_PAGE_BITS);",
"if (!(memory_region_is_ram(section->mr) ||\nmemory_region_is_romd(section->mr))) {",
"} else {",
"unsigned long VAR_4;",
"VAR_4 = memory_region_get_ram_addr(section->mr)\n+ memory_region_section_addr(section, VAR_0);",
"ptr = qemu_get_ram_ptr(VAR_4);",
"memcpy(ptr, VAR_1, VAR_3);",
"qemu_put_ram_ptr(ptr);",
"VAR_2 -= VAR_3;",
"VAR_1 += VAR_3;",
"VAR_0 += VAR_3;"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
31,
33
],
[
37
],
[
39
],
[
41,
43
],
[
47
],
[
49
],
[
58
],
[
61
],
[
63
],
[
65
]
]
|
17,198 | av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
{
c->clear_block = clear_block_8_c;
c->clear_blocks = clear_blocks_8_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
if (ARCH_ARM)
ff_blockdsp_init_arm(c);
if (ARCH_PPC)
ff_blockdsp_init_ppc(c);
if (ARCH_X86)
#if FF_API_XVMC
ff_blockdsp_init_x86(c, avctx);
#else
ff_blockdsp_init_x86(c);
#endif /* FF_API_XVMC */
}
| false | FFmpeg | dcc39ee10e82833ce24aa57926c00ffeb1948198 | av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
{
c->clear_block = clear_block_8_c;
c->clear_blocks = clear_blocks_8_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
if (ARCH_ARM)
ff_blockdsp_init_arm(c);
if (ARCH_PPC)
ff_blockdsp_init_ppc(c);
if (ARCH_X86)
#if FF_API_XVMC
ff_blockdsp_init_x86(c, avctx);
#else
ff_blockdsp_init_x86(c);
#endif
}
| {
"code": [],
"line_no": []
} | av_cold void FUNC_0(BlockDSPContext *c, AVCodecContext *avctx)
{
c->clear_block = clear_block_8_c;
c->clear_blocks = clear_blocks_8_c;
c->fill_block_tab[0] = fill_block16_c;
c->fill_block_tab[1] = fill_block8_c;
if (ARCH_ARM)
ff_blockdsp_init_arm(c);
if (ARCH_PPC)
ff_blockdsp_init_ppc(c);
if (ARCH_X86)
#if FF_API_XVMC
ff_blockdsp_init_x86(c, avctx);
#else
ff_blockdsp_init_x86(c);
#endif
}
| [
"av_cold void FUNC_0(BlockDSPContext *c, AVCodecContext *avctx)\n{",
"c->clear_block = clear_block_8_c;",
"c->clear_blocks = clear_blocks_8_c;",
"c->fill_block_tab[0] = fill_block16_c;",
"c->fill_block_tab[1] = fill_block8_c;",
"if (ARCH_ARM)\nff_blockdsp_init_arm(c);",
"if (ARCH_PPC)\nff_blockdsp_init_ppc(c);",
"if (ARCH_X86)\n#if FF_API_XVMC\nff_blockdsp_init_x86(c, avctx);",
"#else\nff_blockdsp_init_x86(c);",
"#endif\n}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17,
19
],
[
21,
23
],
[
25,
27,
29
],
[
31,
33
],
[
35,
37
]
]
|
17,200 | static void estimate_timings_from_bit_rate(AVFormatContext *ic)
{
int64_t filesize, duration;
int i;
AVStream *st;
/* if bit_rate is already set, we believe it */
if (ic->bit_rate <= 0) {
int bit_rate = 0;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->bit_rate > 0) {
if (INT_MAX - st->codec->bit_rate > bit_rate) {
bit_rate = 0;
break;
}
bit_rate += st->codec->bit_rate;
}
}
ic->bit_rate = bit_rate;
}
/* if duration is already set, we believe it */
if (ic->duration == AV_NOPTS_VALUE &&
ic->bit_rate != 0) {
filesize = ic->pb ? avio_size(ic->pb) : 0;
if (filesize > 0) {
for(i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
if (st->duration == AV_NOPTS_VALUE)
st->duration = duration;
}
}
}
}
| true | FFmpeg | 26f027fba1c5ab482fa2488fbe0fa36c8bb33b69 | static void estimate_timings_from_bit_rate(AVFormatContext *ic)
{
int64_t filesize, duration;
int i;
AVStream *st;
if (ic->bit_rate <= 0) {
int bit_rate = 0;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->bit_rate > 0) {
if (INT_MAX - st->codec->bit_rate > bit_rate) {
bit_rate = 0;
break;
}
bit_rate += st->codec->bit_rate;
}
}
ic->bit_rate = bit_rate;
}
if (ic->duration == AV_NOPTS_VALUE &&
ic->bit_rate != 0) {
filesize = ic->pb ? avio_size(ic->pb) : 0;
if (filesize > 0) {
for(i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
if (st->duration == AV_NOPTS_VALUE)
st->duration = duration;
}
}
}
}
| {
"code": [
" if (INT_MAX - st->codec->bit_rate > bit_rate) {"
],
"line_no": [
25
]
} | static void FUNC_0(AVFormatContext *VAR_0)
{
int64_t filesize, duration;
int VAR_1;
AVStream *st;
if (VAR_0->VAR_2 <= 0) {
int VAR_2 = 0;
for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) {
st = VAR_0->streams[VAR_1];
if (st->codec->VAR_2 > 0) {
if (INT_MAX - st->codec->VAR_2 > VAR_2) {
VAR_2 = 0;
break;
}
VAR_2 += st->codec->VAR_2;
}
}
VAR_0->VAR_2 = VAR_2;
}
if (VAR_0->duration == AV_NOPTS_VALUE &&
VAR_0->VAR_2 != 0) {
filesize = VAR_0->pb ? avio_size(VAR_0->pb) : 0;
if (filesize > 0) {
for(VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {
st = VAR_0->streams[VAR_1];
duration= av_rescale(8*filesize, st->time_base.den, VAR_0->VAR_2*(int64_t)st->time_base.num);
if (st->duration == AV_NOPTS_VALUE)
st->duration = duration;
}
}
}
}
| [
"static void FUNC_0(AVFormatContext *VAR_0)\n{",
"int64_t filesize, duration;",
"int VAR_1;",
"AVStream *st;",
"if (VAR_0->VAR_2 <= 0) {",
"int VAR_2 = 0;",
"for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) {",
"st = VAR_0->streams[VAR_1];",
"if (st->codec->VAR_2 > 0) {",
"if (INT_MAX - st->codec->VAR_2 > VAR_2) {",
"VAR_2 = 0;",
"break;",
"}",
"VAR_2 += st->codec->VAR_2;",
"}",
"}",
"VAR_0->VAR_2 = VAR_2;",
"}",
"if (VAR_0->duration == AV_NOPTS_VALUE &&\nVAR_0->VAR_2 != 0) {",
"filesize = VAR_0->pb ? avio_size(VAR_0->pb) : 0;",
"if (filesize > 0) {",
"for(VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {",
"st = VAR_0->streams[VAR_1];",
"duration= av_rescale(8*filesize, st->time_base.den, VAR_0->VAR_2*(int64_t)st->time_base.num);",
"if (st->duration == AV_NOPTS_VALUE)\nst->duration = duration;",
"}",
"}",
"}",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
71
]
]
|
17,201 | AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
{
AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
if (!ret)
return NULL;
*ret = *ref;
if (ref->type == AVMEDIA_TYPE_VIDEO) {
ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
if (!ret->video) {
av_free(ret);
return NULL;
}
copy_video_props(ret->video, ref->video);
ret->extended_data = ret->data;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
if (!ret->audio) {
av_free(ret);
return NULL;
}
*ret->audio = *ref->audio;
if (ref->extended_data && ref->extended_data != ref->data) {
int nb_channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) *
nb_channels))) {
av_freep(&ret->audio);
av_freep(&ret);
return NULL;
}
memcpy(ret->extended_data, ref->extended_data,
sizeof(*ret->extended_data) * nb_channels);
} else
ret->extended_data = ret->data;
}
ret->perms &= pmask;
ret->buf->refcount ++;
return ret;
} | true | FFmpeg | 6fb2fd895e858ab93f46e656a322778ee181c307 | AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
{
AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
if (!ret)
return NULL;
*ret = *ref;
if (ref->type == AVMEDIA_TYPE_VIDEO) {
ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
if (!ret->video) {
av_free(ret);
return NULL;
}
copy_video_props(ret->video, ref->video);
ret->extended_data = ret->data;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
if (!ret->audio) {
av_free(ret);
return NULL;
}
*ret->audio = *ref->audio;
if (ref->extended_data && ref->extended_data != ref->data) {
int nb_channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) *
nb_channels))) {
av_freep(&ret->audio);
av_freep(&ret);
return NULL;
}
memcpy(ret->extended_data, ref->extended_data,
sizeof(*ret->extended_data) * nb_channels);
} else
ret->extended_data = ret->data;
}
ret->perms &= pmask;
ret->buf->refcount ++;
return ret;
} | {
"code": [],
"line_no": []
} | AVFilterBufferRef *FUNC_0(AVFilterBufferRef *ref, int pmask)
{
AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
if (!ret)
return NULL;
*ret = *ref;
if (ref->type == AVMEDIA_TYPE_VIDEO) {
ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
if (!ret->video) {
av_free(ret);
return NULL;
}
copy_video_props(ret->video, ref->video);
ret->extended_data = ret->data;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
if (!ret->audio) {
av_free(ret);
return NULL;
}
*ret->audio = *ref->audio;
if (ref->extended_data && ref->extended_data != ref->data) {
int VAR_0 = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) *
VAR_0))) {
av_freep(&ret->audio);
av_freep(&ret);
return NULL;
}
memcpy(ret->extended_data, ref->extended_data,
sizeof(*ret->extended_data) * VAR_0);
} else
ret->extended_data = ret->data;
}
ret->perms &= pmask;
ret->buf->refcount ++;
return ret;
} | [
"AVFilterBufferRef *FUNC_0(AVFilterBufferRef *ref, int pmask)\n{",
"AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));",
"if (!ret)\nreturn NULL;",
"*ret = *ref;",
"if (ref->type == AVMEDIA_TYPE_VIDEO) {",
"ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));",
"if (!ret->video) {",
"av_free(ret);",
"return NULL;",
"}",
"copy_video_props(ret->video, ref->video);",
"ret->extended_data = ret->data;",
"} else if (ref->type == AVMEDIA_TYPE_AUDIO) {",
"ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));",
"if (!ret->audio) {",
"av_free(ret);",
"return NULL;",
"}",
"*ret->audio = *ref->audio;",
"if (ref->extended_data && ref->extended_data != ref->data) {",
"int VAR_0 = av_get_channel_layout_nb_channels(ref->audio->channel_layout);",
"if (!(ret->extended_data = av_malloc(sizeof(*ret->extended_data) *\nVAR_0))) {",
"av_freep(&ret->audio);",
"av_freep(&ret);",
"return NULL;",
"}",
"memcpy(ret->extended_data, ref->extended_data,\nsizeof(*ret->extended_data) * VAR_0);",
"} else",
"ret->extended_data = ret->data;",
"}",
"ret->perms &= pmask;",
"ret->buf->refcount ++;",
"return ret;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
2
],
[
3
],
[
4,
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
11
],
[
12
],
[
13
],
[
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20
],
[
21
],
[
22
],
[
23
],
[
24,
25
],
[
26
],
[
27
],
[
28
],
[
29
],
[
30,
31
],
[
32
],
[
33
],
[
34
],
[
35
],
[
36
],
[
37
],
[
38
]
]
|
17,202 | static int parse_playlist(AppleHTTPContext *c, const char *url,
struct variant *var, AVIOContext *in)
{
int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
enum KeyType key_type = KEY_NONE;
uint8_t iv[16] = "";
int has_iv = 0;
char key[MAX_URL_SIZE];
char line[1024];
const char *ptr;
int close_in = 0;
if (!in) {
close_in = 1;
if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
c->interrupt_callback, NULL)) < 0)
return ret;
}
read_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U")) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (var) {
free_segment_list(var);
var->finished = 0;
}
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
is_variant = 1;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-KEY:", &ptr)) {
struct key_info info = {{0}};
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_key_args,
&info);
key_type = KEY_NONE;
has_iv = 0;
if (!strcmp(info.method, "AES-128"))
key_type = KEY_AES_128;
if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) {
ff_hex_to_data(iv, info.iv + 2);
has_iv = 1;
}
av_strlcpy(key, info.uri, sizeof(key));
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->target_duration = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
if (var)
var->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atoi(ptr);
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_variant) {
if (!new_variant(c, bandwidth, line, url)) {
ret = AVERROR(ENOMEM);
goto fail;
}
is_variant = 0;
bandwidth = 0;
}
if (is_segment) {
struct segment *seg;
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
seg->key_type = key_type;
if (has_iv) {
memcpy(seg->iv, iv, sizeof(iv));
} else {
int seq = var->start_seq_no + var->n_segments;
memset(seg->iv, 0, sizeof(seg->iv));
AV_WB32(seg->iv + 12, seq);
}
ff_make_absolute_url(seg->key, sizeof(seg->key), url, key);
ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&var->segments, &var->n_segments, seg);
is_segment = 0;
}
}
}
if (var)
var->last_load_time = av_gettime();
fail:
if (close_in)
avio_close(in);
return ret;
}
| true | FFmpeg | c41b9842ceac42bedfd74a7ba2d02add82f818a9 | static int parse_playlist(AppleHTTPContext *c, const char *url,
struct variant *var, AVIOContext *in)
{
int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
enum KeyType key_type = KEY_NONE;
uint8_t iv[16] = "";
int has_iv = 0;
char key[MAX_URL_SIZE];
char line[1024];
const char *ptr;
int close_in = 0;
if (!in) {
close_in = 1;
if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
c->interrupt_callback, NULL)) < 0)
return ret;
}
read_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U")) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (var) {
free_segment_list(var);
var->finished = 0;
}
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
is_variant = 1;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-KEY:", &ptr)) {
struct key_info info = {{0}};
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_key_args,
&info);
key_type = KEY_NONE;
has_iv = 0;
if (!strcmp(info.method, "AES-128"))
key_type = KEY_AES_128;
if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) {
ff_hex_to_data(iv, info.iv + 2);
has_iv = 1;
}
av_strlcpy(key, info.uri, sizeof(key));
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->target_duration = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
var->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
if (var)
var->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atoi(ptr);
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_variant) {
if (!new_variant(c, bandwidth, line, url)) {
ret = AVERROR(ENOMEM);
goto fail;
}
is_variant = 0;
bandwidth = 0;
}
if (is_segment) {
struct segment *seg;
if (!var) {
var = new_variant(c, 0, url, NULL);
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
}
seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
seg->key_type = key_type;
if (has_iv) {
memcpy(seg->iv, iv, sizeof(iv));
} else {
int seq = var->start_seq_no + var->n_segments;
memset(seg->iv, 0, sizeof(seg->iv));
AV_WB32(seg->iv + 12, seq);
}
ff_make_absolute_url(seg->key, sizeof(seg->key), url, key);
ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&var->segments, &var->n_segments, seg);
is_segment = 0;
}
}
}
if (var)
var->last_load_time = av_gettime();
fail:
if (close_in)
avio_close(in);
return ret;
}
| {
"code": [
" char key[MAX_URL_SIZE];"
],
"line_no": [
15
]
} | static int FUNC_0(AppleHTTPContext *VAR_0, const char *VAR_1,
struct variant *VAR_2, AVIOContext *VAR_3)
{
int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0, VAR_8 = 0;
enum KeyType VAR_9 = KEY_NONE;
uint8_t iv[16] = "";
int VAR_10 = 0;
char VAR_11[MAX_URL_SIZE];
char VAR_12[1024];
const char *VAR_13;
int VAR_14 = 0;
if (!VAR_3) {
VAR_14 = 1;
if ((VAR_4 = avio_open2(&VAR_3, VAR_1, AVIO_FLAG_READ,
VAR_0->interrupt_callback, NULL)) < 0)
return VAR_4;
}
read_chomp_line(VAR_3, VAR_12, sizeof(VAR_12));
if (strcmp(VAR_12, "#EXTM3U")) {
VAR_4 = AVERROR_INVALIDDATA;
goto fail;
}
if (VAR_2) {
free_segment_list(VAR_2);
VAR_2->finished = 0;
}
while (!VAR_3->eof_reached) {
read_chomp_line(VAR_3, VAR_12, sizeof(VAR_12));
if (av_strstart(VAR_12, "#EXT-X-STREAM-INF:", &VAR_13)) {
struct variant_info VAR_16 = {{0}};
VAR_7 = 1;
ff_parse_key_value(VAR_13, (ff_parse_key_val_cb) handle_variant_args,
&VAR_16);
VAR_8 = atoi(VAR_16.VAR_8);
} else if (av_strstart(VAR_12, "#EXT-X-KEY:", &VAR_13)) {
struct key_info VAR_16 = {{0}};
ff_parse_key_value(VAR_13, (ff_parse_key_val_cb) handle_key_args,
&VAR_16);
VAR_9 = KEY_NONE;
VAR_10 = 0;
if (!strcmp(VAR_16.method, "AES-128"))
VAR_9 = KEY_AES_128;
if (!strncmp(VAR_16.iv, "0x", 2) || !strncmp(VAR_16.iv, "0X", 2)) {
ff_hex_to_data(iv, VAR_16.iv + 2);
VAR_10 = 1;
}
av_strlcpy(VAR_11, VAR_16.uri, sizeof(VAR_11));
} else if (av_strstart(VAR_12, "#EXT-X-TARGETDURATION:", &VAR_13)) {
if (!VAR_2) {
VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);
if (!VAR_2) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
}
VAR_2->target_duration = atoi(VAR_13);
} else if (av_strstart(VAR_12, "#EXT-X-MEDIA-SEQUENCE:", &VAR_13)) {
if (!VAR_2) {
VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);
if (!VAR_2) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
}
VAR_2->start_seq_no = atoi(VAR_13);
} else if (av_strstart(VAR_12, "#EXT-X-ENDLIST", &VAR_13)) {
if (VAR_2)
VAR_2->finished = 1;
} else if (av_strstart(VAR_12, "#EXTINF:", &VAR_13)) {
VAR_6 = 1;
VAR_5 = atoi(VAR_13);
} else if (av_strstart(VAR_12, "#", NULL)) {
continue;
} else if (VAR_12[0]) {
if (VAR_7) {
if (!new_variant(VAR_0, VAR_8, VAR_12, VAR_1)) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
VAR_7 = 0;
VAR_8 = 0;
}
if (VAR_6) {
struct segment *VAR_16;
if (!VAR_2) {
VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);
if (!VAR_2) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
}
VAR_16 = av_malloc(sizeof(struct segment));
if (!VAR_16) {
VAR_4 = AVERROR(ENOMEM);
goto fail;
}
VAR_16->VAR_5 = VAR_5;
VAR_16->VAR_9 = VAR_9;
if (VAR_10) {
memcpy(VAR_16->iv, iv, sizeof(iv));
} else {
int VAR_17 = VAR_2->start_seq_no + VAR_2->n_segments;
memset(VAR_16->iv, 0, sizeof(VAR_16->iv));
AV_WB32(VAR_16->iv + 12, VAR_17);
}
ff_make_absolute_url(VAR_16->VAR_11, sizeof(VAR_16->VAR_11), VAR_1, VAR_11);
ff_make_absolute_url(VAR_16->VAR_1, sizeof(VAR_16->VAR_1), VAR_1, VAR_12);
dynarray_add(&VAR_2->segments, &VAR_2->n_segments, VAR_16);
VAR_6 = 0;
}
}
}
if (VAR_2)
VAR_2->last_load_time = av_gettime();
fail:
if (VAR_14)
avio_close(VAR_3);
return VAR_4;
}
| [
"static int FUNC_0(AppleHTTPContext *VAR_0, const char *VAR_1,\nstruct variant *VAR_2, AVIOContext *VAR_3)\n{",
"int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0, VAR_8 = 0;",
"enum KeyType VAR_9 = KEY_NONE;",
"uint8_t iv[16] = \"\";",
"int VAR_10 = 0;",
"char VAR_11[MAX_URL_SIZE];",
"char VAR_12[1024];",
"const char *VAR_13;",
"int VAR_14 = 0;",
"if (!VAR_3) {",
"VAR_14 = 1;",
"if ((VAR_4 = avio_open2(&VAR_3, VAR_1, AVIO_FLAG_READ,\nVAR_0->interrupt_callback, NULL)) < 0)\nreturn VAR_4;",
"}",
"read_chomp_line(VAR_3, VAR_12, sizeof(VAR_12));",
"if (strcmp(VAR_12, \"#EXTM3U\")) {",
"VAR_4 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"if (VAR_2) {",
"free_segment_list(VAR_2);",
"VAR_2->finished = 0;",
"}",
"while (!VAR_3->eof_reached) {",
"read_chomp_line(VAR_3, VAR_12, sizeof(VAR_12));",
"if (av_strstart(VAR_12, \"#EXT-X-STREAM-INF:\", &VAR_13)) {",
"struct variant_info VAR_16 = {{0}};",
"VAR_7 = 1;",
"ff_parse_key_value(VAR_13, (ff_parse_key_val_cb) handle_variant_args,\n&VAR_16);",
"VAR_8 = atoi(VAR_16.VAR_8);",
"} else if (av_strstart(VAR_12, \"#EXT-X-KEY:\", &VAR_13)) {",
"struct key_info VAR_16 = {{0}};",
"ff_parse_key_value(VAR_13, (ff_parse_key_val_cb) handle_key_args,\n&VAR_16);",
"VAR_9 = KEY_NONE;",
"VAR_10 = 0;",
"if (!strcmp(VAR_16.method, \"AES-128\"))\nVAR_9 = KEY_AES_128;",
"if (!strncmp(VAR_16.iv, \"0x\", 2) || !strncmp(VAR_16.iv, \"0X\", 2)) {",
"ff_hex_to_data(iv, VAR_16.iv + 2);",
"VAR_10 = 1;",
"}",
"av_strlcpy(VAR_11, VAR_16.uri, sizeof(VAR_11));",
"} else if (av_strstart(VAR_12, \"#EXT-X-TARGETDURATION:\", &VAR_13)) {",
"if (!VAR_2) {",
"VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);",
"if (!VAR_2) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"VAR_2->target_duration = atoi(VAR_13);",
"} else if (av_strstart(VAR_12, \"#EXT-X-MEDIA-SEQUENCE:\", &VAR_13)) {",
"if (!VAR_2) {",
"VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);",
"if (!VAR_2) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"VAR_2->start_seq_no = atoi(VAR_13);",
"} else if (av_strstart(VAR_12, \"#EXT-X-ENDLIST\", &VAR_13)) {",
"if (VAR_2)\nVAR_2->finished = 1;",
"} else if (av_strstart(VAR_12, \"#EXTINF:\", &VAR_13)) {",
"VAR_6 = 1;",
"VAR_5 = atoi(VAR_13);",
"} else if (av_strstart(VAR_12, \"#\", NULL)) {",
"continue;",
"} else if (VAR_12[0]) {",
"if (VAR_7) {",
"if (!new_variant(VAR_0, VAR_8, VAR_12, VAR_1)) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_7 = 0;",
"VAR_8 = 0;",
"}",
"if (VAR_6) {",
"struct segment *VAR_16;",
"if (!VAR_2) {",
"VAR_2 = new_variant(VAR_0, 0, VAR_1, NULL);",
"if (!VAR_2) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"}",
"VAR_16 = av_malloc(sizeof(struct segment));",
"if (!VAR_16) {",
"VAR_4 = AVERROR(ENOMEM);",
"goto fail;",
"}",
"VAR_16->VAR_5 = VAR_5;",
"VAR_16->VAR_9 = VAR_9;",
"if (VAR_10) {",
"memcpy(VAR_16->iv, iv, sizeof(iv));",
"} else {",
"int VAR_17 = VAR_2->start_seq_no + VAR_2->n_segments;",
"memset(VAR_16->iv, 0, sizeof(VAR_16->iv));",
"AV_WB32(VAR_16->iv + 12, VAR_17);",
"}",
"ff_make_absolute_url(VAR_16->VAR_11, sizeof(VAR_16->VAR_11), VAR_1, VAR_11);",
"ff_make_absolute_url(VAR_16->VAR_1, sizeof(VAR_16->VAR_1), VAR_1, VAR_12);",
"dynarray_add(&VAR_2->segments, &VAR_2->n_segments, VAR_16);",
"VAR_6 = 0;",
"}",
"}",
"}",
"if (VAR_2)\nVAR_2->last_load_time = av_gettime();",
"fail:\nif (VAR_14)\navio_close(VAR_3);",
"return VAR_4;",
"}"
]
| [
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
]
| [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
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
],
[
237,
239,
241
],
[
243
],
[
245
]
]
|
17,204 | static int integrate(hdcd_state_t *state, int *flag, const int32_t *samples, int count, int stride)
{
uint32_t bits = 0;
int result = FFMIN(state->readahead, count);
int i;
*flag = 0;
for (i = result - 1; i >= 0; i--) {
bits |= (*samples & 1) << i; /* might be better as a conditional? */
samples += stride;
}
state->window = (state->window << result) | bits;
state->readahead -= result;
if (state->readahead > 0)
return result;
bits = (state->window ^ state->window >> 5 ^ state->window >> 23);
if (state->arg) {
if ((bits & 0xffffffc8) == 0x0fa00500) {
state->control = (bits & 255) + (bits & 7);
*flag = 1;
state->code_counterA++;
}
if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
state->control = bits >> 8 & 255;
*flag = 1;
state->code_counterB++;
}
state->arg = 0;
}
if (bits == 0x7e0fa005 || bits == 0x7e0fa006) {
state->readahead = (bits & 3) * 8;
state->arg = 1;
state->code_counterC++;
} else {
if (bits)
state->readahead = readaheadtab[bits & ~(-1 << 8)];
else
state->readahead = 31; /* ffwd over digisilence */
}
return result;
}
| false | FFmpeg | 5836a5037ecbbd9b10ac85cdec5ff8cccb1177d0 | static int integrate(hdcd_state_t *state, int *flag, const int32_t *samples, int count, int stride)
{
uint32_t bits = 0;
int result = FFMIN(state->readahead, count);
int i;
*flag = 0;
for (i = result - 1; i >= 0; i--) {
bits |= (*samples & 1) << i;
samples += stride;
}
state->window = (state->window << result) | bits;
state->readahead -= result;
if (state->readahead > 0)
return result;
bits = (state->window ^ state->window >> 5 ^ state->window >> 23);
if (state->arg) {
if ((bits & 0xffffffc8) == 0x0fa00500) {
state->control = (bits & 255) + (bits & 7);
*flag = 1;
state->code_counterA++;
}
if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
state->control = bits >> 8 & 255;
*flag = 1;
state->code_counterB++;
}
state->arg = 0;
}
if (bits == 0x7e0fa005 || bits == 0x7e0fa006) {
state->readahead = (bits & 3) * 8;
state->arg = 1;
state->code_counterC++;
} else {
if (bits)
state->readahead = readaheadtab[bits & ~(-1 << 8)];
else
state->readahead = 31;
}
return result;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(hdcd_state_t *VAR_0, int *VAR_1, const int32_t *VAR_2, int VAR_3, int VAR_4)
{
uint32_t bits = 0;
int VAR_5 = FFMIN(VAR_0->readahead, VAR_3);
int VAR_6;
*VAR_1 = 0;
for (VAR_6 = VAR_5 - 1; VAR_6 >= 0; VAR_6--) {
bits |= (*VAR_2 & 1) << VAR_6;
VAR_2 += VAR_4;
}
VAR_0->window = (VAR_0->window << VAR_5) | bits;
VAR_0->readahead -= VAR_5;
if (VAR_0->readahead > 0)
return VAR_5;
bits = (VAR_0->window ^ VAR_0->window >> 5 ^ VAR_0->window >> 23);
if (VAR_0->arg) {
if ((bits & 0xffffffc8) == 0x0fa00500) {
VAR_0->control = (bits & 255) + (bits & 7);
*VAR_1 = 1;
VAR_0->code_counterA++;
}
if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
VAR_0->control = bits >> 8 & 255;
*VAR_1 = 1;
VAR_0->code_counterB++;
}
VAR_0->arg = 0;
}
if (bits == 0x7e0fa005 || bits == 0x7e0fa006) {
VAR_0->readahead = (bits & 3) * 8;
VAR_0->arg = 1;
VAR_0->code_counterC++;
} else {
if (bits)
VAR_0->readahead = readaheadtab[bits & ~(-1 << 8)];
else
VAR_0->readahead = 31;
}
return VAR_5;
}
| [
"static int FUNC_0(hdcd_state_t *VAR_0, int *VAR_1, const int32_t *VAR_2, int VAR_3, int VAR_4)\n{",
"uint32_t bits = 0;",
"int VAR_5 = FFMIN(VAR_0->readahead, VAR_3);",
"int VAR_6;",
"*VAR_1 = 0;",
"for (VAR_6 = VAR_5 - 1; VAR_6 >= 0; VAR_6--) {",
"bits |= (*VAR_2 & 1) << VAR_6;",
"VAR_2 += VAR_4;",
"}",
"VAR_0->window = (VAR_0->window << VAR_5) | bits;",
"VAR_0->readahead -= VAR_5;",
"if (VAR_0->readahead > 0)\nreturn VAR_5;",
"bits = (VAR_0->window ^ VAR_0->window >> 5 ^ VAR_0->window >> 23);",
"if (VAR_0->arg) {",
"if ((bits & 0xffffffc8) == 0x0fa00500) {",
"VAR_0->control = (bits & 255) + (bits & 7);",
"*VAR_1 = 1;",
"VAR_0->code_counterA++;",
"}",
"if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {",
"VAR_0->control = bits >> 8 & 255;",
"*VAR_1 = 1;",
"VAR_0->code_counterB++;",
"}",
"VAR_0->arg = 0;",
"}",
"if (bits == 0x7e0fa005 || bits == 0x7e0fa006) {",
"VAR_0->readahead = (bits & 3) * 8;",
"VAR_0->arg = 1;",
"VAR_0->code_counterC++;",
"} else {",
"if (bits)\nVAR_0->readahead = readaheadtab[bits & ~(-1 << 8)];",
"else\nVAR_0->readahead = 31;",
"}",
"return VAR_5;",
"}"
]
| [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
| [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29,
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79,
81
],
[
83
],
[
85
],
[
87
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.