id
int32 0
27.3k
| func
stringlengths 26
142k
| target
bool 2
classes | project
stringclasses 2
values | commit_id
stringlengths 40
40
| func_clean
stringlengths 26
131k
| vul_lines
dict | normalized_func
stringlengths 24
132k
| lines
sequencelengths 1
2.8k
| label
sequencelengths 1
2.8k
| line_no
sequencelengths 1
2.8k
|
---|---|---|---|---|---|---|---|---|---|---|
1,230 | void qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
iohandler_init();
aio_set_fd_handler(iohandler_ctx, fd, false,
fd_read, fd_write, NULL, opaque);
}
| false | qemu | c2b38b277a7882a592f4f2ec955084b2b756daaa | void qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
iohandler_init();
aio_set_fd_handler(iohandler_ctx, fd, false,
fd_read, fd_write, NULL, opaque);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(int VAR_0,
IOHandler *VAR_1,
IOHandler *VAR_2,
void *VAR_3)
{
iohandler_init();
aio_set_fd_handler(iohandler_ctx, VAR_0, false,
VAR_1, VAR_2, NULL, VAR_3);
}
| [
"void FUNC_0(int VAR_0,\nIOHandler *VAR_1,\nIOHandler *VAR_2,\nvoid *VAR_3)\n{",
"iohandler_init();",
"aio_set_fd_handler(iohandler_ctx, VAR_0, false,\nVAR_1, VAR_2, NULL, VAR_3);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13,
15
],
[
17
]
] |
1,231 | static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
NVICState *s = (NVICState *)opaque;
uint32_t offset = addr;
unsigned i, startvec, end;
unsigned setval = 0;
trace_nvic_sysreg_write(addr, value, size);
if (attrs.user && !nvic_user_access_ok(s, addr)) {
/* Generate BusFault for unprivileged accesses */
return MEMTX_ERROR;
}
switch (offset) {
case 0x100 ... 0x13f: /* NVIC Set enable */
offset += 0x80;
setval = 1;
/* fall through */
case 0x180 ... 0x1bf: /* NVIC Clear enable */
startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].enabled = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x200 ... 0x23f: /* NVIC Set pend */
/* the special logic in armv7m_nvic_set_pending()
* is not needed since IRQs are never escalated
*/
offset += 0x80;
setval = 1;
/* fall through */
case 0x280 ... 0x2bf: /* NVIC Clear pend */
startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].pending = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x300 ... 0x33f: /* NVIC Active */
return MEMTX_OK; /* R/O */
case 0x400 ... 0x5ef: /* NVIC Priority */
startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
case 0xd18 ... 0xd23: /* System Handler Priority. */
for (i = 0; i < size; i++) {
unsigned hdlidx = (offset - 0xd14) + i;
set_prio(s, hdlidx, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
}
if (size == 4) {
nvic_writel(s, offset, value);
return MEMTX_OK;
}
qemu_log_mask(LOG_GUEST_ERROR,
"NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
/* This is UNPREDICTABLE; treat as RAZ/WI */
return MEMTX_OK;
}
| false | qemu | 45db7ba681ede57113a67499840e69ee586bcdf2 | static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
NVICState *s = (NVICState *)opaque;
uint32_t offset = addr;
unsigned i, startvec, end;
unsigned setval = 0;
trace_nvic_sysreg_write(addr, value, size);
if (attrs.user && !nvic_user_access_ok(s, addr)) {
return MEMTX_ERROR;
}
switch (offset) {
case 0x100 ... 0x13f:
offset += 0x80;
setval = 1;
case 0x180 ... 0x1bf:
startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].enabled = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x200 ... 0x23f:
offset += 0x80;
setval = 1;
case 0x280 ... 0x2bf:
startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ;
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].pending = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x300 ... 0x33f:
return MEMTX_OK;
case 0x400 ... 0x5ef:
startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ;
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
case 0xd18 ... 0xd23:
for (i = 0; i < size; i++) {
unsigned hdlidx = (offset - 0xd14) + i;
set_prio(s, hdlidx, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
}
if (size == 4) {
nvic_writel(s, offset, value);
return MEMTX_OK;
}
qemu_log_mask(LOG_GUEST_ERROR,
"NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
return MEMTX_OK;
}
| {
"code": [],
"line_no": []
} | static MemTxResult FUNC_0(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
NVICState *s = (NVICState *)opaque;
uint32_t offset = addr;
unsigned VAR_0, VAR_1, VAR_2;
unsigned VAR_3 = 0;
trace_nvic_sysreg_write(addr, value, size);
if (attrs.user && !nvic_user_access_ok(s, addr)) {
return MEMTX_ERROR;
}
switch (offset) {
case 0x100 ... 0x13f:
offset += 0x80;
VAR_3 = 1;
case 0x180 ... 0x1bf:
VAR_1 = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
for (VAR_0 = 0, VAR_2 = size * 8; VAR_0 < VAR_2 && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {
if (value & (1 << VAR_0)) {
s->vectors[VAR_1 + VAR_0].enabled = VAR_3;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x200 ... 0x23f:
offset += 0x80;
VAR_3 = 1;
case 0x280 ... 0x2bf:
VAR_1 = 8 * (offset - 0x280) + NVIC_FIRST_IRQ;
for (VAR_0 = 0, VAR_2 = size * 8; VAR_0 < VAR_2 && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {
if (value & (1 << VAR_0)) {
s->vectors[VAR_1 + VAR_0].pending = VAR_3;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x300 ... 0x33f:
return MEMTX_OK;
case 0x400 ... 0x5ef:
VAR_1 = 8 * (offset - 0x400) + NVIC_FIRST_IRQ;
for (VAR_0 = 0; VAR_0 < size && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {
set_prio(s, VAR_1 + VAR_0, (value >> (VAR_0 * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
case 0xd18 ... 0xd23:
for (VAR_0 = 0; VAR_0 < size; VAR_0++) {
unsigned VAR_4 = (offset - 0xd14) + VAR_0;
set_prio(s, VAR_4, (value >> (VAR_0 * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
}
if (size == 4) {
nvic_writel(s, offset, value);
return MEMTX_OK;
}
qemu_log_mask(LOG_GUEST_ERROR,
"NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
return MEMTX_OK;
}
| [
"static MemTxResult FUNC_0(void *opaque, hwaddr addr,\nuint64_t value, unsigned size,\nMemTxAttrs attrs)\n{",
"NVICState *s = (NVICState *)opaque;",
"uint32_t offset = addr;",
"unsigned VAR_0, VAR_1, VAR_2;",
"unsigned VAR_3 = 0;",
"trace_nvic_sysreg_write(addr, value, size);",
"if (attrs.user && !nvic_user_access_ok(s, addr)) {",
"return MEMTX_ERROR;",
"}",
"switch (offset) {",
"case 0x100 ... 0x13f:\noffset += 0x80;",
"VAR_3 = 1;",
"case 0x180 ... 0x1bf:\nVAR_1 = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;",
"for (VAR_0 = 0, VAR_2 = size * 8; VAR_0 < VAR_2 && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {",
"if (value & (1 << VAR_0)) {",
"s->vectors[VAR_1 + VAR_0].enabled = VAR_3;",
"}",
"}",
"nvic_irq_update(s);",
"return MEMTX_OK;",
"case 0x200 ... 0x23f:\noffset += 0x80;",
"VAR_3 = 1;",
"case 0x280 ... 0x2bf:\nVAR_1 = 8 * (offset - 0x280) + NVIC_FIRST_IRQ;",
"for (VAR_0 = 0, VAR_2 = size * 8; VAR_0 < VAR_2 && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {",
"if (value & (1 << VAR_0)) {",
"s->vectors[VAR_1 + VAR_0].pending = VAR_3;",
"}",
"}",
"nvic_irq_update(s);",
"return MEMTX_OK;",
"case 0x300 ... 0x33f:\nreturn MEMTX_OK;",
"case 0x400 ... 0x5ef:\nVAR_1 = 8 * (offset - 0x400) + NVIC_FIRST_IRQ;",
"for (VAR_0 = 0; VAR_0 < size && VAR_1 + VAR_0 < s->num_irq; VAR_0++) {",
"set_prio(s, VAR_1 + VAR_0, (value >> (VAR_0 * 8)) & 0xff);",
"}",
"nvic_irq_update(s);",
"return MEMTX_OK;",
"case 0xd18 ... 0xd23:\nfor (VAR_0 = 0; VAR_0 < size; VAR_0++) {",
"unsigned VAR_4 = (offset - 0xd14) + VAR_0;",
"set_prio(s, VAR_4, (value >> (VAR_0 * 8)) & 0xff);",
"}",
"nvic_irq_update(s);",
"return MEMTX_OK;",
"}",
"if (size == 4) {",
"nvic_writel(s, offset, value);",
"return MEMTX_OK;",
"}",
"qemu_log_mask(LOG_GUEST_ERROR,\n\"NVIC: Bad write of size %d at offset 0x%x\\n\", size, offset);",
"return MEMTX_OK;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
33
],
[
35,
37
],
[
39
],
[
43,
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
71
],
[
73
],
[
77,
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97,
99
],
[
101,
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141,
143
],
[
147
],
[
149
]
] |
1,232 | static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,
hwaddr *nb, uint16_t leaf,
int level)
{
PhysPageEntry *p;
int i;
hwaddr step = (hwaddr)1 << (level * P_L2_BITS);
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {
lp->ptr = phys_map_node_alloc();
p = next_map.nodes[lp->ptr];
if (level == 0) {
for (i = 0; i < P_L2_SIZE; i++) {
p[i].skip = 0;
p[i].ptr = PHYS_SECTION_UNASSIGNED;
}
}
} else {
p = next_map.nodes[lp->ptr];
}
lp = &p[(*index >> (level * P_L2_BITS)) & (P_L2_SIZE - 1)];
while (*nb && lp < &p[P_L2_SIZE]) {
if ((*index & (step - 1)) == 0 && *nb >= step) {
lp->skip = 0;
lp->ptr = leaf;
*index += step;
*nb -= step;
} else {
phys_page_set_level(lp, index, nb, leaf, level - 1);
}
++lp;
}
}
| false | qemu | 53cb28cbfea038f8ad50132dc8a684e638c7d48b | static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index,
hwaddr *nb, uint16_t leaf,
int level)
{
PhysPageEntry *p;
int i;
hwaddr step = (hwaddr)1 << (level * P_L2_BITS);
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {
lp->ptr = phys_map_node_alloc();
p = next_map.nodes[lp->ptr];
if (level == 0) {
for (i = 0; i < P_L2_SIZE; i++) {
p[i].skip = 0;
p[i].ptr = PHYS_SECTION_UNASSIGNED;
}
}
} else {
p = next_map.nodes[lp->ptr];
}
lp = &p[(*index >> (level * P_L2_BITS)) & (P_L2_SIZE - 1)];
while (*nb && lp < &p[P_L2_SIZE]) {
if ((*index & (step - 1)) == 0 && *nb >= step) {
lp->skip = 0;
lp->ptr = leaf;
*index += step;
*nb -= step;
} else {
phys_page_set_level(lp, index, nb, leaf, level - 1);
}
++lp;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(PhysPageEntry *VAR_0, hwaddr *VAR_1,
hwaddr *VAR_2, uint16_t VAR_3,
int VAR_4)
{
PhysPageEntry *p;
int VAR_5;
hwaddr step = (hwaddr)1 << (VAR_4 * P_L2_BITS);
if (VAR_0->skip && VAR_0->ptr == PHYS_MAP_NODE_NIL) {
VAR_0->ptr = phys_map_node_alloc();
p = next_map.nodes[VAR_0->ptr];
if (VAR_4 == 0) {
for (VAR_5 = 0; VAR_5 < P_L2_SIZE; VAR_5++) {
p[VAR_5].skip = 0;
p[VAR_5].ptr = PHYS_SECTION_UNASSIGNED;
}
}
} else {
p = next_map.nodes[VAR_0->ptr];
}
VAR_0 = &p[(*VAR_1 >> (VAR_4 * P_L2_BITS)) & (P_L2_SIZE - 1)];
while (*VAR_2 && VAR_0 < &p[P_L2_SIZE]) {
if ((*VAR_1 & (step - 1)) == 0 && *VAR_2 >= step) {
VAR_0->skip = 0;
VAR_0->ptr = VAR_3;
*VAR_1 += step;
*VAR_2 -= step;
} else {
FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 - 1);
}
++VAR_0;
}
}
| [
"static void FUNC_0(PhysPageEntry *VAR_0, hwaddr *VAR_1,\nhwaddr *VAR_2, uint16_t VAR_3,\nint VAR_4)\n{",
"PhysPageEntry *p;",
"int VAR_5;",
"hwaddr step = (hwaddr)1 << (VAR_4 * P_L2_BITS);",
"if (VAR_0->skip && VAR_0->ptr == PHYS_MAP_NODE_NIL) {",
"VAR_0->ptr = phys_map_node_alloc();",
"p = next_map.nodes[VAR_0->ptr];",
"if (VAR_4 == 0) {",
"for (VAR_5 = 0; VAR_5 < P_L2_SIZE; VAR_5++) {",
"p[VAR_5].skip = 0;",
"p[VAR_5].ptr = PHYS_SECTION_UNASSIGNED;",
"}",
"}",
"} else {",
"p = next_map.nodes[VAR_0->ptr];",
"}",
"VAR_0 = &p[(*VAR_1 >> (VAR_4 * P_L2_BITS)) & (P_L2_SIZE - 1)];",
"while (*VAR_2 && VAR_0 < &p[P_L2_SIZE]) {",
"if ((*VAR_1 & (step - 1)) == 0 && *VAR_2 >= step) {",
"VAR_0->skip = 0;",
"VAR_0->ptr = VAR_3;",
"*VAR_1 += step;",
"*VAR_2 -= step;",
"} else {",
"FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4 - 1);",
"}",
"++VAR_0;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
]
] |
1,233 | static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted)
{
target_phys_addr_t len = wanted;
if (*ptr) {
cpu_physical_memory_unmap(*ptr, len, 1, len);
}
*ptr = cpu_physical_memory_map(addr, &len, 1);
if (len < wanted) {
cpu_physical_memory_unmap(*ptr, len, 1, len);
*ptr = NULL;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted)
{
target_phys_addr_t len = wanted;
if (*ptr) {
cpu_physical_memory_unmap(*ptr, len, 1, len);
}
*ptr = cpu_physical_memory_map(addr, &len, 1);
if (len < wanted) {
cpu_physical_memory_unmap(*ptr, len, 1, len);
*ptr = NULL;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t **VAR_0, uint64_t VAR_1, uint32_t VAR_2)
{
target_phys_addr_t len = VAR_2;
if (*VAR_0) {
cpu_physical_memory_unmap(*VAR_0, len, 1, len);
}
*VAR_0 = cpu_physical_memory_map(VAR_1, &len, 1);
if (len < VAR_2) {
cpu_physical_memory_unmap(*VAR_0, len, 1, len);
*VAR_0 = NULL;
}
}
| [
"static void FUNC_0(uint8_t **VAR_0, uint64_t VAR_1, uint32_t VAR_2)\n{",
"target_phys_addr_t len = VAR_2;",
"if (*VAR_0) {",
"cpu_physical_memory_unmap(*VAR_0, len, 1, len);",
"}",
"*VAR_0 = cpu_physical_memory_map(VAR_1, &len, 1);",
"if (len < VAR_2) {",
"cpu_physical_memory_unmap(*VAR_0, len, 1, len);",
"*VAR_0 = NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
1,234 | static VmdkExtent *vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, unsigned int cluster_sectors)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = cluster_sectors;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
return extent;
}
| false | qemu | 8aa1331c09a9b899f48d97f097bb49b7d458be1c | static VmdkExtent *vmdk_add_extent(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, unsigned int cluster_sectors)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = cluster_sectors;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
return extent;
}
| {
"code": [],
"line_no": []
} | static VmdkExtent *FUNC_0(BlockDriverState *bs,
BlockDriverState *file, bool flat, int64_t sectors,
int64_t l1_offset, int64_t l1_backup_offset,
uint32_t l1_size,
int l2_size, unsigned int cluster_sectors)
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
s->extents = g_realloc(s->extents,
(s->num_extents + 1) * sizeof(VmdkExtent));
extent = &s->extents[s->num_extents];
s->num_extents++;
memset(extent, 0, sizeof(VmdkExtent));
extent->file = file;
extent->flat = flat;
extent->sectors = sectors;
extent->l1_table_offset = l1_offset;
extent->l1_backup_table_offset = l1_backup_offset;
extent->l1_size = l1_size;
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = cluster_sectors;
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else {
extent->end_sector = extent->sectors;
}
bs->total_sectors = extent->end_sector;
return extent;
}
| [
"static VmdkExtent *FUNC_0(BlockDriverState *bs,\nBlockDriverState *file, bool flat, int64_t sectors,\nint64_t l1_offset, int64_t l1_backup_offset,\nuint32_t l1_size,\nint l2_size, unsigned int cluster_sectors)\n{",
"VmdkExtent *extent;",
"BDRVVmdkState *s = bs->opaque;",
"s->extents = g_realloc(s->extents,\n(s->num_extents + 1) * sizeof(VmdkExtent));",
"extent = &s->extents[s->num_extents];",
"s->num_extents++;",
"memset(extent, 0, sizeof(VmdkExtent));",
"extent->file = file;",
"extent->flat = flat;",
"extent->sectors = sectors;",
"extent->l1_table_offset = l1_offset;",
"extent->l1_backup_table_offset = l1_backup_offset;",
"extent->l1_size = l1_size;",
"extent->l1_entry_sectors = l2_size * cluster_sectors;",
"extent->l2_size = l2_size;",
"extent->cluster_sectors = cluster_sectors;",
"if (s->num_extents > 1) {",
"extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;",
"} else {",
"extent->end_sector = extent->sectors;",
"}",
"bs->total_sectors = extent->end_sector;",
"return extent;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
]
] |
1,235 | static void ppc_heathrow_init (int ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char **fd_filename, int snapshot,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char buf[1024];
qemu_irq *pic, **heathrow_irqs;
nvram_t nvram;
m48t59_t *m48t59;
int linux_boot, i;
unsigned long bios_offset, vga_bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
MacIONVRAMState *nvr;
int vga_bios_size, bios_size;
qemu_irq *dummy_irq;
int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
int ppc_boot_device = boot_device[0];
linux_boot = (kernel_filename != NULL);
/* init CPUs */
if (cpu_model == NULL)
cpu_model = "default";
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
/* Set time-base frequency to 100 Mhz */
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
env->osi_call = vga_osi_call;
qemu_register_reset(&cpu_ppc_reset, env);
register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
envs[i] = env;
}
if (env->nip < 0xFFF80000) {
/* Special test for PowerPC 601:
* the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
* But the NVRAM is located at 0xFFF04000...
*/
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
/* allocate RAM */
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
/* allocate and load BIOS */
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
if (bios_size > 0x00080000) {
/* As the NVRAM is located at 0xFFF04000, we cannot use 1 MB BIOSes */
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
/* allocate and load VGA BIOS */
vga_bios_offset = bios_offset + bios_size;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
if (vga_bios_size < 0) {
/* if no bios is present, we can still work */
fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
vga_bios_size = 0;
} else {
/* set a specific header (XXX: find real Apple format for NDRV
drivers) */
phys_ram_base[vga_bios_offset] = 'N';
phys_ram_base[vga_bios_offset + 1] = 'D';
phys_ram_base[vga_bios_offset + 2] = 'R';
phys_ram_base[vga_bios_offset + 3] = 'V';
cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4),
vga_bios_size);
vga_bios_size += 8;
}
vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
/* now we can load the kernel */
kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
if (kernel_size < 0) {
cpu_abort(env, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
/* load initrd */
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image(initrd_filename,
phys_ram_base + initrd_base);
if (initrd_size < 0) {
cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
isa_mem_base = 0x80000000;
/* Register 2 MB of ISA IO space */
isa_mmio_init(0xfe000000, 0x00200000);
/* XXX: we register only 1 output pin for heathrow PIC */
heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1);
/* Connect the heathrow PIC outputs to the 6xx bus */
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
heathrow_irqs[i] = heathrow_irqs[0] + (i * 1);
heathrow_irqs[i][0] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
break;
default:
cpu_abort(env, "Bus model not supported on OldWorld Mac machine\n");
exit(1);
}
}
/* init basic PC hardware */
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n");
exit(1);
}
pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic);
pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
ram_size, vga_ram_size,
vga_bios_offset, vga_bios_size);
/* XXX: suppress that */
dummy_irq = i8259_init(NULL);
/* XXX: use Mac Serial port */
serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
for(i = 0; i < nb_nics; i++) {
if (!nd_table[i].model)
nd_table[i].model = "ne2k_pci";
pci_nic_init(pci_bus, &nd_table[i], -1);
}
pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
/* cuda also initialize ADB */
cuda_init(&cuda_mem_index, pic[0x12]);
adb_kbd_init(&adb_bus);
adb_mouse_init(&adb_bus);
nvr = macio_nvram_init(&nvram_mem_index, 0x2000);
pmac_format_nvram_partition(nvr, 0x2000);
dbdma_init(&dbdma_mem_index);
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
cuda_mem_index, nvr, 0, NULL);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, 3, -1);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", ram_size,
ppc_boot_device, kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
/* XXX: need an option to load a NVRAM image */
0,
graphic_width, graphic_height, graphic_depth);
/* No PCI init: the BIOS will do it */
/* Special port to get debug messages from Open-Firmware */
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| false | qemu | 28c5af54c661e73e5596918fa67a22b5e87c2022 | static void ppc_heathrow_init (int ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char **fd_filename, int snapshot,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char buf[1024];
qemu_irq *pic, **heathrow_irqs;
nvram_t nvram;
m48t59_t *m48t59;
int linux_boot, i;
unsigned long bios_offset, vga_bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
MacIONVRAMState *nvr;
int vga_bios_size, bios_size;
qemu_irq *dummy_irq;
int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
int ppc_boot_device = boot_device[0];
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "default";
for (i = 0; i < smp_cpus; i++) {
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
env->osi_call = vga_osi_call;
qemu_register_reset(&cpu_ppc_reset, env);
register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
envs[i] = env;
}
if (env->nip < 0xFFF80000) {
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
exit(1);
}
bios_size = (bios_size + 0xfff) & ~0xfff;
if (bios_size > 0x00080000) {
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
vga_bios_offset = bios_offset + bios_size;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
if (vga_bios_size < 0) {
fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
vga_bios_size = 0;
} else {
phys_ram_base[vga_bios_offset] = 'N';
phys_ram_base[vga_bios_offset + 1] = 'D';
phys_ram_base[vga_bios_offset + 2] = 'R';
phys_ram_base[vga_bios_offset + 3] = 'V';
cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4),
vga_bios_size);
vga_bios_size += 8;
}
vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
if (kernel_size < 0) {
cpu_abort(env, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image(initrd_filename,
phys_ram_base + initrd_base);
if (initrd_size < 0) {
cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
isa_mem_base = 0x80000000;
isa_mmio_init(0xfe000000, 0x00200000);
heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
heathrow_irqs[i] = heathrow_irqs[0] + (i * 1);
heathrow_irqs[i][0] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
break;
default:
cpu_abort(env, "Bus model not supported on OldWorld Mac machine\n");
exit(1);
}
}
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n");
exit(1);
}
pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic);
pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
ram_size, vga_ram_size,
vga_bios_offset, vga_bios_size);
dummy_irq = i8259_init(NULL);
serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
for(i = 0; i < nb_nics; i++) {
if (!nd_table[i].model)
nd_table[i].model = "ne2k_pci";
pci_nic_init(pci_bus, &nd_table[i], -1);
}
pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
cuda_init(&cuda_mem_index, pic[0x12]);
adb_kbd_init(&adb_bus);
adb_mouse_init(&adb_bus);
nvr = macio_nvram_init(&nvram_mem_index, 0x2000);
pmac_format_nvram_partition(nvr, 0x2000);
dbdma_init(&dbdma_mem_index);
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
cuda_mem_index, nvr, 0, NULL);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, 3, -1);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", ram_size,
ppc_boot_device, kernel_base, kernel_size,
kernel_cmdline,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0 (int VAR_0, int VAR_1,
const char *VAR_2, DisplayState *VAR_3,
const char **VAR_4, int VAR_5,
const char *VAR_6,
const char *VAR_7,
const char *VAR_8,
const char *VAR_9)
{
CPUState *env = NULL, *envs[MAX_CPUS];
char VAR_10[1024];
qemu_irq *pic, **heathrow_irqs;
nvram_t nvram;
m48t59_t *m48t59;
int VAR_11, VAR_12;
unsigned long VAR_13, VAR_14;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
PCIBus *pci_bus;
MacIONVRAMState *nvr;
int VAR_15, VAR_16;
qemu_irq *dummy_irq;
int VAR_17, VAR_18, VAR_19, VAR_20;
int VAR_21 = VAR_2[0];
VAR_11 = (VAR_6 != NULL);
if (VAR_9 == NULL)
VAR_9 = "default";
for (VAR_12 = 0; VAR_12 < smp_cpus; VAR_12++) {
env = cpu_init(VAR_9);
if (!env) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
env->osi_call = vga_osi_call;
qemu_register_reset(&cpu_ppc_reset, env);
register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
envs[VAR_12] = env;
}
if (env->nip < 0xFFF80000) {
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory(0, VAR_0, IO_MEM_RAM);
VAR_13 = VAR_0 + VAR_1;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
snprintf(VAR_10, sizeof(VAR_10), "%s/%s", bios_dir, bios_name);
VAR_16 = load_image(VAR_10, phys_ram_base + VAR_13);
if (VAR_16 < 0 || VAR_16 > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", VAR_10);
exit(1);
}
VAR_16 = (VAR_16 + 0xfff) & ~0xfff;
if (VAR_16 > 0x00080000) {
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
}
cpu_register_physical_memory((uint32_t)(-VAR_16),
VAR_16, VAR_13 | IO_MEM_ROM);
VAR_14 = VAR_13 + VAR_16;
snprintf(VAR_10, sizeof(VAR_10), "%s/%s", bios_dir, VGABIOS_FILENAME);
VAR_15 = load_image(VAR_10, phys_ram_base + VAR_14 + 8);
if (VAR_15 < 0) {
fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", VAR_10);
VAR_15 = 0;
} else {
phys_ram_base[VAR_14] = 'N';
phys_ram_base[VAR_14 + 1] = 'D';
phys_ram_base[VAR_14 + 2] = 'R';
phys_ram_base[VAR_14 + 3] = 'V';
cpu_to_be32w((uint32_t *)(phys_ram_base + VAR_14 + 4),
VAR_15);
VAR_15 += 8;
}
VAR_15 = (VAR_15 + 0xfff) & ~0xfff;
if (VAR_11) {
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_image(VAR_6, phys_ram_base + kernel_base);
if (kernel_size < 0) {
cpu_abort(env, "qemu: could not load kernel '%s'\n",
VAR_6);
exit(1);
}
if (VAR_8) {
initrd_base = INITRD_LOAD_ADDR;
initrd_size = load_image(VAR_8,
phys_ram_base + initrd_base);
if (initrd_size < 0) {
cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
VAR_8);
exit(1);
}
} else {
initrd_base = 0;
initrd_size = 0;
}
VAR_21 = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
}
isa_mem_base = 0x80000000;
isa_mmio_init(0xfe000000, 0x00200000);
heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1);
for (VAR_12 = 0; VAR_12 < smp_cpus; VAR_12++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
heathrow_irqs[VAR_12] = heathrow_irqs[0] + (VAR_12 * 1);
heathrow_irqs[VAR_12][0] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
break;
default:
cpu_abort(env, "Bus model not supported on OldWorld Mac machine\n");
exit(1);
}
}
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n");
exit(1);
}
pic = heathrow_pic_init(&VAR_17, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic);
pci_vga_init(pci_bus, VAR_3, phys_ram_base + VAR_0,
VAR_0, VAR_1,
VAR_14, VAR_15);
dummy_irq = i8259_init(NULL);
serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
for(VAR_12 = 0; VAR_12 < nb_nics; VAR_12++) {
if (!nd_table[VAR_12].model)
nd_table[VAR_12].model = "ne2k_pci";
pci_nic_init(pci_bus, &nd_table[VAR_12], -1);
}
pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
cuda_init(&VAR_20, pic[0x12]);
adb_kbd_init(&adb_bus);
adb_mouse_init(&adb_bus);
nvr = macio_nvram_init(&VAR_18, 0x2000);
pmac_format_nvram_partition(nvr, 0x2000);
dbdma_init(&VAR_19);
macio_init(pci_bus, 0x0017, 1, VAR_17, VAR_19,
VAR_20, nvr, 0, NULL);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, 3, -1);
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
nvram.opaque = m48t59;
nvram.read_fn = &m48t59_read;
nvram.write_fn = &m48t59_write;
PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", VAR_0,
VAR_21, kernel_base, kernel_size,
VAR_7,
initrd_base, initrd_size,
0,
graphic_width, graphic_height, graphic_depth);
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
}
| [
"static void FUNC_0 (int VAR_0, int VAR_1,\nconst char *VAR_2, DisplayState *VAR_3,\nconst char **VAR_4, int VAR_5,\nconst char *VAR_6,\nconst char *VAR_7,\nconst char *VAR_8,\nconst char *VAR_9)\n{",
"CPUState *env = NULL, *envs[MAX_CPUS];",
"char VAR_10[1024];",
"qemu_irq *pic, **heathrow_irqs;",
"nvram_t nvram;",
"m48t59_t *m48t59;",
"int VAR_11, VAR_12;",
"unsigned long VAR_13, VAR_14;",
"uint32_t kernel_base, kernel_size, initrd_base, initrd_size;",
"PCIBus *pci_bus;",
"MacIONVRAMState *nvr;",
"int VAR_15, VAR_16;",
"qemu_irq *dummy_irq;",
"int VAR_17, VAR_18, VAR_19, VAR_20;",
"int VAR_21 = VAR_2[0];",
"VAR_11 = (VAR_6 != NULL);",
"if (VAR_9 == NULL)\nVAR_9 = \"default\";",
"for (VAR_12 = 0; VAR_12 < smp_cpus; VAR_12++) {",
"env = cpu_init(VAR_9);",
"if (!env) {",
"fprintf(stderr, \"Unable to find PowerPC CPU definition\\n\");",
"exit(1);",
"}",
"cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);",
"env->osi_call = vga_osi_call;",
"qemu_register_reset(&cpu_ppc_reset, env);",
"register_savevm(\"cpu\", 0, 3, cpu_save, cpu_load, env);",
"envs[VAR_12] = env;",
"}",
"if (env->nip < 0xFFF80000) {",
"cpu_abort(env, \"G3BW Mac hardware can not handle 1 MB BIOS\\n\");",
"}",
"cpu_register_physical_memory(0, VAR_0, IO_MEM_RAM);",
"VAR_13 = VAR_0 + VAR_1;",
"if (bios_name == NULL)\nbios_name = BIOS_FILENAME;",
"snprintf(VAR_10, sizeof(VAR_10), \"%s/%s\", bios_dir, bios_name);",
"VAR_16 = load_image(VAR_10, phys_ram_base + VAR_13);",
"if (VAR_16 < 0 || VAR_16 > BIOS_SIZE) {",
"cpu_abort(env, \"qemu: could not load PowerPC bios '%s'\\n\", VAR_10);",
"exit(1);",
"}",
"VAR_16 = (VAR_16 + 0xfff) & ~0xfff;",
"if (VAR_16 > 0x00080000) {",
"cpu_abort(env, \"G3BW Mac hardware can not handle 1 MB BIOS\\n\");",
"}",
"cpu_register_physical_memory((uint32_t)(-VAR_16),\nVAR_16, VAR_13 | IO_MEM_ROM);",
"VAR_14 = VAR_13 + VAR_16;",
"snprintf(VAR_10, sizeof(VAR_10), \"%s/%s\", bios_dir, VGABIOS_FILENAME);",
"VAR_15 = load_image(VAR_10, phys_ram_base + VAR_14 + 8);",
"if (VAR_15 < 0) {",
"fprintf(stderr, \"qemu: warning: could not load VGA bios '%s'\\n\", VAR_10);",
"VAR_15 = 0;",
"} else {",
"phys_ram_base[VAR_14] = 'N';",
"phys_ram_base[VAR_14 + 1] = 'D';",
"phys_ram_base[VAR_14 + 2] = 'R';",
"phys_ram_base[VAR_14 + 3] = 'V';",
"cpu_to_be32w((uint32_t *)(phys_ram_base + VAR_14 + 4),\nVAR_15);",
"VAR_15 += 8;",
"}",
"VAR_15 = (VAR_15 + 0xfff) & ~0xfff;",
"if (VAR_11) {",
"kernel_base = KERNEL_LOAD_ADDR;",
"kernel_size = load_image(VAR_6, phys_ram_base + kernel_base);",
"if (kernel_size < 0) {",
"cpu_abort(env, \"qemu: could not load kernel '%s'\\n\",\nVAR_6);",
"exit(1);",
"}",
"if (VAR_8) {",
"initrd_base = INITRD_LOAD_ADDR;",
"initrd_size = load_image(VAR_8,\nphys_ram_base + initrd_base);",
"if (initrd_size < 0) {",
"cpu_abort(env, \"qemu: could not load initial ram disk '%s'\\n\",\nVAR_8);",
"exit(1);",
"}",
"} else {",
"initrd_base = 0;",
"initrd_size = 0;",
"}",
"VAR_21 = 'm';",
"} else {",
"kernel_base = 0;",
"kernel_size = 0;",
"initrd_base = 0;",
"initrd_size = 0;",
"}",
"isa_mem_base = 0x80000000;",
"isa_mmio_init(0xfe000000, 0x00200000);",
"heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));",
"heathrow_irqs[0] =\nqemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1);",
"for (VAR_12 = 0; VAR_12 < smp_cpus; VAR_12++) {",
"switch (PPC_INPUT(env)) {",
"case PPC_FLAGS_INPUT_6xx:\nheathrow_irqs[VAR_12] = heathrow_irqs[0] + (VAR_12 * 1);",
"heathrow_irqs[VAR_12][0] =\n((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];",
"break;",
"default:\ncpu_abort(env, \"Bus model not supported on OldWorld Mac machine\\n\");",
"exit(1);",
"}",
"}",
"if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {",
"cpu_abort(env, \"Only 6xx bus is supported on heathrow machine\\n\");",
"exit(1);",
"}",
"pic = heathrow_pic_init(&VAR_17, 1, heathrow_irqs);",
"pci_bus = pci_grackle_init(0xfec00000, pic);",
"pci_vga_init(pci_bus, VAR_3, phys_ram_base + VAR_0,\nVAR_0, VAR_1,\nVAR_14, VAR_15);",
"dummy_irq = i8259_init(NULL);",
"serial_init(0x3f8, dummy_irq[4], serial_hds[0]);",
"for(VAR_12 = 0; VAR_12 < nb_nics; VAR_12++) {",
"if (!nd_table[VAR_12].model)\nnd_table[VAR_12].model = \"ne2k_pci\";",
"pci_nic_init(pci_bus, &nd_table[VAR_12], -1);",
"}",
"pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);",
"cuda_init(&VAR_20, pic[0x12]);",
"adb_kbd_init(&adb_bus);",
"adb_mouse_init(&adb_bus);",
"nvr = macio_nvram_init(&VAR_18, 0x2000);",
"pmac_format_nvram_partition(nvr, 0x2000);",
"dbdma_init(&VAR_19);",
"macio_init(pci_bus, 0x0017, 1, VAR_17, VAR_19,\nVAR_20, nvr, 0, NULL);",
"if (usb_enabled) {",
"usb_ohci_init_pci(pci_bus, 3, -1);",
"}",
"if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)\ngraphic_depth = 15;",
"m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);",
"nvram.opaque = m48t59;",
"nvram.read_fn = &m48t59_read;",
"nvram.write_fn = &m48t59_write;",
"PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, \"HEATHROW\", VAR_0,\nVAR_21, kernel_base, kernel_size,\nVAR_7,\ninitrd_base, initrd_size,\n0,\ngraphic_width, graphic_height, graphic_depth);",
"register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
93
],
[
95
],
[
101
],
[
107
],
[
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
131
],
[
133
],
[
135,
137
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
203
],
[
205
],
[
207,
209
],
[
211
],
[
213,
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
251
],
[
257
],
[
259,
261
],
[
265
],
[
267
],
[
269,
271
],
[
273,
275
],
[
277
],
[
279,
281
],
[
283
],
[
285
],
[
287
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305,
307,
309
],
[
315
],
[
321
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
337
],
[
343
],
[
347
],
[
349
],
[
353
],
[
355
],
[
359
],
[
363,
365
],
[
369
],
[
371
],
[
373
],
[
377,
379
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391,
393,
395,
397,
401,
403
],
[
411
],
[
413
]
] |
1,236 | static void musicpal_gpio_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
musicpal_gpio_state *s = opaque;
switch (offset) {
case MP_GPIO_OE_HI: /* used for LCD brightness control */
s->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) |
(value & MP_OE_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
break;
case MP_GPIO_OUT_LO:
s->out_state = (s->out_state & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_OUT_HI:
s->out_state = (s->out_state & 0xFFFF) | (value << 16);
s->lcd_brightness = (s->lcd_brightness & 0xFFFF) |
(s->out_state & MP_GPIO_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1);
qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1);
break;
case MP_GPIO_IER_LO:
s->ier = (s->ier & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_IER_HI:
s->ier = (s->ier & 0xFFFF) | (value << 16);
break;
case MP_GPIO_IMR_LO:
s->imr = (s->imr & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_IMR_HI:
s->imr = (s->imr & 0xFFFF) | (value << 16);
break;
}
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void musicpal_gpio_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size)
{
musicpal_gpio_state *s = opaque;
switch (offset) {
case MP_GPIO_OE_HI:
s->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) |
(value & MP_OE_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
break;
case MP_GPIO_OUT_LO:
s->out_state = (s->out_state & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_OUT_HI:
s->out_state = (s->out_state & 0xFFFF) | (value << 16);
s->lcd_brightness = (s->lcd_brightness & 0xFFFF) |
(s->out_state & MP_GPIO_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1);
qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1);
break;
case MP_GPIO_IER_LO:
s->ier = (s->ier & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_IER_HI:
s->ier = (s->ier & 0xFFFF) | (value << 16);
break;
case MP_GPIO_IMR_LO:
s->imr = (s->imr & 0xFFFF0000) | (value & 0xFFFF);
break;
case MP_GPIO_IMR_HI:
s->imr = (s->imr & 0xFFFF) | (value << 16);
break;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
musicpal_gpio_state *s = VAR_0;
switch (VAR_1) {
case MP_GPIO_OE_HI:
s->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) |
(VAR_2 & MP_OE_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
break;
case MP_GPIO_OUT_LO:
s->out_state = (s->out_state & 0xFFFF0000) | (VAR_2 & 0xFFFF);
break;
case MP_GPIO_OUT_HI:
s->out_state = (s->out_state & 0xFFFF) | (VAR_2 << 16);
s->lcd_brightness = (s->lcd_brightness & 0xFFFF) |
(s->out_state & MP_GPIO_LCD_BRIGHTNESS);
musicpal_gpio_brightness_update(s);
qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1);
qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1);
break;
case MP_GPIO_IER_LO:
s->ier = (s->ier & 0xFFFF0000) | (VAR_2 & 0xFFFF);
break;
case MP_GPIO_IER_HI:
s->ier = (s->ier & 0xFFFF) | (VAR_2 << 16);
break;
case MP_GPIO_IMR_LO:
s->imr = (s->imr & 0xFFFF0000) | (VAR_2 & 0xFFFF);
break;
case MP_GPIO_IMR_HI:
s->imr = (s->imr & 0xFFFF) | (VAR_2 << 16);
break;
}
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"musicpal_gpio_state *s = VAR_0;",
"switch (VAR_1) {",
"case MP_GPIO_OE_HI:\ns->lcd_brightness = (s->lcd_brightness & MP_GPIO_LCD_BRIGHTNESS) |\n(VAR_2 & MP_OE_LCD_BRIGHTNESS);",
"musicpal_gpio_brightness_update(s);",
"break;",
"case MP_GPIO_OUT_LO:\ns->out_state = (s->out_state & 0xFFFF0000) | (VAR_2 & 0xFFFF);",
"break;",
"case MP_GPIO_OUT_HI:\ns->out_state = (s->out_state & 0xFFFF) | (VAR_2 << 16);",
"s->lcd_brightness = (s->lcd_brightness & 0xFFFF) |\n(s->out_state & MP_GPIO_LCD_BRIGHTNESS);",
"musicpal_gpio_brightness_update(s);",
"qemu_set_irq(s->out[3], (s->out_state >> MP_GPIO_I2C_DATA_BIT) & 1);",
"qemu_set_irq(s->out[4], (s->out_state >> MP_GPIO_I2C_CLOCK_BIT) & 1);",
"break;",
"case MP_GPIO_IER_LO:\ns->ier = (s->ier & 0xFFFF0000) | (VAR_2 & 0xFFFF);",
"break;",
"case MP_GPIO_IER_HI:\ns->ier = (s->ier & 0xFFFF) | (VAR_2 << 16);",
"break;",
"case MP_GPIO_IMR_LO:\ns->imr = (s->imr & 0xFFFF0000) | (VAR_2 & 0xFFFF);",
"break;",
"case MP_GPIO_IMR_HI:\ns->imr = (s->imr & 0xFFFF) | (VAR_2 << 16);",
"break;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11,
13,
15
],
[
17
],
[
19
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51
],
[
53,
55
],
[
57
],
[
61,
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
]
] |
1,237 | static inline void scale_mv(AVSContext *h, int *d_x, int *d_y,
cavs_vector *src, int distp)
{
int den = h->scale_den[src->ref];
*d_x = (src->x * distp * den + 256 + (src->x >> 31)) >> 9;
*d_y = (src->y * distp * den + 256 + (src->y >> 31)) >> 9;
}
| false | FFmpeg | 1fb46858c2498c67ae2d6775f7da29732e88fb8a | static inline void scale_mv(AVSContext *h, int *d_x, int *d_y,
cavs_vector *src, int distp)
{
int den = h->scale_den[src->ref];
*d_x = (src->x * distp * den + 256 + (src->x >> 31)) >> 9;
*d_y = (src->y * distp * den + 256 + (src->y >> 31)) >> 9;
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(AVSContext *VAR_0, int *VAR_1, int *VAR_2,
cavs_vector *VAR_3, int VAR_4)
{
int VAR_5 = VAR_0->scale_den[VAR_3->ref];
*VAR_1 = (VAR_3->x * VAR_4 * VAR_5 + 256 + (VAR_3->x >> 31)) >> 9;
*VAR_2 = (VAR_3->y * VAR_4 * VAR_5 + 256 + (VAR_3->y >> 31)) >> 9;
}
| [
"static inline void FUNC_0(AVSContext *VAR_0, int *VAR_1, int *VAR_2,\ncavs_vector *VAR_3, int VAR_4)\n{",
"int VAR_5 = VAR_0->scale_den[VAR_3->ref];",
"*VAR_1 = (VAR_3->x * VAR_4 * VAR_5 + 256 + (VAR_3->x >> 31)) >> 9;",
"*VAR_2 = (VAR_3->y * VAR_4 * VAR_5 + 256 + (VAR_3->y >> 31)) >> 9;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11
],
[
13
],
[
15
]
] |
1,238 | static int usb_wacom_handle_data(USBDevice *dev, USBPacket *p)
{
USBWacomState *s = (USBWacomState *) dev;
uint8_t buf[p->iov.size];
int ret = 0;
switch (p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
if (!(s->changed || s->idle))
return USB_RET_NAK;
s->changed = 0;
if (s->mode == WACOM_MODE_HID)
ret = usb_mouse_poll(s, buf, p->iov.size);
else if (s->mode == WACOM_MODE_WACOM)
ret = usb_wacom_poll(s, buf, p->iov.size);
usb_packet_copy(p, buf, ret);
break;
}
/* Fall through. */
case USB_TOKEN_OUT:
default:
ret = USB_RET_STALL;
break;
}
return ret;
}
| false | qemu | 079d0b7f1eedcc634c371fe05b617fdc55c8b762 | static int usb_wacom_handle_data(USBDevice *dev, USBPacket *p)
{
USBWacomState *s = (USBWacomState *) dev;
uint8_t buf[p->iov.size];
int ret = 0;
switch (p->pid) {
case USB_TOKEN_IN:
if (p->devep == 1) {
if (!(s->changed || s->idle))
return USB_RET_NAK;
s->changed = 0;
if (s->mode == WACOM_MODE_HID)
ret = usb_mouse_poll(s, buf, p->iov.size);
else if (s->mode == WACOM_MODE_WACOM)
ret = usb_wacom_poll(s, buf, p->iov.size);
usb_packet_copy(p, buf, ret);
break;
}
case USB_TOKEN_OUT:
default:
ret = USB_RET_STALL;
break;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)
{
USBWacomState *s = (USBWacomState *) VAR_0;
uint8_t buf[VAR_1->iov.size];
int VAR_2 = 0;
switch (VAR_1->pid) {
case USB_TOKEN_IN:
if (VAR_1->devep == 1) {
if (!(s->changed || s->idle))
return USB_RET_NAK;
s->changed = 0;
if (s->mode == WACOM_MODE_HID)
VAR_2 = usb_mouse_poll(s, buf, VAR_1->iov.size);
else if (s->mode == WACOM_MODE_WACOM)
VAR_2 = usb_wacom_poll(s, buf, VAR_1->iov.size);
usb_packet_copy(VAR_1, buf, VAR_2);
break;
}
case USB_TOKEN_OUT:
default:
VAR_2 = USB_RET_STALL;
break;
}
return VAR_2;
}
| [
"static int FUNC_0(USBDevice *VAR_0, USBPacket *VAR_1)\n{",
"USBWacomState *s = (USBWacomState *) VAR_0;",
"uint8_t buf[VAR_1->iov.size];",
"int VAR_2 = 0;",
"switch (VAR_1->pid) {",
"case USB_TOKEN_IN:\nif (VAR_1->devep == 1) {",
"if (!(s->changed || s->idle))\nreturn USB_RET_NAK;",
"s->changed = 0;",
"if (s->mode == WACOM_MODE_HID)\nVAR_2 = usb_mouse_poll(s, buf, VAR_1->iov.size);",
"else if (s->mode == WACOM_MODE_WACOM)\nVAR_2 = usb_wacom_poll(s, buf, VAR_1->iov.size);",
"usb_packet_copy(VAR_1, buf, VAR_2);",
"break;",
"}",
"case USB_TOKEN_OUT:\ndefault:\nVAR_2 = USB_RET_STALL;",
"break;",
"}",
"return VAR_2;",
"}"
] | [
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
],
[
41,
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
]
] |
1,239 | RGB_FUNCTIONS(rgb565)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
/* bgr24 handling */
#define RGB_IN(r, g, b, s)\
{\
b = (s)[0];\
g = (s)[1];\
r = (s)[2];\
}
#define RGB_OUT(d, r, g, b)\
{\
(d)[0] = b;\
(d)[1] = g;\
(d)[2] = r;\
}
#define BPP 3
RGB_FUNCTIONS(bgr24)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
/* rgb24 handling */
#define RGB_IN(r, g, b, s)\
{\
r = (s)[0];\
g = (s)[1];\
b = (s)[2];\
}
#define RGB_OUT(d, r, g, b)\
{\
(d)[0] = r;\
(d)[1] = g;\
(d)[2] = b;\
}
#define BPP 3
RGB_FUNCTIONS(rgb24)
static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
int w, y, cb, cr, r_add, g_add, b_add;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
d = dst->data[0];
y1_ptr = src->data[0];
cb_ptr = src->data[1];
cr_ptr = src->data[2];
for(;height > 0; height --) {
d1 = d;
for(w = width; w > 0; w--) {
YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
RGB_OUT(d1, r, g, b);
d1 += BPP;
y1_ptr++;
cb_ptr++;
cr_ptr++;
}
d += dst->linesize[0];
y1_ptr += src->linesize[0] - width;
cb_ptr += src->linesize[1] - width;
cr_ptr += src->linesize[2] - width;
}
}
| false | FFmpeg | 7e7e59409294af9caa63808e56c5cc824c98b4fc | RGB_FUNCTIONS(rgb565)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
#define RGB_IN(r, g, b, s)\
{\
b = (s)[0];\
g = (s)[1];\
r = (s)[2];\
}
#define RGB_OUT(d, r, g, b)\
{\
(d)[0] = b;\
(d)[1] = g;\
(d)[2] = r;\
}
#define BPP 3
RGB_FUNCTIONS(bgr24)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
#define RGB_IN(r, g, b, s)\
{\
r = (s)[0];\
g = (s)[1];\
b = (s)[2];\
}
#define RGB_OUT(d, r, g, b)\
{\
(d)[0] = r;\
(d)[1] = g;\
(d)[2] = b;\
}
#define BPP 3
RGB_FUNCTIONS(rgb24)
static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
int w, y, cb, cr, r_add, g_add, b_add;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int r, g, b;
d = dst->data[0];
y1_ptr = src->data[0];
cb_ptr = src->data[1];
cr_ptr = src->data[2];
for(;height > 0; height --) {
d1 = d;
for(w = width; w > 0; w--) {
YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
RGB_OUT(d1, r, g, b);
d1 += BPP;
y1_ptr++;
cb_ptr++;
cr_ptr++;
}
d += dst->linesize[0];
y1_ptr += src->linesize[0] - width;
cb_ptr += src->linesize[1] - width;
cr_ptr += src->linesize[2] - width;
}
}
| {
"code": [],
"line_no": []
} | FUNC_1(VAR_0)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
#define RGB_IN(VAR_10, VAR_11, VAR_12, s)\
{\
VAR_12 = (s)[0];\
VAR_11 = (s)[1];\
VAR_10 = (s)[2];\
}
#define RGB_OUT(d, VAR_10, VAR_11, VAR_12)\
{\
(d)[0] = VAR_12;\
(d)[1] = VAR_11;\
(d)[2] = VAR_10;\
}
#define BPP 3
FUNC_1(VAR_1)
#undef RGB_IN
#undef RGB_OUT
#undef BPP
#define RGB_IN(VAR_10, VAR_11, VAR_12, s)\
{\
VAR_10 = (s)[0];\
VAR_11 = (s)[1];\
VAR_12 = (s)[2];\
}
#define RGB_OUT(d, VAR_10, VAR_11, VAR_12)\
{\
(d)[0] = VAR_10;\
(d)[1] = VAR_11;\
(d)[2] = VAR_12;\
}
#define BPP 3
FUNC_1(VAR_2)
static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
int width, int height)
{
uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
unsigned int VAR_10, VAR_11, VAR_12;
d = dst->data[0];
y1_ptr = src->data[0];
cb_ptr = src->data[1];
cr_ptr = src->data[2];
for(;height > 0; height --) {
d1 = d;
for(VAR_3 = width; VAR_3 > 0; VAR_3--) {
YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
YUV_TO_RGB2_CCIR(VAR_10, VAR_11, VAR_12, y1_ptr[0]);
RGB_OUT(d1, VAR_10, VAR_11, VAR_12);
d1 += BPP;
y1_ptr++;
cb_ptr++;
cr_ptr++;
}
d += dst->linesize[0];
y1_ptr += src->linesize[0] - width;
cb_ptr += src->linesize[1] - width;
cr_ptr += src->linesize[2] - width;
}
}
| [
"FUNC_1(VAR_0)\n#undef RGB_IN\n#undef RGB_OUT\n#undef BPP\n#define RGB_IN(VAR_10, VAR_11, VAR_12, s)\\\n{\\",
"VAR_12 = (s)[0];\\",
"VAR_11 = (s)[1];\\",
"VAR_10 = (s)[2];\\",
"}",
"#define RGB_OUT(d, VAR_10, VAR_11, VAR_12)\\\n{\\",
"(d)[0] = VAR_12;\\",
"(d)[1] = VAR_11;\\",
"(d)[2] = VAR_10;\\",
"}",
"#define BPP 3\nFUNC_1(VAR_1)\n#undef RGB_IN\n#undef RGB_OUT\n#undef BPP\n#define RGB_IN(VAR_10, VAR_11, VAR_12, s)\\\n{\\",
"VAR_10 = (s)[0];\\",
"VAR_11 = (s)[1];\\",
"VAR_12 = (s)[2];\\",
"}",
"#define RGB_OUT(d, VAR_10, VAR_11, VAR_12)\\\n{\\",
"(d)[0] = VAR_10;\\",
"(d)[1] = VAR_11;\\",
"(d)[2] = VAR_12;\\",
"}",
"#define BPP 3\nFUNC_1(VAR_2)\nstatic void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,\nint width, int height)\n{",
"uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;",
"int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"uint8_t *cm = cropTbl + MAX_NEG_CROP;",
"unsigned int VAR_10, VAR_11, VAR_12;",
"d = dst->data[0];",
"y1_ptr = src->data[0];",
"cb_ptr = src->data[1];",
"cr_ptr = src->data[2];",
"for(;height > 0; height --) {",
"d1 = d;",
"for(VAR_3 = width; VAR_3 > 0; VAR_3--) {",
"YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);",
"YUV_TO_RGB2_CCIR(VAR_10, VAR_11, VAR_12, y1_ptr[0]);",
"RGB_OUT(d1, VAR_10, VAR_11, VAR_12);",
"d1 += BPP;",
"y1_ptr++;",
"cb_ptr++;",
"cr_ptr++;",
"}",
"d += dst->linesize[0];",
"y1_ptr += src->linesize[0] - width;",
"cb_ptr += src->linesize[1] - width;",
"cr_ptr += src->linesize[2] - width;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
5,
7,
9,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45,
49,
53,
55,
57,
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79,
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93,
97,
101,
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
]
] |
1,240 | int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
{
AudioFrame *new_frame;
AudioFrame *queue_end = afq->frame_queue;
/* find the end of the queue */
while (queue_end && queue_end->next)
queue_end = queue_end->next;
/* allocate new frame queue entry */
if (!(new_frame = av_malloc(sizeof(*new_frame))))
return AVERROR(ENOMEM);
/* get frame parameters */
new_frame->next = NULL;
new_frame->duration = f->nb_samples;
if (f->pts != AV_NOPTS_VALUE) {
new_frame->pts = av_rescale_q(f->pts,
afq->avctx->time_base,
(AVRational){ 1, afq->avctx->sample_rate });
afq->next_pts = new_frame->pts + new_frame->duration;
} else {
new_frame->pts = AV_NOPTS_VALUE;
afq->next_pts = AV_NOPTS_VALUE;
}
/* add new frame to the end of the queue */
if (!queue_end)
afq->frame_queue = new_frame;
else
queue_end->next = new_frame;
/* add frame sample count */
afq->remaining_samples += f->nb_samples;
#ifdef DEBUG
ff_af_queue_log_state(afq);
#endif
return 0;
}
| false | FFmpeg | 36583d23bdbe31e8845d3ca9162bce33fef6e48c | int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
{
AudioFrame *new_frame;
AudioFrame *queue_end = afq->frame_queue;
while (queue_end && queue_end->next)
queue_end = queue_end->next;
if (!(new_frame = av_malloc(sizeof(*new_frame))))
return AVERROR(ENOMEM);
new_frame->next = NULL;
new_frame->duration = f->nb_samples;
if (f->pts != AV_NOPTS_VALUE) {
new_frame->pts = av_rescale_q(f->pts,
afq->avctx->time_base,
(AVRational){ 1, afq->avctx->sample_rate });
afq->next_pts = new_frame->pts + new_frame->duration;
} else {
new_frame->pts = AV_NOPTS_VALUE;
afq->next_pts = AV_NOPTS_VALUE;
}
if (!queue_end)
afq->frame_queue = new_frame;
else
queue_end->next = new_frame;
afq->remaining_samples += f->nb_samples;
#ifdef DEBUG
ff_af_queue_log_state(afq);
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AudioFrameQueue *VAR_0, const AVFrame *VAR_1)
{
AudioFrame *new_frame;
AudioFrame *queue_end = VAR_0->frame_queue;
while (queue_end && queue_end->next)
queue_end = queue_end->next;
if (!(new_frame = av_malloc(sizeof(*new_frame))))
return AVERROR(ENOMEM);
new_frame->next = NULL;
new_frame->duration = VAR_1->nb_samples;
if (VAR_1->pts != AV_NOPTS_VALUE) {
new_frame->pts = av_rescale_q(VAR_1->pts,
VAR_0->avctx->time_base,
(AVRational){ 1, VAR_0->avctx->sample_rate });
VAR_0->next_pts = new_frame->pts + new_frame->duration;
} else {
new_frame->pts = AV_NOPTS_VALUE;
VAR_0->next_pts = AV_NOPTS_VALUE;
}
if (!queue_end)
VAR_0->frame_queue = new_frame;
else
queue_end->next = new_frame;
VAR_0->remaining_samples += VAR_1->nb_samples;
#ifdef DEBUG
ff_af_queue_log_state(VAR_0);
#endif
return 0;
}
| [
"int FUNC_0(AudioFrameQueue *VAR_0, const AVFrame *VAR_1)\n{",
"AudioFrame *new_frame;",
"AudioFrame *queue_end = VAR_0->frame_queue;",
"while (queue_end && queue_end->next)\nqueue_end = queue_end->next;",
"if (!(new_frame = av_malloc(sizeof(*new_frame))))\nreturn AVERROR(ENOMEM);",
"new_frame->next = NULL;",
"new_frame->duration = VAR_1->nb_samples;",
"if (VAR_1->pts != AV_NOPTS_VALUE) {",
"new_frame->pts = av_rescale_q(VAR_1->pts,\nVAR_0->avctx->time_base,\n(AVRational){ 1, VAR_0->avctx->sample_rate });",
"VAR_0->next_pts = new_frame->pts + new_frame->duration;",
"} else {",
"new_frame->pts = AV_NOPTS_VALUE;",
"VAR_0->next_pts = AV_NOPTS_VALUE;",
"}",
"if (!queue_end)\nVAR_0->frame_queue = new_frame;",
"else\nqueue_end->next = new_frame;",
"VAR_0->remaining_samples += VAR_1->nb_samples;",
"#ifdef DEBUG\nff_af_queue_log_state(VAR_0);",
"#endif\nreturn 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
],
[
13,
15
],
[
21,
23
],
[
29
],
[
31
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
55,
57
],
[
59,
61
],
[
67
],
[
71,
73
],
[
75,
79
],
[
81
]
] |
1,241 | yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum AVPixelFormat target)
{
const uint8_t * const d128 = dither_8x8_220[y & 7];
int i;
if (c->flags & SWS_ERROR_DIFFUSION) {
int err = 0;
int acc = 0;
for (i = 0; i < dstW; i +=2) {
int Y;
Y = ((buf0[i + 0] + 64) >> 7);
Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
c->dither_error[0][i] = err;
acc = 2*acc + (Y >= 128);
Y -= 220*(acc&1);
err = ((buf0[i + 1] + 64) >> 7);
err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
c->dither_error[0][i+1] = Y;
acc = 2*acc + (err >= 128);
err -= 220*(acc&1);
if ((i & 7) == 6)
output_pixel(*dest++, acc);
}
c->dither_error[0][i] = err;
} else {
for (i = 0; i < dstW; i += 8) {
int acc = 0;
accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
output_pixel(*dest++, acc);
}
}
}
| false | FFmpeg | 1e0e193240a8e47a980ac76b8b5af831b17b7928 | yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum AVPixelFormat target)
{
const uint8_t * const d128 = dither_8x8_220[y & 7];
int i;
if (c->flags & SWS_ERROR_DIFFUSION) {
int err = 0;
int acc = 0;
for (i = 0; i < dstW; i +=2) {
int Y;
Y = ((buf0[i + 0] + 64) >> 7);
Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
c->dither_error[0][i] = err;
acc = 2*acc + (Y >= 128);
Y -= 220*(acc&1);
err = ((buf0[i + 1] + 64) >> 7);
err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
c->dither_error[0][i+1] = Y;
acc = 2*acc + (err >= 128);
err -= 220*(acc&1);
if ((i & 7) == 6)
output_pixel(*dest++, acc);
}
c->dither_error[0][i] = err;
} else {
for (i = 0; i < dstW; i += 8) {
int acc = 0;
accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
output_pixel(*dest++, acc);
}
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,
const int16_t *VAR_2[2], const int16_t *VAR_3[2],
const int16_t *VAR_4, uint8_t *VAR_5, int VAR_6,
int VAR_7, int VAR_8, enum AVPixelFormat VAR_9)
{
const uint8_t * const VAR_10 = dither_8x8_220[VAR_8 & 7];
int VAR_11;
if (VAR_0->flags & SWS_ERROR_DIFFUSION) {
int VAR_12 = 0;
int VAR_15 = 0;
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11 +=2) {
int VAR_14;
VAR_14 = ((VAR_1[VAR_11 + 0] + 64) >> 7);
VAR_14 += (7*VAR_12 + 1*VAR_0->dither_error[0][VAR_11] + 5*VAR_0->dither_error[0][VAR_11+1] + 3*VAR_0->dither_error[0][VAR_11+2] + 8 - 256)>>4;
VAR_0->dither_error[0][VAR_11] = VAR_12;
VAR_15 = 2*VAR_15 + (VAR_14 >= 128);
VAR_14 -= 220*(VAR_15&1);
VAR_12 = ((VAR_1[VAR_11 + 1] + 64) >> 7);
VAR_12 += (7*VAR_14 + 1*VAR_0->dither_error[0][VAR_11+1] + 5*VAR_0->dither_error[0][VAR_11+2] + 3*VAR_0->dither_error[0][VAR_11+3] + 8 - 256)>>4;
VAR_0->dither_error[0][VAR_11+1] = VAR_14;
VAR_15 = 2*VAR_15 + (VAR_12 >= 128);
VAR_12 -= 220*(VAR_15&1);
if ((VAR_11 & 7) == 6)
output_pixel(*VAR_5++, VAR_15);
}
VAR_0->dither_error[0][VAR_11] = VAR_12;
} else {
for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11 += 8) {
int VAR_15 = 0;
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 0] + 64) >> 7) + VAR_10[0]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 1] + 64) >> 7) + VAR_10[1]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 2] + 64) >> 7) + VAR_10[2]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 3] + 64) >> 7) + VAR_10[3]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 4] + 64) >> 7) + VAR_10[4]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 5] + 64) >> 7) + VAR_10[5]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 6] + 64) >> 7) + VAR_10[6]);
accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 7] + 64) >> 7) + VAR_10[7]);
output_pixel(*VAR_5++, VAR_15);
}
}
}
| [
"FUNC_0(SwsContext *VAR_0, const int16_t *VAR_1,\nconst int16_t *VAR_2[2], const int16_t *VAR_3[2],\nconst int16_t *VAR_4, uint8_t *VAR_5, int VAR_6,\nint VAR_7, int VAR_8, enum AVPixelFormat VAR_9)\n{",
"const uint8_t * const VAR_10 = dither_8x8_220[VAR_8 & 7];",
"int VAR_11;",
"if (VAR_0->flags & SWS_ERROR_DIFFUSION) {",
"int VAR_12 = 0;",
"int VAR_15 = 0;",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11 +=2) {",
"int VAR_14;",
"VAR_14 = ((VAR_1[VAR_11 + 0] + 64) >> 7);",
"VAR_14 += (7*VAR_12 + 1*VAR_0->dither_error[0][VAR_11] + 5*VAR_0->dither_error[0][VAR_11+1] + 3*VAR_0->dither_error[0][VAR_11+2] + 8 - 256)>>4;",
"VAR_0->dither_error[0][VAR_11] = VAR_12;",
"VAR_15 = 2*VAR_15 + (VAR_14 >= 128);",
"VAR_14 -= 220*(VAR_15&1);",
"VAR_12 = ((VAR_1[VAR_11 + 1] + 64) >> 7);",
"VAR_12 += (7*VAR_14 + 1*VAR_0->dither_error[0][VAR_11+1] + 5*VAR_0->dither_error[0][VAR_11+2] + 3*VAR_0->dither_error[0][VAR_11+3] + 8 - 256)>>4;",
"VAR_0->dither_error[0][VAR_11+1] = VAR_14;",
"VAR_15 = 2*VAR_15 + (VAR_12 >= 128);",
"VAR_12 -= 220*(VAR_15&1);",
"if ((VAR_11 & 7) == 6)\noutput_pixel(*VAR_5++, VAR_15);",
"}",
"VAR_0->dither_error[0][VAR_11] = VAR_12;",
"} else {",
"for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11 += 8) {",
"int VAR_15 = 0;",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 0] + 64) >> 7) + VAR_10[0]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 1] + 64) >> 7) + VAR_10[1]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 2] + 64) >> 7) + VAR_10[2]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 3] + 64) >> 7) + VAR_10[3]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 4] + 64) >> 7) + VAR_10[4]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 5] + 64) >> 7) + VAR_10[5]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 6] + 64) >> 7) + VAR_10[6]);",
"accumulate_bit(VAR_15, ((VAR_1[VAR_11 + 7] + 64) >> 7) + VAR_10[7]);",
"output_pixel(*VAR_5++, VAR_15);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
]
] |
1,242 | static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
bool exception)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
/* we only queue EPOW events atm. */
if ((event_mask & EVENT_MASK_EPOW) == 0) {
return NULL;
}
QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
if (entry->exception != exception) {
continue;
}
/* EPOW and hotplug events are surfaced in the same manner */
if (entry->log_type == RTAS_LOG_TYPE_EPOW ||
entry->log_type == RTAS_LOG_TYPE_HOTPLUG) {
break;
}
}
if (entry) {
QTAILQ_REMOVE(&spapr->pending_events, entry, next);
}
return entry;
}
| false | qemu | ffbb1705a33df8e2fb12b24d96663d63b22eaf8b | static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
bool exception)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
if ((event_mask & EVENT_MASK_EPOW) == 0) {
return NULL;
}
QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
if (entry->exception != exception) {
continue;
}
if (entry->log_type == RTAS_LOG_TYPE_EPOW ||
entry->log_type == RTAS_LOG_TYPE_HOTPLUG) {
break;
}
}
if (entry) {
QTAILQ_REMOVE(&spapr->pending_events, entry, next);
}
return entry;
}
| {
"code": [],
"line_no": []
} | static sPAPREventLogEntry *FUNC_0(uint32_t event_mask,
bool exception)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
if ((event_mask & EVENT_MASK_EPOW) == 0) {
return NULL;
}
QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
if (entry->exception != exception) {
continue;
}
if (entry->log_type == RTAS_LOG_TYPE_EPOW ||
entry->log_type == RTAS_LOG_TYPE_HOTPLUG) {
break;
}
}
if (entry) {
QTAILQ_REMOVE(&spapr->pending_events, entry, next);
}
return entry;
}
| [
"static sPAPREventLogEntry *FUNC_0(uint32_t event_mask,\nbool exception)\n{",
"sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());",
"sPAPREventLogEntry *entry = NULL;",
"if ((event_mask & EVENT_MASK_EPOW) == 0) {",
"return NULL;",
"}",
"QTAILQ_FOREACH(entry, &spapr->pending_events, next) {",
"if (entry->exception != exception) {",
"continue;",
"}",
"if (entry->log_type == RTAS_LOG_TYPE_EPOW ||\nentry->log_type == RTAS_LOG_TYPE_HOTPLUG) {",
"break;",
"}",
"}",
"if (entry) {",
"QTAILQ_REMOVE(&spapr->pending_events, entry, next);",
"}",
"return entry;",
"}"
] | [
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
]
] |
1,243 | static int spapr_check_htab_fd(sPAPRMachineState *spapr)
{
int rc = 0;
if (spapr->htab_fd_stale) {
close(spapr->htab_fd);
spapr->htab_fd = kvmppc_get_htab_fd(false);
if (spapr->htab_fd < 0) {
error_report("Unable to open fd for reading hash table from KVM: "
"%s", strerror(errno));
rc = -1;
}
spapr->htab_fd_stale = false;
}
return rc;
}
| false | qemu | 715c54071a43ab978dc12b9da22a5016203ed284 | static int spapr_check_htab_fd(sPAPRMachineState *spapr)
{
int rc = 0;
if (spapr->htab_fd_stale) {
close(spapr->htab_fd);
spapr->htab_fd = kvmppc_get_htab_fd(false);
if (spapr->htab_fd < 0) {
error_report("Unable to open fd for reading hash table from KVM: "
"%s", strerror(errno));
rc = -1;
}
spapr->htab_fd_stale = false;
}
return rc;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(sPAPRMachineState *VAR_0)
{
int VAR_1 = 0;
if (VAR_0->htab_fd_stale) {
close(VAR_0->htab_fd);
VAR_0->htab_fd = kvmppc_get_htab_fd(false);
if (VAR_0->htab_fd < 0) {
error_report("Unable to open fd for reading hash table from KVM: "
"%s", strerror(errno));
VAR_1 = -1;
}
VAR_0->htab_fd_stale = false;
}
return VAR_1;
}
| [
"static int FUNC_0(sPAPRMachineState *VAR_0)\n{",
"int VAR_1 = 0;",
"if (VAR_0->htab_fd_stale) {",
"close(VAR_0->htab_fd);",
"VAR_0->htab_fd = kvmppc_get_htab_fd(false);",
"if (VAR_0->htab_fd < 0) {",
"error_report(\"Unable to open fd for reading hash table from KVM: \"\n\"%s\", strerror(errno));",
"VAR_1 = -1;",
"}",
"VAR_0->htab_fd_stale = false;",
"}",
"return VAR_1;",
"}"
] | [
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
]
] |
1,244 | static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
BDRVRawState *s = bs->opaque;
void *buf = NULL;
BlockDriver *drv;
QEMUIOVector local_qiov;
int ret;
if (s->has_size && (offset > s->size || bytes > (s->size - offset))) {
/* There's not enough space for the data. Don't write anything and just
* fail to prevent leaking out of the size specified in options. */
return -ENOSPC;
}
if (offset > UINT64_MAX - s->offset) {
ret = -EINVAL;
goto fail;
}
if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) {
/* Handling partial writes would be a pain - so we just
* require that guests have 512-byte request alignment if
* probing occurred */
QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512);
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512);
assert(offset == 0 && bytes >= BLOCK_PROBE_BUF_SIZE);
buf = qemu_try_blockalign(bs->file->bs, 512);
if (!buf) {
ret = -ENOMEM;
goto fail;
}
ret = qemu_iovec_to_buf(qiov, 0, buf, 512);
if (ret != 512) {
ret = -EINVAL;
goto fail;
}
drv = bdrv_probe_all(buf, 512, NULL);
if (drv != bs->drv) {
ret = -EPERM;
goto fail;
}
/* Use the checked buffer, a malicious guest might be overwriting its
* original buffer in the background. */
qemu_iovec_init(&local_qiov, qiov->niov + 1);
qemu_iovec_add(&local_qiov, buf, 512);
qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512);
qiov = &local_qiov;
}
offset += s->offset;
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
fail:
if (qiov == &local_qiov) {
qemu_iovec_destroy(&local_qiov);
}
qemu_vfree(buf);
return ret;
}
| false | qemu | 2e6fc7eb1a4af1b127df5f07b8bb28af891946fa | static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
BDRVRawState *s = bs->opaque;
void *buf = NULL;
BlockDriver *drv;
QEMUIOVector local_qiov;
int ret;
if (s->has_size && (offset > s->size || bytes > (s->size - offset))) {
return -ENOSPC;
}
if (offset > UINT64_MAX - s->offset) {
ret = -EINVAL;
goto fail;
}
if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) {
QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512);
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512);
assert(offset == 0 && bytes >= BLOCK_PROBE_BUF_SIZE);
buf = qemu_try_blockalign(bs->file->bs, 512);
if (!buf) {
ret = -ENOMEM;
goto fail;
}
ret = qemu_iovec_to_buf(qiov, 0, buf, 512);
if (ret != 512) {
ret = -EINVAL;
goto fail;
}
drv = bdrv_probe_all(buf, 512, NULL);
if (drv != bs->drv) {
ret = -EPERM;
goto fail;
}
qemu_iovec_init(&local_qiov, qiov->niov + 1);
qemu_iovec_add(&local_qiov, buf, 512);
qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512);
qiov = &local_qiov;
}
offset += s->offset;
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
fail:
if (qiov == &local_qiov) {
qemu_iovec_destroy(&local_qiov);
}
qemu_vfree(buf);
return ret;
}
| {
"code": [],
"line_no": []
} | static int VAR_0 raw_co_pwritev(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
BDRVRawState *s = bs->opaque;
void *buf = NULL;
BlockDriver *drv;
QEMUIOVector local_qiov;
int ret;
if (s->has_size && (offset > s->size || bytes > (s->size - offset))) {
return -ENOSPC;
}
if (offset > UINT64_MAX - s->offset) {
ret = -EINVAL;
goto fail;
}
if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) {
QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512);
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512);
assert(offset == 0 && bytes >= BLOCK_PROBE_BUF_SIZE);
buf = qemu_try_blockalign(bs->file->bs, 512);
if (!buf) {
ret = -ENOMEM;
goto fail;
}
ret = qemu_iovec_to_buf(qiov, 0, buf, 512);
if (ret != 512) {
ret = -EINVAL;
goto fail;
}
drv = bdrv_probe_all(buf, 512, NULL);
if (drv != bs->drv) {
ret = -EPERM;
goto fail;
}
qemu_iovec_init(&local_qiov, qiov->niov + 1);
qemu_iovec_add(&local_qiov, buf, 512);
qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512);
qiov = &local_qiov;
}
offset += s->offset;
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
fail:
if (qiov == &local_qiov) {
qemu_iovec_destroy(&local_qiov);
}
qemu_vfree(buf);
return ret;
}
| [
"static int VAR_0 raw_co_pwritev(BlockDriverState *bs, uint64_t offset,\nuint64_t bytes, QEMUIOVector *qiov,\nint flags)\n{",
"BDRVRawState *s = bs->opaque;",
"void *buf = NULL;",
"BlockDriver *drv;",
"QEMUIOVector local_qiov;",
"int ret;",
"if (s->has_size && (offset > s->size || bytes > (s->size - offset))) {",
"return -ENOSPC;",
"}",
"if (offset > UINT64_MAX - s->offset) {",
"ret = -EINVAL;",
"goto fail;",
"}",
"if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) {",
"QEMU_BUILD_BUG_ON(BLOCK_PROBE_BUF_SIZE != 512);",
"QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE != 512);",
"assert(offset == 0 && bytes >= BLOCK_PROBE_BUF_SIZE);",
"buf = qemu_try_blockalign(bs->file->bs, 512);",
"if (!buf) {",
"ret = -ENOMEM;",
"goto fail;",
"}",
"ret = qemu_iovec_to_buf(qiov, 0, buf, 512);",
"if (ret != 512) {",
"ret = -EINVAL;",
"goto fail;",
"}",
"drv = bdrv_probe_all(buf, 512, NULL);",
"if (drv != bs->drv) {",
"ret = -EPERM;",
"goto fail;",
"}",
"qemu_iovec_init(&local_qiov, qiov->niov + 1);",
"qemu_iovec_add(&local_qiov, buf, 512);",
"qemu_iovec_concat(&local_qiov, qiov, 512, qiov->size - 512);",
"qiov = &local_qiov;",
"}",
"offset += s->offset;",
"BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);",
"ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);",
"fail:\nif (qiov == &local_qiov) {",
"qemu_iovec_destroy(&local_qiov);",
"}",
"qemu_vfree(buf);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
115
],
[
117
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
]
] |
1,245 | void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
{
if (xen_enabled()) {
return xen_map_cache(addr, *size, 1);
} else {
RAMBlock *block;
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (addr - block->offset < block->length) {
if (addr - block->offset + *size > block->length)
*size = block->length - addr + block->offset;
return block->host + (addr - block->offset);
}
}
fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
abort();
*size = 0;
return NULL;
}
}
| false | qemu | 8ab934f93b5ad3d0af4ad419d2531235a75d672c | void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
{
if (xen_enabled()) {
return xen_map_cache(addr, *size, 1);
} else {
RAMBlock *block;
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (addr - block->offset < block->length) {
if (addr - block->offset + *size > block->length)
*size = block->length - addr + block->offset;
return block->host + (addr - block->offset);
}
}
fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
abort();
*size = 0;
return NULL;
}
}
| {
"code": [],
"line_no": []
} | void *FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t *VAR_1)
{
if (xen_enabled()) {
return xen_map_cache(VAR_0, *VAR_1, 1);
} else {
RAMBlock *block;
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (VAR_0 - block->offset < block->length) {
if (VAR_0 - block->offset + *VAR_1 > block->length)
*VAR_1 = block->length - VAR_0 + block->offset;
return block->host + (VAR_0 - block->offset);
}
}
fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)VAR_0);
abort();
*VAR_1 = 0;
return NULL;
}
}
| [
"void *FUNC_0(target_phys_addr_t VAR_0, target_phys_addr_t *VAR_1)\n{",
"if (xen_enabled()) {",
"return xen_map_cache(VAR_0, *VAR_1, 1);",
"} else {",
"RAMBlock *block;",
"QLIST_FOREACH(block, &ram_list.blocks, next) {",
"if (VAR_0 - block->offset < block->length) {",
"if (VAR_0 - block->offset + *VAR_1 > block->length)\n*VAR_1 = block->length - VAR_0 + block->offset;",
"return block->host + (VAR_0 - block->offset);",
"}",
"}",
"fprintf(stderr, \"Bad ram offset %\" PRIx64 \"\\n\", (uint64_t)VAR_0);",
"abort();",
"*VAR_1 = 0;",
"return NULL;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
1,246 | static void *qemu_dummy_cpu_thread_fn(void *arg)
{
#ifdef _WIN32
fprintf(stderr, "qtest is not supported under Windows\n");
exit(1);
#else
CPUState *cpu = arg;
sigset_t waitset;
int r;
qemu_mutex_lock_iothread();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->exception_index = -1;
cpu->can_do_io = 1;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
/* signal CPU creation */
cpu->created = true;
qemu_cond_signal(&qemu_cpu_cond);
current_cpu = cpu;
while (1) {
current_cpu = NULL;
qemu_mutex_unlock_iothread();
do {
int sig;
r = sigwait(&waitset, &sig);
} while (r == -1 && (errno == EAGAIN || errno == EINTR));
if (r == -1) {
perror("sigwait");
exit(1);
}
qemu_mutex_lock_iothread();
current_cpu = cpu;
qemu_wait_io_event_common(cpu);
}
return NULL;
#endif
}
| false | qemu | f9d8f6673591f30028e281e8ff6d5790adc2de83 | static void *qemu_dummy_cpu_thread_fn(void *arg)
{
#ifdef _WIN32
fprintf(stderr, "qtest is not supported under Windows\n");
exit(1);
#else
CPUState *cpu = arg;
sigset_t waitset;
int r;
qemu_mutex_lock_iothread();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->exception_index = -1;
cpu->can_do_io = 1;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
cpu->created = true;
qemu_cond_signal(&qemu_cpu_cond);
current_cpu = cpu;
while (1) {
current_cpu = NULL;
qemu_mutex_unlock_iothread();
do {
int sig;
r = sigwait(&waitset, &sig);
} while (r == -1 && (errno == EAGAIN || errno == EINTR));
if (r == -1) {
perror("sigwait");
exit(1);
}
qemu_mutex_lock_iothread();
current_cpu = cpu;
qemu_wait_io_event_common(cpu);
}
return NULL;
#endif
}
| {
"code": [],
"line_no": []
} | static void *FUNC_0(void *VAR_0)
{
#ifdef _WIN32
fprintf(stderr, "qtest is not supported under Windows\n");
exit(1);
#else
CPUState *cpu = VAR_0;
sigset_t waitset;
int VAR_1;
qemu_mutex_lock_iothread();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->exception_index = -1;
cpu->can_do_io = 1;
sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
cpu->created = true;
qemu_cond_signal(&qemu_cpu_cond);
current_cpu = cpu;
while (1) {
current_cpu = NULL;
qemu_mutex_unlock_iothread();
do {
int VAR_2;
VAR_1 = sigwait(&waitset, &VAR_2);
} while (VAR_1 == -1 && (errno == EAGAIN || errno == EINTR));
if (VAR_1 == -1) {
perror("sigwait");
exit(1);
}
qemu_mutex_lock_iothread();
current_cpu = cpu;
qemu_wait_io_event_common(cpu);
}
return NULL;
#endif
}
| [
"static void *FUNC_0(void *VAR_0)\n{",
"#ifdef _WIN32\nfprintf(stderr, \"qtest is not supported under Windows\\n\");",
"exit(1);",
"#else\nCPUState *cpu = VAR_0;",
"sigset_t waitset;",
"int VAR_1;",
"qemu_mutex_lock_iothread();",
"qemu_thread_get_self(cpu->thread);",
"cpu->thread_id = qemu_get_thread_id();",
"cpu->exception_index = -1;",
"cpu->can_do_io = 1;",
"sigemptyset(&waitset);",
"sigaddset(&waitset, SIG_IPI);",
"cpu->created = true;",
"qemu_cond_signal(&qemu_cpu_cond);",
"current_cpu = cpu;",
"while (1) {",
"current_cpu = NULL;",
"qemu_mutex_unlock_iothread();",
"do {",
"int VAR_2;",
"VAR_1 = sigwait(&waitset, &VAR_2);",
"} while (VAR_1 == -1 && (errno == EAGAIN || errno == EINTR));",
"if (VAR_1 == -1) {",
"perror(\"sigwait\");",
"exit(1);",
"}",
"qemu_mutex_lock_iothread();",
"current_cpu = cpu;",
"qemu_wait_io_event_common(cpu);",
"}",
"return NULL;",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83,
85
]
] |
1,247 | static void acpi_get_hotplug_info(AcpiMiscInfo *misc)
{
int i;
PCIBus *bus = find_i440fx();
if (!bus) {
/* Only PIIX supports ACPI hotplug */
memset(misc->slot_hotplug_enable, 0, sizeof misc->slot_hotplug_enable);
return;
}
memset(misc->slot_hotplug_enable, 0xff,
DIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));
for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
PCIDeviceClass *pc;
PCIDevice *pdev = bus->devices[i];
if (!pdev) {
continue;
}
pc = PCI_DEVICE_GET_CLASS(pdev);
if (pc->no_hotplug) {
int slot = PCI_SLOT(i);
clear_bit(slot, misc->slot_hotplug_enable);
}
}
}
| false | qemu | 99fd437dee468609de8218f0eb3b16621fb6a9c9 | static void acpi_get_hotplug_info(AcpiMiscInfo *misc)
{
int i;
PCIBus *bus = find_i440fx();
if (!bus) {
memset(misc->slot_hotplug_enable, 0, sizeof misc->slot_hotplug_enable);
return;
}
memset(misc->slot_hotplug_enable, 0xff,
DIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));
for (i = 0; i < ARRAY_SIZE(bus->devices); ++i) {
PCIDeviceClass *pc;
PCIDevice *pdev = bus->devices[i];
if (!pdev) {
continue;
}
pc = PCI_DEVICE_GET_CLASS(pdev);
if (pc->no_hotplug) {
int slot = PCI_SLOT(i);
clear_bit(slot, misc->slot_hotplug_enable);
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AcpiMiscInfo *VAR_0)
{
int VAR_1;
PCIBus *bus = find_i440fx();
if (!bus) {
memset(VAR_0->slot_hotplug_enable, 0, sizeof VAR_0->slot_hotplug_enable);
return;
}
memset(VAR_0->slot_hotplug_enable, 0xff,
DIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));
for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(bus->devices); ++VAR_1) {
PCIDeviceClass *pc;
PCIDevice *pdev = bus->devices[VAR_1];
if (!pdev) {
continue;
}
pc = PCI_DEVICE_GET_CLASS(pdev);
if (pc->no_hotplug) {
int slot = PCI_SLOT(VAR_1);
clear_bit(slot, VAR_0->slot_hotplug_enable);
}
}
}
| [
"static void FUNC_0(AcpiMiscInfo *VAR_0)\n{",
"int VAR_1;",
"PCIBus *bus = find_i440fx();",
"if (!bus) {",
"memset(VAR_0->slot_hotplug_enable, 0, sizeof VAR_0->slot_hotplug_enable);",
"return;",
"}",
"memset(VAR_0->slot_hotplug_enable, 0xff,\nDIV_ROUND_UP(PCI_SLOT_MAX, BITS_PER_BYTE));",
"for (VAR_1 = 0; VAR_1 < ARRAY_SIZE(bus->devices); ++VAR_1) {",
"PCIDeviceClass *pc;",
"PCIDevice *pdev = bus->devices[VAR_1];",
"if (!pdev) {",
"continue;",
"}",
"pc = PCI_DEVICE_GET_CLASS(pdev);",
"if (pc->no_hotplug) {",
"int slot = PCI_SLOT(VAR_1);",
"clear_bit(slot, VAR_0->slot_hotplug_enable);",
"}",
"}",
"}"
] | [
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
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
1,248 | static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
{
int ret = 0, offset, cpus_offset;
CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = spapr_vcpu_id(cpu);
int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
if ((index % smt) != 0) {
continue;
}
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
cpus_offset = fdt_path_offset(fdt, "/cpus");
if (cpus_offset < 0) {
cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
if (cpus_offset < 0) {
return cpus_offset;
}
}
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
if (offset < 0) {
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
if (offset < 0) {
return offset;
}
}
ret = fdt_setprop(fdt, offset, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (ret < 0) {
return ret;
}
if (nb_numa_nodes > 1) {
ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu);
if (ret < 0) {
return ret;
}
}
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt);
if (ret < 0) {
return ret;
}
spapr_populate_pa_features(cpu, fdt, offset,
spapr->cas_legacy_guest_workaround);
}
return ret;
}
| false | qemu | ee76a09fc72cfbfab2bb5529320ef7e460adffd8 | static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
{
int ret = 0, offset, cpus_offset;
CPUState *cs;
char cpu_model[32];
int smt = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = spapr_vcpu_id(cpu);
int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
if ((index % smt) != 0) {
continue;
}
snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
cpus_offset = fdt_path_offset(fdt, "/cpus");
if (cpus_offset < 0) {
cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
if (cpus_offset < 0) {
return cpus_offset;
}
}
offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
if (offset < 0) {
offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
if (offset < 0) {
return offset;
}
}
ret = fdt_setprop(fdt, offset, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (ret < 0) {
return ret;
}
if (nb_numa_nodes > 1) {
ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu);
if (ret < 0) {
return ret;
}
}
ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt);
if (ret < 0) {
return ret;
}
spapr_populate_pa_features(cpu, fdt, offset,
spapr->cas_legacy_guest_workaround);
}
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, sPAPRMachineState *VAR_1)
{
int VAR_2 = 0, VAR_3, VAR_4;
CPUState *cs;
char VAR_5[32];
int VAR_6 = kvmppc_smt_threads();
uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)};
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int index = spapr_vcpu_id(cpu);
int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
if ((index % VAR_6) != 0) {
continue;
}
snprintf(VAR_5, 32, "%s@%x", dc->fw_name, index);
VAR_4 = fdt_path_offset(VAR_0, "/cpus");
if (VAR_4 < 0) {
VAR_4 = fdt_add_subnode(VAR_0, 0, "cpus");
if (VAR_4 < 0) {
return VAR_4;
}
}
VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5);
if (VAR_3 < 0) {
VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5);
if (VAR_3 < 0) {
return VAR_3;
}
}
VAR_2 = fdt_setprop(VAR_0, VAR_3, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop));
if (VAR_2 < 0) {
return VAR_2;
}
if (nb_numa_nodes > 1) {
VAR_2 = spapr_fixup_cpu_numa_dt(VAR_0, VAR_3, cpu);
if (VAR_2 < 0) {
return VAR_2;
}
}
VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu, compat_smt);
if (VAR_2 < 0) {
return VAR_2;
}
spapr_populate_pa_features(cpu, VAR_0, VAR_3,
VAR_1->cas_legacy_guest_workaround);
}
return VAR_2;
}
| [
"static int FUNC_0(void *VAR_0, sPAPRMachineState *VAR_1)\n{",
"int VAR_2 = 0, VAR_3, VAR_4;",
"CPUState *cs;",
"char VAR_5[32];",
"int VAR_6 = kvmppc_smt_threads();",
"uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)};",
"CPU_FOREACH(cs) {",
"PowerPCCPU *cpu = POWERPC_CPU(cs);",
"DeviceClass *dc = DEVICE_GET_CLASS(cs);",
"int index = spapr_vcpu_id(cpu);",
"int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));",
"if ((index % VAR_6) != 0) {",
"continue;",
"}",
"snprintf(VAR_5, 32, \"%s@%x\", dc->fw_name, index);",
"VAR_4 = fdt_path_offset(VAR_0, \"/cpus\");",
"if (VAR_4 < 0) {",
"VAR_4 = fdt_add_subnode(VAR_0, 0, \"cpus\");",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"}",
"VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5);",
"if (VAR_3 < 0) {",
"VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5);",
"if (VAR_3 < 0) {",
"return VAR_3;",
"}",
"}",
"VAR_2 = fdt_setprop(VAR_0, VAR_3, \"ibm,pft-size\",\npft_size_prop, sizeof(pft_size_prop));",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"if (nb_numa_nodes > 1) {",
"VAR_2 = spapr_fixup_cpu_numa_dt(VAR_0, VAR_3, cpu);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"}",
"VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu, compat_smt);",
"if (VAR_2 < 0) {",
"return VAR_2;",
"}",
"spapr_populate_pa_features(cpu, VAR_0, VAR_3,\nVAR_1->cas_legacy_guest_workaround);",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107,
109
],
[
111
],
[
113
],
[
115
]
] |
1,250 | void subch_device_save(SubchDev *s, QEMUFile *f)
{
int i;
qemu_put_byte(f, s->cssid);
qemu_put_byte(f, s->ssid);
qemu_put_be16(f, s->schid);
qemu_put_be16(f, s->devno);
qemu_put_byte(f, s->thinint_active);
/* SCHIB */
/* PMCW */
qemu_put_be32(f, s->curr_status.pmcw.intparm);
qemu_put_be16(f, s->curr_status.pmcw.flags);
qemu_put_be16(f, s->curr_status.pmcw.devno);
qemu_put_byte(f, s->curr_status.pmcw.lpm);
qemu_put_byte(f, s->curr_status.pmcw.pnom);
qemu_put_byte(f, s->curr_status.pmcw.lpum);
qemu_put_byte(f, s->curr_status.pmcw.pim);
qemu_put_be16(f, s->curr_status.pmcw.mbi);
qemu_put_byte(f, s->curr_status.pmcw.pom);
qemu_put_byte(f, s->curr_status.pmcw.pam);
qemu_put_buffer(f, s->curr_status.pmcw.chpid, 8);
qemu_put_be32(f, s->curr_status.pmcw.chars);
/* SCSW */
qemu_put_be16(f, s->curr_status.scsw.flags);
qemu_put_be16(f, s->curr_status.scsw.ctrl);
qemu_put_be32(f, s->curr_status.scsw.cpa);
qemu_put_byte(f, s->curr_status.scsw.dstat);
qemu_put_byte(f, s->curr_status.scsw.cstat);
qemu_put_be16(f, s->curr_status.scsw.count);
qemu_put_be64(f, s->curr_status.mba);
qemu_put_buffer(f, s->curr_status.mda, 4);
/* end SCHIB */
qemu_put_buffer(f, s->sense_data, 32);
qemu_put_be64(f, s->channel_prog);
/* last cmd */
qemu_put_byte(f, s->last_cmd.cmd_code);
qemu_put_byte(f, s->last_cmd.flags);
qemu_put_be16(f, s->last_cmd.count);
qemu_put_be32(f, s->last_cmd.cda);
qemu_put_byte(f, s->last_cmd_valid);
qemu_put_byte(f, s->id.reserved);
qemu_put_be16(f, s->id.cu_type);
qemu_put_byte(f, s->id.cu_model);
qemu_put_be16(f, s->id.dev_type);
qemu_put_byte(f, s->id.dev_model);
qemu_put_byte(f, s->id.unused);
for (i = 0; i < ARRAY_SIZE(s->id.ciw); i++) {
qemu_put_byte(f, s->id.ciw[i].type);
qemu_put_byte(f, s->id.ciw[i].command);
qemu_put_be16(f, s->id.ciw[i].count);
}
qemu_put_byte(f, s->ccw_fmt_1);
qemu_put_byte(f, s->ccw_no_data_cnt);
}
| false | qemu | 517ff12c7d000fa1f5b1e989b22fb86a286f9cc2 | void subch_device_save(SubchDev *s, QEMUFile *f)
{
int i;
qemu_put_byte(f, s->cssid);
qemu_put_byte(f, s->ssid);
qemu_put_be16(f, s->schid);
qemu_put_be16(f, s->devno);
qemu_put_byte(f, s->thinint_active);
qemu_put_be32(f, s->curr_status.pmcw.intparm);
qemu_put_be16(f, s->curr_status.pmcw.flags);
qemu_put_be16(f, s->curr_status.pmcw.devno);
qemu_put_byte(f, s->curr_status.pmcw.lpm);
qemu_put_byte(f, s->curr_status.pmcw.pnom);
qemu_put_byte(f, s->curr_status.pmcw.lpum);
qemu_put_byte(f, s->curr_status.pmcw.pim);
qemu_put_be16(f, s->curr_status.pmcw.mbi);
qemu_put_byte(f, s->curr_status.pmcw.pom);
qemu_put_byte(f, s->curr_status.pmcw.pam);
qemu_put_buffer(f, s->curr_status.pmcw.chpid, 8);
qemu_put_be32(f, s->curr_status.pmcw.chars);
qemu_put_be16(f, s->curr_status.scsw.flags);
qemu_put_be16(f, s->curr_status.scsw.ctrl);
qemu_put_be32(f, s->curr_status.scsw.cpa);
qemu_put_byte(f, s->curr_status.scsw.dstat);
qemu_put_byte(f, s->curr_status.scsw.cstat);
qemu_put_be16(f, s->curr_status.scsw.count);
qemu_put_be64(f, s->curr_status.mba);
qemu_put_buffer(f, s->curr_status.mda, 4);
qemu_put_buffer(f, s->sense_data, 32);
qemu_put_be64(f, s->channel_prog);
qemu_put_byte(f, s->last_cmd.cmd_code);
qemu_put_byte(f, s->last_cmd.flags);
qemu_put_be16(f, s->last_cmd.count);
qemu_put_be32(f, s->last_cmd.cda);
qemu_put_byte(f, s->last_cmd_valid);
qemu_put_byte(f, s->id.reserved);
qemu_put_be16(f, s->id.cu_type);
qemu_put_byte(f, s->id.cu_model);
qemu_put_be16(f, s->id.dev_type);
qemu_put_byte(f, s->id.dev_model);
qemu_put_byte(f, s->id.unused);
for (i = 0; i < ARRAY_SIZE(s->id.ciw); i++) {
qemu_put_byte(f, s->id.ciw[i].type);
qemu_put_byte(f, s->id.ciw[i].command);
qemu_put_be16(f, s->id.ciw[i].count);
}
qemu_put_byte(f, s->ccw_fmt_1);
qemu_put_byte(f, s->ccw_no_data_cnt);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(SubchDev *VAR_0, QEMUFile *VAR_1)
{
int VAR_2;
qemu_put_byte(VAR_1, VAR_0->cssid);
qemu_put_byte(VAR_1, VAR_0->ssid);
qemu_put_be16(VAR_1, VAR_0->schid);
qemu_put_be16(VAR_1, VAR_0->devno);
qemu_put_byte(VAR_1, VAR_0->thinint_active);
qemu_put_be32(VAR_1, VAR_0->curr_status.pmcw.intparm);
qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.flags);
qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.devno);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.lpm);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pnom);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.lpum);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pim);
qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.mbi);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pom);
qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pam);
qemu_put_buffer(VAR_1, VAR_0->curr_status.pmcw.chpid, 8);
qemu_put_be32(VAR_1, VAR_0->curr_status.pmcw.chars);
qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.flags);
qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.ctrl);
qemu_put_be32(VAR_1, VAR_0->curr_status.scsw.cpa);
qemu_put_byte(VAR_1, VAR_0->curr_status.scsw.dstat);
qemu_put_byte(VAR_1, VAR_0->curr_status.scsw.cstat);
qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.count);
qemu_put_be64(VAR_1, VAR_0->curr_status.mba);
qemu_put_buffer(VAR_1, VAR_0->curr_status.mda, 4);
qemu_put_buffer(VAR_1, VAR_0->sense_data, 32);
qemu_put_be64(VAR_1, VAR_0->channel_prog);
qemu_put_byte(VAR_1, VAR_0->last_cmd.cmd_code);
qemu_put_byte(VAR_1, VAR_0->last_cmd.flags);
qemu_put_be16(VAR_1, VAR_0->last_cmd.count);
qemu_put_be32(VAR_1, VAR_0->last_cmd.cda);
qemu_put_byte(VAR_1, VAR_0->last_cmd_valid);
qemu_put_byte(VAR_1, VAR_0->id.reserved);
qemu_put_be16(VAR_1, VAR_0->id.cu_type);
qemu_put_byte(VAR_1, VAR_0->id.cu_model);
qemu_put_be16(VAR_1, VAR_0->id.dev_type);
qemu_put_byte(VAR_1, VAR_0->id.dev_model);
qemu_put_byte(VAR_1, VAR_0->id.unused);
for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_0->id.ciw); VAR_2++) {
qemu_put_byte(VAR_1, VAR_0->id.ciw[VAR_2].type);
qemu_put_byte(VAR_1, VAR_0->id.ciw[VAR_2].command);
qemu_put_be16(VAR_1, VAR_0->id.ciw[VAR_2].count);
}
qemu_put_byte(VAR_1, VAR_0->ccw_fmt_1);
qemu_put_byte(VAR_1, VAR_0->ccw_no_data_cnt);
}
| [
"void FUNC_0(SubchDev *VAR_0, QEMUFile *VAR_1)\n{",
"int VAR_2;",
"qemu_put_byte(VAR_1, VAR_0->cssid);",
"qemu_put_byte(VAR_1, VAR_0->ssid);",
"qemu_put_be16(VAR_1, VAR_0->schid);",
"qemu_put_be16(VAR_1, VAR_0->devno);",
"qemu_put_byte(VAR_1, VAR_0->thinint_active);",
"qemu_put_be32(VAR_1, VAR_0->curr_status.pmcw.intparm);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.flags);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.devno);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.lpm);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pnom);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.lpum);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pim);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.pmcw.mbi);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pom);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.pmcw.pam);",
"qemu_put_buffer(VAR_1, VAR_0->curr_status.pmcw.chpid, 8);",
"qemu_put_be32(VAR_1, VAR_0->curr_status.pmcw.chars);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.flags);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.ctrl);",
"qemu_put_be32(VAR_1, VAR_0->curr_status.scsw.cpa);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.scsw.dstat);",
"qemu_put_byte(VAR_1, VAR_0->curr_status.scsw.cstat);",
"qemu_put_be16(VAR_1, VAR_0->curr_status.scsw.count);",
"qemu_put_be64(VAR_1, VAR_0->curr_status.mba);",
"qemu_put_buffer(VAR_1, VAR_0->curr_status.mda, 4);",
"qemu_put_buffer(VAR_1, VAR_0->sense_data, 32);",
"qemu_put_be64(VAR_1, VAR_0->channel_prog);",
"qemu_put_byte(VAR_1, VAR_0->last_cmd.cmd_code);",
"qemu_put_byte(VAR_1, VAR_0->last_cmd.flags);",
"qemu_put_be16(VAR_1, VAR_0->last_cmd.count);",
"qemu_put_be32(VAR_1, VAR_0->last_cmd.cda);",
"qemu_put_byte(VAR_1, VAR_0->last_cmd_valid);",
"qemu_put_byte(VAR_1, VAR_0->id.reserved);",
"qemu_put_be16(VAR_1, VAR_0->id.cu_type);",
"qemu_put_byte(VAR_1, VAR_0->id.cu_model);",
"qemu_put_be16(VAR_1, VAR_0->id.dev_type);",
"qemu_put_byte(VAR_1, VAR_0->id.dev_model);",
"qemu_put_byte(VAR_1, VAR_0->id.unused);",
"for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(VAR_0->id.ciw); VAR_2++) {",
"qemu_put_byte(VAR_1, VAR_0->id.ciw[VAR_2].type);",
"qemu_put_byte(VAR_1, VAR_0->id.ciw[VAR_2].command);",
"qemu_put_be16(VAR_1, VAR_0->id.ciw[VAR_2].count);",
"}",
"qemu_put_byte(VAR_1, VAR_0->ccw_fmt_1);",
"qemu_put_byte(VAR_1, VAR_0->ccw_no_data_cnt);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
]
] |
1,251 | static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
VirtQueue *vq,
EventNotifierHandler *handler,
int n)
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSIVring *r;
int rc;
/* Set up virtqueue notify */
rc = k->set_host_notifier(qbus->parent, n, true);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
rc);
s->dataplane_fenced = true;
return NULL;
}
r = g_new(VirtIOSCSIVring, 1);
r->host_notifier = *virtio_queue_get_host_notifier(vq);
r->guest_notifier = *virtio_queue_get_guest_notifier(vq);
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
handler);
r->parent = s;
if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {
fprintf(stderr, "virtio-scsi: VRing setup failed\n");
goto fail_vring;
}
return r;
fail_vring:
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
NULL);
k->set_host_notifier(qbus->parent, n, false);
g_free(r);
return NULL;
}
| false | qemu | 3a1e8074d74ad2acbcedf28d35aebedc3573f19e | static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
VirtQueue *vq,
EventNotifierHandler *handler,
int n)
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSIVring *r;
int rc;
rc = k->set_host_notifier(qbus->parent, n, true);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
rc);
s->dataplane_fenced = true;
return NULL;
}
r = g_new(VirtIOSCSIVring, 1);
r->host_notifier = *virtio_queue_get_host_notifier(vq);
r->guest_notifier = *virtio_queue_get_guest_notifier(vq);
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
handler);
r->parent = s;
if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {
fprintf(stderr, "virtio-scsi: VRing setup failed\n");
goto fail_vring;
}
return r;
fail_vring:
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
NULL);
k->set_host_notifier(qbus->parent, n, false);
g_free(r);
return NULL;
}
| {
"code": [],
"line_no": []
} | static VirtIOSCSIVring *FUNC_0(VirtIOSCSI *s,
VirtQueue *vq,
EventNotifierHandler *handler,
int n)
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSIVring *r;
int VAR_0;
VAR_0 = k->set_host_notifier(qbus->parent, n, true);
if (VAR_0 != 0) {
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
VAR_0);
s->dataplane_fenced = true;
return NULL;
}
r = g_new(VirtIOSCSIVring, 1);
r->host_notifier = *virtio_queue_get_host_notifier(vq);
r->guest_notifier = *virtio_queue_get_guest_notifier(vq);
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
handler);
r->parent = s;
if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {
fprintf(stderr, "virtio-scsi: VRing setup failed\n");
goto fail_vring;
}
return r;
fail_vring:
aio_set_event_notifier(s->ctx, &r->host_notifier, false,
NULL);
k->set_host_notifier(qbus->parent, n, false);
g_free(r);
return NULL;
}
| [
"static VirtIOSCSIVring *FUNC_0(VirtIOSCSI *s,\nVirtQueue *vq,\nEventNotifierHandler *handler,\nint n)\n{",
"BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));",
"VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);",
"VirtIOSCSIVring *r;",
"int VAR_0;",
"VAR_0 = k->set_host_notifier(qbus->parent, n, true);",
"if (VAR_0 != 0) {",
"fprintf(stderr, \"virtio-scsi: Failed to set host notifier (%d)\\n\",\nVAR_0);",
"s->dataplane_fenced = true;",
"return NULL;",
"}",
"r = g_new(VirtIOSCSIVring, 1);",
"r->host_notifier = *virtio_queue_get_host_notifier(vq);",
"r->guest_notifier = *virtio_queue_get_guest_notifier(vq);",
"aio_set_event_notifier(s->ctx, &r->host_notifier, false,\nhandler);",
"r->parent = s;",
"if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {",
"fprintf(stderr, \"virtio-scsi: VRing setup failed\\n\");",
"goto fail_vring;",
"}",
"return r;",
"fail_vring:\naio_set_event_notifier(s->ctx, &r->host_notifier, false,\nNULL);",
"k->set_host_notifier(qbus->parent, n, false);",
"g_free(r);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45,
47
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
67,
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
]
] |
1,252 | static void do_change_block(const char *device, const char *filename, const char *fmt)
{
BlockDriverState *bs;
BlockDriver *drv = NULL;
bs = bdrv_find(device);
if (!bs) {
term_printf("device not found\n");
return;
}
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
term_printf("invalid format %s\n", fmt);
return;
}
}
if (eject_device(bs, 0) < 0)
return;
bdrv_open2(bs, filename, 0, drv);
qemu_key_check(bs, filename);
}
| false | qemu | c0f4ce7751f0b9a9a7815f931a09a6c3de127cee | static void do_change_block(const char *device, const char *filename, const char *fmt)
{
BlockDriverState *bs;
BlockDriver *drv = NULL;
bs = bdrv_find(device);
if (!bs) {
term_printf("device not found\n");
return;
}
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
term_printf("invalid format %s\n", fmt);
return;
}
}
if (eject_device(bs, 0) < 0)
return;
bdrv_open2(bs, filename, 0, drv);
qemu_key_check(bs, filename);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0, const char *VAR_1, const char *VAR_2)
{
BlockDriverState *bs;
BlockDriver *drv = NULL;
bs = bdrv_find(VAR_0);
if (!bs) {
term_printf("VAR_0 not found\n");
return;
}
if (VAR_2) {
drv = bdrv_find_format(VAR_2);
if (!drv) {
term_printf("invalid format %s\n", VAR_2);
return;
}
}
if (eject_device(bs, 0) < 0)
return;
bdrv_open2(bs, VAR_1, 0, drv);
qemu_key_check(bs, VAR_1);
}
| [
"static void FUNC_0(const char *VAR_0, const char *VAR_1, const char *VAR_2)\n{",
"BlockDriverState *bs;",
"BlockDriver *drv = NULL;",
"bs = bdrv_find(VAR_0);",
"if (!bs) {",
"term_printf(\"VAR_0 not found\\n\");",
"return;",
"}",
"if (VAR_2) {",
"drv = bdrv_find_format(VAR_2);",
"if (!drv) {",
"term_printf(\"invalid format %s\\n\", VAR_2);",
"return;",
"}",
"}",
"if (eject_device(bs, 0) < 0)\nreturn;",
"bdrv_open2(bs, VAR_1, 0, drv);",
"qemu_key_check(bs, VAR_1);",
"}"
] | [
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
]
] |
1,253 | static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
uint32_t *ext_features,
uint32_t *ext2_features,
uint32_t *ext3_features,
uint32_t *kvm_features,
uint32_t *svm_features)
{
if (!lookup_feature(features, flagname, NULL, feature_name) &&
!lookup_feature(ext_features, flagname, NULL, ext_feature_name) &&
!lookup_feature(ext2_features, flagname, NULL, ext2_feature_name) &&
!lookup_feature(ext3_features, flagname, NULL, ext3_feature_name) &&
!lookup_feature(kvm_features, flagname, NULL, kvm_feature_name) &&
!lookup_feature(svm_features, flagname, NULL, svm_feature_name))
fprintf(stderr, "CPU feature %s not found\n", flagname);
}
| false | qemu | a9321a4d49d65d29c2926a51aedc5b91a01f3591 | static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
uint32_t *ext_features,
uint32_t *ext2_features,
uint32_t *ext3_features,
uint32_t *kvm_features,
uint32_t *svm_features)
{
if (!lookup_feature(features, flagname, NULL, feature_name) &&
!lookup_feature(ext_features, flagname, NULL, ext_feature_name) &&
!lookup_feature(ext2_features, flagname, NULL, ext2_feature_name) &&
!lookup_feature(ext3_features, flagname, NULL, ext3_feature_name) &&
!lookup_feature(kvm_features, flagname, NULL, kvm_feature_name) &&
!lookup_feature(svm_features, flagname, NULL, svm_feature_name))
fprintf(stderr, "CPU feature %s not found\n", flagname);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const char *VAR_0, uint32_t *VAR_1,
uint32_t *VAR_2,
uint32_t *VAR_3,
uint32_t *VAR_4,
uint32_t *VAR_5,
uint32_t *VAR_6)
{
if (!lookup_feature(VAR_1, VAR_0, NULL, feature_name) &&
!lookup_feature(VAR_2, VAR_0, NULL, ext_feature_name) &&
!lookup_feature(VAR_3, VAR_0, NULL, ext2_feature_name) &&
!lookup_feature(VAR_4, VAR_0, NULL, ext3_feature_name) &&
!lookup_feature(VAR_5, VAR_0, NULL, kvm_feature_name) &&
!lookup_feature(VAR_6, VAR_0, NULL, svm_feature_name))
fprintf(stderr, "CPU feature %s not found\n", VAR_0);
}
| [
"static void FUNC_0(const char *VAR_0, uint32_t *VAR_1,\nuint32_t *VAR_2,\nuint32_t *VAR_3,\nuint32_t *VAR_4,\nuint32_t *VAR_5,\nuint32_t *VAR_6)\n{",
"if (!lookup_feature(VAR_1, VAR_0, NULL, feature_name) &&\n!lookup_feature(VAR_2, VAR_0, NULL, ext_feature_name) &&\n!lookup_feature(VAR_3, VAR_0, NULL, ext2_feature_name) &&\n!lookup_feature(VAR_4, VAR_0, NULL, ext3_feature_name) &&\n!lookup_feature(VAR_5, VAR_0, NULL, kvm_feature_name) &&\n!lookup_feature(VAR_6, VAR_0, NULL, svm_feature_name))\nfprintf(stderr, \"CPU feature %s not found\\n\", VAR_0);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15,
17,
19,
21,
23,
25,
27
],
[
29
]
] |
1,254 | static void test_machine(const void *data)
{
const testdef_t *test = data;
char tmpname[] = "/tmp/qtest-boot-serial-XXXXXX";
int fd;
fd = mkstemp(tmpname);
g_assert(fd != -1);
/*
* Make sure that this test uses tcg if available: It is used as a
* fast-enough smoketest for that.
*/
global_qtest = qtest_startf("-M %s,accel=tcg:kvm "
"-chardev file,id=serial0,path=%s "
"-no-shutdown -serial chardev:serial0 %s",
test->machine, tmpname, test->extra);
unlink(tmpname);
check_guest_output(test, fd);
qtest_quit(global_qtest);
close(fd);
}
| false | qemu | e12c08d3b67c4f4e5a16ee815188fc13632530ce | static void test_machine(const void *data)
{
const testdef_t *test = data;
char tmpname[] = "/tmp/qtest-boot-serial-XXXXXX";
int fd;
fd = mkstemp(tmpname);
g_assert(fd != -1);
global_qtest = qtest_startf("-M %s,accel=tcg:kvm "
"-chardev file,id=serial0,path=%s "
"-no-shutdown -serial chardev:serial0 %s",
test->machine, tmpname, test->extra);
unlink(tmpname);
check_guest_output(test, fd);
qtest_quit(global_qtest);
close(fd);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(const void *VAR_0)
{
const testdef_t *VAR_1 = VAR_0;
char VAR_2[] = "/tmp/qtest-boot-serial-XXXXXX";
int VAR_3;
VAR_3 = mkstemp(VAR_2);
g_assert(VAR_3 != -1);
global_qtest = qtest_startf("-M %s,accel=tcg:kvm "
"-chardev file,id=serial0,path=%s "
"-no-shutdown -serial chardev:serial0 %s",
VAR_1->machine, VAR_2, VAR_1->extra);
unlink(VAR_2);
check_guest_output(VAR_1, VAR_3);
qtest_quit(global_qtest);
close(VAR_3);
}
| [
"static void FUNC_0(const void *VAR_0)\n{",
"const testdef_t *VAR_1 = VAR_0;",
"char VAR_2[] = \"/tmp/qtest-boot-serial-XXXXXX\";",
"int VAR_3;",
"VAR_3 = mkstemp(VAR_2);",
"g_assert(VAR_3 != -1);",
"global_qtest = qtest_startf(\"-M %s,accel=tcg:kvm \"\n\"-chardev file,id=serial0,path=%s \"\n\"-no-shutdown -serial chardev:serial0 %s\",\nVAR_1->machine, VAR_2, VAR_1->extra);",
"unlink(VAR_2);",
"check_guest_output(VAR_1, VAR_3);",
"qtest_quit(global_qtest);",
"close(VAR_3);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
27,
29,
31,
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
1,255 | START_TEST(qstring_from_substr_test)
{
QString *qs;
qs = qstring_from_substr("virtualization", 3, 9);
fail_unless(qs != NULL);
fail_unless(strcmp(qstring_get_str(qs), "tualiza") == 0);
QDECREF(qs);
}
| false | qemu | 0ac7cc2af500b948510f2481c22e84a57b0a2447 | START_TEST(qstring_from_substr_test)
{
QString *qs;
qs = qstring_from_substr("virtualization", 3, 9);
fail_unless(qs != NULL);
fail_unless(strcmp(qstring_get_str(qs), "tualiza") == 0);
QDECREF(qs);
}
| {
"code": [],
"line_no": []
} | FUNC_0(VAR_0)
{
QString *qs;
qs = qstring_from_substr("virtualization", 3, 9);
fail_unless(qs != NULL);
fail_unless(strcmp(qstring_get_str(qs), "tualiza") == 0);
QDECREF(qs);
}
| [
"FUNC_0(VAR_0)\n{",
"QString *qs;",
"qs = qstring_from_substr(\"virtualization\", 3, 9);",
"fail_unless(qs != NULL);",
"fail_unless(strcmp(qstring_get_str(qs), \"tualiza\") == 0);",
"QDECREF(qs);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
1,256 | void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
{
qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
}
| false | qemu | 7a7aae21ccab06606cee9aba846d2e30cb616763 | void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
{
qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void *VAR_2)
{
qdev_prop_set(VAR_0, VAR_1, &VAR_2, PROP_TYPE_PTR);
}
| [
"void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void *VAR_2)\n{",
"qdev_prop_set(VAR_0, VAR_1, &VAR_2, PROP_TYPE_PTR);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,257 | static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
{
/* This always zero-extends and writes to a full 128 bit wide vector */
TCGv_i64 tmplo = tcg_temp_new_i64();
TCGv_i64 tmphi;
if (size < 4) {
TCGMemOp memop = MO_TE + size;
tmphi = tcg_const_i64(0);
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop);
} else {
TCGv_i64 tcg_hiaddr;
tmphi = tcg_temp_new_i64();
tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(destidx, MO_64));
tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(destidx));
tcg_temp_free_i64(tmplo);
tcg_temp_free_i64(tmphi);
}
| false | qemu | 90e496386fe7fd32c189561f846b7913f95b8cf4 | static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size)
{
TCGv_i64 tmplo = tcg_temp_new_i64();
TCGv_i64 tmphi;
if (size < 4) {
TCGMemOp memop = MO_TE + size;
tmphi = tcg_const_i64(0);
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), memop);
} else {
TCGv_i64 tcg_hiaddr;
tmphi = tcg_temp_new_i64();
tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_ld_i64(tmplo, tcg_addr, get_mem_index(s), MO_TEQ);
tcg_gen_addi_i64(tcg_hiaddr, tcg_addr, 8);
tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(s), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(destidx, MO_64));
tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(destidx));
tcg_temp_free_i64(tmplo);
tcg_temp_free_i64(tmphi);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DisasContext *VAR_0, int VAR_1, TCGv_i64 VAR_2, int VAR_3)
{
TCGv_i64 tmplo = tcg_temp_new_i64();
TCGv_i64 tmphi;
if (VAR_3 < 4) {
TCGMemOp memop = MO_TE + VAR_3;
tmphi = tcg_const_i64(0);
tcg_gen_qemu_ld_i64(tmplo, VAR_2, get_mem_index(VAR_0), memop);
} else {
TCGv_i64 tcg_hiaddr;
tmphi = tcg_temp_new_i64();
tcg_hiaddr = tcg_temp_new_i64();
tcg_gen_qemu_ld_i64(tmplo, VAR_2, get_mem_index(VAR_0), MO_TEQ);
tcg_gen_addi_i64(tcg_hiaddr, VAR_2, 8);
tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(VAR_0), MO_TEQ);
tcg_temp_free_i64(tcg_hiaddr);
}
tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(VAR_1, MO_64));
tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(VAR_1));
tcg_temp_free_i64(tmplo);
tcg_temp_free_i64(tmphi);
}
| [
"static void FUNC_0(DisasContext *VAR_0, int VAR_1, TCGv_i64 VAR_2, int VAR_3)\n{",
"TCGv_i64 tmplo = tcg_temp_new_i64();",
"TCGv_i64 tmphi;",
"if (VAR_3 < 4) {",
"TCGMemOp memop = MO_TE + VAR_3;",
"tmphi = tcg_const_i64(0);",
"tcg_gen_qemu_ld_i64(tmplo, VAR_2, get_mem_index(VAR_0), memop);",
"} else {",
"TCGv_i64 tcg_hiaddr;",
"tmphi = tcg_temp_new_i64();",
"tcg_hiaddr = tcg_temp_new_i64();",
"tcg_gen_qemu_ld_i64(tmplo, VAR_2, get_mem_index(VAR_0), MO_TEQ);",
"tcg_gen_addi_i64(tcg_hiaddr, VAR_2, 8);",
"tcg_gen_qemu_ld_i64(tmphi, tcg_hiaddr, get_mem_index(VAR_0), MO_TEQ);",
"tcg_temp_free_i64(tcg_hiaddr);",
"}",
"tcg_gen_st_i64(tmplo, cpu_env, fp_reg_offset(VAR_1, MO_64));",
"tcg_gen_st_i64(tmphi, cpu_env, fp_reg_hi_offset(VAR_1));",
"tcg_temp_free_i64(tmplo);",
"tcg_temp_free_i64(tmphi);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
]
] |
1,258 | static inline void gen_op_eval_fbne(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
}
| false | qemu | de9e9d9f17a36ff76c1a02a5348835e5e0a081b0 | static inline void gen_op_eval_fbne(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,
unsigned int VAR_2)
{
gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);
gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);
tcg_gen_or_tl(VAR_0, VAR_0, cpu_tmp0);
}
| [
"static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1,\nunsigned int VAR_2)\n{",
"gen_mov_reg_FCC0(VAR_0, VAR_1, VAR_2);",
"gen_mov_reg_FCC1(cpu_tmp0, VAR_1, VAR_2);",
"tcg_gen_or_tl(VAR_0, VAR_0, cpu_tmp0);",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,259 | av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
unsigned int *sample_rate,
int channels, enum CodecID *codec_id)
{
AlsaData *s = ctx->priv_data;
const char *audio_device;
int res, flags = 0;
snd_pcm_format_t format;
snd_pcm_t *h;
snd_pcm_hw_params_t *hw_params;
snd_pcm_uframes_t buffer_size, period_size;
int64_t layout = ctx->streams[0]->codec->channel_layout;
if (ctx->filename[0] == 0) audio_device = "default";
else audio_device = ctx->filename;
if (*codec_id == CODEC_ID_NONE)
*codec_id = DEFAULT_CODEC_ID;
format = codec_id_to_pcm_format(*codec_id);
if (format == SND_PCM_FORMAT_UNKNOWN) {
av_log(ctx, AV_LOG_ERROR, "sample format 0x%04x is not supported\n", *codec_id);
return AVERROR(ENOSYS);
}
s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * channels;
if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
flags = SND_PCM_NONBLOCK;
}
res = snd_pcm_open(&h, audio_device, mode, flags);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot open audio device %s (%s)\n",
audio_device, snd_strerror(res));
return AVERROR(EIO);
}
res = snd_pcm_hw_params_malloc(&hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
snd_strerror(res));
goto fail1;
}
res = snd_pcm_hw_params_any(h, hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set access type (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_format(h, hw_params, format);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample format 0x%04x %d (%s)\n",
*codec_id, format, snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample rate (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_channels(h, hw_params, channels);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set channel count to %d (%s)\n",
channels, snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);
/* TODO: maybe use ctx->max_picture_buffer somehow */
res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA buffer size (%s)\n",
snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);
if (!period_size)
period_size = buffer_size / 4;
res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n",
snd_strerror(res));
goto fail;
}
s->period_size = period_size;
res = snd_pcm_hw_params(h, hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set parameters (%s)\n",
snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_free(hw_params);
if (channels > 2 && layout) {
if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) {
char name[128];
av_get_channel_layout_string(name, sizeof(name), channels, layout);
av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n",
name, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
}
if (s->reorder_func) {
s->reorder_buf_size = buffer_size;
s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size);
if (!s->reorder_buf)
goto fail1;
}
}
s->h = h;
return 0;
fail:
snd_pcm_hw_params_free(hw_params);
fail1:
snd_pcm_close(h);
return AVERROR(EIO);
}
| false | FFmpeg | cc276c85d15272df6e44fb3252657a43cbd49555 | av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
unsigned int *sample_rate,
int channels, enum CodecID *codec_id)
{
AlsaData *s = ctx->priv_data;
const char *audio_device;
int res, flags = 0;
snd_pcm_format_t format;
snd_pcm_t *h;
snd_pcm_hw_params_t *hw_params;
snd_pcm_uframes_t buffer_size, period_size;
int64_t layout = ctx->streams[0]->codec->channel_layout;
if (ctx->filename[0] == 0) audio_device = "default";
else audio_device = ctx->filename;
if (*codec_id == CODEC_ID_NONE)
*codec_id = DEFAULT_CODEC_ID;
format = codec_id_to_pcm_format(*codec_id);
if (format == SND_PCM_FORMAT_UNKNOWN) {
av_log(ctx, AV_LOG_ERROR, "sample format 0x%04x is not supported\n", *codec_id);
return AVERROR(ENOSYS);
}
s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * channels;
if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
flags = SND_PCM_NONBLOCK;
}
res = snd_pcm_open(&h, audio_device, mode, flags);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot open audio device %s (%s)\n",
audio_device, snd_strerror(res));
return AVERROR(EIO);
}
res = snd_pcm_hw_params_malloc(&hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
snd_strerror(res));
goto fail1;
}
res = snd_pcm_hw_params_any(h, hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set access type (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_format(h, hw_params, format);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample format 0x%04x %d (%s)\n",
*codec_id, format, snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample rate (%s)\n",
snd_strerror(res));
goto fail;
}
res = snd_pcm_hw_params_set_channels(h, hw_params, channels);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set channel count to %d (%s)\n",
channels, snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);
res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA buffer size (%s)\n",
snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);
if (!period_size)
period_size = buffer_size / 4;
res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n",
snd_strerror(res));
goto fail;
}
s->period_size = period_size;
res = snd_pcm_hw_params(h, hw_params);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set parameters (%s)\n",
snd_strerror(res));
goto fail;
}
snd_pcm_hw_params_free(hw_params);
if (channels > 2 && layout) {
if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) {
char name[128];
av_get_channel_layout_string(name, sizeof(name), channels, layout);
av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n",
name, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
}
if (s->reorder_func) {
s->reorder_buf_size = buffer_size;
s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size);
if (!s->reorder_buf)
goto fail1;
}
}
s->h = h;
return 0;
fail:
snd_pcm_hw_params_free(hw_params);
fail1:
snd_pcm_close(h);
return AVERROR(EIO);
}
| {
"code": [],
"line_no": []
} | av_cold int FUNC_0(AVFormatContext *ctx, snd_pcm_stream_t mode,
unsigned int *sample_rate,
int channels, enum CodecID *codec_id)
{
AlsaData *s = ctx->priv_data;
const char *VAR_0;
int VAR_1, VAR_2 = 0;
snd_pcm_format_t format;
snd_pcm_t *h;
snd_pcm_hw_params_t *hw_params;
snd_pcm_uframes_t buffer_size, period_size;
int64_t layout = ctx->streams[0]->codec->channel_layout;
if (ctx->filename[0] == 0) VAR_0 = "default";
else VAR_0 = ctx->filename;
if (*codec_id == CODEC_ID_NONE)
*codec_id = DEFAULT_CODEC_ID;
format = codec_id_to_pcm_format(*codec_id);
if (format == SND_PCM_FORMAT_UNKNOWN) {
av_log(ctx, AV_LOG_ERROR, "sample format 0x%04x is not supported\n", *codec_id);
return AVERROR(ENOSYS);
}
s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * channels;
if (ctx->VAR_2 & AVFMT_FLAG_NONBLOCK) {
VAR_2 = SND_PCM_NONBLOCK;
}
VAR_1 = snd_pcm_open(&h, VAR_0, mode, VAR_2);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot open audio device %s (%s)\n",
VAR_0, snd_strerror(VAR_1));
return AVERROR(EIO);
}
VAR_1 = snd_pcm_hw_params_malloc(&hw_params);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
snd_strerror(VAR_1));
goto fail1;
}
VAR_1 = snd_pcm_hw_params_any(h, hw_params);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
VAR_1 = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set access type (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
VAR_1 = snd_pcm_hw_params_set_format(h, hw_params, format);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample format 0x%04x %d (%s)\n",
*codec_id, format, snd_strerror(VAR_1));
goto fail;
}
VAR_1 = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set sample rate (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
VAR_1 = snd_pcm_hw_params_set_channels(h, hw_params, channels);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set channel count to %d (%s)\n",
channels, snd_strerror(VAR_1));
goto fail;
}
snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);
VAR_1 = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA buffer size (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);
if (!period_size)
period_size = buffer_size / 4;
VAR_1 = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
s->period_size = period_size;
VAR_1 = snd_pcm_hw_params(h, hw_params);
if (VAR_1 < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set parameters (%s)\n",
snd_strerror(VAR_1));
goto fail;
}
snd_pcm_hw_params_free(hw_params);
if (channels > 2 && layout) {
if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) {
char VAR_3[128];
av_get_channel_layout_string(VAR_3, sizeof(VAR_3), channels, layout);
av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n",
VAR_3, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
}
if (s->reorder_func) {
s->reorder_buf_size = buffer_size;
s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size);
if (!s->reorder_buf)
goto fail1;
}
}
s->h = h;
return 0;
fail:
snd_pcm_hw_params_free(hw_params);
fail1:
snd_pcm_close(h);
return AVERROR(EIO);
}
| [
"av_cold int FUNC_0(AVFormatContext *ctx, snd_pcm_stream_t mode,\nunsigned int *sample_rate,\nint channels, enum CodecID *codec_id)\n{",
"AlsaData *s = ctx->priv_data;",
"const char *VAR_0;",
"int VAR_1, VAR_2 = 0;",
"snd_pcm_format_t format;",
"snd_pcm_t *h;",
"snd_pcm_hw_params_t *hw_params;",
"snd_pcm_uframes_t buffer_size, period_size;",
"int64_t layout = ctx->streams[0]->codec->channel_layout;",
"if (ctx->filename[0] == 0) VAR_0 = \"default\";",
"else VAR_0 = ctx->filename;",
"if (*codec_id == CODEC_ID_NONE)\n*codec_id = DEFAULT_CODEC_ID;",
"format = codec_id_to_pcm_format(*codec_id);",
"if (format == SND_PCM_FORMAT_UNKNOWN) {",
"av_log(ctx, AV_LOG_ERROR, \"sample format 0x%04x is not supported\\n\", *codec_id);",
"return AVERROR(ENOSYS);",
"}",
"s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * channels;",
"if (ctx->VAR_2 & AVFMT_FLAG_NONBLOCK) {",
"VAR_2 = SND_PCM_NONBLOCK;",
"}",
"VAR_1 = snd_pcm_open(&h, VAR_0, mode, VAR_2);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot open audio device %s (%s)\\n\",\nVAR_0, snd_strerror(VAR_1));",
"return AVERROR(EIO);",
"}",
"VAR_1 = snd_pcm_hw_params_malloc(&hw_params);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot allocate hardware parameter structure (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail1;",
"}",
"VAR_1 = snd_pcm_hw_params_any(h, hw_params);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot initialize hardware parameter structure (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"VAR_1 = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set access type (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"VAR_1 = snd_pcm_hw_params_set_format(h, hw_params, format);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set sample format 0x%04x %d (%s)\\n\",\n*codec_id, format, snd_strerror(VAR_1));",
"goto fail;",
"}",
"VAR_1 = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set sample rate (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"VAR_1 = snd_pcm_hw_params_set_channels(h, hw_params, channels);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set channel count to %d (%s)\\n\",\nchannels, snd_strerror(VAR_1));",
"goto fail;",
"}",
"snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);",
"buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);",
"VAR_1 = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set ALSA buffer size (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);",
"if (!period_size)\nperiod_size = buffer_size / 4;",
"VAR_1 = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set ALSA period size (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"s->period_size = period_size;",
"VAR_1 = snd_pcm_hw_params(h, hw_params);",
"if (VAR_1 < 0) {",
"av_log(ctx, AV_LOG_ERROR, \"cannot set parameters (%s)\\n\",\nsnd_strerror(VAR_1));",
"goto fail;",
"}",
"snd_pcm_hw_params_free(hw_params);",
"if (channels > 2 && layout) {",
"if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) {",
"char VAR_3[128];",
"av_get_channel_layout_string(VAR_3, sizeof(VAR_3), channels, layout);",
"av_log(ctx, AV_LOG_WARNING, \"ALSA channel layout unknown or unimplemented for %s %s.\\n\",\nVAR_3, mode == SND_PCM_STREAM_PLAYBACK ? \"playback\" : \"capture\");",
"}",
"if (s->reorder_func) {",
"s->reorder_buf_size = buffer_size;",
"s->reorder_buf = av_malloc(s->reorder_buf_size * s->frame_size);",
"if (!s->reorder_buf)\ngoto fail1;",
"}",
"}",
"s->h = h;",
"return 0;",
"fail:\nsnd_pcm_hw_params_free(hw_params);",
"fail1:\nsnd_pcm_close(h);",
"return AVERROR(EIO);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145,
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165,
167
],
[
169
],
[
171
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201,
203
],
[
205
],
[
207
],
[
211
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235,
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
251,
253
],
[
255,
257
],
[
259
],
[
261
]
] |
1,260 | bool kvm_arch_stop_on_emulation_error(CPUState *env)
{
return !(env->cr[0] & CR0_PE_MASK) ||
((env->segs[R_CS].selector & 3) != 3);
}
| false | qemu | b9bec74bcb16519a876ec21cd5277c526a9b512d | bool kvm_arch_stop_on_emulation_error(CPUState *env)
{
return !(env->cr[0] & CR0_PE_MASK) ||
((env->segs[R_CS].selector & 3) != 3);
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(CPUState *env)
{
return !(env->cr[0] & CR0_PE_MASK) ||
((env->segs[R_CS].selector & 3) != 3);
}
| [
"bool FUNC_0(CPUState *env)\n{",
"return !(env->cr[0] & CR0_PE_MASK) ||\n((env->segs[R_CS].selector & 3) != 3);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
]
] |
1,261 | static ssize_t block_crypto_write_func(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
struct BlockCryptoCreateData *data = opaque;
ssize_t ret;
ret = blk_pwrite(data->blk, offset, buf, buflen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write encryption header");
return ret;
}
return ret;
}
| false | qemu | 375092332eeaa6e47561ce47fd36144cdaf964d0 | static ssize_t block_crypto_write_func(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
struct BlockCryptoCreateData *data = opaque;
ssize_t ret;
ret = blk_pwrite(data->blk, offset, buf, buflen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write encryption header");
return ret;
}
return ret;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(QCryptoBlock *block,
size_t offset,
const uint8_t *buf,
size_t buflen,
Error **errp,
void *opaque)
{
struct BlockCryptoCreateData *VAR_0 = opaque;
ssize_t ret;
ret = blk_pwrite(VAR_0->blk, offset, buf, buflen, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write encryption header");
return ret;
}
return ret;
}
| [
"static ssize_t FUNC_0(QCryptoBlock *block,\nsize_t offset,\nconst uint8_t *buf,\nsize_t buflen,\nError **errp,\nvoid *opaque)\n{",
"struct BlockCryptoCreateData *VAR_0 = opaque;",
"ssize_t ret;",
"ret = blk_pwrite(VAR_0->blk, offset, buf, buflen, 0);",
"if (ret < 0) {",
"error_setg_errno(errp, -ret, \"Could not write encryption header\");",
"return ret;",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
]
] |
1,262 | static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
uint64_t cumulative_shared_perms, Error **errp)
{
BlockDriver *drv = bs->drv;
BdrvChild *c;
int ret;
/* Write permissions never work with read-only images */
if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&
bdrv_is_read_only(bs))
{
error_setg(errp, "Block node is read-only");
return -EPERM;
}
/* Check this node */
if (!drv) {
return 0;
}
if (drv->bdrv_check_perm) {
return drv->bdrv_check_perm(bs, cumulative_perms,
cumulative_shared_perms, errp);
}
/* Drivers that never have children can omit .bdrv_child_perm() */
if (!drv->bdrv_child_perm) {
assert(QLIST_EMPTY(&bs->children));
return 0;
}
/* Check all children */
QLIST_FOREACH(c, &bs->children, next) {
uint64_t cur_perm, cur_shared;
drv->bdrv_child_perm(bs, c, c->role,
cumulative_perms, cumulative_shared_perms,
&cur_perm, &cur_shared);
ret = bdrv_child_check_perm(c, cur_perm, cur_shared, errp);
if (ret < 0) {
return ret;
}
}
return 0;
}
| false | qemu | 46181129eac9a56d9a948667282dd03d5015f096 | static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
uint64_t cumulative_shared_perms, Error **errp)
{
BlockDriver *drv = bs->drv;
BdrvChild *c;
int ret;
if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&
bdrv_is_read_only(bs))
{
error_setg(errp, "Block node is read-only");
return -EPERM;
}
if (!drv) {
return 0;
}
if (drv->bdrv_check_perm) {
return drv->bdrv_check_perm(bs, cumulative_perms,
cumulative_shared_perms, errp);
}
if (!drv->bdrv_child_perm) {
assert(QLIST_EMPTY(&bs->children));
return 0;
}
QLIST_FOREACH(c, &bs->children, next) {
uint64_t cur_perm, cur_shared;
drv->bdrv_child_perm(bs, c, c->role,
cumulative_perms, cumulative_shared_perms,
&cur_perm, &cur_shared);
ret = bdrv_child_check_perm(c, cur_perm, cur_shared, errp);
if (ret < 0) {
return ret;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t VAR_2, Error **VAR_3)
{
BlockDriver *drv = VAR_0->drv;
BdrvChild *c;
int VAR_4;
if ((VAR_1 & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&
bdrv_is_read_only(VAR_0))
{
error_setg(VAR_3, "Block node is read-only");
return -EPERM;
}
if (!drv) {
return 0;
}
if (drv->FUNC_0) {
return drv->FUNC_0(VAR_0, VAR_1,
VAR_2, VAR_3);
}
if (!drv->bdrv_child_perm) {
assert(QLIST_EMPTY(&VAR_0->children));
return 0;
}
QLIST_FOREACH(c, &VAR_0->children, next) {
uint64_t cur_perm, cur_shared;
drv->bdrv_child_perm(VAR_0, c, c->role,
VAR_1, VAR_2,
&cur_perm, &cur_shared);
VAR_4 = bdrv_child_check_perm(c, cur_perm, cur_shared, VAR_3);
if (VAR_4 < 0) {
return VAR_4;
}
}
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t VAR_2, Error **VAR_3)\n{",
"BlockDriver *drv = VAR_0->drv;",
"BdrvChild *c;",
"int VAR_4;",
"if ((VAR_1 & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&\nbdrv_is_read_only(VAR_0))\n{",
"error_setg(VAR_3, \"Block node is read-only\");",
"return -EPERM;",
"}",
"if (!drv) {",
"return 0;",
"}",
"if (drv->FUNC_0) {",
"return drv->FUNC_0(VAR_0, VAR_1,\nVAR_2, VAR_3);",
"}",
"if (!drv->bdrv_child_perm) {",
"assert(QLIST_EMPTY(&VAR_0->children));",
"return 0;",
"}",
"QLIST_FOREACH(c, &VAR_0->children, next) {",
"uint64_t cur_perm, cur_shared;",
"drv->bdrv_child_perm(VAR_0, c, c->role,\nVAR_1, VAR_2,\n&cur_perm, &cur_shared);",
"VAR_4 = bdrv_child_check_perm(c, cur_perm, cur_shared, VAR_3);",
"if (VAR_4 < 0) {",
"return VAR_4;",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
17,
19,
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43,
45
],
[
47
],
[
53
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69,
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87
],
[
89
]
] |
1,263 | static void test_qemu_strtosz_simple(void)
{
const char *str;
char *endptr = NULL;
int64_t res;
str = "0";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str + 1);
str = "12345";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 12345);
g_assert(endptr == str + 5);
res = qemu_strtosz(str, NULL);
g_assert_cmpint(res, ==, 12345);
/* Note: precision is 53 bits since we're parsing with strtod() */
str = "9007199254740991"; /* 2^53-1 */
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x1fffffffffffff);
g_assert(endptr == str + 16);
str = "9007199254740992"; /* 2^53 */
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(endptr == str + 16);
str = "9007199254740993"; /* 2^53+1 */
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000); /* rounded to 53 bits */
g_assert(endptr == str + 16);
str = "9223372036854774784"; /* 0x7ffffffffffffc00 (53 msbs set) */
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(endptr == str + 19);
str = "9223372036854775295"; /* 0x7ffffffffffffdff */
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00); /* rounded to 53 bits */
g_assert(endptr == str + 19);
/* 0x7ffffffffffffe00..0x7fffffffffffffff get rounded to
* 0x8000000000000000, thus -ERANGE; see test_qemu_strtosz_erange() */
}
| false | qemu | f17fd4fdf0df3d2f3444399d04c38d22b9a3e1b7 | static void test_qemu_strtosz_simple(void)
{
const char *str;
char *endptr = NULL;
int64_t res;
str = "0";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0);
g_assert(endptr == str + 1);
str = "12345";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 12345);
g_assert(endptr == str + 5);
res = qemu_strtosz(str, NULL);
g_assert_cmpint(res, ==, 12345);
str = "9007199254740991";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x1fffffffffffff);
g_assert(endptr == str + 16);
str = "9007199254740992";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(endptr == str + 16);
str = "9007199254740993";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(endptr == str + 16);
str = "9223372036854774784";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(endptr == str + 19);
str = "9223372036854775295";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(endptr == str + 19);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
const char *VAR_0;
char *VAR_1 = NULL;
int64_t res;
VAR_0 = "0";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0);
g_assert(VAR_1 == VAR_0 + 1);
VAR_0 = "12345";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 12345);
g_assert(VAR_1 == VAR_0 + 5);
res = qemu_strtosz(VAR_0, NULL);
g_assert_cmpint(res, ==, 12345);
VAR_0 = "9007199254740991";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0x1fffffffffffff);
g_assert(VAR_1 == VAR_0 + 16);
VAR_0 = "9007199254740992";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(VAR_1 == VAR_0 + 16);
VAR_0 = "9007199254740993";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0x20000000000000);
g_assert(VAR_1 == VAR_0 + 16);
VAR_0 = "9223372036854774784";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(VAR_1 == VAR_0 + 19);
VAR_0 = "9223372036854775295";
res = qemu_strtosz(VAR_0, &VAR_1);
g_assert_cmpint(res, ==, 0x7ffffffffffffc00);
g_assert(VAR_1 == VAR_0 + 19);
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0;",
"char *VAR_1 = NULL;",
"int64_t res;",
"VAR_0 = \"0\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0);",
"g_assert(VAR_1 == VAR_0 + 1);",
"VAR_0 = \"12345\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 12345);",
"g_assert(VAR_1 == VAR_0 + 5);",
"res = qemu_strtosz(VAR_0, NULL);",
"g_assert_cmpint(res, ==, 12345);",
"VAR_0 = \"9007199254740991\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0x1fffffffffffff);",
"g_assert(VAR_1 == VAR_0 + 16);",
"VAR_0 = \"9007199254740992\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0x20000000000000);",
"g_assert(VAR_1 == VAR_0 + 16);",
"VAR_0 = \"9007199254740993\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0x20000000000000);",
"g_assert(VAR_1 == VAR_0 + 16);",
"VAR_0 = \"9223372036854774784\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0x7ffffffffffffc00);",
"g_assert(VAR_1 == VAR_0 + 19);",
"VAR_0 = \"9223372036854775295\";",
"res = qemu_strtosz(VAR_0, &VAR_1);",
"g_assert_cmpint(res, ==, 0x7ffffffffffffc00);",
"g_assert(VAR_1 == VAR_0 + 19);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
97
]
] |
1,264 | void vring_teardown(Vring *vring)
{
hostmem_finalize(&vring->hostmem);
}
| false | qemu | 9154b02c53bb6685797c973fcdbec51c4714777d | void vring_teardown(Vring *vring)
{
hostmem_finalize(&vring->hostmem);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(Vring *VAR_0)
{
hostmem_finalize(&VAR_0->hostmem);
}
| [
"void FUNC_0(Vring *VAR_0)\n{",
"hostmem_finalize(&VAR_0->hostmem);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,266 | static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
NvmeRequest *req)
{
NvmeRwCmd *rw = (NvmeRwCmd *)cmd;
uint32_t nlb = le32_to_cpu(rw->nlb) + 1;
uint64_t slba = le64_to_cpu(rw->slba);
uint64_t prp1 = le64_to_cpu(rw->prp1);
uint64_t prp2 = le64_to_cpu(rw->prp2);
uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
uint64_t data_size = nlb << data_shift;
uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
if ((slba + nlb) > ns->id_ns.nsze) {
return NVME_LBA_RANGE | NVME_DNR;
}
if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) {
return NVME_INVALID_FIELD | NVME_DNR;
}
assert((nlb << data_shift) == req->qsg.size);
dma_acct_start(n->conf.bs, &req->acct, &req->qsg, is_write ?
BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
req->aiocb = is_write ?
dma_bdrv_write(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req) :
dma_bdrv_read(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req);
return NVME_NO_COMPLETE;
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
NvmeRequest *req)
{
NvmeRwCmd *rw = (NvmeRwCmd *)cmd;
uint32_t nlb = le32_to_cpu(rw->nlb) + 1;
uint64_t slba = le64_to_cpu(rw->slba);
uint64_t prp1 = le64_to_cpu(rw->prp1);
uint64_t prp2 = le64_to_cpu(rw->prp2);
uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
uint64_t data_size = nlb << data_shift;
uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
if ((slba + nlb) > ns->id_ns.nsze) {
return NVME_LBA_RANGE | NVME_DNR;
}
if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) {
return NVME_INVALID_FIELD | NVME_DNR;
}
assert((nlb << data_shift) == req->qsg.size);
dma_acct_start(n->conf.bs, &req->acct, &req->qsg, is_write ?
BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
req->aiocb = is_write ?
dma_bdrv_write(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req) :
dma_bdrv_read(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req);
return NVME_NO_COMPLETE;
}
| {
"code": [],
"line_no": []
} | static uint16_t FUNC_0(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
NvmeRequest *req)
{
NvmeRwCmd *rw = (NvmeRwCmd *)cmd;
uint32_t nlb = le32_to_cpu(rw->nlb) + 1;
uint64_t slba = le64_to_cpu(rw->slba);
uint64_t prp1 = le64_to_cpu(rw->prp1);
uint64_t prp2 = le64_to_cpu(rw->prp2);
uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
uint64_t data_size = nlb << data_shift;
uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
int VAR_0 = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
if ((slba + nlb) > ns->id_ns.nsze) {
return NVME_LBA_RANGE | NVME_DNR;
}
if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) {
return NVME_INVALID_FIELD | NVME_DNR;
}
assert((nlb << data_shift) == req->qsg.size);
dma_acct_start(n->conf.bs, &req->acct, &req->qsg, VAR_0 ?
BLOCK_ACCT_WRITE : BLOCK_ACCT_READ);
req->aiocb = VAR_0 ?
dma_bdrv_write(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req) :
dma_bdrv_read(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req);
return NVME_NO_COMPLETE;
}
| [
"static uint16_t FUNC_0(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,\nNvmeRequest *req)\n{",
"NvmeRwCmd *rw = (NvmeRwCmd *)cmd;",
"uint32_t nlb = le32_to_cpu(rw->nlb) + 1;",
"uint64_t slba = le64_to_cpu(rw->slba);",
"uint64_t prp1 = le64_to_cpu(rw->prp1);",
"uint64_t prp2 = le64_to_cpu(rw->prp2);",
"uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);",
"uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;",
"uint64_t data_size = nlb << data_shift;",
"uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);",
"int VAR_0 = rw->opcode == NVME_CMD_WRITE ? 1 : 0;",
"if ((slba + nlb) > ns->id_ns.nsze) {",
"return NVME_LBA_RANGE | NVME_DNR;",
"}",
"if (nvme_map_prp(&req->qsg, prp1, prp2, data_size, n)) {",
"return NVME_INVALID_FIELD | NVME_DNR;",
"}",
"assert((nlb << data_shift) == req->qsg.size);",
"dma_acct_start(n->conf.bs, &req->acct, &req->qsg, VAR_0 ?\nBLOCK_ACCT_WRITE : BLOCK_ACCT_READ);",
"req->aiocb = VAR_0 ?\ndma_bdrv_write(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req) :\ndma_bdrv_read(n->conf.bs, &req->qsg, aio_slba, nvme_rw_cb, req);",
"return NVME_NO_COMPLETE;",
"}"
] | [
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
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47,
49
],
[
51,
53,
55
],
[
59
],
[
61
]
] |
1,267 | static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz,
int ac_index, int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i, j, level, val, run;
if(*EOBRUN){
(*EOBRUN)--;
return 0;
}
{OPEN_READER(re, &s->gb)
for(i=ss;;i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
/* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */
code -= 16;
run = ((unsigned) code) >> 4;
code &= 0xF;
if(code) {
i += run;
if(code > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &s->gb)
}
{
int cache=GET_CACHE(re,&s->gb);
int sign=(~cache)>>31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code)
if (i >= se) {
if(i == se){
j = s->scantable.permutated[se];
block[j] = level * quant_matrix[j] << Al;
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
}else{
if(run == 0xF){// ZRL - skip 15 coefficients
i += 15;
}else{
val = (1 << run);
if(run){
UPDATE_CACHE(re, &s->gb);
val += NEG_USR32(GET_CACHE(re, &s->gb), run);
LAST_SKIP_BITS(re, &s->gb, run);
}
*EOBRUN = val - 1;
break;
}
}
}
CLOSE_READER(re, &s->gb)}
if(i > *last_nnz)
*last_nnz = i;
return 0;
}
| false | FFmpeg | 5675a11f9277b5c7b1c9ad45da893e9ef9a42f03 | static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz,
int ac_index, int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i, j, level, val, run;
if(*EOBRUN){
(*EOBRUN)--;
return 0;
}
{OPEN_READER(re, &s->gb)
for(i=ss;;i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
code -= 16;
run = ((unsigned) code) >> 4;
code &= 0xF;
if(code) {
i += run;
if(code > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &s->gb)
}
{
int cache=GET_CACHE(re,&s->gb);
int sign=(~cache)>>31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code)
if (i >= se) {
if(i == se){
j = s->scantable.permutated[se];
block[j] = level * quant_matrix[j] << Al;
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
}else{
if(run == 0xF){
i += 15;
}else{
val = (1 << run);
if(run){
UPDATE_CACHE(re, &s->gb);
val += NEG_USR32(GET_CACHE(re, &s->gb), run);
LAST_SKIP_BITS(re, &s->gb, run);
}
*EOBRUN = val - 1;
break;
}
}
}
CLOSE_READER(re, &s->gb)}
if(i > *last_nnz)
*last_nnz = i;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MJpegDecodeContext *VAR_0, DCTELEM *VAR_1, uint8_t *VAR_2,
int VAR_3, int16_t *VAR_4,
int VAR_5, int VAR_6, int VAR_7, int *VAR_8)
{
int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;
if(*VAR_8){
(*VAR_8)--;
return 0;
}
{OPEN_READER(re, &VAR_0->gb)
for(VAR_10=VAR_5;;VAR_10++) {
UPDATE_CACHE(re, &VAR_0->gb);
GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[1][VAR_3].table, 9, 2)
VAR_9 -= 16;
VAR_14 = ((unsigned) VAR_9) >> 4;
VAR_9 &= 0xF;
if(VAR_9) {
VAR_10 += VAR_14;
if(VAR_9 > MIN_CACHE_BITS - 16){
UPDATE_CACHE(re, &VAR_0->gb)
}
{
int cache=GET_CACHE(re,&VAR_0->gb);
int sign=(~cache)>>31;
VAR_12 = (NEG_USR32(sign ^ cache,VAR_9) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9)
if (VAR_10 >= VAR_6) {
if(VAR_10 == VAR_6){
VAR_11 = VAR_0->scantable.permutated[VAR_6];
VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;
break;
}
av_log(VAR_0->avctx, AV_LOG_ERROR, "error count: %d\n", VAR_10);
return -1;
}
VAR_11 = VAR_0->scantable.permutated[VAR_10];
VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;
}else{
if(VAR_14 == 0xF){
VAR_10 += 15;
}else{
VAR_13 = (1 << VAR_14);
if(VAR_14){
UPDATE_CACHE(re, &VAR_0->gb);
VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14);
LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14);
}
*VAR_8 = VAR_13 - 1;
break;
}
}
}
CLOSE_READER(re, &VAR_0->gb)}
if(VAR_10 > *VAR_2)
*VAR_2 = VAR_10;
return 0;
}
| [
"static int FUNC_0(MJpegDecodeContext *VAR_0, DCTELEM *VAR_1, uint8_t *VAR_2,\nint VAR_3, int16_t *VAR_4,\nint VAR_5, int VAR_6, int VAR_7, int *VAR_8)\n{",
"int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;",
"if(*VAR_8){",
"(*VAR_8)--;",
"return 0;",
"}",
"{OPEN_READER(re, &VAR_0->gb)",
"for(VAR_10=VAR_5;;VAR_10++) {",
"UPDATE_CACHE(re, &VAR_0->gb);",
"GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[1][VAR_3].table, 9, 2)\nVAR_9 -= 16;",
"VAR_14 = ((unsigned) VAR_9) >> 4;",
"VAR_9 &= 0xF;",
"if(VAR_9) {",
"VAR_10 += VAR_14;",
"if(VAR_9 > MIN_CACHE_BITS - 16){",
"UPDATE_CACHE(re, &VAR_0->gb)\n}",
"{",
"int cache=GET_CACHE(re,&VAR_0->gb);",
"int sign=(~cache)>>31;",
"VAR_12 = (NEG_USR32(sign ^ cache,VAR_9) ^ sign) - sign;",
"}",
"LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9)\nif (VAR_10 >= VAR_6) {",
"if(VAR_10 == VAR_6){",
"VAR_11 = VAR_0->scantable.permutated[VAR_6];",
"VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;",
"break;",
"}",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"error count: %d\\n\", VAR_10);",
"return -1;",
"}",
"VAR_11 = VAR_0->scantable.permutated[VAR_10];",
"VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;",
"}else{",
"if(VAR_14 == 0xF){",
"VAR_10 += 15;",
"}else{",
"VAR_13 = (1 << VAR_14);",
"if(VAR_14){",
"UPDATE_CACHE(re, &VAR_0->gb);",
"VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14);",
"LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14);",
"}",
"*VAR_8 = VAR_13 - 1;",
"break;",
"}",
"}",
"}",
"CLOSE_READER(re, &VAR_0->gb)}",
"if(VAR_10 > *VAR_2)\n*VAR_2 = VAR_10;",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59,
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
]
] |
1,268 | static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
{
/* Primary audio coding side information */
int j, k;
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
if (!base_channel) {
s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;
s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++)
s->prediction_mode[j][k] = get_bits(&s->gb, 1);
}
/* Get prediction codebook */
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++) {
if (s->prediction_mode[j][k] > 0) {
/* (Prediction coefficient VQ address) */
s->prediction_vq[j][k] = get_bits(&s->gb, 12);
}
}
}
/* Bit allocation index */
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->vq_start_subband[j]; k++) {
if (s->bitalloc_huffman[j] == 6)
s->bitalloc[j][k] = get_bits(&s->gb, 5);
else if (s->bitalloc_huffman[j] == 5)
s->bitalloc[j][k] = get_bits(&s->gb, 4);
else if (s->bitalloc_huffman[j] == 7) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid bit allocation index\n");
return AVERROR_INVALIDDATA;
} else {
s->bitalloc[j][k] =
get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]);
}
if (s->bitalloc[j][k] > 26) {
// av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index [%i][%i] too big (%i)\n",
// j, k, s->bitalloc[j][k]);
return AVERROR_INVALIDDATA;
}
}
}
/* Transition mode */
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++) {
s->transition_mode[j][k] = 0;
if (s->subsubframes[s->current_subframe] > 1 &&
k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
s->transition_mode[j][k] =
get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
}
}
}
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
for (j = base_channel; j < s->prim_channels; j++) {
const uint32_t *scale_table;
int scale_sum;
memset(s->scale_factor[j], 0,
s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
if (s->scalefactor_huffman[j] == 6)
scale_table = scale_factor_quant7;
else
scale_table = scale_factor_quant6;
/* When huffman coded, only the difference is encoded */
scale_sum = 0;
for (k = 0; k < s->subband_activity[j]; k++) {
if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
s->scale_factor[j][k][0] = scale_table[scale_sum];
}
if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
/* Get second scale factor */
scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
s->scale_factor[j][k][1] = scale_table[scale_sum];
}
}
}
/* Joint subband scale factor codebook select */
for (j = base_channel; j < s->prim_channels; j++) {
/* Transmitted only if joint subband coding enabled */
if (s->joint_intensity[j] > 0)
s->joint_huff[j] = get_bits(&s->gb, 3);
}
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
/* Scale factors for joint subband coding */
for (j = base_channel; j < s->prim_channels; j++) {
int source_channel;
/* Transmitted only if joint subband coding enabled */
if (s->joint_intensity[j] > 0) {
int scale = 0;
source_channel = s->joint_intensity[j] - 1;
/* When huffman coded, only the difference is encoded
* (is this valid as well for joint scales ???) */
for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
scale = get_scale(&s->gb, s->joint_huff[j], 0);
scale += 64; /* bias */
s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */
}
if (!(s->debug_flag & 0x02)) {
av_log(s->avctx, AV_LOG_DEBUG,
"Joint stereo coding not supported\n");
s->debug_flag |= 0x02;
}
}
}
/* Stereo downmix coefficients */
if (!base_channel && s->prim_channels > 2) {
if (s->downmix) {
for (j = base_channel; j < s->prim_channels; j++) {
s->downmix_coef[j][0] = get_bits(&s->gb, 7);
s->downmix_coef[j][1] = get_bits(&s->gb, 7);
}
} else {
int am = s->amode & DCA_CHANNEL_MASK;
for (j = base_channel; j < s->prim_channels; j++) {
s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
}
}
}
/* Dynamic range coefficient */
if (!base_channel && s->dynrange)
s->dynrange_coef = get_bits(&s->gb, 8);
/* Side information CRC check word */
if (s->crc_present) {
get_bits(&s->gb, 16);
}
/*
* Primary audio data arrays
*/
/* VQ encoded high frequency subbands */
for (j = base_channel; j < s->prim_channels; j++)
for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
/* 1 vector -> 32 samples */
s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
/* Low frequency effect data */
if (!base_channel && s->lfe) {
/* LFE samples */
int lfe_samples = 2 * s->lfe * (4 + block_index);
int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
float lfe_scale;
for (j = lfe_samples; j < lfe_end_sample; j++) {
/* Signed 8 bits int */
s->lfe_data[j] = get_sbits(&s->gb, 8);
}
/* Scale factor index */
s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];
/* Quantization step size * scale factor */
lfe_scale = 0.035 * s->lfe_scale_factor;
for (j = lfe_samples; j < lfe_end_sample; j++)
s->lfe_data[j] *= lfe_scale;
}
#ifdef TRACE
av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n",
s->subsubframes[s->current_subframe]);
av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
s->partial_samples[s->current_subframe]);
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG,
"prediction coefs: %f, %f, %f, %f\n",
(float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
for (k = 0; k < s->vq_start_subband[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
for (k = 0; k < s->subband_activity[j]; k++) {
if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
if (s->joint_intensity[j] > 0) {
int source_channel = s->joint_intensity[j] - 1;
av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
if (!base_channel && s->prim_channels > 2 && s->downmix) {
av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
for (j = 0; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,
dca_downmix_coeffs[s->downmix_coef[j][0]]);
av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j,
dca_downmix_coeffs[s->downmix_coef[j][1]]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++)
for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
if (!base_channel && s->lfe) {
int lfe_samples = 2 * s->lfe * (4 + block_index);
int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
for (j = lfe_samples; j < lfe_end_sample; j++)
av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
#endif
return 0;
}
| false | FFmpeg | d6bc273bac45d6c28e5ec00103268a6fba16f304 | static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
{
int j, k;
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
if (!base_channel) {
s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;
s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++)
s->prediction_mode[j][k] = get_bits(&s->gb, 1);
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++) {
if (s->prediction_mode[j][k] > 0) {
s->prediction_vq[j][k] = get_bits(&s->gb, 12);
}
}
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->vq_start_subband[j]; k++) {
if (s->bitalloc_huffman[j] == 6)
s->bitalloc[j][k] = get_bits(&s->gb, 5);
else if (s->bitalloc_huffman[j] == 5)
s->bitalloc[j][k] = get_bits(&s->gb, 4);
else if (s->bitalloc_huffman[j] == 7) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid bit allocation index\n");
return AVERROR_INVALIDDATA;
} else {
s->bitalloc[j][k] =
get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]);
}
if (s->bitalloc[j][k] > 26) {
return AVERROR_INVALIDDATA;
}
}
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++) {
s->transition_mode[j][k] = 0;
if (s->subsubframes[s->current_subframe] > 1 &&
k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
s->transition_mode[j][k] =
get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
}
}
}
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
for (j = base_channel; j < s->prim_channels; j++) {
const uint32_t *scale_table;
int scale_sum;
memset(s->scale_factor[j], 0,
s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
if (s->scalefactor_huffman[j] == 6)
scale_table = scale_factor_quant7;
else
scale_table = scale_factor_quant6;
scale_sum = 0;
for (k = 0; k < s->subband_activity[j]; k++) {
if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
s->scale_factor[j][k][0] = scale_table[scale_sum];
}
if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum);
s->scale_factor[j][k][1] = scale_table[scale_sum];
}
}
}
for (j = base_channel; j < s->prim_channels; j++) {
if (s->joint_intensity[j] > 0)
s->joint_huff[j] = get_bits(&s->gb, 3);
}
if (get_bits_left(&s->gb) < 0)
return AVERROR_INVALIDDATA;
for (j = base_channel; j < s->prim_channels; j++) {
int source_channel;
if (s->joint_intensity[j] > 0) {
int scale = 0;
source_channel = s->joint_intensity[j] - 1;
for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
scale = get_scale(&s->gb, s->joint_huff[j], 0);
scale += 64;
s->joint_scale_factor[j][k] = scale;
}
if (!(s->debug_flag & 0x02)) {
av_log(s->avctx, AV_LOG_DEBUG,
"Joint stereo coding not supported\n");
s->debug_flag |= 0x02;
}
}
}
if (!base_channel && s->prim_channels > 2) {
if (s->downmix) {
for (j = base_channel; j < s->prim_channels; j++) {
s->downmix_coef[j][0] = get_bits(&s->gb, 7);
s->downmix_coef[j][1] = get_bits(&s->gb, 7);
}
} else {
int am = s->amode & DCA_CHANNEL_MASK;
for (j = base_channel; j < s->prim_channels; j++) {
s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
}
}
}
if (!base_channel && s->dynrange)
s->dynrange_coef = get_bits(&s->gb, 8);
if (s->crc_present) {
get_bits(&s->gb, 16);
}
for (j = base_channel; j < s->prim_channels; j++)
for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
if (!base_channel && s->lfe) {
int lfe_samples = 2 * s->lfe * (4 + block_index);
int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
float lfe_scale;
for (j = lfe_samples; j < lfe_end_sample; j++) {
s->lfe_data[j] = get_sbits(&s->gb, 8);
}
s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];
lfe_scale = 0.035 * s->lfe_scale_factor;
for (j = lfe_samples; j < lfe_end_sample; j++)
s->lfe_data[j] *= lfe_scale;
}
#ifdef TRACE
av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n",
s->subsubframes[s->current_subframe]);
av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
s->partial_samples[s->current_subframe]);
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG,
"prediction coefs: %f, %f, %f, %f\n",
(float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
(float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
for (k = 0; k < s->vq_start_subband[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
for (k = 0; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
for (k = 0; k < s->subband_activity[j]; k++) {
if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++) {
if (s->joint_intensity[j] > 0) {
int source_channel = s->joint_intensity[j] - 1;
av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
}
if (!base_channel && s->prim_channels > 2 && s->downmix) {
av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
for (j = 0; j < s->prim_channels; j++) {
av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,
dca_downmix_coeffs[s->downmix_coef[j][0]]);
av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j,
dca_downmix_coeffs[s->downmix_coef[j][1]]);
}
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
for (j = base_channel; j < s->prim_channels; j++)
for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
if (!base_channel && s->lfe) {
int lfe_samples = 2 * s->lfe * (4 + block_index);
int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
for (j = lfe_samples; j < lfe_end_sample; j++)
av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
av_log(s->avctx, AV_LOG_DEBUG, "\n");
}
#endif
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(DCAContext *VAR_0, int VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
if (get_bits_left(&VAR_0->gb) < 0)
return AVERROR_INVALIDDATA;
if (!VAR_1) {
VAR_0->subsubframes[VAR_0->current_subframe] = get_bits(&VAR_0->gb, 2) + 1;
VAR_0->partial_samples[VAR_0->current_subframe] = get_bits(&VAR_0->gb, 3);
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
VAR_0->prediction_mode[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 1);
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {
if (VAR_0->prediction_mode[VAR_3][VAR_4] > 0) {
VAR_0->prediction_vq[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 12);
}
}
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_0->vq_start_subband[VAR_3]; VAR_4++) {
if (VAR_0->bitalloc_huffman[VAR_3] == 6)
VAR_0->bitalloc[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 5);
else if (VAR_0->bitalloc_huffman[VAR_3] == 5)
VAR_0->bitalloc[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 4);
else if (VAR_0->bitalloc_huffman[VAR_3] == 7) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid bit allocation index\n");
return AVERROR_INVALIDDATA;
} else {
VAR_0->bitalloc[VAR_3][VAR_4] =
get_bitalloc(&VAR_0->gb, &dca_bitalloc_index, VAR_0->bitalloc_huffman[VAR_3]);
}
if (VAR_0->bitalloc[VAR_3][VAR_4] > 26) {
return AVERROR_INVALIDDATA;
}
}
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {
VAR_0->transition_mode[VAR_3][VAR_4] = 0;
if (VAR_0->subsubframes[VAR_0->current_subframe] > 1 &&
VAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->bitalloc[VAR_3][VAR_4] > 0) {
VAR_0->transition_mode[VAR_3][VAR_4] =
get_bitalloc(&VAR_0->gb, &dca_tmode, VAR_0->transient_huffman[VAR_3]);
}
}
}
if (get_bits_left(&VAR_0->gb) < 0)
return AVERROR_INVALIDDATA;
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
const uint32_t *scale_table;
int scale_sum;
memset(VAR_0->scale_factor[VAR_3], 0,
VAR_0->subband_activity[VAR_3] * sizeof(VAR_0->scale_factor[0][0][0]) * 2);
if (VAR_0->scalefactor_huffman[VAR_3] == 6)
scale_table = scale_factor_quant7;
else
scale_table = scale_factor_quant6;
scale_sum = 0;
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {
if (VAR_4 >= VAR_0->vq_start_subband[VAR_3] || VAR_0->bitalloc[VAR_3][VAR_4] > 0) {
scale_sum = get_scale(&VAR_0->gb, VAR_0->scalefactor_huffman[VAR_3], scale_sum);
VAR_0->scale_factor[VAR_3][VAR_4][0] = scale_table[scale_sum];
}
if (VAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->transition_mode[VAR_3][VAR_4]) {
scale_sum = get_scale(&VAR_0->gb, VAR_0->scalefactor_huffman[VAR_3], scale_sum);
VAR_0->scale_factor[VAR_3][VAR_4][1] = scale_table[scale_sum];
}
}
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
if (VAR_0->joint_intensity[VAR_3] > 0)
VAR_0->joint_huff[VAR_3] = get_bits(&VAR_0->gb, 3);
}
if (get_bits_left(&VAR_0->gb) < 0)
return AVERROR_INVALIDDATA;
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
int source_channel;
if (VAR_0->joint_intensity[VAR_3] > 0) {
int scale = 0;
source_channel = VAR_0->joint_intensity[VAR_3] - 1;
for (VAR_4 = VAR_0->subband_activity[VAR_3]; VAR_4 < VAR_0->subband_activity[source_channel]; VAR_4++) {
scale = get_scale(&VAR_0->gb, VAR_0->joint_huff[VAR_3], 0);
scale += 64;
VAR_0->joint_scale_factor[VAR_3][VAR_4] = scale;
}
if (!(VAR_0->debug_flag & 0x02)) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"Joint stereo coding not supported\n");
VAR_0->debug_flag |= 0x02;
}
}
}
if (!VAR_1 && VAR_0->prim_channels > 2) {
if (VAR_0->downmix) {
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
VAR_0->downmix_coef[VAR_3][0] = get_bits(&VAR_0->gb, 7);
VAR_0->downmix_coef[VAR_3][1] = get_bits(&VAR_0->gb, 7);
}
} else {
int VAR_5 = VAR_0->amode & DCA_CHANNEL_MASK;
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
VAR_0->downmix_coef[VAR_3][0] = dca_default_coeffs[VAR_5][VAR_3][0];
VAR_0->downmix_coef[VAR_3][1] = dca_default_coeffs[VAR_5][VAR_3][1];
}
}
}
if (!VAR_1 && VAR_0->dynrange)
VAR_0->dynrange_coef = get_bits(&VAR_0->gb, 8);
if (VAR_0->crc_present) {
get_bits(&VAR_0->gb, 16);
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++)
for (VAR_4 = VAR_0->vq_start_subband[VAR_3]; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
VAR_0->high_freq_vq[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 10);
if (!VAR_1 && VAR_0->lfe) {
int VAR_6 = 2 * VAR_0->lfe * (4 + VAR_2);
int VAR_7 = 2 * VAR_0->lfe * (4 + VAR_2 + VAR_0->subsubframes[VAR_0->current_subframe]);
float VAR_8;
for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++) {
VAR_0->lfe_data[VAR_3] = get_sbits(&VAR_0->gb, 8);
}
VAR_0->lfe_scale_factor = scale_factor_quant7[get_bits(&VAR_0->gb, 8)];
VAR_8 = 0.035 * VAR_0->lfe_scale_factor;
for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++)
VAR_0->lfe_data[VAR_3] *= VAR_8;
}
#ifdef TRACE
av_log(VAR_0->avctx, AV_LOG_DEBUG, "subsubframes: %i\n",
VAR_0->subsubframes[VAR_0->current_subframe]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
VAR_0->partial_samples[VAR_0->current_subframe]);
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "prediction mode:");
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %i", VAR_0->prediction_mode[VAR_3][VAR_4]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"prediction coefs: %f, %f, %f, %f\n",
(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][0] / 8192,
(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][1] / 8192,
(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][2] / 8192,
(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][3] / 8192);
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "bitalloc index: ");
for (VAR_4 = 0; VAR_4 < VAR_0->vq_start_subband[VAR_3]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "%2.2i ", VAR_0->bitalloc[VAR_3][VAR_4]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Transition mode:");
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %i", VAR_0->transition_mode[VAR_3][VAR_4]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Scale factor:");
for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {
if (VAR_4 >= VAR_0->vq_start_subband[VAR_3] || VAR_0->bitalloc[VAR_3][VAR_4] > 0)
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %i", VAR_0->scale_factor[VAR_3][VAR_4][0]);
if (VAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->transition_mode[VAR_3][VAR_4])
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %i(t)", VAR_0->scale_factor[VAR_3][VAR_4][1]);
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {
if (VAR_0->joint_intensity[VAR_3] > 0) {
int source_channel = VAR_0->joint_intensity[VAR_3] - 1;
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
for (VAR_4 = VAR_0->subband_activity[VAR_3]; VAR_4 < VAR_0->subband_activity[source_channel]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %i", VAR_0->joint_scale_factor[VAR_3][VAR_4]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
}
if (!VAR_1 && VAR_0->prim_channels > 2 && VAR_0->downmix) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
for (VAR_3 = 0; VAR_3 < VAR_0->prim_channels; VAR_3++) {
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", VAR_3,
dca_downmix_coeffs[VAR_0->downmix_coef[VAR_3][0]]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", VAR_3,
dca_downmix_coeffs[VAR_0->downmix_coef[VAR_3][1]]);
}
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++)
for (VAR_4 = VAR_0->vq_start_subband[VAR_3]; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, "VQ index: %i\n", VAR_0->high_freq_vq[VAR_3][VAR_4]);
if (!VAR_1 && VAR_0->lfe) {
int VAR_6 = 2 * VAR_0->lfe * (4 + VAR_2);
int VAR_7 = 2 * VAR_0->lfe * (4 + VAR_2 + VAR_0->subsubframes[VAR_0->current_subframe]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "LFE samples:\n");
for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++)
av_log(VAR_0->avctx, AV_LOG_DEBUG, " %f", VAR_0->lfe_data[VAR_3]);
av_log(VAR_0->avctx, AV_LOG_DEBUG, "\n");
}
#endif
return 0;
}
| [
"static int FUNC_0(DCAContext *VAR_0, int VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"if (get_bits_left(&VAR_0->gb) < 0)\nreturn AVERROR_INVALIDDATA;",
"if (!VAR_1) {",
"VAR_0->subsubframes[VAR_0->current_subframe] = get_bits(&VAR_0->gb, 2) + 1;",
"VAR_0->partial_samples[VAR_0->current_subframe] = get_bits(&VAR_0->gb, 3);",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"VAR_0->prediction_mode[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 1);",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {",
"if (VAR_0->prediction_mode[VAR_3][VAR_4] > 0) {",
"VAR_0->prediction_vq[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 12);",
"}",
"}",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->vq_start_subband[VAR_3]; VAR_4++) {",
"if (VAR_0->bitalloc_huffman[VAR_3] == 6)\nVAR_0->bitalloc[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 5);",
"else if (VAR_0->bitalloc_huffman[VAR_3] == 5)\nVAR_0->bitalloc[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 4);",
"else if (VAR_0->bitalloc_huffman[VAR_3] == 7) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Invalid bit allocation index\\n\");",
"return AVERROR_INVALIDDATA;",
"} else {",
"VAR_0->bitalloc[VAR_3][VAR_4] =\nget_bitalloc(&VAR_0->gb, &dca_bitalloc_index, VAR_0->bitalloc_huffman[VAR_3]);",
"}",
"if (VAR_0->bitalloc[VAR_3][VAR_4] > 26) {",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {",
"VAR_0->transition_mode[VAR_3][VAR_4] = 0;",
"if (VAR_0->subsubframes[VAR_0->current_subframe] > 1 &&\nVAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->bitalloc[VAR_3][VAR_4] > 0) {",
"VAR_0->transition_mode[VAR_3][VAR_4] =\nget_bitalloc(&VAR_0->gb, &dca_tmode, VAR_0->transient_huffman[VAR_3]);",
"}",
"}",
"}",
"if (get_bits_left(&VAR_0->gb) < 0)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"const uint32_t *scale_table;",
"int scale_sum;",
"memset(VAR_0->scale_factor[VAR_3], 0,\nVAR_0->subband_activity[VAR_3] * sizeof(VAR_0->scale_factor[0][0][0]) * 2);",
"if (VAR_0->scalefactor_huffman[VAR_3] == 6)\nscale_table = scale_factor_quant7;",
"else\nscale_table = scale_factor_quant6;",
"scale_sum = 0;",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {",
"if (VAR_4 >= VAR_0->vq_start_subband[VAR_3] || VAR_0->bitalloc[VAR_3][VAR_4] > 0) {",
"scale_sum = get_scale(&VAR_0->gb, VAR_0->scalefactor_huffman[VAR_3], scale_sum);",
"VAR_0->scale_factor[VAR_3][VAR_4][0] = scale_table[scale_sum];",
"}",
"if (VAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->transition_mode[VAR_3][VAR_4]) {",
"scale_sum = get_scale(&VAR_0->gb, VAR_0->scalefactor_huffman[VAR_3], scale_sum);",
"VAR_0->scale_factor[VAR_3][VAR_4][1] = scale_table[scale_sum];",
"}",
"}",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"if (VAR_0->joint_intensity[VAR_3] > 0)\nVAR_0->joint_huff[VAR_3] = get_bits(&VAR_0->gb, 3);",
"}",
"if (get_bits_left(&VAR_0->gb) < 0)\nreturn AVERROR_INVALIDDATA;",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"int source_channel;",
"if (VAR_0->joint_intensity[VAR_3] > 0) {",
"int scale = 0;",
"source_channel = VAR_0->joint_intensity[VAR_3] - 1;",
"for (VAR_4 = VAR_0->subband_activity[VAR_3]; VAR_4 < VAR_0->subband_activity[source_channel]; VAR_4++) {",
"scale = get_scale(&VAR_0->gb, VAR_0->joint_huff[VAR_3], 0);",
"scale += 64;",
"VAR_0->joint_scale_factor[VAR_3][VAR_4] = scale;",
"}",
"if (!(VAR_0->debug_flag & 0x02)) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"Joint stereo coding not supported\\n\");",
"VAR_0->debug_flag |= 0x02;",
"}",
"}",
"}",
"if (!VAR_1 && VAR_0->prim_channels > 2) {",
"if (VAR_0->downmix) {",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"VAR_0->downmix_coef[VAR_3][0] = get_bits(&VAR_0->gb, 7);",
"VAR_0->downmix_coef[VAR_3][1] = get_bits(&VAR_0->gb, 7);",
"}",
"} else {",
"int VAR_5 = VAR_0->amode & DCA_CHANNEL_MASK;",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"VAR_0->downmix_coef[VAR_3][0] = dca_default_coeffs[VAR_5][VAR_3][0];",
"VAR_0->downmix_coef[VAR_3][1] = dca_default_coeffs[VAR_5][VAR_3][1];",
"}",
"}",
"}",
"if (!VAR_1 && VAR_0->dynrange)\nVAR_0->dynrange_coef = get_bits(&VAR_0->gb, 8);",
"if (VAR_0->crc_present) {",
"get_bits(&VAR_0->gb, 16);",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++)",
"for (VAR_4 = VAR_0->vq_start_subband[VAR_3]; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"VAR_0->high_freq_vq[VAR_3][VAR_4] = get_bits(&VAR_0->gb, 10);",
"if (!VAR_1 && VAR_0->lfe) {",
"int VAR_6 = 2 * VAR_0->lfe * (4 + VAR_2);",
"int VAR_7 = 2 * VAR_0->lfe * (4 + VAR_2 + VAR_0->subsubframes[VAR_0->current_subframe]);",
"float VAR_8;",
"for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++) {",
"VAR_0->lfe_data[VAR_3] = get_sbits(&VAR_0->gb, 8);",
"}",
"VAR_0->lfe_scale_factor = scale_factor_quant7[get_bits(&VAR_0->gb, 8)];",
"VAR_8 = 0.035 * VAR_0->lfe_scale_factor;",
"for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++)",
"VAR_0->lfe_data[VAR_3] *= VAR_8;",
"}",
"#ifdef TRACE\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \"subsubframes: %i\\n\",\nVAR_0->subsubframes[VAR_0->current_subframe]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"partial samples: %i\\n\",\nVAR_0->partial_samples[VAR_0->current_subframe]);",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"prediction mode:\");",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %i\", VAR_0->prediction_mode[VAR_3][VAR_4]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"prediction coefs: %f, %f, %f, %f\\n\",\n(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][0] / 8192,\n(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][1] / 8192,\n(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][2] / 8192,\n(float) adpcm_vb[VAR_0->prediction_vq[VAR_3][VAR_4]][3] / 8192);",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"bitalloc index: \");",
"for (VAR_4 = 0; VAR_4 < VAR_0->vq_start_subband[VAR_3]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"%2.2i \", VAR_0->bitalloc[VAR_3][VAR_4]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Transition mode:\");",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %i\", VAR_0->transition_mode[VAR_3][VAR_4]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Scale factor:\");",
"for (VAR_4 = 0; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++) {",
"if (VAR_4 >= VAR_0->vq_start_subband[VAR_3] || VAR_0->bitalloc[VAR_3][VAR_4] > 0)\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \" %i\", VAR_0->scale_factor[VAR_3][VAR_4][0]);",
"if (VAR_4 < VAR_0->vq_start_subband[VAR_3] && VAR_0->transition_mode[VAR_3][VAR_4])\nav_log(VAR_0->avctx, AV_LOG_DEBUG, \" %i(t)\", VAR_0->scale_factor[VAR_3][VAR_4][1]);",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"if (VAR_0->joint_intensity[VAR_3] > 0) {",
"int source_channel = VAR_0->joint_intensity[VAR_3] - 1;",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Joint scale factor index:\\n\");",
"for (VAR_4 = VAR_0->subband_activity[VAR_3]; VAR_4 < VAR_0->subband_activity[source_channel]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %i\", VAR_0->joint_scale_factor[VAR_3][VAR_4]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"}",
"if (!VAR_1 && VAR_0->prim_channels > 2 && VAR_0->downmix) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Downmix coeffs:\\n\");",
"for (VAR_3 = 0; VAR_3 < VAR_0->prim_channels; VAR_3++) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Channel 0, %d = %f\\n\", VAR_3,\ndca_downmix_coeffs[VAR_0->downmix_coef[VAR_3][0]]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"Channel 1, %d = %f\\n\", VAR_3,\ndca_downmix_coeffs[VAR_0->downmix_coef[VAR_3][1]]);",
"}",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"for (VAR_3 = VAR_1; VAR_3 < VAR_0->prim_channels; VAR_3++)",
"for (VAR_4 = VAR_0->vq_start_subband[VAR_3]; VAR_4 < VAR_0->subband_activity[VAR_3]; VAR_4++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"VQ index: %i\\n\", VAR_0->high_freq_vq[VAR_3][VAR_4]);",
"if (!VAR_1 && VAR_0->lfe) {",
"int VAR_6 = 2 * VAR_0->lfe * (4 + VAR_2);",
"int VAR_7 = 2 * VAR_0->lfe * (4 + VAR_2 + VAR_0->subsubframes[VAR_0->current_subframe]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"LFE samples:\\n\");",
"for (VAR_3 = VAR_6; VAR_3 < VAR_7; VAR_3++)",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \" %f\", VAR_0->lfe_data[VAR_3]);",
"av_log(VAR_0->avctx, AV_LOG_DEBUG, \"\\n\");",
"}",
"#endif\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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
11,
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
59
],
[
61
],
[
63,
65
],
[
67,
69
],
[
71
],
[
73,
75
],
[
77
],
[
79
],
[
81,
83
],
[
85
],
[
89
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
113,
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
143,
145
],
[
149,
151
],
[
153,
155
],
[
161
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
199,
201
],
[
203
],
[
207,
209
],
[
215
],
[
217
],
[
223
],
[
225
],
[
227
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
299,
301
],
[
307
],
[
309
],
[
311
],
[
325
],
[
327
],
[
331
],
[
337
],
[
341
],
[
343
],
[
345
],
[
349
],
[
353
],
[
355
],
[
361
],
[
367
],
[
371
],
[
373
],
[
375
],
[
379,
381,
383
],
[
385,
387
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407,
409,
411,
413,
415,
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
427
],
[
429
],
[
431
],
[
433
],
[
435
],
[
437
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451,
453
],
[
455,
457
],
[
459
],
[
461
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489,
491
],
[
493,
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
517
],
[
519
],
[
521
],
[
523
],
[
525
],
[
527,
531
],
[
533
]
] |
1,269 | static int vc1_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
uint8_t *buf2 = NULL;
const uint8_t *buf_start = buf;
/* no supplementary picture */
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anything in there. */
if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
int i= ff_find_unused_picture(s, 0);
s->current_picture_ptr= &s->picture[i];
}
if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = PIX_FMT_VDPAU_WMV3;
else
avctx->pix_fmt = PIX_FMT_VDPAU_VC1;
}
//for advanced profile we may need to parse and unescape data
if (avctx->codec_id == CODEC_ID_VC1) {
int buf_size2 = 0;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */
const uint8_t *start, *end, *next;
int size;
next = buf;
for(start = buf, end = buf + buf_size; next < end; start = next){
next = find_next_marker(start + 4, end);
size = next - start - 4;
if(size <= 0) continue;
switch(AV_RB32(start)){
case VC1_CODE_FRAME:
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break;
case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&s->gb, buf2, buf_size2*8);
vc1_decode_entry_point(avctx, v, &s->gb);
break;
case VC1_CODE_SLICE:
av_log(avctx, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n");
av_free(buf2);
return -1;
}
}
}else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */
const uint8_t *divider;
divider = find_next_marker(buf, buf + buf_size);
if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){
av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
av_free(buf2);
return -1;
}
buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
// TODO
av_free(buf2);return -1;
}else{
buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
init_get_bits(&s->gb, buf, buf_size*8);
// do parse frame header
if(v->profile < PROFILE_ADVANCED) {
if(vc1_parse_frame_header(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
} else {
if(vc1_parse_frame_header_adv(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
}
if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){
av_free(buf2);
return -1;
}
// for hurry_up==5
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == FF_I_TYPE;
/* skip B-frames if we don't have reference frames */
if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){
av_free(buf2);
return -1;//buf_size;
}
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return -1;//buf_size;
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE)
|| avctx->skip_frame >= AVDISCARD_ALL) {
av_free(buf2);
return buf_size;
}
/* skip everything if we are in a hurry>=5 */
if(avctx->hurry_up>=5) {
av_free(buf2);
return -1;//buf_size;
}
if(s->next_p_frame_damaged){
if(s->pict_type==FF_B_TYPE)
return buf_size;
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, avctx) < 0) {
av_free(buf2);
return -1;
}
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)
&&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
else if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
return -1;
if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
return -1;
if (avctx->hwaccel->end_frame(avctx) < 0)
return -1;
} else {
ff_er_frame_start(s);
v->bits = buf_size * 8;
vc1_decode_blocks(v);
//av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8);
// if(get_bits_count(&s->gb) > buf_size * 8)
// return -1;
ff_er_frame_end(s);
}
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
av_free(buf2);
return buf_size;
}
| false | FFmpeg | e0f58e39c45abf4fd830f745d31acc43183ac7e6 | static int vc1_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
uint8_t *buf2 = NULL;
const uint8_t *buf_start = buf;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
int i= ff_find_unused_picture(s, 0);
s->current_picture_ptr= &s->picture[i];
}
if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
if (v->profile < PROFILE_ADVANCED)
avctx->pix_fmt = PIX_FMT_VDPAU_WMV3;
else
avctx->pix_fmt = PIX_FMT_VDPAU_VC1;
}
if (avctx->codec_id == CODEC_ID_VC1) {
int buf_size2 = 0;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(IS_MARKER(AV_RB32(buf))){
const uint8_t *start, *end, *next;
int size;
next = buf;
for(start = buf, end = buf + buf_size; next < end; start = next){
next = find_next_marker(start + 4, end);
size = next - start - 4;
if(size <= 0) continue;
switch(AV_RB32(start)){
case VC1_CODE_FRAME:
if (avctx->hwaccel ||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
buf_start = start;
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
break;
case VC1_CODE_ENTRYPOINT:
buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
init_get_bits(&s->gb, buf2, buf_size2*8);
vc1_decode_entry_point(avctx, v, &s->gb);
break;
case VC1_CODE_SLICE:
av_log(avctx, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n");
av_free(buf2);
return -1;
}
}
}else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){
const uint8_t *divider;
divider = find_next_marker(buf, buf + buf_size);
if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){
av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
av_free(buf2);
return -1;
}
buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
av_free(buf2);return -1;
}else{
buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
init_get_bits(&s->gb, buf, buf_size*8);
if(v->profile < PROFILE_ADVANCED) {
if(vc1_parse_frame_header(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
} else {
if(vc1_parse_frame_header_adv(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
}
if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){
av_free(buf2);
return -1;
}
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == FF_I_TYPE;
if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){
av_free(buf2);
return -1;
}
if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return -1;
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE)
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE)
|| avctx->skip_frame >= AVDISCARD_ALL) {
av_free(buf2);
return buf_size;
}
if(avctx->hurry_up>=5) {
av_free(buf2);
return -1;
}
if(s->next_p_frame_damaged){
if(s->pict_type==FF_B_TYPE)
return buf_size;
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, avctx) < 0) {
av_free(buf2);
return -1;
}
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)
&&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
else if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
return -1;
if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
return -1;
if (avctx->hwaccel->end_frame(avctx) < 0)
return -1;
} else {
ff_er_frame_start(s);
v->bits = buf_size * 8;
vc1_decode_blocks(v);
ff_er_frame_end(s);
}
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
av_free(buf2);
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_10;
VC1Context *v = VAR_0->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = VAR_1;
uint8_t *buf2 = NULL;
const uint8_t *VAR_6 = VAR_4;
if (VAR_5 == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
if(s->current_picture_ptr==NULL || s->current_picture_ptr->VAR_1[0]){
int VAR_7= ff_find_unused_picture(s, 0);
s->current_picture_ptr= &s->picture[VAR_7];
}
if (s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
if (v->profile < PROFILE_ADVANCED)
VAR_0->pix_fmt = PIX_FMT_VDPAU_WMV3;
else
VAR_0->pix_fmt = PIX_FMT_VDPAU_VC1;
}
if (VAR_0->codec_id == CODEC_ID_VC1) {
int VAR_8 = 0;
buf2 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);
if(IS_MARKER(AV_RB32(VAR_4))){
const uint8_t *VAR_9, *end, *next;
int VAR_10;
next = VAR_4;
for(VAR_9 = VAR_4, end = VAR_4 + VAR_5; next < end; VAR_9 = next){
next = find_next_marker(VAR_9 + 4, end);
VAR_10 = next - VAR_9 - 4;
if(VAR_10 <= 0) continue;
switch(AV_RB32(VAR_9)){
case VC1_CODE_FRAME:
if (VAR_0->hwaccel ||
s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
VAR_6 = VAR_9;
VAR_8 = vc1_unescape_buffer(VAR_9 + 4, VAR_10, buf2);
break;
case VC1_CODE_ENTRYPOINT:
VAR_8 = vc1_unescape_buffer(VAR_9 + 4, VAR_10, buf2);
init_get_bits(&s->gb, buf2, VAR_8*8);
vc1_decode_entry_point(VAR_0, v, &s->gb);
break;
case VC1_CODE_SLICE:
av_log(VAR_0, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n");
av_free(buf2);
return -1;
}
}
}else if(v->interlace && ((VAR_4[0] & 0xC0) == 0xC0)){
const uint8_t *VAR_11;
VAR_11 = find_next_marker(VAR_4, VAR_4 + VAR_5);
if((VAR_11 == (VAR_4 + VAR_5)) || AV_RB32(VAR_11) != VC1_CODE_FIELD){
av_log(VAR_0, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
av_free(buf2);
return -1;
}
VAR_8 = vc1_unescape_buffer(VAR_4, VAR_11 - VAR_4, buf2);
av_free(buf2);return -1;
}else{
VAR_8 = vc1_unescape_buffer(VAR_4, VAR_5, buf2);
}
init_get_bits(&s->gb, buf2, VAR_8*8);
} else
init_get_bits(&s->gb, VAR_4, VAR_5*8);
if(v->profile < PROFILE_ADVANCED) {
if(vc1_parse_frame_header(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
} else {
if(vc1_parse_frame_header_adv(v, &s->gb) == -1) {
av_free(buf2);
return -1;
}
}
if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){
av_free(buf2);
return -1;
}
s->current_picture.pict_type= s->pict_type;
s->current_picture.key_frame= s->pict_type == FF_I_TYPE;
if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){
av_free(buf2);
return -1;
}
if(VAR_0->hurry_up && s->pict_type==FF_B_TYPE) return -1;
if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE)
|| (VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE)
|| VAR_0->skip_frame >= AVDISCARD_ALL) {
av_free(buf2);
return VAR_5;
}
if(VAR_0->hurry_up>=5) {
av_free(buf2);
return -1;
}
if(s->next_p_frame_damaged){
if(s->pict_type==FF_B_TYPE)
return VAR_5;
else
s->next_p_frame_damaged=0;
}
if(MPV_frame_start(s, VAR_0) < 0) {
av_free(buf2);
return -1;
}
s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)
&&s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_vc1_decode_picture(s, VAR_6, (VAR_4 + VAR_5) - VAR_6);
else if (VAR_0->hwaccel) {
if (VAR_0->hwaccel->start_frame(VAR_0, VAR_4, VAR_5) < 0)
return -1;
if (VAR_0->hwaccel->decode_slice(VAR_0, VAR_6, (VAR_4 + VAR_5) - VAR_6) < 0)
return -1;
if (VAR_0->hwaccel->end_frame(VAR_0) < 0)
return -1;
} else {
ff_er_frame_start(s);
v->bits = VAR_5 * 8;
vc1_decode_blocks(v);
ff_er_frame_end(s);
}
MPV_frame_end(s);
assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
assert(s->current_picture.pict_type == s->pict_type);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*VAR_2 = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
av_free(buf2);
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_10;",
"VC1Context *v = VAR_0->priv_data;",
"MpegEncContext *s = &v->s;",
"AVFrame *pict = VAR_1;",
"uint8_t *buf2 = NULL;",
"const uint8_t *VAR_6 = VAR_4;",
"if (VAR_5 == 0) {",
"if (s->low_delay==0 && s->next_picture_ptr) {",
"*pict= *(AVFrame*)s->next_picture_ptr;",
"s->next_picture_ptr= NULL;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"if(s->current_picture_ptr==NULL || s->current_picture_ptr->VAR_1[0]){",
"int VAR_7= ff_find_unused_picture(s, 0);",
"s->current_picture_ptr= &s->picture[VAR_7];",
"}",
"if (s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){",
"if (v->profile < PROFILE_ADVANCED)\nVAR_0->pix_fmt = PIX_FMT_VDPAU_WMV3;",
"else\nVAR_0->pix_fmt = PIX_FMT_VDPAU_VC1;",
"}",
"if (VAR_0->codec_id == CODEC_ID_VC1) {",
"int VAR_8 = 0;",
"buf2 = av_mallocz(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);",
"if(IS_MARKER(AV_RB32(VAR_4))){",
"const uint8_t *VAR_9, *end, *next;",
"int VAR_10;",
"next = VAR_4;",
"for(VAR_9 = VAR_4, end = VAR_4 + VAR_5; next < end; VAR_9 = next){",
"next = find_next_marker(VAR_9 + 4, end);",
"VAR_10 = next - VAR_9 - 4;",
"if(VAR_10 <= 0) continue;",
"switch(AV_RB32(VAR_9)){",
"case VC1_CODE_FRAME:\nif (VAR_0->hwaccel ||\ns->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)\nVAR_6 = VAR_9;",
"VAR_8 = vc1_unescape_buffer(VAR_9 + 4, VAR_10, buf2);",
"break;",
"case VC1_CODE_ENTRYPOINT:\nVAR_8 = vc1_unescape_buffer(VAR_9 + 4, VAR_10, buf2);",
"init_get_bits(&s->gb, buf2, VAR_8*8);",
"vc1_decode_entry_point(VAR_0, v, &s->gb);",
"break;",
"case VC1_CODE_SLICE:\nav_log(VAR_0, AV_LOG_ERROR, \"Sliced decoding is not implemented (yet)\\n\");",
"av_free(buf2);",
"return -1;",
"}",
"}",
"}else if(v->interlace && ((VAR_4[0] & 0xC0) == 0xC0)){",
"const uint8_t *VAR_11;",
"VAR_11 = find_next_marker(VAR_4, VAR_4 + VAR_5);",
"if((VAR_11 == (VAR_4 + VAR_5)) || AV_RB32(VAR_11) != VC1_CODE_FIELD){",
"av_log(VAR_0, AV_LOG_ERROR, \"Error in WVC1 interlaced frame\\n\");",
"av_free(buf2);",
"return -1;",
"}",
"VAR_8 = vc1_unescape_buffer(VAR_4, VAR_11 - VAR_4, buf2);",
"av_free(buf2);return -1;",
"}else{",
"VAR_8 = vc1_unescape_buffer(VAR_4, VAR_5, buf2);",
"}",
"init_get_bits(&s->gb, buf2, VAR_8*8);",
"} else",
"init_get_bits(&s->gb, VAR_4, VAR_5*8);",
"if(v->profile < PROFILE_ADVANCED) {",
"if(vc1_parse_frame_header(v, &s->gb) == -1) {",
"av_free(buf2);",
"return -1;",
"}",
"} else {",
"if(vc1_parse_frame_header_adv(v, &s->gb) == -1) {",
"av_free(buf2);",
"return -1;",
"}",
"}",
"if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){",
"av_free(buf2);",
"return -1;",
"}",
"s->current_picture.pict_type= s->pict_type;",
"s->current_picture.key_frame= s->pict_type == FF_I_TYPE;",
"if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){",
"av_free(buf2);",
"return -1;",
"}",
"if(VAR_0->hurry_up && s->pict_type==FF_B_TYPE) return -1;",
"if( (VAR_0->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE)\n|| (VAR_0->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE)\n|| VAR_0->skip_frame >= AVDISCARD_ALL) {",
"av_free(buf2);",
"return VAR_5;",
"}",
"if(VAR_0->hurry_up>=5) {",
"av_free(buf2);",
"return -1;",
"}",
"if(s->next_p_frame_damaged){",
"if(s->pict_type==FF_B_TYPE)\nreturn VAR_5;",
"else\ns->next_p_frame_damaged=0;",
"}",
"if(MPV_frame_start(s, VAR_0) < 0) {",
"av_free(buf2);",
"return -1;",
"}",
"s->me.qpel_put= s->dsp.put_qpel_pixels_tab;",
"s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;",
"if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)\n&&s->VAR_0->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)\nff_vdpau_vc1_decode_picture(s, VAR_6, (VAR_4 + VAR_5) - VAR_6);",
"else if (VAR_0->hwaccel) {",
"if (VAR_0->hwaccel->start_frame(VAR_0, VAR_4, VAR_5) < 0)\nreturn -1;",
"if (VAR_0->hwaccel->decode_slice(VAR_0, VAR_6, (VAR_4 + VAR_5) - VAR_6) < 0)\nreturn -1;",
"if (VAR_0->hwaccel->end_frame(VAR_0) < 0)\nreturn -1;",
"} else {",
"ff_er_frame_start(s);",
"v->bits = VAR_5 * 8;",
"vc1_decode_blocks(v);",
"ff_er_frame_end(s);",
"}",
"MPV_frame_end(s);",
"assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);",
"assert(s->current_picture.pict_type == s->pict_type);",
"if (s->pict_type == FF_B_TYPE || s->low_delay) {",
"*pict= *(AVFrame*)s->current_picture_ptr;",
"} else if (s->last_picture_ptr != NULL) {",
"*pict= *(AVFrame*)s->last_picture_ptr;",
"}",
"if(s->last_picture_ptr || s->low_delay){",
"*VAR_2 = sizeof(AVFrame);",
"ff_print_debug_info(s, pict);",
"}",
"av_free(buf2);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91
],
[
93
],
[
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
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
207
],
[
209
],
[
211
],
[
213
],
[
219
],
[
221
],
[
227
],
[
229
],
[
231
],
[
233
],
[
237
],
[
239,
241,
243
],
[
245
],
[
247
],
[
249
],
[
253
],
[
255
],
[
257
],
[
259
],
[
263
],
[
265,
267
],
[
269,
271
],
[
273
],
[
277
],
[
279
],
[
281
],
[
283
],
[
287
],
[
289
],
[
293,
295,
297
],
[
299
],
[
301,
303
],
[
305,
307
],
[
309,
311
],
[
313
],
[
315
],
[
319
],
[
321
],
[
329
],
[
331
],
[
335
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
359
],
[
361
],
[
365
],
[
367
],
[
369
]
] |
1,270 | static void ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i++){
if(nnzc[ scan8[i] ])
ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
else if(block[i*16])
ff_h264_idct_dc_add_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| false | FFmpeg | 1d16a1cf99488f16492b1bb48e023f4da8377e07 | static void ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=16; i<16+8; i++){
if(nnzc[ scan8[i] ])
ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
else if(block[i*16])
ff_h264_idct_dc_add_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t **VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){
int VAR_5;
for(VAR_5=16; VAR_5<16+8; VAR_5++){
if(VAR_4[ scan8[VAR_5] ])
ff_h264_idct_add_mmx (VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);
else if(VAR_2[VAR_5*16])
ff_h264_idct_dc_add_mmx2(VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);
}
}
| [
"static void FUNC_0(uint8_t **VAR_0, const int *VAR_1, DCTELEM *VAR_2, int VAR_3, const uint8_t VAR_4[6*8]){",
"int VAR_5;",
"for(VAR_5=16; VAR_5<16+8; VAR_5++){",
"if(VAR_4[ scan8[VAR_5] ])\nff_h264_idct_add_mmx (VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);",
"else if(VAR_2[VAR_5*16])\nff_h264_idct_dc_add_mmx2(VAR_0[(VAR_5&4)>>2] + VAR_1[VAR_5], VAR_2 + VAR_5*16, VAR_3);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
]
] |
1,271 | int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
{
if (len > 6) {
/* check for h264 start code */
if (AV_RB32(data) == 0x00000001 ||
AV_RB24(data) == 0x000001) {
uint8_t *buf=NULL, *end, *start;
uint32_t sps_size=0, pps_size=0;
uint8_t *sps=0, *pps=0;
int ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
if (ret < 0)
return ret;
start = buf;
end = buf + len;
/* look for sps and pps */
while (buf < end) {
unsigned int size;
uint8_t nal_type;
size = AV_RB32(buf);
nal_type = buf[4] & 0x1f;
if (nal_type == 7) { /* SPS */
sps = buf + 4;
sps_size = size;
} else if (nal_type == 8) { /* PPS */
pps = buf + 4;
pps_size = size;
}
buf += size + 4;
}
assert(sps);
assert(pps);
avio_w8(pb, 1); /* version */
avio_w8(pb, sps[1]); /* profile */
avio_w8(pb, sps[2]); /* profile compat */
avio_w8(pb, sps[3]); /* level */
avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
avio_wb16(pb, sps_size);
avio_write(pb, sps, sps_size);
avio_w8(pb, 1); /* number of pps */
avio_wb16(pb, pps_size);
avio_write(pb, pps, pps_size);
av_free(start);
} else {
avio_write(pb, data, len);
}
}
return 0;
}
| false | FFmpeg | 6c643e070584ba7af251d3907e277d2170537b1f | int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
{
if (len > 6) {
if (AV_RB32(data) == 0x00000001 ||
AV_RB24(data) == 0x000001) {
uint8_t *buf=NULL, *end, *start;
uint32_t sps_size=0, pps_size=0;
uint8_t *sps=0, *pps=0;
int ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
if (ret < 0)
return ret;
start = buf;
end = buf + len;
while (buf < end) {
unsigned int size;
uint8_t nal_type;
size = AV_RB32(buf);
nal_type = buf[4] & 0x1f;
if (nal_type == 7) {
sps = buf + 4;
sps_size = size;
} else if (nal_type == 8) {
pps = buf + 4;
pps_size = size;
}
buf += size + 4;
}
assert(sps);
assert(pps);
avio_w8(pb, 1);
avio_w8(pb, sps[1]);
avio_w8(pb, sps[2]);
avio_w8(pb, sps[3]);
avio_w8(pb, 0xff);
avio_w8(pb, 0xe1);
avio_wb16(pb, sps_size);
avio_write(pb, sps, sps_size);
avio_w8(pb, 1);
avio_wb16(pb, pps_size);
avio_write(pb, pps, pps_size);
av_free(start);
} else {
avio_write(pb, data, len);
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVIOContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{
if (VAR_2 > 6) {
if (AV_RB32(VAR_1) == 0x00000001 ||
AV_RB24(VAR_1) == 0x000001) {
uint8_t *buf=NULL, *end, *start;
uint32_t sps_size=0, pps_size=0;
uint8_t *sps=0, *pps=0;
int VAR_3 = ff_avc_parse_nal_units_buf(VAR_1, &buf, &VAR_2);
if (VAR_3 < 0)
return VAR_3;
start = buf;
end = buf + VAR_2;
while (buf < end) {
unsigned int VAR_4;
uint8_t nal_type;
VAR_4 = AV_RB32(buf);
nal_type = buf[4] & 0x1f;
if (nal_type == 7) {
sps = buf + 4;
sps_size = VAR_4;
} else if (nal_type == 8) {
pps = buf + 4;
pps_size = VAR_4;
}
buf += VAR_4 + 4;
}
assert(sps);
assert(pps);
avio_w8(VAR_0, 1);
avio_w8(VAR_0, sps[1]);
avio_w8(VAR_0, sps[2]);
avio_w8(VAR_0, sps[3]);
avio_w8(VAR_0, 0xff);
avio_w8(VAR_0, 0xe1);
avio_wb16(VAR_0, sps_size);
avio_write(VAR_0, sps, sps_size);
avio_w8(VAR_0, 1);
avio_wb16(VAR_0, pps_size);
avio_write(VAR_0, pps, pps_size);
av_free(start);
} else {
avio_write(VAR_0, VAR_1, VAR_2);
}
}
return 0;
}
| [
"int FUNC_0(AVIOContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{",
"if (VAR_2 > 6) {",
"if (AV_RB32(VAR_1) == 0x00000001 ||\nAV_RB24(VAR_1) == 0x000001) {",
"uint8_t *buf=NULL, *end, *start;",
"uint32_t sps_size=0, pps_size=0;",
"uint8_t *sps=0, *pps=0;",
"int VAR_3 = ff_avc_parse_nal_units_buf(VAR_1, &buf, &VAR_2);",
"if (VAR_3 < 0)\nreturn VAR_3;",
"start = buf;",
"end = buf + VAR_2;",
"while (buf < end) {",
"unsigned int VAR_4;",
"uint8_t nal_type;",
"VAR_4 = AV_RB32(buf);",
"nal_type = buf[4] & 0x1f;",
"if (nal_type == 7) {",
"sps = buf + 4;",
"sps_size = VAR_4;",
"} else if (nal_type == 8) {",
"pps = buf + 4;",
"pps_size = VAR_4;",
"}",
"buf += VAR_4 + 4;",
"}",
"assert(sps);",
"assert(pps);",
"avio_w8(VAR_0, 1);",
"avio_w8(VAR_0, sps[1]);",
"avio_w8(VAR_0, sps[2]);",
"avio_w8(VAR_0, sps[3]);",
"avio_w8(VAR_0, 0xff);",
"avio_w8(VAR_0, 0xe1);",
"avio_wb16(VAR_0, sps_size);",
"avio_write(VAR_0, sps, sps_size);",
"avio_w8(VAR_0, 1);",
"avio_wb16(VAR_0, pps_size);",
"avio_write(VAR_0, pps, pps_size);",
"av_free(start);",
"} else {",
"avio_write(VAR_0, VAR_1, VAR_2);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
21
],
[
23,
25
],
[
27
],
[
29
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
]
] |
1,272 | static void uninit(struct vf_instance *vf)
{
free(vf->priv);
}
| false | FFmpeg | 04001767728fd4ed8b4f9d2ebbb9f9a8c9a7be0d | static void uninit(struct vf_instance *vf)
{
free(vf->priv);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(struct vf_instance *VAR_0)
{
free(VAR_0->priv);
}
| [
"static void FUNC_0(struct vf_instance *VAR_0)\n{",
"free(VAR_0->priv);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,273 | static ExitStatus trans_fop_dew_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_dew(ctx, rt, ra, di->f_dew);
}
| true | qemu | eff235eb2bcd7092901f4698a7907e742f3b7f2f | static ExitStatus trans_fop_dew_0c(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned rt = extract32(insn, 0, 5);
unsigned ra = extract32(insn, 21, 5);
return do_fop_dew(ctx, rt, ra, di->f_dew);
}
| {
"code": [
" return do_fop_dew(ctx, rt, ra, di->f_dew);",
" return do_fop_dew(ctx, rt, ra, di->f_dew);"
],
"line_no": [
11,
11
]
} | static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn,
const DisasInsn *di)
{
unsigned VAR_0 = extract32(insn, 0, 5);
unsigned VAR_1 = extract32(insn, 21, 5);
return do_fop_dew(ctx, VAR_0, VAR_1, di->f_dew);
}
| [
"static ExitStatus FUNC_0(DisasContext *ctx, uint32_t insn,\nconst DisasInsn *di)\n{",
"unsigned VAR_0 = extract32(insn, 0, 5);",
"unsigned VAR_1 = extract32(insn, 21, 5);",
"return do_fop_dew(ctx, VAR_0, VAR_1, di->f_dew);",
"}"
] | [
0,
0,
0,
1,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
1,276 | static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret);
QDECREF(req);
}
| true | qemu | 2a7a1a56d1e30de07cf7d7636a35bf7706b9500e | static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret);
QDECREF(req);
}
| {
"code": [
" QDECREF(ret);"
],
"line_no": [
71
]
} | static void FUNC_0(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QInt *ret3;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict");
assert(!strcmp(qdict_get_str(ret_dict, "string"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put(args3, "a", qint_from_int(66));
qdict_put(req, "arguments", args3);
qdict_put(req, "execute", qstring_from_str("user_def_cmd3"));
ret3 = qobject_to_qint(test_qmp_dispatch(req));
assert(qint_get_int(ret3) == 66);
QDECREF(ret);
QDECREF(req);
}
| [
"static void FUNC_0(void)\n{",
"QDict *req = qdict_new();",
"QDict *args = qdict_new();",
"QDict *args3 = qdict_new();",
"QDict *ud1a = qdict_new();",
"QDict *ud1b = qdict_new();",
"QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;",
"QDict *ret_dict_dict2, *ret_dict_dict2_userdef;",
"QInt *ret3;",
"qdict_put_obj(ud1a, \"integer\", QOBJECT(qint_from_int(42)));",
"qdict_put_obj(ud1a, \"string\", QOBJECT(qstring_from_str(\"hello\")));",
"qdict_put_obj(ud1b, \"integer\", QOBJECT(qint_from_int(422)));",
"qdict_put_obj(ud1b, \"string\", QOBJECT(qstring_from_str(\"hello2\")));",
"qdict_put_obj(args, \"ud1a\", QOBJECT(ud1a));",
"qdict_put_obj(args, \"ud1b\", QOBJECT(ud1b));",
"qdict_put_obj(req, \"arguments\", QOBJECT(args));",
"qdict_put_obj(req, \"execute\", QOBJECT(qstring_from_str(\"user_def_cmd2\")));",
"ret = qobject_to_qdict(test_qmp_dispatch(req));",
"assert(!strcmp(qdict_get_str(ret, \"string\"), \"blah1\"));",
"ret_dict = qdict_get_qdict(ret, \"dict\");",
"assert(!strcmp(qdict_get_str(ret_dict, \"string\"), \"blah2\"));",
"ret_dict_dict = qdict_get_qdict(ret_dict, \"dict\");",
"ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, \"userdef\");",
"assert(qdict_get_int(ret_dict_dict_userdef, \"integer\") == 42);",
"assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, \"string\"), \"hello\"));",
"assert(!strcmp(qdict_get_str(ret_dict_dict, \"string\"), \"blah3\"));",
"ret_dict_dict2 = qdict_get_qdict(ret_dict, \"dict2\");",
"ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, \"userdef\");",
"assert(qdict_get_int(ret_dict_dict2_userdef, \"integer\") == 422);",
"assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, \"string\"), \"hello2\"));",
"assert(!strcmp(qdict_get_str(ret_dict_dict2, \"string\"), \"blah4\"));",
"QDECREF(ret);",
"qdict_put(args3, \"a\", qint_from_int(66));",
"qdict_put(req, \"arguments\", args3);",
"qdict_put(req, \"execute\", qstring_from_str(\"user_def_cmd3\"));",
"ret3 = qobject_to_qint(test_qmp_dispatch(req));",
"assert(qint_get_int(ret3) == 66);",
"QDECREF(ret);",
"QDECREF(req);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
1,279 | int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BdrvTrackedRequest req;
int max_discard, ret;
if (!bs->drv) {
return -ENOMEDIUM;
}
ret = bdrv_check_request(bs, sector_num, nb_sectors);
if (ret < 0) {
return ret;
} else if (bs->read_only) {
return -EPERM;
}
assert(!(bs->open_flags & BDRV_O_INACTIVE));
/* Do nothing if disabled. */
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0;
}
if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {
return 0;
}
tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,
nb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
if (ret < 0) {
goto out;
}
max_discard = MIN_NON_ZERO(bs->bl.max_pdiscard >> BDRV_SECTOR_BITS,
BDRV_REQUEST_MAX_SECTORS);
while (nb_sectors > 0) {
int ret;
int num = nb_sectors;
int discard_alignment = bs->bl.pdiscard_alignment >> BDRV_SECTOR_BITS;
/* align request */
if (discard_alignment &&
num >= discard_alignment &&
sector_num % discard_alignment) {
if (num > discard_alignment) {
num = discard_alignment;
}
num -= sector_num % discard_alignment;
}
/* limit request size */
if (num > max_discard) {
num = max_discard;
}
if (bs->drv->bdrv_co_discard) {
ret = bs->drv->bdrv_co_discard(bs, sector_num, num);
} else {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,
bdrv_co_io_em_complete, &co);
if (acb == NULL) {
ret = -EIO;
goto out;
} else {
qemu_coroutine_yield();
ret = co.ret;
}
}
if (ret && ret != -ENOTSUP) {
goto out;
}
sector_num += num;
nb_sectors -= num;
}
ret = 0;
out:
bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
req.bytes >> BDRV_SECTOR_BITS);
tracked_request_end(&req);
return ret;
} | true | qemu | 3ff2f67a7c24183fcbcfe1332e5223ac6f96438c | int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BdrvTrackedRequest req;
int max_discard, ret;
if (!bs->drv) {
return -ENOMEDIUM;
}
ret = bdrv_check_request(bs, sector_num, nb_sectors);
if (ret < 0) {
return ret;
} else if (bs->read_only) {
return -EPERM;
}
assert(!(bs->open_flags & BDRV_O_INACTIVE));
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0;
}
if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {
return 0;
}
tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,
nb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
if (ret < 0) {
goto out;
}
max_discard = MIN_NON_ZERO(bs->bl.max_pdiscard >> BDRV_SECTOR_BITS,
BDRV_REQUEST_MAX_SECTORS);
while (nb_sectors > 0) {
int ret;
int num = nb_sectors;
int discard_alignment = bs->bl.pdiscard_alignment >> BDRV_SECTOR_BITS;
if (discard_alignment &&
num >= discard_alignment &&
sector_num % discard_alignment) {
if (num > discard_alignment) {
num = discard_alignment;
}
num -= sector_num % discard_alignment;
}
if (num > max_discard) {
num = max_discard;
}
if (bs->drv->bdrv_co_discard) {
ret = bs->drv->bdrv_co_discard(bs, sector_num, num);
} else {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,
bdrv_co_io_em_complete, &co);
if (acb == NULL) {
ret = -EIO;
goto out;
} else {
qemu_coroutine_yield();
ret = co.ret;
}
}
if (ret && ret != -ENOTSUP) {
goto out;
}
sector_num += num;
nb_sectors -= num;
}
ret = 0;
out:
bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
req.bytes >> BDRV_SECTOR_BITS);
tracked_request_end(&req);
return ret;
} | {
"code": [],
"line_no": []
} | int VAR_0 bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BdrvTrackedRequest req;
int max_discard, ret;
if (!bs->drv) {
return -ENOMEDIUM;
}
ret = bdrv_check_request(bs, sector_num, nb_sectors);
if (ret < 0) {
return ret;
} else if (bs->read_only) {
return -EPERM;
}
assert(!(bs->open_flags & BDRV_O_INACTIVE));
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0;
}
if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {
return 0;
}
tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,
nb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
if (ret < 0) {
goto out;
}
max_discard = MIN_NON_ZERO(bs->bl.max_pdiscard >> BDRV_SECTOR_BITS,
BDRV_REQUEST_MAX_SECTORS);
while (nb_sectors > 0) {
int ret;
int num = nb_sectors;
int discard_alignment = bs->bl.pdiscard_alignment >> BDRV_SECTOR_BITS;
if (discard_alignment &&
num >= discard_alignment &&
sector_num % discard_alignment) {
if (num > discard_alignment) {
num = discard_alignment;
}
num -= sector_num % discard_alignment;
}
if (num > max_discard) {
num = max_discard;
}
if (bs->drv->bdrv_co_discard) {
ret = bs->drv->bdrv_co_discard(bs, sector_num, num);
} else {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,
bdrv_co_io_em_complete, &co);
if (acb == NULL) {
ret = -EIO;
goto out;
} else {
qemu_coroutine_yield();
ret = co.ret;
}
}
if (ret && ret != -ENOTSUP) {
goto out;
}
sector_num += num;
nb_sectors -= num;
}
ret = 0;
out:
bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
req.bytes >> BDRV_SECTOR_BITS);
tracked_request_end(&req);
return ret;
} | [
"int VAR_0 bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,\nint nb_sectors)\n{",
"BdrvTrackedRequest req;",
"int max_discard, ret;",
"if (!bs->drv) {",
"return -ENOMEDIUM;",
"}",
"ret = bdrv_check_request(bs, sector_num, nb_sectors);",
"if (ret < 0) {",
"return ret;",
"} else if (bs->read_only) {",
"return -EPERM;",
"}",
"assert(!(bs->open_flags & BDRV_O_INACTIVE));",
"if (!(bs->open_flags & BDRV_O_UNMAP)) {",
"return 0;",
"}",
"if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {",
"return 0;",
"}",
"tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,\nnb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);",
"ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);",
"if (ret < 0) {",
"goto out;",
"}",
"max_discard = MIN_NON_ZERO(bs->bl.max_pdiscard >> BDRV_SECTOR_BITS,\nBDRV_REQUEST_MAX_SECTORS);",
"while (nb_sectors > 0) {",
"int ret;",
"int num = nb_sectors;",
"int discard_alignment = bs->bl.pdiscard_alignment >> BDRV_SECTOR_BITS;",
"if (discard_alignment &&\nnum >= discard_alignment &&\nsector_num % discard_alignment) {",
"if (num > discard_alignment) {",
"num = discard_alignment;",
"}",
"num -= sector_num % discard_alignment;",
"}",
"if (num > max_discard) {",
"num = max_discard;",
"}",
"if (bs->drv->bdrv_co_discard) {",
"ret = bs->drv->bdrv_co_discard(bs, sector_num, num);",
"} else {",
"BlockAIOCB *acb;",
"CoroutineIOCompletion co = {",
".coroutine = qemu_coroutine_self(),\n};",
"acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,\nbdrv_co_io_em_complete, &co);",
"if (acb == NULL) {",
"ret = -EIO;",
"goto out;",
"} else {",
"qemu_coroutine_yield();",
"ret = co.ret;",
"}",
"}",
"if (ret && ret != -ENOTSUP) {",
"goto out;",
"}",
"sector_num += num;",
"nb_sectors -= num;",
"}",
"ret = 0;",
"out:\nbdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,\nreq.bytes >> BDRV_SECTOR_BITS);",
"tracked_request_end(&req);",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55,
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
87,
89,
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125,
127
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167,
170,
172
],
[
174
],
[
176
],
[
178
]
] |
1,280 | static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt1)
{
CCW0 tmp0;
CCW1 tmp1;
CCW1 ret;
if (fmt1) {
cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));
ret.cmd_code = tmp1.cmd_code;
ret.flags = tmp1.flags;
ret.count = be16_to_cpu(tmp1.count);
ret.cda = be32_to_cpu(tmp1.cda);
} else {
cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));
ret.cmd_code = tmp0.cmd_code;
ret.flags = tmp0.flags;
ret.count = be16_to_cpu(tmp0.count);
ret.cda = be16_to_cpu(tmp0.cda1) | (tmp0.cda0 << 16);
if ((ret.cmd_code & 0x0f) == CCW_CMD_TIC) {
ret.cmd_code &= 0x0f;
}
}
return ret;
}
| false | qemu | 9f94f84ce7df633142953806cc4c102765cabc0e | static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt1)
{
CCW0 tmp0;
CCW1 tmp1;
CCW1 ret;
if (fmt1) {
cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));
ret.cmd_code = tmp1.cmd_code;
ret.flags = tmp1.flags;
ret.count = be16_to_cpu(tmp1.count);
ret.cda = be32_to_cpu(tmp1.cda);
} else {
cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));
ret.cmd_code = tmp0.cmd_code;
ret.flags = tmp0.flags;
ret.count = be16_to_cpu(tmp0.count);
ret.cda = be16_to_cpu(tmp0.cda1) | (tmp0.cda0 << 16);
if ((ret.cmd_code & 0x0f) == CCW_CMD_TIC) {
ret.cmd_code &= 0x0f;
}
}
return ret;
}
| {
"code": [],
"line_no": []
} | static CCW1 FUNC_0(hwaddr addr, bool fmt1)
{
CCW0 tmp0;
CCW1 tmp1;
CCW1 ret;
if (fmt1) {
cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));
ret.cmd_code = tmp1.cmd_code;
ret.flags = tmp1.flags;
ret.count = be16_to_cpu(tmp1.count);
ret.cda = be32_to_cpu(tmp1.cda);
} else {
cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));
ret.cmd_code = tmp0.cmd_code;
ret.flags = tmp0.flags;
ret.count = be16_to_cpu(tmp0.count);
ret.cda = be16_to_cpu(tmp0.cda1) | (tmp0.cda0 << 16);
if ((ret.cmd_code & 0x0f) == CCW_CMD_TIC) {
ret.cmd_code &= 0x0f;
}
}
return ret;
}
| [
"static CCW1 FUNC_0(hwaddr addr, bool fmt1)\n{",
"CCW0 tmp0;",
"CCW1 tmp1;",
"CCW1 ret;",
"if (fmt1) {",
"cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));",
"ret.cmd_code = tmp1.cmd_code;",
"ret.flags = tmp1.flags;",
"ret.count = be16_to_cpu(tmp1.count);",
"ret.cda = be32_to_cpu(tmp1.cda);",
"} else {",
"cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));",
"ret.cmd_code = tmp0.cmd_code;",
"ret.flags = tmp0.flags;",
"ret.count = be16_to_cpu(tmp0.count);",
"ret.cda = be16_to_cpu(tmp0.cda1) | (tmp0.cda0 << 16);",
"if ((ret.cmd_code & 0x0f) == CCW_CMD_TIC) {",
"ret.cmd_code &= 0x0f;",
"}",
"}",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
]
] |
1,281 | static int tosa_dac_init(I2CSlave *i2c)
{
/* Nothing to do. */
return 0;
}
| false | qemu | 9e41bade85ef338afd983c109368d1bbbe931f80 | static int tosa_dac_init(I2CSlave *i2c)
{
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(I2CSlave *VAR_0)
{
return 0;
}
| [
"static int FUNC_0(I2CSlave *VAR_0)\n{",
"return 0;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
7
],
[
9
]
] |
1,282 | CharDriverState *qemu_chr_open_eventfd(int eventfd)
{
CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
if (chr) {
chr->avail_connections = 1;
}
return chr;
}
| false | qemu | d0d7708ba29cbcc343364a46bff981e0ff88366f | CharDriverState *qemu_chr_open_eventfd(int eventfd)
{
CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
if (chr) {
chr->avail_connections = 1;
}
return chr;
}
| {
"code": [],
"line_no": []
} | CharDriverState *FUNC_0(int eventfd)
{
CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
if (chr) {
chr->avail_connections = 1;
}
return chr;
}
| [
"CharDriverState *FUNC_0(int eventfd)\n{",
"CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);",
"if (chr) {",
"chr->avail_connections = 1;",
"}",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
]
] |
1,283 | static CharDriverState *qmp_chardev_open_socket(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
CharDriverState *chr;
TCPCharDriver *s;
ChardevSocket *sock = backend->u.socket;
SocketAddress *addr = sock->addr;
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
bool is_listen = sock->has_server ? sock->server : true;
bool is_telnet = sock->has_telnet ? sock->telnet : false;
bool is_waitconnect = sock->has_wait ? sock->wait : false;
int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0;
ChardevCommon *common = qapi_ChardevSocket_base(sock);
QIOChannelSocket *sioc = NULL;
chr = qemu_chr_alloc(common, errp);
if (!chr) {
return NULL;
}
s = g_new0(TCPCharDriver, 1);
s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX;
s->is_listen = is_listen;
s->is_telnet = is_telnet;
s->do_nodelay = do_nodelay;
if (sock->tls_creds) {
Object *creds;
creds = object_resolve_path_component(
object_get_objects_root(), sock->tls_creds);
if (!creds) {
error_setg(errp, "No TLS credentials with id '%s'",
sock->tls_creds);
goto error;
}
s->tls_creds = (QCryptoTLSCreds *)
object_dynamic_cast(creds,
TYPE_QCRYPTO_TLS_CREDS);
if (!s->tls_creds) {
error_setg(errp, "Object with id '%s' is not TLS credentials",
sock->tls_creds);
goto error;
}
object_ref(OBJECT(s->tls_creds));
if (is_listen) {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
error_setg(errp, "%s",
"Expected TLS credentials for server endpoint");
goto error;
}
} else {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
error_setg(errp, "%s",
"Expected TLS credentials for client endpoint");
goto error;
}
}
}
qapi_copy_SocketAddress(&s->addr, sock->addr);
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
/* be isn't opened until we get a connection */
chr->explicit_be_open = true;
chr->filename = SocketAddress_to_str("disconnected:",
addr, is_listen, is_telnet);
if (is_listen) {
if (is_telnet) {
s->do_telnetopt = 1;
}
} else if (reconnect > 0) {
s->reconnect_time = reconnect;
}
sioc = qio_channel_socket_new();
if (s->reconnect_time) {
qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected,
chr, NULL);
} else if (s->is_listen) {
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto error;
}
s->listen_ioc = sioc;
if (is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
}
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
if (!s->ioc) {
s->listen_tag = qio_channel_add_watch(
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
}
} else {
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
goto error;
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
}
return chr;
error:
if (sioc) {
object_unref(OBJECT(sioc));
}
if (s->tls_creds) {
object_unref(OBJECT(s->tls_creds));
}
g_free(s);
qemu_chr_free_common(chr);
return NULL;
}
| false | qemu | 32bafa8fdd098d52fbf1102d5a5e48d29398c0aa | static CharDriverState *qmp_chardev_open_socket(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
CharDriverState *chr;
TCPCharDriver *s;
ChardevSocket *sock = backend->u.socket;
SocketAddress *addr = sock->addr;
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
bool is_listen = sock->has_server ? sock->server : true;
bool is_telnet = sock->has_telnet ? sock->telnet : false;
bool is_waitconnect = sock->has_wait ? sock->wait : false;
int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0;
ChardevCommon *common = qapi_ChardevSocket_base(sock);
QIOChannelSocket *sioc = NULL;
chr = qemu_chr_alloc(common, errp);
if (!chr) {
return NULL;
}
s = g_new0(TCPCharDriver, 1);
s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX;
s->is_listen = is_listen;
s->is_telnet = is_telnet;
s->do_nodelay = do_nodelay;
if (sock->tls_creds) {
Object *creds;
creds = object_resolve_path_component(
object_get_objects_root(), sock->tls_creds);
if (!creds) {
error_setg(errp, "No TLS credentials with id '%s'",
sock->tls_creds);
goto error;
}
s->tls_creds = (QCryptoTLSCreds *)
object_dynamic_cast(creds,
TYPE_QCRYPTO_TLS_CREDS);
if (!s->tls_creds) {
error_setg(errp, "Object with id '%s' is not TLS credentials",
sock->tls_creds);
goto error;
}
object_ref(OBJECT(s->tls_creds));
if (is_listen) {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
error_setg(errp, "%s",
"Expected TLS credentials for server endpoint");
goto error;
}
} else {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
error_setg(errp, "%s",
"Expected TLS credentials for client endpoint");
goto error;
}
}
}
qapi_copy_SocketAddress(&s->addr, sock->addr);
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
chr->explicit_be_open = true;
chr->filename = SocketAddress_to_str("disconnected:",
addr, is_listen, is_telnet);
if (is_listen) {
if (is_telnet) {
s->do_telnetopt = 1;
}
} else if (reconnect > 0) {
s->reconnect_time = reconnect;
}
sioc = qio_channel_socket_new();
if (s->reconnect_time) {
qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected,
chr, NULL);
} else if (s->is_listen) {
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto error;
}
s->listen_ioc = sioc;
if (is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
}
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
if (!s->ioc) {
s->listen_tag = qio_channel_add_watch(
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
}
} else {
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
goto error;
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
}
return chr;
error:
if (sioc) {
object_unref(OBJECT(sioc));
}
if (s->tls_creds) {
object_unref(OBJECT(s->tls_creds));
}
g_free(s);
qemu_chr_free_common(chr);
return NULL;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
Error **errp)
{
CharDriverState *chr;
TCPCharDriver *s;
ChardevSocket *sock = backend->u.socket;
SocketAddress *addr = sock->addr;
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
bool is_listen = sock->has_server ? sock->server : true;
bool is_telnet = sock->has_telnet ? sock->telnet : false;
bool is_waitconnect = sock->has_wait ? sock->wait : false;
int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0;
ChardevCommon *common = qapi_ChardevSocket_base(sock);
QIOChannelSocket *sioc = NULL;
chr = qemu_chr_alloc(common, errp);
if (!chr) {
return NULL;
}
s = g_new0(TCPCharDriver, 1);
s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX;
s->is_listen = is_listen;
s->is_telnet = is_telnet;
s->do_nodelay = do_nodelay;
if (sock->tls_creds) {
Object *creds;
creds = object_resolve_path_component(
object_get_objects_root(), sock->tls_creds);
if (!creds) {
error_setg(errp, "No TLS credentials with id '%s'",
sock->tls_creds);
goto error;
}
s->tls_creds = (QCryptoTLSCreds *)
object_dynamic_cast(creds,
TYPE_QCRYPTO_TLS_CREDS);
if (!s->tls_creds) {
error_setg(errp, "Object with id '%s' is not TLS credentials",
sock->tls_creds);
goto error;
}
object_ref(OBJECT(s->tls_creds));
if (is_listen) {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
error_setg(errp, "%s",
"Expected TLS credentials for server endpoint");
goto error;
}
} else {
if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
error_setg(errp, "%s",
"Expected TLS credentials for client endpoint");
goto error;
}
}
}
qapi_copy_SocketAddress(&s->addr, sock->addr);
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
chr->chr_add_watch = tcp_chr_add_watch;
chr->chr_update_read_handler = tcp_chr_update_read_handler;
chr->explicit_be_open = true;
chr->filename = SocketAddress_to_str("disconnected:",
addr, is_listen, is_telnet);
if (is_listen) {
if (is_telnet) {
s->do_telnetopt = 1;
}
} else if (reconnect > 0) {
s->reconnect_time = reconnect;
}
sioc = qio_channel_socket_new();
if (s->reconnect_time) {
qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected,
chr, NULL);
} else if (s->is_listen) {
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto error;
}
s->listen_ioc = sioc;
if (is_waitconnect) {
fprintf(stderr, "QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
}
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
if (!s->ioc) {
s->listen_tag = qio_channel_add_watch(
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
}
} else {
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
goto error;
}
tcp_chr_new_client(chr, sioc);
object_unref(OBJECT(sioc));
}
return chr;
error:
if (sioc) {
object_unref(OBJECT(sioc));
}
if (s->tls_creds) {
object_unref(OBJECT(s->tls_creds));
}
g_free(s);
qemu_chr_free_common(chr);
return NULL;
}
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevBackend *backend,\nChardevReturn *ret,\nError **errp)\n{",
"CharDriverState *chr;",
"TCPCharDriver *s;",
"ChardevSocket *sock = backend->u.socket;",
"SocketAddress *addr = sock->addr;",
"bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;",
"bool is_listen = sock->has_server ? sock->server : true;",
"bool is_telnet = sock->has_telnet ? sock->telnet : false;",
"bool is_waitconnect = sock->has_wait ? sock->wait : false;",
"int64_t reconnect = sock->has_reconnect ? sock->reconnect : 0;",
"ChardevCommon *common = qapi_ChardevSocket_base(sock);",
"QIOChannelSocket *sioc = NULL;",
"chr = qemu_chr_alloc(common, errp);",
"if (!chr) {",
"return NULL;",
"}",
"s = g_new0(TCPCharDriver, 1);",
"s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX;",
"s->is_listen = is_listen;",
"s->is_telnet = is_telnet;",
"s->do_nodelay = do_nodelay;",
"if (sock->tls_creds) {",
"Object *creds;",
"creds = object_resolve_path_component(\nobject_get_objects_root(), sock->tls_creds);",
"if (!creds) {",
"error_setg(errp, \"No TLS credentials with id '%s'\",\nsock->tls_creds);",
"goto error;",
"}",
"s->tls_creds = (QCryptoTLSCreds *)\nobject_dynamic_cast(creds,\nTYPE_QCRYPTO_TLS_CREDS);",
"if (!s->tls_creds) {",
"error_setg(errp, \"Object with id '%s' is not TLS credentials\",\nsock->tls_creds);",
"goto error;",
"}",
"object_ref(OBJECT(s->tls_creds));",
"if (is_listen) {",
"if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {",
"error_setg(errp, \"%s\",\n\"Expected TLS credentials for server endpoint\");",
"goto error;",
"}",
"} else {",
"if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {",
"error_setg(errp, \"%s\",\n\"Expected TLS credentials for client endpoint\");",
"goto error;",
"}",
"}",
"}",
"qapi_copy_SocketAddress(&s->addr, sock->addr);",
"chr->opaque = s;",
"chr->chr_write = tcp_chr_write;",
"chr->chr_sync_read = tcp_chr_sync_read;",
"chr->chr_close = tcp_chr_close;",
"chr->get_msgfds = tcp_get_msgfds;",
"chr->set_msgfds = tcp_set_msgfds;",
"chr->chr_add_client = tcp_chr_add_client;",
"chr->chr_add_watch = tcp_chr_add_watch;",
"chr->chr_update_read_handler = tcp_chr_update_read_handler;",
"chr->explicit_be_open = true;",
"chr->filename = SocketAddress_to_str(\"disconnected:\",\naddr, is_listen, is_telnet);",
"if (is_listen) {",
"if (is_telnet) {",
"s->do_telnetopt = 1;",
"}",
"} else if (reconnect > 0) {",
"s->reconnect_time = reconnect;",
"}",
"sioc = qio_channel_socket_new();",
"if (s->reconnect_time) {",
"qio_channel_socket_connect_async(sioc, s->addr,\nqemu_chr_socket_connected,\nchr, NULL);",
"} else if (s->is_listen) {",
"if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {",
"goto error;",
"}",
"s->listen_ioc = sioc;",
"if (is_waitconnect) {",
"fprintf(stderr, \"QEMU waiting for connection on: %s\\n\",\nchr->filename);",
"tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);",
"}",
"qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);",
"if (!s->ioc) {",
"s->listen_tag = qio_channel_add_watch(\nQIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);",
"}",
"} else {",
"if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {",
"goto error;",
"}",
"tcp_chr_new_client(chr, sioc);",
"object_unref(OBJECT(sioc));",
"}",
"return chr;",
"error:\nif (sioc) {",
"object_unref(OBJECT(sioc));",
"}",
"if (s->tls_creds) {",
"object_unref(OBJECT(s->tls_creds));",
"}",
"g_free(s);",
"qemu_chr_free_common(chr);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73,
75,
77
],
[
79
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
145
],
[
149,
151
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
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
],
[
227
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
]
] |
1,284 | uint64_t ldq_le_phys(target_phys_addr_t addr)
{
return ldq_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | uint64_t ldq_le_phys(target_phys_addr_t addr)
{
return ldq_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(target_phys_addr_t addr)
{
return ldq_phys_internal(addr, DEVICE_LITTLE_ENDIAN);
}
| [
"uint64_t FUNC_0(target_phys_addr_t addr)\n{",
"return ldq_phys_internal(addr, DEVICE_LITTLE_ENDIAN);",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,285 | static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
AVFrame *pict = data;
int i, ret;
int slice_count;
const uint8_t *slices_hdr = NULL;
av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
/* no supplementary picture */
if (buf_size == 0) {
return 0;
}
if (!avctx->slice_count) {
slice_count = (*buf++) + 1;
buf_size--;
if (!slice_count || buf_size <= 8 * slice_count) {
av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n",
slice_count);
return AVERROR_INVALIDDATA;
}
slices_hdr = buf + 4;
buf += 8 * slice_count;
buf_size -= 8 * slice_count;
} else
slice_count = avctx->slice_count;
for (i = 0; i < slice_count; i++) {
unsigned offset = get_slice_offset(avctx, slices_hdr, i);
int size, size2;
if (offset >= buf_size)
return AVERROR_INVALIDDATA;
if (i + 1 == slice_count)
size = buf_size - offset;
else
size = get_slice_offset(avctx, slices_hdr, i + 1) - offset;
if (i + 2 >= slice_count)
size2 = buf_size - offset;
else
size2 = get_slice_offset(avctx, slices_hdr, i + 2) - offset;
if (size <= 0 || size2 <= 0 ||
offset + FFMAX(size, size2) > buf_size)
return AVERROR_INVALIDDATA;
if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2)) < 0)
return ret;
if (ret > 8 * size)
i++;
}
if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {
ff_er_frame_end(&s->er);
ff_mpv_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr);
}
if (s->last_picture_ptr || s->low_delay) {
*got_frame = 1;
}
// so we can detect if frame_end was not called (find some nicer solution...)
s->current_picture_ptr = NULL;
}
return avpkt->size;
}
| false | FFmpeg | 4b1f5e5090abed6c618c8ba380cd7d28d140f867 | static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s = avctx->priv_data;
AVFrame *pict = data;
int i, ret;
int slice_count;
const uint8_t *slices_hdr = NULL;
av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
if (buf_size == 0) {
return 0;
}
if (!avctx->slice_count) {
slice_count = (*buf++) + 1;
buf_size--;
if (!slice_count || buf_size <= 8 * slice_count) {
av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n",
slice_count);
return AVERROR_INVALIDDATA;
}
slices_hdr = buf + 4;
buf += 8 * slice_count;
buf_size -= 8 * slice_count;
} else
slice_count = avctx->slice_count;
for (i = 0; i < slice_count; i++) {
unsigned offset = get_slice_offset(avctx, slices_hdr, i);
int size, size2;
if (offset >= buf_size)
return AVERROR_INVALIDDATA;
if (i + 1 == slice_count)
size = buf_size - offset;
else
size = get_slice_offset(avctx, slices_hdr, i + 1) - offset;
if (i + 2 >= slice_count)
size2 = buf_size - offset;
else
size2 = get_slice_offset(avctx, slices_hdr, i + 2) - offset;
if (size <= 0 || size2 <= 0 ||
offset + FFMAX(size, size2) > buf_size)
return AVERROR_INVALIDDATA;
if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2)) < 0)
return ret;
if (ret > 8 * size)
i++;
}
if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {
ff_er_frame_end(&s->er);
ff_mpv_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr);
}
if (s->last_picture_ptr || s->low_delay) {
*got_frame = 1;
}
s->current_picture_ptr = NULL;
}
return avpkt->size;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->VAR_11;
MpegEncContext *s = VAR_0->priv_data;
AVFrame *pict = VAR_1;
int VAR_6, VAR_7;
int VAR_8;
const uint8_t *VAR_9 = NULL;
av_dlog(VAR_0, "*****frame %d VAR_11=%d\n", VAR_0->frame_number, VAR_5);
if (VAR_5 == 0) {
return 0;
}
if (!VAR_0->VAR_8) {
VAR_8 = (*VAR_4++) + 1;
VAR_5--;
if (!VAR_8 || VAR_5 <= 8 * VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid slice count: %d.\n",
VAR_8);
return AVERROR_INVALIDDATA;
}
VAR_9 = VAR_4 + 4;
VAR_4 += 8 * VAR_8;
VAR_5 -= 8 * VAR_8;
} else
VAR_8 = VAR_0->VAR_8;
for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) {
unsigned VAR_10 = get_slice_offset(VAR_0, VAR_9, VAR_6);
int VAR_11, VAR_12;
if (VAR_10 >= VAR_5)
return AVERROR_INVALIDDATA;
if (VAR_6 + 1 == VAR_8)
VAR_11 = VAR_5 - VAR_10;
else
VAR_11 = get_slice_offset(VAR_0, VAR_9, VAR_6 + 1) - VAR_10;
if (VAR_6 + 2 >= VAR_8)
VAR_12 = VAR_5 - VAR_10;
else
VAR_12 = get_slice_offset(VAR_0, VAR_9, VAR_6 + 2) - VAR_10;
if (VAR_11 <= 0 || VAR_12 <= 0 ||
VAR_10 + FFMAX(VAR_11, VAR_12) > VAR_5)
return AVERROR_INVALIDDATA;
if ((VAR_7 = rv10_decode_packet(VAR_0, VAR_4 + VAR_10, VAR_11, VAR_12)) < 0)
return VAR_7;
if (VAR_7 > 8 * VAR_11)
VAR_6++;
}
if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {
ff_er_frame_end(&s->er);
ff_mpv_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((VAR_7 = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return VAR_7;
ff_print_debug_info(s, s->current_picture_ptr);
} else if (s->last_picture_ptr != NULL) {
if ((VAR_7 = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return VAR_7;
ff_print_debug_info(s, s->last_picture_ptr);
}
if (s->last_picture_ptr || s->low_delay) {
*VAR_2 = 1;
}
s->current_picture_ptr = NULL;
}
return VAR_3->VAR_11;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->VAR_11;",
"MpegEncContext *s = VAR_0->priv_data;",
"AVFrame *pict = VAR_1;",
"int VAR_6, VAR_7;",
"int VAR_8;",
"const uint8_t *VAR_9 = NULL;",
"av_dlog(VAR_0, \"*****frame %d VAR_11=%d\\n\", VAR_0->frame_number, VAR_5);",
"if (VAR_5 == 0) {",
"return 0;",
"}",
"if (!VAR_0->VAR_8) {",
"VAR_8 = (*VAR_4++) + 1;",
"VAR_5--;",
"if (!VAR_8 || VAR_5 <= 8 * VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid slice count: %d.\\n\",\nVAR_8);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_9 = VAR_4 + 4;",
"VAR_4 += 8 * VAR_8;",
"VAR_5 -= 8 * VAR_8;",
"} else",
"VAR_8 = VAR_0->VAR_8;",
"for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) {",
"unsigned VAR_10 = get_slice_offset(VAR_0, VAR_9, VAR_6);",
"int VAR_11, VAR_12;",
"if (VAR_10 >= VAR_5)\nreturn AVERROR_INVALIDDATA;",
"if (VAR_6 + 1 == VAR_8)\nVAR_11 = VAR_5 - VAR_10;",
"else\nVAR_11 = get_slice_offset(VAR_0, VAR_9, VAR_6 + 1) - VAR_10;",
"if (VAR_6 + 2 >= VAR_8)\nVAR_12 = VAR_5 - VAR_10;",
"else\nVAR_12 = get_slice_offset(VAR_0, VAR_9, VAR_6 + 2) - VAR_10;",
"if (VAR_11 <= 0 || VAR_12 <= 0 ||\nVAR_10 + FFMAX(VAR_11, VAR_12) > VAR_5)\nreturn AVERROR_INVALIDDATA;",
"if ((VAR_7 = rv10_decode_packet(VAR_0, VAR_4 + VAR_10, VAR_11, VAR_12)) < 0)\nreturn VAR_7;",
"if (VAR_7 > 8 * VAR_11)\nVAR_6++;",
"}",
"if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {",
"ff_er_frame_end(&s->er);",
"ff_mpv_frame_end(s);",
"if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {",
"if ((VAR_7 = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)\nreturn VAR_7;",
"ff_print_debug_info(s, s->current_picture_ptr);",
"} else if (s->last_picture_ptr != NULL) {",
"if ((VAR_7 = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)\nreturn VAR_7;",
"ff_print_debug_info(s, s->last_picture_ptr);",
"}",
"if (s->last_picture_ptr || s->low_delay) {",
"*VAR_2 = 1;",
"}",
"s->current_picture_ptr = NULL;",
"}",
"return VAR_3->VAR_11;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
77,
79
],
[
83,
85
],
[
87,
89
],
[
93,
95
],
[
97,
99
],
[
103,
105,
107
],
[
111,
113
],
[
117,
119
],
[
121
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
163
],
[
165
],
[
169
],
[
171
]
] |
1,286 | void xen_config_cleanup(void)
{
struct xs_dirs *d;
TAILQ_FOREACH(d, &xs_cleanup, list) {
xs_rm(xenstore, 0, d->xs_dir);
}
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | void xen_config_cleanup(void)
{
struct xs_dirs *d;
TAILQ_FOREACH(d, &xs_cleanup, list) {
xs_rm(xenstore, 0, d->xs_dir);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
struct xs_dirs *VAR_0;
TAILQ_FOREACH(VAR_0, &xs_cleanup, list) {
xs_rm(xenstore, 0, VAR_0->xs_dir);
}
}
| [
"void FUNC_0(void)\n{",
"struct xs_dirs *VAR_0;",
"TAILQ_FOREACH(VAR_0, &xs_cleanup, list) {",
"xs_rm(xenstore, 0, VAR_0->xs_dir);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
1,287 | uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
/* Reciprocal square root of a negative nonzero number */
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
/* sNaN reciprocal square root */
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float64_div(float64_one, farg.d, &env->fp_status);
}
return farg.ll;
}
| false | qemu | b748863a7f7d2996255dd2cb5a20e49785cc7387 | uint64_t helper_frsqrte(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float64_div(float64_one, farg.d, &env->fp_status);
}
return farg.ll;
}
| {
"code": [],
"line_no": []
} | uint64_t FUNC_0(CPUPPCState *env, uint64_t arg)
{
CPU_DoubleU farg;
farg.ll = arg;
if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);
} else {
if (unlikely(float64_is_signaling_nan(farg.d))) {
fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
}
farg.d = float64_sqrt(farg.d, &env->fp_status);
farg.d = float64_div(float64_one, farg.d, &env->fp_status);
}
return farg.ll;
}
| [
"uint64_t FUNC_0(CPUPPCState *env, uint64_t arg)\n{",
"CPU_DoubleU farg;",
"farg.ll = arg;",
"if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {",
"farg.ll = fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1);",
"} else {",
"if (unlikely(float64_is_signaling_nan(farg.d))) {",
"fload_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);",
"}",
"farg.d = float64_sqrt(farg.d, &env->fp_status);",
"farg.d = float64_div(float64_one, farg.d, &env->fp_status);",
"}",
"return farg.ll;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
1,288 | static MemTxResult vtd_mem_ir_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
int ret = 0;
MSIMessage from = {}, to = {};
from.address = (uint64_t) addr + VTD_INTERRUPT_ADDR_FIRST;
from.data = (uint32_t) value;
ret = vtd_interrupt_remap_msi(opaque, &from, &to);
if (ret) {
/* TODO: report error */
VTD_DPRINTF(GENERAL, "int remap fail for addr 0x%"PRIx64
" data 0x%"PRIx32, from.address, from.data);
/* Drop this interrupt */
return MEMTX_ERROR;
}
VTD_DPRINTF(IR, "delivering MSI 0x%"PRIx64":0x%"PRIx32
" for device sid 0x%04x",
to.address, to.data, sid);
if (dma_memory_write(&address_space_memory, to.address,
&to.data, size)) {
VTD_DPRINTF(GENERAL, "error: fail to write 0x%"PRIx64
" value 0x%"PRIx32, to.address, to.data);
}
return MEMTX_OK;
}
| false | qemu | ede9c94acf6cd1968de4188c0228b714ab871a86 | static MemTxResult vtd_mem_ir_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
int ret = 0;
MSIMessage from = {}, to = {};
from.address = (uint64_t) addr + VTD_INTERRUPT_ADDR_FIRST;
from.data = (uint32_t) value;
ret = vtd_interrupt_remap_msi(opaque, &from, &to);
if (ret) {
VTD_DPRINTF(GENERAL, "int remap fail for addr 0x%"PRIx64
" data 0x%"PRIx32, from.address, from.data);
return MEMTX_ERROR;
}
VTD_DPRINTF(IR, "delivering MSI 0x%"PRIx64":0x%"PRIx32
" for device sid 0x%04x",
to.address, to.data, sid);
if (dma_memory_write(&address_space_memory, to.address,
&to.data, size)) {
VTD_DPRINTF(GENERAL, "error: fail to write 0x%"PRIx64
" value 0x%"PRIx32, to.address, to.data);
}
return MEMTX_OK;
}
| {
"code": [],
"line_no": []
} | static MemTxResult FUNC_0(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
int VAR_0 = 0;
MSIMessage from = {}, to = {};
from.address = (uint64_t) addr + VTD_INTERRUPT_ADDR_FIRST;
from.data = (uint32_t) value;
VAR_0 = vtd_interrupt_remap_msi(opaque, &from, &to);
if (VAR_0) {
VTD_DPRINTF(GENERAL, "int remap fail for addr 0x%"PRIx64
" data 0x%"PRIx32, from.address, from.data);
return MEMTX_ERROR;
}
VTD_DPRINTF(IR, "delivering MSI 0x%"PRIx64":0x%"PRIx32
" for device sid 0x%04x",
to.address, to.data, sid);
if (dma_memory_write(&address_space_memory, to.address,
&to.data, size)) {
VTD_DPRINTF(GENERAL, "error: fail to write 0x%"PRIx64
" value 0x%"PRIx32, to.address, to.data);
}
return MEMTX_OK;
}
| [
"static MemTxResult FUNC_0(void *opaque, hwaddr addr,\nuint64_t value, unsigned size,\nMemTxAttrs attrs)\n{",
"int VAR_0 = 0;",
"MSIMessage from = {}, to = {};",
"from.address = (uint64_t) addr + VTD_INTERRUPT_ADDR_FIRST;",
"from.data = (uint32_t) value;",
"VAR_0 = vtd_interrupt_remap_msi(opaque, &from, &to);",
"if (VAR_0) {",
"VTD_DPRINTF(GENERAL, \"int remap fail for addr 0x%\"PRIx64\n\" data 0x%\"PRIx32, from.address, from.data);",
"return MEMTX_ERROR;",
"}",
"VTD_DPRINTF(IR, \"delivering MSI 0x%\"PRIx64\":0x%\"PRIx32\n\" for device sid 0x%04x\",\nto.address, to.data, sid);",
"if (dma_memory_write(&address_space_memory, to.address,\n&to.data, size)) {",
"VTD_DPRINTF(GENERAL, \"error: fail to write 0x%\"PRIx64\n\" value 0x%\"PRIx32, to.address, to.data);",
"}",
"return MEMTX_OK;",
"}"
] | [
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
],
[
33
],
[
35
],
[
39,
41,
43
],
[
47,
49
],
[
51,
53
],
[
55
],
[
59
],
[
61
]
] |
1,289 | static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
int64_t offset_in_cluster, QEMUIOVector *qiov,
int bytes)
{
int ret;
int cluster_bytes, buf_bytes;
uint8_t *cluster_buf, *compressed_data;
uint8_t *uncomp_buf;
uint32_t data_len;
VmdkGrainMarker *marker;
uLongf buf_len;
if (!extent->compressed) {
ret = bdrv_co_preadv(extent->file->bs,
cluster_offset + offset_in_cluster, bytes,
qiov, 0);
if (ret < 0) {
return ret;
}
return 0;
}
cluster_bytes = extent->cluster_sectors * 512;
/* Read two clusters in case GrainMarker + compressed data > one cluster */
buf_bytes = cluster_bytes * 2;
cluster_buf = g_malloc(buf_bytes);
uncomp_buf = g_malloc(cluster_bytes);
ret = bdrv_pread(extent->file,
cluster_offset,
cluster_buf, buf_bytes);
if (ret < 0) {
goto out;
}
compressed_data = cluster_buf;
buf_len = cluster_bytes;
data_len = cluster_bytes;
if (extent->has_marker) {
marker = (VmdkGrainMarker *)cluster_buf;
compressed_data = marker->data;
data_len = le32_to_cpu(marker->size);
}
if (!data_len || data_len > buf_bytes) {
ret = -EINVAL;
goto out;
}
ret = uncompress(uncomp_buf, &buf_len, compressed_data, data_len);
if (ret != Z_OK) {
ret = -EINVAL;
goto out;
}
if (offset_in_cluster < 0 ||
offset_in_cluster + bytes > buf_len) {
ret = -EINVAL;
goto out;
}
qemu_iovec_from_buf(qiov, 0, uncomp_buf + offset_in_cluster, bytes);
ret = 0;
out:
g_free(uncomp_buf);
g_free(cluster_buf);
return ret;
}
| false | qemu | a03ef88f77af045a2eb9629b5ce774a3fb973c5e | static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset,
int64_t offset_in_cluster, QEMUIOVector *qiov,
int bytes)
{
int ret;
int cluster_bytes, buf_bytes;
uint8_t *cluster_buf, *compressed_data;
uint8_t *uncomp_buf;
uint32_t data_len;
VmdkGrainMarker *marker;
uLongf buf_len;
if (!extent->compressed) {
ret = bdrv_co_preadv(extent->file->bs,
cluster_offset + offset_in_cluster, bytes,
qiov, 0);
if (ret < 0) {
return ret;
}
return 0;
}
cluster_bytes = extent->cluster_sectors * 512;
buf_bytes = cluster_bytes * 2;
cluster_buf = g_malloc(buf_bytes);
uncomp_buf = g_malloc(cluster_bytes);
ret = bdrv_pread(extent->file,
cluster_offset,
cluster_buf, buf_bytes);
if (ret < 0) {
goto out;
}
compressed_data = cluster_buf;
buf_len = cluster_bytes;
data_len = cluster_bytes;
if (extent->has_marker) {
marker = (VmdkGrainMarker *)cluster_buf;
compressed_data = marker->data;
data_len = le32_to_cpu(marker->size);
}
if (!data_len || data_len > buf_bytes) {
ret = -EINVAL;
goto out;
}
ret = uncompress(uncomp_buf, &buf_len, compressed_data, data_len);
if (ret != Z_OK) {
ret = -EINVAL;
goto out;
}
if (offset_in_cluster < 0 ||
offset_in_cluster + bytes > buf_len) {
ret = -EINVAL;
goto out;
}
qemu_iovec_from_buf(qiov, 0, uncomp_buf + offset_in_cluster, bytes);
ret = 0;
out:
g_free(uncomp_buf);
g_free(cluster_buf);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(VmdkExtent *VAR_0, int64_t VAR_1,
int64_t VAR_2, QEMUIOVector *VAR_3,
int VAR_4)
{
int VAR_5;
int VAR_6, VAR_7;
uint8_t *cluster_buf, *compressed_data;
uint8_t *uncomp_buf;
uint32_t data_len;
VmdkGrainMarker *marker;
uLongf buf_len;
if (!VAR_0->compressed) {
VAR_5 = bdrv_co_preadv(VAR_0->file->bs,
VAR_1 + VAR_2, VAR_4,
VAR_3, 0);
if (VAR_5 < 0) {
return VAR_5;
}
return 0;
}
VAR_6 = VAR_0->cluster_sectors * 512;
VAR_7 = VAR_6 * 2;
cluster_buf = g_malloc(VAR_7);
uncomp_buf = g_malloc(VAR_6);
VAR_5 = bdrv_pread(VAR_0->file,
VAR_1,
cluster_buf, VAR_7);
if (VAR_5 < 0) {
goto out;
}
compressed_data = cluster_buf;
buf_len = VAR_6;
data_len = VAR_6;
if (VAR_0->has_marker) {
marker = (VmdkGrainMarker *)cluster_buf;
compressed_data = marker->data;
data_len = le32_to_cpu(marker->size);
}
if (!data_len || data_len > VAR_7) {
VAR_5 = -EINVAL;
goto out;
}
VAR_5 = uncompress(uncomp_buf, &buf_len, compressed_data, data_len);
if (VAR_5 != Z_OK) {
VAR_5 = -EINVAL;
goto out;
}
if (VAR_2 < 0 ||
VAR_2 + VAR_4 > buf_len) {
VAR_5 = -EINVAL;
goto out;
}
qemu_iovec_from_buf(VAR_3, 0, uncomp_buf + VAR_2, VAR_4);
VAR_5 = 0;
out:
g_free(uncomp_buf);
g_free(cluster_buf);
return VAR_5;
}
| [
"static int FUNC_0(VmdkExtent *VAR_0, int64_t VAR_1,\nint64_t VAR_2, QEMUIOVector *VAR_3,\nint VAR_4)\n{",
"int VAR_5;",
"int VAR_6, VAR_7;",
"uint8_t *cluster_buf, *compressed_data;",
"uint8_t *uncomp_buf;",
"uint32_t data_len;",
"VmdkGrainMarker *marker;",
"uLongf buf_len;",
"if (!VAR_0->compressed) {",
"VAR_5 = bdrv_co_preadv(VAR_0->file->bs,\nVAR_1 + VAR_2, VAR_4,\nVAR_3, 0);",
"if (VAR_5 < 0) {",
"return VAR_5;",
"}",
"return 0;",
"}",
"VAR_6 = VAR_0->cluster_sectors * 512;",
"VAR_7 = VAR_6 * 2;",
"cluster_buf = g_malloc(VAR_7);",
"uncomp_buf = g_malloc(VAR_6);",
"VAR_5 = bdrv_pread(VAR_0->file,\nVAR_1,\ncluster_buf, VAR_7);",
"if (VAR_5 < 0) {",
"goto out;",
"}",
"compressed_data = cluster_buf;",
"buf_len = VAR_6;",
"data_len = VAR_6;",
"if (VAR_0->has_marker) {",
"marker = (VmdkGrainMarker *)cluster_buf;",
"compressed_data = marker->data;",
"data_len = le32_to_cpu(marker->size);",
"}",
"if (!data_len || data_len > VAR_7) {",
"VAR_5 = -EINVAL;",
"goto out;",
"}",
"VAR_5 = uncompress(uncomp_buf, &buf_len, compressed_data, data_len);",
"if (VAR_5 != Z_OK) {",
"VAR_5 = -EINVAL;",
"goto out;",
"}",
"if (VAR_2 < 0 ||\nVAR_2 + VAR_4 > buf_len) {",
"VAR_5 = -EINVAL;",
"goto out;",
"}",
"qemu_iovec_from_buf(VAR_3, 0, uncomp_buf + VAR_2, VAR_4);",
"VAR_5 = 0;",
"out:\ng_free(uncomp_buf);",
"g_free(cluster_buf);",
"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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29,
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
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
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119,
121
],
[
123
],
[
125
],
[
127
]
] |
1,291 | static void parser_context_free(JSONParserContext *ctxt)
{
if (ctxt) {
while (!g_queue_is_empty(ctxt->buf)) {
parser_context_pop_token(ctxt);
}
qobject_decref(ctxt->current);
g_queue_free(ctxt->buf);
g_free(ctxt);
}
}
| false | qemu | 9bada8971173345ceb37ed1a47b00a01a4dd48cf | static void parser_context_free(JSONParserContext *ctxt)
{
if (ctxt) {
while (!g_queue_is_empty(ctxt->buf)) {
parser_context_pop_token(ctxt);
}
qobject_decref(ctxt->current);
g_queue_free(ctxt->buf);
g_free(ctxt);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(JSONParserContext *VAR_0)
{
if (VAR_0) {
while (!g_queue_is_empty(VAR_0->buf)) {
parser_context_pop_token(VAR_0);
}
qobject_decref(VAR_0->current);
g_queue_free(VAR_0->buf);
g_free(VAR_0);
}
}
| [
"static void FUNC_0(JSONParserContext *VAR_0)\n{",
"if (VAR_0) {",
"while (!g_queue_is_empty(VAR_0->buf)) {",
"parser_context_pop_token(VAR_0);",
"}",
"qobject_decref(VAR_0->current);",
"g_queue_free(VAR_0->buf);",
"g_free(VAR_0);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
]
] |
1,293 | int page_check_range(target_ulong start, target_ulong len, int flags)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
if (start + len < start)
/* we've wrapped around */
return -1;
end = TARGET_PAGE_ALIGN(start+len); /* must do before we loose bits in the next step */
start = start & TARGET_PAGE_MASK;
for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if( !p )
return -1;
if( !(p->flags & PAGE_VALID) )
return -1;
if ((flags & PAGE_READ) && !(p->flags & PAGE_READ))
return -1;
if (flags & PAGE_WRITE) {
if (!(p->flags & PAGE_WRITE_ORG))
return -1;
/* unprotect the page if it was put read-only because it
contains translated code */
if (!(p->flags & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL))
return -1;
}
return 0;
}
}
return 0;
}
| false | qemu | 376a790970de7e84170ee9360b6ff53ecfa4a1be | int page_check_range(target_ulong start, target_ulong len, int flags)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
if (start + len < start)
return -1;
end = TARGET_PAGE_ALIGN(start+len);
start = start & TARGET_PAGE_MASK;
for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if( !p )
return -1;
if( !(p->flags & PAGE_VALID) )
return -1;
if ((flags & PAGE_READ) && !(p->flags & PAGE_READ))
return -1;
if (flags & PAGE_WRITE) {
if (!(p->flags & PAGE_WRITE_ORG))
return -1;
if (!(p->flags & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL))
return -1;
}
return 0;
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)
{
PageDesc *p;
target_ulong end;
target_ulong addr;
if (VAR_0 + VAR_1 < VAR_0)
return -1;
end = TARGET_PAGE_ALIGN(VAR_0+VAR_1);
VAR_0 = VAR_0 & TARGET_PAGE_MASK;
for(addr = VAR_0; addr < end; addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
if( !p )
return -1;
if( !(p->VAR_2 & PAGE_VALID) )
return -1;
if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ))
return -1;
if (VAR_2 & PAGE_WRITE) {
if (!(p->VAR_2 & PAGE_WRITE_ORG))
return -1;
if (!(p->VAR_2 & PAGE_WRITE)) {
if (!page_unprotect(addr, 0, NULL))
return -1;
}
return 0;
}
}
return 0;
}
| [
"int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)\n{",
"PageDesc *p;",
"target_ulong end;",
"target_ulong addr;",
"if (VAR_0 + VAR_1 < VAR_0)\nreturn -1;",
"end = TARGET_PAGE_ALIGN(VAR_0+VAR_1);",
"VAR_0 = VAR_0 & TARGET_PAGE_MASK;",
"for(addr = VAR_0; addr < end; addr += TARGET_PAGE_SIZE) {",
"p = page_find(addr >> TARGET_PAGE_BITS);",
"if( !p )\nreturn -1;",
"if( !(p->VAR_2 & PAGE_VALID) )\nreturn -1;",
"if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ))\nreturn -1;",
"if (VAR_2 & PAGE_WRITE) {",
"if (!(p->VAR_2 & PAGE_WRITE_ORG))\nreturn -1;",
"if (!(p->VAR_2 & PAGE_WRITE)) {",
"if (!page_unprotect(addr, 0, NULL))\nreturn -1;",
"}",
"return 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
17
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31,
33
],
[
35,
37
],
[
41,
43
],
[
45
],
[
47,
49
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
1,294 | processed(OptsVisitor *ov, const char *name)
{
if (ov->repeated_opts == NULL) {
g_hash_table_remove(ov->unprocessed_opts, name);
}
}
| false | qemu | d95704341280fc521dc2b16bbbc5858f6647e2c3 | processed(OptsVisitor *ov, const char *name)
{
if (ov->repeated_opts == NULL) {
g_hash_table_remove(ov->unprocessed_opts, name);
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(OptsVisitor *VAR_0, const char *VAR_1)
{
if (VAR_0->repeated_opts == NULL) {
g_hash_table_remove(VAR_0->unprocessed_opts, VAR_1);
}
}
| [
"FUNC_0(OptsVisitor *VAR_0, const char *VAR_1)\n{",
"if (VAR_0->repeated_opts == NULL) {",
"g_hash_table_remove(VAR_0->unprocessed_opts, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
]
] |
1,295 | minimac2_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
MilkymistMinimac2State *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_SETUP:
case R_MDIO:
case R_STATE0:
case R_COUNT0:
case R_STATE1:
case R_COUNT1:
case R_TXCOUNT:
r = s->regs[addr];
break;
default:
error_report("milkymist_minimac2: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_minimac2_memory_read(addr << 2, r);
return r;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | minimac2_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
MilkymistMinimac2State *s = opaque;
uint32_t r = 0;
addr >>= 2;
switch (addr) {
case R_SETUP:
case R_MDIO:
case R_STATE0:
case R_COUNT0:
case R_STATE1:
case R_COUNT1:
case R_TXCOUNT:
r = s->regs[addr];
break;
default:
error_report("milkymist_minimac2: read access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
trace_milkymist_minimac2_memory_read(addr << 2, r);
return r;
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, unsigned VAR_2)
{
MilkymistMinimac2State *s = VAR_0;
uint32_t r = 0;
VAR_1 >>= 2;
switch (VAR_1) {
case R_SETUP:
case R_MDIO:
case R_STATE0:
case R_COUNT0:
case R_STATE1:
case R_COUNT1:
case R_TXCOUNT:
r = s->regs[VAR_1];
break;
default:
error_report("milkymist_minimac2: read access to unknown register 0x"
TARGET_FMT_plx, VAR_1 << 2);
break;
}
trace_milkymist_minimac2_memory_read(VAR_1 << 2, r);
return r;
}
| [
"FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, unsigned VAR_2)\n{",
"MilkymistMinimac2State *s = VAR_0;",
"uint32_t r = 0;",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_SETUP:\ncase R_MDIO:\ncase R_STATE0:\ncase R_COUNT0:\ncase R_STATE1:\ncase R_COUNT1:\ncase R_TXCOUNT:\nr = s->regs[VAR_1];",
"break;",
"default:\nerror_report(\"milkymist_minimac2: read access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);",
"break;",
"}",
"trace_milkymist_minimac2_memory_read(VAR_1 << 2, r);",
"return r;",
"}"
] | [
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
],
[
35,
37,
39
],
[
41
],
[
43
],
[
47
],
[
51
],
[
53
]
] |
1,296 | static inline void float_to_int (float * _f, int16_t * s16, int samples)
{
int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format
int i;
for (i = 0; i < samples; i++) {
s16[i] = blah (f[i]);
}
}
| false | FFmpeg | 0058584580b87feb47898e60e4b80c7f425882ad | static inline void float_to_int (float * _f, int16_t * s16, int samples)
{
int32_t * f = (int32_t *) _f;
int i;
for (i = 0; i < samples; i++) {
s16[i] = blah (f[i]);
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0 (float * VAR_0, int16_t * VAR_1, int VAR_2)
{
int32_t * f = (int32_t *) VAR_0;
int VAR_3;
for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
VAR_1[VAR_3] = blah (f[VAR_3]);
}
}
| [
"static inline void FUNC_0 (float * VAR_0, int16_t * VAR_1, int VAR_2)\n{",
"int32_t * f = (int32_t *) VAR_0;",
"int VAR_3;",
"for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {",
"VAR_1[VAR_3] = blah (f[VAR_3]);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
1,297 | void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid)
{
KVMDevice *kd;
if (!kvm_irqchip_in_kernel()) {
return;
}
if (QSLIST_EMPTY(&kvm_devices_head)) {
memory_listener_register(&devlistener, NULL);
qemu_add_machine_init_done_notifier(¬ify);
}
kd = g_new0(KVMDevice, 1);
kd->mr = mr;
kd->kda.id = devid;
kd->kda.addr = -1;
QSLIST_INSERT_HEAD(&kvm_devices_head, kd, entries);
memory_region_ref(kd->mr);
}
| false | qemu | 1da41cc1c6c3efbe2ed47228068bd80dbdc49d0e | void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid)
{
KVMDevice *kd;
if (!kvm_irqchip_in_kernel()) {
return;
}
if (QSLIST_EMPTY(&kvm_devices_head)) {
memory_listener_register(&devlistener, NULL);
qemu_add_machine_init_done_notifier(¬ify);
}
kd = g_new0(KVMDevice, 1);
kd->mr = mr;
kd->kda.id = devid;
kd->kda.addr = -1;
QSLIST_INSERT_HEAD(&kvm_devices_head, kd, entries);
memory_region_ref(kd->mr);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0, uint64_t VAR_1)
{
KVMDevice *kd;
if (!kvm_irqchip_in_kernel()) {
return;
}
if (QSLIST_EMPTY(&kvm_devices_head)) {
memory_listener_register(&devlistener, NULL);
qemu_add_machine_init_done_notifier(¬ify);
}
kd = g_new0(KVMDevice, 1);
kd->VAR_0 = VAR_0;
kd->kda.id = VAR_1;
kd->kda.addr = -1;
QSLIST_INSERT_HEAD(&kvm_devices_head, kd, entries);
memory_region_ref(kd->VAR_0);
}
| [
"void FUNC_0(MemoryRegion *VAR_0, uint64_t VAR_1)\n{",
"KVMDevice *kd;",
"if (!kvm_irqchip_in_kernel()) {",
"return;",
"}",
"if (QSLIST_EMPTY(&kvm_devices_head)) {",
"memory_listener_register(&devlistener, NULL);",
"qemu_add_machine_init_done_notifier(¬ify);",
"}",
"kd = g_new0(KVMDevice, 1);",
"kd->VAR_0 = VAR_0;",
"kd->kda.id = VAR_1;",
"kd->kda.addr = -1;",
"QSLIST_INSERT_HEAD(&kvm_devices_head, kd, entries);",
"memory_region_ref(kd->VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
1,298 | X86CPU *cpu_x86_init(const char *cpu_model)
{
X86CPU *cpu;
CPUX86State *env;
static int inited;
cpu = X86_CPU(object_new(TYPE_X86_CPU));
env = &cpu->env;
env->cpu_model_str = cpu_model;
/* init various static tables used in TCG mode */
if (tcg_enabled() && !inited) {
inited = 1;
optimize_flags_init();
#ifndef CONFIG_USER_ONLY
prev_debug_excp_handler =
cpu_set_debug_excp_handler(breakpoint_handler);
#endif
}
if (cpu_x86_register(cpu, cpu_model) < 0) {
object_delete(OBJECT(cpu));
return NULL;
}
x86_cpu_realize(OBJECT(cpu), NULL);
return cpu;
}
| false | qemu | 130a03855098a4057c227bc658c0688f8665b71f | X86CPU *cpu_x86_init(const char *cpu_model)
{
X86CPU *cpu;
CPUX86State *env;
static int inited;
cpu = X86_CPU(object_new(TYPE_X86_CPU));
env = &cpu->env;
env->cpu_model_str = cpu_model;
if (tcg_enabled() && !inited) {
inited = 1;
optimize_flags_init();
#ifndef CONFIG_USER_ONLY
prev_debug_excp_handler =
cpu_set_debug_excp_handler(breakpoint_handler);
#endif
}
if (cpu_x86_register(cpu, cpu_model) < 0) {
object_delete(OBJECT(cpu));
return NULL;
}
x86_cpu_realize(OBJECT(cpu), NULL);
return cpu;
}
| {
"code": [],
"line_no": []
} | X86CPU *FUNC_0(const char *cpu_model)
{
X86CPU *cpu;
CPUX86State *env;
static int VAR_0;
cpu = X86_CPU(object_new(TYPE_X86_CPU));
env = &cpu->env;
env->cpu_model_str = cpu_model;
if (tcg_enabled() && !VAR_0) {
VAR_0 = 1;
optimize_flags_init();
#ifndef CONFIG_USER_ONLY
prev_debug_excp_handler =
cpu_set_debug_excp_handler(breakpoint_handler);
#endif
}
if (cpu_x86_register(cpu, cpu_model) < 0) {
object_delete(OBJECT(cpu));
return NULL;
}
x86_cpu_realize(OBJECT(cpu), NULL);
return cpu;
}
| [
"X86CPU *FUNC_0(const char *cpu_model)\n{",
"X86CPU *cpu;",
"CPUX86State *env;",
"static int VAR_0;",
"cpu = X86_CPU(object_new(TYPE_X86_CPU));",
"env = &cpu->env;",
"env->cpu_model_str = cpu_model;",
"if (tcg_enabled() && !VAR_0) {",
"VAR_0 = 1;",
"optimize_flags_init();",
"#ifndef CONFIG_USER_ONLY\nprev_debug_excp_handler =\ncpu_set_debug_excp_handler(breakpoint_handler);",
"#endif\n}",
"if (cpu_x86_register(cpu, cpu_model) < 0) {",
"object_delete(OBJECT(cpu));",
"return NULL;",
"}",
"x86_cpu_realize(OBJECT(cpu), NULL);",
"return cpu;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27
],
[
29,
31,
33
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
]
] |
1,299 | int raw_get_aio_fd(BlockDriverState *bs)
{
BDRVRawState *s;
if (!bs->drv) {
return -ENOMEDIUM;
}
if (bs->drv == bdrv_find_format("raw")) {
bs = bs->file;
}
/* raw-posix has several protocols so just check for raw_aio_readv */
if (bs->drv->bdrv_aio_readv != raw_aio_readv) {
return -ENOTSUP;
}
s = bs->opaque;
if (!s->use_aio) {
return -ENOTSUP;
}
return s->fd;
}
| false | qemu | 76ef2cf5493a215efc351f48ae7094d6c183fcac | int raw_get_aio_fd(BlockDriverState *bs)
{
BDRVRawState *s;
if (!bs->drv) {
return -ENOMEDIUM;
}
if (bs->drv == bdrv_find_format("raw")) {
bs = bs->file;
}
if (bs->drv->bdrv_aio_readv != raw_aio_readv) {
return -ENOTSUP;
}
s = bs->opaque;
if (!s->use_aio) {
return -ENOTSUP;
}
return s->fd;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0)
{
BDRVRawState *s;
if (!VAR_0->drv) {
return -ENOMEDIUM;
}
if (VAR_0->drv == bdrv_find_format("raw")) {
VAR_0 = VAR_0->file;
}
if (VAR_0->drv->bdrv_aio_readv != raw_aio_readv) {
return -ENOTSUP;
}
s = VAR_0->opaque;
if (!s->use_aio) {
return -ENOTSUP;
}
return s->fd;
}
| [
"int FUNC_0(BlockDriverState *VAR_0)\n{",
"BDRVRawState *s;",
"if (!VAR_0->drv) {",
"return -ENOMEDIUM;",
"}",
"if (VAR_0->drv == bdrv_find_format(\"raw\")) {",
"VAR_0 = VAR_0->file;",
"}",
"if (VAR_0->drv->bdrv_aio_readv != raw_aio_readv) {",
"return -ENOTSUP;",
"}",
"s = VAR_0->opaque;",
"if (!s->use_aio) {",
"return -ENOTSUP;",
"}",
"return s->fd;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
]
] |
1,300 | static SocketAddressLegacy *unix_build_address(const char *path)
{
SocketAddressLegacy *saddr;
saddr = g_new0(SocketAddressLegacy, 1);
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(path);
return saddr;
}
| false | qemu | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 | static SocketAddressLegacy *unix_build_address(const char *path)
{
SocketAddressLegacy *saddr;
saddr = g_new0(SocketAddressLegacy, 1);
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(path);
return saddr;
}
| {
"code": [],
"line_no": []
} | static SocketAddressLegacy *FUNC_0(const char *path)
{
SocketAddressLegacy *saddr;
saddr = g_new0(SocketAddressLegacy, 1);
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(path);
return saddr;
}
| [
"static SocketAddressLegacy *FUNC_0(const char *path)\n{",
"SocketAddressLegacy *saddr;",
"saddr = g_new0(SocketAddressLegacy, 1);",
"saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;",
"saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);",
"saddr->u.q_unix.data->path = g_strdup(path);",
"return saddr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
]
] |
1,301 | e1000_mmio_read(void *opaque, hwaddr addr, unsigned size)
{
E1000State *s = opaque;
unsigned int index = (addr & 0x1ffff) >> 2;
if (index < NREADOPS && macreg_readops[index])
{
return macreg_readops[index](s, index);
}
DBGOUT(UNKNOWN, "MMIO unknown read addr=0x%08x\n", index<<2);
return 0;
}
| false | qemu | bc0f0674f037a01f2ce0870ad6270a356a7a8347 | e1000_mmio_read(void *opaque, hwaddr addr, unsigned size)
{
E1000State *s = opaque;
unsigned int index = (addr & 0x1ffff) >> 2;
if (index < NREADOPS && macreg_readops[index])
{
return macreg_readops[index](s, index);
}
DBGOUT(UNKNOWN, "MMIO unknown read addr=0x%08x\n", index<<2);
return 0;
}
| {
"code": [],
"line_no": []
} | FUNC_0(void *VAR_0, hwaddr VAR_1, unsigned VAR_2)
{
E1000State *s = VAR_0;
unsigned int VAR_3 = (VAR_1 & 0x1ffff) >> 2;
if (VAR_3 < NREADOPS && macreg_readops[VAR_3])
{
return macreg_readops[VAR_3](s, VAR_3);
}
DBGOUT(UNKNOWN, "MMIO unknown read VAR_1=0x%08x\n", VAR_3<<2);
return 0;
}
| [
"FUNC_0(void *VAR_0, hwaddr VAR_1, unsigned VAR_2)\n{",
"E1000State *s = VAR_0;",
"unsigned int VAR_3 = (VAR_1 & 0x1ffff) >> 2;",
"if (VAR_3 < NREADOPS && macreg_readops[VAR_3])\n{",
"return macreg_readops[VAR_3](s, VAR_3);",
"}",
"DBGOUT(UNKNOWN, \"MMIO unknown read VAR_1=0x%08x\\n\", VAR_3<<2);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
1,302 | void bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags,
Error **errp, bool quiet)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *backing_fmt, *backing_file, *size;
BlockDriverState *bs = NULL;
BlockDriver *drv, *proto_drv;
BlockDriver *backing_drv = NULL;
int ret = 0;
/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv) {
error_setg(errp, "Unknown file format '%s'", fmt);
return;
}
proto_drv = bdrv_find_protocol(filename);
if (!proto_drv) {
error_setg(errp, "Unknown protocol '%s'", filename);
return;
}
create_options = append_option_parameters(create_options,
drv->create_options);
create_options = append_option_parameters(create_options,
proto_drv->create_options);
/* Create parameter list with default values */
param = parse_option_parameters("", create_options, param);
set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size);
/* Parse -o options */
if (options) {
param = parse_option_parameters(options, create_options, param);
if (param == NULL) {
error_setg(errp, "Invalid options for file format '%s'.", fmt);
goto out;
}
}
if (base_filename) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE,
base_filename)) {
error_setg(errp, "Backing file not supported for file format '%s'",
fmt);
goto out;
}
}
if (base_fmt) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) {
error_setg(errp, "Backing file format not supported for file "
"format '%s'", fmt);
goto out;
}
}
backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
if (backing_file && backing_file->value.s) {
if (!strcmp(filename, backing_file->value.s)) {
error_setg(errp, "Error: Trying to create an image with the "
"same filename as the backing file");
goto out;
}
}
backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
if (backing_fmt && backing_fmt->value.s) {
backing_drv = bdrv_find_format(backing_fmt->value.s);
if (!backing_drv) {
error_setg(errp, "Unknown backing file format '%s'",
backing_fmt->value.s);
goto out;
}
}
// The size for the image must always be specified, with one exception:
// If we are using a backing file, we can obtain the size from there
size = get_option_parameter(param, BLOCK_OPT_SIZE);
if (size && size->value.n == -1) {
if (backing_file && backing_file->value.s) {
uint64_t size;
char buf[32];
int back_flags;
/* backing files always opened read-only */
back_flags =
flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
bs = bdrv_new("");
ret = bdrv_open(bs, backing_file->value.s, NULL, back_flags,
backing_drv);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not open '%s'",
backing_file->value.s);
goto out;
}
bdrv_get_geometry(bs, &size);
size *= 512;
snprintf(buf, sizeof(buf), "%" PRId64, size);
set_option_parameter(param, BLOCK_OPT_SIZE, buf);
} else {
error_setg(errp, "Image creation needs a size parameter");
goto out;
}
}
if (!quiet) {
printf("Formatting '%s', fmt=%s ", filename, fmt);
print_option_parameters(param);
puts("");
}
ret = bdrv_create(drv, filename, param);
if (ret < 0) {
if (ret == -ENOTSUP) {
error_setg(errp,"Formatting or formatting option not supported for "
"file format '%s'", fmt);
} else if (ret == -EFBIG) {
error_setg(errp, "The image size is too large for file format '%s'",
fmt);
} else {
error_setg(errp, "%s: error while creating %s: %s", filename, fmt,
strerror(-ret));
}
}
out:
free_option_parameters(create_options);
free_option_parameters(param);
if (bs) {
bdrv_delete(bs);
}
}
| false | qemu | f3f4d2c09b9cf46903ba38425ec46c44185162bd | void bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
char *options, uint64_t img_size, int flags,
Error **errp, bool quiet)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *backing_fmt, *backing_file, *size;
BlockDriverState *bs = NULL;
BlockDriver *drv, *proto_drv;
BlockDriver *backing_drv = NULL;
int ret = 0;
drv = bdrv_find_format(fmt);
if (!drv) {
error_setg(errp, "Unknown file format '%s'", fmt);
return;
}
proto_drv = bdrv_find_protocol(filename);
if (!proto_drv) {
error_setg(errp, "Unknown protocol '%s'", filename);
return;
}
create_options = append_option_parameters(create_options,
drv->create_options);
create_options = append_option_parameters(create_options,
proto_drv->create_options);
param = parse_option_parameters("", create_options, param);
set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size);
if (options) {
param = parse_option_parameters(options, create_options, param);
if (param == NULL) {
error_setg(errp, "Invalid options for file format '%s'.", fmt);
goto out;
}
}
if (base_filename) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE,
base_filename)) {
error_setg(errp, "Backing file not supported for file format '%s'",
fmt);
goto out;
}
}
if (base_fmt) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) {
error_setg(errp, "Backing file format not supported for file "
"format '%s'", fmt);
goto out;
}
}
backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
if (backing_file && backing_file->value.s) {
if (!strcmp(filename, backing_file->value.s)) {
error_setg(errp, "Error: Trying to create an image with the "
"same filename as the backing file");
goto out;
}
}
backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
if (backing_fmt && backing_fmt->value.s) {
backing_drv = bdrv_find_format(backing_fmt->value.s);
if (!backing_drv) {
error_setg(errp, "Unknown backing file format '%s'",
backing_fmt->value.s);
goto out;
}
}
size = get_option_parameter(param, BLOCK_OPT_SIZE);
if (size && size->value.n == -1) {
if (backing_file && backing_file->value.s) {
uint64_t size;
char buf[32];
int back_flags;
back_flags =
flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
bs = bdrv_new("");
ret = bdrv_open(bs, backing_file->value.s, NULL, back_flags,
backing_drv);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not open '%s'",
backing_file->value.s);
goto out;
}
bdrv_get_geometry(bs, &size);
size *= 512;
snprintf(buf, sizeof(buf), "%" PRId64, size);
set_option_parameter(param, BLOCK_OPT_SIZE, buf);
} else {
error_setg(errp, "Image creation needs a size parameter");
goto out;
}
}
if (!quiet) {
printf("Formatting '%s', fmt=%s ", filename, fmt);
print_option_parameters(param);
puts("");
}
ret = bdrv_create(drv, filename, param);
if (ret < 0) {
if (ret == -ENOTSUP) {
error_setg(errp,"Formatting or formatting option not supported for "
"file format '%s'", fmt);
} else if (ret == -EFBIG) {
error_setg(errp, "The image size is too large for file format '%s'",
fmt);
} else {
error_setg(errp, "%s: error while creating %s: %s", filename, fmt,
strerror(-ret));
}
}
out:
free_option_parameters(create_options);
free_option_parameters(param);
if (bs) {
bdrv_delete(bs);
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, const char *VAR_1,
const char *VAR_2, const char *VAR_3,
char *VAR_4, uint64_t VAR_5, int VAR_6,
Error **VAR_7, bool VAR_8)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *backing_fmt, *backing_file, *size;
BlockDriverState *bs = NULL;
BlockDriver *drv, *proto_drv;
BlockDriver *backing_drv = NULL;
int VAR_9 = 0;
drv = bdrv_find_format(VAR_1);
if (!drv) {
error_setg(VAR_7, "Unknown file format '%s'", VAR_1);
return;
}
proto_drv = bdrv_find_protocol(VAR_0);
if (!proto_drv) {
error_setg(VAR_7, "Unknown protocol '%s'", VAR_0);
return;
}
create_options = append_option_parameters(create_options,
drv->create_options);
create_options = append_option_parameters(create_options,
proto_drv->create_options);
param = parse_option_parameters("", create_options, param);
set_option_parameter_int(param, BLOCK_OPT_SIZE, VAR_5);
if (VAR_4) {
param = parse_option_parameters(VAR_4, create_options, param);
if (param == NULL) {
error_setg(VAR_7, "Invalid VAR_4 for file format '%s'.", VAR_1);
goto out;
}
}
if (VAR_2) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE,
VAR_2)) {
error_setg(VAR_7, "Backing file not supported for file format '%s'",
VAR_1);
goto out;
}
}
if (VAR_3) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, VAR_3)) {
error_setg(VAR_7, "Backing file format not supported for file "
"format '%s'", VAR_1);
goto out;
}
}
backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
if (backing_file && backing_file->value.s) {
if (!strcmp(VAR_0, backing_file->value.s)) {
error_setg(VAR_7, "Error: Trying to create an image with the "
"same VAR_0 as the backing file");
goto out;
}
}
backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
if (backing_fmt && backing_fmt->value.s) {
backing_drv = bdrv_find_format(backing_fmt->value.s);
if (!backing_drv) {
error_setg(VAR_7, "Unknown backing file format '%s'",
backing_fmt->value.s);
goto out;
}
}
size = get_option_parameter(param, BLOCK_OPT_SIZE);
if (size && size->value.n == -1) {
if (backing_file && backing_file->value.s) {
uint64_t size;
char VAR_10[32];
int VAR_11;
VAR_11 =
VAR_6 & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
bs = bdrv_new("");
VAR_9 = bdrv_open(bs, backing_file->value.s, NULL, VAR_11,
backing_drv);
if (VAR_9 < 0) {
error_setg_errno(VAR_7, -VAR_9, "Could not open '%s'",
backing_file->value.s);
goto out;
}
bdrv_get_geometry(bs, &size);
size *= 512;
snprintf(VAR_10, sizeof(VAR_10), "%" PRId64, size);
set_option_parameter(param, BLOCK_OPT_SIZE, VAR_10);
} else {
error_setg(VAR_7, "Image creation needs a size parameter");
goto out;
}
}
if (!VAR_8) {
printf("Formatting '%s', VAR_1=%s ", VAR_0, VAR_1);
print_option_parameters(param);
puts("");
}
VAR_9 = bdrv_create(drv, VAR_0, param);
if (VAR_9 < 0) {
if (VAR_9 == -ENOTSUP) {
error_setg(VAR_7,"Formatting or formatting option not supported for "
"file format '%s'", VAR_1);
} else if (VAR_9 == -EFBIG) {
error_setg(VAR_7, "The image size is too large for file format '%s'",
VAR_1);
} else {
error_setg(VAR_7, "%s: error while creating %s: %s", VAR_0, VAR_1,
strerror(-VAR_9));
}
}
out:
free_option_parameters(create_options);
free_option_parameters(param);
if (bs) {
bdrv_delete(bs);
}
}
| [
"void FUNC_0(const char *VAR_0, const char *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nchar *VAR_4, uint64_t VAR_5, int VAR_6,\nError **VAR_7, bool VAR_8)\n{",
"QEMUOptionParameter *param = NULL, *create_options = NULL;",
"QEMUOptionParameter *backing_fmt, *backing_file, *size;",
"BlockDriverState *bs = NULL;",
"BlockDriver *drv, *proto_drv;",
"BlockDriver *backing_drv = NULL;",
"int VAR_9 = 0;",
"drv = bdrv_find_format(VAR_1);",
"if (!drv) {",
"error_setg(VAR_7, \"Unknown file format '%s'\", VAR_1);",
"return;",
"}",
"proto_drv = bdrv_find_protocol(VAR_0);",
"if (!proto_drv) {",
"error_setg(VAR_7, \"Unknown protocol '%s'\", VAR_0);",
"return;",
"}",
"create_options = append_option_parameters(create_options,\ndrv->create_options);",
"create_options = append_option_parameters(create_options,\nproto_drv->create_options);",
"param = parse_option_parameters(\"\", create_options, param);",
"set_option_parameter_int(param, BLOCK_OPT_SIZE, VAR_5);",
"if (VAR_4) {",
"param = parse_option_parameters(VAR_4, create_options, param);",
"if (param == NULL) {",
"error_setg(VAR_7, \"Invalid VAR_4 for file format '%s'.\", VAR_1);",
"goto out;",
"}",
"}",
"if (VAR_2) {",
"if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE,\nVAR_2)) {",
"error_setg(VAR_7, \"Backing file not supported for file format '%s'\",\nVAR_1);",
"goto out;",
"}",
"}",
"if (VAR_3) {",
"if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, VAR_3)) {",
"error_setg(VAR_7, \"Backing file format not supported for file \"\n\"format '%s'\", VAR_1);",
"goto out;",
"}",
"}",
"backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);",
"if (backing_file && backing_file->value.s) {",
"if (!strcmp(VAR_0, backing_file->value.s)) {",
"error_setg(VAR_7, \"Error: Trying to create an image with the \"\n\"same VAR_0 as the backing file\");",
"goto out;",
"}",
"}",
"backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);",
"if (backing_fmt && backing_fmt->value.s) {",
"backing_drv = bdrv_find_format(backing_fmt->value.s);",
"if (!backing_drv) {",
"error_setg(VAR_7, \"Unknown backing file format '%s'\",\nbacking_fmt->value.s);",
"goto out;",
"}",
"}",
"size = get_option_parameter(param, BLOCK_OPT_SIZE);",
"if (size && size->value.n == -1) {",
"if (backing_file && backing_file->value.s) {",
"uint64_t size;",
"char VAR_10[32];",
"int VAR_11;",
"VAR_11 =\nVAR_6 & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);",
"bs = bdrv_new(\"\");",
"VAR_9 = bdrv_open(bs, backing_file->value.s, NULL, VAR_11,\nbacking_drv);",
"if (VAR_9 < 0) {",
"error_setg_errno(VAR_7, -VAR_9, \"Could not open '%s'\",\nbacking_file->value.s);",
"goto out;",
"}",
"bdrv_get_geometry(bs, &size);",
"size *= 512;",
"snprintf(VAR_10, sizeof(VAR_10), \"%\" PRId64, size);",
"set_option_parameter(param, BLOCK_OPT_SIZE, VAR_10);",
"} else {",
"error_setg(VAR_7, \"Image creation needs a size parameter\");",
"goto out;",
"}",
"}",
"if (!VAR_8) {",
"printf(\"Formatting '%s', VAR_1=%s \", VAR_0, VAR_1);",
"print_option_parameters(param);",
"puts(\"\");",
"}",
"VAR_9 = bdrv_create(drv, VAR_0, param);",
"if (VAR_9 < 0) {",
"if (VAR_9 == -ENOTSUP) {",
"error_setg(VAR_7,\"Formatting or formatting option not supported for \"\n\"file format '%s'\", VAR_1);",
"} else if (VAR_9 == -EFBIG) {",
"error_setg(VAR_7, \"The image size is too large for file format '%s'\",\nVAR_1);",
"} else {",
"error_setg(VAR_7, \"%s: error while creating %s: %s\", VAR_0, VAR_1,\nstrerror(-VAR_9));",
"}",
"}",
"out:\nfree_option_parameters(create_options);",
"free_option_parameters(param);",
"if (bs) {",
"bdrv_delete(bs);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51,
53
],
[
55,
57
],
[
63
],
[
67
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
89
],
[
91,
93
],
[
95,
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111,
113
],
[
115
],
[
117
],
[
119
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
181,
183
],
[
187
],
[
191,
193
],
[
195
],
[
197,
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219
],
[
221
],
[
223
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249,
251
],
[
253
],
[
255,
257
],
[
259
],
[
261
],
[
265,
267
],
[
269
],
[
273
],
[
275
],
[
277
],
[
279
]
] |
1,303 | int nbd_client(int fd)
{
int ret;
int serrno;
TRACE("Doing NBD loop");
ret = ioctl(fd, NBD_DO_IT);
if (ret == -1 && errno == EPIPE) {
/* NBD_DO_IT normally returns EPIPE when someone has disconnected
* the socket via NBD_DISCONNECT. We do not want to return 1 in
* that case.
*/
ret = 0;
}
serrno = errno;
TRACE("NBD loop returned %d: %s", ret, strerror(serrno));
TRACE("Clearing NBD queue");
ioctl(fd, NBD_CLEAR_QUE);
TRACE("Clearing NBD socket");
ioctl(fd, NBD_CLEAR_SOCK);
errno = serrno;
return ret;
}
| false | qemu | fc19f8a02e45c4d8ad24dd7eb374330b03dfc28e | int nbd_client(int fd)
{
int ret;
int serrno;
TRACE("Doing NBD loop");
ret = ioctl(fd, NBD_DO_IT);
if (ret == -1 && errno == EPIPE) {
ret = 0;
}
serrno = errno;
TRACE("NBD loop returned %d: %s", ret, strerror(serrno));
TRACE("Clearing NBD queue");
ioctl(fd, NBD_CLEAR_QUE);
TRACE("Clearing NBD socket");
ioctl(fd, NBD_CLEAR_SOCK);
errno = serrno;
return ret;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(int VAR_0)
{
int VAR_1;
int VAR_2;
TRACE("Doing NBD loop");
VAR_1 = ioctl(VAR_0, NBD_DO_IT);
if (VAR_1 == -1 && errno == EPIPE) {
VAR_1 = 0;
}
VAR_2 = errno;
TRACE("NBD loop returned %d: %s", VAR_1, strerror(VAR_2));
TRACE("Clearing NBD queue");
ioctl(VAR_0, NBD_CLEAR_QUE);
TRACE("Clearing NBD socket");
ioctl(VAR_0, NBD_CLEAR_SOCK);
errno = VAR_2;
return VAR_1;
}
| [
"int FUNC_0(int VAR_0)\n{",
"int VAR_1;",
"int VAR_2;",
"TRACE(\"Doing NBD loop\");",
"VAR_1 = ioctl(VAR_0, NBD_DO_IT);",
"if (VAR_1 == -1 && errno == EPIPE) {",
"VAR_1 = 0;",
"}",
"VAR_2 = errno;",
"TRACE(\"NBD loop returned %d: %s\", VAR_1, strerror(VAR_2));",
"TRACE(\"Clearing NBD queue\");",
"ioctl(VAR_0, NBD_CLEAR_QUE);",
"TRACE(\"Clearing NBD socket\");",
"ioctl(VAR_0, NBD_CLEAR_SOCK);",
"errno = VAR_2;",
"return VAR_1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
27
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
] |
1,304 | static void slirp_init_once(void)
{
static int initialized;
struct hostent *he;
char our_name[256];
#ifdef _WIN32
WSADATA Data;
#endif
if (initialized) {
return;
}
initialized = 1;
#ifdef _WIN32
WSAStartup(MAKEWORD(2,0), &Data);
atexit(winsock_cleanup);
#endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
/* FIXME: This address may change during runtime */
if (gethostname(our_name, sizeof(our_name)) == 0) {
he = gethostbyname(our_name);
if (he) {
our_addr = *(struct in_addr *)he->h_addr;
}
}
if (our_addr.s_addr == 0) {
our_addr = loopback_addr;
}
/* FIXME: This address may change during runtime */
if (get_dns_addr(&dns_addr) < 0) {
dns_addr = loopback_addr;
}
}
| false | qemu | ce0bd027df9c62766a5417521d0f08f27359d43f | static void slirp_init_once(void)
{
static int initialized;
struct hostent *he;
char our_name[256];
#ifdef _WIN32
WSADATA Data;
#endif
if (initialized) {
return;
}
initialized = 1;
#ifdef _WIN32
WSAStartup(MAKEWORD(2,0), &Data);
atexit(winsock_cleanup);
#endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
if (gethostname(our_name, sizeof(our_name)) == 0) {
he = gethostbyname(our_name);
if (he) {
our_addr = *(struct in_addr *)he->h_addr;
}
}
if (our_addr.s_addr == 0) {
our_addr = loopback_addr;
}
if (get_dns_addr(&dns_addr) < 0) {
dns_addr = loopback_addr;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void)
{
static int VAR_0;
struct hostent *VAR_1;
char VAR_2[256];
#ifdef _WIN32
WSADATA Data;
#endif
if (VAR_0) {
return;
}
VAR_0 = 1;
#ifdef _WIN32
WSAStartup(MAKEWORD(2,0), &Data);
atexit(winsock_cleanup);
#endif
loopback_addr.s_addr = htonl(INADDR_LOOPBACK);
if (gethostname(VAR_2, sizeof(VAR_2)) == 0) {
VAR_1 = gethostbyname(VAR_2);
if (VAR_1) {
our_addr = *(struct in_addr *)VAR_1->h_addr;
}
}
if (our_addr.s_addr == 0) {
our_addr = loopback_addr;
}
if (get_dns_addr(&dns_addr) < 0) {
dns_addr = loopback_addr;
}
}
| [
"static void FUNC_0(void)\n{",
"static int VAR_0;",
"struct hostent *VAR_1;",
"char VAR_2[256];",
"#ifdef _WIN32\nWSADATA Data;",
"#endif\nif (VAR_0) {",
"return;",
"}",
"VAR_0 = 1;",
"#ifdef _WIN32\nWSAStartup(MAKEWORD(2,0), &Data);",
"atexit(winsock_cleanup);",
"#endif\nloopback_addr.s_addr = htonl(INADDR_LOOPBACK);",
"if (gethostname(VAR_2, sizeof(VAR_2)) == 0) {",
"VAR_1 = gethostbyname(VAR_2);",
"if (VAR_1) {",
"our_addr = *(struct in_addr *)VAR_1->h_addr;",
"}",
"}",
"if (our_addr.s_addr == 0) {",
"our_addr = loopback_addr;",
"}",
"if (get_dns_addr(&dns_addr) < 0) {",
"dns_addr = loopback_addr;",
"}",
"}"
] | [
0,
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
],
[
29,
31
],
[
33
],
[
35,
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
67
],
[
69
],
[
71
],
[
73
]
] |
1,305 | BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
{
return bdrv_named_nodes_list();
}
| true | qemu | d5a8ee60a0fbc20a2c2d02f3bda1bb1bd365f1ee | BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
{
return bdrv_named_nodes_list();
}
| {
"code": [
" return bdrv_named_nodes_list();"
],
"line_no": [
5
]
} | BlockDeviceInfoList *FUNC_0(Error **errp)
{
return bdrv_named_nodes_list();
}
| [
"BlockDeviceInfoList *FUNC_0(Error **errp)\n{",
"return bdrv_named_nodes_list();",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
1,306 | void backup_start(BlockDriverState *bs, BlockDriverState *target,
int64_t speed, MirrorSyncMode sync_mode,
BdrvDirtyBitmap *sync_bitmap,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
BlockCompletionFunc *cb, void *opaque,
BlockJobTxn *txn, Error **errp)
{
int64_t len;
BlockDriverInfo bdi;
int ret;
assert(bs);
assert(target);
assert(cb);
if (bs == target) {
error_setg(errp, "Source and target cannot be the same");
return;
}
if (!bdrv_is_inserted(bs)) {
error_setg(errp, "Device is not inserted: %s",
bdrv_get_device_name(bs));
return;
}
if (!bdrv_is_inserted(target)) {
error_setg(errp, "Device is not inserted: %s",
bdrv_get_device_name(target));
return;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
return;
}
if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) {
return;
}
if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
if (!sync_bitmap) {
error_setg(errp, "must provide a valid bitmap name for "
"\"incremental\" sync mode");
return;
}
/* Create a new bitmap, and freeze/disable this one. */
if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) {
return;
}
} else if (sync_bitmap) {
error_setg(errp,
"a sync_bitmap was provided to backup_run, "
"but received an incompatible sync_mode (%s)",
MirrorSyncMode_lookup[sync_mode]);
return;
}
len = bdrv_getlength(bs);
if (len < 0) {
error_setg_errno(errp, -len, "unable to get length for '%s'",
bdrv_get_device_name(bs));
goto error;
}
BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed,
cb, opaque, errp);
if (!job) {
goto error;
}
job->on_source_error = on_source_error;
job->on_target_error = on_target_error;
job->target = target;
job->sync_mode = sync_mode;
job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ?
sync_bitmap : NULL;
/* If there is no backing file on the target, we cannot rely on COW if our
* backup cluster size is smaller than the target cluster size. Even for
* targets with a backing file, try to avoid COW if possible. */
ret = bdrv_get_info(job->target, &bdi);
if (ret < 0 && !target->backing) {
error_setg_errno(errp, -ret,
"Couldn't determine the cluster size of the target image, "
"which has no backing file");
error_append_hint(errp,
"Aborting, since this may create an unusable destination image\n");
goto error;
} else if (ret < 0 && target->backing) {
/* Not fatal; just trudge on ahead. */
job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT;
} else {
job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size);
}
bdrv_op_block_all(target, job->common.blocker);
job->common.len = len;
job->common.co = qemu_coroutine_create(backup_run);
block_job_txn_add_job(txn, &job->common);
qemu_coroutine_enter(job->common.co, job);
return;
error:
if (sync_bitmap) {
bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL);
}
}
| true | qemu | 91ab68837933232bcef99da7c968e6d41900419b | void backup_start(BlockDriverState *bs, BlockDriverState *target,
int64_t speed, MirrorSyncMode sync_mode,
BdrvDirtyBitmap *sync_bitmap,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
BlockCompletionFunc *cb, void *opaque,
BlockJobTxn *txn, Error **errp)
{
int64_t len;
BlockDriverInfo bdi;
int ret;
assert(bs);
assert(target);
assert(cb);
if (bs == target) {
error_setg(errp, "Source and target cannot be the same");
return;
}
if (!bdrv_is_inserted(bs)) {
error_setg(errp, "Device is not inserted: %s",
bdrv_get_device_name(bs));
return;
}
if (!bdrv_is_inserted(target)) {
error_setg(errp, "Device is not inserted: %s",
bdrv_get_device_name(target));
return;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
return;
}
if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) {
return;
}
if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
if (!sync_bitmap) {
error_setg(errp, "must provide a valid bitmap name for "
"\"incremental\" sync mode");
return;
}
if (bdrv_dirty_bitmap_create_successor(bs, sync_bitmap, errp) < 0) {
return;
}
} else if (sync_bitmap) {
error_setg(errp,
"a sync_bitmap was provided to backup_run, "
"but received an incompatible sync_mode (%s)",
MirrorSyncMode_lookup[sync_mode]);
return;
}
len = bdrv_getlength(bs);
if (len < 0) {
error_setg_errno(errp, -len, "unable to get length for '%s'",
bdrv_get_device_name(bs));
goto error;
}
BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed,
cb, opaque, errp);
if (!job) {
goto error;
}
job->on_source_error = on_source_error;
job->on_target_error = on_target_error;
job->target = target;
job->sync_mode = sync_mode;
job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ?
sync_bitmap : NULL;
ret = bdrv_get_info(job->target, &bdi);
if (ret < 0 && !target->backing) {
error_setg_errno(errp, -ret,
"Couldn't determine the cluster size of the target image, "
"which has no backing file");
error_append_hint(errp,
"Aborting, since this may create an unusable destination image\n");
goto error;
} else if (ret < 0 && target->backing) {
job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT;
} else {
job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size);
}
bdrv_op_block_all(target, job->common.blocker);
job->common.len = len;
job->common.co = qemu_coroutine_create(backup_run);
block_job_txn_add_job(txn, &job->common);
qemu_coroutine_enter(job->common.co, job);
return;
error:
if (sync_bitmap) {
bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL);
}
}
| {
"code": [
" BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed,",
" cb, opaque, errp);"
],
"line_no": [
135,
137
]
} | void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,
int64_t VAR_2, MirrorSyncMode VAR_3,
BdrvDirtyBitmap *VAR_4,
BlockdevOnError VAR_5,
BlockdevOnError VAR_6,
BlockCompletionFunc *VAR_7, void *VAR_8,
BlockJobTxn *VAR_9, Error **VAR_10)
{
int64_t len;
BlockDriverInfo bdi;
int VAR_11;
assert(VAR_0);
assert(VAR_1);
assert(VAR_7);
if (VAR_0 == VAR_1) {
error_setg(VAR_10, "Source and VAR_1 cannot be the same");
return;
}
if (!bdrv_is_inserted(VAR_0)) {
error_setg(VAR_10, "Device is not inserted: %s",
bdrv_get_device_name(VAR_0));
return;
}
if (!bdrv_is_inserted(VAR_1)) {
error_setg(VAR_10, "Device is not inserted: %s",
bdrv_get_device_name(VAR_1));
return;
}
if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_BACKUP_SOURCE, VAR_10)) {
return;
}
if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_BACKUP_TARGET, VAR_10)) {
return;
}
if (VAR_3 == MIRROR_SYNC_MODE_INCREMENTAL) {
if (!VAR_4) {
error_setg(VAR_10, "must provide a valid bitmap name for "
"\"incremental\" sync mode");
return;
}
if (bdrv_dirty_bitmap_create_successor(VAR_0, VAR_4, VAR_10) < 0) {
return;
}
} else if (VAR_4) {
error_setg(VAR_10,
"a VAR_4 was provided to backup_run, "
"but received an incompatible VAR_3 (%s)",
MirrorSyncMode_lookup[VAR_3]);
return;
}
len = bdrv_getlength(VAR_0);
if (len < 0) {
error_setg_errno(VAR_10, -len, "unable to get length for '%s'",
bdrv_get_device_name(VAR_0));
goto error;
}
BackupBlockJob *job = block_job_create(&backup_job_driver, VAR_0, VAR_2,
VAR_7, VAR_8, VAR_10);
if (!job) {
goto error;
}
job->VAR_5 = VAR_5;
job->VAR_6 = VAR_6;
job->VAR_1 = VAR_1;
job->VAR_3 = VAR_3;
job->VAR_4 = VAR_3 == MIRROR_SYNC_MODE_INCREMENTAL ?
VAR_4 : NULL;
VAR_11 = bdrv_get_info(job->VAR_1, &bdi);
if (VAR_11 < 0 && !VAR_1->backing) {
error_setg_errno(VAR_10, -VAR_11,
"Couldn't determine the cluster size of the VAR_1 image, "
"which has no backing file");
error_append_hint(VAR_10,
"Aborting, since this may create an unusable destination image\n");
goto error;
} else if (VAR_11 < 0 && VAR_1->backing) {
job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT;
} else {
job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size);
}
bdrv_op_block_all(VAR_1, job->common.blocker);
job->common.len = len;
job->common.co = qemu_coroutine_create(backup_run);
block_job_txn_add_job(VAR_9, &job->common);
qemu_coroutine_enter(job->common.co, job);
return;
error:
if (VAR_4) {
bdrv_reclaim_dirty_bitmap(VAR_0, VAR_4, NULL);
}
}
| [
"void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1,\nint64_t VAR_2, MirrorSyncMode VAR_3,\nBdrvDirtyBitmap *VAR_4,\nBlockdevOnError VAR_5,\nBlockdevOnError VAR_6,\nBlockCompletionFunc *VAR_7, void *VAR_8,\nBlockJobTxn *VAR_9, Error **VAR_10)\n{",
"int64_t len;",
"BlockDriverInfo bdi;",
"int VAR_11;",
"assert(VAR_0);",
"assert(VAR_1);",
"assert(VAR_7);",
"if (VAR_0 == VAR_1) {",
"error_setg(VAR_10, \"Source and VAR_1 cannot be the same\");",
"return;",
"}",
"if (!bdrv_is_inserted(VAR_0)) {",
"error_setg(VAR_10, \"Device is not inserted: %s\",\nbdrv_get_device_name(VAR_0));",
"return;",
"}",
"if (!bdrv_is_inserted(VAR_1)) {",
"error_setg(VAR_10, \"Device is not inserted: %s\",\nbdrv_get_device_name(VAR_1));",
"return;",
"}",
"if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_BACKUP_SOURCE, VAR_10)) {",
"return;",
"}",
"if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_BACKUP_TARGET, VAR_10)) {",
"return;",
"}",
"if (VAR_3 == MIRROR_SYNC_MODE_INCREMENTAL) {",
"if (!VAR_4) {",
"error_setg(VAR_10, \"must provide a valid bitmap name for \"\n\"\\\"incremental\\\" sync mode\");",
"return;",
"}",
"if (bdrv_dirty_bitmap_create_successor(VAR_0, VAR_4, VAR_10) < 0) {",
"return;",
"}",
"} else if (VAR_4) {",
"error_setg(VAR_10,\n\"a VAR_4 was provided to backup_run, \"\n\"but received an incompatible VAR_3 (%s)\",\nMirrorSyncMode_lookup[VAR_3]);",
"return;",
"}",
"len = bdrv_getlength(VAR_0);",
"if (len < 0) {",
"error_setg_errno(VAR_10, -len, \"unable to get length for '%s'\",\nbdrv_get_device_name(VAR_0));",
"goto error;",
"}",
"BackupBlockJob *job = block_job_create(&backup_job_driver, VAR_0, VAR_2,\nVAR_7, VAR_8, VAR_10);",
"if (!job) {",
"goto error;",
"}",
"job->VAR_5 = VAR_5;",
"job->VAR_6 = VAR_6;",
"job->VAR_1 = VAR_1;",
"job->VAR_3 = VAR_3;",
"job->VAR_4 = VAR_3 == MIRROR_SYNC_MODE_INCREMENTAL ?\nVAR_4 : NULL;",
"VAR_11 = bdrv_get_info(job->VAR_1, &bdi);",
"if (VAR_11 < 0 && !VAR_1->backing) {",
"error_setg_errno(VAR_10, -VAR_11,\n\"Couldn't determine the cluster size of the VAR_1 image, \"\n\"which has no backing file\");",
"error_append_hint(VAR_10,\n\"Aborting, since this may create an unusable destination image\\n\");",
"goto error;",
"} else if (VAR_11 < 0 && VAR_1->backing) {",
"job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT;",
"} else {",
"job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size);",
"}",
"bdrv_op_block_all(VAR_1, job->common.blocker);",
"job->common.len = len;",
"job->common.co = qemu_coroutine_create(backup_run);",
"block_job_txn_add_job(VAR_9, &job->common);",
"qemu_coroutine_enter(job->common.co, job);",
"return;",
"error:\nif (VAR_4) {",
"bdrv_reclaim_dirty_bitmap(VAR_0, VAR_4, NULL);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5,
7,
9,
11,
13,
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111,
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127
],
[
129
],
[
131
],
[
135,
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155,
157
],
[
167
],
[
169
],
[
171,
173,
175
],
[
177,
179
],
[
181
],
[
183
],
[
187
],
[
189
],
[
191
],
[
193
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
211,
213
],
[
215
],
[
217
],
[
219
]
] |
1,309 | void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n",
env->nip, env->lr, env->ctr, cpu_read_xer(env),
cs->cpu_index);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " iidx %d didx %d\n",
env->msr, env->spr[SPR_HID0],
env->hflags, env->immu_idx, env->dmmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
/* FSL-specific */
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
/*
* IVORs are left out as they are large and do not change often --
* they can be read with "p $ivor0", "p $ivor1", etc.
*/
if (env->flags & POWERPC_FLAG_CFAR) {
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_64B:
case POWERPC_MMU_2_03:
case POWERPC_MMU_2_06:
case POWERPC_MMU_2_06a:
case POWERPC_MMU_2_07:
case POWERPC_MMU_2_07a:
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx " DAR " TARGET_FMT_lx
" DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
env->spr[SPR_DAR], env->spr[SPR_DSISR]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL
| true | qemu | f2b70fded9b32c4b9e45e5b7f11bfc2ef961ede7 | void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
#define RGPL 4
#define RFPL 4
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
int i;
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n",
env->nip, env->lr, env->ctr, cpu_read_xer(env),
cs->cpu_index);
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " iidx %d didx %d\n",
env->msr, env->spr[SPR_HID0],
env->hflags, env->immu_idx, env->dmmu_idx);
#if !defined(NO_TIMER_DUMP)
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0)
cpu_fprintf(f, "GPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
if ((i & (RGPL - 1)) == (RGPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "CR ");
for (i = 0; i < 8; i++)
cpu_fprintf(f, "%01x", env->crf[i]);
cpu_fprintf(f, " [");
for (i = 0; i < 8; i++) {
char a = '-';
if (env->crf[i] & 0x08)
a = 'L';
else if (env->crf[i] & 0x04)
a = 'G';
else if (env->crf[i] & 0x02)
a = 'E';
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (i = 0; i < 32; i++) {
if ((i & (RFPL - 1)) == 0)
cpu_fprintf(f, "FPR%02d", i);
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
if ((i & (RFPL - 1)) == (RFPL - 1))
cpu_fprintf(f, "\n");
cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
if (env->flags & POWERPC_FLAG_CFAR) {
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_64B:
case POWERPC_MMU_2_03:
case POWERPC_MMU_2_06:
case POWERPC_MMU_2_06a:
case POWERPC_MMU_2_07:
case POWERPC_MMU_2_07a:
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx " DAR " TARGET_FMT_lx
" DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
env->spr[SPR_DAR], env->spr[SPR_DSISR]);
break;
case POWERPC_MMU_BOOKE206:
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL
| {
"code": [],
"line_no": []
} | void FUNC_0(CPUState *VAR_0, FILE *VAR_1, fprintf_function VAR_2,
int VAR_3)
{
#define RGPL 4
#define RFPL 4
PowerPCCPU *cpu = POWERPC_CPU(VAR_0);
CPUPPCState *env = &cpu->env;
int VAR_4;
VAR_2(VAR_1, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n",
env->nip, env->lr, env->ctr, cpu_read_xer(env),
VAR_0->cpu_index);
VAR_2(VAR_1, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
TARGET_FMT_lx " iidx %d didx %d\n",
env->msr, env->spr[SPR_HID0],
env->hflags, env->immu_idx, env->dmmu_idx);
#if !defined(NO_TIMER_DUMP)
VAR_2(VAR_1, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
" DECR %08" PRIu32
"\n",
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
#if !defined(CONFIG_USER_ONLY)
, cpu_ppc_load_decr(env)
);
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if ((VAR_4 & (RGPL - 1)) == 0)
VAR_2(VAR_1, "GPR%02d", VAR_4);
VAR_2(VAR_1, " %016" PRIx64, ppc_dump_gpr(env, VAR_4));
if ((VAR_4 & (RGPL - 1)) == (RGPL - 1))
VAR_2(VAR_1, "\n");
VAR_2(VAR_1, "CR ");
for (VAR_4 = 0; VAR_4 < 8; VAR_4++)
VAR_2(VAR_1, "%01x", env->crf[VAR_4]);
VAR_2(VAR_1, " [");
for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {
char VAR_5 = '-';
if (env->crf[VAR_4] & 0x08)
VAR_5 = 'L';
else if (env->crf[VAR_4] & 0x04)
VAR_5 = 'G';
else if (env->crf[VAR_4] & 0x02)
VAR_5 = 'E';
VAR_2(VAR_1, " %c%c", VAR_5, env->crf[VAR_4] & 0x01 ? 'O' : ' ');
VAR_2(VAR_1, " ] RES " TARGET_FMT_lx "\n",
env->reserve_addr);
for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {
if ((VAR_4 & (RFPL - 1)) == 0)
VAR_2(VAR_1, "FPR%02d", VAR_4);
VAR_2(VAR_1, " %016" PRIx64, *((uint64_t *)&env->fpr[VAR_4]));
if ((VAR_4 & (RFPL - 1)) == (RFPL - 1))
VAR_2(VAR_1, "\n");
VAR_2(VAR_1, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
#if !defined(CONFIG_USER_ONLY)
VAR_2(VAR_1, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
VAR_2(VAR_1, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
VAR_2(VAR_1, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
if (env->excp_model == POWERPC_EXCP_BOOKE) {
VAR_2(VAR_1, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
VAR_2(VAR_1, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
VAR_2(VAR_1, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
VAR_2(VAR_1, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
" EPR " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
env->spr[SPR_BOOKE_EPR]);
VAR_2(VAR_1, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
if (env->VAR_3 & POWERPC_FLAG_CFAR) {
VAR_2(VAR_1, " CFAR " TARGET_FMT_lx"\n", env->cfar);
switch (env->mmu_model) {
case POWERPC_MMU_32B:
case POWERPC_MMU_601:
case POWERPC_MMU_SOFT_6xx:
case POWERPC_MMU_SOFT_74xx:
case POWERPC_MMU_64B:
case POWERPC_MMU_2_03:
case POWERPC_MMU_2_06:
case POWERPC_MMU_2_06a:
case POWERPC_MMU_2_07:
case POWERPC_MMU_2_07a:
VAR_2(VAR_1, " SDR1 " TARGET_FMT_lx " DAR " TARGET_FMT_lx
" DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
env->spr[SPR_DAR], env->spr[SPR_DSISR]);
break;
case POWERPC_MMU_BOOKE206:
VAR_2(VAR_1, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
VAR_2(VAR_1, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
VAR_2(VAR_1, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
" TLB1CFG " TARGET_FMT_lx "\n",
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
env->spr[SPR_BOOKE_TLB1CFG]);
break;
default:
break;
#undef RGPL
#undef RFPL
| [
"void FUNC_0(CPUState *VAR_0, FILE *VAR_1, fprintf_function VAR_2,\nint VAR_3)\n{",
"#define RGPL 4\n#define RFPL 4\nPowerPCCPU *cpu = POWERPC_CPU(VAR_0);",
"CPUPPCState *env = &cpu->env;",
"int VAR_4;",
"VAR_2(VAR_1, \"NIP \" TARGET_FMT_lx \" LR \" TARGET_FMT_lx \" CTR \"\nTARGET_FMT_lx \" XER \" TARGET_FMT_lx \" CPU#%d\\n\",\nenv->nip, env->lr, env->ctr, cpu_read_xer(env),\nVAR_0->cpu_index);",
"VAR_2(VAR_1, \"MSR \" TARGET_FMT_lx \" HID0 \" TARGET_FMT_lx \" HF \"\nTARGET_FMT_lx \" iidx %d didx %d\\n\",\nenv->msr, env->spr[SPR_HID0],\nenv->hflags, env->immu_idx, env->dmmu_idx);",
"#if !defined(NO_TIMER_DUMP)\nVAR_2(VAR_1, \"TB %08\" PRIu32 \" %08\" PRIu64\n#if !defined(CONFIG_USER_ONLY)\n\" DECR %08\" PRIu32\n\"\\n\",\ncpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)\n#if !defined(CONFIG_USER_ONLY)\n, cpu_ppc_load_decr(env)\n);",
"for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if ((VAR_4 & (RGPL - 1)) == 0)\nVAR_2(VAR_1, \"GPR%02d\", VAR_4);",
"VAR_2(VAR_1, \" %016\" PRIx64, ppc_dump_gpr(env, VAR_4));",
"if ((VAR_4 & (RGPL - 1)) == (RGPL - 1))\nVAR_2(VAR_1, \"\\n\");",
"VAR_2(VAR_1, \"CR \");",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++)",
"VAR_2(VAR_1, \"%01x\", env->crf[VAR_4]);",
"VAR_2(VAR_1, \" [\");",
"for (VAR_4 = 0; VAR_4 < 8; VAR_4++) {",
"char VAR_5 = '-';",
"if (env->crf[VAR_4] & 0x08)\nVAR_5 = 'L';",
"else if (env->crf[VAR_4] & 0x04)\nVAR_5 = 'G';",
"else if (env->crf[VAR_4] & 0x02)\nVAR_5 = 'E';",
"VAR_2(VAR_1, \" %c%c\", VAR_5, env->crf[VAR_4] & 0x01 ? 'O' : ' ');",
"VAR_2(VAR_1, \" ] RES \" TARGET_FMT_lx \"\\n\",\nenv->reserve_addr);",
"for (VAR_4 = 0; VAR_4 < 32; VAR_4++) {",
"if ((VAR_4 & (RFPL - 1)) == 0)\nVAR_2(VAR_1, \"FPR%02d\", VAR_4);",
"VAR_2(VAR_1, \" %016\" PRIx64, *((uint64_t *)&env->fpr[VAR_4]));",
"if ((VAR_4 & (RFPL - 1)) == (RFPL - 1))\nVAR_2(VAR_1, \"\\n\");",
"VAR_2(VAR_1, \"FPSCR \" TARGET_FMT_lx \"\\n\", env->fpscr);",
"#if !defined(CONFIG_USER_ONLY)\nVAR_2(VAR_1, \" SRR0 \" TARGET_FMT_lx \" SRR1 \" TARGET_FMT_lx\n\" PVR \" TARGET_FMT_lx \" VRSAVE \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_SRR0], env->spr[SPR_SRR1],\nenv->spr[SPR_PVR], env->spr[SPR_VRSAVE]);",
"VAR_2(VAR_1, \"SPRG0 \" TARGET_FMT_lx \" SPRG1 \" TARGET_FMT_lx\n\" SPRG2 \" TARGET_FMT_lx \" SPRG3 \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_SPRG0], env->spr[SPR_SPRG1],\nenv->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);",
"VAR_2(VAR_1, \"SPRG4 \" TARGET_FMT_lx \" SPRG5 \" TARGET_FMT_lx\n\" SPRG6 \" TARGET_FMT_lx \" SPRG7 \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_SPRG4], env->spr[SPR_SPRG5],\nenv->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);",
"if (env->excp_model == POWERPC_EXCP_BOOKE) {",
"VAR_2(VAR_1, \"CSRR0 \" TARGET_FMT_lx \" CSRR1 \" TARGET_FMT_lx\n\" MCSRR0 \" TARGET_FMT_lx \" MCSRR1 \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],\nenv->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);",
"VAR_2(VAR_1, \" TCR \" TARGET_FMT_lx \" TSR \" TARGET_FMT_lx\n\" ESR \" TARGET_FMT_lx \" DEAR \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],\nenv->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);",
"VAR_2(VAR_1, \" PIR \" TARGET_FMT_lx \" DECAR \" TARGET_FMT_lx\n\" IVPR \" TARGET_FMT_lx \" EPCR \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],\nenv->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);",
"VAR_2(VAR_1, \" MCSR \" TARGET_FMT_lx \" SPRG8 \" TARGET_FMT_lx\n\" EPR \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],\nenv->spr[SPR_BOOKE_EPR]);",
"VAR_2(VAR_1, \" MCAR \" TARGET_FMT_lx \" PID1 \" TARGET_FMT_lx\n\" PID2 \" TARGET_FMT_lx \" SVR \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],\nenv->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);",
"if (env->VAR_3 & POWERPC_FLAG_CFAR) {",
"VAR_2(VAR_1, \" CFAR \" TARGET_FMT_lx\"\\n\", env->cfar);",
"switch (env->mmu_model) {",
"case POWERPC_MMU_32B:\ncase POWERPC_MMU_601:\ncase POWERPC_MMU_SOFT_6xx:\ncase POWERPC_MMU_SOFT_74xx:\ncase POWERPC_MMU_64B:\ncase POWERPC_MMU_2_03:\ncase POWERPC_MMU_2_06:\ncase POWERPC_MMU_2_06a:\ncase POWERPC_MMU_2_07:\ncase POWERPC_MMU_2_07a:\nVAR_2(VAR_1, \" SDR1 \" TARGET_FMT_lx \" DAR \" TARGET_FMT_lx\n\" DSISR \" TARGET_FMT_lx \"\\n\", env->spr[SPR_SDR1],\nenv->spr[SPR_DAR], env->spr[SPR_DSISR]);",
"break;",
"case POWERPC_MMU_BOOKE206:\nVAR_2(VAR_1, \" MAS0 \" TARGET_FMT_lx \" MAS1 \" TARGET_FMT_lx\n\" MAS2 \" TARGET_FMT_lx \" MAS3 \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],\nenv->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);",
"VAR_2(VAR_1, \" MAS4 \" TARGET_FMT_lx \" MAS6 \" TARGET_FMT_lx\n\" MAS7 \" TARGET_FMT_lx \" PID \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],\nenv->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);",
"VAR_2(VAR_1, \"MMUCFG \" TARGET_FMT_lx \" TLB0CFG \" TARGET_FMT_lx\n\" TLB1CFG \" TARGET_FMT_lx \"\\n\",\nenv->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],\nenv->spr[SPR_BOOKE_TLB1CFG]);",
"break;",
"default:\nbreak;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7,
9,
13
],
[
15
],
[
17
],
[
21,
23,
25,
27
],
[
29,
31,
33,
35
],
[
37,
39,
41,
43,
46,
48,
50,
52,
55
],
[
58
],
[
60,
62
],
[
64
],
[
66,
68
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87,
89
],
[
91,
93
],
[
95
],
[
98,
100
],
[
102
],
[
104,
106
],
[
108
],
[
110,
112
],
[
115
],
[
117,
119,
121,
123,
125
],
[
129,
131,
133,
135
],
[
139,
141,
143,
145
],
[
156
],
[
158,
160,
162,
164
],
[
168,
170,
172,
174
],
[
178,
180,
182,
184
],
[
188,
190,
192,
194
],
[
200,
202,
204,
206
],
[
222
],
[
224
],
[
230
],
[
232,
234,
236,
238,
241,
243,
245,
247,
249,
251,
254,
256,
258
],
[
260
],
[
262,
264,
266,
268,
270
],
[
274,
276,
278,
280
],
[
284,
286,
288,
290
],
[
292
],
[
294,
296
]
] |
1,310 | void uninit_opts(void)
{
int i;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
av_freep(&avcodec_opts[i]);
av_freep(&avformat_opts->key);
av_freep(&avformat_opts);
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
} | true | FFmpeg | ba3517aa6f573d280d80866e776885be7f01de77 | void uninit_opts(void)
{
int i;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
av_freep(&avcodec_opts[i]);
av_freep(&avformat_opts->key);
av_freep(&avformat_opts);
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
} | {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
int VAR_0;
for (VAR_0 = 0; VAR_0 < AVMEDIA_TYPE_NB; VAR_0++)
av_freep(&avcodec_opts[VAR_0]);
av_freep(&avformat_opts->key);
av_freep(&avformat_opts);
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
} | [
"void FUNC_0(void)\n{",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < AVMEDIA_TYPE_NB; VAR_0++)",
"av_freep(&avcodec_opts[VAR_0]);",
"av_freep(&avformat_opts->key);",
"av_freep(&avformat_opts);",
"#if CONFIG_SWSCALE\nav_freep(&sws_opts);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15,
17
],
[
19,
23
]
] |
1,311 | static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
{
USBDevice *dev;
CharDriverState *cdrv;
cdrv = qemu_chr_new("braille", "braille", NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-braille");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
qdev_init_nofail(&dev->qdev);
return dev;
}
| true | qemu | 3bc36a401e0f33e63a4d2c58b646ddf78efb567c | static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
{
USBDevice *dev;
CharDriverState *cdrv;
cdrv = qemu_chr_new("braille", "braille", NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-braille");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
qdev_init_nofail(&dev->qdev);
return dev;
}
| {
"code": [
" return NULL;",
" qdev_init_nofail(&dev->qdev);",
" qdev_init_nofail(&dev->qdev);",
" qdev_init_nofail(&dev->qdev);",
" return NULL;",
" qdev_init_nofail(&dev->qdev);"
],
"line_no": [
15,
23,
23,
23,
15,
23
]
} | static USBDevice *FUNC_0(USBBus *bus, const char *unused)
{
USBDevice *dev;
CharDriverState *cdrv;
cdrv = qemu_chr_new("braille", "braille", NULL);
if (!cdrv)
return NULL;
dev = usb_create(bus, "usb-braille");
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
qdev_init_nofail(&dev->qdev);
return dev;
}
| [
"static USBDevice *FUNC_0(USBBus *bus, const char *unused)\n{",
"USBDevice *dev;",
"CharDriverState *cdrv;",
"cdrv = qemu_chr_new(\"braille\", \"braille\", NULL);",
"if (!cdrv)\nreturn NULL;",
"dev = usb_create(bus, \"usb-braille\");",
"qdev_prop_set_chr(&dev->qdev, \"chardev\", cdrv);",
"qdev_init_nofail(&dev->qdev);",
"return dev;",
"}"
] | [
0,
0,
0,
0,
1,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
]
] |
1,312 | void qdev_free(DeviceState *dev)
{
BusState *bus;
if (dev->state == DEV_STATE_INITIALIZED) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
if (dev->info->exit)
dev->info->exit(dev);
if (dev->opts)
qemu_opts_del(dev->opts);
}
qemu_unregister_reset(qdev_reset, dev);
QLIST_REMOVE(dev, sibling);
for (prop = dev->info->props; prop && prop->name; prop++) {
if (prop->info->free) {
prop->info->free(dev, prop);
}
}
qemu_free(dev);
} | true | qemu | d21357df9a2a6b7e6bb2f579d04877f3bd65c557 | void qdev_free(DeviceState *dev)
{
BusState *bus;
if (dev->state == DEV_STATE_INITIALIZED) {
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
qbus_free(bus);
}
if (dev->info->vmsd)
vmstate_unregister(dev->info->vmsd, dev);
if (dev->info->exit)
dev->info->exit(dev);
if (dev->opts)
qemu_opts_del(dev->opts);
}
qemu_unregister_reset(qdev_reset, dev);
QLIST_REMOVE(dev, sibling);
for (prop = dev->info->props; prop && prop->name; prop++) {
if (prop->info->free) {
prop->info->free(dev, prop);
}
}
qemu_free(dev);
} | {
"code": [],
"line_no": []
} | void FUNC_0(DeviceState *VAR_0)
{
BusState *bus;
if (VAR_0->state == DEV_STATE_INITIALIZED) {
while (VAR_0->num_child_bus) {
bus = QLIST_FIRST(&VAR_0->child_bus);
qbus_free(bus);
}
if (VAR_0->info->vmsd)
vmstate_unregister(VAR_0->info->vmsd, VAR_0);
if (VAR_0->info->exit)
VAR_0->info->exit(VAR_0);
if (VAR_0->opts)
qemu_opts_del(VAR_0->opts);
}
qemu_unregister_reset(qdev_reset, VAR_0);
QLIST_REMOVE(VAR_0, sibling);
for (prop = VAR_0->info->props; prop && prop->name; prop++) {
if (prop->info->free) {
prop->info->free(VAR_0, prop);
}
}
qemu_free(VAR_0);
} | [
"void FUNC_0(DeviceState *VAR_0)\n{",
"BusState *bus;",
"if (VAR_0->state == DEV_STATE_INITIALIZED) {",
"while (VAR_0->num_child_bus) {",
"bus = QLIST_FIRST(&VAR_0->child_bus);",
"qbus_free(bus);",
"}",
"if (VAR_0->info->vmsd)\nvmstate_unregister(VAR_0->info->vmsd, VAR_0);",
"if (VAR_0->info->exit)\nVAR_0->info->exit(VAR_0);",
"if (VAR_0->opts)\nqemu_opts_del(VAR_0->opts);",
"}",
"qemu_unregister_reset(qdev_reset, VAR_0);",
"QLIST_REMOVE(VAR_0, sibling);",
"for (prop = VAR_0->info->props; prop && prop->name; prop++) {",
"if (prop->info->free) {",
"prop->info->free(VAR_0, prop);",
"}",
"}",
"qemu_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
10
],
[
12
],
[
14
],
[
16
],
[
18
],
[
20,
22
],
[
24,
26
],
[
28,
30
],
[
32
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
46
],
[
48
],
[
50
]
] |
1,313 | static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 3%1, %%mm3\n\t"
"punpckldq 6%1, %%mm0\n\t"
"punpckldq 9%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 12;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int r= *s++;
const int g= *s++;
const int b= *s++;
*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
}
}
| true | FFmpeg | 6e42e6c4b410dbef8b593c2d796a5dad95f89ee4 | static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *s = src;
const uint8_t *end;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
end = s + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = end - 15;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 3%1, %%mm3\n\t"
"punpckldq 6%1, %%mm0\n\t"
"punpckldq 9%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*s),"m"(blue_16mask):"memory");
d += 4;
s += 12;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
const int r= *s++;
const int g= *s++;
const int b= *s++;
*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
}
}
| {
"code": [
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"\twhile(s < end)",
"#ifdef HAVE_MMX",
"#endif",
"#ifdef HAVE_MMX",
"#endif",
"#endif",
"#endif",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\tmm_end = end - 15;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t3%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 6%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 9%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 12;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tconst int b= *s++;",
"\t\tconst int g= *s++;",
"\t\tconst int r= *s++;",
"\t\t*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\t ::\"m\"(red_16mask),\"m\"(green_16mask));",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t3%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 6%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 9%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"psllq\t$8, %%mm0\\n\\t\"",
"\t\t\"psllq\t$8, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm1\\n\\t\"",
"\t\t\"psrlq\t$5, %%mm4\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\t:\"=m\"(*d):\"m\"(*s),\"m\"(blue_16mask):\"memory\");",
"\t\td += 4;",
"\t\ts += 12;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tconst int r= *s++;",
"\t\tconst int g= *s++;",
"\t\tconst int b= *s++;",
"\t\t*d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t3%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 6%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 9%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 12;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tconst int b= *s++;",
"\t\tconst int g= *s++;",
"\t\tconst int r= *s++;",
"\tconst uint8_t *s = src;",
"\tconst uint8_t *end;",
"\tconst uint8_t *mm_end;",
"\tuint16_t *d = (uint16_t *)dst;",
"\tend = s + src_size;",
"\t__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"\t__asm __volatile(",
"\t \"movq\t%0, %%mm7\\n\\t\"",
"\t \"movq\t%1, %%mm6\\n\\t\"",
"\tmm_end = end - 15;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"movd\t%1, %%mm0\\n\\t\"",
"\t\t\"movd\t3%1, %%mm3\\n\\t\"",
"\t\t\"punpckldq 6%1, %%mm0\\n\\t\"",
"\t\t\"punpckldq 9%1, %%mm3\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm1\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm4\\n\\t\"",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm0\\n\\t\"",
"\t\t\"pand\t%%mm7, %%mm3\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm1\\n\\t\"",
"\t\t\"pand\t%%mm6, %%mm4\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm2\\n\\t\"",
"\t\t\"psrlq\t$19, %%mm5\\n\\t\"",
"\t\t\"pand\t%2, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"psllq\t$16, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm3, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t\td += 4;",
"\t\ts += 12;",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t\tconst int r= *s++;",
"\t\tconst int g= *s++;",
"\t\tconst int b= *s++;",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t __asm __volatile(",
"\t\t\"movq\t%%mm3, %%mm5\\n\\t\"",
"\t\t\"movq\t%%mm0, %%mm2\\n\\t\"",
"\t\t\"pand\t%2, %%mm5\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\twhile(s < mm_end)",
"\t __asm __volatile(",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\t\"por\t%%mm1, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm2, %%mm0\\n\\t\"",
"\t\t\"por\t%%mm4, %%mm3\\n\\t\"",
"\t\t\"por\t%%mm5, %%mm3\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"\twhile(s < end)",
"\t__asm __volatile(",
"#endif",
"\t__asm __volatile(SFENCE:::\"memory\");",
"\t__asm __volatile(EMMS:::\"memory\");",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"\t\tPREFETCH\" 32%1\\n\\t\"",
"\t\tMOVNTQ\"\t%%mm0, %0\\n\\t\"",
"#endif",
"#endif"
],
"line_no": [
109,
109,
109,
109,
9,
13,
9,
13,
13,
13,
23,
49,
93,
23,
49,
61,
69,
81,
93,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
29,
33,
37,
39,
41,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
13,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
37,
39,
41,
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,
103,
105,
13,
109,
5,
7,
11,
15,
17,
31,
21,
23,
25,
27,
33,
37,
39,
41,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
13,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
103,
105,
13,
109,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
65,
67,
69,
71,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
103,
105,
13,
109,
117,
115,
113,
119,
5,
7,
11,
15,
17,
21,
23,
25,
27,
29,
31,
33,
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,
103,
105,
13,
109,
113,
115,
117,
119,
5,
7,
11,
15,
17,
21,
23,
25,
27,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
69,
71,
81,
83,
85,
87,
89,
91,
93,
97,
99,
103,
105,
13,
109,
117,
115,
113,
5,
7,
11,
15,
17,
21,
23,
25,
27,
31,
33,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
61,
63,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
97,
99,
103,
105,
13,
109,
113,
115,
117,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
81,
85,
83,
87,
37,
55,
51,
79,
85,
85,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
33,
37,
39,
81,
85,
83,
87,
93,
103,
105,
13,
109,
23,
13,
103,
105,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
39,
93,
13,
39,
93,
13,
13
]
} | static inline void FUNC_0(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint8_t *VAR_0 = src;
const uint8_t *VAR_1;
#ifdef HAVE_MMX
const uint8_t *mm_end;
#endif
uint16_t *d = (uint16_t *)dst;
VAR_1 = VAR_0 + src_size;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*src):"memory");
__asm __volatile(
"movq %0, %%mm7\n\t"
"movq %1, %%mm6\n\t"
::"m"(red_16mask),"m"(green_16mask));
mm_end = VAR_1 - 15;
while(VAR_0 < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movd %1, %%mm0\n\t"
"movd 3%1, %%mm3\n\t"
"punpckldq 6%1, %%mm0\n\t"
"punpckldq 9%1, %%mm3\n\t"
"movq %%mm0, %%mm1\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm3, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"psllq $8, %%mm0\n\t"
"psllq $8, %%mm3\n\t"
"pand %%mm7, %%mm0\n\t"
"pand %%mm7, %%mm3\n\t"
"psrlq $5, %%mm1\n\t"
"psrlq $5, %%mm4\n\t"
"pand %%mm6, %%mm1\n\t"
"pand %%mm6, %%mm4\n\t"
"psrlq $19, %%mm2\n\t"
"psrlq $19, %%mm5\n\t"
"pand %2, %%mm2\n\t"
"pand %2, %%mm5\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm5, %%mm3\n\t"
"psllq $16, %%mm3\n\t"
"por %%mm3, %%mm0\n\t"
MOVNTQ" %%mm0, %0\n\t"
:"=m"(*d):"m"(*VAR_0),"m"(blue_16mask):"memory");
d += 4;
VAR_0 += 12;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(VAR_0 < VAR_1)
{
const int VAR_2= *VAR_0++;
const int VAR_3= *VAR_0++;
const int VAR_4= *VAR_0++;
*d++ = (VAR_4>>3) | ((VAR_3&0xFC)<<3) | ((VAR_2&0xF8)<<8);
}
}
| [
"static inline void FUNC_0(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint8_t *VAR_0 = src;",
"const uint8_t *VAR_1;",
"#ifdef HAVE_MMX\nconst uint8_t *mm_end;",
"#endif\nuint16_t *d = (uint16_t *)dst;",
"VAR_1 = VAR_0 + src_size;",
"#ifdef HAVE_MMX\n__asm __volatile(PREFETCH\"\t%0\"::\"m\"(*src):\"memory\");",
"__asm __volatile(\n\"movq\t%0, %%mm7\\n\\t\"\n\"movq\t%1, %%mm6\\n\\t\"\n::\"m\"(red_16mask),\"m\"(green_16mask));",
"mm_end = VAR_1 - 15;",
"while(VAR_0 < mm_end)\n{",
"__asm __volatile(\nPREFETCH\" 32%1\\n\\t\"\n\"movd\t%1, %%mm0\\n\\t\"\n\"movd\t3%1, %%mm3\\n\\t\"\n\"punpckldq 6%1, %%mm0\\n\\t\"\n\"punpckldq 9%1, %%mm3\\n\\t\"\n\"movq\t%%mm0, %%mm1\\n\\t\"\n\"movq\t%%mm0, %%mm2\\n\\t\"\n\"movq\t%%mm3, %%mm4\\n\\t\"\n\"movq\t%%mm3, %%mm5\\n\\t\"\n\"psllq\t$8, %%mm0\\n\\t\"\n\"psllq\t$8, %%mm3\\n\\t\"\n\"pand\t%%mm7, %%mm0\\n\\t\"\n\"pand\t%%mm7, %%mm3\\n\\t\"\n\"psrlq\t$5, %%mm1\\n\\t\"\n\"psrlq\t$5, %%mm4\\n\\t\"\n\"pand\t%%mm6, %%mm1\\n\\t\"\n\"pand\t%%mm6, %%mm4\\n\\t\"\n\"psrlq\t$19, %%mm2\\n\\t\"\n\"psrlq\t$19, %%mm5\\n\\t\"\n\"pand\t%2, %%mm2\\n\\t\"\n\"pand\t%2, %%mm5\\n\\t\"\n\"por\t%%mm1, %%mm0\\n\\t\"\n\"por\t%%mm4, %%mm3\\n\\t\"\n\"por\t%%mm2, %%mm0\\n\\t\"\n\"por\t%%mm5, %%mm3\\n\\t\"\n\"psllq\t$16, %%mm3\\n\\t\"\n\"por\t%%mm3, %%mm0\\n\\t\"\nMOVNTQ\"\t%%mm0, %0\\n\\t\"\n:\"=m\"(*d):\"m\"(*VAR_0),\"m\"(blue_16mask):\"memory\");",
"d += 4;",
"VAR_0 += 12;",
"}",
"__asm __volatile(SFENCE:::\"memory\");",
"__asm __volatile(EMMS:::\"memory\");",
"#endif\nwhile(VAR_0 < VAR_1)\n{",
"const int VAR_2= *VAR_0++;",
"const int VAR_3= *VAR_0++;",
"const int VAR_4= *VAR_0++;",
"*d++ = (VAR_4>>3) | ((VAR_3&0xFC)<<3) | ((VAR_2&0xF8)<<8);",
"}",
"}"
] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13,
15
],
[
17
],
[
19,
21
],
[
23,
25,
27,
29
],
[
31
],
[
33,
35
],
[
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
1,314 | static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#if COMPILE_TEMPLATE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
/* borrowed 32 to 24 */
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*s)
:"memory");
d += 24;
s += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
}
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#if COMPILE_TEMPLATE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while (s < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*s)
:"memory");
d += 24;
s += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (s < end) {
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
}
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *VAR_0;
#if COMPILE_TEMPLATE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *VAR_1 = (const uint16_t *)src;
VAR_0 = VAR_1 + src_size/2;
#if COMPILE_TEMPLATE_MMX
__asm__ volatile(PREFETCH" %0"::"m"(*VAR_1):"memory");
mm_end = VAR_0 - 7;
while (VAR_1 < mm_end) {
__asm__ volatile(
PREFETCH" 32%1 \n\t"
"movq %1, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
"movq %1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
"movq %%mm0, %%mm6 \n\t"
"movq %%mm3, %%mm7 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
"movq 8%1, %%mm2 \n\t"
"pand %2, %%mm0 \n\t"
"pand %3, %%mm1 \n\t"
"pand %4, %%mm2 \n\t"
"psllq $3, %%mm0 \n\t"
"psrlq $3, %%mm1 \n\t"
"psrlq $8, %%mm2 \n\t"
"movq %%mm0, %%mm3 \n\t"
"movq %%mm1, %%mm4 \n\t"
"movq %%mm2, %%mm5 \n\t"
"punpcklwd %5, %%mm0 \n\t"
"punpcklwd %5, %%mm1 \n\t"
"punpcklwd %5, %%mm2 \n\t"
"punpckhwd %5, %%mm3 \n\t"
"punpckhwd %5, %%mm4 \n\t"
"punpckhwd %5, %%mm5 \n\t"
"psllq $8, %%mm1 \n\t"
"psllq $16, %%mm2 \n\t"
"por %%mm1, %%mm0 \n\t"
"por %%mm2, %%mm0 \n\t"
"psllq $8, %%mm4 \n\t"
"psllq $16, %%mm5 \n\t"
"por %%mm4, %%mm3 \n\t"
"por %%mm5, %%mm3 \n\t"
:"=m"(*d)
:"m"(*VAR_1),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
__asm__ volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
"movq %%mm6, %%mm0 \n\t"
"movq %%mm7, %%mm1 \n\t"
"movq %%mm4, %%mm6 \n\t"
"movq %%mm5, %%mm7 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
STORE_BGR24_MMX
:"=m"(*d)
:"m"(*VAR_1)
:"memory");
d += 24;
VAR_1 += 8;
}
__asm__ volatile(SFENCE:::"memory");
__asm__ volatile(EMMS:::"memory");
#endif
while (VAR_1 < VAR_0) {
register uint16_t VAR_2;
VAR_2 = *VAR_1++;
*d++ = (VAR_2&0x1F)<<3;
*d++ = (VAR_2&0x7E0)>>3;
*d++ = (VAR_2&0xF800)>>8;
}
}
| [
"static inline void FUNC_0(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size)\n{",
"const uint16_t *VAR_0;",
"#if COMPILE_TEMPLATE_MMX\nconst uint16_t *mm_end;",
"#endif\nuint8_t *d = (uint8_t *)dst;",
"const uint16_t *VAR_1 = (const uint16_t *)src;",
"VAR_0 = VAR_1 + src_size/2;",
"#if COMPILE_TEMPLATE_MMX\n__asm__ volatile(PREFETCH\" %0\"::\"m\"(*VAR_1):\"memory\");",
"mm_end = VAR_0 - 7;",
"while (VAR_1 < mm_end) {",
"__asm__ volatile(\nPREFETCH\" 32%1 \\n\\t\"\n\"movq %1, %%mm0 \\n\\t\"\n\"movq %1, %%mm1 \\n\\t\"\n\"movq %1, %%mm2 \\n\\t\"\n\"pand %2, %%mm0 \\n\\t\"\n\"pand %3, %%mm1 \\n\\t\"\n\"pand %4, %%mm2 \\n\\t\"\n\"psllq $3, %%mm0 \\n\\t\"\n\"psrlq $3, %%mm1 \\n\\t\"\n\"psrlq $8, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm3 \\n\\t\"\n\"movq %%mm1, %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm5 \\n\\t\"\n\"punpcklwd %5, %%mm0 \\n\\t\"\n\"punpcklwd %5, %%mm1 \\n\\t\"\n\"punpcklwd %5, %%mm2 \\n\\t\"\n\"punpckhwd %5, %%mm3 \\n\\t\"\n\"punpckhwd %5, %%mm4 \\n\\t\"\n\"punpckhwd %5, %%mm5 \\n\\t\"\n\"psllq $8, %%mm1 \\n\\t\"\n\"psllq $16, %%mm2 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"psllq $8, %%mm4 \\n\\t\"\n\"psllq $16, %%mm5 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n\"movq %%mm0, %%mm6 \\n\\t\"\n\"movq %%mm3, %%mm7 \\n\\t\"\n\"movq 8%1, %%mm0 \\n\\t\"\n\"movq 8%1, %%mm1 \\n\\t\"\n\"movq 8%1, %%mm2 \\n\\t\"\n\"pand %2, %%mm0 \\n\\t\"\n\"pand %3, %%mm1 \\n\\t\"\n\"pand %4, %%mm2 \\n\\t\"\n\"psllq $3, %%mm0 \\n\\t\"\n\"psrlq $3, %%mm1 \\n\\t\"\n\"psrlq $8, %%mm2 \\n\\t\"\n\"movq %%mm0, %%mm3 \\n\\t\"\n\"movq %%mm1, %%mm4 \\n\\t\"\n\"movq %%mm2, %%mm5 \\n\\t\"\n\"punpcklwd %5, %%mm0 \\n\\t\"\n\"punpcklwd %5, %%mm1 \\n\\t\"\n\"punpcklwd %5, %%mm2 \\n\\t\"\n\"punpckhwd %5, %%mm3 \\n\\t\"\n\"punpckhwd %5, %%mm4 \\n\\t\"\n\"punpckhwd %5, %%mm5 \\n\\t\"\n\"psllq $8, %%mm1 \\n\\t\"\n\"psllq $16, %%mm2 \\n\\t\"\n\"por %%mm1, %%mm0 \\n\\t\"\n\"por %%mm2, %%mm0 \\n\\t\"\n\"psllq $8, %%mm4 \\n\\t\"\n\"psllq $16, %%mm5 \\n\\t\"\n\"por %%mm4, %%mm3 \\n\\t\"\n\"por %%mm5, %%mm3 \\n\\t\"\n:\"=m\"(*d)\n:\"m\"(*VAR_1),\"m\"(mask16b),\"m\"(mask16g),\"m\"(mask16r),\"m\"(mmx_null)\n:\"memory\");",
"__asm__ volatile(\n\"movq %%mm0, %%mm4 \\n\\t\"\n\"movq %%mm3, %%mm5 \\n\\t\"\n\"movq %%mm6, %%mm0 \\n\\t\"\n\"movq %%mm7, %%mm1 \\n\\t\"\n\"movq %%mm4, %%mm6 \\n\\t\"\n\"movq %%mm5, %%mm7 \\n\\t\"\n\"movq %%mm0, %%mm2 \\n\\t\"\n\"movq %%mm1, %%mm3 \\n\\t\"\nSTORE_BGR24_MMX\n:\"=m\"(*d)\n:\"m\"(*VAR_1)\n:\"memory\");",
"d += 24;",
"VAR_1 += 8;",
"}",
"__asm__ volatile(SFENCE:::\"memory\");",
"__asm__ volatile(EMMS:::\"memory\");",
"#endif\nwhile (VAR_1 < VAR_0) {",
"register uint16_t VAR_2;",
"VAR_2 = *VAR_1++;",
"*d++ = (VAR_2&0x1F)<<3;",
"*d++ = (VAR_2&0x7E0)>>3;",
"*d++ = (VAR_2&0xF800)>>8;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11,
13
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47,
49,
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
85,
87,
91,
93,
95,
97,
99,
101,
103,
105,
107,
109,
111,
113,
115,
117,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143,
145,
147
],
[
151,
153,
155,
157,
159,
163,
165,
167,
169,
173,
177,
179,
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
]
] |
1,315 | static int teletext_close_decoder(AVCodecContext *avctx)
{
TeletextContext *ctx = avctx->priv_data;
av_dlog(avctx, "lines_total=%u\n", ctx->lines_processed);
while (ctx->nb_pages)
subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);
av_freep(&ctx->pages);
vbi_dvb_demux_delete(ctx->dx);
vbi_decoder_delete(ctx->vbi);
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
return 0;
}
| true | FFmpeg | 085ca7dcdbf9ab6c23e3a5397b1f6d4aa23f763d | static int teletext_close_decoder(AVCodecContext *avctx)
{
TeletextContext *ctx = avctx->priv_data;
av_dlog(avctx, "lines_total=%u\n", ctx->lines_processed);
while (ctx->nb_pages)
subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);
av_freep(&ctx->pages);
vbi_dvb_demux_delete(ctx->dx);
vbi_decoder_delete(ctx->vbi);
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
return 0;
}
| {
"code": [
" ctx->dx = NULL;",
" vbi_dvb_demux_delete(ctx->dx);",
" ctx->dx = NULL;"
],
"line_no": [
23,
19,
23
]
} | static int FUNC_0(AVCodecContext *VAR_0)
{
TeletextContext *ctx = VAR_0->priv_data;
av_dlog(VAR_0, "lines_total=%u\n", ctx->lines_processed);
while (ctx->nb_pages)
subtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);
av_freep(&ctx->pages);
vbi_dvb_demux_delete(ctx->dx);
vbi_decoder_delete(ctx->vbi);
ctx->dx = NULL;
ctx->vbi = NULL;
ctx->pts = AV_NOPTS_VALUE;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0)\n{",
"TeletextContext *ctx = VAR_0->priv_data;",
"av_dlog(VAR_0, \"lines_total=%u\\n\", ctx->lines_processed);",
"while (ctx->nb_pages)\nsubtitle_rect_free(&ctx->pages[--ctx->nb_pages].sub_rect);",
"av_freep(&ctx->pages);",
"vbi_dvb_demux_delete(ctx->dx);",
"vbi_decoder_delete(ctx->vbi);",
"ctx->dx = NULL;",
"ctx->vbi = NULL;",
"ctx->pts = AV_NOPTS_VALUE;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
]
] |
1,316 | static av_always_inline void predict(PredictorState *ps, int *coef,
int output_enable)
{
const SoftFloat a = { 1023410176, 0 }; // 61.0 / 64
const SoftFloat alpha = { 973078528, 0 }; // 29.0 / 32
SoftFloat e0, e1;
SoftFloat pv;
SoftFloat k1, k2;
SoftFloat r0 = ps->r0, r1 = ps->r1;
SoftFloat cor0 = ps->cor0, cor1 = ps->cor1;
SoftFloat var0 = ps->var0, var1 = ps->var1;
SoftFloat tmp;
if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) {
k1 = av_mul_sf(cor0, flt16_even(av_div_sf(a, var0)));
}
else {
k1.mant = 0;
k1.exp = 0;
}
if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
k2 = av_mul_sf(cor1, flt16_even(av_div_sf(a, var1)));
}
else {
k2.mant = 0;
k2.exp = 0;
}
tmp = av_mul_sf(k1, r0);
pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1)));
if (output_enable) {
int shift = 28 - pv.exp;
if (shift < 31)
*coef += (pv.mant + (1 << (shift - 1))) >> shift;
}
e0 = av_int2sf(*coef, 2);
e1 = av_sub_sf(e0, tmp);
ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor1), av_mul_sf(r1, e1)));
tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1));
tmp.exp--;
ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var1), tmp));
ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor0), av_mul_sf(r0, e0)));
tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0));
tmp.exp--;
ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var0), tmp));
ps->r1 = flt16_trunc(av_mul_sf(a, av_sub_sf(r0, av_mul_sf(k1, e0))));
ps->r0 = flt16_trunc(av_mul_sf(a, e0));
}
| true | FFmpeg | 1e443051b277f73b94a2f660d3fd31a1a7beab52 | static av_always_inline void predict(PredictorState *ps, int *coef,
int output_enable)
{
const SoftFloat a = { 1023410176, 0 };
const SoftFloat alpha = { 973078528, 0 };
SoftFloat e0, e1;
SoftFloat pv;
SoftFloat k1, k2;
SoftFloat r0 = ps->r0, r1 = ps->r1;
SoftFloat cor0 = ps->cor0, cor1 = ps->cor1;
SoftFloat var0 = ps->var0, var1 = ps->var1;
SoftFloat tmp;
if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) {
k1 = av_mul_sf(cor0, flt16_even(av_div_sf(a, var0)));
}
else {
k1.mant = 0;
k1.exp = 0;
}
if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
k2 = av_mul_sf(cor1, flt16_even(av_div_sf(a, var1)));
}
else {
k2.mant = 0;
k2.exp = 0;
}
tmp = av_mul_sf(k1, r0);
pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1)));
if (output_enable) {
int shift = 28 - pv.exp;
if (shift < 31)
*coef += (pv.mant + (1 << (shift - 1))) >> shift;
}
e0 = av_int2sf(*coef, 2);
e1 = av_sub_sf(e0, tmp);
ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor1), av_mul_sf(r1, e1)));
tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1));
tmp.exp--;
ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var1), tmp));
ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, cor0), av_mul_sf(r0, e0)));
tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0));
tmp.exp--;
ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(alpha, var0), tmp));
ps->r1 = flt16_trunc(av_mul_sf(a, av_sub_sf(r0, av_mul_sf(k1, e0))));
ps->r0 = flt16_trunc(av_mul_sf(a, e0));
}
| {
"code": [
" if (shift < 31)",
" *coef += (pv.mant + (1 << (shift - 1))) >> shift;"
],
"line_no": [
69,
71
]
} | static av_always_inline void FUNC_0(PredictorState *ps, int *coef,
int output_enable)
{
const SoftFloat VAR_0 = { 1023410176, 0 };
const SoftFloat VAR_1 = { 973078528, 0 };
SoftFloat e0, e1;
SoftFloat pv;
SoftFloat k1, k2;
SoftFloat r0 = ps->r0, r1 = ps->r1;
SoftFloat cor0 = ps->cor0, cor1 = ps->cor1;
SoftFloat var0 = ps->var0, var1 = ps->var1;
SoftFloat tmp;
if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) {
k1 = av_mul_sf(cor0, flt16_even(av_div_sf(VAR_0, var0)));
}
else {
k1.mant = 0;
k1.exp = 0;
}
if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {
k2 = av_mul_sf(cor1, flt16_even(av_div_sf(VAR_0, var1)));
}
else {
k2.mant = 0;
k2.exp = 0;
}
tmp = av_mul_sf(k1, r0);
pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1)));
if (output_enable) {
int VAR_2 = 28 - pv.exp;
if (VAR_2 < 31)
*coef += (pv.mant + (1 << (VAR_2 - 1))) >> VAR_2;
}
e0 = av_int2sf(*coef, 2);
e1 = av_sub_sf(e0, tmp);
ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, cor1), av_mul_sf(r1, e1)));
tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1));
tmp.exp--;
ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, var1), tmp));
ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, cor0), av_mul_sf(r0, e0)));
tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0));
tmp.exp--;
ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, var0), tmp));
ps->r1 = flt16_trunc(av_mul_sf(VAR_0, av_sub_sf(r0, av_mul_sf(k1, e0))));
ps->r0 = flt16_trunc(av_mul_sf(VAR_0, e0));
}
| [
"static av_always_inline void FUNC_0(PredictorState *ps, int *coef,\nint output_enable)\n{",
"const SoftFloat VAR_0 = { 1023410176, 0 };",
"const SoftFloat VAR_1 = { 973078528, 0 };",
"SoftFloat e0, e1;",
"SoftFloat pv;",
"SoftFloat k1, k2;",
"SoftFloat r0 = ps->r0, r1 = ps->r1;",
"SoftFloat cor0 = ps->cor0, cor1 = ps->cor1;",
"SoftFloat var0 = ps->var0, var1 = ps->var1;",
"SoftFloat tmp;",
"if (var0.exp > 1 || (var0.exp == 1 && var0.mant > 0x20000000)) {",
"k1 = av_mul_sf(cor0, flt16_even(av_div_sf(VAR_0, var0)));",
"}",
"else {",
"k1.mant = 0;",
"k1.exp = 0;",
"}",
"if (var1.exp > 1 || (var1.exp == 1 && var1.mant > 0x20000000)) {",
"k2 = av_mul_sf(cor1, flt16_even(av_div_sf(VAR_0, var1)));",
"}",
"else {",
"k2.mant = 0;",
"k2.exp = 0;",
"}",
"tmp = av_mul_sf(k1, r0);",
"pv = flt16_round(av_add_sf(tmp, av_mul_sf(k2, r1)));",
"if (output_enable) {",
"int VAR_2 = 28 - pv.exp;",
"if (VAR_2 < 31)\n*coef += (pv.mant + (1 << (VAR_2 - 1))) >> VAR_2;",
"}",
"e0 = av_int2sf(*coef, 2);",
"e1 = av_sub_sf(e0, tmp);",
"ps->cor1 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, cor1), av_mul_sf(r1, e1)));",
"tmp = av_add_sf(av_mul_sf(r1, r1), av_mul_sf(e1, e1));",
"tmp.exp--;",
"ps->var1 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, var1), tmp));",
"ps->cor0 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, cor0), av_mul_sf(r0, e0)));",
"tmp = av_add_sf(av_mul_sf(r0, r0), av_mul_sf(e0, e0));",
"tmp.exp--;",
"ps->var0 = flt16_trunc(av_add_sf(av_mul_sf(VAR_1, var0), tmp));",
"ps->r1 = flt16_trunc(av_mul_sf(VAR_0, av_sub_sf(r0, av_mul_sf(k1, e0))));",
"ps->r0 = flt16_trunc(av_mul_sf(VAR_0, e0));",
"}"
] | [
0,
0,
0,
0,
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
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69,
71
],
[
73
],
[
77
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
]
] |
1,317 | static OSStatus ffat_decode_callback(AudioConverterRef converter, UInt32 *nb_packets,
AudioBufferList *data,
AudioStreamPacketDescription **packets,
void *inctx)
{
AVCodecContext *avctx = inctx;
ATDecodeContext *at = avctx->priv_data;
if (at->eof) {
*nb_packets = 0;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = 0;
}
return 0;
}
av_packet_move_ref(&at->in_pkt, &at->new_in_pkt);
at->new_in_pkt.data = 0;
at->new_in_pkt.size = 0;
if (!at->in_pkt.data) {
*nb_packets = 0;
return 1;
}
data->mNumberBuffers = 1;
data->mBuffers[0].mNumberChannels = 0;
data->mBuffers[0].mDataByteSize = at->in_pkt.size;
data->mBuffers[0].mData = at->in_pkt.data;
*nb_packets = 1;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = at->in_pkt.size;
}
return 0;
} | true | FFmpeg | 95116bf35f1bbc15a41be67f70f31b8de6075b8f | static OSStatus ffat_decode_callback(AudioConverterRef converter, UInt32 *nb_packets,
AudioBufferList *data,
AudioStreamPacketDescription **packets,
void *inctx)
{
AVCodecContext *avctx = inctx;
ATDecodeContext *at = avctx->priv_data;
if (at->eof) {
*nb_packets = 0;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = 0;
}
return 0;
}
av_packet_move_ref(&at->in_pkt, &at->new_in_pkt);
at->new_in_pkt.data = 0;
at->new_in_pkt.size = 0;
if (!at->in_pkt.data) {
*nb_packets = 0;
return 1;
}
data->mNumberBuffers = 1;
data->mBuffers[0].mNumberChannels = 0;
data->mBuffers[0].mDataByteSize = at->in_pkt.size;
data->mBuffers[0].mData = at->in_pkt.data;
*nb_packets = 1;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = at->in_pkt.size;
}
return 0;
} | {
"code": [],
"line_no": []
} | static OSStatus FUNC_0(AudioConverterRef converter, UInt32 *nb_packets,
AudioBufferList *data,
AudioStreamPacketDescription **packets,
void *inctx)
{
AVCodecContext *avctx = inctx;
ATDecodeContext *at = avctx->priv_data;
if (at->eof) {
*nb_packets = 0;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = 0;
}
return 0;
}
av_packet_move_ref(&at->in_pkt, &at->new_in_pkt);
at->new_in_pkt.data = 0;
at->new_in_pkt.size = 0;
if (!at->in_pkt.data) {
*nb_packets = 0;
return 1;
}
data->mNumberBuffers = 1;
data->mBuffers[0].mNumberChannels = 0;
data->mBuffers[0].mDataByteSize = at->in_pkt.size;
data->mBuffers[0].mData = at->in_pkt.data;
*nb_packets = 1;
if (packets) {
*packets = &at->pkt_desc;
at->pkt_desc.mDataByteSize = at->in_pkt.size;
}
return 0;
} | [
"static OSStatus FUNC_0(AudioConverterRef converter, UInt32 *nb_packets,\nAudioBufferList *data,\nAudioStreamPacketDescription **packets,\nvoid *inctx)\n{",
"AVCodecContext *avctx = inctx;",
"ATDecodeContext *at = avctx->priv_data;",
"if (at->eof) {",
"*nb_packets = 0;",
"if (packets) {",
"*packets = &at->pkt_desc;",
"at->pkt_desc.mDataByteSize = 0;",
"}",
"return 0;",
"}",
"av_packet_move_ref(&at->in_pkt, &at->new_in_pkt);",
"at->new_in_pkt.data = 0;",
"at->new_in_pkt.size = 0;",
"if (!at->in_pkt.data) {",
"*nb_packets = 0;",
"return 1;",
"}",
"data->mNumberBuffers = 1;",
"data->mBuffers[0].mNumberChannels = 0;",
"data->mBuffers[0].mDataByteSize = at->in_pkt.size;",
"data->mBuffers[0].mData = at->in_pkt.data;",
"*nb_packets = 1;",
"if (packets) {",
"*packets = &at->pkt_desc;",
"at->pkt_desc.mDataByteSize = at->in_pkt.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
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
36
],
[
38
],
[
40
],
[
44
],
[
46
],
[
48
],
[
50
],
[
54
],
[
56
],
[
58
],
[
60
],
[
62
],
[
66
],
[
68
],
[
70
],
[
72
],
[
76
],
[
78
]
] |
1,319 | static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int i;
int s;
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
vector unsigned char perm1 = vec_lvsl(0, pix1);
vector unsigned char perm2 = vec_lvsl(0, pix2);
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum;
vector signed int sumsqr;
sum = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < h; i++) {
/* Read potentially unaligned pixels into t1 and t2
Since we're reading 16 pixels, and actually only want 8,
mask out the last 8 pixels. The 0s don't change the sum. */
vector unsigned char pix1l = vec_ld( 0, pix1);
vector unsigned char pix1r = vec_ld(15, pix1);
vector unsigned char pix2l = vec_ld( 0, pix2);
vector unsigned char pix2r = vec_ld(15, pix2);
t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
/* Since we want to use unsigned chars, we can take advantage
of the fact that abs(a-b)^2 = (a-b)^2. */
/* Calculate abs differences vector */
t3 = vec_max(t1, t2);
t4 = vec_min(t1, t2);
t5 = vec_sub(t3, t4);
/* Square the values and add them to our sum */
sum = vec_msum(t5, t5, sum);
pix1 += line_size;
pix2 += line_size;
}
/* Sum up the four partial sums, and put the result into s */
sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &s);
return s;
}
| true | FFmpeg | 98fdfa99704f1cfef3d3a26c580b92749b6b64cb | static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
{
int i;
int s;
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
vector unsigned char perm1 = vec_lvsl(0, pix1);
vector unsigned char perm2 = vec_lvsl(0, pix2);
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum;
vector signed int sumsqr;
sum = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < h; i++) {
vector unsigned char pix1l = vec_ld( 0, pix1);
vector unsigned char pix1r = vec_ld(15, pix1);
vector unsigned char pix2l = vec_ld( 0, pix2);
vector unsigned char pix2r = vec_ld(15, pix2);
t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
t3 = vec_max(t1, t2);
t4 = vec_min(t1, t2);
t5 = vec_sub(t3, t4);
sum = vec_msum(t5, t5, sum);
pix1 += line_size;
pix2 += line_size;
}
sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &s);
return s;
}
| {
"code": [
" vector unsigned char pix1l = vec_ld( 0, pix1);",
" vector unsigned char pix1r = vec_ld(15, pix1);",
" vector unsigned char pix2l = vec_ld( 0, pix2);",
" vector unsigned char pix2r = vec_ld(15, pix2);",
" vector unsigned char pix1l = vec_ld( 0, pix1);",
" vector unsigned char pix1r = vec_ld(15, pix1);",
" vector unsigned char pix2l = vec_ld( 0, pix2);",
" vector unsigned char pix2r = vec_ld(15, pix2);"
],
"line_no": [
37,
39,
41,
43,
37,
39,
41,
43
]
} | static int FUNC_0(void *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2, int VAR_3, int VAR_4)
{
int VAR_5;
int VAR_6;
const vector unsigned int VAR_7 = (const vector unsigned int)vec_splat_u32(0);
const vector unsigned char VAR_8 = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
vector unsigned char perm1 = vec_lvsl(0, VAR_1);
vector unsigned char perm2 = vec_lvsl(0, VAR_2);
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum;
vector signed int sumsqr;
sum = (vector unsigned int)vec_splat_u32(0);
for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {
vector unsigned char pix1l = vec_ld( 0, VAR_1);
vector unsigned char pix1r = vec_ld(15, VAR_1);
vector unsigned char pix2l = vec_ld( 0, VAR_2);
vector unsigned char pix2r = vec_ld(15, VAR_2);
t1 = vec_and(vec_perm(pix1l, pix1r, perm1), VAR_8);
t2 = vec_and(vec_perm(pix2l, pix2r, perm2), VAR_8);
t3 = vec_max(t1, t2);
t4 = vec_min(t1, t2);
t5 = vec_sub(t3, t4);
sum = vec_msum(t5, t5, sum);
VAR_1 += VAR_3;
VAR_2 += VAR_3;
}
sumsqr = vec_sums((vector signed int) sum, (vector signed int) VAR_7);
sumsqr = vec_splat(sumsqr, 3);
vec_ste(sumsqr, 0, &VAR_6);
return VAR_6;
}
| [
"static int FUNC_0(void *VAR_0, uint8_t *VAR_1, uint8_t *VAR_2, int VAR_3, int VAR_4)\n{",
"int VAR_5;",
"int VAR_6;",
"const vector unsigned int VAR_7 = (const vector unsigned int)vec_splat_u32(0);",
"const vector unsigned char VAR_8 = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};",
"vector unsigned char perm1 = vec_lvsl(0, VAR_1);",
"vector unsigned char perm2 = vec_lvsl(0, VAR_2);",
"vector unsigned char t1, t2, t3,t4, t5;",
"vector unsigned int sum;",
"vector signed int sumsqr;",
"sum = (vector unsigned int)vec_splat_u32(0);",
"for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) {",
"vector unsigned char pix1l = vec_ld( 0, VAR_1);",
"vector unsigned char pix1r = vec_ld(15, VAR_1);",
"vector unsigned char pix2l = vec_ld( 0, VAR_2);",
"vector unsigned char pix2r = vec_ld(15, VAR_2);",
"t1 = vec_and(vec_perm(pix1l, pix1r, perm1), VAR_8);",
"t2 = vec_and(vec_perm(pix2l, pix2r, perm2), VAR_8);",
"t3 = vec_max(t1, t2);",
"t4 = vec_min(t1, t2);",
"t5 = vec_sub(t3, t4);",
"sum = vec_msum(t5, t5, sum);",
"VAR_1 += VAR_3;",
"VAR_2 += VAR_3;",
"}",
"sumsqr = vec_sums((vector signed int) sum, (vector signed int) VAR_7);",
"sumsqr = vec_splat(sumsqr, 3);",
"vec_ste(sumsqr, 0, &VAR_6);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
59
],
[
61
],
[
63
],
[
69
],
[
73
],
[
75
],
[
77
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
]
] |
1,320 | av_cold void ff_vp8dsp_init_ppc(VP8DSPContext *c)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec;
c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec;
c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec;
c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec;
c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec;
c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec;
c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec;
c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec;
c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec;
c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec;
#endif /* HAVE_ALTIVEC */
}
| true | FFmpeg | ac4b32df71bd932838043a4838b86d11e169707f | av_cold void ff_vp8dsp_init_ppc(VP8DSPContext *c)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec;
c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec;
c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec;
c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec;
c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec;
c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec;
c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec;
c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec;
c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec;
c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec;
#endif
}
| {
"code": [
"av_cold void ff_vp8dsp_init_ppc(VP8DSPContext *c)"
],
"line_no": [
1
]
} | av_cold void FUNC_0(VP8DSPContext *c)
{
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec;
c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec;
c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec;
c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec;
c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec;
c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec;
c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec;
c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec;
c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec;
c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec;
c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec;
c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec;
c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec;
c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec;
c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec;
#endif
}
| [
"av_cold void FUNC_0(VP8DSPContext *c)\n{",
"#if HAVE_ALTIVEC\nif (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))\nreturn;",
"c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;",
"c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec;",
"c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec;",
"c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec;",
"c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec;",
"c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec;",
"c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec;",
"c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec;",
"c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec;",
"c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec;",
"c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec;",
"c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec;",
"c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec;",
"c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec;",
"c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec;",
"c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec;",
"c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec;",
"c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec;",
"c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec;",
"c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec;",
"#endif\n}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7,
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61,
63
]
] |
1,321 | static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
{
Error *local_err = NULL;
BDRVSheepdogState *s = bs->opaque;
int ret, fd;
uint32_t new_vid;
SheepdogInode *inode;
unsigned int datalen;
DPRINTF("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " "
"is_snapshot %d\n", sn_info->name, sn_info->id_str,
s->name, sn_info->vm_state_size, s->is_snapshot);
if (s->is_snapshot) {
error_report("You can't create a snapshot of a snapshot VDI, "
"%s (%" PRIu32 ").", s->name, s->inode.vdi_id);
return -EINVAL;
}
DPRINTF("%s %s\n", sn_info->name, sn_info->id_str);
s->inode.vm_state_size = sn_info->vm_state_size;
s->inode.vm_clock_nsec = sn_info->vm_clock_nsec;
/* It appears that inode.tag does not require a NUL terminator,
* which means this use of strncpy is ok.
*/
strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag));
/* we don't need to update entire object */
datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
/* refresh inode. */
fd = connect_to_sdog(s, &local_err);
if (fd < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
ret = fd;
goto cleanup;
}
ret = write_object(fd, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),
s->inode.nr_copies, datalen, 0, false, s->cache_flags);
if (ret < 0) {
error_report("failed to write snapshot's inode.");
goto cleanup;
}
ret = do_sd_create(s, &new_vid, 1, &local_err);
if (ret < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
error_report("failed to create inode for snapshot. %s",
strerror(errno));
goto cleanup;
}
inode = (SheepdogInode *)g_malloc(datalen);
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid),
s->inode.nr_copies, datalen, 0, s->cache_flags);
if (ret < 0) {
error_report("failed to read new inode info. %s", strerror(errno));
goto cleanup;
}
memcpy(&s->inode, inode, datalen);
DPRINTF("s->inode: name %s snap_id %x oid %x\n",
s->inode.name, s->inode.snap_id, s->inode.vdi_id);
cleanup:
closesocket(fd);
return ret;
}
| true | qemu | 2df5fee2dbd56a9c34afd6d7df6744da2d951ccb | static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
{
Error *local_err = NULL;
BDRVSheepdogState *s = bs->opaque;
int ret, fd;
uint32_t new_vid;
SheepdogInode *inode;
unsigned int datalen;
DPRINTF("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " "
"is_snapshot %d\n", sn_info->name, sn_info->id_str,
s->name, sn_info->vm_state_size, s->is_snapshot);
if (s->is_snapshot) {
error_report("You can't create a snapshot of a snapshot VDI, "
"%s (%" PRIu32 ").", s->name, s->inode.vdi_id);
return -EINVAL;
}
DPRINTF("%s %s\n", sn_info->name, sn_info->id_str);
s->inode.vm_state_size = sn_info->vm_state_size;
s->inode.vm_clock_nsec = sn_info->vm_clock_nsec;
strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag));
datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
fd = connect_to_sdog(s, &local_err);
if (fd < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
ret = fd;
goto cleanup;
}
ret = write_object(fd, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),
s->inode.nr_copies, datalen, 0, false, s->cache_flags);
if (ret < 0) {
error_report("failed to write snapshot's inode.");
goto cleanup;
}
ret = do_sd_create(s, &new_vid, 1, &local_err);
if (ret < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
error_report("failed to create inode for snapshot. %s",
strerror(errno));
goto cleanup;
}
inode = (SheepdogInode *)g_malloc(datalen);
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid),
s->inode.nr_copies, datalen, 0, s->cache_flags);
if (ret < 0) {
error_report("failed to read new inode info. %s", strerror(errno));
goto cleanup;
}
memcpy(&s->inode, inode, datalen);
DPRINTF("s->inode: name %s snap_id %x oid %x\n",
s->inode.name, s->inode.snap_id, s->inode.vdi_id);
cleanup:
closesocket(fd);
return ret;
}
| {
"code": [
" inode = (SheepdogInode *)g_malloc(datalen);"
],
"line_no": [
113
]
} | static int FUNC_0(BlockDriverState *VAR_0, QEMUSnapshotInfo *VAR_1)
{
Error *local_err = NULL;
BDRVSheepdogState *s = VAR_0->opaque;
int VAR_2, VAR_3;
uint32_t new_vid;
SheepdogInode *inode;
unsigned int VAR_4;
DPRINTF("VAR_1: name %s id_str %s s: name %s vm_state_size %" PRId64 " "
"is_snapshot %d\n", VAR_1->name, VAR_1->id_str,
s->name, VAR_1->vm_state_size, s->is_snapshot);
if (s->is_snapshot) {
error_report("You can't create a snapshot of a snapshot VDI, "
"%s (%" PRIu32 ").", s->name, s->inode.vdi_id);
return -EINVAL;
}
DPRINTF("%s %s\n", VAR_1->name, VAR_1->id_str);
s->inode.vm_state_size = VAR_1->vm_state_size;
s->inode.vm_clock_nsec = VAR_1->vm_clock_nsec;
strncpy(s->inode.tag, VAR_1->name, sizeof(s->inode.tag));
VAR_4 = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
VAR_3 = connect_to_sdog(s, &local_err);
if (VAR_3 < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
VAR_2 = VAR_3;
goto cleanup;
}
VAR_2 = write_object(VAR_3, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),
s->inode.nr_copies, VAR_4, 0, false, s->cache_flags);
if (VAR_2 < 0) {
error_report("failed to write snapshot's inode.");
goto cleanup;
}
VAR_2 = do_sd_create(s, &new_vid, 1, &local_err);
if (VAR_2 < 0) {
error_report("%s", error_get_pretty(local_err));;
error_free(local_err);
error_report("failed to create inode for snapshot. %s",
strerror(errno));
goto cleanup;
}
inode = (SheepdogInode *)g_malloc(VAR_4);
VAR_2 = read_object(VAR_3, (char *)inode, vid_to_vdi_oid(new_vid),
s->inode.nr_copies, VAR_4, 0, s->cache_flags);
if (VAR_2 < 0) {
error_report("failed to read new inode info. %s", strerror(errno));
goto cleanup;
}
memcpy(&s->inode, inode, VAR_4);
DPRINTF("s->inode: name %s snap_id %x oid %x\n",
s->inode.name, s->inode.snap_id, s->inode.vdi_id);
cleanup:
closesocket(VAR_3);
return VAR_2;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, QEMUSnapshotInfo *VAR_1)\n{",
"Error *local_err = NULL;",
"BDRVSheepdogState *s = VAR_0->opaque;",
"int VAR_2, VAR_3;",
"uint32_t new_vid;",
"SheepdogInode *inode;",
"unsigned int VAR_4;",
"DPRINTF(\"VAR_1: name %s id_str %s s: name %s vm_state_size %\" PRId64 \" \"\n\"is_snapshot %d\\n\", VAR_1->name, VAR_1->id_str,\ns->name, VAR_1->vm_state_size, s->is_snapshot);",
"if (s->is_snapshot) {",
"error_report(\"You can't create a snapshot of a snapshot VDI, \"\n\"%s (%\" PRIu32 \").\", s->name, s->inode.vdi_id);",
"return -EINVAL;",
"}",
"DPRINTF(\"%s %s\\n\", VAR_1->name, VAR_1->id_str);",
"s->inode.vm_state_size = VAR_1->vm_state_size;",
"s->inode.vm_clock_nsec = VAR_1->vm_clock_nsec;",
"strncpy(s->inode.tag, VAR_1->name, sizeof(s->inode.tag));",
"VAR_4 = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);",
"VAR_3 = connect_to_sdog(s, &local_err);",
"if (VAR_3 < 0) {",
"error_report(\"%s\", error_get_pretty(local_err));;",
"error_free(local_err);",
"VAR_2 = VAR_3;",
"goto cleanup;",
"}",
"VAR_2 = write_object(VAR_3, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id),\ns->inode.nr_copies, VAR_4, 0, false, s->cache_flags);",
"if (VAR_2 < 0) {",
"error_report(\"failed to write snapshot's inode.\");",
"goto cleanup;",
"}",
"VAR_2 = do_sd_create(s, &new_vid, 1, &local_err);",
"if (VAR_2 < 0) {",
"error_report(\"%s\", error_get_pretty(local_err));;",
"error_free(local_err);",
"error_report(\"failed to create inode for snapshot. %s\",\nstrerror(errno));",
"goto cleanup;",
"}",
"inode = (SheepdogInode *)g_malloc(VAR_4);",
"VAR_2 = read_object(VAR_3, (char *)inode, vid_to_vdi_oid(new_vid),\ns->inode.nr_copies, VAR_4, 0, s->cache_flags);",
"if (VAR_2 < 0) {",
"error_report(\"failed to read new inode info. %s\", strerror(errno));",
"goto cleanup;",
"}",
"memcpy(&s->inode, inode, VAR_4);",
"DPRINTF(\"s->inode: name %s snap_id %x oid %x\\n\",\ns->inode.name, s->inode.snap_id, s->inode.vdi_id);",
"cleanup:\nclosesocket(VAR_3);",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19,
21,
23
],
[
27
],
[
29,
31
],
[
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
55
],
[
59
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
117,
119
],
[
123
],
[
125
],
[
127
],
[
129
],
[
133
],
[
135,
137
],
[
141,
143
],
[
145
],
[
147
]
] |
1,322 | static int probe(AVProbeData *p)
{
unsigned i, frames, checked = 0;
if (p->buf_size < 22 || AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1)
return 0;
frames = AV_RL16(p->buf + 4);
if (!frames)
return 0;
for (i = 0; i < frames && i * 16 + 22 <= p->buf_size; i++) {
unsigned offset;
if (AV_RL16(p->buf + 10 + i * 16) & ~1)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (p->buf[13 + i * 16])
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (AV_RL32(p->buf + 14 + i * 16) < 40)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
offset = AV_RL32(p->buf + 18 + i * 16);
if (offset < 22)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (offset + 8 > p->buf_size)
continue;
if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
checked++;
}
if (checked < frames)
return AVPROBE_SCORE_MAX / 4 + FFMIN(checked, 1);
return AVPROBE_SCORE_MAX / 2 + 1;
}
| true | FFmpeg | 56e2cd9c042e05255aa28487694c29aaec023263 | static int probe(AVProbeData *p)
{
unsigned i, frames, checked = 0;
if (p->buf_size < 22 || AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1)
return 0;
frames = AV_RL16(p->buf + 4);
if (!frames)
return 0;
for (i = 0; i < frames && i * 16 + 22 <= p->buf_size; i++) {
unsigned offset;
if (AV_RL16(p->buf + 10 + i * 16) & ~1)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (p->buf[13 + i * 16])
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (AV_RL32(p->buf + 14 + i * 16) < 40)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
offset = AV_RL32(p->buf + 18 + i * 16);
if (offset < 22)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
if (offset + 8 > p->buf_size)
continue;
if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
return FFMIN(i, AVPROBE_SCORE_MAX / 4);
checked++;
}
if (checked < frames)
return AVPROBE_SCORE_MAX / 4 + FFMIN(checked, 1);
return AVPROBE_SCORE_MAX / 2 + 1;
}
| {
"code": [
" if (offset + 8 > p->buf_size)"
],
"line_no": [
41
]
} | static int FUNC_0(AVProbeData *VAR_0)
{
unsigned VAR_1, VAR_2, VAR_3 = 0;
if (VAR_0->buf_size < 22 || AV_RL16(VAR_0->buf) || AV_RL16(VAR_0->buf + 2) != 1)
return 0;
VAR_2 = AV_RL16(VAR_0->buf + 4);
if (!VAR_2)
return 0;
for (VAR_1 = 0; VAR_1 < VAR_2 && VAR_1 * 16 + 22 <= VAR_0->buf_size; VAR_1++) {
unsigned offset;
if (AV_RL16(VAR_0->buf + 10 + VAR_1 * 16) & ~1)
return FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);
if (VAR_0->buf[13 + VAR_1 * 16])
return FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);
if (AV_RL32(VAR_0->buf + 14 + VAR_1 * 16) < 40)
return FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);
offset = AV_RL32(VAR_0->buf + 18 + VAR_1 * 16);
if (offset < 22)
return FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);
if (offset + 8 > VAR_0->buf_size)
continue;
if (VAR_0->buf[offset] != 40 && AV_RB64(VAR_0->buf + offset) != PNGSIG)
return FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);
VAR_3++;
}
if (VAR_3 < VAR_2)
return AVPROBE_SCORE_MAX / 4 + FFMIN(VAR_3, 1);
return AVPROBE_SCORE_MAX / 2 + 1;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"unsigned VAR_1, VAR_2, VAR_3 = 0;",
"if (VAR_0->buf_size < 22 || AV_RL16(VAR_0->buf) || AV_RL16(VAR_0->buf + 2) != 1)\nreturn 0;",
"VAR_2 = AV_RL16(VAR_0->buf + 4);",
"if (!VAR_2)\nreturn 0;",
"for (VAR_1 = 0; VAR_1 < VAR_2 && VAR_1 * 16 + 22 <= VAR_0->buf_size; VAR_1++) {",
"unsigned offset;",
"if (AV_RL16(VAR_0->buf + 10 + VAR_1 * 16) & ~1)\nreturn FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);",
"if (VAR_0->buf[13 + VAR_1 * 16])\nreturn FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);",
"if (AV_RL32(VAR_0->buf + 14 + VAR_1 * 16) < 40)\nreturn FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);",
"offset = AV_RL32(VAR_0->buf + 18 + VAR_1 * 16);",
"if (offset < 22)\nreturn FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);",
"if (offset + 8 > VAR_0->buf_size)\ncontinue;",
"if (VAR_0->buf[offset] != 40 && AV_RB64(VAR_0->buf + offset) != PNGSIG)\nreturn FFMIN(VAR_1, AVPROBE_SCORE_MAX / 4);",
"VAR_3++;",
"}",
"if (VAR_3 < VAR_2)\nreturn AVPROBE_SCORE_MAX / 4 + FFMIN(VAR_3, 1);",
"return AVPROBE_SCORE_MAX / 2 + 1;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37,
39
],
[
41,
43
],
[
45,
47
],
[
49
],
[
51
],
[
55,
57
],
[
59
],
[
61
]
] |
1,323 | int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
{
inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1});
if (av_cmp_q(inc_tb, ts_tb) < 0) {
//increase step is too small for even 1 step to be representable
return ts;
} else {
int64_t old = av_rescale_q(ts, ts_tb, inc_tb);
int64_t old_ts = av_rescale_q(old, inc_tb, ts_tb);
return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);
}
}
| false | FFmpeg | 4956d0e5a6a555d31345c913485bcc4e0a53481e | int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
{
inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1});
if (av_cmp_q(inc_tb, ts_tb) < 0) {
return ts;
} else {
int64_t old = av_rescale_q(ts, ts_tb, inc_tb);
int64_t old_ts = av_rescale_q(old, inc_tb, ts_tb);
return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);
}
}
| {
"code": [],
"line_no": []
} | int64_t FUNC_0(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
{
inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1});
if (av_cmp_q(inc_tb, ts_tb) < 0) {
return ts;
} else {
int64_t old = av_rescale_q(ts, ts_tb, inc_tb);
int64_t old_ts = av_rescale_q(old, inc_tb, ts_tb);
return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);
}
}
| [
"int64_t FUNC_0(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)\n{",
"inc_tb = av_mul_q(inc_tb, (AVRational) {inc, 1});",
"if (av_cmp_q(inc_tb, ts_tb) < 0) {",
"return ts;",
"} else {",
"int64_t old = av_rescale_q(ts, ts_tb, inc_tb);",
"int64_t old_ts = av_rescale_q(old, inc_tb, ts_tb);",
"return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
1,325 | void ff_put_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_8w_msa(src - 2, src - (stride * 2), stride, dst, stride, 8);
}
| false | FFmpeg | 2aab7c2dfaca4386c38e5d565cd2bf73096bcc86 | void ff_put_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_hv_qrt_8w_msa(src - 2, src - (stride * 2), stride, dst, stride, 8);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,
ptrdiff_t VAR_2)
{
avc_luma_hv_qrt_8w_msa(VAR_1 - 2, VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 8);
}
| [
"void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{",
"avc_luma_hv_qrt_8w_msa(VAR_1 - 2, VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 8);",
"}"
] | [
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
]
] |
1,326 | static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)
{
const int mb_x = sl->mb_x;
const int mb_y = sl->mb_y;
const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy];
uint8_t *dest[3];
int linesize;
int i, j, p;
const int *block_offset = &h->block_offset[0];
const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass);
const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1;
for (p = 0; p < plane_count; p++) {
dest[p] = h->cur_pic.f->data[p] +
((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT),
sl->linesize, 4);
}
h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(sl)) {
linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2;
block_offset = &h->block_offset[48];
if (mb_y & 1) // FIXME move out of this function?
for (p = 0; p < 3; p++)
dest[p] -= sl->linesize * 15;
if (FRAME_MBAFF(h)) {
int list;
for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list))
continue;
if (IS_16X16(mb_type)) {
int8_t *ref = &sl->ref_cache[list][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1);
} else {
for (i = 0; i < 16; i += 4) {
int ref = sl->ref_cache[list][scan8[i]];
if (ref >= 0)
fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2,
8, (16 + ref) ^ (sl->mb_y & 1), 1);
}
}
}
}
} else {
linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize;
}
if (!SIMPLE && IS_INTRA_PCM(mb_type)) {
if (PIXEL_SHIFT) {
const int bit_depth = h->sps.bit_depth_luma;
GetBitContext gb;
init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth);
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++) {
uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
for (j = 0; j < 16; j++)
tmp[j] = get_bits(&gb, bit_depth);
}
} else {
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++)
memcpy(dest[p] + i * linesize,
sl->intra_pcm_ptr + p * 256 + i * 16, 16);
}
} else {
if (IS_INTRA(mb_type)) {
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
for (p = 0; p < plane_count; p++)
hl_decode_mb_predict_luma(h, sl, mb_type, SIMPLE,
transform_bypass, PIXEL_SHIFT,
block_offset, linesize, dest[p], p);
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],
h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
for (p = 0; p < plane_count; p++)
hl_decode_mb_idct_luma(h, sl, mb_type, SIMPLE, transform_bypass,
PIXEL_SHIFT, block_offset, linesize,
dest[p], p);
}
}
| false | FFmpeg | 3176217c60ca7828712985092d9102d331ea4f3d | static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)
{
const int mb_x = sl->mb_x;
const int mb_y = sl->mb_y;
const int mb_xy = sl->mb_xy;
const int mb_type = h->cur_pic.mb_type[mb_xy];
uint8_t *dest[3];
int linesize;
int i, j, p;
const int *block_offset = &h->block_offset[0];
const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass);
const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1;
for (p = 0; p < plane_count; p++) {
dest[p] = h->cur_pic.f->data[p] +
((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16;
h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT),
sl->linesize, 4);
}
h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(sl)) {
linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2;
block_offset = &h->block_offset[48];
if (mb_y & 1)
for (p = 0; p < 3; p++)
dest[p] -= sl->linesize * 15;
if (FRAME_MBAFF(h)) {
int list;
for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list))
continue;
if (IS_16X16(mb_type)) {
int8_t *ref = &sl->ref_cache[list][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1);
} else {
for (i = 0; i < 16; i += 4) {
int ref = sl->ref_cache[list][scan8[i]];
if (ref >= 0)
fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2,
8, (16 + ref) ^ (sl->mb_y & 1), 1);
}
}
}
}
} else {
linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize;
}
if (!SIMPLE && IS_INTRA_PCM(mb_type)) {
if (PIXEL_SHIFT) {
const int bit_depth = h->sps.bit_depth_luma;
GetBitContext gb;
init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth);
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++) {
uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
for (j = 0; j < 16; j++)
tmp[j] = get_bits(&gb, bit_depth);
}
} else {
for (p = 0; p < plane_count; p++)
for (i = 0; i < 16; i++)
memcpy(dest[p] + i * linesize,
sl->intra_pcm_ptr + p * 256 + i * 16, 16);
}
} else {
if (IS_INTRA(mb_type)) {
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
for (p = 0; p < plane_count; p++)
hl_decode_mb_predict_luma(h, sl, mb_type, SIMPLE,
transform_bypass, PIXEL_SHIFT,
block_offset, linesize, dest[p], p);
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],
h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
for (p = 0; p < plane_count; p++)
hl_decode_mb_idct_luma(h, sl, mb_type, SIMPLE, transform_bypass,
PIXEL_SHIFT, block_offset, linesize,
dest[p], p);
}
}
| {
"code": [],
"line_no": []
} | static av_noinline void FUNC_0(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)
{
const int VAR_0 = sl->VAR_0;
const int VAR_1 = sl->VAR_1;
const int VAR_2 = sl->VAR_2;
const int VAR_3 = h->cur_pic.VAR_3[VAR_2];
uint8_t *dest[3];
int VAR_4;
int VAR_5, VAR_6, VAR_7;
const int *VAR_8 = &h->VAR_8[0];
const int VAR_9 = !SIMPLE && (sl->qscale == 0 && h->sps.VAR_9);
const int VAR_10 = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1;
for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) {
dest[VAR_7] = h->cur_pic.f->data[VAR_7] +
((VAR_0 << PIXEL_SHIFT) + VAR_1 * sl->VAR_4) * 16;
h->vdsp.prefetch(dest[VAR_7] + (sl->VAR_0 & 3) * 4 * sl->VAR_4 + (64 << PIXEL_SHIFT),
sl->VAR_4, 4);
}
h->list_counts[VAR_2] = sl->list_count;
if (!SIMPLE && MB_FIELD(sl)) {
VAR_4 = sl->mb_linesize = sl->mb_uvlinesize = sl->VAR_4 * 2;
VAR_8 = &h->VAR_8[48];
if (VAR_1 & 1)
for (VAR_7 = 0; VAR_7 < 3; VAR_7++)
dest[VAR_7] -= sl->VAR_4 * 15;
if (FRAME_MBAFF(h)) {
int VAR_11;
for (VAR_11 = 0; VAR_11 < sl->list_count; VAR_11++) {
if (!USES_LIST(VAR_3, VAR_11))
continue;
if (IS_16X16(VAR_3)) {
int8_t *ref = &sl->ref_cache[VAR_11][scan8[0]];
fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->VAR_1 & 1), 1);
} else {
for (VAR_5 = 0; VAR_5 < 16; VAR_5 += 4) {
int ref = sl->ref_cache[VAR_11][scan8[VAR_5]];
if (ref >= 0)
fill_rectangle(&sl->ref_cache[VAR_11][scan8[VAR_5]], 2, 2,
8, (16 + ref) ^ (sl->VAR_1 & 1), 1);
}
}
}
}
} else {
VAR_4 = sl->mb_linesize = sl->mb_uvlinesize = sl->VAR_4;
}
if (!SIMPLE && IS_INTRA_PCM(VAR_3)) {
if (PIXEL_SHIFT) {
const int VAR_12 = h->sps.bit_depth_luma;
GetBitContext gb;
init_get_bits(&gb, sl->intra_pcm_ptr, 768 * VAR_12);
for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)
for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {
uint16_t *tmp = (uint16_t *)(dest[VAR_7] + VAR_5 * VAR_4);
for (VAR_6 = 0; VAR_6 < 16; VAR_6++)
tmp[VAR_6] = get_bits(&gb, VAR_12);
}
} else {
for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)
for (VAR_5 = 0; VAR_5 < 16; VAR_5++)
memcpy(dest[VAR_7] + VAR_5 * VAR_4,
sl->intra_pcm_ptr + VAR_7 * 256 + VAR_5 * 16, 16);
}
} else {
if (IS_INTRA(VAR_3)) {
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], VAR_4,
VAR_4, 1, 1, SIMPLE, PIXEL_SHIFT);
for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)
hl_decode_mb_predict_luma(h, sl, VAR_3, SIMPLE,
VAR_9, PIXEL_SHIFT,
VAR_8, VAR_4, dest[VAR_7], VAR_7);
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], VAR_4,
VAR_4, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
FUNC_0(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],
h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
h->h264dsp.weight_h264_pixels_tab,
h->h264dsp.biweight_h264_pixels_tab);
}
for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)
hl_decode_mb_idct_luma(h, sl, VAR_3, SIMPLE, VAR_9,
PIXEL_SHIFT, VAR_8, VAR_4,
dest[VAR_7], VAR_7);
}
}
| [
"static av_noinline void FUNC_0(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl)\n{",
"const int VAR_0 = sl->VAR_0;",
"const int VAR_1 = sl->VAR_1;",
"const int VAR_2 = sl->VAR_2;",
"const int VAR_3 = h->cur_pic.VAR_3[VAR_2];",
"uint8_t *dest[3];",
"int VAR_4;",
"int VAR_5, VAR_6, VAR_7;",
"const int *VAR_8 = &h->VAR_8[0];",
"const int VAR_9 = !SIMPLE && (sl->qscale == 0 && h->sps.VAR_9);",
"const int VAR_10 = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1;",
"for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) {",
"dest[VAR_7] = h->cur_pic.f->data[VAR_7] +\n((VAR_0 << PIXEL_SHIFT) + VAR_1 * sl->VAR_4) * 16;",
"h->vdsp.prefetch(dest[VAR_7] + (sl->VAR_0 & 3) * 4 * sl->VAR_4 + (64 << PIXEL_SHIFT),\nsl->VAR_4, 4);",
"}",
"h->list_counts[VAR_2] = sl->list_count;",
"if (!SIMPLE && MB_FIELD(sl)) {",
"VAR_4 = sl->mb_linesize = sl->mb_uvlinesize = sl->VAR_4 * 2;",
"VAR_8 = &h->VAR_8[48];",
"if (VAR_1 & 1)\nfor (VAR_7 = 0; VAR_7 < 3; VAR_7++)",
"dest[VAR_7] -= sl->VAR_4 * 15;",
"if (FRAME_MBAFF(h)) {",
"int VAR_11;",
"for (VAR_11 = 0; VAR_11 < sl->list_count; VAR_11++) {",
"if (!USES_LIST(VAR_3, VAR_11))\ncontinue;",
"if (IS_16X16(VAR_3)) {",
"int8_t *ref = &sl->ref_cache[VAR_11][scan8[0]];",
"fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->VAR_1 & 1), 1);",
"} else {",
"for (VAR_5 = 0; VAR_5 < 16; VAR_5 += 4) {",
"int ref = sl->ref_cache[VAR_11][scan8[VAR_5]];",
"if (ref >= 0)\nfill_rectangle(&sl->ref_cache[VAR_11][scan8[VAR_5]], 2, 2,\n8, (16 + ref) ^ (sl->VAR_1 & 1), 1);",
"}",
"}",
"}",
"}",
"} else {",
"VAR_4 = sl->mb_linesize = sl->mb_uvlinesize = sl->VAR_4;",
"}",
"if (!SIMPLE && IS_INTRA_PCM(VAR_3)) {",
"if (PIXEL_SHIFT) {",
"const int VAR_12 = h->sps.bit_depth_luma;",
"GetBitContext gb;",
"init_get_bits(&gb, sl->intra_pcm_ptr, 768 * VAR_12);",
"for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)",
"for (VAR_5 = 0; VAR_5 < 16; VAR_5++) {",
"uint16_t *tmp = (uint16_t *)(dest[VAR_7] + VAR_5 * VAR_4);",
"for (VAR_6 = 0; VAR_6 < 16; VAR_6++)",
"tmp[VAR_6] = get_bits(&gb, VAR_12);",
"}",
"} else {",
"for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)",
"for (VAR_5 = 0; VAR_5 < 16; VAR_5++)",
"memcpy(dest[VAR_7] + VAR_5 * VAR_4,\nsl->intra_pcm_ptr + VAR_7 * 256 + VAR_5 * 16, 16);",
"}",
"} else {",
"if (IS_INTRA(VAR_3)) {",
"if (sl->deblocking_filter)\nxchg_mb_border(h, sl, dest[0], dest[1], dest[2], VAR_4,\nVAR_4, 1, 1, SIMPLE, PIXEL_SHIFT);",
"for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)",
"hl_decode_mb_predict_luma(h, sl, VAR_3, SIMPLE,\nVAR_9, PIXEL_SHIFT,\nVAR_8, VAR_4, dest[VAR_7], VAR_7);",
"if (sl->deblocking_filter)\nxchg_mb_border(h, sl, dest[0], dest[1], dest[2], VAR_4,\nVAR_4, 0, 1, SIMPLE, PIXEL_SHIFT);",
"} else {",
"FUNC_0(hl_motion_444)(h, sl, dest[0], dest[1], dest[2],\nh->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,\nh->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,\nh->h264dsp.weight_h264_pixels_tab,\nh->h264dsp.biweight_h264_pixels_tab);",
"}",
"for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)",
"hl_decode_mb_idct_luma(h, sl, VAR_3, SIMPLE, VAR_9,\nPIXEL_SHIFT, VAR_8, VAR_4,\ndest[VAR_7], 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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
33,
35
],
[
37
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81,
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133
],
[
135
],
[
137
],
[
139
],
[
141,
143,
145
],
[
149
],
[
151,
153,
155
],
[
159,
161,
163
],
[
165
],
[
167,
169,
171,
173,
175
],
[
177
],
[
181
],
[
183,
185,
187
],
[
189
],
[
191
]
] |
1,327 | static int parse_times(void *log_ctx, int64_t **times, int *nb_times,
const char *times_str)
{
char *p;
int i, ret = 0;
char *times_str1 = av_strdup(times_str);
char *saveptr = NULL;
if (!times_str1)
return AVERROR(ENOMEM);
#define FAIL(err) ret = err; goto end
*nb_times = 1;
for (p = times_str1; *p; p++)
if (*p == ',')
(*nb_times)++;
*times = av_malloc(sizeof(**times) * *nb_times);
if (!*times) {
av_log(log_ctx, AV_LOG_ERROR, "Could not allocate forced times array\n");
FAIL(AVERROR(ENOMEM));
}
p = times_str1;
for (i = 0; i < *nb_times; i++) {
int64_t t;
char *tstr = av_strtok(p, ",", &saveptr);
av_assert0(tstr);
p = NULL;
ret = av_parse_time(&t, tstr, 1);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Invalid time duration specification in %s\n", p);
FAIL(AVERROR(EINVAL));
}
(*times)[i] = t;
/* check on monotonicity */
if (i && (*times)[i-1] > (*times)[i]) {
av_log(log_ctx, AV_LOG_ERROR,
"Specified time %f is greater than the following time %f\n",
(float)((*times)[i])/1000000, (float)((*times)[i-1])/1000000);
FAIL(AVERROR(EINVAL));
}
}
end:
av_free(times_str1);
return ret;
}
| true | FFmpeg | ad47ac20ae3e8ac52fa23f6fa520a3124cc515cd | static int parse_times(void *log_ctx, int64_t **times, int *nb_times,
const char *times_str)
{
char *p;
int i, ret = 0;
char *times_str1 = av_strdup(times_str);
char *saveptr = NULL;
if (!times_str1)
return AVERROR(ENOMEM);
#define FAIL(err) ret = err; goto end
*nb_times = 1;
for (p = times_str1; *p; p++)
if (*p == ',')
(*nb_times)++;
*times = av_malloc(sizeof(**times) * *nb_times);
if (!*times) {
av_log(log_ctx, AV_LOG_ERROR, "Could not allocate forced times array\n");
FAIL(AVERROR(ENOMEM));
}
p = times_str1;
for (i = 0; i < *nb_times; i++) {
int64_t t;
char *tstr = av_strtok(p, ",", &saveptr);
av_assert0(tstr);
p = NULL;
ret = av_parse_time(&t, tstr, 1);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Invalid time duration specification in %s\n", p);
FAIL(AVERROR(EINVAL));
}
(*times)[i] = t;
if (i && (*times)[i-1] > (*times)[i]) {
av_log(log_ctx, AV_LOG_ERROR,
"Specified time %f is greater than the following time %f\n",
(float)((*times)[i])/1000000, (float)((*times)[i-1])/1000000);
FAIL(AVERROR(EINVAL));
}
}
end:
av_free(times_str1);
return ret;
}
| {
"code": [
" av_assert0(tstr);",
" \"Invalid time duration specification in %s\\n\", p);"
],
"line_no": [
57,
69
]
} | static int FUNC_0(void *VAR_0, int64_t **VAR_1, int *VAR_2,
const char *VAR_3)
{
char *VAR_4;
int VAR_5, VAR_6 = 0;
char *VAR_7 = av_strdup(VAR_3);
char *VAR_8 = NULL;
if (!VAR_7)
return AVERROR(ENOMEM);
#define FAIL(err) VAR_6 = err; goto end
*VAR_2 = 1;
for (VAR_4 = VAR_7; *VAR_4; VAR_4++)
if (*VAR_4 == ',')
(*VAR_2)++;
*VAR_1 = av_malloc(sizeof(**VAR_1) * *VAR_2);
if (!*VAR_1) {
av_log(VAR_0, AV_LOG_ERROR, "Could not allocate forced VAR_1 array\n");
FAIL(AVERROR(ENOMEM));
}
VAR_4 = VAR_7;
for (VAR_5 = 0; VAR_5 < *VAR_2; VAR_5++) {
int64_t t;
char *VAR_9 = av_strtok(VAR_4, ",", &VAR_8);
av_assert0(VAR_9);
VAR_4 = NULL;
VAR_6 = av_parse_time(&t, VAR_9, 1);
if (VAR_6 < 0) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid time duration specification in %s\n", VAR_4);
FAIL(AVERROR(EINVAL));
}
(*VAR_1)[VAR_5] = t;
if (VAR_5 && (*VAR_1)[VAR_5-1] > (*VAR_1)[VAR_5]) {
av_log(VAR_0, AV_LOG_ERROR,
"Specified time %f is greater than the following time %f\n",
(float)((*VAR_1)[VAR_5])/1000000, (float)((*VAR_1)[VAR_5-1])/1000000);
FAIL(AVERROR(EINVAL));
}
}
end:
av_free(VAR_7);
return VAR_6;
}
| [
"static int FUNC_0(void *VAR_0, int64_t **VAR_1, int *VAR_2,\nconst char *VAR_3)\n{",
"char *VAR_4;",
"int VAR_5, VAR_6 = 0;",
"char *VAR_7 = av_strdup(VAR_3);",
"char *VAR_8 = NULL;",
"if (!VAR_7)\nreturn AVERROR(ENOMEM);",
"#define FAIL(err) VAR_6 = err; goto end",
"*VAR_2 = 1;",
"for (VAR_4 = VAR_7; *VAR_4; VAR_4++)",
"if (*VAR_4 == ',')\n(*VAR_2)++;",
"*VAR_1 = av_malloc(sizeof(**VAR_1) * *VAR_2);",
"if (!*VAR_1) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Could not allocate forced VAR_1 array\\n\");",
"FAIL(AVERROR(ENOMEM));",
"}",
"VAR_4 = VAR_7;",
"for (VAR_5 = 0; VAR_5 < *VAR_2; VAR_5++) {",
"int64_t t;",
"char *VAR_9 = av_strtok(VAR_4, \",\", &VAR_8);",
"av_assert0(VAR_9);",
"VAR_4 = NULL;",
"VAR_6 = av_parse_time(&t, VAR_9, 1);",
"if (VAR_6 < 0) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid time duration specification in %s\\n\", VAR_4);",
"FAIL(AVERROR(EINVAL));",
"}",
"(*VAR_1)[VAR_5] = t;",
"if (VAR_5 && (*VAR_1)[VAR_5-1] > (*VAR_1)[VAR_5]) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Specified time %f is greater than the following time %f\\n\",\n(float)((*VAR_1)[VAR_5])/1000000, (float)((*VAR_1)[VAR_5-1])/1000000);",
"FAIL(AVERROR(EINVAL));",
"}",
"}",
"end:\nav_free(VAR_7);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
1,
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
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67,
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83,
85,
87
],
[
89
],
[
91
],
[
93
],
[
97,
99
],
[
101
],
[
103
]
] |
1,328 | static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {
int range = 255 / fc->multiplier + 1;
int i;
for (i = 0; i < fc->values; i++) {
int position = fc->list[fc->list[i].sort].x;
int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
int j;
float average = 0;
begin = (position + begin) / 2;
end = (position + end ) / 2;
assert(end <= samples);
for (j = begin; j < end; j++) average += fabs(coeffs[j]);
average /= end - begin;
average /= 32; // MAGIC!
for (j = 0; j < range; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
posts[fc->list[i].sort] = j;
}
}
| true | FFmpeg | 90a09b69d7f5d4fc5622c6aec69d5ceef1a72c04 | static void floor_fit(venc_context_t * venc, floor_t * fc, float * coeffs, int * posts, int samples) {
int range = 255 / fc->multiplier + 1;
int i;
for (i = 0; i < fc->values; i++) {
int position = fc->list[fc->list[i].sort].x;
int begin = fc->list[fc->list[FFMAX(i-1, 0)].sort].x;
int end = fc->list[fc->list[FFMIN(i+1, fc->values - 1)].sort].x;
int j;
float average = 0;
begin = (position + begin) / 2;
end = (position + end ) / 2;
assert(end <= samples);
for (j = begin; j < end; j++) average += fabs(coeffs[j]);
average /= end - begin;
average /= 32;
for (j = 0; j < range; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;
posts[fc->list[i].sort] = j;
}
}
| {
"code": [
" for (j = 0; j < range; j++) if (floor1_inverse_db_table[j * fc->multiplier] > average) break;"
],
"line_no": [
33
]
} | static void FUNC_0(venc_context_t * VAR_0, floor_t * VAR_1, float * VAR_2, int * VAR_3, int VAR_4) {
int VAR_5 = 255 / VAR_1->multiplier + 1;
int VAR_6;
for (VAR_6 = 0; VAR_6 < VAR_1->values; VAR_6++) {
int position = VAR_1->list[VAR_1->list[VAR_6].sort].x;
int begin = VAR_1->list[VAR_1->list[FFMAX(VAR_6-1, 0)].sort].x;
int end = VAR_1->list[VAR_1->list[FFMIN(VAR_6+1, VAR_1->values - 1)].sort].x;
int j;
float average = 0;
begin = (position + begin) / 2;
end = (position + end ) / 2;
assert(end <= VAR_4);
for (j = begin; j < end; j++) average += fabs(VAR_2[j]);
average /= end - begin;
average /= 32;
for (j = 0; j < VAR_5; j++) if (floor1_inverse_db_table[j * VAR_1->multiplier] > average) break;
VAR_3[VAR_1->list[VAR_6].sort] = j;
}
}
| [
"static void FUNC_0(venc_context_t * VAR_0, floor_t * VAR_1, float * VAR_2, int * VAR_3, int VAR_4) {",
"int VAR_5 = 255 / VAR_1->multiplier + 1;",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < VAR_1->values; VAR_6++) {",
"int position = VAR_1->list[VAR_1->list[VAR_6].sort].x;",
"int begin = VAR_1->list[VAR_1->list[FFMAX(VAR_6-1, 0)].sort].x;",
"int end = VAR_1->list[VAR_1->list[FFMIN(VAR_6+1, VAR_1->values - 1)].sort].x;",
"int j;",
"float average = 0;",
"begin = (position + begin) / 2;",
"end = (position + end ) / 2;",
"assert(end <= VAR_4);",
"for (j = begin; j < end; j++) average += fabs(VAR_2[j]);",
"average /= end - begin;",
"average /= 32;",
"for (j = 0; j < VAR_5; j++) if (floor1_inverse_db_table[j * VAR_1->multiplier] > average) break;",
"VAR_3[VAR_1->list[VAR_6].sort] = j;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
1,329 | static void gen_spr_power8_fscr(CPUPPCState *env)
{
spr_register_kvm(env, SPR_FSCR, "FSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_FSCR, 0x00000000);
}
| true | qemu | 45ed0be146b7433d1123f09eb1a984210a311625 | static void gen_spr_power8_fscr(CPUPPCState *env)
{
spr_register_kvm(env, SPR_FSCR, "FSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_FSCR, 0x00000000);
}
| {
"code": [
" KVM_REG_PPC_FSCR, 0x00000000);"
],
"line_no": [
11
]
} | static void FUNC_0(CPUPPCState *VAR_0)
{
spr_register_kvm(VAR_0, SPR_FSCR, "FSCR",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
KVM_REG_PPC_FSCR, 0x00000000);
}
| [
"static void FUNC_0(CPUPPCState *VAR_0)\n{",
"spr_register_kvm(VAR_0, SPR_FSCR, \"FSCR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\nKVM_REG_PPC_FSCR, 0x00000000);",
"}"
] | [
0,
1,
0
] | [
[
1,
3
],
[
5,
7,
9,
11
],
[
13
]
] |
1,330 | static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
int sample_size, c, n, i;
short *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
int16_t *dst_int16_t;
int32_t *dst_int32_t;
int64_t *dst_int64_t;
uint16_t *dst_uint16_t;
uint32_t *dst_uint32_t;
samples = data;
src = buf;
if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) {
av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n");
return -1;
}
if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){
av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
return -1;
}
sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
/* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */
if (CODEC_ID_PCM_DVD == avctx->codec_id)
/* 2 samples are interleaved per block in PCM_DVD */
sample_size = avctx->bits_per_coded_sample * 2 / 8;
else if (avctx->codec_id == CODEC_ID_PCM_LXF)
/* we process 40-bit blocks per channel for LXF */
sample_size = 5;
if (sample_size == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
return AVERROR(EINVAL);
}
n = avctx->channels * sample_size;
if(n && buf_size % n){
if (buf_size < n) {
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}else
buf_size -= buf_size % n;
}
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
n = buf_size/sample_size;
switch(avctx->codec->id) {
case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_U32BE:
DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_S24LE:
DECODE(int32_t, le24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_S24BE:
DECODE(int32_t, be24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_U24LE:
DECODE(uint32_t, le24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_U24BE:
DECODE(uint32_t, be24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_S24DAUD:
for(;n>0;n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4; // sync flags are here
*samples++ = av_reverse[(v >> 8) & 0xff] +
(av_reverse[v & 0xff] << 8);
}
break;
case CODEC_ID_PCM_S16LE_PLANAR:
n /= avctx->channels;
for(c=0;c<avctx->channels;c++)
src2[c] = &src[c*n*2];
for(;n>0;n--)
for(c=0;c<avctx->channels;c++)
*samples++ = bytestream_get_le16(&src2[c]);
src = src2[avctx->channels-1];
break;
case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_U16BE:
DECODE(uint16_t, be16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_S8:
dstu8= (uint8_t*)samples;
for(;n>0;n--) {
*dstu8++ = *src++ + 128;
}
samples= (short*)dstu8;
break;
#if HAVE_BIGENDIAN
case CODEC_ID_PCM_F64LE:
DECODE(int64_t, le64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_F32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F64BE:
DECODE(int64_t, be64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F32LE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif /* HAVE_BIGENDIAN */
case CODEC_ID_PCM_U8:
memcpy(samples, src, n*sample_size);
src += n*sample_size;
samples = (short*)((uint8_t*)data + n*sample_size);
break;
case CODEC_ID_PCM_ZORK:
for(;n>0;n--) {
int x= *src++;
if(x&128) x-= 128;
else x = -x;
*samples++ = x << 8;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
for(;n>0;n--) {
*samples++ = s->table[*src++];
}
break;
case CODEC_ID_PCM_DVD:
dst_int32_t = data;
n /= avctx->channels;
switch (avctx->bits_per_coded_sample) {
case 20:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12);
}
src = src8;
}
break;
case 24:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
}
src = src8;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n");
return -1;
}
samples = (short *) dst_int32_t;
break;
case CODEC_ID_PCM_LXF:
dst_int32_t = data;
n /= avctx->channels;
//unpack and de-planerize
for (i = 0; i < n; i++) {
for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
//extract low 20 bits and expand to 32 bits
*dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
((src8[2] & 0xF) << 8) | src8[1];
}
for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
//extract high 20 bits and expand to 32 bits
*dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
}
}
src += n * avctx->channels * 5;
samples = (short *) dst_int32_t;
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
| true | FFmpeg | b45eb9d619d4a039a44bcd1dd82ec70ad29819f0 | static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
int sample_size, c, n, i;
short *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
int16_t *dst_int16_t;
int32_t *dst_int32_t;
int64_t *dst_int64_t;
uint16_t *dst_uint16_t;
uint32_t *dst_uint32_t;
samples = data;
src = buf;
if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) {
av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n");
return -1;
}
if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){
av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
return -1;
}
sample_size = av_get_bits_per_sample(avctx->codec_id)/8;
if (CODEC_ID_PCM_DVD == avctx->codec_id)
sample_size = avctx->bits_per_coded_sample * 2 / 8;
else if (avctx->codec_id == CODEC_ID_PCM_LXF)
sample_size = 5;
if (sample_size == 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
return AVERROR(EINVAL);
}
n = avctx->channels * sample_size;
if(n && buf_size % n){
if (buf_size < n) {
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}else
buf_size -= buf_size % n;
}
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
n = buf_size/sample_size;
switch(avctx->codec->id) {
case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_U32BE:
DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_S24LE:
DECODE(int32_t, le24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_S24BE:
DECODE(int32_t, be24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_U24LE:
DECODE(uint32_t, le24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_U24BE:
DECODE(uint32_t, be24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_S24DAUD:
for(;n>0;n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4;
*samples++ = av_reverse[(v >> 8) & 0xff] +
(av_reverse[v & 0xff] << 8);
}
break;
case CODEC_ID_PCM_S16LE_PLANAR:
n /= avctx->channels;
for(c=0;c<avctx->channels;c++)
src2[c] = &src[c*n*2];
for(;n>0;n--)
for(c=0;c<avctx->channels;c++)
*samples++ = bytestream_get_le16(&src2[c]);
src = src2[avctx->channels-1];
break;
case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_U16BE:
DECODE(uint16_t, be16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_S8:
dstu8= (uint8_t*)samples;
for(;n>0;n--) {
*dstu8++ = *src++ + 128;
}
samples= (short*)dstu8;
break;
#if HAVE_BIGENDIAN
case CODEC_ID_PCM_F64LE:
DECODE(int64_t, le64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_F32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F64BE:
DECODE(int64_t, be64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F32LE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif
case CODEC_ID_PCM_U8:
memcpy(samples, src, n*sample_size);
src += n*sample_size;
samples = (short*)((uint8_t*)data + n*sample_size);
break;
case CODEC_ID_PCM_ZORK:
for(;n>0;n--) {
int x= *src++;
if(x&128) x-= 128;
else x = -x;
*samples++ = x << 8;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
for(;n>0;n--) {
*samples++ = s->table[*src++];
}
break;
case CODEC_ID_PCM_DVD:
dst_int32_t = data;
n /= avctx->channels;
switch (avctx->bits_per_coded_sample) {
case 20:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 &0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ &0x0f) << 12);
}
src = src8;
}
break;
case 24:
while (n--) {
c = avctx->channels;
src8 = src + 4*c;
while (c--) {
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8);
}
src = src8;
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n");
return -1;
}
samples = (short *) dst_int32_t;
break;
case CODEC_ID_PCM_LXF:
dst_int32_t = data;
n /= avctx->channels;
for (i = 0; i < n; i++) {
for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
*dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
((src8[2] & 0xF) << 8) | src8[1];
}
for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
*dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
}
}
src += n * avctx->channels * 5;
samples = (short *) dst_int32_t;
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
| {
"code": [
" short *samples;",
" uint8_t *dstu8;",
" int16_t *dst_int16_t;",
" int64_t *dst_int64_t;",
" uint16_t *dst_uint16_t;",
" uint32_t *dst_uint32_t;",
" DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)",
" DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000)",
" DECODE(int32_t, le24, src, samples, n, 8, 0)",
" DECODE(int32_t, be24, src, samples, n, 8, 0)",
" DECODE(uint32_t, le24, src, samples, n, 8, 0x800000)",
" DECODE(uint32_t, be24, src, samples, n, 8, 0x800000)",
" *samples++ = av_reverse[(v >> 8) & 0xff] +",
" (av_reverse[v & 0xff] << 8);",
" for(c=0;c<avctx->channels;c++)",
" *samples++ = bytestream_get_le16(&src2[c]);",
" DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)",
" DECODE(uint16_t, be16, src, samples, n, 0, 0x8000)",
" dstu8= (uint8_t*)samples;",
" *dstu8++ = *src++ + 128;",
" samples= (short*)dstu8;",
" DECODE(int64_t, le64, src, samples, n, 0, 0)",
" DECODE(int32_t, le32, src, samples, n, 0, 0)",
" DECODE(int16_t, le16, src, samples, n, 0, 0)",
" DECODE(int64_t, be64, src, samples, n, 0, 0)",
" DECODE(int32_t, be32, src, samples, n, 0, 0)",
" DECODE(int16_t, be16, src, samples, n, 0, 0)",
" samples = (short*)((uint8_t*)data + n*sample_size);",
" *samples++ = x << 8;",
" *samples++ = s->table[*src++];",
" samples = (short *) dst_int32_t;",
" samples = (short *) dst_int32_t;",
" *data_size = (uint8_t *)samples - (uint8_t *)data;"
],
"line_no": [
17,
21,
23,
27,
29,
31,
125,
131,
137,
143,
149,
155,
167,
169,
185,
187,
195,
201,
207,
211,
215,
223,
231,
237,
253,
261,
267,
287,
301,
313,
379,
379,
429
]
} | 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;
PCMDecode *s = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9;
short *VAR_10;
const uint8_t *VAR_11, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
int16_t *dst_int16_t;
int32_t *dst_int32_t;
int64_t *dst_int64_t;
uint16_t *dst_uint16_t;
uint32_t *dst_uint32_t;
VAR_10 = VAR_1;
VAR_11 = VAR_4;
if (VAR_0->sample_fmt!=VAR_0->codec->sample_fmts[0]) {
av_log(VAR_0, AV_LOG_ERROR, "invalid sample_fmt\VAR_8");
return -1;
}
if(VAR_0->channels <= 0 || VAR_0->channels > MAX_CHANNELS){
av_log(VAR_0, AV_LOG_ERROR, "PCM channels out of bounds\VAR_8");
return -1;
}
VAR_6 = av_get_bits_per_sample(VAR_0->codec_id)/8;
if (CODEC_ID_PCM_DVD == VAR_0->codec_id)
VAR_6 = VAR_0->bits_per_coded_sample * 2 / 8;
else if (VAR_0->codec_id == CODEC_ID_PCM_LXF)
VAR_6 = 5;
if (VAR_6 == 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid VAR_6\VAR_8");
return AVERROR(EINVAL);
}
VAR_8 = VAR_0->channels * VAR_6;
if(VAR_8 && VAR_5 % VAR_8){
if (VAR_5 < VAR_8) {
av_log(VAR_0, AV_LOG_ERROR, "invalid PCM packet\VAR_8");
return -1;
}else
VAR_5 -= VAR_5 % VAR_8;
}
VAR_5= FFMIN(VAR_5, *VAR_2/2);
*VAR_2=0;
VAR_8 = VAR_5/VAR_6;
switch(VAR_0->codec->id) {
case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, VAR_11, VAR_10, VAR_8, 0, 0x80000000)
break;
case CODEC_ID_PCM_U32BE:
DECODE(uint32_t, be32, VAR_11, VAR_10, VAR_8, 0, 0x80000000)
break;
case CODEC_ID_PCM_S24LE:
DECODE(int32_t, le24, VAR_11, VAR_10, VAR_8, 8, 0)
break;
case CODEC_ID_PCM_S24BE:
DECODE(int32_t, be24, VAR_11, VAR_10, VAR_8, 8, 0)
break;
case CODEC_ID_PCM_U24LE:
DECODE(uint32_t, le24, VAR_11, VAR_10, VAR_8, 8, 0x800000)
break;
case CODEC_ID_PCM_U24BE:
DECODE(uint32_t, be24, VAR_11, VAR_10, VAR_8, 8, 0x800000)
break;
case CODEC_ID_PCM_S24DAUD:
for(;VAR_8>0;VAR_8--) {
uint32_t v = bytestream_get_be24(&VAR_11);
v >>= 4;
*VAR_10++ = av_reverse[(v >> 8) & 0xff] +
(av_reverse[v & 0xff] << 8);
}
break;
case CODEC_ID_PCM_S16LE_PLANAR:
VAR_8 /= VAR_0->channels;
for(VAR_7=0;VAR_7<VAR_0->channels;VAR_7++)
src2[VAR_7] = &VAR_11[VAR_7*VAR_8*2];
for(;VAR_8>0;VAR_8--)
for(VAR_7=0;VAR_7<VAR_0->channels;VAR_7++)
*VAR_10++ = bytestream_get_le16(&src2[VAR_7]);
VAR_11 = src2[VAR_0->channels-1];
break;
case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, VAR_11, VAR_10, VAR_8, 0, 0x8000)
break;
case CODEC_ID_PCM_U16BE:
DECODE(uint16_t, be16, VAR_11, VAR_10, VAR_8, 0, 0x8000)
break;
case CODEC_ID_PCM_S8:
dstu8= (uint8_t*)VAR_10;
for(;VAR_8>0;VAR_8--) {
*dstu8++ = *VAR_11++ + 128;
}
VAR_10= (short*)dstu8;
break;
#if HAVE_BIGENDIAN
case CODEC_ID_PCM_F64LE:
DECODE(int64_t, le64, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_F32LE:
DECODE(int32_t, le32, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F64BE:
DECODE(int64_t, be64, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, VAR_11, VAR_10, VAR_8, 0, 0)
break;
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F32LE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S16LE:
#endif
case CODEC_ID_PCM_U8:
memcpy(VAR_10, VAR_11, VAR_8*VAR_6);
VAR_11 += VAR_8*VAR_6;
VAR_10 = (short*)((uint8_t*)VAR_1 + VAR_8*VAR_6);
break;
case CODEC_ID_PCM_ZORK:
for(;VAR_8>0;VAR_8--) {
int VAR_12= *VAR_11++;
if(VAR_12&128) VAR_12-= 128;
else VAR_12 = -VAR_12;
*VAR_10++ = VAR_12 << 8;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
for(;VAR_8>0;VAR_8--) {
*VAR_10++ = s->table[*VAR_11++];
}
break;
case CODEC_ID_PCM_DVD:
dst_int32_t = VAR_1;
VAR_8 /= VAR_0->channels;
switch (VAR_0->bits_per_coded_sample) {
case 20:
while (VAR_8--) {
VAR_7 = VAR_0->channels;
src8 = VAR_11 + 4*VAR_7;
while (VAR_7--) {
*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8 &0xf0) << 8);
*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++ &0x0f) << 12);
}
VAR_11 = src8;
}
break;
case 24:
while (VAR_8--) {
VAR_7 = VAR_0->channels;
src8 = VAR_11 + 4*VAR_7;
while (VAR_7--) {
*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++) << 8);
*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++) << 8);
}
VAR_11 = src8;
}
break;
default:
av_log(VAR_0, AV_LOG_ERROR, "PCM DVD unsupported sample depth\VAR_8");
return -1;
}
VAR_10 = (short *) dst_int32_t;
break;
case CODEC_ID_PCM_LXF:
dst_int32_t = VAR_1;
VAR_8 /= VAR_0->channels;
for (VAR_9 = 0; VAR_9 < VAR_8; VAR_9++) {
for (VAR_7 = 0, src8 = VAR_11 + VAR_9*5; VAR_7 < VAR_0->channels; VAR_7++, src8 += VAR_8*5) {
*dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
((src8[2] & 0xF) << 8) | src8[1];
}
for (VAR_7 = 0, src8 = VAR_11 + VAR_9*5; VAR_7 < VAR_0->channels; VAR_7++, src8 += VAR_8*5) {
*dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
}
}
VAR_11 += VAR_8 * VAR_0->channels * 5;
VAR_10 = (short *) dst_int32_t;
break;
default:
return -1;
}
*VAR_2 = (uint8_t *)VAR_10 - (uint8_t *)VAR_1;
return VAR_11 - VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"PCMDecode *s = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9;",
"short *VAR_10;",
"const uint8_t *VAR_11, *src8, *src2[MAX_CHANNELS];",
"uint8_t *dstu8;",
"int16_t *dst_int16_t;",
"int32_t *dst_int32_t;",
"int64_t *dst_int64_t;",
"uint16_t *dst_uint16_t;",
"uint32_t *dst_uint32_t;",
"VAR_10 = VAR_1;",
"VAR_11 = VAR_4;",
"if (VAR_0->sample_fmt!=VAR_0->codec->sample_fmts[0]) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid sample_fmt\\VAR_8\");",
"return -1;",
"}",
"if(VAR_0->channels <= 0 || VAR_0->channels > MAX_CHANNELS){",
"av_log(VAR_0, AV_LOG_ERROR, \"PCM channels out of bounds\\VAR_8\");",
"return -1;",
"}",
"VAR_6 = av_get_bits_per_sample(VAR_0->codec_id)/8;",
"if (CODEC_ID_PCM_DVD == VAR_0->codec_id)\nVAR_6 = VAR_0->bits_per_coded_sample * 2 / 8;",
"else if (VAR_0->codec_id == CODEC_ID_PCM_LXF)\nVAR_6 = 5;",
"if (VAR_6 == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid VAR_6\\VAR_8\");",
"return AVERROR(EINVAL);",
"}",
"VAR_8 = VAR_0->channels * VAR_6;",
"if(VAR_8 && VAR_5 % VAR_8){",
"if (VAR_5 < VAR_8) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid PCM packet\\VAR_8\");",
"return -1;",
"}else",
"VAR_5 -= VAR_5 % VAR_8;",
"}",
"VAR_5= FFMIN(VAR_5, *VAR_2/2);",
"*VAR_2=0;",
"VAR_8 = VAR_5/VAR_6;",
"switch(VAR_0->codec->id) {",
"case CODEC_ID_PCM_U32LE:\nDECODE(uint32_t, le32, VAR_11, VAR_10, VAR_8, 0, 0x80000000)\nbreak;",
"case CODEC_ID_PCM_U32BE:\nDECODE(uint32_t, be32, VAR_11, VAR_10, VAR_8, 0, 0x80000000)\nbreak;",
"case CODEC_ID_PCM_S24LE:\nDECODE(int32_t, le24, VAR_11, VAR_10, VAR_8, 8, 0)\nbreak;",
"case CODEC_ID_PCM_S24BE:\nDECODE(int32_t, be24, VAR_11, VAR_10, VAR_8, 8, 0)\nbreak;",
"case CODEC_ID_PCM_U24LE:\nDECODE(uint32_t, le24, VAR_11, VAR_10, VAR_8, 8, 0x800000)\nbreak;",
"case CODEC_ID_PCM_U24BE:\nDECODE(uint32_t, be24, VAR_11, VAR_10, VAR_8, 8, 0x800000)\nbreak;",
"case CODEC_ID_PCM_S24DAUD:\nfor(;VAR_8>0;VAR_8--) {",
"uint32_t v = bytestream_get_be24(&VAR_11);",
"v >>= 4;",
"*VAR_10++ = av_reverse[(v >> 8) & 0xff] +\n(av_reverse[v & 0xff] << 8);",
"}",
"break;",
"case CODEC_ID_PCM_S16LE_PLANAR:\nVAR_8 /= VAR_0->channels;",
"for(VAR_7=0;VAR_7<VAR_0->channels;VAR_7++)",
"src2[VAR_7] = &VAR_11[VAR_7*VAR_8*2];",
"for(;VAR_8>0;VAR_8--)",
"for(VAR_7=0;VAR_7<VAR_0->channels;VAR_7++)",
"*VAR_10++ = bytestream_get_le16(&src2[VAR_7]);",
"VAR_11 = src2[VAR_0->channels-1];",
"break;",
"case CODEC_ID_PCM_U16LE:\nDECODE(uint16_t, le16, VAR_11, VAR_10, VAR_8, 0, 0x8000)\nbreak;",
"case CODEC_ID_PCM_U16BE:\nDECODE(uint16_t, be16, VAR_11, VAR_10, VAR_8, 0, 0x8000)\nbreak;",
"case CODEC_ID_PCM_S8:\ndstu8= (uint8_t*)VAR_10;",
"for(;VAR_8>0;VAR_8--) {",
"*dstu8++ = *VAR_11++ + 128;",
"}",
"VAR_10= (short*)dstu8;",
"break;",
"#if HAVE_BIGENDIAN\ncase CODEC_ID_PCM_F64LE:\nDECODE(int64_t, le64, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_S32LE:\ncase CODEC_ID_PCM_F32LE:\nDECODE(int32_t, le32, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_S16LE:\nDECODE(int16_t, le16, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_F64BE:\ncase CODEC_ID_PCM_F32BE:\ncase CODEC_ID_PCM_S32BE:\ncase CODEC_ID_PCM_S16BE:\n#else\ncase CODEC_ID_PCM_F64BE:\nDECODE(int64_t, be64, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_F32BE:\ncase CODEC_ID_PCM_S32BE:\nDECODE(int32_t, be32, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_S16BE:\nDECODE(int16_t, be16, VAR_11, VAR_10, VAR_8, 0, 0)\nbreak;",
"case CODEC_ID_PCM_F64LE:\ncase CODEC_ID_PCM_F32LE:\ncase CODEC_ID_PCM_S32LE:\ncase CODEC_ID_PCM_S16LE:\n#endif\ncase CODEC_ID_PCM_U8:\nmemcpy(VAR_10, VAR_11, VAR_8*VAR_6);",
"VAR_11 += VAR_8*VAR_6;",
"VAR_10 = (short*)((uint8_t*)VAR_1 + VAR_8*VAR_6);",
"break;",
"case CODEC_ID_PCM_ZORK:\nfor(;VAR_8>0;VAR_8--) {",
"int VAR_12= *VAR_11++;",
"if(VAR_12&128) VAR_12-= 128;",
"else VAR_12 = -VAR_12;",
"*VAR_10++ = VAR_12 << 8;",
"}",
"break;",
"case CODEC_ID_PCM_ALAW:\ncase CODEC_ID_PCM_MULAW:\nfor(;VAR_8>0;VAR_8--) {",
"*VAR_10++ = s->table[*VAR_11++];",
"}",
"break;",
"case CODEC_ID_PCM_DVD:\ndst_int32_t = VAR_1;",
"VAR_8 /= VAR_0->channels;",
"switch (VAR_0->bits_per_coded_sample) {",
"case 20:\nwhile (VAR_8--) {",
"VAR_7 = VAR_0->channels;",
"src8 = VAR_11 + 4*VAR_7;",
"while (VAR_7--) {",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8 &0xf0) << 8);",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++ &0x0f) << 12);",
"}",
"VAR_11 = src8;",
"}",
"break;",
"case 24:\nwhile (VAR_8--) {",
"VAR_7 = VAR_0->channels;",
"src8 = VAR_11 + 4*VAR_7;",
"while (VAR_7--) {",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++) << 8);",
"*dst_int32_t++ = (bytestream_get_be16(&VAR_11) << 16) + ((*src8++) << 8);",
"}",
"VAR_11 = src8;",
"}",
"break;",
"default:\nav_log(VAR_0, AV_LOG_ERROR, \"PCM DVD unsupported sample depth\\VAR_8\");",
"return -1;",
"}",
"VAR_10 = (short *) dst_int32_t;",
"break;",
"case CODEC_ID_PCM_LXF:\ndst_int32_t = VAR_1;",
"VAR_8 /= VAR_0->channels;",
"for (VAR_9 = 0; VAR_9 < VAR_8; VAR_9++) {",
"for (VAR_7 = 0, src8 = VAR_11 + VAR_9*5; VAR_7 < VAR_0->channels; VAR_7++, src8 += VAR_8*5) {",
"*dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |\n((src8[2] & 0xF) << 8) | src8[1];",
"}",
"for (VAR_7 = 0, src8 = VAR_11 + VAR_9*5; VAR_7 < VAR_0->channels; VAR_7++, src8 += VAR_8*5) {",
"*dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |\n((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);",
"}",
"}",
"VAR_11 += VAR_8 * VAR_0->channels * 5;",
"VAR_10 = (short *) dst_int32_t;",
"break;",
"default:\nreturn -1;",
"}",
"*VAR_2 = (uint8_t *)VAR_10 - (uint8_t *)VAR_1;",
"return VAR_11 - VAR_4;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
1,
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,
1,
1,
1,
1,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0,
0,
0,
0,
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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
67,
71
],
[
73,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
121
],
[
123,
125,
127
],
[
129,
131,
133
],
[
135,
137,
139
],
[
141,
143,
145
],
[
147,
149,
151
],
[
153,
155,
157
],
[
159,
161
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
175,
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193,
195,
197
],
[
199,
201,
203
],
[
205,
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217
],
[
219,
221,
223,
225
],
[
227,
229,
231,
233
],
[
235,
237,
239
],
[
241,
243,
245,
247,
249,
251,
253,
255
],
[
257,
259,
261,
263
],
[
265,
267,
269
],
[
271,
273,
275,
277,
279,
281,
283
],
[
285
],
[
287
],
[
289
],
[
291,
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
305
],
[
307,
309,
311
],
[
313
],
[
315
],
[
317
],
[
319,
321
],
[
323
],
[
325
],
[
327,
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
349,
351
],
[
353
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383,
385
],
[
387
],
[
391
],
[
393
],
[
397,
399
],
[
401
],
[
405
],
[
409,
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423,
425
],
[
427
],
[
429
],
[
431
],
[
433
]
] |
1,331 | int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
AVPacket *avpkt)
{
int i, ret = 0;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
return AVERROR(EINVAL);
}
*got_sub_ptr = 0;
get_subtitle_defaults(sub);
if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
AVPacket pkt_recoded;
AVPacket tmp = *avpkt;
int did_split = av_packet_split_side_data(&tmp);
//apply_param_change(avctx, &tmp);
if (did_split) {
/* FFMIN() prevents overflow in case the packet wasn't allocated with
* proper padding.
* If the side data is smaller than the buffer padding size, the
* remaining bytes should have already been filled with zeros by the
* original packet allocation anyway. */
memset(tmp.data + tmp.size, 0,
FFMIN(avpkt->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));
}
pkt_recoded = tmp;
ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
if (ret < 0) {
*got_sub_ptr = 0;
} else {
avctx->internal->pkt = &pkt_recoded;
if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
sub->pts = av_rescale_q(avpkt->pts,
avctx->pkt_timebase, AV_TIME_BASE_Q);
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
av_assert1((ret >= 0) >= !!*got_sub_ptr &&
!!*got_sub_ptr >= !!sub->num_rects);
if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
avctx->pkt_timebase.num) {
AVRational ms = { 1, 1000 };
sub->end_display_time = av_rescale_q(avpkt->duration,
avctx->pkt_timebase, ms);
}
for (i = 0; i < sub->num_rects; i++) {
if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid UTF-8 in decoded subtitles text; "
"maybe missing -sub_charenc option\n");
avsubtitle_free(sub);
return AVERROR_INVALIDDATA;
}
}
if (tmp.data != pkt_recoded.data) { // did we recode?
/* prevent from destroying side data from original packet */
pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0;
av_packet_unref(&pkt_recoded);
}
if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
sub->format = 0;
else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
sub->format = 1;
avctx->internal->pkt = NULL;
}
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_sub_ptr)
avctx->frame_number++;
}
return ret;
}
| true | FFmpeg | 50401f5fb7d778583b03a13bc4440f71063d319d | int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
AVPacket *avpkt)
{
int i, ret = 0;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
if (!avctx->codec)
return AVERROR(EINVAL);
if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
return AVERROR(EINVAL);
}
*got_sub_ptr = 0;
get_subtitle_defaults(sub);
if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
AVPacket pkt_recoded;
AVPacket tmp = *avpkt;
int did_split = av_packet_split_side_data(&tmp);
if (did_split) {
memset(tmp.data + tmp.size, 0,
FFMIN(avpkt->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));
}
pkt_recoded = tmp;
ret = recode_subtitle(avctx, &pkt_recoded, &tmp);
if (ret < 0) {
*got_sub_ptr = 0;
} else {
avctx->internal->pkt = &pkt_recoded;
if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
sub->pts = av_rescale_q(avpkt->pts,
avctx->pkt_timebase, AV_TIME_BASE_Q);
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);
av_assert1((ret >= 0) >= !!*got_sub_ptr &&
!!*got_sub_ptr >= !!sub->num_rects);
if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
avctx->pkt_timebase.num) {
AVRational ms = { 1, 1000 };
sub->end_display_time = av_rescale_q(avpkt->duration,
avctx->pkt_timebase, ms);
}
for (i = 0; i < sub->num_rects; i++) {
if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid UTF-8 in decoded subtitles text; "
"maybe missing -sub_charenc option\n");
avsubtitle_free(sub);
return AVERROR_INVALIDDATA;
}
}
if (tmp.data != pkt_recoded.data) {
pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0;
av_packet_unref(&pkt_recoded);
}
if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
sub->format = 0;
else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
sub->format = 1;
avctx->internal->pkt = NULL;
}
if (did_split) {
av_packet_free_side_data(&tmp);
if(ret == tmp.size)
ret = avpkt->size;
}
if (*got_sub_ptr)
avctx->frame_number++;
}
return ret;
}
| {
"code": [
" if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)"
],
"line_no": [
87
]
} | int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1,
int *VAR_2,
AVPacket *VAR_3)
{
int VAR_4, VAR_5 = 0;
if (!VAR_3->data && VAR_3->size) {
av_log(VAR_0, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
if (!VAR_0->codec)
return AVERROR(EINVAL);
if (VAR_0->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid media type for subtitles\n");
return AVERROR(EINVAL);
}
*VAR_2 = 0;
get_subtitle_defaults(VAR_1);
if ((VAR_0->codec->capabilities & AV_CODEC_CAP_DELAY) || VAR_3->size) {
AVPacket pkt_recoded;
AVPacket tmp = *VAR_3;
int VAR_6 = av_packet_split_side_data(&tmp);
if (VAR_6) {
memset(tmp.data + tmp.size, 0,
FFMIN(VAR_3->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));
}
pkt_recoded = tmp;
VAR_5 = recode_subtitle(VAR_0, &pkt_recoded, &tmp);
if (VAR_5 < 0) {
*VAR_2 = 0;
} else {
VAR_0->internal->pkt = &pkt_recoded;
if (VAR_0->pkt_timebase.den && VAR_3->pts != AV_NOPTS_VALUE)
VAR_1->pts = av_rescale_q(VAR_3->pts,
VAR_0->pkt_timebase, AV_TIME_BASE_Q);
VAR_5 = VAR_0->codec->decode(VAR_0, VAR_1, VAR_2, &pkt_recoded);
av_assert1((VAR_5 >= 0) >= !!*VAR_2 &&
!!*VAR_2 >= !!VAR_1->num_rects);
if (VAR_1->num_rects && !VAR_1->end_display_time && VAR_3->duration &&
VAR_0->pkt_timebase.num) {
AVRational ms = { 1, 1000 };
VAR_1->end_display_time = av_rescale_q(VAR_3->duration,
VAR_0->pkt_timebase, ms);
}
for (VAR_4 = 0; VAR_4 < VAR_1->num_rects; VAR_4++) {
if (VAR_1->rects[VAR_4]->ass && !utf8_check(VAR_1->rects[VAR_4]->ass)) {
av_log(VAR_0, AV_LOG_ERROR,
"Invalid UTF-8 in decoded subtitles text; "
"maybe missing -sub_charenc option\n");
avsubtitle_free(VAR_1);
return AVERROR_INVALIDDATA;
}
}
if (tmp.data != pkt_recoded.data) {
pkt_recoded.side_data = NULL;
pkt_recoded.side_data_elems = 0;
av_packet_unref(&pkt_recoded);
}
if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)
VAR_1->format = 0;
else if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
VAR_1->format = 1;
VAR_0->internal->pkt = NULL;
}
if (VAR_6) {
av_packet_free_side_data(&tmp);
if(VAR_5 == tmp.size)
VAR_5 = VAR_3->size;
}
if (*VAR_2)
VAR_0->frame_number++;
}
return VAR_5;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, AVSubtitle *VAR_1,\nint *VAR_2,\nAVPacket *VAR_3)\n{",
"int VAR_4, VAR_5 = 0;",
"if (!VAR_3->data && VAR_3->size) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid packet: NULL data, size != 0\\n\");",
"return AVERROR(EINVAL);",
"}",
"if (!VAR_0->codec)\nreturn AVERROR(EINVAL);",
"if (VAR_0->codec->type != AVMEDIA_TYPE_SUBTITLE) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid media type for subtitles\\n\");",
"return AVERROR(EINVAL);",
"}",
"*VAR_2 = 0;",
"get_subtitle_defaults(VAR_1);",
"if ((VAR_0->codec->capabilities & AV_CODEC_CAP_DELAY) || VAR_3->size) {",
"AVPacket pkt_recoded;",
"AVPacket tmp = *VAR_3;",
"int VAR_6 = av_packet_split_side_data(&tmp);",
"if (VAR_6) {",
"memset(tmp.data + tmp.size, 0,\nFFMIN(VAR_3->size - tmp.size, AV_INPUT_BUFFER_PADDING_SIZE));",
"}",
"pkt_recoded = tmp;",
"VAR_5 = recode_subtitle(VAR_0, &pkt_recoded, &tmp);",
"if (VAR_5 < 0) {",
"*VAR_2 = 0;",
"} else {",
"VAR_0->internal->pkt = &pkt_recoded;",
"if (VAR_0->pkt_timebase.den && VAR_3->pts != AV_NOPTS_VALUE)\nVAR_1->pts = av_rescale_q(VAR_3->pts,\nVAR_0->pkt_timebase, AV_TIME_BASE_Q);",
"VAR_5 = VAR_0->codec->decode(VAR_0, VAR_1, VAR_2, &pkt_recoded);",
"av_assert1((VAR_5 >= 0) >= !!*VAR_2 &&\n!!*VAR_2 >= !!VAR_1->num_rects);",
"if (VAR_1->num_rects && !VAR_1->end_display_time && VAR_3->duration &&\nVAR_0->pkt_timebase.num) {",
"AVRational ms = { 1, 1000 };",
"VAR_1->end_display_time = av_rescale_q(VAR_3->duration,\nVAR_0->pkt_timebase, ms);",
"}",
"for (VAR_4 = 0; VAR_4 < VAR_1->num_rects; VAR_4++) {",
"if (VAR_1->rects[VAR_4]->ass && !utf8_check(VAR_1->rects[VAR_4]->ass)) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"Invalid UTF-8 in decoded subtitles text; \"",
"\"maybe missing -sub_charenc option\\n\");",
"avsubtitle_free(VAR_1);",
"return AVERROR_INVALIDDATA;",
"}",
"}",
"if (tmp.data != pkt_recoded.data) {",
"pkt_recoded.side_data = NULL;",
"pkt_recoded.side_data_elems = 0;",
"av_packet_unref(&pkt_recoded);",
"}",
"if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB)\nVAR_1->format = 0;",
"else if (VAR_0->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)\nVAR_1->format = 1;",
"VAR_0->internal->pkt = NULL;",
"}",
"if (VAR_6) {",
"av_packet_free_side_data(&tmp);",
"if(VAR_5 == tmp.size)\nVAR_5 = VAR_3->size;",
"}",
"if (*VAR_2)\nVAR_0->frame_number++;",
"}",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
53
],
[
65,
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
87,
89,
91
],
[
93
],
[
95,
97
],
[
101,
103
],
[
105
],
[
107,
109
],
[
111
],
[
115
],
[
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
139
],
[
141
],
[
145
],
[
147
],
[
149,
151
],
[
153,
155
],
[
157
],
[
159
],
[
163
],
[
165
],
[
167,
169
],
[
171
],
[
175,
177
],
[
179
],
[
183
],
[
185
]
] |
1,332 | static int flv_write_packet(AVFormatContext *s, int stream_index,
const uint8_t *buf, int size, int64_t timestamp)
{
ByteIOContext *pb = &s->pb;
AVCodecContext *enc = &s->streams[stream_index]->codec;
FLVContext *flv = s->priv_data;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
frame->next = 0;
frame->type = 9;
frame->flags = 2; // choose h263
frame->flags |= enc->coded_frame->key_frame ? 0x10 : 0x20; // add keyframe indicator
frame->timestamp = timestamp;
//frame->timestamp = ( ( flv->frameCount * (int64_t)FRAME_RATE_BASE * (int64_t)1000 ) / (int64_t)enc->frame_rate );
//printf("%08x %f %f\n",frame->timestamp,(double)enc->frame_rate/(double)FRAME_RATE_BASE,1000*(double)FRAME_RATE_BASE/(double)enc->frame_rate);
frame->size = size;
frame->data = av_malloc(size);
memcpy(frame->data,buf,size);
flv->hasVideo = 1;
InsertSorted(flv,frame);
flv->frameCount ++;
}
else if (enc->codec_type == CODEC_TYPE_AUDIO) {
#ifdef CONFIG_MP3LAME
if (enc->codec_id == CODEC_ID_MP3 ) {
int c=0;
for (;c<size;c++) {
flv->audioFifo[(flv->audioOutPos+c)%AUDIO_FIFO_SIZE] = buf[c];
}
flv->audioSize += size;
flv->audioOutPos += size;
flv->audioOutPos %= AUDIO_FIFO_SIZE;
if ( flv->initDelay == -1 ) {
flv->initDelay = timestamp;
}
if ( flv->audioTime == -1 ) {
flv->audioTime = timestamp;
// flv->audioTime = ( ( ( flv->sampleCount - enc->delay ) * 8000 ) / flv->audioRate ) - flv->initDelay - 250;
// if ( flv->audioTime < 0 ) {
// flv->audioTime = 0;
// }
}
}
for ( ; flv->audioSize >= 4 ; ) {
int mp3FrameSize = 0;
int mp3SampleRate = 0;
int mp3IsMono = 0;
int mp3SamplesPerFrame = 0;
if ( mp3info(&flv->audioFifo[flv->audioInPos],&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {
if ( flv->audioSize >= mp3FrameSize ) {
int soundFormat = 0x22;
int c=0;
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
flv->audioRate = mp3SampleRate;
switch (mp3SampleRate) {
case 44100:
soundFormat |= 0x0C;
break;
case 22050:
soundFormat |= 0x08;
break;
case 11025:
soundFormat |= 0x04;
break;
}
if ( !mp3IsMono ) {
soundFormat |= 0x01;
}
frame->next = 0;
frame->type = 8;
frame->flags = soundFormat;
frame->timestamp = flv->audioTime;
frame->size = mp3FrameSize;
frame->data = av_malloc(mp3FrameSize);
for (;c<mp3FrameSize;c++) {
frame->data[c] = flv->audioFifo[(flv->audioInPos+c)%AUDIO_FIFO_SIZE];
}
flv->audioInPos += mp3FrameSize;
flv->audioSize -= mp3FrameSize;
flv->audioInPos %= AUDIO_FIFO_SIZE;
flv->sampleCount += mp3SamplesPerFrame;
// Reset audio for next round
flv->audioTime = -1;
// We got audio! Make sure we set this to the global flags on closure
flv->hasAudio = 1;
InsertSorted(flv,frame);
}
break;
}
flv->audioInPos ++;
flv->audioSize --;
flv->audioInPos %= AUDIO_FIFO_SIZE;
// no audio in here!
flv->audioTime = -1;
}
#endif
}
Dump(flv,pb,128);
put_flush_packet(pb);
return 0;
}
| true | FFmpeg | 747a0554ea8ad09404c1f5b80239ebd8d71b291e | static int flv_write_packet(AVFormatContext *s, int stream_index,
const uint8_t *buf, int size, int64_t timestamp)
{
ByteIOContext *pb = &s->pb;
AVCodecContext *enc = &s->streams[stream_index]->codec;
FLVContext *flv = s->priv_data;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
frame->next = 0;
frame->type = 9;
frame->flags = 2;
frame->flags |= enc->coded_frame->key_frame ? 0x10 : 0x20;
frame->timestamp = timestamp;
frame->size = size;
frame->data = av_malloc(size);
memcpy(frame->data,buf,size);
flv->hasVideo = 1;
InsertSorted(flv,frame);
flv->frameCount ++;
}
else if (enc->codec_type == CODEC_TYPE_AUDIO) {
#ifdef CONFIG_MP3LAME
if (enc->codec_id == CODEC_ID_MP3 ) {
int c=0;
for (;c<size;c++) {
flv->audioFifo[(flv->audioOutPos+c)%AUDIO_FIFO_SIZE] = buf[c];
}
flv->audioSize += size;
flv->audioOutPos += size;
flv->audioOutPos %= AUDIO_FIFO_SIZE;
if ( flv->initDelay == -1 ) {
flv->initDelay = timestamp;
}
if ( flv->audioTime == -1 ) {
flv->audioTime = timestamp;
}
}
for ( ; flv->audioSize >= 4 ; ) {
int mp3FrameSize = 0;
int mp3SampleRate = 0;
int mp3IsMono = 0;
int mp3SamplesPerFrame = 0;
if ( mp3info(&flv->audioFifo[flv->audioInPos],&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {
if ( flv->audioSize >= mp3FrameSize ) {
int soundFormat = 0x22;
int c=0;
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
flv->audioRate = mp3SampleRate;
switch (mp3SampleRate) {
case 44100:
soundFormat |= 0x0C;
break;
case 22050:
soundFormat |= 0x08;
break;
case 11025:
soundFormat |= 0x04;
break;
}
if ( !mp3IsMono ) {
soundFormat |= 0x01;
}
frame->next = 0;
frame->type = 8;
frame->flags = soundFormat;
frame->timestamp = flv->audioTime;
frame->size = mp3FrameSize;
frame->data = av_malloc(mp3FrameSize);
for (;c<mp3FrameSize;c++) {
frame->data[c] = flv->audioFifo[(flv->audioInPos+c)%AUDIO_FIFO_SIZE];
}
flv->audioInPos += mp3FrameSize;
flv->audioSize -= mp3FrameSize;
flv->audioInPos %= AUDIO_FIFO_SIZE;
flv->sampleCount += mp3SamplesPerFrame;
flv->audioTime = -1;
flv->hasAudio = 1;
InsertSorted(flv,frame);
}
break;
}
flv->audioInPos ++;
flv->audioSize --;
flv->audioInPos %= AUDIO_FIFO_SIZE;
flv->audioTime = -1;
}
#endif
}
Dump(flv,pb,128);
put_flush_packet(pb);
return 0;
}
| {
"code": [
" if ( mp3info(&flv->audioFifo[flv->audioInPos],&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {",
" ByteIOContext *pb = &s->pb;",
" break;"
],
"line_no": [
111,
7,
207
]
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
const uint8_t *VAR_2, int VAR_3, int64_t VAR_4)
{
ByteIOContext *pb = &VAR_0->pb;
AVCodecContext *enc = &VAR_0->streams[VAR_1]->codec;
FLVContext *flv = VAR_0->priv_data;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
frame->next = 0;
frame->type = 9;
frame->flags = 2;
frame->flags |= enc->coded_frame->key_frame ? 0x10 : 0x20;
frame->VAR_4 = VAR_4;
frame->VAR_3 = VAR_3;
frame->data = av_malloc(VAR_3);
memcpy(frame->data,VAR_2,VAR_3);
flv->hasVideo = 1;
InsertSorted(flv,frame);
flv->frameCount ++;
}
else if (enc->codec_type == CODEC_TYPE_AUDIO) {
#ifdef CONFIG_MP3LAME
if (enc->codec_id == CODEC_ID_MP3 ) {
int c=0;
for (;c<VAR_3;c++) {
flv->audioFifo[(flv->audioOutPos+c)%AUDIO_FIFO_SIZE] = VAR_2[c];
}
flv->audioSize += VAR_3;
flv->audioOutPos += VAR_3;
flv->audioOutPos %= AUDIO_FIFO_SIZE;
if ( flv->initDelay == -1 ) {
flv->initDelay = VAR_4;
}
if ( flv->audioTime == -1 ) {
flv->audioTime = VAR_4;
}
}
for ( ; flv->audioSize >= 4 ; ) {
int mp3FrameSize = 0;
int mp3SampleRate = 0;
int mp3IsMono = 0;
int mp3SamplesPerFrame = 0;
if ( mp3info(&flv->audioFifo[flv->audioInPos],&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {
if ( flv->audioSize >= mp3FrameSize ) {
int soundFormat = 0x22;
int c=0;
FLVFrame *frame = av_malloc(sizeof(FLVFrame));
flv->audioRate = mp3SampleRate;
switch (mp3SampleRate) {
case 44100:
soundFormat |= 0x0C;
break;
case 22050:
soundFormat |= 0x08;
break;
case 11025:
soundFormat |= 0x04;
break;
}
if ( !mp3IsMono ) {
soundFormat |= 0x01;
}
frame->next = 0;
frame->type = 8;
frame->flags = soundFormat;
frame->VAR_4 = flv->audioTime;
frame->VAR_3 = mp3FrameSize;
frame->data = av_malloc(mp3FrameSize);
for (;c<mp3FrameSize;c++) {
frame->data[c] = flv->audioFifo[(flv->audioInPos+c)%AUDIO_FIFO_SIZE];
}
flv->audioInPos += mp3FrameSize;
flv->audioSize -= mp3FrameSize;
flv->audioInPos %= AUDIO_FIFO_SIZE;
flv->sampleCount += mp3SamplesPerFrame;
flv->audioTime = -1;
flv->hasAudio = 1;
InsertSorted(flv,frame);
}
break;
}
flv->audioInPos ++;
flv->audioSize --;
flv->audioInPos %= AUDIO_FIFO_SIZE;
flv->audioTime = -1;
}
#endif
}
Dump(flv,pb,128);
put_flush_packet(pb);
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,\nconst uint8_t *VAR_2, int VAR_3, int64_t VAR_4)\n{",
"ByteIOContext *pb = &VAR_0->pb;",
"AVCodecContext *enc = &VAR_0->streams[VAR_1]->codec;",
"FLVContext *flv = VAR_0->priv_data;",
"if (enc->codec_type == CODEC_TYPE_VIDEO) {",
"FLVFrame *frame = av_malloc(sizeof(FLVFrame));",
"frame->next = 0;",
"frame->type = 9;",
"frame->flags = 2;",
"frame->flags |= enc->coded_frame->key_frame ? 0x10 : 0x20;",
"frame->VAR_4 = VAR_4;",
"frame->VAR_3 = VAR_3;",
"frame->data = av_malloc(VAR_3);",
"memcpy(frame->data,VAR_2,VAR_3);",
"flv->hasVideo = 1;",
"InsertSorted(flv,frame);",
"flv->frameCount ++;",
"}",
"else if (enc->codec_type == CODEC_TYPE_AUDIO) {",
"#ifdef CONFIG_MP3LAME\nif (enc->codec_id == CODEC_ID_MP3 ) {",
"int c=0;",
"for (;c<VAR_3;c++) {",
"flv->audioFifo[(flv->audioOutPos+c)%AUDIO_FIFO_SIZE] = VAR_2[c];",
"}",
"flv->audioSize += VAR_3;",
"flv->audioOutPos += VAR_3;",
"flv->audioOutPos %= AUDIO_FIFO_SIZE;",
"if ( flv->initDelay == -1 ) {",
"flv->initDelay = VAR_4;",
"}",
"if ( flv->audioTime == -1 ) {",
"flv->audioTime = VAR_4;",
"}",
"}",
"for ( ; flv->audioSize >= 4 ; ) {",
"int mp3FrameSize = 0;",
"int mp3SampleRate = 0;",
"int mp3IsMono = 0;",
"int mp3SamplesPerFrame = 0;",
"if ( mp3info(&flv->audioFifo[flv->audioInPos],&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {",
"if ( flv->audioSize >= mp3FrameSize ) {",
"int soundFormat = 0x22;",
"int c=0;",
"FLVFrame *frame = av_malloc(sizeof(FLVFrame));",
"flv->audioRate = mp3SampleRate;",
"switch (mp3SampleRate) {",
"case 44100:\nsoundFormat |= 0x0C;",
"break;",
"case 22050:\nsoundFormat |= 0x08;",
"break;",
"case 11025:\nsoundFormat |= 0x04;",
"break;",
"}",
"if ( !mp3IsMono ) {",
"soundFormat |= 0x01;",
"}",
"frame->next = 0;",
"frame->type = 8;",
"frame->flags = soundFormat;",
"frame->VAR_4 = flv->audioTime;",
"frame->VAR_3 = mp3FrameSize;",
"frame->data = av_malloc(mp3FrameSize);",
"for (;c<mp3FrameSize;c++) {",
"frame->data[c] = flv->audioFifo[(flv->audioInPos+c)%AUDIO_FIFO_SIZE];",
"}",
"flv->audioInPos += mp3FrameSize;",
"flv->audioSize -= mp3FrameSize;",
"flv->audioInPos %= AUDIO_FIFO_SIZE;",
"flv->sampleCount += mp3SamplesPerFrame;",
"flv->audioTime = -1;",
"flv->hasAudio = 1;",
"InsertSorted(flv,frame);",
"}",
"break;",
"}",
"flv->audioInPos ++;",
"flv->audioSize --;",
"flv->audioInPos %= AUDIO_FIFO_SIZE;",
"flv->audioTime = -1;",
"}",
"#endif\n}",
"Dump(flv,pb,128);",
"put_flush_packet(pb);",
"return 0;",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
125
],
[
129
],
[
131,
133
],
[
135
],
[
137,
139
],
[
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
175
],
[
177
],
[
179
],
[
183
],
[
185
],
[
187
],
[
189
],
[
195
],
[
199
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
219
],
[
221
],
[
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
]
] |
1,333 | void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports)
{
qemu_irq *irqs;
int i;
s->dma = dma;
s->ports = ports;
s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
ahci_reg_init(s);
/* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", AHCI_MEM_BAR_SIZE);
memory_region_init_io(&s->idp, &ahci_idp_ops, s, "ahci-idp", 32);
irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
for (i = 0; i < s->ports; i++) {
AHCIDevice *ad = &s->dev[i];
ide_bus_new(&ad->port, qdev, i);
ide_init2(&ad->port, irqs[i]);
ad->hba = s;
ad->port_no = i;
ad->port.dma = &ad->dma;
ad->port.dma->ops = &ahci_dma_ops;
ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;
}
}
| true | qemu | 2a4f4f34e6fe55f4c82507c3e7ec9b58c2e24ad4 | void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports)
{
qemu_irq *irqs;
int i;
s->dma = dma;
s->ports = ports;
s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
ahci_reg_init(s);
memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", AHCI_MEM_BAR_SIZE);
memory_region_init_io(&s->idp, &ahci_idp_ops, s, "ahci-idp", 32);
irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
for (i = 0; i < s->ports; i++) {
AHCIDevice *ad = &s->dev[i];
ide_bus_new(&ad->port, qdev, i);
ide_init2(&ad->port, irqs[i]);
ad->hba = s;
ad->port_no = i;
ad->port.dma = &ad->dma;
ad->port.dma->ops = &ahci_dma_ops;
ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;
}
}
| {
"code": [
" ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;"
],
"line_no": [
51
]
} | void FUNC_0(AHCIState *VAR_0, DeviceState *VAR_1, DMAContext *VAR_2, int VAR_3)
{
qemu_irq *irqs;
int VAR_4;
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
VAR_0->dev = g_malloc0(sizeof(AHCIDevice) * VAR_3);
ahci_reg_init(VAR_0);
memory_region_init_io(&VAR_0->mem, &ahci_mem_ops, VAR_0, "ahci", AHCI_MEM_BAR_SIZE);
memory_region_init_io(&VAR_0->idp, &ahci_idp_ops, VAR_0, "ahci-idp", 32);
irqs = qemu_allocate_irqs(ahci_irq_set, VAR_0, VAR_0->VAR_3);
for (VAR_4 = 0; VAR_4 < VAR_0->VAR_3; VAR_4++) {
AHCIDevice *ad = &VAR_0->dev[VAR_4];
ide_bus_new(&ad->port, VAR_1, VAR_4);
ide_init2(&ad->port, irqs[VAR_4]);
ad->hba = VAR_0;
ad->port_no = VAR_4;
ad->port.VAR_2 = &ad->VAR_2;
ad->port.VAR_2->ops = &ahci_dma_ops;
ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;
}
}
| [
"void FUNC_0(AHCIState *VAR_0, DeviceState *VAR_1, DMAContext *VAR_2, int VAR_3)\n{",
"qemu_irq *irqs;",
"int VAR_4;",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->dev = g_malloc0(sizeof(AHCIDevice) * VAR_3);",
"ahci_reg_init(VAR_0);",
"memory_region_init_io(&VAR_0->mem, &ahci_mem_ops, VAR_0, \"ahci\", AHCI_MEM_BAR_SIZE);",
"memory_region_init_io(&VAR_0->idp, &ahci_idp_ops, VAR_0, \"ahci-idp\", 32);",
"irqs = qemu_allocate_irqs(ahci_irq_set, VAR_0, VAR_0->VAR_3);",
"for (VAR_4 = 0; VAR_4 < VAR_0->VAR_3; VAR_4++) {",
"AHCIDevice *ad = &VAR_0->dev[VAR_4];",
"ide_bus_new(&ad->port, VAR_1, VAR_4);",
"ide_init2(&ad->port, irqs[VAR_4]);",
"ad->hba = VAR_0;",
"ad->port_no = VAR_4;",
"ad->port.VAR_2 = &ad->VAR_2;",
"ad->port.VAR_2->ops = &ahci_dma_ops;",
"ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
1,334 | static void put_psr(target_ulong val)
{
env->psr = val & PSR_ICC;
env->psref = (val & PSR_EF)? 1 : 0;
env->psrpil = (val & PSR_PIL) >> 8;
#if ((!defined (TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
cpu_check_irqs(env);
#endif
env->psrs = (val & PSR_S)? 1 : 0;
env->psrps = (val & PSR_PS)? 1 : 0;
#if !defined (TARGET_SPARC64)
env->psret = (val & PSR_ET)? 1 : 0;
#endif
set_cwp(val & PSR_CWP);
env->cc_op = CC_OP_FLAGS;
}
| true | qemu | 2aae2b8e0abd58e76d616bcbe93c6966d06d0188 | static void put_psr(target_ulong val)
{
env->psr = val & PSR_ICC;
env->psref = (val & PSR_EF)? 1 : 0;
env->psrpil = (val & PSR_PIL) >> 8;
#if ((!defined (TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
cpu_check_irqs(env);
#endif
env->psrs = (val & PSR_S)? 1 : 0;
env->psrps = (val & PSR_PS)? 1 : 0;
#if !defined (TARGET_SPARC64)
env->psret = (val & PSR_ET)? 1 : 0;
#endif
set_cwp(val & PSR_CWP);
env->cc_op = CC_OP_FLAGS;
}
| {
"code": [
"#endif",
"#endif",
"#if !defined (TARGET_SPARC64)",
"#endif"
],
"line_no": [
15,
15,
21,
15
]
} | static void FUNC_0(target_ulong VAR_0)
{
env->psr = VAR_0 & PSR_ICC;
env->psref = (VAR_0 & PSR_EF)? 1 : 0;
env->psrpil = (VAR_0 & PSR_PIL) >> 8;
#if ((!defined (TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))
cpu_check_irqs(env);
#endif
env->psrs = (VAR_0 & PSR_S)? 1 : 0;
env->psrps = (VAR_0 & PSR_PS)? 1 : 0;
#if !defined (TARGET_SPARC64)
env->psret = (VAR_0 & PSR_ET)? 1 : 0;
#endif
set_cwp(VAR_0 & PSR_CWP);
env->cc_op = CC_OP_FLAGS;
}
| [
"static void FUNC_0(target_ulong VAR_0)\n{",
"env->psr = VAR_0 & PSR_ICC;",
"env->psref = (VAR_0 & PSR_EF)? 1 : 0;",
"env->psrpil = (VAR_0 & PSR_PIL) >> 8;",
"#if ((!defined (TARGET_SPARC64)) && !defined(CONFIG_USER_ONLY))\ncpu_check_irqs(env);",
"#endif\nenv->psrs = (VAR_0 & PSR_S)? 1 : 0;",
"env->psrps = (VAR_0 & PSR_PS)? 1 : 0;",
"#if !defined (TARGET_SPARC64)\nenv->psret = (VAR_0 & PSR_ET)? 1 : 0;",
"#endif\nset_cwp(VAR_0 & PSR_CWP);",
"env->cc_op = CC_OP_FLAGS;",
"}"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21,
23
],
[
25,
27
],
[
29
],
[
31
]
] |
1,336 | void dsputil_init_ppc(void)
{
// Common optimisations whether Altivec or not
// ... pending ...
#if HAVE_ALTIVEC
if (has_altivec()) {
// Altivec specific optimisations
pix_abs16x16 = pix_abs16x16_altivec;
pix_abs8x8 = pix_abs8x8_altivec;
pix_sum = pix_sum_altivec;
diff_pixels = diff_pixels_altivec;
get_pixels = get_pixels_altivec;
} else
#endif
{
// Non-AltiVec PPC optimisations
// ... pending ...
}
}
| false | FFmpeg | af19f78f2fe2b969104d4419efd25fdee90a2814 | void dsputil_init_ppc(void)
{
#if HAVE_ALTIVEC
if (has_altivec()) {
pix_abs16x16 = pix_abs16x16_altivec;
pix_abs8x8 = pix_abs8x8_altivec;
pix_sum = pix_sum_altivec;
diff_pixels = diff_pixels_altivec;
get_pixels = get_pixels_altivec;
} else
#endif
{
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(void)
{
#if HAVE_ALTIVEC
if (has_altivec()) {
pix_abs16x16 = pix_abs16x16_altivec;
pix_abs8x8 = pix_abs8x8_altivec;
pix_sum = pix_sum_altivec;
diff_pixels = diff_pixels_altivec;
get_pixels = get_pixels_altivec;
} else
#endif
{
}
}
| [
"void FUNC_0(void)\n{",
"#if HAVE_ALTIVEC\nif (has_altivec()) {",
"pix_abs16x16 = pix_abs16x16_altivec;",
"pix_abs8x8 = pix_abs8x8_altivec;",
"pix_sum = pix_sum_altivec;",
"diff_pixels = diff_pixels_altivec;",
"get_pixels = get_pixels_altivec;",
"} else",
"#endif\n{",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31,
33
],
[
41
],
[
43
]
] |
1,339 | int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
int64_t size)
{
BDRVQcowState *s = bs->opaque;
int chk = s->overlap_check & ~ign;
int i, j;
if (!size) {
return 0;
}
if (chk & QCOW2_OL_MAIN_HEADER) {
if (offset < s->cluster_size) {
return QCOW2_OL_MAIN_HEADER;
}
}
/* align range to test to cluster boundaries */
size = align_offset(offset_into_cluster(s, offset) + size, s->cluster_size);
offset = start_of_cluster(s, offset);
if ((chk & QCOW2_OL_ACTIVE_L1) && s->l1_size) {
if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) {
return QCOW2_OL_ACTIVE_L1;
}
}
if ((chk & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) {
if (overlaps_with(s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t))) {
return QCOW2_OL_REFCOUNT_TABLE;
}
}
if ((chk & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) {
if (overlaps_with(s->snapshots_offset, s->snapshots_size)) {
return QCOW2_OL_SNAPSHOT_TABLE;
}
}
if ((chk & QCOW2_OL_INACTIVE_L1) && s->snapshots) {
for (i = 0; i < s->nb_snapshots; i++) {
if (s->snapshots[i].l1_size &&
overlaps_with(s->snapshots[i].l1_table_offset,
s->snapshots[i].l1_size * sizeof(uint64_t))) {
return QCOW2_OL_INACTIVE_L1;
}
}
}
if ((chk & QCOW2_OL_ACTIVE_L2) && s->l1_table) {
for (i = 0; i < s->l1_size; i++) {
if ((s->l1_table[i] & L1E_OFFSET_MASK) &&
overlaps_with(s->l1_table[i] & L1E_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_ACTIVE_L2;
}
}
}
if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
for (i = 0; i < s->refcount_table_size; i++) {
if ((s->refcount_table[i] & REFT_OFFSET_MASK) &&
overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_REFCOUNT_BLOCK;
}
}
}
if ((chk & QCOW2_OL_INACTIVE_L2) && s->snapshots) {
for (i = 0; i < s->nb_snapshots; i++) {
uint64_t l1_ofs = s->snapshots[i].l1_table_offset;
uint32_t l1_sz = s->snapshots[i].l1_size;
uint64_t l1_sz2 = l1_sz * sizeof(uint64_t);
uint64_t *l1 = g_malloc(l1_sz2);
int ret;
ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2);
if (ret < 0) {
g_free(l1);
return ret;
}
for (j = 0; j < l1_sz; j++) {
uint64_t l2_ofs = be64_to_cpu(l1[j]) & L1E_OFFSET_MASK;
if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) {
g_free(l1);
return QCOW2_OL_INACTIVE_L2;
}
}
g_free(l1);
}
}
return 0;
}
| true | qemu | de82815db1c89da058b7fb941dab137d6d9ab738 | int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
int64_t size)
{
BDRVQcowState *s = bs->opaque;
int chk = s->overlap_check & ~ign;
int i, j;
if (!size) {
return 0;
}
if (chk & QCOW2_OL_MAIN_HEADER) {
if (offset < s->cluster_size) {
return QCOW2_OL_MAIN_HEADER;
}
}
size = align_offset(offset_into_cluster(s, offset) + size, s->cluster_size);
offset = start_of_cluster(s, offset);
if ((chk & QCOW2_OL_ACTIVE_L1) && s->l1_size) {
if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) {
return QCOW2_OL_ACTIVE_L1;
}
}
if ((chk & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) {
if (overlaps_with(s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t))) {
return QCOW2_OL_REFCOUNT_TABLE;
}
}
if ((chk & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) {
if (overlaps_with(s->snapshots_offset, s->snapshots_size)) {
return QCOW2_OL_SNAPSHOT_TABLE;
}
}
if ((chk & QCOW2_OL_INACTIVE_L1) && s->snapshots) {
for (i = 0; i < s->nb_snapshots; i++) {
if (s->snapshots[i].l1_size &&
overlaps_with(s->snapshots[i].l1_table_offset,
s->snapshots[i].l1_size * sizeof(uint64_t))) {
return QCOW2_OL_INACTIVE_L1;
}
}
}
if ((chk & QCOW2_OL_ACTIVE_L2) && s->l1_table) {
for (i = 0; i < s->l1_size; i++) {
if ((s->l1_table[i] & L1E_OFFSET_MASK) &&
overlaps_with(s->l1_table[i] & L1E_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_ACTIVE_L2;
}
}
}
if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
for (i = 0; i < s->refcount_table_size; i++) {
if ((s->refcount_table[i] & REFT_OFFSET_MASK) &&
overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_REFCOUNT_BLOCK;
}
}
}
if ((chk & QCOW2_OL_INACTIVE_L2) && s->snapshots) {
for (i = 0; i < s->nb_snapshots; i++) {
uint64_t l1_ofs = s->snapshots[i].l1_table_offset;
uint32_t l1_sz = s->snapshots[i].l1_size;
uint64_t l1_sz2 = l1_sz * sizeof(uint64_t);
uint64_t *l1 = g_malloc(l1_sz2);
int ret;
ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2);
if (ret < 0) {
g_free(l1);
return ret;
}
for (j = 0; j < l1_sz; j++) {
uint64_t l2_ofs = be64_to_cpu(l1[j]) & L1E_OFFSET_MASK;
if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) {
g_free(l1);
return QCOW2_OL_INACTIVE_L2;
}
}
g_free(l1);
}
}
return 0;
}
| {
"code": [
" uint64_t *l1 = g_malloc(l1_sz2);"
],
"line_no": [
151
]
} | int FUNC_0(BlockDriverState *VAR_0, int VAR_1, int64_t VAR_2,
int64_t VAR_3)
{
BDRVQcowState *s = VAR_0->opaque;
int VAR_4 = s->overlap_check & ~VAR_1;
int VAR_5, VAR_6;
if (!VAR_3) {
return 0;
}
if (VAR_4 & QCOW2_OL_MAIN_HEADER) {
if (VAR_2 < s->cluster_size) {
return QCOW2_OL_MAIN_HEADER;
}
}
VAR_3 = align_offset(offset_into_cluster(s, VAR_2) + VAR_3, s->cluster_size);
VAR_2 = start_of_cluster(s, VAR_2);
if ((VAR_4 & QCOW2_OL_ACTIVE_L1) && s->l1_size) {
if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) {
return QCOW2_OL_ACTIVE_L1;
}
}
if ((VAR_4 & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) {
if (overlaps_with(s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t))) {
return QCOW2_OL_REFCOUNT_TABLE;
}
}
if ((VAR_4 & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) {
if (overlaps_with(s->snapshots_offset, s->snapshots_size)) {
return QCOW2_OL_SNAPSHOT_TABLE;
}
}
if ((VAR_4 & QCOW2_OL_INACTIVE_L1) && s->snapshots) {
for (VAR_5 = 0; VAR_5 < s->nb_snapshots; VAR_5++) {
if (s->snapshots[VAR_5].l1_size &&
overlaps_with(s->snapshots[VAR_5].l1_table_offset,
s->snapshots[VAR_5].l1_size * sizeof(uint64_t))) {
return QCOW2_OL_INACTIVE_L1;
}
}
}
if ((VAR_4 & QCOW2_OL_ACTIVE_L2) && s->l1_table) {
for (VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++) {
if ((s->l1_table[VAR_5] & L1E_OFFSET_MASK) &&
overlaps_with(s->l1_table[VAR_5] & L1E_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_ACTIVE_L2;
}
}
}
if ((VAR_4 & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
for (VAR_5 = 0; VAR_5 < s->refcount_table_size; VAR_5++) {
if ((s->refcount_table[VAR_5] & REFT_OFFSET_MASK) &&
overlaps_with(s->refcount_table[VAR_5] & REFT_OFFSET_MASK,
s->cluster_size)) {
return QCOW2_OL_REFCOUNT_BLOCK;
}
}
}
if ((VAR_4 & QCOW2_OL_INACTIVE_L2) && s->snapshots) {
for (VAR_5 = 0; VAR_5 < s->nb_snapshots; VAR_5++) {
uint64_t l1_ofs = s->snapshots[VAR_5].l1_table_offset;
uint32_t l1_sz = s->snapshots[VAR_5].l1_size;
uint64_t l1_sz2 = l1_sz * sizeof(uint64_t);
uint64_t *l1 = g_malloc(l1_sz2);
int ret;
ret = bdrv_pread(VAR_0->file, l1_ofs, l1, l1_sz2);
if (ret < 0) {
g_free(l1);
return ret;
}
for (VAR_6 = 0; VAR_6 < l1_sz; VAR_6++) {
uint64_t l2_ofs = be64_to_cpu(l1[VAR_6]) & L1E_OFFSET_MASK;
if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) {
g_free(l1);
return QCOW2_OL_INACTIVE_L2;
}
}
g_free(l1);
}
}
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int VAR_1, int64_t VAR_2,\nint64_t VAR_3)\n{",
"BDRVQcowState *s = VAR_0->opaque;",
"int VAR_4 = s->overlap_check & ~VAR_1;",
"int VAR_5, VAR_6;",
"if (!VAR_3) {",
"return 0;",
"}",
"if (VAR_4 & QCOW2_OL_MAIN_HEADER) {",
"if (VAR_2 < s->cluster_size) {",
"return QCOW2_OL_MAIN_HEADER;",
"}",
"}",
"VAR_3 = align_offset(offset_into_cluster(s, VAR_2) + VAR_3, s->cluster_size);",
"VAR_2 = start_of_cluster(s, VAR_2);",
"if ((VAR_4 & QCOW2_OL_ACTIVE_L1) && s->l1_size) {",
"if (overlaps_with(s->l1_table_offset, s->l1_size * sizeof(uint64_t))) {",
"return QCOW2_OL_ACTIVE_L1;",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_REFCOUNT_TABLE) && s->refcount_table_size) {",
"if (overlaps_with(s->refcount_table_offset,\ns->refcount_table_size * sizeof(uint64_t))) {",
"return QCOW2_OL_REFCOUNT_TABLE;",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_SNAPSHOT_TABLE) && s->snapshots_size) {",
"if (overlaps_with(s->snapshots_offset, s->snapshots_size)) {",
"return QCOW2_OL_SNAPSHOT_TABLE;",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_INACTIVE_L1) && s->snapshots) {",
"for (VAR_5 = 0; VAR_5 < s->nb_snapshots; VAR_5++) {",
"if (s->snapshots[VAR_5].l1_size &&\noverlaps_with(s->snapshots[VAR_5].l1_table_offset,\ns->snapshots[VAR_5].l1_size * sizeof(uint64_t))) {",
"return QCOW2_OL_INACTIVE_L1;",
"}",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_ACTIVE_L2) && s->l1_table) {",
"for (VAR_5 = 0; VAR_5 < s->l1_size; VAR_5++) {",
"if ((s->l1_table[VAR_5] & L1E_OFFSET_MASK) &&\noverlaps_with(s->l1_table[VAR_5] & L1E_OFFSET_MASK,\ns->cluster_size)) {",
"return QCOW2_OL_ACTIVE_L2;",
"}",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {",
"for (VAR_5 = 0; VAR_5 < s->refcount_table_size; VAR_5++) {",
"if ((s->refcount_table[VAR_5] & REFT_OFFSET_MASK) &&\noverlaps_with(s->refcount_table[VAR_5] & REFT_OFFSET_MASK,\ns->cluster_size)) {",
"return QCOW2_OL_REFCOUNT_BLOCK;",
"}",
"}",
"}",
"if ((VAR_4 & QCOW2_OL_INACTIVE_L2) && s->snapshots) {",
"for (VAR_5 = 0; VAR_5 < s->nb_snapshots; VAR_5++) {",
"uint64_t l1_ofs = s->snapshots[VAR_5].l1_table_offset;",
"uint32_t l1_sz = s->snapshots[VAR_5].l1_size;",
"uint64_t l1_sz2 = l1_sz * sizeof(uint64_t);",
"uint64_t *l1 = g_malloc(l1_sz2);",
"int ret;",
"ret = bdrv_pread(VAR_0->file, l1_ofs, l1, l1_sz2);",
"if (ret < 0) {",
"g_free(l1);",
"return ret;",
"}",
"for (VAR_6 = 0; VAR_6 < l1_sz; VAR_6++) {",
"uint64_t l2_ofs = be64_to_cpu(l1[VAR_6]) & L1E_OFFSET_MASK;",
"if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) {",
"g_free(l1);",
"return QCOW2_OL_INACTIVE_L2;",
"}",
"}",
"g_free(l1);",
"}",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
81
],
[
83
],
[
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107,
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125,
127,
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
193
],
[
195
]
] |
1,340 | static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, AVFormatContext *fmt)
{
char *config = NULL;
switch (c->codec_id) {
case AV_CODEC_ID_H264: {
int mode = 1;
if (fmt && fmt->oformat && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0"))
mode = 0;
if (c->extradata_size) {
config = extradata2psets(c);
}
av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n"
"a=fmtp:%d packetization-mode=%d%s\r\n",
payload_type,
payload_type, mode, config ? config : "");
break;
}
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
/* a=framesize is required by 3GPP TS 26.234 (PSS). It
* actually specifies the maximum video size, but we only know
* the current size. This is required for playback on Android
* stagefright and on Samsung bada. */
if (!fmt || !fmt->oformat->priv_class ||
!av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") ||
c->codec_id == AV_CODEC_ID_H263P)
av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n"
"a=framesize:%d %d-%d\r\n",
payload_type,
payload_type, c->width, c->height);
break;
case AV_CODEC_ID_HEVC:
if (c->extradata_size)
av_log(NULL, AV_LOG_WARNING, "HEVC extradata not currently "
"passed properly through SDP\n");
av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type);
break;
case AV_CODEC_ID_MPEG4:
if (c->extradata_size) {
config = extradata2config(c);
}
av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n"
"a=fmtp:%d profile-level-id=1%s\r\n",
payload_type,
payload_type, config ? config : "");
break;
case AV_CODEC_ID_AAC:
if (fmt && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) {
config = latm_context2config(c);
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n"
"a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, latm_context2profilelevel(c), config);
} else {
if (c->extradata_size) {
config = extradata2config(c);
} else {
/* FIXME: maybe we can forge config information based on the
* codec parameters...
*/
av_log(c, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n");
return NULL;
}
if (!config) {
return NULL;
}
av_strlcatf(buff, size, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n"
"a=fmtp:%d profile-level-id=1;"
"mode=AAC-hbr;sizelength=13;indexlength=3;"
"indexdeltalength=3%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, config);
}
break;
case AV_CODEC_ID_PCM_S16BE:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_PCM_MULAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_PCM_ALAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_AMR_NB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
payload_type, c->sample_rate, c->channels,
payload_type);
break;
case AV_CODEC_ID_AMR_WB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
payload_type, c->sample_rate, c->channels,
payload_type);
break;
case AV_CODEC_ID_VORBIS:
if (c->extradata_size)
config = xiph_extradata2config(c);
else
av_log(c, AV_LOG_ERROR, "Vorbis configuration info missing\n");
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n"
"a=fmtp:%d configuration=%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, config);
break;
case AV_CODEC_ID_THEORA: {
const char *pix_fmt;
switch (c->pix_fmt) {
case AV_PIX_FMT_YUV420P:
pix_fmt = "YCbCr-4:2:0";
break;
case AV_PIX_FMT_YUV422P:
pix_fmt = "YCbCr-4:2:2";
break;
case AV_PIX_FMT_YUV444P:
pix_fmt = "YCbCr-4:4:4";
break;
default:
av_log(c, AV_LOG_ERROR, "Unsupported pixel format.\n");
return NULL;
}
if (c->extradata_size)
config = xiph_extradata2config(c);
else
av_log(c, AV_LOG_ERROR, "Theora configuation info missing\n");
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d theora/90000\r\n"
"a=fmtp:%d delivery-method=inline; "
"width=%d; height=%d; sampling=%s; "
"configuration=%s\r\n",
payload_type, payload_type,
c->width, c->height, pix_fmt, config);
break;
}
case AV_CODEC_ID_VP8:
av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n",
payload_type);
break;
case AV_CODEC_ID_MJPEG:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d JPEG/90000\r\n",
payload_type);
break;
case AV_CODEC_ID_ADPCM_G722:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n",
payload_type,
8000, c->channels);
break;
case AV_CODEC_ID_ADPCM_G726: {
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n",
payload_type,
c->bits_per_coded_sample*8,
c->sample_rate);
break;
}
case AV_CODEC_ID_ILBC:
av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
"a=fmtp:%d mode=%d\r\n",
payload_type, c->sample_rate,
payload_type, c->block_align == 38 ? 20 : 30);
break;
case AV_CODEC_ID_SPEEX:
av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
payload_type, c->sample_rate);
break;
case AV_CODEC_ID_OPUS:
/* The opus RTP draft says that all opus streams MUST be declared
as stereo, to avoid negotiation failures. The actual number of
channels can change on a packet-by-packet basis. The number of
channels a receiver prefers to receive or a sender plans to send
can be declared via fmtp parameters (both default to mono), but
receivers MUST be able to receive and process stereo packets. */
av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n",
payload_type);
if (c->channels == 2) {
av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo:1\r\n",
payload_type);
}
break;
default:
/* Nothing special to do here... */
break;
}
av_free(config);
return buff;
}
| true | FFmpeg | e5cfc8fdad901c9487fe896421972852f38bcf5b | static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, AVFormatContext *fmt)
{
char *config = NULL;
switch (c->codec_id) {
case AV_CODEC_ID_H264: {
int mode = 1;
if (fmt && fmt->oformat && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0"))
mode = 0;
if (c->extradata_size) {
config = extradata2psets(c);
}
av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n"
"a=fmtp:%d packetization-mode=%d%s\r\n",
payload_type,
payload_type, mode, config ? config : "");
break;
}
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if (!fmt || !fmt->oformat->priv_class ||
!av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") ||
c->codec_id == AV_CODEC_ID_H263P)
av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n"
"a=framesize:%d %d-%d\r\n",
payload_type,
payload_type, c->width, c->height);
break;
case AV_CODEC_ID_HEVC:
if (c->extradata_size)
av_log(NULL, AV_LOG_WARNING, "HEVC extradata not currently "
"passed properly through SDP\n");
av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type);
break;
case AV_CODEC_ID_MPEG4:
if (c->extradata_size) {
config = extradata2config(c);
}
av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n"
"a=fmtp:%d profile-level-id=1%s\r\n",
payload_type,
payload_type, config ? config : "");
break;
case AV_CODEC_ID_AAC:
if (fmt && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) {
config = latm_context2config(c);
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n"
"a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, latm_context2profilelevel(c), config);
} else {
if (c->extradata_size) {
config = extradata2config(c);
} else {
av_log(c, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n");
return NULL;
}
if (!config) {
return NULL;
}
av_strlcatf(buff, size, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n"
"a=fmtp:%d profile-level-id=1;"
"mode=AAC-hbr;sizelength=13;indexlength=3;"
"indexdeltalength=3%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, config);
}
break;
case AV_CODEC_ID_PCM_S16BE:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_PCM_MULAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_PCM_ALAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n",
payload_type,
c->sample_rate, c->channels);
break;
case AV_CODEC_ID_AMR_NB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
payload_type, c->sample_rate, c->channels,
payload_type);
break;
case AV_CODEC_ID_AMR_WB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
payload_type, c->sample_rate, c->channels,
payload_type);
break;
case AV_CODEC_ID_VORBIS:
if (c->extradata_size)
config = xiph_extradata2config(c);
else
av_log(c, AV_LOG_ERROR, "Vorbis configuration info missing\n");
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n"
"a=fmtp:%d configuration=%s\r\n",
payload_type, c->sample_rate, c->channels,
payload_type, config);
break;
case AV_CODEC_ID_THEORA: {
const char *pix_fmt;
switch (c->pix_fmt) {
case AV_PIX_FMT_YUV420P:
pix_fmt = "YCbCr-4:2:0";
break;
case AV_PIX_FMT_YUV422P:
pix_fmt = "YCbCr-4:2:2";
break;
case AV_PIX_FMT_YUV444P:
pix_fmt = "YCbCr-4:4:4";
break;
default:
av_log(c, AV_LOG_ERROR, "Unsupported pixel format.\n");
return NULL;
}
if (c->extradata_size)
config = xiph_extradata2config(c);
else
av_log(c, AV_LOG_ERROR, "Theora configuation info missing\n");
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d theora/90000\r\n"
"a=fmtp:%d delivery-method=inline; "
"width=%d; height=%d; sampling=%s; "
"configuration=%s\r\n",
payload_type, payload_type,
c->width, c->height, pix_fmt, config);
break;
}
case AV_CODEC_ID_VP8:
av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n",
payload_type);
break;
case AV_CODEC_ID_MJPEG:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d JPEG/90000\r\n",
payload_type);
break;
case AV_CODEC_ID_ADPCM_G722:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n",
payload_type,
8000, c->channels);
break;
case AV_CODEC_ID_ADPCM_G726: {
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n",
payload_type,
c->bits_per_coded_sample*8,
c->sample_rate);
break;
}
case AV_CODEC_ID_ILBC:
av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
"a=fmtp:%d mode=%d\r\n",
payload_type, c->sample_rate,
payload_type, c->block_align == 38 ? 20 : 30);
break;
case AV_CODEC_ID_SPEEX:
av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
payload_type, c->sample_rate);
break;
case AV_CODEC_ID_OPUS:
av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n",
payload_type);
if (c->channels == 2) {
av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo:1\r\n",
payload_type);
}
break;
default:
break;
}
av_free(config);
return buff;
}
| {
"code": [
" av_log(NULL, AV_LOG_WARNING, \"HEVC extradata not currently \"",
" \"passed properly through SDP\\n\");"
],
"line_no": [
71,
73
]
} | static char *FUNC_0(char *VAR_0, int VAR_1, AVCodecContext *VAR_2, int VAR_3, AVFormatContext *VAR_4)
{
char *VAR_5 = NULL;
switch (VAR_2->codec_id) {
case AV_CODEC_ID_H264: {
int VAR_6 = 1;
if (VAR_4 && VAR_4->oformat && VAR_4->oformat->priv_class &&
av_opt_flag_is_set(VAR_4->priv_data, "rtpflags", "h264_mode0"))
VAR_6 = 0;
if (VAR_2->extradata_size) {
VAR_5 = extradata2psets(VAR_2);
}
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d H264/90000\r\n"
"a=fmtp:%d packetization-VAR_6=%d%s\r\n",
VAR_3,
VAR_3, VAR_6, VAR_5 ? VAR_5 : "");
break;
}
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
if (!VAR_4 || !VAR_4->oformat->priv_class ||
!av_opt_flag_is_set(VAR_4->priv_data, "rtpflags", "rfc2190") ||
VAR_2->codec_id == AV_CODEC_ID_H263P)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d H263-2000/90000\r\n"
"a=framesize:%d %d-%d\r\n",
VAR_3,
VAR_3, VAR_2->width, VAR_2->height);
break;
case AV_CODEC_ID_HEVC:
if (VAR_2->extradata_size)
av_log(NULL, AV_LOG_WARNING, "HEVC extradata not currently "
"passed properly through SDP\n");
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d H265/90000\r\n", VAR_3);
break;
case AV_CODEC_ID_MPEG4:
if (VAR_2->extradata_size) {
VAR_5 = extradata2config(VAR_2);
}
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d MP4V-ES/90000\r\n"
"a=fmtp:%d profile-level-id=1%s\r\n",
VAR_3,
VAR_3, VAR_5 ? VAR_5 : "");
break;
case AV_CODEC_ID_AAC:
if (VAR_4 && VAR_4->oformat->priv_class &&
av_opt_flag_is_set(VAR_4->priv_data, "rtpflags", "latm")) {
VAR_5 = latm_context2config(VAR_2);
if (!VAR_5)
return NULL;
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n"
"a=fmtp:%d profile-level-id=%d;cpresent=0;VAR_5=%s\r\n",
VAR_3, VAR_2->sample_rate, VAR_2->channels,
VAR_3, latm_context2profilelevel(VAR_2), VAR_5);
} else {
if (VAR_2->extradata_size) {
VAR_5 = extradata2config(VAR_2);
} else {
av_log(VAR_2, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n");
return NULL;
}
if (!VAR_5) {
return NULL;
}
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n"
"a=fmtp:%d profile-level-id=1;"
"VAR_6=AAC-hbr;sizelength=13;indexlength=3;"
"indexdeltalength=3%s\r\n",
VAR_3, VAR_2->sample_rate, VAR_2->channels,
VAR_3, VAR_5);
}
break;
case AV_CODEC_ID_PCM_S16BE:
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d L16/%d/%d\r\n",
VAR_3,
VAR_2->sample_rate, VAR_2->channels);
break;
case AV_CODEC_ID_PCM_MULAW:
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d PCMU/%d/%d\r\n",
VAR_3,
VAR_2->sample_rate, VAR_2->channels);
break;
case AV_CODEC_ID_PCM_ALAW:
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d PCMA/%d/%d\r\n",
VAR_3,
VAR_2->sample_rate, VAR_2->channels);
break;
case AV_CODEC_ID_AMR_NB:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d AMR/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
VAR_3, VAR_2->sample_rate, VAR_2->channels,
VAR_3);
break;
case AV_CODEC_ID_AMR_WB:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d AMR-WB/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
VAR_3, VAR_2->sample_rate, VAR_2->channels,
VAR_3);
break;
case AV_CODEC_ID_VORBIS:
if (VAR_2->extradata_size)
VAR_5 = xiph_extradata2config(VAR_2);
else
av_log(VAR_2, AV_LOG_ERROR, "Vorbis configuration info missing\n");
if (!VAR_5)
return NULL;
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d vorbis/%d/%d\r\n"
"a=fmtp:%d configuration=%s\r\n",
VAR_3, VAR_2->sample_rate, VAR_2->channels,
VAR_3, VAR_5);
break;
case AV_CODEC_ID_THEORA: {
const char *VAR_7;
switch (VAR_2->VAR_7) {
case AV_PIX_FMT_YUV420P:
VAR_7 = "YCbCr-4:2:0";
break;
case AV_PIX_FMT_YUV422P:
VAR_7 = "YCbCr-4:2:2";
break;
case AV_PIX_FMT_YUV444P:
VAR_7 = "YCbCr-4:4:4";
break;
default:
av_log(VAR_2, AV_LOG_ERROR, "Unsupported pixel format.\n");
return NULL;
}
if (VAR_2->extradata_size)
VAR_5 = xiph_extradata2config(VAR_2);
else
av_log(VAR_2, AV_LOG_ERROR, "Theora configuation info missing\n");
if (!VAR_5)
return NULL;
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d theora/90000\r\n"
"a=fmtp:%d delivery-method=inline; "
"width=%d; height=%d; sampling=%s; "
"configuration=%s\r\n",
VAR_3, VAR_3,
VAR_2->width, VAR_2->height, VAR_7, VAR_5);
break;
}
case AV_CODEC_ID_VP8:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d VP8/90000\r\n",
VAR_3);
break;
case AV_CODEC_ID_MJPEG:
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d JPEG/90000\r\n",
VAR_3);
break;
case AV_CODEC_ID_ADPCM_G722:
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d G722/%d/%d\r\n",
VAR_3,
8000, VAR_2->channels);
break;
case AV_CODEC_ID_ADPCM_G726: {
if (VAR_3 >= RTP_PT_PRIVATE)
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d G726-%d/%d\r\n",
VAR_3,
VAR_2->bits_per_coded_sample*8,
VAR_2->sample_rate);
break;
}
case AV_CODEC_ID_ILBC:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d iLBC/%d\r\n"
"a=fmtp:%d VAR_6=%d\r\n",
VAR_3, VAR_2->sample_rate,
VAR_3, VAR_2->block_align == 38 ? 20 : 30);
break;
case AV_CODEC_ID_SPEEX:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d speex/%d\r\n",
VAR_3, VAR_2->sample_rate);
break;
case AV_CODEC_ID_OPUS:
av_strlcatf(VAR_0, VAR_1, "a=rtpmap:%d opus/48000/2\r\n",
VAR_3);
if (VAR_2->channels == 2) {
av_strlcatf(VAR_0, VAR_1, "a=fmtp:%d sprop-stereo:1\r\n",
VAR_3);
}
break;
default:
break;
}
av_free(VAR_5);
return VAR_0;
}
| [
"static char *FUNC_0(char *VAR_0, int VAR_1, AVCodecContext *VAR_2, int VAR_3, AVFormatContext *VAR_4)\n{",
"char *VAR_5 = NULL;",
"switch (VAR_2->codec_id) {",
"case AV_CODEC_ID_H264: {",
"int VAR_6 = 1;",
"if (VAR_4 && VAR_4->oformat && VAR_4->oformat->priv_class &&\nav_opt_flag_is_set(VAR_4->priv_data, \"rtpflags\", \"h264_mode0\"))\nVAR_6 = 0;",
"if (VAR_2->extradata_size) {",
"VAR_5 = extradata2psets(VAR_2);",
"}",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d H264/90000\\r\\n\"\n\"a=fmtp:%d packetization-VAR_6=%d%s\\r\\n\",\nVAR_3,\nVAR_3, VAR_6, VAR_5 ? VAR_5 : \"\");",
"break;",
"}",
"case AV_CODEC_ID_H263:\ncase AV_CODEC_ID_H263P:\nif (!VAR_4 || !VAR_4->oformat->priv_class ||\n!av_opt_flag_is_set(VAR_4->priv_data, \"rtpflags\", \"rfc2190\") ||\nVAR_2->codec_id == AV_CODEC_ID_H263P)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d H263-2000/90000\\r\\n\"\n\"a=framesize:%d %d-%d\\r\\n\",\nVAR_3,\nVAR_3, VAR_2->width, VAR_2->height);",
"break;",
"case AV_CODEC_ID_HEVC:\nif (VAR_2->extradata_size)\nav_log(NULL, AV_LOG_WARNING, \"HEVC extradata not currently \"\n\"passed properly through SDP\\n\");",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d H265/90000\\r\\n\", VAR_3);",
"break;",
"case AV_CODEC_ID_MPEG4:\nif (VAR_2->extradata_size) {",
"VAR_5 = extradata2config(VAR_2);",
"}",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d MP4V-ES/90000\\r\\n\"\n\"a=fmtp:%d profile-level-id=1%s\\r\\n\",\nVAR_3,\nVAR_3, VAR_5 ? VAR_5 : \"\");",
"break;",
"case AV_CODEC_ID_AAC:\nif (VAR_4 && VAR_4->oformat->priv_class &&\nav_opt_flag_is_set(VAR_4->priv_data, \"rtpflags\", \"latm\")) {",
"VAR_5 = latm_context2config(VAR_2);",
"if (!VAR_5)\nreturn NULL;",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d MP4A-LATM/%d/%d\\r\\n\"\n\"a=fmtp:%d profile-level-id=%d;cpresent=0;VAR_5=%s\\r\\n\",",
"VAR_3, VAR_2->sample_rate, VAR_2->channels,\nVAR_3, latm_context2profilelevel(VAR_2), VAR_5);",
"} else {",
"if (VAR_2->extradata_size) {",
"VAR_5 = extradata2config(VAR_2);",
"} else {",
"av_log(VAR_2, AV_LOG_ERROR, \"AAC with no global headers is currently not supported.\\n\");",
"return NULL;",
"}",
"if (!VAR_5) {",
"return NULL;",
"}",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d MPEG4-GENERIC/%d/%d\\r\\n\"\n\"a=fmtp:%d profile-level-id=1;\"",
"\"VAR_6=AAC-hbr;sizelength=13;indexlength=3;\"",
"\"indexdeltalength=3%s\\r\\n\",\nVAR_3, VAR_2->sample_rate, VAR_2->channels,\nVAR_3, VAR_5);",
"}",
"break;",
"case AV_CODEC_ID_PCM_S16BE:\nif (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d L16/%d/%d\\r\\n\",\nVAR_3,\nVAR_2->sample_rate, VAR_2->channels);",
"break;",
"case AV_CODEC_ID_PCM_MULAW:\nif (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d PCMU/%d/%d\\r\\n\",\nVAR_3,\nVAR_2->sample_rate, VAR_2->channels);",
"break;",
"case AV_CODEC_ID_PCM_ALAW:\nif (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d PCMA/%d/%d\\r\\n\",\nVAR_3,\nVAR_2->sample_rate, VAR_2->channels);",
"break;",
"case AV_CODEC_ID_AMR_NB:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d AMR/%d/%d\\r\\n\"\n\"a=fmtp:%d octet-align=1\\r\\n\",\nVAR_3, VAR_2->sample_rate, VAR_2->channels,\nVAR_3);",
"break;",
"case AV_CODEC_ID_AMR_WB:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d AMR-WB/%d/%d\\r\\n\"\n\"a=fmtp:%d octet-align=1\\r\\n\",\nVAR_3, VAR_2->sample_rate, VAR_2->channels,\nVAR_3);",
"break;",
"case AV_CODEC_ID_VORBIS:\nif (VAR_2->extradata_size)\nVAR_5 = xiph_extradata2config(VAR_2);",
"else\nav_log(VAR_2, AV_LOG_ERROR, \"Vorbis configuration info missing\\n\");",
"if (!VAR_5)\nreturn NULL;",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d vorbis/%d/%d\\r\\n\"\n\"a=fmtp:%d configuration=%s\\r\\n\",\nVAR_3, VAR_2->sample_rate, VAR_2->channels,\nVAR_3, VAR_5);",
"break;",
"case AV_CODEC_ID_THEORA: {",
"const char *VAR_7;",
"switch (VAR_2->VAR_7) {",
"case AV_PIX_FMT_YUV420P:\nVAR_7 = \"YCbCr-4:2:0\";",
"break;",
"case AV_PIX_FMT_YUV422P:\nVAR_7 = \"YCbCr-4:2:2\";",
"break;",
"case AV_PIX_FMT_YUV444P:\nVAR_7 = \"YCbCr-4:4:4\";",
"break;",
"default:\nav_log(VAR_2, AV_LOG_ERROR, \"Unsupported pixel format.\\n\");",
"return NULL;",
"}",
"if (VAR_2->extradata_size)\nVAR_5 = xiph_extradata2config(VAR_2);",
"else\nav_log(VAR_2, AV_LOG_ERROR, \"Theora configuation info missing\\n\");",
"if (!VAR_5)\nreturn NULL;",
"av_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d theora/90000\\r\\n\"\n\"a=fmtp:%d delivery-method=inline; \"",
"\"width=%d; height=%d; sampling=%s; \"",
"\"configuration=%s\\r\\n\",\nVAR_3, VAR_3,\nVAR_2->width, VAR_2->height, VAR_7, VAR_5);",
"break;",
"}",
"case AV_CODEC_ID_VP8:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d VP8/90000\\r\\n\",\nVAR_3);",
"break;",
"case AV_CODEC_ID_MJPEG:\nif (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d JPEG/90000\\r\\n\",\nVAR_3);",
"break;",
"case AV_CODEC_ID_ADPCM_G722:\nif (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d G722/%d/%d\\r\\n\",\nVAR_3,\n8000, VAR_2->channels);",
"break;",
"case AV_CODEC_ID_ADPCM_G726: {",
"if (VAR_3 >= RTP_PT_PRIVATE)\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d G726-%d/%d\\r\\n\",\nVAR_3,\nVAR_2->bits_per_coded_sample*8,\nVAR_2->sample_rate);",
"break;",
"}",
"case AV_CODEC_ID_ILBC:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d iLBC/%d\\r\\n\"\n\"a=fmtp:%d VAR_6=%d\\r\\n\",\nVAR_3, VAR_2->sample_rate,\nVAR_3, VAR_2->block_align == 38 ? 20 : 30);",
"break;",
"case AV_CODEC_ID_SPEEX:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d speex/%d\\r\\n\",\nVAR_3, VAR_2->sample_rate);",
"break;",
"case AV_CODEC_ID_OPUS:\nav_strlcatf(VAR_0, VAR_1, \"a=rtpmap:%d opus/48000/2\\r\\n\",\nVAR_3);",
"if (VAR_2->channels == 2) {",
"av_strlcatf(VAR_0, VAR_1, \"a=fmtp:%d sprop-stereo:1\\r\\n\",\nVAR_3);",
"}",
"break;",
"default:\nbreak;",
"}",
"av_free(VAR_5);",
"return VAR_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
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25
],
[
27,
29,
31,
33
],
[
35
],
[
37
],
[
39,
41,
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
],
[
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
],
[
235,
237,
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257,
259
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
279,
281
],
[
283,
285
],
[
287,
289
],
[
293,
295
],
[
297
],
[
299,
301,
303
],
[
305
],
[
307
],
[
309,
311,
313
],
[
315
],
[
317,
319,
321,
323
],
[
325
],
[
327,
329,
331,
333,
335
],
[
337
],
[
339
],
[
341,
343,
345,
347,
349
],
[
351
],
[
353
],
[
355,
357,
359,
361,
363
],
[
365
],
[
367,
369,
371
],
[
373
],
[
375,
389,
391
],
[
393
],
[
395,
397
],
[
399
],
[
401
],
[
403,
407
],
[
409
],
[
413
],
[
417
],
[
419
]
] |
1,342 | static void compute_status(HTTPContext *c)
{
HTTPContext *c1;
FFStream *stream;
char *p;
time_t ti;
int i, len;
AVIOContext *pb;
if (avio_open_dyn_buf(&pb) < 0) {
/* XXX: return an error ? */
c->buffer_ptr = c->buffer;
c->buffer_end = c->buffer;
return;
}
avio_printf(pb, "HTTP/1.0 200 OK\r\n");
avio_printf(pb, "Content-type: %s\r\n", "text/html");
avio_printf(pb, "Pragma: no-cache\r\n");
avio_printf(pb, "\r\n");
avio_printf(pb, "<html><head><title>%s Status</title>\n", program_name);
if (c->stream->feed_filename[0])
avio_printf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename);
avio_printf(pb, "</head>\n<body>");
avio_printf(pb, "<h1>%s Status</h1>\n", program_name);
/* format status */
avio_printf(pb, "<h2>Available Streams</h2>\n");
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n");
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
stream = first_stream;
while (stream != NULL) {
char sfilename[1024];
char *eosf;
if (stream->feed != stream) {
av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10);
eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) {
if (strcmp(eosf - 4, ".asf") == 0)
strcpy(eosf - 4, ".asx");
else if (strcmp(eosf - 3, ".rm") == 0)
strcpy(eosf - 3, ".ram");
else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
/* generate a sample RTSP director if
unicast. Generate an SDP redirector if
multicast */
eosf = strrchr(sfilename, '.');
if (!eosf)
eosf = sfilename + strlen(sfilename);
if (stream->is_multicast)
strcpy(eosf, ".sdp");
else
strcpy(eosf, ".rtsp");
}
}
avio_printf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
sfilename, stream->filename);
avio_printf(pb, "<td align=right> %d <td align=right> ",
stream->conns_served);
fmt_bytecount(pb, stream->bytes_served);
switch(stream->stream_type) {
case STREAM_TYPE_LIVE: {
int audio_bit_rate = 0;
int video_bit_rate = 0;
const char *audio_codec_name = "";
const char *video_codec_name = "";
const char *audio_codec_name_extra = "";
const char *video_codec_name_extra = "";
for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
audio_bit_rate += st->codec->bit_rate;
if (codec) {
if (*audio_codec_name)
audio_codec_name_extra = "...";
audio_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_VIDEO:
video_bit_rate += st->codec->bit_rate;
if (codec) {
if (*video_codec_name)
video_codec_name_extra = "...";
video_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_DATA:
video_bit_rate += st->codec->bit_rate;
break;
default:
abort();
}
}
avio_printf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
stream->fmt->name,
stream->bandwidth,
video_bit_rate / 1000, video_codec_name, video_codec_name_extra,
audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra);
if (stream->feed)
avio_printf(pb, "<td>%s", stream->feed->filename);
else
avio_printf(pb, "<td>%s", stream->feed_filename);
avio_printf(pb, "\n");
}
break;
default:
avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
break;
}
}
stream = stream->next;
}
avio_printf(pb, "</table>\n");
stream = first_stream;
while (stream != NULL) {
if (stream->feed == stream) {
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid);
#if defined(linux) && !defined(CONFIG_NOCUTILS)
{
FILE *pid_stat;
char ps_cmd[64];
/* This is somewhat linux specific I guess */
snprintf(ps_cmd, sizeof(ps_cmd),
"ps -o \"%%cpu,cputime\" --no-headers %d",
stream->pid);
pid_stat = popen(ps_cmd, "r");
if (pid_stat) {
char cpuperc[10];
char cpuused[64];
if (fscanf(pid_stat, "%10s %64s", cpuperc,
cpuused) == 2) {
avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
cpuperc, cpuused);
}
fclose(pid_stat);
}
}
#endif
avio_printf(pb, "<p>");
}
avio_printf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
for (i = 0; i < stream->nb_streams; i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
const char *type = "unknown";
char parameters[64];
parameters[0] = 0;
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
type = "audio";
snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate);
break;
case AVMEDIA_TYPE_VIDEO:
type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
break;
default:
abort();
}
avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
}
avio_printf(pb, "</table>\n");
}
stream = stream->next;
}
/* connection status */
avio_printf(pb, "<h2>Connection Status</h2>\n");
avio_printf(pb, "Number of connections: %d / %d<br>\n",
nb_connections, nb_max_connections);
avio_printf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
current_bandwidth, max_bandwidth);
avio_printf(pb, "<table>\n");
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
c1 = first_http_ctx;
i = 0;
while (c1 != NULL) {
int bitrate;
int j;
bitrate = 0;
if (c1->stream) {
for (j = 0; j < c1->stream->nb_streams; j++) {
if (!c1->stream->feed)
bitrate += c1->stream->streams[j]->codec->bit_rate;
else if (c1->feed_streams[j] >= 0)
bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec->bit_rate;
}
}
i++;
p = inet_ntoa(c1->from_addr.sin_addr);
avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
i,
c1->stream ? c1->stream->filename : "",
c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
p,
c1->protocol,
http_state[c1->state]);
fmt_bytecount(pb, bitrate);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, c1->data_count);
avio_printf(pb, "\n");
c1 = c1->next;
}
avio_printf(pb, "</table>\n");
/* date */
ti = time(NULL);
p = ctime(&ti);
avio_printf(pb, "<hr size=1 noshade>Generated at %s", p);
avio_printf(pb, "</body>\n</html>\n");
len = avio_close_dyn_buf(pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
}
| true | FFmpeg | f077e1fb4c912a66ab5d766fd256803821d92c67 | static void compute_status(HTTPContext *c)
{
HTTPContext *c1;
FFStream *stream;
char *p;
time_t ti;
int i, len;
AVIOContext *pb;
if (avio_open_dyn_buf(&pb) < 0) {
c->buffer_ptr = c->buffer;
c->buffer_end = c->buffer;
return;
}
avio_printf(pb, "HTTP/1.0 200 OK\r\n");
avio_printf(pb, "Content-type: %s\r\n", "text/html");
avio_printf(pb, "Pragma: no-cache\r\n");
avio_printf(pb, "\r\n");
avio_printf(pb, "<html><head><title>%s Status</title>\n", program_name);
if (c->stream->feed_filename[0])
avio_printf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", c->stream->feed_filename);
avio_printf(pb, "</head>\n<body>");
avio_printf(pb, "<h1>%s Status</h1>\n", program_name);
avio_printf(pb, "<h2>Available Streams</h2>\n");
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n");
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
stream = first_stream;
while (stream != NULL) {
char sfilename[1024];
char *eosf;
if (stream->feed != stream) {
av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10);
eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) {
if (strcmp(eosf - 4, ".asf") == 0)
strcpy(eosf - 4, ".asx");
else if (strcmp(eosf - 3, ".rm") == 0)
strcpy(eosf - 3, ".ram");
else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
eosf = strrchr(sfilename, '.');
if (!eosf)
eosf = sfilename + strlen(sfilename);
if (stream->is_multicast)
strcpy(eosf, ".sdp");
else
strcpy(eosf, ".rtsp");
}
}
avio_printf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
sfilename, stream->filename);
avio_printf(pb, "<td align=right> %d <td align=right> ",
stream->conns_served);
fmt_bytecount(pb, stream->bytes_served);
switch(stream->stream_type) {
case STREAM_TYPE_LIVE: {
int audio_bit_rate = 0;
int video_bit_rate = 0;
const char *audio_codec_name = "";
const char *video_codec_name = "";
const char *audio_codec_name_extra = "";
const char *video_codec_name_extra = "";
for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
audio_bit_rate += st->codec->bit_rate;
if (codec) {
if (*audio_codec_name)
audio_codec_name_extra = "...";
audio_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_VIDEO:
video_bit_rate += st->codec->bit_rate;
if (codec) {
if (*video_codec_name)
video_codec_name_extra = "...";
video_codec_name = codec->name;
}
break;
case AVMEDIA_TYPE_DATA:
video_bit_rate += st->codec->bit_rate;
break;
default:
abort();
}
}
avio_printf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
stream->fmt->name,
stream->bandwidth,
video_bit_rate / 1000, video_codec_name, video_codec_name_extra,
audio_bit_rate / 1000, audio_codec_name, audio_codec_name_extra);
if (stream->feed)
avio_printf(pb, "<td>%s", stream->feed->filename);
else
avio_printf(pb, "<td>%s", stream->feed_filename);
avio_printf(pb, "\n");
}
break;
default:
avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
break;
}
}
stream = stream->next;
}
avio_printf(pb, "</table>\n");
stream = first_stream;
while (stream != NULL) {
if (stream->feed == stream) {
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid);
#if defined(linux) && !defined(CONFIG_NOCUTILS)
{
FILE *pid_stat;
char ps_cmd[64];
snprintf(ps_cmd, sizeof(ps_cmd),
"ps -o \"%%cpu,cputime\" --no-headers %d",
stream->pid);
pid_stat = popen(ps_cmd, "r");
if (pid_stat) {
char cpuperc[10];
char cpuused[64];
if (fscanf(pid_stat, "%10s %64s", cpuperc,
cpuused) == 2) {
avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
cpuperc, cpuused);
}
fclose(pid_stat);
}
}
#endif
avio_printf(pb, "<p>");
}
avio_printf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
for (i = 0; i < stream->nb_streams; i++) {
AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
const char *type = "unknown";
char parameters[64];
parameters[0] = 0;
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
type = "audio";
snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate);
break;
case AVMEDIA_TYPE_VIDEO:
type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
break;
default:
abort();
}
avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
}
avio_printf(pb, "</table>\n");
}
stream = stream->next;
}
avio_printf(pb, "<h2>Connection Status</h2>\n");
avio_printf(pb, "Number of connections: %d / %d<br>\n",
nb_connections, nb_max_connections);
avio_printf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
current_bandwidth, max_bandwidth);
avio_printf(pb, "<table>\n");
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
c1 = first_http_ctx;
i = 0;
while (c1 != NULL) {
int bitrate;
int j;
bitrate = 0;
if (c1->stream) {
for (j = 0; j < c1->stream->nb_streams; j++) {
if (!c1->stream->feed)
bitrate += c1->stream->streams[j]->codec->bit_rate;
else if (c1->feed_streams[j] >= 0)
bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec->bit_rate;
}
}
i++;
p = inet_ntoa(c1->from_addr.sin_addr);
avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
i,
c1->stream ? c1->stream->filename : "",
c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
p,
c1->protocol,
http_state[c1->state]);
fmt_bytecount(pb, bitrate);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, c1->data_count);
avio_printf(pb, "\n");
c1 = c1->next;
}
avio_printf(pb, "</table>\n");
ti = time(NULL);
p = ctime(&ti);
avio_printf(pb, "<hr size=1 noshade>Generated at %s", p);
avio_printf(pb, "</body>\n</html>\n");
len = avio_close_dyn_buf(pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
c->buffer_end = c->pb_buffer + len;
}
| {
"code": [
" if (fscanf(pid_stat, \"%10s %64s\", cpuperc,"
],
"line_no": [
283
]
} | static void FUNC_0(HTTPContext *VAR_0)
{
HTTPContext *c1;
FFStream *stream;
char *VAR_1;
time_t ti;
int VAR_2, VAR_3;
AVIOContext *pb;
if (avio_open_dyn_buf(&pb) < 0) {
VAR_0->buffer_ptr = VAR_0->buffer;
VAR_0->buffer_end = VAR_0->buffer;
return;
}
avio_printf(pb, "HTTP/1.0 200 OK\r\n");
avio_printf(pb, "Content-type: %s\r\n", "text/html");
avio_printf(pb, "Pragma: no-cache\r\n");
avio_printf(pb, "\r\n");
avio_printf(pb, "<html><head><title>%s Status</title>\n", program_name);
if (VAR_0->stream->feed_filename[0])
avio_printf(pb, "<link rel=\"shortcut icon\" href=\"%s\">\n", VAR_0->stream->feed_filename);
avio_printf(pb, "</head>\n<body>");
avio_printf(pb, "<h1>%s Status</h1>\n", program_name);
avio_printf(pb, "<h2>Available Streams</h2>\n");
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n");
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n");
stream = first_stream;
while (stream != NULL) {
char VAR_4[1024];
char *VAR_5;
if (stream->feed != stream) {
av_strlcpy(VAR_4, stream->filename, sizeof(VAR_4) - 10);
VAR_5 = VAR_4 + strlen(VAR_4);
if (VAR_5 - VAR_4 >= 4) {
if (strcmp(VAR_5 - 4, ".asf") == 0)
strcpy(VAR_5 - 4, ".asx");
else if (strcmp(VAR_5 - 3, ".rm") == 0)
strcpy(VAR_5 - 3, ".ram");
else if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {
VAR_5 = strrchr(VAR_4, '.');
if (!VAR_5)
VAR_5 = VAR_4 + strlen(VAR_4);
if (stream->is_multicast)
strcpy(VAR_5, ".sdp");
else
strcpy(VAR_5, ".rtsp");
}
}
avio_printf(pb, "<tr><td><a href=\"/%s\">%s</a> ",
VAR_4, stream->filename);
avio_printf(pb, "<td align=right> %d <td align=right> ",
stream->conns_served);
fmt_bytecount(pb, stream->bytes_served);
switch(stream->stream_type) {
case STREAM_TYPE_LIVE: {
int VAR_6 = 0;
int VAR_7 = 0;
const char *VAR_8 = "";
const char *VAR_9 = "";
const char *VAR_10 = "";
const char *VAR_11 = "";
for(VAR_2=0;VAR_2<stream->nb_streams;VAR_2++) {
AVStream *st = stream->streams[VAR_2];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
VAR_6 += st->codec->bit_rate;
if (codec) {
if (*VAR_8)
VAR_10 = "...";
VAR_8 = codec->name;
}
break;
case AVMEDIA_TYPE_VIDEO:
VAR_7 += st->codec->bit_rate;
if (codec) {
if (*VAR_9)
VAR_11 = "...";
VAR_9 = codec->name;
}
break;
case AVMEDIA_TYPE_DATA:
VAR_7 += st->codec->bit_rate;
break;
default:
abort();
}
}
avio_printf(pb, "<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s",
stream->fmt->name,
stream->bandwidth,
VAR_7 / 1000, VAR_9, VAR_11,
VAR_6 / 1000, VAR_8, VAR_10);
if (stream->feed)
avio_printf(pb, "<td>%s", stream->feed->filename);
else
avio_printf(pb, "<td>%s", stream->feed_filename);
avio_printf(pb, "\n");
}
break;
default:
avio_printf(pb, "<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\n");
break;
}
}
stream = stream->next;
}
avio_printf(pb, "</table>\n");
stream = first_stream;
while (stream != NULL) {
if (stream->feed == stream) {
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid);
#if defined(linux) && !defined(CONFIG_NOCUTILS)
{
FILE *pid_stat;
char ps_cmd[64];
snprintf(ps_cmd, sizeof(ps_cmd),
"ps -o \"%%cpu,cputime\" --no-headers %d",
stream->pid);
pid_stat = popen(ps_cmd, "r");
if (pid_stat) {
char cpuperc[10];
char cpuused[64];
if (fscanf(pid_stat, "%10s %64s", cpuperc,
cpuused) == 2) {
avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n",
cpuperc, cpuused);
}
fclose(pid_stat);
}
}
#endif
avio_printf(pb, "<VAR_1>");
}
avio_printf(pb, "<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\n");
for (VAR_2 = 0; VAR_2 < stream->nb_streams; VAR_2++) {
AVStream *st = stream->streams[VAR_2];
AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
const char *type = "unknown";
char parameters[64];
parameters[0] = 0;
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
type = "audio";
snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate);
break;
case AVMEDIA_TYPE_VIDEO:
type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
break;
default:
abort();
}
avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
VAR_2, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
}
avio_printf(pb, "</table>\n");
}
stream = stream->next;
}
avio_printf(pb, "<h2>Connection Status</h2>\n");
avio_printf(pb, "Number of connections: %d / %d<br>\n",
nb_connections, nb_max_connections);
avio_printf(pb, "Bandwidth in use: %"PRIu64"k / %"PRIu64"k<br>\n",
current_bandwidth, max_bandwidth);
avio_printf(pb, "<table>\n");
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n");
c1 = first_http_ctx;
VAR_2 = 0;
while (c1 != NULL) {
int VAR_12;
int VAR_13;
VAR_12 = 0;
if (c1->stream) {
for (VAR_13 = 0; VAR_13 < c1->stream->nb_streams; VAR_13++) {
if (!c1->stream->feed)
VAR_12 += c1->stream->streams[VAR_13]->codec->bit_rate;
else if (c1->feed_streams[VAR_13] >= 0)
VAR_12 += c1->stream->feed->streams[c1->feed_streams[VAR_13]]->codec->bit_rate;
}
}
VAR_2++;
VAR_1 = inet_ntoa(c1->from_addr.sin_addr);
avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>",
VAR_2,
c1->stream ? c1->stream->filename : "",
c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
VAR_1,
c1->protocol,
http_state[c1->state]);
fmt_bytecount(pb, VAR_12);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);
avio_printf(pb, "<td align=right>");
fmt_bytecount(pb, c1->data_count);
avio_printf(pb, "\n");
c1 = c1->next;
}
avio_printf(pb, "</table>\n");
ti = time(NULL);
VAR_1 = ctime(&ti);
avio_printf(pb, "<hr size=1 noshade>Generated at %s", VAR_1);
avio_printf(pb, "</body>\n</html>\n");
VAR_3 = avio_close_dyn_buf(pb, &VAR_0->pb_buffer);
VAR_0->buffer_ptr = VAR_0->pb_buffer;
VAR_0->buffer_end = VAR_0->pb_buffer + VAR_3;
}
| [
"static void FUNC_0(HTTPContext *VAR_0)\n{",
"HTTPContext *c1;",
"FFStream *stream;",
"char *VAR_1;",
"time_t ti;",
"int VAR_2, VAR_3;",
"AVIOContext *pb;",
"if (avio_open_dyn_buf(&pb) < 0) {",
"VAR_0->buffer_ptr = VAR_0->buffer;",
"VAR_0->buffer_end = VAR_0->buffer;",
"return;",
"}",
"avio_printf(pb, \"HTTP/1.0 200 OK\\r\\n\");",
"avio_printf(pb, \"Content-type: %s\\r\\n\", \"text/html\");",
"avio_printf(pb, \"Pragma: no-cache\\r\\n\");",
"avio_printf(pb, \"\\r\\n\");",
"avio_printf(pb, \"<html><head><title>%s Status</title>\\n\", program_name);",
"if (VAR_0->stream->feed_filename[0])\navio_printf(pb, \"<link rel=\\\"shortcut icon\\\" href=\\\"%s\\\">\\n\", VAR_0->stream->feed_filename);",
"avio_printf(pb, \"</head>\\n<body>\");",
"avio_printf(pb, \"<h1>%s Status</h1>\\n\", program_name);",
"avio_printf(pb, \"<h2>Available Streams</h2>\\n\");",
"avio_printf(pb, \"<table cellspacing=0 cellpadding=4>\\n\");",
"avio_printf(pb, \"<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\\n\");",
"stream = first_stream;",
"while (stream != NULL) {",
"char VAR_4[1024];",
"char *VAR_5;",
"if (stream->feed != stream) {",
"av_strlcpy(VAR_4, stream->filename, sizeof(VAR_4) - 10);",
"VAR_5 = VAR_4 + strlen(VAR_4);",
"if (VAR_5 - VAR_4 >= 4) {",
"if (strcmp(VAR_5 - 4, \".asf\") == 0)\nstrcpy(VAR_5 - 4, \".asx\");",
"else if (strcmp(VAR_5 - 3, \".rm\") == 0)\nstrcpy(VAR_5 - 3, \".ram\");",
"else if (stream->fmt && !strcmp(stream->fmt->name, \"rtp\")) {",
"VAR_5 = strrchr(VAR_4, '.');",
"if (!VAR_5)\nVAR_5 = VAR_4 + strlen(VAR_4);",
"if (stream->is_multicast)\nstrcpy(VAR_5, \".sdp\");",
"else\nstrcpy(VAR_5, \".rtsp\");",
"}",
"}",
"avio_printf(pb, \"<tr><td><a href=\\\"/%s\\\">%s</a> \",\nVAR_4, stream->filename);",
"avio_printf(pb, \"<td align=right> %d <td align=right> \",\nstream->conns_served);",
"fmt_bytecount(pb, stream->bytes_served);",
"switch(stream->stream_type) {",
"case STREAM_TYPE_LIVE: {",
"int VAR_6 = 0;",
"int VAR_7 = 0;",
"const char *VAR_8 = \"\";",
"const char *VAR_9 = \"\";",
"const char *VAR_10 = \"\";",
"const char *VAR_11 = \"\";",
"for(VAR_2=0;VAR_2<stream->nb_streams;VAR_2++) {",
"AVStream *st = stream->streams[VAR_2];",
"AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);",
"switch(st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\nVAR_6 += st->codec->bit_rate;",
"if (codec) {",
"if (*VAR_8)\nVAR_10 = \"...\";",
"VAR_8 = codec->name;",
"}",
"break;",
"case AVMEDIA_TYPE_VIDEO:\nVAR_7 += st->codec->bit_rate;",
"if (codec) {",
"if (*VAR_9)\nVAR_11 = \"...\";",
"VAR_9 = codec->name;",
"}",
"break;",
"case AVMEDIA_TYPE_DATA:\nVAR_7 += st->codec->bit_rate;",
"break;",
"default:\nabort();",
"}",
"}",
"avio_printf(pb, \"<td align=center> %s <td align=right> %d <td align=right> %d <td> %s %s <td align=right> %d <td> %s %s\",\nstream->fmt->name,\nstream->bandwidth,\nVAR_7 / 1000, VAR_9, VAR_11,\nVAR_6 / 1000, VAR_8, VAR_10);",
"if (stream->feed)\navio_printf(pb, \"<td>%s\", stream->feed->filename);",
"else\navio_printf(pb, \"<td>%s\", stream->feed_filename);",
"avio_printf(pb, \"\\n\");",
"}",
"break;",
"default:\navio_printf(pb, \"<td align=center> - <td align=right> - <td align=right> - <td><td align=right> - <td>\\n\");",
"break;",
"}",
"}",
"stream = stream->next;",
"}",
"avio_printf(pb, \"</table>\\n\");",
"stream = first_stream;",
"while (stream != NULL) {",
"if (stream->feed == stream) {",
"avio_printf(pb, \"<h2>Feed %s</h2>\", stream->filename);",
"if (stream->pid) {",
"avio_printf(pb, \"Running as pid %d.\\n\", stream->pid);",
"#if defined(linux) && !defined(CONFIG_NOCUTILS)\n{",
"FILE *pid_stat;",
"char ps_cmd[64];",
"snprintf(ps_cmd, sizeof(ps_cmd),\n\"ps -o \\\"%%cpu,cputime\\\" --no-headers %d\",\nstream->pid);",
"pid_stat = popen(ps_cmd, \"r\");",
"if (pid_stat) {",
"char cpuperc[10];",
"char cpuused[64];",
"if (fscanf(pid_stat, \"%10s %64s\", cpuperc,\ncpuused) == 2) {",
"avio_printf(pb, \"Currently using %s%% of the cpu. Total time used %s.\\n\",\ncpuperc, cpuused);",
"}",
"fclose(pid_stat);",
"}",
"}",
"#endif\navio_printf(pb, \"<VAR_1>\");",
"}",
"avio_printf(pb, \"<table cellspacing=0 cellpadding=4><tr><th>Stream<th>type<th>kbits/s<th align=left>codec<th align=left>Parameters\\n\");",
"for (VAR_2 = 0; VAR_2 < stream->nb_streams; VAR_2++) {",
"AVStream *st = stream->streams[VAR_2];",
"AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);",
"const char *type = \"unknown\";",
"char parameters[64];",
"parameters[0] = 0;",
"switch(st->codec->codec_type) {",
"case AVMEDIA_TYPE_AUDIO:\ntype = \"audio\";",
"snprintf(parameters, sizeof(parameters), \"%d channel(s), %d Hz\", st->codec->channels, st->codec->sample_rate);",
"break;",
"case AVMEDIA_TYPE_VIDEO:\ntype = \"video\";",
"snprintf(parameters, sizeof(parameters), \"%dx%d, q=%d-%d, fps=%d\", st->codec->width, st->codec->height,\nst->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);",
"break;",
"default:\nabort();",
"}",
"avio_printf(pb, \"<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\\n\",\nVAR_2, type, st->codec->bit_rate/1000, codec ? codec->name : \"\", parameters);",
"}",
"avio_printf(pb, \"</table>\\n\");",
"}",
"stream = stream->next;",
"}",
"avio_printf(pb, \"<h2>Connection Status</h2>\\n\");",
"avio_printf(pb, \"Number of connections: %d / %d<br>\\n\",\nnb_connections, nb_max_connections);",
"avio_printf(pb, \"Bandwidth in use: %\"PRIu64\"k / %\"PRIu64\"k<br>\\n\",\ncurrent_bandwidth, max_bandwidth);",
"avio_printf(pb, \"<table>\\n\");",
"avio_printf(pb, \"<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\\n\");",
"c1 = first_http_ctx;",
"VAR_2 = 0;",
"while (c1 != NULL) {",
"int VAR_12;",
"int VAR_13;",
"VAR_12 = 0;",
"if (c1->stream) {",
"for (VAR_13 = 0; VAR_13 < c1->stream->nb_streams; VAR_13++) {",
"if (!c1->stream->feed)\nVAR_12 += c1->stream->streams[VAR_13]->codec->bit_rate;",
"else if (c1->feed_streams[VAR_13] >= 0)\nVAR_12 += c1->stream->feed->streams[c1->feed_streams[VAR_13]]->codec->bit_rate;",
"}",
"}",
"VAR_2++;",
"VAR_1 = inet_ntoa(c1->from_addr.sin_addr);",
"avio_printf(pb, \"<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td align=right>\",\nVAR_2,\nc1->stream ? c1->stream->filename : \"\",\nc1->state == HTTPSTATE_RECEIVE_DATA ? \"(input)\" : \"\",\nVAR_1,\nc1->protocol,\nhttp_state[c1->state]);",
"fmt_bytecount(pb, VAR_12);",
"avio_printf(pb, \"<td align=right>\");",
"fmt_bytecount(pb, compute_datarate(&c1->datarate, c1->data_count) * 8);",
"avio_printf(pb, \"<td align=right>\");",
"fmt_bytecount(pb, c1->data_count);",
"avio_printf(pb, \"\\n\");",
"c1 = c1->next;",
"}",
"avio_printf(pb, \"</table>\\n\");",
"ti = time(NULL);",
"VAR_1 = ctime(&ti);",
"avio_printf(pb, \"<hr size=1 noshade>Generated at %s\", VAR_1);",
"avio_printf(pb, \"</body>\\n</html>\\n\");",
"VAR_3 = avio_close_dyn_buf(pb, &VAR_0->pb_buffer);",
"VAR_0->buffer_ptr = VAR_0->pb_buffer;",
"VAR_0->buffer_end = VAR_0->pb_buffer + VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
33
],
[
35
],
[
37
],
[
39
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79,
81
],
[
83,
85
],
[
87
],
[
95
],
[
97,
99
],
[
101,
103
],
[
105,
107
],
[
109
],
[
111
],
[
115,
117
],
[
119,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
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
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
253,
255
],
[
257
],
[
259
],
[
265,
267,
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
283,
285
],
[
287,
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299,
303
],
[
305
],
[
307
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
323
],
[
327
],
[
329,
331
],
[
333
],
[
335
],
[
337,
339
],
[
341,
343
],
[
345
],
[
347,
349
],
[
351
],
[
353,
355
],
[
357
],
[
359
],
[
363
],
[
365
],
[
367
],
[
373
],
[
377,
379
],
[
383,
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
405
],
[
407
],
[
409
],
[
411,
413
],
[
415,
417
],
[
419
],
[
421
],
[
425
],
[
427
],
[
429,
431,
433,
435,
437,
439,
441
],
[
443
],
[
445
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
465
],
[
467
],
[
469
],
[
471
],
[
475
],
[
477
],
[
479
],
[
481
]
] |
1,343 | static void esp_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr >> s->it_shift) & (ESP_REGS - 1);
DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr],
val);
switch (saddr) {
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = val & 0xff;
} else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {
uint8_t buf;
buf = val & 0xff;
s->ti_size--;
fprintf(stderr, "esp: PIO data write not implemented\n");
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = val & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = val;
if (val & CMD_DMA) {
s->dma = 1;
/* Reload DMA counter. */
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
} else {
s->dma = 0;
}
switch(val & CMD_CMD) {
case CMD_NOP:
DPRINTF("NOP (%2.2x)\n", val);
break;
case CMD_FLUSH:
DPRINTF("Flush FIFO (%2.2x)\n", val);
//s->ti_size = 0;
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
DPRINTF("Chip reset (%2.2x)\n", val);
esp_reset(s);
break;
case CMD_BUSRESET:
DPRINTF("Bus reset (%2.2x)\n", val);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", val);
write_response(s);
break;
case CMD_MSGACC:
DPRINTF("Message Accepted (%2.2x)\n", val);
write_response(s);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
DPRINTF("Set ATN (%2.2x)\n", val);
break;
case CMD_SELATN:
DPRINTF("Set ATN (%2.2x)\n", val);
handle_satn(s);
break;
case CMD_SELATNS:
DPRINTF("Set ATN & stop (%2.2x)\n", val);
handle_satn_stop(s);
break;
case CMD_ENSEL:
DPRINTF("Enable selection (%2.2x)\n", val);
break;
default:
DPRINTF("Unhandled ESP command (%2.2x)\n", val);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
s->rregs[saddr] = val;
break;
case ESP_WCCF ... ESP_WTEST:
break;
case ESP_CFG2:
s->rregs[saddr] = val & CFG2_MASK;
break;
case ESP_CFG3 ... ESP_RES4:
s->rregs[saddr] = val;
break;
default:
break;
}
s->wregs[saddr] = val;
}
| true | qemu | 8dea1dd406189dae6108104faf27f397835ae871 | static void esp_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr >> s->it_shift) & (ESP_REGS - 1);
DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr],
val);
switch (saddr) {
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = val & 0xff;
} else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {
uint8_t buf;
buf = val & 0xff;
s->ti_size--;
fprintf(stderr, "esp: PIO data write not implemented\n");
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = val & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = val;
if (val & CMD_DMA) {
s->dma = 1;
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
} else {
s->dma = 0;
}
switch(val & CMD_CMD) {
case CMD_NOP:
DPRINTF("NOP (%2.2x)\n", val);
break;
case CMD_FLUSH:
DPRINTF("Flush FIFO (%2.2x)\n", val);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
DPRINTF("Chip reset (%2.2x)\n", val);
esp_reset(s);
break;
case CMD_BUSRESET:
DPRINTF("Bus reset (%2.2x)\n", val);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", val);
write_response(s);
break;
case CMD_MSGACC:
DPRINTF("Message Accepted (%2.2x)\n", val);
write_response(s);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
DPRINTF("Set ATN (%2.2x)\n", val);
break;
case CMD_SELATN:
DPRINTF("Set ATN (%2.2x)\n", val);
handle_satn(s);
break;
case CMD_SELATNS:
DPRINTF("Set ATN & stop (%2.2x)\n", val);
handle_satn_stop(s);
break;
case CMD_ENSEL:
DPRINTF("Enable selection (%2.2x)\n", val);
break;
default:
DPRINTF("Unhandled ESP command (%2.2x)\n", val);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
s->rregs[saddr] = val;
break;
case ESP_WCCF ... ESP_WTEST:
break;
case ESP_CFG2:
s->rregs[saddr] = val & CFG2_MASK;
break;
case ESP_CFG3 ... ESP_RES4:
s->rregs[saddr] = val;
break;
default:
break;
}
s->wregs[saddr] = val;
}
| {
"code": [
" } else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {",
" uint8_t buf;",
" buf = val & 0xff;",
" s->ti_size--;",
" fprintf(stderr, \"esp: PIO data write not implemented\\n\");",
" DPRINTF(\"Unhandled ESP command (%2.2x)\\n\", val);",
" break;"
],
"line_no": [
33,
35,
37,
39,
41,
173,
25
]
} | static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)
{
ESPState *s = VAR_0;
uint32_t saddr;
saddr = (VAR_1 >> s->it_shift) & (ESP_REGS - 1);
DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr],
VAR_2);
switch (saddr) {
case ESP_TCLO:
case ESP_TCMID:
s->rregs[ESP_RSTAT] &= ~STAT_TC;
break;
case ESP_FIFO:
if (s->do_cmd) {
s->cmdbuf[s->cmdlen++] = VAR_2 & 0xff;
} else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {
uint8_t buf;
buf = VAR_2 & 0xff;
s->ti_size--;
fprintf(stderr, "esp: PIO data write not implemented\n");
} else {
s->ti_size++;
s->ti_buf[s->ti_wptr++] = VAR_2 & 0xff;
}
break;
case ESP_CMD:
s->rregs[saddr] = VAR_2;
if (VAR_2 & CMD_DMA) {
s->dma = 1;
s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
} else {
s->dma = 0;
}
switch(VAR_2 & CMD_CMD) {
case CMD_NOP:
DPRINTF("NOP (%2.2x)\n", VAR_2);
break;
case CMD_FLUSH:
DPRINTF("Flush FIFO (%2.2x)\n", VAR_2);
s->rregs[ESP_RINTR] = INTR_FC;
s->rregs[ESP_RSEQ] = 0;
s->rregs[ESP_RFLAGS] = 0;
break;
case CMD_RESET:
DPRINTF("Chip reset (%2.2x)\n", VAR_2);
esp_reset(s);
break;
case CMD_BUSRESET:
DPRINTF("Bus reset (%2.2x)\n", VAR_2);
s->rregs[ESP_RINTR] = INTR_RST;
if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
esp_raise_irq(s);
}
break;
case CMD_TI:
handle_ti(s);
break;
case CMD_ICCS:
DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", VAR_2);
write_response(s);
break;
case CMD_MSGACC:
DPRINTF("Message Accepted (%2.2x)\n", VAR_2);
write_response(s);
s->rregs[ESP_RINTR] = INTR_DC;
s->rregs[ESP_RSEQ] = 0;
break;
case CMD_SATN:
DPRINTF("Set ATN (%2.2x)\n", VAR_2);
break;
case CMD_SELATN:
DPRINTF("Set ATN (%2.2x)\n", VAR_2);
handle_satn(s);
break;
case CMD_SELATNS:
DPRINTF("Set ATN & stop (%2.2x)\n", VAR_2);
handle_satn_stop(s);
break;
case CMD_ENSEL:
DPRINTF("Enable selection (%2.2x)\n", VAR_2);
break;
default:
DPRINTF("Unhandled ESP command (%2.2x)\n", VAR_2);
break;
}
break;
case ESP_WBUSID ... ESP_WSYNO:
break;
case ESP_CFG1:
s->rregs[saddr] = VAR_2;
break;
case ESP_WCCF ... ESP_WTEST:
break;
case ESP_CFG2:
s->rregs[saddr] = VAR_2 & CFG2_MASK;
break;
case ESP_CFG3 ... ESP_RES4:
s->rregs[saddr] = VAR_2;
break;
default:
break;
}
s->wregs[saddr] = VAR_2;
}
| [
"static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint32_t VAR_2)\n{",
"ESPState *s = VAR_0;",
"uint32_t saddr;",
"saddr = (VAR_1 >> s->it_shift) & (ESP_REGS - 1);",
"DPRINTF(\"write reg[%d]: 0x%2.2x -> 0x%2.2x\\n\", saddr, s->wregs[saddr],\nVAR_2);",
"switch (saddr) {",
"case ESP_TCLO:\ncase ESP_TCMID:\ns->rregs[ESP_RSTAT] &= ~STAT_TC;",
"break;",
"case ESP_FIFO:\nif (s->do_cmd) {",
"s->cmdbuf[s->cmdlen++] = VAR_2 & 0xff;",
"} else if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) {",
"uint8_t buf;",
"buf = VAR_2 & 0xff;",
"s->ti_size--;",
"fprintf(stderr, \"esp: PIO data write not implemented\\n\");",
"} else {",
"s->ti_size++;",
"s->ti_buf[s->ti_wptr++] = VAR_2 & 0xff;",
"}",
"break;",
"case ESP_CMD:\ns->rregs[saddr] = VAR_2;",
"if (VAR_2 & CMD_DMA) {",
"s->dma = 1;",
"s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];",
"s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];",
"} else {",
"s->dma = 0;",
"}",
"switch(VAR_2 & CMD_CMD) {",
"case CMD_NOP:\nDPRINTF(\"NOP (%2.2x)\\n\", VAR_2);",
"break;",
"case CMD_FLUSH:\nDPRINTF(\"Flush FIFO (%2.2x)\\n\", VAR_2);",
"s->rregs[ESP_RINTR] = INTR_FC;",
"s->rregs[ESP_RSEQ] = 0;",
"s->rregs[ESP_RFLAGS] = 0;",
"break;",
"case CMD_RESET:\nDPRINTF(\"Chip reset (%2.2x)\\n\", VAR_2);",
"esp_reset(s);",
"break;",
"case CMD_BUSRESET:\nDPRINTF(\"Bus reset (%2.2x)\\n\", VAR_2);",
"s->rregs[ESP_RINTR] = INTR_RST;",
"if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {",
"esp_raise_irq(s);",
"}",
"break;",
"case CMD_TI:\nhandle_ti(s);",
"break;",
"case CMD_ICCS:\nDPRINTF(\"Initiator Command Complete Sequence (%2.2x)\\n\", VAR_2);",
"write_response(s);",
"break;",
"case CMD_MSGACC:\nDPRINTF(\"Message Accepted (%2.2x)\\n\", VAR_2);",
"write_response(s);",
"s->rregs[ESP_RINTR] = INTR_DC;",
"s->rregs[ESP_RSEQ] = 0;",
"break;",
"case CMD_SATN:\nDPRINTF(\"Set ATN (%2.2x)\\n\", VAR_2);",
"break;",
"case CMD_SELATN:\nDPRINTF(\"Set ATN (%2.2x)\\n\", VAR_2);",
"handle_satn(s);",
"break;",
"case CMD_SELATNS:\nDPRINTF(\"Set ATN & stop (%2.2x)\\n\", VAR_2);",
"handle_satn_stop(s);",
"break;",
"case CMD_ENSEL:\nDPRINTF(\"Enable selection (%2.2x)\\n\", VAR_2);",
"break;",
"default:\nDPRINTF(\"Unhandled ESP command (%2.2x)\\n\", VAR_2);",
"break;",
"}",
"break;",
"case ESP_WBUSID ... ESP_WSYNO:\nbreak;",
"case ESP_CFG1:\ns->rregs[saddr] = VAR_2;",
"break;",
"case ESP_WCCF ... ESP_WTEST:\nbreak;",
"case ESP_CFG2:\ns->rregs[saddr] = VAR_2 & CFG2_MASK;",
"break;",
"case ESP_CFG3 ... ESP_RES4:\ns->rregs[saddr] = VAR_2;",
"break;",
"default:\nbreak;",
"}",
"s->wregs[saddr] = VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19,
21,
23
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81,
83
],
[
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
]
] |
1,344 | int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
FLACFrameInfo *fi)
{
int bs_code, sr_code, bps_code;
/* frame sync code */
skip_bits(gb, 16);
/* block size and sample rate codes */
bs_code = get_bits(gb, 4);
sr_code = get_bits(gb, 4);
/* channels and decorrelation */
fi->ch_mode = get_bits(gb, 4);
if (fi->ch_mode < FLAC_MAX_CHANNELS) {
fi->channels = fi->ch_mode + 1;
fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
} else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
fi->channels = 2;
} else {
av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode);
return -1;
}
/* bits per sample */
bps_code = get_bits(gb, 3);
if (bps_code == 3 || bps_code == 7) {
av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
bps_code);
return -1;
}
fi->bps = sample_size_table[bps_code];
/* reserved bit */
if (get_bits1(gb)) {
av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
return -1;
}
/* sample or frame count */
if (get_utf8(gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "utf8 fscked\n");
return -1;
}
/* blocksize */
if (bs_code == 0) {
av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
return -1;
} else if (bs_code == 6) {
fi->blocksize = get_bits(gb, 8) + 1;
} else if (bs_code == 7) {
fi->blocksize = get_bits(gb, 16) + 1;
} else {
fi->blocksize = ff_flac_blocksize_table[bs_code];
}
/* sample rate */
if (sr_code < 12) {
fi->samplerate = ff_flac_sample_rate_table[sr_code];
} else if (sr_code == 12) {
fi->samplerate = get_bits(gb, 8) * 1000;
} else if (sr_code == 13) {
fi->samplerate = get_bits(gb, 16);
} else if (sr_code == 14) {
fi->samplerate = get_bits(gb, 16) * 10;
} else {
av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
sr_code);
return -1;
}
/* header CRC-8 check */
skip_bits(gb, 8);
if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
get_bits_count(gb)/8)) {
av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n");
return -1;
}
return 0;
}
| false | FFmpeg | 7f4e432148779b338a6199f50eb70845c78fd060 | int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
FLACFrameInfo *fi)
{
int bs_code, sr_code, bps_code;
skip_bits(gb, 16);
bs_code = get_bits(gb, 4);
sr_code = get_bits(gb, 4);
fi->ch_mode = get_bits(gb, 4);
if (fi->ch_mode < FLAC_MAX_CHANNELS) {
fi->channels = fi->ch_mode + 1;
fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
} else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
fi->channels = 2;
} else {
av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode);
return -1;
}
bps_code = get_bits(gb, 3);
if (bps_code == 3 || bps_code == 7) {
av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
bps_code);
return -1;
}
fi->bps = sample_size_table[bps_code];
if (get_bits1(gb)) {
av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
return -1;
}
if (get_utf8(gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "utf8 fscked\n");
return -1;
}
if (bs_code == 0) {
av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
return -1;
} else if (bs_code == 6) {
fi->blocksize = get_bits(gb, 8) + 1;
} else if (bs_code == 7) {
fi->blocksize = get_bits(gb, 16) + 1;
} else {
fi->blocksize = ff_flac_blocksize_table[bs_code];
}
if (sr_code < 12) {
fi->samplerate = ff_flac_sample_rate_table[sr_code];
} else if (sr_code == 12) {
fi->samplerate = get_bits(gb, 8) * 1000;
} else if (sr_code == 13) {
fi->samplerate = get_bits(gb, 16);
} else if (sr_code == 14) {
fi->samplerate = get_bits(gb, 16) * 10;
} else {
av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
sr_code);
return -1;
}
skip_bits(gb, 8);
if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
get_bits_count(gb)/8)) {
av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n");
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,
FLACFrameInfo *VAR_2)
{
int VAR_3, VAR_4, VAR_5;
skip_bits(VAR_1, 16);
VAR_3 = get_bits(VAR_1, 4);
VAR_4 = get_bits(VAR_1, 4);
VAR_2->ch_mode = get_bits(VAR_1, 4);
if (VAR_2->ch_mode < FLAC_MAX_CHANNELS) {
VAR_2->channels = VAR_2->ch_mode + 1;
VAR_2->ch_mode = FLAC_CHMODE_INDEPENDENT;
} else if (VAR_2->ch_mode <= FLAC_CHMODE_MID_SIDE) {
VAR_2->channels = 2;
} else {
av_log(VAR_0, AV_LOG_ERROR, "invalid channel mode: %d\n", VAR_2->ch_mode);
return -1;
}
VAR_5 = get_bits(VAR_1, 3);
if (VAR_5 == 3 || VAR_5 == 7) {
av_log(VAR_0, AV_LOG_ERROR, "invalid sample size code (%d)\n",
VAR_5);
return -1;
}
VAR_2->bps = sample_size_table[VAR_5];
if (get_bits1(VAR_1)) {
av_log(VAR_0, AV_LOG_ERROR, "broken stream, invalid padding\n");
return -1;
}
if (get_utf8(VAR_1) < 0) {
av_log(VAR_0, AV_LOG_ERROR, "utf8 fscked\n");
return -1;
}
if (VAR_3 == 0) {
av_log(VAR_0, AV_LOG_ERROR, "reserved blocksize code: 0\n");
return -1;
} else if (VAR_3 == 6) {
VAR_2->blocksize = get_bits(VAR_1, 8) + 1;
} else if (VAR_3 == 7) {
VAR_2->blocksize = get_bits(VAR_1, 16) + 1;
} else {
VAR_2->blocksize = ff_flac_blocksize_table[VAR_3];
}
if (VAR_4 < 12) {
VAR_2->samplerate = ff_flac_sample_rate_table[VAR_4];
} else if (VAR_4 == 12) {
VAR_2->samplerate = get_bits(VAR_1, 8) * 1000;
} else if (VAR_4 == 13) {
VAR_2->samplerate = get_bits(VAR_1, 16);
} else if (VAR_4 == 14) {
VAR_2->samplerate = get_bits(VAR_1, 16) * 10;
} else {
av_log(VAR_0, AV_LOG_ERROR, "illegal sample rate code %d\n",
VAR_4);
return -1;
}
skip_bits(VAR_1, 8);
if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, VAR_1->buffer,
get_bits_count(VAR_1)/8)) {
av_log(VAR_0, AV_LOG_ERROR, "header crc mismatch\n");
return -1;
}
return 0;
}
| [
"int FUNC_0(AVCodecContext *VAR_0, GetBitContext *VAR_1,\nFLACFrameInfo *VAR_2)\n{",
"int VAR_3, VAR_4, VAR_5;",
"skip_bits(VAR_1, 16);",
"VAR_3 = get_bits(VAR_1, 4);",
"VAR_4 = get_bits(VAR_1, 4);",
"VAR_2->ch_mode = get_bits(VAR_1, 4);",
"if (VAR_2->ch_mode < FLAC_MAX_CHANNELS) {",
"VAR_2->channels = VAR_2->ch_mode + 1;",
"VAR_2->ch_mode = FLAC_CHMODE_INDEPENDENT;",
"} else if (VAR_2->ch_mode <= FLAC_CHMODE_MID_SIDE) {",
"VAR_2->channels = 2;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid channel mode: %d\\n\", VAR_2->ch_mode);",
"return -1;",
"}",
"VAR_5 = get_bits(VAR_1, 3);",
"if (VAR_5 == 3 || VAR_5 == 7) {",
"av_log(VAR_0, AV_LOG_ERROR, \"invalid sample size code (%d)\\n\",\nVAR_5);",
"return -1;",
"}",
"VAR_2->bps = sample_size_table[VAR_5];",
"if (get_bits1(VAR_1)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"broken stream, invalid padding\\n\");",
"return -1;",
"}",
"if (get_utf8(VAR_1) < 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"utf8 fscked\\n\");",
"return -1;",
"}",
"if (VAR_3 == 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"reserved blocksize code: 0\\n\");",
"return -1;",
"} else if (VAR_3 == 6) {",
"VAR_2->blocksize = get_bits(VAR_1, 8) + 1;",
"} else if (VAR_3 == 7) {",
"VAR_2->blocksize = get_bits(VAR_1, 16) + 1;",
"} else {",
"VAR_2->blocksize = ff_flac_blocksize_table[VAR_3];",
"}",
"if (VAR_4 < 12) {",
"VAR_2->samplerate = ff_flac_sample_rate_table[VAR_4];",
"} else if (VAR_4 == 12) {",
"VAR_2->samplerate = get_bits(VAR_1, 8) * 1000;",
"} else if (VAR_4 == 13) {",
"VAR_2->samplerate = get_bits(VAR_1, 16);",
"} else if (VAR_4 == 14) {",
"VAR_2->samplerate = get_bits(VAR_1, 16) * 10;",
"} else {",
"av_log(VAR_0, AV_LOG_ERROR, \"illegal sample rate code %d\\n\",\nVAR_4);",
"return -1;",
"}",
"skip_bits(VAR_1, 8);",
"if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, VAR_1->buffer,\nget_bits_count(VAR_1)/8)) {",
"av_log(VAR_0, AV_LOG_ERROR, \"header crc mismatch\\n\");",
"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
] | [
[
1,
3,
5
],
[
7
],
[
13
],
[
19
],
[
21
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51
],
[
53
],
[
55,
57
],
[
59
],
[
61
],
[
63
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137
],
[
139
],
[
141
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
157
],
[
161
],
[
163
]
] |
1,345 | static int64_t mkv_write_seekhead(AVIOContext *pb, MatroskaMuxContext *mkv)
{
AVIOContext *dyn_cp;
mkv_seekhead *seekhead = mkv->main_seekhead;
ebml_master metaseek, seekentry;
int64_t currentpos;
int i;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0) {
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
currentpos = -1;
goto fail;
}
}
if (start_ebml_master_crc32(pb, &dyn_cp, &metaseek, MATROSKA_ID_SEEKHEAD,
seekhead->reserved_size) < 0) {
currentpos = -1;
goto fail;
}
for (i = 0; i < seekhead->num_entries; i++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
seekentry = start_ebml_master(dyn_cp, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(dyn_cp, MATROSKA_ID_SEEKID);
put_ebml_num(dyn_cp, ebml_id_size(entry->elementid), 0);
put_ebml_id(dyn_cp, entry->elementid);
put_ebml_uint(dyn_cp, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(dyn_cp, seekentry);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
fail:
av_freep(&mkv->main_seekhead->entries);
av_freep(&mkv->main_seekhead);
return currentpos;
}
| false | FFmpeg | eabbc64728c2fdb74f565aededec2ab023d20699 | static int64_t mkv_write_seekhead(AVIOContext *pb, MatroskaMuxContext *mkv)
{
AVIOContext *dyn_cp;
mkv_seekhead *seekhead = mkv->main_seekhead;
ebml_master metaseek, seekentry;
int64_t currentpos;
int i;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0) {
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
currentpos = -1;
goto fail;
}
}
if (start_ebml_master_crc32(pb, &dyn_cp, &metaseek, MATROSKA_ID_SEEKHEAD,
seekhead->reserved_size) < 0) {
currentpos = -1;
goto fail;
}
for (i = 0; i < seekhead->num_entries; i++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
seekentry = start_ebml_master(dyn_cp, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(dyn_cp, MATROSKA_ID_SEEKID);
put_ebml_num(dyn_cp, ebml_id_size(entry->elementid), 0);
put_ebml_id(dyn_cp, entry->elementid);
put_ebml_uint(dyn_cp, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(dyn_cp, seekentry);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
fail:
av_freep(&mkv->main_seekhead->entries);
av_freep(&mkv->main_seekhead);
return currentpos;
}
| {
"code": [],
"line_no": []
} | static int64_t FUNC_0(AVIOContext *pb, MatroskaMuxContext *mkv)
{
AVIOContext *dyn_cp;
mkv_seekhead *seekhead = mkv->main_seekhead;
ebml_master metaseek, seekentry;
int64_t currentpos;
int VAR_0;
currentpos = avio_tell(pb);
if (seekhead->reserved_size > 0) {
if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
currentpos = -1;
goto fail;
}
}
if (start_ebml_master_crc32(pb, &dyn_cp, &metaseek, MATROSKA_ID_SEEKHEAD,
seekhead->reserved_size) < 0) {
currentpos = -1;
goto fail;
}
for (VAR_0 = 0; VAR_0 < seekhead->num_entries; VAR_0++) {
mkv_seekhead_entry *entry = &seekhead->entries[VAR_0];
seekentry = start_ebml_master(dyn_cp, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);
put_ebml_id(dyn_cp, MATROSKA_ID_SEEKID);
put_ebml_num(dyn_cp, ebml_id_size(entry->elementid), 0);
put_ebml_id(dyn_cp, entry->elementid);
put_ebml_uint(dyn_cp, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);
end_ebml_master(dyn_cp, seekentry);
}
end_ebml_master_crc32(pb, &dyn_cp, mkv, metaseek);
if (seekhead->reserved_size > 0) {
uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);
put_ebml_void(pb, remaining);
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
fail:
av_freep(&mkv->main_seekhead->entries);
av_freep(&mkv->main_seekhead);
return currentpos;
}
| [
"static int64_t FUNC_0(AVIOContext *pb, MatroskaMuxContext *mkv)\n{",
"AVIOContext *dyn_cp;",
"mkv_seekhead *seekhead = mkv->main_seekhead;",
"ebml_master metaseek, seekentry;",
"int64_t currentpos;",
"int VAR_0;",
"currentpos = avio_tell(pb);",
"if (seekhead->reserved_size > 0) {",
"if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {",
"currentpos = -1;",
"goto fail;",
"}",
"}",
"if (start_ebml_master_crc32(pb, &dyn_cp, &metaseek, MATROSKA_ID_SEEKHEAD,\nseekhead->reserved_size) < 0) {",
"currentpos = -1;",
"goto fail;",
"}",
"for (VAR_0 = 0; VAR_0 < seekhead->num_entries; VAR_0++) {",
"mkv_seekhead_entry *entry = &seekhead->entries[VAR_0];",
"seekentry = start_ebml_master(dyn_cp, MATROSKA_ID_SEEKENTRY, MAX_SEEKENTRY_SIZE);",
"put_ebml_id(dyn_cp, MATROSKA_ID_SEEKID);",
"put_ebml_num(dyn_cp, ebml_id_size(entry->elementid), 0);",
"put_ebml_id(dyn_cp, entry->elementid);",
"put_ebml_uint(dyn_cp, MATROSKA_ID_SEEKPOSITION, entry->segmentpos);",
"end_ebml_master(dyn_cp, seekentry);",
"}",
"end_ebml_master_crc32(pb, &dyn_cp, mkv, metaseek);",
"if (seekhead->reserved_size > 0) {",
"uint64_t remaining = seekhead->filepos + seekhead->reserved_size - avio_tell(pb);",
"put_ebml_void(pb, remaining);",
"avio_seek(pb, currentpos, SEEK_SET);",
"currentpos = seekhead->filepos;",
"}",
"fail:\nav_freep(&mkv->main_seekhead->entries);",
"av_freep(&mkv->main_seekhead);",
"return currentpos;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89,
91
],
[
93
],
[
97
],
[
99
]
] |